[Mesa-dev] [PATCH 02/13] mesa: Make nonlinear_to_linear() function available outside file
Anuj Phogat
anuj.phogat at gmail.com
Mon Nov 12 19:48:46 PST 2012
This patch changes nonlinear_to_linear() function to non static inline
and makes it available outside format_unpack.c. Also, removes the
duplicate copies in other files.
Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
src/mesa/main/format_unpack.c | 2 +-
src/mesa/main/format_unpack.h | 3 +++
src/mesa/main/texcompress_s3tc.c | 28 +---------------------------
3 files changed, 5 insertions(+), 28 deletions(-)
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index d31d2fa..f831aec 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -57,7 +57,7 @@ struct z32f_x24s8
* linear RGB value in [0, 1].
* Implemented with a 256-entry lookup table.
*/
-static inline GLfloat
+GLfloat
nonlinear_to_linear(GLubyte cs8)
{
static GLfloat table[256];
diff --git a/src/mesa/main/format_unpack.h b/src/mesa/main/format_unpack.h
index aad800d..77b640a 100644
--- a/src/mesa/main/format_unpack.h
+++ b/src/mesa/main/format_unpack.h
@@ -24,6 +24,9 @@
#ifndef FORMAT_UNPACK_H
#define FORMAT_UNPACK_H
+extern GLfloat
+nonlinear_to_linear(GLubyte cs8);
+
extern void
_mesa_unpack_rgba_row(gl_format format, GLuint n,
const void *src, GLfloat dst[][4]);
diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c
index 6476f11..472a6a7 100644
--- a/src/mesa/main/texcompress_s3tc.c
+++ b/src/mesa/main/texcompress_s3tc.c
@@ -45,6 +45,7 @@
#include "texcompress_s3tc.h"
#include "texstore.h"
#include "swrast/s_context.h"
+#include "format_unpack.h"
#if defined(_WIN32) || defined(WIN32)
@@ -57,33 +58,6 @@
#define DXTN_LIBNAME "libtxc_dxtn.so"
#endif
-/**
- * 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];
-}
-
typedef void (*dxtFetchTexelFuncExt)( GLint srcRowstride, GLubyte *pixdata, GLint col, GLint row, GLvoid *texelOut );
static dxtFetchTexelFuncExt fetch_ext_rgb_dxt1 = NULL;
--
1.7.7.6
More information about the mesa-dev
mailing list