From e32639616a4ffa7ff9230faa4c281c246f4eaafe Mon Sep 17 00:00:00 2001 From: John Reck Date: Thu, 1 Sep 2022 14:00:22 -0400 Subject: [PATCH] Somewhat improve software drawing Fix that adjustPan wasn't working Bug: 184417683 Test: repro APK Change-Id: I245b266ab13f3d404553c734e933d8f856fe2619 --- core/java/android/view/ViewRootImpl.java | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 674f0a2832732..7354141f0f234 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -2064,6 +2064,7 @@ public final class ViewRootImpl implements ViewParent, } private void invalidateRectOnScreen(Rect dirty) { + if (DEBUG_DRAW) Log.v(mTag, "invalidateRectOnScreen: " + dirty); final Rect localDirty = mDirty; // Add the new dirty rect to the current one @@ -4756,25 +4757,8 @@ public final class ViewRootImpl implements ViewParent, // Draw with software renderer. final Canvas canvas; - // We already have the offset of surfaceInsets in xoff, yoff and dirty region, - // therefore we need to add it back when moving the dirty region. - int dirtyXOffset = xoff; - int dirtyYOffset = yoff; - if (surfaceInsets != null) { - dirtyXOffset += surfaceInsets.left; - dirtyYOffset += surfaceInsets.top; - } - try { - dirty.offset(-dirtyXOffset, -dirtyYOffset); - final int left = dirty.left; - final int top = dirty.top; - final int right = dirty.right; - final int bottom = dirty.bottom; - canvas = mSurface.lockCanvas(dirty); - - // TODO: Do this in native canvas.setDensity(mDensity); } catch (Surface.OutOfResourcesException e) { handleOutOfResourcesException(e); @@ -4786,14 +4770,13 @@ public final class ViewRootImpl implements ViewParent, // kill stuff (or ourself) for no reason. mLayoutRequested = true; // ask wm for a new surface next time. return false; - } finally { - dirty.offset(dirtyXOffset, dirtyYOffset); // Reset to the original value. } try { if (DEBUG_ORIENTATION || DEBUG_DRAW) { Log.v(mTag, "Surface " + surface + " drawing to bitmap w=" - + canvas.getWidth() + ", h=" + canvas.getHeight()); + + canvas.getWidth() + ", h=" + canvas.getHeight() + ", dirty: " + dirty + + ", xOff=" + xoff + ", yOff=" + yoff); //canvas.drawARGB(255, 255, 0, 0); }