Commit Graph

587 Commits

Author SHA1 Message Date
Emmanuele Bassi
73a94a7a79 Replace cogl_color_set_from_* with cogl_color_init_from_*
The former is not yet "officially" deprecated by the latter, but it's
confusing to have them both in the code base.
2010-09-03 16:58:47 +01:00
Emmanuele Bassi
b12f688415 docs: Fixes for gtk-doc 2010-09-03 16:12:24 +01:00
Emmanuele Bassi
08eb738c93 build: Use Makefile.introspection
Whenever possible, instead of writing our own rules for generating GIR
files and typelibs.
2010-09-03 11:38:22 +01:00
Colin Walters
d4d899fa27 introspection: Build fixes
This patch merges in substantial work from
Emmanuele Bassi <ebassi@linux.intel.com>

* Use new introspection --include-uninstalled API since we don't want
  to try to find the clutter-1.0.pc file before it's installed.
* Use --pkg-export for Clutter-1.0.gir, since we want the .gir file to
  contain the associated pkg-config file.
* Drop the use of --pkg for dependencies; those come from the associated
  .gir files.  (Actually, --pkg is almost never needed)
* Add --quiet

http://bugzilla.clutter-project.org/show_bug.cgi?id=2292
2010-09-03 11:38:22 +01:00
Damien Lespiau
7e158c6bc5 cex100: Add a Clutter EGL backend for CE3100/CE4100 SoCs
Intel CE3100 and CE4100 SoCs are designed for TVs. They have separate
framebuffers that are blended together by a piece of hardware to make
the final output. The library that allows you to initialize and
configure those planes is called GDL. A EGL GDL winsys can then be
use with those planes as NativeWindowType to select which plane to use.

This patch adds a new ClutterBackendCex100 backend that can be
selected at compile time with the new --with-flavour=cex100 option.
2010-09-03 11:13:35 +01:00
Damien Lespiau
7367188ab5 egl: Fix compilation for EGL native
Some minor fixes here and there: missing include, wrongly placed #endif,
unused variable warning fixes, missing #ifdef.

Make ClutterStageEGL a subclass of either ClutterStageX11 or GObject
depending if you compile with X11 support (EGLX) or not (native).
2010-09-03 11:13:35 +01:00
Robert Bragg
90f633dd8d material: Implements weak materials
Weak materials are ones that don't take a reference on their parent and
they are associated with a callback that notifies when the material is
destroyed, because its parent was freed or modified.

More details can be found at:
http://wiki.clutter-project.org/wiki/CoglDesign/CoglMaterial

For now the concept is internal only but the plan is to make this public
at some point once we have tested the design internally.
2010-08-13 16:23:19 +01:00
Robert Bragg
63fd426b4b cogl-shader: get_info_log should always use strdup
In the case where there is no error log for arbfp we were returning a
"" string literal. The other paths were using g_strdup to return a
string that could be freed with g_free. This makes the arbfp path return
g_strdup ("") instead.
2010-08-12 16:50:47 +01:00
Robert Bragg
a0247f294d cogl-shader: correctly #ifdef guard an if else block
There are quite a few if {} else {} blocks for dealing with arbfp else
glsl and the first block is guarded with #ifdef HAVE_COGL_GL. In this
case though the #endif was before the else so it wouldn't compile for
gles.
2010-08-12 16:50:47 +01:00
Robert Bragg
13e7260868 material-glsl: #include "cogl-shader-private.h"
We need to include cogl-shader-private.h to have the
COGL_SHADER_TYPE_GLSL define. When building for opengl this wasn't
noticed probably because some other header indirectly includes this
file. It was a problem when building for gles2 though.
2010-08-12 16:50:47 +01:00
Robert Bragg
8d80a88e14 cogl-program: Adds use_uniform_xyz methods
Instead of exposing an API that provides an OpenGL state machine style
where you first have to bind the program to the context using
cogl_program_use() followed by updating uniforms using
cogl_program_uniform_xyz we now have uniform setter methods that take an
explicit CoglHandle for the program.

This deprecates cogl_program_use and all the cogl_program_uniform
variants and provides the following replacements:
    cogl_program_set_uniform_1i
    cogl_program_set_uniform_1f
    cogl_program_set_uniform_int
    cogl_program_set_uniform_float
    cogl_program_set_uniform_matrix
2010-08-12 16:50:46 +01:00
Damien Lespiau
64b5308d7f introspection: Use the --quiet flag conditionally
--quiet has been added to g-ir-scanner in the 0.9.1 cycle. We really
want to be able to compile clutter with 0.6.14 to be able to reuse
gir files that are distributed in current distributions.

Use the INTROSPECTION_SCANNER_ARGS (previously unused) variable to
convey --quiet when necessary.

Fixes: http://bugzilla.clutter-project.org/show_bug.cgi?id=2265
2010-08-12 16:43:07 +01:00
Neil Roberts
717cb2c47f cogl-atlas: Verify that the chosen initial size is supported
CoglAtlas chooses a fairly large default initial size of either
512x512 or 1024x1024 depending on the texture format. There is a
chance that this size will not be supported on some platforms which
would be catastrophic for the glyph cache because it would mean that
it would always fail to put any glyphs in the cache so text wouldn't
work. To fix this the atlas code now checks whether the chosen initial
size is supported by the texture driver and if not it will get halved
until it is supported.
2010-08-12 11:57:00 +01:00
Neil Roberts
b4240cba29 cogl-atlas: Use _cogl_texture_driver_size_supported
Previously when creating a new rectangle map it would try increasingly
larger texture sizes until GL_MAX_TEXTURE_SIZE is reached. This is bad
because it queries state which should really be owned by the texture
driver. Also GL_MAX_TEXTURE_SIZE is often a conservative estimate so
larger texture sizes can be used if the proxy texture is queried
instead.
2010-08-12 11:57:00 +01:00
Neil Roberts
1e72ba4932 cogl-rectangle-map: Record largest gap rather than the remaining space
Previously each node in the rectangle map tree would store the total
remaining space in all of its children to use as an optimization when
adding nodes. With this it could skip an entire branch of the tree if
it knew there could never be enough space for the new node in the
branch. This modifies that slightly to instead store the largest
single gap. This allows it to skip a branch earlier because often
there would be a lot of small gaps which would add up to enough a
space for the new rectangle, but the space can't be used unless it is
in a single node.

The rectangle map still needs to keep track of the total remaining
space for the whole map for the debugging output so this has been
added back in to the CoglRectangleMap struct. There is a separate
debugging function to verify this value.
2010-08-12 11:57:00 +01:00
Neil Roberts
0aaea4a93a cogl-atlas: Try the next size when there would be less than 6% waste
Previously when the atlas needs to be migrated it would start by
trying with the same size as the existing atlas if there is enough
space for the new texture. However even if the atlas is completely
sorted there will always be some amount of waste so when the atlas
needs to grow it would usually end up redundantly trying the same size
when it is very unlikely to fit. This patch changes it so that there
must be at least 6% waste available after the new texture is added
otherwise it will start with the next atlas size.
2010-08-12 11:57:00 +01:00
Neil Roberts
c6b6f619a9 cogl-atlas: Add some more debugging notes
This adds some debugging notes which report when the atlas is trying
various sizes.
2010-08-12 11:57:00 +01:00
Neil Roberts
74b6484812 cogl-rectangle-map: Use a GArray for the stack
When iterating over the rectangle map a stack is used to implement a
recursive algorithm. Previously this was slice allocating a linked
list. Now it uses a GArray which is retained with the rectangle map to
avoid frequent allocations which is a little bit faster.
2010-08-12 11:56:59 +01:00
Neil Roberts
9a62c069aa cogl-rectangle-map: Store the remaining space per node
Previously the remaining space was managed as part of the
CoglRectangleMap struct. Now it is stored per node so that at any
point in the hierarchy we can quickly determine how much space is
remaining in all of the node's children. That way when adding a
rectangle we can miss out entire branches more quickly if we know that
there is no way the new rectangle would fit in that branch.

