Revert "Remove "content" rect from GrTextureAdjuster."

This reverts commit 6e4bbbefe153495cf34ea42aa72691756e6ab40e.

Reason for revert: assertion failure

Original change's description:
> 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>

TBR=bsalomon@google.com,robertphillips@google.com

Change-Id: I2229ec05079368ff196ff351107f88062080e5ec
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/43720
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/tests/DetermineDomainModeTest.cpp b/tests/DetermineDomainModeTest.cpp
index ef1a5ad..ee9a694 100644
--- a/tests/DetermineDomainModeTest.cpp
+++ b/tests/DetermineDomainModeTest.cpp
@@ -13,10 +13,11 @@
 #include "GrTextureProducer.h"
 #include "GrTextureProxy.h"
 
-// For DetermineDomainMode (in the MDB world) we have 3 rects:
+// For DetermineDomainMode (in the MDB world) we have 4 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 constraint rect, which can optionally be hard or soft
+//      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
 // This test "fuzzes" all the combinations of these rects.
 class GrTextureProducer_TestAccess {
 public:
@@ -27,12 +28,14 @@
                                 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);
     }
@@ -40,6 +43,22 @@
 
 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 };
@@ -297,6 +316,20 @@
                          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,
@@ -332,50 +365,70 @@
             sk_sp<GrTextureProxy> proxy = create_proxy(resourceProvider, isPowerOfTwoSized,
                                                        isExact, &outermost);
             SkASSERT(outermost.isHardOrBadAllAround());
-            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;
+
+            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 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));
+                SkASSERT(contentRectStorage.isHardOrBadAllAround());
 
-                                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;
+                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));
                                     } else {
-                                        expectedMode = DomainMode::kDomain_DomainMode;
+                                        SkASSERT(outermost.rect().contains(*constraintRect));
                                     }
-                                }
 
-                                REPORTER_ASSERT(reporter, expectedMode == actualMode);
-                                // TODO: add a check that the returned domain rect is correct
+                                    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;
+                                        }
+                                    }
+
+                                    REPORTER_ASSERT(reporter, expectedMode == actualMode);
+                                    // TODO: add a check that the returned domain rect is correct
+                                }
                             }
                         }
                     }