Commit graph

11575 commits

Author SHA1 Message Date
Bryce Harrington
d09d2ebfd5 Bump version for new development tree, 1.15.13 2018-06-13 15:21:06 -07:00
Bryce Harrington
dc93ea7711 test: Use C comment syntax, not C++ 2018-06-13 15:20:34 -07:00
Alexandre Bique
ccdb8e2307 Fix test compilation when font-config is disabled
Building cairo without font-config fails because test/font-variations.c
was getting compiled without freetype2.

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2018-05-31 18:39:51 -07:00
Bryce Harrington
c6e12d33bf win32: Copyedit recent comments 2018-05-31 18:31:12 -07:00
Vasily Galkin
d4355ecee2 win32: Allow GDI operations for argb32 surfaces (allowed by surface flags)
This finishes a patch series to speed up CAIRO_OPERATOR_SOURCE when used
to copy data to a argb32 cairo surface corresponding to a win32 dc from
a "backbuffer" - DibSection-based cairo surface created with
cairo_surface_create_similar().

This final patch allows the GDI compositor to be used on argb32
surfaces.  For display surfaces, only copying is allowed with gdi (by
BitBlt), since other operations are filtered by flags in
implementations.

But since copying pixels is the only operation used in the most common
scenario (prepare an offscreen image and send it to the screen) - this
is important for presenting argb32 windows with Cairo directly or with
gtk+gdk (which nowadays always creates argb32 windows).

Before this patch pixel copy worked by:
1. mapping image to memory (by copying data from window dc to system
   memory which is very slow on windows maybe due to gpu or interprocess
   access)
2. copying new data over that image.
3. copying updated image from system memory back to window dc.

After this patch there is only one step:

2+3. Copying new data over window dc.

Completely eliminating step 1 gives a very huge speedup and allows
argb32 cairo drawing be as fast as typical dibsection-buffered gdi
drawing.

There is quick & dirty cairo-vs-gdi perf test made for this patch set:
https://gitlab.gnome.org/galkinvv/cairo/snippets/109
See the Cairo mailing list for April 2018 for data and discussion of
performance improvements.

End-user visible speedup does present too - it relates to the following bug

https://gitlab.gnome.org/GNOME/meld/issues/133

This Cairo speedup allows more simultaneous meld windows
without eating 100% of cpu core time on spinner rendering.
2018-05-31 17:34:17 -07:00
Vasily Galkin
0cb7aad2a3 win32: CAIRO_WIN32_SURFACE_CAN_RGB_BRUSH and other argb32 flags set+check
This belongs to a patch series that speeds up CAIRO_OPERATOR_SOURCE when
used to copy data to an argb32 cairo surface corresponding to a win32 dc
from a "backbuffer" - DibSection-based cairo surface created with
cairo_surface_create_similar().

This patch introduces checks to ensure that no solid brush GDI operations
are attempted when using argb32 surfaces.  Doing this allows enabling
usage of the GDI compositor when these surfaces are in use.

To make these checks work, _cairo_win32_flags_for_dc disables
STRETCHBLT, STRETCHDIB and RGB_BRUSH in the argb32 flag.

_cairo_win32_flags_for_dc() is also refactored to make the distinction
between rgb24 and argb32 more readable.  All logic & flags for rgb24
surfaces are retained, except for the addition of
CAIRO_WIN32_SURFACE_CAN_RGB_BRUSH.

The logic of forbidding AlphaBlend on display surfaces is also
kept as is without investigation.
2018-05-31 17:29:26 -07:00
Vasily Galkin
884275c3ab win32: Introduce new flag to mark surfaces that support solid brush drawing
This is part of a patch series to speed up CAIRO_OPERATOR_SOURCE when
used to copy data to an argb32 cairo surface corresponding to a win32 dc
from a "backbuffer" - DibSection-based cairo surface created with
cairo_surface_create_similar().

This initial patch presents only private header changes without changing
any implementation logic.

The big problem with argb32 surfaces and GDI is that GDI is unable to
correctly set the alpha channel when using operations other than BitBlt
and AlphaBlend.

To solve this, a CAIRO_WIN32_SURFACE_CAN_RGB_BRUSH flag is introduced in
this commit to be mark surfaces that correctly handle such brushes
- essentially all surface types except argb32.
The _cairo_win32_flags_for_dc() call receives a new argument that is
used to calculate the flag.
2018-05-31 17:24:50 -07:00
Bryce Harrington
85fe4deee4 gl: Whitespace cleanup 2018-05-29 12:15:47 -07:00
Bryce Harrington
4b9333acf5 Drop stray patch from prior commit 2018-05-07 16:50:42 -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
Uli Schlachter
7554822dd0 Fix assertion failure in the freetype backend
Fonts are kept in a hash table, so when creating a new font, the code
first checks the hash table for an already-existing entry and only then
is a new instance really created. There is an assert that checks that
the key used for the hash table lookup is the same as the instance that
is created later has, because otherwise the hash table was checked
incorrectly.

This assert failed in some conditions.

Fix this by fixing some places that initialised ft hash keys in a wrong
way.

Patch by Behdad Esfahbod and submitted via bugzilla.

Source: https://bugs.freedesktop.org/show_bug.cgi?id=105746#c4
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=105746
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-04-21 09:37:06 +02:00
Bryce Harrington
7149686456 1.15.12 release
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2018-04-11 18:35:40 -07:00
Bryce Harrington
caf6f71d69 configure: Conditionalize color font feature for older freetype2
FT_HAS_COLOR() macro is unavailable in older freetype2 without the color
font feature.

Compile and link a source including FT_HAS_COLOR(); if it fails (which
can happen on older FreeType2) then define FT_HAS_COLOR(x) as (0).

Patch from suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2018-04-11 13:27:53 -07: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
Bryce Harrington
dcafd9e684 cairo-version: Fix version references in docs
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=82741
2018-04-02 17:51:08 -07:00
Unknown
12cb59be7d Cairo trivial typos
Found using `codespell -q 3 -I cairo-whitelist.txt`
whereby whitelist contained:
```
amin
iff
lod
writen
```

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2018-04-02 17:46:58 -07:00
suzuki toshiya
33a348d698 csi-trace does not show help
csi-trace does not show help string correctly, due to a bug in its
command line argument parsing.  strcmp returns 0 when there is an exact
match, which means it requires an inverted test.

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2018-04-02 11:55:19 -07:00
Uli Schlachter
50a6ad5389 pthread-same-source: Refresh reference images
I already did the same thing in commit 3e22a8580a. That commit added
a GENERATE_REFERENCE mode that does not use threads and used that for
generating the reference image.

However, the above commit falls into the range between commits
fb57ea13e0 and 3d94269bd4. The later commit reverts the earlier one,
which changed the way that image downscaling works / is used.

This means that the reference image that were generated back then were
broken. Thus, regenerating the images is the right thing to do.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Acked-by: Bryce Harrington <bryce@osg.samsung.com>
2018-04-02 11:16:34 -07:00
Uli Schlachter
fba7a7ca27 Skip font-variations test for missing fonts
Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2018-04-02 11:08:46 -07:00
Uli Schlachter
1ed124ace2 Fix a 'memory leak' in the image compositor
There is a global pixman_glyph_cache_t instance that is initialized on
first use and shows up in valgrind output as a relatively large leak (I
think it was about 200 KiB). The reason for this is that this cache is
not freed by cairo_debug_reset_static_data().

This commit wires up freeing the cache to
cairo_debug_reset_static_data().

This cache was introduced in commit 615205cf07 from 2012.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-03-15 21:43:03 +01:00
Massimo
5454b85d4b bfo#91271 - Fix access of uninitialized memory
Valgrind reports that xlib-render-compositor's composite_traps()
accesses uninitialized memory when traps->num_traps == 0.

