Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: src/core/SkPixmap.cpp

Issue 1662353002: Add SkAutoPixmapStorage::detachPixelsAsData() (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: detachPixelsAsData Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkPixmap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « include/core/SkPixmap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698