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 "SkDeflate.h" | 9 #include "SkDeflate.h" |
10 #include "SkPDFTypes.h" | 10 #include "SkPDFTypes.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 case Type::kInt: | 170 case Type::kInt: |
171 case Type::kBool: | 171 case Type::kBool: |
172 case Type::kScalar: | 172 case Type::kScalar: |
173 case Type::kName: | 173 case Type::kName: |
174 case Type::kString: | 174 case Type::kString: |
175 case Type::kNameSkS: | 175 case Type::kNameSkS: |
176 case Type::kStringSkS: | 176 case Type::kStringSkS: |
177 return; // These have no resources. | 177 return; // These have no resources. |
178 case Type::kObjRef: { | 178 case Type::kObjRef: { |
179 SkPDFObject* obj = substituteMap.getSubstitute(fObject); | 179 SkPDFObject* obj = substituteMap.getSubstitute(fObject); |
180 if (objNumMap->addObject(obj)) { | 180 objNumMap->addObjectRecursively(obj, substituteMap); |
181 obj->addResources(objNumMap, substituteMap); | |
182 } | |
183 return; | 181 return; |
184 } | 182 } |
185 case Type::kObject: | 183 case Type::kObject: |
186 fObject->addResources(objNumMap, substituteMap); | 184 fObject->addResources(objNumMap, substituteMap); |
187 return; | 185 return; |
188 default: | 186 default: |
189 SkDEBUGFAIL("SkPDFUnion::addResources with bad type"); | 187 SkDEBUGFAIL("SkPDFUnion::addResources with bad type"); |
190 } | 188 } |
191 } | 189 } |
192 | 190 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 | 491 |
494 bool SkPDFObjNumMap::addObject(SkPDFObject* obj) { | 492 bool SkPDFObjNumMap::addObject(SkPDFObject* obj) { |
495 if (fObjectNumbers.find(obj)) { | 493 if (fObjectNumbers.find(obj)) { |
496 return false; | 494 return false; |
497 } | 495 } |
498 fObjectNumbers.set(obj, fObjectNumbers.count() + 1); | 496 fObjectNumbers.set(obj, fObjectNumbers.count() + 1); |
499 fObjects.push(obj); | 497 fObjects.push(obj); |
500 return true; | 498 return true; |
501 } | 499 } |
502 | 500 |
| 501 void SkPDFObjNumMap::addObjectRecursively(SkPDFObject* obj, |
| 502 const SkPDFSubstituteMap& subs) { |
| 503 if (obj && this->addObject(obj)) { |
| 504 obj->addResources(this, subs); |
| 505 } |
| 506 } |
| 507 |
503 int32_t SkPDFObjNumMap::getObjectNumber(SkPDFObject* obj) const { | 508 int32_t SkPDFObjNumMap::getObjectNumber(SkPDFObject* obj) const { |
504 int32_t* objectNumberFound = fObjectNumbers.find(obj); | 509 int32_t* objectNumberFound = fObjectNumbers.find(obj); |
505 SkASSERT(objectNumberFound); | 510 SkASSERT(objectNumberFound); |
506 return *objectNumberFound; | 511 return *objectNumberFound; |
507 } | 512 } |
508 | 513 |
509 #ifdef SK_PDF_IMAGE_STATS | 514 #ifdef SK_PDF_IMAGE_STATS |
510 SkAtomic<int> gDrawImageCalls(0); | 515 SkAtomic<int> gDrawImageCalls(0); |
511 SkAtomic<int> gJpegImageObjects(0); | 516 SkAtomic<int> gJpegImageObjects(0); |
512 SkAtomic<int> gRegularImageObjects(0); | 517 SkAtomic<int> gRegularImageObjects(0); |
513 | 518 |
514 void SkPDFImageDumpStats() { | 519 void SkPDFImageDumpStats() { |
515 SkDebugf("\ntotal PDF drawImage/drawBitmap calls: %d\n" | 520 SkDebugf("\ntotal PDF drawImage/drawBitmap calls: %d\n" |
516 "total PDF jpeg images: %d\n" | 521 "total PDF jpeg images: %d\n" |
517 "total PDF regular images: %d\n", | 522 "total PDF regular images: %d\n", |
518 gDrawImageCalls.load(), | 523 gDrawImageCalls.load(), |
519 gJpegImageObjects.load(), | 524 gJpegImageObjects.load(), |
520 gRegularImageObjects.load()); | 525 gRegularImageObjects.load()); |
521 } | 526 } |
522 #endif // SK_PDF_IMAGE_STATS | 527 #endif // SK_PDF_IMAGE_STATS |
OLD | NEW |