Revert "Use toolkit instead of renderscript in SystemUI"
This reverts commit 76ddc55b97.
Reason for revert: This is breaking some Gradle builds, reverting while we figure out a more proper fix.
Change-Id: Ic6a89c805598620a36199ae66342279585221555
This commit is contained in:
committed by
Gerrit Code Review
parent
76ddc55b97
commit
4f45d483a2
@@ -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",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user