Index: src/gpu/GrImageIDTextureAdjuster.cpp |
diff --git a/src/gpu/GrImageIDTextureAdjuster.cpp b/src/gpu/GrImageIDTextureAdjuster.cpp |
index a9189f63fab88ba161b1821283142564f57d63e0..2edff60553c2118466f5e11773bf87781309ba77 100644 |
--- a/src/gpu/GrImageIDTextureAdjuster.cpp |
+++ b/src/gpu/GrImageIDTextureAdjuster.cpp |
@@ -15,8 +15,12 @@ |
#include "SkImageCacherator.h" |
#include "SkPixelRef.h" |
+static bool bmp_is_alpha_only(const SkBitmap& bm) { return kAlpha_8_SkColorType == bm.colorType(); } |
+ |
GrBitmapTextureAdjuster::GrBitmapTextureAdjuster(const SkBitmap* bmp) |
- : INHERITED(bmp->getTexture(), SkIRect::MakeWH(bmp->width(), bmp->height())) |
+ : INHERITED(bmp->getTexture(), |
+ SkIRect::MakeWH(bmp->width(), bmp->height()), |
+ bmp_is_alpha_only(*bmp)) |
, fBmp(bmp) {} |
void GrBitmapTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) { |
@@ -39,8 +43,15 @@ void GrBitmapTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) { |
////////////////////////////////////////////////////////////////////////////// |
+// SkImage's don't have a way of communicating whether they're alpha-only. So we fallback to |
+// inspecting the texture. |
+static bool tex_image_is_alpha_only(const SkImage_Base& img) { |
+ return GrPixelConfigIsAlphaOnly(img.peekTexture()->config()); |
+} |
+ |
GrImageTextureAdjuster::GrImageTextureAdjuster(const SkImage_Base* img) |
- : INHERITED(img->peekTexture(), SkIRect::MakeWH(img->width(), img->height())) |
+ : INHERITED(img->peekTexture(), SkIRect::MakeWH(img->width(), img->height()), |
+ tex_image_is_alpha_only(*img)) |
, fImageBase(img) {} |
void GrImageTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) { |
@@ -59,7 +70,7 @@ void GrImageTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) { |
////////////////////////////////////////////////////////////////////////////// |
GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& bitmap) |
- : INHERITED(context, bitmap.width(), bitmap.height()) |
+ : INHERITED(context, bitmap.width(), bitmap.height(), bmp_is_alpha_only(bitmap)) |
, fBitmap(bitmap) { |
SkASSERT(!bitmap.getTexture()); |
if (!bitmap.isVolatile()) { |
@@ -99,10 +110,13 @@ void GrBitmapTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { |
} |
////////////////////////////////////////////////////////////////////////////// |
- |
+static bool cacher_is_alpha_only(const SkImageCacherator& cacher) { |
+ return kAlpha_8_SkColorType == cacher.info().colorType(); |
+} |
GrImageTextureMaker::GrImageTextureMaker(GrContext* context, SkImageCacherator* cacher, |
const SkImage* client, SkImage::CachingHint chint) |
- : INHERITED(context, cacher->info().width(), cacher->info().height()) |
+ : INHERITED(context, cacher->info().width(), cacher->info().height(), |
+ cacher_is_alpha_only(*cacher)) |
, fCacher(cacher) |
, fClient(client) |
, fCachingHint(chint) { |