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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 int flagCount = (nullptr == lattice.fFlags) ? 0 : (lattice.fXCount + 1) * (l
attice.fYCount + 1); | 541 int flagCount = (nullptr == lattice.fFlags) ? 0 : (lattice.fXCount + 1) * (l
attice.fYCount + 1); |
542 size_t latticeSize = (1 + lattice.fXCount + 1 + lattice.fYCount + 1) * kUInt
32Size + | 542 size_t latticeSize = (1 + lattice.fXCount + 1 + lattice.fYCount + 1) * kUInt
32Size + |
543 SkAlign4(flagCount * sizeof(SkCanvas::Lattice::Flags)); | 543 SkAlign4(flagCount * sizeof(SkCanvas::Lattice::Flags))
+ sizeof(SkIRect); |
544 | 544 |
545 // op + paint index + image index + lattice + dst rect | 545 // op + paint index + image index + lattice + dst rect |
546 size_t size = 3 * kUInt32Size + latticeSize + sizeof(dst); | 546 size_t size = 3 * kUInt32Size + latticeSize + sizeof(dst); |
547 size_t initialOffset = this->addDraw(DRAW_IMAGE_LATTICE, &size); | 547 size_t initialOffset = this->addDraw(DRAW_IMAGE_LATTICE, &size); |
548 this->addPaintPtr(paint); | 548 this->addPaintPtr(paint); |
549 this->addImage(image); | 549 this->addImage(image); |
550 this->addInt(lattice.fXCount); | 550 this->addInt(lattice.fXCount); |
551 fWriter.writePad(lattice.fXDivs, lattice.fXCount * kUInt32Size); | 551 fWriter.writePad(lattice.fXDivs, lattice.fXCount * kUInt32Size); |
552 this->addInt(lattice.fYCount); | 552 this->addInt(lattice.fYCount); |
553 fWriter.writePad(lattice.fYDivs, lattice.fYCount * kUInt32Size); | 553 fWriter.writePad(lattice.fYDivs, lattice.fYCount * kUInt32Size); |
554 this->addInt(flagCount); | 554 this->addInt(flagCount); |
555 fWriter.writePad(lattice.fFlags, flagCount * sizeof(SkCanvas::Lattice::Flags
)); | 555 fWriter.writePad(lattice.fFlags, flagCount * sizeof(SkCanvas::Lattice::Flags
)); |
| 556 this->addIRect(lattice.fBounds); |
556 this->addRect(dst); | 557 this->addRect(dst); |
557 this->validate(initialOffset, size); | 558 this->validate(initialOffset, size); |
558 } | 559 } |
559 | 560 |
560 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x
, SkScalar y, | 561 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x
, SkScalar y, |
561 const SkPaint& paint) { | 562 const SkPaint& paint) { |
562 // op + paint index + length + 'length' worth of chars + x + y | 563 // op + paint index + length + 'length' worth of chars + x + y |
563 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); | 564 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); |
564 | 565 |
565 DrawType op = DRAW_TEXT; | 566 DrawType op = DRAW_TEXT; |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 addInt(SkToInt(byteLength)); | 986 addInt(SkToInt(byteLength)); |
986 fWriter.writePad(text, byteLength); | 987 fWriter.writePad(text, byteLength); |
987 } | 988 } |
988 | 989 |
989 void SkPictureRecord::addTextBlob(const SkTextBlob* blob) { | 990 void SkPictureRecord::addTextBlob(const SkTextBlob* blob) { |
990 // follow the convention of recording a 1-based index | 991 // follow the convention of recording a 1-based index |
991 this->addInt(find_or_append_uniqueID(fTextBlobRefs, blob) + 1); | 992 this->addInt(find_or_append_uniqueID(fTextBlobRefs, blob) + 1); |
992 } | 993 } |
993 | 994 |
994 /////////////////////////////////////////////////////////////////////////////// | 995 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |