Commit graph

419 commits

Author SHA1 Message Date
Anton Danilkin
500b39e98f Move cairo_svg_surface_t to cairo-svg-surface.c 2021-04-11 23:59:47 +02:00
Anton Danilkin
d88ac55b9f Remove SVG 1.2 and CAIRO_CONTENT_COLOR SVG boilerplate targets 2021-04-11 23:59:47 +02:00
Tim-Philipp Müller
9732f4e80f meson: use encoding=utf-8 when reading/writing files in helper script
Fixes errors such as

Traceback (most recent call last):
  File "C:\Users\...\cairo\test\make-cairo-test-constructors.py", line 19, in <module>
    for l in f.readlines():
  File "c:\python39\lib\encodings\cp1253.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 6694: character maps to <undefined>

on non-English-language Windows locales/installations.
2021-02-23 23:42:11 +00:00
Tim-Philipp Müller
51d50621be meson: only build cairo-boilerplate and cairo-missing helper libs if needed
Used by tests and the sphinx utility, which may or may not be built,
and if they're not built we don't need to build those libs either.
2021-01-15 18:47:08 +00:00
Uli Schlachter
2ceb279d70 boilerplate-xcb: Avoid leaks on success
This gets rid of the following two leaks reported by valgrind when successfully
running a test with CAIRO_TEST_TARGET=xcb:

8,000 bytes in 2 blocks are definitely lost in loss record 9 of 10
   at 0x483877F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x4B7E135: read_packet (xcb_in.c:259)
   by 0x4B7E135: _xcb_in_read (xcb_in.c:1031)
   by 0x4B7BF8E: _xcb_conn_wait (xcb_conn.c:516)
   by 0x4B7D6AE: wait_for_reply (xcb_in.c:516)
   by 0x4B7D8C8: xcb_request_check (xcb_in.c:745)
   by 0x18D747: _cairo_boilerplate_xcb_create_surface (cairo-boilerplate-xcb.c:310)
   by 0x12906F: cairo_test_for_target (cairo-test.c:819)
   by 0x12AAB5: _cairo_test_context_run_for_target (cairo-test.c:1555)
   by 0x126921: _cairo_test_runner_draw (cairo-test-runner.c:250)
   by 0x126921: main (cairo-test-runner.c:932)

8,000 bytes in 2 blocks are definitely lost in loss record 10 of 10
   at 0x483877F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x4B7E135: read_packet (xcb_in.c:259)
   by 0x4B7E135: _xcb_in_read (xcb_in.c:1031)
   by 0x4B7BF8E: _xcb_conn_wait (xcb_conn.c:516)
   by 0x4B7D6AE: wait_for_reply (xcb_in.c:516)
   by 0x4B7D7C0: xcb_wait_for_reply (xcb_in.c:546)
   by 0x18D45D: find_depth (cairo-boilerplate-xcb.c:154)
   by 0x18D45D: _cairo_boilerplate_xcb_create_render_0_0 (cairo-boilerplate-xcb.c:621)
   by 0x12906F: cairo_test_for_target (cairo-test.c:819)
   by 0x12AAB5: _cairo_test_context_run_for_target (cairo-test.c:1555)
   by 0x126921: _cairo_test_runner_draw (cairo-test-runner.c:250)
   by 0x126921: main (cairo-test-runner.c:932)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2020-12-05 08:08:14 +01:00
Uli Schlachter
e3eaccb939 boilerplate-xcb: Avoid leaks on error
Before this commit, running the test suite against a non-existing
display under valgrind resulted in:

$ ( cd test; DISPLAY=:2 CAIRO_TEST_TARGET=xcb valgrind --leak-check=full .libs/cairo-test-suite -f random-clip )
[...]
==47359== 64 bytes in 2 blocks are definitely lost in loss record 1 of 7
==47359==    at 0x483AB65: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==47359==    by 0x18A272: cairo_boilerplate_xcalloc (cairo-boilerplate-system.c:65)
==47359==    by 0x18D652: _cairo_boilerplate_xcb_create_surface (cairo-boilerplate-xcb.c:269)
==47359==    by 0x12906F: cairo_test_for_target (cairo-test.c:819)
==47359==    by 0x12AAB5: _cairo_test_context_run_for_target (cairo-test.c:1555)
==47359==    by 0x126921: _cairo_test_runner_draw (cairo-test-runner.c:250)
==47359==    by 0x126921: main (cairo-test-runner.c:932)

