Commit graph

41 commits

Author SHA1 Message Date
Bryce Harrington
85fe4deee4 gl: Whitespace cleanup 2018-05-29 12:15:47 -07: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
Bryce Harrington
8ff3019f51 gl: Add support for OpenGL ES 3.0
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>
2017-09-13 15:18:04 -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
Adrian Johnson
481e5986f9 Compile fix 2015-10-17 22:46:23 +10:30
Martin Robinson
1704292e49 gl: Fix compiler warnings in the GL backend 2013-05-07 12:01:17 -07:00
Martin Robinson
400ea9c290 gl/msaa: Properly fall back when using CLEAR operator
There are some situations that the MSAA compositor doesn't support using
the CLEAR operator. We should properly fall back in those cases.
2013-02-06 12:53:14 -08:00
Chris Wilson
05ad89f912 gl: Replace manual vertex transformation with VS computation of texcoords
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>
2013-02-04 09:57:53 +00:00
Martin Robinson
cfe0e59663 gl/msaa: Add a fast path for fills that are simple quads
Instead of invoking Bentley-Ottman for fills that are simple
quadrilaterals, just pass the geometry straight to OpenGL.
2013-01-25 16:30:11 -08:00
Henry Song
bb40720460 gl/msaa: Fix a memory leak in _clip_to_traps
We need to clean up the polygon we create when decomposing a path into
trapezoids.
2013-01-25 11:55:10 -08:00
Martin Robinson
1bcd59ef4c gl/msaa: Rely on the stencil buffer to cache the clip
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.
2013-01-09 14:33:41 -08:00
Martin Robinson
d524697ede gl/msaa: No need to set the clip when masking
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.
2013-01-09 14:33:41 -08:00
Henry Song
9dde964553 gl/msaa: Only clear parts of the stencil buffer we will use
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.
2013-01-03 16:37:18 -08:00
Alejandro G. Castro
5e9083f882 gl/msaa: Avoid the stencil buffer when possible during masking
In this case we can draw the clip path and avoid the stencil buffer,
which can be expensive.
2013-01-03 16:37:18 -08:00
Henry Song
dd850583a7 gl/msaa: Add full support for masking with the SOURCE operator
Since OpenGL does not have a means to represent a masking SOURCE
operation in one step, we use two steps combined with the ADD
operator.
2013-01-03 15:58:19 -08:00
Martin Robinson
21db1c9910 gl: Cleanup selection of multisampling mode
Fold the choice of multisampling mode into the cairo_gl_composite_t
structure itself. This makes it more similar to other settings.
2012-12-28 14:29:24 -08:00
Martin Robinson
ced090871b gl/msaa: Improve fallback detection
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."
2012-05-17 14:52:10 -07:00
Martin Robinson
707bb86639 gl/msaa: Lazily flush the context
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.
2012-05-17 14:21:25 -07:00
Martin Robinson
4b3ad4e8da gl/msaa: Implement glyph rendering
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.
2012-05-17 14:02:18 -07:00
Martin Robinson
e3f5b14fba gl/msaa: Wait to clip until compositing begins
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.
2012-05-17 13:56:38 -07:00
Martin Robinson
29b243325c gl/msaa: Support for non-texture surfaces
Add full support for non-texture surfaces, by correctly
querying primitives for stencil and multisample bits.
2012-05-17 13:13:40 -07:00
Henry (Yu) Song
9208dd6230 gl/msaa: Support the OpenGLES EXT multisampling extension
Add support for OpenGLES GPUs that support the EXT multisampling
extension.
2012-05-17 13:08:46 -07:00
Henry (Yu) Song
5ae53c933a gl/msaa: Implement paint via masking
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.
2012-05-17 11:22:25 -07:00
Henry (Yu) Song
4d9064d578 gl/msaa: Add ARB multisampling support
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.
2012-05-17 11:06:47 -07:00
Henry (Yu) Song
3e02dccb97 gl/msaa: Add support for unbounded operators
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.
2012-05-08 12:48:30 -07:00
Henry (Yu) Song
b099f8b0c7 gl/msaa: Support for masking
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.
2012-05-08 12:13:42 -07:00
Henry (Yu) Song
929a96ed03 gl/msaa: Support for texture sources
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.
2012-05-08 11:42:29 -07:00
Henry (Yu) Song
a60bb83f28 gl/msaa: Prevent stroke overlap
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.
2012-05-08 11:06:31 -07:00
Chris Wilson
99f3fea6d9 gl: Uses the inline clip function, so update its include
Fixes build from 0770dda52b.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 17:53:11 +01:00
Chris Wilson
a49a26f961 gl: Various fixes for glyphs
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>
2012-02-29 10:27:39 +00:00
Martin Robinson
b845a191d5 gl/msaa: Scissor simple rectangular clips
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]
2011-12-16 09:51:40 +00:00
Martin Robinson
bbe692372d gl/msaa: Ignore the antialiasing property of the clip.
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>
2011-12-15 19:29:17 +00:00
Martin Robinson
b98c8c1269 gl/msaa: If stenciling the clip fails, reset the color mask.
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>
2011-12-15 19:22:17 +00:00
Chris Wilson
5613b210ff gl: Defer stencil allocation until use
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>
2011-12-07 10:22:25 +00:00
Chris Wilson
5edb3a29b9 gl: Fallback for complex subsurfaces
In the process we need to supply the sampled area and operation extents
into the operands.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-11-24 10:16:22 +00:00
Martin Robinson
c94c3eede0 gl/msaa: Fix scissor bounds
Scissor bounds should depend on both the height and y coordinate
of the bounding box. Also remove _cairo_gl_y_flip() since we were
the last caller.
2011-11-23 20:49:16 +00:00
Martin Robinson
3813066f13 gl/msaa: Fix glScissor bounds
When scissoring the compositing extents for windows, flip
the y coordinate as windows use a projection matrix that
does the same.
2011-10-15 09:05:19 +01:00
Martin Robinson
c25027f2a1 gl/msaa: Support for solid color strokes.
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.
2011-10-13 14:42:23 +01:00
Martin Robinson
32aa361c5e gl/msaa: Add clipping support
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).
2011-10-13 14:42:23 +01:00
Martin Robinson
13d9d07ccd gl/msaa: Implement basic solid color fill
Introduce the very basic functionality of an MSAA compositor
for OpenGL. For this first patch only solid fills are supported.
2011-10-13 14:42:15 +01:00
Martin Robinson
9f85eb52d8 gl/msaa: Introduce an MSAA compositor for OpenGL
The MSAA compositor will composite OpenGL primitives directly and
anti-alias via the GPU.
2011-10-13 14:42:09 +01:00