h/q/d: Optimize framebuffer layer update
While doing mixed mode composition, update only the region of the
framebuffer where layer contents are cached or updated. Avoids
MDP fetch for non-visible contents of FB.
Change-Id: I20997d79e02a6bac60d7333c28c6dde134263197
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 6ff1aa3..440cbd5 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -1212,6 +1212,22 @@
mCurrentFrame.fbCount);
}
+hwc_rect_t MDPComp::getUpdatingFBRect(hwc_context_t *ctx,
+ hwc_display_contents_1_t* list){
+ hwc_rect_t fbRect = (struct hwc_rect){0, 0, 0, 0};
+ hwc_layer_1_t *fbLayer = &list->hwLayers[mCurrentFrame.layerCount];
+
+ /* Update only the region of FB needed for composition */
+ for(int i = 0; i < mCurrentFrame.layerCount; i++ ) {
+ if(mCurrentFrame.isFBComposed[i] && !mCurrentFrame.drop[i]) {
+ hwc_layer_1_t* layer = &list->hwLayers[i];
+ hwc_rect_t dst = layer->displayFrame;
+ fbRect = getUnion(fbRect, dst);
+ }
+ }
+ return fbRect;
+}
+
bool MDPComp::postHeuristicsHandling(hwc_context_t *ctx,
hwc_display_contents_1_t* list) {
@@ -1229,7 +1245,9 @@
//Configure framebuffer first if applicable
if(mCurrentFrame.fbZ >= 0) {
- if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, mCurrentFrame.fbZ)) {
+ hwc_rect_t fbRect = getUpdatingFBRect(ctx, list);
+ if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, fbRect, mCurrentFrame.fbZ))
+ {
ALOGD_IF(isDebug(), "%s configure framebuffer failed",
__FUNCTION__);
return false;