surfaceflinger: remove DisplayDevice::swapRegion
With SWAP_RECTANGLE and PARTIAL_UPDATES removed, it becomes clear
that swapRegion is not needed. It also becomes clear that
DisplayDevice::flip and SurfaceFlinger::doComposeSurfaces do not
need the dirty region.
Test: SurfaceFlinger_test
Change-Id: Id9cd2b43812d3c7dcfa36f605d0f8a647264f228
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index e454ef7..7aa16de 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -201,7 +201,7 @@
return mPageFlipCount;
}
-void DisplayDevice::flip(const Region& /*dirty*/) const
+void DisplayDevice::flip() const
{
mFlinger->getRenderEngine().checkErrors();
mPageFlipCount++;
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index e9cd969..ec3018b 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -56,8 +56,6 @@
// region in layer-stack space
mutable Region dirtyRegion;
// region in screen space
- mutable Region swapRegion;
- // region in screen space
Region undefinedRegion;
bool lastCompositionHadVisibleLayers;
@@ -97,7 +95,7 @@
// Flip the front and back buffers if the back buffer is "dirty". Might
// be instantaneous, might involve copying the frame buffer around.
- void flip(const Region& dirty) const;
+ void flip() const;
int getWidth() const;
int getHeight() const;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index c142f2f..142892e 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1534,7 +1534,7 @@
const Region dirtyRegion(hw->getDirtyRegion(repaintEverything));
if (!dirtyRegion.isEmpty()) {
// redraw the whole screen
- doComposeSurfaces(hw, Region(hw->bounds()));
+ doComposeSurfaces(hw);
// and draw the dirty region
const int32_t height = hw->getHeight();
@@ -2009,8 +2009,7 @@
doDisplayComposition(hw, dirtyRegion);
hw->dirtyRegion.clear();
- hw->flip(hw->swapRegion);
- hw->swapRegion.clear();
+ hw->flip();
}
}
postFramebuffer();
@@ -2643,30 +2642,17 @@
}
ALOGV("doDisplayComposition");
-
- Region dirtyRegion(inDirtyRegion);
-
- // compute the invalid region
- displayDevice->swapRegion.orSelf(dirtyRegion);
-
- // we need to redraw everything (the whole screen)
- dirtyRegion.set(displayDevice->bounds());
- displayDevice->swapRegion = dirtyRegion;
-
- if (!doComposeSurfaces(displayDevice, dirtyRegion)) return;
-
- // update the swap region and clear the dirty region
- displayDevice->swapRegion.orSelf(dirtyRegion);
+ if (!doComposeSurfaces(displayDevice)) return;
// swap buffers (presentation)
displayDevice->swapBuffers(getHwComposer());
}
-bool SurfaceFlinger::doComposeSurfaces(
- const sp<const DisplayDevice>& displayDevice, const Region& dirty)
+bool SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& displayDevice)
{
ALOGV("doComposeSurfaces");
+ const Region bounds(displayDevice->bounds());
const DisplayRenderArea renderArea(displayDevice);
const auto hwcId = displayDevice->getHwcDisplayId();
@@ -2708,10 +2694,7 @@
// We'll revisit later if needed.
mRenderEngine->clearWithColor(0, 0, 0, 0);
} else {
- // we start with the whole screen area
- const Region bounds(displayDevice->getBounds());
-
- // we remove the scissor part
+ // we start with the whole screen area and remove the scissor part
// we're left with the letterbox region
// (common case is that letterbox ends-up being empty)
const Region letterbox(bounds.subtract(displayDevice->getScissor()));
@@ -2719,9 +2702,6 @@
// compute the area to clear
Region region(displayDevice->undefinedRegion.merge(letterbox));
- // but limit it to the dirty region
- region.andSelf(dirty);
-
// screen is already cleared here
if (!region.isEmpty()) {
// can happen with SurfaceView
@@ -2758,7 +2738,7 @@
// we're using h/w composer
bool firstLayer = true;
for (auto& layer : displayDevice->getVisibleLayersSortedByZ()) {
- const Region clip(dirty.intersect(
+ const Region clip(bounds.intersect(
displayTransform.transform(layer->visibleRegion)));
ALOGV("Layer: %s", layer->getName().string());
ALOGV(" Composition type: %s",
@@ -2794,7 +2774,7 @@
} else {
// we're not using h/w composer
for (auto& layer : displayDevice->getVisibleLayersSortedByZ()) {
- const Region clip(dirty.intersect(
+ const Region clip(bounds.intersect(
displayTransform.transform(layer->visibleRegion)));
if (!clip.isEmpty()) {
layer->draw(renderArea, clip);
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 58d9998..974de94 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -543,7 +543,7 @@
// compose surfaces for display hw. this fails if using GL and the surface
// has been destroyed and is no longer valid.
- bool doComposeSurfaces(const sp<const DisplayDevice>& displayDevice, const Region& dirty);
+ bool doComposeSurfaces(const sp<const DisplayDevice>& displayDevice);
void postFramebuffer();
void drawWormhole(const sp<const DisplayDevice>& displayDevice, const Region& region) const;