Index: src/gpu/batches/GrAtlasTextBatch.cpp |
diff --git a/src/gpu/batches/GrAtlasTextBatch.cpp b/src/gpu/batches/GrAtlasTextBatch.cpp |
index 91088c0c59068811a94fea0a48c9ba6dca51d39a..48892946733f4ce32575802942b82491350155a9 100644 |
--- a/src/gpu/batches/GrAtlasTextBatch.cpp |
+++ b/src/gpu/batches/GrAtlasTextBatch.cpp |
@@ -96,12 +96,11 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) { |
return; |
} |
- bool usesDistanceFields = this->usesDistanceFields(); |
GrMaskFormat maskFormat = this->maskFormat(); |
bool isLCD = this->isLCD(); |
SkAutoTUnref<const GrGeometryProcessor> gp; |
- if (usesDistanceFields) { |
+ if (this->usesDistanceFields()) { |
gp.reset(this->setupDfProcessor(this->viewMatrix(), fFilteredColor, this->color(), |
texture)); |
} else { |
@@ -117,7 +116,7 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) { |
FlushInfo flushInfo; |
flushInfo.fGlyphsToFlush = 0; |
size_t vertexStride = gp->getVertexStride(); |
- SkASSERT(vertexStride == (usesDistanceFields ? |
+ SkASSERT(vertexStride == (this->usesDistanceFields() ? |
GetVertexStrideDf(maskFormat, isLCD) : |
GetVertexStride(maskFormat))); |
@@ -153,8 +152,9 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) { |
TextInfo& info = run.fSubRunInfo[args.fSubRun]; |
uint64_t currentAtlasGen = fFontCache->atlasGeneration(maskFormat); |
+ bool regenerateGlyphs = info.fStrike->isAbandoned(); |
bool regenerateTextureCoords = info.fAtlasGeneration != currentAtlasGen || |
- info.fStrike->isAbandoned(); |
+ regenerateGlyphs; |
bool regenerateColors; |
if (usesDistanceFields) { |
regenerateColors = !isLCD && run.fColor != args.fColor; |
@@ -184,7 +184,6 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) { |
// 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 = false; |
GrBatchTextStrike* strike = nullptr; |
if (regenerateTextureCoords) { |
info.fBulkUseToken.reset(); |
@@ -192,7 +191,8 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) { |
// 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 |
// a run |
- const SkDescriptor* newDesc = (run.fOverrideDescriptor && !usesDistanceFields) ? |
+ const SkDescriptor* newDesc = (run.fOverrideDescriptor && |
+ !this->usesDistanceFields()) ? |
run.fOverrideDescriptor->getDesc() : |
run.fDescriptor.getDesc(); |
if (!cache || !SkTypeface::Equal(typeface, run.fTypeface) || |
@@ -207,8 +207,7 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) { |
typeface = run.fTypeface; |
} |
- if (info.fStrike->isAbandoned()) { |
- regenerateGlyphs = true; |
+ if (regenerateGlyphs) { |
strike = fFontCache->getStrike(scaler); |
} else { |
strike = info.fStrike; |
@@ -231,9 +230,7 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) { |
glyph = blob->fGlyphs[glyphOffset]; |
SkASSERT(glyph); |
SkASSERT(id == glyph->fPackedID); |
- // We want to be able to assert this but cannot for testing purposes. |
- // once skbug:4143 has landed we can revist this assert |
- //SkASSERT(glyph->fMaskFormat == this->maskFormat()); |
+ SkASSERT(glyph->fMaskFormat == this->maskFormat()); |
if (!fFontCache->hasGlyph(glyph) && |
!strike->addGlyphToAtlas(target, glyph, scaler, skGlyph, maskFormat)) { |
@@ -251,30 +248,18 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) { |
fFontCache->addGlyphToBulkAndSetUseToken(&info.fBulkUseToken, glyph, |
target->currentToken()); |
- // Texture coords are the last vertex attribute so we get a pointer to the |
- // first one and then map with stride in regenerateTextureCoords |
- intptr_t vertex = reinterpret_cast<intptr_t>(blob->fVertices); |
- vertex += info.fVertexStartIndex; |
- vertex += vertexStride * glyphIdx * kVerticesPerGlyph; |
- vertex += vertexStride - sizeof(SkIPoint16); |
- |
- this->regenerateTextureCoords(glyph, vertex, vertexStride); |
+ this->regenerateTextureCoords(glyph, blob->fVertices, glyphIdx, |
+ info.fVertexStartIndex, vertexStride); |
} |
if (regenerateColors) { |
- intptr_t vertex = reinterpret_cast<intptr_t>(blob->fVertices); |
- vertex += info.fVertexStartIndex; |
- vertex += vertexStride * glyphIdx * kVerticesPerGlyph + sizeof(SkPoint); |
- this->regenerateColors(vertex, vertexStride, args.fColor); |
+ this->regenerateColors(blob->fVertices, glyphIdx, info.fVertexStartIndex, |
+ vertexStride, args.fColor); |
} |
if (regeneratePositions) { |
- intptr_t vertex = reinterpret_cast<intptr_t>(blob->fVertices); |
- vertex += info.fVertexStartIndex; |
- vertex += vertexStride * glyphIdx * kVerticesPerGlyph; |
- SkScalar transX = args.fTransX; |
- SkScalar transY = args.fTransY; |
- this->regeneratePositions(vertex, vertexStride, transX, transY); |
+ this->regeneratePositions(blob->fVertices, glyphIdx, info.fVertexStartIndex, |
+ vertexStride, args.fTransX, args.fTransY); |
} |
flushInfo.fGlyphsToFlush++; |
} |
@@ -309,8 +294,8 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) { |
this->flush(target, &flushInfo); |
} |
-void GrAtlasTextBatch::regenerateTextureCoords(GrGlyph* glyph, intptr_t vertex, |
- size_t vertexStride) { |
+void GrAtlasTextBatch::regenerateTextureCoords(const GrGlyph* glyph, void* vertices, int glyphIdx, |
+ size_t vertexStartIndex, size_t vertexStride) { |
int width = glyph->fBounds.width(); |
int height = glyph->fBounds.height(); |
@@ -327,6 +312,13 @@ void GrAtlasTextBatch::regenerateTextureCoords(GrGlyph* glyph, intptr_t vertex, |
v1 = v0 + height; |
} |
+ // Texture coords are the last vertex attribute so we get a pointer to the |
+ // first one and then map with stride in regenerateTextureCoords |
+ intptr_t vertex = reinterpret_cast<intptr_t>(vertices); |
+ vertex += vertexStartIndex; |
+ vertex += vertexStride * glyphIdx * kVerticesPerGlyph; |
+ vertex += vertexStride - sizeof(SkIPoint16); |
+ |
SkIPoint16* textureCoords; |
// V0 |
textureCoords = reinterpret_cast<SkIPoint16*>(vertex); |
@@ -348,7 +340,12 @@ void GrAtlasTextBatch::regenerateTextureCoords(GrGlyph* glyph, intptr_t vertex, |
textureCoords->set(u1, v0); |
} |
robertphillips
2015/11/20 18:43:02
can this be static ?
|
-void GrAtlasTextBatch::regenerateColors(intptr_t vertex, size_t vertexStride, GrColor color) { |
+void GrAtlasTextBatch::regenerateColors(void* vertices, int glyphIdx, size_t vertexStartIndex, |
+ size_t vertexStride, GrColor color) { |
+ intptr_t vertex = reinterpret_cast<intptr_t>(vertices); |
+ vertex += vertexStartIndex; |
+ vertex += vertexStride * glyphIdx * kVerticesPerGlyph + sizeof(SkPoint); |
+ |
for (int i = 0; i < kVerticesPerGlyph; i++) { |
SkColor* vcolor = reinterpret_cast<SkColor*>(vertex); |
*vcolor = color; |
@@ -356,8 +353,11 @@ void GrAtlasTextBatch::regenerateColors(intptr_t vertex, size_t vertexStride, Gr |
} |
} |
robertphillips
2015/11/20 18:43:02
this guy too ?
|
-void GrAtlasTextBatch::regeneratePositions(intptr_t vertex, size_t vertexStride, SkScalar transX, |
- SkScalar transY) { |
+void GrAtlasTextBatch::regeneratePositions(void* vertices, int glyphIdx, size_t vertexStartIndex, |
+ size_t vertexStride, SkScalar transX, SkScalar transY) { |
+ intptr_t vertex = reinterpret_cast<intptr_t>(vertices); |
+ vertex += vertexStartIndex; |
+ vertex += vertexStride * glyphIdx * kVerticesPerGlyph; |
for (int i = 0; i < kVerticesPerGlyph; i++) { |
SkPoint* point = reinterpret_cast<SkPoint*>(vertex); |
point->fX += transX; |