Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Unified Diff: tests/GradientTest.cpp

Issue 1456783005: Fix nearly-vertical gradient assert (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/gradients/SkLinearGradient.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/GradientTest.cpp
diff --git a/tests/GradientTest.cpp b/tests/GradientTest.cpp
index d0ea1f2b4d4fc7f0e5450e053db4a051762498b1..8d73569f649d53ff04be9837f400f38579c08ff1 100644
--- a/tests/GradientTest.cpp
+++ b/tests/GradientTest.cpp
@@ -9,6 +9,7 @@
#include "SkColorShader.h"
#include "SkGradientShader.h"
#include "SkShader.h"
+#include "SkSurface.h"
#include "SkTemplates.h"
#include "Test.h"
@@ -196,8 +197,24 @@ static void TestGradientShaders(skiatest::Reporter* reporter) {
}
}
+static void test_nearly_vertical(skiatest::Reporter* reporter) {
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(200, 200));
+
+ const SkPoint pts[] = {{ 100, 50 }, { 100.0001f, 50000 }};
+ const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
+ const SkScalar pos[] = { 0, 1 };
+ SkAutoTUnref<SkShader> gradient(
+ SkGradientShader::CreateLinear(pts, colors, pos, 2, SkShader::kClamp_TileMode));
+
+ SkPaint paint;
+ paint.setShader(gradient);
+
+ surface->getCanvas()->drawPaint(paint);
+}
+
DEF_TEST(Gradient, reporter) {
TestGradientShaders(reporter);
TestConstantGradient(reporter);
test_big_grad(reporter);
+ test_nearly_vertical(reporter);
}
« no previous file with comments | « src/effects/gradients/SkLinearGradient.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698