Fixed a displacement issue

The displacement filter was assuming that both inputs were of the same size, which is true in blink, but not necessarily in a compromised stream.

BUG=327372
R=senorblanco@chromium.org, senorblanco@google.com, reed@google.com, fmalita@chromium.org, fmalita@google.com, sugoi@google.com

Author: sugoi@chromium.org

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

git-svn-id: http://skia.googlecode.com/svn/trunk/src@12655 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/effects/SkDisplacementMapEffect.cpp b/effects/SkDisplacementMapEffect.cpp
index 6e5c910..f43287c 100644
--- a/effects/SkDisplacementMapEffect.cpp
+++ b/effects/SkDisplacementMapEffect.cpp
@@ -205,6 +205,14 @@
     if (!this->applyCropRect(&bounds, ctm)) {
         return false;
     }
+    SkIRect displBounds;
+    displ.getBounds(&displBounds);
+    if (!this->applyCropRect(&displBounds, ctm)) {
+        return false;
+    }
+    if (!bounds.intersect(displBounds)) {
+        return false;
+    }
 
     dst->setConfig(color.config(), bounds.width(), bounds.height());
     dst->allocPixels();
@@ -338,6 +346,14 @@
     if (!this->applyCropRect(&bounds, ctm)) {
         return false;
     }
+    SkIRect displBounds;
+    displacementBM.getBounds(&displBounds);
+    if (!this->applyCropRect(&displBounds, ctm)) {
+        return false;
+    }
+    if (!bounds.intersect(displBounds)) {
+        return false;
+    }
     SkRect srcRect = SkRect::Make(bounds);
     SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
     context->drawRectToRect(paint, dstRect, srcRect);