vfs: check userland buffers before reading them.
[haiku.git] / headers / private / interface / PrivateScreen.h
blob7f504a001caa404fcb6a1d4b11034ac33159d312
1 /*
2 * Copyright 2002-2009, Haiku Inc.
3 * Distributed under the terms of the MIT License.
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_
13 #include <Accelerant.h>
14 #include <GraphicsDefs.h>
15 #include <ObjectList.h>
16 #include <Rect.h>
19 struct color_map;
20 class BBitmap;
21 class BApplication;
22 class BWindow;
25 #define B_CURRENT_WORKSPACE_INDEX (~0L)
28 namespace BPrivate {
30 class BPrivateScreen {
31 public:
32 // Constructor and destructor are private. Use the static methods
33 // Get() and Put() instead.
35 static BPrivateScreen* Get(BWindow* window);
36 static BPrivateScreen* Get(int32 id);
37 static void Put(BPrivateScreen* screen);
39 static BPrivateScreen* GetNext(BPrivateScreen* screen);
41 bool IsValid() const;
42 color_space ColorSpace();
43 BRect Frame();
44 int32 ID() const { return fID; }
45 status_t GetNextID(int32& id);
47 status_t WaitForRetrace(bigtime_t timeout);
49 uint8 IndexForColor(uint8 red, uint8 green,
50 uint8 blue, uint8 alpha);
51 rgb_color ColorForIndex(const uint8 index);
52 uint8 InvertIndex(uint8 index);
54 const color_map* ColorMap();
56 status_t GetBitmap(BBitmap** bitmap, bool drawCursor,
57 BRect* bounds);
58 status_t ReadBitmap(BBitmap* bitmap, bool drawCursor,
59 BRect* bounds);
61 rgb_color DesktopColor(uint32 index);
62 void SetDesktopColor(rgb_color, uint32, bool);
64 status_t ProposeMode(display_mode* target,
65 const display_mode* low,
66 const display_mode* high);
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);
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);
81 status_t SetDPMS(uint32 dpmsState);
82 uint32 DPMSState();
83 uint32 DPMSCapabilites();
85 status_t GetBrightness(float*);
86 status_t SetBrightness(float);
88 void* BaseAddress();
89 uint32 BytesPerRow();
91 private:
92 friend class BObjectList<BPrivateScreen>;
94 BPrivateScreen(int32 id);
95 ~BPrivateScreen();
97 void _Acquire();
98 bool _Release();
100 sem_id _RetraceSemaphore();
101 status_t _GetFrameBufferConfig(
102 frame_buffer_config& config);
104 static BPrivateScreen* _Get(int32 id, bool check);
105 static bool _IsValid(int32 id);
107 private:
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;
118 } // namespace BPrivate
120 #endif // _PRIVATE_SCREEN_H_