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 "SkCanvas.h" | 10 #include "SkCanvas.h" |
10 #include "SkView.h" | 11 #include "SkView.h" |
11 #include "Sk1DPathEffect.h" | 12 #include "Sk1DPathEffect.h" |
12 #include "Sk2DPathEffect.h" | 13 #include "Sk2DPathEffect.h" |
13 #include "SkAvoidXfermode.h" | 14 #include "SkAvoidXfermode.h" |
14 #include "SkBlurMaskFilter.h" | 15 #include "SkBlurMaskFilter.h" |
15 #include "SkColorFilter.h" | 16 #include "SkColorFilter.h" |
16 #include "SkColorPriv.h" | 17 #include "SkColorPriv.h" |
17 #include "SkCornerPathEffect.h" | 18 #include "SkCornerPathEffect.h" |
18 #include "SkDashPathEffect.h" | 19 #include "SkDashPathEffect.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 73 } |
73 } | 74 } |
74 | 75 |
75 private: | 76 private: |
76 SkPMColor fMask; | 77 SkPMColor fMask; |
77 }; | 78 }; |
78 | 79 |
79 /////////////////////////////////////////////////////////// | 80 /////////////////////////////////////////////////////////// |
80 | 81 |
81 static void r0(SkLayerRasterizer* rast, SkPaint& p) { | 82 static void r0(SkLayerRasterizer* rast, SkPaint& p) { |
82 p.setMaskFilter(SkBlurMaskFilter::Create(SkIntToScalar(3), | 83 p.setMaskFilter(SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle
, |
83 SkBlurMaskFilter::kNormal_BlurStyle
, | 84 SkBlurMask::ConvertRadiusToSigma(Sk
IntToScalar(3)), |
84 SkBlurMaskFilter::kNone_BlurFlag))-
>unref(); | 85 SkBlurMaskFilter::kNone_BlurFlag))-
>unref(); |
85 rast->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); | 86 rast->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); |
86 | 87 |
87 p.setMaskFilter(NULL); | 88 p.setMaskFilter(NULL); |
88 p.setStyle(SkPaint::kStroke_Style); | 89 p.setStyle(SkPaint::kStroke_Style); |
89 p.setStrokeWidth(SK_Scalar1); | 90 p.setStrokeWidth(SK_Scalar1); |
90 rast->addLayer(p); | 91 rast->addLayer(p); |
91 | 92 |
92 p.setAlpha(0x11); | 93 p.setAlpha(0x11); |
93 p.setStyle(SkPaint::kFill_Style); | 94 p.setStyle(SkPaint::kFill_Style); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 SkPaint p; | 249 SkPaint p; |
249 SkLayerRasterizer* rast = new SkLayerRasterizer; | 250 SkLayerRasterizer* rast = new SkLayerRasterizer; |
250 | 251 |
251 p.setAntiAlias(true); | 252 p.setAntiAlias(true); |
252 proc(rast, p); | 253 proc(rast, p); |
253 paint->setRasterizer(rast)->unref(); | 254 paint->setRasterizer(rast)->unref(); |
254 } | 255 } |
255 | 256 |
256 #if 1 | 257 #if 1 |
257 SkScalar dir[] = { SK_Scalar1, SK_Scalar1, SK_Scalar1 }; | 258 SkScalar dir[] = { SK_Scalar1, SK_Scalar1, SK_Scalar1 }; |
258 paint->setMaskFilter(SkBlurMaskFilter::CreateEmboss(dir, | 259 paint->setMaskFilter(SkBlurMaskFilter::CreateEmboss( |
259 SK_Scalar1/4, | 260 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3)), dir, |
260 SkIntToScalar(4), | 261 SK_Scalar1/4, SkIntToScalar(4)))->unref(); |
261 SkIntToScalar(3)))->unre
f(); | |
262 paint->setColor(SK_ColorBLUE); | 262 paint->setColor(SK_ColorBLUE); |
263 #endif | 263 #endif |
264 } | 264 } |
265 | 265 |
266 class DemoView : public SampleView { | 266 class DemoView : public SampleView { |
267 public: | 267 public: |
268 DemoView() {} | 268 DemoView() {} |
269 | 269 |
270 protected: | 270 protected: |
271 // overrides from SkEventSink | 271 // overrides from SkEventSink |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 radialRadius, radialColors, radialPos, radialCount, | 379 radialRadius, radialColors, radialPos, radialCount, |
380 radialMode, radialMapper); | 380 radialMode, radialMapper); |
381 | 381 |
382 SkTransparentShader* transparentShader = new SkTransparentShader(); | 382 SkTransparentShader* transparentShader = new SkTransparentShader(); |
383 SkEmbossMaskFilter::Light light; | 383 SkEmbossMaskFilter::Light light; |
384 light.fDirection[0] = SK_Scalar1/2; | 384 light.fDirection[0] = SK_Scalar1/2; |
385 light.fDirection[1] = SK_Scalar1/2; | 385 light.fDirection[1] = SK_Scalar1/2; |
386 light.fDirection[2] = SK_Scalar1/3; | 386 light.fDirection[2] = SK_Scalar1/3; |
387 light.fAmbient = 0x48; | 387 light.fAmbient = 0x48; |
388 light.fSpecular = 0x80; | 388 light.fSpecular = 0x80; |
389 SkScalar radius = SkIntToScalar(12)/5; | 389 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(12)/5); |
390 SkEmbossMaskFilter* embossFilter = new SkEmbossMaskFilter(light, radius)
; | 390 SkEmbossMaskFilter* embossFilter = new SkEmbossMaskFilter(sigma, light); |
391 | 391 |
392 SkXfermode* xfermode = SkXfermode::Create(SkXfermode::kXor_Mode); | 392 SkXfermode* xfermode = SkXfermode::Create(SkXfermode::kXor_Mode); |
393 SkColorFilter* lightingFilter = SkColorFilter::CreateLightingFilter( | 393 SkColorFilter* lightingFilter = SkColorFilter::CreateLightingFilter( |
394 0xff89bc45, 0xff112233); | 394 0xff89bc45, 0xff112233); |
395 | 395 |
396 canvas->save(); | 396 canvas->save(); |
397 canvas->translate(SkIntToScalar(0), SkIntToScalar(5)); | 397 canvas->translate(SkIntToScalar(0), SkIntToScalar(5)); |
398 paint.setAntiAlias(true); | 398 paint.setAntiAlias(true); |
399 paint.setFilterLevel(SkPaint::kLow_FilterLevel); | 399 paint.setFilterLevel(SkPaint::kLow_FilterLevel); |
400 // !!! draw through a clip | 400 // !!! draw through a clip |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 private: | 641 private: |
642 SkPoint fClickPt; | 642 SkPoint fClickPt; |
643 SkBitmap fBug, fTb, fTx; | 643 SkBitmap fBug, fTb, fTx; |
644 typedef SampleView INHERITED; | 644 typedef SampleView INHERITED; |
645 }; | 645 }; |
646 | 646 |
647 ////////////////////////////////////////////////////////////////////////////// | 647 ////////////////////////////////////////////////////////////////////////////// |
648 | 648 |
649 static SkView* MyFactory() { return new DemoView; } | 649 static SkView* MyFactory() { return new DemoView; } |
650 static SkViewRegister reg(MyFactory); | 650 static SkViewRegister reg(MyFactory); |
OLD | NEW |