OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkPictureRecord.h" | 8 #include "SkPictureRecord.h" |
9 #include "SkImage_Base.h" | 9 #include "SkImage_Base.h" |
10 #include "SkPatchUtils.h" | 10 #include "SkPatchUtils.h" |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 // op + paint_index + image_index + x + y | 503 // op + paint_index + image_index + x + y |
504 size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar); | 504 size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar); |
505 size_t initialOffset = this->addDraw(DRAW_IMAGE, &size); | 505 size_t initialOffset = this->addDraw(DRAW_IMAGE, &size); |
506 this->addPaintPtr(paint); | 506 this->addPaintPtr(paint); |
507 this->addImage(image); | 507 this->addImage(image); |
508 this->addScalar(x); | 508 this->addScalar(x); |
509 this->addScalar(y); | 509 this->addScalar(y); |
510 this->validate(initialOffset, size); | 510 this->validate(initialOffset, size); |
511 } | 511 } |
512 | 512 |
| 513 void SkPictureRecord::onDrawImageLattice(const SkImage* image, const Lattice& la
ttice, |
| 514 const SkRect& dst, const SkPaint* paint
) { |
| 515 // xCount + xDivs + yCount+ yDivs |
| 516 size_t latticeSize = (1 + lattice.fXCount + 1 + lattice.fYCount) * kUInt32Si
ze; |
| 517 |
| 518 // op + paint index + image index + lattice + dst rect |
| 519 size_t size = 3 * kUInt32Size + latticeSize + sizeof(dst); |
| 520 size_t initialOffset = this->addDraw(DRAW_IMAGE_LATTICE, &size); |
| 521 this->addPaintPtr(paint); |
| 522 this->addImage(image); |
| 523 this->addInt(lattice.fXCount); |
| 524 fWriter.writePad(lattice.fXDivs, lattice.fXCount * kUInt32Size); |
| 525 this->addInt(lattice.fYCount); |
| 526 fWriter.writePad(lattice.fYDivs, lattice.fYCount * kUInt32Size); |
| 527 this->addRect(dst); |
| 528 this->validate(initialOffset, size); |
| 529 } |
| 530 |
513 void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, c
onst SkRect& dst, | 531 void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, c
onst SkRect& dst, |
514 const SkPaint* paint, SrcRectConstraint co
nstraint) { | 532 const SkPaint* paint, SrcRectConstraint co
nstraint) { |
515 // id + paint_index + image_index + bool_for_src + constraint | 533 // id + paint_index + image_index + bool_for_src + constraint |
516 size_t size = 5 * kUInt32Size; | 534 size_t size = 5 * kUInt32Size; |
517 if (src) { | 535 if (src) { |
518 size += sizeof(*src); // + rect | 536 size += sizeof(*src); // + rect |
519 } | 537 } |
520 size += sizeof(dst); // + rect | 538 size += sizeof(dst); // + rect |
521 | 539 |
522 size_t initialOffset = this->addDraw(DRAW_IMAGE_RECT, &size); | 540 size_t initialOffset = this->addDraw(DRAW_IMAGE_RECT, &size); |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 | 1071 |
1054 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { | 1072 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { |
1055 int index = fTextBlobRefs.count(); | 1073 int index = fTextBlobRefs.count(); |
1056 *fTextBlobRefs.append() = blob; | 1074 *fTextBlobRefs.append() = blob; |
1057 blob->ref(); | 1075 blob->ref(); |
1058 // follow the convention of recording a 1-based index | 1076 // follow the convention of recording a 1-based index |
1059 this->addInt(index + 1); | 1077 this->addInt(index + 1); |
1060 } | 1078 } |
1061 | 1079 |
1062 /////////////////////////////////////////////////////////////////////////////// | 1080 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |