1
0
Fork 0
Commit graph

3269 commits

Author SHA1 Message Date
Neil Roberts
0cb09cd40d cogl_read_pixels: Always use GL_RGBA/GL_UNSIGNED_BYTE under GLES
Under GLES glReadPixels is documented to only support GL_RGBA with
GL_UNSIGNED_BYTE and an implementation specfic format which can be
fetched with glGet, GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES and
GL_IMPLEMENTATION_COLOR_READ_TYPE_OES. This patch makes it always read
using GL_RGBA and GL_UNSIGNED_BYTE and then convert the results if
neccessary.

This has some room for improvement because it doesn't attempt to use
the implementation specific format. Also the conversion is somewhat
wasteful because there are currently no cogl_bitmap_* functions to
convert without allocating a new buffer so it ends up doing an
intermediate copy.

http://bugzilla.openedhand.com/show_bug.cgi?id=2057
2010-04-21 10:56:21 +01:00
Neil Roberts
9750b90f37 cogl-bitmap: Fix converting formats with and without alpha channels
_cogl_bitmap_convert_format_and_premult was failing when converting
from RGBA to RGB and vice versa. _cogl_bitmap_fallback_convert
converts without altering the premult status so when choosing a new
format it would copy over the premult bit. However, it did this
regardless of whether the new format had an alpha channel so when
converting from RGBA_8888_PRE to RGB_888 it would end up inventing a
new meaningless format which would be RGB_888_PRE. This patch makes it
avoid copying the premult flag if the destination has no alpha. It
doesn't matter if it copies when the source format has no alpha
because it will always be unset.

_cogl_bitmap_convert_format_and_premult was also breaking when
converting from RGBA_8888_PRE to RGB_888 because it would think
RGB_888 is unpremultiplied and try to convert but then
_cogl_bitmap_fallback_premult wouldn't know how to do the conversion.

http://bugzilla.openedhand.com/show_bug.cgi?id=2057
2010-04-21 10:56:21 +01:00
Neil Roberts
a28440eafb clutter-texture: Remove confusing comments about realization
In 125bded81 some comments were introduced to ClutterTexture
complaining that it can have a Cogl texture before being
realized. Clutter always assumes that the single GL context is current
so there is no need to wait until the actor is realized before setting
a texture. This patch replaces the comments with clarification that
this should not be a problem.

The patch also changes the documentation about the realized state in
various places to clarify that it is acceptable to create any Cogl
resources before the actor is realized.

http://bugzilla.openedhand.com/show_bug.cgi?id=2075
2010-04-19 15:34:43 +01:00
Robert Bragg
62ac3b312e glx: handle spurious GLX_BufferSwapComplete events gracefully
Instead of simply aborting we now print out a warning, when a spurious
GLX_BufferSwapComplete event is handled since it seems that people are
coming across the problem (perhaps due to a buggy driver) and making
apps crash in this situation is a bit extreme.
2010-04-19 11:24:42 +01:00
Neil Roberts
716ec82db8 clutter-cairo-texture: Use the new cogl_pixel_buffer API
ClutterCairoTexture now stores the surface image data in a Cogl pixel
buffer object. When clutter_cairo_texture_create is called the buffer
is mapped and a new Cairo surface is created to render directly to the
PBO. When the surface is destroyed the buffer is unmapped and a Cogl
texture is recreated from the buffer. This should enable slightly
faster uploads when using Cairo because it avoids having to copy the
surface data to the texture.

http://bugzilla.openedhand.com/show_bug.cgi?id=1982

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-04-16 13:19:57 +01:00
Emmanuele Bassi
1a1e7d3573 text: Increase the size of the Layout cache
Currently, each ClutterText caches 3 Pango layouts:

  » one for the preferred, unbounded width
  » one for the preferred height for a given width
  » one for the allocated size

Some layout managers do a double pass that could flush the whole cache
before it has a chance of actually storing relevant data, resulting in
a continuous series of misses.

We can try to counteract this by doubling the size of the cache, from
three slots to six. More than six would be pointless, as well as too
memory consuming; but we might get down to a number between 3 and 6 at
any later point.
2010-04-16 12:57:49 +01:00
Rob Bradford
dd407326fe text: Check generated size of layouts in cache
By comparing the requested size against the computed sized for existing
Pango layouts we can avoid creating layouts where the requested size
matches that of a previously computed one.

In particular this optimisation means that when working with a fixed
positioning based layout (with no constraints on the size of the
ClutterText) the same PangoLayout can be used to calculate the preferred
width, height and also the layout used for the actual painting.

http://bugzilla.openedhand.com/show_bug.cgi?id=2078

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-04-16 12:50:35 +01:00
Neil Roberts
708bbc72e1 cogl: Implement retained clip stacks
This adds three new internal API functions which can be used to retain
the clip stack state and restore it later:

 _cogl_get_clip_stack
 _cogl_set_clip_stack
 _cogl_clip_stack_copy

The functions are currently internal and not yet used but we may want
to make them public in future to replace the cogl_clip_stack_save()
and cogl_clip_stack_restore() APIs.

The get function just returns the handle to the clip stack at the top
of the stack of stacks and the set function just replaces it.

The copy function makes a cheap copy of an existing stack by taking a
reference to the top stack entry. This ends up working like a deep
copy because there is no way to modify entries of a stack but it
doesn't actually copy the data.
2010-04-15 14:51:01 +01:00
Neil Roberts
3a58bc440b cogl-clip-stack: Convert to be a CoglHandle
CoglClipStacks can now be reference counted via a CoglHandle. The
ClipClipState now stores handles in the list rather than CoglClipStack
pointers.
2010-04-15 14:51:01 +01:00
Neil Roberts
aba7fb63cb Separate out CoglClipStackState from cogl-clip-stack.c
CoglClipStackState has now been renamed to CoglClipState and is moved
to a separate file. CoglClipStack now just maintains a stack and
doesn't worry about the rest of the state. CoglClipStack sill contains
the code to flush the stack to GL.
2010-04-15 14:51:00 +01:00
Neil Roberts
732223074b cogl-slip-stack: Store clip window rect entries in Cogl coordinates
When glScissor is called it needs to pass coordinates in GL's
coordinate space where the origin is the bottom left. Previously this
conversion was done before storing the window rect in the clip
stack. However this might make it more difficult if we want to be able
to grab a handle to a clip stack and use it in different circumstances
later. This patch moves the coordinate conversion to inside the clip
state flushing code.
2010-04-15 14:50:55 +01:00
Neil Roberts
e9aa5d807c cogl-clip-stack: Store window rect entries as ints not floats
The window rectangles are passed in as integers so there is no point
in converting them to floats when storing a stack entry for them.
2010-04-15 14:50:26 +01:00
Neil Roberts
a0e19c9469 cogl-clip-stack: Use reference counted stack entries
The stack is now stored as a list of reference counted entries.
Instead of using a GList, each entry now contains a link with a
reference to its parent. The idea is that this would allow copying
stacks with a shared ancestry.

Previously the code flushed the state by finding the bottom of the
stack and then applying each entry by walking back up to the top. This
is slightly harder to do now because the list is no longer
doubly-linked. However I don't think it matters which order the
entries are applied so I've just changed it to apply them in reverse
order.

There was also a restriction that if ever the stencil buffer is used
then we could no longer use clip planes for any subsequent entries. I
don't think this makes sense because it should always work as long as
it doesn't attempt to use the clip planes more than once. I've
therefore removed the restriction.
2010-04-15 14:47:01 +01:00
Emmanuele Bassi
15ef549207 docs: Clean up ClutterActor's long description
The Actor's long description is a bit cluttered; it contains a section
on the actor's box semantics, on the transformation order and on the
event handling.

We should use <refsect2> tags to divide the Actor's description into
logically separated sections.

We should also add a section about the custom Scriptable properties that
ClutterActor defines, and the special handling of unit-based properties.
2010-04-14 23:34:38 +01:00
Neil Roberts
1445e9d32d cogl-atlas-texture: Fix a memory leak
The CoglAtlasTexture struct was not being freed in
_cogl_atlas_texture_free so there would be a small leak whenever a
texture was destroyed.

Thanks to Robert Bragg for spotting this.
2010-04-13 17:26:03 +01:00
Neil Roberts
30f43c6cda cogl-material: Use CLAMP_TO_EDGE for WRAP_AUTOMATIC unless overriden
CoglMaterial now sets GL_CLAMP_TO_EDGE if WRAP_MODE_AUTOMATIC is used
unless it is overridden when the material is flushed. The primitives
are still expected to expose repeat semantics so no user visible
changes are made. The idea is that drawing non-repeated textures is
the most common case so if we make clamp_to_ege the default then we
will reduce the number of times we have to override the
material. Avoiding overrides will become important if the overriding
mechanism is replaced with one where the primitive is expected to copy
the material and change that instead.
2010-04-12 15:44:23 +01:00
Neil Roberts
75f1dc90b0 cogl-material: Add support for setting the wrap mode for a layer
Previously, Cogl's texture coordinate system was effectively always
GL_REPEAT so that if an application specifies coordinates outside the
range 0→1 it would get repeated copies of the texture. It would
however change the mode to GL_CLAMP_TO_EDGE if all of the coordinates
are in the range 0→1 so that in the common case that the whole texture
is being drawn with linear filtering it will not blend in edge pixels
from the opposite sides.

This patch adds the option for applications to change the wrap mode
per layer. There are now three wrap modes: 'repeat', 'clamp-to-edge'
and 'automatic'. The automatic map mode is the default and it
implements the previous behaviour. The wrap mode can be changed for
the s and t coordinates independently. I've tried to make the
internals support setting the r coordinate but as we don't support 3D
textures yet I haven't exposed any public API for it.

The texture backends still have a set_wrap_mode virtual but this value
is intended to be transitory and it will be changed whenever the
material is flushed (although the backends are expected to cache it so
that it won't use too many GL calls). In my understanding this value
was always meant to be transitory and all primitives were meant to set
the value before drawing. However there were comments suggesting that
this is not the expected behaviour. In particular the vertex buffer
drawing code never set a wrap mode so it would end up with whatever
the texture was previously used for. These issues are now fixed
because the material will always set the wrap modes.

There is code to manually implement clamp-to-edge for textures that
can't be hardware repeated. However this doesn't fully work because it
relies on being able to draw the stretched parts using quads with the
same values for tx1 and tx2. The texture iteration code doesn't
support this so it breaks. This is a separate bug and it isn't
trivially solved.

When flushing a material there are now extra options to set wrap mode
overrides. The overrides are an array of values for each layer that
specifies an override for the s, t or r coordinates. The primitives
use this to implement the automatic wrap mode. cogl_polygon also uses
it to set GL_CLAMP_TO_BORDER mode for its trick to render sliced
textures. Although this code has been added it looks like the sliced
trick has been broken for a while and I haven't attempted to fix it
here.

I've added a constant to represent the maximum number of layers that a
material supports so that I can size the overrides array. I've set it
to 32 because as far as I can tell we have that limit imposed anyway
because the other flush options use a guint32 to store a flag about
each layer. The overrides array ends up adding 32 bytes to each flush
options struct which may be a concern.

http://bugzilla.openedhand.com/show_bug.cgi?id=2063
2010-04-12 15:44:23 +01:00
Neil Roberts
463ebc8220 Split the wrap mode of _cogl_texture_set_wrap_mode into three
GL supports setting different wrap modes for the s, t and r
coordinates so we should design the backend interface to support that
also. The r coordinate is not currently used by any of the backends
but we might as well have it to make life easier if we ever add
support for 3D textures.

http://bugzilla.openedhand.com/show_bug.cgi?id=2063
2010-04-12 15:44:23 +01:00
Neil Roberts
774f5e0bdf cogl: Make private members really hard to accidentally use
CoglColor and CoglMatrix have public declarations with private members
so that we are free to change the implementation but the structures
could still be allocated on the stack in applications. However it's
quite easy not to realise the members are private and then access them
directly. This patch wraps the members in a macro which redefines the
symbol name when including the header outside of the clutter source.

http://bugzilla.openedhand.com/show_bug.cgi?id=2065
2010-04-12 15:38:58 +01:00
Neil Roberts
3fea5051db CoglMatrix: Don't make the matrix fields private
The xx, yx, zx etc fields are meant to be read-only but they were
marked as private with the gtk-doc annotation. This patch moves the
private marker so that the 16 float member fields are public but the
type, inverted matrix, flags and padding are not.
2010-04-12 15:38:58 +01:00
Neil Roberts
94465cfe39 Fix indentation in CoglMatrix
The members of CoglMatrix were indented by 4 characters instead of 2.
2010-04-12 15:38:58 +01:00
Damien Lespiau
e0f41fa166 actor: Flag the color argument of the ::pick signal as being constant
When emitting signals, one can mark arguments as being "static", ie an
indication this argument will not change during the signal emission.
This allows the signal marshalling code to create static GValues, in
this case not to copy the Color.

http://bugzilla.openedhand.com/show_bug.cgi?id=2073
2010-04-12 12:48:46 +01:00
Emmanuele Bassi
93a5b78e5a actor: Do not use G_UNLIKELY in paint()
We decide whether the paint() should be a real paint or a paint in pick
mode depending on the global pick_mode value. Using G_UNLIKELY() on an
operation that most likely is going to be executed once every frame is
going to blow a lot of cache lines and frak with the CPU branch
prediction. Not good.
2010-04-09 18:28:37 +01:00
Fridrich Strba
c99a24d341 win32: Use GCLP_* instead of GCL_* when calling GetClassLongPtr
(commit message by Neil)

GetClassLongPtr expects a different constant when retrieving handles
or pointers. This fixes problems using Win64.
2010-04-09 15:43:42 +01:00
Neil Roberts
9ee6dd240b cogl: Support retained paths
This adds three new API calls:

  CoglHandle cogl_path_get()
  void cogl_path_set(CoglHandle path)
  CoglHandle cogl_path_copy(CoglHandle path)

All of the fields relating to the path have been moved from the Cogl
context to a new CoglPath handle type. The cogl context now just
contains a CoglPath handle. All of the existing path commands
manipulate the data in the current path handle. cogl_path_new now just
creates a new path handle and unrefs the old one.

The path handle can be stored for later with cogl_path_get. The path
can then be copied with cogl_path_copy. Internally it implements
copy-on-write semantics with an extra optimisation that it will only
copy the data if the new path is modified, but not if the original
path is modified. It can do this because the only way to modify a path
is by appending to it so the copied path is able to store its own path
length and only render the nodes up to that length. For this to work
the copied path also needs to keep its own copies of the path extents
because the parent path may change these by adding nodes.

The clip stack now uses the cogl_path_copy mechanism to store paths in
the stack instead of directly copying the data. This should save some
memory and processing time.
2010-04-08 19:53:38 +01:00
Robert Bragg
45885850d2 cogl: renames cogl_multiply_matrix to cogl_transform
Although cogl_multiply_matrix was consistent with OpenGL, after further
consideration it was agreed that cogl_transform is a better name. Given
that it's in the global cogl_ namespace cogl_transform seems more self
documenting.
2010-04-08 14:37:01 +01:00
Robert Bragg
412a468d5e docs: This improves the documentation for cogl_push_framebuffer
This adds an example of how to setup a Clutter style 2D coordinate space
and clarifies what state is owned by a framebuffer. (projection,
modelview, viewport and clip stack)

When we expose more cogl_framebuffer API this example will hopefully be
migrated into a more extensive introduction to using framebuffers.
2010-04-06 09:26:10 +01:00
Robert Bragg
6f6ab86929 cogl: move cogl_set_source* funcs into cogl.c
Previously cogl_set_source and cogl_set_source_texture were in
cogl-material.c and the cogl_set_source_color* funcs were in
cogl-color.c. Originally this was because cogl.c was duplicated between
the GL and GLES backends and we didn't want to add to the amount of
duplicated code, but these files have since been consolidated into one
cogl.c.
2010-04-06 09:26:05 +01:00
Robert Bragg
a678e9f627 cogl: adds convenience cogl_multiply_matrix function
Quite often it's desirable to be able to multiply the current modelview
matrix by an arbitrary matrix. Currently though you have to first
explicitly call cogl_get_modelview_matrix to get the current modelview
into a temporary variable, then you need to multiply it with your matrix
using cogl_matrix_multiply and finally use cogl_set_modelview_matrix to
make the result be the new modelview. This new convenience function lets
more efficiently skip the first get and last set steps.
2010-04-01 13:24:56 +01:00
Robert Bragg
1dd70aff73 cogl: rename cogl_enable to _cogl_enable
Every now and then someone sees the cogl_enable API and gets confused,
thinking its public API so this renames the symbol to be clear that it's
is an internal only API.
2010-04-01 12:34:42 +01:00
Owen W. Taylor
6fcc8c5bce x11: Use has_allocation() in TfP actor
ClutterX11TexturePixmap calls get_allocation_box() when queueing a
clipped redraw. If the allocation is not valid, and if we queue a
lot of redraws in response to a series of damage events, the net
result is that we spend all our time in a re-layout. We can
short-circuit this by checking if the actor has a valid allocation, and
if not, just queue a redraw - the actor will be allocated by the time it
is going to be painted.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-26 00:46:43 +00:00
Owen W. Taylor
8df4a0b8fd actor: Add has_allocation() method
Add clutter_actor_has_allocation(), a method meant to be used when
deciding whether to call clutter_actor_get_allocation_box() or any
of its wrappers.

The get_allocation_box() method will, in case the allocation is invalid,
perform a costly re-allocation cycle to ensure that the returned box
is valid. The has_allocation() method is meant to be used if we have an
actor calling get_allocation_box() from outside the place where the
allocation is always guaranteed to be valid.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-26 00:46:31 +00:00
José Dapena Paz
7b63da69cf Add "homogeneous" mode to ClutterBoxLayout.
Added new "homogeneous" mode to ClutterBoxLayout, that makes layout children
get all the same size.

This is heavily inspired in the "homogeneous" attribute available in GtkBox,
but simplified as we don't have padding nor borders in box layout, only
spacing.

Also added to test-box-layout a key to set/unset homogeneous mode.

* Coding style fixes.
* Added proper test for homogeneous mode in box layout.
* Fix in homogeneous mode.

http://bugzilla.openedhand.com/show_bug.cgi?id=2034

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-25 09:41:54 +00:00
Emmanuele Bassi
5395a7a998 Use begin/end macros in cogl-primitives.h
Protect the people using a C++ compiler from the dark abyss of C code.

http://bugzilla.openedhand.com/show_bug.cgi?id=2049
2010-03-25 09:33:26 +00:00
Neil Roberts
6a8e108757 clutter-actor: Rename y1 to y_1 to avoid a compiler warning
Somebody somewhere decided it would be ok to define 'y1' as a global
function in math.h thus condemning us to repeatedly making commits to
fix these obnoxious compiler warnings about aliasing.
2010-03-24 15:32:28 +00:00
Adel Gadllah
5de85051c3 Make sure GLX_SGI_swap_control is set up correctly
glXSwapIntervalSGI only affects buffer swaps to the
current GLX drawable.

That means that calling it once in clutter_backend_glx_get_features
isn't sufficent, so set it up in clutter_backend_glx_ensure_context to
make sure it affects buffer swaps for the current drawable.

http://bugzilla.openedhand.com/show_bug.cgi?id=2044

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-22 11:23:55 +00:00
Owen W. Taylor
2fc8ecdb92 glx: Clean up the clip area conditions
Move the size check after the NULL check, add the clip height into the
check logic and fix up the comment.

http://bugzilla.openedhand.com/show_bug.cgi?id=2040

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-19 18:23:03 +00:00
Emmanuele Bassi
f935270aa0 script: Do not allocate memory when not needed
When printing out the property value during a ClutterScript debug run we
generate the value's content using g_strdup_value_contents() - though we
do it unconditionally. The contents might not be printed (they most
likely won't, actually) and will be freed afterwards. This is
unnecessary: we can allocate the contents string after checking if we're
going to print out the debug note, thus avoiding the whole
allocation/free cycle unless strictly needed.
2010-03-19 16:24:34 +00:00
Emmanuele Bassi
a39cef41b8 glx: Do not access stage_clip without checking it
The stage_clip parameter for add_redraw_clip() can be NULL, so we need
to check before accessing its members.
2010-03-19 11:41:12 +00:00
Owen W. Taylor
913c187f4e Switch texture units before calling _cogl_texture_set_filters()
When setting up the state for a layer, we need to switch texture
units before we do anything that might bind the texture, or
we'll bind the wrong texture to the previous unit.

http://bugzilla.openedhand.com/show_bug.cgi?id=2033

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-19 11:23:48 +00:00
Emmanuele Bassi
66e0f18753 json: Update JsonParser
Add another fix from upstream, to clean up the code.
2010-03-19 11:13:04 +00:00
Emmanuele Bassi
295bc517f8 json: Update the internal copy of JsonGenerator
The JsonGenerator we have inside Clutter as a fallback for a missing
system copy of JSON-GLib is way out of date.
2010-03-19 10:40:12 +00:00
Owen W. Taylor
d21b7522f8 Fix errors in keeping track of the stage bounding rectangle
* Add new clutter_geometry_union(), because writing union intersection
  is harder than it looks. Fixes two problems with the inline code in
  clutter_stage_glx_add_redraw_clip().

  1) The ->x and ->y of were reassigned to before using them to
     compute the new width and height.
  2) since ClutterGeometry has unsigned width, x + width is unsigned,
     and comparison goes wrong if either rectangle has a negative
     x + width. (We fixed width for GdkRectangle to be signed for GTK+-2.0,
     this is a potent source of bugs.)

