OLD | NEW |
1 | 1 |
2 #include "SkPdfNativeTokenizer.h" | 2 #include "SkPdfNativeTokenizer.h" |
3 #include "SkPdfObject.h" | 3 #include "SkPdfObject.h" |
4 #include "SkPdfConfig.h" | 4 #include "SkPdfConfig.h" |
5 | 5 |
6 #include "SkPdfStreamCommonDictionary_autogen.h" | 6 #include "SkPdfStreamCommonDictionary_autogen.h" |
7 #include "SkPdfImageDictionary_autogen.h" | 7 #include "SkPdfImageDictionary_autogen.h" |
8 | 8 |
9 // TODO(edisonn): perf!!! | 9 // TODO(edisonn): perf!!! |
10 // there could be 0s between start and end! but not in the needle. | 10 // there could be 0s between start and end! but not in the needle. |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 fUncompressedStreamEnd = fUncompressedStream + len; | 925 fUncompressedStreamEnd = fUncompressedStream + len; |
926 } | 926 } |
927 | 927 |
928 SkPdfNativeTokenizer::~SkPdfNativeTokenizer() { | 928 SkPdfNativeTokenizer::~SkPdfNativeTokenizer() { |
929 } | 929 } |
930 | 930 |
931 bool SkPdfNativeTokenizer::readTokenCore(PdfToken* token) { | 931 bool SkPdfNativeTokenizer::readTokenCore(PdfToken* token) { |
932 SkPdfObject obj; | 932 SkPdfObject obj; |
933 #ifdef PDF_TRACE_READ_TOKEN | 933 #ifdef PDF_TRACE_READ_TOKEN |
934 static int read_op = 0; | 934 static int read_op = 0; |
935 int last; | |
936 #endif | 935 #endif |
937 token->fKeyword = NULL; | 936 token->fKeyword = NULL; |
938 token->fObject = NULL; | 937 token->fObject = NULL; |
939 | 938 |
940 fUncompressedStream = skipPdfWhiteSpaces(0, fUncompressedStream, fUncompress
edStreamEnd); | 939 fUncompressedStream = skipPdfWhiteSpaces(0, fUncompressedStream, fUncompress
edStreamEnd); |
941 if (fUncompressedStream >= fUncompressedStreamEnd) { | 940 if (fUncompressedStream >= fUncompressedStreamEnd) { |
942 return false; | 941 return false; |
943 } | 942 } |
944 | 943 |
945 #ifdef PDF_TRACE_READ_TOKEN | |
946 printf("BEFORE the read: %i\n", read_op); | |
947 last = read_op; | |
948 #endif | |
949 | |
950 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompressedStream
End, &obj, fAllocator, fDoc); | 944 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompressedStream
End, &obj, fAllocator, fDoc); |
951 #ifdef PDF_TRACE_READ_TOKEN | |
952 printf("BEFORE the read: %i\n", read_op); | |
953 if (last != read_op) { | |
954 printf("break; // memory override"); | |
955 } | |
956 #endif | |
957 | 945 |
958 // If it is a keyword, we will only get the pointer of the string | 946 // If it is a keyword, we will only get the pointer of the string |
959 if (obj.type() == SkPdfObject::kKeyword_PdfObjectType) { | 947 if (obj.type() == SkPdfObject::kKeyword_PdfObjectType) { |
960 token->fKeyword = obj.c_str(); | 948 token->fKeyword = obj.c_str(); |
961 token->fKeywordLength = obj.lenstr(); | 949 token->fKeywordLength = obj.lenstr(); |
962 token->fType = kKeyword_TokenType; | 950 token->fType = kKeyword_TokenType; |
963 } else { | 951 } else { |
964 SkPdfObject* pobj = fAllocator->allocObject(); | 952 SkPdfObject* pobj = fAllocator->allocObject(); |
965 *pobj = obj; | 953 *pobj = obj; |
966 token->fObject = pobj; | 954 token->fObject = pobj; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 SkPdfObject* obj = fAllocator->allocObject(); | 1089 SkPdfObject* obj = fAllocator->allocObject(); |
1102 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompress
edStreamEnd, obj, fAllocator, fDoc); | 1090 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompress
edStreamEnd, obj, fAllocator, fDoc); |
1103 // TODO(edisonn): perf maybe we should not expand abreviation like t
his | 1091 // TODO(edisonn): perf maybe we should not expand abreviation like t
his |
1104 inlineImage->set(inlineImageKeyAbbreviationExpand(key), | 1092 inlineImage->set(inlineImageKeyAbbreviationExpand(key), |
1105 inlineImageValueAbbreviationExpand(obj)); | 1093 inlineImageValueAbbreviationExpand(obj)); |
1106 } | 1094 } |
1107 } | 1095 } |
1108 // TODO(edisonn): report end of data with inline image without an EI | 1096 // TODO(edisonn): report end of data with inline image without an EI |
1109 return inlineImage; | 1097 return inlineImage; |
1110 } | 1098 } |
OLD | NEW |