Remove constructors from GrVertexAttrib.
It fits our style better to use initializer lists, so the constructors have
been removed and replaced with said lists.
Review URL: https://codereview.chromium.org/12379052
git-svn-id: http://skia.googlecode.com/svn/trunk@7936 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index 46e75a0..ebf2ea9 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -480,8 +480,8 @@
// position + edge
static const GrVertexAttrib kAttribs[] = {
- GrVertexAttrib(kVec2f_GrVertexAttribType, 0),
- GrVertexAttrib(kVec4f_GrVertexAttribType, sizeof(GrPoint))
+ {kVec2f_GrVertexAttribType, 0},
+ {kVec4f_GrVertexAttribType, sizeof(GrPoint)}
};
static const GrAttribBindings bindings = GrDrawState::kEdge_AttribBindingsBit;
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index a2ad9e3..783cadf 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -504,8 +504,8 @@
// position + edge
static const GrVertexAttrib kAttribs[] = {
- GrVertexAttrib(kVec2f_GrVertexAttribType, 0),
- GrVertexAttrib(kVec4f_GrVertexAttribType, sizeof(GrPoint))
+ {kVec2f_GrVertexAttribType, 0},
+ {kVec4f_GrVertexAttribType, sizeof(GrPoint)}
};
static const GrAttribBindings kBindings = GrDrawState::kEdge_AttribBindingsBit;
SkMatrix viewM = drawState->getViewMatrix();
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp
index 9bf6195..c39aaf8 100644
--- a/src/gpu/GrAARectRenderer.cpp
+++ b/src/gpu/GrAARectRenderer.cpp
@@ -130,8 +130,8 @@
// position + color/coverage
static const GrVertexAttrib kVertexAttribs[] = {
- GrVertexAttrib(kVec2f_GrVertexAttribType, 0),
- GrVertexAttrib(kVec4ub_GrVertexAttribType, sizeof(GrPoint))
+ {kVec2f_GrVertexAttribType, 0},
+ {kVec4ub_GrVertexAttribType, sizeof(GrPoint)}
};
GrAttribBindings bindings;
GrDrawState::AttribIndex attribIndex;
@@ -214,8 +214,8 @@
// position + color/coverage
static const GrVertexAttrib kVertexAttribs[] = {
- GrVertexAttrib(kVec2f_GrVertexAttribType, 0),
- GrVertexAttrib(kVec4ub_GrVertexAttribType, sizeof(GrPoint))
+ {kVec2f_GrVertexAttribType, 0},
+ {kVec4ub_GrVertexAttribType, sizeof(GrPoint)}
};
GrAttribBindings bindings;
GrDrawState::AttribIndex attribIndex;
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 3b77b73..65f3e0f 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -354,8 +354,8 @@
// position + texture coordinate
static const GrVertexAttrib kVertexAttribs[] = {
- GrVertexAttrib(kVec2f_GrVertexAttribType, 0),
- GrVertexAttrib(kVec2f_GrVertexAttribType, sizeof(GrPoint))
+ {kVec2f_GrVertexAttribType, 0},
+ {kVec2f_GrVertexAttribType, sizeof(GrPoint)}
};
static const GrAttribBindings kAttribBindings = GrDrawState::ExplicitTexCoordAttribBindingsBit(0);
drawState->setAttribBindings(kAttribBindings);
@@ -929,14 +929,16 @@
// set position attribute
drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, attribs.count());
- attribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, currentOffset));
+ GrVertexAttrib currAttrib = {kVec2f_GrVertexAttribType, currentOffset};
+ attribs.push_back(currAttrib);
currentOffset += sizeof(GrPoint);
// set up optional texture coordinate attributes
if (NULL != texCoords) {
bindings |= GrDrawState::ExplicitTexCoordAttribBindingsBit(0);
drawState->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, attribs.count());
- attribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, currentOffset));
+ currAttrib.set(kVec2f_GrVertexAttribType, currentOffset);
+ attribs.push_back(currAttrib);
texOffset = currentOffset;
currentOffset += sizeof(GrPoint);
}
@@ -945,7 +947,8 @@
if (NULL != colors) {
bindings |= GrDrawState::kColor_AttribBindingsBit;
drawState->setAttribIndex(GrDrawState::kColor_AttribIndex, attribs.count());
- attribs.push_back(GrVertexAttrib(kVec4ub_GrVertexAttribType, currentOffset));
+ currAttrib.set(kVec4ub_GrVertexAttribType, currentOffset);
+ attribs.push_back(currAttrib);
colorOffset = currentOffset;
currentOffset += sizeof(GrColor);
}
@@ -1073,8 +1076,8 @@
// position + edge
static const GrVertexAttrib kVertexAttribs[] = {
- GrVertexAttrib(kVec2f_GrVertexAttribType, 0),
- GrVertexAttrib(kVec4f_GrVertexAttribType, sizeof(GrPoint))
+ {kVec2f_GrVertexAttribType, 0},
+ {kVec4f_GrVertexAttribType, sizeof(GrPoint)}
};
static const GrAttribBindings kAttributeBindings = GrDrawState::kEdge_AttribBindingsBit;
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index 6b00913..6a793bc 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -122,8 +122,9 @@
////////////////////////////////////////////////////////////////////////////////
void GrDrawState::setDefaultVertexAttribs() {
+ static const GrVertexAttrib kPositionAttrib = {kVec2f_GrVertexAttribType, 0};
fVertexAttribs.reset();
- fVertexAttribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, 0));
+ fVertexAttribs.push_back(kPositionAttrib);
fCommon.fAttribBindings = kDefault_AttribBindings;
@@ -152,7 +153,8 @@
GrVertexAttribArray<6> attribs;
GrAssert(0 == vertex_size(attribs.begin(), attribs.count()));
- attribs.push_back(GrVertexAttrib(kFloat_GrVertexAttribType, 0));
+ GrVertexAttrib currAttrib = {kFloat_GrVertexAttribType, 0};
+ attribs.push_back(currAttrib);
GrAssert(sizeof(float) == vertex_size(attribs.begin(), attribs.count()));
attribs[0].fType = kVec2f_GrVertexAttribType;
GrAssert(2*sizeof(float) == vertex_size(attribs.begin(), attribs.count()));
@@ -163,15 +165,19 @@
attribs[0].fType = kVec4ub_GrVertexAttribType;
GrAssert(4*sizeof(char) == vertex_size(attribs.begin(), attribs.count()));
- attribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, attribs[0].fOffset + 4*sizeof(char)));
+ currAttrib.set(kVec2f_GrVertexAttribType, attribs[0].fOffset + 4*sizeof(char));
+ attribs.push_back(currAttrib);
GrAssert(4*sizeof(char) + 2*sizeof(float) == vertex_size(attribs.begin(), attribs.count()));
- attribs.push_back(GrVertexAttrib(kVec3f_GrVertexAttribType, attribs[1].fOffset + 2*sizeof(float)));
+ currAttrib.set(kVec3f_GrVertexAttribType, attribs[1].fOffset + 2*sizeof(float));
+ attribs.push_back(currAttrib);
GrAssert(4*sizeof(char) + 2*sizeof(float) + 3*sizeof(float) ==
vertex_size(attribs.begin(), attribs.count()));
- attribs.push_back(GrVertexAttrib(kFloat_GrVertexAttribType, attribs[2].fOffset + 3*sizeof(float)));
+ currAttrib.set(kFloat_GrVertexAttribType, attribs[2].fOffset + 3*sizeof(float));
+ attribs.push_back(currAttrib);
GrAssert(4*sizeof(char) + 2*sizeof(float) + 3*sizeof(float) + sizeof(float) ==
vertex_size(attribs.begin(), attribs.count()));
- attribs.push_back(GrVertexAttrib(kVec4f_GrVertexAttribType, attribs[3].fOffset + sizeof(float)));
+ currAttrib.set(kVec4f_GrVertexAttribType, attribs[3].fOffset + sizeof(float));
+ attribs.push_back(currAttrib);
GrAssert(4*sizeof(char) + 2*sizeof(float) + 3*sizeof(float) + sizeof(float) + 4*sizeof(float) ==
vertex_size(attribs.begin(), attribs.count()));
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index b4d1306..fd11d21 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -38,9 +38,9 @@
static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1;
struct GrVertexAttrib {
- inline GrVertexAttrib() {}
- inline GrVertexAttrib(GrVertexAttribType type, size_t offset) :
- fType(type), fOffset(offset) {}
+ inline void set(GrVertexAttribType type, size_t offset) {
+ fType = type; fOffset = offset;
+ }
bool operator==(const GrVertexAttrib& other) const {
return fType == other.fType && fOffset == other.fOffset;
};
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index dab2965..954a4e7 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -534,8 +534,8 @@
uint32_t explicitCoordMask = 0;
// position + (optional) texture coord
static const GrVertexAttrib kAttribs[] = {
- GrVertexAttrib(kVec2f_GrVertexAttribType, 0),
- GrVertexAttrib(kVec2f_GrVertexAttribType, sizeof(GrPoint))
+ {kVec2f_GrVertexAttribType, 0},
+ {kVec2f_GrVertexAttribType, sizeof(GrPoint)}
};
int attribCount = 1;
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index b2705a4..31b1a57 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -90,7 +90,8 @@
// set position attrib
drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, attribs.count());
- attribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, currentOffset));
+ GrVertexAttrib currAttrib = {kVec2f_GrVertexAttribType, currentOffset};
+ attribs.push_back(currAttrib);
currentOffset += sizeof(GrPoint);
// Using per-vertex colors allows batching across colors. (A lot of rects in a row differing
@@ -103,7 +104,8 @@
drawState->hasSolidCoverage(drawState->getAttribBindings())) {
bindings |= GrDrawState::kColor_AttribBindingsBit;
drawState->setAttribIndex(GrDrawState::kColor_AttribIndex, attribs.count());
- attribs.push_back(GrVertexAttrib(kVec4ub_GrVertexAttribType, currentOffset));
+ currAttrib.set(kVec4ub_GrVertexAttribType, currentOffset);
+ attribs.push_back(currAttrib);
colorOffset = currentOffset;
currentOffset += sizeof(GrColor);
// We set the draw state's color to white here. This is done so that any batching performed
@@ -117,7 +119,8 @@
if (NULL != srcRect) {
bindings |= GrDrawState::ExplicitTexCoordAttribBindingsBit(stage);
drawState->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, attribs.count());
- attribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, currentOffset));
+ currAttrib.set(kVec2f_GrVertexAttribType, currentOffset);
+ attribs.push_back(currAttrib);
texOffset = currentOffset;
currentOffset += sizeof(GrPoint);
explicitCoordMask = (1 << stage);
diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp
index e77bf93..db5abb4 100644
--- a/src/gpu/GrTextContext.cpp
+++ b/src/gpu/GrTextContext.cpp
@@ -189,8 +189,8 @@
if (NULL == fVertices) {
// position + texture coord
static const GrVertexAttrib kVertexAttribs[] = {
- GrVertexAttrib(kVec2f_GrVertexAttribType, 0),
- GrVertexAttrib(kVec2f_GrVertexAttribType, sizeof(GrPoint))
+ {kVec2f_GrVertexAttribType, 0},
+ {kVec2f_GrVertexAttribType, sizeof(GrPoint)}
};
static const GrAttribBindings kAttribBindings = GrDrawState::ExplicitTexCoordAttribBindingsBit(kGlyphMaskStage);