Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 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 | |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 17 | #include <android-base/stringprintf.h> |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 18 | #include <compositionengine/CompositionEngine.h> |
Lloyd Pique | d3d6988 | 2019-02-28 16:03:46 -0800 | [diff] [blame] | 19 | #include <compositionengine/CompositionRefreshArgs.h> |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 20 | #include <compositionengine/DisplayCreationArgs.h> |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 21 | #include <compositionengine/DisplaySurface.h> |
Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 22 | #include <compositionengine/LayerFE.h> |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 23 | #include <compositionengine/impl/Display.h> |
Lloyd Pique | 3d0c02e | 2018-10-19 18:38:12 -0700 | [diff] [blame] | 24 | #include <compositionengine/impl/DisplayColorProfile.h> |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 25 | #include <compositionengine/impl/DumpHelpers.h> |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 26 | #include <compositionengine/impl/OutputLayer.h> |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 27 | #include <compositionengine/impl/RenderSurface.h> |
Lloyd Pique | 3b5a69e | 2020-01-16 17:51:01 -0800 | [diff] [blame] | 28 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 29 | #include <utils/Trace.h> |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 30 | |
Lloyd Pique | 3b5a69e | 2020-01-16 17:51:01 -0800 | [diff] [blame] | 31 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 32 | #pragma clang diagnostic push |
| 33 | #pragma clang diagnostic ignored "-Wconversion" |
| 34 | |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 35 | #include "DisplayHardware/HWComposer.h" |
Lloyd Pique | 3b5a69e | 2020-01-16 17:51:01 -0800 | [diff] [blame] | 36 | |
| 37 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 38 | #pragma clang diagnostic pop // ignored "-Wconversion" |
| 39 | |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 40 | #include "DisplayHardware/PowerAdvisor.h" |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 41 | |
| 42 | namespace android::compositionengine::impl { |
| 43 | |
Lloyd Pique | 35fca9d | 2019-02-13 14:24:11 -0800 | [diff] [blame] | 44 | std::shared_ptr<Display> createDisplay( |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 45 | const compositionengine::CompositionEngine& compositionEngine, |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 46 | const compositionengine::DisplayCreationArgs& args) { |
| 47 | return createDisplayTemplated<Display>(compositionEngine, args); |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 50 | Display::~Display() = default; |
| 51 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 52 | void Display::setConfiguration(const compositionengine::DisplayCreationArgs& args) { |
| 53 | mIsVirtual = !args.physical; |
| 54 | mId = args.physical ? std::make_optional(args.physical->id) : std::nullopt; |
| 55 | mPowerAdvisor = args.powerAdvisor; |
| 56 | |
| 57 | editState().isSecure = args.isSecure; |
| 58 | |
| 59 | setLayerStackFilter(args.layerStackId, |
| 60 | args.physical ? args.physical->type == DisplayConnectionType::Internal |
| 61 | : false); |
| 62 | setName(args.name); |
| 63 | |
| 64 | if (!args.physical && args.useHwcVirtualDisplays) { |
| 65 | mId = maybeAllocateDisplayIdForVirtualDisplay(args.pixels, args.pixelFormat); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | std::optional<DisplayId> Display::maybeAllocateDisplayIdForVirtualDisplay( |
| 70 | ui::Size pixels, ui::PixelFormat pixelFormat) const { |
| 71 | auto& hwc = getCompositionEngine().getHwComposer(); |
| 72 | return hwc.allocateVirtualDisplay(static_cast<uint32_t>(pixels.width), |
| 73 | static_cast<uint32_t>(pixels.height), &pixelFormat); |
| 74 | } |
| 75 | |
| 76 | bool Display::isValid() const { |
| 77 | return Output::isValid() && mPowerAdvisor; |
| 78 | } |
| 79 | |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 80 | const std::optional<DisplayId>& Display::getId() const { |
| 81 | return mId; |
| 82 | } |
| 83 | |
| 84 | bool Display::isSecure() const { |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 85 | return getState().isSecure; |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | bool Display::isVirtual() const { |
| 89 | return mIsVirtual; |
| 90 | } |
| 91 | |
Lloyd Pique | 6c564cf | 2019-05-17 17:31:36 -0700 | [diff] [blame] | 92 | std::optional<DisplayId> Display::getDisplayId() const { |
| 93 | return mId; |
| 94 | } |
| 95 | |
Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 96 | void Display::setDisplayIdForTesting(std::optional<DisplayId> displayId) { |
| 97 | mId = displayId; |
| 98 | } |
| 99 | |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 100 | void Display::disconnect() { |
| 101 | if (!mId) { |
| 102 | return; |
| 103 | } |
| 104 | |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 105 | auto& hwc = getCompositionEngine().getHwComposer(); |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 106 | hwc.disconnectDisplay(*mId); |
| 107 | mId.reset(); |
| 108 | } |
| 109 | |
Lloyd Pique | 3eb1b21 | 2019-03-07 21:15:40 -0800 | [diff] [blame] | 110 | void Display::setColorTransform(const compositionengine::CompositionRefreshArgs& args) { |
| 111 | Output::setColorTransform(args); |
| 112 | |
| 113 | if (!mId || CC_LIKELY(!args.colorTransformMatrix)) { |
| 114 | return; |
| 115 | } |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 116 | |
| 117 | auto& hwc = getCompositionEngine().getHwComposer(); |
Lloyd Pique | 3eb1b21 | 2019-03-07 21:15:40 -0800 | [diff] [blame] | 118 | status_t result = hwc.setColorTransform(*mId, *args.colorTransformMatrix); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 119 | ALOGE_IF(result != NO_ERROR, "Failed to set color transform on display \"%s\": %d", |
| 120 | mId ? to_string(*mId).c_str() : "", result); |
| 121 | } |
| 122 | |
Lloyd Pique | 6a3b446 | 2019-03-07 20:58:12 -0800 | [diff] [blame] | 123 | void Display::setColorProfile(const ColorProfile& colorProfile) { |
| 124 | const ui::Dataspace targetDataspace = |
| 125 | getDisplayColorProfile()->getTargetDataspace(colorProfile.mode, colorProfile.dataspace, |
| 126 | colorProfile.colorSpaceAgnosticDataspace); |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 127 | |
Lloyd Pique | 6a3b446 | 2019-03-07 20:58:12 -0800 | [diff] [blame] | 128 | if (colorProfile.mode == getState().colorMode && |
| 129 | colorProfile.dataspace == getState().dataspace && |
| 130 | colorProfile.renderIntent == getState().renderIntent && |
| 131 | targetDataspace == getState().targetDataspace) { |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 132 | return; |
| 133 | } |
| 134 | |
| 135 | if (mIsVirtual) { |
| 136 | ALOGW("%s: Invalid operation on virtual display", __FUNCTION__); |
| 137 | return; |
| 138 | } |
| 139 | |
Lloyd Pique | 6a3b446 | 2019-03-07 20:58:12 -0800 | [diff] [blame] | 140 | Output::setColorProfile(colorProfile); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 141 | |
| 142 | auto& hwc = getCompositionEngine().getHwComposer(); |
Lloyd Pique | 6a3b446 | 2019-03-07 20:58:12 -0800 | [diff] [blame] | 143 | hwc.setActiveColorMode(*mId, colorProfile.mode, colorProfile.renderIntent); |
Lloyd Pique | 32cbe28 | 2018-10-19 13:09:22 -0700 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | void Display::dump(std::string& out) const { |
| 147 | using android::base::StringAppendF; |
| 148 | |
| 149 | StringAppendF(&out, " Composition Display State: [\"%s\"]", getName().c_str()); |
| 150 | |
| 151 | out.append("\n "); |
| 152 | |
| 153 | dumpVal(out, "isVirtual", mIsVirtual); |
| 154 | if (mId) { |
| 155 | dumpVal(out, "hwcId", to_string(*mId)); |
| 156 | } else { |
| 157 | StringAppendF(&out, "no hwcId, "); |
| 158 | } |
| 159 | |
| 160 | out.append("\n"); |
| 161 | |
| 162 | Output::dumpBase(out); |
| 163 | } |
| 164 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 165 | void Display::createDisplayColorProfile(const DisplayColorProfileCreationArgs& args) { |
| 166 | setDisplayColorProfile(compositionengine::impl::createDisplayColorProfile(args)); |
Lloyd Pique | 3d0c02e | 2018-10-19 18:38:12 -0700 | [diff] [blame] | 167 | } |
| 168 | |
Lloyd Pique | a38ea7e | 2019-04-16 18:10:26 -0700 | [diff] [blame] | 169 | void Display::createRenderSurface(const RenderSurfaceCreationArgs& args) { |
| 170 | setRenderSurface( |
| 171 | compositionengine::impl::createRenderSurface(getCompositionEngine(), *this, args)); |
Lloyd Pique | 31cb294 | 2018-10-19 17:23:03 -0700 | [diff] [blame] | 172 | } |
| 173 | |
Vishnu Nair | 9b079a2 | 2020-01-21 14:36:08 -0800 | [diff] [blame] | 174 | void Display::createClientCompositionCache(uint32_t cacheSize) { |
| 175 | cacheClientCompositionRequests(cacheSize); |
| 176 | } |
| 177 | |
Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 178 | std::unique_ptr<compositionengine::OutputLayer> Display::createOutputLayer( |
Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 179 | const sp<compositionengine::LayerFE>& layerFE) const { |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 180 | auto result = impl::createOutputLayer(*this, layerFE); |
Lloyd Pique | df336d9 | 2019-03-07 21:38:42 -0800 | [diff] [blame] | 181 | |
| 182 | if (result && mId) { |
| 183 | auto& hwc = getCompositionEngine().getHwComposer(); |
| 184 | auto displayId = *mId; |
| 185 | // Note: For the moment we ensure it is safe to take a reference to the |
| 186 | // HWComposer implementation by destroying all the OutputLayers (and |
| 187 | // hence the HWC2::Layers they own) before setting a new HWComposer. See |
| 188 | // for example SurfaceFlinger::updateVrFlinger(). |
| 189 | // TODO(b/121291683): Make this safer. |
| 190 | auto hwcLayer = std::shared_ptr<HWC2::Layer>(hwc.createLayer(displayId), |
| 191 | [&hwc, displayId](HWC2::Layer* layer) { |
| 192 | hwc.destroyLayer(displayId, layer); |
| 193 | }); |
| 194 | ALOGE_IF(!hwcLayer, "Failed to create a HWC layer for a HWC supported display %s", |
| 195 | getName().c_str()); |
| 196 | result->setHwcLayer(std::move(hwcLayer)); |
| 197 | } |
| 198 | return result; |
| 199 | } |
| 200 | |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 201 | void Display::setReleasedLayers(const compositionengine::CompositionRefreshArgs& refreshArgs) { |
| 202 | Output::setReleasedLayers(refreshArgs); |
| 203 | |
| 204 | if (!mId || refreshArgs.layersWithQueuedFrames.empty()) { |
| 205 | return; |
| 206 | } |
| 207 | |
| 208 | // For layers that are being removed from a HWC display, and that have |
| 209 | // queued frames, add them to a a list of released layers so we can properly |
| 210 | // set a fence. |
| 211 | compositionengine::Output::ReleasedLayers releasedLayers; |
| 212 | |
| 213 | // Any non-null entries in the current list of layers are layers that are no |
| 214 | // longer going to be visible |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 215 | for (auto* outputLayer : getOutputLayersOrderedByZ()) { |
| 216 | if (!outputLayer) { |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 217 | continue; |
| 218 | } |
| 219 | |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 220 | compositionengine::LayerFE* layerFE = &outputLayer->getLayerFE(); |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 221 | const bool hasQueuedFrames = |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 222 | std::any_of(refreshArgs.layersWithQueuedFrames.cbegin(), |
| 223 | refreshArgs.layersWithQueuedFrames.cend(), |
| 224 | [layerFE](sp<compositionengine::LayerFE> layerWithQueuedFrames) { |
| 225 | return layerFE == layerWithQueuedFrames.get(); |
| 226 | }); |
Lloyd Pique | c29e4c6 | 2019-03-07 21:48:19 -0800 | [diff] [blame] | 227 | |
| 228 | if (hasQueuedFrames) { |
| 229 | releasedLayers.emplace_back(layerFE); |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | setReleasedLayers(std::move(releasedLayers)); |
| 234 | } |
| 235 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 236 | void Display::chooseCompositionStrategy() { |
| 237 | ATRACE_CALL(); |
| 238 | ALOGV(__FUNCTION__); |
| 239 | |
| 240 | // Default to the base settings -- client composition only. |
| 241 | Output::chooseCompositionStrategy(); |
| 242 | |
| 243 | // If we don't have a HWC display, then we are done |
| 244 | if (!mId) { |
| 245 | return; |
| 246 | } |
| 247 | |
| 248 | // Get any composition changes requested by the HWC device, and apply them. |
| 249 | std::optional<android::HWComposer::DeviceRequestedChanges> changes; |
| 250 | auto& hwc = getCompositionEngine().getHwComposer(); |
| 251 | if (status_t result = hwc.getDeviceCompositionChanges(*mId, anyLayersRequireClientComposition(), |
| 252 | &changes); |
| 253 | result != NO_ERROR) { |
| 254 | ALOGE("chooseCompositionStrategy failed for %s: %d (%s)", getName().c_str(), result, |
| 255 | strerror(-result)); |
| 256 | return; |
| 257 | } |
| 258 | if (changes) { |
| 259 | applyChangedTypesToLayers(changes->changedTypes); |
| 260 | applyDisplayRequests(changes->displayRequests); |
| 261 | applyLayerRequestsToLayers(changes->layerRequests); |
| 262 | } |
| 263 | |
| 264 | // Determine what type of composition we are doing from the final state |
| 265 | auto& state = editState(); |
| 266 | state.usesClientComposition = anyLayersRequireClientComposition(); |
| 267 | state.usesDeviceComposition = !allLayersRequireClientComposition(); |
| 268 | } |
| 269 | |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 270 | bool Display::getSkipColorTransform() const { |
Dominik Laskowski | 1162e47 | 2020-04-02 19:02:47 -0700 | [diff] [blame^] | 271 | const auto& hwc = getCompositionEngine().getHwComposer(); |
| 272 | return mId ? hwc.hasDisplayCapability(*mId, HWC2::DisplayCapability::SkipClientColorTransform) |
| 273 | : hwc.hasCapability(HWC2::Capability::SkipClientColorTransform); |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 274 | } |
| 275 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 276 | bool Display::anyLayersRequireClientComposition() const { |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 277 | const auto layers = getOutputLayersOrderedByZ(); |
| 278 | return std::any_of(layers.begin(), layers.end(), |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 279 | [](const auto& layer) { return layer->requiresClientComposition(); }); |
| 280 | } |
| 281 | |
| 282 | bool Display::allLayersRequireClientComposition() const { |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 283 | const auto layers = getOutputLayersOrderedByZ(); |
| 284 | return std::all_of(layers.begin(), layers.end(), |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 285 | [](const auto& layer) { return layer->requiresClientComposition(); }); |
| 286 | } |
| 287 | |
| 288 | void Display::applyChangedTypesToLayers(const ChangedTypes& changedTypes) { |
| 289 | if (changedTypes.empty()) { |
| 290 | return; |
| 291 | } |
| 292 | |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 293 | for (auto* layer : getOutputLayersOrderedByZ()) { |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 294 | auto hwcLayer = layer->getHwcLayer(); |
| 295 | if (!hwcLayer) { |
| 296 | continue; |
| 297 | } |
| 298 | |
| 299 | if (auto it = changedTypes.find(hwcLayer); it != changedTypes.end()) { |
| 300 | layer->applyDeviceCompositionTypeChange( |
| 301 | static_cast<Hwc2::IComposerClient::Composition>(it->second)); |
| 302 | } |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | void Display::applyDisplayRequests(const DisplayRequests& displayRequests) { |
| 307 | auto& state = editState(); |
| 308 | state.flipClientTarget = (static_cast<uint32_t>(displayRequests) & |
| 309 | static_cast<uint32_t>(HWC2::DisplayRequest::FlipClientTarget)) != 0; |
| 310 | // Note: HWC2::DisplayRequest::WriteClientTargetToOutput is currently ignored. |
| 311 | } |
| 312 | |
| 313 | void Display::applyLayerRequestsToLayers(const LayerRequests& layerRequests) { |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 314 | for (auto* layer : getOutputLayersOrderedByZ()) { |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 315 | layer->prepareForDeviceLayerRequests(); |
| 316 | |
| 317 | auto hwcLayer = layer->getHwcLayer(); |
| 318 | if (!hwcLayer) { |
| 319 | continue; |
| 320 | } |
| 321 | |
| 322 | if (auto it = layerRequests.find(hwcLayer); it != layerRequests.end()) { |
| 323 | layer->applyDeviceLayerRequest( |
| 324 | static_cast<Hwc2::IComposerClient::LayerRequest>(it->second)); |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | |
Lloyd Pique | 35fca9d | 2019-02-13 14:24:11 -0800 | [diff] [blame] | 329 | compositionengine::Output::FrameFences Display::presentAndGetFrameFences() { |
| 330 | auto result = impl::Output::presentAndGetFrameFences(); |
| 331 | |
| 332 | if (!mId) { |
| 333 | return result; |
| 334 | } |
| 335 | |
| 336 | auto& hwc = getCompositionEngine().getHwComposer(); |
| 337 | hwc.presentAndGetReleaseFences(*mId); |
| 338 | |
| 339 | result.presentFence = hwc.getPresentFence(*mId); |
| 340 | |
| 341 | // TODO(b/121291683): Change HWComposer call to return entire map |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 342 | for (const auto* layer : getOutputLayersOrderedByZ()) { |
Lloyd Pique | 35fca9d | 2019-02-13 14:24:11 -0800 | [diff] [blame] | 343 | auto hwcLayer = layer->getHwcLayer(); |
| 344 | if (!hwcLayer) { |
| 345 | continue; |
| 346 | } |
| 347 | |
| 348 | result.layerFences.emplace(hwcLayer, hwc.getLayerReleaseFence(*mId, hwcLayer)); |
| 349 | } |
| 350 | |
| 351 | hwc.clearReleaseFences(*mId); |
| 352 | |
| 353 | return result; |
| 354 | } |
| 355 | |
Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 356 | void Display::setExpensiveRenderingExpected(bool enabled) { |
| 357 | Output::setExpensiveRenderingExpected(enabled); |
| 358 | |
| 359 | if (mPowerAdvisor && mId) { |
| 360 | mPowerAdvisor->setExpensiveRenderingExpected(*mId, enabled); |
| 361 | } |
| 362 | } |
| 363 | |
Lloyd Pique | d3d6988 | 2019-02-28 16:03:46 -0800 | [diff] [blame] | 364 | void Display::finishFrame(const compositionengine::CompositionRefreshArgs& refreshArgs) { |
| 365 | // We only need to actually compose the display if: |
| 366 | // 1) It is being handled by hardware composer, which may need this to |
| 367 | // keep its virtual display state machine in sync, or |
| 368 | // 2) There is work to be done (the dirty region isn't empty) |
| 369 | if (!mId) { |
| 370 | if (getDirtyRegion(refreshArgs.repaintEverything).isEmpty()) { |
| 371 | ALOGV("Skipping display composition"); |
| 372 | return; |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | impl::Output::finishFrame(refreshArgs); |
| 377 | } |
| 378 | |
Lloyd Pique | 45a165a | 2018-10-19 11:54:47 -0700 | [diff] [blame] | 379 | } // namespace android::compositionengine::impl |