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