OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 The Android Open Source Project | 3 * Copyright 2010 The Android Open Source Project |
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 | 9 |
10 #include "SkPDFCatalog.h" | 10 #include "SkPDFCatalog.h" |
11 | 11 |
12 SkPDFCatalog::SkPDFCatalog() {} | 12 SkPDFCatalog::SkPDFCatalog() {} |
13 | 13 |
14 SkPDFCatalog::~SkPDFCatalog() { | 14 SkPDFCatalog::~SkPDFCatalog() { |
15 fSubstituteMap.foreach( | 15 fSubstituteMap.foreach( |
16 [](SkPDFObject*, SkPDFObject** v) { (*v)->unref(); }); | 16 [](SkPDFObject*, SkPDFObject** v) { (*v)->unref(); }); |
17 } | 17 } |
18 | 18 |
19 bool SkPDFCatalog::addObject(SkPDFObject* obj) { | 19 bool SkPDFCatalog::addObject(SkPDFObject* obj) { |
20 if (fObjectNumbers.find(obj)) { | 20 if (fObjectNumbers.find(obj)) { |
21 return false; | 21 return false; |
22 } | 22 } |
23 fObjectNumbers.set(obj, fObjectNumbers.count() + 1); | 23 fObjectNumbers.set(obj, fObjectNumbers.count() + 1); |
| 24 fObjects.push(obj); |
24 return true; | 25 return true; |
25 } | 26 } |
26 | 27 |
27 int32_t SkPDFCatalog::getObjectNumber(SkPDFObject* obj) const { | 28 int32_t SkPDFCatalog::getObjectNumber(SkPDFObject* obj) const { |
28 int32_t* objectNumberFound = fObjectNumbers.find(obj); | 29 int32_t* objectNumberFound = fObjectNumbers.find(obj); |
29 SkASSERT(objectNumberFound); | 30 SkASSERT(objectNumberFound); |
30 return *objectNumberFound; | 31 return *objectNumberFound; |
31 } | 32 } |
32 | 33 |
33 void SkPDFCatalog::setSubstitute(SkPDFObject* original, | 34 void SkPDFCatalog::setSubstitute(SkPDFObject* original, |
34 SkPDFObject* substitute) { | 35 SkPDFObject* substitute) { |
35 SkASSERT(original != substitute); | 36 SkASSERT(original != substitute); |
36 SkASSERT(!fSubstituteMap.find(original)); | 37 SkASSERT(!fSubstituteMap.find(original)); |
37 fSubstituteMap.set(original, SkRef(substitute)); | 38 fSubstituteMap.set(original, SkRef(substitute)); |
38 } | 39 } |
39 | 40 |
40 SkPDFObject* SkPDFCatalog::getSubstituteObject(SkPDFObject* object) const { | 41 SkPDFObject* SkPDFCatalog::getSubstituteObject(SkPDFObject* object) const { |
41 SkPDFObject** found = fSubstituteMap.find(object); | 42 SkPDFObject** found = fSubstituteMap.find(object); |
42 return found ? *found : object; | 43 return found ? *found : object; |
43 } | 44 } |
OLD | NEW |