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

Unified Diff: experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp

Issue 18435007: pdf viewer: refactor and fix a bug (SkPdfobject should not reset on destruct) (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp
===================================================================
--- experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp (revision 9971)
+++ experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp (working copy)
@@ -656,8 +656,14 @@
free(fHandles[i]);
}
for (int i = 0 ; i < fHistory.count(); i++) {
+ for (int j = 0 ; j < BUFFER_SIZE; j++) {
+ fHistory[i][j].reset();
+ }
delete[] fHistory[i];
}
+ for (int j = 0 ; j < BUFFER_SIZE; j++) {
+ fCurrent[j].reset();
+ }
delete[] fCurrent;
}
@@ -667,7 +673,6 @@
fCurrent = allocBlock();
fCurrentUsed = 0;
}
-
fCurrentUsed++;
return &fCurrent[fCurrentUsed - 1];
}
@@ -677,26 +682,28 @@
unsigned char* buffer = NULL;
size_t len = 0;
objWithStream->GetFilteredStreamRef(&buffer, &len, fAllocator);
+ // TODO(edisonn): hack, find end of object
+// char* endobj = strstr((char*)buffer, "endobj");
+// if (endobj) {
+// len = endobj - (char*)buffer + strlen("endobj");
+// }
fUncompressedStreamStart = fUncompressedStream = (unsigned char*)fAllocator->alloc(len);
fUncompressedStreamEnd = fUncompressedStream + len;
- memcpy(fUncompressedStream, buffer, len);}
+ memcpy(fUncompressedStream, buffer, len);
+}
SkPdfNativeTokenizer::SkPdfNativeTokenizer(unsigned char* buffer, int len, const SkPdfMapper* mapper, SkPdfAllocator* allocator) : fMapper(mapper), fAllocator(allocator), fEmpty(false), fHasPutBack(false) {
+ // TODO(edisonn): hack, find end of object
+// char* endobj = strstr((char*)buffer, "endobj");
+// if (endobj) {
+// len = endobj - (char*)buffer + strlen("endobj");
+// }
fUncompressedStreamStart = fUncompressedStream = (unsigned char*)fAllocator->alloc(len);
fUncompressedStreamEnd = fUncompressedStream + len;
memcpy(fUncompressedStream, buffer, len);
}
SkPdfNativeTokenizer::~SkPdfNativeTokenizer() {
- // free the unparsed stream, we don't need it.
- // the parsed one is locked as it contains the strings and keywords referenced in objects
- if (fUncompressedStream) {
- void* dummy = realloc(fUncompressedStreamStart, fUncompressedStream - fUncompressedStreamStart);
- //SkASSERT(dummy == fUncompressedStreamStart);
- fUncompressedStreamStart = (unsigned char*)dummy; // suppress compiler warning
- } else {
- SkASSERT(false);
- }
}
bool SkPdfNativeTokenizer::readTokenCore(PdfToken* token) {
@@ -726,7 +733,7 @@
#ifdef PDF_TRACE
static int read_op = 0;
read_op++;
- if (182749 == read_op) {
+ if (548 == read_op) {
printf("break;\n");
}
printf("%i READ %s %s\n", read_op, token->fType == kKeyword_TokenType ? "Keyword" : "Object", token->fKeyword ? std::string(token->fKeyword, token->fKeywordLength).c_str() : token->fObject->toString().c_str());
@@ -763,3 +770,4 @@
return readTokenCore(token);
}
+
« 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