This also adds a function to recursively verify the cached state in
the nodes such as the remaining space and the number of
rectangles. This function is only called when the dump-atlas-image
debug flag is set because it is potentially quite slow.
2010-08-12 11:56:59 +01:00
Neil Roberts
92b712f6e4 cogl-atlas: Increase the default minimum texture size
When initially creating a texture it would start with a minimum size
of 256x256. This increases the size so that it would try to match 1MB
of memory.
2010-08-12 11:56:59 +01:00
Neil Roberts
bbac324356 cogl-atlas: Support multiple formats and clearing the texture
_cogl_atlas_new now has two extra parameters to specify the format of
the textures it creates as well as a set of flags to modify the
behavious of the atlas. One of the flags causes the new textures to be
cleared and the other causes migration to avoid actually copying the
textures. This is needed to use CoglAtlas from the pango glyph cache
because it needs to use COGL_PIXEL_A_8 and to clear the textures as it
does not fill in the gaps between glyphs. It needs to avoid copying
the textures so that it can work on GL implementations without FBO
support.
2010-08-12 11:56:59 +01:00
Neil Roberts
b2f2e69264 cogl-atlas-texture: Split out the atlas data structure
Instead of storing a pointer to the CoglRectangleMap and a handle to
the atlas texture in the context, there is a now a separate data
structure called a CoglAtlas to manage these two. The context just
contains a pointer to this. The code to reorganise the atlas has been
moved from cogl-atlas-texture.c to cogl-atlas.c
2010-08-12 11:56:59 +01:00
Neil Roberts
cb114f43ab cogl: Add an internal utility to maintain a list of callback functions
This adds an internal CoglCallbackList type which is just a GSList of
of function pointers along with a data pointer to form a
closure. There are functions to add and remove items and to invoke the
list of functions. This could be used in a number of places in Cogl.
2010-08-12 11:54:42 +01:00
Neil Roberts
bc20010582 cogl-atlas: Rename to CoglRectangleMap
This simply renames CoglAtlas to CoglRectangleMap without making any
functional changes. The old 'CoglAtlas' is just a data structure for
managing unused areas of a rectangle and it doesn't neccessarily have
to be used for an atlas so it wasn't a very good name.
2010-08-12 11:54:42 +01:00
Neil Roberts
bb17fd70e2 cogl-material: Compare whether textures are equal by their GL handle
Textures within a layer were compared for equality by comparing their
texture handle. However this means that sub textures and atlas
textures which may be internally using the same GL handle would not be
batched together. Instead it now tries to determine the underlying GL
handle using either the slice override or _cogl_texture_get_gl_texture
and then compares those.
2010-08-12 11:36:18 +01:00
Neil Roberts
b7807d9995 cogl-atlas-texture: Accept formats with different component orders
When filtering on allowed formats for atlas textures, it now masks out
the BGR and AFIRST bits in addition to the premult bit. That way it
will accept RGB and RGBA formats in any component order.

In theory it could also accept luminance and alpha-only textures but I
haven't added this because presumably if the application has requested
these formats then it has some reason not to use a full RGB or RGBA
texture and we should respect that.
2010-08-12 10:03:52 +01:00
Emmanuele Bassi
4be7310fb1 build: Make the introspection generation quiet (again) 2010-08-12 09:03:58 +01:00
Owen W. Taylor
d8e521af0a Always bind a new texture to unit 1 when necessary
The special handling for texture unit 1 caught the case where unit
1 was changed for transient purposes, but didn't properly handle
the case where the actual non-transient texture was different between
two materials with no transient binding in between.

If the actual texture has changed when flushing, mark unit 1 as dirty
and needing a rebind.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2261
2010-08-09 22:02:03 +01:00
Emmanuele Bassi
242afd96eb Silence a compiler warning 2010-08-09 19:38:23 +01:00
Robert Bragg
65196a4a9b cogl: Allow setting ARBfp source on a CoglShader
This makes CoglProgram/Shader automatically detect when the user has
given an ARBfp program by checking for "!!ARBfp1.0" at the beginning of
the user's source.

ARBfp local parameters can be set with cogl_program_uniform_float
assuming you pass a @size of 4 (all ARBfp program.local parameters
are vectors of 4 floats).

This doesn't expose ARBfp environment parameters or double precision
local parameters.
2010-08-09 17:27:02 +01:00
Robert Bragg
11045c724c cogl: Adds a COGL_FEATURE_SHADERS_ARBFP feature flag
This adds a public feature flag for ARBfp so developers can determine if
the cogl API supports ARBfp or not.
2010-08-09 17:27:02 +01:00
Robert Bragg
b025a4a020 material: Add cogl_material_{get,set}_user_program
Previously we had an internal only _cogl_material_set_user_program to
redirect legacy usage of cogl_program_use() through CoglMaterial. This
instead makes the API public because until we implement our planned
"snippet" framework we need a stop-gap solution for using shaders in
Cogl.

The plan is to also support ARBfp with the cogl_program/shader API so
this API will also allow clutter-gst to stop using direct OpenGL calls
that conflict with Cogl's state tracking.
2010-08-09 17:26:57 +01:00
Robert Bragg
937fc0dbec material: chain up in layer_pre_change_notify
A change to a layer is also going to be a change to its owning material
so we have to chain up in _cogl_material_layer_pre_change_notify and
call _cogl_material_pre_change_notify. Previously we were only
considering if the owning material was referenced in the journal but
that ignores that it might also have dependants. We no longer need to
flush the journal directly in layer_pre_change_notify.
2010-08-09 17:12:26 +01:00
Robert Bragg
b493b30257 material: unlink old layer from owner when replacing
In _cogl_material_layer_pre_change_notify when we see that a layer has
dependants and it can't be modified directly then we allocate a new
layer. In this case we also have to link the new layer to its required
owner. If the immutable layer we copied had the same owner though we
weren't unlinking that old layer.
2010-08-09 17:12:26 +01:00
Robert Bragg
021265e634 material: fix initialization of sparse properties
In _cogl_material_pre_change_notify we need to identify if it's a sparse
property being changed and if so initialize the state group if the given
material isn't currently the authority for it.

Previously we were unconditionally calling
_cogl_material_initialize_state which would e.g. NULL the layer
differences list of a material each time a layer change was notified.

It would also call _cogl_material_initialize_state for non-sparse
properties which should always be valid at this point so the function
has been renamed to _cogl_material_initialize_sparse_state to make this
clearer with a corresponding g_return_if_fail check.
2010-08-09 17:12:26 +01:00
Robert Bragg
02ce77dc08 material: fix copying of material layer differences
This fixes how we copy layer differences in
_cogl_material_copy_layer_differences.

We were making a redundant g_list_copy of the src differences and then
iterating the src list calling _cogl_material_add_layer_difference for
each entry which would double the list length, but the initial copy
directly referenced the original layers which wasn't correct.

Also we were initializing dest->n_layers before copying the layer
differences but the act of copying the differences will re-initialize
n_layers to 0 when adding the first layer_difference since it will
trigger a layer_pre_change_notify and since the dest material isn't yet
a STATE_LAYERS authority the state group is initialized before allowing
the change.
2010-08-09 17:12:26 +01:00
Robert Bragg
a75a7fadab material: don't dereference layer->texture directly
In _cogl_material_texture_storage_change_notify we were potentially
dereferencing layer->texture without checking first that it is the
authority of texture state. We now use
_cogl_material_layer_get_texture() instead.
2010-08-09 17:12:26 +01:00
Robert Bragg
8caaf5a8b2 material: Improve the dot file debugging code
This improve the dot file output available when calling
_cogl_debug_dump_materials_dot_file. The material graph now directly
points into the layer graph and the layers now show the texture unit
index.
2010-08-09 17:12:25 +01:00
Neil Roberts
abea3d7ead cogl-material: Unref the texture when reverting authority
When the texture is set on a layer so that it is back to the parent's
texture it would clear the texture change flag but it wouldn't unref
the texture. The free function for a material layer does not unref the
texture if the change flag is cleared so the texture would end up
leaking. This happens for ClutterTexture because it disposes the
texture by setting layer 0 of the material to COGL_INVALID_HANDLE
which ends up the same as the default material.
2010-08-06 17:09:54 +01:00
Robert Bragg
eda852e78c material: only deference layer->texture for authority
In _cogl_material_layer_pre_paint we were mistakenly dereferencing the
layer->texture member for the passed layer instead of dereferencing the
texture state authority which was causing crashes in some cases.
2010-08-06 14:16:35 +01:00
Robert Bragg
99ae7b15f5 cogl-program: gles2: bind programs lazily as for GL
This makes the gles2 cogl_program_use consistent with the GL version by
not binding the program immediately and instead leaving it to
cogl-material.c to bind the program when actually drawing something.
2010-08-03 15:00:07 +01:00
Robert Bragg
650df3f2eb gles2: Have CoglProgram track uniforms per program
Previously custom uniforms were tracked in _CoglGles2Wrapper but as part
of a process to consolidate the gl/gles2 shader code it seems to make
sense for this state to be tracked in the CoglProgram object instead.

