Flutter Engine
The Flutter Engine
Classes | Protected Member Functions | List of all members
SkottieMultiFrameGM Class Reference
Inheritance diagram for SkottieMultiFrameGM:
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 185 of file SkottieGM.cpp.

Member Function Documentation

◆ getISize()

SkISize SkottieMultiFrameGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 190 of file SkottieGM.cpp.

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

◆ getName()

SkString SkottieMultiFrameGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 188 of file SkottieGM.cpp.

188{ return SkString("skottie_multiframe"); }

◆ onAnimate()

bool SkottieMultiFrameGM::onAnimate ( double  nanos)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 212 of file SkottieGM.cpp.

212 {
213 if (!fAnimation) {
214 return false;
215 }
216
217 const auto duration = fAnimation->duration();
218 fAnimation->seek(std::fmod(1e-9 * nanos, duration) / duration);
219 return true;
220 }
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 SkottieMultiFrameGM::onDraw ( SkCanvas canvas,
SkString errorMsg 
)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 201 of file SkottieGM.cpp.

201 {
202 if (!fAnimation) {
203 *errorMsg = "No animation";
204 return DrawResult::kFail;
205 }
206
207 auto dest = SkRect::MakeWH(kSize, kSize);
208 fAnimation->render(canvas, &dest);
209 return DrawResult::kOk;
210 }
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 SkottieMultiFrameGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 192 of file SkottieGM.cpp.

192 {
193 if (auto stream = GetResourceAsStream("skottie/skottie_sample_multiframe.json")) {
194 fAnimation = skottie::Animation::Builder()
195 .setResourceProvider(sk_make_sp<MultiFrameResourceProvider>())
196 .make(stream.get());
197 fAnimation->seek(0);
198 }
199 }
std::unique_ptr< SkStreamAsset > GetResourceAsStream(const char *resource, bool useFileStream)
Definition: Resources.cpp:31
DlVertices::Builder Builder

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