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

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

Issue 1808833002: Revert of Add SkSpecialImage::extractSubset & NewFromPixmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « src/core/SkAutoPixmapStorage.cpp ('k') | src/core/SkScalerContext.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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 SkPaint paint; 274 SkPaint paint;
275 paint.setFilterQuality(quality); 275 paint.setFilterQuality(quality);
276 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 276 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
277 surface->getCanvas()->drawBitmapRect(bitmap, SkRect::MakeIWH(dst.width(), ds t.height()), 277 surface->getCanvas()->drawBitmapRect(bitmap, SkRect::MakeIWH(dst.width(), ds t.height()),
278 &paint); 278 &paint);
279 return true; 279 return true;
280 } 280 }
281 281
282 //////////////////////////////////////////////////////////////////////////////// ////////////////// 282 //////////////////////////////////////////////////////////////////////////////// //////////////////
283 283
284 SkAutoPixmapStorage::SkAutoPixmapStorage() : fStorage(nullptr) {}
285
286 SkAutoPixmapStorage::~SkAutoPixmapStorage() {
287 this->freeStorage();
288 }
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
298 bool SkAutoPixmapStorage::tryAlloc(const SkImageInfo& info) {
299 this->freeStorage();
300
301 size_t rb;
302 size_t size = AllocSize(info, &rb);
303 if (0 == size) {
304 return false;
305 }
306 void* pixels = sk_malloc_flags(size, 0);
307 if (nullptr == pixels) {
308 return false;
309 }
310 this->reset(info, pixels, rb);
311 fStorage = pixels;
312 return true;
313 }
314
315 void SkAutoPixmapStorage::alloc(const SkImageInfo& info) {
316 if (!this->tryAlloc(info)) {
317 sk_throw();
318 }
319 }
320
321 const SkData* SkAutoPixmapStorage::detachPixelsAsData() {
322 if (!fStorage) {
323 return nullptr;
324 }
325
326 auto data = SkData::MakeFromMalloc(fStorage, this->getSafeSize());
327 fStorage = nullptr;
328 this->INHERITED::reset();
329
330 return data.release();
331 }
OLDNEW
« no previous file with comments | « src/core/SkAutoPixmapStorage.cpp ('k') | src/core/SkScalerContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698