This happens in the line that says

      if (xtraps[0].left.p1.y < xtraps[0].left.p2.y) {

after the 'for' loop.  We can actually return early if there are no
trapezoids to render.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=91271
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2018-03-08 13:30:17 -08:00
Federico Mena Quintero
45e3b8f271 bfo#105084 - Initialize memory properly in _cairo_ft_font_face_create_for_pattern()
The font_face->ft_options field was not being initialized, leading to
an invalid free().

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=105084
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2018-03-08 13:30:11 -08:00
Federico Mena Quintero
7784757b9e Add .gitlab-ci.yml to run the tests automatically 2018-03-07 14:20:24 -06:00
Bryce Harrington
14404ada80 compiler-private: Define what PLT stands for 2018-02-28 15:19:06 -08:00
Bryce Harrington
62b724ac84 win32: Fix a few typos in comments 2018-02-06 15:13:00 -08:00
Bryce Harrington
dbe3d9ea51 win32: Whitespace cleanup 2018-02-06 15:13:00 -08:00
Eric Hoffman
4d07b57c16 win32: Fix multi-monitor virtual desktop with negative monitor coords
Under Win32, when you have a multiple-monitor setup, Windows creates a
'virtual desktop', which is a rectangle surface that extends across all
monitors.

The primary monitor always starts with the top-left corner at coordinate
(0,0).  If you have any other monitors which extend to the left or
above the primary monitor, the virtual desktop's top-left corner will
actually have coordinates which are negative.

This creates an issue in Cairo with the desktop DC, i.e. when you use a
DC from the function GetDC(NULL).  The same thing can occur with other
third party libraries like GTK, when you access the Cairo surface from
the root window.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=100793
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2018-02-06 15:12:33 -08:00
Bryce Harrington
a8571a3030 xml: Typo in comment 2018-02-06 12:06:48 -08:00
Bryce Harrington
1cbebafe89 font: Check return value from _cairo_ft_unscaled_font_lock_face
cairo-ft-font.c: In function ‘_cairo_ft_has_color_glyphs’:
cairo-ft-font.c:3011:9: warning: ignoring return value of ‘_cairo_ft_unscaled_font_lock_face’, declared with attribute warn_unused_result [-Wunused-result]
         _cairo_ft_unscaled_font_lock_face (unscaled);
         ^
2018-01-23 19:58:35 -08:00
Bryce Harrington
bc335a741f Fix two type casting warnings in get_C_locale()
cairo-misc.c:806:43: warning: passing argument 1 of ‘_cairo_atomic_ptr_get’ from incompatible pointer type
     C = (locale_t) _cairo_atomic_ptr_get (&C_locale);
                                           ^

cairo-misc.c:811:45: warning: passing argument 1 of ‘_cairo_atomic_ptr_cmpxchg_impl’ from incompatible pointer type
         if (!_cairo_atomic_ptr_cmpxchg (&C_locale, NULL, C)) {
                                             ^

Routines are expecting a void** so cast.
2018-01-23 19:20:08 -08:00
Bryce Harrington
6c675653b1 RELEASING: Refine devel version and tagging 2018-01-22 14:58:46 -08:00
Behdad Esfahbod
14f5b98d22 Fixup on previous commit 2018-01-19 11:10:13 -08:00
Bryce Harrington
4a09fec668 test: Fix compile with older FreeType without FT_Get_Var_Design_Coordinates
Extend earlier fix to the tests as well.
2018-01-18 21:02:12 -08:00
Behdad Esfahbod
5795ac9d90 Fix compile with older FreeType without FT_Get_Var_Design_Coordinates 2018-01-15 19:28:56 -05:00
Uli Schlachter
b7f313a8d2 fix warning: variable X might be clobbered by 'longjmp'
According to "man setjmp", one possible way to avoid variable clobbering
is to declare them as volatile. Thus, this commit turns the variables
that are changed between setjmp() and longjmp() and whose values are
still needed after setjmp() returned the second time into volatile
variables.

The warning in cairo-bentley-ottmann-rectangular.c is worked around by
not initializing the variable before setjmp(). To be honest, I don't
understand why the compiler warns here at all since the value of update
is clearly not used after setjmp()'s second return.

This commit re-fixes the warnings that were reintroduced in commit
82f40285 which reverted b092b63.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Acked-by: Bryce Harrington <bryce@osg.samsung.com>
2018-01-13 11:30:50 +01:00
Uli Schlachter
62f2037bc0 Fix warning: '*' in boolean context
The full message is:

  warning: ‘*’ in boolean context, suggest ‘&&’ instead
      _cairo_malloc((unsigned) (a) * (unsigned) (size)))
                                   ^
  note: in definition of macro ‘_cairo_malloc’
      ((size) ? malloc((unsigned) (size)) : NULL)
        ^~~~

Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2018-01-13 11:30:26 +01:00
Behdad Esfahbod
c3659d7ef6 Use FT_Done_MM_Var() if available 2018-01-08 10:07:25 +00:00
Matthias Clasen
37f9a5525d Don't leak memory in font options
The cairo_font_options_t struct may now contain allocated
memory, so call fini whenever we are about to let go of an
embedded cairo_font_options_t struct.
2018-01-05 09:10:32 -05:00
Matthias Clasen
1f0b6707ea Add a _cairo_font_options_fini function
The variations member of cairo_font_options_t is allocated,
so we need to have a method to free it for cases where
the struct is embedded in larger structs, such as cairo_ft_options_t.
2018-01-05 09:09:01 -05:00
Matthias Clasen
17871c52ef Don't leak patterns when compositing color glyphs
We were forgetting to free the pattern here.
2018-01-04 23:25:09 -05:00
Matthias Clasen
616fb7a9f2 Fix a memory leak
cairo_ft_apply_variations was leaking the FT_MM_Var struct.
2018-01-04 20:56:59 -05:00
Behdad Esfahbod
a7a0085713 Merge branch 'font-variations' 2018-01-03 12:35:12 +00:00
Behdad Esfahbod
a18c0decda [ft] Remember variations set on FT_Face and apply them
For this to work correctly with hb-view, needs a patch that went
into FreeType today.
2018-01-02 19:25:18 -05:00
Uli Schlachter
6b0593827b Add test for error handling with broken PNG streams
Would-have-caught: https://bugs.freedesktop.org/show_bug.cgi?id=104325
Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-12-24 13:23:13 +01:00
Uli Schlachter
82f4028532 Revert "fix warning: variable X might be clobbered by 'longjmp'"
This reverts commit b092b63119 which
introduced a wrapper function around setjmp(). To quote from man setjmp:

  If the function which called setjmp() returns before longjmp() is
  called, the behavior is undefined.  Some kind of subtle or unsubtle
  chaos is sure to result.

Since after the above commit setjmp() is called from the wrapper
function, the result might or might not work, depending on compiler
settings. If the setjmp() wrapper is not inlined, then the state of the
stack after longjmp() will likely be garbage.
2017-12-23 13:04:59 +01:00
Bryce Harrington
3e07efd21e makefile: Fix sorting of source files 2017-12-20 17:09:05 -08:00
Behdad Esfahbod
e8ddc505b3 [ft] Fix warnings 2017-12-19 18:04:04 -05:00
Matthias Clasen
c32a5c741f Shortcut FT_Set_Var_Design_Coordinates
We currently (have to) apply font variations for every glyph.
Calling FT_Set_Var_Design_Coordinates has expensive side-effects,
like resetting the autohinter, so we should avoid doing it
fht he coordinates don't actually change.
2017-12-19 17:36:36 -05:00
Behdad Esfahbod
d8ddadc5c3 [ft] When merging font options, order variations correctly
Later wins, and we want "options" to win over "other".
2017-12-19 15:29:13 -05:00
Behdad Esfahbod
82107467f0 [ft] Use variations from ft_options, not scaled-font
Otherwise the variations from FcPattern won't be applied.
2017-12-19 15:18:57 -05:00