Index: samplecode/SampleLayers.cpp |
diff --git a/samplecode/SampleLayers.cpp b/samplecode/SampleLayers.cpp |
index f8ebd7c94f5077e88feb92edb13d1b249a228ff9..52bf5b357b2b7e308f8819c0c24d5cc31d01177a 100644 |
--- a/samplecode/SampleLayers.cpp |
+++ b/samplecode/SampleLayers.cpp |
@@ -232,80 +232,8 @@ |
private: |
typedef SkView INHERITED; |
}; |
-DEF_SAMPLE( return new LayersView; ) |
////////////////////////////////////////////////////////////////////////////// |
-#include "SkBlurImageFilter.h" |
-#include "SkMatrixConvolutionImageFilter.h" |
-#include "SkMorphologyImageFilter.h" |
- |
-#include "Resources.h" |
-#include "SkAnimTimer.h" |
- |
-class BackdropView : public SampleView { |
- SkPoint fCenter; |
- SkScalar fAngle; |
- SkAutoTUnref<SkImage> fImage; |
- SkAutoTUnref<SkImageFilter> fFilter; |
-public: |
- BackdropView() { |
- fCenter.set(200, 150); |
- fAngle = 0; |
- fImage.reset(GetResourceAsImage("mandrill_512.png")); |
- fFilter.reset(SkDilateImageFilter::Create(8, 8)); |
- } |
- |
-protected: |
- // overrides from SkEventSink |
- bool onQuery(SkEvent* evt) override { |
- if (SampleCode::TitleQ(*evt)) { |
- SampleCode::TitleR(evt, "Backdrop"); |
- return true; |
- } |
- return this->INHERITED::onQuery(evt); |
- } |
- |
- void onDrawContent(SkCanvas* canvas) override { |
- canvas->drawImage(fImage, 0, 0, nullptr); |
- |
- const SkScalar w = 250; |
- const SkScalar h = 150; |
- SkPath path; |
- path.addOval(SkRect::MakeXYWH(-w/2, -h/2, w, h)); |
- SkMatrix m; |
- m.setRotate(fAngle); |
- m.postTranslate(fCenter.x(), fCenter.y()); |
- path.transform(m); |
- |
- canvas->clipPath(path, SkRegion::kIntersect_Op, true); |
- const SkRect bounds = path.getBounds(); |
- |
- SkPaint paint; |
- paint.setAlpha(0xCC); |
- canvas->saveLayer({ &bounds, &paint, fFilter, 0 }); |
- |
- canvas->restore(); |
- } |
- |
- bool onAnimate(const SkAnimTimer& timer) override { |
- fAngle = SkDoubleToScalar(fmod(timer.secs() * 360 / 5, 360)); |
- return true; |
- } |
- |
- SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override { |
- this->inval(nullptr); |
- return new Click(this); |
- } |
- |
- bool onClick(Click* click) override { |
- this->inval(nullptr); |
- fCenter = click->fCurr; |
- return this->INHERITED::onClick(click); |
- } |
- |
-private: |
- typedef SampleView INHERITED; |
-}; |
-DEF_SAMPLE( return new BackdropView; ) |
- |
+static SkView* MyFactory() { return new LayersView; } |
+static SkViewRegister reg(MyFactory); |