hwc: Update redrawing

By default make use of redrawing. It will be toggled only when caching
decides there shouldn't be any. Per our priority ordering:

1) Full MDP - redraw irrelevant
2) Partial/Cached MDP - decide on redraw
3) Only Video - 1 & 2, which include video, are not possible. Redraw.
4) Fallback - Redraw.

Change-Id: I6b74a5edcf79488ede2ea9480721731f371af9c8
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 98905b1..4561546 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -223,7 +223,7 @@
     layerCount = numLayers;
     fbCount = numLayers;
     mdpCount = 0;
-    needsRedraw = false;
+    needsRedraw = true;
     fbZ = 0;
 }
 
@@ -723,12 +723,23 @@
 
     //Check whether layers marked for MDP Composition is actually doable.
     if(isFullFrameDoable(ctx, list)){
-        if(mCurrentFrame.mdpCount) {
-            mCurrentFrame.map();
-            //Acquire and Program MDP pipes
-            if(!programMDP(ctx, list)) {
-                mCurrentFrame.reset(numLayers);
-                mCachedFrame.cacheAll(list);
+        mCurrentFrame.map();
+        //Acquire and Program MDP pipes
+        if(!programMDP(ctx, list)) {
+            mCurrentFrame.reset(numLayers);
+            mCachedFrame.cacheAll(list);
+        } else { //Success
+            //Any change in composition types needs an FB refresh
+            mCurrentFrame.needsRedraw = false;
+            if(mCurrentFrame.fbCount &&
+                    ((mCurrentFrame.mdpCount != mCachedFrame.mdpCount) ||
+                     (mCurrentFrame.fbCount != mCachedFrame.cacheCount) ||
+                     (mCurrentFrame.fbZ != mCachedFrame.fbZ) ||
+                     (!mCurrentFrame.mdpCount) ||
+                     (list->flags & HWC_GEOMETRY_CHANGED) ||
+                     isSkipPresent(ctx, mDpy) ||
+                     (mDpy > HWC_DISPLAY_PRIMARY))) {
+                mCurrentFrame.needsRedraw = true;
             }
         }
     } else if(isOnlyVideoDoable(ctx, list)) {
@@ -750,18 +761,6 @@
         mCachedFrame.cacheAll(list);
     }
 
-    /* Any change in composition types needs an FB refresh*/
-    if(mCurrentFrame.fbCount &&
-            ((mCurrentFrame.mdpCount != mCachedFrame.mdpCount) ||
-            (mCurrentFrame.fbCount != mCachedFrame.cacheCount) ||
-            (mCurrentFrame.fbZ != mCachedFrame.fbZ) ||
-            (!mCurrentFrame.mdpCount) ||
-            (list->flags & HWC_GEOMETRY_CHANGED) ||
-            isSkipPresent(ctx, mDpy) ||
-            (mDpy > HWC_DISPLAY_PRIMARY))) {
-        mCurrentFrame.needsRedraw = true;
-    }
-
     //UpdateLayerFlags
     setMDPCompLayerFlags(ctx, list);
     mCachedFrame.updateCounts(mCurrentFrame);