performance increase by not drawing on do nothing frames
Change-Id: Ibcd4f0ed468563b22e29d23c7d72b474534d21f3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/299916
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Jorge Betancourt <jmbetancourt@google.com>
diff --git a/platform_tools/android/apps/skottie/skottielib/src/main/cpp/native-lib.cpp b/platform_tools/android/apps/skottie/skottielib/src/main/cpp/native-lib.cpp
index 5e384c7..8c32a07 100644
--- a/platform_tools/android/apps/skottie/skottielib/src/main/cpp/native-lib.cpp
+++ b/platform_tools/android/apps/skottie/skottielib/src/main/cpp/native-lib.cpp
@@ -23,6 +23,7 @@
#include "include/gpu/gl/GrGLTypes.h"
#include "modules/skottie/include/Skottie.h"
+#include "modules/sksg/include/SkSGInvalidationController.h"
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
@@ -191,6 +192,15 @@
return;
}
+ sksg::InvalidationController ic;
+
+ if (skottieAnimation->mAnimation) {
+ skottieAnimation->mAnimation->seek(progress, &ic);
+ if (ic.bounds().isEmpty()) {
+ return;
+ }
+ }
+
SkColorType colorType;
// setup surface for fbo0
GrGLFramebufferInfo fboInfo;
@@ -212,13 +222,10 @@
auto canvas = renderTarget->getCanvas();
canvas->clear(SK_ColorTRANSPARENT);
- if (skottieAnimation->mAnimation) {
- skottieAnimation->mAnimation->seek(progress);
- SkAutoCanvasRestore acr(canvas, true);
- SkRect bounds = SkRect::MakeWH(width, height);
- skottieAnimation->mAnimation->render(canvas, &bounds);
- }
+ SkAutoCanvasRestore acr(canvas, true);
+ SkRect bounds = SkRect::MakeWH(width, height);
+ skottieAnimation->mAnimation->render(canvas, &bounds);
canvas->flush();
}