diff options
author | Brian Salomon <bsalomon@google.com> | 2018-05-04 13:43:19 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-07 18:08:40 +0000 |
commit | 2a943df011ef8cfbc9b4f8829ebf9f6385e40054 (patch) | |
tree | 6cd980ebdb5655cdeb15d4526d624b5ae2f8b2ee /src/gpu/GrTextureProducer.h | |
parent | 817847c0c6ca538d5a1b87647dc94cdc31b30c41 (diff) |
Make GPU lattice/nine patch not bleed across cells.
Consolidate code for handling various image/bitmap and lattice/ninepatch flavors.
Makes refTextureForParams virtual on GrTextureProducer. Previously both subclasses had non-virtual flavors of this.
Bug: b/77917978
Change-Id: I14787faef33c4617ef359039e81453d683f33ff1
Reviewed-on: https://skia-review.googlesource.com/125520
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrTextureProducer.h')
-rw-r--r-- | src/gpu/GrTextureProducer.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/gpu/GrTextureProducer.h b/src/gpu/GrTextureProducer.h index 88ba14afa8..467948dfa6 100644 --- a/src/gpu/GrTextureProducer.h +++ b/src/gpu/GrTextureProducer.h @@ -69,6 +69,35 @@ public: const GrSamplerState::Filter* filterOrNullForBicubic, SkColorSpace* dstColorSpace) = 0; + /** + * 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 may have been scaled to fit the texture or the original may have been copied into + * a subrect of the copy. 'scaleAdjust' must be applied to the normalized texture coordinates + * in order to correct for the latter case. + * + * If the GrSamplerState is known to clamp and use kNearest or kBilerp filter mode then the + * proxy will always be unscaled and nullptr can be passed for scaleAdjust. There is a weird + * contract that if scaleAdjust is not null it must be initialized to {1, 1} before calling + * this method. (TODO: Fix this and make this function always initialize scaleAdjust). + * + * Places the color space of the texture in (*proxyColorSpace). + */ + sk_sp<GrTextureProxy> refTextureProxyForParams(const GrSamplerState&, + SkColorSpace* dstColorSpace, + sk_sp<SkColorSpace>* proxyColorSpace, + SkScalar scaleAdjust[2]); + + sk_sp<GrTextureProxy> refTextureProxyForParams(GrSamplerState::Filter filter, + SkColorSpace* dstColorSpace, + sk_sp<SkColorSpace>* proxyColorSpace, + SkScalar scaleAdjust[2]) { + return this->refTextureProxyForParams( + GrSamplerState(GrSamplerState::WrapMode::kClamp, filter), dstColorSpace, + proxyColorSpace, scaleAdjust); + } + virtual ~GrTextureProducer() {} int width() const { return fWidth; } @@ -142,6 +171,11 @@ protected: const GrSamplerState::Filter* filterOrNullForBicubic); private: + virtual sk_sp<GrTextureProxy> onRefTextureProxyForParams(const GrSamplerState&, + SkColorSpace* dstColorSpace, + sk_sp<SkColorSpace>* proxyColorSpace, + SkScalar scaleAdjust[2]) = 0; + const int fWidth; const int fHeight; const bool fIsAlphaOnly; |