Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
GrAAConvexTessellator Class Reference

#include <GrAAConvexTessellator.h>

Public Member Functions

 GrAAConvexTessellator (SkStrokeRec::Style style=SkStrokeRec::kFill_Style, SkScalar strokeWidth=-1.0f, SkPaint::Join join=SkPaint::Join::kBevel_Join, SkScalar miterLimit=0.0f)
 
SkPointPriv::Side side () const
 
bool tessellate (const SkMatrix &m, const SkPath &path)
 
int numPts () const
 
int numIndices () const
 
const SkPointlastPoint () const
 
const SkPointpoint (int index) const
 
int index (int index) const
 
SkScalar coverage (int index) const
 
void rewind ()
 

Detailed Description

Definition at line 31 of file GrAAConvexTessellator.h.

Constructor & Destructor Documentation

◆ GrAAConvexTessellator()

GrAAConvexTessellator::GrAAConvexTessellator ( SkStrokeRec::Style  style = SkStrokeRec::kFill_Style,
SkScalar  strokeWidth = -1.0f,
SkPaint::Join  join = SkPaint::Join::kBevel_Join,
SkScalar  miterLimit = 0.0f 
)
inline

Definition at line 33 of file GrAAConvexTessellator.h.

38 , fStrokeWidth(strokeWidth)
39 , fStyle(style)
40 , fJoin(join)
41 , fMiterLimit(miterLimit) {
42 }
static const int strokeWidth
Definition: BlurTest.cpp:60
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741

Member Function Documentation

◆ coverage()

SkScalar GrAAConvexTessellator::coverage ( int  index) const
inline

Definition at line 55 of file GrAAConvexTessellator.h.

55{ return fCoverages[index]; }
int index(int index) const

◆ index()

int GrAAConvexTessellator::index ( int  index) const
inline

Definition at line 54 of file GrAAConvexTessellator.h.

54{ return fIndices[index]; }

◆ lastPoint()

const SkPoint & GrAAConvexTessellator::lastPoint ( ) const
inline

Definition at line 52 of file GrAAConvexTessellator.h.

52{ return fPts.back(); }
const T & back() const
Definition: SkTDArray.h:162

◆ numIndices()

int GrAAConvexTessellator::numIndices ( ) const
inline

Definition at line 50 of file GrAAConvexTessellator.h.

50{ return fIndices.size(); }
int size() const
Definition: SkTDArray.h:138

◆ numPts()

int GrAAConvexTessellator::numPts ( ) const
inline

Definition at line 49 of file GrAAConvexTessellator.h.

49{ return fPts.size(); }

◆ point()

const SkPoint & GrAAConvexTessellator::point ( int  index) const
inline

Definition at line 53 of file GrAAConvexTessellator.h.

53{ return fPts[index]; }

◆ rewind()

void GrAAConvexTessellator::rewind ( )

Definition at line 155 of file GrAAConvexTessellator.cpp.

155 {
156 fPts.clear();
157 fCoverages.clear();
158 fMovable.clear();
159 fIndices.clear();
160 fNorms.clear();
161 fCurveState.clear();
162 fInitialRing.rewind();
163 fCandidateVerts.rewind();
164#if GR_AA_CONVEX_TESSELLATOR_VIZ
165 fRings.rewind(); // TODO: leak in this case!
166#else
167 fRings[0].rewind();
168 fRings[1].rewind();
169#endif
170}
void clear()
Definition: SkTDArray.h:175

◆ side()

SkPointPriv::Side GrAAConvexTessellator::side ( ) const
inline

Definition at line 44 of file GrAAConvexTessellator.h.

44{ return fSide; }

◆ tessellate()

bool GrAAConvexTessellator::tessellate ( const SkMatrix m,
const SkPath path 
)

Definition at line 268 of file GrAAConvexTessellator.cpp.

