mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-03-30 11:11:05 -04:00
Stop using surface::copy in window
This commit is contained in:
parent
6a1b20102c
commit
2aac302bd9
2 changed files with 49 additions and 26 deletions
14
terminal.c
14
terminal.c
|
|
@ -57,7 +57,6 @@ struct terminal {
|
||||||
char *data;
|
char *data;
|
||||||
int width, height, start, row, column;
|
int width, height, start, row, column;
|
||||||
int fd, master;
|
int fd, master;
|
||||||
cairo_surface_t *surface;
|
|
||||||
GIOChannel *channel;
|
GIOChannel *channel;
|
||||||
uint32_t modifiers;
|
uint32_t modifiers;
|
||||||
char escape[64];
|
char escape[64];
|
||||||
|
|
@ -135,13 +134,13 @@ terminal_draw_contents(struct terminal *terminal)
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
cairo_font_extents_t extents;
|
cairo_font_extents_t extents;
|
||||||
int i, top_margin, side_margin;
|
int i, top_margin, side_margin;
|
||||||
|
cairo_surface_t *surface;
|
||||||
double d;
|
double d;
|
||||||
|
|
||||||
window_get_child_rectangle(terminal->window, &rectangle);
|
window_get_child_rectangle(terminal->window, &rectangle);
|
||||||
|
|
||||||
terminal->surface =
|
surface = window_create_surface(terminal->window, &rectangle);
|
||||||
window_create_surface(terminal->window, &rectangle);
|
cr = cairo_create(surface);
|
||||||
cr = cairo_create(terminal->surface);
|
|
||||||
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
|
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
|
||||||
cairo_set_source_rgba(cr,
|
cairo_set_source_rgba(cr,
|
||||||
terminal->color_scheme->bg.r,
|
terminal->color_scheme->bg.r,
|
||||||
|
|
@ -190,7 +189,9 @@ terminal_draw_contents(struct terminal *terminal)
|
||||||
|
|
||||||
window_copy_surface(terminal->window,
|
window_copy_surface(terminal->window,
|
||||||
&rectangle,
|
&rectangle,
|
||||||
terminal->surface);
|
surface);
|
||||||
|
|
||||||
|
cairo_surface_destroy(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -426,9 +427,6 @@ handle_acknowledge(void *data,
|
||||||
struct terminal *terminal = data;
|
struct terminal *terminal = data;
|
||||||
|
|
||||||
terminal->redraw_scheduled = 0;
|
terminal->redraw_scheduled = 0;
|
||||||
if (key == 0)
|
|
||||||
cairo_surface_destroy(terminal->surface);
|
|
||||||
|
|
||||||
if (terminal->redraw_pending) {
|
if (terminal->redraw_pending) {
|
||||||
terminal->redraw_pending = 0;
|
terminal->redraw_pending = 0;
|
||||||
terminal_schedule_redraw(terminal);
|
terminal_schedule_redraw(terminal);
|
||||||
|
|
|
||||||
61
window.c
61
window.c
|
|
@ -92,6 +92,12 @@ window_attach_surface(struct window *window)
|
||||||
{
|
{
|
||||||
struct wl_visual *visual;
|
struct wl_visual *visual;
|
||||||
|
|
||||||
|
if (window->pending_surface != NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
window->pending_surface =
|
||||||
|
cairo_surface_reference(window->cairo_surface);
|
||||||
|
|
||||||
visual = wl_display_get_premultiplied_argb_visual(window->display->display);
|
visual = wl_display_get_premultiplied_argb_visual(window->display->display);
|
||||||
wl_surface_attach(window->surface,
|
wl_surface_attach(window->surface,
|
||||||
cairo_drm_surface_get_name(window->cairo_surface),
|
cairo_drm_surface_get_name(window->cairo_surface),
|
||||||
|
|
@ -223,6 +229,9 @@ window_draw_fullscreen(struct window *window)
|
||||||
void
|
void
|
||||||
window_draw(struct window *window)
|
window_draw(struct window *window)
|
||||||
{
|
{
|
||||||
|
if (window->cairo_surface != NULL)
|
||||||
|
cairo_surface_destroy(window->cairo_surface);
|
||||||
|
|
||||||
if (window->fullscreen)
|
if (window->fullscreen)
|
||||||
window_draw_fullscreen(window);
|
window_draw_fullscreen(window);
|
||||||
else
|
else
|
||||||
|
|
@ -235,15 +244,19 @@ window_handle_acknowledge(void *data,
|
||||||
uint32_t key, uint32_t frame)
|
uint32_t key, uint32_t frame)
|
||||||
{
|
{
|
||||||
struct window *window = data;
|
struct window *window = data;
|
||||||
|
cairo_surface_t *pending;
|
||||||
|
|
||||||
/* The acknowledge event means that the server
|
/* The acknowledge event means that the server
|
||||||
* processed our last commit request and we can now
|
* processed our last commit request and we can now
|
||||||
* safely free the old window buffer if we resized and
|
* safely free the old window buffer if we resized and
|
||||||
* render the next frame into our back buffer.. */
|
* render the next frame into our back buffer.. */
|
||||||
|
|
||||||
if (key == 0 && window->cairo_surface != NULL) {
|
if (key == 0) {
|
||||||
cairo_surface_destroy(window->cairo_surface);
|
pending = window->pending_surface;
|
||||||
window->cairo_surface = NULL;
|
window->pending_surface = NULL;
|
||||||
|
if (pending != window->cairo_surface)
|
||||||
|
window_attach_surface(window);
|
||||||
|
cairo_surface_destroy(pending);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -568,13 +581,23 @@ window_copy(struct window *window,
|
||||||
struct rectangle *rectangle,
|
struct rectangle *rectangle,
|
||||||
uint32_t name, uint32_t stride)
|
uint32_t name, uint32_t stride)
|
||||||
{
|
{
|
||||||
wl_surface_copy(window->surface,
|
cairo_surface_t *surface;
|
||||||
rectangle->x,
|
cairo_t *cr;
|
||||||
rectangle->y,
|
|
||||||
name, stride,
|
surface = cairo_drm_surface_create_for_name (window->display->device,
|
||||||
0, 0,
|
name, CAIRO_CONTENT_COLOR_ALPHA,
|
||||||
rectangle->width,
|
rectangle->width, rectangle->height,
|
||||||
rectangle->height);
|
stride);
|
||||||
|
|
||||||
|
cr = cairo_create (window->cairo_surface);
|
||||||
|
|
||||||
|
cairo_set_source_surface (cr,
|
||||||
|
surface,
|
||||||
|
rectangle->x, rectangle->y);
|
||||||
|
|
||||||
|
cairo_paint (cr);
|
||||||
|
cairo_destroy (cr);
|
||||||
|
cairo_surface_destroy (surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -582,14 +605,16 @@ window_copy_surface(struct window *window,
|
||||||
struct rectangle *rectangle,
|
struct rectangle *rectangle,
|
||||||
cairo_surface_t *surface)
|
cairo_surface_t *surface)
|
||||||
{
|
{
|
||||||
wl_surface_copy(window->surface,
|
cairo_t *cr;
|
||||||
rectangle->x,
|
|
||||||
rectangle->y,
|
cr = cairo_create (window->cairo_surface);
|
||||||
cairo_drm_surface_get_name(surface),
|
|
||||||
cairo_drm_surface_get_stride(surface),
|
cairo_set_source_surface (cr,
|
||||||
0, 0,
|
surface,
|
||||||
rectangle->width,
|
rectangle->x, rectangle->y);
|
||||||
rectangle->height);
|
|
||||||
|
cairo_paint (cr);
|
||||||
|
cairo_destroy (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue