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

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

Issue 134163010: Refactor read and write buffers. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: original write flags were fine Created 6 years, 10 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
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 "SkFlattenableBuffers.h" 10 #include "SkReadBuffer.h"
11 #include "SkWriteBuffer.h"
11 #include "SkLayerDrawLooper.h" 12 #include "SkLayerDrawLooper.h"
12 #include "SkString.h" 13 #include "SkString.h"
13 #include "SkStringUtils.h" 14 #include "SkStringUtils.h"
14 #include "SkUnPreMultiply.h" 15 #include "SkUnPreMultiply.h"
15 16
16 SkLayerDrawLooper::LayerInfo::LayerInfo() { 17 SkLayerDrawLooper::LayerInfo::LayerInfo() {
17 fFlagsMask = 0; // ignore our paint flags 18 fFlagsMask = 0; // ignore our paint flags
18 fPaintBits = 0; // ignore our paint fields 19 fPaintBits = 0; // ignore our paint fields
19 fColorMode = SkXfermode::kDst_Mode; // ignore our color 20 fColorMode = SkXfermode::kDst_Mode; // ignore our color
20 fOffset.set(0, 0); 21 fOffset.set(0, 0);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } else { 185 } else {
185 canvas->translate(fCurrRec->fInfo.fOffset.fX, fCurrRec->fInfo.fOffset.fY ); 186 canvas->translate(fCurrRec->fInfo.fOffset.fX, fCurrRec->fInfo.fOffset.fY );
186 } 187 }
187 fCurrRec = fCurrRec->fNext; 188 fCurrRec = fCurrRec->fNext;
188 189
189 return true; 190 return true;
190 } 191 }
191 192
192 /////////////////////////////////////////////////////////////////////////////// 193 ///////////////////////////////////////////////////////////////////////////////
193 194
194 void SkLayerDrawLooper::flatten(SkFlattenableWriteBuffer& buffer) const { 195 void SkLayerDrawLooper::flatten(SkWriteBuffer& buffer) const {
195 this->INHERITED::flatten(buffer); 196 this->INHERITED::flatten(buffer);
196 197
197 #ifdef SK_DEBUG 198 #ifdef SK_DEBUG
198 { 199 {
199 Rec* rec = fRecs; 200 Rec* rec = fRecs;
200 int count = 0; 201 int count = 0;
201 while (rec) { 202 while (rec) {
202 rec = rec->fNext; 203 rec = rec->fNext;
203 count += 1; 204 count += 1;
204 } 205 }
205 SkASSERT(count == fCount); 206 SkASSERT(count == fCount);
206 } 207 }
207 #endif 208 #endif
208 209
209 buffer.writeInt(fCount); 210 buffer.writeInt(fCount);
210 211
211 Rec* rec = fRecs; 212 Rec* rec = fRecs;
212 for (int i = 0; i < fCount; i++) { 213 for (int i = 0; i < fCount; i++) {
213 buffer.writeInt(rec->fInfo.fFlagsMask); 214 buffer.writeInt(rec->fInfo.fFlagsMask);
214 buffer.writeInt(rec->fInfo.fPaintBits); 215 buffer.writeInt(rec->fInfo.fPaintBits);
215 buffer.writeInt(rec->fInfo.fColorMode); 216 buffer.writeInt(rec->fInfo.fColorMode);
216 buffer.writePoint(rec->fInfo.fOffset); 217 buffer.writePoint(rec->fInfo.fOffset);
217 buffer.writeBool(rec->fInfo.fPostTranslate); 218 buffer.writeBool(rec->fInfo.fPostTranslate);
218 buffer.writePaint(rec->fPaint); 219 buffer.writePaint(rec->fPaint);
219 rec = rec->fNext; 220 rec = rec->fNext;
220 } 221 }
221 } 222 }
222 223
223 SkLayerDrawLooper::SkLayerDrawLooper(SkFlattenableReadBuffer& buffer) 224 SkLayerDrawLooper::SkLayerDrawLooper(SkReadBuffer& buffer)
224 : INHERITED(buffer), 225 : INHERITED(buffer),
225 fRecs(NULL), 226 fRecs(NULL),
226 fTopRec(NULL), 227 fTopRec(NULL),
227 fCount(0), 228 fCount(0),
228 fCurrRec(NULL) { 229 fCurrRec(NULL) {
229 int count = buffer.readInt(); 230 int count = buffer.readInt();
230 231
231 for (int i = 0; i < count; i++) { 232 for (int i = 0; i < count; i++) {
232 LayerInfo info; 233 LayerInfo info;
233 info.fFlagsMask = buffer.readInt(); 234 info.fFlagsMask = buffer.readInt();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 str->append("true "); 340 str->append("true ");
340 } else { 341 } else {
341 str->append("false "); 342 str->append("false ");
342 } 343 }
343 344
344 rec->fPaint.toString(str); 345 rec->fPaint.toString(str);
345 rec = rec->fNext; 346 rec = rec->fNext;
346 } 347 }
347 } 348 }
348 #endif 349 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698