In a -gtk or -xlib environment, if I call cairo_get_target() and then use that surface to call get_image_surface_width/height(), I get silly numbers. Is this the correct way to determine the screen drawing size? I have sample code to demo this, along the lines of: // find out our surface size cairo_surface_t *cs = cairo_get_target(cr); int width = cairo_image_surface_get_width(cs); int height = cairo_image_surface_get_height(cs); #if DEBUG printf("surface area w: %d, h:%d\n",width,height); #endif
*** Bug 3852 has been marked as a duplicate of this bug. ***
*** Bug 3853 has been marked as a duplicate of this bug. ***
It's definitely not legal code, but since we can catch it, it would be nice to be at least optionally verbose about these types of mistakes.
[Copying from the mailing list discussion of the same issue: http://lists.freedesktop.org/archives/cairo/2005-July/004544.html ] Here's a simple patch that at the very least calls into _cairo_error with CAIRO_STATUS_SURFACE_TYPE_MISMATCH as it should in this case, and also returns 0 rather than garbage. The remaining question is whether this error should also set surface->status to CAIRO_STATUS_SURFACE_TYPE_MISMATCH to shut the surface down. That would be consistent with our error handling strategy of shutdown-on-error, and it does have the advantage of doing something to ensure the user can tell that _something_ is wrong. (After which the debugging approach could be to break on _cairo_debug or enable some print messages in _cairo_error that we don't have yet). Suggestions?
Created attachment 3184 [details] Strange painting in crack attack
date: 2005/07/28 17:47:40; author: cworth; state: Exp; lines: +10 -0 * src/cairo-image-surface.c: (cairo_image_surface_get_width), (cairo_image_surface_get_height): Fix to call _cairo_error and return 0 on surface-type mismatch.
Move bugs against "cvs" version to "0.9.3" so we can remove the "cvs" version.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.