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 "SkPDFUtils.h" | 14 #include "SkPDFUtils.h" |
15 #include "SkStream.h" | 15 #include "SkStream.h" |
16 #include "SkString.h" | 16 #include "SkString.h" |
17 #include "SkPDFTypes.h" | 17 #include "SkPDFTypes.h" |
18 | 18 |
| 19 //static |
| 20 SkPDFArray* SkPDFUtils::RectToArray(const SkRect& rect) { |
| 21 SkPDFArray* result = new SkPDFArray(); |
| 22 result->reserve(4); |
| 23 result->appendScalar(rect.fLeft); |
| 24 result->appendScalar(rect.fTop); |
| 25 result->appendScalar(rect.fRight); |
| 26 result->appendScalar(rect.fBottom); |
| 27 return result; |
| 28 } |
| 29 |
19 // static | 30 // static |
20 SkPDFArray* SkPDFUtils::MatrixToArray(const SkMatrix& matrix) { | 31 SkPDFArray* SkPDFUtils::MatrixToArray(const SkMatrix& matrix) { |
21 SkScalar values[6]; | 32 SkScalar values[6]; |
22 if (!matrix.asAffine(values)) { | 33 if (!matrix.asAffine(values)) { |
23 SkMatrix::SetAffineIdentity(values); | 34 SkMatrix::SetAffineIdentity(values); |
24 } | 35 } |
25 | 36 |
26 SkPDFArray* result = new SkPDFArray; | 37 SkPDFArray* result = new SkPDFArray; |
27 result->reserve(6); | 38 result->reserve(6); |
28 for (size_t i = 0; i < SK_ARRAY_COUNT(values); i++) { | 39 for (size_t i = 0; i < SK_ARRAY_COUNT(values); i++) { |
29 result->appendScalar(values[i]); | 40 result->appendScalar(values[i]); |
30 } | 41 } |
31 return result; | 42 return result; |
32 } | 43 } |
33 | 44 |
34 // static | 45 // static |
35 void SkPDFUtils::AppendTransform(const SkMatrix& matrix, SkWStream* content) { | 46 void SkPDFUtils::AppendTransform(const SkMatrix& matrix, SkWStream* content) { |
36 SkScalar values[6]; | 47 SkScalar values[6]; |
37 if (!matrix.asAffine(values)) { | 48 if (!matrix.asAffine(values)) { |
38 SkMatrix::SetAffineIdentity(values); | 49 SkMatrix::SetAffineIdentity(values); |
39 } | 50 } |
40 for (size_t i = 0; i < SK_ARRAY_COUNT(values); i++) { | 51 for (size_t i = 0; i < SK_ARRAY_COUNT(values); i++) { |
41 SkPDFScalar::Append(values[i], content); | 52 SkPDFScalar::Append(values[i], content); |
42 content->writeText(" "); | 53 content->writeText(" "); |
43 } | 54 } |
44 content->writeText("cm\n"); | 55 content->writeText("cm\n"); |
45 } | 56 } |
46 | 57 |
| 58 //static |
| 59 SkPDFArray* SkPDFUtils::CreateFullProcSetsArray() { |
| 60 const char procs[][7] = {"PDF", "Text", "ImageB", "ImageC", "ImageI"}; |
| 61 SkPDFArray* procSets = new SkPDFArray(); |
| 62 |
| 63 procSets->reserve(SK_ARRAY_COUNT(procs)); |
| 64 for (size_t i = 0; i < SK_ARRAY_COUNT(procs); i++) { |
| 65 procSets->appendName(procs[i]); |
| 66 } |
| 67 |
| 68 return procSets; |
| 69 } |
| 70 |
47 // static | 71 // static |
48 void SkPDFUtils::MoveTo(SkScalar x, SkScalar y, SkWStream* content) { | 72 void SkPDFUtils::MoveTo(SkScalar x, SkScalar y, SkWStream* content) { |
49 SkPDFScalar::Append(x, content); | 73 SkPDFScalar::Append(x, content); |
50 content->writeText(" "); | 74 content->writeText(" "); |
51 SkPDFScalar::Append(y, content); | 75 SkPDFScalar::Append(y, content); |
52 content->writeText(" m\n"); | 76 content->writeText(" m\n"); |
53 } | 77 } |
54 | 78 |
55 // static | 79 // static |
56 void SkPDFUtils::AppendLine(SkScalar x, SkScalar y, SkWStream* content) { | 80 void SkPDFUtils::AppendLine(SkScalar x, SkScalar y, SkWStream* content) { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 content->writeDecAsText(objectIndex); | 234 content->writeDecAsText(objectIndex); |
211 content->writeText(" Do\n"); | 235 content->writeText(" Do\n"); |
212 } | 236 } |
213 | 237 |
214 // static | 238 // static |
215 void SkPDFUtils::ApplyGraphicState(int objectIndex, SkWStream* content) { | 239 void SkPDFUtils::ApplyGraphicState(int objectIndex, SkWStream* content) { |
216 content->writeText("/G"); | 240 content->writeText("/G"); |
217 content->writeDecAsText(objectIndex); | 241 content->writeDecAsText(objectIndex); |
218 content->writeText(" gs\n"); | 242 content->writeText(" gs\n"); |
219 } | 243 } |
OLD | NEW |