Chromium Code Reviews| 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 //TODO: drawPatch | |
|
mtklein
2014/08/04 18:23:03
?
dandov
2014/08/04 19:59:27
Done.
| |
| 1486 | |
| 1487 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
| 1488 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
| 1489 #endif | |
| 1490 | |
| 1491 // op + paint index + path index | |
|
mtklein
2014/08/04 18:23:03
please update comment
dandov
2014/08/04 19:59:27
Done.
| |
| 1492 size_t size = 2 * kUInt32Size + 12 * sizeof(SkPoint) + 4 * sizeof(SkColor); | |
| 1493 size_t initialOffset = this->addDraw(DRAW_PATCH, &size); | |
| 1494 SkASSERT(initialOffset+getPaintOffset(DRAW_PATCH, size) == fWriter.bytesWrit ten()); | |
| 1495 this->addPaint(paint); | |
| 1496 this->addPatch(patch); | |
| 1497 this->validate(initialOffset, size); | |
| 1498 } | |
| 1499 | |
| 1483 void SkPictureRecord::drawData(const void* data, size_t length) { | 1500 void SkPictureRecord::drawData(const void* data, size_t length) { |
| 1484 | 1501 |
| 1485 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 1502 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
| 1486 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | 1503 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); |
| 1487 #endif | 1504 #endif |
| 1488 | 1505 |
| 1489 // op + length + 'length' worth of data | 1506 // op + length + 'length' worth of data |
| 1490 size_t size = 2 * kUInt32Size + SkAlign4(length); | 1507 size_t size = 2 * kUInt32Size + SkAlign4(length); |
| 1491 size_t initialOffset = this->addDraw(DRAW_DATA, &size); | 1508 size_t initialOffset = this->addDraw(DRAW_DATA, &size); |
| 1492 this->addInt(SkToInt(length)); | 1509 this->addInt(SkToInt(length)); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1606 return fPathHeap->insert(path); | 1623 return fPathHeap->insert(path); |
| 1607 #else | 1624 #else |
| 1608 return fPathHeap->append(path); | 1625 return fPathHeap->append(path); |
| 1609 #endif | 1626 #endif |
| 1610 } | 1627 } |
| 1611 | 1628 |
| 1612 void SkPictureRecord::addPath(const SkPath& path) { | 1629 void SkPictureRecord::addPath(const SkPath& path) { |
| 1613 this->addInt(this->addPathToHeap(path)); | 1630 this->addInt(this->addPathToHeap(path)); |
| 1614 } | 1631 } |
| 1615 | 1632 |
| 1633 void SkPictureRecord::addPatch(const SkPatch& patch) { | |
|
mtklein
2014/08/04 18:23:03
Isn't this just fWriter.writePatch(patch); ?
dandov
2014/08/04 19:59:27
Done.
| |
| 1634 const SkPoint* pts = patch.getControlPoints(); | |
| 1635 for (int i = 0; i < 12; i++) { | |
| 1636 this->addPoint(pts[i]); | |
| 1637 } | |
| 1638 | |
| 1639 const SkColor* colors = patch.getColors(); | |
| 1640 for (int i = 0; i < 4; i++) { | |
| 1641 this->addInt(colors[i]); | |
| 1642 } | |
| 1643 } | |
| 1644 | |
| 1616 void SkPictureRecord::addPicture(const SkPicture* picture) { | 1645 void SkPictureRecord::addPicture(const SkPicture* picture) { |
| 1617 int index = fPictureRefs.find(picture); | 1646 int index = fPictureRefs.find(picture); |
| 1618 if (index < 0) { // not found | 1647 if (index < 0) { // not found |
| 1619 index = fPictureRefs.count(); | 1648 index = fPictureRefs.count(); |
| 1620 *fPictureRefs.append() = picture; | 1649 *fPictureRefs.append() = picture; |
| 1621 picture->ref(); | 1650 picture->ref(); |
| 1622 } | 1651 } |
| 1623 // follow the convention of recording a 1-based index | 1652 // follow the convention of recording a 1-based index |
| 1624 this->addInt(index + 1); | 1653 this->addInt(index + 1); |
| 1625 } | 1654 } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1821 void SkPictureRecord::validateRegions() const { | 1850 void SkPictureRecord::validateRegions() const { |
| 1822 int count = fRegions.count(); | 1851 int count = fRegions.count(); |
| 1823 SkASSERT((unsigned) count < 0x1000); | 1852 SkASSERT((unsigned) count < 0x1000); |
| 1824 for (int index = 0; index < count; index++) { | 1853 for (int index = 0; index < count; index++) { |
| 1825 const SkFlatData* region = fRegions[index]; | 1854 const SkFlatData* region = fRegions[index]; |
| 1826 SkASSERT(region); | 1855 SkASSERT(region); |
| 1827 // region->validate(); | 1856 // region->validate(); |
| 1828 } | 1857 } |
| 1829 } | 1858 } |
| 1830 #endif | 1859 #endif |
| OLD | NEW |