OLD | NEW |
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 "SkPictureData.h" | 10 #include "SkPictureData.h" |
10 #include "SkPicturePlayback.h" | 11 #include "SkPicturePlayback.h" |
11 #include "SkPictureRecord.h" | 12 #include "SkPictureRecord.h" |
12 #include "SkPictureStateTree.h" | 13 #include "SkPictureStateTree.h" |
13 #include "SkReader32.h" | 14 #include "SkReader32.h" |
14 #include "SkTDArray.h" | 15 #include "SkTDArray.h" |
15 #include "SkTypes.h" | 16 #include "SkTypes.h" |
16 | 17 |
17 /* | 18 /* |
18 * Read the next op code and chunk size from 'reader'. The returned size | 19 * Read the next op code and chunk size from 'reader'. The returned size |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } break; | 302 } break; |
302 case DRAW_OVAL: { | 303 case DRAW_OVAL: { |
303 const SkPaint& paint = *fPictureData->getPaint(reader); | 304 const SkPaint& paint = *fPictureData->getPaint(reader); |
304 canvas->drawOval(reader->skipT<SkRect>(), paint); | 305 canvas->drawOval(reader->skipT<SkRect>(), paint); |
305 } break; | 306 } break; |
306 case DRAW_PAINT: | 307 case DRAW_PAINT: |
307 canvas->drawPaint(*fPictureData->getPaint(reader)); | 308 canvas->drawPaint(*fPictureData->getPaint(reader)); |
308 break; | 309 break; |
309 case DRAW_PATCH: { | 310 case DRAW_PATCH: { |
310 const SkPaint& paint = *fPictureData->getPaint(reader); | 311 const SkPaint& paint = *fPictureData->getPaint(reader); |
311 SkPatch patch; | 312 |
312 reader->readPatch(&patch); | 313 const SkPoint* cubics = (const SkPoint*)reader->skip(SkPatchUtils::k
NumCtrlPts * |
313 canvas->drawPatch(patch, paint); | 314 sizeof(SkPoint)
); |
| 315 uint32_t flag = reader->readInt(); |
| 316 const SkColor* colors = NULL; |
| 317 if (flag & DRAW_VERTICES_HAS_COLORS) { |
| 318 colors = (const SkColor*)reader->skip(SkPatchUtils::kNumCorners
* sizeof(SkColor)); |
| 319 } |
| 320 const SkPoint* texCoords = NULL; |
| 321 if (flag & DRAW_VERTICES_HAS_TEXS) { |
| 322 texCoords = (const SkPoint*)reader->skip(SkPatchUtils::kNumCorne
rs * |
| 323 sizeof(SkPoint)); |
| 324 } |
| 325 SkAutoTUnref<SkXfermode> xfer; |
| 326 if (flag & DRAW_VERTICES_HAS_XFER) { |
| 327 int mode = reader->readInt(); |
| 328 if (mode < 0 || mode > SkXfermode::kLastMode) { |
| 329 mode = SkXfermode::kModulate_Mode; |
| 330 } |
| 331 xfer.reset(SkXfermode::Create((SkXfermode::Mode)mode)); |
| 332 } |
| 333 canvas->drawPatch(cubics, colors, texCoords, xfer, paint); |
314 } break; | 334 } break; |
315 case DRAW_PATH: { | 335 case DRAW_PATH: { |
316 const SkPaint& paint = *fPictureData->getPaint(reader); | 336 const SkPaint& paint = *fPictureData->getPaint(reader); |
317 canvas->drawPath(fPictureData->getPath(reader), paint); | 337 canvas->drawPath(fPictureData->getPath(reader), paint); |
318 } break; | 338 } break; |
319 case DRAW_PICTURE: | 339 case DRAW_PICTURE: |
320 canvas->drawPicture(fPictureData->getPicture(reader)); | 340 canvas->drawPicture(fPictureData->getPicture(reader)); |
321 break; | 341 break; |
322 case DRAW_PICTURE_MATRIX_PAINT: { | 342 case DRAW_PICTURE_MATRIX_PAINT: { |
323 const SkPicture* pic = fPictureData->getPicture(reader); | 343 const SkPicture* pic = fPictureData->getPicture(reader); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 case TRANSLATE: { | 510 case TRANSLATE: { |
491 SkScalar dx = reader->readScalar(); | 511 SkScalar dx = reader->readScalar(); |
492 SkScalar dy = reader->readScalar(); | 512 SkScalar dy = reader->readScalar(); |
493 canvas->translate(dx, dy); | 513 canvas->translate(dx, dy); |
494 } break; | 514 } break; |
495 default: | 515 default: |
496 SkASSERT(0); | 516 SkASSERT(0); |
497 } | 517 } |
498 } | 518 } |
499 | 519 |
OLD | NEW |