Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | List of all members
skiagm::NestedGM Class Reference
Inheritance diagram for skiagm::NestedGM:
skiagm::GM

Public Member Functions

 NestedGM (bool doAA, bool flipped)
 
- 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 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 Types

enum  Shapes { kRect_Shape = 0 , kRRect_Shape , kOval_Shape , kShapeCount }
 

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 bool onAnimate (double)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
GraphiteTestContextgraphiteTestContext () const
 

Static Protected Member Functions

static void AddShape (SkPathBuilder *b, const SkRect &rect, Shapes shape, SkPathDirection dir)
 

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 24 of file nested.cpp.

Member Enumeration Documentation

◆ Shapes

enum skiagm::NestedGM::Shapes
protected
Enumerator
kRect_Shape 
kRRect_Shape 
kOval_Shape 
kShapeCount 

Definition at line 46 of file nested.cpp.

Constructor & Destructor Documentation

◆ NestedGM()

skiagm::NestedGM::NestedGM ( bool  doAA,
bool  flipped 
)
inline

Definition at line 26 of file nested.cpp.

26 : fDoAA(doAA), fFlipped(flipped) {
27 this->setBGColor(0xFFDDDDDD);
28 }
void setBGColor(SkColor)
Definition gm.cpp:159

Member Function Documentation

◆ AddShape()

static void skiagm::NestedGM::AddShape ( SkPathBuilder b,
const SkRect rect,
Shapes  shape,
SkPathDirection  dir 
)
inlinestaticprotected

Definition at line 53 of file nested.cpp.

53 {
54 switch (shape) {
55 case kRect_Shape:
56 b->addRect(rect, dir);
57 break;
58 case kRRect_Shape: {
59 SkRRect rr;
60 rr.setRectXY(rect, 5, 5);
61 b->addRRect(rr, dir);
62 break;
63 }
64 case kOval_Shape:
65 b->addOval(rect, dir);
66 break;
67 default:
68 break;
69 }
70 }
void setRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Definition SkRRect.cpp:52
static bool b

◆ getISize()

SkISize skiagm::NestedGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 44 of file nested.cpp.

44{ return SkISize::Make(kImageWidth, kImageHeight); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ getName()

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

Implements skiagm::GM.

Definition at line 31 of file nested.cpp.

31 {
32 SkString name("nested");
33 if (fFlipped) {
34 name.append("_flipY");
35 }
36 if (fDoAA) {
37 name.append("_aa");
38 } else {
39 name.append("_bw");
40 }
41 return name;
42 }
const char * name
Definition fuchsia.cc:50

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 72 of file nested.cpp.

72 {
73
74 SkPaint shapePaint;
75 shapePaint.setColor(SK_ColorBLACK);
76 shapePaint.setAntiAlias(fDoAA);
77
78 SkRect outerRect = SkRect::MakeWH(40, 40);
79
80 SkRect innerRects[] = {
81 { 10, 10, 30, 30 }, // small
82 { .5f, 18, 4.5f, 22 } // smaller and offset to left
83 };
84
85 // draw a background pattern to make transparency errors more apparent
86 SkRandom rand;
87
88 for (int y = 0; y < kImageHeight; y += 10) {
89 for (int x = 0; x < kImageWidth; x += 10) {
92 10, 10);
93 SkPaint p;
94 p.setColor(rand.nextU() | 0xFF000000);
95 canvas->drawRect(r, p);
96 }
97 }
98
99 SkScalar xOff = 2, yOff = 2;
100 for (int outerShape = 0; outerShape < kShapeCount; ++outerShape) {
101 for (int innerShape = 0; innerShape < kShapeCount; ++innerShape) {
102 for (size_t innerRect = 0; innerRect < std::size(innerRects); ++innerRect) {
104
105 AddShape(&builder, outerRect, (Shapes) outerShape, SkPathDirection::kCW);
106 AddShape(&builder, innerRects[innerRect], (Shapes) innerShape,
108
109 canvas->save();
110 if (fFlipped) {
111 canvas->scale(1.0f, -1.0f);
112 canvas->translate(xOff, -yOff - 40.0f);
113 } else {
114 canvas->translate(xOff, yOff);
115 }
116
117 canvas->drawPath(builder.detach(), shapePaint);
118 canvas->restore();
119
120 xOff += 45;
121 }
122 }
123
124 xOff = 2;
125 yOff += 45;
126 }
127
128 }
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
#define SkIntToScalar(x)
Definition SkScalar.h:57
void drawRect(const SkRect &rect, const SkPaint &paint)
void restore()
Definition SkCanvas.cpp:465
void translate(SkScalar dx, SkScalar dy)
int save()
Definition SkCanvas.cpp:451
void drawPath(const SkPath &path, const SkPaint &paint)
void scale(SkScalar sx, SkScalar sy)
void setColor(SkColor color)
Definition SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition SkPaint.h:170
uint32_t nextU()
Definition SkRandom.h:42
static void AddShape(SkPathBuilder *b, const SkRect &rect, Shapes shape, SkPathDirection dir)
Definition nested.cpp:53
float SkScalar
Definition extension.cpp:12
double y
double x
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659
static constexpr SkRect MakeWH(float w, float h)
Definition SkRect.h:609

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