diff options
author | Brian Salomon <bsalomon@google.com> | 2018-05-25 10:08:05 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-25 14:41:52 +0000 |
commit | 869433fa113d1573d5d91fcafdca413b247ce1b0 (patch) | |
tree | 92c495186273db105c0dc7803457cac63298981b | |
parent | 71e83e85074187fce322851546e05f435cb8c7c4 (diff) |
Turn off domain in GrTextureOp when src rect contains entire proxy
Move check for turning off domain when nearest/no-aa to GrRenderTargetContext.
Change-Id: I3c071b5f73fb3134218453204f30c3020c9dad9a
Reviewed-on: https://skia-review.googlesource.com/130143
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
-rw-r--r-- | include/private/GrSurfaceProxy.h | 23 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetContext.cpp | 11 | ||||
-rw-r--r-- | src/gpu/ops/GrTextureOp.cpp | 5 |
3 files changed, 25 insertions, 14 deletions
diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h index 1c18492cbd..9499edfde3 100644 --- a/include/private/GrSurfaceProxy.h +++ b/include/private/GrSurfaceProxy.h @@ -239,6 +239,21 @@ public: } int worstCaseWidth() const; int worstCaseHeight() const; + /** + * Helper that gets the width and height of the surface as a bounding rectangle. + */ + SkRect getBoundsRect() const { + SkASSERT(LazyState::kFully != this->lazyInstantiationState()); + return SkRect::MakeIWH(this->width(), this->height()); + } + /** + * Helper that gets the worst case width and height of the surface as a bounding rectangle. + */ + SkRect getWorstCaseBoundsRect() const { + SkASSERT(LazyState::kFully != this->lazyInstantiationState()); + return SkRect::MakeIWH(this->worstCaseWidth(), this->worstCaseHeight()); + } + GrSurfaceOrigin origin() const { SkASSERT(kTopLeft_GrSurfaceOrigin == fOrigin || kBottomLeft_GrSurfaceOrigin == fOrigin); return fOrigin; @@ -303,14 +318,6 @@ public: void deInstantiate(); /** - * Helper that gets the width and height of the surface as a bounding rectangle. - */ - SkRect getBoundsRect() const { - SkASSERT(LazyState::kFully != this->lazyInstantiationState()); - return SkRect::MakeIWH(this->width(), this->height()); - } - - /** * @return the texture proxy associated with the surface proxy, may be NULL. */ virtual GrTextureProxy* asTextureProxy() { return nullptr; } diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index f4db697e41..456d8e4a82 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -776,13 +776,22 @@ void GrRenderTargetContext::drawTexture(const GrClip& clip, sk_sp<GrTextureProxy if (filter != GrSamplerState::Filter::kNearest && !must_filter(srcRect, dstRect, viewMatrix)) { filter = GrSamplerState::Filter::kNearest; } + GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo); + if (constraint == SkCanvas::kStrict_SrcRectConstraint) { + // No need to use a texture domain with nearest filtering unless there is AA bloating. + // Also, no need if the srcRect contains the entire texture. + if (filter == GrSamplerState::Filter::kNearest && aaType != GrAAType::kCoverage) { + constraint = SkCanvas::kFast_SrcRectConstraint; + } else if (srcRect.contains(proxy->getWorstCaseBoundsRect())) { + constraint = SkCanvas::kFast_SrcRectConstraint; + } + } SkRect clippedDstRect = dstRect; SkRect clippedSrcRect = srcRect; if (!crop_filled_rect(this->width(), this->height(), clip, viewMatrix, &clippedDstRect, &clippedSrcRect)) { return; } - GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo); bool allowSRGB = SkToBool(this->colorSpaceInfo().colorSpace()); this->addDrawOp(clip, GrTextureOp::Make(std::move(proxy), filter, color, clippedSrcRect, clippedDstRect, aaType, constraint, viewMatrix, diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp index 4d0c41d127..5724050234 100644 --- a/src/gpu/ops/GrTextureOp.cpp +++ b/src/gpu/ops/GrTextureOp.cpp @@ -709,11 +709,6 @@ __attribute__((no_sanitize("float-cast-overflow"))) , fFinalized(0) , fAllowSRGBInputs(allowSRGBInputs ? 1 : 0) { SkASSERT(aaType != GrAAType::kMixedSamples); - // No need to use a texture domain with nearest filtering unless there is AA bloating. - if (constraint == SkCanvas::kStrict_SrcRectConstraint && - filter == GrSamplerState::Filter::kNearest && GrAAType::kCoverage != aaType) { - constraint = SkCanvas::kFast_SrcRectConstraint; - } const Draw& draw = fDraws.emplace_back(srcRect, 0, GrPerspQuad(dstRect, viewMatrix), constraint, color); |