xref: /haiku/headers/os/game/DirectWindow.h (revision 5ac9b506412b11afb993bb52d161efe7666958a5)
1 /*
2  * Copyright 2001-2008 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Stefano Ceccherini <stefano.ceccherini@gmail.com>
7  */
8 #ifndef	_DIRECT_WINDOW_H
9 #define	_DIRECT_WINDOW_H
10 
11 
12 #include <Region.h>
13 #include <Window.h>
14 
15 
16 enum direct_buffer_state {
17 	B_DIRECT_MODE_MASK	= 15,
18 
19 	B_DIRECT_START		= 0,
20 	B_DIRECT_STOP		= 1,
21 	B_DIRECT_MODIFY		= 2,
22 
23 	B_CLIPPING_MODIFIED = 16,
24 	B_BUFFER_RESIZED 	= 32,
25 	B_BUFFER_MOVED 		= 64,
26 	B_BUFFER_RESET	 	= 128
27 };
28 
29 
30 enum direct_driver_state {
31 	B_DRIVER_CHANGED	= 0x0001,
32 	B_MODE_CHANGED		= 0x0002
33 };
34 
35 
36 typedef struct {
37 	direct_buffer_state	buffer_state;
38 	direct_driver_state	driver_state;
39 	void				*bits;
40 	void				*pci_bits;
41 	int32				bytes_per_row;
42 	uint32				bits_per_pixel;
43 	color_space			pixel_format;
44 	buffer_layout		layout;
45 	buffer_orientation	orientation;
46 	uint32				_reserved[9];
47 	uint32				_dd_type_;
48 	uint32				_dd_token_;
49 	uint32				clip_list_count;
50 	clipping_rect		window_bounds;
51 	clipping_rect		clip_bounds;
52 	clipping_rect		clip_list[1];
53 } direct_buffer_info;
54 
55 
56 class BDirectWindow : public BWindow {
57 public:
58 								BDirectWindow(BRect frame, const char* title,
59 									window_type type, uint32 flags,
60 									uint32 workspace = B_CURRENT_WORKSPACE);
61 								BDirectWindow(BRect frame, const char* title,
62 									window_look look, window_feel feel,
63 									uint32 flags,
64 									uint32 workspace = B_CURRENT_WORKSPACE);
65 	virtual						~BDirectWindow();
66 
67 	static	BArchivable*		Instantiate(BMessage* data);
68 	virtual	status_t			Archive(BMessage* data,
69 									bool deep = true) const;
70 
71 	virtual	void				Quit();
72 	virtual	void				DispatchMessage(BMessage* message,
73 									BHandler* handler);
74 	virtual	void				MessageReceived(BMessage* message);
75 	virtual	void				FrameMoved(BPoint newPosition);
76 	virtual	void				WorkspacesChanged(uint32 oldWorkspaces,
77 									uint32 newWorkspaces);
78 	virtual	void				WorkspaceActivated(int32 workspaceIndex,
79 									bool state);
80 	virtual	void				FrameResized(float newWidth, float newHeight);
81 	virtual	void				Minimize(bool minimize);
82 	virtual	void				Zoom(BPoint recPosition, float recWidth,
83 									float recHeight);
84 	virtual	void				ScreenChanged(BRect screenFrame,
85 									color_space depth);
86 	virtual	void				MenusBeginning();
87 	virtual	void				MenusEnded();
88 	virtual	void				WindowActivated(bool state);
89 	virtual	void				Show();
90 	virtual	void				Hide();
91 	virtual	BHandler*			ResolveSpecifier(BMessage* message,
92 									int32 index, BMessage* specifier,
93 									int32 what, const char* property);
94 	virtual	status_t			GetSupportedSuites(BMessage* data);
95 	virtual	status_t			Perform(perform_code code, void* arg);
96 
97 private:
98 	virtual	void				task_looper();
99 	virtual	BMessage*			ConvertToMessage(void* raw, int32 code);
100 
101 	public:
102 	virtual	void				DirectConnected(direct_buffer_info* info);
103 			status_t			GetClippingRegion(BRegion* region,
104 									BPoint* origin = NULL) const;
105 			status_t			SetFullScreen(bool enable);
106 			bool				IsFullScreen() const;
107 
108 	static	bool				SupportsWindowMode(
109 									screen_id id = B_MAIN_SCREEN_ID);
110 
111 private:
112 	typedef	BWindow				inherited;
113 
114 	virtual	void				_ReservedDirectWindow1();
115 	virtual	void				_ReservedDirectWindow2();
116 	virtual	void				_ReservedDirectWindow3();
117 	virtual	void				_ReservedDirectWindow4();
118 
119 								BDirectWindow();
120 								BDirectWindow(BDirectWindow& other);
121 			BDirectWindow&		operator=(BDirectWindow& other);
122 
123 	static	int32				_daemon_thread(void* arg);
124 			int32				_DirectDaemon();
125 			bool				_LockDirect() const;
126 			void				_UnlockDirect() const;
127 
128 			void				_InitData();
129 			void				_DisposeData();
130 
131 			bool				fDaemonKiller;
132 			bool				fConnectionEnable;
133 			bool				fIsFullScreen;
134 			bool				_unused;
135 			bool				fInDirectConnect;
136 
137 			int32				fDirectLock;
138 			sem_id				fDirectSem;
139 			uint32				fDirectLockCount;
140 			thread_id			fDirectLockOwner;
141 			char*				fDirectLockStack;
142 
143 			sem_id				fDisableSem;
144 			sem_id				fDisableSemAck;
145 
146 			uint32				fInitStatus;
147 			uint32				fInfoAreaSize;
148 
149 			uint32				_reserved[2];
150 
151 			area_id				fClonedClippingArea;
152 			area_id				fSourceClippingArea;
153 			thread_id			fDirectDaemonId;
154 			direct_buffer_info*	fBufferDesc;
155 
156 			uint32				_more_reserved_[17];
157 };
158 
159 
160 #endif	// _DIRECT_WINDOW_H
161