* Use in clutter_stage_glx_add_redraw_clip()

* Account for the case where the incoming rectangle is empty, and don't
  end up with the stage being entirely redrawn.

* Account for the case where the stage already has a degenerate
  width and don't end up with redrawing only the new rectangle and not
  the rest of the stage.

The better fix here for the second two problems is to stop using a 0
width to mean the entire stage, but this should work for now.

http://bugzilla.openedhand.com/show_bug.cgi?id=2040

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-19 10:29:53 +00:00
Owen W. Taylor
bfd2b19290 Set pixel store parameters before calling glGetTexImage
We need to set up the rowstride and alignment properly in
CoglTexture2D before reading texture data.

http://bugzilla.openedhand.com/show_bug.cgi?id=2036

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-19 10:21:34 +00:00
Emmanuele Bassi
a8595aec13 script: Add more comments and annotations
Detail why we are adding a fake id, and under which circumstances that
happens. Also be more verbose with the debug annotations.
2010-03-18 20:20:09 +00:00
Emmanuele Bassi
203847d03c script: Skip empty nodes
If we get an empty node then we should skip it; this is really a
workaround for something that is broken in JSON-GLib or in our use
of JSON-GLib.
2010-03-18 17:44:14 +00:00
Emmanuele Bassi
d2bb57c3b2 Emit a critical warning if features are not initialized
If you forgot to call clutter_init() then you currently end up with a
warning saying that the stage cannot be initialized because the backend
does not support multiple stages. Clearly not useful.

We can catch some of the missing initialization in the features API,
since we will likely end up asking for a feature at some point.
2010-03-18 14:15:33 +00:00
Emmanuele Bassi
54504b7ac4 glx: Remove unnecessary call to create_stage()
If we are in the stage realization sequence we already have a GLX
context set in the backend; there is no need to call create_backend().
2010-03-17 17:41:52 +00:00
Emmanuele Bassi
bf7e6ae587 Add error reporting for create_context() failures
We kind of assume that stuff will break well before during the
ClutterBackend::create_context() implementation if we fail to create a
GL context. We do, however, have error reporting in place inside the
Backend API to catch those cases. Unfortunately, since we switched to
lazy initialization of the Stage, there can be a case of GL context
creation failure that still leads to a successful initialization - and a
segmentation fault later on. This is clearly Not Good™.

Let's try to catch a failure in all the places calling create_context()
and report back to the user the error in a meaningful way, before
crashing and burning.
2010-03-17 17:40:34 +00:00
Emmanuele Bassi
d735ac4807 model: Let get_n_columns() return a sane value
If you call get_n_columns() during the instance initialization phase but
before set_name()/set_types() have been called, you'll get a (guint) -1.
This is less than ideal.

If columns haven't been initialized we should just return 0, which was
the intent of the API since the beginning.

Based on a patch by: Bastian Winkler <buz@netbuz.org>

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-17 17:14:08 +00:00
Emmanuele Bassi
0a6497a3b6 model: Add a comment on the n_columns field type
To avoid another bug report like:

  http://bugzilla.openedhand.com/show_bug.cgi?id=2017

with a patch that gets applied without a proper review, resulting in a
bug like:

  http://bugzilla.openedhand.com/show_bug.cgi?id=2032

I should probably add a comment on why on earth we're using an integer
as the n_columns member of the ClutterModelPrivate structure, and why it
is important that it is initialized as -1.
2010-03-16 18:57:28 +00:00
Emmanuele Bassi
de4abfac95 Revert "model: Use guint for the n_columns field"
The int storage, and the initial value of -1, is used as a guard when
subclassing ClutterListModel to allow the sub-class to call
clutter_model_set_names() and clutter_model_set_types().

This reverts commit c274118a8f.
2010-03-16 18:53:24 +00:00
Colin Walters
60d8369a1a Return and warn if a handle's refcount is <= 0
This makes it more likely consumers notice invalid unreferences.
GObject has the same assertion.

http://bugzilla.openedhand.com/show_bug.cgi?id=2029

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-15 16:22:20 +00:00
Bastian Winkler
c274118a8f model: Use guint for the n_columns field
clutter_model_get_n_columns is supposed to return a guint, so the
n_columns field needs to be a guint with the initial value set to 0.

http://bugzilla.openedhand.com/show_bug.cgi?id=2017

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-15 16:22:20 +00:00
Neil Roberts
c2faaa4f39 cogl-texture-2d: Determine format before checking texture support
When entering cogl_texture_2d_new_from_bitmap the internal format can
be COGL_PIXEL_FORMAT_ANY. This was causing _cogl_texture_2d_can_create
to use an invalid GL format type. Mesa apparently ignores this but it
was causing errors when Cogl is compiled with debugging under NVidia.

http://bugzilla.openedhand.com/show_bug.cgi?id=2026
2010-03-15 16:09:52 +00:00
Owen W. Taylor
a25885edf2 Fix checks for out-of-bounds coordinates and repeats
Add a return result from CoglTexture.transform_quad_coords_to_gl(),
so that we can properly determine the nature of repeats in
the face of GL_TEXTURE_RECTANGLE_ARB, where the returned
coordinates are not normalized.

The comment "We also work out whether any of the texture
coordinates are outside the range [0.0,1.0]. We need to do
this after calling transform_coords_to_gl in case the texture
backend is munging the coordinates (such as in the sub texture
backend)." is disregarded and removed, since it's actually
the virtual coordinates that determine whether we repeat,
not the GL coordinates.

Warnings about disregarded layers are used in all cases where
applicable, including for subtextures.

http://bugzilla.openedhand.com/show_bug.cgi?id=2016

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2010-03-15 16:09:41 +00:00
José Dapena Paz
6bd1846d6c Fix argb initialisation.
Fix clutter initialisation if argb visuals are enabled, setting a border
color on creating the dummy window. This should avoid BadMatch happening
when the depth of the root window visual is not the same of the depth
of the argb visual.

http://bugzilla.openedhand.com/show_bug.cgi?id=2011

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-03-10 00:13:37 +00:00
Emmanuele Bassi
3d2d932835 actor: Remove some double indirection
Use an intermediate variable to avoid a double indirection when accessing
the instance private data structure.
2010-03-07 23:46:59 +00:00
Emmanuele Bassi
9ad1197cb2 json: Improve strictness of the JSON parser
Backport of the upstream JSON-GLib commit that improved the strictness
of JsonParser.

The original upstream commit is:

  29881f03468db08bfb404cfcd5b61b4cdc419a87
2010-03-07 20:54:33 +00:00
Emmanuele Bassi
ac074bc0f0 eglnative: Connect StageWindow.show and .hide
The show() and hide() methods of the StageWindow interface are
implemented but not assigned when initializing the interface
vtable.
2010-03-05 08:48:52 +00:00
Owen W. Taylor
f13a42793a CoglTexture2DSliced: Handle TEXTURE_RECTANGLE_ARB
In _cogl_texture_2d_sliced_foreach_sub_texture_in_region(), don't
assert that the target is GL_TEXTURE_2D; instead conditionalize
normalization on the target.

http://bugzilla.openedhand.com/show_bug.cgi?id=2015
2010-03-04 12:57:53 +00:00
Neil Roberts
40b43fd64a eglnative: Don't create a context if there already is one
If the EGL context is already created then we shouldn't try to create
another one. This was causing problems where one context would be
created from calling _clutter_feature_init and the other was created
from _clutter_backend_get_features. Cogl would set up its state using
the first context and then assume the state was still valid when the
second context became used so blending was not working correctly.

http://bugzilla.openedhand.com/show_bug.cgi?id=2020
2010-03-04 10:28:15 +00:00
Emmanuele Bassi
169ce1508b x11-texture-pixmap: Move signal handler override
The signal handling override for the ::queue-damage-redraw should be
done in the class initialization function, not in the instance one.
2010-03-03 17:46:53 +00:00
Emmanuele Bassi
1b57800208 Update stb_image.c
Upstream "released" 1.18.
2010-03-03 17:02:51 +00:00
Øyvind Kolås
b19332a0be animator: compare floating point values with an epsilon
Direct comparisons with doubles are error prone.
2010-03-03 15:53:07 +00:00
Øyvind Kolås
4168b216a3 animator: fix a crash in clutter_animator_compute_value
Fix a crasher when there is only one key in the animator.
2010-03-03 15:51:30 +00:00
Emmanuele Bassi
824cd9a7ff eglnative: Compilation fixes
We should include <errno.h>, if we plan to use errno.

Why, yes: I am that stupid.
2010-03-03 15:31:01 +00:00
Emmanuele Bassi
52f8cd30ce docs: Fix gtk-doc annotation for ClutterStageManageClass
Remove the semi-colon and use a colon for declaring the type.
2010-03-03 10:49:34 +00:00
Emmanuele Bassi
a2f444ccbe box: Fix allow-none annotation
The syntax for allowing NULL is "allow-none", not "allow none".
2010-03-03 10:47:42 +00:00
Neil Roberts
048fcea988 clutter-actor: Initialize with the identity matrix in get_transform
The documentation and name of the get_transformation_matrix function
implies that 'matrix' is purely an out parameter. However it wasn't
initializing the matrix before calling the 'apply_transform' virtual
so it was basically just a wrapper for the virtual. The virtual
assumes the matrix parameter is in/out and applies the actor's
transformation on top of any existing transformations. This causes
unexpected semantics that are inconsistent with the documentation.
2010-03-02 18:43:22 +00:00
Robert Bragg
38a2414498 glx tfp: make clutter_glx_texture_pixmap_update_area cheap
This changes clutter_glx_texture_pixmap_update_area so it defers the
call to glXBindTexImageEXT until our pre "paint" signal handler which
makes clutter_glx_texture_pixmap_update_area cheap to call.

The hope is that mutter can switch to reporting raw damage updates to
ClutterGLXTexturePixmap and we can use these to queue clipped redraws.
2010-03-02 17:19:11 +00:00
Robert Bragg
c0d5af5de5 Adds initial clipped redraw support to Clutter
A new (internal only currently) API, _clutter_actor_queue_clipped_redraw
can be used to queue a redraw along with a clip rectangle in actor
coordinates. This clip rectangle propagates up to the stage and clutter
backend which may optionally use the information to optimize stage
redraws. The GLX backend in particular may scissor the next redraw to
the clip rectangle and use GLX_MESA_copy_sub_buffer to present the stage
subregion.

The intention is that any actors that can naturally determine the bounds
of updates should queue clipped redraws to reduce the cost of updating
small regions of the screen.

Notes:
» If GLX_MESA_copy_sub_buffer isn't available then the GLX backend
  ignores any clip rectangles.

» queuing multiple clipped redraws will result in the bounding box of
  each clip rectangle being used.

» If a clipped redraw has a height > 300 pixels then it's promoted into
  a full stage redraw, so that the GPU doesn't end up blocking too long
  waiting for the vsync to reach the optimal position to avoid tearing.

  » Note: no empirical data was used to come up with this threshold so
    we may need to tune this.

