Rename SimpleGraphicsLayerScope with InverseLayerScope
This commit is contained in:
1 parent
1a2e29a07e
commit
11b03cdbb5
3 files changed
+10
-10
No files matched your search
@@ -39,7 +39,7 @@ class Backdrop internal constructor(
|
||||
|
||||
internal var backdropCoordinates: LayoutCoordinates? by mutableStateOf(null)
|
||||
|
||||
private var layerScope: SimpleGraphicsLayerScope? = null
|
||||
private var inverseLayerScope: InverseLayerScope? = null
|
||||
|
||||
internal fun DrawScope.drawBackdrop(
|
||||
coordinates: LayoutCoordinates,
|
||||
@@ -50,8 +50,8 @@ class Backdrop internal constructor(
|
||||
val layerBlock = layerBlock
|
||||
if (layerBlock != null) {
|
||||
withTransform({
|
||||
val layerScope = layerScope ?: SimpleGraphicsLayerScope().also { layerScope = it }
|
||||
with(layerScope) { inverseTransform(this@drawBackdrop, layerBlock) }
|
||||
val inverseLayerScope = inverseLayerScope ?: InverseLayerScope().also { inverseLayerScope = it }
|
||||
with(inverseLayerScope) { inverseTransform(scope = this@drawBackdrop, layerBlock = layerBlock) }
|
||||
translate(-offset.x, -offset.y)
|
||||
}) {
|
||||
drawLayer(graphicsLayer)
|
||||
|
||||
@@ -174,7 +174,7 @@ private class ContentBackdropNode(
|
||||
compositingStrategy = androidx.compose.ui.graphics.CompositingStrategy.Offscreen
|
||||
}
|
||||
|
||||
private var layerScope: SimpleGraphicsLayerScope? = null
|
||||
private var inverseLayerScope: InverseLayerScope? = null
|
||||
|
||||
override fun MeasureScope.measure(
|
||||
measurable: Measurable,
|
||||
@@ -205,8 +205,8 @@ private class ContentBackdropNode(
|
||||
val layerBlock = layerBlock
|
||||
if (layerBlock != null) {
|
||||
withTransform({
|
||||
val layerScope = layerScope ?: SimpleGraphicsLayerScope().also { layerScope = it }
|
||||
with(layerScope) { inverseTransform(this@draw, layerBlock) }
|
||||
val inverseLayerScope = inverseLayerScope ?: InverseLayerScope().also { inverseLayerScope = it }
|
||||
with(inverseLayerScope) { inverseTransform(scope = this@draw, layerBlock = layerBlock) }
|
||||
}) {
|
||||
drawLayer(layer)
|
||||
}
|
||||
|
||||
+4
-4
@@ -18,7 +18,7 @@ import kotlin.math.PI
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
internal class SimpleGraphicsLayerScope : GraphicsLayerScope {
|
||||
internal class InverseLayerScope : GraphicsLayerScope {
|
||||
|
||||
override var size: Size = Size.Unspecified
|
||||
override var density: Float = 1f
|
||||
@@ -50,7 +50,7 @@ internal class SimpleGraphicsLayerScope : GraphicsLayerScope {
|
||||
scope: DrawScope,
|
||||
layerBlock: GraphicsLayerScope.() -> Unit
|
||||
) {
|
||||
this@SimpleGraphicsLayerScope.size = scope.size
|
||||
this@InverseLayerScope.size = scope.size
|
||||
density = scope.density
|
||||
fontScale = scope.fontScale
|
||||
|
||||
@@ -88,8 +88,8 @@ internal class SimpleGraphicsLayerScope : GraphicsLayerScope {
|
||||
val a11 = rcz * scaleY
|
||||
|
||||
val det = a00 * a11 - a01 * a10
|
||||
if (det == 0.0f) return
|
||||
val invDet = 1.0f / det
|
||||
if (det == 0f) return
|
||||
val invDet = 1f / det
|
||||
matrix[0, 0] = a11 * invDet
|
||||
matrix[0, 1] = -a01 * invDet
|
||||
matrix[1, 0] = -a10 * invDet
|
||||
Reference in new issue
Block a user