commit-bot@chromium.org | 6397217 | 2013-10-16 13:53:54 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "gm/gm.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 9 | #include "include/core/SkBlendMode.h" |
| 10 | #include "include/core/SkBlurTypes.h" |
| 11 | #include "include/core/SkCanvas.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 12 | #include "include/core/SkColorFilter.h" |
| 13 | #include "include/core/SkMaskFilter.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 14 | #include "include/core/SkPaint.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 15 | #include "include/core/SkPath.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 16 | #include "include/core/SkScalar.h" |
commit-bot@chromium.org | 6397217 | 2013-10-16 13:53:54 +0000 | [diff] [blame] | 17 | |
commit-bot@chromium.org | 6397217 | 2013-10-16 13:53:54 +0000 | [diff] [blame] | 18 | /** |
| 19 | * This test exercises bug 1719. An anti-aliased blurred path is rendered through a soft clip. On |
| 20 | * the GPU a scratch texture was used to hold the original path mask as well as the blurred path |
| 21 | * result. The same texture is then incorrectly used to generate the soft clip mask for the draw. |
| 22 | * Thus the same texture is used for both the blur mask and soft mask in a single draw. |
| 23 | * |
| 24 | * The correct image should look like a thin stroked round rect. |
| 25 | */ |
Mike Klein | d46dce3 | 2018-08-16 10:17:03 -0400 | [diff] [blame] | 26 | DEF_SIMPLE_GM_BG(skbug1719, canvas, 300, 100, 0xFF303030) { |
commit-bot@chromium.org | 6397217 | 2013-10-16 13:53:54 +0000 | [diff] [blame] | 27 | canvas->translate(SkIntToScalar(-800), SkIntToScalar(-650)); |
| 28 | |
| 29 | // The data is lifted from an SKP that exhibited the bug. |
| 30 | |
| 31 | // This is a round rect. |
| 32 | SkPath clipPath; |
| 33 | clipPath.moveTo(832.f, 654.f); |
| 34 | clipPath.lineTo(1034.f, 654.f); |
| 35 | clipPath.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f); |
| 36 | clipPath.lineTo(1042.f, 724.f); |
| 37 | clipPath.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f); |
| 38 | clipPath.lineTo(832.f, 732.f); |
| 39 | clipPath.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f); |
| 40 | clipPath.lineTo(824.f, 662.f); |
| 41 | clipPath.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f); |
| 42 | clipPath.close(); |
| 43 | |
| 44 | // This is a round rect nested inside a rect. |
| 45 | SkPath drawPath; |
| 46 | drawPath.moveTo(823.f, 653.f); |
| 47 | drawPath.lineTo(1043.f, 653.f); |
| 48 | drawPath.lineTo(1043.f, 733.f); |
| 49 | drawPath.lineTo(823.f, 733.f); |
| 50 | drawPath.lineTo(823.f, 653.f); |
| 51 | drawPath.close(); |
| 52 | drawPath.moveTo(832.f, 654.f); |
| 53 | drawPath.lineTo(1034.f, 654.f); |
| 54 | drawPath.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f); |
| 55 | drawPath.lineTo(1042.f, 724.f); |
| 56 | drawPath.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f); |
| 57 | drawPath.lineTo(832.f, 732.f); |
| 58 | drawPath.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f); |
| 59 | drawPath.lineTo(824.f, 662.f); |
| 60 | drawPath.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f); |
| 61 | drawPath.close(); |
Mike Reed | 7d34dc7 | 2019-11-26 12:17:17 -0500 | [diff] [blame] | 62 | drawPath.setFillType(SkPathFillType::kEvenOdd); |
commit-bot@chromium.org | 6397217 | 2013-10-16 13:53:54 +0000 | [diff] [blame] | 63 | |
| 64 | SkPaint paint; |
| 65 | paint.setAntiAlias(true); |
| 66 | paint.setColor(0xFF000000); |
| 67 | paint.setMaskFilter( |
Mike Reed | 1be1f8d | 2018-03-14 13:01:17 -0400 | [diff] [blame] | 68 | SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 0.78867501f)); |
Mike Reed | b286bc2 | 2019-04-08 16:23:20 -0400 | [diff] [blame] | 69 | paint.setColorFilter(SkColorFilters::Blend(0xBFFFFFFF, SkBlendMode::kSrcIn)); |
commit-bot@chromium.org | 6397217 | 2013-10-16 13:53:54 +0000 | [diff] [blame] | 70 | |
reed | 6699838 | 2016-09-21 11:15:07 -0700 | [diff] [blame] | 71 | canvas->clipPath(clipPath, true); |
commit-bot@chromium.org | 6397217 | 2013-10-16 13:53:54 +0000 | [diff] [blame] | 72 | canvas->drawPath(drawPath, paint); |
commit-bot@chromium.org | 6397217 | 2013-10-16 13:53:54 +0000 | [diff] [blame] | 73 | } |