1 /* 2 * Copyright 2005-2009, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Michael Lotz <mmlr@mlotz.ch> 7 * Stephan Aßmus <superstippi@gmx.de> 8 */ 9 #ifndef D_WINDOW_HW_INTERACE_H 10 #define D_WINDOW_HW_INTERACE_H 11 12 13 #include "HWInterface.h" 14 15 #include <AutoDeleter.h> 16 #include <Accelerant.h> 17 #include <image.h> 18 #include <Region.h> 19 #include <String.h> 20 21 22 class DWindowBuffer; 23 class DWindow; 24 class UpdateQueue; 25 26 27 class DWindowHWInterface : public HWInterface { 28 public: 29 DWindowHWInterface(); 30 virtual ~DWindowHWInterface(); 31 32 virtual status_t Initialize(); 33 virtual status_t Shutdown(); 34 35 virtual status_t SetMode(const display_mode& mode); 36 virtual void GetMode(display_mode* mode); 37 38 virtual status_t GetDeviceInfo(accelerant_device_info* info); 39 virtual status_t GetFrameBufferConfig( 40 frame_buffer_config& config); 41 42 virtual status_t GetModeList(display_mode** _modeList, 43 uint32* _count); 44 virtual status_t GetPixelClockLimits(display_mode* mode, 45 uint32* _low, uint32* _high); 46 virtual status_t GetTimingConstraints(display_timing_constraints* 47 constraints); 48 virtual status_t ProposeMode(display_mode* candidate, 49 const display_mode* low, 50 const display_mode* high); 51 52 virtual sem_id RetraceSemaphore(); 53 virtual status_t WaitForRetrace( 54 bigtime_t timeout = B_INFINITE_TIMEOUT); 55 56 virtual status_t SetDPMSMode(uint32 state); 57 virtual uint32 DPMSMode(); 58 virtual uint32 DPMSCapabilities(); 59 60 virtual status_t SetBrightness(float); 61 virtual status_t GetBrightness(float*); 62 63 // query for available hardware accleration and perform it 64 virtual uint32 AvailableHWAcceleration() const; 65 66 virtual void CopyRegion(const clipping_rect* sortedRectList, 67 uint32 count, int32 xOffset, int32 yOffset); 68 virtual void FillRegion(/*const*/ BRegion& region, 69 const rgb_color& color, bool autoSync); 70 virtual void InvertRegion(/*const*/ BRegion& region); 71 72 virtual void Sync(); 73 74 // frame buffer access 75 virtual RenderingBuffer* FrontBuffer() const; 76 virtual RenderingBuffer* BackBuffer() const; 77 virtual bool IsDoubleBuffered() const; 78 79 virtual status_t Invalidate(const BRect& frame); 80 81 // DWindowHWInterface 82 void SetOffset(int32 left, int32 top); 83 84 private: 85 ObjectDeleter<DWindowBuffer> 86 fFrontBuffer; 87 88 DWindow* fWindow; 89 90 display_mode fDisplayMode; 91 int32 fXOffset; 92 int32 fYOffset; 93 94 // accelerant stuff 95 int _OpenGraphicsDevice(int deviceNumber); 96 status_t _OpenAccelerant(int device); 97 status_t _SetupDefaultHooks(); 98 status_t _UpdateFrameBufferConfig(); 99 100 void _RegionToRectParams(/*const*/ BRegion* region, 101 uint32* count) const; 102 uint32 _NativeColor(const rgb_color& color) const; 103 104 private: 105 int fCardFD; 106 image_id fAccelerantImage; 107 GetAccelerantHook fAccelerantHook; 108 engine_token* fEngineToken; 109 sync_token fSyncToken; 110 111 // required hooks - guaranteed to be valid 112 acquire_engine fAccAcquireEngine; 113 release_engine fAccReleaseEngine; 114 sync_to_token fAccSyncToToken; 115 accelerant_mode_count fAccGetModeCount; 116 get_mode_list fAccGetModeList; 117 get_frame_buffer_config fAccGetFrameBufferConfig; 118 set_display_mode fAccSetDisplayMode; 119 get_display_mode fAccGetDisplayMode; 120 get_pixel_clock_limits fAccGetPixelClockLimits; 121 122 // optional accelerant hooks 123 get_timing_constraints fAccGetTimingConstraints; 124 propose_display_mode fAccProposeDisplayMode; 125 fill_rectangle fAccFillRect; 126 invert_rectangle fAccInvertRect; 127 screen_to_screen_blit fAccScreenBlit; 128 set_cursor_shape fAccSetCursorShape; 129 move_cursor fAccMoveCursor; 130 show_cursor fAccShowCursor; 131 132 frame_buffer_config fFrameBufferConfig; 133 134 BString fCardNameInDevFS; 135 136 mutable fill_rect_params* fRectParams; 137 mutable uint32 fRectParamsCount; 138 mutable blit_params* fBlitParams; 139 mutable uint32 fBlitParamsCount; 140 }; 141 142 #endif // D_WINDOW_HW_INTERACE_H 143