reed@google.com | dceecc7 | 2012-02-23 19:20:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
reed@google.com | dceecc7 | 2012-02-23 19:20:19 +0000 | [diff] [blame] | 8 | #include "SkBitmap.h" |
| 9 | #include "SkCanvas.h" |
reed@google.com | 1df888b | 2012-04-24 22:47:21 +0000 | [diff] [blame] | 10 | #include "SkDashPathEffect.h" |
halcanary | 435657f | 2015-09-15 12:53:07 -0700 | [diff] [blame] | 11 | #include "SkStrokeRec.h" |
reed@google.com | f272e35 | 2013-08-26 21:27:03 +0000 | [diff] [blame] | 12 | #include "SkSurface.h" |
tfarina@chromium.org | 8f6884a | 2014-01-24 20:56:26 +0000 | [diff] [blame] | 13 | #include "Test.h" |
reed@google.com | dceecc7 | 2012-02-23 19:20:19 +0000 | [diff] [blame] | 14 | |
reed@google.com | f272e35 | 2013-08-26 21:27:03 +0000 | [diff] [blame] | 15 | // test that we can draw an aa-rect at coordinates > 32K (bigger than fixedpoint) |
| 16 | static void test_big_aa_rect(skiatest::Reporter* reporter) { |
| 17 | SkBitmap output; |
| 18 | SkPMColor pixel[1]; |
commit-bot@chromium.org | 00f8d6c | 2014-05-29 15:57:20 +0000 | [diff] [blame] | 19 | output.installPixels(SkImageInfo::MakeN32Premul(1, 1), pixel, 4); |
reed@google.com | f272e35 | 2013-08-26 21:27:03 +0000 | [diff] [blame] | 20 | |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 21 | SkSurface* surf = SkSurface::NewRasterN32Premul(300, 33300); |
reed@google.com | f272e35 | 2013-08-26 21:27:03 +0000 | [diff] [blame] | 22 | SkCanvas* canvas = surf->getCanvas(); |
| 23 | |
| 24 | SkRect r = { 0, 33000, 300, 33300 }; |
| 25 | int x = SkScalarRoundToInt(r.left()); |
| 26 | int y = SkScalarRoundToInt(r.top()); |
| 27 | |
| 28 | // check that the pixel in question starts as transparent (by the surface) |
| 29 | if (canvas->readPixels(&output, x, y)) { |
| 30 | REPORTER_ASSERT(reporter, 0 == pixel[0]); |
| 31 | } else { |
mtklein@google.com | 9f842d3 | 2013-08-27 16:15:37 +0000 | [diff] [blame] | 32 | REPORTER_ASSERT_MESSAGE(reporter, false, "readPixels failed"); |
reed@google.com | f272e35 | 2013-08-26 21:27:03 +0000 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | SkPaint paint; |
| 36 | paint.setAntiAlias(true); |
| 37 | paint.setColor(SK_ColorWHITE); |
| 38 | |
| 39 | canvas->drawRect(r, paint); |
| 40 | |
| 41 | // Now check that it is BLACK |
| 42 | if (canvas->readPixels(&output, x, y)) { |
| 43 | // don't know what swizzling PMColor did, but white should always |
| 44 | // appear the same. |
| 45 | REPORTER_ASSERT(reporter, 0xFFFFFFFF == pixel[0]); |
| 46 | } else { |
mtklein@google.com | 9f842d3 | 2013-08-27 16:15:37 +0000 | [diff] [blame] | 47 | REPORTER_ASSERT_MESSAGE(reporter, false, "readPixels failed"); |
reed@google.com | f272e35 | 2013-08-26 21:27:03 +0000 | [diff] [blame] | 48 | } |
| 49 | surf->unref(); |
| 50 | } |
| 51 | |
| 52 | /////////////////////////////////////////////////////////////////////////////// |
| 53 | |
reed@google.com | b59ed51 | 2012-06-15 18:26:04 +0000 | [diff] [blame] | 54 | static void moveToH(SkPath* path, const uint32_t raw[]) { |
| 55 | const float* fptr = (const float*)raw; |
| 56 | path->moveTo(fptr[0], fptr[1]); |
| 57 | } |
| 58 | |
| 59 | static void cubicToH(SkPath* path, const uint32_t raw[]) { |
| 60 | const float* fptr = (const float*)raw; |
| 61 | path->cubicTo(fptr[0], fptr[1], fptr[2], fptr[3], fptr[4], fptr[5]); |
| 62 | } |
| 63 | |
| 64 | // This used to assert, because we performed a cast (int)(pt[0].fX * scale) to |
| 65 | // arrive at an int (SkFDot6) rather than calling sk_float_round2int. The assert |
| 66 | // was that the initial line-segment produced by the cubic was not monotonically |
| 67 | // going down (i.e. the initial DY was negative). By rounding the floats, we get |
| 68 | // the more proper result. |
| 69 | // |
| 70 | // http://code.google.com/p/chromium/issues/detail?id=131181 |
| 71 | // |
humper@google.com | 05af1af | 2013-01-07 16:47:43 +0000 | [diff] [blame] | 72 | |
| 73 | // we're not calling this test anymore; is that for a reason? |
| 74 | |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 75 | static void test_crbug131181() { |
reed@google.com | b59ed51 | 2012-06-15 18:26:04 +0000 | [diff] [blame] | 76 | /* |
| 77 | fX = 18.8943768, |
| 78 | fY = 129.121277 |
| 79 | }, { |
| 80 | fX = 18.8937435, |
| 81 | fY = 129.121689 |
| 82 | }, { |
| 83 | fX = 18.8950119, |
| 84 | fY = 129.120422 |
| 85 | }, { |
| 86 | fX = 18.5030727, |
| 87 | fY = 129.13121 |
| 88 | */ |
| 89 | uint32_t data[] = { |
| 90 | 0x419727af, 0x43011f0c, 0x41972663, 0x43011f27, |
| 91 | 0x419728fc, 0x43011ed4, 0x4194064b, 0x43012197 |
| 92 | }; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 93 | |
reed@google.com | b59ed51 | 2012-06-15 18:26:04 +0000 | [diff] [blame] | 94 | SkPath path; |
| 95 | moveToH(&path, &data[0]); |
| 96 | cubicToH(&path, &data[2]); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 97 | |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 98 | SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480)); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 99 | |
reed@google.com | b59ed51 | 2012-06-15 18:26:04 +0000 | [diff] [blame] | 100 | SkPaint paint; |
| 101 | paint.setAntiAlias(true); |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 102 | surface->getCanvas()->drawPath(path, paint); |
reed@google.com | b59ed51 | 2012-06-15 18:26:04 +0000 | [diff] [blame] | 103 | } |
| 104 | |
reed@google.com | e2faf17 | 2012-08-06 19:01:34 +0000 | [diff] [blame] | 105 | // This used to assert in debug builds (and crash writing bad memory in release) |
| 106 | // because we overflowed an intermediate value (B coefficient) setting up our |
| 107 | // stepper for the quadratic. Now we bias that value by 1/2 so we don't overflow |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 108 | static void test_crbug_140803() { |
reed@google.com | e2faf17 | 2012-08-06 19:01:34 +0000 | [diff] [blame] | 109 | SkBitmap bm; |
commit-bot@chromium.org | fa9e5fa | 2014-02-13 22:00:04 +0000 | [diff] [blame] | 110 | bm.allocN32Pixels(2700, 30*1024); |
reed@google.com | e2faf17 | 2012-08-06 19:01:34 +0000 | [diff] [blame] | 111 | SkCanvas canvas(bm); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 112 | |
reed@google.com | e2faf17 | 2012-08-06 19:01:34 +0000 | [diff] [blame] | 113 | SkPath path; |
| 114 | path.moveTo(2762, 20); |
| 115 | path.quadTo(11, 21702, 10, 21706); |
| 116 | SkPaint paint; |
| 117 | paint.setAntiAlias(true); |
| 118 | canvas.drawPath(path, paint); |
| 119 | } |
| 120 | |
reed@google.com | 9d5f76a | 2012-05-01 14:49:28 +0000 | [diff] [blame] | 121 | // Need to exercise drawing an inverse-path whose bounds intersect the clip, |
| 122 | // but whose edges do not (since its a quad which draws only in the bottom half |
| 123 | // of its bounds). |
| 124 | // In the debug build, we used to assert in this case, until it was fixed. |
| 125 | // |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 126 | static void test_inversepathwithclip() { |
reed@google.com | 9d5f76a | 2012-05-01 14:49:28 +0000 | [diff] [blame] | 127 | SkPath path; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 128 | |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 129 | path.moveTo(0, 20); |
| 130 | path.quadTo(10, 10, 20, 20); |
reed@google.com | 9d5f76a | 2012-05-01 14:49:28 +0000 | [diff] [blame] | 131 | path.toggleInverseFillType(); |
| 132 | |
| 133 | SkPaint paint; |
| 134 | |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 135 | SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480)); |
| 136 | SkCanvas* canvas = surface->getCanvas(); |
| 137 | canvas->save(); |
| 138 | canvas->clipRect(SkRect::MakeWH(19, 11)); |
reed@google.com | 9d5f76a | 2012-05-01 14:49:28 +0000 | [diff] [blame] | 139 | |
| 140 | paint.setAntiAlias(false); |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 141 | canvas->drawPath(path, paint); |
reed@google.com | 9d5f76a | 2012-05-01 14:49:28 +0000 | [diff] [blame] | 142 | paint.setAntiAlias(true); |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 143 | canvas->drawPath(path, paint); |
reed@google.com | 9d5f76a | 2012-05-01 14:49:28 +0000 | [diff] [blame] | 144 | |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 145 | canvas->restore(); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 146 | |
reed@google.com | 9d5f76a | 2012-05-01 14:49:28 +0000 | [diff] [blame] | 147 | // Now do the test again, with the path flipped, so we only draw in the |
| 148 | // top half of our bounds, and have the clip intersect our bounds at the |
| 149 | // bottom. |
| 150 | path.reset(); // preserves our filltype |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 151 | path.moveTo(0, 10); |
| 152 | path.quadTo(10, 20, 20, 10); |
| 153 | canvas->clipRect(SkRect::MakeXYWH(0, 19, 19, 11)); |
reed@google.com | 9d5f76a | 2012-05-01 14:49:28 +0000 | [diff] [blame] | 154 | |
| 155 | paint.setAntiAlias(false); |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 156 | canvas->drawPath(path, paint); |
reed@google.com | 9d5f76a | 2012-05-01 14:49:28 +0000 | [diff] [blame] | 157 | paint.setAntiAlias(true); |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 158 | canvas->drawPath(path, paint); |
reed@google.com | 9d5f76a | 2012-05-01 14:49:28 +0000 | [diff] [blame] | 159 | } |
| 160 | |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 161 | static void test_bug533() { |
mike@reedtribe.org | 6093e65 | 2012-04-14 12:55:17 +0000 | [diff] [blame] | 162 | /* |
| 163 | http://code.google.com/p/skia/issues/detail?id=533 |
| 164 | This particular test/bug only applies to the float case, where the |
| 165 | coordinates are very large. |
| 166 | */ |
| 167 | SkPath path; |
| 168 | path.moveTo(64, 3); |
| 169 | path.quadTo(-329936, -100000000, 1153, 330003); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 170 | |
mike@reedtribe.org | 6093e65 | 2012-04-14 12:55:17 +0000 | [diff] [blame] | 171 | SkPaint paint; |
| 172 | paint.setAntiAlias(true); |
| 173 | |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 174 | SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480)); |
| 175 | surface->getCanvas()->drawPath(path, paint); |
mike@reedtribe.org | 6093e65 | 2012-04-14 12:55:17 +0000 | [diff] [blame] | 176 | } |
| 177 | |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 178 | static void test_crbug_140642() { |
reed@google.com | d9ee348 | 2012-08-06 14:58:35 +0000 | [diff] [blame] | 179 | /* |
| 180 | * We used to see this construct, and due to rounding as we accumulated |
| 181 | * our length, the loop where we apply the phase would run off the end of |
| 182 | * the array, since it relied on just -= each interval value, which did not |
| 183 | * behave as "expected". Now the code explicitly checks for walking off the |
| 184 | * end of that array. |
| 185 | |
| 186 | * A different (better) fix might be to rewrite dashing to do all of its |
| 187 | * length/phase/measure math using double, but this may need to be |
| 188 | * coordinated with SkPathMeasure, to be consistent between the two. |
| 189 | |
| 190 | <path stroke="mintcream" stroke-dasharray="27734 35660 2157846850 247" |
| 191 | stroke-dashoffset="-248.135982067"> |
| 192 | */ |
| 193 | |
reed@google.com | d9ee348 | 2012-08-06 14:58:35 +0000 | [diff] [blame] | 194 | const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 }; |
reed | a439334 | 2016-03-18 11:22:57 -0700 | [diff] [blame] | 195 | auto dontAssert = SkDashPathEffect::Make(vals, 4, -248.135982067f); |
reed@google.com | d9ee348 | 2012-08-06 14:58:35 +0000 | [diff] [blame] | 196 | } |
| 197 | |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 198 | static void test_crbug_124652() { |
reed@google.com | 1df888b | 2012-04-24 22:47:21 +0000 | [diff] [blame] | 199 | /* |
| 200 | http://code.google.com/p/chromium/issues/detail?id=124652 |
| 201 | This particular test/bug only applies to the float case, where |
| 202 | large values can "swamp" small ones. |
| 203 | */ |
| 204 | SkScalar intervals[2] = {837099584, 33450}; |
reed | a439334 | 2016-03-18 11:22:57 -0700 | [diff] [blame] | 205 | auto dontAssert = SkDashPathEffect::Make(intervals, 2, -10); |
reed@google.com | 1df888b | 2012-04-24 22:47:21 +0000 | [diff] [blame] | 206 | } |
| 207 | |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 208 | static void test_bigcubic() { |
reed@google.com | a90aa53 | 2012-04-16 16:27:09 +0000 | [diff] [blame] | 209 | SkPath path; |
| 210 | path.moveTo(64, 3); |
| 211 | path.cubicTo(-329936, -100000000, -329936, 100000000, 1153, 330003); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 212 | |
reed@google.com | a90aa53 | 2012-04-16 16:27:09 +0000 | [diff] [blame] | 213 | SkPaint paint; |
| 214 | paint.setAntiAlias(true); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 215 | |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 216 | SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480)); |
| 217 | surface->getCanvas()->drawPath(path, paint); |
reed@google.com | a90aa53 | 2012-04-16 16:27:09 +0000 | [diff] [blame] | 218 | } |
| 219 | |
caryclark | 6df6115 | 2016-01-04 14:17:47 -0800 | [diff] [blame] | 220 | // asserts if halfway case is not handled |
| 221 | static void test_halfway() { |
| 222 | SkPaint paint; |
| 223 | SkPath path; |
| 224 | path.moveTo(16365.5f, 1394); |
| 225 | path.lineTo(16365.5f, 1387.5f); |
| 226 | path.quadTo(16365.5f, 1385.43f, 16367, 1383.96f); |
| 227 | path.quadTo(16368.4f, 1382.5f, 16370.5f, 1382.5f); |
| 228 | path.lineTo(16465.5f, 1382.5f); |
| 229 | path.quadTo(16467.6f, 1382.5f, 16469, 1383.96f); |
| 230 | path.quadTo(16470.5f, 1385.43f, 16470.5f, 1387.5f); |
| 231 | path.lineTo(16470.5f, 1394); |
| 232 | path.quadTo(16470.5f, 1396.07f, 16469, 1397.54f); |
| 233 | path.quadTo(16467.6f, 1399, 16465.5f, 1399); |
| 234 | path.lineTo(16370.5f, 1399); |
| 235 | path.quadTo(16368.4f, 1399, 16367, 1397.54f); |
| 236 | path.quadTo(16365.5f, 1396.07f, 16365.5f, 1394); |
| 237 | path.close(); |
| 238 | SkPath p2; |
| 239 | SkMatrix m; |
| 240 | m.reset(); |
| 241 | m.postTranslate(0.001f, 0.001f); |
| 242 | path.transform(m, &p2); |
| 243 | |
| 244 | SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480)); |
| 245 | SkCanvas* canvas = surface->getCanvas(); |
| 246 | canvas->translate(-16366, -1383); |
| 247 | canvas->drawPath(p2, paint); |
| 248 | |
| 249 | m.reset(); |
| 250 | m.postTranslate(-0.001f, -0.001f); |
| 251 | path.transform(m, &p2); |
| 252 | canvas->drawPath(p2, paint); |
| 253 | |
| 254 | m.reset(); |
| 255 | path.transform(m, &p2); |
| 256 | canvas->drawPath(p2, paint); |
| 257 | } |
| 258 | |
reed@google.com | dceecc7 | 2012-02-23 19:20:19 +0000 | [diff] [blame] | 259 | // we used to assert if the bounds of the device (clip) was larger than 32K |
| 260 | // even when the path itself was smaller. We just draw and hope in the debug |
| 261 | // version to not assert. |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 262 | static void test_giantaa() { |
reed@google.com | dceecc7 | 2012-02-23 19:20:19 +0000 | [diff] [blame] | 263 | const int W = 400; |
| 264 | const int H = 400; |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 265 | SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(33000, 10)); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 266 | |
reed@google.com | dceecc7 | 2012-02-23 19:20:19 +0000 | [diff] [blame] | 267 | SkPaint paint; |
| 268 | paint.setAntiAlias(true); |
| 269 | SkPath path; |
| 270 | path.addOval(SkRect::MakeXYWH(-10, -10, 20 + W, 20 + H)); |
reed | 3054be1 | 2014-12-10 07:24:28 -0800 | [diff] [blame] | 271 | surface->getCanvas()->drawPath(path, paint); |
reed@google.com | dceecc7 | 2012-02-23 19:20:19 +0000 | [diff] [blame] | 272 | } |
| 273 | |
fmalita@google.com | bfa0401 | 2012-12-12 22:13:58 +0000 | [diff] [blame] | 274 | // Extremely large path_length/dash_length ratios may cause infinite looping |
| 275 | // in SkDashPathEffect::filterPath() due to single precision rounding. |
| 276 | // The test is quite expensive, but it should get much faster after the fix |
| 277 | // for http://crbug.com/165432 goes in. |
| 278 | static void test_infinite_dash(skiatest::Reporter* reporter) { |
| 279 | SkPath path; |
| 280 | path.moveTo(0, 0); |
| 281 | path.lineTo(5000000, 0); |
| 282 | |
| 283 | SkScalar intervals[] = { 0.2f, 0.2f }; |
reed | a439334 | 2016-03-18 11:22:57 -0700 | [diff] [blame] | 284 | sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, 2, 0)); |
fmalita@google.com | bfa0401 | 2012-12-12 22:13:58 +0000 | [diff] [blame] | 285 | |
| 286 | SkPath filteredPath; |
| 287 | SkPaint paint; |
| 288 | paint.setStyle(SkPaint::kStroke_Style); |
commit-bot@chromium.org | 0a2bf90 | 2014-02-20 20:40:19 +0000 | [diff] [blame] | 289 | paint.setPathEffect(dash); |
fmalita@google.com | bfa0401 | 2012-12-12 22:13:58 +0000 | [diff] [blame] | 290 | |
| 291 | paint.getFillPath(path, &filteredPath); |
| 292 | // If we reach this, we passed. |
| 293 | REPORTER_ASSERT(reporter, true); |
| 294 | } |
| 295 | |
fmalita@google.com | 6b18d24 | 2012-12-17 16:27:34 +0000 | [diff] [blame] | 296 | // http://crbug.com/165432 |
| 297 | // Limit extreme dash path effects to avoid exhausting the system memory. |
| 298 | static void test_crbug_165432(skiatest::Reporter* reporter) { |
| 299 | SkPath path; |
| 300 | path.moveTo(0, 0); |
| 301 | path.lineTo(10000000, 0); |
| 302 | |
| 303 | SkScalar intervals[] = { 0.5f, 0.5f }; |
reed | a439334 | 2016-03-18 11:22:57 -0700 | [diff] [blame] | 304 | sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, 2, 0)); |
fmalita@google.com | 6b18d24 | 2012-12-17 16:27:34 +0000 | [diff] [blame] | 305 | |
| 306 | SkPaint paint; |
| 307 | paint.setStyle(SkPaint::kStroke_Style); |
commit-bot@chromium.org | 0a2bf90 | 2014-02-20 20:40:19 +0000 | [diff] [blame] | 308 | paint.setPathEffect(dash); |
fmalita@google.com | 6b18d24 | 2012-12-17 16:27:34 +0000 | [diff] [blame] | 309 | |
| 310 | SkPath filteredPath; |
| 311 | SkStrokeRec rec(paint); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 312 | REPORTER_ASSERT(reporter, !dash->filterPath(&filteredPath, path, &rec, nullptr)); |
fmalita@google.com | 6b18d24 | 2012-12-17 16:27:34 +0000 | [diff] [blame] | 313 | REPORTER_ASSERT(reporter, filteredPath.isEmpty()); |
| 314 | } |
| 315 | |
herb | 7cf12dd | 2016-01-11 08:08:56 -0800 | [diff] [blame] | 316 | // http://crbug.com/472147 |
| 317 | // This is a simplified version from the bug. RRect radii not properly scaled. |
| 318 | static void test_crbug_472147_simple(skiatest::Reporter* reporter) { |
| 319 | SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(1000, 1000)); |
| 320 | SkCanvas* canvas = surface->getCanvas(); |
| 321 | SkPaint p; |
| 322 | SkRect r = SkRect::MakeLTRB(-246.0f, 33.0f, 848.0f, 33554464.0f); |
| 323 | SkVector radii[4] = { |
| 324 | { 13.0f, 8.0f }, { 170.0f, 2.0 }, { 256.0f, 33554430.0f }, { 120.0f, 5.0f } |
| 325 | }; |
| 326 | SkRRect rr; |
| 327 | rr.setRectRadii(r, radii); |
| 328 | canvas->drawRRect(rr, p); |
| 329 | } |
| 330 | |
| 331 | // http://crbug.com/472147 |
| 332 | // RRect radii not properly scaled. |
| 333 | static void test_crbug_472147_actual(skiatest::Reporter* reporter) { |
| 334 | SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(1000, 1000)); |
| 335 | SkCanvas* canvas = surface->getCanvas(); |
| 336 | SkPaint p; |
| 337 | SkRect r = SkRect::MakeLTRB(-246.0f, 33.0f, 848.0f, 33554464.0f); |
| 338 | SkVector radii[4] = { |
| 339 | { 13.0f, 8.0f }, { 170.0f, 2.0 }, { 256.0f, 33554430.0f }, { 120.0f, 5.0f } |
| 340 | }; |
| 341 | SkRRect rr; |
| 342 | rr.setRectRadii(r, radii); |
| 343 | canvas->clipRRect(rr, SkRegion::kIntersect_Op, false); |
| 344 | |
| 345 | SkRect r2 = SkRect::MakeLTRB(0, 33, 1102, 33554464); |
| 346 | canvas->drawRect(r2, p); |
| 347 | } |
| 348 | |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 349 | DEF_TEST(DrawPath, reporter) { |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 350 | test_giantaa(); |
| 351 | test_bug533(); |
| 352 | test_bigcubic(); |
| 353 | test_crbug_124652(); |
| 354 | test_crbug_140642(); |
| 355 | test_crbug_140803(); |
| 356 | test_inversepathwithclip(); |
humper@google.com | 05af1af | 2013-01-07 16:47:43 +0000 | [diff] [blame] | 357 | // why? |
sugoi@google.com | 54f0d1b | 2013-02-27 19:17:41 +0000 | [diff] [blame] | 358 | if (false) test_crbug131181(); |
fmalita@google.com | bfa0401 | 2012-12-12 22:13:58 +0000 | [diff] [blame] | 359 | test_infinite_dash(reporter); |
fmalita@google.com | 6b18d24 | 2012-12-17 16:27:34 +0000 | [diff] [blame] | 360 | test_crbug_165432(reporter); |
herb | 7cf12dd | 2016-01-11 08:08:56 -0800 | [diff] [blame] | 361 | test_crbug_472147_simple(reporter); |
| 362 | test_crbug_472147_actual(reporter); |
reed@google.com | 1c028bd | 2013-08-28 15:23:19 +0000 | [diff] [blame] | 363 | test_big_aa_rect(reporter); |
caryclark | 6df6115 | 2016-01-04 14:17:47 -0800 | [diff] [blame] | 364 | test_halfway(); |
reed@google.com | dceecc7 | 2012-02-23 19:20:19 +0000 | [diff] [blame] | 365 | } |