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"
16 void imageblurgm_draw(SkScalar fSigmaX, SkScalar fSigmaY, SkCanvas* canvas) {
18 paint.setImageFilter(SkBlurImageFilter::Make(fSigmaX, fSigmaY, nullptr));
19 canvas->saveLayer(nullptr, &paint);
20 const char* str = "The quick brown fox jumped over the lazy dog.";
24 textPaint.setAntiAlias(true);
25 sk_tool_utils::set_portable_typeface(&textPaint);
26 for (int i = 0; i < 25; ++i) {
27 int x = rand.nextULessThan(WIDTH);
28 int y = rand.nextULessThan(HEIGHT);
29 textPaint.setColor(sk_tool_utils::color_to_565(rand.nextBits(24) | 0xFF000000));
30 textPaint.setTextSize(rand.nextRangeScalar(0, 300));
31 canvas->drawString(str, SkIntToScalar(x),
32 SkIntToScalar(y), textPaint);
36 DEF_SIMPLE_GM_BG(imageblur, canvas, WIDTH, HEIGHT, SK_ColorBLACK) {
37 imageblurgm_draw(24.0f, 0.0f, canvas);
39 DEF_SIMPLE_GM_BG(imageblur_large, canvas, WIDTH, HEIGHT, SK_ColorBLACK) {
40 imageblurgm_draw(80.0f, 80.0f, canvas);