Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1035)

Unified Diff: src/gpu/GrStencilAndCoverTextContext.cpp

Issue 1320323004: Make GrTextContext no longer store a GrDrawContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add newline Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrStencilAndCoverTextContext.h ('k') | src/gpu/GrTextContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrStencilAndCoverTextContext.cpp
diff --git a/src/gpu/GrStencilAndCoverTextContext.cpp b/src/gpu/GrStencilAndCoverTextContext.cpp
index 78c3a2a8df53356d683b6cfc1a91c8c030da8bdb..047cd07978df6934edff09cbfde04def57faa400 100644
--- a/src/gpu/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/GrStencilAndCoverTextContext.cpp
@@ -22,20 +22,18 @@
#include "SkTextFormatParams.h"
GrStencilAndCoverTextContext::GrStencilAndCoverTextContext(GrContext* context,
- GrDrawContext* drawContext,
const SkSurfaceProps& surfaceProps)
- : GrTextContext(context, drawContext, surfaceProps)
+ : GrTextContext(context, surfaceProps)
, fStroke(SkStrokeRec::kFill_InitStyle)
, fQueuedGlyphCount(0)
, fFallbackGlyphsIdx(kGlyphBufferSize) {
}
GrStencilAndCoverTextContext*
-GrStencilAndCoverTextContext::Create(GrContext* context, GrDrawContext* drawContext,
- const SkSurfaceProps& surfaceProps) {
- GrStencilAndCoverTextContext* textContext =
- new GrStencilAndCoverTextContext(context, drawContext, surfaceProps);
- textContext->fFallbackTextContext = GrAtlasTextContext::Create(context, drawContext, surfaceProps);
+GrStencilAndCoverTextContext::Create(GrContext* context, const SkSurfaceProps& surfaceProps) {
+ GrStencilAndCoverTextContext* textContext =
+ new GrStencilAndCoverTextContext(context, surfaceProps);
+ textContext->fFallbackTextContext = GrAtlasTextContext::Create(context, surfaceProps);
return textContext;
}
@@ -73,7 +71,7 @@ bool GrStencilAndCoverTextContext::canDraw(const GrRenderTarget* rt,
return rec.getFormat() != SkMask::kARGB32_Format;
}
-void GrStencilAndCoverTextContext::onDrawText(GrRenderTarget* rt,
+void GrStencilAndCoverTextContext::onDrawText(GrDrawContext* dc, GrRenderTarget* rt,
const GrClip& clip,
const GrPaint& paint,
const SkPaint& skPaint,
@@ -156,17 +154,17 @@ void GrStencilAndCoverTextContext::onDrawText(GrRenderTarget* rt,
const SkGlyph& glyph = glyphCacheProc(fGlyphCache, &text, 0, 0);
fx += SkFixedMul(autokern.adjust(glyph), fixedSizeRatio);
if (glyph.fWidth) {
- this->appendGlyph(glyph, SkPoint::Make(SkFixedToScalar(fx), SkFixedToScalar(fy)));
+ this->appendGlyph(dc, glyph, SkPoint::Make(SkFixedToScalar(fx), SkFixedToScalar(fy)));
}
fx += SkFixedMul(glyph.fAdvanceX, fixedSizeRatio);
fy += SkFixedMul(glyph.fAdvanceY, fixedSizeRatio);
}
- this->finish();
+ this->finish(dc);
}
-void GrStencilAndCoverTextContext::onDrawPosText(GrRenderTarget* rt,
+void GrStencilAndCoverTextContext::onDrawPosText(GrDrawContext* dc, GrRenderTarget* rt,
const GrClip& clip,
const GrPaint& paint,
const SkPaint& skPaint,
@@ -210,12 +208,12 @@ void GrStencilAndCoverTextContext::onDrawPosText(GrRenderTarget* rt,
SkPoint loc;
alignProc(tmsLoc, glyph, &loc);
- this->appendGlyph(glyph, loc);
+ this->appendGlyph(dc, glyph, loc);
}
pos += scalarsPerPosition;
}
- this->finish();
+ this->finish(dc);
}
static GrPathRange* get_gr_glyphs(GrContext* ctx,
@@ -400,10 +398,12 @@ bool GrStencilAndCoverTextContext::mapToFallbackContext(SkMatrix* inverse) {
return true;
}
-inline void GrStencilAndCoverTextContext::appendGlyph(const SkGlyph& glyph, const SkPoint& pos) {
+inline void GrStencilAndCoverTextContext::appendGlyph(GrDrawContext* dc,
+ const SkGlyph& glyph,
+ const SkPoint& pos) {
if (fQueuedGlyphCount >= fFallbackGlyphsIdx) {
SkASSERT(fQueuedGlyphCount == fFallbackGlyphsIdx);
- this->flush();
+ this->flush(dc);
}
// Stick the glyphs we can't draw at the end of the buffer, growing backwards.
@@ -421,7 +421,7 @@ static const SkScalar* get_xy_scalar_array(const SkPoint* pointArray) {
return &pointArray[0].fX;
}
-void GrStencilAndCoverTextContext::flush() {
+void GrStencilAndCoverTextContext::flush(GrDrawContext* dc) {
if (fQueuedGlyphCount > 0) {
SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(fPaint.getColor(),
fViewMatrix,
@@ -446,11 +446,11 @@ void GrStencilAndCoverTextContext::flush() {
SkASSERT(0 == fQueuedGlyphCount);
SkASSERT(kGlyphBufferSize == fFallbackGlyphsIdx);
- fDrawContext->drawPaths(&pipelineBuilder, pp, fGlyphs,
- fGlyphIndices, GrPathRange::kU16_PathIndexType,
- get_xy_scalar_array(fGlyphPositions),
- GrPathRendering::kTranslate_PathTransformType,
- fQueuedGlyphCount, GrPathRendering::kWinding_FillType);
+ dc->drawPaths(&pipelineBuilder, pp, fGlyphs,
+ fGlyphIndices, GrPathRange::kU16_PathIndexType,
+ get_xy_scalar_array(fGlyphPositions),
+ GrPathRendering::kTranslate_PathTransformType,
+ fQueuedGlyphCount, GrPathRendering::kWinding_FillType);
fQueuedGlyphCount = 0;
}
@@ -472,7 +472,7 @@ void GrStencilAndCoverTextContext::flush() {
inverse.mapPoints(&fGlyphPositions[fFallbackGlyphsIdx], fallbackGlyphCount);
}
- fFallbackTextContext->drawPosText(fRenderTarget, fClip, paintFallback, skPaintFallback,
+ fFallbackTextContext->drawPosText(dc, fRenderTarget, fClip, paintFallback, skPaintFallback,
fViewMatrix, (char*)&fGlyphIndices[fFallbackGlyphsIdx],
2 * fallbackGlyphCount,
get_xy_scalar_array(&fGlyphPositions[fFallbackGlyphsIdx]),
@@ -482,8 +482,8 @@ void GrStencilAndCoverTextContext::flush() {
}
}
-void GrStencilAndCoverTextContext::finish() {
- this->flush();
+void GrStencilAndCoverTextContext::finish(GrDrawContext* dc) {
+ this->flush(dc);
fGlyphs->unref();
fGlyphs = nullptr;
« no previous file with comments | « src/gpu/GrStencilAndCoverTextContext.h ('k') | src/gpu/GrTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698