aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTextureProducer.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-05-04 13:43:19 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-07 18:08:40 +0000
commit2a943df011ef8cfbc9b4f8829ebf9f6385e40054 (patch)
tree6cd980ebdb5655cdeb15d4526d624b5ae2f8b2ee /src/gpu/GrTextureProducer.cpp
parent817847c0c6ca538d5a1b87647dc94cdc31b30c41 (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.cpp')
-rw-r--r--src/gpu/GrTextureProducer.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index feee9dd3c7..d35d807c54 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -208,3 +208,25 @@ std::unique_ptr<GrFragmentProcessor> GrTextureProducer::CreateFragmentProcessorF
}
}
}
+
+sk_sp<GrTextureProxy> GrTextureProducer::refTextureProxyForParams(
+ const GrSamplerState& sampler,
+ SkColorSpace* dstColorSpace,
+ sk_sp<SkColorSpace>* proxyColorSpace,
+ SkScalar scaleAdjust[2]) {
+ // Check that the caller pre-initialized scaleAdjust
+ SkASSERT(!scaleAdjust || (scaleAdjust[0] == 1 && scaleAdjust[1] == 1));
+ // Check that if the caller passed nullptr for scaleAdjust that we're in the case where there
+ // can be no scaling.
+ SkDEBUGCODE(bool expectNoScale = (sampler.filter() != GrSamplerState::Filter::kMipMap &&
+ !sampler.isRepeated()));
+ SkASSERT(scaleAdjust || expectNoScale);
+ auto result =
+ this->onRefTextureProxyForParams(sampler, dstColorSpace, proxyColorSpace, scaleAdjust);
+
+ // Check that the "no scaling expected" case always returns a proxy of the same size as the
+ // producer.
+ SkASSERT(!result || !expectNoScale ||
+ (result->width() == this->width() && result->height() == this->height()));
+ return result;
+}