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

Unified Diff: src/gpu/GrDistanceFieldTextContext.cpp

Issue 432443002: Add vertex bounds check for distance field rendering. (Closed) Base URL: https://skia.googlesource.com/skia.git@df-effectcache-7-28
Patch Set: Clean up whitespace. Created 6 years, 5 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/GrDistanceFieldTextContext.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDistanceFieldTextContext.cpp
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index 32d8f0c38454c8243c98cbc2305d5d0b95201f40..034980d455e1b2f48060145b28ebdd6c9083d14c 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -69,8 +69,10 @@ GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context,
fEffectTextureUniqueID = SK_InvalidUniqueID;
fEffectColor = GrColor_ILLEGAL;
fEffectFlags = 0;
-
+
fVertices = NULL;
+
+ fVertexBounds.setLargestInverted();
}
GrDistanceFieldTextContext::~GrDistanceFieldTextContext() {
@@ -225,9 +227,11 @@ void GrDistanceFieldTextContext::flushGlyphs() {
fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType,
nGlyphs,
- 4, 6);
+ 4, 6, &fVertexBounds);
fCurrVertex = 0;
+ fVertexBounds.setLargestInverted();
}
+
fDrawTarget->resetVertexSource();
fVertices = NULL;
}
@@ -329,21 +333,29 @@ HAS_ATLAS:
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 = SkFixedToFloat(sx);
+ r.fTop = SkFixedToFloat(sy);
+ r.fRight = SkFixedToFloat(sx + width);
+ r.fBottom = SkFixedToFloat(sy + height);
+
+ fVertexBounds.growToInclude(r);
+
size_t vertSize = fUseLCDText ? (2 * sizeof(SkPoint))
: (2 * sizeof(SkPoint) + sizeof(GrColor));
-
+
SkASSERT(vertSize == fDrawTarget->getDrawState().getVertexSize());
-
+
SkPoint* positions = reinterpret_cast<SkPoint*>(
reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex);
- positions->setRectFan(sx, sy, sx + width, sy + height, vertSize);
-
+ positions->setRectFan(r.fLeft, r.fTop, r.fRight, r.fBottom, vertSize);
+
// The texture coords are last in both the with and without color vertex layouts.
SkPoint* textureCoords = reinterpret_cast<SkPoint*>(
reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint));
@@ -360,7 +372,7 @@ HAS_ATLAS:
colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(colors) + vertSize);
}
}
-
+
fCurrVertex += 4;
}
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698