Commit Graph

2197 Commits

Author SHA1 Message Date
Lionel Landwerlin
28e37775c0 matrix: add missing transfer annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
59fa8b22bd index-buffer: add missing transfer annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
8dc7480002 attribute-buffer: add missing annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
de0cb3aba2 attribute-buffer: add missing transfer annotations
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
7583f5fc3f attribute: add constructor annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
7b25c8f5ca attribute: add missing transfer annotations
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
db513174f0 primitive: add missing description
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
34838553c0 primitive: add scope annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
dc5b440f07 primitive: add missing transfer annotations
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
5516235921 display: add missing transfer annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
2008493a46 renderer: add missing scope annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
c042051c01 renderer: add missing transfer annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
3ad8307ab3 context: add scope annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
d25b5f0314 context: improve constructor annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
9d2fc82077 onscreen: add scope annotations
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
6ed5a43b82 onscreen: add constructor annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
777be3895d onscreen: add missing transfer annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
6e3e14bb50 framebuffer: add missing transfer annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
95b0c4c558 bitmap: add missing annotations
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
7cc83d58a2 sub-texture: add missing transfer annotaion
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:30 +01:00
Lionel Landwerlin
7fa9b0dfdd atlas-texture: add missing transfer annontations
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:30 +01:00
Lionel Landwerlin
1cb2747ea0 texture-rectangle: add missing transfer annotations
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:30 +01:00
Lionel Landwerlin
dfa0bdc9ed texture-3d: add missing transfer annotations
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:30 +01:00
Lionel Landwerlin
c1f6ec77b5 texture-2d-sliced: add missing transfer annotations
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:30 +01:00
Lionel Landwerlin
c56e87043d texture-2d: add missing annotations
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:30 +01:00
Lionel Landwerlin
6b7c543663 pipeline: add scope annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:30 +01:00
Lionel Landwerlin
44f17fbd8d pipeline: add missing transfer annotations
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:30 +01:00
Lionel Landwerlin
b53de33521 object: use GLib's DestroyNotify if compiled with GLib
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:30 +01:00
Lionel Landwerlin
a34f4f46b6 object: add missing annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:30 +01:00
Giovanni Campagna
b635b68756 egl: don't bind the wayland display if the extension is not available
When running in a purely swrast environment (such as with
LIBGL_ALWAYS_SOFTWARE), the extension is not exposed by mesa,
but wayland is still possible with wl_shm.

https://bugzilla.gnome.org/show_bug.cgi?id=704750

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 8d4e4b0e8062708cece4d4c929abccc492ee21cc)
2013-09-16 18:57:23 +01:00
Lionel Landwerlin
f3c930ceb7 glib-source: fix argument description
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-06 18:42:10 +01:00
Lionel Landwerlin
31246d418f attribute: fix argument description
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-06 18:42:10 +01:00
Lionel Landwerlin
4e11b784f0 atlas-texture: fix argument description
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-06 18:42:10 +01:00
Lionel Landwerlin
fd03b622b0 onscreen-template: fix argument description
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-06 18:42:10 +01:00
Lionel Landwerlin
58a5251868 texture-rectangle: fix argument description
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-06 18:42:10 +01:00
Lionel Landwerlin
b38a7112d9 texture-2d-gl: fix argument description
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-06 18:42:09 +01:00
Lionel Landwerlin
015d928be5 texture-2d-sliced: fix argument description
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-06 18:42:09 +01:00
Lionel Landwerlin
cf3a12f282 pipeline: fix method description
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-06 18:42:09 +01:00
Lionel Landwerlin
9cbf1e8a08 quaternion: fix structure introspection annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-06 18:42:09 +01:00
Lionel Landwerlin
fa2f47059c cogl: add missing colon in headers
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-06 18:42:09 +01:00
Lionel Landwerlin
9080e410b2 cogl1: fix comments from cogl_clip_push_rectangle
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-06 18:42:09 +01:00
Robert Bragg
bdcd012f57 atlas-texture: use COGL_TEXTURE_DEFINE macro
It was an oversight when making the CoglAtlasTexture api public that we
continued to use the COGL_TEXTURE_INTERNAL_DEFINE macro. This updates
the code to now use COGL_TEXTURE_DEFINE which means the
cogl_is_atlas_texture() function will now be exported in the public api.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
Reviewed-by: Lionel Landwerlin <llandwerlin@gmail.com>

(cherry picked from commit ecbe209f48be80fe45b48f92b277a2aee08d5704)
2013-09-06 18:41:02 +01:00
Neil Roberts
6de83d504c Add unit test to verify that modifying uniforms doesn't create chain
The recommended usage model for rendering pipelines with minor changes
is to make a copy of a base pipeline just before rendering and then
modify that. The new pipeline can then be used as the base pipeline
for the next paint. Currently this has a known problem when modifying
uniform values in that Cogl won't prune the redundant ancestry and
instead it will end up with an ever-growing chain of pipelines. This
is particularly bad for something like CoglGST where it could also end
up leaking textures for the video frames if the pipelines are used to
render video.

The patch adds a test case for that situation so that we won't forget
about the problem. The test is maked as a known failure. Additionally
the patch adds a similar test for setting the blend constant to
constrast the test with some state that does work correctly.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 2550181543389d6e9e1cb9618d17cd352a0cf9b6)
2013-09-02 18:20:01 +01:00
Robert Bragg
8ae53cea08 auto-texture: revert _new_with_size semantics
This reverts the change in semantics for cogl_texture_new_with_size so
that it goes back to allocating textures synchronously and returning
NULL if there was a failure to allocate. Only the new/2.0 texture apis
will have the lazy allocation behaviour so we avoid breaking existing
code. This also fixes a potential crasher by removing a code path
that was passing NULL to cogl_texture_allocate() that would have caused
and abort if there were an error.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-09-02 16:49:33 +01:00
Neil Roberts
4bc7377727 Add the cogl_point_coord snippet builtin
This adds a #define for gl_PointCoord to all shaders so that it can be
accessed with a name in the Cogl namespace.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit c28fc054788e88627bcc2346f4c4c368870ff777)
2013-09-02 16:22:08 +01:00
Neil Roberts
cb178b7a3a Always add the #version pragma to shaders
Previously we would only add the #version pragma to shaders when
point sprite texture coordinates are enabled for a layer so that we
can access the gl_PointCoord builtin. However I don't think there's
any good reason not to just always request GLSL version 1.2 if it's
available. That way applications can always use gl_PointCoord without
having to enable point sprite texture coordinates.

This adds a glsl_version_to_use member to CoglContext which is used to
generate the #version pragma as part of the shader boilerplate. On
desktop GL this is set to 120 if version 1.2 is available, otherwise
it is left at 110. On GLES it is always left as 100.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit e4dfe8b07e8af111ecbcb0da20ff2a2875a2b5d0)

Conflicts:
	cogl/driver/gl/gl/cogl-driver-gl.c
2013-09-02 16:22:01 +01:00
Neil Roberts
e67e487daf docs: Fix the documentation for texture coordinates in snippets
The documentation for the builtin varyings for the texture coordinates
was wrongly claiming that the varyings are stored in an array. This
was changed in e55b64a9cdc9 so that each layer gets its own
independent varying.

The documentation was also referring to texture units instead of layer
numbers. The texture units are no longer publicly exposed in the
shaders and instead everything should in theory be expressed in terms
of layer numbers.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit bf6b509c340bdc3be30e1a81fb96710b3176e9dc)
2013-09-02 15:47:18 +01:00
Chun-wei Fan
9440c690fb cogl/cogl-offscreen.h: Fix deprecation macro placement
The deprecation macros need to be before the function prototype on
Visual Studio, and is also accepted by GCC.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-08-30 12:04:36 +01:00
Chun-wei Fan
9f8d21ba48 Update cogl.symbols
Add the symbols that were added to the public Cogl API, and remove the
export of an internal API that was also removed.  Unfortunately
_cogl_system_error_quark needs to be exported for the conformance test
programs.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-08-30 12:04:36 +01:00
Chun-wei Fan
eda015d45c MSVC Builds: Update Predefined cogl-defines.h
Cogl-Path was split out from the main Cogl library to become a standalone
library, but many libraries/appplications using Cogl (such as Clutter)
expects that Cogl-Path is still in Cogl.  Define
COGL_HAS_COGL_PATH_SUPPORT here, as it will always be needed, at least for
the 1.16 release series, so that builds of items using Cogl would not
break, such as Clutter.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-08-30 12:04:36 +01:00
Chun-wei Fan
98340c44ba Fix the Windows Resource Files
The autotools variables to substitute for versioning in 1.16 is wrong, so we
have incorrect versioning info during a release as the variables are for
Cogl-2.x.  Fix this so we can have the correct versioning info for the
Cogl/Cogl-Pango DLLs during a release.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-08-30 12:04:36 +01:00
Chun-wei Fan
1eda045316 cogl/cogl-bitmap-conversion.c: Include missed header
The cogl-texture-private.h needs to be included as
_cogl_texture_needs_premult_conversion, so that we can avoid implicit
declaration warnings of that symbol (aka C4013 on MSVC).

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 4afe9dc1fea646e2a9576f9a0dbd1ffafa40485b)
2013-08-30 12:02:54 +01:00
Damien Lespiau
af8ea69b7f texture-rectangle: Initialize is_foreign
So we don't read an initializes value later on. Caught by valgrind:

Conditional jump or move depends on uninitialised value(s)
  _cogl_object_texture_rectangle_indirect_free (cogl-texture-rectangle.c:105)
  _cogl_object_context_indirect_free (cogl-context.c:453)
  ...
  main (text.c:149)

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 90415aae9495749a2a9e85fb17425a3c7f6a08c8)
2013-08-26 23:19:27 +01:00
Neil Roberts
cf44ad2493 gles2: Use GL_ES instead of __VERSION__ for setting precision
Mesa has started getting picky about specifying the precision for
floating types in the fragment shader. We already have a default
precision specifier in all the fragment shaders but apparently this
wasn't working because it is only used when the __VERSION__ define is
100 and Mesa is reporting 110. Regardless of whether Mesa is doing the
right thing or not I think it makes sense to use GL_ES instead of
__VERSION__ because we will also need the precision specifier if we
start requesting GLSL 3.0. The GLES specification explictly states
that GL_ES will only be defined for GLES and this is similar to what
the internal meta shaders do in Mesa.

http://cgit.freedesktop.org/mesa/mesa/commit/?id=cabd45773b58d6aa482

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 37f5205739cfb0745ea74dedaec117081ba0088b)
2013-08-25 02:34:13 +01:00
Neil Roberts
7bab449700 renderer: Don't allow the COGL_DRIVER env var to override application
Since e07d0fc7441 the COGL_DRIVER environment variable was able to
override the application's driver selection. This doesn't seem like a
good idea because if the application is specifying a driver explicitly
then presumably it can not work with any other driver. This patch
changes it so that if a driver is selected in the configuration and by
the application then they must match, otherwise it will fail with a
CoglError.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 4e0942d74c8d69aa48e0176bfecf27f64a950d0f)
2013-08-23 16:50:51 +01:00
Neil Roberts
e7b50a6cba renderer: Only check certain constraints when selecting a driver
Only COGL_RENDERER_CONSTRAINT_SUPPORTS_COGL_GLES2 affects the driver
selection and all of the the other constraints are only relevant to
the winsys selection. However Cogl was trying to apply all of the
constraints to the driver selection which meant that if any other
constraint was specified then it would always fail. This patch makes
the driver selection filter out all other constraints based on a mask
defined in cogl-renderer-private.h.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f07febc8913b97fb828e7f2cc2857813af2d3657)
2013-08-23 16:49:59 +01:00
Robert Bragg
627e518da0 display: add _set_onscreen_template() api
Currently it's only possible to set an onscreen template on a
CoglDisplay by passing a template to cogl_display_new(). For
applications that want to deal with fallbacks then they may want to
replace the onscreen template so this adds a
cogl_display_set_onscreen_template() function.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit f307c9545791dae5472a9568fef6b31b3bf52854)
2013-08-23 16:44:07 +01:00
Robert Bragg
1c91bd4a05 renderer: assert CoglPrivateFeatureFlags fit in 32 bits
This updates the static assertion in cogl-renderer.c to only check that
the flags will fit in 32 bits instead of asserting the type has the same
size as an unsigned long.

(cherry picked from commit c6893fa3c9eda0f13b79d3a1fc03f8b79c42a8f6)
2013-08-23 15:26:45 +01:00
Robert Bragg
29f08ef124 webgl: use DEPTH_STENCIL_ATTACHMENT
WebGL doesn't allow you to separately attach buffers to the
STENCIL_ATTACHMENT and DEPTH_ATTACHMENT framebuffer attachment points
and instead requires you to use the DEPTH_STENCIL_ATTACHMENT whenever
you want a depth and stencil buffer.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit ec7b6360c9c4e45e0b113f9dca7bb1502e7e93be)
2013-08-23 15:25:44 +01:00
Robert Bragg
3fc1a39db8 Adds "webgl" driver
This adds a COGL_DRIVER_WEBGL enum and a new driver description for
webgl in cogl-renderer.c. This also adds a COGL_DRIVER_FLAG_OPENGL_WEB
driver flag and a HAVE_COGL_WEBGL define which we can start to use to
handle special cases where webgl differs from gles2.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 2c167b7a4ee56241827322bbe7cb287b0628437c)
2013-08-23 15:22:30 +01:00
Robert Bragg
34658ea057 generalize driver description and selection
This adds a table of driver descriptions to cogl-renderer.c in order of
preference and when choosing what driver to use we now iterate the table
instead of repeating boilerplate checks. For handling the "default driver"
that can be specified when building cogl and handling driver overrides
there is a foreach_driver_description() that will make sure to iterate
the default driver first or if an override has been set then nothing but
the override will be considered.

This patch introduces some driver flags that let us broadly categorize
what kind of GL driver we are currently running on. Since there are
numerous OpenGL apis with different broad feature sets and new apis
may be introduced in the future by Khronos then we should tend to
avoid using the driver id to do runtime feature checking. These flags
provide a more stable quantity for broad feature checks.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit e07d0fc7441dddc3f0a2bc33a6a37d62ddc3efc0)
2013-08-23 14:51:43 +01:00
Giovanni Campagna
bd3dce4af1 kms: add public API to override the default configuration of outputs
Add API to allow complex applications using the KMS backend
to go almost straight to direct configuration (which is not possible
because Cogl needs to be in charge of buffers and FB objects).

https://bugzilla.gnome.org/show_bug.cgi?id=705837

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 52fb8e1c33d8c83c731c05cee767928fdd5991d7)
2013-08-23 13:55:42 +01:00
Jasper St. Pierre
99352e1149 Fix introspection issues 2013-08-20 19:18:40 -04:00
Robert Bragg
d9cf422253 cogl: further fix for including cogl-path.h
This now updates the guard to ignore whether
COGL_ENABLE_EXPERIMENTAL_2_0_API is defined since we need to work for
clutter which does define that, as well as clutter users that don't.
2013-08-20 12:14:12 +01:00
Robert Bragg
29c2819df4 cogl: fix incorrect guard around cogl-path.h include
cogl.h was meant to include cogl-path.h so long as
COGL_ENABLE_EXPERIMENTAL_2_0_API is not defined but it was actually
requiring it to be defined which was breaking clutter applications.
2013-08-20 11:53:39 +01:00
Neil Roberts
45550cd343 wayland: Call eglTerminate before destroying wl_display, not after
The eglTerminate code in Mesa will try to destroy the wl_drm object
which involves using data structures in the wl_display. Cogl was
disconnecting the display before calling eglTerminate which meant that
this would end up accessing potentially garbage data.

https://bugzilla.gnome.org/show_bug.cgi?id=705591

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 358d85f35d0fe36698b758163729c4551fe5fd25)
2013-08-20 11:13:37 +01:00
Robert Bragg
daa3a7d7b5 framebuffer: restore api to maintain ABI for release
This restores the cogl_framebufer_[v]draw_*_attributes APIs for the 1.16
branch so we can avoid changing the soname for the 1.15.6 release
2013-08-20 01:06:25 +01:00
Chun-wei Fan
aa878ddca6 Fix the placement of deprecation macros
The deprecation macros, which expand to __declspec (deprecated) on Visual
Studio, is expected to be before the return type of the function which
is annotated by them, and having the deprecation macros there is also
accepted by GCC as well.

This will fix the builds of all applications/libraries using Cogl under
Visual Studio,

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-08-19 22:44:45 +01:00
Fan Chun-wei
d87a0b08d6 Update the cogl.symbols file
Add and rename the symbols that have been added/renamed during the
development cycle, and also remove those that have been dropped during the
process.

Also continue the quest of purging from the exports lists of the internal
APIs as some of those are no longer referenced by other Cogl components.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-08-19 22:44:45 +01:00
Chun-wei Fan
00b3e21f44 cogl-gpu-info.c: Avoid using named initializers
Unfortunately named initializers is a feature that is not supported by
all compilers (such as pre-2013 Visual Studio) so avoid using that.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 5a5659f9861dfe7a4808f2a5284de8fe6175bec2)
2013-08-19 22:44:45 +01:00
Chun-wei Fan
45288c5d6d cogl-texture-gl.c: Don't include strings.h unconditionally
Use the HAVE_STRINGS_H check before we include strings.h, as it is not
universally available.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit ff65144c84a16f9470d3f3931dc91cc9a6ef5938)
2013-08-19 22:44:45 +01:00
Chun-wei Fan
96de3fbcf5 MSVC builds: Update pre-defined cogl-define.h
...For both the regular WGL winsys and SDL winsys builds, that
COGL_HAS_GTYPE_SUPPORT is defined, so that the builds won't break as
Visual Studio builds do assume an existing installation of GLib.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit ef41aea2796315a47693bf278f08b41ca6703566)
2013-08-19 22:44:45 +01:00
Robert Bragg
04d943579b gl: bind position attribute to location 0
Full GL treats the position attribute specially and requires that it
must be bound to generic attribute location 0 unlike GLES 2.0 or
GL 3.2 core. We now make sure to unconditionally bind the
cogl_position_in attribute to location 0 before linking any glsl program
in cogl.

For reference the relevant part of the GL 3.0 spec that covers these
semantics is Section 2.7 "Vertex Specification" pg 27

After this change there was one remaining problem in
test-custom-attributes where the test_short_verts() test was using its
own "pos" attribute instead of cogl_position_in and so cogl wasn't able
to ensure it would be bound to location 0.

This updates the test to use cogl_position_in but to work around the
fact that glVertexPointer doesn't support UNSIGNED_SHORT components we
force the test to use the glsl backend by setting a shader snippet on
the pipeline.

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

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 992ef7b3b49ebb56adde2133bb36330c04133a3f)
2013-08-19 22:44:45 +01:00
Robert Bragg
1317a25a91 offscreen: rename _new_to_texture to _new_with_texture
This renames cogl_offscreen_new_to_texture to
cogl_offscreen_new_with_texture. The intention is to then cherry-pick
this back to the cogl-1.16 branch so we can maintain a parallel
cogl_offscreen_new_to_texture() function which keeps the synchronous
allocation semantics that some clutter applications are currently
relying on.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit ecc6d2f64481626992b2fe6cdfa7b999270b28f5)

Note: Since we can't break the 1.x api on this branch this keeps a
thin shim around cogl_offscreen_new_with_texture to implement
cogl_offscreen_new_to_texture with its synchronous allocation
semantics.
2013-08-19 22:44:44 +01:00
Adel Gadllah
64aa6092ce offscreen: Allocate the framebuffer in cogl_offscreen_new_to_texture_full
The API says that it should return NULL on failure but it does not do that
due to the lazy allocation.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=703174
2013-08-19 22:44:44 +01:00
Robert Bragg
7365c3aa77 Separate out CoglPath api into sub-library
This splits out the cogl_path_ api into a separate cogl-path sub-library
like cogl-pango and cogl-gst. This enables developers to build Cogl with
this sub-library disabled if they don't need it which can be useful when
its important to keep the size of an application and its dependencies
down to a minimum. The functions cogl_framebuffer_{fill,stroke}_path
have been renamed to cogl_path_{fill,stroke}.

There were a few places in core cogl and cogl-gst that referenced the
CoglPath api and these have been decoupled by using the CoglPrimitive
api instead. In the case of cogl_framebuffer_push_path_clip() the core
clip stack no longer accepts path clips directly but it's now possible
to get a CoglPrimitive for the fill of a path and so the implementation
of cogl_framebuffer_push_path_clip() now lives in cogl-path and works as
a shim that first gets a CoglPrimitive and uses
cogl_framebuffer_push_primitive_clip instead.

We may want to consider renaming cogl_framebuffer_push_path_clip to
put it in the cogl_path_ namespace.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 8aadfd829239534fb4ec8255cdea813d698c5a3f)

So as to avoid breaking the 1.x API or even the ABI since we are quite
late in the 1.16 development cycle the patch was modified to build
cogl-path as a noinst_LTLIBRARY before building cogl and link the code
directly into libcogl.so as it was previously. This way we can wait
until the start of the 1.18 cycle before splitting the code into a
separate libcogl-path.so.

This also adds shims for cogl_framebuffer_fill/stroke_path() to avoid
breaking the 1.x API/ABI.
2013-08-19 22:44:35 +01:00
Giovanni Campagna
dab054200c egl-kms: set the EGL_PLATFORM explicitly
Otherwise, if we try egl-wayland first, we get the environment
variable from that, which crashes mesa trying to open the gbm device
as a wayland display.

https://bugzilla.gnome.org/show_bug.cgi?id=705836
2013-08-13 09:32:17 +02:00
Robert Bragg
e4f24dba75 framebuffer: remove attribute drawing apis
Almost nothing draws attributes directly and for those things that do
it's trivial to adapt them to instead draw via the cogl_primitive api.
This simplifies the Cogl api a bit.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 7395925bcc01aad6c695fd0d9af78b784b3c64d4)

Conflicts:
	cogl/cogl-framebuffer.c
	cogl/cogl-framebuffer.h
2013-07-30 15:08:39 +01:00
Robert Bragg
e9f721216e Add _primitive_draw to replace _framebuffer_draw_primitive
When splitting out the CoglPath api we saw that we would be left with
inconsistent drawing apis if the drawing apis in core Cogl were lumped
into the cogl_framebuffer_ api considering other Cogl sub-libraries or
that others will want to create higher level drawing apis outside of
Cogl but can't use the same namespace.

So that we can aim for a more consistent style this adds a
cogl_primitive_draw() api, comparable to cogl_path_fill() or
cogl_pango_show_layout() that's intended to replace
cogl_framebuffer_draw_primitive()

Note: the attribute and rectangle drawing apis are still in the
cogl_framebuffer_ namespace and this might potentially change but in
these cases there is no single object representing the thing being drawn
so it seems a more reasonable they they live in the framebuffer
namespace for now.

Note: the cogl_framebuffer_draw_primitive() api isn't removed by this
patch so it can more conveniently be cherry picked to the 1.16 branch so
we can mark it deprecated for a short while. Even though it's marked as
experimental api we know that there are people using the api so we'd
like to give them a chance to switch to the new api.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 418912b93ff81a47f9b38114d05335ab76277c48)

Conflicts:
	cogl-pango/cogl-pango-display-list.c
	cogl/Makefile.am
	cogl/cogl-framebuffer.c
	cogl/cogl-pipeline-layer-state.h
	cogl/cogl2-path.c
	cogl/driver/gl/cogl-clip-stack-gl.c
2013-07-29 18:31:36 +01:00
Robert Bragg
7d2e23bd75 bitmap: calc rowstride from width * bpp if 0
This updates cogl_bitmap_new_for_data() to calculate the rowstride from
the width and bpp if the given rowstride is 0, to be consistent with how
the texture apis work.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 1c809210092a8c5e223edfcab1e378b205cf35d6)
2013-07-29 16:59:37 +01:00
Robert Bragg
d383bc0e61 remove internal use of cogl_texture_new_with_size
In preparation for removing the automagic cogl-auto-texture apis this
adds a more minimal version of the cogl_texture_new_with_size code to
cogl-atlas.c for creating textures used to migrate images out of an
atlas and to cogl-texture-pixmap-x11.c.

Note: It turned out that both of these minimal versions were the same so
I did consider keeping a shared utility, but since the implementations
are very small and potentially due to the differing requirements for
atlas and pixmap-x11 textures we might even want them to differ later I
chose to keep them separate.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 6d64307483713e7a5a7ef554275619def51b840f)

Conflicts:
	cogl/cogl-atlas.c
	cogl/winsys/cogl-texture-pixmap-x11.c
2013-07-29 16:57:33 +01:00
Robert Bragg
061240ef2a 2d-sliced: add _new_from_file/data/bitmap apis
This adds cogl_texture_2d_sliced_new_from_bitmap/data/file apis in
preparation for removing the cogl_texture_new_from_bitmap/file apis that
are considered a bit too magic, but we don't want to loose the
convenience they have.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 218da8e1349d7658f45c6933b9736c0d32941b8b)

