diff options
author | 2013-02-28 16:28:34 +0000 | |
---|---|---|
committer | 2013-02-28 16:28:34 +0000 | |
commit | b8b705b1b983a2ee3a254bed4dd03f926101e4e7 (patch) | |
tree | 700a965273fff93e1cc821bfdbcc22028e138d46 /src/gpu/GrTextContext.cpp | |
parent | 4aaaaeace7e617ddc473645756fb7c20790bc270 (diff) |
Add new vertex attribute array specification.
This changes the old method of setting vertex layout to a new one where we
specify vertex attribute data separately from attribute bindings (i.e. program
functionality). Attribute data is now set up via an array of generic attribute
types and offsets, and this is mapped to the old program functionality by
setting specific attribute indices. This allows us to create more general
inputs to shaders.
git-svn-id: http://skia.googlecode.com/svn/trunk@7899 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/GrTextContext.cpp')
-rw-r--r-- | src/gpu/GrTextContext.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp index e599fc9500..e77bf93429 100644 --- a/src/gpu/GrTextContext.cpp +++ b/src/gpu/GrTextContext.cpp @@ -92,8 +92,6 @@ GrTextContext::GrTextContext(GrContext* context, const GrPaint& paint) : fPaint( fVertices = NULL; fMaxVertices = 0; - - fVertexLayout = GrDrawState::StageTexCoordVertexLayoutBit(kGlyphMaskStage); } GrTextContext::~GrTextContext() { @@ -189,13 +187,20 @@ HAS_ATLAS: } if (NULL == fVertices) { - // If we need to reserve vertices allow the draw target to suggest + // position + texture coord + static const GrVertexAttrib kVertexAttribs[] = { + GrVertexAttrib(kVec2f_GrVertexAttribType, 0), + GrVertexAttrib(kVec2f_GrVertexAttribType, sizeof(GrPoint)) + }; + static const GrAttribBindings kAttribBindings = GrDrawState::ExplicitTexCoordAttribBindingsBit(kGlyphMaskStage); + + // If we need to reserve vertices allow the draw target to suggest // a number of verts to reserve and whether to perform a flush. fMaxVertices = kMinRequestedVerts; bool flush = false; fDrawTarget = fContext->getTextTarget(fPaint); if (NULL != fDrawTarget) { - fDrawTarget->drawState()->setVertexLayout(fVertexLayout); + fDrawTarget->drawState()->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs)); flush = fDrawTarget->geometryHints(&fMaxVertices, NULL); } if (flush) { @@ -203,8 +208,11 @@ HAS_ATLAS: fContext->flush(); // flushGlyphs() will reset fDrawTarget to NULL. fDrawTarget = fContext->getTextTarget(fPaint); - fDrawTarget->drawState()->setVertexLayout(fVertexLayout); + fDrawTarget->drawState()->setVertexAttribs(kVertexAttribs, SK_ARRAY_COUNT(kVertexAttribs)); } + fDrawTarget->drawState()->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); + fDrawTarget->drawState()->setAttribIndex(GrDrawState::kTexCoord_AttribIndex, 1); + fDrawTarget->drawState()->setAttribBindings(kAttribBindings); fMaxVertices = kDefaultRequestedVerts; // ignore return, no point in flushing again. fDrawTarget->geometryHints(&fMaxVertices, NULL); @@ -222,6 +230,7 @@ HAS_ATLAS: GrTCast<void**>(&fVertices), NULL); GrAlwaysAssert(success); + GrAssert(2*sizeof(GrPoint) == fDrawTarget->getDrawState().getVertexSize()); } GrFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX); |