Commit graph

134 commits

Author SHA1 Message Date
Uli Schlachter
0251f0951d xcb: Clear the result of create_similar_image
The documentation of cairo_surface_create_similar_image() states that the
image's contents are initially all 0. However, the implementation didn't live up
to the documentation.

This was found via the corresponding assert in
cairo_surface_create_similar_image().

There are some cairo-xcb-internal users of this function which cleared the image
right after creating it. Obviously, this isn't needed anymore.

Fixes: Nothing. The existing call in the testsuite to
cairo_surface_create_similar_image() doesn't hit this issue, since it creates a
too small image to hit the SHM-case.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-10-06 15:00:51 +02:00
Uli Schlachter
f2720e2ba1 xcb: Add a missing check for FillRectangles
Fixes: big-empty-box big-little-box operator operator-alpha
surface-pattern-operator unbounded-operator

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-09-25 11:39:42 +02:00
Uli Schlachter
b264ae76bd xcb: Check if traps are supported before using them
This code tried to optimize the clip away by intersecting the boxes with the
clip polygon. However, it also did so when the server didn't support traps.

Fixes: clip-stroke-unbounded clip-fill-nz-unbounded clip-fill-eo-unbounded
clip-fill clip-fill-rule a1-clip-fill-rule clip-group-shapes-circles
clip-intersect clip-nesting clip-operator clip-push-group clip-polygons
clip-shape clip-text clip-twice inverted-clip mask random-clip
rotate-clip-image-surface-paint trap-clip unantialiased-shapes

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-09-25 11:34:52 +02:00
Uli Schlachter
0ccbb83eb8 xcb: Check the right flag for FillRectangles
Fixes: operator-source

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-09-25 11:31:04 +02:00
Uli Schlachter
de31018bdd xcb: Switch to compositor architecture
This commit removes the hand-written code in cairo-xcb-surface.c and instead
makes use of cairo_compositor_t. Surprisingly, this doesn't break a single test
case. :-)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-09-24 09:44:10 +02:00
Uli Schlachter
9f52261dd7 xcb: Correctly handle a recording surface's extents
The size of the target area doesn't really have much to do with the size of the
recording surface that we are painting from. Thus, let's use the recording
surface's size instead.

Since we apply the transformation before replaying the recording surface, we
need to transform the recording surface's size via the inverse of our pattern
matrix to get the size in the target surface. This makes this a little more
complex.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-06-25 21:18:18 +02:00
Uli Schlachter
e704f64d8f xcb: Handle recording surfaces differently
Let's say we are painting recording surface 'source' to xcb surface 'target' by
replaying the source to a temporary surface 'tmp'.

Previously, the xcb backend replayed the recording surface to tmp with just a
translation and then used that as its source surface with the pattern's
transformation. That means 'tmp' used the same coordinate system as 'source'.

This patch changes this so that the transformation is applied during the replay
and painting from 'tmp' to 'target' is just a simple translation, so 'tmp' now
uses the same coordinate system as 'target'.

This should produce way less better results, because transforming a recording
surface should have less artifacts than transforming a raster surface.

Fixes: record1414x-* record2x-* record90-* ps-surface-source

Breaks (or rather, "exposes unrelated bug that I have not yet figured out in"):
record-extend-*-similar

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-06-25 21:18:18 +02:00
Chris Wilson
57cfdfd979 Split cairo-list into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 13:17:29 +01:00
Chris Wilson
8653c2692e Split cairo-recording-surface-private into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 12:46:34 +01:00
Chris Wilson
0770dda52b Split cairo-clip-privates into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 12:19:19 +01:00
Nis Martensen
a6a5b1fd0b doc: no separate cairo-xcb-xrender section
There is already a cairo-xcb section and there are no symbols that
should be documented in an extra -xrender section. It is not mentioned
in cairo-sections.txt either. So simply delete it.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-04-12 10:23:27 +02:00
Andrea Canciani
f717341ab9 doc: Make documentation comments symmetric
Documentation comments should always start with "/**" and end with
"**/". This is not required by gtk-doc, but it makes the
documentations formatting more consistent and simplifies the checking
of documentation comments.

The following Python script tries to enforce this.

from sys import argv
from sre import search

for filename in argv[1:]:
    in_doc = False
    lines = open(filename, "r").read().split("\n")
    for i in range(len(lines)):
        ls = lines[i].strip()
        if ls == "/**":
            in_doc = True
        elif in_doc and ls == "*/":
            lines[i] = " **/"
        if ls.endswith("*/"):
            in_doc = False

    out = open(filename, "w")
    out.write("\n".join(lines))
    out.close()

This fixes most 'documentation comment not closed with **/' warnings
by check-doc-syntax.awk.
2012-03-29 11:03:18 +02:00
Uli Schlachter
8025fcc4d3 xcb: Add a special case for recording surface
An unbounded recording surface will complain loudly when you call
acquire_source_image on it and thus we need a special case which draws the
recording surface to a temporary surface and then proceeds with that.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-12-11 14:04:16 +01:00
Uli Schlachter
420110d12b xcb: Move the surface picture setup into its own function
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-12-11 13:41:39 +01:00
Uli Schlachter
fe04df11ed xcb: Silence compiler warnings about ignored return values
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-12-11 11:17:06 +01:00
Uli Schlachter
b6fcf0768c xcb: Silence a compiler warning for mixing type and internal type enums
cairo-xcb-surface-render.c:1134:35: warning: comparison between
'cairo_surface_type_t' and 'enum _cairo_internal_surface_type' [-Wenum-compare]

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-12-11 11:14:58 +01:00
Uli Schlachter
2a60e8deec xcb: Fix invalid casts from cairo_content_t to cairo_format_t
This was introduced in a69335a84e when the second argument of
_cairo_xcb_surface_create_similar_image was changed from content to format.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-12-08 22:41:10 +01:00
Chris Wilson
8844d50308 Convert cairo_mime_surface_t to cairo_raster_source_pattern_t
As discussed, overloading the cairo_surface_t semantics to include
sources (i.e. read-only surfaces) was duplicating the definition of
cairo_pattern_t. So rather than introduce a new surface type with
pattern semantics, start along the thorny road of extensible pattern
types.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-11-25 10:35:42 +00:00
Uli Schlachter
edc238b40f xcb: Fix some invalid casts
cairo-xcb was deciding which type to cast a surface to based on its "type"
member. This is wrong, it should use "backend->type".

This bug was hit via xlib-xcb. This was painting a subsurface of a xlib-xcb
surface to an xcb surface. Because surface->type said "xlib", the code was
trying to check if the xcb surface had a fallback. However, this was done on the
subsurface. The end result was dereferencing a pointer to 0x28.

This was noticed while looking into
https://bugs.freedesktop.org/show_bug.cgi?id=42889

No test for this bug since I didn't manage to come up with one.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-11-15 19:19:44 +01:00
Chris Wilson
c8bfa8c088 xcb: Re-enable glyph rendering
I lost the '&& 0' I put in to disable the glyph rendering until I had
the glyph cache integration working again.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-10-11 12:44:25 +01:00
Uli Schlachter
aa16e3e666 xcb: Honor clips for defer clear
This bug was accidentally introduced in fd613cb9f9.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-09-22 21:18:57 +02:00
Chris Wilson
fd613cb9f9 xcb: track fallback damage
And only upload the parts of the image that are modified during the
fallback. I have to keep reminding myself that the goal is always to
reduce the amount of fallbacks required...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-09-19 15:23:57 +01:00
Uli Schlachter
36a1423045 xcb: Remove an unused variable
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-09-18 20:07:35 +02:00
Uli Schlachter
cdd75ec407 xcb: Use a mask in _composite_boxes() when needed
This doesn't just need a clip without any path, it also needs pixel aligned
boxes.

This improves the result for unaligned boxes in tighten-bounds.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-09-18 20:07:35 +02:00
Uli Schlachter
e580565e28 xcb: Stop using _cairo_clip_get_surface()
This function changed its behavior and no longer does what we want. Instead,
this now uses its own function which uses _cairo_clip_combine_with_surface().

This fixes crashes in the tighten-bounds and random-clip tests. These happened
because cairo-xcb was trying to be clever. ;-)

