Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 17 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 18 | #pragma clang diagnostic push |
| 19 | #pragma clang diagnostic ignored "-Wconversion" |
| 20 | |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 21 | // #define LOG_NDEBUG 0 |
| 22 | |
| 23 | #undef LOG_TAG |
| 24 | #define LOG_TAG "HWC2" |
| 25 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 26 | |
| 27 | #include "HWC2.h" |
| 28 | |
Dominik Laskowski | 4e2b71f | 2020-11-10 15:05:32 -0800 | [diff] [blame] | 29 | #include <android/configuration.h> |
Dominik Laskowski | 8809687 | 2023-12-08 15:26:04 -0500 | [diff] [blame] | 30 | #include <common/FlagManager.h> |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 31 | #include <ui/Fence.h> |
Dan Stoza | 5a423ea | 2017-02-16 14:10:39 -0800 | [diff] [blame] | 32 | #include <ui/FloatRect.h> |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 33 | #include <ui/GraphicBuffer.h> |
Brian Lindahl | 7a4cb7e | 2024-10-30 10:42:21 -0600 | [diff] [blame] | 34 | #include <ui/PictureProfileHandle.h> |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 35 | |
Manasi Navare | fc2a4a7 | 2024-11-12 23:59:21 +0000 | [diff] [blame] | 36 | #include "DisplayHardware/Hal.h" |
| 37 | |
Lloyd Pique | 3c085a0 | 2018-05-09 19:38:32 -0700 | [diff] [blame] | 38 | #include <algorithm> |
Dominik Laskowski | 4e2b71f | 2020-11-10 15:05:32 -0800 | [diff] [blame] | 39 | #include <cinttypes> |
Lloyd Pique | 3c085a0 | 2018-05-09 19:38:32 -0700 | [diff] [blame] | 40 | #include <iterator> |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 41 | #include <set> |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 42 | |
Ady Abraham | 6e60b14 | 2022-01-06 18:10:35 -0800 | [diff] [blame] | 43 | using aidl::android::hardware::graphics::composer3::Color; |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 44 | using aidl::android::hardware::graphics::composer3::Composition; |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 45 | using AidlCapability = aidl::android::hardware::graphics::composer3::Capability; |
Leon Scroggins III | 5967aec | 2021-12-29 11:14:22 -0500 | [diff] [blame] | 46 | using aidl::android::hardware::graphics::composer3::DisplayCapability; |
Sally Qi | 11dcd58 | 2024-08-16 18:11:27 -0700 | [diff] [blame] | 47 | using aidl::android::hardware::graphics::composer3::DisplayLuts; |
Sally Qi | 0abc4a5 | 2024-09-26 16:13:06 -0700 | [diff] [blame] | 48 | using aidl::android::hardware::graphics::composer3::LutProperties; |
| 49 | using aidl::android::hardware::graphics::composer3::Luts; |
Sally Qi | 0cbd08b | 2022-08-17 12:12:28 -0700 | [diff] [blame] | 50 | using aidl::android::hardware::graphics::composer3::OverlayProperties; |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 51 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 52 | namespace android { |
| 53 | |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 54 | using android::Fence; |
Dan Stoza | 5a423ea | 2017-02-16 14:10:39 -0800 | [diff] [blame] | 55 | using android::FloatRect; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 56 | using android::GraphicBuffer; |
Dan Stoza | 7d7ae73 | 2016-03-16 12:23:40 -0700 | [diff] [blame] | 57 | using android::HdrCapabilities; |
Courtney Goeltzenleuchter | f9c98e5 | 2018-02-12 07:23:17 -0700 | [diff] [blame] | 58 | using android::HdrMetadata; |
Brian Lindahl | 7a4cb7e | 2024-10-30 10:42:21 -0600 | [diff] [blame] | 59 | using android::PictureProfileHandle; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 60 | using android::Rect; |
| 61 | using android::Region; |
| 62 | using android::sp; |
| 63 | |
| 64 | namespace HWC2 { |
| 65 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 66 | using namespace android::hardware::graphics::composer::hal; |
| 67 | |
Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 68 | namespace Hwc2 = android::Hwc2; |
| 69 | |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 70 | namespace { |
| 71 | |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 72 | inline bool hasMetadataKey(const std::set<Hwc2::PerFrameMetadataKey>& keys, |
| 73 | const Hwc2::PerFrameMetadataKey& key) { |
| 74 | return keys.find(key) != keys.end(); |
| 75 | } |
| 76 | |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 77 | } // namespace anonymous |
| 78 | |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 79 | // Display methods |
Ana Krulec | 4593b69 | 2019-01-11 22:07:25 -0800 | [diff] [blame] | 80 | Display::~Display() = default; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 81 | |
Ana Krulec | 4593b69 | 2019-01-11 22:07:25 -0800 | [diff] [blame] | 82 | namespace impl { |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 83 | |
Peiyong Lin | 74ca2f4 | 2019-01-14 19:36:57 -0800 | [diff] [blame] | 84 | Display::Display(android::Hwc2::Composer& composer, |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 85 | const std::unordered_set<AidlCapability>& capabilities, HWDisplayId id, |
Lloyd Pique | bc79209 | 2018-01-17 11:52:30 -0800 | [diff] [blame] | 86 | DisplayType type) |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 87 | : mComposer(composer), mCapabilities(capabilities), mId(id), mType(type) { |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 88 | ALOGV("Created display %" PRIu64, id); |
HyunKyoung | a264a35 | 2024-04-24 18:51:33 +0900 | [diff] [blame] | 89 | if (mType == hal::DisplayType::VIRTUAL) { |
| 90 | loadDisplayCapabilities(); |
| 91 | } |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 92 | } |
| 93 | |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 94 | Display::~Display() { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 95 | // Note: The calls to onOwningDisplayDestroyed() are allowed (and expected) |
| 96 | // to call Display::onLayerDestroyed(). As that call removes entries from |
| 97 | // mLayers, we do not want to have a for loop directly over it here. Since |
| 98 | // the end goal is an empty mLayers anyway, we just go ahead and swap an |
| 99 | // initially empty local container with mLayers, and then enumerate |
| 100 | // the contents of the local container. |
| 101 | Layers destroyingLayers; |
| 102 | std::swap(mLayers, destroyingLayers); |
| 103 | for (const auto& [_, weakLayer] : destroyingLayers) { |
| 104 | if (std::shared_ptr layer = weakLayer.lock()) { |
| 105 | layer->onOwningDisplayDestroyed(); |
| 106 | } |
| 107 | } |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 108 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 109 | Error error = Error::NONE; |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 110 | const char* msg; |
| 111 | switch (mType) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 112 | case DisplayType::PHYSICAL: |
| 113 | error = setVsyncEnabled(HWC2::Vsync::DISABLE); |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 114 | msg = "disable VSYNC for"; |
| 115 | break; |
| 116 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 117 | case DisplayType::VIRTUAL: |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 118 | error = static_cast<Error>(mComposer.destroyVirtualDisplay(mId)); |
| 119 | msg = "destroy virtual"; |
| 120 | break; |
| 121 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 122 | case DisplayType::INVALID: // Used in unit tests. |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 123 | break; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 124 | } |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 125 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 126 | ALOGE_IF(error != Error::NONE, "%s: Failed to %s display %" PRIu64 ": %d", __FUNCTION__, msg, |
| 127 | mId, static_cast<int32_t>(error)); |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 128 | |
| 129 | ALOGV("Destroyed display %" PRIu64, mId); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 130 | } |
| 131 | |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 132 | // Required by HWC2 display |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 133 | Error Display::acceptChanges() |
| 134 | { |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 135 | auto intError = mComposer.acceptDisplayChanges(mId); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 136 | return static_cast<Error>(intError); |
| 137 | } |
| 138 | |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 139 | base::expected<std::shared_ptr<HWC2::Layer>, hal::Error> Display::createLayer() { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 140 | HWLayerId layerId = 0; |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 141 | auto intError = mComposer.createLayer(mId, &layerId); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 142 | auto error = static_cast<Error>(intError); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 143 | if (error != Error::NONE) { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 144 | return base::unexpected(error); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 147 | auto layer = std::make_shared<impl::Layer>(mComposer, mCapabilities, *this, layerId); |
| 148 | mLayers.emplace(layerId, layer); |
| 149 | return layer; |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 150 | } |
| 151 | |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 152 | void Display::onLayerDestroyed(hal::HWLayerId layerId) { |
| 153 | mLayers.erase(layerId); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 154 | } |
| 155 | |
Ady Abraham | 7159f57 | 2019-10-11 11:10:18 -0700 | [diff] [blame] | 156 | bool Display::isVsyncPeriodSwitchSupported() const { |
| 157 | ALOGV("[%" PRIu64 "] isVsyncPeriodSwitchSupported()", mId); |
| 158 | |
Ady Abraham | 4d211cf | 2021-12-14 16:19:03 -0800 | [diff] [blame] | 159 | return mComposer.isSupported(android::Hwc2::Composer::OptionalFeature::RefreshRateSwitching); |
Ady Abraham | 7159f57 | 2019-10-11 11:10:18 -0700 | [diff] [blame] | 160 | } |
| 161 | |
ramindani | 32cf060 | 2022-03-02 02:30:29 +0000 | [diff] [blame] | 162 | bool Display::hasDisplayIdleTimerCapability() const { |
| 163 | bool isCapabilitySupported = false; |
| 164 | return mComposer.hasDisplayIdleTimerCapability(mId, &isCapabilitySupported) == Error::NONE && |
| 165 | isCapabilitySupported; |
| 166 | } |
| 167 | |
ramindani | 06e518e | 2022-03-14 18:47:53 +0000 | [diff] [blame] | 168 | Error Display::getPhysicalDisplayOrientation(Hwc2::AidlTransform* outTransform) const { |
| 169 | auto error = mComposer.getPhysicalDisplayOrientation(mId, outTransform); |
| 170 | return static_cast<Error>(error); |
| 171 | } |
| 172 | |
Lloyd Pique | 35d5824 | 2018-12-18 16:33:25 -0800 | [diff] [blame] | 173 | Error Display::getChangedCompositionTypes(std::unordered_map<HWC2::Layer*, Composition>* outTypes) { |
Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 174 | std::vector<Hwc2::Layer> layerIds; |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 175 | std::vector<Composition> types; |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 176 | auto intError = mComposer.getChangedCompositionTypes( |
| 177 | mId, &layerIds, &types); |
Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 178 | uint32_t numElements = layerIds.size(); |
linkai | d1bb314 | 2023-12-20 10:18:16 +0800 | [diff] [blame] | 179 | const auto error = static_cast<Error>(intError); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 180 | if (error != Error::NONE) { |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 181 | return error; |
| 182 | } |
| 183 | |
| 184 | outTypes->clear(); |
| 185 | outTypes->reserve(numElements); |
| 186 | for (uint32_t element = 0; element < numElements; ++element) { |
| 187 | auto layer = getLayerById(layerIds[element]); |
| 188 | if (layer) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 189 | auto type = types[element]; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 190 | ALOGV("getChangedCompositionTypes: adding %" PRIu64 " %s", |
| 191 | layer->getId(), to_string(type).c_str()); |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 192 | outTypes->emplace(layer.get(), type); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 193 | } else { |
| 194 | ALOGE("getChangedCompositionTypes: invalid layer %" PRIu64 " found" |
| 195 | " on display %" PRIu64, layerIds[element], mId); |
| 196 | } |
| 197 | } |
| 198 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 199 | return Error::NONE; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Peiyong Lin | 34beb7a | 2018-03-28 11:57:12 -0700 | [diff] [blame] | 202 | Error Display::getColorModes(std::vector<ColorMode>* outModes) const |
Dan Stoza | 076ac67 | 2016-03-14 10:47:53 -0700 | [diff] [blame] | 203 | { |
Peiyong Lin | fd997e0 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 204 | auto intError = mComposer.getColorModes(mId, outModes); |
| 205 | return static_cast<Error>(intError); |
Dan Stoza | 076ac67 | 2016-03-14 10:47:53 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Chia-I Wu | d7e01d7 | 2018-06-21 13:39:09 +0800 | [diff] [blame] | 208 | int32_t Display::getSupportedPerFrameMetadata() const |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 209 | { |
Chia-I Wu | d7e01d7 | 2018-06-21 13:39:09 +0800 | [diff] [blame] | 210 | int32_t supportedPerFrameMetadata = 0; |
| 211 | |
| 212 | std::vector<Hwc2::PerFrameMetadataKey> tmpKeys = mComposer.getPerFrameMetadataKeys(mId); |
| 213 | std::set<Hwc2::PerFrameMetadataKey> keys(tmpKeys.begin(), tmpKeys.end()); |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 214 | |
| 215 | // Check whether a specific metadata type is supported. A metadata type is considered |
| 216 | // supported if and only if all required fields are supported. |
| 217 | |
| 218 | // SMPTE2086 |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 219 | if (hasMetadataKey(keys, Hwc2::PerFrameMetadataKey::DISPLAY_RED_PRIMARY_X) && |
| 220 | hasMetadataKey(keys, Hwc2::PerFrameMetadataKey::DISPLAY_RED_PRIMARY_Y) && |
| 221 | hasMetadataKey(keys, Hwc2::PerFrameMetadataKey::DISPLAY_GREEN_PRIMARY_X) && |
| 222 | hasMetadataKey(keys, Hwc2::PerFrameMetadataKey::DISPLAY_GREEN_PRIMARY_Y) && |
| 223 | hasMetadataKey(keys, Hwc2::PerFrameMetadataKey::DISPLAY_BLUE_PRIMARY_X) && |
| 224 | hasMetadataKey(keys, Hwc2::PerFrameMetadataKey::DISPLAY_BLUE_PRIMARY_Y) && |
| 225 | hasMetadataKey(keys, Hwc2::PerFrameMetadataKey::WHITE_POINT_X) && |
| 226 | hasMetadataKey(keys, Hwc2::PerFrameMetadataKey::WHITE_POINT_Y) && |
| 227 | hasMetadataKey(keys, Hwc2::PerFrameMetadataKey::MAX_LUMINANCE) && |
| 228 | hasMetadataKey(keys, Hwc2::PerFrameMetadataKey::MIN_LUMINANCE)) { |
Chia-I Wu | d7e01d7 | 2018-06-21 13:39:09 +0800 | [diff] [blame] | 229 | supportedPerFrameMetadata |= HdrMetadata::Type::SMPTE2086; |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 230 | } |
| 231 | // CTA861_3 |
| 232 | if (hasMetadataKey(keys, Hwc2::PerFrameMetadataKey::MAX_CONTENT_LIGHT_LEVEL) && |
| 233 | hasMetadataKey(keys, Hwc2::PerFrameMetadataKey::MAX_FRAME_AVERAGE_LIGHT_LEVEL)) { |
Chia-I Wu | d7e01d7 | 2018-06-21 13:39:09 +0800 | [diff] [blame] | 234 | supportedPerFrameMetadata |= HdrMetadata::Type::CTA861_3; |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Valerie Hau | e9e843a | 2018-12-18 13:39:23 -0800 | [diff] [blame] | 237 | // HDR10PLUS |
| 238 | if (hasMetadataKey(keys, Hwc2::PerFrameMetadataKey::HDR10_PLUS_SEI)) { |
| 239 | supportedPerFrameMetadata |= HdrMetadata::Type::HDR10PLUS; |
| 240 | } |
| 241 | |
Chia-I Wu | d7e01d7 | 2018-06-21 13:39:09 +0800 | [diff] [blame] | 242 | return supportedPerFrameMetadata; |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 243 | } |
| 244 | |
Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 245 | Error Display::getRenderIntents(ColorMode colorMode, |
| 246 | std::vector<RenderIntent>* outRenderIntents) const |
| 247 | { |
| 248 | auto intError = mComposer.getRenderIntents(mId, colorMode, outRenderIntents); |
| 249 | return static_cast<Error>(intError); |
| 250 | } |
| 251 | |
| 252 | Error Display::getDataspaceSaturationMatrix(Dataspace dataspace, android::mat4* outMatrix) |
| 253 | { |
| 254 | auto intError = mComposer.getDataspaceSaturationMatrix(dataspace, outMatrix); |
| 255 | return static_cast<Error>(intError); |
| 256 | } |
| 257 | |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 258 | Error Display::getName(std::string* outName) const |
| 259 | { |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 260 | auto intError = mComposer.getDisplayName(mId, outName); |
Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 261 | return static_cast<Error>(intError); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | Error Display::getRequests(HWC2::DisplayRequest* outDisplayRequests, |
Lloyd Pique | 35d5824 | 2018-12-18 16:33:25 -0800 | [diff] [blame] | 265 | std::unordered_map<HWC2::Layer*, LayerRequest>* outLayerRequests) { |
Lloyd Pique | e9eff97 | 2020-05-05 12:36:44 -0700 | [diff] [blame] | 266 | uint32_t intDisplayRequests = 0; |
Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 267 | std::vector<Hwc2::Layer> layerIds; |
| 268 | std::vector<uint32_t> layerRequests; |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 269 | auto intError = mComposer.getDisplayRequests( |
| 270 | mId, &intDisplayRequests, &layerIds, &layerRequests); |
Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 271 | uint32_t numElements = layerIds.size(); |
| 272 | auto error = static_cast<Error>(intError); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 273 | if (error != Error::NONE) { |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 274 | return error; |
| 275 | } |
| 276 | |
| 277 | *outDisplayRequests = static_cast<DisplayRequest>(intDisplayRequests); |
| 278 | outLayerRequests->clear(); |
| 279 | outLayerRequests->reserve(numElements); |
| 280 | for (uint32_t element = 0; element < numElements; ++element) { |
| 281 | auto layer = getLayerById(layerIds[element]); |
| 282 | if (layer) { |
| 283 | auto layerRequest = |
| 284 | static_cast<LayerRequest>(layerRequests[element]); |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 285 | outLayerRequests->emplace(layer.get(), layerRequest); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 286 | } else { |
| 287 | ALOGE("getRequests: invalid layer %" PRIu64 " found on display %" |
| 288 | PRIu64, layerIds[element], mId); |
| 289 | } |
| 290 | } |
| 291 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 292 | return Error::NONE; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 293 | } |
| 294 | |
Dominik Laskowski | 969cdcb | 2024-02-08 16:35:29 -0500 | [diff] [blame] | 295 | ftl::Expected<ui::DisplayConnectionType, hal::Error> Display::getConnectionType() const { |
| 296 | if (!mConnectionType) { |
| 297 | mConnectionType = [this]() -> decltype(mConnectionType) { |
| 298 | if (mType != DisplayType::PHYSICAL) { |
| 299 | return ftl::Unexpected(Error::BAD_DISPLAY); |
| 300 | } |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 301 | |
Dominik Laskowski | 969cdcb | 2024-02-08 16:35:29 -0500 | [diff] [blame] | 302 | using ConnectionType = Hwc2::IComposerClient::DisplayConnectionType; |
| 303 | ConnectionType connectionType; |
| 304 | |
| 305 | if (const auto error = static_cast<Error>( |
| 306 | mComposer.getDisplayConnectionType(mId, &connectionType)); |
| 307 | error != Error::NONE) { |
| 308 | return ftl::Unexpected(error); |
| 309 | } |
| 310 | |
| 311 | return connectionType == ConnectionType::INTERNAL ? ui::DisplayConnectionType::Internal |
| 312 | : ui::DisplayConnectionType::External; |
| 313 | }(); |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 314 | } |
| 315 | |
Dominik Laskowski | 969cdcb | 2024-02-08 16:35:29 -0500 | [diff] [blame] | 316 | return *mConnectionType; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 317 | } |
| 318 | |
Leon Scroggins III | 5967aec | 2021-12-29 11:14:22 -0500 | [diff] [blame] | 319 | bool Display::hasCapability(DisplayCapability capability) const { |
Ady Abraham | 27fbcc7 | 2021-09-20 14:54:57 -0700 | [diff] [blame] | 320 | std::scoped_lock lock(mDisplayCapabilitiesMutex); |
| 321 | if (mDisplayCapabilities) { |
| 322 | return mDisplayCapabilities->count(capability) > 0; |
| 323 | } |
| 324 | |
Leon Scroggins III | 515f038 | 2021-12-29 11:17:04 -0500 | [diff] [blame] | 325 | ALOGW("Can't query capability %s." |
Ady Abraham | 27fbcc7 | 2021-09-20 14:54:57 -0700 | [diff] [blame] | 326 | " Display Capabilities were not queried from HWC yet", |
Leon Scroggins III | 515f038 | 2021-12-29 11:17:04 -0500 | [diff] [blame] | 327 | to_string(capability).c_str()); |
Ady Abraham | 27fbcc7 | 2021-09-20 14:54:57 -0700 | [diff] [blame] | 328 | |
| 329 | return false; |
| 330 | } |
| 331 | |
Peiyong Lin | ed531a3 | 2018-10-26 18:27:56 -0700 | [diff] [blame] | 332 | Error Display::supportsDoze(bool* outSupport) const { |
Leon Scroggins III | 689c80f | 2023-06-05 17:49:32 -0400 | [diff] [blame] | 333 | { |
| 334 | std::scoped_lock lock(mDisplayCapabilitiesMutex); |
| 335 | if (!mDisplayCapabilities) { |
| 336 | // The display has not turned on since boot, so DOZE support is unknown. |
| 337 | ALOGW("%s: haven't queried capabilities yet!", __func__); |
| 338 | return Error::NO_RESOURCES; |
| 339 | } |
| 340 | } |
Ady Abraham | 27fbcc7 | 2021-09-20 14:54:57 -0700 | [diff] [blame] | 341 | *outSupport = hasCapability(DisplayCapability::DOZE); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 342 | return Error::NONE; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 343 | } |
| 344 | |
Peiyong Lin | 6266589 | 2018-04-16 11:07:44 -0700 | [diff] [blame] | 345 | Error Display::getHdrCapabilities(HdrCapabilities* outCapabilities) const |
Dan Stoza | 7d7ae73 | 2016-03-16 12:23:40 -0700 | [diff] [blame] | 346 | { |
Dan Stoza | 7d7ae73 | 2016-03-16 12:23:40 -0700 | [diff] [blame] | 347 | float maxLuminance = -1.0f; |
| 348 | float maxAverageLuminance = -1.0f; |
| 349 | float minLuminance = -1.0f; |
Marc Kassis | bdf7e4b | 2022-11-04 17:26:48 +0100 | [diff] [blame] | 350 | std::vector<Hwc2::Hdr> hdrTypes; |
| 351 | auto intError = mComposer.getHdrCapabilities(mId, &hdrTypes, &maxLuminance, |
| 352 | &maxAverageLuminance, &minLuminance); |
Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 353 | auto error = static_cast<HWC2::Error>(intError); |
| 354 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 355 | if (error != Error::NONE) { |
Dan Stoza | 7d7ae73 | 2016-03-16 12:23:40 -0700 | [diff] [blame] | 356 | return error; |
| 357 | } |
| 358 | |
Marc Kassis | bdf7e4b | 2022-11-04 17:26:48 +0100 | [diff] [blame] | 359 | *outCapabilities = |
| 360 | HdrCapabilities(std::move(hdrTypes), maxLuminance, maxAverageLuminance, minLuminance); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 361 | return Error::NONE; |
Dan Stoza | 7d7ae73 | 2016-03-16 12:23:40 -0700 | [diff] [blame] | 362 | } |
| 363 | |
Sally Qi | bb866c1 | 2022-10-17 11:31:20 -0700 | [diff] [blame] | 364 | Error Display::getOverlaySupport(OverlayProperties* outProperties) const { |
| 365 | auto intError = mComposer.getOverlaySupport(outProperties); |
| 366 | return static_cast<Error>(intError); |
Sally Qi | 0cbd08b | 2022-08-17 12:12:28 -0700 | [diff] [blame] | 367 | } |
| 368 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 369 | Error Display::getDisplayedContentSamplingAttributes(hal::PixelFormat* outFormat, |
Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 370 | Dataspace* outDataspace, |
| 371 | uint8_t* outComponentMask) const { |
| 372 | auto intError = mComposer.getDisplayedContentSamplingAttributes(mId, outFormat, outDataspace, |
| 373 | outComponentMask); |
| 374 | return static_cast<Error>(intError); |
| 375 | } |
| 376 | |
Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 377 | Error Display::setDisplayContentSamplingEnabled(bool enabled, uint8_t componentMask, |
| 378 | uint64_t maxFrames) const { |
| 379 | auto intError = |
| 380 | mComposer.setDisplayContentSamplingEnabled(mId, enabled, componentMask, maxFrames); |
| 381 | return static_cast<Error>(intError); |
| 382 | } |
| 383 | |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 384 | Error Display::getDisplayedContentSample(uint64_t maxFrames, uint64_t timestamp, |
| 385 | android::DisplayedFrameStats* outStats) const { |
| 386 | auto intError = mComposer.getDisplayedContentSample(mId, maxFrames, timestamp, outStats); |
| 387 | return static_cast<Error>(intError); |
| 388 | } |
| 389 | |
Lloyd Pique | 35d5824 | 2018-12-18 16:33:25 -0800 | [diff] [blame] | 390 | Error Display::getReleaseFences(std::unordered_map<HWC2::Layer*, sp<Fence>>* outFences) const { |
Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 391 | std::vector<Hwc2::Layer> layerIds; |
| 392 | std::vector<int> fenceFds; |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 393 | auto intError = mComposer.getReleaseFences(mId, &layerIds, &fenceFds); |
Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 394 | auto error = static_cast<Error>(intError); |
| 395 | uint32_t numElements = layerIds.size(); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 396 | if (error != Error::NONE) { |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 397 | return error; |
| 398 | } |
| 399 | |
Lloyd Pique | 35d5824 | 2018-12-18 16:33:25 -0800 | [diff] [blame] | 400 | std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 401 | releaseFences.reserve(numElements); |
| 402 | for (uint32_t element = 0; element < numElements; ++element) { |
| 403 | auto layer = getLayerById(layerIds[element]); |
| 404 | if (layer) { |
Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 405 | sp<Fence> fence(sp<Fence>::make(fenceFds[element])); |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 406 | releaseFences.emplace(layer.get(), fence); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 407 | } else { |
| 408 | ALOGE("getReleaseFences: invalid layer %" PRIu64 |
| 409 | " found on display %" PRIu64, layerIds[element], mId); |
Chia-I Wu | 5e74c65 | 2017-05-17 13:43:16 -0700 | [diff] [blame] | 410 | for (; element < numElements; ++element) { |
| 411 | close(fenceFds[element]); |
| 412 | } |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 413 | return Error::BAD_LAYER; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 414 | } |
| 415 | } |
| 416 | |
| 417 | *outFences = std::move(releaseFences); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 418 | return Error::NONE; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 419 | } |
| 420 | |
Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 421 | Error Display::present(sp<Fence>* outPresentFence) |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 422 | { |
Naseer Ahmed | 847650b | 2016-06-17 11:14:25 -0400 | [diff] [blame] | 423 | int32_t presentFenceFd = -1; |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 424 | auto intError = mComposer.presentDisplay(mId, &presentFenceFd); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 425 | auto error = static_cast<Error>(intError); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 426 | if (error != Error::NONE) { |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 427 | return error; |
| 428 | } |
| 429 | |
Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 430 | *outPresentFence = sp<Fence>::make(presentFenceFd); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 431 | return Error::NONE; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 432 | } |
| 433 | |
Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 434 | Error Display::setActiveConfigWithConstraints(hal::HWConfigId configId, |
| 435 | const VsyncPeriodChangeConstraints& constraints, |
| 436 | VsyncPeriodChangeTimeline* outTimeline) { |
Ady Abraham | 7159f57 | 2019-10-11 11:10:18 -0700 | [diff] [blame] | 437 | ALOGV("[%" PRIu64 "] setActiveConfigWithConstraints", mId); |
Ady Abraham | 7159f57 | 2019-10-11 11:10:18 -0700 | [diff] [blame] | 438 | |
Dominik Laskowski | 8809687 | 2023-12-08 15:26:04 -0500 | [diff] [blame] | 439 | // FIXME (b/319505580): At least the first config set on an external display must be |
| 440 | // `setActiveConfig`, so skip over the block that calls `setActiveConfigWithConstraints` |
| 441 | // for simplicity. |
Dominik Laskowski | 8809687 | 2023-12-08 15:26:04 -0500 | [diff] [blame] | 442 | const bool connected_display = FlagManager::getInstance().connected_display(); |
Dominik Laskowski | 8809687 | 2023-12-08 15:26:04 -0500 | [diff] [blame] | 443 | |
| 444 | if (isVsyncPeriodSwitchSupported() && |
Dominik Laskowski | 969cdcb | 2024-02-08 16:35:29 -0500 | [diff] [blame] | 445 | (!connected_display || |
| 446 | getConnectionType().value_opt() != ui::DisplayConnectionType::External)) { |
Ady Abraham | 7159f57 | 2019-10-11 11:10:18 -0700 | [diff] [blame] | 447 | Hwc2::IComposerClient::VsyncPeriodChangeConstraints hwc2Constraints; |
| 448 | hwc2Constraints.desiredTimeNanos = constraints.desiredTimeNanos; |
| 449 | hwc2Constraints.seamlessRequired = constraints.seamlessRequired; |
| 450 | |
| 451 | Hwc2::VsyncPeriodChangeTimeline vsyncPeriodChangeTimeline = {}; |
Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 452 | auto intError = mComposer.setActiveConfigWithConstraints(mId, configId, hwc2Constraints, |
| 453 | &vsyncPeriodChangeTimeline); |
Ady Abraham | 7159f57 | 2019-10-11 11:10:18 -0700 | [diff] [blame] | 454 | outTimeline->newVsyncAppliedTimeNanos = vsyncPeriodChangeTimeline.newVsyncAppliedTimeNanos; |
| 455 | outTimeline->refreshRequired = vsyncPeriodChangeTimeline.refreshRequired; |
| 456 | outTimeline->refreshTimeNanos = vsyncPeriodChangeTimeline.refreshTimeNanos; |
| 457 | return static_cast<Error>(intError); |
| 458 | } |
| 459 | |
| 460 | // Use legacy setActiveConfig instead |
| 461 | ALOGV("fallback to legacy setActiveConfig"); |
| 462 | const auto now = systemTime(); |
| 463 | if (constraints.desiredTimeNanos > now || constraints.seamlessRequired) { |
| 464 | ALOGE("setActiveConfigWithConstraints received constraints that can't be satisfied"); |
| 465 | } |
| 466 | |
Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 467 | auto intError_2_4 = mComposer.setActiveConfig(mId, configId); |
Ady Abraham | 7159f57 | 2019-10-11 11:10:18 -0700 | [diff] [blame] | 468 | outTimeline->newVsyncAppliedTimeNanos = std::max(now, constraints.desiredTimeNanos); |
| 469 | outTimeline->refreshRequired = true; |
| 470 | outTimeline->refreshTimeNanos = now; |
| 471 | return static_cast<Error>(intError_2_4); |
| 472 | } |
| 473 | |
Daniel Nicoara | 1f42e3a | 2017-04-10 13:27:32 -0400 | [diff] [blame] | 474 | Error Display::setClientTarget(uint32_t slot, const sp<GraphicBuffer>& target, |
Alec Mouri | f97df4d | 2023-09-06 02:10:05 +0000 | [diff] [blame] | 475 | const sp<Fence>& acquireFence, Dataspace dataspace, |
| 476 | float hdrSdrRatio) { |
Dan Stoza | 5cf424b | 2016-05-20 14:02:39 -0700 | [diff] [blame] | 477 | // TODO: Properly encode client target surface damage |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 478 | int32_t fenceFd = acquireFence->dup(); |
Alec Mouri | f97df4d | 2023-09-06 02:10:05 +0000 | [diff] [blame] | 479 | auto intError = |
| 480 | mComposer.setClientTarget(mId, slot, target, fenceFd, dataspace, |
| 481 | std::vector<Hwc2::IComposerClient::Rect>(), hdrSdrRatio); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 482 | return static_cast<Error>(intError); |
| 483 | } |
| 484 | |
Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 485 | Error Display::setColorMode(ColorMode mode, RenderIntent renderIntent) |
Dan Stoza | 076ac67 | 2016-03-14 10:47:53 -0700 | [diff] [blame] | 486 | { |
Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 487 | auto intError = mComposer.setColorMode(mId, mode, renderIntent); |
Dan Stoza | 076ac67 | 2016-03-14 10:47:53 -0700 | [diff] [blame] | 488 | return static_cast<Error>(intError); |
| 489 | } |
| 490 | |
Ady Abraham | dc011a9 | 2021-12-21 14:06:44 -0800 | [diff] [blame] | 491 | Error Display::setColorTransform(const android::mat4& matrix) { |
| 492 | auto intError = mComposer.setColorTransform(mId, matrix.asArray()); |
Dan Stoza | 5df2a86 | 2016-03-24 16:19:37 -0700 | [diff] [blame] | 493 | return static_cast<Error>(intError); |
| 494 | } |
| 495 | |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 496 | Error Display::setOutputBuffer(const sp<GraphicBuffer>& buffer, |
| 497 | const sp<Fence>& releaseFence) |
| 498 | { |
| 499 | int32_t fenceFd = releaseFence->dup(); |
| 500 | auto handle = buffer->getNativeBuffer()->handle; |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 501 | auto intError = mComposer.setOutputBuffer(mId, handle, fenceFd); |
Dan Stoza | 3862898 | 2016-07-13 15:48:58 -0700 | [diff] [blame] | 502 | close(fenceFd); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 503 | return static_cast<Error>(intError); |
| 504 | } |
| 505 | |
| 506 | Error Display::setPowerMode(PowerMode mode) |
| 507 | { |
Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 508 | auto intMode = static_cast<Hwc2::IComposerClient::PowerMode>(mode); |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 509 | auto intError = mComposer.setPowerMode(mId, intMode); |
Peiyong Lin | 1336e6e | 2019-05-28 09:23:50 -0700 | [diff] [blame] | 510 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 511 | if (mode == PowerMode::ON) { |
HyunKyoung | a264a35 | 2024-04-24 18:51:33 +0900 | [diff] [blame] | 512 | loadDisplayCapabilities(); |
Peiyong Lin | 1336e6e | 2019-05-28 09:23:50 -0700 | [diff] [blame] | 513 | } |
| 514 | |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 515 | return static_cast<Error>(intError); |
| 516 | } |
| 517 | |
| 518 | Error Display::setVsyncEnabled(Vsync enabled) |
| 519 | { |
Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 520 | auto intEnabled = static_cast<Hwc2::IComposerClient::Vsync>(enabled); |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 521 | auto intError = mComposer.setVsyncEnabled(mId, intEnabled); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 522 | return static_cast<Error>(intError); |
| 523 | } |
| 524 | |
ramindani | 09acbb8 | 2023-11-03 09:02:38 -0700 | [diff] [blame] | 525 | Error Display::validate(nsecs_t expectedPresentTime, int32_t frameIntervalNs, uint32_t* outNumTypes, |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 526 | uint32_t* outNumRequests) { |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 527 | uint32_t numTypes = 0; |
| 528 | uint32_t numRequests = 0; |
ramindani | 09acbb8 | 2023-11-03 09:02:38 -0700 | [diff] [blame] | 529 | auto intError = mComposer.validateDisplay(mId, expectedPresentTime, frameIntervalNs, &numTypes, |
| 530 | &numRequests); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 531 | auto error = static_cast<Error>(intError); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 532 | if (error != Error::NONE && !hasChangesError(error)) { |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 533 | return error; |
| 534 | } |
| 535 | |
| 536 | *outNumTypes = numTypes; |
| 537 | *outNumRequests = numRequests; |
| 538 | return error; |
| 539 | } |
| 540 | |
ramindani | 4aac32c | 2023-10-30 14:13:30 -0700 | [diff] [blame] | 541 | Error Display::presentOrValidate(nsecs_t expectedPresentTime, int32_t frameIntervalNs, |
| 542 | uint32_t* outNumTypes, uint32_t* outNumRequests, |
| 543 | sp<android::Fence>* outPresentFence, uint32_t* state) { |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 544 | uint32_t numTypes = 0; |
| 545 | uint32_t numRequests = 0; |
| 546 | int32_t presentFenceFd = -1; |
ramindani | 4aac32c | 2023-10-30 14:13:30 -0700 | [diff] [blame] | 547 | auto intError = |
| 548 | mComposer.presentOrValidateDisplay(mId, expectedPresentTime, frameIntervalNs, &numTypes, |
| 549 | &numRequests, &presentFenceFd, state); |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 550 | auto error = static_cast<Error>(intError); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 551 | if (error != Error::NONE && !hasChangesError(error)) { |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 552 | return error; |
| 553 | } |
| 554 | |
| 555 | if (*state == 1) { |
Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 556 | *outPresentFence = sp<Fence>::make(presentFenceFd); |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | if (*state == 0) { |
| 560 | *outNumTypes = numTypes; |
| 561 | *outNumRequests = numRequests; |
| 562 | } |
| 563 | return error; |
| 564 | } |
Chia-I Wu | 0c6ce46 | 2017-06-22 10:48:28 -0700 | [diff] [blame] | 565 | |
Dominik Laskowski | b17c621 | 2022-05-09 09:36:19 -0700 | [diff] [blame] | 566 | ftl::Future<Error> Display::setDisplayBrightness( |
Alec Mouri | 4d8a05d | 2022-03-23 18:14:26 +0000 | [diff] [blame] | 567 | float brightness, float brightnessNits, |
| 568 | const Hwc2::Composer::DisplayBrightnessOptions& options) { |
| 569 | return ftl::defer([composer = &mComposer, id = mId, brightness, brightnessNits, options] { |
| 570 | const auto intError = |
| 571 | composer->setDisplayBrightness(id, brightness, brightnessNits, options); |
Dominik Laskowski | 5690bde | 2020-04-23 19:04:22 -0700 | [diff] [blame] | 572 | return static_cast<Error>(intError); |
| 573 | }); |
Dan Gittik | 57e63c5 | 2019-01-18 16:37:54 +0000 | [diff] [blame] | 574 | } |
| 575 | |
Kriti Dang | 7defaf3 | 2021-11-15 11:55:43 +0100 | [diff] [blame] | 576 | Error Display::setBootDisplayConfig(hal::HWConfigId configId) { |
| 577 | auto intError = mComposer.setBootDisplayConfig(mId, configId); |
| 578 | return static_cast<Error>(intError); |
| 579 | } |
| 580 | |
| 581 | Error Display::clearBootDisplayConfig() { |
| 582 | auto intError = mComposer.clearBootDisplayConfig(mId); |
| 583 | return static_cast<Error>(intError); |
| 584 | } |
| 585 | |
| 586 | Error Display::getPreferredBootDisplayConfig(hal::HWConfigId* configId) const { |
| 587 | auto intError = mComposer.getPreferredBootDisplayConfig(mId, configId); |
| 588 | return static_cast<Error>(intError); |
| 589 | } |
| 590 | |
Dominik Laskowski | 5690bde | 2020-04-23 19:04:22 -0700 | [diff] [blame] | 591 | Error Display::setAutoLowLatencyMode(bool on) { |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 592 | auto intError = mComposer.setAutoLowLatencyMode(mId, on); |
| 593 | return static_cast<Error>(intError); |
| 594 | } |
| 595 | |
| 596 | Error Display::getSupportedContentTypes(std::vector<ContentType>* outSupportedContentTypes) const { |
| 597 | std::vector<Hwc2::IComposerClient::ContentType> tmpSupportedContentTypes; |
| 598 | auto intError = mComposer.getSupportedContentTypes(mId, &tmpSupportedContentTypes); |
| 599 | for (Hwc2::IComposerClient::ContentType contentType : tmpSupportedContentTypes) { |
| 600 | outSupportedContentTypes->push_back(static_cast<ContentType>(contentType)); |
| 601 | } |
| 602 | return static_cast<Error>(intError); |
| 603 | } |
| 604 | |
Dominik Laskowski | 5690bde | 2020-04-23 19:04:22 -0700 | [diff] [blame] | 605 | Error Display::setContentType(ContentType contentType) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 606 | auto intError = mComposer.setContentType(mId, contentType); |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 607 | return static_cast<Error>(intError); |
| 608 | } |
| 609 | |
Alec Mouri | 8506569 | 2022-03-18 00:58:26 +0000 | [diff] [blame] | 610 | Error Display::getClientTargetProperty( |
| 611 | aidl::android::hardware::graphics::composer3::ClientTargetPropertyWithBrightness* |
| 612 | outClientTargetProperty) { |
| 613 | const auto error = mComposer.getClientTargetProperty(mId, outClientTargetProperty); |
Peiyong Lin | dfc3f7c | 2020-05-07 20:15:50 -0700 | [diff] [blame] | 614 | return static_cast<Error>(error); |
| 615 | } |
| 616 | |
Sally Qi | 95f669a | 2024-08-27 11:31:42 -0700 | [diff] [blame] | 617 | Error Display::getRequestedLuts(LayerLuts* outLuts, |
| 618 | LutFileDescriptorMapper& lutFileDescriptorMapper) { |
| 619 | std::vector<Hwc2::Layer> layerIds; |
| 620 | std::vector<DisplayLuts::LayerLut> tmpLuts; |
| 621 | const auto error = static_cast<Error>(mComposer.getRequestedLuts(mId, &layerIds, &tmpLuts)); |
| 622 | if (error != Error::NONE) { |
| 623 | return error; |
| 624 | } |
| 625 | |
| 626 | uint32_t numElements = layerIds.size(); |
| 627 | outLuts->clear(); |
| 628 | for (uint32_t i = 0; i < numElements; ++i) { |
| 629 | auto layer = getLayerById(layerIds[i]); |
| 630 | if (layer) { |
| 631 | auto& layerLut = tmpLuts[i]; |
Sally Qi | 0abc4a5 | 2024-09-26 16:13:06 -0700 | [diff] [blame] | 632 | if (layerLut.luts.pfd.get() > 0 && layerLut.luts.offsets.has_value()) { |
| 633 | const auto& offsets = layerLut.luts.offsets.value(); |
| 634 | std::vector<std::pair<int32_t, LutProperties>> lutOffsetsAndProperties; |
| 635 | lutOffsetsAndProperties.reserve(offsets.size()); |
| 636 | std::transform(offsets.begin(), offsets.end(), layerLut.luts.lutProperties.begin(), |
| 637 | std::back_inserter(lutOffsetsAndProperties), |
| 638 | [](int32_t i, LutProperties j) { return std::make_pair(i, j); }); |
| 639 | outLuts->emplace_or_replace(layer.get(), lutOffsetsAndProperties); |
| 640 | lutFileDescriptorMapper.emplace_or_replace(layer.get(), |
| 641 | ndk::ScopedFileDescriptor( |
| 642 | layerLut.luts.pfd.release())); |
| 643 | } |
Sally Qi | 492cec3 | 2024-06-28 14:34:47 -0700 | [diff] [blame] | 644 | } |
| 645 | } |
Sally Qi | 95f669a | 2024-08-27 11:31:42 -0700 | [diff] [blame] | 646 | |
| 647 | return Error::NONE; |
Sally Qi | 492cec3 | 2024-06-28 14:34:47 -0700 | [diff] [blame] | 648 | } |
| 649 | |
Leon Scroggins III | e7c51c6 | 2022-02-01 15:53:54 -0500 | [diff] [blame] | 650 | Error Display::getDisplayDecorationSupport( |
| 651 | std::optional<aidl::android::hardware::graphics::common::DisplayDecorationSupport>* |
| 652 | support) { |
| 653 | const auto error = mComposer.getDisplayDecorationSupport(mId, support); |
| 654 | return static_cast<Error>(error); |
| 655 | } |
| 656 | |
ramindani | 32cf060 | 2022-03-02 02:30:29 +0000 | [diff] [blame] | 657 | Error Display::setIdleTimerEnabled(std::chrono::milliseconds timeout) { |
| 658 | const auto error = mComposer.setIdleTimerEnabled(mId, timeout); |
| 659 | return static_cast<Error>(error); |
| 660 | } |
| 661 | |
Brian Lindahl | 7a4cb7e | 2024-10-30 10:42:21 -0600 | [diff] [blame] | 662 | Error Display::getMaxLayerPictureProfiles(int32_t* outMaxProfiles) { |
| 663 | const auto error = mComposer.getMaxLayerPictureProfiles(mId, outMaxProfiles); |
| 664 | return static_cast<Error>(error); |
| 665 | } |
| 666 | |
| 667 | Error Display::setPictureProfileHandle(const PictureProfileHandle& handle) { |
| 668 | const auto error = mComposer.setDisplayPictureProfileId(mId, handle.getId()); |
| 669 | return static_cast<Error>(error); |
| 670 | } |
| 671 | |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 672 | // For use by Device |
| 673 | |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 674 | void Display::setConnected(bool connected) { |
Steven Thomas | b6c6ad4 | 2018-01-29 12:22:00 -0800 | [diff] [blame] | 675 | if (!mIsConnected && connected) { |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 676 | mComposer.setClientTargetSlotCount(mId); |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 677 | } |
| 678 | mIsConnected = connected; |
| 679 | } |
| 680 | |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 681 | // Other Display methods |
| 682 | |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 683 | std::shared_ptr<HWC2::Layer> Display::getLayerById(HWLayerId id) const { |
| 684 | auto it = mLayers.find(id); |
| 685 | return it != mLayers.end() ? it->second.lock() : nullptr; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 686 | } |
HyunKyoung | a264a35 | 2024-04-24 18:51:33 +0900 | [diff] [blame] | 687 | |
| 688 | void Display::loadDisplayCapabilities() { |
| 689 | std::call_once(mDisplayCapabilityQueryFlag, [this]() { |
| 690 | std::vector<DisplayCapability> tmpCapabilities; |
| 691 | auto error = |
| 692 | static_cast<Error>(mComposer.getDisplayCapabilities(mId, &tmpCapabilities)); |
| 693 | if (error == Error::NONE) { |
| 694 | std::scoped_lock lock(mDisplayCapabilitiesMutex); |
| 695 | mDisplayCapabilities.emplace(); |
| 696 | for (auto capability : tmpCapabilities) { |
| 697 | mDisplayCapabilities->emplace(capability); |
| 698 | } |
| 699 | } else if (error == Error::UNSUPPORTED) { |
| 700 | std::scoped_lock lock(mDisplayCapabilitiesMutex); |
| 701 | mDisplayCapabilities.emplace(); |
| 702 | if (mCapabilities.count(AidlCapability::SKIP_CLIENT_COLOR_TRANSFORM)) { |
| 703 | mDisplayCapabilities->emplace(DisplayCapability::SKIP_CLIENT_COLOR_TRANSFORM); |
| 704 | } |
| 705 | bool dozeSupport = false; |
| 706 | error = static_cast<Error>(mComposer.getDozeSupport(mId, &dozeSupport)); |
| 707 | if (error == Error::NONE && dozeSupport) { |
| 708 | mDisplayCapabilities->emplace(DisplayCapability::DOZE); |
| 709 | } |
| 710 | } |
| 711 | }); |
| 712 | } |
Lucas Berthou | 8d0a0c4 | 2024-08-27 14:32:31 +0000 | [diff] [blame] | 713 | |
| 714 | void Display::setPhysicalSizeInMm(std::optional<ui::Size> size) { |
| 715 | mPhysicalSize = size; |
| 716 | } |
| 717 | |
Ana Krulec | 4593b69 | 2019-01-11 22:07:25 -0800 | [diff] [blame] | 718 | } // namespace impl |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 719 | |
| 720 | // Layer methods |
| 721 | |
Leon Scroggins III | 4459bf4 | 2022-01-04 13:58:26 -0500 | [diff] [blame] | 722 | namespace { |
| 723 | std::vector<Hwc2::IComposerClient::Rect> convertRegionToHwcRects(const Region& region) { |
| 724 | size_t rectCount = 0; |
| 725 | Rect const* rectArray = region.getArray(&rectCount); |
| 726 | |
| 727 | std::vector<Hwc2::IComposerClient::Rect> hwcRects; |
| 728 | hwcRects.reserve(rectCount); |
| 729 | for (size_t rect = 0; rect < rectCount; ++rect) { |
| 730 | hwcRects.push_back({rectArray[rect].left, rectArray[rect].top, rectArray[rect].right, |
| 731 | rectArray[rect].bottom}); |
| 732 | } |
| 733 | return hwcRects; |
| 734 | } |
| 735 | } // namespace |
| 736 | |
Lloyd Pique | 35d5824 | 2018-12-18 16:33:25 -0800 | [diff] [blame] | 737 | Layer::~Layer() = default; |
| 738 | |
| 739 | namespace impl { |
| 740 | |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 741 | Layer::Layer(android::Hwc2::Composer& composer, |
| 742 | const std::unordered_set<AidlCapability>& capabilities, HWC2::Display& display, |
| 743 | HWLayerId layerId) |
Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 744 | : mComposer(composer), |
| 745 | mCapabilities(capabilities), |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 746 | mDisplay(&display), |
Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 747 | mId(layerId), |
| 748 | mColorMatrix(android::mat4()) { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 749 | ALOGV("Created layer %" PRIu64 " on display %" PRIu64, layerId, display.getId()); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | Layer::~Layer() |
| 753 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 754 | onOwningDisplayDestroyed(); |
| 755 | } |
| 756 | |
| 757 | void Layer::onOwningDisplayDestroyed() { |
| 758 | // Note: onOwningDisplayDestroyed() may be called to perform cleanup by |
| 759 | // either the Layer dtor or by the Display dtor and must be safe to call |
| 760 | // from either path. In particular, the call to Display::onLayerDestroyed() |
| 761 | // is expected to be safe to do, |
| 762 | |
| 763 | if (CC_UNLIKELY(!mDisplay)) { |
| 764 | return; |
| 765 | } |
| 766 | |
| 767 | mDisplay->onLayerDestroyed(mId); |
| 768 | |
| 769 | // Note: If the HWC display was actually disconnected, these calls are will |
| 770 | // return an error. We always make them as there may be other reasons for |
| 771 | // the HWC2::Display to be destroyed. |
| 772 | auto intError = mComposer.destroyLayer(mDisplay->getId(), mId); |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 773 | auto error = static_cast<Error>(intError); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 774 | ALOGE_IF(error != Error::NONE, |
| 775 | "destroyLayer(%" PRIu64 ", %" PRIu64 ")" |
| 776 | " failed: %s (%d)", |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 777 | mDisplay->getId(), mId, to_string(error).c_str(), intError); |
| 778 | |
| 779 | mDisplay = nullptr; |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 780 | } |
| 781 | |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 782 | Error Layer::setCursorPosition(int32_t x, int32_t y) |
| 783 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 784 | if (CC_UNLIKELY(!mDisplay)) { |
| 785 | return Error::BAD_DISPLAY; |
| 786 | } |
| 787 | |
| 788 | auto intError = mComposer.setCursorPosition(mDisplay->getId(), mId, x, y); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 789 | return static_cast<Error>(intError); |
| 790 | } |
| 791 | |
Daniel Nicoara | 1f42e3a | 2017-04-10 13:27:32 -0400 | [diff] [blame] | 792 | Error Layer::setBuffer(uint32_t slot, const sp<GraphicBuffer>& buffer, |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 793 | const sp<Fence>& acquireFence) |
| 794 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 795 | if (CC_UNLIKELY(!mDisplay)) { |
| 796 | return Error::BAD_DISPLAY; |
| 797 | } |
| 798 | |
Yichi Chen | 8366f56 | 2019-03-25 19:44:06 +0800 | [diff] [blame] | 799 | if (buffer == nullptr && mBufferSlot == slot) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 800 | return Error::NONE; |
Yichi Chen | 8366f56 | 2019-03-25 19:44:06 +0800 | [diff] [blame] | 801 | } |
| 802 | mBufferSlot = slot; |
| 803 | |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 804 | int32_t fenceFd = acquireFence->dup(); |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 805 | auto intError = mComposer.setLayerBuffer(mDisplay->getId(), mId, slot, buffer, fenceFd); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 806 | return static_cast<Error>(intError); |
| 807 | } |
| 808 | |
Brian Lindahl | b158a5c | 2022-12-15 15:21:13 -0700 | [diff] [blame] | 809 | Error Layer::setBufferSlotsToClear(const std::vector<uint32_t>& slotsToClear, |
| 810 | uint32_t activeBufferSlot) { |
Brian Lindahl | 90553da | 2022-12-06 13:36:30 -0700 | [diff] [blame] | 811 | if (CC_UNLIKELY(!mDisplay)) { |
| 812 | return Error::BAD_DISPLAY; |
| 813 | } |
Brian Lindahl | b158a5c | 2022-12-15 15:21:13 -0700 | [diff] [blame] | 814 | auto intError = mComposer.setLayerBufferSlotsToClear(mDisplay->getId(), mId, slotsToClear, |
| 815 | activeBufferSlot); |
Brian Lindahl | 90553da | 2022-12-06 13:36:30 -0700 | [diff] [blame] | 816 | return static_cast<Error>(intError); |
| 817 | } |
| 818 | |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 819 | Error Layer::setSurfaceDamage(const Region& damage) |
| 820 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 821 | if (CC_UNLIKELY(!mDisplay)) { |
| 822 | return Error::BAD_DISPLAY; |
| 823 | } |
| 824 | |
Yichi Chen | 8366f56 | 2019-03-25 19:44:06 +0800 | [diff] [blame] | 825 | if (damage.isRect() && mDamageRegion.isRect() && |
| 826 | (damage.getBounds() == mDamageRegion.getBounds())) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 827 | return Error::NONE; |
Yichi Chen | 8366f56 | 2019-03-25 19:44:06 +0800 | [diff] [blame] | 828 | } |
| 829 | mDamageRegion = damage; |
| 830 | |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 831 | // We encode default full-screen damage as INVALID_RECT upstream, but as 0 |
| 832 | // rects for HWC |
Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 833 | Hwc2::Error intError = Hwc2::Error::NONE; |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 834 | if (damage.isRect() && damage.getBounds() == Rect::INVALID_RECT) { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 835 | intError = mComposer.setLayerSurfaceDamage(mDisplay->getId(), mId, |
| 836 | std::vector<Hwc2::IComposerClient::Rect>()); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 837 | } else { |
Leon Scroggins III | 4459bf4 | 2022-01-04 13:58:26 -0500 | [diff] [blame] | 838 | const auto hwcRects = convertRegionToHwcRects(damage); |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 839 | intError = mComposer.setLayerSurfaceDamage(mDisplay->getId(), mId, hwcRects); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 840 | } |
| 841 | |
| 842 | return static_cast<Error>(intError); |
| 843 | } |
| 844 | |
| 845 | Error Layer::setBlendMode(BlendMode mode) |
| 846 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 847 | if (CC_UNLIKELY(!mDisplay)) { |
| 848 | return Error::BAD_DISPLAY; |
| 849 | } |
| 850 | |
| 851 | auto intError = mComposer.setLayerBlendMode(mDisplay->getId(), mId, mode); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 852 | return static_cast<Error>(intError); |
| 853 | } |
| 854 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 855 | Error Layer::setColor(Color color) { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 856 | if (CC_UNLIKELY(!mDisplay)) { |
| 857 | return Error::BAD_DISPLAY; |
| 858 | } |
| 859 | |
| 860 | auto intError = mComposer.setLayerColor(mDisplay->getId(), mId, color); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 861 | return static_cast<Error>(intError); |
| 862 | } |
| 863 | |
| 864 | Error Layer::setCompositionType(Composition type) |
| 865 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 866 | if (CC_UNLIKELY(!mDisplay)) { |
| 867 | return Error::BAD_DISPLAY; |
| 868 | } |
| 869 | |
| 870 | auto intError = mComposer.setLayerCompositionType(mDisplay->getId(), mId, type); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 871 | return static_cast<Error>(intError); |
| 872 | } |
| 873 | |
Peiyong Lin | 34beb7a | 2018-03-28 11:57:12 -0700 | [diff] [blame] | 874 | Error Layer::setDataspace(Dataspace dataspace) |
Dan Stoza | 5df2a86 | 2016-03-24 16:19:37 -0700 | [diff] [blame] | 875 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 876 | if (CC_UNLIKELY(!mDisplay)) { |
| 877 | return Error::BAD_DISPLAY; |
| 878 | } |
| 879 | |
Courtney Goeltzenleuchter | c988ee4 | 2017-05-31 17:56:46 -0600 | [diff] [blame] | 880 | if (dataspace == mDataSpace) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 881 | return Error::NONE; |
Courtney Goeltzenleuchter | c988ee4 | 2017-05-31 17:56:46 -0600 | [diff] [blame] | 882 | } |
| 883 | mDataSpace = dataspace; |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 884 | auto intError = mComposer.setLayerDataspace(mDisplay->getId(), mId, mDataSpace); |
Dan Stoza | 5df2a86 | 2016-03-24 16:19:37 -0700 | [diff] [blame] | 885 | return static_cast<Error>(intError); |
| 886 | } |
| 887 | |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 888 | Error Layer::setPerFrameMetadata(const int32_t supportedPerFrameMetadata, |
| 889 | const android::HdrMetadata& metadata) |
| 890 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 891 | if (CC_UNLIKELY(!mDisplay)) { |
| 892 | return Error::BAD_DISPLAY; |
| 893 | } |
| 894 | |
Courtney Goeltzenleuchter | f9c98e5 | 2018-02-12 07:23:17 -0700 | [diff] [blame] | 895 | if (metadata == mHdrMetadata) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 896 | return Error::NONE; |
Courtney Goeltzenleuchter | f9c98e5 | 2018-02-12 07:23:17 -0700 | [diff] [blame] | 897 | } |
| 898 | |
| 899 | mHdrMetadata = metadata; |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 900 | int validTypes = mHdrMetadata.validTypes & supportedPerFrameMetadata; |
| 901 | std::vector<Hwc2::PerFrameMetadata> perFrameMetadatas; |
| 902 | if (validTypes & HdrMetadata::SMPTE2086) { |
| 903 | perFrameMetadatas.insert(perFrameMetadatas.end(), |
| 904 | {{Hwc2::PerFrameMetadataKey::DISPLAY_RED_PRIMARY_X, |
Valerie Hau | e9e843a | 2018-12-18 13:39:23 -0800 | [diff] [blame] | 905 | mHdrMetadata.smpte2086.displayPrimaryRed.x}, |
| 906 | {Hwc2::PerFrameMetadataKey::DISPLAY_RED_PRIMARY_Y, |
| 907 | mHdrMetadata.smpte2086.displayPrimaryRed.y}, |
| 908 | {Hwc2::PerFrameMetadataKey::DISPLAY_GREEN_PRIMARY_X, |
| 909 | mHdrMetadata.smpte2086.displayPrimaryGreen.x}, |
| 910 | {Hwc2::PerFrameMetadataKey::DISPLAY_GREEN_PRIMARY_Y, |
| 911 | mHdrMetadata.smpte2086.displayPrimaryGreen.y}, |
| 912 | {Hwc2::PerFrameMetadataKey::DISPLAY_BLUE_PRIMARY_X, |
| 913 | mHdrMetadata.smpte2086.displayPrimaryBlue.x}, |
| 914 | {Hwc2::PerFrameMetadataKey::DISPLAY_BLUE_PRIMARY_Y, |
| 915 | mHdrMetadata.smpte2086.displayPrimaryBlue.y}, |
| 916 | {Hwc2::PerFrameMetadataKey::WHITE_POINT_X, |
| 917 | mHdrMetadata.smpte2086.whitePoint.x}, |
| 918 | {Hwc2::PerFrameMetadataKey::WHITE_POINT_Y, |
| 919 | mHdrMetadata.smpte2086.whitePoint.y}, |
| 920 | {Hwc2::PerFrameMetadataKey::MAX_LUMINANCE, |
| 921 | mHdrMetadata.smpte2086.maxLuminance}, |
| 922 | {Hwc2::PerFrameMetadataKey::MIN_LUMINANCE, |
| 923 | mHdrMetadata.smpte2086.minLuminance}}); |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 924 | } |
| 925 | |
| 926 | if (validTypes & HdrMetadata::CTA861_3) { |
| 927 | perFrameMetadatas.insert(perFrameMetadatas.end(), |
| 928 | {{Hwc2::PerFrameMetadataKey::MAX_CONTENT_LIGHT_LEVEL, |
Valerie Hau | e9e843a | 2018-12-18 13:39:23 -0800 | [diff] [blame] | 929 | mHdrMetadata.cta8613.maxContentLightLevel}, |
| 930 | {Hwc2::PerFrameMetadataKey::MAX_FRAME_AVERAGE_LIGHT_LEVEL, |
| 931 | mHdrMetadata.cta8613.maxFrameAverageLightLevel}}); |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 932 | } |
| 933 | |
Alec Mouri | 66d8348 | 2022-01-11 11:14:44 -0800 | [diff] [blame] | 934 | const Error error = static_cast<Error>( |
| 935 | mComposer.setLayerPerFrameMetadata(mDisplay->getId(), mId, perFrameMetadatas)); |
| 936 | if (error != Error::NONE) { |
| 937 | return error; |
| 938 | } |
Valerie Hau | e9e843a | 2018-12-18 13:39:23 -0800 | [diff] [blame] | 939 | |
Alec Mouri | 66d8348 | 2022-01-11 11:14:44 -0800 | [diff] [blame] | 940 | std::vector<Hwc2::PerFrameMetadataBlob> perFrameMetadataBlobs; |
Valerie Hau | e9e843a | 2018-12-18 13:39:23 -0800 | [diff] [blame] | 941 | if (validTypes & HdrMetadata::HDR10PLUS) { |
Yichi Chen | 1d5146d | 2020-06-12 18:50:11 +0800 | [diff] [blame] | 942 | if (CC_UNLIKELY(mHdrMetadata.hdr10plus.size() == 0)) { |
| 943 | return Error::BAD_PARAMETER; |
| 944 | } |
| 945 | |
Valerie Hau | e9e843a | 2018-12-18 13:39:23 -0800 | [diff] [blame] | 946 | perFrameMetadataBlobs.push_back( |
| 947 | {Hwc2::PerFrameMetadataKey::HDR10_PLUS_SEI, mHdrMetadata.hdr10plus}); |
Valerie Hau | e9e843a | 2018-12-18 13:39:23 -0800 | [diff] [blame] | 948 | } |
Alec Mouri | 66d8348 | 2022-01-11 11:14:44 -0800 | [diff] [blame] | 949 | |
| 950 | return static_cast<Error>( |
| 951 | mComposer.setLayerPerFrameMetadataBlobs(mDisplay->getId(), mId, perFrameMetadataBlobs)); |
Courtney Goeltzenleuchter | f9c98e5 | 2018-02-12 07:23:17 -0700 | [diff] [blame] | 952 | } |
| 953 | |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 954 | Error Layer::setDisplayFrame(const Rect& frame) |
| 955 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 956 | if (CC_UNLIKELY(!mDisplay)) { |
| 957 | return Error::BAD_DISPLAY; |
| 958 | } |
| 959 | |
Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 960 | Hwc2::IComposerClient::Rect hwcRect{frame.left, frame.top, |
Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 961 | frame.right, frame.bottom}; |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 962 | auto intError = mComposer.setLayerDisplayFrame(mDisplay->getId(), mId, hwcRect); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 963 | return static_cast<Error>(intError); |
| 964 | } |
| 965 | |
| 966 | Error Layer::setPlaneAlpha(float alpha) |
| 967 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 968 | if (CC_UNLIKELY(!mDisplay)) { |
| 969 | return Error::BAD_DISPLAY; |
| 970 | } |
| 971 | |
| 972 | auto intError = mComposer.setLayerPlaneAlpha(mDisplay->getId(), mId, alpha); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 973 | return static_cast<Error>(intError); |
| 974 | } |
| 975 | |
| 976 | Error Layer::setSidebandStream(const native_handle_t* stream) |
| 977 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 978 | if (CC_UNLIKELY(!mDisplay)) { |
| 979 | return Error::BAD_DISPLAY; |
| 980 | } |
| 981 | |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 982 | if (mCapabilities.count(AidlCapability::SIDEBAND_STREAM) == 0) { |
Dan Stoza | 09e7a27 | 2016-04-14 12:31:01 -0700 | [diff] [blame] | 983 | ALOGE("Attempted to call setSidebandStream without checking that the " |
| 984 | "device supports sideband streams"); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 985 | return Error::UNSUPPORTED; |
Dan Stoza | 09e7a27 | 2016-04-14 12:31:01 -0700 | [diff] [blame] | 986 | } |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 987 | auto intError = mComposer.setLayerSidebandStream(mDisplay->getId(), mId, stream); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 988 | return static_cast<Error>(intError); |
| 989 | } |
| 990 | |
| 991 | Error Layer::setSourceCrop(const FloatRect& crop) |
| 992 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 993 | if (CC_UNLIKELY(!mDisplay)) { |
| 994 | return Error::BAD_DISPLAY; |
| 995 | } |
| 996 | |
Chia-I Wu | cd8d7f0 | 2016-11-16 11:02:31 +0800 | [diff] [blame] | 997 | Hwc2::IComposerClient::FRect hwcRect{ |
Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 998 | crop.left, crop.top, crop.right, crop.bottom}; |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 999 | auto intError = mComposer.setLayerSourceCrop(mDisplay->getId(), mId, hwcRect); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 1000 | return static_cast<Error>(intError); |
| 1001 | } |
| 1002 | |
| 1003 | Error Layer::setTransform(Transform transform) |
| 1004 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 1005 | if (CC_UNLIKELY(!mDisplay)) { |
| 1006 | return Error::BAD_DISPLAY; |
| 1007 | } |
| 1008 | |
Chia-I Wu | aab99f5 | 2016-10-05 12:59:58 +0800 | [diff] [blame] | 1009 | auto intTransform = static_cast<Hwc2::Transform>(transform); |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 1010 | auto intError = mComposer.setLayerTransform(mDisplay->getId(), mId, intTransform); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 1011 | return static_cast<Error>(intError); |
| 1012 | } |
| 1013 | |
| 1014 | Error Layer::setVisibleRegion(const Region& region) |
| 1015 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 1016 | if (CC_UNLIKELY(!mDisplay)) { |
| 1017 | return Error::BAD_DISPLAY; |
| 1018 | } |
| 1019 | |
Yichi Chen | 8366f56 | 2019-03-25 19:44:06 +0800 | [diff] [blame] | 1020 | if (region.isRect() && mVisibleRegion.isRect() && |
| 1021 | (region.getBounds() == mVisibleRegion.getBounds())) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 1022 | return Error::NONE; |
Yichi Chen | 8366f56 | 2019-03-25 19:44:06 +0800 | [diff] [blame] | 1023 | } |
| 1024 | mVisibleRegion = region; |
Leon Scroggins III | 4459bf4 | 2022-01-04 13:58:26 -0500 | [diff] [blame] | 1025 | const auto hwcRects = convertRegionToHwcRects(region); |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 1026 | auto intError = mComposer.setLayerVisibleRegion(mDisplay->getId(), mId, hwcRects); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 1027 | return static_cast<Error>(intError); |
| 1028 | } |
| 1029 | |
| 1030 | Error Layer::setZOrder(uint32_t z) |
| 1031 | { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 1032 | if (CC_UNLIKELY(!mDisplay)) { |
| 1033 | return Error::BAD_DISPLAY; |
| 1034 | } |
| 1035 | |
| 1036 | auto intError = mComposer.setLayerZOrder(mDisplay->getId(), mId, z); |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 1037 | return static_cast<Error>(intError); |
| 1038 | } |
| 1039 | |
Peiyong Lin | 698147a | 2018-09-14 13:27:18 -0700 | [diff] [blame] | 1040 | // Composer HAL 2.3 |
| 1041 | Error Layer::setColorTransform(const android::mat4& matrix) { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 1042 | if (CC_UNLIKELY(!mDisplay)) { |
| 1043 | return Error::BAD_DISPLAY; |
| 1044 | } |
| 1045 | |
Peiyong Lin | 698147a | 2018-09-14 13:27:18 -0700 | [diff] [blame] | 1046 | if (matrix == mColorMatrix) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 1047 | return Error::NONE; |
Peiyong Lin | 698147a | 2018-09-14 13:27:18 -0700 | [diff] [blame] | 1048 | } |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 1049 | auto intError = mComposer.setLayerColorTransform(mDisplay->getId(), mId, matrix.asArray()); |
Peiyong Lin | 04d2587 | 2019-04-18 10:26:19 -0700 | [diff] [blame] | 1050 | Error error = static_cast<Error>(intError); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 1051 | if (error != Error::NONE) { |
Peiyong Lin | 04d2587 | 2019-04-18 10:26:19 -0700 | [diff] [blame] | 1052 | return error; |
| 1053 | } |
| 1054 | mColorMatrix = matrix; |
| 1055 | return error; |
Peiyong Lin | 698147a | 2018-09-14 13:27:18 -0700 | [diff] [blame] | 1056 | } |
Lloyd Pique | 35d5824 | 2018-12-18 16:33:25 -0800 | [diff] [blame] | 1057 | |
Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 1058 | // Composer HAL 2.4 |
| 1059 | Error Layer::setLayerGenericMetadata(const std::string& name, bool mandatory, |
| 1060 | const std::vector<uint8_t>& value) { |
Lloyd Pique | a516c00 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 1061 | if (CC_UNLIKELY(!mDisplay)) { |
| 1062 | return Error::BAD_DISPLAY; |
| 1063 | } |
| 1064 | |
| 1065 | auto intError = |
| 1066 | mComposer.setLayerGenericMetadata(mDisplay->getId(), mId, name, mandatory, value); |
Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 1067 | return static_cast<Error>(intError); |
| 1068 | } |
| 1069 | |
Alec Mouri | cdf6cbc | 2021-11-01 17:21:15 -0700 | [diff] [blame] | 1070 | // AIDL HAL |
Alec Mouri | 6da0e27 | 2022-02-07 12:45:57 -0800 | [diff] [blame] | 1071 | Error Layer::setBrightness(float brightness) { |
Alec Mouri | cdf6cbc | 2021-11-01 17:21:15 -0700 | [diff] [blame] | 1072 | if (CC_UNLIKELY(!mDisplay)) { |
| 1073 | return Error::BAD_DISPLAY; |
| 1074 | } |
| 1075 | |
Alec Mouri | 6da0e27 | 2022-02-07 12:45:57 -0800 | [diff] [blame] | 1076 | auto intError = mComposer.setLayerBrightness(mDisplay->getId(), mId, brightness); |
Alec Mouri | cdf6cbc | 2021-11-01 17:21:15 -0700 | [diff] [blame] | 1077 | return static_cast<Error>(intError); |
| 1078 | } |
| 1079 | |
Leon Scroggins III | d77d316 | 2022-01-05 10:42:28 -0500 | [diff] [blame] | 1080 | Error Layer::setBlockingRegion(const Region& region) { |
| 1081 | if (CC_UNLIKELY(!mDisplay)) { |
| 1082 | return Error::BAD_DISPLAY; |
| 1083 | } |
| 1084 | |
| 1085 | if (region.isRect() && mBlockingRegion.isRect() && |
| 1086 | (region.getBounds() == mBlockingRegion.getBounds())) { |
| 1087 | return Error::NONE; |
| 1088 | } |
| 1089 | mBlockingRegion = region; |
| 1090 | const auto hwcRects = convertRegionToHwcRects(region); |
| 1091 | const auto intError = mComposer.setLayerBlockingRegion(mDisplay->getId(), mId, hwcRects); |
| 1092 | return static_cast<Error>(intError); |
| 1093 | } |
| 1094 | |
Sally Qi | 0abc4a5 | 2024-09-26 16:13:06 -0700 | [diff] [blame] | 1095 | Error Layer::setLuts(aidl::android::hardware::graphics::composer3::Luts& luts) { |
Sally Qi | 11dcd58 | 2024-08-16 18:11:27 -0700 | [diff] [blame] | 1096 | if (CC_UNLIKELY(!mDisplay)) { |
| 1097 | return Error::BAD_DISPLAY; |
| 1098 | } |
| 1099 | const auto intError = mComposer.setLayerLuts(mDisplay->getId(), mId, luts); |
| 1100 | return static_cast<Error>(intError); |
| 1101 | } |
| 1102 | |
Brian Lindahl | 7a4cb7e | 2024-10-30 10:42:21 -0600 | [diff] [blame] | 1103 | Error Layer::setPictureProfileHandle(const PictureProfileHandle& handle) { |
| 1104 | if (CC_UNLIKELY(!mDisplay)) { |
| 1105 | return Error::BAD_DISPLAY; |
| 1106 | } |
| 1107 | const auto intError = |
| 1108 | mComposer.setLayerPictureProfileId(mDisplay->getId(), mId, handle.getId()); |
| 1109 | return static_cast<Error>(intError); |
| 1110 | } |
| 1111 | |
Lloyd Pique | 35d5824 | 2018-12-18 16:33:25 -0800 | [diff] [blame] | 1112 | } // namespace impl |
Dan Stoza | 651bf31 | 2015-10-23 17:03:17 -0700 | [diff] [blame] | 1113 | } // namespace HWC2 |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 1114 | } // namespace android |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 1115 | |
| 1116 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 1117 | #pragma clang diagnostic pop // ignored "-Wconversion" |