1 /* 2 * Copyright 2007-2009, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _SCREEN_H 6 #define _SCREEN_H 7 8 9 #include <Accelerant.h> 10 #include <GraphicsDefs.h> 11 #include <Rect.h> 12 #include <OS.h> 13 14 15 class BBitmap; 16 class BWindow; 17 18 namespace BPrivate { 19 class BPrivateScreen; 20 } 21 22 23 class BScreen { 24 public: 25 BScreen(screen_id id = B_MAIN_SCREEN_ID); 26 BScreen(BWindow* window); 27 ~BScreen(); 28 29 bool IsValid(); 30 status_t SetToNext(); 31 32 color_space ColorSpace(); 33 BRect Frame(); 34 screen_id ID(); 35 36 status_t WaitForRetrace(); 37 status_t WaitForRetrace(bigtime_t timeout); 38 39 uint8 IndexForColor(rgb_color color); 40 uint8 IndexForColor(uint8 red, uint8 green, 41 uint8 blue, uint8 alpha = 255); 42 rgb_color ColorForIndex(uint8 index); 43 uint8 InvertIndex(uint8 index); 44 45 const color_map* ColorMap(); 46 47 status_t GetBitmap(BBitmap** _bitmap, 48 bool drawCursor = true, 49 BRect* frame = NULL); 50 status_t ReadBitmap(BBitmap* bitmap, 51 bool drawCursor = true, 52 BRect* frame = NULL); 53 54 rgb_color DesktopColor(); 55 rgb_color DesktopColor(uint32 workspace); 56 void SetDesktopColor(rgb_color color, 57 bool stick = true); 58 void SetDesktopColor(rgb_color color, 59 uint32 workspace, bool stick = true); 60 61 status_t ProposeMode(display_mode* target, 62 const display_mode* low, 63 const display_mode* high); 64 status_t GetModeList(display_mode** _modeList, 65 uint32* _count); 66 status_t GetMode(display_mode* mode); 67 status_t GetMode(uint32 workspace, 68 display_mode* mode); 69 status_t SetMode(display_mode* mode, 70 bool makeDefault = false); 71 status_t SetMode(uint32 workspace, 72 display_mode* mode, 73 bool makeDefault = false); 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* 80 timingConstraints); 81 status_t SetDPMS(uint32 state); 82 uint32 DPMSState(); 83 uint32 DPMSCapabilites(); 84 85 status_t GetBrightness(float* brightness); 86 status_t SetBrightness(float brightness); 87 88 private: 89 // Forbidden and deprecated methods 90 BScreen(const BScreen& other); 91 BScreen& operator=(const BScreen& other); 92 93 BPrivate::BPrivateScreen* private_screen(); 94 status_t ProposeDisplayMode(display_mode* target, 95 const display_mode* low, 96 const display_mode* high); 97 void* BaseAddress(); 98 uint32 BytesPerRow(); 99 100 private: 101 BPrivate::BPrivateScreen* fScreen; 102 }; 103 104 105 inline uint8 106 BScreen::IndexForColor(rgb_color color) 107 { 108 return IndexForColor(color.red, color.green, color.blue, color.alpha); 109 } 110 111 #endif // _SCREEN_H 112