From 3660d534516e4687546a43ac80d0ae40bc68dae7 Mon Sep 17 00:00:00 2001 From: joshualitt Date: Mon, 7 Dec 2015 11:32:50 -0800 Subject: Start objectifying GrAtlasTextBlob BUG=skia: Review URL: https://codereview.chromium.org/1503193002 --- src/gpu/batches/GrAtlasTextBatch.cpp | 31 ++++++++++++++++--------------- src/gpu/batches/GrAtlasTextBatch.h | 4 ++-- 2 files changed, 18 insertions(+), 17 deletions(-) (limited to 'src/gpu/batches') diff --git a/src/gpu/batches/GrAtlasTextBatch.cpp b/src/gpu/batches/GrAtlasTextBatch.cpp index fa34036af6..b1ec1f8ef5 100644 --- a/src/gpu/batches/GrAtlasTextBatch.cpp +++ b/src/gpu/batches/GrAtlasTextBatch.cpp @@ -135,7 +135,7 @@ inline void GrAtlasTextBatch::regenBlob(Target* target, FlushInfo* flushInfo, Bl static_assert(!regenGlyphs || regenTexCoords, "must regenTexCoords along regenGlyphs"); GrBatchTextStrike* strike = nullptr; if (regenTexCoords) { - info->fBulkUseToken.reset(); + info->resetBulkUseToken(); // We can reuse if we have a valid strike and our descriptors / typeface are the // same. The override descriptor is only for the non distance field text within @@ -151,14 +151,14 @@ inline void GrAtlasTextBatch::regenBlob(Target* target, FlushInfo* flushInfo, Bl *desc = newDesc; *cache = SkGlyphCache::DetachCache(run->fTypeface, *desc); *scaler = GrTextContext::GetGrFontScaler(*cache); - strike = info->fStrike; + strike = info->strike(); *typeface = run->fTypeface; } if (regenGlyphs) { strike = fFontCache->getStrike(*scaler); } else { - strike = info->fStrike; + strike = info->strike(); } } @@ -166,7 +166,7 @@ inline void GrAtlasTextBatch::regenBlob(Target* target, FlushInfo* flushInfo, Bl for (int glyphIdx = 0; glyphIdx < glyphCount; glyphIdx++) { GrGlyph* glyph = nullptr; if (regenTexCoords) { - size_t glyphOffset = glyphIdx + info->fGlyphStartIndex; + size_t glyphOffset = glyphIdx + info->glyphStartIndex(); if (regenGlyphs) { // Get the id from the old glyph, and use the new strike to lookup @@ -190,12 +190,12 @@ inline void GrAtlasTextBatch::regenBlob(Target* target, FlushInfo* flushInfo, Bl this->maskFormat()); SkASSERT(success); } - fFontCache->addGlyphToBulkAndSetUseToken(&info->fBulkUseToken, glyph, + fFontCache->addGlyphToBulkAndSetUseToken(info->bulkUseToken(), glyph, target->currentToken()); } intptr_t vertex = reinterpret_cast(blob->fVertices); - vertex += info->fVertexStartIndex; + vertex += info->vertexStartIndex(); vertex += vertexStride * glyphIdx * GrAtlasTextBatch::kVerticesPerGlyph; regen_vertices(vertex, glyph, vertexStride, this->usesDistanceFields(), transX, @@ -207,10 +207,10 @@ inline void GrAtlasTextBatch::regenBlob(Target* target, FlushInfo* flushInfo, Bl run->fColor = color; if (regenTexCoords) { if (regenGlyphs) { - info->fStrike.reset(SkRef(strike)); + info->setStrike(strike); } - info->fAtlasGeneration = brokenRun ? GrBatchAtlas::kInvalidAtlasGeneration : - fFontCache->atlasGeneration(this->maskFormat()); + info->setAtlasGeneration(brokenRun ? GrBatchAtlas::kInvalidAtlasGeneration : + fFontCache->atlasGeneration(this->maskFormat())); } } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -378,8 +378,8 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) const { // new strike, we instead keep our ref to the old strike and use the packed ids from // it. These ids will still be valid as long as we hold the ref. When we are done // updating our cache of the GrGlyph*s, we drop our ref on the old strike - bool regenerateGlyphs = info.fStrike->isAbandoned(); - bool regenerateTextureCoords = info.fAtlasGeneration != currentAtlasGen || + bool regenerateGlyphs = info.strike()->isAbandoned(); + bool regenerateTextureCoords = info.atlasGeneration() != currentAtlasGen || regenerateGlyphs; bool regenerateColors; if (usesDistanceFields) { @@ -388,7 +388,7 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) const { regenerateColors = kA8_GrMaskFormat == maskFormat && run.fColor != args.fColor; } bool regeneratePositions = args.fTransX != 0.f || args.fTransY != 0.f; - int glyphCount = info.fGlyphEndIndex - info.fGlyphStartIndex; + int glyphCount = info.glyphCount(); uint32_t regenMaskBits = kNoRegen; regenMaskBits |= regeneratePositions ? kRegenPos : 0; @@ -416,13 +416,14 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) const { // set use tokens for all of the glyphs in our subrun. This is only valid if we // have a valid atlas generation - fFontCache->setUseTokenBulk(info.fBulkUseToken, target->currentToken(), maskFormat); + fFontCache->setUseTokenBulk(*info.bulkUseToken(), target->currentToken(), + maskFormat); break; } // now copy all vertices - size_t byteCount = info.fVertexEndIndex - info.fVertexStartIndex; - memcpy(currVertex, blob->fVertices + info.fVertexStartIndex, byteCount); + size_t byteCount = info.byteCount(); + memcpy(currVertex, blob->fVertices + info.vertexStartIndex(), byteCount); currVertex += byteCount; } diff --git a/src/gpu/batches/GrAtlasTextBatch.h b/src/gpu/batches/GrAtlasTextBatch.h index 65fd07d7bb..11cd89ea9a 100644 --- a/src/gpu/batches/GrAtlasTextBatch.h +++ b/src/gpu/batches/GrAtlasTextBatch.h @@ -20,7 +20,7 @@ public: // position + local coord static const size_t kColorTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16); static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + sizeof(SkIPoint16); - static const int kVerticesPerGlyph = 4; + static const int kVerticesPerGlyph = GrAtlasTextBlob::kVerticesPerGlyph; static const int kIndicesPerGlyph = 6; typedef GrAtlasTextContext::DistanceAdjustTable DistanceAdjustTable; @@ -89,7 +89,7 @@ public: // We don't yet position distance field text on the cpu, so we have to map the vertex bounds // into device space const Run& run = geo.fBlob->fRuns[geo.fRun]; - if (run.fSubRunInfo[geo.fSubRun].fDrawAsDistanceFields) { + if (run.fSubRunInfo[geo.fSubRun].drawAsDistanceFields()) { SkRect bounds = run.fVertexBounds; fBatch.fViewMatrix.mapRect(&bounds); this->setBounds(bounds); -- cgit v1.2.3