Make GrTextBlob::VertexRegenerator determine vertex stride from mask format
Change-Id: Ib0910ca563150add6399ba3ca891ee23db3578ec
Reviewed-on: https://skia-review.googlesource.com/68861
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp
index 9e98466..6a26551 100644
--- a/src/gpu/ops/GrAtlasTextOp.cpp
+++ b/src/gpu/ops/GrAtlasTextOp.cpp
@@ -233,7 +233,7 @@
Blob* blob = args.fBlob;
GrAtlasTextBlob::VertexRegenerator regenerator(
blob, args.fRun, args.fSubRun, args.fViewMatrix, args.fX, args.fY, args.fColor,
- target->deferredUploadTarget(), fFontCache, &glyphCache, vertexStride);
+ target->deferredUploadTarget(), fFontCache, &glyphCache);
GrAtlasTextBlob::VertexRegenerator::Result result;
do {
result = regenerator.regenerate();
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 403cbbf..450e256 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -557,7 +557,7 @@
*/
VertexRegenerator(GrAtlasTextBlob* blob, int runIdx, int subRunIdx, const SkMatrix& viewMatrix,
SkScalar x, SkScalar y, GrColor color, GrDeferredUploadTarget*,
- GrAtlasGlyphCache*, SkAutoGlyphCache*, size_t vertexStride);
+ GrAtlasGlyphCache*, SkAutoGlyphCache*);
struct Result {
/**
@@ -591,7 +591,6 @@
SkAutoGlyphCache* fLazyCache;
Run* fRun;
Run::SubRunInfo* fSubRun;
- size_t fVertexStride;
GrColor fColor;
SkScalar fTransX;
SkScalar fTransY;
diff --git a/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp b/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp
index 6b242ad..28b2e0f 100644
--- a/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp
+++ b/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp
@@ -153,7 +153,7 @@
Regenerator::VertexRegenerator(GrAtlasTextBlob* blob, int runIdx, int subRunIdx,
const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color,
GrDeferredUploadTarget* uploadTarget, GrAtlasGlyphCache* glyphCache,
- SkAutoGlyphCache* lazyCache, size_t vertexStride)
+ SkAutoGlyphCache* lazyCache)
: fViewMatrix(viewMatrix)
, fBlob(blob)
, fUploadTarget(uploadTarget)
@@ -161,7 +161,6 @@
, fLazyCache(lazyCache)
, fRun(&blob->fRuns[runIdx])
, fSubRun(&blob->fRuns[runIdx].fSubRunInfo[subRunIdx])
- , fVertexStride(vertexStride)
, fColor(color) {
// Compute translation if any
fSubRun->computeTranslation(fViewMatrix, x, y, &fTransX, &fTransY);
@@ -213,8 +212,9 @@
}
Result result;
+ auto vertexStride = GetVertexStride(fSubRun->maskFormat());
char* currVertex = fBlob->fVertices + fSubRun->vertexStartIndex() +
- fCurrGlyph * kVerticesPerGlyph * fVertexStride;
+ fCurrGlyph * kVerticesPerGlyph * vertexStride;
result.fFirstVertex = currVertex;
for (int glyphIdx = fCurrGlyph; glyphIdx < (int)fSubRun->glyphCount(); glyphIdx++) {
@@ -244,10 +244,10 @@
fUploadTarget->nextDrawToken());
}
- regen_vertices<regenPos, regenCol, regenTexCoords>(currVertex, glyph, fVertexStride,
+ regen_vertices<regenPos, regenCol, regenTexCoords>(currVertex, glyph, vertexStride,
fSubRun->drawAsDistanceFields(), fTransX,
fTransY, fColor);
- currVertex += fVertexStride * GrAtlasTextOp::kVerticesPerGlyph;
+ currVertex += vertexStride * GrAtlasTextOp::kVerticesPerGlyph;
++result.fGlyphsRegenerated;
++fCurrGlyph;
}
@@ -300,9 +300,10 @@
return this->doRegen<false, true, true, true>();
case kNoRegen: {
Result result;
+ auto vertexStride = GetVertexStride(fSubRun->maskFormat());
result.fGlyphsRegenerated = fSubRun->glyphCount() - fCurrGlyph;
result.fFirstVertex = fBlob->fVertices + fSubRun->vertexStartIndex() +
- fCurrGlyph * kVerticesPerGlyph * fVertexStride;
+ fCurrGlyph * kVerticesPerGlyph * vertexStride;
fCurrGlyph = fSubRun->glyphCount();
// set use tokens for all of the glyphs in our subrun. This is only valid if we