compositor: Move shader setup to weston_surface_draw()
diff --git a/src/compositor.c b/src/compositor.c
index bccd372..427d217 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -223,6 +223,7 @@
 
 	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 @@
 		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 @@
 {
 	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 @@
 	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 @@
 	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 @@
 
 	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);