Commit graph

4450 commits

Author SHA1 Message Date
Chris Wilson
6dfe050d63 [polygon] Amalgamate collinear edges
Combine sequential collinear edges into a single edge, this benefits
immensely by feeding fewer edges into either the tessellator or spans.
2009-08-29 08:08:31 +01:00
Chris Wilson
0f8af05484 [fallback] Avoid tessellating empty polygons
I added an assert inside the tessellator to ensure that empty polygon were
not being propagated that far...
2009-08-29 08:08:31 +01:00
Chris Wilson
09377a7163 [freelist] Lazy initialisation of pools 2009-08-29 08:08:30 +01:00
Chris Wilson
6f0340e2e5 [clip] Use the rectilinear tessellator
We can ensure that we always produce a clip region when possible by using
the rectilinear tessellator to convert complex, device-aligned polygons to
regions. Prior to using the tessellator, we relied on pixman's region code
which could only handle a union of rectangles.
2009-08-29 08:08:30 +01:00
Chris Wilson
e3820bef20 [fill] Short-circuit extents on an empty path.
If the path is empty, avoid redundant polygonisation and tessellation by
simply returning the empty extents.
2009-08-29 08:08:30 +01:00
Chris Wilson
4051ed328b [tessellator] Special case rectilinear tessellation
For the frequent cases where we know in advance that we are dealing with a
rectilinear path, but can not use the simple region code, implement a
variant of the Bentley-Ottmann tessellator. The advantages here are that
edge comparison is very simple (we only have vertical edges) and there are
no intersection, though possible overlaps. The idea is the same, maintain
a y-x sorted queue of start/stop events that demarcate traps and sweep
through the active edges at each event, looking for completed traps.

The motivation for this was noticing a performance regression in
box-fill-outline with the self-intersection work:

  1.9.2 to HEAD^: 3.66x slowdown
  HEAD^ to HEAD:  5.38x speedup
  1.9.2 to HEAD:  1.57x speedup

The cause of which was choosing to use spans instead of the region handling
code, as the complex polygon was no longer being tessellated.
2009-08-29 08:08:29 +01:00
Chris Wilson
82ccb4c70c [clip] Use special-purpose fill_to_region()
Avoid the creation of temporary traps when generating a region, by calling
the to_region() directly.
2009-08-29 08:08:29 +01:00
Chris Wilson
41adeac988 [fallback] Avoid going through traps for trivial regions. 2009-08-29 08:08:29 +01:00
Chris Wilson
55bd590561 [tessellator] Use a priority queue for the events
The skip list was suffering from severe overhead, so though the search was
quick, the extra copies during insertion and deletion were slow.
2009-08-29 08:08:29 +01:00
Chris Wilson
ebfcc2ce8f [tessellator] Remove the skiplist for the active edges
The active edge list is typically short, and the skiplist adds significant
overhead that far outweigh the benefit of the O(n lg n) sort. Instead we
track the position of the last insertion edge, knowing that the start
events are lexicographically sorted, and begin a linear search from there.
2009-08-29 08:08:29 +01:00
Chris Wilson
36480fe531 [traps] Increase exponential expansion factor.
Grow the traps more rapidly, as the allocations are very short-lived so
the over-allocation is less of an issue.
2009-08-29 08:08:28 +01:00
Chris Wilson
9d51c03bad [traps] Compute extents on demand. 2009-08-29 08:08:28 +01:00
Chris Wilson
f8bb3617c3 Eliminate self-intersecting strokes.
We refactor the surface fallbacks to convert full strokes and fills to the
intermediate polygon representation (as opposed to before where we
returned the trapezoidal representation). This allow greater flexibility
to choose how then to rasterize the polygon. Where possible we use the
local spans rasteriser for its increased performance, but still have the
option to use the tessellator instead (for example, with the current
Render protocol which does not yet have a polygon image).

In order to accommodate this, the spans interface is tweaked to accept
whole polygons instead of a path and the tessellator is tweaked for speed.

Performance Impact
==================

...
Still measuring, expecting some severe regressions.
...
2009-08-29 08:08:28 +01:00
Benjamin Otte
40aefac5d7 [xlib] DO_XCOPYAREA and DO_XTILE optimizations break with Window source
Cairo should include the contents of subwindows when using a Window as a
source but will clip to subwindows when using a Window as a destination.
This can be set using the GC's subwindow_mode.

XCopyArea and XFillRectangle can however only use one GC for both source
and destination. Cairo's mode is set to (the default) ClipByChildren.
This means that copying from a Window is broken, so we only allow the
optimization when we know that the source is a Pixmap.

The performance impact of this change has not been tested. It should be
small, as the code will use XRender otherwise.

If it turns out to be a bigger impact, the optimizations could be
improved by doing a two-step copy process:
1) Copy to an intermediate Pixmap with IncludeInferiors
2) Copy to the destination with ClipByChildren
(potentially omitting one one of the steps if source or destination are
known to be Pixmaps).

references:
commit 0c5d28a4e5
https://bugs.freedesktop.org/show_bug.cgi?id=12996
2009-08-26 21:22:52 +02:00
Chris Wilson
d1b8e260d4 [qt] Fix compilation
Enabling 'FAST CLIP' appears to trigger an infinite loop so disable.

Enabling 'FAST FILL' has limited effect on performance, so disable whilst
the basic QT surface is improved.
2009-08-10 21:31:10 +01:00
Chris Wilson
dff0a91742 [xlib] Rewrite UNSUPPORTED() avoiding gcc-ism
Behdad pointed out that fprintf() returns a value so that we could simply
use the comma operator to return the correct value instead of the
expression-block gcc-ism.
2009-08-10 18:01:14 +01:00
Andrea Canciani
d4d0fcb4a8 [quartz] Compile fix for show_glyphs
Correct the prototype for _cairo_quartz_surface_show_glyphs().
2009-08-10 17:44:31 +01:00
Chris Wilson
2a2a19457b [surface] Check for a NULL snapshot
The backend is permitted to return a NULL surface when snapshotting to
indicate that it cannot (or choses not to) implement the method.
2009-08-10 17:44:25 +01:00
Chris Wilson
2e8ce34454 [quartz] Use the implementation font-face not the associated
As the associated is now explicitly the font-face used to create the font
by the user, whereas what we require is the current implementation
(quartz) font.
2009-08-10 17:20:00 +01:00
Chris Wilson
a4dc372bab [scaled-font] Update API documentation
Now that the toy-font-face is exposed to the user, it is expected to be
returned when the user queries the font face associated with a scaled font.
2009-08-10 17:19:53 +01:00
Andrea Canciani
3487049195 [quartz] Fix one more compile error 2009-08-09 21:47:40 +01:00
Chris Wilson
c2e75b9993 [quartz] Attempt to fix compile errors
ranma42 spotted that the quartz-backend no longer compiled after bed270,
so once again attempt to blindly fix those errors...
2009-08-09 21:12:36 +01:00
Chris Wilson
19f54d872f [gl] Move hidden cairo_gl_surface_create() proto to header
Make check-plt.sh happy
2009-08-06 10:40:32 +01:00
Chris Wilson
1327df2cf2 [pattern] Invalid access beyond end of freed-pool
Oops, we were attempting to return a pointer from beyond the end of our
array.
2009-08-06 10:16:45 +01:00
Chris Wilson
cb30c1f367 [path] Extend identical lines.
If a subsequent PATH_OP is just a continuation of the previous line, i.e.
it has the same gradient, then just replace the end-point of the previous
line with the new point rather than adding a new operation. Surprisingly
this occurs in the wild, but the main motivation is a future optimisation
to reduce the number of intersections during stroke-to-path.
2009-08-06 10:16:02 +01:00
Chris Wilson
85b688a3f6 [matrix] Use hypot()
Use hypot() instead of open-coding sqrt(x*x + y*y). In theory, the
compiler could emit highly efficient code. In practice it's slower, but
more likely to be more accurate -- but the difference over a bare sqrt()
is likely not to be perceptible.
2009-08-06 10:15:51 +01:00
Chris Wilson
60c574ad06 [surface] Protect against the user setting a fallback resolution of 0.
Bug 23067 -- using clear drawing operator crashes printing
http://bugs.freedesktop.org/show_bug.cgi?id=23067

Here we were hitting an assert within the paginated surface after creating
a zero sized fallback image, due to the paginated surface being created
with an x fallback resolution of 0 dpi (by
_gtk_printer_create_cairo_surface(), gtk/gtkprinter.c:924).

Avoid the bug by guarding against bad input to
cairo_surface_set_fallback_resolution() which also allows us to identity
the invalid caller.
2009-08-06 10:12:01 +01:00
Chris Wilson
5dd29d7e2d [directfb] Conditionally use DSPF_BGR555
Appears that this token is more recent than some of my headers, so check
for its presence before use.
2009-08-06 10:10:06 +01:00
Chris Wilson
640a0be2e2 Merge branch 'gl-glyph-cache'
Comparing the glyph-cache on an i915:

   gnome-terminal-20090728:  1.51x speedup
          firefox-20090601:  No change
2009-07-31 19:34:59 +01:00
Chris Wilson
5c2239be4b [gl] Use scissors rather than allocating a temporary depth buffer. 2009-07-31 17:55:40 +01:00
Chris Wilson
728d3f6383 Revert "[gl] Fixup unbounded regions after spans"
This reverts commit f7121ca888.
2009-07-31 16:24:37 +01:00
Chris Wilson
74bdea1249 [spans] Emit empty rows.
A problem that does not present itself whilst using spans to intermediate
masks is that the tor-span-convertor did not emit the empty rows. When
compositing directly using spans with an unbounded operator this was
causing rendering artefacts, for overlapping-glyphs and the gl backend.
2009-07-31 16:20:54 +01:00
Chris Wilson
1e4b9ab04b [gl] Return status from _render_glyphs() 2009-07-31 15:28:14 +01:00
Chris Wilson
097484da6f [boilerplate] Conditionally tweak the xlib surface
Prior to introduction of the buggy members to the surface, we obviously
cannot set them. However, the boilerplate code is meant to compile against
older revisions of the library so we need to check for the existence prior
to use.
2009-07-31 14:48:32 +01:00
Chris Wilson
786d1f962a [xlib] Use server-side gradients.
We can offload creation of gradients to server that support RENDER 0.10
and later. This greatly reduces the amount of traffic we need to send over
our display connection as the gradient patterns are much smaller than the
full image. Even if the server fallbacks to using pixman, performance
should be improved by the reduced transport overhead. Furthermore this is a
requisite to enable hardware accelerated gradients with the xlib backend.

Running cairo-perf-trace on tiny, Celeron/i915:

  before: firefox-20090601 211.585
   after: firefox-20090601 270.939

and on tiger, CoreDuo/nvidia:

  before: firefox-20090601 70.143
   after: firefox-20090601 87.326

where linear gradients are used extensively throughout the GTK+ theme.
Not quite the result I was expecting!

In particular, looking at tiny:

 xlib-rgba paint-with-alpha_linear-rgba_over-512   47.11 (47.16 0.05%) -> 123.42 (123.72 0.13%):  2.62x slowdown
█▋
 xlib-rgba paint-with-alpha_linear3-rgba_over-512   47.27 (47.32 0.04%) -> 123.78 (124.04 0.13%):  2.62x slowdown
█▋
 xlib-rgba paint-with-alpha_linear-rgb_over-512   47.19 (47.21 0.02%) -> 123.37 (123.70 0.13%):  2.61x slowdown
█▋
 xlib-rgba paint-with-alpha_linear3-rgb_over-512   47.30 (47.31 0.04%) -> 123.52 (123.62 0.09%):  2.61x slowdown
█▋
 xlib-rgba     paint_linear3-rgb_over-512   47.29 (47.32 0.05%) -> 118.95 (119.60 0.29%):  2.52x slowdown
█▌
 xlib-rgba     paint_linear-rgba_over-512   47.14 (47.17 0.06%) -> 116.76 (117.06 0.16%):  2.48x slowdown
█▌
 xlib-rgba    paint_linear3-rgba_over-512   47.32 (47.34 0.04%) -> 116.85 (116.98 0.05%):  2.47x slowdown
█▌
 xlib-rgba      paint_linear-rgb_over-512   47.15 (47.19 0.03%) -> 114.08 (114.55 0.20%):  2.42x slowdown
