summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/View.java10
-rw-r--r--core/java/android/view/ViewGroup.java28
2 files changed, 26 insertions, 12 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index d3913dcb29cb..393412f0e6a0 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -73,7 +73,6 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.List;
import java.util.WeakHashMap;
/**
@@ -2375,6 +2374,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
})
int mLayerType = LAYER_TYPE_NONE;
Paint mLayerPaint;
+ Rect mLocalDirtyRect;
/**
* Simple constructor to use when creating a view from code.
@@ -8173,7 +8173,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
}
mLayerType = layerType;
- mLayerPaint = mLayerType == LAYER_TYPE_NONE ? null : (paint == null ? new Paint() : paint);
+ final boolean layerDisabled = mLayerType == LAYER_TYPE_NONE;
+ mLayerPaint = layerDisabled ? null : (paint == null ? new Paint() : paint);
+ mLocalDirtyRect = layerDisabled ? null : new Rect();
invalidateParentCaches();
invalidate(true);
@@ -8228,8 +8230,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
mAttachInfo.mHardwareCanvas = canvas;
try {
canvas.setViewport(width, height);
- // TODO: We should pass the dirty rect
- canvas.onPreDraw(null);
+ canvas.onPreDraw(mLocalDirtyRect);
final int restoreCount = canvas.save();
@@ -8251,6 +8252,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
canvas.onPostDraw();
mHardwareLayer.end(currentCanvas);
mAttachInfo.mHardwareCanvas = currentCanvas;
+ mLocalDirtyRect.setEmpty();
}
}
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index edfef7694a12..5d5a09a484d2 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -3487,16 +3487,19 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
if (child.mLayerType != LAYER_TYPE_NONE) {
mPrivateFlags |= INVALIDATED;
mPrivateFlags &= ~DRAWING_CACHE_VALID;
+ child.mLocalDirtyRect.setEmpty();
}
do {
View view = null;
if (parent instanceof View) {
view = (View) parent;
- if (view.mLayerType != LAYER_TYPE_NONE &&
- view.getParent() instanceof View) {
- final View grandParent = (View) view.getParent();
- grandParent.mPrivateFlags |= INVALIDATED;
- grandParent.mPrivateFlags &= ~DRAWING_CACHE_VALID;
+ if (view.mLayerType != LAYER_TYPE_NONE) {
+ view.mLocalDirtyRect.setEmpty();
+ if (view.getParent() instanceof View) {
+ final View grandParent = (View) view.getParent();
+ grandParent.mPrivateFlags |= INVALIDATED;
+ grandParent.mPrivateFlags &= ~DRAWING_CACHE_VALID;
+ }
}
if ((view.mPrivateFlags & DIRTY_MASK) != 0) {
// already marked dirty - we're done
@@ -3550,7 +3553,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
if (child.mLayerType != LAYER_TYPE_NONE) {
mPrivateFlags |= INVALIDATED;
mPrivateFlags &= ~DRAWING_CACHE_VALID;
- }
+ child.mLocalDirtyRect.union(dirty);
+ }
+
do {
View view = null;
if (parent instanceof View) {
@@ -3631,6 +3636,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
location[CHILD_LEFT_INDEX] = left;
location[CHILD_TOP_INDEX] = top;
+ if (mLayerType != LAYER_TYPE_NONE) {
+ mLocalDirtyRect.union(dirty);
+ }
+
return mParent;
}
} else {
@@ -3639,8 +3648,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
location[CHILD_LEFT_INDEX] = mLeft;
location[CHILD_TOP_INDEX] = mTop;
- dirty.set(0, 0, mRight - location[CHILD_LEFT_INDEX],
- mBottom - location[CHILD_TOP_INDEX]);
+ dirty.set(0, 0, mRight - mLeft, mBottom - mTop);
+
+ if (mLayerType != LAYER_TYPE_NONE) {
+ mLocalDirtyRect.union(dirty);
+ }
return mParent;
}