Commit graph

282 commits

Author SHA1 Message Date
luz.paz
6d93bddbd6 Misc. typos
Found via `codespell -i 3 -w -I ../cairo-word-whitelist.txt -L tim,ned,uint`
Follow up of 12cb59be7d

Reviewed-by: Bryce Harrington <bryce@bryceharrington.org>
2019-01-31 17:37:15 -08:00
Bryce Harrington
85fe4deee4 gl: Whitespace cleanup 2018-05-29 12:15: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
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
4b164bc898 gl: Convert images to rgba or a8 formats when uploading with GLESv2
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>
2017-09-13 15:17:55 -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
aa1323f04c Fix some surfaces missed in b1192bea 2015-10-17 22:02:11 +10:30
Bryce Harrington
7b50883577 gl: Handle PIXMAN_a8r8g8b8_sRGB format in switch
Fixes the following compiler warning:

  cairo-gl-surface.c:182:5: warning: enumeration value
  ‘PIXMAN_a8r8g8b8_sRGB’ not handled in switch

Same fix as done for image in 1d0055078.

Chris Wilson <chris@chris-wilson.co.uk>
2014-02-25 12:14:36 -08:00
Martin Robinson
7270f22af3 gl: Extend oversize check to cairo_gl_surface_create_for_texture
If a texture is too large to render to via a framebuffer, then eagerly
fail with an error surface.
2013-09-11 08:52:31 -07:00
Martin Robinson
95f320e3f2 gl: Return surface in error when creating oversized texture surfaces
When creating a texture surface that is larger than the maximum
framebuffer or texture dimensions of the context, return a surface in
error. Previously the code failed an assertion, but this prevents an
application from easily detecting when to fall back.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-08-19 14:54:28 -07:00
Henry Song
b5e1373c58 gl/msaa: Clean up msaa depth/stencil buffer for OpenGLES
OpenGLES also uses the depth/stencil buffer when doing multisampling, so
it's a leak to only clean up the buffer for desktop OpenGL.
2013-08-19 12:56:58 -07:00
Henry Song
be2c09a1f5 gl/msaa: Properly destroy stencil buffer clip cache
When replacing the stencil buffer clip cache or destroying a surface,
destroy the cached clip. This prevents the clip from leaking.
2013-07-15 19:27:19 -07:00
Martin Robinson
8da704ca7c gl: Separate framebuffer bind from destination selection
Disentangle the action of binding the framebuffer from setting the
destination. This straightens up the code a bit and avoids some redundant
operations (such as reacquiring the context) when simply switching from
the multi-sample framebuffer to the single-sample framebuffer and vice
versa.
2013-04-26 15:03:46 -07:00
Henry Song
498421bec9 gl/msaa: Resolve multisampling on surface flush
When flushing a surface, we must resolve multisampling for desktop GL.
This allows use of the original surface texture in any following raw GL
operations. This fixes accelerated canvas with WebKitGTK+ using the MSAA
compositor.
2013-04-17 10:27:58 -07:00
Henry Song
4cb181d985 gl: do not force flush everytime uploading a glyph image to glyph cache
In normal cases, we want to flush pending operations reading from the
texture before modifying its contents.  However during uploading of
glyphs into the glyph cache, we repeatedly modify the texture as we
construct the vbo (whilst referencing it for that operation). We track
unused areas in the glyph cache so that if we run out of space, we can
explicitly flush the pending glyphs and start afresh and avoid having to
flush the operation in common case.
2013-02-04 10:49:37 +00:00
Henry Song
1e3424cfd1 gl: Use GL_ALPHA textures for CAIRO_CONTENT_ALPHA glyph caching
It's safe to us GL_ALPHA for glyph caching surfaces, since Cairo only
uses them for texture uploading. This saves a little bit of memory.
2013-01-25 14:09:18 -08:00
Martin Robinson
9194904fa8 gl: Better handling of clear surfaces
When clearing a GL surface, set is_clear to true, and when mapping to an
image, handle is_clear like surfaces without modification. Additionally,
explicitly clear surfaces created via cairo_surface_create_similar.
2013-01-04 16:31:01 -08:00
Chris Wilson
127dd46669 gl: Use vfunc for vertex emission
In order to overload the emitters in future to provide specialised
routines for the common types of operands, begin by switching the
current users over to a vfunc interface.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-12-30 12:21:11 +00:00
Martin Robinson
433a5829d7 Revert "gl/msaa: Share the depth/stencil buffer among all surfaces"
This was pushed mistakenly. Sorry.