This commit fixes that by freeing the allocated memory in the error
path.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2020-12-05 07:46:41 +01:00
Anton Danilkin
b5175fd8a6 Fix testing in the full mode for PDF, PS and SVG backends
Fix how offset, scale and transparency are handled.

Also do the same change in the "win32-printing" backend as it has a copy of the code from PDS, PS and SVG backends.
2020-11-13 12:04:51 +00:00
George Matsumura
ed98414686 build: Fix various compiler warnings
This fixes a few compiler warnings that were encountered with gcc 9.3.0.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-11-07 06:45:01 -07:00
Tim-Philipp Müller
4ea2991a40 Retire dummy cairo-version.h header to fix meson subproject build
It was originally added to make bisecting easier,
but has outlived its usefuleness now.

Going forward we'll have just a single cairo-version.h
header file, the one with the real version numbers.

This is needed to fix the case where cairo is being
built as a Meson subproject, but also simplifies
things in general.

Fixes #421
2020-09-29 15:50:53 +00:00
George Matsumura
ecbd7ed174 cogl: Add new path cache
This redesigns the path cache so that it does not mess with the
context functions, thereby hopefully making it much more resilient
to changes in the rest of cairo that change the way the default
context works. It is also much simpler, and it is anticipated that
it will be more maintainable. Performance in contrast to the old
cache design speeds up most traces in cairo-perf-trace, and slows
down only a lesser few by <20%.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:58 -06:00
George Matsumura
26c7103750 cogl: Fix reference counting bugs
Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:58 -06:00
George Matsumura
bb84bb650d cogl: Ensure onscreen framebuffers have an alpha component if required
Prior to this change, cogl often queried GLX so that it returned
a framebuffer that could not support an alpha component.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:58 -06:00
George Matsumura
916408481f cogl: Move framebuffer creation functionality out of boilerplate
In order to be more consistent with backends such as gl, support for
creating a surface from content, width, and height parameters was
moved into the backend itself. The option to pass cairo-cogl a
framebuffer to create a texture from still exists, just now it is
not the only option.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:58 -06:00
George Matsumura
f3d2623046 cogl: Fix very small surfaces in boilerplate
Prior to this change, the boilerplate code crashed when given surface
dimensions less than 1. This fixes such behaviour by rounding the
dimensions up to 1, which is also done by the boilerplate code for
several other backends.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:58 -06:00
George Matsumura
75d843208c cogl: Move context, device, and surface members to most fitting places
The buffer stack was moved from the surface to the device, as
mapped buffers are shared across all surfaces using the device
and more than one surface may be doing so. Stemming from this, if
a surface tries to map a buffer without first unmapping one that
has been mapped by another surface, it will trigger an error.

The parent backend functions were moved from the device to the
context, as it is possible that the context creation function could
be passed a non-cogl device. Prior to this change, many of the
subsurface tests segfaulted.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:57 -06:00
George Matsumura
ceffa65fb0 cogl: Account for new representations of framebuffer types
With the new cogl API, casting the framebuffer into offscreen
and onscreen types with the provided macros is a deprecated
behavior.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:57 -06:00
George Matsumura
bda0f90d6e cogl: Correct behavior of boilerplate surface finishing functions
Without this, a buffer-swapping function only usable on onscreen
framebuffers would have been used on offscreen framebuffers.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:57 -06:00
George Matsumura
6250e1a843 cogl: Use new separate functions for offscreen and onscreen framebuffers
The old boilerplate code no longer worked due to the deprecation of
functions for swapping the buffers that it used.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:57 -06:00
Mathieu Duponchelle
596a82f2d1 Add meson build definitions
Co-Authored by:
Nirbheek Chauhan <nirbheek@centricular.com>
lb90 <luca.bacci982@gmail.com>
Tim-Philipp Müller <tim@centricular.com>
2020-07-31 12:21:50 +01:00
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
38806bc3c0 Disable skia from configure
Implement suggestion by Adrian Johnson to comment out skia in
configure.ac to avoid presenting it as an option to users.  This was
discussed on the Cairo mailing list in September 2017.