http://bugzilla.o-hand.com/show_bug.cgi?id=2179
2010-08-03 15:00:04 +01:00
Robert Bragg
7705469d2b cogl-shader: unifies the driver/{gl,gles} shader files
The per driver implementations of cogl-shader.c had become almost
identical we now have a single cogl/cogl-shader.c instead.
2010-08-03 12:41:37 +01:00
Robert Bragg
6e176f94fa cogl-shader: Store the CoglShaderType in CoglShader
Instead of having to query GL and translate the GL enum into a
CoglShaderType each time cogl_shader_get_type is called we now keep
track of the type in CoglShader.
2010-08-03 12:41:34 +01:00
Robert Bragg
8640f527cb cogl: don't include cogl-debug.h in cogl.h or install
cogl-debug.h is an internal header so it shouldn't have been included by
cogl.h and the header shouldn't be installed either.
2010-08-02 17:41:42 +01:00
Neil Roberts
a2c2797105 gles/cogl-shader.c: Store the shader type in CoglShader
Nothing was storing the shader type when a shader was created so it
would get confused about whether it was a custom vertex or fragment
shader.

Also the 'type' member of CoglShader was a GLenum but the only place
that read it was treating it as if it was CoglShaderType. This changes
it be CoglShaderType.
2010-07-22 22:22:23 +01:00
Neil Roberts
023510636c Plug the leaking CoglProgram and CoglShader
_cogl_program_free and _cogl_shader_free never freed the struct their
structs so it would end up leaking a little bit.
2010-07-22 21:51:43 +01:00
Neil Roberts
2ccee98b31 cogl-bitmap-pixbuf: Avoid copying the buffer in more circumstances
When loading an RGB image GdkPixbuf will pad the rowstride so that the
beginning of each row is aligned to 4 bytes. This was causing us to
fallback to the code that copies the buffer. It is probably safe to
avoid copying the buffer if we can detect that the rowstride is simply
an alignment of the packed rowstride.

This also changes the copying fallback code so that it uses the
aligned rowstride. However it is now extremely unlikely that the
fallback code would ever be used.
2010-07-22 20:13:37 +01:00
Neil Roberts
fecb40a043 cogl-bitmap-pixbuf: Fix the rowstride used when copying a GdkPixbuf
In commit b780413e5a the GdkPixbuf loading code was changed so that
if it needs to copy the pixbuf then it would tightly pack it. However
it was still using the rowstride from the pixbuf so the image would
end up skewed. This fixes it to use the real rowstride.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2235
2010-07-22 20:13:15 +01:00
Neil Roberts
0ab6dc9db1 cogl-material: Don't map the shininess value to [0,1]
In OpenGL the 'shininess' lighting parameter is floating point value
limited to the range 0.0→128.0. This number is used to affect the size
of the specular highlight. Cogl materials used to only accept a number
between 0.0 and 1.0 which then gets multiplied by 128.0 before sending
to GL. I think the assumption was that this is just a weird GL quirk
so we don't expose it. However the value is used as an exponent to
raise the attenuation to a power so there is no conceptual limit to
the value.

This removes the mapping and changes some of the documentation.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2222
2010-07-22 17:52:51 +01:00
Neil Roberts
89286f6a47 cogl-material: Always reset the GLSL program to zero when flushing
When flushing a fixed-function or arbfp material it would always call
disable_glsl to try to get rid of the previous GLSL shader. This is
needed even if current_use_program_type is not GLSL because if an
application calls cogl_program_uniform then Cogl will have to bind the
program to set the uniform. If this happens then it won't update
current_use_program_type presumably because the enabled state of arbfp
is still valid.

The problem was that disable_glsl would only select program zero when
the current_use_program_type is set to GLSL which wouldn't be the case
if cogl_program_uniform was called. This patch changes it to just
directly call _cogl_gl_use_program_wrapper(0) instead of having a
separate disable_glsl function. The current program is cached in the
cogl context anyway so it shouldn't cause any extra unnecessary GL
calls.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2232
2010-07-22 17:50:56 +01:00
Neil Roberts
5b6298db10 cogl-material: Consider the shader when deciding if materials equate
_cogl_material_equal was ignoring the user shader state so rectangles
with different shaders would get batched together.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2220
2010-07-20 17:21:12 +01:00
Neil Roberts
b2247b10fd cogl-material-arbfp: Use separate buffers when calling g_ascii_dtostr
g_ascii_dtostr was being used in four separate arguments to
g_string_append_printf but all invocations of it were using the same
buffer. This would end up with all of the arguments having the same
value which would depend on whichever order the compiler evaluates
them in. This patches changes it to use a multi-dimensional array and
a loop to fill in the separate buffers.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2219
2010-07-18 11:01:05 +01:00
Emmanuele Bassi
62fa7b4e02 material-arbfp: Use locale-independent double to string conversion
The ARBfp programs are created with a printf() wrapper, which usually
fails in non-en locales as soon as you start throwing things like
floating point values in the mix.

We should use the g_ascii_dtostr() function which places a double into a
string buffer in a locale-independent way.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2219
2010-07-16 23:40:34 +01:00
Neil Roberts
4eca571a32 Add an internal _cogl_bitmap_new_from_buffer
This function creates a CoglBitmap which internally references a
CoglBuffer. The map and unmap functions will divert to mapping the
buffer. There are also now bind and unbind functions which should be
used instead of map and unmap whenever the data doesn't need to be
read from the CPU but will instead be passed to GL for packing or
unpacking. For bitmaps created from buffers this just binds the
bitmap.

cogl_texture_new_from_buffer now just uses this function to wrap the
buffer in a bitmap rather than trying to bind the buffer
immediately. This means that the buffer will be bound only at the
point right before the texture data is uploaded.

This approach means that using a pixel array will take the fastest
upload route if possible, but can still fallback to copying the data
by mapping the buffer if some conversion is needed. Previously it
would just crash in this case because the texture functions were all
passed a NULL pointer.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2112
2010-07-15 17:27:15 +01:00
Neil Roberts
e5dc645753 Add a Cogl debug flag for BITMAP
CoglBitmap will soon want to report notes as it gets more complicated
so this adds a debug flag for it.
2010-07-15 17:27:15 +01:00
Neil Roberts
c5205c50d2 Try to avoid copying the GdkPixbuf when it is tightly packed
The docs for GdkPixbuf say that the last row of the image won't
necessarily be allocated to the size of the full rowstride. The rest
of Cogl and possibly GL assumes that we can copy the bitmap with
memcpy(height*rowstride) so we previously would copy the pixbuf data
to ensure this. However if the rowstride is the same as bpp*width then
there is no way for the last row to be under-allocated so in this case
we can just directly upload from the gdk pixbuf. Now that CoglBitmap
can be created with a destroy function we can make it keep a reference
to the pixbuf and unref it during its destroy callback. GdkPixbuf
seems to always pack the image with no padding between rows even if it
is RGB so this should end up always avoiding the memcpy.

The fallback code for when we do have to copy the pixbuf is now
simplified so that it copies all of the rows in a single loop. We only
copy the useful region of each row so this should be safe. The
rowstride of the CoglBitmap is now always allocated to bpp*width
regardless of the rowstride of the pixbuf.
2010-07-15 17:25:36 +01:00
Neil Roberts
ccc3068ffd cogl-bitmap: Encapsulate the CoglBitmap even internally
The CoglBitmap struct is now only defined within cogl-bitmap.c so that
all of its members can now only be accessed with accessor
functions. To get to the data pointer for the bitmap image you must
first call _cogl_bitmap_map and later call _cogl_bitmap_unmap. The map
function takes the same arguments as cogl_pixel_array_map so that
eventually we can make a bitmap optionally internally divert to a
pixel array.

There is a _cogl_bitmap_new_from_data function which constructs a new
bitmap object and takes ownership of the data pointer. The function
gets passed a destroy callback which gets called when the bitmap is
freed. This is similar to how gdk_pixbuf_new_from_data
works. Alternatively NULL can be passed for the destroy function which
means that the caller will manage the life of the pointer (but must
guarantee that it stays alive at least until the bitmap is
freed). This mechanism is used instead of the old approach of creating
a CoglBitmap struct on the stack and manually filling in the
members. It could also later be used to create a CoglBitmap that owns
a GdkPixbuf ref so that we don't necessarily have to copy the
GdkPixbuf data when converting to a bitmap.

There is also _cogl_bitmap_new_shared. This creates a bitmap using a
reference to another CoglBitmap for the data. This is a bit of a hack
but it is needed by the atlas texture backend which wants to divert
the set_region virtual to another texture but it needs to override the
format of the bitmap to ignore the premult flag.
2010-07-15 17:24:01 +01:00
Neil Roberts
41cd2ae2c8 cogl-texture-2d-sliced: Store the internal format not image format
The 'format' member of CoglTexture2DSliced is returned by
cogl_texture_get_format. All of the other backends return the internal
format of the GL texture in this case. However the sliced backend was
returning the format of the image data used to create the texture. It
doesn't make any sense to retain this information because it doesn't
necessarily indicate the format of the actual texture. This patch
changes it to store the internal format instead.
2010-07-15 14:31:23 +01:00
Neil Roberts
7d269c6315 gles/cogl-texture-driver.c: Fix the include for cogl-material-private
In ddb9016be4 the GL texture driver backend was changed to include
cogl-material-opengl-private.h instead of cogl-material-private.h.
However the gles texture backend was missed from this so it was giving
a compiler warning about using an undeclared function.
2010-07-14 17:49:16 +01:00
Neil Roberts
00e3d77be3 cogl-texture-3d: Use glTexSubImage3D through an indirect pointer
glTexSubImage3D was being called directly in cogl-texture-3d.c but the
function is only available since GL version 1.2 so on Windows it won't
be possible to directly link to it. Also under GLES it is only
available conditionally in an extension.
2010-07-14 17:45:15 +01:00
Neil Roberts
a104b37068 cogl-texture-3d: Fix the cogl-material-private header include
In ddb9016be4 the texture backends were changed to include
cogl-material-opengl-private.h instead of cogl-material-private.h.
However the 3D texture backend was missed from this so it was giving a
compiler warning about using an undeclared function.
2010-07-14 16:35:33 +01:00
Neil Roberts
8b8f5efbe5 cogl-texture-3d: Don't include cogl-texture-2d-private.h
I think this was included by a cut-and-paste error as it isn't needed
anywhere in the source.
2010-07-14 16:34:42 +01:00
Robert Bragg
96b0e6c304 material: splits out all the state flushing code
This moves the code supporting _cogl_material_flush_gl_state into
cogl-material-opengl.c as part of an effort to reduce the size of
cogl-material.c to keep it manageable.
2010-07-13 19:26:58 +01:00
Robert Bragg
5442e429ba material: split the texture unit management out
In general cogl-material.c has become far to large to manage in one
source file. As one of the ways to try and break it down this patch
starts to move some of lower level texture unit state management out
into cogl-material-opengl.c. The naming is such because the plan is to
follow up and migrate the very GL specific state flushing code into the
same file.
2010-07-13 19:26:58 +01:00
Robert Bragg
be9564b3db material: copy_differences: handle copying fog state
When the support for redirecting the legacy fog state through cogl
material was added in 9b9e764dc, the code to handle copying the fog
state in _cogl_material_copy_differences was missed.
2010-07-13 19:26:57 +01:00
Neil Roberts
ae88bff329 Add a GL_GENERATE_MIPMAP fallback to the texture 2d and 3d backends
The CoglTexture2DSliced backend has a fallback for when the
framebuffer extension is missing so it's not possible to use
glGenerateMipmap. This involves keeping a copy of the upper-left pixel
of the tex image so that we can temporarily enable GL_GENERATE_MIPMAP
on the texture object and do a sub texture update by reuploading the
contents of the first pixel. This patch copies that mechanism to the
2D and 3D backends. The CoglTexturePixel structure which was
previously internal to the sliced backend has been moved to
cogl-texture-private.h so that it can be shared.
2010-07-13 18:41:01 +01:00
Neil Roberts
671abec8b7 Make the material functions for setting the p wrap mode public
Now that we have 3D texture support it makes sense to expose the wrap
mode for the p coordinate.
2010-07-13 14:29:07 +01:00
Neil Roberts
ec718d4ca4 Rename the third texure coordinate from 'r' to 'p'
Using 'r' to name the third component is problematic because that is
commonly used to represent the red component of a vector representing
a color. Under GLSL this is awkward because the texture swizzling for
a vector uses a single letter for each component and the names for
colors, textures and positions are synonymous. GLSL works around this
by naming the components of the texture s, t, p and q. Cogl already
effectively already exposes this naming because it exposes GLSL so it
makes sense to use that naming consistently. Another alternative could
be u, v and w. This is what Blender and Direct3D use. However the w
component conflicts with the w component of a position vertex.
2010-07-13 14:29:07 +01:00
Neil Roberts
5288f6d88d Add a Cogl texture 3D backend
This adds a publicly exposed experimental API for a 3D texture
backend. There is a feature flag which can be checked for whether 3D
textures are supported. Although we require OpenGL 1.2 which has 3D
textures in core, GLES only provides them through an extension so the
feature can be used to detect that.

The textures can be created with one of two new API functions :-

cogl_texture_3d_new_with_size

 and

cogl_texture_3d_new_from_data

There is also internally a new_from_bitmap function. new_from_data is
implemented in terms of this function.

The two constructors are effectively the only way to upload data to a
3D texture. It does not work to call glTexImage2D with the
GL_TEXTURE_3D target so the virtual for cogl_texture_set_region does
nothing. It would be possible to make cogl_texture_get_data do
something sensible like returning all of the images as a single long
image but this is not currently implemented and instead the virtual
just always fails. We may want to add API specific to the 3D texture
backend to get and set a sub region of the texture.

All of those three functions can throw a GError. This will happen if
the GPU does not support 3D textures or it does not support NPOTs and
an NPOT size is requested. It will also fail if the FBO extension is
not supported and the COGL_TEXTURE_NO_AUTO_MIPMAP flag is not
given. This could be avoided by copying the code for the
GL_GENERATE_MIPMAP TexParameter fallback, but in the interests of
keeping the code simple this is not yet done.

