Commit Graph

2051 Commits

Author SHA1 Message Date
Robert Bragg
8cedb43249 expose deprecated fb api regardless of COGL_ENABLE_EXPERIMENTAL_2_0_API
test-path for example uses COGL_ENABLE_EXPERIMENTAL_2_0_API to access
the 2.0 CoglPath api but also uses deprecated framebuffer api such as
cogl_push/pop_framebuffer. Similarly clutter-backend.c builds with
COGL_ENABLE_EXPERIMENTAL_2_0_API and uses cogl_set_framebuffer().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-01-09 17:10:21 +00:00
Robert Bragg
1932892b98 framebuffer: move fb stack under cogl/deprecated/
This moves the framebuffer stack apis out of cogl-framebuffer.c into
cogl/deprecated/cogl-framebuffer-deprecated.c so cogl-framebuffer.c is
more in-line with the master branch to ease cherry picking patches.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-01-09 16:29:14 +00:00
Robert Bragg
1472c5beb2 auto-texture: Adds cogl-auto-texture.h header
This moves all of the automagic texture constructor prototypes from
cogl-texture.h into a new deprecated/cogl-auto-texture.h file. This also
moves cogl_texture_new_from_sub_texture() into
deprecated/cogl-auto-texture.c

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-01-09 16:29:11 +00:00
Robert Bragg
af7398788a remove internal_format and redundant error arguments
Texture allocation is now consistently handled lazily such that the
internal format can now be controlled using
cogl_texture_set_components() and cogl_texture_set_premultiplied()
before allocating the texture with cogl_texture_allocate(). This means
that the internal_format arguments to texture constructors are now
redundant and since most of the texture constructors now can't ever fail
the error arguments are also redundant. This now means we no longer
use CoglPixelFormat in the public api for describing the internal format
of textures which had been bad solution originally due to how specific
CoglPixelFormat is which is missleading when we don't support such
explicit control over the internal format.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 99a53c82e9ab0a1e5ee35941bf83dc334b1fbe87)

Note: there are numerous API changes for functions currently marked
as 'unstable' which we don't think are in use by anyone depending on
a stable 1.x api. Compared to the original patch though this avoids
changing the cogl_texture_rectangle_new_with_size() api which we know
is used by Mutter.
2014-01-09 15:49:47 +00:00
Robert Bragg
cbd6951134 introduce texture loaders to make allocations lazy
This introduces the internal idea of texture loaders that track the
state for loading and allocating a texture. This defers a lot more work
until the texture is allocated.

There are several intentions to this change:

- provides a means for extending how textures are allocated without
  requiring all the parameters to be supplied in a single _texture_new()
  function call.

- allow us to remove the internal_format argument from all
  _texture_new() apis since using CoglPixelFormat is bad way of
  expressing the internal format constraints because it is too specific.

  For now the internal_format arguments haven't actually been removed
  but this patch does introduce replacement apis for controlling the
  internal format:

    cogl_texture_set_components() lets you specify what components your
    texture needs when it is allocated.
    cogl_texture_set_premultiplied() lets you specify whether a texture
    data should be interpreted as premultiplied or not.

- Enable us to support asynchronous texture loading + allocation in the
  future.

Of note, the _new_from_data() texture constructors all continue to
allocate textures immediately so that existing code doesn't need to be
adapted to manage the lifetime of the data being uploaded.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 6a83de9ef4210f380a31f410797447b365a8d02c)

Note: Compared to the original patch, the ->premultipled state for
textures isn't forced to be %TRUE in _cogl_texture_init since that
effectively ignores the users explicitly given internal_format which was
a mistake and on master that change should have been made in the patch
that followed. The gtk-doc comments for cogl_texture_set_premultiplied()
and cogl_texture_set_components() have also been updated in-line with
this fix.
2014-01-09 15:49:46 +00:00
Robert Bragg
3f780e2f3f get_texture_bits_via_offscreen(): use meta texture format
When reading a texture back by first wrapping it as an offscreen
framebuffer and using _read_pixels_into_bitmap() we now make sure the
offscreen framebuffer has an internal format that matches the
meta-texture being read not that of the current sub-texture being
iterated. In the case of atlas textures the subtexture is a shared
texture whose format doesn't reflect the premultipled alpha status of
individual atlas-textures, nor whether the alpha component is valid.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 6ee425d4f10acd8b008a2c17e5c701fc1d850f59)
2014-01-09 15:49:46 +00:00
Robert Bragg
99cdcc9e3c texture: make cogl_texture_get_format api private
CoglPixelFormat is not a good way of describing the internal
format of a texture because it's too specific given that we don't
actually have exact knowledge of the internal format used by the driver.

