mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-26 05:20:10 +01:00
[cairo-boilerplate-xlib] Check that the surface will fit in the screen.
Whilst testing the fallback surface, the resultant image was being clipped to the screen size. Be conservative and refuse to create windows (for CAIRO_CONTENT_COLOR surfaces) that are larger than the screen.
This commit is contained in:
parent
a29544a0b6
commit
8894894d9d
1 changed files with 25 additions and 0 deletions
|
|
@ -110,6 +110,18 @@ _cairo_boilerplate_xlib_test_create_surface (Display *dpy,
|
|||
width, height);
|
||||
}
|
||||
|
||||
|
||||
static cairo_bool_t
|
||||
_cairo_boilerplate_xlib_check_screen_size (Display *dpy,
|
||||
int screen,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
Screen *scr = XScreenOfDisplay (dpy, screen);
|
||||
return width <= WidthOfScreen (scr) && height <= HeightOfScreen (scr);
|
||||
}
|
||||
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_xlib_perf_create_surface (Display *dpy,
|
||||
cairo_content_t content,
|
||||
|
|
@ -135,6 +147,13 @@ _cairo_boilerplate_xlib_perf_create_surface (Display *dpy,
|
|||
break;
|
||||
|
||||
case CAIRO_CONTENT_COLOR:
|
||||
if (! _cairo_boilerplate_xlib_check_screen_size (dpy,
|
||||
DefaultScreen (dpy),
|
||||
width, height)) {
|
||||
CAIRO_BOILERPLATE_LOG ("Surface is larger than the Screen.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
visual = DefaultVisual (dpy, DefaultScreen (dpy));
|
||||
xrender_format = XRenderFindVisualFormat (dpy, visual);
|
||||
if (xrender_format == NULL) {
|
||||
|
|
@ -244,6 +263,12 @@ _cairo_boilerplate_xlib_fallback_create_surface (const char *name,
|
|||
XSynchronize (dpy, 1);
|
||||
|
||||
screen = DefaultScreen (dpy);
|
||||
if (! _cairo_boilerplate_xlib_check_screen_size (dpy, screen,
|
||||
width, height)) {
|
||||
CAIRO_BOILERPLATE_LOG ("Surface is larger than the Screen.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
attr.override_redirect = True;
|
||||
xtc->drawable = XCreateWindow (dpy, DefaultRootWindow (dpy),
|
||||
0, 0,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue