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/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 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1077 GrDrawState::AutoDeviceCoordDraw adcd(drawState); | 1078 GrDrawState::AutoDeviceCoordDraw adcd(drawState); |
| 1078 if (!adcd.succeeded()) { | 1079 if (!adcd.succeeded()) { |
| 1079 return; | 1080 return; |
| 1080 } | 1081 } |
| 1081 | 1082 |
| 1082 // position + edge | 1083 // position + edge |
| 1083 static const GrVertexAttrib kVertexAttribs[] = { | 1084 static const GrVertexAttrib kVertexAttribs[] = { |
| 1084 {kVec2f_GrVertexAttribType, 0}, | 1085 {kVec2f_GrVertexAttribType, 0}, |
| 1085 {kVec4f_GrVertexAttribType, sizeof(GrPoint)} | 1086 {kVec4f_GrVertexAttribType, sizeof(GrPoint)} |
| 1086 }; | 1087 }; |
| 1087 static const GrAttribBindings kAttributeBindings = GrDrawState::kEdge_Attrib BindingsBit; | |
| 1088 | |
| 1089 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs)); | 1088 drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs)); |
| 1090 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); | 1089 drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); |
| 1091 drawState->setAttribIndex(GrDrawState::kEdge_AttribIndex, 1); | |
| 1092 drawState->setAttribBindings(kAttributeBindings); | |
| 1093 GrAssert(sizeof(CircleVertex) == drawState->getVertexSize()); | 1090 GrAssert(sizeof(CircleVertex) == drawState->getVertexSize()); |
| 1094 | 1091 |
| 1095 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); | 1092 GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0); |
| 1096 if (!geo.succeeded()) { | 1093 if (!geo.succeeded()) { |
| 1097 GrPrintf("Failed to get space for vertices!\n"); | 1094 GrPrintf("Failed to get space for vertices!\n"); |
| 1098 return; | 1095 return; |
| 1099 } | 1096 } |
| 1100 | 1097 |
| 1101 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices()); | 1098 CircleVertex* verts = reinterpret_cast<CircleVertex*>(geo.vertices()); |
| 1102 | 1099 |
| 1103 GrPoint center = GrPoint::Make(oval.centerX(), oval.centerY()); | 1100 GrPoint center = GrPoint::Make(oval.centerX(), oval.centerY()); |
| 1104 vm.mapPoints(¢er, 1); | 1101 vm.mapPoints(¢er, 1); |
| 1105 | 1102 |
| 1106 SkScalar L; | 1103 SkScalar L; |
| 1107 SkScalar R; | 1104 SkScalar R; |
| 1108 SkScalar T; | 1105 SkScalar T; |
| 1109 SkScalar B; | 1106 SkScalar B; |
| 1110 | 1107 |
| 1111 if (isCircle) { | 1108 if (isCircle) { |
| 1109 drawState->setAttribBindings(GrDrawState::kEdge_AttribBindingsBit); | |
| 1112 drawState->setVertexEdgeType(GrDrawState::kCircle_EdgeType); | 1110 drawState->setVertexEdgeType(GrDrawState::kCircle_EdgeType); |
| 1111 drawState->setAttribIndex(GrDrawState::kEdge_AttribIndex, 1); | |
| 1113 | 1112 |
| 1114 xRadius = vm.mapRadius(xRadius); | 1113 xRadius = vm.mapRadius(xRadius); |
| 1115 | 1114 |
| 1116 SkScalar outerRadius = xRadius; | 1115 SkScalar outerRadius = xRadius; |
| 1117 SkScalar innerRadius = 0; | 1116 SkScalar innerRadius = 0; |
| 1118 SkScalar halfWidth = 0; | 1117 SkScalar halfWidth = 0; |
| 1119 if (style != SkStrokeRec::kFill_Style) { | 1118 if (style != SkStrokeRec::kFill_Style) { |
| 1120 strokeWidth = vm.mapRadius(strokeWidth); | 1119 strokeWidth = vm.mapRadius(strokeWidth); |
| 1121 if (SkScalarNearlyZero(strokeWidth)) { | 1120 if (SkScalarNearlyZero(strokeWidth)) { |
| 1122 halfWidth = SK_ScalarHalf; | 1121 halfWidth = SK_ScalarHalf; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1134 verts[i].fCenter = center; | 1133 verts[i].fCenter = center; |
| 1135 verts[i].fOuterRadius = outerRadius; | 1134 verts[i].fOuterRadius = outerRadius; |
| 1136 verts[i].fInnerRadius = innerRadius; | 1135 verts[i].fInnerRadius = innerRadius; |
| 1137 } | 1136 } |
| 1138 | 1137 |
| 1139 L = -outerRadius; | 1138 L = -outerRadius; |
| 1140 R = +outerRadius; | 1139 R = +outerRadius; |
| 1141 T = -outerRadius; | 1140 T = -outerRadius; |
| 1142 B = +outerRadius; | 1141 B = +outerRadius; |
| 1143 } else { // is axis-aligned ellipse | 1142 } else { // is axis-aligned ellipse |
| 1144 drawState->setVertexEdgeType(GrDrawState::kEllipse_EdgeType); | 1143 drawState->setAttribBindings(GrDrawState::kDefault_AttribBindings); |
| 1144 | |
| 1145 enum { | |
| 1146 // the edge effects share this stage with glyph rendering | |
| 1147 // (kGlyphMaskStage in GrTextContext) && SW path rendering | |
| 1148 // (kPathMaskStage in GrSWMaskHelper) | |
| 1149 kEdgeEffectStage = GrPaint::kTotalStages, | |
| 1150 }; | |
| 1151 GrEffectRef* effect = GrEllipseEdgeEffect::Create(); | |
| 1152 int edgeAttrIndex = 1; | |
|
bsalomon
2013/03/07 15:59:13
static const?
jvanverth1
2013/03/07 22:00:44
Done.
| |
| 1153 drawState->setEffect(kEdgeEffectStage, effect, &edgeAttrIndex)->unref(); | |
| 1145 | 1154 |
| 1146 SkRect xformedRect; | 1155 SkRect xformedRect; |
| 1147 vm.mapRect(&xformedRect, oval); | 1156 vm.mapRect(&xformedRect, oval); |
| 1148 | 1157 |
| 1149 xRadius = SkScalarHalf(xformedRect.width()); | 1158 xRadius = SkScalarHalf(xformedRect.width()); |
| 1150 yRadius = SkScalarHalf(xformedRect.height()); | 1159 yRadius = SkScalarHalf(xformedRect.height()); |
| 1151 | 1160 |
| 1152 if (style == SkStrokeRec::kStrokeAndFill_Style && strokeWidth > 0.0f) { | 1161 if (style == SkStrokeRec::kStrokeAndFill_Style && strokeWidth > 0.0f) { |
| 1153 SkScalar halfWidth = SkScalarHalf(strokeWidth); | 1162 SkScalar halfWidth = SkScalarHalf(strokeWidth); |
| 1154 // do (potentially) anisotropic mapping | 1163 // do (potentially) anisotropic mapping |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1992 return srcTexture; | 2001 return srcTexture; |
| 1993 } | 2002 } |
| 1994 } | 2003 } |
| 1995 | 2004 |
| 1996 /////////////////////////////////////////////////////////////////////////////// | 2005 /////////////////////////////////////////////////////////////////////////////// |
| 1997 #if GR_CACHE_STATS | 2006 #if GR_CACHE_STATS |
| 1998 void GrContext::printCacheStats() const { | 2007 void GrContext::printCacheStats() const { |
| 1999 fTextureCache->printStats(); | 2008 fTextureCache->printStats(); |
| 2000 } | 2009 } |
| 2001 #endif | 2010 #endif |
| OLD | NEW |