diff --git a/gm/bigtext.cpp b/gm/bigtext.cpp new file mode 100644 index 000000000..e8bddf80c --- /dev/null +++ b/gm/bigtext.cpp @@ -0,0 +1,53 @@ +/* + * Copyright 2013 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "gm.h" +#include "SkCanvas.h" +#include "SkPath.h" + +/** + * Skia may draw from outlines when the size is very large, so we exercise that + * here. +*/ + +class BigTextGM : public skiagm::GM { +public: + BigTextGM() {} + +protected: + virtual SkString onShortName() SK_OVERRIDE { + return SkString("bigtext"); + } + + virtual SkISize onISize() SK_OVERRIDE { + return SkISize::Make(640, 480); + } + + virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { + SkPaint paint; + paint.setAntiAlias(true); + paint.setTextSize(1500); + + SkRect r; + (void)paint.measureText("/", 1, &r); + SkPoint pos = { + this->width()/2 - r.centerX(), + this->height()/2 - r.centerY() + }; + + paint.setColor(SK_ColorRED); + canvas->drawText("/", 1, pos.fX, pos.fY, paint); + + paint.setColor(SK_ColorBLUE); + canvas->drawPosText("\\", 1, &pos, paint); + } + +private: + typedef skiagm::GM INHERITED; +}; + +DEF_GM( return SkNEW(BigTextGM); ) diff --git a/gyp/gmslides.gypi b/gyp/gmslides.gypi index c67c2d1da..632a2757c 100644 --- a/gyp/gmslides.gypi +++ b/gyp/gmslides.gypi @@ -7,6 +7,7 @@ '../gm/arithmode.cpp', '../gm/bicubicfilter.cpp', '../gm/bigmatrix.cpp', + '../gm/bigtext.cpp', '../gm/bitmapcopy.cpp', '../gm/bitmapmatrix.cpp', '../gm/bitmapfilters.cpp', diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 5782fc537..30d5956ae 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -1861,12 +1861,8 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength, SkPaint paint(origPaint); SkScalar matrixScale = paint.setupForAsPaths(); - SkDraw draw(*this); - - // Now modify our matrix to account for the canonical text size - SkMatrix matrix = *fMatrix; - matrix.preScale(matrixScale, matrixScale); - const SkScalar posScale = SkScalarInvert(matrixScale); + SkMatrix matrix; + matrix.setScale(matrixScale, matrixScale); SkDrawCacheProc glyphCacheProc = paint.getDrawCacheProc(); SkAutoGlyphCache autoCache(paint, NULL, NULL); @@ -1886,11 +1882,13 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength, SkIPoint fixedLoc; alignProc(tms.fLoc, glyph, &fixedLoc); - SkMatrix localMatrix = matrix; - localMatrix.preTranslate(SkFixedToScalar(fixedLoc.fX) * posScale, - SkFixedToScalar(fixedLoc.fY) * posScale); - draw.fMatrix = &localMatrix; - draw.drawPath(*path, paint); + matrix[SkMatrix::kMTransX] = SkFixedToScalar(fixedLoc.fX); + matrix[SkMatrix::kMTransY] = SkFixedToScalar(fixedLoc.fY); + if (fDevice) { + fDevice->drawPath(*this, *path, paint, &matrix, false); + } else { + this->drawPath(*path, paint, &matrix, false); + } } } pos += scalarsPerPosition;