[skottie] Refactor keyframe encoding

For each Lottie keyframe, we currently store interpolation
*segments*:

 {
   t0, v0
   t1, v1
   cubic_mapper
 }

This is quite redundant:

 - kf(n).t1 == kf(n+1).t0 for all keyframes
 - kf(n).v1 == kf(n+1).v0 for all non-constant keyframes

Refactor to store single keyframe records:

  {
    t, v
    mapping
  }

To identify constant keyframes, since we no longer store
explicit hard stops, we now tag each record with a "mapping"
selector:

    0 -> constant keyframe
    1 -> linear keyframe
  > 1 -> cubic keyframe (adjusted cubic mapper index)


This reduces the storage size by 2/5, and yields overall cleaner
logic (as we're no longer back-filling info as we parse).

Also add a handful of unit tests to lock down limit semantics
(keyframe segments are left-inclusive/right-exclusive).

Change-Id: I3ab0e5568b83ab8536a7d326dbc07c4c455e978d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270450
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
3 files changed