Commit graph

331 commits

Author SHA1 Message Date
Chris Wilson
ab1d106cba [xlib] Use the cached xrender formats.
Use the cached formats for consistency and simplify several double pointer
dereferences.
2008-10-11 19:52:28 +01:00
Chris Wilson
ac3e4b4bea [xlib] Disable XRender support if the surface has no xrender_format
Bug 11734:
  XRender crashes due to NULL pointer from Cairo on SGI O2
  (https://bugs.freedesktop.org/show_bug.cgi?id=1173)
is an example of a case where we try to perform an XRender operation on a
surface with a format that was not supported by the XRender extension. By
marking the extension version as -1 on those surfaces, the current checks
for SURFACE_RENDER_HAS_* always correctly return false and prevent us try
to create a Picture with a NULL xrender_format.
2008-10-10 15:42:09 +01:00
Chris Wilson
552cc09e6b [xlib] Check integer translation for XCopyArea.
A precondition for using the core XCopyArea protocol is that the source
attributes contain only integer translations. However, we failed to apply
any integer translations from the source matrix to the XCopyArea offsets.
This worked prior to 5b97ee6525 as
_cairo_pattern_acquire_surface_for_surface() was careful to only generate
an identity matrix if the pattern matrix only contained an integer
translation (and thus we would use XCopyArea in the xlib backend).
2008-10-07 21:05:57 +01:00
Chris Wilson
8ec24a443d [xlib] Share the common conditions for starting a new xGlyphElt using a macro.
Move the predicate for starting a new glyph elt into a macro so that it
can be shared between _cairo_xlib_surface_emit_glyphs() and
_emit_glyph_chunks() without code duplication.
2008-10-04 10:10:52 +01:00
Carl Worth
8ea9cb187a Use symbolic constants for Render repeat modes.
Names like RepeatNone and RepeatNormal are much easier to
read and understand than bare 0 and 1.
2008-10-01 14:12:18 -07:00
Behdad Esfahbod
2c58a2c385 [xlib] Start a new glyph element every 128 glyphs
Xrender has limits at 252 glyphs.  We play safe and fast and limit
elements to 128 glyphs.  That's plenty, no measurable performance
hit expected.
2008-09-30 17:55:01 -04:00
Behdad Esfahbod
fd7e09c7e6 [xlib] Allow room for glyph element padding
Xrender pads glyph elements to 4byte boundaries.  We didn't consider
that in our request size calculations.  We do now.
2008-09-30 17:46:06 -04:00
Behdad Esfahbod
c01fb77abb [xlib] s/_cairo_xlib_surface_emit_glyphs_chunk/_emit_glyphs_chunk/
For readability's sake.
2008-09-30 17:41:51 -04:00
Behdad Esfahbod
c2ba25df1a [xlib] Add comment about glyph chunk invariant 2008-09-30 17:40:56 -04:00
Behdad Esfahbod
e983458e1f Revert "[xlib] Correct calculation of XRenderComposite* request size."
This reverts commit 0eb0c26474.
The change was too drastic and overlooked some subleties of the old
code, but the main reason for the revert is that it introduced an
ugly duplicated glyph flush block.  I'm working on a more incremental
fix.
2008-09-30 17:26:46 -04:00
Chris Wilson
0eb0c26474 [xlib] Correct calculation of XRenderComposite* request size.
show-glyphs-many is triggering an assertion failure within xlib. The cause
appears to be that we are submitting an overlong request.

Reviewing the code and comparing with libXrender/src/Glyph.c I found two
points to address.

1. When encountering the first 2-byte, or 4-byte glyph and thus triggering
the recalculation of the current request_size, we did not check that there
was enough room for the expanded request. In case there is not, we need to
emit the current request (before expansion) and reset.

2. Subtleties in how XRenderCompositeText* constructs the binary protocol
buffer require that xGlyphElts are aligned to 32-bit boundaries and that
it inserts an additional xGlyphElt every 252 glyphs when width==1 or
every 254 glyphs for width==2 || width==4.  Thus we need to explicitly
compute how many bytes would be required to add this glyph in accordance
with the above.

Considering the complexity (and apparent fragility since we require tight
coupling to XRender) of the code, I'm sure there are more bugs to be
found.
2008-09-30 15:29:30 +01:00
Karl Tomlinson
d52b55cb1b [xlib] _surfaces_compatible() can return true for different picture formats
_surfaces_compatible in cairo-xlib-surface returns true for surfaces with
different xrender_format when each has the same depth and no (NULL)
visual.

Common picture formats will not have the same depth, but
it is possible to create a surface with a non-standard xrender_format
having the same depth as another xrender_format with
cairo_xlib_surface_create_with_xrender_format.

Both cairo_xlib_surface_create_with_xrender_format and
_cairo_xlib_surface_create_similar_with_format create surfaces with no
visual.

The same issue exists in the xcb backend.

Fixes bug https://bugs.freedesktop.org/show_bug.cgi?id=16564.
2008-09-28 17:51:23 +01:00
Chris Wilson
871f683367 clone_similar(): s/device_offset/clone_offset/
A little bit of sleep and reflection suggested that the use of
device_offset_[xy] was confusing and clone_offset_[xy] more consistent
with the function naming.
2008-09-27 17:27:21 +01:00
Chris Wilson
5b97ee6525 Allow cloning sub-regions of similar surfaces.
Previously the rule for clone_similar() was that the returned surface
had exactly the same size as the original, but only the contents within
the region of interest needed to be copied. This caused failures for very
large images in the xlib-backend (see test/large-source).

The obvious solution to allow cloning only the region of interest seemed
to be to simply set the device offset on the cloned surface. However, this
fails as a) nothing respects the device offset on the surface at that
layer in the compositing stack and b) possibly returning references to the
original source surface provides further confusion by mixing in another
source of device offset.

