summaryrefslogtreecommitdiffstats
path: root/core/java/android/view
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-04-26 15:19:26 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-04-26 15:19:26 -0700
commitcbb02b9a66c6fa6f68aa3542b64c8ad578007f15 (patch)
tree4c27aedb7a19cdc81e9103f4828038d599080a36 /core/java/android/view
parent6dee0a3fac648a82ae998348b6673cb7823bd15d (diff)
parent62801264e3ea82dc338dbb28e38902a97ee27df4 (diff)
downloadframeworks_base-cbb02b9a66c6fa6f68aa3542b64c8ad578007f15.zip
frameworks_base-cbb02b9a66c6fa6f68aa3542b64c8ad578007f15.tar.gz
frameworks_base-cbb02b9a66c6fa6f68aa3542b64c8ad578007f15.tar.bz2
am 62801264: Merge "fix [2615973] ViewRoot locks the Surface even when the dirty region is empty" into kraken
Diffstat (limited to 'core/java/android/view')
-rw-r--r--core/java/android/view/ViewRoot.java170
1 files changed, 86 insertions, 84 deletions
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index bf94707..c2c57bb 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -1332,103 +1332,105 @@ public final class ViewRoot extends Handler implements ViewParent,
appScale + ", width=" + mWidth + ", height=" + mHeight);
}
- Canvas canvas;
- try {
- int left = dirty.left;
- int top = dirty.top;
- int right = dirty.right;
- int bottom = dirty.bottom;
- canvas = surface.lockCanvas(dirty);
-
- if (left != dirty.left || top != dirty.top || right != dirty.right ||
- bottom != dirty.bottom) {
- mAttachInfo.mIgnoreDirtyState = true;
- }
-
- // TODO: Do this in native
- canvas.setDensity(mDensity);
- } catch (Surface.OutOfResourcesException e) {
- Log.e("ViewRoot", "OutOfResourcesException locking surface", e);
- // TODO: we should ask the window manager to do something!
- // for now we just do nothing
- return;
- } catch (IllegalArgumentException e) {
- Log.e("ViewRoot", "IllegalArgumentException locking surface", e);
- // TODO: we should ask the window manager to do something!
- // for now we just do nothing
- return;
- }
+ if (!dirty.isEmpty() || mIsAnimating) {
+ Canvas canvas;
+ try {
+ int left = dirty.left;
+ int top = dirty.top;
+ int right = dirty.right;
+ int bottom = dirty.bottom;
+ canvas = surface.lockCanvas(dirty);
+
+ if (left != dirty.left || top != dirty.top || right != dirty.right ||
+ bottom != dirty.bottom) {
+ mAttachInfo.mIgnoreDirtyState = true;
+ }
- try {
- if (!dirty.isEmpty() || mIsAnimating) {
- long startTime = 0L;
+ // TODO: Do this in native
+ canvas.setDensity(mDensity);
+ } catch (Surface.OutOfResourcesException e) {
+ Log.e("ViewRoot", "OutOfResourcesException locking surface", e);
+ // TODO: we should ask the window manager to do something!
+ // for now we just do nothing
+ return;
+ } catch (IllegalArgumentException e) {
+ Log.e("ViewRoot", "IllegalArgumentException locking surface", e);
+ // TODO: we should ask the window manager to do something!
+ // for now we just do nothing
+ return;
+ }
- if (DEBUG_ORIENTATION || DEBUG_DRAW) {
- Log.v("ViewRoot", "Surface " + surface + " drawing to bitmap w="
- + canvas.getWidth() + ", h=" + canvas.getHeight());
- //canvas.drawARGB(255, 255, 0, 0);
- }
+ try {
+ if (!dirty.isEmpty() || mIsAnimating) {
+ long startTime = 0L;
- if (Config.DEBUG && ViewDebug.profileDrawing) {
- startTime = SystemClock.elapsedRealtime();
- }
+ if (DEBUG_ORIENTATION || DEBUG_DRAW) {
+ Log.v("ViewRoot", "Surface " + surface + " drawing to bitmap w="
+ + canvas.getWidth() + ", h=" + canvas.getHeight());
+ //canvas.drawARGB(255, 255, 0, 0);
+ }
- // If this bitmap's format includes an alpha channel, we
- // need to clear it before drawing so that the child will
- // properly re-composite its drawing on a transparent
- // background. This automatically respects the clip/dirty region
- // or
- // If we are applying an offset, we need to clear the area
- // where the offset doesn't appear to avoid having garbage
- // left in the blank areas.
- if (!canvas.isOpaque() || yoff != 0) {
- canvas.drawColor(0, PorterDuff.Mode.CLEAR);
- }
+ if (Config.DEBUG && ViewDebug.profileDrawing) {
+ startTime = SystemClock.elapsedRealtime();
+ }
- dirty.setEmpty();
- mIsAnimating = false;
- mAttachInfo.mDrawingTime = SystemClock.uptimeMillis();
- mView.mPrivateFlags |= View.DRAWN;
+ // If this bitmap's format includes an alpha channel, we
+ // need to clear it before drawing so that the child will
+ // properly re-composite its drawing on a transparent
+ // background. This automatically respects the clip/dirty region
+ // or
+ // If we are applying an offset, we need to clear the area
+ // where the offset doesn't appear to avoid having garbage
+ // left in the blank areas.
+ if (!canvas.isOpaque() || yoff != 0) {
+ canvas.drawColor(0, PorterDuff.Mode.CLEAR);
+ }
- if (DEBUG_DRAW) {
- Context cxt = mView.getContext();
- Log.i(TAG, "Drawing: package:" + cxt.getPackageName() +
- ", metrics=" + cxt.getResources().getDisplayMetrics() +
- ", compatibilityInfo=" + cxt.getResources().getCompatibilityInfo());
- }
- int saveCount = canvas.save(Canvas.MATRIX_SAVE_FLAG);
- try {
- canvas.translate(0, -yoff);
- if (mTranslator != null) {
- mTranslator.translateCanvas(canvas);
+ dirty.setEmpty();
+ mIsAnimating = false;
+ mAttachInfo.mDrawingTime = SystemClock.uptimeMillis();
+ mView.mPrivateFlags |= View.DRAWN;
+
+ if (DEBUG_DRAW) {
+ Context cxt = mView.getContext();
+ Log.i(TAG, "Drawing: package:" + cxt.getPackageName() +
+ ", metrics=" + cxt.getResources().getDisplayMetrics() +
+ ", compatibilityInfo=" + cxt.getResources().getCompatibilityInfo());
+ }
+ int saveCount = canvas.save(Canvas.MATRIX_SAVE_FLAG);
+ try {
+ canvas.translate(0, -yoff);
+ if (mTranslator != null) {
+ mTranslator.translateCanvas(canvas);
+ }
+ canvas.setScreenDensity(scalingRequired
+ ? DisplayMetrics.DENSITY_DEVICE : 0);
+ mView.draw(canvas);
+ } finally {
+ mAttachInfo.mIgnoreDirtyState = false;
+ canvas.restoreToCount(saveCount);
}
- canvas.setScreenDensity(scalingRequired
- ? DisplayMetrics.DENSITY_DEVICE : 0);
- mView.draw(canvas);
- } finally {
- mAttachInfo.mIgnoreDirtyState = false;
- canvas.restoreToCount(saveCount);
- }
- if (Config.DEBUG && ViewDebug.consistencyCheckEnabled) {
- mView.dispatchConsistencyCheck(ViewDebug.CONSISTENCY_DRAWING);
- }
+ if (Config.DEBUG && ViewDebug.consistencyCheckEnabled) {
+ mView.dispatchConsistencyCheck(ViewDebug.CONSISTENCY_DRAWING);
+ }
- if (SHOW_FPS || Config.DEBUG && ViewDebug.showFps) {
- int now = (int)SystemClock.elapsedRealtime();
- if (sDrawTime != 0) {
- nativeShowFPS(canvas, now - sDrawTime);
+ if (SHOW_FPS || Config.DEBUG && ViewDebug.showFps) {
+ int now = (int)SystemClock.elapsedRealtime();
+ if (sDrawTime != 0) {
+ nativeShowFPS(canvas, now - sDrawTime);
+ }
+ sDrawTime = now;
}
- sDrawTime = now;
- }
- if (Config.DEBUG && ViewDebug.profileDrawing) {
- EventLog.writeEvent(60000, SystemClock.elapsedRealtime() - startTime);
+ if (Config.DEBUG && ViewDebug.profileDrawing) {
+ EventLog.writeEvent(60000, SystemClock.elapsedRealtime() - startTime);
+ }
}
- }
- } finally {
- surface.unlockCanvasAndPost(canvas);
+ } finally {
+ surface.unlockCanvasAndPost(canvas);
+ }
}
if (LOCAL_LOGV) {