@@ -81,6 +81,7 @@ Texture2DTests::Texture2DTests()
81
81
ADD_TEST_CASE (TextureTGA);
82
82
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
83
83
ADD_TEST_CASE (TextureWEBP);
84
+ ADD_TEST_CASE (TextureWEBPNoAlpha)
84
85
#endif
85
86
ADD_TEST_CASE (TexturePixelFormat);
86
87
ADD_TEST_CASE (TextureBlend);
@@ -261,11 +262,36 @@ void TextureWEBP::onEnter()
261
262
img->setPosition (Vec2 ( s.width /2 .0f , s.height /2 .0f ));
262
263
addChild (img);
263
264
log (" %s\n " , Director::getInstance ()->getTextureCache ()->getCachedTextureInfo ().c_str ());
265
+ Texture2D* texture = Director::getInstance ()->getTextureCache ()->getTextureForKey (" Images/test_image.webp" );
266
+ log (" pixel format:%d, premultiplied alpha:%d\n " , texture->getPixelFormat (), texture->hasPremultipliedAlpha ());
264
267
}
265
268
266
269
std::string TextureWEBP::title () const
267
270
{
268
- return " WEBP Test" ;
271
+ return " WEBP with alpha Test" ;
272
+ }
273
+
274
+ // ------------------------------------------------------------------
275
+ //
276
+ // TextureWEBPNoAlpha
277
+ //
278
+ // ------------------------------------------------------------------
279
+ void TextureWEBPNoAlpha::onEnter ()
280
+ {
281
+ TextureDemo::onEnter ();
282
+ auto s = Director::getInstance ()->getWinSize ();
283
+
284
+ auto img = Sprite::create (" Images/test_image_no_alpha.webp" );
285
+ img->setPosition (Vec2 ( s.width /2 .0f , s.height /2 .0f ));
286
+ addChild (img);
287
+ log (" %s\n " , Director::getInstance ()->getTextureCache ()->getCachedTextureInfo ().c_str ());
288
+ Texture2D* texture = Director::getInstance ()->getTextureCache ()->getTextureForKey (" Images/test_image_no_alpha.webp" );
289
+ log (" pixel format:%d, premultiplied alpha:%d\n " , texture->getPixelFormat (), texture->hasPremultipliedAlpha ());
290
+ }
291
+
292
+ std::string TextureWEBPNoAlpha::title () const
293
+ {
294
+ return " WEBP without alpha Test" ;
269
295
}
270
296
271
297
// ------------------------------------------------------------------
0 commit comments