| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkPDFTypes.h" | 9 #include "SkPDFTypes.h" |
| 10 #include "SkStream.h" | 10 #include "SkStream.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 263 |
| 264 SkPDFUnion SkPDFUnion::Object(SkPDFObject* ptr) { | 264 SkPDFUnion SkPDFUnion::Object(SkPDFObject* ptr) { |
| 265 SkPDFUnion u(Type::kObject); | 265 SkPDFUnion u(Type::kObject); |
| 266 SkASSERT(ptr); | 266 SkASSERT(ptr); |
| 267 u.fObject = ptr; | 267 u.fObject = ptr; |
| 268 return u.move(); | 268 return u.move(); |
| 269 } | 269 } |
| 270 | 270 |
| 271 //////////////////////////////////////////////////////////////////////////////// | 271 //////////////////////////////////////////////////////////////////////////////// |
| 272 | 272 |
| 273 #if 0 // Enable if needed. |
| 273 void SkPDFAtom::emitObject(SkWStream* stream, | 274 void SkPDFAtom::emitObject(SkWStream* stream, |
| 274 const SkPDFObjNumMap& objNumMap, | 275 const SkPDFObjNumMap& objNumMap, |
| 275 const SkPDFSubstituteMap& substitutes) { | 276 const SkPDFSubstituteMap& substitutes) { |
| 276 fValue.emitObject(stream, objNumMap, substitutes); | 277 fValue.emitObject(stream, objNumMap, substitutes); |
| 277 } | 278 } |
| 278 void SkPDFAtom::addResources(SkPDFObjNumMap* map, | 279 void SkPDFAtom::addResources(SkPDFObjNumMap* map, |
| 279 const SkPDFSubstituteMap& substitutes) const { | 280 const SkPDFSubstituteMap& substitutes) const { |
| 280 fValue.addResources(map, substitutes); | 281 fValue.addResources(map, substitutes); |
| 281 } | 282 } |
| 282 | 283 #endif // 0 |
| 283 //////////////////////////////////////////////////////////////////////////////// | 284 //////////////////////////////////////////////////////////////////////////////// |
| 284 | 285 |
| 285 // static | 286 // static |
| 286 void SkPDFScalar::Append(SkScalar value, SkWStream* stream) { | 287 void SkPDFScalar::Append(SkScalar value, SkWStream* stream) { |
| 287 // The range of reals in PDF/A is the same as SkFixed: +/- 32,767 and | 288 // The range of reals in PDF/A is the same as SkFixed: +/- 32,767 and |
| 288 // +/- 1/65,536 (though integers can range from 2^31 - 1 to -2^31). | 289 // +/- 1/65,536 (though integers can range from 2^31 - 1 to -2^31). |
| 289 // When using floats that are outside the whole value range, we can use | 290 // When using floats that are outside the whole value range, we can use |
| 290 // integers instead. | 291 // integers instead. |
| 291 | 292 |
| 292 #if !defined(SK_ALLOW_LARGE_PDF_SCALARS) | 293 #if !defined(SK_ALLOW_LARGE_PDF_SCALARS) |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 const SkPDFSubstituteMap& substitutes) const { | 410 const SkPDFSubstituteMap& substitutes) const { |
| 410 for (const SkPDFUnion& value : fValues) { | 411 for (const SkPDFUnion& value : fValues) { |
| 411 value.addResources(catalog, substitutes); | 412 value.addResources(catalog, substitutes); |
| 412 } | 413 } |
| 413 } | 414 } |
| 414 | 415 |
| 415 void SkPDFArray::append(SkPDFUnion&& value) { | 416 void SkPDFArray::append(SkPDFUnion&& value) { |
| 416 SkNEW_PLACEMENT_ARGS(fValues.append(), SkPDFUnion, (value.move())); | 417 SkNEW_PLACEMENT_ARGS(fValues.append(), SkPDFUnion, (value.move())); |
| 417 } | 418 } |
| 418 | 419 |
| 419 SkPDFObject* SkPDFArray::append(SkPDFObject* value) { | |
| 420 // DEPRECATED | |
| 421 this->append(SkPDFUnion::Object(SkRef(value))); | |
| 422 return value; | |
| 423 } | |
| 424 | |
| 425 void SkPDFArray::appendInt(int32_t value) { | 420 void SkPDFArray::appendInt(int32_t value) { |
| 426 this->append(SkPDFUnion::Int(value)); | 421 this->append(SkPDFUnion::Int(value)); |
| 427 } | 422 } |
| 428 | 423 |
| 429 void SkPDFArray::appendBool(bool value) { | 424 void SkPDFArray::appendBool(bool value) { |
| 430 this->append(SkPDFUnion::Bool(value)); | 425 this->append(SkPDFUnion::Bool(value)); |
| 431 } | 426 } |
| 432 | 427 |
| 433 void SkPDFArray::appendScalar(SkScalar value) { | 428 void SkPDFArray::appendScalar(SkScalar value) { |
| 434 this->append(SkPDFUnion::Scalar(value)); | 429 this->append(SkPDFUnion::Scalar(value)); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 this->set(SkPDFUnion::Name(key), SkPDFUnion::ObjRef(value)); | 500 this->set(SkPDFUnion::Name(key), SkPDFUnion::ObjRef(value)); |
| 506 } | 501 } |
| 507 | 502 |
| 508 void SkPDFDict::insertObject(const char key[], SkPDFObject* value) { | 503 void SkPDFDict::insertObject(const char key[], SkPDFObject* value) { |
| 509 this->set(SkPDFUnion::Name(key), SkPDFUnion::Object(value)); | 504 this->set(SkPDFUnion::Name(key), SkPDFUnion::Object(value)); |
| 510 } | 505 } |
| 511 void SkPDFDict::insertObject(const SkString& key, SkPDFObject* value) { | 506 void SkPDFDict::insertObject(const SkString& key, SkPDFObject* value) { |
| 512 this->set(SkPDFUnion::Name(key), SkPDFUnion::Object(value)); | 507 this->set(SkPDFUnion::Name(key), SkPDFUnion::Object(value)); |
| 513 } | 508 } |
| 514 | 509 |
| 515 // DEPRECATED | |
| 516 SkPDFObject* SkPDFDict::insert(const char key[], SkPDFObject* value) { | |
| 517 this->set(SkPDFUnion::Name(key), SkPDFUnion::Object(SkRef(value))); | |
| 518 return value; | |
| 519 } | |
| 520 | |
| 521 void SkPDFDict::insertBool(const char key[], bool value) { | 510 void SkPDFDict::insertBool(const char key[], bool value) { |
| 522 this->set(SkPDFUnion::Name(key), SkPDFUnion::Bool(value)); | 511 this->set(SkPDFUnion::Name(key), SkPDFUnion::Bool(value)); |
| 523 } | 512 } |
| 524 | 513 |
| 525 void SkPDFDict::insertInt(const char key[], int32_t value) { | 514 void SkPDFDict::insertInt(const char key[], int32_t value) { |
| 526 this->set(SkPDFUnion::Name(key), SkPDFUnion::Int(value)); | 515 this->set(SkPDFUnion::Name(key), SkPDFUnion::Int(value)); |
| 527 } | 516 } |
| 528 | 517 |
| 529 void SkPDFDict::insertInt(const char key[], size_t value) { | 518 void SkPDFDict::insertInt(const char key[], size_t value) { |
| 530 this->insertInt(key, SkToS32(value)); | 519 this->insertInt(key, SkToS32(value)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 fObjects.push(obj); | 576 fObjects.push(obj); |
| 588 return true; | 577 return true; |
| 589 } | 578 } |
| 590 | 579 |
| 591 int32_t SkPDFObjNumMap::getObjectNumber(SkPDFObject* obj) const { | 580 int32_t SkPDFObjNumMap::getObjectNumber(SkPDFObject* obj) const { |
| 592 int32_t* objectNumberFound = fObjectNumbers.find(obj); | 581 int32_t* objectNumberFound = fObjectNumbers.find(obj); |
| 593 SkASSERT(objectNumberFound); | 582 SkASSERT(objectNumberFound); |
| 594 return *objectNumberFound; | 583 return *objectNumberFound; |
| 595 } | 584 } |
| 596 | 585 |
| OLD | NEW |