2014-06-16 11:34:55 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2011-2014 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software
|
|
|
|
|
* and its documentation for any purpose is hereby granted without
|
|
|
|
|
* fee, provided that the above copyright notice appear in all copies
|
|
|
|
|
* and that both that copyright notice and this permission notice
|
|
|
|
|
* appear in supporting documentation, and that the name of the
|
|
|
|
|
* copyright holders not be used in advertising or publicity
|
|
|
|
|
* pertaining to distribution of the software without specific,
|
|
|
|
|
* written prior permission. The copyright holders make no
|
|
|
|
|
* representations about the suitability of this software for any
|
|
|
|
|
* purpose. It is provided "as is" without express or implied
|
|
|
|
|
* warranty.
|
|
|
|
|
*
|
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
|
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
|
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
|
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
|
|
|
|
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
|
* SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "xwayland.h"
|
|
|
|
|
|
|
|
|
|
#define MESA_EGL_NO_X11_HEADERS
|
2016-10-05 12:34:34 -04:00
|
|
|
#include <glamor_egl.h>
|
2014-06-16 11:34:55 -07:00
|
|
|
|
|
|
|
|
#include <glamor.h>
|
|
|
|
|
#include <glamor_context.h>
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_glamor_egl_make_current(struct glamor_context *glamor_ctx)
|
|
|
|
|
{
|
|
|
|
|
eglMakeCurrent(glamor_ctx->display, EGL_NO_SURFACE,
|
|
|
|
|
EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
|
|
|
if (!eglMakeCurrent(glamor_ctx->display,
|
|
|
|
|
EGL_NO_SURFACE, EGL_NO_SURFACE,
|
|
|
|
|
glamor_ctx->ctx))
|
|
|
|
|
FatalError("Failed to make EGL context current\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_screen *xwl_screen = xwl_screen_get(screen);
|
|
|
|
|
|
|
|
|
|
glamor_ctx->ctx = xwl_screen->egl_context;
|
|
|
|
|
glamor_ctx->display = xwl_screen->egl_display;
|
|
|
|
|
|
|
|
|
|
glamor_ctx->make_current = xwl_glamor_egl_make_current;
|
|
|
|
|
|
|
|
|
|
xwl_screen->glamor_ctx = glamor_ctx;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-20 14:38:03 -04:00
|
|
|
void
|
|
|
|
|
xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
|
|
|
|
|
struct wl_registry *registry,
|
|
|
|
|
uint32_t id, const char *interface,
|
|
|
|
|
uint32_t version)
|
2014-06-16 11:34:55 -07:00
|
|
|
{
|
2018-04-20 14:38:03 -04:00
|
|
|
if (xwl_screen->egl_backend.init_wl_registry)
|
|
|
|
|
xwl_screen->egl_backend.init_wl_registry(xwl_screen, registry,
|
|
|
|
|
interface, id, version);
|
2014-06-16 11:34:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct wl_buffer *
|
2018-03-13 16:00:52 +01:00
|
|
|
xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap,
|
|
|
|
|
unsigned short width,
|
|
|
|
|
unsigned short height,
|
|
|
|
|
Bool *created)
|
2014-06-16 11:34:55 -07:00
|
|
|
{
|
|
|
|
|
struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
|
|
|
|
|
|
2018-04-20 14:38:03 -04:00
|
|
|
if (xwl_screen->egl_backend.get_wl_buffer_for_pixmap)
|
|
|
|
|
return xwl_screen->egl_backend.get_wl_buffer_for_pixmap(pixmap,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
created);
|
2014-06-16 11:34:55 -07:00
|
|
|
|
2018-04-20 14:38:03 -04:00
|
|
|
return NULL;
|
2014-06-16 11:34:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
|
xwl_glamor_create_screen_resources(ScreenPtr screen)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_screen *xwl_screen = xwl_screen_get(screen);
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
screen->CreateScreenResources = xwl_screen->CreateScreenResources;
|
|
|
|
|
ret = (*screen->CreateScreenResources) (screen);
|
|
|
|
|
xwl_screen->CreateScreenResources = screen->CreateScreenResources;
|
|
|
|
|
screen->CreateScreenResources = xwl_glamor_create_screen_resources;
|
|
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
|
return ret;
|
|
|
|
|
|
2015-11-23 08:51:48 +01:00
|
|
|
if (xwl_screen->rootless) {
|
2014-06-16 11:34:55 -07:00
|
|
|
screen->devPrivate =
|
|
|
|
|
fbCreatePixmap(screen, 0, 0, screen->rootDepth, 0);
|
2015-11-23 08:51:48 +01:00
|
|
|
}
|
2014-06-16 11:34:55 -07:00
|
|
|
else {
|
2018-04-20 14:38:03 -04:00
|
|
|
screen->devPrivate = screen->CreatePixmap(
|
|
|
|
|
screen, screen->width, screen->height, screen->rootDepth,
|
|
|
|
|
CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
|
2014-06-16 11:34:55 -07:00
|
|
|
}
|
|
|
|
|
|
dix: Add hybrid full-size/empty-clip mode to SetRootClip
216bdbc735 removed the SetRootClip call in the XWayland output-hotplug
handler when running rootless (e.g. as a part of Weston/Mutter), since
the root window has no storage, so generating exposures will result in
writes to invalid memory.
Unfortunately, preventing the segfault also breaks sprite confinement.
SetRootClip updates winSize and borderSize for the root window, which
when combined with RRScreenSizeChanged calling ScreenRestructured,
generates a new sprite-confinment area to update it to the whole screen.
Removing this call results in the window geometry being reported
correctly, but winSize/borderSize never changing from their values at
startup, i.e. out of sync with the root window geometry / screen
information in the connection info / XRandR.
This patch introduces a hybrid mode, where we update winSize and
borderSize for the root window, enabling sprite confinement to work
correctly, but keep the clip emptied so exposures are never generated.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-02-12 16:36:59 +00:00
|
|
|
SetRootClip(screen, xwl_screen->root_clip_mode);
|
|
|
|
|
|
2014-06-16 11:34:55 -07:00
|
|
|
return screen->devPrivate != NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2018-02-28 01:19:43 +00:00
|
|
|
glamor_egl_fd_name_from_pixmap(ScreenPtr screen,
|
|
|
|
|
PixmapPtr pixmap,
|
|
|
|
|
CARD16 *stride, CARD32 *size)
|
2014-06-16 11:34:55 -07:00
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
xwl_glamor_init(struct xwl_screen *xwl_screen)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr screen = xwl_screen->screen;
|
2017-03-02 11:03:15 +01:00
|
|
|
const char *no_glamor_env;
|
|
|
|
|
|
|
|
|
|
no_glamor_env = getenv("XWAYLAND_NO_GLAMOR");
|
|
|
|
|
if (no_glamor_env && *no_glamor_env != '0') {
|
|
|
|
|
ErrorF("Disabling glamor and dri3 support, XWAYLAND_NO_GLAMOR is set\n");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2014-06-16 11:34:55 -07:00
|
|
|
|
2018-04-20 14:38:03 -04:00
|
|
|
if (!xwl_screen->egl_backend.init_egl(xwl_screen)) {
|
|
|
|
|
ErrorF("EGL setup failed, disabling glamor\n");
|
2014-06-16 11:34:55 -07:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-29 20:30:12 -07:00
|
|
|
if (!glamor_init(xwl_screen->screen, GLAMOR_USE_EGL_SCREEN)) {
|
2014-06-16 11:34:55 -07:00
|
|
|
ErrorF("Failed to initialize glamor\n");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-20 14:38:03 -04:00
|
|
|
if (!xwl_screen->egl_backend.init_screen(xwl_screen)) {
|
|
|
|
|
ErrorF("EGL backend init_screen() failed, disabling glamor\n");
|
2017-03-08 10:32:22 +01:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-16 11:34:55 -07:00
|
|
|
xwl_screen->CreateScreenResources = screen->CreateScreenResources;
|
|
|
|
|
screen->CreateScreenResources = xwl_glamor_create_screen_resources;
|
|
|
|
|
|
2016-03-09 16:21:18 +01:00
|
|
|
#ifdef XV
|
|
|
|
|
if (!xwl_glamor_xv_init(screen))
|
|
|
|
|
ErrorF("Failed to initialize glamor Xv extension\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-06-16 11:34:55 -07:00
|
|
|
return TRUE;
|
|
|
|
|
}
|