Commit graph

364 commits

Author SHA1 Message Date
Adrian Johnson
1998239387 Use _cairo_malloc instead of malloc
_cairo_malloc(0) always returns NULL, but has not been used
consistently.  This patch replaces many calls to malloc() with
_cairo_malloc().

Fixes:  fdo# 101547
CVE: CVE-2017-9814 Heap buffer overflow at cairo-truetype-subset.c:1299
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2018-05-07 16:35:51 -07:00
Adrian Johnson
378e8e2f59 pdf: set ca/CA instead of using an smask when the mask has constant alpha 2017-10-24 07:01:14 +10:30
Bryce Harrington
b7b6803567 pattern: Fix incorrect grammar in cairo_pattern_get_type.
"This function returns the type a pattern." is obviously missing 'of',
but this can be stated more succinctly with active voice.

Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
2016-10-10 14:39:23 -07:00
Bryce Harrington
9d2983175e Fix grammar in cairo_*_reference() function documentation.
"can be get" is incorrect grammar; "can be gotten" would be better, but
active voice is best.

Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
2016-10-10 14:39:19 -07:00
Ed Schouten
a69e5af9cd Write debugging information to the debugging file
Some debugging functions wrote to stdout, which is inconsistent with
the other debugging functions of the same groups.

Instead they should write to the debugging file that they are given as
input.

Reviewed-by: Andrea Canciani <ranma42@gmail.com>

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=95227
2016-09-04 11:05:43 +02:00
Adrian Johnson
d28b6d9b12 pattern: revert an unintentional change added in 190678f 2016-07-18 18:43:03 +09:30
Adrian Johnson
190678f644 pattern: don't round extents to 0 on vector surfaces
In this bug a Type 3 font contains a dash glyph. The dash glyph
consists of an 82x2 image. The image height, when scaled to user space,
is < 1 resuling in the drawing operation for the image being culled.

https://bugs.freedesktop.org/show_bug.cgi?id=94615
2016-07-16 15:42:23 +09:30
Adrian Johnson
e7b1cb0c53 image: fix record-replay-extend test failures 2016-06-05 20:43:36 +09:30
Adrian Johnson
a736fd8699 Fix PDF record-neg-extents test failure
Modify PDF surface to allow surface extents to have negative x, y.
When emitting recording surfaces, set the surface extents to the
recording extents.
2016-06-05 20:43:36 +09:30
Bryce Harrington
6951fb4238 Revert "pattern: allow for a floating one pixel rounded difference."
While this fixed a real bug, in testing this patch was found to fail a
number of tests and thus needs further work.

This reverts commit e7acf4b6dc.
2015-07-17 12:07:18 -07:00
John Lindgren
bb24f165ff Avoid indiscriminate use of VALGRIND_MAKE_MEM_NOACCESS.
Marking stack-allocated objects as no-access creates false positives,
which distract from finding real memory errors.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=52548

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-26 16:12:33 -07:00
Alban Browaeys
e7acf4b6dc pattern: allow for a floating one pixel rounded difference.
That is if the difference between the origin and the end is bigger than
.5 round up regardless of the coordinates.

Round the difference of the floats instead of rounding the floats then
diff them.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=84396

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-18 16:07:40 -07:00
Ravi Nanjundappa
121f384c0e Fix one more warning from check-doc-syntax.sh
$ ./check-doc-syntax.sh
Checking documentation for incorrect syntax
./cairo-pattern.c (3342): ERROR: Will invalid doc id (should be 'cairo_...:')

The proposed changes fixes the warning about the documentation style used in cairo.

Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com>
2014-11-12 10:38:52 -08:00
Ravi Nanjundappa
caa4c9fdeb Fix warnings from check-doc-syntax.sh
$ ./check-doc-syntax.sh
Checking documentation for incorrect syntax
./cairo-pattern.c (3346): ERROR: Will bad line: ' */'
./cairo-pattern.c (3346): ERROR: Will documentation comment not closed with **/
./cairo-pattern.c (3422): ERROR: _cairo_pattern_sampled_area invalid doc id (should be 'cairo_...:')

The warnings are about the documentation style used in cairo

Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com>
2014-10-28 22:24:55 -07:00
Bryce Harrington
f6fd372a8b pattern: Restore dropped inclusion of cairoint.h
Fixes failure in make release-check due by check-preprocessor-syntax.sh
due to requirement that cairoint.h be the first include for source files.
2014-10-13 18:54:12 -07:00
Bill Spitzak
45934f69cd image: Corrected extents calculations
New implementations of _cairo_pattern_sampled_area and _cairo_pattern_get_extents
which produce a more accurate bounding box. These do not depend on side-effects
of analyze_filter, can handle different horizontal and vertical scales, filters
wider than 1 for down-scaling, and compute a somewhat tighter bounding box
in most cases.

I removed the pad output of _cairo_pattern_analyze_filter as it is unused.

Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
2014-10-10 18:09:14 -07:00
Bill Spitzak
c8b1bf55ad image: Move filter decision to _cairo_pattern_analyze_filter
The analysis to deterimine if the GOOD filter can be replaced with
the BILINEAR filter is moved to this function so it can be used
by backends other than the image backend.

Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
2014-10-10 18:08:48 -07:00
Maks Naumov
29a8b4e970 Fix _cairo_mesh_pattern_equal() when cairo_mesh_patch_t structs are different
Signed-off-by: Maks Naumov <maksqwe1@ukr.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2014-08-28 13:16:47 -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
jimmyfrasche
85b05e84ac Pattern document clarification
Replaces documentation of the form "range 0 to 1 less than the number"
with "ranges from 0 to n-1 where n is the number", which is idiomatic
mathematical writing and less ambiguous.

Signed-off-by: jimmyfrasche <soapboxcicero@gmail.com>
Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
2014-05-12 10:19:33 -07:00
Alexander Larsson
f0e2cd4494 gstate: Handle device scale on surface as source
When creating a transformed pattern we must apply the device
transform *before* the transform set on the pattern itself, otherwise
e.g. its translation will not be affected by the device scale.

We also fix up the device_transform related handling in
_cairo_default_context_pop_group().  With a device scale we can
no longer just use the device_transform_inverse to unset the
device offset for the extents, so we make that a simple translate
instead.

We also remove some weird code that tries to handle the device
transform but seems unnecessary (maybe a workaround for applying
the device transform in the wrong order?). With that code removed
things work fine, but with it things get translated wrongly when
there is a scale.
2013-09-05 16:08:19 +01:00
Chris Wilson
7eb33099d3 snapshot: Perform the cow under a mutex
In order to prevent a race between concurrent destroy and use in another
thread, we need to acquire a reference to the snapshot->target under a
mutex. Whilst we hold that reference, it prevents the internal destroy
mechanism from freeing the memory we are using (if we have a pointer to
the original surface) and the client drops their final reference.

Oh boy, talk about opening a can of worms...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-27 14:10:50 +01:00
Chris Wilson
57cfdfd979 Split cairo-list into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 13:17:29 +01:00
Chris Wilson
8653c2692e Split cairo-recording-surface-private into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 12:46:34 +01:00
Adrian Johnson
8657ca10e3 fix _cairo_pattern_get_ink_extents to work with snapshot recording surfaces
It had caused pdf bbox sizes to regress to page size bboxes.
2012-04-06 21:24:22 +09:30
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
7f635e4ead doc: Make doc ids more consistent my always putting ':' after them
This makes the documentations comments more consistent and fixes many
reports of 'invalid doc id'.
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
Nis Martensen
b42270a3f1 doc: preserve whitespace by using docbook screen tag
Using the programlisting tag is not appropriate everywhere. Use the
screen tag where the formatting shall be preserved and the text is no
code listing.

Also add whitespace to prevent gtk-doc from inserting paragraph breaks.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-03-10 10:20:29 +01:00
Nis Martensen
acf50966e6 doc: typo
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-03-10 10:20:28 +01:00
Nis Martensen
c7d8ec72e6 doc: fix typo
The pattern creation function call in the example code has one _mesh too
much. This hopefully fixes the mesh mismatch mess :)

Signed-off-by: Nis Martensen <nis.martensen@web.de>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-02-14 21:04:25 +01:00
Nis Martensen
76df401263 doc: Fix pattern name mismatch
In the example code, the mesh pattern variable was named "mesh" and
"pattern". Just use "pattern".

Signed-off-by: Andrea Canciani <ranma42@gmail.com>
2012-02-12 09:07:48 +01:00
Andrea Canciani
a2f419b546 rectangle: Implement _cairo_rectangle_contains_rectangle()
And reuse it.
2012-01-15 18:25:57 +01:00
Andrea Canciani
2808bf5b95 pattern: Infinite color-only sources are always opaque
No matter what the sampling extents are, infinite color-only sources
are opaque.
2012-01-15 18:25:52 +01:00
Chris Wilson
934a3dcc6b doc: Drop the gtk-doc markup from _cairo_radial_pattern_focus_is_inside
Stop confusing gtk-doc with this private function.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-02 16:19:48 +00:00
Chris Wilson
8844d50308 Convert cairo_mime_surface_t to cairo_raster_source_pattern_t
As discussed, overloading the cairo_surface_t semantics to include
sources (i.e. read-only surfaces) was duplicating the definition of
cairo_pattern_t. So rather than introduce a new surface type with
pattern semantics, start along the thorny road of extensible pattern
types.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-11-25 10:35:42 +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
Adrian Johnson
37a22669d8 pdf: use ink extents for smask bbox
There are some inkscape bugs reporting very slow rendering of inkscape
generated PDFs (inkscape uses cairo for PDF output). These bugs are
caused by cairo specifying a page sized bounding box in XObjects and
Patterns. PDF renderers usually use the BBox as the image size when
compositing. As PDFs generated from SVG tends to use a lot of XObjects
and Patterns this can lead to very long rendering times.

These three patches tighten up all the BBoxes in PDF output.
2011-09-05 21:18:36 +09:30
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
1f2dc2e06a pattern: Do not provide type field in cairo_pattern_union_t
The type field is accessible through the base.type field. This makes
it possible to change the layout of cairo_pattern_t and move the type
field without breaking cairo_pattern_union_t.
2011-07-31 16:46:36 +02:00
Andrea Canciani
2787ef4e73 pattern: Complete the list of possible pattern errors
A mesh pattern is put in CAIRO_STATUS_INVALID_MESH_CONSTRUCTION when
an invalid patch construction operation is performed.

A mesh pattern is put in CAIRO_STATUS_INVALID_INDEX when an operation
is performed with an out-of-bound index.

Any pattern is put in CAIRO_STATUS_INVALID_MATRIX when its matrix is
set to a singular matrix.
2011-07-29 13:17:17 +02: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
9374cf0a97 pattern: Implement _rgb functions as wrappers over _rgba functions
cairo_pattern_create_rgb() and cairo_pattern_add_color_stop_rgb()
implement the same logic as cairo_pattern_create_rgba() and
cairo_pattern_add_color_stop_rgba() with an alpha == 1.0.

Instead of duplicating the code, they can simply call into the more
general functions.
2011-07-08 11:14:16 +02:00
Andrea Canciani
fe3ca9c36f Remove conditional compilation of freed-pools
Conditional compilation was needed to avoid warnings:
cairo-clip.c:51: warning: ‘clip_path_pool’ defined but not used
cairo.c:181: warning: ‘context_pool’ defined but not used

They can be avoided by making sure that _freed_pool_reset(ptr)
actually consumes its argument. This has the pleasant side-effect that
forgetting to properly reset a freed-pool now results in a warning if
atomic ops are disabled/not available.
2011-07-05 10:00:13 +02:00
Andrea Canciani
ab8c108b88 Do not warn when ignoring the return value of _cairo_rectangle_intersect()
gcc complains that

cairo-surface-wrapper.c:647: warning: ignoring return value of
‘_cairo_rectangle_intersect’, declared with attribute warn_unused_result

It can be silenced by making _cairo_rectangle_intersect()
cairo_private_no_warn. This makes it possible to avoid unused
temporary variables in other places and reduces the dead assignments
reported by clang static analyzer from 114 to 98.
2011-03-19 12:24:14 +01:00
Andrea Canciani
6521bab6e8 xcb,xlib: Fallback upon generic radial gradients
The RENDER specification requires radial gradients to have the first
circle completely inside the second one, but the error is not actually
generated.

The implementation produces the expected results if either circle
contains the other one, so only fall back in these cases.
2011-03-18 09:48:56 +01:00
Uli Schlachter
788bdec628 Fix errors from src/check-plt.sh
All of these symbols are used in cairo-script-surface.c for emitting mesh
patterns.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-02-12 21:12:46 +01:00
Andrea Canciani
5f039f0f89 mesh: Rename cairo_pattern_mesh_* functions to cairo_mesh_pattern_*
This is consistent with the naming of most cairo types/functions
(example: cairo_foo_surface_*).

The substitution in the code has been performed using:

  sed -i 's/cairo_pattern_mesh_/cairo_mesh_pattern_/' <files>
2011-02-07 20:28:09 +01:00
Andrea Canciani
8c031c029d pdf,ps,quartz: Use correct tolerance for gradient domain computation
The tolerance argument of _cairo_gradient_pattern_box_to_parameter ()
is in pattern space, so to have it constant in device space, it should
depend on the pattern matrix.

In ps and pdf the fallback resolution alone is not meaningful. The
resolution/fallback_resolution ratio should be used instead.
2011-01-18 15:15:28 +01:00