window: move buffer type and transform into struct surface
These are surface specifics, since buffers are surface specific. SURFACE_HINT_RESIZE is moved together to the other SURFACE_* flags, so that surface_create_surface() would not need two flags arguments. struct toysurface::prepare vfunc checks for SURFACE_HINT_RESIZE, and egl_window_surface_create() and shm_surface_create() check for the non-HINT flags. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
committed by
Kristian Høgsberg
parent
811ec4ff31
commit
02bba7ceb0
+43
-38
@@ -145,10 +145,6 @@ struct window_output {
|
|||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum toysurface_prepare_flags {
|
|
||||||
SURFACE_HINT_RESIZE = 0x01,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct toysurface {
|
struct toysurface {
|
||||||
/*
|
/*
|
||||||
* Prepare the surface for drawing. Makes sure there is a surface
|
* Prepare the surface for drawing. Makes sure there is a surface
|
||||||
@@ -197,6 +193,9 @@ struct surface {
|
|||||||
|
|
||||||
struct rectangle allocation;
|
struct rectangle allocation;
|
||||||
struct rectangle server_allocation;
|
struct rectangle server_allocation;
|
||||||
|
|
||||||
|
enum window_buffer_type buffer_type;
|
||||||
|
enum wl_output_transform buffer_transform;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct window {
|
struct window {
|
||||||
@@ -219,8 +218,6 @@ struct window {
|
|||||||
int transparent;
|
int transparent;
|
||||||
int focus_count;
|
int focus_count;
|
||||||
|
|
||||||
enum window_buffer_type buffer_type;
|
|
||||||
enum wl_output_transform buffer_transform;
|
|
||||||
cairo_surface_t *cairo_surface;
|
cairo_surface_t *cairo_surface;
|
||||||
|
|
||||||
int resizing;
|
int resizing;
|
||||||
@@ -1221,18 +1218,13 @@ window_get_display(struct window *window)
|
|||||||
return window->display;
|
return window->display;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static cairo_surface_t *
|
||||||
window_create_surface(struct window *window)
|
surface_create_surface(struct surface *surface, int dx, int dy, uint32_t flags)
|
||||||
{
|
{
|
||||||
struct surface *surface = window->main_surface;
|
struct display *display = surface->window->display;
|
||||||
struct rectangle allocation = surface->allocation;
|
struct rectangle allocation = surface->allocation;
|
||||||
uint32_t flags = 0;
|
|
||||||
int dx, dy;
|
|
||||||
|
|
||||||
if (!window->transparent)
|
switch (surface->buffer_transform) {
|
||||||
flags = SURFACE_OPAQUE;
|
|
||||||
|
|
||||||
switch (window->buffer_transform) {
|
|
||||||
case WL_OUTPUT_TRANSFORM_90:
|
case WL_OUTPUT_TRANSFORM_90:
|
||||||
case WL_OUTPUT_TRANSFORM_270:
|
case WL_OUTPUT_TRANSFORM_270:
|
||||||
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
||||||
@@ -1244,45 +1236,54 @@ window_create_surface(struct window *window)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!surface->toysurface &&
|
if (!surface->toysurface && display->dpy &&
|
||||||
window->buffer_type == WINDOW_BUFFER_TYPE_EGL_WINDOW &&
|
surface->buffer_type == WINDOW_BUFFER_TYPE_EGL_WINDOW) {
|
||||||
window->display->dpy) {
|
|
||||||
surface->toysurface =
|
surface->toysurface =
|
||||||
egl_window_surface_create(window->display,
|
egl_window_surface_create(display,
|
||||||
surface->surface,
|
surface->surface,
|
||||||
flags,
|
flags,
|
||||||
&allocation);
|
&allocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!surface->toysurface)
|
if (!surface->toysurface)
|
||||||
surface->toysurface = shm_surface_create(window->display,
|
surface->toysurface = shm_surface_create(display,
|
||||||
surface->surface,
|
surface->surface,
|
||||||
flags, &allocation);
|
flags, &allocation);
|
||||||
|
|
||||||
|
return surface->toysurface->prepare(surface->toysurface, dx, dy,
|
||||||
|
allocation.width,
|
||||||
|
allocation.height,
|
||||||
|
flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
window_create_surface(struct window *window)
|
||||||
|
{
|
||||||
|
uint32_t flags = 0;
|
||||||
|
int dx, dy;
|
||||||
|
|
||||||
|
if (!window->transparent)
|
||||||
|
flags |= SURFACE_OPAQUE;
|
||||||
|
|
||||||
if (window->resizing)
|
if (window->resizing)
|
||||||
flags = SURFACE_HINT_RESIZE;
|
flags |= SURFACE_HINT_RESIZE;
|
||||||
else
|
|
||||||
flags = 0;
|
|
||||||
|
|
||||||
window_get_resize_dx_dy(window, &dx, &dy);
|
window_get_resize_dx_dy(window, &dx, &dy);
|
||||||
window->cairo_surface =
|
window->cairo_surface =
|
||||||
surface->toysurface->prepare(surface->toysurface, dx, dy,
|
surface_create_surface(window->main_surface, dx, dy, flags);
|
||||||
allocation.width,
|
|
||||||
allocation.height,
|
|
||||||
flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
window_get_buffer_transform(struct window *window)
|
window_get_buffer_transform(struct window *window)
|
||||||
{
|
{
|
||||||
return window->buffer_transform;
|
return window->main_surface->buffer_transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_buffer_transform(struct window *window,
|
window_set_buffer_transform(struct window *window,
|
||||||
enum wl_output_transform transform)
|
enum wl_output_transform transform)
|
||||||
{
|
{
|
||||||
window->buffer_transform = transform;
|
window->main_surface->buffer_transform = transform;
|
||||||
wl_surface_set_buffer_transform(window->main_surface->surface,
|
wl_surface_set_buffer_transform(window->main_surface->surface,
|
||||||
transform);
|
transform);
|
||||||
}
|
}
|
||||||
@@ -3598,6 +3599,7 @@ window_create_internal(struct display *display,
|
|||||||
struct window *parent, int type)
|
struct window *parent, int type)
|
||||||
{
|
{
|
||||||
struct window *window;
|
struct window *window;
|
||||||
|
struct surface *surface;
|
||||||
|
|
||||||
window = malloc(sizeof *window);
|
window = malloc(sizeof *window);
|
||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
@@ -3606,11 +3608,14 @@ window_create_internal(struct display *display,
|
|||||||
memset(window, 0, sizeof *window);
|
memset(window, 0, sizeof *window);
|
||||||
window->display = display;
|
window->display = display;
|
||||||
window->parent = parent;
|
window->parent = parent;
|
||||||
window->main_surface = surface_create(window);
|
|
||||||
|
surface = surface_create(window);
|
||||||
|
window->main_surface = surface;
|
||||||
|
|
||||||
if (type != TYPE_CUSTOM && display->shell) {
|
if (type != TYPE_CUSTOM && display->shell) {
|
||||||
window->shell_surface =
|
window->shell_surface =
|
||||||
wl_shell_get_shell_surface(display->shell,
|
wl_shell_get_shell_surface(display->shell,
|
||||||
window->main_surface->surface);
|
surface->surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
window->transparent = 1;
|
window->transparent = 1;
|
||||||
@@ -3621,14 +3626,14 @@ window_create_internal(struct display *display,
|
|||||||
|
|
||||||
if (display->argb_device)
|
if (display->argb_device)
|
||||||
#ifdef HAVE_CAIRO_EGL
|
#ifdef HAVE_CAIRO_EGL
|
||||||
window->buffer_type = WINDOW_BUFFER_TYPE_EGL_WINDOW;
|
surface->buffer_type = WINDOW_BUFFER_TYPE_EGL_WINDOW;
|
||||||
#else
|
#else
|
||||||
window->buffer_type = WINDOW_BUFFER_TYPE_SHM;
|
surface->buffer_type = WINDOW_BUFFER_TYPE_SHM;
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
window->buffer_type = WINDOW_BUFFER_TYPE_SHM;
|
surface->buffer_type = WINDOW_BUFFER_TYPE_SHM;
|
||||||
|
|
||||||
wl_surface_set_user_data(window->main_surface->surface, window);
|
wl_surface_set_user_data(surface->surface, window);
|
||||||
wl_list_insert(display->window_list.prev, &window->link);
|
wl_list_insert(display->window_list.prev, &window->link);
|
||||||
wl_list_init(&window->redraw_task.link);
|
wl_list_init(&window->redraw_task.link);
|
||||||
|
|
||||||
@@ -3851,7 +3856,7 @@ window_show_menu(struct display *display,
|
|||||||
void
|
void
|
||||||
window_set_buffer_type(struct window *window, enum window_buffer_type type)
|
window_set_buffer_type(struct window *window, enum window_buffer_type type)
|
||||||
{
|
{
|
||||||
window->buffer_type = type;
|
window->main_surface->buffer_type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4499,7 +4504,7 @@ display_acquire_window_surface(struct display *display,
|
|||||||
{
|
{
|
||||||
struct surface *surface = window->main_surface;
|
struct surface *surface = window->main_surface;
|
||||||
|
|
||||||
if (window->buffer_type != WINDOW_BUFFER_TYPE_EGL_WINDOW)
|
if (surface->buffer_type != WINDOW_BUFFER_TYPE_EGL_WINDOW)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return surface->toysurface->acquire(surface->toysurface, ctx);
|
return surface->toysurface->acquire(surface->toysurface, ctx);
|
||||||
@@ -4511,7 +4516,7 @@ display_release_window_surface(struct display *display,
|
|||||||
{
|
{
|
||||||
struct surface *surface = window->main_surface;
|
struct surface *surface = window->main_surface;
|
||||||
|
|
||||||
if (window->buffer_type != WINDOW_BUFFER_TYPE_EGL_WINDOW)
|
if (surface->buffer_type != WINDOW_BUFFER_TYPE_EGL_WINDOW)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
surface->toysurface->release(surface->toysurface);
|
surface->toysurface->release(surface->toysurface);
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ display_release_window_surface(struct display *display,
|
|||||||
#define SURFACE_OPAQUE 0x01
|
#define SURFACE_OPAQUE 0x01
|
||||||
#define SURFACE_SHM 0x02
|
#define SURFACE_SHM 0x02
|
||||||
|
|
||||||
|
#define SURFACE_HINT_RESIZE 0x10
|
||||||
|
|
||||||
cairo_surface_t *
|
cairo_surface_t *
|
||||||
display_create_surface(struct display *display,
|
display_create_surface(struct display *display,
|
||||||
struct wl_surface *surface,
|
struct wl_surface *surface,
|
||||||
|
|||||||
Reference in New Issue
Block a user