xref: /haiku/headers/os/game/DirectWindow.h (revision 3cb015b1ee509d69c643506e8ff573808c86dcfc)
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				fDaemonKiller;
137 		bool				fConnectionEnable;
138 		bool				fIsFullScreen;
139 		bool				fDirectDriverReady;
140 		bool				fInDirectConnect;
141 
142 		int32				fDirectLock;
143 		sem_id				fDirectSem;
144 		uint32				fDirectLockCount;
145 		thread_id			fDirectLockOwner;
146 		char				*fDirectLockStack;
147 
148 		sem_id				fDisableSem;
149 		sem_id				fDisableSemAck;
150 
151 		uint32				fInitStatus;
152 		uint32				fInfoAreaSize;
153 
154 		uint32				fDirectDriverType;
155 		uint32				fDirectDriverToken;
156 
157 		area_id				fClonedClippingArea;
158 		area_id				fSourceClippingArea;
159 		thread_id			fDirectDaemonId;
160 		direct_buffer_info		*fBufferDesc;
161 
162 		BDirectDriver			*direct_driver;
163 		struct priv_ext			*extension;
164 		uint32				_reserved_[15];
165 
166 	static	int32				_DaemonStarter(void *arg);
167 		int32				DirectDaemonFunc();
168 		bool				LockDirect() const;
169 		void				UnlockDirect() const;
170 		void				InitData();
171 		void				DisposeData();
172 		status_t			DriverSetup() const;
173 };
174 
175 #endif
176