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
This commit is contained in:
commit-bot@chromium.org 2013-10-10 21:58:31 +00:00
parent e258eb34a8
commit 21a705d2eb

View File

@ -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;
}