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

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

Issue 1208993017: Add image->bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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
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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 // Encoded version? 256 // Encoded version?
257 if (SkData* encoded = pr->refEncodedData()) { 257 if (SkData* encoded = pr->refEncodedData()) {
258 SkAutoTUnref<SkData> data(encoded); 258 SkAutoTUnref<SkData> data(encoded);
259 return SkImage::NewFromEncoded(encoded); // todo: add origin/subset/et c? 259 return SkImage::NewFromEncoded(encoded); // todo: add origin/subset/et c?
260 } 260 }
261 261
262 // This will check for immutable (share or copy) 262 // This will check for immutable (share or copy)
263 return SkNewImageFromRasterBitmap(bm, false, NULL); 263 return SkNewImageFromRasterBitmap(bm, false, NULL);
264 } 264 }
265 265
266 bool SkImage::asBitmap(SkBitmap* bitmap, AsBitmapMode mode) const {
267 return as_IB(this)->onAsBitmap(bitmap, mode);
268 }
269
270 bool SkImage_Base::onAsBitmap(SkBitmap* bitmap, AsBitmapMode) const {
271 // As the base-class, all we can do is make a copy (regardless of mode).
272 // Subclasses that want to be more optimal should override.
273 SkImageInfo info = SkImageInfo::MakeN32(this->width(), this->height(),
274 this->isOpaque() ? kOpaque_SkAlphaType : kPr emul_SkAlphaType);
275 if (!bitmap->tryAllocPixels(info)) {
276 return false;
277 }
278 return this->readPixels(bitmap->info(), bitmap->getPixels(), bitmap->rowByte s(), 0, 0);
279 }
280
266 //////////////////////////////////////////////////////////////////////////////// ////// 281 //////////////////////////////////////////////////////////////////////////////// //////
267 282
268 #if !SK_SUPPORT_GPU 283 #if !SK_SUPPORT_GPU
269 284
270 SkImage* SkImage::NewFromTexture(GrContext*, const GrBackendTextureDesc&, SkAlph aType, 285 SkImage* SkImage::NewFromTexture(GrContext*, const GrBackendTextureDesc&, SkAlph aType,
271 TextureReleaseProc, ReleaseContext) { 286 TextureReleaseProc, ReleaseContext) {
272 return NULL; 287 return NULL;
273 } 288 }
274 289
275 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType) { 290 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType) {
276 return NULL; 291 return NULL;
277 } 292 }
278 293
279 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk AlphaType) { 294 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk AlphaType) {
280 return NULL; 295 return NULL;
281 } 296 }
282 297
283 #endif 298 #endif
OLDNEW
« include/core/SkImage.h ('K') | « include/core/SkImage.h ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698