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

Unified Diff: src/pdf/SkPDFDocument.cpp

Issue 1790023003: SkPDF: add drop() virtual to release resources early. (Closed) Base URL: https://skia.googlesource.com/skia.git@skpdf-global
Patch Set: free → release Created 4 years, 9 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/SkPDFBitmap.cpp ('k') | src/pdf/SkPDFFont.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFDocument.cpp
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index 4895dc5a7426e399412be17c6ba00fe4686e2389..670908e6d51199f706d26cbddee6458daed6b536 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -224,7 +224,7 @@ static bool emit_pdf_document(const SkTArray<sk_sp<const SkPDFDevice>>& pageDevi
emit_pdf_header(stream);
SkTDArray<int32_t> offsets;
for (int i = 0; i < objNumMap.objects().count(); ++i) {
- SkPDFObject* object = objNumMap.objects()[i];
+ SkPDFObject* object = objNumMap.objects()[i].get();
size_t offset = stream->bytesWritten();
// This assert checks that size(pdf_header) > 0 and that
// the output stream correctly reports bytesWritten().
@@ -236,6 +236,7 @@ static bool emit_pdf_document(const SkTArray<sk_sp<const SkPDFDevice>>& pageDevi
stream->writeText(" 0 obj\n"); // Generation number is always 0.
object->emitObject(stream, objNumMap, substitutes);
stream->writeText("\nendobj\n");
+ object->drop();
}
int32_t xRefFileOffset = SkToS32(stream->bytesWritten() - baseOffset);
@@ -256,7 +257,7 @@ static bool emit_pdf_document(const SkTArray<sk_sp<const SkPDFDevice>>& pageDevi
// The page tree has both child and parent pointers, so it creates a
// reference cycle. We must clear that cycle to properly reclaim memory.
for (int i = 0; i < pageTree.count(); i++) {
- pageTree[i]->clear();
+ pageTree[i]->drop();
}
pageTree.safeUnrefAll();
pages.unrefAll();
« no previous file with comments | « src/pdf/SkPDFBitmap.cpp ('k') | src/pdf/SkPDFFont.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698