Make setVertexAttribs in GrDrawState take a stride parameter.
authoregdaniel <egdaniel@google.com>
Thu, 28 Aug 2014 12:41:14 +0000 (05:41 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 28 Aug 2014 12:41:14 +0000 (05:41 -0700)
BUG=skia:

Committed: https://skia.googlesource.com/skia/+/af013bf8afc4c77ab8ff230f536e2ade973427fa

R=bsalomon@google.com

Author: egdaniel@google.com

Review URL: https://codereview.chromium.org/511593004

17 files changed:
gm/beziereffects.cpp
gm/convexpolyeffect.cpp
src/gpu/GrAAConvexPathRenderer.cpp
src/gpu/GrAAHairLinePathRenderer.cpp
src/gpu/GrAARectRenderer.cpp
src/gpu/GrBitmapTextContext.cpp
src/gpu/GrContext.cpp
src/gpu/GrDistanceFieldTextContext.cpp
src/gpu/GrDrawState.cpp
src/gpu/GrDrawState.h
src/gpu/GrDrawTarget.cpp
src/gpu/GrInOrderDrawBuffer.cpp
src/gpu/GrOvalRenderer.cpp
src/gpu/GrRODrawState.cpp
src/gpu/GrRODrawState.h
src/gpu/effects/GrDashingEffect.cpp
src/gpu/gl/GrGpuGL_program.cpp

index 2045e38ec4c57c56a562bc869eddf30dafaf270c..e0a1d8726e9001cf09b667840ff882185fbd4291 100644 (file)
@@ -168,7 +168,7 @@ protected:
                     context->getTestTarget(&tt);
                     SkASSERT(NULL != tt.target());
                     GrDrawState* drawState = tt.target()->drawState();
-                    drawState->setVertexAttribs<kAttribs>(2);
+                    drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex));
 
                     drawState->addCoverageEffect(effect, 1);
                     drawState->setRenderTarget(rt);
@@ -323,7 +323,7 @@ protected:
                     context->getTestTarget(&tt);
                     SkASSERT(NULL != tt.target());
                     GrDrawState* drawState = tt.target()->drawState();
-                    drawState->setVertexAttribs<kAttribs>(2);
+                    drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex));
 
                     drawState->addCoverageEffect(effect, 1);
                     drawState->setRenderTarget(rt);
@@ -507,7 +507,7 @@ protected:
                     context->getTestTarget(&tt);
                     SkASSERT(NULL != tt.target());
                     GrDrawState* drawState = tt.target()->drawState();
-                    drawState->setVertexAttribs<kAttribs>(2);
+                    drawState->setVertexAttribs<kAttribs>(2, sizeof(Vertex));
 
                     drawState->addCoverageEffect(effect, 1);
                     drawState->setRenderTarget(rt);
index 00e89db2b170c0b4e05d6998c97e2eb762046552..275193f326435be3ae42c8c77df4944c32d19d49 100644 (file)
@@ -127,7 +127,7 @@ protected:
                     return;
                 }
                 GrDrawState* drawState = tt.target()->drawState();
-                drawState->setVertexAttribs<kAttribs>(SK_ARRAY_COUNT(kAttribs));
+                drawState->setVertexAttribs<kAttribs>(SK_ARRAY_COUNT(kAttribs), sizeof(SkPoint));
 
                 SkMatrix m;
                 SkPath p;
@@ -193,7 +193,7 @@ protected:
                 }
 
                 GrDrawState* drawState = tt.target()->drawState();
-                drawState->setVertexAttribs<kAttribs>(SK_ARRAY_COUNT(kAttribs));
+                drawState->setVertexAttribs<kAttribs>(SK_ARRAY_COUNT(kAttribs), sizeof(SkPoint));
                 drawState->addCoverageEffect(effect, 1);
                 drawState->setIdentityViewMatrix();
                 drawState->setRenderTarget(rt);
index b29c7c80a346ecc1286f70a036e4bfc9ad1025e8..c260382dbb394690246e7be17b5498c2e2e16b5d 100644 (file)
@@ -674,7 +674,7 @@ bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath,
     // Our computed verts should all be within one pixel of the segment control points.
     devBounds.outset(SK_Scalar1, SK_Scalar1);
 
-    drawState->setVertexAttribs<gPathAttribs>(SK_ARRAY_COUNT(gPathAttribs));
+    drawState->setVertexAttribs<gPathAttribs>(SK_ARRAY_COUNT(gPathAttribs), sizeof(QuadVertex));
 
     static const int kEdgeAttrIndex = 1;
     GrEffect* quadEffect = QuadEdgeEffect::Create();
@@ -684,7 +684,6 @@ bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath,
     if (!arg.succeeded()) {
         return false;
     }
-    SkASSERT(sizeof(QuadVertex) == drawState->getVertexSize());
     verts = reinterpret_cast<QuadVertex*>(arg.vertices());
     idxs = reinterpret_cast<uint16_t*>(arg.indices());
 