This adds a couple of functions to cogl-texture-driver for uploading
3D data and querying the 3D proxy
texture. prep_gl_for_pixels_upload_full now also takes sets the
GL_UNPACK_IMAGE_HEIGHT parameter so that 3D textures can have padding
between the images. Whenever 3D texture is uploading, both the height
of the images and the height of all of the data is specified (either
explicitly or implicilty from the CoglBitmap) so that the image height
can be deduced by dividing by the depth.
2010-07-13 14:28:52 +01:00
Neil Roberts
159c7ed7e5 configure: Include gl2ext.h or glext.h under GLES
Under big GL, glext.h is included automatically by gl.h. However under
GLES this doesn't appear to happen so it has to be included explicitly
to get the defines for extensions. This patch changes the
clutter_gl_header to be called cogl_gl_headers and it can now take a
space seperated list of multiple headers. This is then later converted
to a list of #include lines which ends up cogl-defines.h. The gles2
and gles1 backends now add their respective ext header to this list.
2010-07-13 14:28:51 +01:00
Neil Roberts
42dcffbc3a Make a public CoglBitmapError enum
There are many places in the texture backend that need to do
conversion using the CoglBitmap code. Currently none of these
functions can throw an error but they do return a value to indicate
failure. In future it would make sense if new texture functions could
throw an error and in that case they would want to use a CoglBitmap
error if the failure was due to the conversion. This moves the
internal CoglBitmap error from the quartz backend to be public in
cogl-bitmap.h so that it can be used in this way.
2010-07-13 14:28:45 +01:00
Neil Roberts
396ef40d43 Rename COGL_ERROR_MISSING_FEATURE to COGL_ERROR_UNSUPPORTED
We can use this error in more unsupported situations than just when we
have a Cogl feature flag for the error. For example if a non-sliced
texture is created with dimensions that are too large then we could
throw this error. Therefore it seems good to rename to something more
general.
2010-07-13 14:28:36 +01:00
Neil Roberts
c3489a0a22 Move _cogl_texture_2d_is_pot to cogl-util.h
This function could be used in many places in Cogl so it makes sense
to share it in cogl-util.h as _cogl_util_is_pot().
2010-07-13 14:28:35 +01:00
Neil Roberts
ccd45fc723 cogl-gles2-wrapper: Layers aren't equal if one is enabled and one is not
Previously when comparing whether the settings for a layer are equal
it would only check if one of them was enabled. If so then it would
assume the other one was enabled and continue to compare the texture
environment. Now it also checks whether the enabledness differs.
2010-07-13 14:28:35 +01:00
Neil Roberts
044523db26 Add the deprecated ref-counting for cogl_program
cogl_program has always had cogl_program_ref and cogl_program_unref
but this was missed from 89cb325fd4 so they got removed.
2010-07-09 19:09:49 +01:00
Neil Roberts
2c8bf00995 Don't define public cogl_is_* functions for internal types
This adds a COGL_OBJECT_INTERNAL_DEFINE macro and friends that are the
same as COGL_OBJECT_DEFINE except that they prefix the cogl_is_*
function with an underscore so that it doesn't get exported in the
shared library.
2010-07-09 18:57:54 +01:00
Neil Roberts
9e3705ecb3 Add cogl_vertex_buffer_is_indices to the public headers
This function has always been defined in the shared library but it was
missed from the public headers.
2010-07-09 18:57:54 +01:00
Neil Roberts
b25035ad2d cogl: Don't define the deprecated ref/unref accessors for new types
Previously COGL_OBJECT_DEFINE would always define deprecated
cogl_$type_{ref,unref} functions even if the type is new or if the
type is entirely internal. An application would still find it
difficult to use these because they wouldn't be in the headers, but it
still looks bad that they are exported from the shared library. This
patch changes it so that the deprecated ref counting functions are
defined using a separate macro and only the types that have these
functions in the headers call this macro.
2010-07-09 18:57:54 +01:00
Robert Bragg
ea708094c5 material: use common node type for materials and layers
Since 365605cf42, materials and layers are represented in a tree
structure that allows traversing up through parents and iterating down
through children.  This re-works the related typedefs and reparenting
code so that they can be shared.
2010-07-09 18:04:27 +01:00
Damien Lespiau
2d20589d8e cogl-texture-pixmap-x11: This API is new in 1.4, not 1.2
CoglTexturePixmapX11 has been introduced in the 1.3 development cycle. A
Stability: Unstable tag was missing too, so add it.
2010-07-09 17:55:31 +01:00
Damien Lespiau
c0fb59702c cogl: Add Stability tag to new experimental API
Functions guarded with COGL_ENABLE_EXPERIMENTAL API should be also maked
as being Unstable with the Stability gtk-doc tag.

Fixes: http://bugzilla.clutter-project.org/show_bug.cgi?id=2175
2010-07-09 17:17:11 +01:00
Neil Roberts
bf8384baf1 Use GL_MAX_TEXTURE_SIZE on GLES when checking supported tex size
Under big GL, _cogl_texture_driver_size_supported uses the proxy
texture to check whether the given texture size is supported. Proxy
textures aren't available under GLES so previously this would just
return TRUE to assume all texture sizes are supported. This patch
makes it use glGetIntegerv with GL_MAX_TEXTURE_SIZE to give a second
best guess.

This fixes the sliced texture backend so that it will use slices when
the texture is too big.
2010-07-09 11:14:15 +01:00
Neil Roberts
0fbdafd318 Fix cogl_texture_get_data when an intermediate buffer is used
When an intermediate buffer is used for downloading texture data it
was using the wrong byte length for a row so the copy back to the
user's buffer would fail.
2010-07-09 11:14:15 +01:00
Neil Roberts
d3ea1ec6f8 Use GL_NEAREST filter in the draw-and-read get_data texture fallback
The fallback for when glGetTexImage is not available renders the
texture to the framebuffer to read the data using glReadPixels. This
patch just sets the COGL_MATERIAL_FILTER_NEAREST filter mode on the
material before rendering to avoid linear filtering which would alter
the texture data.
2010-07-09 11:14:15 +01:00
Neil Roberts
f8d1955ab7 Use cogl_read_pixels in the cogl texture draw-and-read fallback
The fallback for when glGetTexImage is not available draws parts of
the texture to the framebuffer and uses glReadPixels to extract the
data. However it was using cogl_rectangle to draw and then immediately
using raw glReadPixels to fetch the data. This won't cause a journal
flush so the rectangle won't necessarily have hit the framebuffer
yet. Instead it now uses cogl_read_pixels which does flush the
journal.
2010-07-09 11:14:15 +01:00
Neil Roberts
475a72fd94 cogl-material: Fix some problems with flushing texture overrides
There were a few problems flushing texture overrides so that sliced
textures would not work:

* In _cogl_material_set_layer_texture it ignored the 'overriden'
  parameter and always set texture_overridden to FALSE.

* cogl_texture_get_gl_texture wasn't being called correctly in
  override_layer_texture_cb. It returns a gboolean to indicate the
  error status but this boolean was being assigned to gl_target.

* _cogl_material_layer_texture_equal did not take into account the
  override.

* _cogl_material_layer_get_texture_info did not return the overridden
  texture so it would always use the first texture slice.
2010-07-09 11:14:15 +01:00
Neil Roberts
61cbeeacfa cogl-texture: Share the common code in the set_region virtual
There was a lot of common code that was copied to all of the backends
to convert the data to a suitable format and wrap it into a CoglBitmap
so that it can be passed to _cogl_texture_driver_upload_subregion_to_gl.
This patch moves the common code to cogl-texture.c so that the virtual
just takes a CoglBitmap that is already in the right format.
2010-07-09 11:14:14 +01:00
Neil Roberts
223317c500 cogl-texture: Share the common code in the get_data virtual
Previously cogl_texture_get_data would pretty much directly pass on to
the get_data texture virtual function. This ended up with a lot of
common code that was copied to all of the backends. For example, the
method is expected to return the required data size if the data
pointer is NULL and to calculate its own rowstride if the rowstride is
0. Also it needs to convert the downloaded data if GL can't support
that format directly.

This patch moves the common code to cogl-texture.c so the virtual is
always called with a format that can be downloaded directly by GL and
with a valid rowstride. If the download fails then the virtual can
return FALSE in which case cogl-texture will use the draw and read
fallback.
2010-07-09 11:00:48 +01:00
Neil Roberts
0e49e4f204 cogl-vertex-buffer: Default to GL_CLAMP_TO_EDGE for point sprites
For point sprites you are usually drawing the whole texture so you
most often want GL_CLAMP_TO_EDGE. This patch removes the override for
COGL_MATERIAL_WRAP_MODE_AUTOMATIC when point sprites are enabled for a
layer so that it will clamp to edge.
2010-07-08 16:34:31 +01:00
Neil Roberts
da3be3df6b cogl-material: Add support for point sprites
This adds a new API call to enable point sprite coordinate generation
for a material layer:

void
cogl_material_set_layer_point_sprite_coords_enabled (CoglHandle material,
                                                     int layer_index,
                                                     gboolean enable);

There is also a corresponding get function.

