Commit graph

3965 commits

Author SHA1 Message Date
Chris Wilson
813cbf13dd [path] Separate the approx. bounds into 3 distinct functions
Based on feedback from Jeff Muizelaar, there is a case for a very quick
and dirty extents approximation based solely on the curve control points
(for example when computing the clip intersect rectangle of a path) and
by moving the stroke extension into a core function we can clean up the
interface for all users, and centralise the logic of approximating the
stroke extents.
2008-12-18 14:55:20 +00:00
Chris Wilson
dea40e61ba [path] Return the fixed-point bounds of the path
When analysing the stroke extents, we need the original fixed-point
extents so that we do not incur an OBO when we round-to-integer a second
time. We also need a more accurate estimate than simply using the control
points of the curve, so pass in tolerance and decompose until someone
discovers a cheaper algorithm to determine the precise aligned bounding
box of a bezier curve.
2008-12-18 12:06:47 +00:00
Chris Wilson
3424b5f8c8 [scaled-font] Make check-doc happy
Replace a structure marker '#' with a macro marker '%'.
2008-12-18 12:06:46 +00:00
Chris Wilson
ce0b136a44 Query the backend to see if we can repaint the solid pattern.
If we are dithering on the Xlib backend we can not simply repaint the
surface used for a solid pattern and must recreate it from scratch.
However, for ordinary XRender usage we do not want to have to pay that
price - so query the backend to see if we can reuse the surface.
2008-12-18 12:06:45 +00:00
Chris Wilson
97a00bdd4e [cairoint.h] Wrap macro in parenthesis
Ensure that the stride calculation macro is not influenced by surrounding
precedence issues by enclosing it in a pair of parenthesis.
2008-12-18 10:40:14 +00:00
Chris Wilson
6458903c95 [image] Eliminate the short-lived context used for coercing.
When coercing from one image format to another we performed a paint
operation using a temporary context - this is overkill as we can just call
_cairo_surface_paint() directly.
2008-12-18 10:40:14 +00:00
Chris Wilson
2d790daa95 [pattern] Use a solid pattern for a uniform gradient.
If each color stop in a gradient is identical, replace the gradient
surface with a simple solid surface. As seen in the wild.
2008-12-18 10:40:13 +00:00
Chris Wilson
25a4677200 [analysis] Use approximate extents.
Use the approximate path based extents to avoid tessellation.
2008-12-18 10:40:13 +00:00
Behdad Esfahbod
18bca91411 [twin] close_path the 'o' 2008-12-18 02:12:14 -05:00
Behdad Esfahbod
5ee6aad471 [toy] Use twin font if font backend returns UNSUPPORTED 2008-12-17 18:19:24 -05:00
Behdad Esfahbod
eb069094ea Treat any toy family starting with "@cairo:" as request for twin 2008-12-17 18:19:24 -05:00
Jeff Muizelaar
32c6610905 Call _cairo_error when propagating error status from the font_face. 2008-12-17 17:43:37 -05:00
Jeff Muizelaar
1d72e53c3e Add a missing _cairo_error() to a bunch of status returns. 2008-12-17 17:42:18 -05:00
Behdad Esfahbod
af3a892c3e [ft] Remove stale comment 2008-12-17 16:45:28 -05:00
Karl Tomlinson
e4d7c87b5e [ft] Don't call FT_Done_Face() on faces we did not create 2008-12-17 16:40:12 -05:00
Behdad Esfahbod
6778a5f67a [.gitignore] Update 2008-12-17 16:20:18 -05:00
Behdad Esfahbod
26f4719999 [scaled-font] Improve docs 2008-12-17 16:08:32 -05:00
Behdad Esfahbod
f7ab65e9b0 Clean up toy font face handling
This commit moves the toy-to-real mapping from the scaled font creation
time to font face creation.  A toy font face will keep an internal ref
to an implementation face.  Then cairo_scaled_font_create() will simply
substitute the implementation face before creating anything.

This also modifies the cairo-ft toy creation in that we now create a
non-resolved pattern and store it in a cairo-ft font-face.  We then
do the resolving and unscaled font creation at scaled-font creation
time.  This also means that cairo_ft_font_face_create_for_pattern()
now accepts non-resolved patterns too, and does the right thing about
them.  As much as that can be called right.

