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

Commit aa23a487 authored by Prashanth Swaminathan's avatar Prashanth Swaminathan Committed by Automerger Merge Worker
Browse files

Merge "Revert "Use toolkit instead of renderscript in SystemUI"" am:...

Merge "Revert "Use toolkit instead of renderscript in SystemUI"" am: 1e49f5d2 am: 7fd50e05 am: 10df77f0

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2495538



Change-Id: I231b6bc5117903e4ed899da5729a0722f688b0b3
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents ab2a2b61 10df77f0
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -195,7 +195,6 @@ android_library {
        "lottie",
        "LowLightDreamLib",
        "motion_tool_lib",
        "renderscript_toolkit",
    ],
    manifest: "AndroidManifest.xml",

@@ -329,7 +328,6 @@ android_library {
        "WindowManager-Shell",
        "LowLightDreamLib",
        "motion_tool_lib",
        "renderscript_toolkit",
        "androidx.core_core-animation-testing-nodeps",
        "androidx.compose.ui_ui",
    ],
+24 −4
Original line number Diff line number Diff line
@@ -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()
        }
    }