summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-08-02 17:39:36 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-08-02 17:39:36 +0000
commitbdeb796b8a4506fd318789b24b113ece9d7b3a38 (patch)
tree195374779aae64fa3c2731db89f6eed56907ffd9
parent25b52e4ce350c0b75da441fe4630fbdea59a37e8 (diff)
parentd0a92a0dd469f59029f60cc67352564fe5f84e1f (diff)
Merge "SF: Move beginFrame to CompositionEngine"
-rw-r--r--services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h3
-rw-r--r--services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h1
-rw-r--r--services/surfaceflinger/CompositionEngine/include/compositionengine/mock/Output.h1
-rw-r--r--services/surfaceflinger/CompositionEngine/src/Output.cpp28
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp43
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h6
6 files changed, 39 insertions, 43 deletions
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h
index ebfda1f702..4dfcfa4593 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/Output.h
@@ -150,6 +150,9 @@ public:
// Takes (moves) the set of layers being released this frame.
virtual ReleasedLayers takeReleasedLayers() = 0;
+ // Signals that a frame is beginning on the output
+ virtual void beginFrame() = 0;
+
// Prepares a frame for display
virtual void prepareFrame() = 0;
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h
index b454212e2c..5f4a76440c 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/Output.h
@@ -75,6 +75,7 @@ public:
void setReleasedLayers(ReleasedLayers&&) override;
ReleasedLayers takeReleasedLayers() override;
+ void beginFrame() override;
void prepareFrame() override;
void postFramebuffer() override;
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/Output.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/Output.h
index 8aaebc2628..d494413af5 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/Output.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/Output.h
@@ -73,6 +73,7 @@ public:
MOCK_METHOD1(setReleasedLayers, void(ReleasedLayers&&));
MOCK_METHOD0(takeReleasedLayers, ReleasedLayers());
+ MOCK_METHOD0(beginFrame, void());
MOCK_METHOD0(prepareFrame, void());
MOCK_METHOD0(chooseCompositionStrategy, void());
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index 6d060e404a..b411e0a04a 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -251,6 +251,34 @@ Output::ReleasedLayers Output::takeReleasedLayers() {
return std::move(mReleasedLayers);
}
+void Output::beginFrame() {
+ const bool dirty = !getDirtyRegion(false).isEmpty();
+ const bool empty = mOutputLayersOrderedByZ.empty();
+ const bool wasEmpty = !mState.lastCompositionHadVisibleLayers;
+
+ // If nothing has changed (!dirty), don't recompose.
+ // If something changed, but we don't currently have any visible layers,
+ // and didn't when we last did a composition, then skip it this time.
+ // The second rule does two things:
+ // - When all layers are removed from a display, we'll emit one black
+ // 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);
+
+ 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]);
+
+ mRenderSurface->beginFrame(mustRecompose);
+
+ if (mustRecompose) {
+ mState.lastCompositionHadVisibleLayers = !empty;
+ }
+}
+
void Output::prepareFrame() {
ATRACE_CALL();
ALOGV(__FUNCTION__);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index acfd534018..1aec0c5389 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1790,11 +1790,12 @@ void SurfaceFlinger::handleMessageRefresh() {
mCompositionEngine->preComposition(refreshArgs);
rebuildLayerStacks();
calculateWorkingSet();
- for (const auto& [token, display] : mDisplays) {
- beginFrame(display);
- display->getCompositionDisplay()->prepareFrame();
- doDebugFlashRegions(display, repaintEverything);
- doComposition(display, repaintEverything);
+ for (const auto& [token, displayDevice] : mDisplays) {
+ auto display = displayDevice->getCompositionDisplay();
+ display->beginFrame();
+ display->prepareFrame();
+ doDebugFlashRegions(displayDevice, repaintEverything);
+ doComposition(displayDevice, repaintEverything);
}
logLayerStats();
@@ -2373,38 +2374,6 @@ void SurfaceFlinger::pickColorMode(const sp<DisplayDevice>& display, ColorMode*
profile->getBestColorMode(bestDataSpace, intent, outDataSpace, outMode, outRenderIntent);
}
-void SurfaceFlinger::beginFrame(const sp<DisplayDevice>& displayDevice) {
- auto display = displayDevice->getCompositionDisplay();
- const auto& displayState = display->getState();
-
- bool dirty = !display->getDirtyRegion(false).isEmpty();
- bool empty = displayDevice->getVisibleLayersSortedByZ().size() == 0;
- bool wasEmpty = !displayState.lastCompositionHadVisibleLayers;
-
- // If nothing has changed (!dirty), don't recompose.
- // If something changed, but we don't currently have any visible layers,
- // and didn't when we last did a composition, then skip it this time.
- // The second rule does two things:
- // - When all layers are removed from a display, we'll emit one black
- // 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.
- bool mustRecompose = dirty && !(empty && wasEmpty);
-
- const char flagPrefix[] = {'-', '+'};
- static_cast<void>(flagPrefix);
- ALOGV_IF(displayDevice->isVirtual(), "%s: %s composition for %s (%cdirty %cempty %cwasEmpty)",
- __FUNCTION__, mustRecompose ? "doing" : "skipping",
- displayDevice->getDebugName().c_str(), flagPrefix[dirty], flagPrefix[empty],
- flagPrefix[wasEmpty]);
-
- display->getRenderSurface()->beginFrame(mustRecompose);
-
- if (mustRecompose) {
- display->editState().lastCompositionHadVisibleLayers = !empty;
- }
-}
-
void SurfaceFlinger::doComposition(const sp<DisplayDevice>& displayDevice, bool repaintEverything) {
ATRACE_CALL();
ALOGV("doComposition");
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index af216037d4..3974a8cf08 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -760,12 +760,6 @@ private:
ui::Dataspace* outDataSpace, ui::RenderIntent* outRenderIntent) const;
void calculateWorkingSet();
- /*
- * beginFrame - This function handles any pre-frame processing that needs to be
- * prior to any CompositionInfo handling and is not dependent on data in
- * CompositionInfo
- */
- void beginFrame(const sp<DisplayDevice>& display);
void doComposition(const sp<DisplayDevice>& display, bool repainEverything);
void doDebugFlashRegions(const sp<DisplayDevice>& display, bool repaintEverything);
void logLayerStats();