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

Unified Diff: src/pdf/SkPDFGraphicState.cpp

Issue 1334523002: Revert of Port uses of SkLazyPtr to SkOncePtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 0ad1853f3e9b1e6ed77ffc4a9b9274475a51860c..162ddc8447161779fbb7fe30a084ebcfa27cc4c3 100644
--- a/src/pdf/SkPDFGraphicState.cpp
+++ b/src/pdf/SkPDFGraphicState.cpp
@@ -6,7 +6,7 @@
*/
#include "SkData.h"
-#include "SkOncePtr.h"
+#include "SkLazyPtr.h"
#include "SkPDFCanon.h"
#include "SkPDFFormXObject.h"
#include "SkPDFGraphicState.h"
@@ -126,7 +126,8 @@
return pdfGraphicState;
}
-static SkPDFObject* create_invert_function() {
+namespace {
+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);
@@ -146,7 +147,13 @@
return invertFunction;
}
-SK_DECLARE_STATIC_ONCE_PTR(SkPDFObject, invertFunction);
+template <typename T> void unref(T* ptr) { ptr->unref(); }
+} // namespace
+
+SK_DECLARE_STATIC_LAZY_PTR(SkPDFObject,
+ invertFunction,
+ create_invert_function,
+ unref<SkPDFObject>);
// static
SkPDFDict* SkPDFGraphicState::GetSMaskGraphicState(SkPDFFormXObject* sMask,
@@ -162,7 +169,7 @@
}
sMaskDict->insertObjRef("G", SkRef(sMask));
if (invert) {
- sMaskDict->insertObjRef("TR", SkRef(invertFunction.get(create_invert_function)));
+ sMaskDict->insertObjRef("TR", SkRef(invertFunction.get()));
}
SkPDFDict* result = new SkPDFDict("ExtGState");
@@ -170,16 +177,21 @@
return result;
}
-static SkPDFDict* create_no_smask_graphic_state() {
+namespace {
+SkPDFDict* create_no_smask_graphic_state() {
SkPDFDict* noSMaskGS = new SkPDFDict("ExtGState");
noSMaskGS->insertName("SMask", "None");
return noSMaskGS;
}
-SK_DECLARE_STATIC_ONCE_PTR(SkPDFDict, noSMaskGraphicState);
+} // namespace
+SK_DECLARE_STATIC_LAZY_PTR(SkPDFDict,
+ noSMaskGraphicState,
+ create_no_smask_graphic_state,
+ unref<SkPDFDict>);
// static
SkPDFDict* SkPDFGraphicState::GetNoSMaskGraphicState() {
- return SkRef(noSMaskGraphicState.get(create_no_smask_graphic_state));
+ return SkRef(noSMaskGraphicState.get());
}
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