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
This commit is contained in:
jvanverth@google.com 2013-03-01 20:30:01 +00:00
parent cef21e415b
commit 3b0d631cdf
9 changed files with 43 additions and 31 deletions

View File

@ -480,8 +480,8 @@ bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath,
// position + edge // position + edge
static const GrVertexAttrib kAttribs[] = { static const GrVertexAttrib kAttribs[] = {
GrVertexAttrib(kVec2f_GrVertexAttribType, 0), {kVec2f_GrVertexAttribType, 0},
GrVertexAttrib(kVec4f_GrVertexAttribType, sizeof(GrPoint)) {kVec4f_GrVertexAttribType, sizeof(GrPoint)}
}; };
static const GrAttribBindings bindings = GrDrawState::kEdge_AttribBindingsBit; static const GrAttribBindings bindings = GrDrawState::kEdge_AttribBindingsBit;

View File

@ -504,8 +504,8 @@ bool GrAAHairLinePathRenderer::createGeom(
// position + edge // position + edge
static const GrVertexAttrib kAttribs[] = { static const GrVertexAttrib kAttribs[] = {
GrVertexAttrib(kVec2f_GrVertexAttribType, 0), {kVec2f_GrVertexAttribType, 0},
GrVertexAttrib(kVec4f_GrVertexAttribType, sizeof(GrPoint)) {kVec4f_GrVertexAttribType, sizeof(GrPoint)}
}; };
static const GrAttribBindings kBindings = GrDrawState::kEdge_AttribBindingsBit; static const GrAttribBindings kBindings = GrDrawState::kEdge_AttribBindingsBit;
SkMatrix viewM = drawState->getViewMatrix(); SkMatrix viewM = drawState->getViewMatrix();

View File

@ -130,8 +130,8 @@ void GrAARectRenderer::fillAARect(GrGpu* gpu,
// position + color/coverage // position + color/coverage
static const GrVertexAttrib kVertexAttribs[] = { static const GrVertexAttrib kVertexAttribs[] = {
GrVertexAttrib(kVec2f_GrVertexAttribType, 0), {kVec2f_GrVertexAttribType, 0},
GrVertexAttrib(kVec4ub_GrVertexAttribType, sizeof(GrPoint)) {kVec4ub_GrVertexAttribType, sizeof(GrPoint)}
}; };
GrAttribBindings bindings; GrAttribBindings bindings;
GrDrawState::AttribIndex attribIndex; GrDrawState::AttribIndex attribIndex;
@ -214,8 +214,8 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu,
// position + color/coverage // position + color/coverage
static const GrVertexAttrib kVertexAttribs[] = { static const GrVertexAttrib kVertexAttribs[] = {
GrVertexAttrib(kVec2f_GrVertexAttribType, 0), {kVec2f_GrVertexAttribType, 0},
GrVertexAttrib(kVec4ub_GrVertexAttribType, sizeof(GrPoint)) {kVec4ub_GrVertexAttribType, sizeof(GrPoint)}
}; };
GrAttribBindings bindings; GrAttribBindings bindings;
GrDrawState::AttribIndex attribIndex; GrDrawState::AttribIndex attribIndex;

View File

@ -354,8 +354,8 @@ GrTexture* GrContext::createResizedTexture(const GrTextureDesc& desc,
// position + texture coordinate // position + texture coordinate
static const GrVertexAttrib kVertexAttribs[] = { static const GrVertexAttrib kVertexAttribs[] = {
GrVertexAttrib(kVec2f_GrVertexAttribType, 0), {kVec2f_GrVertexAttribType, 0},
GrVertexAttrib(kVec2f_GrVertexAttribType, sizeof(GrPoint)) {kVec2f_GrVertexAttribType, sizeof(GrPoint)}
}; };
static const GrAttribBindings kAttribBindings = GrDrawState::ExplicitTexCoordAttribBindingsBit(0); static const GrAttribBindings kAttribBindings = GrDrawState::ExplicitTexCoordAttribBindingsBit(0);
drawState->setAttribBindings(kAttribBindings); drawState->setAttribBindings(kAttribBindings);
@ -929,14 +929,16 @@ void GrContext::drawVertices(const GrPaint& paint,
// set position attribute // set position attribute
drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, attribs.count()); 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); currentOffset += sizeof(GrPoint);
// set up optional texture coordinate attributes // set up optional texture coordinate attributes
if (NULL != texCoords) { if (NULL != texCoords) {
bindings |= GrDrawState::ExplicitTexCoordAttribBindingsBit(0); bindings |= GrDrawState::ExplicitTexCoordAttribBindingsBit(0);
drawState->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, attribs.count()); 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; texOffset = currentOffset;
currentOffset += sizeof(GrPoint); currentOffset += sizeof(GrPoint);
} }
@ -945,7 +947,8 @@ void GrContext::drawVertices(const GrPaint& paint,
if (NULL != colors) { if (NULL != colors) {
bindings |= GrDrawState::kColor_AttribBindingsBit; bindings |= GrDrawState::kColor_AttribBindingsBit;
drawState->setAttribIndex(GrDrawState::kColor_AttribIndex, attribs.count()); 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; colorOffset = currentOffset;
currentOffset += sizeof(GrColor); currentOffset += sizeof(GrColor);
} }
@ -1073,8 +1076,8 @@ void GrContext::internalDrawOval(const GrPaint& paint,
// position + edge // position + edge
static const GrVertexAttrib kVertexAttribs[] = { static const GrVertexAttrib kVertexAttribs[] = {
GrVertexAttrib(kVec2f_GrVertexAttribType, 0), {kVec2f_GrVertexAttribType, 0},
GrVertexAttrib(kVec4f_GrVertexAttribType, sizeof(GrPoint)) {kVec4f_GrVertexAttribType, sizeof(GrPoint)}
}; };
static const GrAttribBindings kAttributeBindings = GrDrawState::kEdge_AttribBindingsBit; static const GrAttribBindings kAttributeBindings = GrDrawState::kEdge_AttribBindingsBit;

View File

@ -122,8 +122,9 @@ void GrDrawState::setVertexAttribs(const GrVertexAttrib* attribs, int count) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void GrDrawState::setDefaultVertexAttribs() { void GrDrawState::setDefaultVertexAttribs() {
static const GrVertexAttrib kPositionAttrib = {kVec2f_GrVertexAttribType, 0};
fVertexAttribs.reset(); fVertexAttribs.reset();
fVertexAttribs.push_back(GrVertexAttrib(kVec2f_GrVertexAttribType, 0)); fVertexAttribs.push_back(kPositionAttrib);
fCommon.fAttribBindings = kDefault_AttribBindings; fCommon.fAttribBindings = kDefault_AttribBindings;
@ -152,7 +153,8 @@ void GrDrawState::VertexAttributesUnitTest() {
GrVertexAttribArray<6> attribs; GrVertexAttribArray<6> attribs;
GrAssert(0 == vertex_size(attribs.begin(), attribs.count())); 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())); GrAssert(sizeof(float) == vertex_size(attribs.begin(), attribs.count()));
attribs[0].fType = kVec2f_GrVertexAttribType; attribs[0].fType = kVec2f_GrVertexAttribType;
GrAssert(2*sizeof(float) == vertex_size(attribs.begin(), attribs.count())); GrAssert(2*sizeof(float) == vertex_size(attribs.begin(), attribs.count()));
@ -163,15 +165,19 @@ void GrDrawState::VertexAttributesUnitTest() {
attribs[0].fType = kVec4ub_GrVertexAttribType; attribs[0].fType = kVec4ub_GrVertexAttribType;
GrAssert(4*sizeof(char) == vertex_size(attribs.begin(), attribs.count())); 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())); 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) == GrAssert(4*sizeof(char) + 2*sizeof(float) + 3*sizeof(float) ==
vertex_size(attribs.begin(), attribs.count())); 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) == GrAssert(4*sizeof(char) + 2*sizeof(float) + 3*sizeof(float) + sizeof(float) ==
vertex_size(attribs.begin(), attribs.count())); 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) == GrAssert(4*sizeof(char) + 2*sizeof(float) + 3*sizeof(float) + sizeof(float) + 4*sizeof(float) ==
vertex_size(attribs.begin(), attribs.count())); vertex_size(attribs.begin(), attribs.count()));

