Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(829)

Unified Diff: src/pdf/SkPDFCatalog.cpp

Issue 870333002: Simplify reference management in SkPDF (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-02-10 (Tuesday) 11:05:24 EST Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFCatalog.h ('k') | src/pdf/SkPDFDocument.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFCatalog.cpp
diff --git a/src/pdf/SkPDFCatalog.cpp b/src/pdf/SkPDFCatalog.cpp
index 5fd0f7619c94de36402b9392978232db86727bca..21f2ae2b9a9c4f962b581a9a65617a29ca702f60 100644
--- a/src/pdf/SkPDFCatalog.cpp
+++ b/src/pdf/SkPDFCatalog.cpp
@@ -50,13 +50,7 @@ void SkPDFCatalog::emitObjectNumber(SkWStream* stream, SkPDFObject* obj) {
stream->writeText(" 0"); // Generation number is always 0.
}
-size_t SkPDFCatalog::getObjectNumberSize(SkPDFObject* obj) {
- SkDynamicMemoryWStream buffer;
- emitObjectNumber(&buffer, obj);
- return buffer.getOffset();
-}
-
-int SkPDFCatalog::findObjectIndex(SkPDFObject* obj) const {
+int SkPDFCatalog::findObjectIndex(SkPDFObject* obj) {
for (int i = 0; i < fCatalog.count(); i++) {
if (fCatalog[i].fObject == obj) {
return i;
@@ -68,7 +62,9 @@ int SkPDFCatalog::findObjectIndex(SkPDFObject* obj) const {
return findObjectIndex(fSubstituteMap[i].fOriginal);
}
}
- return -1;
+ struct Rec newEntry(obj, false);
mtklein 2015/02/10 17:25:52 drop struct? This is not C.
hal.canary 2015/02/10 17:44:59 Done.
+ fCatalog.append(1, &newEntry);
+ return fCatalog.count() - 1;
}
int SkPDFCatalog::assignObjNum(SkPDFObject* obj) {
@@ -150,35 +146,8 @@ void SkPDFCatalog::setSubstitute(SkPDFObject* original,
}
}
#endif
- // Check if the original is on first page.
- bool onFirstPage = false;
- for (int i = 0; i < fCatalog.count(); ++i) {
- if (fCatalog[i].fObject == original) {
- onFirstPage = fCatalog[i].fOnFirstPage;
- break;
- }
-#if defined(SK_DEBUG)
- if (i == fCatalog.count() - 1) {
- SkASSERT(false); // original not in catalog
- return;
- }
-#endif
- }
-
SubstituteMapping newMapping(original, substitute);
fSubstituteMap.append(1, &newMapping);
-
- // Add resource objects of substitute object to catalog.
- 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,7 +159,3 @@ SkPDFObject* SkPDFCatalog::getSubstituteObject(SkPDFObject* object) {
return object;
}
-SkTSet<SkPDFObject*>* SkPDFCatalog::getSubstituteList(bool firstPage) {
- return firstPage ? &fSubstituteResourcesFirstPage :
- &fSubstituteResourcesRemaining;
-}
« no previous file with comments | « src/pdf/SkPDFCatalog.h ('k') | src/pdf/SkPDFDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698