Commit graph

7499 commits

Author SHA1 Message Date
Matthias Clasen
e4a79db010 xlib compositor: Support subpixel positioning
As for the image compository, support a 4x4
subpixel grid.
2019-07-18 14:38:47 -07:00
Matthias Clasen
ea9329215d image compositor: Support subpixel positioning
Support subpixel positioning with a 4x4 subpixel grid.

When compositing glyphs in the image compositor,
we store the subpixel phases in the high bits of the
glyph index. The _cairo_scaled_glyph_index() macro
has been updated to discard these bits. By storing
the phases in the glyph index, the glyph cache just
keeps working. When loading a glyph, the Freetype
font backend shifts the outline according to the
phases.
2019-07-18 14:38:47 -07:00
Florian Müllner
bab53d91a8 ft-font: Fix color font support
FT_PIXEL_MODE_BGRA is an enum member, not a define, so it always appears
as 0 in the preprocessor conditions added in commit c0ed8ce1a1.

There is an existing define for color font support, use that instead.
2019-05-30 17:38:59 +00:00
Antony Lee
dfe3aa6d88 Fix off-by-one bug in tor22-scan-converter.
This makes the implementation in tor22-scan-converter match the one in
tor-scan-converter.
2019-05-10 15:02:54 +00:00
Bryce Harrington
2d1a137f3d Revert "clip-boxes: Drop too-early return"
This reverts commit cb871c6c69.

The original code is badly, but removing the early return leads to
crashes.  This code will need a lot more attention to get right, for now
at least go back to the original behavior.

Fixes: https://gitlab.freedesktop.org/cairo/cairo/issues/358#note_125270
2019-03-03 00:01:34 -08:00
Bryce Harrington
4c5c48ebaa surface: Fix spelling fix 2019-02-01 09:11:46 -08:00
Bryce Harrington
0f6ca43f5e cairo: Fix Since number for new color formats 2019-02-01 08:15:42 -08:00
Adrian Johnson
2a21ed0293 tags: Don't ignore tag on empty pages
Issue 357
2019-02-01 19:47:00 +10: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
cb871c6c69 clip-boxes: Drop too-early return
The indentation of this line suggests it is a typo.  In any case it
causes the function to unconditionally return immediately, thereby
shortcircuiting it entirely, which does not appear to be the intended
behavior.

Fixes: https://gitlab.com/cairo/cairo/issues/2
2019-01-31 17:24:05 -08:00
Adrian Johnson
ef8c379e0f scaled-subsets: always include glyphs maps to character 0
Issue 354
2019-01-16 20:46:42 +10:30
Uli Schlachter
6edf572ebb Merge branch 'ft-crash' of gitlab.freedesktop.org:carlosgc/cairo 2019-01-09 07:50:12 +01:00
Maarten Lankhorst
d061570a70 png: Add support for 16 bpc png reading as floating point format
Similar to writing png, don't squash 16 bpc to 8 bpc and create
a float surface to contain the image.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Bryce Harrington <bryce@bryceharrington.org>
2019-01-07 19:14:16 -08:00
Maarten Lankhorst
1df0a68460 png: Add support for writing new floating point formats as 16 bpc png.
_cairo_image_surface_coerce will round down the image to a lower
bpp when using one of the floating point formats, so don't coerce those.
This makes the code actually work for those formats.

Because a float takes more storage than u16, we have to convert float
to u16 before calling png_write_image, because png_write
doesn't give us back the original row data, but an in-place copy.

With these changes we can dump floating point files with the highest
possible accuracy, with floats clamped between 0 and 1.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Bryce Harrington <bryce@bryceharrington.org>
2019-01-07 19:14:13 -08:00
Maarten Lankhorst
a34cb719cd Add support for RGBA128F and RGB96F formats.
IGT wants to add support for planes with a bit depth >10, which
requires a higher precision format than we have currently.

I'm using RGBA as format, because of its existence in OpenGL.
With the new formats we can directly convert our bytes to half float,
or multiply a colro vector with a matrix to go to the Y'CbCr colorspace.

