Fix bug with GrAtlasTextContext color regen
authorjoshualitt <joshualitt@chromium.org>
Wed, 9 Dec 2015 17:26:44 +0000 (09:26 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 9 Dec 2015 17:26:44 +0000 (09:26 -0800)
BUG=skia:

Review URL: https://codereview.chromium.org/1513723002

src/gpu/GrAtlasTextBlob.cpp
src/gpu/GrAtlasTextBlob.h
src/gpu/batches/GrAtlasTextBatch.cpp

index 3ccca49..0f7368a 100644 (file)
@@ -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<intptr_t>(this->fVertices + subRun->vertexEndIndex());
 
index 6f92c1e..a400782 100644 (file)
@@ -63,8 +63,7 @@ struct GrAtlasTextBlob : public SkNVRefCnt<GrAtlasTextBlob> {
      */
     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<GrAtlasTextBlob> {
                 , fVertexEndIndex(0)
                 , fGlyphStartIndex(0)
                 , fGlyphEndIndex(0)
+                , fColor(GrColor_ILLEGAL)
                 , fMaskFormat(kA8_GrMaskFormat)
                 , fDrawAsDistanceFields(false)
                 , fUseLCDText(false) {}
@@ -88,6 +88,7 @@ struct GrAtlasTextBlob : public SkNVRefCnt<GrAtlasTextBlob> {
                 , 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<GrAtlasTextBlob> {
             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<GrAtlasTextBlob> {
             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<GrAtlasTextBlob> {
         // 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;
     };
index 3f3a521..d7f59a9 100644 (file)
@@ -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();