Commit Graph

926 Commits

Author SHA1 Message Date
Neil Roberts
b9b41723c1 cogl-pipeline: Use BSD lists for the list of pipeline children
Instead of having a separate GList for the children we can use the
linked list code from FreeBSD and store the list node directly in the
struct. That way we can avoid having a separate slice allocation for
the list node. It also means that we effectively have a pointer to the
list node given a pointer to the pipeline node. That means we can
unparent a pipeline without having to walk the entire list of
children. With this change there is no need to have the optimisation
to fast track a pipeline that only has one child which simplifies the
code somewhat.

With this patch we are removing a pointer and a gboolean from the
CoglPipeline struct and adding two pointers. On 32-bit architectures
this should end up exactly the same size because a gboolean is the
same size as a pointer. On 64-bit architectures I think it should end
up 4 bytes smaller because it also ends up removing two cases where a
pointer follows a gboolean which presumably would mean the compiler
would have to insert 4 bytes of padding to keep the pointer aligned to
8 bytes.

https://bugzilla.gnome.org/show_bug.cgi?id=652514
2011-07-01 17:58:59 +01:00
Neil Roberts
7b50c38cc8 cogl-queue: Make suitable for use in Cogl source code
This modifies cogl-queue.h so that:-

- Everything is in a COGL_* namespace

- It assumes there is a typedef for all of the types instead of
  requiring the code to use struct WhateverType.

- It doesn't contain any tabs

https://bugzilla.gnome.org/show_bug.cgi?id=652514
2011-07-01 17:52:55 +01:00
Neil Roberts
17c9cb8d49 Add the code from FreeBSD for their linked-list/queue implementation
This directly copies in the header from the FreeBSD kernel for their
linked-list implementation. A later patch will modify it but this
patch is here so we can have a clear patch to show what the
changes are.

Using the list implementation from this header is beneficial as
opposed to using GList because it's possible to embed the list
pointers directly into another struct. This saves a separate
allocation and it also makes it possible to remove an item from the
list without having to iterate the entire list to find its list
node. The header provides four different list types: single and
doubley linked lists and each of them can either have a header with
pointers to the beginning and end or just to the beginning. Glib
effectively only provides single and doubley linked lists with a
pointer to the beginning or a doubley-linked list with a pointer to
both (GQueue).

https://bugzilla.gnome.org/show_bug.cgi?id=652514
2011-07-01 17:52:55 +01:00
Neil Roberts
a517242087 gles: Fix the name of the GLeglImageOES type
The function declarations for the GL_OES_EGL_image extension were
using the wrong name for the GLeglImageOES type so it was getting
build errors when compiling for GLES.
2011-07-01 14:30:59 +01:00
Robert Bragg
f0366907d3 build: egl fix typo introduced by 3b64a439f0
The XEvent argument for event_filter_cb was named "event" but the rest
of the function is expecting a variable named "xevent".
2011-06-30 15:00:58 +01:00
Robert Bragg
5dff6f6aa1 renderer: split win32 api out into separate header
This adds a cogl-win32-renderer.h for the win32 specific cogl-renderer
API instead of having #ifdef guards in cogl-renderer.h

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:34:46 +01:00
Robert Bragg
cd6e1d183d Updates wayland symbol names to be consistent
This updates the public wayland symbols to follow the pattern
cogl_wayland_blah instead of cogl_blah_wayland.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:34:46 +01:00
Robert Bragg
89562dda73 work towards consistent platform file/symbol naming
we've got into a bit of a mess with how we name platform specific
symbols and files, so this is a first pass at trying to tidy that up.

All platform specific symbols should be named like
cogl_<platform>_symbol_name and similarly files should be named like
cogl-<platform>-filename.c

