OLD | NEW |
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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 const SkImageInfo info = bm.info(); | 250 const SkImageInfo info = bm.info(); |
251 return SkNEW_ARGS(SkImage_Gpu, (info.width(), info.height(), info.alphaT
ype(), | 251 return SkNEW_ARGS(SkImage_Gpu, (info.width(), info.height(), info.alphaT
ype(), |
252 tex, 0, SkSurface::kNo_Budgeted)); | 252 tex, 0, SkSurface::kNo_Budgeted)); |
253 } | 253 } |
254 #endif | 254 #endif |
255 | 255 |
256 // This will check for immutable (share or copy) | 256 // This will check for immutable (share or copy) |
257 return SkNewImageFromRasterBitmap(bm, false, NULL); | 257 return SkNewImageFromRasterBitmap(bm, false, NULL); |
258 } | 258 } |
259 | 259 |
| 260 bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const { |
| 261 return as_IB(this)->onAsLegacyBitmap(bitmap, mode); |
| 262 } |
| 263 |
| 264 bool SkImage_Base::onAsLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) con
st { |
| 265 // As the base-class, all we can do is make a copy (regardless of mode). |
| 266 // Subclasses that want to be more optimal should override. |
| 267 SkImageInfo info = SkImageInfo::MakeN32(this->width(), this->height(), |
| 268 this->isOpaque() ? kOpaque_SkAlphaType : kPr
emul_SkAlphaType); |
| 269 if (!bitmap->tryAllocPixels(info)) { |
| 270 return false; |
| 271 } |
| 272 if (!this->readPixels(bitmap->info(), bitmap->getPixels(), bitmap->rowBytes(
), 0, 0)) { |
| 273 bitmap->reset(); |
| 274 return false; |
| 275 } |
| 276 |
| 277 if (kRO_LegacyBitmapMode == mode) { |
| 278 bitmap->setImmutable(); |
| 279 } |
| 280 return true; |
| 281 } |
| 282 |
260 ////////////////////////////////////////////////////////////////////////////////
////// | 283 ////////////////////////////////////////////////////////////////////////////////
////// |
261 | 284 |
262 #if !SK_SUPPORT_GPU | 285 #if !SK_SUPPORT_GPU |
263 | 286 |
264 SkImage* SkImage::NewFromTexture(GrContext*, const GrBackendTextureDesc&, SkAlph
aType, | 287 SkImage* SkImage::NewFromTexture(GrContext*, const GrBackendTextureDesc&, SkAlph
aType, |
265 TextureReleaseProc, ReleaseContext) { | 288 TextureReleaseProc, ReleaseContext) { |
266 return NULL; | 289 return NULL; |
267 } | 290 } |
268 | 291 |
269 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&,
SkAlphaType) { | 292 SkImage* SkImage::NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&,
SkAlphaType) { |
270 return NULL; | 293 return NULL; |
271 } | 294 } |
272 | 295 |
273 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk
AlphaType) { | 296 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk
AlphaType) { |
274 return NULL; | 297 return NULL; |
275 } | 298 } |
276 | 299 |
277 #endif | 300 #endif |
OLD | NEW |