Home | History | Annotate | Download | only in samplecode
      1 
      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  */
      8 #include "SampleCode.h"
      9 #include "SkBlurMask.h"
     10 #include "SkBlurMaskFilter.h"
     11 #include "SkCanvas.h"
     12 #include "SkView.h"
     13 
     14 class BigBlurView : public SampleView {
     15 public:
     16     BigBlurView() {
     17     }
     18 
     19 protected:
     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(
     34             kNormal_SkBlurStyle,
     35             SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(128)),
     36             SkBlurMaskFilter::kHighQuality_BlurFlag);
     37         paint.setMaskFilter(mf)->unref();
     38         canvas->translate(200, 200);
     39         canvas->drawCircle(100, 100, 200, paint);
     40         canvas->restore();
     41     }
     42 
     43 private:
     44     typedef SkView INHERITED;
     45 };
     46 
     47 //////////////////////////////////////////////////////////////////////////////
     48 
     49 static SkView* MyFactory() { return new BigBlurView; }
     50 static SkViewRegister reg(MyFactory);
     51