index d5ff40d9551d364d878c89327b29913c340295b2..2114720f34fd86cad72cca3aa5a09e2900234a2b 100644 (file)
@@ -731,8 +731,8 @@ bool GrAAHairLinePathRenderer::createLineGeom(const SkPath& path,
 
     int vertCnt = kVertsPerLineSeg * lineCnt;
 
-    drawState->setVertexAttribs<gHairlineLineAttribs>(SK_ARRAY_COUNT(gHairlineLineAttribs));
-    SkASSERT(sizeof(LineVertex) == drawState->getVertexSize());
+    drawState->setVertexAttribs<gHairlineLineAttribs>(SK_ARRAY_COUNT(gHairlineLineAttribs),
+                                                      sizeof(LineVertex));
 
     if (!arg->set(target, vertCnt, 0)) {
         return false;
@@ -778,8 +778,8 @@ bool GrAAHairLinePathRenderer::createBezierGeom(
 
     int vertCnt = kVertsPerQuad * quadCnt + kVertsPerQuad * conicCnt;
 
-    target->drawState()->setVertexAttribs<gHairlineBezierAttribs>(SK_ARRAY_COUNT(gHairlineBezierAttribs));
-    SkASSERT(sizeof(BezierVertex) == target->getDrawState().getVertexSize());
+    int vAttribCnt = SK_ARRAY_COUNT(gHairlineBezierAttribs);
+    target->drawState()->setVertexAttribs<gHairlineBezierAttribs>(vAttribCnt, sizeof(BezierVertex));
 
     if (!arg->set(target, vertCnt, 0)) {
         return false;
index b4790bb99d9d309f640a9ca0ce0dd217afc5cfb9..a7ddfde7ccb7c6867ac45e199ef9a224a164d4d1 100644 (file)
@@ -276,10 +276,10 @@ enum CoverageAttribType {
 
 static CoverageAttribType set_rect_attribs(GrDrawState* drawState) {
     if (drawState->canTweakAlphaForCoverage()) {
-        drawState->setVertexAttribs<gAARectAttribs>(2);
+        drawState->setVertexAttribs<gAARectAttribs>(2, sizeof(SkPoint) + sizeof(SkColor));
         return kUseColor_CoverageAttribType;
     } else {
-        drawState->setVertexAttribs<gAARectAttribs>(3);
+        drawState->setVertexAttribs<gAARectAttribs>(3, sizeof(SkPoint) + 2 * sizeof(SkColor));
         return kUseCoverage_CoverageAttribType;
     }
 }
@@ -482,10 +482,10 @@ void GrAARectRenderer::geometryFillAARect(GrGpu* gpu,
     }
 
     intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices());
-    size_t vsize = drawState->getVertexSize();
+    size_t vstride = drawState->getVertexStride();
 
     SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts);
-    SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + 4 * vsize);
+    SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + 4 * vstride);
 
     SkScalar inset = SkMinScalar(devRect.width(), SK_Scalar1);
     inset = SK_ScalarHalf * SkMinScalar(inset, devRect.height());
@@ -499,8 +499,8 @@ void GrAARectRenderer::geometryFillAARect(GrGpu* gpu,
         combinedMatrix.mapRect(&devRect, rect);
 #endif
 
-        set_inset_fan(fan0Pos, vsize, devRect, -SK_ScalarHalf, -SK_ScalarHalf);
-        set_inset_fan(fan1Pos, vsize, devRect, inset,  inset);
+        set_inset_fan(fan0Pos, vstride, devRect, -SK_ScalarHalf, -SK_ScalarHalf);
+        set_inset_fan(fan1Pos, vstride, devRect, inset,  inset);
     } else {
         // compute transformed (1, 0) and (0, 1) vectors
         SkVector vec[2] = {
@@ -515,38 +515,38 @@ void GrAARectRenderer::geometryFillAARect(GrGpu* gpu,
 
         // create the rotated rect
         fan0Pos->setRectFan(rect.fLeft, rect.fTop,
-                            rect.fRight, rect.fBottom, vsize);
-        combinedMatrix.mapPointsWithStride(fan0Pos, vsize, 4);
+                            rect.fRight, rect.fBottom, vstride);
+        combinedMatrix.mapPointsWithStride(fan0Pos, vstride, 4);
 
         // Now create the inset points and then outset the original
         // rotated points
 
         // TL
-        *((SkPoint*)((intptr_t)fan1Pos + 0 * vsize)) =
-            *((SkPoint*)((intptr_t)fan0Pos + 0 * vsize)) + vec[0] + vec[1];
-        *((SkPoint*)((intptr_t)fan0Pos + 0 * vsize)) -= vec[0] + vec[1];
+        *((SkPoint*)((intptr_t)fan1Pos + 0 * vstride)) =
+            *((SkPoint*)((intptr_t)fan0Pos + 0 * vstride)) + vec[0] + vec[1];
+        *((SkPoint*)((intptr_t)fan0Pos + 0 * vstride)) -= vec[0] + vec[1];
         // BL
-        *((SkPoint*)((intptr_t)fan1Pos + 1 * vsize)) =
-            *((SkPoint*)((intptr_t)fan0Pos + 1 * vsize)) + vec[0] - vec[1];
-        *((SkPoint*)((intptr_t)fan0Pos + 1 * vsize)) -= vec[0] - vec[1];
+        *((SkPoint*)((intptr_t)fan1Pos + 1 * vstride)) =
+            *((SkPoint*)((intptr_t)fan0Pos + 1 * vstride)) + vec[0] - vec[1];
+        *((SkPoint*)((intptr_t)fan0Pos + 1 * vstride)) -= vec[0] - vec[1];
         // BR
-        *((SkPoint*)((intptr_t)fan1Pos + 2 * vsize)) =
-            *((SkPoint*)((intptr_t)fan0Pos + 2 * vsize)) - vec[0] - vec[1];
-        *((SkPoint*)((intptr_t)fan0Pos + 2 * vsize)) += vec[0] + vec[1];
+        *((SkPoint*)((intptr_t)fan1Pos + 2 * vstride)) =
+            *((SkPoint*)((intptr_t)fan0Pos + 2 * vstride)) - vec[0] - vec[1];
+        *((SkPoint*)((intptr_t)fan0Pos + 2 * vstride)) += vec[0] + vec[1];
         // TR
-        *((SkPoint*)((intptr_t)fan1Pos + 3 * vsize)) =
-            *((SkPoint*)((intptr_t)fan0Pos + 3 * vsize)) - vec[0] + vec[1];
-        *((SkPoint*)((intptr_t)fan0Pos + 3 * vsize)) += vec[0] - vec[1];
+        *((SkPoint*)((intptr_t)fan1Pos + 3 * vstride)) =
+            *((SkPoint*)((intptr_t)fan0Pos + 3 * vstride)) - vec[0] + vec[1];
+        *((SkPoint*)((intptr_t)fan0Pos + 3 * vstride)) += vec[0] - vec[1];
     }
 
     // Make verts point to vertex color and then set all the color and coverage vertex attrs values.
     verts += sizeof(SkPoint);
     for (int i = 0; i < 4; ++i) {
         if (kUseCoverage_CoverageAttribType == covAttribType) {
-            *reinterpret_cast<GrColor*>(verts + i * vsize) = color;
-            *reinterpret_cast<GrColor*>(verts + i * vsize + sizeof(GrColor)) = 0;
+            *reinterpret_cast<GrColor*>(verts + i * vstride) = color;
+            *reinterpret_cast<GrColor*>(verts + i * vstride + sizeof(GrColor)) = 0;
         } else {
-            *reinterpret_cast<GrColor*>(verts + i * vsize) = 0;
+            *reinterpret_cast<GrColor*>(verts + i * vstride) = 0;
         }
     }
 
@@ -564,13 +564,13 @@ void GrAARectRenderer::geometryFillAARect(GrGpu* gpu,
     } else {
         innerCoverage = (0xff == scale) ? color : SkAlphaMulQ(color, scale);
     }
-    verts += 4 * vsize;
+    verts += 4 * vstride;
     for (int i = 0; i < 4; ++i) {
         if (kUseCoverage_CoverageAttribType == covAttribType) {
-            *reinterpret_cast<GrColor*>(verts + i * vsize) = color;
-            *reinterpret_cast<GrColor*>(verts + i * vsize + sizeof(GrColor)) = innerCoverage;
+            *reinterpret_cast<GrColor*>(verts + i * vstride) = color;
+            *reinterpret_cast<GrColor*>(verts + i * vstride + sizeof(GrColor)) = innerCoverage;
         } else {
-            *reinterpret_cast<GrColor*>(verts + i * vsize) = innerCoverage;
+            *reinterpret_cast<GrColor*>(verts + i * vstride) = innerCoverage;
         }
     }
 
@@ -634,8 +634,8 @@ void GrAARectRenderer::shaderFillAARect(GrGpu* gpu,
 
     SkScalar newWidth = SkScalarHalf(rect.width() * vec[0].length()) + SK_ScalarHalf;
     SkScalar newHeight = SkScalarHalf(rect.height() * vec[1].length()) + SK_ScalarHalf;
-    drawState->setVertexAttribs<gAARectVertexAttribs>(SK_ARRAY_COUNT(gAARectVertexAttribs));
-    SkASSERT(sizeof(RectVertex) == drawState->getVertexSize());
+    drawState->setVertexAttribs<gAARectVertexAttribs>(SK_ARRAY_COUNT(gAARectVertexAttribs),
+                                                      sizeof(RectVertex));
 
     GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0);
     if (!geo.succeeded()) {
@@ -684,8 +684,8 @@ void GrAARectRenderer::shaderFillAlignedAARect(GrGpu* gpu,
     GrDrawState* drawState = target->drawState();
     SkASSERT(combinedMatrix.rectStaysRect());
 
-    drawState->setVertexAttribs<gAAAARectVertexAttribs>(SK_ARRAY_COUNT(gAAAARectVertexAttribs));
-    SkASSERT(sizeof(AARectVertex) == drawState->getVertexSize());
+    drawState->setVertexAttribs<gAAAARectVertexAttribs>(SK_ARRAY_COUNT(gAAAARectVertexAttribs),
+                                                        sizeof(AARectVertex));
 
     GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0);
     if (!geo.succeeded()) {
@@ -834,15 +834,15 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
     }
 
     intptr_t verts = reinterpret_cast<intptr_t>(geo.vertices());
-    size_t vsize = drawState->getVertexSize();
+    size_t vstride = drawState->getVertexStride();
 
     // We create vertices for four nested rectangles. There are two ramps from 0 to full
     // coverage, one on the exterior of the stroke and the other on the interior.
     // The following pointers refer to the four rects, from outermost to innermost.
     SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts);
-    SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + outerVertexNum * vsize);
-    SkPoint* fan2Pos = reinterpret_cast<SkPoint*>(verts + 2 * outerVertexNum * vsize);
-    SkPoint* fan3Pos = reinterpret_cast<SkPoint*>(verts + (2 * outerVertexNum + innerVertexNum) * vsize);
+    SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + outerVertexNum * vstride);
+    SkPoint* fan2Pos = reinterpret_cast<SkPoint*>(verts + 2 * outerVertexNum * vstride);
+    SkPoint* fan3Pos = reinterpret_cast<SkPoint*>(verts + (2 * outerVertexNum + innerVertexNum) * vstride);
 
 #ifndef SK_IGNORE_THIN_STROKED_RECT_FIX
     // TODO: this only really works if the X & Y margins are the same all around