This patch tackles the X11 specific renderer/display APIs as a start.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:34:33 +01:00
Robert Bragg
3b64a439f0 replace public native_event APIs with typesafe APIs
This adds Xlib and Win32 typesafe replacements for
cogl_renderer_handle_native_event, cogl_renderer_add_native_filter,
cogl_renderer_remove_native_filter. The old functions are kept as an
implementation detail so we can share code.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:33:13 +01:00
Robert Bragg
f0a28f4287 attribute: cleanup some sentinel array left over logic
It used to be that we passed around NULL terminated arrays of
attributes, but since 3c1e83c7f we now explicitly pass an n_attributes
count instead. There were some leftovers of the old approach in the
cogl_vdraw_[indexed]_attributes functions and also there was an
off-by-one error with the n_attributes values passed on which was
causing crashes.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:33:13 +01:00
Robert Bragg
098a193802 pipeline: Avoid reseting texture target for NULL textures
When setting a NULL texture on a CoglPipeline we would also reset the
texture target to a dummy value of 0. Reseting the target also had the
effect of making fragends discard any associated program. In cases where
the NULL texture was only transient until a replacement texture could be
set we were re-running lots of redundant codegen and shader
compilations.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:33:13 +01:00
Robert Bragg
256274bfcc pipeline: fix layer change notify mutex rule
There is a documented rule that layer changes should only be notified to
the fragend once; either as a pipeline change or as a layer change. When
the number of layers associated with a material changes then that should
get notified against the pipeline. All other layer changes get notified
against the layer.

There was a mistake in the _cogl_pipeline_add/remove_layer_difference
functions, in that we weren't using the 'inc/dec_n_layers' boolean to
determine if the fragend should be notified of the change.

It was also noticed that the logic of _cogl_pipeline_prune_to_n_layers
would also break this rule, by failing to notify some changes at all.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:33:13 +01:00
Robert Bragg
b9d7181f03 buffer: Improve the CoglBuffer API description
This improves the gtk-doc overview for the CoglBuffer interface.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:33:12 +01:00
Robert Bragg
b3a105c576 renderer: Expose winsys ID setter/getters
This adds API to let you override the choice of Cogl's winsys backend.
Previously it was only possible to override the winsys using the
COGL_RENDERER environment variable, but it's useful for something like
Clutter to be able to control the winsys via API without needing
environment variable tricks. This also adds API to query back the
winsys chosen by Cogl, in case you don't set an explicit override.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:33:11 +01:00
Robert Bragg
c4eb869bd7 framebuffer: expose viewport getters/setters
This exposes experimental cogl_framebuffer APIs for getting and setting
a viewport without having to refer to the implicit CoglContext. It adds
the following experimental API:

  cogl_framebuffer_set_viewport
  cogl_framebuffer_get_viewport4fv
  cogl_framebuffer_get_viewport_x
  cogl_framebuffer_get_viewport_y
  cogl_framebuffer_get_viewport_width
  cogl_framebuffer_get_viewport_height

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:33:11 +01:00
Robert Bragg
a1234ee8d1 Add internal _cogl_init() function
This adds a _cogl_init function for Cogl that we expect to be the first
thing called before anything else is done with Cogl. It's not a public
API so it's expected that all entry points for Cogl that might be the
first function used should call _cogl_init().

We currently call _cogl_init() in these functions:
  cogl_renderer_new
  cogl_display_new
  cogl_context_new
  cogl_android_set_native_window

_cogl_init() can be called multiple times, and only the first call has
any affect.

For example _cogl_init() gives us a place check and parse the COGL_DEBUG
environment variable.

Since we don't have any need to parse command line arguments (we can
always get user configuration options from the environment) our init
function doesn't require argc/argv pointers.

By saying up front that we aren't interested in command line arguments
that means we can avoid the mess that is GOption based library
initialization which is extremely fragile due to its lack of dependency
tracking between modules.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:33:11 +01:00
Adam Jackson
5496a6464d Typo fix in cogl-framebuffer
Signed-off-by: Adam Jackson <ajax@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=652672
2011-06-16 00:27:13 +01:00
Robert Bragg
57d76e315f Fixes for make distcheck 2011-06-14 17:09:55 +01:00
Robert Bragg
036c5bf572 include required cogl-context.h in cogl-texture-2d.h 2011-06-14 17:09:55 +01:00
Robert Bragg
7a0a4de691 Fix some gtk-doc annotations in cogl-depth-state.h 2011-06-14 17:09:55 +01:00
Robert Bragg
800f5e6d6e profile: Adds a --enable-profile option
This adds a --enable-profile option which enables uprof based profiling.
It was also necessary to fixup a CLUTTER_ENABLE_PROFILING #ifdef in
cogl-context.c to renamed COGL_ENABLE_PROFILING instead. By default Cogl
doesn't output uprof reports directly, instead it assumes a higher level
toolkit will output a report. If you want a report from Cogl you can
export COGL_PROFILE_OUTPUT_REPORT=1 before running your app.

The latest version of uprof can be fetched from:
git://github.com/rib/UProf.git
2011-06-14 17:09:55 +01:00
Robert Bragg
3729bf2769 Make it clearer that the 2.0 API is experimental
This explicitly renames the cogl-2.0 reference manual to
cogl-2.0-experimental and renames the cogl-2.0 pkg-config file to
cogl-2.0-experimental.pc. Hopefully this should avoid
miss-understandings.
2011-06-14 17:09:55 +01:00
Neil Roberts
e86543cd7d Revert "Do not use "near" and "far" variables"
This reverts commit 3d2564df8f.

Since 01e1260aa the 'near' and 'far' defines are now undef'd on
Windows so we no longer have to remember not to use them in Cogl code.
2011-06-14 14:40:27 +01:00
Lionel Landwerlin
5dc42284a5 cogl-debug: add instrumentation to track the number of objects
This allows to track the number of objects allocated by Cogl. The
results are displayed on the standard output by calling :

cogl_debug_print_instances ();

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@linux.intel.com>
Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-14 12:14:02 +01:00
Robert Bragg
c603dc67ca cogl-vertex-buffer: make sure to unref weak pipelines
When validating a user pipeline before drawing with a CoglVertexBuffer
we sometimes find we have to make some overrides and we handle that by
creating a pipeline which is a weak copy of the user pipeline. The weak
pipeline gets associated with the original pipeline so if that pipeline
is used multiple times then we can re-use the same override pipeline and
skip validation. Because it's a weak pipeline we get notified when the
original material is destroyed or changed so we know our weak pipeline
is now invalid.

When we get notified that the weak material is invalid we should unref
it, but instead we were just discarding our reference to it. This was
resulting in leaking weak materials and in some cases those materials
referenced textures which would then also be leaked.
2011-06-13 17:48:23 +01:00
Emmanuele Bassi
3d2564df8f Do not use "near" and "far" variables
They collide with existing symbols when compiling on Windows.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2667
2011-06-13 12:05:41 +01:00
Neil Roberts
6d1371e0e9 cogl-texture-pixmap-x11: Fix the can_hardware_repeat wrapper
The wrapper for the can_hardware_repeat had a cut and paste error so
it would call the wrong function on the child texture.

Many thanks to Owen Taylor for finding this bug.
2011-06-10 18:43:56 +01:00
Emmanuele Bassi
552761f3a8 Remove G_CONST_RETURN
It is going to be deprecated by GLib, see bug:

  https://bugzilla.gnome.org/show_bug.cgi?id=644611
