Remove the concept of a border from weston_output.

The only user for this was the wayland backend with the GL renderer.  It is
not needed in the Pixman renderer because you can easily create subimages.
All of the fancy output matrix calculations can be replaced by a single
glViewport call.  Also, it didn't work with outputs located anywhere but
(0, 0) and I'm pretty sure output transformed outputs would break it too.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index 1b2b1f4..68a071f 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -664,31 +664,44 @@
 	struct gl_output_state *go = get_output_state(output);
 	struct gl_renderer *gr = get_renderer(output->compositor);
 	struct gl_shader *shader = &gr->texture_shader_rgba;
-	int32_t full_width;
+	struct gl_border_image *top, *bottom, *left, *right;
+	struct weston_matrix matrix;
+	int full_width, full_height;
+
+	top = &go->borders[GL_RENDERER_BORDER_TOP];
+	bottom = &go->borders[GL_RENDERER_BORDER_BOTTOM];
+	left = &go->borders[GL_RENDERER_BORDER_LEFT];
+	right = &go->borders[GL_RENDERER_BORDER_RIGHT];
+
+	full_width = output->current_mode->width + left->width + right->width;
+	full_height = output->current_mode->height + top->height + bottom->height;
 
 	glDisable(GL_BLEND);
 	use_shader(gr, shader);
 
-	glUniformMatrix4fv(shader->proj_uniform,
-			   1, GL_FALSE, output->matrix.d);
+	glViewport(0, 0, full_width, full_height);
+
+	weston_matrix_init(&matrix);
+	weston_matrix_translate(&matrix, -full_width/2.0, -full_height/2.0, 0);
+	weston_matrix_scale(&matrix, 2.0/full_width, -2.0/full_height, 1);
+	glUniformMatrix4fv(shader->proj_uniform, 1, GL_FALSE, matrix.d);
 
 	glUniform1i(shader->tex_uniforms[0], 0);
 	glUniform1f(shader->alpha_uniform, 1);
 	glActiveTexture(GL_TEXTURE0);
 
-	full_width = output->width + output->border.left + output->border.right;
-	draw_output_border_texture(&go->borders[GL_RENDERER_BORDER_TOP],
-				   -output->border.left, -output->border.top,
-				   full_width, output->border.top);
-	draw_output_border_texture(&go->borders[GL_RENDERER_BORDER_LEFT],
-				   -output->border.left, 0,
-				   output->border.left, output->height);
-	draw_output_border_texture(&go->borders[GL_RENDERER_BORDER_RIGHT],
-				   output->width, 0,
-				   output->border.right, output->height);
-	draw_output_border_texture(&go->borders[GL_RENDERER_BORDER_BOTTOM],
-				   -output->border.left, output->height,
-				   full_width, output->border.bottom);
+	draw_output_border_texture(top,
+				   0, 0,
+				   full_width, top->height);
+	draw_output_border_texture(left,
+				   0, top->height,
+				   left->width, output->current_mode->height);
+	draw_output_border_texture(right,
+				   full_width - right->width, top->height,
+				   right->width, output->current_mode->height);
+	draw_output_border_texture(bottom,
+				   0, full_height - bottom->height,
+				   full_width, bottom->height);
 }
 
 static void
@@ -745,15 +758,13 @@
 	struct gl_renderer *gr = get_renderer(compositor);
 	EGLBoolean ret;
 	static int errored;
-	int32_t width, height;
 	pixman_region32_t buffer_damage, total_damage;
 
-	width = output->current_mode->width +
-		output->border.left + output->border.right;
-	height = output->current_mode->height +
-		output->border.top + output->border.bottom;
-
-	glViewport(0, 0, width, height);
+	/* Calculate the viewport */
+	glViewport(go->borders[GL_RENDERER_BORDER_LEFT].width,
+		   go->borders[GL_RENDERER_BORDER_BOTTOM].height,
+		   output->current_mode->width,
+		   output->current_mode->height);
 
 	if (use_output(output) < 0)
 		return;