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 #ifndef SkPdfTokenLooper_DEFINED | 8 #ifndef SkPdfTokenLooper_DEFINED |
9 #define SkPdfTokenLooper_DEFINED | 9 #define SkPdfTokenLooper_DEFINED |
10 | 10 |
11 #include "SkPdfNativeTokenizer.h" | 11 #include "SkPdfNativeTokenizer.h" |
12 // For SkPdfResult | 12 // For SkPdfResult |
13 #include "SkPdfUtils.h" | 13 #include "SkPdfUtils.h" |
14 | 14 |
15 class SkCanvas; | 15 class SkCanvas; |
16 class SkPdfContext; | 16 class SkPdfContext; |
17 | 17 |
18 /** | |
19 * An object which reads tokens from a tokenizer and draws it to an SkCanvas. | |
20 */ | |
18 class SkPdfTokenLooper { | 21 class SkPdfTokenLooper { |
19 protected: | 22 public: |
20 SkPdfTokenLooper* fParent; | 23 /** |
21 SkPdfNativeTokenizer* fTokenizer; | 24 * Create a looper with no parent. |
22 SkPdfContext* fPdfContext; | 25 * @param tokenizer SkPdfNativeTokenizer for reading tokens. |
23 SkCanvas* fCanvas; | 26 * @param pdfContext Context for drawing state. |
27 * @param canvas Target SkCanvas for drawing. | |
28 */ | |
29 SkPdfTokenLooper(SkPdfNativeTokenizer* tokenizer, | |
mtklein
2013/12/02 21:28:08
This has just occurred to me (I think, maybe I've
scroggo
2013/12/02 22:34:29
All subclasses need fTokenizer, fPdfContext, and f
| |
30 SkPdfContext* pdfContext, | |
31 SkCanvas* canvas) | |
32 : fParent(NULL) | |
33 , fTokenizer(tokenizer) | |
34 , fPdfContext(pdfContext) | |
35 , fCanvas(canvas) {} | |
24 | 36 |
25 public: | 37 /** |
26 SkPdfTokenLooper(SkPdfTokenLooper* parent, | 38 * Create a looper as a child of parent. It will share the |
27 SkPdfNativeTokenizer* tokenizer, | 39 * SkPdfContext, SkPdfTokenizer, and SkCanvas with its parent. |
28 SkPdfContext* pdfContext, | 40 */ |
29 SkCanvas* canvas) | 41 explicit SkPdfTokenLooper(SkPdfTokenLooper* parent) |
30 : fParent(parent), fTokenizer(tokenizer), fPdfContext(pdfContext), fCanv as(canvas) {} | 42 : fParent(parent) |
43 , fTokenizer(parent->fTokenizer) | |
44 , fPdfContext(parent->fPdfContext) | |
45 , fCanvas(parent->fCanvas) {} | |
31 | 46 |
32 virtual ~SkPdfTokenLooper() {} | 47 virtual ~SkPdfTokenLooper() {} |
33 | 48 |
49 /** | |
50 * Consume a token, and draw to fCanvas as directed. | |
51 */ | |
34 virtual SkPdfResult consumeToken(PdfToken& token) = 0; | 52 virtual SkPdfResult consumeToken(PdfToken& token) = 0; |
53 | |
54 /** | |
55 * Consume all the tokens this looper can handle. | |
56 */ | |
35 virtual void loop() = 0; | 57 virtual void loop() = 0; |
36 | 58 |
37 void setUp(SkPdfTokenLooper* parent) { | 59 protected: |
38 fParent = parent; | 60 // All are unowned pointers. |
39 fTokenizer = parent->fTokenizer; | 61 SkPdfTokenLooper* fParent; |
40 fPdfContext = parent->fPdfContext; | 62 SkPdfNativeTokenizer* fTokenizer; |
41 fCanvas = parent->fCanvas; | 63 SkPdfContext* fPdfContext; |
42 } | 64 SkCanvas* fCanvas; |
43 }; | 65 }; |
44 | 66 |
45 #endif // SkPdfTokenLooper_DEFINED | 67 #endif // SkPdfTokenLooper_DEFINED |
OLD | NEW |