Split GrTextContext into baseclass and subclass
This is a step towards enabling alternate text rendering code paths (GLyphy in particular)
Committed on behalf of baranowski@chromium.org
Review URL: http://codereview.appspot.com/5796071/
git-svn-id: http://skia.googlecode.com/svn/trunk@3412 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 9769cf4..2e82ad9 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -9,6 +9,7 @@
#include "GrContext.h"
+#include "GrDefaultTextContext.h"
#include "GrTextContext.h"
#include "SkGpuDevice.h"
@@ -184,6 +185,8 @@
pr = new SkGrRenderTargetPixelRef(fRenderTarget);
}
this->setPixelRef(pr, 0)->unref();
+
+ fTextContext = NULL;
}
SkGpuDevice::SkGpuDevice(GrContext* context, SkBitmap::Config config, int width,
@@ -245,6 +248,8 @@
width, height);
GrAssert(false);
}
+
+ fTextContext = NULL;
}
SkGpuDevice::~SkGpuDevice() {
@@ -260,6 +265,10 @@
fContext->unlockTexture(fCache);
}
fContext->unref();
+
+ if (NULL != fTextContext) {
+ fTextContext->unref();
+ }
}
///////////////////////////////////////////////////////////////////////////////
@@ -1595,8 +1604,9 @@
&grPaint)) {
return;
}
- GrTextContext context(fContext, grPaint, draw.fExtMatrix);
- myDraw.fProcs = this->initDrawForText(&context);
+ GrTextContext::AutoFinish txtCtxAF(this->getTextContext(), fContext,
+ grPaint, draw.fExtMatrix);
+ myDraw.fProcs = this->initDrawForText(txtCtxAF.getTextContext());
this->INHERITED::drawText(myDraw, text, byteLength, x, y, paint);
}
}
@@ -1624,9 +1634,9 @@
&grPaint)) {
return;
}
-
- GrTextContext context(fContext, grPaint, draw.fExtMatrix);
- myDraw.fProcs = this->initDrawForText(&context);
+ GrTextContext::AutoFinish txtCtxAF(this->getTextContext(), fContext,
+ grPaint, draw.fExtMatrix);
+ myDraw.fProcs = this->initDrawForText(txtCtxAF.getTextContext());
this->INHERITED::drawPosText(myDraw, text, byteLength, pos, constY,
scalarsPerPos, paint);
}
@@ -1742,3 +1752,9 @@
width, height, usage));
}
+GrTextContext* SkGpuDevice::getTextContext() {
+ if (NULL == fTextContext) {
+ fTextContext = new GrDefaultTextContext();
+ }
+ return fTextContext;
+}