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

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

Issue 21738005: pdfviewer: add indexed rbg image support, enhanche caching(setData) for SkPdfObject (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
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 14 matching lines...) Expand all
25 } 25 }
26 hayStart++; 26 hayStart++;
27 } 27 }
28 return NULL; 28 return NULL;
29 } 29 }
30 30
31 #ifdef PDF_TRACE_TOKENIZER 31 #ifdef PDF_TRACE_TOKENIZER
32 static void TRACE_INDENT(int level, const char* type) { 32 static void TRACE_INDENT(int level, const char* type) {
33 static int id = 0; 33 static int id = 0;
34 id++; 34 id++;
35 #if 0
35 if (478613 == id) { 36 if (478613 == id) {
36 printf("break;\n"); 37 printf("break;\n");
37 } 38 }
39 #endif
38 // all types should have 2 letters, so the text is alligned nicely 40 // all types should have 2 letters, so the text is alligned nicely
39 printf("\n%10i %15s: ", id, type); 41 printf("\n%10i %15s: ", id, type);
40 for (int i = 0 ; i < level; i++) { 42 for (int i = 0 ; i < level; i++) {
41 printf(" "); 43 printf(" ");
42 } 44 }
43 } 45 }
44 46
45 static void TRACE_COMMENT(char ch) { 47 static void TRACE_COMMENT(char ch) {
46 printf("%c", ch); 48 printf("%c", ch);
47 } 49 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // TODO(edisonn): perf/memory: put the variables on the stack, and flush them on the array only when 153 // TODO(edisonn): perf/memory: put the variables on the stack, and flush them on the array only when
152 // we are sure they are not references! 154 // we are sure they are not references!
153 if (newObj->isKeywordReference() && array->size() >= 2 && array->objAtAI ndex(array->size() - 1)->isInteger() && array->objAtAIndex(array->size() - 2)->i sInteger()) { 155 if (newObj->isKeywordReference() && array->size() >= 2 && array->objAtAI ndex(array->size() - 1)->isInteger() && array->objAtAIndex(array->size() - 2)->i sInteger()) {
154 SkPdfObject* gen = array->removeLastInArray(); 156 SkPdfObject* gen = array->removeLastInArray();
155 SkPdfObject* id = array->removeLastInArray(); 157 SkPdfObject* id = array->removeLastInArray();
156 newObj->reset(); 158 newObj->reset();
157 SkPdfObject::makeReference((unsigned int)id->intValue(), (unsigned i nt)gen->intValue(), newObj); 159 SkPdfObject::makeReference((unsigned int)id->intValue(), (unsigned i nt)gen->intValue(), newObj);
158 } 160 }
159 array->appendInArray(newObj); 161 array->appendInArray(newObj);
160 } 162 }
161 printf("break;\n"); // DO NOT SUBMIT!
162 // TODO(edisonn): report not reached, we should never get here 163 // TODO(edisonn): report not reached, we should never get here
163 // TODO(edisonn): there might be a bug here, enable an assert and run it on files 164 // TODO(edisonn): there might be a bug here, enable an assert and run it on files
164 // or it might be that the files were actually corrupted 165 // or it might be that the files were actually corrupted
165 return start; 166 return start;
166 } 167 }
167 168
168 // When we read strings we will rewrite the string so we will reuse the memory 169 // When we read strings we will rewrite the string so we will reuse the memory
169 // when we start to read the string, we already consumed the opened bracket 170 // when we start to read the string, we already consumed the opened bracket
170 171
171 // TODO(edisonn): space: add paramater, taht would report if we need to allocate new buffer, or we can reuse the one we have 172 // TODO(edisonn): space: add paramater, taht would report if we need to allocate new buffer, or we can reuse the one we have
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 } else { 948 } else {
948 SkPdfObject* pobj = fAllocator->allocObject(); 949 SkPdfObject* pobj = fAllocator->allocObject();
949 *pobj = obj; 950 *pobj = obj;
950 token->fObject = pobj; 951 token->fObject = pobj;
951 token->fType = kObject_TokenType; 952 token->fType = kObject_TokenType;
952 } 953 }
953 954
954 #ifdef PDF_TRACE_READ_TOKEN 955 #ifdef PDF_TRACE_READ_TOKEN
955 static int read_op = 0; 956 static int read_op = 0;
956 read_op++; 957 read_op++;
958 #if 0
957 if (548 == read_op) { 959 if (548 == read_op) {
958 printf("break;\n"); 960 printf("break;\n");
959 } 961 }
962 #endif
960 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()); 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());
961 #endif 964 #endif
962 965
963 return true; 966 return true;
964 } 967 }
965 968
966 void SkPdfNativeTokenizer::PutBack(PdfToken token) { 969 void SkPdfNativeTokenizer::PutBack(PdfToken token) {
967 SkASSERT(!fHasPutBack); 970 SkASSERT(!fHasPutBack);
968 fHasPutBack = true; 971 fHasPutBack = true;
969 fPutBack = token; 972 fPutBack = token;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 SkPdfObject* obj = fAllocator->allocObject(); 1087 SkPdfObject* obj = fAllocator->allocObject();
1085 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompress edStreamEnd, obj, fAllocator, fDoc); 1088 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompress edStreamEnd, obj, fAllocator, fDoc);
1086 // TODO(edisonn): perf maybe we should not expand abreviation like t his 1089 // TODO(edisonn): perf maybe we should not expand abreviation like t his
1087 inlineImage->set(inlineImageKeyAbbreviationExpand(key), 1090 inlineImage->set(inlineImageKeyAbbreviationExpand(key),
1088 inlineImageValueAbbreviationExpand(obj)); 1091 inlineImageValueAbbreviationExpand(obj));
1089 } 1092 }
1090 } 1093 }
1091 // TODO(edisonn): report end of data with inline image without an EI 1094 // TODO(edisonn): report end of data with inline image without an EI
1092 return inlineImage; 1095 return inlineImage;
1093 } 1096 }
OLDNEW
« no previous file with comments | « experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp ('k') | experimental/PdfViewer/pdfparser/native/SkPdfObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698