» Currently only ClutterX11TexturePixmap makes use of this new API. This
  is done via a new "queue-damage-redraw" signal that is emitted when
  the pixmap is updated. The default handler queues a clipped redraw
  with the assumption that the pixmap is being painted as a rectangle
  covering the actors transformed allocation. If you subclass
  ClutterX11TexturePixmap and change how it's painted you now also
  need to override the signal handler and queue your own redraw.

  Technically this is a semantic break, but it's assumed that no one
  is currently doing this.

This still leaves a few unsolved issues with regards to optimizing sub
stage redraws that need to be addressed in further work so this can only
be considered a stepping stone a this point:

» Because we have no reliable way to determine if the painting of any
  given actor is being modified any optimizations implemented using
  _clutter_actor_queue_redraw_with_clip must be overridable by a
  subclass, and technically must be opt-in for existing classes to avoid
  a change in semantics. E.g. consider that a user connects to the paint
  signal for ClutterTexture and paints a circle instead of a rectangle.
  In this case any original logic to queue clipped redraws would be
  incorrect.

» Currently only the implementation of an actor has enough information
  with which to queue clipped redraws. E.g. It is not possible for
  generic code in clutter-actor.c to queue a clipped redraw when hiding
  an actor because actors have no way to report a "paint box". (remember
  actors can draw outside their allocation and actors with depth may
  also be projected outside of their allocation)

  » The current plan is to add a actor_class->get_paint_cuboid()
    virtual so actors can report a bounding cube for everything they
    would draw in their current state and use that to queue clipped
    redraws against the stage by projecting the paint cube into stage
    coordinates.

» Our heuristics for promoting clipped redraws into full redraws to
  avoid blocking the GPU while we wait for the vsync need improving:

  » vsync issues aren't relevant for redirected/composited applications
    so they should use different heuristics. In this case we instead
    need to trade off the cost of blitting when using glXCopySubBuffer
    vs promoting to a full redraw and flipping instead.
2010-03-02 17:19:11 +00:00
Øyvind Kolås
09d8460a5c animator: s/clutter_animator_run/clutter_animator_start/
This is consistent with choice of words in clutter_timeline_start and
makes the API less surprising.
2010-03-02 17:03:03 +00:00
Robert Bragg
9d1ea81dc5 cogl debug: Adds missing guards around debug cogl_args[]
commit 511e5ceb51 accidentally removed the #ifdef COGL_ENABLE_DEBUG
guards around the "cogl-debug" and "cogl-no-debug" cogl_args[] which
this patch restores.
2010-03-02 16:15:39 +00:00
Emmanuele Bassi
aba6c5acc7 flow-layout: Provide a preferred size
The FlowLayout fails to provide a preferred size in case no sizing is
specified on one axis. It should, instead, have the preferred size of
the sum of its children, depending on the orientation property.

http://bugzilla.openedhand.com/show_bug.cgi?id=2013
2010-03-02 15:11:27 +00:00
Øyvind Kolås
9a55ddc7c3 animator: restore accidentally removed break
In 505e5966 a break statement was removed by accident, causing the
animator to enter infinite loops if no initial key is present.
2010-03-02 12:38:51 +00:00
Emmanuele Bassi
3a84af0106 Merge branch 'eglnative-update'
* eglnative-update:
  eglnative: Add CLUTTER_FB_DEVICE
  eglnative: Update implementation
2010-03-02 12:25:45 +00:00
Emmanuele Bassi
a2573ad2ad eglnative: Add CLUTTER_FB_DEVICE
Some EGL drivers for embedded devices require a specific framebuffer
device to be opened and passed to eglCreateWindowSurface(). Since it's
optional, we can provide an environment variabled called
CLUTTER_FB_DEVICE that can be used to specify the path of the device
to be opened.

http://bugzilla.openedhand.com/show_bug.cgi?id=1997
2010-03-02 11:50:31 +00:00
Emmanuele Bassi
b4e9f40394 eglnative: Update implementation
Update the EGL native framebuffer backend to be 1.2-ready:

  » create the EGL context and the surface inside the create_context()
    implementation so that a context is always available

  » simplify the StageWindow implementation

  » clean up old code

http://bugzilla.openedhand.com/show_bug.cgi?id=1997
2010-03-02 11:50:31 +00:00
Owen W. Taylor
0baeabc2aa Fall back in _cogl_texture_2d_new_from_bitmap()
Just like _cogl_texture_2d_new_with_size(),
_cogl_texture_2d_new_from_bitmap() needs to check if an unsliced
texture can be created at the given size, or if hardware
limitations prevent this.

http://bugzilla.openedhand.com/show_bug.cgi?id=2014

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2010-03-02 11:48:15 +00:00
Emmanuele Bassi
74a27bbb1c docs: Documentation fixes
Let's see if we can get a 100% coverage for Clutter too.
2010-03-02 11:12:32 +00:00
Neil Roberts
c0a553163b cogl: Support any format in cogl_read_pixels
cogl_read_pixels() no longer asserts that the format passed in is
RGBA_8888 but instead accepts any format. The appropriate GL enums for
the format are passed to glReadPixels so OpenGL should be perform a
conversion if neccessary.

It currently assumes glReadPixels will always give us premultiplied
data. This will usually be correct because the result of the default
blending operations for Cogl ends up with premultiplied data in the
framebuffer. However it is possible for the framebuffer to be in
whatever format depending on what CoglMaterial is used to render to
it. Eventually we may want to add a way for an application to inform
Cogl that the framebuffer is not premultiplied in case it is being
used for some special purpose.

If the requested format is not premultiplied then Cogl will convert
it. The tests have been changed to read the data as premultiplied so
that they won't be affected by the conversion. Picking in Clutter has
been changed to use COGL_PIXEL_FORMAT_RGB_888 because it doesn't need
the alpha component. clutter_stage_read_pixels is left unchanged
because the application can't specify a format for that so it seems to
make most sense to store unpremultiplied values.

http://bugzilla.openedhand.com/show_bug.cgi?id=1959
2010-03-02 11:01:35 +00:00
Øyvind Kolås
505e5966e4 Do not overwrite the initial key, making ease-in work as expected.
Fixes bug #2008, where a property with ease-in would jump instead of
start at the properties initial value.
2010-03-01 18:39:24 +00:00
Bastian Winkler
7d0ad7ac1b animator: Remove redundant declaration in header file
clutter_animator_property_set_interpolation was declared twice in
clutter-animator.h

http://bugzilla.openedhand.com/show_bug.cgi?id=2012
2010-03-01 17:49:58 +00:00
Emmanuele Bassi
1d9ddad9a3 docs: Fix syntax error in Model's documentation
A missing opening quote sign is breaking gtk-doc for ClutterModel.
2010-03-01 17:45:00 +00:00
Emmanuele Bassi
1777a69f2f Merge branch 'stage-min-size-rework'
* stage-min-size-rework:
  docs: Update minimum size accessors
  actor: Use the TOPLEVEL flag instead of a type check
  [stage] Use min-width/height props for min size
2010-03-01 15:37:12 +00:00
Robert Bragg
8146d8d08d profile: avoid segfault generating reports with no stats
The clutter-profile.c print_report() code would crash if no stats had
been gathered because uprof would return NULL for the "Redrawing" timer
which we then dereferenced.

This changes the code to start by checking for the "Mainloop",
"Redrawing" and "Do Pick" timers and if none are present it returns
immediately without generating any report.
2010-03-01 15:25:45 +00:00
Robert Bragg
b9a91594f4 build: Fixes out of tree builds
When building the gobject introspection data the build wasn't able to
find clutter/clutter-json.h so this adds $(top_builddir) to INCLUDES.
2010-03-01 15:25:45 +00:00
Emmanuele Bassi
79acb088e7 Remove mentions of the FSF address
Since using addresses that might change is something that finally
the FSF acknowledge as a plausible scenario (after changing address
twice), the license blurb in the source files should use the URI
for getting the license in case the library did not come with it.

Not that URIs cannot possibly change, but at least it's easier to
set up a redirection at the same place.

As a side note: this commit closes the oldes bug in Clutter's bug
report tool.

http://bugzilla.openedhand.com/show_bug.cgi?id=521
2010-03-01 12:56:10 +00:00
Emmanuele Bassi
23867875a1 build: Remove unused checks on platform functions
There is no need for us to check for low-level functions and header
files, especially since we haven't been checking the results until
now. This makes cross-compiling slightly more bearable.
2010-03-01 11:12:16 +00:00
Emmanuele Bassi
ce6a24eb2b actor: Call unparent() in destroy
If the actor is an internal child of another actor then we should call
unparent() when destroying it, like clutter_actor_reparent() does;
otherwise we'll leak the actor, since the parent holds a reference to
it.

http://bugzilla.openedhand.com/show_bug.cgi?id=2009
2010-02-28 10:59:29 +00:00
Emmanuele Bassi
7ffb62eab9 docs: Update minimum size accessors
Expand the documentation for set_minimum_size() and get_minimum_size(),
and add introspection annotations for get_minimum_size().
2010-02-27 18:56:34 +00:00
Emmanuele Bassi
52ba9a1800 actor: Use the TOPLEVEL flag instead of a type check
We can use the internal private CLUTTER_ACTOR_IS_TOPLEVEL flag, which is
set only on Stages.
2010-02-27 18:24:17 +00:00
Chris Lord
cd62dfbd14 [stage] Use min-width/height props for min size
Instead of shadowing these properties with different properties with the
same names on stage, actually use them. Behaviour should be identical,
except the minimum stage size can now be enforced by setting the
min-width/height properties as well as using the set_minimum_size
function.
2010-02-26 18:36:38 +00:00
Emmanuele Bassi
e0f04efa41 device: When changing the stage, unset the pointer actor
If we do not unset the Stage we will have stale data, and the Crossing
event when re-entering a Stage will not be emitted, as the actor under
the pointer might be the same as before.
2010-02-26 11:19:26 +00:00
Neil Roberts
5d83468295 cogl-vertex-buffer: Add support for unsigned int indices
This adds a COGL_INDICES_TYPE_UNSIGNED_INT enum value so that unsigned
ints can be used with cogl_vertex_buffer_indices_new.  Unsigned ints
are not supported in core on GLES so a feature flag has also been
added to advertise this. GLES only sets the feature if the
GL_OES_element_index_uint extension is available. It is an error to
call indices_new() with unsigned ints unless the feature is
advertised.

http://bugzilla.openedhand.com/show_bug.cgi?id=1998
2010-02-26 10:56:35 +00:00
Emmanuele Bassi
67d9d92814 docs: Document the "columns" syntax for ClutterModel
Like we do for other classes implementing custom properties, we should
document the syntax of the "columns" scriptable property of ClutterModel.
2010-02-25 23:23:53 +00:00
Bastian Winkler
96c31bbf0e model: Implement ClutterScriptable interface
Allow a ClutterModel to be constructed through the ClutterScript API.
Currently this allows a model to be generated like like this:

{
  "id" : "test-model",
  "type" : "ClutterListModel",
  "columns" : [
    [ "text-column", "gchararray" ],
    [ "int-column", "gint" ],
    [ "actor-column", "ClutterRectangle" ]
  ]
}

where 'columns' is an array containing arrays of column-name,
column-type pairs.

http://bugzilla.openedhand.com/show_bug.cgi?id=2007
2010-02-25 23:09:11 +00:00
Emmanuele Bassi
63279f827e docs: gtk-doc fixes for Animator
Fix the syntax for:

  → enumeration values
  → return values
  → @since tags

Also, fix the introspection annotations.
2010-02-25 22:50:38 +00:00
Emmanuele Bassi
9db135c4ef glx: Clean up sync-to-vblank mechanism discovery
The code has gotten really complicated to follow.

As soon as we have a sync-to-vblank mechanism we should just bail out.

Also, __GL_SYNC_TO_VBLANK (which is used by nVidia) should be assumed
equivalent to a CLUTTER_VBLANK_GLX_SWAP.
2010-02-25 18:56:39 +00:00
Emmanuele Bassi
655cb966c0 docs: Add visual cue for Animator's key frames
We should explain what a "key frame" is for ClutterAnimator, possibly
with some sort of visual cue.

This allows me to demonstrate my poor skills at using Inkscape, as well
as my overall bad taste for graphics design.
2010-02-25 17:09:55 +00:00
Emmanuele Bassi
d3d05261e6 script-parser: Remove top-level types list
The top-level types list was comically out of date, and it was only
determining whether the type we were constructing was initially unowned
or a full object. We can safely replace it with a simple type check.
2010-02-25 14:22:08 +00:00
Emmanuele Bassi
c0be19eff6 script-parser: Be more strict with "children" members
The "children" member for Container definitions should only reference
actors, and warn about any other type.
2010-02-25 14:20:05 +00:00
Emmanuele Bassi
c291d5a660 animator: Add a :timeline property
It would be useful to be able to share the Timeline across different
animator instances, or with different animation constructs. Also this
allows sharing definitions of Timelines in ClutterScript.
2010-02-25 14:08:57 +00:00
Emmanuele Bassi
6415825339 animator: Remove NULL check in remove_key()
The arguments for remove_key() can be NULL, but there is an extraneous
assertion that fails if they are. The pre-conditions should match the
documentation, in this case.
2010-02-25 14:02:29 +00:00
Emmanuele Bassi
4bc4c604e9 box: Let pack_at() create the ChildMeta, if any
A sub-class of ClutterBox might add ChildMeta support, and since
pack_at() does not go through clutter_container_add_actor(), we
need to manually call the create_child_meta() ourselves.
2010-02-25 12:55:12 +00:00
Emmanuele Bassi
543e2d3f06 container: Expose create and destroy ChildMeta methods
It is conceivable that Container implementations might add children
outside of the Container::add() implementation - e.g. for packing at
a specific index. Since the addition (and removal) might happen outside
the common path we need to expose all the API that is implicitly called
by ClutterContainer when adding and removing a child - namely the
ChildMeta creation and destruction.
2010-02-25 12:55:12 +00:00
Neil Roberts
14999bec5e gles2: Remove the special wrapper for glBindTexture
Previously the GLES2 backend needed a special wrapper for
glBindTexture because it needed to know the internal GL format of the
texture in order to correctly implement the GL_MODULATE texture env
mode. When GL_MODULATE is used then the RGB values are taken from the
previous texture layer rather than being fetched from the
texture. However since the material API was added Cogl no longer uses
the GL_MODULATE texture env mode but instead always uses GL_COMBINE.

Compiling the GLES2 backend broke since the more-texture-backends
branch merge because the cogl_get_internal_gl_format function was
removed and there was one place in GLES2 specific code that was using
this to bind the texture.
2010-02-25 12:50:52 +00:00
Neil Roberts
eba07020c5 cogl-gles2-wrapper: Add support for the layer combine operations
The texture layer combine functions are now hard coded to GL_COMBINE
instead of GL_MODULATE. The combine function can be customized with
all the parameters of GL_COMBINE. A shader is generated to implement
the given parameters.

Currently it will try to generate code for the constant color but it
will use a uniform which does not exist.
2010-02-25 12:50:52 +00:00
Neil Roberts
02b952394a gles2: Implement a wrapper for glGetIntegerv(GL_MAX_TEXTURE_UNITS)
The GLES2 backend for Cogl is failing to compile because
GL_MAX_TEXTURE_UNITS is not defined. Let's define it and provide a
wrapper which uses GL_MAX_TEXTURE_IMAGE_UNITS or
COGL_GLES2_MAX_TEXTURE_UNITS, whichever is the smallest.
2010-02-25 12:50:52 +00:00
Øyvind Kolås
3bc0672fef animator: handle no initial key
Fixing the crasher reported in bug #1995.
2010-02-25 12:35:19 +00:00
Øyvind Kolås
d2db512788 animator: added clutter_animator_compute_value
Allow querying the computed values of properties managed by a
ClutterAnimator.
2010-02-25 12:35:06 +00:00
Øyvind Kolås
e8d32fd153 animator: removed bogus arg in keys interpolation accessor
A bogus ClutterInterpolation argument had been carried from
clutter_animator_set_interpolation to clutter_animator_get_interpolation
in copy and paste.
2010-02-25 12:35:05 +00:00
Emmanuele Bassi
be8f53f229 animation: Fix a typo
This will teach me to check before compiling a version-dependent branch
that I'm actually using my jhbuild environment and not the system
libraries.
2010-02-25 12:01:03 +00:00
Emmanuele Bassi
26e22b2ede Conditionally use G_VALUE_COLLECT_INIT() macro
GLib 2.24 (but starting from the 2.23.2 unstable release) added a new
macro for collecting GValues from a va_list.

