[PATCH weston 07/11] Remove the concept of a border from weston_output.

Jason Ekstrand jason at jlekstrand.net
Mon Oct 28 04:24:59 CET 2013


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 at jlekstrand.net>
---
 src/compositor-wayland.c | 10 +--------
 src/compositor.c         | 12 ++++------
 src/compositor.h         |  5 -----
 src/gl-renderer.c        | 57 +++++++++++++++++++++++++++++-------------------
 4 files changed, 39 insertions(+), 45 deletions(-)

diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 4cb19e3..c8268fd 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -570,7 +570,7 @@ static const struct wl_shell_surface_listener shell_surface_listener;
 static int
 wayland_output_init_gl_renderer(struct wayland_output *output)
 {
-	int32_t fx, fy, fwidth, fheight;
+	int32_t fwidth = 0, fheight = 0;
 
 	if (output->frame) {
 		fwidth = frame_width(output->frame);
@@ -592,14 +592,6 @@ wayland_output_init_gl_renderer(struct wayland_output *output)
 			output->gl.egl_window) < 0)
 		goto cleanup_window;
 
-	if (output->frame) {
-		frame_interior(output->frame, &fx, &fy, NULL, NULL);
-		output->base.border.left = fx;
-		output->base.border.top = fy;
-		output->base.border.right = fwidth - output->base.width - fx;
-		output->base.border.bottom = fheight - output->base.height - fy;
-	}
-
 	return 0;
 
 cleanup_window:
diff --git a/src/compositor.c b/src/compositor.c
index 90e865b..418ebb0 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3006,12 +3006,12 @@ weston_output_update_matrix(struct weston_output *output)
 
 	weston_matrix_init(&output->matrix);
 	weston_matrix_translate(&output->matrix,
-				-(output->x + (output->border.right + output->width - output->border.left) / 2.0),
-				-(output->y + (output->border.bottom + output->height - output->border.top) / 2.0), 0);
+				-(output->x + output->width / 2.0),
+				-(output->y + output->height / 2.0), 0);
 
 	weston_matrix_scale(&output->matrix,
-			    2.0 / (output->width + output->border.left + output->border.right),
-			    -2.0 / (output->height + output->border.top + output->border.bottom), 1);
+			    2.0 / output->width,
+			    -2.0 / output->height, 1);
 
 	weston_output_compute_transform(output);
 
@@ -3080,10 +3080,6 @@ weston_output_init(struct weston_output *output, struct weston_compositor *c,
 	output->compositor = c;
 	output->x = x;
 	output->y = y;
-	output->border.top = 0;
-	output->border.bottom = 0;
-	output->border.left = 0;
-	output->border.right = 0;
 	output->mm_width = mm_width;
 	output->mm_height = mm_height;
 	output->dirty = 1;
diff --git a/src/compositor.h b/src/compositor.h
index e60a512..c36b209 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -114,10 +114,6 @@ struct weston_shell_interface {
 
 };
 
-struct weston_border {
-	int32_t left, right, top, bottom;
-};
-
 struct weston_animation {
 	void (*frame)(struct weston_animation *animation,
 		      struct weston_output *output, uint32_t msecs);
@@ -189,7 +185,6 @@ struct weston_output {
 	struct wl_list animation_list;
 	int32_t x, y, width, height;
 	int32_t mm_width, mm_height;
-	struct weston_border border;
 	pixman_region32_t region;
 	pixman_region32_t previous_damage;
 	int repaint_needed;
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 @@ draw_output_border(struct weston_output *output)
 	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 @@ gl_renderer_repaint_output(struct weston_output *output,
 	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;
-- 
1.8.3.1



More information about the wayland-devel mailing list