Enabling point sprite coords simply sets the GL_COORD_REPLACE of the
GL_POINT_SPRITE glTexEnv when flusing the material. There is no
separate application control for glEnable(GL_POINT_SPRITE). Instead it
is left permanently enabled under the assumption that it has no affect
unless GL_COORD_REPLACE is enabled for a texture unit.

http://bugzilla.openedhand.com/show_bug.cgi?id=2047
2010-07-08 16:34:30 +01:00
Neil Roberts
06b58baa10 cogl-material: Add a property for setting the point size
This adds cogl_material_{get,set}_point_size. If the point size is not
1.0f then glPointSize will be called when the material is flushed.

http://bugzilla.openedhand.com/show_bug.cgi?id=2047
2010-07-08 16:34:30 +01:00
Robert Bragg
dcc8c66fdd material: support dumping layer state graph to dot file
Recently I added a _cogl_debug_dump_materials_dot_file function for
debugging the sparse material state. This extends the state dumped to
include the graph of layer state also.
2010-07-07 20:46:50 +01:00
Robert Bragg
093251776f material: set ->layer_index on new layers for unit0
We were mistakenly only initializing layer->layer_index for new layers
associated with texture units > 0. This had gone unnoticed because
normally layers associated with texture unit0 have a layer index of 0
too. Mutter was hitting this issue because it was initializing layer 1
before layer 0 for one of its materials so layer 1 was temporarily
associated with texture unit 0.
2010-07-07 20:46:04 +01:00
Emmanuele Bassi
added497f4 Merge branch 'cally-merge'
* cally-merge:
  cally: Add introspection generation
  cally: Improving cally doc
  cally: Cleaning CallyText
  cally: Refactoring "window:create" and "window:destroy" emission code
  cally: Use proper backend information on CallyActor
  cally: Check HAVE_CONFIG_H on cally-util.c
  docs: Fix Cally documentation
  cally: Clean up the headers
  Add binaries of the Cally examples to the ignore file
  docs: Add Cally API reference
  Avoid to load cally module on a11y examples
  Add accessibility tests
  Initialize accessibility support on clutter_init
  Rename some methods and includes to avoid -Wshadow warnings
  Cally initialization code
  Add Cally
2010-07-07 16:06:30 +01:00
Emmanuele Bassi
0eb9fc04f5 cally: Add introspection generation
Toolkits and applications not written in C might still need access to
the Cally API to write accessibility extensions based on it for their
own native elements.
2010-07-07 15:57:43 +01:00
Robert Bragg
0c3354acba framebuffer: Replace CoglHandle with CoglFramebuffer *
One more object converted to stop using CoglHandle re:a8c8cbee513
2010-07-07 14:41:54 +01:00
Robert Bragg
8098052d56 material: route fogging state through CoglMaterial
Previously cogl_set_fog would cause a flush of the Cogl journal and
would directly bang the GL state machine to setup fogging. As part of
the ongoing effort to track most state in CoglMaterial to support
renderlists this now adds an indirection so that cogl_set_fog now just
updates ctx->legacy_fog_state. The fogging state then gets enabled as a
legacy override similar to how the old depth testing API is handled.
2010-07-07 14:12:15 +01:00
Robert Bragg
a17dfcf1c2 cogl-buffer: Move malloc fallback logic into CoglBuffer
Since we'll want to share the fallback logic with CoglVertexArray this
moves the malloc based fallback (for when OpenGL doesn't support vertex
or pixel buffer objects) into cogl-buffer.c.
2010-07-07 14:08:11 +01:00
Robert Bragg
f8d58446a8 cogl-buffer: consider it an error to free a mapped buffer
Explicitly warn if we detect that a CoglBuffer is being freed while it
is still mapped. Previously we silently unmapped the buffer, but it's
not something we want to encourage.
2010-07-07 14:08:11 +01:00
Robert Bragg
e98ee6665b cogl-buffer: Track the last used bind target in CoglBuffer
This makes CoglBuffer track the last used bind target as a private
property. This is later used when binding a buffer to map instead of
always using the PIXEL_UNPACK target.

This also adds some additional sanity checks that code doesn't try to
nest binds to the same target or bind a buffer to multiple targets at
the same time.
2010-07-07 14:08:11 +01:00
Robert Bragg
7571cc1923 cogl: expose the semantic differences of gl/gles2 npot textures
This adds three new feature flags COGL_FEATURE_TEXTURE_NPOT_BASIC,
COGL_FEATURE_TEXTURE_NPOT_MIPMAP and COGL_FEATURE_TEXTURE_NPOT_REPEAT
that can tell you if your hardware supports non power of two textures,
npot textures + mipmaps and npot textures + wrap modes other than
CLAMP_TO_EDGE.

The pre-existing COGL_FEATURE_TEXTURE_NPOT feature implies all of the
above.

By default GLES 2 core supports npot textures but mipmaps and repeat
modes can only be used with power of two textures. This patch also makes
GLES check for the GL_OES_texture_npot extension to determine if mipmaps
and repeating are supported with npot textures.
2010-07-07 13:26:41 +01:00
Neil Roberts
c243086f44 cogl-vertex-buffer: Fix the #define for glDisableVertexAttribArray
glDisableVertexAttribArray was defined to glEnableVertexAttribArray so
it would probably cause crashes if it was ever used. Presumably
nothing is using these yet because the generic attributes are not yet
tied to shader attributes in a predictable way.
2010-07-06 16:08:44 +01:00
Alexandros Frantzis
bf56e798c6 build: Exclude built sources from the dist
http://bugzilla.clutter-project.org/show_bug.cgi?id=2169

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-07-06 13:24:00 +01:00
Robert Bragg
3b4b5ba01c debug: Adds a COGL_DEBUG=disable-pbos debug option
For testing purposes, either to identify bugs in Cogl or the driver or
simulate lack of PBO support COGL_DEBUG=disable-pbos can be used to
fallback to malloc instead.
2010-07-06 12:09:01 +01:00
Robert Bragg
92d0322766 pixel-array: Allow passing of hints to cogl_buffer_map
This allows you to tell Cogl that you are planning to replace all the
buffer's data once it is mapped with cogl_buffer_map. This means if the
buffer is currently being accessed by the GPU then the driver doesn't
have to stall and wait for it to finish before it can access it from the
CPU and can instead potentially allocate a new buffer with undefined
data and map that.
2010-07-06 12:07:28 +01:00
Robert Bragg
51e4245ce1 cogl-object: cogl_is_XYZ prototype should take void *
This changes the cogl_is_XYZ function prototypes generated when using
the COGL_OBJECT_DEFINE macro to take a void * argument instead of a
CoglHandle argument.
2010-07-05 15:47:02 +01:00
Robert Bragg
9e25f8c40d pixel-array: Only allow allocation of arrays with a 2D size
This removes cogl_pixel_array_new which just took a size in bytes.

Without the image size and pixel format then the driver often doesn't
have enough information to allocate optimal GPU memory that can be
textured from directly. This is because GPUs often have ways to
spatially alter the layout of a texture to improve cache access patterns
which may require special alignment and padding dependant in the images
width, height and bpp.

