Take two for r8466:
Replace the old attribute binding and index interface with one where we include the binding as part of the attribute array. Also removed the fixed attribute indices for constant color and coverage attributes, and replaced with dynamic ones based on current attribute set. Removed binding of color and coverage attributes unless they're actually set.
Original author: bsalomon@google.com
Author: jvanverth@google.com
Reviewed By: bsalomon@google.com,robertphillips@google.com
Review URL: https://chromiumcodereview.appspot.com/13296005
git-svn-id: http://skia.googlecode.com/svn/trunk@8468 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp
index b4f02ba..0093b08 100644
--- a/src/gpu/GrAARectRenderer.cpp
+++ b/src/gpu/GrAARectRenderer.cpp
@@ -13,15 +13,17 @@
namespace {
-static void aa_rect_attributes(bool useCoverage, GrAttribBindings* bindings,
- GrDrawState::AttribIndex* index) {
- if (useCoverage) {
- *bindings = GrDrawState::kCoverage_AttribBindingsBit;
- *index = GrDrawState::kCoverage_AttribIndex;
- } else {
- *bindings = GrDrawState::kColor_AttribBindingsBit;
- *index = GrDrawState::kColor_AttribIndex;
- }
+static void aa_rect_attributes(bool useCoverage, const GrVertexAttrib** attribs, int* count) {
+ static const GrVertexAttrib kCoverageAttribs[] = {
+ {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
+ {kVec4ub_GrVertexAttribType, sizeof(GrPoint), kCoverage_GrVertexAttribBinding},
+ };
+ static const GrVertexAttrib kColorAttribs[] = {
+ {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
+ {kVec4ub_GrVertexAttribType, sizeof(GrPoint), kColor_GrVertexAttribBinding},
+ };
+ *attribs = useCoverage ? kCoverageAttribs : kColorAttribs;
+ *count = 2;
}
static void set_inset_fan(GrPoint* pts, size_t stride,
@@ -128,18 +130,10 @@
bool useVertexCoverage) {
GrDrawState* drawState = target->drawState();
- // position + color/coverage
- static const GrVertexAttrib kVertexAttribs[] = {
- {kVec2f_GrVertexAttribType, 0},
- {kVec4ub_GrVertexAttribType, sizeof(GrPoint)}
- };
- GrAttribBindings bindings;
- GrDrawState::AttribIndex attribIndex;
- aa_rect_attributes(useVertexCoverage, &bindings, &attribIndex);
- drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs));
- drawState->setAttribBindings(bindings);
- drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0);
- drawState->setAttribIndex(attribIndex, 1);
+ const GrVertexAttrib* attribs;
+ int attribCount;
+ aa_rect_attributes(useVertexCoverage, &attribs, &attribCount);
+ drawState->setVertexAttribs(attribs, attribCount);
GrDrawTarget::AutoReleaseGeometry geo(target, 8, 0);
if (!geo.succeeded()) {
@@ -212,18 +206,10 @@
return;
}
- // position + color/coverage
- static const GrVertexAttrib kVertexAttribs[] = {
- {kVec2f_GrVertexAttribType, 0},
- {kVec4ub_GrVertexAttribType, sizeof(GrPoint)}
- };
- GrAttribBindings bindings;
- GrDrawState::AttribIndex attribIndex;
- aa_rect_attributes(useVertexCoverage, &bindings, &attribIndex);
- drawState->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs));
- drawState->setAttribBindings(bindings);
- drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0);
- drawState->setAttribIndex(attribIndex, 1);
+ const GrVertexAttrib* attribs;
+ int attribCount;
+ aa_rect_attributes(useVertexCoverage, &attribs, &attribCount);
+ drawState->setVertexAttribs(attribs, attribCount);
GrDrawTarget::AutoReleaseGeometry geo(target, 16, 0);
if (!geo.succeeded()) {