Index: src/gpu/SkGpuDevice.cpp |
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
index c858403669fa13496bc85777bb41168171ad67e4..dfae1c4a49bb502cb367e66f2fc23c2fc2fe7fd6 100644 |
--- a/src/gpu/SkGpuDevice.cpp |
+++ b/src/gpu/SkGpuDevice.cpp |
@@ -201,9 +201,11 @@ void SkGpuDevice::initFromRenderTarget(GrContext* context, |
fContext->ref(); |
#if SK_DISTANCEFIELD_FONTS |
- fTextContextManager = SkNEW(GrTTextContextManager<GrDistanceFieldTextContext>); |
+ fMainTextContext = SkNEW_ARGS(GrDistanceFieldTextContext, (fContext, fLeakyProperties)); |
+ fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProperties)); |
#else |
- fTextContextManager = SkNEW(GrTTextContextManager<GrBitmapTextContext>); |
+ fMainTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProperties)); |
+ fFallbackTextContext = NULL; |
#endif |
fRenderTarget = NULL; |
@@ -242,9 +244,11 @@ SkGpuDevice::SkGpuDevice(GrContext* context, |
fContext->ref(); |
#if SK_DISTANCEFIELD_FONTS |
- fTextContextManager = SkNEW(GrTTextContextManager<GrDistanceFieldTextContext>); |
+ fMainTextContext = SkNEW_ARGS(GrDistanceFieldTextContext, (fContext, fLeakyProperties)); |
+ fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProperties)); |
#else |
- fTextContextManager = SkNEW(GrTTextContextManager<GrBitmapTextContext>); |
+ fMainTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProperties)); |
+ fFallbackTextContext = NULL; |
#endif |
fRenderTarget = NULL; |
@@ -292,7 +296,8 @@ SkGpuDevice::~SkGpuDevice() { |
delete fDrawProcs; |
} |
- delete fTextContextManager; |
+ delete fMainTextContext; |
+ delete fFallbackTextContext; |
// The GrContext takes a ref on the target. We don't want to cause the render |
// target to be unnecessarily kept alive. |
@@ -1778,7 +1783,7 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text, |
const SkPaint& paint) { |
CHECK_SHOULD_DRAW(draw, false); |
- if (fTextContextManager->canDraw(paint, fContext->getMatrix())) { |
+ if (fMainTextContext->canDraw(paint)) { |
GrPaint grPaint; |
if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |
return; |
@@ -1786,11 +1791,8 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text, |
SkDEBUGCODE(this->validate();) |
- SkAutoTDelete<GrTextContext> ctx(fTextContextManager->create(this->context(), |
- grPaint, paint, |
- this->getDeviceProperties())); |
- ctx->drawText((const char *)text, byteLength, x, y); |
- } else if (GrBitmapTextContext::CanDraw(paint, fContext->getMatrix())) { |
+ fMainTextContext->drawText(grPaint, paint, (const char *)text, byteLength, x, y); |
+ } else if (fFallbackTextContext && fFallbackTextContext->canDraw(paint)) { |
GrPaint grPaint; |
if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |
return; |
@@ -1798,9 +1800,7 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text, |
SkDEBUGCODE(this->validate();) |
- GrBitmapTextContext textContext(this->context(), grPaint, paint, |
- this->getDeviceProperties()); |
- textContext.drawText((const char *)text, byteLength, x, y); |
+ fFallbackTextContext->drawText(grPaint, paint, (const char *)text, byteLength, x, y); |
} else { |
// this guy will just call our drawPath() |
draw.drawText_asPaths((const char*)text, byteLength, x, y, paint); |
@@ -1813,7 +1813,7 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, |
const SkPaint& paint) { |
CHECK_SHOULD_DRAW(draw, false); |
- if (fTextContextManager->canDraw(paint, fContext->getMatrix())) { |
+ if (fMainTextContext->canDraw(paint)) { |
GrPaint grPaint; |
if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |
return; |
@@ -1821,11 +1821,9 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, |
SkDEBUGCODE(this->validate();) |
- SkAutoTDelete<GrTextContext> ctx(fTextContextManager->create(this->context(), |
- grPaint, paint, |
- this->getDeviceProperties())); |
- ctx->drawPosText((const char *)text, byteLength, pos, constY, scalarsPerPos); |
- } else if (GrBitmapTextContext::CanDraw(paint, fContext->getMatrix())) { |
+ fMainTextContext->drawPosText(grPaint, paint, (const char *)text, byteLength, pos, |
+ constY, scalarsPerPos); |
+ } else if (fFallbackTextContext && fFallbackTextContext->canDraw(paint)) { |
GrPaint grPaint; |
if (!skPaint2GrPaintShader(this, paint, true, &grPaint)) { |
return; |
@@ -1833,9 +1831,8 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, |
SkDEBUGCODE(this->validate();) |
- GrBitmapTextContext textContext(this->context(), grPaint, paint, |
- this->getDeviceProperties()); |
- textContext.drawPosText((const char *)text, byteLength, pos, constY, scalarsPerPos); |
+ fFallbackTextContext->drawPosText(grPaint, paint, (const char *)text, byteLength, pos, |
+ constY, scalarsPerPos); |
} else { |
draw.drawPosText_asPaths((const char*)text, byteLength, pos, constY, |
scalarsPerPos, paint); |