aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFCanon.cpp
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2016-03-13 18:30:24 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-13 18:30:24 -0700
commit1437c1eea8f40f7a43bfe6e80a8d3f6cd61a3643 (patch)
tree4cdbff97b6e2bf856dff2875ff2c8a818f9b27ea /src/pdf/SkPDFCanon.cpp
parent1a9b9640843a64af8d9d90337ec3b3fea663196a (diff)
SkPDF: remove all globally references SkPDFObjects
Move these singletons into SkPDFCanon (there is still a single object per document; output PDF size will not change). Motivation: After this change, all indirectly-referenced SkPDFObjects are serialized exactly once. The next CL will add a memory saving feature: a method to purge an object's resources immediately after serialization. After that, further changes wil allow some objects to be serialized *before* SkDocument::close(), leading to potentially very large memory savings. BUG=skia:5087 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1788263002 Review URL: https://codereview.chromium.org/1788263002
Diffstat (limited to 'src/pdf/SkPDFCanon.cpp')
-rw-r--r--src/pdf/SkPDFCanon.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/pdf/SkPDFCanon.cpp b/src/pdf/SkPDFCanon.cpp
index 4fdaa0db62..d7aea8ad69 100644
--- a/src/pdf/SkPDFCanon.cpp
+++ b/src/pdf/SkPDFCanon.cpp
@@ -149,3 +149,25 @@ const SkImage* SkPDFCanon::bitmapToImage(const SkBitmap& bm) {
bm.copyTo(&n32bitmap, kN32_SkColorType);
return *fBitmapToImageMap.set(key, SkImage::NewFromBitmap(n32bitmap));
}
+
+sk_sp<SkPDFStream> SkPDFCanon::makeInvertFunction() {
+ if (fInvertFunction) {
+ return fInvertFunction;
+ }
+ fInvertFunction = SkPDFGraphicState::MakeInvertFunction();
+ return fInvertFunction;
+}
+sk_sp<SkPDFDict> SkPDFCanon::makeNoSmaskGraphicState() {
+ if (fNoSmaskGraphicState) {
+ return fNoSmaskGraphicState;
+ }
+ fNoSmaskGraphicState = SkPDFGraphicState::MakeNoSmaskGraphicState();
+ return fNoSmaskGraphicState;
+}
+sk_sp<SkPDFArray> SkPDFCanon::makeRangeObject() {
+ if (fRangeObject) {
+ return fRangeObject;
+ }
+ fRangeObject = SkPDFShader::MakeRangeObject();
+ return fRangeObject;
+}