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 "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h"
15 class BlurCirclesGM : public skiagm::GM {
18 : fName("blurcircles") {
23 SkString onShortName() SK_OVERRIDE {
27 SkISize onISize() SK_OVERRIDE {
28 return SkISize::Make(950, 950);
31 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
32 canvas->scale(1.5f, 1.5f);
33 canvas->translate(50,50);
35 const float blurRadii[] = { 1,5,10,20 };
36 const int circleRadii[] = { 5,10,25,50 };
37 for (size_t i = 0; i < SK_ARRAY_COUNT(blurRadii); ++i) {
38 SkAutoCanvasRestore autoRestore(canvas, true);
39 canvas->translate(0, SkIntToScalar(150*i));
40 for (size_t j = 0; j < SK_ARRAY_COUNT(circleRadii); ++j) {
41 SkMaskFilter* filter = SkBlurMaskFilter::Create(
43 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i])),
44 SkBlurMaskFilter::kHighQuality_BlurFlag);
46 paint.setColor(SK_ColorBLACK);
47 paint.setMaskFilter(filter)->unref();
49 canvas->drawCircle(SkIntToScalar(50),SkIntToScalar(50),SkIntToScalar(circleRadii[j]),paint);
50 canvas->translate(SkIntToScalar(150), 0);
57 typedef skiagm::GM INHERITED;
60 DEF_GM(return new BlurCirclesGM();)