Commit graph

98 commits

Author SHA1 Message Date
Bryce Harrington
d5b634da61 Factor out the ISFINITE() macro 2017-10-11 19:13:46 -07:00
Bill Spitzak
1d9f4ae520 V5: Use NEAREST filter when possible
(changed to use determinant funciton and remove debug printf)

Modifies _cairo_matrix_has_unity_scale to return true for 90 degree rotations
by allowing error caused by inaccuracy in trig functions.

This fails after 14 additions of M_PI_2 to itself as a float argument to
cairo_rotate, but the failure is in the detection of the integer translate,
not in the trig components. I believe this is due to the matrix inversion,
which may need similar rounding.

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2014-08-14 12:59:07 -07:00
Andrea Canciani
1d3d64469f doc: Add "since" tag to documentation
The following Python script was used to compute "Since: 1.X" tags,
based on the first version where a symbol became officially supported.

This script requires a concatenation of the the cairo public headers
for the officially supported beckends to be available as
"../../includes/1.X.0.h".

from sys import argv
import re

syms = {}

def stripcomments(text):
    def replacer(match):
        s = match.group(0)
        if s.startswith('/'):
            return ""
        else:
            return s
    pattern = re.compile(
        r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
        re.DOTALL | re.MULTILINE
    )
    return re.sub(pattern, replacer, text)

for minor in range(12,-2,-2):
    version = "1.%d" % minor
    names = re.split('([A-Za-z0-9_]+)', stripcomments(open("../../includes/%s.0.h" % version).read()))
    for s in names: syms[s] = version

for filename in argv[1:]:
    is_public = False
    lines = open(filename, "r").read().split("\n")
    newlines = []
    for i in range(len(lines)):
        if lines[i] == "/**":
            last_sym = lines[i+1][2:].strip().replace(":", "")
            is_public = last_sym.lower().startswith("cairo")
        elif is_public and lines[i] == " **/":
            if last_sym in syms:
                v = syms[last_sym]
                if re.search("Since", newlines[-1]): newlines = newlines[:-1]
                if newlines[-1].strip() != "*": newlines.append(" *")
                newlines.append(" * Since: %s" % v)
            else:
                print "%s (%d): Cannot determine the version in which '%s' was introduced" % (filename, i, last_sym)
        newlines.append(lines[i])

    out = open(filename, "w")
    out.write("\n".join(newlines))
    out.close()
2012-03-29 11:03:18 +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
Chris Wilson
0a778d974f stroke: Adapt rectilinear stroker to handle separable non-unity scaling
Reported-by: Christos Sotiriou <csotiriou@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-19 20:02:50 +00:00
Chris Wilson
be5ab6df68 surface-wrapper: Apply the scaled-font ctm and non-default font-options
Improves record*-text-transform.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-28 18:11:22 +00: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
Andrea Canciani
5339533737 Do not use fmax()
fmin() and fmax() are not available on all the supported
architectures. MIN() and MAX() should be used in their place.
2011-03-19 15:29:03 +01:00
Andrea Canciani
c72c7aa6d6 matrix: Fix warnings about documentation by 'make check'
'make check' complains about the syntax of the documentation: the
space between the function name and the parenthesis is not allowed.
2011-01-02 19:32:26 +01:00
Andrea Canciani
51594d9787 matrix: Cairo matrix to pixman transform/offset conversion
Xlib, XCB and image use the same code to convert a cairo_matrix_t to a
backend-specific transform.

The code did not handle correctly some matrices, thus a new function
that performs the conversion in a more generic way was added and used
in the backends instead of fixing the repeated code.

Fixes part of https://bugs.freedesktop.org/show_bug.cgi?id=32215
2011-01-02 18:31:42 +01:00
Benjamin Otte
b870cc030d doc: Move tmpl/ docs to inline docs
I did this manually so I could review the docs at the same time.
If anyone finds typos or other mistakes I did, please complain to me (or
better: fix them).
2010-07-08 14:27:16 +02:00
Andrea Canciani
d2d6c96c24 user-font: correct handling of size 0 text
Text with size 0 has a singular scale matrix, thus requires special
handling to avoid invalidating the context where it is used.

