OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "SkColorPriv.h" | 8 #include "SkColorPriv.h" |
9 #include "SkConfig8888.h" | 9 #include "SkConfig8888.h" |
| 10 #include "SkData.h" |
10 #include "SkMask.h" | 11 #include "SkMask.h" |
11 #include "SkPixmap.h" | 12 #include "SkPixmap.h" |
12 #include "SkUtils.h" | 13 #include "SkUtils.h" |
13 | 14 |
14 void SkAutoPixmapUnlock::reset(const SkPixmap& pm, void (*unlock)(void*), void*
ctx) { | 15 void SkAutoPixmapUnlock::reset(const SkPixmap& pm, void (*unlock)(void*), void*
ctx) { |
15 SkASSERT(pm.addr() != nullptr); | 16 SkASSERT(pm.addr() != nullptr); |
16 | 17 |
17 this->unlock(); | 18 this->unlock(); |
18 fPixmap = pm; | 19 fPixmap = pm; |
19 fUnlockProc = unlock; | 20 fUnlockProc = unlock; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 this->reset(info, pixels, rb); | 266 this->reset(info, pixels, rb); |
266 fStorage = pixels; | 267 fStorage = pixels; |
267 return true; | 268 return true; |
268 } | 269 } |
269 | 270 |
270 void SkAutoPixmapStorage::alloc(const SkImageInfo& info) { | 271 void SkAutoPixmapStorage::alloc(const SkImageInfo& info) { |
271 if (!this->tryAlloc(info)) { | 272 if (!this->tryAlloc(info)) { |
272 sk_throw(); | 273 sk_throw(); |
273 } | 274 } |
274 } | 275 } |
| 276 |
| 277 const SkData* SkAutoPixmapStorage::detachPixelsAsData() { |
| 278 if (!fStorage) { |
| 279 return nullptr; |
| 280 } |
| 281 |
| 282 const SkData* data = SkData::NewFromMalloc(fStorage, this->getSafeSize()); |
| 283 fStorage = nullptr; |
| 284 this->INHERITED::reset(); |
| 285 |
| 286 return data; |
| 287 } |
OLD | NEW |