hwc: Avoid MDP comp for RGB downscaled layer
- In targets with fewer pipes, composition switch can happen
continuously for a layer based on whether it is updating or not.
If that updating layer requires downscaling, because of the
difference in the downscale filters between MDP and GPU,
the output of MDP and GPU will differ. This difference could be
perceived as flicker. To avoid this flicker, mark RGB downscaled layer
with downscale more than threshold to GPU always.
- property persist.hwc.downscale_threshold defines the threshold value
for downscale beyond which the layer will be marked for GPU composition.
Change-Id: Ifd26d7eb1eff0096b0391a0552d0fd97386c1a19
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 8efe025..5ceaa6d 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -942,6 +942,27 @@
return false;
}
+
+bool isDownscaleWithinThreshold(hwc_layer_1_t const* layer, float threshold) {
+ hwc_rect_t displayFrame = layer->displayFrame;
+ hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
+ int dst_w, dst_h, src_w, src_h;
+ float downscale = 1.0;
+ dst_w = displayFrame.right - displayFrame.left;
+ dst_h = displayFrame.bottom - displayFrame.top;
+ src_w = sourceCrop.right - sourceCrop.left;
+ src_h = sourceCrop.bottom - sourceCrop.top;
+ if(dst_w && dst_h) {
+ float w_scale = ((float)src_w / (float)dst_w);
+ float h_scale = ((float)src_h / (float)dst_h);
+
+ if((w_scale > threshold) or (h_scale > threshold))
+ return false;
+ }
+
+ return true;
+}
+
bool needsScaling(hwc_layer_1_t const* layer) {
int dst_w, dst_h, src_w, src_h;
hwc_rect_t displayFrame = layer->displayFrame;