hwc: cache layers on framebuffer
In the cases where all the layers that are marked as HWC_FRAMEBUFFER did not
change, we can mark them as HWC_OVERLAY since their contents are already on the
framebuffer and do not need any additional processing.
This optimization shows power improvement for video playback.
Bug: 7623741
Change-Id: Ia178a926e6f56a3ec9291250a22a66f212c30b14
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index ced542e..0f93dd9 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -29,6 +29,7 @@
#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
#define FINAL_TRANSFORM_MASK 0x000F
#define MAX_NUM_DISPLAYS 4 //Yes, this is ambitious
+#define MAX_NUM_LAYERS 32
//Fwrd decls
struct hwc_context_t;
@@ -81,6 +82,26 @@
HWC_LAYER_RESERVED_1 = 0x00000008
};
+class LayerCache {
+ public:
+ LayerCache() {
+ canUseLayerCache = false;
+ numHwLayers = 0;
+ for(uint32_t i = 0; i < MAX_NUM_LAYERS; i++) {
+ hnd[i] = NULL;
+ }
+ }
+ //LayerCache optimization
+ void updateLayerCache(hwc_display_contents_1_t* list);
+ void resetLayerCache(int num);
+ void markCachedLayersAsOverlay(hwc_display_contents_1_t* list);
+ private:
+ uint32_t numHwLayers;
+ bool canUseLayerCache;
+ buffer_handle_t hnd[MAX_NUM_LAYERS];
+
+};
+
// -----------------------------------------------------------------------------
// Utility functions - implemented in hwc_utils.cpp
@@ -196,6 +217,8 @@
qhwc::ListStats listStats[HWC_NUM_DISPLAY_TYPES];
+ qhwc::LayerCache *mLayerCache;
+
//Securing in progress indicator
bool mSecuring;