Skip to content

Commit 7e1c72a

Browse files
author
Thayer J Andrews
committed
CCEffectStack - Update the padding of an effect stack from its contained effects
If the padding of any contained effects is greater than the padding set directly on the stack, use the contained effects value.
1 parent f7395f5 commit 7e1c72a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

cocos2d/CCEffectStack.m

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ - (CCEffectPrepareStatus)prepareForRendering
116116
CCEffectPrepareStatus result = CCEffectPrepareNothingToDo;
117117
if (_passesDirty)
118118
{
119+
CGSize maxPadding = self.padding;
120+
119121
// Start by populating the flattened list with this stack's effects.
120122
NSMutableArray *flattenedEffects = [[NSMutableArray alloc] initWithArray:_effects];
121123
NSUInteger index = 0;
@@ -141,11 +143,22 @@ - (CCEffectPrepareStatus)prepareForRendering
141143
}
142144
}
143145

144-
// Make sure all the contained effects are ready for rendering
145-
// before we do anything else.
146146
for (CCEffect *effect in flattenedEffects)
147147
{
148+
// Make sure all the contained effects are ready for rendering
149+
// before we do anything else.
148150
[effect prepareForRendering];
151+
152+
// And find the max padding values of all contained effects.
153+
if (effect.padding.width > maxPadding.width)
154+
{
155+
maxPadding.width = effect.padding.width;
156+
}
157+
158+
if (effect.padding.height > maxPadding.height)
159+
{
160+
maxPadding.height = effect.padding.height;
161+
}
149162
}
150163

151164
NSMutableArray *stitchedEffects = [[NSMutableArray alloc] init];
@@ -194,8 +207,9 @@ - (CCEffectPrepareStatus)prepareForRendering
194207
}
195208
self.renderPasses = [passes copy];
196209
self.shaderUniforms = uniforms;
197-
_passesDirty = NO;
210+
self.padding = maxPadding;
198211

212+
_passesDirty = NO;
199213
result = CCEffectPrepareSuccess;
200214
}
201215
return result;

0 commit comments

Comments
 (0)