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

Unified Diff: src/effects/gradients/SkGradientShaderPriv.h

Issue 385713005: Allow GrGLEffects to produce variable length keys. (Closed) Base URL: https://skia.googlesource.com/skia.git@key
Patch Set: rebase 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/effects/gradients/SkGradientShader.cpp ('k') | src/effects/gradients/SkLinearGradient.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/gradients/SkGradientShaderPriv.h
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index 96135378032d52ade5e27b2c573408206543eb37..61acf3c8fe8075d015ba164d7577f775fdfd5fa6 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -379,6 +379,29 @@ public:
virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
protected:
+ /**
+ * Subclasses must call this. It will return a key for the part of the shader code controlled
+ * by the base class. The subclasses must stick it in their key and then pass it to the below
+ * emit* functions from their emitCode function.
+ */
+ static uint32_t GenBaseGradientKey(const GrDrawEffect&);
+
+ // Emits the uniform used as the y-coord to texture samples in derived classes. Subclasses
+ // should call this method from their emitCode().
+ void emitUniforms(GrGLShaderBuilder* builder, uint32_t baseKey);
+
+
+ // emit code that gets a fragment's color from an expression for t; Has branches for 3 separate
+ // control flows inside -- 2 color gradients, 3 color symmetric gradients (both using
+ // native GLSL mix), and 4+ color gradients that use the traditional texture lookup.
+ void emitColor(GrGLShaderBuilder* builder,
+ const char* gradientTValue,
+ uint32_t baseKey,
+ const char* outputColor,
+ const char* inputColor,
+ const TextureSamplerArray& samplers);
+
+private:
enum {
kPremulTypeKeyBitCnt = 1,
kPremulTypeMask = 1,
@@ -393,45 +416,24 @@ protected:
// and combine with the result of GenBaseGradientKey.
kBaseKeyBitCnt = (kPremulTypeKeyBitCnt + kColorKeyBitCnt)
};
+ GR_STATIC_ASSERT(kBaseKeyBitCnt <= 32);
- static SkGradientShaderBase::GpuColorType ColorTypeFromKey(EffectKey key){
- if (kTwoColorKey == (key & kColorKeyMask)) {
+ static SkGradientShaderBase::GpuColorType ColorTypeFromKey(uint32_t baseKey){
+ if (kTwoColorKey == (baseKey & kColorKeyMask)) {
return SkGradientShaderBase::kTwo_GpuColorType;
- } else if (kThreeColorKey == (key & kColorKeyMask)) {
+ } else if (kThreeColorKey == (baseKey & kColorKeyMask)) {
return SkGradientShaderBase::kThree_GpuColorType;
} else {return SkGradientShaderBase::kTexture_GpuColorType;}
}
- static GrGradientEffect::PremulType PremulTypeFromKey(EffectKey key){
- if (kPremulBeforeInterpKey == (key & kPremulTypeMask)) {
+ static GrGradientEffect::PremulType PremulTypeFromKey(uint32_t baseKey){
+ if (kPremulBeforeInterpKey == (baseKey & kPremulTypeMask)) {
return GrGradientEffect::kBeforeInterp_PremulType;
} else {
return GrGradientEffect::kAfterInterp_PremulType;
}
}
- /**
- * Subclasses must call this. It will return a value restricted to the lower kBaseKeyBitCnt
- * bits.
- */
- static EffectKey GenBaseGradientKey(const GrDrawEffect&);
-
- // Emits the uniform used as the y-coord to texture samples in derived classes. Subclasses
- // should call this method from their emitCode().
- void emitUniforms(GrGLShaderBuilder* builder, EffectKey key);
-
-
- // emit code that gets a fragment's color from an expression for t; Has branches for 3 separate
- // control flows inside -- 2 color gradients, 3 color symmetric gradients (both using
- // native GLSL mix), and 4+ color gradients that use the traditional texture lookup.
- void emitColor(GrGLShaderBuilder* builder,
- const char* gradientTValue,
- EffectKey key,
- const char* outputColor,
- const char* inputColor,
- const TextureSamplerArray& samplers);
-
-private:
SkScalar fCachedYCoord;
GrGLUniformManager::UniformHandle fFSYUni;
GrGLUniformManager::UniformHandle fColorStartUni;
« no previous file with comments | « src/effects/gradients/SkGradientShader.cpp ('k') | src/effects/gradients/SkLinearGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698