aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image
diff options
context:
space:
mode:
authorGravatar brianosman <brianosman@google.com>2016-06-06 13:10:58 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-06-06 13:10:58 -0700
commit982eb7f377a0c771345276558072deb2fcea0d3e (patch)
tree02ae878610160d6b6c91629424aaf895e5f17497 /src/image
parentdc27a648d2ff23b2e96232c00c15976c46e1d48d (diff)
Add new SkSourceGammaTreatment enum, used in situations like mipmap construction, where we need to know if we should respect (vs. ignore) the gamma encoding of sRGB tagged images. Plumb that extensively.
Diffstat (limited to 'src/image')
-rw-r--r--src/image/SkImageShader.cpp12
-rw-r--r--src/image/SkImageShader.h3
-rw-r--r--src/image/SkImage_Base.h3
-rw-r--r--src/image/SkImage_Generator.cpp8
-rw-r--r--src/image/SkImage_Gpu.cpp9
-rw-r--r--src/image/SkImage_Gpu.h3
-rw-r--r--src/image/SkImage_Raster.cpp8
7 files changed, 29 insertions, 17 deletions
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index d12ee030a2..b2fab39e11 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -83,10 +83,12 @@ void SkImageShader::toString(SkString* str) const {
#include "effects/GrBicubicEffect.h"
#include "effects/GrSimpleTextureEffect.h"
-const GrFragmentProcessor* SkImageShader::asFragmentProcessor(GrContext* context,
- const SkMatrix& viewM,
- const SkMatrix* localMatrix,
- SkFilterQuality filterQuality) const {
+const GrFragmentProcessor* SkImageShader::asFragmentProcessor(
+ GrContext* context,
+ const SkMatrix& viewM,
+ const SkMatrix* localMatrix,
+ SkFilterQuality filterQuality,
+ SkSourceGammaTreatment gammaTreatment) const {
SkMatrix matrix;
matrix.setIDiv(fImage->width(), fImage->height());
@@ -113,7 +115,7 @@ const GrFragmentProcessor* SkImageShader::asFragmentProcessor(GrContext* context
GrTextureParams::FilterMode textureFilterMode =
GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix(), &doBicubic);
GrTextureParams params(tm, textureFilterMode);
- SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, params));
+ SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, params, gammaTreatment));
if (!texture) {
return nullptr;
}
diff --git a/src/image/SkImageShader.h b/src/image/SkImageShader.h
index f466e618a0..58b22dd3af 100644
--- a/src/image/SkImageShader.h
+++ b/src/image/SkImageShader.h
@@ -23,7 +23,8 @@ public:
#if SK_SUPPORT_GPU
const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& viewM,
- const SkMatrix*, SkFilterQuality) const override;
+ const SkMatrix*, SkFilterQuality,
+ SkSourceGammaTreatment) const override;
#endif
protected:
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index 947af0e0d1..c01d9af635 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -49,7 +49,8 @@ public:
}
// Caller must call unref when they are done.
- virtual GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const = 0;
+ virtual GrTexture* asTextureRef(GrContext*, const GrTextureParams&,
+ SkSourceGammaTreatment) const = 0;
virtual sk_sp<SkImage> onMakeSubset(const SkIRect&) const = 0;
diff --git a/src/image/SkImage_Generator.cpp b/src/image/SkImage_Generator.cpp
index b117322aa6..20f4863d82 100644
--- a/src/image/SkImage_Generator.cpp
+++ b/src/image/SkImage_Generator.cpp
@@ -31,7 +31,8 @@ public:
bool isOpaque() const override { return fCache->info().isOpaque(); }
sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
bool getROPixels(SkBitmap*, CachingHint) const override;
- GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override;
+ GrTexture* asTextureRef(GrContext*, const GrTextureParams&,
+ SkSourceGammaTreatment) const override;
bool onIsLazyGenerated() const override { return true; }
private:
@@ -73,8 +74,9 @@ bool SkImage_Generator::getROPixels(SkBitmap* bitmap, CachingHint chint) const {
return fCache->lockAsBitmap(bitmap, this, chint);
}
-GrTexture* SkImage_Generator::asTextureRef(GrContext* ctx, const GrTextureParams& params) const {
- return fCache->lockAsTexture(ctx, params, this);
+GrTexture* SkImage_Generator::asTextureRef(GrContext* ctx, const GrTextureParams& params,
+ SkSourceGammaTreatment gammaTreatment) const {
+ return fCache->lockAsTexture(ctx, params, gammaTreatment, this);
}
sk_sp<SkImage> SkImage_Generator::onMakeSubset(const SkIRect& subset) const {
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index a728c3dae5..0c4769fa95 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -77,8 +77,10 @@ bool SkImage_Gpu::asBitmapForImageFilters(SkBitmap* bitmap) const {
return true;
}
-GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& params) const {
- return GrImageTextureAdjuster(as_IB(this)).refTextureSafeForParams(params, nullptr);
+GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& params,
+ SkSourceGammaTreatment gammaTreatment) const {
+ return GrImageTextureAdjuster(as_IB(this)).refTextureSafeForParams(params, gammaTreatment,
+ nullptr);
}
bool SkImage_Gpu::isOpaque() const {
@@ -277,7 +279,8 @@ sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace
}
static sk_sp<SkImage> create_image_from_maker(GrTextureMaker* maker, SkAlphaType at, uint32_t id) {
- SkAutoTUnref<GrTexture> texture(maker->refTextureForParams(GrTextureParams::ClampNoFilter()));
+ SkAutoTUnref<GrTexture> texture(maker->refTextureForParams(GrTextureParams::ClampNoFilter(),
+ SkSourceGammaTreatment::kRespect));
if (!texture) {
return nullptr;
}
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index 612741ee7b..3cef934032 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -39,7 +39,8 @@ public:
}
bool getROPixels(SkBitmap*, CachingHint) const override;
- GrTexture* asTextureRef(GrContext* ctx, const GrTextureParams& params) const override;
+ GrTexture* asTextureRef(GrContext* ctx, const GrTextureParams& params,
+ SkSourceGammaTreatment) const override;
sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
GrTexture* peekTexture() const override { return fTexture; }
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index a67128a6a3..338c778ad9 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -82,7 +82,8 @@ public:
bool onPeekPixels(SkPixmap*) const override;
SkData* onRefEncoded(GrContext*) const override;
bool getROPixels(SkBitmap*, CachingHint) const override;
- GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override;
+ GrTexture* asTextureRef(GrContext*, const GrTextureParams&,
+ SkSourceGammaTreatment) const override;
sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
// exposed for SkSurface_Raster via SkNewImageFromPixelRef
@@ -174,13 +175,14 @@ bool SkImage_Raster::getROPixels(SkBitmap* dst, CachingHint) const {
return true;
}
-GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& params) const {
+GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& params,
+ SkSourceGammaTreatment gammaTreatment) const {
#if SK_SUPPORT_GPU
if (!ctx) {
return nullptr;
}
- return GrRefCachedBitmapTexture(ctx, fBitmap, params);
+ return GrRefCachedBitmapTexture(ctx, fBitmap, params, gammaTreatment);
#endif
return nullptr;