Skip to content
Commits on Source (7)
......@@ -1260,6 +1260,48 @@ output_has_borders(struct weston_output *output)
go->borders[GL_RENDERER_BORDER_LEFT].data;
}
static struct weston_geometry
output_get_border_area(const struct gl_output_state *go,
enum gl_renderer_border_side side)
{
const struct weston_size *fb = &go->fb_size;
const struct weston_geometry *area = &go->area;
switch (side) {
case GL_RENDERER_BORDER_TOP:
return (struct weston_geometry){
.x = 0,
.y = 0,
.width = fb->width,
.height = area->y
};
case GL_RENDERER_BORDER_LEFT:
return (struct weston_geometry){
.x = 0,
.y = area->y,
.width = area->x,
.height = area->height
};
case GL_RENDERER_BORDER_RIGHT:
return (struct weston_geometry){
.x = area->x + area->width,
.y = area->y,
.width = fb->width - area->x - area->width,
.height = area->height
};
case GL_RENDERER_BORDER_BOTTOM:
return (struct weston_geometry){
.x = 0,
.y = area->y + area->height,
.width = fb->width,
.height = fb->height - area->y - area->height
};
}
assert(0);
return (struct weston_geometry){};
}
static void
draw_output_borders(struct weston_output *output,
enum gl_border_status border_status)
......@@ -1274,8 +1316,8 @@ draw_output_borders(struct weston_output *output,
struct weston_color_transform *ctransf;
struct gl_output_state *go = get_output_state(output);
struct gl_renderer *gr = get_renderer(output->compositor);
struct gl_border_image *top, *bottom, *left, *right;
int full_width, full_height;
const struct weston_size *fb = &go->fb_size;
unsigned side;
if (border_status == BORDER_STATUS_CLEAN)
return; /* Clean. Nothing to do. */
......@@ -1286,41 +1328,27 @@ draw_output_borders(struct weston_output *output,
return;
}
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);
glViewport(0, 0, full_width, full_height);
glViewport(0, 0, fb->width, fb->height);
weston_matrix_init(&sconf.projection);
weston_matrix_translate(&sconf.projection,
-full_width / 2.0, -full_height / 2.0, 0);
-fb->width / 2.0, -fb->height / 2.0, 0);
weston_matrix_scale(&sconf.projection,
2.0 / full_width, -2.0 / full_height, 1);
2.0 / fb->width, -2.0 / fb->height, 1);
glActiveTexture(GL_TEXTURE0);
if (border_status & BORDER_TOP_DIRTY)
draw_output_border_texture(gr, go, &sconf, GL_RENDERER_BORDER_TOP,
0, 0,
full_width, top->height);
if (border_status & BORDER_LEFT_DIRTY)
draw_output_border_texture(gr, go, &sconf, GL_RENDERER_BORDER_LEFT,
0, top->height,
left->width, output->current_mode->height);
if (border_status & BORDER_RIGHT_DIRTY)
draw_output_border_texture(gr, go, &sconf, GL_RENDERER_BORDER_RIGHT,
full_width - right->width, top->height,
right->width, output->current_mode->height);
if (border_status & BORDER_BOTTOM_DIRTY)
draw_output_border_texture(gr, go, &sconf, GL_RENDERER_BORDER_BOTTOM,
0, full_height - bottom->height,
full_width, bottom->height);
for (side = 0; side < 4; side++) {
struct weston_geometry g;
if (!(border_status & (1 << side)))
continue;
g = output_get_border_area(go, side);
draw_output_border_texture(gr, go, &sconf, side,
g.x, g.y, g.width, g.height);
}
}
static void
......@@ -1329,35 +1357,18 @@ output_get_border_damage(struct weston_output *output,
pixman_region32_t *damage)
{
struct gl_output_state *go = get_output_state(output);
struct gl_border_image *top, *bottom, *left, *right;
int full_width, full_height;
unsigned side;
if (border_status == BORDER_STATUS_CLEAN)
return; /* Clean. Nothing to do. */
for (side = 0; side < 4; side++) {
struct weston_geometry g;
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];
if (!(border_status & (1 << side)))
continue;
full_width = output->current_mode->width + left->width + right->width;
full_height = output->current_mode->height + top->height + bottom->height;
if (border_status & BORDER_TOP_DIRTY)
g = output_get_border_area(go, side);
pixman_region32_union_rect(damage, damage,
0, 0,
full_width, top->height);
if (border_status & BORDER_LEFT_DIRTY)
pixman_region32_union_rect(damage, damage,
0, top->height,
left->width, output->current_mode->height);
if (border_status & BORDER_RIGHT_DIRTY)
pixman_region32_union_rect(damage, damage,
full_width - right->width, top->height,
right->width, output->current_mode->height);
if (border_status & BORDER_BOTTOM_DIRTY)
pixman_region32_union_rect(damage, damage,
0, full_height - bottom->height,
full_width, bottom->height);
g.x, g.y, g.width, g.height);
}
}
static void
......@@ -1445,7 +1456,6 @@ pixman_region_to_egl_y_invert(struct weston_output *output,
struct gl_output_state *go = get_output_state(output);
pixman_region32_t transformed;
struct pixman_box32 *box;
int buffer_height;
EGLint *d;
int i;
......@@ -1460,8 +1470,7 @@ pixman_region_to_egl_y_invert(struct weston_output *output,
* damage resulting from borders being redrawn. */
if (output_has_borders(output)) {
pixman_region32_translate(&transformed,
go->borders[GL_RENDERER_BORDER_LEFT].width,
go->borders[GL_RENDERER_BORDER_TOP].height);
go->area.x, go->area.y);
output_get_border_damage(output, go->border_status,
&transformed);
}
......@@ -1471,14 +1480,10 @@ pixman_region_to_egl_y_invert(struct weston_output *output,
box = pixman_region32_rectangles(&transformed, nrects);
*rects = malloc(*nrects * 4 * sizeof(EGLint));
buffer_height = go->borders[GL_RENDERER_BORDER_TOP].height +
output->current_mode->height +
go->borders[GL_RENDERER_BORDER_BOTTOM].height;
d = *rects;
for (i = 0; i < *nrects; ++i) {
*d++ = box[i].x1;
*d++ = buffer_height - box[i].y2;
*d++ = go->fb_size.height - box[i].y2;
*d++ = box[i].x2 - box[i].x1;
*d++ = box[i].y2 - box[i].y1;
}
......@@ -1511,8 +1516,8 @@ blit_shadow_to_output(struct weston_output *output,
.input_tex[0] = go->shadow.tex,
};
struct gl_renderer *gr = get_renderer(output->compositor);
double width = output->current_mode->width;
double height = output->current_mode->height;
double width = go->area.width;
double height = go->area.height;
struct weston_color_transform *ctransf;
pixman_box32_t *rects;
int n_rects;
......@@ -1588,6 +1593,8 @@ gl_renderer_repaint_output(struct weston_output *output,
pixman_region32_t total_damage;
enum gl_border_status border_status = BORDER_STATUS_CLEAN;
struct weston_paint_node *pnode;
const int32_t area_inv_y =
go->fb_size.height - go->area.y - go->area.height;
assert(output->from_blend_to_output_by_backend ||
output->color_outcome->from_blend_to_output == NULL ||
......@@ -1617,11 +1624,11 @@ gl_renderer_repaint_output(struct weston_output *output,
/* 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);
-(go->area.width / 2.0),
-(go->area.height / 2.0), 0);
weston_matrix_scale(&go->output_matrix,
2.0 / output->current_mode->width,
-2.0 / output->current_mode->height, 1);
2.0 / go->area.width,
-2.0 / go->area.height, 1);
/* If using shadow, redirect all drawing to it first. */
if (shadow_exists(go)) {
......@@ -1629,10 +1636,8 @@ gl_renderer_repaint_output(struct weston_output *output,
glViewport(0, 0, go->area.width, go->area.height);
} else {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(go->borders[GL_RENDERER_BORDER_LEFT].width,
go->borders[GL_RENDERER_BORDER_BOTTOM].height,
output->current_mode->width,
output->current_mode->height);
glViewport(go->area.x, area_inv_y,
go->area.width, go->area.height);
}
/* In fan debug mode, redraw everything to make sure that we clear any
......@@ -1688,10 +1693,8 @@ gl_renderer_repaint_output(struct weston_output *output,
repaint_views(output, output_damage);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(go->borders[GL_RENDERER_BORDER_LEFT].width,
go->borders[GL_RENDERER_BORDER_BOTTOM].height,
output->current_mode->width,
output->current_mode->height);
glViewport(go->area.x, area_inv_y,
go->area.width, go->area.height);
blit_shadow_to_output(output, &total_damage);
} else {
repaint_views(output, &total_damage);
......@@ -1752,8 +1755,8 @@ gl_renderer_read_pixels(struct weston_output *output,
{
struct gl_output_state *go = get_output_state(output);
x += go->borders[GL_RENDERER_BORDER_LEFT].width;
y += go->borders[GL_RENDERER_BORDER_BOTTOM].height;
x += go->area.x;
y += go->fb_size.height - go->area.y - go->area.height;
if (format->gl_format == 0 || format->gl_type == 0)
return -1;
......