xref: /haiku/headers/os/game/DirectWindow.h (revision 93aeb8c3bc3f13cb1f282e3e749258a23790d947)
1 /*******************************************************************************
2 //
3 //	File:		DirectWindow.h
4 //
5 //	Description:	Client window class for direct screen access.
6 //
7 //	Copyright 1998, Be Incorporated, All Rights Reserved.
8 //
9 *******************************************************************************/
10 
11 
12 #ifndef	_DIRECT_WINDOW_H
13 #define	_DIRECT_WINDOW_H
14 
15 #include <Region.h>
16 #include <Window.h>
17 
18 class BDirectDriver;
19 
20 /* State of the direct access when called back through DirectConnected */
21 enum direct_buffer_state {
22 	B_DIRECT_MODE_MASK	= 15,
23 
24 	B_DIRECT_START		= 0,
25 	B_DIRECT_STOP		= 1,
26 	B_DIRECT_MODIFY		= 2,
27 
28 	B_CLIPPING_MODIFIED = 16,
29 	B_BUFFER_RESIZED 	= 32,
30 	B_BUFFER_MOVED 		= 64,
31 	B_BUFFER_RESET	 	= 128
32 };
33 
34 /* State of the direct driver and its hooks functions */
35 enum direct_driver_state {
36 	B_DRIVER_CHANGED	= 0x0001,
37 	B_MODE_CHANGED		= 0x0002
38 };
39 
40 /* Integer rect used to define a cliping rectangle. All bounds are included */
41 /* Moved to Region.h */
42 
43 /* Frame buffer access descriptor */
44 typedef struct {
45 	direct_buffer_state	buffer_state;
46 	direct_driver_state	driver_state;
47 	void				*bits;
48 	void				*pci_bits;
49 	int32				bytes_per_row;
50 	uint32				bits_per_pixel;
51 	color_space			pixel_format;
52 	buffer_layout		layout;
53 	buffer_orientation	orientation;
54 	uint32				_reserved[9];
55 	uint32				_dd_type_;
56 	uint32				_dd_token_;
57 	uint32				clip_list_count;
58 	clipping_rect		window_bounds;
59 	clipping_rect		clip_bounds;
60 	clipping_rect		clip_list[1];
61 } direct_buffer_info;
62 
63 /* BDirectWindow class */
64 class BDirectWindow : public BWindow {
65 public:
66 		BDirectWindow(	BRect		frame,
67 						const char	*title,
68 						window_type	type,
69 						uint32		flags,
70 						uint32		workspace = B_CURRENT_WORKSPACE);
71         BDirectWindow(	BRect		frame,
72 						const char	*title,
73 						window_look	look,
74 						window_feel feel,
75 						uint32		flags,
76 						uint32 		workspace = B_CURRENT_WORKSPACE);
77 virtual ~BDirectWindow();
78 static	BArchivable		*Instantiate(BMessage *data);
79 virtual	status_t		Archive(BMessage *data, bool deep = true) const;
80 
81 /* defined for future extension (fragile base class). Identical to BWindow */
82 virtual void        	Quit(void);
83 virtual	void			DispatchMessage(BMessage *message, BHandler *handler);
84 virtual	void			MessageReceived(BMessage *message);
85 virtual	void			FrameMoved(BPoint new_position);
86 virtual void			WorkspacesChanged(uint32 old_ws, uint32 new_ws);
87 virtual void			WorkspaceActivated(int32 ws, bool state);
88 virtual	void			FrameResized(float new_width, float new_height);
89 virtual void			Minimize(bool minimize);
90 virtual void			Zoom(	BPoint rec_position,
91 								float rec_width,
92 								float rec_height);
93 virtual void			ScreenChanged(BRect screen_size, color_space depth);
94 virtual	void			MenusBeginning();
95 virtual	void			MenusEnded();
96 virtual	void			WindowActivated(bool state);
97 virtual	void			Show();
98 virtual	void			Hide();
99 virtual BHandler		*ResolveSpecifier(BMessage *msg,
100 										int32 index,
101 										BMessage *specifier,
102 										int32 form,
103 										const char *property);
104 virtual status_t		GetSupportedSuites(BMessage *data);
105 virtual status_t		Perform(perform_code d, void *arg);
106 
107 private:
108 virtual	void			task_looper();
109 virtual BMessage		*ConvertToMessage(void *raw, int32 code);
110 
111 /* new APIs */
112 
113 public:
114 virtual void        	DirectConnected(direct_buffer_info *info);
115 		status_t		GetClippingRegion(BRegion *region, BPoint *origin = NULL) const;
116 		status_t		SetFullScreen(bool enable);
117 		bool			IsFullScreen() const;
118 
119 static	bool			SupportsWindowMode(screen_id = B_MAIN_SCREEN_ID);
120 
121 /* private */
122 private:
123 
124 		typedef BWindow	inherited;
125 
126 virtual void        	_ReservedDirectWindow1();
127 virtual void        	_ReservedDirectWindow2();
128 virtual void        	_ReservedDirectWindow3();
129 virtual void        	_ReservedDirectWindow4();
130 
131 
132 		BDirectWindow();
133 		BDirectWindow(BDirectWindow &);
134 		BDirectWindow &operator=(BDirectWindow &);
135 
136 		bool				deamon_killer;
137 		bool				connection_enable;
138 		bool				full_screen_enable;
139 		bool				direct_driver_ready;
140 		bool				in_direct_connect;
141 		int32				direct_lock;
142 		sem_id				direct_sem;
143 		uint32				direct_lock_count;
144 		thread_id			direct_lock_owner;
145 		char				*direct_lock_stack;
146 		sem_id				disable_sem;
147 		sem_id				disable_sem_ack;
148 		uint32				dw_init_status;
149 		uint32				info_area_size;
150 		uint32				direct_driver_type;
151 		uint32				direct_driver_token;
152 		area_id				cloned_clipping_area;
153 		area_id				source_clipping_area;
154 		thread_id			direct_deamon_id;
155 		direct_buffer_info	*buffer_desc;
156 		BDirectDriver		*direct_driver;
157 		struct priv_ext		*extension;
158 		uint32				_reserved_[15];
159 
160 static	int32				DirectDeamonFunc(void *arg);
161 		bool				LockDirect() const;
162 		void				UnlockDirect() const;
163 		void				InitData();
164 		void				DisposeData();
165 		status_t			DriverSetup() const;
166 };
167 
168 #endif
169