aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2016-11-08 17:08:54 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-09 01:05:07 +0000
commit7b8400dad2f82dcc6ed3c7cc1707ebaf85f04840 (patch)
treedc1e131776fb1922b113f1a5e723205d8c13ccfe
parentc8b15684fe5b5b924b90091fedfbedf2806535e0 (diff)
Rename SkSourceGammaTreatment to SkDestinationSurfaceColorMode
This is much more explicit about what that type represents (are we in legacy mode or not), which also makes it suitable for other (upcoming) usage. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4529 Change-Id: Iacb397c34e7765f1ca86c0195bc622b2be4d9acf Reviewed-on: https://skia-review.googlesource.com/4529 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
-rw-r--r--bench/MipMapBench.cpp21
-rw-r--r--experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp8
-rw-r--r--gm/image_pict.cpp7
-rw-r--r--gm/showmiplevels.cpp8
-rw-r--r--gm/texturedomaineffect.cpp6
-rw-r--r--gm/yuvtorgbeffect.cpp33
-rw-r--r--include/core/SkImage.h2
-rw-r--r--include/core/SkImageInfo.h6
-rw-r--r--include/core/SkShader.h18
-rw-r--r--include/gpu/GrRenderTargetContext.h6
-rw-r--r--include/gpu/GrTexture.h10
-rw-r--r--include/gpu/SkGr.h4
-rw-r--r--src/core/SkBitmapCache.cpp23
-rw-r--r--src/core/SkBitmapCache.h4
-rw-r--r--src/core/SkBitmapController.cpp25
-rw-r--r--src/core/SkBitmapController.h4
-rw-r--r--src/core/SkBitmapProcShader.cpp6
-rw-r--r--src/core/SkBitmapProcState.cpp10
-rw-r--r--src/core/SkBitmapProcState.h32
-rw-r--r--src/core/SkImageCacherator.cpp11
-rw-r--r--src/core/SkImageCacherator.h4
-rw-r--r--src/core/SkLocalMatrixShader.cpp2
-rw-r--r--src/core/SkMipMap.cpp8
-rw-r--r--src/core/SkMipMap.h15
-rw-r--r--src/core/SkPictureShader.cpp2
-rw-r--r--src/core/SkShadowShader.cpp2
-rw-r--r--src/core/SkSpecialImage.cpp22
-rw-r--r--src/effects/SkPerlinNoiseShader.cpp4
-rw-r--r--src/effects/SkTableColorFilter.cpp5
-rw-r--r--src/effects/gradients/SkGradientShader.cpp6
-rw-r--r--src/gpu/GrImageIDTextureAdjuster.cpp8
-rw-r--r--src/gpu/GrImageIDTextureAdjuster.h4
-rw-r--r--src/gpu/GrTestUtils.cpp5
-rw-r--r--src/gpu/GrTexture.cpp4
-rw-r--r--src/gpu/GrTextureParamsAdjuster.cpp20
-rw-r--r--src/gpu/GrTextureParamsAdjuster.h14
-rw-r--r--src/gpu/GrTexturePriv.h6
-rw-r--r--src/gpu/SkGpuDevice.cpp18
-rw-r--r--src/gpu/SkGpuDevice_drawTexture.cpp2
-rw-r--r--src/gpu/SkGr.cpp18
-rw-r--r--src/gpu/SkGrPriv.h3
-rw-r--r--src/gpu/gl/GrGLGpu.cpp16
-rw-r--r--src/image/SkImage.cpp2
-rw-r--r--src/image/SkImageShader.cpp3
-rw-r--r--src/image/SkImage_Base.h2
-rw-r--r--src/image/SkImage_Generator.cpp6
-rw-r--r--src/image/SkImage_Gpu.cpp49
-rw-r--r--src/image/SkImage_Gpu.h2
-rw-r--r--src/image/SkImage_Raster.cpp14
-rw-r--r--tests/MipMapTest.cpp6
-rw-r--r--tests/ResourceCacheTest.cpp2
-rw-r--r--tests/SkResourceCacheTest.cpp18
52 files changed, 272 insertions, 264 deletions
diff --git a/bench/MipMapBench.cpp b/bench/MipMapBench.cpp
index 1f41e817db..57e4588b4f 100644
--- a/bench/MipMapBench.cpp
+++ b/bench/MipMapBench.cpp
@@ -13,13 +13,13 @@ class MipMapBench: public Benchmark {
SkBitmap fBitmap;
SkString fName;
const int fW, fH;
- SkSourceGammaTreatment fTreatment;
+ SkDestinationSurfaceColorMode fColorMode;
public:
- MipMapBench(int w, int h, SkSourceGammaTreatment treatment)
- : fW(w), fH(h), fTreatment(treatment)
+ MipMapBench(int w, int h, SkDestinationSurfaceColorMode colorMode)
+ : fW(w), fH(h), fColorMode(colorMode)
{
- fName.printf("mipmap_build_%dx%d_%d_gamma", w, h, static_cast<int>(treatment));
+ fName.printf("mipmap_build_%dx%d_%d_gamma", w, h, static_cast<int>(colorMode));
}
protected:
@@ -37,7 +37,7 @@ protected:
void onDraw(int loops, SkCanvas*) override {
for (int i = 0; i < loops * 4; i++) {
- SkMipMap::Build(fBitmap, fTreatment, nullptr)->unref();
+ SkMipMap::Build(fBitmap, fColorMode, nullptr)->unref();
}
}
@@ -48,8 +48,9 @@ private:
// Build variants that exercise the width and heights being even or odd at each level, as the
// impl specializes on each of these.
//
-DEF_BENCH( return new MipMapBench(511, 511, SkSourceGammaTreatment::kIgnore); )
-DEF_BENCH( return new MipMapBench(512, 511, SkSourceGammaTreatment::kIgnore); )
-DEF_BENCH( return new MipMapBench(511, 512, SkSourceGammaTreatment::kIgnore); )
-DEF_BENCH( return new MipMapBench(512, 512, SkSourceGammaTreatment::kIgnore); )
-DEF_BENCH( return new MipMapBench(512, 512, SkSourceGammaTreatment::kRespect); )
+DEF_BENCH( return new MipMapBench(511, 511, SkDestinationSurfaceColorMode::kLegacy); )
+DEF_BENCH( return new MipMapBench(512, 511, SkDestinationSurfaceColorMode::kLegacy); )
+DEF_BENCH( return new MipMapBench(511, 512, SkDestinationSurfaceColorMode::kLegacy); )
+DEF_BENCH( return new MipMapBench(512, 512, SkDestinationSurfaceColorMode::kLegacy); )
+DEF_BENCH( return new MipMapBench(512, 512,
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware); )
diff --git a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
index fcbf017c43..130e11678b 100644
--- a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
+++ b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
@@ -1323,10 +1323,10 @@ sk_sp<GrFragmentProcessor> SkPerlinNoiseShader2::asFragmentProcessor(const AsFPA
GrTextureParams::FilterMode::kNone_FilterMode);
sk_sp<GrTexture> permutationsTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getImprovedPermutationsBitmap(),
- textureParams, args.fGammaTreatment));
+ textureParams, args.fColorMode));
sk_sp<GrTexture> gradientTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getGradientBitmap(),
- textureParams, args.fGammaTreatment));
+ textureParams, args.fColorMode));
return GrImprovedPerlinNoiseEffect::Make(fNumOctaves, fSeed, paintingData,
permutationsTexture.get(),
gradientTexture.get(), m);
@@ -1350,10 +1350,10 @@ sk_sp<GrFragmentProcessor> SkPerlinNoiseShader2::asFragmentProcessor(const AsFPA
sk_sp<GrTexture> permutationsTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getPermutationsBitmap(),
- GrTextureParams::ClampNoFilter(), args.fGammaTreatment));
+ GrTextureParams::ClampNoFilter(), args.fColorMode));
sk_sp<GrTexture> noiseTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getNoiseBitmap(),
- GrTextureParams::ClampNoFilter(), args.fGammaTreatment));
+ GrTextureParams::ClampNoFilter(), args.fColorMode));
if ((permutationsTexture) && (noiseTexture)) {
sk_sp<GrFragmentProcessor> inner(
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index 8cbd287f3b..903024b8ee 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -314,10 +314,9 @@ protected:
static void draw_as_tex(SkCanvas* canvas, SkImageCacherator* cache, SkScalar x, SkScalar y) {
#if SK_SUPPORT_GPU
- sk_sp<GrTexture> texture(cache->lockAsTexture(canvas->getGrContext(),
- GrTextureParams::ClampBilerp(),
- SkSourceGammaTreatment::kRespect,
- nullptr));
+ sk_sp<GrTexture> texture(
+ cache->lockAsTexture(canvas->getGrContext(), GrTextureParams::ClampBilerp(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware, nullptr));
if (!texture) {
// show placeholder if we have no texture
SkPaint paint;
diff --git a/gm/showmiplevels.cpp b/gm/showmiplevels.cpp
index 2386e1d3c1..a4fd16404f 100644
--- a/gm/showmiplevels.cpp
+++ b/gm/showmiplevels.cpp
@@ -139,8 +139,8 @@ protected:
baseBM.lockPixels();
baseBM.peekPixels(&prevPM);
- SkSourceGammaTreatment treatment = SkSourceGammaTreatment::kIgnore;
- sk_sp<SkMipMap> mm(SkMipMap::Build(baseBM, treatment, nullptr));
+ SkDestinationSurfaceColorMode colorMode = SkDestinationSurfaceColorMode::kLegacy;
+ sk_sp<SkMipMap> mm(SkMipMap::Build(baseBM, colorMode, nullptr));
int index = 0;
SkMipMap::Level level;
@@ -250,8 +250,8 @@ protected:
SkScalar x = 4;
SkScalar y = 4;
- SkSourceGammaTreatment treatment = SkSourceGammaTreatment::kIgnore;
- sk_sp<SkMipMap> mm(SkMipMap::Build(baseBM, treatment, nullptr));
+ SkDestinationSurfaceColorMode colorMode = SkDestinationSurfaceColorMode::kLegacy;
+ sk_sp<SkMipMap> mm(SkMipMap::Build(baseBM, colorMode, nullptr));
int index = 0;
SkMipMap::Level level;
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index cac193b205..b76c70ebc5 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -82,9 +82,9 @@ protected:
return;
}
- sk_sp<GrTexture> texture(GrRefCachedBitmapTexture(context, fBmp,
- GrTextureParams::ClampNoFilter(),
- SkSourceGammaTreatment::kRespect));
+ sk_sp<GrTexture> texture(
+ GrRefCachedBitmapTexture(context, fBmp, GrTextureParams::ClampNoFilter(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
if (!texture) {
return;
}
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index e3b78a6b66..307ea7c6dd 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -81,15 +81,15 @@ protected:
}
sk_sp<GrTexture> texture[3];
- texture[0].reset(GrRefCachedBitmapTexture(context, fBmp[0],
- GrTextureParams::ClampBilerp(),
- SkSourceGammaTreatment::kRespect));
- texture[1].reset(GrRefCachedBitmapTexture(context, fBmp[1],
- GrTextureParams::ClampBilerp(),
- SkSourceGammaTreatment::kRespect));
- texture[2].reset(GrRefCachedBitmapTexture(context, fBmp[2],
- GrTextureParams::ClampBilerp(),
- SkSourceGammaTreatment::kRespect));
+ texture[0].reset(
+ GrRefCachedBitmapTexture(context, fBmp[0], GrTextureParams::ClampBilerp(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
+ texture[1].reset(
+ GrRefCachedBitmapTexture(context, fBmp[1], GrTextureParams::ClampBilerp(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
+ texture[2].reset(
+ GrRefCachedBitmapTexture(context, fBmp[2], GrTextureParams::ClampBilerp(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
if (!texture[0] || !texture[1] || !texture[2]) {
return;
@@ -206,12 +206,15 @@ protected:
}
sk_sp<GrTexture> texture[3];
- texture[0].reset(GrRefCachedBitmapTexture(context, fBmp[0], GrTextureParams::ClampBilerp(),
- SkSourceGammaTreatment::kRespect));
- texture[1].reset(GrRefCachedBitmapTexture(context, fBmp[1], GrTextureParams::ClampBilerp(),
- SkSourceGammaTreatment::kRespect));
- texture[2].reset(GrRefCachedBitmapTexture(context, fBmp[1], GrTextureParams::ClampBilerp(),
- SkSourceGammaTreatment::kRespect));
+ texture[0].reset(
+ GrRefCachedBitmapTexture(context, fBmp[0], GrTextureParams::ClampBilerp(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
+ texture[1].reset(
+ GrRefCachedBitmapTexture(context, fBmp[1], GrTextureParams::ClampBilerp(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
+ texture[2].reset(
+ GrRefCachedBitmapTexture(context, fBmp[1], GrTextureParams::ClampBilerp(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
if (!texture[0] || !texture[1] || !texture[2]) {
return;
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 53ae04ecb2..02b632bc65 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -425,7 +425,7 @@ protected:
private:
static sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&,
const GrMipLevel* texels, int mipLevelCount,
- SkBudgeted, SkSourceGammaTreatment);
+ SkBudgeted, SkDestinationSurfaceColorMode);
const int fWidth;
const int fHeight;
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h
index eac8c0f9cf..f8582d65c7 100644
--- a/include/core/SkImageInfo.h
+++ b/include/core/SkImageInfo.h
@@ -169,9 +169,9 @@ enum SkYUVColorSpace {
///////////////////////////////////////////////////////////////////////////////
-enum class SkSourceGammaTreatment {
- kRespect,
- kIgnore,
+enum class SkDestinationSurfaceColorMode {
+ kLegacy,
+ kGammaAndColorSpaceAware,
};
/**
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index 2f836940c8..07818772e1 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -333,20 +333,20 @@ public:
const SkMatrix* localMatrix,
SkFilterQuality filterQuality,
SkColorSpace* dstColorSpace,
- SkSourceGammaTreatment gammaTreatment)
+ SkDestinationSurfaceColorMode colorMode)
: fContext(context)
, fViewMatrix(viewMatrix)
, fLocalMatrix(localMatrix)
, fFilterQuality(filterQuality)
, fDstColorSpace(dstColorSpace)
- , fGammaTreatment(gammaTreatment) {}
-
- GrContext* fContext;
- const SkMatrix* fViewMatrix;
- const SkMatrix* fLocalMatrix;
- SkFilterQuality fFilterQuality;
- SkColorSpace* fDstColorSpace;
- SkSourceGammaTreatment fGammaTreatment;
+ , fColorMode(colorMode) {}
+
+ GrContext* fContext;
+ const SkMatrix* fViewMatrix;
+ const SkMatrix* fLocalMatrix;
+ SkFilterQuality fFilterQuality;
+ SkColorSpace* fDstColorSpace;
+ SkDestinationSurfaceColorMode fColorMode;
};
/**
diff --git a/include/gpu/GrRenderTargetContext.h b/include/gpu/GrRenderTargetContext.h
index 95d8c9d463..a3869a353a 100644
--- a/include/gpu/GrRenderTargetContext.h
+++ b/include/gpu/GrRenderTargetContext.h
@@ -332,9 +332,9 @@ public:
GrPixelConfig config() const { return fRenderTargetProxy->config(); }
int numColorSamples() const { return fRenderTargetProxy->numColorSamples(); }
bool isGammaCorrect() const { return SkToBool(fColorSpace.get()); }
- SkSourceGammaTreatment sourceGammaTreatment() const {
- return this->isGammaCorrect() ? SkSourceGammaTreatment::kRespect
- : SkSourceGammaTreatment::kIgnore;
+ SkDestinationSurfaceColorMode colorMode() const {
+ return this->isGammaCorrect() ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
+ : SkDestinationSurfaceColorMode::kLegacy;
}
const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
SkColorSpace* getColorSpace() const { return fColorSpace.get(); }
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index 8fa0db9587..7381a90aa4 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -61,11 +61,11 @@ private:
kValid_MipMapsStatus
};
- GrSLType fSamplerType;
- GrTextureParams::FilterMode fHighestFilterMode;
- MipMapsStatus fMipMapsStatus;
- int fMaxMipMapLevel;
- SkSourceGammaTreatment fGammaTreatment;
+ GrSLType fSamplerType;
+ GrTextureParams::FilterMode fHighestFilterMode;
+ MipMapsStatus fMipMapsStatus;
+ int fMaxMipMapLevel;
+ SkDestinationSurfaceColorMode fMipColorMode;
friend class GrTexturePriv;
typedef GrSurface INHERITED;
diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h
index fc13c3864b..fae0c76c6d 100644
--- a/include/gpu/SkGr.h
+++ b/include/gpu/SkGr.h
@@ -81,10 +81,10 @@ static inline GrColor SkPMColorToGrColor(SkPMColor c) {
texture is inserted into the cache (unless the bitmap is marked volatile) and can be
retrieved again via this function. */
GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTextureParams&,
- SkSourceGammaTreatment);
+ SkDestinationSurfaceColorMode);
sk_sp<GrTexture> GrMakeCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTextureParams&,
- SkSourceGammaTreatment);
+ SkDestinationSurfaceColorMode);
// TODO: Move SkImageInfo2GrPixelConfig to SkGrPriv.h (requires cleanup to SkWindow its subclasses).
GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, const SkColorSpace*,
diff --git a/src/core/SkBitmapCache.cpp b/src/core/SkBitmapCache.cpp
index e6a664bf80..0751089083 100644
--- a/src/core/SkBitmapCache.cpp
+++ b/src/core/SkBitmapCache.cpp
@@ -208,21 +208,21 @@ static unsigned gMipMapKeyNamespaceLabel;
struct MipMapKey : public SkResourceCache::Key {
public:
- MipMapKey(uint32_t genID, SkSourceGammaTreatment treatment, const SkIRect& bounds)
- : fGenID(genID), fSrcGammaTreatment(static_cast<uint32_t>(treatment)), fBounds(bounds)
+ MipMapKey(uint32_t genID, SkDestinationSurfaceColorMode colorMode, const SkIRect& bounds)
+ : fGenID(genID), fColorMode(static_cast<uint32_t>(colorMode)), fBounds(bounds)
{
this->init(&gMipMapKeyNamespaceLabel, SkMakeResourceCacheSharedIDForBitmap(genID),
- sizeof(fGenID) + sizeof(fSrcGammaTreatment) + sizeof(fBounds));
+ sizeof(fGenID) + sizeof(fColorMode) + sizeof(fBounds));
}
uint32_t fGenID;
- uint32_t fSrcGammaTreatment;
+ uint32_t fColorMode;
SkIRect fBounds;
};
struct MipMapRec : public SkResourceCache::Rec {
- MipMapRec(const SkBitmap& src, SkSourceGammaTreatment treatment, const SkMipMap* result)
- : fKey(src.getGenerationID(), treatment, get_bounds_from_bitmap(src))
+ MipMapRec(const SkBitmap& src, SkDestinationSurfaceColorMode colorMode, const SkMipMap* result)
+ : fKey(src.getGenerationID(), colorMode, get_bounds_from_bitmap(src))
, fMipMap(result)
{
fMipMap->attachToCacheAndRef();
@@ -260,10 +260,10 @@ private:
}
const SkMipMap* SkMipMapCache::FindAndRef(const SkBitmapCacheDesc& desc,
- SkSourceGammaTreatment treatment,
+ SkDestinationSurfaceColorMode colorMode,
SkResourceCache* localCache) {
// Note: we ignore width/height from desc, just need id and bounds
- MipMapKey key(desc.fImageID, treatment, desc.fBounds);
+ MipMapKey key(desc.fImageID, colorMode, desc.fBounds);
const SkMipMap* result;
if (!CHECK_LOCAL(localCache, find, Find, key, MipMapRec::Finder, &result)) {
@@ -277,11 +277,12 @@ static SkResourceCache::DiscardableFactory get_fact(SkResourceCache* localCache)
: SkResourceCache::GetDiscardableFactory();
}
-const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkSourceGammaTreatment treatment,
+const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src,
+ SkDestinationSurfaceColorMode colorMode,
SkResourceCache* localCache) {
- SkMipMap* mipmap = SkMipMap::Build(src, treatment, get_fact(localCache));
+ SkMipMap* mipmap = SkMipMap::Build(src, colorMode, get_fact(localCache));
if (mipmap) {
- MipMapRec* rec = new MipMapRec(src, treatment, mipmap);
+ MipMapRec* rec = new MipMapRec(src, colorMode, mipmap);
CHECK_LOCAL(localCache, add, Add, rec);
src.pixelRef()->notifyAddedToCache();
}
diff --git a/src/core/SkBitmapCache.h b/src/core/SkBitmapCache.h
index 76bcef06cf..522c93ee45 100644
--- a/src/core/SkBitmapCache.h
+++ b/src/core/SkBitmapCache.h
@@ -72,9 +72,9 @@ public:
class SkMipMapCache {
public:
- static const SkMipMap* FindAndRef(const SkBitmapCacheDesc&, SkSourceGammaTreatment,
+ static const SkMipMap* FindAndRef(const SkBitmapCacheDesc&, SkDestinationSurfaceColorMode,
SkResourceCache* localCache = nullptr);
- static const SkMipMap* AddAndRef(const SkBitmap& src, SkSourceGammaTreatment,
+ static const SkMipMap* AddAndRef(const SkBitmap& src, SkDestinationSurfaceColorMode,
SkResourceCache* localCache = nullptr);
};
diff --git a/src/core/SkBitmapController.cpp b/src/core/SkBitmapController.cpp
index ffeb10c8af..435940b84c 100644
--- a/src/core/SkBitmapController.cpp
+++ b/src/core/SkBitmapController.cpp
@@ -45,12 +45,12 @@ SkBitmapController::State* SkBitmapController::requestBitmap(const SkBitmapProvi
class SkDefaultBitmapControllerState : public SkBitmapController::State {
public:
SkDefaultBitmapControllerState(const SkBitmapProvider&, const SkMatrix& inv, SkFilterQuality,
- SkSourceGammaTreatment);
+ SkDestinationSurfaceColorMode);
private:
- SkBitmap fResultBitmap;
- SkSourceGammaTreatment fSrcGammaTreatment;
- sk_sp<const SkMipMap> fCurrMip;
+ SkBitmap fResultBitmap;
+ SkDestinationSurfaceColorMode fColorMode;
+ sk_sp<const SkMipMap> fCurrMip;
bool processHQRequest(const SkBitmapProvider&);
bool processMediumRequest(const SkBitmapProvider&);
@@ -166,13 +166,13 @@ bool SkDefaultBitmapControllerState::processMediumRequest(const SkBitmapProvider
}
if (invScaleSize.width() > SK_Scalar1 || invScaleSize.height() > SK_Scalar1) {
- fCurrMip.reset(SkMipMapCache::FindAndRef(provider.makeCacheDesc(), fSrcGammaTreatment));
+ fCurrMip.reset(SkMipMapCache::FindAndRef(provider.makeCacheDesc(), fColorMode));
if (nullptr == fCurrMip.get()) {
SkBitmap orig;
if (!provider.asBitmap(&orig)) {
return false;
}
- fCurrMip.reset(SkMipMapCache::AddAndRef(orig, fSrcGammaTreatment));
+ fCurrMip.reset(SkMipMapCache::AddAndRef(orig, fColorMode));
if (nullptr == fCurrMip.get()) {
return false;
}
@@ -200,13 +200,14 @@ bool SkDefaultBitmapControllerState::processMediumRequest(const SkBitmapProvider
return false;
}
-SkDefaultBitmapControllerState::SkDefaultBitmapControllerState(const SkBitmapProvider& provider,
- const SkMatrix& inv,
- SkFilterQuality qual,
- SkSourceGammaTreatment treatment) {
+SkDefaultBitmapControllerState::SkDefaultBitmapControllerState(
+ const SkBitmapProvider& provider,
+ const SkMatrix& inv,
+ SkFilterQuality qual,
+ SkDestinationSurfaceColorMode colorMode) {
fInvMatrix = inv;
fQuality = qual;
- fSrcGammaTreatment = treatment;
+ fColorMode = colorMode;
if (this->processHQRequest(provider) || this->processMediumRequest(provider)) {
SkASSERT(fResultBitmap.getPixels());
@@ -228,5 +229,5 @@ SkBitmapController::State* SkDefaultBitmapController::onRequestBitmap(const SkBi
SkFilterQuality quality,
void* storage, size_t size) {
return SkInPlaceNewCheck<SkDefaultBitmapControllerState>(storage, size, bm, inverse, quality,
- fSrcGammaTreatment);
+ fColorMode);
}
diff --git a/src/core/SkBitmapController.h b/src/core/SkBitmapController.h
index f31c8eef55..2e7a9f3895 100644
--- a/src/core/SkBitmapController.h
+++ b/src/core/SkBitmapController.h
@@ -57,14 +57,14 @@ protected:
class SkDefaultBitmapController : public SkBitmapController {
public:
- SkDefaultBitmapController(SkSourceGammaTreatment treatment) : fSrcGammaTreatment(treatment) {}
+ SkDefaultBitmapController(SkDestinationSurfaceColorMode colorMode) : fColorMode(colorMode) {}
protected:
State* onRequestBitmap(const SkBitmapProvider&, const SkMatrix& inverse, SkFilterQuality,
void* storage, size_t storageSize) override;
private:
- const SkSourceGammaTreatment fSrcGammaTreatment;
+ const SkDestinationSurfaceColorMode fColorMode;
};
#endif
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index e4309b67f4..06ad04b1e4 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -219,11 +219,11 @@ SkShader::Context* SkBitmapProcLegacyShader::MakeContext(const SkShader& shader,
// Decide if we can/want to use the new linear pipeline
bool useLinearPipeline = choose_linear_pipeline(rec, provider.info());
- SkSourceGammaTreatment treatment = SkMipMap::DeduceTreatment(rec);
+ SkDestinationSurfaceColorMode colorMode = SkMipMap::DeduceColorMode(rec);
if (useLinearPipeline) {
void* infoStorage = (char*)storage + sizeof(LinearPipelineContext);
- SkBitmapProcInfo* info = new (infoStorage) SkBitmapProcInfo(provider, tmx, tmy, treatment);
+ SkBitmapProcInfo* info = new (infoStorage) SkBitmapProcInfo(provider, tmx, tmy, colorMode);
if (!info->init(totalInverse, *rec.fPaint)) {
info->~SkBitmapProcInfo();
return nullptr;
@@ -233,7 +233,7 @@ SkShader::Context* SkBitmapProcLegacyShader::MakeContext(const SkShader& shader,
} else {
void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext);
SkBitmapProcState* state = new (stateStorage) SkBitmapProcState(provider, tmx, tmy,
- treatment);
+ colorMode);
if (!state->setup(totalInverse, *rec.fPaint)) {
state->~SkBitmapProcState();
return nullptr;
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index 26ee82e28f..7b88ab644a 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -38,21 +38,21 @@ extern void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const void*, int, int, u
SkBitmapProcInfo::SkBitmapProcInfo(const SkBitmapProvider& provider,
SkShader::TileMode tmx, SkShader::TileMode tmy,
- SkSourceGammaTreatment treatment)
+ SkDestinationSurfaceColorMode colorMode)
: fProvider(provider)
, fTileModeX(tmx)
, fTileModeY(tmy)
- , fSrcGammaTreatment(treatment)
+ , fColorMode(colorMode)
, fBMState(nullptr)
{}
SkBitmapProcInfo::SkBitmapProcInfo(const SkBitmap& bm,
SkShader::TileMode tmx, SkShader::TileMode tmy,
- SkSourceGammaTreatment treatment)
+ SkDestinationSurfaceColorMode colorMode)
: fProvider(SkBitmapProvider(bm))
, fTileModeX(tmx)
, fTileModeY(tmy)
- , fSrcGammaTreatment(treatment)
+ ,fColorMode(colorMode)
, fBMState(nullptr)
{}
@@ -121,7 +121,7 @@ bool SkBitmapProcInfo::init(const SkMatrix& inv, const SkPaint& paint) {
allow_ignore_fractional_translate = false;
}
- SkDefaultBitmapController controller(fSrcGammaTreatment);
+ SkDefaultBitmapController controller(fColorMode);
fBMState = controller.requestBitmap(fProvider, inv, paint.getFilterQuality(),
fBMStateStorage.get(), fBMStateStorage.size());
// Note : we allow the controller to return an empty (zero-dimension) result. Should we?
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h
index e2e4f96951..1818406f61 100644
--- a/src/core/SkBitmapProcState.h
+++ b/src/core/SkBitmapProcState.h
@@ -29,23 +29,23 @@ class SkPaint;
struct SkBitmapProcInfo {
SkBitmapProcInfo(const SkBitmapProvider&, SkShader::TileMode tmx, SkShader::TileMode tmy,
- SkSourceGammaTreatment);
+ SkDestinationSurfaceColorMode);
SkBitmapProcInfo(const SkBitmap&, SkShader::TileMode tmx, SkShader::TileMode tmy,
- SkSourceGammaTreatment);
+ SkDestinationSurfaceColorMode);
~SkBitmapProcInfo();
- const SkBitmapProvider fProvider;
+ const SkBitmapProvider fProvider;
- SkPixmap fPixmap;
- SkMatrix fInvMatrix; // This changes based on tile mode.
+ SkPixmap fPixmap;
+ SkMatrix fInvMatrix; // This changes based on tile mode.
// TODO: combine fInvMatrix and fRealInvMatrix.
- SkMatrix fRealInvMatrix; // The actual inverse matrix.
- SkColor fPaintColor;
- SkShader::TileMode fTileModeX;
- SkShader::TileMode fTileModeY;
- SkFilterQuality fFilterQuality;
- SkMatrix::TypeMask fInvType;
- SkSourceGammaTreatment fSrcGammaTreatment;
+ SkMatrix fRealInvMatrix; // The actual inverse matrix.
+ SkColor fPaintColor;
+ SkShader::TileMode fTileModeX;
+ SkShader::TileMode fTileModeY;
+ SkFilterQuality fFilterQuality;
+ SkMatrix::TypeMask fInvType;
+ SkDestinationSurfaceColorMode fColorMode;
bool init(const SkMatrix& inverse, const SkPaint&);
@@ -59,11 +59,11 @@ private:
struct SkBitmapProcState : public SkBitmapProcInfo {
SkBitmapProcState(const SkBitmapProvider& prov, SkShader::TileMode tmx, SkShader::TileMode tmy,
- SkSourceGammaTreatment treatment)
- : SkBitmapProcInfo(prov, tmx, tmy, treatment) {}
+ SkDestinationSurfaceColorMode colorMode)
+ : SkBitmapProcInfo(prov, tmx, tmy, colorMode) {}
SkBitmapProcState(const SkBitmap& bitmap, SkShader::TileMode tmx, SkShader::TileMode tmy,
- SkSourceGammaTreatment treatment)
- : SkBitmapProcInfo(bitmap, tmx, tmy, treatment) {}
+ SkDestinationSurfaceColorMode colorMode)
+ : SkBitmapProcInfo(bitmap, tmx, tmy, colorMode) {}
bool setup(const SkMatrix& inv, const SkPaint& paint) {
return this->init(inv, paint) && this->chooseProcs();
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp
index 9401b35c9f..54045d5821 100644
--- a/src/core/SkImageCacherator.cpp
+++ b/src/core/SkImageCacherator.cpp
@@ -280,7 +280,7 @@ static GrTexture* set_key_and_return(GrTexture* tex, const GrUniqueKey& key) {
GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key,
const SkImage* client, SkImage::CachingHint chint,
bool willBeMipped,
- SkSourceGammaTreatment gammaTreatment) {
+ SkDestinationSurfaceColorMode colorMode) {
// Values representing the various texture lock paths we can take. Used for logging the path
// taken to a histogram.
enum LockTexturePath {
@@ -346,7 +346,7 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key
if (this->tryLockAsBitmap(&bitmap, client, chint)) {
GrTexture* tex = nullptr;
if (willBeMipped) {
- tex = GrGenerateMipMapsAndUploadToTexture(ctx, bitmap, gammaTreatment);
+ tex = GrGenerateMipMapsAndUploadToTexture(ctx, bitmap, colorMode);
}
if (!tex) {
tex = GrUploadBitmapToTexture(ctx, bitmap);
@@ -365,20 +365,19 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key
///////////////////////////////////////////////////////////////////////////////////////////////////
GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParams& params,
- SkSourceGammaTreatment gammaTreatment,
+ SkDestinationSurfaceColorMode colorMode,
const SkImage* client, SkImage::CachingHint chint) {
if (!ctx) {
return nullptr;
}
- return GrImageTextureMaker(ctx, this, client, chint).refTextureForParams(params,
- gammaTreatment);
+ return GrImageTextureMaker(ctx, this, client, chint).refTextureForParams(params, colorMode);
}
#else
GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParams&,
- SkSourceGammaTreatment gammaTreatment,
+ SkDestinationSurfaceColorMode colorMode,
const SkImage* client, SkImage::CachingHint) {
return nullptr;
}
diff --git a/src/core/SkImageCacherator.h b/src/core/SkImageCacherator.h
index 8bf335bf51..a8a05a1f90 100644
--- a/src/core/SkImageCacherator.h
+++ b/src/core/SkImageCacherator.h
@@ -51,7 +51,7 @@ public:
* The caller is responsible for calling texture->unref() when they are done.
*/
GrTexture* lockAsTexture(GrContext*, const GrTextureParams&,
- SkSourceGammaTreatment gammaTreatment, const SkImage* client,
+ SkDestinationSurfaceColorMode colorMode, const SkImage* client,
SkImage::CachingHint = SkImage::kAllow_CachingHint);
/**
@@ -108,7 +108,7 @@ private:
// Returns the texture. If the cacherator is generating the texture and wants to cache it,
// it should use the passed in key (if the key is valid).
GrTexture* lockTexture(GrContext*, const GrUniqueKey& key, const SkImage* client,
- SkImage::CachingHint, bool willBeMipped, SkSourceGammaTreatment);
+ SkImage::CachingHint, bool willBeMipped, SkDestinationSurfaceColorMode);
#endif
sk_sp<SharedGenerator> fSharedGenerator;
diff --git a/src/core/SkLocalMatrixShader.cpp b/src/core/SkLocalMatrixShader.cpp
index 506fd3e71a..fb436d8759 100644
--- a/src/core/SkLocalMatrixShader.cpp
+++ b/src/core/SkLocalMatrixShader.cpp
@@ -19,7 +19,7 @@ sk_sp<GrFragmentProcessor> SkLocalMatrixShader::asFragmentProcessor(const AsFPAr
}
return fProxyShader->asFragmentProcessor(AsFPArgs(
args.fContext, args.fViewMatrix, &tmp, args.fFilterQuality, args.fDstColorSpace,
- args.fGammaTreatment));
+ args.fColorMode));
}
#endif
diff --git a/src/core/SkMipMap.cpp b/src/core/SkMipMap.cpp
index c5bd3ac3b7..ba3cb18749 100644
--- a/src/core/SkMipMap.cpp
+++ b/src/core/SkMipMap.cpp
@@ -306,7 +306,7 @@ size_t SkMipMap::AllocLevelsSize(int levelCount, size_t pixelSize) {
return sk_64_asS32(size);
}
-SkMipMap* SkMipMap::Build(const SkPixmap& src, SkSourceGammaTreatment treatment,
+SkMipMap* SkMipMap::Build(const SkPixmap& src, SkDestinationSurfaceColorMode colorMode,
SkDiscardableFactoryProc fact) {
typedef void FilterProc(void*, const void* srcPtr, size_t srcRB, int count);
@@ -321,7 +321,7 @@ SkMipMap* SkMipMap::Build(const SkPixmap& src, SkSourceGammaTreatment treatment,
const SkColorType ct = src.colorType();
const SkAlphaType at = src.alphaType();
- const bool srgbGamma = (SkSourceGammaTreatment::kRespect == treatment)
+ const bool srgbGamma = (SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware == colorMode)
&& src.info().gammaCloseToSRGB();
switch (ct) {
@@ -601,7 +601,7 @@ bool SkMipMap::extractLevel(const SkSize& scaleSize, Level* levelPtr) const {
// Helper which extracts a pixmap from the src bitmap
//
-SkMipMap* SkMipMap::Build(const SkBitmap& src, SkSourceGammaTreatment treatment,
+SkMipMap* SkMipMap::Build(const SkBitmap& src, SkDestinationSurfaceColorMode colorMode,
SkDiscardableFactoryProc fact) {
SkAutoPixmapUnlock srcUnlocker;
if (!src.requestLock(&srcUnlocker)) {
@@ -612,7 +612,7 @@ SkMipMap* SkMipMap::Build(const SkBitmap& src, SkSourceGammaTreatment treatment,
if (nullptr == srcPixmap.addr()) {
sk_throw();
}
- return Build(srcPixmap, treatment, fact);
+ return Build(srcPixmap, colorMode, fact);
}
int SkMipMap::countLevels() const {
diff --git a/src/core/SkMipMap.h b/src/core/SkMipMap.h
index 0f31a9f703..f3425cbeaa 100644
--- a/src/core/SkMipMap.h
+++ b/src/core/SkMipMap.h
@@ -28,12 +28,15 @@ typedef SkDiscardableMemory* (*SkDiscardableFactoryProc)(size_t bytes);
*/
class SkMipMap : public SkCachedData {
public:
- static SkMipMap* Build(const SkPixmap& src, SkSourceGammaTreatment, SkDiscardableFactoryProc);
- static SkMipMap* Build(const SkBitmap& src, SkSourceGammaTreatment, SkDiscardableFactoryProc);
-
- static SkSourceGammaTreatment DeduceTreatment(const SkShader::ContextRec& rec) {
- return (SkShader::ContextRec::kPMColor_DstType == rec.fPreferredDstType) ?
- SkSourceGammaTreatment::kIgnore : SkSourceGammaTreatment::kRespect;
+ static SkMipMap* Build(const SkPixmap& src, SkDestinationSurfaceColorMode,
+ SkDiscardableFactoryProc);
+ static SkMipMap* Build(const SkBitmap& src, SkDestinationSurfaceColorMode,
+ SkDiscardableFactoryProc);
+
+ static SkDestinationSurfaceColorMode DeduceColorMode(const SkShader::ContextRec& rec) {
+ return (SkShader::ContextRec::kPMColor_DstType == rec.fPreferredDstType)
+ ? SkDestinationSurfaceColorMode::kLegacy
+ : SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware;
}
// Determines how many levels a SkMipMap will have without creating that mipmap.
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index ad954d29df..74cce6815c 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -329,6 +329,6 @@ sk_sp<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(const AsFPArgs&
}
return bitmapShader->asFragmentProcessor(SkShader::AsFPArgs(
args.fContext, args.fViewMatrix, nullptr, args.fFilterQuality, args.fDstColorSpace,
- args.fGammaTreatment));
+ args.fColorMode));
}
#endif
diff --git a/src/core/SkShadowShader.cpp b/src/core/SkShadowShader.cpp
index c3ede8081e..8737b32cac 100644
--- a/src/core/SkShadowShader.cpp
+++ b/src/core/SkShadowShader.cpp
@@ -139,7 +139,7 @@ public:
// gets deleted when the ShadowFP is destroyed, and frees the GrTexture*
fTexture[fNumNonAmbLights] = sk_sp<GrTexture>(shadowMap->asTextureRef(context,
GrTextureParams::ClampNoFilter(),
- SkSourceGammaTreatment::kIgnore));
+ SkDestinationSurfaceColorMode::kLegacy));
fDepthMapAccess[fNumNonAmbLights].reset(fTexture[fNumNonAmbLights].get());
this->addTextureAccess(&fDepthMapAccess[fNumNonAmbLights]);
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index e750571ff3..239d9a90da 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -101,10 +101,9 @@ sk_sp<SkSpecialImage> SkSpecialImage::makeTextureImage(GrContext* context) {
return SkSpecialImage::MakeFromRaster(SkIRect::MakeEmpty(), bmp, &this->props());
}
- sk_sp<GrTexture> resultTex(GrRefCachedBitmapTexture(context,
- bmp,
- GrTextureParams::ClampNoFilter(),
- SkSourceGammaTreatment::kRespect));
+ sk_sp<GrTexture> resultTex(
+ GrRefCachedBitmapTexture(context, bmp, GrTextureParams::ClampNoFilter(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
if (!resultTex) {
return nullptr;
}
@@ -241,10 +240,9 @@ public:
#if SK_SUPPORT_GPU
sk_sp<GrTexture> onAsTextureRef(GrContext* context) const override {
if (context) {
- return sk_ref_sp(GrRefCachedBitmapTexture(context,
- fBitmap,
- GrTextureParams::ClampNoFilter(),
- SkSourceGammaTreatment::kRespect));
+ return sk_ref_sp(
+ GrRefCachedBitmapTexture(context, fBitmap, GrTextureParams::ClampNoFilter(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
}
return nullptr;
@@ -252,11 +250,9 @@ public:
sk_sp<GrTextureProxy> onAsTextureProxy(GrContext* context) const override {
if (context) {
- sk_sp<GrTexture> tex(sk_ref_sp(GrRefCachedBitmapTexture(
- context,
- fBitmap,
- GrTextureParams::ClampNoFilter(),
- SkSourceGammaTreatment::kRespect)));
+ sk_sp<GrTexture> tex(sk_ref_sp(
+ GrRefCachedBitmapTexture(context, fBitmap, GrTextureParams::ClampNoFilter(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware)));
return GrTextureProxy::Make(tex);
}
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index 87db93d303..0b34d161b1 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -926,10 +926,10 @@ sk_sp<GrFragmentProcessor> SkPerlinNoiseShader::asFragmentProcessor(const AsFPAr
new PaintingData(fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix);
sk_sp<GrTexture> permutationsTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getPermutationsBitmap(),
- GrTextureParams::ClampNoFilter(), args.fGammaTreatment));
+ GrTextureParams::ClampNoFilter(), args.fColorMode));
sk_sp<GrTexture> noiseTexture(
GrRefCachedBitmapTexture(args.fContext, paintingData->getNoiseBitmap(),
- GrTextureParams::ClampNoFilter(), args.fGammaTreatment));
+ GrTextureParams::ClampNoFilter(), args.fColorMode));
SkMatrix m = *args.fViewMatrix;
m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index 289dee7aee..cd786dfee6 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -473,8 +473,9 @@ sk_sp<GrFragmentProcessor> ColorTableEffect::Make(GrContext* context, SkBitmap b
sk_sp<GrTexture> texture;
if (-1 == row) {
atlas = nullptr;
- texture.reset(GrRefCachedBitmapTexture(context, bitmap, GrTextureParams::ClampNoFilter(),
- SkSourceGammaTreatment::kRespect));
+ texture.reset(
+ GrRefCachedBitmapTexture(context, bitmap, GrTextureParams::ClampNoFilter(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
} else {
texture.reset(SkRef(atlas->getTexture()));
}
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 0bd9c8748d..3bf569c888 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -1661,9 +1661,9 @@ GrGradientEffect::GrGradientEffect(const CreateArgs& args) {
fCoordTransform.reset(*args.fMatrix, fAtlas->getTexture(), params.filterMode());
fTextureAccess.reset(fAtlas->getTexture(), params);
} else {
- sk_sp<GrTexture> texture(
- GrRefCachedBitmapTexture(args.fContext, bitmap, params,
- SkSourceGammaTreatment::kRespect));
+ sk_sp<GrTexture> texture(GrRefCachedBitmapTexture(
+ args.fContext, bitmap, params,
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
if (!texture) {
return;
}
diff --git a/src/gpu/GrImageIDTextureAdjuster.cpp b/src/gpu/GrImageIDTextureAdjuster.cpp
index 5a96b6d3e6..cc869baf7f 100644
--- a/src/gpu/GrImageIDTextureAdjuster.cpp
+++ b/src/gpu/GrImageIDTextureAdjuster.cpp
@@ -30,7 +30,7 @@ GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& b
}
GrTexture* GrBitmapTextureMaker::refOriginalTexture(bool willBeMipped,
- SkSourceGammaTreatment gammaTreatment) {
+ SkDestinationSurfaceColorMode colorMode) {
GrTexture* tex = nullptr;
if (fOriginalKey.isValid()) {
@@ -40,7 +40,7 @@ GrTexture* GrBitmapTextureMaker::refOriginalTexture(bool willBeMipped,
}
}
if (willBeMipped) {
- tex = GrGenerateMipMapsAndUploadToTexture(this->context(), fBitmap, gammaTreatment);
+ tex = GrGenerateMipMapsAndUploadToTexture(this->context(), fBitmap, colorMode);
}
if (!tex) {
tex = GrUploadBitmapToTexture(this->context(), fBitmap);
@@ -88,9 +88,9 @@ GrImageTextureMaker::GrImageTextureMaker(GrContext* context, SkImageCacherator*
}
GrTexture* GrImageTextureMaker::refOriginalTexture(bool willBeMipped,
- SkSourceGammaTreatment gammaTreatment) {
+ SkDestinationSurfaceColorMode colorMode) {
return fCacher->lockTexture(this->context(), fOriginalKey, fClient, fCachingHint, willBeMipped,
- gammaTreatment);
+ colorMode);
}
void GrImageTextureMaker::makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey) {
diff --git a/src/gpu/GrImageIDTextureAdjuster.h b/src/gpu/GrImageIDTextureAdjuster.h
index 36ac0ad3e1..b0b70487e3 100644
--- a/src/gpu/GrImageIDTextureAdjuster.h
+++ b/src/gpu/GrImageIDTextureAdjuster.h
@@ -23,7 +23,7 @@ public:
GrBitmapTextureMaker(GrContext* context, const SkBitmap& bitmap);
protected:
- GrTexture* refOriginalTexture(bool willBeMipped, SkSourceGammaTreatment) override;
+ GrTexture* refOriginalTexture(bool willBeMipped, SkDestinationSurfaceColorMode) override;
void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey) override;
@@ -51,7 +51,7 @@ protected:
// able to efficiently produce a "stretched" texture natively (e.g. picture-backed)
// GrTexture* generateTextureForParams(const CopyParams&) override;
- GrTexture* refOriginalTexture(bool willBeMipped, SkSourceGammaTreatment) override;
+ GrTexture* refOriginalTexture(bool willBeMipped, SkDestinationSurfaceColorMode) override;
void makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey) override;
void didCacheCopy(const GrUniqueKey& copyKey) override;
diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp
index 704b1281f1..6dfe670931 100644
--- a/src/gpu/GrTestUtils.cpp
+++ b/src/gpu/GrTestUtils.cpp
@@ -331,8 +331,9 @@ TestAsFPArgs::TestAsFPArgs(GrProcessorTestData* d) {
fArgs.fLocalMatrix = nullptr;
fArgs.fFilterQuality = kNone_SkFilterQuality;
fArgs.fDstColorSpace = fColorSpaceStorage.get();
- fArgs.fGammaTreatment = SkToBool(fArgs.fDstColorSpace)
- ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
+ fArgs.fColorMode = SkToBool(fArgs.fDstColorSpace)
+ ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
+ : SkDestinationSurfaceColorMode::kLegacy;
}
} // namespace GrTest
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index 6fc1580e89..807fb9b544 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -74,8 +74,8 @@ GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType
: INHERITED(gpu, desc)
, fSamplerType(samplerType)
, fHighestFilterMode(highestFilterMode)
- // Gamma treatment is explicitly set after creation via GrTexturePriv
- , fGammaTreatment(SkSourceGammaTreatment::kIgnore) {
+ // Mip color mode is explicitly set after creation via GrTexturePriv
+ , fMipColorMode(SkDestinationSurfaceColorMode::kLegacy) {
if (wasMipMapDataProvided) {
fMipMapsStatus = kValid_MipMapsStatus;
fMaxMipMapLevel = SkMipMap::ComputeLevelCount(fDesc.fWidth, fDesc.fHeight);
diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp
index 43bfec8463..fa1fffd2a3 100644
--- a/src/gpu/GrTextureParamsAdjuster.cpp
+++ b/src/gpu/GrTextureParamsAdjuster.cpp
@@ -142,7 +142,7 @@ GrTexture* GrTextureAdjuster::refCopy(const CopyParams& copyParams) {
}
GrTexture* GrTextureAdjuster::refTextureSafeForParams(const GrTextureParams& params,
- SkSourceGammaTreatment gammaTreatment,
+ SkDestinationSurfaceColorMode colorMode,
SkIPoint* outOffset) {
GrTexture* texture = this->originalTexture();
GrContext* context = texture->getContext();
@@ -369,7 +369,7 @@ sk_sp<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor(
bool coordsLimitedToConstraintRect,
const GrTextureParams::FilterMode* filterOrNullForBicubic,
SkColorSpace* dstColorSpace,
- SkSourceGammaTreatment gammaTreatment) {
+ SkDestinationSurfaceColorMode colorMode) {
SkMatrix textureMatrix = origTextureMatrix;
const SkIRect* contentArea = this->contentAreaOrNull();
@@ -388,7 +388,7 @@ sk_sp<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor(
if (filterOrNullForBicubic) {
params.setFilterMode(*filterOrNullForBicubic);
}
- sk_sp<GrTexture> texture(this->refTextureSafeForParams(params, gammaTreatment, nullptr));
+ sk_sp<GrTexture> texture(this->refTextureSafeForParams(params, colorMode, nullptr));
if (!texture) {
return nullptr;
}
@@ -430,7 +430,7 @@ sk_sp<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor(
//////////////////////////////////////////////////////////////////////////////
GrTexture* GrTextureMaker::refTextureForParams(const GrTextureParams& params,
- SkSourceGammaTreatment gammaTreatment) {
+ SkDestinationSurfaceColorMode colorMode) {
CopyParams copyParams;
bool willBeMipped = params.filterMode() == GrTextureParams::kMipMap_FilterMode;
@@ -440,7 +440,7 @@ GrTexture* GrTextureMaker::refTextureForParams(const GrTextureParams& params,
if (!fContext->getGpu()->makeCopyForTextureParams(this->width(), this->height(), params,
&copyParams)) {
- return this->refOriginalTexture(willBeMipped, gammaTreatment);
+ return this->refOriginalTexture(willBeMipped, colorMode);
}
GrUniqueKey copyKey;
this->makeCopyKey(copyParams, &copyKey);
@@ -451,7 +451,7 @@ GrTexture* GrTextureMaker::refTextureForParams(const GrTextureParams& params,
}
}
- GrTexture* result = this->generateTextureForParams(copyParams, willBeMipped, gammaTreatment);
+ GrTexture* result = this->generateTextureForParams(copyParams, willBeMipped, colorMode);
if (!result) {
return nullptr;
}
@@ -470,7 +470,7 @@ sk_sp<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor(
bool coordsLimitedToConstraintRect,
const GrTextureParams::FilterMode* filterOrNullForBicubic,
SkColorSpace* dstColorSpace,
- SkSourceGammaTreatment gammaTreatment) {
+ SkDestinationSurfaceColorMode colorMode) {
const GrTextureParams::FilterMode* fmForDetermineDomain = filterOrNullForBicubic;
if (filterOrNullForBicubic && GrTextureParams::kMipMap_FilterMode == *filterOrNullForBicubic &&
@@ -491,7 +491,7 @@ sk_sp<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor(
// Bicubic doesn't use filtering for it's texture accesses.
params.reset(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode);
}
- sk_sp<GrTexture> texture(this->refTextureForParams(params, gammaTreatment));
+ sk_sp<GrTexture> texture(this->refTextureForParams(params, colorMode));
if (!texture) {
return nullptr;
}
@@ -511,8 +511,8 @@ sk_sp<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor(
}
GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams, bool willBeMipped,
- SkSourceGammaTreatment gammaTreatment) {
- sk_sp<GrTexture> original(this->refOriginalTexture(willBeMipped, gammaTreatment));
+ SkDestinationSurfaceColorMode colorMode) {
+ sk_sp<GrTexture> original(this->refOriginalTexture(willBeMipped, colorMode));
if (!original) {
return nullptr;
}
diff --git a/src/gpu/GrTextureParamsAdjuster.h b/src/gpu/GrTextureParamsAdjuster.h
index 3de4db7441..1784ab66a7 100644
--- a/src/gpu/GrTextureParamsAdjuster.h
+++ b/src/gpu/GrTextureParamsAdjuster.h
@@ -66,7 +66,7 @@ public:
bool coordsLimitedToConstraintRect,
const GrTextureParams::FilterMode* filterOrNullForBicubic,
SkColorSpace* dstColorSpace,
- SkSourceGammaTreatment) = 0;
+ SkDestinationSurfaceColorMode) = 0;
virtual ~GrTextureProducer() {}
@@ -131,7 +131,7 @@ public:
outOffset will be the top-left corner of the subset if a copy is not made. Otherwise,
the copy will be tight to the contents and outOffset will be (0, 0). If the copy's size
does not match subset's dimensions then the contents are scaled to fit the copy.*/
- GrTexture* refTextureSafeForParams(const GrTextureParams&, SkSourceGammaTreatment,
+ GrTexture* refTextureSafeForParams(const GrTextureParams&, SkDestinationSurfaceColorMode,
SkIPoint* outOffset);
sk_sp<GrFragmentProcessor> createFragmentProcessor(
@@ -141,7 +141,7 @@ public:
bool coordsLimitedToConstraintRect,
const GrTextureParams::FilterMode* filterOrNullForBicubic,
SkColorSpace* dstColorSpace,
- SkSourceGammaTreatment) override;
+ SkDestinationSurfaceColorMode) override;
// We do not ref the texture nor the colorspace, so the caller must keep them in scope while
// this Adjuster is alive.
@@ -180,7 +180,7 @@ public:
/** Returns a texture that is safe for use with the params. If the size of the returned texture
does not match width()/height() then the contents of the original must be scaled to fit
the texture. */
- GrTexture* refTextureForParams(const GrTextureParams&, SkSourceGammaTreatment);
+ GrTexture* refTextureForParams(const GrTextureParams&, SkDestinationSurfaceColorMode);
sk_sp<GrFragmentProcessor> createFragmentProcessor(
const SkMatrix& textureMatrix,
@@ -189,7 +189,7 @@ public:
bool coordsLimitedToConstraintRect,
const GrTextureParams::FilterMode* filterOrNullForBicubic,
SkColorSpace* dstColorSpace,
- SkSourceGammaTreatment) override;
+ SkDestinationSurfaceColorMode) override;
protected:
GrTextureMaker(GrContext* context, int width, int height, bool isAlphaOnly)
@@ -200,7 +200,7 @@ protected:
* Return the maker's "original" texture. It is the responsibility of the maker to handle any
* caching of the original if desired.
*/
- virtual GrTexture* refOriginalTexture(bool willBeMipped, SkSourceGammaTreatment) = 0;
+ virtual GrTexture* refOriginalTexture(bool willBeMipped, SkDestinationSurfaceColorMode) = 0;
/**
* Return a new (uncached) texture that is the stretch of the maker's original.
@@ -213,7 +213,7 @@ protected:
* by copying.
*/
virtual GrTexture* generateTextureForParams(const CopyParams&, bool willBeMipped,
- SkSourceGammaTreatment);
+ SkDestinationSurfaceColorMode);
GrContext* context() const { return fContext; }
diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h
index c4c185560e..e8721bc62c 100644
--- a/src/gpu/GrTexturePriv.h
+++ b/src/gpu/GrTexturePriv.h
@@ -54,10 +54,10 @@ public:
/** The filter used is clamped to this value in GrTextureAccess. */
GrTextureParams::FilterMode highestFilterMode() const { return fTexture->fHighestFilterMode; }
- void setGammaTreatment(SkSourceGammaTreatment gammaTreatment) const {
- fTexture->fGammaTreatment = gammaTreatment;
+ void setMipColorMode(SkDestinationSurfaceColorMode colorMode) const {
+ fTexture->fMipColorMode = colorMode;
}
- SkSourceGammaTreatment gammaTreatment() const { return fTexture->fGammaTreatment; }
+ SkDestinationSurfaceColorMode mipColorMode() const { return fTexture->fMipColorMode; }
static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 19c637735c..f7f7c021c4 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1033,7 +1033,7 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap,
bitmap.height() <= fContext->caps()->maxTileSize());
sk_sp<GrTexture> texture = GrMakeCachedBitmapTexture(
- fContext.get(), bitmap, params, fRenderTargetContext->sourceGammaTreatment());
+ fContext.get(), bitmap, params, fRenderTargetContext->colorMode());
if (nullptr == texture) {
return;
}
@@ -1111,9 +1111,9 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
}
// draw sprite neither filters nor tiles.
- texture.reset(GrRefCachedBitmapTexture(fContext.get(), bitmap,
- GrTextureParams::ClampNoFilter(),
- SkSourceGammaTreatment::kRespect));
+ texture.reset(
+ GrRefCachedBitmapTexture(fContext.get(), bitmap, GrTextureParams::ClampNoFilter(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
if (!texture) {
return;
}
@@ -1279,9 +1279,9 @@ sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkBitmap& bitmap) {
return nullptr;
}
- sk_sp<GrTexture> texture = GrMakeCachedBitmapTexture(fContext.get(), bitmap,
- GrTextureParams::ClampNoFilter(),
- SkSourceGammaTreatment::kRespect);
+ sk_sp<GrTexture> texture =
+ GrMakeCachedBitmapTexture(fContext.get(), bitmap, GrTextureParams::ClampNoFilter(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware);
if (!texture) {
return nullptr;
}
@@ -1455,7 +1455,7 @@ void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc
SkRect::MakeIWH(producer->width(), producer->height()),
GrTextureProducer::kNo_FilterConstraint, true,
&kMode, fRenderTargetContext->getColorSpace(),
- fRenderTargetContext->sourceGammaTreatment()));
+ fRenderTargetContext->colorMode()));
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(this->context(), fRenderTargetContext.get(), paint,
*draw.fMatrix, std::move(fp), producer->isAlphaOnly(),
@@ -1509,7 +1509,7 @@ void SkGpuDevice::drawProducerLattice(const SkDraw& draw, GrTextureProducer* pro
SkRect::MakeIWH(producer->width(), producer->height()),
GrTextureProducer::kNo_FilterConstraint, true,
&kMode, fRenderTargetContext->getColorSpace(),
- fRenderTargetContext->sourceGammaTreatment()));
+ fRenderTargetContext->colorMode()));
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(this->context(), fRenderTargetContext.get(), paint,
*draw.fMatrix, std::move(fp), producer->isAlphaOnly(),
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index d50b05032e..f232e19906 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -203,7 +203,7 @@ void SkGpuDevice::drawTextureProducerImpl(GrTextureProducer* producer,
}
sk_sp<GrFragmentProcessor> fp(producer->createFragmentProcessor(
*textureMatrix, clippedSrcRect, constraintMode, coordsAllInsideSrcRect, filterMode,
- fRenderTargetContext->getColorSpace(), fRenderTargetContext->sourceGammaTreatment()));
+ fRenderTargetContext->getColorSpace(), fRenderTargetContext->colorMode()));
if (!fp) {
return;
}
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 679ba8cd77..d74e259fef 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -339,7 +339,7 @@ void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pix
}
GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& bitmap,
- SkSourceGammaTreatment gammaTreatment)
+ SkDestinationSurfaceColorMode colorMode)
{
GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info(), *ctx->caps());
if (kIndex_8_SkColorType != bitmap.colorType() && !bitmap.readyToDraw()) {
@@ -378,7 +378,7 @@ GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b
sk_throw();
}
- std::unique_ptr<SkMipMap> mipmaps(SkMipMap::Build(pixmap, gammaTreatment, nullptr));
+ std::unique_ptr<SkMipMap> mipmaps(SkMipMap::Build(pixmap, colorMode, nullptr));
if (!mipmaps) {
return nullptr;
}
@@ -409,7 +409,7 @@ GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b
texels.get(),
mipLevelCount);
if (texture) {
- texture->texturePriv().setGammaTreatment(gammaTreatment);
+ texture->texturePriv().setMipColorMode(colorMode);
}
return texture;
}
@@ -425,14 +425,14 @@ GrTexture* GrUploadMipMapToTexture(GrContext* ctx, const SkImageInfo& info,
GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap,
const GrTextureParams& params,
- SkSourceGammaTreatment gammaTreatment) {
- return GrBitmapTextureMaker(ctx, bitmap).refTextureForParams(params, gammaTreatment);
+ SkDestinationSurfaceColorMode colorMode) {
+ return GrBitmapTextureMaker(ctx, bitmap).refTextureForParams(params, colorMode);
}
sk_sp<GrTexture> GrMakeCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap,
const GrTextureParams& params,
- SkSourceGammaTreatment gammaTreatment) {
- GrTexture* tex = GrBitmapTextureMaker(ctx, bitmap).refTextureForParams(params, gammaTreatment);
+ SkDestinationSurfaceColorMode colorMode) {
+ GrTexture* tex = GrBitmapTextureMaker(ctx, bitmap).refTextureForParams(params, colorMode);
return sk_sp<GrTexture>(tex);
}
@@ -599,7 +599,7 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
shaderFP = shader->asFragmentProcessor(SkShader::AsFPArgs(context, &viewM, nullptr,
skPaint.getFilterQuality(),
rtc->getColorSpace(),
- rtc->sourceGammaTreatment()));
+ rtc->colorMode()));
if (!shaderFP) {
return false;
}
@@ -787,7 +787,7 @@ bool SkPaintToGrPaintWithTexture(GrContext* context,
nullptr,
paint.getFilterQuality(),
rtc->getColorSpace(),
- rtc->sourceGammaTreatment()));
+ rtc->colorMode()));
if (!shaderFP) {
return false;
}
diff --git a/src/gpu/SkGrPriv.h b/src/gpu/SkGrPriv.h
index 3aa8a0ca05..ecbe558c94 100644
--- a/src/gpu/SkGrPriv.h
+++ b/src/gpu/SkGrPriv.h
@@ -131,7 +131,8 @@ GrPixelConfig GrIsCompressedTextureDataSupported(GrContext* ctx, SkData* data,
*/
GrTexture* GrUploadBitmapToTexture(GrContext*, const SkBitmap&);
-GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext*, const SkBitmap&, SkSourceGammaTreatment);
+GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext*, const SkBitmap&,
+ SkDestinationSurfaceColorMode);
/**
* Creates a new texture for the pixmap.
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 266f3a8419..9ccd073fe7 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -3245,9 +3245,10 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, bool allow
if (GrTextureParams::kMipMap_FilterMode == filterMode) {
SkASSERT(!texture->texturePriv().mipMapsAreDirty());
if (GrPixelConfigIsSRGB(texture->config())) {
- SkSourceGammaTreatment gammaTreatment = allowSRGBInputs ?
- SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore;
- SkASSERT(texture->texturePriv().gammaTreatment() == gammaTreatment);
+ SkDestinationSurfaceColorMode colorMode = allowSRGBInputs
+ ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
+ : SkDestinationSurfaceColorMode::kLegacy;
+ SkASSERT(texture->texturePriv().mipColorMode() == colorMode);
}
}
#endif
@@ -3360,10 +3361,11 @@ 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;
+ SkDestinationSurfaceColorMode colorMode = allowSRGBInputs
+ ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
+ : SkDestinationSurfaceColorMode::kLegacy;
if (GrPixelConfigIsSRGB(texture->config()) &&
- gammaTreatment != texture->texturePriv().gammaTreatment()) {
+ colorMode != texture->texturePriv().mipColorMode()) {
texture->texturePriv().dirtyMipMaps(true);
}
@@ -3398,7 +3400,7 @@ void GrGLGpu::generateMipmaps(const GrTextureParams& params, bool allowSRGBInput
texture->texturePriv().dirtyMipMaps(false);
texture->texturePriv().setMaxMipMapLevel(SkMipMap::ComputeLevelCount(
texture->width(), texture->height()));
- texture->texturePriv().setGammaTreatment(gammaTreatment);
+ texture->texturePriv().setMipColorMode(colorMode);
// We have potentially set lots of state on the texture. Easiest to dirty it all:
texture->textureParamsModified();
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 22cb5cb540..3ae7ed71bc 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -368,7 +368,7 @@ sk_sp<SkImage> SkImage::MakeTextureFromPixmap(GrContext*, const SkPixmap&, SkBud
}
sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&, const GrMipLevel* texels,
- int mipLevelCount, SkBudgeted, SkSourceGammaTreatment) {
+ int mipLevelCount, SkBudgeted, SkDestinationSurfaceColorMode) {
return nullptr;
}
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index f58228c56c..eed817554e 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -210,8 +210,7 @@ sk_sp<GrFragmentProcessor> SkImageShader::asFragmentProcessor(const AsFPArgs& ar
GrSkFilterQualityToGrFilterMode(args.fFilterQuality, *args.fViewMatrix, this->getLocalMatrix(),
&doBicubic);
GrTextureParams params(tm, textureFilterMode);
- sk_sp<GrTexture> texture(as_IB(fImage)->asTextureRef(args.fContext, params,
- args.fGammaTreatment));
+ sk_sp<GrTexture> texture(as_IB(fImage)->asTextureRef(args.fContext, params, args.fColorMode));
if (!texture) {
return nullptr;
}
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index b314cc6c2f..3a4aabd4b6 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -56,7 +56,7 @@ public:
// Caller must call unref when they are done.
virtual GrTexture* asTextureRef(GrContext*, const GrTextureParams&,
- SkSourceGammaTreatment) const = 0;
+ SkDestinationSurfaceColorMode) 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 483ebdf2b1..03dda91e5e 100644
--- a/src/image/SkImage_Generator.cpp
+++ b/src/image/SkImage_Generator.cpp
@@ -32,7 +32,7 @@ public:
sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
bool getROPixels(SkBitmap*, CachingHint) const override;
GrTexture* asTextureRef(GrContext*, const GrTextureParams&,
- SkSourceGammaTreatment) const override;
+ SkDestinationSurfaceColorMode) const override;
bool onIsLazyGenerated() const override { return true; }
private:
@@ -75,8 +75,8 @@ bool SkImage_Generator::getROPixels(SkBitmap* bitmap, CachingHint chint) const {
}
GrTexture* SkImage_Generator::asTextureRef(GrContext* ctx, const GrTextureParams& params,
- SkSourceGammaTreatment gammaTreatment) const {
- return fCache.lockAsTexture(ctx, params, gammaTreatment, this);
+ SkDestinationSurfaceColorMode colorMode) const {
+ return fCache.lockAsTexture(ctx, params, colorMode, 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 5e2d1a5018..a006e14ecf 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -86,10 +86,10 @@ bool SkImage_Gpu::getROPixels(SkBitmap* dst, CachingHint chint) const {
}
GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& params,
- SkSourceGammaTreatment gammaTreatment) const {
+ SkDestinationSurfaceColorMode colorMode) const {
GrTextureAdjuster adjuster(this->peekTexture(), this->alphaType(), this->bounds(), this->uniqueID(),
this->onImageInfo().colorSpace());
- return adjuster.refTextureSafeForParams(params, gammaTreatment, nullptr);
+ return adjuster.refTextureSafeForParams(params, colorMode, nullptr);
}
static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) {
@@ -294,8 +294,9 @@ sk_sp<SkImage> SkImage::MakeFromNV12TexturesCopy(GrContext* ctx, SkYUVColorSpace
}
static sk_sp<SkImage> create_image_from_maker(GrTextureMaker* maker, SkAlphaType at, uint32_t id) {
- sk_sp<GrTexture> texture(maker->refTextureForParams(GrTextureParams::ClampNoFilter(),
- SkSourceGammaTreatment::kRespect));
+ sk_sp<GrTexture> texture(
+ maker->refTextureForParams(GrTextureParams::ClampNoFilter(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
if (!texture) {
return nullptr;
}
@@ -364,23 +365,23 @@ struct MipMapLevelData {
};
struct DeferredTextureImage {
- uint32_t fContextUniqueID;
- // Right now, the gamma treatment is only considered when generating mipmaps
- SkSourceGammaTreatment fGammaTreatment;
+ uint32_t fContextUniqueID;
+ // Right now, the destination color mode is only considered when generating mipmaps
+ SkDestinationSurfaceColorMode fColorMode;
// We don't store a SkImageInfo because it contains a ref-counted SkColorSpace.
- int fWidth;
- int fHeight;
- SkColorType fColorType;
- SkAlphaType fAlphaType;
- void* fColorSpace;
- size_t fColorSpaceSize;
- int fColorTableCnt;
- uint32_t* fColorTableData;
- int fMipMapLevelCount;
+ int fWidth;
+ int fHeight;
+ SkColorType fColorType;
+ SkAlphaType fAlphaType;
+ void* fColorSpace;
+ size_t fColorSpaceSize;
+ int fColorTableCnt;
+ uint32_t* fColorTableData;
+ int fMipMapLevelCount;
// The fMipMapLevelData array may contain more than 1 element.
// It contains fMipMapLevelCount elements.
// That means this struct's size is not known at compile-time.
- MipMapLevelData fMipMapLevelData[1];
+ MipMapLevelData fMipMapLevelData[1];
};
} // anonymous namespace
@@ -569,10 +570,10 @@ size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox
// If the context has sRGB support, and we're intending to render to a surface with an attached
// color space, and the image has an sRGB-like color space attached, then use our gamma (sRGB)
// aware mip-mapping.
- SkSourceGammaTreatment gammaTreatment = SkSourceGammaTreatment::kIgnore;
+ SkDestinationSurfaceColorMode colorMode = SkDestinationSurfaceColorMode::kLegacy;
if (proxy.fCaps->srgbSupport() && SkToBool(dstColorSpace) &&
info.colorSpace() && info.colorSpace()->gammaCloseToSRGB()) {
- gammaTreatment = SkSourceGammaTreatment::kRespect;
+ colorMode = SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware;
}
SkASSERT(info == pixmap.info());
@@ -580,7 +581,7 @@ size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox
static_assert(std::is_standard_layout<DeferredTextureImage>::value,
"offsetof, which we use below, requires the type have standard layout");
auto dtiBufferFiller = DTIBufferFiller{bufferAsCharPtr};
- FILL_MEMBER(dtiBufferFiller, fGammaTreatment, &gammaTreatment);
+ FILL_MEMBER(dtiBufferFiller, fColorMode, &colorMode);
FILL_MEMBER(dtiBufferFiller, fContextUniqueID, &proxy.fContextUniqueID);
int width = info.width();
FILL_MEMBER(dtiBufferFiller, fWidth, &width);
@@ -616,7 +617,7 @@ size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox
static_assert(std::is_standard_layout<MipMapLevelData>::value,
"offsetof, which we use below, requires the type have a standard layout");
- std::unique_ptr<SkMipMap> mipmaps(SkMipMap::Build(pixmap, gammaTreatment, nullptr));
+ std::unique_ptr<SkMipMap> mipmaps(SkMipMap::Build(pixmap, colorMode, nullptr));
// SkMipMap holds only the mipmap levels it generates.
// A programmer can use the data they provided to SkMipMap::Build as level 0.
// So the SkMipMap provides levels 1-x but it stores them in its own
@@ -690,7 +691,7 @@ sk_sp<SkImage> SkImage::MakeFromDeferredTextureImageData(GrContext* context, con
return SkImage::MakeTextureFromMipMap(context, info, texels.get(),
mipLevelCount, SkBudgeted::kYes,
- dti->fGammaTreatment);
+ dti->fColorMode);
}
}
@@ -699,7 +700,7 @@ sk_sp<SkImage> SkImage::MakeFromDeferredTextureImageData(GrContext* context, con
sk_sp<SkImage> SkImage::MakeTextureFromMipMap(GrContext* ctx, const SkImageInfo& info,
const GrMipLevel* texels, int mipLevelCount,
SkBudgeted budgeted,
- SkSourceGammaTreatment gammaTreatment) {
+ SkDestinationSurfaceColorMode colorMode) {
if (!ctx) {
return nullptr;
}
@@ -707,7 +708,7 @@ sk_sp<SkImage> SkImage::MakeTextureFromMipMap(GrContext* ctx, const SkImageInfo&
if (!texture) {
return nullptr;
}
- texture->texturePriv().setGammaTreatment(gammaTreatment);
+ texture->texturePriv().setMipColorMode(colorMode);
return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNewImageUniqueID,
info.alphaType(), std::move(texture),
sk_ref_sp(info.colorSpace()), budgeted);
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index b0380863b5..13c1e306dc 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -40,7 +40,7 @@ public:
bool getROPixels(SkBitmap*, CachingHint) const override;
GrTexture* asTextureRef(GrContext* ctx, const GrTextureParams& params,
- SkSourceGammaTreatment) const override;
+ SkDestinationSurfaceColorMode) const override;
sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
GrTexture* peekTexture() const override { return fTexture.get(); }
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 5799f0b3ef..ccddd25256 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -90,7 +90,7 @@ public:
SkData* onRefEncoded(GrContext*) const override;
bool getROPixels(SkBitmap*, CachingHint) const override;
GrTexture* asTextureRef(GrContext*, const GrTextureParams&,
- SkSourceGammaTreatment) const override;
+ SkDestinationSurfaceColorMode) const override;
sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
// exposed for SkSurface_Raster via SkNewImageFromPixelRef
@@ -198,7 +198,7 @@ bool SkImage_Raster::getROPixels(SkBitmap* dst, CachingHint) const {
}
GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& params,
- SkSourceGammaTreatment gammaTreatment) const {
+ SkDestinationSurfaceColorMode colorMode) const {
#if SK_SUPPORT_GPU
if (!ctx) {
return nullptr;
@@ -209,10 +209,10 @@ GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& p
if (tex) {
GrTextureAdjuster adjuster(fPinnedTexture.get(), fBitmap.alphaType(), fBitmap.bounds(),
fPinnedUniqueID, fBitmap.colorSpace());
- return adjuster.refTextureSafeForParams(params, gammaTreatment, nullptr);
+ return adjuster.refTextureSafeForParams(params, colorMode, nullptr);
}
- return GrRefCachedBitmapTexture(ctx, fBitmap, params, gammaTreatment);
+ return GrRefCachedBitmapTexture(ctx, fBitmap, params, colorMode);
#endif
return nullptr;
@@ -238,9 +238,9 @@ void SkImage_Raster::onPinAsTexture(GrContext* ctx) const {
} else {
SkASSERT(fPinnedCount == 0);
SkASSERT(fPinnedUniqueID == 0);
- fPinnedTexture.reset(GrRefCachedBitmapTexture(ctx, fBitmap,
- GrTextureParams::ClampNoFilter(),
- SkSourceGammaTreatment::kRespect));
+ fPinnedTexture.reset(
+ GrRefCachedBitmapTexture(ctx, fBitmap, GrTextureParams::ClampNoFilter(),
+ SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
fPinnedUniqueID = fBitmap.getGenerationID();
}
// Note: we always increment, even if we failed to create the pinned texture
diff --git a/tests/MipMapTest.cpp b/tests/MipMapTest.cpp
index 4bcbb69697..7e0a653c1e 100644
--- a/tests/MipMapTest.cpp
+++ b/tests/MipMapTest.cpp
@@ -23,7 +23,7 @@ DEF_TEST(MipMap, reporter) {
int width = 1 + rand.nextU() % 1000;
int height = 1 + rand.nextU() % 1000;
make_bitmap(&bm, width, height);
- sk_sp<SkMipMap> mm(SkMipMap::Build(bm, SkSourceGammaTreatment::kIgnore, nullptr));
+ sk_sp<SkMipMap> mm(SkMipMap::Build(bm, SkDestinationSurfaceColorMode::kLegacy, nullptr));
REPORTER_ASSERT(reporter, mm->countLevels() == SkMipMap::ComputeLevelCount(width, height));
REPORTER_ASSERT(reporter, !mm->extractLevel(SkSize::Make(SK_Scalar1, SK_Scalar1),
@@ -60,7 +60,7 @@ static void test_mipmap_generation(int width, int height, int expectedMipLevelCo
SkBitmap bm;
bm.allocN32Pixels(width, height);
bm.eraseColor(SK_ColorWHITE);
- sk_sp<SkMipMap> mm(SkMipMap::Build(bm, SkSourceGammaTreatment::kIgnore, nullptr));
+ sk_sp<SkMipMap> mm(SkMipMap::Build(bm, SkDestinationSurfaceColorMode::kLegacy, nullptr));
const int mipLevelCount = mm->countLevels();
REPORTER_ASSERT(reporter, mipLevelCount == expectedMipLevelCount);
@@ -90,7 +90,7 @@ DEF_TEST(MipMap_DirectLevelAccess, reporter) {
SkBitmap bm;
bm.allocN32Pixels(1, 1);
bm.eraseColor(SK_ColorWHITE);
- sk_sp<SkMipMap> mm(SkMipMap::Build(bm, SkSourceGammaTreatment::kIgnore, nullptr));
+ sk_sp<SkMipMap> mm(SkMipMap::Build(bm, SkDestinationSurfaceColorMode::kLegacy, nullptr));
REPORTER_ASSERT(reporter, mm == nullptr);
}
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 822f67652a..dad958f835 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -1369,7 +1369,7 @@ static sk_sp<GrTexture> make_mipmap_texture(GrTextureProvider* provider,
bm.allocN32Pixels(width, height, true);
bm.eraseColor(SK_ColorBLUE);
- sk_sp<SkMipMap> mipmaps(SkMipMap::Build(bm, SkSourceGammaTreatment::kIgnore, nullptr));
+ sk_sp<SkMipMap> mipmaps(SkMipMap::Build(bm, SkDestinationSurfaceColorMode::kLegacy, nullptr));
SkASSERT(mipmaps);
SkASSERT(mipmaps->countLevels() > 1);
diff --git a/tests/SkResourceCacheTest.cpp b/tests/SkResourceCacheTest.cpp
index 9275dff7d2..c8da135b0d 100644
--- a/tests/SkResourceCacheTest.cpp
+++ b/tests/SkResourceCacheTest.cpp
@@ -96,17 +96,17 @@ static void test_mipmapcache(skiatest::Reporter* reporter, SkResourceCache* cach
src.allocN32Pixels(5, 5);
src.setImmutable();
- const SkSourceGammaTreatment treatment = SkSourceGammaTreatment::kIgnore;
+ const SkDestinationSurfaceColorMode colorMode = SkDestinationSurfaceColorMode::kLegacy;
- const SkMipMap* mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), treatment,
+ const SkMipMap* mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), colorMode,
cache);
REPORTER_ASSERT(reporter, nullptr == mipmap);
- mipmap = SkMipMapCache::AddAndRef(src, treatment, cache);
+ mipmap = SkMipMapCache::AddAndRef(src, colorMode, cache);
REPORTER_ASSERT(reporter, mipmap);
{
- const SkMipMap* mm = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), treatment,
+ const SkMipMap* mm = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), colorMode,
cache);
REPORTER_ASSERT(reporter, mm);
REPORTER_ASSERT(reporter, mm == mipmap);
@@ -121,7 +121,7 @@ static void test_mipmapcache(skiatest::Reporter* reporter, SkResourceCache* cach
check_data(reporter, mipmap, 1, kInCache, kNotLocked);
// find us again
- mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), treatment, cache);
+ mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), colorMode, cache);
check_data(reporter, mipmap, 2, kInCache, kLocked);
cache->purgeAll();
@@ -131,19 +131,19 @@ static void test_mipmapcache(skiatest::Reporter* reporter, SkResourceCache* cach
}
static void test_mipmap_notify(skiatest::Reporter* reporter, SkResourceCache* cache) {
- const SkSourceGammaTreatment treatment = SkSourceGammaTreatment::kIgnore;
+ const SkDestinationSurfaceColorMode colorMode = SkDestinationSurfaceColorMode::kLegacy;
const int N = 3;
SkBitmap src[N];
for (int i = 0; i < N; ++i) {
src[i].allocN32Pixels(5, 5);
src[i].setImmutable();
- SkMipMapCache::AddAndRef(src[i], treatment, cache)->unref();
+ SkMipMapCache::AddAndRef(src[i], colorMode, cache)->unref();
}
for (int i = 0; i < N; ++i) {
const SkMipMap* mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src[i]),
- treatment, cache);
+ colorMode, cache);
if (cache) {
// if cache is null, we're working on the global cache, and other threads might purge
// it, making this check fragile.
@@ -153,7 +153,7 @@ static void test_mipmap_notify(skiatest::Reporter* reporter, SkResourceCache* ca
src[i].reset(); // delete the underlying pixelref, which *should* remove us from the cache
- mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src[i]), treatment, cache);
+ mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src[i]), colorMode, cache);
REPORTER_ASSERT(reporter, !mipmap);
}
}