CMP catalog

This commit is contained in:
Kyant0 committed 2026-02-15 13:54:20 +08:00
1 parent 978adadd21
commit 001da68aca
65 files changed
+70 -3656

No files matched your search

+1 -1
View File
@@ -84,7 +84,7 @@ mavenPublishing {
publishToMavenCentral()
signAllPublications()
coordinates("io.github.kyant0", "backdrop", "2.0.0-alpha03")
coordinates("io.github.kyant0", "backdrop", "2.0.0-alpha04")
pom {
name.set("Backdrop")
@@ -0,0 +1,10 @@
package com.kyant.backdrop
import android.os.Build
import androidx.annotation.ChecksSdkIntAtLeast
@ChecksSdkIntAtLeast(Build.VERSION_CODES.S)
actual fun isRenderEffectSupported(): Boolean = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
@ChecksSdkIntAtLeast(Build.VERSION_CODES.TIRAMISU)
actual fun isRuntimeShaderSupported(): Boolean = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
@@ -3,6 +3,7 @@ package com.kyant.backdrop
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shader
import androidx.compose.ui.graphics.toArgb
import org.intellij.lang.annotations.Language
@@ -12,6 +13,10 @@ actual fun RuntimeShader(@Language("AGSL") shaderString: String): RuntimeShader
return AndroidRuntimeShader(shader)
}
actual fun RuntimeShader.asComposeShader(): Shader {
return this.asAndroidRuntimeShader()
}
fun RuntimeShader.asAndroidRuntimeShader(): android.graphics.RuntimeShader {
return (this as AndroidRuntimeShader).shader
}
@@ -1,7 +0,0 @@
package com.kyant.backdrop.internal
import android.os.Build
internal actual fun isRenderEffectSupported(): Boolean = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
internal actual fun isRuntimeShaderSupported(): Boolean = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
@@ -32,7 +32,6 @@ import com.kyant.backdrop.backdrops.LayerBackdrop
import com.kyant.backdrop.highlight.Highlight
import com.kyant.backdrop.highlight.HighlightElement
import com.kyant.backdrop.internal.ShapeProvider
import com.kyant.backdrop.internal.isRenderEffectSupported
import com.kyant.backdrop.internal.recordLayer
import com.kyant.backdrop.shadow.InnerShadow
import com.kyant.backdrop.shadow.InnerShadowElement
@@ -0,0 +1,5 @@
package com.kyant.backdrop
expect fun isRenderEffectSupported(): Boolean
expect fun isRuntimeShaderSupported(): Boolean
@@ -1,10 +1,13 @@
package com.kyant.backdrop
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shader
import org.intellij.lang.annotations.Language
expect fun RuntimeShader(@Language("AGSL") shaderString: String): RuntimeShader
expect fun RuntimeShader.asComposeShader(): Shader
interface RuntimeShader {
fun setFloatUniform(name: String, value: Float)
@@ -4,7 +4,7 @@ import androidx.annotation.FloatRange
import androidx.compose.ui.graphics.BlurEffect
import androidx.compose.ui.graphics.TileMode
import com.kyant.backdrop.BackdropEffectScope
import com.kyant.backdrop.internal.isRenderEffectSupported
import com.kyant.backdrop.isRenderEffectSupported
fun BackdropEffectScope.blur(
@FloatRange(from = 0.0) radius: Float,
@@ -6,7 +6,7 @@ import androidx.compose.ui.graphics.ColorMatrix
import androidx.compose.ui.graphics.ColorMatrixColorFilter
import com.kyant.backdrop.BackdropEffectScope
import com.kyant.backdrop.internal.ColorFilterEffect
import com.kyant.backdrop.internal.isRenderEffectSupported
import com.kyant.backdrop.isRenderEffectSupported
fun BackdropEffectScope.colorFilter(colorFilter: ColorFilter) {
if (!isRenderEffectSupported()) return
@@ -10,7 +10,7 @@ import com.kyant.backdrop.BackdropEffectScope
import com.kyant.backdrop.internal.RoundedRectRefractionShaderString
import com.kyant.backdrop.internal.RoundedRectRefractionWithDispersionShaderString
import com.kyant.backdrop.internal.RuntimeShaderEffect
import com.kyant.backdrop.internal.isRuntimeShaderSupported
import com.kyant.backdrop.isRuntimeShaderSupported
import com.kyant.shapes.RoundedRectangularShape
fun BackdropEffectScope.lens(
@@ -5,8 +5,8 @@ import com.kyant.backdrop.BackdropEffectScope
import com.kyant.backdrop.RuntimeShader
import com.kyant.backdrop.internal.RuntimeShaderEffect
import com.kyant.backdrop.internal.chain
import com.kyant.backdrop.internal.isRenderEffectSupported
import com.kyant.backdrop.internal.isRuntimeShaderSupported
import com.kyant.backdrop.isRenderEffectSupported
import com.kyant.backdrop.isRuntimeShaderSupported
import org.intellij.lang.annotations.Language
import kotlin.contracts.ExperimentalContracts
@@ -23,8 +23,8 @@ import com.kyant.backdrop.RuntimeShaderCacheImpl
import com.kyant.backdrop.internal.ShapeProvider
import com.kyant.backdrop.internal.blur
import com.kyant.backdrop.internal.clipOutline
import com.kyant.backdrop.internal.isRuntimeShaderSupported
import com.kyant.backdrop.internal.setRuntimeShader
import com.kyant.backdrop.isRuntimeShaderSupported
import kotlin.math.ceil
internal class HighlightElement(
@@ -14,7 +14,7 @@ import com.kyant.backdrop.RuntimeShader
import com.kyant.backdrop.RuntimeShaderCache
import com.kyant.backdrop.internal.AmbientHighlightShaderString
import com.kyant.backdrop.internal.DefaultHighlightShaderString
import com.kyant.backdrop.internal.isRuntimeShaderSupported
import com.kyant.backdrop.isRuntimeShaderSupported
import kotlin.math.PI
@Immutable
@@ -1,5 +0,0 @@
package com.kyant.backdrop.internal
internal expect fun isRenderEffectSupported(): Boolean
internal expect fun isRuntimeShaderSupported(): Boolean
@@ -21,7 +21,7 @@ import androidx.compose.ui.platform.InspectorInfo
import androidx.compose.ui.unit.Density
import com.kyant.backdrop.internal.ShapeProvider
import com.kyant.backdrop.internal.clipOutline
import com.kyant.backdrop.internal.isRenderEffectSupported
import com.kyant.backdrop.isRenderEffectSupported
internal class InnerShadowElement(
val shapeProvider: ShapeProvider,
@@ -0,0 +1,5 @@
package com.kyant.backdrop
actual fun isRenderEffectSupported(): Boolean = true
actual fun isRuntimeShaderSupported(): Boolean = true
@@ -1,6 +1,7 @@
package com.kyant.backdrop
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shader
import androidx.compose.ui.graphics.colorspace.ColorSpaces
import org.intellij.lang.annotations.Language
import org.jetbrains.skia.RuntimeEffect
@@ -11,6 +12,10 @@ actual fun RuntimeShader(@Language("AGSL") shaderString: String): RuntimeShader
return SkikoRuntimeShader(shader)
}
actual fun RuntimeShader.asComposeShader(): Shader {
return this.asSkikoRuntimeShader().makeShader()
}
fun RuntimeShader.asSkikoRuntimeShader(): RuntimeShaderBuilder {
return (this as SkikoRuntimeShader).shader
}
@@ -59,6 +64,7 @@ internal class SkikoRuntimeShader(val shader: RuntimeShaderBuilder) : RuntimeSha
override fun setColorUniform(name: String, color: Color) {
val srgb = color.convert(ColorSpaces.Srgb)
shader.uniform(name, srgb.red, srgb.green, srgb.blue, srgb.alpha)
val a = srgb.alpha
shader.uniform(name, srgb.red * a, srgb.green * a, srgb.blue * a, a)
}
}
@@ -1,5 +0,0 @@
package com.kyant.backdrop.internal
internal actual fun isRenderEffectSupported(): Boolean = true
internal actual fun isRuntimeShaderSupported(): Boolean = true