Conflicts:
	cogl/cogl-auto-texture.c
2013-07-29 16:49:01 +01:00
Robert Bragg
aa92110f83 texture-2d: Add _new_from_file api
This adds a cogl_texture_2d_new_from_file() api since we are planning to
remove cogl_texture_new_from_file() but don't want to loose the
convenience it had.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 10e91aa513123ed277a8d45976f8d75445d7dc9c)
2013-07-29 16:48:49 +01:00
Robert Bragg
fc5d1a8a68 Expose CoglAtlasTexture api
This exposes the CoglAtlasTexture api, making the following public:
cogl_atlas_texture_new_with_size
cogl_atlas_texture_new_from_file
cogl_atlas_texture_new_from_data
cogl_atlas_texture_new_from_bitmap

The plan is to remove auto-texture apis like cogl_texture_new_from_file
since they are a bit too magic, but that means we need an explicit way
for users to allocate texture that will go in the atlas.

Although the _new_from_file() api is arguably redundant since you can
use _bitmap_new_from_file() followed by _atlas_texture_new_from_bitmap()
we don't want to loose any of the convenience that
cogl_texture_new_from_file() had.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit fe515e6063ba4c3ddb5cd00d2c8527d9a6336a12)

Conflicts:
	cogl/Makefile.am
2013-07-29 16:38:53 +01:00
Robert Bragg
6f480c7530 texture: remove _cogl_texture_prepare_for_upload
This removes the gl centric _cogl_texture_prepare_for_upload api from
cogl-texture.c and instead adds a _cogl_bitmap_convert_for_upload() api
which everything now uses instead. GL specific code that needed the gl
internal/format/type enums returned by _cogl_texture_prepare_for_upload
now use ->pixel_format_to_gl directly.

Since there was a special case optimization in
cogl_texture_new_from_file that aimed to avoid copying the temporary
bitmap that's created for the given file and allow conversions to
happen in-place the new _cogl_bitmap_convert_for_upload() api supports
converting in place depending on a 'can_convert_in_place' argument.

This ability to convert bitmaps in-place has been integrated across the
different components as appropriate.

In updating cogl-texture-2d-sliced.c this was able to remove a number of
other GL specific parts to how spans are setup.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit e190dd23c655da34b9c5c263a9f6006dcc0413b0)

Conflicts:
	cogl/cogl-auto-texture.c
	cogl/cogl.symbols
2013-07-29 16:31:44 +01:00
Damien Lespiau
1e4e68e069 context: Don't forget to unref() the renderer if we create it ourselves
cogl_display_new() takes a ref on the renderer, so code creating a
renderer and not keeping a pointer to it do unref later needs to drop
the ref immediately.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 5433555f19ac73f3f236026f1bafca758d63c9fa)
2013-07-29 16:06:37 +01:00
Damien Lespiau
eb002f20e8 pipeline: Initialize unknown_color_alpha on copy
Just like:

commit f3adec1faeb651dd97095a02256932cc82761f40
Author: Neil Roberts <neil@linux.intel.com>
Date:   Thu Jul 11 13:51:28 2013 +0100

    Initialise dirty_real_blend_enable in _cogl_pipeline_copy

But this time for unknown_color_alpha.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit e6a6a2752fb1cc14860cbc559f41f25f7e7f195e)
2013-07-19 13:54:07 +01:00
Robert Bragg
8de1f83b1c gpu-info: consider "(Core Profile)" GL version annotation
Mesa annotates the GL version string with "(Core Profile)" when using
the OpenGL 3 core profile and so our heuristics that try and determine
what vendor and GPU is being used where being confused. This updates
the check_mesa_driver_package() function to consider this optional
annotation.

This adds a small unit test to verify the parsing of some example
version strings. We can update this with more real world version strings
if the format changes again in the future.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 1a074173d20857c7bedb6a862958713e5ef8d2d1)
2013-07-19 13:53:52 +01:00
Neil Roberts
2f9a0a2c97 Initialise dirty_real_blend_enable in _cogl_pipeline_copy
When making a copy of a pipeline, the flag to mark whether the real
blend enable is valid was not being initialised.

Thanks to Damien Lespiau for pointing this out

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f3adec1faeb651dd97095a02256932cc82761f40)
2013-07-11 16:05:34 +01:00
Neil Roberts
b3cc4d26d9 wayland: Send COGL_FRAME_EVENT_SYNC based on the frame callback
Instead of queuing the frame sync event immediately after a swap, the
Wayland winsys now installs a frame callback and queues the event when
Wayland reports that the frame is complete. It also reports the
COGL_FRAME_EVENT_COMPLETE event at the same time because there is no
more information we can give.

This patch is a bit of a divergence from how the events are handled in
the GLX winsys. Instead of installing its own idle function, the
_cogl_onscreen_queue_event() function has now been made non-static so
that it can be used by the Wayland winsys. The frame callback now just
queues an event using that. The pending_frame_infos queue on the
CoglOnscreen isn't used and instead the CoglFrameInfo is immediately
popped off the queue so that it can be stored as part of the closure
data when the frame callback is set up. That way it would use the
right frame info even if somehow the Wayland callbacks were invoked in
the wrong order and the code is a bit simpler.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f7ea370a0d5013c9f0263f37c7f892adc8a2f087)
2013-07-11 14:22:12 +01:00
Neil Roberts
737806bcee wayland: Remove the Wayland socket FD if there are any errors
Previously if the Wayland socket gets closed then Cogl would ignore
the error when dispatching events which meant the socket would be
constantly ready for reading, the main loop would never go idle and it
would sit at 100% CPU. When Wayland encounters an error it will
actually close the socket which means if something else opened another
file then we might even end up polling on a completely unrelated FD.
This patch makes it remove the FD from the main loop as soon as it
hits an error so that it will at least avoid breaking the main loop.
However I think most applications would probably want to abort in this
case so we might also want to add a way to inform the application of
this or even just abort directly.

The cogl_poll_* functions have been changed so that they can cope if
the pending and dispatch callbacks remove their own FD while they are
invoked.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 85857b10687a5a246a0a4ef42711e560c7a6f45d)
2013-07-11 14:22:12 +01:00
Damien Lespiau
5858cac873 color: Add HSL conversion functions
This allows to easily caculate shades of the same color or pick colors
with the same saturation/luminance. In short, all sorts of interesting
things.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit edcbeaf3c941f7a2335fbec47d5248cd9b0e8088)
2013-07-09 22:52:49 +01:00
Neil Roberts
3d9eaef3ac wayland: Add API to prevent Cogl from dispatching the wayland display
This adds cogl_wayland_renderer_set_event_dispatch_enabled() which can
be used to prevent Cogl from adding the socket for the Wayland display
to its list of file descriptors to poll. This can be used in
applications that want to integrate Cogl with existing code that is
reading from the Wayland socket itself.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f5b8d98676ab3e90ad80459019c737ec2ff90aa4)
2013-07-09 15:46:46 +01:00
Neil Roberts
18ce7ad7f5 Get rid of the foreign shell and compositor APIs
The Wayland 1.0 protocol supports multiple independent components querying the
available interfaces by retreiving their own wl_registry object so the
application doesn't need to pass them down anymore.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 8ca36a1d1ab7236fec0f4d7b7361ca96e14c32be)
2013-07-09 15:46:46 +01:00
Neil Roberts
8911da794e Implicitly allocate on cogl_wayland_onscreen_get_(shell_)?surface
The idea with the framebuffer allocation is that it will lazily
allocate so that if you don't want to handle errors then you don't
have to be aware that there is an allocation step. In order for this
to work any accessors that get data that is only available after
allocation should implicitly allocate the framebuffer. This patch
makes that change for cogl_wayland_onscreen_get_surface and
cogl_wayland_onscreen_get_shell_surface.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 0c4ba78787323fedd162d7b71b86b460908b9b98)
2013-07-09 15:46:46 +01:00
Neil Roberts
3060d44365 Allow cogl_wayland_onscreen_get_surface to be used non-foreignly
cogl_wayland_onscreen_get_surface previously only worked if the
onscreen had a foreign surface on it. However there is no reason why
this shouldn't also work fine for manipulating the surface that Cogl
created as well. We may want to consider adding a separate getter for
the foreign surface that can be used before the framebuffer is
allocated.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 6bc12947a51224b70525893143bfe421723ce255)
2013-07-09 15:46:46 +01:00
Neil Roberts
9730b9d6a6 Include endian.h before checking __FLOAT_WORD_ORDER
CoglFixed was trying to use the __FLOAT_WORD_ORDER macro in order to
do some fast float conversions but it wasn't including any header that
could define it so it was giving an annoying warning. This patch
checks for the macro in endian.h in the configure script and only
checks its value if it's available.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-07-04 11:40:40 +01:00
Neil Roberts
823f254190 Fix the check for whether to use inline ARM assembler
Commit 839cf49763 changed the inline ARM assembler so that it
won't be used when targetting the Thumb instruction set. I manually
applied the patch but I messed up the #if so it was generating a
warning.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-07-04 11:40:40 +01:00
Neil Roberts
a0ea2f3aca Don't enable deprecation warnings for internal API when building Cogl
The 1.x branch needs to use some of the deprecated API internally in
order to set up some deprecated state. This was causing a lot of
annoying warnings so instead we'll just disable the deprecation
attribute when COGL_COMPLIATION is defined.

It probably wouldn't be a good idea to apply this to the 2.0 branch
because at least for now we want to get warnings if we accidentally
use deprecated API internally.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-07-04 11:40:39 +01:00
Neil Roberts
1ad0e81b7b wayland-server: Update because wl_shm_buffer is no longer a wl_buffer
The Wayland server API has changed so that wl_shm_buffer is no longer
a type of wl_buffer and it instead must be retrieved directly from the
resource.

cogl_wayland_texture_2d_new_from_buffer now takes a resource pointer
instead of directly taking a wl_buffer and it will do different things
depending on whether it can get a wl_shm_buffer out of the resource
instead of trying to query the buffer type.

Cogland has also been updated so that it tracks a resource for buffers
of surfaces instead of directly tracking a wl_buffer. This are pointed
to by a new CoglandBuffer struct which can be referenced by a
CoglandBufferReference. The WL_BUFFER_RELEASE event will be posted
when the last reference to the buffer is removed instead of directly
whenever a new buffer is attached. This is similar to how Weston
works.

https://bugzilla.gnome.org/show_bug.cgi?id=702999

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 9b35e1651ad0e46ed489893b60563e2c25457701)

Conflicts:
	examples/cogland.c
2013-07-01 13:48:22 +01:00
Neil Roberts
baa398b324 wayland: Always call wl_display_flush before going idle
Previously Cogl would only call wl_display_flush after doing a swap
buffers on the onscreen because that is the only place where Cogl
itself would end up queueing requests. However since commit
323fe188748 Cogl takes control of calling wl_display_dispatch as well
which effectively makes it very difficult for the application to
handle the Wayland event queue itself. Therefore it needs to rely on
Cogl to do it which means that other parts of the application may also
queue requests that need to be flushed.

This patch tries to copy the display fd handling of window.c in the
Weston example clients. wl_display_flush will always be called in
prepare function for the fd which means it will always be called
before going idle. If flushing the display causes the socket buffer to
become full, it will additionally poll for write on the FD to try
flushing again when it becomes empty.

We also need to call wl_display_dispatch_pending in the prepare
because apparently calling eglSwapBuffers can cause it to read data
from the FD to receive events for a different queue. In that case
there will be events that need to be handled but the FD will no longer
be ready for reading so we won't wake up the main loop any other way.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 962d1825105a87dd8358a765353b77f6af8fe760)
2013-07-01 13:47:48 +01:00
Neil Roberts
651a2775b5 poll: Add _cogl_poll_renderer_modify_fd
_cogl_poll_rendererer_modify_fd can be used internally to modify the
event mask on an FD to be polled. This will be used in the Wayland
backend to start blocking on write whenever flushing the display fills
the socket's buffer. Modifying the FD's events causes the poll age to
increase.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 8bc0df53ee508687b87e547c1cbac5e8d7d5fc80)
2013-07-01 13:47:48 +01:00
Neil Roberts
41b97b885a poll: Always run the prepare callbacks for all sources
Eventually the Wayland winsys will want to do useful work in its
prepare callback before the main loop goes idle. Previously
cogl_poll_renderer_get_info would stop calling any further prepare
functions if it found one with a zero timeout. That would mean the
Wayland prepare function might not get called before going idle in
some cases. This patch changes it so that it continues to call all of
the prepare functions regardless of the timeout.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 02f7fa538c9d2b383fa0f601177140b571ecf315)
2013-07-01 13:47:48 +01:00
Neil Roberts
813e8f3a98 wayland: Disconnect the display when the renderer disconnects
If we don't do this then it might leak connections to the display if
multiple different renderers are tried.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 8e5b4d40a4d960d0d20927d30ee68a37387fe776)
2013-07-01 13:47:48 +01:00
Neil Roberts
2f4d66f950 Don't create a layer when enabling texture coordinate attributes
When a primitive is drawn with an attribute that contains texture
coordinates Cogl will fetch the corresponding layer in order to
determine the unit number. However if the pipeline didn't actually
have a layer it would end up redundantly creating it. It's probably
not a good idea to be modifying the pipeline while flushing the
attributes state so this patch makes it pass the no-create flag to the
get_layer function and then skips out enabling the attribute if the
layer didn't already exist.

https://bugzilla.gnome.org/show_bug.cgi?id=702570

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 7507ad1a55a2aeb5beb8c0e3343e1e1f2805ddde)
2013-07-01 13:36:56 +01:00
Neil Roberts
e926c1dab4 Fix the alpha value in the default texture data
When a layer is added to a pipeline without setting a texture it ends
up sampling from a default 1x1 texture which is meant to be solid
white. However for some reason we were creating the texture with 0
opacity which is effectively an invalid premultiplied colour. This
would make the blending behave oddly if it was used.

https://bugzilla.gnome.org/show_bug.cgi?id=702570

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 2ffc77565fb6395b986d3274f8bdb6eee6addbf9)
2013-07-01 13:36:56 +01:00
Neil Roberts
7b80ddcef9 Log a fatal error when an error is propagated to a NULL error argument
Unlike in GError, the policy in Cogl for when NULL is passed as the
CoglError argument is that the program should abort with a fatal
error. Previously however any errors that were being propagated were
being silently dropped if the application passed NULL. This patch
fixes it to also log a fatal error in that case.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 41e233b4b27de579f77b82115cf43a618bf0c93f)
2013-06-27 14:29:51 +01:00
Neil Roberts
29b01c2aba Fix the check for whether snippets require pipeline to need blending
When determining whether a pipeline needs blending, it was previously
returning TRUE if the pipeline has no snippets, whereas it should be
the other way around because we can't determine the final colour when
there are snipets.

https://bugzilla.gnome.org/show_bug.cgi?id=702570

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 109c815bf747fe027a74f098b4fcb6ea4846a482)
2013-06-21 14:18:40 +01:00
Neil Roberts
2933423ca7 Don't generate GLSL for the point size for default pipelines
Previously on GLES2 where there is no builtin point size uniform then
we would always add a line to the vertex shader to write to the
builtin point size output because when generating the shader it is not
possible to determine if the pipeline will be used to draw points or
not. This patch changes it so that the default point size is 0.0f
which is documented to have undefined results when drawing points.
That way we can avoid adding the point size code to the shader in that
case. The assumption is that any application that is drawing points
will probably have explicitly set the point size on the pipeline
anyway so it is not a big deal to change the default size from 1.0f.

This adds a new pipeline state flag to track whether the point size is
non-zero. This needs to be its own state because altering it needs to
cause a different shader to be added to the pipeline cache. The state
flags that affect the vertex shader have been changed from a constant
to a runtime function because they will be different depending on
whether there is a builtin point size uniform.

There is also a unit test to ensure that changing the point size does
or doesn't generate a new shader depending on the values.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit b2eba06e16b587acbf5c57944a70ceccecb4f175)

Conflicts:
	cogl/cogl-pipeline-private.h
	cogl/cogl-pipeline-state-private.h
	cogl/cogl-pipeline-state.c
	cogl/cogl-pipeline.c
2013-06-21 14:18:37 +01:00
Neil Roberts
1455561a20 egl-x11: Fix a crash when the app has non-Cogl windows
The handler for ConfigureNotify events in the EGL X11 winsys was
incorrectly trying dereference the onscreen pointer even if it didn't
find an onscreen for the X window that has resized. This meant that if
the application has other windows that weren't created by Cogl then it
would crash when handling events for them.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit a0056df61903d74180d4e4caa1046e68396d1be0)
2013-06-21 14:13:09 +01:00
Roy.Li
b32d135299 cogl-fixed: In ARM asm don't allow GCC to reuse input regs for outputs
Add register constraints to prevent asm statement complaints like:

  {standard input}:382: rdhi, rdlo and rm must all be different

Signed-off-by: Donn Seeley <donn.seeley@windriver.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-06-14 12:18:04 +01:00
Roy.Li
839cf49763 cogl-fixed: Don't use inline ARM assembler when building for Thumb
There are two asm() statements in cogl-fixed.c that can't be assembled
in Thumb mode. This patch switches it to the generic code in Thumb
mode.

Signed-off-by: Donn Seeley <donn.seeley@windriver.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-06-14 12:10:59 +01:00
Neil Roberts
1b1713625c Don't handle the out-of-memory error specially for auto-textures
Previously when trying the three different texture types to create an
automagic texture it would handle the out-of-memory error specially
and bypass trying the remaining texture types. Presumably the idea is
that out-of-memory is a serious error and it can't be recovered from.
However, in the case of atlas textures, this error will be thrown if
the texture is too large to fit into an atlas. In that case it makes
sense to try another texture type so that it can fallback to using a
sliced texture. I think conceptually each different texture type will
have different memory requirements so it seems reasonable to try the
others if there is not enough memory for one of them.

This was causing cogl_texture_new_from_data to break when loading very
large textures because it wouldn't end up slicing them.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit ad6968135a01823eb6a94668dd22c7a4df6f9327)
2013-06-14 11:28:41 +01:00
Neil Roberts
534e535a28 Use the Wayland embedded linked list implementation instead of BSD's
This removes cogl-queue.h and adds a copy of Wayland's embedded list
implementation. The advantage of the Wayland model is that it is much
simpler and so it is easier to follow. It also doesn't require
defining a typedef for every list type.

The downside is that there is only one list type which is a
doubly-linked list where the head has a pointer to both the beginning
and the end. The BSD implementation has many more combinations some of
which we were taking advantage of to reduce the size of critical
structs where we didn't need a pointer to the end of the list.

The corresponding changes to uses of cogl-queue.h are:

• COGL_STAILQ_* was used for onscreen the list of events and dirty
  notifications. This makes the size of the CoglContext grow by one
  pointer.

• COGL_TAILQ_* was used for fences.

• COGL_LIST_* for CoglClosures. In this case the list head now has an
  extra pointer which means CoglOnscreen will grow by the size of
  three pointers, but this doesn't seem like a particularly important
  struct to optimise for size anyway.

• COGL_LIST_* was used for the list of foreign GLES2 offscreens.

• COGL_TAILQ_* was used for the list of sub stacks in a
  CoglMemoryStack.

• COGL_LIST_* was used to track the list of layers that haven't had
  code generated yet while generating a fragment shader for a
  pipeline.

• COGL_LIST_* was used to track the pipeline hierarchy in CoglNode.

The last part is a bit more controversial because it increases the
size of CoglPipeline and CoglPipelineLayer by one pointer in order to
have the redundant tail pointer for the list head. Normally we try to
be very careful about the size of the CoglPipeline struct. Because
CoglPipeline is slice-allocated, this effectively ends up adding two
pointers to the size because GSlice rounds up to the size of two
pointers.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 13abf613b15f571ba1fcf6d2eb831ffc6fa31324)

Conflicts:
	cogl/cogl-context-private.h
	cogl/cogl-context.c
	cogl/driver/gl/cogl-pipeline-fragend-glsl.c
	doc/reference/cogl-2.0-experimental/Makefile.am
2013-06-13 13:45:47 +01:00
Neil Roberts
ed510dbe6d Use a GList instead of a BSD list for CoglPipelineSnippetList
Previously CoglPipelineSnippetList was using the BSD embedded list
type with a mini struct to combine the list node with a pointer to the
snippet. This is effectively equivalent to just using a GList so we
might as well do that. This will help if we eventually want to get rid
of cogl-queue.h

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 54a168f3c7829c427d54ab517533bb9f7384d022)
2013-06-13 13:45:46 +01:00
Neil Roberts
fa0df6ea96 Fix freeing an atlas texture that hasn't been allocated
The free function for atlas textures was previously always assuming
that there will be a valid sub_texture pointer but this might not be
the case if the texture was never successfully allocated. This was
causing Cogl to crash if the application tries to make a texture that
can not fit in the atlas using the automagic texture API.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit a7a8b7aefc8cb03fe8b716bee06b3449a7dba85f)
2013-06-13 13:45:46 +01:00
Neil Roberts
6d51a18e7c Add support for per-vertex point sizes
This adds a new function to enable per-vertex point size on a
pipeline. This can be set with
cogl_pipeline_set_per_vertex_point_size(). Once enabled the point size
can be set either by drawing with an attribute named
'cogl_point_size_in' or by writing to the 'cogl_point_size_out'
builtin from a snippet.

There is a feature flag which must be checked for before using
per-vertex point sizes. This will only be set on GL >= 2.0 or on GLES
2.0. GL will only let you set a per-vertex point size from GLSL by
writing to gl_PointSize. This is only available in GL2 and not in the
older GLSL extensions.

The per-vertex point size has its own pipeline state flag so that it
can be part of the state that affects vertex shader generation.

Having to enable the per vertex point size with a separate function is
a bit awkward. Ideally it would work like the color attribute where
you can just set it for every vertex in your primitive with
cogl_pipeline_set_color or set it per-vertex by just using the
attribute. This is harder to get working with the point size because
we need to generate a different vertex shader depending on what
attributes are bound. I think if we wanted to make this work
transparently we would still want to internally have a pipeline
property describing whether the shader was generated with per-vertex
support so that it would work with the shader cache correctly.
Potentially we could make the per-vertex property internal and
automatically make a weak pipeline whenever the attribute is bound.
However we would then also need to automatically detect when an
application is writing to cogl_point_size_out from a snippet.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 8495d9c1c15ce389885a9356d965eabd97758115)

Conflicts:
	cogl/cogl-context.c
	cogl/cogl-pipeline-private.h
	cogl/cogl-pipeline.c
	cogl/cogl-private.h
	cogl/driver/gl/cogl-pipeline-progend-fixed.c
	cogl/driver/gl/gl/cogl-pipeline-progend-fixed-arbfp.c
2013-06-07 16:53:29 +01:00
Robert Bragg
2d24248a3c pipeline: only maintain breadcrumb for debug builds
This ensures we only add a static_breadcrumb pointer to every
CoglPipeline when build with debugging enabled. Since applications may
allocate a lot of pipelines we want to keep the basic size of pipelines
(ignoring optional sparse state) down to a minimum.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 4716312e14bc253cd174a22b3db9d2c9cf031fa1)
2013-06-06 21:49:14 +01:00
Robert Bragg
d264b30090 units: remove test-bitmask and add UNIT_TEST instead
This moves the code in test-bitmask into a UNIT_TEST() directly in
cogl-bitmask.c which will now be run as a tests/unit/ test.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 693c85e0cde8a1ffbffc03a5f8fcc1f92e8d0ac7)

Includes fix to build conform tests with -I$(top_builddir)/cogl to
be able to find cogl-gl-header.h
2013-06-06 21:45:11 +01:00
Robert Bragg
eb7fafe700 tests: Adds our first white-box unit test
This adds a white-box unit test that verifies that GL_BLEND is disabled
when drawing an opaque rectangle, enabled when drawing a transparent
rectangle and then disabled again when drawing a transparent rectangle
but with a blend string that effectively disables blending.

This shares the test utilities and launcher infrastructure we are using
for conformance tests so we get consistent reporting and so unit tests
will be run against a range of different drivers.

This adds a --enable-unit-tests configure option which is enabled by
default but if disabled will make all UNIT_TESTS() into static inline
functions that we should expect the compiler to discard since they won't
be referenced by anything.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 9047cce06bbf9051ec77e622be2fdbb96ed767a8)
2013-06-06 21:27:16 +01:00
Robert Bragg
8f9151303d pipeline: improve real_blend_enable checks
Since _cogl_pipeline_update_blend_enable() can sometimes show up quite
high in profiles; instead of calling
_cogl_pipeline_update_blend_enable() whenever we change pipeline state
that may affect blending we now just set a dirty flag and when we flush
a pipeline we check this dirty flag and lazily calculate whether blender
really needs to be enabled if it's set.

