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 | */ |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 7 | #include "include/core/SkCanvas.h" |
| 8 | #include "include/core/SkMaskFilter.h" |
| 9 | #include "samplecode/Sample.h" |
| 10 | #include "src/core/SkBlurMask.h" |
senorblanco@chromium.org | e36ddf0 | 2011-07-15 14:28:16 +0000 | [diff] [blame] | 11 | |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 12 | class BigBlurView : public Sample { |
senorblanco@chromium.org | e36ddf0 | 2011-07-15 14:28:16 +0000 | [diff] [blame] | 13 | public: |
| 14 | BigBlurView() { |
| 15 | } |
| 16 | |
| 17 | protected: |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 18 | virtual bool onQuery(Sample::Event* evt) { |
| 19 | if (Sample::TitleQ(*evt)) { |
| 20 | Sample::TitleR(evt, "BigBlur"); |
senorblanco@chromium.org | e36ddf0 | 2011-07-15 14:28:16 +0000 | [diff] [blame] | 21 | return true; |
| 22 | } |
| 23 | return this->INHERITED::onQuery(evt); |
| 24 | } |
| 25 | |
| 26 | virtual void onDrawContent(SkCanvas* canvas) { |
| 27 | SkPaint paint; |
| 28 | canvas->save(); |
| 29 | paint.setColor(SK_ColorBLUE); |
Mike Reed | 1be1f8d | 2018-03-14 13:01:17 -0400 | [diff] [blame] | 30 | paint.setMaskFilter(SkMaskFilter::MakeBlur( |
commit-bot@chromium.org | e396455 | 2014-04-28 16:25:35 +0000 | [diff] [blame] | 31 | kNormal_SkBlurStyle, |
Mike Reed | 1be1f8d | 2018-03-14 13:01:17 -0400 | [diff] [blame] | 32 | SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(128)))); |
senorblanco@chromium.org | e36ddf0 | 2011-07-15 14:28:16 +0000 | [diff] [blame] | 33 | canvas->translate(200, 200); |
senorblanco@chromium.org | 4a947d2 | 2011-07-18 21:48:35 +0000 | [diff] [blame] | 34 | canvas->drawCircle(100, 100, 200, paint); |
senorblanco@chromium.org | e36ddf0 | 2011-07-15 14:28:16 +0000 | [diff] [blame] | 35 | canvas->restore(); |
| 36 | } |
| 37 | |
| 38 | private: |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 39 | typedef Sample INHERITED; |
senorblanco@chromium.org | e36ddf0 | 2011-07-15 14:28:16 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | ////////////////////////////////////////////////////////////////////////////// |
| 43 | |
Ben Wagner | b2c4ea6 | 2018-08-08 11:36:17 -0400 | [diff] [blame] | 44 | DEF_SAMPLE( return new BigBlurView(); ) |