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

Side by Side Diff: src/pdf/SkPDFUtils.cpp

Issue 811863006: Revert of enable conics gm (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « gyp/gmslides.gypi ('k') | no next file » | 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 SkPDFScalar::Append(ctl2Y, content); 88 SkPDFScalar::Append(ctl2Y, content);
89 content->writeText(" "); 89 content->writeText(" ");
90 } 90 }
91 SkPDFScalar::Append(dstX, content); 91 SkPDFScalar::Append(dstX, content);
92 content->writeText(" "); 92 content->writeText(" ");
93 SkPDFScalar::Append(dstY, content); 93 SkPDFScalar::Append(dstY, content);
94 content->writeText(" "); 94 content->writeText(" ");
95 content->writeText(cmd.c_str()); 95 content->writeText(cmd.c_str());
96 } 96 }
97 97
98 static void append_quad(const SkPoint quad[], SkWStream* content) {
99 SkPoint cubic[4];
100 SkConvertQuadToCubic(quad, cubic);
101 SkPDFUtils::AppendCubic(cubic[1].fX, cubic[1].fY, cubic[2].fX, cubic[2].fY,
102 cubic[3].fX, cubic[3].fY, content);
103 }
104
105 // static 98 // static
106 void SkPDFUtils::AppendRectangle(const SkRect& rect, SkWStream* content) { 99 void SkPDFUtils::AppendRectangle(const SkRect& rect, SkWStream* content) {
107 // Skia has 0,0 at top left, pdf at bottom left. Do the right thing. 100 // Skia has 0,0 at top left, pdf at bottom left. Do the right thing.
108 SkScalar bottom = SkMinScalar(rect.fBottom, rect.fTop); 101 SkScalar bottom = SkMinScalar(rect.fBottom, rect.fTop);
109 102
110 SkPDFScalar::Append(rect.fLeft, content); 103 SkPDFScalar::Append(rect.fLeft, content);
111 content->writeText(" "); 104 content->writeText(" ");
112 SkPDFScalar::Append(bottom, content); 105 SkPDFScalar::Append(bottom, content);
113 content->writeText(" "); 106 content->writeText(" ");
114 SkPDFScalar::Append(rect.width(), content); 107 SkPDFScalar::Append(rect.width(), content);
(...skipping 15 matching lines...) Expand all
130 kNonSingleLine_SkipFillState = 2, 123 kNonSingleLine_SkipFillState = 2,
131 }; 124 };
132 SkipFillState fillState = kEmpty_SkipFillState; 125 SkipFillState fillState = kEmpty_SkipFillState;
133 if (paintStyle != SkPaint::kFill_Style) { 126 if (paintStyle != SkPaint::kFill_Style) {
134 fillState = kNonSingleLine_SkipFillState; 127 fillState = kNonSingleLine_SkipFillState;
135 } 128 }
136 SkPoint lastMovePt = SkPoint::Make(0,0); 129 SkPoint lastMovePt = SkPoint::Make(0,0);
137 SkDynamicMemoryWStream currentSegment; 130 SkDynamicMemoryWStream currentSegment;
138 SkPoint args[4]; 131 SkPoint args[4];
139 SkPath::Iter iter(path, false); 132 SkPath::Iter iter(path, false);
140 for (SkPath::Verb verb = iter.next(args); verb != SkPath::kDone_Verb; verb = iter.next(args)) { 133 for (SkPath::Verb verb = iter.next(args);
134 verb != SkPath::kDone_Verb;
135 verb = iter.next(args)) {
141 // args gets all the points, even the implicit first point. 136 // args gets all the points, even the implicit first point.
142 switch (verb) { 137 switch (verb) {
143 case SkPath::kMove_Verb: 138 case SkPath::kMove_Verb:
144 MoveTo(args[0].fX, args[0].fY, &currentSegment); 139 MoveTo(args[0].fX, args[0].fY, &currentSegment);
145 lastMovePt = args[0]; 140 lastMovePt = args[0];
146 fillState = kEmpty_SkipFillState; 141 fillState = kEmpty_SkipFillState;
147 break; 142 break;
148 case SkPath::kLine_Verb: 143 case SkPath::kLine_Verb:
149 AppendLine(args[1].fX, args[1].fY, &currentSegment); 144 AppendLine(args[1].fX, args[1].fY, &currentSegment);
150 if (fillState == kEmpty_SkipFillState) { 145 if (fillState == kEmpty_SkipFillState) {
151 if (args[0] != lastMovePt) { 146 if (args[0] != lastMovePt) {
152 fillState = kSingleLine_SkipFillState; 147 fillState = kSingleLine_SkipFillState;
153 } 148 }
154 } else if (fillState == kSingleLine_SkipFillState) { 149 } else if (fillState == kSingleLine_SkipFillState) {
155 fillState = kNonSingleLine_SkipFillState; 150 fillState = kNonSingleLine_SkipFillState;
156 } 151 }
157 break; 152 break;
158 case SkPath::kQuad_Verb: 153 case SkPath::kQuad_Verb: {
159 append_quad(args, &currentSegment); 154 SkPoint cubic[4];
155 SkConvertQuadToCubic(args, cubic);
156 AppendCubic(cubic[1].fX, cubic[1].fY, cubic[2].fX, cubic[2].fY,
157 cubic[3].fX, cubic[3].fY, &currentSegment);
160 fillState = kNonSingleLine_SkipFillState; 158 fillState = kNonSingleLine_SkipFillState;
161 break; 159 break;
162 case SkPath::kConic_Verb: { 160 }
163 const SkScalar tol = SK_Scalar1 / 4;
164 SkAutoConicToQuads converter;
165 const SkPoint* quads = converter.computeQuads(args, iter.conicWe ight(), tol);
166 for (int i = 0; i < converter.countQuads(); ++i) {
167 append_quad(&quads[i * 2], &currentSegment);
168 }
169 } break;
170 case SkPath::kCubic_Verb: 161 case SkPath::kCubic_Verb:
171 AppendCubic(args[1].fX, args[1].fY, args[2].fX, args[2].fY, 162 AppendCubic(args[1].fX, args[1].fY, args[2].fX, args[2].fY,
172 args[3].fX, args[3].fY, &currentSegment); 163 args[3].fX, args[3].fY, &currentSegment);
173 fillState = kNonSingleLine_SkipFillState; 164 fillState = kNonSingleLine_SkipFillState;
174 break; 165 break;
175 case SkPath::kClose_Verb: 166 case SkPath::kClose_Verb:
176 if (fillState != kSingleLine_SkipFillState) { 167 if (fillState != kSingleLine_SkipFillState) {
177 ClosePath(&currentSegment); 168 ClosePath(&currentSegment);
178 SkData* data = currentSegment.copyToData(); 169 SkData* data = currentSegment.copyToData();
179 content->write(data->data(), data->size()); 170 content->write(data->data(), data->size());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // color (SCN, scn) 240 // color (SCN, scn)
250 SkString resourceName = SkPDFResourceDict::getResourceName( 241 SkString resourceName = SkPDFResourceDict::getResourceName(
251 SkPDFResourceDict::kPattern_ResourceType, 242 SkPDFResourceDict::kPattern_ResourceType,
252 objectIndex); 243 objectIndex);
253 content->writeText("/Pattern CS/Pattern cs/"); 244 content->writeText("/Pattern CS/Pattern cs/");
254 content->writeText(resourceName.c_str()); 245 content->writeText(resourceName.c_str());
255 content->writeText(" SCN/"); 246 content->writeText(" SCN/");
256 content->writeText(resourceName.c_str()); 247 content->writeText(resourceName.c_str());
257 content->writeText(" scn\n"); 248 content->writeText(" scn\n");
258 } 249 }
OLDNEW
« no previous file with comments | « gyp/gmslides.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698