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
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>
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>
Not only is our point transformation code is quite slow (well at least
compared to a real GPU), but by deriving the texture coordinates from
the vertex position we can elide the multiple arrays that we need to
construct and pass to GL - improving performance by eliminating CPU
overhead from needless transforms and data shovelling.
However, not all vertex emission is suitable. For instance, for glyphs
we need to emit discontiguous texture coordinates for each glyph, but
span generation is suitable - which fortuitously also has the largest
vertex density and so benefits the most.
The only real concern is for hardware without true vertex shader support
(e.g. i915) but there we are already invoking the VS to transform the
vertex into the viewport. We would need to eliminate that transform as
well as manually compute the texture coordinates in order to eliminate
the vertex recomputation pass.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
When using a texture surface the depth/stencil buffer is private to
cairo so we can rely on the fact that any previously painted clip is
still valid.
We also only scissor when there's a previously painted clip on the
stencil buffer, otherwise we disable the scissor test. This fixes a few
test cases.
After 5e9083f882 there's no need to set a
clip on the cairo_gl_composite_t when masking. Clips are converted to
traps and rendered directly when masking now.
Writing to the stencil buffer can be expensive, so when using the
stencil buffer for clipping only clear the clip extent. When using the
stencil buffer to prevent overlapping rendering during stroking, only
clear the approximate stroke extents.
Rename should_fall_back to can_use_msaa_compositor to make it
more comprehensible and also modify the logic to fall back
when the antialias mode is not "fast" or "default."
Instead of conservatively flushing after every single drawing
operation. Wait until we are certain we need to flush, which
in the case of the MSAA compositor is when we start compositing
with a different type of geometry.
Instead of falling back to the traps compositor to do glyph
rendering, handle it in the MSAA compositor. This allows using
the stencil buffer or scissor to clip and simplifies the MSAA
code path.
The MSAA compositors clips in a unique way We'd like to
share this method with the text rendering path, so we move
it to cairo-gl-composite so that it works in a way very
similar to clipping with the spans and traps compositors.
Instead of falling back to the spans compositor, let the msaa
compositor handle painting. This ensure clipping is handled
in a consistent way with the rest of the msaa compositor.
This implementation is not very efficient at the moment and does not
work with platforms using the incompatible IMG extension (mobile
GPUs). Performance improvements and mobile GPU support will follow.
When filling and stroking with an unbounded operator, first fill
and stroke to a temporary surface and then paint the entire surface
back to the original target.
Add support for masking in the OpenGL MSAA compositor. This is
accomplished simply by properly setting up the masking source,
emitting the entire bounded composite region, and unforking
vertex emission.
Add support for texture sources, by unforking _cairo_gl_composite_begin.
_cairo_gl_composite_begin_tristrip is now just a small wrapper. Also
properly emit the source texture coordinates when emitting tristrip
vertices.
When stroking we do not send our polygon to the tessellator, so
it may have overlapping stroke components. Use the stencil buffer
to prevent stroke components from overlapping.
Not 100% improvement, there are still a variety of failures with
GLXWindows, but getting there. At least it fixes more things than its
breaks...
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Instead of using the stencil buffer to perform simple
rectangular clips, just scissor the clip rectangle.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
[ickle: fixed application to master]
If the clip suggests anti-aliasing and we don't support it,
draw the clip anyway. Currently disabling anti-aliasing does
not disable anti-aliasing on certain clips.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
If the clip failed, not resetting the color mask leaves the GL context
in a state in which we cannot draw anything.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Allocating a stencil and a depth buffer for every destination surface is
simply too expensive and causes major resource issues. So defer the
allocation and attachment of a stencil buffer until just prior to first
use.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Add support for basic solid color strokes using the fixed path
stroke shaper. Currently components of the stroke overlap, but
that will be handled in the following patch.
Adds basic clipping to the OpenGL MSAA compositor via the
depth and stencil buffers. Stenciling and depth bits are
stored in a renderbuffer.
Note that we only attach renderbuffers to surfaces created by ourselves
and not for foreign drawables (e.g. X Windows).