2 * Copyright 2011 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
9 #include "sk_tool_utils.h"
10 #include "SkBlurImageFilter.h"
13 // TODO deprecate imageblur
18 constexpr float kBlurSigmas[] = {
19 0.0, 0.3f, 0.5f, 2.0f, 32.0f, 80.0f };
21 const char* kTestStrings[] = {
32 class BlurImageFilter : public GM {
35 this->setBGColor(0xFFFFFFFF);
36 fName.printf("imageblur2");
41 SkString onShortName() override {
45 SkISize onISize() override {
46 return SkISize::Make(WIDTH, HEIGHT);
49 void onDraw(SkCanvas* canvas) override {
50 const int sigmaCount = SK_ARRAY_COUNT(kBlurSigmas);
51 const int testStringCount = SK_ARRAY_COUNT(kTestStrings);
52 SkScalar dx = WIDTH / sigmaCount;
53 SkScalar dy = HEIGHT / sigmaCount;
54 const SkScalar textSize = 12;
56 for (int x = 0; x < sigmaCount; x++) {
57 SkScalar sigmaX = kBlurSigmas[x];
58 for (int y = 0; y < sigmaCount; y++) {
59 SkScalar sigmaY = kBlurSigmas[y];
62 paint.setImageFilter(SkBlurImageFilter::Make(sigmaX, sigmaY, nullptr));
63 canvas->saveLayer(nullptr, &paint);
67 textPaint.setAntiAlias(false);
68 textPaint.setColor(sk_tool_utils::color_to_565(rand.nextBits(24) | 0xFF000000));
69 sk_tool_utils::set_portable_typeface(&textPaint);
70 textPaint.setTextSize(textSize);
72 for (int i = 0; i < testStringCount; i++) {
73 canvas->drawString(kTestStrings[i],
74 SkIntToScalar(x * dx),
75 SkIntToScalar(y * dy + textSize * i + textSize),
89 //////////////////////////////////////////////////////////////////////////////
91 DEF_GM(return new BlurImageFilter;)