blob: 883f53313a1f1483bd4049ae87250d1a32da11d2 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Mathias Agopiand3ee2312012-08-02 14:01:42 -070017#ifndef ANDROID_DISPLAY_DEVICE_H
18#define ANDROID_DISPLAY_DEVICE_H
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080019
Dan Stoza9e56aa02015-11-02 13:00:03 -080020#include "Transform.h"
21
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080022#include <stdlib.h>
Peiyong Lind6fa4a72018-04-17 15:09:44 -070023#include <unordered_map>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080024
Yiwei Zhang7c64f172018-03-07 14:52:28 -080025#include <math/mat4.h>
26
Dan Stoza9e56aa02015-11-02 13:00:03 -080027#include <binder/IBinder.h>
Peiyong Lin2c327ac2018-04-19 22:06:34 -070028#include <gui/ISurfaceComposer.h>
29#include <hardware/hwcomposer_defs.h>
30#include <ui/GraphicTypes.h>
Peiyong Linfb069302018-04-25 14:34:31 -070031#include <ui/HdrCapabilities.h>
Peiyong Lin2c327ac2018-04-19 22:06:34 -070032#include <ui/Region.h>
Dan Stoza9e56aa02015-11-02 13:00:03 -080033#include <utils/RefBase.h>
Mathias Agopian86303202012-07-24 22:46:10 -070034#include <utils/Mutex.h>
Mathias Agopian4f4f0942013-08-19 17:26:18 -070035#include <utils/String8.h>
Mathias Agopian86303202012-07-24 22:46:10 -070036#include <utils/Timers.h>
37
chaviwa76b2712017-09-20 12:02:26 -070038#include "RenderArea.h"
Chia-I Wuf846a352017-11-10 09:22:52 -080039#include "RenderEngine/Surface.h"
Mathias Agopianf4358632012-08-22 17:16:19 -070040
Dan Stoza9e56aa02015-11-02 13:00:03 -080041#include <memory>
Mathias Agopian1f7bec62010-06-25 18:02:21 -070042
Mathias Agopiand8552d72012-08-04 21:39:11 -070043struct ANativeWindow;
44
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080045namespace android {
46
Jesse Hall646f5412014-08-07 22:19:07 -070047struct DisplayInfo;
Jesse Hall99c7dbb2013-03-14 14:29:29 -070048class DisplaySurface;
Dan Stoza9e56aa02015-11-02 13:00:03 -080049class Fence;
Jesse Hall9e663de2013-08-16 14:28:37 -070050class IGraphicBufferProducer;
Mathias Agopian13127d82013-03-05 17:47:11 -080051class Layer;
Mathias Agopian86303202012-07-24 22:46:10 -070052class SurfaceFlinger;
Mathias Agopianda27af92012-09-13 18:17:13 -070053class HWComposer;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080054
Mathias Agopian028a7572012-08-05 01:23:51 -070055class DisplayDevice : public LightRefBase<DisplayDevice>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080056{
57public:
Peiyong Linfb069302018-04-25 14:34:31 -070058 constexpr static float sDefaultMinLumiance = 0.0;
59 constexpr static float sDefaultMaxLumiance = 500.0;
60
Mathias Agopian87baae12012-07-31 12:38:26 -070061 // region in layer-stack space
62 mutable Region dirtyRegion;
63 // region in screen space
Mathias Agopian87baae12012-07-31 12:38:26 -070064 Region undefinedRegion;
Jesse Hallb7a05492014-08-14 15:45:06 -070065 bool lastCompositionHadVisibleLayers;
Mathias Agopian3eb38cb2012-04-03 22:09:52 -070066
Mathias Agopian3ee454a2012-08-27 16:28:24 -070067 enum DisplayType {
68 DISPLAY_ID_INVALID = -1,
69 DISPLAY_PRIMARY = HWC_DISPLAY_PRIMARY,
70 DISPLAY_EXTERNAL = HWC_DISPLAY_EXTERNAL,
Jesse Hall9e663de2013-08-16 14:28:37 -070071 DISPLAY_VIRTUAL = HWC_DISPLAY_VIRTUAL,
72 NUM_BUILTIN_DISPLAY_TYPES = HWC_NUM_PHYSICAL_DISPLAY_TYPES,
Mathias Agopian92a979a2012-08-02 18:32:23 -070073 };
74
75 enum {
Jesse Hall01e29052013-02-19 16:13:35 -080076 NO_LAYER_STACK = 0xFFFFFFFF,
77 };
78
Courtney Goeltzenleuchter5d943892017-03-22 13:46:46 -060079 // clang-format off
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -070080 DisplayDevice(
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080081 const sp<SurfaceFlinger>& flinger,
Jamie Gennisdd3cb842012-10-19 18:19:11 -070082 DisplayType type,
Dan Stoza9e56aa02015-11-02 13:00:03 -080083 int32_t hwcId,
Jamie Gennisdd3cb842012-10-19 18:19:11 -070084 bool isSecure,
85 const wp<IBinder>& displayToken,
Lloyd Pique09594832018-01-22 17:48:03 -080086 const sp<ANativeWindow>& nativeWindow,
Jesse Hall99c7dbb2013-03-14 14:29:29 -070087 const sp<DisplaySurface>& displaySurface,
Lloyd Pique09594832018-01-22 17:48:03 -080088 std::unique_ptr<RE::Surface> renderSurface,
89 int displayWidth,
90 int displayHeight,
Peiyong Lindd9b2ae2018-03-01 16:22:45 -080091 bool hasWideColorGamut,
Peiyong Lin62665892018-04-16 11:07:44 -070092 const HdrCapabilities& hdrCapabilities,
Peiyong Lin2c327ac2018-04-19 22:06:34 -070093 const int32_t supportedPerFrameMetadata,
Peiyong Lind6fa4a72018-04-17 15:09:44 -070094 const std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>>& hdrAndRenderIntents,
Lloyd Pique09594832018-01-22 17:48:03 -080095 int initialPowerMode);
Courtney Goeltzenleuchter5d943892017-03-22 13:46:46 -060096 // clang-format on
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080097
Mathias Agopian028a7572012-08-05 01:23:51 -070098 ~DisplayDevice();
Mathias Agopian92a979a2012-08-02 18:32:23 -070099
100 // whether this is a valid object. An invalid DisplayDevice is returned
101 // when an non existing id is requested
102 bool isValid() const;
103
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700104 // isSecure indicates whether this display can be trusted to display
105 // secure surfaces.
106 bool isSecure() const { return mIsSecure; }
107
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800108 // Flip the front and back buffers if the back buffer is "dirty". Might
109 // be instantaneous, might involve copying the frame buffer around.
Chia-I Wub02087d2017-11-09 10:19:54 -0800110 void flip() const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800111
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800112 int getWidth() const;
113 int getHeight() const;
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700114
Mathias Agopian13127d82013-03-05 17:47:11 -0800115 void setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers);
116 const Vector< sp<Layer> >& getVisibleLayersSortedByZ() const;
Chia-I Wu83806892017-11-16 10:50:20 -0800117 void setLayersNeedingFences(const Vector< sp<Layer> >& layers);
118 const Vector< sp<Layer> >& getLayersNeedingFences() const;
Mathias Agopiancd60f992012-08-16 16:28:27 -0700119 Region getDirtyRegion(bool repaintEverything) const;
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700120
Mathias Agopian28947d72012-08-08 18:51:15 -0700121 void setLayerStack(uint32_t stack);
Michael Lentine47e45402014-07-18 15:34:25 -0700122 void setDisplaySize(const int newWidth, const int newHeight);
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700123 void setProjection(int orientation, const Rect& viewport, const Rect& frame);
Mathias Agopian28947d72012-08-08 18:51:15 -0700124
Mathias Agopian1b031492012-06-20 17:51:20 -0700125 int getOrientation() const { return mOrientation; }
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700126 uint32_t getOrientationTransform() const;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700127 static uint32_t getPrimaryDisplayOrientationTransform();
Mathias Agopian1b031492012-06-20 17:51:20 -0700128 const Transform& getTransform() const { return mGlobalTransform; }
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800129 const Rect getViewport() const { return mViewport; }
130 const Rect getFrame() const { return mFrame; }
Mathias Agopian766dc492012-10-30 18:08:06 -0700131 const Rect& getScissor() const { return mScissor; }
Mathias Agopianeba8c682012-09-19 23:14:45 -0700132 bool needsFiltering() const { return mNeedsFiltering; }
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700133
Mathias Agopian87baae12012-07-31 12:38:26 -0700134 uint32_t getLayerStack() const { return mLayerStack; }
Mathias Agopian3ee454a2012-08-27 16:28:24 -0700135 int32_t getDisplayType() const { return mType; }
Chia-I Wuab0c3192017-08-01 11:29:00 -0700136 bool isPrimary() const { return mType == DISPLAY_PRIMARY; }
Mathias Agopiane60b0682012-08-21 23:34:09 -0700137 int32_t getHwcDisplayId() const { return mHwcDisplayId; }
Mathias Agopian3ee454a2012-08-27 16:28:24 -0700138 const wp<IBinder>& getDisplayToken() const { return mDisplayToken; }
Mathias Agopian87baae12012-07-31 12:38:26 -0700139
Peiyong Lin2c327ac2018-04-19 22:06:34 -0700140 int32_t getSupportedPerFrameMetadata() const { return mSupportedPerFrameMetadata; }
141
Dan Stoza71433162014-02-04 16:22:36 -0800142 // We pass in mustRecompose so we can keep VirtualDisplaySurface's state
143 // machine happy without actually queueing a buffer if nothing has changed
144 status_t beginFrame(bool mustRecompose) const;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800145 status_t prepareFrame(HWComposer& hwc);
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800146 bool hasWideColorGamut() const { return mHasWideColorGamut; }
Peiyong Lind6fa4a72018-04-17 15:09:44 -0700147 // Whether h/w composer has native support for specific HDR type.
Peiyong Lin62665892018-04-16 11:07:44 -0700148 bool hasHDR10Support() const { return mHasHdr10; }
149 bool hasHLGSupport() const { return mHasHLG; }
150 bool hasDolbyVisionSupport() const { return mHasDolbyVision; }
Peiyong Linfb069302018-04-25 14:34:31 -0700151 // The returned HdrCapabilities is the combination of HDR capabilities from
152 // hardware composer and RenderEngine. When the DisplayDevice supports wide
153 // color gamut, RenderEngine is able to simulate HDR support in Display P3
154 // color space for both PQ and HLG HDR contents. The minimum and maximum
155 // luminance will be set to sDefaultMinLumiance and sDefaultMaxLumiance
156 // respectively if hardware composer doesn't return meaningful values.
157 const HdrCapabilities& getHdrCapabilities() const { return mHdrCapabilities; }
Jesse Hall38efe862013-04-06 23:12:29 -0700158
Peiyong Lind6fa4a72018-04-17 15:09:44 -0700159 // Whether h/w composer has BT2100_PQ color mode.
160 bool hasBT2100PQColorimetricSupport() const { return mHasBT2100PQColorimetric; }
161 bool hasBT2100PQEnhanceSupport() const { return mHasBT2100PQEnhance; }
162
163 // Whether h/w composer has BT2100_HLG color mode.
164 bool hasBT2100HLGColorimetricSupport() const { return mHasBT2100HLGColorimetric; }
165 bool hasBT2100HLGEnhanceSupport() const { return mHasBT2100HLGEnhance; }
166
Mathias Agopianda27af92012-09-13 18:17:13 -0700167 void swapBuffers(HWComposer& hwc) const;
Jesse Hall01e29052013-02-19 16:13:35 -0800168
Mathias Agopianda27af92012-09-13 18:17:13 -0700169 // called after h/w composer has completed its set() call
Dan Stoza9e56aa02015-11-02 13:00:03 -0800170 void onSwapBuffersCompleted() const;
Mathias Agopianda27af92012-09-13 18:17:13 -0700171
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700172 Rect getBounds() const {
Mathias Agopian1b031492012-06-20 17:51:20 -0700173 return Rect(mDisplayWidth, mDisplayHeight);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800174 }
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700175 inline Rect bounds() const { return getBounds(); }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800176
Mathias Agopian9e2463e2012-09-21 18:26:16 -0700177 void setDisplayName(const String8& displayName);
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700178 const String8& getDisplayName() const { return mDisplayName; }
179
Chia-I Wuf846a352017-11-10 09:22:52 -0800180 bool makeCurrent() const;
Mathias Agopian875d8e12013-06-07 15:35:48 -0700181 void setViewportAndProjection() const;
Mathias Agopianbae92d02012-09-28 01:00:47 -0700182
Dan Stoza9e56aa02015-11-02 13:00:03 -0800183 const sp<Fence>& getClientTargetAcquireFence() const;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800184
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700185 /* ------------------------------------------------------------------------
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700186 * Display power mode management.
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700187 */
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700188 int getPowerMode() const;
189 void setPowerMode(int mode);
190 bool isDisplayOn() const;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700191
Peiyong Linfd997e02018-03-28 15:29:00 -0700192 ui::ColorMode getActiveColorMode() const;
193 void setActiveColorMode(ui::ColorMode mode);
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800194 ui::RenderIntent getActiveRenderIntent() const;
195 void setActiveRenderIntent(ui::RenderIntent renderIntent);
Yiwei Zhang7c64f172018-03-07 14:52:28 -0800196 android_color_transform_t getColorTransform() const;
197 void setColorTransform(const mat4& transform);
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700198 void setCompositionDataSpace(ui::Dataspace dataspace);
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800199 ui::Dataspace getCompositionDataSpace() const;
Michael Wright28f24d02016-07-12 13:30:53 -0700200
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700201 /* ------------------------------------------------------------------------
202 * Display active config management.
203 */
204 int getActiveConfig() const;
205 void setActiveConfig(int mode);
206
Jesse Hall02d86562013-03-25 14:43:23 -0700207 // release HWC resources (if any) for removable displays
208 void disconnect(HWComposer& hwc);
209
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700210 /* ------------------------------------------------------------------------
211 * Debugging
212 */
213 uint32_t getPageFlipCount() const;
Mathias Agopian74d211a2013-04-22 16:55:35 +0200214 void dump(String8& result) const;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700215
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800216private:
Peiyong Lind6fa4a72018-04-17 15:09:44 -0700217 void hasToneMapping(const std::vector<ui::RenderIntent>& renderIntents,
218 bool* outColorimetric, bool *outEnhance);
219
Mathias Agopiana4912602012-07-12 14:25:33 -0700220 /*
221 * Constants, set during initialization
222 */
Mathias Agopianc7d14e22011-08-01 16:32:21 -0700223 sp<SurfaceFlinger> mFlinger;
Mathias Agopian3ee454a2012-08-27 16:28:24 -0700224 DisplayType mType;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700225 int32_t mHwcDisplayId;
Mathias Agopian3ee454a2012-08-27 16:28:24 -0700226 wp<IBinder> mDisplayToken;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700227
Mathias Agopiana4912602012-07-12 14:25:33 -0700228 // ANativeWindow this display is rendering into
Mathias Agopiand8552d72012-08-04 21:39:11 -0700229 sp<ANativeWindow> mNativeWindow;
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700230 sp<DisplaySurface> mDisplaySurface;
Mathias Agopiana4912602012-07-12 14:25:33 -0700231
Lloyd Pique144e1162017-12-20 16:44:52 -0800232 std::unique_ptr<RE::Surface> mSurface;
Mathias Agopian1b031492012-06-20 17:51:20 -0700233 int mDisplayWidth;
234 int mDisplayHeight;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700235 mutable uint32_t mPageFlipCount;
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700236 String8 mDisplayName;
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700237 bool mIsSecure;
Mathias Agopian03e40722012-04-26 16:11:59 -0700238
Mathias Agopiana4912602012-07-12 14:25:33 -0700239 /*
240 * Can only accessed from the main thread, these members
241 * don't need synchronization.
242 */
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700243
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700244 // list of visible layers on that display
Mathias Agopian13127d82013-03-05 17:47:11 -0800245 Vector< sp<Layer> > mVisibleLayersSortedByZ;
Chia-I Wu83806892017-11-16 10:50:20 -0800246 // list of layers needing fences
247 Vector< sp<Layer> > mLayersNeedingFences;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700248
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700249 /*
250 * Transaction state
251 */
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700252 static status_t orientationToTransfrom(int orientation,
253 int w, int h, Transform* tr);
254
Fabien Sanglardf0c53d62017-03-03 18:58:50 -0800255 // The identifier of the active layer stack for this display. Several displays
256 // can use the same layer stack: A z-ordered group of layers (sometimes called
257 // "surfaces"). Any given layer can only be on a single layer stack.
Mathias Agopian87baae12012-07-31 12:38:26 -0700258 uint32_t mLayerStack;
Fabien Sanglardf0c53d62017-03-03 18:58:50 -0800259
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700260 int mOrientation;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700261 static uint32_t sPrimaryDisplayOrientation;
Mathias Agopian766dc492012-10-30 18:08:06 -0700262 // user-provided visible area of the layer stack
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700263 Rect mViewport;
Mathias Agopian766dc492012-10-30 18:08:06 -0700264 // user-provided rectangle where mViewport gets mapped to
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700265 Rect mFrame;
Mathias Agopian766dc492012-10-30 18:08:06 -0700266 // pre-computed scissor to apply to the display
267 Rect mScissor;
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700268 Transform mGlobalTransform;
Mathias Agopianeba8c682012-09-19 23:14:45 -0700269 bool mNeedsFiltering;
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700270 // Current power mode
271 int mPowerMode;
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700272 // Current active config
273 int mActiveConfig;
Michael Wright28f24d02016-07-12 13:30:53 -0700274 // current active color mode
Chia-I Wu437efc22018-05-23 02:17:03 -0700275 ui::ColorMode mActiveColorMode = ui::ColorMode::NATIVE;
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800276 // Current active render intent.
Chia-I Wu437efc22018-05-23 02:17:03 -0700277 ui::RenderIntent mActiveRenderIntent = ui::RenderIntent::COLORIMETRIC;
278 ui::Dataspace mCompositionDataSpace = ui::Dataspace::UNKNOWN;
Yiwei Zhang7c64f172018-03-07 14:52:28 -0800279 // Current color transform
280 android_color_transform_t mColorTransform;
Courtney Goeltzenleuchter5d943892017-03-22 13:46:46 -0600281
282 // Need to know if display is wide-color capable or not.
283 // Initialized by SurfaceFlinger when the DisplayDevice is created.
284 // Fed to RenderEngine during composition.
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800285 bool mHasWideColorGamut;
286 bool mHasHdr10;
Peiyong Lin62665892018-04-16 11:07:44 -0700287 bool mHasHLG;
288 bool mHasDolbyVision;
Peiyong Linfb069302018-04-25 14:34:31 -0700289 HdrCapabilities mHdrCapabilities;
Peiyong Lin2c327ac2018-04-19 22:06:34 -0700290 const int32_t mSupportedPerFrameMetadata;
Peiyong Lind6fa4a72018-04-17 15:09:44 -0700291 // Whether h/w composer has BT2100_PQ and BT2100_HLG color mode with
292 // colorimetrical tone mapping or enhanced tone mapping.
293 bool mHasBT2100PQColorimetric;
294 bool mHasBT2100PQEnhance;
295 bool mHasBT2100HLGColorimetric;
296 bool mHasBT2100HLGEnhance;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800297};
298
Irvelffc9efc2016-07-27 15:16:37 -0700299struct DisplayDeviceState {
300 DisplayDeviceState() = default;
301 DisplayDeviceState(DisplayDevice::DisplayType type, bool isSecure);
302
303 bool isValid() const { return type >= 0; }
304 bool isMainDisplay() const { return type == DisplayDevice::DISPLAY_PRIMARY; }
305 bool isVirtualDisplay() const { return type >= DisplayDevice::DISPLAY_VIRTUAL; }
306
307 static std::atomic<int32_t> nextDisplayId;
308 int32_t displayId = nextDisplayId++;
309 DisplayDevice::DisplayType type = DisplayDevice::DISPLAY_ID_INVALID;
310 sp<IGraphicBufferProducer> surface;
311 uint32_t layerStack = DisplayDevice::NO_LAYER_STACK;
312 Rect viewport;
313 Rect frame;
314 uint8_t orientation = 0;
315 uint32_t width = 0;
316 uint32_t height = 0;
317 String8 displayName;
318 bool isSecure = false;
319};
320
chaviwa76b2712017-09-20 12:02:26 -0700321class DisplayRenderArea : public RenderArea {
322public:
323 DisplayRenderArea(const sp<const DisplayDevice> device,
324 ISurfaceComposer::Rotation rotation = ISurfaceComposer::eRotateNone)
325 : DisplayRenderArea(device, device->getBounds(), device->getHeight(), device->getWidth(),
326 rotation) {}
327 DisplayRenderArea(const sp<const DisplayDevice> device, Rect sourceCrop, uint32_t reqHeight,
328 uint32_t reqWidth, ISurfaceComposer::Rotation rotation)
chaviw50da5042018-04-09 13:49:37 -0700329 : RenderArea(reqHeight, reqWidth, CaptureFill::OPAQUE, rotation), mDevice(device),
330 mSourceCrop(sourceCrop) {}
chaviwa76b2712017-09-20 12:02:26 -0700331
332 const Transform& getTransform() const override { return mDevice->getTransform(); }
333 Rect getBounds() const override { return mDevice->getBounds(); }
334 int getHeight() const override { return mDevice->getHeight(); }
335 int getWidth() const override { return mDevice->getWidth(); }
336 bool isSecure() const override { return mDevice->isSecure(); }
337 bool needsFiltering() const override { return mDevice->needsFiltering(); }
338 Rect getSourceCrop() const override { return mSourceCrop; }
chaviwa76b2712017-09-20 12:02:26 -0700339
340private:
341 const sp<const DisplayDevice> mDevice;
342 const Rect mSourceCrop;
343};
344
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800345}; // namespace android
346
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700347#endif // ANDROID_DISPLAY_DEVICE_H