Rename SkSourceGammaTreatment to SkDestinationSurfaceColorMode
authorBrian Osman <brianosman@google.com>
Tue, 8 Nov 2016 22:08:54 +0000 (17:08 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 9 Nov 2016 01:05:07 +0000 (01:05 +0000)
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>
52 files changed:
bench/MipMapBench.cpp
experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
gm/image_pict.cpp
gm/showmiplevels.cpp
gm/texturedomaineffect.cpp
gm/yuvtorgbeffect.cpp
include/core/SkImage.h
include/core/SkImageInfo.h
include/core/SkShader.h
include/gpu/GrRenderTargetContext.h
include/gpu/GrTexture.h
include/gpu/SkGr.h
src/core/SkBitmapCache.cpp
src/core/SkBitmapCache.h
src/core/SkBitmapController.cpp
src/core/SkBitmapController.h
src/core/SkBitmapProcShader.cpp
src/core/SkBitmapProcState.cpp
src/core/SkBitmapProcState.h
src/core/SkImageCacherator.cpp
src/core/SkImageCacherator.h
src/core/SkLocalMatrixShader.cpp
src/core/SkMipMap.cpp
src/core/SkMipMap.h
src/core/SkPictureShader.cpp
src/core/SkShadowShader.cpp
src/core/SkSpecialImage.cpp
src/effects/SkPerlinNoiseShader.cpp
src/effects/SkTableColorFilter.cpp
src/effects/gradients/SkGradientShader.cpp
src/gpu/GrImageIDTextureAdjuster.cpp
src/gpu/GrImageIDTextureAdjuster.h
src/gpu/GrTestUtils.cpp
src/gpu/GrTexture.cpp
src/gpu/GrTextureParamsAdjuster.cpp
src/gpu/GrTextureParamsAdjuster.h
src/gpu/GrTexturePriv.h
src/gpu/SkGpuDevice.cpp
src/gpu/SkGpuDevice_drawTexture.cpp
src/gpu/SkGr.cpp
src/gpu/SkGrPriv.h
src/gpu/gl/GrGLGpu.cpp
src/image/SkImage.cpp
src/image/SkImageShader.cpp
src/image/SkImage_Base.h
src/image/SkImage_Generator.cpp
src/image/SkImage_Gpu.cpp
src/image/SkImage_Gpu.h
src/image/SkImage_Raster.cpp
tests/MipMapTest.cpp
tests/ResourceCacheTest.cpp
tests/SkResourceCacheTest.cpp

index 1f41e81..57e4588 100644 (file)
@@ -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); )
index fcbf017..130e116 100644 (file)
@@ -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(
index 8cbd287..903024b 100644 (file)
@@ -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;
index 2386e1d..a4fd164 100644 (file)
@@ -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;
index cac193b..b76c70e 100644 (file)
@@ -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;
         }
index e3b78a6..307ea7c 100644 (file)
@@ -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;
index 53ae04e..02b632b 100644 (file)
@@ -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;
index eac8c0f..f8582d6 100644 (file)
@@ -169,9 +169,9 @@ enum SkYUVColorSpace {
 
 ///////////////////////////////////////////////////////////////////////////////
 
-enum class SkSourceGammaTreatment {
-    kRespect,
-    kIgnore,
+enum class SkDestinationSurfaceColorMode {
+    kLegacy,
+    kGammaAndColorSpaceAware,
 };
 
 /**
index 2f83694..0781877 100644 (file)
@@ -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;
     };
 
     /**
index 95d8c9d..a3869a3 100644 (file)
@@ -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(); }
index 8fa0db9..7381a90 100644 (file)
@@ -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;
index fc13c38..fae0c76 100644 (file)
@@ -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*,
index e6a664b..0751089 100644 (file)
@@ -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();
     }
index 76bcef0..522c93e 100644 (file)
@@ -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);
 };
 
index ffeb10c..435940b 100644 (file)
@@ -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);
 }
index f31c8ee..2e7a9f3 100644 (file)
@@ -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
index e4309b6..06ad04b 100644 (file)
@@ -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;
index 26ee82e..7b88ab6 100644 (file)
@@ -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?
index e2e4f96..1818406 100644 (file)
@@ -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();
index 9401b35..54045d5 100644 (file)
@@ -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;
 }
index 8bf335b..a8a05a1 100644 (file)
@@ -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;
index 506fd3e..fb436d8 100644 (file)
@@ -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
 
index c5bd3ac..ba3cb18 100644 (file)
@@ -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 {
index 0f31a9f..f3425cb 100644 (file)
@@ -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.
index ad954d2..74cce68 100644 (file)
@@ -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
index c3ede80..8737b32 100644 (file)
@@ -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]);
 
index e750571..239d9a9 100644 (file)
@@ -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);
         }
 
index 87db93d..0b34d16 100644 (file)
@@ -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);
index 289dee7..cd786df 100644 (file)
@@ -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()));
     }
index 0bd9c87..3bf569c 100644 (file)
@@ -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;
                 }
index 5a96b6d..cc869ba 100644 (file)
@@ -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) {
index 36ac0ad..b0b7048 100644 (file)
@@ -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;
 
index 704b128..6dfe670 100644 (file)
@@ -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
index 6fc1580..807fb9b 100644 (file)
@@ -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);
index 43bfec8..fa1fffd 100644 (file)
@@ -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;
     }
index 3de4db7..1784ab6 100644 (file)
@@ -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; }
 
index c4c1855..e8721bc 100644 (file)
@@ -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*);
 
index 19c6377..f7f7c02 100644 (file)
@@ -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(),
index d50b050..f232e19 100644 (file)
@@ -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;
     }
index 679ba8c..d74e259 100644 (file)
@@ -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;
             }
index 3aa8a0c..ecbe558 100644 (file)
@@ -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.
index 266f3a8..9ccd073 100644 (file)
@@ -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();
index 22cb5cb..3ae7ed7 100644 (file)
@@ -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;
 }
 
index f58228c..eed8175 100644 (file)
@@ -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;
     }
index b314cc6..3a4aabd 100644 (file)
@@ -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;
 
index 483ebdf..03dda91 100644 (file)
@@ -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 {
index 5e2d1a5..a006e14 100644 (file)
@@ -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);
index b038086..13c1e30 100644 (file)
@@ -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(); }
index 5799f0b..ccddd25 100644 (file)
@@ -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
index 4bcbb69..7e0a653 100644 (file)
@@ -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);
     }
index 822f676..dad958f 100644 (file)
@@ -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);
 
index 9275dff..c8da135 100644 (file)
@@ -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);
     }
 }