aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-11-01 16:38:48 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-02 13:11:31 +0000
commitc77085d2e0a3ff7e908a7164ac6224ea10686739 (patch)
treeca804bb45e7e257e324cd31a1e2215b93ad0ba07
parentd1b2eec0d0f95977b52669025cb25038618c0335 (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>
-rw-r--r--src/gpu/GrTextureAdjuster.cpp53
-rw-r--r--src/gpu/GrTextureAdjuster.h8
-rw-r--r--src/gpu/GrTextureMaker.cpp7
-rw-r--r--src/gpu/GrTextureProducer.cpp70
-rw-r--r--src/gpu/GrTextureProducer.h3
-rw-r--r--src/gpu/SkGpuDevice.cpp8
-rw-r--r--src/gpu/SkGpuDevice_drawTexture.cpp5
-rw-r--r--src/image/SkImage_Gpu.cpp4
-rw-r--r--src/image/SkImage_Raster.cpp5
-rw-r--r--tests/DetermineDomainModeTest.cpp132
10 files changed, 78 insertions, 217 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, &copyParams,
- scaleAdjust)) {
+ if (!fContext->getGpu()->isACopyNeededForTextureParams(proxy.get(), params, &copyParams,
+ 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 ||
diff --git a/src/gpu/GrTextureAdjuster.h b/src/gpu/GrTextureAdjuster.h
index ca5b0e90c7..a0ce8c40db 100644
--- a/src/gpu/GrTextureAdjuster.h
+++ b/src/gpu/GrTextureAdjuster.h
@@ -35,8 +35,8 @@ public:
// We do not ref the texture nor the colorspace, so the caller must keep them in scope while
// this Adjuster is alive.
- GrTextureAdjuster(GrContext*, sk_sp<GrTextureProxy>, SkAlphaType, const SkIRect& area,
- uint32_t uniqueID, SkColorSpace*);
+ GrTextureAdjuster(GrContext*, sk_sp<GrTextureProxy>, SkAlphaType, uint32_t uniqueID,
+ SkColorSpace*);
protected:
SkAlphaType alphaType() const override { return fAlphaType; }
@@ -47,11 +47,7 @@ protected:
GrTextureProxy* originalProxy() const { return fOriginal.get(); }
sk_sp<GrTextureProxy> originalProxyRef() const { return fOriginal; }
- /** Returns the content area or null for the whole original texture */
- const SkIRect* contentAreaOrNull() { return fContentArea.getMaybeNull(); }
-
private:
- SkTLazy<SkIRect> fContentArea;
GrContext* fContext;
sk_sp<GrTextureProxy> fOriginal;
SkAlphaType fAlphaType;
diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp
index e234180d4b..b3a16f5d8c 100644
--- a/src/gpu/GrTextureMaker.cpp
+++ b/src/gpu/GrTextureMaker.cpp
@@ -73,7 +73,7 @@ sk_sp<GrTextureProxy> GrTextureMaker::refTextureProxyForParams(const GrSamplerSt
return nullptr;
}
- result = CopyOnGpu(fContext, std::move(result), nullptr, copyParams, willBeMipped);
+ result = CopyOnGpu(fContext, std::move(result), copyParams, willBeMipped);
if (!result) {
return nullptr;
@@ -133,8 +133,7 @@ std::unique_ptr<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor(
SkRect domain;
DomainMode domainMode =
DetermineDomainMode(constraintRect, filterConstraint, coordsLimitedToConstraintRect,
- proxy.get(),
- nullptr, fmForDetermineDomain, &domain);
+ proxy.get(), fmForDetermineDomain, &domain);
SkASSERT(kTightCopy_DomainMode != domainMode);
GrPixelConfig config = proxy->config();
auto fp = CreateFragmentProcessorForDomainAndFilter(std::move(proxy), adjustedMatrix,
@@ -151,5 +150,5 @@ sk_sp<GrTextureProxy> GrTextureMaker::generateTextureProxyForParams(const CopyPa
return nullptr;
}
- return CopyOnGpu(fContext, std::move(original), nullptr, copyParams, willBeMipped);
+ return CopyOnGpu(fContext, std::move(original), copyParams, willBeMipped);
}
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index f5ae0ad565..1be75f9649 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -16,10 +16,8 @@
sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context,
sk_sp<GrTextureProxy> inputProxy,
- const SkIRect* subset,
const CopyParams& copyParams,
bool dstWillRequireMipMaps) {
- SkASSERT(!subset || !subset->isEmpty());
SkASSERT(context);
const SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
@@ -35,23 +33,13 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context,
GrPaint paint;
paint.setGammaCorrect(true);
- SkRect localRect;
- if (subset) {
- localRect = SkRect::Make(*subset);
- } else {
- localRect = SkRect::MakeWH(inputProxy->width(), inputProxy->height());
- }
+ SkRect localRect = SkRect::MakeWH(inputProxy->width(), inputProxy->height());
bool needsDomain = false;
if (copyParams.fFilter != GrSamplerState::Filter::kNearest) {
bool resizing = localRect.width() != dstRect.width() ||
localRect.height() != dstRect.height();
-
- if (GrResourceProvider::IsFunctionallyExact(inputProxy.get())) {
- needsDomain = subset && resizing;
- } else {
- needsDomain = resizing;
- }
+ needsDomain = resizing && !GrResourceProvider::IsFunctionallyExact(inputProxy.get());
}
if (needsDomain) {
@@ -90,17 +78,11 @@ GrTextureProducer::DomainMode GrTextureProducer::DetermineDomainMode(
FilterConstraint filterConstraint,
bool coordsLimitedToConstraintRect,
GrTextureProxy* proxy,
- const SkIRect* contentRect,
const GrSamplerState::Filter* filterModeOrNullForBicubic,
SkRect* domainRect) {
const SkIRect proxyBounds = SkIRect::MakeWH(proxy->width(), proxy->height());
SkASSERT(proxyBounds.contains(constraintRect));
- // We only expect a content area rect if there is some non-content area.
- SkASSERT(!contentRect ||
- (!contentRect->contains(proxyBounds) &&
- proxyBounds.contains(*contentRect) &&
- contentRect->contains(constraintRect)));
const bool proxyIsExact = GrResourceProvider::IsFunctionallyExact(proxy);
@@ -109,16 +91,12 @@ GrTextureProducer::DomainMode GrTextureProducer::DetermineDomainMode(
return kNoDomain_DomainMode;
}
- if (!contentRect && !proxyIsExact) {
- contentRect = &proxyBounds;
- }
-
bool restrictFilterToRect = (filterConstraint == GrTextureProducer::kYes_FilterConstraint);
// If we can filter outside the constraint rect, and there is no non-content area of the
// proxy, and we aren't going to generate sample coords outside the constraint rect then we
// don't need a domain.
- if (!restrictFilterToRect && !contentRect && coordsLimitedToConstraintRect) {
+ if (!restrictFilterToRect && proxyIsExact && coordsLimitedToConstraintRect) {
return kNoDomain_DomainMode;
}
@@ -137,7 +115,7 @@ GrTextureProducer::DomainMode GrTextureProducer::DetermineDomainMode(
filterHalfWidth = .5f;
break;
case GrSamplerState::Filter::kMipMap:
- if (restrictFilterToRect || contentRect) {
+ if (restrictFilterToRect || !proxyIsExact) {
// No domain can save us here.
return kTightCopy_DomainMode;
}
@@ -157,10 +135,10 @@ GrTextureProducer::DomainMode GrTextureProducer::DetermineDomainMode(
// the domain.
if (restrictFilterToRect) {
*domainRect = constraintRect.makeInset(kDomainInset, kDomainInset);
- } else if (contentRect) {
- // If we got here then: there is a contentRect, the coords are limited to the
+ } else if (!proxyIsExact) {
+ // If we got here then: proxy is not exact, the coords are limited to the
// constraint rect, and we're allowed to filter across the constraint rect boundary. So
- // we check whether the filter would reach across the edge of the content area.
+ // we check whether the filter would reach across the edge of the proxy.
// We will only set the sides that are required.
domainRect->setLargest();
@@ -168,24 +146,12 @@ GrTextureProducer::DomainMode GrTextureProducer::DetermineDomainMode(
// We may be able to use the fact that the texture coords are limited to the constraint
// rect in order to avoid having to add a domain.
bool needContentAreaConstraint = false;
- if (contentRect->fLeft > 0 &&
- contentRect->fLeft + filterHalfWidth > constraintRect.fLeft) {
- domainRect->fLeft = contentRect->fLeft + kDomainInset;
+ if (proxyBounds.fRight - filterHalfWidth < constraintRect.fRight) {
+ domainRect->fRight = proxyBounds.fRight - kDomainInset;
needContentAreaConstraint = true;
}
- if (contentRect->fTop > 0 &&
- contentRect->fTop + filterHalfWidth > constraintRect.fTop) {
- domainRect->fTop = contentRect->fTop + kDomainInset;
- needContentAreaConstraint = true;
- }
- if ((!proxyIsExact || contentRect->fRight < proxy->width()) &&
- contentRect->fRight - filterHalfWidth < constraintRect.fRight) {
- domainRect->fRight = contentRect->fRight - kDomainInset;
- needContentAreaConstraint = true;
- }
- if ((!proxyIsExact || contentRect->fBottom < proxy->height()) &&
- contentRect->fBottom - filterHalfWidth < constraintRect.fBottom) {
- domainRect->fBottom = contentRect->fBottom - kDomainInset;
+ if (proxyBounds.fBottom - filterHalfWidth < constraintRect.fBottom) {
+ domainRect->fBottom = proxyBounds.fBottom - kDomainInset;
needContentAreaConstraint = true;
}
if (!needContentAreaConstraint) {
@@ -194,18 +160,8 @@ GrTextureProducer::DomainMode GrTextureProducer::DetermineDomainMode(
} else {
// Our sample coords for the texture are allowed to be outside the constraintRect so we
// don't consider it when computing the domain.
- if (contentRect->fLeft > 0) {
- domainRect->fLeft = contentRect->fLeft + kDomainInset;
- }
- if (contentRect->fTop > 0) {
- domainRect->fTop = contentRect->fTop + kDomainInset;
- }
- if (!proxyIsExact || contentRect->fRight < proxy->width()) {
- domainRect->fRight = contentRect->fRight - kDomainInset;
- }
- if (!proxyIsExact || contentRect->fBottom < proxy->height()) {
- domainRect->fBottom = contentRect->fBottom - kDomainInset;
- }
+ domainRect->fRight = proxyBounds.fRight - kDomainInset;
+ domainRect->fBottom = proxyBounds.fBottom - kDomainInset;
}
} else {
return kNoDomain_DomainMode;
diff --git a/src/gpu/GrTextureProducer.h b/src/gpu/GrTextureProducer.h
index 432e7b35b3..88ba14afa8 100644
--- a/src/gpu/GrTextureProducer.h
+++ b/src/gpu/GrTextureProducer.h
@@ -124,14 +124,13 @@ protected:
};
static sk_sp<GrTextureProxy> CopyOnGpu(GrContext*, sk_sp<GrTextureProxy> inputProxy,
- const SkIRect* subset, const CopyParams& copyParams,
+ const CopyParams& copyParams,
bool dstWillRequireMipMaps);
static DomainMode DetermineDomainMode(const SkRect& constraintRect,
FilterConstraint filterConstraint,
bool coordsLimitedToConstraintRect,
GrTextureProxy*,
- const SkIRect* textureContentArea,
const GrSamplerState::Filter* filterModeOrNullForBicubic,
SkRect* domainRect);
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 760e6064bb..33837d391c 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1395,8 +1395,8 @@ void SkGpuDevice::drawImageNine(const SkImage* image,
uint32_t pinnedUniqueID;
if (sk_sp<GrTextureProxy> proxy = as_IB(image)->refPinnedTextureProxy(&pinnedUniqueID)) {
GrTextureAdjuster adjuster(this->context(), std::move(proxy),
- image->alphaType(), image->bounds(),
- pinnedUniqueID, as_IB(image)->onImageInfo().colorSpace());
+ image->alphaType(), pinnedUniqueID,
+ as_IB(image)->onImageInfo().colorSpace());
this->drawProducerNine(&adjuster, center, dst, paint);
} else {
SkBitmap bm;
@@ -1451,8 +1451,8 @@ void SkGpuDevice::drawImageLattice(const SkImage* image,
uint32_t pinnedUniqueID;
if (sk_sp<GrTextureProxy> proxy = as_IB(image)->refPinnedTextureProxy(&pinnedUniqueID)) {
GrTextureAdjuster adjuster(this->context(), std::move(proxy),
- image->alphaType(), image->bounds(),
- pinnedUniqueID, as_IB(image)->onImageInfo().colorSpace());
+ image->alphaType(), pinnedUniqueID,
+ as_IB(image)->onImageInfo().colorSpace());
this->drawProducerLattice(&adjuster, lattice, dst, paint);
} else {
SkBitmap bm;
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 9838f46ee2..c823ebd082 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -147,9 +147,8 @@ void SkGpuDevice::drawPinnedTextureProxy(sk_sp<GrTextureProxy> proxy, uint32_t p
this->clip(), fRenderTargetContext.get());
return;
}
- auto contentRect = SkIRect::MakeWH(proxy->width(), proxy->height());
- GrTextureAdjuster adjuster(this->context(), std::move(proxy), alphaType, contentRect,
- pinnedUniqueID, colorSpace);
+ GrTextureAdjuster adjuster(this->context(), std::move(proxy), alphaType, pinnedUniqueID,
+ colorSpace);
this->drawTextureProducer(&adjuster, srcRect, dstRect, constraint, viewMatrix, paint);
}
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 856b3b8108..d279188f44 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -125,8 +125,8 @@ sk_sp<GrTextureProxy> SkImage_Gpu::asTextureProxyRef(GrContext* context,
*texColorSpace = this->fColorSpace;
}
- GrTextureAdjuster adjuster(fContext, fProxy, this->alphaType(), this->bounds(),
- this->uniqueID(), this->fColorSpace.get());
+ GrTextureAdjuster adjuster(fContext, fProxy, this->alphaType(), this->uniqueID(),
+ this->fColorSpace.get());
return adjuster.refTextureProxySafeForParams(params, scaleAdjust);
}
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index db91621695..fc9e16743a 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -186,9 +186,8 @@ sk_sp<GrTextureProxy> SkImage_Raster::asTextureProxyRef(GrContext* context,
uint32_t uniqueID;
sk_sp<GrTextureProxy> tex = this->refPinnedTextureProxy(&uniqueID);
if (tex) {
- GrTextureAdjuster adjuster(context, fPinnedProxy,
- fBitmap.alphaType(), fBitmap.bounds(),
- fPinnedUniqueID, fBitmap.colorSpace());
+ GrTextureAdjuster adjuster(context, fPinnedProxy, fBitmap.alphaType(), fPinnedUniqueID,
+ fBitmap.colorSpace());
return adjuster.refTextureProxySafeForParams(params, scaleAdjust);
}
diff --git a/tests/DetermineDomainModeTest.cpp b/tests/DetermineDomainModeTest.cpp
index 111194f4ad..9c584d8a54 100644
--- a/tests/DetermineDomainModeTest.cpp
+++ b/tests/DetermineDomainModeTest.cpp
@@ -13,11 +13,10 @@
#include "GrTextureProducer.h"
#include "GrTextureProxy.h"
-// For DetermineDomainMode (in the MDB world) we have 4 rects:
+// For DetermineDomainMode (in the MDB world) we have 3 rects:
// 1) the final instantiated backing storage (i.e., the actual GrTexture's extent)
// 2) the proxy's extent, which may or may not match the GrTexture's extent
-// 3) the content rect, which can be a subset of the proxy's extent or null
-// 4) the constraint rect, which can optionally be hard or soft
+// 3) the constraint rect, which can optionally be hard or soft
// This test "fuzzes" all the combinations of these rects.
class GrTextureProducer_TestAccess {
public:
@@ -27,14 +26,12 @@ public:
GrTextureProducer::FilterConstraint filterConstraint,
bool coordsLimitedToConstraintRect,
GrTextureProxy* proxy,
- const SkIRect* textureContentArea,
const GrSamplerState::Filter* filterModeOrNullForBicubic,
SkRect* domainRect) {
return GrTextureProducer::DetermineDomainMode(constraintRect,
filterConstraint,
coordsLimitedToConstraintRect,
proxy,
- textureContentArea,
filterModeOrNullForBicubic,
domainRect);
}
@@ -42,22 +39,6 @@ public:
using DomainMode = GrTextureProducer_TestAccess::DomainMode;
-#ifdef SK_DEBUG
-static bool is_irect(const SkRect& r) {
- return SkScalarIsInt(r.fLeft) && SkScalarIsInt(r.fTop) &&
- SkScalarIsInt(r.fRight) && SkScalarIsInt(r.fBottom);
-}
-#endif
-
-static SkIRect to_irect(const SkRect& r) {
- SkASSERT(is_irect(r));
- return SkIRect::MakeLTRB(SkScalarRoundToInt(r.fLeft),
- SkScalarRoundToInt(r.fTop),
- SkScalarRoundToInt(r.fRight),
- SkScalarRoundToInt(r.fBottom));
-}
-
-
class RectInfo {
public:
enum Side { kLeft = 0, kTop = 1, kRight = 2, kBot = 3 };
@@ -315,20 +296,6 @@ static const SkRect* full_inset(const RectInfo& enclosing,
kInsetLeft_Flag|kInsetTop_Flag|kInsetRight_Flag|kInsetBot_Flag, name);
}
-// This is only used for content rect creation. We ensure 'result' is correct but
-// return null to indicate no content area (other than what the proxy specifies).
-static const SkRect* null_rect(const RectInfo& enclosing,
- RectInfo* result,
- bool isInsetHard,
- bool areCoordsLimitedToRect,
- float insetAmount,
- float halfFilterWidth) {
- static const char* name = "null";
- generic_inset(enclosing, result, isInsetHard, areCoordsLimitedToRect,
- insetAmount, halfFilterWidth, 0, name);
- return nullptr;
-}
-
// Make a rect with no inset. This is only used for constraint rect creation.
static const SkRect* no_inset(const RectInfo& enclosing,
RectInfo* result,
@@ -364,69 +331,44 @@ static void proxy_test(skiatest::Reporter* reporter, GrResourceProvider* resourc
isExact, &outermost);
SkASSERT(outermost.isHardOrBadAllAround());
- for (auto contentRectMaker : { left_only, top_only, right_only,
- bot_only, full_inset, null_rect}) {
- RectInfo contentRectStorage;
- const SkRect* contentRect = (*contentRectMaker)(outermost,
- &contentRectStorage,
- true, false, 5.0f, -1.0f);
- if (contentRect) {
- // We only have content rects if they actually reduce the extent of the content
- SkASSERT(!contentRect->contains(outermost.rect()));
- SkASSERT(outermost.rect().contains(*contentRect));
- SkASSERT(is_irect(*contentRect));
- }
- SkASSERT(contentRectStorage.isHardOrBadAllAround());
-
- for (auto isConstraintRectHard : { true, false }) {
- for (auto areCoordsLimitedToConstraintRect : { true, false }) {
- for (int filterMode = 0; filterMode < 4; ++filterMode) {
- for (auto constraintRectMaker : { left_only, top_only, right_only,
- bot_only, full_inset, no_inset }) {
- for (auto insetAmt : { 0.25f, 0.75f, 1.25f, 1.75f, 5.0f }) {
- RectInfo constraintRectStorage;
- const SkRect* constraintRect = (*constraintRectMaker)(
- contentRect ? contentRectStorage : outermost,
- &constraintRectStorage,
- isConstraintRectHard,
- areCoordsLimitedToConstraintRect,
- insetAmt,
- gHalfFilterWidth[filterMode]);
- SkASSERT(constraintRect); // always need one of these
- if (contentRect) {
- SkASSERT(contentRect->contains(*constraintRect));
+ for (auto isConstraintRectHard : { true, false }) {
+ for (auto areCoordsLimitedToConstraintRect : { true, false }) {
+ for (int filterMode = 0; filterMode < 4; ++filterMode) {
+ for (auto constraintRectMaker : { left_only, top_only, right_only,
+ bot_only, full_inset, no_inset }) {
+ for (auto insetAmt : { 0.25f, 0.75f, 1.25f, 1.75f, 5.0f }) {
+ RectInfo constraintRectStorage;
+ const SkRect* constraintRect = (*constraintRectMaker)(
+ outermost,
+ &constraintRectStorage,
+ isConstraintRectHard,
+ areCoordsLimitedToConstraintRect,
+ insetAmt,
+ gHalfFilterWidth[filterMode]);
+ SkASSERT(constraintRect); // always need one of these
+ SkASSERT(outermost.rect().contains(*constraintRect));
+
+ actualMode = GrTextureProducer_TestAccess::DetermineDomainMode(
+ *constraintRect,
+ isConstraintRectHard
+ ? GrTextureProducer::kYes_FilterConstraint
+ : GrTextureProducer::kNo_FilterConstraint,
+ areCoordsLimitedToConstraintRect,
+ proxy.get(),
+ gModePtrs[filterMode],
+ &actualDomainRect);
+
+ expectedMode = DomainMode::kNoDomain_DomainMode;
+ if (constraintRectStorage.hasABad()) {
+ if (3 == filterMode) {
+ expectedMode = DomainMode::kTightCopy_DomainMode;
} else {
- SkASSERT(outermost.rect().contains(*constraintRect));
- }
-
- SkIRect contentIRect;
- if (contentRect) {
- contentIRect = to_irect(*contentRect);
- }
-
- actualMode = GrTextureProducer_TestAccess::DetermineDomainMode(
- *constraintRect,
- isConstraintRectHard
- ? GrTextureProducer::kYes_FilterConstraint
- : GrTextureProducer::kNo_FilterConstraint,
- areCoordsLimitedToConstraintRect,
- proxy.get(),
- contentRect ? &contentIRect : nullptr,
- gModePtrs[filterMode],
- &actualDomainRect);
-
- expectedMode = DomainMode::kNoDomain_DomainMode;
- if (constraintRectStorage.hasABad()) {
- if (3 == filterMode) {
- expectedMode = DomainMode::kTightCopy_DomainMode;
- } else {
- expectedMode = DomainMode::kDomain_DomainMode;
- }
+ expectedMode = DomainMode::kDomain_DomainMode;
}
-
- REPORTER_ASSERT(reporter, expectedMode == actualMode);
- // TODO: add a check that the returned domain rect is correct
}
+
+ REPORTER_ASSERT(reporter, expectedMode == actualMode);
+ // TODO: add a check that the returned domain rect is correct
}
}
}