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

Public Member Functions

 GradientsManyColorsGM (bool dither)
 
- 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 228 of file gradients_no_texture.cpp.

Constructor & Destructor Documentation

◆ GradientsManyColorsGM()

GradientsManyColorsGM::GradientsManyColorsGM ( bool  dither)
inline

Definition at line 236 of file gradients_no_texture.cpp.

236: fDither(dither) {}

Member Function Documentation

◆ getISize()

SkISize GradientsManyColorsGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 243 of file gradients_no_texture.cpp.

243{ return SkISize::Make(880, 400); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString GradientsManyColorsGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 239 of file gradients_no_texture.cpp.

239 {
240 return SkString(fDither ? "gradients_many" : "gradients_many_nodither");
241 }

◆ onDraw()

void GradientsManyColorsGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 245 of file gradients_no_texture.cpp.

245 {
246 const Proc procs[] = {
248 };
249 const SkPoint pts[] = {
250 { 0, 0 },
251 { SkIntToScalar(W), 0 },
252 };
253 const SkRect r = SkRect::MakeWH(SkIntToScalar(W), 30);
254
256 paint.setDither(fDither);
257
258 canvas->translate(40, 20);
259
260 for (int i = 0; i <= 8; ++i) {
261 SkScalar x = r.width() * i / 8;
262 canvas->drawLine(x, 0, x, 10000, paint);
263 }
264
265 // expand the drawing rect so we exercise clampping in the gradients
266 const SkRect drawR = r.makeOutset(20, 0);
267 for (size_t i = 0; i < std::size(procs); ++i) {
268 ColorPos rec;
269 procs[i](&rec);
270 paint.setShader(SkGradientShader::MakeLinear(pts, rec.fColors, rec.fPos, rec.fCount,
272 canvas->drawRect(drawR, paint);
273
274 canvas->save();
275 canvas->translate(r.centerX(), r.height() + 4);
276 canvas->scale(-1, 1);
277 canvas->translate(-r.centerX(), 0);
278 canvas->drawRect(drawR, paint);
279 canvas->restore();
280
281 canvas->translate(0, r.height() + 2*r.height() + 8);
282 }
283 }
#define SkIntToScalar(x)
Definition: SkScalar.h:57
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
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
Definition: SkCanvas.cpp:2700
int save()
Definition: SkCanvas.cpp:447
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
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)
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
static void make1(ColorPos *rec)
static void make2(ColorPos *rec)
static void make3(ColorPos *rec)
static void make0(ColorPos *rec)
double x
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 keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SkRect makeOutset(float dx, float dy) const
Definition: SkRect.h:1002
constexpr float centerX() const
Definition: SkRect.h:776
constexpr float height() const
Definition: SkRect.h:769
constexpr float width() const
Definition: SkRect.h:762
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

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