diff --git a/compottie/src/commonMain/kotlin/io/github/alexzhirkevich/compottie/internal/layers/BaseLayer.kt b/compottie/src/commonMain/kotlin/io/github/alexzhirkevich/compottie/internal/layers/BaseLayer.kt index c4026749..6777e5fd 100644 --- a/compottie/src/commonMain/kotlin/io/github/alexzhirkevich/compottie/internal/layers/BaseLayer.kt +++ b/compottie/src/commonMain/kotlin/io/github/alexzhirkevich/compottie/internal/layers/BaseLayer.kt @@ -147,46 +147,45 @@ internal abstract class BaseLayer : Layer { parentAlpha: Float, state: AnimationState, ) { - try { - state.onLayer(this) { + state.onLayer(this) { - if (!isActive(state)) - return@onLayer + if (!isActive(state)) + return@onLayer - buildParentLayerListIfNeeded() + buildParentLayerListIfNeeded() - matrix.fastSetFrom(parentMatrix) - parentLayers?.fastForEachReversed { - matrix.preConcat(it.transform.matrix(state)) - } + matrix.fastSetFrom(parentMatrix) + parentLayers?.fastForEachReversed { + matrix.preConcat(it.transform.matrix(state)) + } - var alpha = 1f + var alpha = 1f - transform.opacity.interpolatedNorm(state).let { - alpha = (alpha * it).coerceIn(0f, 1f) - } + transform.opacity.interpolatedNorm(state).let { + alpha = (alpha * it).coerceIn(0f, 1f) + } - alpha = (alpha * parentAlpha.coerceIn(0f, 1f)) + alpha = (alpha * parentAlpha.coerceIn(0f, 1f)) - if (matteLayer == null && !hasMasks() && blendMode == LottieBlendMode.Normal) { - matrix.preConcat(transform.matrix(state)) - drawLayer(drawScope, matrix, alpha, state) - return@onLayer - } + if (matteLayer == null && !hasMasks() && blendMode == LottieBlendMode.Normal) { + matrix.preConcat(transform.matrix(state)) + drawLayer(drawScope, matrix, alpha, state) + return@onLayer + } - rect.set(0f,0f,0f,0f) - getBounds(drawScope, matrix, false, state, rect) + rect.set(0f, 0f, 0f, 0f) + getBounds(drawScope, matrix, false, state, rect) - intersectBoundsWithMatte(drawScope, rect, parentMatrix, state) + intersectBoundsWithMatte(drawScope, rect, parentMatrix, state) - matrix.preConcat(transform.matrix(state)) - intersectBoundsWithMask(rect, matrix, state) + matrix.preConcat(transform.matrix(state)) + intersectBoundsWithMask(rect, matrix, state) - // Intersect the mask and matte rect with the canvas bounds. - // If the canvas has a transform, then we need to transform its bounds by its matrix - // so that we know the coordinate space that the canvas is showing. + // Intersect the mask and matte rect with the canvas bounds. + // If the canvas has a transform, then we need to transform its bounds by its matrix + // so that we know the coordinate space that the canvas is showing. // canvasBounds.set(0f, 0f, drawScope.size.width, drawScope.size.height) - drawScope.drawIntoCanvas { canvas -> + drawScope.drawIntoCanvas { canvas -> // canvas.getMatrix(canvasMatrix) // if (!canvasMatrix.isIdentity()) { @@ -196,30 +195,30 @@ internal abstract class BaseLayer : Layer { // rect.intersectOrReset(canvasBounds) // - // Ensure that what we are drawing is >=1px of width and height. - // On older devices, drawing to an offscreen buffer of <1px would draw back as a black bar. - // https://github.com/airbnb/lottie-android/issues/1625 - if (rect.width >= 1f && rect.height >= 1f) { - contentPaint.alpha = 1f - canvas.saveLayer(rect, contentPaint) - - clearCanvas(canvas) - drawLayer(drawScope, matrix, alpha, state) - - if (hasMasks()) { - applyMasks(canvas, matrix, state) - } + // Ensure that what we are drawing is >=1px of width and height. + // On older devices, drawing to an offscreen buffer of <1px would draw back as a black bar. + // https://github.com/airbnb/lottie-android/issues/1625 + if (rect.width >= 1f && rect.height >= 1f) { + contentPaint.alpha = 1f + canvas.saveLayer(rect, contentPaint) + + clearCanvas(canvas) + drawLayer(drawScope, matrix, alpha, state) - matteLayer?.let { - canvas.saveLayer(rect, mattePaint, SAVE_FLAGS) - clearCanvas(canvas) - it.draw(drawScope, parentMatrix, alpha, state) - canvas.restore() - } + if (hasMasks()) { + applyMasks(canvas, matrix, state) + } + matteLayer?.let { + canvas.saveLayer(rect, mattePaint, SAVE_FLAGS) + clearCanvas(canvas) + it.draw(drawScope, parentMatrix, alpha, state) canvas.restore() } + canvas.restore() + } + // val outlineMasksAndMattesPaint = Paint().apply { // style = PaintingStyle.Stroke // strokeWidth = 4f @@ -229,10 +228,7 @@ internal abstract class BaseLayer : Layer { // outlineMasksAndMattesPaint.style = PaintingStyle.Fill // outlineMasksAndMattesPaint.color = Color(0x50EBEBEB) // canvas.drawRect(rect, outlineMasksAndMattesPaint) - } } - } catch (t: Throwable) { - Compottie.logger?.error("Lottie crashed in draw :(", t) } } diff --git a/convention-plugins/src/main/kotlin/root.publication.gradle.kts b/convention-plugins/src/main/kotlin/root.publication.gradle.kts index 911e4012..249d6d80 100644 --- a/convention-plugins/src/main/kotlin/root.publication.gradle.kts +++ b/convention-plugins/src/main/kotlin/root.publication.gradle.kts @@ -1,4 +1,3 @@ -import gradle.kotlin.dsl.accessors._2502cef48cff830615fe1c6d6ab5e104.ext import java.io.FileInputStream import java.util.Properties diff --git a/gradle.properties b/gradle.properties index b890fa1e..2af48bc8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ android.minSdk=21 #MPP kotlin.mpp.enableCInteropCommonization=true kotlin.mpp.androidSourceSetLayoutVersion=2 -version=2.0.0-rc01 +version=2.0.0-rc02 group=io.github.alexzhirkevich diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4a974caa..41f98907 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Mar 13 11:02:04 MSK 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME