diff options
Diffstat (limited to 'services/surfaceflinger/CompositionEngine/src/Output.cpp')
-rw-r--r-- | services/surfaceflinger/CompositionEngine/src/Output.cpp | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp index 30fc56746d..1fde0925de 100644 --- a/services/surfaceflinger/CompositionEngine/src/Output.cpp +++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp @@ -591,8 +591,29 @@ void Output::ensureOutputLayerIfVisible(sp<compositionengine::LayerFE>& layerFE, // Remove the transparent area from the visible region if (!layerFEState->isOpaque) { if (tr.preserveRects()) { - // transform the transparent region - transparentRegion = tr.transform(layerFEState->transparentRegionHint); + // Clip the transparent region to geomLayerBounds first + // The transparent region may be influenced by applications, for + // instance, by overriding ViewGroup#gatherTransparentRegion with a + // custom view. Once the layer stack -> display mapping is known, we + // must guard against very wrong inputs to prevent underflow or + // overflow errors. We do this here by constraining the transparent + // region to be within the pre-transform layer bounds, since the + // layer bounds are expected to play nicely with the full + // transform. + const Region clippedTransparentRegionHint = + layerFEState->transparentRegionHint.intersect( + Rect(layerFEState->geomLayerBounds)); + + if (clippedTransparentRegionHint.isEmpty()) { + if (!layerFEState->transparentRegionHint.isEmpty()) { + ALOGD("Layer: %s had an out of bounds transparent region", + layerFE->getDebugName()); + layerFEState->transparentRegionHint.dump("transparentRegionHint"); + } + transparentRegion.clear(); + } else { + transparentRegion = tr.transform(clippedTransparentRegionHint); + } } else { // transformation too complex, can't do the // transparent region optimization. @@ -1021,17 +1042,17 @@ void Output::beginFrame() { // frame, then nothing more until we get new layers. // - When a display is created with a private layer stack, we won't // emit any black frames until a layer is added to the layer stack. - const bool mustRecompose = dirty && !(empty && wasEmpty); + mMustRecompose = dirty && !(empty && wasEmpty); const char flagPrefix[] = {'-', '+'}; static_cast<void>(flagPrefix); - ALOGV_IF("%s: %s composition for %s (%cdirty %cempty %cwasEmpty)", __FUNCTION__, - mustRecompose ? "doing" : "skipping", getName().c_str(), flagPrefix[dirty], - flagPrefix[empty], flagPrefix[wasEmpty]); + ALOGV("%s: %s composition for %s (%cdirty %cempty %cwasEmpty)", __func__, + mMustRecompose ? "doing" : "skipping", getName().c_str(), flagPrefix[dirty], + flagPrefix[empty], flagPrefix[wasEmpty]); - mRenderSurface->beginFrame(mustRecompose); + mRenderSurface->beginFrame(mMustRecompose); - if (mustRecompose) { + if (mMustRecompose) { outputState.lastCompositionHadVisibleLayers = !empty; } } @@ -1164,6 +1185,10 @@ void Output::finishFrame(const CompositionRefreshArgs& refreshArgs, GpuCompositi return; } + if (isPowerHintSessionEnabled()) { + // get fence end time to know when gpu is complete in display + setHintSessionGpuFence(std::make_unique<FenceTime>(new Fence(dup(optReadyFence->get())))); + } // swap buffers (presentation) mRenderSurface->queueBuffer(std::move(*optReadyFence)); } @@ -1293,7 +1318,8 @@ std::optional<base::unique_fd> Output::composeSurfaces( ATRACE_NAME("ClientCompositionCacheHit"); outputCompositionState.reusedClientComposition = true; setExpensiveRenderingExpected(false); - return base::unique_fd(); + // b/239944175 pass the fence associated with the buffer. + return base::unique_fd(std::move(fd)); } ATRACE_NAME("ClientCompositionCacheMiss"); mClientCompositionRequestCache->add(tex->getBuffer()->getId(), clientCompositionDisplay, @@ -1479,6 +1505,14 @@ void Output::setExpensiveRenderingExpected(bool) { // The base class does nothing with this call. } +void Output::setHintSessionGpuFence(std::unique_ptr<FenceTime>&&) { + // The base class does nothing with this call. +} + +bool Output::isPowerHintSessionEnabled() { + return false; +} + void Output::postFramebuffer() { ATRACE_CALL(); ALOGV(__FUNCTION__); @@ -1536,7 +1570,8 @@ void Output::postFramebuffer() { void Output::renderCachedSets(const CompositionRefreshArgs& refreshArgs) { if (mPlanner) { - mPlanner->renderCachedSets(getState(), refreshArgs.scheduledFrameTime); + mPlanner->renderCachedSets(getState(), refreshArgs.scheduledFrameTime, + getState().usesDeviceComposition || getSkipColorTransform()); } } @@ -1639,5 +1674,9 @@ void Output::getVisibleLayerInfo(std::vector<std::string> *layerName, } } +bool Output::mustRecompose() const { + return mMustRecompose; +} + } // namespace impl } // namespace android::compositionengine |