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

Unified Diff: tests/GradientTest.cpp

Issue 1756573002: [Reland] Fix SkTwoPointConicalGradient zero-radius handling (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: avoid all-zero radius instantiation Created 4 years, 10 months 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/SkTwoPointConicalGradient.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 6a277d520efa64d51b654d853cf0297bff95ac31..cc94cbaf7591d3e7ecbca31cfc3422754854d55b 100644
--- a/tests/GradientTest.cpp
+++ b/tests/GradientTest.cpp
@@ -6,6 +6,7 @@
*/
#include "SkCanvas.h"
+#include "SkColorPriv.h"
#include "SkColorShader.h"
#include "SkGradientShader.h"
#include "SkShader.h"
@@ -233,10 +234,33 @@ static void test_linear_fuzz(skiatest::Reporter* reporter) {
surface->getCanvas()->drawRect(r, paint);
}
+// https://bugs.chromium.org/p/skia/issues/detail?id=5023
+// We should still shade pixels for which the radius is exactly 0.
+static void test_two_point_conical_zero_radius(skiatest::Reporter* reporter) {
+ SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(5, 5));
+ surface->getCanvas()->clear(SK_ColorRED);
+
+ const SkColor colors[] = { SK_ColorGREEN, SK_ColorBLUE };
+ SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(
+ SkPoint::Make(2.5f, 2.5f), 0,
+ SkPoint::Make(3.0f, 3.0f), 10,
+ colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode));
+ SkPaint p;
+ p.setShader(shader);
+ surface->getCanvas()->drawPaint(p);
+
+ // r == 0 for the center pixel.
+ // verify that we draw it (no red bleed)
+ SkPMColor centerPMColor;
+ surface->readPixels(SkImageInfo::MakeN32Premul(1, 1), &centerPMColor, sizeof(SkPMColor), 2, 2);
+ REPORTER_ASSERT(reporter, SkGetPackedR32(centerPMColor) == 0);
+}
+
DEF_TEST(Gradient, reporter) {
TestGradientShaders(reporter);
TestConstantGradient(reporter);
test_big_grad(reporter);
test_nearly_vertical(reporter);
test_linear_fuzz(reporter);
+ test_two_point_conical_zero_radius(reporter);
}
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698