aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/DetermineDomainModeTest.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-09-07 11:41:25 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-07 16:02:51 +0000
commit6e4bbbefe153495cf34ea42aa72691756e6ab40e (patch)
tree477ceefbff993e8fda299ce1f32e51b938082f77 /tests/DetermineDomainModeTest.cpp
parent7c627b49ed502e3ebb543d06c4176e630c7ddfc9 (diff)
Remove "content" rect from GrTextureAdjuster.
Since we got rid of texture-backed bitmaps this is no longer required. Change-Id: Id15c745994a3d6a1489e193b5d29916fa0931264 Reviewed-on: https://skia-review.googlesource.com/36340 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/DetermineDomainModeTest.cpp')
-rw-r--r--tests/DetermineDomainModeTest.cpp137
1 files changed, 42 insertions, 95 deletions
diff --git a/tests/DetermineDomainModeTest.cpp b/tests/DetermineDomainModeTest.cpp
index ee9a694f19..ef1a5ad09f 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:
@@ -28,14 +27,12 @@ public:
GrTextureProducer::FilterConstraint filterConstraint,
bool coordsLimitedToConstraintRect,
GrTextureProxy* proxy,
- const SkIRect* textureContentArea,
const GrSamplerParams::FilterMode* filterModeOrNullForBicubic,
SkRect* domainRect) {
return GrTextureProducer::DetermineDomainMode(constraintRect,
filterConstraint,
coordsLimitedToConstraintRect,
proxy,
- textureContentArea,
filterModeOrNullForBicubic,
domainRect);
}
@@ -43,22 +40,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 };
@@ -316,20 +297,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,
@@ -365,70 +332,50 @@ static void proxy_test(skiatest::Reporter* reporter, GrResourceProvider* resourc
sk_sp<GrTextureProxy> proxy = create_proxy(resourceProvider, isPowerOfTwoSized,
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));
+ for (auto isConstraintRectHard : { true, false }) {
+ if (!isConstraintRectHard && !isExact) {
+ // GrTextureProducer expects that texture inexactness is expressed as a
+ // constraint rect and asserts if not. This skips a case that never happens
+ // through the public API.
+ continue;
}
- 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 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
}
}
}