Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp

Issue 22269002: pdfviewer: debug code for crash (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « experimental/PdfViewer/SkPdfRenderer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 len = endobj - (char*)buffer + strlen("endobj"); 922 len = endobj - (char*)buffer + strlen("endobj");
923 } 923 }
924 fUncompressedStreamStart = fUncompressedStream = buffer; 924 fUncompressedStreamStart = fUncompressedStream = buffer;
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;
933 #ifdef PDF_TRACE_READ_TOKEN
934 static int read_op = 0;
935 int last;
936 #endif
932 token->fKeyword = NULL; 937 token->fKeyword = NULL;
933 token->fObject = NULL; 938 token->fObject = NULL;
934 939
935 fUncompressedStream = skipPdfWhiteSpaces(0, fUncompressedStream, fUncompress edStreamEnd); 940 fUncompressedStream = skipPdfWhiteSpaces(0, fUncompressedStream, fUncompress edStreamEnd);
936 if (fUncompressedStream >= fUncompressedStreamEnd) { 941 if (fUncompressedStream >= fUncompressedStreamEnd) {
937 return false; 942 return false;
938 } 943 }
939 944
940 SkPdfObject obj; 945 #ifdef PDF_TRACE_READ_TOKEN
946 printf("BEFORE the read: %i\n", read_op);
947 last = read_op;
948 #endif
949
941 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompressedStream End, &obj, fAllocator, fDoc); 950 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
942 957
943 // If it is a keyword, we will only get the pointer of the string 958 // If it is a keyword, we will only get the pointer of the string
944 if (obj.type() == SkPdfObject::kKeyword_PdfObjectType) { 959 if (obj.type() == SkPdfObject::kKeyword_PdfObjectType) {
945 token->fKeyword = obj.c_str(); 960 token->fKeyword = obj.c_str();
946 token->fKeywordLength = obj.lenstr(); 961 token->fKeywordLength = obj.lenstr();
947 token->fType = kKeyword_TokenType; 962 token->fType = kKeyword_TokenType;
948 } else { 963 } else {
949 SkPdfObject* pobj = fAllocator->allocObject(); 964 SkPdfObject* pobj = fAllocator->allocObject();
950 *pobj = obj; 965 *pobj = obj;
951 token->fObject = pobj; 966 token->fObject = pobj;
952 token->fType = kObject_TokenType; 967 token->fType = kObject_TokenType;
953 } 968 }
954 969
955 #ifdef PDF_TRACE_READ_TOKEN 970 #ifdef PDF_TRACE_READ_TOKEN
956 static int read_op = 0;
957 read_op++; 971 read_op++;
958 #if 0 972 #if 0
959 if (548 == read_op) { 973 if (548 == read_op) {
960 printf("break;\n"); 974 printf("break;\n");
961 } 975 }
962 #endif 976 #endif
963 printf("%i READ %s %s\n", read_op, token->fType == kKeyword_TokenType ? "Key word" : "Object", token->fKeyword ? std::string(token->fKeyword, token->fKeyword Length).c_str() : token->fObject->toString().c_str()); 977 printf("%i READ %s %s\n", read_op, token->fType == kKeyword_TokenType ? "Key word" : "Object", token->fKeyword ? std::string(token->fKeyword, token->fKeyword Length).c_str() : token->fObject->toString().c_str());
964 #endif 978 #endif
965 979
966 return true; 980 return true;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 SkPdfObject* obj = fAllocator->allocObject(); 1101 SkPdfObject* obj = fAllocator->allocObject();
1088 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompress edStreamEnd, obj, fAllocator, fDoc); 1102 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompress edStreamEnd, obj, fAllocator, fDoc);
1089 // TODO(edisonn): perf maybe we should not expand abreviation like t his 1103 // TODO(edisonn): perf maybe we should not expand abreviation like t his
1090 inlineImage->set(inlineImageKeyAbbreviationExpand(key), 1104 inlineImage->set(inlineImageKeyAbbreviationExpand(key),
1091 inlineImageValueAbbreviationExpand(obj)); 1105 inlineImageValueAbbreviationExpand(obj));
1092 } 1106 }
1093 } 1107 }
1094 // TODO(edisonn): report end of data with inline image without an EI 1108 // TODO(edisonn): report end of data with inline image without an EI
1095 return inlineImage; 1109 return inlineImage;
1096 } 1110 }
OLDNEW
« no previous file with comments | « experimental/PdfViewer/SkPdfRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698