From bb9b14f0209d9a83df38c3fdcd27ea0fe4255fc0 Mon Sep 17 00:00:00 2001 From: Marissa Wall Date: Tue, 23 Apr 2019 14:10:15 -0700 Subject: ASurfaceControl: fix surface damage There are two problems with surface control. 1) By merging the rects, the Region turned into 0,0,0,0 instead of an or of the Rects. 2) In the case where an app intends to have a region of 0,0,0,0, we should treat it the same as a region of 0,0,-1,-1. Bug: 131175047 Test: ASurfaceControl Change-Id: Ib2e3b90ac215e069d3d3c2eca81ff1013b4287aa --- native/android/surface_control.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'native/android/surface_control.cpp') diff --git a/native/android/surface_control.cpp b/native/android/surface_control.cpp index d07052bb3b3f..7ee2f0a1db18 100644 --- a/native/android/surface_control.cpp +++ b/native/android/surface_control.cpp @@ -411,7 +411,15 @@ void ASurfaceTransaction_setDamageRegion(ASurfaceTransaction* aSurfaceTransactio Region region; for (uint32_t i = 0; i < count; ++i) { - region.merge(static_cast(rects[i])); + region.orSelf(static_cast(rects[i])); + } + + // Hardware composer interprets a DamageRegion with a single Rect of {0,0,0,0} to be an + // undamaged region and {0,0,-1,-1} to be a fully damaged buffer. This is a confusing + // distinction for a public api. Instead, default both cases to be a fully damaged buffer. + if (count == 1 && region.getBounds().isEmpty()) { + transaction->setSurfaceDamageRegion(surfaceControl, Region::INVALID_REGION); + return; } transaction->setSurfaceDamageRegion(surfaceControl, region); -- cgit v1.2.3