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

Side by Side Diff: experimental/PdfViewer/SkPdfBasics.h

Issue 18323019: work on the native parser, in progress, uploaded to have a backup (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 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 | « experimental/PdfViewer/PdfReference-okular-1.txt ('k') | experimental/PdfViewer/SkPdfFont.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7
8 #include <iostream> 8 #include <iostream>
9 #include <cstdio> 9 #include <cstdio>
10 #include <map> 10 #include <map>
11 #include <stack> 11 #include <stack>
12 12
13 class SkPdfFont; 13 class SkPdfFont;
14 class SkPdfDoc; 14 class SkPdfDoc;
15 class SkPdfObject; 15 class SkPdfObject;
16 class SkPdfResourceDictionary; 16 class SkPdfResourceDictionary;
17 17
18 class SkPodofoParsedPDF; 18 class SkNativeParsedPDF;
19 19
20 // TODO(edisonn): better class design. 20 // TODO(edisonn): better class design.
21 struct SkPdfColorOperator { 21 struct SkPdfColorOperator {
22 std::string fColorSpace; // TODO(edisonn): use SkString 22 // does not own the char*
23 const char* fColorSpace; // TODO(edisonn): use SkString, or even char*
23 SkColor fColor; 24 SkColor fColor;
24 double fOpacity; // ca or CA 25 double fOpacity; // ca or CA
25 // TODO(edisonn): add here other color space options. 26 // TODO(edisonn): add here other color space options.
26 27
27 void setRGBColor(SkColor color) { 28 void setRGBColor(SkColor color) {
28 // TODO(edisonn): ASSERT DeviceRGB is the color space. 29 // TODO(edisonn): ASSERT DeviceRGB is the color space.
29 fColor = color; 30 fColor = color;
30 } 31 }
31 // TODO(edisonn): double check the default values for all fields. 32 // TODO(edisonn): double check the default values for all fields.
32 SkPdfColorOperator() : fColor(SK_ColorBLACK), fOpacity(1) {} 33 SkPdfColorOperator() : fColorSpace(NULL), fColor(SK_ColorBLACK), fOpacity(1) {}
33 34
34 void applyGraphicsState(SkPaint* paint) { 35 void applyGraphicsState(SkPaint* paint) {
35 paint->setColor(SkColorSetA(fColor, fOpacity * 255)); 36 paint->setColor(SkColorSetA(fColor, fOpacity * 255));
36 } 37 }
37 }; 38 };
38 39
39 // TODO(edisonn): better class design. 40 // TODO(edisonn): better class design.
40 struct SkPdfGraphicsState { 41 struct SkPdfGraphicsState {
41 SkMatrix fMatrix; 42 SkMatrix fMatrix;
42 SkMatrix fMatrixTm; 43 SkMatrix fMatrixTm;
(...skipping 13 matching lines...) Expand all
56 SkPath fClipPath; 57 SkPath fClipPath;
57 58
58 SkPdfColorOperator fStroking; 59 SkPdfColorOperator fStroking;
59 SkPdfColorOperator fNonStroking; 60 SkPdfColorOperator fNonStroking;
60 61
61 double fLineWidth; 62 double fLineWidth;
62 double fTextLeading; 63 double fTextLeading;
63 double fWordSpace; 64 double fWordSpace;
64 double fCharSpace; 65 double fCharSpace;
65 66
66 const SkPdfResourceDictionary* fResources; 67 SkPdfResourceDictionary* fResources;
67 68
68 SkBitmap fSMask; 69 SkBitmap fSMask;
69 70
70 SkPdfGraphicsState() { 71 SkPdfGraphicsState() {
71 fCurPosX = 0.0; 72 fCurPosX = 0.0;
72 fCurPosY = 0.0; 73 fCurPosY = 0.0;
73 fCurFontSize = 0.0; 74 fCurFontSize = 0.0;
74 fTextBlock = false; 75 fTextBlock = false;
75 fMatrix = SkMatrix::I(); 76 fMatrix = SkMatrix::I();
76 fMatrixTm = SkMatrix::I(); 77 fMatrixTm = SkMatrix::I();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 std::map<std::string, std::string> fKeyValuePairs; 109 std::map<std::string, std::string> fKeyValuePairs;
109 std::string fImageData; 110 std::string fImageData;
110 }; 111 };
111 112
112 // TODO(edisonn): better class design. 113 // TODO(edisonn): better class design.
113 // TODO(edisonn): rename to SkPdfContext 114 // TODO(edisonn): rename to SkPdfContext
114 struct PdfContext { 115 struct PdfContext {
115 std::stack<SkPdfObject*> fObjectStack; 116 std::stack<SkPdfObject*> fObjectStack;
116 std::stack<SkPdfGraphicsState> fStateStack; 117 std::stack<SkPdfGraphicsState> fStateStack;
117 SkPdfGraphicsState fGraphicsState; 118 SkPdfGraphicsState fGraphicsState;
118 const SkPodofoParsedPDF* fPdfDoc; 119 SkNativeParsedPDF* fPdfDoc;
119 SkMatrix fOriginalMatrix; 120 SkMatrix fOriginalMatrix;
120 121
121 SkPdfInlineImage fInlineImage; 122 SkPdfInlineImage fInlineImage;
122 123
123 PdfContext(const SkPodofoParsedPDF* doc) : fPdfDoc(doc) {} 124 PdfContext(SkNativeParsedPDF* doc) : fPdfDoc(doc) {}
124 125
125 }; 126 };
126 127
127 // TODO(edisonn): temporary code, to report how much of the PDF we actually thin k we rendered. 128 // TODO(edisonn): temporary code, to report how much of the PDF we actually thin k we rendered.
128 // TODO(edisonn): rename to SkPdfResult 129 // TODO(edisonn): rename to SkPdfResult
129 enum PdfResult { 130 enum PdfResult {
130 kOK_PdfResult, 131 kOK_PdfResult,
131 kPartial_PdfResult, 132 kPartial_PdfResult,
132 kNYI_PdfResult, 133 kNYI_PdfResult,
133 kIgnoreError_PdfResult, 134 kIgnoreError_PdfResult,
134 kError_PdfResult, 135 kError_PdfResult,
135 kUnsupported_PdfResult, 136 kUnsupported_PdfResult,
136 137
137 kCount_PdfResult 138 kCount_PdfResult
138 }; 139 };
139 140
140 #endif // __DEFINED__SkPdfBasics 141 #endif // __DEFINED__SkPdfBasics
OLDNEW
« no previous file with comments | « experimental/PdfViewer/PdfReference-okular-1.txt ('k') | experimental/PdfViewer/SkPdfFont.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698