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

Public Member Functions

 ComplexClip3GM (bool doSimpleClipFirst)
 
- 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 30 of file complexclip3.cpp.

Constructor & Destructor Documentation

◆ ComplexClip3GM()

skiagm::ComplexClip3GM::ComplexClip3GM ( bool  doSimpleClipFirst)
inline

Definition at line 32 of file complexclip3.cpp.

33 : fDoSimpleClipFirst(doSimpleClipFirst) {
34 this->setBGColor(0xFFDDDDDD);
35 }
void setBGColor(SkColor)
Definition: gm.cpp:159

Member Function Documentation

◆ getISize()

SkISize skiagm::ComplexClip3GM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 44 of file complexclip3.cpp.

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

◆ getName()

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

Implements skiagm::GM.

Definition at line 38 of file complexclip3.cpp.

38 {
39 SkString str;
40 str.printf("complexclip3_%s", fDoSimpleClipFirst ? "simple" : "complex");
41 return str;
42 }
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534

◆ onDraw()

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

Reimplemented from skiagm::GM.

Definition at line 46 of file complexclip3.cpp.

46 {
47 SkPath clipSimple = SkPath::Circle(70, 50, 20);
48
49 SkRect r1 = { 10, 20, 70, 80 };
50 SkPath clipComplex = SkPathBuilder().moveTo(40, 50)
51 .arcTo(r1, 30, 300, false)
52 .close()
53 .detach();
54
55 SkPath* firstClip = &clipSimple;
56 SkPath* secondClip = &clipComplex;
57 if (!fDoSimpleClipFirst) {
58 std::swap(firstClip, secondClip);
59 }
60
62 paint.setAntiAlias(true);
63
65
66 constexpr struct {
67 SkClipOp fOp;
68 const char* fName;
69 } gOps[] = {
72 };
73
74 canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
75 canvas->scale(3 * SK_Scalar1 / 4, 3 * SK_Scalar1 / 4);
76
77 SkPaint pathPaint;
78 pathPaint.setAntiAlias(true);
79 pathPaint.setColor(gPathColor);
80
81 for (int invA = 0; invA < 2; ++invA) {
82 for (int aaBits = 0; aaBits < 4; ++aaBits) {
83 canvas->save();
84 for (size_t op = 0; op < std::size(gOps); ++op) {
85 for (int invB = 0; invB < 2; ++invB) {
86 bool doAAA = SkToBool(aaBits & 1);
87 bool doAAB = SkToBool(aaBits & 2);
88 bool doInvA = SkToBool(invA);
89 bool doInvB = SkToBool(invB);
90 canvas->save();
91 // set clip
94 secondClip->setFillType(doInvB ? SkPathFillType::kInverseEvenOdd :
96 canvas->clipPath(*firstClip, doAAA);
97 canvas->clipPath(*secondClip, gOps[op].fOp, doAAB);
98
99 // draw rect clipped
100 SkRect r = { 0, 0, 100, 100 };
101 canvas->drawRect(r, pathPaint);
102 canvas->restore();
103
104
105 SkScalar txtX = SkIntToScalar(10);
106 paint.setColor(SK_ColorBLACK);
107 SkString str;
108 str.printf("%s%s %s %s%s", doAAA ? "A" : "B",
109 doInvA ? "I" : "N",
110 gOps[op].fName,
111 doAAB ? "A" : "B",
112 doInvB ? "I" : "N");
113
114 canvas->drawString(str.c_str(), txtX, SkIntToScalar(130), font, paint);
115 if (doInvB) {
116 canvas->translate(SkIntToScalar(150),0);
117 } else {
118 canvas->translate(SkIntToScalar(120),0);
119 }
120 }
121 }
122 canvas->restore();
123 canvas->translate(0, SkIntToScalar(150));
124 }
125 }
126 }
SkClipOp
Definition: SkClipOp.h:13
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition: SkRefCnt.h:341
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkIntToScalar(x)
Definition: SkScalar.h:57
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
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 clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1456
int save()
Definition: SkCanvas.cpp:447
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
Definition: SkFont.h:35
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
SkPathBuilder & close()
SkPathBuilder & arcTo(const SkRect &oval, SkScalar startAngleDeg, SkScalar sweepAngleDeg, bool forceMoveTo)
SkPathBuilder & moveTo(SkPoint pt)
Definition: SkPath.h:59
void setFillType(SkPathFillType ft)
Definition: SkPath.h:235
static SkPath Circle(SkScalar center_x, SkScalar center_y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:3598
const char * c_str() const
Definition: SkString.h:133
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
sk_sp< SkTypeface > DefaultPortableTypeface()
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
font
Font Metadata and Metrics.
constexpr SkColor gPathColor
Definition: complexclip.cpp:34
const char * fName

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