Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkData_DEFINED | 8 #ifndef SkData_DEFINED |
| 9 #define SkData_DEFINED | 9 #define SkData_DEFINED |
| 10 | 10 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 ReleaseProc fReleaseProc; | 161 ReleaseProc fReleaseProc; |
| 162 void* fReleaseProcContext; | 162 void* fReleaseProcContext; |
| 163 | 163 |
| 164 void* fPtr; | 164 void* fPtr; |
| 165 size_t fSize; | 165 size_t fSize; |
| 166 | 166 |
| 167 SkData(const void* ptr, size_t size, ReleaseProc, void* context); | 167 SkData(const void* ptr, size_t size, ReleaseProc, void* context); |
| 168 SkData(size_t size); // inplace new/delete | 168 SkData(size_t size); // inplace new/delete |
| 169 virtual ~SkData(); | 169 virtual ~SkData(); |
| 170 | 170 |
| 171 virtual void internal_dispose() const SK_OVERRIDE; | 171 |
| 172 // Objects of this type are sometimes created in a custom fashion using sk_m alloc_throw and | |
| 173 // therefore must be sk_freed. We overload new to also call sk_malloc_throw so that memory | |
| 174 // can unconditionally released using sk_free in and overloaded delete. Over loading regular | |
|
mtklein
2014/11/19 21:56:59
and -> an
bsalomon
2014/11/20 14:49:57
Done, and also asserted that text blobs are always
| |
| 175 // new means we must also overload placement new. | |
| 176 void* operator new(size_t size) { return sk_malloc_throw(size); } | |
| 177 void* operator new(size_t, void* p) { return p; } | |
| 178 void operator delete(void* p) { sk_free(p); } | |
| 172 | 179 |
| 173 // Called the first time someone calls NewEmpty to initialize the singleton. | 180 // Called the first time someone calls NewEmpty to initialize the singleton. |
| 174 friend SkData* sk_new_empty_data(); | 181 friend SkData* sk_new_empty_data(); |
| 175 | 182 |
| 176 // shared internal factory | 183 // shared internal factory |
| 177 static SkData* PrivateNewWithCopy(const void* srcOrNull, size_t length); | 184 static SkData* PrivateNewWithCopy(const void* srcOrNull, size_t length); |
| 178 | 185 |
| 179 typedef SkRefCnt INHERITED; | 186 typedef SkRefCnt INHERITED; |
| 180 }; | 187 }; |
| 181 | 188 |
| 182 /** Typedef of SkAutoTUnref<SkData> for automatically unref-ing a SkData. */ | 189 /** Typedef of SkAutoTUnref<SkData> for automatically unref-ing a SkData. */ |
| 183 typedef SkAutoTUnref<SkData> SkAutoDataUnref; | 190 typedef SkAutoTUnref<SkData> SkAutoDataUnref; |
| 184 | 191 |
| 185 #endif | 192 #endif |
| OLD | NEW |