hwc: Use gpu composition when there is rotation

Mdp3 has a hw issue where it cannot handle rotation and blending,
when roi height or width is not divisible by 16. When roi is not
divisible by 16 mdp3 would read memory that it is beyond the
image. This leads to page faults, which further leads to poor
performance.

Change-Id: I2cd1b77c21c407503399630cdb702b575aa4e64e
diff --git a/libhwcomposer/hwc_copybit.cpp b/libhwcomposer/hwc_copybit.cpp
index 287c11d..804257f 100644
--- a/libhwcomposer/hwc_copybit.cpp
+++ b/libhwcomposer/hwc_copybit.cpp
@@ -166,6 +166,17 @@
     private_handle_t *fbHnd = (private_handle_t *)fbLayer->handle;
 
 
+    // Avoid issue with mdp3 and rotation by using gpu composition
+    if (qdutils::MDPVersion::getInstance().getMDPVersion() < 400) {
+        for (int i = ctx->listStats[dpy].numAppLayers-1; i >= 0 ; i--) {
+            hwc_layer_1_t *layer = (hwc_layer_1_t *) &list->hwLayers[i];
+            if ((layer->transform & (HAL_TRANSFORM_FLIP_H |
+                   HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90)) &&
+                   ((layer->displayFrame.bottom - layer->displayFrame.top) % 16 ||
+                   (layer->displayFrame.right - layer->displayFrame.left) % 16))
+                return true;
+        }
+    }
 
     //Allocate render buffers if they're not allocated
     if (useCopybitForYUV || useCopybitForRGB) {