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