Enable partial invalidates when rendering with OpenGL.

Change-Id: Ie8be06c4776b815e8737753eb8003b4fd8936130
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 8af2549..b073513 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -6730,11 +6730,14 @@
             mPrivateFlags |= INVALIDATED;
             final ViewParent p = mParent;
             final AttachInfo ai = mAttachInfo;
-            if (p != null && ai != null && ai.mHardwareAccelerated) {
-                // fast-track for GL-enabled applications; just invalidate the whole hierarchy
-                // with a null dirty rect, which tells the ViewRoot to redraw everything
-                p.invalidateChild(this, null);
-                return;
+            //noinspection PointlessBooleanExpression,ConstantConditions
+            if (!HardwareRenderer.RENDER_DIRTY_REGIONS) {
+                if (p != null && ai != null && ai.mHardwareAccelerated) {
+                    // fast-track for GL-enabled applications; just invalidate the whole hierarchy
+                    // with a null dirty rect, which tells the ViewRoot to redraw everything
+                    p.invalidateChild(this, null);
+                    return;
+                }
             }
             if (p != null && ai != null) {
                 final int scrollX = mScrollX;
@@ -6770,11 +6773,14 @@
             mPrivateFlags |= INVALIDATED;
             final ViewParent p = mParent;
             final AttachInfo ai = mAttachInfo;
-            if (p != null && ai != null && ai.mHardwareAccelerated) {
-                // fast-track for GL-enabled applications; just invalidate the whole hierarchy
-                // with a null dirty rect, which tells the ViewRoot to redraw everything
-                p.invalidateChild(this, null);
-                return;
+            //noinspection PointlessBooleanExpression,ConstantConditions
+            if (!HardwareRenderer.RENDER_DIRTY_REGIONS) {
+                if (p != null && ai != null && ai.mHardwareAccelerated) {
+                    // fast-track for GL-enabled applications; just invalidate the whole hierarchy
+                    // with a null dirty rect, which tells the ViewRoot to redraw everything
+                    p.invalidateChild(this, null);
+                    return;
+                }
             }
             if (p != null && ai != null && l < r && t < b) {
                 final int scrollX = mScrollX;
@@ -6823,11 +6829,14 @@
             }
             final AttachInfo ai = mAttachInfo;
             final ViewParent p = mParent;
-            if (p != null && ai != null && ai.mHardwareAccelerated) {
-                // fast-track for GL-enabled applications; just invalidate the whole hierarchy
-                // with a null dirty rect, which tells the ViewRoot to redraw everything
-                p.invalidateChild(this, null);
-                return;
+            //noinspection PointlessBooleanExpression,ConstantConditions
+            if (!HardwareRenderer.RENDER_DIRTY_REGIONS) {
+                if (p != null && ai != null && ai.mHardwareAccelerated) {
+                    // fast-track for GL-enabled applications; just invalidate the whole hierarchy
+                    // with a null dirty rect, which tells the ViewRoot to redraw everything
+                    p.invalidateChild(this, null);
+                    return;
+                }
             }
 
             if (p != null && ai != null) {
@@ -8101,7 +8110,8 @@
             final HardwareCanvas canvas = mHardwareLayer.start(mAttachInfo.mHardwareCanvas);
             try {
                 canvas.setViewport(width, height);
-                canvas.onPreDraw();
+                // TODO: We should pass the dirty rect
+                canvas.onPreDraw(null);
 
                 computeScroll();
                 canvas.translate(-mScrollX, -mScrollY);
@@ -8190,7 +8200,7 @@
             ViewGroup parent = (ViewGroup) this;
             final int count = parent.getChildCount();
             for (int i = 0; i < count; i++) {
-                final View child = (View) parent.getChildAt(i);
+                final View child = parent.getChildAt(i);
                 child.outputDirtyFlags(indent + "  ", clear, clearMask);
             }
         }
@@ -8251,7 +8261,8 @@
                 int height = mBottom - mTop;
 
                 canvas.setViewport(width, height);
-                canvas.onPreDraw();
+                // The dirty rect should always be null for a display list
+                canvas.onPreDraw(null);
 
                 final int restoreCount = canvas.save();