Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Unified Diff: src/gpu/GrDrawTarget.cpp

Issue 14328009: Vertex Attrib configurations now handled as pointers vs. SkSTArrays (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Added "extern const" & removed comment Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | src/gpu/GrInOrderDrawBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawTarget.cpp
===================================================================
--- src/gpu/GrDrawTarget.cpp (revision 8777)
+++ src/gpu/GrDrawTarget.cpp (working copy)
@@ -590,27 +590,36 @@
////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+// position + (optional) texture coord
+extern const GrVertexAttrib gBWRectPosUVAttribs[] = {
+ {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
+ {kVec2f_GrVertexAttribType, sizeof(GrPoint), kLocalCoord_GrVertexAttribBinding}
+};
+
+void set_vertex_attributes(GrDrawState* drawState, bool hasUVs) {
+ if (hasUVs) {
+ drawState->setVertexAttribs<gBWRectPosUVAttribs>(2);
+ } else {
+ drawState->setVertexAttribs<gBWRectPosUVAttribs>(1);
+ }
+}
+
+};
+
void GrDrawTarget::onDrawRect(const GrRect& rect,
const SkMatrix* matrix,
const GrRect* localRect,
const SkMatrix* localMatrix) {
- // position + (optional) texture coord
- static const GrVertexAttrib kAttribs[] = {
- {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
- {kVec2f_GrVertexAttribType, sizeof(GrPoint), kLocalCoord_GrVertexAttribBinding}
- };
- int attribCount = 1;
- if (NULL != localRect) {
- attribCount = 2;
- }
-
GrDrawState::AutoViewMatrixRestore avmr;
if (NULL != matrix) {
avmr.set(this->drawState(), *matrix);
}
- this->drawState()->setVertexAttribs(kAttribs, attribCount);
+ set_vertex_attributes(this->drawState(), NULL != localRect);
+
AutoReleaseGeometry geo(this, 4, 0);
if (!geo.succeeded()) {
GrPrintf("Failed to get space for vertices!\n");
@@ -620,9 +629,8 @@
size_t vsize = this->drawState()->getVertexSize();
geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vsize);
if (NULL != localRect) {
- GrAssert(attribCount == 2);
GrPoint* coords = GrTCast<GrPoint*>(GrTCast<intptr_t>(geo.vertices()) +
- kAttribs[1].fOffset);
+ sizeof(GrPoint));
coords->setRectFan(localRect->fLeft, localRect->fTop,
localRect->fRight, localRect->fBottom,
vsize);
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | src/gpu/GrInOrderDrawBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698