mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 22:48:07 +02:00
[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:
parent
31f5a2e94d
commit
60e38d0530
1 changed files with 9 additions and 1 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue