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

Unified Diff: src/gpu/GrDistanceFieldTextContext.cpp

Issue 783763002: Initial CL to move color / coverage off of drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@no-static-gp
Patch Set: nvpr bug fixed Created 6 years 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
Index: src/gpu/GrDistanceFieldTextContext.cpp
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index e5374f2a45abcb0742c0a2c8942ee643a21bce34..d8f10f1c846ab36db47e56188586d649b5e1743b 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -405,7 +405,15 @@ void GrDistanceFieldTextContext::setupCoverageEffect(const SkColor& filteredColo
flags != fEffectFlags) {
if (fUseLCDText) {
GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor);
- fCachedGeometryProcessor.reset(GrDistanceFieldLCDTextureEffect::Create(fCurrTexture,
+
+ // We don't use the GrPaint's color in this case because it's been premultiplied by
+ // alpha. Instead we feed in a non-premultiplied color, and multiply its alpha by
+ // the mask texture color. The end result is that we get
+ // mask*paintAlpha*paintColor + (1-mask*paintAlpha)*dstColor
+ int a = GrColorUnpackA(fSkPaint.getColor());
+ GrColor color = GrColorPackRGBA(a, a, a, a);
+ fCachedGeometryProcessor.reset(GrDistanceFieldLCDTextureEffect::Create(color,
+ fCurrTexture,
params,
fGammaTexture,
gammaParams,
@@ -413,18 +421,22 @@ void GrDistanceFieldTextContext::setupCoverageEffect(const SkColor& filteredColo
flags));
} else {
flags |= kColorAttr_DistanceFieldEffectFlag;
+ GrColor color = fSkPaint.getColor();
#ifdef SK_GAMMA_APPLY_TO_A8
U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDeviceProperties.gamma(),
filteredColor);
- fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create(fCurrTexture,
+ fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create(color,
+ fCurrTexture,
params,
fGammaTexture,
gammaParams,
lum/255.f,
flags));
#else
- fCachedGeometryProcessor.reset(GrDistanceFieldNoGammaTextureEffect::Create(fCurrTexture,
- params, flags));
+ fCachedGeometryProcessor.reset(GrDistanceFieldNoGammaTextureEffect::Create(color,
+ fCurrTexture,
+ params,
+ flags));
#endif
}
fEffectTextureUniqueID = textureUniqueID;
@@ -642,13 +654,6 @@ void GrDistanceFieldTextContext::flush() {
SkDebugf("LCD Text will not draw correctly.\n");
}
SkASSERT(!drawState.hasColorVertexAttribute());
- // We don't use the GrPaint's color in this case because it's been premultiplied by
- // alpha. Instead we feed in a non-premultiplied color, and multiply its alpha by
- // the mask texture color. The end result is that we get
- // mask*paintAlpha*paintColor + (1-mask*paintAlpha)*dstColor
- int a = SkColorGetA(fSkPaint.getColor());
- // paintAlpha
- drawState.setColor(SkColorSetARGB(a, a, a, a));
// paintColor
drawState.setBlendConstant(colorNoPreMul);
drawState.setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff);

Powered by Google App Engine
This is Rietveld 408576698