blob: 55b216679eb8dd3f6c1e2984a6e32452d97b6762 [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
maxwen80ee9662021-10-05 21:08:06 +020026#include <ui/DisplayMode.h>
maxwenad0a9222020-09-20 14:40:41 +020027#include <ui/DisplayState.h>
Steve Kondik6f9ab852017-07-09 21:30:20 -070028#include <ui/Rect.h>
29
30using namespace android;
Steve Kondik961b4cc2017-06-22 18:10:50 -070031
32namespace vncflinger {
33
Steve Kondik6f9ab852017-07-09 21:30:20 -070034class VirtualDisplay : public RefBase {
Steve Kondik961b4cc2017-06-22 18:10:50 -070035 public:
maxwen80ee9662021-10-05 21:08:06 +020036 VirtualDisplay(ui::DisplayMode *mode, ui::DisplayState* state,
maxwenad0a9222020-09-20 14:40:41 +020037 uint32_t width, uint32_t height,
Steve Kondik6f9ab852017-07-09 21:30:20 -070038 sp<CpuConsumer::FrameAvailableListener> listener);
Steve Kondik961b4cc2017-06-22 18:10:50 -070039
Steve Kondik6f9ab852017-07-09 21:30:20 -070040 virtual ~VirtualDisplay();
41
42 virtual Rect getDisplayRect();
43
44 virtual Rect getSourceRect() {
45 return mSourceRect;
46 }
47
48 CpuConsumer* getConsumer() {
49 return mCpuConsumer.get();
50 }
Steve Kondik961b4cc2017-06-22 18:10:50 -070051
52 private:
Steve Kondik6f9ab852017-07-09 21:30:20 -070053 float aspectRatio() {
54 return (float)mSourceRect.getHeight() / (float)mSourceRect.getWidth();
55 }
Steve Kondik961b4cc2017-06-22 18:10:50 -070056
57 // Producer side of queue, passed into the virtual display.
58 sp<IGraphicBufferProducer> mProducer;
59
60 // This receives frames from the virtual display and makes them available
61 sp<CpuConsumer> mCpuConsumer;
Steve Kondik6f9ab852017-07-09 21:30:20 -070062
63 // Virtual display
maxwen95dceef2019-12-07 12:00:17 +010064 sp<IBinder> mDisplayToken;
Steve Kondik6f9ab852017-07-09 21:30:20 -070065
66 sp<CpuConsumer::FrameAvailableListener> mListener;
67
68 uint32_t mWidth, mHeight;
69 Rect mSourceRect;
Steve Kondik961b4cc2017-06-22 18:10:50 -070070};
71};
Steve Kondik6f9ab852017-07-09 21:30:20 -070072#endif