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
The combination of both curved strokes and ignoring the ctm in the thin
line check caused some fill-strokes in this test case to be culled.
Modify the thin line check to take the ctm into account and increase
the minimum width to 1 point to prevent curved lines such as tiny dots
from being culled.
https://bugs.freedesktop.org/show_bug.cgi?id=103071
- move num_glyphs_in_face to base struct as it is the number in the font
- move num_glyphs to the subset variables as it is the num glyphs in the subset
- move widths to subset variables as it uses the subset id as the array index
Subset array sizes are allocated based on the number of glyphs in the
font. In this bug the fonts did not contain the mandatory .notdef
glyph, hence the subset arrays were not large enough.
https://bugs.freedesktop.org/show_bug.cgi?id=102922
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>
The GLESv2 backend supports only GL_RGBA and GL_ALPHA as supported
texture formats. So, make _cairo_gl_get_image_format_and_type_gles2
force conversion of other image formats to either of these two as
appropriate when uploading images.
Patch originally from Henry Song <henry.song@samsung.com>
Bryce Harrington <bryce@osg.samsung.com>
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
In cairo, most operators are composited this way:
((src IN mask) OP dst) LERP_clip dst
but SOURCE and CLEAR operators are composited this way:
(src OP dst) LERP_(clip IN mask) dst
(why is this not specified anywhere in the docs or source tree?)
With color glyphs, we were not special-casing SOURCE and CLEAR.
We do now.
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=102661
As reported to me:
"A calculation on signed integers has undefined behaviour if the result is not
representable in the type. In this case, it's trying to negate int_min, aka
-2^31 but the range of an int is [-2^31, 2^31-1] so it doesn't fit. Instead,
cast to unsigned which has 2's complement wrap-around arithmetic which is what
this particular function expects."
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.
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.
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>
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>
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.
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.
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.
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.
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.
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.
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.
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.
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>
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>
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.