This makes cogl_texture_get_format private and in the future we'll
provide a better way of querying the channels and their precision.

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

(cherry picked from commit ffde82981f22bd0185a7f33e1e6e1479f4c295b8)

Note: Since we can't break API compatibility on the 1.x branch this adds
a cogl/deprecated/cogl-texture-deprecated.c file with a
cogl_texture_get_format() wrapper around the private api. This also
moves the cogl_texture_get_rowstride() and cogl_texture_ref/unref()
functions that were previously deprecated into cogl-texture-deprecated.c
2014-01-09 15:49:35 +00:00
Robert Bragg
bab33bf0f3 atlas: defer checks until allocation
This defers checking the internal format and whether accelerated
migration is supported until allocating the texture.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 83b05cbe3969789bc3ec78480c0937a6722efbf1)
2014-01-09 15:29:30 +00:00
Robert Bragg
46f5239664 atlas: make zero size a programmer error
Instead of throwing a CoglError exception if an application tries to
allocate a zero size atlas texture this make that a programmer error
instead.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit d3eaeedc86d408669b81d6c43ef2b0ab9d859c85)
2014-01-09 15:29:30 +00:00
Robert Bragg
40c6b1cc29 texture: allocate on slicing/hw repeat queries
The plan is to defer a lot more work in creating a texture until
allocation time. This means that for some texture backends we might not
know until after allocation whether the texture is sliced or can support
hardware repeating. This makes sure we trigger an allocation if either
of these are queried.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 4868582812dbcd5125495b312d858f751fc31e9d)
2014-01-09 15:29:30 +00:00
Robert Bragg
b9093839b4 ensure texture allocated in _get_gl_texture() in preparation
The plan is to defer a lot more work in creating a texture until
allocation time. This means we wont be able to assume that all textures
being used to render must have already been allocated when data was
specified.

The latest point at which we will generally require a texture to be
allocated will be when we need to know the underlying GL handle for a
texture and so this updates cogl_texture_get_gl_texture() to ensure the
texture is allocated.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 59f6fefc37524f492512a71b831760a218d9bb95)
2014-01-09 15:29:30 +00:00
Robert Bragg
96ed01cc18 framebuffer: defer calculating level size until allocation
The plan is to defer more of the work for creating a texture until
allocation time, but that means we won't be able to always assume
we can query the size of a texture when creating an offscreen
framebuffer from a texture (consider for example using
_texture_new_from_file() where the size isn't known until the file has
been loaded). This defers needing to know the size of the texture
underlying an offscreen framebuffer until calling
cogl_framebuffer_allocate().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 9688e7dc1eeae3144729dfd4a4bf409620346bf4)
2014-01-09 15:29:30 +00:00
Robert Bragg
08ba5c64b9 framebuffer: if size unknown; allocate for size/vp queries
This ensures framebuffers are implicitly allocated when querying the
width, height or viewport width/height if the framebuffer's size is
currently unknown. The plan is to allow texture backends to defer
calculating the size of textures until they are allocated which in turn
means we won't know the size of offscreen framebuffers until the texture
has been allocated. Potentially we could be more specific about this in
the future and only ensure the texture is allocated, but for now it will
be simplest to just ensure the framebuffer is allocated.

Note: in the case of onscreen buffers which are always initialized with
a requested size we are careful to avoid triggering an allocation when
this is queried otherwise we will see recursion when the winsys code
queries the requested size during allocation.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit f4b612f1b75e043f1852b9a32368cc37ab89308b)
2014-01-09 15:29:30 +00:00
Robert Bragg
a07d26e9ae offscreen: allocate texture before querying slicing
Since we are planning on deferring more texture allocation work this
makes sure we don't query whether a texture is sliced until we know it
has been allocated.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit b742638a1ce581f5a2c9f15907361c3b0c1b178c)
2014-01-09 15:29:30 +00:00
Robert Bragg
2e61318914 framebuffer: make format internal
This removes cogl_framebuffer_get_color_format() since the actual
internal format isn't strictly controlled by us. CoglFramebuffer::format
has been renamed to ::internal_format to make it clearer that it only
really represents the premultiplication status.

The plan is to make most of the work involved in creating a texture
happen lazily when allocating so this patch also changes
_cogl_framebuffer_init() to not take a format argument anymore since we
won't know the format of offscreen framebuffers until the framebuffer is
allocated, after the corresponding texture has been allocated. In the
case of offscreen framebuffers we now update the framebuffer
internal_format during allocation.

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

(cherry picked from commit 8cc9e1c8bd2fac8b2a95087249c23c952d5e379f)

Note: Since we can't break API compatibility on the 1.x branch this
actually keeps the cogl_framebuffer_get_color_format() api but moves it
into a new deprecated/cogl-framebuffer-deprecated.c file and it now
returns the newly name ::internal_format.
2014-01-09 15:29:30 +00:00
Robert Bragg
8f19d01815 macros: Add 1.18 deprecation macros 2014-01-09 15:29:30 +00:00
Robert Bragg
3083ff6877 version: Add COGL_VERSION_1_18 define 2014-01-09 15:29:30 +00:00
Adel Gadllah
0af4105458 winsys-glx: Fix swap region to remain disabled for old mesa
Commit a750f80c6a was supposed to enable it for newer mesa but was wrong,
fix that.
2014-01-06 22:02:16 +01:00
Adel Gadllah
a750f80c6a winsys-glx: Reenable swap_region for llvmpipe and swrast
The bug that prevented MESA_copy_sub_buffer to work for swrast /
llvmpipe got fixed in mesa 10.1 git so enable it for mesa 10.1+.

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

When landing the patch, it was tweaked to #include "cogl-version.h" to
avoid a compiler warning about COGL_VERSION_ENCODE being implicitly
defined. -- Robert Bragg

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit e7e216b1d3d151acf3fed619bd759692a989b4b4)
2014-01-06 17:17:17 +00:00
Robert Bragg
52a69bb9ab Build and install cogl-path as a shared library
Since we now have more time to ensure that Clutter is updated to check
for the now separate cogl-path package as part of its build
configuration we are now making the package split, in line with Cogl
master.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-12-11 18:49:19 +00:00
Robert Bragg
a0bc2d96be Make cogl-sdl.h a top-level header
This makes it so that cogl-sdl.h is a top-level header no longer
automatically included by cogl.h. This avoids lots of warnings building
the conformance tests and examples due to SDL.h warning when
__STRICT_ANSI__ isn't defined.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit f7536985437dc85c26b33d1bbe1b7f3d4b32476a)
2013-12-11 18:49:19 +00:00
Jasper St. Pierre
1b0d0f3892 cogl-framebuffer: Don't mark the clear clip dirty from the journal
This means that we can't cache the journal read_pixels optimization.

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

Reviewed-by: Neil Roberts <neil@linux.intel.com>
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 550bae22d20c8d6d7cf1d090faa9c91619594077)
2013-12-04 18:38:44 +00:00
Neil Roberts
24412798dc Revert "Revert "Remove the framebuffer's stack of clip stacks""
This reverts commit bc41489336.

The reason this was causing problems for Clutter is that it defines
COGL_ENABLE_EXPERIMENTAL_2_0_API which is meant to cause the Cogl
headers not to declare the deprecated API. The reverted patch moved
some additional clipping API to a deprecated header which was
previously being used by Clutter. Clutter was still successfully
compiling but with some warnings for the missing function
declarations. However when the binary is run the clipping would get
completely messed up because it would assume all of the arguments to
the functions are integers instead of floats and the wrong values
would be passed.

Clutter now has commit to make it use the 2.0 API instead of the
deprecated functions so the revert is no longer necessary.

https://git.gnome.org/browse/clutter/commit?id=705640367a5c2ae21405806bfa

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-12-04 17:22:01 +00:00
Neil Roberts
0596fe8020 Fix calculating the bounds when clipping from a primitive
When projecting the bounding rectangle of a primitive it was using the
modelview matrix twice instead of the modelview and projection
matrices so it was coming out with garbage.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 7e1f05c84013bb91248d691091df00f4f634c6cf)
2013-12-03 15:28:35 +00:00
Jasper St. Pierre
bc41489336 Revert "Remove the framebuffer's stack of clip stacks"
This reverts commit ae9cd7ca01.

