Index: src/gpu/GrDistanceFieldTextContext.cpp |
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp |
index bd3927c648839232f655aaead473cee7a7892b21..077709fb78cfe548c1392a0d637fed832870f797 100755 |
--- a/src/gpu/GrDistanceFieldTextContext.cpp |
+++ b/src/gpu/GrDistanceFieldTextContext.cpp |
@@ -8,6 +8,7 @@ |
#include "GrDistanceFieldTextContext.h" |
#include "GrAtlas.h" |
#include "GrDrawTarget.h" |
+#include "GrDrawTargetCaps.h" |
#include "GrFontScaler.h" |
#include "SkGlyphCache.h" |
#include "GrIndexBuffer.h" |
@@ -21,6 +22,7 @@ |
#include "effects/GrDistanceFieldTextureEffect.h" |
static const int kGlyphCoordsAttributeIndex = 1; |
+static const int kGlyphOffsetAttributeIndex = 2; |
static const int kBaseDFFontSize = 32; |
@@ -46,6 +48,7 @@ GrDistanceFieldTextContext::~GrDistanceFieldTextContext() { |
bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) { |
return !paint.getRasterizer() && !paint.getMaskFilter() && |
paint.getStyle() == SkPaint::kFill_Style && |
+ fContext->getTextTarget()->caps()->shaderDerivativeSupport() && |
!SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix()); |
} |
@@ -67,14 +70,14 @@ void GrDistanceFieldTextContext::flushGlyphs() { |
if (fCurrVertex > 0) { |
// setup our sampler state for our text texture/atlas |
- SkASSERT(GrIsALIGN4(fCurrVertex)); |
+ SkASSERT(fCurrVertex % 6 == 0); |
SkASSERT(fCurrTexture); |
GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_FilterMode); |
// This effect could be stored with one of the cache objects (atlas?) |
drawState->addCoverageEffect( |
GrDistanceFieldTextureEffect::Create(fCurrTexture, params), |
- kGlyphCoordsAttributeIndex)->unref(); |
+ kGlyphCoordsAttributeIndex, kGlyphOffsetAttributeIndex)->unref(); |
if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) { |
if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || |
@@ -98,7 +101,7 @@ void GrDistanceFieldTextContext::flushGlyphs() { |
drawState->setColor(fPaint.getColor()); |
} |
- int nGlyphs = fCurrVertex / 4; |
+ int nGlyphs = fCurrVertex / 6; |
fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); |
fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType, |
nGlyphs, |
@@ -115,8 +118,9 @@ namespace { |
// position + texture coord |
extern const GrVertexAttrib gTextVertexAttribs[] = { |
- {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, |
- {kVec2f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding} |
+ {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding}, |
+ {kVec2f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribBinding}, |
+ {kVec2f_GrVertexAttribType, 2*sizeof(GrPoint), kEffect_GrVertexAttribBinding} |
}; |
}; |
@@ -248,7 +252,7 @@ HAS_ATLAS: |
GrTCast<void**>(&fVertices), |
NULL); |
GrAlwaysAssert(success); |
- SkASSERT(2*sizeof(GrPoint) == fDrawTarget->getDrawState().getVertexSize()); |
+ SkASSERT(3*sizeof(GrPoint) == fDrawTarget->getDrawState().getVertexSize()); |
} |
SkScalar dx = SkIntToScalar(glyph->fBounds.fLeft); |
@@ -263,23 +267,30 @@ HAS_ATLAS: |
sy += dy; |
width *= scale; |
height *= scale; |
- |
+ |
GrFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX); |
GrFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY); |
GrFixed tw = SkIntToFixed(glyph->fBounds.width()); |
GrFixed th = SkIntToFixed(glyph->fBounds.height()); |
+ SkISize texSize = fStrike->getAtlasSize(); |
bsalomon
2014/02/05 20:19:10
AFAICT this is the same for the lifetime of the pr
jvanverth1
2014/02/10 18:34:02
Done.
|
+ |
fVertices[2*fCurrVertex].setRectFan(sx, |
sy, |
sx + width, |
sy + height, |
- 2 * sizeof(SkPoint)); |
+ 3 * sizeof(SkPoint)); |
bsalomon
2014/02/05 20:19:10
this 3 * sizeof(SkPoint) is repeated here three ti
jvanverth1
2014/02/10 18:34:02
Done.
|
fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixedX(tx)), |
SkFixedToFloat(texture->normalizeFixedY(ty)), |
SkFixedToFloat(texture->normalizeFixedX(tx + tw)), |
SkFixedToFloat(texture->normalizeFixedY(ty + th)), |
- 2 * sizeof(SkPoint)); |
- fCurrVertex += 4; |
+ 3 * sizeof(SkPoint)); |
+ fVertices[2*fCurrVertex+2].setRectFan(SkIntToScalar(texSize.fWidth), |
+ SkIntToScalar(texSize.fHeight), |
+ SkIntToScalar(texSize.fWidth), |
+ SkIntToScalar(texSize.fHeight), |
+ 3 * sizeof(SkPoint)); |
+ fCurrVertex += 6; |
} |
inline void GrDistanceFieldTextContext::init(const GrPaint& paint, const SkPaint& skPaint) { |