Although currently we are limited by OpenGL because it doesn't let us
pass on the width and height when allocating a PBO, the hope is that we
can define a better extension at some point.
2010-07-05 15:20:04 +01:00
Robert Bragg
daa34aeb0e pixel-array: rename new_from_size to new_with_size
It is more in keeping with other coding conventions in Cogl to use new
"with" size instead of new "from" size.
2010-07-05 15:20:04 +01:00
Robert Bragg
a46cc22c1b cogl-buffer-private.h: cleanup up the coding style
This file was following the Clutter coding style of arranging prototypes
into columns which Cogl doesn't copy.
2010-07-05 15:20:04 +01:00
Robert Bragg
521d9ca203 rename CoglPixelBuffer to CoglPixelArray
This renames CoglPixelBuffer to CoglPixelArray to be consistent with the
new CoglVertexArray API.
2010-07-05 15:20:04 +01:00
Robert Bragg
cafeb02531 cogl-buffer: make the COGL_BUFFER_USAGE_HINT private
The usage hint should be implied by the CoglBuffer subclass type so the
public getter and setter APIs for manually changing the usage hint of a
CoglBuffer have now been removed.
2010-07-05 15:20:04 +01:00
Robert Bragg
9ceb0edf26 cogl-buffer: Handle subclass registration like cogl-texture
Instead of having to extend cogl_is_buffer with new buffer types
manually this now adds a new COGL_BUFFER_DEFINE macro to be used instead
of COGL_OBJECT_DEFINE for CoglBuffer subclasses. This macro will
automatically register the new type with ctx->buffer_types which will
iterated by cogl_is_buffer. This is the same coding pattern used for
CoglTexture.
2010-07-05 15:20:03 +01:00
Robert Bragg
1b7e362189 pixel-buffer: Replace CoglHandle with CoglPixelBuffer *
One more file converted to stop using CoglHandle re:a8c8cbee513
2010-07-05 15:20:03 +01:00
Robert Bragg
12a76ca4aa cogl-material: Adds debug api to dump sparse material graph
This adds a _cogl_debug_dump_materials_dot_file function that can be
used to dump all the descendants of the default material to a file using
the dot format which can then be converted to an image to visualize.
2010-07-05 15:04:46 +01:00
Robert Bragg
b5f7ab345c cogl-vertex-buffer.h: #include <cogl/cogl-defines.h>
cogl-vertex-buffer.h was assuming that the platforms GL headers had
already been included but that shouldn't have to be the case.
2010-07-05 14:54:21 +01:00
Robert Bragg
0b3c45396b cogl-object-private.h: #include glib.h and cogl-types.h
cogl-object-private.h was only working in places that had already
included glib.h and cogl-types.h
2010-07-05 14:51:28 +01:00
Robert Bragg
cc0b76b405 material: don't keep extra ref on copy-on-write materials
In _cogl_material_pre_change_notify if a material with descendants is
modified then we create a new material that is a copy of the one being
modified and reparent those descendants to the new material.

This patch ensures we drop the reference we get from cogl_material_copy
since we can rely on the descendants to keep the new material alive.
2010-07-05 14:51:05 +01:00
Robert Bragg
3428633cb3 build: Fix GLES builds since the material backend split
The commit to split the fragment processing backends out from
cogl-material.c (3e1323a636) broke the GLES 1 and 2 builds the
fix was to guard the code in each backend according to the
COGL_MATERIAL_BACKEND_XYZ defines which are setup in
cogl-material-private.h.
2010-07-05 14:50:47 +01:00
Neil Roberts
cea74d92ea Convert the ASCII art documentation in cogl-vertex-buffer to PNGs
The documentation for cogl_vertex_buffer_indices_get_for_quads was
using ugly ASCII art to draw the diagrams. These have now been
replaced with PNG figures.
2010-07-02 17:29:34 +01:00
Neil Roberts
432c37bd21 Add CoglMaterialWrapMode to the Cogl docs and fix docs for the getters
CoglMaterialWrapMode was missing from the cogl-sections.txt file so it
wasn't getting displayed. There were also no documented return values
from the getters.
2010-07-02 17:29:34 +01:00
Neil Roberts
59d06d486d Fix building the tesselator code for GLES
The tesselator code uses some defines that it expects to be in the GL
headers such as GLAPI and GLAPIENTRY. These are used to mark the entry
points as exportable on each platform. We don't really want the
tesselator code to use these but we also don't want to modify the C
files so instead they are #defined to be empty in the stub glu.h. That
header is only included internally when building the tesselator/ files
so it shouldn't affect the rest of Cogl.

GLES also doesn't have a GLdouble type so we just #define this to be a
regular double.
2010-07-01 20:39:57 +01:00
Neil Roberts
7961b1c93d cogl-material: Don't doubly ref the parent in cogl_material_copy
cogl_material_copy was taking a reference on the original texture when
making a copy. However it then calls _cogl_material_set_parent on the
material which also takes a reference on the parent. The second
reference is cleaned up whenever _cogl_material_unparent is called and
this is also called by _cogl_material_free. However, it seems that
nothing was cleaning up the first reference. I think the reference is
entirely unnecessary so this patch removes it.
2010-07-01 15:32:08 +01:00
Robert Bragg
137d38962a cogl: don't include cogl-vector.h twice in cogl.h
cogl-vector.h should only be included by cogl.h when
COGL_ENABLE_EXPERIMENTAL_API is defined. This removes the unguarded
duplicate include.
2010-07-01 12:23:10 +01:00
Robert Bragg
1000c80444 cogl: declare experimental symbols consistently
We had several different ways of exposing experimental API, in one case
the symbols had no special suffix, in two other ways the symbols were
given an _EXP suffix but in different ways.

This makes all experimental API have an _EXP suffix which is handled
using #defines in the header so the prototypes in the .c and .h files
don't have the suffix.

The documented reason for the suffix is so that anyone watching Cogl for
ABI changes who sees symbols disappear will hopefully understand what's
going on.
2010-06-30 18:51:31 +01:00
Neil Roberts
a0a06f0342 cogl/tesselator: Update to the latest code from GLU
This grabs the latest code for libtess from git Mesa. This is mostly
so that we can get the following commit which fixes a lot of compiler
warnings in Clutter:

commit 75acb896c6da758d03e86f8725d6ca0cb2c6ad82
Author: Neil Roberts <neil@linux.intel.com>
Date:   Wed Jun 30 12:41:11 2010 +0100

    glu: Fix some compiler warnings in libtess
    
    When compiled with the more aggressive compiler warnings such as
    -Wshadow and -Wempty-body the libtess code gives a lot more
    warnings. This fixes the following issues:
    
    * The 'Swap' macro tries to combine multiple statements into one and
      then consume the trailing semicolon by using if(1){/*...*/}else.
      This gives warnings because the else part ends up with an empty
      statement. It also seems a bit dangerous because if the semicolon
      were missed then it would still be valid syntax but it would just
      ignore the following statement. This patch replaces it with the more
      common idiom do { /*...*/ } while(0).
    
    * 'free' was being used as a local variable name but this shadows the
      global function. This has been renamed to 'free_handle'
    
    * TRUE and FALSE were being unconditionally defined. Although this
      isn't currently a problem it seems better to guard them with #ifndef
      because it's quite common for them to be defined in other headers.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=28845
2010-06-30 16:35:33 +01:00
Emmanuele Bassi
6fbe92193f docs: Various fixes for gtk-doc 2010-06-30 15:51:12 +01:00
Robert Bragg
be46b872e9 material: Replace CoglHandle with CoglMaterial *
As part of the ongoing effort to remove CoglHandle from the API this
switches the cogl_material API to use a strongly typed CoglMaterial
pointer instead of CoglHandle.
2010-06-30 15:04:18 +01:00
Robert Bragg
17731b3af1 material: Split the fragment processing backends out
This splits the fragment processing backends (glsl, arbfp and fixed) out
from cogl-material.c into their own cogl-material-{glsl,arbfp,fixed}.c
files in an effort to help and keep cogl-material.c maintainable.
2010-06-30 15:04:10 +01:00
Robert Bragg
e7df757739 material: remove a duplicate gtk-doc "Since: 1.4"
The cogl_material_get_depth_writing_enabled documentation had two
"Since: 1.4" annotations which was confusing the gobject introspection
scanner.
2010-06-30 14:31:46 +01:00
Neil Roberts
cdf5b222db cogl-path: Allow changing the fill rule
This adds two new API calls- cogl_path_set_fill_rule and
cogl_path_get_fill_rule. This allows modifying the fill rule of the
current path. In addition to the previous default fill rule of
'even-odd' it now supports the 'non-zero' rule. The fill rule is a
property of the path (not the Cogl context) so creating a new path or
preserving a path with cogl_path_get_handle affects the fill rule.
2010-06-29 20:37:14 +01:00
Neil Roberts
244a795f43 cogl-debug: Remove the force-scanline-paths option
The scanline path rasterizer has been removed because the paths can be
drawn with the tesselator instead. The option therefore no longer does
anything.
2010-06-29 20:37:13 +01:00
Neil Roberts
fecaaea132 cogl-path: Use the GLU tesselator to draw paths
Instead of drawing paths using the stencil buffer trick, it now
tesselates the path into triangles using the GLU tesselator and
renders them directly. A vbo is created with one vertex for each node
on the path. The tesselator is used to generate a series of indices
into the vbo as triangles. The tesselator's output of strips and fans
is converted into GL_TRIANGLES so that it can be rendered with a
single draw call (but the vertices are still shared via the
indices). The vbo is stored with the path so that if the application
uses retained paths then Cogl won't have to tessellate again.

The vertices also have texture coordinates associated with them so
that it can replicate the old behaviour of drawing a material with a
texture by fitting the texture to the bounding box of the path and
then clipping it. However if the texture contains waste or is sliced
then the vertex buffer code will refuse to draw it. In this case it
will revert back to drawing the path into the stencil buffer and then
drawing the material as a clipped quad.

The VBO is used even when setting up the stencil buffer for clipping
to a path because the tessellated geometry may cover less area.

The old scanline rasterizer has been removed because the tesselator
should work equally well on drivers with no stencil buffer.
2010-06-29 20:37:13 +01:00
Neil Roberts
b86e330957 cogl: Pull in the code for GLU tesselator from Mesa/SGI
This copies the files for the GLU tesselator from Mesa. The Mesa code
is based on the original SGI code and is released under a BSD license.

The memalloc.h header has been replaced with one that forces the code
to use g_malloc and friends. The rest of the files are not altered
from the original so it should be possible to later upgrade the files
by simply overwriting them.

There is a tesselator.h header which is expected to be included by
rest of Cogl to use the tesselator. This contains a trimmed down
version of glu.h that only includes parts that pertain to the
tesselator. There is also a stub glu.h in the GL directory which is
just provided so that the tesselator code can include <GL/gl.h>
without depending on the system header. It just redirects to
tesselator.h
2010-06-29 20:37:13 +01:00
Neil Roberts
d99a8bf694 cogl: Add const to some pointer arguments
Some of the arguments to the material and path functions were taking a
pointer to a CoglColor or an array of floats that was not intended to
be written to but were not marked with const.
2010-06-28 15:25:19 +01:00
Robert Bragg
de1f4885dd material: Avoid possibly reading invalid memory
in _cogl_material_prune_empty_layer_difference we sometimes unref the
given layer before dereferencing it to get a pointer to its parent. This
defers the unref until after we have fetched the parent pointer.
2010-06-24 17:05:26 +01:00
Neil Roberts
e33a94bff4 cogl: Remove cogl-defines.h.in from the driver make files
Commit 7fae8ac051 changed cogl-defines.h.in so there is only a
single copy in clutter/cogl/ instead of one for each driver. However
the old files were still mentioned in the EXTRA_DIST of the
Makefile.am so make distcheck was failing.
2010-06-23 17:44:09 +01:00
Chris Lord
e8e5188484 cogl-path: Disable texture coord arrays before drawing
It was possible that the texture co-ord arrays were left enabled during
stroking, which could possibly cause a crash.
2010-06-23 16:07:00 +01:00
Robert Bragg
857aee2b91 texture-pixmap-x11: don't assume anything about the GLXFBConfig type
A pedantic change to get_fbconfig_for_depth() so that we don't need to
make any assumptions about the GLXFBConfig typedef or what values
we can overload to indicate an invalid config.

get_fbconfig_for_depth() now simply returns FALSE if it fails to find a
config.
2010-06-22 16:53:59 +01:00
Emmanuele Bassi
c0d42cb021 Silence another compiler warning 2010-06-22 14:43:36 +01:00
Neil Roberts
7d206ccdbb cogl-texture-pixmap-x11: Use NULL instead of None for invalid GLXFBConfig
GLXFBConfigs are opaque pointers not XIDs so it doesn't make sense to
return None from get_fbconfig_for_depth. Instead it now returns NULL.
2010-06-22 14:19:59 +01:00
Emmanuele Bassi
0244eccfe3 Silence some compiler warnings 2010-06-22 13:48:53 +01:00
Neil Roberts
8458fb7e20 Add a CoglTexturePixmapX11 texture backend
This is a publicly exposed texture backend to create a texture which
contains the contents of an X11 pixmap. The API is currently marked as
experimental.

The backend internally holds a handle to another texture. All of the
backend virtuals simply redirect to the internal texture.

The texture can optionally be automatically updated if the
automatic_updates parameter is TRUE. If set then Cogl will listen for
damage events on the pixmap and update the texture accordingly.
Alternatively a damage object can be created externally and passed
down to Cogl.

The updates can be performed with XGetImage, XShmGetImage or the
GLX_EXT_texture_pixmap extension. If the TFP extension is used it will
optionally try to create a rectangle texture if the driver does not
support NPOTs or it is forced through the
COGL_PIXMAP_TEXTURE_RECTANGLE or CLUTTER_PIXMAP_TEXTURE_RECTANGLE
environment variables.

If the GLXFBConfig does not support mipmapping then it will fallback
to using X{Shm,}GetImage. It keeps a separate texture around for this
so that it can later start using the TFP texture again if the texture
is later drawn with mipmaps disabled.
2010-06-22 12:22:48 +01:00
Neil Roberts
9c62265939 Add -DCOGL_ENABLE_EXPERIMENTAL_API to Makefiles for Cogl and x11/glx
Cogl and Clutter should be able to use the experimental API so this
adds the required define to the CPPFLAGS in the Makefiles.
2010-06-22 12:22:47 +01:00
Neil Roberts
9d0962098f cogl-defines.h: Add a COGL_HAS_X11 define
This will be defined in cogl-defines.h whenever Cogl is built using a
winsys that supports X11. This implies CoglTexturePixmapX11 will be
available.

To make this work the two separate cogl-defines.h.in files have been
merged into one. The configure script now makes a @COGL_DEFINES@
substitution variable which contains the #define lines to put in
rather than directly having them in the seperate files.
2010-06-22 12:22:47 +01:00
Neil Roberts
16c7d12e6c cogl: Add _cogl_xlib_{,un}trap_errors
This is similar to clutter_x11_{,un}trap_errors except that it stores
the previous trap state in a caller-allocated struct so that it can be
re-entrant.

Make _cogl_xlib_trap_errors re-entrant

(this will be squashed into an earlier commit)
2010-06-22 12:22:47 +01:00
Neil Roberts
6ad668c76b cogl-texture: Avoid premult conversion if the dst format has no alpha
The _cogl_texture_needs_premult_conversion function was already
checking whether the source format had an alpha channel before
returning TRUE, but it also doesn't make sense to do the premult
conversion if the destination format has no alpha. This patch adds
that check in too.
2010-06-22 12:22:47 +01:00
Neil Roberts
31b5beb2c0 cogl: Add the infrastructure for checking for winsys extensions
This adds the framework needed to check for winsys specific extensions
(such as GLX extensions) using a similar mechanism to the
cogl-feature-functions header. There is a separate
cogl-winsys-feature-functions header which will contain macros to list
the extensions and functions. cogl_create_context_winsys now calls
_cogl_feature_check for each of these functions. _cogl_feature_check
has had to be changed to accept the driver prefix as the first
parameter so that it can prepend "GLX" rather than "GL" in this case.
2010-06-22 12:22:43 +01:00
Neil Roberts
9646e85ba7 Pass all Xlib events through Cogl
The Clutter X11 backend now passes all events through
_cogl_xlib_handle_event. This function can now internally be hooked
with _cogl_xlib_add_filter. These are added to a list of callbacks
which are all called in turn by _cogl_xlib_handle_event. This is
intended to be used internally in Cogl by any parts that need to see
Xlib events.

Cogl now also has an internally exposed function to set a pointer to
the Xlib display. This is stored in a global variable. The Clutter X11
backend sets this.

_cogl_xlib_handle_event and _cogl_xlib_set_display can be removed once
Cogl gains a proper window system abstraction.
2010-06-22 12:20:59 +01:00
Neil Roberts
2e5b4a5b81 cogl: Add a struct for winsys-specific data to CoglContext
This creates a separate struct to store the fields of the context that
are specific to the winsys. This is all stored in one file but ideally
this could work more like the CoglContextDriver struct and have a
different header for each winsys.
2010-06-22 11:47:33 +01:00