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

Public Member Functions

 GraphiteStartGM ()=default
 
- 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

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 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
 

Static Protected Attributes

static constexpr int kTileWidth = 128
 
static constexpr int kTileHeight = 128
 
static constexpr int kWidth = 3 * kTileWidth
 
static constexpr int kHeight = 3 * kTileHeight
 
static constexpr int kClipInset = 4
 

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 256 of file graphitestart.cpp.

Constructor & Destructor Documentation

◆ GraphiteStartGM()

skiagm::GraphiteStartGM::GraphiteStartGM ( )
default

Member Function Documentation

◆ getISize()

SkISize skiagm::GraphiteStartGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 274 of file graphitestart.cpp.

274{ return SkISize::Make(kWidth, kHeight); }
static constexpr int kWidth
static constexpr int kHeight
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 272 of file graphitestart.cpp.

272{ return SkString("graphitestart"); }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 276 of file graphitestart.cpp.

276 {
277
279
280 canvas->save();
281 canvas->clipRRect(SkRRect::MakeRectXY(clipRect, 32.f, 32.f), true);
282
283 // Upper-left corner
284 draw_image_shader_tile(canvas, SkRect::MakeXYWH(0, 0, kTileWidth, kTileHeight));
285
286 // Upper-middle tile
287 draw_gradient_tile(canvas, SkRect::MakeXYWH(kTileWidth, 0, kTileWidth, kTileHeight));
288
289 // Upper-right corner
290 draw_colorfilter_swatches(canvas, SkRect::MakeXYWH(2*kTileWidth, 0,
292
293 // Middle-left tile
294 {
295 SkPaint p;
296 p.setColor(SK_ColorRED);
297
299 canvas->drawRect(r.makeInset(1.0f, 1.0f), p);
300 }
301
302 // Middle-middle tile
303 {
304 SkPaint p;
305 p.setShader(create_blend_shader(canvas, SkBlendMode::kModulate));
306
308 canvas->drawRect(r.makeInset(1.0f, 1.0f), p);
309 }
310
311 // Middle-right tile
312 {
313 sk_sp<SkImage> image(ToolUtils::GetResourceAsImage("images/mandrill_128.png"));
314 sk_sp<SkShader> shader;
315
316 if (image) {
318 shader = shader->makeWithColorFilter(create_grayscale_colorfilter());
319 }
320
321 SkPaint p;
322 p.setShader(std::move(shader));
323
325 canvas->drawRect(r.makeInset(1.0f, 1.0f), p);
326 }
327
328 canvas->restore();
329
330 // Bottom-left corner
331#if defined(SK_GRAPHITE)
332 // TODO: failing serialize test on Linux, not sure what's going on
333 canvas->writePixels(fBitmap, 0, 2*kTileHeight);
334#endif
335
336 // Bottom-middle tile
337 draw_blend_mode_swatches(canvas, SkRect::MakeXYWH(kTileWidth, 2*kTileHeight,
339
340 // Bottom-right corner
341 {
344
345 SkPaint circlePaint;
346 circlePaint.setColor(SK_ColorBLUE);
347 circlePaint.setBlendMode(SkBlendMode::kSrc);
348
349 canvas->clipRect(kTile);
350 canvas->drawRect(kTile.makeInset(10, 20), circlePaint);
351
352 SkPaint restorePaint;
353 restorePaint.setBlendMode(SkBlendMode::kPlus);
354
355 canvas->saveLayer(nullptr, &restorePaint);
356 circlePaint.setColor(SK_ColorRED);
357 circlePaint.setBlendMode(SkBlendMode::kSrc);
358
359 canvas->drawRect(kTile.makeInset(15, 25), circlePaint);
360 canvas->restore();
361 }
362 }
@ kPlus
r = min(s + d, 1)
@ kModulate
r = s*d
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition: SkCanvas.cpp:496
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
bool writePixels(const SkImageInfo &info, const void *pixels, size_t rowBytes, int x, int y)
Definition: SkCanvas.cpp:399
int save()
Definition: SkCanvas.cpp:447
void clipRRect(const SkRRect &rrect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1439
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkImage.cpp:179
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setBlendMode(SkBlendMode mode)
Definition: SkPaint.cpp:151
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Definition: SkRRect.h:180
sk_sp< SkShader > makeWithColorFilter(sk_sp< SkColorFilter >) const
Definition: SkShader.cpp:43
static constexpr int kTileWidth
static constexpr int kClipInset
static constexpr int kTileHeight
clipRect(r.rect, r.opAA.op(), r.opAA.aa())) template<> void Draw
sk_sp< const SkImage > image
Definition: SkRecords.h:269
sk_sp< SkImage > GetResourceAsImage(const char *resource)
Definition: DecodeUtils.h:25
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659
SkRect makeInset(float dx, float dy) const
Definition: SkRect.h:987
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ onOnceBeforeDraw()

void skiagm::GraphiteStartGM::onOnceBeforeDraw ( )
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 267 of file graphitestart.cpp.

267 {
269 ToolUtils::GetResourceAsBitmap("images/color_wheel.gif", &fBitmap);
270 }
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
void setBGColor(SkColor)
Definition: gm.cpp:159
bool GetResourceAsBitmap(const char *resource, SkBitmap *dst)
Definition: DecodeUtils.h:21

Member Data Documentation

◆ kClipInset

constexpr int skiagm::GraphiteStartGM::kClipInset = 4
staticconstexprprotected

Definition at line 265 of file graphitestart.cpp.

◆ kHeight

constexpr int skiagm::GraphiteStartGM::kHeight = 3 * kTileHeight
staticconstexprprotected

Definition at line 264 of file graphitestart.cpp.

◆ kTileHeight

constexpr int skiagm::GraphiteStartGM::kTileHeight = 128
staticconstexprprotected

Definition at line 262 of file graphitestart.cpp.

◆ kTileWidth

constexpr int skiagm::GraphiteStartGM::kTileWidth = 128
staticconstexprprotected

Definition at line 261 of file graphitestart.cpp.

◆ kWidth

constexpr int skiagm::GraphiteStartGM::kWidth = 3 * kTileWidth
staticconstexprprotected

Definition at line 263 of file graphitestart.cpp.


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