Some testing of toy font creation performance is in order, as is testing
win32 and quartz font backends.
2008-12-17 15:13:35 -05:00
Chris Wilson
43edb4dd7b Fix compilation with gcov
We need to add --coverage to LDFLAGS, so create CAIRO_LDFLAGS and use that
to populate AM_LDFLAGS.
2008-12-14 16:44:03 +00:00
Chris Wilson
1950abd14c [doc] Fix erroneous doc comment.
A normal comment was marked as a gtk-doc entry and thus causing gtk-doc to
complain.
2008-12-14 16:39:24 +00:00
Chris Wilson
2b7c6f361a [skiplist] Allocate elements in chunks.
Use a pool allocator to preallocate a chunk from which to allocate the
skiplist elements (if we failed to reallocate from the freelists).
2008-12-12 13:43:36 +00:00
Chris Wilson
1d68ee73f8 [pattern] Compute the combined color content.
When multiplying two colors together, the combined content is simply the
or of the their contents.
2008-12-12 13:21:11 +00:00
Chris Wilson
30cef3116e [spans] Add a sentinel cell to the cell_list.
By terminating the list with a cell for INT_MAX, we remove a few
conditionals from the hot-paths.
2008-12-12 12:00:45 +00:00
Chris Wilson
3b2bb95249 [spans] Embed 64 edge buckets into polygon
Frequently we only need a few y-buckets, so embed 64 into the parent
structure.
2008-12-12 12:00:45 +00:00
Chris Wilson
70235df72e [spans] Pool capacity is in bytes not elements.
Set the polygon capacity to a shade under 8k, not 200 bytes, reducing the
number of malloc calls made by the scan convertor by a factor of 40!
2008-12-12 12:00:44 +00:00
Chris Wilson
565b3d6ad6 [script] Switch to hyphens.
Using hyphen in the operators is easier to read than underscores.
2008-12-12 12:00:43 +00:00
Chris Wilson
af53297a97 [cairo] Use a stack buffer for text path.
First try to allocate glyphs from the stack, similar to cairo_show_text().
2008-12-12 12:00:41 +00:00
Chris Wilson
09589e20e1 [clip] Intersect to region extents.
When querying the intersection of a rectangle with the clip region, the
result only depends upon the region extents so we do not need to perform
an expensive region-region intersection computation.
2008-12-12 12:00:40 +00:00
Chris Wilson
c5acb125e9 [surface] Avoid a short-lived context during fallback_clone_similar()
We can paint to the surface directly without need of a temporary context,
so do so.
2008-12-12 12:00:36 +00:00
Chris Wilson
bcb2724920 [path] Mark points as const during _cairo_path_fixed_interpret()
Use const to document the read-only nature of the arguments passed to the
callbacks.
2008-12-12 11:11:49 +00:00
Chris Wilson
68b29cafa5 [spline] Propagate errors during add point.
Yikes! The callback could fail so we need to propagate the error status.
2008-12-12 11:11:48 +00:00
Chris Wilson
2f3905dec3 [image] Set status on error path.
We failed to set the status after cairo_image_surface_create() returned an
error.
2008-12-12 11:11:48 +00:00
Chris Wilson
095a1fd786 [gstate] Remove culled glyphs from clusters.
Sascha Steinbiss reported a bug where the PDF backend was reading beyond
the end of the glyph array:
http://lists.cairographics.org/archives/cairo/2008-December/015976.html.

It transpires that in the early glyph culling in the gstate we were
not updating the clusters to skip culled glyphs.
2008-12-12 10:20:47 +00:00
Julien Danjou
834f1d7b70 [xcb] check for render extension presence
Otherwise this may leads to an invalid memory access to r.

Fixes: Bug 18588 - XCB backend fails with missing render.
https://bugs.freedesktop.org/show_bug.cgi?id=18588

Signed-off-by: Julien Danjou <julien@danjou.info>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2008-12-12 10:20:47 +00:00
Chris Wilson
e184bf0d35 Fix compilation with --enable-png=no
Adrian Johnson spotted that the build was broken if the PNG functions were
disabled. Fix.
2008-12-12 10:20:47 +00:00
Jeff Muizelaar
391c602640 Merge branch '1.8' 2008-12-11 14:41:01 -05:00
Jeff Muizelaar
2f1b581f54 [quartz] Create a copy instead of increasing the reference
The pattern could be stack allocated so we can't take a reference to it.

Some testing of quartz shows that it doesn't deal with malloc failure particularily
well. In the best case CGFunctionCreate returns NULL, in the worst case it just crashes.
Quartz does seem to be able to handle a NULL CGFunctionRef, so returning NULL if
we fail to copy the pattern avoids complicating the code to deal with
propagating the failure and shouldn't cause any additional crashes.

Based on a patch by Paolo Bonzini.
2008-12-11 14:39:23 -05:00
Jeff Muizelaar
f7b3f1b7d7 [quartz] Propagate const patterns through the casts
As part of this avoid using cairo_pattern_get_matrix() because it requires a
'cairo_pattern_t *' instead of 'const cairo_pattern *'

Also, make a copy of the pattern before pasing it in to cairo_set_source()
2008-12-10 17:55:28 -05:00
Jeff Muizelaar
d93bf10edc [quartz] Create a copy of the pattern so that the reference counts are balanced
The pattern could be stack allocated so we can't take a reference to it;
instead make a copy.