@@ -862,25 +862,25 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
 
     if (miterStroke) {
         // outermost
-        set_inset_fan(fan0Pos, vsize, devOutside, -SK_ScalarHalf, -SK_ScalarHalf);
+        set_inset_fan(fan0Pos, vstride, devOutside, -SK_ScalarHalf, -SK_ScalarHalf);
         // inner two
-        set_inset_fan(fan1Pos, vsize, devOutside,  inset,  inset);
-        set_inset_fan(fan2Pos, vsize, devInside,  -inset, -inset);
+        set_inset_fan(fan1Pos, vstride, devOutside,  inset,  inset);
+        set_inset_fan(fan2Pos, vstride, devInside,  -inset, -inset);
         // innermost
-        set_inset_fan(fan3Pos, vsize, devInside,   SK_ScalarHalf,  SK_ScalarHalf);
+        set_inset_fan(fan3Pos, vstride, devInside,   SK_ScalarHalf,  SK_ScalarHalf);
     } else {
-        SkPoint* fan0AssistPos = reinterpret_cast<SkPoint*>(verts + 4 * vsize);
-        SkPoint* fan1AssistPos = reinterpret_cast<SkPoint*>(verts + (outerVertexNum + 4) * vsize);
+        SkPoint* fan0AssistPos = reinterpret_cast<SkPoint*>(verts + 4 * vstride);
+        SkPoint* fan1AssistPos = reinterpret_cast<SkPoint*>(verts + (outerVertexNum + 4) * vstride);
         // outermost
-        set_inset_fan(fan0Pos, vsize, devOutside, -SK_ScalarHalf, -SK_ScalarHalf);
-        set_inset_fan(fan0AssistPos, vsize, devOutsideAssist, -SK_ScalarHalf, -SK_ScalarHalf);
+        set_inset_fan(fan0Pos, vstride, devOutside, -SK_ScalarHalf, -SK_ScalarHalf);
+        set_inset_fan(fan0AssistPos, vstride, devOutsideAssist, -SK_ScalarHalf, -SK_ScalarHalf);
         // outer one of the inner two
-        set_inset_fan(fan1Pos, vsize, devOutside,  inset,  inset);
-        set_inset_fan(fan1AssistPos, vsize, devOutsideAssist,  inset,  inset);
+        set_inset_fan(fan1Pos, vstride, devOutside,  inset,  inset);
+        set_inset_fan(fan1AssistPos, vstride, devOutsideAssist,  inset,  inset);
         // inner one of the inner two
-        set_inset_fan(fan2Pos, vsize, devInside,  -inset, -inset);
+        set_inset_fan(fan2Pos, vstride, devInside,  -inset, -inset);
         // innermost
-        set_inset_fan(fan3Pos, vsize, devInside,   SK_ScalarHalf,  SK_ScalarHalf);
+        set_inset_fan(fan3Pos, vstride, devInside,   SK_ScalarHalf,  SK_ScalarHalf);
     }
 
     // Make verts point to vertex color and then set all the color and coverage vertex attrs values.
