diff options
author | jvanverth@google.com <jvanverth@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-03-01 20:30:01 +0000 |
---|---|---|
committer | jvanverth@google.com <jvanverth@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-03-01 20:30:01 +0000 |
commit | 3b0d631cdfe2dcf59e7b7ea60d92566eade7bfc0 (patch) | |
tree | 8c416b03a5c1c1776c2cbbf0b5fed1be76022e94 /src/gpu | |
parent | cef21e415b4b1fd7ed25a447a05d82a1b756c703 (diff) |
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
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrAAConvexPathRenderer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrAAHairLinePathRenderer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrAARectRenderer.cpp | 8 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 17 | ||||
-rw-r--r-- | src/gpu/GrDrawState.cpp | 18 | ||||
-rw-r--r-- | src/gpu/GrDrawState.h | 6 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.cpp | 9 | ||||
-rw-r--r-- | src/gpu/GrTextContext.cpp | 4 |
9 files changed, 43 insertions, 31 deletions
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp index 46e75a07a6..ebf2ea98c4 100644 --- a/src/gpu/GrAAConvexPathRenderer.cpp +++ b/src/gpu/GrAAConvexPathRenderer.cpp @@ -480,8 +480,8 @@ bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath, // 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 a2ad9e3327..783cadf82a 100644 --- a/src/gpu/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/GrAAHairLinePathRenderer.cpp @@ -504,8 +504,8 @@ bool GrAAHairLinePathRenderer::createGeom( // 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 9bf61958dd..c39aaf8036 100644 --- a/src/gpu/GrAARectRenderer.cpp +++ b/src/gpu/GrAARectRenderer.cpp @@ -130,8 +130,8 @@ void GrAARectRenderer::fillAARect(GrGpu* gpu, // 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 @@ void GrAARectRenderer::strokeAARect(GrGpu* gpu, // 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 3b77b73fe6..65f3e0f99f 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -354,8 +354,8 @@ GrTexture* GrContext::createResizedTexture(const GrTextureDesc& desc, // 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 @@ void GrContext::drawVertices(const GrPaint& paint, // 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 @@ void GrContext::drawVertices(const GrPaint& paint, 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 @@ void GrContext::internalDrawOval(const GrPaint& paint, // 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 6b00913036..6a793bc84c 100644 --- a/src/gpu/GrDrawState.cpp +++ b/src/gpu/GrDrawState.cpp @@ -122,8 +122,9 @@ void GrDrawState::setVertexAttribs(const GrVertexAttrib* attribs, int count) { //////////////////////////////////////////////////////////////////////////////// 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 @@ void GrDrawState::VertexAttributesUnitTest() { 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 @@ void GrDrawState::VertexAttributesUnitTest() { 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 b4d130648b..fd11d2164e 100644 --- a/src/gpu/GrDrawState.h +++ b/src/gpu/GrDrawState.h @@ -38,9 +38,9 @@ enum GrVertexAttribType { 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 dab2965c6b..954a4e7687 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -534,8 +534,8 @@ void GrDrawTarget::drawRect(const GrRect& rect, 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 b2705a4b9b..31b1a57c1f 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -90,7 +90,8 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect, // 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 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect, 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 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect, 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 e77bf93429..db5abb40b3 100644 --- a/src/gpu/GrTextContext.cpp +++ b/src/gpu/GrTextContext.cpp @@ -189,8 +189,8 @@ HAS_ATLAS: 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); |