Since it turns out we were too optimistic in assuming most GL drivers
would recognize blending with ADD(src,0) is equivalent to disabling
GL_BLEND we now check this case ourselves so we can always explicitly
disable GL_BLEND if we know we don't need blending.

This introduces the idea of an 'unknown_color_alpha' boolean to the
pipeline flush code which is set whenever we can't guarantee that the
color attribute is opaque. For example this is set whenever a user
specifies a color attribute with 4 components when drawing a primitive.
This boolean needs to be cached along with every pipeline because
pipeline::real_blend_enabled depends on this and so we need to also call
_cogl_pipeline_update_blend_enable() if the status of this changes.

Incidentally with this patch we now no longer ever use
_cogl_pipeline_set_blend_enable() internally. For now the internal api
hasn't been removed though since we might want to consider re-purposing
it as a public api since it will now not conflict with our own internal
state tracking and could provide a more convenient way to disable
blending than setting a blend string.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit ab2ae18f3207514c91fa6fd9f2d3f2ed93a86497)
2013-06-06 21:27:09 +01:00
Neil Roberts
2ed926120d Fix a warning in the EGL winsys
_cogl_egl_query_wayland_buffer was using _COGL_RETURN_IF_FAIL but the
function needs to return a CoglBool so it was giving a warning.

(cherry picked from commit d0290eb19fc9bf56fb24f8eab573e19966ea7e1a)
2013-05-30 13:59:13 +01:00
Neil Roberts
d0944b8fbd Add a callback to get dirty events from a CoglOnscreen
This adds a callback that can be registered with
cogl_onscreen_add_dirty_callback which will get called whenever the
window system determines that the contents of the window is dirty and
needs to be redrawn. Under the two X-based winsys's, this is reported
off the back of the Expose events, under SDL it is reported from
SDL_VIDEOEXPOSE or SDL_WINDOWEVENT_EXPOSED and under Windows from the
WM_PAINT messages. The Wayland winsys doesn't really have the concept
of dirtying the buffer but in order to allow applications to work the
same way on all platforms it will emit the event when the surface is
first shown and whenever it is resized.

There is a private feature flag to specify whether dirty events are
supported. If the winsys does not set this then Cogl will simulate
dirty events by emitting one when the window is first allocated and
when it is resized. The only winsys's that don't set this flag are
things like KMS or the EGL null winsys where there is no windowing
system and showing and hiding the onscreen doesn't really make any
sense. In that case Cogl can assume the buffer will only become dirty
once when it is first allocated.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 85c5a9ba419b2247bd768284c79ee69164a0c098)

Conflicts:
	cogl/cogl-private.h
2013-05-30 13:42:56 +01:00
Neil Roberts
45e18e0fb7 wayland: Don't delay resize if nothing is drawn since last swap
After discussing with Kristian Høgsberg it seems that the semantics of
wl_egl_window_resize is meant to be that if nothing has been drawn to
the framebuffer since the last swap then the resize will take effect
immediately. Cogl was previously always delaying the call to
wl_egl_window_resize until the next swap. That meant that if you
wanted to resize the surface you would have to call
cogl_wayland_onscreen_resize and then redundantly draw a frame at the
old size so that you can swap to get the resize to occur before
drawing again at the right size. Typically an application would decide
to resize at the start of its paint sequence so it should be able to
just resize immediately.

In current Mesa master it seems that there is a bug which means that
it won't actually delay a resize that is done mid-scene and instead it
will just discard what came before. To get consistent behaviour in
Cogl, the code to delay the call to wl_egl_window_resize is still used
if it determines that the buffer is dirty. There is an existing
_cogl_framebuffer_mark_mid_scene call which was being used to track
when the framebuffer becomes dirty since the last clear. This function
is now also used to track a new flag to track whether something has
been drawn since the last swap. It is called ‘mid_scene’ under the
assumption that this may also be useful for other things later.

cogl_framebuffer_clear has been slightly altered to always call
_cogl_framebuffer_mark_mid_scene even if it determines that it doesn't
need to clear because the framebuffer should still be considered to be
in the middle of a scene. Adding a quad to the journal now also begins
the scene.

This also fixes a potential bug where it looks like pending_dx/dy were
never cleared so they would always be accumulated even after the
resize is flushed.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 945689a62903990a20abb87a85d2c96eb3985fe7)
2013-05-30 13:42:11 +01:00
Neil Roberts
2a42576fe7 Rename _cogl_framebuffer_dirty to _cogl_framebuffer_mark_mid_scene
In some later patches we want to be able to use the term ‘dirty’ as a
public facing concept which represents expose events from the window
system. In that case the internal concept of dirtying the framebuffer
is confusing, so this patch changes the name to instead mean that
we've doing something which causes the framebuffer to be in the middle
of a frame.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 88eed85b52c29f66659ea112038f3522c9bd864e)
2013-05-30 13:42:11 +01:00
Neil Roberts
0b2b46ce4c wayland: Don't set the surface to toplevel until it is shown
If we delay setting the surface to toplevel until it is shown then
that gives the application an opportunity to avoid calling show so
that it can set its own surface type.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit ab59c3a421968d7f159d89ca2f0ba8a9f098cbf6)
2013-05-30 13:42:11 +01:00
Neil Roberts
4543ed6ac3 win32: Automatically process windows messages when using a GMainLoop
Previously the WGL winsys was expecting the application to send all
windows messages to Cogl via the cogl_win32_renderer_handle_event
function. When using a GLib main loop we can make this work
transparently to the application with a GSource for the magic
G_WIN32_MSG_HANDLE file descriptor. That causes the GMainLoop to wake
up whenever a message is available.

This patch makes the WGL winsys add that magic value as a source fd.
This will only have any meaning if the application is using glib, but
it shouldn't matter because the cogl_poll_renderer_get_info function
is documented to only work on Unix-based winsys's anyway.

This patch is an API break because by default Cogl will now start
stealing all of the Windows messages. Something like Clutter that wants to handle
its own event retrieval would now need to call
cogl_win32_renderer_set_event_retrieval_enabled to stop Cogl from
stealing the events.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 99a7f84d7149f24f3e86c5d3562f9f2632ff6df8)
2013-05-30 13:41:44 +01:00
Robert Bragg
cc4e144dd7 check the wayland buffer format when creating texture
The implementation of cogl_wayland_texture_2d_new_from_buffer now uses
eglQueryWaylandBuffer to query the format of the buffer before trying to
create a texture from the buffer.  This makes sure we don't try and
create a texture from YUV buffers for instance that may actually require
multiple textures. We now also report an error when we don't understand
the buffer type or format.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 79252d4e419e2462c5bc89ea4614b40bddc932c5)
2013-05-29 19:30:44 +01:00
Robert Bragg
cf002a7989 pipeline: ignore driver in blend state tracking
This removes the various checks for != COGL_DRIVER_GLES1 when tracking
blend state that was trying to avoid checking the equation or alpha
component factors when they are known to be fixed on gles1. Now we just
rely on the opengl driver to do the right thing for the different
drivers and ignore the differences in the general pipeline state
tracking.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit f67c7eaf23e1e2088e9956cb2b66dfdc9abc8b3b)
2013-05-29 19:30:44 +01:00
Robert Bragg
0e7a632e13 Adds initial Emscripten support to Cogl
This enables basic Emscripten support in Cogl via the SDL winsys.
Assuming you have setup an emscripten toolchain you can configure Cogl
like this:

 emconfigure ./configure --enable-debug --enable-emscripten

Building the examples will build .html files that can be loaded directly
by a WebGL enabled browser.

Note: at this point the emscripten support has just barely been smoke
tested so it's expected that as we continue to build on this we will
learn about more things we need to change in Cogl to full support this
environment.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit a3bc2e7539391b074e697839dfae60b69c37cf10)
2013-05-29 19:30:44 +01:00
Robert Bragg
d39f4b8a16 gl: #ifdef guard ARB_sync api in cogl-all-functions.h
The ARB_sync api depends on a GLsync type which may not be available if
GL_ARB_sync isn't defined, such as when building for gles2 only. This
guards the prototypes with #ifdef GL_ARB_sync to fix compilation when a
GLsync type isn't defined.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit ba79020e0f5b102e8b25cd831c408dd68d241297)
2013-05-29 19:30:44 +01:00
Andreas Oberritter
bb1f787e6a cogl-error.h: add COGL_BEGIN_DECLS/COGL_END_DECLS
Fixes 'undefined reference to cogl_error_free' when using g++.

Signed-off-by: Andreas Oberritter <obi@saftware.de>

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 41c54fcaba5b4bf76a0e943bac6bca777f3dae2f)
2013-05-29 11:58:48 +01:00
Daniel Stone
ea7d3b8476 Add fence API
cogl_framebuffer_add_fence creates a synchronisation fence, which will
invoke a user-specified callback when the GPU has finished executing all
commands provided to it up to that point in time.

Support is currently provided for GL 3.x's GL_ARB_sync extension, and
EGL's EGL_KHR_fence_sync (when used with OpenGL ES).

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=691752

(cherry picked from commit e6d37470da9294adc1554c0a8c91aa2af560ed9f)
2013-05-28 21:36:03 +01:00
Robert Bragg
7b14b5e3da poll: Add general way to hook into mainloop without fd
This adds a _cogl_poll_renderer_add_source() function that we can use
within cogl to hook into the mainloop without necessarily having a file
descriptor to poll. Since the intention is to use this to support
polling for fence completions this also updates the
CoglPollCheckCallback type to take a timeout pointer so sources can
optionally update the timeout that will be passed to poll.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 81c1ce0ffce4e75e08622e20848405987e00b3cc)
2013-05-28 21:36:03 +01:00
Adam Jackson
c08fe74cd0 xlib: Don't crash just because the display doesn't expose RANDR
If this happens, XRRGetScreenResources will return NULL, so just treat
that like nothing happened.

https://bugzilla.gnome.org/show_bug.cgi?id=699431

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 57a79912ac70080a2f9cbe65181a25b00bf1192a)
2013-05-16 15:28:01 +01:00
Robert Bragg
74b8cc3acb Include cogl-defines.h before checking COGL_HAS_ define
This makes sure we include cogl-defines.h in cogl-matrix.h before
checking if COGL_HAS_GYPE_SUPPORT is defined

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit aa5ba324bb3b2ce77be29942f8716d61919cefeb)
2013-05-16 15:28:00 +01:00
Robert Bragg
3a7c1263f1 onscreen: Adds swap_buffers_with_damage api
This adds api to be able requests a swap_buffers and also pass a list of
damage rectangles that can be passed on to a compositor to enable it to
minimize how much of the screen it needs to recompose.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 0d9684c7b7c2018bb42715c369555330d38514a2)
2013-04-30 16:39:31 +01:00
Robert Bragg
95a41e177a Associate check and dispatch funcs with poll fds
Instead of driving event dispatching through a per winsys poll_dispatch
vfunc its now possible to associate a check and dispatch function with
each file descriptor that is registered for polling. This means we can
remove the winsys get_dispatch_timeout and poll_dispatch vfuncs and it
also makes it easier for more orthogonal internal components to add file
descriptors for polling to the mainloop.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 627947622df36dd529b9dc60a3ae9e6083532b19)
2013-04-30 16:39:31 +01:00
Robert Bragg
e3975d1711 Add api for queuing idle callback internally
This adds a _cogl_poll_renderer_add_idle api that can be used internally
for queuing an idle callback without needing to make any assumption
about the system mainloop that is being used. This is now used to avoid
having the _cogl_poll_renderer_dispatch() directly check for all kinds of
events to dispatch, and to avoid having the winsys dispatch vfuncs need
to directly know about CoglContext. This means we can now avoid having a
back reference from CoglRenderer to the CoglContext.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit a1e169f18f4257caec58760adccfe4ec09b9805d)
2013-04-30 16:39:31 +01:00
Robert Bragg
04a1655804 Adds internal cogl closure list utility
This adds some utility code to help us manage lists of closures
consistently within Cogl. The utilities are from Rig and were originally
written by Neil Roberts.

This adapts the way we track CoglOnscreen resize and frame closures to
use the new utilities.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 2e15fc76eb29bf5932418f7ee80f1fcb2f6a816c)
2013-04-30 16:39:31 +01:00
Robert Bragg
ed90c6fed9 Move event polling into CoglRenderer
This updates the cogl_poll_ apis to allow dispatching events before we
have a CoglContext and to also enables pollfd state to be changed in a
more add-hoc way by different Cogl components by replacing the
winsys->get_poll_info with _cogl_poll_renderer_add/remove_fd functions
and a winsys->get_dispatch_timeout vfunc.

One of the intentions here is that applications should be able to run
their mainloop before creating a CoglContext to potentially get events
relating to CoglOutputs.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 667e58c9cb2662aef5f44e580a9eda42dc8d0176)
2013-04-30 16:39:31 +01:00
Neil Roberts
816a5bc437 onscreen: Make the resize callback work the same as the frame callback
When adding the frame callback API in 70040166 we decided on a common
idiom for adding callbacks which would return an opaque pointer
representing the closure for the callback. This pointer can then be
used to later remove the callback. The closure can also contain an
optional callback to invoke when the user data parameter is destroyed.
The resize callback didn't work this way and instead had an integer
handle to identify the closure. This patch changes it to work the same
way as the frame callback.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 33164c4b04d253ebe0ff41b12c1e90232c519274)
2013-04-30 16:39:31 +01:00
Chris Cummins
59a04cd0e6 wayland: implement foreign surfaces for CoglOnscreen
This adds support for optionally providing a foreign Wayland surface to
a CoglOnscreen before allocation. Setting a foreign surface prevents
Cogl from creating a toplevel Wayland shell surface for the OnScreen.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit e447d9878f3bcfe5fe336d367238383b02879223)
2013-04-26 17:53:07 +01:00
Chris Cummins
4327b7a364 wayland: free framebuffer's shell surface on destroy
This prevents leaking the Wayland shell surface associated with a Cogl
OnScreen when it is finalised.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 760fc9f3af5475530262b82a55df311fceca358a)
2013-04-26 17:52:57 +01:00
Robert Bragg
afbb13e1a4 Add compiler deprecation warnings
This adds compiler symbol deprecation declarations for old Cogl APIs so
that users can easily see via compiler warning when they are using these
symbols, and also see a hint for what the apis should be replaced with.

So that users of Cogl can manage when to show these warnings this
introduces a scheme borrowed from glib whereby you can declare what
version of the Cogl api you are using:

COGL_VERSION_MIN_REQUIRED can be defined to indicate the oldest Cogl api
that the application wants to use. Cogl will only warn about
deprecations for symbols that were deprecated earlier than this required
version. If this is left undefined then by default Cogl will warn about
all deprecations.

COGL_VERSION_MAX_ALLOWED can be defined to indicate the newest api
that the application uses. If the application uses symbols newer than
this then Cogl will give a warning about that.

This patch removes the need to maintain the COGL_DISABLE_DEPRECATED
guards around deprecated symbols.

This patch fixes a few uses of deprecated symbols in the examples/

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-04-24 22:23:50 +01:00
Andreas Oberritter
b5e57c914b wayland: implement poll_get_info and poll_dispatch
Call wl_display_dispatch on POLLIN. This follows the implementation
in weston/clients/window.c and improves integration of input events,
at least.

Signed-off-by: Andreas Oberritter <obi@saftware.de>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 323fe1887487f19c3e26aa6b7644de31d8d0a532)
2013-04-24 22:23:49 +01:00
Emanuele Aina
b8673fbb2f build: Use LT_LIB_M to find the math library in a portable way
https://bugzilla.gnome.org/show_bug.cgi?id=697330

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit a7b4930e14add7d955c22f396178b71083dfb52f)

Conflicts:
	cogl/Makefile.am
2013-04-23 18:30:50 +01:00
Andreas Oberritter
a2168cedb3 cogl-xlib.h: add missing COGL_END_DECLS
Fixes compilation with C++ compiler.

Signed-off-by: Andreas Oberritter <obi@saftware.de>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 7b3c6dd7f6810f3c8dec62904daa887c917ab7e2)
2013-04-16 19:50:09 +01:00
Neil Roberts
20657d6245 pipeline-cache: Use a special trimmed down pipeline for the key
When a pipeline is added to the cache, a normal copy would previously be
made to use as the key in the hash table. This copy keeps a reference
to the real pipeline which means all of the resources it contains are
retained forever, even if they aren't necessary to generate the hash.

This patch changes it to create a trimmed down copy that only has the
state necessary to generate the hash. A new function called
_cogl_pipeline_deep_copy is added which makes a new pipeline that is
directly a child of the root pipeline. It then copies over the
pertinent state from the original pipeline. The pipeline state is
copied using the existing _cogl_pipeline_copy_differences function.
There was no equivalent function for the layer state so I have added
one.

That way the pipeline key doesn't have the texture data state and it
doesn't hold a reference to the original pipeline so it should be much
cheaper to keep around.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit e27e01c1215e7e7c7c0183ded11dd769bb112c5c)
2013-04-04 13:38:43 +01:00
Neil Roberts
4e03bd47bf pipeline-hash-table: Store the hash value in the entry
Calculating the hash value for a pipeline can be a bit expensive.
Previously when adding a new pipeline to the hash table we would end
up calculating the hash value once when checking whether the pipeline
is already in the hash table and then again when adding the pipeline
to the hash table. Ideally GHashTable would provide some API to add an
entry with a precalculated hash value to avoid the recalculation, but
seeing as it doesn't do that we can force it to avoid recalculating by
storing the hash value as part of the struct we are using for the key.
That way the hash func passed to GHashTable can simply return the
precalculated value and we can calculate the hash outside of the
GHashTable calls.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 4a0460a452fd1be382fd5a92d8cfd5e0cdfd4403)
2013-04-04 13:38:43 +01:00
Neil Roberts
3b8d328652 pipeline-cache: Use a shared hash table wrapper
The pipeline cache contains three separate hash tables, one for the
state affecting the vertex shaders, one for the fragment shaders and
one for the resulting combined program. Previously these hash tables
had a fair bit of duplicated code to calculate the hashes, check for
equality and copy the pipeline when it is added. This patch moves the
common bits of code to a new type called CoglPipelineHashTable which
just wraps a GHashTable with a given set of state flags to use for
hashing and checking for equality.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 402796430c839038339e531363b8c2463f9b2a9e)

Conflicts:
	cogl/Makefile.am
2013-04-04 13:38:41 +01:00
Neil Roberts
a1952a25ad quartz-image: Pass a CoglError argument to the bitmap functions
Since 67cad9c0 and f7735e141a the bitmap allocation and mapping
functions now take an extra error argument. The quartz image backend
was missed in this update so Cogl would fail to compile if
--enable-quartz-image is used.

https://bugzilla.gnome.org/show_bug.cgi?id=696730

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 1827965befccf331b0787f71cb191d370640a9de)
2013-04-04 13:37:51 +01:00
Robert Bragg
af8803baab egl: define missing EGL_KHR_create_context enums
This makes sure the EGL_KHR_create_context enums are always defined in
cogl-winsys-egl.c so we will build with drivers that don't support this
extension. Cogl will do runtime checks to explicitly check that the
extension is available before ever referencing these enums so this is
safe to do.

https://bugzilla.gnome.org/show_bug.cgi?id=694537

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit bd034b7451e7d9c602bcc91f1a00f6aaa7b05ec0)
2013-03-24 23:55:10 +00:00
Plamena Manolova
b833d26b3f Fix multiple snippet interleaving bug
Interleaving multiple snippets with different hooks
(COGL_SNIPPET_HOOK_VERTEX and COGL_SNIPPET_HOOK_VERTEX_TRANSFORM,
for instance) used to cause a bug during shader code generation.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 38ca76695d54bbbfe3b940a6d0b2ae879e6fd66b)
2013-03-20 14:37:58 +00:00
Neil Roberts
22363a4137 Prune redundant pipeline ancestry after adding a layer difference
Adding a layer difference may mean the pipeline overrides all of the
layers of its parent which might make the parent redundant so we
should try to prune the hierarchy.

This is particularly important for CoglGst because whenever a new
frame is ready it tries to make a copy of the pipeline it last used
and then replace all of the textures in the layers. Without this patch
the new pipeline would keep the parent pipeline alive which means also
keeping the old textures alive so all of the frames of the video would
effectively be leaked.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 576c7b55aa835448c977f1d79d128dffd40e7cd8)
2013-03-19 17:53:43 +00:00
Chun-wei Fan
8906f7139a Update cogl.symbols
Add the newly-added symbols during the development cycle, and drop those
that are dropped.  Also, clean up the private symbols that were exported,
those that are still left in cogl.symbols are those still being referenced
by Cogl-Pango

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-03-15 00:25:41 +08:00
Robert Bragg
e886ad46e0 Revert "cogl-buffer: Stop warning spam running in sw rendering"
This reverts commit 83dbf79986981fac9ec0f2575b7c7cb32f629f0f.

On further consideration we realized that needing this change either
indicated a bug in the code using cogl, or that it was a symptom of
some other bug in Cogl resulting in us returning NULL in
cogl_buffer_map_range but not returning a CoglError too.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 8c5127c712570f1ea0d495a7fe7290ae5ee60ce6)
2013-03-06 16:46:03 +00:00
Robert Bragg
2fa7b5573d gl: ensure depth isn't masked during clear
If a pipeline has been flushed that disables depth writing and then we
try to clear the framebuffer with cogl_framebuffer_clear4f, passing
COGL_BUFFER_BIT_DEPTH then we need to make sure that depth writing is
re-enabled before issuing the glClear call. We also need to make sure
that when the next primitive is flushed that we re-check what state the
depth mask should be in.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 3cf497042897d1aa6918bc55b71a36ff67e560b9)
2013-03-06 16:45:31 +00:00
Robert Bragg
3c5ebb8752 framebuffer: vp change = clip change for gen6 workaround
This makes sure that a viewport change when comparing between separate
framebuffers also implies a clip change when we are applying the Intel
gen6 workaround for broken viewport clipping. Without this then
switching between different size framebuffers could leave a scissor
matching the size of a previous framebuffer.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit f23f2129c58550f819cff783f47039d7bd91391e)
2013-03-06 16:45:14 +00:00
Robert Bragg
b62b9a68bb bitmap: don't mark bitmap bound on _gl_bind error
This makes some changes to _cogl_bitmap_gl_bind to be more paranoid
about bad access arguments and make sure we don't mark a bitmap as bound
if there was an error in _cogl_buffer_gl_bind.

We now validate the access argument upfront to check that one of _READ
or _WRITE access has been requested. In the case that cogl is built
without debug support then we will still detect a bad access argument
later and now explicitly return before marking the bitmap as bound, just
in case the g_assert_not_reach has been somehow disabled. Finally we
defer setting bitmap->bound = TRUE until after we have check for any
error with _cogl_bitmap_gl_bind.

https://bugzilla.gnome.org/show_bug.cgi?id=686770

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 1720d5cf32449a189fd9d400cf5e6696cd50a9fa)
2013-03-06 16:44:52 +00:00
Neil Roberts
a131b697d9 Add the layer's sampler and uniform declarations at the start
Previously the sampler uniform declarations such as cogl_sampler0 were
generated by walking the list of layers in the shader state. This had
two problems. Firstly it would only generate the declarations for
layers that have been referenced. If a layer has a combine mode of
replace then the samplers from previous layers couldn't be used by
custom snippets. Secondly it meant that the samplers couldn't be
referenced by functions in the declarations sections because the
samplers are declared too late.

This patch fixes it to generate the layer declarations in the backend
start function using all of the layers on the pipeline instead. In
addition it adds the sampler declarations to the vertex shader as they
were previously missing.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 1824df902bbb9995cae6ffb7a413913f2df35eef)

Conflicts:
	cogl/driver/gl/cogl-pipeline-fragend-glsl.c
	cogl/driver/gl/cogl-pipeline-vertend-glsl.c
2013-02-27 15:53:43 +00:00
Neil Roberts
956d39ac30 Add fragment and vertex snippet hooks for global declarations
This adds hook points to add global function and variable declarations
to either the fragment or vertex shader. The declarations can then be
used by subsequent snippets. Only the ‘declarations’ string of the
snippet is used and the code is directly put in the global scope near
the top of the shader.

