Elliott's Firefox Builds for Mac OS X
Here are Firefox builds for Mac OS X. They run on Intel processors.
July 19, 2008 Firefox 3.0.1 for Mac OS X patches are in the 301patches subdirectory - the LUT patch is a combination of patches which take a little work to apply
May 3, 2008 Firefox 3.0Pre Trunk 20080503 for Mac OS X JPEG, rounding
August 23, 2007 firefox 2.0.0.6 x08 for Mac OS X optimized PNG decompresser and GIF decoder
August 23, 2007 firefox 2.0.0.6 x07 for Mac OS X optimized PNG decoder copying
August
18, 2007 firefox 2.0.0.6 x06 for Mac OS X fixed cnet.com bug in x05, added gfxImageFrame optimization, added -mfpmath=sse -ftree-vectorize
August
17, 2007 firefox 2.0.0.6 x05 for Mac OS X added JPEG decoding SSE2 optimization (crash bug at cnet.com)
August
16, 2007 firefox 2.0.0.6 x04 for Mac OS X added JPEG SSE2 Color Optimization
August
12, 2007 firefox 2.0.0.6 x03 for Mac OS X added JPEG
Inverse Discrete Cosine Transform SSE2 acceleration
August
8, 2007 firefox 2.0.0.6 x01 for Mac OS X added
jslock lightweight locking and lightweight rounding
August
8, 2007 firefox 2.0.0.6 for Mac OS X stock build
with -o3 optimization
Things to do:
- Port range limit tables from x64 (JPEG)
- Use SSE2 processing for jdsample box filters (JPEG)
- Use integer work variable instead of a double for JS conversion of string ints to doubles
- Port PNG MMX optimizations to intrinsics (work in progress)
- Consider writing a highly optimized memcpy routine
- Get PowerPC G5 builds up and running
Patches applied to
x08 build (excluding IJG code):
Index: Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/modules/libimg/png/Makefile.in,v
retrieving revision 1.27.18.1
diff -u -r1.27.18.1 Makefile.in
--- Makefile.in 20 May 2006 17:20:48 -0000 1.27.18.1
+++ Makefile.in 25 Aug 2007 23:01:07 -0000
@@ -68,6 +68,7 @@
pngwtran.c \
pngrtran.c \
pngwutil.c \
+ pnggccrd.c \
$(NULL)
EXPORTS = png.h pngconf.h mozpngconf.h
@@ -85,6 +86,8 @@
DEFINES += -DMOZ_PNG_WRITE
endif
+DEFINES += -DPNG_USE_PNGGCCRD
+
ifeq ($(OS_ARCH),WINNT)
DEFINES += -DZLIB_DLL
ifdef BUILD_DEBUG_GC
Index: pnggccrd.c
===================================================================
RCS file: /cvsroot/mozilla/modules/libimg/png/pnggccrd.c,v
retrieving revision 3.7
diff -u -r3.7 pnggccrd.c
--- pnggccrd.c 7 Oct 2004 19:21:29 -0000 3.7
+++ pnggccrd.c 25 Aug 2007 23:00:41 -0000
@@ -236,13 +236,15 @@
* - rewrite all MMX interlacing code so it's aligned with beginning
* of the row buffer, not the end (see 19991007 for details)
* x pick one version of mmxsupport() and get rid of the other
- * - add error messages to any remaining bogus default cases
+ * - add error messages to any remaining bogus defau>lt cases
* - enable pixel_depth == 8 cases in png_read_filter_row()? (test speed)
* x add support for runtime enable/disable/query of various MMX routines
*/
#define PNG_INTERNAL
#include "png.h"
+#include "emmintrin.h"
+#include "xmmintrin.h"
#if defined(PNG_USE_PNGGCCRD)
@@ -254,6 +256,8 @@
static const int FARDATA png_pass_width[7] = {8, 4, 4, 2, 2, 1, 1};
#endif
+#undef PNG_ASSEMBLER_CODE_SUPPORTED
+
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
/* djgpp, Win32, and Cygwin add their own underscores to global variables,
* so define them without: */
@@ -5190,12 +5194,32 @@
else
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
{
- png_uint_32 i;
- png_uint_32 istop = row_info->rowbytes;
- png_bytep rp = row;
- png_bytep pp = prev_row;
+ png_uint_32 i, j;
+ png_uint_32 istop = row_info->rowbytes;
+ png_bytep rp = row;
+ png_bytep pp = prev_row;
+ __m128i rp_vec1, pp_vec1;
+ unsigned int diff;
+
+ if (istop > 40) {
+ diff = ((unsigned int) rp) & 0xf;
+ diff = (16 - diff) & 0xf;
+ for (i = 0; i < diff; ++i)
+ {
+ *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
+ rp++;
+ }
+ for (j = diff; j < istop - 16; j += 16) {
+ rp_vec1 = _mm_load_si128((__m128i const *) rp);
+ pp_vec1 = _mm_loadu_si128((__m128i const *) pp);
+ rp_vec1 = _mm_add_epi8(rp_vec1, pp_vec1);
+ _mm_store_si128((__m128i *) rp, rp_vec1);
+ rp += 16;
+ pp += 16;
+ }
+ }
- for (i = 0; i < istop; ++i)
+ for (i = j; i < istop; ++i)
{
*rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
rp++;
@@ -5338,69 +5362,7 @@
int PNGAPI
png_mmx_support(void)
{
-#if defined(PNG_MMX_CODE_SUPPORTED)
- __asm__ __volatile__ (
- "pushl
%%ebx \n\t"
// ebx gets clobbered by CPUID instruction
- "pushl
%%ecx \n\t"
// so does ecx...
- "pushl
%%edx \n\t"
// ...and edx (but ecx & edx safe on Linux)
-// ".byte
0x66 \n\t"
// convert 16-bit pushf to 32-bit pushfd
-//
"pushf
\n\t" // 16-bit pushf
-
"pushfl
\n\t" // save Eflag to stack
- "popl
%%eax
\n\t" // get Eflag from stack into eax
- "movl %%eax,
%%ecx \n\t" // make another copy of Eflag in ecx
- "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21)
- "pushl
%%eax \n\t"
// save modified Eflag back to stack
-// ".byte
0x66 \n\t"
// convert 16-bit popf to 32-bit popfd
-//
"popf
\n\t" // 16-bit popf
-
"popfl
\n\t" // restore modified value to Eflag reg
-
"pushfl
\n\t" // save Eflag to stack
- "popl
%%eax
\n\t" // get Eflag from stack
- "pushl
%%ecx \n\t"
// save original Eflag to stack
-
"popfl
\n\t" // restore original Eflag
- "xorl %%ecx,
%%eax \n\t" // compare new Eflag with original
Eflag
- "jz
0f
\n\t" // if same, CPUID instr. is not supported
-
- "xorl %%eax, %%eax \n\t" // set eax to zero
-// ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode)
-
"cpuid
\n\t" // get the CPU identification info
- "cmpl $1,
%%eax \n\t" // make sure eax
return non-zero value
- "jl
0f
\n\t" // if eax is zero, MMX is not supported
-
- "xorl %%eax, %%eax \n\t" // set eax to zero and...
- "incl
%%eax
\n\t" // ...increment eax to 1. This pair is
-
// faster than the instruction "mov eax, 1"
-
"cpuid
\n\t" // get the CPU identification info again
- "andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23)
- "cmpl $0,
%%edx \n\t" // 0 = MMX not
supported
- "jz
0f
\n\t" // non-zero = yes, MMX IS supported
-
- "movl $1,
%%eax \n\t" // set return
value to 1
- "jmp
1f
\n\t" // DONE: have MMX support
-
-
"0:
\n\t" // .NOT_SUPPORTED: target label for jump instructions
- "movl $0,
%%eax \n\t" // set return
value to 0
-
"1:
\n\t" // .RETURN: target label for jump instructions
- "movl %%eax, _mmx_supported \n\t" // save in global static variable, too
- "popl
%%edx
\n\t" // restore edx
- "popl
%%ecx
\n\t" // restore ecx
- "popl
%%ebx
\n\t" // restore ebx
-
-//
"ret
\n\t" // DONE: no MMX support
-
// (fall through to standard C "ret")
-
-
:
// output list (none)
-
-
:
// any variables used on input (none)
-
- :
"%eax"
// clobber list
-// , "%ebx", "%ecx", "%edx" // GRR: we handle these manually
-// , "memory" // if write to a variable gcc thought was in a reg
-// , "cc" // "condition codes" (flag bits)
- );
-#else
_mmx_supported = 0;
-#endif /* PNG_MMX_CODE_SUPPORTED */
-
return _mmx_supported;
}
Index: nsJPEGDecoder.cpp
===================================================================
RCS file: /cvsroot/mozilla/modules/libpr0n/decoders/jpeg/nsJPEGDecoder.cpp,v
retrieving revision 1.62.18.1
diff -u -r1.62.18.1 nsJPEGDecoder.cpp
--- nsJPEGDecoder.cpp 3 Feb 2006 14:41:10 -0000 1.62.18.1
+++ nsJPEGDecoder.cpp 18 Aug 2007 17:33:20 -0000
@@ -49,6 +49,8 @@
#include "ImageLogging.h"
#include "jerror.h"
+#include "emmintrin.h"
+#include "xmmintrin.h"
NS_IMPL_ISUPPORTS1(nsJPEGDecoder, imgIDecoder)
@@ -361,7 +363,7 @@
mSamples = (*mInfo.mem->alloc_sarray)((j_common_ptr) &mInfo,
JPOOL_IMAGE,
-
row_stride, 1);
+
mInfo.output_width * 3, 1);
#if defined(XP_WIN) || defined(XP_OS2) || defined(XP_BEOS) ||
defined(XP_MAC) || defined(XP_MACOSX) || defined(MOZ_WIDGET_PHOTON)
// allocate buffer to do byte flipping / padding
@@ -379,7 +381,7 @@
/* FIXME -- Should reset dct_method and dither mode
* for final pass of progressive JPEG
*/
- mInfo.dct_method = JDCT_ISLOW;
+ mInfo.dct_method = JDCT_IFAST;
mInfo.dither_mode = JDITHER_FS;
mInfo.do_fancy_upsampling = TRUE;
mInfo.enable_2pass_quant = FALSE;
@@ -499,12 +501,12 @@
return NS_OK;
}
-
int
nsJPEGDecoder::OutputScanlines()
{
PRUint32 top = mInfo.output_scanline;
PRBool rv = PR_TRUE;
+ PRUint32 i;
while ((mInfo.output_scanline < mInfo.output_height)) {
JSAMPROW samples;
@@ -529,11 +531,29 @@
}
samples = mRGBRow;
-#elif defined(XP_MAC) || defined(XP_MACOSX)
+#elif defined(XP_MAC1) || defined(XP_MACOSX1)
PRUint8 *ptrOutputBuf = mRGBRow;
JSAMPLE *j1 = mSamples[0];
- for (PRUint32 i=0;i<mInfo.output_width;++i) {
+ mask1 = *((__m128i *) color_mask_1a);
+ mask2 = *((__m128i *) color_mask_2a);
+ for (i=0; i < mInfo.output_width - 4; i += 4) {
+ tmp1 = mask1;
+ tmp2 = mask2;
+ read1 = _mm_loadl_epi64((__m128i *) j1);
+ read1 = (__m128i) _mm_loadh_pi((__m128) read1, (__m64 *)(j1+6));
+ tmp1 = _mm_and_si128(tmp1, read1);
+ tmp2 = _mm_and_si128(tmp2, read1);
+ tmp1 = _mm_slli_si128(tmp1, 1);
+ tmp2 = _mm_slli_si128(tmp2, 2);
+ tmp1 = _mm_or_si128(tmp1, tmp2);
+ _mm_storel_pi((__m64 *) ptrOutputBuf, (__m128) tmp1);
+ _mm_storeh_pi((__m64 *) (ptrOutputBuf + 8), (__m128) tmp1);
+ ptrOutputBuf += 16;
+ j1 += 12;
+ }
+
+ for (; i < mInfo.output_width; ++i) {
ptrOutputBuf[0] = 0;
ptrOutputBuf[1] = *j1++;
ptrOutputBuf[2] = *j1++;
@@ -557,8 +577,8 @@
PRUint32 bpr;
mFrame->GetImageBytesPerRow(&bpr);
mFrame->SetImageData(
-
samples,
// data
- row_stride, // length
+
samples,
// data
+
-mInfo.output_width,
// length
(mInfo.output_scanline-1) * bpr); // offset
}
Index: gfxImageFrame.cpp
===================================================================
RCS file: /cvsroot/mozilla/gfx/src/shared/gfxImageFrame.cpp,v
retrieving revision 1.32
diff -u -r1.32 gfxImageFrame.cpp
--- gfxImageFrame.cpp 8 Mar 2005 03:44:27 -0000 1.32
+++ gfxImageFrame.cpp 18 Aug 2007 23:51:51 -0000
@@ -39,6 +39,8 @@
#include "gfxImageFrame.h"
#include "nsIServiceManager.h"
+#include "emmintrin.h"
+#include "xmmintrin.h"
NS_IMPL_ISUPPORTS2(gfxImageFrame, gfxIImageFrame, nsIInterfaceRequestor)
@@ -279,9 +281,15 @@
return NS_OK;
}
+unsigned char color_mask_1b[16] __attribute__ ((aligned(16))) = {255,255,255,0,0,0,0,0,255,255,255,0,0,0,0,0};
+unsigned char color_mask_2b[16] __attribute__ ((aligned(16))) = {0,0,0,255,255,255,0,0,0,0,0,255,255,255,0,0};
+
/* void setImageData ([array, size_is (length), const] in PRUint8 data, in unsigned long length, in long offset); */
NS_IMETHODIMP gfxImageFrame::SetImageData(const PRUint8 *aData, PRUint32 aLength, PRInt32 aOffset)
{
+ int express_flag = 0;
+ __m128i mask1, mask2, tmp1, tmp2, read1;
+
if (!mInitalized)
return NS_ERROR_NOT_INITIALIZED;
@@ -292,6 +300,11 @@
if (aLength == 0)
return NS_OK;
+ if ((int) aLength < 0) {
+ express_flag = - ((int) aLength);
+ aLength = (-4) * ((int) aLength);
+ }
+
PRInt32 row_stride = mImage->GetLineStride();
mImage->LockImagePixels(PR_FALSE);
@@ -313,7 +326,40 @@
}
if (aData)
- memcpy(imgData + newOffset, aData, aLength);
+ if (express_flag == 0)
+ memcpy(imgData + newOffset, aData, aLength);
+ else {
+ const PRUint8 *j1 = aData;
+ PRUint8 *ptrOutputBuf = imgData + newOffset;
+ int i;
+
+ mask1 = *((__m128i *) color_mask_1b);
+ mask2 = *((__m128i *) color_mask_2b);
+ for (i=0; i < express_flag - 4; i += 4) {
+ tmp1 = mask1;
+ tmp2 = mask2;
+ read1 = _mm_loadl_epi64((__m128i *) j1);
+ read1 = (__m128i) _mm_loadh_pi((__m128) read1, (__m64 *)(j1+6));
+ tmp1 = _mm_and_si128(tmp1, read1);
+ tmp2 = _mm_and_si128(tmp2, read1);
+ tmp1 = _mm_slli_si128(tmp1, 1);
+ tmp2 = _mm_slli_si128(tmp2, 2);
+ tmp1 = _mm_or_si128(tmp1, tmp2);
+ _mm_storel_pi((__m64 *) ptrOutputBuf, (__m128) tmp1);
+ _mm_storeh_pi((__m64 *) (ptrOutputBuf + 8), (__m128) tmp1);
+ ptrOutputBuf += 16;
+ j1 += 12;
+ }
+
+ for (; i < express_flag; ++i) {
+ ptrOutputBuf[0] = 0;
+ ptrOutputBuf[1] = *j1++;
+ ptrOutputBuf[2] = *j1++;
+ ptrOutputBuf[3] = *j1++;
+ ptrOutputBuf += 4;
+ }
+
+ }
else
memset(imgData + newOffset, 0, aLength);
mImage->UnlockImagePixels(PR_FALSE);
Index: nsUnitConversion.h
===================================================================
RCS file: /cvsroot/mozilla/xpcom/ds/nsUnitConversion.h,v
retrieving revision 3.12
diff -r3.12 nsUnitConversion.h
43a44
> #include <xmmintrin.h>
82c83,85
< return ((0.0f <= aValue) ? nscoord(aValue + ROUND_CONST_FLOAT) : nscoord(aValue - ROUND_CONST_FLOAT));
---
> /* return ((0.0f <= aValue) ? nscoord(aValue + ROUND_CONST_FLOAT) : nscoord(aValue - ROUND_CONST_FLOAT)); */
> return(_mm_cvtss_si32(_mm_load_ss(&aValue)));
>
101c104,105
< return ((0.0f <= aValue) ? PRInt32(aValue + ROUND_CONST_FLOAT) : PRInt32(aValue - ROUND_CONST_FLOAT));
---
> /* return ((0.0f <= aValue) ? PRInt32(aValue + ROUND_CONST_FLOAT) : PRInt32(aValue - ROUND_CONST_FLOAT)); */
> return(_mm_cvtss_si32(_mm_load_ss(&aValue)));
Index: GIF2.cpp
===================================================================
RCS file: /cvsroot/mozilla/modules/libpr0n/decoders/gif/Attic/GIF2.cpp,v
retrieving revision 1.52.8.2
diff -u -r1.52.8.2 GIF2.cpp
--- GIF2.cpp 4 Apr 2007 19:30:42 -0000 1.52.8.2
+++ GIF2.cpp 29 Aug 2007 02:38:57 -0000
@@ -565,7 +565,18 @@
case gif_global_colormap:
{
- memcpy(gs->global_colormap, q, 3 * gs->global_colormap_size);
+ int i, target;
+ PRUint8 * gcmap = gs->global_colormap;
+
+ target = gs->global_colormap_size;
+ for (i = 0; i < target; i++) {
+ *gcmap++ = 0;
+ *gcmap++ = *q++;
+ *gcmap++ = *q++;
+ *gcmap++ = *q++;
+ }
+
+ /* memcpy(gs->global_colormap, q, 3 * gs->global_colormap_size); */
GETN(1, gif_image_start);
}
@@ -858,15 +869,23 @@
case gif_image_colormap:
{
PRUint8 *map = gs->local_colormap;
+ int i, target;
if (!map) {
- map = gs->local_colormap = (PRUint8*)PR_MALLOC(3 * gs->local_colormap_size);
+ map = gs->local_colormap = (PRUint8*)PR_MALLOC(4 * gs->local_colormap_size);
if (!map) {
gs->state = gif_oom;
break;
}
}
+ target = gs->local_colormap_size;
+ for (i = 0; i < target; i++) {
+ *map++ = 0;
+ *map++ = *q++;
+ *map++ = *q++;
+ *map++ = *q++;
+ }
- memcpy(map, q, 3 * gs->local_colormap_size);
+ /* memcpy(map, q, 3 * gs->local_colormap_size); */
GETN(1, gif_lzw_start);
}
Index: nsGIFDecoder2.cpp
===================================================================
RCS file: /cvsroot/mozilla/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp,v
retrieving revision 1.65
diff -u -r1.65 nsGIFDecoder2.cpp
--- nsGIFDecoder2.cpp 10 Mar 2005 13:31:26 -0000 1.65
+++ nsGIFDecoder2.cpp 29 Aug 2007 02:38:58 -0000
@@ -484,10 +484,11 @@
if(decoder->mGIFStruct->global_colormap &&
decoder->mGIFStruct->screen_bgcolor < cmapsize) {
gfx_color bgColor = 0;
- PRUint32 bgIndex = decoder->mGIFStruct->screen_bgcolor * 3;
- bgColor |= cmap[bgIndex];
- bgColor |= cmap[bgIndex + 1] << 8;
- bgColor |= cmap[bgIndex + 2] << 16;
+ PRUint32 bgIndex = decoder->mGIFStruct->screen_bgcolor * 4;
+ bgColor = ((PRUint32 *) cmap)[decoder->mGIFStruct->screen_bgcolor];
+ // bgColor |= cmap[bgIndex];
+ // bgColor |= cmap[bgIndex + 1] << 8;
+ // bgColor |= cmap[bgIndex + 2] << 16;
decoder->mImageFrame->SetBackgroundColor(bgColor);
}
if (decoder->mGIFStruct->is_local_colormap_defined) {
@@ -514,8 +515,10 @@
case gfxIFormats::BGR:
{
while (rowBufIndex != decoder->mGIFStruct->rowend) {
+ PRUint32 * rgbRowIndexLong = (PRUint32 *) rgbRowIndex;
+ PRUint32 * cmaplong = (PRUint32 *) cmap;
#if defined(XP_MAC) || defined(XP_MACOSX)
-
*rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad
+
//*rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad
#endif
if (*rowBufIndex < cmapsize) {
PRUint32 colorIndex = *rowBufIndex * 3;
@@ -524,14 +527,18 @@
*rgbRowIndex++ = cmap[colorIndex + 1]; // green
*rgbRowIndex++ = cmap[colorIndex]; // red
#else
-
*rgbRowIndex++ = cmap[colorIndex]; // red
- *rgbRowIndex++ = cmap[colorIndex + 1]; // green
- *rgbRowIndex++ = cmap[colorIndex + 2]; // blue
+
//*rgbRowIndex++ = cmap[colorIndex]; // red
+
//*rgbRowIndex++ = cmap[colorIndex + 1]; // green
+ //*rgbRowIndex++ = cmap[colorIndex + 2]; // blue
+ *rgbRowIndexLong = cmaplong[*rowBufIndex];
+ rgbRowIndex += 4;
#endif
} else {
-
*rgbRowIndex++ =
0;
// red
-
*rgbRowIndex++ =
0;
// green
-
*rgbRowIndex++ =
0;
// blue
+ *rgbRowIndexLong = 0;
+
// *rgbRowIndex++ =
0;
// red
+
// *rgbRowIndex++ =
0;
// green
+
// *rgbRowIndex++ =
0;
// blue
+ rgbRowIndex += 4;
}
++rowBufIndex;
}
@@ -547,9 +554,11 @@
memset(decoder->mRGBLine, 0, bpr);
memset(decoder->mAlphaLine, 0, abpr);
for (PRUint32 x = 0; x < (PRUint32)width; ++x) {
+ PRUint32 * rgbRowIndexLong = (PRUint32 *) rgbRowIndex;
+ PRUint32 * cmaplong = (PRUint32 *) cmap;
if (*rowBufIndex != decoder->mGIFStruct->tpixel) {
#if defined(XP_MAC) || defined(XP_MACOSX)
-
*rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad
+
//*rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad
#endif
if (*rowBufIndex < cmapsize) {
PRUint32 colorIndex = *rowBufIndex * 3;
@@ -558,14 +567,18 @@
*rgbRowIndex++ = cmap[colorIndex + 1]; // green
*rgbRowIndex++ = cmap[colorIndex]; // red
#else
-
*rgbRowIndex++ = cmap[colorIndex]; // red
-
*rgbRowIndex++ = cmap[colorIndex + 1]; // green
-
*rgbRowIndex++ = cmap[colorIndex + 2]; // blue
+
//*rgbRowIndex++ = cmap[colorIndex]; // red
+
//*rgbRowIndex++ = cmap[colorIndex + 1]; // green
+
//*rgbRowIndex++ = cmap[colorIndex + 2]; // blue
+
*rgbRowIndexLong = cmaplong[*rowBufIndex];
+ rgbRowIndex += 4;
#endif
} else {
-
*rgbRowIndex++ =
0;
// red
-
*rgbRowIndex++ =
0;
// green
-
*rgbRowIndex++ =
0;
// blue
+ *rgbRowIndexLong = 0;
+
//*rgbRowIndex++ =
0;
// red
+
//*rgbRowIndex++ =
0;
// green
+
//*rgbRowIndex++ =
0;
// blue
+ rgbRowIndex += 4;
}
decoder->mAlphaLine[x>>3] |= 1<<(7-x&0x7);
} else {
Index: GIF2.cpp
===================================================================
RCS file: /cvsroot/mozilla/modules/libpr0n/decoders/gif/Attic/GIF2.cpp,v
retrieving revision 1.52.8.2
diff -u -r1.52.8.2 GIF2.cpp
--- GIF2.cpp 4 Apr 2007 19:30:42 -0000 1.52.8.2
+++ GIF2.cpp 29 Aug 2007 02:38:57 -0000
@@ -565,7 +565,18 @@
case gif_global_colormap:
{
- memcpy(gs->global_colormap, q, 3 * gs->global_colormap_size);
+ int i, target;
+ PRUint8 * gcmap = gs->global_colormap;
+
+ target = gs->global_colormap_size;
+ for (i = 0; i < target; i++) {
+ *gcmap++ = 0;
+ *gcmap++ = *q++;
+ *gcmap++ = *q++;
+ *gcmap++ = *q++;
+ }
+
+ /* memcpy(gs->global_colormap, q, 3 * gs->global_colormap_size); */
GETN(1, gif_image_start);
}
@@ -858,15 +869,23 @@
case gif_image_colormap:
{
PRUint8 *map = gs->local_colormap;
+ int i, target;
if (!map) {
- map = gs->local_colormap = (PRUint8*)PR_MALLOC(3 * gs->local_colormap_size);
+ map = gs->local_colormap = (PRUint8*)PR_MALLOC(4 * gs->local_colormap_size);
if (!map) {
gs->state = gif_oom;
break;
}
}
+ target = gs->local_colormap_size;
+ for (i = 0; i < target; i++) {
+ *map++ = 0;
+ *map++ = *q++;
+ *map++ = *q++;
+ *map++ = *q++;
+ }
- memcpy(map, q, 3 * gs->local_colormap_size);
+ /* memcpy(map, q, 3 * gs->local_colormap_size); */
GETN(1, gif_lzw_start);
}
Index: nsGIFDecoder2.cpp
===================================================================
RCS file: /cvsroot/mozilla/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp,v
retrieving revision 1.65
diff -u -r1.65 nsGIFDecoder2.cpp
--- nsGIFDecoder2.cpp 10 Mar 2005 13:31:26 -0000 1.65
+++ nsGIFDecoder2.cpp 29 Aug 2007 02:38:58 -0000
@@ -484,10 +484,11 @@
if(decoder->mGIFStruct->global_colormap &&
decoder->mGIFStruct->screen_bgcolor < cmapsize) {
gfx_color bgColor = 0;
- PRUint32 bgIndex = decoder->mGIFStruct->screen_bgcolor * 3;
- bgColor |= cmap[bgIndex];
- bgColor |= cmap[bgIndex + 1] << 8;
- bgColor |= cmap[bgIndex + 2] << 16;
+ PRUint32 bgIndex = decoder->mGIFStruct->screen_bgcolor * 4;
+ bgColor = ((PRUint32 *) cmap)[decoder->mGIFStruct->screen_bgcolor];
+ // bgColor |= cmap[bgIndex];
+ // bgColor |= cmap[bgIndex + 1] << 8;
+ // bgColor |= cmap[bgIndex + 2] << 16;
decoder->mImageFrame->SetBackgroundColor(bgColor);
}
if (decoder->mGIFStruct->is_local_colormap_defined) {
@@ -514,8 +515,10 @@
case gfxIFormats::BGR:
{
while (rowBufIndex != decoder->mGIFStruct->rowend) {
+ PRUint32 * rgbRowIndexLong = (PRUint32 *) rgbRowIndex;
+ PRUint32 * cmaplong = (PRUint32 *) cmap;
#if defined(XP_MAC) || defined(XP_MACOSX)
-
*rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad
+
//*rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad
#endif
if (*rowBufIndex < cmapsize) {
PRUint32 colorIndex = *rowBufIndex * 3;
@@ -524,14 +527,18 @@
*rgbRowIndex++ = cmap[colorIndex + 1]; // green
*rgbRowIndex++ = cmap[colorIndex]; // red
#else
-
*rgbRowIndex++ = cmap[colorIndex]; // red
- *rgbRowIndex++ = cmap[colorIndex + 1]; // green
- *rgbRowIndex++ = cmap[colorIndex + 2]; // blue
+
//*rgbRowIndex++ = cmap[colorIndex]; // red
+
//*rgbRowIndex++ = cmap[colorIndex + 1]; // green
+ //*rgbRowIndex++ = cmap[colorIndex + 2]; // blue
+ *rgbRowIndexLong = cmaplong[*rowBufIndex];
+ rgbRowIndex += 4;
#endif
} else {
-
*rgbRowIndex++ =
0;
// red
-
*rgbRowIndex++ =
0;
// green
-
*rgbRowIndex++ =
0;
// blue
+ *rgbRowIndexLong = 0;
+
// *rgbRowIndex++ =
0;
// red
+
// *rgbRowIndex++ =
0;
// green
+
// *rgbRowIndex++ =
0;
// blue
+ rgbRowIndex += 4;
}
++rowBufIndex;
}
@@ -547,9 +554,11 @@
memset(decoder->mRGBLine, 0, bpr);
memset(decoder->mAlphaLine, 0, abpr);
for (PRUint32 x = 0; x < (PRUint32)width; ++x) {
+ PRUint32 * rgbRowIndexLong = (PRUint32 *) rgbRowIndex;
+ PRUint32 * cmaplong = (PRUint32 *) cmap;
if (*rowBufIndex != decoder->mGIFStruct->tpixel) {
#if defined(XP_MAC) || defined(XP_MACOSX)
-
*rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad
+
//*rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad
#endif
if (*rowBufIndex < cmapsize) {
PRUint32 colorIndex = *rowBufIndex * 3;
@@ -558,14 +567,18 @@
*rgbRowIndex++ = cmap[colorIndex + 1]; // green
*rgbRowIndex++ = cmap[colorIndex]; // red
#else
-
*rgbRowIndex++ = cmap[colorIndex]; // red
-
*rgbRowIndex++ = cmap[colorIndex + 1]; // green
-
*rgbRowIndex++ = cmap[colorIndex + 2]; // blue
+
//*rgbRowIndex++ = cmap[colorIndex]; // red
+
//*rgbRowIndex++ = cmap[colorIndex + 1]; // green
+
//*rgbRowIndex++ = cmap[colorIndex + 2]; // blue
+
*rgbRowIndexLong = cmaplong[*rowBufIndex];
+ rgbRowIndex += 4;
#endif
} else {
-
*rgbRowIndex++ =
0;
// red
-
*rgbRowIndex++ =
0;
// green
-
*rgbRowIndex++ =
0;
// blue
+ *rgbRowIndexLong = 0;
+
//*rgbRowIndex++ =
0;
// red
+
//*rgbRowIndex++ =
0;
// green
+
//*rgbRowIndex++ =
0;
// blue
+ rgbRowIndex += 4;
}
decoder->mAlphaLine[x>>3] |= 1<<(7-x&0x7);
} else {
Updated by Elliott
on July 19, 2008.