Pushing this for now so we can get gnome-shell working again without
memory corruption. Let's push a proper fix later for everybody.
2013-12-02 23:32:48 -05:00
Neil Roberts
833ed7ebc1 Remove cogl2-compatibility.c
This was added in 361bd516f3 late during the 1.10 cycle to
contain experimental functions that we should never have made public.
The plan was to remove them once we started working on 1.12 but it
looks like we never got around to doing that. Better late than never!

The header for the file was already removed in 7365c3aa77.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-12-02 17:05:30 +00:00
Neil Roberts
ae9cd7ca01 Remove the framebuffer's stack of clip stacks
There used to be a function called cogl_clip_stack_save in the public
API which was used when temporarily switching to an offscreen buffer
to save the clip state. This is no longer necessary because each
framebuffer has its own clip stack anyway so the function was removed
in master. However the code to maintain the stack of stacks was
retained. This patch removes it in an effort to simplify the code.

On the 1.18 branch this function is deprecated and the documentation
says that it does nothing. However that is incorrect because it does
actually the push clip stack. I think it would be safe to backport
this patch to the 1.18 branch and actually make it do nothing like it
is documented to do.

https://bugzilla.gnome.org/show_bug.cgi?id=719546
(cherry picked from commit 8655027fdcf03b02fcbbb02d179a0a88ed79c5b3)

This patch has some extra changes while backporting to the 1.18
branch. Here the cogl-clip-state file still contained some deprecated
functions. Instead of deleting the file completely it has been moved
to the deprecated folder. The declarations for this functions have
been moved from cogl1-context.h to a new deprecated/cogl-clip-state.h
header.

Conflicts:
	cogl/Makefile.am
	cogl/cogl-clip-state.c

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-11-29 16:35:58 +00:00
Neil Roberts
a29b8c475e wayland: Add a convenience function to update a region from SHM buffer
Adds cogl_wayland_texture_set_region_from_shm_buffer which is a
convenience wrapper around cogl_texture_set_region but it uses the
correct format to copy the data from a Wayland SHM buffer. This will
typically be used by compositors to update the texture for a surface
when an SHM buffer is attached. The ordering of the arguments is based
on cogl_texture_set_region_from_bitmap.

Based on a patch by Jasper St. Pierre.

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

Conflicts:
	examples/cogland.c
2013-11-28 18:12:22 +00:00
Neil Roberts
5ef1020e8a Revert "cogl-texture-2d: Add update_area equivalent for Wayland"
This patch was accidentally added before it had any review and without
first going through master. Master now has a replacement patch with
some modifications. That will be cherry-picked to the 1.18 branch in a
subsequent commit.

This reverts commit af480a2b8b.
2013-11-28 18:12:22 +00:00
Neil Roberts
c5644723f8 Use COGL_FLAGS_* for the context's private feature flags
Previously the private feature flags were stored in an enum and we
already had 31 flags. Adding the 32nd flag would presumably make it
add -2³¹ as one of the values which might cause problems. To avoid
this we'll just use an fixed-size array of longs and use indices for
the enum values like we do for the public features.

A slight complication with this is in the CoglDriverDescription where
we were previously using a static intialised value to describe the set
of features that the driver supports. We can't easily do this with the
flags array so instead the features are stored in a fixed-size array
of indices.

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

Conflicts:
	cogl/cogl-context-private.h
	cogl/cogl-context.c
	cogl/cogl-private.h
	cogl/cogl-renderer.c
	cogl/driver/gl/cogl-pipeline-opengl.c
	cogl/driver/gl/gl/cogl-driver-gl.c
	cogl/driver/gl/gl/cogl-pipeline-progend-fixed-arbfp.c
	cogl/driver/gl/gles/cogl-driver-gles.c
	cogl/driver/nop/cogl-driver-nop.c
