blob: f632852860de6ced45254910d22fc3f63113aa37 [file] [log] [blame]
commit-bot@chromium.org63972172013-10-16 13:53:54 +00001/*
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"
Mike Klein33d20552017-03-22 13:47:51 -04009#include "sk_tool_utils.h"
reedfb8c1fc2015-08-04 18:44:56 -070010#include "SkBlurMaskFilter.h"
bungemand3ebb482015-08-05 13:57:49 -070011#include "SkColorFilter.h"
12#include "SkPath.h"
commit-bot@chromium.org63972172013-10-16 13:53:54 +000013
commit-bot@chromium.org63972172013-10-16 13:53:54 +000014/**
15 * This test exercises bug 1719. An anti-aliased blurred path is rendered through a soft clip. On
16 * the GPU a scratch texture was used to hold the original path mask as well as the blurred path
17 * result. The same texture is then incorrectly used to generate the soft clip mask for the draw.
18 * Thus the same texture is used for both the blur mask and soft mask in a single draw.
19 *
20 * The correct image should look like a thin stroked round rect.
21 */
halcanary2a243382015-09-09 08:16:41 -070022DEF_SIMPLE_GM_BG(skbug1719, canvas, 300, 100,
23 sk_tool_utils::color_to_565(0xFF303030)) {
commit-bot@chromium.org63972172013-10-16 13:53:54 +000024 canvas->translate(SkIntToScalar(-800), SkIntToScalar(-650));
25
26 // The data is lifted from an SKP that exhibited the bug.
27
28 // This is a round rect.
29 SkPath clipPath;
30 clipPath.moveTo(832.f, 654.f);
31 clipPath.lineTo(1034.f, 654.f);
32 clipPath.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f);
33 clipPath.lineTo(1042.f, 724.f);
34 clipPath.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f);
35 clipPath.lineTo(832.f, 732.f);
36 clipPath.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f);
37 clipPath.lineTo(824.f, 662.f);
38 clipPath.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f);
39 clipPath.close();
40
41 // This is a round rect nested inside a rect.
42 SkPath drawPath;
43 drawPath.moveTo(823.f, 653.f);
44 drawPath.lineTo(1043.f, 653.f);
45 drawPath.lineTo(1043.f, 733.f);
46 drawPath.lineTo(823.f, 733.f);
47 drawPath.lineTo(823.f, 653.f);
48 drawPath.close();
49 drawPath.moveTo(832.f, 654.f);
50 drawPath.lineTo(1034.f, 654.f);
51 drawPath.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f);
52 drawPath.lineTo(1042.f, 724.f);
53 drawPath.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f);
54 drawPath.lineTo(832.f, 732.f);
55 drawPath.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f);
56 drawPath.lineTo(824.f, 662.f);
57 drawPath.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f);
58 drawPath.close();
59 drawPath.setFillType(SkPath::kEvenOdd_FillType);
60
61 SkPaint paint;
62 paint.setAntiAlias(true);
63 paint.setColor(0xFF000000);
64 paint.setMaskFilter(
reedefdfd512016-04-04 10:02:58 -070065 SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 0.78867501f,
66 SkBlurMaskFilter::kHighQuality_BlurFlag));
Mike Reed7d954ad2016-10-28 15:42:34 -040067 paint.setColorFilter(SkColorFilter::MakeModeFilter(0xBFFFFFFF, SkBlendMode::kSrcIn));
commit-bot@chromium.org63972172013-10-16 13:53:54 +000068
reed66998382016-09-21 11:15:07 -070069 canvas->clipPath(clipPath, true);
commit-bot@chromium.org63972172013-10-16 13:53:54 +000070 canvas->drawPath(drawPath, paint);
commit-bot@chromium.org63972172013-10-16 13:53:54 +000071}