Skip to content

Commit

Permalink
Bug 1131446. mFrameHasNoAlpha is mostly pointless. r=seth
Browse files Browse the repository at this point in the history
Starting with bug 391583 we detect whether a png image has any transparency
during decode. I don't think this is worth doing anymore. We choose the format
of image based on the png header, that should be sufficient for the performance
improvement we desire from opaque images. This gets us faster image decoding.
  • Loading branch information
jrmuizel committed Feb 10, 2015
1 parent 39071f3 commit 216ff00
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
14 changes: 1 addition & 13 deletions image/decoders/nsPNGDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ void nsPNGDecoder::CreateFrame(png_uint_32 x_offset, png_uint_32 y_offset,
}

mFrameRect = neededRect;
mFrameHasNoAlpha = true;

PR_LOG(GetPNGDecoderAccountingLog(), PR_LOG_DEBUG,
("PNGDecoderAccounting: nsPNGDecoder::CreateFrame -- created "
Expand Down Expand Up @@ -201,7 +200,7 @@ nsPNGDecoder::EndImageFrame()
mNumFrames++;

Opacity opacity = Opacity::SOME_TRANSPARENCY;
if (format == gfx::SurfaceFormat::B8G8R8X8 || mFrameHasNoAlpha) {
if (format == gfx::SurfaceFormat::B8G8R8X8) {
opacity = Opacity::OPAQUE;
}

Expand Down Expand Up @@ -739,7 +738,6 @@ nsPNGDecoder::row_callback(png_structp png_ptr, png_bytep new_row,

uint32_t bpr = width * sizeof(uint32_t);
uint32_t* cptr32 = (uint32_t*)(decoder->mImageData + (row_num*bpr));
bool rowHasNoAlpha = true;

if (decoder->mTransform) {
if (decoder->mCMSLine) {
Expand Down Expand Up @@ -788,18 +786,12 @@ nsPNGDecoder::row_callback(png_structp png_ptr, png_bytep new_row,
if (!decoder->mDisablePremultipliedAlpha) {
for (uint32_t x=width; x>0; --x) {
*cptr32++ = gfxPackedPixel(line[3], line[0], line[1], line[2]);
if (line[3] != 0xff) {
rowHasNoAlpha = false;
}
line += 4;
}
} else {
for (uint32_t x=width; x>0; --x) {
*cptr32++ = gfxPackedPixelNoPreMultiply(line[3], line[0], line[1],
line[2]);
if (line[3] != 0xff) {
rowHasNoAlpha = false;
}
line += 4;
}
}
Expand All @@ -809,10 +801,6 @@ nsPNGDecoder::row_callback(png_structp png_ptr, png_bytep new_row,
png_longjmp(decoder->mPNG, 1);
}

if (!rowHasNoAlpha) {
decoder->mFrameHasNoAlpha = false;
}

if (decoder->mNumFrames <= 1) {
// Only do incremental image display for the first frame
// XXXbholley - this check should be handled in the superclass
Expand Down
1 change: 0 additions & 1 deletion image/decoders/nsPNGDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class nsPNGDecoder : public Decoder
uint32_t mCMSMode;

uint8_t mChannels;
bool mFrameHasNoAlpha;
bool mFrameIsHidden;
bool mDisablePremultipliedAlpha;

Expand Down

0 comments on commit 216ff00

Please sign in to comment.