This requires pixman 0.36.0, so bump the version requirement.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Bryce Harrington <bryce@bryceharrington.org>
2019-01-07 19:10:44 -08:00
Adrian Johnson
3a0670e03c tag_attributes: Allow decimal points in non decimal point locales
Issue #347
2018-12-31 12:45:06 +10:30
suzuki toshiya
c0ed8ce1a1 [cairo-ft-font.c] conditionalize the changes by 3ec4aa24 on 2018-07-16 for legacy FreeType2 without color font feature 2018-12-13 14:36:56 +09:00
Adrian Johnson
3c4570f8f4 ps: fix invalid matrix in eps embedding 2018-12-02 21:30:51 +10:30
Carlos Garcia Campos
90e85c2493 ft: Use FT_Done_MM_Var instead of free when available in cairo_ft_apply_variations
Fixes a crash when using freetype >= 2.9
2018-11-19 12:35:33 +01:00
Adrian Johnson
4c8813f0ea pdf: add missing flush
Issue #342
2018-10-25 18:46:17 +10:30
Adrian Johnson
4db835c5b5 doc: fix link tags code example
The old code did not work.
2018-10-24 13:43:05 +10:30
Adrian Johnson
717f0e0a40 type1: fallback if the font matrix is not a uniform scale
https://bugs.launchpad.net/ubuntu/+source/cairo/+bug/1790242
2018-10-21 13:42:24 +10:30
Bryce Harrington
3a03c1ba4b win32: Fix regression with text containing space character
Converting a series of glyphs to a path triggers an out of memory error
if there is a space glyph (bytesGlyph==0).  The regression was
introduced by commit 19982393 in cairo-win32-font.c:107.

The behavior of malloc(0) is not well defined - it can return NULL on
some platforms, or an arbitrary (non-allocated) pointer on other
platforms.  Commit 19982393 introduced sanity by enforcing that NULL is
always returned in this situation, which inappropriately triggers the
OOM check in _cairo_win32_scaled_font_init_glyph_path().  Instead,
special case the handling for bytesGlyph==0.

Patch authored by Uli Schlachter, based on fix proposed by lb90.

Fixes:  https://gitlab.freedesktop.org/cairo/cairo/issues/339
Reference:  https://gitlab.gnome.org/GNOME/pango/issues/323
Reviewed-by: Bryce Harrington <bryce@bryceharrington.org>
2018-10-17 17:32:10 -07: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
Paul Menzel
f246a2144f Use HTTPS URLs for gnome.org domains
Run the command below suggested by geirha in ##sed@irc.freenode.net.

    git grep -l 'http://.*gnome.org' | xargs sed -i 's|http\(://\([[:alnum:].-]*\.\)\{0,1\}gnome\.org\)|https\1|g'

Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
2018-10-16 10:03:20 -07:00
Paul Menzel
1c9201721d Use HTTPS URLs for freedesktop.org domains
Run the command below suggested by geirha in ##sed@irc.freenode.net.

    git grep -l 'http://.*freedesktop.org' | xargs sed -i 's|http\(://\([[:alnum:].-]*\.\)\{0,1\}freedesktop\.org\)|https\1|g'

Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
2018-10-16 10:03:07 -07:00
Paul Menzel
15ad6ca3e1 Use HTTPS URLs for cairographics.org domains
Run the command below suggested by geirha in ##sed@irc.freenode.net.

    git grep -l 'http://.*cairographics.org' | xargs sed -i 's|http\(://\([[:alnum:].-]*\.\)\{0,1\}cairographics\.org\)|https\1|g'

Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
2018-10-16 10:03:01 -07:00
Bryce Harrington
bf597b8928 Revert "Correctly decode Adobe CMYK JPEGs in PDF export"
From further testing and investigation it appears that many PDF viewers
already have a workaround to invert Adobe CMYK JPEGs, so our generated
PDFs display incorrectly with those viewers due to double-inversion.

Further investigation will be needed to find a better solution that
doesn't cause regression for some PDF viewers; perhaps PDF viewers that
lack this inversion workaround should be changed to include it.  For now
we'll drop the patch to avoid shipping the regression in 1.16.0.

This reverts commit b207a932a2.

