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

Public Member Functions

 Xfermodes2GM (bool grayscale)
 
- 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 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 34 of file xfermodes2.cpp.

Constructor & Destructor Documentation

◆ Xfermodes2GM()

skiagm::Xfermodes2GM::Xfermodes2GM ( bool  grayscale)
inline

Definition at line 36 of file xfermodes2.cpp.

36: fGrayscale(grayscale) {}

Member Function Documentation

◆ getISize()

SkISize skiagm::Xfermodes2GM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 43 of file xfermodes2.cpp.

43{ return SkISize::Make(455, 475); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 39 of file xfermodes2.cpp.

39 {
40 return fGrayscale ? SkString("xfermodes2_gray") : SkString("xfermodes2");
41 }

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 45 of file xfermodes2.cpp.

45 {
46 canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
47
48 const SkScalar w = SkIntToScalar(kSize);
49 const SkScalar h = SkIntToScalar(kSize);
50
52
53 const int W = 6;
54
55 SkScalar x = 0, y = 0;
56 for (size_t m = 0; m < kSkBlendModeCount; m++) {
57 SkBlendMode mode = static_cast<SkBlendMode>(m);
58
59 canvas->save();
60
61 canvas->translate(x, y);
62 SkPaint p;
63 p.setAntiAlias(false);
64 p.setStyle(SkPaint::kFill_Style);
65 p.setShader(fBG);
67 canvas->drawRect(r, p);
68
69 canvas->saveLayer(&r, nullptr);
70
71 p.setShader(fDst);
72 canvas->drawRect(r, p);
73 p.setShader(fSrc);
74 p.setBlendMode(mode);
75 canvas->drawRect(r, p);
76
77 canvas->restore();
78
80 p.setStyle(SkPaint::kStroke_Style);
81 p.setShader(nullptr);
82 p.setBlendMode(SkBlendMode::kSrcOver);
83 canvas->drawRect(r, p);
84
85 canvas->restore();
86
87#if 1
88 SkTextUtils::DrawString(canvas, SkBlendMode_Name(mode), x + w/2, y - font.getSize()/2, font, SkPaint(),
90#endif
91 x += w + SkIntToScalar(10);
92 if ((m % W) == W - 1) {
93 x = 0;
94 y += h + SkIntToScalar(30);
95 }
96 }
97 }
SK_API const char * SkBlendMode_Name(SkBlendMode blendMode)
static constexpr int kSkBlendModeCount
Definition: SkBlendMode.h:76
SkBlendMode
Definition: SkBlendMode.h:38
@ kSrcOver
r = s + (1-sa)*d
#define SK_ScalarHalf
Definition: SkScalar.h:19
#define SkIntToScalar(x)
Definition: SkScalar.h:57
#define W
Definition: aaa.cpp:17
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 restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
Definition: SkFont.h:35
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
static void DrawString(SkCanvas *canvas, const char text[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint, Align align=kLeft_Align)
Definition: SkTextUtils.h:34
float SkScalar
Definition: extension.cpp:12
double y
double x
SkFont DefaultPortableFont()
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 mode
Definition: switches.h:228
font
Font Metadata and Metrics.
SkScalar w
SkScalar h
void inset(float dx, float dy)
Definition: SkRect.h:1060
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

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