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 | |
| 26 | #include <ui/DisplayInfo.h> |
| 27 | #include <ui/Rect.h> |
| 28 | |
| 29 | using namespace android; |
Steve Kondik | 961b4cc | 2017-06-22 18:10:50 -0700 | [diff] [blame] | 30 | |
| 31 | namespace vncflinger { |
| 32 | |
Steve Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 33 | class VirtualDisplay : public RefBase { |
Steve Kondik | 961b4cc | 2017-06-22 18:10:50 -0700 | [diff] [blame] | 34 | public: |
Steve Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 35 | VirtualDisplay(DisplayInfo* info, uint32_t width, uint32_t height, |
| 36 | sp<CpuConsumer::FrameAvailableListener> listener); |
Steve Kondik | 961b4cc | 2017-06-22 18:10:50 -0700 | [diff] [blame] | 37 | |
Steve Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 38 | 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 Kondik | 961b4cc | 2017-06-22 18:10:50 -0700 | [diff] [blame] | 49 | |
| 50 | private: |
Steve Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 51 | float aspectRatio() { |
| 52 | return (float)mSourceRect.getHeight() / (float)mSourceRect.getWidth(); |
| 53 | } |
Steve Kondik | 961b4cc | 2017-06-22 18:10:50 -0700 | [diff] [blame] | 54 | |
| 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 Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 60 | |
| 61 | // Virtual display |
| 62 | sp<IBinder> mDpy; |
| 63 | |
| 64 | sp<CpuConsumer::FrameAvailableListener> mListener; |
| 65 | |
| 66 | uint32_t mWidth, mHeight; |
| 67 | Rect mSourceRect; |
Steve Kondik | 961b4cc | 2017-06-22 18:10:50 -0700 | [diff] [blame] | 68 | }; |
| 69 | }; |
Steve Kondik | 6f9ab85 | 2017-07-09 21:30:20 -0700 | [diff] [blame] | 70 | #endif |