[SurfaceFlinger] Make sure switch the protected state of buffers.
Previously we avoid switching the protected state of buffers if the protected
state is not changed or we fail to switch RenderEngine. However, if we just
switch away from protected state and immediately have screenshot capturing
happen, we end up not switching buffers to unprotected in next round because
we switch RenderEngine to unprotected state. This patch makes sure we always
switch the protected state correctly.
BUG: b/130435822, b/130442144
Test: Verified with Youtube
Test: libcompositionengine_test
Change-Id: I30da95d8172b349cc7897a008fd27ecbc24fb960
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index fc0d5fc..b2abe18 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3301,8 +3301,11 @@
break;
}
}
- if (needsProtected != renderEngine.isProtected() &&
- renderEngine.useProtectedContext(needsProtected)) {
+ if (needsProtected != renderEngine.isProtected()) {
+ renderEngine.useProtectedContext(needsProtected);
+ }
+ if (needsProtected != display->getRenderSurface()->isProtected() &&
+ needsProtected == renderEngine.isProtected()) {
display->getRenderSurface()->setProtected(needsProtected);
}
}