| OLD | NEW |
| (Empty) |
| 1 | |
| 2 /* | |
| 3 * Copyright 2010 The Android Open Source Project | |
| 4 * | |
| 5 * Use of this source code is governed by a BSD-style license that can be | |
| 6 * found in the LICENSE file. | |
| 7 */ | |
| 8 | |
| 9 | |
| 10 #include "SkPDFCatalog.h" | |
| 11 | |
| 12 SkPDFCatalog::SkPDFCatalog() {} | |
| 13 | |
| 14 SkPDFCatalog::~SkPDFCatalog() { | |
| 15 fSubstituteMap.foreach( | |
| 16 [](SkPDFObject*, SkPDFObject** v) { (*v)->unref(); }); | |
| 17 } | |
| 18 | |
| 19 bool SkPDFCatalog::addObject(SkPDFObject* obj) { | |
| 20 if (fObjectNumbers.find(obj)) { | |
| 21 return false; | |
| 22 } | |
| 23 fObjectNumbers.set(obj, fObjectNumbers.count() + 1); | |
| 24 fObjects.push(obj); | |
| 25 return true; | |
| 26 } | |
| 27 | |
| 28 int32_t SkPDFCatalog::getObjectNumber(SkPDFObject* obj) const { | |
| 29 int32_t* objectNumberFound = fObjectNumbers.find(obj); | |
| 30 SkASSERT(objectNumberFound); | |
| 31 return *objectNumberFound; | |
| 32 } | |
| 33 | |
| 34 void SkPDFCatalog::setSubstitute(SkPDFObject* original, | |
| 35 SkPDFObject* substitute) { | |
| 36 SkASSERT(original != substitute); | |
| 37 SkASSERT(!fSubstituteMap.find(original)); | |
| 38 fSubstituteMap.set(original, SkRef(substitute)); | |
| 39 } | |
| 40 | |
| 41 SkPDFObject* SkPDFCatalog::getSubstituteObject(SkPDFObject* object) const { | |
| 42 SkPDFObject** found = fSubstituteMap.find(object); | |
| 43 return found ? *found : object; | |
| 44 } | |
| OLD | NEW |