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 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 this->addPaint(paint); | 964 this->addPaint(paint); |
965 this->validate(initialOffset, size); | 965 this->validate(initialOffset, size); |
966 } | 966 } |
967 | 967 |
968 void SkPictureRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts
[], | 968 void SkPictureRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts
[], |
969 const SkPaint& paint) { | 969 const SkPaint& paint) { |
970 | 970 |
971 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 971 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
972 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | 972 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); |
973 #endif | 973 #endif |
| 974 fContentInfo.onDrawPoints(count, paint); |
974 | 975 |
975 // op + paint index + mode + count + point data | 976 // op + paint index + mode + count + point data |
976 size_t size = 4 * kUInt32Size + count * sizeof(SkPoint); | 977 size_t size = 4 * kUInt32Size + count * sizeof(SkPoint); |
977 size_t initialOffset = this->addDraw(DRAW_POINTS, &size); | 978 size_t initialOffset = this->addDraw(DRAW_POINTS, &size); |
978 SkASSERT(initialOffset+getPaintOffset(DRAW_POINTS, size) == fWriter.bytesWri
tten()); | 979 SkASSERT(initialOffset+getPaintOffset(DRAW_POINTS, size) == fWriter.bytesWri
tten()); |
979 this->addPaint(paint); | 980 this->addPaint(paint); |
980 if (paint.getPathEffect() != NULL) { | 981 |
981 SkPathEffect::DashInfo info; | |
982 SkPathEffect::DashType dashType = paint.getPathEffect()->asADash(&info); | |
983 if (2 == count && SkPaint::kRound_Cap != paint.getStrokeCap() && | |
984 SkPathEffect::kDash_DashType == dashType && 2 == info.fCount) { | |
985 fContentInfo.incFastPathDashEffects(); | |
986 } | |
987 } | |
988 this->addInt(mode); | 982 this->addInt(mode); |
989 this->addInt(SkToInt(count)); | 983 this->addInt(SkToInt(count)); |
990 fWriter.writeMul4(pts, count * sizeof(SkPoint)); | 984 fWriter.writeMul4(pts, count * sizeof(SkPoint)); |
991 this->validate(initialOffset, size); | 985 this->validate(initialOffset, size); |
992 } | 986 } |
993 | 987 |
994 void SkPictureRecord::drawOval(const SkRect& oval, const SkPaint& paint) { | 988 void SkPictureRecord::drawOval(const SkRect& oval, const SkPaint& paint) { |
995 | 989 |
996 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 990 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
997 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | 991 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 size_t initialOffset = this->addDraw(DRAW_DRRECT, &size); | 1048 size_t initialOffset = this->addDraw(DRAW_DRRECT, &size); |
1055 SkASSERT(initialOffset+getPaintOffset(DRAW_DRRECT, size) == fWriter.bytesWri
tten()); | 1049 SkASSERT(initialOffset+getPaintOffset(DRAW_DRRECT, size) == fWriter.bytesWri
tten()); |
1056 this->addPaint(paint); | 1050 this->addPaint(paint); |
1057 this->addRRect(outer); | 1051 this->addRRect(outer); |
1058 this->addRRect(inner); | 1052 this->addRRect(inner); |
1059 this->validate(initialOffset, size); | 1053 this->validate(initialOffset, size); |
1060 } | 1054 } |
1061 | 1055 |
1062 void SkPictureRecord::drawPath(const SkPath& path, const SkPaint& paint) { | 1056 void SkPictureRecord::drawPath(const SkPath& path, const SkPaint& paint) { |
1063 | 1057 |
1064 if (paint.isAntiAlias() && !path.isConvex()) { | 1058 fContentInfo.onDrawPath(path, paint); |
1065 fContentInfo.incAAConcavePaths(); | |
1066 | |
1067 if (SkPaint::kStroke_Style == paint.getStyle() && | |
1068 0 == paint.getStrokeWidth()) { | |
1069 fContentInfo.incAAHairlineConcavePaths(); | |
1070 } | |
1071 } | |
1072 | 1059 |
1073 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 1060 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
1074 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | 1061 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); |
1075 #endif | 1062 #endif |
1076 | 1063 |
1077 // op + paint index + path index | 1064 // op + paint index + path index |
1078 size_t size = 3 * kUInt32Size; | 1065 size_t size = 3 * kUInt32Size; |
1079 size_t initialOffset = this->addDraw(DRAW_PATH, &size); | 1066 size_t initialOffset = this->addDraw(DRAW_PATH, &size); |
1080 SkASSERT(initialOffset+getPaintOffset(DRAW_PATH, size) == fWriter.bytesWritt
en()); | 1067 SkASSERT(initialOffset+getPaintOffset(DRAW_PATH, size) == fWriter.bytesWritt
en()); |
1081 this->addPaint(paint); | 1068 this->addPaint(paint); |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 | 1564 |
1578 void SkPictureRecord::addMatrix(const SkMatrix& matrix) { | 1565 void SkPictureRecord::addMatrix(const SkMatrix& matrix) { |
1579 fWriter.writeMatrix(matrix); | 1566 fWriter.writeMatrix(matrix); |
1580 } | 1567 } |
1581 | 1568 |
1582 const SkFlatData* SkPictureRecord::getFlatPaintData(const SkPaint& paint) { | 1569 const SkFlatData* SkPictureRecord::getFlatPaintData(const SkPaint& paint) { |
1583 return fPaints.findAndReturnFlat(paint); | 1570 return fPaints.findAndReturnFlat(paint); |
1584 } | 1571 } |
1585 | 1572 |
1586 const SkFlatData* SkPictureRecord::addPaintPtr(const SkPaint* paint) { | 1573 const SkFlatData* SkPictureRecord::addPaintPtr(const SkPaint* paint) { |
1587 if (NULL != paint && NULL != paint->getPathEffect()) { | 1574 fContentInfo.onAddPaintPtr(paint); |
1588 fContentInfo.incPaintWithPathEffectUses(); | |
1589 } | |
1590 | 1575 |
1591 const SkFlatData* data = paint ? getFlatPaintData(*paint) : NULL; | 1576 const SkFlatData* data = paint ? getFlatPaintData(*paint) : NULL; |
1592 this->addFlatPaint(data); | 1577 this->addFlatPaint(data); |
1593 return data; | 1578 return data; |
1594 } | 1579 } |
1595 | 1580 |
1596 void SkPictureRecord::addFlatPaint(const SkFlatData* flatPaint) { | 1581 void SkPictureRecord::addFlatPaint(const SkFlatData* flatPaint) { |
1597 int index = flatPaint ? flatPaint->index() : 0; | 1582 int index = flatPaint ? flatPaint->index() : 0; |
1598 this->addInt(index); | 1583 this->addInt(index); |
1599 } | 1584 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 | 1662 |
1678 void SkPictureRecord::addRRect(const SkRRect& rrect) { | 1663 void SkPictureRecord::addRRect(const SkRRect& rrect) { |
1679 fWriter.writeRRect(rrect); | 1664 fWriter.writeRRect(rrect); |
1680 } | 1665 } |
1681 | 1666 |
1682 void SkPictureRecord::addRegion(const SkRegion& region) { | 1667 void SkPictureRecord::addRegion(const SkRegion& region) { |
1683 fWriter.writeRegion(region); | 1668 fWriter.writeRegion(region); |
1684 } | 1669 } |
1685 | 1670 |
1686 void SkPictureRecord::addText(const void* text, size_t byteLength) { | 1671 void SkPictureRecord::addText(const void* text, size_t byteLength) { |
| 1672 fContentInfo.onDrawText(); |
1687 #ifdef SK_DEBUG_SIZE | 1673 #ifdef SK_DEBUG_SIZE |
1688 size_t start = fWriter.bytesWritten(); | 1674 size_t start = fWriter.bytesWritten(); |
1689 #endif | 1675 #endif |
1690 addInt(SkToInt(byteLength)); | 1676 addInt(SkToInt(byteLength)); |
1691 fWriter.writePad(text, byteLength); | 1677 fWriter.writePad(text, byteLength); |
1692 #ifdef SK_DEBUG_SIZE | 1678 #ifdef SK_DEBUG_SIZE |
1693 fTextBytes += fWriter.bytesWritten() - start; | 1679 fTextBytes += fWriter.bytesWritten() - start; |
1694 fTextWrites++; | 1680 fTextWrites++; |
1695 #endif | 1681 #endif |
1696 } | 1682 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 void SkPictureRecord::validateRegions() const { | 1807 void SkPictureRecord::validateRegions() const { |
1822 int count = fRegions.count(); | 1808 int count = fRegions.count(); |
1823 SkASSERT((unsigned) count < 0x1000); | 1809 SkASSERT((unsigned) count < 0x1000); |
1824 for (int index = 0; index < count; index++) { | 1810 for (int index = 0; index < count; index++) { |
1825 const SkFlatData* region = fRegions[index]; | 1811 const SkFlatData* region = fRegions[index]; |
1826 SkASSERT(region); | 1812 SkASSERT(region); |
1827 // region->validate(); | 1813 // region->validate(); |
1828 } | 1814 } |
1829 } | 1815 } |
1830 #endif | 1816 #endif |
OLD | NEW |