Revert of Make GrTextContext be owned by the GrDrawContext (patchset #7 id:120001 of https://codereview.chromium.org/1175553002/)
Reason for revert:
Breaking Test-Win8-MSVC-ShuttleA-GPU-GTX660-x86_64-Debug ?
https://build.chromium.org/p/client.skia/builders/Test-Win8-MSVC-ShuttleA-GPU-GTX660-x86_64-Debug/builds/436/steps/dm/logs/stdio
Original issue's description:
> Make GrTextContext be owned by the GrDrawContext
>
> This CL makes the GrTextContext be owned (and hidden) by the GrDrawContext. This funnels all the drawText* calls through the GrDrawContext and hides the (dispreferred) GrPipelineBuilder drawText variant.
>
> Some consequences of this are:
>
> GrDrawContext now has to get the text drawing settings (i.e., SkDeviceProperties & useDFT). This means that we need a separate GrDrawContext for each combination of pixel geometry and DFT-use.
>
> All the GrTextContext-derived classes now get a back pointer to the originating GrDrawContext so their method calls no longer take one.
>
> Committed: https://skia.googlesource.com/skia/+/5b16e740fe6ab6d679083d06f07651602265081b
TBR=joshualitt@chromium.org,joshualitt@google.com,jvanverth@google.com,reed@google.com,robertphillips@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1178383003
diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp
index 5559b2d..91c8e85 100644
--- a/src/gpu/GrTextContext.cpp
+++ b/src/gpu/GrTextContext.cpp
@@ -20,12 +20,10 @@
#include "SkTextMapStateProc.h"
#include "SkTextToPathIter.h"
-GrTextContext::GrTextContext(GrContext* context, GrDrawContext* drawContext,
- const SkDeviceProperties& properties)
+GrTextContext::GrTextContext(GrContext* context, const SkDeviceProperties& properties)
: fFallbackTextContext(NULL)
, fContext(context)
- , fDeviceProperties(properties)
- , fDrawContext(drawContext) {
+ , fDeviceProperties(properties) {
}
GrTextContext::~GrTextContext() {
@@ -49,14 +47,19 @@
const SkPaint& skPaint, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
SkScalar x, SkScalar y, const SkIRect& clipBounds) {
- if (fContext->abandoned() || !fDrawContext) {
+ if (fContext->abandoned()) {
+ return;
+ }
+
+ GrDrawContext* drawContext = fContext->drawContext();
+ if (!drawContext) {
return;
}
GrTextContext* textContext = this;
do {
if (textContext->canDraw(rt, clip, paint, skPaint, viewMatrix)) {
- textContext->onDrawText(rt, clip, paint, skPaint, viewMatrix,
+ textContext->onDrawText(drawContext, rt, clip, paint, skPaint, viewMatrix,
text, byteLength, x, y, clipBounds);
return;
}
@@ -64,7 +67,7 @@
} while (textContext);
// fall back to drawing as a path
- this->drawTextAsPath(rt, clip, skPaint, viewMatrix,
+ this->drawTextAsPath(drawContext, rt, clip, skPaint, viewMatrix,
text, byteLength, x, y, clipBounds);
}
@@ -73,14 +76,19 @@
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkIRect& clipBounds) {
- if (fContext->abandoned() || !fDrawContext) {
+ if (fContext->abandoned()) {
+ return;
+ }
+
+ GrDrawContext* drawContext = fContext->drawContext();
+ if (!drawContext) {
return;
}
GrTextContext* textContext = this;
do {
if (textContext->canDraw(rt, clip, paint, skPaint, viewMatrix)) {
- textContext->onDrawPosText(rt, clip, paint, skPaint, viewMatrix,
+ textContext->onDrawPosText(drawContext, rt, clip, paint, skPaint, viewMatrix,
text, byteLength, pos,
scalarsPerPosition, offset, clipBounds);
return;
@@ -89,7 +97,7 @@
} while (textContext);
// fall back to drawing as a path
- this->drawPosTextAsPath(rt, clip, skPaint, viewMatrix, text, byteLength, pos,
+ this->drawPosTextAsPath(drawContext, rt, clip, skPaint, viewMatrix, text, byteLength, pos,
scalarsPerPosition, offset, clipBounds);
}
@@ -175,7 +183,7 @@
}
}
-void GrTextContext::drawTextAsPath(GrRenderTarget* rt,
+void GrTextContext::drawTextAsPath(GrDrawContext* drawContext, GrRenderTarget* rt,
const GrClip& clip,
const SkPaint& skPaint, const SkMatrix& viewMatrix,
const char text[], size_t byteLength, SkScalar x, SkScalar y,
@@ -193,14 +201,14 @@
matrix.postTranslate(xpos - prevXPos, 0);
if (iterPath) {
const SkPaint& pnt = iter.getPaint();
- GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, rt, clip, *iterPath,
+ GrBlurUtils::drawPathWithMaskFilter(fContext, drawContext, rt, clip, *iterPath,
pnt, viewMatrix, &matrix, clipBounds, false);
}
prevXPos = xpos;
}
}
-void GrTextContext::drawPosTextAsPath(GrRenderTarget* rt,
+void GrTextContext::drawPosTextAsPath(GrDrawContext* drawContext, GrRenderTarget* rt,
const GrClip& clip,
const SkPaint& origPaint, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
@@ -241,7 +249,7 @@
matrix[SkMatrix::kMTransX] = loc.fX;
matrix[SkMatrix::kMTransY] = loc.fY;
- GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext, rt, clip, *path, paint,
+ GrBlurUtils::drawPathWithMaskFilter(fContext, drawContext, rt, clip, *path, paint,
viewMatrix, &matrix, clipBounds, false);
}
}