Use pixel coordinates for weston_output.matrix

Previously, weston_output.matrix was in GL coordinates and therefore only
really useful for the GL backend.

This breaks zoom, which will be fixed by the following patch:
	zoom: Use pixels instead of GL coordinates

[Pekka: added a comment to compositor.h, message]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
dev
Jason Ekstrand 10 years ago committed by Pekka Paalanen
parent 9808708406
commit fb23df7b35
  1. 82
      src/compositor.c
  2. 3
      src/compositor.h
  3. 14
      src/gl-renderer.c

@ -3773,88 +3773,60 @@ weston_output_destroy(struct weston_output *output)
wl_global_destroy(output->global);
}
static void
weston_output_compute_transform(struct weston_output *output)
WL_EXPORT void
weston_output_update_matrix(struct weston_output *output)
{
struct weston_matrix transform;
int flip;
float magnification;
weston_matrix_init(&transform);
transform.type = WESTON_MATRIX_TRANSFORM_ROTATE;
weston_matrix_init(&output->matrix);
weston_matrix_translate(&output->matrix, -output->x, -output->y, 0);
if (output->zoom.active) {
magnification = 1 / (1 - output->zoom.spring_z.current);
weston_output_update_zoom(output);
weston_matrix_translate(&output->matrix, -output->zoom.trans_x,
-output->zoom.trans_y, 0);
weston_matrix_scale(&output->matrix, magnification,
magnification, 1.0);
}
switch (output->transform) {
case WL_OUTPUT_TRANSFORM_FLIPPED:
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
transform.type |= WESTON_MATRIX_TRANSFORM_OTHER;
flip = -1;
break;
default:
flip = 1;
weston_matrix_translate(&output->matrix, -output->width, 0, 0);
weston_matrix_scale(&output->matrix, -1, 1, 1);
break;
}
switch (output->transform) {
default:
case WL_OUTPUT_TRANSFORM_NORMAL:
case WL_OUTPUT_TRANSFORM_FLIPPED:
transform.d[0] = flip;
transform.d[1] = 0;
transform.d[4] = 0;
transform.d[5] = 1;
break;
case WL_OUTPUT_TRANSFORM_90:
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
transform.d[0] = 0;
transform.d[1] = -flip;
transform.d[4] = 1;
transform.d[5] = 0;
weston_matrix_translate(&output->matrix, 0, -output->height, 0);
weston_matrix_rotate_xy(&output->matrix, 0, 1);
break;
case WL_OUTPUT_TRANSFORM_180:
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
transform.d[0] = -flip;
transform.d[1] = 0;
transform.d[4] = 0;
transform.d[5] = -1;
weston_matrix_translate(&output->matrix,
-output->width, -output->height, 0);
weston_matrix_rotate_xy(&output->matrix, -1, 0);
break;
case WL_OUTPUT_TRANSFORM_270:
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
transform.d[0] = 0;
transform.d[1] = flip;
transform.d[4] = -1;
transform.d[5] = 0;
break;
default:
weston_matrix_translate(&output->matrix, -output->width, 0, 0);
weston_matrix_rotate_xy(&output->matrix, 0, -1);
break;
}
weston_matrix_multiply(&output->matrix, &transform);
}
WL_EXPORT void
weston_output_update_matrix(struct weston_output *output)
{
float magnification;
weston_matrix_init(&output->matrix);
weston_matrix_translate(&output->matrix,
-(output->x + output->width / 2.0),
-(output->y + output->height / 2.0), 0);
if (output->current_scale != 1)
weston_matrix_scale(&output->matrix,
2.0 / output->width,
-2.0 / output->height, 1);
if (output->zoom.active) {
magnification = 1 / (1 - output->zoom.spring_z.current);
weston_output_update_zoom(output);
weston_matrix_translate(&output->matrix, -output->zoom.trans_x,
output->zoom.trans_y, 0);
weston_matrix_scale(&output->matrix, magnification,
magnification, 1.0);
}
weston_output_compute_transform(output);
output->current_scale,
output->current_scale, 1);
output->dirty = 0;
}

@ -182,7 +182,10 @@ struct weston_output {
struct wl_list resource_list;
struct wl_global *global;
struct weston_compositor *compositor;
/** From global to output buffer coordinates. */
struct weston_matrix matrix;
struct wl_list animation_list;
int32_t x, y, width, height;
int32_t mm_width, mm_height;

@ -76,6 +76,8 @@ struct gl_output_state {
enum gl_border_status border_damage[BUFFER_DAMAGE_COUNT];
struct gl_border_image borders[4];
enum gl_border_status border_status;
struct weston_matrix output_matrix;
};
enum buffer_type {
@ -574,9 +576,10 @@ shader_uniforms(struct gl_shader *shader,
{
int i;
struct gl_surface_state *gs = get_surface_state(view->surface);
struct gl_output_state *go = get_output_state(output);
glUniformMatrix4fv(shader->proj_uniform,
1, GL_FALSE, output->matrix.d);
1, GL_FALSE, go->output_matrix.d);
glUniform4fv(shader->color_uniform, 1, gs->color);
glUniform1f(shader->alpha_uniform, view->alpha);
@ -954,6 +957,15 @@ gl_renderer_repaint_output(struct weston_output *output,
output->current_mode->width,
output->current_mode->height);
/* Calculate the global GL matrix */
go->output_matrix = output->matrix;
weston_matrix_translate(&go->output_matrix,
-(output->current_mode->width / 2.0),
-(output->current_mode->height / 2.0), 0);
weston_matrix_scale(&go->output_matrix,
2.0 / output->current_mode->width,
-2.0 / output->current_mode->height, 1);
/* if debugging, redraw everything outside the damage to clean up
* debug lines from the previous draw on this buffer:
*/

Loading…
Cancel
Save