diff options
author | edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-02 15:33:08 +0000 |
---|---|---|
committer | edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-02 15:33:08 +0000 |
commit | 6addb1930013ebb2f984045141650fd7afcfa90f (patch) | |
tree | dd4c38a7cb519486ecf9cf54c2f7a65ec85dcfca /src/pdf/SkPDFCatalog.cpp | |
parent | c52570475f00d5b62b8d82ba50b4b911dc38ce43 (diff) |
resubmit https://code.google.com/p/skia/source/detail?r=7883 (in the meantime we
added capability to collect minidump and callstack if buildbot fails with heap
coruption in windows, and a NPE bug was fixed in SkPDFDocument, when document was destroyed without ever beeing used and a field was NULL + a few minor conflicts have been resolved)
git-svn-id: http://skia.googlecode.com/svn/trunk@8487 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pdf/SkPDFCatalog.cpp')
-rw-r--r-- | src/pdf/SkPDFCatalog.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/pdf/SkPDFCatalog.cpp b/src/pdf/SkPDFCatalog.cpp index 49c0404974..8690b3eaea 100644 --- a/src/pdf/SkPDFCatalog.cpp +++ b/src/pdf/SkPDFCatalog.cpp @@ -171,12 +171,16 @@ void SkPDFCatalog::setSubstitute(SkPDFObject* original, fSubstituteMap.append(1, &newMapping); // Add resource objects of substitute object to catalog. - SkTDArray<SkPDFObject*>* targetList = getSubstituteList(onFirstPage); - int existingSize = targetList->count(); - newMapping.fSubstitute->getResources(targetList); - for (int i = existingSize; i < targetList->count(); ++i) { - addObject((*targetList)[i], onFirstPage); - } + SkTSet<SkPDFObject*>* targetSet = getSubstituteList(onFirstPage); + SkTSet<SkPDFObject*> newResourceObjects; + newMapping.fSubstitute->getResources(*targetSet, &newResourceObjects); + for (int i = 0; i < newResourceObjects.count(); ++i) { + addObject(newResourceObjects[i], onFirstPage); + } + // mergeInto returns the number of duplicates. + // If there are duplicates, there is a bug and we mess ref counting. + SkDEBUGCODE(int duplicates =) targetSet->mergeInto(newResourceObjects); + SkASSERT(duplicates == 0); } SkPDFObject* SkPDFCatalog::getSubstituteObject(SkPDFObject* object) { @@ -190,22 +194,22 @@ SkPDFObject* SkPDFCatalog::getSubstituteObject(SkPDFObject* object) { off_t SkPDFCatalog::setSubstituteResourcesOffsets(off_t fileOffset, bool firstPage) { - SkTDArray<SkPDFObject*>* targetList = getSubstituteList(firstPage); + SkTSet<SkPDFObject*>* targetSet = getSubstituteList(firstPage); off_t offsetSum = fileOffset; - for (int i = 0; i < targetList->count(); ++i) { - offsetSum += setFileOffset((*targetList)[i], offsetSum); + for (int i = 0; i < targetSet->count(); ++i) { + offsetSum += setFileOffset((*targetSet)[i], offsetSum); } return offsetSum - fileOffset; } void SkPDFCatalog::emitSubstituteResources(SkWStream *stream, bool firstPage) { - SkTDArray<SkPDFObject*>* targetList = getSubstituteList(firstPage); - for (int i = 0; i < targetList->count(); ++i) { - (*targetList)[i]->emit(stream, this, true); + SkTSet<SkPDFObject*>* targetSet = getSubstituteList(firstPage); + for (int i = 0; i < targetSet->count(); ++i) { + (*targetSet)[i]->emit(stream, this, true); } } -SkTDArray<SkPDFObject*>* SkPDFCatalog::getSubstituteList(bool firstPage) { +SkTSet<SkPDFObject*>* SkPDFCatalog::getSubstituteList(bool firstPage) { return firstPage ? &fSubstituteResourcesFirstPage : &fSubstituteResourcesRemaining; } |