OLD | NEW |
---|---|
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" |
11 #include "SkGeometry.h" | 11 #include "SkGeometry.h" |
12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
13 #include "SkPath.h" | 13 #include "SkPath.h" |
14 #include "SkPDFResourceDict.h" | 14 #include "SkPDFResourceDict.h" |
15 #include "SkPDFUtils.h" | 15 #include "SkPDFUtils.h" |
16 #include "SkStream.h" | 16 #include "SkStream.h" |
17 #include "SkString.h" | 17 #include "SkString.h" |
18 #include "SkPDFTypes.h" | 18 #include "SkPDFTypes.h" |
19 | 19 |
20 //static | |
21 SkPDFArray* SkPDFUtils::RectToArray(const SkRect& rect) { | |
22 SkPDFArray* result = new SkPDFArray(); | |
23 result->reserve(4); | |
24 result->appendScalar(rect.fLeft); | |
25 result->appendScalar(rect.fTop); | |
26 result->appendScalar(rect.fRight); | |
27 result->appendScalar(rect.fBottom); | |
28 return result; | |
29 } | |
30 | |
20 // static | 31 // static |
21 SkPDFArray* SkPDFUtils::MatrixToArray(const SkMatrix& matrix) { | 32 SkPDFArray* SkPDFUtils::MatrixToArray(const SkMatrix& matrix) { |
22 SkScalar values[6]; | 33 SkScalar values[6]; |
23 if (!matrix.asAffine(values)) { | 34 if (!matrix.asAffine(values)) { |
24 SkMatrix::SetAffineIdentity(values); | 35 SkMatrix::SetAffineIdentity(values); |
25 } | 36 } |
26 | 37 |
27 SkPDFArray* result = new SkPDFArray; | 38 SkPDFArray* result = new SkPDFArray; |
28 result->reserve(6); | 39 result->reserve(6); |
29 for (size_t i = 0; i < SK_ARRAY_COUNT(values); i++) { | 40 for (size_t i = 0; i < SK_ARRAY_COUNT(values); i++) { |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 } | 226 } |
216 | 227 |
217 // static | 228 // static |
218 void SkPDFUtils::ApplyGraphicState(int objectIndex, SkWStream* content) { | 229 void SkPDFUtils::ApplyGraphicState(int objectIndex, SkWStream* content) { |
219 content->writeText("/"); | 230 content->writeText("/"); |
220 content->writeText(SkPDFResourceDict::getResourceName( | 231 content->writeText(SkPDFResourceDict::getResourceName( |
221 SkPDFResourceDict::kExtGState_ResourceType, | 232 SkPDFResourceDict::kExtGState_ResourceType, |
222 objectIndex).c_str()); | 233 objectIndex).c_str()); |
223 content->writeText(" gs\n"); | 234 content->writeText(" gs\n"); |
224 } | 235 } |
236 | |
237 // static | |
238 void SkPDFUtils::ApplyPattern(int objectIndex, SkWStream* content) { | |
239 SkString resourceName = SkPDFResourceDict::getResourceName( | |
240 SkPDFResourceDict::kPattern_ResourceType, | |
241 objectIndex); | |
242 content->writeText("/Pattern CS/Pattern cs/"); | |
edisonn
2013/07/17 17:52:24
Do you set the value of /Pattern twice? Per spec,
ducky
2013/07/17 22:18:20
Addressed in comment in the other CL (resource dic
| |
243 content->writeText(resourceName.c_str()); | |
244 content->writeText(" SCN/"); | |
edisonn
2013/07/17 17:52:24
please comment the scn/SCN related lines
ducky
2013/07/17 22:18:20
Done.
| |
245 content->writeText(resourceName.c_str()); | |
246 content->writeText(" scn\n"); | |
247 } | |
OLD | NEW |