Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
VerticesGM Class Reference
Inheritance diagram for VerticesGM:
skiagm::GM

Public Member Functions

 VerticesGM (SkScalar shaderScale)
 
- 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 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

void onOnceBeforeDraw () override
 
SkString getName () const override
 
SkISize getISize () override
 
void onDraw (SkCanvas *canvas) override
 
- Protected Member Functions inherited from skiagm::GM
virtual DrawResult onGpuSetup (SkCanvas *, SkString *, GraphiteTestContext *)
 
virtual void onGpuTeardown ()
 
virtual DrawResult onDraw (SkCanvas *, SkString *errorMsg)
 
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 105 of file vertices.cpp.

Constructor & Destructor Documentation

◆ VerticesGM()

VerticesGM::VerticesGM ( SkScalar  shaderScale)
inline

Definition at line 115 of file vertices.cpp.

115: fShaderScale(shaderScale) {}

Member Function Documentation

◆ getISize()

SkISize VerticesGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 134 of file vertices.cpp.

134{ return SkISize::Make(975, 1175); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

SkString VerticesGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 126 of file vertices.cpp.

126 {
127 SkString name("vertices");
128 if (fShaderScale != 1) {
129 name.append("_scaled_shader");
130 }
131 return name;
132 }
const char * name
Definition fuchsia.cc:50

◆ onDraw()

void VerticesGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 136 of file vertices.cpp.

136 {
137 const SkBlendMode modes[] = {
167 };
168
170
171 canvas->translate(4, 4);
172 for (auto mode : modes) {
173 canvas->save();
174 for (float alpha : {1.0f, 0.5f}) {
175 for (const auto& cf : {sk_sp<SkColorFilter>(nullptr), fColorFilter}) {
176 for (const auto& shader : {fShader1, fShader2}) {
177 static constexpr struct {
178 bool fHasColors;
179 bool fHasTexs;
180 } kAttrs[] = {{true, false}, {false, true}, {true, true}};
181 for (auto attrs : kAttrs) {
182 paint.setShader(shader);
183 paint.setColorFilter(cf);
184 paint.setAlphaf(alpha);
185
186 const SkColor* colors = attrs.fHasColors ? fColors : nullptr;
187 const SkPoint* texs = attrs.fHasTexs ? fTexs : nullptr;
189 kMeshVertexCnt, fPts, texs, colors,
191 canvas->drawVertices(v, mode, paint);
192 canvas->translate(40, 0);
193 }
194 }
195 }
196 }
197 canvas->restore();
198 canvas->translate(0, 40);
199 }
200 }
SkBlendMode
Definition SkBlendMode.h:38
@ kSrcOut
r = s * (1-da)
@ kExclusion
rc = s + d - two(s*d), ra = kSrcOver
@ kSaturation
saturation of source with hue and luminosity of destination
@ kColorBurn
darken destination to reflect source
@ kPlus
r = min(s + d, 1)
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kHue
hue of source with saturation and luminosity of destination
@ kDstIn
r = d * sa
@ kModulate
r = s*d
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kColorDodge
brighten destination to reflect source
@ kScreen
r = s + d - s*d
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kLuminosity
luminosity of source with hue and saturation of destination
@ kSoftLight
lighten or darken, depending on source
@ kDifference
rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
@ kOverlay
multiply or screen, depending on destination
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstATop
r = d*sa + s*(1-da)
@ kDstOver
r = d + (1-da)*s
@ kColor
hue and saturation of source with luminosity of destination
@ kHardLight
multiply or screen, depending on source
@ kDstOut
r = d * (1-sa)
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
@ kSrcIn
r = s * da
@ kClear
r = 0
uint32_t SkColor
Definition SkColor.h:37
void restore()
Definition SkCanvas.cpp:465
void translate(SkScalar dx, SkScalar dy)
int save()
Definition SkCanvas.cpp:451
void drawVertices(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
static sk_sp< SkVertices > MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[], int indexCount, const uint16_t indices[])
@ kTriangleFan_VertexMode
Definition SkVertices.h:33
const Paint & paint
PODArray< SkRect > texs
Definition SkRecords.h:333
PODArray< SkColor > colors
Definition SkRecords.h:276
static const int kMeshIndexCnt
Definition vertices.cpp:73
static const int kMeshVertexCnt
Definition vertices.cpp:74
static constexpr uint16_t kMeshFan[]
Definition vertices.cpp:68

◆ onOnceBeforeDraw()

void VerticesGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 119 of file vertices.cpp.

119 {
120 fill_mesh(fPts, fTexs, fColors, fShaderScale);
121 fShader1 = make_shader1(fShaderScale);
122 fShader2 = make_shader2();
123 fColorFilter = make_color_filter();
124 }
static sk_sp< SkShader > make_shader1(SkScalar shaderScale)
Definition vertices.cpp:39
static sk_sp< SkShader > make_shader2()
Definition vertices.cpp:57
static void fill_mesh(SkPoint pts[kMeshVertexCnt], SkPoint texs[kMeshVertexCnt], SkColor colors[kMeshVertexCnt], SkScalar shaderScale)
Definition vertices.cpp:76
static sk_sp< SkColorFilter > make_color_filter()
Definition vertices.cpp:61

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