HWC2: Optimize execution by caching all HWC2 calls in setPerFrameData
To avoid redundant HWC2 calls into hwcomposer service, we cache all HWC2
calls in BufferLayer::setPerFrameData by having visible region, damage
region and layer buffers cached in HWC2::Layer.
Bug: 119414178
Test: Display function test on F2.
Test: b/129317072 Display function tests on M1/S1, M2/S2, B1/C1, B4/S4,
and C2/F2.
Change-Id: I1679e755ac55a459c93b42b9f8225f0c270228e6
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.h b/services/surfaceflinger/DisplayHardware/HWC2.h
index 4209e45..e0a5ef1 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.h
+++ b/services/surfaceflinger/DisplayHardware/HWC2.h
@@ -27,6 +27,7 @@
#include <math/mat4.h>
#include <ui/GraphicTypes.h>
#include <ui/HdrCapabilities.h>
+#include <ui/Region.h>
#include <utils/Log.h>
#include <utils/StrongPointer.h>
#include <utils/Timers.h>
@@ -42,8 +43,6 @@
class Fence;
class FloatRect;
class GraphicBuffer;
- class Rect;
- class Region;
namespace Hwc2 {
class Composer;
}
@@ -438,9 +437,15 @@
hwc2_display_t mDisplayId;
hwc2_layer_t mId;
+
+ // Cached HWC2 data, to ensure the same commands aren't sent to the HWC
+ // multiple times.
+ android::Region mVisibleRegion = android::Region::INVALID_REGION;
+ android::Region mDamageRegion = android::Region::INVALID_REGION;
android::ui::Dataspace mDataSpace = android::ui::Dataspace::UNKNOWN;
android::HdrMetadata mHdrMetadata;
android::mat4 mColorMatrix;
+ uint32_t mBufferSlot;
};
} // namespace impl