The newly added G_VALUE_COLLECT_INIT() macro should be used in place
of initializing the GValue and calling G_VALUE_COLLECT(), and improves
the collection performances by avoiding multiple checks, free and
initialization calls.
2010-02-25 10:22:36 +00:00
Bastian Winkler
59fd7e4a81 animator: Append parsed animator keys to previously parsed ones
Reuse the GSList of the previously parsed property when building a
ClutterAnimator from script, otherwise only the last used property will
be used

http://bugzilla.openedhand.com/show_bug.cgi?id=2003
2010-02-24 16:33:19 +00:00
Emmanuele Bassi
ec0c7fcd9b build: Use the right headers when enumerating them
The installed _HEADERS should be the public ones and the enumeration
types; repeating clutter-x11-texture-pixmap.h breaks with automake 1.11
and doesn't strictly make any sense.

http://bugzilla.openedhand.com/show_bug.cgi?id=2002
2010-02-24 14:23:58 +00:00
Emmanuele Bassi
d1ca0e1b8f fixed layout: Store a back pointer to the Container
When set_container() is called with a NULL container we cannot use the
passed pointer to unset the CLUTTER_ACTOR_NO_LAYOUT flag. We should
store a back pointer to the container as object data (there's no need
to add a Private data structure in this case) and unset the flag on the
back pointer instead.
2010-02-24 12:25:53 +00:00
Emmanuele Bassi
aa8c812705 box: Do not short-circuit size negotiation for empty Boxes
The LayoutManager used might decide to have a default allocation or a
default preferred size when empty.
2010-02-24 12:10:23 +00:00
Robert Bragg
523bab0868 layout: allow wider use of the CLUTTER_ACTOR_NO_LAYOUT flag
Previously only ClutterGroup was able to set the CLUTTER_ACTOR_NO_LAYOUT
flag which allows clutter-actor.c to avoid a relayout when showing or
hiding fixed layout containers. Instead of it being the responsibility
of the container to set this flag this patch makes the layout manager
itself decide in the ::set_container method. This way both ClutterBox
and ClutterGroup can take advantage of the optimization.
2010-02-24 12:07:23 +00:00
Emmanuele Bassi
f21e649c80 docs: Detail replacement for cogl_check_extension()
The cogl_check_extension() function has been deprecated, but it's easily
replaceable with a simple strstr() call.
2010-02-24 11:28:44 +00:00
Emmanuele Bassi
d54af2363d build: Use template for ClutterX11 enumerationt types
Clutter and Cogl use the template Makefile.am.enums for building the
enumeration GTypes from public headers, but ClutterX11 is not.
2010-02-24 10:20:10 +00:00
Neil Roberts
eb35c446b1 clutter-box: Layer new actors on top of all others at the same depth
g_list_insert_sorted inserts the new actor before all others that
compare equal so for the normal case when all actors have depth==0
this has the surprising behaviour of layering the actors in reverse
order. To fix this it now manually inserts the actor in the right
place by searching until it finds an actor at a higher depth and
inserting before that.

http://bugzilla.openedhand.com/show_bug.cgi?id=1988
2010-02-24 10:03:43 +00:00
Neil Roberts
da0315e4d6 box: Revert "Tweak the depth sorting function"
This reverts commit 939e56e2b1.

Changing the depth sort function to have inconsistent behaviour for
nodes that compare equal breaks the stability of g_list_sort. It ends
up so that every time clutter_container_sort_depth_order is called the
order of all actors with the same depth is reversed.

http://bugzilla.openedhand.com/show_bug.cgi?id=1988
2010-02-24 10:03:41 +00:00
Robert Bragg
1c65f2ee1e cogl debug: Adds glViewport call tracing
To aid in the debugging of Clutter stage resize issues this adds a
COGL_DEBUG=opengl option that will trace "some select OpenGL calls"
(currently just glViewport calls)
2010-02-23 22:09:07 +00:00
Robert Bragg
fa3830ff20 cogl debug: hint that all debugging paths are G_UNLIKELY
Most Cogl debugging code conditions are marked as G_UNLIKELY with the
intention of having the CPU branch prediction always assume the
path is disabled so having debugging support in release binaries has
negligible overhead.

This patch simply fixes a few cases where we weren't using G_UNLIKELY.
2010-02-23 22:09:07 +00:00
Robert Bragg
511e5ceb51 cogl debug: Makes COGL_DEBUG=all|verbose|help more useful
COGL_DEBUG=all wasn't previously useful as there are several options
that change the behaviour of Cogl and all together wouldn't help anyone
debug anything.

This patch makes it so COGL_DEBUG=all|verbose now only enables options
that don't change the behaviour of Cogl, i.e. they only affect the
amount of noise we'll print to a terminal.

In addition to that this patch also improves the output from
COGL_DEBUG=help so we now print a table of options including one liner
descriptions of what each option enables.
2010-02-23 22:09:06 +00:00
Emmanuele Bassi
939e56e2b1 box: Tweak the depth sorting function
By changing the depth sorting function we can achieve the same effect as
ClutterGroup but without the costly append+sort.

http://bugzilla.openedhand.com/show_bug.cgi?id=1988
2010-02-23 17:59:09 +00:00
Emmanuele Bassi
95960ab902 cogl: Add deprecation annotation to CoglMaterial ref/unref
The G_GNUC_DEPRECATED annotation was missing from the material ref and
unref functions.
2010-02-23 16:51:26 +00:00
Emmanuele Bassi
a9941e9499 debug: Split debugging notes from behavioural modifiers
Some of the ClutterDebugFlags are not meant as a logging facility: they
actually change Clutter's behaviour at run-time.

It would be useful to have this distinction ratified, and thus split
ClutterDebugFlags into two: one DebugFlags for logging facilities and
another set of flags for behavioural changes.

This split is warranted because:

  • it should be possible to do "CLUTTER_DEBUG=all" and only have
    log messages on the output

  • it should be possible to use behavioural modifiers even on a
    Clutter that has been compiled without debugging messages
    support

The commit adds two new debugging flags:

  ClutterPickDebugFlags - controlled by the CLUTTER_PICK environment
                          variable

  ClutterPaintDebugFlags - controlled by the CLUTTER_PAINT environment
                           variable

The PickDebugFlags are:

  nop-picking
  dump-pick-buffers

While the PaintDebugFlags is:

  disable-swap-events

The mechanism is equivalent to the CLUTTER_DEBUG environment variable,
but it does not depend on the debug level selected when configuring and
compiling Clutter. The picking and painting debugging flags are
initialized at clutter_init() time.

http://bugzilla.openedhand.com/show_bug.cgi?id=1991
2010-02-23 14:39:23 +00:00
Neil Roberts
a9c307ff5d cogl-vertex-buffer: Fix the malloc fallback for indices
The size of the malloc'd buffer for indices when VBOs are not
available was too small so memory corruption would result if it was
used.

http://bugzilla.o-hand.com/show_bug.cgi?id=1996
2010-02-23 14:01:11 +00:00
Emmanuele Bassi
1466965773 device: Motion events compression should honour the device
The motion event compression should be affected by the device field of
the event; that is: we should compress motion events coming from the
same device.
2010-02-22 11:34:04 +00:00
Emmanuele Bassi
5ed4732737 device: Force ENTER on Stage with overlapping Actors
If an actor is on the boundary of a Stage and the pointer for a device
enters the Stage over that actor, the sequence of events currently is:

  ➔ ENTER (source: actor, related: NULL)
  ➔ MOTION

Thus the Stage never gets an ENTER event. This is a regression from
Clutter 1.0.

The correct sequence is:

  ➔ ENTER (source: stage, related: NULL)
  ➔ ENTER (source: actor, related: stage)
  ➔ MOTION

This also maps to the sequence of events sythesized by Clutter when
leaving the Stage through an actor overlapping the Stage boundary.

http://bugzilla.moblin.org/show_bug.cgi?id=9781
2010-02-22 11:30:14 +00:00
Emmanuele Bassi
ee33357fd5 stage: Only clutter_stage_get_default() creates the default stage
The introduction of the StageManager in 0.8 implied that the first Stage
instance to be created was automatically assigned the status of "default
stage". This was all well and good, since the default stage was created
behind the curtains by the initialization sequence.

Now that the initialization sequence does not create a default stage any
longer, it means that the first stage created using clutter_stage_new()
gets to be the default, and all special and warm and fuzzy - which also
means that the first stage created by clutter_stage_new() cannot be
destroyed or handled as any other stage. Whoopsie.

Let's go back to the old semantics: the stage created by the first
invocation of clutter_stage_get_default() is the default stage, and
nothing else can be set as default. One day we'll be able to break the
API and the whole default stage business will be a thing of the past.
2010-02-18 17:01:57 +00:00
Emmanuele Bassi
9a6de8757f docs: Document the InputDevice update method
Embedding toolkits should benefit from a proper documentation of
clutter_input_device_update_from_event(): its meaning, its use and
the caveats for the "update_stage" argument.
2010-02-18 11:40:49 +00:00
Neil Roberts
a2afc9d7ba win32: Fixup compilation errors from b398292089
That commit added some Win32 code which breaks compilation.

Thanks to Samuel Degrande for help with this.
2010-02-18 11:36:15 +00:00
Robert Bragg
5de743de70 cogl_texture_new_from_foreign: improve docs
Improve the explanation of what the x_pot_waste and y_pot_waste
arguments can be used for.
2010-02-17 20:36:51 +00:00
Robert Bragg
9c06c94374 cogl-texture: for foreign textures; always trust user geom
We now never query the width and height of the given texture object
from OpenGL. The problem is that the user may be creating a Cogl
texture from a texture_from_pixmap object where glTexImage2D was
never called and the texture_from_pixmap spec doesn't clarify that
it's reliable to query the width from OpenGL.

This should address:
http://bugzilla.openedhand.com/show_bug.cgi?id=1502

Thanks to Johan Bilien for reporting
2010-02-17 20:36:50 +00:00
Emmanuele Bassi
8b040cac4d docs: Fixes for DeviceManager 2010-02-17 19:02:43 +00:00
Emmanuele Bassi
51a3e49c82 device: Allow updating devices from embedding toolkits
Embedding toolkits most likely will disable the event handling, so all
the input device code will not be executed. Unfortunately, the newly
added synthetic event generation of ENTER and LEAVE event pairs depends
on having input devices.

In order to unbreak things without reintroducing the madness of the
previous code we should allow embedding toolkits to just update the
state of an InputDevice by using the data contained inside the
ClutterEvent. This strategy has two obvious reasons:

  • the embedding toolkit is creating a ClutterEvent by translating
    a toolkit-native event anyway

  • this is exactly what ClutterStage does when processing events

We are, essentially, deferring input device handling to the embedding
toolkits, just like we're deferring event handling to them.
2010-02-17 18:21:50 +00:00
Emmanuele Bassi
b398292089 device: Impose per-backend DeviceManager
The DeviceManager class should be abstract in Clutter, and implemented
by each backend, as different backends will have different ways to
detect, initialize and list devices; the X11 backend alone has *two*
ways of dealing with devices.

This commit makes DeviceManager an abstract class and delegates the
device initialization and enumeration to per-backend sub-classes.

The responsible for creating the device manager is, obviously, the
backend singleton.

The X11 and Win32 backends have been updated to the new layout; the
Win32 backend has been updated blindly, so it might require additional
testing.
2010-02-17 17:46:48 +00:00
Chris Lord
0bf6d57ab1 [event-x11] Don't relayout on window move
ConfigureNotify is delivered on window movements too, but there is no
need to queue a relayout on these as the viewport hasn't changed size.
Check for the window actually changing size on ConfigureNotify before
queueing a relayout.

This fixes laggy window movement when moving a window in response to
Clutter mouse motion events.
2010-02-17 16:56:30 +00:00
Neil Roberts
05054bed87 cogl-clip-stack: Round the coords when clipping to a window rect
The size and position of the window rectangle for clipping in
try_pushing_rect_as_window_rect is calculated by projecting the
rectangle coordinates. Due to rounding errors, this can end up with
slightly off numbers like 34.999999. These were then being cast
directly to an integer so it could end up off by one.

This uses a new macro called COGL_UTIL_NEARBYINT which is a
replacement for the C99 nearbyint function.
2010-02-17 16:12:47 +00:00
Emmanuele Bassi
fbcaf1e0b3 Improve LEAVE events for border actors
If an actor is lying on the border of the Stage it might miss the LEAVE
event when the pointer of a device leaves the Stage window. Since the
backend is unsetting the Stage back pointer on the InputDevice we can
queue the emission of a LEAVE event on the pointer actor as well.

http://bugzilla.moblin.org/show_bug.cgi?id=9677
2010-02-17 10:48:18 +00:00
Chris Lord
719e314b8e [stage-x11] Fix a warning due to a missing cast
I stupidly forgot to cast a ClutterStage to a ClutterActor and somehow
missed or didn't get the compiler warning. Fix.
2010-02-16 18:25:46 +00:00
Chris Lord
f9f03894a6 [stage-x11] Fix resizing for foreign windows
As well as manually setting the geometry size, we needed to queue a
relayout. This is what the ConfigureNotify handler would normally do,
but we don't get this event when using a foreign window (obviously).

This should fix resizing in things like gtk-clutter.
2010-02-16 18:17:55 +00:00
Chris Lord
df6e7aee73 [stage-x11] Set the geometry size for foreign wins
If we get into the resize function and it's a foreign window, set the
geometry size so that the allocate will set the backend size and call
glViewport.
2010-02-16 17:53:05 +00:00
Chris Lord
1117b6a9ac [stage-x11] Fix switching fullscreen mode
Setting/unsetting fullscreen on a mapped or unmapped window now works
correctly.

If you unfullscreen a window that was initially full-screened, it will
unset the fullscreen hint and the WM will likely push the size down to
the largest valid size.

If the window was previously un-fullscreened, Clutter will restore the
previous size.

Fullscreening also now works if the WM switches the hint without the
application's knowledge (as happens when you resize a window to the size
of the screen, for example, with stock metacity).
2010-02-16 14:55:53 +00:00
Neil Roberts
958545aa70 cogl-atlas-texture: Don't use the atlas if FBOs aren't supported
If FBOs aren't supported then it will end up very slow to reorganize
the atlas. Also currently the CoglTexture2D backend will refuse to
create any textures anyway so the full atlas texture won't be created.
2010-02-16 12:07:18 +00:00
Neil Roberts
a5021ba30f cogl-atlas-texture: Check for errors when creating the atlas texture
cogl_texture_2d_new may fail in certain circumstances so
cogl_atlas_texture_reserve_space should detect this and also
fail. This will cause cogl_texture_new to fallback to a sliced
texture.

