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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 0, // SET_MATRIX - no paint | 115 0, // SET_MATRIX - no paint |
116 0, // SKEW - no paint | 116 0, // SKEW - no paint |
117 0, // TRANSLATE - no paint | 117 0, // TRANSLATE - no paint |
118 0, // NOOP - no paint | 118 0, // NOOP - no paint |
119 0, // BEGIN_GROUP - no paint | 119 0, // BEGIN_GROUP - no paint |
120 0, // COMMENT - no paint | 120 0, // COMMENT - no paint |
121 0, // END_GROUP - no paint | 121 0, // END_GROUP - no paint |
122 1, // DRAWDRRECT - right after op code | 122 1, // DRAWDRRECT - right after op code |
123 0, // PUSH_CULL - no paint | 123 0, // PUSH_CULL - no paint |
124 0, // POP_CULL - no paint | 124 0, // POP_CULL - no paint |
| 125 1, // DRAW_PATCH - right after op code |
125 }; | 126 }; |
126 | 127 |
127 SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1, | 128 SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1, |
128 need_to_be_in_sync); | 129 need_to_be_in_sync); |
129 SkASSERT((unsigned)op <= (unsigned)LAST_DRAWTYPE_ENUM); | 130 SkASSERT((unsigned)op <= (unsigned)LAST_DRAWTYPE_ENUM); |
130 | 131 |
131 int overflow = 0; | 132 int overflow = 0; |
132 if (0 != (opSize & ~MASK_24) || opSize == MASK_24) { | 133 if (0 != (opSize & ~MASK_24) || opSize == MASK_24) { |
133 // This op's size overflows so an extra uint32_t will be written | 134 // This op's size overflows so an extra uint32_t will be written |
134 // after the op code | 135 // after the op code |
(...skipping 1338 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 |