SkData need not be a Flattenable, since it does not need subclass/factories

BUG=
R=mtklein@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk/include@11754 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/core/SkData.h b/core/SkData.h
index 6f883c8..c244cb8 100644
--- a/core/SkData.h
+++ b/core/SkData.h
@@ -11,7 +11,7 @@
 #ifndef SkData_DEFINED
 #define SkData_DEFINED
 
-#include "SkFlattenable.h"
+#include "SkRefCnt.h"
 
 struct SkFILE;
 
@@ -20,7 +20,7 @@
  *  but the actual ptr that is returned (by data() or bytes()) is guaranteed
  *  to always be the same for the life of this instance.
  */
-class SK_API SkData : public SkFlattenable {
+class SK_API SkData : public SkRefCnt {
 public:
     SK_DECLARE_INST_COUNT(SkData)
 
@@ -126,12 +126,6 @@
      */
     static SkData* NewEmpty();
 
-    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkData)
-
-protected:
-    SkData(SkFlattenableReadBuffer&);
-    virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
-
 private:
     ReleaseProc fReleaseProc;
     void*       fReleaseProcContext;
@@ -142,7 +136,7 @@
     SkData(const void* ptr, size_t size, ReleaseProc, void* context);
     virtual ~SkData();
 
-    typedef SkFlattenable INHERITED;
+    typedef SkRefCnt INHERITED;
 };
 
 /** Typedef of SkAutoTUnref<SkData> for automatically unref-ing a SkData. */
diff --git a/core/SkFlattenableBuffers.h b/core/SkFlattenableBuffers.h
index 03c03f3..dd51e08 100644
--- a/core/SkFlattenableBuffers.h
+++ b/core/SkFlattenableBuffers.h
@@ -10,6 +10,7 @@
 #define SkFlattenableBuffers_DEFINED
 
 #include "SkColor.h"
+#include "SkData.h"
 #include "SkPaint.h"
 #include "SkPoint.h"
 
@@ -97,6 +98,13 @@
         this->readPoint(&point);
         return point;
     }
+    
+    SkData* readByteArrayAsData() {
+        size_t len = this->getArrayCount();
+        void* buffer = sk_malloc_throw(len);
+        (void)this->readByteArray(buffer);
+        return SkData::NewFromMalloc(buffer, len);
+    }
 
     template <typename T> T* readFlattenableT() {
         return static_cast<T*>(this->readFlattenable());
@@ -165,6 +173,10 @@
 
     bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; }
 
+    void writeDataAsByteArray(SkData* data) {
+        this->writeByteArray(data->data(), data->size());
+    }
+
 protected:
     // A helper function so that each subclass does not have to be a friend of SkFlattenable
     void flattenObject(SkFlattenable* obj, SkFlattenableWriteBuffer& buffer);