2013-11-28 18:12:22 +00:00
Robert Bragg
31a9726506 build: fix building introspection data
This fixes the build with --enable-introspection. I'm not sure why
g-ir-scanner seems to parse all public headers in isolation instead of
being able take a more limited list of top-level public headers and
automatically parse all necessary #include directives but this means we
have to special case how we define and undefine __COGL_H_INSIDE__ to
subvert the guards we have in place for detecting misuse of the headers.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit e0b2255876c1cf11d124d5ae37cbe9a6e43777f1)
2013-11-28 16:59:55 +00:00
Robert Bragg
6436cd073d Declare interface types as void and remove cast macros
This declares the interface types CoglFramebuffer, CoglBuffer,
CoglTexture, CoglMetaTexture and CoglPrimitiveTexture as void when
including the public cogl.h header so that users don't have to use lots
of C type casts between instance types and interface types.

This also removes all of the COGL_XYZ() type cast macros since they do
nothing more than compile time type casting but it's less readable if
you haven't seen that coding pattern before.

Unlike with gobject based apis that use per-type macros for casting and
performing runtime type checking we instead prefer to do our runtime
type checking internally within the front-end public apis when objects
are passed into Cogl. This greatly reduces the verbosity for users of
the api and may help reduce the chance of excessive runtime type
checking that can sometimes be a problem.

(cherry picked from commit 248a76f5eac7e5ae4fb45208577f9a55360812a7)

Since we can't break the 1.x api this version of the patch actually
defines compatible NOP macros within deprecated/cogl-type-casts.h
2013-11-27 19:33:44 +00:00
Neil Roberts
d24f632d91 Revert "framebuffer: Don't mark the clip dirty at mid scene"
This patch doesn't look right because now nothing will ever set
clear_clip_dirty = TRUE. Presumably that would mean that if a
rectangle is drawn and then the journal is flushed before the
framebuffer is read, then it would think it could return the clear
color even though it shouldn't.

Perhaps a better approach would be to make a second version of
_cogl_framebuffer_mark_mid_scene that doesn't set the clear_clip_dirty
flag and call that from the journal instead. As this patch was pushed
without review and without first going into the master branch I think
it makes sense to just revert it and apply a new version to master.

This reverts commit 3eb63f67a3.
2013-11-21 12:12:21 +00:00
Jasper St. Pierre
08ee344fa5 Revert "framebuffer: Fix clip tracking in the unclipped case"
This broke gnome-shell's StScrollViewFade.

This reverts commit 5c5715f4da.
2013-11-19 18:09:55 -05:00
Jasper St. Pierre
af480a2b8b cogl-texture-2d: Add update_area equivalent for Wayland 2013-11-18 00:43:51 -05:00
Jasper St. Pierre
5c5715f4da framebuffer: Fix clip tracking in the unclipped case
Leaving the clip bounds untouched means that it will retain the stale value
of whatever it was when we last had a clip; reset it so that it contains the
full framebuffer contents instead.

https://bugzilla.gnome.org/show_bug.cgi?id=712562
2013-11-18 00:43:51 -05:00
Jasper St. Pierre
3eb63f67a3 framebuffer: Don't mark the clip dirty at mid scene
https://bugzilla.gnome.org/show_bug.cgi?id=712562
2013-11-18 00:43:50 -05:00
Hans Petter Jansson
a8e04a7d6b Add API to control per-framebuffer depth writing
Add framebuffer methods cogl_framebuffer_[gs]et_depth_write_enabled()
and backend bits to pass the state on to glDepthMask().

This allows us to enable or disable depth writing per-framebuffer, which
if disabled saves us some work in glClear(). When rendering, the flag
is combined with the pipeline's depth writing flag using a logical AND.

Depth writing is enabled by default.

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 71406438c5357eb4e0ef03e940c5456a536602a0)
2013-10-28 16:34:58 +00:00
Robert Bragg
18486a6aa9 egl: forward declare wl_resource for compatibility
Depending on what version of Mesa you have then eglQueryWaylandBuffer
may take a wl_buffer or wl_resource argument and the EGL header will
only forward declare the corresponding type.

