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

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

Issue 80463005: Separate and update PDF_DIFF_TRACE_IN_PNG (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years 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 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkPdfConfig.h" 8 #include "SkPdfConfig.h"
9 #include "SkPdfDiffEncoder.h"
9 #include "SkPdfNativeObject.h" 10 #include "SkPdfNativeObject.h"
10 #include "SkPdfNativeTokenizer.h" 11 #include "SkPdfNativeTokenizer.h"
11 #include "SkPdfUtils.h" 12 #include "SkPdfUtils.h"
12 13
13 // TODO(edisonn): mac builder does not find the header ... but from headers is o k 14 // TODO(edisonn): mac builder does not find the header ... but from headers is o k
14 //#include "SkPdfStreamCommonDictionary_autogen.h" 15 //#include "SkPdfStreamCommonDictionary_autogen.h"
15 //#include "SkPdfImageDictionary_autogen.h" 16 //#include "SkPdfImageDictionary_autogen.h"
16 #include "SkPdfHeaders_autogen.h" 17 #include "SkPdfHeaders_autogen.h"
17 18
18 19
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 bool SkPdfNativeTokenizer::readTokenCore(PdfToken* token) { 934 bool SkPdfNativeTokenizer::readTokenCore(PdfToken* token) {
934 #ifdef PDF_TRACE_READ_TOKEN 935 #ifdef PDF_TRACE_READ_TOKEN
935 static int read_op = 0; 936 static int read_op = 0;
936 #endif 937 #endif
937 938
938 token->fKeyword = NULL; 939 token->fKeyword = NULL;
939 token->fObject = NULL; 940 token->fObject = NULL;
940 941
941 fUncompressedStream = skipPdfWhiteSpaces(fUncompressedStream, fUncompressedS treamEnd); 942 fUncompressedStream = skipPdfWhiteSpaces(fUncompressedStream, fUncompressedS treamEnd);
942 if (fUncompressedStream >= fUncompressedStreamEnd) { 943 if (fUncompressedStream >= fUncompressedStreamEnd) {
944 fEmpty = true;
943 return false; 945 return false;
944 } 946 }
945 947
946 SkPdfNativeObject obj; 948 SkPdfNativeObject obj;
947 fUncompressedStream = nextObject(fUncompressedStream, fUncompressedStreamEnd , &obj, fAllocator, fDoc); 949 fUncompressedStream = nextObject(fUncompressedStream, fUncompressedStreamEnd , &obj, fAllocator, fDoc);
948 // PUT_TRACK_STREAM_ARGS_EXPL2(fStreamId, fUncompressedStreamStart) 950 // PUT_TRACK_STREAM_ARGS_EXPL2(fStreamId, fUncompressedStreamStart)
949 951
950 // If it is a keyword, we will only get the pointer of the string. 952 // If it is a keyword, we will only get the pointer of the string.
951 if (obj.type() == SkPdfNativeObject::kKeyword_PdfObjectType) { 953 if (obj.type() == SkPdfNativeObject::kKeyword_PdfObjectType) {
952 token->fKeyword = obj.c_str(); 954 token->fKeyword = obj.c_str();
(...skipping 25 matching lines...) Expand all
978 SkASSERT(!fHasPutBack); 980 SkASSERT(!fHasPutBack);
979 fHasPutBack = true; 981 fHasPutBack = true;
980 fPutBack = token; 982 fPutBack = token;
981 #ifdef PDF_TRACE_READ_TOKEN 983 #ifdef PDF_TRACE_READ_TOKEN
982 printf("PUT_BACK %s %s\n", token.fType == kKeyword_TokenType ? "Keyword" : " Object", 984 printf("PUT_BACK %s %s\n", token.fType == kKeyword_TokenType ? "Keyword" : " Object",
983 token.fKeyword ? SkString(token.fKeyword, token.fKeywordLength).c_str () : 985 token.fKeyword ? SkString(token.fKeyword, token.fKeywordLength).c_str () :
984 token.fObject->toString().c_str()); 986 token.fObject->toString().c_str());
985 #endif 987 #endif
986 } 988 }
987 989
988 bool SkPdfNativeTokenizer::readToken(PdfToken* token) { 990 bool SkPdfNativeTokenizer::readToken(PdfToken* token, bool writeDiff) {
989 if (fHasPutBack) { 991 if (fHasPutBack) {
990 *token = fPutBack; 992 *token = fPutBack;
991 fHasPutBack = false; 993 fHasPutBack = false;
992 #ifdef PDF_TRACE_READ_TOKEN 994 #ifdef PDF_TRACE_READ_TOKEN
993 printf("READ_BACK %s %s\n", token->fType == kKeyword_TokenType ? "Keyword" : "Object", 995 printf("READ_BACK %s %s\n", token->fType == kKeyword_TokenType ? "Keywor d" : "Object",
994 token->fKeyword ? SkString(token->fKeyword, token->fKeywordLength).c_ str() : 996 token->fKeyword ? SkString(token->fKeyword, token->fKeywordLength ).c_str() :
995 token->fObject->toString().c_str()); 997 token->fObject->toString().c_str());
996 #endif 998 #endif
999 if (writeDiff) {
1000 SkPdfDiffEncoder::WriteToFile(token);
1001 }
997 return true; 1002 return true;
998 } 1003 }
999 1004
1000 if (fEmpty) { 1005 if (fEmpty) {
1001 #ifdef PDF_TRACE_READ_TOKEN 1006 #ifdef PDF_TRACE_READ_TOKEN
1002 printf("EMPTY TOKENIZER\n"); 1007 printf("EMPTY TOKENIZER\n");
1003 #endif 1008 #endif
1004 return false; 1009 return false;
1005 } 1010 }
1006 1011
1007 return readTokenCore(token); 1012 const bool result = readTokenCore(token);
1013 if (result && writeDiff) {
1014 SkPdfDiffEncoder::WriteToFile(token);
1015 }
1016 return result;
1008 } 1017 }
1009 1018
1010 #define DECLARE_PDF_NAME(longName) SkPdfName longName((char*)#longName) 1019 #define DECLARE_PDF_NAME(longName) SkPdfName longName((char*)#longName)
1011 1020
1012 // keys 1021 // keys
1013 DECLARE_PDF_NAME(BitsPerComponent); 1022 DECLARE_PDF_NAME(BitsPerComponent);
1014 DECLARE_PDF_NAME(ColorSpace); 1023 DECLARE_PDF_NAME(ColorSpace);
1015 DECLARE_PDF_NAME(Decode); 1024 DECLARE_PDF_NAME(Decode);
1016 DECLARE_PDF_NAME(DecodeParms); 1025 DECLARE_PDF_NAME(DecodeParms);
1017 DECLARE_PDF_NAME(Filter); 1026 DECLARE_PDF_NAME(Filter);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 fAllocator, fDoc); 1116 fAllocator, fDoc);
1108 // PUT_TRACK_STREAM_ARGS_EXPL2(fStreamId, fUncompressedStreamStart) s 1117 // PUT_TRACK_STREAM_ARGS_EXPL2(fStreamId, fUncompressedStreamStart) s
1109 // TODO(edisonn): perf maybe we should not expand abBreviation like this 1118 // TODO(edisonn): perf maybe we should not expand abBreviation like this
1110 inlineImage->set(inlineImageKeyAbbreviationExpand(key), 1119 inlineImage->set(inlineImageKeyAbbreviationExpand(key),
1111 inlineImageValueAbbreviationExpand(obj)); 1120 inlineImageValueAbbreviationExpand(obj));
1112 } 1121 }
1113 } 1122 }
1114 // TODO(edisonn): report end of data with inline image without an EI 1123 // TODO(edisonn): report end of data with inline image without an EI
1115 return inlineImage; 1124 return inlineImage;
1116 } 1125 }
OLDNEW
« no previous file with comments | « experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.h ('k') | experimental/PdfViewer/src/SkPdfContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698