Fix rendering artifacts on tiled renderers
Bug #7275145

This change fixes ViewRoot and adds extra debug information. It does
not solve the problem entirely. Another CL will.

Change-Id: I7e604ba38aad7f421769783dcbd998d6905ab2d9
diff --git a/core/java/android/view/GLES20RecordingCanvas.java b/core/java/android/view/GLES20RecordingCanvas.java
index ba8be6c..d2df45a 100644
--- a/core/java/android/view/GLES20RecordingCanvas.java
+++ b/core/java/android/view/GLES20RecordingCanvas.java
@@ -236,18 +236,6 @@
     }
 
     @Override
-    public void drawRect(Rect r, Paint paint) {
-        super.drawRect(r, paint);
-        recordShaderBitmap(paint);
-    }
-
-    @Override
-    public void drawRect(RectF r, Paint paint) {
-        super.drawRect(r, paint);
-        recordShaderBitmap(paint);
-    }
-
-    @Override
     public void drawRoundRect(RectF rect, float rx, float ry, Paint paint) {
         super.drawRoundRect(rect, rx, ry, paint);
         recordShaderBitmap(paint);
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index 99987bf..37e0a36 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -507,17 +507,22 @@
      * @param width The width of the drawing surface.
      * @param height The height of the drawing surface.
      * @param surface The surface to hardware accelerate
+     *                
+     * @return true if the surface was initialized, false otherwise. Returning
+     *         false might mean that the surface was already initialized.
      */
-    void initializeIfNeeded(int width, int height, Surface surface)
+    boolean initializeIfNeeded(int width, int height, Surface surface)
             throws Surface.OutOfResourcesException {
         if (isRequested()) {
             // We lost the gl context, so recreate it.
             if (!isEnabled()) {
                 if (initialize(surface)) {
                     setup(width, height);
+                    return true;
                 }
             }
-        }        
+        }
+        return false;
     }
 
     /**
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 2d083b6..ae51c1d 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2904,6 +2904,7 @@
      */
     int mOldHeightMeasureSpec = Integer.MIN_VALUE;
 
+    @ViewDebug.ExportedProperty(deepExport = true, prefix = "bg_")
     private Drawable mBackground;
 
     private int mBackgroundResource;
diff --git a/core/java/android/view/ViewDebug.java b/core/java/android/view/ViewDebug.java
index c013d85..023e58f 100644
--- a/core/java/android/view/ViewDebug.java
+++ b/core/java/android/view/ViewDebug.java
@@ -923,8 +923,12 @@
     private static void dumpViewProperties(Context context, Object view,
             BufferedWriter out, String prefix) throws IOException {
 
-        Class<?> klass = view.getClass();
+        if (view == null) {
+            out.write(prefix + "=4,null ");
+            return;
+        }
 
+        Class<?> klass = view.getClass();
         do {
             exportFields(context, view, out, klass, prefix);
             exportMethods(context, view, out, klass, prefix);
@@ -1064,8 +1068,8 @@
                     return;
                 } else if (!type.isPrimitive()) {
                     if (property.deepExport()) {
-                        dumpViewProperties(context, field.get(view), out, prefix
-                                + property.prefix());
+                        dumpViewProperties(context, field.get(view), out, prefix +
+                                property.prefix());
                         continue;
                     }
                 }
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 438f792..be2d5b3 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -52,7 +52,6 @@
 import android.os.SystemClock;
 import android.os.SystemProperties;
 import android.os.Trace;
-import android.os.UserHandle;
 import android.util.AndroidRuntimeException;
 import android.util.DisplayMetrics;
 import android.util.Log;
@@ -2817,10 +2816,10 @@
             case MSG_RESIZED: {
                 // Recycled in the fall through...
                 SomeArgs args = (SomeArgs) msg.obj;
-                if (mWinFrame.equals((Rect) args.arg1)
-                        && mPendingContentInsets.equals((Rect) args.arg2)
-                        && mPendingVisibleInsets.equals((Rect) args.arg3)
-                        && ((Configuration) args.arg4 == null)) {
+                if (mWinFrame.equals(args.arg1)
+                        && mPendingContentInsets.equals(args.arg2)
+                        && mPendingVisibleInsets.equals(args.arg3)
+                        && args.arg4 == null) {
                     break;
                 }
                 } // fall through...
@@ -2882,8 +2881,10 @@
                                 mSurface != null && mSurface.isValid()) {
                             mFullRedrawNeeded = true;
                             try {
-                                mAttachInfo.mHardwareRenderer.initializeIfNeeded(mWidth, mHeight,
-                                        mHolder.getSurface());
+                                if (mAttachInfo.mHardwareRenderer.initializeIfNeeded(
+                                        mWidth, mHeight, mHolder.getSurface())) {
+                                    mFullRedrawNeeded = true;
+                                }
                             } catch (Surface.OutOfResourcesException e) {
                                 Log.e(TAG, "OutOfResourcesException locking surface", e);
                                 try {
diff --git a/graphics/java/android/graphics/drawable/ColorDrawable.java b/graphics/java/android/graphics/drawable/ColorDrawable.java
index 4561397..d11e554 100644
--- a/graphics/java/android/graphics/drawable/ColorDrawable.java
+++ b/graphics/java/android/graphics/drawable/ColorDrawable.java
@@ -20,6 +20,7 @@
 import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.util.AttributeSet;
+import android.view.ViewDebug;
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
 
@@ -34,6 +35,7 @@
  * @attr ref android.R.styleable#ColorDrawable_color
  */
 public class ColorDrawable extends Drawable {
+    @ViewDebug.ExportedProperty(deepExport = true, prefix = "state_")
     private ColorState mState;
     private final Paint mPaint = new Paint();
     private boolean mMutated;
@@ -174,6 +176,7 @@
 
     final static class ColorState extends ConstantState {
         int mBaseColor; // base color, independent of setAlpha()
+        @ViewDebug.ExportedProperty
         int mUseColor;  // basecolor modulated by setAlpha()
         int mChangingConfigurations;