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

Public Member Functions

 PerspShadersGM (bool doAA)
 
- 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 drawRow (SkCanvas *canvas, const SkSamplingOptions &sampling)
 
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 42 of file perspshaders.cpp.

Constructor & Destructor Documentation

◆ PerspShadersGM()

skiagm::PerspShadersGM::PerspShadersGM ( bool  doAA)
inline

Definition at line 44 of file perspshaders.cpp.

44: fDoAA(doAA) { }

Member Function Documentation

◆ drawRow()

void skiagm::PerspShadersGM::drawRow ( SkCanvas canvas,
const SkSamplingOptions sampling 
)
inlineprotected

Definition at line 91 of file perspshaders.cpp.

91 {
92 SkPaint filterPaint;
93 filterPaint.setAntiAlias(fDoAA);
94
95 SkPaint pathPaint;
96 pathPaint.setShader(fBitmapImage->makeShader(sampling));
97 pathPaint.setAntiAlias(fDoAA);
98
99 SkPaint gradPaint1;
100 gradPaint1.setShader(fLinearGrad1);
101 gradPaint1.setAntiAlias(fDoAA);
102 SkPaint gradPaint2;
103 gradPaint2.setShader(fLinearGrad2);
104 gradPaint2.setAntiAlias(fDoAA);
105
106 SkRect r = SkRect::MakeWH(SkIntToScalar(kCellSize), SkIntToScalar(kCellSize));
107
108 canvas->save();
109
110 canvas->save();
111 canvas->concat(fPerspMatrix);
112 canvas->drawImageRect(fBitmapImage, r, sampling, &filterPaint);
113 canvas->restore();
114
115 canvas->translate(SkIntToScalar(kCellSize), 0);
116 canvas->save();
117 canvas->concat(fPerspMatrix);
118 canvas->drawImage(fImage.get(), 0, 0, sampling, &filterPaint);
119 canvas->restore();
120
121 canvas->translate(SkIntToScalar(kCellSize), 0);
122 canvas->save();
123 canvas->concat(fPerspMatrix);
124 canvas->drawRect(r, pathPaint);
125 canvas->restore();
126
127 canvas->translate(SkIntToScalar(kCellSize), 0);
128 canvas->save();
129 canvas->concat(fPerspMatrix);
130 canvas->drawPath(fPath, pathPaint);
131 canvas->restore();
132
133 canvas->translate(SkIntToScalar(kCellSize), 0);
134 canvas->save();
135 canvas->concat(fPerspMatrix);
136 canvas->drawRect(r, gradPaint1);
137 canvas->restore();
138
139 canvas->translate(SkIntToScalar(kCellSize), 0);
140 canvas->save();
141 canvas->concat(fPerspMatrix);
142 canvas->drawPath(fPath, gradPaint2);
143 canvas->restore();
144
145 canvas->restore();
146 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
Definition: SkCanvas.cpp:2333
int save()
Definition: SkCanvas.cpp:447
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkImage.cpp:179
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
void setShader(sk_sp< SkShader > shader)
T * get() const
Definition: SkRefCnt.h:303
SkSamplingOptions sampling
Definition: SkRecords.h:337
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ getISize()

SkISize skiagm::PerspShadersGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 54 of file perspshaders.cpp.

54 {
55 return SkISize::Make(kCellSize*kNumCols, kCellSize*kNumRows);
56 }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 47 of file perspshaders.cpp.

47 {
49 name.printf("persp_shaders_%s",
50 fDoAA ? "aa" : "bw");
51 return name;
52 }
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 148 of file perspshaders.cpp.

148 {
149 if (!fImage || !fImage->isValid(canvas->recordingContext())) {
150 fImage = make_image(canvas, kCellSize, kCellSize);
151 }
152
154 canvas->translate(0, SkIntToScalar(kCellSize));
156 canvas->translate(0, SkIntToScalar(kCellSize));
159 canvas->translate(0, SkIntToScalar(kCellSize));
161 canvas->translate(0, SkIntToScalar(kCellSize));
162 this->drawRow(canvas, SkSamplingOptions::Aniso(16));
163 canvas->translate(0, SkIntToScalar(kCellSize));
164 }
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637
virtual bool isValid(GrRecordingContext *context) const =0
void drawRow(SkCanvas *canvas, const SkSamplingOptions &sampling)
SkSamplingOptions(SkFilterMode::kLinear))
static sk_sp< SkImage > make_image(SkColorType colorType, SkAlphaType alphaType)
static constexpr SkCubicResampler Mitchell()
static constexpr SkSamplingOptions Aniso(int maxAniso)

◆ onOnceBeforeDraw()

void skiagm::PerspShadersGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 58 of file perspshaders.cpp.

58 {
60 kCellSize, kCellSize, SK_ColorBLUE, SK_ColorYELLOW, kCellSize / 10);
61
62 SkPoint pts1[] = {
63 { 0, 0 },
64 { SkIntToScalar(kCellSize), SkIntToScalar(kCellSize) }
65 };
66 SkPoint pts2[] = {
67 { 0, 0 },
68 { 0, SkIntToScalar(kCellSize) }
69 };
70 constexpr SkColor colors[] = {
72 };
73 constexpr SkScalar pos[] = { 0, 0.25f, 0.5f, 0.75f, SK_Scalar1 };
74
79
80 fPerspMatrix.reset();
81 fPerspMatrix.setPerspY(SK_Scalar1 / 50);
82
83 fPath.moveTo(0, 0);
84 fPath.lineTo(0, SkIntToScalar(kCellSize));
85 fPath.lineTo(kCellSize/2.0f, kCellSize/2.0f);
86 fPath.lineTo(SkIntToScalar(kCellSize), SkIntToScalar(kCellSize));
87 fPath.lineTo(SkIntToScalar(kCellSize), 0);
88 fPath.close();
89 }
SkPoint pos
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
#define SK_Scalar1
Definition: SkScalar.h:18
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
SkMatrix & setPerspY(SkScalar v)
Definition: SkMatrix.h:544
SkMatrix & reset()
Definition: SkMatrix.cpp:49
SkPath & moveTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:688
SkPath & lineTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:728
SkPath & close()
Definition: SkPath.cpp:823
float SkScalar
Definition: extension.cpp:12
PODArray< SkColor > colors
Definition: SkRecords.h:276
sk_sp< SkImage > create_checkerboard_image(int w, int h, SkColor c1, SkColor c2, int checkSize)
Definition: ToolUtils.cpp:168
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

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