diff options
author | 2016-11-08 17:08:54 -0500 | |
---|---|---|
committer | 2016-11-09 01:05:07 +0000 | |
commit | 7b8400dad2f82dcc6ed3c7cc1707ebaf85f04840 (patch) | |
tree | dc1e131776fb1922b113f1a5e723205d8c13ccfe /src/image | |
parent | c8b15684fe5b5b924b90091fedfbedf2806535e0 (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>
Diffstat (limited to 'src/image')
-rw-r--r-- | src/image/SkImage.cpp | 2 | ||||
-rw-r--r-- | src/image/SkImageShader.cpp | 3 | ||||
-rw-r--r-- | src/image/SkImage_Base.h | 2 | ||||
-rw-r--r-- | src/image/SkImage_Generator.cpp | 6 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 49 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.h | 2 | ||||
-rw-r--r-- | src/image/SkImage_Raster.cpp | 14 |
7 files changed, 39 insertions, 39 deletions
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 |