| 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 SkPdfNativeTokenizer_DEFINED | 8 #ifndef SkPdfNativeTokenizer_DEFINED |
| 9 #define SkPdfNativeTokenizer_DEFINED | 9 #define SkPdfNativeTokenizer_DEFINED |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 ((ch)==kOpenedCurlyBracket_PdfDelimiter)||\ | 63 ((ch)==kOpenedCurlyBracket_PdfDelimiter)||\ |
| 64 ((ch)==kClosedCurlyBracket_PdfDelimiter)||\ | 64 ((ch)==kClosedCurlyBracket_PdfDelimiter)||\ |
| 65 ((ch)==kNamed_PdfDelimiter)||\ | 65 ((ch)==kNamed_PdfDelimiter)||\ |
| 66 ((ch)==kComment_PdfDelimiter)) | 66 ((ch)==kComment_PdfDelimiter)) |
| 67 | 67 |
| 68 #define isPdfWhiteSpaceOrPdfDelimiter(ch) (isPdfWhiteSpace(ch)||isPdfDelimiter(c
h)) | 68 #define isPdfWhiteSpaceOrPdfDelimiter(ch) (isPdfWhiteSpace(ch)||isPdfDelimiter(c
h)) |
| 69 | 69 |
| 70 #define isPdfDigit(ch) ((ch)>='0'&&(ch)<='9') | 70 #define isPdfDigit(ch) ((ch)>='0'&&(ch)<='9') |
| 71 #define isPdfNumeric(ch) (isPdfDigit(ch)||(ch)=='+'||(ch)=='-'||(ch)=='.') | 71 #define isPdfNumeric(ch) (isPdfDigit(ch)||(ch)=='+'||(ch)=='-'||(ch)=='.') |
| 72 | 72 |
| 73 const unsigned char* skipPdfWhiteSpaces(int level, const unsigned char* buffer,
const unsigned char* end); | 73 const unsigned char* skipPdfWhiteSpaces(const unsigned char* buffer, const unsig
ned char* end); |
| 74 const unsigned char* endOfPdfToken(int level, const unsigned char* start, const
unsigned char* end); | 74 const unsigned char* endOfPdfToken(const unsigned char* start, const unsigned ch
ar* end); |
| 75 | 75 |
| 76 // TODO(edisonn): typedef read and integer tyepes? make less readable... | 76 // TODO(edisonn): typedef read and integer tyepes? make less readable... |
| 77 //typedef double SkPdfReal; | 77 //typedef double SkPdfReal; |
| 78 //typedef int64_t SkPdfInteger; | 78 //typedef int64_t SkPdfInteger; |
| 79 | 79 |
| 80 // an allocator only allocates memory, and it deletes it all when the allocator
is destroyed | 80 // an allocator only allocates memory, and it deletes it all when the allocator
is destroyed |
| 81 // this would allow us not to do any garbage collection while we parse or draw a
pdf, and defere it | 81 // this would allow us not to do any garbage collection while we parse or draw a
pdf, and defere it |
| 82 // while the user is looking at the image | 82 // while the user is looking at the image |
| 83 | 83 |
| 84 class SkPdfNativeObject; | 84 class SkPdfNativeObject; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 111 fSizeInBytes += bytes; | 111 fSizeInBytes += bytes; |
| 112 return data; | 112 return data; |
| 113 } | 113 } |
| 114 | 114 |
| 115 size_t bytesUsed() const { | 115 size_t bytesUsed() const { |
| 116 return fSizeInBytes; | 116 return fSizeInBytes; |
| 117 } | 117 } |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 class SkPdfNativeDoc; | 120 class SkPdfNativeDoc; |
| 121 const unsigned char* nextObject(int level, const unsigned char* start, const uns
igned char* end, SkPdfNativeObject* token, SkPdfAllocator* allocator, SkPdfNativ
eDoc* doc GET_TRACK_STREAM); | 121 const unsigned char* nextObject(const unsigned char* start, const unsigned char*
end, SkPdfNativeObject* token, SkPdfAllocator* allocator, SkPdfNativeDoc* doc); |
| 122 | 122 |
| 123 enum SkPdfTokenType { | 123 enum SkPdfTokenType { |
| 124 kKeyword_TokenType, | 124 kKeyword_TokenType, |
| 125 kObject_TokenType, | 125 kObject_TokenType, |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 struct PdfToken { | 128 struct PdfToken { |
| 129 const char* fKeyword; | 129 const char* fKeyword; |
| 130 size_t fKeywordLength; | 130 size_t fKeywordLength; |
| 131 SkPdfNativeObject* fObject; | 131 SkPdfNativeObject* fObject; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 150 SkPdfNativeDoc* fDoc; | 150 SkPdfNativeDoc* fDoc; |
| 151 SkPdfAllocator* fAllocator; | 151 SkPdfAllocator* fAllocator; |
| 152 | 152 |
| 153 const unsigned char* fUncompressedStreamStart; | 153 const unsigned char* fUncompressedStreamStart; |
| 154 const unsigned char* fUncompressedStream; | 154 const unsigned char* fUncompressedStream; |
| 155 const unsigned char* fUncompressedStreamEnd; | 155 const unsigned char* fUncompressedStreamEnd; |
| 156 | 156 |
| 157 bool fEmpty; | 157 bool fEmpty; |
| 158 bool fHasPutBack; | 158 bool fHasPutBack; |
| 159 PdfToken fPutBack; | 159 PdfToken fPutBack; |
| 160 | |
| 161 #ifdef PDF_TRACK_STREAM_OFFSETS | |
| 162 int fStreamId; | |
| 163 #endif // PDF_TRACK_STREAM_OFFSETS | |
| 164 }; | 160 }; |
| 165 | 161 |
| 166 #endif // SkPdfNativeTokenizer_DEFINED | 162 #endif // SkPdfNativeTokenizer_DEFINED |
| OLD | NEW |