| 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 "SkPdfHeaders_autogen.h" | |
| 9 #include "SkPdfMapper_autogen.h" | |
| 10 | 8 |
| 11 #ifndef SkPdfParser_DEFINED | 9 #ifndef SkPdfParser_DEFINED |
| 12 #define SkPdfParser_DEFINED | 10 #define SkPdfParser_DEFINED |
| 13 | 11 |
| 14 #include "SkPdfBasics.h" | 12 #include "SkPdfBasics.h" |
| 15 #include "SkPdfPodofoTokenizer.h" | 13 #include "SkPdfNativeTokenizer.h" |
| 16 | 14 |
| 17 extern "C" PdfContext* gPdfContext; | 15 extern "C" PdfContext* gPdfContext; |
| 18 extern "C" SkBitmap* gDumpBitmap; | 16 extern "C" SkBitmap* gDumpBitmap; |
| 19 extern "C" SkCanvas* gDumpCanvas; | 17 extern "C" SkCanvas* gDumpCanvas; |
| 20 | 18 |
| 21 // TODO(edisonn): Document PdfTokenLooper and subclasses. | 19 // TODO(edisonn): Document PdfTokenLooper and subclasses. |
| 22 class PdfTokenLooper { | 20 class PdfTokenLooper { |
| 23 protected: | 21 protected: |
| 24 PdfTokenLooper* fParent; | 22 PdfTokenLooper* fParent; |
| 25 SkPdfPodofoTokenizer* fTokenizer; | 23 SkPdfNativeTokenizer* fTokenizer; |
| 26 PdfContext* fPdfContext; | 24 PdfContext* fPdfContext; |
| 27 SkCanvas* fCanvas; | 25 SkCanvas* fCanvas; |
| 28 | 26 |
| 29 public: | 27 public: |
| 30 PdfTokenLooper(PdfTokenLooper* parent, | 28 PdfTokenLooper(PdfTokenLooper* parent, |
| 31 SkPdfPodofoTokenizer* tokenizer, | 29 SkPdfNativeTokenizer* tokenizer, |
| 32 PdfContext* pdfContext, | 30 PdfContext* pdfContext, |
| 33 SkCanvas* canvas) | 31 SkCanvas* canvas) |
| 34 : fParent(parent), fTokenizer(tokenizer), fPdfContext(pdfContext), fCanv
as(canvas) {} | 32 : fParent(parent), fTokenizer(tokenizer), fPdfContext(pdfContext), fCanv
as(canvas) {} |
| 35 | 33 |
| 36 virtual PdfResult consumeToken(PdfToken& token) = 0; | 34 virtual PdfResult consumeToken(PdfToken& token) = 0; |
| 37 virtual void loop() = 0; | 35 virtual void loop() = 0; |
| 38 | 36 |
| 39 void setUp(PdfTokenLooper* parent) { | 37 void setUp(PdfTokenLooper* parent) { |
| 40 fParent = parent; | 38 fParent = parent; |
| 41 fTokenizer = parent->fTokenizer; | 39 fTokenizer = parent->fTokenizer; |
| 42 fPdfContext = parent->fPdfContext; | 40 fPdfContext = parent->fPdfContext; |
| 43 fCanvas = parent->fCanvas; | 41 fCanvas = parent->fCanvas; |
| 44 } | 42 } |
| 45 }; | 43 }; |
| 46 | 44 |
| 47 class PdfMainLooper : public PdfTokenLooper { | 45 class PdfMainLooper : public PdfTokenLooper { |
| 48 public: | 46 public: |
| 49 PdfMainLooper(PdfTokenLooper* parent, | 47 PdfMainLooper(PdfTokenLooper* parent, |
| 50 SkPdfPodofoTokenizer* tokenizer, | 48 SkPdfNativeTokenizer* tokenizer, |
| 51 PdfContext* pdfContext, | 49 PdfContext* pdfContext, |
| 52 SkCanvas* canvas) | 50 SkCanvas* canvas) |
| 53 : PdfTokenLooper(parent, tokenizer, pdfContext, canvas) {} | 51 : PdfTokenLooper(parent, tokenizer, pdfContext, canvas) {} |
| 54 | 52 |
| 55 virtual PdfResult consumeToken(PdfToken& token); | 53 virtual PdfResult consumeToken(PdfToken& token); |
| 56 virtual void loop(); | 54 virtual void loop(); |
| 57 }; | 55 }; |
| 58 | 56 |
| 59 class PdfInlineImageLooper : public PdfTokenLooper { | 57 class PdfInlineImageLooper : public PdfTokenLooper { |
| 60 public: | 58 public: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 79 class SkPdfViewer : public SkRefCnt { | 77 class SkPdfViewer : public SkRefCnt { |
| 80 public: | 78 public: |
| 81 | 79 |
| 82 bool load(const SkString inputFileName, SkPicture* out); | 80 bool load(const SkString inputFileName, SkPicture* out); |
| 83 bool write(void*) const { return false; } | 81 bool write(void*) const { return false; } |
| 84 }; | 82 }; |
| 85 | 83 |
| 86 void reportPdfRenderStats(); | 84 void reportPdfRenderStats(); |
| 87 | 85 |
| 88 #endif // SkPdfParser_DEFINED | 86 #endif // SkPdfParser_DEFINED |
| OLD | NEW |