Commit graph

6542 commits

Author SHA1 Message Date
Chris Wilson
9f4f41de7d [tutorial] Correct twin font name
We changed the name for the builtin font  from "cairo" to "<cairo>" to
reduce possible naming conflicts - update the tutorial to match.
2008-12-12 13:23:09 +00:00
Chris Wilson
4ff884fe4d [test] Check idempotency of append_path() -> copy_path()
The API should preserve the precision across the public interface so that
the user is able to retrieve the co-ordinates that he used to construct
the path. However since we transform the path to a 24.8 fixed-point
internal represent we currently incur a precision-loss - the affects of
which can be seen in the miter-precision test case for example. It is
planned to move to keeping the path as doubles until the backend
explicitly requests the fixed-point coodinates (and some backends, e.g.
pdf, might only ever use the doubles). Then, barring rounding errors
during path transformations, we should be able to return the exact path
the user set (under an identity CTM, of course ;-).
2008-12-12 13:23:09 +00:00
Chris Wilson
fe4af195a7 [test] Add a rectilinear-dash test case.
Exercise dashing on pixel-aligned boundaries to test extending the
rectilinear stroker to handle dashes.
2008-12-12 13:23:08 +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
6f284587a4 [script] Add examples
Add some simple examples to demonstrate CairoScript, courtesy of M Joonas
Philaja.
2008-12-12 12:00:44 +00:00
Chris Wilson
463dc28913 [script] Allocate the interned strings from a permanent pool
Reduce memory fragmentation by allocating the permanent strings from a
single pool.
2008-12-12 12:00:44 +00:00
Chris Wilson
adc9c90d79 [script] Freed object cache.
Cache the last freed object to reduce malloc pressure.
2008-12-12 12:00:44 +00:00
Chris Wilson
1042909796 [script] Replay multiple files.
Iterate over the argument vector and replay each file on the command line.
2008-12-12 12:00:44 +00:00
Chris Wilson
c5c04528b5 [script] Slab allocator
Allocate small objects from a pool and maintain a per-size free-list.
2008-12-12 12:00:44 +00:00
Chris Wilson
83f0e6cf62 [script] Inline the stack push
Frequently to push an object onto the stack all we need is to simply
perform the struct copy - so inline it and only call the out-of-line
function if we need to enlarge the stack.
2008-12-12 12:00:43 +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
3abfd836a0 [script] Null constructor
Expose 'null', principally for comparison purposes.
2008-12-12 12:00:43 +00:00
M Joonas Pihlaja
7540ac7f23 [script] Reverse direction of bitshift.
Positive shift counts should shift left according to PostScript.
2008-12-12 12:00:43 +00:00
Chris Wilson
4be479cc63 [script] Add simple to integer converter
Simple operator to coerce the type of the object on top of the stack to
integer.
2008-12-12 12:00:43 +00:00
Chris Wilson
6711b591b9 [script] Simple replay.
Basic script executer.
2008-12-12 12:00:42 +00:00
Chris Wilson
177a68ef3e [script] Add a few mathematical constants
Just pi and the sqrt(2) for the moment, more to come on demand.
2008-12-12 12:00:42 +00:00
Chris Wilson
5dfaa22a57 [script] Add repeat operator.
Simple operator to repeat procedure n times.
2008-12-12 12:00:42 +00:00
M Joonas Pihlaja
738cb32745 [script] Fix \t escapes in string literals.
Typo \r -> \t.
2008-12-12 12:00:42 +00:00
M Joonas Pihlaja
265ebd372a [script] Flesh out the relational comparison operators to be more PostScript-like.
The relational comparison operators can now compare strings vs names
by content as well as performing automatic type promotions on the
numeric types.  For other types relational comparisons succeeed
only if the values compare equal according to the eq operator, and
put the interpreter into a type-error state otherwise.
2008-12-12 12:00:42 +00:00
M Joonas Pihlaja
05afec7a8a [script] Implement the ne operator. 2008-12-12 12:00:41 +00:00
M Joonas Pihlaja
1aeb96dc28 [script] Implement PostScript-like semantics for the eq operator.
The eq operator would only work for some types and put the
interpreter in an error state if passed objects it didn't
know how to compare.  It would also not compare strings
by value nor allow strings to be compared to names.
This patch makes any two objects comparable.
2008-12-12 12:00:41 +00:00
M Joonas Pihlaja
620028fd19 [script] Don't segfault when hashing empty strings.
Check for the empty string.
2008-12-12 12:00:41 +00:00
M Joonas Pihlaja
4ba77f7765 [script] Fix dictionary construction to access the right stack slots.
It bound values to themselves and ignored keys.
2008-12-12 12:00:41 +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
888f62feaa [test] Propagate error from path
If the path is in error, just append it to the context so that the error
is propagated correctly.
2008-12-12 11:11:49 +00:00
Chris Wilson
f13f63e3d8 [test/clip-nesting] Propagate status from sub-context.
Use cairo_path_append() to propagate an error status from a child context
to it parent so that it is properly reported under memfault.
2008-12-12 11:11:49 +00:00
Chris Wilson
e6e33b036f [test/solid-pattern-cache-stress] Propagate status from sub-contexts.
Use a cairo_append_path() to set an arbitrary error status on the parent
context, in order to propagate errors from a child.
2008-12-12 11:11:49 +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
dfc49a67e6 [test] Trim the number of fallback resolutions tested.
Simplify the test matrix to only include testing the fallback-resolution
of a uniform scale in one or both axes.
2008-12-12 11:11:48 +00:00
Chris Wilson
0ebbcd671c [test] Fix memleak from fallback-resolution.
The test-name was being recreated for every pass, but was never freed.
2008-12-12 11:11:48 +00:00
Chris Wilson
a9697e5fb0 [test] Exercise glyph culling.
Sascha Steinbiss reported an issue with glyph culling,
http://lists.cairographics.org/archives/cairo/2008-December/015976.html,
whereby we failed to update the text clusters upon culling the glyphs in
the gstate and proceeded to read beyond the end of the glyph array in the
PDF backend. This test case setups a similar condition as reported, by
trying to write a wide string into a small box.
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