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

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

Issue 1893423002: Fix ImageFilter fuzzer issue (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove setOffset 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"
11 #include "SkPicturePlayback.h" 11 #include "SkPicturePlayback.h"
12 #include "SkPictureRecord.h" 12 #include "SkPictureRecord.h"
13 #include "SkReader32.h" 13 #include "SkReadBuffer.h"
14 #include "SkRSXform.h" 14 #include "SkRSXform.h"
15 #include "SkTextBlob.h" 15 #include "SkTextBlob.h"
16 #include "SkTDArray.h" 16 #include "SkTDArray.h"
17 #include "SkTypes.h" 17 #include "SkTypes.h"
18 18
19 // matches old SkCanvas::SaveFlags 19 // matches old SkCanvas::SaveFlags
20 enum LegacySaveFlags { 20 enum LegacySaveFlags {
21 kHasAlphaLayer_LegacySaveFlags = 0x04, 21 kHasAlphaLayer_LegacySaveFlags = 0x04,
22 kClipToLayer_LegacySaveFlags = 0x10, 22 kClipToLayer_LegacySaveFlags = 0x10,
23 }; 23 };
(...skipping 10 matching lines...) Expand all
34 return layerFlags; 34 return layerFlags;
35 } 35 }
36 36
37 /* 37 /*
38 * Read the next op code and chunk size from 'reader'. The returned size 38 * Read the next op code and chunk size from 'reader'. The returned size
39 * is the entire size of the chunk (including the opcode). Thus, the 39 * is the entire size of the chunk (including the opcode). Thus, the
40 * offset just prior to calling ReadOpAndSize + 'size' is the offset 40 * offset just prior to calling ReadOpAndSize + 'size' is the offset
41 * to the next chunk's op code. This also means that the size of a chunk 41 * to the next chunk's op code. This also means that the size of a chunk
42 * with no arguments (just an opcode) will be 4. 42 * with no arguments (just an opcode) will be 4.
43 */ 43 */
44 DrawType SkPicturePlayback::ReadOpAndSize(SkReader32* reader, uint32_t* size) { 44 DrawType SkPicturePlayback::ReadOpAndSize(SkReadBuffer* reader, uint32_t* size) {
45 uint32_t temp = reader->readInt(); 45 uint32_t temp = reader->readInt();
46 uint32_t op; 46 uint32_t op;
47 if (((uint8_t)temp) == temp) { 47 if (((uint8_t)temp) == temp) {
48 // old skp file - no size information 48 // old skp file - no size information
49 op = temp; 49 op = temp;
50 *size = 0; 50 *size = 0;
51 } else { 51 } else {
52 UNPACK_8_24(temp, op, *size); 52 UNPACK_8_24(temp, op, *size);
53 if (MASK_24 == *size) { 53 if (MASK_24 == *size) {
54 *size = reader->readInt(); 54 *size = reader->readInt();
55 } 55 }
56 } 56 }
57 return (DrawType)op; 57 return (DrawType)op;
58 } 58 }
59 59
60 60
61 static const SkRect* get_rect_ptr(SkReader32* reader) { 61 static const SkRect* get_rect_ptr(SkReadBuffer* reader, SkRect* storage) {
62 if (reader->readBool()) { 62 if (reader->readBool()) {
63 return &reader->skipT<SkRect>(); 63 reader->readRect(storage);
64 return storage;
64 } else { 65 } else {
65 return nullptr; 66 return nullptr;
66 } 67 }
67 } 68 }
68 69
69 class TextContainer { 70 class TextContainer {
70 public: 71 public:
71 size_t length() { return fByteLength; } 72 size_t length() { return fByteLength; }
72 const void* text() { return (const void*)fText; } 73 const void* text() { return (const void*)fText; }
73 size_t fByteLength; 74 size_t fByteLength;
74 const char* fText; 75 const char* fText;
75 }; 76 };
76 77
77 void get_text(SkReader32* reader, TextContainer* text) { 78 void get_text(SkReadBuffer* reader, TextContainer* text) {
78 size_t length = text->fByteLength = reader->readInt(); 79 size_t length = text->fByteLength = reader->readInt();
79 text->fText = (const char*)reader->skip(length); 80 text->fText = (const char*)reader->skip(length);
80 } 81 }
81 82
82 // 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.
83 static SkBitmap shallow_copy(const SkBitmap& bitmap) { 84 static SkBitmap shallow_copy(const SkBitmap& bitmap) {
84 return bitmap; 85 return bitmap;
85 } 86 }
86 87
87 void SkPicturePlayback::draw(SkCanvas* canvas, SkPicture::AbortCallback* callbac k) { 88 void SkPicturePlayback::draw(SkCanvas* canvas, SkPicture::AbortCallback* callbac k) {
88 AutoResetOpID aroi(this); 89 AutoResetOpID aroi(this);
89 SkASSERT(0 == fCurOffset); 90 SkASSERT(0 == fCurOffset);
90 91
91 SkReader32 reader(fPictureData->opData()->bytes(), fPictureData->opData()->s ize()); 92 SkReadBuffer reader(fPictureData->opData()->bytes(), fPictureData->opData()- >size());
92 93
93 // Record this, so we can concat w/ it if we encounter a setMatrix() 94 // Record this, so we can concat w/ it if we encounter a setMatrix()
94 SkMatrix initialMatrix = canvas->getTotalMatrix(); 95 SkMatrix initialMatrix = canvas->getTotalMatrix();
95 96
96 SkAutoCanvasRestore acr(canvas, false); 97 SkAutoCanvasRestore acr(canvas, false);
97 98
98 while (!reader.eof()) { 99 while (!reader.eof()) {
99 if (callback && callback->abort()) { 100 if (callback && callback->abort()) {
100 return; 101 return;
101 } 102 }
102 103
103 fCurOffset = reader.offset(); 104 fCurOffset = reader.offset();
104 uint32_t size; 105 uint32_t size;
105 DrawType op = ReadOpAndSize(&reader, &size); 106 DrawType op = ReadOpAndSize(&reader, &size);
106 107
107 this->handleOp(&reader, op, size, canvas, initialMatrix); 108 this->handleOp(&reader, op, size, canvas, initialMatrix);
108 } 109 }
109 } 110 }
110 111
111 void SkPicturePlayback::handleOp(SkReader32* reader, 112 void SkPicturePlayback::handleOp(SkReadBuffer* reader,
112 DrawType op, 113 DrawType op,
113 uint32_t size, 114 uint32_t size,
114 SkCanvas* canvas, 115 SkCanvas* canvas,
115 const SkMatrix& initialMatrix) { 116 const SkMatrix& initialMatrix) {
116 switch (op) { 117 switch (op) {
117 case NOOP: { 118 case NOOP: {
118 SkASSERT(size >= 4); 119 SkASSERT(size >= 4);
119 reader->skip(size - 4); 120 reader->skip(size - 4);
120 } break; 121 } break;
121 case CLIP_PATH: { 122 case CLIP_PATH: {
122 const SkPath& path = fPictureData->getPath(reader); 123 const SkPath& path = fPictureData->getPath(reader);
123 uint32_t packed = reader->readInt(); 124 uint32_t packed = reader->readInt();
124 SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed); 125 SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed);
125 bool doAA = ClipParams_unpackDoAA(packed); 126 bool doAA = ClipParams_unpackDoAA(packed);
126 size_t offsetToRestore = reader->readInt(); 127 size_t offsetToRestore = reader->readInt();
127 SkASSERT(!offsetToRestore || offsetToRestore >= reader->offset()); 128 SkASSERT(!offsetToRestore || offsetToRestore >= reader->offset());
128 canvas->clipPath(path, regionOp, doAA); 129 canvas->clipPath(path, regionOp, doAA);
129 if (canvas->isClipEmpty() && offsetToRestore) { 130 if (canvas->isClipEmpty() && offsetToRestore) {
130 reader->setOffset(offsetToRestore); 131 reader->skip(offsetToRestore - reader->offset());
131 } 132 }
132 } break; 133 } break;
133 case CLIP_REGION: { 134 case CLIP_REGION: {
134 SkRegion region; 135 SkRegion region;
135 reader->readRegion(&region); 136 reader->readRegion(&region);
136 uint32_t packed = reader->readInt(); 137 uint32_t packed = reader->readInt();
137 SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed); 138 SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed);
138 size_t offsetToRestore = reader->readInt(); 139 size_t offsetToRestore = reader->readInt();
139 SkASSERT(!offsetToRestore || offsetToRestore >= reader->offset()); 140 SkASSERT(!offsetToRestore || offsetToRestore >= reader->offset());
140 canvas->clipRegion(region, regionOp); 141 canvas->clipRegion(region, regionOp);
141 if (canvas->isClipEmpty() && offsetToRestore) { 142 if (canvas->isClipEmpty() && offsetToRestore) {
142 reader->setOffset(offsetToRestore); 143 reader->skip(offsetToRestore - reader->offset());
143 } 144 }
144 } break; 145 } break;
145 case CLIP_RECT: { 146 case CLIP_RECT: {
146 const SkRect& rect = reader->skipT<SkRect>(); 147 SkRect rect;
148 reader->readRect(&rect);
147 uint32_t packed = reader->readInt(); 149 uint32_t packed = reader->readInt();
148 SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed); 150 SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed);
149 bool doAA = ClipParams_unpackDoAA(packed); 151 bool doAA = ClipParams_unpackDoAA(packed);
150 size_t offsetToRestore = reader->readInt(); 152 size_t offsetToRestore = reader->readInt();
151 SkASSERT(!offsetToRestore || offsetToRestore >= reader->offset()); 153 SkASSERT(!offsetToRestore || offsetToRestore >= reader->offset());
152 canvas->clipRect(rect, regionOp, doAA); 154 canvas->clipRect(rect, regionOp, doAA);
153 if (canvas->isClipEmpty() && offsetToRestore) { 155 if (canvas->isClipEmpty() && offsetToRestore) {
154 reader->setOffset(offsetToRestore); 156 reader->skip(offsetToRestore - reader->offset());
155 } 157 }
156 } break; 158 } break;
157 case CLIP_RRECT: { 159 case CLIP_RRECT: {
158 SkRRect rrect; 160 SkRRect rrect;
159 reader->readRRect(&rrect); 161 reader->readRRect(&rrect);
160 uint32_t packed = reader->readInt(); 162 uint32_t packed = reader->readInt();
161 SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed); 163 SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed);
162 bool doAA = ClipParams_unpackDoAA(packed); 164 bool doAA = ClipParams_unpackDoAA(packed);
163 size_t offsetToRestore = reader->readInt(); 165 size_t offsetToRestore = reader->readInt();
164 SkASSERT(!offsetToRestore || offsetToRestore >= reader->offset()); 166 SkASSERT(!offsetToRestore || offsetToRestore >= reader->offset());
165 canvas->clipRRect(rrect, regionOp, doAA); 167 canvas->clipRRect(rrect, regionOp, doAA);
166 if (canvas->isClipEmpty() && offsetToRestore) { 168 if (canvas->isClipEmpty() && offsetToRestore) {
167 reader->setOffset(offsetToRestore); 169 reader->skip(offsetToRestore - reader->offset());
168 } 170 }
169 } break; 171 } break;
170 case PUSH_CULL: break; // Deprecated, safe to ignore both push and pop. 172 case PUSH_CULL: break; // Deprecated, safe to ignore both push and pop.
171 case POP_CULL: break; 173 case POP_CULL: break;
172 case CONCAT: { 174 case CONCAT: {
173 SkMatrix matrix; 175 SkMatrix matrix;
174 reader->readMatrix(&matrix); 176 reader->readMatrix(&matrix);
175 canvas->concat(matrix); 177 canvas->concat(matrix);
176 break; 178 break;
177 } 179 }
178 case DRAW_ANNOTATION: { 180 case DRAW_ANNOTATION: {
179 const SkRect& rect = reader->skipT<SkRect>(); 181 SkRect rect;
180 const char* key = reader->readString(); 182 reader->readRect(&rect);
181 canvas->drawAnnotation(rect, key, reader->readData().get()); 183 SkString key;
184 reader->readString(&key);
185 canvas->drawAnnotation(rect, key.c_str(), reader->readByteArrayAsDat a().get());
182 } break; 186 } break;
183 case DRAW_ATLAS: { 187 case DRAW_ATLAS: {
184 const SkPaint* paint = fPictureData->getPaint(reader); 188 const SkPaint* paint = fPictureData->getPaint(reader);
185 const SkImage* atlas = fPictureData->getImage(reader); 189 const SkImage* atlas = fPictureData->getImage(reader);
186 const uint32_t flags = reader->readU32(); 190 const uint32_t flags = reader->readUInt();
187 const int count = reader->readU32(); 191 const int count = reader->readUInt();
188 const SkRSXform* xform = (const SkRSXform*)reader->skip(count * size of(SkRSXform)); 192 const SkRSXform* xform = (const SkRSXform*)reader->skip(count * size of(SkRSXform));
189 const SkRect* tex = (const SkRect*)reader->skip(count * sizeof(SkRec t)); 193 const SkRect* tex = (const SkRect*)reader->skip(count * sizeof(SkRec t));
190 const SkColor* colors = nullptr; 194 const SkColor* colors = nullptr;
191 SkXfermode::Mode mode = SkXfermode::kDst_Mode; 195 SkXfermode::Mode mode = SkXfermode::kDst_Mode;
192 if (flags & DRAW_ATLAS_HAS_COLORS) { 196 if (flags & DRAW_ATLAS_HAS_COLORS) {
193 colors = (const SkColor*)reader->skip(count * sizeof(SkColor)); 197 colors = (const SkColor*)reader->skip(count * sizeof(SkColor));
194 mode = (SkXfermode::Mode)reader->readU32(); 198 mode = (SkXfermode::Mode)reader->readUInt();
195 } 199 }
196 const SkRect* cull = nullptr; 200 const SkRect* cull = nullptr;
197 if (flags & DRAW_ATLAS_HAS_CULL) { 201 if (flags & DRAW_ATLAS_HAS_CULL) {
198 cull = (const SkRect*)reader->skip(sizeof(SkRect)); 202 cull = (const SkRect*)reader->skip(sizeof(SkRect));
199 } 203 }
200 canvas->drawAtlas(atlas, xform, tex, colors, count, mode, cull, pain t); 204 canvas->drawAtlas(atlas, xform, tex, colors, count, mode, cull, pain t);
201 } break; 205 } break;
202 case DRAW_BITMAP: { 206 case DRAW_BITMAP: {
203 const SkPaint* paint = fPictureData->getPaint(reader); 207 const SkPaint* paint = fPictureData->getPaint(reader);
204 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader) ); 208 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader) );
205 const SkPoint& loc = reader->skipT<SkPoint>(); 209 SkPoint loc;
210 reader->readPoint(&loc);
206 canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint); 211 canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint);
207 } break; 212 } break;
208 case DRAW_BITMAP_RECT: { 213 case DRAW_BITMAP_RECT: {
209 const SkPaint* paint = fPictureData->getPaint(reader); 214 const SkPaint* paint = fPictureData->getPaint(reader);
210 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader) ); 215 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader) );
211 const SkRect* src = get_rect_ptr(reader); // may be null 216 SkRect storage;
212 const SkRect& dst = reader->skipT<SkRect>(); // required 217 const SkRect* src = get_rect_ptr(reader, &storage); // may be null
218 SkRect dst;
219 reader->readRect(&dst); // required
213 SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstrain t)reader->readInt(); 220 SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstrain t)reader->readInt();
214 canvas->legacy_drawBitmapRect(bitmap, src, dst, paint, constraint); 221 canvas->legacy_drawBitmapRect(bitmap, src, dst, paint, constraint);
215 } break; 222 } break;
216 case DRAW_BITMAP_MATRIX: { 223 case DRAW_BITMAP_MATRIX: {
217 const SkPaint* paint = fPictureData->getPaint(reader); 224 const SkPaint* paint = fPictureData->getPaint(reader);
218 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader) ); 225 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader) );
219 SkMatrix matrix; 226 SkMatrix matrix;
220 reader->readMatrix(&matrix); 227 reader->readMatrix(&matrix);
221 228
222 SkAutoCanvasRestore acr(canvas, true); 229 SkAutoCanvasRestore acr(canvas, true);
223 canvas->concat(matrix); 230 canvas->concat(matrix);
224 canvas->drawBitmap(bitmap, 0, 0, paint); 231 canvas->drawBitmap(bitmap, 0, 0, paint);
225 } break; 232 } break;
226 case DRAW_BITMAP_NINE: { 233 case DRAW_BITMAP_NINE: {
227 const SkPaint* paint = fPictureData->getPaint(reader); 234 const SkPaint* paint = fPictureData->getPaint(reader);
228 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader) ); 235 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader) );
229 const SkIRect& src = reader->skipT<SkIRect>(); 236 SkIRect src;
230 const SkRect& dst = reader->skipT<SkRect>(); 237 reader->readIRect(&src);
238 SkRect dst;
239 reader->readRect(&dst);
231 canvas->drawBitmapNine(bitmap, src, dst, paint); 240 canvas->drawBitmapNine(bitmap, src, dst, paint);
232 } break; 241 } break;
233 case DRAW_CLEAR: 242 case DRAW_CLEAR:
234 canvas->clear(reader->readInt()); 243 canvas->clear(reader->readInt());
235 break; 244 break;
236 case DRAW_DATA: { 245 case DRAW_DATA: {
237 // This opcode is now dead, just need to skip it for backwards compa tibility 246 // This opcode is now dead, just need to skip it for backwards compa tibility
238 size_t length = reader->readInt(); 247 size_t length = reader->readInt();
239 (void)reader->skip(length); 248 (void)reader->skip(length);
240 // skip handles padding the read out to a multiple of 4 249 // skip handles padding the read out to a multiple of 4
241 } break; 250 } break;
242 case DRAW_DRRECT: { 251 case DRAW_DRRECT: {
243 const SkPaint& paint = *fPictureData->getPaint(reader); 252 const SkPaint& paint = *fPictureData->getPaint(reader);
244 SkRRect outer, inner; 253 SkRRect outer, inner;
245 reader->readRRect(&outer); 254 reader->readRRect(&outer);
246 reader->readRRect(&inner); 255 reader->readRRect(&inner);
247 canvas->drawDRRect(outer, inner, paint); 256 canvas->drawDRRect(outer, inner, paint);
248 } break; 257 } break;
249 case BEGIN_COMMENT_GROUP: 258 case BEGIN_COMMENT_GROUP: {
250 reader->readString(); 259 SkString tmp;
260 reader->readString(&tmp);
251 // deprecated (M44) 261 // deprecated (M44)
252 break; 262 break;
253 case COMMENT: 263 }
254 reader->readString(); 264 case COMMENT: {
255 reader->readString(); 265 SkString tmp;
266 reader->readString(&tmp);
267 reader->readString(&tmp);
256 // deprecated (M44) 268 // deprecated (M44)
257 break; 269 break;
270 }
258 case END_COMMENT_GROUP: 271 case END_COMMENT_GROUP:
259 // deprecated (M44) 272 // deprecated (M44)
260 break; 273 break;
261 case DRAW_IMAGE: { 274 case DRAW_IMAGE: {
262 const SkPaint* paint = fPictureData->getPaint(reader); 275 const SkPaint* paint = fPictureData->getPaint(reader);
263 const SkImage* image = fPictureData->getImage(reader); 276 const SkImage* image = fPictureData->getImage(reader);
264 const SkPoint& loc = reader->skipT<SkPoint>(); 277 SkPoint loc;
278 reader->readPoint(&loc);
265 canvas->drawImage(image, loc.fX, loc.fY, paint); 279 canvas->drawImage(image, loc.fX, loc.fY, paint);
266 } break; 280 } break;
267 case DRAW_IMAGE_NINE: { 281 case DRAW_IMAGE_NINE: {
268 const SkPaint* paint = fPictureData->getPaint(reader); 282 const SkPaint* paint = fPictureData->getPaint(reader);
269 const SkImage* image = fPictureData->getImage(reader); 283 const SkImage* image = fPictureData->getImage(reader);
270 const SkIRect& center = reader->skipT<SkIRect>(); 284 SkIRect center;
271 const SkRect& dst = reader->skipT<SkRect>(); 285 reader->readIRect(&center);
286 SkRect dst;
287 reader->readRect(&dst);
272 canvas->drawImageNine(image, center, dst, paint); 288 canvas->drawImageNine(image, center, dst, paint);
273 } break; 289 } break;
274 case DRAW_IMAGE_RECT_STRICT: 290 case DRAW_IMAGE_RECT_STRICT:
275 case DRAW_IMAGE_RECT: { 291 case DRAW_IMAGE_RECT: {
276 const SkPaint* paint = fPictureData->getPaint(reader); 292 const SkPaint* paint = fPictureData->getPaint(reader);
277 const SkImage* image = fPictureData->getImage(reader); 293 const SkImage* image = fPictureData->getImage(reader);
278 const SkRect* src = get_rect_ptr(reader); // may be null 294 SkRect storage;
279 const SkRect& dst = reader->skipT<SkRect>(); // required 295 const SkRect* src = get_rect_ptr(reader, &storage); // may be null
296 SkRect dst;
297 reader->readRect(&dst); // required
280 // DRAW_IMAGE_RECT_STRICT assumes this constraint, and doesn't store it 298 // DRAW_IMAGE_RECT_STRICT assumes this constraint, and doesn't store it
281 SkCanvas::SrcRectConstraint constraint = SkCanvas::kStrict_SrcRectCo nstraint; 299 SkCanvas::SrcRectConstraint constraint = SkCanvas::kStrict_SrcRectCo nstraint;
282 if (DRAW_IMAGE_RECT == op) { 300 if (DRAW_IMAGE_RECT == op) {
283 // newer op-code stores the constraint explicitly 301 // newer op-code stores the constraint explicitly
284 constraint = (SkCanvas::SrcRectConstraint)reader->readInt(); 302 constraint = (SkCanvas::SrcRectConstraint)reader->readInt();
285 } 303 }
286 canvas->legacy_drawImageRect(image, src, dst, paint, constraint); 304 canvas->legacy_drawImageRect(image, src, dst, paint, constraint);
287 } break; 305 } break;
288 case DRAW_OVAL: { 306 case DRAW_OVAL: {
289 const SkPaint& paint = *fPictureData->getPaint(reader); 307 const SkPaint& paint = *fPictureData->getPaint(reader);
290 canvas->drawOval(reader->skipT<SkRect>(), paint); 308 SkRect rect;
309 reader->readRect(&rect);
310 canvas->drawOval(rect, paint);
291 } break; 311 } break;
292 case DRAW_PAINT: 312 case DRAW_PAINT:
293 canvas->drawPaint(*fPictureData->getPaint(reader)); 313 canvas->drawPaint(*fPictureData->getPaint(reader));
294 break; 314 break;
295 case DRAW_PATCH: { 315 case DRAW_PATCH: {
296 const SkPaint& paint = *fPictureData->getPaint(reader); 316 const SkPaint& paint = *fPictureData->getPaint(reader);
297 317
298 const SkPoint* cubics = (const SkPoint*)reader->skip(SkPatchUtils::k NumCtrlPts * 318 const SkPoint* cubics = (const SkPoint*)reader->skip(SkPatchUtils::k NumCtrlPts *
299 sizeof(SkPoint) ); 319 sizeof(SkPoint) );
300 uint32_t flag = reader->readInt(); 320 uint32_t flag = reader->readInt();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 const SkScalar* xpos = (const SkScalar*)reader->skip((3 + xCount) * sizeof(SkScalar)); 395 const SkScalar* xpos = (const SkScalar*)reader->skip((3 + xCount) * sizeof(SkScalar));
376 const SkScalar top = *xpos++; 396 const SkScalar top = *xpos++;
377 const SkScalar bottom = *xpos++; 397 const SkScalar bottom = *xpos++;
378 const SkScalar constY = *xpos++; 398 const SkScalar constY = *xpos++;
379 if (!canvas->quickRejectY(top, bottom)) { 399 if (!canvas->quickRejectY(top, bottom)) {
380 canvas->drawPosTextH(text.text(), text.length(), xpos, constY, p aint); 400 canvas->drawPosTextH(text.text(), text.length(), xpos, constY, p aint);
381 } 401 }
382 } break; 402 } break;
383 case DRAW_RECT: { 403 case DRAW_RECT: {
384 const SkPaint& paint = *fPictureData->getPaint(reader); 404 const SkPaint& paint = *fPictureData->getPaint(reader);
385 canvas->drawRect(reader->skipT<SkRect>(), paint); 405 SkRect rect;
406 reader->readRect(&rect);
407 canvas->drawRect(rect, paint);
386 } break; 408 } break;
387 case DRAW_RRECT: { 409 case DRAW_RRECT: {
388 const SkPaint& paint = *fPictureData->getPaint(reader); 410 const SkPaint& paint = *fPictureData->getPaint(reader);
389 SkRRect rrect; 411 SkRRect rrect;
390 reader->readRRect(&rrect); 412 reader->readRRect(&rrect);
391 canvas->drawRRect(rrect, paint); 413 canvas->drawRRect(rrect, paint);
392 } break; 414 } break;
393 case DRAW_SPRITE: { 415 case DRAW_SPRITE: {
394 /* const SkPaint* paint = */ fPictureData->getPaint(reader); 416 /* const SkPaint* paint = */ fPictureData->getPaint(reader);
395 /* const SkBitmap bitmap = */ shallow_copy(fPictureData->getBitmap(r eader)); 417 /* const SkBitmap bitmap = */ shallow_copy(fPictureData->getBitmap(r eader));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 break; 494 break;
473 case SAVE: 495 case SAVE:
474 // SKPs with version < 29 also store a SaveFlags param. 496 // SKPs with version < 29 also store a SaveFlags param.
475 if (size > 4) { 497 if (size > 4) {
476 SkASSERT(8 == size); 498 SkASSERT(8 == size);
477 reader->readInt(); 499 reader->readInt();
478 } 500 }
479 canvas->save(); 501 canvas->save();
480 break; 502 break;
481 case SAVE_LAYER_SAVEFLAGS_DEPRECATED: { 503 case SAVE_LAYER_SAVEFLAGS_DEPRECATED: {
482 const SkRect* boundsPtr = get_rect_ptr(reader); 504 SkRect storage;
505 const SkRect* boundsPtr = get_rect_ptr(reader, &storage);
483 const SkPaint* paint = fPictureData->getPaint(reader); 506 const SkPaint* paint = fPictureData->getPaint(reader);
484 auto flags = SkCanvas::LegacySaveFlagsToSaveLayerFlags(reader->readI nt()); 507 auto flags = SkCanvas::LegacySaveFlagsToSaveLayerFlags(reader->readI nt());
485 canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, flags)); 508 canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, flags));
486 } break; 509 } break;
487 case SAVE_LAYER_SAVELAYERFLAGS_DEPRECATED_JAN_2016: { 510 case SAVE_LAYER_SAVELAYERFLAGS_DEPRECATED_JAN_2016: {
488 const SkRect* boundsPtr = get_rect_ptr(reader); 511 SkRect storage;
512 const SkRect* boundsPtr = get_rect_ptr(reader, &storage);
489 const SkPaint* paint = fPictureData->getPaint(reader); 513 const SkPaint* paint = fPictureData->getPaint(reader);
490 canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, reader->r eadInt())); 514 canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, reader->r eadInt()));
491 } break; 515 } break;
492 case SAVE_LAYER_SAVELAYERREC: { 516 case SAVE_LAYER_SAVELAYERREC: {
493 SkCanvas::SaveLayerRec rec(nullptr, nullptr, nullptr, 0); 517 SkCanvas::SaveLayerRec rec(nullptr, nullptr, nullptr, 0);
494 const uint32_t flatFlags = reader->readInt(); 518 const uint32_t flatFlags = reader->readInt();
519 SkRect bounds;
495 if (flatFlags & SAVELAYERREC_HAS_BOUNDS) { 520 if (flatFlags & SAVELAYERREC_HAS_BOUNDS) {
496 rec.fBounds = &reader->skipT<SkRect>(); 521 reader->readRect(&bounds);
522 rec.fBounds = &bounds;
497 } 523 }
498 if (flatFlags & SAVELAYERREC_HAS_PAINT) { 524 if (flatFlags & SAVELAYERREC_HAS_PAINT) {
499 rec.fPaint = fPictureData->getPaint(reader); 525 rec.fPaint = fPictureData->getPaint(reader);
500 } 526 }
501 if (flatFlags & SAVELAYERREC_HAS_BACKDROP) { 527 if (flatFlags & SAVELAYERREC_HAS_BACKDROP) {
502 const SkPaint* paint = fPictureData->getPaint(reader); 528 const SkPaint* paint = fPictureData->getPaint(reader);
503 rec.fBackdrop = paint->getImageFilter(); 529 rec.fBackdrop = paint->getImageFilter();
504 } 530 }
505 if (flatFlags & SAVELAYERREC_HAS_FLAGS) { 531 if (flatFlags & SAVELAYERREC_HAS_FLAGS) {
506 rec.fSaveLayerFlags = reader->readInt(); 532 rec.fSaveLayerFlags = reader->readInt();
(...skipping 18 matching lines...) Expand all
525 } break; 551 } break;
526 case TRANSLATE: { 552 case TRANSLATE: {
527 SkScalar dx = reader->readScalar(); 553 SkScalar dx = reader->readScalar();
528 SkScalar dy = reader->readScalar(); 554 SkScalar dy = reader->readScalar();
529 canvas->translate(dx, dy); 555 canvas->translate(dx, dy);
530 } break; 556 } break;
531 default: 557 default:
532 SkASSERTF(false, "Unknown draw type: %d", op); 558 SkASSERTF(false, "Unknown draw type: %d", op);
533 } 559 }
534 } 560 }
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