The reason this is necessary rather than just adding a normal snippet
with the declarations is that for the other hooks Cogl assumes that
the snippets are independent of each other. That means if a snippet
has a replace string then it will assume that it doesn't even need to
generate the code for earlier hooks which means the global
declarations would be lost.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit ebb82d5b0bc30487b7101dc66b769160b40f92ca)
2013-02-27 14:43:55 +00:00
Bastien Nocera
bd1e3e7642 cogl-buffer: Stop warning spam running in sw rendering
/etc/gdm/Xsession[731]: Aviso do gerenciador de janelas: Log level 8:
g_error_free: assertion `error != NULL' failed

https://bugzilla.gnome.org/show_bug.cgi?id=694657

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 83dbf79986981fac9ec0f2575b7c7cb32f629f0f)
2013-02-25 17:50:18 +00:00
Tomeu Vizoso
74a749386b Guard cogl-object.h within COGL_BEGIN_DECLS
To avoid linking trouble in C++ stuff

Reviewed-By: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit b194f1bf58055ef1f5075508f19336cae648a0c8)

Conflicts:
	cogl/cogl-object.h
2013-02-22 16:36:38 +01:00
Neil Roberts
fc86d0e12e win32: Minor build fixes for building for win32
This fixes some minor errors and warnings that were preventing Cogl
building with mingw32:

• cogl-framebuffer-gl.c was not including cogl-texture-private.h.
  Presumably something else ends up including that when building for
  GLX.

• The WGL winsys was not including cogl-error-private.h

• A call to strsplit in the WGL winsys was wrong.

• For some reason the test-wrap-rectangle-textures test was trying to
  include the GDKPixbuf header.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 5380343399f834d9f96ca3b137d49c9c2193900a)
2013-02-21 15:20:55 +00:00
Neil Roberts
a0af92fae9 Update to the latest version of the tesselator from GLU
Mesa's libGLU tesselator code has had a commit on it since it was
copied into Cogl. It sounds like it fixes a potential crash so we
should probably have it in Cogl too.

http://cgit.freedesktop.org/mesa/glu/commit/?id=bfdf99d6ff64b9c2

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit c6b2429546d3ea0aa91caa47c7c90f932984ea33)
2013-02-20 14:55:44 +00:00
Neil Roberts
29983a7e2c buffer: Don't set the invalidate hint when requesting read access
glMapBufferRange is documented to fail with GL_INVALID_OPERATION if
GL_MAP_INVALIDATE_BUFFER_BIT is set as well as GL_MAP_READ_BIT. I
guess this makes sense when only read access is requested because
there would be no point in reading back uninitialised data. However,
Clutter requests read/write access with the discard hint when
rendering to a CoglBitmap with Cairo. The data is new so the discard
hint makes sense but it also needs read access so that it can read
back the data it just wrote for blending.

This patch works around the GL restriction by skipping the discard
hints if read access is requested. If the buffer discard hint is set
along with read access it will recreate the buffer store as an
alternative way to discard the buffer as it does in the case where the
GL_ARB_map_buffer_range extension is not supported.

https://bugzilla.gnome.org/show_bug.cgi?id=694164

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 986675d6043e8701f2d65415cf72ffc91734debd)
2013-02-19 15:03:30 +00:00
Neil Roberts
861b119a53 journal: Dirty the modelview matrix state when flushing
The journal manually flushes its own modelview matrix state so it
needs to mark the state as dirty so that if a primitive is drawn with
the same matrix state as the last primitive it will correctly reflush
it.

https://bugzilla.gnome.org/show_bug.cgi?id=693612

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit c7290c994c742456ff0977cb394c289afb377049)
2013-02-19 11:06:59 +00:00
Jasper St. Pierre
66c75f9a9d cogl-texture: Make the list of registered types global, not per-context
If we make this per-context and create two Cogl contexts, some types
won't re-register, and we'll be in a broken state where some types will
be considered not to be texture types.

https://bugzilla.gnome.org/show_bug.cgi?id=693696

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 567f049d20554bb8ea4e40fa5e72a9fd0bbd409e)
2013-02-13 18:47:16 +00:00
Jasper St. Pierre
a60f16116d cogl-context: Remove the unused buffer_types variable
https://bugzilla.gnome.org/show_bug.cgi?id=693696

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-02-13 18:46:51 +00:00
Neil Roberts
f79e78f648 Don't #ifdef the call to glDiscardFramebuffer
When Cogl is compiled with support for both the GL and GLES drivers it
only includes the GL header and not the GLES header. That means in
that case it would not compile in the code for the
GL_EXT_discard_framebuffer extension even though it could be used on
the GLES driver. This patch makes it use the standard names for the
GL_COLOR, GL_STENCIL etc names instead of the _EXT suffixed names and
manually defines them if we are using the GLES headers. That way the
discard code can be used unconditionally.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 59c30292d0f3c28d6e0e08bc5bf3b4b10545d856)
2013-02-13 12:05:26 +00:00
Neil Roberts
7d9e075917 Bind the framebuffer before calling glDiscardFramebuffer
This patch just adds a call to _cogl_framebuffer_flush_state to ensure
the correct framebuffer is bound before discarding its buffers.
Previously it would presumably just discard the buffers of whatever
framebuffer happened to be used last.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 37c390a5b33d4f65ff6c834e9be2f8de716635ee)
2013-02-13 12:05:22 +00:00
Neil Roberts
1e39819c49 Fix a clear of an array allocated with alloca which had the wrong size
The array allocated for storing the difference flags for each layer in
cogl-pipeline-opengl.c was being cleared with the size of a pointer
instead of the size actually allocated for the array. Presumably this
would mean that if there is more than one layer it wouldn't clear the
array properly.

Also the size of the array was slightly wrong because it was allocating
the size of a pointer for each layer instead of the size of an
unsigned long.

This was originally reported by Jasper St. Pierre on #clutter.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 1e134dd7cd5317651be158a483c7cb2723ce8869)
2013-02-08 12:20:32 +00:00
Neil Roberts
8122368c6a poll: Always let the winsys add fds even if there is a zero timeout
Even if Cogl decides to set a zero timeout because there are events
queued, it still makes sense to give the winsys a chance to add file
descriptors to the list. The winsys might be relying on the list of
CoglPollFDs passed to poll_dispatch to decide whether to read from a
file descriptor and that should happen even if Cogl also woke up the
main loop because the event queue isn't empty.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 6d2f3bc4913d0f1570c09e3714ac8fe2dbfc7a03)
2013-02-04 13:35:59 +00:00
Neil Roberts
446dd70b91 sdl: Wakeup the event blocking immediately if necessary
It is expected that cogl_sdl_idle() will be called from the
application immediately before blocking in SDL_WaitEvent. However,
dispatching the onscreen events may cause more events to be queued. If
that happens we need to make sure the blocking returns immediately.
This patch makes it post the dummy event that the application chose in
order to make that happen.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 9e34a1e8ce97b67ebb2889c622f2c9f1076b087d)
2013-02-03 10:07:47 +01:00
Neil Roberts
f8108751a5 sdl: Use a 32-bit type to store the user event type number
In SDL1 the event type numbers were a single byte so there were only
reserving a byte to store the application's chosen type in
CoglRenderer. However in SDL2 they are a Uint32 and SDL_USEREVENT is
0x8000 so if the application was using that then Cogl would actually
end up posting event type 0.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 39c9177776ac601a92c6f4112558464af6968ea0)
2013-02-03 10:07:47 +01:00
Neil Roberts
b34034217a Make it possible to call swap_buffers within a frame event callback
It seems like it would be quite a reasonable design for an application
to immediately paint the buffer and call swap_buffers within the
handler for the sync event. This previously wouldn't work.

When using the GLX winsys if swap_region is called then it immediately
tries to set the pending notification flag. However if this is called
from the event callback then when the callback is complete it will
clear the flag again and the pending notification will be lost. This
patch just makes it clear the pending flag before invoking the
callback so that it can be safely queued again.

With any winsys that doesn't directly handle the sync event
notification it would almost work except that it was iterating the
live list of pending events. If the callback causes another event to
be added to this list by issuing a buffer swap then the iteration
would never complete and cogl_poll_dispatch would never return. This
patch just makes it steal the list before iterating so that any
additions will be dispatched by a later call to cogl_poll_dispatch
instead.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 2263b31594900b73900d2ce22cf70c68e7e793c6)
2013-02-03 10:07:47 +01:00
Robert Bragg
8a1353a215 This reverts the first hunk from Jerome's last patch
The first hunk from commit 93b7b4c850dd928bf21ee168a95641a8d631f713
turned out to be redundant because GLX guarantees that configs returned
by glXChooseFBConfig should be sorted with non msaa configs coming
first. The second hunk is required since we use glXGetFBConfigs in that
case which doesn't sort the configs.

I had meant to drop this part of the patch before landing it but forgot.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit b19fcc1869275826e952925af922125daf8a48de)
2013-01-31 21:12:36 +00:00
Jerome Glisse
1f84b5c9b4 glx do not use multisample visual config for front or pixmap
There is no guaranty that glXGetFBConfigs will return fbconfig ordered
with non msaa config first. This patch make sure that non msaa config
get choose.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 93b7b4c850dd928bf21ee168a95641a8d631f713)
2013-01-31 12:28:04 +00:00
Owen W. Taylor
98e3b57d0d Add cogl_get_clock_time()
Add an API to get the current time in the time system that Cogl
is reporting timestamps. This is to be used to convert timestamps
into a different time system.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 9f3735a0c37adcfcffa485f81699b53a4cc0caf8)
2013-01-30 20:09:49 +00:00
Owen W. Taylor
24733abf68 onscreen: Add CoglFrameInfo and _add_frame_callback() api
Add a CoglFrameInfo object that tracks timing information for frames
that are drawn. We track a frame counter and frame timing information
for each CoglOnscreen. Internally a CoglFrameInfo is automatically
created for each frame, delimited by cogl_onscreen_swap_buffers() or
cogl_onscreen_swap_region() calls.

CoglFrameInfos are delivered to applications via frame event callbacks
that can be registered with a new cogl_onscreen_add_frame_callback()
api. Two initial event types (dispatched on all platforms) have been
defined; a _SYNC event used for throttling the frame rate of
applications and a _COMPLETE event used so signify the end of a frame.

Note: This new _add_frame_callback() api makes the
cogl_onscreen_add_swap_complete_callback() api redundant and so it
should be considered deprecated. Since the _add_swap_complete_callback()
api is still experimental api, we will be looking to quickly migrate
users to the new api so we can remove the old api.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 700401667db2522045e4623d78797b17f9184501)
2013-01-30 20:09:49 +00:00
Owen W. Taylor
5ce058c0e5 Prefer OML_sync_control over SGI_video_sync when waiting for swap
When we block waiting for the swap, prefer doing that using
glXWaitForMsc() from OML_sync_control because that returns a system
time value for the precise time of the swap.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 1e8114aabc78b90373d3d5f3f7c0224f8786e399)
2013-01-30 20:09:40 +00:00
Robert Bragg
013548c109 renderer: expose CoglOutputs
This adds a cogl_renderer_foreach_output() function that can be used to
iterate the display outputs for a particular renderer.

This also updates cogl-info to use this new api so it can dump out all
the output information.

Reviewed-by: Owen W. Taylor <otaylor@fishsoup.net>

(cherry picked from commit a2abf4c4c1fd5aeafd761f965d07a0fe9a362afc)
2013-01-30 19:57:22 +00:00
Owen W. Taylor
88d8bd84f2 Add CoglOutput and track for the GLX backend
The CoglOutput object represents one output such as a monitor or
laptop panel, with information about attributes of the output such as
the position of the output within the global coordinate space, and
the refresh rate.

We don't yet publically export the ability to get output information but
we track it for the GLX backend, where we'll use it to track the refresh
rate.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit d7ef9d8d71488d0e6874f1ffc6e48700d5c82a31)
2013-01-30 19:56:45 +00:00
Neil Roberts
23eca5c793 Support cogl_renderer_get_n_fragment_texture_units() for ARBfp
There is a cogl_renderer_get_n_fragment_texture_units() function which
is documented to return the number of texture units that are
accessible from a fragment program. This just directly returns the
value from GL_MAX_TEXTURE_IMAGE_UNITS which is available in either the
GLSL extensions or the ARBfp extension. Clutter-GST relies on this to
determine whether it can use a program to convert the YUV data on the
GPU.

When the GL3 driver was added in 66c9db993595b this was changed to
only query the value when the GLSL feature is available. Previously it
would always query the value when the GL or GLES2 driver is used. This
change makes sense on master because there is no API for an
application to make its own ARBfp programs so the only way to access
texture units from a program is via GLSL. However on the 1.14 branch
this patch broke clutter-gst when GLSL is disabled because it thinks
the ARBfp programs can't use multi-texturing.

This patch just changes it to also query the value when ARBfp support
is available.

Note: it's probably note a good idea to apply this patch to master,
but only to the 1.14 branch. On master the function probably needs to
be changed anyway because it is using _COGL_GET_CONTEXT().

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-01-30 14:44:53 +00:00
Neil Roberts
1e00ff268e Bind the dummy surface or drawable when current onscreen is destroyed
Similar to commit 2c0cfdefbb9d1 for the SDL2 winsys, the GLX and EGL
window systems need to bind the dummy surface or drawable when the
currently bound onscreen is destroyed so that there will always be a
valid context bound.

Previously I got the idea that this would not be necessary on GLX
because the documentation for glXDestroyDrawable states that the
drawable won't actually be destroyed if it is currently bound until it
becomes unbound. However it doesn't say what happens if the underlying
X window is also destroyed and after testing it seems this causes a
segfault in Mesa in GLX and an XError for EGLX.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 4a464eec8c5b5832b9fd6b69746ab4ab36229182)
2013-01-25 18:21:09 +00:00
Neil Roberts
da7971f6be Don't set GL_TEXTURE_MAX_LEVEL on GLES
GL_TEXTURE_MAX_LEVEL is not supported on GLES so we can't set it. It
looks like Mesa was letting us get away with this but on other drivers
it may cause errors. The enum is not defined in the GLES headers so it
was failing to compile unless the GL driver is also enabled.

The test-texture-mipmap-get-set test is now marked as n/a on GLES2
because it can't support limiting the sampled mipmaps.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit ba51c393818582b058f5f1e66cf8d13835ad10e5)

Conflicts:
	tests/conform/test-conform-main.c
2013-01-25 18:21:09 +00:00
Neil Roberts
9a242832dc Add some defines that are missing on GLES
The GLES2 driver wasn't compiling unless the GL driver is also enabled
because some run-time conditional code was directly using GL-only
defines.

This should also fix compiling using the stock GL headers on OS X
which don't define GL_NUM_EXTENSIONS.

https://bugzilla.gnome.org/show_bug.cgi?id=692420

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 661e1719aa0b95c409c568ec91ea52b8ff90519b)
2013-01-25 18:21:09 +00:00
Neil Roberts
a749c7c1ab Query rectangle tex parameters when creating a foreign texture on GL3
Previously when creating a foreign rectangle texture it would ignore
the passed in texture information and query the texture directly when
using COGL_DRIVER_GL. However this should also work for
COGL_DRIVER_GL3. This patch changes it to check the private feature
flags for the texture querying feature instead of directly checking
the driver value.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 258c98b82027cb5074afe7844ff3954bbe928757)
2013-01-25 18:21:09 +00:00
Neil Roberts
5d6160c751 Replace some #if HAVE_COGL_GL lines with #ifdef
This was generating warnings when the GL driver is disabled.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f26682dcc04642fed9db959c63d6c6e4261d2148)

Conflicts:
	cogl/cogl-auto-texture.c
2013-01-25 18:21:09 +00:00
Robert Bragg
d521b61a49 egl: support EGL_EXT_buffer_age
This adds support for the EGL_EXT_buffer_age extension which is a
counterpart to the GLX_EXT_buffer_age extension.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 92d869764c03d0bac6b51dac833510c22669ac4a)
2013-01-23 17:58:20 +00:00
Adel Gadllah
860fb00fdc cogl-onscreen: Add buffer_age support
Add a new BUFFER_AGE winsys feature and a get_buffer_age method to
cogl-onscreen that allows to query the value.

https://bugzilla.gnome.org/show_bug.cgi?id=669122

Reviewed-by: Neil Roberts <neil@linux.intel.com>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

Note: When landing the patch I made some gtk-doc updates and changed
_get_buffer_age to return an age of 0 always if the age feature isn't
support instead of using _COGL_RETURN_VAL_IF_FAIL. -- Robert Bragg

(cherry picked from commit 427b1038051e9b53a071d8c229b363b075bb1dc0)
2013-01-23 17:58:10 +00:00
Adam Jackson
9fb0cbd45d meta-texture: Fix nonsensical <= on pointers
Comparing the pointed-to value is clearly what was meant.

Found by Coverity.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f676352210fad856ae85962733e488bc1a832411)
2013-01-22 20:11:25 +00:00
Patrick Welche
8c319e4bc1 Remove vestiges of libdl / dlfcn.h as cogl uses gmodule.
https://bugzilla.gnome.org/show_bug.cgi?id=691944

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 397e673446e86a9116cb7396ea094e9f8b46986e)
2013-01-22 18:00:11 +00:00
Neil Roberts
51f3e28c1f bitmap: Don't try to token paste the typenames from stdint.h
Previously the functions for packing and unpacking pixels where
generated by token pasting together a function name along with its
type, like the following:

 _cogl_pack_ ## uint8_t

Then later in cogl-bitmap-conversion.c it would directly refer to the
function names without token pasting.

This wouldn't work however if the system headers define the stdint
types using #defines instead of typedefs because in that case the
function name generated using token pasting would get the expanded
type name but the reference that doesn't use token pasting wouldn't.

This patch adds an extra macro passed to the cogl-bitmap-packing.h
header which just has the type size. That way the function can be
defined like this instead:

 _cogl_pack_ ## 8

That should prevent it from hitting problems with #defined types.

https://bugzilla.gnome.org/show_bug.cgi?id=691945

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit d6b5d7085b004ebd48c1543b820331802395ee63)
2013-01-22 18:00:11 +00:00
Robert Bragg
50005a9364 build: update to build with automake 1.13
This make autogen.sh look for automake-1.13 and also updates all
Makefile.am files to no longer use the INCLUDES variable which automake
1.13 warns is deprecated by AM_CPPFLAGS.

https://bugzilla.gnome.org/show_bug.cgi?id=690891

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 5de5569e960102afe979a5f2f0403e1defebca62)
2013-01-22 18:00:05 +00:00
Robert Bragg
1d31055ddb disable viewport scissor workaround for clear
We have a workaround in Cogl to fix viewport clipping with Mesa Intel
Gen 6 drivers but this was breaking the semantics of
cogl_framebuffer_clear() which should not be affected by viewport
clipping. This makes sure we disable and restore the workaround when
clearing the framebuffer. This fixes Clutter's test-cogl-viewport
conformance test.
2013-01-22 17:48:19 +00:00
Neil Roberts
3a041ef41b Reorder some struct members to avoid padding due to alignment
This tweaks the ordering of some struct members in some of the more
important structs so that the compiler won't insert wasted padding to
avoid breaking the alignment. Some members that were previously
unsigned long have been changed to unsigned int. These members need to
be able to fit in 32-bits to run on 32-bit machines anyway so there's
no point in having them extend to 64-bit on 64-bit machines. This
doesn't affect the public API.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit b721af236680005464e39f7f4dd11381d95efb16)
2013-01-22 17:48:19 +00:00
Neil Roberts
7572fedeaa Fix filling the array of texture pointers for sliced textures
In commit 1fa7c0f10a8a0 the sliced texture code which creates the
array of pointers to the texture slices was changed so that the
textures are appended to the end of the array instead of initially
creating the array with the right size upfront and then shrinking the
array on error. However it was then still also setting the size of the
array after creating it so the new textures would actually end up in
an unused part of the array. The part of the array that is used was
left unitialised so it would crash. This just removes the call to set
the size of the array.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 7df09d505ba28a1a960df867346af67118e96718)
2013-01-22 17:48:19 +00:00
Neil Roberts
82615e292d Don't try to use clip planes on GL3
GL3 has support for clip planes but they are used differently and
involve writing to a builtin output variable in the vertex shader. The
current clip plane code assumes it is only used with a fixed function
driver and tries to directly push to the matrix builtins. This
obviously won't work on GL3 so for now let's just disable clip planes.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 5f621589467ab961f5130590298dc8e26d658a92)
2013-01-22 17:48:19 +00:00
Neil Roberts
988486ac7d framebuffer: Support the GL_RED texture workaround when querying bits
When a component-alpha texture is made using a GL3 context a GL_RED
texture is actually used and a swizzle is set up to hide it. However
if a framebuffer is then bound to that texture then when the bits are
queried this workaround will leak out of the API. To fix this it now
detects the situation and reports the number of red bits as the number
of alpha bits.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 425cfb2675912a2cbcaaaeed7c2196d563948222)
2013-01-22 17:48:19 +00:00
Neil Roberts
520ccba49d Query the framebuffer stencil bits instead of assuming it's global
Previously when the context was initialised Cogl would query the
number of stencil bits and set a private feature flag to mark that it
can use the buffer for clipping if there was at least 3. The problem
with this is that the number of stencil bits returned by
GL_STENCIL_BITS depends on the currently bound framebuffer. This patch
adds an internal function to query the number of stencil bits in a
framebuffer and makes it use that instead when determining whether it
can push the clip using the stencil buffer.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit e928d21516a6c07798655341f4f0f8e3c1d1686c)
2013-01-22 17:48:18 +00:00
Neil Roberts
109e576b1f Add a public cogl_framebuffer_get_depth_bits() function
Cogl publicly exposes the depth buffer state so we might as well have
a function to query the number of depth bits of a framebuffer.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 853143eb10387f50f8d32cf09af31b8829dc1e01)
2013-01-22 17:48:18 +00:00
Neil Roberts
0b01c91fc5 framebuffer: Bind the framebuffer before querying the bits
The GL framebuffer driver now makes sure to bind the framebuffer
before counting the number of bits. Previously it would just query the
number of bits for whatever framebuffer happened to be used last.

In addition the virtual for querying the framebuffer bits has been
modified to take a pointer to a structure instead of a separate
pointer to each component. This should make it slightly more efficient
and easier to maintain.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit e9c58b2ba23a7cebcd4e633ea7c3191f02056fb5)
2013-01-22 17:48:18 +00:00
Neil Roberts
fe3aa8b8b3 Query glX* functions before getting the context to fix GL3 driver
The GL3 context is created using the glXCreateContextAttribs function
which is part of the GLX_ARB_create_context extension. However
previously the function pointers from GLX extensions were only
retrieved once the GL context is created. That meant that the GL3
context creation function would always assume that the extension is
not supported so it would always fail.

This patch changes it to query the functions when the renderer is set
up instead. The base winsys feature flags that are determined while
querying the functions are stored in a member of CoglGLXRenderer.
These are then copied to the CoglContext when it is initialised.

The spec for glXGetProcAddress says that the functions returned are
context-independent. That implies that it is safe to call it without
binding a context although that is not explicitly stated as far as I
can tell. A big of googling finds this DRI documentation which says it
can be used without a context:

http://dri.freedesktop.org/wiki/glXGetProcAddressNeverReturnsNULL

And also this code sample:

http://www.opengl.org/wiki/Tutorial:_OpenGL_3.0_Context_Creation_%28GLX%29

One point that makes me concerned that this might not always work in
practice is that the code in SDL2 to create a GL3 context first
creates a dummy GL2 context in order to have something bound before it
calls glXGetProcAddress. I think this may just be a misunderstanding
based on how wglGetProcAddress works however.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 04a7aca9a98e84e43ac5559305a1358112902e30)
2013-01-22 17:48:18 +00:00
Neil Roberts
671275ba36 Also flip the virtual coordinates when iterating spans
_cogl_texture_spans_foreach_in_region first swaps over the texture
coordinates if they are flipped so that it can always iterate in a
positive direction. It sets a flag so that it will remember that the
coordinates are flipped. Before invoking the callback it is meant to
reflip the coordinates so that the callee doesn't need to be aware of
the flipping. However it was only flipping the sub-texture coordinates
and not the virtual coordinates. This was causing sliced textures to
draw their slice rectangles with the wrong geometry.
test-backface-culling was failing because of this.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit e7338a1e09cb22151374aefa6f0bb58485af9189)
2013-01-22 17:48:18 +00:00
Neil Roberts
a2aa04f219 texture-2d-slice: Fix the foreach_sub_texture_in_region implementation
There were a few problems with the sub texture iterating code of
sliced textures which were causing some conformance tests to fail when
NPOT textures are disabled:

• The spans are stored in un-normalized coordinates and the
  coordinates passed to the foreach function are normalized. The
  function was trying to un-normalize them before passing them to the
  span iterator code but it was using the wrong factor which was
  causing it to actually doubley normalize them.

• The shim function to renormalize the coordinates before passing them
  to the callback was renormalizing the sub-texture coordinates
  instead of the virtual coordinates. The sub-texture coordinates are
  already in the right scale for whatever is the underlying texture so
  we don't need to touch them. Instead we need to normalize the
  virtual coordinates because these are coming from the un-normalized
  coordinates that we passed to the span iterating code.

• The normalize factors passed to the span iterating were always 1.
  The code uses this normalizing factor to round the incoming
  coordinates to the nearest multiple of a full texture. It divides
  the coordinates by the factor rather than multiplying so it looks
  like we should be passing the virtual texture size here.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit c9773566b0ec0a17b34c440090529de8cff9609e)
2013-01-22 17:48:18 +00:00
Robert Bragg
2c0d48324f texture: Adds cogl_texture_set_data convenience api
This adds a cogl_texture_set_data function that is basically just a
convenience wrapper around cogl_texture_set_region. In the common case
where you want to upload the full contents of a mipmap level though this
api takes 4 less arguments (6 in total) so it's a bit simpler.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit e651dbdc4e4f03016a3dee513e3680270a4a9142)
2013-01-22 17:48:17 +00:00
Robert Bragg
73e8a6d7ce Allow lazy texture storage allocation
Consistent with how we lazily allocate framebuffers this patch allows us
to instantiate textures but still specify constraints and requirements
before allocating storage so that we can be sure to allocate the most
appropriate/efficient storage.

This adds a cogl_texture_allocate() function that is analogous to
cogl_framebuffer_allocate() which can optionally be called to explicitly
allocate storage and catch any errors. If this function isn't used
explicitly then Cogl will implicitly ensure textures are allocated
before the storage is needed.

It is generally recommended to rely on lazy storage allocation or at
least perform explicit allocation as late as possible so Cogl can be
fully informed about the best way to allocate storage.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 1fa7c0f10a8a03043e3c75cb079a49625df098b7)

Note: This reverts the cogl_texture_rectangle_new_with_size API change
that dropped the CoglError argument and keeps the semantics of
allocating the texture immediately. This is because Mutter currently
uses this API so we will probably look at updating this later once
we have a corresponding Mutter patch prepared. The other API changes
were kept since they only affected experimental api.
2013-01-22 17:48:17 +00:00
Robert Bragg
5a814e386a texture: add width/height members to base CoglTexture
There was a lot of redundancy in how we tracked the width and height of
different texture types which is greatly simplified by adding width and
height members to CoglTexture directly and removing the get_width and
get_height vfuncs from CoglTextureVtable

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 3236e47723e4287d5e0023f29083521aeffc75dd)
2013-01-22 17:48:17 +00:00
Robert Bragg
0850eea162 Move _cogl_texture_get_gl_format to -texture-gl.c
This moves the _cogl_texture_get_gl_format function from cogl-texture.c
to cogl-texture-gl.c and renames it _cogl_texture_gl_get_format.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit f8deec01eff7d8d9900b509048cf1ff1c86ca879)
2013-01-22 17:48:17 +00:00
Robert Bragg
a57195d16d framebuffer: split out GL read_pixels code
This moves the direct use of GL in cogl-framebuffer.c for handling
cogl_framebuffer_read_pixels_into_bitmap() into
driver/gl/cogl-framebuffer-gl.c and adds a
->framebuffer_read_pixels_into_bitmap vfunc to CoglDriverVtable.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 2f893054d6754e6bc7983f061b27c7858f1a593c)
2013-01-22 17:48:17 +00:00
Robert Bragg
36c85da3b8 Remove cogl-internal.h
This remove cogl-internal.h in favour of using cogl-private.h. Some
things in cogl-internal.h were moved to driver/gl/cogl-util-gl-private.h
and the _cogl_gl_error_to_string function whose prototype was moved from
cogl-internal.h to cogl-util-gl-private.h has had its implementation
moved from cogl.c to cogl-util-gl.c

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 01cc82ece091aa3bec4c07fdd6bc9e5135fca573)
2013-01-22 17:48:17 +00:00
Damien Lespiau
a0d47d5660 build: Hide cogl_pipeline_cache_{new,free}()
Those symbols should not be public and were exported as they started
with cogl_.

(cherry picked from commit 68a55f1dc70ea60fcccbe226029e585886feddc2)
2013-01-22 17:48:16 +00:00
Damien Lespiau
1f78b4044a enum-types: Fix the header guard #endif comment
Something left from the Clutter split.

(cherry picked from commit f148b7e2ff1fb86cab7f4b7be869bfdba4f91100)
2013-01-22 17:48:16 +00:00
Damien Lespiau
5912ee9997 doc: Fix the remaining broken internal cross-references
Symbols changed names, %1 makes gtk-doc sad and some referenced symbols
were missing in the -sections.txt file.

(cherry picked from commit c12919c321186ac7b223bc4f82c588ca2f199d67)
2013-01-22 17:48:16 +00:00
Damien Lespiau
4316c3c9e1 doc: Use Docbook's <constant> for external constants
For external (non gtk-doc even) constants, we can use <constant> to
correctly tag those without gtk-doc trying to cross-reference them.

(cherry picked from commit 78d22c6cd44a2279adcd2b94c3317292af861c70)
2013-01-22 17:48:16 +00:00
Damien Lespiau
ec6a713fcc doc: Add a missing '*' to the documentation of CoglFilterReturn
(cherry picked from commit 0b9bdd5aaf2616993c4c20c7d7317daf178b19fd)
2013-01-22 17:48:16 +00:00
Damien Lespiau
c0a024f81d doc: Put the opening '{' at the end of combined typedefs
gtk-doc is not smart enough to parse things like:

  typedef struct
  {
    ...
  } CoglFoo;

but needs the '{' at the end of the first line.

(cherry picked from commit d1187550ef547305fdeb8a22a7e39a95611a0e1d)
2013-01-22 17:48:15 +00:00
Damien Lespiau
bde1d2e661 doc: Fix FALSE documentation
Typo with the copy & paste from TRUE.

(cherry picked from commit c7d4a13889ee5681a237a0d2a0fbbdca79120f17)
2013-01-22 17:48:15 +00:00
Damien Lespiau
9401cb044e doc: Fixup type references
gtk-doc needs the types in -sections.txt to be able to do
cross-references. Add all those currently generating warnings.

(cherry picked from commit e57a21d2608f0885e6f2eb3a017feb7dffb7a63c)
2013-01-22 17:48:15 +00:00
Damien Lespiau
55d2a039c6 doc: Don't use '::' to denote an object property
That's actually for signals in gtk-doc and we're not dealing with
GObjects so it's not really appropriate. Used <structfield> as it's the
closest tag I could find to describe a 'property' of a CoglObject and
gives a generic style in the produced HTML.

(cherry picked from commit 8b485d57577cff227a0c7a2e6c06d8d277821374)
2013-01-22 17:48:15 +00:00
Damien Lespiau
780b01f1c8 doc: Populate cogl-types a bit more and move it to the general section
I just added the general types creating warnings in the current state of the
documentation (ie the ones references by already documented functions)
and moved the section from the 'Utility' section to the 'General'
section which I believe is a better fit as they are used by more than
one type and not really utilities.

(cherry picked from commit c51b147789763863ef32482d7ffa936160ed7c93)
2013-01-22 17:48:15 +00:00
Damien Lespiau
5c12c36c58 doc: Don't use the HTML <ul> but the DocBook equivalent
Of course, this confused gtk-doc.

(cherry picked from commit be512104784a9200a2e98a75d16a56e3897a8845)
2013-01-22 17:48:15 +00:00
Damien Lespiau
f1f1e876f1 doc: Fix the remaining warning around the depth state
Various changes have led to the current, separate from the pipeline,
depth state, this commit fixes the remaining waring around that.

(cherry picked from commit 111e687e722ad67a0e1c09f881c6282ccb06410b)
2013-01-22 17:48:15 +00:00
Damien Lespiau
9ae9602047 doc: Expose CoglDepthState
It wasn't included to the documention up to now.

(cherry picked from commit 826c0d5c8333ad31595d690d7c8753f84d12b2ad)
2013-01-22 17:48:14 +00:00
Damien Lespiau
17333d3f10 doc: Use <ulink> to make Gimbal Lock reactive
Instead of just having the reference at the end of the paragraph.
Usually seen as more usable.

(cherry picked from commit 6988d3ae61ab16fb298b34d2bd31860833f04186)
2013-01-22 17:48:14 +00:00
Damien Lespiau
61e1206d33 doc: Unhide cogl-matrix-stack.h
The documentation welcomes a new 2.0 API.

(cherry picked from commit 8d78957c8d29b89c7bf352131d84c9755083eed9)
2013-01-22 17:48:14 +00:00
Damien Lespiau
f2b0dac871 doc: Document CoglColor
(cherry picked from commit a0dfba1eb1c541490611a021799e656bf43a04fe)
2013-01-22 17:48:14 +00:00
Damien Lespiau
cfcb440d70 doc: Document the members of CoglPollFDEvent
(cherry picked from commit 7cc94c2a994a774f0d8db172c9e0bec506bd2287)
2013-01-22 17:48:14 +00:00
Damien Lespiau
864e5562df doc: Fix various mismatches between arguments and their documentation
Argument names and @$arg suffered from various little mismatches, fix
them in a batch commit.

(cherry picked from commit d2ac3c5a88d980e7519c98bd261111b93cf73a6e)
2013-01-22 17:48:13 +00:00
Damien Lespiau
6aadb4a0db doc: Make a pass on CoglRenderer argument documentation
Various arguments where missing, added them.

(cherry picked from commit 6e6ee4acb5524ced2f82d42d9c6a706f84f8184c)
2013-01-22 17:48:13 +00:00
Damien Lespiau
f63b4597f7 doc: Finish describing the arguments of cogl_error_matches()
(cherry picked from commit 8f429d9ce45e3df204db0bdc0d988fd07f103282)
2013-01-22 17:48:13 +00:00
Damien Lespiau
532cd9bf9f doc: Fix small typo of sequence
(cherry picked from commit 09706dc78178d022b4313572600a245112d23fd9)
2013-01-22 17:48:13 +00:00
Damien Lespiau
0142d027d7 doc: Update the section name and description of CoglIndices
cogl-index-range was the old API, update the section name to match what
is declared in the documentation. Also update the short description to
better match the new API.

(cherry picked from commit d73df38ff2a8ebe477e139e5ac20838c8f4364bb)
2013-01-22 17:48:13 +00:00
Damien Lespiau
e4ca3cb039 doc: s/Fuction/Function/
(cherry picked from commit 8e62a12cff9ba0a267d199c359fdc8e591f65264)
2013-01-22 17:48:12 +00:00
Damien Lespiau
8c1708ec93 doc: Fix argument syntax of existing commment blocks
Fixes:
  Parsing comment block file : parameter expecter

by correctly declaring parameters.

(cherry picked from commit 2fe9bc2017fa966ab445674a530aac0c17204040)
2013-01-22 17:48:12 +00:00
Damien Lespiau
388e589ac4 doc: Fix a typo in the description of cogl-bitmap
(cherry picked from commit 423b8f8c62b1f73d6b0e24a5689428821e154703)
2013-01-22 17:48:12 +00:00
Damien Lespiau
81a94a7849 doc: Expose the Cogl GLES 2.0 facilities in the documentation
(cherry picked from commit 0c2344b9aafe4afdf7782fd9badc451de79b7a63)
2013-01-22 17:48:12 +00:00
Damien Lespiau
37cc715269 doc: Add missing symbol in cogl_framebuffer_get_context() documentation
(cherry picked from commit 146a1bfc2655c7e7ed0a5a4fd64b490385159f49)
2013-01-22 17:48:12 +00:00
Damien Lespiau
7b43289ec9 doc: Use Returns: to annotate return values
gtk-doc complains that having a sentence starting by Return is a bit
ambiguous and it'd rather see 'Returns:' spelled out.

Fixes 2 warnings:

 warning: Free-form return value description in $symbol. Use `Returns:'
 to avoid ambiguities

