| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| 11 | 11 |
| 12 #include "effects/GrSingleTextureEffect.h" | 12 #include "effects/GrSingleTextureEffect.h" |
| 13 #include "effects/GrConfigConversionEffect.h" | 13 #include "effects/GrConfigConversionEffect.h" |
| 14 | 14 |
| 15 #include "GrAARectRenderer.h" | 15 #include "GrAARectRenderer.h" |
| 16 #include "GrBufferAllocPool.h" | 16 #include "GrBufferAllocPool.h" |
| 17 #include "GrGpu.h" | 17 #include "GrGpu.h" |
| 18 #include "GrDrawTargetCaps.h" | 18 #include "GrDrawTargetCaps.h" |
| 19 #include "GrIndexBuffer.h" | 19 #include "GrIndexBuffer.h" |
| 20 #include "GrInOrderDrawBuffer.h" | 20 #include "GrInOrderDrawBuffer.h" |
| 21 #include "GrLayerCache.h" | 21 #include "GrLayerCache.h" |
| 22 #include "GrOvalRenderer.h" | 22 #include "GrOvalRenderer.h" |
| 23 #include "GrPathRenderer.h" | 23 #include "GrPathRenderer.h" |
| 24 #include "GrPathUtils.h" | 24 #include "GrPathUtils.h" |
| 25 #include "GrResourceCache.h" | 25 #include "GrResourceCache.h" |
| 26 #include "GrSoftwarePathRenderer.h" | 26 #include "GrSoftwarePathRenderer.h" |
| 27 #include "GrStencilBuffer.h" | 27 #include "GrStencilBuffer.h" |
| 28 #include "GrStrokeInfo.h" |
| 28 #include "GrTextStrike.h" | 29 #include "GrTextStrike.h" |
| 29 #include "GrTracing.h" | 30 #include "GrTracing.h" |
| 31 #include "SkDashPathPriv.h" |
| 30 #include "SkGr.h" | 32 #include "SkGr.h" |
| 31 #include "SkRTConf.h" | 33 #include "SkRTConf.h" |
| 32 #include "SkRRect.h" | 34 #include "SkRRect.h" |
| 33 #include "SkStrokeRec.h" | 35 #include "SkStrokeRec.h" |
| 34 #include "SkTLazy.h" | 36 #include "SkTLazy.h" |
| 35 #include "SkTLS.h" | 37 #include "SkTLS.h" |
| 36 #include "SkTraceEvent.h" | 38 #include "SkTraceEvent.h" |
| 37 | 39 |
| 38 // It can be useful to set this to false to test whether a bug is caused by usin
g the | 40 // It can be useful to set this to false to test whether a bug is caused by usin
g the |
| 39 // InOrderDrawBuffer, to compare performance of using/not using InOrderDrawBuffe
r, or to make | 41 // InOrderDrawBuffer, to compare performance of using/not using InOrderDrawBuffe
r, or to make |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 } | 770 } |
| 769 } | 771 } |
| 770 | 772 |
| 771 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
int) { | 773 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
int) { |
| 772 return point.fX >= rect.fLeft && point.fX <= rect.fRight && | 774 return point.fX >= rect.fLeft && point.fX <= rect.fRight && |
| 773 point.fY >= rect.fTop && point.fY <= rect.fBottom; | 775 point.fY >= rect.fTop && point.fY <= rect.fBottom; |
| 774 } | 776 } |
| 775 | 777 |
| 776 void GrContext::drawRect(const GrPaint& paint, | 778 void GrContext::drawRect(const GrPaint& paint, |
| 777 const SkRect& rect, | 779 const SkRect& rect, |
| 778 const SkStrokeRec* stroke, | 780 const GrStrokeInfo* strokeInfo, |
| 779 const SkMatrix* matrix) { | 781 const SkMatrix* matrix) { |
| 782 if (NULL != strokeInfo && strokeInfo->isDashed()) { |
| 783 SkPath path; |
| 784 path.addRect(rect); |
| 785 this->drawPath(paint, path, *strokeInfo); |
| 786 return; |
| 787 } |
| 788 |
| 780 AutoRestoreEffects are; | 789 AutoRestoreEffects are; |
| 781 AutoCheckFlush acf(this); | 790 AutoCheckFlush acf(this); |
| 782 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); | 791 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); |
| 783 | 792 |
| 784 GR_CREATE_TRACE_MARKER("GrContext::drawRect", target); | 793 GR_CREATE_TRACE_MARKER("GrContext::drawRect", target); |
| 785 | 794 |
| 786 SkScalar width = stroke == NULL ? -1 : stroke->getWidth(); | 795 SkScalar width = NULL == strokeInfo ? -1 : strokeInfo->getStrokeRec().getWid
th(); |
| 787 SkMatrix combinedMatrix = target->drawState()->getViewMatrix(); | 796 SkMatrix combinedMatrix = target->drawState()->getViewMatrix(); |
| 788 if (NULL != matrix) { | 797 if (NULL != matrix) { |
| 789 combinedMatrix.preConcat(*matrix); | 798 combinedMatrix.preConcat(*matrix); |
| 790 } | 799 } |
| 791 | 800 |
| 792 // Check if this is a full RT draw and can be replaced with a clear. We don'
t bother checking | 801 // Check if this is a full RT draw and can be replaced with a clear. We don'
t bother checking |
| 793 // cases where the RT is fully inside a stroke. | 802 // cases where the RT is fully inside a stroke. |
| 794 if (width < 0) { | 803 if (width < 0) { |
| 795 SkRect rtRect; | 804 SkRect rtRect; |
| 796 target->getDrawState().getRenderTarget()->getBoundsRect(&rtRect); | 805 target->getDrawState().getRenderTarget()->getBoundsRect(&rtRect); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 823 } | 832 } |
| 824 } | 833 } |
| 825 } | 834 } |
| 826 | 835 |
| 827 SkRect devBoundRect; | 836 SkRect devBoundRect; |
| 828 bool useVertexCoverage; | 837 bool useVertexCoverage; |
| 829 bool needAA = paint.isAntiAlias() && | 838 bool needAA = paint.isAntiAlias() && |
| 830 !target->getDrawState().getRenderTarget()->isMultisampled(); | 839 !target->getDrawState().getRenderTarget()->isMultisampled(); |
| 831 bool doAA = needAA && apply_aa_to_rect(target, rect, width, combinedMatrix,
&devBoundRect, | 840 bool doAA = needAA && apply_aa_to_rect(target, rect, width, combinedMatrix,
&devBoundRect, |
| 832 &useVertexCoverage); | 841 &useVertexCoverage); |
| 842 |
| 843 const SkStrokeRec& strokeRec = strokeInfo->getStrokeRec(); |
| 844 |
| 833 if (doAA) { | 845 if (doAA) { |
| 834 GrDrawState::AutoViewMatrixRestore avmr; | 846 GrDrawState::AutoViewMatrixRestore avmr; |
| 835 if (!avmr.setIdentity(target->drawState())) { | 847 if (!avmr.setIdentity(target->drawState())) { |
| 836 return; | 848 return; |
| 837 } | 849 } |
| 838 if (width >= 0) { | 850 if (width >= 0) { |
| 839 fAARectRenderer->strokeAARect(this->getGpu(), target, rect, | 851 fAARectRenderer->strokeAARect(this->getGpu(), target, rect, |
| 840 combinedMatrix, devBoundRect, | 852 combinedMatrix, devBoundRect, |
| 841 stroke, useVertexCoverage); | 853 strokeRec, useVertexCoverage); |
| 842 } else { | 854 } else { |
| 843 // filled AA rect | 855 // filled AA rect |
| 844 fAARectRenderer->fillAARect(this->getGpu(), target, | 856 fAARectRenderer->fillAARect(this->getGpu(), target, |
| 845 rect, combinedMatrix, devBoundRect, | 857 rect, combinedMatrix, devBoundRect, |
| 846 useVertexCoverage); | 858 useVertexCoverage); |
| 847 } | 859 } |
| 848 return; | 860 return; |
| 849 } | 861 } |
| 850 | 862 |
| 851 if (width >= 0) { | 863 if (width >= 0) { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 target->resetIndexSource(); | 1011 target->resetIndexSource(); |
| 1000 } else { | 1012 } else { |
| 1001 target->drawNonIndexed(primitiveType, 0, vertexCount); | 1013 target->drawNonIndexed(primitiveType, 0, vertexCount); |
| 1002 } | 1014 } |
| 1003 } | 1015 } |
| 1004 | 1016 |
| 1005 /////////////////////////////////////////////////////////////////////////////// | 1017 /////////////////////////////////////////////////////////////////////////////// |
| 1006 | 1018 |
| 1007 void GrContext::drawRRect(const GrPaint& paint, | 1019 void GrContext::drawRRect(const GrPaint& paint, |
| 1008 const SkRRect& rrect, | 1020 const SkRRect& rrect, |
| 1009 const SkStrokeRec& stroke) { | 1021 const GrStrokeInfo& strokeInfo) { |
| 1010 if (rrect.isEmpty()) { | 1022 if (rrect.isEmpty()) { |
| 1011 return; | 1023 return; |
| 1012 } | 1024 } |
| 1013 | 1025 |
| 1026 if (strokeInfo.isDashed()) { |
| 1027 SkPath path; |
| 1028 path.addRRect(rrect); |
| 1029 this->drawPath(paint, path, strokeInfo); |
| 1030 return; |
| 1031 } |
| 1032 |
| 1014 AutoRestoreEffects are; | 1033 AutoRestoreEffects are; |
| 1015 AutoCheckFlush acf(this); | 1034 AutoCheckFlush acf(this); |
| 1016 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); | 1035 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); |
| 1017 | 1036 |
| 1018 GR_CREATE_TRACE_MARKER("GrContext::drawRRect", target); | 1037 GR_CREATE_TRACE_MARKER("GrContext::drawRRect", target); |
| 1019 | 1038 |
| 1020 if (!fOvalRenderer->drawRRect(target, this, paint.isAntiAlias(), rrect, stro
ke)) { | 1039 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec(); |
| 1040 |
| 1041 if (!fOvalRenderer->drawRRect(target, this, paint.isAntiAlias(), rrect, stro
keRec)) { |
| 1021 SkPath path; | 1042 SkPath path; |
| 1022 path.addRRect(rrect); | 1043 path.addRRect(rrect); |
| 1023 this->internalDrawPath(target, paint.isAntiAlias(), path, stroke); | 1044 this->internalDrawPath(target, paint.isAntiAlias(), path, strokeInfo); |
| 1024 } | 1045 } |
| 1025 } | 1046 } |
| 1026 | 1047 |
| 1027 /////////////////////////////////////////////////////////////////////////////// | 1048 /////////////////////////////////////////////////////////////////////////////// |
| 1028 | 1049 |
| 1029 void GrContext::drawDRRect(const GrPaint& paint, | 1050 void GrContext::drawDRRect(const GrPaint& paint, |
| 1030 const SkRRect& outer, | 1051 const SkRRect& outer, |
| 1031 const SkRRect& inner) { | 1052 const SkRRect& inner) { |
| 1032 if (outer.isEmpty()) { | 1053 if (outer.isEmpty()) { |
| 1033 return; | 1054 return; |
| 1034 } | 1055 } |
| 1035 | 1056 |
| 1036 AutoRestoreEffects are; | 1057 AutoRestoreEffects are; |
| 1037 AutoCheckFlush acf(this); | 1058 AutoCheckFlush acf(this); |
| 1038 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); | 1059 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); |
| 1039 | 1060 |
| 1040 GR_CREATE_TRACE_MARKER("GrContext::drawDRRect", target); | 1061 GR_CREATE_TRACE_MARKER("GrContext::drawDRRect", target); |
| 1041 | 1062 |
| 1042 if (!fOvalRenderer->drawDRRect(target, this, paint.isAntiAlias(), outer, inn
er)) { | 1063 if (!fOvalRenderer->drawDRRect(target, this, paint.isAntiAlias(), outer, inn
er)) { |
| 1043 SkPath path; | 1064 SkPath path; |
| 1044 path.addRRect(inner); | 1065 path.addRRect(inner); |
| 1045 path.addRRect(outer); | 1066 path.addRRect(outer); |
| 1046 path.setFillType(SkPath::kEvenOdd_FillType); | 1067 path.setFillType(SkPath::kEvenOdd_FillType); |
| 1047 | 1068 |
| 1048 SkStrokeRec fillRec(SkStrokeRec::kFill_InitStyle); | 1069 GrStrokeInfo fillRec(SkStrokeRec::kFill_InitStyle); |
| 1049 this->internalDrawPath(target, paint.isAntiAlias(), path, fillRec); | 1070 this->internalDrawPath(target, paint.isAntiAlias(), path, fillRec); |
| 1050 } | 1071 } |
| 1051 } | 1072 } |
| 1052 | 1073 |
| 1053 /////////////////////////////////////////////////////////////////////////////// | 1074 /////////////////////////////////////////////////////////////////////////////// |
| 1054 | 1075 |
| 1055 void GrContext::drawOval(const GrPaint& paint, | 1076 void GrContext::drawOval(const GrPaint& paint, |
| 1056 const SkRect& oval, | 1077 const SkRect& oval, |
| 1057 const SkStrokeRec& stroke) { | 1078 const GrStrokeInfo& strokeInfo) { |
| 1058 if (oval.isEmpty()) { | 1079 if (oval.isEmpty()) { |
| 1059 return; | 1080 return; |
| 1060 } | 1081 } |
| 1061 | 1082 |
| 1083 if (strokeInfo.isDashed()) { |
| 1084 SkPath path; |
| 1085 path.addOval(oval); |
| 1086 this->drawPath(paint, path, strokeInfo); |
| 1087 return; |
| 1088 } |
| 1089 |
| 1062 AutoRestoreEffects are; | 1090 AutoRestoreEffects are; |
| 1063 AutoCheckFlush acf(this); | 1091 AutoCheckFlush acf(this); |
| 1064 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); | 1092 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); |
| 1065 | 1093 |
| 1066 GR_CREATE_TRACE_MARKER("GrContext::drawOval", target); | 1094 GR_CREATE_TRACE_MARKER("GrContext::drawOval", target); |
| 1067 | 1095 |
| 1068 if (!fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), oval, stroke
)) { | 1096 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec(); |
| 1097 |
| 1098 |
| 1099 if (!fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), oval, stroke
Rec)) { |
| 1069 SkPath path; | 1100 SkPath path; |
| 1070 path.addOval(oval); | 1101 path.addOval(oval); |
| 1071 this->internalDrawPath(target, paint.isAntiAlias(), path, stroke); | 1102 this->internalDrawPath(target, paint.isAntiAlias(), path, strokeInfo); |
| 1072 } | 1103 } |
| 1073 } | 1104 } |
| 1074 | 1105 |
| 1075 // Can 'path' be drawn as a pair of filled nested rectangles? | 1106 // Can 'path' be drawn as a pair of filled nested rectangles? |
| 1076 static bool is_nested_rects(GrDrawTarget* target, | 1107 static bool is_nested_rects(GrDrawTarget* target, |
| 1077 const SkPath& path, | 1108 const SkPath& path, |
| 1078 const SkStrokeRec& stroke, | 1109 const SkStrokeRec& stroke, |
| 1079 SkRect rects[2], | 1110 SkRect rects[2], |
| 1080 bool* useVertexCoverage) { | 1111 bool* useVertexCoverage) { |
| 1081 SkASSERT(stroke.isFillStyle()); | 1112 SkASSERT(stroke.isFillStyle()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 for (int i = 1; i < 4; ++i) { | 1151 for (int i = 1; i < 4; ++i) { |
| 1121 SkScalar temp = SkScalarAbs(outer[i] - inner[i]); | 1152 SkScalar temp = SkScalarAbs(outer[i] - inner[i]); |
| 1122 if (!SkScalarNearlyEqual(margin, temp)) { | 1153 if (!SkScalarNearlyEqual(margin, temp)) { |
| 1123 return false; | 1154 return false; |
| 1124 } | 1155 } |
| 1125 } | 1156 } |
| 1126 | 1157 |
| 1127 return true; | 1158 return true; |
| 1128 } | 1159 } |
| 1129 | 1160 |
| 1130 void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrok
eRec& stroke) { | 1161 void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const GrStrok
eInfo& strokeInfo) { |
| 1131 | 1162 |
| 1132 if (path.isEmpty()) { | 1163 if (path.isEmpty()) { |
| 1133 if (path.isInverseFillType()) { | 1164 if (path.isInverseFillType()) { |
| 1134 this->drawPaint(paint); | 1165 this->drawPaint(paint); |
| 1135 } | 1166 } |
| 1136 return; | 1167 return; |
| 1137 } | 1168 } |
| 1138 | 1169 |
| 1170 if (strokeInfo.isDashed()) { |
| 1171 const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo(); |
| 1172 SkTLazy<SkPath> effectPath; |
| 1173 GrStrokeInfo newStrokeInfo(strokeInfo, false); |
| 1174 SkStrokeRec* stroke = newStrokeInfo.getStrokeRecPtr(); |
| 1175 if (SkDashPath::FilterDashPath(effectPath.init(), path, stroke, NULL, in
fo)) { |
| 1176 this->drawPath(paint, *effectPath.get(), newStrokeInfo); |
| 1177 return; |
| 1178 } |
| 1179 |
| 1180 this->drawPath(paint, path, newStrokeInfo); |
| 1181 return; |
| 1182 } |
| 1183 |
| 1139 // Note that internalDrawPath may sw-rasterize the path into a scratch textu
re. | 1184 // Note that internalDrawPath may sw-rasterize the path into a scratch textu
re. |
| 1140 // Scratch textures can be recycled after they are returned to the texture | 1185 // Scratch textures can be recycled after they are returned to the texture |
| 1141 // cache. This presents a potential hazard for buffered drawing. However, | 1186 // cache. This presents a potential hazard for buffered drawing. However, |
| 1142 // the writePixels that uploads to the scratch will perform a flush so we're | 1187 // the writePixels that uploads to the scratch will perform a flush so we're |
| 1143 // OK. | 1188 // OK. |
| 1144 AutoRestoreEffects are; | 1189 AutoRestoreEffects are; |
| 1145 AutoCheckFlush acf(this); | 1190 AutoCheckFlush acf(this); |
| 1146 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); | 1191 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf
); |
| 1147 GrDrawState* drawState = target->drawState(); | 1192 GrDrawState* drawState = target->drawState(); |
| 1148 | 1193 |
| 1149 GR_CREATE_TRACE_MARKER("GrContext::drawPath", target); | 1194 GR_CREATE_TRACE_MARKER("GrContext::drawPath", target); |
| 1150 | 1195 |
| 1196 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec(); |
| 1197 |
| 1151 bool useCoverageAA = paint.isAntiAlias() && !drawState->getRenderTarget()->i
sMultisampled(); | 1198 bool useCoverageAA = paint.isAntiAlias() && !drawState->getRenderTarget()->i
sMultisampled(); |
| 1152 | 1199 |
| 1153 if (useCoverageAA && stroke.getWidth() < 0 && !path.isConvex()) { | 1200 if (useCoverageAA && strokeRec.getWidth() < 0 && !path.isConvex()) { |
| 1154 // Concave AA paths are expensive - try to avoid them for special cases | 1201 // Concave AA paths are expensive - try to avoid them for special cases |
| 1155 bool useVertexCoverage; | 1202 bool useVertexCoverage; |
| 1156 SkRect rects[2]; | 1203 SkRect rects[2]; |
| 1157 | 1204 |
| 1158 if (is_nested_rects(target, path, stroke, rects, &useVertexCoverage)) { | 1205 if (is_nested_rects(target, path, strokeRec, rects, &useVertexCoverage))
{ |
| 1159 SkMatrix origViewMatrix = drawState->getViewMatrix(); | 1206 SkMatrix origViewMatrix = drawState->getViewMatrix(); |
| 1160 GrDrawState::AutoViewMatrixRestore avmr; | 1207 GrDrawState::AutoViewMatrixRestore avmr; |
| 1161 if (!avmr.setIdentity(target->drawState())) { | 1208 if (!avmr.setIdentity(target->drawState())) { |
| 1162 return; | 1209 return; |
| 1163 } | 1210 } |
| 1164 | 1211 |
| 1165 fAARectRenderer->fillAANestedRects(this->getGpu(), target, | 1212 fAARectRenderer->fillAANestedRects(this->getGpu(), target, |
| 1166 rects, | 1213 rects, |
| 1167 origViewMatrix, | 1214 origViewMatrix, |
| 1168 useVertexCoverage); | 1215 useVertexCoverage); |
| 1169 return; | 1216 return; |
| 1170 } | 1217 } |
| 1171 } | 1218 } |
| 1172 | 1219 |
| 1173 SkRect ovalRect; | 1220 SkRect ovalRect; |
| 1174 bool isOval = path.isOval(&ovalRect); | 1221 bool isOval = path.isOval(&ovalRect); |
| 1175 | 1222 |
| 1176 if (!isOval || path.isInverseFillType() | 1223 if (!isOval || path.isInverseFillType() |
| 1177 || !fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), ovalRect,
stroke)) { | 1224 || !fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), ovalRect,
strokeRec)) { |
| 1178 this->internalDrawPath(target, paint.isAntiAlias(), path, stroke); | 1225 this->internalDrawPath(target, paint.isAntiAlias(), path, strokeInfo); |
| 1179 } | 1226 } |
| 1180 } | 1227 } |
| 1181 | 1228 |
| 1182 void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath&
path, | 1229 void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath&
path, |
| 1183 const SkStrokeRec& origStroke) { | 1230 const GrStrokeInfo& strokeInfo) { |
| 1184 SkASSERT(!path.isEmpty()); | 1231 SkASSERT(!path.isEmpty()); |
| 1185 | 1232 |
| 1186 GR_CREATE_TRACE_MARKER("GrContext::internalDrawPath", target); | 1233 GR_CREATE_TRACE_MARKER("GrContext::internalDrawPath", target); |
| 1187 | 1234 |
| 1188 | 1235 |
| 1189 // An Assumption here is that path renderer would use some form of tweaking | 1236 // An Assumption here is that path renderer would use some form of tweaking |
| 1190 // the src color (either the input alpha or in the frag shader) to implement | 1237 // the src color (either the input alpha or in the frag shader) to implement |
| 1191 // aa. If we have some future driver-mojo path AA that can do the right | 1238 // aa. If we have some future driver-mojo path AA that can do the right |
| 1192 // thing WRT to the blend then we'll need some query on the PR. | 1239 // thing WRT to the blend then we'll need some query on the PR. |
| 1193 bool useCoverageAA = useAA && | 1240 bool useCoverageAA = useAA && |
| 1194 !target->getDrawState().getRenderTarget()->isMultisampled() && | 1241 !target->getDrawState().getRenderTarget()->isMultisampled() && |
| 1195 !target->shouldDisableCoverageAAForBlend(); | 1242 !target->shouldDisableCoverageAAForBlend(); |
| 1196 | 1243 |
| 1197 | 1244 |
| 1198 GrPathRendererChain::DrawType type = | 1245 GrPathRendererChain::DrawType type = |
| 1199 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType : | 1246 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType : |
| 1200 GrPathRendererChain::kColor_DrawType; | 1247 GrPathRendererChain::kColor_DrawType; |
| 1201 | 1248 |
| 1202 const SkPath* pathPtr = &path; | 1249 const SkPath* pathPtr = &path; |
| 1203 SkTLazy<SkPath> tmpPath; | 1250 SkTLazy<SkPath> tmpPath; |
| 1204 SkTCopyOnFirstWrite<SkStrokeRec> stroke(origStroke); | 1251 SkTCopyOnFirstWrite<SkStrokeRec> stroke(strokeInfo.getStrokeRec()); |
| 1205 | 1252 |
| 1206 // Try a 1st time without stroking the path and without allowing the SW rend
erer | 1253 // Try a 1st time without stroking the path and without allowing the SW rend
erer |
| 1207 GrPathRenderer* pr = this->getPathRenderer(*pathPtr, *stroke, target, false,
type); | 1254 GrPathRenderer* pr = this->getPathRenderer(*pathPtr, *stroke, target, false,
type); |
| 1208 | 1255 |
| 1209 if (NULL == pr) { | 1256 if (NULL == pr) { |
| 1210 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*stroke, this->getMatr
ix(), NULL)) { | 1257 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*stroke, this->getMatr
ix(), NULL)) { |
| 1211 // It didn't work the 1st time, so try again with the stroked path | 1258 // It didn't work the 1st time, so try again with the stroked path |
| 1212 if (stroke->applyToPath(tmpPath.init(), *pathPtr)) { | 1259 if (stroke->applyToPath(tmpPath.init(), *pathPtr)) { |
| 1213 pathPtr = tmpPath.get(); | 1260 pathPtr = tmpPath.get(); |
| 1214 stroke.writable()->setFillStyle(); | 1261 stroke.writable()->setFillStyle(); |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 SkSafeRef(resource); | 1885 SkSafeRef(resource); |
| 1839 return resource; | 1886 return resource; |
| 1840 } | 1887 } |
| 1841 | 1888 |
| 1842 /////////////////////////////////////////////////////////////////////////////// | 1889 /////////////////////////////////////////////////////////////////////////////// |
| 1843 #if GR_CACHE_STATS | 1890 #if GR_CACHE_STATS |
| 1844 void GrContext::printCacheStats() const { | 1891 void GrContext::printCacheStats() const { |
| 1845 fResourceCache->printStats(); | 1892 fResourceCache->printStats(); |
| 1846 } | 1893 } |
| 1847 #endif | 1894 #endif |
| OLD | NEW |