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

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: now with mutex safeness Created 5 years, 4 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
« src/image/SkImage_Generator.cpp ('K') | « 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 size_t size; 215 size_t size;
216 if (!SkImage_Raster::ValidArgs(info, rowBytes, NULL, &size) || !pixels) { 216 if (!SkImage_Raster::ValidArgs(info, rowBytes, NULL, &size) || !pixels) {
217 return NULL; 217 return NULL;
218 } 218 }
219 219
220 SkColorTable* ctable = NULL; 220 SkColorTable* ctable = NULL;
221 SkAutoDataUnref data(SkData::NewWithProc(pixels, size, proc, ctx)); 221 SkAutoDataUnref data(SkData::NewWithProc(pixels, size, proc, ctx));
222 return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes, ctable, NULL)); 222 return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes, ctable, NULL));
223 } 223 }
224 224
225 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* s ubset) {
226 SkBitmap bitmap;
227 if (!SkInstallDiscardablePixelRef(generator, subset, &bitmap, NULL)) {
228 return NULL;
229 }
230 if (0 == bitmap.width() || 0 == bitmap.height()) {
231 return NULL;
232 }
233
234 return SkNEW_ARGS(SkImage_Raster, (bitmap, NULL));
235 }
236
237 SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr, 225 SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr,
238 const SkIPoint& pixelRefOrigin, size_t rowBytes, 226 const SkIPoint& pixelRefOrigin, size_t rowBytes,
239 const SkSurfaceProps* props) { 227 const SkSurfaceProps* props) {
240 if (!SkImage_Raster::ValidArgs(info, rowBytes, NULL, NULL)) { 228 if (!SkImage_Raster::ValidArgs(info, rowBytes, NULL, NULL)) {
241 return NULL; 229 return NULL;
242 } 230 }
243 return SkNEW_ARGS(SkImage_Raster, (info, pr, pixelRefOrigin, rowBytes, props )); 231 return SkNEW_ARGS(SkImage_Raster, (info, pr, pixelRefOrigin, rowBytes, props ));
244 } 232 }
245 233
246 SkImage* SkNewImageFromRasterBitmap(const SkBitmap& bm, const SkSurfaceProps* pr ops, 234 SkImage* SkNewImageFromRasterBitmap(const SkBitmap& bm, const SkSurfaceProps* pr ops,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // pixelref since the caller might call setImmutable() themselves 273 // pixelref since the caller might call setImmutable() themselves
286 // (thus changing our state). 274 // (thus changing our state).
287 if (fBitmap.isImmutable()) { 275 if (fBitmap.isImmutable()) {
288 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); 276 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes());
289 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); 277 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin());
290 return true; 278 return true;
291 } 279 }
292 } 280 }
293 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); 281 return this->INHERITED::onAsLegacyBitmap(bitmap, mode);
294 } 282 }
OLDNEW
« src/image/SkImage_Generator.cpp ('K') | « src/image/SkImage_Gpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698