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

Side by Side Diff: gm/blurs.cpp

Issue 23701006: Push sigma-based blur interface into our GMs/benches/tests/samplecode (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Cleaned up 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
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 "gm.h" 8 #include "gm.h"
9 #include "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 paint.setAntiAlias(true); 52 paint.setAntiAlias(true);
53 paint.setTextSize(SkIntToScalar(25)); 53 paint.setTextSize(SkIntToScalar(25));
54 canvas->translate(SkIntToScalar(-40), SkIntToScalar(0)); 54 canvas->translate(SkIntToScalar(-40), SkIntToScalar(0));
55 55
56 SkBlurMaskFilter::BlurFlags flags = SkBlurMaskFilter::kNone_BlurFlag; 56 SkBlurMaskFilter::BlurFlags flags = SkBlurMaskFilter::kNone_BlurFlag;
57 for (int j = 0; j < 2; j++) { 57 for (int j = 0; j < 2; j++) {
58 canvas->save(); 58 canvas->save();
59 paint.setColor(SK_ColorBLUE); 59 paint.setColor(SK_ColorBLUE);
60 for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) { 60 for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) {
61 if (gRecs[i].fStyle != NONE) { 61 if (gRecs[i].fStyle != NONE) {
62 SkMaskFilter* mf = SkBlurMaskFilter::Create( 62 SkMaskFilter* mf = SkBlurMaskFilter::Create(gRecs[i].fStyle,
63 SkIntToScalar(20), gRecs[i].fStyle, flags); 63 SkFloatToScalar( 12.047f),
64 flags);
64 paint.setMaskFilter(mf)->unref(); 65 paint.setMaskFilter(mf)->unref();
65 } else { 66 } else {
66 paint.setMaskFilter(NULL); 67 paint.setMaskFilter(NULL);
67 } 68 }
68 canvas->drawCircle(SkIntToScalar(200 + gRecs[i].fCx*100), 69 canvas->drawCircle(SkIntToScalar(200 + gRecs[i].fCx*100),
69 SkIntToScalar(200 + gRecs[i].fCy*100), 70 SkIntToScalar(200 + gRecs[i].fCy*100),
70 SkIntToScalar(50), 71 SkIntToScalar(50),
71 paint); 72 paint);
72 } 73 }
73 // draw text 74 // draw text
74 { 75 {
75 SkMaskFilter* mf = SkBlurMaskFilter::Create( 76 SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kN ormal_BlurStyle,
76 SkIntToScalar(4), 77 SkFloatToScalar(2.80 94f),
77 SkBlurMaskFilter::kNormal_BlurStyle, 78 flags);
78 flags);
79 paint.setMaskFilter(mf)->unref(); 79 paint.setMaskFilter(mf)->unref();
80 SkScalar x = SkIntToScalar(70); 80 SkScalar x = SkIntToScalar(70);
81 SkScalar y = SkIntToScalar(400); 81 SkScalar y = SkIntToScalar(400);
82 paint.setColor(SK_ColorBLACK); 82 paint.setColor(SK_ColorBLACK);
83 canvas->drawText("Hamburgefons Style", 18, x, y, paint); 83 canvas->drawText("Hamburgefons Style", 18, x, y, paint);
84 canvas->drawText("Hamburgefons Style", 18, 84 canvas->drawText("Hamburgefons Style", 18,
85 x, y + SkIntToScalar(50), paint); 85 x, y + SkIntToScalar(50), paint);
86 paint.setMaskFilter(NULL); 86 paint.setMaskFilter(NULL);
87 paint.setColor(SK_ColorWHITE); 87 paint.setColor(SK_ColorWHITE);
88 x -= SkIntToScalar(2); 88 x -= SkIntToScalar(2);
89 y -= SkIntToScalar(2); 89 y -= SkIntToScalar(2);
90 canvas->drawText("Hamburgefons Style", 18, x, y, paint); 90 canvas->drawText("Hamburgefons Style", 18, x, y, paint);
91 } 91 }
92 canvas->restore(); 92 canvas->restore();
93 flags = SkBlurMaskFilter::kHighQuality_BlurFlag; 93 flags = SkBlurMaskFilter::kHighQuality_BlurFlag;
94 canvas->translate(SkIntToScalar(350), SkIntToScalar(0)); 94 canvas->translate(SkIntToScalar(350), SkIntToScalar(0));
95 } 95 }
96 } 96 }
97 97
98 private: 98 private:
99 typedef GM INHERITED; 99 typedef GM INHERITED;
100 }; 100 };
101 101
102 ////////////////////////////////////////////////////////////////////////////// 102 //////////////////////////////////////////////////////////////////////////////
103 103
104 static GM* MyFactory(void*) { return new BlursGM; } 104 static GM* MyFactory(void*) { return new BlursGM; }
105 static GMRegistry reg(MyFactory); 105 static GMRegistry reg(MyFactory);
106 106
107 } 107 }
OLDNEW
« bench/BlurBench.cpp ('K') | « gm/blurrect.cpp ('k') | gm/circles.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698