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 "SkBitmapCache.h" | 9 #include "SkBitmapCache.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 return SkMakeImageFromRasterBitmap(bm); | 312 return SkMakeImageFromRasterBitmap(bm); |
313 } | 313 } |
314 | 314 |
315 bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const { | 315 bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const { |
316 return as_IB(this)->onAsLegacyBitmap(bitmap, mode); | 316 return as_IB(this)->onAsLegacyBitmap(bitmap, mode); |
317 } | 317 } |
318 | 318 |
319 bool SkImage_Base::onAsLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) con
st { | 319 bool SkImage_Base::onAsLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) con
st { |
320 // As the base-class, all we can do is make a copy (regardless of mode). | 320 // As the base-class, all we can do is make a copy (regardless of mode). |
321 // Subclasses that want to be more optimal should override. | 321 // Subclasses that want to be more optimal should override. |
322 SkImageInfo info = SkImageInfo::MakeN32(this->width(), this->height(), | 322 SkImageInfo info = this->onImageInfo().makeColorType(kN32_SkColorType) |
323 this->isOpaque() ? kOpaque_SkAlphaType : kPr
emul_SkAlphaType); | 323 .makeAlphaType(this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAl
phaType); |
324 if (!bitmap->tryAllocPixels(info)) { | 324 if (!bitmap->tryAllocPixels(info)) { |
325 return false; | 325 return false; |
326 } | 326 } |
327 if (!this->readPixels(bitmap->info(), bitmap->getPixels(), bitmap->rowBytes(
), 0, 0)) { | 327 if (!this->readPixels(bitmap->info(), bitmap->getPixels(), bitmap->rowBytes(
), 0, 0)) { |
328 bitmap->reset(); | 328 bitmap->reset(); |
329 return false; | 329 return false; |
330 } | 330 } |
331 | 331 |
332 if (kRO_LegacyBitmapMode == mode) { | 332 if (kRO_LegacyBitmapMode == mode) { |
333 bitmap->setImmutable(); | 333 bitmap->setImmutable(); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 SkImage* SkImage::NewFromDeferredTextureImageData(GrContext* ctx, const void* da
ta, | 497 SkImage* SkImage::NewFromDeferredTextureImageData(GrContext* ctx, const void* da
ta, |
498 SkBudgeted budgeted) { | 498 SkBudgeted budgeted) { |
499 return MakeFromDeferredTextureImageData(ctx, data, budgeted).release(); | 499 return MakeFromDeferredTextureImageData(ctx, data, budgeted).release(); |
500 } | 500 } |
501 #endif | 501 #endif |
502 | 502 |
503 sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&, const GrMip
Level* texels, | 503 sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&, const GrMip
Level* texels, |
504 int mipLevelCount, SkBudgeted) { | 504 int mipLevelCount, SkBudgeted) { |
505 return nullptr; | 505 return nullptr; |
506 } | 506 } |
OLD | NEW |