Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/effects/SkArcToPathEffect.cpp

Issue 813513003: add arcto patheffect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « samplecode/SamplePath.cpp ('k') | src/ports/SkGlobalInitialization_chromium.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 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 */
7
8 #include "SkArcToPathEffect.h"
9 #include "SkPath.h"
10 #include "SkPoint.h"
11 #include "SkReadBuffer.h"
12 #include "SkWriteBuffer.h"
13
14 SkArcToPathEffect::SkArcToPathEffect(SkScalar radius) : fRadius(radius) {}
15
16 bool SkArcToPathEffect::filterPath(SkPath* dst, const SkPath& src,
17 SkStrokeRec*, const SkRect*) const {
18 SkPath::Iter iter(src, false);
19 SkPath::Verb verb;
20 SkPoint pts[4];
21
22 SkPoint lastCorner = { 0, 0 }; // avoid warning
23 SkPath::Verb prevVerb = SkPath::kMove_Verb;
24
25 for (;;) {
26 switch (verb = iter.next(pts, false)) {
27 case SkPath::kMove_Verb:
28 if (SkPath::kLine_Verb == prevVerb) {
29 dst->lineTo(lastCorner);
30 }
31 dst->moveTo(pts[0]);
32 break;
33 case SkPath::kLine_Verb:
34 if (prevVerb == SkPath::kLine_Verb) {
35 dst->arcTo(pts[0], pts[1], fRadius);
36 }
37 lastCorner = pts[1];
38 break;
39 case SkPath::kQuad_Verb:
40 dst->quadTo(pts[1], pts[2]);
41 lastCorner = pts[2];
42 break;
43 case SkPath::kConic_Verb:
44 dst->conicTo(pts[1], pts[2], iter.conicWeight());
45 lastCorner = pts[2];
46 break;
47 case SkPath::kCubic_Verb:
48 dst->cubicTo(pts[1], pts[2], pts[3]);
49 lastCorner = pts[3];
50 break;
51 case SkPath::kClose_Verb:
52 dst->lineTo(lastCorner);
53 break;
54 case SkPath::kDone_Verb:
55 dst->lineTo(lastCorner);
56 goto DONE;
57 }
58 prevVerb = verb;
59 }
60 DONE:
61 return true;
62 }
63
64 SkFlattenable* SkArcToPathEffect::CreateProc(SkReadBuffer& buffer) {
65 return SkArcToPathEffect::Create(buffer.readScalar());
66 }
67
68 void SkArcToPathEffect::flatten(SkWriteBuffer& buffer) const {
69 buffer.writeScalar(fRadius);
70 }
OLDNEW
« no previous file with comments | « samplecode/SamplePath.cpp ('k') | src/ports/SkGlobalInitialization_chromium.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698