hwc: Map dirtyRect to layer destination before using.
DirtyRect for a layer is generated w.r.t to its buffer
coordinates. It needs to be mapped for layer destination
(display) coordinates before using it to calculate the frame's
ROI.
Change-Id: Id86f495b2016da2cfd5aed4d86bff6d3035abf10
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index e72d0ea..14c478d 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -579,11 +579,17 @@
hwc_layer_1_t* layer = &list->hwLayers[index];
if ((mCachedFrame.hnd[index] != layer->handle) ||
isYuvBuffer((private_handle_t *)layer->handle)) {
- hwc_rect_t updatingRect = layer->displayFrame;
+ hwc_rect_t dst = layer->displayFrame;
+ hwc_rect_t updatingRect = dst;
#ifdef QCOM_BSP
if(!needsScaling(layer) && !layer->transform)
- updatingRect = layer->dirtyRect;
+ {
+ hwc_rect_t src = integerizeSourceCrop(layer->sourceCropf);
+ int x_off = dst.left - src.left;
+ int y_off = dst.top - src.top;
+ updatingRect = moveRect(layer->dirtyRect, x_off, y_off);
+ }
#endif
hwc_rect_t l_dst = getIntersection(l_frame, updatingRect);
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index b5a7629..972f12f 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -1088,6 +1088,21 @@
return false;
}
+hwc_rect_t moveRect(const hwc_rect_t& rect, const int& x_off, const int& y_off)
+{
+ hwc_rect_t res;
+
+ if(!isValidRect(rect))
+ return (hwc_rect_t){0, 0, 0, 0};
+
+ res.left = rect.left + x_off;
+ res.top = rect.top + y_off;
+ res.right = rect.right + x_off;
+ res.bottom = rect.bottom + y_off;
+
+ return res;
+}
+
/* computes the intersection of two rects */
hwc_rect_t getIntersection(const hwc_rect_t& rect1, const hwc_rect_t& rect2)
{
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index 234804c..4cfed2a 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -262,6 +262,7 @@
bool isValidRect(const hwc_rect_t& rect);
hwc_rect_t deductRect(const hwc_rect_t& rect1, const hwc_rect_t& rect2);
bool isSameRect(const hwc_rect& rect1, const hwc_rect& rect2);
+hwc_rect_t moveRect(const hwc_rect_t& rect, const int& x_off, const int& y_off);
hwc_rect_t getIntersection(const hwc_rect_t& rect1, const hwc_rect_t& rect2);
hwc_rect_t getUnion(const hwc_rect_t& rect1, const hwc_rect_t& rect2);
void optimizeLayerRects(const hwc_display_contents_1_t *list);