more tests for offsetimagefilter
authorreed <reed@google.com>
Tue, 23 Jun 2015 15:29:20 +0000 (08:29 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 23 Jun 2015 15:29:20 +0000 (08:29 -0700)
BUG=skia:

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

gm/offsetimagefilter.cpp
include/core/SkImageFilter.h

index 6519f0a45a95924c20105ed96592574f39e64ad6..6645a98b611fd0d6db48bc2397cfc5b8c30065a0 100644 (file)
@@ -127,17 +127,26 @@ protected:
             p.setStyle(SkPaint::kFill_Style);
         }
 
-        p.setImageFilter(imgf);
-        p.setColor(SK_ColorRED);
+        if (imgf && imgf->cropRectIsSet()) {
+            SkImageFilter::CropRect cr = imgf->getCropRect();
+
+            p.setColor(0x66FF00FF);
+            p.setStyle(SkPaint::kStroke_Style);
+            canvas->drawRect(cr.rect().makeInset(SK_ScalarHalf, SK_ScalarHalf), p);
+            p.setStyle(SkPaint::kFill_Style);
+        }
+
+        p.setColor(0x660000FF);
         canvas->drawRect(r, p);
 
         if (clipR) {
             canvas->save();
             canvas->clipRect(*clipR);
         }
-        p.setImageFilter(NULL);
-        p.setColor(0x660000FF);
+        p.setImageFilter(imgf);
+        p.setColor(0x66FF0000);
         canvas->drawRect(r, p);
+
         if (clipR) {
             canvas->restore();
         }
@@ -147,6 +156,8 @@ protected:
         const SkRect r = SkRect::MakeWH(10, 10);
         SkImageFilter::CropRect cr0(r);
         SkImageFilter::CropRect cr1(SkRect::MakeWH(5, 5));
+        const SkRect r2 = SkRect::MakeXYWH(10, 0, 10, 10);
+        SkImageFilter::CropRect cr2(r2);
 
         canvas->translate(20, 20);
         this->doDraw(canvas, r, NULL);
@@ -162,6 +173,13 @@ protected:
         
         canvas->translate(20, 0);
         this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5, NULL, &cr1));
+        
+        SkRect clipR = SkRect::MakeXYWH(10, 10, 10, 10);
+        canvas->translate(20, 0);
+        this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5, NULL, NULL), &clipR);
+        
+        canvas->translate(20, 0);
+        this->doDraw(canvas, r, SkOffsetImageFilter::Create(10, 0, NULL, &cr2), NULL);
     }
 
 private:
index e0e97b0ad2b91ec1528a9e84fb209b38d6d55188..911b3f648d5d6ae2e4c8cfd51dae55efcdffa40e 100644 (file)
@@ -192,6 +192,8 @@ public:
      */
     bool cropRectIsSet() const { return fCropRect.flags() != 0x0; }
 
+    CropRect getCropRect() const { return fCropRect; }
+
     // Default impl returns union of all input bounds.
     virtual void computeFastBounds(const SkRect&, SkRect*) const;