2011-06-09 16:21:15 +01:00
Neil Roberts
c3c0804819 Implement COGL_DEBUG=disable-texturing for ARBFp and GLSL fragends
The COGL_DEBUG=disable-texturing debug variable disables texturing in
the fixed function fragend by not bothering to enable the texture
targets. This wasn't working for the programmable fragends because the
texture targets don't need to be enabled to use them. This patch
modifies the two programmable backends to generate a constant value
for the texture lookups in the shader when the debug variable is
given.
2011-06-08 18:03:58 +01:00
Robert Bragg
bbfe8b8ec4 gir: pass dep cflags to gobject introspection scanner
The gobject introspection scanner was failing to find EGL headers so we
now pass the COGL_DEP_CFLAGS to Cogl_1_0_gir_CFLAGS.
2011-06-01 20:44:43 +01:00
Robert Bragg
5022ec54d2 replace _xlib_add_filter use with _cogl_renderer API
Instead of using _cogl_xlib_add/remove_filter we now use
_cogl_renderer_add/remove_native_filter. The _cogl_xlib_add_filter API
was only required as a stop gap while EGL support was still in Clutter
because in that case we were using the stub winsys and didn't have a
CoglRenderer.
2011-06-01 20:44:42 +01:00
Robert Bragg
8c35a6bb7c remove _cogl_xlib_trap/untrap_errors wrappers
This removes the redundant _cogl_xlib_trap/untrap_errors functions that
simply wrap equivalent functions in the _cogl_renderer_xlib namespace.
These were originally only required while the EGL winsys was being
handled in clutter and so there wasn't a CoglRenderer in all cases.
2011-06-01 20:44:42 +01:00
Robert Bragg
4a97fc0a1e egl: fix some #ifdef guards
In the winsys vtable .xlib_get_visual_info and
.onscreen_x11_get_window_xid should be guarded by the
COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT because they need to be there
if cogl is configured with --enable-xlib-egl-platform but not if just
configured with --enable-xlib.
2011-06-01 20:44:42 +01:00
Robert Bragg
b934859dde renderer: set winsys on renderer before ->renderer_connect
When iterating through all the possible window systems trying to find
one we can successfully connect we now associated the current winsys
vtable with the renderer before calling winsys->renderer_connect in case
the implementation calls some other Cogl API that expects to be able to
determine the current winsys. For example calling _cogl_get_proc_address
when querying winsys extensions as part of a successful connect will
need to get at the current winsys vtable.
2011-06-01 20:44:42 +01:00
Robert Bragg
656f28de2f glx: make sure _cogl_winsys_get_proc_address is static
Make sure not to export _cogl_winsys_get_proc_address outside of
cogl-winsys-glx.c
2011-06-01 20:44:42 +01:00
Robert Bragg
a29a76dbab Adds _cogl_wayland_texture_2d_new_from_buffer API
This adds internal API to be able to wrap a wayland buffer as a
CoglTexture2D. There is a --enable-wayland-egl-server option to decide
if Cogl should support this feature and potentially any EGL based winsys
could support this through the EGL_KHR_image_base and
EGL_WL_bind_display extensions.
2011-06-01 20:44:42 +01:00
Robert Bragg
8714d99300 egl: Add x11 texture-from-pixmap support
By using the EGL_KHR_image_base/pixmap extensions this adds support for
wrapping X11 pixmaps as CoglTexture2D textures. Clutter will
automatically take advantage of this if using the
ClutterX11TexturePixmap actor.
2011-06-01 20:44:42 +01:00
Robert Bragg
60b25615fd Add _cogl_egl_texture_2d_new_from_image API
This adds an internal texture_2d constructor that can wrap an EGLImage
as a CoglTexture2D. The plan is to utilize this for texture-from-pixmap
support with EGL as well as creating textures from wayland buffers.
2011-06-01 20:44:42 +01:00
Robert Bragg
c9f1541de0 egl: check or EGL/eglext.h
While running configure we now check for EGL/eglext.h and if found we
will substitute an inclusion in cogl-defines.h.
2011-06-01 20:44:41 +01:00
Robert Bragg
52aada8442 egl: Check EGL extension as early as possible
Instead of waiting until initializing a CoglContext we now check EGL
extensions after calling eglInitialize.
2011-06-01 20:44:41 +01:00
Robert Bragg
be15bf75e4 Add internal _cogl_get_proc_address
This adds an internal _cogl_get_proc_address that doesn't need a
CoglContext. This will enable us to check driver features earlier.
2011-06-01 20:44:41 +01:00
Robert Bragg
b380fed23d Make stub winsys into a proper winsys backend
Instead of the stub winsys being a special case set of #ifdef'd code
used when COGL_HAS_FULL_WINSYS wasn't defined, the stub winsys now
implements a CoglWinsysVtable like all other winsys backends (it's just
that everything is a NOP). This way we can get rid of the
COGL_HAS_FULL_WINSYS define and also the stub winsys can be runtime
selected whereas before it was incompatible with all other winsys
backends.
2011-06-01 20:44:41 +01:00
Robert Bragg
1ec8525510 cogl-xlib: remove special cases for stub winsys
Since we no longer have any xlib based backends in Clutter that depend
on the stub winsys in Cogl we can now remove all the special case code
we had for this in cogl-xlib.c
2011-06-01 20:44:41 +01:00
Robert Bragg
ee7cc9e788 Make CoglTexture2D public as experimental API
This exposes a CoglTexture2D typedef and adds the following experimental
API:
    cogl_is_texture_2d
    cogl_texture_2d_new_with_size
    cogl_texture_2d_new_from_data
    cogl_texture_2d_new_from_foreign

