Alpha Premultiplied Issue

12 views
Skip to first unread message

Vision Ke

unread,
May 28, 2014, 2:56:49 PM5/28/14
to cocos2d-...@googlegroups.com
Hi guys,

We have a bug reported that sprites initialized with transparent images have unpleasant black border in some cases.
http://www.cocos2d-x.org/issues/4850

There are more discussions from another thread illustrating the same issue.

The root cause has been figured out. When loading a PNG file as texture, we did alpha premultiplied operations in cocos2d-x 2.x, this is why it worked fine. But seems the behavior had been changed since 3.0 alpha, those codes had been removed on account of performance optimization.

We might have to bring the old codes back to resolve this issue. So I did some tests to see the performance decrease affected by enabling alpha premultiplied today.
The tests simply created several sprites with PNG images of different sizes, and recored their time costs respectively.
Below are the final result (on iPhone4s):

Image Size             Enable Alpha Premultiplied (µs)           Disable Alpha Premultiplied(µs)
32x32                     6770                                                 6126
64x64                     7676                                                 7169
128x128                 12569                                                10769
256x256                 41821                                                30948
512x512                 148200                                              120519
1024x1024              577649                                              470119

As is seen, when alpha premultiplied is enabled, the loading time increased by about 10~20%.

I am not sure if we should bring alpha premultiplied back for PNG. Besides the influence of performance, there might be some other things affected too.

Any suggestion for that?

Thanks.
Reply all
Reply to author
Forward
0 new messages