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

Side by Side Diff: experimental/PdfViewer/SkPdfUtils.h

Issue 26613006: code cleanup (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 2 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 * 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 #ifndef SkPdfUtils_DEFINED 8 #ifndef SkPdfUtils_DEFINED
9 #define SkPdfUtils_DEFINED 9 #define SkPdfUtils_DEFINED
10 10
(...skipping 14 matching lines...) Expand all
25 kNYI_SkPdfResult, 25 kNYI_SkPdfResult,
26 kIgnoreError_SkPdfResult, 26 kIgnoreError_SkPdfResult,
27 kError_SkPdfResult, 27 kError_SkPdfResult,
28 kUnsupported_SkPdfResult, 28 kUnsupported_SkPdfResult,
29 29
30 kCount_SkPdfResult 30 kCount_SkPdfResult
31 }; 31 };
32 32
33 struct NotOwnedString { 33 struct NotOwnedString {
34 const unsigned char* fBuffer; 34 const unsigned char* fBuffer;
35 // TODO(edisonn): clean up, the last two bytes are used to signal if compres sion is used
35 size_t fBytes; 36 size_t fBytes;
36 37
37 static void init(NotOwnedString* str) { 38 static void init(NotOwnedString* str) {
38 str->fBuffer = NULL; 39 str->fBuffer = NULL;
39 str->fBytes = 0; 40 str->fBytes = 0;
40 } 41 }
41 42
42 static void init(NotOwnedString* str, const char* sz) { 43 static void init(NotOwnedString* str, const char* sz) {
43 str->fBuffer = (const unsigned char*)sz; 44 str->fBuffer = (const unsigned char*)sz;
44 str->fBytes = strlen(sz); 45 str->fBytes = strlen(sz);
45 } 46 }
46 47
47 bool equals(const char* sz) { 48 bool equals(const char* sz) {
48 return strncmp((const char*)fBuffer, sz, fBytes) == 0 && fBytes == strle n(sz); 49 return strncmp((const char*)fBuffer, sz, fBytes) == 0 && fBytes == strle n(sz);
49 50
50 } 51 }
51 }; 52 };
52 53
54 SkMatrix SkMatrixFromPdfMatrix(double array[6]);
55
53 // TODO(edisonn): hack to make code generation simpler. Alternatively we can upd ate the 56 // TODO(edisonn): hack to make code generation simpler. Alternatively we can upd ate the
54 // generate_code.py not to rely on != operator 57 // generate_code.py not to rely on != operator
55 bool operator !=(const SkString& first, const char* second); 58 bool operator !=(const SkString& first, const char* second);
56 59
57 SkMatrix SkMatrixFromPdfArray(SkPdfArray* pdfArray); 60 SkMatrix SkMatrixFromPdfArray(SkPdfArray* pdfArray);
58 61
59 SkPdfResult doType3Char(SkPdfContext* pdfContext, SkCanvas* canvas, const SkPdfN ativeObject* skobj, SkRect bBox, SkMatrix matrix, double textSize); 62 SkPdfResult doType3Char(SkPdfContext* pdfContext, SkCanvas* canvas, const SkPdfN ativeObject* skobj, SkRect bBox, SkMatrix matrix, double textSize);
60 63
61 //////////////////////////////////////////////////////////////////////////////// //////////////////// 64 //////////////////////////////////////////////////////////////////////////////// ////////////////////
62 // 65 //
63 // TRACE functions 66 // TRACE functions
64 // 67 //
65 #ifdef PDF_TRACE 68 #ifdef PDF_TRACE
66 void SkTraceMatrix(const SkMatrix& matrix, const char* sz); 69 void SkTraceMatrix(const SkMatrix& matrix, const char* sz);
67 void SkTraceRect(const SkRect& rect, const char* sz); 70 void SkTraceRect(const SkRect& rect, const char* sz);
68 #else 71 #else
69 #define SkTraceMatrix(a,b) 72 #define SkTraceMatrix(a,b)
70 #define SkTraceRect(a,b) 73 #define SkTraceRect(a,b)
71 #endif 74 #endif
72 75
76 #ifdef PDF_TRACE_TOKENIZER
77
78 static void TRACE_COMMENT(char ch) {
79 printf("%c", ch);
80 }
81
82 static void TRACE_TK(char ch) {
83 printf("%c", ch);
84 }
85
86 static void TRACE_NAME(const unsigned char* start, const unsigned char* end) {
87 while (start < end) {
88 printf("%c", *start);
89 start++;
90 }
91 printf("\n");
92 }
93
94 static void TRACE_STRING(const unsigned char* start, const unsigned char* end) {
95 while (start < end) {
96 printf("%c", *start);
97 start++;
98 }
99 printf("\n");
100 }
101
102 static void TRACE_HEXSTRING(const unsigned char* start, const unsigned char* end ) {
103 while (start < end) {
104 printf("%c", *start);
105 start++;
106 }
107 printf("\n");
108 }
109
110 #else
111 #define TRACE_COMMENT(ch)
112 #define TRACE_TK(ch)
113 #define TRACE_NAME(start,end)
114 #define TRACE_STRING(start,end)
115 #define TRACE_HEXSTRING(start,end)
116 #endif
117
73 #endif // SkPdfUtils_DEFINED 118 #endif // SkPdfUtils_DEFINED
OLDNEW
« no previous file with comments | « experimental/PdfViewer/SkPdfConfig.h ('k') | experimental/PdfViewer/pdfparser/native/SkPdfNativeDoc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698