Fix bug with GrAtlasTextContext color regen
BUG=skia:
Review URL: https://codereview.chromium.org/1513723002
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 @@
subRun->setMaskFormat(format);
run.fVertexBounds.joinNonEmptyArg(positions);
- run.fColor = color;
+ subRun->setColor(color);
intptr_t vertex = reinterpret_cast<intptr_t>(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 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 @@
, fVertexEndIndex(0)
, fGlyphStartIndex(0)
, fGlyphEndIndex(0)
+ , fColor(GrColor_ILLEGAL)
, fMaskFormat(kA8_GrMaskFormat)
, fDrawAsDistanceFields(false)
, fUseLCDText(false) {}
@@ -88,6 +88,7 @@
, 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 @@
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 @@
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 @@
// 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<SkAutoDescriptor> 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 @@
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 @@
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();