Skip to content

Commit

Permalink
animation engine integration: fix flickering: small optimization
Browse files Browse the repository at this point in the history
Let's try to skip same time values.

Signed-off-by: Marco Cecchetti <[email protected]>
Change-Id: I318da7d6ff5c31198d1d94d679129ea0c3772512
  • Loading branch information
mcecchetti authored and eszkadev committed Sep 5, 2024
1 parent 7090969 commit d15f0e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions browser/src/slideshow/Transition2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ abstract class TransitionBase extends SlideChangeGl {
}

public startTransition(): void {
this.prevTime = null;
this.time = null;
this.isLastFrame = false;
this.requestAnimationFrameId = requestAnimationFrame(this.animate.bind(this));
Expand Down
5 changes: 4 additions & 1 deletion browser/src/slideshow/engine/SlideChangeBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function SlideChangeTemplate<T extends AGConstructor<any>>(BaseType: T) {
protected leavingSlide: WebGLTexture | ImageBitmap;
protected enteringSlide: WebGLTexture | ImageBitmap;
protected time: number;
protected prevTime: number;
protected isLastFrame: boolean;

constructor(...args: any[]) {
Expand All @@ -42,6 +43,7 @@ function SlideChangeTemplate<T extends AGConstructor<any>>(BaseType: T) {
this.isFinished = false;
this.requestAnimationFrameId = null;
this.time = null;
this.prevTime = null;
this.isLastFrame = false;
}

Expand All @@ -64,12 +66,13 @@ function SlideChangeTemplate<T extends AGConstructor<any>>(BaseType: T) {

public perform(nT: number, last: boolean = false): void {
if (this.isFinished) return;
this.prevTime = this.time;
this.time = nT;
this.isLastFrame = last;
}

protected animate() {
if (this.time != null) {
if (this.time !== null && this.time !== this.prevTime) {
this.render(this.time);
}
if (!this.isLastFrame)
Expand Down

0 comments on commit d15f0e7

Please sign in to comment.