Since _cairo_clip_get_surface() did less, the resulting surface had
deferred_clear == true and picture == XCB_NONE. The code then tried using this
evil picture and either ran into an assert() or caused a BadPicture error.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-09-18 20:07:35 +02:00
Uli Schlachter
b6c3fea672 xcb: Improve error cases in _clip_and_composite_combine
This makes sure that errors from _cairo_clip_get_surface() aren't lost and that
we really got an xcb surface.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-09-16 17:45:26 +02:00
Uli Schlachter
a349564e3c Revert "xcb: Error on 0x0 source surfaces"
This reverts commit 8f8149a207.
2011-09-15 16:21:42 +02:00
Chris Wilson
af9fbd176b Introduce a new compositor architecture
Having spent the last dev cycle looking at how we could specialize the
compositors for various backends, we once again look for the
commonalities in order to reduce the duplication. In part this is
motivated by the idea that spans is a good interface for both the
existent GL backend and pixman, and so they deserve a dedicated
compositor. xcb/xlib target an identical rendering system and so they
should be using the same compositor, and it should be possible to run
that same compositor locally against pixman to generate reference tests.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

P.S. This brings massive upheaval (read breakage) I've tried delaying in
order to fix as many things as possible but now this one patch does far,
far, far too much. Apologies in advance for breaking your favourite
backend, but trust me in that the end result will be much better. :)
2011-09-12 08:29:48 +01:00
Uli Schlachter
ea52556531 xcb: Fix fixup_unbounded_with_mask
This code was casting a pixman_box32_t* to cairo_box_t*. However, a box uses
fixed point numbers while the pixman box uses integers which means the result
was off by factor 256.

The fix is to replace the use of _cairo_boxes_limit() with
_cairo_boxes_init_with_clip(). However, this means this function no needs to be
passed a clip instead of a clip region which causes some minor changes to
_composite_boxes().

This improves the result for tighten-bounds again. Out of the tested
combinations, 10 are fixed by this. This bug was hit by code similar to this
(Repeating here since that test has so many different cases):

cairo_set_operator (cr, CAIRO_OPERATOR_IN);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_rectangle (cr, 0, 0, SIZE, SIZE);
cairo_rectangle (cr, 0, 0, SIZE, SIZE);
cairo_rectangle (cr, SIZE / 4, SIZE / 4, SIZE / 2, SIZE / 2);
cairo_clip_preserve (cr);
cairo_fill (cr);

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-09-02 15:12:25 +02:00
Uli Schlachter
ed7f992c13 xcb: Skip drawing if bounded extents are empty
This only wraps the whole code block in an if which checks if the bounded
extents are empty. No other changes are done in here.

This fixes the failed assertion from the tighten-bounds test.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-09-02 15:12:25 +02:00
Uli Schlachter
5f45f696d0 xcb: Add an assert for the tighten-bounds test
This code casts the result of _cairo_xcb_surface_create_similar() to
cairo_xcb_surface_t*. However, the tighten-bounds test makes this run with
bounded extents of size 0x0 and thus _cairo_xcb_surface_create_similar() falls
back to an image surface. Ugly.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-08-30 22:10:34 +02:00
Chris Wilson
70cd3b473d api: Extend cairo_antialias_t to include performace/quality hints
The existing API only described the method to be used for performing
rasterisation and unlike other API provided no opportunity for the user
to give a hint as to how to trade off performance against speed. So in
order to no be overly prescriptive, we extend the NONE/GRAY/SUBPIXEL
methods with FAST/GOOD/BEST hints and leave the backend to decide how
best to achieve those goals.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-30 15:17:38 +01:00
Chris Wilson
6b3d53646e image: peek through a snapshot to the recording surface behind
Fixes record-* after the recent overhaul.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-14 12:37:57 +01:00
Chris Wilson
e849e7c929 image: move surface definition to new header for subclassing
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-13 09:54:28 +01:00
Uli Schlachter
7b5b29cc0f xcb: Handle deferred clear in _upload_image_inplace
Fixes: clip-device-offset, image-surface-source,
composite-integer-translate-source, move-to-show-surface,
source-surface-scale-paint, translate-show-surface, perhaps even more?

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-08-02 22:34:54 +02:00
Andrea Canciani
e04e368748 Remove useless checks for NULL before freeing
This patch has been generated by the following Coccinelle semantic patch:
// Remove useless checks for NULL before freeing
//
// free (NULL) is a no-op, so there is no need to avoid it

@@
expression E;
@@
+ free (E);
+ E = NULL;
- if (unlikely (E != NULL)) {
-   free(E);
(
-   E = NULL;
|
-   E = 0;
)
   ...
- }

