blob: 79ba15de582a852df279345232204ea6322f17cd [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 Lin136fbbc2018-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 Lin0ac5f4e2018-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 Lin0ac5f4e2018-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>
Dominik Laskowskibf170d92018-04-19 15:08:05 -070042#include <string>
Mathias Agopian1f7bec62010-06-25 18:02:21 -070043
Mathias Agopiand8552d72012-08-04 21:39:11 -070044struct ANativeWindow;
45
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080046namespace android {
47
Jesse Hall646f5412014-08-07 22:19:07 -070048struct DisplayInfo;
Jesse Hall99c7dbb2013-03-14 14:29:29 -070049class DisplaySurface;
Dan Stoza9e56aa02015-11-02 13:00:03 -080050class Fence;
Jesse Hall9e663de2013-08-16 14:28:37 -070051class IGraphicBufferProducer;
Mathias Agopian13127d82013-03-05 17:47:11 -080052class Layer;
Mathias Agopian86303202012-07-24 22:46:10 -070053class SurfaceFlinger;
Mathias Agopianda27af92012-09-13 18:17:13 -070054class HWComposer;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080055
Mathias Agopian028a7572012-08-05 01:23:51 -070056class DisplayDevice : public LightRefBase<DisplayDevice>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080057{
58public:
Peiyong Linfb069302018-04-25 14:34:31 -070059 constexpr static float sDefaultMinLumiance = 0.0;
60 constexpr static float sDefaultMaxLumiance = 500.0;
61
Mathias Agopian87baae12012-07-31 12:38:26 -070062 // region in layer-stack space
63 mutable Region dirtyRegion;
64 // region in screen space
Mathias Agopian87baae12012-07-31 12:38:26 -070065 Region undefinedRegion;
Jesse Hallb7a05492014-08-14 15:45:06 -070066 bool lastCompositionHadVisibleLayers;
Mathias Agopian3eb38cb2012-04-03 22:09:52 -070067
Mathias Agopian3ee454a2012-08-27 16:28:24 -070068 enum DisplayType {
69 DISPLAY_ID_INVALID = -1,
70 DISPLAY_PRIMARY = HWC_DISPLAY_PRIMARY,
71 DISPLAY_EXTERNAL = HWC_DISPLAY_EXTERNAL,
Jesse Hall9e663de2013-08-16 14:28:37 -070072 DISPLAY_VIRTUAL = HWC_DISPLAY_VIRTUAL,
73 NUM_BUILTIN_DISPLAY_TYPES = HWC_NUM_PHYSICAL_DISPLAY_TYPES,
Mathias Agopian92a979a2012-08-02 18:32:23 -070074 };
75
76 enum {
Jesse Hall01e29052013-02-19 16:13:35 -080077 NO_LAYER_STACK = 0xFFFFFFFF,
78 };
79
Courtney Goeltzenleuchter5d943892017-03-22 13:46:46 -060080 // clang-format off
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -070081 DisplayDevice(
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080082 const sp<SurfaceFlinger>& flinger,
Jamie Gennisdd3cb842012-10-19 18:19:11 -070083 DisplayType type,
Dan Stoza9e56aa02015-11-02 13:00:03 -080084 int32_t hwcId,
Jamie Gennisdd3cb842012-10-19 18:19:11 -070085 bool isSecure,
86 const wp<IBinder>& displayToken,
Lloyd Pique09594832018-01-22 17:48:03 -080087 const sp<ANativeWindow>& nativeWindow,
Jesse Hall99c7dbb2013-03-14 14:29:29 -070088 const sp<DisplaySurface>& displaySurface,
Lloyd Pique09594832018-01-22 17:48:03 -080089 std::unique_ptr<RE::Surface> renderSurface,
90 int displayWidth,
91 int displayHeight,
Peiyong Lindd9b2ae2018-03-01 16:22:45 -080092 bool hasWideColorGamut,
Peiyong Lin62665892018-04-16 11:07:44 -070093 const HdrCapabilities& hdrCapabilities,
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -070094 const int32_t supportedPerFrameMetadata,
Chia-I Wube02ec02018-05-18 10:59:36 -070095 const std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>>& hwcColorModes,
Lloyd Pique09594832018-01-22 17:48:03 -080096 int initialPowerMode);
Courtney Goeltzenleuchter5d943892017-03-22 13:46:46 -060097 // clang-format on
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080098
Mathias Agopian028a7572012-08-05 01:23:51 -070099 ~DisplayDevice();
Mathias Agopian92a979a2012-08-02 18:32:23 -0700100
101 // whether this is a valid object. An invalid DisplayDevice is returned
102 // when an non existing id is requested
103 bool isValid() const;
104
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700105 // isSecure indicates whether this display can be trusted to display
106 // secure surfaces.
107 bool isSecure() const { return mIsSecure; }
108
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800109 // Flip the front and back buffers if the back buffer is "dirty". Might
110 // be instantaneous, might involve copying the frame buffer around.
Chia-I Wub02087d2017-11-09 10:19:54 -0800111 void flip() const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800112
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800113 int getWidth() const;
114 int getHeight() const;
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700115
Mathias Agopian13127d82013-03-05 17:47:11 -0800116 void setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers);
117 const Vector< sp<Layer> >& getVisibleLayersSortedByZ() const;
Chia-I Wu83806892017-11-16 10:50:20 -0800118 void setLayersNeedingFences(const Vector< sp<Layer> >& layers);
119 const Vector< sp<Layer> >& getLayersNeedingFences() const;
Mathias Agopiancd60f992012-08-16 16:28:27 -0700120 Region getDirtyRegion(bool repaintEverything) const;
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700121
Mathias Agopian28947d72012-08-08 18:51:15 -0700122 void setLayerStack(uint32_t stack);
Michael Lentine47e45402014-07-18 15:34:25 -0700123 void setDisplaySize(const int newWidth, const int newHeight);
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700124 void setProjection(int orientation, const Rect& viewport, const Rect& frame);
Mathias Agopian28947d72012-08-08 18:51:15 -0700125
Mathias Agopian1b031492012-06-20 17:51:20 -0700126 int getOrientation() const { return mOrientation; }
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700127 uint32_t getOrientationTransform() const;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700128 static uint32_t getPrimaryDisplayOrientationTransform();
Mathias Agopian1b031492012-06-20 17:51:20 -0700129 const Transform& getTransform() const { return mGlobalTransform; }
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800130 const Rect getViewport() const { return mViewport; }
131 const Rect getFrame() const { return mFrame; }
Mathias Agopian766dc492012-10-30 18:08:06 -0700132 const Rect& getScissor() const { return mScissor; }
Mathias Agopianeba8c682012-09-19 23:14:45 -0700133 bool needsFiltering() const { return mNeedsFiltering; }
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700134
Mathias Agopian87baae12012-07-31 12:38:26 -0700135 uint32_t getLayerStack() const { return mLayerStack; }
Mathias Agopian3ee454a2012-08-27 16:28:24 -0700136 int32_t getDisplayType() const { return mType; }
Chia-I Wuab0c3192017-08-01 11:29:00 -0700137 bool isPrimary() const { return mType == DISPLAY_PRIMARY; }
Dominik Laskowski281644e2018-04-19 15:47:35 -0700138 bool isVirtual() const { return mType == DISPLAY_VIRTUAL; }
Mathias Agopiane60b0682012-08-21 23:34:09 -0700139 int32_t getHwcDisplayId() const { return mHwcDisplayId; }
Mathias Agopian3ee454a2012-08-27 16:28:24 -0700140 const wp<IBinder>& getDisplayToken() const { return mDisplayToken; }
Mathias Agopian87baae12012-07-31 12:38:26 -0700141
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -0700142 int32_t getSupportedPerFrameMetadata() const { return mSupportedPerFrameMetadata; }
143
Dan Stoza71433162014-02-04 16:22:36 -0800144 // We pass in mustRecompose so we can keep VirtualDisplaySurface's state
145 // machine happy without actually queueing a buffer if nothing has changed
146 status_t beginFrame(bool mustRecompose) const;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800147 status_t prepareFrame(HWComposer& hwc);
Chia-I Wube02ec02018-05-18 10:59:36 -0700148
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800149 bool hasWideColorGamut() const { return mHasWideColorGamut; }
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700150 // Whether h/w composer has native support for specific HDR type.
Peiyong Lin62665892018-04-16 11:07:44 -0700151 bool hasHDR10Support() const { return mHasHdr10; }
152 bool hasHLGSupport() const { return mHasHLG; }
153 bool hasDolbyVisionSupport() const { return mHasDolbyVision; }
Chia-I Wube02ec02018-05-18 10:59:36 -0700154
155 // Return true if the corresponding color mode for the HDR dataspace is
156 // supported.
157 bool hasModernHdrSupport(ui::Dataspace dataspace) const;
158
Peiyong Linfb069302018-04-25 14:34:31 -0700159 // The returned HdrCapabilities is the combination of HDR capabilities from
160 // hardware composer and RenderEngine. When the DisplayDevice supports wide
161 // color gamut, RenderEngine is able to simulate HDR support in Display P3
162 // color space for both PQ and HLG HDR contents. The minimum and maximum
163 // luminance will be set to sDefaultMinLumiance and sDefaultMaxLumiance
164 // respectively if hardware composer doesn't return meaningful values.
165 const HdrCapabilities& getHdrCapabilities() const { return mHdrCapabilities; }
Jesse Hall38efe862013-04-06 23:12:29 -0700166
Chia-I Wube02ec02018-05-18 10:59:36 -0700167 // Return true if intent is supported by the display.
168 bool hasRenderIntent(ui::RenderIntent intent) const;
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700169
Chia-I Wube02ec02018-05-18 10:59:36 -0700170 void getBestColorMode(ui::Dataspace dataspace, ui::RenderIntent intent,
171 ui::Dataspace* outDataspace, ui::ColorMode* outMode,
172 ui::RenderIntent* outIntent) const;
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700173
Mathias Agopianda27af92012-09-13 18:17:13 -0700174 void swapBuffers(HWComposer& hwc) const;
Jesse Hall01e29052013-02-19 16:13:35 -0800175
Mathias Agopianda27af92012-09-13 18:17:13 -0700176 // called after h/w composer has completed its set() call
Dan Stoza9e56aa02015-11-02 13:00:03 -0800177 void onSwapBuffersCompleted() const;
Mathias Agopianda27af92012-09-13 18:17:13 -0700178
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700179 Rect getBounds() const {
Mathias Agopian1b031492012-06-20 17:51:20 -0700180 return Rect(mDisplayWidth, mDisplayHeight);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800181 }
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700182 inline Rect bounds() const { return getBounds(); }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800183
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700184 void setDisplayName(const std::string& displayName);
185 const std::string& getDisplayName() const { return mDisplayName; }
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700186
Chia-I Wuf846a352017-11-10 09:22:52 -0800187 bool makeCurrent() const;
Mathias Agopian875d8e12013-06-07 15:35:48 -0700188 void setViewportAndProjection() const;
Mathias Agopianbae92d02012-09-28 01:00:47 -0700189
Dan Stoza9e56aa02015-11-02 13:00:03 -0800190 const sp<Fence>& getClientTargetAcquireFence() const;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800191
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700192 /* ------------------------------------------------------------------------
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700193 * Display power mode management.
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700194 */
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700195 int getPowerMode() const;
196 void setPowerMode(int mode);
Dominik Laskowskieecd6592018-05-29 10:25:41 -0700197 bool isPoweredOn() const;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700198
Peiyong Linfd997e02018-03-28 15:29:00 -0700199 ui::ColorMode getActiveColorMode() const;
200 void setActiveColorMode(ui::ColorMode mode);
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800201 ui::RenderIntent getActiveRenderIntent() const;
202 void setActiveRenderIntent(ui::RenderIntent renderIntent);
Yiwei Zhang7c64f172018-03-07 14:52:28 -0800203 android_color_transform_t getColorTransform() const;
204 void setColorTransform(const mat4& transform);
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700205 void setCompositionDataSpace(ui::Dataspace dataspace);
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800206 ui::Dataspace getCompositionDataSpace() const;
Michael Wright28f24d02016-07-12 13:30:53 -0700207
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700208 /* ------------------------------------------------------------------------
209 * Display active config management.
210 */
211 int getActiveConfig() const;
212 void setActiveConfig(int mode);
213
Jesse Hall02d86562013-03-25 14:43:23 -0700214 // release HWC resources (if any) for removable displays
215 void disconnect(HWComposer& hwc);
216
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700217 /* ------------------------------------------------------------------------
218 * Debugging
219 */
220 uint32_t getPageFlipCount() const;
Mathias Agopian74d211a2013-04-22 16:55:35 +0200221 void dump(String8& result) const;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700222
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800223private:
Mathias Agopiana4912602012-07-12 14:25:33 -0700224 /*
225 * Constants, set during initialization
226 */
Mathias Agopianc7d14e22011-08-01 16:32:21 -0700227 sp<SurfaceFlinger> mFlinger;
Mathias Agopian3ee454a2012-08-27 16:28:24 -0700228 DisplayType mType;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700229 int32_t mHwcDisplayId;
Mathias Agopian3ee454a2012-08-27 16:28:24 -0700230 wp<IBinder> mDisplayToken;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700231
Mathias Agopiana4912602012-07-12 14:25:33 -0700232 // ANativeWindow this display is rendering into
Mathias Agopiand8552d72012-08-04 21:39:11 -0700233 sp<ANativeWindow> mNativeWindow;
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700234 sp<DisplaySurface> mDisplaySurface;
Mathias Agopiana4912602012-07-12 14:25:33 -0700235
Lloyd Pique144e1162017-12-20 16:44:52 -0800236 std::unique_ptr<RE::Surface> mSurface;
Mathias Agopian1b031492012-06-20 17:51:20 -0700237 int mDisplayWidth;
238 int mDisplayHeight;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700239 mutable uint32_t mPageFlipCount;
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700240 std::string mDisplayName;
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700241 bool mIsSecure;
Mathias Agopian03e40722012-04-26 16:11:59 -0700242
Mathias Agopiana4912602012-07-12 14:25:33 -0700243 /*
244 * Can only accessed from the main thread, these members
245 * don't need synchronization.
246 */
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700247
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700248 // list of visible layers on that display
Mathias Agopian13127d82013-03-05 17:47:11 -0800249 Vector< sp<Layer> > mVisibleLayersSortedByZ;
Chia-I Wu83806892017-11-16 10:50:20 -0800250 // list of layers needing fences
251 Vector< sp<Layer> > mLayersNeedingFences;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700252
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700253 /*
254 * Transaction state
255 */
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700256 static status_t orientationToTransfrom(int orientation,
257 int w, int h, Transform* tr);
258
Fabien Sanglardf0c53d62017-03-03 18:58:50 -0800259 // The identifier of the active layer stack for this display. Several displays
260 // can use the same layer stack: A z-ordered group of layers (sometimes called
261 // "surfaces"). Any given layer can only be on a single layer stack.
Mathias Agopian87baae12012-07-31 12:38:26 -0700262 uint32_t mLayerStack;
Fabien Sanglardf0c53d62017-03-03 18:58:50 -0800263
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700264 int mOrientation;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700265 static uint32_t sPrimaryDisplayOrientation;
Mathias Agopian766dc492012-10-30 18:08:06 -0700266 // user-provided visible area of the layer stack
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700267 Rect mViewport;
Mathias Agopian766dc492012-10-30 18:08:06 -0700268 // user-provided rectangle where mViewport gets mapped to
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700269 Rect mFrame;
Mathias Agopian766dc492012-10-30 18:08:06 -0700270 // pre-computed scissor to apply to the display
271 Rect mScissor;
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700272 Transform mGlobalTransform;
Mathias Agopianeba8c682012-09-19 23:14:45 -0700273 bool mNeedsFiltering;
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700274 // Current power mode
275 int mPowerMode;
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700276 // Current active config
277 int mActiveConfig;
Michael Wright28f24d02016-07-12 13:30:53 -0700278 // current active color mode
Chia-I Wu614e1422018-05-23 02:17:03 -0700279 ui::ColorMode mActiveColorMode = ui::ColorMode::NATIVE;
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800280 // Current active render intent.
Chia-I Wu614e1422018-05-23 02:17:03 -0700281 ui::RenderIntent mActiveRenderIntent = ui::RenderIntent::COLORIMETRIC;
282 ui::Dataspace mCompositionDataSpace = ui::Dataspace::UNKNOWN;
Yiwei Zhang7c64f172018-03-07 14:52:28 -0800283 // Current color transform
284 android_color_transform_t mColorTransform;
Courtney Goeltzenleuchter5d943892017-03-22 13:46:46 -0600285
286 // Need to know if display is wide-color capable or not.
287 // Initialized by SurfaceFlinger when the DisplayDevice is created.
288 // Fed to RenderEngine during composition.
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800289 bool mHasWideColorGamut;
290 bool mHasHdr10;
Peiyong Lin62665892018-04-16 11:07:44 -0700291 bool mHasHLG;
292 bool mHasDolbyVision;
Peiyong Linfb069302018-04-25 14:34:31 -0700293 HdrCapabilities mHdrCapabilities;
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -0700294 const int32_t mSupportedPerFrameMetadata;
Chia-I Wube02ec02018-05-18 10:59:36 -0700295
296 // Mappings from desired Dataspace/RenderIntent to the supported
297 // Dataspace/ColorMode/RenderIntent.
298 using ColorModeKey = uint64_t;
299 struct ColorModeValue {
300 ui::Dataspace dataspace;
301 ui::ColorMode colorMode;
302 ui::RenderIntent renderIntent;
303 };
304
305 static ColorModeKey getColorModeKey(ui::Dataspace dataspace, ui::RenderIntent intent) {
306 return (static_cast<uint64_t>(dataspace) << 32) | static_cast<uint32_t>(intent);
307 }
308 void populateColorModes(
309 const std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>>& hwcColorModes);
310 void addColorMode(
311 const std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>>& hwcColorModes,
312 const ui::ColorMode mode, const ui::RenderIntent intent);
313
314 std::unordered_map<ColorModeKey, ColorModeValue> mColorModes;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800315};
316
Irvelffc9efc2016-07-27 15:16:37 -0700317struct DisplayDeviceState {
Irvelffc9efc2016-07-27 15:16:37 -0700318 bool isValid() const { return type >= 0; }
Dominik Laskowski663bd282018-04-19 15:26:54 -0700319 bool isVirtual() const { return type >= DisplayDevice::DISPLAY_VIRTUAL; }
Irvelffc9efc2016-07-27 15:16:37 -0700320
Dominik Laskowski663bd282018-04-19 15:26:54 -0700321 int32_t sequenceId = sNextSequenceId++;
Irvelffc9efc2016-07-27 15:16:37 -0700322 DisplayDevice::DisplayType type = DisplayDevice::DISPLAY_ID_INVALID;
323 sp<IGraphicBufferProducer> surface;
324 uint32_t layerStack = DisplayDevice::NO_LAYER_STACK;
325 Rect viewport;
326 Rect frame;
327 uint8_t orientation = 0;
328 uint32_t width = 0;
329 uint32_t height = 0;
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700330 std::string displayName;
Irvelffc9efc2016-07-27 15:16:37 -0700331 bool isSecure = false;
Dominik Laskowski663bd282018-04-19 15:26:54 -0700332
333private:
334 static std::atomic<int32_t> sNextSequenceId;
Irvelffc9efc2016-07-27 15:16:37 -0700335};
336
chaviwa76b2712017-09-20 12:02:26 -0700337class DisplayRenderArea : public RenderArea {
338public:
339 DisplayRenderArea(const sp<const DisplayDevice> device,
340 ISurfaceComposer::Rotation rotation = ISurfaceComposer::eRotateNone)
341 : DisplayRenderArea(device, device->getBounds(), device->getHeight(), device->getWidth(),
342 rotation) {}
343 DisplayRenderArea(const sp<const DisplayDevice> device, Rect sourceCrop, uint32_t reqHeight,
344 uint32_t reqWidth, ISurfaceComposer::Rotation rotation)
chaviw50da5042018-04-09 13:49:37 -0700345 : RenderArea(reqHeight, reqWidth, CaptureFill::OPAQUE, rotation), mDevice(device),
346 mSourceCrop(sourceCrop) {}
chaviwa76b2712017-09-20 12:02:26 -0700347
348 const Transform& getTransform() const override { return mDevice->getTransform(); }
349 Rect getBounds() const override { return mDevice->getBounds(); }
350 int getHeight() const override { return mDevice->getHeight(); }
351 int getWidth() const override { return mDevice->getWidth(); }
352 bool isSecure() const override { return mDevice->isSecure(); }
353 bool needsFiltering() const override { return mDevice->needsFiltering(); }
354 Rect getSourceCrop() const override { return mSourceCrop; }
chaviwa76b2712017-09-20 12:02:26 -0700355
356private:
357 const sp<const DisplayDevice> mDevice;
358 const Rect mSourceCrop;
359};
360
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800361}; // namespace android
362
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700363#endif // ANDROID_DISPLAY_DEVICE_H