summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-07-31 16:11:57 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-07-31 16:11:57 +0000
commitcd63ae38f5a73d786ee6bed987b4565c6ef32b04 (patch)
tree1f319e8d1866009dd09cc8bc9a5f8a9d07eaa38b
parent71bb1a58638553175d35bbd3ab2bf7ab533f4496 (diff)
parentc7ef21b0b83f6f215e81f3fd676137cfa820c162 (diff)
Merge "SF: Move/Refactor LayersNeedingFences"
-rw-r--r--services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h7
-rw-r--r--services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h4
-rw-r--r--services/surfaceflinger/CompositionEngine/include/compositionengine/mock/Output.h4
-rw-r--r--services/surfaceflinger/CompositionEngine/src/Output.cpp8
-rw-r--r--services/surfaceflinger/DisplayDevice.cpp8
-rw-r--r--services/surfaceflinger/DisplayDevice.h4
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp15
7 files changed, 32 insertions, 18 deletions
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h
index 591382dcd9..5b9e282276 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h
@@ -46,6 +46,7 @@ struct OutputCompositionState;
class Output {
public:
using OutputLayers = std::vector<std::unique_ptr<compositionengine::OutputLayer>>;
+ using ReleasedLayers = std::vector<wp<LayerFE>>;
virtual ~Output();
@@ -131,6 +132,12 @@ public:
// Gets the ordered set of output layers for this output
virtual const OutputLayers& getOutputLayersOrderedByZ() const = 0;
+ // Sets the new set of layers being released this frame.
+ virtual void setReleasedLayers(ReleasedLayers&&) = 0;
+
+ // Takes (moves) the set of layers being released this frame.
+ virtual ReleasedLayers takeReleasedLayers() = 0;
+
protected:
virtual void setDisplayColorProfile(std::unique_ptr<DisplayColorProfile>) = 0;
virtual void setRenderSurface(std::unique_ptr<RenderSurface>) = 0;
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h
index f245936744..20812d258b 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h
@@ -72,6 +72,9 @@ public:
void setOutputLayersOrderedByZ(OutputLayers&&) override;
const OutputLayers& getOutputLayersOrderedByZ() const override;
+ void setReleasedLayers(ReleasedLayers&&) override;
+ ReleasedLayers takeReleasedLayers() override;
+
// Testing
void setDisplayColorProfileForTest(std::unique_ptr<compositionengine::DisplayColorProfile>);
void setRenderSurfaceForTest(std::unique_ptr<compositionengine::RenderSurface>);
@@ -93,6 +96,7 @@ private:
std::unique_ptr<compositionengine::RenderSurface> mRenderSurface;
OutputLayers mOutputLayersOrderedByZ;
+ ReleasedLayers mReleasedLayers;
};
} // namespace impl
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/Output.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/Output.h
index cf82107194..924d72cb00 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/Output.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/Output.h
@@ -66,8 +66,12 @@ public:
std::unique_ptr<compositionengine::OutputLayer>(
std::optional<DisplayId>, std::shared_ptr<compositionengine::Layer>,
sp<compositionengine::LayerFE>));
+
MOCK_METHOD1(setOutputLayersOrderedByZ, void(OutputLayers&&));
MOCK_CONST_METHOD0(getOutputLayersOrderedByZ, OutputLayers&());
+
+ MOCK_METHOD1(setReleasedLayers, void(ReleasedLayers&&));
+ MOCK_METHOD0(takeReleasedLayers, ReleasedLayers());
};
} // namespace android::compositionengine::mock
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index 0725926be4..845e3c6500 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -242,6 +242,14 @@ const Output::OutputLayers& Output::getOutputLayersOrderedByZ() const {
return mOutputLayersOrderedByZ;
}
+void Output::setReleasedLayers(Output::ReleasedLayers&& layers) {
+ mReleasedLayers = std::move(layers);
+}
+
+Output::ReleasedLayers Output::takeReleasedLayers() {
+ return std::move(mReleasedLayers);
+}
+
void Output::dirtyEntireOutput() {
mState.dirtyRegion.set(mState.bounds);
}
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 4a13bfb7ae..d1365627cf 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -126,14 +126,6 @@ const Vector< sp<Layer> >& DisplayDevice::getVisibleLayersSortedByZ() const {
return mVisibleLayersSortedByZ;
}
-void DisplayDevice::setLayersNeedingFences(const Vector< sp<Layer> >& layers) {
- mLayersNeedingFences = layers;
-}
-
-const Vector< sp<Layer> >& DisplayDevice::getLayersNeedingFences() const {
- return mLayersNeedingFences;
-}
-
// ----------------------------------------------------------------------------
void DisplayDevice::setPowerMode(int mode) {
mPowerMode = mode;
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index 0067b505e3..8bc19d4447 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -88,8 +88,6 @@ public:
void setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers);
const Vector< sp<Layer> >& getVisibleLayersSortedByZ() const;
- void setLayersNeedingFences(const Vector< sp<Layer> >& layers);
- const Vector< sp<Layer> >& getLayersNeedingFences() const;
void setLayerStack(uint32_t stack);
void setDisplaySize(const int newWidth, const int newHeight);
@@ -182,8 +180,6 @@ private:
// list of visible layers on that display
Vector< sp<Layer> > mVisibleLayersSortedByZ;
- // list of layers needing fences
- Vector< sp<Layer> > mLayersNeedingFences;
/*
* Transaction state
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 5a9ee79eaf..d9f71fd975 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2210,8 +2210,8 @@ void SurfaceFlinger::rebuildLayerStacks() {
Region opaqueRegion;
Region dirtyRegion;
compositionengine::Output::OutputLayers layersSortedByZ;
+ compositionengine::Output::ReleasedLayers releasedLayers;
Vector<sp<Layer>> deprecated_layersSortedByZ;
- Vector<sp<Layer>> layersNeedingFences;
const ui::Transform& tr = displayState.transform;
const Rect bounds = displayState.bounds;
if (displayState.isEnabled) {
@@ -2259,16 +2259,16 @@ void SurfaceFlinger::rebuildLayerStacks() {
layer) != mLayersWithQueuedFrames.cend();
if (hasExistingOutputLayer && hasQueuedFrames) {
- layersNeedingFences.add(layer);
+ releasedLayers.push_back(layer);
}
}
});
}
display->setOutputLayersOrderedByZ(std::move(layersSortedByZ));
+ display->setReleasedLayers(std::move(releasedLayers));
displayDevice->setVisibleLayersSortedByZ(deprecated_layersSortedByZ);
- displayDevice->setLayersNeedingFences(layersNeedingFences);
Region undefinedRegion{bounds};
undefinedRegion.subtractSelf(tr.transform(opaqueRegion));
@@ -2504,11 +2504,14 @@ void SurfaceFlinger::postFramebuffer(const sp<DisplayDevice>& displayDevice) {
// We've got a list of layers needing fences, that are disjoint with
// display->getVisibleLayersSortedByZ. The best we can do is to
// supply them with the present fence.
- if (!displayDevice->getLayersNeedingFences().isEmpty()) {
+ auto releasedLayers = display->takeReleasedLayers();
+ if (!releasedLayers.empty()) {
sp<Fence> presentFence =
displayId ? getHwComposer().getPresentFence(*displayId) : Fence::NO_FENCE;
- for (auto& layer : displayDevice->getLayersNeedingFences()) {
- layer->getCompositionLayer()->getLayerFE()->onLayerDisplayed(presentFence);
+ for (auto& weakLayer : releasedLayers) {
+ if (auto layer = weakLayer.promote(); layer != nullptr) {
+ layer->onLayerDisplayed(presentFence);
+ }
}
}