aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFGraphicState.cpp
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2016-03-08 12:38:22 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-08 12:38:22 -0800
commit9904c9212074279380e21f96575078734dbbd308 (patch)
tree8970a1405170db6036b11ec1797e21cf33d5ce4b /src/pdf/SkPDFGraphicState.cpp
parent6b5c5cc7b7bdffb4882706b915b544aba8714961 (diff)
SkPDF: Add sk_sp setters; .release() becomes std::move()
Note to reviewers: Start with changes to SkPDFTypes.h Many places that had a bare pointer owning a reference are refactored to use a sk_sp. There remain several places where a non-owning pointer `T*` should be replaced with `const sk_sp<T>&` to eliminate the common pattern `sk_sp<T>(SkRef(x))`. Review URL: https://codereview.chromium.org/1775043002
Diffstat (limited to 'src/pdf/SkPDFGraphicState.cpp')
-rw-r--r--src/pdf/SkPDFGraphicState.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/pdf/SkPDFGraphicState.cpp b/src/pdf/SkPDFGraphicState.cpp
index 7c4c5e30eb..19e9a36d05 100644
--- a/src/pdf/SkPDFGraphicState.cpp
+++ b/src/pdf/SkPDFGraphicState.cpp
@@ -126,7 +126,7 @@ SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint(
return pdfGraphicState;
}
-static SkPDFObject* create_invert_function() {
+static SkPDFStream* create_invert_function() {
// Acrobat crashes if we use a type 0 function, kpdf crashes if we use
// a type 2 function, so we use a type 4 function.
auto domainAndRange = sk_make_sp<SkPDFArray>();
@@ -141,12 +141,17 @@ static SkPDFObject* create_invert_function() {
auto invertFunction = sk_make_sp<SkPDFStream>(psInvertStream.get());
invertFunction->insertInt("FunctionType", 4);
- invertFunction->insertObject("Domain", SkRef(domainAndRange.get()));
- invertFunction->insertObject("Range", domainAndRange.release());
+ invertFunction->insertObject("Domain", domainAndRange);
+ invertFunction->insertObject("Range", std::move(domainAndRange));
return invertFunction.release();
}
-SK_DECLARE_STATIC_ONCE_PTR(SkPDFObject, invertFunction);
+SK_DECLARE_STATIC_ONCE_PTR(SkPDFStream, invertFunction);
+
+static sk_sp<SkPDFStream> make_invert_function() {
+ return sk_sp<SkPDFStream>(
+ SkRef(invertFunction.get(create_invert_function)));
+}
// static
SkPDFDict* SkPDFGraphicState::GetSMaskGraphicState(SkPDFFormXObject* sMask,
@@ -160,13 +165,13 @@ SkPDFDict* SkPDFGraphicState::GetSMaskGraphicState(SkPDFFormXObject* sMask,
} else if (sMaskMode == kLuminosity_SMaskMode) {
sMaskDict->insertName("S", "Luminosity");
}
- sMaskDict->insertObjRef("G", SkRef(sMask));
+ sMaskDict->insertObjRef("G", sk_sp<SkPDFFormXObject>(SkRef(sMask)));
if (invert) {
- sMaskDict->insertObjRef("TR", SkRef(invertFunction.get(create_invert_function)));
+ sMaskDict->insertObjRef("TR", make_invert_function());
}
auto result = sk_make_sp<SkPDFDict>("ExtGState");
- result->insertObject("SMask", sMaskDict.release());
+ result->insertObject("SMask", std::move(sMaskDict));
return result.release();
}