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

Public Member Functions

 AnalyticGradientShaderGM ()
 
- 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 133 of file analytic_gradients.cpp.

Constructor & Destructor Documentation

◆ AnalyticGradientShaderGM()

AnalyticGradientShaderGM::AnalyticGradientShaderGM ( )
inline

Definition at line 135 of file analytic_gradients.cpp.

135 {
136
137 }

Member Function Documentation

◆ getISize()

SkISize AnalyticGradientShaderGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 142 of file analytic_gradients.cpp.

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

◆ getName()

SkString AnalyticGradientShaderGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 140 of file analytic_gradients.cpp.

140{ return SkString("analytic_gradients"); }

◆ onDraw()

void AnalyticGradientShaderGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 144 of file analytic_gradients.cpp.

144 {
145 const SkPoint points[2] = { SkPoint::Make(0, 0), SkPoint::Make(RECT_WIDTH, 0.0) };
146
147 for (int cellRow = 0; cellRow < NUM_ROWS; cellRow++) {
148 // Each interval has 4 different color counts, one per mode
149 const int* colorCounts = INTERVAL_COLOR_COUNTS[cellRow]; // Has len = 4
150
151 for (int cellCol = 0; cellCol < NUM_COLS; cellCol++) {
152 // create_gradient_points(cellRow, cellCol, points);
153
154 // Get the color count dependent on interval and mode
155 int colorCount = colorCounts[cellCol];
156 // Get the positions given the mode
157 const int* layout = M_POSITIONS[cellCol];
158
159 // Collect positions and colors specific to the interval+mode normalizing the
160 // position based on the interval count (== cellRow+1)
162 AutoSTMalloc<4, SkScalar> positions(colorCount);
163 int j = 0;
164 for (int i = 0; i < colorCount; i++) {
165 positions[i] = SkIntToScalar(layout[i]) / (cellRow + 1);
166 colors[i] = COLORS[j % COLOR_COUNT];
167 j++;
168 }
169
170 auto shader = SkGradientShader::MakeLinear(
171 points,
172 colors.get(),
173 positions.get(),
174 colorCount,
176 0,
177 nullptr);
178
179 shade_rect(canvas, shader, cellRow, cellCol);
180 }
181 }
182 }
static const int points[]
#define SkIntToScalar(x)
Definition: SkScalar.h:57
const SkColor COLORS[]
static void shade_rect(SkCanvas *canvas, sk_sp< SkShader > shader, int cellRow, int cellCol)
const int NUM_COLS
const int RECT_WIDTH
const int * M_POSITIONS[]
const int * INTERVAL_COLOR_COUNTS[]
const int COLOR_COUNT
const int NUM_ROWS
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)
PODArray< SkColor > colors
Definition: SkRecords.h:276
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173

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