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