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

Side by Side Diff: gm/drawlooper.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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkGraphics.h" 10 #include "SkGraphics.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 SkLayerDrawLooper* fLooper; 55 SkLayerDrawLooper* fLooper;
56 56
57 void init() { 57 void init() {
58 if (fLooper) return; 58 if (fLooper) return;
59 59
60 static const struct { 60 static const struct {
61 SkColor fColor; 61 SkColor fColor;
62 SkPaint::Style fStyle; 62 SkPaint::Style fStyle;
63 SkScalar fWidth; 63 SkScalar fWidth;
64 SkScalar fOffset; 64 SkScalar fOffset;
65 int fBlur; 65 SkScalar fSigma;
66 } gParams[] = { 66 } gParams[] = {
67 { SK_ColorWHITE, SkPaint::kStroke_Style, SkIntToScalar(1)*3/4, 0, 0 }, 67 { SK_ColorWHITE, SkPaint::kStroke_Style, SkIntToScalar(1)*3/4, 0, 0 },
68 { SK_ColorRED, SkPaint::kStroke_Style, SkIntToScalar(4), 0, 0 }, 68 { SK_ColorRED, SkPaint::kStroke_Style, SkIntToScalar(4), 0, 0 },
69 { SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0 }, 69 { SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0 },
70 { 0x88000000, SkPaint::kFill_Style, 0, SkIntToScalar(10), 3 } 70 { 0x88000000, SkPaint::kFill_Style, 0, SkIntToScalar(10), SkFloatToS calar(2.23205f) }
71 }; 71 };
72 72
73 fLooper = new SkLayerDrawLooper; 73 fLooper = new SkLayerDrawLooper;
74 74
75 SkLayerDrawLooper::LayerInfo info; 75 SkLayerDrawLooper::LayerInfo info;
76 info.fFlagsMask = SkPaint::kAntiAlias_Flag; 76 info.fFlagsMask = SkPaint::kAntiAlias_Flag;
77 info.fPaintBits = SkLayerDrawLooper::kStyle_Bit | SkLayerDrawLooper::kMa skFilter_Bit; 77 info.fPaintBits = SkLayerDrawLooper::kStyle_Bit | SkLayerDrawLooper::kMa skFilter_Bit;
78 info.fColorMode = SkXfermode::kSrc_Mode; 78 info.fColorMode = SkXfermode::kSrc_Mode;
79 79
80 for (size_t i = 0; i < SK_ARRAY_COUNT(gParams); i++) { 80 for (size_t i = 0; i < SK_ARRAY_COUNT(gParams); i++) {
81 info.fOffset.set(gParams[i].fOffset, gParams[i].fOffset); 81 info.fOffset.set(gParams[i].fOffset, gParams[i].fOffset);
82 SkPaint* paint = fLooper->addLayer(info); 82 SkPaint* paint = fLooper->addLayer(info);
83 paint->setAntiAlias(true); 83 paint->setAntiAlias(true);
84 paint->setColor(gParams[i].fColor); 84 paint->setColor(gParams[i].fColor);
85 paint->setStyle(gParams[i].fStyle); 85 paint->setStyle(gParams[i].fStyle);
86 paint->setStrokeWidth(gParams[i].fWidth); 86 paint->setStrokeWidth(gParams[i].fWidth);
87 if (gParams[i].fBlur > 0) { 87 if (gParams[i].fSigma > 0) {
88 SkMaskFilter* mf = SkBlurMaskFilter::Create(SkIntToScalar(gParam s[i].fBlur), 88 SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kN ormal_BlurStyle,
89 SkBlurMaskFilter::kN ormal_BlurStyle); 89 gParams[i].fSigma);
90 paint->setMaskFilter(mf)->unref(); 90 paint->setMaskFilter(mf)->unref();
91 } 91 }
92 } 92 }
93 } 93 }
94 94
95 typedef GM INHERITED; 95 typedef GM INHERITED;
96 }; 96 };
97 97
98 ////////////////////////////////////////////////////////////////////////////// 98 //////////////////////////////////////////////////////////////////////////////
99 99
100 static skiagm::GM* MyFactory(void*) { return new DrawLooperGM; } 100 static skiagm::GM* MyFactory(void*) { return new DrawLooperGM; }
101 static skiagm::GMRegistry reg(MyFactory); 101 static skiagm::GMRegistry reg(MyFactory);
OLDNEW
« bench/BlurBench.cpp ('K') | « gm/drawbitmaprect.cpp ('k') | gm/megalooper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698