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" 96397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org#include "SkColorFilter.h" 106397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org#include "SkBlurMaskFilter.h" 116397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 126397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.orgnamespace skiagm { 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 */ 226397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.orgclass SkBug1719GM : public GM { 236397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.orgpublic: 246397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org SkBug1719GM() {} 256397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 266397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.orgprotected: 27a90c6803865766d28e92091f56f718f5e41fe80fcommit-bot@chromium.org virtual uint32_t onGetFlags() const SK_OVERRIDE { 28a90c6803865766d28e92091f56f718f5e41fe80fcommit-bot@chromium.org return kSkipTiled_Flag; 29a90c6803865766d28e92091f56f718f5e41fe80fcommit-bot@chromium.org } 30a90c6803865766d28e92091f56f718f5e41fe80fcommit-bot@chromium.org 316397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org virtual SkString onShortName() SK_OVERRIDE { 326397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org return SkString("skbug1719"); 336397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org } 346397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 356397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org virtual SkISize onISize() SK_OVERRIDE { 36f539318f0d3dba743ec1886d5d9df0fb1be628a1tfarina return SkISize::Make(300, 100); 376397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org } 386397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 396397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org virtual void onDrawBackground(SkCanvas* canvas) SK_OVERRIDE { 406397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org SkPaint bgPaint; 416397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org bgPaint.setColor(0xFF303030); 426397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org canvas->drawPaint(bgPaint); 436397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org } 446397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 456397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 466397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org canvas->translate(SkIntToScalar(-800), SkIntToScalar(-650)); 476397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 486397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org // The data is lifted from an SKP that exhibited the bug. 496397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 506397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org // This is a round rect. 516397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org SkPath clipPath; 526397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.moveTo(832.f, 654.f); 536397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.lineTo(1034.f, 654.f); 546397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f); 556397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.lineTo(1042.f, 724.f); 566397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f); 576397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.lineTo(832.f, 732.f); 586397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f); 596397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.lineTo(824.f, 662.f); 606397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f); 616397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org clipPath.close(); 626397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 636397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org // This is a round rect nested inside a rect. 646397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org SkPath drawPath; 656397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.moveTo(823.f, 653.f); 666397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(1043.f, 653.f); 676397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(1043.f, 733.f); 686397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(823.f, 733.f); 696397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(823.f, 653.f); 706397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.close(); 716397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.moveTo(832.f, 654.f); 726397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(1034.f, 654.f); 736397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.cubicTo(1038.4183f, 654.f, 1042.f, 657.58173f, 1042.f, 662.f); 746397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(1042.f, 724.f); 756397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.cubicTo(1042.f, 728.41827f, 1038.4183f, 732.f, 1034.f, 732.f); 766397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(832.f, 732.f); 776397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.cubicTo(827.58173f, 732.f, 824.f, 728.41827f, 824.f, 724.f); 786397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.lineTo(824.f, 662.f); 796397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.cubicTo(824.f, 657.58173f, 827.58173f, 654.f, 832.f, 654.f); 806397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.close(); 816397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org drawPath.setFillType(SkPath::kEvenOdd_FillType); 826397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 836397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org SkPaint paint; 846397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org paint.setAntiAlias(true); 856397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org paint.setColor(0xFF000000); 866397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org paint.setMaskFilter( 87e396455d2d60ddf8e625b5037254f3c09fbcdcf5commit-bot@chromium.org SkBlurMaskFilter::Create(kNormal_SkBlurStyle, 886397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 0.78867501f, 896397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org SkBlurMaskFilter::kHighQuality_BlurFlag))->unref(); 906397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org paint.setColorFilter( 916397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org SkColorFilter::CreateModeFilter(0xBFFFFFFF, SkXfermode::kSrcIn_Mode))->unref(); 926397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 936397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org canvas->clipPath(clipPath, SkRegion::kIntersect_Op, true); 946397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org canvas->drawPath(drawPath, paint); 956397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org } 966397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 976397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.orgprivate: 986397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 996397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org typedef GM INHERITED; 1006397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org}; 1016397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 1026397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org////////////////////////////////////////////////////////////////////////////// 1036397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 1046397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.orgDEF_GM(return new SkBug1719GM;) 1056397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org 1066397217b300ec18704d49c54f5b30119dc799923commit-bot@chromium.org} 107