aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/SkGpuDevice.cpp
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/gpu/SkGpuDevice.cpp
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/gpu/SkGpuDevice.cpp')
-rw-r--r--src/gpu/SkGpuDevice.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 406dedb0a7..81e955d702 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -80,21 +80,23 @@ public:
AutoBitmapTexture(GrContext* context,
const SkBitmap& bitmap,
const GrTextureParams& params,
+ SkSourceGammaTreatment gammaTreatment,
GrTexture** texture) {
SkASSERT(texture);
- *texture = this->set(context, bitmap, params);
+ *texture = this->set(context, bitmap, params, gammaTreatment);
}
GrTexture* set(GrContext* context,
const SkBitmap& bitmap,
- const GrTextureParams& params) {
+ const GrTextureParams& params,
+ SkSourceGammaTreatment gammaTreatment) {
// Either get the texture directly from the bitmap, or else use the cache and
// remember to unref it.
if (GrTexture* bmpTexture = bitmap.getTexture()) {
fTexture.reset(nullptr);
return bmpTexture;
} else {
- fTexture.reset(GrRefCachedBitmapTexture(context, bitmap, params));
+ fTexture.reset(GrRefCachedBitmapTexture(context, bitmap, params, gammaTreatment));
return fTexture.get();
}
}
@@ -260,7 +262,8 @@ void SkGpuDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitma
GrTexture* texture;
// draw sprite neither filters nor tiles.
- AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(), &texture);
+ AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(),
+ SkSourceGammaTreatment::kRespect, &texture);
if (!texture) {
return;
}
@@ -1165,7 +1168,9 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
bitmap.height() <= fContext->caps()->maxTileSize()));
GrTexture* texture;
- AutoBitmapTexture abt(fContext, bitmap, params, &texture);
+ SkSourceGammaTreatment gammaTreatment = this->surfaceProps().isGammaCorrect()
+ ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
+ AutoBitmapTexture abt(fContext, bitmap, params, gammaTreatment, &texture);
if (nullptr == texture) {
return;
}
@@ -1264,7 +1269,8 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
GrTexture* texture;
// draw sprite neither filters nor tiles.
- AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(), &texture);
+ AutoBitmapTexture abt(fContext, bitmap, GrTextureParams::ClampNoFilter(),
+ SkSourceGammaTreatment::kRespect, &texture);
if (!texture) {
return;
}
@@ -1520,15 +1526,17 @@ void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc
}
static const GrTextureParams::FilterMode kMode = GrTextureParams::kNone_FilterMode;
+ bool gammaCorrect = this->surfaceProps().isGammaCorrect();
+ SkSourceGammaTreatment gammaTreatment = gammaCorrect
+ ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
SkAutoTUnref<const GrFragmentProcessor> fp(
producer->createFragmentProcessor(SkMatrix::I(),
SkRect::MakeIWH(producer->width(), producer->height()),
GrTextureProducer::kNo_FilterConstraint, true,
- &kMode));
+ &kMode, gammaTreatment));
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, fp,
- producer->isAlphaOnly(),
- this->surfaceProps().isGammaCorrect(), &grPaint)) {
+ producer->isAlphaOnly(), gammaCorrect, &grPaint)) {
return;
}