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

Unified Diff: src/gpu/GrImageIDTextureAdjuster.cpp

Issue 1507973005: Make "alpha only" be a property of GrTextureProducer (Closed) Base URL: https://skia.googlesource.com/skia.git@producernine
Patch Set: fix unused var Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/gpu/GrTextureParamsAdjuster.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | src/gpu/GrTextureParamsAdjuster.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698