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

Public Member Functions

 ShaderPathGM ()
 
- 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
 
void onDraw (SkCanvas *canvas) 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 63 of file shaderpath.cpp.

Constructor & Destructor Documentation

◆ ShaderPathGM()

skiagm::ShaderPathGM::ShaderPathGM ( )
inline

Definition at line 65 of file shaderpath.cpp.

65 {
66 this->setBGColor(0xFFDDDDDD);
67 }
void setBGColor(SkColor)
Definition: gm.cpp:159

Member Function Documentation

◆ getISize()

SkISize skiagm::ShaderPathGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 72 of file shaderpath.cpp.

72{ return SkISize::Make(820, 930); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString skiagm::ShaderPathGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 70 of file shaderpath.cpp.

70{ return SkString("shaderpath"); }

◆ onDraw()

void skiagm::ShaderPathGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 78 of file shaderpath.cpp.

78 {
79
80 SkPaint bmpPaint;
81 bmpPaint.setAntiAlias(true);
82 bmpPaint.setAlphaf(0.5f);
84
85 canvas->drawImage(fBmp.asImage(), 5.f, 5.f, sampling, &bmpPaint);
86
87 SkPaint outlinePaint;
88 outlinePaint.setStyle(SkPaint::kStroke_Style);
89 outlinePaint.setStrokeWidth(0.f);
90
91 canvas->translate(15.f, 15.f);
92 canvas->scale(2.f, 2.f);
93
94 constexpr SkTileMode kTileModes[] = {
97 };
98
99 // position the baseline of the first path
100 canvas->translate(0.f, 2.25);
101
102 SkPath path;
103 path.moveTo(0, 40).cubicTo(10, 70, 20, 10, 30, 40);
104
105 canvas->save();
106 int i = 0;
107 for (size_t tm0 = 0; tm0 < std::size(kTileModes); ++tm0) {
108 for (size_t tm1 = 0; tm1 < std::size(kTileModes); ++tm1) {
109 SkMatrix localM;
110 localM.setTranslate(5.f, 5.f);
111 localM.postRotate(20);
112 localM.postScale(1.15f, .85f);
113
114 SkPaint fillPaint;
115 fillPaint.setAntiAlias(true);
116 fillPaint.setShader(fBmp.makeShader(kTileModes[tm0], kTileModes[tm1],
117 sampling, localM));
118
119 canvas->drawPath(path, fillPaint);
120 canvas->drawPath(path, outlinePaint);
121 canvas->translate(50.f, 0.f);
122 ++i;
123 if (!(i % 2)) {
124 canvas->restore();
125 canvas->translate(0, 22.5f);
126 canvas->save();
127 }
128 }
129 }
130 canvas->restore();
131 }
SkTileMode
Definition: SkTileMode.h:13
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkBitmap.cpp:669
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
SkMatrix & postRotate(SkScalar degrees, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:474
SkMatrix & postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:360
SkMatrix & setTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:254
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
void setShader(sk_sp< SkShader > shader)
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
void setAlphaf(float a)
Definition: SkPaint.cpp:130
Definition: SkPath.h:59
SkSamplingOptions sampling
Definition: SkRecords.h:337
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
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

◆ onOnceBeforeDraw()

void skiagm::ShaderPathGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 74 of file shaderpath.cpp.

74 {
75 makebm(&fBmp, kPointSize / 4, kPointSize / 4);
76 }
constexpr int kPointSize
Definition: shaderpath.cpp:61
static void makebm(SkBitmap *bm, int w, int h)
Definition: shaderpath.cpp:31

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