mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 06:14:53 +08:00
[android] Fix Canvas.drawVertices() for Android <= 9. Closes #2638
This commit is contained in:
parent
fb1cd5e161
commit
7994973a22
@ -49,6 +49,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
|
||||
/** Is responsible to transform the {@link Skeleton} with its current pose to {@link SkeletonRenderer.RenderCommand} commands and
|
||||
* render them to a {@link Canvas}. */
|
||||
@ -246,8 +247,18 @@ public class SkeletonRenderer {
|
||||
for (int i = 0; i < commands.size; i++) {
|
||||
RenderCommand command = commands.get(i);
|
||||
|
||||
canvas.drawVertices(Canvas.VertexMode.TRIANGLES, command.vertices.size, command.vertices.items, 0, command.uvs.items, 0,
|
||||
command.colors.items, 0, command.indices.items, 0, command.indices.size, command.texture.getPaint(command.blendMode));
|
||||
if (Build.VERSION.SDK_INT >= 29) {
|
||||
canvas.drawVertices(Canvas.VertexMode.TRIANGLES, command.vertices.size, command.vertices.items, 0, command.uvs.items, 0,
|
||||
command.colors.items, 0, command.indices.items, 0, command.indices.size, command.texture.getPaint(command.blendMode));
|
||||
} else {
|
||||
// See https://github.com/EsotericSoftware/spine-runtimes/issues/2638
|
||||
int[] colors = command.colors.items;
|
||||
int[] colorsCopy = new int[command.vertices.size];
|
||||
System.arraycopy(colors, 0, colorsCopy, 0, command.colors.size);
|
||||
|
||||
canvas.drawVertices(Canvas.VertexMode.TRIANGLES, command.vertices.size, command.vertices.items, 0, command.uvs.items, 0,
|
||||
colorsCopy, 0, command.indices.items, 0, command.indices.size, command.texture.getPaint(command.blendMode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ import com.esotericsoftware.spine.Skeleton;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.AttributeSet;
|
||||
@ -187,6 +188,10 @@ public class SpineView extends View implements Choreographer.FrameCallback {
|
||||
public SpineView (Context context, SpineController controller) {
|
||||
super(context);
|
||||
this.controller = controller;
|
||||
// See https://github.com/EsotericSoftware/spine-runtimes/issues/2638
|
||||
if (Build.VERSION.SDK_INT < 29) {
|
||||
this.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
}
|
||||
}
|
||||
|
||||
/** Constructs a new {@link SpineView} without providing a {@link SpineController}, which you need to provide using
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user