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 "SkDevice.h" | 9 #include "SkDevice.h" |
10 #include "SkImage_Base.h" | 10 #include "SkImage_Base.h" |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 size_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst); | 619 size_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst); |
620 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size); | 620 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size); |
621 SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_NINE, size) == fWriter.b
ytesWritten()); | 621 SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_NINE, size) == fWriter.b
ytesWritten()); |
622 this->addPaintPtr(paint); | 622 this->addPaintPtr(paint); |
623 this->addBitmap(bitmap); | 623 this->addBitmap(bitmap); |
624 this->addIRect(center); | 624 this->addIRect(center); |
625 this->addRect(dst); | 625 this->addRect(dst); |
626 this->validate(initialOffset, size); | 626 this->validate(initialOffset, size); |
627 } | 627 } |
628 | 628 |
629 void SkPictureRecord::onDrawSprite(const SkBitmap& bitmap, int left, int top, | |
630 const SkPaint* paint) { | |
631 // op + paint index + bitmap index + left + top | |
632 size_t size = 5 * kUInt32Size; | |
633 size_t initialOffset = this->addDraw(DRAW_SPRITE, &size); | |
634 SkASSERT(initialOffset+get_paint_offset(DRAW_SPRITE, size) == fWriter.bytesW
ritten()); | |
635 this->addPaintPtr(paint); | |
636 this->addBitmap(bitmap); | |
637 this->addInt(left); | |
638 this->addInt(top); | |
639 this->validate(initialOffset, size); | |
640 } | |
641 | |
642 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x
, SkScalar y, | 629 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x
, SkScalar y, |
643 const SkPaint& paint) { | 630 const SkPaint& paint) { |
644 // op + paint index + length + 'length' worth of chars + x + y | 631 // op + paint index + length + 'length' worth of chars + x + y |
645 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); | 632 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); |
646 | 633 |
647 DrawType op = DRAW_TEXT; | 634 DrawType op = DRAW_TEXT; |
648 size_t initialOffset = this->addDraw(op, &size); | 635 size_t initialOffset = this->addDraw(op, &size); |
649 SkASSERT(initialOffset+get_paint_offset(op, size) == fWriter.bytesWritten())
; | 636 SkASSERT(initialOffset+get_paint_offset(op, size) == fWriter.bytesWritten())
; |
650 this->addPaint(paint); | 637 this->addPaint(paint); |
651 this->addText(text, byteLength); | 638 this->addText(text, byteLength); |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { | 1051 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { |
1065 int index = fTextBlobRefs.count(); | 1052 int index = fTextBlobRefs.count(); |
1066 *fTextBlobRefs.append() = blob; | 1053 *fTextBlobRefs.append() = blob; |
1067 blob->ref(); | 1054 blob->ref(); |
1068 // follow the convention of recording a 1-based index | 1055 // follow the convention of recording a 1-based index |
1069 this->addInt(index + 1); | 1056 this->addInt(index + 1); |
1070 } | 1057 } |
1071 | 1058 |
1072 /////////////////////////////////////////////////////////////////////////////// | 1059 /////////////////////////////////////////////////////////////////////////////// |
1073 | 1060 |
OLD | NEW |