Improve quality of distance field rendering
- Update spacing of LODs to get better results scaling up to 256 - Remove unnecessary "bolding" from dftext - Add debug colors for dftext LODs BUG=skia:2933,skia:2935 Review URL: https://codereview.chromium.org/703463002
This commit is contained in:
parent
a6ca5a002e
commit
ada68ef2dc
@ -66,3 +66,13 @@ multipicturedraw_sierpinski_tiled
|
|||||||
|
|
||||||
#joshualitt
|
#joshualitt
|
||||||
texture_domain_effect
|
texture_domain_effect
|
||||||
|
|
||||||
|
#jvanverth https://codereview.chromium.org/703463002
|
||||||
|
dftext
|
||||||
|
nested_aa
|
||||||
|
path-reverse
|
||||||
|
pathfill
|
||||||
|
polygons
|
||||||
|
pathopsinverse
|
||||||
|
rects
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ static int g_NumFreedPaths = 0;
|
|||||||
|
|
||||||
// mip levels
|
// mip levels
|
||||||
static const int kSmallMIP = 32;
|
static const int kSmallMIP = 32;
|
||||||
static const int kMediumMIP = 64;
|
static const int kMediumMIP = 78;
|
||||||
static const int kLargeMIP = 128;
|
static const int kLargeMIP = 192;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
GrAADistanceFieldPathRenderer::GrAADistanceFieldPathRenderer(GrContext* context)
|
GrAADistanceFieldPathRenderer::GrAADistanceFieldPathRenderer(GrContext* context)
|
||||||
|
@ -34,9 +34,9 @@ SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false,
|
|||||||
|
|
||||||
static const int kSmallDFFontSize = 32;
|
static const int kSmallDFFontSize = 32;
|
||||||
static const int kSmallDFFontLimit = 32;
|
static const int kSmallDFFontLimit = 32;
|
||||||
static const int kMediumDFFontSize = 64;
|
static const int kMediumDFFontSize = 78;
|
||||||
static const int kMediumDFFontLimit = 64;
|
static const int kMediumDFFontLimit = 78;
|
||||||
static const int kLargeDFFontSize = 128;
|
static const int kLargeDFFontSize = 192;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// position + texture coord
|
// position + texture coord
|
||||||
@ -153,12 +153,24 @@ inline void GrDistanceFieldTextContext::init(const GrPaint& paint, const SkPaint
|
|||||||
if (scaledTextSize <= kSmallDFFontLimit) {
|
if (scaledTextSize <= kSmallDFFontLimit) {
|
||||||
fTextRatio = textSize / kSmallDFFontSize;
|
fTextRatio = textSize / kSmallDFFontSize;
|
||||||
fSkPaint.setTextSize(SkIntToScalar(kSmallDFFontSize));
|
fSkPaint.setTextSize(SkIntToScalar(kSmallDFFontSize));
|
||||||
|
#if DEBUG_TEXT_SIZE
|
||||||
|
fSkPaint.setColor(SkColorSetARGB(0xFF, 0x00, 0x00, 0xFF));
|
||||||
|
fPaint.setColor(GrColorPackRGBA(0x00, 0x00, 0xFF, 0xFF));
|
||||||
|
#endif
|
||||||
} else if (scaledTextSize <= kMediumDFFontLimit) {
|
} else if (scaledTextSize <= kMediumDFFontLimit) {
|
||||||
fTextRatio = textSize / kMediumDFFontSize;
|
fTextRatio = textSize / kMediumDFFontSize;
|
||||||
fSkPaint.setTextSize(SkIntToScalar(kMediumDFFontSize));
|
fSkPaint.setTextSize(SkIntToScalar(kMediumDFFontSize));
|
||||||
|
#if DEBUG_TEXT_SIZE
|
||||||
|
fSkPaint.setColor(SkColorSetARGB(0xFF, 0x00, 0xFF, 0x00));
|
||||||
|
fPaint.setColor(GrColorPackRGBA(0x00, 0xFF, 0x00, 0xFF));
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
fTextRatio = textSize / kLargeDFFontSize;
|
fTextRatio = textSize / kLargeDFFontSize;
|
||||||
fSkPaint.setTextSize(SkIntToScalar(kLargeDFFontSize));
|
fSkPaint.setTextSize(SkIntToScalar(kLargeDFFontSize));
|
||||||
|
#if DEBUG_TEXT_SIZE
|
||||||
|
fSkPaint.setColor(SkColorSetARGB(0xFF, 0xFF, 0x00, 0x00));
|
||||||
|
fPaint.setColor(GrColorPackRGBA(0xFF, 0x00, 0x00, 0xFF));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
fUseLCDText = fSkPaint.isLCDRenderText();
|
fUseLCDText = fSkPaint.isLCDRenderText();
|
||||||
|
@ -16,16 +16,6 @@
|
|||||||
|
|
||||||
#include "SkDistanceFieldGen.h"
|
#include "SkDistanceFieldGen.h"
|
||||||
|
|
||||||
// To get optical sizes people don't complain about when we blit correctly,
|
|
||||||
// we need to slightly bold each glyph. On the Mac, we need a larger bold value.
|
|
||||||
#if defined(SK_BUILD_FOR_MAC)
|
|
||||||
#define SK_DistanceFieldLCDFactor "0.33"
|
|
||||||
#define SK_DistanceFieldNonLCDFactor "0.25"
|
|
||||||
#else
|
|
||||||
#define SK_DistanceFieldLCDFactor "0.05"
|
|
||||||
#define SK_DistanceFieldNonLCDFactor "0.05"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Assuming a radius of the diagonal of the fragment, hence a factor of sqrt(2)/2
|
// Assuming a radius of the diagonal of the fragment, hence a factor of sqrt(2)/2
|
||||||
#define SK_DistanceFieldAAFactor "0.7071"
|
#define SK_DistanceFieldAAFactor "0.7071"
|
||||||
|
|
||||||
@ -66,8 +56,7 @@ public:
|
|||||||
kVec2f_GrSLType);
|
kVec2f_GrSLType);
|
||||||
fsBuilder->codeAppend(";\n");
|
fsBuilder->codeAppend(";\n");
|
||||||
fsBuilder->codeAppend("\tfloat distance = "
|
fsBuilder->codeAppend("\tfloat distance = "
|
||||||
SK_DistanceFieldMultiplier "*(texColor.r - " SK_DistanceFieldThreshold ")"
|
SK_DistanceFieldMultiplier "*(texColor.r - " SK_DistanceFieldThreshold ");");
|
||||||
"+ " SK_DistanceFieldNonLCDFactor ";\n");
|
|
||||||
|
|
||||||
// we adjust for the effect of the transformation on the distance by using
|
// we adjust for the effect of the transformation on the distance by using
|
||||||
// the length of the gradient of the texture coordinates. We use st coordinates
|
// the length of the gradient of the texture coordinates. We use st coordinates
|
||||||
@ -465,8 +454,7 @@ public:
|
|||||||
fsBuilder->codeAppend("\tdistance.z = texColor.r;\n");
|
fsBuilder->codeAppend("\tdistance.z = texColor.r;\n");
|
||||||
|
|
||||||
fsBuilder->codeAppend("\tdistance = "
|
fsBuilder->codeAppend("\tdistance = "
|
||||||
"vec3(" SK_DistanceFieldMultiplier ")*(distance - vec3(" SK_DistanceFieldThreshold"))"
|
"vec3(" SK_DistanceFieldMultiplier ")*(distance - vec3(" SK_DistanceFieldThreshold"));");
|
||||||
"+ vec3(" SK_DistanceFieldLCDFactor ");\n");
|
|
||||||
|
|
||||||
// we adjust for the effect of the transformation on the distance by using
|
// we adjust for the effect of the transformation on the distance by using
|
||||||
// the length of the gradient of the texture coordinates. We use st coordinates
|
// the length of the gradient of the texture coordinates. We use st coordinates
|
||||||
|
Loading…
Reference in New Issue
Block a user