| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2013 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #ifndef SkPdfTokenLooper_DEFINED | |
| 9 #define SkPdfTokenLooper_DEFINED | |
| 10 | |
| 11 #include "SkPdfNativeTokenizer.h" | |
| 12 // For SkPdfResult | |
| 13 #include "SkPdfUtils.h" | |
| 14 | |
| 15 class SkCanvas; | |
| 16 class SkPdfContext; | |
| 17 | |
| 18 /** | |
| 19 * An object which reads tokens from a tokenizer and draws it to an SkCanvas. | |
| 20 * FIXME (scroggo): Can this be an interface? See http://goo.gl/AXQtkH | |
| 21 */ | |
| 22 class SkPdfTokenLooper { | |
| 23 public: | |
| 24 /** | |
| 25 * Create a looper with no parent. | |
| 26 * @param tokenizer SkPdfNativeTokenizer for reading tokens. | |
| 27 * @param pdfContext Context for drawing state. | |
| 28 * @param canvas Target SkCanvas for drawing. | |
| 29 */ | |
| 30 SkPdfTokenLooper(SkPdfNativeTokenizer* tokenizer, | |
| 31 SkPdfContext* pdfContext, | |
| 32 SkCanvas* canvas) | |
| 33 : fParent(NULL) | |
| 34 , fTokenizer(tokenizer) | |
| 35 , fPdfContext(pdfContext) | |
| 36 , fCanvas(canvas) {} | |
| 37 | |
| 38 /** | |
| 39 * Create a looper as a child of parent. It will share the | |
| 40 * SkPdfContext, SkPdfTokenizer, and SkCanvas with its parent. | |
| 41 */ | |
| 42 explicit SkPdfTokenLooper(SkPdfTokenLooper* parent) | |
| 43 : fParent(parent) | |
| 44 , fTokenizer(parent->fTokenizer) | |
| 45 , fPdfContext(parent->fPdfContext) | |
| 46 , fCanvas(parent->fCanvas) {} | |
| 47 | |
| 48 virtual ~SkPdfTokenLooper() {} | |
| 49 | |
| 50 /** | |
| 51 * Consume a token, and draw to fCanvas as directed. | |
| 52 */ | |
| 53 virtual SkPdfResult consumeToken(PdfToken& token) = 0; | |
| 54 | |
| 55 /** | |
| 56 * Consume all the tokens this looper can handle. | |
| 57 */ | |
| 58 virtual void loop() = 0; | |
| 59 | |
| 60 protected: | |
| 61 // All are unowned pointers. | |
| 62 SkPdfTokenLooper* fParent; | |
| 63 SkPdfNativeTokenizer* fTokenizer; | |
| 64 SkPdfContext* fPdfContext; | |
| 65 SkCanvas* fCanvas; | |
| 66 }; | |
| 67 | |
| 68 #endif // SkPdfTokenLooper_DEFINED | |
| OLD | NEW |