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