@@
expression E;
@@
+ free (E);
- if (unlikely (E != NULL)) {
-   free (E);
- }
2011-07-31 16:46:36 +02:00
Chris Wilson
6448022a05 xcb: Convert the box back to integer coordinates for uploading the image
Silly bug of the day.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-29 16:29:10 +01:00
Chris Wilson
7c6e1b8db8 xcb: Short-circuit multiplying the alpha mask by 1.0
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-29 12:36:21 +01:00
Andrea Canciani
ad3ef3a8fb Silence Clang static analyzer reports
Clang static analysis triggers some reports in non-buggy code.

Silence them trying to follow better coding practices.
2011-07-29 11:54:56 +02:00
Uli Schlachter
8f8149a207 xcb: Error on 0x0 source surfaces
Recording surfaces can be unbounded which causes
_cairo_surface_acquire_source_image to return a 0x0 image surface for them.
Since X11 doesn't like anything with a size of 0x0, we should reject such source
images. Users might still try to mess with 0x0 surfaces, so we will eventually
need a better idea for handling this.

Instead of failing the assertion that was added in the previous commit, this
commit makes cairo-xcb return an error.

This makes the recording-* tests fail instead of crash.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-29 09:23:15 +02:00
Chris Wilson
91faf9c1cf composite: Pass unbounded extents to initialisation
For an unbounded surface we cannot assume (0, 0, surface_width,
surface_height) as that is wrong and causes the operation to appear
clipped.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-26 16:00:43 +01:00
Chris Wilson
a69335a84e API: map-to-image and create-similar-image
A common requirement is the fast upload of pixel data. In order to
allocate the most appropriate image buffer, we need knowledge of the
destination. The most obvious example is that we could use a
shared-memory region for the image to avoid the transfer cost of
uploading the pixels to the X server. Similarly, gl, win32, quartz...

The other side of the equation is that for manual modification of a
remote surface, it would be more efficient if we can create a similar
image to reduce the transfer costs. This strategy is already followed
for the destination fallbacks and this merely exposes the same
capability for the application fallbacks.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-26 14:55:58 +01:00
Chris Wilson
f5d602cb59 xcb: Make composite_opacity_boxes slightly less silly
Being called with no clip, might be unexpected, but it means to fill the
whole extents with the opacity. So do so.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-24 19:45:31 +01:00
Chris Wilson
59612847e3 xcb: set the right members of cairo_color_t for generating the opacity mask
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-24 15:08:03 +01:00
Uli Schlachter
b60694cbc7 xcb: Work around wrong extent computation in the X server
This is basically the same fix as e6c3efdd65. However, this was lost in
b132fae5e8 and thus had to be fixed again.

Fixes: clip-fill-eo-unbounded clip-fill-nz-unbounded

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-21 19:39:25 +02:00
Uli Schlachter
adf026fffe xcb: Fix a NULL dereference
This fixes a crash in the hatchings test case.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-21 19:24:37 +02:00
Chris Wilson
5eb8eacde0 xcb: Always send a clip region along with clipped glyphs
As we do not control the geometry used for the individual glyphs, we
must always send a clip-region so that X can trim the glyph
appropriately. However, in order to avoid sending unnecessary data we
only do so if the clip extents is less than the ink extents of the
glyphs.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-21 18:07:17 +01:00
Uli Schlachter
83df0ab2b6 XCB: Store the flags per-connection only
Every xcb surface had its own copy of the flags from the time that it was
created. This means that, if you want to make use of
cairo_xcb_device_debug_cap_xrender_version() and
cairo_xcb_device_debug_cap_xshm_version(), you first had to create a dummy xcb
surface, use that to get access to the cairo_device_t so that you can use these
functions and only then create your real surface, because the change only
affected new surfaces.

This commit changes everything to use the connection's flag and removes the
per-surface flags. This avoids the dummy surfaces completely.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-21 16:51:26 +02:00
Chris Wilson
6b3e5cd39c xcb: Reduce one pass for masking, now just 2 passes required!
Another 10% off fishbowl for both snb and pnv.

[Note this exposes the bugs in the polygon clipper; naive *and* broken.]

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-20 19:56:27 +01:00
Chris Wilson
a585a092ee xcb: squash initial ChangePicture request for precision
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-20 19:53:12 +01:00