hwc: Optimize layer drops based on ROI
- Iterate layer list to drop layers from composition that
are not going to be visible inside the updating ROI.
- No ROI when skip layers are present.
- Reset dropped layer info on full GPU fallback.
Change-Id: Ib544526a8c28ffdd16b5be12f73d57d10d207c39
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 8342615..cd4fad4 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -402,6 +402,12 @@
return ret;
}
+/*
+ * 1) Identify layers that are not visible in the updating ROI and drop them
+ * from composition.
+ * 2) If we have a scaling layers which needs cropping against generated ROI.
+ * Reset ROI to full resolution.
+ */
bool MDPComp::validateAndApplyROI(hwc_context_t *ctx,
hwc_display_contents_1_t* list, hwc_rect_t roi) {
int numAppLayers = ctx->listStats[mDpy].numAppLayers;
@@ -409,7 +415,15 @@
if(!isValidRect(roi))
return false;
- for(int i = 0; i < numAppLayers; i++){
+ hwc_rect_t visibleRect = roi;
+
+ for(int i = numAppLayers - 1; i >= 0; i--){
+
+ if(!isValidRect(visibleRect)) {
+ mCurrentFrame.drop[i] = true;
+ mCurrentFrame.dropCount++;
+ }
+
const hwc_layer_1_t* layer = &list->hwLayers[i];
hwc_rect_t dstRect = layer->displayFrame;
@@ -417,7 +431,7 @@
int transform = layer->transform;
trimLayer(ctx, mDpy, transform, srcRect, dstRect);
- hwc_rect_t res = getIntersection(roi, dstRect);
+ hwc_rect_t res = getIntersection(visibleRect, dstRect);
int res_w = res.right - res.left;
int res_h = res.bottom - res.top;
@@ -438,6 +452,9 @@
return false;
}
}
+
+ if (layer->blending == HWC_BLENDING_NONE)
+ visibleRect = deductRect(visibleRect, res);
}
return true;
}
@@ -456,6 +473,9 @@
return;
}
+ if(isSkipPresent(ctx, mDpy))
+ return;
+
if(list->flags & HWC_GEOMETRY_CHANGED)
return;
@@ -1224,10 +1244,11 @@
}
} else {
reset(numLayers, list);
+ memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop));
+ mCurrentFrame.dropCount = 0;
ret = -1;
goto exit;
}
-
//UpdateLayerFlags
setMDPCompLayerFlags(ctx, list);
mCachedFrame.cacheAll(list);