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 | |
| 8 | #include "gm.h" |
reed | fb8c1fc | 2015-08-04 18:44:56 -0700 | [diff] [blame] | 9 | #include "SkBlurMaskFilter.h" |
bungeman | d3ebb48 | 2015-08-05 13:57:49 -0700 | [diff] [blame] | 10 | #include "SkColorFilter.h" |
| 11 | #include "SkPath.h" |
commit-bot@chromium.org | 6397217 | 2013-10-16 13:53:54 +0000 | [diff] [blame] | 12 | |
commit-bot@chromium.org | 6397217 | 2013-10-16 13:53:54 +0000 | [diff] [blame] | 13 | /** |
| 14 | * This test exercises bug 1719. An anti-aliased blurred path is rendered through a soft clip. On |
| 15 | * the GPU a scratch texture was used to hold the original path mask as well as the blurred path |
| 16 | * result. The same texture is then incorrectly used to generate the soft clip mask for the draw. |
| 17 | * Thus the same texture is used for both the blur mask and soft mask in a single draw. |
| 18 | * |
| 19 | * The correct image should look like a thin stroked round rect. |
| 20 | */ |
halcanary | 2a24338 | 2015-09-09 08:16:41 -0700 | [diff] [blame] | 21 | DEF_SIMPLE_GM_BG(skbug1719, canvas, 300, 100, |
| 22 | sk_tool_utils::color_to_565(0xFF303030)) { |
commit-bot@chromium.org | 6397217 | 2013-10-16 13:53:54 +0000 | [diff] [blame] | 23 | canvas->translate(SkIntToScalar(-800), SkIntToScalar(-650)); |
| 24 | |
| 25 | // The data is lifted from an SKP that exhibited the bug. |
| 26 | |
| 27 | // This is a round rect. |
| 28 | SkPath clipPath; |
| 29 | clipPath.moveTo(832.f, 654.f); |
| 30 | clipPath.lineTo(1034.f, 654.f); |
| 31 | clipPath.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f); |
| 32 | clipPath.lineTo(1042.f, 724.f); |
| 33 | clipPath.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f); |
| 34 | clipPath.lineTo(832.f, 732.f); |
| 35 | clipPath.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f); |
| 36 | clipPath.lineTo(824.f, 662.f); |
| 37 | clipPath.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f); |
| 38 | clipPath.close(); |
| 39 | |
| 40 | // This is a round rect nested inside a rect. |
| 41 | SkPath drawPath; |
| 42 | drawPath.moveTo(823.f, 653.f); |
| 43 | drawPath.lineTo(1043.f, 653.f); |
| 44 | drawPath.lineTo(1043.f, 733.f); |
| 45 | drawPath.lineTo(823.f, 733.f); |
| 46 | drawPath.lineTo(823.f, 653.f); |
| 47 | drawPath.close(); |
| 48 | drawPath.moveTo(832.f, 654.f); |
| 49 | drawPath.lineTo(1034.f, 654.f); |
| 50 | drawPath.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f); |
| 51 | drawPath.lineTo(1042.f, 724.f); |
| 52 | drawPath.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f); |
| 53 | drawPath.lineTo(832.f, 732.f); |
| 54 | drawPath.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f); |
| 55 | drawPath.lineTo(824.f, 662.f); |
| 56 | drawPath.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f); |
| 57 | drawPath.close(); |
| 58 | drawPath.setFillType(SkPath::kEvenOdd_FillType); |
| 59 | |
| 60 | SkPaint paint; |
| 61 | paint.setAntiAlias(true); |
| 62 | paint.setColor(0xFF000000); |
| 63 | paint.setMaskFilter( |
reed | efdfd51 | 2016-04-04 10:02:58 -0700 | [diff] [blame] | 64 | SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 0.78867501f, |
| 65 | SkBlurMaskFilter::kHighQuality_BlurFlag)); |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 66 | paint.setColorFilter(SkColorFilter::MakeModeFilter(0xBFFFFFFF, SkXfermode::kSrcIn_Mode)); |
commit-bot@chromium.org | 6397217 | 2013-10-16 13:53:54 +0000 | [diff] [blame] | 67 | |
| 68 | canvas->clipPath(clipPath, SkRegion::kIntersect_Op, true); |
| 69 | canvas->drawPath(drawPath, paint); |
commit-bot@chromium.org | 6397217 | 2013-10-16 13:53:54 +0000 | [diff] [blame] | 70 | } |