hwc: src split: Fix unwanted scaling with H-flip
Source split splits the crop and position into half, but if the
widths are odd and the left, right crops are swapped for H-flip, it
induces a scaling that is unaccounted for while allocating pipes.
This could lead to DMA pipes having scaling.
To fix this, the patch manipulates position width, if a swap happens.
Change-Id: I1b3ed582740fd49e651407be422820f60fe59cc6
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 6084d8d..0b749d2 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -2407,14 +2407,24 @@
cropR.left = cropL.right;
sanitizeSourceCrop(cropL, cropR, hnd);
+ bool cropSwap = false;
//Swap crops on H flip since 2 pipes are being used
if((orient & OVERLAY_TRANSFORM_FLIP_H) && (*rot) == NULL) {
hwc_rect_t tmp = cropL;
cropL = cropR;
cropR = tmp;
+ cropSwap = true;
}
- dstL.right = (dst.right + dst.left) / 2;
+ //cropSwap trick: If the src and dst widths are both odd, let us say
+ //2507, then splitting both into half would cause left width to be 1253
+ //and right 1254. If crop is swapped because of H flip, this will cause
+ //left crop width to be 1254, whereas left dst width remains 1253, thus
+ //inducing a scaling that is unaccounted for. To overcome that we add 1
+ //to the dst width if there is a cropSwap. So if the original width was
+ //2507, the left dst width will be 1254. Even if the original width was
+ //even for ex: 2508, the left dst width will still remain 1254.
+ dstL.right = (dst.right + dst.left + cropSwap) / 2;
dstR.left = dstL.right;
}