From 87a3b3958c30da58d871cd3355c6f8f1ac04a5e7 Mon Sep 17 00:00:00 2001 From: Matthew Ng Date: Thu, 28 Jun 2018 13:05:30 -0700 Subject: [PATCH] Skip hardware bitmaps if canvas does not support hardware acceleration Test: use go/web-hv on nav bar Change-Id: Id7d5f01aa0dbe9d05d0526726f64fc5233b9f563 Fixes: 110949540 --- .../android/systemui/statusbar/phone/ShadowKeyDrawable.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadowKeyDrawable.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadowKeyDrawable.java index 8311dfd64fd2..2471e34a5a11 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadowKeyDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ShadowKeyDrawable.java @@ -82,7 +82,12 @@ public class ShadowKeyDrawable extends Drawable { if (bounds.isEmpty()) { 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(); } canvas.drawBitmap(mState.mLastDrawnBitmap, null, bounds, mPaint); @@ -171,7 +176,10 @@ public class ShadowKeyDrawable extends Drawable { d.draw(canvas); } - bitmap = bitmap.copy(Bitmap.Config.HARDWARE, false); + if (mState.mIsHardwareBitmap) { + bitmap = bitmap.copy(Bitmap.Config.HARDWARE, false); + } + mState.mLastDrawnBitmap = bitmap; canvas.restore(); } @@ -186,6 +194,7 @@ public class ShadowKeyDrawable extends Drawable { int mShadowSize; int mShadowColor; + boolean mIsHardwareBitmap; Bitmap mLastDrawnBitmap; ConstantState mChildState; -- 2.11.0