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

Unified Diff: src/gpu/GrBitmapTextContext.cpp

Issue 150743002: Replace factory generation of TextContexts with persistent objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: And an if statement Created 6 years, 11 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/GrBitmapTextContext.h ('k') | src/gpu/GrDistanceFieldTextContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrBitmapTextContext.cpp
diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp
index 488aa137e9a14f5c72033df5d74dedcea9d639ae..c7beb14e4204d58f3e01f74908a9edc3a047bc39 100755
--- a/src/gpu/GrBitmapTextContext.cpp
+++ b/src/gpu/GrBitmapTextContext.cpp
@@ -29,15 +29,9 @@ static const int kGlyphCoordsAttributeIndex = 1;
SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false,
"Dump the contents of the font cache before every purge.");
-bool GrBitmapTextContext::CanDraw(const SkPaint& paint, const SkMatrix& ctm) {
- return !SkDraw::ShouldDrawTextAsPaths(paint, ctm);
-}
-
GrBitmapTextContext::GrBitmapTextContext(GrContext* context,
- const GrPaint& grPaint,
- const SkPaint& skPaint,
const SkDeviceProperties& properties)
- : GrTextContext(context, grPaint, skPaint, properties) {
+ : GrTextContext(context, properties) {
fStrike = NULL;
fCurrTexture = NULL;
@@ -51,6 +45,10 @@ GrBitmapTextContext::~GrBitmapTextContext() {
this->flushGlyphs();
}
+bool GrBitmapTextContext::canDraw(const SkPaint& paint) {
+ return !SkDraw::ShouldDrawTextAsPaths(paint, fContext->getMatrix());
+}
+
static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) {
unsigned r = SkColorGetR(c);
unsigned g = SkColorGetG(c);
@@ -117,7 +115,26 @@ void GrBitmapTextContext::flushGlyphs() {
}
}
-void GrBitmapTextContext::drawText(const char text[], size_t byteLength,
+inline void GrBitmapTextContext::init(const GrPaint& paint, const SkPaint& skPaint) {
+ GrTextContext::init(paint, skPaint);
+
+ fStrike = NULL;
+
+ fCurrTexture = NULL;
+ fCurrVertex = 0;
+
+ fVertices = NULL;
+ fMaxVertices = 0;
+}
+
+inline void GrBitmapTextContext::finish() {
+ flushGlyphs();
+
+ GrTextContext::finish();
+}
+
+void GrBitmapTextContext::drawText(const GrPaint& paint, const SkPaint& skPaint,
+ const char text[], size_t byteLength,
SkScalar x, SkScalar y) {
SkASSERT(byteLength == 0 || text != NULL);
@@ -126,6 +143,8 @@ void GrBitmapTextContext::drawText(const char text[], size_t byteLength,
return;
}
+ this->init(paint, skPaint);
+
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &fContext->getMatrix());
@@ -201,6 +220,8 @@ void GrBitmapTextContext::drawText(const char text[], size_t byteLength,
fx += glyph.fAdvanceX;
fy += glyph.fAdvanceY;
}
+
+ this->finish();
}
///////////////////////////////////////////////////////////////////////////////
@@ -295,7 +316,8 @@ BitmapTextMapState::Proc BitmapTextMapState::pickProc(int scalarsPerPosition) {
///////////////////////////////////////////////////////////////////////////////
-void GrBitmapTextContext::drawPosText(const char text[], size_t byteLength,
+void GrBitmapTextContext::drawPosText(const GrPaint& paint, const SkPaint& skPaint,
+ const char text[], size_t byteLength,
const SkScalar pos[], SkScalar constY,
int scalarsPerPosition) {
SkASSERT(byteLength == 0 || text != NULL);
@@ -306,6 +328,8 @@ void GrBitmapTextContext::drawPosText(const char text[], size_t byteLength,
return;
}
+ this->init(paint, skPaint);
+
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, &fContext->getMatrix());
@@ -439,6 +463,8 @@ void GrBitmapTextContext::drawPosText(const char text[], size_t byteLength,
}
}
}
+
+ this->finish();
}
namespace {
« no previous file with comments | « src/gpu/GrBitmapTextContext.h ('k') | src/gpu/GrDistanceFieldTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698