fosphor/gl_cmap: Add a return value and void* arg to the generate func

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
Sylvain Munaut 2015-03-11 13:21:29 +01:00
parent 773442b170
commit 1780d4b43b
5 changed files with 16 additions and 12 deletions

View File

@ -279,9 +279,9 @@ fosphor_gl_init(struct fosphor *self)
rv = (gl->cmap_ctx == NULL);
rv |= fosphor_gl_cmap_generate(&gl->cmap_waterfall,
fosphor_gl_cmap_waterfall, 256);
fosphor_gl_cmap_waterfall, NULL, 256);
rv |= fosphor_gl_cmap_generate(&gl->cmap_histogram,
fosphor_gl_cmap_histogram, 256);
fosphor_gl_cmap_histogram, NULL, 256);
if (rv)
goto error;

View File

@ -297,7 +297,7 @@ fosphor_gl_cmap_draw_scale(GLuint cmap_id,
int
fosphor_gl_cmap_generate(GLuint *cmap_id, gl_cmap_gen_func_t gfn, int N)
fosphor_gl_cmap_generate(GLuint *cmap_id, gl_cmap_gen_func_t gfn, void *gfn_arg, int N)
{
uint32_t *rgba;
@ -313,7 +313,7 @@ fosphor_gl_cmap_generate(GLuint *cmap_id, gl_cmap_gen_func_t gfn, int N)
glBindTexture(GL_TEXTURE_1D, *cmap_id);
/* Generate texture data */
gfn(rgba, N);
gfn(rgba, N, gfn_arg);
/* Upload data */
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, N, 0,

View File

@ -56,8 +56,8 @@ void fosphor_gl_cmap_disable(void);
void fosphor_gl_cmap_draw_scale(GLuint cmap_id,
float x0, float x1, float y0, float y1);
typedef void (*gl_cmap_gen_func_t)(uint32_t *rgba, int N);
int fosphor_gl_cmap_generate(GLuint *cmap_id, gl_cmap_gen_func_t gfn, int N);
typedef int (*gl_cmap_gen_func_t)(uint32_t *rgba, int N, void *arg);
int fosphor_gl_cmap_generate(GLuint *cmap_id, gl_cmap_gen_func_t gfn, void *gfn_arg, int N);
/*! @} */

View File

@ -128,8 +128,8 @@ _set_rgba_from_hsv(uint32_t *rgba, float h, float s, float v)
}
void
fosphor_gl_cmap_histogram(uint32_t *rgba, int N)
int
fosphor_gl_cmap_histogram(uint32_t *rgba, int N, void *arg)
{
int i;
int m = N >> 4;
@ -155,11 +155,13 @@ fosphor_gl_cmap_histogram(uint32_t *rgba, int N)
0.60f + ((p < 0.40f) ? p : 0.40f)
);
}
return 0;
}
void
fosphor_gl_cmap_waterfall(uint32_t *rgba, int N)
int
fosphor_gl_cmap_waterfall(uint32_t *rgba, int N, void *arg)
{
int i;
@ -173,6 +175,8 @@ fosphor_gl_cmap_waterfall(uint32_t *rgba, int N)
((p * 0.95f) + 0.05f) /* V */
);
}
return 0;
}
/*! @} */

View File

@ -32,8 +32,8 @@
#include <stdint.h>
void fosphor_gl_cmap_histogram(uint32_t *rgba, int N);
void fosphor_gl_cmap_waterfall(uint32_t *rgba, int N);
int fosphor_gl_cmap_histogram(uint32_t *rgba, int N, void *arg);
int fosphor_gl_cmap_waterfall(uint32_t *rgba, int N, void *arg);
/*! @} */