blob: 768c27c8974474fac0934c4bace1e5c72bfa0e83 [file] [log] [blame]
Steve Kondik961b4cc2017-06-22 18:10:50 -07001#ifndef ANDROID_DESKTOP_H_
2#define ANDROID_DESKTOP_H_
3
4#include <memory>
5
6#include <utils/Condition.h>
7#include <utils/Mutex.h>
8#include <utils/RefBase.h>
9#include <utils/Thread.h>
10
11#include <gui/CpuConsumer.h>
12
Steve Kondik6f9ab852017-07-09 21:30:20 -070013#include <ui/DisplayInfo.h>
14
Steve Kondik961b4cc2017-06-22 18:10:50 -070015#include <rfb/PixelBuffer.h>
16#include <rfb/SDesktop.h>
17#include <rfb/VNCServerST.h>
18
Steve Kondik6f9ab852017-07-09 21:30:20 -070019#include "AndroidPixelBuffer.h"
Steve Kondik961b4cc2017-06-22 18:10:50 -070020#include "InputDevice.h"
Steve Kondik6f9ab852017-07-09 21:30:20 -070021#include "VirtualDisplay.h"
Steve Kondik961b4cc2017-06-22 18:10:50 -070022
23using namespace android;
24
25namespace vncflinger {
26
Steve Kondik6f9ab852017-07-09 21:30:20 -070027class AndroidDesktop : public rfb::SDesktop,
28 public CpuConsumer::FrameAvailableListener,
29 public AndroidPixelBuffer::BufferDimensionsListener {
Steve Kondik961b4cc2017-06-22 18:10:50 -070030 public:
31 AndroidDesktop();
32
33 virtual ~AndroidDesktop();
34
35 virtual void start(rfb::VNCServer* vs);
36 virtual void stop();
37
38 virtual rfb::Point getFbSize();
39 virtual unsigned int setScreenLayout(int fb_width, int fb_height, const rfb::ScreenSet& layout);
40
41 virtual void keyEvent(rdr::U32 key, bool down);
42 virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
43
44 virtual void processFrames();
45
46 virtual int getEventFd() {
47 return mEventFd;
48 }
49
Steve Kondik6f9ab852017-07-09 21:30:20 -070050 virtual void onBufferDimensionsChanged(uint32_t width, uint32_t height);
51
52 virtual void onFrameAvailable(const BufferItem& item);
53
Steve Kondik961b4cc2017-06-22 18:10:50 -070054 private:
Steve Kondik961b4cc2017-06-22 18:10:50 -070055 virtual void notify();
56
Steve Kondik6f9ab852017-07-09 21:30:20 -070057 virtual status_t updateDisplayInfo();
Steve Kondik961b4cc2017-06-22 18:10:50 -070058
Steve Kondik961b4cc2017-06-22 18:10:50 -070059 Rect mDisplayRect;
60
Steve Kondik6f9ab852017-07-09 21:30:20 -070061 Mutex mLock;
Steve Kondik961b4cc2017-06-22 18:10:50 -070062
63 uint64_t mFrameNumber;
Steve Kondik961b4cc2017-06-22 18:10:50 -070064
65 int mEventFd;
66
Steve Kondik961b4cc2017-06-22 18:10:50 -070067 // Server instance
68 rfb::VNCServerST* mServer;
69
70 // Pixel buffer
71 sp<AndroidPixelBuffer> mPixels;
72
Steve Kondik6f9ab852017-07-09 21:30:20 -070073 // Virtual display controller
74 sp<VirtualDisplay> mVirtualDisplay;
75
Steve Kondik961b4cc2017-06-22 18:10:50 -070076 // Primary display
77 sp<IBinder> mMainDpy;
Steve Kondik6f9ab852017-07-09 21:30:20 -070078 DisplayInfo mDisplayInfo;
Steve Kondik961b4cc2017-06-22 18:10:50 -070079
80 // Virtual input device
81 sp<InputDevice> mInputDevice;
82};
83};
84
85#endif