OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkRect.h" | 10 #include "SkRect.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // no stroke bleed should be visible | 39 // no stroke bleed should be visible |
40 canvas.drawRect(SkRect::MakeWH(44, 100), paint); | 40 canvas.drawRect(SkRect::MakeWH(44, 100), paint); |
41 REPORTER_ASSERT(reporter, !has_green_pixels(bm)); | 41 REPORTER_ASSERT(reporter, !has_green_pixels(bm)); |
42 | 42 |
43 // right stroke edge should bleed into the visible area | 43 // right stroke edge should bleed into the visible area |
44 canvas.scale(2, 2); | 44 canvas.scale(2, 2); |
45 canvas.drawRect(SkRect::MakeWH(22, 50), paint); | 45 canvas.drawRect(SkRect::MakeWH(22, 50), paint); |
46 REPORTER_ASSERT(reporter, has_green_pixels(bm)); | 46 REPORTER_ASSERT(reporter, has_green_pixels(bm)); |
47 } | 47 } |
48 | 48 |
| 49 static void test_skbug4406(skiatest::Reporter* reporter) { |
| 50 SkBitmap bm; |
| 51 bm.allocN32Pixels(10, 10); |
| 52 bm.eraseColor(SK_ColorTRANSPARENT); |
| 53 |
| 54 SkCanvas canvas(bm); |
| 55 const SkRect r = { 1.5f, 1, 3.5f, 3 }; |
| 56 // draw filled green rect first |
| 57 SkPaint paint; |
| 58 paint.setStyle(SkPaint::kFill_Style); |
| 59 paint.setColor(0xff00ff00); |
| 60 paint.setStrokeWidth(1); |
| 61 paint.setAntiAlias(true); |
| 62 canvas.drawRect(r, paint); |
| 63 |
| 64 // paint black with stroke rect (that asserts in bug 4406) |
| 65 // over the filled rect, it should cover it |
| 66 paint.setStyle(SkPaint::kStroke_Style); |
| 67 paint.setColor(0xff000000); |
| 68 paint.setStrokeWidth(1); |
| 69 canvas.drawRect(r, paint); |
| 70 REPORTER_ASSERT(reporter, !has_green_pixels(bm)); |
| 71 |
| 72 // do it again with thinner stroke |
| 73 paint.setStyle(SkPaint::kFill_Style); |
| 74 paint.setColor(0xff00ff00); |
| 75 paint.setStrokeWidth(1); |
| 76 paint.setAntiAlias(true); |
| 77 canvas.drawRect(r, paint); |
| 78 // paint black with stroke rect (that asserts in bug 4406) |
| 79 // over the filled rect, it doesnt cover it completelly with thinner stroke |
| 80 paint.setStyle(SkPaint::kStroke_Style); |
| 81 paint.setColor(0xff000000); |
| 82 paint.setStrokeWidth(0.99f); |
| 83 canvas.drawRect(r, paint); |
| 84 REPORTER_ASSERT(reporter, has_green_pixels(bm)); |
| 85 } |
| 86 |
49 DEF_TEST(Rect, reporter) { | 87 DEF_TEST(Rect, reporter) { |
50 test_stroke_width_clipping(reporter); | 88 test_stroke_width_clipping(reporter); |
| 89 test_skbug4406(reporter); |
51 } | 90 } |
OLD | NEW |