OLD | NEW |
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" | 9 #include "SkColorPriv.h" |
10 #include "SkColorShader.h" | 10 #include "SkColorShader.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode)); | 227 colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode)); |
228 surface->getCanvas()->drawPaint(p); | 228 surface->getCanvas()->drawPaint(p); |
229 | 229 |
230 // r == 0 for the center pixel. | 230 // r == 0 for the center pixel. |
231 // verify that we draw it (no red bleed) | 231 // verify that we draw it (no red bleed) |
232 SkPMColor centerPMColor; | 232 SkPMColor centerPMColor; |
233 surface->readPixels(SkImageInfo::MakeN32Premul(1, 1), ¢erPMColor, sizeof
(SkPMColor), 2, 2); | 233 surface->readPixels(SkImageInfo::MakeN32Premul(1, 1), ¢erPMColor, sizeof
(SkPMColor), 2, 2); |
234 REPORTER_ASSERT(reporter, SkGetPackedR32(centerPMColor) == 0); | 234 REPORTER_ASSERT(reporter, SkGetPackedR32(centerPMColor) == 0); |
235 } | 235 } |
236 | 236 |
| 237 // http://crbug.com/599458 |
| 238 static void test_clamping_overflow(skiatest::Reporter*) { |
| 239 SkPaint p; |
| 240 const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN }; |
| 241 const SkPoint pts1[] = { SkPoint::Make(1001, 1000001), SkPoint::Make(1000.99
f, 1000000) }; |
| 242 |
| 243 p.setShader(SkGradientShader::MakeLinear(pts1, colors, nullptr, 2, SkShader:
:kClamp_TileMode)); |
| 244 |
| 245 sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(50, 50)); |
| 246 surface->getCanvas()->scale(100, 100); |
| 247 surface->getCanvas()->drawPaint(p); |
| 248 |
| 249 const SkPoint pts2[] = { SkPoint::Make(10000.99f, 1000000), SkPoint::Make(10
001, 1000001) }; |
| 250 p.setShader(SkGradientShader::MakeLinear(pts2, colors, nullptr, 2, SkShader:
:kClamp_TileMode)); |
| 251 surface->getCanvas()->drawPaint(p); |
| 252 |
| 253 // Passes if we don't trigger asserts. |
| 254 } |
| 255 |
237 DEF_TEST(Gradient, reporter) { | 256 DEF_TEST(Gradient, reporter) { |
238 TestGradientShaders(reporter); | 257 TestGradientShaders(reporter); |
239 TestConstantGradient(reporter); | 258 TestConstantGradient(reporter); |
240 test_big_grad(reporter); | 259 test_big_grad(reporter); |
241 test_nearly_vertical(reporter); | 260 test_nearly_vertical(reporter); |
242 test_linear_fuzz(reporter); | 261 test_linear_fuzz(reporter); |
243 test_two_point_conical_zero_radius(reporter); | 262 test_two_point_conical_zero_radius(reporter); |
| 263 test_clamping_overflow(reporter); |
244 } | 264 } |
OLD | NEW |