@@ -888,10 +888,10 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
     verts += sizeof(SkPoint);
     for (int i = 0; i < outerVertexNum; ++i) {
         if (kUseCoverage_CoverageAttribType == covAttribType) {
-            *reinterpret_cast<GrColor*>(verts + i * vsize) = color;
-            *reinterpret_cast<GrColor*>(verts + i * vsize + sizeof(GrColor)) = 0;
+            *reinterpret_cast<GrColor*>(verts + i * vstride) = color;
+            *reinterpret_cast<GrColor*>(verts + i * vstride + sizeof(GrColor)) = 0;
         } else {
-            *reinterpret_cast<GrColor*>(verts + i * vsize) = 0;
+            *reinterpret_cast<GrColor*>(verts + i * vstride) = 0;
         }
     }
 
@@ -904,7 +904,7 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
         scale = 0xff;
     }
 
-    verts += outerVertexNum * vsize;
+    verts += outerVertexNum * vstride;
     GrColor innerCoverage;
     if (kUseCoverage_CoverageAttribType == covAttribType) {
         innerCoverage = GrColorPackRGBA(scale, scale, scale, scale);
@@ -914,21 +914,21 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
 
     for (int i = 0; i < outerVertexNum + innerVertexNum; ++i) {
         if (kUseCoverage_CoverageAttribType == covAttribType) {
-            *reinterpret_cast<GrColor*>(verts + i * vsize) = color;
-            *reinterpret_cast<GrColor*>(verts + i * vsize + sizeof(GrColor)) = innerCoverage;
+            *reinterpret_cast<GrColor*>(verts + i * vstride) = color;
+            *reinterpret_cast<GrColor*>(verts + i * vstride + sizeof(GrColor)) = innerCoverage;
         } else {
-            *reinterpret_cast<GrColor*>(verts + i * vsize) = innerCoverage;
+            *reinterpret_cast<GrColor*>(verts + i * vstride) = innerCoverage;
         }
     }
 
     // The innermost rect has 0 coverage
-    verts += (outerVertexNum + innerVertexNum) * vsize;
+    verts += (outerVertexNum + innerVertexNum) * vstride;
     for (int i = 0; i < innerVertexNum; ++i) {
         if (kUseCoverage_CoverageAttribType == covAttribType) {
-            *reinterpret_cast<GrColor*>(verts + i * vsize) = color;
-            *reinterpret_cast<GrColor*>(verts + i * vsize + sizeof(GrColor)) = 0;
+            *reinterpret_cast<GrColor*>(verts + i * vstride) = color;
+            *reinterpret_cast<GrColor*>(verts + i * vstride + sizeof(GrColor)) = 0;
         } else {
-            *reinterpret_cast<GrColor*>(verts + i * vsize) = 0;
+            *reinterpret_cast<GrColor*>(verts + i * vstride) = 0;
         }
     }
 
index 0c4d324d895b49ffb5236cfa86183830082a3229..6599d4ea473a719b2edbe8459047b494e31d10f1 100755 (executable)
@@ -40,6 +40,8 @@ extern const GrVertexAttrib gTextVertexAttribs[] = {
     {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kEffect_GrVertexAttribBinding}
 };
 
+static const size_t kTextVASize = 2 * sizeof(SkPoint); 
+
 // position + color + texture coord
 extern const GrVertexAttrib gTextVertexWithColorAttribs[] = {
     {kVec2f_GrVertexAttribType,  0,                                 kPosition_GrVertexAttribBinding},
@@ -47,6 +49,8 @@ extern const GrVertexAttrib gTextVertexWithColorAttribs[] = {
     {kVec2f_GrVertexAttribType,  sizeof(SkPoint) + sizeof(GrColor), kEffect_GrVertexAttribBinding}
 };
 
+static const size_t kTextVAColorSize = 2 * sizeof(SkPoint) + sizeof(GrColor); 
+
 };
 
 GrBitmapTextContext::GrBitmapTextContext(GrContext* context,
@@ -528,10 +532,10 @@ HAS_ATLAS:
         fMaxVertices = kMinRequestedVerts;
         if (useColorVerts) {
             fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttribs>(
-                SK_ARRAY_COUNT(gTextVertexWithColorAttribs));
+                SK_ARRAY_COUNT(gTextVertexWithColorAttribs), kTextVAColorSize);
         } else {
             fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(
-                SK_ARRAY_COUNT(gTextVertexAttribs));
+                SK_ARRAY_COUNT(gTextVertexAttribs), kTextVASize);
         }
         bool flush = fDrawTarget->geometryHints(&fMaxVertices, NULL);
         if (flush) {
@@ -539,10 +543,10 @@ HAS_ATLAS:
             fContext->flush();
             if (useColorVerts) {
                 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttribs>(
-                  SK_ARRAY_COUNT(gTextVertexWithColorAttribs));
+                    SK_ARRAY_COUNT(gTextVertexWithColorAttribs), kTextVAColorSize);
             } else {
                 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(
-                  SK_ARRAY_COUNT(gTextVertexAttribs));
+                    SK_ARRAY_COUNT(gTextVertexAttribs), kTextVASize);
             }
         }
         fMaxVertices = kDefaultRequestedVerts;
@@ -577,7 +581,7 @@ HAS_ATLAS:
     size_t vertSize = useColorVerts ? (2 * sizeof(SkPoint) + sizeof(GrColor)) :
                                       (2 * sizeof(SkPoint));
 
-    SkASSERT(vertSize == fDrawTarget->getDrawState().getVertexSize());
+    SkASSERT(vertSize == fDrawTarget->getDrawState().getVertexStride());
 
     SkPoint* positions = reinterpret_cast<SkPoint*>(
         reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex);
index 3b44b7e7c089ec8400c7efcbd913f413b411fcd5..322ea87dcb88017904d13777aebbeb6d4535230a 100755 (executable)
@@ -365,7 +365,8 @@ GrTexture* GrContext::createResizedTexture(const GrTextureDesc& desc,
                                                                    GrTextureParams::kNone_FilterMode);
         drawState->addColorTextureEffect(clampedTexture, SkMatrix::I(), params);
 
-        drawState->setVertexAttribs<gVertexAttribs>(SK_ARRAY_COUNT(gVertexAttribs));
+        drawState->setVertexAttribs<gVertexAttribs>(SK_ARRAY_COUNT(gVertexAttribs),
+                                                    2 * sizeof(SkPoint));
 
         GrDrawTarget::AutoReleaseGeometry arg(fGpu, 4, 0);
 
@@ -935,11 +936,17 @@ extern const GrVertexAttrib gPosUVColorAttribs[] = {
     {kVec4ub_GrVertexAttribType, 2*sizeof(SkPoint), kColor_GrVertexAttribBinding}
 };
 
