Commit graph

13066 commits

Author SHA1 Message Date
Luca Bacci
57916e22be CI: Run tests on Windows 2025-11-07 13:58:16 +01:00
Luca Bacci
457dd4afa9 Tests/create-regions: skip if needed features are missing 2025-11-07 13:58:16 +01:00
Luca Bacci
47d8ff0e2a Tests/font-variations: Cleanup resources in all cases
Otherwise the test runner detects leaks
2025-11-07 13:58:16 +01:00
Luca Bacci
98e5d5ad16 Tests/pdf-operator-text: Check if pdf target is enabled
The same is done in pdf-mime-data.c
2025-11-07 13:58:16 +01:00
Luca Bacci
5df592c28b Tests: Avoid defining standard macros
That leads to compilation errors with CLang (depending
on the order of includes):

 > In file included from ../test/invalid-matrix.c:31:
 > In file included from /usr/include/fenv.h:64:
 > /usr/include/bits/fenv.h:26:5: error: expected identifier
 >    26 |     FE_INVALID =
 >       |     ^
 > ../test/cairo-test.h:78:20: note: expanded from macro 'FE_INVALID'
 >    78 | #define FE_INVALID 0
 >       |                    ^

Instead of defining standard macros, rely on the value of
(math_errhandling & MATH_ERREXCEPT) to check if floating-point
exceptions are supported. If so, all three macros FE_DIVBYZERO,
FE_INVALID, and FE_OVERFLOW are guaranteed to be defined.

https://en.cppreference.com/w/c/numeric/math/math_errhandling.html
2025-11-07 13:58:16 +01:00
Luca Bacci
6535ef2bcf Tests/invalid-matrix: Also mask FE_OVERFLOW (_EM_OVERFLOW)
On Windows SDK <= 10.0.22621.0 (as we currently have in CI),
INFINITY is defined as a compound expression that overflows
at runtime.

From Windows SDK 10.0.26100.0 onwards, INFINITY is defined
as a literal expression (double) cast'ed to float. That
doesn't trigger the overflow at runtime. The previous behavior
can be retained by defining _UCRT_LEGACY_INFINITY.
2025-11-07 13:58:16 +01:00
Luca Bacci
21242ae5df Tests: Trap floating point exceptions also on Windows 2025-11-07 13:58:16 +01:00
Luca Bacci
6b208d6de7 Do not check for feclearexcept
Unlike feenableexcept and fedisableexcept, which are GNU
extensions, feclearexcept is part of C99.

https://en.cppreference.com/w/c/header/fenv.html
2025-11-07 13:58:16 +01:00
Luca Bacci
2f34598297 Add STDC FENV_ACCESS ON pragma
This is required by the C99 standard, even though it's not
needed by the compilers we support.
2025-11-07 13:58:16 +01:00
Luca Bacci
658c7a721d Test runner: Add some Win32-specific implementations
Disable error message boxes in tests, enable termination on heap
corruption, and check if running under a debugger.
2025-11-07 13:58:16 +01:00
Luca Bacci
9ea82b9a90 Boilerplate/Win32: Switch to a DIB section
The Win32 boilerplated works by positioning a test HWND
at (INT_MIN, INT_MIN) and drawing into the client HDC.
However, the image read-back always yields a blank image
(_cairo_boilerplate_get_image_surface).

The window is positioned offscreen, thus GDI returns an
HDC that is completely clipped, as GDI always clips to
the visible region of the client area. In short, every
drawing operation turns into a no-op.

It's probably best to use a bitmap target with a memory
DC. This commit reworks the Win32 boilerplate to target
a DIB section.
2025-11-07 13:58:16 +01:00
Luca Bacci
402db78257 Boilerplate: Adapt system / popen commands for Windows
Both system() and popen() invoke the command interpreter;
that's CMD.exe on Windows (or whatever is specified in the
COMSPEC environment variable).

The Windows API supports forward slashes in paths just fine,
but CMD doesn't (well, it does in very specific cases [1]).
Forward slashes are always parsed as start of switches / options.

[1] https://devblogs.microsoft.com/oldnewthing/20180605-00/?p=98915
2025-11-07 13:58:16 +01:00
Luca Bacci
3ad2e95025 Boilerplate: Open pipe in binary mode on Windows
Avoids a translation from LF to CRLF, which messes up the
expected byte counts.

Note that popen() on GLibc does not support the 'b' mode,
so this change is for Windows only. From the POSIX.2024
spec:

 > The behavior of popen() is specified for values of mode of "r",
 > "w", "re", and "we". Other modes such as "rb" and "wb" might be
 > supported by specific implementations, but these would not be
 > portable features.
