blob: 02a85c7025f0fa0a211f8a57ee2f2deda7688ceb [file] [log] [blame]
Steve Kondik6f9ab852017-07-09 21:30:20 -07001//
2// vncflinger - Copyright (C) 2017 Steve Kondik
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//
17
18#ifndef VIRTUAL_DISPLAY_H_
19#define VIRTUAL_DISPLAY_H_
20
21#include <utils/RefBase.h>
22
Steve Kondik961b4cc2017-06-22 18:10:50 -070023#include <gui/CpuConsumer.h>
Steve Kondik6f9ab852017-07-09 21:30:20 -070024#include <gui/IGraphicBufferProducer.h>
25
26#include <ui/DisplayInfo.h>
27#include <ui/Rect.h>
28
29using namespace android;
Steve Kondik961b4cc2017-06-22 18:10:50 -070030
31namespace vncflinger {
32
Steve Kondik6f9ab852017-07-09 21:30:20 -070033class VirtualDisplay : public RefBase {
Steve Kondik961b4cc2017-06-22 18:10:50 -070034 public:
Steve Kondik6f9ab852017-07-09 21:30:20 -070035 VirtualDisplay(DisplayInfo* info, uint32_t width, uint32_t height,
36 sp<CpuConsumer::FrameAvailableListener> listener);
Steve Kondik961b4cc2017-06-22 18:10:50 -070037
Steve Kondik6f9ab852017-07-09 21:30:20 -070038 virtual ~VirtualDisplay();
39
40 virtual Rect getDisplayRect();
41
42 virtual Rect getSourceRect() {
43 return mSourceRect;
44 }
45
46 CpuConsumer* getConsumer() {
47 return mCpuConsumer.get();
48 }
Steve Kondik961b4cc2017-06-22 18:10:50 -070049
50 private:
Steve Kondik6f9ab852017-07-09 21:30:20 -070051 float aspectRatio() {
52 return (float)mSourceRect.getHeight() / (float)mSourceRect.getWidth();
53 }
Steve Kondik961b4cc2017-06-22 18:10:50 -070054
55 // Producer side of queue, passed into the virtual display.
56 sp<IGraphicBufferProducer> mProducer;
57
58 // This receives frames from the virtual display and makes them available
59 sp<CpuConsumer> mCpuConsumer;
Steve Kondik6f9ab852017-07-09 21:30:20 -070060
61 // Virtual display
maxwen95dceef2019-12-07 12:00:17 +010062 sp<IBinder> mDisplayToken;
Steve Kondik6f9ab852017-07-09 21:30:20 -070063
64 sp<CpuConsumer::FrameAvailableListener> mListener;
65
66 uint32_t mWidth, mHeight;
67 Rect mSourceRect;
Steve Kondik961b4cc2017-06-22 18:10:50 -070068};
69};
Steve Kondik6f9ab852017-07-09 21:30:20 -070070#endif