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

Side by Side Diff: src/core/SkPicturePlayback.cpp

Issue 377623002: Split SkPicturePlayback out of SkPictureData (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add virtual dtor for SkPicturePlayback Created 6 years, 5 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 | « src/core/SkPicturePlayback.h ('k') | src/gpu/GrPictureUtils.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkCanvas.h"
9 #include "SkPictureData.h"
10 #include "SkPicturePlayback.h"
11 #include "SkPictureRecord.h"
12 #include "SkPictureStateTree.h"
13 #include "SkReader32.h"
14 #include "SkTDArray.h"
15 #include "SkTypes.h"
16
17 SkPicturePlayback::PlaybackReplacements::ReplacementInfo*
18 SkPicturePlayback::PlaybackReplacements::push() {
19 SkDEBUGCODE(this->validate());
20 return fReplacements.push();
21 }
22
23 void SkPicturePlayback::PlaybackReplacements::freeAll() {
24 for (int i = 0; i < fReplacements.count(); ++i) {
25 SkDELETE(fReplacements[i].fBM);
26 }
27 fReplacements.reset();
28 }
29
30 #ifdef SK_DEBUG
31 void SkPicturePlayback::PlaybackReplacements::validate() const {
32 // Check that the ranges are monotonically increasing and non-overlapping
33 if (fReplacements.count() > 0) {
34 SkASSERT(fReplacements[0].fStart < fReplacements[0].fStop);
35
36 for (int i = 1; i < fReplacements.count(); ++i) {
37 SkASSERT(fReplacements[i].fStart < fReplacements[i].fStop);
38 SkASSERT(fReplacements[i - 1].fStop < fReplacements[i].fStart);
39 }
40 }
41 }
42 #endif
43
44 // TODO: Replace with hash or pass in "lastLookedUp" hint
45 SkPicturePlayback::PlaybackReplacements::ReplacementInfo*
46 SkPicturePlayback::PlaybackReplacements::lookupByStart(size_t start) {
47 SkDEBUGCODE(this->validate());
48 for (int i = 0; i < fReplacements.count(); ++i) {
49 if (start == fReplacements[i].fStart) {
50 return &fReplacements[i];
51 } else if (start < fReplacements[i].fStart) {
52 return NULL; // the ranges are monotonically increasing and non-ove rlapping
53 }
54 }
55
56 return NULL;
57 }
58
59
60 class SkAutoResetOpID {
61 public:
62 SkAutoResetOpID(SkPicturePlayback* playback) : fPlayback(playback) { }
63 ~SkAutoResetOpID() {
64 if (NULL != fPlayback) {
65 fPlayback->resetOpID();
66 }
67 }
68
69 private:
70 SkPicturePlayback* fPlayback;
71 };
72
73 /*
74 * Read the next op code and chunk size from 'reader'. The returned size
75 * is the entire size of the chunk (including the opcode). Thus, the
76 * offset just prior to calling read_op_and_size + 'size' is the offset
77 * to the next chunk's op code. This also means that the size of a chunk
78 * with no arguments (just an opcode) will be 4.
79 */
80 static DrawType read_op_and_size(SkReader32* reader, uint32_t* size) {
81 uint32_t temp = reader->readInt();
82 uint32_t op;
83 if (((uint8_t)temp) == temp) {
84 // old skp file - no size information
85 op = temp;
86 *size = 0;
87 } else {
88 UNPACK_8_24(temp, op, *size);
89 if (MASK_24 == *size) {
90 *size = reader->readInt();
91 }
92 }
93 return (DrawType)op;
94 }
95
96
97 static const SkRect* get_rect_ptr(SkReader32& reader) {
98 if (reader.readBool()) {
99 return &reader.skipT<SkRect>();
100 } else {
101 return NULL;
102 }
103 }
104
105 class TextContainer {
106 public:
107 size_t length() { return fByteLength; }
108 const void* text() { return (const void*)fText; }
109 size_t fByteLength;
110 const char* fText;
111 };
112
113 void get_text(SkReader32* reader, TextContainer* text) {
114 size_t length = text->fByteLength = reader->readInt();
115 text->fText = (const char*)reader->skip(length);
116 }
117
118 void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) {
119 SkAutoResetOpID aroi(this);
120 SkASSERT(0 == fCurOffset);
121
122 #ifdef ENABLE_TIME_DRAW
123 SkAutoTime at("SkPicture::draw", 50);
124 #endif
125
126 #ifdef SPEW_CLIP_SKIPPING
127 SkipClipRec skipRect, skipRRect, skipRegion, skipPath, skipCull;
128 int opCount = 0;
129 #endif
130
131 // kDrawComplete will be the signal that we have reached the end of
132 // the command stream
133 static const uint32_t kDrawComplete = SK_MaxU32;
134
135 SkReader32 reader(fPictureData->fOpData->bytes(), fPictureData->fOpData->siz e());
136 TextContainer text;
137 SkAutoTDelete<const SkPicture::OperationList> activeOpsList;
138 const SkTDArray<void*>* activeOps = NULL;
139
140 // When draw limits are enabled (i.e., 0 != fStart || 0 != fStop) the state
141 // tree isn't used to pick and choose the draw operations
142 if (0 == fStart && 0 == fStop) {
143 if (fUseBBH && NULL != fPictureData->fStateTree && NULL != fPictureData- >fBoundingHierarchy) {
144 SkRect clipBounds;
145 if (canvas->getClipBounds(&clipBounds)) {
146 SkIRect query;
147 clipBounds.roundOut(&query);
148
149 activeOpsList.reset(fPictureData->getActiveOps(query));
150 if (NULL != activeOpsList.get()) {
151 if (0 == activeOpsList->numOps()) {
152 return; // nothing to draw
153 }
154
155 // Since the opList is valid we know it is our derived class
156 activeOps = &((const SkPictureData::OperationList*)activeOps List.get())->fOps;
157 }
158 }
159 }
160 }
161
162 SkPictureStateTree::Iterator it = (NULL == activeOps) ?
163 SkPictureStateTree::Iterator() :
164 fPictureData->fStateTree->getIterator(*activeOps, canvas);
165
166 if (0 != fStart || 0 != fStop) {
167 reader.setOffset(fStart);
168 uint32_t size;
169 SkDEBUGCODE(DrawType op = ) read_op_and_size(&reader, &size);
170 SkASSERT(SAVE_LAYER == op);
171 reader.setOffset(fStart + size);
172 }
173
174 if (it.isValid()) {
175 uint32_t skipTo = it.nextDraw();
176 if (kDrawComplete == skipTo) {
177 return;
178 }
179 reader.setOffset(skipTo);
180 }
181
182 // Record this, so we can concat w/ it if we encounter a setMatrix()
183 SkMatrix initialMatrix = canvas->getTotalMatrix();
184
185 SkAutoCanvasRestore acr(canvas, false);
186
187 #ifdef SK_DEVELOPER
188 int opIndex = -1;
189 #endif
190
191 while (!reader.eof()) {
192 if (callback && callback->abortDrawing()) {
193 return;
194 }
195
196 if (0 != fStart || 0 != fStop) {
197 size_t offset = reader.offset();
198 if (offset >= fStop) {
199 uint32_t size;
200 SkDEBUGCODE(DrawType op = ) read_op_and_size(&reader, &size);
201 SkASSERT(RESTORE == op);
202 return;
203 }
204 }
205
206 if (NULL != fReplacements) {
207 // Potentially replace a block of operations with a single drawBitma p call
208 SkPicturePlayback::PlaybackReplacements::ReplacementInfo* temp =
209 fReplacements->lookupByStart(reader.offset());
210 if (NULL != temp) {
211 SkASSERT(NULL != temp->fBM);
212 SkASSERT(NULL != temp->fPaint);
213 canvas->save();
214 canvas->setMatrix(initialMatrix);
215 SkRect src = SkRect::Make(temp->fSrcRect);
216 SkRect dst = SkRect::MakeXYWH(temp->fPos.fX, temp->fPos.fY,
217 temp->fSrcRect.width(),
218 temp->fSrcRect.height());
219 canvas->drawBitmapRectToRect(*temp->fBM, &src, dst, temp->fPaint );
220 canvas->restore();
221
222 if (it.isValid()) {
223 // This save is needed since the BBH will automatically issu e
224 // a restore to balanced the saveLayer we're skipping
225 canvas->save();
226
227 // At this point we know that the PictureStateTree was aimin g
228 // for some draw op within temp's saveLayer (although potent ially
229 // in a separate saveLayer nested inside it).
230 // We need to skip all the operations inside temp's range
231 // along with all the associated state changes but update
232 // the state tree to the first operation outside temp's rang e.
233
234 uint32_t skipTo;
235 do {
236 skipTo = it.nextDraw();
237 if (kDrawComplete == skipTo) {
238 break;
239 }
240
241 if (skipTo <= temp->fStop) {
242 reader.setOffset(skipTo);
243 uint32_t size;
244 DrawType op = read_op_and_size(&reader, &size);
245 // Since we are relying on the normal SkPictureState Tree
246 // playback we need to convert any nested saveLayer calls
247 // it may issue into saves (so that all its internal
248 // restores will be balanced).
249 if (SAVE_LAYER == op) {
250 canvas->save();
251 }
252 }
253 } while (skipTo <= temp->fStop);
254
255 if (kDrawComplete == skipTo) {
256 break;
257 }
258
259 reader.setOffset(skipTo);
260 } else {
261 reader.setOffset(temp->fStop);
262 uint32_t size;
263 SkDEBUGCODE(DrawType op = ) read_op_and_size(&reader, &size) ;
264 SkASSERT(RESTORE == op);
265 }
266 continue;
267 }
268 }
269
270 #ifdef SPEW_CLIP_SKIPPING
271 opCount++;
272 #endif
273
274 fCurOffset = reader.offset();
275 uint32_t size;
276 DrawType op = read_op_and_size(&reader, &size);
277 size_t skipTo = 0;
278 if (NOOP == op) {
279 // NOOPs are to be ignored - do not propagate them any further
280 skipTo = fCurOffset + size;
281 #ifdef SK_DEVELOPER
282 } else {
283 opIndex++;
284 if (this->preDraw(opIndex, op)) {
285 skipTo = fCurOffset + size;
286 }
287 #endif
288 }
289
290 if (0 != skipTo) {
291 if (it.isValid()) {
292 // If using a bounding box hierarchy, advance the state tree
293 // iterator until at or after skipTo
294 uint32_t adjustedSkipTo;
295 do {
296 adjustedSkipTo = it.nextDraw();
297 } while (adjustedSkipTo < skipTo);
298 skipTo = adjustedSkipTo;
299 }
300 if (kDrawComplete == skipTo) {
301 break;
302 }
303 reader.setOffset(skipTo);
304 continue;
305 }
306
307 switch (op) {
308 case CLIP_PATH: {
309 const SkPath& path = fPictureData->getPath(reader);
310 uint32_t packed = reader.readInt();
311 SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed);
312 bool doAA = ClipParams_unpackDoAA(packed);
313 size_t offsetToRestore = reader.readInt();
314 SkASSERT(!offsetToRestore || offsetToRestore >= reader.offset());
315 canvas->clipPath(path, regionOp, doAA);
316 if (canvas->isClipEmpty() && offsetToRestore) {
317 #ifdef SPEW_CLIP_SKIPPING
318 skipPath.recordSkip(offsetToRestore - reader.offset());
319 #endif
320 reader.setOffset(offsetToRestore);
321 }
322 } break;
323 case CLIP_REGION: {
324 SkRegion region;
325 reader.readRegion(&region);
326 uint32_t packed = reader.readInt();
327 SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed);
328 size_t offsetToRestore = reader.readInt();
329 SkASSERT(!offsetToRestore || offsetToRestore >= reader.offset());
330 canvas->clipRegion(region, regionOp);
331 if (canvas->isClipEmpty() && offsetToRestore) {
332 #ifdef SPEW_CLIP_SKIPPING
333 skipRegion.recordSkip(offsetToRestore - reader.offset());
334 #endif
335 reader.setOffset(offsetToRestore);
336 }
337 } break;
338 case CLIP_RECT: {
339 const SkRect& rect = reader.skipT<SkRect>();
340 uint32_t packed = reader.readInt();
341 SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed);
342 bool doAA = ClipParams_unpackDoAA(packed);
343 size_t offsetToRestore = reader.readInt();
344 SkASSERT(!offsetToRestore || offsetToRestore >= reader.offset());
345 canvas->clipRect(rect, regionOp, doAA);
346 if (canvas->isClipEmpty() && offsetToRestore) {
347 #ifdef SPEW_CLIP_SKIPPING
348 skipRect.recordSkip(offsetToRestore - reader.offset());
349 #endif
350 reader.setOffset(offsetToRestore);
351 }
352 } break;
353 case CLIP_RRECT: {
354 SkRRect rrect;
355 reader.readRRect(&rrect);
356 uint32_t packed = reader.readInt();
357 SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed);
358 bool doAA = ClipParams_unpackDoAA(packed);
359 size_t offsetToRestore = reader.readInt();
360 SkASSERT(!offsetToRestore || offsetToRestore >= reader.offset());
361 canvas->clipRRect(rrect, regionOp, doAA);
362 if (canvas->isClipEmpty() && offsetToRestore) {
363 #ifdef SPEW_CLIP_SKIPPING
364 skipRRect.recordSkip(offsetToRestore - reader.offset());
365 #endif
366 reader.setOffset(offsetToRestore);
367 }
368 } break;
369 case PUSH_CULL: {
370 const SkRect& cullRect = reader.skipT<SkRect>();
371 size_t offsetToRestore = reader.readInt();
372 if (offsetToRestore && canvas->quickReject(cullRect)) {
373 #ifdef SPEW_CLIP_SKIPPING
374 skipCull.recordSkip(offsetToRestore - reader.offset());
375 #endif
376 reader.setOffset(offsetToRestore);
377 } else {
378 canvas->pushCull(cullRect);
379 }
380 } break;
381 case POP_CULL:
382 canvas->popCull();
383 break;
384 case CONCAT: {
385 SkMatrix matrix;
386 reader.readMatrix(&matrix);
387 canvas->concat(matrix);
388 break;
389 }
390 case DRAW_BITMAP: {
391 const SkPaint* paint = fPictureData->getPaint(reader);
392 const SkBitmap& bitmap = fPictureData->getBitmap(reader);
393 const SkPoint& loc = reader.skipT<SkPoint>();
394 canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint);
395 } break;
396 case DRAW_BITMAP_RECT_TO_RECT: {
397 const SkPaint* paint = fPictureData->getPaint(reader);
398 const SkBitmap& bitmap = fPictureData->getBitmap(reader);
399 const SkRect* src = get_rect_ptr(reader); // may be null
400 const SkRect& dst = reader.skipT<SkRect>(); // required
401 SkCanvas::DrawBitmapRectFlags flags;
402 flags = (SkCanvas::DrawBitmapRectFlags) reader.readInt();
403 canvas->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
404 } break;
405 case DRAW_BITMAP_MATRIX: {
406 const SkPaint* paint = fPictureData->getPaint(reader);
407 const SkBitmap& bitmap = fPictureData->getBitmap(reader);
408 SkMatrix matrix;
409 reader.readMatrix(&matrix);
410 canvas->drawBitmapMatrix(bitmap, matrix, paint);
411 } break;
412 case DRAW_BITMAP_NINE: {
413 const SkPaint* paint = fPictureData->getPaint(reader);
414 const SkBitmap& bitmap = fPictureData->getBitmap(reader);
415 const SkIRect& src = reader.skipT<SkIRect>();
416 const SkRect& dst = reader.skipT<SkRect>();
417 canvas->drawBitmapNine(bitmap, src, dst, paint);
418 } break;
419 case DRAW_CLEAR:
420 canvas->clear(reader.readInt());
421 break;
422 case DRAW_DATA: {
423 size_t length = reader.readInt();
424 canvas->drawData(reader.skip(length), length);
425 // skip handles padding the read out to a multiple of 4
426 } break;
427 case DRAW_DRRECT: {
428 const SkPaint& paint = *fPictureData->getPaint(reader);
429 SkRRect outer, inner;
430 reader.readRRect(&outer);
431 reader.readRRect(&inner);
432 canvas->drawDRRect(outer, inner, paint);
433 } break;
434 case BEGIN_COMMENT_GROUP: {
435 const char* desc = reader.readString();
436 canvas->beginCommentGroup(desc);
437 } break;
438 case COMMENT: {
439 const char* kywd = reader.readString();
440 const char* value = reader.readString();
441 canvas->addComment(kywd, value);
442 } break;
443 case END_COMMENT_GROUP: {
444 canvas->endCommentGroup();
445 } break;
446 case DRAW_OVAL: {
447 const SkPaint& paint = *fPictureData->getPaint(reader);
448 canvas->drawOval(reader.skipT<SkRect>(), paint);
449 } break;
450 case DRAW_PAINT:
451 canvas->drawPaint(*fPictureData->getPaint(reader));
452 break;
453 case DRAW_PATH: {
454 const SkPaint& paint = *fPictureData->getPaint(reader);
455 canvas->drawPath(fPictureData->getPath(reader), paint);
456 } break;
457 case DRAW_PICTURE:
458 canvas->drawPicture(fPictureData->getPicture(reader));
459 break;
460 case DRAW_POINTS: {
461 const SkPaint& paint = *fPictureData->getPaint(reader);
462 SkCanvas::PointMode mode = (SkCanvas::PointMode)reader.readInt();
463 size_t count = reader.readInt();
464 const SkPoint* pts = (const SkPoint*)reader.skip(sizeof(SkPoint)* co unt);
465 canvas->drawPoints(mode, count, pts, paint);
466 } break;
467 case DRAW_POS_TEXT: {
468 const SkPaint& paint = *fPictureData->getPaint(reader);
469 get_text(&reader, &text);
470 size_t points = reader.readInt();
471 const SkPoint* pos = (const SkPoint*)reader.skip(points * sizeof(SkP oint));
472 canvas->drawPosText(text.text(), text.length(), pos, paint);
473 } break;
474 case DRAW_POS_TEXT_TOP_BOTTOM: {
475 const SkPaint& paint = *fPictureData->getPaint(reader);
476 get_text(&reader, &text);
477 size_t points = reader.readInt();
478 const SkPoint* pos = (const SkPoint*)reader.skip(points * sizeof(SkP oint));
479 const SkScalar top = reader.readScalar();
480 const SkScalar bottom = reader.readScalar();
481 if (!canvas->quickRejectY(top, bottom)) {
482 canvas->drawPosText(text.text(), text.length(), pos, paint);
483 }
484 } break;
485 case DRAW_POS_TEXT_H: {
486 const SkPaint& paint = *fPictureData->getPaint(reader);
487 get_text(&reader, &text);
488 size_t xCount = reader.readInt();
489 const SkScalar constY = reader.readScalar();
490 const SkScalar* xpos = (const SkScalar*)reader.skip(xCount * sizeof( SkScalar));
491 canvas->drawPosTextH(text.text(), text.length(), xpos, constY, paint );
492 } break;
493 case DRAW_POS_TEXT_H_TOP_BOTTOM: {
494 const SkPaint& paint = *fPictureData->getPaint(reader);
495 get_text(&reader, &text);
496 size_t xCount = reader.readInt();
497 const SkScalar* xpos = (const SkScalar*)reader.skip((3 + xCount) * s izeof(SkScalar));
498 const SkScalar top = *xpos++;
499 const SkScalar bottom = *xpos++;
500 const SkScalar constY = *xpos++;
501 if (!canvas->quickRejectY(top, bottom)) {
502 canvas->drawPosTextH(text.text(), text.length(), xpos, constY, p aint);
503 }
504 } break;
505 case DRAW_RECT: {
506 const SkPaint& paint = *fPictureData->getPaint(reader);
507 canvas->drawRect(reader.skipT<SkRect>(), paint);
508 } break;
509 case DRAW_RRECT: {
510 const SkPaint& paint = *fPictureData->getPaint(reader);
511 SkRRect rrect;
512 reader.readRRect(&rrect);
513 canvas->drawRRect(rrect, paint);
514 } break;
515 case DRAW_SPRITE: {
516 const SkPaint* paint = fPictureData->getPaint(reader);
517 const SkBitmap& bitmap = fPictureData->getBitmap(reader);
518 int left = reader.readInt();
519 int top = reader.readInt();
520 canvas->drawSprite(bitmap, left, top, paint);
521 } break;
522 case DRAW_TEXT: {
523 const SkPaint& paint = *fPictureData->getPaint(reader);
524 get_text(&reader, &text);
525 SkScalar x = reader.readScalar();
526 SkScalar y = reader.readScalar();
527 canvas->drawText(text.text(), text.length(), x, y, paint);
528 } break;
529 case DRAW_TEXT_TOP_BOTTOM: {
530 const SkPaint& paint = *fPictureData->getPaint(reader);
531 get_text(&reader, &text);
532 const SkScalar* ptr = (const SkScalar*)reader.skip(4 * sizeof(SkScal ar));
533 // ptr[0] == x
534 // ptr[1] == y
535 // ptr[2] == top
536 // ptr[3] == bottom
537 if (!canvas->quickRejectY(ptr[2], ptr[3])) {
538 canvas->drawText(text.text(), text.length(), ptr[0], ptr[1], pai nt);
539 }
540 } break;
541 case DRAW_TEXT_ON_PATH: {
542 const SkPaint& paint = *fPictureData->getPaint(reader);
543 get_text(&reader, &text);
544 const SkPath& path = fPictureData->getPath(reader);
545 SkMatrix matrix;
546 reader.readMatrix(&matrix);
547 canvas->drawTextOnPath(text.text(), text.length(), path, &matrix, pa int);
548 } break;
549 case DRAW_VERTICES: {
550 SkAutoTUnref<SkXfermode> xfer;
551 const SkPaint& paint = *fPictureData->getPaint(reader);
552 DrawVertexFlags flags = (DrawVertexFlags)reader.readInt();
553 SkCanvas::VertexMode vmode = (SkCanvas::VertexMode)reader.readInt();
554 int vCount = reader.readInt();
555 const SkPoint* verts = (const SkPoint*)reader.skip(vCount * sizeof(S kPoint));
556 const SkPoint* texs = NULL;
557 const SkColor* colors = NULL;
558 const uint16_t* indices = NULL;
559 int iCount = 0;
560 if (flags & DRAW_VERTICES_HAS_TEXS) {
561 texs = (const SkPoint*)reader.skip(vCount * sizeof(SkPoint));
562 }
563 if (flags & DRAW_VERTICES_HAS_COLORS) {
564 colors = (const SkColor*)reader.skip(vCount * sizeof(SkColor));
565 }
566 if (flags & DRAW_VERTICES_HAS_INDICES) {
567 iCount = reader.readInt();
568 indices = (const uint16_t*)reader.skip(iCount * sizeof(uint16_t) );
569 }
570 if (flags & DRAW_VERTICES_HAS_XFER) {
571 int mode = reader.readInt();
572 if (mode < 0 || mode > SkXfermode::kLastMode) {
573 mode = SkXfermode::kModulate_Mode;
574 }
575 xfer.reset(SkXfermode::Create((SkXfermode::Mode)mode));
576 }
577 canvas->drawVertices(vmode, vCount, verts, texs, colors, xfer, indic es, iCount, paint);
578 } break;
579 case RESTORE:
580 canvas->restore();
581 break;
582 case ROTATE:
583 canvas->rotate(reader.readScalar());
584 break;
585 case SAVE:
586 // SKPs with version < 29 also store a SaveFlags param.
587 if (size > 4) {
588 SkASSERT(8 == size);
589 reader.readInt();
590 }
591 canvas->save();
592 break;
593 case SAVE_LAYER: {
594 const SkRect* boundsPtr = get_rect_ptr(reader);
595 const SkPaint* paint = fPictureData->getPaint(reader);
596 canvas->saveLayer(boundsPtr, paint, (SkCanvas::SaveFlags) reader.rea dInt());
597 } break;
598 case SCALE: {
599 SkScalar sx = reader.readScalar();
600 SkScalar sy = reader.readScalar();
601 canvas->scale(sx, sy);
602 } break;
603 case SET_MATRIX: {
604 SkMatrix matrix;
605 reader.readMatrix(&matrix);
606 matrix.postConcat(initialMatrix);
607 canvas->setMatrix(matrix);
608 } break;
609 case SKEW: {
610 SkScalar sx = reader.readScalar();
611 SkScalar sy = reader.readScalar();
612 canvas->skew(sx, sy);
613 } break;
614 case TRANSLATE: {
615 SkScalar dx = reader.readScalar();
616 SkScalar dy = reader.readScalar();
617 canvas->translate(dx, dy);
618 } break;
619 default:
620 SkASSERT(0);
621 }
622
623 #ifdef SK_DEVELOPER
624 this->postDraw(opIndex);
625 #endif
626
627 if (it.isValid()) {
628 uint32_t skipTo = it.nextDraw();
629 if (kDrawComplete == skipTo) {
630 break;
631 }
632 reader.setOffset(skipTo);
633 }
634 }
635
636 #ifdef SPEW_CLIP_SKIPPING
637 {
638 size_t size = skipRect.fSize + skipRRect.fSize + skipPath.fSize + skipRe gion.fSize +
639 skipCull.fSize;
640 SkDebugf("--- Clip skips %d%% rect:%d rrect:%d path:%d rgn:%d cull:%d\n" ,
641 size * 100 / reader.offset(), skipRect.fCount, skipRRect.fCount,
642 skipPath.fCount, skipRegion.fCount, skipCull.fCount);
643 SkDebugf("--- Total ops: %d\n", opCount);
644 }
645 #endif
646 // this->dumpSize();
647 }
648
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/gpu/GrPictureUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698