diff options
Diffstat (limited to 'services/surfaceflinger/Layer.cpp')
| -rw-r--r-- | services/surfaceflinger/Layer.cpp | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 66c2fb658f..62e31b9f79 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -146,7 +146,7 @@ Layer::Layer(const LayerCreationArgs& args) mLayerCreationFlags(args.flags), mBorderEnabled(false), mTextureName(args.textureName), - mLegacyLayerFE(args.flinger->getFactory().createLayerFE(mName)) { + mLayerFE(args.flinger->getFactory().createLayerFE(mName)) { ALOGV("Creating Layer %s", getDebugName()); uint32_t layerFlags = 0; @@ -3123,14 +3123,15 @@ bool Layer::setSidebandStream(const sp<NativeHandle>& sidebandStream) { return true; } -bool Layer::setTransactionCompletedListeners(const std::vector<sp<CallbackHandle>>& handles, - bool willPresent) { +bool Layer::setTransactionCompletedListeners(const std::vector<sp<CallbackHandle>>& handles) { // If there is no handle, we will not send a callback so reset mReleasePreviousBuffer and return if (handles.empty()) { mReleasePreviousBuffer = false; return false; } + const bool willPresent = willPresentCurrentTransaction(); + std::deque<sp<CallbackHandle>> remainingHandles; for (const auto& handle : handles) { // If this transaction set a buffer on this layer, release its previous buffer @@ -3213,10 +3214,11 @@ bool Layer::fenceHasSignaled() const { return fenceSignaled; } -void Layer::onPreComposition(nsecs_t refreshStartTime) { +bool Layer::onPreComposition(nsecs_t refreshStartTime) { for (const auto& handle : mDrawingState.callbackHandles) { handle->refreshStartTime = refreshStartTime; } + return hasReadyFrame(); } void Layer::setAutoRefresh(bool autoRefresh) { @@ -3602,7 +3604,7 @@ bool Layer::isHdrY410() const { sp<LayerFE> Layer::getCompositionEngineLayerFE() const { // There's no need to get a CE Layer if the layer isn't going to draw anything. - return hasSomethingToDraw() ? mLegacyLayerFE : nullptr; + return hasSomethingToDraw() ? mLayerFE : nullptr; } const LayerSnapshot* Layer::getLayerSnapshot() const { @@ -3613,36 +3615,16 @@ LayerSnapshot* Layer::editLayerSnapshot() { return mSnapshot.get(); } -std::unique_ptr<frontend::LayerSnapshot> Layer::stealLayerSnapshot() { - return std::move(mSnapshot); -} - -void Layer::updateLayerSnapshot(std::unique_ptr<frontend::LayerSnapshot> snapshot) { - mSnapshot = std::move(snapshot); -} - const compositionengine::LayerFECompositionState* Layer::getCompositionState() const { return mSnapshot.get(); } sp<LayerFE> Layer::copyCompositionEngineLayerFE() const { - auto result = mFlinger->getFactory().createLayerFE(mName); + auto result = mFlinger->getFactory().createLayerFE(mLayerFE->getDebugName()); result->mSnapshot = std::make_unique<LayerSnapshot>(*mSnapshot); return result; } -sp<LayerFE> Layer::getCompositionEngineLayerFE( - const frontend::LayerHierarchy::TraversalPath& path) { - for (auto& [p, layerFE] : mLayerFEs) { - if (p == path) { - return layerFE; - } - } - auto layerFE = mFlinger->getFactory().createLayerFE(mName); - mLayerFEs.emplace_back(path, layerFE); - return layerFE; -} - void Layer::useSurfaceDamage() { if (mFlinger->mForceFullDamage) { surfaceDamageRegion = Region::INVALID_REGION; @@ -4038,6 +4020,28 @@ void Layer::updateRelativeMetadataSnapshot(const LayerMetadata& relativeLayerMet } } +LayerSnapshotGuard::LayerSnapshotGuard(Layer* layer) : mLayer(layer) { + if (mLayer) { + mLayer->mLayerFE->mSnapshot = std::move(mLayer->mSnapshot); + } +} + +LayerSnapshotGuard::~LayerSnapshotGuard() { + if (mLayer) { + mLayer->mSnapshot = std::move(mLayer->mLayerFE->mSnapshot); + } +} + +LayerSnapshotGuard::LayerSnapshotGuard(LayerSnapshotGuard&& other) : mLayer(other.mLayer) { + other.mLayer = nullptr; +} + +LayerSnapshotGuard& LayerSnapshotGuard::operator=(LayerSnapshotGuard&& other) { + mLayer = other.mLayer; + other.mLayer = nullptr; + return *this; +} + void Layer::setTrustedPresentationInfo(TrustedPresentationThresholds const& thresholds, TrustedPresentationListener const& listener) { bool hadTrustedPresentationListener = hasTrustedPresentationListener(); |