Fixes matrix inconsistency in GPU draws with filters. Also adds a GM test.

May make GM go red on bots, will rebaseline.

Committed on behalf of Guanqun.Lu@gmail.com

Review URL: http://codereview.appspot.com/6049046/



git-svn-id: http://skia.googlecode.com/svn/trunk@3764 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/drawbitmaprect.cpp b/gm/drawbitmaprect.cpp
index 5832a9c..64e4cf3 100644
--- a/gm/drawbitmaprect.cpp
+++ b/gm/drawbitmaprect.cpp
@@ -8,6 +8,7 @@
 #include "gm.h"
 #include "SkShader.h"
 #include "SkColorPriv.h"
+#include "SkBlurMaskFilter.h"
 
 // effects
 #include "SkGradientShader.h"
@@ -15,6 +16,21 @@
 
 namespace skiagm {
 
+static SkBitmap make_chessbm(int w, int h) {
+    SkBitmap bm;
+    bm.setConfig(SkBitmap::kARGB_8888_Config , w, h);
+    bm.allocPixels();
+
+    for (int y = 0; y < bm.height(); y++) {
+        uint32_t* p = bm.getAddr32(0, y);
+        for (int x = 0; x < bm.width(); x++) {
+            p[x] = ((x + y) & 1) ? SK_ColorWHITE : SK_ColorBLACK;
+        }
+    }
+    bm.unlockPixels();
+    return bm;
+}
+
 static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) {
     bm->setConfig(config, w, h);
     bm->allocPixels();
@@ -140,6 +156,26 @@
                 }
             }
         }
+
+        {
+            // test the following code path:
+            // SkGpuDevice::drawPath() -> SkGpuDevice::drawWithMaskFilter()
+            SkIRect srcRect;
+            SkPaint paint;
+            SkBitmap bm;
+
+            bm = make_chessbm(5, 5);
+            paint.setFilterBitmap(true);
+
+            srcRect.setXYWH(1, 1, 3, 3);
+            SkMaskFilter* mf = SkBlurMaskFilter::Create(
+                5,
+                SkBlurMaskFilter::kNormal_BlurStyle,
+                SkBlurMaskFilter::kHighQuality_BlurFlag |
+                SkBlurMaskFilter::kIgnoreTransform_BlurFlag);
+            paint.setMaskFilter(mf)->unref();
+            canvas->drawBitmapRect(bm, &srcRect, dstRect, &paint);
+        }
     }
 
 private: