Flutter Engine
The Flutter Engine
Protected Member Functions | List of all members
SkottieWebFontGM Class Reference
Inheritance diagram for SkottieWebFontGM:
skiagm::GM

Protected Member Functions

SkString getName () const override
 
SkISize getISize () override
 
void onOnceBeforeDraw () override
 
DrawResult onDraw (SkCanvas *canvas, SkString *errorMsg) override
 
bool onAnimate (double nanos) override
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual void onOnceBeforeDraw ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
virtual void onDraw (SkCanvas *)
 
virtual bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Additional Inherited Members

- Public Types inherited from skiagm::GM
enum  Mode { kGM_Mode , kSample_Mode , kBench_Mode }
 
using DrawResult = skiagm::DrawResult
 
using GraphiteTestContext = skiatest::graphite::GraphiteTestContext
 
- Public Member Functions inherited from skiagm::GM
 GM (SkColor backgroundColor=SK_ColorWHITE)
 
virtual ~GM ()
 
void setMode (Mode mode)
 
Mode getMode () const
 
DrawResult gpuSetup (SkCanvas *, SkString *errorMsg, GraphiteTestContext *=nullptr)
 
void gpuTeardown ()
 
void onceBeforeDraw ()
 
DrawResult draw (SkCanvas *canvas)
 
DrawResult draw (SkCanvas *, SkString *errorMsg)
 
void drawBackground (SkCanvas *)
 
DrawResult drawContent (SkCanvas *canvas)
 
DrawResult drawContent (SkCanvas *, SkString *errorMsg)
 
virtual SkISize getISize ()=0
 
virtual SkString getName () const =0
 
virtual bool runAsBench () const
 
SkScalar width ()
 
SkScalar height ()
 
SkColor getBGColor () const
 
void setBGColor (SkColor)
 
void drawSizeBounds (SkCanvas *, SkColor)
 
bool animate (double)
 
virtual bool onChar (SkUnichar)
 
bool getControls (SkMetaData *controls)
 
void setControls (const SkMetaData &controls)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual void modifyGraphiteContextOptions (skgpu::graphite::ContextOptions *) const
 
virtual bool isBazelOnly () const
 
virtual std::map< std::string, std::string > getGoldKeys () const
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 48 of file SkottieGM.cpp.

Member Function Documentation

◆ getISize()

SkISize SkottieWebFontGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 53 of file SkottieGM.cpp.

53{ return SkISize::Make(kSize, kSize); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString SkottieWebFontGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 51 of file SkottieGM.cpp.

51{ return SkString("skottie_webfont"); }

◆ onAnimate()

bool SkottieWebFontGM::onAnimate ( double  nanos)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 76 of file SkottieGM.cpp.

76 {
77 if (!fAnimation) {
78 return false;
79 }
80
81 const auto duration = fAnimation->duration();
82 fAnimation->seek(std::fmod(1e-9 * nanos, duration) / duration);
83 return true;
84 }
double duration() const
Definition: Skottie.h:268
void seek(SkScalar t, sksg::InvalidationController *ic=nullptr)
Definition: Skottie.h:244
double duration
Definition: examples.cpp:30

◆ onDraw()

DrawResult SkottieWebFontGM::onDraw ( SkCanvas canvas,
SkString errorMsg 
)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 65 of file SkottieGM.cpp.

65 {
66 if (!fAnimation) {
67 *errorMsg = "No animation";
68 return DrawResult::kFail;
69 }
70
71 auto dest = SkRect::MakeWH(kSize, kSize);
72 fAnimation->render(canvas, &dest);
73 return DrawResult::kOk;
74 }
void render(SkCanvas *canvas, const SkRect *dst=nullptr) const
Definition: Skottie.cpp:482
dest
Definition: zip.py:79
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ onOnceBeforeDraw()

void SkottieWebFontGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 55 of file SkottieGM.cpp.

55 {
56 if (auto stream = GetResourceAsStream(kSkottieResource)) {
57 fAnimation = skottie::Animation::Builder()
58 .setFontManager(ToolUtils::TestFontMgr())
59 .setResourceProvider(sk_make_sp<FakeWebFontProvider>())
60 .setTextShapingFactory(SkShapers::BestAvailable())
61 .make(stream.get());
62 }
63 }
std::unique_ptr< SkStreamAsset > GetResourceAsStream(const char *resource, bool useFileStream)
Definition: Resources.cpp:31
sk_sp< Factory > BestAvailable()
sk_sp< SkFontMgr > TestFontMgr()
DlVertices::Builder Builder

The documentation for this class was generated from the following file: