Commit graph

300 commits

Author SHA1 Message Date
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
Behdad Esfahbod
74818d2b00 [cairo-xlib] Some code reshuffling, in preparation for a fix 2008-05-23 20:43:08 -04:00
Behdad Esfahbod
db1b18232b [cairo-xlib] Fix max-request size calculations
First, XMaxRequestSize returns number of 4-byte words.  So multiply by 4 is
needed in all uses.  Next, XRenderAddGlyphs uses BIG-REQUEST extension if
available, so when checking for glyph size overflow, we should use
XExtendedMaxRequestSize() first.

Also use the right format when calculating glyph size.

These changes combined, push the biggest font size that can be uploaded to the
server from under 200 to about 5000.

See bug #4339 for history.
2008-05-23 20:03:49 -04:00
Behdad Esfahbod
cf473f4a75 [cairo-xlib] Fix show_glyphs when failing to upload a glyph
Originally reported here:
http://lists.cairographics.org/archives/cairo/2008-May/014032.html
and analyized later in the thread.

Change (font and surface) backend show_glyphs() API to take a
int *remaining_glyphs argument.  It's used to communicate to the caller,
by way of setting remaining_glyphs and returning INT_STATUS_UNSUPPORTED,
that some of the glyphs were shown but not the others.  The xlib backend
now correctly uses this to handle failure to upload a glyph to the server.
So the large-font test passes now.

An alternative approach could be to add some public value for glyphs
indices that are not shown.  -1 perhaps (the xlib backend already uses
that value internally).  Then instead of remaining_glyphs, a backend
could simply set glyph indices of glyphs shown to that -1 value.
2008-05-23 20:03:49 -04:00
Behdad Esfahbod
e66e198ab0 [cairo-xlib] Remove unused variable 2008-05-23 17:11:43 -04:00
Behdad Esfahbod
537ffa7628 [cairo-xlib-surface.c] Fix memmove bug
This was introduced in b7272e9e8e
2008-05-15 18:47:24 -04:00
Chris Wilson
b7272e9e8e [cairo-xlib] Batch XRenderFreeGlyphs
For every glyph evicted from the cache we would allocate a very small
structure to push onto the xlib work queue. This quickly becomes
noticably for an app that consumes a lot of scaled fonts and glyphs,
e.g. trying to draw text at various angles. So we maintain a small array
of glyphs pending finalisation and issue the XRenderFreeGlyphs() once the
array is full.
2008-05-06 15:11:00 +01:00
Chris Wilson
3428acf25d [cairo-scaled-font] Mark the scaled font as finished during destruction.
During the destruction of every font used with an xlib surface, we send
an XRenderFreeGlyphs() for every single glyph in the cache. These
requests are redundant as the server-side glyphs will be released along
with the XRenderFreeGlyphSet(), so we skip the individual glyph
destruction if the font is marked as finished.
2008-05-06 15:10:51 +01:00
Chris Wilson
24284c5101 [cairo-xlib] Enlarge the on-stack arrays.
Grow the on-stack arrays for the XRectangles and XTrapezoids to the
standard size in order to reduce the frequency of allocations.
2008-05-06 14:31:55 +01:00
Chris Wilson
fda9586802 [cairo-xlib] Cache standard xrender formats.
XRender performs a round-trip in order to query the available formats on
the xserver, before searching for a matching format. In order to save
that round-trip and to avoid the short-lived allocation of the array of
available formats, we cache the result on the display.
2008-05-06 14:31:45 +01:00
Chris Wilson
4924d4d928 [cairo-xlib] Do not create surface with mismatching Visual and PictFormat.
As identified by Vladimir Vukicevic,
_cairo_xlib_surface_create_similar_with_format() was erroneously passing
down the source Visual when creating a surface with a different
XRenderPictFormat.
2008-04-08 07:52:47 +01:00
Chris Wilson
f6afba8f54 [cairo-xlib] Create Pixmap using depth from xrender_format.
Use the depth as specified by the xrender_format when creating the
pixmap (as opposed to a guess based on the cairo_format_t).
2008-04-08 07:52:47 +01:00
Chris Wilson
922fefdde4 [cairo-xlib] Handle missing RENDER during similar surface creation
If the xserver doesn't support the RENDER extension or simply doesn't
have the matching PictFormat then xrender_format might be NULL. Check
and fallback in this case.
2008-04-08 07:52:46 +01:00
Chris Wilson
2c8ead12a6 [xlib] Avoiding sending glyphs > XMaxRequestSize.
XRenderAddGlyph() does not split its image data across multiple requests
and so the glyph surface must be smaller than XMaxRequestSize or else
the server will disconnect the client, causing "Fatal IO error 104".
As this will require an extension to the XRender spec, we can work
around the issue by using our fallbacks if we detect that the glyph will
be too large for a single request.

