Fix single leg Compose Shader crash.
R=halcanary@google.com
BUG=skia:6291
Change-Id: Ifa63dce2b06662e7b535a4f04e1f3f772c099122
Reviewed-on: https://skia-review.googlesource.com/9027
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
diff --git a/tests/ShaderTest.cpp b/tests/ShaderTest.cpp
index e3d87a2..06aca1c 100644
--- a/tests/ShaderTest.cpp
+++ b/tests/ShaderTest.cpp
@@ -7,7 +7,10 @@
#include "Test.h"
#include "SkBitmap.h"
+#include "SkCanvas.h"
#include "SkImage.h"
+#include "SkPerlinNoiseShader.h"
+#include "SkRRect.h"
#include "SkShader.h"
#include "SkSurface.h"
#include "SkData.h"
@@ -58,3 +61,21 @@
check_isabitmap(reporter, shader0.get(), W, H, tmx, tmy, localM);
check_isabitmap(reporter, shader1.get(), W, H, tmx, tmy, localM);
}
+
+// Make sure things are ok with just a single leg.
+DEF_TEST(ComposeShaderSingle, reporter) {
+ SkBitmap srcBitmap;
+ srcBitmap.allocN32Pixels(10, 10);
+ srcBitmap.eraseColor(SK_ColorRED);
+ SkCanvas canvas(srcBitmap);
+ SkPaint p;
+ p.setShader(
+ SkShader::MakeComposeShader(
+ SkShader::MakeEmptyShader(),
+ SkPerlinNoiseShader::MakeFractalNoise(1.0f, 1.0f, 2, 0.0f),
+ SkBlendMode::kClear));
+ SkRRect rr;
+ SkVector rd[] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}};
+ rr.setRectRadii({0, 0, 0, 0}, rd);
+ canvas.drawRRect(rr, p);
+}