Commit graph

379 commits

Author SHA1 Message Date
Koichi Akabe
d517773ff1 Fix "out of memory" when using linear gradient 2024-02-06 22:18:06 +09:00
Emmanuele Bassi
5de85afb75 docs: Add docblocks for missing feature defines 2023-09-23 15:18:32 +01:00
Marc Jeanmougin
e6ab85712c Enable access to the pixman dithering path
Newer versions of Pixman allow choosing the dithering format.
2023-09-07 15:42:21 +01:00
Emmanuele Bassi
77c2820840 Drop "slim" symbols
The original "slim" symbol rewriting was added without any shred of a
set of performance evaluation, and mostly copy-pasted from a very early
version of pixman. Pixman itself never used them, and most C
libraries—like GLib and GTK—have dropped similar mechanisms over the
past 15 years, as linkers have improved considerably in the meantime.

Modern linkers provide functionality to avoid intra-library PLT jump
through flags like `-Bsymbolic-functions`; we should use that, instead,
and keep the code base more maintainable and debuggable.
2023-08-16 16:33:04 +01:00
Khaled Hosny
40badda549 doc: Fix the gtk-doc syntax of internal symbols
To stop gtk-doc from listing them as undocumented.
2023-02-02 14:13:56 +02:00
Adrian Johnson
bdf97dd2a1 Rename is_userfont_foreground to is_foreground_marker
as it is used by FT as well as user fonts.
2023-01-27 20:22:19 +10:30
Adrian Johnson
c8695f0503 Foreground color fixes for ft, svg, colrv1 2023-01-27 20:22:18 +10:30
Adrian Johnson
7146358250 Fix shared use of recording surface with paginated targets
The problem is _cairo_recording_surface_replay_and_create_regions()
stores the cairo_recording_region_type_t in the same structure as the
recording commands. This does not work well when the recording surface
is used as source by multiple surfaces

Fix this by moving the cairo_recording_region_type_t into a separate
struct cairo_recording_regions_array_t. This struct is stored in a
list that allows multiple create regions results to be store in the
surface.

The new function _cairo_recording_surface_region_array_attach() is
used to create a new cairo_recording_regions_array_t, attach it to the
recording surface and return a unique region id.

The _cairo_recording_surface_replay_and_create_regions() and
_cairo_recording_surface_replay_region() functions use this region id
to identify the cairo_recording_regions_array_t.

To handle nested recording surfaces, when replaying a recording, the
region id is passed to the target as an extra parameter in the surface
pattern. The wrapper surface makes a temporary copy of the pattern to
ensure the snapshot pattern in the recording surface is not modified.

cairo_recording_regions_array_t has a reference count so the target
can hold on to the cairo_recording_regions_array_t after the paginated
surface has called _cairo_recording_surface_region_array_remove().
2023-01-15 19:29:28 +10:30
Adrian Johnson
3c8dec60e5 Integrate COLR v1 renderer with cairo-ft-font.c 2023-01-08 15:15:13 +10:30
Adrian Johnson
3e8b9a7cf4 Add some missing slim_hidden entries 2022-12-28 14:00:33 +10:30
Matthias Clasen
1df5969ef6 Document whether colors are premultiplied
For the various APIs that take or return
RGBA colors, make it explicit that they are
unpremultiplied.
2022-12-24 07:22:39 -05:00
Adrian Johnson
8ea4ae5413 Allow user fonts to use the foreground color 2021-09-18 07:05:35 +09:30
Adrian Johnson
9fbf427548 Use uintptr_t for all casts between pointer and integer
On 64-bit windows, long is 32-bit. When compiling there are a large
number of warnings about mismatched sizes when casting long to/from a
pointer.

Use the (u)intptr_t type for any integer that will have a pointer stored
in it. Use a (u)intptr_t cast when integers are stored in pointers to
silence warnings.

Fixes #263
2021-07-25 11:01:20 +09:30
luz.paz
6d93bddbd6 Misc. typos
Found via `codespell -i 3 -w -I ../cairo-word-whitelist.txt -L tim,ned,uint`
Follow up of 12cb59be7d

Reviewed-by: Bryce Harrington <bryce@bryceharrington.org>
2019-01-31 17:37:15 -08:00
Bryce Harrington
7786b8fe4e Drop skia backend
Commit 38806bc3 already disabled the backend from use, now drop the
code.
2018-10-17 17:21:03 -07:00
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