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

Unified Diff: src/gpu/GrAtlasTextContext.cpp

Issue 1485973004: Reduce use of GrRenderTarget in GrTextContexts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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/GrAtlasTextContext.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAtlasTextContext.cpp
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
index 163601e836358bc482e97c1f4f9750e531450cf2..c72080529aac97784a19128f79128e0d2aaed942 100644
--- a/src/gpu/GrAtlasTextContext.cpp
+++ b/src/gpu/GrAtlasTextContext.cpp
@@ -149,11 +149,7 @@ GrAtlasTextContext* GrAtlasTextContext::Create(GrContext* context,
return new GrAtlasTextContext(context, surfaceProps);
}
-bool GrAtlasTextContext::canDraw(const GrRenderTarget*,
- const GrClip&,
- const GrPaint&,
- const SkPaint& skPaint,
- const SkMatrix& viewMatrix) {
+bool GrAtlasTextContext::canDraw(const SkPaint& skPaint, const SkMatrix& viewMatrix) {
return this->canDrawAsDistanceFields(skPaint, viewMatrix) ||
!SkDraw::ShouldDrawTextAsPaths(skPaint, viewMatrix);
}
@@ -521,7 +517,7 @@ void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob,
}
}
if (fallbackTxt.count()) {
- this->fallbackDrawPosText(cacheBlob, run, rt, clip, color, runPaint, viewMatrix,
+ this->fallbackDrawPosText(cacheBlob, run, clip, color, runPaint, viewMatrix,
fallbackTxt, fallbackPos, scalarsPerPosition, dfOffset,
clipRect);
}
@@ -614,7 +610,7 @@ inline void GrAtlasTextContext::initDistanceFieldPaint(GrAtlasTextBlob* blob,
inline void GrAtlasTextContext::fallbackDrawPosText(GrAtlasTextBlob* blob,
int runIndex,
- GrRenderTarget* rt, const GrClip& clip,
+ const GrClip& clip,
GrColor color,
const SkPaint& skPaint,
const SkMatrix& viewMatrix,
@@ -657,14 +653,14 @@ GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint,
}
inline GrAtlasTextBlob*
-GrAtlasTextContext::createDrawTextBlob(GrRenderTarget* rt, const GrClip& clip,
+GrAtlasTextContext::createDrawTextBlob(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) {
int glyphCount = skPaint.countText(text, byteLength);
SkIRect clipRect;
- clip.getConservativeBounds(rt->width(), rt->height(), &clipRect);
+ clip.getConservativeBounds(dc->width(), dc->height(), &clipRect);
GrAtlasTextBlob* blob;
if (this->canDrawAsDistanceFields(skPaint, viewMatrix)) {
@@ -679,7 +675,7 @@ GrAtlasTextContext::createDrawTextBlob(GrRenderTarget* rt, const GrClip& clip,
byteLength, x, y, clipRect, textRatio, &fallbackTxt, &fallbackPos,
&offset, skPaint);
if (fallbackTxt.count()) {
- this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPaint, viewMatrix,
+ this->fallbackDrawPosText(blob, 0, clip, paint.getColor(), skPaint, viewMatrix,
fallbackTxt, fallbackPos, 2, offset, clipRect);
}
} else {
@@ -695,7 +691,7 @@ GrAtlasTextContext::createDrawTextBlob(GrRenderTarget* rt, const GrClip& clip,
}
inline GrAtlasTextBlob*
-GrAtlasTextContext::createDrawPosTextBlob(GrRenderTarget* rt, const GrClip& clip,
+GrAtlasTextContext::createDrawPosTextBlob(GrDrawContext* dc, const GrClip& clip,
const GrPaint& paint, const SkPaint& skPaint,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
@@ -704,7 +700,7 @@ GrAtlasTextContext::createDrawPosTextBlob(GrRenderTarget* rt, const GrClip& clip
int glyphCount = skPaint.countText(text, byteLength);
SkIRect clipRect;
- clip.getConservativeBounds(rt->width(), rt->height(), &clipRect);
+ clip.getConservativeBounds(dc->width(), dc->height(), &clipRect);
GrAtlasTextBlob* blob;
if (this->canDrawAsDistanceFields(skPaint, viewMatrix)) {
@@ -718,7 +714,7 @@ GrAtlasTextContext::createDrawPosTextBlob(GrRenderTarget* rt, const GrClip& clip
byteLength, pos, scalarsPerPosition, offset, clipRect,
textRatio, &fallbackTxt, &fallbackPos);
if (fallbackTxt.count()) {
- this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPaint, viewMatrix,
+ this->fallbackDrawPosText(blob, 0, clip, paint.getColor(), skPaint, viewMatrix,
fallbackTxt, fallbackPos, scalarsPerPosition, offset,
clipRect);
}
@@ -740,7 +736,7 @@ void GrAtlasTextContext::onDrawText(GrDrawContext* dc, GrRenderTarget* rt,
const char text[], size_t byteLength,
SkScalar x, SkScalar y, const SkIRect& regionClipBounds) {
SkAutoTUnref<GrAtlasTextBlob> blob(
- this->createDrawTextBlob(rt, clip, paint, skPaint, viewMatrix,
+ this->createDrawTextBlob(dc, clip, paint, skPaint, viewMatrix,
text, byteLength, x, y, regionClipBounds));
this->flush(blob, dc, rt, skPaint, paint, clip, regionClipBounds);
}
@@ -753,7 +749,7 @@ void GrAtlasTextContext::onDrawPosText(GrDrawContext* dc, GrRenderTarget* rt,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& regionClipBounds) {
SkAutoTUnref<GrAtlasTextBlob> blob(
- this->createDrawPosTextBlob(rt, clip, paint, skPaint, viewMatrix,
+ this->createDrawPosTextBlob(dc, clip, paint, skPaint, viewMatrix,
text, byteLength,
pos, scalarsPerPosition,
offset, regionClipBounds));
@@ -1416,6 +1412,8 @@ DRAW_BATCH_TEST_DEFINE(TextBlobBatch) {
SkASSERT(nullptr != texture->asRenderTarget());
GrRenderTarget* rt = texture->asRenderTarget();
+ SkAutoTUnref<GrDrawContext> dc(context->drawContext(rt));
+
// Setup dummy SkPaint / GrPaint
GrColor color = GrRandomColor(random);
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
@@ -1440,7 +1438,7 @@ DRAW_BATCH_TEST_DEFINE(TextBlobBatch) {
// right now we don't handle textblobs, nor do we handle drawPosText. Since we only
// intend to test the batch with this unit test, that is okay.
SkAutoTUnref<GrAtlasTextBlob> blob(
- gTextContext->createDrawTextBlob(rt, clip, grPaint, skPaint, viewMatrix, text,
+ gTextContext->createDrawTextBlob(dc, clip, grPaint, skPaint, viewMatrix, text,
static_cast<size_t>(textLen), 0, 0, noClip));
SkScalar transX = static_cast<SkScalar>(random->nextU());
« no previous file with comments | « src/gpu/GrAtlasTextContext.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698