+static const size_t kPosUVAttribsSize = 2 * sizeof(SkPoint);
+static const size_t kPosUVColorAttribsSize = 2 * sizeof(SkPoint) + sizeof(GrColor);
+
 extern const GrVertexAttrib gPosColorAttribs[] = {
     {kVec2f_GrVertexAttribType,  0, kPosition_GrVertexAttribBinding},
     {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVertexAttribBinding},
 };
 
+static const size_t kPosAttribsSize = sizeof(SkPoint);
+static const size_t kPosColorAttribsSize = sizeof(SkPoint) + sizeof(GrColor);
+
 static void set_vertex_attributes(GrDrawState* drawState,
                                   const SkPoint* texCoords,
                                   const GrColor* colors,
@@ -951,15 +958,15 @@ static void set_vertex_attributes(GrDrawState* drawState,
     if (NULL != texCoords && NULL != colors) {
         *texOffset = sizeof(SkPoint);
         *colorOffset = 2*sizeof(SkPoint);
-        drawState->setVertexAttribs<gPosUVColorAttribs>(3);
+        drawState->setVertexAttribs<gPosUVColorAttribs>(3, kPosUVColorAttribsSize);
     } else if (NULL != texCoords) {
         *texOffset = sizeof(SkPoint);
-        drawState->setVertexAttribs<gPosUVColorAttribs>(2);
+        drawState->setVertexAttribs<gPosUVColorAttribs>(2, kPosUVAttribsSize);
     } else if (NULL != colors) {
         *colorOffset = sizeof(SkPoint);
-        drawState->setVertexAttribs<gPosColorAttribs>(2);
+        drawState->setVertexAttribs<gPosColorAttribs>(2, kPosColorAttribsSize);
     } else {
-        drawState->setVertexAttribs<gPosColorAttribs>(1);
+        drawState->setVertexAttribs<gPosColorAttribs>(1, kPosAttribsSize);
     }
 }
 
@@ -988,8 +995,8 @@ void GrContext::drawVertices(const GrPaint& paint,
     int colorOffset = -1, texOffset = -1;
     set_vertex_attributes(drawState, texCoords, colors, &colorOffset, &texOffset);
 
-    size_t vertexSize = drawState->getVertexSize();
-    if (sizeof(SkPoint) != vertexSize) {
+    size_t VertexStride = drawState->getVertexStride();
+    if (sizeof(SkPoint) != VertexStride) {
         if (!geo.set(target, vertexCount, 0)) {
             GrPrintf("Failed to get space for vertices!\n");
             return;
@@ -1005,7 +1012,7 @@ void GrContext::drawVertices(const GrPaint& paint,
             if (colorOffset >= 0) {
                 *(GrColor*)((intptr_t)curVertex + colorOffset) = colors[i];
             }
-            curVertex = (void*)((intptr_t)curVertex + vertexSize);
+            curVertex = (void*)((intptr_t)curVertex + VertexStride);
         }
     } else {
         target->setVertexSourceToArray(positions, vertexCount);
index b7b4f9903f1fdeba7f63fe62ec802c4ff4fec610..dc0ea954ec189f50cd47f058acd6a35497a3c2a0 100755 (executable)
@@ -44,6 +44,8 @@ extern const GrVertexAttrib gTextVertexAttribs[] = {
     {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kEffect_GrVertexAttribBinding}
 };
 
+static const size_t kTextVASize = 2 * sizeof(SkPoint); 
+
 // position + color + texture coord
 extern const GrVertexAttrib gTextVertexWithColorAttribs[] = {
     {kVec2f_GrVertexAttribType,  0,                                 kPosition_GrVertexAttribBinding},
@@ -51,6 +53,8 @@ extern const GrVertexAttrib gTextVertexWithColorAttribs[] = {
     {kVec2f_GrVertexAttribType,  sizeof(SkPoint) + sizeof(GrColor), kEffect_GrVertexAttribBinding}
 };
     
+static const size_t kTextVAColorSize = 2 * sizeof(SkPoint) + sizeof(GrColor); 
+
 };
 
 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context,
@@ -342,10 +346,12 @@ HAS_ATLAS:
         fMaxVertices = kMinRequestedVerts;
         if (useColorVerts) {
             fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttribs>(
-                                                    SK_ARRAY_COUNT(gTextVertexWithColorAttribs));
+                                                    SK_ARRAY_COUNT(gTextVertexWithColorAttribs),
+                                                    kTextVAColorSize);
         } else {
             fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(
-                                                    SK_ARRAY_COUNT(gTextVertexAttribs));
+                                                    SK_ARRAY_COUNT(gTextVertexAttribs),
+                                                    kTextVASize);
         }
         bool flush = fDrawTarget->geometryHints(&fMaxVertices, NULL);
         if (flush) {
@@ -353,10 +359,12 @@ HAS_ATLAS:
             fContext->flush();
             if (useColorVerts) {
                 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttribs>(
-                                                    SK_ARRAY_COUNT(gTextVertexWithColorAttribs));
+                                                    SK_ARRAY_COUNT(gTextVertexWithColorAttribs),
+                                                    kTextVAColorSize);
             } else {
                 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(
-                                                    SK_ARRAY_COUNT(gTextVertexAttribs));
+                                                    SK_ARRAY_COUNT(gTextVertexAttribs),
+                                                    kTextVASize);
             }
         }
         fMaxVertices = kDefaultRequestedVerts;
@@ -406,7 +414,7 @@ HAS_ATLAS:
     size_t vertSize = fUseLCDText ? (2 * sizeof(SkPoint))
                                   : (2 * sizeof(SkPoint) + sizeof(GrColor));
 
-    SkASSERT(vertSize == fDrawTarget->getDrawState().getVertexSize());
+    SkASSERT(vertSize == fDrawTarget->getDrawState().getVertexStride());
 
     SkPoint* positions = reinterpret_cast<SkPoint*>(
         reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex);
index a6b3d68238cdc18a20f527c9f7a3dccd5b05b8c9..0c2b1c3684e295d3bb321669375a9f3d414cb4ed 100644 (file)
@@ -75,7 +75,7 @@ GrDrawState& GrDrawState::operator=(const GrDrawState& that) {
     fFlagBits = that.fFlagBits;
     fVACount = that.fVACount;
     fVAPtr = that.fVAPtr;
-    fVertexSize = that.fVertexSize;
+    fVAStride = that.fVAStride;
     fStencilSettings = that.fStencilSettings;
     fCoverage = that.fCoverage;
     fDrawFace = that.fDrawFace;
@@ -178,35 +178,34 @@ void GrDrawState::setFromPaint(const GrPaint& paint, const SkMatrix& vm, GrRende
 
 ////////////////////////////////////////////////////////////////////////////////
 
-static size_t vertex_size(const GrVertexAttrib* attribs, int count) {
+static void validate_vertex_attribs(const GrVertexAttrib* attribs, int count, size_t stride) {
     // this works as long as we're 4 byte-aligned
 #ifdef SK_DEBUG
     uint32_t overlapCheck = 0;
-#endif
     SkASSERT(count <= GrRODrawState::kMaxVertexAttribCnt);
-    size_t size = 0;
     for (int index = 0; index < count; ++index) {
         size_t attribSize = GrVertexAttribTypeSize(attribs[index].fType);
-        size += attribSize;
-#ifdef SK_DEBUG
+        size_t attribOffset = attribs[index].fOffset;
+        SkASSERT(attribOffset + attribSize <= stride);
         size_t dwordCount = attribSize >> 2;
         uint32_t mask = (1 << dwordCount)-1;
-        size_t offsetShift = attribs[index].fOffset >> 2;
+        size_t offsetShift = attribOffset >> 2;
         SkASSERT(!(overlapCheck & (mask << offsetShift)));
         overlapCheck |= (mask << offsetShift);
-#endif
     }
-    return size;
+#endif
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
-void GrDrawState::setVertexAttribs(const GrVertexAttrib* attribs, int count) {
+void GrDrawState::internalSetVertexAttribs(const GrVertexAttrib* attribs, int count,
+                                           size_t stride) {
     SkASSERT(count <= kMaxVertexAttribCnt);
 
     fVAPtr = attribs;
     fVACount = count;
-    fVertexSize = vertex_size(fVAPtr, fVACount);
+    fVAStride = stride;
+    validate_vertex_attribs(fVAPtr, fVACount, fVAStride);
 
     // Set all the indices to -1
     memset(fFixedFunctionVertexAttribIndices,
@@ -244,7 +243,7 @@ void GrDrawState::setDefaultVertexAttribs() {
 
     fVAPtr = &kPositionAttrib;
     fVACount = 1;
-    fVertexSize = GrVertexAttribTypeSize(kVec2f_GrVertexAttribType);
+    fVAStride = GrVertexAttribTypeSize(kVec2f_GrVertexAttribType);
 
     // set all the fixed function indices to -1 except position.
     memset(fFixedFunctionVertexAttribIndices,
@@ -279,6 +278,7 @@ GrDrawState::AutoVertexAttribRestore::AutoVertexAttribRestore(
     fDrawState = drawState;
     fVAPtr = drawState->fVAPtr;
     fVACount = drawState->fVACount;
+    fVAStride = drawState->fVAStride;
     fDrawState->setDefaultVertexAttribs();
 }
 
index dcd6ff9aaf8459f03ee68ec12b65c7e38311c02c..ec0ccade3746dec09bb10201b03eec04c903b38d 100644 (file)
@@ -79,9 +79,12 @@ public:
     /**
      *  Sets vertex attributes for next draw. The object driving the templatization
      *  should be a global GrVertexAttrib array that is never changed.
+     *
+     *  @param count      the number of attributes being set, limited to kMaxVertexAttribCnt.
+     *  @param stride     the number of bytes between successive vertex data.
      */
-    template <const GrVertexAttrib A[]> void setVertexAttribs(int count) {
-        this->setVertexAttribs(A, count);
+    template <const GrVertexAttrib A[]> void setVertexAttribs(int count, size_t stride) {
+        this->internalSetVertexAttribs(A, count, stride);
     }
 
     /**
@@ -97,12 +100,13 @@ public:
      public:
          AutoVertexAttribRestore(GrDrawState* drawState);
 
-         ~AutoVertexAttribRestore() { fDrawState->setVertexAttribs(fVAPtr, fVACount); }
+         ~AutoVertexAttribRestore() { fDrawState->internalSetVertexAttribs(fVAPtr, fVACount, fVAStride); }
 
      private:
          GrDrawState*          fDrawState;
          const GrVertexAttrib* fVAPtr;
          int                   fVACount;
+         size_t                fVAStride;
      };
 
     /// @}
@@ -559,13 +563,7 @@ private:
     // This is used to assert that this condition holds.
     SkDEBUGCODE(int fBlockEffectRemovalCnt;)
 
-    /**
-     *  Sets vertex attributes for next draw.
-     *
-     *  @param attribs    the array of vertex attributes to set.
-     *  @param count      the number of attributes being set, limited to kMaxVertexAttribCnt.
-     */
-    void setVertexAttribs(const GrVertexAttrib attribs[], int count);
+    void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, size_t stride);
 
     typedef GrRODrawState INHERITED;
 };
index 2d27859c3ee5fd61aef50ac5e64300e2dc66ac09..9605781d34d62f625fcb2c46efeff0d8238ed9b1 100644 (file)
@@ -195,10 +195,10 @@ bool GrDrawTarget::reserveVertexAndIndexSpace(int vertexCount,
                                               int indexCount,
                                               void** vertices,
                                               void** indices) {
-    size_t vertexSize = this->drawState()->getVertexSize();
+    size_t vertexStride = this->drawState()->getVertexStride();
     this->willReserveVertexAndIndexSpace(vertexCount, indexCount);
     if (vertexCount) {
-        if (!this->reserveVertexSpace(vertexSize, vertexCount, vertices)) {
+        if (!this->reserveVertexSpace(vertexStride, vertexCount, vertices)) {
             if (indexCount) {
                 this->resetIndexSource();
             }
@@ -278,7 +278,7 @@ void GrDrawTarget::setVertexSourceToArray(const void* vertexArray,
     this->releasePreviousVertexSource();
     GeometrySrcState& geoSrc = fGeoSrcStateStack.back();
     geoSrc.fVertexSrc = kArray_GeometrySrcType;
-    geoSrc.fVertexSize = this->drawState()->getVertexSize();
+    geoSrc.fVertexSize = this->drawState()->getVertexStride();
     geoSrc.fVertexCount = vertexCount;
     this->onSetVertexSourceToArray(vertexArray, vertexCount);
 }
@@ -298,7 +298,7 @@ void GrDrawTarget::setVertexSourceToBuffer(const GrVertexBuffer* buffer) {
     geoSrc.fVertexSrc    = kBuffer_GeometrySrcType;
     geoSrc.fVertexBuffer = buffer;
     buffer->ref();
-    geoSrc.fVertexSize = this->drawState()->getVertexSize();
+    geoSrc.fVertexSize = this->drawState()->getVertexStride();
 }
 
 void GrDrawTarget::setIndexSourceToBuffer(const GrIndexBuffer* buffer) {
@@ -673,9 +673,9 @@ extern const GrVertexAttrib gBWRectPosUVAttribs[] = {
 
 void set_vertex_attributes(GrDrawState* drawState, bool hasUVs) {
     if (hasUVs) {
-        drawState->setVertexAttribs<gBWRectPosUVAttribs>(2);
+        drawState->setVertexAttribs<gBWRectPosUVAttribs>(2, 2 * sizeof(SkPoint));
     } else {
-        drawState->setVertexAttribs<gBWRectPosUVAttribs>(1);
+        drawState->setVertexAttribs<gBWRectPosUVAttribs>(1, sizeof(SkPoint));
     }
 }
 
@@ -693,16 +693,16 @@ void GrDrawTarget::onDrawRect(const SkRect& rect,
         return;
     }
 
-    size_t vsize = this->drawState()->getVertexSize();
-    geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vsize);
+    size_t vstride = this->drawState()->getVertexStride();
+    geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vstride);
     if (NULL != localRect) {
         SkPoint* coords = GrTCast<SkPoint*>(GrTCast<intptr_t>(geo.vertices()) +
                                             sizeof(SkPoint));
         coords->setRectFan(localRect->fLeft, localRect->fTop,
                            localRect->fRight, localRect->fBottom,
-                           vsize);
+                           vstride);
         if (NULL != localMatrix) {
-            localMatrix->mapPointsWithStride(coords, vsize, 4);
+            localMatrix->mapPointsWithStride(coords, vstride, 4);
         }
     }
     SkRect bounds;
index 9df54a807609719911ed4f3929ddfdb81c5fe687..4fd6b4e331785b5e3cbdbd4390745c3581a61132 100644 (file)
@@ -97,9 +97,9 @@ extern const GrVertexAttrib kRectAttribs[] = {
  */
 static void set_vertex_attributes(GrDrawState* drawState, bool hasLocalCoords, GrColor color) {
     if (hasLocalCoords) {
-        drawState->setVertexAttribs<kRectAttribs>(3);
+        drawState->setVertexAttribs<kRectAttribs>(3, 2 * sizeof(SkPoint) + sizeof(SkColor));
     } else {
-        drawState->setVertexAttribs<kRectAttribs>(2);
+        drawState->setVertexAttribs<kRectAttribs>(2, sizeof(SkPoint) + sizeof(SkColor));
     }
     if (0xFF == GrColorUnpackA(color)) {
         drawState->setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true);
@@ -143,24 +143,24 @@ void GrInOrderDrawBuffer::onDrawRect(const SkRect& rect,
         return;
     }
 
-    size_t vsize = drawState->getVertexSize();
+    size_t vstride = drawState->getVertexStride();
 
-    geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vsize);
-    matrix.mapPointsWithStride(geo.positions(), vsize, 4);
+    geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vstride);
+    matrix.mapPointsWithStride(geo.positions(), vstride, 4);
 
     SkRect devBounds;
     // since we already computed the dev verts, set the bounds hint. This will help us avoid
     // unnecessary clipping in our onDraw().
-    get_vertex_bounds(geo.vertices(), vsize, 4, &devBounds);
+    get_vertex_bounds(geo.vertices(), vstride, 4, &devBounds);
 
     if (NULL != localRect) {
         static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
         SkPoint* coords = GrTCast<SkPoint*>(GrTCast<intptr_t>(geo.vertices()) + kLocalOffset);
         coords->setRectFan(localRect->fLeft, localRect->fTop,
                            localRect->fRight, localRect->fBottom,
-                           vsize);
+                           vstride);
         if (NULL != localMatrix) {
-            localMatrix->mapPointsWithStride(coords, vsize, 4);
+            localMatrix->mapPointsWithStride(coords, vstride, 4);
         }
     }
 
@@ -168,7 +168,7 @@ void GrInOrderDrawBuffer::onDrawRect(const SkRect& rect,
     GrColor* vertColor = GrTCast<GrColor*>(GrTCast<intptr_t>(geo.vertices()) + kColorOffset);
     for (int i = 0; i < 4; ++i) {
         *vertColor = color;
-        vertColor = (GrColor*) ((intptr_t) vertColor + vsize);
+        vertColor = (GrColor*) ((intptr_t) vertColor + vstride);
     }
 
     this->setIndexSourceToBuffer(this->getContext()->getQuadIndexBuffer());
@@ -266,7 +266,7 @@ int GrInOrderDrawBuffer::concatInstancedDraw(const DrawInfo& info) {
 
     // update the amount of reserved vertex data actually referenced in draws
     size_t vertexBytes = instancesToConcat * info.verticesPerInstance() *
-                         drawState.getVertexSize();
+                         drawState.getVertexStride();
     poolState.fUsedPoolVertexBytes = SkTMax(poolState.fUsedPoolVertexBytes, vertexBytes);
 
     draw->adjustInstanceCount(instancesToConcat);
@@ -339,7 +339,7 @@ void GrInOrderDrawBuffer::onDraw(const DrawInfo& info) {
         case kReserved_GeometrySrcType: // fallthrough
         case kArray_GeometrySrcType: {
             size_t vertexBytes = (info.vertexCount() + info.startVertex()) *
-                                 drawState.getVertexSize();
+                                 drawState.getVertexStride();
             poolState.fUsedPoolVertexBytes = SkTMax(poolState.fUsedPoolVertexBytes, vertexBytes);
             draw->fVertexBuffer = poolState.fPoolVertexBuffer;
             draw->adjustStartVertex(poolState.fPoolStartVertex);
@@ -726,11 +726,11 @@ bool GrInOrderDrawBuffer::geometryHints(int* vertexCount,
         *indexCount = currIndices;
     }
     if (NULL != vertexCount) {
-        size_t vertexSize = this->getDrawState().getVertexSize();
-        int32_t currVertices = fVertexPool.currentBufferVertices(vertexSize);
+        size_t vertexStride = this->getDrawState().getVertexStride();
+        int32_t currVertices = fVertexPool.currentBufferVertices(vertexStride);
         if (*vertexCount > currVertices &&
             (!fVertexPool.preallocatedBuffersRemaining() &&
-             *vertexCount <= fVertexPool.preallocatedBufferVertices(vertexSize))) {
+             *vertexCount <= fVertexPool.preallocatedBufferVertices(vertexStride))) {
 
             flush = true;
         }
index dcce88955926bbfc19145ac89909bf25ccac6629..f368dc8d899c06e02b63128e3db3f9a0b4a1e784 100644 (file)
@@ -519,8 +519,8 @@ void GrOvalRenderer::drawCircle(GrDrawTarget* target,
         return;
     }
 
-    drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircleVertexAttribs));
-    SkASSERT(sizeof(CircleVertex) == drawState->getVertexSize());
+    drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircleVertexAttribs),
+                                                      sizeof(CircleVertex));
 
     GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0);
     if (!geo.succeeded()) {
@@ -680,8 +680,8 @@ bool GrOvalRenderer::drawEllipse(GrDrawTarget* target,
         return false;
     }
 
-    drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllipseVertexAttribs));
-    SkASSERT(sizeof(EllipseVertex) == drawState->getVertexSize());
+    drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllipseVertexAttribs),
+                                                       sizeof(EllipseVertex));
 
     GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0);
     if (!geo.succeeded()) {
@@ -799,8 +799,8 @@ bool GrOvalRenderer::drawDIEllipse(GrDrawTarget* target,
     SkScalar innerRatioX = SkScalarDiv(xRadius, innerXRadius);
     SkScalar innerRatioY = SkScalarDiv(yRadius, innerYRadius);
 
-    drawState->setVertexAttribs<gDIEllipseVertexAttribs>(SK_ARRAY_COUNT(gDIEllipseVertexAttribs));
-    SkASSERT(sizeof(DIEllipseVertex) == drawState->getVertexSize());
+    drawState->setVertexAttribs<gDIEllipseVertexAttribs>(SK_ARRAY_COUNT(gDIEllipseVertexAttribs),
+                                                         sizeof(DIEllipseVertex));
 
     GrDrawTarget::AutoReleaseGeometry geo(target, 4, 0);
     if (!geo.succeeded()) {
@@ -1032,8 +1032,8 @@ bool GrOvalRenderer::drawRRect(GrDrawTarget* target, GrContext* context, bool us
 
     // if the corners are circles, use the circle renderer
     if ((!hasStroke || scaledStroke.fX == scaledStroke.fY) && xRadius == yRadius) {
-        drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircleVertexAttribs));
-        SkASSERT(sizeof(CircleVertex) == drawState->getVertexSize());
+        drawState->setVertexAttribs<gCircleVertexAttribs>(SK_ARRAY_COUNT(gCircleVertexAttribs),
+                                                          sizeof(CircleVertex));
 
         GrDrawTarget::AutoReleaseGeometry geo(target, 16, 0);
         if (!geo.succeeded()) {
@@ -1121,8 +1121,8 @@ bool GrOvalRenderer::drawRRect(GrDrawTarget* target, GrContext* context, bool us
 
     // otherwise we use the ellipse renderer
     } else {
-        drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllipseVertexAttribs));
-        SkASSERT(sizeof(EllipseVertex) == drawState->getVertexSize());
+        drawState->setVertexAttribs<gEllipseVertexAttribs>(SK_ARRAY_COUNT(gEllipseVertexAttribs),
+                                                           sizeof(EllipseVertex));
 
         SkScalar innerXRadius = 0.0f;
         SkScalar innerYRadius = 0.0f;
index 1460f57320e48e3c56d87278a96941936f66b333..9118d0dc8dc037af8d5fe1fe3ca7e92cb6c68569 100644 (file)
@@ -25,6 +25,7 @@ bool GrRODrawState::isEqual(const GrRODrawState& that) const {
         this->fBlendConstant != that.fBlendConstant ||
         this->fFlagBits != that.fFlagBits ||
         this->fVACount != that.fVACount ||
+        this->fVAStride != that.fVAStride ||
         memcmp(this->fVAPtr, that.fVAPtr, this->fVACount * sizeof(GrVertexAttrib)) ||
         this->fStencilSettings != that.fStencilSettings ||
         this->fDrawFace != that.fDrawFace) {
@@ -50,7 +51,6 @@ bool GrRODrawState::isEqual(const GrRODrawState& that) const {
         }
     }
 
-    SkASSERT(this->fVertexSize == that.fVertexSize);
     SkASSERT(0 == memcmp(this->fFixedFunctionVertexAttribIndices,
                             that.fFixedFunctionVertexAttribIndices,
                             sizeof(this->fFixedFunctionVertexAttribIndices)));
index 231560854fc1bf91f5f519d161dd1a1bad254e70..0abd4a6aa54cce8169f5f9a16c93983a747a74d3 100644 (file)
@@ -37,7 +37,7 @@ public:
     const GrVertexAttrib* getVertexAttribs() const { return fVAPtr; }
     int getVertexAttribCount() const { return fVACount; }
 
-    size_t getVertexSize() const { return fVertexSize; }
+    size_t getVertexStride() const { return fVAStride; }
 
     /**
      * Getters for index into getVertexAttribs() for particular bindings. -1 is returned if the
@@ -340,8 +340,6 @@ public:
         kB_CombinedState,
     };
 
-    GrRODrawState& operator= (const GrRODrawState& that);
-
 protected:
     bool isEqual(const GrRODrawState& that) const;
 
@@ -353,7 +351,7 @@ protected:
     uint32_t                            fFlagBits;
     const GrVertexAttrib*               fVAPtr;
     int                                 fVACount;
-    size_t                              fVertexSize;
+    size_t                              fVAStride;
     GrStencilSettings                   fStencilSettings;
     uint8_t                             fCoverage;
     DrawFace                            fDrawFace;
index 4b2bafefdbbb14af4f62ff29ae9d9f18390b9b46..adee4aec966bdd7acd12b2f994190b7188b19b3e 100644 (file)
@@ -350,7 +350,8 @@ bool GrDashingEffect::DrawDashLine(const SkPoint pts[2], const GrPaint& paint,
     }
 
     // Set up the vertex data for the line and start/end dashes
-    drawState->setVertexAttribs<gDashLineVertexAttribs>(SK_ARRAY_COUNT(gDashLineVertexAttribs));
+    drawState->setVertexAttribs<gDashLineVertexAttribs>(SK_ARRAY_COUNT(gDashLineVertexAttribs),
+                                                        sizeof(DashLineVertex));
 
     int totalRectCnt = 0;
 
index b19676adb9ba53cc9cefbf7f17f6a55130c35cb4..beef93e96b7b25b09cc4d6587dac701194ac0d97 100644 (file)
@@ -284,7 +284,7 @@ bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC
 
 void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) {
 
-    GrGLsizei stride = static_cast<GrGLsizei>(this->getDrawState().getVertexSize());
+    GrGLsizei stride = static_cast<GrGLsizei>(this->getDrawState().getVertexStride());
 
     size_t vertexOffsetInBytes = stride * info.startVertex();