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/GrConvolutionEffect.h" | 12 #include "effects/GrConvolutionEffect.h" |
13 #include "effects/GrSingleTextureEffect.h" | 13 #include "effects/GrSingleTextureEffect.h" |
14 #include "effects/GrConfigConversionEffect.h" | 14 #include "effects/GrConfigConversionEffect.h" |
| 15 #include "effects/GrEllipseEdgeEffect.h" |
15 | 16 |
16 #include "GrBufferAllocPool.h" | 17 #include "GrBufferAllocPool.h" |
17 #include "GrGpu.h" | 18 #include "GrGpu.h" |
18 #include "GrIndexBuffer.h" | 19 #include "GrIndexBuffer.h" |
19 #include "GrInOrderDrawBuffer.h" | 20 #include "GrInOrderDrawBuffer.h" |
20 #include "GrPathRenderer.h" | 21 #include "GrPathRenderer.h" |
21 #include "GrPathUtils.h" | 22 #include "GrPathUtils.h" |
22 #include "GrResourceCache.h" | 23 #include "GrResourceCache.h" |
23 #include "GrSoftwarePathRenderer.h" | 24 #include "GrSoftwarePathRenderer.h" |
24 #include "GrStencilBuffer.h" | 25 #include "GrStencilBuffer.h" |
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 GrDrawState::AutoDeviceCoordDraw adcd(drawState); | 1066 GrDrawState::AutoDeviceCoordDraw adcd(drawState); |
1066 if (!adcd.succeeded()) { | 1067 if (!adcd.succeeded()) { |
1067 return; | 1068 return; |
1068 } | 1069 } |
1069 | 1070 |
1070 // position + edge | 1071 // position + edge |
1071 static const GrVertexAttrib kVertexAttribs[] = { | 1072 static const GrVertexAttrib kVertexAttribs[] = { |
1072 {kVec2f_GrVertexAttribType, 0}, | 1073 {kVec2f_GrVertexAttribType, 0}, |
1073 {kVec4f_GrVertexAttribType, sizeof(GrPoint)} | 1074 {kVec4f_GrVertexAttribType, sizeof(GrPoint)} |
1074 }; | 1075 }; |
1075 static const GrAttribBindings kAttributeBindings = GrDrawState::kEdge_Attrib
BindingsBit; | |
1076 | |
1077 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs)); | 1076 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs)); |
1078 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); | 1077 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); |
1079 drawState->setAttribIndex(GrDrawState::kEdge_AttribIndex, 1); | |
1080 drawState->setAttribBindings(kAttributeBindings); | |
1081 GrAssert(sizeof(CircleVertex) == drawState->getVertexSize()); | 1078 GrAssert(sizeof(CircleVertex) == drawState->getVertexSize()); |
1082 | 1079 |
1083 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); | 1080 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); |
1084 if (!geo.succeeded()) { | 1081 if (!geo.succeeded()) { |
1085 GrPrintf("Failed to get space for vertices!\n"); | 1082 GrPrintf("Failed to get space for vertices!\n"); |
1086 return; | 1083 return; |
1087 } | 1084 } |
1088 | 1085 |
1089 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices()); | 1086 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices()); |
1090 | 1087 |
1091 GrPoint center = GrPoint::Make(oval.centerX(), oval.centerY()); | 1088 GrPoint center = GrPoint::Make(oval.centerX(), oval.centerY()); |
1092 vm.mapPoints(¢er, 1); | 1089 vm.mapPoints(¢er, 1); |
1093 | 1090 |
1094 SkScalar L; | 1091 SkScalar L; |
1095 SkScalar R; | 1092 SkScalar R; |
1096 SkScalar T; | 1093 SkScalar T; |
1097 SkScalar B; | 1094 SkScalar B; |
1098 | 1095 |
1099 if (isCircle) { | 1096 if (isCircle) { |
| 1097 drawState->setAttribBindings(GrDrawState::kEdge_AttribBindingsBit); |
1100 drawState->setVertexEdgeType(GrDrawState::kCircle_EdgeType); | 1098 drawState->setVertexEdgeType(GrDrawState::kCircle_EdgeType); |
| 1099 drawState->setAttribIndex(GrDrawState::kEdge_AttribIndex, 1); |
1101 | 1100 |
1102 xRadius = vm.mapRadius(xRadius); | 1101 xRadius = vm.mapRadius(xRadius); |
1103 | 1102 |
1104 SkScalar outerRadius = xRadius; | 1103 SkScalar outerRadius = xRadius; |
1105 SkScalar innerRadius = 0; | 1104 SkScalar innerRadius = 0; |
1106 SkScalar halfWidth = 0; | 1105 SkScalar halfWidth = 0; |
1107 if (style != SkStrokeRec::kFill_Style) { | 1106 if (style != SkStrokeRec::kFill_Style) { |
1108 strokeWidth = vm.mapRadius(strokeWidth); | 1107 strokeWidth = vm.mapRadius(strokeWidth); |
1109 if (SkScalarNearlyZero(strokeWidth)) { | 1108 if (SkScalarNearlyZero(strokeWidth)) { |
1110 halfWidth = SK_ScalarHalf; | 1109 halfWidth = SK_ScalarHalf; |
(...skipping 11 matching lines...) Expand all Loading... |
1122 verts[i].fCenter = center; | 1121 verts[i].fCenter = center; |
1123 verts[i].fOuterRadius = outerRadius; | 1122 verts[i].fOuterRadius = outerRadius; |
1124 verts[i].fInnerRadius = innerRadius; | 1123 verts[i].fInnerRadius = innerRadius; |
1125 } | 1124 } |
1126 | 1125 |
1127 L = -outerRadius; | 1126 L = -outerRadius; |
1128 R = +outerRadius; | 1127 R = +outerRadius; |
1129 T = -outerRadius; | 1128 T = -outerRadius; |
1130 B = +outerRadius; | 1129 B = +outerRadius; |
1131 } else { // is axis-aligned ellipse | 1130 } else { // is axis-aligned ellipse |
1132 drawState->setVertexEdgeType(GrDrawState::kEllipse_EdgeType); | 1131 drawState->setAttribBindings(GrDrawState::kDefault_AttribBindings); |
| 1132 |
| 1133 enum { |
| 1134 // the edge effects share this stage with glyph rendering |
| 1135 // (kGlyphMaskStage in GrTextContext) && SW path rendering |
| 1136 // (kPathMaskStage in GrSWMaskHelper) |
| 1137 kEdgeEffectStage = GrPaint::kTotalStages, |
| 1138 }; |
| 1139 GrEffectRef* effect = GrEllipseEdgeEffect::Create(); |
| 1140 static const int kEdgeAttrIndex = 1; |
| 1141 drawState->setEffect(kEdgeEffectStage, effect, &kEdgeAttrIndex)->unref()
; |
1133 | 1142 |
1134 SkRect xformedRect; | 1143 SkRect xformedRect; |
1135 vm.mapRect(&xformedRect, oval); | 1144 vm.mapRect(&xformedRect, oval); |
1136 | 1145 |
1137 xRadius = SkScalarHalf(xformedRect.width()); | 1146 xRadius = SkScalarHalf(xformedRect.width()); |
1138 yRadius = SkScalarHalf(xformedRect.height()); | 1147 yRadius = SkScalarHalf(xformedRect.height()); |
1139 | 1148 |
1140 if (style == SkStrokeRec::kStrokeAndFill_Style && strokeWidth > 0.0f) { | 1149 if (style == SkStrokeRec::kStrokeAndFill_Style && strokeWidth > 0.0f) { |
1141 SkScalar halfWidth = SkScalarHalf(strokeWidth); | 1150 SkScalar halfWidth = SkScalarHalf(strokeWidth); |
1142 // do (potentially) anisotropic mapping | 1151 // do (potentially) anisotropic mapping |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1980 return srcTexture; | 1989 return srcTexture; |
1981 } | 1990 } |
1982 } | 1991 } |
1983 | 1992 |
1984 /////////////////////////////////////////////////////////////////////////////// | 1993 /////////////////////////////////////////////////////////////////////////////// |
1985 #if GR_CACHE_STATS | 1994 #if GR_CACHE_STATS |
1986 void GrContext::printCacheStats() const { | 1995 void GrContext::printCacheStats() const { |
1987 fTextureCache->printStats(); | 1996 fTextureCache->printStats(); |
1988 } | 1997 } |
1989 #endif | 1998 #endif |
OLD | NEW |