diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-14 14:33:11 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-10-14 14:33:11 +0000 |
commit | da30055b296faa5a100e474e0406ef4296c14241 (patch) | |
tree | 0bcc7d20f3efea9e802b4df6ed1ab13277b2bf33 /include/core | |
parent | 9eef56bd3e260a1e6a17640be4a620bf325261e1 (diff) |
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@11754 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkData.h | 12 | ||||
-rw-r--r-- | include/core/SkFlattenableBuffers.h | 12 |
2 files changed, 15 insertions, 9 deletions
diff --git a/include/core/SkData.h b/include/core/SkData.h index 6f883c8843..c244cb8a92 100644 --- a/include/core/SkData.h +++ b/include/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 @@ struct SkFILE; * 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 @@ public: */ 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 @@ private: 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/include/core/SkFlattenableBuffers.h b/include/core/SkFlattenableBuffers.h index 03c03f3877..dd51e08967 100644 --- a/include/core/SkFlattenableBuffers.h +++ b/include/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 @@ public: 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 @@ public: 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); |