The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 17 | #pragma once |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | |
Peiyong Lin | efefaac | 2018-08-17 12:27:51 -0700 | [diff] [blame] | 19 | #include <memory> |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 20 | #include <optional> |
Peiyong Lin | efefaac | 2018-08-17 12:27:51 -0700 | [diff] [blame] | 21 | #include <string> |
Peiyong Lin | 136fbbc | 2018-04-17 15:09:44 -0700 | [diff] [blame] | 22 | #include <unordered_map> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | |
Alec Mouri | f6fd29e | 2018-11-17 04:56:41 +0000 | [diff] [blame] | 24 | #include <android/native_window.h> |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 25 | #include <binder/IBinder.h> |
Chia-I Wu | f2aa311 | 2018-08-27 14:54:37 -0700 | [diff] [blame] | 26 | #include <gui/LayerState.h> |
Peiyong Lin | efefaac | 2018-08-17 12:27:51 -0700 | [diff] [blame] | 27 | #include <math/mat4.h> |
Alec Mouri | 0a9c7b8 | 2018-11-16 13:05:25 -0800 | [diff] [blame] | 28 | #include <renderengine/RenderEngine.h> |
Alec Mouri | f6fd29e | 2018-11-17 04:56:41 +0000 | [diff] [blame] | 29 | #include <system/window.h> |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 30 | #include <ui/DisplayId.h> |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 31 | #include <ui/DisplayInfo.h> |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 32 | #include <ui/DisplayState.h> |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 33 | #include <ui/GraphicTypes.h> |
Peiyong Lin | fb06930 | 2018-04-25 14:34:31 -0700 | [diff] [blame] | 34 | #include <ui/HdrCapabilities.h> |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 35 | #include <ui/Region.h> |
Peiyong Lin | efefaac | 2018-08-17 12:27:51 -0700 | [diff] [blame] | 36 | #include <ui/Transform.h> |
Marin Shalamanov | 12c9e5a | 2021-01-07 00:25:35 +0100 | [diff] [blame] | 37 | #include <utils/Errors.h> |
Alec Mouri | 8d4f90a | 2018-11-14 22:33:24 +0000 | [diff] [blame] | 38 | #include <utils/Mutex.h> |
Alec Mouri | 0a9c7b8 | 2018-11-16 13:05:25 -0800 | [diff] [blame] | 39 | #include <utils/RefBase.h> |
Mathias Agopian | 8630320 | 2012-07-24 22:46:10 -0700 | [diff] [blame] | 40 | #include <utils/Timers.h> |
| 41 | |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 42 | #include "DisplayHardware/DisplayIdentification.h" |
Marin Shalamanov | 23c4420 | 2020-12-22 19:09:20 +0100 | [diff] [blame] | 43 | #include "DisplayHardware/DisplayMode.h" |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 44 | #include "DisplayHardware/Hal.h" |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 45 | #include "DisplayHardware/PowerAdvisor.h" |
Mathias Agopian | f435863 | 2012-08-22 17:16:19 -0700 | [diff] [blame] | 46 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | namespace android { |
| 48 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 49 | class Fence; |
Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 50 | class HWComposer; |
Jesse Hall | 9e663de | 2013-08-16 14:28:37 -0700 | [diff] [blame] | 51 | class IGraphicBufferProducer; |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 52 | class Layer; |
Mathias Agopian | 8630320 | 2012-07-24 22:46:10 -0700 | [diff] [blame] | 53 | class SurfaceFlinger; |
Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 54 | |
David Sodman | fb95bcc | 2017-12-22 15:45:30 -0800 | [diff] [blame] | 55 | struct CompositionInfo; |
Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 56 | struct DisplayDeviceCreationArgs; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 58 | namespace compositionengine { |
| 59 | class Display; |
Lloyd Pique | 542307f | 2018-10-19 13:24:08 -0700 | [diff] [blame] | 60 | class DisplaySurface; |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 61 | } // namespace compositionengine |
| 62 | |
Marin Shalamanov | 1c43429 | 2020-06-12 01:47:29 +0200 | [diff] [blame] | 63 | class DisplayDevice : public RefBase { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | public: |
Peiyong Lin | fb06930 | 2018-04-25 14:34:31 -0700 | [diff] [blame] | 65 | constexpr static float sDefaultMinLumiance = 0.0; |
| 66 | constexpr static float sDefaultMaxLumiance = 500.0; |
| 67 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 68 | explicit DisplayDevice(DisplayDeviceCreationArgs& args); |
Marin Shalamanov | 1c43429 | 2020-06-12 01:47:29 +0200 | [diff] [blame] | 69 | |
| 70 | // Must be destroyed on the main thread because it may call into HWComposer. |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 71 | virtual ~DisplayDevice(); |
| 72 | |
| 73 | std::shared_ptr<compositionengine::Display> getCompositionDisplay() const { |
| 74 | return mCompositionDisplay; |
| 75 | } |
Mathias Agopian | 92a979a | 2012-08-02 18:32:23 -0700 | [diff] [blame] | 76 | |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 77 | std::optional<DisplayConnectionType> getConnectionType() const { return mConnectionType; } |
| 78 | |
| 79 | bool isVirtual() const { return !mConnectionType; } |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 80 | bool isPrimary() const { return mIsPrimary; } |
Mathias Agopian | 92a979a | 2012-08-02 18:32:23 -0700 | [diff] [blame] | 81 | |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 82 | // isSecure indicates whether this display can be trusted to display |
| 83 | // secure surfaces. |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 84 | bool isSecure() const; |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 85 | |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 86 | int getWidth() const; |
| 87 | int getHeight() const; |
| 88 | ui::Size getSize() const { return {getWidth(), getHeight()}; } |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 89 | |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 90 | void setLayerStack(ui::LayerStack); |
| 91 | void setDisplaySize(int width, int height); |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 92 | void setProjection(ui::Rotation orientation, Rect viewport, Rect frame); |
| 93 | |
| 94 | ui::Rotation getPhysicalOrientation() const { return mPhysicalOrientation; } |
| 95 | ui::Rotation getOrientation() const { return mOrientation; } |
| 96 | |
| 97 | static ui::Transform::RotationFlags getPrimaryDisplayRotationFlags(); |
| 98 | |
Garfield Tan | 54edd91 | 2020-10-21 16:31:41 -0700 | [diff] [blame] | 99 | ui::Transform::RotationFlags getTransformHint() const; |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 100 | const ui::Transform& getTransform() const; |
Marin Shalamanov | 6ad317c | 2020-07-29 23:34:07 +0200 | [diff] [blame] | 101 | const Rect& getLayerStackSpaceRect() const; |
| 102 | const Rect& getOrientedDisplaySpaceRect() const; |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 103 | bool needsFiltering() const; |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 104 | ui::LayerStack getLayerStack() const; |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 105 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 106 | // Returns the physical ID of this display. This function asserts the ID is physical and it |
| 107 | // shouldn't be called for other display types, e.g. virtual. |
| 108 | PhysicalDisplayId getPhysicalId() const { |
| 109 | const auto displayIdOpt = PhysicalDisplayId::tryCast(getId()); |
| 110 | LOG_FATAL_IF(!displayIdOpt); |
| 111 | return *displayIdOpt; |
| 112 | } |
| 113 | |
| 114 | DisplayId getId() const; |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 115 | const wp<IBinder>& getDisplayToken() const { return mDisplayToken; } |
Dominik Laskowski | e977409 | 2018-12-11 10:04:24 -0800 | [diff] [blame] | 116 | int32_t getSequenceId() const { return mSequenceId; } |
Mathias Agopian | 87baae1 | 2012-07-31 12:38:26 -0700 | [diff] [blame] | 117 | |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 118 | const Region& getUndefinedRegion() const; |
| 119 | |
Lloyd Pique | 3d0c02e | 2018-10-19 18:38:12 -0700 | [diff] [blame] | 120 | int32_t getSupportedPerFrameMetadata() const; |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 121 | |
Lloyd Pique | 3d0c02e | 2018-10-19 18:38:12 -0700 | [diff] [blame] | 122 | bool hasWideColorGamut() const; |
Peiyong Lin | 136fbbc | 2018-04-17 15:09:44 -0700 | [diff] [blame] | 123 | // Whether h/w composer has native support for specific HDR type. |
Lloyd Pique | 3d0c02e | 2018-10-19 18:38:12 -0700 | [diff] [blame] | 124 | bool hasHDR10PlusSupport() const; |
| 125 | bool hasHDR10Support() const; |
| 126 | bool hasHLGSupport() const; |
| 127 | bool hasDolbyVisionSupport() const; |
Chia-I Wu | be02ec0 | 2018-05-18 10:59:36 -0700 | [diff] [blame] | 128 | |
Peiyong Lin | fb06930 | 2018-04-25 14:34:31 -0700 | [diff] [blame] | 129 | // The returned HdrCapabilities is the combination of HDR capabilities from |
| 130 | // hardware composer and RenderEngine. When the DisplayDevice supports wide |
| 131 | // color gamut, RenderEngine is able to simulate HDR support in Display P3 |
| 132 | // color space for both PQ and HLG HDR contents. The minimum and maximum |
| 133 | // luminance will be set to sDefaultMinLumiance and sDefaultMaxLumiance |
| 134 | // respectively if hardware composer doesn't return meaningful values. |
Lloyd Pique | 3d0c02e | 2018-10-19 18:38:12 -0700 | [diff] [blame] | 135 | const HdrCapabilities& getHdrCapabilities() const; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 136 | |
Chia-I Wu | be02ec0 | 2018-05-18 10:59:36 -0700 | [diff] [blame] | 137 | // Return true if intent is supported by the display. |
| 138 | bool hasRenderIntent(ui::RenderIntent intent) const; |
Peiyong Lin | 136fbbc | 2018-04-17 15:09:44 -0700 | [diff] [blame] | 139 | |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 140 | const Rect& getBounds() const; |
| 141 | const Rect& bounds() const { return getBounds(); } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 142 | |
Dominik Laskowski | bf170d9 | 2018-04-19 15:08:05 -0700 | [diff] [blame] | 143 | void setDisplayName(const std::string& displayName); |
| 144 | const std::string& getDisplayName() const { return mDisplayName; } |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 145 | |
Marin Shalamanov | e5cceea | 2020-04-30 18:13:10 +0200 | [diff] [blame] | 146 | void setDeviceProductInfo(std::optional<DeviceProductInfo> info); |
| 147 | const std::optional<DeviceProductInfo>& getDeviceProductInfo() const { |
| 148 | return mDeviceProductInfo; |
| 149 | } |
| 150 | |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 151 | /* ------------------------------------------------------------------------ |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 152 | * Display power mode management. |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 153 | */ |
Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 154 | hardware::graphics::composer::hal::PowerMode getPowerMode() const; |
| 155 | void setPowerMode(hardware::graphics::composer::hal::PowerMode mode); |
Dominik Laskowski | eecd659 | 2018-05-29 10:25:41 -0700 | [diff] [blame] | 156 | bool isPoweredOn() const; |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 157 | |
Peiyong Lin | dd9b2ae | 2018-03-01 16:22:45 -0800 | [diff] [blame] | 158 | ui::Dataspace getCompositionDataSpace() const; |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 159 | |
Michael Lentine | 6c9e34a | 2014-07-14 13:48:55 -0700 | [diff] [blame] | 160 | /* ------------------------------------------------------------------------ |
Marin Shalamanov | 5801c94 | 2020-12-17 17:00:13 +0100 | [diff] [blame] | 161 | * Display mode management. |
Michael Lentine | 6c9e34a | 2014-07-14 13:48:55 -0700 | [diff] [blame] | 162 | */ |
Marin Shalamanov | 5801c94 | 2020-12-17 17:00:13 +0100 | [diff] [blame] | 163 | const DisplayModePtr& getActiveMode() const; |
| 164 | void setActiveMode(DisplayModeId); |
Marin Shalamanov | 12c9e5a | 2021-01-07 00:25:35 +0100 | [diff] [blame] | 165 | status_t initiateModeChange(DisplayModeId modeId, |
| 166 | const hal::VsyncPeriodChangeConstraints& constraints, |
| 167 | hal::VsyncPeriodChangeTimeline* outTimeline) const; |
Marin Shalamanov | 5801c94 | 2020-12-17 17:00:13 +0100 | [diff] [blame] | 168 | |
| 169 | // Return the immutable list of supported display modes. The HWC may report different modes |
| 170 | // after a hotplug reconnect event, in which case the DisplayDevice object will be recreated. |
| 171 | // Hotplug reconnects are common for external displays. |
| 172 | const DisplayModes& getSupportedModes() const; |
| 173 | |
| 174 | // Returns nullptr if the given mode ID is not supported. A previously |
| 175 | // supported mode may be no longer supported for some devices like TVs and |
| 176 | // set-top boxes after a hotplug reconnect. |
| 177 | DisplayModePtr getMode(DisplayModeId) const; |
Michael Lentine | 6c9e34a | 2014-07-14 13:48:55 -0700 | [diff] [blame] | 178 | |
Jesse Hall | 02d8656 | 2013-03-25 14:43:23 -0700 | [diff] [blame] | 179 | // release HWC resources (if any) for removable displays |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 180 | void disconnect(); |
Jesse Hall | 02d8656 | 2013-03-25 14:43:23 -0700 | [diff] [blame] | 181 | |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 182 | /* ------------------------------------------------------------------------ |
| 183 | * Debugging |
| 184 | */ |
| 185 | uint32_t getPageFlipCount() const; |
Dominik Laskowski | 9b17b2c2 | 2018-11-01 14:49:03 -0700 | [diff] [blame] | 186 | std::string getDebugName() const; |
Yiwei Zhang | 5434a78 | 2018-12-05 18:06:32 -0800 | [diff] [blame] | 187 | void dump(std::string& result) const; |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 188 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 189 | private: |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 190 | const sp<SurfaceFlinger> mFlinger; |
Marin Shalamanov | 12c9e5a | 2021-01-07 00:25:35 +0100 | [diff] [blame] | 191 | HWComposer& mHwComposer; |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 192 | const wp<IBinder> mDisplayToken; |
Dominik Laskowski | e977409 | 2018-12-11 10:04:24 -0800 | [diff] [blame] | 193 | const int32_t mSequenceId; |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 194 | const std::optional<DisplayConnectionType> mConnectionType; |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 195 | |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 196 | const std::shared_ptr<compositionengine::Display> mCompositionDisplay; |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 197 | |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 198 | std::string mDisplayName; |
Mathias Agopian | 03e4072 | 2012-04-26 16:11:59 -0700 | [diff] [blame] | 199 | |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 200 | const ui::Rotation mPhysicalOrientation; |
| 201 | ui::Rotation mOrientation = ui::ROTATION_0; |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 202 | |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 203 | static ui::Transform::RotationFlags sPrimaryDisplayRotationFlags; |
Mathias Agopian | da8d0a5 | 2012-09-04 15:05:38 -0700 | [diff] [blame] | 204 | |
Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 205 | hardware::graphics::composer::hal::PowerMode mPowerMode = |
| 206 | hardware::graphics::composer::hal::PowerMode::OFF; |
Marin Shalamanov | 5801c94 | 2020-12-17 17:00:13 +0100 | [diff] [blame] | 207 | DisplayModeId mActiveModeId; |
| 208 | const DisplayModes mSupportedModes; |
Courtney Goeltzenleuchter | 5d94389 | 2017-03-22 13:46:46 -0600 | [diff] [blame] | 209 | |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 210 | // TODO(b/74619554): Remove special cases for primary display. |
| 211 | const bool mIsPrimary; |
Marin Shalamanov | e5cceea | 2020-04-30 18:13:10 +0200 | [diff] [blame] | 212 | |
| 213 | std::optional<DeviceProductInfo> mDeviceProductInfo; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 214 | }; |
| 215 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 216 | struct DisplayDeviceState { |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 217 | struct Physical { |
Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 218 | PhysicalDisplayId id; |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 219 | DisplayConnectionType type; |
Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 220 | hardware::graphics::composer::hal::HWDisplayId hwcDisplayId; |
Marin Shalamanov | 7ce8764 | 2020-05-06 13:45:58 +0200 | [diff] [blame] | 221 | std::optional<DeviceProductInfo> deviceProductInfo; |
Marin Shalamanov | a903d03 | 2020-12-29 20:35:13 +0100 | [diff] [blame^] | 222 | DisplayModes supportedModes; |
| 223 | DisplayModePtr activeMode; |
| 224 | |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 225 | bool operator==(const Physical& other) const { |
Marin Shalamanov | 4a42d43 | 2020-02-12 20:22:26 +0100 | [diff] [blame] | 226 | return id == other.id && type == other.type && hwcDisplayId == other.hwcDisplayId; |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 227 | } |
| 228 | }; |
| 229 | |
| 230 | bool isVirtual() const { return !physical; } |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 231 | |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 232 | int32_t sequenceId = sNextSequenceId++; |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 233 | std::optional<Physical> physical; |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 234 | sp<IGraphicBufferProducer> surface; |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 235 | ui::LayerStack layerStack = ui::NO_LAYER_STACK; |
Marin Shalamanov | 6ad317c | 2020-07-29 23:34:07 +0200 | [diff] [blame] | 236 | Rect layerStackSpaceRect; |
| 237 | Rect orientedDisplaySpaceRect; |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 238 | ui::Rotation orientation = ui::ROTATION_0; |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 239 | uint32_t width = 0; |
| 240 | uint32_t height = 0; |
Dominik Laskowski | bf170d9 | 2018-04-19 15:08:05 -0700 | [diff] [blame] | 241 | std::string displayName; |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 242 | bool isSecure = false; |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 243 | |
| 244 | private: |
| 245 | static std::atomic<int32_t> sNextSequenceId; |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 246 | }; |
| 247 | |
Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 248 | struct DisplayDeviceCreationArgs { |
| 249 | // We use a constructor to ensure some of the values are set, without |
| 250 | // assuming a default value. |
Marin Shalamanov | 12c9e5a | 2021-01-07 00:25:35 +0100 | [diff] [blame] | 251 | DisplayDeviceCreationArgs(const sp<SurfaceFlinger>&, HWComposer& hwComposer, |
| 252 | const wp<IBinder>& displayToken, |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 253 | std::shared_ptr<compositionengine::Display>); |
Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 254 | const sp<SurfaceFlinger> flinger; |
Marin Shalamanov | 12c9e5a | 2021-01-07 00:25:35 +0100 | [diff] [blame] | 255 | HWComposer& hwComposer; |
Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 256 | const wp<IBinder> displayToken; |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 257 | const std::shared_ptr<compositionengine::Display> compositionDisplay; |
Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 258 | |
Dominik Laskowski | e977409 | 2018-12-11 10:04:24 -0800 | [diff] [blame] | 259 | int32_t sequenceId{0}; |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 260 | std::optional<DisplayConnectionType> connectionType; |
Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 261 | bool isSecure{false}; |
| 262 | sp<ANativeWindow> nativeWindow; |
Lloyd Pique | 542307f | 2018-10-19 13:24:08 -0700 | [diff] [blame] | 263 | sp<compositionengine::DisplaySurface> displaySurface; |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 264 | ui::Rotation physicalOrientation{ui::ROTATION_0}; |
Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 265 | bool hasWideColorGamut{false}; |
| 266 | HdrCapabilities hdrCapabilities; |
| 267 | int32_t supportedPerFrameMetadata{0}; |
| 268 | std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>> hwcColorModes; |
Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 269 | hardware::graphics::composer::hal::PowerMode initialPowerMode{ |
| 270 | hardware::graphics::composer::hal::PowerMode::ON}; |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 271 | bool isPrimary{false}; |
Marin Shalamanov | 5801c94 | 2020-12-17 17:00:13 +0100 | [diff] [blame] | 272 | DisplayModes supportedModes; |
Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 273 | }; |
| 274 | |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 275 | } // namespace android |