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

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

Issue 19793011: (upload draf code for backup) pdfviewer: improve memory, son't allocate extra buffers, and put the … (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 | « no previous file | experimental/PdfViewer/SkPdfBasics.cpp » ('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 SkNativeParsedPDF; 18 class SkNativeParsedPDF;
19 class SkPdfAllocator;
19 20
20 // TODO(edisonn): better class design. 21 // TODO(edisonn): better class design.
21 struct SkPdfColorOperator { 22 struct SkPdfColorOperator {
22 // does not own the char* 23 // does not own the char*
23 const char* fColorSpace; // TODO(edisonn): use SkString, or even char* 24 NotOwnedString fColorSpace;
24 SkColor fColor; 25 SkColor fColor;
25 double fOpacity; // ca or CA 26 double fOpacity; // ca or CA
26 // TODO(edisonn): add here other color space options. 27 // TODO(edisonn): add here other color space options.
27 28
28 void setRGBColor(SkColor color) { 29 void setRGBColor(SkColor color) {
29 // TODO(edisonn): ASSERT DeviceRGB is the color space. 30 // TODO(edisonn): ASSERT DeviceRGB is the color space.
30 fColor = color; 31 fColor = color;
31 } 32 }
32 // TODO(edisonn): double check the default values for all fields. 33 // TODO(edisonn): double check the default values for all fields.
33 SkPdfColorOperator() : fColorSpace(NULL), fColor(SK_ColorBLACK), fOpacity(1) {} 34 SkPdfColorOperator() : fColor(SK_ColorBLACK), fOpacity(1) {
35 NotOwnedString::init(&fColorSpace);
36 }
34 37
35 void applyGraphicsState(SkPaint* paint) { 38 void applyGraphicsState(SkPaint* paint) {
36 paint->setColor(SkColorSetA(fColor, fOpacity * 255)); 39 paint->setColor(SkColorSetA(fColor, fOpacity * 255));
37 } 40 }
38 }; 41 };
39 42
40 // TODO(edisonn): better class design. 43 // TODO(edisonn): better class design.
41 struct SkPdfGraphicsState { 44 struct SkPdfGraphicsState {
42 SkMatrix fMatrix; 45 SkMatrix fMatrix;
43 SkMatrix fMatrixTm; 46 SkMatrix fMatrixTm;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 std::string fImageData; 113 std::string fImageData;
111 }; 114 };
112 115
113 // TODO(edisonn): better class design. 116 // TODO(edisonn): better class design.
114 // TODO(edisonn): rename to SkPdfContext 117 // TODO(edisonn): rename to SkPdfContext
115 struct PdfContext { 118 struct PdfContext {
116 std::stack<SkPdfObject*> fObjectStack; 119 std::stack<SkPdfObject*> fObjectStack;
117 std::stack<SkPdfGraphicsState> fStateStack; 120 std::stack<SkPdfGraphicsState> fStateStack;
118 SkPdfGraphicsState fGraphicsState; 121 SkPdfGraphicsState fGraphicsState;
119 SkNativeParsedPDF* fPdfDoc; 122 SkNativeParsedPDF* fPdfDoc;
123 // TODO(edisonn): the allocator, could be freed after the page is done drawi ng.
124 SkPdfAllocator* fTmpPageAllocator;
120 SkMatrix fOriginalMatrix; 125 SkMatrix fOriginalMatrix;
121 126
122 SkPdfInlineImage fInlineImage; 127 SkPdfInlineImage fInlineImage;
123 128
124 PdfContext(SkNativeParsedPDF* doc) : fPdfDoc(doc) {} 129 PdfContext(SkNativeParsedPDF* doc);
125 130 ~PdfContext();
126 }; 131 };
127 132
128 // TODO(edisonn): temporary code, to report how much of the PDF we actually thin k we rendered. 133 // TODO(edisonn): temporary code, to report how much of the PDF we actually thin k we rendered.
129 // TODO(edisonn): rename to SkPdfResult 134 // TODO(edisonn): rename to SkPdfResult
130 enum PdfResult { 135 enum PdfResult {
131 kOK_PdfResult, 136 kOK_PdfResult,
132 kPartial_PdfResult, 137 kPartial_PdfResult,
133 kNYI_PdfResult, 138 kNYI_PdfResult,
134 kIgnoreError_PdfResult, 139 kIgnoreError_PdfResult,
135 kError_PdfResult, 140 kError_PdfResult,
136 kUnsupported_PdfResult, 141 kUnsupported_PdfResult,
137 142
138 kCount_PdfResult 143 kCount_PdfResult
139 }; 144 };
140 145
141 #endif // __DEFINED__SkPdfBasics 146 #endif // __DEFINED__SkPdfBasics
OLDNEW
« no previous file with comments | « no previous file | experimental/PdfViewer/SkPdfBasics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698