1 /* 2 * Copyright 2009, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Michael Lotz <mmlr@mlotz.ch> 7 */ 8 #ifndef REMOTE_HW_INTERFACE_H 9 #define REMOTE_HW_INTERFACE_H 10 11 #include "HWInterface.h" 12 13 #include <Locker.h> 14 #include <ObjectList.h> 15 16 class BNetEndpoint; 17 class StreamingRingBuffer; 18 class NetSender; 19 class NetReceiver; 20 class RemoteEventStream; 21 class RemoteMessage; 22 23 struct callback_info; 24 25 26 class RemoteHWInterface : public HWInterface { 27 public: 28 RemoteHWInterface(const char* target); 29 virtual ~RemoteHWInterface(); 30 31 virtual status_t Initialize(); 32 virtual status_t Shutdown(); 33 34 virtual DrawingEngine* CreateDrawingEngine(); 35 virtual EventStream* CreateEventStream(); 36 37 virtual status_t SetMode(const display_mode& mode); 38 virtual void GetMode(display_mode* mode); 39 virtual status_t GetPreferredMode(display_mode* mode); 40 41 virtual status_t GetDeviceInfo(accelerant_device_info* info); 42 virtual status_t GetFrameBufferConfig( 43 frame_buffer_config& config); 44 45 virtual status_t GetModeList(display_mode** _modeList, 46 uint32* _count); 47 virtual status_t GetPixelClockLimits(display_mode* mode, 48 uint32* _low, uint32* _high); 49 virtual status_t GetTimingConstraints( 50 display_timing_constraints* constraints); 51 virtual status_t ProposeMode(display_mode* candidate, 52 const display_mode* low, 53 const display_mode* high); 54 55 virtual sem_id RetraceSemaphore(); 56 virtual status_t WaitForRetrace( 57 bigtime_t timeout = B_INFINITE_TIMEOUT); 58 59 virtual status_t SetDPMSMode(uint32 state); 60 virtual uint32 DPMSMode(); 61 virtual uint32 DPMSCapabilities(); 62 63 virtual status_t SetBrightness(float); 64 virtual status_t GetBrightness(float*); 65 66 // cursor handling 67 virtual void SetCursor(ServerCursor* cursor); 68 virtual void SetCursorVisible(bool visible); 69 virtual void MoveCursorTo(float x, float y); 70 virtual void SetDragBitmap(const ServerBitmap* bitmap, 71 const BPoint& offsetFormCursor); 72 73 // frame buffer access 74 virtual RenderingBuffer* FrontBuffer() const; 75 virtual RenderingBuffer* BackBuffer() const; 76 virtual bool IsDoubleBuffered() const; 77 78 virtual status_t InvalidateRegion(BRegion& region); 79 virtual status_t Invalidate(const BRect& frame); 80 virtual status_t CopyBackToFront(const BRect& frame); 81 82 // drawing engine interface 83 StreamingRingBuffer* ReceiveBuffer() { return fReceiveBuffer; } 84 StreamingRingBuffer* SendBuffer() { return fSendBuffer; } 85 86 typedef bool (*CallbackFunction)(void* cookie, RemoteMessage& message); 87 88 status_t AddCallback(uint32 token, 89 CallbackFunction callback, 90 void* cookie); 91 bool RemoveCallback(uint32 token); 92 93 private: 94 callback_info* _FindCallback(uint32 token); 95 static int _CallbackCompare(const uint32* key, 96 const callback_info* info); 97 98 static int32 _EventThreadEntry(void* data); 99 status_t _EventThread(); 100 101 static status_t _NewConnectionCallback(void *cookie, 102 BNetEndpoint &endpoint); 103 status_t _NewConnection(BNetEndpoint &endpoint); 104 105 void _Disconnect(); 106 107 void _FillDisplayModeTiming(display_mode &mode); 108 109 const char* fTarget; 110 status_t fInitStatus; 111 bool fIsConnected; 112 uint32 fProtocolVersion; 113 uint32 fConnectionSpeed; 114 display_mode fFallbackMode; 115 display_mode fCurrentMode; 116 display_mode fClientMode; 117 uint16 fListenPort; 118 119 BNetEndpoint* fListenEndpoint; 120 StreamingRingBuffer* fSendBuffer; 121 StreamingRingBuffer* fReceiveBuffer; 122 123 NetSender* fSender; 124 NetReceiver* fReceiver; 125 126 thread_id fEventThread; 127 RemoteEventStream* fEventStream; 128 129 BLocker fCallbackLocker; 130 BObjectList<callback_info> fCallbacks; 131 }; 132 133 #endif // REMOTE_HW_INTERFACE_H 134