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

Unified Diff: src/gpu/text/GrAtlasTextContext.cpp

Issue 1684733005: Start whittling down GrTextContext (Closed) Base URL: https://skia.googlesource.com/skia.git@tc-cleanup-2
Patch Set: feedback inc Created 4 years, 10 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/text/GrAtlasTextContext.h ('k') | src/gpu/text/GrStencilAndCoverTextContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/text/GrAtlasTextContext.cpp
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 9e30476248c47fbdefc553a7fac36f97b869ab72..5e346452bd0c93bb87d671c1126834d63e659dc5 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -42,7 +42,6 @@ GrAtlasTextContext::GrAtlasTextContext(GrContext* context, const SkSurfaceProps&
static_assert(GrAtlasTextBlob::kGrayTextVASize >= GrAtlasTextBlob::kColorTextVASize &&
GrAtlasTextBlob::kGrayTextVASize >= GrAtlasTextBlob::kLCDTextVASize,
"vertex_attribute_changed");
- fCurrStrike = nullptr;
fCache = context->getTextBlobCache();
}
@@ -314,33 +313,50 @@ GrAtlasTextContext::createDrawPosTextBlob(const GrPaint& paint, const SkPaint& s
return blob;
}
-void GrAtlasTextContext::onDrawText(GrDrawContext* dc,
- const GrClip& clip,
- const GrPaint& paint, const SkPaint& skPaint,
- const SkMatrix& viewMatrix,
- const char text[], size_t byteLength,
- SkScalar x, SkScalar y, const SkIRect& regionClipBounds) {
- SkAutoTUnref<GrAtlasTextBlob> blob(
- this->createDrawTextBlob(paint, skPaint, viewMatrix, text, byteLength, x, y));
- blob->flushThrowaway(fContext, dc, fSurfaceProps, fDistanceAdjustTable, skPaint, paint,
- clip, regionClipBounds);
+void GrAtlasTextContext::drawText(GrDrawContext* dc,
+ const GrClip& clip,
+ const GrPaint& paint, const SkPaint& skPaint,
+ const SkMatrix& viewMatrix,
+ const char text[], size_t byteLength,
+ SkScalar x, SkScalar y, const SkIRect& regionClipBounds) {
+ if (fContext->abandoned()) {
+ return;
+ } else if (this->canDraw(skPaint, viewMatrix)) {
+ SkAutoTUnref<GrAtlasTextBlob> blob(
+ this->createDrawTextBlob(paint, skPaint, viewMatrix, text, byteLength, x, y));
+ blob->flushThrowaway(fContext, dc, fSurfaceProps, fDistanceAdjustTable, skPaint, paint,
+ clip, regionClipBounds);
+ return;
+ }
+
+ // fall back to drawing as a path
+ GrTextUtils::DrawTextAsPath(fContext, dc, clip, skPaint, viewMatrix, text, byteLength, x, y,
+ regionClipBounds);
}
-void GrAtlasTextContext::onDrawPosText(GrDrawContext* dc,
- const GrClip& clip,
- const GrPaint& paint, const SkPaint& skPaint,
- const SkMatrix& viewMatrix,
- const char text[], size_t byteLength,
- const SkScalar pos[], int scalarsPerPosition,
- const SkPoint& offset, const SkIRect& regionClipBounds) {
- SkAutoTUnref<GrAtlasTextBlob> blob(
- this->createDrawPosTextBlob(paint, skPaint, viewMatrix,
- text, byteLength,
- pos, scalarsPerPosition,
- offset));
+void GrAtlasTextContext::drawPosText(GrDrawContext* dc,
+ const GrClip& clip,
+ const GrPaint& paint, const SkPaint& skPaint,
+ const SkMatrix& viewMatrix,
+ const char text[], size_t byteLength,
+ const SkScalar pos[], int scalarsPerPosition,
+ const SkPoint& offset, const SkIRect& regionClipBounds) {
+ if (fContext->abandoned()) {
+ return;
+ } else if (this->canDraw(skPaint, viewMatrix)) {
+ SkAutoTUnref<GrAtlasTextBlob> blob(
+ this->createDrawPosTextBlob(paint, skPaint, viewMatrix,
+ text, byteLength,
+ pos, scalarsPerPosition,
+ offset));
+ blob->flushThrowaway(fContext, dc, fSurfaceProps, fDistanceAdjustTable, skPaint, paint,
+ clip, regionClipBounds);
+ return;
+ }
- blob->flushThrowaway(fContext, dc, fSurfaceProps, fDistanceAdjustTable, skPaint, paint, clip,
- regionClipBounds);
+ // fall back to drawing as a path
+ GrTextUtils::DrawPosTextAsPath(fContext, dc, fSurfaceProps, clip, skPaint, viewMatrix, text,
+ byteLength, pos, scalarsPerPosition, offset, regionClipBounds);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/gpu/text/GrAtlasTextContext.h ('k') | src/gpu/text/GrStencilAndCoverTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698