Skip to content

Commit 77d8811

Browse files
author
Thayer J Andrews
committed
Merge remote-tracking branch 'upstream/develop' into develop
2 parents 69ff4a6 + 7b1311e commit 77d8811

21 files changed

+77
-111
lines changed

cocos2d-ui-tests/tests/SpritePerformanceTest.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ @implementation SpritePerformanceTest
66

77
#define SPRITE_COUNT 3000
88
#define TILE_COUNT 37
9+
#define SCALE 1.0
910

1011
- (void)setupSpritesUnbatchedUnatlassedTest
1112
{
@@ -18,6 +19,7 @@ - (void)setupSpritesUnbatchedUnatlassedTest
1819
CCSprite *sprite = [CCSprite spriteWithImageNamed:[NSString stringWithFormat:@"Tiles/%02d.png", num]];
1920
sprite.position = ccp(CCRANDOM_0_1()*size.width, CCRANDOM_0_1()*size.height);
2021
sprite.rotation = CCRANDOM_0_1()*360;
22+
sprite.scale = SCALE;
2123
[self.contentNode addChild:sprite];
2224
}
2325
}
@@ -33,6 +35,7 @@ - (void)setupSpritesUnbatchedTest
3335
CCSprite *sprite = [CCSprite spriteWithImageNamed:[NSString stringWithFormat:@"TilesAtlassed/%02d.png", num]];
3436
sprite.position = ccp(CCRANDOM_0_1()*size.width, CCRANDOM_0_1()*size.height);
3537
sprite.rotation = CCRANDOM_0_1()*360;
38+
sprite.scale = SCALE;
3639
[self.contentNode addChild:sprite];
3740
}
3841
}
@@ -48,6 +51,7 @@ - (void)setupSpritesUnbatchedUnatlassed2080Test
4851
CCSprite *sprite = [CCSprite spriteWithImageNamed:[NSString stringWithFormat:@"Tiles/%02d.png", num]];
4952
sprite.position = ccp(CCRANDOM_0_1()*size.width, CCRANDOM_0_1()*size.height);
5053
sprite.rotation = CCRANDOM_0_1()*360;
54+
sprite.scale = SCALE;
5155

5256
if(i < 0.8*SPRITE_COUNT) sprite.position = ccp(-1000, -1000);
5357

@@ -68,6 +72,7 @@ - (void)setupSpritesSorted2080Test
6872
CCSprite *sprite = [CCSprite spriteWithImageNamed:[NSString stringWithFormat:@"Tiles/%02d.png", num]];
6973
sprite.position = ccp(CCRANDOM_0_1()*size.width, CCRANDOM_0_1()*size.height);
7074
sprite.rotation = CCRANDOM_0_1()*360;
75+
sprite.scale = SCALE;
7176

7277
if(i < 0.8*SPRITE_COUNT) sprite.position = ccp(-1000, -1000);
7378

@@ -92,6 +97,7 @@ - (void)setupSpritesUnbatched2080Test
9297
CCSprite *sprite = [CCSprite spriteWithImageNamed:[NSString stringWithFormat:@"TilesAtlassed/%02d.png", num]];
9398
sprite.position = ccp(CCRANDOM_0_1()*size.width, CCRANDOM_0_1()*size.height);
9499
sprite.rotation = CCRANDOM_0_1()*360;
100+
sprite.scale = SCALE;
95101

96102
if(i < 0.8*SPRITE_COUNT) sprite.position = ccp(-1000, -1000);
97103