Fixes pthread-show-text and text-zero-len (they failed with assertion
when ran using the user font backend).
2010-06-30 12:31:25 +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
6bfcf3ea55 matrix: Do not need to iteratively refine conversion for unity matrices.
If the scale factors on the matrix are unity, then the conversion from a
cairo_matrix_t to a pixman_matrix_t is exact (within numerical
restrictions).
2010-01-22 23:01:52 +00:00
Chris Wilson
d2f251f84b configure: Globally define AC_GNU_SOURCE
We were using _GNU_SOURCE throughout the codebase, so simply define it
once during configure. This is the easiest method to enable recursive
mutexes using pthreads, as required in a pending patch.
2010-01-22 23:01:50 +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
Chris Wilson
6ff711b630 [matrix] Improve bbox finding for translation matrix
If the matrix is a pure translation matrix than we can skip determination
of the extents and just translate the input bbox.
2009-08-29 17:07:02 +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
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
dd4276c661 [stroker] Rectilinear dashing.
Extend the rectilinear stroker to handle dashes, so that for pixel-aligned
dashed strokes we completely avoid tessellation overhead.
2009-01-29 14:55:21 +00:00
Daniel Holbert
d108b2777f Spelling corrections: s/it's/its/
As a fun itch to scratch, I've been fixing incorrect uses of the
contraction "it's" in comments within the mozilla source tree (tracked
in https://bugzilla.mozilla.org/show_bug.cgi?id=458167 ), and I ran
across 6 instances of this typo in mozilla's snapshot of cairo.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2009-01-29 10:10:40 +00:00
Chris Wilson
8a5b55ca6c [matrix] Impose a maximum number of refinement iterations
Ensure we do not loop forever trying to minimise the error between the
pixman and cairo matrices - for instance when the FPU is not running at
full precision.
2008-11-26 16:15:35 +00:00
Chris Wilson
29621bd399 [matrix] Remove stray offset from previous commit.
I moved the pixel centre to xc,yc but forgot to remove it during
compensation - as caught by the test suite.

Refresh a couple of reference images that depend upon exact pixel-centre
rounding conditions.
2008-11-05 12:16:47 +00:00
Chris Wilson
e811173311 [matrix] Compensate pixman_matrix in device space.
We wish to reduce the visible error when converting to a pixman matrix, so
perform the compensation in device space instead of pattern space.
2008-11-05 11:16:08 +00:00
Chris Wilson
59bdeba9ab [matrix] Minimise pixman conversion error.
Minimise the error of the pixman matrix about the centre of the displayed
area rather than the origin.
2008-11-05 08:01:27 +00:00
Chris Wilson
0d0c6a199c [matrix] Optimise invert for simple scaling|translation matrices.
The matrix is quite often just a simple scale and translate (or even
identity!). For this class of matrix, we can skip the full adjoint
rearrangement and determinant calculation and just compute the inverse
directly.
2008-10-30 17:52:13 +00:00
Chris Wilson
13ba43eb8f [matrix] Optimize finding the bounding box under an orthogonal matrix.
We frequently need to find the bounds of a pattern under an identity
matrix, or a simple scale+translation. For these cases we do not need to
transform each corner and search for the bounds as the matrix is x/y
separable and so allows us to inspect the results for the extreme x/y
points independently.
2008-10-30 17:52:12 +00:00
Chris Wilson
2c277ddbea [matrix] Avoid error correction overhead for translation matrices.
We can only correct rounding errors between cairo and pixman matrices for
scaled matrices - so skip the inversion and point transformation overhead
for simple translation matrices.
2008-10-30 17:14:27 +00:00
Owen W. Taylor
5eec3e378a [pattern] Improve handling of filter radius and optimize when possible.
Factor out common filter analysis code from _cairo_pattern_get_extents()
so that we can share it with _cairo_pattern_acquire_surface_for_surface()
as well. During the analysis of the filter determine whether the pattern
matrix maps source pixels exactly onto destination pixels and if so convert
the filter to NEAREST - generalising the existing conversion to NEAREST.

(Patch ported to master by Chris Wilson, all bugs are his.)
2008-09-29 09:46:50 +01:00
Behdad Esfahbod
22552dae51 Rename _cairo_matrix_compute_scale_factors to _cairo_matrix_compute_basis_scale_factors 2008-08-27 20:08:49 -04:00
Chris Wilson
49fb0e834e [matrix] Prefer a return parameter for _compute_determinant().
Returning a double tends to be slightly more efficient than passing a
pointer to fill, and is a lot easier to read.
2008-08-08 09:11:10 +01:00
Behdad Esfahbod
0621f412ff [cairo-matrix] Move IS_FINITE(det) checks before det==0 checks
I'm still getting floating point exceptions in test suite in a
made-to-overflow test though.  Not sure why isfinite() doesn't work.
2008-05-25 00:55:36 -04:00
Behdad Esfahbod
bdfda97f19 [cairo-matrix] Add _cairo_matrix_transform_bounding_box_fixed() 2008-05-09 15:54:11 +02:00
Behdad Esfahbod
11299ae5c5 Add doc/tutorial/src/singular.c 2008-04-09 11:17:14 -05:00
Shailendra Jain
536e1963b7 Compile fix for AIX.
Minor correction for a build failure on AIX:
"mozilla/gfx/cairo/cairo/src/cairo-gstate.c", line 45.43: 1506-294 (S)
Syntax error in expression on #if directive.

(Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=415867.)
2008-02-15 13:50:43 +00:00
Carl Worth
e2bb36fe08 wAdd proper error propagation to _cairo_matrix_compute_scale_factors
Before there was just an assert statement here that the
determinant of the matrix was not infinite. That was bogus
since a user-provided can end up here. So instead, do the
correct error propagation of any CAIRO_STATUS_INVALID_MATRIX
error as necessary.

This eliminates the current failure of the invalid-matrix
test case.
2008-01-29 09:01:00 -08:00
Behdad Esfahbod
0d898f2bad [doc] Make sure all type names in docs are prefixed by # 2008-01-28 20:49:44 -05:00
Bertram Felgenhauer
188765c8e8 improve comments for the pixman transformation anchoring math. 2008-01-23 19:22:18 +01:00
Bertram Felgenhauer
5a0b15d2c9 anchor pattern transformations at the pattern origin
This keeps the rounding errors due to the conversion to 16.16 fixed point
numbers small and improves cairo's translation invariance.
2008-01-23 18:02:02 +01:00
Chris Wilson
3f59ef9548 [cairo-matrix] Tidy usage of HAVE_ISFINITE.
Use a macro to switch between isfinite() and its fallback in order to
avoid using an #ifdef from within a function.
2008-01-13 11:21:39 +00:00
Chris Wilson
ae1e044e32 [cairo-matrix] Use isfinite() to check matrix determinant.
The current NaN check is insufficient as it classifies inf as a valid
determinant. We can improve the test by using isfinite() - but only
when it is available. We use the feature test macros as being the
simplest way of determining the presence of isfinite() as it may be
implemented as a macro, making checking for its usability troublesome
during configure.
2008-01-12 00:40:59 +00:00
Chris Wilson
4e44d54f3e [cairo-matrix] Check whether a matrix is invertible before use.
Provide an early check as to whether the font matrix is invertible.
2007-10-04 16:00:22 +01:00
Chris Wilson
bed8239f03 [cairo-error] Clean up all the warnings and missing _cairo_error() calls.
Every time we assign or return a hard-coded error status wrap that value
with a call to _cairo_error(). So the idiom becomes:
    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
or
    return _cairo_error (CAIRO_STATUS_INVALID_DASH);

This ensures that a breakpoint placed on _cairo_error() will trigger
immediately cairo detects the error.
2007-10-04 13:31:44 +01:00
Vladimir Vukicevic
aaf94ef6c4 [fixpt] remove dependency on some pixman types
Introduce cairo_gradient_stop_t, and remove pixman dependency
for core pattern types.  Perform conversion from cairo types
to pixman types as necessary in fallback code.
2007-07-18 22:45:21 +02:00
Chris Wilson
35ef8419a9 [cairo-matrix] Check determinant for invalid numbers.
By checking matrices for invalid determinants, we can prevent the
setting and application of invalid matrices.

The trick used here is that NaNs, as specified by IEE754, always
return FALSE in comparisons. Since we know that the square of the
determinant must be positive definite, then if the comparison is
FALSE the computation must have resulted in a NaN.
2007-07-05 19:15:07 +01:00
Kouhei Sutou
0898411d0a [doc] Minor documentation fixes 2007-05-28 17:05:40 -04:00
Carl Worth
93776772ed Make _cairo_matrix_compute_scale_factors void
Yet another function that cannot fail under any circumstances.
2007-04-09 17:15:33 -07:00
Behdad Esfahbod
8fbf50d31d [src] Make sure all source files #include "cairoint.h" as their first include
This is necessary to avoid many portability problems as cairoint.h includes
config.h.  Without a test, we will regress again, hence add it.

The inclusion idiom for cairo now is:

	#include "cairoint.h"

	#include "cairo-something.h"
	#include "cairo-anotherthing-private.h"

	#include <some-library.h>
	#include <other-library/other-file.h>

Moreover, some standard headers files are included from cairoint.h and need
not be included again.
2007-04-03 20:28:11 -04:00
Alp Toker
caa3c2e1e7 Fix various code/comment typos 2007-01-07 01:35:15 -05:00
Dan Amelang
11d21dbaa3 Change _cairo_matrix_to_pixman_matrix to use a pixman_transform_t as the template, thus avoiding a forced memcpy 2006-11-22 16:25:54 -08:00