[libpng16] Exit loop over tRNS array when a transparent entry is

found (performance report by PoChun Chang)
This commit is contained in:
Glenn Randers-Pehrson 2013-08-04 14:03:44 -05:00
parent 5881b11629
commit 492e67163e

View File

@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers /* pngrtran.c - transforms the data in a row for PNG readers
* *
* Last changed in libpng 1.6.2 [April 25, 2013] * Last changed in libpng 1.6.4 [(PENDING RELEASE)]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -1116,12 +1116,18 @@ png_init_palette_transformations(png_structrp png_ptr)
/* Ignore if all the entries are opaque (unlikely!) */ /* Ignore if all the entries are opaque (unlikely!) */
for (i=0; i<png_ptr->num_trans; ++i) for (i=0; i<png_ptr->num_trans; ++i)
{
if (png_ptr->trans_alpha[i] == 255) if (png_ptr->trans_alpha[i] == 255)
continue; continue;
else if (png_ptr->trans_alpha[i] == 0) else if (png_ptr->trans_alpha[i] == 0)
input_has_transparency = 1; input_has_transparency = 1;
else else
{
input_has_transparency = 1;
input_has_alpha = 1; input_has_alpha = 1;
break;
}
}
} }
/* If no alpha we can optimize. */ /* If no alpha we can optimize. */