2 * Copyright 2014 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"
17 class ImageBlurTiledGM : public GM {
19 ImageBlurTiledGM(SkScalar sigmaX, SkScalar sigmaY)
20 : fSigmaX(sigmaX), fSigmaY(sigmaY) {
24 virtual SkString onShortName() {
25 return SkString("imageblurtiled");
28 virtual SkISize onISize() {
29 return SkISize::Make(WIDTH, HEIGHT);
32 virtual void onDraw(SkCanvas* canvas) {
34 paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref();
35 const SkScalar tile_size = SkIntToScalar(128);
37 if (!canvas->getClipBounds(&bounds)) {
40 for (SkScalar y = bounds.top(); y < bounds.bottom(); y += tile_size) {
41 for (SkScalar x = bounds.left(); x < bounds.right(); x += tile_size) {
43 canvas->clipRect(SkRect::MakeXYWH(x, y, tile_size, tile_size));
44 canvas->saveLayer(NULL, &paint);
52 textPaint.setAntiAlias(true);
53 sk_tool_utils::set_portable_typeface(&textPaint);
54 textPaint.setTextSize(SkIntToScalar(100));
56 for (unsigned i = 0; i < SK_ARRAY_COUNT(str); i++) {
58 canvas->drawText(str[i], strlen(str[i]), SkIntToScalar(0),
59 SkIntToScalar(posY), textPaint);
74 //////////////////////////////////////////////////////////////////////////////
76 static GM* MyFactory1(void*) { return new ImageBlurTiledGM(3.0f, 3.0f); }
77 static GMRegistry reg1(MyFactory1);