View File

@ -38,9 +38,9 @@ enum GrVertexAttribType {
static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1; static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1;
struct GrVertexAttrib { struct GrVertexAttrib {
inline GrVertexAttrib() {} inline void set(GrVertexAttribType type, size_t offset) {
inline GrVertexAttrib(GrVertexAttribType type, size_t offset) : fType = type; fOffset = offset;
fType(type), fOffset(offset) {} }
bool operator==(const GrVertexAttrib& other) const { bool operator==(const GrVertexAttrib& other) const {
return fType == other.fType && fOffset == other.fOffset; return fType == other.fType && fOffset == other.fOffset;
}; };

View File

@ -534,8 +534,8 @@ void GrDrawTarget::drawRect(const GrRect& rect,
uint32_t explicitCoordMask = 0; uint32_t explicitCoordMask = 0;
// position + (optional) texture coord // position + (optional) texture coord
static const GrVertexAttrib kAttribs[] = { static const GrVertexAttrib kAttribs[] = {
GrVertexAttrib(kVec2f_GrVertexAttribType, 0), {kVec2f_GrVertexAttribType, 0},
GrVertexAttrib(kVec2f_GrVertexAttribType, sizeof(GrPoint)) {kVec2f_GrVertexAttribType, sizeof(GrPoint)}
}; };
int attribCount = 1; int attribCount = 1;

View File

@ -90,7 +90,8 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
// set position attrib // set position attrib
drawState->setAttribIndex(GrDrawState::kPosition_AttribIndex, attribs.count()); 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); currentOffset += sizeof(GrPoint);
// Using per-vertex colors allows batching across colors. (A lot of rects in a row differing // Using per-vertex colors allows batching across colors. (A lot of rects in a row differing
@ -103,7 +104,8 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
drawState->hasSolidCoverage(drawState->getAttribBindings())) { drawState->hasSolidCoverage(drawState->getAttribBindings())) {
bindings |= GrDrawState::kColor_AttribBindingsBit; bindings |= GrDrawState::kColor_AttribBindingsBit;
drawState->setAttribIndex(GrDrawState::kColor_AttribIndex, attribs.count()); 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; colorOffset = currentOffset;
currentOffset += sizeof(GrColor); currentOffset += sizeof(GrColor);
// We set the draw state's color to white here. This is done so that any batching performed // We set the draw state's color to white here. This is done so that any batching performed
@ -117,7 +119,8 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
if (NULL != srcRect) { if (NULL != srcRect) {
bindings |= GrDrawState::ExplicitTexCoordAttribBindingsBit(stage); bindings |= GrDrawState::ExplicitTexCoordAttribBindingsBit(stage);
drawState->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, attribs.count()); 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; texOffset = currentOffset;
currentOffset += sizeof(GrPoint); currentOffset += sizeof(GrPoint);
explicitCoordMask = (1 << stage); explicitCoordMask = (1 << stage);

View File

@ -189,8 +189,8 @@ HAS_ATLAS:
if (NULL == fVertices) { if (NULL == fVertices) {
// position + texture coord // position + texture coord
static const GrVertexAttrib kVertexAttribs[] = { static const GrVertexAttrib kVertexAttribs[] = {
GrVertexAttrib(kVec2f_GrVertexAttribType, 0), {kVec2f_GrVertexAttribType, 0},
GrVertexAttrib(kVec2f_GrVertexAttribType, sizeof(GrPoint)) {kVec2f_GrVertexAttribType, sizeof(GrPoint)}
}; };
static const GrAttribBindings kAttribBindings = GrDrawState::ExplicitTexCoordAttribBindingsBit(kGlyphMaskStage); static const GrAttribBindings kAttribBindings = GrDrawState::ExplicitTexCoordAttribBindingsBit(kGlyphMaskStage);