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

Unified Diff: src/gpu/effects/GrDistanceFieldTextureEffect.cpp

Issue 424173002: Revert of Add effect caching to distance field text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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/effects/GrDistanceFieldTextureEffect.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrDistanceFieldTextureEffect.cpp
diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
index 675715781c5d65808b6d41a6bdadb6a079fa25ca..0c0c1afc769ac15f2355e85c46deb83427b19c20 100755
--- a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
+++ b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
@@ -79,7 +79,7 @@
builder->fsCodeAppendf("\tvec2 uv = %s;\n", fsCoordName.c_str());
builder->fsCodeAppendf("\tvec2 st = uv*%s;\n", textureSizeUniName);
builder->fsCodeAppend("\tfloat afwidth;\n");
- if (dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag) {
+ if (dfTexEffect.isSimilarity()) {
// this gives us a smooth step across approximately one fragment
builder->fsCodeAppend("\tafwidth = " SK_DistanceFieldAAFactor "*dFdx(st.x);\n");
} else {
@@ -153,7 +153,7 @@
const GrDistanceFieldTextureEffect& dfTexEffect =
drawEffect.castEffect<GrDistanceFieldTextureEffect>();
- b->add32(dfTexEffect.getFlags());
+ b->add32(dfTexEffect.isSimilarity());
}
private:
@@ -174,14 +174,13 @@
const GrTextureParams& gammaParams,
float luminance,
#endif
- uint32_t flags)
+ bool similarity)
: fTextureAccess(texture, params)
#ifdef SK_GAMMA_APPLY_TO_A8
, fGammaTextureAccess(gamma, gammaParams)
, fLuminance(luminance)
#endif
- , fFlags(flags & kNonLCD_DistanceFieldEffectMask) {
- SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask));
+ , fIsSimilarity(similarity) {
this->addTextureAccess(&fTextureAccess);
#ifdef SK_GAMMA_APPLY_TO_A8
this->addTextureAccess(&fGammaTextureAccess);
@@ -191,10 +190,7 @@
bool GrDistanceFieldTextureEffect::onIsEqual(const GrEffect& other) const {
const GrDistanceFieldTextureEffect& cte = CastEffect<GrDistanceFieldTextureEffect>(other);
- return fTextureAccess == cte.fTextureAccess &&
- fGammaTextureAccess == cte.fGammaTextureAccess &&
- fLuminance == cte.fLuminance &&
- fFlags == cte.fFlags;
+ return fTextureAccess == cte.fTextureAccess;
}
void GrDistanceFieldTextureEffect::getConstantColorComponents(GrColor* color,
@@ -246,8 +242,7 @@
textures[texIdx2], params2,
random->nextF(),
#endif
- random->nextBool() ?
- kSimilarity_DistanceFieldEffectFlag : 0);
+ random->nextBool());
}
///////////////////////////////////////////////////////////////////////////////
@@ -291,8 +286,7 @@
// create LCD offset adjusted by inverse of transform
builder->fsCodeAppendf("\tvec2 uv = %s;\n", fsCoordName.c_str());
builder->fsCodeAppendf("\tvec2 st = uv*%s.xy;\n", textureSizeUniName);
- bool isUniformScale = !!(dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask);
- if (isUniformScale) {
+ if (dfTexEffect.isUniformScale()) {
builder->fsCodeAppend("\tfloat dx = dFdx(st.x);\n");
builder->fsCodeAppendf("\tvec2 offset = vec2(dx*%s.z, 0.0);\n", textureSizeUniName);
} else {
@@ -333,7 +327,7 @@
// transformations, and even then using a single factor seems like a reasonable
// trade-off between quality and speed.
builder->fsCodeAppend("\tfloat afwidth;\n");
- if (isUniformScale) {
+ if (dfTexEffect.isUniformScale()) {
// this gives us a smooth step across approximately one fragment
builder->fsCodeAppend("\tafwidth = " SK_DistanceFieldAAFactor "*dx;\n");
} else {
@@ -399,7 +393,7 @@
texture->height() != fTextureSize.height()) {
fTextureSize = SkISize::Make(texture->width(), texture->height());
float delta = 1.0f/(3.0f*texture->width());
- if (dfTexEffect.getFlags() & kBGR_DistanceFieldEffectFlag) {
+ if (dfTexEffect.useBGR()) {
delta = -delta;
}
uman.set3f(fTextureSizeUni,
@@ -424,7 +418,7 @@
const GrDistanceFieldLCDTextureEffect& dfTexEffect =
drawEffect.castEffect<GrDistanceFieldLCDTextureEffect>();
- b->add32(dfTexEffect.getFlags());
+ b->add32(dfTexEffect.isUniformScale());
}
private:
@@ -442,13 +436,12 @@
GrTexture* texture, const GrTextureParams& params,
GrTexture* gamma, const GrTextureParams& gParams,
SkColor textColor,
- uint32_t flags)
+ bool uniformScale, bool useBGR)
: fTextureAccess(texture, params)
, fGammaTextureAccess(gamma, gParams)
, fTextColor(textColor)
- , fFlags(flags & kLCD_DistanceFieldEffectMask) {
- SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_DistanceFieldEffectFlag));
-
+ , fUniformScale(uniformScale)
+ , fUseBGR(useBGR) {
this->addTextureAccess(&fTextureAccess);
this->addTextureAccess(&fGammaTextureAccess);
this->addVertexAttrib(kVec2f_GrSLType);
@@ -457,10 +450,7 @@
bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrEffect& other) const {
const GrDistanceFieldLCDTextureEffect& cte =
CastEffect<GrDistanceFieldLCDTextureEffect>(other);
- return (fTextureAccess == cte.fTextureAccess &&
- fGammaTextureAccess == cte.fGammaTextureAccess &&
- fTextColor == cte.fTextColor &&
- fFlags == cte.fFlags);
+ return (fTextureAccess == cte.fTextureAccess && fGammaTextureAccess == cte.fGammaTextureAccess);
}
void GrDistanceFieldLCDTextureEffect::getConstantColorComponents(GrColor* color,
@@ -506,11 +496,8 @@
random->nextULessThan(256),
random->nextULessThan(256),
random->nextULessThan(256));
- uint32_t flags = kUseLCD_DistanceFieldEffectFlag;
- flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0;
- flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0;
return GrDistanceFieldLCDTextureEffect::Create(textures[texIdx], params,
textures[texIdx2], params2,
textColor,
- flags);
-}
+ random->nextBool(), random->nextBool());
+}
« no previous file with comments | « src/gpu/effects/GrDistanceFieldTextureEffect.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698