diff options
author | brianosman <brianosman@google.com> | 2016-07-18 10:53:52 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-18 10:53:52 -0700 |
commit | 54f30c13fc0a5d89797fc9be5f0fb1050d96b6f4 (patch) | |
tree | 484d25c1b668126bd51203cd1875d7c47f34a1bf /src/gpu/effects/GrBicubicEffect.h | |
parent | baaea531c249d3a13b0d04eca59b8bd0ee58d76b (diff) |
Introduce GrColorSpaceXform, for gamut conversion on textures
GrTextureAccess optionally includes an instance, computed from the src
and dst color spaces. In all common cases (no color space for either src
or dst, or same color space for both), no object is allocated.
This change is orthogonal to my attempts to get color space attached to
render targets - regardless of how we choose to do that, this will give
us the source color space at all points where we are connecting src to
dst.
There are many dangling injection points where I've been inserting
nullptr, but I have a record of all of them. Additionally, there are now
three places (the most common simple paths for bitmap/image rendering)
where things are plumbed enough that I expect to have access to the dst
color space (all marked with XFORMTODO).
In addition to getting the dst color space, I need to inject shader code
and uniform uploading for appendTextureLookup and friends.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2154753003
Review-Url: https://codereview.chromium.org/2154753003
Diffstat (limited to 'src/gpu/effects/GrBicubicEffect.h')
-rw-r--r-- | src/gpu/effects/GrBicubicEffect.h | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h index 3c84f97919..58bb068d5f 100644 --- a/src/gpu/effects/GrBicubicEffect.h +++ b/src/gpu/effects/GrBicubicEffect.h @@ -29,19 +29,23 @@ public: const GrTextureDomain& domain() const { return fDomain; } + GrColorSpaceXform* colorSpaceXform() const { return fColorSpaceXform.get(); } + /** * Create a simple filter effect with custom bicubic coefficients and optional domain. */ - static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, const SkScalar coefficients[16], + static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, + sk_sp<GrColorSpaceXform> colorSpaceXform, + const SkScalar coefficients[16], const SkRect* domain = nullptr) { if (nullptr == domain) { static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_TileMode, SkShader::kClamp_TileMode }; - return Make(tex, coefficients, GrCoordTransform::MakeDivByTextureWHMatrix(tex), - kTileModes); + return Make(tex, std::move(colorSpaceXform), coefficients, + GrCoordTransform::MakeDivByTextureWHMatrix(tex), kTileModes); } else { return sk_sp<GrFragmentProcessor>( - new GrBicubicEffect(tex, coefficients, + new GrBicubicEffect(tex, std::move(colorSpaceXform), coefficients, GrCoordTransform::MakeDivByTextureWHMatrix(tex), *domain)); } } @@ -49,28 +53,35 @@ public: /** * Create a Mitchell filter effect with specified texture matrix and x/y tile modes. */ - static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, const SkMatrix& matrix, + static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, + sk_sp<GrColorSpaceXform> colorSpaceXform, + const SkMatrix& matrix, const SkShader::TileMode tileModes[2]) { - return Make(tex, gMitchellCoefficients, matrix, tileModes); + return Make(tex, std::move(colorSpaceXform), gMitchellCoefficients, matrix, tileModes); } /** * Create a filter effect with custom bicubic coefficients, the texture matrix, and the x/y * tilemodes. */ - static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, const SkScalar coefficients[16], + static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, + sk_sp<GrColorSpaceXform> colorSpaceXform, + const SkScalar coefficients[16], const SkMatrix& matrix, const SkShader::TileMode tileModes[2]) { - return sk_sp<GrFragmentProcessor>(new GrBicubicEffect(tex, coefficients, matrix, - tileModes)); + return sk_sp<GrFragmentProcessor>(new GrBicubicEffect(tex, std::move(colorSpaceXform), + coefficients, matrix, tileModes)); } /** * Create a Mitchell filter effect with a texture matrix and a domain. */ - static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, const SkMatrix& matrix, + static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, + sk_sp<GrColorSpaceXform> colorSpaceXform, + const SkMatrix& matrix, const SkRect& domain) { - return sk_sp<GrFragmentProcessor>(new GrBicubicEffect(tex, gMitchellCoefficients, matrix, + return sk_sp<GrFragmentProcessor>(new GrBicubicEffect(tex, std::move(colorSpaceXform), + gMitchellCoefficients, matrix, domain)); } @@ -85,10 +96,10 @@ public: GrTextureParams::FilterMode* filterMode); private: - GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], const SkMatrix &matrix, - const SkShader::TileMode tileModes[2]); - GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], const SkMatrix &matrix, - const SkRect& domain); + GrBicubicEffect(GrTexture*, sk_sp<GrColorSpaceXform>, const SkScalar coefficients[16], + const SkMatrix &matrix, const SkShader::TileMode tileModes[2]); + GrBicubicEffect(GrTexture*, sk_sp<GrColorSpaceXform>, const SkScalar coefficients[16], + const SkMatrix &matrix, const SkRect& domain); GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; @@ -100,6 +111,7 @@ private: float fCoefficients[16]; GrTextureDomain fDomain; + sk_sp<GrColorSpaceXform> fColorSpaceXform; GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |