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

Side by Side Diff: tests/GradientTest.cpp

Issue 1754113003: Revert of Fix SkTwoPointConicalGradient zero-radius handling (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkColorPriv.h"
10 #include "SkColorShader.h" 9 #include "SkColorShader.h"
11 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
12 #include "SkShader.h" 11 #include "SkShader.h"
13 #include "SkSurface.h" 12 #include "SkSurface.h"
14 #include "SkTemplates.h" 13 #include "SkTemplates.h"
15 #include "Test.h" 14 #include "Test.h"
16 15
17 // https://code.google.com/p/chromium/issues/detail?id=448299 16 // https://code.google.com/p/chromium/issues/detail?id=448299
18 // Giant (inverse) matrix causes overflow when converting/computing using 32.32 17 // Giant (inverse) matrix causes overflow when converting/computing using 32.32
19 // Before the fix, we would assert (and then crash). 18 // Before the fix, we would assert (and then crash).
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 226
228 SkAutoTUnref<SkShader> gradient( 227 SkAutoTUnref<SkShader> gradient(
229 SkGradientShader::CreateLinear(pts, colors, pos, 4, SkShader: :kClamp_TileMode)); 228 SkGradientShader::CreateLinear(pts, colors, pos, 4, SkShader: :kClamp_TileMode));
230 229
231 SkPaint paint; 230 SkPaint paint;
232 paint.setShader(gradient); 231 paint.setShader(gradient);
233 SkRect r = {0, 83, 1254, 620}; 232 SkRect r = {0, 83, 1254, 620};
234 surface->getCanvas()->drawRect(r, paint); 233 surface->getCanvas()->drawRect(r, paint);
235 } 234 }
236 235
237 // https://bugs.chromium.org/p/skia/issues/detail?id=5023
238 // We should still shade pixels for which the radius is exactly 0.
239 static void test_two_point_conical_zero_radius(skiatest::Reporter* reporter) {
240 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(5, 5));
241 surface->getCanvas()->clear(SK_ColorRED);
242
243 const SkColor colors[] = { SK_ColorGREEN, SK_ColorBLUE };
244 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(
245 SkPoint::Make(2.5f, 2.5f), 0,
246 SkPoint::Make(3.0f, 3.0f), 10,
247 colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode));
248 SkPaint p;
249 p.setShader(shader);
250 surface->getCanvas()->drawPaint(p);
251
252 // r == 0 for the center pixel.
253 // verify that we draw it (no red bleed)
254 SkPMColor centerPMColor;
255 surface->readPixels(SkImageInfo::MakeN32Premul(1, 1), &centerPMColor, sizeof (SkPMColor), 2, 2);
256 REPORTER_ASSERT(reporter, SkGetPackedR32(centerPMColor) == 0);
257 }
258
259 DEF_TEST(Gradient, reporter) { 236 DEF_TEST(Gradient, reporter) {
260 TestGradientShaders(reporter); 237 TestGradientShaders(reporter);
261 TestConstantGradient(reporter); 238 TestConstantGradient(reporter);
262 test_big_grad(reporter); 239 test_big_grad(reporter);
263 test_nearly_vertical(reporter); 240 test_nearly_vertical(reporter);
264 test_linear_fuzz(reporter); 241 test_linear_fuzz(reporter);
265 test_two_point_conical_zero_radius(reporter);
266 } 242 }
OLDNEW
« 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