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

Public Member Functions

 AlphaGradientsGM ()
 
- 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
 

Static Protected Member Functions

static void draw_grad (SkCanvas *canvas, const SkRect &r, SkColor c0, SkColor c1, bool doPreMul)
 

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 21 of file alphagradients.cpp.

Constructor & Destructor Documentation

◆ AlphaGradientsGM()

AlphaGradientsGM::AlphaGradientsGM ( )
inline

Definition at line 23 of file alphagradients.cpp.

23{}

Member Function Documentation

◆ draw_grad()

static void AlphaGradientsGM::draw_grad ( SkCanvas canvas,
const SkRect r,
SkColor  c0,
SkColor  c1,
bool  doPreMul 
)
inlinestaticprotected

Definition at line 30 of file alphagradients.cpp.

31 {
32 SkColor colors[] = { c0, c1 };
33 SkPoint pts[] = { { r.fLeft, r.fTop }, { r.fRight, r.fBottom } };
36 paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2,
37 SkTileMode::kClamp, flags, nullptr));
38 canvas->drawRect(r, paint);
39
40 paint.setShader(nullptr);
42 canvas->drawRect(r, paint);
43 }
uint32_t SkColor
Definition: SkColor.h:37
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
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)
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
const Paint & paint
Definition: color_source.cc:38
FlutterSemanticsFlag flags
PODArray< SkColor > colors
Definition: SkRecords.h:276
SkScalar fBottom
larger y-axis bounds
Definition: extension.cpp:17
SkScalar fLeft
smaller x-axis bounds
Definition: extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition: extension.cpp:16
SkScalar fTop
smaller y-axis bounds
Definition: extension.cpp:15

◆ getISize()

SkISize AlphaGradientsGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 28 of file alphagradients.cpp.

28{ return SkISize::Make(640, 480); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString AlphaGradientsGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 26 of file alphagradients.cpp.

26{ return SkString("alphagradients"); }

◆ onDraw()

void AlphaGradientsGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 45 of file alphagradients.cpp.

45 {
46 constexpr struct {
47 SkColor fColor0;
48 SkColor fColor1;
49 } gRec[] = {
50 { 0xFFFFFFFF, 0x00000000 },
51 { 0xFFFFFFFF, 0x00FF0000 },
52 { 0xFFFFFFFF, 0x00FFFF00 },
53 { 0xFFFFFFFF, 0x00FFFFFF },
54 { 0xFFFF0000, 0x00000000 },
55 { 0xFFFF0000, 0x00FF0000 },
56 { 0xFFFF0000, 0x00FFFF00 },
57 { 0xFFFF0000, 0x00FFFFFF },
58 { 0xFF0000FF, 0x00000000 },
59 { 0xFF0000FF, 0x00FF0000 },
60 { 0xFF0000FF, 0x00FFFF00 },
61 { 0xFF0000FF, 0x00FFFFFF },
62 };
63
64 SkRect r = SkRect::MakeWH(300, 30);
65
66 canvas->translate(10, 10);
67
68 for (int doPreMul = 0; doPreMul <= 1; ++doPreMul) {
69 canvas->save();
70 for (size_t i = 0; i < std::size(gRec); ++i) {
71 draw_grad(canvas, r, gRec[i].fColor0, gRec[i].fColor1, SkToBool(doPreMul));
72 canvas->translate(0, r.height() + 8);
73 }
74 canvas->restore();
75 canvas->translate(r.width() + 10, 0);
76 }
77 }
static const struct @223 gRec[]
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
static void draw_grad(SkCanvas *canvas, const SkRect &r, SkColor c0, SkColor c1, bool doPreMul)
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
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
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: