From f9e658b1d648948ebe37db5cceebd61cddc94575 Mon Sep 17 00:00:00 2001 From: joshualitt Date: Wed, 9 Dec 2015 09:26:44 -0800 Subject: [PATCH] Fix bug with GrAtlasTextContext color regen BUG=skia: Review URL: https://codereview.chromium.org/1513723002 --- src/gpu/GrAtlasTextBlob.cpp | 2 +- src/gpu/GrAtlasTextBlob.h | 9 ++++++--- src/gpu/batches/GrAtlasTextBatch.cpp | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/gpu/GrAtlasTextBlob.cpp b/src/gpu/GrAtlasTextBlob.cpp index 3ccca49..0f7368a 100644 --- a/src/gpu/GrAtlasTextBlob.cpp +++ b/src/gpu/GrAtlasTextBlob.cpp @@ -30,7 +30,7 @@ void GrAtlasTextBlob::appendGlyph(int runIndex, subRun->setMaskFormat(format); run.fVertexBounds.joinNonEmptyArg(positions); - run.fColor = color; + subRun->setColor(color); intptr_t vertex = reinterpret_cast(this->fVertices + subRun->vertexEndIndex()); diff --git a/src/gpu/GrAtlasTextBlob.h b/src/gpu/GrAtlasTextBlob.h index 6f92c1e..a400782 100644 --- a/src/gpu/GrAtlasTextBlob.h +++ b/src/gpu/GrAtlasTextBlob.h @@ -63,8 +63,7 @@ struct GrAtlasTextBlob : public SkNVRefCnt { */ struct Run { Run() - : fColor(GrColor_ILLEGAL) - , fInitialized(false) + : fInitialized(false) , fDrawAsPaths(false) { fVertexBounds.setLargestInverted(); // To ensure we always have one subrun, we push back a fresh run here @@ -77,6 +76,7 @@ struct GrAtlasTextBlob : public SkNVRefCnt { , fVertexEndIndex(0) , fGlyphStartIndex(0) , fGlyphEndIndex(0) + , fColor(GrColor_ILLEGAL) , fMaskFormat(kA8_GrMaskFormat) , fDrawAsDistanceFields(false) , fUseLCDText(false) {} @@ -88,6 +88,7 @@ struct GrAtlasTextBlob : public SkNVRefCnt { , fVertexEndIndex(that.fVertexEndIndex) , fGlyphStartIndex(that.fGlyphStartIndex) , fGlyphEndIndex(that.fGlyphEndIndex) + , fColor(that.fColor) , fMaskFormat(that.fMaskFormat) , fDrawAsDistanceFields(that.fDrawAsDistanceFields) , fUseLCDText(that.fUseLCDText) { @@ -113,6 +114,8 @@ struct GrAtlasTextBlob : public SkNVRefCnt { uint32_t glyphStartIndex() const { return fGlyphStartIndex; } uint32_t glyphEndIndex() const { return fGlyphEndIndex; } void glyphAppended() { fGlyphEndIndex++; } + void setColor(GrColor color) { fColor = color; } + GrColor color() const { return fColor; } void setMaskFormat(GrMaskFormat format) { fMaskFormat = format; } GrMaskFormat maskFormat() const { return fMaskFormat; } @@ -138,6 +141,7 @@ struct GrAtlasTextBlob : public SkNVRefCnt { size_t fVertexEndIndex; uint32_t fGlyphStartIndex; uint32_t fGlyphEndIndex; + GrColor fColor; GrMaskFormat fMaskFormat; bool fDrawAsDistanceFields; // df property bool fUseLCDText; // df property @@ -162,7 +166,6 @@ struct GrAtlasTextBlob : public SkNVRefCnt { // will have different descriptors. If fOverrideDescriptor is non-nullptr, then it // will be used in place of the run's descriptor to regen texture coords SkAutoTDelete fOverrideDescriptor; // df properties - GrColor fColor; bool fInitialized; bool fDrawAsPaths; }; diff --git a/src/gpu/batches/GrAtlasTextBatch.cpp b/src/gpu/batches/GrAtlasTextBatch.cpp index 3f3a521..d7f59a9 100644 --- a/src/gpu/batches/GrAtlasTextBatch.cpp +++ b/src/gpu/batches/GrAtlasTextBatch.cpp @@ -203,8 +203,8 @@ inline void GrAtlasTextBatch::regenBlob(Target* target, FlushInfo* flushInfo, Bl flushInfo->fGlyphsToFlush++; } - // We my have changed the color so update it here - run->fColor = color; + // We may have changed the color so update it here + info->setColor(color); if (regenTexCoords) { if (regenGlyphs) { info->setStrike(strike); @@ -378,7 +378,7 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) const { bool regenerateTextureCoords = info.atlasGeneration() != currentAtlasGen || regenerateGlyphs; bool regenerateColors = kARGB_GrMaskFormat != maskFormat && - run.fColor != args.fColor; + info.color() != args.fColor; bool regeneratePositions = args.fTransX != 0.f || args.fTransY != 0.f; int glyphCount = info.glyphCount(); -- 2.7.4