mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Set decorations as opaque, to optimise composition
This commit is contained in:
parent
dfc7eacd50
commit
a0dbffb8f2
@ -224,9 +224,12 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image)
|
|||||||
|
|
||||||
static void createDecoration(_GLFWdecorationWayland* decoration,
|
static void createDecoration(_GLFWdecorationWayland* decoration,
|
||||||
struct wl_surface* parent,
|
struct wl_surface* parent,
|
||||||
struct wl_buffer* buffer, int x, int y,
|
struct wl_buffer* buffer, GLFWbool opaque,
|
||||||
|
int x, int y,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
{
|
{
|
||||||
|
struct wl_region* region;
|
||||||
|
|
||||||
decoration->surface = wl_compositor_create_surface(_glfw.wl.compositor);
|
decoration->surface = wl_compositor_create_surface(_glfw.wl.compositor);
|
||||||
decoration->subsurface =
|
decoration->subsurface =
|
||||||
wl_subcompositor_get_subsurface(_glfw.wl.subcompositor,
|
wl_subcompositor_get_subsurface(_glfw.wl.subcompositor,
|
||||||
@ -236,6 +239,16 @@ static void createDecoration(_GLFWdecorationWayland* decoration,
|
|||||||
decoration->surface);
|
decoration->surface);
|
||||||
wp_viewport_set_destination(decoration->viewport, width, height);
|
wp_viewport_set_destination(decoration->viewport, width, height);
|
||||||
wl_surface_attach(decoration->surface, buffer, 0, 0);
|
wl_surface_attach(decoration->surface, buffer, 0, 0);
|
||||||
|
|
||||||
|
if (opaque)
|
||||||
|
{
|
||||||
|
region = wl_compositor_create_region(_glfw.wl.compositor);
|
||||||
|
wl_region_add(region, 0, 0, width, height);
|
||||||
|
wl_surface_set_opaque_region(decoration->surface, region);
|
||||||
|
wl_surface_commit(decoration->surface);
|
||||||
|
wl_region_destroy(region);
|
||||||
|
}
|
||||||
|
else
|
||||||
wl_surface_commit(decoration->surface);
|
wl_surface_commit(decoration->surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,6 +256,7 @@ static void createDecorations(_GLFWwindow* window)
|
|||||||
{
|
{
|
||||||
unsigned char data[] = { 224, 224, 224, 255 };
|
unsigned char data[] = { 224, 224, 224, 255 };
|
||||||
const GLFWimage image = { 1, 1, data };
|
const GLFWimage image = { 1, 1, data };
|
||||||
|
GLFWbool opaque = (data[3] == 255);
|
||||||
|
|
||||||
if (!_glfw.wl.viewporter)
|
if (!_glfw.wl.viewporter)
|
||||||
return;
|
return;
|
||||||
@ -251,19 +265,19 @@ static void createDecorations(_GLFWwindow* window)
|
|||||||
window->wl.decorations.buffer = createShmBuffer(&image);
|
window->wl.decorations.buffer = createShmBuffer(&image);
|
||||||
|
|
||||||
createDecoration(&window->wl.decorations.top, window->wl.surface,
|
createDecoration(&window->wl.decorations.top, window->wl.surface,
|
||||||
window->wl.decorations.buffer,
|
window->wl.decorations.buffer, opaque,
|
||||||
0, -_GLFW_DECORATION_TOP,
|
0, -_GLFW_DECORATION_TOP,
|
||||||
window->wl.width, _GLFW_DECORATION_TOP);
|
window->wl.width, _GLFW_DECORATION_TOP);
|
||||||
createDecoration(&window->wl.decorations.left, window->wl.surface,
|
createDecoration(&window->wl.decorations.left, window->wl.surface,
|
||||||
window->wl.decorations.buffer,
|
window->wl.decorations.buffer, opaque,
|
||||||
-_GLFW_DECORATION_WIDTH, -_GLFW_DECORATION_TOP,
|
-_GLFW_DECORATION_WIDTH, -_GLFW_DECORATION_TOP,
|
||||||
_GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
|
_GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
|
||||||
createDecoration(&window->wl.decorations.right, window->wl.surface,
|
createDecoration(&window->wl.decorations.right, window->wl.surface,
|
||||||
window->wl.decorations.buffer,
|
window->wl.decorations.buffer, opaque,
|
||||||
window->wl.width, -_GLFW_DECORATION_TOP,
|
window->wl.width, -_GLFW_DECORATION_TOP,
|
||||||
_GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
|
_GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
|
||||||
createDecoration(&window->wl.decorations.bottom, window->wl.surface,
|
createDecoration(&window->wl.decorations.bottom, window->wl.surface,
|
||||||
window->wl.decorations.buffer,
|
window->wl.decorations.buffer, opaque,
|
||||||
-_GLFW_DECORATION_WIDTH, window->wl.height,
|
-_GLFW_DECORATION_WIDTH, window->wl.height,
|
||||||
window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH);
|
window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user