█▍
 xlib-rgba paint-with-alpha_radial-rgb_over-512  117.25 (119.43 1.21%) -> 194.36 (194.73 0.09%):  1.66x slowdown
▋
 xlib-rgba paint-with-alpha_radial-rgba_over-512  117.22 (117.26 0.02%) -> 193.81 (194.17 0.11%):  1.65x slowdown
▋
 xlib-rgba     paint_radial-rgba_over-512  117.23 (117.26 0.02%) -> 186.35 (186.41 0.03%):  1.59x slowdown
▋
 xlib-rgba      paint_radial-rgb_over-512  117.23 (117.27 0.02%) -> 184.14 (184.62 1.51%):  1.57x slowdown
▋

Before 1.10, we may choose to disable server-side gradients for the
current crop of Xorg servers, similar to the extended repeat modes.

[Updated by Chris Wilson. All bugs are his.]
2009-07-31 14:33:01 +01:00
Chris Wilson
53cbbad8fb [xlib] Disable extended repeat modes if RENDER < 0.10
The extended repeat modes were only introduced in RENDER 0.10, so disable
them if the server reports an earlier version. This is in addition to
disabling the repeat modes if we know (guess!) the server to have a buggy
implementation.
2009-07-31 13:17:23 +01:00
Chris Wilson
71f5649846 [path] Fix iter to handle circular list of buffers
When switching the path over to use the circularly linked list, 73f801,
I missed updating the path iterator.
2009-07-29 16:17:12 +01:00
Chris Wilson
acfcf4a31b [path] Remove the broken rel-curve-to as line-to
As pointed out by Andrea, and now tested by test/degenerate-rel-curve-to,
this attempt at removing degenerate curve-to was broken.
2009-07-29 16:17:11 +01:00
Chris Wilson
f7121ca888 [gl] Fixup unbounded regions after spans 2009-07-28 20:56:56 +01:00
Chris Wilson
5631f01075 [gl] Cache texture snapshots. 2009-07-28 20:56:50 +01:00
Chris Wilson
3b0bb2cfd2 [gl] Replace DrawPixels with TexSubImage 2009-07-28 20:56:48 +01:00
Chris Wilson
4b7a1a2da7 [gl] Disable the EXTEND_REFLECT convertor
As we can handle EXTEND_REFLECT via the samplers, we do not need to
convert such patterns to EXTEND_REPEAT during acquisition.
2009-07-28 20:56:48 +01:00
Chris Wilson
780a95b024 [gl] Trim glyphs to surface/clip extents. 2009-07-28 20:56:39 +01:00
Chris Wilson
b1227dea29 [gl] Render glyphs to an intermediate mask as opposed to falling back.
There are many common scenarios, mostly involving overlapping glyphs,
for which to guarantee correct rendering we have to composite the glyphs
via an explicit mask. That is instead of just blending the glyphs on to
the destination, we have to add the glyphs to a mask, and then composite
that mask+source with the destination.
2009-07-28 16:39:52 +01:00
Chris Wilson
cd259489e2 [gl] Fallback for overlapping glyphs. 2009-07-28 15:58:54 +01:00
Chris Wilson
3d8f1d3dc8 [gl] Only unlock the glyph cache when full. 2009-07-28 15:38:45 +01:00
Adrian Johnson
922b1fe8e3 Ensure Type 3 fonts do not use the name .notdef in the PS encoding 2009-07-28 22:34:42 +09:30
Chris Wilson
a251e34dbb [gl] Move check for vertex buffer support to individual operations.
As we can fallback instead of using vertex buffers, do so rather than
preventing any use of GL acceleration.
2009-07-28 13:46:36 +01:00
Chris Wilson
90657bacc3 [gl] Separate out supported operator check.
By performing the check on whether the operator is supported prior to
acquiring the context, we do not need to handle the error part way
through the context setup. This makes the code much cleaner, and save
some work for the unsupported cases.
2009-07-28 13:30:31 +01:00
Chris Wilson
21d50e2163 [gl] Unthaw font along contended path.
If we bail after freezing the font, make sure we thaw that it is thawed
before returning.
2009-07-28 13:30:26 +01:00