Revert of Change drawText() to generate positions and send to drawPosText() (patchset #4 id:60001 of https://codereview.chromium.org/653133004/)
Reason for revert:
A large number of GMs on Ubuntu12 are failing. The text layout on GPU is visibly different than that for 8888.
Original issue's description:
> Change drawText() to generate positions and send to drawPosText()
>
> The idea here is to have a central place that does layout for drawText(), and
> then always feed text through drawPosText(). This both makes all of the
> GrTextContexts consistent in drawText() output, and does a better job of
> stressing drawPosText().
>
> Because of the effect of matrices on hinting and approximation error, the
> generated text is not 100% identical to that produced by the raster pipeline.
>
> BUG=skia:2778
>
> Committed: https://skia.googlesource.com/skia/+/7851a56895c9c076f73a835a7dd51d3c6180c16f
TBR=cdalton.nvidia@gmail.com,bungeman@google.com,reed@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:2778
Review URL: https://codereview.chromium.org/659993003
diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp
index 869706e..94c05a7 100644
--- a/src/gpu/GrTextContext.cpp
+++ b/src/gpu/GrTextContext.cpp
@@ -44,63 +44,16 @@
const char text[], size_t byteLength,
SkScalar x, SkScalar y) {
- SkASSERT(byteLength == 0 || text != NULL);
+ GrTextContext* textContext = this;
+ do {
+ if (textContext->canDraw(skPaint)) {
+ textContext->onDrawText(paint, skPaint, text, byteLength, x, y);
+ return true;
+ }
+ textContext = textContext->fFallbackTextContext;
+ } while (textContext);
- // nothing to draw
- if (text == NULL || byteLength == 0) {
- return true;
- }
-
- SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc();
- SkAutoGlyphCache autoCache(skPaint, &fDeviceProperties, NULL);
- SkGlyphCache* cache = autoCache.getCache();
-
- SkTArray<SkScalar> positions;
-
- const char* textPtr = text;
- SkFixed stopX = 0;
- SkFixed stopY = 0;
- SkFixed origin;
- switch (skPaint.getTextAlign()) {
- case SkPaint::kRight_Align: origin = SK_Fixed1; break;
- case SkPaint::kCenter_Align: origin = SK_FixedHalf; break;
- case SkPaint::kLeft_Align: origin = 0; break;
- default: SkFAIL("Invalid paint origin"); return false;
- }
-
- SkAutoKern autokern;
- const char* stop = text + byteLength;
- while (textPtr < stop) {
- // don't need x, y here, since all subpixel variants will have the
- // same advance
- const SkGlyph& glyph = glyphCacheProc(cache, &textPtr, 0, 0);
-
- SkFixed width = glyph.fAdvanceX + autokern.adjust(glyph);
- positions.push_back(SkFixedToScalar(stopX + SkFixedMul_portable(origin, width)));
-
- SkFixed height = glyph.fAdvanceY;
- positions.push_back(SkFixedToScalar(stopY + SkFixedMul_portable(origin, height)));
-
- stopX += width;
- stopY += height;
- }
- SkASSERT(textPtr == stop);
-
- // now adjust starting point depending on alignment
- SkScalar alignX = SkFixedToScalar(stopX);
- SkScalar alignY = SkFixedToScalar(stopY);
- if (skPaint.getTextAlign() == SkPaint::kCenter_Align) {
- alignX = SkScalarHalf(alignX);
- alignY = SkScalarHalf(alignY);
- } else if (skPaint.getTextAlign() == SkPaint::kLeft_Align) {
- alignX = 0;
- alignY = 0;
- }
- x -= alignX;
- y -= alignY;
- SkPoint offset = SkPoint::Make(x, y);
-
- return this->drawPosText(paint, skPaint, text, byteLength, positions.begin(), 2, offset);
+ return false;
}
bool GrTextContext::drawPosText(const GrPaint& paint, const SkPaint& skPaint,