aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTextureParamsAdjuster.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-11-12 09:59:44 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-12 09:59:44 -0800
commit3aa5fce54e1d8f4a682eaf6446fa73df962b3778 (patch)
treec8d99b821094aeac779977c17141d7d3e7993b66 /src/gpu/GrTextureParamsAdjuster.cpp
parent147ea2fb7ad9adeeb52fe5549f7ba20953296f6f (diff)
API changes to GrTextureAdjuster.
These changes are to facilitate converting SkGpuDevice::drawTextureAdjuster to SkGpuDevice::drawTextureProducer. Make constraint rect relative to content area Store dimensions in GrTextureProducer Make originalTexture() protected. Remove getContentArea() Provide pre-normalized texture matrix to GrTextureAdjuster::createFragmentProcessor. Define it to be be relative to content area. Review URL: https://codereview.chromium.org/1438663004
Diffstat (limited to 'src/gpu/GrTextureParamsAdjuster.cpp')
-rw-r--r--src/gpu/GrTextureParamsAdjuster.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp
index 37f1d8156e..0547d95053 100644
--- a/src/gpu/GrTextureParamsAdjuster.cpp
+++ b/src/gpu/GrTextureParamsAdjuster.cpp
@@ -120,7 +120,9 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset,
}
GrTextureAdjuster::GrTextureAdjuster(GrTexture* original, const SkIRect& contentArea)
- : fOriginal(original) {
+ : INHERITED(contentArea.width(), contentArea.height())
+ , fOriginal(original) {
+ SkASSERT(SkIRect::MakeWH(original->width(), original->height()).contains(contentArea));
if (contentArea.fLeft > 0 || contentArea.fTop > 0 ||
contentArea.fRight < original->width() || contentArea.fBottom < original->height()) {
fContentArea.set(contentArea);
@@ -323,18 +325,28 @@ static DomainMode determine_domain_mode(
}
const GrFragmentProcessor* GrTextureAdjuster::createFragmentProcessor(
- const SkMatrix& textureMatrix,
- const SkRect& constraintRect,
+ const SkMatrix& origTextureMatrix,
+ const SkRect& origConstraintRect,
FilterConstraint filterConstraint,
bool coordsLimitedToConstraintRect,
const GrTextureParams::FilterMode* filterOrNullForBicubic) {
+ SkMatrix textureMatrix = origTextureMatrix;
const SkIRect* contentArea = this->contentAreaOrNull();
+ // Convert the constraintRect to be relative to the texture rather than the content area so
+ // that both rects are in the same coordinate system.
+ SkTCopyOnFirstWrite<SkRect> constraintRect(origConstraintRect);
+ if (contentArea) {
+ SkScalar l = SkIntToScalar(contentArea->fLeft);
+ SkScalar t = SkIntToScalar(contentArea->fTop);
+ constraintRect.writable()->offset(l, t);
+ textureMatrix.postTranslate(l, t);
+ }
SkRect domain;
GrTexture* texture = this->originalTexture();
DomainMode domainMode =
- determine_domain_mode(constraintRect, filterConstraint, coordsLimitedToConstraintRect,
+ determine_domain_mode(*constraintRect, filterConstraint, coordsLimitedToConstraintRect,
texture->width(), texture->height(),
contentArea, filterOrNullForBicubic,
&domain);
@@ -348,13 +360,14 @@ const GrFragmentProcessor* GrTextureAdjuster::createFragmentProcessor(
GrTextureParams::kMipMap_FilterMode == *filterOrNullForBicubic);
static const GrTextureParams::FilterMode kBilerp = GrTextureParams::kBilerp_FilterMode;
domainMode =
- determine_domain_mode(constraintRect, filterConstraint, coordsLimitedToConstraintRect,
+ determine_domain_mode(*constraintRect, filterConstraint, coordsLimitedToConstraintRect,
texture->width(), texture->height(),
contentArea, &kBilerp, &domain);
SkASSERT(kTightCopy_DomainMode != domainMode);
}
SkASSERT(kNoDomain_DomainMode == domainMode ||
(domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom));
+ textureMatrix.postIDiv(texture->width(), texture->height());
if (filterOrNullForBicubic) {
if (kDomain_DomainMode == domainMode) {
return GrTextureDomainEffect::Create(texture, textureMatrix, domain,