Skia is not API stable and is not available in packaged+versioned forms,
resulting in it being a continually moving target.  I.e. it's pretty
much always unusably out of date.  The last update to the skia backend
was in 2014, and had not been updated very regularly prior to that.

We'll simply disable it for now.  If no one complains by the next Cairo
snapshot release, we'll assume no one is needing it and will drop the
code entirely.

Meanwhile, if anyone does need it, it can be uncommented and used.

(The changes to the win32 build config appear to be automatically
generated as a result of disabling the feature in configure.  I'm
committing them to avoid confusion.)
2018-04-02 20:20:00 -07:00
Adrian Johnson
38fbe621cf image: prevent invalid ptr access for > 4GB images
Image data is often accessed using:

  image->data + y * image->stride

On 64-bit achitectures if the image data is > 4GB, this computation
will overflow since both y and stride are 32-bit types.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=98165
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2017-11-07 17:01:49 -08:00
Adrian Johnson
1674d2b885 pdf: set default create date 2017-10-24 21:44:08 +10:30
Bryce Harrington
8ff3019f51 gl: Add support for OpenGL ES 3.0
This improves the OpenGL ES support to extend it to version 3.0.
A number of new features are available in glesv3 including creation of
multi-sampled renderbuffers.  These renderbuffers can be blitted to
single sample textures (but not the other way around).  Other features
such as PBO for image uploading, are left as followon work.

For this preliminary implementation, glesv3 backends always create
renderbuffers, which can be set as single sample or multisample.  The
renderbuffer's content is blitted to the texture only when used as a
source or a mask.

Images uploaded to a texture stay there until the surface is used as a
rendering target, at which point its painted to the renderbuffer.

This patch is heavily based off of Henry Song's initial GLESv3 patch
6f7f3795 from his cairogles fork of Cairo, and incorporates subsequent
fixes and pertinent refactorings from his trunk and review feedback from
Uli.

This implements the *functional* support for glesv3, excluding the
various optimization work to utilize its features.  Rendering and
performance should not be expected to improve notably from pure glesv2.
As the GL backend for Cairo remains "experimental", these changes should
likewise be considered as such.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2017-09-13 15:18:04 -07:00
Adrian Johnson
1272db90f8 win32: gcc 5.4 build fix 2016-06-21 19:44:48 +09:30
Bryce Harrington
e0963f6c8e gitignore: Ignore .trs (test results) 2015-07-31 17:56:54 -07:00
Bryce Harrington
2de9fca5f3 boilerplate: Fix list termination for glXChooseVisual
The attribute list is terminated by GLX_NONE (defined as 0x8000), but
the man page of 'glXChooseVisual' says it must be terminated with None
(0L).

Issue found and fix suggested by Massimo.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=91293
2015-07-30 17:16:53 -07:00
Руслан Ижбулатов
e38e942ac0 win32: Add a win32 boilerplate that uses a real window
This way it uses the codepath for cairo_win32_surface_create_with_format(),
instead of the cairo_win32_surface_create_with_dib().

Without the recording tests (which terminate the testsuite)
the testsuite results for win32 are:

284 Passed, 167 Failed [1 crashed, 9 expected], 23 Skipped
win32 (rgb24): 1 crashed!
win32 (rgb24): 17 error
win32 (rgb24): 155 failed
win32 (argb32): 1 crashed!
win32 (argb32): 17 error
win32 (argb32): 68 failed
win32-window-color (rgb24): 1 crashed!
win32-window-color (rgb24): 17 error
win32-window-color (rgb24): 148 failed
win32-window-coloralpha (argb32): 1 crashed!
win32-window-coloralpha (argb32): 17 error
win32-window-coloralpha (argb32): 66 failed

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-04-13 17:43:35 -07:00
Bryce Harrington
2c5af590dd Refactor ARRAY_LENGTH macro definitions in test code 2014-11-20 12:22:06 -08:00
Ravi Nanjundappa
c61aeddc44 test: improve selective execution of Cairo tests based on FORMAT option
This patch improves the patch "test: Selective execution of Cairo tests based on FORMAT option"
by extending the usage of FORMAT option even in the case of user not
providing TARGETS= option

