Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: src/core/SkPictureRecord.cpp

Issue 463493002: SkCanvas::drawPatch param SkPoint[12] (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 fWriter.writePad(indices, indexCount * sizeof(uint16_t)); 1473 fWriter.writePad(indices, indexCount * sizeof(uint16_t));
1474 } 1474 }
1475 if (flags & DRAW_VERTICES_HAS_XFER) { 1475 if (flags & DRAW_VERTICES_HAS_XFER) {
1476 SkXfermode::Mode mode = SkXfermode::kModulate_Mode; 1476 SkXfermode::Mode mode = SkXfermode::kModulate_Mode;
1477 (void)xfer->asMode(&mode); 1477 (void)xfer->asMode(&mode);
1478 this->addInt(mode); 1478 this->addInt(mode);
1479 } 1479 }
1480 this->validate(initialOffset, size); 1480 this->validate(initialOffset, size);
1481 } 1481 }
1482 1482
1483 void SkPictureRecord::drawPatch(const SkPatch& patch, const SkPaint& paint) { 1483 void SkPictureRecord::drawPatch(const SkPoint cubics[12], const SkColor colors[4 ],
1484 const SkPoint texCoords[4], SkXfermode* xmode,
1485 const SkPaint& paint) {
1486 if (NULL == cubics) {
1487 return;
1488 }
1489
1484 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 1490 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
1485 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); 1491 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
1486 #endif 1492 #endif
1487 1493
1488 // op + paint index + patch 12 control points + patch 4 colors 1494 // op + paint index + patch 12 control points + flag + patch 4 colors + 4 te xture coordinates
1489 size_t size = 2 * kUInt32Size + SkPatch::kNumCtrlPts * sizeof(SkPoint) + 1495 size_t size = 2 * kUInt32Size + SkPatch::kNumCtrlPts * sizeof(SkPoint) + kUI nt32Size;
1490 SkPatch::kNumColors * sizeof(SkColor); 1496 uint32_t flag = 0;
1497 if (NULL != colors) {
1498 flag |= DRAW_VERTICES_HAS_COLORS;
1499 size += SkPatch::kNumCorners * sizeof(SkColor);
1500 }
1501 if (NULL != texCoords) {
1502 flag |= DRAW_VERTICES_HAS_TEXS;
1503 size += SkPatch::kNumCorners * sizeof(SkPoint);
1504 }
1505 if (NULL != xmode) {
1506 SkXfermode::Mode mode;
1507 if (xmode->asMode(&mode) && SkXfermode::kModulate_Mode != mode) {
1508 flag |= DRAW_VERTICES_HAS_XFER;
1509 size += kUInt32Size;
1510 }
1511 }
1512
1491 size_t initialOffset = this->addDraw(DRAW_PATCH, &size); 1513 size_t initialOffset = this->addDraw(DRAW_PATCH, &size);
1492 SkASSERT(initialOffset+getPaintOffset(DRAW_PATCH, size) == fWriter.bytesWrit ten()); 1514 SkASSERT(initialOffset+getPaintOffset(DRAW_PATCH, size) == fWriter.bytesWrit ten());
1493 this->addPaint(paint); 1515 this->addPaint(paint);
1494 this->addPatch(patch); 1516 this->addPatch(cubics);
1517 this->addInt(flag);
1518
1519 // write optional parameters
1520 if (NULL != colors) {
1521 fWriter.write(colors, SkPatch::kNumCorners * sizeof(SkColor));
1522 }
1523 if (NULL != texCoords) {
1524 fWriter.write(texCoords, SkPatch::kNumCorners * sizeof(SkPoint));
1525 }
1526 if (flag & DRAW_VERTICES_HAS_XFER) {
1527 SkXfermode::Mode mode = SkXfermode::kModulate_Mode;
1528 xmode->asMode(&mode);
1529 this->addInt(mode);
1530 }
1495 this->validate(initialOffset, size); 1531 this->validate(initialOffset, size);
1496 } 1532 }
1497 1533
1498 void SkPictureRecord::drawData(const void* data, size_t length) { 1534 void SkPictureRecord::drawData(const void* data, size_t length) {
1499 1535
1500 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 1536 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
1501 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); 1537 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
1502 #endif 1538 #endif
1503 1539
1504 // op + length + 'length' worth of data 1540 // op + length + 'length' worth of data
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 return fPathHeap->insert(path); 1655 return fPathHeap->insert(path);
1620 #else 1656 #else
1621 return fPathHeap->append(path); 1657 return fPathHeap->append(path);
1622 #endif 1658 #endif
1623 } 1659 }
1624 1660
1625 void SkPictureRecord::addPath(const SkPath& path) { 1661 void SkPictureRecord::addPath(const SkPath& path) {
1626 this->addInt(this->addPathToHeap(path)); 1662 this->addInt(this->addPathToHeap(path));
1627 } 1663 }
1628 1664
1629 void SkPictureRecord::addPatch(const SkPatch& patch) { 1665 void SkPictureRecord::addPatch(const SkPoint cubics[12]) {
1630 fWriter.writePatch(patch); 1666 fWriter.write(cubics, SkPatch::kNumCtrlPts * sizeof(SkPoint));
1631 } 1667 }
1632 1668
1633 void SkPictureRecord::addPicture(const SkPicture* picture) { 1669 void SkPictureRecord::addPicture(const SkPicture* picture) {
1634 int index = fPictureRefs.find(picture); 1670 int index = fPictureRefs.find(picture);
1635 if (index < 0) { // not found 1671 if (index < 0) { // not found
1636 index = fPictureRefs.count(); 1672 index = fPictureRefs.count();
1637 *fPictureRefs.append() = picture; 1673 *fPictureRefs.append() = picture;
1638 picture->ref(); 1674 picture->ref();
1639 } 1675 }
1640 // follow the convention of recording a 1-based index 1676 // follow the convention of recording a 1-based index
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 void SkPictureRecord::validateRegions() const { 1875 void SkPictureRecord::validateRegions() const {
1840 int count = fRegions.count(); 1876 int count = fRegions.count();
1841 SkASSERT((unsigned) count < 0x1000); 1877 SkASSERT((unsigned) count < 0x1000);
1842 for (int index = 0; index < count; index++) { 1878 for (int index = 0; index < count; index++) {
1843 const SkFlatData* region = fRegions[index]; 1879 const SkFlatData* region = fRegions[index];
1844 SkASSERT(region); 1880 SkASSERT(region);
1845 // region->validate(); 1881 // region->validate();
1846 } 1882 }
1847 } 1883 }
1848 #endif 1884 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698