Index: src/pdf/SkPDFGraphicState.cpp |
diff --git a/src/pdf/SkPDFGraphicState.cpp b/src/pdf/SkPDFGraphicState.cpp |
index 7c4c5e30eb4858f3fc3b4ae0e991aa72b1b013d4..19e9a36d05ca52520787a00e5dfa310b99e22f32 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(); |
} |