mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-06-19 21:48:37 +02:00
Make backend-specific function set a surface error on type mismatch.
If any backend-specific, surface-modifying function is called with the wrong surface type we set an error on that surface.
This commit is contained in:
parent
0e4527c67e
commit
41e288a880
4 changed files with 19 additions and 11 deletions
|
|
@ -108,7 +108,7 @@ const cairo_surface_t _cairo_surface_nil_read_error = {
|
|||
* breakpoint in _cairo_error() to generate a stack trace for when the
|
||||
* user causes cairo to detect an error.
|
||||
**/
|
||||
static void
|
||||
void
|
||||
_cairo_surface_set_error (cairo_surface_t *surface,
|
||||
cairo_status_t status)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1291,9 +1291,10 @@ cairo_xcb_surface_set_size (cairo_surface_t *surface,
|
|||
{
|
||||
cairo_xcb_surface_t *xcb_surface = (cairo_xcb_surface_t *)surface;
|
||||
|
||||
/* XXX: How do we want to handle this error case? */
|
||||
if (! _cairo_surface_is_xcb (surface))
|
||||
if (! _cairo_surface_is_xcb (surface)) {
|
||||
_cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
|
||||
return;
|
||||
}
|
||||
|
||||
xcb_surface->width = width;
|
||||
xcb_surface->height = height;
|
||||
|
|
|
|||
|
|
@ -1947,18 +1947,20 @@ cairo_xlib_surface_create_with_xrender_format (Display *dpy,
|
|||
* this function on a surface created for a Pixmap.
|
||||
**/
|
||||
void
|
||||
cairo_xlib_surface_set_size (cairo_surface_t *surface,
|
||||
cairo_xlib_surface_set_size (cairo_surface_t *abstract_surface,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
cairo_xlib_surface_t *xlib_surface = (cairo_xlib_surface_t *)surface;
|
||||
cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
|
||||
|
||||
/* XXX: How do we want to handle this error case? */
|
||||
if (! _cairo_surface_is_xlib (surface))
|
||||
if (! _cairo_surface_is_xlib (abstract_surface)) {
|
||||
_cairo_surface_set_error (abstract_surface,
|
||||
CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
|
||||
return;
|
||||
}
|
||||
|
||||
xlib_surface->width = width;
|
||||
xlib_surface->height = height;
|
||||
surface->width = width;
|
||||
surface->height = height;
|
||||
}
|
||||
/**
|
||||
* cairo_xlib_surface_set_drawable:
|
||||
|
|
@ -1982,9 +1984,10 @@ cairo_xlib_surface_set_drawable (cairo_surface_t *abstract_surface,
|
|||
{
|
||||
cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface;
|
||||
|
||||
/* XXX: How do we want to handle this error case? */
|
||||
if (! _cairo_surface_is_xlib (abstract_surface))
|
||||
if (! _cairo_surface_is_xlib (abstract_surface)) {
|
||||
_cairo_surface_set_error (abstract_surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
|
||||
return;
|
||||
}
|
||||
|
||||
/* XXX: and what about this case? */
|
||||
if (surface->owns_pixmap)
|
||||
|
|
|
|||
|
|
@ -1607,6 +1607,10 @@ extern const cairo_private cairo_surface_t _cairo_surface_nil;
|
|||
extern const cairo_private cairo_surface_t _cairo_surface_nil_read_error;
|
||||
extern const cairo_private cairo_surface_t _cairo_surface_nil_file_not_found;
|
||||
|
||||
cairo_private void
|
||||
_cairo_surface_set_error (cairo_surface_t *surface,
|
||||
cairo_status_t status);
|
||||
|
||||
cairo_private cairo_surface_t *
|
||||
_cairo_surface_create_similar_scratch (cairo_surface_t *other,
|
||||
cairo_content_t content,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue