Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8966e12 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 4008 into donut

* changes:
  Fixes #1886237. Views drawing cache was not generated properly.
parents f229aff1 8506ab4a
Loading
Loading
Loading
Loading
+64 −39
Original line number Diff line number Diff line
@@ -5868,8 +5868,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
                EventLog.writeEvent(60002, hashCode());
            }

            final int width = mRight - mLeft;
            final int height = mBottom - mTop;
            int width = mRight - mLeft;
            int height = mBottom - mTop;

            final AttachInfo attachInfo = mAttachInfo;
            if (attachInfo != null) {
                final boolean scalingRequired = attachInfo.mScalingRequired;
                if (scalingRequired) {
                    width = (int) ((width * attachInfo.mApplicationScale) + 0.5f);
                    height = (int) ((height * attachInfo.mApplicationScale) + 0.5f);
                }
            }

            final int drawingCacheBackgroundColor = mDrawingCacheBackgroundColor;
            final boolean opaque = drawingCacheBackgroundColor != 0 ||
@@ -5925,11 +5934,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
            }

            Canvas canvas;
            final AttachInfo attachInfo = mAttachInfo;
            if (attachInfo != null) {
                canvas = attachInfo.mCanvas;
                if (canvas == null) {
                    canvas = new Canvas();

                    // NOTE: This should have to happen only once since compatibility
                    //       mode should not change at runtime
                    if (attachInfo.mScalingRequired) {
                        final float scale = attachInfo.mApplicationScale;
                        canvas.scale(scale, scale);
                    }
                }
                canvas.setBitmap(bitmap);
                // Temporarily clobber the cached Canvas in case one of our children
@@ -8452,6 +8467,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
        IBinder mPanelParentWindowToken;
        Surface mSurface;

        /**
         * Scale factor used by the compatibility mode
         */
        float mApplicationScale;

        /**
         * Indicates whether the application is in compatibility mode
         */
        boolean mScalingRequired;

        /**
         * Left position of this view's window
         */
+38 −28
Original line number Diff line number Diff line
@@ -1444,10 +1444,12 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        final int sx = child.mScrollX;
        final int sy = child.mScrollY;

        boolean scalingRequired = false;
        Bitmap cache = null;
        if ((flags & FLAG_CHILDREN_DRAWN_WITH_CACHE) == FLAG_CHILDREN_DRAWN_WITH_CACHE ||
                (flags & FLAG_ALWAYS_DRAWN_WITH_CACHE) == FLAG_ALWAYS_DRAWN_WITH_CACHE) {
            cache = child.getDrawingCache();
            scalingRequired = mAttachInfo.mScalingRequired;
        }

        final boolean hasNoCache = cache == null;
@@ -1457,6 +1459,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
            canvas.translate(cl - sx, ct - sy);
        } else {
            canvas.translate(cl, ct);
            if (scalingRequired) {
                final float scale = 1.0f / mAttachInfo.mApplicationScale;
                canvas.scale(scale, scale);
            }
        }

        float alpha = 1.0f;
@@ -1499,7 +1505,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
            if (hasNoCache) {
                canvas.clipRect(sx, sy, sx + (cr - cl), sy + (cb - ct));
            } else {
                if (!scalingRequired) {
                    canvas.clipRect(0, 0, cr - cl, cb - ct);
                } else {
                    canvas.clipRect(0, 0, cache.getWidth(), cache.getHeight());
                }
            }
        }

+72 −70
Original line number Diff line number Diff line
@@ -399,6 +399,8 @@ public final class ViewRoot extends Handler implements ViewParent,
                mSoftInputMode = attrs.softInputMode;
                mWindowAttributesChanged = true;
                mAttachInfo.mRootView = view;
                mAttachInfo.mScalingRequired = mCompatibilityInfo.mScalingRequired;
                mAttachInfo.mApplicationScale = mCompatibilityInfo.mApplicationScale;
                if (panelParentView != null) {
                    mAttachInfo.mPanelParentWindowToken
                            = panelParentView.getApplicationWindowToken();