2013-10-16 13:53:54 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gm.h"
|
2017-03-22 17:47:51 +00:00
|
|
|
#include "sk_tool_utils.h"
|
2015-08-05 20:57:49 +00:00
|
|
|
#include "SkColorFilter.h"
|
2018-03-14 17:01:17 +00:00
|
|
|
#include "SkMaskFilter.h"
|
2015-08-05 20:57:49 +00:00
|
|
|
#include "SkPath.h"
|
2013-10-16 13:53:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This test exercises bug 1719. An anti-aliased blurred path is rendered through a soft clip. On
|
|
|
|
* the GPU a scratch texture was used to hold the original path mask as well as the blurred path
|
|
|
|
* result. The same texture is then incorrectly used to generate the soft clip mask for the draw.
|
|
|
|
* Thus the same texture is used for both the blur mask and soft mask in a single draw.
|
|
|
|
*
|
|
|
|
* The correct image should look like a thin stroked round rect.
|
|
|
|
*/
|
2018-08-16 14:17:03 +00:00
|
|
|
DEF_SIMPLE_GM_BG(skbug1719, canvas, 300, 100, 0xFF303030) {
|
2013-10-16 13:53:54 +00:00
|
|
|
canvas->translate(SkIntToScalar(-800), SkIntToScalar(-650));
|
|
|
|
|
|
|
|
// The data is lifted from an SKP that exhibited the bug.
|
|
|
|
|
|
|
|
// This is a round rect.
|
|
|
|
SkPath clipPath;
|
|
|
|
clipPath.moveTo(832.f, 654.f);
|
|
|
|
clipPath.lineTo(1034.f, 654.f);
|
|
|
|
clipPath.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f);
|
|
|
|
clipPath.lineTo(1042.f, 724.f);
|
|
|
|
clipPath.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f);
|
|
|
|
clipPath.lineTo(832.f, 732.f);
|
|
|
|
clipPath.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f);
|
|
|
|
clipPath.lineTo(824.f, 662.f);
|
|
|
|
clipPath.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f);
|
|
|
|
clipPath.close();
|
|
|
|
|
|
|
|
// This is a round rect nested inside a rect.
|
|
|
|
SkPath drawPath;
|
|
|
|
drawPath.moveTo(823.f, 653.f);
|
|
|
|
drawPath.lineTo(1043.f, 653.f);
|
|
|
|
drawPath.lineTo(1043.f, 733.f);
|
|
|
|
drawPath.lineTo(823.f, 733.f);
|
|
|
|
drawPath.lineTo(823.f, 653.f);
|
|
|
|
drawPath.close();
|
|
|
|
drawPath.moveTo(832.f, 654.f);
|
|
|
|
drawPath.lineTo(1034.f, 654.f);
|
|
|
|
drawPath.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f);
|
|
|
|
drawPath.lineTo(1042.f, 724.f);
|
|
|
|
drawPath.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f);
|
|
|
|
drawPath.lineTo(832.f, 732.f);
|
|
|
|
drawPath.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f);
|
|
|
|
drawPath.lineTo(824.f, 662.f);
|
|
|
|
drawPath.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f);
|
|
|
|
drawPath.close();
|
|
|
|
drawPath.setFillType(SkPath::kEvenOdd_FillType);
|
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setColor(0xFF000000);
|
|
|
|
paint.setMaskFilter(
|
2018-03-14 17:01:17 +00:00
|
|
|
SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 0.78867501f));
|
2016-10-28 19:42:34 +00:00
|
|
|
paint.setColorFilter(SkColorFilter::MakeModeFilter(0xBFFFFFFF, SkBlendMode::kSrcIn));
|
2013-10-16 13:53:54 +00:00
|
|
|
|
2016-09-21 18:15:07 +00:00
|
|
|
canvas->clipPath(clipPath, true);
|
2013-10-16 13:53:54 +00:00
|
|
|
canvas->drawPath(drawPath, paint);
|
|
|
|
}
|