xref: /aosp_15_r20/external/skia/gm/blurtextsmallradii.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2017 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/SkBlurTypes.h"
10 #include "include/core/SkCanvas.h"
11 #include "include/core/SkColor.h"
12 #include "include/core/SkFont.h"
13 #include "include/core/SkMaskFilter.h"
14 #include "include/core/SkPaint.h"
15 #include "tools/fonts/FontToolUtils.h"
16 
17 // GM to check the behavior from chrome bug:745290
18 DEF_SIMPLE_GM(blurSmallRadii, canvas, 100, 100) {
19     double sigmas[] = {0.5, 0.75, 1.0, 1.5, 2.5};
20     SkPaint paint;
21     SkFont font = ToolUtils::DefaultPortableFont();
22 
23     for (auto sigma : sigmas) {
24         paint.setColor(SK_ColorRED);
25         paint.setAntiAlias(true);
26         paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma));
27         canvas->drawString("guest", 20, 10, font, paint);
28 
29         paint.setMaskFilter(nullptr);
30         paint.setColor(SK_ColorGREEN);
31         canvas->drawString("guest", 20, 10, font, paint);
32         canvas->translate(0, 20);
33     }
34 }
35