1c2784486SAxel Dörfler /*
289208c77SStephan Aßmus * Copyright 2007-2009, Haiku, Inc. All rights reserved.
3c2784486SAxel Dörfler * Distributed under the terms of the MIT License.
4c2784486SAxel Dörfler */
5d734a8ceSbeveloper #ifndef _SCREEN_H
6d734a8ceSbeveloper #define _SCREEN_H
7d734a8ceSbeveloper
8c2784486SAxel Dörfler
9d734a8ceSbeveloper #include <Accelerant.h>
10d734a8ceSbeveloper #include <GraphicsDefs.h>
11d734a8ceSbeveloper #include <Rect.h>
12d734a8ceSbeveloper #include <OS.h>
13d734a8ceSbeveloper
14d734a8ceSbeveloper
15f6e4cbb9SAxel Dörfler class BBitmap;
16d734a8ceSbeveloper class BWindow;
17d734a8ceSbeveloper
18c2784486SAxel Dörfler namespace BPrivate {
19c2784486SAxel Dörfler class BPrivateScreen;
20c2784486SAxel Dörfler }
21d734a8ceSbeveloper
2289208c77SStephan Aßmus
23d734a8ceSbeveloper class BScreen {
24d734a8ceSbeveloper public:
25d734a8ceSbeveloper BScreen(screen_id id = B_MAIN_SCREEN_ID);
26c2784486SAxel Dörfler BScreen(BWindow* window);
27d734a8ceSbeveloper ~BScreen();
28d734a8ceSbeveloper
29d734a8ceSbeveloper bool IsValid();
30d734a8ceSbeveloper status_t SetToNext();
31d734a8ceSbeveloper
32d734a8ceSbeveloper color_space ColorSpace();
33d734a8ceSbeveloper BRect Frame();
34d734a8ceSbeveloper screen_id ID();
35d734a8ceSbeveloper
36d734a8ceSbeveloper status_t WaitForRetrace();
37d734a8ceSbeveloper status_t WaitForRetrace(bigtime_t timeout);
38d734a8ceSbeveloper
39c2784486SAxel Dörfler uint8 IndexForColor(rgb_color color);
4089208c77SStephan Aßmus uint8 IndexForColor(uint8 red, uint8 green,
4189208c77SStephan Aßmus uint8 blue, uint8 alpha = 255);
42c2784486SAxel Dörfler rgb_color ColorForIndex(uint8 index);
43d734a8ceSbeveloper uint8 InvertIndex(uint8 index);
44d734a8ceSbeveloper
45d734a8ceSbeveloper const color_map* ColorMap();
46d734a8ceSbeveloper
4789208c77SStephan Aßmus status_t GetBitmap(BBitmap** _bitmap,
4889208c77SStephan Aßmus bool drawCursor = true,
49c2784486SAxel Dörfler BRect* frame = NULL);
5089208c77SStephan Aßmus status_t ReadBitmap(BBitmap* bitmap,
5189208c77SStephan Aßmus bool drawCursor = true,
52c2784486SAxel Dörfler BRect* frame = NULL);
53d734a8ceSbeveloper
54d734a8ceSbeveloper rgb_color DesktopColor();
551326b9d0SNiels Sascha Reedijk rgb_color DesktopColor(uint32 workspace);
5689208c77SStephan Aßmus void SetDesktopColor(rgb_color color,
571326b9d0SNiels Sascha Reedijk bool stick = true);
5889208c77SStephan Aßmus void SetDesktopColor(rgb_color color,
591326b9d0SNiels Sascha Reedijk uint32 workspace, bool stick = true);
60d734a8ceSbeveloper
6189208c77SStephan Aßmus status_t ProposeMode(display_mode* target,
6289208c77SStephan Aßmus const display_mode* low,
63c2784486SAxel Dörfler const display_mode* high);
6489208c77SStephan Aßmus status_t GetModeList(display_mode** _modeList,
6589208c77SStephan Aßmus uint32* _count);
661326b9d0SNiels Sascha Reedijk status_t GetMode(display_mode* mode);
6789208c77SStephan Aßmus status_t GetMode(uint32 workspace,
681326b9d0SNiels Sascha Reedijk display_mode* mode);
6989208c77SStephan Aßmus status_t SetMode(display_mode* mode,
7089208c77SStephan Aßmus bool makeDefault = false);
7189208c77SStephan Aßmus status_t SetMode(uint32 workspace,
7289208c77SStephan Aßmus display_mode* mode,
73c2784486SAxel Dörfler bool makeDefault = false);
74c2784486SAxel Dörfler status_t GetDeviceInfo(accelerant_device_info* info);
75c2784486SAxel Dörfler status_t GetMonitorInfo(monitor_info* info);
7689208c77SStephan Aßmus status_t GetPixelClockLimits(display_mode* mode,
771326b9d0SNiels Sascha Reedijk uint32* _low, uint32* _high);
78c2784486SAxel Dörfler status_t GetTimingConstraints(
7989208c77SStephan Aßmus display_timing_constraints*
8089208c77SStephan Aßmus timingConstraints);
81c2784486SAxel Dörfler status_t SetDPMS(uint32 state);
82c2784486SAxel Dörfler uint32 DPMSState();
83c2784486SAxel Dörfler uint32 DPMSCapabilites();
84d734a8ceSbeveloper
85*24e63de5SAdrien Destugues status_t GetBrightness(float* brightness);
86*24e63de5SAdrien Destugues status_t SetBrightness(float brightness);
873a2b67b5SAdrien Destugues
88d734a8ceSbeveloper private:
8989208c77SStephan Aßmus // Forbidden and deprecated methods
90c2784486SAxel Dörfler BScreen(const BScreen& other);
9189208c77SStephan Aßmus BScreen& operator=(const BScreen& other);
92c2784486SAxel Dörfler
93c2784486SAxel Dörfler BPrivate::BPrivateScreen* private_screen();
94c2784486SAxel Dörfler status_t ProposeDisplayMode(display_mode* target,
9589208c77SStephan Aßmus const display_mode* low,
9689208c77SStephan Aßmus const display_mode* high);
97d734a8ceSbeveloper void* BaseAddress();
98d734a8ceSbeveloper uint32 BytesPerRow();
99d734a8ceSbeveloper
10089208c77SStephan Aßmus private:
101c2784486SAxel Dörfler BPrivate::BPrivateScreen* fScreen;
102d734a8ceSbeveloper };
103d734a8ceSbeveloper
104d734a8ceSbeveloper
105c2784486SAxel Dörfler inline uint8
IndexForColor(rgb_color color)106c2784486SAxel Dörfler BScreen::IndexForColor(rgb_color color)
107c2784486SAxel Dörfler {
108c2784486SAxel Dörfler return IndexForColor(color.red, color.green, color.blue, color.alpha);
109c2784486SAxel Dörfler }
110d734a8ceSbeveloper
111c2784486SAxel Dörfler #endif // _SCREEN_H
112