Reference: https://bugs.freedesktop.org/show_bug.cgi?id=97612
Fixes: https://gitlab.freedesktop.org/cairo/cairo/issues/156
2018-10-16 09:53:00 -07:00
Bryce Harrington
201791a52d gstate: Minor grammar copyedit 2018-09-05 19:12:29 -07:00
Federico Mena Quintero
38fc475995 cairo-analysis-surface: Quell invalid uninitialized variable warning
Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
2018-09-05 17:00:44 -07:00
Bryce Harrington
5de2667b76 Fix sp. sheering
Pointed out by keith.briggs@bt.com
2018-08-24 09:33:50 -07:00
Bryce Harrington
2cf141f690 Convert 3 headers to UTF8
Fix distcheck, which was failing on the copyright symbols in these
files, because their encoding was not being detected as UTF-8.
2018-08-16 20:14:57 -07:00
Behdad Esfahbod
3ec4aa24aa [ft] Implement some more color conversion routines
Makes new COLR/CPAL implementation in FreeType work with cairo now.
Ie. Microsoft's Segoe UI Emoji Regular font renders (instead of
crashing cairo.)
2018-07-16 13:55:20 +02:00
Bryce Harrington
6112212794 scaled-font: Fix glyph and cluster count checks (CID #983386)
num_glyphs and num_clusters are explicitly checked to be non-NULL at the
beginning of this routine, and by this point in the code both have been
deref'd multiple times, so checking them for NULL here again is
superfluous.

It looks like the intent here is to verify the glyphs and clusters
arrays are non-NULL unless their counts are zero, so change the tests
accordingly.

Coverity ID: #983386

Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
2018-06-15 22:15:19 -07:00
Bryce Harrington
2b6b23fd8c polygon-intersection: Clarify ptr checks for right edges (CID #1160730)
The code is checking a variable is non-NULL after it's already been
dereferenced in an assert.

I'm not certain whether the assert should be conditionalized to only be
tested when right != NULL (which would allow edges_end() to still be
invoked), or if the function should assert right as non-NULL always.

Coverity ID: #1160730
Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
Reviewed-By: Uli Schlachter <psychon@znc.in>
2018-06-13 15:21:50 -07:00
Bryce Harrington
5a4a86c27f type1-subset: Fix incorrect null ptr check from find_token() (CID #1160662)
subrs was already tested for NULL prior to this, and will never be NULL
at this point.  Meanwhile, find_token()'s return is unchecked (it can
return NULL and is checked in all other calls).  Quite clearly, this is
a copy-paste error from the prior find_token call, and the intent was to
check array_start not subrs.

Coverity ID: #1160662
Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
Reviewed-By: Uli Schlachter <psychon@znc.in>
2018-06-13 15:21:50 -07:00
Bryce Harrington
9b0355a591 pdf: Fix potential null ptr deref when creating smask groups (CID #1159559)
Patch 37a22669 improved performance by using bounding box extents.
However, the code appears to be incorrect.  If extents is non-NULL it
copies its contents to group->extents, otherwise it sets group->extents
to sensible defaults, but then goes ahead and tries to copy the
undefined contents.  This second copy is unnecessary if extents is
non-NULL and will cause a crash if it is NULL.

Drop the extra copy, guessing it's just a typo.

Coverity ID: #1159559
Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
Reviewed-By: Uli Schlachter <psychon@znc.in>
2018-06-13 15:21:50 -07:00
Bryce Harrington
9c56502e06 bo: Free event_y in case of error to prevent memory leak (CID ##1160682)
If the call to _cairo_malloc_ab_plus_c() fails, it returns an error
without first freeing event_y.

Coverity ID: #1160682
Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
Reviewed-By: Uli Schlachter <psychon@znc.in>
2018-06-13 15:21:50 -07:00
Bryce Harrington
1c3ecfac13 snapshot: Don't use extra after it's been freed (CID #220086)
Note this changes the semantics of the value of extra_out such that it
is set to NULL instead of left undefined in case an error is returned.

Coverity ID: 220086
Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
Reviewed-By: Uli Schlachter <psychon@znc.in>
2018-06-13 15:21:50 -07:00
Bryce Harrington
37655af38d bo: Check null return from _cairo_malloc_ab() (CID #1159556)
_cairo_malloc_ab() can return NULL under some circumstances, and all
other callers of this routine in the Cairo codebase check its return, so
do so here as well.

Coverity ID: #1159556
Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
Reviewed-by: Uli Schlachter <psychon@znc.in>
2018-06-13 15:21:50 -07:00
Bryce Harrington
9d2e3646fa script-surface: Check for invalid ids (CID #1159557, 1159558)
If the bitmap's min is non-zero, _bitmap_next_id() could break out of
its loop early, before initializing the prev variable.  prev would then
be dereferenced without a null ptr check.  This condition should never
occur in practice, so add an assert() to assure it doesn't.

Same issue is present in trace.c.

Coverity IDs: #1159557, #1159558
Reviewed-By: Uli Schlachter <psychon@znc.in>
Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
2018-06-13 15:21:50 -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
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