epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
senorblanco@chromium.org | e36ddf0 | 2011-07-15 14:28:16 +0000 | [diff] [blame] | 7 | #include "SampleCode.h" |
robertphillips@google.com | b706117 | 2013-09-06 14:16:12 +0000 | [diff] [blame] | 8 | #include "SkBlurMask.h" |
senorblanco@chromium.org | e36ddf0 | 2011-07-15 14:28:16 +0000 | [diff] [blame] | 9 | #include "SkBlurMaskFilter.h" |
senorblanco@chromium.org | e36ddf0 | 2011-07-15 14:28:16 +0000 | [diff] [blame] | 10 | #include "SkCanvas.h" |
robertphillips@google.com | b706117 | 2013-09-06 14:16:12 +0000 | [diff] [blame] | 11 | #include "SkView.h" |
senorblanco@chromium.org | e36ddf0 | 2011-07-15 14:28:16 +0000 | [diff] [blame] | 12 | |
| 13 | class BigBlurView : public SampleView { |
| 14 | public: |
| 15 | BigBlurView() { |
| 16 | } |
| 17 | |
| 18 | protected: |
| 19 | // overrides from SkEventSink |
| 20 | virtual bool onQuery(SkEvent* evt) { |
| 21 | if (SampleCode::TitleQ(*evt)) { |
| 22 | SampleCode::TitleR(evt, "BigBlur"); |
| 23 | return true; |
| 24 | } |
| 25 | return this->INHERITED::onQuery(evt); |
| 26 | } |
| 27 | |
| 28 | virtual void onDrawContent(SkCanvas* canvas) { |
| 29 | SkPaint paint; |
| 30 | canvas->save(); |
| 31 | paint.setColor(SK_ColorBLUE); |
reed | efdfd51 | 2016-04-04 10:02:58 -0700 | [diff] [blame] | 32 | paint.setMaskFilter(SkBlurMaskFilter::Make( |
commit-bot@chromium.org | e396455 | 2014-04-28 16:25:35 +0000 | [diff] [blame] | 33 | kNormal_SkBlurStyle, |
robertphillips@google.com | b706117 | 2013-09-06 14:16:12 +0000 | [diff] [blame] | 34 | SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(128)), |
reed | efdfd51 | 2016-04-04 10:02:58 -0700 | [diff] [blame] | 35 | SkBlurMaskFilter::kHighQuality_BlurFlag)); |
senorblanco@chromium.org | e36ddf0 | 2011-07-15 14:28:16 +0000 | [diff] [blame] | 36 | canvas->translate(200, 200); |
senorblanco@chromium.org | 4a947d2 | 2011-07-18 21:48:35 +0000 | [diff] [blame] | 37 | canvas->drawCircle(100, 100, 200, paint); |
senorblanco@chromium.org | e36ddf0 | 2011-07-15 14:28:16 +0000 | [diff] [blame] | 38 | canvas->restore(); |
| 39 | } |
| 40 | |
| 41 | private: |
| 42 | typedef SkView INHERITED; |
| 43 | }; |
| 44 | |
| 45 | ////////////////////////////////////////////////////////////////////////////// |
| 46 | |
| 47 | static SkView* MyFactory() { return new BigBlurView; } |
| 48 | static SkViewRegister reg(MyFactory); |