Commit graph

7216 commits

Author SHA1 Message Date
Chris Wilson
dced42a680 xlib: Avoid using uninitialised variable on impossible error path
In commit f6843d5cbb
Author: Arpit Jain <jain.arpit@samsung.com>
Date:   Mon Jul 6 14:13:06 2015 -0700

    xlib: Fix deferencing of uninitialised 'display'

the common error + clenaup path was clumsily fixed to use the right
variable after the error didn't set the local display variable.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-07-06 22:28:20 +01:00
Chris Wilson
84b8d76576 Revert "xlib: Fix deferencing of uninitialised 'display'"
This reverts commit f6843d5cbb.
2015-07-06 22:28:20 +01:00
Arpit Jain
f6843d5cbb xlib: Fix deferencing of uninitialised 'display'
Initialising 'display' to NULL and checking before deferencing during display->base.
This patch will check the deferencing of uninitialised 'display' in case,
_cairo_xlib_display_acquire does not return CAIRO_STATUS_SUCCESS.

Fixes:  https://bugs.freedesktop.org/show_bug.cgi?id=87893
Signed-off-by: Arpit Jain <jain.arpit@samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-07-06 14:13:24 -07:00
Bryce Harrington
06a2696d5f cairo-gl: Still check the value of the macros
Just because they're defined doesn't mean they've been enabled.
2015-07-06 14:11:57 -07:00
Koop Mast
c8b6c6066a cairo-gl: Fix compiler warning if CAIRO_HAS_*_FUNCTIONS is not defined.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=88050

[Updated to also still check the value of the macros]

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-27 01:14:22 -07:00
Bryce Harrington
bf4f5f3a90 cairo-script: Return a cairo_status_t error, not FALSE
This typo results in certain paths being incorrectly recorded with
script surfaces.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=91054
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-26 16:30:06 -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
Bryce Harrington
1bcce43629 cairo-recording-surface: Fix loss of alpha when clipping
Commit 8020e0bc introduced a regression due to a typo when copying a
mask for a cairo recording surface.  It should copy the source and mask
members from the command source to the recording surface, but instead it
copies the source twice.

Fix suggested by Massimo.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=73038
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=73901
2015-06-25 18:54:23 -07:00
Bryce Harrington
c1c3028a0c cairo-script: Fix sp. "directoriy"
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-25 17:42:27 -07:00
Uli Schlachter
f82ae573fe XCB: Don't attach uploaded surfaces as snapshots
When you draw (part of) a surface to an XCB surface, the XCB backend will safe
the uploaded part as a snapshot to the input surface. This allows to re-use this
picture in case the same surface is later used again as a source.

However, other backends do not do this and this has caused and/or highlighted
numerous bugs. Just skipping the snapshot fixes or hides these bugs.

Papers-over: https://bugs.freedesktop.org/show_bug.cgi?id=67505
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-06-20 10:59:52 +02: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
Fredrik Fornwall
11b6c49c10 Fix cairo_get_locale_decimal_point() on Android 2015-06-05 20:53:11 -07:00
Massimo Valentini
1ed318ce13 polygon-intersection: Delete misleading comments and dead-code
den_det is positive because intersect_lines is called
only after _slope_compare returned > 0 and slope_compare
is returning the sign of den_det

The quadratic-time intersection finder is #if 0-ed out
in src/cairo-bentley-ottman.c, but is unusable even there
since the second commit to that file.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=74779
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-04 15:02:01 -07:00
Massimo Valentini
63f59ea896 polygon-intersection: Try not to invoke undefined behaviour
Optimizing compilers aggressively remove code that is executed only
after an undefined behaviour occurred.

Also, the difference of two (non char) pointers hides an integer
division that, because the divisor is known at compile time, is
transformed into a multiplication by a pseudo-reciprocal, and in this
case the difference is not always a multiple of the divisor, resulting
in an invalid comparison predicate.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=74779
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-04 15:01:57 -07:00
Massimo Valentini
a3c022bb98 polygon-intersection: Include approximation in intersection points
In Hobby's paper it is proved that INTERSECTION events can be
processed in any order by ignoring intersections between edges
non-adjacent in the active edges list.
But with respect to START/STOP events they must be processed in
order. Because START/STOP events have always exact y, it is
sufficient to know whether an integer y intersection is a
default/excess approximation of the exact to properly sort events.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=74779
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-04 15:01:35 -07:00
Massimo Valentini
9f2bbfa41f polygon-intersection: Do not discard intersection exactly at top edge
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=74779
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-04 15:00:58 -07:00
Nathan Froyd
5d150ee111 Support new-style __atomic_* primitives
Recent versions of GCC/clang feature a new set of compiler intrinsics
for performing atomic operations, motivated by the operations needed to
support the C++11 memory model.  These intrinsics are more flexible than
the old __sync_* intrinstics and offer efficient support for atomic load
and store operations.

Having the load appear atomic to the compiler is particular important
for tools like ThreadSanitizer so they don't report false positives on
memory operations that we intend to be atomic.

Patch from Nathan Froyd <froydnj@mozilla.com>
2015-06-04 13:25:23 -07:00
Adrian Johnson
d1dda5eeb2 cff: ensure glyph widths are positive when font matrix yy is negative
Bug 90538
2015-05-21 22:40:01 +09:30
Zan Dobersek
f52f0e2feb Manually transpose the matrix in _cairo_gl_shader_bind_matrix()
To maintain compatibility with OpenGL ES 2.0, the matrix in
_cairo_gl_shader_bind_matrix() should be manually transposed,
and GL_FALSE passed as the transpose argument to the
glUniformMatrix3fv() call as it is the only valid value for
that parameter in OpenGL ES 2.0.

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Acked-by: "Henry (Yu) Song" <henry.song@samsung.com>
2015-05-18 15:03:29 -07:00
Bryce Harrington
8b798c320f Fix broken canvas text font size in Inkscape
An earlier fix to bug 84324 added a regression in the font size of
canvas text in Inkscape when compiled with the Quartz backend.

Patch from Andrea Canciani

Fixes:  https://bugs.freedesktop.org/show_bug.cgi?id=84324
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-04-24 18:23:46 -07:00
Behdad Esfahbod
d5ffe67008 Remove debug printf; ouch! 2015-04-23 14:26:14 -07:00
Behdad Esfahbod
853e822c9c Oops, fixup previous commit 2015-04-21 14:31:53 -07:00
Behdad Esfahbod
bb01fd8794 [ft] Return CAIRO_STATUS_FILE_NOT_FOUND if font file can't be opened
A common source of error when people are setting up pango on a new
device is when font files don't have the right permissions and cannot
be opened.  Cairo was returning out-of-memory before, making the
Pango error message useless.

With this change, cairo will return file-not-found, and pango prints
that out.  It's still not ideal; a ENOACCESS equivalent would have
been better.
2015-04-21 14:29:41 -07:00
江頭幸路
040ae0ce19 Avoid appending an empty slot to an user data array when user_data is NULL.
Otherwise, calling cairo_set_user_data(cr, key, 0, 0) many times
causes a long user data array, almost all of whose slots are empty.
It leads to unnecessarily much memory consumption and long execution time of
cairo_set_user_data(cr, key, 0, 0) and cairo_get_user_data(cr, key) after
it.

This issue probably happens since the commit
http://cgit.freedesktop.org/cairo/commit/?id=9341c254a

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-04-20 17:16:18 -07:00
Руслан Ижбулатов
16898ba11b win32: Add cairo API to set up a Win32 surface for an HDC with an alpha channel.
Signed-off-by: Руслан Ижбулатов <lrn1986@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-04-13 17:43:28 -07:00
Bryce Harrington
2cf2d8e340 Fix spellings descibed, indicies, stange 2015-04-04 15:49:18 -07:00
Bryce Harrington
904f1fdc1d surface: Clarify flush documentation 2015-03-18 15:49:41 -07:00
Bryce Harrington
3a7d411539 Revert "xlib: Remove queued event from _XReadEvents"
This reverts commit e7fc8f405b.
2015-03-06 23:35:34 -08:00
Bryce Harrington
246d5c1d47 doc: Drop extraneous para's
These may have been required in the past, but just trip up distcheck
today.  The generated docs still look fine.
2015-03-06 19:19:13 -08:00
Henry (Yu) Song
e7fc8f405b xlib: Remove queued event from _XReadEvents
Following patch fixes a memory leak in xlib surface.

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-03-05 17:27:14 -08:00
Michael Haubenwallner
4e680ff4bb headers: fix include order for AIX, bug#89354
also for cairo-xcb-private.h
2015-03-05 17:03:32 -08:00
Michael Haubenwallner
733de40e87 headers: fix include order for AIX, bug#89354 2015-03-05 17:03:28 -08:00
Michael Haubenwallner
ac75ab9f30 fix conflicting types for 'sync' on AIX, bug#89338 2015-03-05 12:00:48 -08:00
Andrea Canciani
70cc8f250b quartz: Remove call to obsolete CGFontGetGlyphPath
CGFontGetGlyphPath was not public and is not available anymore on
modern OSX/iOS systems. The same functionality is available through
the CoreText API since OSX 10.5.

