blob: 3d49183a5d94155dd6f65fde3145a8b3e98ee900 [file] [log] [blame]
Lloyd Pique45a165a2018-10-19 11:54:47 -07001/*
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 Pique32cbe282018-10-19 13:09:22 -070017#include <android-base/stringprintf.h>
Lloyd Pique45a165a2018-10-19 11:54:47 -070018#include <compositionengine/CompositionEngine.h>
Lloyd Piqued3d69882019-02-28 16:03:46 -080019#include <compositionengine/CompositionRefreshArgs.h>
Lloyd Pique45a165a2018-10-19 11:54:47 -070020#include <compositionengine/DisplayCreationArgs.h>
Lloyd Pique31cb2942018-10-19 17:23:03 -070021#include <compositionengine/DisplaySurface.h>
Lloyd Piquedf336d92019-03-07 21:38:42 -080022#include <compositionengine/LayerFE.h>
Lloyd Pique45a165a2018-10-19 11:54:47 -070023#include <compositionengine/impl/Display.h>
Lloyd Pique3d0c02e2018-10-19 18:38:12 -070024#include <compositionengine/impl/DisplayColorProfile.h>
Lloyd Pique32cbe282018-10-19 13:09:22 -070025#include <compositionengine/impl/DumpHelpers.h>
Lloyd Pique66d68602019-02-13 14:23:31 -080026#include <compositionengine/impl/OutputLayer.h>
Lloyd Pique31cb2942018-10-19 17:23:03 -070027#include <compositionengine/impl/RenderSurface.h>
Lloyd Pique3b5a69e2020-01-16 17:51:01 -080028
Lloyd Pique66d68602019-02-13 14:23:31 -080029#include <utils/Trace.h>
Lloyd Pique45a165a2018-10-19 11:54:47 -070030
Lloyd Pique3b5a69e2020-01-16 17:51:01 -080031// TODO(b/129481165): remove the #pragma below and fix conversion issues
32#pragma clang diagnostic push
33#pragma clang diagnostic ignored "-Wconversion"
34
Lloyd Pique45a165a2018-10-19 11:54:47 -070035#include "DisplayHardware/HWComposer.h"
Lloyd Pique3b5a69e2020-01-16 17:51:01 -080036
37// TODO(b/129481165): remove the #pragma below and fix conversion issues
38#pragma clang diagnostic pop // ignored "-Wconversion"
39
Lloyd Pique688abd42019-02-15 15:42:24 -080040#include "DisplayHardware/PowerAdvisor.h"
Lloyd Pique45a165a2018-10-19 11:54:47 -070041
42namespace android::compositionengine::impl {
43
Lloyd Pique35fca9d2019-02-13 14:24:11 -080044std::shared_ptr<Display> createDisplay(
Lloyd Pique45a165a2018-10-19 11:54:47 -070045 const compositionengine::CompositionEngine& compositionEngine,
Lloyd Piquea38ea7e2019-04-16 18:10:26 -070046 const compositionengine::DisplayCreationArgs& args) {
47 return createDisplayTemplated<Display>(compositionEngine, args);
Lloyd Pique45a165a2018-10-19 11:54:47 -070048}
49
Lloyd Pique45a165a2018-10-19 11:54:47 -070050Display::~Display() = default;
51
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -070052void Display::setConfiguration(const compositionengine::DisplayCreationArgs& args) {
53 mIsVirtual = !args.physical;
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -070054 mPowerAdvisor = args.powerAdvisor;
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -070055 editState().isSecure = args.isSecure;
Marin Shalamanovb15d2272020-09-17 21:41:52 +020056 editState().displaySpace.bounds = Rect(args.pixels);
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -070057 setLayerStackFilter(args.layerStackId,
Marin Shalamanov228f46b2021-01-28 21:11:45 +010058 args.physical &&
59 args.physical->type == ui::DisplayConnectionType::Internal);
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -070060 setName(args.name);
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020061 mGpuVirtualDisplayIdGenerator = args.gpuVirtualDisplayIdGenerator;
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -070062
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020063 if (args.physical) {
64 mId = args.physical->id;
65 } else {
66 std::optional<DisplayId> id;
67 if (args.useHwcVirtualDisplays) {
68 id = maybeAllocateDisplayIdForVirtualDisplay(args.pixels, args.pixelFormat);
69 }
70 if (!id) {
71 id = mGpuVirtualDisplayIdGenerator->nextId();
72 }
73 LOG_ALWAYS_FATAL_IF(!id, "Failed to generate display ID");
74 mId = *id;
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -070075 }
76}
77
78std::optional<DisplayId> Display::maybeAllocateDisplayIdForVirtualDisplay(
79 ui::Size pixels, ui::PixelFormat pixelFormat) const {
80 auto& hwc = getCompositionEngine().getHwComposer();
81 return hwc.allocateVirtualDisplay(static_cast<uint32_t>(pixels.width),
82 static_cast<uint32_t>(pixels.height), &pixelFormat);
83}
84
85bool Display::isValid() const {
86 return Output::isValid() && mPowerAdvisor;
87}
88
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +020089DisplayId Display::getId() const {
Lloyd Pique45a165a2018-10-19 11:54:47 -070090 return mId;
91}
92
93bool Display::isSecure() const {
Lloyd Pique32cbe282018-10-19 13:09:22 -070094 return getState().isSecure;
Lloyd Pique45a165a2018-10-19 11:54:47 -070095}
96
97bool Display::isVirtual() const {
98 return mIsVirtual;
99}
100
Lloyd Pique6c564cf2019-05-17 17:31:36 -0700101std::optional<DisplayId> Display::getDisplayId() const {
102 return mId;
103}
104
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200105void Display::setDisplayIdForTesting(DisplayId displayId) {
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -0700106 mId = displayId;
107}
108
Lloyd Pique45a165a2018-10-19 11:54:47 -0700109void Display::disconnect() {
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200110 if (mIsDisconnected) {
Lloyd Pique45a165a2018-10-19 11:54:47 -0700111 return;
112 }
113
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200114 mIsDisconnected = true;
115 if (const auto id = GpuVirtualDisplayId::tryCast(mId)) {
116 mGpuVirtualDisplayIdGenerator->markUnused(*id);
117 return;
118 }
119 const auto halDisplayId = HalDisplayId::tryCast(mId);
120 LOG_FATAL_IF(!halDisplayId);
121 getCompositionEngine().getHwComposer().disconnectDisplay(*halDisplayId);
Lloyd Pique45a165a2018-10-19 11:54:47 -0700122}
123
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800124void Display::setColorTransform(const compositionengine::CompositionRefreshArgs& args) {
125 Output::setColorTransform(args);
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200126 const auto halDisplayId = HalDisplayId::tryCast(mId);
127 if (mIsDisconnected || !halDisplayId || CC_LIKELY(!args.colorTransformMatrix)) {
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800128 return;
129 }
Lloyd Pique32cbe282018-10-19 13:09:22 -0700130
131 auto& hwc = getCompositionEngine().getHwComposer();
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200132 status_t result = hwc.setColorTransform(*halDisplayId, *args.colorTransformMatrix);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700133 ALOGE_IF(result != NO_ERROR, "Failed to set color transform on display \"%s\": %d",
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200134 to_string(mId).c_str(), result);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700135}
136
Lloyd Pique6a3b4462019-03-07 20:58:12 -0800137void Display::setColorProfile(const ColorProfile& colorProfile) {
138 const ui::Dataspace targetDataspace =
139 getDisplayColorProfile()->getTargetDataspace(colorProfile.mode, colorProfile.dataspace,
140 colorProfile.colorSpaceAgnosticDataspace);
Lloyd Piquef5275482019-01-29 18:42:42 -0800141
Lloyd Pique6a3b4462019-03-07 20:58:12 -0800142 if (colorProfile.mode == getState().colorMode &&
143 colorProfile.dataspace == getState().dataspace &&
144 colorProfile.renderIntent == getState().renderIntent &&
145 targetDataspace == getState().targetDataspace) {
Lloyd Pique32cbe282018-10-19 13:09:22 -0700146 return;
147 }
148
149 if (mIsVirtual) {
150 ALOGW("%s: Invalid operation on virtual display", __FUNCTION__);
151 return;
152 }
153
Lloyd Pique6a3b4462019-03-07 20:58:12 -0800154 Output::setColorProfile(colorProfile);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700155
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200156 const auto physicalId = PhysicalDisplayId::tryCast(mId);
157 LOG_FATAL_IF(!physicalId);
158 getCompositionEngine().getHwComposer().setActiveColorMode(*physicalId, colorProfile.mode,
159 colorProfile.renderIntent);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700160}
161
162void Display::dump(std::string& out) const {
163 using android::base::StringAppendF;
164
165 StringAppendF(&out, " Composition Display State: [\"%s\"]", getName().c_str());
166
167 out.append("\n ");
Lloyd Pique32cbe282018-10-19 13:09:22 -0700168 dumpVal(out, "isVirtual", mIsVirtual);
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200169 dumpVal(out, "DisplayId", to_string(mId));
Lloyd Pique32cbe282018-10-19 13:09:22 -0700170 out.append("\n");
171
172 Output::dumpBase(out);
173}
174
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700175void Display::createDisplayColorProfile(const DisplayColorProfileCreationArgs& args) {
176 setDisplayColorProfile(compositionengine::impl::createDisplayColorProfile(args));
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700177}
178
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700179void Display::createRenderSurface(const RenderSurfaceCreationArgs& args) {
180 setRenderSurface(
181 compositionengine::impl::createRenderSurface(getCompositionEngine(), *this, args));
Lloyd Pique31cb2942018-10-19 17:23:03 -0700182}
183
Vishnu Nair9b079a22020-01-21 14:36:08 -0800184void Display::createClientCompositionCache(uint32_t cacheSize) {
185 cacheClientCompositionRequests(cacheSize);
186}
187
Lloyd Piquedf336d92019-03-07 21:38:42 -0800188std::unique_ptr<compositionengine::OutputLayer> Display::createOutputLayer(
Lloyd Piquedf336d92019-03-07 21:38:42 -0800189 const sp<compositionengine::LayerFE>& layerFE) const {
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200190 auto outputLayer = impl::createOutputLayer(*this, layerFE);
Lloyd Piquedf336d92019-03-07 21:38:42 -0800191
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200192 if (const auto halDisplayId = HalDisplayId::tryCast(mId);
193 outputLayer && !mIsDisconnected && halDisplayId) {
Lloyd Piquedf336d92019-03-07 21:38:42 -0800194 auto& hwc = getCompositionEngine().getHwComposer();
Lloyd Pique1b33fc32021-05-07 14:36:58 -0700195 auto hwcLayer = hwc.createLayer(*halDisplayId);
Lloyd Piquedf336d92019-03-07 21:38:42 -0800196 ALOGE_IF(!hwcLayer, "Failed to create a HWC layer for a HWC supported display %s",
197 getName().c_str());
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200198 outputLayer->setHwcLayer(std::move(hwcLayer));
Lloyd Piquedf336d92019-03-07 21:38:42 -0800199 }
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200200 return outputLayer;
Lloyd Piquedf336d92019-03-07 21:38:42 -0800201}
202
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800203void Display::setReleasedLayers(const compositionengine::CompositionRefreshArgs& refreshArgs) {
204 Output::setReleasedLayers(refreshArgs);
205
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200206 if (mIsDisconnected || GpuVirtualDisplayId::tryCast(mId) ||
207 refreshArgs.layersWithQueuedFrames.empty()) {
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800208 return;
209 }
210
211 // For layers that are being removed from a HWC display, and that have
212 // queued frames, add them to a a list of released layers so we can properly
213 // set a fence.
214 compositionengine::Output::ReleasedLayers releasedLayers;
215
216 // Any non-null entries in the current list of layers are layers that are no
217 // longer going to be visible
Lloyd Piquede196652020-01-22 17:29:58 -0800218 for (auto* outputLayer : getOutputLayersOrderedByZ()) {
219 if (!outputLayer) {
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800220 continue;
221 }
222
Lloyd Piquede196652020-01-22 17:29:58 -0800223 compositionengine::LayerFE* layerFE = &outputLayer->getLayerFE();
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800224 const bool hasQueuedFrames =
Lloyd Piquede196652020-01-22 17:29:58 -0800225 std::any_of(refreshArgs.layersWithQueuedFrames.cbegin(),
226 refreshArgs.layersWithQueuedFrames.cend(),
227 [layerFE](sp<compositionengine::LayerFE> layerWithQueuedFrames) {
228 return layerFE == layerWithQueuedFrames.get();
229 });
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800230
231 if (hasQueuedFrames) {
232 releasedLayers.emplace_back(layerFE);
233 }
234 }
235
236 setReleasedLayers(std::move(releasedLayers));
237}
238
Lloyd Pique66d68602019-02-13 14:23:31 -0800239void Display::chooseCompositionStrategy() {
240 ATRACE_CALL();
241 ALOGV(__FUNCTION__);
242
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200243 if (mIsDisconnected) {
244 return;
245 }
246
Lloyd Pique66d68602019-02-13 14:23:31 -0800247 // Default to the base settings -- client composition only.
248 Output::chooseCompositionStrategy();
249
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200250 // If we don't have a HWC display, then we are done.
251 const auto halDisplayId = HalDisplayId::tryCast(mId);
252 if (!halDisplayId) {
Lloyd Pique66d68602019-02-13 14:23:31 -0800253 return;
254 }
255
256 // Get any composition changes requested by the HWC device, and apply them.
257 std::optional<android::HWComposer::DeviceRequestedChanges> changes;
258 auto& hwc = getCompositionEngine().getHwComposer();
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200259 if (status_t result =
260 hwc.getDeviceCompositionChanges(*halDisplayId, anyLayersRequireClientComposition(),
Ady Abrahamb42cdc12021-05-11 14:31:26 -0700261 getState().earliestPresentTime, &changes);
Lloyd Pique66d68602019-02-13 14:23:31 -0800262 result != NO_ERROR) {
263 ALOGE("chooseCompositionStrategy failed for %s: %d (%s)", getName().c_str(), result,
264 strerror(-result));
265 return;
266 }
267 if (changes) {
268 applyChangedTypesToLayers(changes->changedTypes);
269 applyDisplayRequests(changes->displayRequests);
270 applyLayerRequestsToLayers(changes->layerRequests);
Peiyong Lindfc3f7c2020-05-07 20:15:50 -0700271 applyClientTargetRequests(changes->clientTargetProperty);
Lloyd Pique66d68602019-02-13 14:23:31 -0800272 }
273
274 // Determine what type of composition we are doing from the final state
275 auto& state = editState();
276 state.usesClientComposition = anyLayersRequireClientComposition();
277 state.usesDeviceComposition = !allLayersRequireClientComposition();
278}
279
Lloyd Pique688abd42019-02-15 15:42:24 -0800280bool Display::getSkipColorTransform() const {
Dominik Laskowski1162e472020-04-02 19:02:47 -0700281 const auto& hwc = getCompositionEngine().getHwComposer();
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200282 if (const auto halDisplayId = HalDisplayId::tryCast(mId)) {
283 return hwc.hasDisplayCapability(*halDisplayId,
284 hal::DisplayCapability::SKIP_CLIENT_COLOR_TRANSFORM);
285 }
286
287 return hwc.hasCapability(hal::Capability::SKIP_CLIENT_COLOR_TRANSFORM);
Lloyd Pique688abd42019-02-15 15:42:24 -0800288}
289
Lloyd Pique66d68602019-02-13 14:23:31 -0800290bool Display::anyLayersRequireClientComposition() const {
Lloyd Pique01c77c12019-04-17 12:48:32 -0700291 const auto layers = getOutputLayersOrderedByZ();
292 return std::any_of(layers.begin(), layers.end(),
Lloyd Pique66d68602019-02-13 14:23:31 -0800293 [](const auto& layer) { return layer->requiresClientComposition(); });
294}
295
296bool Display::allLayersRequireClientComposition() const {
Lloyd Pique01c77c12019-04-17 12:48:32 -0700297 const auto layers = getOutputLayersOrderedByZ();
298 return std::all_of(layers.begin(), layers.end(),
Lloyd Pique66d68602019-02-13 14:23:31 -0800299 [](const auto& layer) { return layer->requiresClientComposition(); });
300}
301
302void Display::applyChangedTypesToLayers(const ChangedTypes& changedTypes) {
303 if (changedTypes.empty()) {
304 return;
305 }
306
Lloyd Pique01c77c12019-04-17 12:48:32 -0700307 for (auto* layer : getOutputLayersOrderedByZ()) {
Lloyd Pique66d68602019-02-13 14:23:31 -0800308 auto hwcLayer = layer->getHwcLayer();
309 if (!hwcLayer) {
310 continue;
311 }
312
313 if (auto it = changedTypes.find(hwcLayer); it != changedTypes.end()) {
314 layer->applyDeviceCompositionTypeChange(
315 static_cast<Hwc2::IComposerClient::Composition>(it->second));
316 }
317 }
318}
319
320void Display::applyDisplayRequests(const DisplayRequests& displayRequests) {
321 auto& state = editState();
322 state.flipClientTarget = (static_cast<uint32_t>(displayRequests) &
Peiyong Line9d809e2020-04-14 13:10:48 -0700323 static_cast<uint32_t>(hal::DisplayRequest::FLIP_CLIENT_TARGET)) != 0;
Lloyd Pique66d68602019-02-13 14:23:31 -0800324 // Note: HWC2::DisplayRequest::WriteClientTargetToOutput is currently ignored.
325}
326
327void Display::applyLayerRequestsToLayers(const LayerRequests& layerRequests) {
Lloyd Pique01c77c12019-04-17 12:48:32 -0700328 for (auto* layer : getOutputLayersOrderedByZ()) {
Lloyd Pique66d68602019-02-13 14:23:31 -0800329 layer->prepareForDeviceLayerRequests();
330
331 auto hwcLayer = layer->getHwcLayer();
332 if (!hwcLayer) {
333 continue;
334 }
335
336 if (auto it = layerRequests.find(hwcLayer); it != layerRequests.end()) {
337 layer->applyDeviceLayerRequest(
338 static_cast<Hwc2::IComposerClient::LayerRequest>(it->second));
339 }
340 }
341}
342
Peiyong Lindfc3f7c2020-05-07 20:15:50 -0700343void Display::applyClientTargetRequests(const ClientTargetProperty& clientTargetProperty) {
344 if (clientTargetProperty.dataspace == ui::Dataspace::UNKNOWN) {
345 return;
346 }
Ady Abraham0094dc62021-06-03 10:08:33 -0700347
348 editState().dataspace = clientTargetProperty.dataspace;
Peiyong Lindfc3f7c2020-05-07 20:15:50 -0700349 getRenderSurface()->setBufferDataspace(clientTargetProperty.dataspace);
350 getRenderSurface()->setBufferPixelFormat(clientTargetProperty.pixelFormat);
351}
352
Lloyd Pique35fca9d2019-02-13 14:24:11 -0800353compositionengine::Output::FrameFences Display::presentAndGetFrameFences() {
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200354 auto fences = impl::Output::presentAndGetFrameFences();
Lloyd Pique35fca9d2019-02-13 14:24:11 -0800355
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200356 const auto halDisplayIdOpt = HalDisplayId::tryCast(mId);
357 if (mIsDisconnected || !halDisplayIdOpt) {
358 return fences;
Lloyd Pique35fca9d2019-02-13 14:24:11 -0800359 }
360
361 auto& hwc = getCompositionEngine().getHwComposer();
Ady Abrahamb42cdc12021-05-11 14:31:26 -0700362 hwc.presentAndGetReleaseFences(*halDisplayIdOpt, getState().earliestPresentTime);
Lloyd Pique35fca9d2019-02-13 14:24:11 -0800363
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200364 fences.presentFence = hwc.getPresentFence(*halDisplayIdOpt);
Lloyd Pique35fca9d2019-02-13 14:24:11 -0800365
366 // TODO(b/121291683): Change HWComposer call to return entire map
Lloyd Pique01c77c12019-04-17 12:48:32 -0700367 for (const auto* layer : getOutputLayersOrderedByZ()) {
Lloyd Pique35fca9d2019-02-13 14:24:11 -0800368 auto hwcLayer = layer->getHwcLayer();
369 if (!hwcLayer) {
370 continue;
371 }
372
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200373 fences.layerFences.emplace(hwcLayer, hwc.getLayerReleaseFence(*halDisplayIdOpt, hwcLayer));
Lloyd Pique35fca9d2019-02-13 14:24:11 -0800374 }
375
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200376 hwc.clearReleaseFences(*halDisplayIdOpt);
Lloyd Pique35fca9d2019-02-13 14:24:11 -0800377
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200378 return fences;
Lloyd Pique35fca9d2019-02-13 14:24:11 -0800379}
380
Lloyd Pique688abd42019-02-15 15:42:24 -0800381void Display::setExpensiveRenderingExpected(bool enabled) {
382 Output::setExpensiveRenderingExpected(enabled);
383
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200384 if (mPowerAdvisor && !GpuVirtualDisplayId::tryCast(mId)) {
385 mPowerAdvisor->setExpensiveRenderingExpected(mId, enabled);
Lloyd Pique688abd42019-02-15 15:42:24 -0800386 }
387}
388
Lloyd Piqued3d69882019-02-28 16:03:46 -0800389void Display::finishFrame(const compositionengine::CompositionRefreshArgs& refreshArgs) {
390 // We only need to actually compose the display if:
391 // 1) It is being handled by hardware composer, which may need this to
392 // keep its virtual display state machine in sync, or
393 // 2) There is work to be done (the dirty region isn't empty)
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200394 if (GpuVirtualDisplayId::tryCast(mId) &&
395 getDirtyRegion(refreshArgs.repaintEverything).isEmpty()) {
396 ALOGV("Skipping display composition");
397 return;
Lloyd Piqued3d69882019-02-28 16:03:46 -0800398 }
399
400 impl::Output::finishFrame(refreshArgs);
401}
402
Lloyd Pique45a165a2018-10-19 11:54:47 -0700403} // namespace android::compositionengine::impl