Revert "Draw perspective text as paths."
This reverts commit 76826fc91c
.
Reason for revert: Missing some characters
Original change's description:
> Draw perspective text as paths.
>
> Perspective glyphs can vary in screen size so it's unclear which SDF
> level is best, and even if we choose one for an entire subrun it's
> possible that a given glyph will have artifacts if it's too big.
> Instead we fall back to paths.
>
> Bug: skia:9515
> Change-Id: I88f03b25651df0222459f5dbd03eee9465b97487
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/247437
> Commit-Queue: Herb Derby <herb@google.com>
> Reviewed-by: Jim Van Verth <jvanverth@google.com>
TBR=jvanverth@google.com,herb@google.com
Change-Id: I5e39566c35b49323913eb72ff89ecbc91faac8ce
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:9515
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/247462
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
0a9ec07ff3
commit
d543fbbd6f
@ -181,7 +181,6 @@ SkStrikeSpec::MakeSDFT(const SkFont& font, const SkPaint& paint,
|
||||
const SkSurfaceProps& surfaceProps, const SkMatrix& deviceMatrix,
|
||||
const GrTextContext::Options& options) {
|
||||
SkStrikeSpec storage;
|
||||
SkASSERT(!deviceMatrix.hasPerspective());
|
||||
|
||||
SkPaint dfPaint = GrTextContext::InitDistanceFieldPaint(paint);
|
||||
SkFont dfFont = GrTextContext::InitDistanceFieldFont(
|
||||
|
@ -95,8 +95,24 @@ bool GrTextContext::CanDrawAsDistanceFields(const SkPaint& paint, const SkFont&
|
||||
const SkSurfaceProps& props,
|
||||
bool contextSupportsDistanceFieldText,
|
||||
const Options& options) {
|
||||
if (viewMatrix.hasPerspective()) {
|
||||
return false;
|
||||
if (!viewMatrix.hasPerspective()) {
|
||||
SkScalar maxScale = viewMatrix.getMaxScale();
|
||||
SkScalar scaledTextSize = maxScale * font.getSize();
|
||||
// Hinted text looks far better at small resolutions
|
||||
// Scaling up beyond 2x yields undesireable artifacts
|
||||
if (scaledTextSize < options.fMinDistanceFieldFontSize ||
|
||||
scaledTextSize > options.fMaxDistanceFieldFontSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool useDFT = props.isUseDeviceIndependentFonts();
|
||||
#if SK_FORCE_DISTANCE_FIELD_TEXT
|
||||
useDFT = true;
|
||||
#endif
|
||||
|
||||
if (!useDFT && scaledTextSize < kLargeDFFontSize) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// mask filters modify alpha, which doesn't translate well to distance
|
||||
@ -109,38 +125,24 @@ bool GrTextContext::CanDrawAsDistanceFields(const SkPaint& paint, const SkFont&
|
||||
return false;
|
||||
}
|
||||
|
||||
SkScalar maxScale = viewMatrix.getMaxScale();
|
||||
SkScalar scaledTextSize = maxScale * font.getSize();
|
||||
// Hinted text looks far better at small resolutions
|
||||
// Scaling up beyond 2x yields undesirable artifacts
|
||||
if (scaledTextSize < options.fMinDistanceFieldFontSize ||
|
||||
scaledTextSize > options.fMaxDistanceFieldFontSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool useDFT = props.isUseDeviceIndependentFonts();
|
||||
#if SK_FORCE_DISTANCE_FIELD_TEXT
|
||||
useDFT = true;
|
||||
#endif
|
||||
|
||||
if (!useDFT && scaledTextSize < kLargeDFFontSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SkScalar scaled_text_size(const SkScalar textSize, const SkMatrix& viewMatrix) {
|
||||
SkASSERT(!viewMatrix.hasPerspective());
|
||||
|
||||
SkScalar scaledTextSize = textSize;
|
||||
|
||||
SkScalar maxScale = viewMatrix.getMaxScale();
|
||||
// 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)) {
|
||||
scaledTextSize *= maxScale;
|
||||
if (viewMatrix.hasPerspective()) {
|
||||
// for perspective, we simply force to the medium size
|
||||
// TODO: compute a size based on approximate screen area
|
||||
scaledTextSize = kMediumDFFontLimit;
|
||||
} else {
|
||||
SkScalar maxScale = viewMatrix.getMaxScale();
|
||||
// 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)) {
|
||||
scaledTextSize *= maxScale;
|
||||
}
|
||||
}
|
||||
|
||||
return scaledTextSize;
|
||||
|
@ -678,8 +678,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsDFT, reporter, c
|
||||
SkPaint paint;
|
||||
SkFont font;
|
||||
|
||||
// A scale transform forces fallback to dft.
|
||||
SkMatrix matrix = SkMatrix::MakeScale(16);
|
||||
// A perspective transform forces fallback to dft.
|
||||
SkMatrix matrix = SkMatrix::I();
|
||||
matrix[SkMatrix::kMPersp0] = 0.5f;
|
||||
REPORTER_ASSERT(reporter, matrix.hasPerspective());
|
||||
SkSurfaceProps surfaceProps(0, kUnknown_SkPixelGeometry);
|
||||
GrTextContext::Options options;
|
||||
GrTextContext::SanitizeOptions(&options);
|
||||
|
Loading…
Reference in New Issue
Block a user