From d296fa3efa03d3d99c0cb0dcf46c850605544a0e Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 11 Oct 2021 16:16:55 +0200 Subject: [PATCH] [ts] Closes #1966, PolygonBatcher does not flush if the blend mode has not changed. --- spine-ts/spine-core/src/AnimationState.ts | 12 +- spine-ts/spine-webgl/src/PolygonBatcher.ts | 1 + .../spine-webgl/tests/test-drawcalls.html | 106 ++++++++++++++++++ 3 files changed, 113 insertions(+), 6 deletions(-) create mode 100644 spine-ts/spine-webgl/tests/test-drawcalls.html diff --git a/spine-ts/spine-core/src/AnimationState.ts b/spine-ts/spine-core/src/AnimationState.ts index fd0691bf1..4dac3da2d 100644 --- a/spine-ts/spine-core/src/AnimationState.ts +++ b/spine-ts/spine-core/src/AnimationState.ts @@ -1095,24 +1095,24 @@ export enum EventType { * {@link AnimationState#addListener()}. */ export interface AnimationStateListener { /** Invoked when this entry has been set as the current entry. */ - start? (entry: TrackEntry): void; + start?(entry: TrackEntry): void; /** Invoked when another entry has replaced this entry as the current entry. This entry may continue being applied for * mixing. */ - interrupt? (entry: TrackEntry): void; + interrupt?(entry: TrackEntry): void; /** Invoked when this entry is no longer the current entry and will never be applied again. */ - end? (entry: TrackEntry): void; + end?(entry: TrackEntry): void; /** Invoked when this entry will be disposed. This may occur without the entry ever being set as the current entry. * References to the entry should not be kept after dispose is called, as it may be destroyed or reused. */ - dispose? (entry: TrackEntry): void; + dispose?(entry: TrackEntry): void; /** Invoked every time this entry's animation completes a loop. */ - complete? (entry: TrackEntry): void; + complete?(entry: TrackEntry): void; /** Invoked when this entry's animation triggers an event. */ - event? (entry: TrackEntry, event: Event): void; + event?(entry: TrackEntry, event: Event): void; } export abstract class AnimationStateAdapter implements AnimationStateListener { diff --git a/spine-ts/spine-webgl/src/PolygonBatcher.ts b/spine-ts/spine-webgl/src/PolygonBatcher.ts index 9df3ec9e5..4fcf43216 100644 --- a/spine-ts/spine-webgl/src/PolygonBatcher.ts +++ b/spine-ts/spine-webgl/src/PolygonBatcher.ts @@ -72,6 +72,7 @@ export class PolygonBatcher implements Disposable { } setBlendMode (srcColorBlend: number, srcAlphaBlend: number, dstBlend: number) { + if (this.srcColorBlend == srcColorBlend && this.srcAlphaBlend == srcAlphaBlend && this.dstBlend == dstBlend) return; this.srcColorBlend = srcColorBlend; this.srcAlphaBlend = srcAlphaBlend; this.dstBlend = dstBlend; diff --git a/spine-ts/spine-webgl/tests/test-drawcalls.html b/spine-ts/spine-webgl/tests/test-drawcalls.html new file mode 100644 index 000000000..5b66ee5a8 --- /dev/null +++ b/spine-ts/spine-webgl/tests/test-drawcalls.html @@ -0,0 +1,106 @@ + + + + + + +
test
+ + + + \ No newline at end of file