call through to the device from SkDraw

BUG=
R=robertphillips@google.com

Review URL: https://codereview.chromium.org/16378003

git-svn-id: http://skia.googlecode.com/svn/trunk@9449 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2013-06-05 18:00:30 +00:00
parent 4609b9ca9d
commit 5a64902ee9
3 changed files with 63 additions and 11 deletions

53
gm/bigtext.cpp Normal file
View File

@ -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); )

View File

@ -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',

View File

@ -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;