Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Unified Diff: src/gpu/GrDistanceFieldTextContext.cpp

Issue 219243012: Add LCD support for distance field text (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase to master Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.h ('k') | src/gpu/effects/GrDistanceFieldTextureEffect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDistanceFieldTextContext.cpp
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index 71e5d0f16c7b5294252c70825b52e74d578cfa43..cd3922c4131a03adba4d0ec39e2699b13cbc1e02 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -84,13 +84,18 @@ void GrDistanceFieldTextContext::flushGlyphs() {
SkASSERT(fCurrTexture);
GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_FilterMode);
- // This effect could be stored with one of the cache objects (atlas?)
- drawState->addCoverageEffect(
- GrDistanceFieldTextureEffect::Create(fCurrTexture, params,
- fContext->getMatrix().isSimilarity()),
- kGlyphCoordsAttributeIndex)->unref();
+ // Effects could be stored with one of the cache objects (atlas?)
+ if (fUseLCDText) {
+ bool useBGR = SkDeviceProperties::Geometry::kBGR_Layout ==
+ fDeviceProperties.fGeometry.getLayout();
+ drawState->addCoverageEffect(GrDistanceFieldLCDTextureEffect::Create(
+ fCurrTexture,
+ params,
+ fContext->getMatrix().rectStaysRect() &&
+ fContext->getMatrix().isSimilarity(),
+ useBGR),
+ kGlyphCoordsAttributeIndex)->unref();
- if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) {
if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() ||
kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() ||
fPaint.numColorStages()) {
@@ -107,6 +112,10 @@ void GrDistanceFieldTextContext::flushGlyphs() {
drawState->setBlendConstant(skcolor_to_grcolor_nopremultiply(fSkPaint.getColor()));
drawState->setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff);
} else {
+ drawState->addCoverageEffect(GrDistanceFieldTextureEffect::Create(fCurrTexture, params,
+ fContext->getMatrix().isSimilarity()),
+ kGlyphCoordsAttributeIndex)->unref();
+
// set back to normal in case we took LCD path previously.
drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstBlendCoeff());
drawState->setColor(fPaint.getColor());
@@ -318,6 +327,8 @@ inline void GrDistanceFieldTextContext::init(const GrPaint& paint, const SkPaint
fSkPaint.setTextSize(SkIntToScalar(kLargeDFFontSize));
}
+ fUseLCDText = fSkPaint.isLCDRenderText();
+
fSkPaint.setLCDRenderText(false);
fSkPaint.setAutohinted(false);
fSkPaint.setSubpixelText(true);
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.h ('k') | src/gpu/effects/GrDistanceFieldTextureEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698