See bugs https://bugs.freedesktop.org/show_bug.cgi?id=4339 and
http://bugs.freedesktop.org/show_bug.cgi?id=13266 for examples.
2008-04-04 18:08:25 +01:00
Chris Wilson
eb3eb0252b [cairo-xlib-surface] Avoid writing to the error surface.
Insert status checks during construction of temporary glyph surfaces
to avoid potentially writing to the inert error object.
2008-04-02 17:33:30 +01:00
Chris Wilson
c1062bf20a [cairo-xlib-surface] Preserve Visuals for non-TrueColor similar surfaces.
Previously, given a valid XRenderFormat the Visual was discarded
when creating similar surfaces. However the original Visual is
required to support reading back from non-TrueColor surfaces.
2008-04-02 10:50:48 +01:00
Chris Wilson
37c69c0d54 [cairo-xlib] Handle malloc failures for cairo_xlib_visual_info_t.
Tidy the error paths whilst handling visuals, in particular avoiding a
couple of potential NULL deferences, missed status checks and fresh
leaks.
2008-04-02 10:50:48 +01:00
Carl Worth
46ea00d829 More quieting of subtle potentially-uninitialized warnings
The compiler isn't clever enough to notice that these
variables are always initialized (in either the TrueColor
or ! TrueColor conditions corresponding to the later
identical conditions in which the variables are used).
2008-04-01 14:53:55 -07:00
Carl Worth
d7e5f6b6a0 Rename _popcount to _cairo_popcount and make it available for internal use
Both cairo-image-surface.c and cairo-xlib-surface.c want to
use this function now.
2008-03-25 16:32:24 -07:00
Carl Worth
e96f382549 Add support for 8-bit PseudoColor visuals
This support involves allocating a 16-bit grayscale ramp as well
as a 5x5x5 RGB color cube. Afterwards, the 256 colors are queried
and an array is generated mapping from r3g3b3 colors to the closest
available color. Both the queried colors and the reverse mapping
are stored in a new visual-specific cairo_xlib_visual_info_t
structure which hangs off of the cairo_xlib_screen_info_t.

Both the color-cube allocation and the distance metric could be
improved by someone sufficiently motivated, (for example, allocating
and matching in a perceptually linear color space rather than just
in RGB space). Also, making this work well in the face of a changing
color map, or in the case of GrayScale, StaticGray, or DirectColor
visuals are left entirely as exercises for the reader. StaticColor
support should be fine as is, but is entirely untested.
2008-03-20 11:51:57 -07:00
Carl Worth
d413c5ab21 xlib: Add support for arbitrary TrueColor visuals
This fixes the following bugs:

	cairo doesn't support 8-bit truecolor visuals
	https://bugs.freedesktop.org/show_bug.cgi?id=7735

	cairo doesn't support 655 xlib format
	https://bugs.freedesktop.org/show_bug.cgi?id=9719
2008-03-20 11:51:57 -07:00
Carl Worth
eb31c52feb Make _pixman_format_to_masks accept a cairo_format_masks_t structure
This makes it work similarly to _pixman_format_from_masks
2008-03-18 17:20:08 -07:00
Carl Worth
cdb1ae97f2 Move assertion failure for unsupported masks up one level
We're moving the assertion up from inside _pixman_format_to_mask
to its callers. This will allow us to selectively eliminate the
assertion from the supported xlib backend, while leaving it in
the unsupported glitz and xcb backends for now.
2008-03-18 17:20:08 -07:00
Chris Wilson
c985096e6d [cairo-xlib] Tidy usage of _cairo_error().
Avoid a duplicate call to _cairo_error() and add a missing one.
2008-03-04 09:31:20 +00:00
Behdad Esfahbod
e68584d3a1 [xlib] Move multiple CAIRO_MUTEX_INITIALIZE into one place they all end up anyway 2008-02-08 17:37:50 -05:00
Carl Worth
ac743e25fa cairo_xlib_surface_create_similar: Pass the original drawable to XCreatePixmap
Previously we were passing the root window of the same screen.
Letting the X server know the actual Drawable for which we're
trying to be similar allows the X server to be more efficient.
2008-02-06 17:01:21 -08:00
Behdad Esfahbod
9d8990b6bd [doc] Remove excess paranthesis 2008-01-28 23:23:00 -05:00
Behdad Esfahbod
b790c5a6bc [doc] Replace 'NOTE' by 'Note' and add it to test 2008-01-28 21:53:44 -05:00
Behdad Esfahbod
c133ee5acc [doc] Improve docs for new API 2008-01-28 21:00:21 -05:00
Behdad Esfahbod
0d898f2bad [doc] Make sure all type names in docs are prefixed by # 2008-01-28 20:49:44 -05:00
Behdad Esfahbod
9ecde82d35 [doc] Make sure all macro names in docs are prefixed by % 2008-01-28 20:48:48 -05:00
Carl Worth
cc94dce250 Return NULL from cairo_xlib_surface_get_xrender_format without an error
The NULL return value will only happen if the X Render extension
is not available. We've already got that NULL return value
documented, so it's not an error if the user asks for it. In
particular, it's definitely not a surface-type mismatch.
2008-01-28 15:39:39 -08:00