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

Side by Side Diff: src/effects/SkLayerDrawLooper.cpp

Issue 180483004: remove SK_SUPPORT_LEGACY_LAYERDRAWLOOPER_PAINTFLAGS -- not needed (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkColor.h" 9 #include "SkColor.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
11 #include "SkWriteBuffer.h" 11 #include "SkWriteBuffer.h"
12 #include "SkLayerDrawLooper.h" 12 #include "SkLayerDrawLooper.h"
13 #include "SkString.h" 13 #include "SkString.h"
14 #include "SkStringUtils.h" 14 #include "SkStringUtils.h"
15 #include "SkUnPreMultiply.h" 15 #include "SkUnPreMultiply.h"
16 16
17 SkLayerDrawLooper::LayerInfo::LayerInfo() { 17 SkLayerDrawLooper::LayerInfo::LayerInfo() {
18 #ifdef SK_SUPPORT_LEGACY_LAYERDRAWLOOPER_PAINTFLAGS
19 fFlagsMask = 0; // ignore layerinfo's paint flags
20 #endif
21 fPaintBits = 0; // ignore our paint fields 18 fPaintBits = 0; // ignore our paint fields
22 fColorMode = SkXfermode::kDst_Mode; // ignore our color 19 fColorMode = SkXfermode::kDst_Mode; // ignore our color
23 fOffset.set(0, 0); 20 fOffset.set(0, 0);
24 fPostTranslate = false; 21 fPostTranslate = false;
25 } 22 }
26 23
27 SkLayerDrawLooper::SkLayerDrawLooper() 24 SkLayerDrawLooper::SkLayerDrawLooper()
28 : fRecs(NULL), 25 : fRecs(NULL),
29 fTopRec(NULL), 26 fTopRec(NULL),
30 fCount(0), 27 fCount(0),
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 94 }
98 } 95 }
99 } 96 }
100 97
101 // Even with kEntirePaint_Bits, we always ensure that the master paint's 98 // Even with kEntirePaint_Bits, we always ensure that the master paint's
102 // text-encoding is respected, since that controls how we interpret the 99 // text-encoding is respected, since that controls how we interpret the
103 // text/length parameters of a draw[Pos]Text call. 100 // text/length parameters of a draw[Pos]Text call.
104 void SkLayerDrawLooper::ApplyInfo(SkPaint* dst, const SkPaint& src, 101 void SkLayerDrawLooper::ApplyInfo(SkPaint* dst, const SkPaint& src,
105 const LayerInfo& info) { 102 const LayerInfo& info) {
106 103
107 #ifdef SK_SUPPORT_LEGACY_LAYERDRAWLOOPER_PAINTFLAGS
108 uint32_t mask = info.fFlagsMask;
109 dst->setFlags((dst->getFlags() & ~mask) | (src.getFlags() & mask));
110 #endif
111 dst->setColor(xferColor(src.getColor(), dst->getColor(), info.fColorMode)); 104 dst->setColor(xferColor(src.getColor(), dst->getColor(), info.fColorMode));
112 105
113 BitFlags bits = info.fPaintBits; 106 BitFlags bits = info.fPaintBits;
114 SkPaint::TextEncoding encoding = dst->getTextEncoding(); 107 SkPaint::TextEncoding encoding = dst->getTextEncoding();
115 108
116 if (0 == bits) { 109 if (0 == bits) {
117 return; 110 return;
118 } 111 }
119 if (kEntirePaint_Bits == bits) { 112 if (kEntirePaint_Bits == bits) {
120 // we've already computed these, so save it from the assignment 113 // we've already computed these, so save it from the assignment
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 count += 1; 201 count += 1;
209 } 202 }
210 SkASSERT(count == fCount); 203 SkASSERT(count == fCount);
211 } 204 }
212 #endif 205 #endif
213 206
214 buffer.writeInt(fCount); 207 buffer.writeInt(fCount);
215 208
216 Rec* rec = fRecs; 209 Rec* rec = fRecs;
217 for (int i = 0; i < fCount; i++) { 210 for (int i = 0; i < fCount; i++) {
218 #ifdef SK_SUPPORT_LEGACY_LAYERDRAWLOOPER_PAINTFLAGS 211 // Legacy "flagsmask" field -- now ignored, remove when we bump version
219 buffer.writeInt(rec->fInfo.fFlagsMask); 212 buffer.writeInt(0);
220 #else 213
221 buffer.writeInt(0); // remove eventually, when we can bump the version
222 #endif
223 buffer.writeInt(rec->fInfo.fPaintBits); 214 buffer.writeInt(rec->fInfo.fPaintBits);
224 buffer.writeInt(rec->fInfo.fColorMode); 215 buffer.writeInt(rec->fInfo.fColorMode);
225 buffer.writePoint(rec->fInfo.fOffset); 216 buffer.writePoint(rec->fInfo.fOffset);
226 buffer.writeBool(rec->fInfo.fPostTranslate); 217 buffer.writeBool(rec->fInfo.fPostTranslate);
227 buffer.writePaint(rec->fPaint); 218 buffer.writePaint(rec->fPaint);
228 rec = rec->fNext; 219 rec = rec->fNext;
229 } 220 }
230 } 221 }
231 222
232 SkFlattenable* SkLayerDrawLooper::CreateProc(SkReadBuffer& buffer) { 223 SkFlattenable* SkLayerDrawLooper::CreateProc(SkReadBuffer& buffer) {
233 int count = buffer.readInt(); 224 int count = buffer.readInt();
234 225
235 Builder builder; 226 Builder builder;
236 for (int i = 0; i < count; i++) { 227 for (int i = 0; i < count; i++) {
237 LayerInfo info; 228 LayerInfo info;
238 #ifdef SK_SUPPORT_LEGACY_LAYERDRAWLOOPER_PAINTFLAGS 229 // Legacy "flagsmask" field -- now ignored, remove when we bump version
239 info.fFlagsMask = buffer.readInt();
240 #else
241 (void)buffer.readInt(); 230 (void)buffer.readInt();
242 #endif 231
243 info.fPaintBits = buffer.readInt(); 232 info.fPaintBits = buffer.readInt();
244 info.fColorMode = (SkXfermode::Mode)buffer.readInt(); 233 info.fColorMode = (SkXfermode::Mode)buffer.readInt();
245 buffer.readPoint(&info.fOffset); 234 buffer.readPoint(&info.fOffset);
246 info.fPostTranslate = buffer.readBool(); 235 info.fPostTranslate = buffer.readBool();
247 buffer.readPaint(builder.addLayerOnTop(info)); 236 buffer.readPaint(builder.addLayerOnTop(info));
248 } 237 }
249 SkLayerDrawLooper* looper = builder.detachLooper(); 238 SkLayerDrawLooper* looper = builder.detachLooper();
250 SkASSERT(count == looper->fCount); 239 SkASSERT(count == looper->fCount);
251 240
252 #ifdef SK_DEBUG 241 #ifdef SK_DEBUG
(...skipping 10 matching lines...) Expand all
263 252
264 return looper; 253 return looper;
265 } 254 }
266 255
267 #ifdef SK_DEVELOPER 256 #ifdef SK_DEVELOPER
268 void SkLayerDrawLooper::toString(SkString* str) const { 257 void SkLayerDrawLooper::toString(SkString* str) const {
269 str->appendf("SkLayerDrawLooper (%d): ", fCount); 258 str->appendf("SkLayerDrawLooper (%d): ", fCount);
270 259
271 Rec* rec = fRecs; 260 Rec* rec = fRecs;
272 for (int i = 0; i < fCount; i++) { 261 for (int i = 0; i < fCount; i++) {
273 str->appendf("%d: ", i); 262 str->appendf("%d: paintBits: (", i);
274
275 #ifdef SK_SUPPORT_LEGACY_LAYERDRAWLOOPER_PAINTFLAGS
276 str->append("flagsMask: (");
277 if (0 == rec->fInfo.fFlagsMask) {
278 str->append("None");
279 } else {
280 bool needSeparator = false;
281 SkAddFlagToString(str, SkToBool(SkPaint::kAntiAlias_Flag & rec->fInf o.fFlagsMask),
282 "AntiAlias", &needSeparator);
283 // SkAddFlagToString(str, SkToBool(SkPaint::kFilterBitmap_Flag & rec- >fInfo.fFlagsMask), "FilterBitmap", &needSeparator);
284 SkAddFlagToString(str, SkToBool(SkPaint::kDither_Flag & rec->fInfo.f FlagsMask),
285 "Dither", &needSeparator);
286 SkAddFlagToString(str, SkToBool(SkPaint::kUnderlineText_Flag & rec-> fInfo.fFlagsMask),
287 "UnderlineText", &needSeparator);
288 SkAddFlagToString(str, SkToBool(SkPaint::kStrikeThruText_Flag & rec- >fInfo.fFlagsMask),
289 "StrikeThruText", &needSeparator);
290 SkAddFlagToString(str, SkToBool(SkPaint::kFakeBoldText_Flag & rec->f Info.fFlagsMask),
291 "FakeBoldText", &needSeparator);
292 SkAddFlagToString(str, SkToBool(SkPaint::kLinearText_Flag & rec->fIn fo.fFlagsMask),
293 "LinearText", &needSeparator);
294 SkAddFlagToString(str, SkToBool(SkPaint::kSubpixelText_Flag & rec->f Info.fFlagsMask),
295 "SubpixelText", &needSeparator);
296 SkAddFlagToString(str, SkToBool(SkPaint::kDevKernText_Flag & rec->fI nfo.fFlagsMask),
297 "DevKernText", &needSeparator);
298 SkAddFlagToString(str, SkToBool(SkPaint::kLCDRenderText_Flag & rec-> fInfo.fFlagsMask),
299 "LCDRenderText", &needSeparator);
300 SkAddFlagToString(str, SkToBool(SkPaint::kEmbeddedBitmapText_Flag & rec->fInfo.fFlagsMask),
301 "EmbeddedBitmapText", &needSeparator);
302 SkAddFlagToString(str, SkToBool(SkPaint::kAutoHinting_Flag & rec->fI nfo.fFlagsMask),
303 "Autohinted", &needSeparator);
304 SkAddFlagToString(str, SkToBool(SkPaint::kVerticalText_Flag & rec->f Info.fFlagsMask),
305 "VerticalText", &needSeparator);
306 SkAddFlagToString(str, SkToBool(SkPaint::kGenA8FromLCD_Flag & rec->f Info.fFlagsMask),
307 "GenA8FromLCD", &needSeparator);
308 }
309 #endif
310 str->append(") ");
311
312 str->append("paintBits: (");
313 if (0 == rec->fInfo.fPaintBits) { 263 if (0 == rec->fInfo.fPaintBits) {
314 str->append("None"); 264 str->append("None");
315 } else if (kEntirePaint_Bits == rec->fInfo.fPaintBits) { 265 } else if (kEntirePaint_Bits == rec->fInfo.fPaintBits) {
316 str->append("EntirePaint"); 266 str->append("EntirePaint");
317 } else { 267 } else {
318 bool needSeparator = false; 268 bool needSeparator = false;
319 SkAddFlagToString(str, SkToBool(kStyle_Bit & rec->fInfo.fPaintBits), "Style", 269 SkAddFlagToString(str, SkToBool(kStyle_Bit & rec->fInfo.fPaintBits), "Style",
320 &needSeparator); 270 &needSeparator);
321 SkAddFlagToString(str, SkToBool(kTextSkewX_Bit & rec->fInfo.fPaintBi ts), "TextSkewX", 271 SkAddFlagToString(str, SkToBool(kTextSkewX_Bit & rec->fInfo.fPaintBi ts), "TextSkewX",
322 &needSeparator); 272 &needSeparator);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 SkLayerDrawLooper* looper = SkNEW(SkLayerDrawLooper); 368 SkLayerDrawLooper* looper = SkNEW(SkLayerDrawLooper);
419 looper->fCount = fCount; 369 looper->fCount = fCount;
420 looper->fRecs = fRecs; 370 looper->fRecs = fRecs;
421 371
422 fCount = 0; 372 fCount = 0;
423 fRecs = NULL; 373 fRecs = NULL;
424 fTopRec = NULL; 374 fTopRec = NULL;
425 375
426 return looper; 376 return looper;
427 } 377 }
OLDNEW
« include/effects/SkLayerDrawLooper.h ('K') | « include/effects/SkLayerDrawLooper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698