edisonn@google.com | cf2cfa1 | 2013-08-21 16:31:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkPdfNativeObject_DEFINED |
| 9 | #define SkPdfNativeObject_DEFINED |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 10 | |
| 11 | #include <stdint.h> |
| 12 | #include <string.h> |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 13 | |
| 14 | #include "SkMatrix.h" |
| 15 | #include "SkPdfConfig.h" |
| 16 | #include "SkPdfNativeTokenizer.h" |
| 17 | #include "SkPdfNYI.h" |
| 18 | #include "SkPdfUtils.h" |
| 19 | #include "SkRect.h" |
edisonn@google.com | 063d707 | 2013-08-16 15:05:08 +0000 | [diff] [blame] | 20 | #include "SkString.h" |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 21 | #include "SkTDArray.h" |
| 22 | #include "SkTDict.h" |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 23 | |
| 24 | class SkPdfDictionary; |
| 25 | class SkPdfStream; |
| 26 | class SkPdfAllocator; |
| 27 | |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 28 | // TODO(edisonn): remove these constants and clean up the code. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 29 | #define kFilteredStreamBit 0 |
| 30 | #define kUnfilteredStreamBit 1 |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 31 | #define kOwnedStreamBit 2 |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 32 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 33 | class SkPdfNativeObject { |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 34 | public: |
| 35 | enum ObjectType { |
edisonn@google.com | af54a51 | 2013-09-13 19:33:42 +0000 | [diff] [blame] | 36 | // The type will have only one of these values, but for error reporting, we make it an enum |
| 37 | // so it can easily report that something was expected to be one of a few types |
| 38 | kInvalid_PdfObjectType = 1 << 1, |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 39 | |
edisonn@google.com | af54a51 | 2013-09-13 19:33:42 +0000 | [diff] [blame] | 40 | kBoolean_PdfObjectType = 1 << 2, |
| 41 | kInteger_PdfObjectType = 1 << 3, |
| 42 | kReal_PdfObjectType = 1 << 4, |
| 43 | _kNumber_PdfObjectType = kInteger_PdfObjectType | kReal_PdfObjectType, |
| 44 | kString_PdfObjectType = 1 << 5, |
| 45 | kHexString_PdfObjectType = 1 << 6, |
| 46 | _kAnyString_PdfObjectType = kString_PdfObjectType | kHexString_PdfObjectType, |
| 47 | kName_PdfObjectType = 1 << 7, |
| 48 | kKeyword_PdfObjectType = 1 << 8, |
| 49 | _kStream_PdfObjectType = 1 << 9, // attached to a Dictionary, do not use |
| 50 | kArray_PdfObjectType = 1 << 10, |
| 51 | kDictionary_PdfObjectType = 1 << 11, |
| 52 | kNull_PdfObjectType = 1 << 12, |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 53 | |
edisonn@google.com | af54a51 | 2013-09-13 19:33:42 +0000 | [diff] [blame] | 54 | kReference_PdfObjectType = 1 << 13, |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 55 | |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 56 | kUndefined_PdfObjectType = 1 << 14, // per 1.4 spec, if the same key appear twice in the |
| 57 | // dictionary, the value is undefined. |
edisonn@google.com | af54a51 | 2013-09-13 19:33:42 +0000 | [diff] [blame] | 58 | |
| 59 | _kObject_PdfObjectType = -1, |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
edisonn@google.com | b0145ce | 2013-08-05 16:23:23 +0000 | [diff] [blame] | 62 | enum DataType { |
| 63 | kEmpty_Data, |
| 64 | kFont_Data, |
| 65 | kBitmap_Data, |
| 66 | }; |
| 67 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 68 | private: |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 69 | // TODO(edisonn): assert reset operations while in rendering! The objects should be reset |
| 70 | // only when rendering is completed. |
edisonn@google.com | 063d707 | 2013-08-16 15:05:08 +0000 | [diff] [blame] | 71 | uint32_t fInRendering : 1; |
| 72 | uint32_t fUnused : 31; |
| 73 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 74 | struct Reference { |
| 75 | unsigned int fId; |
| 76 | unsigned int fGen; |
| 77 | }; |
| 78 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 79 | ObjectType fObjectType; |
| 80 | |
| 81 | union { |
| 82 | bool fBooleanValue; |
| 83 | int64_t fIntegerValue; |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 84 | // TODO(edisonn): double, float, SkScalar? |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 85 | double fRealValue; |
| 86 | NotOwnedString fStr; |
| 87 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 88 | SkTDArray<SkPdfNativeObject*>* fArray; |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 89 | Reference fRef; |
| 90 | }; |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 91 | SkTDict<SkPdfNativeObject*>* fMap; |
edisonn@google.com | b0145ce | 2013-08-05 16:23:23 +0000 | [diff] [blame] | 92 | |
| 93 | // TODO(edisonn): rename data with cache |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 94 | void* fData; |
edisonn@google.com | b0145ce | 2013-08-05 16:23:23 +0000 | [diff] [blame] | 95 | DataType fDataType; |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 96 | |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 97 | // Keep this the last entries |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 98 | #ifdef PDF_TRACK_OBJECT_USAGE |
| 99 | mutable bool fUsed; |
| 100 | #endif // PDF_TRACK_OBJECT_USAGE |
| 101 | |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 102 | #ifdef PDF_TRACK_STREAM_OFFSETS |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 103 | public: |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 104 | int fStreamId; |
| 105 | int fOffsetStart; |
| 106 | int fOffsetEnd; |
| 107 | #endif // PDF_TRACK_STREAM_OFFSETS |
| 108 | |
| 109 | public: |
| 110 | |
| 111 | #ifdef PDF_TRACK_STREAM_OFFSETS |
| 112 | int streamId() const { return fStreamId; } |
| 113 | int offsetStart() const { return fOffsetStart; } |
| 114 | int offsetEnd() const { return fOffsetEnd; } |
| 115 | #endif // PDF_TRACK_STREAM_OFFSETS |
| 116 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 117 | |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 118 | SkPdfNativeObject() : fInRendering(0) |
| 119 | , fObjectType(kInvalid_PdfObjectType) |
| 120 | , fMap(NULL) |
| 121 | , fData(NULL) |
| 122 | , fDataType(kEmpty_Data) |
| 123 | #ifdef PDF_TRACK_OBJECT_USAGE |
| 124 | , fUsed(false) |
| 125 | #endif // PDF_TRACK_OBJECT_USAGE |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 126 | |
| 127 | #ifdef PDF_TRACK_STREAM_OFFSETS |
| 128 | , fStreamId(-1) |
| 129 | , fOffsetStart(-1) |
| 130 | , fOffsetEnd(-1) |
| 131 | #endif // PDF_TRACK_STREAM_OFFSETS |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 132 | {} |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 133 | |
edisonn@google.com | 063d707 | 2013-08-16 15:05:08 +0000 | [diff] [blame] | 134 | bool inRendering() const { return fInRendering != 0; } |
| 135 | void startRendering() {fInRendering = 1;} |
| 136 | void doneRendering() {fInRendering = 0;} |
edisonn@google.com | b0145ce | 2013-08-05 16:23:23 +0000 | [diff] [blame] | 137 | |
| 138 | inline bool hasData(DataType type) { |
| 139 | return type == fDataType; |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 140 | } |
| 141 | |
edisonn@google.com | b0145ce | 2013-08-05 16:23:23 +0000 | [diff] [blame] | 142 | inline void* data(DataType type) { |
| 143 | return type == fDataType ? fData : NULL; |
| 144 | } |
| 145 | |
| 146 | inline void setData(void* data, DataType type) { |
| 147 | releaseData(); |
| 148 | fDataType = type; |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 149 | fData = data; |
| 150 | } |
| 151 | |
edisonn@google.com | b0145ce | 2013-08-05 16:23:23 +0000 | [diff] [blame] | 152 | void releaseData(); |
| 153 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 154 | // ~SkPdfNativeObject() { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 155 | // //reset(); must be called manually! Normally, will be called by allocator destructor. |
edisonn@google.com | 222382b | 2013-07-10 22:33:10 +0000 | [diff] [blame] | 156 | // } |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 157 | |
| 158 | void reset() { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 159 | SkPdfMarkObjectUnused(); |
| 160 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 161 | switch (fObjectType) { |
| 162 | case kArray_PdfObjectType: |
| 163 | delete fArray; |
| 164 | break; |
| 165 | |
| 166 | case kDictionary_PdfObjectType: |
| 167 | delete fMap; |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 168 | if (isStreamOwned()) { |
| 169 | delete[] fStr.fBuffer; |
| 170 | fStr.fBuffer = NULL; |
| 171 | fStr.fBytes = 0; |
| 172 | } |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 173 | break; |
| 174 | |
| 175 | default: |
| 176 | break; |
| 177 | } |
| 178 | fObjectType = kInvalid_PdfObjectType; |
edisonn@google.com | b0145ce | 2013-08-05 16:23:23 +0000 | [diff] [blame] | 179 | releaseData(); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 180 | } |
| 181 | |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 182 | ObjectType type() { |
| 183 | SkPdfMarkObjectUsed(); |
| 184 | |
| 185 | return fObjectType; |
| 186 | } |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 187 | |
| 188 | const char* c_str() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 189 | SkPdfMarkObjectUsed(); |
| 190 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 191 | switch (fObjectType) { |
| 192 | case kString_PdfObjectType: |
| 193 | case kHexString_PdfObjectType: |
| 194 | case kKeyword_PdfObjectType: |
edisonn@google.com | 276fed9 | 2013-08-01 21:20:47 +0000 | [diff] [blame] | 195 | case kName_PdfObjectType: |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 196 | return (const char*)fStr.fBuffer; |
| 197 | |
| 198 | default: |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 199 | // TODO(edisonn): report/warning/assert? |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 200 | return NULL; |
| 201 | } |
| 202 | } |
| 203 | |
edisonn@google.com | e878e72 | 2013-07-29 19:10:58 +0000 | [diff] [blame] | 204 | size_t lenstr() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 205 | SkPdfMarkObjectUsed(); |
| 206 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 207 | switch (fObjectType) { |
| 208 | case kString_PdfObjectType: |
| 209 | case kHexString_PdfObjectType: |
| 210 | case kKeyword_PdfObjectType: |
edisonn@google.com | 276fed9 | 2013-08-01 21:20:47 +0000 | [diff] [blame] | 211 | case kName_PdfObjectType: |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 212 | return fStr.fBytes; |
| 213 | |
| 214 | default: |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 215 | // TODO(edisonn): report/warning/assert? |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 216 | return 0; |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | |
| 221 | // TODO(edisonn): NYI |
| 222 | SkPdfDate& dateValue() const { |
| 223 | static SkPdfDate nyi; |
| 224 | return nyi; |
| 225 | } |
| 226 | |
| 227 | // TODO(edisonn): NYI |
| 228 | SkPdfFunction& functionValue() const { |
| 229 | static SkPdfFunction nyi; |
| 230 | return nyi; |
| 231 | } |
| 232 | |
| 233 | // TODO(edisonn): NYI |
| 234 | SkPdfFileSpec& fileSpecValue() const { |
| 235 | static SkPdfFileSpec nyi; |
| 236 | return nyi; |
| 237 | } |
| 238 | |
| 239 | // TODO(edisonn): NYI |
| 240 | SkPdfTree& treeValue() const { |
| 241 | static SkPdfTree nyi; |
| 242 | return nyi; |
| 243 | } |
| 244 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 245 | static void makeBoolean(bool value, SkPdfNativeObject* obj) { |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 246 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 247 | SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); |
| 248 | |
| 249 | obj->fObjectType = kBoolean_PdfObjectType; |
| 250 | obj->fBooleanValue = value; |
| 251 | } |
| 252 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 253 | static SkPdfNativeObject makeBoolean(bool value) { |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 254 | SkPdfNativeObject obj; |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 255 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 256 | obj.fObjectType = kBoolean_PdfObjectType; |
| 257 | obj.fBooleanValue = value; |
| 258 | return obj; |
| 259 | } |
| 260 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 261 | static void makeInteger(int64_t value, SkPdfNativeObject* obj) { |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 262 | SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); |
| 263 | |
| 264 | obj->fObjectType = kInteger_PdfObjectType; |
| 265 | obj->fIntegerValue = value; |
| 266 | } |
| 267 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 268 | static void makeReal(double value, SkPdfNativeObject* obj) { |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 269 | SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); |
| 270 | |
| 271 | obj->fObjectType = kReal_PdfObjectType; |
| 272 | obj->fRealValue = value; |
| 273 | } |
| 274 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 275 | static void makeNull(SkPdfNativeObject* obj) { |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 276 | SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); |
| 277 | |
| 278 | obj->fObjectType = kNull_PdfObjectType; |
| 279 | } |
| 280 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 281 | static SkPdfNativeObject makeNull() { |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 282 | SkPdfNativeObject obj; |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 283 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 284 | obj.fObjectType = kNull_PdfObjectType; |
| 285 | return obj; |
| 286 | } |
| 287 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 288 | static SkPdfNativeObject kNull; |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 289 | |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 290 | static void makeNumeric(const unsigned char* start, const unsigned char* end, |
| 291 | SkPdfNativeObject* obj) { |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 292 | SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); |
| 293 | |
| 294 | // TODO(edisonn): NYI properly |
| 295 | // if has dot (impl), or exceeds max int, is real, otherwise is int |
| 296 | bool isInt = true; |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 297 | for (const unsigned char* current = start; current < end; current++) { |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 298 | if (*current == '.') { |
| 299 | isInt = false; |
| 300 | break; |
| 301 | } |
| 302 | // TODO(edisonn): report parse issue with numbers like "24asdasd123" |
| 303 | } |
| 304 | if (isInt) { |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 305 | makeInteger(atol((const char*)start), obj); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 306 | } else { |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 307 | makeReal(atof((const char*)start), obj); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 308 | } |
| 309 | } |
| 310 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 311 | static void makeReference(unsigned int id, unsigned int gen, SkPdfNativeObject* obj) { |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 312 | SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); |
| 313 | |
| 314 | obj->fObjectType = kReference_PdfObjectType; |
| 315 | obj->fRef.fId = id; |
| 316 | obj->fRef.fGen = gen; |
| 317 | } |
| 318 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 319 | static void resetAndMakeReference(unsigned int id, unsigned int gen, SkPdfNativeObject* obj) { |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 320 | obj->reset(); |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 321 | makeReference(id, gen, obj); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 325 | static void makeString(const unsigned char* start, SkPdfNativeObject* obj) { |
| 326 | makeStringCore(start, strlen((const char*)start), obj, kString_PdfObjectType); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 327 | } |
| 328 | |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 329 | static void makeString(const unsigned char* start, const unsigned char* end, |
| 330 | SkPdfNativeObject* obj) { |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 331 | makeStringCore(start, end - start, obj, kString_PdfObjectType); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 332 | } |
| 333 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 334 | static void makeString(const unsigned char* start, size_t bytes, SkPdfNativeObject* obj) { |
| 335 | makeStringCore(start, bytes, obj, kString_PdfObjectType); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 339 | static void makeHexString(const unsigned char* start, SkPdfNativeObject* obj) { |
| 340 | makeStringCore(start, strlen((const char*)start), obj, kHexString_PdfObjectType); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 341 | } |
| 342 | |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 343 | static void makeHexString(const unsigned char* start, const unsigned char* end, |
| 344 | SkPdfNativeObject* obj) { |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 345 | makeStringCore(start, end - start, obj, kHexString_PdfObjectType); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 346 | } |
| 347 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 348 | static void makeHexString(const unsigned char* start, size_t bytes, SkPdfNativeObject* obj) { |
| 349 | makeStringCore(start, bytes, obj, kHexString_PdfObjectType); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 353 | static void makeName(const unsigned char* start, SkPdfNativeObject* obj) { |
| 354 | makeStringCore(start, strlen((const char*)start), obj, kName_PdfObjectType); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 355 | } |
| 356 | |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 357 | static void makeName(const unsigned char* start, const unsigned char* end, |
| 358 | SkPdfNativeObject* obj) { |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 359 | makeStringCore(start, end - start, obj, kName_PdfObjectType); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 360 | } |
| 361 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 362 | static void makeName(const unsigned char* start, size_t bytes, SkPdfNativeObject* obj) { |
| 363 | makeStringCore(start, bytes, obj, kName_PdfObjectType); |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 367 | static void makeKeyword(const unsigned char* start, SkPdfNativeObject* obj) { |
| 368 | makeStringCore(start, strlen((const char*)start), obj, kKeyword_PdfObjectType); |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 369 | } |
| 370 | |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 371 | static void makeKeyword(const unsigned char* start, const unsigned char* end, |
| 372 | SkPdfNativeObject* obj) { |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 373 | makeStringCore(start, end - start, obj, kKeyword_PdfObjectType); |
edisonn@google.com | bca421b | 2013-09-05 20:00:21 +0000 | [diff] [blame] | 374 | } |
| 375 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 376 | static void makeKeyword(const unsigned char* start, size_t bytes, SkPdfNativeObject* obj) { |
| 377 | makeStringCore(start, bytes, obj, kKeyword_PdfObjectType); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 378 | } |
| 379 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 380 | static void makeEmptyArray(SkPdfNativeObject* obj) { |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 381 | SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); |
| 382 | |
| 383 | obj->fObjectType = kArray_PdfObjectType; |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 384 | obj->fArray = new SkTDArray<SkPdfNativeObject*>(); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 385 | } |
| 386 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 387 | bool appendInArray(SkPdfNativeObject* obj) { |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 388 | SkASSERT(fObjectType == kArray_PdfObjectType); |
| 389 | if (fObjectType != kArray_PdfObjectType) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 390 | // TODO(edisonn): report/warning/assert? |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 391 | return false; |
| 392 | } |
| 393 | |
| 394 | fArray->push(obj); |
| 395 | return true; |
| 396 | } |
| 397 | |
| 398 | size_t size() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 399 | SkPdfMarkObjectUsed(); |
| 400 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 401 | SkASSERT(fObjectType == kArray_PdfObjectType); |
| 402 | |
| 403 | return fArray->count(); |
| 404 | } |
| 405 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 406 | SkPdfNativeObject* objAtAIndex(int i) { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 407 | SkPdfMarkObjectUsed(); |
| 408 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 409 | SkASSERT(fObjectType == kArray_PdfObjectType); |
| 410 | |
| 411 | return (*fArray)[i]; |
| 412 | } |
| 413 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 414 | SkPdfNativeObject* removeLastInArray() { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 415 | SkPdfMarkObjectUsed(); |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 416 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 417 | SkASSERT(fObjectType == kArray_PdfObjectType); |
| 418 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 419 | SkPdfNativeObject* ret = NULL; |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 420 | fArray->pop(&ret); |
| 421 | |
| 422 | return ret; |
| 423 | } |
| 424 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 425 | const SkPdfNativeObject* objAtAIndex(int i) const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 426 | SkPdfMarkObjectUsed(); |
| 427 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 428 | SkASSERT(fObjectType == kArray_PdfObjectType); |
| 429 | |
| 430 | return (*fArray)[i]; |
| 431 | } |
| 432 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 433 | SkPdfNativeObject* operator[](int i) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 434 | SkPdfMarkObjectUsed(); |
| 435 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 436 | SkASSERT(fObjectType == kArray_PdfObjectType); |
| 437 | |
| 438 | return (*fArray)[i]; |
| 439 | } |
| 440 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 441 | const SkPdfNativeObject* operator[](int i) const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 442 | SkPdfMarkObjectUsed(); |
| 443 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 444 | SkASSERT(fObjectType == kArray_PdfObjectType); |
| 445 | |
| 446 | return (*fArray)[i]; |
| 447 | } |
| 448 | |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 449 | static void makeEmptyDictionary(SkPdfNativeObject* obj) { |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 450 | SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); |
| 451 | |
| 452 | obj->fObjectType = kDictionary_PdfObjectType; |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 453 | obj->fMap = new SkTDict<SkPdfNativeObject*>(1); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 454 | obj->fStr.fBuffer = NULL; |
| 455 | obj->fStr.fBytes = 0; |
| 456 | } |
| 457 | |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 458 | // TODO(edisonn): perf: get all the possible names from spec, and compute a hash function |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 459 | // that would create no overlaps in the same dictionary |
| 460 | // or build a tree of chars that when followed goes to a unique id/index/hash |
| 461 | // TODO(edisonn): generate constants like kDictFoo, kNameDict_name |
| 462 | // which will be used in code |
| 463 | // add function SkPdfFastNameKey key(const char* key); |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 464 | // TODO(edisonn): setting the same key twice, will make the value undefined! |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 465 | bool set(const SkPdfNativeObject* key, SkPdfNativeObject* value) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 466 | SkPdfMarkObjectUsed(); |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 467 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 468 | SkASSERT(fObjectType == kDictionary_PdfObjectType); |
| 469 | SkASSERT(key->fObjectType == kName_PdfObjectType); |
| 470 | |
| 471 | if (key->fObjectType != kName_PdfObjectType || fObjectType != kDictionary_PdfObjectType) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 472 | // TODO(edisonn): report/warn/assert? |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 473 | return false; |
| 474 | } |
| 475 | |
edisonn@google.com | d761e32 | 2013-07-22 17:29:43 +0000 | [diff] [blame] | 476 | return set(key->fStr.fBuffer, key->fStr.fBytes, value); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 477 | } |
| 478 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 479 | bool set(const char* key, SkPdfNativeObject* value) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 480 | SkPdfMarkObjectUsed(); |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 481 | |
edisonn@google.com | d761e32 | 2013-07-22 17:29:43 +0000 | [diff] [blame] | 482 | return set((const unsigned char*)key, strlen(key), value); |
| 483 | } |
| 484 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 485 | bool set(const unsigned char* key, size_t len, SkPdfNativeObject* value) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 486 | SkPdfMarkObjectUsed(); |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 487 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 488 | SkASSERT(fObjectType == kDictionary_PdfObjectType); |
| 489 | |
| 490 | if (fObjectType != kDictionary_PdfObjectType) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 491 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 492 | return false; |
| 493 | } |
| 494 | |
edisonn@google.com | d761e32 | 2013-07-22 17:29:43 +0000 | [diff] [blame] | 495 | return fMap->set((const char*)key, len, value); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 496 | } |
| 497 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 498 | SkPdfNativeObject* get(const SkPdfNativeObject* key) { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 499 | SkPdfMarkObjectUsed(); |
| 500 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 501 | SkASSERT(fObjectType == kDictionary_PdfObjectType); |
| 502 | SkASSERT(key->fObjectType == kName_PdfObjectType); |
| 503 | |
| 504 | if (key->fObjectType != kName_PdfObjectType || fObjectType != kDictionary_PdfObjectType) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 505 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | 3fc4826 | 2013-07-22 15:29:55 +0000 | [diff] [blame] | 506 | return NULL; |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 507 | } |
| 508 | |
edisonn@google.com | d761e32 | 2013-07-22 17:29:43 +0000 | [diff] [blame] | 509 | return get(key->fStr.fBuffer, key->fStr.fBytes); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 510 | } |
| 511 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 512 | SkPdfNativeObject* get(const char* key) { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 513 | SkPdfMarkObjectUsed(); |
| 514 | |
edisonn@google.com | d761e32 | 2013-07-22 17:29:43 +0000 | [diff] [blame] | 515 | return get((const unsigned char*)key, strlen(key)); |
| 516 | } |
| 517 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 518 | SkPdfNativeObject* get(const unsigned char* key, size_t len) { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 519 | SkPdfMarkObjectUsed(); |
| 520 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 521 | SkASSERT(fObjectType == kDictionary_PdfObjectType); |
| 522 | SkASSERT(key); |
| 523 | if (fObjectType != kDictionary_PdfObjectType) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 524 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 525 | return NULL; |
| 526 | } |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 527 | SkPdfNativeObject* ret = NULL; |
edisonn@google.com | d761e32 | 2013-07-22 17:29:43 +0000 | [diff] [blame] | 528 | fMap->find((const char*)key, len, &ret); |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 529 | |
| 530 | #ifdef PDF_TRACE |
| 531 | SkString _key; |
| 532 | _key.append((const char*)key, len); |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 533 | printf("\nget(/%s) = %s\n", _key.c_str(), |
| 534 | ret ? ret->toString(0, len + 9).c_str() : "_NOT_FOUND"); |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 535 | #endif |
| 536 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 537 | return ret; |
| 538 | } |
| 539 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 540 | const SkPdfNativeObject* get(const SkPdfNativeObject* key) const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 541 | SkPdfMarkObjectUsed(); |
| 542 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 543 | SkASSERT(fObjectType == kDictionary_PdfObjectType); |
| 544 | SkASSERT(key->fObjectType == kName_PdfObjectType); |
| 545 | |
| 546 | if (key->fObjectType != kName_PdfObjectType || fObjectType != kDictionary_PdfObjectType) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 547 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | 3fc4826 | 2013-07-22 15:29:55 +0000 | [diff] [blame] | 548 | return NULL; |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 549 | } |
| 550 | |
edisonn@google.com | d761e32 | 2013-07-22 17:29:43 +0000 | [diff] [blame] | 551 | return get(key->fStr.fBuffer, key->fStr.fBytes); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 552 | } |
| 553 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 554 | const SkPdfNativeObject* get(const char* key) const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 555 | SkPdfMarkObjectUsed(); |
| 556 | |
edisonn@google.com | d761e32 | 2013-07-22 17:29:43 +0000 | [diff] [blame] | 557 | return get((const unsigned char*)key, strlen(key)); |
| 558 | } |
| 559 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 560 | const SkPdfNativeObject* get(const unsigned char* key, size_t len) const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 561 | SkPdfMarkObjectUsed(); |
| 562 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 563 | SkASSERT(fObjectType == kDictionary_PdfObjectType); |
| 564 | SkASSERT(key); |
| 565 | if (fObjectType != kDictionary_PdfObjectType) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 566 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 567 | return NULL; |
| 568 | } |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 569 | SkPdfNativeObject* ret = NULL; |
edisonn@google.com | d761e32 | 2013-07-22 17:29:43 +0000 | [diff] [blame] | 570 | fMap->find((const char*)key, len, &ret); |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 571 | |
| 572 | #ifdef PDF_TRACE |
| 573 | SkString _key; |
| 574 | _key.append((const char*)key, len); |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 575 | printf("\nget(/%s) = %s\n", _key.c_str(), |
| 576 | ret ? ret->toString(0, len + 9).c_str() : "_NOT_FOUND"); |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 577 | #endif |
| 578 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 579 | return ret; |
| 580 | } |
| 581 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 582 | const SkPdfNativeObject* get(const char* key, const char* abr) const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 583 | SkPdfMarkObjectUsed(); |
| 584 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 585 | const SkPdfNativeObject* ret = get(key); |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 586 | // TODO(edisonn): remove || *abr == '\0' and pass NULL in the _autogen files instead. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 587 | if (ret != NULL || abr == NULL || *abr == '\0') { |
| 588 | return ret; |
| 589 | } |
| 590 | return get(abr); |
| 591 | } |
| 592 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 593 | SkPdfNativeObject* get(const char* key, const char* abr) { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 594 | SkPdfMarkObjectUsed(); |
| 595 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 596 | SkPdfNativeObject* ret = get(key); |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 597 | // TODO(edisonn): remove || *abr == '\0' and pass NULL in the _autogen files instead. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 598 | if (ret != NULL || abr == NULL || *abr == '\0') { |
| 599 | return ret; |
| 600 | } |
| 601 | return get(abr); |
| 602 | } |
| 603 | |
| 604 | SkPdfDictionary* asDictionary() { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 605 | SkPdfMarkObjectUsed(); |
| 606 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 607 | SkASSERT(isDictionary()); |
| 608 | if (!isDictionary()) { |
| 609 | return NULL; |
| 610 | } |
| 611 | return (SkPdfDictionary*) this; |
| 612 | } |
| 613 | |
| 614 | const SkPdfDictionary* asDictionary() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 615 | SkPdfMarkObjectUsed(); |
| 616 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 617 | SkASSERT(isDictionary()); |
| 618 | if (!isDictionary()) { |
| 619 | return NULL; |
| 620 | } |
| 621 | return (SkPdfDictionary*) this; |
| 622 | } |
| 623 | |
| 624 | |
| 625 | bool isReference() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 626 | SkPdfMarkObjectUsed(); |
| 627 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 628 | return fObjectType == kReference_PdfObjectType; |
| 629 | } |
| 630 | |
| 631 | bool isBoolean() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 632 | SkPdfMarkObjectUsed(); |
| 633 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 634 | return fObjectType == kBoolean_PdfObjectType; |
| 635 | } |
| 636 | |
| 637 | bool isInteger() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 638 | SkPdfMarkObjectUsed(); |
| 639 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 640 | return fObjectType == kInteger_PdfObjectType; |
| 641 | } |
| 642 | private: |
| 643 | bool isReal() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 644 | SkPdfMarkObjectUsed(); |
| 645 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 646 | return fObjectType == kReal_PdfObjectType; |
| 647 | } |
| 648 | public: |
| 649 | bool isNumber() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 650 | SkPdfMarkObjectUsed(); |
| 651 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 652 | return fObjectType == kInteger_PdfObjectType || fObjectType == kReal_PdfObjectType; |
| 653 | } |
| 654 | |
| 655 | bool isKeywordReference() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 656 | SkPdfMarkObjectUsed(); |
| 657 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 658 | return fObjectType == kKeyword_PdfObjectType && fStr.fBytes == 1 && fStr.fBuffer[0] == 'R'; |
| 659 | } |
| 660 | |
| 661 | bool isKeyword() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 662 | SkPdfMarkObjectUsed(); |
| 663 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 664 | return fObjectType == kKeyword_PdfObjectType; |
| 665 | } |
| 666 | |
edisonn@google.com | 4ef4bed | 2013-07-29 22:14:45 +0000 | [diff] [blame] | 667 | bool isKeyword(const char* keyword) const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 668 | SkPdfMarkObjectUsed(); |
| 669 | |
edisonn@google.com | 4ef4bed | 2013-07-29 22:14:45 +0000 | [diff] [blame] | 670 | if (!isKeyword()) { |
| 671 | return false; |
| 672 | } |
| 673 | |
| 674 | if (strlen(keyword) != fStr.fBytes) { |
| 675 | return false; |
| 676 | } |
| 677 | |
| 678 | if (strncmp(keyword, (const char*)fStr.fBuffer, fStr.fBytes) != 0) { |
| 679 | return false; |
| 680 | } |
| 681 | |
| 682 | return true; |
| 683 | } |
| 684 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 685 | bool isName() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 686 | SkPdfMarkObjectUsed(); |
| 687 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 688 | return fObjectType == kName_PdfObjectType; |
| 689 | } |
| 690 | |
edisonn@google.com | 78b38b1 | 2013-07-15 18:20:58 +0000 | [diff] [blame] | 691 | bool isName(const char* name) const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 692 | SkPdfMarkObjectUsed(); |
| 693 | |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 694 | return fObjectType == kName_PdfObjectType && |
| 695 | fStr.fBytes == strlen(name) && |
| 696 | strncmp((const char*)fStr.fBuffer, name, fStr.fBytes) == 0; |
edisonn@google.com | 78b38b1 | 2013-07-15 18:20:58 +0000 | [diff] [blame] | 697 | } |
| 698 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 699 | bool isArray() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 700 | SkPdfMarkObjectUsed(); |
| 701 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 702 | return fObjectType == kArray_PdfObjectType; |
| 703 | } |
| 704 | |
| 705 | bool isDate() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 706 | SkPdfMarkObjectUsed(); |
| 707 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 708 | return fObjectType == kString_PdfObjectType || fObjectType == kHexString_PdfObjectType; |
| 709 | } |
| 710 | |
| 711 | bool isDictionary() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 712 | SkPdfMarkObjectUsed(); |
| 713 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 714 | return fObjectType == kDictionary_PdfObjectType; |
| 715 | } |
| 716 | |
| 717 | bool isFunction() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 718 | SkPdfMarkObjectUsed(); |
| 719 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 720 | return false; // NYI |
| 721 | } |
| 722 | |
| 723 | bool isRectangle() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 724 | SkPdfMarkObjectUsed(); |
| 725 | |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 726 | // TODO(edisonn): add also that each of these 4 objects are numbers. |
| 727 | return fObjectType == kArray_PdfObjectType && fArray->count() == 4; |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | // TODO(edisonn): has stream .. or is stream ... TBD |
| 731 | bool hasStream() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 732 | SkPdfMarkObjectUsed(); |
| 733 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 734 | return isDictionary() && fStr.fBuffer != NULL; |
| 735 | } |
| 736 | |
| 737 | // TODO(edisonn): has stream .. or is stream ... TBD |
| 738 | const SkPdfStream* getStream() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 739 | SkPdfMarkObjectUsed(); |
| 740 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 741 | return hasStream() ? (const SkPdfStream*)this : NULL; |
| 742 | } |
| 743 | |
| 744 | SkPdfStream* getStream() { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 745 | SkPdfMarkObjectUsed(); |
| 746 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 747 | return hasStream() ? (SkPdfStream*)this : NULL; |
| 748 | } |
| 749 | |
| 750 | bool isAnyString() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 751 | SkPdfMarkObjectUsed(); |
| 752 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 753 | return fObjectType == kString_PdfObjectType || fObjectType == kHexString_PdfObjectType; |
| 754 | } |
| 755 | |
edisonn@google.com | b0145ce | 2013-08-05 16:23:23 +0000 | [diff] [blame] | 756 | bool isHexString() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 757 | SkPdfMarkObjectUsed(); |
| 758 | |
edisonn@google.com | b0145ce | 2013-08-05 16:23:23 +0000 | [diff] [blame] | 759 | return fObjectType == kHexString_PdfObjectType; |
| 760 | } |
| 761 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 762 | bool isMatrix() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 763 | SkPdfMarkObjectUsed(); |
| 764 | |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 765 | // TODO(edisonn): add also that each of these 6 objects are numbers. |
| 766 | return fObjectType == kArray_PdfObjectType && fArray->count() == 6; |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | inline int64_t intValue() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 770 | SkPdfMarkObjectUsed(); |
| 771 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 772 | SkASSERT(fObjectType == kInteger_PdfObjectType); |
| 773 | |
| 774 | if (fObjectType != kInteger_PdfObjectType) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 775 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 776 | return 0; |
| 777 | } |
| 778 | return fIntegerValue; |
| 779 | } |
| 780 | private: |
| 781 | inline double realValue() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 782 | SkPdfMarkObjectUsed(); |
| 783 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 784 | SkASSERT(fObjectType == kReal_PdfObjectType); |
| 785 | |
| 786 | if (fObjectType != kReal_PdfObjectType) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 787 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 788 | return 0; |
| 789 | } |
| 790 | return fRealValue; |
| 791 | } |
| 792 | public: |
| 793 | inline double numberValue() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 794 | SkPdfMarkObjectUsed(); |
| 795 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 796 | SkASSERT(isNumber()); |
| 797 | |
| 798 | if (!isNumber()) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 799 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 800 | return 0; |
| 801 | } |
| 802 | return fObjectType == kReal_PdfObjectType ? fRealValue : fIntegerValue; |
| 803 | } |
| 804 | |
edisonn@google.com | a0cefa1 | 2013-07-28 18:34:14 +0000 | [diff] [blame] | 805 | inline SkScalar scalarValue() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 806 | SkPdfMarkObjectUsed(); |
| 807 | |
edisonn@google.com | a0cefa1 | 2013-07-28 18:34:14 +0000 | [diff] [blame] | 808 | SkASSERT(isNumber()); |
| 809 | |
| 810 | if (!isNumber()) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 811 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | a0cefa1 | 2013-07-28 18:34:14 +0000 | [diff] [blame] | 812 | return SkIntToScalar(0); |
| 813 | } |
| 814 | return fObjectType == kReal_PdfObjectType ? SkDoubleToScalar(fRealValue) : |
| 815 | SkIntToScalar(fIntegerValue); |
| 816 | } |
| 817 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 818 | int referenceId() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 819 | SkPdfMarkObjectUsed(); |
| 820 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 821 | SkASSERT(fObjectType == kReference_PdfObjectType); |
| 822 | return fRef.fId; |
| 823 | } |
| 824 | |
| 825 | int referenceGeneration() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 826 | SkPdfMarkObjectUsed(); |
| 827 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 828 | SkASSERT(fObjectType == kReference_PdfObjectType); |
| 829 | return fRef.fGen; |
| 830 | } |
| 831 | |
| 832 | inline const char* nameValue() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 833 | SkPdfMarkObjectUsed(); |
| 834 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 835 | SkASSERT(fObjectType == kName_PdfObjectType); |
| 836 | |
| 837 | if (fObjectType != kName_PdfObjectType) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 838 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 839 | return ""; |
| 840 | } |
| 841 | return (const char*)fStr.fBuffer; |
| 842 | } |
| 843 | |
| 844 | inline const char* stringValue() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 845 | SkPdfMarkObjectUsed(); |
| 846 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 847 | SkASSERT(fObjectType == kString_PdfObjectType || fObjectType == kHexString_PdfObjectType); |
| 848 | |
| 849 | if (fObjectType != kString_PdfObjectType && fObjectType != kHexString_PdfObjectType) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 850 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 851 | return ""; |
| 852 | } |
| 853 | return (const char*)fStr.fBuffer; |
| 854 | } |
| 855 | |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 856 | inline NotOwnedString strRef() { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 857 | SkPdfMarkObjectUsed(); |
| 858 | |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 859 | switch (fObjectType) { |
| 860 | case kString_PdfObjectType: |
| 861 | case kHexString_PdfObjectType: |
| 862 | case kKeyword_PdfObjectType: |
edisonn@google.com | 276fed9 | 2013-08-01 21:20:47 +0000 | [diff] [blame] | 863 | case kName_PdfObjectType: |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 864 | return fStr; |
| 865 | |
| 866 | default: |
| 867 | // TODO(edisonn): report/warning |
| 868 | return NotOwnedString(); |
| 869 | } |
| 870 | } |
| 871 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 872 | // TODO(edisonn): nameValue2 and stringValue2 are used to make code generation easy, |
| 873 | // but it is not a performat way to do it, since it will create an extra copy |
| 874 | // remove these functions and make code generated faster |
edisonn@google.com | 063d707 | 2013-08-16 15:05:08 +0000 | [diff] [blame] | 875 | inline SkString nameValue2() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 876 | SkPdfMarkObjectUsed(); |
| 877 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 878 | SkASSERT(fObjectType == kName_PdfObjectType); |
| 879 | |
| 880 | if (fObjectType != kName_PdfObjectType) { |
| 881 | // TODO(edisonn): log err |
edisonn@google.com | 063d707 | 2013-08-16 15:05:08 +0000 | [diff] [blame] | 882 | return SkString(); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 883 | } |
edisonn@google.com | 063d707 | 2013-08-16 15:05:08 +0000 | [diff] [blame] | 884 | return SkString((const char*)fStr.fBuffer, fStr.fBytes); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 885 | } |
| 886 | |
edisonn@google.com | 063d707 | 2013-08-16 15:05:08 +0000 | [diff] [blame] | 887 | inline SkString stringValue2() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 888 | SkPdfMarkObjectUsed(); |
| 889 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 890 | SkASSERT(fObjectType == kString_PdfObjectType || fObjectType == kHexString_PdfObjectType); |
| 891 | |
| 892 | if (fObjectType != kString_PdfObjectType && fObjectType != kHexString_PdfObjectType) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 893 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | 063d707 | 2013-08-16 15:05:08 +0000 | [diff] [blame] | 894 | return SkString(); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 895 | } |
edisonn@google.com | 063d707 | 2013-08-16 15:05:08 +0000 | [diff] [blame] | 896 | return SkString((const char*)fStr.fBuffer, fStr.fBytes); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 897 | } |
| 898 | |
| 899 | inline bool boolValue() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 900 | SkPdfMarkObjectUsed(); |
| 901 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 902 | SkASSERT(fObjectType == kBoolean_PdfObjectType); |
| 903 | |
edisonn@google.com | f111a4b | 2013-07-31 18:22:36 +0000 | [diff] [blame] | 904 | if (fObjectType != kBoolean_PdfObjectType) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 905 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 906 | return false; |
| 907 | } |
| 908 | return fBooleanValue; |
| 909 | } |
| 910 | |
| 911 | SkRect rectangleValue() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 912 | SkPdfMarkObjectUsed(); |
| 913 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 914 | SkASSERT(isRectangle()); |
| 915 | if (!isRectangle()) { |
| 916 | return SkRect::MakeEmpty(); |
| 917 | } |
| 918 | |
| 919 | double array[4]; |
| 920 | for (int i = 0; i < 4; i++) { |
| 921 | // TODO(edisonn): version where we could resolve references? |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 922 | const SkPdfNativeObject* elem = objAtAIndex(i); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 923 | if (elem == NULL || !elem->isNumber()) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 924 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 925 | return SkRect::MakeEmpty(); |
| 926 | } |
| 927 | array[i] = elem->numberValue(); |
| 928 | } |
| 929 | |
| 930 | return SkRect::MakeLTRB(SkDoubleToScalar(array[0]), |
| 931 | SkDoubleToScalar(array[1]), |
| 932 | SkDoubleToScalar(array[2]), |
| 933 | SkDoubleToScalar(array[3])); |
| 934 | } |
| 935 | |
| 936 | SkMatrix matrixValue() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 937 | SkPdfMarkObjectUsed(); |
| 938 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 939 | SkASSERT(isMatrix()); |
| 940 | if (!isMatrix()) { |
| 941 | return SkMatrix::I(); |
| 942 | } |
| 943 | |
| 944 | double array[6]; |
| 945 | for (int i = 0; i < 6; i++) { |
| 946 | // TODO(edisonn): version where we could resolve references? |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 947 | const SkPdfNativeObject* elem = objAtAIndex(i); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 948 | if (elem == NULL || !elem->isNumber()) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 949 | // TODO(edisonn): report/warn/assert. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 950 | return SkMatrix::I(); |
| 951 | } |
| 952 | array[i] = elem->numberValue(); |
| 953 | } |
| 954 | |
| 955 | return SkMatrixFromPdfMatrix(array); |
| 956 | } |
| 957 | |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 958 | bool filterStream(); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 959 | |
| 960 | |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 961 | bool GetFilteredStreamRef(unsigned char const** buffer, size_t* len) { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 962 | SkPdfMarkObjectUsed(); |
| 963 | |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 964 | // TODO(edisonn): add params that could let the last filter in place |
| 965 | // if it is jpeg or png to fast load images. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 966 | if (!hasStream()) { |
| 967 | return false; |
| 968 | } |
| 969 | |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 970 | filterStream(); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 971 | |
| 972 | if (buffer) { |
| 973 | *buffer = fStr.fBuffer; |
| 974 | } |
| 975 | |
| 976 | if (len) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 977 | *len = fStr.fBytes >> 2; // last 2 bits - TODO(edisonn): clean up. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 978 | } |
| 979 | |
| 980 | return true; |
| 981 | } |
| 982 | |
| 983 | bool isStreamFiltered() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 984 | SkPdfMarkObjectUsed(); |
| 985 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 986 | return hasStream() && ((fStr.fBytes & 1) == kFilteredStreamBit); |
| 987 | } |
| 988 | |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 989 | bool isStreamOwned() const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 990 | SkPdfMarkObjectUsed(); |
| 991 | |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 992 | return hasStream() && ((fStr.fBytes & 2) == kOwnedStreamBit); |
| 993 | } |
| 994 | |
| 995 | bool GetUnfilteredStreamRef(unsigned char const** buffer, size_t* len) const { |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 996 | SkPdfMarkObjectUsed(); |
| 997 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 998 | if (isStreamFiltered()) { |
| 999 | return false; |
| 1000 | } |
| 1001 | |
| 1002 | if (!hasStream()) { |
| 1003 | return false; |
| 1004 | } |
| 1005 | |
| 1006 | if (buffer) { |
| 1007 | *buffer = fStr.fBuffer; |
| 1008 | } |
| 1009 | |
| 1010 | if (len) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 1011 | *len = fStr.fBytes >> 2; // remove last 2 bits - TODO(edisonn): clean up. |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | return true; |
| 1015 | } |
| 1016 | |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 1017 | bool addStream(const unsigned char* buffer, size_t len) { |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 1018 | SkPdfMarkObjectUsed(); |
edisonn@google.com | 0fd25d8 | 2013-09-05 16:40:34 +0000 | [diff] [blame] | 1019 | |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1020 | SkASSERT(!hasStream()); |
| 1021 | SkASSERT(isDictionary()); |
| 1022 | |
| 1023 | if (!isDictionary() || hasStream()) { |
| 1024 | return false; |
| 1025 | } |
| 1026 | |
| 1027 | fStr.fBuffer = buffer; |
| 1028 | fStr.fBytes = (len << 2) + kUnfilteredStreamBit; |
| 1029 | |
| 1030 | return true; |
| 1031 | } |
| 1032 | |
edisonn@google.com | 276fed9 | 2013-08-01 21:20:47 +0000 | [diff] [blame] | 1033 | static void appendSpaces(SkString* str, int level) { |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1034 | for (int i = 0 ; i < level; i++) { |
| 1035 | str->append(" "); |
| 1036 | } |
| 1037 | } |
| 1038 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 1039 | static void append(SkString* str, const char* data, size_t len, const char* prefix = "\\x") { |
| 1040 | for (unsigned int i = 0 ; i < len; i++) { |
| 1041 | if (data[i] == kNUL_PdfWhiteSpace) { |
| 1042 | str->append(prefix); |
| 1043 | str->append("00"); |
| 1044 | } else if (data[i] == kHT_PdfWhiteSpace) { |
| 1045 | str->append(prefix); |
| 1046 | str->append("09"); |
| 1047 | } else if (data[i] == kLF_PdfWhiteSpace) { |
| 1048 | str->append(prefix); |
| 1049 | str->append("0A"); |
| 1050 | } else if (data[i] == kFF_PdfWhiteSpace) { |
| 1051 | str->append(prefix); |
| 1052 | str->append("0C"); |
| 1053 | } else if (data[i] == kCR_PdfWhiteSpace) { |
| 1054 | str->append(prefix); |
| 1055 | str->append("0D"); |
| 1056 | } else { |
| 1057 | str->append(data + i, 1); |
| 1058 | } |
| 1059 | } |
| 1060 | } |
| 1061 | |
edisonn@google.com | e2e01ff | 2013-08-02 20:24:48 +0000 | [diff] [blame] | 1062 | SkString toString(int firstRowLevel = 0, int level = 0) { |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1063 | SkString str; |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1064 | appendSpaces(&str, firstRowLevel); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1065 | switch (fObjectType) { |
| 1066 | case kInvalid_PdfObjectType: |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1067 | str.append("__Invalid"); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1068 | break; |
| 1069 | |
| 1070 | case kBoolean_PdfObjectType: |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1071 | str.appendf("%s", fBooleanValue ? "true" : "false"); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1072 | break; |
| 1073 | |
| 1074 | case kInteger_PdfObjectType: |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1075 | str.appendf("%i", (int)fIntegerValue); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1076 | break; |
| 1077 | |
| 1078 | case kReal_PdfObjectType: |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1079 | str.appendf("%f", fRealValue); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1080 | break; |
| 1081 | |
| 1082 | case kString_PdfObjectType: |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1083 | str.append("\""); |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 1084 | append(&str, (const char*)fStr.fBuffer, fStr.fBytes); |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1085 | str.append("\""); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1086 | break; |
| 1087 | |
| 1088 | case kHexString_PdfObjectType: |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1089 | str.append("<"); |
edisonn@google.com | b0145ce | 2013-08-05 16:23:23 +0000 | [diff] [blame] | 1090 | for (unsigned int i = 0 ; i < fStr.fBytes; i++) { |
| 1091 | str.appendf("%02x", (unsigned int)fStr.fBuffer[i]); |
| 1092 | } |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1093 | str.append(">"); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1094 | break; |
| 1095 | |
| 1096 | case kName_PdfObjectType: |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1097 | str.append("/"); |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 1098 | append(&str, (const char*)fStr.fBuffer, fStr.fBytes, "#"); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1099 | break; |
| 1100 | |
| 1101 | case kKeyword_PdfObjectType: |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 1102 | append(&str, (const char*)fStr.fBuffer, fStr.fBytes); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1103 | break; |
| 1104 | |
| 1105 | case kArray_PdfObjectType: |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1106 | str.append("[\n"); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1107 | for (unsigned int i = 0; i < size(); i++) { |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1108 | str.append(objAtAIndex(i)->toString(level + 1, level + 1)); |
| 1109 | if (i < size() - 1) { |
| 1110 | str.append(","); |
| 1111 | } |
| 1112 | str.append("\n"); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1113 | } |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1114 | appendSpaces(&str, level); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1115 | str.append("]"); |
| 1116 | break; |
| 1117 | |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1118 | case kDictionary_PdfObjectType: { |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 1119 | SkTDict<SkPdfNativeObject*>::Iter iter(*fMap); |
| 1120 | SkPdfNativeObject* obj = NULL; |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1121 | const char* key = NULL; |
| 1122 | str.append("<<\n"); |
| 1123 | while ((key = iter.next(&obj)) != NULL) { |
| 1124 | appendSpaces(&str, level + 2); |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 1125 | str.appendf("/%s %s\n", key, |
| 1126 | obj->toString(0, level + strlen(key) + 4).c_str()); |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1127 | } |
| 1128 | appendSpaces(&str, level); |
| 1129 | str.append(">>"); |
| 1130 | if (hasStream()) { |
edisonn@google.com | e2e01ff | 2013-08-02 20:24:48 +0000 | [diff] [blame] | 1131 | const unsigned char* stream = NULL; |
| 1132 | size_t length = 0; |
| 1133 | if (GetFilteredStreamRef(&stream, &length)) { |
edisonn@google.com | b0145ce | 2013-08-05 16:23:23 +0000 | [diff] [blame] | 1134 | str.append("stream\n"); |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 1135 | append(&str, (const char*)stream, length > 256 ? 256 : length); |
edisonn@google.com | b0145ce | 2013-08-05 16:23:23 +0000 | [diff] [blame] | 1136 | str.append("\nendstream"); |
edisonn@google.com | e2e01ff | 2013-08-02 20:24:48 +0000 | [diff] [blame] | 1137 | } else { |
| 1138 | str.append("stream STREAM_ERROR endstream"); |
| 1139 | } |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1140 | } |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1141 | } |
| 1142 | break; |
| 1143 | |
| 1144 | case kNull_PdfObjectType: |
| 1145 | str = "NULL"; |
| 1146 | break; |
| 1147 | |
| 1148 | case kReference_PdfObjectType: |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1149 | str.appendf("%i %i R", fRef.fId, fRef.fGen); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1150 | break; |
| 1151 | |
| 1152 | case kUndefined_PdfObjectType: |
| 1153 | str = "Undefined"; |
| 1154 | break; |
| 1155 | |
| 1156 | default: |
edisonn@google.com | 9a43c18 | 2013-08-01 20:06:42 +0000 | [diff] [blame] | 1157 | str = "Error"; |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1158 | break; |
| 1159 | } |
| 1160 | |
| 1161 | return str; |
| 1162 | } |
| 1163 | |
| 1164 | private: |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 1165 | static void makeStringCore(const unsigned char* start, SkPdfNativeObject* obj, |
| 1166 | ObjectType type) { |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 1167 | makeStringCore(start, strlen((const char*)start), obj, type); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1168 | } |
| 1169 | |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 1170 | static void makeStringCore(const unsigned char* start, const unsigned char* end, |
| 1171 | SkPdfNativeObject* obj, ObjectType type) { |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 1172 | makeStringCore(start, end - start, obj, type); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1173 | } |
| 1174 | |
edisonn@google.com | c8fda9d | 2013-10-09 20:23:12 +0000 | [diff] [blame] | 1175 | static void makeStringCore(const unsigned char* start, size_t bytes, SkPdfNativeObject* obj, |
| 1176 | ObjectType type) { |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1177 | SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); |
| 1178 | |
| 1179 | obj->fObjectType = type; |
| 1180 | obj->fStr.fBuffer = start; |
| 1181 | obj->fStr.fBytes = bytes; |
| 1182 | } |
| 1183 | |
edisonn@google.com | 2ccc3af | 2013-07-23 17:43:18 +0000 | [diff] [blame] | 1184 | bool applyFilter(const char* name); |
| 1185 | bool applyFlateDecodeFilter(); |
| 1186 | bool applyDCTDecodeFilter(); |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1187 | }; |
| 1188 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 1189 | class SkPdfStream : public SkPdfNativeObject {}; |
| 1190 | class SkPdfArray : public SkPdfNativeObject {}; |
| 1191 | class SkPdfString : public SkPdfNativeObject {}; |
| 1192 | class SkPdfHexString : public SkPdfNativeObject {}; |
| 1193 | class SkPdfInteger : public SkPdfNativeObject {}; |
| 1194 | class SkPdfReal : public SkPdfNativeObject {}; |
| 1195 | class SkPdfNumber : public SkPdfNativeObject {}; |
edisonn@google.com | 571c70b | 2013-07-10 17:09:50 +0000 | [diff] [blame] | 1196 | |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 1197 | class SkPdfName : public SkPdfNativeObject { |
| 1198 | SkPdfName() : SkPdfNativeObject() { |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 1199 | SkPdfNativeObject::makeName((const unsigned char*)"", this); |
edisonn@google.com | 78b38b1 | 2013-07-15 18:20:58 +0000 | [diff] [blame] | 1200 | } |
| 1201 | public: |
edisonn@google.com | 3aa3555 | 2013-08-14 18:26:20 +0000 | [diff] [blame] | 1202 | SkPdfName(char* name) : SkPdfNativeObject() { |
edisonn@google.com | 598cf5d | 2013-10-09 15:13:19 +0000 | [diff] [blame] | 1203 | this->makeName((const unsigned char*)name, this); |
edisonn@google.com | 78b38b1 | 2013-07-15 18:20:58 +0000 | [diff] [blame] | 1204 | } |
| 1205 | }; |
| 1206 | |
edisonn@google.com | cf2cfa1 | 2013-08-21 16:31:37 +0000 | [diff] [blame] | 1207 | #endif // SkPdfNativeObject |