aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDrawState.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-07 22:00:29 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-07 22:00:29 +0000
commit85983288ba8f4abc1fba4c54da827d2b089472e0 (patch)
tree3276c3ed59920948c82093c3ac9c49036b295e3c /src/gpu/GrDrawState.cpp
parentedbd21aa39fa706d38910bd9c14bef56c381409a (diff)
Remove compile time option to use different types for text vertices.
Review URL: https://codereview.appspot.com/7309060 git-svn-id: http://skia.googlecode.com/svn/trunk@7658 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/GrDrawState.cpp')
-rw-r--r--src/gpu/GrDrawState.cpp42
1 files changed, 11 insertions, 31 deletions
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index b6c521f093..5b434c3d7f 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -6,8 +6,6 @@
*/
#include "GrDrawState.h"
-
-#include "GrGpuVertex.h"
#include "GrPaint.h"
void GrDrawState::setFromPaint(const GrPaint& paint) {
@@ -149,15 +147,13 @@ int num_tex_coords(GrVertexLayout layout) {
} //unnamed namespace
+static const size_t kVec2Size = sizeof(GrPoint);
+
size_t GrDrawState::VertexSize(GrVertexLayout vertexLayout) {
GrAssert(check_layout(vertexLayout));
- size_t vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ?
- sizeof(GrGpuTextVertex) :
- sizeof(GrPoint);
-
- size_t size = vecSize; // position
- size += num_tex_coords(vertexLayout) * vecSize;
+ size_t size = kVec2Size; // position
+ size += num_tex_coords(vertexLayout) * kVec2Size;
if (vertexLayout & kColor_VertexLayoutBit) {
size += sizeof(GrColor);
}
@@ -194,14 +190,11 @@ int GrDrawState::VertexStageCoordOffset(int stageIdx, GrVertexLayout vertexLayou
int tcIdx = VertexTexCoordsForStage(stageIdx, vertexLayout);
if (tcIdx >= 0) {
- int vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ?
- sizeof(GrGpuTextVertex) :
- sizeof(GrPoint);
- int offset = vecSize; // position
+ int offset = kVec2Size; // position
// figure out how many tex coordinates are present and precede this one.
for (int t = 0; t < tcIdx; ++t) {
if (gTexCoordMasks[t] & vertexLayout) {
- offset += vecSize;
+ offset += kVec2Size;
}
}
return offset;
@@ -214,10 +207,7 @@ int GrDrawState::VertexColorOffset(GrVertexLayout vertexLayout) {
GrAssert(check_layout(vertexLayout));
if (vertexLayout & kColor_VertexLayoutBit) {
- int vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ?
- sizeof(GrGpuTextVertex) :
- sizeof(GrPoint);
- return vecSize * (num_tex_coords(vertexLayout) + 1); //+1 for pos
+ return kVec2Size * (num_tex_coords(vertexLayout) + 1); //+1 for pos
}
return -1;
}
@@ -226,11 +216,7 @@ int GrDrawState::VertexCoverageOffset(GrVertexLayout vertexLayout) {
GrAssert(check_layout(vertexLayout));
if (vertexLayout & kCoverage_VertexLayoutBit) {
- int vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ?
- sizeof(GrGpuTextVertex) :
- sizeof(GrPoint);
-
- int offset = vecSize * (num_tex_coords(vertexLayout) + 1);
+ int offset = kVec2Size * (num_tex_coords(vertexLayout) + 1);
if (vertexLayout & kColor_VertexLayoutBit) {
offset += sizeof(GrColor);
}
@@ -244,10 +230,7 @@ int GrDrawState::VertexEdgeOffset(GrVertexLayout vertexLayout) {
// edge pts are after the pos, tex coords, and color
if (vertexLayout & kEdge_VertexLayoutBit) {
- int vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ?
- sizeof(GrGpuTextVertex) :
- sizeof(GrPoint);
- int offset = vecSize * (num_tex_coords(vertexLayout) + 1); //+1 for pos
+ int offset = kVec2Size * (num_tex_coords(vertexLayout) + 1); //+1 for pos
if (vertexLayout & kColor_VertexLayoutBit) {
offset += sizeof(GrColor);
}
@@ -267,17 +250,14 @@ int GrDrawState::VertexSizeAndOffsetsByIdx(
int* edgeOffset) {
GrAssert(check_layout(vertexLayout));
- int vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ?
- sizeof(GrGpuTextVertex) :
- sizeof(GrPoint);
- int size = vecSize; // position
+ int size = kVec2Size; // position
for (int t = 0; t < kMaxTexCoords; ++t) {
if (gTexCoordMasks[t] & vertexLayout) {
if (NULL != texCoordOffsetsByIdx) {
texCoordOffsetsByIdx[t] = size;
}
- size += vecSize;
+ size += kVec2Size;
} else {
if (NULL != texCoordOffsetsByIdx) {
texCoordOffsetsByIdx[t] = -1;