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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); | 596 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); |
597 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.write
ToMemory(nullptr); | 597 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.write
ToMemory(nullptr); |
598 size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size); | 598 size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size); |
599 this->addPaint(paint); | 599 this->addPaint(paint); |
600 this->addText(text, byteLength); | 600 this->addText(text, byteLength); |
601 this->addPath(path); | 601 this->addPath(path); |
602 this->addMatrix(m); | 602 this->addMatrix(m); |
603 this->validate(initialOffset, size); | 603 this->validate(initialOffset, size); |
604 } | 604 } |
605 | 605 |
| 606 void SkPictureRecord::onDrawTextRSXform(const void* text, size_t byteLength, |
| 607 const SkRSXform xform[], const SkRect* c
ull, |
| 608 const SkPaint& paint) { |
| 609 const int count = paint.countText(text, byteLength); |
| 610 // [op + paint-index + count + flags + length] + [text] + [xform] + cull |
| 611 size_t size = 5 * kUInt32Size + SkAlign4(byteLength) + count * sizeof(SkRSXf
orm); |
| 612 uint32_t flags = 0; |
| 613 if (cull) { |
| 614 flags |= DRAW_TEXT_RSXFORM_HAS_CULL; |
| 615 size += sizeof(SkRect); |
| 616 } |
| 617 |
| 618 size_t initialOffset = this->addDraw(DRAW_TEXT_RSXFORM, &size); |
| 619 this->addPaint(paint); |
| 620 this->addInt(count); |
| 621 this->addInt(flags); |
| 622 this->addText(text, byteLength); |
| 623 fWriter.write(xform, count * sizeof(SkRSXform)); |
| 624 if (cull) { |
| 625 fWriter.write(cull, sizeof(SkRect)); |
| 626 } |
| 627 this->validate(initialOffset, size); |
| 628 } |
| 629 |
606 void SkPictureRecord::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScala
r y, | 630 void SkPictureRecord::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScala
r y, |
607 const SkPaint& paint) { | 631 const SkPaint& paint) { |
608 | 632 |
609 // op + paint index + blob index + x/y | 633 // op + paint index + blob index + x/y |
610 size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar); | 634 size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar); |
611 size_t initialOffset = this->addDraw(DRAW_TEXT_BLOB, &size); | 635 size_t initialOffset = this->addDraw(DRAW_TEXT_BLOB, &size); |
612 | 636 |
613 this->addPaint(paint); | 637 this->addPaint(paint); |
614 this->addTextBlob(blob); | 638 this->addTextBlob(blob); |
615 this->addScalar(x); | 639 this->addScalar(x); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 | 1020 |
997 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { | 1021 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { |
998 int index = fTextBlobRefs.count(); | 1022 int index = fTextBlobRefs.count(); |
999 *fTextBlobRefs.append() = blob; | 1023 *fTextBlobRefs.append() = blob; |
1000 blob->ref(); | 1024 blob->ref(); |
1001 // follow the convention of recording a 1-based index | 1025 // follow the convention of recording a 1-based index |
1002 this->addInt(index + 1); | 1026 this->addInt(index + 1); |
1003 } | 1027 } |
1004 | 1028 |
1005 /////////////////////////////////////////////////////////////////////////////// | 1029 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |