skia2/tools/viewer/SkottieSlide.h
Florin Malita 67ff541ac1 [skottie] Add support for embedded fonts (glyph paths)
Parse embedded fonts into SkCustomTypefaces, and pass down the text
animation pipeline.  Things seem to mostly work for Latin examples.

Most existing Lottie files come with embedded fonts (the option is
enabled by default), so to minimize disruption only use the new
feature as a fallback for typefaces which cannot be resolved otherwise.

Also introduce a builder flag to prioritize embedded fonts over native
(kPreferEmbeddedFonts), and plumb in existing tools for testing.

Change-Id: Ia2a659f76e354fea6081b0f2e0dce1d8bdf63c52
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291180
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
2020-05-21 01:27:34 +00:00

65 lines
2.0 KiB
C++

/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkottieSlide_DEFINED
#define SkottieSlide_DEFINED
#include "tools/viewer/Slide.h"
#if defined(SK_ENABLE_SKOTTIE)
#include "modules/skottie/include/Skottie.h"
#include "modules/sksg/include/SkSGInvalidationController.h"
#include <vector>
namespace sksg { class Scene; }
class SkottieSlide : public Slide {
public:
SkottieSlide(const SkString& name, const SkString& path);
~SkottieSlide() override = default;
void load(SkScalar winWidth, SkScalar winHeight) override;
void unload() override;
void resize(SkScalar, SkScalar) override;
SkISize getDimensions() const override;
void draw(SkCanvas*) override;
bool animate(double) override;
bool onChar(SkUnichar) override;
bool onMouse(SkScalar x, SkScalar y, skui::InputState, skui::ModifierKey modifiers) override;
private:
SkRect UIArea() const;
void renderUI();
const SkString fPath;
sk_sp<skottie::Animation> fAnimation;
skottie::Animation::Builder::Stats fAnimationStats;
sksg::InvalidationController fInvalController;
std::vector<float> fFrameTimes;
SkSize fWinSize = SkSize::MakeEmpty();
double fTimeBase = 0,
fFrameRate = 0;
const char* fFrameRateLabel = nullptr;
float fCurrentFrame = 0;
bool fShowAnimationInval = false,
fShowAnimationStats = false,
fShowUI = false,
fDraggingProgress = false,
fPreferGlyphPaths = false;
typedef Slide INHERITED;
};
#endif // SK_ENABLE_SKOTTIE
#endif // SkottieSlide_DEFINED