The second method was to add extra out parameters so that the
device offset could be returned separately and, for example, mixed into
the pattern matrix. Not as elegant, a couple of extra warts to the
interface, but it works - one less XFAIL...
2008-09-27 02:20:42 +01:00
Søren Sandmann Pedersen
86485e76b7 [xlib] Use _cairo_matrix_to_pixman_matrix() to compute the XTransform
The adjustments done to the pixman matrix also need to be done for
XTransform. Since an XTransform is just a pixman_transform_t with
another name, we can reuse the conversion function.
2008-09-17 15:18:55 -04:00
Chris Wilson
a5d33bcbb4 [xlib] Keep a pointer to the cairo_xlib_display_t on the surface.
Cleanup the code somewhat by passing cairo_xlib_display_t around
internally as opposed to a Display and then having to lookup the
corresponding cairo_xlib_display_t each time.

[To get a cairo_xlib_display_t from a Display is a list traversal under
mutex (though the element we're looking for is most likely at the start),
but to get the Display is just a lockless pointer dereference.]
2008-09-02 10:49:12 +01:00
Chris Wilson
939b836bfa [xlib] Use an embedded doubly-linked list for the close display hooks.
Kill the allocation and linear search of the close display list on remove,
by embedding a list node into the parent structure.

Original patch by Karl Tomlinson <karlt+@karlt.net>, Mozilla Corporation.
https://bugzilla.mozilla.org/show_bug.cgi?id=453199#c5
2008-09-02 10:08:04 +01:00
Vladimir Vukicevic
d756a4d632 [xlib] check for too-large surface size in create similar to avoid UNSUPPORTED loop 2008-08-28 16:58:52 -07:00
Vladimir Vukicevic
2cf82eaf0d [xlib] Check CreatePixmap dimensions before calling, to avoid unnecessary size errors 2008-08-27 14:16:52 -07:00
Chris Wilson
63befc6ab1 [xlib] Remove the key parameter from the close display hook.
By inspecting all the users of the close display hooks, we can see that
(a) the key is redundant and (b) the data is unique to the hook. This
means we can trim the interface and stop the linear searches as soon as
we've found the correct element.
2008-08-14 09:14:51 +01:00
Chris Wilson
84a541a041 [cairo-xlib-surface] Remove status return for SUCCESS only function.
Convert _cairo_xlib_surface_set_repeat() to a void return type, and
update caller, as the function can only return CAIRO_STATUS_SUCCESS.
2008-08-14 09:06:24 +01:00
Chris Wilson
8552e76ee5 [xlib] Fix leak of pending_free_glyphs on CloseDisplay.
Missing free of the pending_free_glyphs array in
_cairo_xlib_surface_remove_scaled_font.
2008-08-14 08:25:58 +01:00
Chris Wilson
fef03ef98a [xlib] Check for depth == 0 in create_surface_internal().
Validate that we find an appropriate depth for the Xlib surface, before
attempting to create the surface. This was manifesting itself with
XInitImage() failures during _draw_image_surface() (actually detected as
a segmentation fault in XPutPixel() due to an incomplete XImage).  So we
also add a couple of asserts to ensure that XInitImage() is successful -
which to the best of our knowledge, they should always be.
2008-08-10 08:44:45 +01:00
Chris Wilson
5bac12252c [xlib] Free regions on failure.
Fix leak of regions along error path.
2008-08-08 01:48:43 +01:00
Behdad Esfahbod
787fb13566 [xlib] Use _cairo_xlib_surface_create_internal() directly 2008-06-26 16:20:58 -04:00
Behdad Esfahbod
d9784c8c37 [cairo-xlib] Don't undither pseudocolor, doesn't look good 2008-06-19 22:24:13 -04:00
Behdad Esfahbod
fe41d100aa [cairo-xlib-surface] Fix core solid_fill_rectangles to do dithering
Do this by tiling the surface form the solid pattern.  The pattern in
turn calls into xlib's create_solid_surface which returns a dithered
pattern.

This can get into infinite loop right now, because of the way solid
surface cache tries to repaint cached surfaces.
2008-06-19 22:00:52 -04:00
Behdad Esfahbod
abac0f96cb [cairo-xlib-surface] Implement create_solid_pattern_surface
If render is disabled, this will create a surface the size of the
dither pattern and paint it with dithering.
2008-06-19 22:00:50 -04:00
Behdad Esfahbod
fb8f2b3854 [cairo-xlib-surface] Make _draw_image_surface handle arbitrary image formats
This is not a useful change.  Just committing because I already did it.
2008-06-19 21:55:41 -04:00
Behdad Esfahbod
bc4b788ec1 [cairo-xlib-surface] In _get_image_surface only use pixman formats >= 24bpp
Otherwise we can't do dithering.  This drastically improves gradient rendering
on 16bit displays, essentially making them indistinguishable from 32bit ones
with a naked eye.
2008-06-19 21:55:27 -04:00
Behdad Esfahbod
5faf8663b2 [cairo-xlib-surface] Force buggy_repeat to TRUE if Render is not available
So we use more core protocol paths.
2008-06-19 21:54:29 -04:00
Behdad Esfahbod
e7c1fc5bf5 [xlib] Implement dithering
Remove the intermediate rgb333 for PseudoColor and work on the
cube directly.  Also upgrade to a 6x6x6 cube instead of 5x5x5.
Do dithering on both PseudoColor and TrueColor, using a 4x4 pattern.

This only affects X servers with no XRender.
2008-06-19 21:54:23 -04:00
Behdad Esfahbod
c0176dc54c [cairo-xlib-surface] Remove unused macro 2008-06-19 21:54:02 -04:00
Chris Wilson
f2ea46edf4 [cairo-xlib-surface] Optimize away clip that covers the entire surface.
Replace a clip rectangle that covers the entire surface with no
clipping as this is quite a common operation when toolkits (i.e. GTK+)
clear surfaces before drawing and avoids a redundant
XRenderSetClipRectangles.
2008-06-13 21:52:37 +01:00
Chris Wilson
b06bd9379a [cairo-xlib-surface] Handle a NULL visual along core FillRectangles path.
It is possible for an XRender capable surface to use
_cairo_xlib_surface_solid_fill_rectangle() if the surface
HAS_CREATE_PICTURE() && ! HAS_FILL_RECTANGLES(), in which case we need to
handle the surface having no associated visual.

Fixes test/xlib-expose-event.
2008-06-13 21:37:58 +01:00
Chris Wilson
ad9a334e2c Allocate the correct pattern type on the stack.
Instead of allocating the union of all possible pattern types, just
allocate the specific pattern as used by the function in order to trim
the stack space consumption and flag potential misuse.
2008-06-13 21:37:58 +01:00
Chris Wilson
74c1e9b545 Trivial warning fixes to silence the compiler. 2008-06-13 21:37:58 +01:00
Chris Wilson
ea79af728c [cairo-xlib] Scan for a glyphset to match a pending free glyph.
In order to avoid re-rasterising a glyph that is pending an
XRenderFreeGlyph, we first scan all glyphsets and their arrays of
pending_free_glyphs for a matching glyph. The additional cost of
scanning the extra arrays should be negligble as most fonts will only
have the single array (which we would scan anyway) but we potentially
save an expensive rasterisation and short-lived image surface.

(As suggested by Behdad Esfahbod.)
2008-06-13 21:37:57 +01:00
Søren Sandmann
c3121543f8 Fix xlib incarnation of the large-clip bug.
Intersect the clip region with the bounds of the surface to prevent
overflows when converting from 32 to 16 bits.
2008-06-10 18:09:00 -04:00
Behdad Esfahbod
3f5051fab1 Fix now-detected doc formatting issues 2008-06-01 19:14:13 -04:00
Behdad Esfahbod
4e10241148 Fix whitespace 2008-05-28 17:12:51 -04:00
Behdad Esfahbod
78b9e29178 [cairo-xlib] Rewrite cairo_xlib_glyph_t as a union of cairo_glyph_t
Someone reported on cairo list that on some system with gcc, he had the
compile-time assertion failing, meaning that the following struct:

typedef struct {
  unsigned long index;
  union {
    struct {
      double x;
      double y;
    } d;
    struct {
      int x;
      int y;
    } i;
  } p;
} cairo_xlib_glyph_t;

had a different size from:

typedef struct {
  unsigned long        index;
  double               x;
  double               y;
} cairo_glyph_t;

That looks quite a weird thing for a compiler to do.  Anyway, rewriting
our struct like this may help in those weird situations:

typedef union {
  cairo_glyph_t d;
  unsigned long index;
  struct {
    unsigned long index;
    int x;
    int y;
  } i;
} cairo_xlib_glyph_t;

That's what we do now.
2008-05-28 17:04:09 -04:00
Behdad Esfahbod
295dee36e3 [cairo-xlib] Use newly-added COMPILE_TIME_ASSERT 2008-05-28 13:10:07 -04:00
Behdad Esfahbod
043ed895ad [cairo-xlib] Fix compiler warning 2008-05-28 13:09:43 -04:00
Behdad Esfahbod
f3a3a0594d [cairo-xlib] Add recently-added byteswap macros (#16128) 2008-05-28 12:02:16 -04:00
Ginn Chen
07fef4f480 [cairo-xlib] Implement _cairo_xlib_surface_solid_fill_rectangles() (#11529) 2008-05-27 05:07:44 -04:00
Behdad Esfahbod
f90b155b5a [cairo-xlib] Delay using fallback if xrender is not available
So we can use XCopyArea when Render is not available.  Based on patch by
Ginn Chen.
2008-05-27 05:07:44 -04:00
Behdad Esfahbod
e638e7652f [cairo-xlib] Fix bug introduced in yesterday's code shuffling. Oops. 2008-05-24 14:25:13 -04:00
Behdad Esfahbod
c20072c881 [cairo-xlib] Upon seeing glyphs with large position, just let fallback handle
This now fixes the large-font test for xlib again.
2008-05-23 20:57:21 -04:00
Behdad Esfahbod
e55252bd3b [cairo-xlib] Shift range of allowed glyph positions
From -1024..15359, to -4096..122887.  This still does not fix the
large-font test as that uses a 10000 font.  Working on a proper fix
for glyph dropping now.
2008-05-23 20:46:36 -04:00