Add a 'unique' method to SkRefCnt, document the usage, and add support.

std::shared_ptr has a method called 'unique' which captures the concept that
a reference count of 1 is special, and can be used to optimize copy on write.
It also has some undocumented need for memory barriers in certain situations
and those needs are documented here.

The motivation for looking into this is crbug.com/258499 . The use of the
reference count in this manner is a benign race with both ref() and unref().
By introducing sk_atomic_unprotected_read, it is possible for Chromium to
annotate this read to tell ThreadSanitizer that this is known.

R=bsalomon@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@10221 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
index e8b6d38..1dff7ec 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -50,7 +50,7 @@
         // the surface may need to fork its backend, if its sharing it with
         // the cached image. Note: we only call if there is an outstanding owner
         // on the image (besides us).
-        if (fCachedImage->getRefCnt() > 1) {
+        if (!fCachedImage->unique()) {
             this->onCopyOnWrite(mode);
         }