Commit graph

7347 commits

Author SHA1 Message Date
Bryce Harrington
1af18610ba glesv2: Fix regression in gles version detection
Revert the _cairo_gl_get_flavor() portion of the change from commit
eb523200.  This caused GLES to be enabled only if the hardware reported
version 2 exactly; if the hardware supported version 2 and 3 then no ES
support would be enabled.
2017-09-11 19:56:06 -07:00
Adrian Johnson
c29db4f0de Remove unused variable 2017-09-02 16:11:43 +09:30
Adrian Johnson
609261bcbc pdf: use explicit dest instead of named dest when 'internal' attribute is set 2017-08-29 21:43:07 +09:30
Adrian Johnson
12b875aef3 pdf: use link attributes instead of dest name for cairo_pdf_surface_add_outline
In PDF outline targets are specified the same way as link targets so
there is no need to restrict the target to dest names.
2017-08-26 16:32:48 +09:30
Adrian Johnson
df37baf789 pdf: fix link positions
Converting the link position from cairo to pdf coordinates requires
the page height. Since the link may point to a different page, build
an array of the height of each page and use the target page height for
the conversion.

Don't default to a [0,0] position if "pos" is not specified. PDF
allows a null destination position to be specified which means don't
change the position if the page is already displayed or show top left
if switching to a different page. This is more useful default
particularly for external files where the coordinates (which must be
in PDF coordinates as we don't know the page height) of the top left
corner may not be known.
2017-08-26 16:26:12 +09:30
Adrian Johnson
74c6e3ae1d pdf: don't write logical structure if it only contains links 2017-08-22 21:25:22 +09:30
Doran Moppert
63f14d4a8f image: Check for negative len in fill/blit functions
Applies the same fix as 5c82d91 to other potential negative len cases.

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2017-08-21 17:08:47 -07:00
Alexander Täschner
5f90f0a706 win32: Initialize mutexes for static builds for win32
For static win32 builds the mutexes are not initialized (for dynamic
builds it's done when the DLL is loaded). Therefore, add initialization
to the create surface calls.

Cc: Uli Schlachter <psychon@znc.in>
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2017-08-21 16:35:27 -07:00
Guillermo Rodriguez
339fe9a768 Remove redundant check.
Spotted by David Kastrup <dak@gnu.org>.

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2017-08-21 16:29:10 -07:00
Bryce Harrington
a5ac8fe203 image: Disambiguate 0. in doxygen
Doxygen is interpreting the leading 0. as starting an ordered list, and
misformatting the HTML documentation.

Issue reported by Артур Галямов.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2017-08-21 14:39:24 -07:00
Adrian Johnson
4c12e2aec3 pdf: Don't emit /PageLabel dict when no labels defined 2017-08-21 21:23:45 +09:30
Adrian Johnson
e3857c133f pdf: link tags do not need to be leaf nodes in the document structure 2017-08-20 20:09:02 +09:30
Behdad Esfahbod
f3515954e0 [ft] Fix color font loading on big-endian systems
Untested, but the logic is correct: FreeType's BGRA type is always
laid out in that order in memory.  Cairo's ARGB32 is endianness-
dependent.  On little-endian systems the two are the same.  On big-endian
we need to flip.
2017-08-08 22:04:55 -07:00
Behdad Esfahbod
495cb9a0a7 Fix uninitialized status! 2017-07-29 17:40:34 +01:00
Behdad Esfahbod
7a1e378466 Fix color font support infinite-loop with empty glyphs
Ouch! But it all works now! Only took five years to merge this feature.
Thanks Matthias Clasen for working out a real patch from my initial
sketch.
2017-07-29 16:20:21 +01:00
Matthias Clasen
5e3350e4d1 Simplify things a bit
Do away with the separate check for color glyphs - we can just
do the filtering, and if there are no color glyphs, it is a
no-op. As long as we only do this for fonts with color glyphs,
it should be fine.

Reduce repetition in composite_color_glyphs by breaking out
some helper functions.
2017-07-29 12:30:50 +01:00
Matthias Clasen
db14d6d707 Render color glyphs as source, not as mask
Use paint instead of show_glyphs for color glyphs. To avoid
overhead, we only check for color glyphs if the font is known
to contain any. Paint clusters containing only color glyphs
and rewrite the inputs to remove the handled clusters and
glyphs.
2017-07-29 12:30:50 +01:00
Matthias Clasen
6a8a25cc47 Implement has_color_glyphs for freetype
This information is available from the FT_Face using the
FT_HAS_COLOR macro. We cache the value in the unscaled_font
object as soon as we have an FT_Face.
2017-07-29 12:30:50 +01:00
Matthias Clasen
6622845653 Expose 'has color glyphs' as a scaled font property
This information will be used in subsequent commits to quickly
decide that we won't try to handle glpyhs as masks. Implementing
the new has_color_glyphs vfunc is optional - only backends that
support color glyphs need to implement it.
2017-07-29 12:30:50 +01:00
Matthias Clasen
52b17c7242 Support loading color glyphs with freetype
Use the FT_LOAD_COLOR flag to instruct freetype to load embedded
PNGs without converting them to grayscale. We always load both
the color and regular surface when we are loading surfaces.
2017-07-29 12:30:50 +01:00
Matthias Clasen
0d8859c66f Add support for color glyphs to cairo_scaled_glyph_t
With this, glyphs can have either a surface that is expected
to be used as mask, or a color_surface that should be used
as source, or both.

This will be used to support colored emoji glyphs that are
stored as PNG images in OpenType fonts.
2017-07-29 12:30:50 +01:00
Adrian Johnson
57b40507dd Fix off by one check in cairo-image-info.c
https://bugs.freedesktop.org/show_bug.cgi?id=101427
2017-06-15 20:53:29 +09:30
Bryce Harrington
ce68336f7d drm: Add/reorder headers as required by check-preprocessor-syntax.sh
If cairo-drm-intel-brw-eu.h and/or cairo-drm-intel-brw-structs.h are
intended to be private headers, then the change to include cairo.h can
be dropped but the headers should be renamed *-private.h to conform with
Cairo standards.

I'm not certain why check-preprocessor-syntax.sh started flagging these
issues, as it doesn't look like there's been changes to them recently.
But the release scripts won't move forward without these being fixed.
2017-06-13 14:57:38 -07:00
Bryce Harrington
f613e07172 gl: Fix comment syntax
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2017-06-12 18:55:35 -07:00
Uli Schlachter
bfc243ca52 xcb: Fix error reporting if fallback fails
If we cannot let the X11 server do some operation (for example: the
RENDER extension is not available), then we fall back to an image
surface and do the operation locally instead. This fallback requires the
current content of the surface to be downloaded from the X11 server.
This fallback logic had an error.

The fallback is implemented with _get_image() in the function
_cairo_xcb_surface_fallback(). _get_image() is only called if we do not
yet have a fallback available, so when we call _get_image we have
surface->fallback == NULL. Then, if _get_image() fails, it returns a
surface in an error state.

Before this patch, the code would then just ignore this error surface
and return &surface->fallback->base, a NULL pointer. This would then
quickly cause a crash when e.g. the surface's ->status member is
accessed.

Fix this by returning the error surface instead as the fallback.

The end result of this patch will be that the XCB surface that is
currently drawn to ends up in an error state which is a lot better than
a NULL pointer dereference and actually correct in this case. The error
state is reached because the current drawing operation will fail and
this error is reported up the call stack and eventually "taints" the
surface.

(However, the error code could be better: _get_image() too often fails
with a generic CAIRO_STATUS_NO_MEMORY error, but that's left as future
work)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-05-30 18:04:38 +02:00
Adrian Johnson
0fd0fd0ae9 subsetting: support variable fonts
If the font is a non default variant, fallback to creating a font from
the outlines.
2017-05-28 09:12:56 +09:30
Uli Schlachter
9d44136ef8 Revert "stroker: Check for scaling overflow in computing half line widths"
This reverts commit 91b25005d6 because it
causes lots of new crashes due to assertion failures.
2017-05-13 09:37:34 +02:00
Chris Wilson
91b25005d6 stroker: Check for scaling overflow in computing half line widths
Given a combination of a large scaling matrix and a large line, we can
easily generate a half line width that is unrepresentable in our 24.8
fixed-point. This leads to spurious errors later, such as generating
negative height boxes, and so asking pixman to fill to infinity. To
avoid this, we can check for overflow in calculating the half line with,
though we still lack adequate range checking on the final stroke path.

References: https://bugs.webkit.org/show_bug.cgi?id=16793
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: magomez@igalia.com
Tested-by: Bryce Harrington <bryce@osg.samsung.com>
Acked-by: Bryce Harrington <bryce@osg.samsung.com>
2017-05-04 17:44:48 -07:00
Andrea Canciani
a3cc46d2cc quartz-font: Fix text-glyph-range
The index 0 is a legitimate index used for character codes that do not
correspond to any glyph in the font.  Instead, the API reserves 0xFFFF
(kCGFontIndexInvalid) as the invalid index and defines 0xFFFE
(kCGFontIndexMax = kCGGlyphMax) as the maximum legal index.

Fixes text-glyph-range.
2017-04-25 18:06:14 +02:00
Andrea Canciani
fcb0a8ef36 quartz-font: Correct handling of SMP Unicode characters
Truncating the UCS4 representation to 16 bits only works for the Basic
Multilingual Plane, the other characters must be translated to a
surrogate pair.

Fixes smp-glyph.

Reported-by: Clerk Ma <clerkma@gmail.com>
2017-04-25 18:06:14 +02:00
Andrea Canciani
5584bf755c unicode: Extract the UCS4 to UTF-16 conversion to a separate function
Reuse the function for the UTF-8 to UTF-16 conversion, but also make
it available for internal use by cairo.
2017-04-25 18:05:40 +02:00
Enrico Weigelt, metux IT consult
8455d88b12 drm: fixed calls to _cairo_surface_init()
This function now expects an additional parameter is_vector.

Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt@gr13.net>
2017-04-24 18:35:44 -07:00
Enrico Weigelt, metux IT consult
f7e686c92a drm: use typedefs and defines from drm headers instead of redundant own definitions
These typedefs and defines are part of the libdrm API and therefore should
be taken from there, instead of own redundant declarations.

Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt@gr13.net>
2017-04-24 15:54:02 -07:00
Enrico Weigelt, metux IT consult
72c600afbf drm: dropped obsolete/unused intel_bo_get_image()
[Call to this was dropped in bd672d08 in favor of intel_bo_map()]]

Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt@gr13.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2017-04-24 15:42:35 -07:00
Enrico Weigelt, metux IT consult
182104defe drm: fixed missing includes
Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt@gr13.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2017-04-24 10:18:08 -07:00
Debarshi Ray
cffa452f44 doc: Clarify when the device scale is inherited and when it isn't
In short, cairo_surface_create_similar inherits it, while
cairo_surface_create_similar_image doesn't. It wasn't obvious without
reading the code or explicitly checking the device scale of the new
surface.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=99094

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2017-03-15 20:26:22 -07:00
Debarshi Ray
1192f97388 doc: Fix the units used by cairo_surface_create_similar_image
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=99094

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2017-03-15 20:26:18 -07:00
Uli Schlachter
10e4103a50 xlib: Call XSync() before ignoring errors
The code here wants to ignore errors for a specific request. To do so,
it sets a no-op error handler. However, it could happen that some
previous request caused an error and this error will also be ignored by
the no-op error handler.

To avoid this, call XSync() before setting the error handler. This makes
sure that all pending errors are handled.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-03-07 13:40:21 +01:00
Uli Schlachter
f02ee3d3cf xlib: Remove unused variable
This constant seems to be unused since commit af9fbd176b
from 2011.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-03-07 09:57:55 +01:00
Adrian Johnson
1a307123af pdf-operators: fix bug in line wrapping
patch by jmmorlan@sonic.net

https://bugs.freedesktop.org/show_bug.cgi?id=100029
2017-03-02 19:14:04 +10:30
Adrian Johnson
5854dd9df4 pdf: don't return uninitialized status
https://bugs.freedesktop.org/show_bug.cgi?id=99630
2017-02-02 06:47:11 +10:30
Andrea Canciani
5a8a9c97ed quartz: Restore 10.4-specific font code
The code for extracting font glyphs was replaced in
70cc8f250b with an implementation based
on CoreText, which is not available on MacOSX 10.4.  This commit
restores automatic detection of which API should be used by means of
dynamic linking.
2017-01-18 15:06:33 +01:00
Kouhei Sutou
dd4706d0a9 pdf: Fix wrong cairo_pdf_outline_flags_t item prefix 2017-01-05 08:33:07 +10:30
Kouhei Sutou
c7e87cd9df pdf: Remove duplicated item 2017-01-05 08:30:52 +10:30
Bryce Harrington
3f1a6f7225 gl: Fix one more CAIRO_GL_FLAVOR_ES3 enum 2016-11-03 09:16:24 -07:00
Bryce Harrington
eb5232002b gl: Treat GLES v2 as a separate flavor from GLES v3
To support differentiating between GLES v2 and v3, rename the flavor
enum to be version specific, as CAIRO_GL_FLAVOR_ES2.

Then, when GLES v3 support is introduced we can add it as a distinct
flavor enum (i.e. CAIRO_GL_FLAVOR_ES3).

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2016-10-28 17:56:09 -07:00
Bryce Harrington
b7b6803567 pattern: Fix incorrect grammar in cairo_pattern_get_type.
"This function returns the type a pattern." is obviously missing 'of',
but this can be stated more succinctly with active voice.

Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
2016-10-10 14:39:23 -07:00
Bryce Harrington
9d2983175e Fix grammar in cairo_*_reference() function documentation.
"can be get" is incorrect grammar; "can be gotten" would be better, but
active voice is best.

Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
2016-10-10 14:39:19 -07:00
Adrian Johnson
4790a3663d strndup is not avuilable with MSVC 2016-10-07 07:38:37 +10:30
Adrian Johnson
55f8c6d9f4 fix compiler warnings 2016-10-04 12:00:30 +10:30