display: Add support for flip operation in MDP comp

This change adds support for flip operation during MDP composition. This
enables frames to get MDP composited during 270 degree orientation too (with
pre rotation doing 90 degree rotation) or even with layers with just h flip or
v flip.

Bug: 7435860
Change-Id: I7fd18226d8337b2cd9341d709c2bd030eff881f7
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 6cab545..0fbe309 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -276,10 +276,6 @@
         // commit - commit changes to mdp driver
         // queueBuffer - not here, happens when draw is called
 
-        ovutils::eTransform orient =
-            static_cast<ovutils::eTransform>(layer->transform);
-
-        ov.setTransform(orient, dest);
         ovutils::Whf info(hnd->width, hnd->height, hnd->format, hnd->size);
         ovutils::eMdpFlags mdpFlags = mdp_info.isVG ? ovutils::OV_MDP_PIPE_SHARE
                                                    : ovutils::OV_MDP_FLAGS_NONE;
@@ -292,6 +288,18 @@
                     ovutils::OV_MDP_BLEND_FG_PREMULT);
         }
 
+        if(layer->transform & HAL_TRANSFORM_FLIP_H) {
+            ovutils::setMdpFlags(mdpFlags,
+                    ovutils::OV_MDP_FLIP_H);
+        }
+
+        if(layer->transform & HAL_TRANSFORM_FLIP_V) {
+            ovutils::setMdpFlags(mdpFlags,
+                    ovutils::OV_MDP_FLIP_V);
+        }
+
+        ov.setTransform(0, dest);
+
         ovutils::PipeArgs parg(mdpFlags,
                                info,
                                zOrder,
@@ -359,9 +367,11 @@
         return false;
     }
 
-    //MDP composition is not efficient if rotation is needed.
+    //MDP composition is not efficient if layer needs rotator.
     for(int i = 0; i < numAppLayers; ++i) {
-        if(list->hwLayers[i].transform) {
+        // As MDP h/w supports flip operation, use MDP comp only for
+        // 180 transforms. Fail for any transform involving 90 (90, 270).
+        if(list->hwLayers[i].transform & HWC_TRANSFORM_ROT_90) {
                 ALOGD_IF(isDebug(), "%s: orientation involved",__FUNCTION__);
                 return false;
         }
@@ -705,7 +715,7 @@
 
         /* reset Invalidator */
         if(idleInvalidator)
-        idleInvalidator->markForSleep();
+           idleInvalidator->markForSleep();
 
         ovutils::eDest dest;