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			status_t			GetBrightness(float*);
86			status_t			SetBrightness(float);
87
88			void*				BaseAddress();
89			uint32				BytesPerRow();
90
91private:
92	friend class BObjectList<BPrivateScreen>;
93
94								BPrivateScreen(int32 id);
95								~BPrivateScreen();
96
97			void				_Acquire();
98			bool				_Release();
99
100			sem_id				_RetraceSemaphore();
101			status_t			_GetFrameBufferConfig(
102									frame_buffer_config& config);
103
104	static	BPrivateScreen*		_Get(int32 id, bool check);
105	static	bool				_IsValid(int32 id);
106
107private:
108			int32				fID;
109			int32				fReferenceCount;
110			color_map*			fColorMap;
111			sem_id				fRetraceSem;
112			bool				fRetraceSemValid;
113			bool				fOwnsColorMap;
114			BRect				fFrame;
115			bigtime_t			fLastUpdate;
116};
117
118}	// namespace BPrivate
119
120#endif // _PRIVATE_SCREEN_H_
121