From 237fe615c664ea0754da6d2c6fd23d9a363015ab Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Sun, 17 Aug 2008 22:08:53 -0700 Subject: [PATCH] Code to fastpath Alpha PNGs in LCMS - part of bug 445552. r=vlad --- modules/lcms/src/cmsxform.c | 9 +++++++-- modules/libpr0n/decoders/png/nsPNGDecoder.cpp | 10 +++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/lcms/src/cmsxform.c b/modules/lcms/src/cmsxform.c index cc951a77d92..43b42c00bdb 100644 --- a/modules/lcms/src/cmsxform.c +++ b/modules/lcms/src/cmsxform.c @@ -615,8 +615,13 @@ void MatrixShaperXFORMFloat(_LPcmsTRANSFORM p, register LPBYTE In, Out; register unsigned int i; LPMATSHAPER MatShaper; + unsigned Increment; + // We support a very limited number of configurations for the floatpath + CMSASSERT(p->InputFormat == p->OutputFormat); + CMSASSERT((p->InputFormat == TYPE_RGB_8) || (p->InputFormat == TYPE_RGBA_8)); + Increment = (p->InputFormat == TYPE_RGB_8) ? 3 : 4; In = (LPBYTE) in; Out = (LPBYTE) out; MatShaper = p -> SmeltMatShaper; @@ -758,8 +763,8 @@ void MatrixShaperXFORMFloat(_LPcmsTRANSFORM p, Out[2] = RGB_16_TO_8((WORD)tmp[2]); } - In += 3; - Out += 3; + In += Increment; + Out += Increment; } } #endif diff --git a/modules/libpr0n/decoders/png/nsPNGDecoder.cpp b/modules/libpr0n/decoders/png/nsPNGDecoder.cpp index d3b13b27b88..28e3e5fa0df 100644 --- a/modules/libpr0n/decoders/png/nsPNGDecoder.cpp +++ b/modules/libpr0n/decoders/png/nsPNGDecoder.cpp @@ -542,20 +542,24 @@ info_callback(png_structp png_ptr, png_infop info_ptr) } if (decoder->mInProfile && gfxPlatform::GetCMSOutputProfile()) { PRUint32 outType; + PRUint32 dwFlags = 0; if (color_type & PNG_COLOR_MASK_ALPHA || num_trans) outType = TYPE_RGBA_8; else outType = TYPE_RGB_8; + /* Determine if we can use the optimized floating point path. */ + if ((inType == outType) && + ((inType == TYPE_RGB_8) || (inType == TYPE_RGBA_8))) + dwFlags |= cmsFLAGS_FLOATSHAPER; + decoder->mTransform = cmsCreateTransform(decoder->mInProfile, inType, gfxPlatform::GetCMSOutputProfile(), outType, intent, - ((inType == TYPE_RGB_8) && - (outType == TYPE_RGB_8)) - ? cmsFLAGS_FLOATSHAPER : 0); + dwFlags); } else { png_set_gray_to_rgb(png_ptr); if (gfxPlatform::GetCMSMode() == eCMSMode_All) {