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 "SkTSearch.h" | 9 #include "SkTSearch.h" |
10 #include "SkPixelRef.h" | 10 #include "SkPixelRef.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 0, // CLIP_RRECT - no paint | 86 0, // CLIP_RRECT - no paint |
87 0, // CONCAT - no paint | 87 0, // CONCAT - no paint |
88 1, // DRAW_BITMAP - right after op code | 88 1, // DRAW_BITMAP - right after op code |
89 1, // DRAW_BITMAP_MATRIX - right after op code | 89 1, // DRAW_BITMAP_MATRIX - right after op code |
90 1, // DRAW_BITMAP_NINE - right after op code | 90 1, // DRAW_BITMAP_NINE - right after op code |
91 1, // DRAW_BITMAP_RECT_TO_RECT - right after op code | 91 1, // DRAW_BITMAP_RECT_TO_RECT - right after op code |
92 0, // DRAW_CLEAR - no paint | 92 0, // DRAW_CLEAR - no paint |
93 0, // DRAW_DATA - no paint | 93 0, // DRAW_DATA - no paint |
94 1, // DRAW_OVAL - right after op code | 94 1, // DRAW_OVAL - right after op code |
95 1, // DRAW_PAINT - right after op code | 95 1, // DRAW_PAINT - right after op code |
| 96 1, // DRAW_PATCH - right after op code |
96 1, // DRAW_PATH - right after op code | 97 1, // DRAW_PATH - right after op code |
97 0, // DRAW_PICTURE - no paint | 98 0, // DRAW_PICTURE - no paint |
98 1, // DRAW_POINTS - right after op code | 99 1, // DRAW_POINTS - right after op code |
99 1, // DRAW_POS_TEXT - right after op code | 100 1, // DRAW_POS_TEXT - right after op code |
100 1, // DRAW_POS_TEXT_TOP_BOTTOM - right after op code | 101 1, // DRAW_POS_TEXT_TOP_BOTTOM - right after op code |
101 1, // DRAW_POS_TEXT_H - right after op code | 102 1, // DRAW_POS_TEXT_H - right after op code |
102 1, // DRAW_POS_TEXT_H_TOP_BOTTOM - right after op code | 103 1, // DRAW_POS_TEXT_H_TOP_BOTTOM - right after op code |
103 1, // DRAW_RECT - right after op code | 104 1, // DRAW_RECT - right after op code |
104 1, // DRAW_RRECT - right after op code | 105 1, // DRAW_RRECT - right after op code |
105 1, // DRAW_SPRITE - right after op code | 106 1, // DRAW_SPRITE - right after op code |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 fWriter.writePad(indices, indexCount * sizeof(uint16_t)); | 1474 fWriter.writePad(indices, indexCount * sizeof(uint16_t)); |
1474 } | 1475 } |
1475 if (flags & DRAW_VERTICES_HAS_XFER) { | 1476 if (flags & DRAW_VERTICES_HAS_XFER) { |
1476 SkXfermode::Mode mode = SkXfermode::kModulate_Mode; | 1477 SkXfermode::Mode mode = SkXfermode::kModulate_Mode; |
1477 (void)xfer->asMode(&mode); | 1478 (void)xfer->asMode(&mode); |
1478 this->addInt(mode); | 1479 this->addInt(mode); |
1479 } | 1480 } |
1480 this->validate(initialOffset, size); | 1481 this->validate(initialOffset, size); |
1481 } | 1482 } |
1482 | 1483 |
| 1484 void SkPictureRecord::drawPatch(const SkPatch& patch, const SkPaint& paint) { |
| 1485 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
| 1486 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); |
| 1487 #endif |
| 1488 |
| 1489 // op + paint index + patch 12 control points + patch 4 colors |
| 1490 size_t size = 2 * kUInt32Size + SkPatch::kNumCtrlPts * sizeof(SkPoint) + |
| 1491 SkPatch::kNumColors * sizeof(SkColor); |
| 1492 size_t initialOffset = this->addDraw(DRAW_PATCH, &size); |
| 1493 SkASSERT(initialOffset+getPaintOffset(DRAW_PATCH, size) == fWriter.bytesWrit
ten()); |
| 1494 this->addPaint(paint); |
| 1495 this->addPatch(patch); |
| 1496 this->validate(initialOffset, size); |
| 1497 } |
| 1498 |
1483 void SkPictureRecord::drawData(const void* data, size_t length) { | 1499 void SkPictureRecord::drawData(const void* data, size_t length) { |
1484 | 1500 |
1485 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 1501 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
1486 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | 1502 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); |
1487 #endif | 1503 #endif |
1488 | 1504 |
1489 // op + length + 'length' worth of data | 1505 // op + length + 'length' worth of data |
1490 size_t size = 2 * kUInt32Size + SkAlign4(length); | 1506 size_t size = 2 * kUInt32Size + SkAlign4(length); |
1491 size_t initialOffset = this->addDraw(DRAW_DATA, &size); | 1507 size_t initialOffset = this->addDraw(DRAW_DATA, &size); |
1492 this->addInt(SkToInt(length)); | 1508 this->addInt(SkToInt(length)); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 return fPathHeap->insert(path); | 1622 return fPathHeap->insert(path); |
1607 #else | 1623 #else |
1608 return fPathHeap->append(path); | 1624 return fPathHeap->append(path); |
1609 #endif | 1625 #endif |
1610 } | 1626 } |
1611 | 1627 |
1612 void SkPictureRecord::addPath(const SkPath& path) { | 1628 void SkPictureRecord::addPath(const SkPath& path) { |
1613 this->addInt(this->addPathToHeap(path)); | 1629 this->addInt(this->addPathToHeap(path)); |
1614 } | 1630 } |
1615 | 1631 |
| 1632 void SkPictureRecord::addPatch(const SkPatch& patch) { |
| 1633 fWriter.writePatch(patch); |
| 1634 } |
| 1635 |
1616 void SkPictureRecord::addPicture(const SkPicture* picture) { | 1636 void SkPictureRecord::addPicture(const SkPicture* picture) { |
1617 int index = fPictureRefs.find(picture); | 1637 int index = fPictureRefs.find(picture); |
1618 if (index < 0) { // not found | 1638 if (index < 0) { // not found |
1619 index = fPictureRefs.count(); | 1639 index = fPictureRefs.count(); |
1620 *fPictureRefs.append() = picture; | 1640 *fPictureRefs.append() = picture; |
1621 picture->ref(); | 1641 picture->ref(); |
1622 } | 1642 } |
1623 // follow the convention of recording a 1-based index | 1643 // follow the convention of recording a 1-based index |
1624 this->addInt(index + 1); | 1644 this->addInt(index + 1); |
1625 } | 1645 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 void SkPictureRecord::validateRegions() const { | 1841 void SkPictureRecord::validateRegions() const { |
1822 int count = fRegions.count(); | 1842 int count = fRegions.count(); |
1823 SkASSERT((unsigned) count < 0x1000); | 1843 SkASSERT((unsigned) count < 0x1000); |
1824 for (int index = 0; index < count; index++) { | 1844 for (int index = 0; index < count; index++) { |
1825 const SkFlatData* region = fRegions[index]; | 1845 const SkFlatData* region = fRegions[index]; |
1826 SkASSERT(region); | 1846 SkASSERT(region); |
1827 // region->validate(); | 1847 // region->validate(); |
1828 } | 1848 } |
1829 } | 1849 } |
1830 #endif | 1850 #endif |
OLD | NEW |