(cherry picked from commit 9718f31717b3a0e01b7c4c69cea138f39d23c0e0)
2013-01-22 17:48:11 +00:00
Damien Lespiau
b8d9bbed1a Don't use #if with defines that are either defined or not
COGL_HAS_* and COGL_ENABLE_DEBUG are either defined in config.h or not.

So let's test against this, not against their truth value, this allow us
to use -Wundef to catch undefined macros in preprocessor directives.

(cherry picked from commit 73b62832f24711073b0876a6c0f5c61727842c1c)
2013-01-22 17:48:11 +00:00
Neil Roberts
1f0b432a25 sdl: Bind the default window when currently bound window is destroyed
Cogl always needs to have the context bound to something so that it
can freely create resources such as textures even if there is no
current window. When the currently bound SDLWindow is destroyed, SDL
apparently explicitly unbinds the GL context. If something then later
for example tries to create a texture Cogl would start getting GL
errors and fail. To fix this the SDL winsys now just binds the dummy
window before deiniting the currently bound onscreen.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 2c0cfdefbb9d1ac5097d98887d3581b67a324fae)
2013-01-22 17:48:11 +00:00
Robert Bragg
cab4622eb3 matrix-stack: make CoglMatrixStack public
We have found several times now when writing code using Cogl that it
would really help if Cogl's matrix stack api was public as a utility
api. In Rig for example we want to avoid redundant arithmetic when
deriving the matrices of entities used to render and we aren't able
to simply use the framebuffer's matrix stack to achieve this. Also when
implementing cairo-cogl we found that it would be really useful if we
could have a matrix stack utility api.

(cherry picked from commit d17a01fd935d88fab96fe6cc0b906c84026c0067)
2013-01-22 17:48:11 +00:00
Robert Bragg
3e33c00c84 matrix-stack: only maintain composite_gets in debug builds
At times there can be huge numbers of CoglMatrixEntry structures
allocated if they are being used to track the transform of many drawing
commands or objects in a scenegraph. Therefore the size of a
CoglMatrixEntry should be kept as small as possible both to help reduce
the memory usage of applications but also to improve cache usage since
matrix stack manipulations are performance critical at times.

This reduces the size of CoglMatrixEntry structures for non-debug builds
by removing the composite_gets counter used to sanity check how often
the transform for an entry is resolved.

(cherry picked from commit c400b86681a328b1e12b7e120e9c3f4f12c356e0)
2013-01-22 17:48:10 +00:00
Robert Bragg
f5b95e8087 matrix-stack: move pointer to top of CoglMatrixEntry
This moves the parent pointer member to the top of the CoglMatrixEntry
structure since it will lead to wasted padding when we build for 64bit
cpus.

(cherry picked from commit 42b4750070286a6404b103d8a827a46efb6b344c)
2013-01-22 17:48:10 +00:00
Robert Bragg
9eb816bc7e matrix-stack: getting parent ptr before freeing
When unrefing a CoglMatrixEntry we walk up the ancestry unrefing and
freeing entries until we find an entry that doesn't need to be freed.
The problem fixed by this patch was that we didn't dereference the
parent member of each entry until after the entry was freed and so there
was the potential for reading a junk parent pointer back.

(cherry picked from commit e5d836b84acb35a009854a0cc0892320023789d1)
2013-01-22 17:48:10 +00:00
Robert Bragg
5bc6121cbf journal: don't call cogl_attribute_buffer_new with NULL
It is considered an error to pass a NULL data pointer to
cogl_attribute_buffer_new so we now call
cogl_attribute_buffer_new_with_size instead.

(cherry picked from commit 8e201574b9c35847aa4e999a391741538a0b356b)
2013-01-22 17:48:10 +00:00
Damien Lespiau
5d796f0a4c x11: Replace all internal usage of cogl_xlib_get_display()
And use the renderer replacement, cogl_xlib_renderer_get_display()

(cherry picked from commit ea355792e88b09b0b0afa6fb5c5acc311d41688e)
2013-01-22 17:48:09 +00:00
Neil Roberts
6bcfc8342a Fix handling of binding errors when uploading a full texture
Both the texture drivers weren't handling errors correctly when a
CoglPixelBuffer was used to set the contents of an entire texture.
This was causing it to hit an assertion failure in the pixel buffer
tests.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 888733d3c3b24080d2f136cedb3876a41312e4cf)
2013-01-22 17:48:09 +00:00
Robert Bragg
7011eb5db4 texture: expose mipmap level in set region apis
cogl_texture_set_region() and cogl_texture_set_region_from_bitmap() now
have a level argument so image data can be uploaded to a specific mipmap
level.

The prototype for cogl_texture_set_region was also updated to simplify
the arguments.

The arguments for cogl_texture_set_region_from_bitmap were reordered to
be consistent with cogl_texture_set_region with the source related
arguments listed first followed by the destination arguments.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 3a336a8adcd406b53731a6de0e7d97ba7932c1a8)

Note: Public API changes were reverted in cherry-picking this patch
2013-01-22 17:48:09 +00:00
Robert Bragg
fa5a9c88fe atlas-texture: remove some use of _COGL_GET_CONTEXT
This removes several uses of _COGL_GET_CONTEXT in cogl-atlas-texture.c.
Notably this involved making CoglPangoGlyphCache track an associated
CoglContext pointer which cogl-pango can pass to
_cogl_atlas_texture_new_with_size().

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit d66afbd0758539330490945c699a05c0749c76aa)
2013-01-22 17:48:09 +00:00
Robert Bragg
cd7b15b7df glx: avoid use of _COGL_GET_CONTEXT()
Removes some (not all) use of _COGL_GET_CONTEXT() from cogl-winsys-glx.c

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 698a131c4991e4393ce966b968637fba194f252c)
2013-01-22 17:48:09 +00:00
Robert Bragg
110a7d0ed7 framebuffer: remove use of _COGL_GET_CONTEXT
Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit b8755a98e4139b6a077ff329b9c5900292d3a1d3)
2013-01-22 17:48:08 +00:00
Robert Bragg
7941357e73 journal: don't reference global context
This removes all use of _COGL_GET_CONTEXT from cogl-journal.c

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit b5c8ec5db52a6cb71f29b338a59fb3772506fef7)
2013-01-22 17:48:08 +00:00
Neil Roberts
ca5197a70c error: Don't allocate a new CoglError when propagating
The _cogl_propagate_error() function takes ownership of the incoming
error pointer so there's no need to allocate a new error when passing
it on. The errors can potentially be passed up from a number of layers
so it seems worthwhile to avoid the allocation.

The _cogl_propagate_gerror() function was previously using
_cogl_propagate_error(). Presumably this would not have worked because
that function would try to free the error from glib using
cogl_error_free but that would use the wrong free function and thus
the wrong slice allocator. The GError propagating function is only
used when gdk-pixbuf is enabled which now requires glib support anyway
so we can just avoid defining the function when compiling without
glib.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 91266162bef9f89fb42c01be0f929d5079758096)
2013-01-22 17:48:08 +00:00
Neil Roberts
af0dc3431d Fix spelling of _cogl_propagate_error
‘Propagate’ was misspelled as ‘propogate’.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 5fb4a6178c3e64371c01510690d9de1e8a740bde)
2013-01-22 17:48:08 +00:00
Robert Bragg
38921701e5 blit: avoid referring to framebuffer stack
This make _cogl_framebuffer_blit take explicit src and dest framebuffer
pointers and updates all the texture blitting strategies in cogl-blit.c
to avoid pushing/popping to/from the the framebuffer stack.

The removes the last user of the framebuffer stack which we've been
aiming to remove before Cogl 2.0

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 598ca33950a93dd7a201045c4abccda2a855e936)
2013-01-22 17:48:08 +00:00
Robert Bragg
e8eb9793e6 moves some gl texture code too cogl-texture-gl.c
This adds a driver/gl/cogl-texture-gl.c file and moves some gl specific
bits from cogl-texture.c into it. The moved symbols were also given a
_gl_ infix and the calling code was updated accordingly.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 2c9e81de70cc02d72b1ce9013c49e39300a05b6a)
2013-01-22 17:48:08 +00:00
Robert Bragg
6941ff2c71 matrix-stack: init cache->flipped
This ensures we initialize the value of cache->flipped in
_cogl_matrix_entry_cache_init()

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 507814d27298231c9ae50d74b386fb00f0909922)
2013-01-22 17:48:08 +00:00
Robert Bragg
da9f5e6179 bitmap: ret CoglError from _new_with_malloc_buffer
_cogl_bitmap_new_with_malloc_buffer() now takes a CoglError for throwing
exceptional errors and all callers have been updated to pass through
any application error pointer as appropriate.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 67cad9c0eb5e2650b75aff16abde49f23aabd0cc)
2013-01-22 17:48:08 +00:00
Robert Bragg
07d47eadd3 texture: split out high-level texture constructors
This splits out the very high level texture constructors that may
internally construct one of several types of lower level texture due to
various constraints.

This also updates the prototypes for these constructors to take an
explicit context pointer and return a CoglError consistent with other
texture constructors.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit a1cabfae6ad50c51006c608cdde7d631b7832e71)
2013-01-22 17:48:07 +00:00
Robert Bragg
e439bdd12f atlas: catch _create_texture errors
Previously we were passing NULL to
cogl_texture_2d_new_{from_bitmap,with_size} so if there was an error the
application would be aborted. This ensures we pass an internal CoglError
so errors can be caught and suppressed instead.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit b8d1a1db482e1417979df9f88f92da47aa954bd0)
2013-01-22 17:48:07 +00:00
Robert Bragg
f53fb5e2e0 Allow propogation of OOM errors to apps
This allows apps to catch out-of-memory errors when allocating textures.

Textures can be pretty huge at times and so it's quite possible for an
application to try and allocate more memory than is available. It's also
very possible that the application can take some action in response to
reduce memory pressure (such as freeing up texture caches perhaps) so
we shouldn't just automatically abort like we do for trivial heap
allocations.

These public functions now take a CoglError argument so applications can
catch out of memory errors:

cogl_buffer_map
cogl_buffer_map_range
cogl_buffer_set_data
cogl_framebuffer_read_pixels_into_bitmap
cogl_pixel_buffer_new
cogl_texture_new_from_data
cogl_texture_new_from_bitmap

Note: we've been quite conservative with how many apis we let throw OOM
CoglErrors since we don't really want to put a burdon on developers to
be checking for errors with every cogl api call. So long as there is
some lower level api for apps to use that let them catch OOM errors
for everything necessary that's enough and we don't have to make more
convenient apis more awkward to use.

The main focus is on bitmaps and texture allocations since they
can be particularly large and prone to failing.

A new cogl_attribute_buffer_new_with_size() function has been added in
case developers need to catch OOM errors when allocating attribute buffers
whereby they can first use _buffer_new_with_size() (which doesn't take a
CoglError) followed by cogl_buffer_set_data() which will lazily allocate
the buffer storage and report OOM errors.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit f7735e141ad537a253b02afa2a8238f96340b978)

Note: since we can't break the API for Cogl 1.x then actually the main
purpose of cherry picking this patch is to keep in-line with changes
on the master branch so that we can easily cherry-pick patches.

All the api changes relating stable apis released on the 1.12 branch
have been reverted as part of cherry-picking this patch so this most
just applies all the internal plumbing changes that enable us to
correctly propagate OOM errors.
2013-01-22 17:48:07 +00:00
Robert Bragg
63db64f426 attribute: Only unref buffer for buffered attributes
constant attributes don't have a corresponding buffer so
_cogl_attribute_free shouldn't try to unref it. Also, for good measure,
in the case of constant attributes we should call
_cogl_boxed_value_destroy() (although currently we know there is no
dynamic data associated with the boxed values).

(cherry picked from commit 89d6dc90d10c59676e0deed87c2c15a0c9712737)
2013-01-22 17:48:07 +00:00
Robert Bragg
6e379fb54e attribute: Adds support for constant CoglAttributes
This makes it possible to create vertex attributes that efficiently
represent constant values without duplicating the constant for every
vertex. This adds the following new constructors for constant
attributes:

  cogl_attribute_new_const_1f
  cogl_attribute_new_const_2fv
  cogl_attribute_new_const_3fv
  cogl_attribute_new_const_4fv
  cogl_attribute_new_const_2f
  cogl_attribute_new_const_3f
  cogl_attribute_new_const_4f
  cogl_attribute_new_const_2x2fv
  cogl_attribute_new_const_3x3fv
  cogl_attribute_new_const_4x4fv

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 6507216f8030e84dcf2e63b8ecfe906ac47f2ca7)
2013-01-22 17:48:07 +00:00
Robert Bragg
56ae6f9afa progend-glsl: dirty prog for vertex state changes
_cogl_pipeline_progend_glsl_pre_change_notify and
_cogl_pipeline_progend_glsl_layer_pre_change_notify were only dirtying
the current program state for changes related to fragment processing.

This make both functions also check for changes that affect vertex
shader codegen.

This also fixes a mistake where
_cogl_pipeline_progend_glsl_layer_pre_change_notify was checking for
non-layer related changes which would never be seen, and instead it
should be checking for layer based changes only.
2013-01-22 17:48:07 +00:00
Robert Bragg
7fa04bb1a6 Adds back tex_coord array for CoglShader compatibility
This adds back compatibility for CoglShaders that reference the
cogl_tex_coord_in[] or cogl_tex_coord_out[] varyings. Unlike the
previous way this was done this patch maintains the use of layer numbers
for attributes and maintains forwards compatibility by letting shaders
alternatively access the per-layer tex_coord varyings via
cogl_tex_coord%i_in/out defines that index into the array.
2013-01-22 17:48:07 +00:00
Robert Bragg
1c449c67f6 Remove the varying array for tex_coords
This removes the need to maintain an array of tex_coord varyings and
instead we now just emit a varying per-layer uniquely named using a
layer_number infix like cogl_tex_coord0_out and cogl_tex_coord0_in.

Notable this patch also had to change the journal flushing code to use
pipeline layer numbers to determine the name of texture coordinate
attributes.

