[skottie] Don't revalidate during render()
Updating property handles causes scene graph invalidation, and requires
a revalidation pass before rendering.
To hide this detail from clients, we're currently revalidating in
sksg::Scene::render(), just before diving into the scene graph.
That's problematic, because render() is supposed to be const and
thread-safe.
This CL removes the revalidation call from Scene::render(), and
replaces it with on-the-fly revalidation in property setters:
- Introduce SceneGraphRevalidator (SGR), a trivial wrapper which
forwards revalidation calls to the render tree root. This
indirection is required because the render tree root does not
exist at build time, when property callbacks are issued and
property handles are created.
- Expand PropertyHandle to store a SGR reference, and to issue
revalidate() calls from all property setters.
- Adjust the animation builder to store a sksg::RenderNode root
instead of sksg::Scene, and to push the root information to SGR
as the very last step.
Also relocate existing property tests to
modules/skottie/tests/PropertyObserver.cpp, and add a new test to
verify revalidation for property changes.
There are two interesting scenarios to consider:
1) Properties are updated while the animation is loading, in
callbacks, and then the animation is rendered without an explicit
seek() call: in this case, on-the-fly revalidation is suppressed because the root node does not exist, but an initial revalidation is
triggered at the end of parsing, in AnimationBuilder::parse().
2) Properties are updated after the animation is loaded, and then
the animation is rendered without an explicit seek() call: in this
case, revalidation is triggered on-the-fly, from property setters.
Change-Id: I72fb515d5d82dbaa595ba546fb1b8ab81cec2638
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/699577
Reviewed-by: Jorge Betancourt <jmbetancourt@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
13 files changed