Remove redundent layer setDataspace calls.
Cache the layer's dataspace in hwc2 and only send
to the HAL when it changes. Allows HAL to optimize
use of layer.
Bug: 38396128
Test: Manually checked systraces on Pixel
Change-Id: Ia94bebe7de9f79d01ae19b9917591837d865fea9
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.cpp b/services/surfaceflinger/DisplayHardware/HWC2.cpp
index 0366630..263ff00 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWC2.cpp
@@ -856,6 +856,10 @@
Error Layer::setDataspace(android_dataspace_t dataspace)
{
+ if (dataspace == mDataSpace) {
+ return Error::None;
+ }
+ mDataSpace = dataspace;
auto intDataspace = static_cast<Hwc2::Dataspace>(dataspace);
auto intError = mDevice.mComposer->setLayerDataspace(mDisplayId,
mId, intDataspace);