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

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 650273003: Change GrTextContext fallbacks to be a linked list chain. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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
« src/gpu/GrTextContext.cpp ('K') | « src/gpu/SkGpuDevice.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGpuDevice.cpp
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 6f4d1a6f99ea6b83fc5ac1ae99a78704678e8228..f0abf4463f5790001d178e2ab3d1878fa1d35839 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -147,8 +147,7 @@ SkGpuDevice::SkGpuDevice(GrSurface* surface, const SkSurfaceProps& props, unsign
this->setPixelGeometry(props.pixelGeometry());
bool useDFFonts = !!(flags & kDFFonts_Flag);
- fMainTextContext = fContext->createTextContext(fRenderTarget, this->getLeakyProperties(), useDFFonts);
- fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, this->getLeakyProperties()));
+ fTextContext = fContext->createTextContext(fRenderTarget, this->getLeakyProperties(), useDFFonts);
}
SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo,
@@ -192,8 +191,7 @@ SkGpuDevice::~SkGpuDevice() {
delete fDrawProcs;
}
- delete fMainTextContext;
- delete fFallbackTextContext;
+ delete fTextContext;
// The GrContext takes a ref on the target. We don't want to cause the render
// target to be unnecessarily kept alive.
@@ -1685,24 +1683,22 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text,
CHECK_SHOULD_DRAW(draw, false);
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext);
- if (fMainTextContext->canDraw(paint)) {
- GrPaint grPaint;
- SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
-
- SkDEBUGCODE(this->validate();)
+ GrTextContext* textContext = fTextContext;
+ do {
+ if (textContext->canDraw(paint)) {
+ GrPaint grPaint;
+ SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
- fMainTextContext->drawText(grPaint, paint, (const char *)text, byteLength, x, y);
- } else if (fFallbackTextContext && fFallbackTextContext->canDraw(paint)) {
- GrPaint grPaint;
- SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
+ SkDEBUGCODE(this->validate();)
- SkDEBUGCODE(this->validate();)
+ textContext->drawText(grPaint, paint, (const char *)text, byteLength, x, y);
+ return;
+ }
+ textContext = textContext->getFallbackTextContext();
bsalomon 2014/10/13 18:46:36 Would it make sense for this to just happen within
jvanverth1 2014/10/13 18:54:48 I thought of that, but you'd have to call canDraw(
bsalomon 2014/10/13 19:01:44 I'm not sure I see why... GrTextContext::drawTex
jvanverth1 2014/10/13 19:06:18 Got it. And GrTextContext::drawText can return fal
+ } while (textContext);
- 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);
- }
+ // this will just call our drawPath()
+ draw.drawText_asPaths((const char*)text, byteLength, x, y, paint);
}
void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteLength,
@@ -1711,25 +1707,22 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext);
CHECK_SHOULD_DRAW(draw, false);
- if (fMainTextContext->canDraw(paint)) {
- GrPaint grPaint;
- SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
-
- SkDEBUGCODE(this->validate();)
+ GrTextContext* textContext = fTextContext;
+ do {
+ if (textContext->canDraw(paint)) {
+ GrPaint grPaint;
+ SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
- fMainTextContext->drawPosText(grPaint, paint, (const char *)text, byteLength, pos,
- scalarsPerPos, offset);
- } else if (fFallbackTextContext && fFallbackTextContext->canDraw(paint)) {
- GrPaint grPaint;
- SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
+ SkDEBUGCODE(this->validate();)
- SkDEBUGCODE(this->validate();)
+ textContext->drawPosText(grPaint, paint, (const char *)text, byteLength, pos,
+ scalarsPerPos, offset);
+ return;
+ }
+ textContext = textContext->getFallbackTextContext();
+ } while (textContext);
- fFallbackTextContext->drawPosText(grPaint, paint, (const char *)text, byteLength, pos,
- scalarsPerPos, offset);
- } else {
- draw.drawPosText_asPaths((const char*)text, byteLength, pos, scalarsPerPos, offset, paint);
- }
+ draw.drawPosText_asPaths((const char*)text, byteLength, pos, scalarsPerPos, offset, paint);
}
void SkGpuDevice::drawTextOnPath(const SkDraw& draw, const void* text,
« src/gpu/GrTextContext.cpp ('K') | « src/gpu/SkGpuDevice.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698