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

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

Issue 1776693002: Add deferred texture upload API. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase on sk_skp Created 4 years, 9 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/gpu/GrContext.h ('k') | src/gpu/GrContext.cpp » ('j') | 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 "SkData.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 280 }
281 281
282 //////////////////////////////////////////////////////////////////////////////// ////////////////// 282 //////////////////////////////////////////////////////////////////////////////// //////////////////
283 283
284 SkAutoPixmapStorage::SkAutoPixmapStorage() : fStorage(nullptr) {} 284 SkAutoPixmapStorage::SkAutoPixmapStorage() : fStorage(nullptr) {}
285 285
286 SkAutoPixmapStorage::~SkAutoPixmapStorage() { 286 SkAutoPixmapStorage::~SkAutoPixmapStorage() {
287 this->freeStorage(); 287 this->freeStorage();
288 } 288 }
289 289
290 size_t SkAutoPixmapStorage::AllocSize(const SkImageInfo& info, size_t* rowBytes) {
291 size_t rb = info.minRowBytes();
292 if (rowBytes) {
293 *rowBytes = rb;
294 }
295 return info.getSafeSize(rb);
296 }
297
290 bool SkAutoPixmapStorage::tryAlloc(const SkImageInfo& info) { 298 bool SkAutoPixmapStorage::tryAlloc(const SkImageInfo& info) {
291 this->freeStorage(); 299 this->freeStorage();
292 300
293 size_t rb = info.minRowBytes(); 301 size_t rb;
294 size_t size = info.getSafeSize(rb); 302 size_t size = AllocSize(info, &rb);
295 if (0 == size) { 303 if (0 == size) {
296 return false; 304 return false;
297 } 305 }
298 void* pixels = sk_malloc_flags(size, 0); 306 void* pixels = sk_malloc_flags(size, 0);
299 if (nullptr == pixels) { 307 if (nullptr == pixels) {
300 return false; 308 return false;
301 } 309 }
302 this->reset(info, pixels, rb); 310 this->reset(info, pixels, rb);
303 fStorage = pixels; 311 fStorage = pixels;
304 return true; 312 return true;
305 } 313 }
306 314
307 void SkAutoPixmapStorage::alloc(const SkImageInfo& info) { 315 void SkAutoPixmapStorage::alloc(const SkImageInfo& info) {
308 if (!this->tryAlloc(info)) { 316 if (!this->tryAlloc(info)) {
309 sk_throw(); 317 sk_throw();
310 } 318 }
311 } 319 }
312 320
313 const SkData* SkAutoPixmapStorage::detachPixelsAsData() { 321 const SkData* SkAutoPixmapStorage::detachPixelsAsData() {
314 if (!fStorage) { 322 if (!fStorage) {
315 return nullptr; 323 return nullptr;
316 } 324 }
317 325
318 const SkData* data = SkData::NewFromMalloc(fStorage, this->getSafeSize()); 326 const SkData* data = SkData::NewFromMalloc(fStorage, this->getSafeSize());
319 fStorage = nullptr; 327 fStorage = nullptr;
320 this->INHERITED::reset(); 328 this->INHERITED::reset();
321 329
322 return data; 330 return data;
323 } 331 }
OLDNEW
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698