Start objectifying GrAtlasTextBlob
BUG=skia:
Review URL: https://codereview.chromium.org/1503193002
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
index bfc58f5..cac52fb 100644
--- a/src/gpu/GrAtlasTextContext.cpp
+++ b/src/gpu/GrAtlasTextContext.cpp
@@ -466,11 +466,11 @@
PerSubRunInfo& newRun = cacheBlob->fRuns[run].fSubRunInfo.back();
PerSubRunInfo& lastRun = cacheBlob->fRuns[run - 1].fSubRunInfo.back();
- newRun.fVertexStartIndex = lastRun.fVertexEndIndex;
- newRun.fVertexEndIndex = lastRun.fVertexEndIndex;
+ newRun.setVertexStartIndex(lastRun.vertexEndIndex());
+ newRun.setVertexEndIndex(lastRun.vertexEndIndex());
- newRun.fGlyphStartIndex = lastRun.fGlyphEndIndex;
- newRun.fGlyphEndIndex = lastRun.fGlyphEndIndex;
+ newRun.setGlyphStartIndex(lastRun.glyphEndIndex());
+ newRun.setGlyphEndIndex(lastRun.glyphEndIndex());
}
if (this->canDrawAsDistanceFields(runPaint, viewMatrix)) {
@@ -480,8 +480,8 @@
this->initDistanceFieldPaint(cacheBlob, &dfPaint, &textRatio, viewMatrix);
Run& runIdx = cacheBlob->fRuns[run];
PerSubRunInfo& subRun = runIdx.fSubRunInfo.back();
- subRun.fUseLCDText = runPaint.isLCDRenderText();
- subRun.fDrawAsDistanceFields = true;
+ subRun.setUseLCDText(runPaint.isLCDRenderText());
+ subRun.setDrawAsDistanceFields();
SkTDArray<char> fallbackTxt;
SkTDArray<SkScalar> fallbackPos;
@@ -641,8 +641,8 @@
blob->fViewMatrix = viewMatrix;
Run& run = blob->fRuns[0];
PerSubRunInfo& subRun = run.fSubRunInfo.back();
- subRun.fUseLCDText = origPaint.isLCDRenderText();
- subRun.fDrawAsDistanceFields = true;
+ subRun.setUseLCDText(origPaint.isLCDRenderText());
+ subRun.setDrawAsDistanceFields();
return blob;
}
@@ -1007,11 +1007,11 @@
GrMaskFormat format = glyph->fMaskFormat;
PerSubRunInfo* subRun = &run.fSubRunInfo.back();
- if (run.fInitialized && subRun->fMaskFormat != format) {
+ if (run.fInitialized && subRun->maskFormat() != format) {
subRun = &run.push_back();
- subRun->fStrike.reset(SkRef(fCurrStrike));
+ subRun->setStrike(fCurrStrike);
} else if (!run.fInitialized) {
- subRun->fStrike.reset(SkRef(fCurrStrike));
+ subRun->setStrike(SkRef(fCurrStrike));
}
run.fInitialized = true;
@@ -1023,7 +1023,7 @@
r.fTop = SkIntToScalar(y);
r.fRight = r.fLeft + SkIntToScalar(width);
r.fBottom = r.fTop + SkIntToScalar(height);
- subRun->fMaskFormat = format;
+ subRun->setMaskFormat(format);
this->appendGlyphCommon(blob, &run, subRun, r, color, vertexStride, kA8_GrMaskFormat == format,
glyph);
}
@@ -1075,16 +1075,16 @@
PerSubRunInfo* subRun = &run.fSubRunInfo.back();
if (!run.fInitialized) {
- subRun->fStrike.reset(SkRef(fCurrStrike));
+ subRun->setStrike(fCurrStrike);
}
run.fInitialized = true;
SkASSERT(glyph->fMaskFormat == kA8_GrMaskFormat);
- subRun->fMaskFormat = kA8_GrMaskFormat;
+ subRun->setMaskFormat(kA8_GrMaskFormat);
size_t vertexStride = GrAtlasTextBatch::GetVertexStrideDf(kA8_GrMaskFormat,
- subRun->fUseLCDText);
+ subRun->hasUseLCDText());
- bool useColorVerts = !subRun->fUseLCDText;
+ bool useColorVerts = !subRun->hasUseLCDText();
this->appendGlyphCommon(blob, &run, subRun, glyphRect, color, vertexStride, useColorVerts,
glyph);
return true;
@@ -1110,11 +1110,11 @@
const SkRect& positions, GrColor color,
size_t vertexStride, bool useVertexColor,
GrGlyph* glyph) {
- blob->fGlyphs[subRun->fGlyphEndIndex] = glyph;
+ blob->appendGlyph(subRun, glyph);
run->fVertexBounds.joinNonEmptyArg(positions);
run->fColor = color;
- intptr_t vertex = reinterpret_cast<intptr_t>(blob->fVertices + subRun->fVertexEndIndex);
+ intptr_t vertex = reinterpret_cast<intptr_t>(blob->fVertices + subRun->vertexEndIndex());
if (useVertexColor) {
// V0
@@ -1163,9 +1163,7 @@
position = reinterpret_cast<SkPoint*>(vertex);
position->set(positions.fRight, positions.fTop);
}
-
- subRun->fGlyphEndIndex++;
- subRun->fVertexEndIndex += vertexStride * GrAtlasTextBatch::kVerticesPerGlyph;
+ subRun->appendVertices(vertexStride);
}
void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc,
@@ -1211,7 +1209,7 @@
int glyphCount, int run, int subRun,
GrColor color, SkScalar transX, SkScalar transY,
const SkPaint& skPaint) {
- GrMaskFormat format = info.fMaskFormat;
+ GrMaskFormat format = info.maskFormat();
GrColor subRunColor;
if (kARGB_GrMaskFormat == format) {
uint8_t paintAlpha = skPaint.getAlpha();
@@ -1221,7 +1219,7 @@
}
GrAtlasTextBatch* batch;
- if (info.fDrawAsDistanceFields) {
+ if (info.drawAsDistanceFields()) {
SkColor filteredColor;
SkColorFilter* colorFilter = skPaint.getColorFilter();
if (colorFilter) {
@@ -1232,7 +1230,7 @@
bool useBGR = SkPixelGeometryIsBGR(fSurfaceProps.pixelGeometry());
batch = GrAtlasTextBatch::CreateDistanceField(glyphCount, fContext->getBatchFontCache(),
fDistanceAdjustTable, filteredColor,
- info.fUseLCDText, useBGR);
+ info.hasUseLCDText(), useBGR);
} else {
batch = GrAtlasTextBatch::CreateBitmap(format, glyphCount, fContext->getBatchFontCache());
}
@@ -1254,7 +1252,7 @@
const SkPaint& skPaint) {
for (int subRun = 0; subRun < cacheBlob->fRuns[run].fSubRunInfo.count(); subRun++) {
const PerSubRunInfo& info = cacheBlob->fRuns[run].fSubRunInfo[subRun];
- int glyphCount = info.fGlyphEndIndex - info.fGlyphStartIndex;
+ int glyphCount = info.glyphCount();
if (0 == glyphCount) {
continue;
}