Sunday, January 06, 2008

libpng patch for Mobile Firefox

There are submitted patches for Mobile Firefox on the Mozilla wiki.
http://wiki.mozilla.org/Mobile/Patches

My colleague tried to apply the png patch to Mozilla and get a good result related to performance improvement.

As you know, we can build the libpng fixed point routines like the above patch.
(Use #define PNG_NO_FLOATING_POINT_SUPPORTED in mozilla/modules/libimg/png/mozpngconf.h )

In this case, he can get 8.6% performance improvement.
It's great. I think this patch is valuable to use on Mobile Firefox.

However, there is the following problem in this patch.
Mozilla handles some floating point values to get image information from the libpng so the patch commented those parts in the info_callback() function. (mozilla/modules/libpr0n/decoders/png/nsPNGDecoder.cpp)
The problem is that color management feature should get color profile information from the libpng. The following code shows the example:

void
info_callback(png_structp png_ptr, png_infop info_ptr)
{
...

if (gfxPlatform::IsCMSEnabled()) {
decoder->mInProfile = PNGGetColorProfile(png_ptr, info_ptr,
color_type, &inType, &intent);
}
...
}

We can check the value of gfx.color_management.enabled through the gfxPlatform::IsCMSEnable() method.

If the gfx.color_management.enabled is true, you can use the color profiles embedded in images to adjust the colors to match your computer's display. In this case, Mozilla should call the PNGGetColorProfile() method. But this method handles floating point values.

Fortunately, Mozilla sets the value of gfx.color_management.enabled to false as default. The PNGGetColorProfile() method is not called. Nevertheless, the patch commented this part because a user may try to set the value to true.
Anyway, the color management feature is not used basically now.


If Mobile Firefox should use the color management feature, the png patch needs more tweaks.

How do you think about that?

No comments: