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 "SkPatchUtils.h" |
10 #include "SkPictureData.h" | 10 #include "SkPictureData.h" |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 uint32_t flag = reader->readInt(); | 300 uint32_t flag = reader->readInt(); |
301 const SkColor* colors = nullptr; | 301 const SkColor* colors = nullptr; |
302 if (flag & DRAW_VERTICES_HAS_COLORS) { | 302 if (flag & DRAW_VERTICES_HAS_COLORS) { |
303 colors = (const SkColor*)reader->skip(SkPatchUtils::kNumCorners
* sizeof(SkColor)); | 303 colors = (const SkColor*)reader->skip(SkPatchUtils::kNumCorners
* sizeof(SkColor)); |
304 } | 304 } |
305 const SkPoint* texCoords = nullptr; | 305 const SkPoint* texCoords = nullptr; |
306 if (flag & DRAW_VERTICES_HAS_TEXS) { | 306 if (flag & DRAW_VERTICES_HAS_TEXS) { |
307 texCoords = (const SkPoint*)reader->skip(SkPatchUtils::kNumCorne
rs * | 307 texCoords = (const SkPoint*)reader->skip(SkPatchUtils::kNumCorne
rs * |
308 sizeof(SkPoint)); | 308 sizeof(SkPoint)); |
309 } | 309 } |
310 SkAutoTUnref<SkXfermode> xfer; | 310 sk_sp<SkXfermode> xfer; |
311 if (flag & DRAW_VERTICES_HAS_XFER) { | 311 if (flag & DRAW_VERTICES_HAS_XFER) { |
312 int mode = reader->readInt(); | 312 int mode = reader->readInt(); |
313 if (mode < 0 || mode > SkXfermode::kLastMode) { | 313 if (mode < 0 || mode > SkXfermode::kLastMode) { |
314 mode = SkXfermode::kModulate_Mode; | 314 mode = SkXfermode::kModulate_Mode; |
315 } | 315 } |
316 xfer.reset(SkXfermode::Create((SkXfermode::Mode)mode)); | 316 xfer = SkXfermode::Make((SkXfermode::Mode)mode); |
317 } | 317 } |
318 canvas->drawPatch(cubics, colors, texCoords, xfer, paint); | 318 canvas->drawPatch(cubics, colors, texCoords, std::move(xfer), paint)
; |
319 } break; | 319 } break; |
320 case DRAW_PATH: { | 320 case DRAW_PATH: { |
321 const SkPaint& paint = *fPictureData->getPaint(reader); | 321 const SkPaint& paint = *fPictureData->getPaint(reader); |
322 canvas->drawPath(fPictureData->getPath(reader), paint); | 322 canvas->drawPath(fPictureData->getPath(reader), paint); |
323 } break; | 323 } break; |
324 case DRAW_PICTURE: | 324 case DRAW_PICTURE: |
325 canvas->drawPicture(fPictureData->getPicture(reader)); | 325 canvas->drawPicture(fPictureData->getPicture(reader)); |
326 break; | 326 break; |
327 case DRAW_PICTURE_MATRIX_PAINT: { | 327 case DRAW_PICTURE_MATRIX_PAINT: { |
328 const SkPaint* paint = fPictureData->getPaint(reader); | 328 const SkPaint* paint = fPictureData->getPaint(reader); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 case DRAW_TEXT_ON_PATH: { | 428 case DRAW_TEXT_ON_PATH: { |
429 const SkPaint& paint = *fPictureData->getPaint(reader); | 429 const SkPaint& paint = *fPictureData->getPaint(reader); |
430 TextContainer text; | 430 TextContainer text; |
431 get_text(reader, &text); | 431 get_text(reader, &text); |
432 const SkPath& path = fPictureData->getPath(reader); | 432 const SkPath& path = fPictureData->getPath(reader); |
433 SkMatrix matrix; | 433 SkMatrix matrix; |
434 reader->readMatrix(&matrix); | 434 reader->readMatrix(&matrix); |
435 canvas->drawTextOnPath(text.text(), text.length(), path, &matrix, pa
int); | 435 canvas->drawTextOnPath(text.text(), text.length(), path, &matrix, pa
int); |
436 } break; | 436 } break; |
437 case DRAW_VERTICES: { | 437 case DRAW_VERTICES: { |
438 SkAutoTUnref<SkXfermode> xfer; | 438 sk_sp<SkXfermode> xfer; |
439 const SkPaint& paint = *fPictureData->getPaint(reader); | 439 const SkPaint& paint = *fPictureData->getPaint(reader); |
440 DrawVertexFlags flags = (DrawVertexFlags)reader->readInt(); | 440 DrawVertexFlags flags = (DrawVertexFlags)reader->readInt(); |
441 SkCanvas::VertexMode vmode = (SkCanvas::VertexMode)reader->readInt()
; | 441 SkCanvas::VertexMode vmode = (SkCanvas::VertexMode)reader->readInt()
; |
442 int vCount = reader->readInt(); | 442 int vCount = reader->readInt(); |
443 const SkPoint* verts = (const SkPoint*)reader->skip(vCount * sizeof(
SkPoint)); | 443 const SkPoint* verts = (const SkPoint*)reader->skip(vCount * sizeof(
SkPoint)); |
444 const SkPoint* texs = nullptr; | 444 const SkPoint* texs = nullptr; |
445 const SkColor* colors = nullptr; | 445 const SkColor* colors = nullptr; |
446 const uint16_t* indices = nullptr; | 446 const uint16_t* indices = nullptr; |
447 int iCount = 0; | 447 int iCount = 0; |
448 if (flags & DRAW_VERTICES_HAS_TEXS) { | 448 if (flags & DRAW_VERTICES_HAS_TEXS) { |
449 texs = (const SkPoint*)reader->skip(vCount * sizeof(SkPoint)); | 449 texs = (const SkPoint*)reader->skip(vCount * sizeof(SkPoint)); |
450 } | 450 } |
451 if (flags & DRAW_VERTICES_HAS_COLORS) { | 451 if (flags & DRAW_VERTICES_HAS_COLORS) { |
452 colors = (const SkColor*)reader->skip(vCount * sizeof(SkColor)); | 452 colors = (const SkColor*)reader->skip(vCount * sizeof(SkColor)); |
453 } | 453 } |
454 if (flags & DRAW_VERTICES_HAS_INDICES) { | 454 if (flags & DRAW_VERTICES_HAS_INDICES) { |
455 iCount = reader->readInt(); | 455 iCount = reader->readInt(); |
456 indices = (const uint16_t*)reader->skip(iCount * sizeof(uint16_t
)); | 456 indices = (const uint16_t*)reader->skip(iCount * sizeof(uint16_t
)); |
457 } | 457 } |
458 if (flags & DRAW_VERTICES_HAS_XFER) { | 458 if (flags & DRAW_VERTICES_HAS_XFER) { |
459 int mode = reader->readInt(); | 459 int mode = reader->readInt(); |
460 if (mode < 0 || mode > SkXfermode::kLastMode) { | 460 if (mode < 0 || mode > SkXfermode::kLastMode) { |
461 mode = SkXfermode::kModulate_Mode; | 461 mode = SkXfermode::kModulate_Mode; |
462 } | 462 } |
463 xfer.reset(SkXfermode::Create((SkXfermode::Mode)mode)); | 463 xfer = SkXfermode::Make((SkXfermode::Mode)mode); |
464 } | 464 } |
465 canvas->drawVertices(vmode, vCount, verts, texs, colors, xfer, indic
es, iCount, paint); | 465 canvas->drawVertices(vmode, vCount, verts, texs, colors, xfer, indic
es, iCount, paint); |
466 } break; | 466 } break; |
467 case RESTORE: | 467 case RESTORE: |
468 canvas->restore(); | 468 canvas->restore(); |
469 break; | 469 break; |
470 case ROTATE: | 470 case ROTATE: |
471 canvas->rotate(reader->readScalar()); | 471 canvas->rotate(reader->readScalar()); |
472 break; | 472 break; |
473 case SAVE: | 473 case SAVE: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 } break; | 525 } break; |
526 case TRANSLATE: { | 526 case TRANSLATE: { |
527 SkScalar dx = reader->readScalar(); | 527 SkScalar dx = reader->readScalar(); |
528 SkScalar dy = reader->readScalar(); | 528 SkScalar dy = reader->readScalar(); |
529 canvas->translate(dx, dy); | 529 canvas->translate(dx, dy); |
530 } break; | 530 } break; |
531 default: | 531 default: |
532 SkASSERTF(false, "Unknown draw type: %d", op); | 532 SkASSERTF(false, "Unknown draw type: %d", op); |
533 } | 533 } |
534 } | 534 } |
OLD | NEW |