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

Verified Commit 62a6ed3e authored by Saalim Quadri's avatar Saalim Quadri
Browse files

bliss: Use RenderEffect

parent e3bd1193
Loading
Loading
Loading
Loading
+22 −22
Original line number Diff line number Diff line
@@ -19,7 +19,8 @@ package foundation.e.bliss.blur

import android.content.Context
import android.graphics.Bitmap
import com.hoko.blur.HokoBlur
import android.graphics.Canvas
import com.android.launcher3.taskbar.BlurredBitmapDrawable

class BlurWallpaperFilter(private val context: Context) :
    WallpaperFilter<BlurWallpaperProvider.BlurSizes> {
@@ -56,9 +57,7 @@ class BlurWallpaperFilter(private val context: Context) :
    }

    private fun blur(wallpaper: Bitmap, config: BlurWallpaperProvider.BlurConfig): Bitmap {
        val source =
            if (config.scale == 1) {
                // Make mutable copy in case we need to return source
        val source = if (config.scale == 1) {
            Bitmap.createBitmap(wallpaper)
        } else {
            Bitmap.createScaledBitmap(
@@ -69,18 +68,19 @@ class BlurWallpaperFilter(private val context: Context) :
            )
        }

        // Bypass blur processor if we don't need to blur (hotseat)
        // This will only happen if the input is full resolution (scale = 1) and blur radius = 0
        if (config.radius == 0 && config.scale == 1) {
            return source
        }
        return applyBlur(source, config.radius.toFloat())
    }

    private fun applyBlur(bitmap: Bitmap, radius: Float): Bitmap {
        val output = Bitmap.createBitmap(bitmap.width, bitmap.height, Bitmap.Config.ARGB_8888)
        val canvas = Canvas(output)

        return HokoBlur.with(context)
            .scheme(HokoBlur.SCHEME_NATIVE)
            .mode(HokoBlur.MODE_STACK)
            .radius(config.radius)
            .forceCopy(false)
            .processor()
            .blur(source)
        val blurredDrawable = BlurredBitmapDrawable(bitmap, radius)
        blurredDrawable.setBounds(0, 0, bitmap.width, bitmap.height)
        blurredDrawable.draw(canvas)
        return output
    }
}
+0 −6
Original line number Diff line number Diff line
@@ -35,11 +35,6 @@ java_import {
    ],
}

android_library_import {
    name: "hoko-blur",
    aars:  ["hoko-blur.aar"],
}

java_import {
    name: "librxkotlin",
    jars: [
@@ -106,7 +101,6 @@ java_library {
        "okhttp-me",
        "okhttp-log",
        "converter-gson",
        "hoko-blur",
        "librxkotlin",
        "librxjava",
        "libretrofit",

libs/hoko-blur.aar

deleted100644 → 0
−1.73 MiB

File deleted.