aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/gpu/GrTexture.h10
-rw-r--r--src/gpu/GrTexture.cpp10
-rw-r--r--src/gpu/GrTexturePriv.h9
-rw-r--r--src/gpu/SkGr.cpp11
-rw-r--r--src/gpu/gl/GrGLGpu.cpp16
5 files changed, 32 insertions, 24 deletions
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index 2eccd575ef..211f1937da 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -53,7 +53,7 @@ protected:
private:
void computeScratchKey(GrScratchKey*) const override;
size_t onGpuMemorySize() const override;
- void dirtyMipMaps(bool mipMapsDirty, bool sRGBCorrect);
+ void dirtyMipMaps(bool mipMapsDirty);
enum MipMapsStatus {
kNotAllocated_MipMapsStatus,
@@ -61,10 +61,10 @@ private:
kValid_MipMapsStatus
};
- GrSLType fSamplerType;
- MipMapsStatus fMipMapsStatus;
- int fMaxMipMapLevel;
- bool fMipMapsAreSRGBCorrect;
+ GrSLType fSamplerType;
+ MipMapsStatus fMipMapsStatus;
+ int fMaxMipMapLevel;
+ SkSourceGammaTreatment fGammaTreatment;
friend class GrTexturePriv;
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index 9209dbd053..683458182e 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -18,7 +18,7 @@
#include "SkMipMap.h"
#include "SkTypes.h"
-void GrTexture::dirtyMipMaps(bool mipMapsDirty, bool sRGBCorrect) {
+void GrTexture::dirtyMipMaps(bool mipMapsDirty) {
if (mipMapsDirty) {
if (kValid_MipMapsStatus == fMipMapsStatus) {
fMipMapsStatus = kAllocated_MipMapsStatus;
@@ -26,7 +26,6 @@ void GrTexture::dirtyMipMaps(bool mipMapsDirty, bool sRGBCorrect) {
} else {
const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus;
fMipMapsStatus = kValid_MipMapsStatus;
- fMipMapsAreSRGBCorrect = sRGBCorrect;
if (sizeChanged) {
// This must not be called until after changing fMipMapsStatus.
this->didChangeGpuMemorySize();
@@ -90,16 +89,15 @@ GrSurfaceOrigin resolve_origin(const GrSurfaceDesc& desc) {
GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType,
bool wasMipMapDataProvided)
: INHERITED(gpu, desc)
- , fSamplerType(samplerType) {
+ , fSamplerType(samplerType)
+ // Gamma treatment is explicitly set after creation via GrTexturePriv
+ , fGammaTreatment(SkSourceGammaTreatment::kIgnore) {
if (wasMipMapDataProvided) {
fMipMapsStatus = kValid_MipMapsStatus;
fMaxMipMapLevel = SkMipMap::ComputeLevelCount(fDesc.fWidth, fDesc.fHeight);
- // At the moment, the CPU code for generating mipmaps doesn't account for sRGB:
- fMipMapsAreSRGBCorrect = false;
} else {
fMipMapsStatus = kNotAllocated_MipMapsStatus;
fMaxMipMapLevel = 0;
- fMipMapsAreSRGBCorrect = false;
}
}
diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h
index 762890fcc0..c4e6538d16 100644
--- a/src/gpu/GrTexturePriv.h
+++ b/src/gpu/GrTexturePriv.h
@@ -29,8 +29,8 @@ public:
return 0 != (fTexture->fDesc.fFlags & flags);
}
- void dirtyMipMaps(bool mipMapsDirty, bool sRGBCorrect = false) {
- fTexture->dirtyMipMaps(mipMapsDirty, sRGBCorrect);
+ void dirtyMipMaps(bool mipMapsDirty) {
+ fTexture->dirtyMipMaps(mipMapsDirty);
}
bool mipMapsAreDirty() const {
@@ -49,9 +49,10 @@ public:
return fTexture->fMaxMipMapLevel;
}
- bool mipMapsAreSRGBCorrect() const {
- return fTexture->fMipMapsAreSRGBCorrect;
+ void setGammaTreatment(SkSourceGammaTreatment gammaTreatment) const {
+ fTexture->fGammaTreatment = gammaTreatment;
}
+ SkSourceGammaTreatment gammaTreatment() const { return fTexture->fGammaTreatment; }
static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index cf50f6004e..c2e284154a 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -14,6 +14,7 @@
#include "GrGpuResourcePriv.h"
#include "GrImageIDTextureAdjuster.h"
#include "GrTextureParamsAdjuster.h"
+#include "GrTexturePriv.h"
#include "GrTypes.h"
#include "GrXferProcessor.h"
#include "GrYUVProvider.h"
@@ -385,8 +386,14 @@ GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b
texels[i].fRowBytes = generatedMipLevel.fPixmap.rowBytes();
}
- return ctx->textureProvider()->createMipMappedTexture(desc, SkBudgeted::kYes, texels.get(),
- mipLevelCount);
+ {
+ GrTexture* texture = ctx->textureProvider()->createMipMappedTexture(desc,
+ SkBudgeted::kYes,
+ texels.get(),
+ mipLevelCount);
+ texture->texturePriv().setGammaTreatment(gammaTreatment);
+ return texture;
+ }
}
GrTexture* GrUploadMipMapToTexture(GrContext* ctx, const SkImageInfo& info,
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index de60be6b06..d19afaff2e 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -3192,11 +3192,8 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, bool allow
newTexParams.fMinFilter = glMinFilterModes[filterMode];
newTexParams.fMagFilter = glMagFilterModes[filterMode];
- bool enableSRGBDecode = false;
if (GrPixelConfigIsSRGB(texture->config())) {
- enableSRGBDecode = allowSRGBInputs;
-
- newTexParams.fSRGBDecode = enableSRGBDecode ? GR_GL_DECODE_EXT : GR_GL_SKIP_DECODE_EXT;
+ newTexParams.fSRGBDecode = allowSRGBInputs ? GR_GL_DECODE_EXT : GR_GL_SKIP_DECODE_EXT;
if (setAll || newTexParams.fSRGBDecode != oldTexParams.fSRGBDecode) {
this->setTextureUnit(unitIdx);
GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SRGB_DECODE_EXT, newTexParams.fSRGBDecode));
@@ -3208,7 +3205,9 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, bool allow
if (GrTextureParams::kMipMap_FilterMode == filterMode) {
SkASSERT(!texture->texturePriv().mipMapsAreDirty());
if (GrPixelConfigIsSRGB(texture->config())) {
- SkASSERT(texture->texturePriv().mipMapsAreSRGBCorrect() == enableSRGBDecode);
+ SkSourceGammaTreatment gammaTreatment = allowSRGBInputs ?
+ SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
+ SkASSERT(texture->texturePriv().gammaTreatment() == gammaTreatment);
}
}
#endif
@@ -3321,8 +3320,10 @@ void GrGLGpu::generateMipmaps(const GrTextureParams& params, bool allowSRGBInput
// If this is an sRGB texture and the mips were previously built the "other" way
// (gamma-correct vs. not), then we need to rebuild them. We don't need to check for
// srgbSupport - we'll *never* get an sRGB pixel config if we don't support it.
+ SkSourceGammaTreatment gammaTreatment = allowSRGBInputs
+ ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
if (GrPixelConfigIsSRGB(texture->config()) &&
- allowSRGBInputs != texture->texturePriv().mipMapsAreSRGBCorrect()) {
+ gammaTreatment != texture->texturePriv().gammaTreatment()) {
texture->texturePriv().dirtyMipMaps(true);
}
@@ -3354,9 +3355,10 @@ void GrGLGpu::generateMipmaps(const GrTextureParams& params, bool allowSRGBInput
GL_CALL(GenerateMipmap(target));
}
- texture->texturePriv().dirtyMipMaps(false, allowSRGBInputs);
+ texture->texturePriv().dirtyMipMaps(false);
texture->texturePriv().setMaxMipMapLevel(SkMipMap::ComputeLevelCount(
texture->width(), texture->height()));
+ texture->texturePriv().setGammaTreatment(gammaTreatment);
// We have potentially set lots of state on the texture. Easiest to dirty it all:
texture->textureParamsModified();