Commit graph

138 commits

Author SHA1 Message Date
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
Chris Wilson
ba406866be stroke: Rely on the tessellator to remove self-intersections
As handling joins/caps between line segments shorter than
half_line_width is tricky.

Rather than also fixing the bug in traps, remove that code. The plan is
to avoiding hitting the traps code, short-circuiting several steps along
the fast rectangular paths.

Fixes line-width-overlap.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-13 16:41:28 +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
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
4032c86127 fallback: Prevent recursion when combining with the clip
We need to special case the handling of unaligned clip regions in order
to prevent the treatment of those as a general path requiring a
clip+mask...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-29 12:36:21 +01: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
b132fae5e8 clip: Rudimentary support for clip-polygon extraction
Step 1, fix the failings sighted recently by tracking clip-boxes as an
explicit property of the clipping and of composition.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-19 21:14:34 +01:00
Chris Wilson
2458120dee pattern: Add observer hooks
In order for custom context to automatically track when a pattern is
modify after being set on the context (and before it is used in an
operator), we need for there to be a callback when the pattern is
modified.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-15 11:05:19 +01:00
Andrea Canciani
85a489f0f2 polygon: Merge _cairo_polygon_init and _cairo_polygon_limit
_cairo_polygon_limit() had to be called immediately after
_cairo_polygon_init() (or never at all).

Merging the two calls is a simple way to enforce this rule.
2010-12-10 11:04:48 +01:00
Andrea Canciani
e9c1fc3188 path: Do not access flags directly
Use inline accessors to hide the flags in the code.

This ensures that flags that need additional computations (example:
is_rectilinear for the fill case) are always used correctly.
2010-10-29 17:31:21 +02:00
Chris Wilson
679e5a600b Differentiate between reducing clip to composite extents and a rectangle
This is required for handling glyphs when rendering directly to the
surface.
2010-07-12 16:33:38 +01:00
Benjamin Otte
3b1c0a4bd6 fallback: Remove span renderer paths
Those paths were broken, as they didn't properly translate the polygon
to the destination size. And rather than adding lots of code that allows
translation, it's easier to just delete this code.

Note that the only user of the code was the GL backend anyway.
2010-05-14 15:56:17 +02:00
Chris Wilson
e6180d1d5e surface-fallback: Only destroy the clip after it has been initialized.
More memfault detected error path errors.
2010-05-07 22:19:43 +01:00
Chris Wilson
a2a2bd62ff surface-fallback: Handle memfaults during clipping.
Don't be lazy, propagate the error rather than asserting.
2010-05-06 14:40:19 +01:00
Benjamin Otte
758ffadcb1 fallback: Only do _fill/compsoite_rectangles on bounded source
For unbounded sources, these optimizations fail to take into account the
regions outside the source.
2010-04-29 16:54:09 +02:00
Benjamin Otte
6288ad719d fallback: translate extents regions properly
The extents clip regions that were created for unbounded operators were
not translated properly. This has been changed now.

This is a followup to 9ce8bef9d6.
2010-04-29 15:38:25 +02:00
Benjamin Otte
9ce8bef9d6 fallback: Propagate extents properly
Otherwise unbounded operators will clear the full surface.
Improves the score for the unbounded-operator test, in particular the
output for the test-fallback case.
2010-04-28 20:25:56 +02:00
Benjamin Otte
91fd97ae7c fallback: Pass the correct extents for unbounbded operations 2010-04-28 20:25:52 +02:00
Benjamin Otte
393da364a7 fallback: Sanitize code that queries surface extents
The previous code was setting extents.is_bounded, but that value has a
completely different meaning.
2010-04-28 18:18:15 +02:00
Benjamin Otte
2a91d42508 fallback: Fix clip_region handling in mask creation
Fixes the xlib-expose-event test.
2010-04-28 13:15:09 +02:00
Andrea Canciani
b8a7f8621a Update FSF address
I updated the Free Software Foundation address using the following script.

for i in $(git grep Temple | cut -d: -f1 )
do
  sed -e 's/59 Temple Place[, -]* Suite 330, Boston, MA *02111-1307[, ]* USA/51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA/' -i "$i"
done

Fixes http://bugs.freedesktop.org/show_bug.cgi?id=21356
2010-04-27 11:13:38 +02:00
Chris Wilson
4d3632761b clip: Report the surface offset when retrieving the clip mask
Stop the callers from guessing the origin of the clip surface by
reporting it explicitly! This enables the clip to bypass any rectangles
overlaid on top of the clip surface, which is common when the backends
limit the clip to the extents of the operation -- but irrelevant to the
actual content of the clip mask
2010-04-25 09:45:41 +01:00
Chris Wilson
4126d580d8 surface-fallback: Free traps on composite_trapezoids() error 2010-03-02 14:38:36 +00:00
Chris Wilson
8a59522bbd surface-fallback: Propagate NOTHING_TO_DO
NOTHING_TO_DO is converted to SUCCESS by the surface layer, so clean up
the code slightly by reducing the number of checks and conversions.
2010-03-02 14:36:16 +00:00
Chris Wilson
21b2457aab fallback: Initialize rects.is_bounded for span renderer. 2010-02-22 15:26:37 +00:00
Chris Wilson
5390df961f clip: Restrict composite extents to clip extents
Fixes test/clip-rectangle-twice.
2010-02-12 12:24:01 +00:00
Chris Wilson
38ba696c48 surface-fallback: We no longer own a reference to the clip surface
_cairo_clip_get_surface() now returns a borrowed reference to the cached
surface on the clip, so we must not destroy it - as Carlos pointed out
when he hit the assert:

