OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
10 #include "SkForceLinking.h" | 10 #include "SkForceLinking.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 virtual PdfResult consumeToken(PdfToken& token) = 0; | 100 virtual PdfResult consumeToken(PdfToken& token) = 0; |
101 virtual void loop() = 0; | 101 virtual void loop() = 0; |
102 | 102 |
103 void setUp(PdfTokenLooper* parent) { | 103 void setUp(PdfTokenLooper* parent) { |
104 fParent = parent; | 104 fParent = parent; |
105 fTokenizer = parent->fTokenizer; | 105 fTokenizer = parent->fTokenizer; |
106 fPdfContext = parent->fPdfContext; | 106 fPdfContext = parent->fPdfContext; |
107 fCanvas = parent->fCanvas; | 107 fCanvas = parent->fCanvas; |
108 } | 108 } |
| 109 |
| 110 SkPdfNativeTokenizer* tokenizer() { return fTokenizer; } |
109 }; | 111 }; |
110 | 112 |
111 class PdfMainLooper : public PdfTokenLooper { | 113 class PdfMainLooper : public PdfTokenLooper { |
112 public: | 114 public: |
113 PdfMainLooper(PdfTokenLooper* parent, | 115 PdfMainLooper(PdfTokenLooper* parent, |
114 SkPdfNativeTokenizer* tokenizer, | 116 SkPdfNativeTokenizer* tokenizer, |
115 PdfContext* pdfContext, | 117 PdfContext* pdfContext, |
116 SkCanvas* canvas) | 118 SkCanvas* canvas) |
117 : PdfTokenLooper(parent, tokenizer, pdfContext, canvas) {} | 119 : PdfTokenLooper(parent, tokenizer, pdfContext, canvas) {} |
118 | 120 |
(...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1837 } | 1839 } |
1838 | 1840 |
1839 void PdfMainLooper::loop() { | 1841 void PdfMainLooper::loop() { |
1840 PdfToken token; | 1842 PdfToken token; |
1841 while (readToken(fTokenizer, &token)) { | 1843 while (readToken(fTokenizer, &token)) { |
1842 consumeToken(token); | 1844 consumeToken(token); |
1843 } | 1845 } |
1844 } | 1846 } |
1845 | 1847 |
1846 PdfResult PdfInlineImageLooper::consumeToken(PdfToken& token) { | 1848 PdfResult PdfInlineImageLooper::consumeToken(PdfToken& token) { |
1847 //pdfContext.fInlineImage.fKeyValuePairs[key] = value; | 1849 SkASSERT(false); |
1848 return kNYI_PdfResult; | 1850 return kIgnoreError_PdfResult; |
1849 } | 1851 } |
1850 | 1852 |
1851 void PdfInlineImageLooper::loop() { | 1853 void PdfInlineImageLooper::loop() { |
1852 PdfToken token; | 1854 doXObject_Image(fPdfContext, fCanvas, fTokenizer->readInlineImage()); |
1853 while (readToken(fTokenizer, &token)) { | |
1854 if (token.fType == kKeyword_TokenType && strcmp(token.fKeyword, "BX") ==
0) { | |
1855 PdfTokenLooper* looper = new PdfCompatibilitySectionLooper(); | |
1856 looper->setUp(this); | |
1857 looper->loop(); | |
1858 } else { | |
1859 if (token.fType == kKeyword_TokenType && strcmp(token.fKeyword, "EI"
) == 0) { | |
1860 done(); | |
1861 return; | |
1862 } | |
1863 | |
1864 consumeToken(token); | |
1865 } | |
1866 } | |
1867 // TODO(edisonn): report error/warning, EOF without EI. | |
1868 } | 1855 } |
1869 | 1856 |
1870 PdfResult PdfInlineImageLooper::done() { | 1857 PdfResult PdfInlineImageLooper::done() { |
1871 | 1858 |
1872 // TODO(edisonn): long to short names | 1859 // TODO(edisonn): long to short names |
1873 // TODO(edisonn): set properties in a map | 1860 // TODO(edisonn): set properties in a map |
1874 // TODO(edisonn): extract bitmap stream, check if PoDoFo has public utilitie
s to uncompress | 1861 // TODO(edisonn): extract bitmap stream, check if PoDoFo has public utilitie
s to uncompress |
1875 // the stream. | 1862 // the stream. |
1876 | 1863 |
1877 SkBitmap bitmap; | 1864 SkBitmap bitmap; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2021 } | 2008 } |
2022 | 2009 |
2023 SkRect SkPdfRenderer::MediaBox(int page) const { | 2010 SkRect SkPdfRenderer::MediaBox(int page) const { |
2024 SkASSERT(fPdfDoc); | 2011 SkASSERT(fPdfDoc); |
2025 return fPdfDoc->MediaBox(page); | 2012 return fPdfDoc->MediaBox(page); |
2026 } | 2013 } |
2027 | 2014 |
2028 size_t SkPdfRenderer::bytesUsed() const { | 2015 size_t SkPdfRenderer::bytesUsed() const { |
2029 return fPdfDoc ? fPdfDoc->bytesUsed() : 0; | 2016 return fPdfDoc ? fPdfDoc->bytesUsed() : 0; |
2030 } | 2017 } |
OLD | NEW |