From 3e361da40d01e77cb8a7e5a5fe2975bfb4b19517 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Tue, 5 Mar 2019 08:01:06 -0800 Subject: [PATCH] Ensure Bitmap.Config.ARGB_8888 before blurring RenderScript needs this Bitmap format, otherwise channels will be mixed up Bug: 124466617 Test: visual Change-Id: Ib7e436d0e8f2d81b3f3c1b58c4e6052b194ec8e4 --- .../android/systemui/statusbar/MediaArtworkProcessor.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt index 52b8cc2b685b7..b7ae4edc15220 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt @@ -51,8 +51,15 @@ class MediaArtworkProcessor @Inject constructor() { val renderScript = RenderScript.create(context) val rect = Rect(0, 0, artwork.width, artwork.height) MathUtils.fitRect(rect, Math.max(mTmpSize.x / DOWNSAMPLE, mTmpSize.y / DOWNSAMPLE)) - val inBitmap = Bitmap.createScaledBitmap(artwork, rect.width(), rect.height(), + var inBitmap = Bitmap.createScaledBitmap(artwork, rect.width(), rect.height(), true /* filter */) + // Render script blurs only support ARGB_8888, we need a conversion if we got a + // different bitmap config. + if (inBitmap.config != Bitmap.Config.ARGB_8888) { + val oldIn = inBitmap + inBitmap = oldIn.copy(Bitmap.Config.ARGB_8888, false /* isMutable */) + oldIn.recycle() + } val input = Allocation.createFromBitmap(renderScript, inBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE) val outBitmap = Bitmap.createBitmap(inBitmap.width, inBitmap.height,