boilerplate/gl: Round fractional window sizes up

A few test cases purposely create fractional surface sizes which can not
be natively supported by the raster backends such as GL. For these
backends we need to consistent in creating a surface that is large
enough to contain the test, so we need to use ceil() rather than
implicit truncation to integers.

A consequence of the misalignment between the Window size and the
surface size (where one was using ceil and the other not) is that the
first row of the cairo surface would not be visible on the output.

Based on a patch by Chuanbo Wen to fix 5 test cases, such as
group-unaligned.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2012-06-29 10:25:13 +01:00
parent cb85631c63
commit 64d65f72e5

View file

@ -98,6 +98,9 @@ _cairo_boilerplate_gl_create_surface (const char *name,
gltc = calloc (1, sizeof (gl_target_closure_t));
*closure = gltc;
width = ceil (width);
height = ceil (height);
if (width == 0)
width = 1;
if (height == 0)
@ -133,9 +136,7 @@ _cairo_boilerplate_gl_create_surface (const char *name,
gltc->device = cairo_glx_device_create (dpy, ctx);
gltc->surface = surface = cairo_gl_surface_create (gltc->device,
content,
ceil (width),
ceil (height));
content, width, height);
if (cairo_surface_status (surface))
_cairo_boilerplate_gl_cleanup (gltc);
@ -143,7 +144,7 @@ _cairo_boilerplate_gl_create_surface (const char *name,
}
static cairo_surface_t *
_cairo_boilerplate_gl_create_window (const char *name,
_cairo_boilerplate_gl_create_window (const char *name,
cairo_content_t content,
double width,
double height,
@ -169,6 +170,9 @@ _cairo_boilerplate_gl_create_window (const char *name,
gltc = calloc (1, sizeof (gl_target_closure_t));
*closure = gltc;
width = ceil (width);
height = ceil (height);
if (width == 0)
width = 1;
if (height == 0)
@ -214,8 +218,7 @@ _cairo_boilerplate_gl_create_window (const char *name,
gltc->surface = surface = cairo_gl_surface_create_for_window (gltc->device,
gltc->drawable,
ceil (width),
ceil (height));
width, height);
if (cairo_surface_status (surface))
_cairo_boilerplate_gl_cleanup (gltc);
@ -224,7 +227,7 @@ _cairo_boilerplate_gl_create_window (const char *name,
static cairo_surface_t *
_cairo_boilerplate_gl_create_window_db (const char *name,
cairo_content_t content,
cairo_content_t content,
double width,
double height,
double max_width,
@ -250,6 +253,9 @@ _cairo_boilerplate_gl_create_window_db (const char *name,
gltc = calloc (1, sizeof (gl_target_closure_t));
*closure = gltc;
width = ceil (width);
height = ceil (height);
if (width == 0)
width = 1;
if (height == 0)
@ -295,8 +301,7 @@ _cairo_boilerplate_gl_create_window_db (const char *name,
gltc->surface = cairo_gl_surface_create_for_window (gltc->device,
gltc->drawable,
ceil (width),
ceil (height));
width, height);
surface = cairo_surface_create_similar (gltc->surface, content, width, height);
status = cairo_surface_set_user_data (surface, &gl_closure_key, gltc, NULL);
if (status == CAIRO_STATUS_SUCCESS)