2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
9 #include "SkColorFilter.h"
10 #include "SkBlurMaskFilter.h"
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.
20 * The correct image should look like a thin stroked round rect.
22 class SkBug1719GM : public GM {
27 SkString onShortName() SK_OVERRIDE {
28 return SkString("skbug1719");
31 SkISize onISize() SK_OVERRIDE {
32 return SkISize::Make(300, 100);
35 void onDrawBackground(SkCanvas* canvas) SK_OVERRIDE {
37 bgPaint.setColor(0xFF303030);
38 canvas->drawPaint(bgPaint);
41 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
42 canvas->translate(SkIntToScalar(-800), SkIntToScalar(-650));
44 // The data is lifted from an SKP that exhibited the bug.
46 // This is a round rect.
48 clipPath.moveTo(832.f, 654.f);
49 clipPath.lineTo(1034.f, 654.f);
50 clipPath.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f);
51 clipPath.lineTo(1042.f, 724.f);
52 clipPath.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f);
53 clipPath.lineTo(832.f, 732.f);
54 clipPath.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f);
55 clipPath.lineTo(824.f, 662.f);
56 clipPath.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f);
59 // This is a round rect nested inside a rect.
61 drawPath.moveTo(823.f, 653.f);
62 drawPath.lineTo(1043.f, 653.f);
63 drawPath.lineTo(1043.f, 733.f);
64 drawPath.lineTo(823.f, 733.f);
65 drawPath.lineTo(823.f, 653.f);
67 drawPath.moveTo(832.f, 654.f);
68 drawPath.lineTo(1034.f, 654.f);
69 drawPath.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f);
70 drawPath.lineTo(1042.f, 724.f);
71 drawPath.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f);
72 drawPath.lineTo(832.f, 732.f);
73 drawPath.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f);
74 drawPath.lineTo(824.f, 662.f);
75 drawPath.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f);
77 drawPath.setFillType(SkPath::kEvenOdd_FillType);
80 paint.setAntiAlias(true);
81 paint.setColor(0xFF000000);
83 SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
85 SkBlurMaskFilter::kHighQuality_BlurFlag))->unref();
87 SkColorFilter::CreateModeFilter(0xBFFFFFFF, SkXfermode::kSrcIn_Mode))->unref();
89 canvas->clipPath(clipPath, SkRegion::kIntersect_Op, true);
90 canvas->drawPath(drawPath, paint);
98 //////////////////////////////////////////////////////////////////////////////
100 DEF_GM(return new SkBug1719GM;)