For ex:
(1). CAIRO_TESTS="zero-alpha" make test FORMAT=rgba
This command runs the zero-alpha test for all the backends with
argb32 content format and so on.
(2). CAIRO_TESTS="zero-alpha" make test FORMAT=rgba,rgb
This command runs the zero-alpha test for all the backends with
argb32 and rgb24 content formats.

Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-08-14 16:10:09 -07:00
Ravi Nanjundappa
f8e0ecb5af test: Selective execution of Cairo tests based on FORMAT option
Added a new command line option FORMAT which can take rgb and/or rgba
values which enables the execution of tests only for the given FORMAT
For ex:
(1). CAIRO_TESTS="zero-alpha" make test TARGETS=ps2,image FORMAT=rgba,rgb
This command runs the zero-alpha test for both ps2 and image backends
with argb32 and rgb24 content formats.
(2). CAIRO_TESTS="zero-alpha" make test TARGETS=ps2,image FORMAT=rgba
This command runs the zero-alpha test for both ps2 and image backends
with argb32 content format and so on.

Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-08-14 16:09:20 -07:00
Behdad Esfahbod
9e6ceb23b4 More binary mode for Windows
Based on:
https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-cairo/0012-more-binary-mode.mingw.patch
2014-07-23 12:12:04 -04:00
Ravi Nanjundappa
ead5c7909f vg: Use EGL_NONE and GLX_NONE in place of None
Use EGL_NONE in EGL section and GLX_NONE in GLX section
instead of None in cairo-boilerplate-vg.c

Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=55805
2014-05-19 17:37:38 -07:00
Ravi Nanjundappa
69e10bc8b5 glx: Use GLX_NONE in place of None
Use "GLX_NONE" in rgb and rgba attributes instead of
"None" in cairo-boilerplate-glx.c

Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com>
Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
2014-05-16 11:54:43 -07:00
Ravi Nanjundappa
55608e4fd6 boilerplate: Maintain consistency in the usage of switch cases
Some of the switch cases used in boilerplate are not consistent
across other source files in the same module. This patch fixes the
consistency issues of switch case usage in the boilerplate module.

Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com>
Reviewed-by: Uli Schlachter <psychon@znc.in>
2014-05-06 10:22:43 -07:00
Martin Robinson
f6efecdfef boilerplate/gl: Disable thread awareness
This dramatically speeds up testing on NVidia and actually makes it
possible to run traces within a reasonable amount of time.

cairo-perf-trace results for:
NVIDIA Corporation GeForce GTS 250/PCIe/SSE2 3.3.0 NVIDIA 310.14

Before:
test              min(s)  median(s) stddev. count
gvim              30.924  31.251    0.72%   5/6
firefox-fishbowl  168.751 201.017   12.46%  8/8
(exited early)

After:
test              min(s)  median(s) stddev. count
gvim              1.294   1.325     1.79%   6/6
firefox-fishbowl  18.540  19.104    1.54%   6/6
2013-04-04 12:04:50 -07:00
Martin Robinson
b00b9e82ab boilerplate: Add a mode for running threaded perf tests
This is useful because the GL backend runs much faster on some drivers
when thread awareness is disabled.
2013-04-04 12:04:50 -07:00
Uli Schlachter
b7c06fff1f boilerplate: rename xcb-render-0.0 to xcb-render-0_0
The test suite uses dots to separate the backend name from the content type.
Thus, the backend name must not contain any dots.

The xlib backend already calls its RENDER 0.0 target xlib-render-0_0 for this
reason. This commit makes the xcb backend match this.