We now also break batches by using a deeper comparison of layers so
such that two pipelines with the same number of layers can now cause a
batch break if they use different layer numbers.

This adds an internal _cogl_pipeline_layer_numbers_equal() function that
takes two pipelines and returns TRUE if they have the same number of
layers and all the layer numbers are the same too, otherwise it returns
FALSE.

Where we used to break batches based on changes to the number of layers
we now break according to the status of
_cogl_pipeline_layer_numbers_equal

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit e55b64a9cdc93285049d9b969bef67484c2d9fb3)

Note: this will cause a temporary regression for the Cogl 1.x CoglShader
api since it will break compatibility with existing shaders that
reference the texture varyings from the fragment shader.

The intention is to follow up with another patch to add back
CoglShader compatibility.
2013-01-22 17:48:06 +00:00
Robert Bragg
14d8ec7cca sync cogl-blit and cogl-texture with master
This synchronizes parts of cogl-blit.c and cogl-texture.c with the
master branch to help with cherry picking patches.
2013-01-22 17:48:06 +00:00
Robert Bragg
272431e102 Check for out-of-memory when allocating 3d textures
This makes Cogl explicitly check for out-of-memory errors reported by
the opengl driver in cogl_texture_3d_new_with_size() calls. This allows
us to throw a COGL_SYSTEM_ERROR_NO_MEMORY error and return NULL so
applications may gracefully handle this condition.

This patch only affects the cogl_texture_3d_new_with_size() api not
_new_from_data() or _new_from_bitmap().

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit a602cae233b16d2ec9ad6fd238b169720467cf75)
2013-01-22 17:48:06 +00:00
Robert Bragg
31d105abd8 Check for out-of-memory when allocating 2d textures
This makes Cogl explicitly check for out-of-memory errors reported by
the opengl driver in cogl_texture_2d_new_with_size() calls. This allows
us to throw a COGL_SYSTEM_ERROR_NO_MEMORY error and return NULL so
applications may gracefully handle this condition.

This patch only affects the cogl_texture_2d_new_with_size() api not
_new_from_data() or _new_from_bitmap().

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 0283423dad59ba3d3e4cde400c29ac8e7803f888)
2013-01-22 17:48:06 +00:00
Neil Roberts
4f6fe6f0e2 Fixes for --disable-glib
This fixes some problems which were stopping --disable-glib from
working properly:

• A lot of the public headers were including glib.h. This shouldn't be
  necessary because the API doesn't expose any glib types. Otherwise
  any apps would require glib in order to get the header.

• The public headers were using G_BEGIN_DECLS. There is now a
  replacement macro called COGL_BEGIN_DECLS which is defined in
  cogl-types.h.

• A similar fix has been done for G_GNUC_NULL_TERMINATED and
  G_GNUC_DEPRECATED.

• The CFLAGS were not including $(builddir)/deps/glib which was
  preventing it finding the generated glibconfig.h when building out
  of tree.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 4138b3141c2f39cddaea3d72bfc04342ed5092d0)
2013-01-22 17:48:05 +00:00
Neil Roberts
eec0f1cd65 Add cogl_sdl_onscreen_get_window()
This adds a function to get a pointer to the SDL_Window associated
with a CoglOnscreen when using the SDL2 winsys.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 071f4b80daa8a2f967746a30b3acf014d74f781a)
2013-01-22 17:48:05 +00:00
Neil Roberts
ff11a2b207 Use GL_ARB_texture_swizzle to emulate GL_ALPHA textures
The core profile of GL3 has removed support for component-alpha
textures. Previously the GL3 driver would just ignore this and try to
create them anyway. This would generate a GL error on Mesa.

To fix this the GL texture driver will now create a GL_RED texture
when GL_ALPHA textures are not supported natively. It will then set a
texture swizzle using the GL_ARB_texture_swizzle extension so that the
alpha component will be taken from the red component of the texture.
The swizzle is part of the texture object state so it only needs to be
set once when the texture is created.

The ‘gen’ virtual function of the texture driver has been changed to
also take the internal format as a parameter. The GL driver will now
set the swizzle as appropriate here.

The GL3 driver now reports an error if the texture swizzle extension
is not available because Cogl can't really work properly without out
it. The extension is part of GL 3.3 so it is quite likely that it has
wide support from drivers. Eventually we could get rid of this
requirement if we have our own GLSL front-end and we could generate
the swizzle ourselves.

When uploading or downloading texture data to or from a
component-alpha texture, we can no longer rely on GL to do the
conversion. The swizzle doesn't have any effect on the texture data
functions. In these cases Cogl will now force an intermediate buffer
to be used and it will manually do the conversion as it does for the
GLES drivers.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 32bacf81ebaa3be21a8f26af07d8f6eed6607652)
2013-01-22 17:48:04 +00:00
Neil Roberts
05ebbfdae7 sdl: Support setting resizable before allocate in SDL 1
The SDL 1 winsys now checks for the initial resizable state of the
onscreen framebuffer when it is allocated and updates the video flags
accordingly.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f5fb9be70a92f751886a94da0b34e14252ed197e)
2013-01-22 17:48:04 +00:00
Neil Roberts
982ee75319 Fix flushing the stencil viewport clipping workaround
There were two problems with the stencil viewport clip workaround
introduced in afc5daab8:

• When the viewport is changed the current clip state is not marked as
  dirty. That means that when the framebuffer state is next flushed it
  would continue to use the stencil from the previous viewport.

• When the viewport is automatically updated due to the window being
  resized the viewport age was not incremented so the clip state
  wouldn't be flushed.

I noticed the bugs by running cogl-sdl2-hello.

This patch makes it so that the clip state is dirtied in
cogl_framebuffer_set_viewport if the workaround is enabled.

The automatic viewport changing code now just calls
cogl_framebuffer_set_viewport instead of directly prodding the
viewport values. This has the side-effect that it will also cause the
journal to be flushed. This seems like the right thing to do anyway
and presumably there would have been a bug before where it wouldn't
have flushed the journal, although presumably this is extremely
unlikely because it would have to have done a resize in the middle of
painting the scene.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 0dca99ddf728c8d4e3003861a03e8a2beccf282d)
2013-01-22 17:48:04 +00:00
Neil Roberts
9f107ab3fb Support window resizing in the SDL 2 winsys
The SDL2 winsys will now set the SDL_WINDOW_RESIZABLE flag on the
window before creating it if the resizable property is set on the
onscreen. Note that there doesn't appear to be a way in SDL to change
the flag later so unlike the other winsyses it will only take affect
if it is set before allocating the framebuffer.

The winsys now registers a callback for SDL events so that it can
report window size changes back to the application.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 0dea9aeb897faf029828379b120970477df3c7d5)
2013-01-22 17:48:04 +00:00
Adel Gadllah
41d59c0af7 cogl: Enable PBO path for all mesa versions when using intel
There seem to be other cases where the slow path is hit even with mesa 9.0.

https://bugzilla.gnome.org/show_bug.cgi?id=685915

(cherry picked from commit 6b14fa222bafb7e67c4845b26439322b34ac26a2)
2013-01-22 17:48:04 +00:00
Robert Bragg
6cfc93f26f clip-stack: workaround intel gen6 viewport clip bug
The Intel Mesa gen6 driver doesn't currently handle scissoring offset
viewports correctly, so this implements a workaround to intersect the
current viewport bounds with the scissor rectangle.

(cherry picked from commit afc5daab85e5faca99d6d6866658cb82c3954830)
2013-01-22 17:48:04 +00:00
Neil Roberts
362db1c445 Don't add the ARB suffix for the GL_ARB_map_buffer_range extension
The functions defined in the GL_ARB_map_buffer_range extension have no
suffix.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f355d0a01af9015ffdcd574477090cdc69025280)
2013-01-22 17:48:04 +00:00
Neil Roberts
7654c7cffc Make cogl_color_init_from_4fv take a const array
The passed in array isn't written to so it's more convenient to use if
it is const.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 87c02670107f00008611cbb0a8cfc97c8b6ea956)
2013-01-22 17:48:03 +00:00
Neil Roberts
6db9427e8a Use cogl_buffer_map_range from the journal
The journal maintains a cache of attribute buffers to upload the
vertices for the rectangles. The buffers are mapped to fill in the
data. However, if the previous journal was larger than the one being
flushed now then the buffers may be larger than is actually needed. In
that case we might as well only map the range that is actually used so
that the driver can potentially avoid having to set up a mapping for
the entire buffer. The COGL_BUFFER_MAP_HINT_DISCARD flag is still set
so that the driver is free to discard the entire buffer, not just the
subrange.

The _cogl_buffer_map_for_fill_or_fallback has been replaced with
_cogl_buffer_map_range_for_fill_or_fallback so that the range
parameters can be passed. The original function is now just a wrapper
around the latter.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 27769e54806dcfc1a12fdc4b07b054b8f2f4215b)
2013-01-22 17:48:03 +00:00
Neil Roberts
ec03357e88 Add cogl_buffer_map_range()
This adds a buffer method to map a subregion of the buffer. This works
using the GL_ARB_map_buffer_range extension. If the extension is not
available then it will fallback to using glMapBuffer to map the entire
buffer and then just add the offset to the returned pointer.

cogl_buffer_map() is now just a wrapper which maps the entire range of
the buffer. The driver backend functions have been renamed to
map_range and they now all take the offset and size arguments.

When the COGL_BUFFER_MAP_HINT_DISCARD hint is used and the map range
extension is available instead of using glBufferData to invalidate the
buffer it will instead pass the new GL_MAP_HINT_INVALIDATE_BUFFER
flag. There is now additionally a COGL_BUFFER_MAP_HINT_DISCARD_REGION
hint which can be used if the application only wants to discard the
small region that is mapped. glMapBufferRange is always used if it is
available even if the entire buffer is being mapped because it seems
more robust to pass those flags then to call glBufferData.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 55ca02b5ca9cafc750251ec974e0d6a536cb80b8)
2013-01-22 17:48:03 +00:00
Damien Lespiau
8a3fb7a10d context: Re-add /<* private *>/ for _COGL_N_FEATURE_IDS
Turns out gtk-doc really needs 'private' and glib-mkenums needs 'skip'.
So let's have both.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit e51206b2a9c9a582ac83fb71290524c99a8dbbb6)
2013-01-22 17:48:03 +00:00
Damien Lespiau
979a3d5517 error: Fix 'burden' typo
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 9af7dda5d7de69522b152d853ed8921c00c15f4e)
2013-01-22 17:48:03 +00:00
Damien Lespiau
08205a40e1 context: glib-mkenums chokes on /*< private >*/ but supports /*< skip >*/
The private option is really part of gtk-doc, glib-mkenums does not
support it. Use skip instead.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 015c36af27a8ce68d60f8aab6a10acdc48c5f38c)
2013-01-22 17:48:03 +00:00
Rico Tzschichholz
87e15d6693 build: fix make dist
(cherry picked from commit 6a78a8c6b6d368f2816f50e10cb9602f5c47de71)
2013-01-22 17:48:03 +00:00
Neil Roberts
76843fc529 sdl2: Fix GL3 context creation
The check to verify whether we've got the right GL context was
checking that the GL version was less than 3 whenever the non-GL3
driver is used. However it looks like the driver is free to return a
GL3 context that is compatible with GL2 if GL2 is requested so this
was breaking the GL2 driver.

This also adds the necessary SDL attributes to request a forward
compatible core context like the GLX and EGL winsys's do. I haven't
actually tested this because it looks like SDL will only create a GL
context with GLX and I haven't got a recent enough X server to handle
the glXCreateContextAttribs request.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit d46acafa3ea7ba2e6c4ac7a45f00a132df1b2872)
2013-01-22 17:48:02 +00:00
Neil Roberts
8039c2c779 Fix a warning when building the SDL2 winsys
The SDL2 winsys was using _cogl_set_error without including its header
so it was giving an annoying warning. This patch also fixes some
indentation issues.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 9c8433087b7573f7606dfae2bae3045803ead115)
2013-01-22 17:48:02 +00:00
Damien Lespiau
2582fa1519 display: Fix 'arguments' typo
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 1f30d200be65cd44dbd6f224532b9c4030d6c39c)
2013-01-22 17:48:02 +00:00
Damien Lespiau
f9c7e9d270 framebuffer: Annotate the output parameter of get_viewport4fv()
Annotate that the float* is an out parameter that points to a caller
allocated array of 4 floats.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f40b0d03d796c16c62f4937e99e16de084fc6b9a)
2013-01-22 17:48:02 +00:00
Damien Lespiau
0866b90069 object: Move cogl_object_{ref,unref}() to cogl-object.h
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit d2f07344a361c43ccdb85a0587812ca3a103078b)
2013-01-22 17:48:02 +00:00
Neil Roberts
2e77c039c9 Fix a warning when building without GLES2 support
Since commit 2701b93f cogl-pipeline-opengl.c always has code which
calls _cogl_pipeline_progend_glsl_get_attrib_location but the header
declaring this function was only included if GLES2 support was
enabled. This was making it give an annoying warning so let's just
unconditionally include it.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 34143bc6f1239c9cb22ba613521ba9ee7ec7059a)
2013-01-22 17:48:02 +00:00
Neil Roberts
bf8a1b1eda progend-glsl: Fix handling of the builtin uniforms on non-GLES2
The ‘builtin uniforms’ are added to the GLSL code generated for the
GLES2 driver to implement missing fixed functionality such as the
builtin point sprite size and the alpha test reference. Previously the
code that accessed these was #ifdef'd to be compiled only when GLES2
was enabled. However since 2701b93f part of this code is now always
used even for non-GLES2 drivers. The code that accessed the builtin
uniforms array was however no longer #ifdef'd which meant that it
wouldn't compile any more if GLES2 was not enabled. This was further
broken becase the GL3 driver actually should be using the alpha test
uniform because that also does not provide any fixed functionality for
alpha testing.

To fix this the builtin uniform array is now always compiled in and
the code to access it is always used. A new member has been added to
the array to mark which private feature the uniform is used to
replace. That is checked before updating the uniform so that under
GLES2 it will update both uniforms but under GL3 it will only update
the alpha test reference.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 5469a25413883080df75a80153accf5d9124f716)
2013-01-22 17:48:02 +00:00
Neil Roberts
2616ae0fa9 Add a GL 3 driver
This adds a new CoglDriver for GL 3 called COGL_DRIVER_GL3. When
requested, the GLX, EGL and SDL2 winsyss will set the necessary
attributes to request a forward-compatible core profile 3.1 context.
That means it will have no deprecated features.

To simplify the explosion of checks for specific combinations of
context->driver, many of these conditionals have now been replaced
with private feature flags that are checked instead. The GL and GLES
drivers now initialise these private feature flags depending on which
driver is used.

The fixed function backends now explicitly check whether the fixed
function private feature is available which means the GL3 driver will
fall back to always using the GLSL progend. Since Rob's latest patches
the GLSL progend no longer uses any fixed function API anyway so it
should just work.

The driver is currently lower priority than COGL_DRIVER_GL so it will
not be used unless it is specificly requested. We may want to change
this priority at some point because apparently Mesa can make some
memory savings if a core profile context is used.

In GL 3, getting the combined extensions string with glGetString is
deprecated so this patch changes it to use glGetStringi to build up an
array of extensions instead. _cogl_context_get_gl_extensions now
returns this array instead of trying to return a const string. The
caller is expected to free the array.

Some issues with this patch:

• GL 3 does not support GL_ALPHA format textures. We should probably
  make this a feature flag or something. Cogl uses this to render text
  which currently just throws a GL error and breaks so it's pretty
  important to do something about this before considering the GL3
  driver to be stable.

• GL 3 doesn't support client side vertex buffers. This probably
  doesn't matter because CoglBuffer won't normally use malloc'd
  buffers if VBOs are available, but it might but worth making
  malloc'd buffers a private feature and forcing it not to use them.

• GL 3 doesn't support the default vertex array object. This patch
  just makes it create and bind a single non-default vertex array
  object which gets used just like the normal default object. Ideally
  it would be good to use vertex array objects properly and attach
  them to a CoglPrimitive to cache the state.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 66c9db993595b3a22e63f4c201ea468bc9b88cb6)
2013-01-22 17:48:01 +00:00
Neil Roberts
1abf0ed55e pipeline: Don't notify the undefined progend of layer changes
When a layer changes before the pipeline has decided which progend to
use it doesn't need to notify the progend of the change. This was
causing it to crash. This patch makes that change and also simplifies
the notification a bit by just making the calls directly instead of
having three separate functions.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 2006ddd68ea6a5d53b5a810d8dbf39025d9ec04c)
2013-01-22 17:48:01 +00:00
Robert Bragg
de7416fd1d driver-gl: re-indent misleading if-else statement
There was a very, very, very misleading if else statement using no
braces for a single statement if block, followed by a blank line *and*
followed by a comment before the else which was aligned to the 'if'
column, all leading you to believe on first glance that there is no else
block. The fact that Neil and I were both separately mislead by this,
this week, is a pretty compelling reason to clarify this by deleting the
blank line, and moving the comment inside the else block.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 96d9ea78eb56269c0de5283a5302ab095d8bdfce)
2013-01-22 17:48:01 +00:00
Robert Bragg
986ba3aa79 egl: remove special re-try without stencil code
The EGL winsys had a special case code path when trying to create a
context where if it failed it would try again except without requesting
a stencil buffer. Historically this code path was to allow Clutter to
run on PowerVR MBX hardware which doesn't support a stencil buffer. It
doesn't really make sense to keep this workaround in Cogl as it would
leave Cogl in a state where the clip stack doesn't work without
providing any feedback to the developer. If we need to support running
on MBX like hardware - probably not very likely these days - then we
should provide developer control over the stencil buffer so the
equivalent workaround could be implemented on top of Cogl.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit a7c391a985e82707b17f2fb1105de5d37822a390)
2013-01-22 17:48:01 +00:00
Robert Bragg
01937201e4 Unify a lot of gles2 vs gl glsl code
Since we used to support hybrid fixed-function + glsl pipelines when
running with OpenGL there were numerous differences in how we handled
codegen and uniform updates between GLES2 and full OpenGL. Now that we
only support end-to-end glsl pipelines this patch can largely unify how
we handle GLES2 and OpenGL.

Most notably we now never use the builtin attribute names. This should
also make it easy for us to support creating strict OpenGL 3.1 contexts
where the builtin names have been removed.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 2701b93f159bf2d3387cedf2d06fe921ad5641f3)
2013-01-22 17:48:01 +00:00
Robert Bragg
62b472f4f5 add cogl-glsl-shader files to aid backporting patches
To aid with backporting patches from master made after the deprecated
CoglShader api was removed this patch adds the cogl-glsl- files that
have been added on master so we should get less conflicts when cherry
picking.
2013-01-22 17:48:01 +00:00
Robert Bragg
258aba3836 check the glsl version during init
This adds a check for the glsl version during driver init which gets
stored in ctx->glsl_major and ctx->glsl_minor.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 9bde48bda6d602dd536c3536d56d2ff7545802c3)
2013-01-22 17:48:01 +00:00
Robert Bragg
2438d70b38 driver-gl: split out parse_gl_version function
This splits out the GL version parser code from
cogl-driver-gl.c:_cogl_get_gl_version() so it can also be used for
parsing other gl version strings.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 66c2e74b9d61669fb5b93cf9a31cc8659a601fdd)
2013-01-22 17:48:00 +00:00
Neil Roberts
2bcf38d126 Fix a warning in the vtable for texture_2d_get_data
The function pointer for texture_2d_get_data in the driver vtable was
expecting an unsigned int for the rowstride but the definition in
cogl-texture-2d-gl.c took a size_t so it was giving an annoying
warning. This normalizes them both to just take an int. This seems to
better match the pattern used for cogl_bitmap_new_from_data and
cogl_texture_2d_new_from_data.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 003f080531d5368835081568779b031ef4f09a77)
2013-01-22 17:48:00 +00:00
Robert Bragg
8f3380adc3 Clearly define 3 progends that own the frag+vertends
This adds a new "fixed-arbfp" progend so we now have 3 distinct ways of
setting up the state of a pipeline:

  » fixed; where the vertex and fragment processing are implemented
    using fixed function opengl apis.
  » fixed-arbfp; where vertex processing is implemented using fixed
    function opengl apis but fragment processing is implemented
    using the ARB Fragment Processing language.
  » glsl; there vertex and fragment processing are both implemented
    using glsl.

This means we avoid unusual, combinations such as glsl for vertex
processing and arbfp for fragment processing, and also avoid pairing
fixed-function vertex processing with glsl fragment processing which we
happen to know hits some awkward code paths in Mesa that lead to poor
performance.

As part of this change, the progend now implies specific vertend and
fragend choices so instead of associating a vertend and fragend with a
pipeline we now just associate a progend choice.

When flushing a pipeline and choosing what progend to use, we now call a
progend->start() method that is able to determine if the vertend and
fragend together will be able to handle the given pipeline so the
vertend and fragend ->start() methods no longer need to return a boolean
status.

Since we now don't need to support glsl used in conjunction with fixed
function this will allow us to avoid ever using OpenGL builtin attribute
names, though this patch doesn't change that yet.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit cec381f50c7a2f2186bd4a8c5f38fecd5f099075)
2013-01-22 17:48:00 +00:00
Robert Bragg
f05a1a62f4 pipeline: tidy up definition of *END defines
There is some fairly awkward #ifdefing to determine which vertends,
fragends and progends are available at build time. This patch
consolidates the #ifdefing of vertend, fragend and progend defines to
make for slightly easier reading.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 098d6244bf7c8f2a4ca24206c6e8271d589ed4c9)
2013-01-22 17:48:00 +00:00
Robert Bragg
9fd201ffc6 pipeline: remove duplicate defines
There was a spurious duplication of the COGL_PIPELINE_VERTEND_DEFAULT
and COGL_PIPELINE_VERTEND_UNDEFINED defines which this patch removes.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 1bcf34bd3eb0134b7ef1b30cba91d3e70a23e5ed)
2013-01-22 17:48:00 +00:00
Robert Bragg
d20c8e4a71 pipeline: remove unused _MASK defines
The COGL_PIPELINE_FRAGEND_XYZ_MASK and COGL_PIPELINE_VERTEND_XYZ_MASK
defines aren't used any more so this patch simply removes them.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 119b0d771a4be2550ce1ca1e789db5b22776b066)
2013-01-22 17:48:00 +00:00
Robert Bragg
6712aaef45 pipeline: remove dubious optimization
This removes an optimization that I added at some point, which I'm
pretty certain I only added on a hunch. Reading the description I'm not
really convinced it makes sense to do this given that the fixed vertend
and fragend are currently listed before the glsl vertend and fragend in
the order that we look for a suitable backend. This means unless the
pipeline depends on glsl (e.g. due to an associated snippet) we would
reselect the fixed backend anyway, and if it really did depend on glsl
then we'd notice when we come to flush and switch backends there any way.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 071698d2c017af33e41b838429d514f5df5e02a1)
2013-01-22 17:48:00 +00:00
Robert Bragg
b1ecfbf720 buffer: splits out GL specific code
As part of an on-going effort to be able to support non-opengl drivers
for Cogl this splits out the opengl specific code from cogl-buffer.c
into driver/gl/cogl-buffer-gl.c

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 4d7094a979ff2cbbe4054f4a44ca05fc41a9e447)
2013-01-22 17:47:59 +00:00
Robert Bragg
bcf6a61d0b Give buffer/bitmap bind functions gl infix
The buffer and bitmap _bind() functions are GL specific so to clarify
that, this patch adds a _gl infix to these functions, though it doesn't
yet move the implementations out into gl specific files.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 6371fbb9637d88ff187dfb6c4bcd18468ba44d19)
2013-01-22 17:47:59 +00:00
Robert Bragg
91a02e9107 buffer: move choice about using malloc closer to driver
This moves the decision about whether a buffer should be allocated using
malloc or not into cogl-buffer.c closer to the driver since it seem
there could be other driver specific factors that might also influence
this choice that we don't currently consider.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 06d46f10bf755d3009c28904e616a0adb4586cf5)
2013-01-22 17:47:59 +00:00
Robert Bragg
ffd2cf8ef8 clip-stack: Splits out opengl specific code
As part of an on-going effort to enable non-opengl drivers for Cogl this
splits out the opengl specific code in cogl-clip-stack.c into
cogl/driver/cogl-clip-stack-gl.c

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit acf989f1bb628282c53d1249b2e3fc6f6579f1e9)
2013-01-22 17:47:59 +00:00
Robert Bragg
ae713a32d0 Adds a NOP driver
This adds a new "nop" driver that does nothing. This can be selected at
runtime either with the COGL_DRIVER=nop environment variable or by
passing COGL_DRIVER_NOP to cogl_renderer_set_driver()

Adding the nop driver gives us a way to test workloads without any
driver and hardware overheads which can help us understand how Cogl's
state tracking performs in isolation.

