aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Chromium Automerger <chromium-automerger@android>2014-09-22 23:44:14 +0000
committerAndroid Chromium Automerger <chromium-automerger@android>2014-09-22 23:44:14 +0000
commitd9e51ff0cd92561723f86faffe36f3921fabfc44 (patch)
treef6fbcadfecb2c869a2190584070f7d99ade0aa21
parent469bb5ff51b8621c2bed0c9453d0b63e833a0a1e (diff)
parent76ce81e5e6c205dbb6344f9da51bfb7eba7bb43c (diff)
downloadskia-d9e51ff0cd92561723f86faffe36f3921fabfc44.tar.gz
Merge third_party/skia from https://chromium.googlesource.com/skia.git at 76ce81e5e6c205dbb6344f9da51bfb7eba7bb43c
This commit was generated by merge_from_chromium.py. Change-Id: Ib8f0e7f2b6432e123ae7a662bbb780bdc001939e
-rwxr-xr-xgm/dftext.cpp46
-rwxr-xr-xsrc/gpu/GrDistanceFieldTextContext.cpp25
-rw-r--r--src/gpu/GrDistanceFieldTextContext.h1
3 files changed, 50 insertions, 22 deletions
diff --git a/gm/dftext.cpp b/gm/dftext.cpp
index dccc62adb..59106f734 100755
--- a/gm/dftext.cpp
+++ b/gm/dftext.cpp
@@ -51,10 +51,13 @@ protected:
SkSurfaceProps props(SkSurfaceProps::kUseDistanceFieldFonts_Flag,
SkSurfaceProps::kLegacyFontHost_InitType);
SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, info, 0, &props));
- SkCanvas* canvas = surface->getCanvas();
+ SkCanvas* canvas = surface.get() ? surface->getCanvas() : inputCanvas;
#else
SkCanvas* canvas = inputCanvas;
#endif
+
+ // apply global scale to test glyph positioning
+ canvas->scale(1.05f, 1.05f);
canvas->clear(0xffffffff);
SkPaint paint;
@@ -97,7 +100,7 @@ protected:
// check scaling down
paint.setLCDRenderText(true);
- x = SkIntToScalar(700);
+ x = SkIntToScalar(680);
y = SkIntToScalar(20);
size_t arraySize = SK_ARRAY_COUNT(textSizes);
for (size_t i = 0; i < arraySize; ++i) {
@@ -110,6 +113,29 @@ protected:
y += paint.getFontMetrics(NULL)*scaleFactor;
}
+ // check pos text
+ {
+ SkAutoCanvasRestore acr(canvas, true);
+
+ canvas->scale(2.0f, 2.0f);
+
+ SkAutoTArray<SkPoint> pos(textLen);
+ SkAutoTArray<SkScalar> widths(textLen);
+ paint.setTextSize(textSizes[0]);
+
+ paint.getTextWidths(text, textLen, &widths[0]);
+
+ SkScalar x = SkIntToScalar(340);
+ SkScalar y = SkIntToScalar(75);
+ for (unsigned int i = 0; i < textLen; ++i) {
+ pos[i].set(x, y);
+ x += widths[i];
+ }
+
+ canvas->drawPosText(text, textLen, &pos[0], paint);
+ }
+
+
// check gamma-corrected blending
const SkColor fg[] = {
0xFFFFFFFF,
@@ -119,10 +145,10 @@ protected:
};
paint.setColor(0xFFF1F1F1);
- SkRect r = SkRect::MakeLTRB(690, 250, 840, 460);
+ SkRect r = SkRect::MakeLTRB(670, 250, 820, 460);
canvas->drawRect(r, paint);
- x = SkIntToScalar(700);
+ x = SkIntToScalar(680);
y = SkIntToScalar(270);
paint.setTextSize(SkIntToScalar(22));
for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) {
@@ -133,10 +159,10 @@ protected:
}
paint.setColor(0xFF1F1F1F);
- r = SkRect::MakeLTRB(840, 250, 990, 460);
+ r = SkRect::MakeLTRB(820, 250, 970, 460);
canvas->drawRect(r, paint);
- x = SkIntToScalar(850);
+ x = SkIntToScalar(830);
y = SkIntToScalar(270);
paint.setTextSize(SkIntToScalar(22));
for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) {
@@ -148,9 +174,11 @@ protected:
#if SK_SUPPORT_GPU
// render offscreen buffer
- SkImage* image = surface->newImageSnapshot();
- image->draw(inputCanvas, 0, 0, NULL);
- image->unref();
+ if (surface) {
+ SkImage* image = surface->newImageSnapshot();
+ image->draw(inputCanvas, 0, 0, NULL);
+ image->unref();
+ }
#endif
}
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index df07204fc..3b5bd304d 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -124,12 +124,13 @@ void GrDistanceFieldTextContext::setupCoverageEffect(const SkColor& filteredColo
GrTextureParams gammaParams(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode);
uint32_t textureUniqueID = fCurrTexture->getUniqueID();
+ const SkMatrix& ctm = fContext->getMatrix();
// set up any flags
uint32_t flags = 0;
- flags |= fTextMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
+ flags |= ctm.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0;
- flags |= fUseLCDText && fTextMatrix.rectStaysRect() ?
+ flags |= fUseLCDText && ctm.rectStaysRect() ?
kRectToRect_DistanceFieldEffectFlag : 0;
bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.fPixelGeometry);
flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0;
@@ -176,7 +177,7 @@ void GrDistanceFieldTextContext::flushGlyphs() {
GrDrawState* drawState = fDrawTarget->drawState();
GrDrawState::AutoRestoreEffects are(drawState);
- drawState->setFromPaint(fPaint, fTextMatrix, fContext->getRenderTarget());
+ drawState->setFromPaint(fPaint, fContext->getMatrix(), fContext->getRenderTarget());
if (fCurrVertex > 0) {
// setup our sampler state for our text texture/atlas
@@ -445,28 +446,28 @@ inline void GrDistanceFieldTextContext::init(const GrPaint& paint, const SkPaint
fStrike = NULL;
- fTextMatrix = fContext->getMatrix();
+ const SkMatrix& ctm = fContext->getMatrix();
// getMaxScale doesn't support perspective, so neither do we at the moment
- SkASSERT(!fTextMatrix.hasPerspective());
- SkScalar maxScale = fTextMatrix.getMaxScale();
+ SkASSERT(!ctm.hasPerspective());
+ SkScalar maxScale = ctm.getMaxScale();
SkScalar textSize = fSkPaint.getTextSize();
- // if we have non-unity scale, we need to adjust our text size accordingly
- // to avoid aliasing, and prescale the matrix by the inverse to end up with the same size
+ SkScalar scaledTextSize = textSize;
+ // if we have non-unity scale, we need to choose our base text size
+ // based on the SkPaint's text size multiplied by the max scale factor
// TODO: do we need to do this if we're scaling down (i.e. maxScale < 1)?
if (maxScale > 0 && !SkScalarNearlyEqual(maxScale, SK_Scalar1)) {
- textSize *= maxScale;
- fTextMatrix.preScale(SK_Scalar1 / maxScale, SK_Scalar1 / maxScale);
+ scaledTextSize *= maxScale;
}
fCurrVertex = 0;
fVertices = NULL;
- if (textSize <= kSmallDFFontLimit) {
+ if (scaledTextSize <= kSmallDFFontLimit) {
fTextRatio = textSize / kSmallDFFontSize;
fSkPaint.setTextSize(SkIntToScalar(kSmallDFFontSize));
- } else if (textSize <= kMediumDFFontLimit) {
+ } else if (scaledTextSize <= kMediumDFFontLimit) {
fTextRatio = textSize / kMediumDFFontSize;
fSkPaint.setTextSize(SkIntToScalar(kMediumDFFontSize));
} else {
diff --git a/src/gpu/GrDistanceFieldTextContext.h b/src/gpu/GrDistanceFieldTextContext.h
index 15ff6d9d7..75a13b385 100644
--- a/src/gpu/GrDistanceFieldTextContext.h
+++ b/src/gpu/GrDistanceFieldTextContext.h
@@ -31,7 +31,6 @@ public:
private:
GrTextStrike* fStrike;
- SkMatrix fTextMatrix;
SkScalar fTextRatio;
bool fUseLCDText;
bool fEnableDFRendering;