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

Side by Side Diff: gm/textbloblooper.cpp

Issue 2396953002: Revert[8] "replace SkXfermode obj with SkBlendMode enum in paints" (Closed)
Patch Set: add tmp virtual to unroll legacy arithmodes Created 4 years, 2 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
« no previous file with comments | « gm/textblobblockreordering.cpp ('k') | gm/texteffects.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 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 9
10 #include "Sk2DPathEffect.h" 10 #include "Sk2DPathEffect.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 45 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
46 const SkTextBlobBuilder::RunBuffer& run = builder->allocRunPos(paint, glyphs .count()); 46 const SkTextBlobBuilder::RunBuffer& run = builder->allocRunPos(paint, glyphs .count());
47 memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t)); 47 memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t));
48 memcpy(run.pos, pos.begin(), len * sizeof(SkScalar) * 2); 48 memcpy(run.pos, pos.begin(), len * sizeof(SkScalar) * 2);
49 } 49 }
50 50
51 typedef void (*LooperProc)(SkPaint*); 51 typedef void (*LooperProc)(SkPaint*);
52 52
53 struct LooperSettings { 53 struct LooperSettings {
54 SkXfermode::Mode fMode; 54 SkBlendMode fMode;
55 SkColor fColor; 55 SkColor fColor;
56 SkPaint::Style fStyle; 56 SkPaint::Style fStyle;
57 SkScalar fWidth; 57 SkScalar fWidth;
58 SkScalar fOffset; 58 SkScalar fOffset;
59 SkScalar fSkewX; 59 SkScalar fSkewX;
60 bool fEffect; 60 bool fEffect;
61 }; 61 };
62 62
63 static void mask_filter(SkPaint* paint) { 63 static void mask_filter(SkPaint* paint) {
64 paint->setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 64 paint->setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 SkLayerDrawLooper::Builder looperBuilder; 113 SkLayerDrawLooper::Builder looperBuilder;
114 114
115 SkLayerDrawLooper::LayerInfo info; 115 SkLayerDrawLooper::LayerInfo info;
116 info.fPaintBits = bits; 116 info.fPaintBits = bits;
117 117
118 info.fColorMode = SkXfermode::kSrc_Mode; 118 info.fColorMode = SkXfermode::kSrc_Mode;
119 119
120 for (size_t i = 0; i < size; i++) { 120 for (size_t i = 0; i < size; i++) {
121 info.fOffset.set(settings[i].fOffset, settings[i].fOffset); 121 info.fOffset.set(settings[i].fOffset, settings[i].fOffset);
122 SkPaint* paint = looperBuilder.addLayer(info); 122 SkPaint* paint = looperBuilder.addLayer(info);
123 paint->setXfermodeMode(settings[i].fMode); 123 paint->setBlendMode(settings[i].fMode);
124 paint->setColor(settings[i].fColor); 124 paint->setColor(settings[i].fColor);
125 paint->setStyle(settings[i].fStyle); 125 paint->setStyle(settings[i].fStyle);
126 paint->setStrokeWidth(settings[i].fWidth); 126 paint->setStrokeWidth(settings[i].fWidth);
127 if (settings[i].fEffect) { 127 if (settings[i].fEffect) {
128 (*proc)(paint); 128 (*proc)(paint);
129 } 129 }
130 } 130 }
131 return looperBuilder.detach(); 131 return looperBuilder.detach();
132 } 132 }
133 133
(...skipping 11 matching lines...) Expand all
145 const char* text = "The quick brown fox jumps over the lazy dog"; 145 const char* text = "The quick brown fox jumps over the lazy dog";
146 paint.setSubpixelText(true); 146 paint.setSubpixelText(true);
147 paint.setLCDRenderText(true); 147 paint.setLCDRenderText(true);
148 paint.setAntiAlias(true); 148 paint.setAntiAlias(true);
149 sk_tool_utils::set_portable_typeface(&paint); 149 sk_tool_utils::set_portable_typeface(&paint);
150 add_to_text_blob(&builder, text, paint, 0, 0); 150 add_to_text_blob(&builder, text, paint, 0, 0);
151 fBlob = builder.make(); 151 fBlob = builder.make();
152 152
153 // create a looper which sandwhiches an effect in two normal draws 153 // create a looper which sandwhiches an effect in two normal draws
154 LooperSettings looperSandwhich[] = { 154 LooperSettings looperSandwhich[] = {
155 { SkXfermode::kSrc_Mode, SK_ColorMAGENTA, SkPaint::kFill_Style, 0, 0, 0, false }, 155 { SkBlendMode::kSrc, SK_ColorMAGENTA, SkPaint::kFill_Style, 0, 0, 0, false },
156 { SkXfermode::kSrcOver_Mode, 0x88000000, SkPaint::kFill_Style, 0, 10. f, 0, true }, 156 { SkBlendMode::kSrcOver, 0x88000000, SkPaint::kFill_Style, 0, 10.f, 0 , true },
157 { SkXfermode::kSrcOver_Mode, 0x50FF00FF, SkPaint::kFill_Style, 0, 20. f, 0, false }, 157 { SkBlendMode::kSrcOver, 0x50FF00FF, SkPaint::kFill_Style, 0, 20.f, 0 , false },
158 }; 158 };
159 159
160 LooperSettings compound[] = { 160 LooperSettings compound[] = {
161 { SkXfermode::kSrc_Mode, SK_ColorWHITE, SkPaint::kStroke_Style, 1.f * 3/4, 0, 0, false }, 161 { SkBlendMode::kSrc, SK_ColorWHITE, SkPaint::kStroke_Style, 1.f * 3/ 4, 0, 0, false },
162 { SkXfermode::kSrc_Mode, SK_ColorRED, SkPaint::kStroke_Style, 4.f, 0 , 0, false }, 162 { SkBlendMode::kSrc, SK_ColorRED, SkPaint::kStroke_Style, 4.f, 0, 0, false },
163 { SkXfermode::kSrc_Mode, SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0 , false }, 163 { SkBlendMode::kSrc, SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0, fa lse },
164 { SkXfermode::kSrcOver_Mode, 0x88000000, SkPaint::kFill_Style, 0, 10 .f, 0, true } 164 { SkBlendMode::kSrcOver, 0x88000000, SkPaint::kFill_Style, 0, 10.f, 0, true }
165 }; 165 };
166 166
167 LooperSettings xfermode[] = { 167 LooperSettings xfermode[] = {
168 { SkXfermode::kDifference_Mode, SK_ColorWHITE, SkPaint::kFill_Style, 0, 0, 0, false }, 168 { SkBlendMode::kDifference, SK_ColorWHITE, SkPaint::kFill_Style, 0, 0, 0, false },
169 { SkXfermode::kSrcOver_Mode, 0xFF000000, SkPaint::kFill_Style, 0, 1. f, 0, true }, 169 { SkBlendMode::kSrcOver, 0xFF000000, SkPaint::kFill_Style, 0, 1.f, 0 , true },
170 { SkXfermode::kSrcOver_Mode, 0x50FF00FF, SkPaint::kFill_Style, 0, 2. f, 0, false }, 170 { SkBlendMode::kSrcOver, 0x50FF00FF, SkPaint::kFill_Style, 0, 2.f, 0 , false },
171 }; 171 };
172 172
173 // NOTE, this should be ignored by textblobs 173 // NOTE, this should be ignored by textblobs
174 LooperSettings skew[] = { 174 LooperSettings skew[] = {
175 { SkXfermode::kSrc_Mode, SK_ColorRED, SkPaint::kFill_Style, 0, 0, -1 .f, false }, 175 { SkBlendMode::kSrc, SK_ColorRED, SkPaint::kFill_Style, 0, 0, -1.f, false },
176 { SkXfermode::kSrc_Mode, SK_ColorGREEN, SkPaint::kFill_Style, 0, 10. f, -1.f, false }, 176 { SkBlendMode::kSrc, SK_ColorGREEN, SkPaint::kFill_Style, 0, 10.f, - 1.f, false },
177 { SkXfermode::kSrc_Mode, SK_ColorBLUE, SkPaint::kFill_Style, 0, 20.f , -1.f, false }, 177 { SkBlendMode::kSrc, SK_ColorBLUE, SkPaint::kFill_Style, 0, 20.f, -1 .f, false },
178 }; 178 };
179 179
180 LooperSettings kitchenSink[] = { 180 LooperSettings kitchenSink[] = {
181 { SkXfermode::kSrc_Mode, SK_ColorWHITE, SkPaint::kStroke_Style, 1.f * 3/4, 0, 0, false }, 181 { SkBlendMode::kSrc, SK_ColorWHITE, SkPaint::kStroke_Style, 1.f * 3/ 4, 0, 0, false },
182 { SkXfermode::kSrc_Mode, SK_ColorBLACK, SkPaint::kFill_Style, 0, 0, 0, false }, 182 { SkBlendMode::kSrc, SK_ColorBLACK, SkPaint::kFill_Style, 0, 0, 0, f alse },
183 { SkXfermode::kDifference_Mode, SK_ColorWHITE, SkPaint::kFill_Style, 1.f, 10.f, 0, false }, 183 { SkBlendMode::kDifference, SK_ColorWHITE, SkPaint::kFill_Style, 1.f , 10.f, 0, false },
184 { SkXfermode::kSrc_Mode, SK_ColorWHITE, SkPaint::kFill_Style, 0, 10. f, 0, true }, 184 { SkBlendMode::kSrc, SK_ColorWHITE, SkPaint::kFill_Style, 0, 10.f, 0 , true },
185 { SkXfermode::kSrcOver_Mode, 0x50FF00FF, SkPaint::kFill_Style, 0, 20 .f, 0, false }, 185 { SkBlendMode::kSrcOver, 0x50FF00FF, SkPaint::kFill_Style, 0, 20.f, 0, false },
186 }; 186 };
187 187
188 fLoopers.push_back(setupLooper(SkLayerDrawLooper::kMaskFilter_Bit | 188 fLoopers.push_back(setupLooper(SkLayerDrawLooper::kMaskFilter_Bit |
189 SkLayerDrawLooper::kXfermode_Bit | 189 SkLayerDrawLooper::kXfermode_Bit |
190 SkLayerDrawLooper::kStyle_Bit, &mask_filt er, 190 SkLayerDrawLooper::kStyle_Bit, &mask_filt er,
191 compound, SK_ARRAY_COUNT(compound))); 191 compound, SK_ARRAY_COUNT(compound)));
192 fLoopers.push_back(setupLooper(SkLayerDrawLooper::kPathEffect_Bit | 192 fLoopers.push_back(setupLooper(SkLayerDrawLooper::kPathEffect_Bit |
193 SkLayerDrawLooper::kXfermode_Bit, &path_e ffect, 193 SkLayerDrawLooper::kXfermode_Bit, &path_e ffect,
194 looperSandwhich, SK_ARRAY_COUNT(looperSan dwhich))); 194 looperSandwhich, SK_ARRAY_COUNT(looperSan dwhich)));
195 fLoopers.push_back(setupLooper(SkLayerDrawLooper::kShader_Bit | 195 fLoopers.push_back(setupLooper(SkLayerDrawLooper::kShader_Bit |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 sk_sp<SkTextBlob> fBlob; 248 sk_sp<SkTextBlob> fBlob;
249 SkTArray<sk_sp<SkDrawLooper>, true> fLoopers; 249 SkTArray<sk_sp<SkDrawLooper>, true> fLoopers;
250 250
251 typedef GM INHERITED; 251 typedef GM INHERITED;
252 }; 252 };
253 253
254 ////////////////////////////////////////////////////////////////////////////// 254 //////////////////////////////////////////////////////////////////////////////
255 255
256 DEF_GM(return new TextBlobLooperGM;) 256 DEF_GM(return new TextBlobLooperGM;)
257 } 257 }
OLDNEW
« no previous file with comments | « gm/textblobblockreordering.cpp ('k') | gm/texteffects.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698