Reported-by: Darxus <darxus@chaosreigns.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-03-22 14:04:44 +01:00
Uli Schlachter
caf50c07e2 test: Fix handling of dots in CAIRO_TEST_TARGET
Before this, the following happened:

  $ CAIRO_TEST_TARGET=image,xcb-render-0.0 make test
  Cannot find target 'image'.
  Known targets: image, [...]

The reason for this is that _cairo_boilerplate_target_matches_name() doesn't get
a null-terminated string, but instead has a pointer to the end of the string.
However, strpbrk() expects a null-terminated argument and thus could return a
result which points past the end of the input.

This commit fixes exactly this.

Reported-by: Darxus <darxus@chaosreigns.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-03-22 14:02:09 +01:00
Martin Robinson
9bff450844 boilerplate/glx: Add a target with multisampling and stencil support
Add a gl-window target that supports multisampling. This is useful for
testing the MSAA backend on the default framebuffer.
2013-01-04 16:29:51 -08:00
Uli Schlachter
000a137a65 boilerplate-xcb: Ignore MappingNotify events
The boilerplate code makes sure that our tests didn't cause any X11 errors or
X11 events, because those might confuse API users.

However, when the keyboard layout changes, every connection gets a MappingNotify
event. This means that the test and performance test suites failed when the
keyboard layout was changed while they are running.

Fix this by ignoring MappingNotifies.

Reported by Arthur Huillet on IRC.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2012-12-17 17:12:59 +01:00
Chris Wilson
64d65f72e5 boilerplate/gl: Round fractional window sizes up
A few test cases purposely create fractional surface sizes which can not
be natively supported by the raster backends such as GL. For these
backends we need to consistent in creating a surface that is large
enough to contain the test, so we need to use ceil() rather than
implicit truncation to integers.

A consequence of the misalignment between the Window size and the
surface size (where one was using ceil and the other not) is that the
first row of the cairo surface would not be visible on the output.

Based on a patch by Chuanbo Wen to fix 5 test cases, such as
group-unaligned.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-06-29 10:33:08 +01:00
Chris Wilson
93d42e82a4 Revert accidental push of ps debugging API.
This reverts commits
   6ad8c96fd8,
   a3f97d1d2e,
   25abe58298

I should know better by now than to push without checking for outstanding
changes.
2012-04-14 14:54:07 +01:00
Chris Wilson
25abe58298 pdf (debug API): Export the ability to force fallbacks
We need to occasionally force fallbacks whilst testing the PDF
output, so export a debug interface to do so in order to avoid poking
around inside cairo internals.

References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-12 12:22:17 +01:00
Chris Wilson
a3f97d1d2e ps (debug API): Export the ability to force fallbacks
We need to occasionally force fallbacks whilst testing the PostScript
output, so export a debug interface to do so in order to avoid poking
around inside cairo internals.

References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-12 12:22:15 +01:00
Chris Wilson
6ad8c96fd8 ps (API): Export the ability to set the creation date of the surface
A PostScript surface embeds a CreationDate comment into its document
description pre-amble. Normally this is set to the time the surface is
written out, except we set this to a constant value in the boilerplate
for the purposes of mimicking a reference file. It may also be useful
for external applications, so make it a public export.

References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-12 12:21:22 +01:00
Maarten Bosmans
b74e8ebd50 Add _cairo_win32_print_gdi_error to boilerplate code
This function is not exported in libcairo, so can't be used from the
library.
2012-04-10 12:09:02 +01:00
Henry (Yu) Song
1e4f385dec boilerplate/gl: set width and height to be at least 1 2012-03-19 11:01:47 +00:00
Adrian Johnson
589216c1e3 win32: fix compilation on cygwin 2012-02-25 09:52:10 +10:30
Andrea Canciani
d95cf87c03 boilerplate: Use any2ppm from ANY2PPM env variable
If the environment variable ANY2PPM is set, use it as the path to the
any2ppm program. Otherwise, default to "./any2ppm" as before.

This makes it possible to set the ANY2PPM variable in the
Makefile.win32 build system, which makes it possible to use the "test"
target on the script backend.
2012-02-23 00:16:44 +01:00