2025-11-07 13:58:16 +01:00
Luca Bacci
187dad3fbe Meson: Use mklink on Windows to create the srcdir link
Create the directory symlink '<builddir>/test/srcdir' -> '<sourcedir>'
as done on UNIX. Invoke mklink /J to create a junction, which doesn't
require developer mode nor admin rights.

Note: we might also set the srcdir environment variable [1]

[1] https://gitlab.freedesktop.org/cairo/cairo/-/blob/1.18.4/test/cairo-test.c?ref_type=tags#L198
2025-11-07 13:58:16 +01:00
Uli Schlachter
04656d7450 Merge branch 'tests-misc-fixes' into 'master'
Tests: Misc enhancements

See merge request cairo/cairo!634
2025-07-17 18:38:49 +00:00
Tim-Philipp Müller
6955595c60 Merge branch 'ci-macos-arm64' into 'master'
ci: add macOS arm64

See merge request cairo/cairo!498
2025-07-16 17:31:44 +00:00
Luca Bacci
a9e3eaccb8 CI: Add coverage-column-triangles to Quartz ignores
Fails with the following log:

Testing coverage-column-triangles with quartz target (dev offset 0 scale: 1)
963 pixels differ (with maximum difference of 9) from reference image
963 pixels differ (with maximum difference of 9) from reference image
OUTPUT: output/coverage-column-triangles.quartz.argb32.out.png
REFERENCE: ../../test/reference/coverage-column-triangles.ref.png
DIFFERENCE: output/coverage-column-triangles.quartz.argb32.diff.png
TEST: coverage-column-triangles TARGET: quartz FORMAT: argb32 OFFSET: 0 SCALE: 1 SIMILAR: 0 RESULT: FAIL
(...)
2025-07-16 11:52:45 +02:00
Luca Bacci
2e0713971f Update Quartz reference images 2025-07-16 11:52:45 +02:00
Tim-Philipp Müller
d371015d45 ci: add macOS arm64 2025-07-16 11:52:41 +02:00
Luca Bacci
355e421640 CI: Avoid running duplicated tests
...also simplifies .gitlab-ci.yml a bit
2025-07-15 14:28:27 +02:00
Luca Bacci
2b7ab8b895 Remove leftover scripts from the autotools build 2025-07-15 14:28:18 +02:00
Luca Bacci
471f8410a5 make-constructors.py: Sort tests list
This way cairo-test-suite works on sorted data
2025-07-15 14:27:15 +02:00
Emmanuele Bassi
8e9b856488 Merge branch 'win2k' into 'master'
win32: Fix MSVC build with dwrite disabled

See merge request cairo/cairo!618
2025-07-14 22:39:41 +00:00
Benjamin Gilbert
7a780896a1 win32: Fix MSVC build with dwrite disabled
We now require at least Windows Vista.  When dwrite is disabled, declare
WINVER accordingly so we get the defines we no longer carry ourselves.
The default dwrite-enabled path already has a new-enough WINVER.

Fixes: d0ee67a142 ("Win32: Remove unused code and defines for old toolchains")
2025-07-14 12:17:27 -07:00
Emmanuele Bassi
a4d5a24d60 Merge branch 'fix-msc-ver-compare' into 'master'
Check if _MSC_VER macro is defined

See merge request cairo/cairo!611
2025-07-14 14:42:26 +00:00
Emmanuele Bassi
6ac5348308 The GDI coordinate system is inverted compared to cairo's here, so the
delta-y value needs to be negated, otherwise glyph runs with non-zero 
y-advances will shift in the wrong direction.

See mozilla bug https://bugzilla.mozilla.org/show_bug.cgi?id=1962816 and
earlier https://bugzilla.mozilla.org/show_bug.cgi?id=454098 where this was
first discovered & fixed, but unfortunately was not upstreamed at that 
time.
2025-07-14 14:41:40 +00:00
Jonathan Kew
503505666f Fix sign of delta-y for ExtTextOutW 2025-07-14 14:41:40 +00:00
Luca Bacci
c7a3e6c519 Check if _MSC_VER macro is defined
Original patch from MSYS2:
https://github.com/msys2/MINGW-packages/blob/36dd8e0bdf/mingw-w64-cairo/0030-ucrt-clang-fixes.patch
2025-07-14 15:53:52 +02:00
Luca Bacci
b9bab3defb Readme: Remove leftover mention of Windows 2000
We support Windows Vista or newer
2025-07-14 15:52:40 +02:00
Uli Schlachter
2f21b3874c Merge branch 'fix-clipping-crash' into 'master'
Fix a crash in the clipping code

