diff options
author | 2013-10-10 21:58:31 +0000 | |
---|---|---|
committer | 2013-10-10 21:58:31 +0000 | |
commit | 21a705d2ebdf0319d45970784950886f62a77141 (patch) | |
tree | 25aca54eb41e843c9404da359ce000cee260acdc /src | |
parent | e258eb34a8ad7a6ea9546e5096da172cf2380cbd (diff) |
SK_ONCE for SkMatrix::I()
Going to start doing these in progressively larger and larger bulk,
but I figured the first few changes probably merit caution.
BUG=
R=reed@google.com, bungeman@google.com
Author: mtklein@google.com
Review URL: https://codereview.chromium.org/26905002
git-svn-id: http://skia.googlecode.com/svn/trunk@11721 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkMatrix.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp index 3a5ab62219..d802e1c565 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; } |