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 "SkPdfContext.h" | 8 #include "SkPdfContext.h" |
9 #include "SkPdfNativeDoc.h" | 9 #include "SkPdfNativeDoc.h" |
10 #include "SkPdfReporter.h" | 10 #include "SkPdfReporter.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 /////////////////////////////////////////////////////////////////////////////// | 29 /////////////////////////////////////////////////////////////////////////////// |
30 | 30 |
31 SkPdfContext::SkPdfContext(SkPdfNativeDoc* doc) | 31 SkPdfContext::SkPdfContext(SkPdfNativeDoc* doc) |
32 : fPdfDoc(doc) | 32 : fPdfDoc(doc) |
33 { | 33 { |
34 SkASSERT(fPdfDoc != NULL); | 34 SkASSERT(fPdfDoc != NULL); |
35 } | 35 } |
36 | 36 |
37 void SkPdfContext::parseStream(SkPdfNativeObject* stream, SkCanvas* canvas) { | 37 void SkPdfContext::parseStream(SkPdfNativeObject* stream, SkCanvas* canvas) { |
38 SkPdfNativeTokenizer* tokenizer = fPdfDoc->tokenizerOfStream(stream, &fTmpPa
geAllocator); | 38 if (NULL == stream) { |
39 if (NULL == tokenizer) { | |
40 // Nothing to parse. | 39 // Nothing to parse. |
41 return; | 40 return; |
42 } | 41 } |
43 PdfMainLooper looper(tokenizer, this, canvas); | 42 |
| 43 SkPdfNativeTokenizer tokenizer(stream, &fTmpPageAllocator, fPdfDoc); |
| 44 PdfMainLooper looper(&tokenizer, this, canvas); |
44 looper.loop(); | 45 looper.loop(); |
45 // FIXME (scroggo): Will restructure to put tokenizer on the stack. | |
46 delete tokenizer; | |
47 } | 46 } |
48 | 47 |
49 /////////////////////////////////////////////////////////////////////////////// | 48 /////////////////////////////////////////////////////////////////////////////// |
50 | 49 |
51 // FIXME (scroggo): This probably belongs in a debugging file. | 50 // FIXME (scroggo): This probably belongs in a debugging file. |
52 // For reportRenderStats declaration. | 51 // For reportRenderStats declaration. |
53 #include "SkPdfRenderer.h" | 52 #include "SkPdfRenderer.h" |
54 | 53 |
55 // Temp code to measure what operands fail. | 54 // Temp code to measure what operands fail. |
56 template <typename T> class SkTDictWithDefaultConstructor : public SkTDict<T> { | 55 template <typename T> class SkTDictWithDefaultConstructor : public SkTDict<T> { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 117 } |
119 return kOK_SkPdfResult; | 118 return kOK_SkPdfResult; |
120 } | 119 } |
121 | 120 |
122 void PdfMainLooper::loop() { | 121 void PdfMainLooper::loop() { |
123 PdfToken token; | 122 PdfToken token; |
124 while (fTokenizer->readToken(&token, true)) { | 123 while (fTokenizer->readToken(&token, true)) { |
125 this->consumeToken(token); | 124 this->consumeToken(token); |
126 } | 125 } |
127 } | 126 } |
OLD | NEW |