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 "SkBlurImageFilter.h"
12 // TODO deprecate imageblur
17 static const float kBlurSigmas[] = {
18 0.0, 0.3f, 0.5f, 2.0f, 32.0f, 80.0f };
20 const char* kTestStrings[] = {
31 class BlurImageFilter : public GM {
34 this->setBGColor(0xFFFFFFFF);
35 fName.printf("imageblur2");
40 SkString onShortName() override {
44 SkISize onISize() override {
45 return SkISize::Make(WIDTH, HEIGHT);
48 void onDraw(SkCanvas* canvas) override {
49 const int sigmaCount = SK_ARRAY_COUNT(kBlurSigmas);
50 const int testStringCount = SK_ARRAY_COUNT(kTestStrings);
51 SkScalar dx = WIDTH / sigmaCount;
52 SkScalar dy = HEIGHT / sigmaCount;
53 const SkScalar textSize = 12;
55 for (int x = 0; x < sigmaCount; x++) {
56 SkScalar sigmaX = kBlurSigmas[x];
57 for (int y = 0; y < sigmaCount; y++) {
58 SkScalar sigmaY = kBlurSigmas[y];
61 paint.setImageFilter(SkBlurImageFilter::Create(sigmaX, sigmaY))->unref();
62 canvas->saveLayer(NULL, &paint);
66 textPaint.setAntiAlias(false);
67 textPaint.setColor(rand.nextBits(24) | 0xFF000000);
68 textPaint.setTextSize(textSize);
70 for (int i = 0; i < testStringCount; i++) {
71 canvas->drawText(kTestStrings[i],
72 strlen(kTestStrings[i]),
73 SkIntToScalar(x * dx),
74 SkIntToScalar(y * dy + textSize * i + textSize),
88 //////////////////////////////////////////////////////////////////////////////
90 static GM* MyFactory(void*) { return new BlurImageFilter; }
91 static GMRegistry reg(MyFactory);