| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrTextureDomainEffect_DEFINED | 8 #ifndef GrTextureDomainEffect_DEFINED |
| 9 #define GrTextureDomainEffect_DEFINED | 9 #define GrTextureDomainEffect_DEFINED |
| 10 | 10 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 /** | 89 /** |
| 90 * A GrGLProcessor subclass that corresponds to a GrProcessor subclass that
uses GrTextureDomain | 90 * A GrGLProcessor subclass that corresponds to a GrProcessor subclass that
uses GrTextureDomain |
| 91 * should include this helper. It generates the texture domain GLSL, produce
s the part of the | 91 * should include this helper. It generates the texture domain GLSL, produce
s the part of the |
| 92 * effect key that reflects the texture domain code, and performs the unifor
m uploads necessary | 92 * effect key that reflects the texture domain code, and performs the unifor
m uploads necessary |
| 93 * for texture domains. | 93 * for texture domains. |
| 94 */ | 94 */ |
| 95 class GLDomain { | 95 class GLDomain { |
| 96 public: | 96 public: |
| 97 GLDomain() { | 97 GLDomain() { |
| 98 fPrevDomain[0] = SK_FloatNaN; | 98 for (int i = 0; i < kPrevDomainCount; i++) { |
| 99 fPrevDomain[i] = SK_FloatNaN; |
| 100 } |
| 99 SkDEBUGCODE(fMode = (Mode) -1;) | 101 SkDEBUGCODE(fMode = (Mode) -1;) |
| 100 } | 102 } |
| 101 | 103 |
| 102 /** | 104 /** |
| 103 * Call this from GrGLProcessor::emitCode() to sample the texture W.R.T.
the domain and | 105 * Call this from GrGLProcessor::emitCode() to sample the texture W.R.T.
the domain and |
| 104 * mode. | 106 * mode. |
| 105 * | 107 * |
| 106 * @param outcolor name of vec4 variable to hold the sampled color. | 108 * @param outcolor name of vec4 variable to hold the sampled color. |
| 107 * @param inCoords name of vec2 variable containing the coords to be us
ed with the domain. | 109 * @param inCoords name of vec2 variable containing the coords to be us
ed with the domain. |
| 108 * It is assumed that this is a variable and not an exp
ression. | 110 * It is assumed that this is a variable and not an exp
ression. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 130 /** | 132 /** |
| 131 * GrGLProcessor::GenKey() must call this and include the returned value
in it's computed | 133 * GrGLProcessor::GenKey() must call this and include the returned value
in it's computed |
| 132 * key. The returned will be limited to the lower kDomainKeyBits bits. | 134 * key. The returned will be limited to the lower kDomainKeyBits bits. |
| 133 */ | 135 */ |
| 134 static uint32_t DomainKey(const GrTextureDomain& domain) { | 136 static uint32_t DomainKey(const GrTextureDomain& domain) { |
| 135 GR_STATIC_ASSERT(kModeCount <= 4); | 137 GR_STATIC_ASSERT(kModeCount <= 4); |
| 136 return domain.mode(); | 138 return domain.mode(); |
| 137 } | 139 } |
| 138 | 140 |
| 139 private: | 141 private: |
| 142 static const int kPrevDomainCount = 4; |
| 140 SkDEBUGCODE(Mode fMode;) | 143 SkDEBUGCODE(Mode fMode;) |
| 141 GrGLProgramDataManager::UniformHandle fDomainUni; | 144 GrGLProgramDataManager::UniformHandle fDomainUni; |
| 142 SkString fDomainName; | 145 SkString fDomainName; |
| 143 GrGLfloat fPrevDomain[4]; | 146 GrGLfloat fPrevDomain[kPrevDomainCount]; |
| 144 }; | 147 }; |
| 145 | 148 |
| 146 protected: | 149 protected: |
| 147 Mode fMode; | 150 Mode fMode; |
| 148 SkRect fDomain; | 151 SkRect fDomain; |
| 149 int fIndex; | 152 int fIndex; |
| 150 | 153 |
| 151 typedef GrSingleTextureEffect INHERITED; | 154 typedef GrSingleTextureEffect INHERITED; |
| 152 }; | 155 }; |
| 153 | 156 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 bool onIsEqual(const GrFragmentProcessor&) const override; | 193 bool onIsEqual(const GrFragmentProcessor&) const override; |
| 191 | 194 |
| 192 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 195 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
| 193 | 196 |
| 194 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 197 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 195 | 198 |
| 196 typedef GrSingleTextureEffect INHERITED; | 199 typedef GrSingleTextureEffect INHERITED; |
| 197 }; | 200 }; |
| 198 | 201 |
| 199 #endif | 202 #endif |
| OLD | NEW |