blob: 7d7c8adb7b88aa3cd7df100a8dfab26bda0d7cba [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
Dominik Laskowski718f9602019-11-09 20:01:35 -080017#pragma once
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080018
Peiyong Linefefaac2018-08-17 12:27:51 -070019#include <memory>
20#include <string>
Peiyong Lin136fbbc2018-04-17 15:09:44 -070021#include <unordered_map>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080022
Dominik Laskowski298b08e2022-02-15 13:45:02 -080023#include <android-base/thread_annotations.h>
Alec Mourif6fd29e2018-11-17 04:56:41 +000024#include <android/native_window.h>
Dan Stoza9e56aa02015-11-02 13:00:03 -080025#include <binder/IBinder.h>
Gil Dekelde4ce292025-03-03 17:08:43 -050026#include <compositionengine/Display.h>
27#include <compositionengine/DisplaySurface.h>
Chia-I Wuf2aa3112018-08-27 14:54:37 -070028#include <gui/LayerState.h>
Peiyong Linefefaac2018-08-17 12:27:51 -070029#include <math/mat4.h>
Alec Mouri0a9c7b82018-11-16 13:05:25 -080030#include <renderengine/RenderEngine.h>
Alec Mourif6fd29e2018-11-17 04:56:41 +000031#include <system/window.h>
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020032#include <ui/DisplayId.h>
Dominik Laskowski298b08e2022-02-15 13:45:02 -080033#include <ui/DisplayIdentification.h>
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080034#include <ui/DisplayState.h>
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -070035#include <ui/GraphicTypes.h>
Peiyong Linfb069302018-04-25 14:34:31 -070036#include <ui/HdrCapabilities.h>
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -070037#include <ui/Region.h>
Marin Shalamanov228f46b2021-01-28 21:11:45 +010038#include <ui/StaticDisplayInfo.h>
Peiyong Linefefaac2018-08-17 12:27:51 -070039#include <ui/Transform.h>
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +010040#include <utils/Errors.h>
Alec Mouri8d4f90a2018-11-14 22:33:24 +000041#include <utils/Mutex.h>
Alec Mouri0a9c7b82018-11-16 13:05:25 -080042#include <utils/RefBase.h>
Mathias Agopian86303202012-07-24 22:46:10 -070043#include <utils/Timers.h>
44
Marin Shalamanov23c44202020-12-22 19:09:20 +010045#include "DisplayHardware/DisplayMode.h"
Peiyong Line9d809e2020-04-14 13:10:48 -070046#include "DisplayHardware/Hal.h"
Vishnu Nairaf6d2972022-11-18 06:26:38 +000047#include "FrontEnd/DisplayInfo.h"
Dominik Laskowskid82e0f02022-10-26 15:23:04 -040048#include "Scheduler/RefreshRateSelector.h"
Dominik Laskowski298b08e2022-02-15 13:45:02 -080049#include "ThreadContext.h"
Ady Abraham690f4612021-07-01 23:24:03 -070050#include "TracedOrdinal.h"
Dominik Laskowskie70461a2022-08-30 14:42:01 -070051#include "Utils/Dumper.h"
Dominik Laskowski59746512023-11-19 09:30:24 -050052
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080053namespace android {
54
Dan Stoza9e56aa02015-11-02 13:00:03 -080055class Fence;
Lloyd Pique2eef1d22018-09-18 21:30:04 -070056class HWComposer;
Sally Qi147581b2023-06-27 11:55:34 -070057class HdrSdrRatioOverlay;
Jesse Hall9e663de2013-08-16 14:28:37 -070058class IGraphicBufferProducer;
Mathias Agopian13127d82013-03-05 17:47:11 -080059class Layer;
Ady Abraham1b11bc62021-06-03 19:51:19 -070060class RefreshRateOverlay;
Mathias Agopian86303202012-07-24 22:46:10 -070061class SurfaceFlinger;
Lloyd Pique2eef1d22018-09-18 21:30:04 -070062
David Sodmanfb95bcc2017-12-22 15:45:30 -080063struct CompositionInfo;
Lloyd Pique2eef1d22018-09-18 21:30:04 -070064struct DisplayDeviceCreationArgs;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080065
Dominik Laskowskib363c4c2022-08-02 14:03:41 -070066namespace display {
67class DisplaySnapshot;
68} // namespace display
69
Marin Shalamanov1c434292020-06-12 01:47:29 +020070class DisplayDevice : public RefBase {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080071public:
Peiyong Linfb069302018-04-25 14:34:31 -070072 constexpr static float sDefaultMinLumiance = 0.0;
73 constexpr static float sDefaultMaxLumiance = 500.0;
Evan Rosky2239b372021-05-20 13:43:47 -070074 enum { eReceivesInput = 0x01 };
Peiyong Linfb069302018-04-25 14:34:31 -070075
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -070076 explicit DisplayDevice(DisplayDeviceCreationArgs& args);
Marin Shalamanov1c434292020-06-12 01:47:29 +020077
78 // Must be destroyed on the main thread because it may call into HWComposer.
Lloyd Pique45a165a2018-10-19 11:54:47 -070079 virtual ~DisplayDevice();
80
81 std::shared_ptr<compositionengine::Display> getCompositionDisplay() const {
82 return mCompositionDisplay;
83 }
Mathias Agopian92a979a2012-08-02 18:32:23 -070084
Gil Dekel147626a2025-03-03 17:09:41 -050085 bool isVirtual() const;
Dominik Laskowski075d3172018-05-24 15:50:06 -070086 bool isPrimary() const { return mIsPrimary; }
Mathias Agopian92a979a2012-08-02 18:32:23 -070087
Jamie Gennisdd3cb842012-10-19 18:19:11 -070088 // isSecure indicates whether this display can be trusted to display
89 // secure surfaces.
Lloyd Pique45a165a2018-10-19 11:54:47 -070090 bool isSecure() const;
Huihong Luo9ebb7a72023-06-27 17:01:50 -070091 void setSecure(bool secure);
Jamie Gennisdd3cb842012-10-19 18:19:11 -070092
Dennis Kiilerich85202062025-02-22 00:26:53 -080093 // The optimization policy influences whether this display is optimized for power or
94 // performance.
95 gui::ISurfaceComposer::OptimizationPolicy getOptimizationPolicy() const;
96 void setOptimizationPolicy(gui::ISurfaceComposer::OptimizationPolicy optimizationPolicy);
97
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080098 int getWidth() const;
99 int getHeight() const;
100 ui::Size getSize() const { return {getWidth(), getHeight()}; }
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700101
Dominik Laskowskib363c4c2022-08-02 14:03:41 -0700102 void setLayerFilter(ui::LayerFilter);
Dominik Laskowski251e6122024-07-31 11:04:24 -0400103 void setDisplaySize(ui::Size);
Dominik Laskowski718f9602019-11-09 20:01:35 -0800104 void setProjection(ui::Rotation orientation, Rect viewport, Rect frame);
Dominik Laskowski298b08e2022-02-15 13:45:02 -0800105 void stageBrightness(float brightness) REQUIRES(kMainThreadContext);
106 void persistBrightness(bool needsComposite) REQUIRES(kMainThreadContext);
107 bool isBrightnessStale() const REQUIRES(kMainThreadContext);
Evan Rosky2239b372021-05-20 13:43:47 -0700108 void setFlags(uint32_t flags);
Dominik Laskowski718f9602019-11-09 20:01:35 -0800109
110 ui::Rotation getPhysicalOrientation() const { return mPhysicalOrientation; }
111 ui::Rotation getOrientation() const { return mOrientation; }
112
Dominik Laskowski298b08e2022-02-15 13:45:02 -0800113 std::optional<float> getStagedBrightness() const REQUIRES(kMainThreadContext);
Garfield Tan54edd912020-10-21 16:31:41 -0700114 ui::Transform::RotationFlags getTransformHint() const;
Lloyd Pique32cbe282018-10-19 13:09:22 -0700115 const ui::Transform& getTransform() const;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200116 const Rect& getLayerStackSpaceRect() const;
117 const Rect& getOrientedDisplaySpaceRect() const;
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800118 ui::LayerStack getLayerStack() const;
Evan Rosky2239b372021-05-20 13:43:47 -0700119 bool receivesInput() const { return mFlags & eReceivesInput; }
Dominik Laskowski075d3172018-05-24 15:50:06 -0700120
Dominik Laskowski3dce4f42021-03-08 20:48:28 -0800121 DisplayId getId() const;
122
Gil Dekelde4ce292025-03-03 17:08:43 -0500123 DisplayIdVariant getDisplayIdVariant() const {
124 const auto idVariant = mCompositionDisplay->getDisplayIdVariant();
125 LOG_FATAL_IF(!idVariant);
126 return *idVariant;
127 }
128
Gil Dekel147626a2025-03-03 17:09:41 -0500129 std::optional<VirtualDisplayIdVariant> getVirtualDisplayIdVariant() const {
130 return ftl::match(
131 getDisplayIdVariant(),
132 [](PhysicalDisplayId) { return std::optional<VirtualDisplayIdVariant>(); },
133 [](auto id) { return std::optional<VirtualDisplayIdVariant>(id); });
134 }
135
Dominik Laskowski3dce4f42021-03-08 20:48:28 -0800136 // Shorthand to upcast the ID of a display whose type is known as a precondition.
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200137 PhysicalDisplayId getPhysicalId() const {
Gil Dekel147626a2025-03-03 17:09:41 -0500138 const auto physicalDisplayId = asPhysicalDisplayId(getDisplayIdVariant());
139 LOG_FATAL_IF(!physicalDisplayId);
140 return *physicalDisplayId;
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200141 }
142
Dominik Laskowski3dce4f42021-03-08 20:48:28 -0800143 VirtualDisplayId getVirtualId() const {
Gil Dekel147626a2025-03-03 17:09:41 -0500144 const auto virtualDisplayId = asVirtualDisplayId(getDisplayIdVariant());
145 LOG_FATAL_IF(!virtualDisplayId);
146 return *virtualDisplayId;
Dominik Laskowski3dce4f42021-03-08 20:48:28 -0800147 }
148
Dominik Laskowski075d3172018-05-24 15:50:06 -0700149 const wp<IBinder>& getDisplayToken() const { return mDisplayToken; }
Dominik Laskowskie9774092018-12-11 10:04:24 -0800150 int32_t getSequenceId() const { return mSequenceId; }
Mathias Agopian87baae12012-07-31 12:38:26 -0700151
Lloyd Pique32cbe282018-10-19 13:09:22 -0700152 const Region& getUndefinedRegion() const;
153
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700154 int32_t getSupportedPerFrameMetadata() const;
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -0700155
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700156 bool hasWideColorGamut() const;
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700157 // Whether h/w composer has native support for specific HDR type.
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700158 bool hasHDR10PlusSupport() const;
159 bool hasHDR10Support() const;
160 bool hasHLGSupport() const;
161 bool hasDolbyVisionSupport() const;
Chia-I Wube02ec02018-05-18 10:59:36 -0700162
Kriti Dang4bc7cdf2021-01-08 11:49:56 +0100163 void overrideHdrTypes(const std::vector<ui::Hdr>& hdrTypes);
164
Peiyong Linfb069302018-04-25 14:34:31 -0700165 // The returned HdrCapabilities is the combination of HDR capabilities from
166 // hardware composer and RenderEngine. When the DisplayDevice supports wide
167 // color gamut, RenderEngine is able to simulate HDR support in Display P3
168 // color space for both PQ and HLG HDR contents. The minimum and maximum
169 // luminance will be set to sDefaultMinLumiance and sDefaultMaxLumiance
170 // respectively if hardware composer doesn't return meaningful values.
Kriti Dang4bc7cdf2021-01-08 11:49:56 +0100171 HdrCapabilities getHdrCapabilities() const;
Jesse Hall38efe862013-04-06 23:12:29 -0700172
Chia-I Wube02ec02018-05-18 10:59:36 -0700173 // Return true if intent is supported by the display.
174 bool hasRenderIntent(ui::RenderIntent intent) const;
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700175
Angel Aguayob108a6d2021-08-06 21:34:57 +0000176 const Rect getBounds() const;
177 const Rect bounds() const { return getBounds(); }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800178
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700179 void setDisplayName(const std::string& displayName);
180 const std::string& getDisplayName() const { return mDisplayName; }
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700181
Vishnu Nairaf6d2972022-11-18 06:26:38 +0000182 surfaceflinger::frontend::DisplayInfo getFrontEndInfo() const;
Prabir Pradhan48f8cb92021-08-26 14:05:36 -0700183
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700184 /* ------------------------------------------------------------------------
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700185 * Display power mode management.
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700186 */
Dominik Laskowskia42d5392022-09-29 14:26:53 -0400187 hardware::graphics::composer::hal::PowerMode getPowerMode() const;
188 void setPowerMode(hardware::graphics::composer::hal::PowerMode);
Dominik Laskowskieecd6592018-05-29 10:25:41 -0700189 bool isPoweredOn() const;
Ady Abraham8e3e2ea2024-10-31 15:52:31 -0700190 bool isRefreshable() const;
Ady Abraham66452722023-03-14 17:41:47 -0700191 void tracePowerMode();
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700192
Alec Mouridd8bf2d2021-05-08 16:36:33 -0700193 // Enables layer caching on this DisplayDevice
194 void enableLayerCaching(bool enable);
195
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800196 ui::Dataspace getCompositionDataSpace() const;
Michael Wright28f24d02016-07-12 13:30:53 -0700197
Dominik Laskowskid82e0f02022-10-26 15:23:04 -0400198 scheduler::RefreshRateSelector& refreshRateSelector() const { return *mRefreshRateSelector; }
Ady Abraham3efa3942021-06-24 19:01:25 -0700199
Dominik Laskowskid82e0f02022-10-26 15:23:04 -0400200 // Extends the lifetime of the RefreshRateSelector, so it can outlive this DisplayDevice.
201 std::shared_ptr<scheduler::RefreshRateSelector> holdRefreshRateSelector() const {
202 return mRefreshRateSelector;
Ady Abraham3efa3942021-06-24 19:01:25 -0700203 }
204
Ady Abraham1b11bc62021-06-03 19:51:19 -0700205 // Enables an overlay to be displayed with the current refresh rate
Dominik Laskowski5c989f52024-04-11 13:57:14 -0400206 // TODO(b/241285876): Move overlay to DisplayModeController.
207 void enableRefreshRateOverlay(bool enable, bool setByHwc, Fps refreshRate, Fps renderFps,
208 bool showSpinner, bool showRenderRate, bool showInMiddle)
209 REQUIRES(kMainThreadContext);
Ying Wei22d59cc2024-05-11 02:41:08 +0000210 void updateRefreshRateOverlayRate(Fps refreshRate, Fps renderFps, bool setByHwc = false);
Ady Abraham1b11bc62021-06-03 19:51:19 -0700211 bool isRefreshRateOverlayEnabled() const { return mRefreshRateOverlay != nullptr; }
Dominik Laskowski5c989f52024-04-11 13:57:14 -0400212 void animateOverlay();
Ady Abraham1b11bc62021-06-03 19:51:19 -0700213 bool onKernelTimerChanged(std::optional<DisplayModeId>, bool timerExpired);
Ady Abrahameba039c2024-07-10 17:45:29 -0700214 void onVrrIdle(bool idle);
Sally Qi147581b2023-06-27 11:55:34 -0700215
216 // Enables an overlay to be display with the hdr/sdr ratio
217 void enableHdrSdrRatioOverlay(bool enable) REQUIRES(kMainThreadContext);
218 void updateHdrSdrRatioOverlayRatio(float currentHdrSdrRatio);
219 bool isHdrSdrRatioOverlayEnabled() const { return mHdrSdrRatioOverlay != nullptr; }
Ady Abraham1b11bc62021-06-03 19:51:19 -0700220
Huihong Luo1768cb02022-10-11 11:10:34 -0700221 Fps getAdjustedRefreshRate() const { return mAdjustedRefreshRate; }
222
Leon Scroggins III1af0fb62023-03-02 14:21:44 -0500223 // Round the requested refresh rate to match a divisor of the pacesetter
Huihong Luo1768cb02022-10-11 11:10:34 -0700224 // display's refresh rate. Only supported for virtual displays.
Leon Scroggins III1af0fb62023-03-02 14:21:44 -0500225 void adjustRefreshRate(Fps pacesetterDisplayRefreshRate);
Huihong Luo1768cb02022-10-11 11:10:34 -0700226
Jesse Hall02d86562013-03-25 14:43:23 -0700227 // release HWC resources (if any) for removable displays
Lloyd Pique45a165a2018-10-19 11:54:47 -0700228 void disconnect();
Jesse Hall02d86562013-03-25 14:43:23 -0700229
Dominik Laskowskie70461a2022-08-30 14:42:01 -0700230 void dump(utils::Dumper&) const;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700231
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800232private:
Dominik Laskowski075d3172018-05-24 15:50:06 -0700233 const sp<SurfaceFlinger> mFlinger;
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +0100234 HWComposer& mHwComposer;
Dominik Laskowski075d3172018-05-24 15:50:06 -0700235 const wp<IBinder> mDisplayToken;
Dominik Laskowskie9774092018-12-11 10:04:24 -0800236 const int32_t mSequenceId;
Dominik Laskowski075d3172018-05-24 15:50:06 -0700237
Lloyd Pique45a165a2018-10-19 11:54:47 -0700238 const std::shared_ptr<compositionengine::Display> mCompositionDisplay;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700239
Lloyd Pique31cb2942018-10-19 17:23:03 -0700240 std::string mDisplayName;
Mathias Agopian03e40722012-04-26 16:11:59 -0700241
Dominik Laskowski718f9602019-11-09 20:01:35 -0800242 const ui::Rotation mPhysicalOrientation;
243 ui::Rotation mOrientation = ui::ROTATION_0;
Sally Qi147581b2023-06-27 11:55:34 -0700244 bool mIsOrientationChanged = false;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700245
Dominik Laskowskia42d5392022-09-29 14:26:53 -0400246 TracedOrdinal<hardware::graphics::composer::hal::PowerMode> mPowerMode;
Dominik Laskowski02bb2072022-08-26 15:02:52 -0700247
248 std::optional<float> mStagedBrightness;
linpeterdcfd4e62022-12-29 09:39:14 +0800249 std::optional<float> mBrightness;
Courtney Goeltzenleuchter5d943892017-03-22 13:46:46 -0600250
Dominik Laskowskif8db0f02021-04-19 11:05:25 -0700251 // TODO(b/182939859): Remove special cases for primary display.
Dominik Laskowski075d3172018-05-24 15:50:06 -0700252 const bool mIsPrimary;
Marin Shalamanove5cceea2020-04-30 18:13:10 +0200253
Dennis Kiilerich85202062025-02-22 00:26:53 -0800254 gui::ISurfaceComposer::OptimizationPolicy mOptimizationPolicy =
255 gui::ISurfaceComposer::OptimizationPolicy::optimizeForPerformance;
256
Evan Rosky2239b372021-05-20 13:43:47 -0700257 uint32_t mFlags = 0;
258
Huihong Luo1768cb02022-10-11 11:10:34 -0700259 // Requested refresh rate in fps, supported only for virtual displays.
260 // when this value is non zero, SurfaceFlinger will try to drop frames
261 // for virtual displays to match this requested refresh rate.
262 const Fps mRequestedRefreshRate;
263
Leon Scroggins III1af0fb62023-03-02 14:21:44 -0500264 // Adjusted refresh rate, rounded to match a divisor of the pacesetter
Huihong Luo1768cb02022-10-11 11:10:34 -0700265 // display's refresh rate. Only supported for virtual displays.
266 Fps mAdjustedRefreshRate = 0_Hz;
267
Kriti Dang4bc7cdf2021-01-08 11:49:56 +0100268 std::vector<ui::Hdr> mOverrideHdrTypes;
Ady Abraham3efa3942021-06-24 19:01:25 -0700269
Dominik Laskowskid82e0f02022-10-26 15:23:04 -0400270 std::shared_ptr<scheduler::RefreshRateSelector> mRefreshRateSelector;
Ady Abraham1b11bc62021-06-03 19:51:19 -0700271 std::unique_ptr<RefreshRateOverlay> mRefreshRateOverlay;
Sally Qi147581b2023-06-27 11:55:34 -0700272 std::unique_ptr<HdrSdrRatioOverlay> mHdrSdrRatioOverlay;
273 // This parameter is only used for hdr/sdr ratio overlay
274 float mHdrSdrRatio = 1.0f;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800275};
276
Irvelffc9efc2016-07-27 15:16:37 -0700277struct DisplayDeviceState {
Dominik Laskowski55c85402020-01-21 16:25:47 -0800278 struct Physical {
Marin Shalamanova524a092020-07-27 21:39:55 +0200279 PhysicalDisplayId id;
Peiyong Lin65248e02020-04-18 21:15:07 -0700280 hardware::graphics::composer::hal::HWDisplayId hwcDisplayId;
Gil Dekel161feaf2025-02-10 18:59:29 -0500281 uint8_t port;
Marin Shalamanova903d032020-12-29 20:35:13 +0100282 DisplayModePtr activeMode;
283
Dominik Laskowski55c85402020-01-21 16:25:47 -0800284 bool operator==(const Physical& other) const {
Dominik Laskowskib363c4c2022-08-02 14:03:41 -0700285 return id == other.id && hwcDisplayId == other.hwcDisplayId;
Dominik Laskowski55c85402020-01-21 16:25:47 -0800286 }
287 };
288
289 bool isVirtual() const { return !physical; }
Irvelffc9efc2016-07-27 15:16:37 -0700290
Dominik Laskowski663bd282018-04-19 15:26:54 -0700291 int32_t sequenceId = sNextSequenceId++;
Dominik Laskowski55c85402020-01-21 16:25:47 -0800292 std::optional<Physical> physical;
Irvelffc9efc2016-07-27 15:16:37 -0700293 sp<IGraphicBufferProducer> surface;
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700294 ui::LayerStack layerStack;
Evan Rosky2239b372021-05-20 13:43:47 -0700295 uint32_t flags = 0;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200296 Rect layerStackSpaceRect;
297 Rect orientedDisplaySpaceRect;
Dominik Laskowski718f9602019-11-09 20:01:35 -0800298 ui::Rotation orientation = ui::ROTATION_0;
Irvelffc9efc2016-07-27 15:16:37 -0700299 uint32_t width = 0;
300 uint32_t height = 0;
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700301 std::string displayName;
Alan Dingfc6eab52024-05-02 18:28:45 -0700302 std::string uniqueId;
Irvelffc9efc2016-07-27 15:16:37 -0700303 bool isSecure = false;
Dennis Kiilerich85202062025-02-22 00:26:53 -0800304
305 gui::ISurfaceComposer::OptimizationPolicy optimizationPolicy =
306 gui::ISurfaceComposer::OptimizationPolicy::optimizeForPerformance;
Chavi Weingarten18fa7c62023-11-28 21:16:03 +0000307 bool isProtected = false;
Huihong Luo1768cb02022-10-11 11:10:34 -0700308 // Refer to DisplayDevice::mRequestedRefreshRate, for virtual display only
309 Fps requestedRefreshRate;
Brian Lindahl7a4cb7e2024-10-30 10:42:21 -0600310 int32_t maxLayerPictureProfiles = 0;
311 bool hasPictureProcessing = false;
Vladimir Komsiyskie0ab7b92025-03-07 01:10:15 -0800312 hardware::graphics::composer::hal::PowerMode initialPowerMode{
313 hardware::graphics::composer::hal::PowerMode::OFF};
Dominik Laskowski663bd282018-04-19 15:26:54 -0700314
315private:
316 static std::atomic<int32_t> sNextSequenceId;
Irvelffc9efc2016-07-27 15:16:37 -0700317};
318
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700319struct DisplayDeviceCreationArgs {
320 // We use a constructor to ensure some of the values are set, without
321 // assuming a default value.
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +0100322 DisplayDeviceCreationArgs(const sp<SurfaceFlinger>&, HWComposer& hwComposer,
323 const wp<IBinder>& displayToken,
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -0700324 std::shared_ptr<compositionengine::Display>);
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700325 const sp<SurfaceFlinger> flinger;
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +0100326 HWComposer& hwComposer;
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700327 const wp<IBinder> displayToken;
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -0700328 const std::shared_ptr<compositionengine::Display> compositionDisplay;
Dominik Laskowskid82e0f02022-10-26 15:23:04 -0400329 std::shared_ptr<scheduler::RefreshRateSelector> refreshRateSelector;
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700330
Dominik Laskowskie9774092018-12-11 10:04:24 -0800331 int32_t sequenceId{0};
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700332 bool isSecure{false};
Chavi Weingarten18fa7c62023-11-28 21:16:03 +0000333 bool isProtected{false};
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700334 sp<ANativeWindow> nativeWindow;
Lloyd Pique542307f2018-10-19 13:24:08 -0700335 sp<compositionengine::DisplaySurface> displaySurface;
Dominik Laskowski718f9602019-11-09 20:01:35 -0800336 ui::Rotation physicalOrientation{ui::ROTATION_0};
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700337 bool hasWideColorGamut{false};
338 HdrCapabilities hdrCapabilities;
339 int32_t supportedPerFrameMetadata{0};
340 std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>> hwcColorModes;
Dominik Laskowskia42d5392022-09-29 14:26:53 -0400341 hardware::graphics::composer::hal::PowerMode initialPowerMode{
342 hardware::graphics::composer::hal::PowerMode::OFF};
Dominik Laskowski075d3172018-05-24 15:50:06 -0700343 bool isPrimary{false};
Huihong Luo1768cb02022-10-11 11:10:34 -0700344 // Refer to DisplayDevice::mRequestedRefreshRate, for virtual display only
345 Fps requestedRefreshRate;
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700346};
347
Dominik Laskowski718f9602019-11-09 20:01:35 -0800348} // namespace android