Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Side by Side Diff: samplecode/SampleAll.cpp

Issue 21835004: Blur refactoring (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Removed unneeded #includes Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/effects/SkEmbossMaskFilter.h ('k') | samplecode/SampleXfermodesBlur.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(SkIntToScalar(3),
83 SkBlurMaskFilter::kNormal_BlurStyle ))->unref(); 83 SkBlurMaskFilter::kNormal_BlurStyle ,
84 SkBlurMaskFilter::kNone_BlurFlag))- >unref();
84 rast->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); 85 rast->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
85 86
86 p.setMaskFilter(NULL); 87 p.setMaskFilter(NULL);
87 p.setStyle(SkPaint::kStroke_Style); 88 p.setStyle(SkPaint::kStroke_Style);
88 p.setStrokeWidth(SK_Scalar1); 89 p.setStrokeWidth(SK_Scalar1);
89 rast->addLayer(p); 90 rast->addLayer(p);
90 91
91 p.setAlpha(0x11); 92 p.setAlpha(0x11);
92 p.setStyle(SkPaint::kFill_Style); 93 p.setStyle(SkPaint::kFill_Style);
93 p.setXfermodeMode(SkXfermode::kSrc_Mode); 94 p.setXfermodeMode(SkXfermode::kSrc_Mode);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 SkPaint p; 248 SkPaint p;
248 SkLayerRasterizer* rast = new SkLayerRasterizer; 249 SkLayerRasterizer* rast = new SkLayerRasterizer;
249 250
250 p.setAntiAlias(true); 251 p.setAntiAlias(true);
251 proc(rast, p); 252 proc(rast, p);
252 paint->setRasterizer(rast)->unref(); 253 paint->setRasterizer(rast)->unref();
253 } 254 }
254 255
255 #if 1 256 #if 1
256 SkScalar dir[] = { SK_Scalar1, SK_Scalar1, SK_Scalar1 }; 257 SkScalar dir[] = { SK_Scalar1, SK_Scalar1, SK_Scalar1 };
257 paint->setMaskFilter(SkBlurMaskFilter::CreateEmboss(dir, SK_Scalar1/4, SkInt ToScalar(4), SkIntToScalar(3)))->unref(); 258 paint->setMaskFilter(SkBlurMaskFilter::CreateEmboss(dir,
259 SK_Scalar1/4,
260 SkIntToScalar(4),
261 SkIntToScalar(3)))->unre f();
258 paint->setColor(SK_ColorBLUE); 262 paint->setColor(SK_ColorBLUE);
259 #endif 263 #endif
260 } 264 }
261 265
262 class DemoView : public SampleView { 266 class DemoView : public SampleView {
263 public: 267 public:
264 DemoView() {} 268 DemoView() {}
265 269
266 protected: 270 protected:
267 // overrides from SkEventSink 271 // overrides from SkEventSink
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 radialMode, radialMapper); 380 radialMode, radialMapper);
377 381
378 SkTransparentShader* transparentShader = new SkTransparentShader(); 382 SkTransparentShader* transparentShader = new SkTransparentShader();
379 SkEmbossMaskFilter::Light light; 383 SkEmbossMaskFilter::Light light;
380 light.fDirection[0] = SK_Scalar1/2; 384 light.fDirection[0] = SK_Scalar1/2;
381 light.fDirection[1] = SK_Scalar1/2; 385 light.fDirection[1] = SK_Scalar1/2;
382 light.fDirection[2] = SK_Scalar1/3; 386 light.fDirection[2] = SK_Scalar1/3;
383 light.fAmbient = 0x48; 387 light.fAmbient = 0x48;
384 light.fSpecular = 0x80; 388 light.fSpecular = 0x80;
385 SkScalar radius = SkIntToScalar(12)/5; 389 SkScalar radius = SkIntToScalar(12)/5;
386 SkEmbossMaskFilter* embossFilter = new SkEmbossMaskFilter(light, 390 SkEmbossMaskFilter* embossFilter = new SkEmbossMaskFilter(light, radius) ;
387 radius);
388 391
389 SkXfermode* xfermode = SkXfermode::Create(SkXfermode::kXor_Mode); 392 SkXfermode* xfermode = SkXfermode::Create(SkXfermode::kXor_Mode);
390 SkColorFilter* lightingFilter = SkColorFilter::CreateLightingFilter( 393 SkColorFilter* lightingFilter = SkColorFilter::CreateLightingFilter(
391 0xff89bc45, 0xff112233); 394 0xff89bc45, 0xff112233);
392 395
393 canvas->save(); 396 canvas->save();
394 canvas->translate(SkIntToScalar(0), SkIntToScalar(5)); 397 canvas->translate(SkIntToScalar(0), SkIntToScalar(5));
395 paint.setAntiAlias(true); 398 paint.setAntiAlias(true);
396 paint.setFilterLevel(SkPaint::kLow_FilterLevel); 399 paint.setFilterLevel(SkPaint::kLow_FilterLevel);
397 // !!! draw through a clip 400 // !!! draw through a clip
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 private: 641 private:
639 SkPoint fClickPt; 642 SkPoint fClickPt;
640 SkBitmap fBug, fTb, fTx; 643 SkBitmap fBug, fTb, fTx;
641 typedef SampleView INHERITED; 644 typedef SampleView INHERITED;
642 }; 645 };
643 646
644 ////////////////////////////////////////////////////////////////////////////// 647 //////////////////////////////////////////////////////////////////////////////
645 648
646 static SkView* MyFactory() { return new DemoView; } 649 static SkView* MyFactory() { return new DemoView; }
647 static SkViewRegister reg(MyFactory); 650 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « include/effects/SkEmbossMaskFilter.h ('k') | samplecode/SampleXfermodesBlur.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698