blob: cd2356ede3dfdd906fdc7daa13929884c40c0699 [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
maxwenad0a9222020-09-20 14:40:41 +020026#include <ui/DisplayConfig.h>
Steve Kondik6f9ab852017-07-09 21:30:20 -070027#include <ui/DisplayInfo.h>
maxwenad0a9222020-09-20 14:40:41 +020028#include <ui/DisplayState.h>
Steve Kondik6f9ab852017-07-09 21:30:20 -070029#include <ui/Rect.h>
30
31using namespace android;
Steve Kondik961b4cc2017-06-22 18:10:50 -070032
33namespace vncflinger {
34
Steve Kondik6f9ab852017-07-09 21:30:20 -070035class VirtualDisplay : public RefBase {
Steve Kondik961b4cc2017-06-22 18:10:50 -070036 public:
maxwenad0a9222020-09-20 14:40:41 +020037 VirtualDisplay(DisplayConfig *config, ui::DisplayState* state,
38 uint32_t width, uint32_t height,
Steve Kondik6f9ab852017-07-09 21:30:20 -070039 sp<CpuConsumer::FrameAvailableListener> listener);
Steve Kondik961b4cc2017-06-22 18:10:50 -070040
Steve Kondik6f9ab852017-07-09 21:30:20 -070041 virtual ~VirtualDisplay();
42
43 virtual Rect getDisplayRect();
44
45 virtual Rect getSourceRect() {
46 return mSourceRect;
47 }
48
49 CpuConsumer* getConsumer() {
50 return mCpuConsumer.get();
51 }
Steve Kondik961b4cc2017-06-22 18:10:50 -070052
53 private:
Steve Kondik6f9ab852017-07-09 21:30:20 -070054 float aspectRatio() {
55 return (float)mSourceRect.getHeight() / (float)mSourceRect.getWidth();
56 }
Steve Kondik961b4cc2017-06-22 18:10:50 -070057
58 // Producer side of queue, passed into the virtual display.
59 sp<IGraphicBufferProducer> mProducer;
60
61 // This receives frames from the virtual display and makes them available
62 sp<CpuConsumer> mCpuConsumer;
Steve Kondik6f9ab852017-07-09 21:30:20 -070063
64 // Virtual display
maxwen95dceef2019-12-07 12:00:17 +010065 sp<IBinder> mDisplayToken;
Steve Kondik6f9ab852017-07-09 21:30:20 -070066
67 sp<CpuConsumer::FrameAvailableListener> mListener;
68
69 uint32_t mWidth, mHeight;
70 Rect mSourceRect;
Steve Kondik961b4cc2017-06-22 18:10:50 -070071};
72};
Steve Kondik6f9ab852017-07-09 21:30:20 -070073#endif