Based on a patch by Simon Cozens.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=84324
2015-02-05 15:13:46 +01:00
Massimo Valentini
91f128bf7a win32: Fix crash from win32 surface's image size too small
Beginning in 1.12, a crash can occur when the win32 surface's image size
does not cover the entire surface (e.g. due to clipping regions).

This patch enlarges the fallback surface created of the amount
necessary not to write past the end of the DIB. It assumes that
Clip applied to an HDC are clamped to (0,0,width,height) of the HDC.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=53121
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-02-02 16:33:06 -08:00
Uli Schlachter
ebd23accc8 xlib-xcb: Don't be lazy and use the real xcb_screen_t
Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-01-17 20:12:39 +01:00
Uli Schlachter
b47209a03f xcb: Query the display's subpixel order via RENDER
With commit e691d242, the xcb backend started parsing the resources, just like
cairo-xlib does. One behavior from cairo-xlib was missing: If no Xft.rgba
property was specified, cairo-xlib defaults to the screen's subpixel order.
This commit brings that last bit of functionality to cairo-xcb (but currently
disabled due to commit e0c0a673).

This commits adds a new array to cairo_xcb_connection_t that contains the
subpixel order for each screen. There is also a new member in cairo_xcb_screen_t
which contains the subpixel order of that screen and which is initialized from
the array when the screen is constructed. With this in place, the
resource-parsing code can just pick the subpixel order from the screen if
needed.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-01-17 20:11:59 +01:00
Andrea Canciani
02e4efc961 font: Actually perform destruction of fonts
Commit 337ab1f8d9 introduced delayed
font destruction to overcome a race, but prevented the correct cleanup
of the font cache.

This caused fonts to stay in the cache and caused a crash in the
api-special-cases (when running the test suite with -f).

Fixes api-special-cases,
https://bugs.freedesktop.org/show_bug.cgi?id=87567
2015-01-03 14:59:51 +01:00
Chris Wilson
028d286e61 xlib: Bump reference count for recording surface replays
The snapshot takes a reference to the target recording surface in order
to enable it for use by multiple treads. In order to balance this, the
other two sources of recording surface must also take a reference and
for us to release that reference after the replay.

Otherwise, we end up with a memory leak:

==1== 1,392 bytes in 3 blocks are definitely lost in loss record 1 of 7
==1==    at 0x4A06BCF: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1==    by 0x4C7042D: _cairo_recording_surface_snapshot (cairo/src/cairo-recording-surface.c:1427)
==1==    by 0x4C842BE: _cairo_surface_snapshot_copy_on_write (cairo/src/cairo-surface-snapshot.c:189)
==1==    by 0x4C7E7E0: _cairo_surface_detach_snapshot (cairo/src/cairo-surface.c:348)
==1==    by 0x4C7E55B: _cairo_surface_detach_snapshots (cairo/src/cairo-surface.c:333)
==1==    by 0x4C7E55B: _cairo_surface_flush (cairo/src/cairo-surface.c:1545)
==1==    by 0x4C7E6CC: _cairo_surface_finish_snapshots (cairo/src/cairo-surface.c:1017)
==1==    by 0x4C7E6CC: cairo_surface_destroy (cairo/src/cairo-surface.c:961)
==1==    by 0x4C625A7: cairo_pattern_destroy (cairo/src/cairo-pattern.c:1131)
==1==    by 0x4C3FAC6: _cairo_gstate_fini (cairo/src/cairo-gstate.c:225)
==1==    by 0x4C3C68C: _cairo_default_context_fini (cairo/src/cairo-default-context.c:75)
==1==    by 0x4C3C708: _cairo_default_context_destroy (cairo/src/cairo-default-context.c:93)
==1==    by 0x43E576: record_get (cairo/test/record-extend.c:158)
==1==    by 0x43E576: record_replay (cairo/test/record-extend.c:173)
==1==    by 0x40E22D: cairo_test_for_target (cairo/test/cairo-test.c:929)
==1==    by 0x40E22D: _cairo_test_context_run_for_target (cairo/test/cairo-test.c:1532)
==1==    by 0x40B6C0: _cairo_test_runner_draw (cairo/test/cairo-test-runner.c:255)
==1==    by 0x40B6C0: main (cairo/test/cairo-test-runner.c:937)

