| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 | 10 |
| 11 #ifndef SkData_DEFINED | 11 #ifndef SkData_DEFINED |
| 12 #define SkData_DEFINED | 12 #define SkData_DEFINED |
| 13 | 13 |
| 14 #include "SkFlattenable.h" | 14 #include "SkRefCnt.h" |
| 15 | 15 |
| 16 struct SkFILE; | 16 struct SkFILE; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * SkData holds an immutable data buffer. Not only is the data immutable, | 19 * SkData holds an immutable data buffer. Not only is the data immutable, |
| 20 * but the actual ptr that is returned (by data() or bytes()) is guaranteed | 20 * but the actual ptr that is returned (by data() or bytes()) is guaranteed |
| 21 * to always be the same for the life of this instance. | 21 * to always be the same for the life of this instance. |
| 22 */ | 22 */ |
| 23 class SK_API SkData : public SkFlattenable { | 23 class SK_API SkData : public SkRefCnt { |
| 24 public: | 24 public: |
| 25 SK_DECLARE_INST_COUNT(SkData) | 25 SK_DECLARE_INST_COUNT(SkData) |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * Returns the number of bytes stored. | 28 * Returns the number of bytes stored. |
| 29 */ | 29 */ |
| 30 size_t size() const { return fSize; } | 30 size_t size() const { return fSize; } |
| 31 | 31 |
| 32 bool isEmpty() const { return 0 == fSize; } | 32 bool isEmpty() const { return 0 == fSize; } |
| 33 | 33 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 * src dataref. | 119 * src dataref. |
| 120 */ | 120 */ |
| 121 static SkData* NewSubset(const SkData* src, size_t offset, size_t length); | 121 static SkData* NewSubset(const SkData* src, size_t offset, size_t length); |
| 122 | 122 |
| 123 /** | 123 /** |
| 124 * Returns a new empty dataref (or a reference to a shared empty dataref). | 124 * Returns a new empty dataref (or a reference to a shared empty dataref). |
| 125 * New or shared, the caller must see that unref() is eventually called. | 125 * New or shared, the caller must see that unref() is eventually called. |
| 126 */ | 126 */ |
| 127 static SkData* NewEmpty(); | 127 static SkData* NewEmpty(); |
| 128 | 128 |
| 129 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkData) | |
| 130 | |
| 131 protected: | |
| 132 SkData(SkFlattenableReadBuffer&); | |
| 133 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; | |
| 134 | |
| 135 private: | 129 private: |
| 136 ReleaseProc fReleaseProc; | 130 ReleaseProc fReleaseProc; |
| 137 void* fReleaseProcContext; | 131 void* fReleaseProcContext; |
| 138 | 132 |
| 139 const void* fPtr; | 133 const void* fPtr; |
| 140 size_t fSize; | 134 size_t fSize; |
| 141 | 135 |
| 142 SkData(const void* ptr, size_t size, ReleaseProc, void* context); | 136 SkData(const void* ptr, size_t size, ReleaseProc, void* context); |
| 143 virtual ~SkData(); | 137 virtual ~SkData(); |
| 144 | 138 |
| 145 typedef SkFlattenable INHERITED; | 139 typedef SkRefCnt INHERITED; |
| 146 }; | 140 }; |
| 147 | 141 |
| 148 /** Typedef of SkAutoTUnref<SkData> for automatically unref-ing a SkData. */ | 142 /** Typedef of SkAutoTUnref<SkData> for automatically unref-ing a SkData. */ |
| 149 typedef SkAutoTUnref<SkData> SkAutoDataUnref; | 143 typedef SkAutoTUnref<SkData> SkAutoDataUnref; |
| 150 | 144 |
| 151 #endif | 145 #endif |
| OLD | NEW |