diff options
| -rw-r--r-- | services/surfaceflinger/Android.bp | 1 | ||||
| -rw-r--r-- | services/surfaceflinger/BufferQueueLayer.cpp | 1 | ||||
| -rw-r--r-- | services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFE.h | 15 | ||||
| -rw-r--r-- | services/surfaceflinger/CompositionEngine/include/compositionengine/mock/LayerFE.h | 3 | ||||
| -rw-r--r-- | services/surfaceflinger/Layer.cpp | 5 | ||||
| -rw-r--r-- | services/surfaceflinger/Layer.h | 17 | ||||
| -rw-r--r-- | services/surfaceflinger/LayerBE.cpp | 40 | ||||
| -rw-r--r-- | services/surfaceflinger/LayerBE.h | 63 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 34 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 5 |
10 files changed, 31 insertions, 153 deletions
diff --git a/services/surfaceflinger/Android.bp b/services/surfaceflinger/Android.bp index 3304fd14ab..9bf499b37d 100644 --- a/services/surfaceflinger/Android.bp +++ b/services/surfaceflinger/Android.bp @@ -134,7 +134,6 @@ filegroup { "EventLog/EventLog.cpp", "FrameTracker.cpp", "Layer.cpp", - "LayerBE.cpp", "LayerProtoHelper.cpp", "LayerRejecter.cpp", "LayerStats.cpp", diff --git a/services/surfaceflinger/BufferQueueLayer.cpp b/services/surfaceflinger/BufferQueueLayer.cpp index 96c49921dd..215dea1ee1 100644 --- a/services/surfaceflinger/BufferQueueLayer.cpp +++ b/services/surfaceflinger/BufferQueueLayer.cpp @@ -199,7 +199,6 @@ bool BufferQueueLayer::latchSidebandStream(bool& recomputeVisibleRegions) { bool sidebandStreamChanged = true; if (mSidebandStreamChanged.compare_exchange_strong(sidebandStreamChanged, false)) { // mSidebandStreamChanged was changed to false - // replicated in LayerBE until FE/BE is ready to be synchronized auto& layerCompositionState = getCompositionLayer()->editState().frontEnd; layerCompositionState.sidebandStream = mConsumer->getSidebandStream(); if (layerCompositionState.sidebandStream != nullptr) { diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFE.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFE.h index f9a36241c8..6cc87ba79f 100644 --- a/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFE.h +++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFE.h @@ -18,10 +18,19 @@ #include <utils/RefBase.h> -namespace android::compositionengine { +namespace android { + +class Fence; + +namespace compositionengine { // Defines the interface used by the CompositionEngine to make requests // of the front-end layer -class LayerFE : public virtual RefBase {}; +class LayerFE : public virtual RefBase { +public: + // Called after the layer is displayed to update the presentation fence + virtual void onLayerDisplayed(const sp<Fence>&) = 0; +}; -} // namespace android::compositionengine +} // namespace compositionengine +} // namespace android diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/LayerFE.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/LayerFE.h index 92e007081b..a0c2a63a73 100644 --- a/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/LayerFE.h +++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/LayerFE.h @@ -18,6 +18,7 @@ #include <compositionengine/LayerFE.h> #include <gmock/gmock.h> +#include <ui/Fence.h> namespace android::compositionengine::mock { @@ -27,6 +28,8 @@ class LayerFE : public compositionengine::LayerFE { public: LayerFE(); virtual ~LayerFE(); + + MOCK_METHOD1(onLayerDisplayed, void(const sp<Fence>&)); }; } // namespace android::compositionengine::mock diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index b6eef0b751..0ff7755c55 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -69,10 +69,7 @@ using base::StringAppendF; std::atomic<int32_t> Layer::sSequence{1}; Layer::Layer(const LayerCreationArgs& args) - : mFlinger(args.flinger), - mName(args.name), - mClientRef(args.client), - mBE{this, args.name.string()} { + : mFlinger(args.flinger), mName(args.name), mClientRef(args.client) { mCurrentCrop.makeInvalid(); uint32_t layerFlags = 0; diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index fcec2622c1..de73a4b223 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -45,7 +45,6 @@ #include "Client.h" #include "FrameTracker.h" -#include "LayerBE.h" #include "LayerVector.h" #include "MonitoredProducer.h" #include "SurfaceFlinger.h" @@ -67,7 +66,6 @@ class DisplayDevice; class GraphicBuffer; class SurfaceFlinger; class LayerDebugInfo; -class LayerBE; namespace compositionengine { class Layer; @@ -97,9 +95,6 @@ class Layer : public virtual compositionengine::LayerFE { static std::atomic<int32_t> sSequence; public: - friend class LayerBE; - LayerBE& getBE() { return mBE; } - LayerBE& getBE() const { return mBE; } mutable bool contentDirty{false}; // regions below are in window-manager space Region visibleRegion; @@ -440,6 +435,11 @@ protected: renderengine::LayerSettings& layer) = 0; public: + /* + * compositionengine::LayerFE overrides + */ + void onLayerDisplayed(const sp<Fence>& releaseFence) override; + virtual void setDefaultBufferSize(uint32_t /*w*/, uint32_t /*h*/) {} virtual bool isHdrY410() const { return false; } @@ -460,11 +460,6 @@ public: bool getClearClientTarget(const sp<const DisplayDevice>& display) const; void updateCursorPosition(const sp<const DisplayDevice>& display); - /* - * called after page-flip - */ - virtual void onLayerDisplayed(const sp<Fence>& releaseFence); - virtual bool shouldPresentNow(nsecs_t /*expectedPresentTime*/) const { return false; } virtual void setTransformHint(uint32_t /*orientation*/) const { } @@ -860,8 +855,6 @@ protected: wp<Layer> mCurrentParent; wp<Layer> mDrawingParent; - mutable LayerBE mBE; - // Can only be accessed with the SF state lock held. bool mLayerDetached{false}; // Can only be accessed with the SF state lock held. diff --git a/services/surfaceflinger/LayerBE.cpp b/services/surfaceflinger/LayerBE.cpp deleted file mode 100644 index 9f634408c7..0000000000 --- a/services/surfaceflinger/LayerBE.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_NDEBUG 0 -#undef LOG_TAG -#define LOG_TAG "LayerBE" -#define ATRACE_TAG ATRACE_TAG_GRAPHICS - -#include "Layer.h" - -namespace android { - -LayerBE::LayerBE(Layer* layer, std::string layerName) : mLayer(layer) { - compositionInfo.layer = std::make_shared<LayerBE>(*this); - compositionInfo.layerName = layerName; -} - -LayerBE::LayerBE(const LayerBE& layer) : mLayer(layer.mLayer) { - compositionInfo.layer = layer.compositionInfo.layer; - compositionInfo.layerName = layer.mLayer->getName().string(); -} - -void LayerBE::onLayerDisplayed(const sp<Fence>& releaseFence) { - mLayer->onLayerDisplayed(releaseFence); -} - -}; // namespace android diff --git a/services/surfaceflinger/LayerBE.h b/services/surfaceflinger/LayerBE.h deleted file mode 100644 index 51f7857356..0000000000 --- a/services/surfaceflinger/LayerBE.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include <stdint.h> -#include <string.h> - -#include <ui/Fence.h> -#include <utils/StrongPointer.h> - -#include "DisplayHardware/DisplayIdentification.h" - -namespace android { - -class LayerBE; - -struct CompositionInfo { - std::string layerName; - std::shared_ptr<LayerBE> layer; - struct { - DisplayId displayId; - } hwc; -}; - -class LayerBE { -public: - friend class Layer; - friend class BufferLayer; - friend class BufferQueueLayer; - friend class BufferStateLayer; - friend class ColorLayer; - friend class SurfaceFlinger; - - // For unit tests - friend class TestableSurfaceFlinger; - - LayerBE(Layer* layer, std::string layerName); - explicit LayerBE(const LayerBE& layer); - - void onLayerDisplayed(const sp<Fence>& releaseFence); - - Layer*const mLayer; - -private: - CompositionInfo compositionInfo; -}; - -}; // namespace android - diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index daa9ff9047..75e84e6488 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1721,8 +1721,6 @@ void SurfaceFlinger::handleMessageRefresh() { mVsyncModulator.onRefreshed(mHadClientComposition); - getBE().mEndOfFrameCompositionInfo = std::move(getBE().mCompositionInfo); - mLayersWithQueuedFrames.clear(); } @@ -1835,12 +1833,9 @@ void SurfaceFlinger::calculateWorkingSet() { for (const auto& [token, displayDevice] : mDisplays) { auto display = displayDevice->getCompositionDisplay(); for (auto& layer : displayDevice->getVisibleLayersSortedByZ()) { - const auto displayId = display->getId(); auto& layerState = layer->getCompositionLayer()->editState().frontEnd; layerState.compositionType = static_cast<Hwc2::IComposerClient::Composition>( layer->getCompositionType(displayDevice)); - layer->getBE().compositionInfo.hwc.displayId = *displayId; - getBE().mCompositionInfo[token].push_back(layer->getBE().compositionInfo); } } } @@ -2215,17 +2210,6 @@ void SurfaceFlinger::rebuildLayerStacks() { ATRACE_CALL(); ALOGV("rebuildLayerStacks"); - // We need to clear these out now as these may be holding on to a - // HWC2::Layer reference at the same time as the LayerBE::HWCInfo structure - // also holds a reference. When the set of visible layers is recomputed, - // some layers may be destroyed if the only thing keeping them alive was - // that list of visible layers associated with each display. The layer - // destruction code asserts that the HWC2::Layer is properly destroyed, but - // that doesn't happen if SurfaceFlingerBE::mCompositionInfo keeps it alive. - for (const auto& [token, display] : mDisplays) { - getBE().mCompositionInfo[token].clear(); - } - // rebuild the visible layer list per screen if (CC_UNLIKELY(mVisibleRegionsDirty)) { ATRACE_NAME("rebuildLayerStacks VR Dirty"); @@ -2499,16 +2483,19 @@ void SurfaceFlinger::postFramebuffer(const sp<DisplayDevice>& displayDevice) { getHwComposer().presentAndGetReleaseFences(*displayId); } display->getRenderSurface()->onPresentDisplayCompleted(); - for (auto& layer : displayDevice->getVisibleLayersSortedByZ()) { + for (auto& layer : display->getOutputLayersOrderedByZ()) { sp<Fence> releaseFence = Fence::NO_FENCE; + bool usedClientComposition = true; // The layer buffer from the previous frame (if any) is released // by HWC only when the release fence from this frame (if any) is // signaled. Always get the release fence from HWC first. - if (displayId && layer->hasHwcLayer(displayDevice)) { + if (layer->getState().hwc) { + const auto& hwcState = *layer->getState().hwc; releaseFence = - getHwComposer().getLayerReleaseFence(*displayId, - layer->getHwcLayer(displayDevice)); + getHwComposer().getLayerReleaseFence(*displayId, hwcState.hwcLayer.get()); + usedClientComposition = + hwcState.hwcCompositionType == Hwc2::IComposerClient::Composition::CLIENT; } // If the layer was client composited in the previous frame, we @@ -2516,14 +2503,13 @@ void SurfaceFlinger::postFramebuffer(const sp<DisplayDevice>& displayDevice) { // Since we do not track that, always merge with the current // client target acquire fence when it is available, even though // this is suboptimal. - if (layer->getCompositionType(displayDevice) == - Hwc2::IComposerClient::Composition::CLIENT) { + if (usedClientComposition) { releaseFence = Fence::merge("LayerRelease", releaseFence, display->getRenderSurface()->getClientTargetAcquireFence()); } - layer->getBE().onLayerDisplayed(releaseFence); + layer->getLayerFE().onLayerDisplayed(releaseFence); } // We've got a list of layers needing fences, that are disjoint with @@ -2533,7 +2519,7 @@ void SurfaceFlinger::postFramebuffer(const sp<DisplayDevice>& displayDevice) { sp<Fence> presentFence = displayId ? getHwComposer().getPresentFence(*displayId) : Fence::NO_FENCE; for (auto& layer : displayDevice->getLayersNeedingFences()) { - layer->getBE().onLayerDisplayed(presentFence); + layer->getCompositionLayer()->getLayerFE()->onLayerDisplayed(presentFence); } } diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 4fb1c0e258..8206cf051a 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -55,7 +55,6 @@ #include "DisplayHardware/HWComposer.h" #include "Effects/Daltonizer.h" #include "FrameTracker.h" -#include "LayerBE.h" #include "LayerStats.h" #include "LayerVector.h" #include "RegionSamplingThread.h" @@ -106,7 +105,6 @@ class Surface; class SurfaceFlingerBE; class TimeStats; class VSyncSource; -struct CompositionInfo; namespace compositionengine { class DisplaySurface; @@ -199,9 +197,6 @@ public: // use to differentiate callbacks from different hardware composer // instances. Each hardware composer instance gets a different sequence id. int32_t mComposerSequenceId; - - std::map<wp<IBinder>, std::vector<CompositionInfo>> mCompositionInfo; - std::map<wp<IBinder>, std::vector<CompositionInfo>> mEndOfFrameCompositionInfo; }; class SetInputWindowsListener : public BnSetInputWindowsListener { |