SK_ONCE for SkData and SkPathRef

Adds SK_ONCE_FRIEND, to allow SK_DEF_ONCE code to be friends with a class.  This had to go in include/core to be visible to headers there.

BUG=
R=reed@google.com, bungeman@google.com

Author: mtklein@google.com

Review URL: https://codereview.chromium.org/26491003

git-svn-id: http://skia.googlecode.com/svn/trunk@11914 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp
index aeef227..f635c2a 100644
--- a/src/core/SkPathRef.cpp
+++ b/src/core/SkPathRef.cpp
@@ -6,6 +6,7 @@
  */
 
 #include "SkBuffer.h"
+#include "SkOnce.h"
 #include "SkPath.h"
 #include "SkPathRef.h"
 
@@ -36,6 +37,18 @@
 }
 
 //////////////////////////////////////////////////////////////////////////////
+void SkPathRef::CreateEmptyImpl(SkPathRef** empty) {
+    *empty = SkNEW(SkPathRef);
+    (*empty)->computeBounds();  // Preemptively avoid a race to clear fBoundsIsDirty.
+}
+
+SkPathRef* SkPathRef::CreateEmpty() {
+    static SkPathRef* gEmptyPathRef;
+    SK_DECLARE_STATIC_ONCE(once);
+    SkOnce(&once, SkPathRef::CreateEmptyImpl, &gEmptyPathRef);
+    return SkRef(gEmptyPathRef);
+}
+
 void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst,
                                       const SkPathRef& src,
                                       const SkMatrix& matrix) {