diff options
author | 2013-07-23 17:43:18 +0000 | |
---|---|---|
committer | 2013-07-23 17:43:18 +0000 | |
commit | 2ccc3afa474f9485c39c2e863252ddaa3f35724b (patch) | |
tree | a0656156a32a57c109e6dc0ed8063b41b24ddcdc /experimental/PdfViewer/SkPdfBasics.h | |
parent | 0ab790bef3f4cc018015fce58b12265b5511afad (diff) |
pdfviewer: improve memory usage, improve parse time (by 30-50%) and don't allocate extra buffers (more to do, but low priority now), and put the page specific memory in an allocator.
Review URL: https://codereview.chromium.org/19793011
git-svn-id: http://skia.googlecode.com/svn/trunk@10282 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/PdfViewer/SkPdfBasics.h')
-rw-r--r-- | experimental/PdfViewer/SkPdfBasics.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/experimental/PdfViewer/SkPdfBasics.h b/experimental/PdfViewer/SkPdfBasics.h index 747c32a3d4..31fc2cd071 100644 --- a/experimental/PdfViewer/SkPdfBasics.h +++ b/experimental/PdfViewer/SkPdfBasics.h @@ -16,11 +16,12 @@ class SkPdfObject; class SkPdfResourceDictionary; class SkNativeParsedPDF; +class SkPdfAllocator; // TODO(edisonn): better class design. struct SkPdfColorOperator { // does not own the char* - const char* fColorSpace; // TODO(edisonn): use SkString, or even char* + NotOwnedString fColorSpace; SkColor fColor; double fOpacity; // ca or CA // TODO(edisonn): add here other color space options. @@ -30,7 +31,9 @@ struct SkPdfColorOperator { fColor = color; } // TODO(edisonn): double check the default values for all fields. - SkPdfColorOperator() : fColorSpace(NULL), fColor(SK_ColorBLACK), fOpacity(1) {} + SkPdfColorOperator() : fColor(SK_ColorBLACK), fOpacity(1) { + NotOwnedString::init(&fColorSpace); + } void applyGraphicsState(SkPaint* paint) { paint->setColor(SkColorSetA(fColor, fOpacity * 255)); @@ -117,12 +120,14 @@ struct PdfContext { std::stack<SkPdfGraphicsState> fStateStack; SkPdfGraphicsState fGraphicsState; SkNativeParsedPDF* fPdfDoc; + // TODO(edisonn): the allocator, could be freed after the page is done drawing. + SkPdfAllocator* fTmpPageAllocator; SkMatrix fOriginalMatrix; SkPdfInlineImage fInlineImage; - PdfContext(SkNativeParsedPDF* doc) : fPdfDoc(doc) {} - + PdfContext(SkNativeParsedPDF* doc); + ~PdfContext(); }; // TODO(edisonn): temporary code, to report how much of the PDF we actually think we rendered. |