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

Commit 64801670 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Skip hardware bitmaps if canvas does not support hardware acceleration"

parents e9053378 87a3b395
Loading
Loading
Loading
Loading
+11 −2
Original line number Original line Diff line number Diff line
@@ -82,7 +82,12 @@ public class ShadowKeyDrawable extends Drawable {
        if (bounds.isEmpty()) {
        if (bounds.isEmpty()) {
            return;
            return;
        }
        }
        if (mState.mLastDrawnBitmap == null) {

        // If no cache or previous cached bitmap is hardware/software acceleration does not match
        // the current canvas on draw then regenerate
        if (mState.mLastDrawnBitmap == null
                || mState.mIsHardwareBitmap != canvas.isHardwareAccelerated()) {
            mState.mIsHardwareBitmap = canvas.isHardwareAccelerated();
            regenerateBitmapCache();
            regenerateBitmapCache();
        }
        }
        canvas.drawBitmap(mState.mLastDrawnBitmap, null, bounds, mPaint);
        canvas.drawBitmap(mState.mLastDrawnBitmap, null, bounds, mPaint);
@@ -171,7 +176,10 @@ public class ShadowKeyDrawable extends Drawable {
            d.draw(canvas);
            d.draw(canvas);
        }
        }


        if (mState.mIsHardwareBitmap) {
            bitmap = bitmap.copy(Bitmap.Config.HARDWARE, false);
            bitmap = bitmap.copy(Bitmap.Config.HARDWARE, false);
        }

        mState.mLastDrawnBitmap = bitmap;
        mState.mLastDrawnBitmap = bitmap;
        canvas.restore();
        canvas.restore();
    }
    }
@@ -186,6 +194,7 @@ public class ShadowKeyDrawable extends Drawable {
        int mShadowSize;
        int mShadowSize;
        int mShadowColor;
        int mShadowColor;


        boolean mIsHardwareBitmap;
        Bitmap mLastDrawnBitmap;
        Bitmap mLastDrawnBitmap;
        ConstantState mChildState;
        ConstantState mChildState;