16397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org/* 26397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org * Copyright 2013 Google Inc. 36397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org * 46397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org * Use of this source code is governed by a BSD-style license that can be 56397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org * found in the LICENSE file. 66397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org */ 76397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 86397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org#include "gm.h" 933d2055e594177b27360f84e0631b26d74a55a9bMike Klein#include "sk_tool_utils.h" 10fb8c1fcab19c99b56d2fdcf6234751d6f0465142reed#include "SkBlurMaskFilter.h" 11d3ebb48320cf1b7e969974673e4bd7743816985ebungeman#include "SkColorFilter.h" 12d3ebb48320cf1b7e969974673e4bd7743816985ebungeman#include "SkPath.h" 136397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 146397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org/** 156397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org * This test exercises bug 1719. An anti-aliased blurred path is rendered through a soft clip. On 166397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org * the GPU a scratch texture was used to hold the original path mask as well as the blurred path 176397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org * result. The same texture is then incorrectly used to generate the soft clip mask for the draw. 186397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org * Thus the same texture is used for both the blur mask and soft mask in a single draw. 196397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org * 206397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org * The correct image should look like a thin stroked round rect. 216397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org */ 222a24338c777462e04a2b26295f9c034155ee8f3ehalcanaryDEF_SIMPLE_GM_BG(skbug1719, canvas, 300, 100, 232a24338c777462e04a2b26295f9c034155ee8f3ehalcanary sk_tool_utils::color_to_565(0xFF303030)) { 246397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org canvas->translate(SkIntToScalar(-800), SkIntToScalar(-650)); 256397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 266397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org // The data is lifted from an SKP that exhibited the bug. 276397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 286397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org // This is a round rect. 296397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org SkPath clipPath; 306397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.moveTo(832.f, 654.f); 316397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.lineTo(1034.f, 654.f); 326397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f); 336397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.lineTo(1042.f, 724.f); 346397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f); 356397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.lineTo(832.f, 732.f); 366397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f); 376397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.lineTo(824.f, 662.f); 386397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f); 396397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.close(); 406397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 416397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org // This is a round rect nested inside a rect. 426397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org SkPath drawPath; 436397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.moveTo(823.f, 653.f); 446397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(1043.f, 653.f); 456397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(1043.f, 733.f); 466397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(823.f, 733.f); 476397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(823.f, 653.f); 486397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.close(); 496397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.moveTo(832.f, 654.f); 506397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(1034.f, 654.f); 516397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f); 526397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(1042.f, 724.f); 536397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f); 546397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(832.f, 732.f); 556397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f); 566397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(824.f, 662.f); 576397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f); 586397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.close(); 596397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.setFillType(SkPath::kEvenOdd_FillType); 606397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 616397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org SkPaint paint; 626397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org paint.setAntiAlias(true); 636397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org paint.setColor(0xFF000000); 646397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org paint.setMaskFilter( 65efdfd51b68a300d5c6e28743fe0344ca05d1cec9reed SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 0.78867501f, 66efdfd51b68a300d5c6e28743fe0344ca05d1cec9reed SkBlurMaskFilter::kHighQuality_BlurFlag)); 677d954ad797176afedb9262fdea4507d0fc60eb9dMike Reed paint.setColorFilter(SkColorFilter::MakeModeFilter(0xBFFFFFFF, SkBlendMode::kSrcIn)); 686397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 69669983856d99b9312be3166b7dd1f8483a90c315reed canvas->clipPath(clipPath, true); 706397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org canvas->drawPath(drawPath, paint); 716397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org} 72