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 "SkCanvas.h" |
Mike Reed | 1be1f8d | 2018-03-14 13:01:17 -0400 | [diff] [blame] | 10 | #include "SkMaskFilter.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); |
Mike Reed | 1be1f8d | 2018-03-14 13:01:17 -0400 | [diff] [blame] | 32 | paint.setMaskFilter(SkMaskFilter::MakeBlur( |
commit-bot@chromium.org | e396455 | 2014-04-28 16:25:35 +0000 | [diff] [blame] | 33 | kNormal_SkBlurStyle, |
Mike Reed | 1be1f8d | 2018-03-14 13:01:17 -0400 | [diff] [blame] | 34 | SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(128)))); |
senorblanco@chromium.org | e36ddf0 | 2011-07-15 14:28:16 +0000 | [diff] [blame] | 35 | canvas->translate(200, 200); |
senorblanco@chromium.org | 4a947d2 | 2011-07-18 21:48:35 +0000 | [diff] [blame] | 36 | canvas->drawCircle(100, 100, 200, paint); |
senorblanco@chromium.org | e36ddf0 | 2011-07-15 14:28:16 +0000 | [diff] [blame] | 37 | canvas->restore(); |
| 38 | } |
| 39 | |
| 40 | private: |
| 41 | typedef SkView INHERITED; |
| 42 | }; |
| 43 | |
| 44 | ////////////////////////////////////////////////////////////////////////////// |
| 45 | |
| 46 | static SkView* MyFactory() { return new BigBlurView; } |
| 47 | static SkViewRegister reg(MyFactory); |