Based on a patch by Paolo Bonzini.
2008-12-10 17:41:45 -05:00
Jeff Muizelaar
db4c427e84 [quartz] Change some pattern casts to access to the base class
Avoiding casts gives us some more type safety.
2008-12-09 12:03:11 -05:00
Jeff Muizelaar
5f60e2e004 Reorganize the (set|get)_antialias prototypes
Move _cairo_gstate_set_antialias() and _cairo_gstate_get_antialias() into the
gstate section of cairoint.h
2008-12-09 11:41:10 -05:00
Jeff Muizelaar
673640a3b3 [win32] Use MOD instead of the '%' operator
Repeat should be handled using MOD instead of '%' so that negative numbers
are handled as expected. E.g. -1 mod 600 = 599, not 495 as the '%' operator
gives. This was causing https://bugzilla.mozilla.org/show_bug.cgi?id=466258

Patch from Robert O'Callahan
2008-12-08 11:37:38 -05:00
M Joonas Pihlaja
5e06085b48 [cairo-spans] Render clip mask surfaces with spans if we can.
Generating surface masks for clipping can also benefit from span
rendering sometimes.
2008-12-07 03:51:07 +02:00
M Joonas Pihlaja
18634c3702 [cairo-spans] Hook up filling paths with spans to cairo-surface-fallback.c.
This speeds up the mask generation step in cairo_fill() for the image
surface by up to 10x in especially favourable cases.

image-rgba                              twin-800 7757.80 0.20% -> 749.41 0.29%: 10.36x speedup
image-rgba spiral-diag-pixalign-nonzero-fill-512   15.16 0.44% ->   3.45 8.80%:  5.54x speedup

More typical simple non-rectilinear geometries are sped up by 30-50%.
This patch does not affect any stroking operations or any fill
operations of pixel aligned rectilinear geometries; those are still
rendered using trapezoids.
2008-12-07 03:27:13 +02:00
M Joonas Pihlaja
85b81a3e59 [cairo-spans] Implement a span renderer for cairo_image_surface_t.
This implementation first produces an A8 alpha mask and then
pixman_image_composites the result to the destination with the source.
Clipping is handled by pixman when it is region clipping or by
cairo-surface-fallback when it is something more complex.
2008-12-06 14:04:36 +02:00
M Joonas Pihlaja
7994fc06ad [cairo-spans] New cairo_tor_scan_converter_t.
Imports a new polygon scan converter implementation from the
repository at

http://cgit.freedesktop.org/~joonas/glitter-paths/

Glitter paths is a stand alone polygon rasteriser derived from David
Turner's reimplementation of Tor Anderssons's 15x17 supersampling
rasteriser from the Apparition graphics library.  The main new feature
in this implementation is cheaply choosing per-scan line between doing
fully analytical coverage computation for an entire row at a time
vs. using a supersampling approach.
2008-12-06 14:04:36 +02:00
M Joonas Pihlaja
2078e5b20f [cairo-spans] New _cairo_path_fixed_fill_using_spans().
Adds a helper function for backends to use for filling a path using
spans.
2008-12-06 14:04:36 +02:00
M Joonas Pihlaja
4a9b274eeb [cairo-spans] Add a check/create_span_renderer backend methods.
A surface will have the chance to use span rendering at cairo_fill()
time by creating a renderer for a specific combination of
pattern/dst/op before the path is scan converted.  The protocol is to
first call check_span_renderer() to see if the surface wants to render
with spans and then later call create_span_renderer() to create the
renderer for real once the extents of the path are known.

No backends have an implementation yet.
2008-12-06 14:04:36 +02:00
M Joonas Pihlaja
948c3526dc [cairo-spans] New abstract types for scan converting polygons.
A cairo_span_renderer_t implementation can be provided by a surface if
it wants to render paths as horizontal spans of the alpha component of
a mask.  Its job is to composite a source pattern to the destination
surface when given spans of alpha coverage for a row while taking care
of backend specific clipping.

A cairo_scan_converter_t takes edges of a flattened path and generates
spans for a span renderer to render.
2008-12-06 14:04:35 +02:00
M Joonas Pihlaja
4b227143b3 [cairo-spans] Introduce a type to track which pixels combine in a compositing op.
A cairo_composite_rectangles_t contains the coordinates of rectangular
windows into each of the source pattern, mask, clip and destination
surface containing the pixels that will combine in a compositing
operation.  The idea is to have a uniform way to represent all the
translations involved rather than overloading parameters like src_x/y,
dst_x/y, etc., sometimes with different incompatible meanings across
functions.
2008-12-06 14:04:35 +02:00