Reported-by: Massimo Valentini <mvalentini@src.gnome.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87898
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-12-31 11:01:45 +00:00
Uli Schlachter
40201f4b1a tor-scan-converter: Correctly align 64bit types
On 32bit SPARC the scan converter was causing a SIGBUS due to an unaligned
memory access while accessing an int64_t. This memory accessing was to struct
quorem's rem member.

This crash occurred because the tor-scan-converter contains its own
implementation of a memory pool. This implementation only guarantees an
alignment of sizeof(void *), which is less than what a 64 bit type requires on
32bit platforms. This 4 byte alignment is guaranteed, because struct _pool_chunk
(which is the struct that is used for managing free space) contains elements of
that size and so the size of that struct is a multiple of this size as well.

This problem was introduced with commit 03c3d4b7c1.

To fix this problem, this commit introduces a int64_t member to struct
_pool_chunk that marks the beginning of the free data space. Thanks to this, the
compiler ensures proper alignment and sizeof(struct _pool_chunk) becomes a
multiple of 8.

However, previously the end of the struct marked the beginning of the data and
sizeof() was used for correctly calculating offsets to the data section. So,
just adding such a member would work, but would also waste some memory. To avoid
this, this commit also changes the rest of the pool implementation to
accommodate.

Reported-by: Nicolas Setton <setton@adacore.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2014-12-06 10:25:30 +01:00
Bryce Harrington
5c82d91a5e image: Fix crash in _fill_xrgb32_lerp_opaque_spans
If a span length is negative don't go out of bounds processing the fill
data.

Patch thanks to Ilya Sakhnenko <ilia.softway@gmail.com> on mailing list.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2014-12-05 19:16:43 -08:00
Hans Breuer
56da7adc3c win32: Fix compilation of 'cairo-path-stroke-traps.c' with MSVC8
"The issue here is that Visual Studio 2005+ is quite strict on type
conversions (so it wants code to be clear enough on conversions)."

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=84908
2014-11-20 12:26:52 -08:00
Adrian Johnson
ae608035c7 pdf-operators: fix bug with RTL text
bug 86461
2014-11-20 10:16:06 +10:30
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
Adam Jackson
a03f2ff720 xcb: Don't crash when swapping a 0-sized glyph
malloc(0) needn't return NULL, and on glibc, doesn't.  Then we encounter
a loop of the form do { ... } while (--c), which doesn't do quite what
you were hoping for when c is initially 0.

Since there's nothing to swap in this case, just bomb out.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2014-11-06 12:56:18 -08:00
Adam Jackson
3cf862f6d9 xlib: Don't crash when swapping a 0-sized glyph
malloc(0) needn't return NULL, and on glibc, doesn't.  Then we encounter
a loop of the form do { ... } while (--c), which doesn't do quite what
you were hoping for when c is initially 0.

Since there's nothing to swap in this case, just bomb out.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2014-11-06 12:56:13 -08:00
Adrian Johnson
adbeb3d53c Improve performance of cpu_to_be32 and be32_to_cpu
By switching to the more common form, gcc and clang emit a single
bswap instruction and truetype subsetting of large fonts runs about
15% faster.
2014-10-31 22:55:14 +10:30
Adrian Johnson
e4b78424ac pdf-operators: only wrap text strings for PS output
since the PS Document Structing Conventions impose a 255 character
line limit. PDF does not require wrapping.

pdf-operators is designed to emit the same output for PS and PDF.
Unfortunately some PDF interpreters don't like strings split with
'\\\n' and some PS interpreters don't like strings split with ')('.
So we are forced to make pdf-operators handling string wrapping
differently for PDF and PS.

Bug 85662
2014-10-31 19:26:05 +10:30
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
Massimo Valentini
2de69581c2 tor-scan-converter: can't do_fullrow when intersection in row + 0.5subrow
the active edges list must be left sorted at the next possible use
and since full_row does not deal with intersections it is not usable
when there is an intersection in the top half of the next row first
subrow

Reported-and-tested-by: Matthew Leach
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=85151
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-10-19 12:47:23 +01:00