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

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

Issue 1918433002: Optionally enable SkValidatingReadBuffer in SkPictureImageFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: More clean up Created 4 years, 8 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/core/SkReadBuffer.h » ('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 2014 Google Inc. 2 * Copyright 2014 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkPatchUtils.h" 9 #include "SkPatchUtils.h"
10 #include "SkPictureData.h" 10 #include "SkPictureData.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 void get_text(SkReadBuffer* reader, TextContainer* text) { 78 void get_text(SkReadBuffer* reader, TextContainer* text) {
79 size_t length = text->fByteLength = reader->readInt(); 79 size_t length = text->fByteLength = reader->readInt();
80 text->fText = (const char*)reader->skip(length); 80 text->fText = (const char*)reader->skip(length);
81 } 81 }
82 82
83 // FIXME: SkBitmaps are stateful, so we need to copy them to play back in multip le threads. 83 // FIXME: SkBitmaps are stateful, so we need to copy them to play back in multip le threads.
84 static SkBitmap shallow_copy(const SkBitmap& bitmap) { 84 static SkBitmap shallow_copy(const SkBitmap& bitmap) {
85 return bitmap; 85 return bitmap;
86 } 86 }
87 87
88 void SkPicturePlayback::draw(SkCanvas* canvas, SkPicture::AbortCallback* callbac k) { 88 void SkPicturePlayback::draw(SkCanvas* canvas,
89 SkPicture::AbortCallback* callback,
90 const SkReadBuffer* buffer) {
89 AutoResetOpID aroi(this); 91 AutoResetOpID aroi(this);
90 SkASSERT(0 == fCurOffset); 92 SkASSERT(0 == fCurOffset);
91 93
92 SkReadBuffer reader(fPictureData->opData()->bytes(), fPictureData->opData()- >size()); 94 SkAutoTDelete<SkReadBuffer> reader;
95 if (buffer) {
96 reader.reset(buffer->clone(fPictureData->opData()->bytes(),
97 fPictureData->opData()->size()));
98 } else {
99 reader.reset(new SkReadBuffer(fPictureData->opData()->bytes(),
100 fPictureData->opData()->size()));
101 }
93 102
94 // Record this, so we can concat w/ it if we encounter a setMatrix() 103 // Record this, so we can concat w/ it if we encounter a setMatrix()
95 SkMatrix initialMatrix = canvas->getTotalMatrix(); 104 SkMatrix initialMatrix = canvas->getTotalMatrix();
96 105
97 SkAutoCanvasRestore acr(canvas, false); 106 SkAutoCanvasRestore acr(canvas, false);
98 107
99 while (!reader.eof()) { 108 while (!reader->eof()) {
100 if (callback && callback->abort()) { 109 if (callback && callback->abort()) {
101 return; 110 return;
102 } 111 }
103 112
104 fCurOffset = reader.offset(); 113 fCurOffset = reader->offset();
105 uint32_t size; 114 uint32_t size;
106 DrawType op = ReadOpAndSize(&reader, &size); 115 DrawType op = ReadOpAndSize(reader, &size);
107 116
108 this->handleOp(&reader, op, size, canvas, initialMatrix); 117 this->handleOp(reader, op, size, canvas, initialMatrix);
109 } 118 }
110 } 119 }
111 120
112 void SkPicturePlayback::handleOp(SkReadBuffer* reader, 121 void SkPicturePlayback::handleOp(SkReadBuffer* reader,
113 DrawType op, 122 DrawType op,
114 uint32_t size, 123 uint32_t size,
115 SkCanvas* canvas, 124 SkCanvas* canvas,
116 const SkMatrix& initialMatrix) { 125 const SkMatrix& initialMatrix) {
117 switch (op) { 126 switch (op) {
118 case NOOP: { 127 case NOOP: {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 } break; 560 } break;
552 case TRANSLATE: { 561 case TRANSLATE: {
553 SkScalar dx = reader->readScalar(); 562 SkScalar dx = reader->readScalar();
554 SkScalar dy = reader->readScalar(); 563 SkScalar dy = reader->readScalar();
555 canvas->translate(dx, dy); 564 canvas->translate(dx, dy);
556 } break; 565 } break;
557 default: 566 default:
558 SkASSERTF(false, "Unknown draw type: %d", op); 567 SkASSERTF(false, "Unknown draw type: %d", op);
559 } 568 }
560 } 569 }
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/core/SkReadBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698