• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "SkView.h"
10 #include "SkCanvas.h"
11 #include "Sk64.h"
12 #include "SkColorShader.h"
13 #include "SkEmbossMaskFilter.h"
14 #include "SkGradientShader.h"
15 #include "SkGraphics.h"
16 #include "SkImageDecoder.h"
17 #include "SkKernel33MaskFilter.h"
18 #include "SkPath.h"
19 #include "SkRandom.h"
20 #include "SkRegion.h"
21 #include "SkShader.h"
22 #include "SkUtils.h"
23 #include "SkColorPriv.h"
24 #include "SkColorFilter.h"
25 #include "SkTime.h"
26 #include "SkTypeface.h"
27 #include "SkXfermode.h"
28 
29 class EmbossView : public SampleView {
30     SkEmbossMaskFilter::Light   fLight;
31 public:
EmbossView()32 	EmbossView() {
33         fLight.fDirection[0] = SK_Scalar1;
34         fLight.fDirection[1] = SK_Scalar1;
35         fLight.fDirection[2] = SK_Scalar1;
36         fLight.fAmbient = 128;
37         fLight.fSpecular = 16*2;
38     }
39 
40 protected:
41     // overrides from SkEventSink
onQuery(SkEvent * evt)42     virtual bool onQuery(SkEvent* evt) {
43         if (SampleCode::TitleQ(*evt)) {
44             SampleCode::TitleR(evt, "Emboss");
45             return true;
46         }
47         return this->INHERITED::onQuery(evt);
48     }
49 
onDrawContent(SkCanvas * canvas)50     virtual void onDrawContent(SkCanvas* canvas) {
51         SkPaint paint;
52 
53         paint.setAntiAlias(true);
54         paint.setStyle(SkPaint::kStroke_Style);
55         paint.setStrokeWidth(SkIntToScalar(10));
56         paint.setMaskFilter(new SkEmbossMaskFilter(fLight, SkIntToScalar(4)))->unref();
57         paint.setShader(new SkColorShader(SK_ColorBLUE))->unref();
58         paint.setDither(true);
59 
60         canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50),
61                            SkIntToScalar(30), paint);
62     }
63 
64 private:
65 
66     typedef SampleView INHERITED;
67 };
68 
69 //////////////////////////////////////////////////////////////////////////////
70 
MyFactory()71 static SkView* MyFactory() { return new EmbossView; }
72 static SkViewRegister reg(MyFactory);
73 
74