Reallocate GraphicBuffer as long as the protected bit is different.
Previously as long as the usage bit is the superset of the requested usage bit,
we don't reallocate GraphicBuffer. However, this is wrong for protected
contents, the protected usage bit on GraphicBuffer must align with the
protected context. Since we turn off protected context when there's no
protected content, we need to reallocate non-protected GraphicBuffer, otherwise
it's undefined behaviour and will result in crash.
BUG: b/35315015, b/127862411
Test: Verify no kgsl page fault with protected contents.
Change-Id: I789076ba411079364528bd844e6abb5dcbfa77f7
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
index 40df260..45340a1 100644
--- a/libs/ui/GraphicBuffer.cpp
+++ b/libs/ui/GraphicBuffer.cpp
@@ -194,6 +194,7 @@
if (inFormat != format) return true;
if (inLayerCount != layerCount) return true;
if ((usage & inUsage) != inUsage) return true;
+ if ((usage & USAGE_PROTECTED) != (inUsage & USAGE_PROTECTED)) return true;
return false;
}