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

Public Member Functions

 ShaderText3GM ()
 
- 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 64 of file shadertext3.cpp.

Constructor & Destructor Documentation

◆ ShaderText3GM()

skiagm::ShaderText3GM::ShaderText3GM ( )
inline

Definition at line 66 of file shadertext3.cpp.

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

Member Function Documentation

◆ getISize()

SkISize skiagm::ShaderText3GM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 73 of file shadertext3.cpp.

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

◆ getName()

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

Implements skiagm::GM.

Definition at line 71 of file shadertext3.cpp.

71{ return SkString("shadertext3"); }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 79 of file shadertext3.cpp.

79 {
80
81 SkPaint bmpPaint;
82 bmpPaint.setAntiAlias(true);
83 bmpPaint.setAlphaf(0.5f);
85
86 canvas->drawImage(fBmp.asImage(), 5.f, 5.f, sampling, &bmpPaint);
87
89 SkPaint outlinePaint;
90 outlinePaint.setStyle(SkPaint::kStroke_Style);
91 outlinePaint.setStrokeWidth(0.f);
92
93 canvas->translate(15.f, 15.f);
94
95 // draw glyphs scaled up
96 canvas->scale(2.f, 2.f);
97
98 constexpr SkTileMode kTileModes[] = {
101 };
102
103 // position the baseline of the first run
104 canvas->translate(0.f, 0.75f * kPointSize);
105
106 canvas->save();
107 int i = 0;
108 for (size_t tm0 = 0; tm0 < std::size(kTileModes); ++tm0) {
109 for (size_t tm1 = 0; tm1 < std::size(kTileModes); ++tm1) {
110 SkMatrix localM;
111 localM.setTranslate(5.f, 5.f);
112 localM.postRotate(20);
113 localM.postScale(1.15f, .85f);
114
115 SkPaint fillPaint;
116 fillPaint.setAntiAlias(true);
117 fillPaint.setShader(fBmp.makeShader(kTileModes[tm0], kTileModes[tm1],
118 sampling, localM));
119
120 constexpr char kText[] = "B";
121 canvas->drawString(kText, 0, 0, font, fillPaint);
122 canvas->drawString(kText, 0, 0, font, outlinePaint);
123 SkScalar w = font.measureText(kText, strlen(kText), SkTextEncoding::kUTF8);
124 canvas->translate(w + 10.f, 0.f);
125 ++i;
126 if (!(i % 2)) {
127 canvas->restore();
128 canvas->translate(0, 0.75f * kPointSize);
129 canvas->save();
130 }
131 }
132 }
133 canvas->restore();
134 }
@ kUTF8
uses bytes to represent UTF-8 or ASCII
#define SkIntToScalar(x)
Definition: SkScalar.h:57
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 scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
Definition: SkFont.h:35
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
float SkScalar
Definition: extension.cpp:12
constexpr char kText[]
Definition: glyph_pos.cpp:28
SkSamplingOptions sampling
Definition: SkRecords.h:337
sk_sp< SkTypeface > DefaultPortableTypeface()
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
font
Font Metadata and Metrics.
constexpr int kPointSize
Definition: shaderpath.cpp:61
SkScalar w

◆ onOnceBeforeDraw()

void skiagm::ShaderText3GM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 75 of file shadertext3.cpp.

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

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