12:55 < KaL> ickle: cairo-surface.c:595: cairo_surface_destroy:
Assertion `((*&(&surface->ref_count)->ref_count) > 0)' failed.
12:56 < KaL> ickle: trying to render any pdf file with poppler glib demo
after installing cairo from git master
13:00 < KaL> ickle: well, it seems it has nothing ot do with poppler,
since it crashes in clearlooks src/clearlooks_draw.c:347
2010-01-25 09:20:11 +00:00
Chris Wilson
b713510f21 surface-fallback: Convert to composite rectangles 2010-01-22 23:01:52 +00:00
Chris Wilson
498c10032e clip: Implement clipping using only the high-level operators.
Revamp clipping in preparation for the removal of the low-level interface
and promote backend to use the higher levels. The principle here is that
the higher level interface gives the backend more scope for choosing
better performing primitives.
2010-01-22 23:01:52 +00:00
Chris Wilson
29bedde904 pattern: Add convenience patterns for stock colours
By preallocating in our data segment a couple of solid patterns for the
stock colours, it becomes more convenient when using those in surface
operations, such as when clearing.
2010-01-22 23:01:51 +00:00
Chris Wilson
ae25f1c360 Alter definition of cairo_composite_rectangles_t
This is a more useful definition that is able to individually track the
rectangles that compose the composite operation. This will be used by
the specialist compositors as a means to perform the common extents
determination for an operation.
2010-01-22 23:01:51 +00:00
Chris Wilson
cfd204824f Constify stroke style and matrices.
As a simple step to ensure that we do not inadvertently modify (or at least
generate compiler warns if we try) user data, mark the incoming style
and matrices as constant.
2010-01-22 23:01:49 +00:00
Chris Wilson
c50c8b90c0 Move _cairo_error() to a standalone header
A pending commit will want to include some utility code from cairo and
so we need to extricate the error handling from the PLT symbol hiding.
2010-01-22 22:30:43 +00:00
Benjamin Otte
a2254e5647 [gstate] Apply target device offsets to patterns immediately
Previously target device offsets were applied in cairo-surface.c which
could cause bugs when paths were taken as fallbacks, as for example
pointed out by ade55037ff and quick-fixed
by 79190d8985. The quick-fix is now
unnecessary and was removed.
2009-10-18 22:12:13 +02:00
Chris Wilson
54df07a3da [surface] Don't AND in the desired content.
Gah, that was a horrible mistake. It was a flawed hack to create Pixmaps
of the correct depth when cloning patterns for blitting to the xlib
backend. However, it had the nasty side-effect of discarding alpha when
targeting Window surfaces. The correct solution is to simply correct the
Pixmap of the desired depth and render a matching pattern onto the
surface - i.e. a reversal the current acquire -> clone. See the
forthcoming revised xcb backend on how I should have done it originally.
2009-10-16 17:04:16 +01:00
Chris Wilson
ed94d7caad [fallback] Create intermediate surface with same content.
The goal is to create a similar surface with an identical format to
maximise performance in the subsequent blit, e.g. the xlib backend could
make the similar surface with an identical depth and so use the core
protocol, or the image surface could indeed make an identical copy so
that pixman only has to do a fast memcpy. As there is no direct method
to specify such a clone, we ask the backend for a similar surface of
identical content, and trust that the semantics are clear enough for the
intent to obvious.
2009-10-16 09:00:16 +01:00
Chris Wilson
79190d8985 [surface] Avoid double application of device offset when calling fill()
_cairo_surface_fallback_paint() attempts to avoid a clipped operation if
we can convert the paint into a fill of the clipmask. However by calling
_cairo_surface_fill() we incur a double application of device offset to
the source, triggering various failures.

Company spotted this and managed to extract an excellent minimal test
case, test/clip-device-offset. This commit fixes that failure.
2009-10-15 14:08:01 +01:00
Chris Wilson
378b1e73d9 [fallback] Special case single composite rectangle
Avoid the overhead of region-from-traps extraction for the very frequent
case of using a single (possibly clipped) rectangle with a pattern source.
2009-09-21 04:26:01 +01:00
Chris Wilson
de99f84188 [fallback] Only eliminate the clip if the operation is bounded
For unbounded operations we still need to pass along the clip in order to
correctly limit the extents of the operation.
2009-09-04 08:55:19 +01:00
Chris Wilson
8a323d7c89 [clip] Apply surface offset when combining with clip mask
In order to correctly combine the clip mask with the compositing mask the
clip path must be offset so that it is relative to the destination
surface.
2009-08-29 17:12:31 +01:00
Chris Wilson
21225a7163 [clip] Pass in destination offset for combining with clip-mask
When combining a clip-mask with a subsurface, as when used to combine with
the composite mask, we need to pass the destination surface offset to the
clip so that the paths can be corrected for the new surface.
2009-08-29 17:10:05 +01:00
Chris Wilson
f22045bb4b [fallback] Include implicit closes in the check for rectilinear paths
Fixes test/implicit-close

By forgetting the implicit-close when checking for rectilinear paths, we
tried to feed the triangle (and other diagclose) into the specialised
rectilinear tesselators which completely mishandled that final edge.
2009-08-29 17:07:38 +01:00
Chris Wilson
87175334a5 [gl] Use spans for trapezois.
Always use spans, even for unaligned boxes. In the future (given a new
interface) we may want to emit the common unaligned box code more
efficient than a per-scanline computation -- but for now simply avoid the
requirements to write a temporary CPU buffer.
2009-08-29 17:07:36 +01:00
Chris Wilson
5fdf5b311e [fallback] Reduce paint + clipmask to fill
Under simple, yet common, conditions using a bounded operator and painting
with a single complex clip we can reduce the strength of that operation to
a fill. In effect this removes the need for a temporary mask for some
backends (GL, drm, xlib).
2009-08-29 17:07:34 +01:00
Chris Wilson
33ef32af4e [clip] Use the rectangular tessellator to extract boxes 2009-08-29 08:08:38 +01:00
Chris Wilson
ab035ab2c7 [tessellate] Rectangular special case
Add an even simpler sweep-line tessellator for rectangular trapezoids (as
produced by the rectilinear stoker and box filler).

This is so simple it even outperforms pixman's region validation code for the
purposes of path-to-region conversion.
2009-08-29 08:08:38 +01:00
Chris Wilson
4bf96bad96 [fill] Use trivial rectilinear_to_traps
Avoid a small amount of unnecessary overhead by performing a simple
conversion of the path to traps when it consists solely of simple boxes.
2009-08-29 08:08:33 +01:00
Chris Wilson
a1e0c4b309 [clip] Combine directly onto target
Where it is unlikely that we will reuse the temporary clip surface,
combine the clip directly with the mask.
2009-08-29 08:08:33 +01:00
Chris Wilson
3f12d9ec5d [clip] Use geometric clipping for unaligned clips
For the simple cases where the clip is an unaligned box (or boxes), apply
the clip directly to the geometry and avoid having to use an intermediate
clip-mask.
2009-08-29 08:08:33 +01:00
Chris Wilson
85094c4eee [clip] Eliminate redundant clips
First perform a simple geometric clip to catch the majority of cases where
an unaligned clip has been set outside the operation extents that can be
discarded without having to use an image surface.

This causes a dramatic increase of over 13x for the poppler-bug-12266
trace and little impact elsewhere for more sensible clippers.
2009-08-29 08:08:32 +01:00