See merge request cairo/cairo!622
2025-07-14 13:01:46 +00:00
Uli Schlachter
55cb75c4df Merge branch 'winsdk_26100_fix' into 'master'
Add check for clang to cairo attribute handling code

See merge request cairo/cairo!612
2025-07-05 09:02:29 +00:00
Tim-Philipp Müller
217501df9c Merge branch 'fix-init-once-complete-check' into 'master'
Fix check for InitOnceComplete failure

See merge request cairo/cairo!631
2025-07-02 16:13:29 +00:00
Luca Bacci
76a0978d7b Fix check for InitOnceComplete failure
...also include <windows.h>

Fixes ff4f2f43
2025-07-02 13:26:00 +02:00
Ryan VanderMeulen
ef42ed0ec8 Add check for clang to cairo attribute handling code 2025-07-01 12:14:08 -04:00
Tim-Philipp Müller
0bf0265009 Merge branch 'compiler-features' into 'master'
Rework compiler features detection

See merge request cairo/cairo!627
2025-07-01 12:32:05 +00:00
Tim-Philipp Müller
b09fe42db5 Merge branch 'ci-update-for-removal-of-old-intel-mac-runners' into 'master'
ci: remove macos job that used ancient intel mac mini runners

See merge request cairo/cairo!630
2025-06-25 11:00:33 +00:00
Tim-Philipp Müller
1fa0aebad1 ci: remove macos job that used ancient intel mac mini runners
The old intel mac mini runners are being retired and are no
longer available.

A job that uses the new arm64 mac runners will be added in !498.
2025-06-25 11:14:17 +01:00
Tim-Philipp Müller
abb37e2d02 Merge branch 'fixes' into 'master'
Win32: Fix init once condition

See merge request cairo/cairo!628
2025-06-19 09:03:09 +00:00
Luca Bacci
d4f1ba74d0 Win32: Fix init once condition
Fixes !626
2025-06-19 10:15:37 +02:00
Tim-Philipp Müller
3ffb6d5c07 Merge branch 'win32-fixes' into 'master'
Win32 Fixes

Closes #897

See merge request cairo/cairo!626
2025-06-16 17:15:07 +00:00
Luca Bacci
51be2591fe Meson: Define _CRT_SECURE_NO_WARNINGS when compiling with MSVC 2025-06-16 19:10:07 +02:00
Luca Bacci
481c6c78bd Meson: Suppress warning C5286 on MSVC
This happens when converting _cairo_status to _cairo_int_status:

  warning C5286: implicit conversion from enum type '_cairo_int_status' to
  enum type '_cairo_status'; use an explicit cast to silence this warning
2025-06-16 19:01:58 +02:00
Luca Bacci
cc51930a32 Meson: Add arguments for both C and C++ compilation
C++ compilation is used on Windows
2025-06-16 18:58:00 +02:00
Luca Bacci
6989158f4c Drop support for very old GCC versions
They don't support C11 anyway. Additionally, CLang defines a very
conservative __GNUC__ value (which is also configurable via the
-fgnuc-version= command-line argument)
2025-06-16 18:52:39 +02:00
Luca Bacci
ff4f2f4301 Win32: Implement init_once with InitOnceBeginInitialize / InitOnceComplete 2025-06-16 18:50:13 +02:00
Luca Bacci
ec2e879e0d Meson: Add comment about atomic ops on Windows 2025-06-16 18:49:36 +02:00
Luca Bacci
ee554c8610 DWrite: Fix switch for grid-fit mode
Ooops!
2025-06-16 17:52:15 +02:00
Luca Bacci
d9a11c3736 Win32: Use cairo_atomic_once_t to initialize TLS slot
We were using the double-checked locking pattern, which requires
memory fences to be safe on architectures with weak memory
guarantess (e.g ARM64)

Fixes https://gitlab.freedesktop.org/cairo/cairo/-/issues/897
2025-06-16 17:51:53 +02:00
Matthias Clasen
1d3347a690 Fix a crash in the clipping code
When cairo_is_all_clipped return true, we must not attempt
to change any of the clip fields, since it is pointing to
the static const __cairo_clip_all.

Moving the check for ->region into the 'if' is fine, since
it will always be NULL for _cairo_clip_all.

This was causing a crash in inkscape, see
https://gitlab.com/inkscape/inkscape/-/issues/5631
2025-05-28 18:12:16 -04:00
Uli Schlachter
a3ca983ec3 Merge branch 'cm/fix-uaf-warning' into 'master'
xcb: Fix a -Wuse-after-free=3 warning with GCC

Closes #898

See merge request cairo/cairo!623
2025-05-27 16:02:14 +00:00