Having a nop driver can also serve as an shell/outline for creating
other drivers later.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 90587418233b6438290741d80aedf193ae660cad)
2013-01-22 17:47:59 +00:00
Robert Bragg
4efcd4e6a6 attribute: Split out GL specific code
As part of an on-going effort to enable non-opengl drivers for Cogl this
splits out the GL specific code in cogl-attribute.c into
cogl/driver/gl/cogl-attribute-gl.c

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 7e20c39c47fa176aa5062867ff273bc2c41a2f22)
2013-01-22 17:47:59 +00:00
Robert Bragg
ae2b064fd7 blit: avoid using _COGL_GET_CONTEXT
As part of an on-going effort to avoid depending on a global Cogl
context cogl-blit.c now finds the context by looking at
data->src_text->context instead of using the _COGL_GET_CONTEXT macro.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 3f2c99150494efc04487d0dbd17980bac20e4485)
2013-01-22 17:47:59 +00:00
Robert Bragg
4087e848c4 texture-2d: factor out all GL specific code
This factors out all of the OpenGL specific code in cogl-texture-2d.c
into cogl-texture-2d-gl.c and where necessary adds indirection through
the CoglDriver vtable so that we can eventually start to experiment with
non-OpenGL backends for Cogl.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit ec57588671696bbe7ce714bdfe7324236146c9c0)
2013-01-22 17:47:58 +00:00
Robert Bragg
8326c71b6b texture: rename texobj flush code as gl specific
This renames the set_filters and set_wrap_mode_parameters texture
virtual functions to gl_flush_legacy_texobj_filters and
gl_flush_legacy_texobj_wrap_modes respectively to clarify that they are
opengl driver specific and that they are only used to support the legacy
opengl apis for setting filters and wrap modes where the state is
associated with texture objects instead of being associated with sampler
objects.

This part of an effort to clearly delimit our abstraction over opengl so
that we can start to consider non-opengl backends for Cogl.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 6f78b8a613340d7c6b736e51a16c625f52154430)
2013-01-22 17:47:58 +00:00
Robert Bragg
ab72a2275f build: don't include deps/glib headers if glib enabled
If we're using the system glib library then we need to make sure not to
include headers under deps/glib otherwise we end up with with
incompatible typedefs that break the build.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 5d5fc97b59951ec56a4193b7ee7909ebd3cfbb94)
2013-01-22 17:47:58 +00:00
Damien Lespiau
d2c41502a4 build: Allow to build cogl without an external glib dependency
This commit pushes --disable-glib to the extreme of embedding the par of
glib cogl depends on in tree to be able to generate a DSO that does not
depend on an external glib.

To do so, it:
  - keeps a lot of glib's configure.ac in as-glibconfig.m4
  - pulls the code cogl depends on and the necessary dependencies

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-01-22 17:47:58 +00:00
Robert Bragg
df21e20f65 Adds CoglError api
Although we use GLib internally in Cogl we would rather not leak GLib
api through Cogl's own api, except through explicitly namespaced
cogl_glib_ / cogl_gtype_ feature apis.

One of the benefits we see to not leaking GLib through Cogl's public API
is that documentation for Cogl won't need to first introduce the Glib
API to newcomers, thus hopefully lowering the barrier to learning Cogl.

This patch provides a Cogl specific typedef for reporting runtime errors
which by no coincidence matches the typedef for GError exactly.  If Cogl
is built with --enable-glib (default) then developers can even safely
assume that a CoglError is a GError under the hood.

This patch also enforces a consistent policy for when NULL is passed as
an error argument and an error is thrown. In this case we log the error
and abort the application, instead of silently ignoring it. In common
cases where nothing has been implemented to handle a particular error
and/or where applications are just printing the error and aborting
themselves then this saves some typing. This also seems more consistent
with language based exceptions which usually cause a program to abort if
they are not explicitly caught (which passing a non-NULL error signifies
in this case)

Since this policy for NULL error pointers is stricter than the standard
GError convention, there is a clear note in the documentation to warn
developers that are used to using the GError api.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit b068d5ea09ab32c37e8c965fc8582c85d1b2db46)

Note: Since we can't change the Cogl 1.x api the patch was changed to
not rename _error_quark() functions to be _error_domain() functions and
although it's a bit ugly, instead of providing our own CoglError type
that's compatible with GError we simply #define CoglError to GError
unless Cogl is built with glib disabled.

Note: this patch does technically introduce an API break since it drops
the cogl_error_get_type() symbol generated by glib-mkenum (Since the
CoglError enum was replaced by a CoglSystemError enum) but for now we
are assuming that this will not affect anyone currently using the Cogl
API. If this does turn out to be a problem in practice then we would be
able to fix this my manually copying an implementation of
cogl_error_get_type() generated by glib-mkenum into a compatibility
source file and we could also define the original COGL_ERROR_ enums for
compatibility too.

Note: another minor concern with cherry-picking this patch to the 1.14
branch is that an api scanner would be lead to believe that some APIs
have changed, and for example the gobject-introspection parser which
understands the semantics of GError will not understand the semantics of
CoglError. We expect most people that have tried to use
gobject-introspection with Cogl already understand though that it is not
well suited to generating bindings of the Cogl api anyway and we aren't
aware or anyone depending on such bindings for apis involving GErrors.
(GnomeShell only makes very-very minimal use of Cogl via the gjs
bindings for the cogl_rectangle and cogl_color apis.)

The main reason we have cherry-picked this patch to the 1.14 branch
even given the above concerns is that without it it would become very
awkward for us to cherry-pick other beneficial patches from master.
2013-01-22 17:47:39 +00:00
Damien Lespiau
4a229cf708 config: Don't read a config file at startup when using --disable-glib
GKeyFile is a bit too much to import in a standalone build for my taste
as it depends on the encoding part of glib.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 9af04f0d8813b7f6f7117e1cc2a38ae2b8d04cdd)
2013-01-22 17:47:24 +00:00
Damien Lespiau
eb92b512c6 core: Don't initialize the GType system with --disable-glib
--disable-glib also defines COGL_HAS_GTYPE_SUPPORT to #ifdef out GType
support in cogl. This also means we don't want to initialize glib's type
system in that case.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 67ad777099d62bdbc8515f6ee58ed80429cc6496)
2013-01-22 17:47:24 +00:00
Robert Bragg
5d62185f1c Re-organize the source layout
As part of an effort towards being able to write non-opengl based
backends for Cogl this moves most of the opengl specific code under
drivers/gl. drivers/gl and drivers/gles have been moved to
drivers/gl/gl and drivers/gl/es respectively.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 7dc482facb0a265c7f48660079e7e12dd7a2813e)
2013-01-22 17:47:19 +00:00
Damien Lespiau
024a143cb8 stb_image: Fix warnings that the original stb_image has
Clean compiler output is a must! that also means imported source code
from other projects. I can't be bothered to submit a patch upstream,
because last time it was totally ignored by the stb_image guy.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit b43b1eac77e2f13d126e2211e12dc0c6d152716e)
2013-01-18 17:28:25 +00:00
Damien Lespiau
24fa64bea2 core: Don't use g_once_*() API
As Cogl is not thread safe, we don't really need a thread safe
cogl_init() function.

This also reduces the amount of dependency cogl has on glib, handy when
we want to create a standalone version of cogl, some day.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 429e49e3028a425eb198d8969dfbf57790e2e72a)
2013-01-18 17:28:25 +00:00
Damien Lespiau
c9fe28c93b renderer: Remove unused error from CoglRendererError
This type is not documented and is experimental. We don't use
COGL_RENDERER_ERROR_NOT_FOUND and it's pretty vague anyway, just remove
it.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit ffa78534616547b9bd4cd5c0ade8fdc039a2b977)
2013-01-18 17:28:25 +00:00
Damien Lespiau
ab91bdf12b build: Remove spurious Makefile.am
These days cogl/ has a non-recursive Makefile.am and an old one was
still present in cogl/driver.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit e1db8e38be72f5372e9d7571a3faec5039e0e6d0)
2013-01-18 17:28:25 +00:00
Robert Bragg
1161870670 matrix: Add cogl_debug_matrix_print api
As a convenience for debugging this adds a cogl_debug_matrix_print
function that prints out the components of a matrix and any internal
flags associated with the given matrix.

(cherry picked from commit 3b33889ff1204f19347a9548320ba95baa54c18c)
2013-01-18 17:28:25 +00:00
Robert Bragg
0ffad6ba20 texture-rectangle: Make new_from_foreign api public
This adds a new public cogl_texture_rectangle_new_from_foreign()
function so that we can look at removing the generic
cogl_texture_new_from_foreign().

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit af02792b336bb492c5bd11afc34a5dcd417503f6)
2013-01-18 17:28:19 +00:00
Robert Bragg
13f228fe69 Remove all remaining _EXP suffix defines
To delimit which symbols were considered experimental we used to use
some preprocessor defines to gives experimental symbols an _EXP suffix
so that anyone monitoring the ABI for changes would easily be able to
discount changes made to clearly experimental functions.

These days we simply rely on the gtk-doc "Stability: unstable"
annotation to serve this purpose because changing the actual symbol name
made it slightly more awkward to debug Cogl using GDB and was an extra
mechanical step we decided we could do without.

This patch removes the last remaining _EXP suffix defines in Cogl

(cherry picked from commit 5a1c4a979e00accd492097cfb8f6a8d0fd8331bc)
2013-01-18 10:53:29 +00:00
Robert Bragg
ce5d06afe1 framebuffer: split GL code out from cogl-framebuffer.c
This splits out most of the OpenGL specific code from cogl-framebuffer.c
into cogl-framebuffer-gl.c and extends the CoglDriverVtable interface
for cogl-framebuffer.c to use.

There are hopes to support several different backends for Cogl
eventually to hopefully get us closer to the metal so this makes some
progress in organizing which parts of Cogl are OpenGL specific so these
parts can potentially be switched out later.

The only remaining use of OpenGL still in cogl-framebuffer.c is to
handle cogl_framebuffer_read_pixels.
2013-01-18 10:53:29 +00:00
Damien Lespiau
87bc616d34 framebuffer: Support texture based depth buffers
This commit introduces some new framebuffer api to be able to
enable texture based depth buffers for a framebuffer (currently
only supported for offscreen framebuffers) and once allocated
to be able to retrieve the depth buffer as a texture for further
usage, say, to implement shadow mapping.

The API works as follow:
  * Before the framebuffer is allocated, you can request that a depth
    texture is created with
    cogl_framebuffer_set_depth_texture_enabled()
  * cogl_framebuffer_get_depth_texture() can then be used to grab a
    CoglTexture once the framebuffer has been allocated.
2013-01-18 10:53:29 +00:00
Tomeu Vizoso
5bce5f88d9 Use the correct type for GLintptr
On 32bit, intptr_t has a different type than khronos_intptr_t.

https://bugzilla.gnome.org/show_bug.cgi?id=691296
(cherry picked from commit a77222385812a696a999a871cde439f50b648f69)
2013-01-08 14:56:25 +01:00
Neil Roberts
f1baa4d60f Clear the scissor before calling glBlitFramebuffer in swap_region
glBlitFramebuffer is affected by the scissor so we need to ensure
there is an empty clip flushed before using it. This is similar to
what is done in _cogl_blit_framebuffer().

https://bugzilla.gnome.org/show_bug.cgi?id=690451

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Tested-by: Aaron Plattner <aplattner@nvidia.com>

(cherry picked from commit 65da3f88af9c7b8d72758d116c2652aff68195c1)
2013-01-07 16:37:29 +00:00
Damien Lespiau
70f71e2627 doc: Generate a valid cogl-context.xml
The automagic paragraph support of gtk-doc is way too simple to support
things like multi-paragraphs <note>s. Let's trick gtk-doc and make it
generate a valid docbook snippet for cogl-context.

Without this, cogl-context remains absent of the reference
documentation, how sad is this?!

(cherry picked from commit 606b472d91450e3221da6631020f534892e866a9)
2013-01-04 17:02:02 +00:00
Adam Jackson
f326401094 opengl: Fix conditional call of BlendFuncSeparate
Checking whether src_rgb != src_alpha twice is pointless; not checking
whether dst_rgb != dst_alpha is clearly wrong.

Found by Coverity.

Signed-off-by: Adam Jackson <ajax@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=689850

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit fc292c25db3004543e277d92693ab9cb388d2121)
2012-12-07 15:52:51 +00:00
Chun-wei Fan
491618a74c cogl-gles2-context: Cast func pointers to void* when filling
vtable

(Sorry, I had to re-apply Neil's patch as the original one somehow did
 not apply)

The function prototypes for the GL functions in CoglContext have the
GLAPIENTRY attribute which on Windows makes them use the stdcall
calling convention. The function pointers exposed from cogl-gles2.h
don't have GLAPIENTRY so they end up having a different calling
convention on Windows. When Cogl is compiled there it ends up giving a
lot of warnings because it assigns a pointer to an incompatible
function type.

We probably don't want to make the functions exposed in cogl-gles2.h
use the stdcall calling convention because we control that API so
there is no need to introduce a second calling convention. The GLES2
context support currently isn't going to work on Windows anyway
because there is no EGL or GLES2 implementation.

Eventually if we make the Cogl GLES2 context virtualized on top of
Cogl then we will provide our own implementations of all these
functions so we can easily keep the C calling convention even on
Windows.

Until then to avoid the warnings on Windows we can just cast the
function pointers temporarily to (void*) when filling in the vtable.

This will also fix the build on Windows using Visual Studio, as it is
more picky on calling convention mismatches.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-11-24 00:18:29 +08:00
Chun-wei Fan
fefa6bc929 cogl.symbols: Add symbols required for Clutter 1.12
Those symbols were missed and are needed for Clutter-1.12.x to build.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-11-24 00:01:40 +08:00
Neil Roberts
6a62e3077b sdl: Don't set SDL_GL_DOUBLEBUFFER when the swap chain has no pref
The ‘length’ for the swap chain is initially -1 which is supposed to
mean ‘no preference’. However, both of the SDL winsys's were
explicitly setting the SDL_GL_DOUBLEBUFFER attribute to zero in that
case which would try to disable double buffering.

On OS X, the equivalent to eglSwapBuffers (ie, [NSOpenGLContext
flushBuffer]) does nothing for a single buffer context. The
cogl-sdl-hello example does not specify the swap chain length so
presumably it would end up with a single buffer config. When
cogl_onscreen_swap_buffers is called it therefore does nothing and
nothing is painted.

I guess to make single-buffered contexts actually useful we should
expose some public equivalent to glFlush so that you can ensure the
rendering commands will actually hit the buffer. Alternatively we
could document that cogl_onscreen_swap_buffers performs this task on
single-buffered configs and then we could make the SDL winsys
explicitly call glFlush in that case.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 71e57f99002d5dee79bbd44b3bc57712b99acb55)
2012-11-23 15:45:26 +00:00
Rob Bradford
0e33654efb wayland: Port to new Wayland protocol
Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit db50c3015c589375029a4c26c58db8295bb17bca)
2012-10-18 17:25:21 +01:00
Neil Roberts
0edb848850 Use the right context when pushing the GLES2 context to an onscreen
Previously when pushing the GLES2 context with an onscreen framebuffer
it would just call bind_onscreen. This actually binds it with Cogl's
context so presumably the context isolation wasn't working properly.
This patch splits out bind_onscreen to have a second function called
bind_onscreen_with_context that explicitly takes the EGL context to
use. Cogl now uses this when pushing the GLES2 context.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 3653c5b10058a3f79900eb2644cb30f4cf1ca47e)
2012-10-01 15:05:22 +01:00
Neil Roberts
5e730568d4 Remove an out of date comment in the GLES2 context code
There was a FIXME comment about making glCopyTex{Sub,}Image2D work
with CoglOffscreen buffers. This has already been fixed so we should
remove the comment.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 750e5668ee64a315c8090dd2223334b1e04bee54)
2012-10-01 15:05:16 +01:00
Neil Roberts
07a50012b9 egl: Only allow GLES2 context creation for the GLES2 driver
Previously, Cogl was advertising the GLES2 context feature whenever
the EGL winsys was used, even if the winsys was used with the GL
driver. This wasn't working because when the GL context is created the
API is set to GL with eglBindAPI and it is never changed back to GLES
when the GLES2 context is created. That meant that the created context
is actually GL not GLES2. Any rendering would then fail because the GL
context does not understand the precision statement.

It could be possible to fix it so that it will set the API correctly
before creating the context. It would then also need to reset the API
and unbind the previous context whenever switching between GLES2 and
GL contexts. If the context isn't unbound first then eglMakeCurrent
will actually try to bind both contexts at the same time and at least
Mesa detects this situation and reports that the two contexts
conflict. Presumably we would also need to do something more clever
when we retrieve the function pointers for the GLES2 context.
Currently we just copy them from the CoglContext but if the context is
using the GL driver then this would mean the functions came from libGL
not libGLESv2.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 624dea207cf76ae9ccd7f57c4ebd15d3bd65bff0)
2012-10-01 15:05:11 +01:00
Neil Roberts
9563799655 Fix the terminator in one of the extension lists
The list of extension names in COGL_EXT_BEGIN should be a zero
separated list of strings which is terminated by an empty string. The
name for the GL_ARB_shader_objects extension was missing the zero
separator so presumably it was relying on the following byte to happen
to be a zero in order not to crash.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit f63381f23fa8b0b17e030561940b8a38efff221f)
2012-09-28 17:15:11 +01:00
Neil Roberts
f9e7f8df94 winsys-glx: Remove the vblank counter feature when indirect rendering
Previously when Cogl detects that the GLX context is indirect it
resets the function pointers for the VBLANK_COUNTER feature to NULL.
However it wasn't removing the VBLANK_COUNTER feature flag. Some other
parts of the winsys check for that feature flag rather than checking
whether the pointer is NULL so it would end up calling an invalid
function pointer and crashing. This just fixes it to also clear the
feature flag.

https://bugzilla.gnome.org/show_bug.cgi?id=684917

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit e947c713a541086f80a308d22774229f0720196a)
2012-09-28 17:15:11 +01:00
Chun-wei Fan
b743d95e21 Bug 682071-cogl/cogl-sdl.h: MSVC: Link to SDL when apps are built
Link to SDL.lib and SDLmain.lib if Cogl was built with the SDL winsys.

Recent changes to the SDL winsys introduced a direct dependency to
SDLmain.lib (and hence SDL.lib) when programs are built, causing linker
errors to appear when any programs using cogl (with the SDL winsys built
in) are built.

Since we cannot determine whether a Cogl build is built with the SDL winsys
at build time easily, we could use #pragma comment (lib, ...) whenever
cogl-sdl.h is included by cogl.h so that SDLmain.lib and SDL.lib is linked
into the resulting binary, so that the program can link and run correctly.

This does not add any external dependencies as the Cogl DLL already depends
on SDL.dll when it is built with the SDL winsys.
2012-09-19 15:33:47 +08:00
Neil Roberts
1b3a7ac0ab gles2-context: Don't split the wrapper snippet into two
We don't need to split the wrapper snippet into two separate parts
because it should be ok to declare the flip uniform in the middle of
the shader as long as it is somewhere in the global scope. Therefore
we can just declare it right before the definition for the replacement
main function. This is important because we don't want to put anything
at the top of the application's shader in case it is using a
'#version' directive. In that case moving it to anything other than
the first line would break things.

This patch also adds a marker in a comment around the wrapper snippet
so that we can easily locate the snippet when glGetShaderSource is
called and remove it.

The wrapper for glGetAttachedShaders has been removed because there
are no longer any additional shaders attached to the program so we can
just let GL handle it directly.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit dbd92e24ae61dcbe7ef26f61c9117c5516a7fa87)
2012-09-17 23:06:21 +01:00
Robert Bragg
5f3768f086 gles2-context: only insert prelude + wrapper into strv once
In our wrapper for glShaderSource we special case when a vertex shader
is being specified so we can sneak in a wrapper for the main function to
potentially flip all rendering upside down for better integration with
Cogl.

Previously we were appending the wrapper to all the sub-strings passed
via the vector of strings to glShaderSource but we now grow the vector
instead and insert the prelude and wrapper strings into the beginning
and end of the vector respectively so we should only have one copy for a
single shader.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit d2904d518718e3fbf4441abe2c2bcfd63edfd64b)
2012-09-17 23:06:21 +01:00
Daniel Stone
a491789637 cogl-gles2-context: Append wrapper shader to user shaders
The SGX GLSL compiler refuses to accept shaders of the form:
    void foo();
    void bar() {
        foo();
    }
where foo is undefined at glShaderSource() time, left for definition at
link time.  To work around this, simply append the wrapper shader to
user shaders, rather than building a separate shader that's always
linked with user shaders.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 96f02c445f763ace088be71dc32b3374b2cdbab2)
2012-09-17 23:06:21 +01:00
Robert Bragg
50ba5fa130 gpu-info: Match latest Mesa strings
Mesa now reports a vendor string of "Mesa Project" instead of "VMWare,
Inc." and the software rasterizer renderer string is now "Software
Rasterizer". This update cogl-gpu-info.c to recognize these new strings.

Thanks to Alexander Larsson for the original patch.

https://bugzilla.gnome.org/show_bug.cgi?id=683818

(cherry picked from commit dfacbbd96f3fbadaffa4a76dfd71c47ece6ed6a3)
2012-09-17 23:06:20 +01:00
Robert Bragg
0f0ee4a909 texture: Add a context pointer to each texture
As part of our on-going goal to remove our dependence on a global Cogl
context this patch adds a pointer to the context to each CoglTexture
so that the various texture apis no longer need to use
_COGL_GET_CONTEXT.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 83131072eea395f18ab0525ea2446f443a6033b1)
2012-09-17 23:06:20 +01:00
Robert Bragg
ea3d8eca91 Don't take internal references on the context
We want applications to fully control the lifetime of a CoglContext
without having to worry that internal resources (such as the default
2d,3d and rectangle textures, or any caches we maintain) could result in
circular references that keep the context alive. We also want to avoid
making CoglContext into a special kind of object that isn't ref-counted
or that can't be used with object apis such as
cogl_object_set_user_data. Being able to reliably destroy the context is
important on platforms such as Android where you may be required
bring-up and tear-down a CoglContext numerous times throughout the
applications lifetime. A dissadvantage of this policy is that it is now
possible to leave other object such as framebuffers in an inconsistent
state if the context is unreferenced and destroyed. The documentation
states that all objects that directly or indirectly depend on a context
that has been destroyed will be left in an inconsistent state and must
not be accessed thereafter. Applications (such as Android applications)
that need to cleanly destroy and re-create Cogl resources should make
sure to manually unref these dependant objects before destroying the
context.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 23ce51beba1bb739a224e47614a59327dfbb65af)
2012-09-17 23:06:20 +01:00
Robert Bragg
2942fd362d Avoid referencing file scope context in _context_new()
cogl_context_new() had a mixture of references to the file scope context
variable (_context) and the local (context) variable. This renames the
file scope variable to _cogl_context to catch unnecessary references to
the old name and fixes the code accordingly to reference the local
variable instead.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 33a9397ee1ae1729200be2e5084cf43cebb64289)
2012-09-17 23:06:20 +01:00
Robert Bragg
66169276f4 texture-2d: improve new_from_foreign error handling
There were lots of places where cogl_texture_2d_new_from_foreign would
simply return NULL without returning a corresponding error. We now
return an error wherever we are returning NULL except in cases where the
user provided invalid data.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit a1efc9405a13ac8aaf692c5f631a3b8f95d2f259)
2012-09-17 23:06:20 +01:00
Robert Bragg
7b5b0bef83 framebuffer: drop _ALLOCATE_FLAG_DEPTH24_STENCIL8
There are two extensions, GL_OES_packed_depth_stencil and
GL_EXT_packed_depth_stencil, that inform us that the hardware supports
packing the depth and stencil values together into one format.

The OES extension is the GLES equivalent of the EXT extension and the
two extensions provide the same enums with basically the same semantics,
except that the EXT extension is a lot more wordy due to a larger number
of features in the full OpenGL api and the OES extension has some
asymmetric limitations on when the GL_DEPTH_STENCIL and
GL_DEPTH24_STENCIL8 enums can be used as internal formats.

GL_OES_packed_depth_stencil doesn't allow the GL_DEPTH_STENCIL enum
to be passed to glRenderbufferStorage (GL_DEPTH24_STENCIL8 should be
used instead) and GL_OES_packed_depth_stencil doesn't allow
GL_DEPTH24_STENCIL8 to be passed as an internal format to glTexImage2D.

We had been handling the two extensions differently in Cogl by calling
try_creating_fbo with different flags depending on whether the OES or
EXT extension was available and passing GL_DEPTH_STENCIL to
glRenderbufferStorage when we have the EXT extension or
GL_DEPTH24_STENCIL8 with the OES extension.

To localize the code that deals with the differences between the
extensions this patch does away with the need for separate flags
so we now just have COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH_DEPTH_STENCIL and
right before calling glRenderbufferStorage we check which extension we
are using to decide whether to use the GL_DEPTH_STENCIL or
GL_DEPTH24_STENCIL8 enums.

