Skip to content

Commit adfdd1f

Browse files
committed
Merge branch 'develop' into CCDirector/ResponderRefactoring
2 parents d2a2e6a + 57dc0ff commit adfdd1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+444
-758
lines changed

CCRendererGLSupport.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ -(GLenum)glType
5959
return GLTypeForCCTextureType(self.type);
6060
}
6161

62-
-(void)_setupTexture:(CCTextureType)type sizeInPixels:(CGSize)sizeInPixels mipmapped:(BOOL)mipmapped
62+
-(void)_setupTexture:(CCTextureType)type rendertexture:(BOOL)rendertexture sizeInPixels:(CGSize)sizeInPixels mipmapped:(BOOL)mipmapped;
6363
{
6464
glGenTextures(1, &_name);
6565
}

UnitTests/CCNodeTests.m

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,68 @@ -(void)testCCNodeTransformScale
502502

503503
}
504504

505+
-(CCNode*) makeChainOfNodes
506+
{
507+
// testing a large number of fairly deeply nested nodes. Nodes use relative positioning.
508+
CCScene *scene = [CCScene node];
509+
510+
CCNode *prev = scene;
511+
const int DEPTH = 8;
512+
for(int i = 0; i < DEPTH; i++ ){
513+
514+
CCNode *child = [CCNode node];
515+
child.positionType = CCPositionTypeNormalized;
516+
child.position = ccp(CCRANDOM_0_1(), CCRANDOM_0_1());
517+
child.contentSize = CGSizeMake(1.0, 1.0);
518+
[prev addChild:child];
519+
prev = child;
520+
}
521+
522+
for(int i = 0; i < 500; i++){
523+
CCNode *child = [CCNode node];
524+
child.name = [NSString stringWithFormat:@"Child number: %d", i];
525+
child.positionType = CCPositionTypeNormalized;
526+
child.position = ccp(0.5, 0.5);
527+
[prev addChild:child];
528+
}
529+
return prev;
530+
}
531+
532+
-(void)testPerformanceInstantiatingNormalizedNodes
533+
{
534+
CCNode *node = [self makeChainOfNodes];
535+
XCTAssertEqual(500, node.children.count);
536+
}
537+
538+
-(void)testPerformanceManipulatingNormalizedNodes
539+
{
540+
CCNode *node = [self makeChainOfNodes];
541+
542+
for(int i = 0; i < 100; i++){
543+
for (CCNode *child in node.children) {
544+
child.position = ccpAdd(child.position, ccp(CCRANDOM_0_1() - 0.5, CCRANDOM_0_1() - 0.5));
545+
}
546+
}
547+
548+
XCTAssertEqual(500, node.children.count);
549+
}
550+
551+
-(void)testPerformanceCalculateNodeToParentTransform
552+
{
553+
CCNode *node = [self makeChainOfNodes];
554+
555+
for(int i = 0; i < 100; i++){
556+
for (CCNode *child in node.children) {
557+
child.position = ccp(CCRANDOM_0_1(), CCRANDOM_0_1());
558+
// Accessing the nodeToParent is a very common operation when drawing, and a good place to check for performance issues.
559+
[child nodeToParentTransform];
560+
}
561+
}
562+
563+
XCTAssertEqual(500, node.children.count);
564+
}
565+
566+
505567
// TODO: Write tests that scale a parent anchor node, make sure the child's nodeToWorldTransform moves.
506568

507569

0 commit comments

Comments
 (0)