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

Public Member Functions

 TrimGM ()
 
void onOnceBeforeDraw () override
 
- 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
 
bool onAnimate (double nanos) 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 77 of file dashcubics.cpp.

Constructor & Destructor Documentation

◆ TrimGM()

TrimGM::TrimGM ( )
inline

Definition at line 79 of file dashcubics.cpp.

79{}

Member Function Documentation

◆ getISize()

SkISize TrimGM::getISize ( )
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 109 of file dashcubics.cpp.

109{ return SkISize::Make(1400, 1000); }
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ getName()

SkString TrimGM::getName ( ) const
inlineoverrideprotectedvirtual

Implements skiagm::GM.

Definition at line 107 of file dashcubics.cpp.

107{ return SkString("trimpatheffect"); }

◆ onAnimate()

bool TrimGM::onAnimate ( double  nanos)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 166 of file dashcubics.cpp.

166 {
167 fOffset = TimeUtils::NanosToMSec(nanos) / 2000.0f;
168 fOffset -= floorf(fOffset);
169 return true;
170 }
static SkMSec NanosToMSec(double nanos)
Definition: TimeUtils.h:16

◆ onDraw()

void TrimGM::onDraw ( SkCanvas canvas)
inlineoverrideprotectedvirtual

Reimplemented from skiagm::GM.

Definition at line 111 of file dashcubics.cpp.

111 {
112 static constexpr SkSize kCellSize = { 440, 150 };
113 static constexpr SkScalar kOffsets[][2] = {
114 { -0.33f, -0.66f },
115 { 0 , 1 },
116 { 0 , 0.25f},
117 { 0.25f, 0.75f},
118 { 0.75f, 1 },
119 { 1 , 0.75f},
120 };
121
122 SkPaint hairlinePaint;
123 hairlinePaint.setAntiAlias(true);
124 hairlinePaint.setStroke(true);
125 hairlinePaint.setStrokeCap(SkPaint::kRound_Cap);
126 hairlinePaint.setStrokeWidth(2);
127 SkPaint normalPaint = hairlinePaint;
128 normalPaint.setStrokeWidth(10);
129 normalPaint.setColor(0x8000ff00);
130 SkPaint invertedPaint = normalPaint;
131 invertedPaint.setColor(0x80ff0000);
132
133 for (const auto& offset : kOffsets) {
134 auto start = offset[0] + fOffset,
135 stop = offset[1] + fOffset;
136
137 auto normalMode = SkTrimPathEffect::Mode::kNormal,
139 if (fOffset) {
141 stop -= SkScalarFloorToScalar(stop);
142 if (start > stop) {
143 using std::swap;
144 swap(start, stop);
145 swap(normalMode, invertedMode);
146 }
147 }
148
149 normalPaint.setPathEffect(SkTrimPathEffect::Make(start, stop, normalMode));
150 invertedPaint.setPathEffect(SkTrimPathEffect::Make(start, stop, invertedMode));
151
152 {
153 SkAutoCanvasRestore acr(canvas, true);
154 for (const auto& path : fPaths) {
155 canvas->drawPath(path, normalPaint);
156 canvas->drawPath(path, invertedPaint);
157 canvas->drawPath(path, hairlinePaint);
158 canvas->translate(kCellSize.width(), 0);
159 }
160 }
161
162 canvas->translate(0, kCellSize.height());
163 }
164 }
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition: SkRefCnt.h:341
#define SkScalarFloorToScalar(x)
Definition: SkScalar.h:30
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
@ kRound_Cap
adds circle
Definition: SkPaint.h:335
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
void setStrokeCap(Cap cap)
Definition: SkPaint.cpp:179
void setPathEffect(sk_sp< SkPathEffect > pathEffect)
void setStroke(bool)
Definition: SkPaint.cpp:115
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
static sk_sp< SkPathEffect > Make(SkScalar startT, SkScalar stopT, Mode=Mode::kNormal)
float SkScalar
Definition: extension.cpp:12
const int kCellSize
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
SeparatedVector2 offset
Definition: SkSize.h:52

◆ onOnceBeforeDraw()

void TrimGM::onOnceBeforeDraw ( )
inlineoverridevirtual

Reimplemented from skiagm::GM.

Definition at line 81 of file dashcubics.cpp.

81 {
83 "M 0,100 C 10, 50 190, 50 200,100"
84 "M 200,100 C 210,150 390,150 400,100"
85 "M 400,100 C 390, 50 210, 50 200,100"
86 "M 200,100 C 190,150 10,150 0,100",
87 &fPaths.push_back()));
88
90 "M 0, 75 L 200, 75"
91 "M 200, 91 L 200, 91"
92 "M 200,108 L 200,108"
93 "M 200,125 L 400,125",
94 &fPaths.push_back()));
95
97 "M 0,100 L 50, 50"
98 "M 50, 50 L 150,150"
99 "M 150,150 L 250, 50"
100 "M 250, 50 L 350,150"
101 "M 350,150 L 400,100",
102 &fPaths.push_back()));
103
104 }
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
static bool FromSVGString(const char str[], SkPath *)

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