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

Public Member Functions

 SkottieColorizeGM (const char *name, const char *resource)
 
- 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
 

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
 
bool onChar (SkUnichar uni) 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
 
- Static Public Attributes inherited from skiagm::GM
static constexpr char kErrorMsg_DrawSkippedGpuOnly []
 

Detailed Description

Definition at line 96 of file SkottieGM.cpp.

Constructor & Destructor Documentation

◆ SkottieColorizeGM()

SkottieColorizeGM::SkottieColorizeGM ( const char *  name,
const char *  resource 
)
inline

Definition at line 98 of file SkottieGM.cpp.

99 : fName(name)
100 , fResource(resource)
101 {}
static SkString resource(SkPDFResourceType type, int index)
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

Member Function Documentation

◆ getISize()

SkISize SkottieColorizeGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 106 of file SkottieGM.cpp.

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

◆ getName()

SkString SkottieColorizeGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 104 of file SkottieGM.cpp.

104{ return SkStringPrintf("skottie_colorize_%s", fName); }
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.

◆ onAnimate()

bool SkottieColorizeGM::onAnimate ( double  nanos)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 132 of file SkottieGM.cpp.

132 {
133 if (!fAnimation) {
134 return false;
135 }
136
137 const auto duration = fAnimation->duration();
138 fAnimation->seek(std::fmod(1e-9 * nanos, duration) / duration);
139 return true;
140 }
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

◆ onChar()

bool SkottieColorizeGM::onChar ( SkUnichar  uni)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 142 of file SkottieGM.cpp.

142 {
143 static constexpr SkColor kColors[] = {
149 };
150
151 if (uni == 'c') {
152 fColorIndex = (fColorIndex + 1) % std::size(kColors);
153 for (const auto& prop : fColorProps) {
154 fPropManager->setColor(prop, kColors[fColorIndex]);
155 }
156 for (const auto& prop : fTextProps) {
157 auto txtval = fPropManager->getText(prop);
158 txtval.fFillColor = kColors[fColorIndex];
159 fPropManager->setText(prop, txtval);
160 }
161 return true;
162 }
163
164 return false;
165 }
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorCYAN
Definition: SkColor.h:143
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
const DlColor kColors[]
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
static SkScalar prop(SkScalar radius, SkScalar newSize, SkScalar oldSize)
Definition: rrect.cpp:83

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 121 of file SkottieGM.cpp.

121 {
122 if (!fAnimation) {
123 *errorMsg = "No animation";
124 return DrawResult::kFail;
125 }
126
127 auto dest = SkRect::MakeWH(kSize, kSize);
128 fAnimation->render(canvas, &dest);
129 return DrawResult::kOk;
130 }
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 SkottieColorizeGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 108 of file SkottieGM.cpp.

108 {
109 if (auto stream = GetResourceAsStream(fResource)) {
110 fPropManager = std::make_unique<skottie_utils::CustomPropertyManager>();
111 fAnimation = skottie::Animation::Builder()
112 .setFontManager(ToolUtils::TestFontMgr())
113 .setPropertyObserver(fPropManager->getPropertyObserver())
114 .setTextShapingFactory(SkShapers::BestAvailable())
115 .make(stream.get());
116 fColorProps = fPropManager->getColorProps();
117 fTextProps = fPropManager->getTextProps();
118 }
119 }
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: