Commit graph

39 commits

Author SHA1 Message Date
Adrian Johnson
fea2463107 Support color fonts that use the foreground color
COLR fonts can have a layer with the same color as the current text
color. This change passes the current color (if solid) through to
the font backend where it can be used to render color fonts.

scaled_glyph_lookup checks if the foreground color has changed (for
glyph that require it) and requests a new color surface if required.

This also fixes a bug where scaled_glyph_lookup would always request a
color surface for glyphs for glyphs in color fonts that do not have
color.
2021-08-28 18:07:01 +09:30
Heiko Lewin
3ca8a46caf Minor corrections 2021-04-11 02:07:10 +02:00
Heiko Lewin
518ba13779 Fix undefined left-shifts 2021-03-31 12:20:34 +02:00
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
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
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
Mikhail Fludkov
90104809b0 Surround initialisations with atomic critical section
Fixes the race condition when one thread uses cairo_mask_compositor_t
pointer returned by _cairo_image_mask_compositor_get, while another one
started but has not finished it's initialisation yet

Usage:
static cairo_atomic_once_t once = CAIRO_ATOMIC_ONCE_INIT;
if (_cairo_atomic_init_once_enter(&once)) {
    /* Initialization code */
    _cairo_atomic_init_once_leave(&once);
}

https://bugs.freedesktop.org/show_bug.cgi?id=103037
2017-10-15 18:51:04 +10:30
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
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
Uli Schlachter
31eff5c6eb Correct usage of CAIRO_STACK_ARRAY_LENGTH
This macro wants the array type as its argument and calls sizeof() on it
internally.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-11-16 19:05:35 +01:00
Chris Wilson
054f34111d Provide backwards compatibilty with old pixman
The goal is to allow compilation against older pixman to ease regression
testing.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-08-23 12:53:27 +01:00
Chris Wilson
2d7ac9e737 xlib: Only apply the dst offset to the glyph strings once
The elts offset is a delta from the previous glyph coordinate. So by
subtracting the dst origin everytime, we were accumulating a glyph
position error. Instead we just want to offset the starting coordinate
and then always use relative positions.

Reported-by: Theo Veenker <T.J.G.Veenker@uu.nl>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-02-08 15:20:41 +00:00
Chris Wilson
41ae904461 xlib/shm: Appease the compiler for a 'maybe used uninitialised' variable
Initialise shm during its declaration so that it is indeed initialised
for the cleanup after every path.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-01-29 03:52:02 +00:00
Chris Wilson
9b92625151 xlib/shm: Simplify uploading of SHM image data
Make sure that we simply copy from the SHM segment into the target
drawable, and not inadvertently stage it through another SHM buffer.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-01-29 03:51:01 +00:00
Chris Wilson
30e9505151 xlib/shm: Skip creating new SHM segments if the data is already in the xserver
If the image is already inside a SHM segment, but the image format does
not match the surface, fallback to the XRender paths in order to perform
colorspace conversion on the data already inside the Xserver.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-01-29 02:49:26 +00:00
Chris Wilson
1d1af825bb xlib/shm: Tighten mark-active to the actual CopyArea on the ShmPixmap
Along the draw_image_boxes() upload path, we were actually marking the
ShmPixmap as still active for the subsequent drawing operation - which
could in theory never be submitted...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-01-29 02:47:48 +00:00
Chris Wilson
7012334ebb xlib: Handle lack of XRenderFillRectangles
Remember to check for a supported render version before making a
FillRectangle request, and fallback to the core protocol where possible
instead.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-01-13 18:37:08 +00:00
Chris Wilson
503b6b9e2e xlib: Only fallback through the mask intermediate if we can composite the mask
Before rendering into the mask, we should first check whether the
subsequent call to composite the mask will trigger a fallback. In that
case, we should fallback earlier and do the operation in place.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-01-11 13:18:26 +00:00
Chris Wilson
0c84a5474d xlib/shm: Rate-limit events and only use as necessary
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-12-29 14:55:17 +00:00
Behdad Esfahbod
867c876b0e [Minor] Improve logging 2012-12-21 18:46:56 -05:00
Chris Wilson
66625cb46c xlib: Apply the image offsets to the destination rather the source
So that we can specify the entire source surface as the region to copy
and not introduce clipping errors.

Fixes regression from
commit c068691ff5
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri Aug 17 21:33:54 2012 +0100

    xlib/shm: Use an impromptu upload ShmSegment

Reported-by: John Lindgren <john.lindgren@aol.com>
Reported-by: Kalev Lember <kalevlember@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=56547
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-10-30 12:40:41 +00:00
Chris Wilson
b3448c3dff xlib: Drop the false optimisation of using a potentially busy shm upload pixmap
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-08-18 09:28:37 +01:00
Chris Wilson
3da2d8a1e2 xlib: Only use CopyArea if the ShmPixmap and destination are the same depth
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-08-18 00:06:06 +01:00
Chris Wilson
c068691ff5 xlib/shm: Use an impromptu upload ShmSegment
Reduce the number of copies required for uploading large image data.
Ultimately we want the client to allocate the similar-image itself to
acheive zero copy, this is just an intermediate step for legacy clients.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-08-17 23:43:26 +01:00
Chris Wilson
bc38108947 xlib/shm: Limit use of the impromptu fallback pixmap for uploads
We want to avoid unnecessary readback and so only want to use the
ShmPixmap when uploading the complete surface.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-08-17 23:20:01 +01:00
Chris Wilson
0bfd2acd35 xlib: Implement SHM fallbacks and fast upload paths
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-08-17 13:58:09 +01:00
Chris Wilson
57cfdfd979 Split cairo-list into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 13:17:29 +01:00
Chris Wilson
3454604459 xlib: Apply the glyph offset
The (dst_x, dst_y) parameters passed to the XRenderCompositeText are
misleading and do not perform any adjustment, so we have to do it
ourselves.

Fixes clip-operator

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-06 21:13:20 +00:00
Chris Wilson
b079f18fad xlib: Handle window-to-window copies by avoiding the use of a clip region
Rather than compress the copies into a clip + copy, iterate over and
perform each copy separately so as to avoid the confusion for
window-to-window copies and the solitary GC->pCompositeClip.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-23 13:44:28 +00:00
Chris Wilson
605f23d155 xlib: Hook up copy_boxes for the mask compositor
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-22 11:27:05 +00:00
Chris Wilson
b454db4b13 xlib: Set IncludeInferiors when using CopyArea
cairo-xlib semantics state that we copy the contents of a Window's
children when we use a Window as a source in a cairo operation. This
requires that we set the IncludeInferiors SubwindowMode on the GC.
However, we can only set one SubwindowMode for an operation and our
semantics are that drawing performed by cairo onto a Window are clipped
by its children (the ClipByChildren SubwindowMode). Therefore if we have
to copy between two Window, we can not use CopyArea. Furthermore, we
cannot tell if an external Drawable is a Window or a Pixmap, therefore
we treat all foriegn Drawables as Window.

Failure here means falling back to a render path, where we can
independently control the subwindow mode on the source and destination,
or to a GetImage/PutImage if the xserver does not support render.

Reported-by: Benjamin Otte <otte@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-02 01:14:16 +00:00
Keith Packard
950021f881 Clip rectangles are not necessarily YSorted
None of the cairo clipping computations guarantee that the resulting
list of rectangles are constructed in any particular order. Promising
that they are results in an X error (BadMatch) which generally causes
applications to crash.

I suspect this may well be implicated in many (many) bug reports about
applications which use cairo.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-06 18:06:28 +00:00
Chris Wilson
2c4f6bbfbc gl: Prevent the traps compositor from exploding
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-11-24 10:16:22 +00:00
Chris Wilson
e217677ce6 xlib: ADD only reduces to SOURCE for alpha-only targets
Fixes operator.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-11-23 14:57:35 +00:00
Chris Wilson
10ebda8698 xlib: Reduce the composite traps operator for when the dest is clear
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-10-14 13:23:02 +01:00
Uli Schlachter
e3131242b2 xlib-xcb: Make this compile again
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-09-14 15:50:19 +02:00
Chris Wilson
af9fbd176b Introduce a new compositor architecture
Having spent the last dev cycle looking at how we could specialize the
compositors for various backends, we once again look for the
commonalities in order to reduce the duplication. In part this is
motivated by the idea that spans is a good interface for both the
existent GL backend and pixman, and so they deserve a dedicated
compositor. xcb/xlib target an identical rendering system and so they
should be using the same compositor, and it should be possible to run
that same compositor locally against pixman to generate reference tests.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

P.S. This brings massive upheaval (read breakage) I've tried delaying in
order to fix as many things as possible but now this one patch does far,
far, far too much. Apologies in advance for breaking your favourite
backend, but trust me in that the end result will be much better. :)
2011-09-12 08:29:48 +01:00