compositor: Move surface color state to gles2-renderer.

This moves the surface color state into gles2-renderer. To do this it
adds two new weston_renderer functions. create_surface to be able to
create per-surface renderer state, and surface_set_color to set the
color of a surface and changes it to a color surface.
diff --git a/src/gles2-renderer.c b/src/gles2-renderer.c
index 2a62da2..a02cdac 100644
--- a/src/gles2-renderer.c
+++ b/src/gles2-renderer.c
@@ -35,6 +35,10 @@
 	EGLSurface egl_surface;
 };
 
+struct gles2_surface_state {
+	GLfloat color[4];
+};
+
 struct gles2_renderer {
 	struct weston_renderer base;
 	int fragment_shader_debug;
@@ -56,6 +60,12 @@
 	return (struct gles2_output_state *)output->renderer_state;
 }
 
+static inline struct gles2_surface_state *
+get_surface_state(struct weston_surface *surface)
+{
+	return (struct gles2_surface_state *)surface->renderer_state;
+}
+
 static inline struct gles2_renderer *
 get_renderer(struct weston_compositor *ec)
 {
@@ -648,10 +658,11 @@
 		       struct weston_output *output)
 {
 	int i;
+	struct gles2_surface_state *gs = get_surface_state(surface);
 
 	glUniformMatrix4fv(shader->proj_uniform,
 			   1, GL_FALSE, output->matrix.d);
-	glUniform4fv(shader->color_uniform, 1, surface->color);
+	glUniform4fv(shader->color_uniform, 1, gs->color);
 	glUniform1f(shader->alpha_uniform, surface->alpha);
 
 	for (i = 0; i < surface->num_textures; i++)
@@ -1123,8 +1134,38 @@
 }
 
 static void
+gles2_renderer_surface_set_color(struct weston_surface *surface,
+		 float red, float green, float blue, float alpha)
+{
+	struct gles2_surface_state *gs = get_surface_state(surface);
+
+	gs->color[0] = red;
+	gs->color[1] = green;
+	gs->color[2] = blue;
+	gs->color[3] = alpha;
+
+	surface->shader = &surface->compositor->solid_shader;
+}
+
+static int
+gles2_renderer_create_surface(struct weston_surface *surface)
+{
+	struct gles2_surface_state *gs;
+
+	gs = calloc(1, sizeof *gs);
+
+	if (!gs)
+		return -1;
+
+	surface->renderer_state = gs;
+
+	return 0;
+}
+
+static void
 gles2_renderer_destroy_surface(struct weston_surface *surface)
 {
+	struct gles2_surface_state *gs = get_surface_state(surface);
 	struct weston_compositor *ec = surface->compositor;
 	struct gles2_renderer *gr = get_renderer(ec);
 	int i;
@@ -1133,6 +1174,8 @@
 
 	for (i = 0; i < surface->num_images; i++)
 		ec->destroy_image(gr->egl_display, surface->images[i]);
+
+	free(gs);
 }
 
 static const char vertex_shader[] =
@@ -1600,6 +1643,8 @@
 	gr->base.repaint_output = gles2_renderer_repaint_output;
 	gr->base.flush_damage = gles2_renderer_flush_damage;
 	gr->base.attach = gles2_renderer_attach;
+	gr->base.create_surface = gles2_renderer_create_surface;
+	gr->base.surface_set_color = gles2_renderer_surface_set_color;
 	gr->base.destroy_surface = gles2_renderer_destroy_surface;
 
 	gr->egl_display = eglGetDisplay(display);