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

Unified Diff: src/pdf/SkPDFBitmap.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 | « bench/PDFBench.cpp ('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/SkPDFBitmap.cpp
diff --git a/src/pdf/SkPDFBitmap.cpp b/src/pdf/SkPDFBitmap.cpp
index fdc33032a9c793d0ada23d4fdd6d5863599775b8..5e617decf4feb749d510975020fa2836bd64b6ec 100644
--- a/src/pdf/SkPDFBitmap.cpp
+++ b/src/pdf/SkPDFBitmap.cpp
@@ -382,13 +382,14 @@ namespace {
// This SkPDFObject only outputs the alpha layer of the given bitmap.
class PDFAlphaBitmap final : public SkPDFObject {
public:
- PDFAlphaBitmap(const SkImage* image) : fImage(SkRef(image)) {}
- ~PDFAlphaBitmap() {}
+ PDFAlphaBitmap(const SkImage* image) : fImage(SkRef(image)) { SkASSERT(image); }
void emitObject(SkWStream* stream,
const SkPDFObjNumMap& objNumMap,
const SkPDFSubstituteMap& subs) const override {
+ SkASSERT(fImage);
emit_image_xobject(stream, fImage.get(), true, nullptr, objNumMap, subs);
}
+ void drop() override { fImage = nullptr; }
private:
sk_sp<const SkImage> fImage;
@@ -404,22 +405,25 @@ public:
void emitObject(SkWStream* stream,
const SkPDFObjNumMap& objNumMap,
const SkPDFSubstituteMap& subs) const override {
+ SkASSERT(fImage);
emit_image_xobject(stream, fImage.get(), false, fSMask, objNumMap, subs);
}
void addResources(SkPDFObjNumMap* catalog,
const SkPDFSubstituteMap& subs) const override {
+ SkASSERT(fImage);
if (fSMask.get()) {
SkPDFObject* obj = subs.getSubstitute(fSMask.get());
SkASSERT(obj);
catalog->addObjectRecursively(obj, subs);
}
}
+ void drop() override { fImage = nullptr; fSMask = nullptr; }
PDFDefaultBitmap(const SkImage* image, SkPDFObject* smask)
- : fImage(SkRef(image)), fSMask(smask) {}
+ : fImage(SkRef(image)), fSMask(smask) { SkASSERT(fImage); }
private:
sk_sp<const SkImage> fImage;
- const sk_sp<SkPDFObject> fSMask;
+ sk_sp<SkPDFObject> fSMask;
};
} // namespace
@@ -437,15 +441,17 @@ public:
sk_sp<SkData> fData;
bool fIsYUV;
PDFJpegBitmap(SkISize size, SkData* data, bool isYUV)
- : fSize(size), fData(SkRef(data)), fIsYUV(isYUV) {}
+ : fSize(size), fData(SkRef(data)), fIsYUV(isYUV) { SkASSERT(data); }
void emitObject(SkWStream*,
const SkPDFObjNumMap&,
const SkPDFSubstituteMap&) const override;
+ void drop() override { fData = nullptr; }
};
void PDFJpegBitmap::emitObject(SkWStream* stream,
const SkPDFObjNumMap& objNumMap,
const SkPDFSubstituteMap& substituteMap) const {
+ SkASSERT(fData);
SkPDFDict pdfDict("XObject");
pdfDict.insertName("Subtype", "Image");
pdfDict.insertInt("Width", fSize.width());
« no previous file with comments | « bench/PDFBench.cpp ('k') | src/pdf/SkPDFDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698