Steve Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 1 | // |
| 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 Kondik | 961b4cc | 2017-06-22 18:10:50 -0700 | [diff] [blame] | 23 | #include <gui/CpuConsumer.h> |
Steve Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 24 | #include <gui/IGraphicBufferProducer.h> |
| 25 | |
maxwen | 80ee966 | 2021-10-05 21:08:06 +0200 | [diff] [blame] | 26 | #include <ui/DisplayMode.h> |
maxwen | ad0a922 | 2020-09-20 14:40:41 +0200 | [diff] [blame] | 27 | #include <ui/DisplayState.h> |
Steve Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 28 | #include <ui/Rect.h> |
| 29 | |
| 30 | using namespace android; |
Steve Kondik | 961b4cc | 2017-06-22 18:10:50 -0700 | [diff] [blame] | 31 | |
| 32 | namespace vncflinger { |
| 33 | |
Steve Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 34 | class VirtualDisplay : public RefBase { |
Steve Kondik | 961b4cc | 2017-06-22 18:10:50 -0700 | [diff] [blame] | 35 | public: |
maxwen | 80ee966 | 2021-10-05 21:08:06 +0200 | [diff] [blame] | 36 | VirtualDisplay(ui::DisplayMode *mode, ui::DisplayState* state, |
maxwen | ad0a922 | 2020-09-20 14:40:41 +0200 | [diff] [blame] | 37 | uint32_t width, uint32_t height, |
Steve Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 38 | sp<CpuConsumer::FrameAvailableListener> listener); |
Steve Kondik | 961b4cc | 2017-06-22 18:10:50 -0700 | [diff] [blame] | 39 | |
Steve Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 40 | 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 Kondik | 961b4cc | 2017-06-22 18:10:50 -0700 | [diff] [blame] | 51 | |
| 52 | private: |
Steve Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 53 | float aspectRatio() { |
| 54 | return (float)mSourceRect.getHeight() / (float)mSourceRect.getWidth(); |
| 55 | } |
Steve Kondik | 961b4cc | 2017-06-22 18:10:50 -0700 | [diff] [blame] | 56 | |
| 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 Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 62 | |
| 63 | // Virtual display |
maxwen | 95dceef | 2019-12-07 12:00:17 +0100 | [diff] [blame] | 64 | sp<IBinder> mDisplayToken; |
Steve Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 65 | |
| 66 | sp<CpuConsumer::FrameAvailableListener> mListener; |
| 67 | |
| 68 | uint32_t mWidth, mHeight; |
| 69 | Rect mSourceRect; |
Steve Kondik | 961b4cc | 2017-06-22 18:10:50 -0700 | [diff] [blame] | 70 | }; |
| 71 | }; |
Steve Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 72 | #endif |