Thanks to Vladimir Ivakin for reporting this problem.
2010-02-16 12:07:18 +00:00
Emmanuele Bassi
56f164f8a1 docs: Document SWAP_EVENTS feature flag 2010-02-15 19:03:37 +00:00
Chris Lord
2fcb644e4f [stage] Fix some races to do with window resizing
When we resize, we relied on the stage's allocate to re-initialise the
GL viewport. Unfortunately, if we resized within Clutter, the new size
was cached before the window is actually resized, so glViewport wasn't
being called after resizing (some of the time, it's a race condition).

Change the way resizing works slightly so that we only resize when the
geometry size doesn't match our preferred size, and queue a relayout on
ConfigureNotify so the glViewport gets called.

Also change window creation slightly so that setting the size of a
window before it's realized works correctly.
2010-02-15 18:56:50 +00:00
Emmanuele Bassi
0d428655e2 actor: Turn push/pop_internal into Actor methods
Since the "internal" state is global, it will leak onto actors that you
didn't intend for it to, because it applies not just to the actors you
create, but also to any actors *they* create. Eg, if you have a dialog
box class, you might push/pop_internal around creating its buttons, so
that those buttons get marked as internal to the dialog box. But
ctx->internal_child will still be set during the *button*'s constructor
as well, and so, eg, the label and icon inside the button actor will
*also* be marked as internal children, even if that isn't what the
button class wanted.

The least intrusive change at this point is to make push_internal() and
pop_internal() two methods of the Actor class, and take a ClutterActor
pointer as the argument - thus moving the locality of the internal_child
counter to the Actor itself.

http://bugzilla.openedhand.com/show_bug.cgi?id=1990
2010-02-15 16:09:26 +00:00
Emmanuele Bassi
2229cafc38 stage: Add sanity checks for get_pending_swaps()
The master clock might have a Stage during its destruction phase,
without a StageWindow attached to it. If this happens and we try
to dereference the StageWindow to get its class and call a virtual
function we might experience some slight turbulence and... then...
explode.

http://bugzilla.openedhand.com/show_bug.cgi?id=1987
2010-02-15 12:04:50 +00:00
Emmanuele Bassi
d607400f01 x11: Do not set pid or title on foreign windows
If a StageX11 is using a foreign window we should not need to set the
_NET_WM_PID or the WM_TITLE properies.

http://bugzilla.openedhand.com/show_bug.cgi?id=1989
2010-02-15 11:50:04 +00:00
Emmanuele Bassi
89191e8bbc docs: Mention signal-swapped-after modifier
The signal-swapped-after:: modifier for signal connection inside the
clutter_actor_animate* variadic arguments functions is not mentioned in
the documentation.
2010-02-15 11:44:02 +00:00
Damien Lespiau
01bf509056 cogl-buffer: fix compilation for GL ES
In the frenzy of the last 10mins before API freeze, I obviously forgot
to update the OpenGL path for _cogl_buffer_hints_to_gl_enum(). This
commit fixes this.
2010-02-12 17:29:51 +00:00
Neil Roberts
e668a2f228 cogl-atlas-texture: Flush the journal before adding a new texture
When the atlas is reorganised we could potentially be moving around
textures that are already referenced in the journal. We therefore need
to flush the journal otherwise they will be rendered with incorrect
texture coordinates. We also need to flush the journal even if we are
not reorganizing so that we can rely on the old texture contents
remaining in the atlas after migrating a texture out.
2010-02-12 16:57:17 +00:00
Neil Roberts
4be4f56bdf cogl-sub-texture: Optimise taking a sub texture of a sub texture
When creating a Cogl sub-texture, if the full texture is also a sub
texture it will now just offset the x and y and reference the full
texture instead. This avoids one level of indirection when rendering
the texture which reduces the chances of getting rounding errors in
the calculations.
2010-02-12 16:57:17 +00:00
Emmanuele Bassi
2018b5b167 actor: Split get_paint_opacity() from the type check
Since get_paint_opacity() recurses through the hierarchy it might lead
to a lot of type checks while we walk the parent-child chain. We can
split the recursive function from the public entry point and perform the
type check just once.
2010-02-12 16:24:27 +00:00
Emmanuele Bassi
37d51cb78e actor: Do not call get_opacity() from get_paint_opacity()
We already have access to the opacity private field, there's no need to
go through the public API.
2010-02-12 16:18:12 +00:00
Emmanuele Bassi
124f30ccce docs: Fixes for Cogl 2010-02-12 15:52:07 +00:00
Emmanuele Bassi
78f1f508af analysis: x11: ClutterEvent
Remove an unused variable.
2010-02-12 14:57:55 +00:00
Emmanuele Bassi
081696fdb5 analysis: CoglPangoRenderer
Remove unused variables.
2010-02-12 14:57:55 +00:00
Emmanuele Bassi
2d8bdf9e5e analysis: ClutterTimeoutPool
Do not pre-initialize the list iterator, the for loop will do it for us.
2010-02-12 14:57:55 +00:00
Emmanuele Bassi
9c8f881878 analysis: ClutterTimeline
Remove an unused variable.
2010-02-12 14:57:50 +00:00
Emmanuele Bassi
65af411cb4 analysis: ClutterTexture
Remove unused variables.
2010-02-12 14:50:11 +00:00
Emmanuele Bassi
09644e4bb6 analysis: ClutterText
Remove unused variables.
2010-02-12 14:50:11 +00:00
Emmanuele Bassi
c2d434e3af analysis: ClutterStage
Remove unused variables.
2010-02-12 14:50:11 +00:00
Emmanuele Bassi
136e8c1acb analysis: ClutterScriptParser
We parse a JSON value depending on the initial state of an uninitialized
variable. Ouch.
2010-02-12 14:50:11 +00:00
Emmanuele Bassi
4d9010dd5e analysis: ClutterRectangle
Remove unused variables.
2010-02-12 14:50:11 +00:00
Emmanuele Bassi
8ba65cfd4a analysis: ClutterModel
Remove unused variables.
2010-02-12 14:50:11 +00:00
Emmanuele Bassi
bea1a0a6a2 analysis: ClutterMain
• Remove unused variables.

• Do not pre-initialize ClutterActor's GType; pre-emptive optimizations
  like these are more black magic than real optimization.
2010-02-12 14:50:11 +00:00
Emmanuele Bassi
66920ea540 analysis: ClutterInterval
Remove unused variables.
2010-02-12 14:50:11 +00:00
Emmanuele Bassi
853f9941da analysis: ClutterBoxLayout
Remove an useless assignment. The n_expand_children is not used outside
the extra_space check, and if n_expand_children is 0 then the extra
space we allocate is 0.
2010-02-12 14:50:10 +00:00
Emmanuele Bassi
cd05856253 analysis: ClutterBehaviour
Remove an unused variable.
2010-02-12 14:50:06 +00:00
Emmanuele Bassi
6dc0e9632c analysis: ClutterAnimation
• Remove one unused variable.

• We ignore the result of get_timeline_internal() so we need to tell
  the compiler that - though a better solution would be to split the
  timeline implicit creation into its own function.
2010-02-12 14:50:06 +00:00
Emmanuele Bassi
a287ca7a28 analysis: ClutterAnimator/2
Clean up an unused variable.
2010-02-12 14:50:06 +00:00
Emmanuele Bassi
667222c301 analysis: ClutterAnimator/1
Do not de-reference a void*; use a temporary variable -- after
checking the contents of the pointer. This actually simplifies
the readability and avoids pulling a Lisp with the parentheses.
2010-02-12 14:50:06 +00:00
Emmanuele Bassi
fcd3cfc0bf analysis: ClutterAlpha
Clean up unused variables.
2010-02-12 14:50:06 +00:00
Emmanuele Bassi
aa6d7a3029 analysis: ClutterActor
Clean up ClutterActor for unused variables.
2010-02-12 14:50:06 +00:00
Neil Roberts
7a372bc001 cogl: Cache the value for GL_MAX_TEXTURE_UNITS
The function _cogl_get_max_texture_units is called quite often while
rendering and it returns a constant value so we might as well cache
the result. Calling glGetInteger on Mesa can be expensive because it
flushes a lot of state.
2010-02-12 14:38:53 +00:00
Robert Bragg
22c33b2fea cogl: resolves some low hanging issues flagged by clang
An initial pass over the Cogl source code using the Clang static
analysis tool flagged a few low hanging issues such as un-used variables
or redundant initializing of variables which this patch fixes.
2010-02-12 14:05:02 +00:00
Robert Bragg
18305cbd98 cogl_rectangle: avoid redundant copy of geometry
All the cogl_rectangle* APIs normalize their input into into an array of
_CoglMutiTexturedRect rectangles and pass these on to our work horse;
_cogl_rectangles_with_multitexture_coords. The definition of
_CoglMutiTexturedRect had 4 separate float members, x_1, y_1, x_2 and
y_2 which meant for some common cases we were having to copy out from an
array into these members. We are now able to simply point into the users
array avoiding a copy which seems desirable when submiting lots of
rectangles.
2010-02-12 14:05:02 +00:00
Robert Bragg
5f18fc928d cogl: explicitly mark cogl_<object>_ref/unref APIs as deprecated
This uses the G_GNUC_DEPRECATED macros to mark the
cogl_{texture,vertex_buffer,shader}_ref and unref APIs as deprecated.
Since this flagged that cogl-pango-display-list.c and
clutter-glx-texture-pixmap.c were still using deprecated _ref/_unref
APIs they have now been changed to use the cogl_handle_ref/unref API
instead.
2010-02-12 14:05:01 +00:00
Robert Bragg
48660349db cogl: cleanly separate primitives + paths code
The function prototypes for the primitives API were spread between
cogl-path.h and cogl-texture.h and should have been in a
cogl-primitives.h.

As well as shuffling the prototypes around into more sensible places
this commit splits the cogl-path API out from cogl-primitives.c into
a cogl-path.c
2010-02-12 14:05:01 +00:00
Robert Bragg
9f5a3e1445 cogl: remove redundant _cogl_journal_flush prototype
There was a redundant _cogl_journal_flush function prototype in
cogl-primitives.h
2010-02-12 14:05:01 +00:00
Robert Bragg
7edcbaa1f9 cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.

There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.

The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:

 return_type
 cogl_function_name (CoglType arg0,
                     CoglType arg1);

Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.

The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.

The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.

The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-12 14:05:00 +00:00
Robert Bragg
8c9472bc4c cogl: deprecates cogl_check_extension
OpenGL is an implementation detail for Cogl so it's not appropriate to
expose OpenGL extensions through the Cogl API.

Note: Clutter is currently still using this API, because it is still
doing raw GL calls in ClutterGLXTexturePixmap, so this introduces a
couple of (legitimate) build warnings while compiling Clutter.
2010-02-12 14:05:00 +00:00
Robert Bragg
b898f0e227 never presume queuing redraws on invisible actors is redundant
This replaces code like this:
  if (CLUTTER_ACTOR_IS_VISIBLE (self))
    clutter_actor_queue_redraw (self);
with:
  clutter_actor_queue_redraw (self);

clutter_actor_queue_redraw internally knows what can be optimized when
the actor is not visible, but it also knows that the queue_redraw signal
must always be sent in case a ClutterClone is cloning a hidden actor.
2010-02-12 14:05:00 +00:00
Robert Bragg
bfb271b403 box: port a ClutterGroup::foreach fix to ClutterBox
ClutterGroup::foreach was recently changed (ref: ce030a3fce) to use
g_list_foreach() to iterate the children instead of manually iterating
the list so it would safely handle calls like:

  clutter_container_foreach (container, clutter_actor_destroy);

  (In this example clutter_actor_destroy will result in the current
   list item being iterated being freed.)
2010-02-12 12:31:24 +00:00
Robert Bragg
60a4664d6e box: Adds missing copyright header
Adds a Copyright (C) 2009,2010  Intel Corporation header
2010-02-12 12:31:24 +00:00
Robert Bragg
4355621aeb group: make it comparable to ClutterBox
There is a lot of duplication between ClutterGroup and ClutterBox so
this makes the two files diff-able so that new fixes can easily be
ported to both and bug fixes missing in one or the other can be spotted
more easily. This doesn't change the behaviour of either actor; it's
really just a shuffle around of code and normalizes the coding style to
make the files comparable.

This has already uncovered one bug in ClutterBox, and also highlights
a bug in ClutterGroup + many other actors:

1) ClutterGroup::real_foreach was recently changed to use
   g_list_foreach instead of manually iterating the child list so it can
   safely handle calls like:
     clutter_container_foreach (container, clutter_actor_destroy);
   ClutterBox is still manually iterating the list.

2) In ClutterGroup we guard _queue_redraw() calls like this:
    if (CLUTTER_ACTOR_IS_VISIBLE (container))
	clutter_actor_queue_redraw (CLUTTER_ACTOR (container));
   In ClutterBox we don't:
     I think ClutterBox is correct here because
     clutter_actor_queue_redraw already optimizes the case where the
     actor's not visible, but it also considers that the actor may be
     cloned and so the guard in ClutterGroup could break clones. This
     actually highlights a wider clutter bug since the same kinds of
     guards can be found in all other clutter actors.
2010-02-12 12:31:24 +00:00
Neil Roberts
44818a4827 cogl: Add a fallback for when the signbit macro is missing
The signbit macro is defined in C99 so it should be available but some
versions of GCC don't appear to define it by default. If it's not
available we can use a hack to test the bit directly.
2010-02-11 15:59:53 +00:00
Emmanuele Bassi
59463c2213 Do a sanity check on _clutter_do_pick() arguments
We should check that the passed ClutterStage pointer is indeed: a) still
valid and b) a Stage.
2010-02-10 17:20:31 +00:00
Emmanuele Bassi
d0734bc474 input-device: Do not pick() on NULL stages
If the stage associated to the InputDevice is not set we should
short-circuit out and return NULL. This will result in a pick()
done on the event's stage - if applicable.

http://bugzilla.moblin.org/show_bug.cgi?id=9602
2010-02-10 17:13:33 +00:00
Emmanuele Bassi
4208169ab4 text: Bump up the preferred height
Instead of returning a sub-pixel height round up the preferred height to
the nearest integral value that is not less than the size reported by
Pango, once converted in pixels.
2010-02-10 15:45:54 +00:00
Robert Bragg
3fdb0a5950 uprof: make the Redrawing timer a child of the Master Clock
Previously it was a child of the Mainloop, but it's more closely
a child of the Master Clock.
2010-02-10 15:04:53 +00:00
Robert Bragg
1899dbdc27 backend-glx: Fix glXQueryVersion test
This fixes some backwards logic for asserting that we have a GLX major
version == 1 and a minor version >= 2. (NB: Although we technically
depend on GLX 1.3 features, we still have to support drivers that report
GLX 1.2 because there are a lot of mesa drivers out there incorrectly
report GLX 1.2 even though they export extensions that depend on GLX
1.3)
2010-02-10 15:04:53 +00:00
Neil Roberts
ce1bb3d858 cogl-material: Layers are not equal if the filters aren't equal
A material layer can not be considered equal if it is using different
texture filtering modes. This was causing problems where rectangles
with different filters would end up batched together and then rendered
with the wrong filter mode.
2010-02-10 12:41:09 +00:00
Emmanuele Bassi
b61c2b510b build: Tweak internal defines for building Clutter
When building Clutter we should:

  • disable Cogl deprecated API;
  • enable experimental API.
2010-02-10 10:58:14 +00:00
Robert Bragg
4a9f08639f debug: Adds CLUTTER_DEBUG=disable-swap-events option
This allows us to forcibly disable the use of the GLX_INTEL_swap_events
extension for testing or debugging purposes.
2010-02-09 22:19:41 +00:00
Robert Bragg
5d702853b8 glx backend: Adds support for GLX_INTEL_swap_event
If your OpenGL driver supports GLX_INTEL_swap_event that means when
glXSwapBuffers is called it returns immediatly and an XEvent is sent when
the actual swap has finished.

Clutter can use the events that notify swap completion as a means to
throttle rendering in the master clock without blocking the CPU and so it
should help improve the performance of CPU bound applications.
2010-02-09 22:19:41 +00:00
Robert Bragg
848db1ee4c glx backend: when running with GLX 1.3 then create GLXWindows for stages
Some extensions only support GLX versions > 1.3 and may not support
old style X Windows as GLXDrawables, so we now create GLXWindows for
stages when possible.
2010-02-09 22:19:41 +00:00
Neil Roberts
ca3ab41a1b clutter-backend: Fix the error check in _clutter_backend_create_stage
Commit d2bdd3cb62 fixed some compiler warnings but also broke the
ability to create a stage. Although not having warnings from the
compiler is nice, it is also nice to be able to create a stage so lets
not invert the meaning of the error check.
2010-02-09 18:33:09 +00:00
Emmanuele Bassi
7b1925df82 cogl: Move material_copy() out of the deprecated section
We strongly suggest people should be using cogl_material_copy(), but it
was hidden behind the deprecation guards.
2010-02-09 17:07:08 +00:00
Emmanuele Bassi
d2bdd3cb62 Fix some compiler warnings
GCC complains that some variable might be used uninitialized.
2010-02-09 16:58:03 +00:00
Neil Roberts
193c477495 cogl-bitmap: Remove const from premult_alpha_last_four_pixels_sse2
The function modifies the pixels pointed by p in-place so the pointer
can not be constant. The compiler was accepting this because the
modification is done from inline assembler.
2010-02-09 16:30:28 +00:00
Bastian Winkler
ecc5ffe91a cogl-buffer: Use correct argument types in cogl_buffer_set_data_EXP
offset and size arguments are gsize in cogl-buffer.h

http://bugzilla.openedhand.com/show_bug.cgi?id=1980

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-02-09 15:01:09 +00:00
Emmanuele Bassi
7ebb1e7157 docs: Fixes for Cogl API reference
98% symbol docs coverage.
  335 symbols documented.
  0 symbols incomplete.
  8 not documented.

