Flutter Engine
The Flutter Engine
Public Member Functions | Protected Attributes | List of all members
SkOpContourBuilder Class Reference

#include <SkOpContour.h>

Public Member Functions

 SkOpContourBuilder (SkOpContour *contour)
 
void addConic (SkPoint pts[3], SkScalar weight)
 
void addCubic (SkPoint pts[4])
 
void addCurve (SkPath::Verb verb, const SkPoint pts[4], SkScalar weight=1)
 
void addLine (const SkPoint pts[2])
 
void addQuad (SkPoint pts[3])
 
void flush ()
 
SkOpContourcontour ()
 
void setContour (SkOpContour *contour)
 

Protected Attributes

SkOpContourfContour
 
SkPoint fLastLine [2]
 
bool fLastIsLine
 

Detailed Description

Definition at line 441 of file SkOpContour.h.

Constructor & Destructor Documentation

◆ SkOpContourBuilder()

SkOpContourBuilder::SkOpContourBuilder ( SkOpContour contour)
inline

Definition at line 443 of file SkOpContour.h.

445 , fLastIsLine(false) {
446 }
SkOpContour * fContour
Definition: SkOpContour.h:457

Member Function Documentation

◆ addConic()

void SkOpContourBuilder::addConic ( SkPoint  pts[3],
SkScalar  weight 
)

Definition at line 46 of file SkOpContour.cpp.

46 {
47 this->flush();
48 fContour->addConic(pts, weight);
49}
void addConic(SkPoint pts[3], SkScalar weight)
Definition: SkOpContour.h:40

◆ addCubic()

void SkOpContourBuilder::addCubic ( SkPoint  pts[4])

Definition at line 51 of file SkOpContour.cpp.

51 {
52 this->flush();
53 fContour->addCubic(pts);
54}
void addCubic(SkPoint pts[4])
Definition: SkOpContour.h:44

◆ addCurve()

void SkOpContourBuilder::addCurve ( SkPath::Verb  verb,
const SkPoint  pts[4],
SkScalar  weight = 1 
)

Definition at line 56 of file SkOpContour.cpp.

56 {
57 if (SkPath::kLine_Verb == verb) {
58 this->addLine(pts);
59 return;
60 }
61 SkArenaAlloc* allocator = fContour->globalState()->allocator();
62 switch (verb) {
63 case SkPath::kQuad_Verb: {
64 SkPoint* ptStorage = allocator->makeArrayDefault<SkPoint>(3);
65 memcpy(ptStorage, pts, sizeof(SkPoint) * 3);
66 this->addQuad(ptStorage);
67 } break;
69 SkPoint* ptStorage = allocator->makeArrayDefault<SkPoint>(3);
70 memcpy(ptStorage, pts, sizeof(SkPoint) * 3);
71 this->addConic(ptStorage, weight);
72 } break;
74 SkPoint* ptStorage = allocator->makeArrayDefault<SkPoint>(4);
75 memcpy(ptStorage, pts, sizeof(SkPoint) * 4);
76 this->addCubic(ptStorage);
77 } break;
78 default:
79 SkASSERT(0);
80 }
81}
#define SkASSERT(cond)
Definition: SkAssert.h:116
T * makeArrayDefault(size_t count)
Definition: SkArenaAlloc.h:171
void addConic(SkPoint pts[3], SkScalar weight)
Definition: SkOpContour.cpp:46
void addCubic(SkPoint pts[4])
Definition: SkOpContour.cpp:51
void addQuad(SkPoint pts[3])
Definition: SkOpContour.cpp:97
void addLine(const SkPoint pts[2])
Definition: SkOpContour.cpp:83
SkOpGlobalState * globalState() const
Definition: SkOpContour.h:139
SkArenaAlloc * allocator()
@ kConic_Verb
Definition: SkPath.h:1469
@ kCubic_Verb
Definition: SkPath.h:1470
@ kQuad_Verb
Definition: SkPath.h:1468
@ kLine_Verb
Definition: SkPath.h:1467

◆ addLine()

void SkOpContourBuilder::addLine ( const SkPoint  pts[2])

Definition at line 83 of file SkOpContour.cpp.

83 {
84 // if the previous line added is the exact opposite, eliminate both
85 if (fLastIsLine) {
86 if (fLastLine[0] == pts[1] && fLastLine[1] == pts[0]) {
87 fLastIsLine = false;
88 return;
89 } else {
90 flush();
91 }
92 }
93 memcpy(fLastLine, pts, sizeof(fLastLine));
94 fLastIsLine = true;
95}
SkPoint fLastLine[2]
Definition: SkOpContour.h:458

◆ addQuad()

void SkOpContourBuilder::addQuad ( SkPoint  pts[3])

Definition at line 97 of file SkOpContour.cpp.

97 {
98 this->flush();
99 fContour->addQuad(pts);
100}
void addQuad(SkPoint pts[3])
Definition: SkOpContour.h:53

◆ contour()

SkOpContour * SkOpContourBuilder::contour ( )
inline

Definition at line 454 of file SkOpContour.h.

454{ return fContour; }

◆ flush()

void SkOpContourBuilder::flush ( )

Definition at line 102 of file SkOpContour.cpp.

102 {
103 if (!fLastIsLine)
104 return;
105 SkArenaAlloc* allocator = fContour->globalState()->allocator();
106 SkPoint* ptStorage = allocator->makeArrayDefault<SkPoint>(2);
107 memcpy(ptStorage, fLastLine, sizeof(fLastLine));
108 (void) fContour->addLine(ptStorage);
109 fLastIsLine = false;
110}
SkOpSegment * addLine(SkPoint pts[2])
Definition: SkOpContour.h:48

◆ setContour()

void SkOpContourBuilder::setContour ( SkOpContour contour)
inline

Definition at line 455 of file SkOpContour.h.

455{ flush(); fContour = contour; }
SkOpContour * contour()
Definition: SkOpContour.h:454

Member Data Documentation

◆ fContour

SkOpContour* SkOpContourBuilder::fContour
protected

Definition at line 457 of file SkOpContour.h.

◆ fLastIsLine

bool SkOpContourBuilder::fLastIsLine
protected

Definition at line 459 of file SkOpContour.h.

◆ fLastLine

SkPoint SkOpContourBuilder::fLastLine[2]
protected

Definition at line 458 of file SkOpContour.h.


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