blob: fcbd6ac4f9e7b9aa176ae62709085b2d899664fd [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
senorblanco@chromium.orge36ddf02011-07-15 14:28:16 +00008#include "SampleCode.h"
robertphillips@google.comb7061172013-09-06 14:16:12 +00009#include "SkBlurMask.h"
senorblanco@chromium.orge36ddf02011-07-15 14:28:16 +000010#include "SkBlurMaskFilter.h"
senorblanco@chromium.orge36ddf02011-07-15 14:28:16 +000011#include "SkCanvas.h"
robertphillips@google.comb7061172013-09-06 14:16:12 +000012#include "SkView.h"
senorblanco@chromium.orge36ddf02011-07-15 14:28:16 +000013
14class BigBlurView : public SampleView {
15public:
16 BigBlurView() {
17 }
18
19protected:
20 // overrides from SkEventSink
21 virtual bool onQuery(SkEvent* evt) {
22 if (SampleCode::TitleQ(*evt)) {
23 SampleCode::TitleR(evt, "BigBlur");
24 return true;
25 }
26 return this->INHERITED::onQuery(evt);
27 }
28
29 virtual void onDrawContent(SkCanvas* canvas) {
30 SkPaint paint;
31 canvas->save();
32 paint.setColor(SK_ColorBLUE);
33 SkMaskFilter* mf = SkBlurMaskFilter::Create(
commit-bot@chromium.orge3964552014-04-28 16:25:35 +000034 kNormal_SkBlurStyle,
robertphillips@google.comb7061172013-09-06 14:16:12 +000035 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(128)),
senorblanco@chromium.orge36ddf02011-07-15 14:28:16 +000036 SkBlurMaskFilter::kHighQuality_BlurFlag);
37 paint.setMaskFilter(mf)->unref();
38 canvas->translate(200, 200);
senorblanco@chromium.org4a947d22011-07-18 21:48:35 +000039 canvas->drawCircle(100, 100, 200, paint);
senorblanco@chromium.orge36ddf02011-07-15 14:28:16 +000040 canvas->restore();
41 }
42
43private:
44 typedef SkView INHERITED;
45};
46
47//////////////////////////////////////////////////////////////////////////////
48
49static SkView* MyFactory() { return new BigBlurView; }
50static SkViewRegister reg(MyFactory);