Since this is experimental API you need to define
COGL_ENABLE_EXPERIMENTAL_API before including cogl.h.

Note: With these new entrypoints we now expect a CoglContext pointer to
be passed in, instead of assuming there is a default context. The aim is
that for Cogl 2.0 we won't have a default context so this is a step in
that direction.
2011-06-01 20:44:41 +01:00
Robert Bragg
1e3f4f62e0 framebuffer: validate width/height in _set_viewport
This validates that the viewport width and height arguments are positive
values in _cogl_framebuffer_set_viewport. In addition, just before
calling glViewport we also assert that something else hasn't gone amiss
and that the internal viewport width/height values we track are still
positive before passing to glViewport which generates an error for
negative values.
2011-06-01 20:21:59 +01:00
Robert Bragg
5a9b92a4a5 Revert "Initial build of a Quartz winsys stub"
This reverts commit b2e41f1bfa.

We are backing out the quartz specific stub winsys since we can simply
use the generic stub winsys on quartz until we develop a standalone
winsys. Since we plan on removing all special cases for the stub winsys
by handling with a winsys vtable like all the others it's better if we
don't introduce a quartz specific stub.
2011-06-01 20:21:59 +01:00
Robert Bragg
891a9c33c5 Revert "quartz: Remove X11 ifdefs"
This reverts commit eb81ec945c.

We are backing out the quartz specific stub winsys since we can simply
use the generic stub winsys on quartz until we develop a standalone
winsys. Since we plan on removing all special cases for the stub winsys
by handling with a winsys vtable like all the others it's better if we
don't introduce a quartz specific stub.
2011-06-01 20:21:59 +01:00
Neil Roberts
efadc439a4 cogl-journal: Use a pool of vertex arrays
Previously whenever the journal is flushed a new vertex array would be
created to contain the vertices. To avoid the overhead of reallocating
a buffer every time, this patch makes it use a pool of 8 buffers which
are cycled in turn. The buffers are never destroyed but instead the
data is replaced. The journal should only ever be using one buffer at
a time but we cache more than one buffer anyway in case the GL driver
is internally using the buffer in which case mapping the buffer may
cause it to create a new buffer anyway.
2011-06-01 14:41:59 +01:00
Neil Roberts
54f94a0ed0 cogl-pipeline-fragend-fixed: Fix enabling texture targets
When flushing a pipeline that has more layers than the previous
pipeline, the fixed function fragend is supposed to detect that the
texture unit previously had no texture target enabled and then enable
it. However the logic for checking whether the unit was enabled was
broken due to a typing failure when unit->enabled and
unit->current_gl_target were combined into one value in commit
6b7139b0. This was breaking some of the conformance tests when the
fixed function fragend is used.

https://bugzilla.gnome.org/show_bug.cgi?id=650979
2011-05-27 11:59:17 +01:00
Neil Roberts
d8df30cb9c cogl-pipeline-opengl: Don't use number of tex units on fixed-function
The CoglPipeline code uses a combination of GL_MAX_TEXTURE_COORDS,
GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS and GL_MAX_TEXTURE_UNITS to
determine the maximum number of layers to allow in a pipeline. However
on fixed function hardware that doesn't advertise either GLSL or ARBfp
it was still using the first two enums which will probably just return
0 and set a GLerror. This meant that we effectively didn't support
using any layers on purely fixed function hardware. This patch changes
it to only use those two enums if the appropriate extensions are
advertised and to always use GL_MAX_TEXTURE_UNITS except on GLES2
where there is no fixed function.

https://bugzilla.gnome.org/show_bug.cgi?id=650966
2011-05-27 11:59:17 +01:00