OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
| 9 #include "SkBlurMask.h" |
9 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
| 11 #include "SkCanvas.h" |
10 #include "SkView.h" | 12 #include "SkView.h" |
11 #include "SkCanvas.h" | |
12 | 13 |
13 class BigBlurView : public SampleView { | 14 class BigBlurView : public SampleView { |
14 public: | 15 public: |
15 BigBlurView() { | 16 BigBlurView() { |
16 } | 17 } |
17 | 18 |
18 protected: | 19 protected: |
19 // overrides from SkEventSink | 20 // overrides from SkEventSink |
20 virtual bool onQuery(SkEvent* evt) { | 21 virtual bool onQuery(SkEvent* evt) { |
21 if (SampleCode::TitleQ(*evt)) { | 22 if (SampleCode::TitleQ(*evt)) { |
22 SampleCode::TitleR(evt, "BigBlur"); | 23 SampleCode::TitleR(evt, "BigBlur"); |
23 return true; | 24 return true; |
24 } | 25 } |
25 return this->INHERITED::onQuery(evt); | 26 return this->INHERITED::onQuery(evt); |
26 } | 27 } |
27 | 28 |
28 virtual void onDrawContent(SkCanvas* canvas) { | 29 virtual void onDrawContent(SkCanvas* canvas) { |
29 SkPaint paint; | 30 SkPaint paint; |
30 canvas->save(); | 31 canvas->save(); |
31 paint.setColor(SK_ColorBLUE); | 32 paint.setColor(SK_ColorBLUE); |
32 SkMaskFilter* mf = SkBlurMaskFilter::Create( | 33 SkMaskFilter* mf = SkBlurMaskFilter::Create( |
33 128, | |
34 SkBlurMaskFilter::kNormal_BlurStyle, | 34 SkBlurMaskFilter::kNormal_BlurStyle, |
| 35 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(128)), |
35 SkBlurMaskFilter::kHighQuality_BlurFlag); | 36 SkBlurMaskFilter::kHighQuality_BlurFlag); |
36 paint.setMaskFilter(mf)->unref(); | 37 paint.setMaskFilter(mf)->unref(); |
37 canvas->translate(200, 200); | 38 canvas->translate(200, 200); |
38 canvas->drawCircle(100, 100, 200, paint); | 39 canvas->drawCircle(100, 100, 200, paint); |
39 canvas->restore(); | 40 canvas->restore(); |
40 } | 41 } |
41 | 42 |
42 private: | 43 private: |
43 typedef SkView INHERITED; | 44 typedef SkView INHERITED; |
44 }; | 45 }; |
45 | 46 |
46 ////////////////////////////////////////////////////////////////////////////// | 47 ////////////////////////////////////////////////////////////////////////////// |
47 | 48 |
48 static SkView* MyFactory() { return new BigBlurView; } | 49 static SkView* MyFactory() { return new BigBlurView; } |
49 static SkViewRegister reg(MyFactory); | 50 static SkViewRegister reg(MyFactory); |
OLD | NEW |