blob: 42909880c7c92aac57e96551ff51ce9ff1540afc [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
20#include <stdlib.h>
Peiyong Linefefaac2018-08-17 12:27:51 -070021
22#include <memory>
23#include <string>
Peiyong Lin136fbbc2018-04-17 15:09:44 -070024#include <unordered_map>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080025
Dan Stoza9e56aa02015-11-02 13:00:03 -080026#include <binder/IBinder.h>
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -070027#include <hardware/hwcomposer_defs.h>
Peiyong Linefefaac2018-08-17 12:27:51 -070028#include <math/mat4.h>
Peiyong Lincbc184f2018-08-22 13:24:10 -070029#include <renderengine/Surface.h>
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -070030#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>
Peiyong Linefefaac2018-08-17 12:27:51 -070033#include <ui/Transform.h>
Dan Stoza9e56aa02015-11-02 13:00:03 -080034#include <utils/RefBase.h>
Mathias Agopian86303202012-07-24 22:46:10 -070035#include <utils/Mutex.h>
Mathias Agopian4f4f0942013-08-19 17:26:18 -070036#include <utils/String8.h>
Mathias Agopian86303202012-07-24 22:46:10 -070037#include <utils/Timers.h>
38
chaviwa76b2712017-09-20 12:02:26 -070039#include "RenderArea.h"
Mathias Agopianf4358632012-08-22 17:16:19 -070040
Mathias Agopiand8552d72012-08-04 21:39:11 -070041struct ANativeWindow;
42
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080043namespace android {
44
Jesse Hall646f5412014-08-07 22:19:07 -070045struct DisplayInfo;
Jesse Hall99c7dbb2013-03-14 14:29:29 -070046class DisplaySurface;
Dan Stoza9e56aa02015-11-02 13:00:03 -080047class Fence;
Jesse Hall9e663de2013-08-16 14:28:37 -070048class IGraphicBufferProducer;
Mathias Agopian13127d82013-03-05 17:47:11 -080049class Layer;
Mathias Agopian86303202012-07-24 22:46:10 -070050class SurfaceFlinger;
Mathias Agopianda27af92012-09-13 18:17:13 -070051class HWComposer;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080052
Mathias Agopian028a7572012-08-05 01:23:51 -070053class DisplayDevice : public LightRefBase<DisplayDevice>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080054{
55public:
Peiyong Linfb069302018-04-25 14:34:31 -070056 constexpr static float sDefaultMinLumiance = 0.0;
57 constexpr static float sDefaultMaxLumiance = 500.0;
58
Mathias Agopian87baae12012-07-31 12:38:26 -070059 // region in layer-stack space
60 mutable Region dirtyRegion;
61 // region in screen space
Mathias Agopian87baae12012-07-31 12:38:26 -070062 Region undefinedRegion;
Jesse Hallb7a05492014-08-14 15:45:06 -070063 bool lastCompositionHadVisibleLayers;
Mathias Agopian3eb38cb2012-04-03 22:09:52 -070064
Mathias Agopian3ee454a2012-08-27 16:28:24 -070065 enum DisplayType {
66 DISPLAY_ID_INVALID = -1,
67 DISPLAY_PRIMARY = HWC_DISPLAY_PRIMARY,
68 DISPLAY_EXTERNAL = HWC_DISPLAY_EXTERNAL,
Jesse Hall9e663de2013-08-16 14:28:37 -070069 DISPLAY_VIRTUAL = HWC_DISPLAY_VIRTUAL,
70 NUM_BUILTIN_DISPLAY_TYPES = HWC_NUM_PHYSICAL_DISPLAY_TYPES,
Mathias Agopian92a979a2012-08-02 18:32:23 -070071 };
72
73 enum {
Jesse Hall01e29052013-02-19 16:13:35 -080074 NO_LAYER_STACK = 0xFFFFFFFF,
75 };
76
Courtney Goeltzenleuchter5d943892017-03-22 13:46:46 -060077 // clang-format off
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -070078 DisplayDevice(
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080079 const sp<SurfaceFlinger>& flinger,
Jamie Gennisdd3cb842012-10-19 18:19:11 -070080 DisplayType type,
Dominik Laskowski7e045462018-05-30 13:02:02 -070081 int32_t id,
Jamie Gennisdd3cb842012-10-19 18:19:11 -070082 bool isSecure,
83 const wp<IBinder>& displayToken,
Lloyd Pique09594832018-01-22 17:48:03 -080084 const sp<ANativeWindow>& nativeWindow,
Jesse Hall99c7dbb2013-03-14 14:29:29 -070085 const sp<DisplaySurface>& displaySurface,
Lloyd Pique09594832018-01-22 17:48:03 -080086 std::unique_ptr<RE::Surface> renderSurface,
87 int displayWidth,
88 int displayHeight,
Peiyong Lindd9b2ae2018-03-01 16:22:45 -080089 bool hasWideColorGamut,
Peiyong Lin62665892018-04-16 11:07:44 -070090 const HdrCapabilities& hdrCapabilities,
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -070091 const int32_t supportedPerFrameMetadata,
Chia-I Wube02ec02018-05-18 10:59:36 -070092 const std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>>& hwcColorModes,
Lloyd Pique09594832018-01-22 17:48:03 -080093 int initialPowerMode);
Courtney Goeltzenleuchter5d943892017-03-22 13:46:46 -060094 // clang-format on
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080095
Mathias Agopian028a7572012-08-05 01:23:51 -070096 ~DisplayDevice();
Mathias Agopian92a979a2012-08-02 18:32:23 -070097
98 // whether this is a valid object. An invalid DisplayDevice is returned
99 // when an non existing id is requested
100 bool isValid() const;
101
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700102 // isSecure indicates whether this display can be trusted to display
103 // secure surfaces.
104 bool isSecure() const { return mIsSecure; }
105
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800106 // Flip the front and back buffers if the back buffer is "dirty". Might
107 // be instantaneous, might involve copying the frame buffer around.
Chia-I Wub02087d2017-11-09 10:19:54 -0800108 void flip() const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800109
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800110 int getWidth() const;
111 int getHeight() const;
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700112
Mathias Agopian13127d82013-03-05 17:47:11 -0800113 void setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers);
114 const Vector< sp<Layer> >& getVisibleLayersSortedByZ() const;
Chia-I Wu83806892017-11-16 10:50:20 -0800115 void setLayersNeedingFences(const Vector< sp<Layer> >& layers);
116 const Vector< sp<Layer> >& getLayersNeedingFences() const;
Mathias Agopiancd60f992012-08-16 16:28:27 -0700117 Region getDirtyRegion(bool repaintEverything) const;
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700118
Mathias Agopian28947d72012-08-08 18:51:15 -0700119 void setLayerStack(uint32_t stack);
Michael Lentine47e45402014-07-18 15:34:25 -0700120 void setDisplaySize(const int newWidth, const int newHeight);
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700121 void setProjection(int orientation, const Rect& viewport, const Rect& frame);
Mathias Agopian28947d72012-08-08 18:51:15 -0700122
Mathias Agopian1b031492012-06-20 17:51:20 -0700123 int getOrientation() const { return mOrientation; }
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700124 uint32_t getOrientationTransform() const;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700125 static uint32_t getPrimaryDisplayOrientationTransform();
Peiyong Linefefaac2018-08-17 12:27:51 -0700126 const ui::Transform& getTransform() const { return mGlobalTransform; }
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800127 const Rect getViewport() const { return mViewport; }
128 const Rect getFrame() const { return mFrame; }
Mathias Agopian766dc492012-10-30 18:08:06 -0700129 const Rect& getScissor() const { return mScissor; }
Mathias Agopianeba8c682012-09-19 23:14:45 -0700130 bool needsFiltering() const { return mNeedsFiltering; }
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700131
Mathias Agopian87baae12012-07-31 12:38:26 -0700132 uint32_t getLayerStack() const { return mLayerStack; }
Mathias Agopian3ee454a2012-08-27 16:28:24 -0700133 int32_t getDisplayType() const { return mType; }
Chia-I Wuab0c3192017-08-01 11:29:00 -0700134 bool isPrimary() const { return mType == DISPLAY_PRIMARY; }
Dominik Laskowski281644e2018-04-19 15:47:35 -0700135 bool isVirtual() const { return mType == DISPLAY_VIRTUAL; }
Dominik Laskowski7e045462018-05-30 13:02:02 -0700136 int32_t getId() const { return mId; }
Mathias Agopian3ee454a2012-08-27 16:28:24 -0700137 const wp<IBinder>& getDisplayToken() const { return mDisplayToken; }
Mathias Agopian87baae12012-07-31 12:38:26 -0700138
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -0700139 int32_t getSupportedPerFrameMetadata() const { return mSupportedPerFrameMetadata; }
140
Dan Stoza71433162014-02-04 16:22:36 -0800141 // We pass in mustRecompose so we can keep VirtualDisplaySurface's state
142 // machine happy without actually queueing a buffer if nothing has changed
143 status_t beginFrame(bool mustRecompose) const;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800144 status_t prepareFrame(HWComposer& hwc);
Chia-I Wube02ec02018-05-18 10:59:36 -0700145
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800146 bool hasWideColorGamut() const { return mHasWideColorGamut; }
Peiyong Lin136fbbc2018-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; }
Chia-I Wube02ec02018-05-18 10:59:36 -0700151
Peiyong Lindfde5112018-06-05 10:58:41 -0700152 // Return true if the HDR dataspace is supported but
153 // there is no corresponding color mode.
154 bool hasLegacyHdrSupport(ui::Dataspace dataspace) const;
Chia-I Wube02ec02018-05-18 10:59:36 -0700155
Peiyong Linfb069302018-04-25 14:34:31 -0700156 // The returned HdrCapabilities is the combination of HDR capabilities from
157 // hardware composer and RenderEngine. When the DisplayDevice supports wide
158 // color gamut, RenderEngine is able to simulate HDR support in Display P3
159 // color space for both PQ and HLG HDR contents. The minimum and maximum
160 // luminance will be set to sDefaultMinLumiance and sDefaultMaxLumiance
161 // respectively if hardware composer doesn't return meaningful values.
162 const HdrCapabilities& getHdrCapabilities() const { return mHdrCapabilities; }
Jesse Hall38efe862013-04-06 23:12:29 -0700163
Chia-I Wube02ec02018-05-18 10:59:36 -0700164 // Return true if intent is supported by the display.
165 bool hasRenderIntent(ui::RenderIntent intent) const;
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700166
Chia-I Wube02ec02018-05-18 10:59:36 -0700167 void getBestColorMode(ui::Dataspace dataspace, ui::RenderIntent intent,
168 ui::Dataspace* outDataspace, ui::ColorMode* outMode,
169 ui::RenderIntent* outIntent) const;
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700170
Mathias Agopianda27af92012-09-13 18:17:13 -0700171 void swapBuffers(HWComposer& hwc) const;
Jesse Hall01e29052013-02-19 16:13:35 -0800172
Mathias Agopianda27af92012-09-13 18:17:13 -0700173 // called after h/w composer has completed its set() call
Dan Stoza9e56aa02015-11-02 13:00:03 -0800174 void onSwapBuffersCompleted() const;
Mathias Agopianda27af92012-09-13 18:17:13 -0700175
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700176 Rect getBounds() const {
Mathias Agopian1b031492012-06-20 17:51:20 -0700177 return Rect(mDisplayWidth, mDisplayHeight);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800178 }
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700179 inline Rect bounds() const { return getBounds(); }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800180
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700181 void setDisplayName(const std::string& displayName);
182 const std::string& getDisplayName() const { return mDisplayName; }
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700183
Chia-I Wuf846a352017-11-10 09:22:52 -0800184 bool makeCurrent() const;
Mathias Agopian875d8e12013-06-07 15:35:48 -0700185 void setViewportAndProjection() const;
Mathias Agopianbae92d02012-09-28 01:00:47 -0700186
Dan Stoza9e56aa02015-11-02 13:00:03 -0800187 const sp<Fence>& getClientTargetAcquireFence() const;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800188
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700189 /* ------------------------------------------------------------------------
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700190 * Display power mode management.
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700191 */
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700192 int getPowerMode() const;
193 void setPowerMode(int mode);
Dominik Laskowskieecd6592018-05-29 10:25:41 -0700194 bool isPoweredOn() const;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700195
Peiyong Linfd997e02018-03-28 15:29:00 -0700196 ui::ColorMode getActiveColorMode() const;
197 void setActiveColorMode(ui::ColorMode mode);
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800198 ui::RenderIntent getActiveRenderIntent() const;
199 void setActiveRenderIntent(ui::RenderIntent renderIntent);
Yiwei Zhang7c64f172018-03-07 14:52:28 -0800200 android_color_transform_t getColorTransform() const;
201 void setColorTransform(const mat4& transform);
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700202 void setCompositionDataSpace(ui::Dataspace dataspace);
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800203 ui::Dataspace getCompositionDataSpace() const;
Michael Wright28f24d02016-07-12 13:30:53 -0700204
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700205 /* ------------------------------------------------------------------------
206 * Display active config management.
207 */
208 int getActiveConfig() const;
209 void setActiveConfig(int mode);
210
Jesse Hall02d86562013-03-25 14:43:23 -0700211 // release HWC resources (if any) for removable displays
212 void disconnect(HWComposer& hwc);
213
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700214 /* ------------------------------------------------------------------------
215 * Debugging
216 */
217 uint32_t getPageFlipCount() const;
Mathias Agopian74d211a2013-04-22 16:55:35 +0200218 void dump(String8& result) const;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700219
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800220private:
Mathias Agopiana4912602012-07-12 14:25:33 -0700221 /*
222 * Constants, set during initialization
223 */
Mathias Agopianc7d14e22011-08-01 16:32:21 -0700224 sp<SurfaceFlinger> mFlinger;
Mathias Agopian3ee454a2012-08-27 16:28:24 -0700225 DisplayType mType;
Dominik Laskowski7e045462018-05-30 13:02:02 -0700226 int32_t mId;
Mathias Agopian3ee454a2012-08-27 16:28:24 -0700227 wp<IBinder> mDisplayToken;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700228
Mathias Agopiana4912602012-07-12 14:25:33 -0700229 // ANativeWindow this display is rendering into
Mathias Agopiand8552d72012-08-04 21:39:11 -0700230 sp<ANativeWindow> mNativeWindow;
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700231 sp<DisplaySurface> mDisplaySurface;
Mathias Agopiana4912602012-07-12 14:25:33 -0700232
Lloyd Pique144e1162017-12-20 16:44:52 -0800233 std::unique_ptr<RE::Surface> mSurface;
Mathias Agopian1b031492012-06-20 17:51:20 -0700234 int mDisplayWidth;
235 int mDisplayHeight;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700236 mutable uint32_t mPageFlipCount;
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700237 std::string mDisplayName;
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700238 bool mIsSecure;
Mathias Agopian03e40722012-04-26 16:11:59 -0700239
Mathias Agopiana4912602012-07-12 14:25:33 -0700240 /*
241 * Can only accessed from the main thread, these members
242 * don't need synchronization.
243 */
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700244
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700245 // list of visible layers on that display
Mathias Agopian13127d82013-03-05 17:47:11 -0800246 Vector< sp<Layer> > mVisibleLayersSortedByZ;
Chia-I Wu83806892017-11-16 10:50:20 -0800247 // list of layers needing fences
248 Vector< sp<Layer> > mLayersNeedingFences;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700249
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700250 /*
251 * Transaction state
252 */
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700253 static status_t orientationToTransfrom(int orientation,
Peiyong Linefefaac2018-08-17 12:27:51 -0700254 int w, int h, ui::Transform* tr);
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700255
Fabien Sanglardf0c53d62017-03-03 18:58:50 -0800256 // The identifier of the active layer stack for this display. Several displays
257 // can use the same layer stack: A z-ordered group of layers (sometimes called
258 // "surfaces"). Any given layer can only be on a single layer stack.
Mathias Agopian87baae12012-07-31 12:38:26 -0700259 uint32_t mLayerStack;
Fabien Sanglardf0c53d62017-03-03 18:58:50 -0800260
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700261 int mOrientation;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700262 static uint32_t sPrimaryDisplayOrientation;
Mathias Agopian766dc492012-10-30 18:08:06 -0700263 // user-provided visible area of the layer stack
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700264 Rect mViewport;
Mathias Agopian766dc492012-10-30 18:08:06 -0700265 // user-provided rectangle where mViewport gets mapped to
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700266 Rect mFrame;
Mathias Agopian766dc492012-10-30 18:08:06 -0700267 // pre-computed scissor to apply to the display
268 Rect mScissor;
Peiyong Linefefaac2018-08-17 12:27:51 -0700269 ui::Transform mGlobalTransform;
Mathias Agopianeba8c682012-09-19 23:14:45 -0700270 bool mNeedsFiltering;
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700271 // Current power mode
272 int mPowerMode;
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700273 // Current active config
274 int mActiveConfig;
Michael Wright28f24d02016-07-12 13:30:53 -0700275 // current active color mode
Chia-I Wu614e1422018-05-23 02:17:03 -0700276 ui::ColorMode mActiveColorMode = ui::ColorMode::NATIVE;
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800277 // Current active render intent.
Chia-I Wu614e1422018-05-23 02:17:03 -0700278 ui::RenderIntent mActiveRenderIntent = ui::RenderIntent::COLORIMETRIC;
279 ui::Dataspace mCompositionDataSpace = ui::Dataspace::UNKNOWN;
Yiwei Zhang7c64f172018-03-07 14:52:28 -0800280 // Current color transform
281 android_color_transform_t mColorTransform;
Courtney Goeltzenleuchter5d943892017-03-22 13:46:46 -0600282
283 // Need to know if display is wide-color capable or not.
284 // Initialized by SurfaceFlinger when the DisplayDevice is created.
285 // Fed to RenderEngine during composition.
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800286 bool mHasWideColorGamut;
287 bool mHasHdr10;
Peiyong Lin62665892018-04-16 11:07:44 -0700288 bool mHasHLG;
289 bool mHasDolbyVision;
Peiyong Linfb069302018-04-25 14:34:31 -0700290 HdrCapabilities mHdrCapabilities;
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -0700291 const int32_t mSupportedPerFrameMetadata;
Chia-I Wube02ec02018-05-18 10:59:36 -0700292
293 // Mappings from desired Dataspace/RenderIntent to the supported
294 // Dataspace/ColorMode/RenderIntent.
295 using ColorModeKey = uint64_t;
296 struct ColorModeValue {
297 ui::Dataspace dataspace;
298 ui::ColorMode colorMode;
299 ui::RenderIntent renderIntent;
300 };
301
302 static ColorModeKey getColorModeKey(ui::Dataspace dataspace, ui::RenderIntent intent) {
303 return (static_cast<uint64_t>(dataspace) << 32) | static_cast<uint32_t>(intent);
304 }
305 void populateColorModes(
306 const std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>>& hwcColorModes);
307 void addColorMode(
308 const std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>>& hwcColorModes,
309 const ui::ColorMode mode, const ui::RenderIntent intent);
310
311 std::unordered_map<ColorModeKey, ColorModeValue> mColorModes;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800312};
313
Irvelffc9efc2016-07-27 15:16:37 -0700314struct DisplayDeviceState {
Dominik Laskowski663bd282018-04-19 15:26:54 -0700315 bool isVirtual() const { return type >= DisplayDevice::DISPLAY_VIRTUAL; }
Irvelffc9efc2016-07-27 15:16:37 -0700316
Dominik Laskowski663bd282018-04-19 15:26:54 -0700317 int32_t sequenceId = sNextSequenceId++;
Irvelffc9efc2016-07-27 15:16:37 -0700318 DisplayDevice::DisplayType type = DisplayDevice::DISPLAY_ID_INVALID;
319 sp<IGraphicBufferProducer> surface;
320 uint32_t layerStack = DisplayDevice::NO_LAYER_STACK;
321 Rect viewport;
322 Rect frame;
323 uint8_t orientation = 0;
324 uint32_t width = 0;
325 uint32_t height = 0;
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700326 std::string displayName;
Irvelffc9efc2016-07-27 15:16:37 -0700327 bool isSecure = false;
Dominik Laskowski663bd282018-04-19 15:26:54 -0700328
329private:
330 static std::atomic<int32_t> sNextSequenceId;
Irvelffc9efc2016-07-27 15:16:37 -0700331};
332
chaviwa76b2712017-09-20 12:02:26 -0700333class DisplayRenderArea : public RenderArea {
334public:
335 DisplayRenderArea(const sp<const DisplayDevice> device,
Chia-I Wuc80dcbb2018-08-24 15:34:02 -0700336 ui::Transform::orientation_flags rotation = ui::Transform::ROT_0)
Chia-I Wu9d1abea2018-08-23 13:44:43 -0700337 : DisplayRenderArea(device, device->getBounds(), device->getWidth(), device->getHeight(),
chaviwa76b2712017-09-20 12:02:26 -0700338 rotation) {}
Chia-I Wu9d1abea2018-08-23 13:44:43 -0700339 DisplayRenderArea(const sp<const DisplayDevice> device, Rect sourceCrop, uint32_t reqWidth,
Chia-I Wuc80dcbb2018-08-24 15:34:02 -0700340 uint32_t reqHeight, ui::Transform::orientation_flags rotation)
Chia-I Wu9d1abea2018-08-23 13:44:43 -0700341 : RenderArea(reqWidth, reqHeight, CaptureFill::OPAQUE, rotation), mDevice(device),
chaviw50da5042018-04-09 13:49:37 -0700342 mSourceCrop(sourceCrop) {}
chaviwa76b2712017-09-20 12:02:26 -0700343
Peiyong Linefefaac2018-08-17 12:27:51 -0700344 const ui::Transform& getTransform() const override { return mDevice->getTransform(); }
chaviwa76b2712017-09-20 12:02:26 -0700345 Rect getBounds() const override { return mDevice->getBounds(); }
346 int getHeight() const override { return mDevice->getHeight(); }
347 int getWidth() const override { return mDevice->getWidth(); }
348 bool isSecure() const override { return mDevice->isSecure(); }
349 bool needsFiltering() const override { return mDevice->needsFiltering(); }
350 Rect getSourceCrop() const override { return mSourceCrop; }
chaviwa76b2712017-09-20 12:02:26 -0700351
352private:
353 const sp<const DisplayDevice> mDevice;
354 const Rect mSourceCrop;
355};
356
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800357}; // namespace android
358
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700359#endif // ANDROID_DISPLAY_DEVICE_H