Anuj Phogat <anuj.pho...@gmail.com> writes: > This patch moves nonlinear_to_linear() function from format_unpack.c > to format_unpack.h and removes the duplicate copies of this function > in other files. > +#include "macros.h" > + > +/** > + * Convert an 8-bit sRGB value from non-linear space to a > + * linear RGB value in [0, 1]. > + * Implemented with a 256-entry lookup table. > + */ > +static inline GLfloat > +nonlinear_to_linear(GLubyte cs8) > +{ > + static GLfloat table[256]; > + static GLboolean tableReady = GL_FALSE; > + if (!tableReady) { > + /* compute lookup table now */ > + GLuint i; > + for (i = 0; i < 256; i++) { > + const GLfloat cs = UBYTE_TO_FLOAT(i); > + if (cs <= 0.04045) { > + table[i] = cs / 12.92f; > + } > + else { > + table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4); > + } > + } > + tableReady = GL_TRUE; > + } > + return table[cs8]; > +}
Given that this function has a static stable that it initializes, it really doesn't want to be an inline function in a header file. Make it a non-inline function in the original file, imo, or at least make the table static in the original file.
pgpgo8etEF8dG.pgp
Description: PGP signature
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev