@@ -29,11 +29,11 @@ internal class SVGACanvasDrawer(videoItem: SVGAVideoEntity, val dynamicItem: SVG
2929 this .pathCache.onSizeChanged(canvas)
3030 val sprites = requestFrameSprites(frameIndex)
3131 val matteSprites = mutableMapOf<String , SVGADrawerSprite >()
32- var saveID = 0
32+ var saveID = - 1
3333 beginIndexList = null
3434 endIndexList = null
3535
36- // Filte no matte layer
36+ // Filter no matte layer
3737 var hasMatteLayer = false
3838 sprites.get(0 ).imageKey?.let {
3939 if (it.endsWith(" .matte" )) {
@@ -42,10 +42,10 @@ internal class SVGACanvasDrawer(videoItem: SVGAVideoEntity, val dynamicItem: SVG
4242 }
4343 sprites.forEachIndexed { index, svgaDrawerSprite ->
4444
45- // save matte sprite
45+ // Save matte sprite
4646 svgaDrawerSprite.imageKey?.let {
47- // / No matte layer included
48- if (! hasMatteLayer) {
47+ // / No matte layer included or VERSION Unsopport matte
48+ if (! hasMatteLayer || Build . VERSION . SDK_INT < Build . VERSION_CODES . LOLLIPOP ) {
4949 // Normal sprite
5050 drawSprite(svgaDrawerSprite, canvas, frameIndex)
5151 // Continue
@@ -62,6 +62,8 @@ internal class SVGACanvasDrawer(videoItem: SVGAVideoEntity, val dynamicItem: SVG
6262 if (isMatteBegin(index, sprites)) {
6363 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
6464 saveID = canvas.saveLayer(0f , 0f , canvas.width.toFloat(), canvas.height.toFloat(), null )
65+ } else {
66+ canvas.save()
6567 }
6668 }
6769 // / Normal matte
@@ -72,7 +74,11 @@ internal class SVGACanvasDrawer(videoItem: SVGAVideoEntity, val dynamicItem: SVG
7274 matteSprites.get(svgaDrawerSprite.matteKey)?.let {
7375 drawSprite(it, this .sharedValues.shareMatteCanvas(canvas.width, canvas.height), frameIndex)
7476 canvas.drawBitmap(this .sharedValues.sharedMatteBitmap(), 0f , 0f , this .sharedValues.shareMattePaint())
75- canvas.restoreToCount(saveID)
77+ if (saveID != - 1 ) {
78+ canvas.restoreToCount(saveID)
79+ } else {
80+ canvas.restore()
81+ }
7682 // Continue
7783 return @forEachIndexed
7884 }
0 commit comments