268 {
269 if (!this->extractFromPath(m, path)) {
270 return false;
271 }
272
273 SkScalar coverage = 1.0f;
274 SkScalar scaleFactor = 0.0f;
275
276 if (SkStrokeRec::kStrokeAndFill_Style == fStyle) {
277 SkASSERT(m.isSimilarity());
278 scaleFactor = m.getMaxScale(); // x and y scale are the same
279 SkScalar effectiveStrokeWidth = scaleFactor * fStrokeWidth;
280 Ring outerStrokeAndAARing;
281 this->createOuterRing(fInitialRing,
282 effectiveStrokeWidth / 2 + kAntialiasingRadius, 0.0,
283 &outerStrokeAndAARing);
284
285 // discard all the triangles added between the originating ring and the new outer ring
286 fIndices.clear();
287
288 outerStrokeAndAARing.init(*this);
289
290 outerStrokeAndAARing.makeOriginalRing();
291
292 // Add the outer stroke ring's normals to the originating ring's normals
293 // so it can also act as an originating ring
294 fNorms.resize(fNorms.size() + outerStrokeAndAARing.numPts());
295 for (int i = 0; i < outerStrokeAndAARing.numPts(); ++i) {
296 SkASSERT(outerStrokeAndAARing.index(i) < fNorms.size());
297 fNorms[outerStrokeAndAARing.index(i)] = outerStrokeAndAARing.norm(i);
298 }
299
300 // the bisectors are only needed for the computation of the outer ring
301 fBisectors.clear();
302
303 Ring* insetAARing;
304 this->createInsetRings(outerStrokeAndAARing,
305 0.0f, 0.0f, 2*kAntialiasingRadius, 1.0f,
306 &insetAARing);
307
308 SkDEBUGCODE(this->validate();)
309 return true;
310 }
311
312 if (SkStrokeRec::kStroke_Style == fStyle) {
313 SkASSERT(fStrokeWidth >= 0.0f);
314 SkASSERT(m.isSimilarity());
315 scaleFactor = m.getMaxScale(); // x and y scale are the same
316 SkScalar effectiveStrokeWidth = scaleFactor * fStrokeWidth;
317 Ring outerStrokeRing;
318 this->createOuterRing(fInitialRing, effectiveStrokeWidth / 2 - kAntialiasingRadius,
319 coverage, &outerStrokeRing);
320 outerStrokeRing.init(*this);
321 Ring outerAARing;
322 this->createOuterRing(outerStrokeRing, kAntialiasingRadius * 2, 0.0f, &outerAARing);
323 } else {
324 Ring outerAARing;
325 this->createOuterRing(fInitialRing, kAntialiasingRadius, 0.0f, &outerAARing);
326 }
327
328 // the bisectors are only needed for the computation of the outer ring
329 fBisectors.clear();
330 if (SkStrokeRec::kStroke_Style == fStyle && fInitialRing.numPts() > 2) {
331 SkASSERT(fStrokeWidth >= 0.0f);
332 SkScalar effectiveStrokeWidth = scaleFactor * fStrokeWidth;
333 Ring* insetStrokeRing;
334 SkScalar strokeDepth = effectiveStrokeWidth / 2 - kAntialiasingRadius;
335 if (this->createInsetRings(fInitialRing, 0.0f, coverage, strokeDepth, coverage,
336 &insetStrokeRing)) {
337 Ring* insetAARing;
338 this->createInsetRings(*insetStrokeRing, strokeDepth, coverage, strokeDepth +
339 kAntialiasingRadius * 2, 0.0f, &insetAARing);
340 }
341 } else {
342 Ring* insetAARing;
343 this->createInsetRings(fInitialRing, 0.0f, 0.5f, kAntialiasingRadius, 1.0f, &insetAARing);
344 }
345
346 SkDEBUGCODE(this->validate();)
347 return true;
348}
static const SkScalar kAntialiasingRadius
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
SkScalar coverage(int index) const
@ kStrokeAndFill_Style
Definition: SkStrokeRec.h:36
float SkScalar
Definition: extension.cpp:12
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

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