The use of wl_buffer has been deprecated and so internally we assume
that eglQueryWaylandBuffer takes a wl_resource but for compatibility we
forward declare wl_resource in case we are building with EGL headers
that still use wl_buffer.

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

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 9bd1ee544667cfe7ecae479ec7f778446dd8f326)
2013-10-28 16:34:58 +00:00
Chun-wei Fan
e0e3eba0dd cogl.symbols: Make Sure cogl_is_atlas_texture is Exported
cogl_is_atlas_texture is supposed to be exported from the DLL/.so, so
update the cogl.symbols file to ensure this.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 13e037f096de5742db769500b4c0018249d8f8e4)
2013-10-28 16:34:57 +00:00
Robert Bragg
c1724eff60 framebuffer: NOP _set_color_mask if mask isn't changing
This makes cogl_framebuffer_set_color_mask immediately bail out if the
given mask equals the framebuffer's current mask, since the cost of
flushing the journal and flushing the gl state will hugely outweigh the
cost of the check.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 925174d99df7f1f4b11098e748bcc23eaa396a21)
2013-10-28 16:34:57 +00:00
Robert Bragg
8d998b64c9 util: simplify _COGL_STATIC_ASSERT definition
This updates the definition of _COGL_STATIC_ASSERT to just use
_Static_assert if available or be NOP if not. We no longer worry about
supporting static assertions with older compilers. This fixes some
verbose warnings that newer compilers were giving with the old typedef
based static assertion method.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 645e3607ea7f210d6dcb9d217204790051de7c82)
2013-10-28 16:34:57 +00:00
Robert Bragg
669b3ad864 pipeline: notify all progends of changes
When a pipeline is notified of a change we now make sure to notify all
progends of that change not just the progend directly associated with
that pipeline. A pipeline can have private state associated with it from
multiple progends because descendants will always try and cache state on
ancestors to maximize the chance that the state can later be re-used.
Descendants may be using different progends than the ancestors that they
cache state with.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 873939a18934185fb3c9c84c373cb86d1278add7)
2013-10-28 16:34:57 +00:00
Robert Bragg
a93e789a7c Avoid conflicting client/server wayland includes
This avoids including wayland-server.h in cogl-display-private.h which
avoid lots of compile time warnings that wl_buffer is deprecated. The
problem is that wl_buffer is also exposed in the client side headers and
isn't deprecated for clients. If we end up including the client and
server headers in the same compilation unit we can get conflicting
definitions.

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

(cherry picked from commit 60fcd9c87cf5d8ae8c41134217ee0e1fa2fbd46e)
2013-10-28 16:34:57 +00:00
Neil Roberts
8392420244 wayland-server: Use wl_resource instead of wl_buffer
wl_buffer has been deprecated in the server API and instead
compositors should be directly passing the wl_resource pointer to
eglQueryWaylandBuffer.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit f13278bcf3f1475b7afc7d55a5218f409d119658)
2013-10-24 17:39:40 +01:00
Emilio Pozuelo Monfort
9bbb8a79c3 Fix build on big-endian
Commit 50d1285b updated the wl_shm enum values but left
one out. Update it to fix the build on big-endian.

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

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 9246286846d0428b03e646b2f5ec14f0eff4edc6)
2013-10-15 19:07:50 +01:00
Robert Bragg
fa855b7c45 Start clearly separating deprecated code
This makes a start on clearly factoring the deprecated code of core Cogl
into a deprecated/ directory. Ideally we want to get to the point where
all code here can be re-worked in terms of the public 2.0 api so that it
can be kept indefinitely for cogl 1.x api compatibility without
cluttering the core code base itself. If we can do this then we can
avoid maintaining the Cogl 1.x branches in parallel with master which
would reduce the maintenance effort.
2013-09-23 18:38:49 +01:00
Robert Bragg
3b14acdbcc remove spurious COGL_GTYPE_DEFINE_CLASS reference
Commit 7b25c8f5ca mistakenly added a reference to a
COGL_GTYPE_DEFINE_CLASS() macro that does not yet exist so this patch
removes it.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-09-23 18:37:29 +01:00
Lionel Landwerlin
d33f8ca070 texture: add missing annotations
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
fbba3478a8 fence: add scope annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
84bdd679df buffer: add missing transfer annotations
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
c1597a3364 pixel-buffer: add missing transfer annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
bd69f5963c frame-info: add missing annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
Lionel Landwerlin
232842c1f7 matrix-stack: add missing transfer annotation
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2013-09-23 15:02:31 +01:00
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