Index: src/gpu/GrBitmapTextContext.cpp |
diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp |
index afecead65d28446d75417663446bf6cbc2c59f51..f9ea1702643a451b7c93dc96593d0e55cd1d21c6 100755 |
--- a/src/gpu/GrBitmapTextContext.cpp |
+++ b/src/gpu/GrBitmapTextContext.cpp |
@@ -15,6 +15,7 @@ |
#include "GrTextStrike.h" |
#include "GrTextStrike_impl.h" |
#include "effects/GrCustomCoordsTextureEffect.h" |
+#include "effects/GrSimpleTextureEffect.h" |
#include "SkAutoKern.h" |
#include "SkColorPriv.h" |
@@ -38,7 +39,15 @@ extern const GrVertexAttrib gTextVertexAttribs[] = { |
{kVec2f_GrVertexAttribType, sizeof(SkPoint), kGeometryProcessor_GrVertexAttribBinding} |
}; |
-static const size_t kTextVASize = 2 * sizeof(SkPoint); |
+static const size_t kTextVASize = 2 * sizeof(SkPoint); |
+ |
+// position + local coord |
+extern const GrVertexAttrib gTextVertexWithLCAttribs[] = { |
bsalomon
2014/10/30 15:31:11
gBmpTextVertexAttribs?
jvanverth1
2014/10/30 18:19:43
I think it's more consistent the way it is.
egdaniel
2014/10/30 19:22:20
I'm in agreement with jim. The way the old names w
|
+ {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, |
+ {kVec2f_GrVertexAttribType, sizeof(SkPoint), kLocalCoord_GrVertexAttribBinding} |
+}; |
+ |
+static const size_t kTextVALCSize = 2 * sizeof(SkPoint); |
// position + color + texture coord |
extern const GrVertexAttrib gTextVertexWithColorAttribs[] = { |
@@ -345,15 +354,18 @@ void GrBitmapTextContext::onDrawPosText(const GrPaint& paint, const SkPaint& skP |
this->finish(); |
} |
-static void* alloc_vertices(GrDrawTarget* drawTarget, int numVertices, bool useColorVerts) { |
+static void* alloc_vertices(GrDrawTarget* drawTarget, int numVertices, GrMaskFormat maskFormat) { |
if (numVertices <= 0) { |
return NULL; |
} |
// set up attributes |
- if (useColorVerts) { |
+ if (kA8_GrMaskFormat == maskFormat) { |
drawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttribs>( |
SK_ARRAY_COUNT(gTextVertexWithColorAttribs), kTextVAColorSize); |
+ } else if (kARGB_GrMaskFormat == maskFormat) { |
+ drawTarget->drawState()->setVertexAttribs<gTextVertexWithLCAttribs>( |
+ SK_ARRAY_COUNT(gTextVertexWithLCAttribs), kTextVALCSize); |
} else { |
drawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>( |
SK_ARRAY_COUNT(gTextVertexAttribs), kTextVASize); |
@@ -476,12 +488,10 @@ HAS_ATLAS: |
fCurrMaskFormat = glyph->fMaskFormat; |
} |
- bool useColorVerts = kA8_GrMaskFormat == fCurrMaskFormat; |
- |
if (NULL == fVertices) { |
int maxQuadVertices = kVerticesPerGlyph * fContext->getQuadIndexBuffer()->maxQuads(); |
fAllocVertexCount = SkMin32(fTotalVertexCount, maxQuadVertices); |
- fVertices = alloc_vertices(fDrawTarget, fAllocVertexCount, useColorVerts); |
+ fVertices = alloc_vertices(fDrawTarget, fAllocVertexCount, fCurrMaskFormat); |
} |
SkFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX); |
@@ -495,8 +505,16 @@ HAS_ATLAS: |
fVertexBounds.joinNonEmptyArg(r); |
- size_t vertSize = useColorVerts ? (2 * sizeof(SkPoint) + sizeof(GrColor)) : |
- (2 * sizeof(SkPoint)); |
+ size_t vertSize; |
+ switch (fCurrMaskFormat) { |
+ case kA8_GrMaskFormat: |
+ vertSize = kTextVAColorSize; |
+ break; |
+ case kARGB_GrMaskFormat: |
+ vertSize = kTextVALCSize; |
+ default: |
+ vertSize = kTextVASize; |
+ } |
SkASSERT(vertSize == fDrawTarget->getDrawState().getVertexStride()); |
@@ -512,7 +530,7 @@ HAS_ATLAS: |
SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx + width)), |
SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty + height)), |
vertSize); |
- if (useColorVerts) { |
+ if (kA8_GrMaskFormat == fCurrMaskFormat) { |
if (0xFF == GrColorUnpackA(fPaint.getColor())) { |
fDrawTarget->drawState()->setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true); |
} |
@@ -548,16 +566,25 @@ void GrBitmapTextContext::flush() { |
SkASSERT(fCurrTexture); |
GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNone_FilterMode); |
- uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
+ // This effect could be stored with one of the cache objects (atlas?) |
+ if (kARGB_GrMaskFormat != fCurrMaskFormat) { |
bsalomon
2014/10/30 15:31:11
Switch the sense of this? Seems easier to read
i
|
+ uint32_t textureUniqueID = fCurrTexture->getUniqueID(); |
+ if (textureUniqueID != fEffectTextureUniqueID) { |
+ fCachedGeometryProcessor.reset(GrCustomCoordsTextureEffect::Create(fCurrTexture, |
+ params)); |
+ fEffectTextureUniqueID = textureUniqueID; |
+ } |
- if (textureUniqueID != fEffectTextureUniqueID) { |
- fCachedGeometryProcessor.reset(GrCustomCoordsTextureEffect::Create(fCurrTexture, |
- params)); |
- fEffectTextureUniqueID = textureUniqueID; |
+ drawState->setGeometryProcessor(fCachedGeometryProcessor.get()); |
+ } else { |
+ SkMatrix matrix; |
+ matrix.reset(); |
+ GrFragmentProcessor* fragProcessor = GrSimpleTextureEffect::Create(fCurrTexture, |
+ matrix, |
jvanverth1
2014/10/30 18:19:42
I think you can use SkMatrix::I() instead of havin
|
+ params); |
+ drawState->addColorProcessor(fragProcessor)->unref(); |
} |
- // This effect could be stored with one of the cache objects (atlas?) |
- drawState->setGeometryProcessor(fCachedGeometryProcessor.get()); |
SkASSERT(fStrike); |
switch (fCurrMaskFormat) { |
// Color bitmap text |