Merge "display: Remove framebuffer HAL usage"
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 496dc21..3a85d47 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -634,6 +634,9 @@
     Dim srcCrop(crop.left, crop.top,
             crop.right - crop.left,
             crop.bottom - crop.top);
+    //getMdpOrient will switch the flips if the source is 90 rotated.
+    //Clients in Android dont factor in 90 rotation while deciding the flip.
+    orient = static_cast<eTransform>(ovutils::getMdpOrient(orient));
     preRotateSource(orient, whf, srcCrop);
     crop.left = srcCrop.x;
     crop.top = srcCrop.y;
@@ -684,11 +687,13 @@
             return -1;
         whf.format = (*rot)->getDstFormat();
         updateSource(orient, whf, crop);
-        //For the mdp, since we are pre-rotating
-        transform = 0;
         rotFlags |= ovutils::ROT_PREROTATED;
     }
 
+    //For the mdp, since either we are pre-rotating or MDP does flips
+    orient = OVERLAY_TRANSFORM_0;
+    transform = 0;
+
     PipeArgs parg(mdpFlags, whf, z, isFg, static_cast<eRotFlags>(rotFlags));
     if(configMdp(ctx->mOverlay, parg, orient, crop, dst, dest) < 0) {
         ALOGE("%s: commit failed for low res panel", __FUNCTION__);
@@ -730,8 +735,6 @@
             return -1;
         whf.format = (*rot)->getDstFormat();
         updateSource(orient, whf, crop);
-        //For the mdp, since we are pre-rotating
-        transform = 0;
         rotFlags |= ROT_PREROTATED;
     }
 
@@ -757,7 +760,7 @@
     //When buffer is flipped, contents of mixer config also needs to swapped.
     //Not needed if the layer is confined to one half of the screen.
     //If rotator has been used then it has also done the flips, so ignore them.
-    if(layer->transform & HWC_TRANSFORM_FLIP_V && lDest != OV_INVALID
+    if((orient & OVERLAY_TRANSFORM_FLIP_V) && lDest != OV_INVALID
             && rDest != OV_INVALID && rot == NULL) {
         hwc_rect_t new_cropR;
         new_cropR.left = tmp_cropL.left;
@@ -775,6 +778,10 @@
 
     }
 
+    //For the mdp, since either we are pre-rotating or MDP does flips
+    orient = OVERLAY_TRANSFORM_0;
+    transform = 0;
+
     //configure left mixer
     if(lDest != OV_INVALID) {
         PipeArgs pargL(mdpFlagsL, whf, z, isFg,
diff --git a/liboverlay/overlayMdp.h b/liboverlay/overlayMdp.h
index 7d3bbee..08d744f 100644
--- a/liboverlay/overlayMdp.h
+++ b/liboverlay/overlayMdp.h
@@ -296,10 +296,8 @@
 
 inline void MdpCtrl::setRotationFlags() {
     const int u = getUserData();
-    if (u == MDP_ROT_90 || u == MDP_ROT_270)
+    if (u & MDP_ROT_90)
         mOVInfo.flags |= MDP_SOURCE_ROTATED_90;
-    else
-        mOVInfo.flags &= ~MDP_SOURCE_ROTATED_90;
 }
 
 ///////    MdpCtrl3D //////
diff --git a/liboverlay/overlayUtils.cpp b/liboverlay/overlayUtils.cpp
index 2eed1e9..8cc9cc0 100644
--- a/liboverlay/overlayUtils.cpp
+++ b/liboverlay/overlayUtils.cpp
@@ -212,7 +212,10 @@
     return x - ( y + z );
 }
 
-void preRotateSource(eTransform& tr, Whf& whf, Dim& srcCrop) {
+//Expects transform to be adjusted for clients of Android.
+//i.e flips switched if 90 component present.
+//See getMdpOrient()
+void preRotateSource(const eTransform& tr, Whf& whf, Dim& srcCrop) {
     if(tr & OVERLAY_TRANSFORM_FLIP_H) {
         srcCrop.x = compute(whf.w, srcCrop.x, srcCrop.w);
     }
@@ -228,7 +231,6 @@
         swap(whf.w, whf.h);
         swap(srcCrop.w, srcCrop.h);
     }
-    tr = OVERLAY_TRANSFORM_0;
 }
 
 bool is3DTV() {
diff --git a/liboverlay/overlayUtils.h b/liboverlay/overlayUtils.h
index 5eb0e1e..3eabc1d 100644
--- a/liboverlay/overlayUtils.h
+++ b/liboverlay/overlayUtils.h
@@ -688,7 +688,7 @@
         value--;
 }
 
-void preRotateSource(eTransform& tr, Whf& whf, Dim& srcCrop);
+void preRotateSource(const eTransform& tr, Whf& whf, Dim& srcCrop);
 void getDump(char *buf, size_t len, const char *prefix, const mdp_overlay& ov);
 void getDump(char *buf, size_t len, const char *prefix, const msmfb_img& ov);
 void getDump(char *buf, size_t len, const char *prefix, const mdp_rect& ov);