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

Unified Diff: src/core/SkMatrix.cpp

Issue 26905002: SK_ONCE for SkMatrix::I() (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: pleasant note Created 7 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMatrix.cpp
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 3a5ab622197694edfa89358ee3187b1ccff07042..d802e1c5653142add278d7402a973d70ed959375 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -8,6 +8,7 @@
#include "SkMatrix.h"
#include "Sk64.h"
#include "SkFloatBits.h"
+#include "SkOnce.h"
#include "SkScalarCompare.h"
#include "SkString.h"
@@ -1893,13 +1894,14 @@ SkScalar SkMatrix::getMaxStretch() const {
return SkScalarSqrt(largerRoot);
}
+DEF_SK_ONCE(reset_identity_matrix, SkMatrix* identity) {
+ identity->reset();
+}
+
const SkMatrix& SkMatrix::I() {
+ // If you can use C++11 now, you might consider replacing this with a constexpr constructor.
static SkMatrix gIdentity;
- static bool gOnce;
- if (!gOnce) {
- gIdentity.reset();
- gOnce = true;
- }
+ SK_ONCE(reset_identity_matrix, &gIdentity);
return gIdentity;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698