//////////////////////////////////////////////////////// // // TextureTest // //////////////////////////////////////////////////////// void TextureTest::performTestsPNG(const char* filename) { struct timeval now; CCTexture2D *texture; CCTextureCache *cache = CCTextureCache::sharedTextureCache(); CCLog("RGBA 8888"); CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888); gettimeofday(&now, NULL); texture = cache->addImage(filename); if( texture ) CCLog(" ms:%f\n", calculateDeltaTime(&now) ); else CCLog(" ERROR\n"); cache->removeTexture(texture); //CCLog("RGBA 4444"); //CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444); //gettimeofday(&now, NULL); //texture = cache->addImage(filename); //if( texture ) // CCLog(" ms:%f\n", calculateDeltaTime(&now) ); //else // CCLog(" ERROR\n"); //cache->removeTexture(texture); /* CCLog("RGBA 5551"); CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB5A1); gettimeofday(&now, NULL); texture = cache->addImage(filename); if( texture ) CCLog(" ms:%f\n", calculateDeltaTime(&now) ); else CCLog(" ERROR\n"); cache->removeTexture(texture);*/ CCLog("RGB 565"); CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB565); gettimeofday(&now, NULL); texture = cache->addImage(filename); if( texture ) CCLog(" ms:%f\n", calculateDeltaTime(&now) ); else CCLog(" ERROR\n"); cache->removeTexture(texture); // restore default CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default); }
void SubTest::initWithSubTest(int nSubTest, CCNode* p) { subtestNumber = nSubTest; parent = p; batchNode = NULL; /* * Tests: * 1: 1 (32-bit) PNG sprite of 52 x 139 * 2: 1 (32-bit) PNG Batch Node using 1 sprite of 52 x 139 * 3: 1 (16-bit) PNG Batch Node using 1 sprite of 52 x 139 * 4: 1 (4-bit) PVRTC Batch Node using 1 sprite of 52 x 139 * 5: 14 (32-bit) PNG sprites of 85 x 121 each * 6: 14 (32-bit) PNG Batch Node of 85 x 121 each * 7: 14 (16-bit) PNG Batch Node of 85 x 121 each * 8: 14 (4-bit) PVRTC Batch Node of 85 x 121 each * 9: 64 (32-bit) sprites of 32 x 32 each *10: 64 (32-bit) PNG Batch Node of 32 x 32 each *11: 64 (16-bit) PNG Batch Node of 32 x 32 each *12: 64 (4-bit) PVRTC Batch Node of 32 x 32 each */ // purge textures CCTextureCache *mgr = CCTextureCache::sharedTextureCache(); // [mgr removeAllTextures]; mgr->removeTexture(mgr->addImage("Images/grossinis_sister1.png")); mgr->removeTexture(mgr->addImage("Images/grossini_dance_atlas.png")); mgr->removeTexture(mgr->addImage("Images/spritesheet1.png")); switch ( subtestNumber) { case 1: case 4: case 7: break; /// case 2: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888); batchNode = CCSpriteBatchNode::create("Images/grossinis_sister1.png", 100); p->addChild(batchNode, 0); break; case 3: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444); batchNode = CCSpriteBatchNode::create("Images/grossinis_sister1.png", 100); p->addChild(batchNode, 0); break; /// case 5: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888); batchNode = CCSpriteBatchNode::create("Images/grossini_dance_atlas.png", 100); p->addChild(batchNode, 0); break; case 6: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444); batchNode = CCSpriteBatchNode::create("Images/grossini_dance_atlas.png", 100); p->addChild(batchNode, 0); break; /// case 8: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888); batchNode = CCSpriteBatchNode::create("Images/spritesheet1.png", 100); p->addChild(batchNode, 0); break; case 9: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444); batchNode = CCSpriteBatchNode::create("Images/spritesheet1.png", 100); p->addChild(batchNode, 0); break; default: break; } if (batchNode) { batchNode->retain(); } CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default); }