Skip to content

Commit d03e851

Browse files
author
Thayer J Andrews
committed
CCEffectHue - Store conditioned hue / matrix as NSNumber / NSValue
To avoid recreating these on every draw.
1 parent 7e55028 commit d03e851

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

cocos2d/CCEffectHue.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757

5858
@interface CCEffectHue ()
5959
#if CCEFFECTHUE_USES_COLOR_MATRIX
60-
@property (nonatomic) GLKMatrix4 hueRotationMtx;
60+
@property (nonatomic) NSValue *hueRotationMtx;
6161
#else
62-
@property (nonatomic) float conditionedHue;
62+
@property (nonatomic) NSNumber *conditionedHue;
6363
#endif
6464
@end
6565

@@ -85,9 +85,9 @@ -(id)initWithHue:(float)hue
8585
{
8686
_hue = hue;
8787
#if CCEFFECTHUE_USES_COLOR_MATRIX
88-
_hueRotationMtx = matrixWithHue(conditionHue(hue));
88+
_hueRotationMtx = [NSValue valueWithGLKMatrix4:matrixWithHue(conditionHue(hue))];
8989
#else
90-
_conditionedHue = conditionHue(hue);
90+
_conditionedHue = [NSNumber numberWithFloat:conditionHue(hue)];
9191
#endif
9292
self.debugName = @"CCEffectHue";
9393
}
@@ -164,9 +164,9 @@ -(void)buildRenderPasses
164164
pass.shaderUniforms[CCShaderUniformMainTexture] = previousPassTexture;
165165
pass.shaderUniforms[CCShaderUniformPreviousPassTexture] = previousPassTexture;
166166
#if CCEFFECTHUE_USES_COLOR_MATRIX
167-
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_hueRotationMtx"]] = [NSValue valueWithGLKMatrix4:weakSelf.hueRotationMtx];
167+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_hueRotationMtx"]] = weakSelf.hueRotationMtx;
168168
#else
169-
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_hue"]] = [NSNumber numberWithFloat:weakSelf.conditionedHue];
169+
pass.shaderUniforms[weakSelf.uniformTranslationTable[@"u_hue"]] = weakSelf.conditionedHue;
170170
#endif
171171
} copy]];
172172

@@ -177,9 +177,9 @@ -(void)setHue:(float)hue
177177
{
178178
_hue = hue;
179179
#if CCEFFECTHUE_USES_COLOR_MATRIX
180-
_hueRotationMtx = matrixWithHue(conditionHue(hue));
180+
_hueRotationMtx = [NSValue valueWithGLKMatrix4:matrixWithHue(conditionHue(hue))];
181181
#else
182-
_conditionedHue = conditionHue(hue);
182+
_conditionedHue = [NSNumber numberWithFloat:conditionHue(hue)];
183183
#endif
184184
}
185185

0 commit comments

Comments
 (0)