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

Side by Side Diff: src/image/SkImage_Raster.cpp

Issue 1282363002: Use SkImageCacherator in SkImages (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix rob comments Created 5 years, 3 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/image/SkImage_Gpu.cpp ('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 2012 Google Inc. 2 * Copyright 2012 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 "SkImage_Base.h" 8 #include "SkImage_Base.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 size_t size; 224 size_t size;
225 if (!SkImage_Raster::ValidArgs(info, rowBytes, nullptr, &size) || !pixels) { 225 if (!SkImage_Raster::ValidArgs(info, rowBytes, nullptr, &size) || !pixels) {
226 return nullptr; 226 return nullptr;
227 } 227 }
228 228
229 SkColorTable* ctable = nullptr; 229 SkColorTable* ctable = nullptr;
230 SkAutoDataUnref data(SkData::NewWithProc(pixels, size, proc, ctx)); 230 SkAutoDataUnref data(SkData::NewWithProc(pixels, size, proc, ctx));
231 return new SkImage_Raster(info, data, rowBytes, ctable, nullptr); 231 return new SkImage_Raster(info, data, rowBytes, ctable, nullptr);
232 } 232 }
233 233
234 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* s ubset) {
235 SkBitmap bitmap;
236 if (!SkInstallDiscardablePixelRef(generator, subset, &bitmap, nullptr)) {
237 return nullptr;
238 }
239 if (0 == bitmap.width() || 0 == bitmap.height()) {
240 return nullptr;
241 }
242
243 return new SkImage_Raster(bitmap, nullptr);
244 }
245
246 SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr, 234 SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr,
247 const SkIPoint& pixelRefOrigin, size_t rowBytes, 235 const SkIPoint& pixelRefOrigin, size_t rowBytes,
248 const SkSurfaceProps* props) { 236 const SkSurfaceProps* props) {
249 if (!SkImage_Raster::ValidArgs(info, rowBytes, nullptr, nullptr)) { 237 if (!SkImage_Raster::ValidArgs(info, rowBytes, nullptr, nullptr)) {
250 return nullptr; 238 return nullptr;
251 } 239 }
252 return new SkImage_Raster(info, pr, pixelRefOrigin, rowBytes, props); 240 return new SkImage_Raster(info, pr, pixelRefOrigin, rowBytes, props);
253 } 241 }
254 242
255 SkImage* SkNewImageFromRasterBitmap(const SkBitmap& bm, const SkSurfaceProps* pr ops, 243 SkImage* SkNewImageFromRasterBitmap(const SkBitmap& bm, const SkSurfaceProps* pr ops,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // pixelref since the caller might call setImmutable() themselves 282 // pixelref since the caller might call setImmutable() themselves
295 // (thus changing our state). 283 // (thus changing our state).
296 if (fBitmap.isImmutable()) { 284 if (fBitmap.isImmutable()) {
297 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); 285 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes());
298 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); 286 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin());
299 return true; 287 return true;
300 } 288 }
301 } 289 }
302 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); 290 return this->INHERITED::onAsLegacyBitmap(bitmap, mode);
303 } 291 }
292
293 #ifdef SK_SUPPORT_LEGACY_NEWFROMGENERATOR
294 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* s ubset) {
295 SkBitmap bitmap;
296 if (!SkInstallDiscardablePixelRef(generator, subset, &bitmap, nullptr)) {
297 return nullptr;
298 }
299 if (0 == bitmap.width() || 0 == bitmap.height()) {
300 return nullptr;
301 }
302 return new SkImage_Raster(bitmap, nullptr);
303 }
304 #endif
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698