blob: d79a6b5f3db7c2423fbf710342cbe91888e36c70 [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>
Dominik Laskowski075d3172018-05-24 15:50:06 -070020#include <optional>
Peiyong Linefefaac2018-08-17 12:27:51 -070021#include <string>
Peiyong Lin136fbbc2018-04-17 15:09:44 -070022#include <unordered_map>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080023
Dominik Laskowski298b08e2022-02-15 13:45:02 -080024#include <android-base/thread_annotations.h>
Alec Mourif6fd29e2018-11-17 04:56:41 +000025#include <android/native_window.h>
Dan Stoza9e56aa02015-11-02 13:00:03 -080026#include <binder/IBinder.h>
Chia-I Wuf2aa3112018-08-27 14:54:37 -070027#include <gui/LayerState.h>
Peiyong Linefefaac2018-08-17 12:27:51 -070028#include <math/mat4.h>
Alec Mouri0a9c7b82018-11-16 13:05:25 -080029#include <renderengine/RenderEngine.h>
Alec Mourif6fd29e2018-11-17 04:56:41 +000030#include <system/window.h>
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020031#include <ui/DisplayId.h>
Dominik Laskowski298b08e2022-02-15 13:45:02 -080032#include <ui/DisplayIdentification.h>
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080033#include <ui/DisplayState.h>
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -070034#include <ui/GraphicTypes.h>
Peiyong Linfb069302018-04-25 14:34:31 -070035#include <ui/HdrCapabilities.h>
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -070036#include <ui/Region.h>
Marin Shalamanov228f46b2021-01-28 21:11:45 +010037#include <ui/StaticDisplayInfo.h>
Peiyong Linefefaac2018-08-17 12:27:51 -070038#include <ui/Transform.h>
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +010039#include <utils/Errors.h>
Alec Mouri8d4f90a2018-11-14 22:33:24 +000040#include <utils/Mutex.h>
Alec Mouri0a9c7b82018-11-16 13:05:25 -080041#include <utils/RefBase.h>
Mathias Agopian86303202012-07-24 22:46:10 -070042#include <utils/Timers.h>
43
Marin Shalamanov23c44202020-12-22 19:09:20 +010044#include "DisplayHardware/DisplayMode.h"
Peiyong Line9d809e2020-04-14 13:10:48 -070045#include "DisplayHardware/Hal.h"
Lloyd Pique688abd42019-02-15 15:42:24 -080046#include "DisplayHardware/PowerAdvisor.h"
Ady Abraham3efa3942021-06-24 19:01:25 -070047#include "Scheduler/RefreshRateConfigs.h"
Dominik Laskowski298b08e2022-02-15 13:45:02 -080048#include "ThreadContext.h"
Ady Abraham690f4612021-07-01 23:24:03 -070049#include "TracedOrdinal.h"
50
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080051namespace android {
52
Dan Stoza9e56aa02015-11-02 13:00:03 -080053class Fence;
Lloyd Pique2eef1d22018-09-18 21:30:04 -070054class HWComposer;
Jesse Hall9e663de2013-08-16 14:28:37 -070055class IGraphicBufferProducer;
Mathias Agopian13127d82013-03-05 17:47:11 -080056class Layer;
Ady Abraham1b11bc62021-06-03 19:51:19 -070057class RefreshRateOverlay;
Mathias Agopian86303202012-07-24 22:46:10 -070058class SurfaceFlinger;
Lloyd Pique2eef1d22018-09-18 21:30:04 -070059
David Sodmanfb95bcc2017-12-22 15:45:30 -080060struct CompositionInfo;
Lloyd Pique2eef1d22018-09-18 21:30:04 -070061struct DisplayDeviceCreationArgs;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080062
Lloyd Pique45a165a2018-10-19 11:54:47 -070063namespace compositionengine {
64class Display;
Lloyd Pique542307f2018-10-19 13:24:08 -070065class DisplaySurface;
Lloyd Pique45a165a2018-10-19 11:54:47 -070066} // namespace compositionengine
67
Dominik Laskowskib363c4c2022-08-02 14:03:41 -070068namespace display {
69class DisplaySnapshot;
70} // namespace display
71
Marin Shalamanov1c434292020-06-12 01:47:29 +020072class DisplayDevice : public RefBase {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080073public:
Peiyong Linfb069302018-04-25 14:34:31 -070074 constexpr static float sDefaultMinLumiance = 0.0;
75 constexpr static float sDefaultMaxLumiance = 500.0;
Evan Rosky2239b372021-05-20 13:43:47 -070076 enum { eReceivesInput = 0x01 };
Peiyong Linfb069302018-04-25 14:34:31 -070077
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -070078 explicit DisplayDevice(DisplayDeviceCreationArgs& args);
Marin Shalamanov1c434292020-06-12 01:47:29 +020079
80 // Must be destroyed on the main thread because it may call into HWComposer.
Lloyd Pique45a165a2018-10-19 11:54:47 -070081 virtual ~DisplayDevice();
82
83 std::shared_ptr<compositionengine::Display> getCompositionDisplay() const {
84 return mCompositionDisplay;
85 }
Mathias Agopian92a979a2012-08-02 18:32:23 -070086
Dominik Laskowskib363c4c2022-08-02 14:03:41 -070087 bool isVirtual() const { return VirtualDisplayId::tryCast(getId()).has_value(); }
Dominik Laskowski075d3172018-05-24 15:50:06 -070088 bool isPrimary() const { return mIsPrimary; }
Mathias Agopian92a979a2012-08-02 18:32:23 -070089
Jamie Gennisdd3cb842012-10-19 18:19:11 -070090 // isSecure indicates whether this display can be trusted to display
91 // secure surfaces.
Lloyd Pique45a165a2018-10-19 11:54:47 -070092 bool isSecure() const;
Jamie Gennisdd3cb842012-10-19 18:19:11 -070093
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080094 int getWidth() const;
95 int getHeight() const;
96 ui::Size getSize() const { return {getWidth(), getHeight()}; }
Mathias Agopian3eb38cb2012-04-03 22:09:52 -070097
Dominik Laskowskib363c4c2022-08-02 14:03:41 -070098 void setLayerFilter(ui::LayerFilter);
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080099 void setDisplaySize(int width, int height);
Dominik Laskowski718f9602019-11-09 20:01:35 -0800100 void setProjection(ui::Rotation orientation, Rect viewport, Rect frame);
Dominik Laskowski298b08e2022-02-15 13:45:02 -0800101 void stageBrightness(float brightness) REQUIRES(kMainThreadContext);
102 void persistBrightness(bool needsComposite) REQUIRES(kMainThreadContext);
103 bool isBrightnessStale() const REQUIRES(kMainThreadContext);
Evan Rosky2239b372021-05-20 13:43:47 -0700104 void setFlags(uint32_t flags);
Dominik Laskowski718f9602019-11-09 20:01:35 -0800105
106 ui::Rotation getPhysicalOrientation() const { return mPhysicalOrientation; }
107 ui::Rotation getOrientation() const { return mOrientation; }
108
109 static ui::Transform::RotationFlags getPrimaryDisplayRotationFlags();
110
Dominik Laskowski298b08e2022-02-15 13:45:02 -0800111 std::optional<float> getStagedBrightness() const REQUIRES(kMainThreadContext);
Garfield Tan54edd912020-10-21 16:31:41 -0700112 ui::Transform::RotationFlags getTransformHint() const;
Lloyd Pique32cbe282018-10-19 13:09:22 -0700113 const ui::Transform& getTransform() const;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200114 const Rect& getLayerStackSpaceRect() const;
115 const Rect& getOrientedDisplaySpaceRect() const;
Lloyd Pique32cbe282018-10-19 13:09:22 -0700116 bool needsFiltering() const;
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800117 ui::LayerStack getLayerStack() const;
Evan Rosky2239b372021-05-20 13:43:47 -0700118 bool receivesInput() const { return mFlags & eReceivesInput; }
Dominik Laskowski075d3172018-05-24 15:50:06 -0700119
Dominik Laskowski3dce4f42021-03-08 20:48:28 -0800120 DisplayId getId() const;
121
122 // Shorthand to upcast the ID of a display whose type is known as a precondition.
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200123 PhysicalDisplayId getPhysicalId() const {
Dominik Laskowski3dce4f42021-03-08 20:48:28 -0800124 const auto id = PhysicalDisplayId::tryCast(getId());
125 LOG_FATAL_IF(!id);
126 return *id;
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200127 }
128
Dominik Laskowski3dce4f42021-03-08 20:48:28 -0800129 VirtualDisplayId getVirtualId() const {
130 const auto id = VirtualDisplayId::tryCast(getId());
131 LOG_FATAL_IF(!id);
132 return *id;
133 }
134
Dominik Laskowski075d3172018-05-24 15:50:06 -0700135 const wp<IBinder>& getDisplayToken() const { return mDisplayToken; }
Dominik Laskowskie9774092018-12-11 10:04:24 -0800136 int32_t getSequenceId() const { return mSequenceId; }
Mathias Agopian87baae12012-07-31 12:38:26 -0700137
Lloyd Pique32cbe282018-10-19 13:09:22 -0700138 const Region& getUndefinedRegion() const;
139
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700140 int32_t getSupportedPerFrameMetadata() const;
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -0700141
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700142 bool hasWideColorGamut() const;
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700143 // Whether h/w composer has native support for specific HDR type.
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700144 bool hasHDR10PlusSupport() const;
145 bool hasHDR10Support() const;
146 bool hasHLGSupport() const;
147 bool hasDolbyVisionSupport() const;
Chia-I Wube02ec02018-05-18 10:59:36 -0700148
Kriti Dang4bc7cdf2021-01-08 11:49:56 +0100149 void overrideHdrTypes(const std::vector<ui::Hdr>& hdrTypes);
150
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.
Kriti Dang4bc7cdf2021-01-08 11:49:56 +0100157 HdrCapabilities getHdrCapabilities() const;
Jesse Hall38efe862013-04-06 23:12:29 -0700158
Chia-I Wube02ec02018-05-18 10:59:36 -0700159 // Return true if intent is supported by the display.
160 bool hasRenderIntent(ui::RenderIntent intent) const;
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700161
Angel Aguayob108a6d2021-08-06 21:34:57 +0000162 const Rect getBounds() const;
163 const Rect bounds() const { return getBounds(); }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800164
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700165 void setDisplayName(const std::string& displayName);
166 const std::string& getDisplayName() const { return mDisplayName; }
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700167
Dominik Laskowski9f410f02022-01-08 16:22:46 -0800168 struct InputInfo {
169 gui::DisplayInfo info;
170 ui::Transform transform;
171 bool receivesInput;
172 bool isSecure;
173 };
174
175 InputInfo getInputInfo() const;
Prabir Pradhan48f8cb92021-08-26 14:05:36 -0700176
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700177 /* ------------------------------------------------------------------------
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700178 * Display power mode management.
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700179 */
linpeter1c69cd32022-07-13 19:20:48 +0800180 std::optional<hardware::graphics::composer::hal::PowerMode> getPowerMode() const;
Peiyong Lin65248e02020-04-18 21:15:07 -0700181 void setPowerMode(hardware::graphics::composer::hal::PowerMode mode);
Dominik Laskowskieecd6592018-05-29 10:25:41 -0700182 bool isPoweredOn() const;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700183
Alec Mouridd8bf2d2021-05-08 16:36:33 -0700184 // Enables layer caching on this DisplayDevice
185 void enableLayerCaching(bool enable);
186
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800187 ui::Dataspace getCompositionDataSpace() const;
Michael Wright28f24d02016-07-12 13:30:53 -0700188
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700189 /* ------------------------------------------------------------------------
Marin Shalamanov5801c942020-12-17 17:00:13 +0100190 * Display mode management.
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700191 */
Marin Shalamanov5801c942020-12-17 17:00:13 +0100192 const DisplayModePtr& getActiveMode() const;
Ady Abraham690f4612021-07-01 23:24:03 -0700193
194 struct ActiveModeInfo {
195 DisplayModePtr mode;
Dominik Laskowski068173d2021-08-11 17:22:59 -0700196 scheduler::DisplayModeEvent event = scheduler::DisplayModeEvent::None;
Ady Abraham690f4612021-07-01 23:24:03 -0700197
198 bool operator!=(const ActiveModeInfo& other) const {
199 return mode != other.mode || event != other.event;
200 }
201 };
202
203 bool setDesiredActiveMode(const ActiveModeInfo&) EXCLUDES(mActiveModeLock);
204 std::optional<ActiveModeInfo> getDesiredActiveMode() const EXCLUDES(mActiveModeLock);
205 void clearDesiredActiveModeState() EXCLUDES(mActiveModeLock);
Dominik Laskowski298b08e2022-02-15 13:45:02 -0800206 ActiveModeInfo getUpcomingActiveMode() const REQUIRES(kMainThreadContext) {
Ady Abraham690f4612021-07-01 23:24:03 -0700207 return mUpcomingActiveMode;
208 }
209
Dominik Laskowskib363c4c2022-08-02 14:03:41 -0700210 // Precondition: DisplaySnapshot must contain a mode with DisplayModeId.
211 void setActiveMode(DisplayModeId, const display::DisplaySnapshot&) REQUIRES(kMainThreadContext);
212
Ady Abraham690f4612021-07-01 23:24:03 -0700213 status_t initiateModeChange(const ActiveModeInfo&,
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +0100214 const hal::VsyncPeriodChangeConstraints& constraints,
Ady Abraham690f4612021-07-01 23:24:03 -0700215 hal::VsyncPeriodChangeTimeline* outTimeline)
Dominik Laskowski298b08e2022-02-15 13:45:02 -0800216 REQUIRES(kMainThreadContext);
Marin Shalamanov5801c942020-12-17 17:00:13 +0100217
Ady Abraham3efa3942021-06-24 19:01:25 -0700218 // Returns the refresh rate configs for this display.
219 scheduler::RefreshRateConfigs& refreshRateConfigs() const { return *mRefreshRateConfigs; }
220
221 // Returns a shared pointer to the refresh rate configs for this display.
222 // Clients can store this refresh rate configs and use it even if the DisplayDevice
223 // is destroyed.
224 std::shared_ptr<scheduler::RefreshRateConfigs> holdRefreshRateConfigs() const {
225 return mRefreshRateConfigs;
226 }
227
Ady Abraham1b11bc62021-06-03 19:51:19 -0700228 // Enables an overlay to be displayed with the current refresh rate
229 void enableRefreshRateOverlay(bool enable, bool showSpinner);
230 bool isRefreshRateOverlayEnabled() const { return mRefreshRateOverlay != nullptr; }
231 bool onKernelTimerChanged(std::optional<DisplayModeId>, bool timerExpired);
Dominik Laskowskie0e0cde2021-07-30 10:42:05 -0700232 void animateRefreshRateOverlay();
Ady Abraham1b11bc62021-06-03 19:51:19 -0700233
Marin Shalamanov045b7002021-01-07 16:56:24 +0100234 void onVsync(nsecs_t timestamp);
235 nsecs_t getVsyncPeriodFromHWC() const;
236 nsecs_t getRefreshTimestamp() const;
237
Ady Abrahama92a5682022-06-07 23:35:38 +0000238 status_t setRefreshRatePolicy(
239 const std::optional<scheduler::RefreshRateConfigs::Policy>& policy,
240 bool overridePolicy);
241
Jesse Hall02d86562013-03-25 14:43:23 -0700242 // release HWC resources (if any) for removable displays
Lloyd Pique45a165a2018-10-19 11:54:47 -0700243 void disconnect();
Jesse Hall02d86562013-03-25 14:43:23 -0700244
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700245 /* ------------------------------------------------------------------------
246 * Debugging
247 */
Dominik Laskowski9b17b2c22018-11-01 14:49:03 -0700248 std::string getDebugName() const;
Yiwei Zhang5434a782018-12-05 18:06:32 -0800249 void dump(std::string& result) const;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700250
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800251private:
Dominik Laskowski075d3172018-05-24 15:50:06 -0700252 const sp<SurfaceFlinger> mFlinger;
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +0100253 HWComposer& mHwComposer;
Dominik Laskowski075d3172018-05-24 15:50:06 -0700254 const wp<IBinder> mDisplayToken;
Dominik Laskowskie9774092018-12-11 10:04:24 -0800255 const int32_t mSequenceId;
Dominik Laskowski075d3172018-05-24 15:50:06 -0700256
Lloyd Pique45a165a2018-10-19 11:54:47 -0700257 const std::shared_ptr<compositionengine::Display> mCompositionDisplay;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700258
Lloyd Pique31cb2942018-10-19 17:23:03 -0700259 std::string mDisplayName;
Ady Abraham690f4612021-07-01 23:24:03 -0700260 std::string mActiveModeFPSTrace;
261 std::string mActiveModeFPSHwcTrace;
Mathias Agopian03e40722012-04-26 16:11:59 -0700262
Dominik Laskowski718f9602019-11-09 20:01:35 -0800263 const ui::Rotation mPhysicalOrientation;
264 ui::Rotation mOrientation = ui::ROTATION_0;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700265
Dominik Laskowski718f9602019-11-09 20:01:35 -0800266 static ui::Transform::RotationFlags sPrimaryDisplayRotationFlags;
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700267
linpeter1c69cd32022-07-13 19:20:48 +0800268 // allow initial power mode as null.
269 std::optional<hardware::graphics::composer::hal::PowerMode> mPowerMode;
Marin Shalamanovf22e6ac2021-02-10 20:45:15 +0100270 DisplayModePtr mActiveMode;
Alec Mouricdf16792021-12-10 13:16:06 -0800271 std::optional<float> mStagedBrightness = std::nullopt;
272 float mBrightness = -1.f;
Courtney Goeltzenleuchter5d943892017-03-22 13:46:46 -0600273
Marin Shalamanov045b7002021-01-07 16:56:24 +0100274 std::atomic<nsecs_t> mLastHwVsync = 0;
275
Dominik Laskowskif8db0f02021-04-19 11:05:25 -0700276 // TODO(b/182939859): Remove special cases for primary display.
Dominik Laskowski075d3172018-05-24 15:50:06 -0700277 const bool mIsPrimary;
Marin Shalamanove5cceea2020-04-30 18:13:10 +0200278
Evan Rosky2239b372021-05-20 13:43:47 -0700279 uint32_t mFlags = 0;
280
Kriti Dang4bc7cdf2021-01-08 11:49:56 +0100281 std::vector<ui::Hdr> mOverrideHdrTypes;
Ady Abraham3efa3942021-06-24 19:01:25 -0700282
283 std::shared_ptr<scheduler::RefreshRateConfigs> mRefreshRateConfigs;
Ady Abraham1b11bc62021-06-03 19:51:19 -0700284 std::unique_ptr<RefreshRateOverlay> mRefreshRateOverlay;
Ady Abraham690f4612021-07-01 23:24:03 -0700285
286 mutable std::mutex mActiveModeLock;
287 ActiveModeInfo mDesiredActiveMode GUARDED_BY(mActiveModeLock);
288 TracedOrdinal<bool> mDesiredActiveModeChanged
289 GUARDED_BY(mActiveModeLock) = {"DesiredActiveModeChanged", false};
Dominik Laskowski298b08e2022-02-15 13:45:02 -0800290 ActiveModeInfo mUpcomingActiveMode GUARDED_BY(kMainThreadContext);
Ady Abrahama92a5682022-06-07 23:35:38 +0000291
292 std::atomic_int mNumModeSwitchesInPolicy = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800293};
294
Irvelffc9efc2016-07-27 15:16:37 -0700295struct DisplayDeviceState {
Dominik Laskowski55c85402020-01-21 16:25:47 -0800296 struct Physical {
Marin Shalamanova524a092020-07-27 21:39:55 +0200297 PhysicalDisplayId id;
Peiyong Lin65248e02020-04-18 21:15:07 -0700298 hardware::graphics::composer::hal::HWDisplayId hwcDisplayId;
Marin Shalamanova903d032020-12-29 20:35:13 +0100299 DisplayModePtr activeMode;
300
Dominik Laskowski55c85402020-01-21 16:25:47 -0800301 bool operator==(const Physical& other) const {
Dominik Laskowskib363c4c2022-08-02 14:03:41 -0700302 return id == other.id && hwcDisplayId == other.hwcDisplayId;
Dominik Laskowski55c85402020-01-21 16:25:47 -0800303 }
304 };
305
306 bool isVirtual() const { return !physical; }
Irvelffc9efc2016-07-27 15:16:37 -0700307
Dominik Laskowski663bd282018-04-19 15:26:54 -0700308 int32_t sequenceId = sNextSequenceId++;
Dominik Laskowski55c85402020-01-21 16:25:47 -0800309 std::optional<Physical> physical;
Irvelffc9efc2016-07-27 15:16:37 -0700310 sp<IGraphicBufferProducer> surface;
Dominik Laskowski29fa1462021-04-27 15:51:50 -0700311 ui::LayerStack layerStack;
Evan Rosky2239b372021-05-20 13:43:47 -0700312 uint32_t flags = 0;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200313 Rect layerStackSpaceRect;
314 Rect orientedDisplaySpaceRect;
Dominik Laskowski718f9602019-11-09 20:01:35 -0800315 ui::Rotation orientation = ui::ROTATION_0;
Irvelffc9efc2016-07-27 15:16:37 -0700316 uint32_t width = 0;
317 uint32_t height = 0;
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700318 std::string displayName;
Irvelffc9efc2016-07-27 15:16:37 -0700319 bool isSecure = false;
Dominik Laskowski663bd282018-04-19 15:26:54 -0700320
321private:
322 static std::atomic<int32_t> sNextSequenceId;
Irvelffc9efc2016-07-27 15:16:37 -0700323};
324
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700325struct DisplayDeviceCreationArgs {
326 // We use a constructor to ensure some of the values are set, without
327 // assuming a default value.
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +0100328 DisplayDeviceCreationArgs(const sp<SurfaceFlinger>&, HWComposer& hwComposer,
329 const wp<IBinder>& displayToken,
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -0700330 std::shared_ptr<compositionengine::Display>);
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700331 const sp<SurfaceFlinger> flinger;
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +0100332 HWComposer& hwComposer;
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700333 const wp<IBinder> displayToken;
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -0700334 const std::shared_ptr<compositionengine::Display> compositionDisplay;
Ady Abraham3efa3942021-06-24 19:01:25 -0700335 std::shared_ptr<scheduler::RefreshRateConfigs> refreshRateConfigs;
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700336
Dominik Laskowskie9774092018-12-11 10:04:24 -0800337 int32_t sequenceId{0};
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700338 bool isSecure{false};
339 sp<ANativeWindow> nativeWindow;
Lloyd Pique542307f2018-10-19 13:24:08 -0700340 sp<compositionengine::DisplaySurface> displaySurface;
Dominik Laskowski718f9602019-11-09 20:01:35 -0800341 ui::Rotation physicalOrientation{ui::ROTATION_0};
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700342 bool hasWideColorGamut{false};
343 HdrCapabilities hdrCapabilities;
344 int32_t supportedPerFrameMetadata{0};
345 std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>> hwcColorModes;
linpeter1c69cd32022-07-13 19:20:48 +0800346 std::optional<hardware::graphics::composer::hal::PowerMode> initialPowerMode;
Dominik Laskowski075d3172018-05-24 15:50:06 -0700347 bool isPrimary{false};
Ady Abraham3efa3942021-06-24 19:01:25 -0700348 DisplayModeId activeModeId;
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700349};
350
Dominik Laskowski718f9602019-11-09 20:01:35 -0800351} // namespace android