Commit ccf5d7f5 authored by He Junyan's avatar He Junyan Committed by Eric Anholt

Prepare for modification of gradient using shader.

 Prepare for modification of gradient using shader. The
 gradient pixmaps now is generated by pixman and we will
 replace them with shader. Add structure fields and
 dispatch functions which will be needed. Some auxiliary
 macro for vertex convert.
Reviewed-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
Signed-off-by: default avatarZhigang Gong <zhigang.gong@linux.intel.com>
parent a57bf66d
......@@ -389,6 +389,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_init_tile_shader(screen);
glamor_init_putimage_shaders(screen);
glamor_init_finish_access_shaders(screen);
glamor_init_gradient_shader(screen);
glamor_pixmap_init(screen);
glamor_priv->flags = flags;
......@@ -416,6 +417,7 @@ glamor_release_screen_priv(ScreenPtr screen)
glamor_fini_tile_shader(screen);
glamor_fini_putimage_shaders(screen);
glamor_fini_finish_access_shaders(screen);
glamor_fini_gradient_shader(screen);
glamor_pixmap_fini(screen);
free(glamor_priv);
......
......@@ -65,10 +65,12 @@ glamor_gl_dispatch_init_impl(struct glamor_gl_dispatch *dispatch,
INIT_FUNC(dispatch, glUseProgram, get_proc_address);
INIT_FUNC(dispatch, glUniform1i, get_proc_address);
INIT_FUNC(dispatch, glUniform1f, get_proc_address);
INIT_FUNC(dispatch, glUniform4f, get_proc_address);
INIT_FUNC(dispatch, glUniform4fv, get_proc_address);
INIT_FUNC(dispatch, glUniform1fv, get_proc_address);
INIT_FUNC(dispatch, glUniform2fv, get_proc_address);
INIT_FUNC(dispatch, glUniform4fv, get_proc_address);
INIT_FUNC(dispatch, glUniformMatrix3fv, get_proc_address);
INIT_FUNC(dispatch, glCreateProgram, get_proc_address);
INIT_FUNC(dispatch, glDeleteProgram, get_proc_address);
INIT_FUNC(dispatch, glCreateShader, get_proc_address);
......
......@@ -60,7 +60,7 @@ typedef struct glamor_gl_dispatch {
const GLvoid * data, GLenum usage);
GLvoid *(*glMapBuffer) (GLenum target, GLenum access);
GLvoid *(*glMapBufferRange) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
GLboolean(*glUnmapBuffer) (GLenum target);
GLboolean (*glUnmapBuffer) (GLenum target);
void (*glBindBuffer) (GLenum target, GLuint buffer);
void (*glDeleteBuffers) (GLsizei n, const GLuint * buffers);
......@@ -71,7 +71,7 @@ typedef struct glamor_gl_dispatch {
void (*glDeleteFramebuffers) (GLsizei n,
const GLuint * framebuffers);
void (*glGenFramebuffers) (GLsizei n, GLuint * framebuffers);
GLenum(*glCheckFramebufferStatus) (GLenum target);
GLenum (*glCheckFramebufferStatus) (GLenum target);
void (*glBlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1,
GLint srcY1, GLint dstX0, GLint dstY0,
GLint dstX1, GLint dstY1,
......@@ -92,6 +92,7 @@ typedef struct glamor_gl_dispatch {
const GLint * length);
void (*glUseProgram) (GLuint program);
void (*glUniform1i) (GLint location, GLint v0);
void (*glUniform1f) (GLint location, GLfloat v0);
void (*glUniform4f) (GLint location, GLfloat v0, GLfloat v1,
GLfloat v2, GLfloat v3);
void (*glUniform1fv) (GLint location, GLsizei count,
......@@ -100,9 +101,11 @@ typedef struct glamor_gl_dispatch {
const GLfloat * value);
void (*glUniform4fv) (GLint location, GLsizei count,
const GLfloat * value);
GLuint(*glCreateProgram) (void);
GLuint(*glDeleteProgram) (GLuint);
GLuint(*glCreateShader) (GLenum type);
void (*glUniformMatrix3fv) (GLint location, GLsizei count,
GLboolean transpose, const GLfloat* value);
GLuint (*glCreateProgram) (void);
GLuint (*glDeleteProgram) (GLuint);
GLuint (*glCreateShader) (GLenum type);
void (*glCompileShader) (GLuint shader);
void (*glAttachShader) (GLuint program, GLuint shader);
void (*glGetShaderiv) (GLuint shader, GLenum pname,
......@@ -113,7 +116,7 @@ typedef struct glamor_gl_dispatch {
GLint * params);
void (*glGetProgramInfoLog) (GLuint program, GLsizei bufSize,
GLsizei * length, GLchar * infoLog);
GLint(*glGetUniformLocation) (GLuint program,
GLint (*glGetUniformLocation) (GLuint program,
const GLchar * name);
} glamor_gl_dispatch;
......
......@@ -123,6 +123,13 @@ enum shader_in {
SHADER_IN_COUNT,
};
enum gradient_shader_type {
GRADIENT_SHADER_LINEAR,
GRADIENT_SHADER_RADIAL,
GRADIENT_SHADER_CONICAL,
GRADIENT_SHADER_COUNT,
};
struct glamor_screen_private;
struct glamor_pixmap_private;
typedef void (*glamor_pixmap_validate_function_t) (struct
......@@ -221,6 +228,9 @@ typedef struct glamor_screen_private {
GLint tile_prog;
GLint tile_wh;
/* glamor gradient */
GLint gradient_prog[GRADIENT_SHADER_COUNT];
/* glamor_putimage */
GLint put_image_xybitmap_prog;
GLint put_image_xybitmap_fg_uniform_location;
......@@ -562,6 +572,9 @@ Bool glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
void glamor_init_tile_shader(ScreenPtr screen);
void glamor_fini_tile_shader(ScreenPtr screen);
void glamor_init_gradient_shader(ScreenPtr screen);
void glamor_fini_gradient_shader(ScreenPtr screen);
/* glamor_triangles.c */
void
......
......@@ -1275,6 +1275,28 @@ done:
return ret;
}
void
glamor_init_gradient_shader(ScreenPtr screen)
{
glamor_screen_private *glamor_priv;
glamor_priv = glamor_get_screen_private(screen);
}
void
glamor_fini_gradient_shader(ScreenPtr screen)
{
glamor_screen_private *glamor_priv;
glamor_gl_dispatch *dispatch;
glamor_priv = glamor_get_screen_private(screen);
dispatch = glamor_get_dispatch(glamor_priv);
glamor_put_dispatch(glamor_priv);
}
static PicturePtr
glamor_convert_gradient_picture(ScreenPtr screen,
PicturePtr source,
......
......@@ -99,6 +99,24 @@
(vertices)[7] = (vertices)[5]; \
} while(0)
#define glamor_set_tcoords(x1, y1, x2, y2, yInverted, vertices) \
do { \
(vertices)[0] = (x1); \
(vertices)[2] = (x2); \
(vertices)[4] = (vertices)[2]; \
(vertices)[6] = (vertices)[0]; \
if (yInverted) { \
(vertices)[1] = (y1); \
(vertices)[5] = (y2); \
} \
else { \
(vertices)[1] = (y2); \
(vertices)[5] = (y1); \
} \
(vertices)[3] = (vertices)[1]; \
(vertices)[7] = (vertices)[5]; \
} while(0)
#define glamor_set_normalize_vcoords(xscale, yscale, x1, y1, x2, y2, \
yInverted, vertices) \
......@@ -119,6 +137,17 @@
(vertices)[7] = (vertices)[5]; \
} while(0)
#define glamor_set_normalize_pt(xscale, yscale, x, x_start, y, y_start, \
yInverted, pt) \
do { \
(pt)[0] = t_from_x_coord_x(xscale, x - x_start); \
if (yInverted) { \
(pt)[1] = t_from_x_coord_y_inverted(yscale, y - y_start); \
} else { \
(pt)[1] = t_from_x_coord_y(yscale, y - y_start); \
} \
(pt)[2] = (pt)[3] = 0.0; \
} while(0)
inline static void
glamor_calculate_boxes_bound(BoxPtr bound, BoxPtr boxes, int nbox)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment