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

Unified Diff: src/pdf/SkPDFGraphicState.cpp

Issue 1322933005: Port uses of SkLazyPtr to SkOncePtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: name Created 5 years, 3 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/opts/opts_check_x86.cpp ('k') | src/pdf/SkPDFShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFGraphicState.cpp
diff --git a/src/pdf/SkPDFGraphicState.cpp b/src/pdf/SkPDFGraphicState.cpp
index 162ddc8447161779fbb7fe30a084ebcfa27cc4c3..0ad1853f3e9b1e6ed77ffc4a9b9274475a51860c 100644
--- a/src/pdf/SkPDFGraphicState.cpp
+++ b/src/pdf/SkPDFGraphicState.cpp
@@ -6,7 +6,7 @@
*/
#include "SkData.h"
-#include "SkLazyPtr.h"
+#include "SkOncePtr.h"
#include "SkPDFCanon.h"
#include "SkPDFFormXObject.h"
#include "SkPDFGraphicState.h"
@@ -126,8 +126,7 @@ SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint(
return pdfGraphicState;
}
-namespace {
-SkPDFObject* create_invert_function() {
+static SkPDFObject* 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.
SkAutoTUnref<SkPDFArray> domainAndRange(new SkPDFArray);
@@ -147,13 +146,7 @@ SkPDFObject* create_invert_function() {
return invertFunction;
}
-template <typename T> void unref(T* ptr) { ptr->unref(); }
-} // namespace
-
-SK_DECLARE_STATIC_LAZY_PTR(SkPDFObject,
- invertFunction,
- create_invert_function,
- unref<SkPDFObject>);
+SK_DECLARE_STATIC_ONCE_PTR(SkPDFObject, invertFunction);
// static
SkPDFDict* SkPDFGraphicState::GetSMaskGraphicState(SkPDFFormXObject* sMask,
@@ -169,7 +162,7 @@ SkPDFDict* SkPDFGraphicState::GetSMaskGraphicState(SkPDFFormXObject* sMask,
}
sMaskDict->insertObjRef("G", SkRef(sMask));
if (invert) {
- sMaskDict->insertObjRef("TR", SkRef(invertFunction.get()));
+ sMaskDict->insertObjRef("TR", SkRef(invertFunction.get(create_invert_function)));
}
SkPDFDict* result = new SkPDFDict("ExtGState");
@@ -177,21 +170,16 @@ SkPDFDict* SkPDFGraphicState::GetSMaskGraphicState(SkPDFFormXObject* sMask,
return result;
}
-namespace {
-SkPDFDict* create_no_smask_graphic_state() {
+static SkPDFDict* create_no_smask_graphic_state() {
SkPDFDict* noSMaskGS = new SkPDFDict("ExtGState");
noSMaskGS->insertName("SMask", "None");
return noSMaskGS;
}
-} // namespace
-SK_DECLARE_STATIC_LAZY_PTR(SkPDFDict,
- noSMaskGraphicState,
- create_no_smask_graphic_state,
- unref<SkPDFDict>);
+SK_DECLARE_STATIC_ONCE_PTR(SkPDFDict, noSMaskGraphicState);
// static
SkPDFDict* SkPDFGraphicState::GetNoSMaskGraphicState() {
- return SkRef(noSMaskGraphicState.get());
+ return SkRef(noSMaskGraphicState.get(create_no_smask_graphic_state));
}
void SkPDFGraphicState::emitObject(
« no previous file with comments | « src/opts/opts_check_x86.cpp ('k') | src/pdf/SkPDFShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698