issue #1686:synchronized Texture2DTest

This commit is contained in:
minggo 2013-02-28 14:54:09 +08:00
parent 47830a5ef4
commit f5e334d9e3
2 changed files with 69 additions and 1 deletions

View File

@ -14,6 +14,7 @@ static CCLayer* create##className() \
{ return new className(); }
TEXTURE2D_CREATE_FUNC(TextureMemoryAlloc);
TEXTURE2D_CREATE_FUNC(TextureAlias);
TEXTURE2D_CREATE_FUNC(TexturePVRMipMap);
TEXTURE2D_CREATE_FUNC(TexturePVRMipMap2);
@ -21,6 +22,7 @@ TEXTURE2D_CREATE_FUNC(TexturePVRNonSquare);
TEXTURE2D_CREATE_FUNC(TexturePVRNPOT4444);
TEXTURE2D_CREATE_FUNC(TexturePVRNPOT8888);
TEXTURE2D_CREATE_FUNC(TexturePVR);
TEXTURE2D_CREATE_FUNC(TexturePVR2BPP);
TEXTURE2D_CREATE_FUNC(TexturePVR2BPPv3);
TEXTURE2D_CREATE_FUNC(TexturePVR4BPP);
@ -46,6 +48,9 @@ TEXTURE2D_CREATE_FUNC(TexturePVRI8);
TEXTURE2D_CREATE_FUNC(TexturePVRI8v3);
TEXTURE2D_CREATE_FUNC(TexturePVRAI88);
TEXTURE2D_CREATE_FUNC(TexturePVRAI88v3);
TEXTURE2D_CREATE_FUNC(TexturePVRv3Premult);
TEXTURE2D_CREATE_FUNC(TexturePVRBadEncoding);
TESTLAYER_CREATE_FUNC(TexturePNG);
TESTLAYER_CREATE_FUNC(TextureJPEG);
@ -97,6 +102,8 @@ static NEWTEXTURE2DTESTFUNC createFunctions[] =
createTexturePVRAI88,
createTexturePVRAI88v3,
createTexturePVRv3Premult,
createTexturePVRBadEncoding,
createTexturePNG,
createTextureJPEG,
@ -1989,3 +1996,53 @@ string TextureMemoryAlloc::subtitle()
{
return "Testing Texture Memory allocation. Use Instruments + VM Tracker";
}
// TexturePVRv3Premult
TexturePVRv3Premult::TexturePVRv3Premult()
{
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCLayerColor *background = CCLayerColor::create(ccc4(128,128,128,255), size.width, size.height);
addChild(background, -1);
// PVR premultiplied
CCSprite *pvr1 = CCSprite::create("Images/grossinis_sister1-testalpha_premult.pvr");
addChild(pvr1, 0);
pvr1->setPosition(ccp(size.width/4*1, size.height/2));
transformSprite(pvr1);
// PVR non-premultiplied
CCSprite *pvr2 = CCSprite::create("Images/grossinis_sister1-testalpha_nopremult.pvr");
addChild(pvr2, 0);
pvr2->setPosition(ccp(size.width/4*2, size.height/2));
transformSprite(pvr2);
// PNG
CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888);
CCTextureCache::sharedTextureCache()->removeTextureForKey("Images/grossinis_sister1-testalpha.png");
CCSprite *png = CCSprite::create("Images/grossinis_sister1-testalpha.png");
addChild(png, 0);
png->setPosition(ccp(size.width/4*3, size.height/2));
transformSprite(png);
}
std::string TexturePVRv3Premult::title()
{
return "PVRv3 Premult Flag";
}
std::string TexturePVRv3Premult::subtitle()
{
return "All images should look exactly the same";
}
void TexturePVRv3Premult::transformSprite(cocos2d::CCSprite *sprite)
{
CCFadeOut *fade = CCFadeOut::create(2);
CCDelayTime *dl = CCDelayTime::create(2);
CCFadeOut *fadein = (CCFadeOut*)fade->reverse();
CCSequence *seq = CCSequence::create(fade, fadein, dl, NULL);
CCRepeatForever *repeat = CCRepeatForever::create(seq);
sprite->runAction(repeat);
}

View File

@ -431,4 +431,15 @@ private:
CCSprite *m_pBackground;
};
class TexturePVRv3Premult : public TextureDemo
{
public:
TexturePVRv3Premult();
virtual std::string title();
virtual std::string subtitle();
void transformSprite(cocos2d::CCSprite *sprite);
};
#endif // __TEXTURE2D_TEST_H__