This reverts commit a7d684e6fe.
2012-12-17 17:56:19 +01:00
Martin Robinson
9d9aa04b60 gl: Add BGRA download support for GLES2
Some OpenGLES2 drivers support downloading BGRA data. On little-endian
systems BGRA and GL_UNSIGNED_BYTe is equivalent to the typical
cairo_image_t format, so this can prevent CPU bit swizzling for
operations that involve images.
2012-12-10 10:18:15 +01:00
Martin Robinson
a7d684e6fe gl/msaa: Share the depth/stencil buffer among all surfaces
Instead of allocating a depth/stencil buffer for all surfaces, share a
common buffer that's the size of the largest surface. This reduces
video memory usage when there are many GL surfaces.
2012-12-08 13:31:13 +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
Dongyeon Kim
ac2668dd08 gl: Set is_clear flag to FALSE after map_to_image
In _cairo_gl_surface_map_to_image(), the image surface data has been
filled by glReadPixels, so is_clear flag should be set to FALSE.
Otherwise mapped image surface does not get drawn as it is presumed
clear and so returns true from nothing_to_do().
2012-07-12 18:14:59 +01:00
Chris Wilson
f3a1ee5edd gl: Do no access ctx after release during map-to-image
Based on a patch by Yuanhan Liu.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-05-30 11:10:34 +01:00
Andrea Canciani
d6fb8d2134 surface: Make backend-specific map/unmap functions symmetric
Map allocates a surface. Symmetrically, unmap should destroy it.
2012-05-26 16:06:31 +02:00
Andrea Canciani
df7829e2cc surface: Make map_to_image return cairo_image_surface_t*
This makes it easier to check that the funciton is returning the
correct type of surfaces.
2012-05-26 16:06:26 +02: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
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
Chris Wilson
a18506acf0 Update the remaining backends to handle a NULL extents for _cairo_surface_get_source
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-27 22:13:01 +01:00
Henry (Yu) Song
a965b0f95f gl: fix y-axis origin when map_to_image() for non texture GL surface
We need to fix y-axis origin when map a GL surface to image surface for
non-texture GL surface.

Test cases: extended-blend-alpha-mask, extended-blend-mask.
Although the image outputs is not right, but the image on the first grid
(upper-left corner) is correct comparing to image output.
2012-03-29 15:06:11 +01:00
Andrea Canciani
f0e40af05b doc: Silence last 'missing Since field' errors
Some APIs are public but not yet supported, hence they might chenge
without notice. State their "Since" status as "to be determined".
2012-03-29 11:03:19 +02:00
Igor Oliveira
2121887030 gl: GL_UNPACK_ROW_LENGTH does not accept negative values
Use the slow fallback path if passed an image with a negative stride.

Fixes negative-stride-image.
2012-03-23 16:54:22 +00:00
Chris Wilson
a3612610b1 gl: Manually invert images without MESA_pack_invert extension
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-19 10:36:08 +00: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
Chris Wilson
2061cd81f2 Replace the ad-hoc surface unwrappers with a function pointer
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-09 13:01:17 +00:00
Chris Wilson
909f4a4a7f gl: Set the destination for swap buffers, required by EGL at least
EGL mandates that the current context be valid for a call to
swapbuffers, and does not just operate upon the drawable passed in. The
current code prevents this as a side effect of calling flush decouples
the current context (so that the state can be clobbered by the
application without impacting upon Cairo). So when we try to swap, EGL
complains.

We can get the desired behaviour by setting the surface upon the
context, thus calling MakeCurrent as necessary, and then flushing any
pending operations before swapping. This has the positive side-effect
of not clobbering our own state unnecessarily.

Reported-by: Pekka Paalanen <ppaalanen@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-12 13:57:10 +00:00
Chuanbo Weng
8d4425053d gl: fix bug in _cairo_gl_surface_embedded_operand_init()
The operand->texture.surface should be set to right value, not
NULL. Otherwise, when doing _cairo_gl_surface_operand_init(),
the texture.surface in operand struct will also be NULL, which
is incorrect. This fix regression suite in 43 test cases(such
as source-clip) in cairo/test/.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-09 09:17:28 +00:00
Chris Wilson
6b472e12ae gl: Re-enable the CLEAR optimisation
It was temporarily disabled whilst the surface API was in flux.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-06 11:33:15 +00:00
Chris Wilson
dd73add00c gl: Set the device offset on map-to-image
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-05 17:17:26 +00:00
Chris Wilson
16038150b3 gl: Use the embedded operand to allow passing sources around
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-05 17:17:26 +00:00
Chris Wilson
65cd7d3beb gl: Propagate surface texture to embedded operand
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-05 17:17:26 +00:00
Chris Wilson
3edf369ead gl: Make the backend struct static
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-05 17:17:26 +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
5e4a0bd892 gl: Embed a operand into the surface for pass-through
The traps compositor expects to be able to pass either in a surface or a
source to its composite functions, so make it so.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-11-24 10:16:22 +00:00
Chris Wilson
12b8f94161 gl: Correctly offset sub-image uploads
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-11-24 10:16:22 +00: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
Chris Wilson
a6c27b500b gl: Basic fixes to get cairo-gl running again
Let there be textures!

Unbreak the setup of surface operands after my lazy convertion to the
new compositor interface. This is still only the first step, but it gets
the essentials up and running again, enough to keep me happy whilst
sitting in the airport.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-10-09 19:54:15 +01: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
Chris Wilson
e849e7c929 image: move surface definition to new header for subclassing
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-13 09:54:28 +01:00
Andrea Canciani
e04e368748 Remove useless checks for NULL before freeing
This patch has been generated by the following Coccinelle semantic patch:
// Remove useless checks for NULL before freeing
//
// free (NULL) is a no-op, so there is no need to avoid it

@@
expression E;
@@
+ free (E);
+ E = NULL;
- if (unlikely (E != NULL)) {
-   free(E);
(
-   E = NULL;
|
-   E = 0;
)
   ...
- }

@@
expression E;
@@
+ free (E);
- if (unlikely (E != NULL)) {
-   free (E);
- }
2011-07-31 16:46:36 +02:00