| 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/gm.h" |
| 9 |
#include "include/core/SkBlendMode.h" |
| 10 |
#include "include/core/SkBlurTypes.h" |
| 11 |
#include "include/core/SkCanvas.h" |
| 12 |
#include "include/core/SkColorFilter.h" |
| 13 |
#include "include/core/SkMaskFilter.h" |
| 14 |
#include "include/core/SkPaint.h" |
| 15 |
#include "include/core/SkPath.h" |
| 16 |
#include "include/core/SkPathBuilder.h" |
| 17 |
#include "include/core/SkScalar.h" |
| 18 |
|
| 19 |
/** |
| 20 |
* This test exercises skbug.com/40032817. An anti-aliased blurred path is rendered through a soft |
| 21 |
* clip. On the GPU a scratch texture was used to hold the original path mask as well as the blurred |
| 22 |
* path result. The same texture is then incorrectly used to generate the soft clip mask for the |
| 23 |
* draw. Thus the same texture is used for both the blur mask and soft mask in a single draw. |
| 24 |
* |
| 25 |
* The correct image should look like a thin stroked round rect. |
| 26 |
*/ |
| 27 |
DEF_SIMPLE_GM_BG(skbug1719, canvas, 300, 100, 0xFF303030) { |
| 28 |
canvas->translate(SkIntToScalar(-800), SkIntToScalar(-650)); |
| 29 |
|
| 30 |
// The data is lifted from an SKP that exhibited the bug. |
| 31 |
|
| 32 |
// This is a round rect. |
| 33 |
SkPath clipPath = SkPathBuilder() |
| 34 |
.moveTo(832.f, 654.f) |
| 35 |
.lineTo(1034.f, 654.f) |
| 36 |
.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f) |
| 37 |
.lineTo(1042.f, 724.f) |
| 38 |
.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f) |
| 39 |
.lineTo(832.f, 732.f) |
| 40 |
.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f) |
| 41 |
.lineTo(824.f, 662.f) |
| 42 |
.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f) |
| 43 |
.close() |
| 44 |
.detach(); |
| 45 |
|
| 46 |
// This is a round rect nested inside a rect. |
| 47 |
SkPath drawPath = SkPathBuilder(SkPathFillType::kEvenOdd) |
| 48 |
.moveTo(823.f, 653.f) |
| 49 |
.lineTo(1043.f, 653.f) |
| 50 |
.lineTo(1043.f, 733.f) |
| 51 |
.lineTo(823.f, 733.f) |
| 52 |
.lineTo(823.f, 653.f) |
| 53 |
.close() |
| 54 |
.moveTo(832.f, 654.f) |
| 55 |
.lineTo(1034.f, 654.f) |
| 56 |
.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f) |
| 57 |
.lineTo(1042.f, 724.f) |
| 58 |
.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f) |
| 59 |
.lineTo(832.f, 732.f) |
| 60 |
.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f) |
| 61 |
.lineTo(824.f, 662.f) |
| 62 |
.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f) |
| 63 |
.close() |
| 64 |
.detach(); |
| 65 |
|
| 66 |
SkPaint paint; |
| 67 |
paint.setAntiAlias(true); |
| 68 |
paint.setColor(0xFF000000); |
| 69 |
paint.setMaskFilter( |
| 70 |
SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 0.78867501f)); |
| 71 |
paint.setColorFilter(SkColorFilters::Blend(0xBFFFFFFF, SkBlendMode::kSrcIn)); |
| 72 |
|
| 73 |
canvas->clipPath(clipPath, true); |
| 74 |
canvas->drawPath(drawPath, paint); |
| 75 |
} |