1/*
2 * Copyright 2002-2009, Haiku Inc.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Stefano Ceccherini (burton666@libero.it)
7 *		Axel Dörfler, axeld@pinc-software.de
8 */
9#ifndef _PRIVATE_SCREEN_H_
10#define _PRIVATE_SCREEN_H_
11
12
13#include <Accelerant.h>
14#include <GraphicsDefs.h>
15#include <ObjectList.h>
16#include <Rect.h>
17
18
19struct color_map;
20class BBitmap;
21class BApplication;
22class BWindow;
23
24
25#define B_CURRENT_WORKSPACE_INDEX	(~0L)
26
27
28namespace BPrivate {
29
30class BPrivateScreen {
31public:
32	// Constructor and destructor are private. Use the static methods
33	// Get() and Put() instead.
34
35	static	BPrivateScreen*		Get(BWindow* window);
36	static	BPrivateScreen*		Get(int32 id);
37	static	void				Put(BPrivateScreen* screen);
38
39	static	BPrivateScreen*		GetNext(BPrivateScreen* screen);
40
41			bool				IsValid() const;
42			color_space			ColorSpace();
43			BRect				Frame();
44			int32				ID() const { return fID; }
45			status_t			GetNextID(int32& id);
46
47			status_t			WaitForRetrace(bigtime_t timeout);
48
49			uint8				IndexForColor(uint8 red, uint8 green,
50									uint8 blue, uint8 alpha);
51			rgb_color			ColorForIndex(const uint8 index);
52			uint8				InvertIndex(uint8 index);
53
54			const color_map*	ColorMap();
55
56			status_t			GetBitmap(BBitmap** bitmap, bool drawCursor,
57									BRect* bounds);
58			status_t			ReadBitmap(BBitmap* bitmap, bool drawCursor,
59									BRect* bounds);
60
61			rgb_color			DesktopColor(uint32 index);
62			void				SetDesktopColor(rgb_color, uint32, bool);
63
64			status_t			ProposeMode(display_mode* target,
65									const display_mode* low,
66									const display_mode* high);
67
68			status_t			GetModeList(display_mode** _modeList,
69									uint32* _count);
70			status_t			GetMode(uint32 workspace, display_mode* mode);
71			status_t			SetMode(uint32 workspace, display_mode* mode,
72									bool makeDefault);
73
74			status_t			GetDeviceInfo(accelerant_device_info* info);
75			status_t			GetMonitorInfo(monitor_info* info);
76			status_t			GetPixelClockLimits(display_mode* mode,
77									uint32* _low, uint32* _high);
78			status_t			GetTimingConstraints(
79									display_timing_constraints* constraints);
80
81			status_t			SetDPMS(uint32 dpmsState);
82			uint32				DPMSState();
83			uint32				DPMSCapabilites();
84
85			void*				BaseAddress();
86			uint32				BytesPerRow();
87
88private:
89	friend class BObjectList<BPrivateScreen>;
90
91								BPrivateScreen(int32 id);
92								~BPrivateScreen();
93
94			void				_Acquire();
95			bool				_Release();
96
97			sem_id				_RetraceSemaphore();
98			status_t			_GetFrameBufferConfig(
99									frame_buffer_config& config);
100
101	static	BPrivateScreen*		_Get(int32 id, bool check);
102	static	bool				_IsValid(int32 id);
103
104private:
105			int32				fID;
106			int32				fReferenceCount;
107			color_map*			fColorMap;
108			sem_id				fRetraceSem;
109			bool				fRetraceSemValid;
110			bool				fOwnsColorMap;
111			BRect				fFrame;
112			bigtime_t			fLastUpdate;
113};
114
115}	// namespace BPrivate
116
117#endif // _PRIVATE_SCREEN_H_
118