Bug 370942 - Remove non-Cairo from jpeg decoder and optimize loop

p=Alfred Kayser <alfredkayser@nl.ibm.com>
r=tor, sr=pavlov
This commit is contained in:
asqueella%gmail.com 2007-04-29 15:51:35 +00:00
Родитель 13beea1aa2
Коммит 7f949592b9
1 изменённых файлов: 5 добавлений и 6 удалений

Просмотреть файл

@ -49,6 +49,7 @@
#include "ImageLogging.h"
#include "nsIImage.h"
#include "nsIInterfaceRequestorUtils.h"
#include "gfxColor.h"
#include "jerror.h"
@ -470,7 +471,6 @@ nsJPEGDecoder::OutputScanlines()
PRUint8 *imageData;
PRUint32 imageDataLength;
mFrame->GetImageData(&imageData, &imageDataLength);
nsCOMPtr<nsIImage> img(do_GetInterface(mFrame));
while ((mInfo.output_scanline < mInfo.output_height)) {
/* Request one scanline. Returns 0 or 1 scanlines. */
@ -483,16 +483,15 @@ nsJPEGDecoder::OutputScanlines()
PRUint32 offset = (mInfo.output_scanline - 1) * mInfo.output_width;
PRUint32 *ptrOutputBuf = ((PRUint32*)imageData) + offset;
JSAMPLE *j1 = mSamples[0];
for (PRUint32 i=0; i < mInfo.output_width; ++i) {
PRUint8 r = *j1++;
PRUint8 g = *j1++;
PRUint8 b = *j1++;
*ptrOutputBuf++ = (0xFF << 24) | (r << 16) | (g << 8) | b;
for (PRUint32 i=mInfo.output_width; i>0; --i) {
*ptrOutputBuf++ = GFX_PACKED_PIXEL(0xFF, j1[0], j1[1], j1[2]);
j1+=3;
}
}
if (top != mInfo.output_scanline) {
nsIntRect r(0, top, mInfo.output_width, mInfo.output_scanline-top);
nsCOMPtr<nsIImage> img(do_GetInterface(mFrame));
img->ImageUpdated(nsnull, nsImageUpdateFlags_kBitsChanged, &r);
mObserver->OnDataAvailable(nsnull, mFrame, &r);
}