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 23163007: pdfviewer: make pdfviewer compile on mac 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/pdfparser/native/SkPdfNativeTokenizer.h ('k') | gyp/pdfviewer.gyp » ('j') | 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 "SkPdfNativeObject.h" 3 #include "SkPdfNativeObject.h"
4 #include "SkPdfConfig.h" 4 #include "SkPdfConfig.h"
5 5
6 #include "SkPdfStreamCommonDictionary_autogen.h" 6 // TODO(edisonn): mac builder does not find the header ... but from headers is o k
7 #include "SkPdfImageDictionary_autogen.h" 7 //#include "SkPdfStreamCommonDictionary_autogen.h"
8 //#include "SkPdfImageDictionary_autogen.h"
9 #include "SkPdfHeaders_autogen.h"
10
8 11
9 // TODO(edisonn): perf!!! 12 // TODO(edisonn): perf!!!
10 // there could be 0s between start and end! but not in the needle. 13 // there could be 0s between start and end! but not in the needle.
11 static char* strrstrk(char* hayStart, char* hayEnd, const char* needle) { 14 static char* strrstrk(char* hayStart, char* hayEnd, const char* needle) {
12 int needleLen = strlen(needle); 15 int needleLen = strlen(needle);
13 if ((isPdfWhiteSpaceOrPdfDelimiter(*(hayStart+needleLen)) || (hayStart+needl eLen == hayEnd)) && 16 if ((isPdfWhiteSpaceOrPdfDelimiter(*(hayStart+needleLen)) || (hayStart+needl eLen == hayEnd)) &&
14 strncmp(hayStart, needle, needleLen) == 0) { 17 strncmp(hayStart, needle, needleLen) == 0) {
15 return hayStart; 18 return hayStart;
16 } 19 }
17 20
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 fHistory.push(fCurrent); 898 fHistory.push(fCurrent);
896 fCurrent = allocBlock(); 899 fCurrent = allocBlock();
897 fCurrentUsed = 0; 900 fCurrentUsed = 0;
898 fSizeInBytes += sizeof(SkPdfNativeObject*); 901 fSizeInBytes += sizeof(SkPdfNativeObject*);
899 } 902 }
900 fCurrentUsed++; 903 fCurrentUsed++;
901 return &fCurrent[fCurrentUsed - 1]; 904 return &fCurrent[fCurrentUsed - 1];
902 } 905 }
903 906
904 // TODO(edisonn): perf: do no copy the buffers, but use them, and mark cache the result, so there is no need of a second pass 907 // TODO(edisonn): perf: do no copy the buffers, but use them, and mark cache the result, so there is no need of a second pass
905 SkPdfNativeTokenizer::SkPdfNativeTokenizer(SkPdfNativeObject* objWithStream, con st SkPdfMapper* mapper, SkPdfAllocator* allocator, SkPdfNativeDoc* doc) : fDoc(d oc), fMapper(mapper), fAllocator(allocator), fUncompressedStream(NULL), fUncompr essedStreamEnd(NULL), fEmpty(false), fHasPutBack(false) { 908 SkPdfNativeTokenizer::SkPdfNativeTokenizer(SkPdfNativeObject* objWithStream, SkP dfAllocator* allocator, SkPdfNativeDoc* doc) : fDoc(doc), fAllocator(allocator), fUncompressedStream(NULL), fUncompressedStreamEnd(NULL), fEmpty(false), fHasPut Back(false) {
906 const unsigned char* buffer = NULL; 909 const unsigned char* buffer = NULL;
907 size_t len = 0; 910 size_t len = 0;
908 objWithStream->GetFilteredStreamRef(&buffer, &len); 911 objWithStream->GetFilteredStreamRef(&buffer, &len);
909 // TODO(edisonn): hack, find end of object 912 // TODO(edisonn): hack, find end of object
910 char* endobj = strrstrk((char*)buffer, (char*)buffer + len, "endobj"); 913 char* endobj = strrstrk((char*)buffer, (char*)buffer + len, "endobj");
911 if (endobj) { 914 if (endobj) {
912 len = endobj - (char*)buffer + strlen("endobj"); 915 len = endobj - (char*)buffer + strlen("endobj");
913 } 916 }
914 fUncompressedStreamStart = fUncompressedStream = buffer; 917 fUncompressedStreamStart = fUncompressedStream = buffer;
915 fUncompressedStreamEnd = fUncompressedStream + len; 918 fUncompressedStreamEnd = fUncompressedStream + len;
916 } 919 }
917 920
918 SkPdfNativeTokenizer::SkPdfNativeTokenizer(const unsigned char* buffer, int len, const SkPdfMapper* mapper, SkPdfAllocator* allocator, SkPdfNativeDoc* doc) : fD oc(doc), fMapper(mapper), fAllocator(allocator), fEmpty(false), fHasPutBack(fals e) { 921 SkPdfNativeTokenizer::SkPdfNativeTokenizer(const unsigned char* buffer, int len, SkPdfAllocator* allocator, SkPdfNativeDoc* doc) : fDoc(doc), fAllocator(allocat or), fEmpty(false), fHasPutBack(false) {
919 // TODO(edisonn): hack, find end of object 922 // TODO(edisonn): hack, find end of object
920 char* endobj = strrstrk((char*)buffer, (char*)buffer + len, "endobj"); 923 char* endobj = strrstrk((char*)buffer, (char*)buffer + len, "endobj");
921 if (endobj) { 924 if (endobj) {
922 len = endobj - (char*)buffer + strlen("endobj"); 925 len = endobj - (char*)buffer + strlen("endobj");
923 } 926 }
924 fUncompressedStreamStart = fUncompressedStream = buffer; 927 fUncompressedStreamStart = fUncompressedStream = buffer;
925 fUncompressedStreamEnd = fUncompressedStream + len; 928 fUncompressedStreamEnd = fUncompressedStream + len;
926 } 929 }
927 930
928 SkPdfNativeTokenizer::~SkPdfNativeTokenizer() { 931 SkPdfNativeTokenizer::~SkPdfNativeTokenizer() {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 SkPdfNativeObject* obj = fAllocator->allocObject(); 1092 SkPdfNativeObject* obj = fAllocator->allocObject();
1090 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompress edStreamEnd, obj, fAllocator, fDoc); 1093 fUncompressedStream = nextObject(0, fUncompressedStream, fUncompress edStreamEnd, obj, fAllocator, fDoc);
1091 // TODO(edisonn): perf maybe we should not expand abreviation like t his 1094 // TODO(edisonn): perf maybe we should not expand abreviation like t his
1092 inlineImage->set(inlineImageKeyAbbreviationExpand(key), 1095 inlineImage->set(inlineImageKeyAbbreviationExpand(key),
1093 inlineImageValueAbbreviationExpand(obj)); 1096 inlineImageValueAbbreviationExpand(obj));
1094 } 1097 }
1095 } 1098 }
1096 // TODO(edisonn): report end of data with inline image without an EI 1099 // TODO(edisonn): report end of data with inline image without an EI
1097 return inlineImage; 1100 return inlineImage;
1098 } 1101 }
OLDNEW
« no previous file with comments | « experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.h ('k') | gyp/pdfviewer.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698