Check all scratch texture allocations for image filters.

[Cherry-picked from 673d9732bf37df724500e04afcdf27d5c711ef60 to
chrome/m38_2125.]

BUG=403677
TBR=bungeman@google.com

Review URL: https://codereview.chromium.org/474443003
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index cf1f076..4a9a22e 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -256,6 +256,9 @@
     desc.fConfig = kRGBA_8888_GrPixelConfig;
 
     GrAutoScratchTexture dst(context, desc);
+    if (NULL == dst.texture()) {
+        return false;
+    }
     GrContext::AutoMatrix am;
     am.setIdentity(context);
     GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget());
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 26aaa02..bae7ac0 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -389,6 +389,9 @@
     desc.fConfig = kSkia8888_GrPixelConfig;
 
     GrAutoScratchTexture ast(context, desc);
+    if (NULL == ast.texture()) {
+        return false;
+    }
     SkAutoTUnref<GrTexture> dst(ast.detach());
 
     GrContext::AutoRenderTarget art(context, dst->asRenderTarget());
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 49df654..67769f2 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -506,6 +506,9 @@
 
     if (radius.fWidth > 0) {
         GrAutoScratchTexture ast(context, desc);
+        if (NULL == ast.texture()) {
+            return false;
+        }
         GrContext::AutoRenderTarget art(context, ast.texture()->asRenderTarget());
         apply_morphology_pass(context, src, srcRect, dstRect, radius.fWidth,
                               morphType, Gr1DKernelEffect::kX_Direction);
@@ -519,6 +522,9 @@
     }
     if (radius.fHeight > 0) {
         GrAutoScratchTexture ast(context, desc);
+        if (NULL == ast.texture()) {
+            return false;
+        }
         GrContext::AutoRenderTarget art(context, ast.texture()->asRenderTarget());
         apply_morphology_pass(context, src, srcRect, dstRect, radius.fHeight,
                               morphType, Gr1DKernelEffect::kY_Direction);
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index cf32cf5..c876d5f 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -132,6 +132,9 @@
     desc.fConfig = kSkia8888_GrPixelConfig;
 
     GrAutoScratchTexture ast(context, desc);
+    if (NULL == ast.texture()) {
+        return false;
+    }
     SkAutoTUnref<GrTexture> dst(ast.detach());
 
     GrContext::AutoRenderTarget art(context, dst->asRenderTarget());