Use GrTextureDomain in GrBicubicEffect to perform non-bleeding HQ filter drawBitmap.

R=senorblanco@chromium.org, robertphillips@google.com

Author: bsalomon@google.com

Review URL: https://codereview.chromium.org/99203011

git-svn-id: http://skia.googlecode.com/svn/trunk@12687 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index c8d2896..a0692d0 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1208,8 +1208,7 @@
             break;
         case SkPaint::kHigh_FilterLevel: {
             // Minification can look bad with the bicubic effect.
-            if (fContext->getMatrix().getMinStretch() >= SK_Scalar1 &&
-                (flags & SkCanvas::kBleed_DrawBitmapRectFlag)) {
+            if (fContext->getMatrix().getMinStretch() >= SK_Scalar1) {
                 // We will install an effect that does the filtering in the shader.
                 textureFilterMode = GrTextureParams::kNone_FilterMode;
                 tileFilterPad = GrBicubicEffect::kFilterTexelPad;
@@ -1292,8 +1291,6 @@
                     // but stay within the bitmap bounds
                     iClampRect = SkIRect::MakeWH(bitmap.width(), bitmap.height());
                 } else {
-                    SkASSERT(!bicubic); // Bicubic is not supported with non-bleed yet.
-
                     // In texture-domain/clamp mode we only want to expand the
                     // tile on edges interior to "srcRect" (i.e., we want to
                     // not bleed across the original clamped edges)
@@ -1391,12 +1388,11 @@
 
     bool needsTextureDomain = false;
     if (!(flags & SkCanvas::kBleed_DrawBitmapRectFlag) &&
-        params.filterMode() != GrTextureParams::kNone_FilterMode) {
-        SkASSERT(!bicubic);
-        // Need texture domain if drawing a sub rect.
+        (bicubic || params.filterMode() != GrTextureParams::kNone_FilterMode)) {
+        // Need texture domain if drawing a sub rect
         needsTextureDomain = srcRect.width() < bitmap.width() ||
                              srcRect.height() < bitmap.height();
-        if (needsTextureDomain && fContext->getMatrix().rectStaysRect()) {
+        if (!bicubic && needsTextureDomain && fContext->getMatrix().rectStaysRect()) {
             const SkMatrix& matrix = fContext->getMatrix();
             // sampling is axis-aligned
             SkRect transformedRect;
@@ -1432,11 +1428,15 @@
             top = bottom = SkScalarHalf(paintRect.top() + paintRect.bottom());
         }
         textureDomain.setLTRB(left, top, right, bottom);
-        effect.reset(GrTextureDomainEffect::Create(texture,
-                                                   SkMatrix::I(),
-                                                   textureDomain,
-                                                   GrTextureDomain::kClamp_Mode,
-                                                   params.filterMode()));
+        if (bicubic) {
+            effect.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), textureDomain));
+        } else {
+            effect.reset(GrTextureDomainEffect::Create(texture,
+                                                       SkMatrix::I(),
+                                                       textureDomain,
+                                                       GrTextureDomain::kClamp_Mode,
+                                                       params.filterMode()));
+        }
     } else if (bicubic) {
         SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode());
         SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTileModeY() };