cocos2d-ui/CCBReader/CCAnimationManager.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ -(void) onEnter {
8585

8686
- (void)addNode:(CCNode*)node andSequences:(NSDictionary*)seq
8787
{
88-
#ifdef DEBUG
88+
#if DEBUG
8989
//Sanity check sequences;
9090

9191
for (NSMutableDictionary* seqNodeProps in seq.allValues) {

cocos2d/CCConfiguration.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ typedef NS_ENUM(NSUInteger, CCDevice) {
7575

7676
GLint _maxTextureSize;
7777
BOOL _supportsPVRTC;
78-
BOOL _supportsNPOT;
7978
BOOL _supportsBGRA8888;
8079
BOOL _supportsDiscardFramebuffer;
8180
BOOL _supportsShareableVAO;
@@ -92,12 +91,6 @@ typedef NS_ENUM(NSUInteger, CCDevice) {
9291
*/
9392
@property (nonatomic, readonly) GLint maxTextureUnits;
9493

95-
/** Whether or not the GPU supports NPOT (Non Power Of Two) textures.
96-
OpenGL ES 2.0 already supports NPOT (iOS).
97-
98-
*/
99-
@property (nonatomic, readonly) BOOL supportsNPOT;
100-
10194
/** Whether or not PVR Texture Compressed is supported */
10295
@property (nonatomic, readonly) BOOL supportsPVRTC;
10396

cocos2d/CCConfiguration.m

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ @implementation CCConfiguration
4444

4545
@synthesize maxTextureSize = _maxTextureSize, maxTextureUnits=_maxTextureUnits;
4646
@synthesize supportsPVRTC = _supportsPVRTC;
47-
@synthesize supportsNPOT = _supportsNPOT;
4847
@synthesize supportsBGRA8888 = _supportsBGRA8888;
4948
@synthesize supportsDiscardFramebuffer = _supportsDiscardFramebuffer;
5049
@synthesize supportsShareableVAO = _supportsShareableVAO;
@@ -182,12 +181,6 @@ -(void) getOpenGLvariables
182181
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_maxTextureSize);
183182
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &_maxTextureUnits );
184183

185-
#ifdef __CC_PLATFORM_IOS
186-
_supportsNPOT = YES;
187-
#elif defined(__CC_PLATFORM_MAC)
188-
_supportsNPOT = [self checkForGLExtension:@"GL_ARB_texture_non_power_of_two"];
189-
#endif
190-
191184
_supportsPVRTC = [self checkForGLExtension:@"GL_IMG_texture_compression_pvrtc"];
192185

193186
// It seems that somewhere between firmware iOS 3.0 and 4.2 Apple renamed
@@ -222,14 +215,6 @@ -(GLint) maxTextureUnits
222215
return _maxTextureUnits;
223216
}
224217

225-
-(BOOL) supportsNPOT
226-
{
227-
if( ! _openGLInitialized )
228-
[self getOpenGLvariables];
229-
230-
return _supportsNPOT;
231-
}
232-
233218
-(BOOL) supportsPVRTC
234219
{
235220
if( ! _openGLInitialized )
@@ -308,7 +293,6 @@ -(void) dumpInfo
308293
printf("cocos2d: GL_MAX_SAMPLES: %d\n", _maxSamplesAllowed);
309294
printf("cocos2d: GL supports PVRTC: %s\n", (_supportsPVRTC ? "YES" : "NO") );
310295
printf("cocos2d: GL supports BGRA8888 textures: %s\n", (_supportsBGRA8888 ? "YES" : "NO") );
311-
printf("cocos2d: GL supports NPOT textures: %s\n", (_supportsNPOT ? "YES" : "NO") );
312296
printf("cocos2d: GL supports discard_framebuffer: %s\n", (_supportsDiscardFramebuffer ? "YES" : "NO") );
313297
printf("cocos2d: GL supports shareable VAO: %s\n", (_supportsShareableVAO ? "YES" : "NO") );
314298

cocos2d/CCDirector.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ -(void) calculateDeltaTime
265265
_dt = MAX(0,_dt);
266266
}
267267

268-
#ifdef DEBUG
268+
#if DEBUG
269269
// If we are debugging our code, prevent big delta time
270270
if( _dt > 0.2f )
271271
_dt = 1/60.0f;
@@ -864,7 +864,7 @@ -(void) showStats
864864
NSString *fpsstr = [[NSString alloc] initWithFormat:@"%.1f", _frameRate];
865865
[_FPSLabel setString:fpsstr];
866866

867-
// Subtract one to exclude the batch for actually rendering the stats label itself.
867+
// Subtract one for the stat label's own batch. This caused a lot of confusion on the forums...
868868
NSString *draws = [[NSString alloc] initWithFormat:@"%4lu", (unsigned long)__ccNumberOfDraws - 1];
869869
[_drawsLabel setString:draws];
870870
}

cocos2d/CCDrawNode.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ @implementation CCDrawNode {
5656

5757
+(void)initialize
5858
{
59+
// +initialize may be called due to loading a subclass.
60+
if(self != [CCDrawNode class]) return;
61+
5962
SHADER = [[CCShader alloc] initWithFragmentShaderSource:FRAGMENT_SHADER_SOURCE];
6063
}
6164

cocos2d/CCEffectRenderer.m

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,11 @@ - (BOOL)setupGLResourcesWithSize:(CGSize)size
6262

6363
glPushGroupMarkerEXT(0, "CCEffectRenderTarget: allocateRenderTarget");
6464

65-
// Textures may need to be a power of two
66-
NSUInteger powW;
67-
NSUInteger powH;
68-
69-
if( [[CCConfiguration sharedConfiguration] supportsNPOT] )
70-
{
71-
powW = size.width;
72-
powH = size.height;
73-
}
74-
else
75-
{
76-
powW = CCNextPOT(size.width);
77-
powH = CCNextPOT(size.height);
78-
}
79-
8065
static const CCTexturePixelFormat kRenderTargetDefaultPixelFormat = CCTexturePixelFormat_RGBA8888;
8166

8267
// Create a new texture object for use as the color attachment of the new
8368
// FBO.
84-
_texture = [[CCTexture alloc] initWithData:nil pixelFormat:kRenderTargetDefaultPixelFormat pixelsWide:powW pixelsHigh:powH contentSizeInPixels:size contentScale:[CCDirector sharedDirector].contentScaleFactor];
69+
_texture = [[CCTexture alloc] initWithData:nil pixelFormat:kRenderTargetDefaultPixelFormat pixelsWide:size.width pixelsHigh:size.height contentSizeInPixels:size contentScale:[CCDirector sharedDirector].contentScaleFactor];
8570
[_texture setAliasTexParameters];
8671

8772
// Save the old FBO binding so it can be restored after we create the new

cocos2d/CCNode+Debug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#import "CCNode.h"
2727

28-
#ifdef DEBUG
28+
#if DEBUG
2929

3030
/** Debugging extensions of CCNode. They are available when the DEBUG macro is defined at compile time. */
3131
@interface CCNode (Debug)

cocos2d/CCNode+Debug.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#import "CCNode+Debug.h"
2727
#import "CCNode_Private.h"
2828

29-
#ifdef DEBUG
29+
#if DEBUG
3030

3131
@implementation CCNode (Debug)
3232

cocos2d/CCPhysicsBody.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ -(void)didRemoveFromPhysicsNode:(CCPhysicsNode *)physics
514514
//The following are properties which we track on the parent nodes in order to update the child nodes.
515515
NSString * kDependantProperties[2] = { @"position", @"rotation"};
516516

517-
#ifdef DEBUG
517+
#if DEBUG
518518
//The following are properties which cannot be animated. Changing their values after onEnter in unhandled.
519519
NSString * kRestrictedProperties[3] = { @"scale", @"scaleX", @"scaleY"};
520520
#endif
@@ -531,7 +531,7 @@ -(void)trackParentTransformations:(CCPhysicsNode *)physics
531531
[node addObserver:self forKeyPath:kDependantProperties[i] options:NSKeyValueObservingOptionNew context:nil];
532532
}
533533

534-
#ifdef DEBUG
534+
#if DEBUG
535535
for (int i = 0; i < sizeof(kRestrictedProperties)/sizeof(kRestrictedProperties[0]); i++)
536536
{
537537
[node addObserver:self forKeyPath:kRestrictedProperties[i] options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
@@ -552,7 +552,7 @@ -(void)removeParentTransformTracking:(CCPhysicsNode *)physics
552552
{
553553
[node removeObserver:self forKeyPath:kDependantProperties[i]];
554554
}
555-
#ifdef DEBUG
555+
#if DEBUG
556556
for (int i = 0; i < sizeof(kRestrictedProperties)/sizeof(kRestrictedProperties[0]); i++)
557557
{
558558
[node removeObserver:self forKeyPath:kRestrictedProperties[i]];
@@ -567,7 +567,7 @@ -(void)removeParentTransformTracking:(CCPhysicsNode *)physics
567567

568568
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
569569
{
570-
#ifdef DEBUG
570+
#if DEBUG
571571
for (int i = 0; i < sizeof(kRestrictedProperties)/sizeof(kRestrictedProperties[0]); i++)
572572
{
573573
if([kRestrictedProperties[i] isEqualToString:keyPath])

0 commit comments

Comments
 (0)