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

Side by Side Diff: src/pathops/SkPathWriter.cpp

Issue 14798004: path ops -- fix skp bugs (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « src/pathops/SkPathWriter.h ('k') | tests/PathOpsAngleTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "SkPathOpsTypes.h" 7 #include "SkPathOpsPoint.h"
8 #include "SkPathWriter.h" 8 #include "SkPathWriter.h"
9 9
10 // wrap path to keep track of whether the contour is initialized and non-empty 10 // wrap path to keep track of whether the contour is initialized and non-empty
11 SkPathWriter::SkPathWriter(SkPath& path) 11 SkPathWriter::SkPathWriter(SkPath& path)
12 : fPathPtr(&path) 12 : fPathPtr(&path)
13 , fCloses(0) 13 , fCloses(0)
14 , fMoves(0) 14 , fMoves(0)
15 { 15 {
16 init(); 16 init();
17 } 17 }
(...skipping 12 matching lines...) Expand all
30 SkDebugf("path.close();\n"); 30 SkDebugf("path.close();\n");
31 #endif 31 #endif
32 fPathPtr->close(); 32 fPathPtr->close();
33 fCloses++; 33 fCloses++;
34 } 34 }
35 init(); 35 init();
36 } 36 }
37 37
38 void SkPathWriter::cubicTo(const SkPoint& pt1, const SkPoint& pt2, const SkPoint & pt3) { 38 void SkPathWriter::cubicTo(const SkPoint& pt1, const SkPoint& pt2, const SkPoint & pt3) {
39 lineTo(); 39 lineTo();
40 if (fEmpty && AlmostEqualUlps(fDefer[0], pt1) && AlmostEqualUlps(pt1, pt2)
41 && AlmostEqualUlps(pt2, pt3)) {
42 deferredLine(pt3);
43 return;
44 }
40 moveTo(); 45 moveTo();
41 fDefer[1] = pt3; 46 fDefer[1] = pt3;
42 nudge(); 47 nudge();
43 fDefer[0] = fDefer[1]; 48 fDefer[0] = fDefer[1];
44 #if DEBUG_PATH_CONSTRUCTION 49 #if DEBUG_PATH_CONSTRUCTION
45 SkDebugf("path.cubicTo(%1.9g,%1.9g, %1.9g,%1.9g, %1.9g,%1.9g);\n", 50 SkDebugf("path.cubicTo(%1.9g,%1.9g, %1.9g,%1.9g, %1.9g,%1.9g);\n",
46 pt1.fX, pt1.fY, pt2.fX, pt2.fY, fDefer[1].fX, fDefer[1].fY); 51 pt1.fX, pt1.fY, pt2.fX, pt2.fY, fDefer[1].fX, fDefer[1].fY);
47 #endif 52 #endif
48 fPathPtr->cubicTo(pt1.fX, pt1.fY, pt2.fX, pt2.fY, fDefer[1].fX, fDefer[1].fY ); 53 fPathPtr->cubicTo(pt1.fX, pt1.fY, pt2.fX, pt2.fY, fDefer[1].fX, fDefer[1].fY );
49 fEmpty = false; 54 fEmpty = false;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 void SkPathWriter::nudge() { 114 void SkPathWriter::nudge() {
110 if (fEmpty || !AlmostEqualUlps(fDefer[1].fX, fFirstPt.fX) 115 if (fEmpty || !AlmostEqualUlps(fDefer[1].fX, fFirstPt.fX)
111 || !AlmostEqualUlps(fDefer[1].fY, fFirstPt.fY)) { 116 || !AlmostEqualUlps(fDefer[1].fY, fFirstPt.fY)) {
112 return; 117 return;
113 } 118 }
114 fDefer[1] = fFirstPt; 119 fDefer[1] = fFirstPt;
115 } 120 }
116 121
117 void SkPathWriter::quadTo(const SkPoint& pt1, const SkPoint& pt2) { 122 void SkPathWriter::quadTo(const SkPoint& pt1, const SkPoint& pt2) {
118 lineTo(); 123 lineTo();
124 if (fEmpty && AlmostEqualUlps(fDefer[0], pt1) && AlmostEqualUlps(pt1, pt2)) {
125 deferredLine(pt2);
126 return;
127 }
119 moveTo(); 128 moveTo();
120 fDefer[1] = pt2; 129 fDefer[1] = pt2;
121 nudge(); 130 nudge();
122 fDefer[0] = fDefer[1]; 131 fDefer[0] = fDefer[1];
123 #if DEBUG_PATH_CONSTRUCTION 132 #if DEBUG_PATH_CONSTRUCTION
124 SkDebugf("path.quadTo(%1.9g,%1.9g, %1.9g,%1.9g);\n", 133 SkDebugf("path.quadTo(%1.9g,%1.9g, %1.9g,%1.9g);\n",
125 pt1.fX, pt1.fY, fDefer[1].fX, fDefer[1].fY); 134 pt1.fX, pt1.fY, fDefer[1].fX, fDefer[1].fY);
126 #endif 135 #endif
127 fPathPtr->quadTo(pt1.fX, pt1.fY, fDefer[1].fX, fDefer[1].fY); 136 fPathPtr->quadTo(pt1.fX, pt1.fY, fDefer[1].fX, fDefer[1].fY);
128 fEmpty = false; 137 fEmpty = false;
(...skipping 19 matching lines...) Expand all
148 return; 157 return;
149 } 158 }
150 fFirstPt = fDefer[0]; 159 fFirstPt = fDefer[0];
151 #if DEBUG_PATH_CONSTRUCTION 160 #if DEBUG_PATH_CONSTRUCTION
152 SkDebugf("path.moveTo(%1.9g,%1.9g);\n", fDefer[0].fX, fDefer[0].fY); 161 SkDebugf("path.moveTo(%1.9g,%1.9g);\n", fDefer[0].fX, fDefer[0].fY);
153 #endif 162 #endif
154 fPathPtr->moveTo(fDefer[0].fX, fDefer[0].fY); 163 fPathPtr->moveTo(fDefer[0].fX, fDefer[0].fY);
155 fMoved = false; 164 fMoved = false;
156 fMoves++; 165 fMoves++;
157 } 166 }
OLDNEW
« no previous file with comments | « src/pathops/SkPathWriter.h ('k') | tests/PathOpsAngleTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698