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 "SkCanvasPriv.h" |
8 #include "SkPictureRecord.h" | 9 #include "SkPictureRecord.h" |
9 #include "SkImage_Base.h" | 10 #include "SkImage_Base.h" |
10 #include "SkPatchUtils.h" | 11 #include "SkPatchUtils.h" |
11 #include "SkPixelRef.h" | 12 #include "SkPixelRef.h" |
12 #include "SkRRect.h" | 13 #include "SkRRect.h" |
13 #include "SkRSXform.h" | 14 #include "SkRSXform.h" |
14 #include "SkTextBlob.h" | 15 #include "SkTextBlob.h" |
15 #include "SkTSearch.h" | 16 #include "SkTSearch.h" |
16 | 17 |
17 #define HEAP_BLOCK_SIZE 4096 | 18 #define HEAP_BLOCK_SIZE 4096 |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 // op + paint index + bitmap id + center + dst rect | 535 // op + paint index + bitmap id + center + dst rect |
535 size_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst); | 536 size_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst); |
536 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size); | 537 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size); |
537 this->addPaintPtr(paint); | 538 this->addPaintPtr(paint); |
538 this->addBitmap(bitmap); | 539 this->addBitmap(bitmap); |
539 this->addIRect(center); | 540 this->addIRect(center); |
540 this->addRect(dst); | 541 this->addRect(dst); |
541 this->validate(initialOffset, size); | 542 this->validate(initialOffset, size); |
542 } | 543 } |
543 | 544 |
| 545 void SkPictureRecord::onDrawBitmapNine(const SkBitmap& bitmap, const NinePatchDi
vs& divs, |
| 546 const SkRect& dst, const SkPaint* paint)
{ |
| 547 // dataLen + xCount + yCount + xDivs + yDivs |
| 548 // It is unnecesary to store the dataLen (it can be determined from xCount a
nd yCount), |
| 549 // but it is convenient to use the read/write data helpers. |
| 550 size_t divsSize = (1 + 1 + 1 + divs.fXCount + divs.fYCount) * kUInt32Size; |
| 551 |
| 552 // op + paint index + bitmap id + divs + dst rect |
| 553 size_t size = 3 * kUInt32Size + divsSize + sizeof(dst); |
| 554 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE_DIVS, &size); |
| 555 this->addPaintPtr(paint); |
| 556 this->addBitmap(bitmap); |
| 557 fWriter.writeData(((const SkNinePatchDivs&) divs).asData().get()); |
| 558 this->addRect(dst); |
| 559 this->validate(initialOffset, size); |
| 560 } |
| 561 |
544 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x
, SkScalar y, | 562 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x
, SkScalar y, |
545 const SkPaint& paint) { | 563 const SkPaint& paint) { |
546 // op + paint index + length + 'length' worth of chars + x + y | 564 // op + paint index + length + 'length' worth of chars + x + y |
547 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); | 565 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); |
548 | 566 |
549 DrawType op = DRAW_TEXT; | 567 DrawType op = DRAW_TEXT; |
550 size_t initialOffset = this->addDraw(op, &size); | 568 size_t initialOffset = this->addDraw(op, &size); |
551 this->addPaint(paint); | 569 this->addPaint(paint); |
552 this->addText(text, byteLength); | 570 this->addText(text, byteLength); |
553 this->addScalar(x); | 571 this->addScalar(x); |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 | 1038 |
1021 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { | 1039 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { |
1022 int index = fTextBlobRefs.count(); | 1040 int index = fTextBlobRefs.count(); |
1023 *fTextBlobRefs.append() = blob; | 1041 *fTextBlobRefs.append() = blob; |
1024 blob->ref(); | 1042 blob->ref(); |
1025 // follow the convention of recording a 1-based index | 1043 // follow the convention of recording a 1-based index |
1026 this->addInt(index + 1); | 1044 this->addInt(index + 1); |
1027 } | 1045 } |
1028 | 1046 |
1029 /////////////////////////////////////////////////////////////////////////////// | 1047 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |