[cairo] Screen* must be known in Xlib backend

Owen Taylor otaylor at redhat.com
Tue Jul 19 11:38:48 PDT 2005


On Wed, 2005-06-22 at 13:47 -0700, Keith Packard wrote:
> Instead, we should add Screen* arguments to each of these functions:
> 
>         cairo_surface_t *
>         cairo_xlib_surface_create_for_bitmap (Display  *dpy,
>                                               Pixmap    bitmap,
>                                               Screen    *screen,
>                                               int       width,
>                                               int       height);
> 
>         cairo_surface_t *
>         cairo_xlib_surface_create_with_xrender_format (Display           *dpy,
>                                                        Drawable           drawable,
>                                                        Screen            *screen,
>                                                        XRenderPictFormat *format,
>                                                        int                width,
>                                                        int                height);
>         
> With these in place, all that's needed is to make sure
> screens match everywhere multiple drawables are used.
> They key location for this is in _cairo_xlib_surface_clone_similar where
> it checks to see if it can re-use an existing source surface.

An obvious question is whether we should be using a Screen * here or a
screen number. The Xlib API is certainly schizophrenic on the
issue, but screen numbers have generally seemed the more "basic"
version; almost ever Xlib program I've written has had things like:
 
 int screen = DefaultScreen (dpy);
 Visual *visual = DefaultVisual (dpy, screen);

Rather than:

 Screen *screen = DefaultScreenOfDisplay (dpy);
 Visual *visual = screen->root_visual;

So a using a screen number (just like Xft) would have been my expectation.

In terms of implementation, the only thing I saw was the item I pointed
out to you on IRC when you first posted the patch:

@@ -878,7 +884,7 @@ _categorize_composite_repeat (cairo_xlib
                if (operator == CAIRO_OPERATOR_OVER && _surface_has_alpha (src))
                    return DO_UNSUPPORTED;

-               if (src->dpy == dst->dpy && !_surfaces_compatible (src, dst))
+               if (!_surfaces_compatible (src, dst))
                    return DO_UNSUPPORTED;
            }
        }

The check here is screening out cases where we *know* we need to do a software
fallback - if the surfaces are for the same display, then we can do the
final check for compatibility here. If they are for different displays (or
different screens), then we have to wait until 
_cairo_xlib_surface_clone_similar() does its work to make the check: the
cloned source surface may be compatible with the dest.

So the right check is:

-               if (src->dpy == dst->dpy && !_surfaces_compatible (src, dst))
+               /* If the source and destination are for the same screen,
+                * then we can go ahead and check for compatibility now. Otherwise,
+                * we have to wait until _cairo_xlib_surface_clone_similar() does
+                * its work */
+               if (src->dpy == dst->dpy && src->screen == dst->screen &&
+                   !_surfaces_compatible (src, dst))

Regards,
							Owen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050719/18c2beaa/attachment.pgp


More information about the cairo mailing list