diff options
author | Greg Daniel <egdaniel@google.com> | 2017-11-01 16:38:48 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-02 13:11:31 +0000 |
commit | c77085d2e0a3ff7e908a7164ac6224ea10686739 (patch) | |
tree | ca804bb45e7e257e324cd31a1e2215b93ad0ba07 /src/gpu/GrTextureAdjuster.cpp | |
parent | d1b2eec0d0f95977b52669025cb25038618c0335 (diff) |
Remove content area from GrTextureAdjuster.
Bug: skia:
Change-Id: I77854ee22303afe5787bf3094bca2db1a3dcf5ef
Reviewed-on: https://skia-review.googlesource.com/66149
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/GrTextureAdjuster.cpp')
-rw-r--r-- | src/gpu/GrTextureAdjuster.cpp | 53 |
1 files changed, 12 insertions, 41 deletions
diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp index 2ae95a929e..d8985fed12 100644 --- a/src/gpu/GrTextureAdjuster.cpp +++ b/src/gpu/GrTextureAdjuster.cpp @@ -15,21 +15,15 @@ GrTextureAdjuster::GrTextureAdjuster(GrContext* context, sk_sp<GrTextureProxy> original, SkAlphaType alphaType, - const SkIRect& contentArea, uint32_t uniqueID, + uint32_t uniqueID, SkColorSpace* cs) - : INHERITED(contentArea.width(), contentArea.height(), + : INHERITED(original->width(), original->height(), GrPixelConfigIsAlphaOnly(original->config())) , fContext(context) , fOriginal(std::move(original)) , fAlphaType(alphaType) , fColorSpace(cs) - , fUniqueID(uniqueID) { - SkASSERT(SkIRect::MakeWH(fOriginal->width(), fOriginal->height()).contains(contentArea)); - SkASSERT(0 == contentArea.fLeft && 0 == contentArea.fTop); - if (contentArea.fRight < fOriginal->width() || contentArea.fBottom < fOriginal->height()) { - fContentArea.set(contentArea); - } -} + , fUniqueID(uniqueID) {} void GrTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey, SkColorSpace* dstColorSpace) { @@ -57,10 +51,8 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxyCopy(const CopyParams& c } sk_sp<GrTextureProxy> proxy = this->originalProxyRef(); - const SkIRect* contentArea = this->contentAreaOrNull(); - sk_sp<GrTextureProxy> copy = CopyOnGpu(fContext, std::move(proxy), contentArea, copyParams, - willBeMipped); + sk_sp<GrTextureProxy> copy = CopyOnGpu(fContext, std::move(proxy), copyParams, willBeMipped); if (copy) { if (key.isValid()) { SkASSERT(copy->origin() == this->originalProxy()->origin()); @@ -75,46 +67,29 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxySafeForParams(const GrSa SkScalar scaleAdjust[2]) { sk_sp<GrTextureProxy> proxy = this->originalProxyRef(); CopyParams copyParams; - const SkIRect* contentArea = this->contentAreaOrNull(); if (!fContext) { // The texture was abandoned. return nullptr; } - bool willBeMipped = GrSamplerState::Filter::kMipMap == params.filter(); - if (contentArea && willBeMipped) { - // If we generate a MIP chain for texture it will read pixel values from outside the content - // area. - copyParams.fWidth = contentArea->width(); - copyParams.fHeight = contentArea->height(); - copyParams.fFilter = GrSamplerState::Filter::kBilerp; - } else if (!fContext->getGpu()->isACopyNeededForTextureParams(proxy.get(), params, ©Params, - scaleAdjust)) { + if (!fContext->getGpu()->isACopyNeededForTextureParams(proxy.get(), params, ©Params, + scaleAdjust)) { return proxy; } + bool willBeMipped = GrSamplerState::Filter::kMipMap == params.filter(); return this->refTextureProxyCopy(copyParams, willBeMipped); } std::unique_ptr<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor( const SkMatrix& origTextureMatrix, - const SkRect& origConstraintRect, + const SkRect& constraintRect, FilterConstraint filterConstraint, bool coordsLimitedToConstraintRect, const GrSamplerState::Filter* filterOrNullForBicubic, SkColorSpace* dstColorSpace) { 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; GrSamplerState samplerState; @@ -130,15 +105,12 @@ std::unique_ptr<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor( // If we made a copy then we only copied the contentArea, in which case the new texture is all // content. if (proxy.get() != this->originalProxy()) { - contentArea = nullptr; textureMatrix.postScale(scaleAdjust[0], scaleAdjust[1]); } DomainMode domainMode = - DetermineDomainMode(*constraintRect, filterConstraint, coordsLimitedToConstraintRect, - proxy.get(), - contentArea, filterOrNullForBicubic, - &domain); + DetermineDomainMode(constraintRect, filterConstraint, coordsLimitedToConstraintRect, + proxy.get(), filterOrNullForBicubic, &domain); if (kTightCopy_DomainMode == domainMode) { // TODO: Copy the texture and adjust the texture matrix (both parts need to consider // non-int constraint rect) @@ -149,9 +121,8 @@ std::unique_ptr<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor( GrSamplerState::Filter::kMipMap == *filterOrNullForBicubic); static const GrSamplerState::Filter kBilerp = GrSamplerState::Filter::kBilerp; domainMode = - DetermineDomainMode(*constraintRect, filterConstraint, coordsLimitedToConstraintRect, - proxy.get(), - contentArea, &kBilerp, &domain); + DetermineDomainMode(constraintRect, filterConstraint, coordsLimitedToConstraintRect, + proxy.get(), &kBilerp, &domain); SkASSERT(kTightCopy_DomainMode != domainMode); } SkASSERT(kNoDomain_DomainMode == domainMode || |