OLD | NEW |
1 #ifndef __DEFINED__SkPdfBasics | 1 #ifndef __DEFINED__SkPdfBasics |
2 #define __DEFINED__SkPdfBasics | 2 #define __DEFINED__SkPdfBasics |
3 | 3 |
4 #include "SkCanvas.h" | 4 #include "SkCanvas.h" |
5 #include "SkPaint.h" | 5 #include "SkPaint.h" |
6 #include "SkPdfConfig.h" | 6 #include "SkPdfConfig.h" |
| 7 #include "SkPdfUtils.h" |
7 | 8 |
8 #include <iostream> | |
9 #include <cstdio> | |
10 #include <map> | |
11 #include <stack> | 9 #include <stack> |
12 | 10 |
13 class SkPdfFont; | 11 class SkPdfFont; |
14 class SkPdfDoc; | 12 class SkPdfDoc; |
15 class SkPdfObject; | 13 class SkPdfNativeObject; |
16 class SkPdfResourceDictionary; | 14 class SkPdfResourceDictionary; |
17 class SkPdfSoftMaskDictionary; | 15 class SkPdfSoftMaskDictionary; |
18 | 16 |
19 class SkNativeParsedPDF; | 17 class SkPdfNativeDoc; |
20 class SkPdfAllocator; | 18 class SkPdfAllocator; |
21 | 19 |
22 // TODO(edisonn): better class design. | 20 // TODO(edisonn): better class design. |
23 class SkPdfColorOperator { | 21 class SkPdfColorOperator { |
24 | 22 |
25 /* | 23 /* |
26 color space name or array The current color space in which color value
s are to be interpreted | 24 color space name or array The current color space in which color value
s are to be interpreted |
27 (see Section 4.5, “Color Spaces”). There are
two separate color space | 25 (see Section 4.5, “Color Spaces”). There are
two separate color space |
28 parameters: one for stroking and one for all
other painting opera- | 26 parameters: one for stroking and one for all
other painting opera- |
29 tions. Initial value: DeviceGray. | 27 tions. Initial value: DeviceGray. |
30 */ | 28 */ |
31 | 29 |
32 // TODO(edisonn): implement the array part too | 30 // TODO(edisonn): implement the array part too |
33 // does not own the char* | 31 // does not own the char* |
34 // TODO(edisonn): remove this public, let fields be private | 32 // TODO(edisonn): remove this public, let fields be private |
35 // TODO(edisonn): make color space an enum! | 33 // TODO(edisonn): make color space an enum! |
36 public: | 34 public: |
37 NotOwnedString fColorSpace; | 35 NotOwnedString fColorSpace; |
38 SkPdfObject* fPattern; | 36 SkPdfNativeObject* fPattern; |
39 | 37 |
40 /* | 38 /* |
41 color (various) The current color to be used during painting
operations (see Section | 39 color (various) The current color to be used during painting
operations (see Section |
42 4.5, “Color Spaces”). The type and interpret
ation of this parameter | 40 4.5, “Color Spaces”). The type and interpret
ation of this parameter |
43 depend on the current color space; for most
color spaces, a color | 41 depend on the current color space; for most
color spaces, a color |
44 value consists of one to four numbers. There
are two separate color | 42 value consists of one to four numbers. There
are two separate color |
45 parameters: one for stroking and one for all
other painting opera- | 43 parameters: one for stroking and one for all
other painting opera- |
46 tions. Initial value: black. | 44 tions. Initial value: black. |
47 */ | 45 */ |
48 | 46 |
(...skipping 11 matching lines...) Expand all Loading... |
60 // TODO(edisonn): double check the default values for all fields. | 58 // TODO(edisonn): double check the default values for all fields. |
61 SkPdfColorOperator() : fPattern(NULL), fColor(SK_ColorBLACK), fOpacity(1) { | 59 SkPdfColorOperator() : fPattern(NULL), fColor(SK_ColorBLACK), fOpacity(1) { |
62 NotOwnedString::init(&fColorSpace, "DeviceRGB"); | 60 NotOwnedString::init(&fColorSpace, "DeviceRGB"); |
63 } | 61 } |
64 | 62 |
65 void setColorSpace(NotOwnedString* colorSpace) { | 63 void setColorSpace(NotOwnedString* colorSpace) { |
66 fColorSpace = *colorSpace; | 64 fColorSpace = *colorSpace; |
67 fPattern = NULL; | 65 fPattern = NULL; |
68 } | 66 } |
69 | 67 |
70 void setPatternColorSpace(SkPdfObject* pattern) { | 68 void setPatternColorSpace(SkPdfNativeObject* pattern) { |
71 fColorSpace.fBuffer = (const unsigned char*)"Pattern"; | 69 fColorSpace.fBuffer = (const unsigned char*)"Pattern"; |
72 fColorSpace.fBytes = 7; // strlen("Pattern") | 70 fColorSpace.fBytes = 7; // strlen("Pattern") |
73 fPattern = pattern; | 71 fPattern = pattern; |
74 } | 72 } |
75 | 73 |
76 void applyGraphicsState(SkPaint* paint) { | 74 void applyGraphicsState(SkPaint* paint) { |
77 paint->setColor(SkColorSetA(fColor, (U8CPU)(fOpacity * 255))); | 75 paint->setColor(SkColorSetA(fColor, (U8CPU)(fOpacity * 255))); |
78 } | 76 } |
79 }; | 77 }; |
80 | 78 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 fBlendModesLength = 1; | 351 fBlendModesLength = 1; |
354 fBlendModes[0] = SkXfermode::kSrc_Mode; // PDF: Normal Blend mode | 352 fBlendModes[0] = SkXfermode::kSrc_Mode; // PDF: Normal Blend mode |
355 fSMask = NULL; | 353 fSMask = NULL; |
356 } | 354 } |
357 | 355 |
358 // TODO(edisonn): make two functons instead, stroking and non stoking, avoid
branching | 356 // TODO(edisonn): make two functons instead, stroking and non stoking, avoid
branching |
359 void applyGraphicsState(SkPaint* paint, bool stroking); | 357 void applyGraphicsState(SkPaint* paint, bool stroking); |
360 }; | 358 }; |
361 | 359 |
362 // TODO(edisonn): better class design. | 360 // TODO(edisonn): better class design. |
363 // TODO(edisonn): could we remove it? | |
364 // TODO(edisonn): rename to SkPdfInlineImage | |
365 struct SkPdfInlineImage { | |
366 std::map<std::string, std::string> fKeyValuePairs; | |
367 std::string fImageData; | |
368 }; | |
369 | |
370 // TODO(edisonn): better class design. | |
371 // TODO(edisonn): rename to SkPdfContext | 361 // TODO(edisonn): rename to SkPdfContext |
372 struct PdfContext { | 362 struct SkPdfContext { |
373 std::stack<SkPdfObject*> fObjectStack; | 363 std::stack<SkPdfNativeObject*> fObjectStack; |
374 std::stack<SkPdfGraphicsState> fStateStack; | 364 std::stack<SkPdfGraphicsState> fStateStack; |
375 SkPdfGraphicsState fGraphicsState; | 365 SkPdfGraphicsState fGraphicsState; |
376 SkNativeParsedPDF* fPdfDoc; | 366 SkPdfNativeDoc* fPdfDoc; |
377 // TODO(edisonn): the allocator, could be freed after the page is done drawi
ng. | 367 // TODO(edisonn): the allocator, could be freed after the page is done drawi
ng. |
378 SkPdfAllocator* fTmpPageAllocator; | 368 SkPdfAllocator* fTmpPageAllocator; |
379 SkMatrix fOriginalMatrix; | 369 SkMatrix fOriginalMatrix; |
380 | 370 |
381 SkPdfInlineImage fInlineImage; | 371 SkPdfContext(SkPdfNativeDoc* doc); |
382 | 372 ~SkPdfContext(); |
383 PdfContext(SkNativeParsedPDF* doc); | |
384 ~PdfContext(); | |
385 }; | |
386 | |
387 // TODO(edisonn): temporary code, to report how much of the PDF we actually thin
k we rendered. | |
388 // TODO(edisonn): rename to SkPdfResult | |
389 enum PdfResult { | |
390 kOK_PdfResult, | |
391 kPartial_PdfResult, | |
392 kNYI_PdfResult, | |
393 kIgnoreError_PdfResult, | |
394 kError_PdfResult, | |
395 kUnsupported_PdfResult, | |
396 | |
397 kCount_PdfResult | |
398 }; | 373 }; |
399 | 374 |
400 #endif // __DEFINED__SkPdfBasics | 375 #endif // __DEFINED__SkPdfBasics |
OLD | NEW |