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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 this->addPaintPtr(paint); | 531 this->addPaintPtr(paint); |
532 this->addImage(img); | 532 this->addImage(img); |
533 this->addIRect(center); | 533 this->addIRect(center); |
534 this->addRect(dst); | 534 this->addRect(dst); |
535 this->validate(initialOffset, size); | 535 this->validate(initialOffset, size); |
536 } | 536 } |
537 | 537 |
538 void SkPictureRecord::onDrawImageLattice(const SkImage* image, const Lattice& la
ttice, | 538 void SkPictureRecord::onDrawImageLattice(const SkImage* image, const Lattice& la
ttice, |
539 const SkRect& dst, const SkPaint* paint
) { | 539 const SkRect& dst, const SkPaint* paint
) { |
540 // xCount + xDivs + yCount+ yDivs | 540 // xCount + xDivs + yCount+ yDivs |
541 size_t latticeSize = (1 + lattice.fXCount + 1 + lattice.fYCount) * kUInt32Si
ze; | 541 size_t latticeSize = (1 + lattice.fXCount + 1 + lattice.fYCount + 1) * kUInt
32Size + |
| 542 SkAlign4(lattice.fFlagCount * sizeof(SkCanvas::Lattice:
:Flags)); |
542 | 543 |
543 // op + paint index + image index + lattice + dst rect | 544 // op + paint index + image index + lattice + dst rect |
544 size_t size = 3 * kUInt32Size + latticeSize + sizeof(dst); | 545 size_t size = 3 * kUInt32Size + latticeSize + sizeof(dst); |
545 size_t initialOffset = this->addDraw(DRAW_IMAGE_LATTICE, &size); | 546 size_t initialOffset = this->addDraw(DRAW_IMAGE_LATTICE, &size); |
546 this->addPaintPtr(paint); | 547 this->addPaintPtr(paint); |
547 this->addImage(image); | 548 this->addImage(image); |
548 this->addInt(lattice.fXCount); | 549 this->addInt(lattice.fXCount); |
549 fWriter.writePad(lattice.fXDivs, lattice.fXCount * kUInt32Size); | 550 fWriter.writePad(lattice.fXDivs, lattice.fXCount * kUInt32Size); |
550 this->addInt(lattice.fYCount); | 551 this->addInt(lattice.fYCount); |
551 fWriter.writePad(lattice.fYDivs, lattice.fYCount * kUInt32Size); | 552 fWriter.writePad(lattice.fYDivs, lattice.fYCount * kUInt32Size); |
| 553 this->addInt(lattice.fFlagCount); |
| 554 fWriter.writePad(lattice.fFlags, lattice.fFlagCount * sizeof(SkCanvas::Latti
ce::Flags)); |
552 this->addRect(dst); | 555 this->addRect(dst); |
553 this->validate(initialOffset, size); | 556 this->validate(initialOffset, size); |
554 } | 557 } |
555 | 558 |
556 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x
, SkScalar y, | 559 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x
, SkScalar y, |
557 const SkPaint& paint) { | 560 const SkPaint& paint) { |
558 // op + paint index + length + 'length' worth of chars + x + y | 561 // op + paint index + length + 'length' worth of chars + x + y |
559 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); | 562 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); |
560 | 563 |
561 DrawType op = DRAW_TEXT; | 564 DrawType op = DRAW_TEXT; |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 addInt(SkToInt(byteLength)); | 984 addInt(SkToInt(byteLength)); |
982 fWriter.writePad(text, byteLength); | 985 fWriter.writePad(text, byteLength); |
983 } | 986 } |
984 | 987 |
985 void SkPictureRecord::addTextBlob(const SkTextBlob* blob) { | 988 void SkPictureRecord::addTextBlob(const SkTextBlob* blob) { |
986 // follow the convention of recording a 1-based index | 989 // follow the convention of recording a 1-based index |
987 this->addInt(find_or_append_uniqueID(fTextBlobRefs, blob) + 1); | 990 this->addInt(find_or_append_uniqueID(fTextBlobRefs, blob) + 1); |
988 } | 991 } |
989 | 992 |
990 /////////////////////////////////////////////////////////////////////////////// | 993 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |