blob: 709d7c9f481e484676834aef248940d932bf2a36 [file] [log] [blame]
Lloyd Pique32cbe282018-10-19 13:09:22 -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 Piquef8cf14d2019-02-28 16:03:12 -080017#include <thread>
18
Lloyd Pique32cbe282018-10-19 13:09:22 -070019#include <android-base/stringprintf.h>
20#include <compositionengine/CompositionEngine.h>
Lloyd Piquef8cf14d2019-02-28 16:03:12 -080021#include <compositionengine/CompositionRefreshArgs.h>
Lloyd Pique3d0c02e2018-10-19 18:38:12 -070022#include <compositionengine/DisplayColorProfile.h>
Lloyd Piquecc01a452018-12-04 17:24:00 -080023#include <compositionengine/LayerFE.h>
Lloyd Pique9755fb72019-03-26 14:44:40 -070024#include <compositionengine/LayerFECompositionState.h>
Lloyd Pique31cb2942018-10-19 17:23:03 -070025#include <compositionengine/RenderSurface.h>
Lloyd Pique32cbe282018-10-19 13:09:22 -070026#include <compositionengine/impl/Output.h>
Lloyd Piquea38ea7e2019-04-16 18:10:26 -070027#include <compositionengine/impl/OutputCompositionState.h>
Lloyd Piquecc01a452018-12-04 17:24:00 -080028#include <compositionengine/impl/OutputLayer.h>
Lloyd Piquea38ea7e2019-04-16 18:10:26 -070029#include <compositionengine/impl/OutputLayerCompositionState.h>
Dan Stoza269dc4d2021-01-15 15:07:43 -080030#include <compositionengine/impl/planner/Planner.h>
31
32#include <SurfaceFlingerProperties.sysprop.h>
Lloyd Pique3b5a69e2020-01-16 17:51:01 -080033
34// TODO(b/129481165): remove the #pragma below and fix conversion issues
35#pragma clang diagnostic push
36#pragma clang diagnostic ignored "-Wconversion"
37
Lloyd Pique688abd42019-02-15 15:42:24 -080038#include <renderengine/DisplaySettings.h>
39#include <renderengine/RenderEngine.h>
Lloyd Pique3b5a69e2020-01-16 17:51:01 -080040
41// TODO(b/129481165): remove the #pragma below and fix conversion issues
42#pragma clang diagnostic pop // ignored "-Wconversion"
43
Dan Stoza269dc4d2021-01-15 15:07:43 -080044#include <android-base/properties.h>
Lloyd Pique32cbe282018-10-19 13:09:22 -070045#include <ui/DebugUtils.h>
Lloyd Pique688abd42019-02-15 15:42:24 -080046#include <ui/HdrCapabilities.h>
Lloyd Pique66d68602019-02-13 14:23:31 -080047#include <utils/Trace.h>
Lloyd Pique32cbe282018-10-19 13:09:22 -070048
Lloyd Pique688abd42019-02-15 15:42:24 -080049#include "TracedOrdinal.h"
50
Lloyd Piquefeb73d72018-12-04 17:23:44 -080051namespace android::compositionengine {
52
53Output::~Output() = default;
54
55namespace impl {
Lloyd Pique32cbe282018-10-19 13:09:22 -070056
Dan Stoza269dc4d2021-01-15 15:07:43 -080057Output::Output() {
58 const bool enableLayerCaching = [] {
59 const bool enable =
60 android::sysprop::SurfaceFlingerProperties::enable_layer_caching().value_or(false);
61 return base::GetBoolProperty(std::string("debug.sf.enable_layer_caching"), enable);
62 }();
63
64 if (enableLayerCaching) {
65 mPlanner = std::make_unique<planner::Planner>();
66 }
67}
68
Lloyd Piquec29e4c62019-03-07 21:48:19 -080069namespace {
70
71template <typename T>
72class Reversed {
73public:
74 explicit Reversed(const T& container) : mContainer(container) {}
75 auto begin() { return mContainer.rbegin(); }
76 auto end() { return mContainer.rend(); }
77
78private:
79 const T& mContainer;
80};
81
82// Helper for enumerating over a container in reverse order
83template <typename T>
84Reversed<T> reversed(const T& c) {
85 return Reversed<T>(c);
86}
87
Marin Shalamanovb15d2272020-09-17 21:41:52 +020088struct ScaleVector {
89 float x;
90 float y;
91};
92
93// Returns a ScaleVector (x, y) such that from.scale(x, y) = to',
94// where to' will have the same size as "to". In the case where "from" and "to"
95// start at the origin to'=to.
96ScaleVector getScale(const Rect& from, const Rect& to) {
97 return {.x = static_cast<float>(to.width()) / from.width(),
98 .y = static_cast<float>(to.height()) / from.height()};
99}
100
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800101} // namespace
102
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700103std::shared_ptr<Output> createOutput(
104 const compositionengine::CompositionEngine& compositionEngine) {
105 return createOutputTemplated<Output>(compositionEngine);
106}
Lloyd Pique32cbe282018-10-19 13:09:22 -0700107
108Output::~Output() = default;
109
Lloyd Pique32cbe282018-10-19 13:09:22 -0700110bool Output::isValid() const {
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700111 return mDisplayColorProfile && mDisplayColorProfile->isValid() && mRenderSurface &&
112 mRenderSurface->isValid();
Lloyd Pique32cbe282018-10-19 13:09:22 -0700113}
114
Lloyd Pique6c564cf2019-05-17 17:31:36 -0700115std::optional<DisplayId> Output::getDisplayId() const {
116 return {};
117}
118
Lloyd Pique32cbe282018-10-19 13:09:22 -0700119const std::string& Output::getName() const {
120 return mName;
121}
122
123void Output::setName(const std::string& name) {
124 mName = name;
125}
126
127void Output::setCompositionEnabled(bool enabled) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700128 auto& outputState = editState();
129 if (outputState.isEnabled == enabled) {
Lloyd Pique32cbe282018-10-19 13:09:22 -0700130 return;
131 }
132
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700133 outputState.isEnabled = enabled;
Lloyd Pique32cbe282018-10-19 13:09:22 -0700134 dirtyEntireOutput();
135}
136
Marin Shalamanov68933fb2020-09-10 17:58:12 +0200137void Output::setProjection(ui::Rotation orientation, const Rect& layerStackSpaceRect,
138 const Rect& orientedDisplaySpaceRect) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700139 auto& outputState = editState();
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200140
Marin Shalamanov68933fb2020-09-10 17:58:12 +0200141 outputState.displaySpace.orientation = orientation;
Marin Shalamanovb15d2272020-09-17 21:41:52 +0200142 LOG_FATAL_IF(outputState.displaySpace.bounds == Rect::INVALID_RECT,
143 "The display bounds are unknown.");
Marin Shalamanov68933fb2020-09-10 17:58:12 +0200144
Marin Shalamanovb15d2272020-09-17 21:41:52 +0200145 // Compute orientedDisplaySpace
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200146 ui::Size orientedSize = outputState.displaySpace.bounds.getSize();
Marin Shalamanov68933fb2020-09-10 17:58:12 +0200147 if (orientation == ui::ROTATION_90 || orientation == ui::ROTATION_270) {
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200148 std::swap(orientedSize.width, orientedSize.height);
149 }
150 outputState.orientedDisplaySpace.bounds = Rect(orientedSize);
Marin Shalamanov68933fb2020-09-10 17:58:12 +0200151 outputState.orientedDisplaySpace.content = orientedDisplaySpaceRect;
152
153 // Compute displaySpace.content
154 const uint32_t transformOrientationFlags = ui::Transform::toRotationFlags(orientation);
155 ui::Transform rotation;
156 if (transformOrientationFlags != ui::Transform::ROT_INVALID) {
157 const auto displaySize = outputState.displaySpace.bounds;
158 rotation.set(transformOrientationFlags, displaySize.width(), displaySize.height());
159 }
160 outputState.displaySpace.content = rotation.transform(orientedDisplaySpaceRect);
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200161
Marin Shalamanovb15d2272020-09-17 21:41:52 +0200162 // Compute framebufferSpace
163 outputState.framebufferSpace.orientation = orientation;
164 LOG_FATAL_IF(outputState.framebufferSpace.bounds == Rect::INVALID_RECT,
165 "The framebuffer bounds are unknown.");
166 const auto scale =
Marin Shalamanov209ae612020-10-01 00:17:39 +0200167 getScale(outputState.displaySpace.bounds, outputState.framebufferSpace.bounds);
Marin Shalamanovb15d2272020-09-17 21:41:52 +0200168 outputState.framebufferSpace.content = outputState.displaySpace.content.scale(scale.x, scale.y);
169
170 // Compute layerStackSpace
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200171 outputState.layerStackSpace.content = layerStackSpaceRect;
172 outputState.layerStackSpace.bounds = layerStackSpaceRect;
Marin Shalamanovb15d2272020-09-17 21:41:52 +0200173
Marin Shalamanov68933fb2020-09-10 17:58:12 +0200174 outputState.transform = outputState.layerStackSpace.getTransform(outputState.displaySpace);
175 outputState.needsFiltering = outputState.transform.needsBilinearFiltering();
Lloyd Pique32cbe282018-10-19 13:09:22 -0700176 dirtyEntireOutput();
177}
178
Marin Shalamanovb15d2272020-09-17 21:41:52 +0200179void Output::setDisplaySize(const ui::Size& size) {
Lloyd Pique31cb2942018-10-19 17:23:03 -0700180 mRenderSurface->setDisplaySize(size);
Marin Shalamanovb15d2272020-09-17 21:41:52 +0200181
182 auto& state = editState();
183
184 // Update framebuffer space
185 const Rect newBounds(size);
Marin Shalamanovb15d2272020-09-17 21:41:52 +0200186 state.framebufferSpace.bounds = newBounds;
Marin Shalamanovb15d2272020-09-17 21:41:52 +0200187
188 // Update display space
Marin Shalamanovb15d2272020-09-17 21:41:52 +0200189 state.displaySpace.bounds = newBounds;
Marin Shalamanovb15d2272020-09-17 21:41:52 +0200190 state.transform = state.layerStackSpace.getTransform(state.displaySpace);
191
192 // Update oriented display space
193 const auto orientation = state.displaySpace.orientation;
194 ui::Size orientedSize = size;
195 if (orientation == ui::ROTATION_90 || orientation == ui::ROTATION_270) {
196 std::swap(orientedSize.width, orientedSize.height);
197 }
198 const Rect newOrientedBounds(orientedSize);
Marin Shalamanovb15d2272020-09-17 21:41:52 +0200199 state.orientedDisplaySpace.bounds = newOrientedBounds;
Lloyd Pique32cbe282018-10-19 13:09:22 -0700200
201 dirtyEntireOutput();
202}
203
Garfield Tan54edd912020-10-21 16:31:41 -0700204ui::Transform::RotationFlags Output::getTransformHint() const {
205 return static_cast<ui::Transform::RotationFlags>(getState().transform.getOrientation());
206}
207
Lloyd Piqueef36b002019-01-23 17:52:04 -0800208void Output::setLayerStackFilter(uint32_t layerStackId, bool isInternal) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700209 auto& outputState = editState();
210 outputState.layerStackId = layerStackId;
211 outputState.layerStackInternal = isInternal;
Lloyd Pique32cbe282018-10-19 13:09:22 -0700212
213 dirtyEntireOutput();
214}
215
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800216void Output::setColorTransform(const compositionengine::CompositionRefreshArgs& args) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700217 auto& colorTransformMatrix = editState().colorTransformMatrix;
218 if (!args.colorTransformMatrix || colorTransformMatrix == args.colorTransformMatrix) {
Lloyd Pique77f79a22019-04-29 15:55:40 -0700219 return;
220 }
221
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700222 colorTransformMatrix = *args.colorTransformMatrix;
Lloyd Piqueef958122019-02-05 18:00:12 -0800223
224 dirtyEntireOutput();
Lloyd Pique32cbe282018-10-19 13:09:22 -0700225}
226
Lloyd Pique6a3b4462019-03-07 20:58:12 -0800227void Output::setColorProfile(const ColorProfile& colorProfile) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700228 ui::Dataspace targetDataspace =
Lloyd Pique6a3b4462019-03-07 20:58:12 -0800229 getDisplayColorProfile()->getTargetDataspace(colorProfile.mode, colorProfile.dataspace,
230 colorProfile.colorSpaceAgnosticDataspace);
Lloyd Piquef5275482019-01-29 18:42:42 -0800231
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700232 auto& outputState = editState();
233 if (outputState.colorMode == colorProfile.mode &&
234 outputState.dataspace == colorProfile.dataspace &&
235 outputState.renderIntent == colorProfile.renderIntent &&
236 outputState.targetDataspace == targetDataspace) {
Lloyd Piqueef958122019-02-05 18:00:12 -0800237 return;
238 }
239
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700240 outputState.colorMode = colorProfile.mode;
241 outputState.dataspace = colorProfile.dataspace;
242 outputState.renderIntent = colorProfile.renderIntent;
243 outputState.targetDataspace = targetDataspace;
Lloyd Pique32cbe282018-10-19 13:09:22 -0700244
Lloyd Pique6a3b4462019-03-07 20:58:12 -0800245 mRenderSurface->setBufferDataspace(colorProfile.dataspace);
Lloyd Pique31cb2942018-10-19 17:23:03 -0700246
Lloyd Pique32cbe282018-10-19 13:09:22 -0700247 ALOGV("Set active color mode: %s (%d), active render intent: %s (%d)",
Lloyd Pique6a3b4462019-03-07 20:58:12 -0800248 decodeColorMode(colorProfile.mode).c_str(), colorProfile.mode,
249 decodeRenderIntent(colorProfile.renderIntent).c_str(), colorProfile.renderIntent);
Lloyd Piqueef958122019-02-05 18:00:12 -0800250
251 dirtyEntireOutput();
Lloyd Pique32cbe282018-10-19 13:09:22 -0700252}
253
254void Output::dump(std::string& out) const {
255 using android::base::StringAppendF;
256
257 StringAppendF(&out, " Composition Output State: [\"%s\"]", mName.c_str());
258
259 out.append("\n ");
260
261 dumpBase(out);
262}
263
264void Output::dumpBase(std::string& out) const {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700265 dumpState(out);
Lloyd Pique31cb2942018-10-19 17:23:03 -0700266
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700267 if (mDisplayColorProfile) {
268 mDisplayColorProfile->dump(out);
269 } else {
270 out.append(" No display color profile!\n");
271 }
272
Lloyd Pique31cb2942018-10-19 17:23:03 -0700273 if (mRenderSurface) {
274 mRenderSurface->dump(out);
275 } else {
276 out.append(" No render surface!\n");
277 }
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800278
Lloyd Pique01c77c12019-04-17 12:48:32 -0700279 android::base::StringAppendF(&out, "\n %zu Layers\n", getOutputLayerCount());
280 for (const auto* outputLayer : getOutputLayersOrderedByZ()) {
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800281 if (!outputLayer) {
282 continue;
283 }
284 outputLayer->dump(out);
285 }
Lloyd Pique31cb2942018-10-19 17:23:03 -0700286}
287
Dan Stoza269dc4d2021-01-15 15:07:43 -0800288void Output::dumpPlannerInfo(const Vector<String16>& args, std::string& out) const {
289 if (!mPlanner) {
290 base::StringAppendF(&out, "Planner is disabled\n");
291 return;
292 }
293 base::StringAppendF(&out, "Planner info for display [%s]\n", mName.c_str());
294 mPlanner->dump(args, out);
295}
296
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700297compositionengine::DisplayColorProfile* Output::getDisplayColorProfile() const {
298 return mDisplayColorProfile.get();
299}
300
301void Output::setDisplayColorProfile(std::unique_ptr<compositionengine::DisplayColorProfile> mode) {
302 mDisplayColorProfile = std::move(mode);
303}
304
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800305const Output::ReleasedLayers& Output::getReleasedLayersForTest() const {
306 return mReleasedLayers;
307}
308
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700309void Output::setDisplayColorProfileForTest(
310 std::unique_ptr<compositionengine::DisplayColorProfile> mode) {
311 mDisplayColorProfile = std::move(mode);
312}
313
Lloyd Pique31cb2942018-10-19 17:23:03 -0700314compositionengine::RenderSurface* Output::getRenderSurface() const {
315 return mRenderSurface.get();
316}
317
318void Output::setRenderSurface(std::unique_ptr<compositionengine::RenderSurface> surface) {
319 mRenderSurface = std::move(surface);
Marin Shalamanovb15d2272020-09-17 21:41:52 +0200320 editState().framebufferSpace.bounds = Rect(mRenderSurface->getSize());
Lloyd Pique31cb2942018-10-19 17:23:03 -0700321 dirtyEntireOutput();
322}
323
Vishnu Nair9b079a22020-01-21 14:36:08 -0800324void Output::cacheClientCompositionRequests(uint32_t cacheSize) {
325 if (cacheSize == 0) {
326 mClientCompositionRequestCache.reset();
327 } else {
328 mClientCompositionRequestCache = std::make_unique<ClientCompositionRequestCache>(cacheSize);
329 }
330};
331
Lloyd Pique31cb2942018-10-19 17:23:03 -0700332void Output::setRenderSurfaceForTest(std::unique_ptr<compositionengine::RenderSurface> surface) {
333 mRenderSurface = std::move(surface);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700334}
335
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000336Region Output::getDirtyRegion(bool repaintEverything) const {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700337 const auto& outputState = getState();
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200338 Region dirty(outputState.layerStackSpace.content);
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000339 if (!repaintEverything) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700340 dirty.andSelf(outputState.dirtyRegion);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700341 }
342 return dirty;
343}
344
Lloyd Piquec6687342019-03-07 21:34:57 -0800345bool Output::belongsInOutput(std::optional<uint32_t> layerStackId, bool internalOnly) const {
Lloyd Piqueef36b002019-01-23 17:52:04 -0800346 // The layerStackId's must match, and also the layer must not be internal
347 // only when not on an internal output.
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700348 const auto& outputState = getState();
349 return layerStackId && (*layerStackId == outputState.layerStackId) &&
350 (!internalOnly || outputState.layerStackInternal);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700351}
352
Lloyd Piquede196652020-01-22 17:29:58 -0800353bool Output::belongsInOutput(const sp<compositionengine::LayerFE>& layerFE) const {
354 const auto* layerFEState = layerFE->getCompositionState();
355 return layerFEState && belongsInOutput(layerFEState->layerStackId, layerFEState->internalOnly);
Lloyd Pique66c20c42019-03-07 21:44:02 -0800356}
357
Lloyd Piquedf336d92019-03-07 21:38:42 -0800358std::unique_ptr<compositionengine::OutputLayer> Output::createOutputLayer(
Lloyd Piquede196652020-01-22 17:29:58 -0800359 const sp<LayerFE>& layerFE) const {
360 return impl::createOutputLayer(*this, layerFE);
Lloyd Piquecc01a452018-12-04 17:24:00 -0800361}
362
Lloyd Piquede196652020-01-22 17:29:58 -0800363compositionengine::OutputLayer* Output::getOutputLayerForLayer(const sp<LayerFE>& layerFE) const {
364 auto index = findCurrentOutputLayerForLayer(layerFE);
Lloyd Pique01c77c12019-04-17 12:48:32 -0700365 return index ? getOutputLayerOrderedByZByIndex(*index) : nullptr;
Lloyd Piquecc01a452018-12-04 17:24:00 -0800366}
367
Lloyd Pique01c77c12019-04-17 12:48:32 -0700368std::optional<size_t> Output::findCurrentOutputLayerForLayer(
Lloyd Piquede196652020-01-22 17:29:58 -0800369 const sp<compositionengine::LayerFE>& layer) const {
Lloyd Pique01c77c12019-04-17 12:48:32 -0700370 for (size_t i = 0; i < getOutputLayerCount(); i++) {
371 auto outputLayer = getOutputLayerOrderedByZByIndex(i);
Lloyd Piquede196652020-01-22 17:29:58 -0800372 if (outputLayer && &outputLayer->getLayerFE() == layer.get()) {
Lloyd Pique01c77c12019-04-17 12:48:32 -0700373 return i;
374 }
375 }
376 return std::nullopt;
Lloyd Piquecc01a452018-12-04 17:24:00 -0800377}
378
Lloyd Piquec7ef21b2019-01-29 18:43:00 -0800379void Output::setReleasedLayers(Output::ReleasedLayers&& layers) {
380 mReleasedLayers = std::move(layers);
381}
382
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800383void Output::prepare(const compositionengine::CompositionRefreshArgs& refreshArgs,
384 LayerFESet& geomSnapshots) {
385 ATRACE_CALL();
386 ALOGV(__FUNCTION__);
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800387
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800388 rebuildLayerStacks(refreshArgs, geomSnapshots);
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800389}
390
Lloyd Piqued7b429f2019-03-07 21:11:02 -0800391void Output::present(const compositionengine::CompositionRefreshArgs& refreshArgs) {
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800392 ATRACE_CALL();
393 ALOGV(__FUNCTION__);
394
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800395 updateColorProfile(refreshArgs);
Dan Stoza269dc4d2021-01-15 15:07:43 -0800396 updateCompositionState(refreshArgs);
397 planComposition();
398 writeCompositionState(refreshArgs);
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800399 setColorTransform(refreshArgs);
Lloyd Piqued7b429f2019-03-07 21:11:02 -0800400 beginFrame();
401 prepareFrame();
402 devOptRepaintFlash(refreshArgs);
403 finishFrame(refreshArgs);
404 postFramebuffer();
405}
406
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800407void Output::rebuildLayerStacks(const compositionengine::CompositionRefreshArgs& refreshArgs,
408 LayerFESet& layerFESet) {
409 ATRACE_CALL();
410 ALOGV(__FUNCTION__);
411
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700412 auto& outputState = editState();
413
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800414 // Do nothing if this output is not enabled or there is no need to perform this update
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700415 if (!outputState.isEnabled || CC_LIKELY(!refreshArgs.updatingOutputGeometryThisFrame)) {
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800416 return;
417 }
418
419 // Process the layers to determine visibility and coverage
420 compositionengine::Output::CoverageState coverage{layerFESet};
421 collectVisibleLayers(refreshArgs, coverage);
422
423 // Compute the resulting coverage for this output, and store it for later
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700424 const ui::Transform& tr = outputState.transform;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200425 Region undefinedRegion{outputState.displaySpace.bounds};
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800426 undefinedRegion.subtractSelf(tr.transform(coverage.aboveOpaqueLayers));
427
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700428 outputState.undefinedRegion = undefinedRegion;
429 outputState.dirtyRegion.orSelf(coverage.dirtyRegion);
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800430}
431
432void Output::collectVisibleLayers(const compositionengine::CompositionRefreshArgs& refreshArgs,
433 compositionengine::Output::CoverageState& coverage) {
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800434 // Evaluate the layers from front to back to determine what is visible. This
435 // also incrementally calculates the coverage information for each layer as
436 // well as the entire output.
Lloyd Piquede196652020-01-22 17:29:58 -0800437 for (auto layer : reversed(refreshArgs.layers)) {
Lloyd Pique01c77c12019-04-17 12:48:32 -0700438 // Incrementally process the coverage for each layer
439 ensureOutputLayerIfVisible(layer, coverage);
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800440
441 // TODO(b/121291683): Stop early if the output is completely covered and
442 // no more layers could even be visible underneath the ones on top.
443 }
444
Lloyd Pique01c77c12019-04-17 12:48:32 -0700445 setReleasedLayers(refreshArgs);
446
447 finalizePendingOutputLayers();
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800448
449 // Generate a simple Z-order values to each visible output layer
450 uint32_t zOrder = 0;
Lloyd Pique01c77c12019-04-17 12:48:32 -0700451 for (auto* outputLayer : getOutputLayersOrderedByZ()) {
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800452 outputLayer->editState().z = zOrder++;
453 }
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800454}
455
Lloyd Piquede196652020-01-22 17:29:58 -0800456void Output::ensureOutputLayerIfVisible(sp<compositionengine::LayerFE>& layerFE,
Lloyd Pique01c77c12019-04-17 12:48:32 -0700457 compositionengine::Output::CoverageState& coverage) {
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800458 // Ensure we have a snapshot of the basic geometry layer state. Limit the
459 // snapshots to once per frame for each candidate layer, as layers may
460 // appear on multiple outputs.
461 if (!coverage.latchedLayers.count(layerFE)) {
462 coverage.latchedLayers.insert(layerFE);
Lloyd Piquede196652020-01-22 17:29:58 -0800463 layerFE->prepareCompositionState(compositionengine::LayerFE::StateSubset::BasicGeometry);
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800464 }
465
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800466 // Only consider the layers on the given layer stack
Lloyd Piquede196652020-01-22 17:29:58 -0800467 if (!belongsInOutput(layerFE)) {
468 return;
469 }
470
471 // Obtain a read-only pointer to the front-end layer state
472 const auto* layerFEState = layerFE->getCompositionState();
473 if (CC_UNLIKELY(!layerFEState)) {
474 return;
475 }
476
477 // handle hidden surfaces by setting the visible region to empty
478 if (CC_UNLIKELY(!layerFEState->isVisible)) {
Lloyd Pique01c77c12019-04-17 12:48:32 -0700479 return;
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800480 }
481
482 /*
483 * opaqueRegion: area of a surface that is fully opaque.
484 */
485 Region opaqueRegion;
486
487 /*
488 * visibleRegion: area of a surface that is visible on screen and not fully
489 * transparent. This is essentially the layer's footprint minus the opaque
490 * regions above it. Areas covered by a translucent surface are considered
491 * visible.
492 */
493 Region visibleRegion;
494
495 /*
496 * coveredRegion: area of a surface that is covered by all visible regions
497 * above it (which includes the translucent areas).
498 */
499 Region coveredRegion;
500
501 /*
502 * transparentRegion: area of a surface that is hinted to be completely
503 * transparent. This is only used to tell when the layer has no visible non-
504 * transparent regions and can be removed from the layer list. It does not
505 * affect the visibleRegion of this layer or any layers beneath it. The hint
506 * may not be correct if apps don't respect the SurfaceView restrictions
507 * (which, sadly, some don't).
508 */
509 Region transparentRegion;
510
Vishnu Naira483b4a2019-12-12 15:07:52 -0800511 /*
512 * shadowRegion: Region cast by the layer's shadow.
513 */
514 Region shadowRegion;
515
Lloyd Piquede196652020-01-22 17:29:58 -0800516 const ui::Transform& tr = layerFEState->geomLayerTransform;
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800517
518 // Get the visible region
519 // TODO(b/121291683): Is it worth creating helper methods on LayerFEState
520 // for computations like this?
Lloyd Piquede196652020-01-22 17:29:58 -0800521 const Rect visibleRect(tr.transform(layerFEState->geomLayerBounds));
Vishnu Naira483b4a2019-12-12 15:07:52 -0800522 visibleRegion.set(visibleRect);
523
Lloyd Piquede196652020-01-22 17:29:58 -0800524 if (layerFEState->shadowRadius > 0.0f) {
Vishnu Naira483b4a2019-12-12 15:07:52 -0800525 // if the layer casts a shadow, offset the layers visible region and
526 // calculate the shadow region.
Lloyd Piquede196652020-01-22 17:29:58 -0800527 const auto inset = static_cast<int32_t>(ceilf(layerFEState->shadowRadius) * -1.0f);
Vishnu Naira483b4a2019-12-12 15:07:52 -0800528 Rect visibleRectWithShadows(visibleRect);
529 visibleRectWithShadows.inset(inset, inset, inset, inset);
530 visibleRegion.set(visibleRectWithShadows);
531 shadowRegion = visibleRegion.subtract(visibleRect);
532 }
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800533
534 if (visibleRegion.isEmpty()) {
Lloyd Pique01c77c12019-04-17 12:48:32 -0700535 return;
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800536 }
537
538 // Remove the transparent area from the visible region
Lloyd Piquede196652020-01-22 17:29:58 -0800539 if (!layerFEState->isOpaque) {
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800540 if (tr.preserveRects()) {
541 // transform the transparent region
Lloyd Piquede196652020-01-22 17:29:58 -0800542 transparentRegion = tr.transform(layerFEState->transparentRegionHint);
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800543 } else {
544 // transformation too complex, can't do the
545 // transparent region optimization.
546 transparentRegion.clear();
547 }
548 }
549
550 // compute the opaque region
Lloyd Pique0a456232020-01-16 17:51:13 -0800551 const auto layerOrientation = tr.getOrientation();
Lloyd Piquede196652020-01-22 17:29:58 -0800552 if (layerFEState->isOpaque && ((layerOrientation & ui::Transform::ROT_INVALID) == 0)) {
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800553 // If we one of the simple category of transforms (0/90/180/270 rotation
554 // + any flip), then the opaque region is the layer's footprint.
555 // Otherwise we don't try and compute the opaque region since there may
556 // be errors at the edges, and we treat the entire layer as
557 // translucent.
Vishnu Naira483b4a2019-12-12 15:07:52 -0800558 opaqueRegion.set(visibleRect);
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800559 }
560
561 // Clip the covered region to the visible region
562 coveredRegion = coverage.aboveCoveredLayers.intersect(visibleRegion);
563
564 // Update accumAboveCoveredLayers for next (lower) layer
565 coverage.aboveCoveredLayers.orSelf(visibleRegion);
566
567 // subtract the opaque region covered by the layers above us
568 visibleRegion.subtractSelf(coverage.aboveOpaqueLayers);
569
570 if (visibleRegion.isEmpty()) {
Lloyd Pique01c77c12019-04-17 12:48:32 -0700571 return;
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800572 }
573
574 // Get coverage information for the layer as previously displayed,
575 // also taking over ownership from mOutputLayersorderedByZ.
Lloyd Piquede196652020-01-22 17:29:58 -0800576 auto prevOutputLayerIndex = findCurrentOutputLayerForLayer(layerFE);
Lloyd Pique01c77c12019-04-17 12:48:32 -0700577 auto prevOutputLayer =
578 prevOutputLayerIndex ? getOutputLayerOrderedByZByIndex(*prevOutputLayerIndex) : nullptr;
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800579
580 // Get coverage information for the layer as previously displayed
581 // TODO(b/121291683): Define kEmptyRegion as a constant in Region.h
582 const Region kEmptyRegion;
583 const Region& oldVisibleRegion =
584 prevOutputLayer ? prevOutputLayer->getState().visibleRegion : kEmptyRegion;
585 const Region& oldCoveredRegion =
586 prevOutputLayer ? prevOutputLayer->getState().coveredRegion : kEmptyRegion;
587
588 // compute this layer's dirty region
589 Region dirty;
Lloyd Piquede196652020-01-22 17:29:58 -0800590 if (layerFEState->contentDirty) {
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800591 // we need to invalidate the whole region
592 dirty = visibleRegion;
593 // as well, as the old visible region
594 dirty.orSelf(oldVisibleRegion);
595 } else {
596 /* compute the exposed region:
597 * the exposed region consists of two components:
598 * 1) what's VISIBLE now and was COVERED before
599 * 2) what's EXPOSED now less what was EXPOSED before
600 *
601 * note that (1) is conservative, we start with the whole visible region
602 * but only keep what used to be covered by something -- which mean it
603 * may have been exposed.
604 *
605 * (2) handles areas that were not covered by anything but got exposed
606 * because of a resize.
607 *
608 */
609 const Region newExposed = visibleRegion - coveredRegion;
610 const Region oldExposed = oldVisibleRegion - oldCoveredRegion;
611 dirty = (visibleRegion & oldCoveredRegion) | (newExposed - oldExposed);
612 }
613 dirty.subtractSelf(coverage.aboveOpaqueLayers);
614
615 // accumulate to the screen dirty region
616 coverage.dirtyRegion.orSelf(dirty);
617
618 // Update accumAboveOpaqueLayers for next (lower) layer
619 coverage.aboveOpaqueLayers.orSelf(opaqueRegion);
620
621 // Compute the visible non-transparent region
622 Region visibleNonTransparentRegion = visibleRegion.subtract(transparentRegion);
623
Vishnu Naira483b4a2019-12-12 15:07:52 -0800624 // Perform the final check to see if this layer is visible on this output
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800625 // TODO(b/121291683): Why does this not use visibleRegion? (see outputSpaceVisibleRegion below)
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700626 const auto& outputState = getState();
627 Region drawRegion(outputState.transform.transform(visibleNonTransparentRegion));
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200628 drawRegion.andSelf(outputState.displaySpace.bounds);
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800629 if (drawRegion.isEmpty()) {
Lloyd Pique01c77c12019-04-17 12:48:32 -0700630 return;
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800631 }
632
Vishnu Naira483b4a2019-12-12 15:07:52 -0800633 Region visibleNonShadowRegion = visibleRegion.subtract(shadowRegion);
634
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800635 // The layer is visible. Either reuse the existing outputLayer if we have
636 // one, or create a new one if we do not.
Lloyd Piquede196652020-01-22 17:29:58 -0800637 auto result = ensureOutputLayer(prevOutputLayerIndex, layerFE);
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800638
639 // Store the layer coverage information into the layer state as some of it
640 // is useful later.
641 auto& outputLayerState = result->editState();
642 outputLayerState.visibleRegion = visibleRegion;
643 outputLayerState.visibleNonTransparentRegion = visibleNonTransparentRegion;
644 outputLayerState.coveredRegion = coveredRegion;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200645 outputLayerState.outputSpaceVisibleRegion = outputState.transform.transform(
646 visibleNonShadowRegion.intersect(outputState.layerStackSpace.content));
Vishnu Naira483b4a2019-12-12 15:07:52 -0800647 outputLayerState.shadowRegion = shadowRegion;
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800648}
649
650void Output::setReleasedLayers(const compositionengine::CompositionRefreshArgs&) {
651 // The base class does nothing with this call.
652}
653
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800654void Output::updateLayerStateFromFE(const CompositionRefreshArgs& args) const {
Lloyd Pique01c77c12019-04-17 12:48:32 -0700655 for (auto* layer : getOutputLayersOrderedByZ()) {
Lloyd Piquede196652020-01-22 17:29:58 -0800656 layer->getLayerFE().prepareCompositionState(
657 args.updatingGeometryThisFrame ? LayerFE::StateSubset::GeometryAndContent
658 : LayerFE::StateSubset::Content);
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800659 }
660}
661
Dan Stoza269dc4d2021-01-15 15:07:43 -0800662void Output::updateCompositionState(const compositionengine::CompositionRefreshArgs& refreshArgs) {
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800663 ATRACE_CALL();
664 ALOGV(__FUNCTION__);
665
Alec Mourif9a2a2c2019-11-12 12:46:02 -0800666 if (!getState().isEnabled) {
667 return;
668 }
669
Lucas Dupin19c8f0e2019-11-25 17:55:44 -0800670 mLayerRequestingBackgroundBlur = findLayerRequestingBackgroundComposition();
671 bool forceClientComposition = mLayerRequestingBackgroundBlur != nullptr;
672
Lloyd Pique01c77c12019-04-17 12:48:32 -0700673 for (auto* layer : getOutputLayersOrderedByZ()) {
Lloyd Pique7a234912019-10-03 11:54:27 -0700674 layer->updateCompositionState(refreshArgs.updatingGeometryThisFrame,
Lucas Dupin19c8f0e2019-11-25 17:55:44 -0800675 refreshArgs.devOptForceClientComposition ||
Snild Dolkow9e217d62020-04-22 15:53:42 +0200676 forceClientComposition,
677 refreshArgs.internalDisplayRotationFlags);
Lucas Dupin19c8f0e2019-11-25 17:55:44 -0800678
679 if (mLayerRequestingBackgroundBlur == layer) {
680 forceClientComposition = false;
681 }
Dan Stoza269dc4d2021-01-15 15:07:43 -0800682 }
683}
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800684
Dan Stoza269dc4d2021-01-15 15:07:43 -0800685void Output::planComposition() {
686 if (!mPlanner || !getState().isEnabled) {
687 return;
688 }
689
690 ATRACE_CALL();
691 ALOGV(__FUNCTION__);
692
693 mPlanner->plan(getOutputLayersOrderedByZ());
694}
695
696void Output::writeCompositionState(const compositionengine::CompositionRefreshArgs& refreshArgs) {
697 ATRACE_CALL();
698 ALOGV(__FUNCTION__);
699
700 if (!getState().isEnabled) {
701 return;
702 }
703
704 for (auto* layer : getOutputLayersOrderedByZ()) {
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800705 layer->writeStateToHWC(refreshArgs.updatingGeometryThisFrame);
706 }
707}
708
Lucas Dupin19c8f0e2019-11-25 17:55:44 -0800709compositionengine::OutputLayer* Output::findLayerRequestingBackgroundComposition() const {
710 compositionengine::OutputLayer* layerRequestingBgComposition = nullptr;
711 for (auto* layer : getOutputLayersOrderedByZ()) {
Galia Peycheva66eaf4a2020-11-09 13:17:57 +0100712 auto* compState = layer->getLayerFE().getCompositionState();
713
714 // If any layer has a sideband stream, we will disable blurs. In that case, we don't
715 // want to force client composition because of the blur.
716 if (compState->sidebandStream != nullptr) {
717 return nullptr;
718 }
719 if (compState->backgroundBlurRadius > 0 || compState->blurRegions.size() > 0) {
Lucas Dupin19c8f0e2019-11-25 17:55:44 -0800720 layerRequestingBgComposition = layer;
721 }
722 }
723 return layerRequestingBgComposition;
724}
725
Lloyd Pique6a3b4462019-03-07 20:58:12 -0800726void Output::updateColorProfile(const compositionengine::CompositionRefreshArgs& refreshArgs) {
727 setColorProfile(pickColorProfile(refreshArgs));
728}
729
730// Returns a data space that fits all visible layers. The returned data space
731// can only be one of
732// - Dataspace::SRGB (use legacy dataspace and let HWC saturate when colors are enhanced)
733// - Dataspace::DISPLAY_P3
734// - Dataspace::DISPLAY_BT2020
735// The returned HDR data space is one of
736// - Dataspace::UNKNOWN
737// - Dataspace::BT2020_HLG
738// - Dataspace::BT2020_PQ
739ui::Dataspace Output::getBestDataspace(ui::Dataspace* outHdrDataSpace,
740 bool* outIsHdrClientComposition) const {
741 ui::Dataspace bestDataSpace = ui::Dataspace::V0_SRGB;
742 *outHdrDataSpace = ui::Dataspace::UNKNOWN;
743
Lloyd Pique01c77c12019-04-17 12:48:32 -0700744 for (const auto* layer : getOutputLayersOrderedByZ()) {
Lloyd Piquede196652020-01-22 17:29:58 -0800745 switch (layer->getLayerFE().getCompositionState()->dataspace) {
Lloyd Pique6a3b4462019-03-07 20:58:12 -0800746 case ui::Dataspace::V0_SCRGB:
747 case ui::Dataspace::V0_SCRGB_LINEAR:
748 case ui::Dataspace::BT2020:
749 case ui::Dataspace::BT2020_ITU:
750 case ui::Dataspace::BT2020_LINEAR:
751 case ui::Dataspace::DISPLAY_BT2020:
752 bestDataSpace = ui::Dataspace::DISPLAY_BT2020;
753 break;
754 case ui::Dataspace::DISPLAY_P3:
755 bestDataSpace = ui::Dataspace::DISPLAY_P3;
756 break;
757 case ui::Dataspace::BT2020_PQ:
758 case ui::Dataspace::BT2020_ITU_PQ:
759 bestDataSpace = ui::Dataspace::DISPLAY_P3;
760 *outHdrDataSpace = ui::Dataspace::BT2020_PQ;
Lloyd Piquede196652020-01-22 17:29:58 -0800761 *outIsHdrClientComposition =
762 layer->getLayerFE().getCompositionState()->forceClientComposition;
Lloyd Pique6a3b4462019-03-07 20:58:12 -0800763 break;
764 case ui::Dataspace::BT2020_HLG:
765 case ui::Dataspace::BT2020_ITU_HLG:
766 bestDataSpace = ui::Dataspace::DISPLAY_P3;
767 // When there's mixed PQ content and HLG content, we set the HDR
768 // data space to be BT2020_PQ and convert HLG to PQ.
769 if (*outHdrDataSpace == ui::Dataspace::UNKNOWN) {
770 *outHdrDataSpace = ui::Dataspace::BT2020_HLG;
771 }
772 break;
773 default:
774 break;
775 }
776 }
777
778 return bestDataSpace;
779}
780
781compositionengine::Output::ColorProfile Output::pickColorProfile(
782 const compositionengine::CompositionRefreshArgs& refreshArgs) const {
783 if (refreshArgs.outputColorSetting == OutputColorSetting::kUnmanaged) {
784 return ColorProfile{ui::ColorMode::NATIVE, ui::Dataspace::UNKNOWN,
785 ui::RenderIntent::COLORIMETRIC,
786 refreshArgs.colorSpaceAgnosticDataspace};
787 }
788
789 ui::Dataspace hdrDataSpace;
790 bool isHdrClientComposition = false;
791 ui::Dataspace bestDataSpace = getBestDataspace(&hdrDataSpace, &isHdrClientComposition);
792
793 switch (refreshArgs.forceOutputColorMode) {
794 case ui::ColorMode::SRGB:
795 bestDataSpace = ui::Dataspace::V0_SRGB;
796 break;
797 case ui::ColorMode::DISPLAY_P3:
798 bestDataSpace = ui::Dataspace::DISPLAY_P3;
799 break;
800 default:
801 break;
802 }
803
804 // respect hdrDataSpace only when there is no legacy HDR support
805 const bool isHdr = hdrDataSpace != ui::Dataspace::UNKNOWN &&
806 !mDisplayColorProfile->hasLegacyHdrSupport(hdrDataSpace) && !isHdrClientComposition;
807 if (isHdr) {
808 bestDataSpace = hdrDataSpace;
809 }
810
811 ui::RenderIntent intent;
812 switch (refreshArgs.outputColorSetting) {
813 case OutputColorSetting::kManaged:
814 case OutputColorSetting::kUnmanaged:
815 intent = isHdr ? ui::RenderIntent::TONE_MAP_COLORIMETRIC
816 : ui::RenderIntent::COLORIMETRIC;
817 break;
818 case OutputColorSetting::kEnhanced:
819 intent = isHdr ? ui::RenderIntent::TONE_MAP_ENHANCE : ui::RenderIntent::ENHANCE;
820 break;
821 default: // vendor display color setting
822 intent = static_cast<ui::RenderIntent>(refreshArgs.outputColorSetting);
823 break;
824 }
825
826 ui::ColorMode outMode;
827 ui::Dataspace outDataSpace;
828 ui::RenderIntent outRenderIntent;
829 mDisplayColorProfile->getBestColorMode(bestDataSpace, intent, &outDataSpace, &outMode,
830 &outRenderIntent);
831
832 return ColorProfile{outMode, outDataSpace, outRenderIntent,
833 refreshArgs.colorSpaceAgnosticDataspace};
834}
835
Lloyd Piqued0a92a02019-02-19 17:47:26 -0800836void Output::beginFrame() {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700837 auto& outputState = editState();
Lloyd Piqued0a92a02019-02-19 17:47:26 -0800838 const bool dirty = !getDirtyRegion(false).isEmpty();
Lloyd Pique01c77c12019-04-17 12:48:32 -0700839 const bool empty = getOutputLayerCount() == 0;
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700840 const bool wasEmpty = !outputState.lastCompositionHadVisibleLayers;
Lloyd Piqued0a92a02019-02-19 17:47:26 -0800841
842 // If nothing has changed (!dirty), don't recompose.
843 // If something changed, but we don't currently have any visible layers,
844 // and didn't when we last did a composition, then skip it this time.
845 // The second rule does two things:
846 // - When all layers are removed from a display, we'll emit one black
847 // frame, then nothing more until we get new layers.
848 // - When a display is created with a private layer stack, we won't
849 // emit any black frames until a layer is added to the layer stack.
850 const bool mustRecompose = dirty && !(empty && wasEmpty);
851
852 const char flagPrefix[] = {'-', '+'};
853 static_cast<void>(flagPrefix);
854 ALOGV_IF("%s: %s composition for %s (%cdirty %cempty %cwasEmpty)", __FUNCTION__,
855 mustRecompose ? "doing" : "skipping", getName().c_str(), flagPrefix[dirty],
856 flagPrefix[empty], flagPrefix[wasEmpty]);
857
858 mRenderSurface->beginFrame(mustRecompose);
859
860 if (mustRecompose) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700861 outputState.lastCompositionHadVisibleLayers = !empty;
Lloyd Piqued0a92a02019-02-19 17:47:26 -0800862 }
863}
864
Lloyd Pique66d68602019-02-13 14:23:31 -0800865void Output::prepareFrame() {
866 ATRACE_CALL();
867 ALOGV(__FUNCTION__);
868
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700869 const auto& outputState = getState();
870 if (!outputState.isEnabled) {
Lloyd Pique66d68602019-02-13 14:23:31 -0800871 return;
872 }
873
874 chooseCompositionStrategy();
875
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700876 mRenderSurface->prepareFrame(outputState.usesClientComposition,
877 outputState.usesDeviceComposition);
Lloyd Pique66d68602019-02-13 14:23:31 -0800878}
879
Lloyd Piquef8cf14d2019-02-28 16:03:12 -0800880void Output::devOptRepaintFlash(const compositionengine::CompositionRefreshArgs& refreshArgs) {
881 if (CC_LIKELY(!refreshArgs.devOptFlashDirtyRegionsDelay)) {
882 return;
883 }
884
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700885 if (getState().isEnabled) {
Lloyd Piquef8cf14d2019-02-28 16:03:12 -0800886 // transform the dirty region into this screen's coordinate space
887 const Region dirtyRegion = getDirtyRegion(refreshArgs.repaintEverything);
888 if (!dirtyRegion.isEmpty()) {
889 base::unique_fd readyFence;
890 // redraw the whole screen
Lucas Dupin2dd6f392020-02-18 17:43:36 -0800891 static_cast<void>(composeSurfaces(dirtyRegion, refreshArgs));
Lloyd Piquef8cf14d2019-02-28 16:03:12 -0800892
893 mRenderSurface->queueBuffer(std::move(readyFence));
894 }
895 }
896
897 postFramebuffer();
898
899 std::this_thread::sleep_for(*refreshArgs.devOptFlashDirtyRegionsDelay);
900
901 prepareFrame();
902}
903
Lucas Dupin2dd6f392020-02-18 17:43:36 -0800904void Output::finishFrame(const compositionengine::CompositionRefreshArgs& refreshArgs) {
Lloyd Piqued3d69882019-02-28 16:03:46 -0800905 ATRACE_CALL();
906 ALOGV(__FUNCTION__);
907
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700908 if (!getState().isEnabled) {
Lloyd Piqued3d69882019-02-28 16:03:46 -0800909 return;
910 }
911
912 // Repaint the framebuffer (if needed), getting the optional fence for when
913 // the composition completes.
Lucas Dupin2dd6f392020-02-18 17:43:36 -0800914 auto optReadyFence = composeSurfaces(Region::INVALID_REGION, refreshArgs);
Lloyd Piqued3d69882019-02-28 16:03:46 -0800915 if (!optReadyFence) {
916 return;
917 }
918
919 // swap buffers (presentation)
920 mRenderSurface->queueBuffer(std::move(*optReadyFence));
921}
922
Lucas Dupin2dd6f392020-02-18 17:43:36 -0800923std::optional<base::unique_fd> Output::composeSurfaces(
924 const Region& debugRegion, const compositionengine::CompositionRefreshArgs& refreshArgs) {
Lloyd Pique688abd42019-02-15 15:42:24 -0800925 ATRACE_CALL();
926 ALOGV(__FUNCTION__);
927
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700928 const auto& outputState = getState();
Vishnu Nair9b079a22020-01-21 14:36:08 -0800929 OutputCompositionState& outputCompositionState = editState();
Lloyd Pique688abd42019-02-15 15:42:24 -0800930 const TracedOrdinal<bool> hasClientComposition = {"hasClientComposition",
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700931 outputState.usesClientComposition};
Lloyd Piquee9eff972020-05-05 12:36:44 -0700932
933 auto& renderEngine = getCompositionEngine().getRenderEngine();
934 const bool supportsProtectedContent = renderEngine.supportsProtectedContent();
935
936 // If we the display is secure, protected content support is enabled, and at
937 // least one layer has protected content, we need to use a secure back
938 // buffer.
939 if (outputState.isSecure && supportsProtectedContent) {
940 auto layers = getOutputLayersOrderedByZ();
941 bool needsProtected = std::any_of(layers.begin(), layers.end(), [](auto* layer) {
942 return layer->getLayerFE().getCompositionState()->hasProtectedContent;
943 });
944 if (needsProtected != renderEngine.isProtected()) {
945 renderEngine.useProtectedContext(needsProtected);
946 }
947 if (needsProtected != mRenderSurface->isProtected() &&
948 needsProtected == renderEngine.isProtected()) {
949 mRenderSurface->setProtected(needsProtected);
950 }
Peiyong Lin09f910f2020-09-25 10:54:13 -0700951 } else if (!outputState.isSecure && renderEngine.isProtected()) {
952 renderEngine.useProtectedContext(false);
Lloyd Piquee9eff972020-05-05 12:36:44 -0700953 }
954
955 base::unique_fd fd;
956 sp<GraphicBuffer> buf;
957
958 // If we aren't doing client composition on this output, but do have a
959 // flipClientTarget request for this frame on this output, we still need to
960 // dequeue a buffer.
961 if (hasClientComposition || outputState.flipClientTarget) {
962 buf = mRenderSurface->dequeueBuffer(&fd);
963 if (buf == nullptr) {
964 ALOGW("Dequeuing buffer for display [%s] failed, bailing out of "
965 "client composition for this frame",
966 mName.c_str());
967 return {};
968 }
969 }
970
Lloyd Piqued3d69882019-02-28 16:03:46 -0800971 base::unique_fd readyFence;
Lloyd Pique688abd42019-02-15 15:42:24 -0800972 if (!hasClientComposition) {
Lloyd Piquea76ce462020-01-14 13:06:37 -0800973 setExpensiveRenderingExpected(false);
Lloyd Piqued3d69882019-02-28 16:03:46 -0800974 return readyFence;
Lloyd Pique688abd42019-02-15 15:42:24 -0800975 }
976
977 ALOGV("hasClientComposition");
978
Lloyd Pique688abd42019-02-15 15:42:24 -0800979 renderengine::DisplaySettings clientCompositionDisplay;
Marin Shalamanovb15d2272020-09-17 21:41:52 +0200980 clientCompositionDisplay.physicalDisplay = outputState.framebufferSpace.content;
Marin Shalamanov6ad317c2020-07-29 23:34:07 +0200981 clientCompositionDisplay.clip = outputState.layerStackSpace.content;
Marin Shalamanov68933fb2020-09-10 17:58:12 +0200982 clientCompositionDisplay.orientation =
983 ui::Transform::toRotationFlags(outputState.displaySpace.orientation);
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700984 clientCompositionDisplay.outputDataspace = mDisplayColorProfile->hasWideColorGamut()
985 ? outputState.dataspace
986 : ui::Dataspace::UNKNOWN;
Lloyd Pique688abd42019-02-15 15:42:24 -0800987 clientCompositionDisplay.maxLuminance =
988 mDisplayColorProfile->getHdrCapabilities().getDesiredMaxLuminance();
989
990 // Compute the global color transform matrix.
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700991 if (!outputState.usesDeviceComposition && !getSkipColorTransform()) {
992 clientCompositionDisplay.colorTransform = outputState.colorTransformMatrix;
Lloyd Pique688abd42019-02-15 15:42:24 -0800993 }
994
995 // Note: Updated by generateClientCompositionRequests
996 clientCompositionDisplay.clearRegion = Region::INVALID_REGION;
997
998 // Generate the client composition requests for the layers on this output.
Vishnu Nair9b079a22020-01-21 14:36:08 -0800999 std::vector<LayerFE::LayerSettings> clientCompositionLayers =
Lloyd Pique688abd42019-02-15 15:42:24 -08001000 generateClientCompositionRequests(supportsProtectedContent,
Vishnu Nair3a7346c2019-12-04 08:09:09 -08001001 clientCompositionDisplay.clearRegion,
1002 clientCompositionDisplay.outputDataspace);
Lloyd Pique688abd42019-02-15 15:42:24 -08001003 appendRegionFlashRequests(debugRegion, clientCompositionLayers);
1004
Vishnu Nair9b079a22020-01-21 14:36:08 -08001005 // Check if the client composition requests were rendered into the provided graphic buffer. If
1006 // so, we can reuse the buffer and avoid client composition.
1007 if (mClientCompositionRequestCache) {
1008 if (mClientCompositionRequestCache->exists(buf->getId(), clientCompositionDisplay,
1009 clientCompositionLayers)) {
1010 outputCompositionState.reusedClientComposition = true;
1011 setExpensiveRenderingExpected(false);
1012 return readyFence;
1013 }
1014 mClientCompositionRequestCache->add(buf->getId(), clientCompositionDisplay,
1015 clientCompositionLayers);
1016 }
1017
Lloyd Pique688abd42019-02-15 15:42:24 -08001018 // We boost GPU frequency here because there will be color spaces conversion
Lucas Dupin19c8f0e2019-11-25 17:55:44 -08001019 // or complex GPU shaders and it's expensive. We boost the GPU frequency so that
1020 // GPU composition can finish in time. We must reset GPU frequency afterwards,
1021 // because high frequency consumes extra battery.
Lucas Dupin2dd6f392020-02-18 17:43:36 -08001022 const bool expensiveBlurs =
1023 refreshArgs.blursAreExpensive && mLayerRequestingBackgroundBlur != nullptr;
Lloyd Pique688abd42019-02-15 15:42:24 -08001024 const bool expensiveRenderingExpected =
Lucas Dupin2dd6f392020-02-18 17:43:36 -08001025 clientCompositionDisplay.outputDataspace == ui::Dataspace::DISPLAY_P3 || expensiveBlurs;
Lloyd Pique688abd42019-02-15 15:42:24 -08001026 if (expensiveRenderingExpected) {
1027 setExpensiveRenderingExpected(true);
1028 }
1029
Vishnu Nair9b079a22020-01-21 14:36:08 -08001030 std::vector<const renderengine::LayerSettings*> clientCompositionLayerPointers;
1031 clientCompositionLayerPointers.reserve(clientCompositionLayers.size());
1032 std::transform(clientCompositionLayers.begin(), clientCompositionLayers.end(),
1033 std::back_inserter(clientCompositionLayerPointers),
1034 [](LayerFE::LayerSettings& settings) -> renderengine::LayerSettings* {
1035 return &settings;
1036 });
1037
Alec Mourie4034bb2019-11-19 12:45:54 -08001038 const nsecs_t renderEngineStart = systemTime();
Alec Mouri1684c702021-02-04 12:27:26 -08001039 // Only use the framebuffer cache when rendering to an internal display
1040 // TODO(b/173560331): This is only to help mitigate memory leaks from virtual displays because
1041 // right now we don't have a concrete eviction policy for output buffers: GLESRenderEngine
1042 // bounds its framebuffer cache but Skia RenderEngine has no current policy. The best fix is
1043 // probably to encapsulate the output buffer into a structure that dispatches resource cleanup
1044 // over to RenderEngine, in which case this flag can be removed from the drawLayers interface.
1045 const bool useFramebufferCache = outputState.layerStackInternal;
Vishnu Nair9b079a22020-01-21 14:36:08 -08001046 status_t status =
Ana Krulecfc874ae2020-02-22 15:39:32 -08001047 renderEngine.drawLayers(clientCompositionDisplay, clientCompositionLayerPointers, buf,
Alec Mouri1684c702021-02-04 12:27:26 -08001048 useFramebufferCache, std::move(fd), &readyFence);
Vishnu Nair9b079a22020-01-21 14:36:08 -08001049
1050 if (status != NO_ERROR && mClientCompositionRequestCache) {
1051 // If rendering was not successful, remove the request from the cache.
1052 mClientCompositionRequestCache->remove(buf->getId());
1053 }
1054
Alec Mourie4034bb2019-11-19 12:45:54 -08001055 auto& timeStats = getCompositionEngine().getTimeStats();
1056 if (readyFence.get() < 0) {
1057 timeStats.recordRenderEngineDuration(renderEngineStart, systemTime());
1058 } else {
1059 timeStats.recordRenderEngineDuration(renderEngineStart,
1060 std::make_shared<FenceTime>(
1061 new Fence(dup(readyFence.get()))));
1062 }
Lloyd Pique688abd42019-02-15 15:42:24 -08001063
Lloyd Piqued3d69882019-02-28 16:03:46 -08001064 return readyFence;
Lloyd Pique688abd42019-02-15 15:42:24 -08001065}
1066
Vishnu Nair9b079a22020-01-21 14:36:08 -08001067std::vector<LayerFE::LayerSettings> Output::generateClientCompositionRequests(
Vishnu Nair3a7346c2019-12-04 08:09:09 -08001068 bool supportsProtectedContent, Region& clearRegion, ui::Dataspace outputDataspace) {
Vishnu Nair9b079a22020-01-21 14:36:08 -08001069 std::vector<LayerFE::LayerSettings> clientCompositionLayers;
Lloyd Pique688abd42019-02-15 15:42:24 -08001070 ALOGV("Rendering client layers");
1071
Lloyd Piquea38ea7e2019-04-16 18:10:26 -07001072 const auto& outputState = getState();
Marin Shalamanov6ad317c2020-07-29 23:34:07 +02001073 const Region viewportRegion(outputState.layerStackSpace.content);
Lloyd Pique688abd42019-02-15 15:42:24 -08001074 bool firstLayer = true;
1075 // Used when a layer clears part of the buffer.
Peiyong Lind8460c82020-07-28 16:04:22 -07001076 Region stubRegion;
Lloyd Pique688abd42019-02-15 15:42:24 -08001077
Galia Peycheva66eaf4a2020-11-09 13:17:57 +01001078 bool disableBlurs = false;
1079
Lloyd Pique01c77c12019-04-17 12:48:32 -07001080 for (auto* layer : getOutputLayersOrderedByZ()) {
Lloyd Pique688abd42019-02-15 15:42:24 -08001081 const auto& layerState = layer->getState();
Lloyd Piquede196652020-01-22 17:29:58 -08001082 const auto* layerFEState = layer->getLayerFE().getCompositionState();
Lloyd Pique688abd42019-02-15 15:42:24 -08001083 auto& layerFE = layer->getLayerFE();
1084
Lloyd Piquea2468662019-03-07 21:31:06 -08001085 const Region clip(viewportRegion.intersect(layerState.visibleRegion));
Lloyd Pique688abd42019-02-15 15:42:24 -08001086 ALOGV("Layer: %s", layerFE.getDebugName());
1087 if (clip.isEmpty()) {
1088 ALOGV(" Skipping for empty clip");
1089 firstLayer = false;
1090 continue;
1091 }
1092
Galia Peycheva66eaf4a2020-11-09 13:17:57 +01001093 disableBlurs |= layerFEState->sidebandStream != nullptr;
1094
Vishnu Naira483b4a2019-12-12 15:07:52 -08001095 const bool clientComposition = layer->requiresClientComposition();
Lloyd Pique688abd42019-02-15 15:42:24 -08001096
1097 // We clear the client target for non-client composed layers if
1098 // requested by the HWC. We skip this if the layer is not an opaque
1099 // rectangle, as by definition the layer must blend with whatever is
1100 // underneath. We also skip the first layer as the buffer target is
1101 // guaranteed to start out cleared.
Vishnu Nairb87d94f2020-02-13 09:17:36 -08001102 const bool clearClientComposition =
Lloyd Piquede196652020-01-22 17:29:58 -08001103 layerState.clearClientTarget && layerFEState->isOpaque && !firstLayer;
Lloyd Pique688abd42019-02-15 15:42:24 -08001104
1105 ALOGV(" Composition type: client %d clear %d", clientComposition, clearClientComposition);
1106
Vishnu Nairb87d94f2020-02-13 09:17:36 -08001107 // If the layer casts a shadow but the content casting the shadow is occluded, skip
1108 // composing the non-shadow content and only draw the shadows.
1109 const bool realContentIsVisible = clientComposition &&
1110 !layerState.visibleRegion.subtract(layerState.shadowRegion).isEmpty();
1111
Lloyd Pique688abd42019-02-15 15:42:24 -08001112 if (clientComposition || clearClientComposition) {
Marin Shalamanov6ad317c2020-07-29 23:34:07 +02001113 compositionengine::LayerFE::ClientCompositionTargetSettings
1114 targetSettings{.clip = clip,
1115 .needsFiltering =
1116 layer->needsFiltering() || outputState.needsFiltering,
1117 .isSecure = outputState.isSecure,
1118 .supportsProtectedContent = supportsProtectedContent,
1119 .clearRegion = clientComposition ? clearRegion : stubRegion,
1120 .viewport = outputState.layerStackSpace.content,
1121 .dataspace = outputDataspace,
1122 .realContentIsVisible = realContentIsVisible,
Galia Peycheva66eaf4a2020-11-09 13:17:57 +01001123 .clearContent = !clientComposition,
1124 .disableBlurs = disableBlurs};
Vishnu Nairb87d94f2020-02-13 09:17:36 -08001125 std::vector<LayerFE::LayerSettings> results =
1126 layerFE.prepareClientCompositionList(targetSettings);
1127 if (realContentIsVisible && !results.empty()) {
1128 layer->editState().clientCompositionTimestamp = systemTime();
Lloyd Pique688abd42019-02-15 15:42:24 -08001129 }
Vishnu Nairb87d94f2020-02-13 09:17:36 -08001130
1131 clientCompositionLayers.insert(clientCompositionLayers.end(),
1132 std::make_move_iterator(results.begin()),
1133 std::make_move_iterator(results.end()));
1134 results.clear();
Lloyd Pique688abd42019-02-15 15:42:24 -08001135 }
1136
1137 firstLayer = false;
1138 }
1139
1140 return clientCompositionLayers;
1141}
1142
1143void Output::appendRegionFlashRequests(
Vishnu Nair9b079a22020-01-21 14:36:08 -08001144 const Region& flashRegion, std::vector<LayerFE::LayerSettings>& clientCompositionLayers) {
Lloyd Pique688abd42019-02-15 15:42:24 -08001145 if (flashRegion.isEmpty()) {
1146 return;
1147 }
1148
Vishnu Nair9b079a22020-01-21 14:36:08 -08001149 LayerFE::LayerSettings layerSettings;
Lloyd Pique688abd42019-02-15 15:42:24 -08001150 layerSettings.source.buffer.buffer = nullptr;
1151 layerSettings.source.solidColor = half3(1.0, 0.0, 1.0);
1152 layerSettings.alpha = half(1.0);
1153
1154 for (const auto& rect : flashRegion) {
1155 layerSettings.geometry.boundaries = rect.toFloatRect();
1156 clientCompositionLayers.push_back(layerSettings);
1157 }
1158}
1159
1160void Output::setExpensiveRenderingExpected(bool) {
1161 // The base class does nothing with this call.
1162}
1163
Lloyd Pique35fca9d2019-02-13 14:24:11 -08001164void Output::postFramebuffer() {
1165 ATRACE_CALL();
1166 ALOGV(__FUNCTION__);
1167
1168 if (!getState().isEnabled) {
1169 return;
1170 }
1171
Lloyd Piquea38ea7e2019-04-16 18:10:26 -07001172 auto& outputState = editState();
1173 outputState.dirtyRegion.clear();
Lloyd Piqued3d69882019-02-28 16:03:46 -08001174 mRenderSurface->flip();
1175
Lloyd Pique35fca9d2019-02-13 14:24:11 -08001176 auto frame = presentAndGetFrameFences();
1177
Lloyd Pique7d90ba52019-08-08 11:57:53 -07001178 mRenderSurface->onPresentDisplayCompleted();
1179
Lloyd Pique01c77c12019-04-17 12:48:32 -07001180 for (auto* layer : getOutputLayersOrderedByZ()) {
Lloyd Pique35fca9d2019-02-13 14:24:11 -08001181 // The layer buffer from the previous frame (if any) is released
1182 // by HWC only when the release fence from this frame (if any) is
1183 // signaled. Always get the release fence from HWC first.
1184 sp<Fence> releaseFence = Fence::NO_FENCE;
1185
1186 if (auto hwcLayer = layer->getHwcLayer()) {
1187 if (auto f = frame.layerFences.find(hwcLayer); f != frame.layerFences.end()) {
1188 releaseFence = f->second;
1189 }
1190 }
1191
1192 // If the layer was client composited in the previous frame, we
1193 // need to merge with the previous client target acquire fence.
1194 // Since we do not track that, always merge with the current
1195 // client target acquire fence when it is available, even though
1196 // this is suboptimal.
1197 // TODO(b/121291683): Track previous frame client target acquire fence.
Lloyd Piquea38ea7e2019-04-16 18:10:26 -07001198 if (outputState.usesClientComposition) {
Lloyd Pique35fca9d2019-02-13 14:24:11 -08001199 releaseFence =
1200 Fence::merge("LayerRelease", releaseFence, frame.clientTargetAcquireFence);
1201 }
1202
1203 layer->getLayerFE().onLayerDisplayed(releaseFence);
1204 }
1205
1206 // We've got a list of layers needing fences, that are disjoint with
Lloyd Pique01c77c12019-04-17 12:48:32 -07001207 // OutputLayersOrderedByZ. The best we can do is to
Lloyd Pique35fca9d2019-02-13 14:24:11 -08001208 // supply them with the present fence.
1209 for (auto& weakLayer : mReleasedLayers) {
1210 if (auto layer = weakLayer.promote(); layer != nullptr) {
1211 layer->onLayerDisplayed(frame.presentFence);
1212 }
1213 }
1214
1215 // Clear out the released layers now that we're done with them.
1216 mReleasedLayers.clear();
1217}
1218
Lloyd Pique32cbe282018-10-19 13:09:22 -07001219void Output::dirtyEntireOutput() {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -07001220 auto& outputState = editState();
Marin Shalamanov6ad317c2020-07-29 23:34:07 +02001221 outputState.dirtyRegion.set(outputState.displaySpace.bounds);
Lloyd Pique32cbe282018-10-19 13:09:22 -07001222}
1223
Lloyd Pique66d68602019-02-13 14:23:31 -08001224void Output::chooseCompositionStrategy() {
1225 // The base output implementation can only do client composition
Lloyd Piquea38ea7e2019-04-16 18:10:26 -07001226 auto& outputState = editState();
1227 outputState.usesClientComposition = true;
1228 outputState.usesDeviceComposition = false;
Vishnu Nair9b079a22020-01-21 14:36:08 -08001229 outputState.reusedClientComposition = false;
Lloyd Pique66d68602019-02-13 14:23:31 -08001230}
1231
Lloyd Pique688abd42019-02-15 15:42:24 -08001232bool Output::getSkipColorTransform() const {
1233 return true;
1234}
1235
Lloyd Pique35fca9d2019-02-13 14:24:11 -08001236compositionengine::Output::FrameFences Output::presentAndGetFrameFences() {
1237 compositionengine::Output::FrameFences result;
Lloyd Piquea38ea7e2019-04-16 18:10:26 -07001238 if (getState().usesClientComposition) {
Lloyd Pique35fca9d2019-02-13 14:24:11 -08001239 result.clientTargetAcquireFence = mRenderSurface->getClientTargetAcquireFence();
1240 }
1241 return result;
1242}
1243
Lloyd Piquefeb73d72018-12-04 17:23:44 -08001244} // namespace impl
1245} // namespace android::compositionengine