Not bad, if I may say so.
2010-02-09 14:41:37 +00:00
Neil Roberts
a02253f19a cogl-texture-2d: Use _cogl_texture_driver_gen to generate the GL tex
_cogl_texture_driver_gen is needed to set the texture minification
mode to Cogl's default of GL_LINEAR. There was also a line to set this
in _cogl_texture_2d_new_with_size but it wasn't working because it was
called *before* the texture was bound. If the texture was later
rendered with the default material it then it would end up with GL's
default mipmap filtering mode but without mipmaps so it would render
white squares instead.
2010-02-09 12:21:10 +00:00
Neil Roberts
1b2ff7eff7 cogl: Use SSE2 when possible for premultiplying
This adds a fast path for premultiplying an RGBA image using SSE2
instructions. SSE registers are 128-bit and we need at least 16-bits
per component for the intermediate result of the multiplication so we
can do two pixels in parallel with one register. The function
interleaves 2 SSE registers to multiply 4 pixels in one function call
with the hope that this will pipeline better.

http://bugzilla.openedhand.com/show_bug.cgi?id=1939
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-02-09 11:03:21 +00:00
Emmanuele Bassi
bbb058df40 actor: Improve readability of raise/lower warnings
• Add the function name in the warning, since the text is the same in
  both clutter_actor_raise() and clutter_actor_lower().

• If an actor has a name then prefer it to the type name.
2010-02-09 10:34:41 +00:00
Halton Huo
7664568fff Remove return from void functions
This patch fixes compilation on suncc.

http://bugzilla.openedhand.com/show_bug.cgi?id=1978

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-02-09 10:24:25 +00:00
Emmanuele Bassi
4d9327bbe1 animator: Zero the AnimatorKey:value member
The test suite is showing random segfaults because the GValue member of
AnimatorKey is not zero-ed on creation.
2010-02-08 17:55:29 +00:00
Emmanuele Bassi
d62ddc374f docs: Fixes for ClutterAnimator 2010-02-08 17:37:00 +00:00
Damien Lespiau
c02dded0f6 cogl-buffer: Use TEXTURE as the only value for CoglBufferUsageHint
We should try to use more explicit defines than GL for our hints. For
now we only support using a CoglBuffer to generate textures.
2010-02-08 17:14:49 +00:00
Damien Lespiau
54a6df22b0 cogl-buffer: make sure the code compiles on GL ES
OpenGL ES has no PBO extension, so we fallback to using a malloc'ed
buffer. Make sure the OpenGL-only defines don't leak into the OpenGL ES
compilation.
2010-02-08 17:14:49 +00:00
Damien Lespiau
d0fe479536 cogl-pixel-buffer: Add a fallback path
First, let's add a new public feature called, surprisingly,
COGL_FEATURE_PBOS to check the availability of PBOs and provide a
fallback path when running on older GL implementations or on OpenGL ES

