Push GrPipelineBuilder down to the drawBatch calls in the TextContext
This is split out of https://codereview.chromium.org/2092893003/ (Retract PipelineBuilder some more)
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2155983003
Review-Url: https://codereview.chromium.org/2155983003
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index 0ead354..9ab9c12 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -302,9 +302,9 @@
}
inline
-void GrAtlasTextBlob::flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBuilder,
+void GrAtlasTextBlob::flushRun(GrDrawContext* dc, const GrPaint& grPaint,
const GrClip& clip, int run, const SkMatrix& viewMatrix, SkScalar x,
- SkScalar y, GrColor color,
+ SkScalar y,
const SkPaint& skPaint, const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
GrBatchFontCache* cache) {
@@ -315,12 +315,17 @@
continue;
}
+ GrColor color = grPaint.getColor();
+
SkAutoTUnref<GrDrawBatch> batch(this->createBatch(info, glyphCount, run,
subRun, viewMatrix, x, y, color,
skPaint, props,
distanceAdjustTable, dc->isGammaCorrect(),
cache));
- dc->drawBatch(*pipelineBuilder, clip, batch);
+
+ GrPipelineBuilder pipelineBuilder(grPaint, dc->mustUseHWAA(grPaint));
+
+ dc->drawBatch(pipelineBuilder, clip, batch);
}
}
@@ -419,10 +424,6 @@
SkScalar x, SkScalar y) {
// We loop through the runs of the blob, flushing each. If any run is too large, then we flush
// it as paths
- GrPipelineBuilder pipelineBuilder(grPaint, dc->mustUseHWAA(grPaint));
-
- GrColor color = grPaint.getColor();
-
SkTextBlobRunIterator it(blob);
for (int run = 0; !it.done(); it.next(), run++) {
if (fRuns[run].fDrawAsPaths) {
@@ -430,7 +431,7 @@
drawFilter, viewMatrix, clipBounds, x, y);
continue;
}
- this->flushRun(dc, &pipelineBuilder, clip, run, viewMatrix, x, y, color, skPaint, props,
+ this->flushRun(dc, grPaint, clip, run, viewMatrix, x, y, skPaint, props,
distanceAdjustTable, context->getBatchFontCache());
}
@@ -448,11 +449,8 @@
const SkMatrix& viewMatrix,
const SkIRect& clipBounds,
SkScalar x, SkScalar y) {
- GrPipelineBuilder pipelineBuilder(grPaint, dc->mustUseHWAA(grPaint));
-
- GrColor color = grPaint.getColor();
for (int run = 0; run < fRunCount; run++) {
- this->flushRun(dc, &pipelineBuilder, clip, run, viewMatrix, x, y, color, skPaint, props,
+ this->flushRun(dc, grPaint, clip, run, viewMatrix, x, y, skPaint, props,
distanceAdjustTable, context->getBatchFontCache());
}
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 63c8033..f76d026 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -293,8 +293,8 @@
void appendLargeGlyph(GrGlyph* glyph, SkGlyphCache* cache, const SkGlyph& skGlyph,
SkScalar x, SkScalar y, SkScalar scale, bool applyVM);
- inline void flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBuilder, const GrClip&,
- int run, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color,
+ inline void flushRun(GrDrawContext* dc, const GrPaint&, const GrClip&,
+ int run, const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
const SkPaint& skPaint, const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
GrBatchFontCache* cache);
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp
index aba854d..dd93025 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -82,9 +82,8 @@
} else if (this->canDraw(skPaint, viewMatrix)) {
if (skPaint.getTextSize() > 0) {
TextRun run(skPaint);
- GrPipelineBuilder pipelineBuilder(paint);
run.setText(text, byteLength, x, y);
- run.draw(context, dc, &pipelineBuilder, clip, paint.getColor(), viewMatrix, props, 0, 0,
+ run.draw(context, dc, paint, clip, paint.getColor(), viewMatrix, props, 0, 0,
clipBounds, fFallbackTextContext, skPaint);
}
return;
@@ -117,9 +116,8 @@
} else if (this->canDraw(skPaint, viewMatrix)) {
if (skPaint.getTextSize() > 0) {
TextRun run(skPaint);
- GrPipelineBuilder pipelineBuilder(paint);
run.setPosText(text, byteLength, pos, scalarsPerPosition, offset);
- run.draw(context, dc, &pipelineBuilder, clip, paint.getColor(), viewMatrix, props, 0, 0,
+ run.draw(context, dc, paint, clip, paint.getColor(), viewMatrix, props, 0, 0,
clipBounds, fFallbackTextContext, skPaint);
}
return;
@@ -225,11 +223,10 @@
}
const TextBlob& blob = this->findOrCreateTextBlob(skBlob, skPaint);
- GrPipelineBuilder pipelineBuilder(paint);
TextBlob::Iter iter(blob);
for (TextRun* run = iter.get(); run; run = iter.next()) {
- run->draw(context, dc, &pipelineBuilder, clip, paint.getColor(), viewMatrix, props, x, y,
+ run->draw(context, dc, paint, clip, paint.getColor(), viewMatrix, props, x, y,
clipBounds, fFallbackTextContext, skPaint);
run->releaseGlyphCache();
}
@@ -596,7 +593,7 @@
void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
GrDrawContext* drawContext,
- GrPipelineBuilder* pipelineBuilder,
+ const GrPaint& grPaint,
const GrClip& clip,
GrColor color,
const SkMatrix& viewMatrix,
@@ -609,8 +606,6 @@
SkASSERT(drawContext->isStencilBufferMultisampled() || !fFont.isAntiAlias());
if (fInstanceData->count()) {
- pipelineBuilder->setState(GrPipelineBuilder::kHWAntialias_Flag, fFont.isAntiAlias());
-
static constexpr GrUserStencilSettings kCoverPass(
GrUserStencilSettings::StaticInit<
0x0000,
@@ -621,8 +616,6 @@
0xffff>()
);
- pipelineBuilder->setUserStencil(&kCoverPass);
-
SkAutoTUnref<GrPathRange> glyphs(this->createGlyphs(ctx));
if (fLastDrawnGlyphsID != glyphs->getUniqueID()) {
// Either this is the first draw or the glyphs object was purged since last draw.
@@ -643,7 +636,11 @@
GrPathRendering::kWinding_FillType, glyphs, fInstanceData,
bounds));
- drawContext->drawBatch(*pipelineBuilder, clip, batch);
+ GrPipelineBuilder pipelineBuilder(grPaint);
+ pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, fFont.isAntiAlias());
+ pipelineBuilder.setUserStencil(&kCoverPass);
+
+ drawContext->drawBatch(pipelineBuilder, clip, batch);
}
if (fFallbackTextBlob) {
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.h b/src/gpu/text/GrStencilAndCoverTextContext.h
index 64bcd4d..d81cb7a 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.h
+++ b/src/gpu/text/GrStencilAndCoverTextContext.h
@@ -78,7 +78,7 @@
void setPosText(const char text[], size_t byteLength, const SkScalar pos[],
int scalarsPerPosition, const SkPoint& offset);
- void draw(GrContext*, GrDrawContext*, GrPipelineBuilder*, const GrClip&, GrColor,
+ void draw(GrContext*, GrDrawContext*, const GrPaint&, const GrClip&, GrColor,
const SkMatrix&, const SkSurfaceProps&,
SkScalar x, SkScalar y, const SkIRect& clipBounds,
GrAtlasTextContext* fallbackTextContext, const SkPaint& originalSkPaint) const;