Chromium Code Reviews| 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, |
|
bsalomon
2014/06/05 19:22:54
Why does this take a StrokeRec* and others a Strok
egdaniel
2014/06/05 20:18:17
There are a few locations throughout the code that
| |
| 779 const SkMatrix* matrix) { | 781 const SkMatrix* matrix) { |
|
robertphillips
2014/06/05 18:28:00
NULL != ?
egdaniel
2014/06/05 19:07:23
Yes to this and all the other ones
egdaniel
2014/06/05 19:07:23
yes to this and all the other ones
| |
| 782 if (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 |
|
robertphillips
2014/06/05 18:28:01
NULL ==
| |
| 786 SkScalar width = stroke == NULL ? -1 : stroke->getWidth(); | 795 SkScalar width = !strokeInfo ? -1 : strokeInfo->getStrokeRec().getWidth(); |
| 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 | |
|
robertphillips
2014/06/05 18:28:00
strokeRec ?
egdaniel
2014/06/05 19:07:23
sure
| |
| 843 const SkStrokeRec& stroke = 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 stroke, useVertexCoverage); |
| 842 } else { | 854 } else { |
| (...skipping 156 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 |
|
robertphillips
2014/06/05 18:28:01
strokeRec ?
| |
| 1039 const SkStrokeRec& stroke = strokeInfo.getStrokeRec(); | |
| 1040 | |
| 1020 if (!fOvalRenderer->drawRRect(target, this, paint.isAntiAlias(), rrect, stro ke)) { | 1041 if (!fOvalRenderer->drawRRect(target, this, paint.isAntiAlias(), rrect, stro ke)) { |
| 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 |
|
robertphillips
2014/06/05 18:28:00
strokeRec ?
| |
| 1096 const SkStrokeRec& stroke = strokeInfo.getStrokeRec(); | |
| 1097 | |
| 1098 | |
| 1068 if (!fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), oval, stroke )) { | 1099 if (!fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), oval, stroke )) { |
| 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; | |
|
robertphillips
2014/06/05 18:28:00
Do we need cullRect here ? Can we just pass NULL t
egdaniel
2014/06/05 19:07:23
So I was matching the format used by the filterPat
| |
| 1173 const SkRect* cullRect = NULL; | |
| 1174 GrStrokeInfo newStrokeInfo(strokeInfo, false); | |
| 1175 SkStrokeRec* stroke = newStrokeInfo.getStrokeRecPtr(); | |
| 1176 if (SkDashPath::FilterDashPath(effectPath.init(), path, stroke, cullRect , info)) { | |
| 1177 this->drawPath(paint, *effectPath.get(), newStrokeInfo); | |
| 1178 return; | |
| 1179 } | |
| 1180 | |
| 1181 this->drawPath(paint, path, newStrokeInfo); | |
| 1182 return; | |
| 1183 } | |
| 1184 | |
| 1139 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re. | 1185 // 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 | 1186 // Scratch textures can be recycled after they are returned to the texture |
| 1141 // cache. This presents a potential hazard for buffered drawing. However, | 1187 // 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 | 1188 // the writePixels that uploads to the scratch will perform a flush so we're |
| 1143 // OK. | 1189 // OK. |
| 1144 AutoRestoreEffects are; | 1190 AutoRestoreEffects are; |
| 1145 AutoCheckFlush acf(this); | 1191 AutoCheckFlush acf(this); |
| 1146 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf ); | 1192 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf ); |
| 1147 GrDrawState* drawState = target->drawState(); | 1193 GrDrawState* drawState = target->drawState(); |
| 1148 | 1194 |
| 1149 GR_CREATE_TRACE_MARKER("GrContext::drawPath", target); | 1195 GR_CREATE_TRACE_MARKER("GrContext::drawPath", target); |
| 1150 | 1196 |
|
robertphillips
2014/06/05 18:28:00
strokeRec ?
| |
| 1197 const SkStrokeRec& stroke = strokeInfo.getStrokeRec(); | |
| 1198 | |
| 1151 bool useCoverageAA = paint.isAntiAlias() && !drawState->getRenderTarget()->i sMultisampled(); | 1199 bool useCoverageAA = paint.isAntiAlias() && !drawState->getRenderTarget()->i sMultisampled(); |
| 1152 | 1200 |
| 1153 if (useCoverageAA && stroke.getWidth() < 0 && !path.isConvex()) { | 1201 if (useCoverageAA && stroke.getWidth() < 0 && !path.isConvex()) { |
| 1154 // Concave AA paths are expensive - try to avoid them for special cases | 1202 // Concave AA paths are expensive - try to avoid them for special cases |
| 1155 bool useVertexCoverage; | 1203 bool useVertexCoverage; |
| 1156 SkRect rects[2]; | 1204 SkRect rects[2]; |
| 1157 | 1205 |
| 1158 if (is_nested_rects(target, path, stroke, rects, &useVertexCoverage)) { | 1206 if (is_nested_rects(target, path, stroke, rects, &useVertexCoverage)) { |
| 1159 SkMatrix origViewMatrix = drawState->getViewMatrix(); | 1207 SkMatrix origViewMatrix = drawState->getViewMatrix(); |
| 1160 GrDrawState::AutoViewMatrixRestore avmr; | 1208 GrDrawState::AutoViewMatrixRestore avmr; |
| 1161 if (!avmr.setIdentity(target->drawState())) { | 1209 if (!avmr.setIdentity(target->drawState())) { |
| 1162 return; | 1210 return; |
| 1163 } | 1211 } |
| 1164 | 1212 |
| 1165 fAARectRenderer->fillAANestedRects(this->getGpu(), target, | 1213 fAARectRenderer->fillAANestedRects(this->getGpu(), target, |
| 1166 rects, | 1214 rects, |
| 1167 origViewMatrix, | 1215 origViewMatrix, |
| 1168 useVertexCoverage); | 1216 useVertexCoverage); |
| 1169 return; | 1217 return; |
| 1170 } | 1218 } |
| 1171 } | 1219 } |
| 1172 | 1220 |
| 1173 SkRect ovalRect; | 1221 SkRect ovalRect; |
| 1174 bool isOval = path.isOval(&ovalRect); | 1222 bool isOval = path.isOval(&ovalRect); |
| 1175 | 1223 |
| 1176 if (!isOval || path.isInverseFillType() | 1224 if (!isOval || path.isInverseFillType() |
| 1177 || !fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), ovalRect, stroke)) { | 1225 || !fOvalRenderer->drawOval(target, this, paint.isAntiAlias(), ovalRect, stroke)) { |
| 1178 this->internalDrawPath(target, paint.isAntiAlias(), path, stroke); | 1226 this->internalDrawPath(target, paint.isAntiAlias(), path, strokeInfo); |
| 1179 } | 1227 } |
| 1180 } | 1228 } |
| 1181 | 1229 |
| 1182 void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath& path, | 1230 void GrContext::internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath& path, |
| 1183 const SkStrokeRec& origStroke) { | 1231 const GrStrokeInfo& strokeInfo) { |
| 1184 SkASSERT(!path.isEmpty()); | 1232 SkASSERT(!path.isEmpty()); |
| 1185 | 1233 |
| 1186 GR_CREATE_TRACE_MARKER("GrContext::internalDrawPath", target); | 1234 GR_CREATE_TRACE_MARKER("GrContext::internalDrawPath", target); |
| 1187 | 1235 |
| 1188 | 1236 |
| 1189 // An Assumption here is that path renderer would use some form of tweaking | 1237 // 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 | 1238 // 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 | 1239 // 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. | 1240 // thing WRT to the blend then we'll need some query on the PR. |
| 1193 bool useCoverageAA = useAA && | 1241 bool useCoverageAA = useAA && |
| 1194 !target->getDrawState().getRenderTarget()->isMultisampled() && | 1242 !target->getDrawState().getRenderTarget()->isMultisampled() && |
| 1195 !target->shouldDisableCoverageAAForBlend(); | 1243 !target->shouldDisableCoverageAAForBlend(); |
| 1196 | 1244 |
| 1197 | 1245 |
| 1198 GrPathRendererChain::DrawType type = | 1246 GrPathRendererChain::DrawType type = |
| 1199 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType : | 1247 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType : |
| 1200 GrPathRendererChain::kColor_DrawType; | 1248 GrPathRendererChain::kColor_DrawType; |
| 1201 | 1249 |
| 1202 const SkPath* pathPtr = &path; | 1250 const SkPath* pathPtr = &path; |
| 1203 SkTLazy<SkPath> tmpPath; | 1251 SkTLazy<SkPath> tmpPath; |
| 1204 SkTCopyOnFirstWrite<SkStrokeRec> stroke(origStroke); | 1252 SkTCopyOnFirstWrite<SkStrokeRec> stroke(strokeInfo.getStrokeRec()); |
| 1205 | 1253 |
| 1206 // Try a 1st time without stroking the path and without allowing the SW rend erer | 1254 // 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); | 1255 GrPathRenderer* pr = this->getPathRenderer(*pathPtr, *stroke, target, false, type); |
| 1208 | 1256 |
| 1209 if (NULL == pr) { | 1257 if (NULL == pr) { |
| 1210 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*stroke, this->getMatr ix(), NULL)) { | 1258 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*stroke, this->getMatr ix(), NULL)) { |
| 1211 // It didn't work the 1st time, so try again with the stroked path | 1259 // It didn't work the 1st time, so try again with the stroked path |
| 1212 if (stroke->applyToPath(tmpPath.init(), *pathPtr)) { | 1260 if (stroke->applyToPath(tmpPath.init(), *pathPtr)) { |
| 1213 pathPtr = tmpPath.get(); | 1261 pathPtr = tmpPath.get(); |
| 1214 stroke.writable()->setFillStyle(); | 1262 stroke.writable()->setFillStyle(); |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1838 SkSafeRef(resource); | 1886 SkSafeRef(resource); |
| 1839 return resource; | 1887 return resource; |
| 1840 } | 1888 } |
| 1841 | 1889 |
| 1842 /////////////////////////////////////////////////////////////////////////////// | 1890 /////////////////////////////////////////////////////////////////////////////// |
| 1843 #if GR_CACHE_STATS | 1891 #if GR_CACHE_STATS |
| 1844 void GrContext::printCacheStats() const { | 1892 void GrContext::printCacheStats() const { |
| 1845 fResourceCache->printStats(); | 1893 fResourceCache->printStats(); |
| 1846 } | 1894 } |
| 1847 #endif | 1895 #endif |
| OLD | NEW |