summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Prashanth Swaminathan <prashanthsw@google.com> 2023-03-17 18:12:03 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2023-03-17 18:12:03 +0000
commit7fd50e05d59c7f12e27562f3327d5939a032f729 (patch)
treeb7d7b95200c774de248d3fa46fe66d3fc8d58f26
parent4dca7937c6a1eb3adf527a6d3674bf86b3f4e054 (diff)
parent1e49f5d23148268f22352c7ae3f8858a0f3847d2 (diff)
Merge "Revert "Use toolkit instead of renderscript in SystemUI"" am: 1e49f5d231
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2495538 Change-Id: Ida00dec3a1c5af1052936cb2cfe61fa026c711e2 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--packages/SystemUI/Android.bp2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt28
2 files changed, 24 insertions, 6 deletions
diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp
index beade793c862..cd0fbea6a2d2 100644
--- a/packages/SystemUI/Android.bp
+++ b/packages/SystemUI/Android.bp
@@ -177,7 +177,6 @@ android_library {
"lottie",
"LowLightDreamLib",
"motion_tool_lib",
- "renderscript_toolkit",
],
manifest: "AndroidManifest.xml",
@@ -271,7 +270,6 @@ android_library {
"WindowManager-Shell",
"LowLightDreamLib",
"motion_tool_lib",
- "renderscript_toolkit",
"androidx.core_core-animation-testing-nodeps",
],
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt
index dd713ae1c637..750272d65659 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt
@@ -21,17 +21,20 @@ import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Point
import android.graphics.Rect
+import android.renderscript.Allocation
+import android.renderscript.Element
+import android.renderscript.RenderScript
+import android.renderscript.ScriptIntrinsicBlur
import android.util.Log
import android.util.MathUtils
import com.android.internal.graphics.ColorUtils
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.statusbar.notification.MediaNotificationProcessor
-import com.google.android.renderscript.Toolkit
import javax.inject.Inject
private const val TAG = "MediaArtworkProcessor"
private const val COLOR_ALPHA = (255 * 0.7f).toInt()
-private const val BLUR_RADIUS = 25
+private const val BLUR_RADIUS = 25f
private const val DOWNSAMPLE = 6
@SysUISingleton
@@ -44,6 +47,10 @@ class MediaArtworkProcessor @Inject constructor() {
if (mArtworkCache != null) {
return mArtworkCache
}
+ val renderScript = RenderScript.create(context)
+ val blur = ScriptIntrinsicBlur.create(renderScript, Element.U8_4(renderScript))
+ var input: Allocation? = null
+ var output: Allocation? = null
var inBitmap: Bitmap? = null
try {
@Suppress("DEPRECATION")
@@ -59,8 +66,18 @@ class MediaArtworkProcessor @Inject constructor() {
inBitmap = oldIn.copy(Bitmap.Config.ARGB_8888, false /* isMutable */)
oldIn.recycle()
}
+ val outBitmap = Bitmap.createBitmap(inBitmap.width, inBitmap.height,
+ Bitmap.Config.ARGB_8888)
+
+ input = Allocation.createFromBitmap(renderScript, inBitmap,
+ Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE)
+ output = Allocation.createFromBitmap(renderScript, outBitmap)
+
+ blur.setRadius(BLUR_RADIUS)
+ blur.setInput(input)
+ blur.forEach(output)
+ output.copyTo(outBitmap)
- val outBitmap = Toolkit.blur(inBitmap, BLUR_RADIUS)
val swatch = MediaNotificationProcessor.findBackgroundSwatch(artwork)
val canvas = Canvas(outBitmap)
@@ -70,6 +87,9 @@ class MediaArtworkProcessor @Inject constructor() {
Log.e(TAG, "error while processing artwork", ex)
return null
} finally {
+ input?.destroy()
+ output?.destroy()
+ blur.destroy()
inBitmap?.recycle()
}
}
@@ -78,4 +98,4 @@ class MediaArtworkProcessor @Inject constructor() {
mArtworkCache?.recycle()
mArtworkCache = null
}
-}
+} \ No newline at end of file