Flutter Engine
The Flutter Engine
SkOpContour.cpp
Go to the documentation of this file.
1/*
2* Copyright 2013 Google Inc.
3*
4* Use of this source code is governed by a BSD-style license that can be
5* found in the LICENSE file.
6*/
8
10
11#include <cstring>
12
14 if (!this->count()) {
15 return;
16 }
17 const SkOpSegment* segment = &fHead;
18 do {
19 SkAssertResult(segment->addCurveTo(segment->head(), segment->tail(), path));
20 } while ((segment = segment->next()));
21 path->finishContour();
22 path->assemble();
23}
24
26 const SkOpSegment* segment = fTail;
27 do {
28 SkAssertResult(segment->addCurveTo(segment->tail(), segment->head(), path));
29 } while ((segment = segment->prev()));
30 path->finishContour();
31 path->assemble();
32}
33
35 SkOpSegment* testSegment = &fHead;
36 do {
37 if (testSegment->done()) {
38 continue;
39 }
40 return testSegment->undoneSpan();
41 } while ((testSegment = testSegment->next()));
42 fDone = true;
43 return nullptr;
44}
45
47 this->flush();
48 fContour->addConic(pts, weight);
49}
50
52 this->flush();
53 fContour->addCubic(pts);
54}
55
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}
82
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}
96
98 this->flush();
99 fContour->addQuad(pts);
100}
101
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}
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
#define SkASSERT(cond)
Definition: SkAssert.h:116
T * makeArrayDefault(size_t count)
Definition: SkArenaAlloc.h:171
SkOpContour * fContour
Definition: SkOpContour.h:457
void addConic(SkPoint pts[3], SkScalar weight)
Definition: SkOpContour.cpp:46
void addCurve(SkPath::Verb verb, const SkPoint pts[4], SkScalar weight=1)
Definition: SkOpContour.cpp:56
SkPoint fLastLine[2]
Definition: SkOpContour.h:458
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
int count() const
Definition: SkOpContour.h:84
void addCubic(SkPoint pts[4])
Definition: SkOpContour.h:44
void toReversePath(SkPathWriter *path) const
Definition: SkOpContour.cpp:25
SkOpGlobalState * globalState() const
Definition: SkOpContour.h:139
SkOpSpan * undoneSpan()
Definition: SkOpContour.cpp:34
SkOpSegment * fTail
Definition: SkOpContour.h:385
void addQuad(SkPoint pts[3])
Definition: SkOpContour.h:53
void addConic(SkPoint pts[3], SkScalar weight)
Definition: SkOpContour.h:40
void toPath(SkPathWriter *path) const
Definition: SkOpContour.cpp:13
SkOpSegment fHead
Definition: SkOpContour.h:384
SkOpSegment * addLine(SkPoint pts[2])
Definition: SkOpContour.h:48
SkArenaAlloc * allocator()
bool done() const
Definition: SkOpSegment.h:200
const SkOpSegment * prev() const
Definition: SkOpSegment.h:319
const SkOpSpanBase * tail() const
Definition: SkOpSegment.h:398
SkOpSpan * undoneSpan()
const SkOpSpan * head() const
Definition: SkOpSegment.h:234
bool addCurveTo(const SkOpSpanBase *start, const SkOpSpanBase *end, SkPathWriter *path) const
SkOpSegment * next() const
Definition: SkOpSegment.h:304
@ kConic_Verb
Definition: SkPath.h:1469
@ kCubic_Verb
Definition: SkPath.h:1470
@ kQuad_Verb
Definition: SkPath.h:1468
@ kLine_Verb
Definition: SkPath.h:1467
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