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

Public Member Functions

 HardstopGradientShaderGM ()
 
- 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 91 of file hardstop_gradients.cpp.

Constructor & Destructor Documentation

◆ HardstopGradientShaderGM()

HardstopGradientShaderGM::HardstopGradientShaderGM ( )
inline

Definition at line 93 of file hardstop_gradients.cpp.

93 {
94
95 }

Member Function Documentation

◆ getISize()

SkISize HardstopGradientShaderGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 100 of file hardstop_gradients.cpp.

100{ return SkISize::Make(512, 512); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString HardstopGradientShaderGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 98 of file hardstop_gradients.cpp.

98{ return SkString("hardstop_gradients"); }

◆ onDraw()

void HardstopGradientShaderGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 102 of file hardstop_gradients.cpp.

102 {
103 SkPoint points[2];
104
105 SkColor colors[] = {
111 };
112
113 SkScalar row3[] = {0.00f, 0.25f, 1.00f};
114 SkScalar row4[] = {0.00f, 0.25f, 0.50f, 0.50f, 1.00f};
115 SkScalar row5[] = {0.00f, 0.50f, 0.50f, 1.00f};
116 SkScalar row6[] = {0.00f, 0.00f, 1.00f};
117 SkScalar row7[] = {0.00f, 1.00f, 1.00f};
118 SkScalar row8[] = {0.00f, 0.30f, 0.30f, 1.00f};
119
120 SkScalar* positions[NUM_ROWS] = {
121 nullptr,
122 nullptr,
123 row3,
124 row4,
125 row5,
126 row6,
127 row7,
128 row8,
129 };
130
131 int numGradientColors[NUM_ROWS] = {
132 2,
133 3,
134 3,
135 5,
136 4,
137 3,
138 3,
139 4,
140 };
141
142 SkTileMode tilemodes[NUM_COLS] = {
146 };
147
148 for (int cellRow = 0; cellRow < NUM_ROWS; cellRow++) {
149 for (int cellCol = 0; cellCol < NUM_COLS; cellCol++) {
150 create_gradient_points(cellRow, cellCol, points);
151
152 auto shader = SkGradientShader::MakeLinear(
153 points,
154 colors,
155 positions[cellRow],
156 numGradientColors[cellRow],
157 tilemodes[cellCol],
158 0,
159 nullptr);
160
161 shade_rect(canvas, shader, cellRow, cellCol);
162 }
163 }
164 }
static const int points[]
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
constexpr SkColor SK_ColorMAGENTA
Definition: SkColor.h:147
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
SkTileMode
Definition: SkTileMode.h:13
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)
float SkScalar
Definition: extension.cpp:12
static void shade_rect(SkCanvas *canvas, sk_sp< SkShader > shader, int cellRow, int cellCol)
const int NUM_COLS
static void create_gradient_points(int cellRow, int cellCol, SkPoint points[2])
const int NUM_ROWS
PODArray< SkColor > colors
Definition: SkRecords.h:276

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