Allow LCD text to batch across colorchanges. This will always use
color vertices, even when we can't batch across color changes
BUG=skia:
Review URL: https://codereview.chromium.org/1502253003
diff --git a/src/gpu/batches/GrAtlasTextBatch.cpp b/src/gpu/batches/GrAtlasTextBatch.cpp
index b1ec1f8..685cddc 100644
--- a/src/gpu/batches/GrAtlasTextBatch.cpp
+++ b/src/gpu/batches/GrAtlasTextBatch.cpp
@@ -312,12 +312,10 @@
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 {
@@ -333,9 +331,7 @@
FlushInfo flushInfo;
flushInfo.fGlyphsToFlush = 0;
size_t vertexStride = gp->getVertexStride();
- SkASSERT(vertexStride == (usesDistanceFields ?
- GetVertexStrideDf(maskFormat, isLCD) :
- GetVertexStride(maskFormat)));
+ SkASSERT(vertexStride == GetVertexStride(maskFormat));
target->initDraw(gp, this->pipeline());
@@ -381,12 +377,8 @@
bool regenerateGlyphs = info.strike()->isAbandoned();
bool regenerateTextureCoords = info.atlasGeneration() != currentAtlasGen ||
regenerateGlyphs;
- bool regenerateColors;
- if (usesDistanceFields) {
- regenerateColors = !isLCD && run.fColor != args.fColor;
- } else {
- regenerateColors = kA8_GrMaskFormat == maskFormat && run.fColor != args.fColor;
- }
+ bool regenerateColors = kARGB_GrMaskFormat != maskFormat &&
+ run.fColor != args.fColor;
bool regeneratePositions = args.fTransX != 0.f || args.fTransY != 0.f;
int glyphCount = info.glyphCount();
@@ -459,9 +451,7 @@
}
if (!this->usesDistanceFields()) {
- // TODO we can often batch across LCD text if we have dual source blending and don't
- // have to use the blend constant
- if (kGrayscaleCoverageMask_MaskType != fMaskType && this->color() != that->color()) {
+ if (kColorBitmapMask_MaskType == fMaskType && this->color() != that->color()) {
return false;
}
if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->viewMatrix())) {
@@ -479,11 +469,6 @@
if (fUseBGR != that->fUseBGR) {
return false;
}
-
- // TODO see note above
- if (kLCDDistanceField_MaskType == fMaskType && this->color() != that->color()) {
- return false;
- }
}
fBatch.fNumGlyphs += that->numGlyphs();
@@ -530,6 +515,7 @@
flags |= kUseLCD_DistanceFieldEffectFlag;
flags |= viewMatrix.rectStaysRect() ? kRectToRect_DistanceFieldEffectFlag : 0;
flags |= fUseBGR ? kBGR_DistanceFieldEffectFlag : 0;
+ flags |= kColorAttr_DistanceFieldEffectFlag;
GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor);
diff --git a/src/gpu/batches/GrAtlasTextBatch.h b/src/gpu/batches/GrAtlasTextBatch.h
index 11cd89e..95abbf4 100644
--- a/src/gpu/batches/GrAtlasTextBatch.h
+++ b/src/gpu/batches/GrAtlasTextBatch.h
@@ -15,11 +15,11 @@
class GrAtlasTextBatch : public GrVertexBatch {
public:
DEFINE_BATCH_CLASS_ID
- static const size_t kLCDTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16);
// 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 size_t kLCDTextVASize = kGrayTextVASize;
static const int kVerticesPerGlyph = GrAtlasTextBlob::kVerticesPerGlyph;
static const int kIndicesPerGlyph = 6;
@@ -113,15 +113,6 @@
}
}
- static size_t GetVertexStrideDf(GrMaskFormat maskFormat, bool useLCDText) {
- SkASSERT(maskFormat == kA8_GrMaskFormat);
- if (useLCDText) {
- return kLCDTextVASize;
- } else {
- return kGrayTextVASize;
- }
- }
-
protected:
void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,