(cherry picked from commit 88a05fac6609f88c0f46d9df2611d9fbaf159939)
2012-09-17 23:06:19 +01:00
Alban Browaeys
8d09b93572 meta-texture: Fix textures[] index
textures[iter_y.index * n_y_spans + iter_x.index]
only works for vertical rectangles when n_x_spans > 0 (ie x != {0} )

is also wrong for horizontal rectangles ( x = {0, 1, 2, 3} , y = {0, 1}
-> second line will start at 2 = iter_y.index * n_y_spans + iter_x.index
-> iteration are 0, 1, 2, 3, \n 2, 3, 4, 5 instead of 0, 1, 2, 3 \n 4, 5, 6, 7

Reviewed-by: Robert Bragg <robert@linux.inte.com>

(cherry picked from commit bf0d187f1b5423b9ce1281aab1333fa2dfb9863f)
2012-09-17 11:47:04 +01:00
Neil Roberts
cb834c95e9 pipeline: Fix the layer index used when pruning layers
When pruning a pipeline to a set number of layers it records the index
of the first layer after the given number of layers have been found.
This is stored in a variable called 'first_index_to_prune' implying
that this layer should be included in the layers to be pruned. However
the subsequent if-statement was only pruning layers with an index
greater than the recorded index so it would presumably only prune the
following layers. This patch fixes it to use '>=' instead.

https://bugzilla.gnome.org/show_bug.cgi?id=683414

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit d3063e8dea92a8f668acef6435cc68e0c901dc8d)
2012-09-07 11:44:41 +01:00
Neil Roberts
a18c97798f pipeline: Ensure the pipeline layer cache is freed when pruning layers
When pruning layers from a pipeline the pipeline cache would once be
freed due to the call to pre_change_notify but it would immediately be
recreated again when foreach_layer_internal is called. When n_layers
is later set to 0 it would end up with an invalid cache lying around.
This patch changes the order so that it will iterate the layers first
before triggering the pre-change notify so that the cache will be
cleared correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=683414

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 1c8efdc838cc5ace380365cb54e0741645856edf)
2012-09-07 11:44:41 +01:00
Neil Roberts
27d74f09df kms: Fix the version check for GBM
The check for whether to use ‘stride’ instead of ‘pitch’ from the GBM
API tries to check whether the GBM version is >= 8.1.0. However it was
comparing the major and micro components independently so any version
with the minor part set to 0 would fail. The GBM version in Mesa
master is now 9.0.0 which breaks it. This patch changes it to check
the version using the COGL_VERSION_ENCODE macro instead.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 38f1dc58b35023f9e6bbc0db746b1554bd0377fc)
2012-09-06 18:30:30 +01:00
Sjoerd Simons
cde0eb3e76 Make the default driver selectable at configure time
When building COGL with multiple backends it can be useful to force a
default driver to be selected. For example while for Debian we do want to
build the GL renderer on ARM, GLESv2 is much more suitable as the
default renderer on that platform.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 8a43aa7167b56784f7b50c557391b990861d594f)
2012-09-03 15:51:45 +01:00
Robert Bragg
ac72d0685c profile: Print warning if "Mainloop" timer missing
As a helpful aid Cogl will now print a warning if no "Mainloop" UProf
timer was setup by the application that explains that either Clutter
should be built with --enable-profile or if Clutter isn't being used
then it shows how it can create its own Mainloop timer.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 3d052dbca86bf36f30b2d60ff59b967d14665436)
2012-09-03 15:51:45 +01:00
Robert Bragg
85efcfac2a journal: Add a uprof timer around the _flush() discard
This adds a uprof timer around the _cogl_journal_discard() at the end of
_cogl_journal_flush() since this sometimes takes a significant
proportion of the time to flush the journal.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 14ffc3a197100be814452af2d0f839970353b04d)
2012-09-03 15:51:45 +01:00
Robert Bragg
c477e9ce49 debug: define COGL_DEBUG_ macros for non-debug builds
Since we only want to disable the debug features that may impact
performance when building with --disable-debug this ensures that the
COGL_DEBUG_ macros aren't defined as NOPs for non-debug builds.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit c4b50040b5c033e370eb721d1d217eced8ebdaad)
2012-09-03 15:51:45 +01:00
Robert Bragg
fb22383993 pipeline: make _GET_LAYER_NO_CREATE enum a flag
_cogl_pipeline_get_layer_with_flags accepts a CoglPipelineGetLayerFlags
flags argument and understands one COGL_PIPELINE_GET_LAYER_NO_CREATE
flag. There was a mistake with the definition of this enum though so
COGL_PIPELINE_GET_LAYER_NO_CREATE had a value of 0 and so testing for
the flag using the bitwise & operator would never find the flag set.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 5923f92f1428b3eb4977b5f21723f1b19a9d284a)
2012-09-03 15:51:45 +01:00
Robert Bragg
71f20064ab debug: ignore wireframe debug drawing for line primitives
If a primitive is already line based then we don't need to do anything
special to draw it in wireframe mode.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit fb575a42c308739a7185311a613b1a5f49dbfb39)
2012-09-03 15:51:44 +01:00
Robert Bragg
971b5cfae1 primitive: Don't leak indices
If a CoglPrimitive is associated with a set of indices then we must
unref those indices when freeing the primitive to avoid a leak.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 45cac786b55c953e44f98b864add952b9e398b13)
2012-09-03 15:51:44 +01:00
Robert Bragg
74d749eca4 kms: Update to latest gbm api
gbm_bo_get_pitch was renamed to gbm_bo_get_stride to be consistent with
how the terms pitch and stride are used throughout mesa. This updates
the Cogl backend to use the new gbm_bo_get_stride name.

For compatibility with previous version of libgbm we now explicitly
check the version of libgbm in configure.ac and expose
COGL_GBM_{MAJOR,MINOR,MICRO} defines to the code so we can conditionally
use the older gbm_bo_get_pitch() name with older versions.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 47c6247095e2f1f8725c4eb08d38c9de15e283cd)
2012-09-03 15:51:44 +01:00
Neil Roberts
ef73e6e3b9 cogl-version: Fix the 'since' tags in the documentation
The COGL_VERSION_* macros will also be in Cogl 1.12.0.

(cherry picked from commit e9473b58b80a06d3be34a4b518aade190ed9b666)
2012-09-03 15:48:05 +01:00
Neil Roberts
f13f6b9175 cogl-version: Fix the version number
The version number macros were using the @COGL_VERSION_*@
substitutions. These are always defined to 2.0.0 in the 1.x releases
so we need to use the Cogl @COGL_1_VERSION_*@ substitutions instead to
get the real version number.
2012-09-03 15:47:56 +01:00
Neil Roberts
b3f56ccb48 tex-driver-gles: Fix subregion uploads without GL_EXT_unpack_subimage
When the GL_EXT_unpack_subimage extension is not available and a
subregion of a texture is uploaded then it should first copy the
subregion to a newly allocated bitmap. However it was then later still
trying to prepare the upload using the original src_x and src_y values
which would cause an assertion failure. This patch fixes it to just
reset those to zero if the subregion is first copied.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 6f9a62db6f846f1d76e3ca16d9d8cdadf82a7009)
2012-08-29 15:01:31 +01:00
Chun-wei Fan
55e4394780 Update/fix cogl.symbols for 1.12
Update the cogl.symbols file for the 1.12 series, where symbols
were added for the following commits:

010d16f6: Adds initial GLES2 integration support
6eb88648: Add a cogl_matrix_init_from_euler function
5e8ff248: Add functions to directly transform from a euler or a quaternion
1686e754: bitmap: Adds cogl_android_bitmap_new_from_asset()
df515741: onscreen: Adds support for resizable windows
e347135b: Move cogl_wayland_display_ proto to cogl-wayland-server.h

Plus, when we branched out for 1.12, some needed symbols were missing, so
we would need to make up for them, in particular those in cogl-shader.h
and cogl-path-functions.h.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-08-17 01:20:13 +08:00
Chun-wei Fan
8dbf7ffe05 cogl/Makefile.am: Correct the way gen-enums.bat is created
Don't use --symbol-prefix cogl_gtype as we are still using the old
namespace in cogl-1.12, so there will still be the various _get_type()'s
like before

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-08-17 01:20:02 +08:00
Tomeu Vizoso
04348bda0b cogl-gles2: Install headers in cogl/ instead of in cogl2/
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-08-16 16:36:34 +01:00
Neil Roberts
32fbd0ada6 kms: Use a dummy surface instead of the surfaceless extension
The surfaceless extension that Mesa advertises has been renamed to
EGL_KHR_surfaceless_context instead of a separate extension for the
GLES, GLES2 and GL APIs and the new extension has been ratified by
Khronos. Therefore the KMS backend no longer runs against Mesa master.
We could just rename the extension we check for, however Weston (the
sample Wayland compositor) has switched to just creating a dummy GBM
surface and not using the surfaceless extension at all. We should
probably do the same thing.

Using the surfaceless extension could be a good idea but we don't
really need to rely on it for KMS and we would want to do it for all
EGL backends, not just the KMS backend.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit d4f22f8cb013d417c99ba03924538924191c2fe6)
2012-08-15 17:29:16 +01:00
Neil Roberts
51d94769be framebuffer: Take const pointers for the matrix setters
cogl_framebuffer_set_{projection,modelview}_matrix don't need to read
from the matrix argument so they should probably take a const pointer.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 710d6af053aca97935b54f9ff68858ef51f4482b)
2012-08-15 17:29:16 +01:00
Neil Roberts
41539dd7f0 bitmap: Use the 'copy' blend mode when loading images on Quartz
When loading images on Quartz, the image is rendered into a bitmap
context using a buffer allocated with
_cogl_bitmap_new_with_malloc_buffer. However this buffer is not
initialised and by default Quartz will blend the source image with the
destination so if there are transparent parts in the source image it
will leave garbage in the destination. This patch changes the blend
mode to 'copy' so that it won't try to blend.

Before 5b785dd4 the buffer was cleared because it was allocated with
g_malloc0 so it was working in that case. Presumably it should be more
efficient to disable blending and avoid the clear though.

https://bugzilla.gnome.org/show_bug.cgi?id=680124

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 5ba7f4e6837a539d92cbe45491f79a8926fd6828)
2012-08-15 17:14:25 +01:00
Sjoerd Simons
57f420e21e Remove one final user of cogl-handle and cogl-handle.h itself
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-08-15 13:46:25 +01:00
Neil Roberts
19ccb72b80 cogl-gles2-context: Wrap glCopyTex{Sub,}Image2D to flip the result
When the CoglGLES2Context is bound to read from a CoglOffscreen then
the result will be upside down from what GL expects if
glCopyTexImage2D is used directly. To fix that, this patch now wraps
glCopyTexImage2D and glCopyTexSubImage2D so that the copy is doing by
binding an FBO to the target texture and then rendering a quad
sampling from the texture in the offscreen framebuffer.

The rendering is done using the Cogl context rather than the GLES2
context because otherwise it would have to do a fair bit of work to
try and stash the old state on the context before setting up the state
to do the blit. The down side of this is that the contexts need to be
synchronized so that the rendering will be up-to-date. As far as I
understand from the GL spec, this requires a glFinish and then the
texture needs to be rebound in the new context because updates to
shared objects are guaranteed to be reflected until the object is
rebound.

GLES2 supports using glCopyTexImage2D for cube map textures. As Cogl
doesn't currently have support for cube maps, it is quite hard to get
that to work with this patch. For now attempts to copy to a cube map
texture will just be sliently ignored.

This patch also includes a test case which renders an image to the
framebuffer and then copies it to a texture. The texture is then
rendered back to the framebuffer and the contents are checked for the
correct orientation using glReadPixels.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 30b6da8134bad95267265e26685c7475f6c351c9)
2012-08-15 13:46:20 +01:00
Neil Roberts
77edc1f204 cogl-gles2-context: Keep track of extra data per texture object
This patch adds a hash table mapping texture object IDs to a struct so
that we can keep track of some of the state for each texture object.
Currently it will just track the width and height of the texture 2D
target.

Additionally it will now try to delete any texture objects that have
data created for them by the GLES2 context so that it won't leak them.
It only tracks objects that get data set on them, not all objects that
are bound because it is possible to use the GLES2 context with foreign
textures via cogl_gles2_texture_get_handle() and we don't want to
delete those.

In order to keep track of the currently bound texture object it also
needs to track the active texture unit.

Note that this state tracking will probably go wrong if GL throws an
error for invalid state. For example if glActiveTexture is called with
an invalid texture unit then GL will ignore the binding but Cogl will
assume it is valid and the state tracking will get out of sync.
Perhaps it would be good if Cogl could detect the errors but this is
difficult to do without consuming them.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit d8c72bb56cf3598fc57d629edc618f1bfa79f125)
2012-08-15 13:44:22 +01:00
Neil Roberts
8e12e40da9 cogl-gles2-context: Flip the rendering when framebuffer is offscreen
Cogl has a different origin for texture coordinates than OpenGL so
that the results of rendering to a texture should leave the top of the
image at the texture coordinate 0,0 rather than the bottom. When a
GLES2 context is used to render to a Cogl texture via a CoglOffscreen
we don't really want the application to have to be aware of the
mismatch and flip the texture coordinates. To get that to work, this
patch now tracks all of the programs that the application generates
using the context and sneaks in an extra vertex shader with an
alternative main function. This main function multiplies the final
calculated gl_Position by a vector uniform which we can use to flip
the image. When the application uploads the source code for a vertex
shader we now replace any occurrences of the token 'main' with '_c31'
and this renamed function gets called from the replacement main
function. The token has a weird name so that it will be unlikely to
conflict with a variable name in the application's source but it also
needs to have the same number of characters as the original token so
that it won't affect column numbers in the error reporting.

We are also wrapping glGetShaderSource so that we can try to revert
the token name. The same goes for the error logs just in case the
error report mentions function names.

Both places that cause drawing to occur (glDrawElements and
glDrawArrays) are now also wrapped so that we can update the uniform
value whenever the program is used with a different type of
framebuffer from last time.

We additionally need to manually track the state for the viewport, the
stencil box and the front face because all of these will be affected
by whether we are flipping the image or not. Any attempts to change
these states will be queued and instead flushed at the last minute
before drawing.

There are still some known issues with this patch:

• glCopyTexImage2D and glCopyTexSubImage2D will do the wrong thing
  when copying data from a CoglOffscreen. This could be quite fiddly
  to solve.

• Point sprites won't flip correctly. To make this work we would need
  to flip the gl_PointSprite builtin variable somehow. This is done in
  the fragment shader not the vertex shader so flipping the calculated
  gl_Position doesn't help here.

• The patch doesn't attempt to flip rendering to framebuffers for
  textures created within the GLES2 context. This probably makes sense
  because those textures are likely to be used within the GLES2
  context in which case we want to leave the texture coordinates as
  they are. However, if the texture is shared back out to Cogl with
  cogl_gles2_texture_2d_new_from_handle then the texture will be
  upside-down.

• The application can discover our secret uniform that we added via
  glGetActiveUniform. It might be worth trying to disguise this by
  wrapping that function although that could be quite fiddly.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit d589bf19e51f22c3241b2a18db10f22131ac126a)
2012-08-14 18:55:42 +01:00
Neil Roberts
0c66431df3 Add a wrapper for 'memmem'
memmem is a GNU libc extension that works like strstr except that the
size of the needle and the haystack are passed into the function
instead of using null-terminated strings.

This patch adds a wrapper function called 'cogl_util_memmem' so that
we can use this function. There is a configure check and if the
function is not available then a fallback implementation will be used.
Otherwise cogl_util_memmem is just defined to memmem.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 1dd1b0a67f6238e13f7f9253fb03addada0541b7)
2012-08-14 18:55:42 +01:00
Neil Roberts
12a1ef72c0 cogl-gles2-context: Keep some extra data for shaders and programs
All of the functions that create and destroy shaders are now wrapped
in the CoglGLES2Context so that we can track some extra data for them.
There are hash tables mapping object IDs to the corresponding data.
The data is currently not used for anything but will be in later
patches.

The glUseProgram, glAttachShader and glDetachShader functions
additionally need to be wrapped because GL does not delete shader
objects that are in use. Therefore we need to have a reference count
on the data so we can recognise when the last use has been removed.

The IDs are assumed to be specific to an individual CoglGLES2Context.
This is technically not the case because all of the CoglGLES2Contexts
are in the same share list. However we don't really want this to be
the case so currently we will assume sharing the object IDs between
contexts is undefined behaviour. Eventually we may want to actually
enforce this.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 05dc1e34785ae5f5484cd398ecc5464bd8bd3dcd)
2012-08-14 18:55:42 +01:00
Neil Roberts
0cd88bd676 cogl-gles2-context: Fix the default viewport and scissor size
In GL, the default viewport and scissor should be set to the size of
the first surface that the context is bound to. If a CoglGLES2Context
is first used with an offscreen framebuffer then this surface will
actually be the dummy 1x1 window which will mess up the defaults. To
fix that, this patch makes it just always override the viewport and
scissor the first time the context is bound to something.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 02567b3e6b64e6849b9f7c6aa2137401be7ece8d)
2012-08-14 18:55:42 +01:00
Robert Bragg
6a024acaa9 display: inc cogl-wayland-server.h if needed
Since 0773107deb9ede the prototype for
cogl_wayland_display_set_compositor_display() has moved into
cogl-wayland-server.h but cogl-display.c wasn't updated to include this
header.

(cherry picked from commit f6ccff9992fcfb9497ce91dd299460362476ba7a)
2012-08-06 18:51:34 +01:00
Robert Bragg
e347135b6a Move cogl_wayland_display_ proto to cogl-wayland-server.h
We need to avoid including wayland-server.h or wayland-client.h
indirectly when including cogl.h because there are overlapping typedef
names between the client and server wayland headers and we can't assume
whether Cogl is being used client or server side. This moves the
prototype for cogl_wayland_display_set_compositor_display() into
cogl-wayland-server.h which Cogl apps must include explicitly if the
want access to server side Cogl Wayland symbols.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 0773107deb9eded408e2801f217462c5d551f15a)
2012-08-06 18:51:34 +01:00
Neil Roberts
0e168ed0aa Fix the header guards for cogl-texture-2d{,-private}.h
The header guard for cogl-texture-2d-private.h was
__COGL_TEXTURE_2D_H. This would conflict with the header guard for
cogl-texture-2d.h except there a small typo ('TEXURE') so that it
was subtly different. This fixes them both to make more sense.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 222ec4d009973cb62020a9da05f72dea41460b33)
2012-08-06 18:51:33 +01:00
Neil Roberts
96b726b518 cogl-winsys-sdl: Fix the signature for the get_proc_address method
This function should take an extra third paramter to specify whether
the procedure is in core or not. The parameter is not used so this
patch just fixes an annoying warning.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit eed4ac80cd8c3fa1859493c9bb00547038be6095)
2012-08-06 18:51:33 +01:00
Neil Roberts
59ff396875 cogl-winsys-egl-kms: Remove some unused variables
This just gets rid of some annoying warnings.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 3d0aea04d1f6a8094b749e20a59d8a9a95a6235e)
2012-08-06 18:51:33 +01:00
Neil Roberts
5fff83cd3c cogl-texture-2d-private: Include egl-defines.h
The cogl-texture-2d-private.h header checks for the presence of
EGL_KHR_image_base before declaring
_cogl_egl_texture_2d_new_from_image. This define will only be
available if the EGL headers are included so we should make sure that
happens. This was resulting in a warning complaining that the function
was not previously declared.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit bd4840d7858efcf30eb5cf5d6fd0d39bdd59d1c1)
2012-08-06 18:51:33 +01:00
Neil Roberts
74fd618df9 Add conf vars to trick Cogl to think extensions are disabled
This adds two new configuration environment variables:

COGL_DISABLE_GL_EXTENSIONS and
COGL_OVERRIDE_GL_VERSION

The variables can also be set in the cogl.conf file using the same
names.

The first one is a list of GL extension names separated by commas.
When set Cogl will assume any extension listed here is not available
by removing it from the string returned from
glGetString(GL_EXTENSIONS). If the string is set in both the config
file and the environment variable then the union of the two lists will
be used.

The second overrides the value returned from glGetString(GL_VERSION).
If the string is set in both places the version from the environment
variable will take priority.

These are sometimes useful for debugging Cogl to test the various
combinations of extensions. It could also be useful to work around
driver bugs where an extension is badly supported and it would be
better not to use it.

The variables in cogl-config that just set a global char * variable
have been put together in an array instead of having a separate blob
of code for each one in order to make it simpler to add new variables.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit ec69c2dc576c78664e0b73879365cb7414ecf441)
2012-08-06 18:51:33 +01:00
Damien Lespiau
e5fea8b734 egl-x11: Don't use GLXDrawable on EGL
Someone trying to compile cogl (ThijsNL on irc0 for the Rasberry Pi
stumbled into that one. GLXDrawable may not be defined in a pure EGL/X
environment.

Change it to Window, the type used for XConfigureEvent.window.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit f05d6923fff28b1d167a391d486e319743c49215)
2012-08-06 18:51:33 +01:00
Neil Roberts
cbad21f0f4 pipeline: Remove the CoglPipelineFlag enum
This doesn't appear to be used anywhere in the code since it was added
in 1cc3ae69. Dead code is confusing so let's remove it.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 41928d0ac528acf4ba89b5b27d7ca7ac5501b194)
2012-08-06 18:51:33 +01:00
Tomeu Vizoso
bb258c1d42 Avoid including the EGL headers from the public Cogl headers
Otherwise, X11 identifiers may leak and cause havoc in big applications

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit ed0cdca0eca815543619fe72fbd42d662d53f92d)
2012-08-06 18:51:32 +01:00
Robert Bragg
961832164b quaternions: Allow multiplication into 'a' arg
When multiplying two quaternions, we now implicitly copy the components
of the 'a' argument so that the result can be reliably written back to
the 'a' argument quaternion without conflicting with the multiplication
itself. This is consistent with the cogl_matrix_multiply() api which
allows the 'result' and 'a' arguments to point to the same matrix. In
debug builds Cogl will assert that the 'b' and 'result' arguments don't
point to the same quaternion.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 207527313a8957789390069e84189254cf41e88f)
2012-08-06 18:51:32 +01:00
Robert Bragg
8f4dd4587e onscreen: Free swap notify callback state
When freeing a CoglOnscreen we weren't freeing the state associated with
swap notification callbacks.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 70bc12fe20fa1be4eac58356861a730f18d6b59e)
2012-08-06 18:51:32 +01:00
Robert Bragg
56382435fa stack: don't deref freed mem in _cogl_memory_stack_free
This fixes _cogl_memory_stack_free to ensure we don't dereference freed
memory as we iterate the sub-stacks to free them.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 1d27fedef9c599aa9976b809f18e0da1913cec26)
2012-08-06 18:51:32 +01:00
Robert Bragg
df51574116 onscreen: Adds support for resizable windows
This adds api to be able to request that the window system allows a
given onscreen framebuffer to be resizable, and api to add and remove
resize handlers to be called whenever the framebuffer does actually
change size.

The new functions are:
  cogl_onscreen_{get,set}_resizable()
  cogl_onscreen_{add,remove}_resize_handler()

The examples cogl-hello and cogl-x11-foreign have been updated to use
the new api. To smoke test how Cogl updates the viewport automatically
in response to window resizes the cogl-hello test doesn't explicitly
respond to resize events by setting the viewport and cogl-x11-foreign
responds by setting a viewport that is offset by a quarter of the
window's width/height and half the width and height of the window.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit a1a8cc00bfa2cecaf1007aec5f3dd95dc07b1786)
2012-08-06 18:51:32 +01:00
Neil Roberts
2ae352b0a6 Fix point sprite coordinates in shaders on GLES2
When using the GLES2 driver with a pipeline layer that has point
sprite coordinates enabled it extracts the texture coordinates from
the gl_PointCoord builtin instead of cogl_tex_coord_in[*].
gl_PointCoord is not quite the same as the regular texture coordinates
because it is only a vec2 instead of a vec4. This used to work ok
because either set of texture coordinates would always immediately be
accessed using a swizzle of '.st' so it would effectively be converted
to a vec2 anyway. However since the snippet hook for texture lookups
was added the texture coordinates are now passed to a function to
perform the actual lookup instead. This function always takes a vec4
so the shader would not compile. This patch fixes it to construct a
vec4 from gl_PointCoord by setting the third and fourth components to
0.0 and 1.0.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit cb3409b23caf324a548f82cfb88acc684cc71930)
2012-08-06 18:51:31 +01:00
Tomeu Vizoso
053845f796 framebuffer: Only remember offscreen allocate flags when !COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL
Otherwise, if a texture is created before all the other FBOs, a new
atlas will be created, with a FBO with COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL
causing last_offscreen_allocate_flags to be 0.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 7d2156785da8196e129eb393efb0d09093c4783e)
2012-08-06 18:51:31 +01:00