In case the underlying OpenGL implementation does not provide PBOs, we
need a fallback path (a malloc'ed buffer). The CoglPixelBufer
constructors will instanciate a subclass of CoglBuffer that handles
map/unmap and set_data() with a malloc'ed buffer.

The public feature is useful to check before using set_data() on a
buffer as it will mean doing a memcpy() when not supporting PBOs (in
that case, it's better to create the texture directly instead of using a
CoglBuffer).
2010-02-08 17:14:49 +00:00
Damien Lespiau
b7f049495b cogl-texture: Add a new constructor to turn CoglBuffers into textures
The only goal of using COGL buffers is to use them to create
textures. cogl_texture_new_from_buffer() is the new symbol to create
textures out of buffers.
2010-02-08 17:14:49 +00:00
Damien Lespiau
abbb668163 cogl-pixel-buffer: add a pixel buffer object class
This subclass of CoglBuffer aims at wrapping PBOs or other system
surfaces like DRM buffer objects. Two constructors are available:

cogl_pixel_buffer_new() with a size when you only care about the size of
the buffer (such a buffer can be used to store several texture data such
as the three planes of a I420 frame).

cogl_pixel_buffer_new_full() is more a 1:1 mapping between the data and
an underlying surface, with the possibility of having access to a low
level memory buffer that may have a stride.
2010-02-08 17:14:49 +00:00
Damien Lespiau
b5e9710cdf cogl-buffer: add an abstract class around openGL's buffer objects
Buffer objects are cool! This abstracts the buffer API first introduced
by GL_ARB_vertex_buffer_object and then extended to other objects.

The coglBuffer abstract class is intended to be the base class of all
the buffer objects, letting the user map() buffers. If the underlying
implementation does not support buffer objects (or only support VBO but
not FBO for instance), fallback paths should be provided.
2010-02-08 17:14:49 +00:00
Damien Lespiau
de8a6314f1 cogl: new textures sould have GL_TEXTURE_MIN_FILTER set to GL_LINEAR
The only way the user has to set the mipmap filters is through the
material/layer API. This API defaults to GL_LINEAR/GL_LINEAR for the max
and min filters. With the main use case of cogl being 2D interfaces, it
makes sense do default to GL_LINEAR for the min filter.

When creating new textures, we did not set any filter on them, using
OpenGL defaults': GL_NEAREST_MIPMAP_LINEAR for the min filter and
GL_LINEAR for the max filter. This will make the driver allocate memory
for the mipmap tree, memory that will not be used in the nominal case
(as the material API defaults to GL_LINEAR).

This patch tries to ensure that the min filter is set to GL_LINEAR
before any glTexImage*() call is done on the texture by setting the
filter when generating new OpenGL handles.
2010-02-08 17:14:49 +00:00
Damien Lespiau
c0f65212ba cogl: Introduce the GE_RET() debug macro
Some GL functions have a return value that the GE() macro is not able to
handle. Let's define a new Ge_RET() macro which will be able to handle
functions such as glMapBuffer().

While at it, removed the unused variadic dots to the GE() macro.
2010-02-08 17:14:49 +00:00
Emmanuele Bassi
069ba6daf9 Merge branch 'animator-parser'
* animator-parser:
  docs: Describe the Animation definition syntax
  animator: Provide a ClutterScript parser
  animator: Allow retrieving type property type from a key
  script: Use a node when resolving an animation mode
2010-02-08 16:53:11 +00:00
Emmanuele Bassi
6ab90899ba docs: Describe the Animation definition syntax
The ClutterAnimator documentation needs a section on the syntax of its
ClutterScript definition, possibly with an example.
2010-02-08 16:50:29 +00:00
Emmanuele Bassi
4dd11d6915 animator: Provide a ClutterScript parser
The whole point of having the Animator class is that the developer can
describe a complex animation using ClutterScript. Hence, ClutterAnimator
should hook into the Script machinery and parse a specific description
format for its keys.
2010-02-08 15:52:18 +00:00
Emmanuele Bassi
790a13c0d9 animator: Allow retrieving type property type from a key
When asking a key for its target value we also ask the developer to pass
in an initialized GValue - but we don't make it easy to know the type of
the GValue. A developer has to ask the GObject class for the GParamSpec
and then initialize the GValue, instead.

Since we know the type of the GValue we should provide a getter for it.

We should also allow developers to throw at us GValue with compatible and
transformable types.

Finally, all the accessors should be constified.
2010-02-08 15:47:46 +00:00
Emmanuele Bassi
09f91ff6ea script: Use a node when resolving an animation mode
Instead of taking a string and duplicating the "is it a string or an
integer" check in both Alpha and Animation, the function in
ClutterScript that resolves the animation mode values should take a
JsonNode and do all the checks it needs.
2010-02-08 15:45:43 +00:00
Robert Bragg
cc6aefad34 cogl path: make sure marking the clip state dirty takes affect
When we trashed the contents of the stencil buffer during
_cogl_path_fill_nodes we marked the clip stack state as dirty and expected
the clip stack code would clean up our glStencilFunc state.

The problem is that we only try and update the clip state during
_cogl_journal_init (when we flush the framebuffer state) which is only
called when the journal first gets something logged in it.

To make sure the stencil state is cleaned up we now also flush the journal
so _cogl_journal_init will be called for the next logged rectangle.
2010-02-08 13:35:45 +00:00
Neil Roberts
24338a7511 clutter-master-clock: Don't wait for a frame if time goes backwards
If we aren't syncing to vblank or if the last dispatch didn't cause a
redraw then the master clock will try to wait at least a small amount
of time before dispatching again. However if time goes backwards then
it would not do a dispatch until time catches up again. To fix this it
know just runs a dispatch immediately if time goes backwards.

This is related to Moblin bug #3839. There was a similar fix for this
in 9dc012c07, however that only fixed the case where timelines
wouldn't update. If there are no animations running then the master
clock won't even try updating timelines until time catches up.

http://bugzilla.o-hand.com/show_bug.cgi?id=1974
2010-02-08 11:13:55 +00:00
Emmanuele Bassi
6106010b6f Merge remote branch 'origin/cwiiis-stage-resize'
* origin/cwiiis-stage-resize:
  [stage-x11] Set the default size differently
  [stage] Set default size correctly
  Revert "[x11] Don't set actor size on ConfigureNotify"
  [x11] Don't set actor size on ConfigureNotify
  [stage] Now that get_geometry works, use it
  [stage-x11] make get_geometry always get geometry
  [stage] Get the current size correctly
  [stage] Set minimum width/height to 1x1
  [stage] Add set/get_minumum_size
2010-02-08 10:34:22 +00:00
Øyvind Kolås
4cc269a468 Add ClutterAnimator
ClutterAnimator is a class for managing the animation of multiple
properties of multiple actors over time with keyframing of values.

The Animator class is meant to be used to effectively describe
animations using the ClutterScript definition format, and to construct
complex implicit animations from the ground up.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-02-07 18:25:19 +00:00
Chris Lord
c82c94e620 [stage-x11] Set the default size differently
We want to set the default size without triggering the layout machinary,
so change the window creation process slightly so we start with a
640x480 window.
2010-02-07 19:17:43 +01:00
Chris Lord
b968defae9 [stage] Set default size correctly
Due to the way the new sizing works, clutter stage must set its size in
init (to maintain old behaviour) and the properties on the X11 stage
must be initialised to 1x1 so that it actually goes ahead with the
resize.

Fixes stages that aren't user resizable and have no size set from
appearing at 1x1.
2010-02-07 14:18:14 +01:00
Chris Lord
8083dc418b Revert "[x11] Don't set actor size on ConfigureNotify"
This reverts commit 29cc027f06.

I misunderstood the problem, this commit breaks resizes coming from
outside of Clutter.
2010-02-06 16:57:37 +01:00
Chris Lord
29cc027f06 [x11] Don't set actor size on ConfigureNotify
Calling clutter_actor_set_size in response to ConfigureNotify makes
setting the size of the stage racy - the most common result of which
seems to be that you can't set the stage dimensions to anything less
than 640x480.

Instead, add a first_allocation bit to the private structure of the X11
stage and force the first resize (necessary or the default stage will be
a 1x1 window).
2010-02-06 16:47:22 +01:00
Chris Lord
cea9de7f04 [stage] Now that get_geometry works, use it
We want the actual window geometry in clutter_stage_set_minimum_size,
not the set size. Now that the geometry function has been changed to do
what it says, use it.
2010-02-06 15:41:01 +01:00
Chris Lord
4887707bb3 [stage-x11] make get_geometry always get geometry
Now that we have a minimum size getter on the stage object, change
get_geometry to actually always return the geometry. This fixes stages
that are set as user-resizable appearing at 1x1 size.

This will need changing in other back-ends too.
2010-02-06 15:34:55 +01:00
Chris Lord
27e33aa14f [stage] Get the current size correctly
Get the current size of the stage correctly in
clutter_stage_set_minimum_size. The get_geometry StageWindow function is
not equivalent of the current size, use clutter_actor_get_size().
2010-02-06 14:59:51 +01:00
Chris Lord
be11564b55 [stage] Set minimum width/height to 1x1
Whoops, to maintain the old behaviour, make sure the default minimum
width/height are 1x1.
2010-02-06 14:04:47 +01:00
Chris Lord
fd11d3098f [stage] Add set/get_minumum_size
Add two functions to set/get the minimum stage size. This takes effect
when a stage is set to user resizable.
2010-02-06 11:23:37 +00:00
Emmanuele Bassi
e55966d675 Deprecate clutter_util_next_p2()
The next_p2() function should have never been publicly exposed by
Clutter.
2010-02-06 10:49:33 +00:00
Neil Roberts
830f2402d4 Merge branch 'more-texture-backends'
This adds three new texture backends.

- CoglTexture2D: This is a trimmed down version of CoglTexture2DSliced
  which only supports a single texture and only works with the
  GL_TEXTURE_2D target. The code is a lot simpler so it has a less
  overheads than dealing with slices. Cogl will use this wherever
  possible.

- CoglSubTexture: This is used to get a CoglHandle to represent a
  subregion of another texture. The texture can be used as if it was a
  standalone texture but it does not need to copy the resources.

- CoglAtlasTexture: This collects RGB and RGBA textures into a single
  GL texture with the aim of reducing texture state changes and
  increasing batching. The backend will try to manage the atlas and
  may move the textures around to close gaps in the texture. By
  default all textures will be placed in the atlas.
2010-02-06 00:20:32 +00:00
Neil Roberts
6b1b27d4f8 cogl-bitmap: Update the format after (un)premultiplying
The pixel format of the bitmap needs to have its premult flag cleared
or set after the premult conversion otherwise it may get converted
again.
2010-02-06 00:13:25 +00:00
Neil Roberts
191d20eb56 cogl-atlas-texture: Fix a cut and paste error when getting the height
There was a typo in getting the height of the full texture to check
whether the sub region fits so that it was using the width
instead. This was causing crashes when debugging is enabled for some
apps.
2010-02-05 17:03:04 +00:00
Damien Lespiau
1bdc3db9ab docs: Use % for defines not #
Some links to defines in the gtk-doc annotations were using '#' instead
of '%'.
2010-02-04 21:10:02 +00:00
Emmanuele Bassi
0ea25d661b event: Do not generate click count for SCROLL events
The ClutterScrollEvent structure does not have a click count field,
so Clutter should not generate the click count for events of type
CLUTTER_SCROLL.
2010-02-04 18:29:47 +00:00
Neil Roberts
1f70da62a7 glx: Create a colormap for the dummy window
Otherwise X will fail to create the window and throw a BadMatch error
at least on NVidia.
2010-02-04 16:35:42 +00:00
Emmanuele Bassi
466b00a806 glx: Clarify *why* we need the dummy window
The reason why we have a dummy, offscreen Window when we create the
GLX context is that GLX does not like it when you ask the context for
features if it's not made current to a Drawable. Maybe in the future
it will allow us to do so, but right now we have to make do with what
GLX offers us.
2010-02-04 13:59:39 +00:00
Emmanuele Bassi
ea5e33cf3a glx: Do not leak a XVisualInfo
The XVisualInfo we retrieve for the dummy window should be freed after
we used it.
2010-02-04 13:56:33 +00:00
Neil Roberts
e6a3b6ebe7 cogl-texture: Avoid copying the bitmap when premultiplying from a file
In cogl_texture_new_from_file we create and own a temporary
bitmap. There's no need to copy this data if we need to do a premult
conversion so instead it just does conversion before passing it on to
cogl_texture_new_from_bitmap.
2010-02-03 23:27:45 +00:00
Neil Roberts
59198b8ab8 cogl-texture: Split out _cogl_texture_prepare_for_upload
The Cogl atlas code was using _cogl_texture_prepare_for_upload with a
NULL pointer for the dst_bmp to determine the internal format of the
texture without converting the bitmap. It needs to do this to decide
whether the texture will go in the atlas before wasting time on the
conversion. This use of the function is a little confusing so that
part of it has been split out into a new function called
_cogl_texture_determine_internal_format. The code to decide whether a
premult conversion is needed has also been split out.
2010-02-03 23:10:52 +00:00
Neil Roberts
5063f4669c cogl-atlas: Make the cogl_atlas_* API internal
This just adds an underscore to every entry point for the CoglAtlas
API so that it's not exported.
2010-02-03 23:09:26 +00:00
Jussi Kukkonen
cd3c5155d8 text: implement del_word_next/del_word_prev()
Bind ctrl-backspace and ctrl-del to functions that delete a word before
or after the cursor, respectively.

Selection does not affect the deletion, but current selection is
preserved. This mimicks GTK+ functionality in GtkTextView and GtkEntry.

http://bugzilla.openedhand.com/show_bug.cgi?id=1767

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-02-03 17:15:05 +00:00
Emmanuele Bassi
d8d728a8d7 Remove the SDL backend
The SDL API is far too limited for the windowing system needs of
Clutter; the status of the SDL backend was always experimental, and
since the Windows platform is supported by a native backend there is
no point in having the SDL backend around any more.
2010-02-03 16:34:27 +00:00
Neil Roberts
ae188d203c win32: Use a dummy window to support delayed stage creation
The Win32 backend now implements the create_context method which
creates a context and binds it to a 1x1 invisible window. That way
there will always be a context bound and the features can be retrieved
without creating the default stage. This reflects the changes in
1c6ffc8..b245d55 to the GLX backend.
2010-02-03 16:34:27 +00:00
Emmanuele Bassi
479fdffc7d glx: Fix error messages and debug notes
Instead of using g_critical() inside the create_context() implementation
of the ClutterBackendGLX we should use the passed GError, so that the
error message can bubble up to the caller.
2010-02-03 16:34:27 +00:00
Emmanuele Bassi
ede2cbfab0 stage: Create the default stage on demand
Instead of creating the default stage during initialization we can
now safely create it whenever clutter_stage_get_default() is called.

To maintain the invariant, the default stage is immediately realized
by Clutter itself.
2010-02-03 16:34:27 +00:00
Emmanuele Bassi
d2c091e62d glx: Create the dummy Window with the GLX context
Since we must guarantee that Cogl has a GL context to query, it is too
late to use the "dummy Window" trick from within the get_features()
virtual function implementation.

Instead, we can create a dummy Window from create_context() itself and
leave it around - basically trading a default stage with a dummy X
window.

We need to have the dummy X window around all the time so that the
GLX context can be selected and made current.
2010-02-03 16:34:27 +00:00
Emmanuele Bassi
5eb6fb74b6 feature: Make sure we have a GL context
Before asking Cogl and ClutterBackend for the list of features we must
have a GL backend ready.
2010-02-03 16:34:27 +00:00
Emmanuele Bassi
a8daaa8222 stage: Move default title in Stage.init
The default title should be set from within clutter_stage_init(); at
that point clutter_init() must have been called.
2010-02-03 16:34:27 +00:00
Emmanuele Bassi
38f26634ee Lazily create the Pango fontmap
The Pango fontmap needed by Clutter should be initialized the first
time we need a PangoContext, not on initialization.
2010-02-03 16:34:27 +00:00
Emmanuele Bassi
6fbed66add Delay default stage creation
The default stage creation should be delayed as much as possible,
ideally at the end of the init() process.
2010-02-03 16:34:27 +00:00
Emmanuele Bassi
3191ea1195 cogl-debug: Remove redundant newlines
The debugging notes wrapping g_debug() already have an implicit newline
at the end of the passed message.
2010-02-03 16:34:27 +00:00
Emmanuele Bassi
cb52581a24 text: Add :font-description
High level toolkits might wish to construct a PangoFontDescription and
then set it directly on a ClutterText actor proxy or sub-class.
ClutterText should have a :font-description property to set (and get)
the PangoFontDescription.

http://bugzilla.openedhand.com/show_bug.cgi?id=1960
2010-02-03 14:38:13 +00:00
Neil Roberts
74c0170ccc cogl-vertex-buffer: Refix disabling texture coord arrays
Commit 92a375ab4 changed the initial value of max_texcoord_attrib_unit
to -1 so that it could disable the texture coord array for the first
texture unit when there are no texture coords used in the vbo. However
max_texcoord_attrib_unit was an unsigned value so this actually became
G_MAXUINT. The disabling loop at the bottom still worked because
G_MAXUINT+1==0 but the check for whether any texture unit is greater
than max_texcoord_attrib_unit was failing so it would always end up
disabling all texture units. This is now fixed by changing
max_texcoord_attrib_unit to be signed.
2010-02-03 14:31:12 +00:00
Emmanuele Bassi
301863d43b text: Fixes for selection bound
The commit ecbb7ce41a exposed some issues
when positioning the cursor with the mouse pointer: the selection is
not moved along with the cursor when inserting a single character or a
string.

Also, some freeze_notify() are called too early, leading to decoupling
from their respective thaw_notify().

http://bugzilla.openedhand.com/show_bug.cgi?id=1955
2010-02-03 10:48:59 +00:00
Emmanuele Bassi
c9a6e63fa4 docs: Clarify Group's sizing semantics
The documentation for ClutterGroup behaviour when setting an explicit
size is not accurate - or, actually, it was accurate by the time
ClutterGroup was first written but has been neglected in the following
release cycles.

To avoid confusion for new users of Clutter the documentation should be
slightly expanded, mentioning the exact semantics of ClutterGroup with
regards to: preferred size, explicitly set size and how to constrain the
visible area of a ClutterGroup to an explicitly set size.

Based on a patch by: Neil Roberts <neil@linux.intel.com>
2010-02-02 14:53:04 +00:00
Emmanuele Bassi
f94e691151 behaviour: Clean up BehaviourOpacity
• Use a consistent coding style

• Call set_bounds() from set_property(), because we need proper
  notification on the modified property
2010-02-02 12:54:51 +00:00
Emmanuele Bassi
521d71d4bc event: Unify the off-stage motion events delivery behaviour
When we disable the per-actor events delivery Clutter replicates the X11
implicit soft grab for motion events with off-stage. The implicit grab
is done whenever the pointer of a device leaves a window with a button
still pressed; with the implicit grab in place the window still receives
motion events even after the LeaveNotify - until the button is released.

The implicit grab is not honoured in the per-actor event deliver case,
though, so we have a mismatch between two in theory equivalent cases.

Luckily, the fix is pretty trivial: when we check for a motion event
with a stage set but without an actor set, and that has off-stage
coordinates, we arbitrarily set the source to be the stage of the event
and emit the pointer event.
2010-02-01 16:36:36 +00:00
Neil Roberts
145cc9d3df Merge remote branch 'master' into texture-debugging
Conflicts:
	clutter/cogl/cogl/cogl-context.h
2010-02-01 13:37:19 +00:00
Neil Roberts
aa6731e338 cogl-material: Compare GL texture numbers for material layer textures
When deciding if a material layer is equal it now compares the GL
target and texture number if the textures are not sliced. This is
needed to get batching across atlased textures.
2010-02-01 13:27:42 +00:00
Neil Roberts
abe91784c4 cogl: Let GL do the format conversion when uploading texture data
Cogl accepts a pixel format for both the data in memory and the
internal format to be used for the texture. If they do not match then
it would convert them using the CoglBitmap functions before uploading
the data. However, GL also lets you specify both formats so it makes
more sense to let GL do the conversion. The driver may need the
texture in a specific format so it may end up being converted anyway.

The cogl_texture_upload_data functions have been removed and replaced
with a single function to prepare the bitmap. This will only do the
premultiplication conversion because that is the only part that GL
can't do directly.
2010-02-01 13:27:34 +00:00
Neil Roberts
e83ffb1fa3 cogl: Do the premult conversion in-place rather than copying to a new buffer
The premult part of _cogl_convert_premult has now been split out as
_cogl_convert_premult_status. _cogl_convert_premult has been renamed
to _cogl_convert_format to make it less confusing. The premult
conversion is now done in-place instead of copying the
buffer. Previously it was copying the buffer once for the format
conversion and then copying it again for the premult conversion. The
premult conversion never changes the size of the buffer so it's quite
easy to do in place. We can also use the separated out function
independently.
2010-02-01 13:27:34 +00:00
Neil Roberts
72fba19eac cogl-atlas-texture: Use a single atlas for both RGB and RGBA textures
The internal format of the atlas texture is still set to the
appropriate format so Cogl will disable blending for textures that are
intended to be RGB. This should end up ignoring the alpha channel from
the texture in the atlas. This makes the code slightly easier to
maintain and should also improve the chances of batching.
2010-02-01 13:27:29 +00:00
Emmanuele Bassi
ad6bd2ee88 actor: Reword the allocation cycle warning
Since we're allowing allocation cycles saying that calling
queue_relayout() inside an allocation cycle "is not allowed" is kind of
confusing. We should say that "it is not recommended".
2010-02-01 12:18:10 +00:00
Emmanuele Bassi
5f1c8a17e4 Merge branch 'device-manager'
* device-manager: (37 commits)
  x11: Re-enable XI1 extension keyboards
  x11: Always handle core device events before XI events
  docs: Documentation fixes for DeviceManager
  device-manager: Fix the signals definition
  docs: Add sections for InputDevice and DeviceManager
  docs: Add clutter_input_device_get_device_name()
  tests: Print out the device details on motion
  Always register core devices
  device: Remove unused is_default member
  win32: Experimental implementation of device support
  tests: Print the device name, as well as its Id
  x11: Fill out the :name property of the InputDevices
  device: Add the :name property to InputDevice
  x11: Store core devices on the X11 Backend singleton
  device: Unset the cursor actor when leaving the stage
  device: Add pointer actor getter
  x11: Discard the LeaveNotify for off-stage ButtonRelease
  device: Do not overwrite the stage for an InputDevice
  event: Off-stage button releases have a click count of 1
  event: Scroll events do not have click count
  ...
2010-02-01 11:26:56 +00:00
Alejandro Piñeiro
ecbb7ce41a Fix problems with "position" and "selection-bound" change notification
Added a "selection-bound" notify on clutter_text_clear_selection as it
changes the value.

Added utility function clutter_text_set_positions, in order to
change both cursor position and selection bound inside a
g_object_[freeze/thaw]_notify block

Added g_object_[freeze/thaw]_notify in other functions that changes
both cursor position and selection bound

Solves http://bugzilla.openedhand.com/show_bug.cgi?id=1955
2010-02-01 11:22:58 +00:00
Emmanuele Bassi
579a9a2665 stage: Add :key-focus property
ClutterStage has both set_key_focus() and get_key_focus() methods, but
there is no :key-focus property. This means that it is not possible to
get notifications when the key-focus has changes except by connecting to
both the ::key-focus-in and ::key-focus-out signals and do additional
bookkeeping.

http://bugzilla.openedhand.com/show_bug.cgi?id=1956

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-02-01 11:09:13 +00:00
Emmanuele Bassi
7a1ebcbced Whitespace fixes in cogl-util 2010-02-01 10:40:34 +00:00
Emmanuele Bassi
578e83e463 Whitespace fixes 2010-02-01 10:40:34 +00:00
Emmanuele Bassi
2d5eeba5d8 docs: Fixes for TimeoutPool and Frame sources
The TimeoutPool is not used by ClutterTimeline any more, so we need to
remove a sentence from its description. We also need to fix the gtk-doc
syntax errors.
2010-02-01 10:40:34 +00:00
Neil Roberts
046a4b8047 cogl: Use the colours of COGL_DEBUG=rectangles to debug batching
Instead of assigning a new colour to each quad of a batch, the
rectangle debugging code now assigns a new colour to each batch so
that it can be used to visually see what is being batched. The colour
is stored in a global variable that is reset during cogl_clear. This
improves the chances that the same colour will be used for a batch in
the next frames to avoid flickering.
2010-01-28 16:52:42 +00:00
Neil Roberts
92a375ab47 cogl-vertex-buffer: Fix disabling the texture arrays from previous prim
When setting up the state for the vertex buffer,
enable_state_for_drawing_buffer tries to keep track of the highest
numbered texture unit in use. It then disables any texture arrays for
units that were previously enabled if they are greater than that
number. However if there is no texturing in the VBO then the max used
unit would be left at 0 which it would later think meant unit 0 is
still in use so it wouldn't disable it. To fix this it now initialises
the max used unit to -1 which it should interpret as ‘no units are in
use’ so it will later disable the arrays for all units.

Thanks to Jon Mayo for reporting the bug.

http://bugzilla.openedhand.com/show_bug.cgi?id=1957
2010-01-27 14:31:59 +00:00
Neil Roberts
f288eae0fc docs: Add some notes about the CoglPixelFormat enums
The pixel format enums didn't explain what order in memory the
components should be so it was difficult to use them.
2010-01-27 12:07:38 +00:00
Damien Lespiau
52cb54f5fa cogl: Fix checks of the number of available texture units
We were checking the number of texture units against the GL enum that is
used in glGetInteger() to query that number. Let's abstract this in a
little function.

Took the opportunity to dig a bit on the usage of GL limits for the
number of texture (image) units and document our use of them. We'll need
something finer grained if we want to fully exploit texture image units
with a programmable pipeline.
2010-01-26 18:47:25 +00:00
Damien Lespiau
06d8ebb0ba cogl: Create CoglTextureUnit with its associated unit number
The index field of CoglTextureUnit was never set, leading to the
creation of units with index set to 0. When trying to retrieve a texture
unit by its index (!= 0) with _cogl_get_texture_unit(), a new one was
created as it could not find it back in the list of textures units:
ctx->texture_units.

http://bugzilla.openedhand.com/show_bug.cgi?id=1958
2010-01-26 12:12:20 +00:00
Emmanuele Bassi
8fc07c51a9 actor: Use GParamSpecUint for :opacity
The :opacity property is defined using a GParamSpecUchar. This usually
leads to issues with language bindings that don't have an 'unsigned
char' type and that need to explicitly handle the conversion between
G_TYPE_UCHAR and G_TYPE_INT or G_TYPE_UINT.

The property definition already specifies an interval size of [0, 255]
on the values; more importantly, GObject already implicitly transforms
between G_TYPE_UCHAR and G_TYPE_UINT (the GValue transformation
functions are registered at type system initialization time) so
switching between a GParamSpecUchar and a GParamSpecUint should not be
an ABI break.

I have tested a simple program using the opacity property before and
after the change and I cannot see any run-time warnings related to this
issue.
2010-01-22 21:47:20 +00:00
Emmanuele Bassi
7073e69b4e animation: Verify internal state
Be more drastic if the internal state is broken, and assert() if the
expected Alpha and Timeline instances we need are not valid. This
usually implies a library bug or a massive heap corruption.
2010-01-22 21:42:55 +00:00
Emmanuele Bassi
8daa3035e5 docs: Fix the Animation:object property
There is a typo in the Animation:object property gtk-doc declaration.
2010-01-22 21:42:10 +00:00
Emmanuele Bassi
0788aa43b2 animation: Add more debug annotations
We need some better tracking of the Animation's lifetime.
2010-01-22 21:41:33 +00:00
Emmanuele Bassi
7fa7c4a1b6 animation: Transform if necessary
The Animation code does transformation of values between type A and A'
after checking for compatibility using g_value_type_compatible(). This
is incorrect: compatibility means that the two types can be copied. The
correct conversion should follow:

        if (compatible (type (A), type (A')))
          copy (A, A');
        else
          if (transformable (type (A), type (A')))
            transform (A, A');
          else
            error("Unable to trasform type A in A'");

The transformation might still fail, so we need to check for errors
there as well as a fall-through case.
2010-01-22 21:36:41 +00:00
Emmanuele Bassi
94249efff7 animation: Check for value transformability
We should not just check for compatibility, but also for the ability to
transform a GValue of type A into another of type A'.

Usually compatibility is enough, especially if types can be
introspected beforehand; some times, though, we also need to check for
transformability as a type can provide the transformation functions
necessary for the operation.
2010-01-22 21:33:28 +00:00
Neil Roberts
996614cfaf cogl-atlas-texture: Add a debug option to disable the atlas
If the user specifies the 'disable-atlas' debug option then no texture
will be put in the atlas.
2010-01-22 15:54:15 +00:00
Emmanuele Bassi
a545f66a5c master clock: Improve the timeline advancement protection
The commit 1c69c61745 which improved the
protection against timeline removals during the master clock advancement
was only doing half the job - and actually broke the chaining of
animations inside the ::completed signal.

We cannot simply take a reference on the timelines and still use the list
held by the master clock because the do_tick() might result in the
creation of a new timeline, which gets added at the end of the list with
no reference increase and thus gets disposed at the end of the iteration.

We also cannot steal the master clock timelines list because a timeline
might be removed as the direct result of do_tick() and remove_timeline()
would not find the timeline, failing and leaving a dangling pointer
behind.

For this reason we copy the list of timelines out of the one that the
Master Clock holds, take a reference on each timeline, advance them all,
release the reference and free the list.
2010-01-21 23:54:25 +00:00
Emmanuele Bassi
8a4b647154 x11: Re-enable XI1 extension keyboards
The extension keyboard support in XInput 1.x is hopelessly broken.

Nevertheless, it's possible to use some bits of it, as we prefer the
core keyboard events to the XInput events, thus at least having proper
handling for X11 key events on the Stage window.
2010-01-20 19:40:58 +00:00
Emmanuele Bassi
94f9f3bd93 x11: Always handle core device events before XI events
The XI 1.0 layer is complementary to the X11 core devices handling; this
means that core events will still be emitted for the core pointer and
keyboard devices, and that secondary (floating) devices should be
handled on top of that.

Thus, the XI event handling code should be executed (if explicitly
compiled in and enabled) if the core device events have not been parsed.

Note: this is going away with XI2, which completely replaces both core and
XI1 events.
2010-01-20 00:39:18 +00:00
Emmanuele Bassi
dc39e9eff9 docs: Documentation fixes for DeviceManager 2010-01-20 00:38:53 +00:00
Emmanuele Bassi
65c7ff7d05 device-manager: Fix the signals definition
Add documentation for the signals, as well as using the correct type for
the marshallers.
2010-01-20 00:38:53 +00:00
Emmanuele Bassi
d8e167f151 Always register core devices
Even with XInput support we should always register core devices. This
allows us to handle enter and leave events correctly on the Stage and
to have a working XInput 1.x support in Clutter.
2010-01-20 00:38:53 +00:00
Emmanuele Bassi
e0b8d63159 device: Remove unused is_default member
The is_default member of the InputDevice structure was not used
anywhere.
2010-01-20 00:38:53 +00:00
Emmanuele Bassi
74dbcede25 win32: Experimental implementation of device support
Mostly lifted from the core pointer and keyboard X11 backend support.

The win32 backend registers two devices (a core pointer and a core
keyboard) and assigns them to the event structure when doing the
translation from native events to Clutter events.

Thanks to: Samuel Degrande <Samuel.Degrande@lifl.fr> for testing this
patch.
2010-01-20 00:38:09 +00:00
Emmanuele Bassi
66740e8000 x11: Fill out the :name property of the InputDevices
For the core pointer and keyboard we assign the names ourselves; for
devices coming from XI we can use the XDeviceInfo.name member.
2010-01-20 00:38:09 +00:00
Emmanuele Bassi
cf4e05930a device: Add the :name property to InputDevice
The InputDevice should have a name, possibly user readable, coming from
the backend.
2010-01-20 00:38:09 +00:00
Emmanuele Bassi
79ad2b6a72 x11: Store core devices on the X11 Backend singleton
Instead of overloading the device id of 0 and 1 we should treat the core
devices as special, and have a pointer inside the X11 backend singleton
structure, for fast access.
2010-01-20 00:38:09 +00:00
Emmanuele Bassi
8a579838d5 device: Unset the cursor actor when leaving the stage
When an InputDevice leaves a stage we set the stage member of
InputDevice to NULL. We should also unset the cursor_actor (as the
device is obviously not on an actor any more).

When the device re-enters the Stage the ENTER/LEAVE event generation
machinery will then be able to emit the ENTER event on the Stage.
2010-01-20 00:38:09 +00:00
Emmanuele Bassi
55e4315aa5 device: Add pointer actor getter
ClutterInputDevice should have a getter method for retrieving the
reactive actor underneath the pointer.
2010-01-20 00:38:09 +00:00
Emmanuele Bassi
25c6ebbb2c x11: Discard the LeaveNotify for off-stage ButtonRelease
If the user presses a button on a pointer device and then moves out the
Stage X11 will emit the following events:

  LeaveNotify ➔ MotionNotify ... ➔ ButtonRelease ➔ LeaveNotify

The second LeaveNotify differs from the first by the state field.

Unfortunately, ClutterCrossingEvent doesn't have a modifier_state field
like other events, so we cannot provide a way for programmatically
distinguishing them from a Clutter perspective. This is also an X11-ism
we might not even want to replicate on every backend with sane
enter/leave semantics.

For this reason we should check inside the X11 event processing if the
pointer device has already left the Stage and ignore the second
LeaveNotify.
2010-01-20 00:38:09 +00:00
Emmanuele Bassi
8736b53d7c device: Do not overwrite the stage for an InputDevice
The Stage field of an InputDevice is set by the backend, whenever the
pointer enters or leaves the Stage. The Stage should not overwrite the
stage field for every event it processes.
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
cf287db204 event: Off-stage button releases have a click count of 1
The ButtonRelease off-stage should not have a click count of 0 but a
click count initialized to 1.
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
bddabf6d2c event: Scroll events do not have click count
Remove the unneeded CLUTTER_SCROLL case from the click count checks.
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
e30856a54d Whitespace and indentation fixes 2010-01-20 00:38:08 +00:00
Emmanuele Bassi
0f9cfd9911 event: Clean up click-count detection
Avoid a few indirections and direct access to the Event and InputDevice
structures.
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
cf8a06f018 device: Store the current state, not the previous
The previous state for the device is used by the click count machinery
and we should not be overwriting it at every event; instead, we should
use a parallel storage for the current state coming from the windowing
system.
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
b3a42c3b09 docs: Update the API reference
Add the new symbols for InputDevice and DeviceManager
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
130286979d Do not pick when motion event delivery is disabled
The device manager does not need to update the state of the devices
when the user has disabled the delivery of motion events to actors:
the events will always be delivered as they are to the stage.
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
687c70dffa Rework the emission of LEAVE/ENTER event pairs
The LEAVE/ENTER event pairs should be queued during the InputDevice
update process, when we change the actor under the device pointer.

This commit cleans up the event emission code inside clutter-main.c
and the logic of the event processing.
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
a056ae7164 Add docs and licensing notices 2010-01-20 00:38:08 +00:00
Emmanuele Bassi
9506510d1c Move all picking-related operations inside InputDevice
The InputDevice objects stores pointer coordinates, state, stage and
the actor under the cursor, so if the current backend provides us with
one attached to the Event structure then we want the InputDevice itself
to update its state and give us the ClutterActor underneath the
pointer's cursor.
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
1f87cac069 actor: Add :has-pointer property
ClutterActor should be able to tell whether a pointer is within
its area or not.
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
d23dd9af6b device: Make InputDevice an object and subclass it for X11
ClutterInputDevice should be a type that we can subclass per-backend
to add functionality.
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
157da20e86 x11: Always assign a device to pointer and key events
Even when we are not using XInput we now have fallback devices; the
X11 backend should always assign the default devices when translating
the X events to Clutter events.
2010-01-20 00:38:07 +00:00
Emmanuele Bassi
ca16446319 Add :is-default flag to InputDevice 2010-01-20 00:38:07 +00:00
Emmanuele Bassi
3027d4327a Port the X11 backend to the Device Manager
Use the device manager to store the input devices. Also, provide
two fallback devices when initializing the X11 backend: device 0
for the pointer and device 1 for the keyboard.
2010-01-20 00:38:07 +00:00
Emmanuele Bassi
d34f1aa775 Add ClutterDeviceManager
The ClutterDeviceManager is a singleton object that behaves like the
StageManager: it holds all input devices and notifies on addition and
removal.
2010-01-20 00:38:07 +00:00
Neil Roberts
08b8b2791f cogl-atlas-texture: Don't create atlas textures with the premult bit
Previously the atlas textures were being created with whatever format
the first sub texture is in. Only three formats are supported so this
only matters if the first texture is a premultiplied alpha
texture. Instead it now masks out the premultiplied bit so that the
textures are always either RGB_888 or RGBA_8888.
2010-01-19 17:15:51 +00:00
Neil Roberts
14a28620ae win32: Use an invisible cursor when cursor-visible is FALSE
The win32 backend now handles the WM_SETCURSOR message and sets a
fully transparent cursor if the cursor-visible property has been
cleared on the stage. The icon is stored in the library via a resource
file. The instance handle for the DLL is needed to load the resource
so there is now a DllMain function to grab the handle.
2010-01-19 16:10:23 +00:00
Neil Roberts
ce030a3fce clutter-group: Use g_list_foreach in clutter_group_real_foreach
g_list_foreach has better protection against the current node being
removed. This will happen for example if someone calls
clutter_container_foreach(container, clutter_actor_destroy). This was
causing valgrind errors for the conformance tests which do just that.
2010-01-18 12:42:42 +00:00
Neil Roberts
c4adefffd3 cogl-atlas-texture: Fix premultiplied texture formats
When uploading texture data it was just calling cogl_texture_set_data
on the large texture. This would attempt to convert the data to the
format of the large texture. All of the textures with alpha channels
are stored together regardless of whether they are premultiplied so
this was causing premultiplied textures to be unpremultiplied
again. It now just uploads the data ignoring the premult bit of the
format so that it only gets converted once.
2010-01-18 10:53:00 +00:00
Neil Roberts
b78024bd2d cogl-primitives: Ensure the mipmaps for a layer before logging quads
With the atlas texture backend ensuring the mipmaps can make it become
a completely different texture which will have different texture
coordinates or may even be sliced. Therefore we need to ensure the
mipmaps before deciding which quads to log in the journal. This adds a
new private function to cogl-material which ensures the mipmaps if
needed.
2010-01-18 09:22:11 +00:00
Neil Roberts
36f18e5ac5 cogl: Make CoglSubTexture only work for quad rendering
The sub texture backend doesn't work well as a completely general
texture backend because for example when rendering with cogl_polygon
it needs to be able to tranform arbitrary texture coordinates without
reference to the other coordintes. This can't be done when the texture
coordinates are a multiple of one because sometimes the coordinate
should represent the left or top edge and sometimes it should
represent the bottom or top edge. For example if the s coordinates are
0 and 1 then 1 represents the right edge but if they are 1 and 2 then
1 represents the left edge.

Instead the sub-textures are now documented not to support coordinates
outside the range [0,1]. The coordinates for the sub-region are now
represented as integers as this helps avoid rounding issues. The
region can no longer be a super-region of the texture as this
simplifies the code quite a lot.

There are two new texture virtual functions:

transform_quad_coords_to_gl - This transforms two pairs of coordinates
     representing a quad. It will return FALSE if the coordinates can
     not be transformed. The sub texture backend uses this to detect
     coordinates that require repeating which causes cogl-primitives
     to use manual repeating.

ensure_non_quad_rendering - This is used in cogl_polygon and
     cogl_vertex_buffer to inform the texture backend that
     transform_quad_to_gl is going to be used. The atlas backend
     migrates the texture out of the atlas when it hits this.
2010-01-18 09:22:04 +00:00
Samuel Degrande
3d373c7278 win32: Fix computation of the fullscreen size during stage realization
http://bugzilla.openedhand.com/show_bug.cgi?id=1905

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2010-01-15 17:35:09 +00:00
Emmanuele Bassi
ea662b9eca docs: Display the features section
The features section of the API reference is built but not used, and it
has some copy-and-paste errors.
2010-01-15 17:06:56 +00:00
Emmanuele Bassi
e019547e8c x11: Fix typo in clutter_x11_set_use_argb_visual() declaration
The function should have a lowercase x11, not an uppercase X11 in its
name.
2010-01-15 14:48:42 +00:00
Neil Roberts
b844653c64 cogl-texture: Fix manual repeating for negative coordinates
When calculating the next integer position for negative coordinates it
would not increment if the position is already a multiple of one so we
need to manually add one.
2010-01-15 12:16:06 +00:00
Neil Roberts
a01b4eefce cogl-texture-2d: Fix the coordinate wrapping for negative coordinates
The formula to wrap the coordinates to the [0,1] range was broken when
the coordinates were negative.
2010-01-15 12:16:06 +00:00
Neil Roberts
ead4399536 Merge branch 'master' into more-texture-backends 2010-01-15 12:15:46 +00:00
Neil Roberts
8247bdf4f9 cogl-framebuffer: Return gboolean from try_creating_fbo
When try_creating_fbo fails it returns 0 to report the error and if it
succeeds it returns ‘flags’. However cogl_offscreen_new_to_texture
also passes in 0 for the flags as the last fallback to create the fbo
with nothing but the color buffer. In that case it will return 0
regardless of whether it succeeded so the last fallback will always be
considered a failure.

To fix this it now just returns a gboolean to indicate whether it
succeeded and the flags used for each attempt is assigned when passing
the argument rather than from the return value of the function.

Also if the only configuration that succeeded was with flags==0 then
it would always try all combinations because last_working_flags would
also be zero. To avoid this it now uses a separate gboolean to mark
whether we found a successful set of flags.

http://bugzilla.openedhand.com/show_bug.cgi?id=1873
2010-01-14 14:10:05 +00:00
Emmanuele Bassi
4388509a15 master-clock: Add profiling timers
Use the newly-added profiling timers inside the master clock dispatch
function to see how much time we spend:

  • in the whole function
    • in the event processing for each stage
    • in the timeline advancement
2010-01-14 12:30:48 +00:00
Emmanuele Bassi
948db40c87 Add gcov support to the build
Using gcov it's possible to get a coverage report, that is a break down
of how much the exposed API is exercised by the conformance test suite.
2010-01-13 17:15:06 +00:00
Emmanuele Bassi
5322546a4e build: Clean up COGL build flags 2010-01-13 17:15:06 +00:00
Damien Lespiau
18d96005ec texture: Remove reading the texture data back in ::unrealize()
Reading back the texture data in unrealize does not seem like a
desirable feature any more, clutter has evolved a lot since it was
implemented.

What's wrong with it now:

  * It takes *a lot* of time to read the data back with glReadPixel(),
  * When several textures share the same CoglTexture, the same data can
    be read back multiple times,
  * If the underlying material uses multiple texture units, only the
    first one was copied back,
  * In ClutterCairoTexture, we end up having two separate copies of the
    data,
  * GL actually manages texture memory accross system/video memory
    for us!

For all the reasons above, let's get rid of the glReadPixel() in
Texture::unrealize()

Fixes: OHB#1842
2010-01-13 15:13:10 +00:00
Neil Roberts
778e08e4e2 cogl-framebuffer: Add some missing GL defines
Since 755cce33a7 the framebuffer code is using the GL enums
GL_DEPTH_ATTACHMENT and GL_DEPTH_COMPONENT16. These aren't available
directly under GLES except with the OES suffix so we need to define
them manually as we do with the other framebuffer constants.
2010-01-12 17:10:15 +00:00
Neil Roberts
bb8352ca95 cogl: Remove the CGL_* defines
These macros used to define Cogl wrappers for the GLenum values. There are
now Cogl enums everywhere in the API where these were required so we
shouldn't need them anymore. They were in the public headers but as
they are not neccessary and were not in the API docs for Clutter 1.0
it should be safe to remove them.
2010-01-12 17:10:15 +00:00
Emmanuele Bassi
1c6ffc8a23 stage: Add the delete-event signal
Using the ::event signal to match the CLUTTER_DELETE event type (and
block the stage destruction) can be costly, since it means checking
every single event.

The ::delete-event signal is similar in spirit to any other specialized
signal handler dealing with events, and retains the same semantics.
2010-01-12 15:58:27 +00:00
Robert Bragg
8b950bdc87 journal: Fixes logging of multiple sets of texture coordinates
If a user supplied multiple groups of texture coordinates with
cogl_rectangle_with_multitexture_coords() then we would repeatedly log only
the first group in the journal.  This fixes that bug and adds a conformance
test to verify the fix.

Thanks to Gord Allott for reporting this bug.
2010-01-12 11:22:08 +00:00
Emmanuele Bassi
bc8a80fee5 text: Zero out the cursor_pos member
Do not trust the zero-ing done by GObject on the private data structure,
and use memset() instead to zero the ClutterGeometry structure.
2010-01-11 17:10:00 +00:00
Robert Bragg
755cce33a7 cogl: Support multiple fallbacks in cogl_offscreen_new_to_texture()
The Intel drivers in Mesa 7.6 (and possibly earlier versions) don't
support creating FBOs with a stencil buffer but without a depth
buffer. This reworks framebuffer allocation so that we try a number
of fallback options before failing.

The options we try in order are:
- the same options that were sucessful last time if available
- combined depth and stencil
- separate depth and stencil
- just stencil, no depth
- just depth, no stencil
- neither depth or stencil
2010-01-11 15:32:52 +00:00
Damien Lespiau
4c1231c7fe media: Add an API to specify which font should be used for subtitles
Allow the user of the ClutterMedia interface to specify a Pango font
description to display subtitles. Even if the underlying implementation
of the interface does not natively use Pange, it must be capable of
parsing the grammar that pango_font_description_from_string() accepts.
2010-01-11 13:04:16 +00:00