Proof of adoption in SkRecord::replace.

It used to be an unenforced requirement that callers take ownership of
the command which was replaced when calling SkRecord::replace.  Now we
can enforce it, by splitting replace into two modes:
  - T* replace(i): always destroys the existing command for you
  - T* replace(i, proofOfAdoption): proofOfAdoption is checked to make
    sure the caller has adopted the existing command before replacing it.

BUG=skia:2378
R=fmalita@chromium.org, mtklein@google.com

Author: mtklein@chromium.org

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

git-svn-id: http://skia.googlecode.com/svn/trunk@14352 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/record/SkRecords.h b/src/record/SkRecords.h
index 8b96e8d..bfa1549 100644
--- a/src/record/SkRecords.h
+++ b/src/record/SkRecords.h
@@ -133,7 +133,12 @@
 class Adopted : SkNoncopyable {
 public:
     Adopted(T* ptr) : fPtr(ptr) { SkASSERT(fPtr); }
-    ~Adopted() { fPtr->~T(); }
+    Adopted(Adopted* source) {
+        // Transfer ownership from source to this.
+        fPtr = source->fPtr;
+        source->fPtr = NULL;
+    }
+    ~Adopted() { if (fPtr) fPtr->~T(); }
 
     ACT_AS_PTR(fPtr);
 private:
@@ -142,9 +147,10 @@
 
 // PODArray doesn't own the pointer's memory, and we assume the data is POD.
 template <typename T>
-class PODArray : SkNoncopyable {
+class PODArray {
 public:
     PODArray(T* ptr) : fPtr(ptr) {}
+    // Default copy and assign.
 
     ACT_AS_PTR(fPtr);
 private: