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 40 virtual status_t GetDeviceInfo(accelerant_device_info* info); 41 virtual status_t GetFrameBufferConfig( 42 frame_buffer_config& config); 43 44 virtual status_t GetModeList(display_mode** _modeList, 45 uint32* _count); 46 virtual status_t GetPixelClockLimits(display_mode* mode, 47 uint32* _low, uint32* _high); 48 virtual status_t GetTimingConstraints( 49 display_timing_constraints* constraints); 50 virtual status_t ProposeMode(display_mode* candidate, 51 const display_mode* low, 52 const display_mode* high); 53 54 virtual sem_id RetraceSemaphore(); 55 virtual status_t WaitForRetrace( 56 bigtime_t timeout = B_INFINITE_TIMEOUT); 57 58 virtual status_t SetDPMSMode(uint32 state); 59 virtual uint32 DPMSMode(); 60 virtual uint32 DPMSCapabilities(); 61 62 // cursor handling 63 virtual void SetCursor(ServerCursor* cursor); 64 virtual void SetCursorVisible(bool visible); 65 virtual void MoveCursorTo(float x, float y); 66 virtual void SetDragBitmap(const ServerBitmap* bitmap, 67 const BPoint& offsetFormCursor); 68 69 // frame buffer access 70 virtual RenderingBuffer* FrontBuffer() const; 71 virtual RenderingBuffer* BackBuffer() const; 72 virtual bool IsDoubleBuffered() const; 73 74 virtual status_t InvalidateRegion(BRegion& region); 75 virtual status_t Invalidate(const BRect& frame); 76 virtual status_t CopyBackToFront(const BRect& frame); 77 78 // drawing engine interface 79 StreamingRingBuffer* ReceiveBuffer() { return fReceiveBuffer; } 80 StreamingRingBuffer* SendBuffer() { return fSendBuffer; } 81 82 typedef bool (*CallbackFunction)(void* cookie, RemoteMessage& message); 83 84 status_t AddCallback(uint32 token, 85 CallbackFunction callback, 86 void* cookie); 87 bool RemoveCallback(uint32 token); 88 89 private: 90 callback_info* _FindCallback(uint32 token); 91 static int _CallbackCompare(const uint32* key, 92 const callback_info* info); 93 94 static int32 _EventThreadEntry(void* data); 95 status_t _EventThread(); 96 97 status_t _Connect(); 98 void _Disconnect(); 99 100 const char* fTarget; 101 char* fRemoteHost; 102 uint32 fRemotePort; 103 104 status_t fInitStatus; 105 bool fIsConnected; 106 uint32 fProtocolVersion; 107 uint32 fConnectionSpeed; 108 display_mode fDisplayMode; 109 uint16 fListenPort; 110 111 BNetEndpoint* fSendEndpoint; 112 BNetEndpoint* fReceiveEndpoint; 113 114 StreamingRingBuffer* fSendBuffer; 115 StreamingRingBuffer* fReceiveBuffer; 116 117 NetSender* fSender; 118 NetReceiver* fReceiver; 119 120 thread_id fEventThread; 121 RemoteEventStream* fEventStream; 122 123 BLocker fCallbackLocker; 124 BObjectList<callback_info> fCallbacks; 125 }; 126 127 #endif // REMOTE_HW_INTERFACE_H 128