blob: afd12b59a323392ac1aa7fa232605b9c970a57e1 [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
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>
Chia-I Wuf2aa3112018-08-27 14:54:37 -070026#include <gui/LayerState.h>
Peiyong Linefefaac2018-08-17 12:27:51 -070027#include <math/mat4.h>
Alec Mouri0a9c7b82018-11-16 13:05:25 -080028#include <renderengine/RenderEngine.h>
Alec Mourif6fd29e2018-11-17 04:56:41 +000029#include <system/window.h>
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020030#include <ui/DisplayId.h>
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080031#include <ui/DisplayState.h>
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -070032#include <ui/GraphicTypes.h>
Peiyong Linfb069302018-04-25 14:34:31 -070033#include <ui/HdrCapabilities.h>
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -070034#include <ui/Region.h>
Marin Shalamanov228f46b2021-01-28 21:11:45 +010035#include <ui/StaticDisplayInfo.h>
Peiyong Linefefaac2018-08-17 12:27:51 -070036#include <ui/Transform.h>
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +010037#include <utils/Errors.h>
Alec Mouri8d4f90a2018-11-14 22:33:24 +000038#include <utils/Mutex.h>
Alec Mouri0a9c7b82018-11-16 13:05:25 -080039#include <utils/RefBase.h>
Mathias Agopian86303202012-07-24 22:46:10 -070040#include <utils/Timers.h>
41
Ady Abraham690f4612021-07-01 23:24:03 -070042#include "MainThreadGuard.h"
43
Dominik Laskowski075d3172018-05-24 15:50:06 -070044#include "DisplayHardware/DisplayIdentification.h"
Marin Shalamanov23c44202020-12-22 19:09:20 +010045#include "DisplayHardware/DisplayMode.h"
Peiyong Line9d809e2020-04-14 13:10:48 -070046#include "DisplayHardware/Hal.h"
Lloyd Pique688abd42019-02-15 15:42:24 -080047#include "DisplayHardware/PowerAdvisor.h"
Mathias Agopianf4358632012-08-22 17:16:19 -070048
Ady Abraham3efa3942021-06-24 19:01:25 -070049#include "Scheduler/RefreshRateConfigs.h"
50
Ady Abraham690f4612021-07-01 23:24:03 -070051#include "TracedOrdinal.h"
52
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;
Jesse Hall9e663de2013-08-16 14:28:37 -070057class IGraphicBufferProducer;
Mathias Agopian13127d82013-03-05 17:47:11 -080058class Layer;
Ady Abraham1b11bc62021-06-03 19:51:19 -070059class RefreshRateOverlay;
Mathias Agopian86303202012-07-24 22:46:10 -070060class SurfaceFlinger;
Lloyd Pique2eef1d22018-09-18 21:30:04 -070061
David Sodmanfb95bcc2017-12-22 15:45:30 -080062struct CompositionInfo;
Lloyd Pique2eef1d22018-09-18 21:30:04 -070063struct DisplayDeviceCreationArgs;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080064
Lloyd Pique45a165a2018-10-19 11:54:47 -070065namespace compositionengine {
66class Display;
Lloyd Pique542307f2018-10-19 13:24:08 -070067class DisplaySurface;
Lloyd Pique45a165a2018-10-19 11:54:47 -070068} // namespace compositionengine
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
Marin Shalamanov228f46b2021-01-28 21:11:45 +010085 std::optional<ui::DisplayConnectionType> getConnectionType() const { return mConnectionType; }
Dominik Laskowski55c85402020-01-21 16:25:47 -080086
87 bool isVirtual() const { return !mConnectionType; }
Dominik Laskowski075d3172018-05-24 15:50:06 -070088 bool isPrimary() const { return mIsPrimary; }
Ady Abrahamed3290f2021-05-17 15:12:14 -070089 bool isInternal() const {
90 return !isVirtual() && mConnectionType == ui::DisplayConnectionType::Internal;
91 }
Mathias Agopian92a979a2012-08-02 18:32:23 -070092
Jamie Gennisdd3cb842012-10-19 18:19:11 -070093 // isSecure indicates whether this display can be trusted to display
94 // secure surfaces.
Lloyd Pique45a165a2018-10-19 11:54:47 -070095 bool isSecure() const;
Jamie Gennisdd3cb842012-10-19 18:19:11 -070096
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080097 int getWidth() const;
98 int getHeight() const;
99 ui::Size getSize() const { return {getWidth(), getHeight()}; }
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700100
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800101 void setLayerStack(ui::LayerStack);
102 void setDisplaySize(int width, int height);
Dominik Laskowski718f9602019-11-09 20:01:35 -0800103 void setProjection(ui::Rotation orientation, Rect viewport, Rect frame);
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
Garfield Tan54edd912020-10-21 16:31:41 -0700111 ui::Transform::RotationFlags getTransformHint() const;
Lloyd Pique32cbe282018-10-19 13:09:22 -0700112 const ui::Transform& getTransform() const;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200113 const Rect& getLayerStackSpaceRect() const;
114 const Rect& getOrientedDisplaySpaceRect() const;
Lloyd Pique32cbe282018-10-19 13:09:22 -0700115 bool needsFiltering() const;
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800116 ui::LayerStack getLayerStack() const;
Evan Rosky2239b372021-05-20 13:43:47 -0700117 bool receivesInput() const { return mFlags & eReceivesInput; }
Dominik Laskowski075d3172018-05-24 15:50:06 -0700118
Dominik Laskowski3dce4f42021-03-08 20:48:28 -0800119 DisplayId getId() const;
120
121 // Shorthand to upcast the ID of a display whose type is known as a precondition.
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200122 PhysicalDisplayId getPhysicalId() const {
Dominik Laskowski3dce4f42021-03-08 20:48:28 -0800123 const auto id = PhysicalDisplayId::tryCast(getId());
124 LOG_FATAL_IF(!id);
125 return *id;
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200126 }
127
Dominik Laskowski3dce4f42021-03-08 20:48:28 -0800128 VirtualDisplayId getVirtualId() const {
129 const auto id = VirtualDisplayId::tryCast(getId());
130 LOG_FATAL_IF(!id);
131 return *id;
132 }
133
Dominik Laskowski075d3172018-05-24 15:50:06 -0700134 const wp<IBinder>& getDisplayToken() const { return mDisplayToken; }
Dominik Laskowskie9774092018-12-11 10:04:24 -0800135 int32_t getSequenceId() const { return mSequenceId; }
Mathias Agopian87baae12012-07-31 12:38:26 -0700136
Lloyd Pique32cbe282018-10-19 13:09:22 -0700137 const Region& getUndefinedRegion() const;
138
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700139 int32_t getSupportedPerFrameMetadata() const;
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -0700140
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700141 bool hasWideColorGamut() const;
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700142 // Whether h/w composer has native support for specific HDR type.
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700143 bool hasHDR10PlusSupport() const;
144 bool hasHDR10Support() const;
145 bool hasHLGSupport() const;
146 bool hasDolbyVisionSupport() const;
Chia-I Wube02ec02018-05-18 10:59:36 -0700147
Kriti Dang4bc7cdf2021-01-08 11:49:56 +0100148 void overrideHdrTypes(const std::vector<ui::Hdr>& hdrTypes);
149
Peiyong Linfb069302018-04-25 14:34:31 -0700150 // The returned HdrCapabilities is the combination of HDR capabilities from
151 // hardware composer and RenderEngine. When the DisplayDevice supports wide
152 // color gamut, RenderEngine is able to simulate HDR support in Display P3
153 // color space for both PQ and HLG HDR contents. The minimum and maximum
154 // luminance will be set to sDefaultMinLumiance and sDefaultMaxLumiance
155 // respectively if hardware composer doesn't return meaningful values.
Kriti Dang4bc7cdf2021-01-08 11:49:56 +0100156 HdrCapabilities getHdrCapabilities() const;
Jesse Hall38efe862013-04-06 23:12:29 -0700157
Chia-I Wube02ec02018-05-18 10:59:36 -0700158 // Return true if intent is supported by the display.
159 bool hasRenderIntent(ui::RenderIntent intent) const;
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700160
Lloyd Pique32cbe282018-10-19 13:09:22 -0700161 const Rect& getBounds() const;
162 const Rect& bounds() const { return getBounds(); }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800163
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700164 void setDisplayName(const std::string& displayName);
165 const std::string& getDisplayName() const { return mDisplayName; }
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700166
Marin Shalamanove5cceea2020-04-30 18:13:10 +0200167 void setDeviceProductInfo(std::optional<DeviceProductInfo> info);
168 const std::optional<DeviceProductInfo>& getDeviceProductInfo() const {
169 return mDeviceProductInfo;
170 }
171
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700172 /* ------------------------------------------------------------------------
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700173 * Display power mode management.
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700174 */
Peiyong Lin65248e02020-04-18 21:15:07 -0700175 hardware::graphics::composer::hal::PowerMode getPowerMode() const;
176 void setPowerMode(hardware::graphics::composer::hal::PowerMode mode);
Dominik Laskowskieecd6592018-05-29 10:25:41 -0700177 bool isPoweredOn() const;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700178
Alec Mouridd8bf2d2021-05-08 16:36:33 -0700179 // Enables layer caching on this DisplayDevice
180 void enableLayerCaching(bool enable);
181
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800182 ui::Dataspace getCompositionDataSpace() const;
Michael Wright28f24d02016-07-12 13:30:53 -0700183
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700184 /* ------------------------------------------------------------------------
Marin Shalamanov5801c942020-12-17 17:00:13 +0100185 * Display mode management.
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700186 */
Marin Shalamanov5801c942020-12-17 17:00:13 +0100187 const DisplayModePtr& getActiveMode() const;
Ady Abraham690f4612021-07-01 23:24:03 -0700188
189 struct ActiveModeInfo {
190 DisplayModePtr mode;
191 scheduler::RefreshRateConfigEvent event = scheduler::RefreshRateConfigEvent::None;
192
193 bool operator!=(const ActiveModeInfo& other) const {
194 return mode != other.mode || event != other.event;
195 }
196 };
197
198 bool setDesiredActiveMode(const ActiveModeInfo&) EXCLUDES(mActiveModeLock);
199 std::optional<ActiveModeInfo> getDesiredActiveMode() const EXCLUDES(mActiveModeLock);
200 void clearDesiredActiveModeState() EXCLUDES(mActiveModeLock);
201 ActiveModeInfo getUpcomingActiveMode() const REQUIRES(SF_MAIN_THREAD) {
202 return mUpcomingActiveMode;
203 }
204
205 void setActiveMode(DisplayModeId) REQUIRES(SF_MAIN_THREAD);
206 status_t initiateModeChange(const ActiveModeInfo&,
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +0100207 const hal::VsyncPeriodChangeConstraints& constraints,
Ady Abraham690f4612021-07-01 23:24:03 -0700208 hal::VsyncPeriodChangeTimeline* outTimeline)
209 REQUIRES(SF_MAIN_THREAD);
Marin Shalamanov5801c942020-12-17 17:00:13 +0100210
211 // Return the immutable list of supported display modes. The HWC may report different modes
212 // after a hotplug reconnect event, in which case the DisplayDevice object will be recreated.
213 // Hotplug reconnects are common for external displays.
214 const DisplayModes& getSupportedModes() const;
215
216 // Returns nullptr if the given mode ID is not supported. A previously
217 // supported mode may be no longer supported for some devices like TVs and
218 // set-top boxes after a hotplug reconnect.
219 DisplayModePtr getMode(DisplayModeId) const;
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700220
Ady Abraham3efa3942021-06-24 19:01:25 -0700221 // Returns the refresh rate configs for this display.
222 scheduler::RefreshRateConfigs& refreshRateConfigs() const { return *mRefreshRateConfigs; }
223
224 // Returns a shared pointer to the refresh rate configs for this display.
225 // Clients can store this refresh rate configs and use it even if the DisplayDevice
226 // is destroyed.
227 std::shared_ptr<scheduler::RefreshRateConfigs> holdRefreshRateConfigs() const {
228 return mRefreshRateConfigs;
229 }
230
Ady Abraham1b11bc62021-06-03 19:51:19 -0700231 // Enables an overlay to be displayed with the current refresh rate
232 void enableRefreshRateOverlay(bool enable, bool showSpinner);
233 bool isRefreshRateOverlayEnabled() const { return mRefreshRateOverlay != nullptr; }
234 bool onKernelTimerChanged(std::optional<DisplayModeId>, bool timerExpired);
235 void onInvalidate();
236
Marin Shalamanov045b7002021-01-07 16:56:24 +0100237 void onVsync(nsecs_t timestamp);
238 nsecs_t getVsyncPeriodFromHWC() const;
239 nsecs_t getRefreshTimestamp() const;
240
Jesse Hall02d86562013-03-25 14:43:23 -0700241 // release HWC resources (if any) for removable displays
Lloyd Pique45a165a2018-10-19 11:54:47 -0700242 void disconnect();
Jesse Hall02d86562013-03-25 14:43:23 -0700243
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700244 /* ------------------------------------------------------------------------
245 * Debugging
246 */
247 uint32_t getPageFlipCount() const;
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;
Marin Shalamanov228f46b2021-01-28 21:11:45 +0100256 const std::optional<ui::DisplayConnectionType> mConnectionType;
Dominik Laskowski075d3172018-05-24 15:50:06 -0700257
Lloyd Pique45a165a2018-10-19 11:54:47 -0700258 const std::shared_ptr<compositionengine::Display> mCompositionDisplay;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700259
Lloyd Pique31cb2942018-10-19 17:23:03 -0700260 std::string mDisplayName;
Ady Abraham690f4612021-07-01 23:24:03 -0700261 std::string mActiveModeFPSTrace;
262 std::string mActiveModeFPSHwcTrace;
Mathias Agopian03e40722012-04-26 16:11:59 -0700263
Dominik Laskowski718f9602019-11-09 20:01:35 -0800264 const ui::Rotation mPhysicalOrientation;
265 ui::Rotation mOrientation = ui::ROTATION_0;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700266
Dominik Laskowski718f9602019-11-09 20:01:35 -0800267 static ui::Transform::RotationFlags sPrimaryDisplayRotationFlags;
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700268
Peiyong Lin65248e02020-04-18 21:15:07 -0700269 hardware::graphics::composer::hal::PowerMode mPowerMode =
270 hardware::graphics::composer::hal::PowerMode::OFF;
Marin Shalamanovf22e6ac2021-02-10 20:45:15 +0100271 DisplayModePtr mActiveMode;
Marin Shalamanov5801c942020-12-17 17:00:13 +0100272 const DisplayModes mSupportedModes;
Courtney Goeltzenleuchter5d943892017-03-22 13:46:46 -0600273
Marin Shalamanov045b7002021-01-07 16:56:24 +0100274 std::atomic<nsecs_t> mLastHwVsync = 0;
275
Dominik Laskowski075d3172018-05-24 15:50:06 -0700276 // TODO(b/74619554): Remove special cases for primary display.
277 const bool mIsPrimary;
Marin Shalamanove5cceea2020-04-30 18:13:10 +0200278
Evan Rosky2239b372021-05-20 13:43:47 -0700279 uint32_t mFlags = 0;
280
Marin Shalamanove5cceea2020-04-30 18:13:10 +0200281 std::optional<DeviceProductInfo> mDeviceProductInfo;
Kriti Dang4bc7cdf2021-01-08 11:49:56 +0100282
283 std::vector<ui::Hdr> mOverrideHdrTypes;
Ady Abraham3efa3942021-06-24 19:01:25 -0700284
285 std::shared_ptr<scheduler::RefreshRateConfigs> mRefreshRateConfigs;
Ady Abraham1b11bc62021-06-03 19:51:19 -0700286 std::unique_ptr<RefreshRateOverlay> mRefreshRateOverlay;
Ady Abraham690f4612021-07-01 23:24:03 -0700287
288 mutable std::mutex mActiveModeLock;
289 ActiveModeInfo mDesiredActiveMode GUARDED_BY(mActiveModeLock);
290 TracedOrdinal<bool> mDesiredActiveModeChanged
291 GUARDED_BY(mActiveModeLock) = {"DesiredActiveModeChanged", false};
292 ActiveModeInfo mUpcomingActiveMode GUARDED_BY(SF_MAIN_THREAD);
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;
Marin Shalamanov228f46b2021-01-28 21:11:45 +0100298 ui::DisplayConnectionType type;
Peiyong Lin65248e02020-04-18 21:15:07 -0700299 hardware::graphics::composer::hal::HWDisplayId hwcDisplayId;
Marin Shalamanov7ce87642020-05-06 13:45:58 +0200300 std::optional<DeviceProductInfo> deviceProductInfo;
Marin Shalamanova903d032020-12-29 20:35:13 +0100301 DisplayModes supportedModes;
302 DisplayModePtr activeMode;
303
Dominik Laskowski55c85402020-01-21 16:25:47 -0800304 bool operator==(const Physical& other) const {
Marin Shalamanov4a42d432020-02-12 20:22:26 +0100305 return id == other.id && type == other.type && hwcDisplayId == other.hwcDisplayId;
Dominik Laskowski55c85402020-01-21 16:25:47 -0800306 }
307 };
308
309 bool isVirtual() const { return !physical; }
Irvelffc9efc2016-07-27 15:16:37 -0700310
Dominik Laskowski663bd282018-04-19 15:26:54 -0700311 int32_t sequenceId = sNextSequenceId++;
Dominik Laskowski55c85402020-01-21 16:25:47 -0800312 std::optional<Physical> physical;
Irvelffc9efc2016-07-27 15:16:37 -0700313 sp<IGraphicBufferProducer> surface;
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800314 ui::LayerStack layerStack = ui::NO_LAYER_STACK;
Evan Rosky2239b372021-05-20 13:43:47 -0700315 uint32_t flags = 0;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200316 Rect layerStackSpaceRect;
317 Rect orientedDisplaySpaceRect;
Dominik Laskowski718f9602019-11-09 20:01:35 -0800318 ui::Rotation orientation = ui::ROTATION_0;
Irvelffc9efc2016-07-27 15:16:37 -0700319 uint32_t width = 0;
320 uint32_t height = 0;
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700321 std::string displayName;
Irvelffc9efc2016-07-27 15:16:37 -0700322 bool isSecure = false;
Dominik Laskowski663bd282018-04-19 15:26:54 -0700323
324private:
325 static std::atomic<int32_t> sNextSequenceId;
Irvelffc9efc2016-07-27 15:16:37 -0700326};
327
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700328struct DisplayDeviceCreationArgs {
329 // We use a constructor to ensure some of the values are set, without
330 // assuming a default value.
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +0100331 DisplayDeviceCreationArgs(const sp<SurfaceFlinger>&, HWComposer& hwComposer,
332 const wp<IBinder>& displayToken,
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -0700333 std::shared_ptr<compositionengine::Display>);
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700334 const sp<SurfaceFlinger> flinger;
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +0100335 HWComposer& hwComposer;
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700336 const wp<IBinder> displayToken;
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -0700337 const std::shared_ptr<compositionengine::Display> compositionDisplay;
Ady Abraham3efa3942021-06-24 19:01:25 -0700338 std::shared_ptr<scheduler::RefreshRateConfigs> refreshRateConfigs;
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700339
Dominik Laskowskie9774092018-12-11 10:04:24 -0800340 int32_t sequenceId{0};
Marin Shalamanov228f46b2021-01-28 21:11:45 +0100341 std::optional<ui::DisplayConnectionType> connectionType;
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700342 bool isSecure{false};
343 sp<ANativeWindow> nativeWindow;
Lloyd Pique542307f2018-10-19 13:24:08 -0700344 sp<compositionengine::DisplaySurface> displaySurface;
Dominik Laskowski718f9602019-11-09 20:01:35 -0800345 ui::Rotation physicalOrientation{ui::ROTATION_0};
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700346 bool hasWideColorGamut{false};
347 HdrCapabilities hdrCapabilities;
348 int32_t supportedPerFrameMetadata{0};
349 std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>> hwcColorModes;
Peiyong Lin65248e02020-04-18 21:15:07 -0700350 hardware::graphics::composer::hal::PowerMode initialPowerMode{
351 hardware::graphics::composer::hal::PowerMode::ON};
Dominik Laskowski075d3172018-05-24 15:50:06 -0700352 bool isPrimary{false};
Marin Shalamanov5801c942020-12-17 17:00:13 +0100353 DisplayModes supportedModes;
Ady Abraham3efa3942021-06-24 19:01:25 -0700354 DisplayModeId activeModeId;
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700355};
356
Dominik Laskowski718f9602019-11-09 20:01:35 -0800357} // namespace android