compositor: Move shader setup to weston_surface_draw()
This commit is contained in:
parent
765bcdf1fa
commit
0763262e3d
|
@ -223,6 +223,7 @@ weston_surface_create(struct weston_compositor *compositor,
|
|||
|
||||
surface->compositor = compositor;
|
||||
surface->visual = WESTON_NONE_VISUAL;
|
||||
surface->shader = &compositor->texture_shader;
|
||||
surface->image = EGL_NO_IMAGE_KHR;
|
||||
surface->saved_texture = 0;
|
||||
surface->x = x;
|
||||
|
@ -584,9 +585,19 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output)
|
|||
break;
|
||||
}
|
||||
|
||||
if (ec->current_shader != es->shader) {
|
||||
glUseProgram(es->shader->program);
|
||||
glUniformMatrix4fv(es->shader->proj_uniform,
|
||||
1, GL_FALSE, output->matrix.d);
|
||||
if (es->shader->tex_uniform != GL_NONE)
|
||||
glUniform1i(es->shader->tex_uniform, 0);
|
||||
if (es->shader->color_uniform != GL_NONE)
|
||||
glUniform4fv(es->shader->color_uniform,1, es->color);
|
||||
ec->current_shader = es->shader;
|
||||
}
|
||||
|
||||
if (es->alpha != ec->current_alpha) {
|
||||
glUniform1f(ec->texture_shader.alpha_uniform,
|
||||
es->alpha / 255.0);
|
||||
glUniform1f(es->shader->alpha_uniform, es->alpha / 255.0);
|
||||
ec->current_alpha = es->alpha;
|
||||
}
|
||||
|
||||
|
@ -689,7 +700,6 @@ fade_output(struct weston_output *output,
|
|||
{
|
||||
struct weston_compositor *compositor = output->compositor;
|
||||
struct weston_surface surface;
|
||||
GLfloat color[4] = { 0.0, 0.0, 0.0, tint };
|
||||
|
||||
surface.compositor = compositor;
|
||||
surface.x = output->x;
|
||||
|
@ -700,6 +710,11 @@ fade_output(struct weston_output *output,
|
|||
surface.texture = GL_NONE;
|
||||
surface.transform = NULL;
|
||||
surface.alpha = compositor->current_alpha;
|
||||
surface.shader = &compositor->solid_shader;
|
||||
surface.color[0] = 0.0;
|
||||
surface.color[1] = 0.0;
|
||||
surface.color[2] = 0.0;
|
||||
surface.color[3] = tint;
|
||||
pixman_region32_init(&surface.damage);
|
||||
pixman_region32_copy(&surface.damage, region);
|
||||
|
||||
|
@ -708,10 +723,6 @@ fade_output(struct weston_output *output,
|
|||
else
|
||||
surface.visual = WESTON_RGB_VISUAL;
|
||||
|
||||
glUseProgram(compositor->solid_shader.program);
|
||||
glUniformMatrix4fv(compositor->solid_shader.proj_uniform,
|
||||
1, GL_FALSE, output->matrix.d);
|
||||
glUniform4fv(compositor->solid_shader.color_uniform, 1, color);
|
||||
weston_surface_draw(&surface, output);
|
||||
|
||||
pixman_region32_fini(&surface.damage);
|
||||
|
@ -796,11 +807,6 @@ weston_output_repaint(struct weston_output *output)
|
|||
|
||||
glViewport(0, 0, output->current->width, output->current->height);
|
||||
|
||||
glUseProgram(ec->texture_shader.program);
|
||||
glUniformMatrix4fv(ec->texture_shader.proj_uniform,
|
||||
1, GL_FALSE, output->matrix.d);
|
||||
glUniform1i(ec->texture_shader.tex_uniform, 0);
|
||||
|
||||
weston_output_set_cursor(output, ec->input_device,
|
||||
ec->fade.spring.current >= 0.001);
|
||||
|
||||
|
|
|
@ -172,6 +172,7 @@ struct weston_compositor {
|
|||
uint32_t current_alpha;
|
||||
struct weston_shader texture_shader;
|
||||
struct weston_shader solid_shader;
|
||||
struct weston_shader *current_shader;
|
||||
struct wl_display *wl_display;
|
||||
|
||||
struct weston_shell *shell;
|
||||
|
@ -239,6 +240,8 @@ struct weston_surface {
|
|||
struct wl_list link;
|
||||
struct wl_list buffer_link;
|
||||
struct weston_transform *transform;
|
||||
struct weston_shader *shader;
|
||||
GLfloat color[4];
|
||||
uint32_t alpha;
|
||||
uint32_t visual;
|
||||
int overlapped;
|
||||
|
|
Loading…
Reference in New Issue