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) { |
robertphillips
2013/03/05 20:30:13
kCircleAttrBindings? As is I think just passing kE
jvanverth1
2013/03/07 15:21:54
Done.
| |
1109 static const GrAttribBindings kAttributeBindings = GrDrawState::kEdge_At tribBindingsBit; | |
1110 drawState->setAttribBindings(kAttributeBindings); | |
1112 drawState->setVertexEdgeType(GrDrawState::kCircle_EdgeType); | 1111 drawState->setVertexEdgeType(GrDrawState::kCircle_EdgeType); |
1112 drawState->setAttribIndex(GrDrawState::kEdge_AttribIndex, 1); | |
1113 | 1113 |
1114 xRadius = vm.mapRadius(xRadius); | 1114 xRadius = vm.mapRadius(xRadius); |
1115 | 1115 |
1116 SkScalar outerRadius = xRadius; | 1116 SkScalar outerRadius = xRadius; |
1117 SkScalar innerRadius = 0; | 1117 SkScalar innerRadius = 0; |
1118 SkScalar halfWidth = 0; | 1118 SkScalar halfWidth = 0; |
1119 if (style != SkStrokeRec::kFill_Style) { | 1119 if (style != SkStrokeRec::kFill_Style) { |
1120 strokeWidth = vm.mapRadius(strokeWidth); | 1120 strokeWidth = vm.mapRadius(strokeWidth); |
1121 if (SkScalarNearlyZero(strokeWidth)) { | 1121 if (SkScalarNearlyZero(strokeWidth)) { |
1122 halfWidth = SK_ScalarHalf; | 1122 halfWidth = SK_ScalarHalf; |
(...skipping 11 matching lines...) Expand all Loading... | |
1134 verts[i].fCenter = center; | 1134 verts[i].fCenter = center; |
1135 verts[i].fOuterRadius = outerRadius; | 1135 verts[i].fOuterRadius = outerRadius; |
1136 verts[i].fInnerRadius = innerRadius; | 1136 verts[i].fInnerRadius = innerRadius; |
1137 } | 1137 } |
1138 | 1138 |
1139 L = -outerRadius; | 1139 L = -outerRadius; |
1140 R = +outerRadius; | 1140 R = +outerRadius; |
1141 T = -outerRadius; | 1141 T = -outerRadius; |
1142 B = +outerRadius; | 1142 B = +outerRadius; |
1143 } else { // is axis-aligned ellipse | 1143 } else { // is axis-aligned ellipse |
1144 drawState->setVertexEdgeType(GrDrawState::kEllipse_EdgeType); | 1144 drawState->setAttribBindings(GrDrawState::kDefault_AttribBindings); |
1145 | |
robertphillips
2013/03/05 20:30:13
Why not "static const" style? Also, some words her
jvanverth1
2013/03/07 15:21:54
All the other stage constants use enums. Should I
| |
1146 enum { | |
1147 kEdgeEffectStage = GrPaint::kTotalStages, | |
1148 }; | |
1149 GrEffectRef* effect = GrEllipseEdgeEffect::Create(); | |
1150 drawState->setEffect(kEdgeEffectStage, effect)->unref(); | |
1151 int index = 1; | |
1152 drawState->setEffectAttribIndices(kEdgeEffectStage, &index, 1); | |
1145 | 1153 |
1146 SkRect xformedRect; | 1154 SkRect xformedRect; |
1147 vm.mapRect(&xformedRect, oval); | 1155 vm.mapRect(&xformedRect, oval); |
1148 | 1156 |
1149 xRadius = SkScalarHalf(xformedRect.width()); | 1157 xRadius = SkScalarHalf(xformedRect.width()); |
1150 yRadius = SkScalarHalf(xformedRect.height()); | 1158 yRadius = SkScalarHalf(xformedRect.height()); |
1151 | 1159 |
1152 if (style == SkStrokeRec::kStrokeAndFill_Style && strokeWidth > 0.0f) { | 1160 if (style == SkStrokeRec::kStrokeAndFill_Style && strokeWidth > 0.0f) { |
1153 SkScalar halfWidth = SkScalarHalf(strokeWidth); | 1161 SkScalar halfWidth = SkScalarHalf(strokeWidth); |
1154 // do (potentially) anisotropic mapping | 1162 // do (potentially) anisotropic mapping |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1992 return srcTexture; | 2000 return srcTexture; |
1993 } | 2001 } |
1994 } | 2002 } |
1995 | 2003 |
1996 /////////////////////////////////////////////////////////////////////////////// | 2004 /////////////////////////////////////////////////////////////////////////////// |
1997 #if GR_CACHE_STATS | 2005 #if GR_CACHE_STATS |
1998 void GrContext::printCacheStats() const { | 2006 void GrContext::printCacheStats() const { |
1999 fTextureCache->printStats(); | 2007 fTextureCache->printStats(); |
2000 } | 2008 } |
2001 #endif | 2009 #endif |
OLD | NEW |