[surface] Convert FORMAT_INVALID during snapshots

Currently the surface snapshotting attempts to clone the source using a
new surface of identical format. This will raise an error if the source is
an unusual xserver, for example one operating at 16bpp. The solution to
this is to create the surface using the content type rather than the
format (as elsewhere within the code base). However, we also wish to
preserve FORMAT_A1 (which is lost if we only choose the format based on
_cairo_format_from_content) as the various backends may be able to
trivially special case such bitmaps.
This commit is contained in:
Chris Wilson 2009-05-05 17:05:39 +01:00
parent 31f5a2e94d
commit 60e38d0530

View file

@ -1115,6 +1115,7 @@ _cairo_surface_fallback_snapshot (cairo_surface_t *surface)
{
cairo_surface_t *snapshot;
cairo_status_t status;
cairo_format_t format;
cairo_surface_pattern_t pattern;
cairo_image_surface_t *image;
void *image_extra;
@ -1124,7 +1125,14 @@ _cairo_surface_fallback_snapshot (cairo_surface_t *surface)
if (unlikely (status))
return _cairo_surface_create_in_error (status);
snapshot = cairo_image_surface_create (image->format,
format = image->format;
if (format == CAIRO_FORMAT_INVALID) {
/* Non-standard images formats can be generated when retrieving
* images from unusual xservers, for example.
*/
format = _cairo_format_from_content (image->base.content);
}
snapshot = cairo_image_surface_create (format,
image->width,
image->height);
if (cairo_surface_status (snapshot)) {