aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDistanceFieldTextContext.cpp
diff options
context:
space:
mode:
authorGravatar jvanverth <jvanverth@google.com>2014-10-31 12:59:57 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-31 12:59:57 -0700
commit2faa2284357d7cec51b26d8251c53bc91251b1fe (patch)
treeb27ed66cc2627c69fef46855aaa0b77e9fb2871d /src/gpu/GrDistanceFieldTextContext.cpp
parentb9e8230b50fc383869ee64208e23e5b6403568a1 (diff)
Some distance field text optimizations.
- Add clipRect check - Remove creation of scalerContext to check for color fonts in canDraw() (no longer needed) BUG=skia:2933 Review URL: https://codereview.chromium.org/696503004
Diffstat (limited to 'src/gpu/GrDistanceFieldTextContext.cpp')
-rwxr-xr-xsrc/gpu/GrDistanceFieldTextContext.cpp66
1 files changed, 26 insertions, 40 deletions
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index b141d2cf77..6ffa3c3cac 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -123,10 +123,7 @@ bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) {
return false;
}
- // distance fields cannot represent color fonts
- SkScalerContext::Rec rec;
- SkScalerContext::MakeRec(paint, &fDeviceProperties, NULL, &rec);
- return rec.getFormat() != SkMask::kARGB32_Format;
+ return true;
}
inline void GrDistanceFieldTextContext::init(const GrPaint& paint, const SkPaint& skPaint) {
@@ -434,7 +431,7 @@ void GrDistanceFieldTextContext::setupCoverageEffect(const SkColor& filteredColo
lum/255.f,
flags));
#else
- fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create(fCurrTexture,
+ fCachedGeometryProcessor.reset(GrDistanceFieldNoGammaTextureEffect::Create(fCurrTexture,
params, flags));
#endif
}
@@ -468,25 +465,32 @@ bool GrDistanceFieldTextContext::appendGlyph(GrGlyph::PackedID packed,
return false;
}
-/*
- // not valid, need to find a different solution for this
- vx += SkIntToFixed(glyph->fBounds.fLeft);
- vy += SkIntToFixed(glyph->fBounds.fTop);
+ SkScalar dx = SkIntToScalar(glyph->fBounds.fLeft + SK_DistanceFieldInset);
+ SkScalar dy = SkIntToScalar(glyph->fBounds.fTop + SK_DistanceFieldInset);
+ SkScalar width = SkIntToScalar(glyph->fBounds.width() - 2*SK_DistanceFieldInset);
+ SkScalar height = SkIntToScalar(glyph->fBounds.height() - 2*SK_DistanceFieldInset);
- // keep them as ints until we've done the clip-test
- GrFixed width = glyph->fBounds.width();
- GrFixed height = glyph->fBounds.height();
+ SkScalar scale = fTextRatio;
+ dx *= scale;
+ dy *= scale;
+ sx += dx;
+ sy += dy;
+ width *= scale;
+ height *= scale;
+ SkRect glyphRect = SkRect::MakeXYWH(sx, sy, width, height);
// check if we clipped out
- if (true || NULL == glyph->fPlot) {
- int x = vx >> 16;
- int y = vy >> 16;
- if (fClipRect.quickReject(x, y, x + width, y + height)) {
+ SkRect dstRect;
+ const SkMatrix& ctm = fContext->getMatrix();
+ (void) ctm.mapRect(&dstRect, glyphRect);
+ if (fClipRect.quickReject(SkScalarTruncToInt(dstRect.left()),
+ SkScalarTruncToInt(dstRect.top()),
+ SkScalarTruncToInt(dstRect.right()),
+ SkScalarTruncToInt(dstRect.bottom()))) {
// SkCLZ(3); // so we can set a break-point in the debugger
- return;
- }
+ return true;
}
-*/
+
if (NULL == glyph->fPlot) {
if (!fStrike->glyphTooLargeForAtlas(glyph)) {
if (fStrike->addGlyphToAtlas(glyph, scaler)) {
@@ -565,31 +569,12 @@ HAS_ATLAS:
fVertices = alloc_vertices(fDrawTarget, fAllocVertexCount, useColorVerts);
}
- SkScalar dx = SkIntToScalar(glyph->fBounds.fLeft + SK_DistanceFieldInset);
- SkScalar dy = SkIntToScalar(glyph->fBounds.fTop + SK_DistanceFieldInset);
- SkScalar width = SkIntToScalar(glyph->fBounds.width() - 2*SK_DistanceFieldInset);
- SkScalar height = SkIntToScalar(glyph->fBounds.height() - 2*SK_DistanceFieldInset);
-
- SkScalar scale = fTextRatio;
- dx *= scale;
- dy *= scale;
- sx += dx;
- sy += dy;
- width *= scale;
- height *= scale;
-
SkFixed tx = SkIntToFixed(glyph->fAtlasLocation.fX + SK_DistanceFieldInset);
SkFixed ty = SkIntToFixed(glyph->fAtlasLocation.fY + SK_DistanceFieldInset);
SkFixed tw = SkIntToFixed(glyph->fBounds.width() - 2*SK_DistanceFieldInset);
SkFixed th = SkIntToFixed(glyph->fBounds.height() - 2*SK_DistanceFieldInset);
- SkRect r;
- r.fLeft = sx;
- r.fTop = sy;
- r.fRight = sx + width;
- r.fBottom = sy + height;
-
- fVertexBounds.joinNonEmptyArg(r);
+ fVertexBounds.joinNonEmptyArg(glyphRect);
size_t vertSize = fUseLCDText ? (2 * sizeof(SkPoint))
: (2 * sizeof(SkPoint) + sizeof(GrColor));
@@ -598,7 +583,8 @@ HAS_ATLAS:
SkPoint* positions = reinterpret_cast<SkPoint*>(
reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex);
- positions->setRectFan(r.fLeft, r.fTop, r.fRight, r.fBottom, vertSize);
+ positions->setRectFan(glyphRect.fLeft, glyphRect.fTop, glyphRect.fRight, glyphRect.fBottom,
+ vertSize);
// The texture coords are last in both the with and without color vertex layouts.
SkPoint* textureCoords = reinterpret_cast<SkPoint*>(