1
0
Fork 0
Commit graph

4373 commits

Author SHA1 Message Date
Emmanuele Bassi
a731682ac3 actor: Simple show/hide optimizations
Showing a visible (and hiding an invisible) actor is far less cheap than
it should be.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2422
2010-11-17 08:32:55 +00:00
Emmanuele Bassi
a32f781144 docs: Break down the constraints example 2010-11-17 08:32:54 +00:00
Emmanuele Bassi
2950cb3e78 docs: Fix Since tags for PaintVolume-related API 2010-11-15 16:02:15 +00:00
Emmanuele Bassi
b7fa13a52f docs: Add introductory section on Constraints
Use the snap-constraint code for the example code and screenshot.
2010-11-15 16:00:49 +00:00
Emmanuele Bassi
3c15c0c9bb Add SnapConstraint
A SnapConstraint is a constraint that "snaps" the edges of two actors
together.
2010-11-15 16:00:49 +00:00
Emmanuele Bassi
b3f5a6e2ba actor: Do not queue relayouts on actors being destroyed
Simple optimization is simple.
2010-11-15 16:00:48 +00:00
Emmanuele Bassi
0523d6db08 actor: Add a get_debug_name() private Actor method
For internal usage, writing:

  clutter_actor_get_name (actor) != NULL
    ? clutter_actor_get_name (actor)
    : G_OBJECT_TYPE_NAME (actor)

is overly verbose and does two type checks. A simple, internal method
for getting the same result without type checks would be much more
appreciated.
2010-11-15 16:00:48 +00:00
Emmanuele Bassi
5f9df7e3a0 Fix compilation warning by using the correct type 2010-11-15 15:36:41 +00:00
Emmanuele Bassi
e80035331b Use the right string in the font settings debug blurb 2010-11-14 23:06:53 +00:00
Emmanuele Bassi
e6bc65b5c3 text: Do not segfault with NULL :font-name
Make sure that we have a fall back in place for the default font name
string, and use g_strcmp0 to protect ourselves from NULL strings.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2417
2010-11-14 23:06:48 +00:00
Owen W. Taylor
9249bd8411 xsettings: don't use the xsettings watch function functionality
The "watch" function functionality in xsettings-client.c is designed
for setups like GDK where filters are per-window. If we are going
to pass all events to _clutter_xsettings_client_process_event()
anyways, we can just pass in NULL for watch.

This avoids a nasty infinite loop where an event would get processed
triggering removing a filter and adding a new filter, which would
immediately run and remove a filter and add another and so on
ad-infinitum.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2415
2010-11-14 14:50:25 +00:00
Lucas Rocha
03a713e18e click-action: don't use pointer grabs
The same behavior can be achieved by capturing events on stage while
button is pressed. This fixes a problem when using click and drag
actions on the same actor as there no grabs involved.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2409
2010-11-11 23:18:20 +00:00
Emmanuele Bassi
dfdd591414 Merge branch 'wip/static-colors'
* wip/static-colors:
  Move tests to static colors where possible
  color: Add named, global colors
2010-11-11 17:53:42 +00:00
Neil Roberts
1bcf15e1b8 cogl-texture: Remove the gl_handle from CoglTextureSliceCallback
There's no longer any need to use the GL handle in the callback for
_cogl_texture_foreach_sub_texture_in_region because it can now work in
terms of primitive cogl textures so it has now been removed. This
would be helpful if we ever want to make the foreach function public
so that apps could implement their own primitives using sliced
textures.
2010-11-11 16:25:13 +00:00
Neil Roberts
49898d43dd cogl-pipeline: Use layer overrides as CoglHandles instead of GLuint
Since d5634e37 the sliced texture backend now works in terms of
CoglTexture2Ds so there's no need to have special casing for
overriding the texture of a pipeline layer with a GL handle. Instead
we can just use cogl_pipeline_set_layer_texture with the
CoglHandle. The special _cogl_pipeline_set_layer_gl_texture_slice
function has now been removed and parts of the code for comparing
materials have been simplified.
2010-11-11 16:25:13 +00:00
Neil Roberts
1447ceb0de CoglTexture2DSliced: Pass slice tex to callback in foreach_sub_texture
The cogl_texture_foreach_sub_texture_in_region virtual for the sliced
texture backend was previously passing the CoglHandle of the sliced
texture to the callback. Since d5634e37 the slice texture backend now
works in terms of 2D textures so it's possible to pass the underlying
slice texture as a handle too. This makes all of the foreach callbacks
consistent in that they pass a CoglHandle of the primitive texture
type that matches the GL handle.
2010-11-11 16:25:13 +00:00
Robert Bragg
fb9d3a8350 path 2.0: update path API for experimental 2.0 API
When COGL_ENABLE_EXPERIMENTAL_2_0_API is defined cogl.h will now include
cogl2-path.h which changes cogl_path_new() so it can directly return a
CoglPath pointer; it no longer exposes a prototype for
cogl_{get,set}_path and all the remaining cogl_path_ functions now take
an explicit path as their first argument.

The idea is that we want to encourage developers to retain path objects
for as long as possible so they can take advantage of us uploading the
path geometry to the GPU. Currently although it is possible to start a
new path and query the current path, it is not convenient.

The other thing is that we want to get Cogl to the point where nothing
depends on a global, current context variable. This will allow us to one
day define a sensible threading model if/when that is ever desired.
2010-11-11 13:17:26 +00:00
Robert Bragg
b993195dc8 cogl: Adds COGL_ENABLE_EXPERIMENTAL_2_0_API define
For now this new define is simply an alias for
COGL_ENABLE_EXPERIMENTAL_API but the intention is that we will also use
it to start experimenting with changes that need to break the existing
Cogl API in incompatible ways.
2010-11-11 13:17:26 +00:00
Emmanuele Bassi
985518c601 color: Add named, global colors
Since EGA colors are apparently all the rage in other toolkits, Clutter
should not be left out. On top of the usual CGA/EGA palette the static
colors also include the Tango Icon palette, which at least is more
pleasant to the eye.

Static colors are accessed through an enumeration by using
clutter_color_get_static(), or using the short-hand pre-processor
macros.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2066
2010-11-11 13:14:23 +00:00
Robert Bragg
5f30835eae cogl-shader: Prepend boilerplate for portable shaders
We now prepend a set of defines to any given GLSL shader so that we can
define builtin uniforms/attributes within the "cogl" namespace that we
can use to provide compatibility across a range of the earlier versions
of GLSL.

This updates test-cogl-shader-glsl.c and test-shader.c so they no longer
needs to special case GLES vs GL when splicing together its shaders as
well as the blur, colorize and desaturate effects.

To get a feel for the new, portable uniform/attribute names here are the
defines for OpenGL vertex shaders:

 #define cogl_position_in gl_Vertex
 #define cogl_color_in gl_Color
 #define cogl_tex_coord_in  gl_MultiTexCoord0
 #define cogl_tex_coord0_in gl_MultiTexCoord0
 #define cogl_tex_coord1_in gl_MultiTexCoord1
 #define cogl_tex_coord2_in gl_MultiTexCoord2
 #define cogl_tex_coord3_in gl_MultiTexCoord3
 #define cogl_tex_coord4_in gl_MultiTexCoord4
 #define cogl_tex_coord5_in gl_MultiTexCoord5
 #define cogl_tex_coord6_in gl_MultiTexCoord6
 #define cogl_tex_coord7_in gl_MultiTexCoord7
 #define cogl_normal_in gl_Normal

 #define cogl_position_out gl_Position
 #define cogl_point_size_out gl_PointSize
 #define cogl_color_out gl_FrontColor
 #define cogl_tex_coord_out gl_TexCoord

 #define cogl_modelview_matrix gl_ModelViewMatrix
 #define cogl_modelview_projection_matrix gl_ModelViewProjectionMatrix
 #define cogl_projection_matrix gl_ProjectionMatrix
 #define cogl_texture_matrix gl_TextureMatrix

And for fragment shaders we have:

 #define cogl_color_in gl_Color
 #define cogl_tex_coord_in gl_TexCoord

 #define cogl_color_out gl_FragColor
 #define cogl_depth_out gl_FragDepth

 #define cogl_front_facing gl_FrontFacing
2010-11-10 14:24:52 +00:00
Tomeu Vizoso
373140c830 Discard the current pick buffer...
if we are asked to pick with a different mode.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2385
2010-11-08 16:45:15 +00:00
Emmanuele Bassi
4909ecc71e gtk-doc: Fixes for the API references 2010-11-08 16:01:19 +00:00
Emmanuele Bassi
993d3b3fe1 timeout-pool: Deprecate the structure too
Don't leave it lying around, since nothing can use it anyway.
2010-11-08 15:52:17 +00:00
Emmanuele Bassi
26a70707ab path-constraint: Add a ::node-reached signal
Emit a signal whenever a node in the path has been reached.
2010-11-07 21:35:40 +00:00
Emmanuele Bassi
ef7f729c68 build: Re-instate profile builds
The profiling support was broken - probably during the restructuring of
the build environment, but I'm too lazy to bisect that.

The fix is trivial, and everything works as it should.
2010-11-07 15:27:17 +00:00
Emmanuele Bassi
38912ee4d9 Deprecate ClutterFrameSource
The FrameSource API hasn't been used internally since 1.0; since it's
not part of the paint clock, it is of limited use.
2010-11-06 20:11:16 +00:00
Emmanuele Bassi
9ac2f5cba5 Deprecate ClutterTimeoutPool
Timelines have stopped using the pool since 1.0; there is no real reason
to expose it as part of the active API.
2010-11-06 20:11:16 +00:00
Emmanuele Bassi
a432d9973d Remove a compiler warning 2010-11-06 18:12:41 +00:00
Maxim Ermilov
6ec9c3247c CoglContext: correct initialization order
http://bugzilla.clutter-project.org/show_bug.cgi?id=2401
2010-11-06 18:06:19 +00:00
Neil Roberts
cc63c7dd8f cogl-texture-2d-sliced: Fix the foreach callback for waste textures
When converting the virtual coordinates of the underlying texture for
a slice to virtual coordinates for the whole texture it was using the
size and offset of the intersection as the size of the child
texture. This would be incorrect if the texture contains waste or the
texture coordinates are not the default. Instead the sliced foreach
function now passes the CoglSpan to the callback instead of the
intersection.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2398
2010-11-05 18:45:31 +00:00
Neil Roberts
8112bfc49f Replace the disable-npots tool with a COGL_DEBUG option
Previously in the tests/tools directory we build a disable-npots
library which was used as an LD_PRELOAD to trick Cogl in to thinking
there is no NPOT texture extension. This is a little awkward to use so
it seems much simpler to just define a COGL_DEBUG option to disable
npot textures.
2010-11-05 18:45:31 +00:00
Robert Bragg
632412c9c8 actor: Check "paint" handlers in _get_paint_volume
Instead of waiting until clutter_actor_paint to check if there are any
handlers connected to the "paint" signal, we now do the check whenever
the paint-volume is requested in _actor_get_paint_volume_mutable().

Previously we checked in clutter_actor_paint(), but at that time we may
already be using a stage clip that could be derived from an invalid
paint-volume. We used to try and handle that by queuing a follow up,
unclipped, redraw but anyway there was an additional problem with the
previous approach because the checking wasn't enough to always catch
invalid volumes involved in culling (considering that containers may
derive their volume from children that haven't yet been painted)

By moving the check to _get_paint_volume time not only do we now
correctly check children in cases where a container derives its volume
from its children's volumes but we no longer need to queue follow up
redraws to cover up artefacts.

Since we now never queue follow up redraws, this in turn means we should
no longer clobber redraws queued with an explicit clip which was
something affecting gnome-shell since it connects a handler to the paint
signal of the stage.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2388
2010-11-05 17:22:05 +00:00
Robert Bragg
844b578128 matrix-stack: use GArray instead of GSList for stack
In some micro-benchmarks testing journal throughput the list
manipulation jumps pretty high in the profile. This replaces the GSList
usage with a GArray instead which is effectively a grow only allocation
that means we avoid ongoing allocations while manipulating the stack
mid-scene.
2010-11-04 18:35:16 +00:00
Robert Bragg
a6000533dc pipeline: Avoid costly checking of lighting properties
During _cogl_pipeline_needs_blending_enabled we were always checking the
current lighting properties (ambient,diffuse,specular,emission) which
had a notable impact during micro-benchmarks that exercise journal
throughput of simple colored rectangles. This #if 0's the offending code
considering that Cogl doesn't actually support lighting currently and
when it actually does then we will be able to optimize this by avoiding
the checks when lighting is disabled.
2010-11-04 18:22:41 +00:00
Robert Bragg
eaee5dd604 cogl: add separate material for blended source_colors
When using cogl_set_source_color4ub there is a notable difference
between colors that require blending and those that dont. When trying to
modify the color of pipeline referenced by the journal we don't force a
flush of the journal unless the color change will also change the
blending state. By using two separate pipeline objects for handing
opaque or transparent colors we can avoid ever flushing the journal when
repeatedly using cogl_set_source_color and jumping between opaque and
transparent colors.
2010-11-04 18:22:40 +00:00
Robert Bragg
d05ce7cd26 texture_quad_multiple_primitives: rework wrap mode overrides
This reworks _cogl_texture_quad_multiple_primitives so instead of using
the CoglPipelineWrapModeOverrides mechanism to force the clamp to edge
repeat mode we now derive an override pipeline using cogl_pipeline_copy
instead. This avoids a relatively large, unconditional, memset.
2010-11-04 18:22:40 +00:00
Robert Bragg
7bbe207b65 _multitexture_quad_single_primitive: avoid wrap overrides
This avoids using the wrap mode overrides mechanism to implement
_cogl_multitexture_quad_single_primitive which requires memsetting a
fairly large array. This updates it to use cogl_pipeline_foreach_layer()
and we now derive an override_material to handle changes to the wrap
modes instead of using the CoglPipelineWrapModeOverrides.
2010-11-04 18:22:39 +00:00
Neil Roberts
e73b67e59b cogl-path: Don't bother filling the path if less than 3 nodes
Previously there was a check to avoid filling the path if there are
zero nodes. However the tesselator also won't generate any triangles
if there are less than 3 nodes so we might as well bail out in that
case too. If we don't emit any triangles then we would end up trying
to create an empty VBO. Although I don't think this should necessarily
be a problem, this seems to cause Mesa to segfault in version 7.8.1
when calling glBufferSubData (although not in
master). test-cogl-primitives tries to fill a path with only two
points so it's convenient to be able to avoid the crash in this case.
2010-11-04 18:10:09 +00:00
Neil Roberts
25b48585d3 cogl-journal: Log the clip state in the journal
When adding a new entry to the journal a reference is now taken on the
current clip stack. Modifying the current clip state no longer causes
a journal flush. The journal flushing code now has an extra stage to
compare the clip state of each entry. The comparison can simply be
done by comparing the pointers. Although different clip states will
still end up with multiple draw calls this at leasts allows a scene
comprising of multiple different clips to be upload with one vbo. It
also lays the groundwork to do certain tricks when drawing clipped
rectangles such as modifying the geometry instead of setting a clip
state.
2010-11-04 18:10:09 +00:00
Neil Roberts
4d5dc42dad cogl-framebuffer: Add a flag to skip flushing the clip state
This adds a flag to avoid flushing the clip state when flushing the
framebuffer state. This will be used by the journal to manage its own
clip state flushing.
2010-11-04 18:10:09 +00:00
Neil Roberts
c5d909d063 cogl: Don't flush the journal when flushing clip state
Flushing the clip state no longer does anything that would cause the
journal to flush. The clip state is only flushed when flushing the
framebuffer state and in all cases this ends up flushing the journal
in one way or another anyway. Avoiding flushing the journal will make
it easier to log the clip state in the journal.

Previously when trying to set up a rectangle clip that can't be
scissored or when using a path clip the code would use cogl_rectangle
as part of the process to fill the stencil buffer. This is now changed
to use a new internal _cogl_rectangle_immediate function which
directly uses the vertex array API to draw a triangle strip without
affecting the journal. This should be just as efficient as the
previous journalled code because these places would end up flushing
the journal immediately before and after submitting the single
rectangle anyway and flushing the journal always creates a new vbo so
it would effectively do the same thing.

Similarly there is also a new internal _cogl_clear function that does
not flush the journal.
2010-11-04 18:10:08 +00:00
Neil Roberts
a39b292d90 cogl-path: Use the vertex array API instead of CoglVertexBuffer
The new vertex array is now implemented in terms of the
CoglVertexBuffer anyway so it should be slightly faster to use a
vertex array directly.
2010-11-04 18:09:42 +00:00
Neil Roberts
60de7939ee cogl: Move the clip stack dirtiness to the context rather than the FB
Previously we tracked whether the clip stack needs flushing as part of
the CoglClipState which is part of the CoglFramebuffer state. This is
a bit odd because most of the clipping state (such as the clip planes
and the scissor) are part of the GL context's state rather than the
framebuffer. We were marking the clip state on the framebuffer dirty
every time we change the framebuffer anyway so it seems to make more
sense to have the dirtiness be part of the global context.

Instead of a just a single boolean to record whether the state needs
flushing, the CoglContext now holds a reference to the clip stack that
was flushed. That way we can flush arbitrary stack states and if it
happens to be the same as the state already flushed then Cogl will do
nothing. This will be useful if we log the clip stack in the journal
because then we will need to flush unrelated clip stack states for
each batch.
2010-11-04 18:08:27 +00:00
Neil Roberts
57574f3995 cogl-clip-stack: Don't allocate a separate struct for CoglClipStack
Instead of having a separate CoglHandle for CoglClipStack the code is
now expected to directly hold a pointer to the top entry on the
stack. The empty stack is then the NULL pointer. This saves an
allocation when we want to copy the stack because we can just take a
reference on a stack entry. The idea is that this will make it
possible to store the clip stack in the journal without any extra
allocations.

The _cogl_get_clip_stack and set functions now take a CoglClipStack
pointer instead of a handle so it would no longer make sense to make
them public. However I think the only reason we would have wanted that
in the first place would be to save the clip state between switching
FBOs and that is no longer necessary.
2010-11-04 18:08:27 +00:00
Neil Roberts
314e980a3b cogl: Don't flush the framebuffer state for the internal draw
CoglVertexAttribute has an internal draw function that is used by the
CoglJournal to avoid the call to cogl_journal_flush which would
otherwise end up recursively flushing the journal forever. The
enable_gl_state function called by this was previously also calling
_cogl_flush_framebuffer_state. However the journal code tries to
handle this function specially by calling it with a flag to disable
flushing the modelview matrix. This is useful because the journal
handles flushing the modelview itself. Without this patch the journal
state ends up getting flushed twice. This isn't a particularly big
problem currently because the matrix stack has caching to recognise
when it would push the same state twice and bails out. However if we
later want to use the framebuffer flush flags to override a particular
state of the framebuffer (such as the clip state) then we need to make
sure the flush isn't called twice.
2010-11-04 18:08:27 +00:00
Neil Roberts
738a669fc2 cogl-buffer: Use void* instead of guint8* for map and set_data
Unless the CoglBuffer is being used for texture data then it's
relatively unlikely that the data will contain an array of bytes. For
example if it's used as a vertex array then it's more likely to be
floats or some vertex struct. In that case it's much more convenient
if set_data and map use void* pointers so that we can avoid a cast.
2010-11-04 18:04:03 +00:00
Neil Roberts
390bdd2a27 cogl-primitive: Fix the texture attribute offsets
The offsets for the texture coordinate attributes in the convenience
constructors were all wrong.
2010-11-04 17:59:33 +00:00
Neil Roberts
17aaaac336 cogl-primitive: Fix a typo in new_with_attributes_array
A typo in the g_return_val_if_fail was causing it to segfault.
2010-11-04 17:59:33 +00:00
Neil Roberts
b6eaab812b cogl-primitive: Add the missing cogl_primitive_new_p2 function
There was a struct defined for CoglP2Vertex but there was no
constructor function to use it.
2010-11-04 17:59:28 +00:00
Neil Roberts
1935855cdd cogl-primitive: Fix the ref-counting for the convenience constuctors
The convenience constructors for the builtin vertex structs were
creating the primitive and then immediately destroying it and
returning the pointer. I think the intention was to unref the
attributes instead. This adds an internal wrapper around the
new_with_attributes_array constructor which unrefs the attributes
instead of the primitive. The convenience constructors now use that.
2010-11-04 17:57:09 +00:00
Robert Bragg
3c35b95a84 primitive: fix prototypes and start adding docs
This fixes the prototypes for the cogl_primitive_new_xyz functions and
also adds documentation with examples for each one.
2010-11-04 17:57:05 +00:00
Neil Roberts
00397a313c cogl-gles2-wrapper: Fix a reference to the old name for CoglPipeline
The GLES2 wrapper was referring to COGL_MATERIAL_PROGRAM_TYPE_GLSL but
this has since been renamed to COGL_PIPELINE_PROGRAM_TYPE_GLSL so the
GLES2 backend wouldn't compile.
2010-11-04 14:56:44 +00:00
Robert Bragg
5abdbd5f7a gles2: disable vbos until while we rework backend
The gles2 wrapper functions don't understand about the CoglBuffer API so
they don't support attributes stored in a CoglVertexArray. Instead of
teaching the backend about buffers we are going to wait until we have
overhauled the GLES 2 backend. We are currently making progress
consolidating the GLES 2 backend with a new GLSL backend for
CoglMaterial. This will hugely simplify the GLES 2 support and share
code with the OpenGL backend. In the end it's hoped that this problem
will simply go away so it doesn't make much sense to solve it with the
current design.
2010-11-03 18:09:23 +00:00
Robert Bragg
8034dc87d4 cogl: rename CoglMaterial -> CoglPipeline
This applies an API naming change that's been deliberated over for a
while now which is to rename CoglMaterial to CoglPipeline.

For now the new pipeline API is marked as experimental and public
headers continue to talk about materials not pipelines. The CoglMaterial
API is now maintained in terms of the cogl_pipeline API internally.
Currently this API is targeting Cogl 2.0 so we will have time to
integrate it properly with other upcoming Cogl 2.0 work.

The basic reasons for the rename are:
- That the term "material" implies to many people that they are
  constrained to fragment processing; perhaps as some kind of high-level
  texture abstraction.
    - In Clutter they get exposed by ClutterTexture actors which may be
      re-inforcing this misconception.
- When comparing how other frameworks use the term material, a material
  sometimes describes a multi-pass fragment processing technique which
  isn't the case in Cogl.
- In code, "CoglPipeline" will hopefully be a much more self documenting
  summary of what these objects represent; a full GPU pipeline
  configuration including, for example, vertex processing, fragment
  processing and blending.
- When considering the API documentation story, at some point we need a
  document introducing developers to how the "GPU pipeline" works so it
  should become intuitive that CoglPipeline maps back to that
  description of the GPU pipeline.
- This is consistent in terminology and concept to OpenGL 4's new
  pipeline object which is a container for program objects.

Note: The cogl-material.[ch] files have been renamed to
cogl-material-compat.[ch] because otherwise git doesn't seem to treat
the change as a moving the old cogl-material.c->cogl-pipeline.c and so
we loose all our git-blame history.
2010-11-03 18:09:23 +00:00
Robert Bragg
959af183b1 pango: Use CoglMaterial type for materials
Instead of using the CoglHandle type for material variables this updates
the pango code to use CoglMaterial * instead. CoglHandle is the old
typename which is being phased out of the API.
2010-11-03 18:09:23 +00:00
Robert Bragg
7ee99aaa83 pango: push/pop source instead of trashing users source
The pango-display-list code was calling cogl_set_source in numerous
places and it didn't appear to be saving the users source to restore
later. This could result in the user inadvertantly drawing a primitive
with one of these internally managed materials instead of one that they
chose. To rectify this the code now uses cogl_{push,pop}_source to save
and restore the users source.
2010-11-03 18:09:22 +00:00
Robert Bragg
4e69c73085 primitives: implements cogl_polygon on vertex_attributes
This updates the implementation of cogl_polygon so it sits on the new
CoglVertexArray and CoglVertexAttribute apis. This lets us minimize the
number of different drawing paths we have to maintain in Cogl.

Since the sliced texture support for cogl_polygon has been broken for a
long time now and no one has complained this patch also greatly
simplifies the code by not doing any special material validation so
cogl_polygon will be restricted in the same way as
cogl_draw_vertex_attributes. (i.e. sliced textures not supported).
2010-11-03 18:09:22 +00:00
Robert Bragg
f9d9b1b157 journal: port to the vertex_attributes API
Instead of using raw OpenGL in the journal we now use the vertex
attributes API instead. This is part of an ongoing effort to reduce the
number of drawing paths we maintain in Cogl.
2010-11-03 18:09:22 +00:00
Robert Bragg
f82b32cb3b vertex-buffer: use cogl_get_rectangle_indices
The functionality of cogl_vertex_buffer_indices_get_for_quads is now
provided by cogl_get_rectangle_indices so this reworks the former to now
work in terms of the latter so we don't have duplicated logic.
2010-11-03 18:09:22 +00:00
Robert Bragg
670ea32dbd vertex-buffer: port to CoglVertexAttributes + CoglPrimitive
As part of an ongoing effort to reduce the number of draw paths we have
in Cogl this re-works CoglVertexBuffer to use the CoglVertexAttribute
and CoglPrimitive APIs instead of using raw GL.
2010-11-03 18:09:15 +00:00
Robert Bragg
69b1f756d1 primitive: adds immutable ref/unref mechanism
This adds a way to mark that a primitive is in use so that modifications
will generate a warning. The plan is to use this mechanism when batching
primitives in the journal to warn users that mid-scene modifications of
primitives is not allowed.
2010-11-03 18:04:31 +00:00
Robert Bragg
2d58d3f1b6 primitive: Adds convenience constructors
This adds convenience primitive constructors named like:
  cogl_primitive_new_p3 or
  cogl_primitive_new_p3c4 or
  cogl_primitive_new_p3t2c4
where the letters correspond to the interleved vertex attributes layouts
such as CoglP3Vertex which is a struct with 3 float x,y,z members for
the [p]osition, or CoglP3T2C4Vertex which is a struct with 3 float x,y,z
members for the [p]osition, 2 float s,t members for the [t]exture
coordinates and 4 unsigned byte r,g,b,a members for the [c]olor.

The hope is that people will find these convenient enough to replace
cogl_polygon.
2010-11-03 18:04:31 +00:00
Robert Bragg
0cd077dc7e cogl: Adds experimental CoglPrimitive API
A CoglPrimitive is a retainable object for drawing a single primitive,
such as a triangle strip, fan or list.

CoglPrimitives build on CoglVertexAttributes and CoglIndices which
themselves build on CoglVertexArrays and CoglIndexArrays respectively.

A CoglPrimitive encapsulates enough information such that it can be
retained in a queue (e.g. the Cogl Journal, or renderlists in the
future) and drawn at some later time.
2010-11-03 18:04:31 +00:00
Robert Bragg
dd63078bd3 cogl: Adds experimental CoglVertexAttribute API
A CoglVertexAttribute defines a single attribute contained in a
CoglVertexArray. I.e. a CoglVertexArray is simply a buffer of N bytes
intended for containing a collection of attributes (position, color,
normals etc) and a CoglVertexAttribute defines one such attribute by
specifying its start offset in the array, its type, the number of
components and the stride etc.
2010-11-03 18:04:26 +00:00
Robert Bragg
3d14fbc308 cogl: Adds experimental CoglIndices API
CoglIndices define a range of indices inside a CoglIndexArray. I.e. a
CoglIndexArray is simply a buffer of N bytes and you can then
instantiate multiple CoglIndices collections that define a sub-region of
a CoglIndexArray by specifying a start offset and an index data type.
2010-11-03 18:04:00 +00:00
Robert Bragg
8ca80e47c4 cogl: Adds experimental CoglVertexArray type
This adds a new CoglVertexArray object which is a subclass of CoglBuffer
used to hold vertex attributes. A later commit will add a
CoglVertexAttribute API which will be used to describe the attributes
inside a CoglVertexArray.
2010-11-03 18:04:00 +00:00
Robert Bragg
3aba41e202 cogl: Adds experimental CoglIndexArray type
A CoglIndexArray is a subclass of CoglBuffer and will be used to hold
vertex indices. A later commit will add a CoglIndices API which will
allow describing a range of indices inside a CoglIndexArray.
2010-11-03 18:04:00 +00:00
Robert Bragg
eac167df1c buffer: adds immutable ref/unref mechanism
This adds an internal mechanism to mark that a buffer is in-use so that
a warning can be generated if the user attempts to modify the buffer.

The plans is for the journal to use this mechanism so that we can warn
users about mid-scene modifications of buffers.
2010-11-03 18:03:55 +00:00
Robert Bragg
efa11f8a8f buffer: make _bind() return base pointer
We now make _cogl_buffer_bind return a base pointer for the bound buffer
which can be used with OpenGL. The pointer will be NULL for GPU based
buffers or may point to an malloc'd buffer. Since OpenGL expects an
offset instead of a pointer when dealing with buffer objects this means
we can handle fallback malloc buffers and GPU buffers in a consistent
way.
2010-11-03 17:28:45 +00:00
Robert Bragg
35ddc5407e material: Bail out faster if re-flushing unchanged material
This allows _cogl_material_flush_gl_state to bail out faster if
repeatedly asked to flush the same material and we can see the material
hasn't changed.

Since we can rely on the material age incrementing when any material
property changes or any associated layer property changes then we can
track the age of the material after flushing so it can be compared with
the age of the material if it is subsequently re-flushed. If the age is
the same we only have to re-assert the texture object state.
2010-11-03 17:28:45 +00:00
Robert Bragg
bbf27e6b28 material-node: track if node owns reference on parent
MaterialNodes are used for the sparse graph of material state and layer
state. In the case of materials there is the idea of weak materials that
don't take a reference on their parent and in that case we need to be
careful not to unref our parent during
_cogl_material_node_unparent_real. This adds a has_parent_reference
member to the CoglMaterialNode struct so we now know when to skip the
unref.
2010-11-03 17:28:45 +00:00
Robert Bragg
e5202d6a0d cogl-object: correctly free user_data_array in _unref
If there is private data associated with a CoglObject then there may be
a user_data_array that needs to be freed. The code was mistakenly
freeing the array inside the loop that was actually iterating over the
user data array notifying the objects destruction instead of waiting
until all the data entries had been destroyed.
2010-11-03 17:28:45 +00:00
Owen W. Taylor
0b4b1ca1ca Don't leave stale invalidated queued redraws around
Once an actor had _clutter_stage_queue_redraw_entry_invalidate()
called on it once, then priv->queue_redraw_entry would point to
an entry with entry->actor NULL. _clutter_stage_queue_actor_redraw()
doesn't handle this case and no further redraws would be queued.

To fix this, NULL out priv->queue_redraw_entry() and then make sure
we free the invalidated entry in
_clutter_stage_maybe_finish_queue_redraws() just as we do for
still valid entries.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2389
2010-11-03 15:43:55 +00:00
Neil Roberts
02a3670e88 win32: Fix a couple of build warnings
* clutter-backend-win32 had an unused variable

* clutter-event-win32 was using the abs function without including
  stdlib.h
2010-11-01 15:21:04 +00:00
Neil Roberts
f13f545aa9 clutter-backend-win32: Use g_object_unref on the stage manager
Previously when trying to destroy all of the stages in the backend
dispose function it would poke directly in the ClutterStageManager
struct to get the list. In 8613013ab0 the defintion of
ClutterStageManager moved to a different header which isn't included
by the Win32 backend so it wouldn't compile. In that commit the X11
backend was changed to unref the stage manager instead of poking in
the internals so we should do the same for the win32 backend.
2010-11-01 15:14:07 +00:00
Damien Lespiau
907490d795 clone: Remove checks in set_source_internal()
One of the ideas behind _internal() functions is to be able to have a
version of the original one without checks (among other things). As
these functions are either static or private to the library, we control
the arguments given to it, and thus no need for checking them again
here.
2010-11-01 12:16:53 +00:00
Damien Lespiau
a318fe5ca5 texture: Warn when the file loaded from a ClutterScript can't be found
Telling the user about files not found when loading a ClutterScript with
ClutterTextures in it is very useful and can save a few minutes (or
hours) of frustation because it "does not work".
2010-11-01 11:43:35 +00:00
Neil Roberts
2ee0e40848 Merge cogl-program-{gl,gles}.c into one cogl-program.c
This merges the two implementations of CoglProgram for the GLES2 and
GL backends into one. The implementation is more like the GLES2
version which would track the uniform values and delay sending them to
GL. CoglProgram is now effectively just a GList of CoglShaders along
with an array of stored uniform values. CoglProgram never actually
creates a GL program, instead this is left up to the GLSL material
backend. This is necessary on GLES2 where we may need to relink the
user's program with different generated shaders depending on the other
emulated fixed function state. It will also be necessary in the future
GLSL backends for regular OpenGL. The GLSL and ARBfp material backends
are now the ones that create and link the GL program from the list of
shaders. The linked program is attached to the private material state
so that it can be reused if the CoglProgram is used again with the
same material. This does mean the program will get relinked if the
shader is used with multiple materials. This will be particularly bad
if the legacy cogl_program_use function is used because that
effectively always makes one-shot materials. This problem will
hopefully be alleviated if we make a hash table with a cache of
generated programs. The cogl program would then need to become part of
the hash lookup.

Each CoglProgram now has an age counter which is incremented every
time a shader is added. This is used by the material backends to
detect when we need to create a new GL program for the user program.

The internal _cogl_use_program function now takes a GL program handle
rather than a CoglProgram. It no longer needs any special differences
for GLES2. The GLES2 wrapper function now also uses this function to
bind its generated shaders.

The ARBfp shaders no longer store a copy of the program source but
instead just directly create a program object when cogl_shader_source
is called. This avoids having to reupload the source if the same
shader is used in multiple materials.

There are currently a few gross hacks to get the GLES2 backend to work
with this. The problem is that the GLSL material backend is now
generating a complete GL program but the GLES2 wrapper still needs to
add its fixed function emulation shaders if the program doesn't
provide either a vertex or fragment shader. There is a new function in
the GLES2 wrapper called _cogl_gles2_use_program which replaces the
previous cogl_program_use implementation. It extracts the GL shaders
from the GL program object and creates a new GL program containing all
of the shaders plus its fixed function emulation. This new program is
returned to the GLSL material backend so that it can still flush the
custom uniforms using it. The user_program is attached to the GLES2
settings struct as before but its stored using a GL program handle
rather than a CoglProgram pointer. This hack will go away once the
GLSL material backend replaces the GLES2 wrapper by generating the
code itself.

Under Mesa this currently generates some GL errors when glClear is
called in test-cogl-shader-glsl. I think this is due to a bug in Mesa
however. When the user program on the material is changed the GLSL
backend gets notified and deletes the GL program that it linked from
the user shaders. The program will still be bound in GL
however. Leaving a deleted shader bound exposes a bug in Mesa's
glClear implementation. More details are here:

https://bugs.freedesktop.org/show_bug.cgi?id=31194
2010-10-28 19:51:42 +01:00
Neil Roberts
65d7a113ee cogl: Use separate materials for set_source_color and texture
Previously cogl_set_source_color and cogl_set_source_texture modified
a single global material. If an application then mixes using
cogl_set_source_color and texture then the material will constantly
need a new ARBfp program because the numbers of layers alternates
between 0 and 1. This patch just adds a second global material that is
only used for cogl_set_source_texture. I think it would still end up
flushing the journal if cogl_set_source_texture is used with multiple
different textures but at least it should avoid a recompile unless the
texture target also changes. It might be nice to somehow attach a
material to the CoglTexture for use with cogl_set_source_texture but
it would be difficult to implement this without creating a circular
reference.
2010-10-27 15:07:03 +01:00
Robert Bragg
89cedc7800 Move IndicesType and VerticesMode typedefs to cogl-types.h
This moves the CoglIndicesType and CoglVerticesMode typedefs from
cogl-vertex-buffer.h to cogl-types.h so they can be shared with the
anticipated cogl vertex attribute API.
2010-10-26 17:25:33 +01:00
Robert Bragg
e3bf83eab5 buffer: BufferBindTarget + BufferUsageHint enum renaming
This renames the BufferBindTarget + BufferUsageHint enums to match the
anticipated new APIs for "index arrays" and "vertex arrays" as opposed
to using the terms "vertices" or "indices".
2010-10-26 17:25:27 +01:00
Robert Bragg
9efe7ca5bc buffer: warn if (offset + size) > buffer->size
previously we would silently bail out if the given offset + data size
would overflow the buffer size. Now we use g_return_val_if_fail so we
get a warning if we hit this case.
2010-10-26 16:40:54 +01:00
Robert Bragg
b2963b4eef pixel-array: Remove some benign variables
There were some completely unused static global variables declared in
cogl-pixel-array.c which this patch removes.
2010-10-26 16:16:50 +01:00
Robert Bragg
902c18ad87 pixel-array: Remove flags member and flag macros
There are no flags associated with pixel-arrays so we don't need the
flags member or flag macros.
2010-10-26 16:16:40 +01:00
Robert Bragg
1c8b355bbb buffer: Add a store_created bit field member
This adds a store_created bit field to CoglBuffer so we know if the
underlying buffer has been allocated yet. Previously the code was trying
to do something really wrong by accidentally using the
COGL_PIXEL_ARRAY_FLAG_IS_SET macro (note "PIXEL_ARRAY") and what is more
odd was the declaration of a CoglPixelArray *pixel_array in
cogl-buffer.c which the buffer was being cast too before calling using
the macro. Probably this was the fall-out of some previous code
re-factoring.
2010-10-26 16:16:29 +01:00
Robert Bragg
d5188c26b6 buffer: remove flag macros
All the macros get used for are to |= (a new flag bit), &= ~(a flag bit)
or use the & operator to test if a flag bit is set. I haven't found the
code more readable with these macros, but several times now I've felt
the need to double check if these macros do anything else behind the
hood or I've forgotten what flags are available so I've had to go to the
macro definition to see what the full enum names are for the flags (the
macros use symbol concatenation) so I can search for the definition of
all the flags. It turns out they are defined next to the macro so you
don't have to search far, but without the macro that wouldn't have been
necessary.

The more common use of the _IS_SET macro is actually more concise
expanded and imho since it doesn't hide anything in a separate header
file the code is more readable without the macro.
2010-10-26 13:21:11 +01:00
Robert Bragg
bc3a26d035 material: Adds _cogl_material_get_layer_texture
This is a counter part for _cogl_material_layer_get_texture which takes
a layer index instead of a direct CoglMaterialLayer pointer. The aim is
to phase out code that directly iterates the internal layer pointers of
a material since the layer pointers can change if any property of any
layer is changed making direct layer pointers very fragile.
2010-10-26 13:06:54 +01:00
Robert Bragg
0288ba3911 material: add internal layer filter getters
This adds internal _cogl_material_get_layer_filters and
_cogl_material_get_layer_{min,mag}_filter functions which can be used to
query the filters associated with a layer using a layer_index, as
opposed to a layer pointer. Accessing layer pointers is considered
deprecated so we need to provide layer_index based replacements.
2010-10-26 13:04:05 +01:00
Robert Bragg
6fd26630ba material: Adds missing get_layer_wrap_mode_xyz prototypes
This adds missing getter function prototypes for
cogl_material_get_layer_wrap_mode_{s,t,p}
2010-10-26 13:02:23 +01:00
Robert Bragg
32ae904d81 vertex-buffer: remove the unstrided CBO type
When we come to submitting the users given attributes we sort them into
different types of buffers. Previously we had three types; strided,
unstrided and multi-pack. Really though unstrided was just a limited
form of multi-pack buffer and didn't imply any hind of special
optimization so this patch consolidates some code by reducing to just
two types; strided and multi-pack.
2010-10-26 12:38:15 +01:00
Robert Bragg
94e0619785 material: Adds _cogl_material_pre_paint_for_layer
This is a counter part for _cogl_material_layer_pre_paint which takes a
layer index instead of a direct CoglMaterialLayer pointer. The aim is to
phase out code that directly iterates the internal layer pointers of a
material since the layer pointers can change if any property of any
layer is changed making direct layer pointers very fragile.
2010-10-26 12:17:27 +01:00
Robert Bragg
701a693661 cogl: Adds {push,pop,get}_source functions
This exposes the idea of a stack of source materials instead of just
having a single current material. This allows the writing of orthogonal
code that can change the current source material and restore it to its
previous state. It also allows the implementation of new composite
primitives that may want to validate the current source material and
possibly make override changes in a derived material.
2010-10-26 12:08:20 +01:00
Emmanuele Bassi
bf6c635e9d Merge branch 'private-cleanup'
* private-cleanup:
  Add copyright notices
  Clean up clutter-private.h/6
  Clean up clutter-private.h/5
  Clean up clutter-private.h/4
  Clean up clutter-private.h/3
  Clean up clutter-private.h/2
  Clean up clutter-private.h/1
2010-10-25 23:44:53 +01:00
Chris Lord
cb7d2943ea state: Correct the documentation
Correct the argument order and replace all occurrences of
clutter_state_change() with the appropriate clutter_state_set_state() or
clutter_state_warp_to_state().
2010-10-25 17:21:20 +01:00
Chris Lord
bfc1583d76 state: Fix warping to the current state during transitions
If you warp to a state, it should be immediately set. Check if the
animation is in progress when warping to a state and don't short-circuit
in the already-set check if we're not animating.
2010-10-25 17:21:20 +01:00
Chris Lord
35c35de55c state: Handle setting keys for the current target state
Add special behaviour when you set the key of the current target state:
- If the state is transitioning, add/modify the interval so that the new
  key transitions from the current time (taking into account pre-delay) to
  its target final property
- If the state is set but has already finished animating/was warped to,
  set the property immediately
2010-10-25 17:21:20 +01:00
Chris Lord
73dcbedc80 state: Fix crasher when removing the last key of a transitioning state
If ClutterState is in the middle of a transition and you remove all the
keys from the target state, the target state will be destroyed without
stopping the animation/unsetting the target state. This caused an invalid
memory access.
2010-10-25 17:21:20 +01:00
Chris Lord
5700b34b9c state: Allow setting a NULL state
Allow setting a %NULL state. This has the effect of unsetting the current
state and stopping all animation. This allows you to, for example, start
a state transition, set the state to NULL, alter the state transition
and then resume it again, by just setting it.
2010-10-25 17:21:20 +01:00
Emmanuele Bassi
ef6b46d826 Merge branch 'wip/path-constraint'
* wip/path-constraint:
  docs: Add PathConstraint
  tests: Add a PathConstraint interactive test
  Add ClutterPathConstraint
  actor-box: Add setters for origin and size
2010-10-25 17:09:46 +01:00
Emmanuele Bassi
f6ab7eccd9 docs: Add PathConstraint 2010-10-25 16:09:40 +01:00
Emmanuele Bassi
6b2cbb9908 Add ClutterPathConstraint
ClutterPathConstraint is a simple Constraint implementation that
modifies the allocation of the Actor to which is has been applied using
a progress value and a ClutterPath.
2010-10-25 15:46:04 +01:00
Emmanuele Bassi
3f6ec0ba5a actor-box: Add setters for origin and size 2010-10-25 15:45:35 +01:00
Neil Roberts
6da18b6e4f win32: Fix clutter_win32_disable_event_retrieval
There was previously a flag that gets set when this function was
called but nothing checked it so the function effectively did
nothing. Also the flag was a member of the backend struct but this
can't be used because the function should be called before
clutter_init so the backend is not ready yet. This patch makes the
event disabling work more like the X11 backend and set a global
variable instead.
2010-10-25 13:19:18 +01:00
Ole André Vadla Ravnås
e6099cdd4b win32: Use _clutter_actor_rerealize() like X11 backend does
http://bugzilla.clutter-project.org/show_bug.cgi?id=1654
2010-10-25 13:19:18 +01:00
Neil Roberts
e66c679e84 win32: Add a public clutter_win32_handle_event function
This function handles a single windows message. The idea is that it
could be used by clutter-gtk to forward on events from a
GdkEventFilter. The function replaces the old message_translate()
function. That function didn't translate the event anymore anyway and
instead it could generate multiple events so
clutter_win32_handle_event seems like a more appropriate name. The
function returns TRUE or FALSE depending on whether the event was
completely handled instead of setting call_window_proc.
2010-10-25 13:19:17 +01:00
Neil Roberts
52744c0d9d clutter-stage: Set the Cogl framebuffer size after allocating
When handling an allocation on the stage, Clutter uses the oppurtunity
to inform Cogl of the new size of the framebuffer so that it can
handle the viewport correctly. It queries the size of the window
implementation using a backend virtual function. However it was doing
this before letting the backend handle the allocation so on Win32 it
would end up using the previous framebuffer size. This wasn't
affecting the X11 backend because in that case the resizes are
asynchronous so setting the stage size causes one allocation which
ends up sending a window size request. Eventually a ConfigureNotify is
received which causes the size of the stage to be set again and
another allocation is fired meaning the framebuffer size will be set
again this time with the correct size. In Win32 the resizes are
synchronous so we don't have this second allocation.
2010-10-25 13:19:17 +01:00
Neil Roberts
cc7977988c cogl-context-winsys: Avoid zero-length arrays
When compiling for non-glx platforms the winsys feature data array
ends up empty. Empty arrays cause problems for MSVC so this patch adds
a stub entry so that the array always has at least one entry.

Based on a patch by Ole André Vadla Ravnås
2010-10-25 13:18:25 +01:00
Neil Roberts
f1752ff3ba Avoid mixing declarations and code
Mixing declarations and code causes problems for MSVC as it is a C99
feature so we should try to avoid it.
2010-10-25 13:18:25 +01:00
Neil Roberts
8e3674dcc1 Avoid variable length arrays in clutter-backend-x11
There was an array whose length was define by a static const int
variable. GCC seems to consider this a variable-length array so it
will cause warnings now that -Wvla is enabled. We might as well make
this constant a #define instead to avoid the warning.
2010-10-25 13:18:25 +01:00
Giovanni Campagna
164af55a6e Avoid warnings on ClutterClone with a NULL source
clutter_clone_apply_transform should check the source before calling
methods on it, else criticals will be emitted.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2381
2010-10-25 12:36:00 +01:00
Ole André Vadla Ravnås
276acf5854 binding-pool: Use the correct marshaller 2010-10-25 00:39:13 +01:00
Ole André Vadla Ravnås
c792431538 interval: Remember to chain up to parent in finalize() 2010-10-25 00:31:36 +01:00
Neil Roberts
d5634e37a2 cogl-texture-2d-sliced: Use the other backends for the slices
Instead of directly manipulating GL textures itself,
CoglTexture2DSliced now works in terms of CoglHandles. It creates the
texture slices using cogl_texture_new_with_size which should always
end up creating a CoglTexture2D because the size should fit. This
allows us to avoid replicating some code such as the first pixel
mipmap tracking and it better enforces the separation that each
texture backend is the only place that contains code dealing with each
texture target.
2010-10-22 12:19:04 +01:00
Neil Roberts
61f2f1c024 Support foreign textures in the texture-2d and rectangle backends
This adds two new internal functions to create a foreign texture for
the texture 2d and rectangle backends. cogl_texture_new_from_foreign
will now use one of these backends directly if there is no waste
instead of always using the sliced texture backend.
2010-10-22 12:19:02 +01:00
Emmanuele Bassi
cf46c8197e Add copyright notices 2010-10-21 13:13:00 +01:00
Emmanuele Bassi
46c597a1f6 Clean up clutter-private.h/6
Move all Actor private API to a separate file.
2010-10-21 12:22:17 +01:00
Emmanuele Bassi
cf3a29f224 Clean up clutter-private.h/5
Move PaintVolume private API to a separate header.
2010-10-21 12:22:17 +01:00
Emmanuele Bassi
43edfc9400 Clean up clutter-private.h/4
Move the private Backend API to a separate header.

This also allows us to finally move the class vtable and instance
structure to a separate file and plug the visibility hole that left
the Backend class bare for everyone to poke into.
2010-10-21 12:22:17 +01:00
Emmanuele Bassi
8613013ab0 Clean up clutter-private.h/3
Move Stage private API to a separate header.
2010-10-21 11:33:26 +01:00
Emmanuele Bassi
999c063784 Clean up clutter-private.h/2
Move StageManager private API to a different header.
2010-10-21 11:30:19 +01:00
Emmanuele Bassi
c1771d152e Clean up clutter-private.h/1
Move DeviceManager/InputDevice private API to a different header.
2010-10-21 10:54:14 +01:00
Emmanuele Bassi
68156c24c1 build: Remove unused Makefile.am
We switched to a non-recursive layout, hence we don't need Makefile.am
in the osx/ and fruity/ sub-directories.
2010-10-19 17:48:15 +01:00
Emmanuele Bassi
dd2f55c6f6 x11: Protect XComposite API calls
Since we allow compiling Clutter without the XComposite extension
available, we need to protect the calls to the XComposite API with
the guards provided by the configure script.
2010-10-19 10:43:50 +01:00
Emmanuele Bassi
21eb49098a script: Fix the memory management
Currently, the memory management in ClutterScript is overly complicated.
The basic design tenet should be:

  - ClutterScript owns a reference on every object it creates

This allows the Script instance to reliably handle the lifetime of the
instances from creation to disposal.

In case of unmerge, the Script instance should destroy any Actor
instance, except for the Stage, and release the reference it owns. The
Stage is special because it's really owned by Clutter itself, and it
should be destroyed explicitly.

When disposing the Script itself, it should just release the reference;
any parented actor, or any InitiallyUnowned instance, will then be
managed by the parent object, as they should, while every GObject
instance will go away, as documented.

This commit is based on a patch by:

  Henrik Hedberg <hhedberg@innologies.fi>

http://bugzilla.clutter-project.org/show_bug.cgi?id=2316
2010-10-19 01:42:19 +01:00
Emmanuele Bassi
20a359cc53 debug: Do not use '&' in the messages
Use ':' as a separator between G_STRLOC and the debug message, like we
do for warnings.
2010-10-19 01:42:19 +01:00
Emmanuele Bassi
78d4073f8e Remove unused variables 2010-10-19 01:42:19 +01:00
Damien Lespiau
32270730bd build: Fix EGL/CEX100 build with GLES2
Some headers files have been renamed or removed and the gles(2) did not
compile anymore, fix that.
2010-10-18 16:08:47 +01:00
Emmanuele Bassi
0f613ea134 cairo-texture: Allow overriding the surface creation
By using a new signal, ::create-surface (width, height), it should be
possible for third party code and sub-classes to override the default
surface creation code in CairoSurface.

This commit takes a bit of the patch from:

  http://bugzilla.clutter-project.org/show_bug.cgi?id=1878

which cleans up CairoTexture; the idea, mutuated from that bug, is that
the CairoTexture actor checks whether the surface it has it's an image
one, and in that case it uses a Cogl texture as the backing store. In
case the surface is not an image one we assume that the surface itself
has some way of updating the GL state and flush the surface.
2010-10-18 11:26:45 +01:00
Emmanuele Bassi
050e775da2 Move more classes to install_properties() 2010-10-18 11:26:45 +01:00
Emmanuele Bassi
8429aa8d75 Remove unnecessary GLib version checks
We now depend on a newer version of GLib than those checks tested for.
2010-10-18 11:26:45 +01:00
Emmanuele Bassi
7dd09e2186 Use G_DEFINE_BOXED_TYPE for all boxed types
We actually need a couple more macros for registering GValue
transformation functions. Those should be added to upstream
GLib.
2010-10-18 11:26:45 +01:00
Emmanuele Bassi
09a830d294 Remove conditional wrappers for property installation/notification
For the time being, just keep the #define's.
2010-10-18 11:26:45 +01:00
Emmanuele Bassi
9caf11f2d8 Use G_DEFINE_INTERFACE
GObject provides us with a nice, safe macro for defining interface
types.
2010-10-18 11:26:44 +01:00
Emmanuele Bassi
2b4ee9ab54 actor: Add more checks to the redraw queue 2010-10-15 16:05:44 +01:00
Emmanuele Bassi
56c89bd86b osx: Fix glib.h include path
The fix for removing glib/gmain.h introduced the wrong path for glib.h.
2010-10-15 12:40:43 +01:00
Roland Peffer
d842619755 osx: Add button mask to the modifier state translation
The modifier state translation is missing the CLUTTER_BUTTON*_MASK.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2365

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-10-14 18:23:02 +01:00
Kristian Høgsberg
134ce072e7 The amazing lazy-copy-back-repaint-page-flip
Always use pageflipping, but avoid full repaint by copying back dirty
regions from front to back.  Additionally, we dealy copying back until
we're ready to paint the new frame, so we can avoid copying areas that
will be repainted anyway.

This is the least amount of copying per frame we can get away with at all
and at the same time we don't have to worry about stalling the GPU on
synchronized blits since we always pageflip.
2010-10-14 16:23:05 +01:00
Kristian Høgsberg
cb5582c4ab Add wayland backend
This adds a clutter backend for running under the wayland window system.
Initial cogl framebuffer integration by Robert Bragg.
2010-10-14 16:23:05 +01:00
Kristian Høgsberg
a7cf98ebfc Initialize color masks lazily
When we don't use a window system drawable, we can't query the color
masks at context initialization time.  Do it lazily so we're sure to have
a current context with a valid framebuffer.
2010-10-14 16:23:05 +01:00
Robert Bragg
f456116c18 When unparenting an actor, remove queued redraws for all descendants
We need to make sure that redraws queued for actors on a stage are for
actors actually in the stage. So in clutter_actor_unparent() descend
through the children and remove redraws. Just removing the actor itself
isn't good enough since an entire hierarchy can be removed from the
stage without breaking it up into individual actors.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2359

This is based on an original patch from Owen Taylor who debugged the
root cause of this bug; thanks.
2010-10-14 16:19:55 +01:00
Robert Bragg
07f2dba7e2 stage: handle unclipped redraw following clipped
In the case that an unclipped redraw of an actor is queued after a
clipped we should update any existing ClutterStageQueueRedrawEntry
so entry->has_clip = FALSE and free the previous clip.
2010-10-14 15:29:33 +01:00
Emmanuele Bassi
e6418a9dec constraints: Remove unused variable 2010-10-12 15:44:57 +01:00
Emmanuele Bassi
4e724aed46 bind-constraint: Use ::queue-relayout
Instead of using the allocation-changed signal, use the queue-relayout
signal on the source to queue a relayout on the actor to which the
BindConstraint has been attached to.

The ::allocation-changed signal is not always enough, given that a
BindConstraint can use the position as well as the size of an actor to
drive the allocation of another; in this regard, it's much similar
to a ClutterClone, which requires a notification on every change, even
potential, and not just real ones, given the short-circuiting done
inside ClutterActor.
2010-10-12 14:09:47 +01:00
Emmanuele Bassi
5c82b2551c constraints: Do not check for :enabled
ClutterActor will do it for us.
2010-10-12 14:09:17 +01:00
Emmanuele Bassi
3f27afde24 actor: Use an explicit check for NULL
Follow the coding style, and don't use the implicit C boolean
equivalence for NULL pointers.
2010-10-12 14:08:07 +01:00
Emmanuele Bassi
3b72fdb20c actor: Queue a relayout when adding/removing constraints
Constraints change the way an actor is allocated; this warrants a
relayout.
2010-10-12 14:07:27 +01:00
Emmanuele Bassi
91a9a355c3 actor: Check CluterActorMeta:enabled
Instead of delegating the check for the ActorMeta:enabled property to
the sub-classes of ClutterActorMeta, ClutterActor can do the check prior
to using the ClutterActorMeta instances.
2010-10-12 14:07:17 +01:00
Emmanuele Bassi
3f6b82c9c9 actor: Add debugging note for allocation changes 2010-10-12 14:04:05 +01:00
Emmanuele Bassi
89a389cd2b actor-box: Split out ActorBox into its own file
clutter-actor.c is getting way too large, so splitting it up wherever
possible makes sense.
2010-10-11 15:57:22 +01:00
Emmanuele Bassi
7a54bdc65d vertex: Register progress function
This allows animating properties storing a ClutterVertex.
2010-10-11 15:52:50 +01:00
Emmanuele Bassi
4931802fee geometry: Register a progress function
This allows animating properties storing a ClutterGeometry.
2010-10-11 15:44:09 +01:00
Emmanuele Bassi
a5fc90d4d9 actor-box: Register a progress function
So that we can animate properties storing ClutterActorBox.
2010-10-11 15:39:19 +01:00
Emmanuele Bassi
2f21c851ea script: Fix annotation for get_object()'s return value 2010-10-11 15:39:19 +01:00
Emmanuele Bassi
dcf2662616 interval: Remove special casing for ClutterColor
ClutterColor registers a progress function on type initialization, so we
don't need to special case it any more.
2010-10-11 15:39:19 +01:00
Emmanuele Bassi
d5376bf317 color: Add Color.interpolate() method
The interpolate() method does what it says on the tin: it interpolates
between two colors using the given factor.

ClutterColor uses it to register a progress function for Intervals.
2010-10-11 15:39:19 +01:00
Neil Roberts
7e112472b5 cogl-texture-2d-sliced: Use the smallest possible waste
When picking a size for the last slice in a texture, Cogl would always
pick the biggest power of two size that doesn't create too much
waste and is less than or equal to the previous slice size. However
this can end up creating a texture that is bigger than needed if there
is a smaller power of two.

For example, if the maximum waste is 127 (the current default) and we
try to create a texture that is 257 pixels wide it will decide that
the next power of two (512) is too much waste (255) so it will create
the first slice at 256 pixels wide. Then we only have 1 pixel left to
allocate but Cogl would pick the next smaller size that has a small
enough waste which is 128. But of course 1 is already a power of two
so that's redundantly oversized by 127.

This patch fixes it so that whenever it finds a size that would be big
enough, instead of using exactly that it picks the next power of two
up from the size we need to fill.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2355
2010-10-11 14:40:04 +01:00
Emmanuele Bassi
1f106b35a9 Whitespace alignment fixes 2010-10-11 13:52:09 +01:00
Emmanuele Bassi
68d656c61b paint-volume: Add arguments checks
In some cases we access the arguments in public functions without, or
prior to checking the arguments.
2010-10-11 13:51:12 +01:00
Owen W. Taylor
8089af3c1b ClutterClone: Handle clone_source == NULL for get_paint_volume()
It's valid to have a ClutterClone without a clone source; in this
case the paint volume is empty.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2360
2010-10-11 13:43:39 +01:00
Emmanuele Bassi
e005892534 clone: Remove unnecessary G_UNLIKELY macros
A Clone:source property might be NULL, and we should not penalize
performance when we can just bail out early, because that would kind of
defeat the point.
2010-10-11 13:32:26 +01:00
Emmanuele Bassi
f8af2da4c8 osx: Compilation fixes
Replace deprecated symbols with the correct ones.
2010-10-10 09:31:55 +01:00
Emmanuele Bassi
981fed1f63 box-layout: Plug a memory leak
Similar to commit 4724be167f for
TableLayout.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2358
2010-10-08 13:29:49 +01:00
Neil Roberts
4724be167f Plug a memory leak in clutter-table-layout
Whenever the allocation is changed on a child of a ClutterTableLayout
and animations are not in effect then it would store a copy of the
allocation in the child meta data. However it was not freeing the old
copy of the allocation so it would end up with a small leak.

Instead of just changing it to free the old value this patch makes it
store the allocation inline in the meta data struct because it seems
that the size of an actor box is already quite small compared to the
size of the meta data struct so it is probably not worth having a
separate allocation for it. To detect the case when there has not yet
been an allocation a separate boolean is used instead of storing NULL.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2358
2010-10-08 12:11:39 +01:00
Damien Lespiau
155bde2465 texture: Fix the typos in the blurbs and make them not end with '.'
All the nifty things you discover when translating strings not exposed
to anyone. First the clutter-wide record of the number of typos in one
string. Second, ClutterTexture happened to have the only property blurbs
ending with a '.', remove them.
2010-10-05 08:39:40 +01:00
Damien Lespiau
2d56ed637c text: Rename the nick of the position property "Cursor Position"
the "position" property of ClutterText is really the position of the
cursor. Rename the nick accordingly not to confuse it with the position
of the actor itself and be consistent with all the other cursor-related
properties.
2010-10-05 08:25:06 +01:00
Damien Lespiau
a13182c740 cogl: Use Cogl (not COGL) consistently
If I remember correctly, Robert wants to name Cogl, Cogl (not COGL) so
start by having a consistent naming in the code.
2010-10-05 08:03:19 +01:00
Damien Lespiau
24577a0538 bin-layer: Fix the property blurbs
The descriptions for the 'y-align' and 'x-align' properties talk about a
layer and a layer manager. It seems that these properties are the
alignement factors relative to the BinLayout, so document them
accordingly.
2010-10-05 07:50:52 +01:00
Damien Lespiau
9ae1729f37 box-layout: Fix missing spaces in the blurbs of vertical and homogeneous 2010-10-04 18:52:57 +01:00
Damien Lespiau
9258f9bebb deform-effect: Fix Horiontal/Horizontal typo 2010-10-04 17:21:15 +01:00
Emmanuele Bassi
6af0ee2cbe cogl-x11: Trap glXDestroyPixmap()
There are ordering issues in the pixmap destruction with current and
past X11 server, Mesa and dri2. Under some circumstances, an X pixmap
might be destroyed with the GLX pixmap still referencing it, and thus
the X server will decide to destroy the GLX pixmap as well; then, when
Cogl tries to destroy the GLX pixmap, it gets BadDrawable errors.

Clutter 1.2 used to trap + sync all calls to glXDestroyPixmap(), but
then we assumed that the ordering issue had been solved. So, we're back
to square 1.

I left a Big Fat Comment™ right above the glXDestroyPixmap() call
referencing the bug and the reasoning behind the trap, so that we don't
go and remove it in the future without checking that the issue has been
in fact solved.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2324
2010-10-04 14:26:23 +01:00
Alejandro Piñeiro
f5aeabadd5 Fixing cally.pc.in and moving include headers to previous directory
After commit 8dd8fbdb some errors appear if you try work directly
against cally:

 * cally.pc.in removed some elements. After install clutter, doing
   pkg-config --cflags cally-1.0
   fails due missing winsys

 * cally headers were moved from clutter-1.0/cally to
   clutter-1.0/clutter/cally.  Applications using it (yes I know,
   nobody is officially using it) would require to:
    * Change their include.
    * Add directly a dependency to cally, in order to use the cally.pc
      file with the correct directory include.

Note: Take into account that accessibility support still works (ie:
clutter_get_accessibility_enabled). This bug only prevents
applications to work directly against cally (ie: create a CallyActor
subclass)

http://bugzilla.clutter-project.org/show_bug.cgi?id=2353

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-10-04 13:05:02 +01:00
Emmanuele Bassi
d3b6dd5ec7 effect: Fix up the class ABI
Landing the paint-box branch accidentally added two slots to the
ClutterEffectClass vtable, plus the get_paint_volume() function
pointer. This is an ABI break from 1.4.
2010-10-04 11:30:32 +01:00
Emmanuele Bassi
e1a1050a39 actor-box: Constify arguments for union
The input arguments for clutter_actor_box_union() should be constified,
since they will not be modified by the function.
2010-10-04 11:27:16 +01:00
Emmanuele Bassi
45b6d7d47a docs: Fix the annotations of ActorClass 2010-10-04 11:26:46 +01:00
Emmanuele Bassi
bdb24701f0 build: Add -xobjective-c to the fruity backend section
Like we do for the Quartz backend, we should turn on the -xobjective-c
compiler flag for the Fruity backend.

This does not mean that the backend actually works.
2010-10-04 10:52:36 +01:00
Emmanuele Bassi
0cf2f50ba6 build: Remove redundant EXTRA_DISTs
The files for the backend that we conditionally compile are
automatically added to the dist process by automake.
2010-10-04 09:09:13 +01:00
Emmanuele Bassi
a29623e838 build: Unconditionally add GLES2 shaders to EXTRA_DIST 2010-10-04 08:57:29 +01:00
Emmanuele Bassi
939333b4f2 build: Dist every backend file
All backend files should be present in the tarball generated by `make
dist`, to allow building Clutter on different platforms.
2010-10-03 16:10:44 +01:00
Emmanuele Bassi
6df136ae7c container: Do not emit a signal in the class handler
Yes, I am that stupid.
2010-10-03 15:28:14 +01:00
Emmanuele Bassi
e8d3ab4fd3 introspection: Skip Script.connect_signals_full()
It's meant to be used by language bindings, not by applications.
2010-10-03 15:16:41 +01:00
Emmanuele Bassi
19b93a94ae container: Fix the marshaller for ::child-notify
The marshaller was defined as OBJECT,OBJECT,PARAM but the signal
definition used only two arguments. Since the signal never worked
and we never got any report about it, nobody could be possibly
using the ::child-notify signal.
2010-10-03 15:12:01 +01:00
Emmanuele Bassi
7ac84cf7a3 container: Add child_notify() wrapper
The child_notify() virtual function on ClutterContainer does not have a
wrapper for implementations to call.
2010-09-30 14:58:23 +01:00
Emmanuele Bassi
fc344fb93a container: Implement ::child-notify
Since we added child properties to the Container interface we made a
guarantee that the ::child-notify signal would be emitted whenever a
property was set using clutter_container_child_set*().

We were lying.

The child_notify virtual function was not implemented, and the signal
was never emitted.

We also used a G_LIKELY() macro while checking for non-NULL on a
function pointer that was by default set to NULL, thus making the
setting of child properties far less efficient than needed.
2010-09-30 13:11:05 +01:00
Emmanuele Bassi
18ff73c244 build: Add more metadata to the introspection files 2010-09-30 12:43:10 +01:00
Emmanuele Bassi
fde6efc690 build: Make Cally.gir depend on Cogl.gir
Since Cally's introspection data depends on it.
2010-09-30 12:31:28 +01:00
Colin Walters
077a5b4c34 introspection: Update to changed variables for header file names
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-09-30 12:10:02 +01:00
Ray Strode
32d647ddd1 actor: sync entry has_clip member to clip state
The clutter stage has a list of entries of actors waiting to be redrawn.
Each entry has a "clip" ClutterPaintVolume member which represents which
how much of the actor needs to get redrawn.  It's possible for there to
be no clip associated with the entry.  In this case, the clip member is
invalid, the has_clip member should be set to false.

This commit fixes a bug where the has_clip member was not being
initially, explicitly set to false for new entries, and not being
explicitly set to false in the event the clip associated with the entry
is freed.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2350

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2010-09-30 11:54:07 +01:00
Robert Bragg
fba6335291 actor: don't ignore clip for clipped redraws
In all the changes made recently to how we handle redraws and adding
support for paint-volumes we stopped looking at explicit clip regions
passed to _clutter_actor_queue_redraw_with_clip.

In _clutter_actor_finish_queue_redraw we had started always trying to
clip the redraw to the paint-volume of the actor, but forgot to consider
that the user may have already determined the clip region for us!

Now we first check if the given clip != NUll and if so we don't need to
calculate the paint-volume of the actor.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2349
2010-09-30 11:44:12 +01:00
Robert Bragg
18e3273fb1 x11-tfp: Implement get_paint_volume virtual
One of the later changes made on the paint volume branch before merging
with master was to make paint volumes opt in only since we couldn't make
any safe assumptions about how custom actors may constrain their
painting. We added very conservative implementations for the existing
Clutter actors - including for ClutterTexture which
ClutterX11TexturePixmap is a sub-class of - but we were conservative to
the extent of explicitly checking the GType of the actor so we would
avoid making any assumptions about sub-classes. The upshot was that we
neglected to implement the get_paint_volume vfunc for
ClutterX11TexturePixmap.

This patch provides an implementation that simply reports the actor's
allocation as its paint volume. Also unlike for other core actors it
doesn't explicitly check the GType so we are assuming that all existing
sub-classes of ClutterX11TexturePixmap constrain their drawing to the
actor's transformed allocation. If anyone does want to draw outside the
allocation in future sub-classes, then they should also provide an
updated get_paint_volume implementation.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2349
2010-09-30 11:44:12 +01:00
Robert Bragg
83eb5ab88c material: tweak dot file debug code
When using the debug function _cogl_debug_dump_materials_dot_file to
write a dot file representing the sparse graph of material state we now
only show a link between materials and layers when the material directly
owns that layer reference (i.e. just those referenced in
material->layer_differences) This makes it possible to see when
ancestors of a material are being deferred too for layer state.

For example when looking at the graph if you see that a material has an
n_layers of 3 but there is only a link to 2 layers, then you know you
need to look at it's ancestors to find the last layer.
2010-09-30 11:44:12 +01:00
Neil Roberts
d8a9026b84 win32: Fix the CLUTTER_* keysym macros
In 4ee05f8e21 the namespace for the clutter keysym macros were
changed to CLUTTER_KEY_* but the win32 events backend was still
referring to the old names.
2010-09-30 10:59:40 +01:00
Emmanuele Bassi
f753b0c4a1 Wrap g_object_class_install_properties()
GObject ≥ 2.26.0 added a nice convenience call for installing properties
from an array of GParamSpec. Since we're already storing all GParamSpec
in an array in order to use them with g_object_notify_by_pspec(), this
turns out nicely for us.

Since we do not depend on GLib 2.26 (yet), we need to provide a simple
private wrapper that implements the fall back to the default
g_object_class_install_property() call.

ClutterDragAction has been converted as a proof of concept.
2010-09-30 10:33:24 +01:00
Emmanuele Bassi
f090c3ea49 stage: Add more checks on the stage window retrieval
During destruction, the StageWindow implementation associated to a Stage
might be NULL. We need to add more checks for a) the IN_DESTRUCTION flag
being set and b) the StageWindow pointer being NULL. Otherwise, we will
get warnings during the destruction of the Stage.
2010-09-30 10:27:10 +01:00
Neil Roberts
a278a1f940 cogl-texture-2d-sliced: Don't create the slice textures twice
Both of the cogl_texture_2d_sliced_new functions called the
slices_create function which creates the underlying GL
textures. However this was also called by init_base so the textures
would end up being created twice. This would make it leak the GL
textures and the arrays which point to them.
2010-09-29 16:14:34 +01:00
Emmanuele Bassi
66b0c1969c Remove the internal copy of JSON-GLib
The internal copy of JSON-GLib was meant to go away right after the 1.0
release, given that JSON-GLib was still young and relatively unknown.

Nowadays, many projects started depending on this little library, and
distributions ship it and keep it up to date.

Keeping a copy of JSON-GLib means keeping it up to date; unfortunately,
this would also imply updating the code not just for the API but for the
internal implementations.

Starting with the 1.2 release, Clutter preferably dependend on the
system copy; with the 1.4 release we stopped falling back automatically.
The 1.6 cycle finally removes the internal copy and requires a copy of
JSON-GLib installed on the target system in order to compile Clutter.
2010-09-29 15:57:28 +01:00
Emmanuele Bassi
e36cc40a49 Merge branch 'wip/non-recursive'
* wip/non-recursive:
  build: Start moving to a non-recursive layout
2010-09-29 15:55:58 +01:00
Robert Bragg
42f6364cac actor: don't dirty pick buffer in _real_queue_redraw
Since re-working how redraws are queued it is no longer necessary to
dirty the pick buffer in _clutter_actor_real_queue_redraw since this
should now reliably be handled in _clutter_stage_queue_actor_redraw.
2010-09-29 15:13:01 +01:00
Robert Bragg
51fca9d968 actor: Adds private _clutter_actor_traverse API
This adds two internal functions relating to explicit traversal of the
scenegraph:
_clutter_actor_foreach_child
_clutter_actor_traverse

_clutter_actor_foreach_child just iterates the immediate children of an
actor, and with a new ClutterForeachCallback type it allows the
callbacks to break iteration early.

_clutter_actor_traverse traverses the given actor and all of its
decendants. Again traversal can be stopped early if a callback returns
FALSE.

The first intended use for _clutter_actor_traverse is to maintain a
cache pointer to the stage for all actors. In this case we will need to
update the pointer for all descendants of an actor when an actor is
reparented in any way.
2010-09-29 15:13:01 +01:00
Robert Bragg
9a1abbc713 actor: Adds private _clutter_actor_get_n_children
This adds a private getter to query the number of children an actor has.
One use planned for this API is to avoid calling get_paint_volume on
such actors. (It's not clear what the best semantics for
get_paint_volume are for actors with children, so we are considering
leaving the semantics undefined for the initial clutter 1.4 release)
2010-09-29 15:13:01 +01:00
Robert Bragg
239d83f952 actor: explicitly track children in clutter-actor.c
We now explicitly track the list of children each actor has in a private
GList. This gives us a reliable way to know how many children an actor
has - even for composite actors that don't implement the container
interface. This also will allow us to directly traverse the scenegraph
in a more generalized fashion. Previously the scenegraph was
more-or-less represented implicitly according the implementation of
paint methods.
2010-09-29 15:13:01 +01:00
Robert Bragg
b3edd3e922 debug: fix blue outlines for paint-volumes debug opt
When using the CLUTTER_PAINT=paint-volumes debug option we try and show
when a paint volume couldn't be determined by drawing a blue outline of
the allocation instead. There was a typo though and instead we were
drawing an outline the size of the stage instead of for the given actor.
This fixes that and removes a FIXME comment relating to the blue outline
that is now implemented.
2010-09-29 15:13:00 +01:00
Robert Bragg
1a8d577168 clone: Implement get_paint_volume virtual
To allow Clutter to queue clipped redraws when a clone actor changes we
need to be able to report a paint volume for clone actors. This patch
makes ClutterClones query the paint volume of their source actor and
masquerade it as their own volume.
2010-09-29 15:13:00 +01:00
Robert Bragg
f6ba69f82d Revert "actor: don't immediately queue redraw when queuing relayout"
This reverts commit ca44c6a7d8abe9f2c548bee817559ea8adaa7a80.

In reality there are probably lots of actors that depend on the exact
semantics as they are documented so this change isn't really acceptable.
For example when the font changes in ClutterText we only queue a
relayout, and since it's possible that the font will have the same size
and the actor won't get a new allocation it wouldn't otherwise queue a
redraw.

Since queue_redraw requests now get deferred until just before a paint
run it is actually no longer a problem to queue the redraw here.
2010-09-29 15:13:00 +01:00
Robert Bragg
3b789490d2 actor: defer queue-redraw signaling
Instead of immediately, recursively emitting the "queue-redraw" signal
when clutter_actor_queue_redraw is called we now defer this process
until all stage updates are complete. This allows us to aggregate
repeated _queue_redraw requests for the same actor avoiding redundant
paint volume transformations. By deferring we also increase the
likelihood that the actor will have a valid paint volume since it will
have an up to date allocation; this in turn means we will more often be
able to automatically queue clipped redraws which can have a big impact
on performance.

Here's an outline of the actor queue redraw mechanism:

The process starts in clutter_actor_queue_redraw or
_clutter_actor_queue_redraw_with_clip.

These functions queue an entry in a list associated with the stage which
is a list of actors that queued a redraw while updating the timelines,
performing layouting and processing other mainloop sources before the
next paint starts.

We aim to minimize the processing done at this point because there is a
good chance other events will happen while updating the scenegraph that
would invalidate any expensive work we might otherwise try to do here.
For example we don't try and resolve the screen space bounding box of an
actor at this stage so as to minimize how much of the screen redraw
because it's possible something else will happen which will force a full
redraw anyway.

When all updates are complete and we come to paint the stage (see
_clutter_stage_do_update) then we iterate this list and actually emit
the "queue-redraw" signals for each of the listed actors which will
bubble up to the stage for each actor and at that point we will
transform the actors paint volume into screen coordinates to determine
the clip region for what needs to be redrawn in the next paint.

Note: actors are allowed to queue a redraw in reseponse to a
queue-redraw signal so we repeat the processing of the list until it
remains empty. An example of when this happens is for Clone actors or
clutter_texture_new_from_actor actors which need to queue a redraw if
their source queues a redraw.
2010-09-29 15:13:00 +01:00
Robert Bragg
7d8effd5e2 paint_volume: add private api to change reference actor
For Clone actors we will need a way to report the volume of the source
actor as the volume of the clone actor. To make this work though we need
to be able to replace the reference to the source actor with a reference
to the clone actor instead. This adds a private
_clutter_paint_volume_set_reference_actor function to do that.
2010-09-29 15:13:00 +01:00
Robert Bragg
2d895816be paint_volume: Adds _clutter_paint_volume_set_from_volume
This adds a way to initialize a paint volume from another source paint
volume. This lets us for instance pass the contents of one paint volume
back through the out param of a get_paint_volume implementation.
2010-09-29 15:13:00 +01:00
Robert Bragg
bfacca3011 actor: don't queue_redraw actors not descended from stage
This makes clutter_actor_queue_redraw simply bail out early if the actor
isn't a descendant of a ClutterStage since the request isn't meaningful
and it avoids a crash when trying to queue a clipped redraw against the
stage to clear the actors old location.
2010-09-29 15:13:00 +01:00
Emmanuele Bassi
b77d9a6d2c paint-volume: Add convenience function for using an allocation
Classes overriding ClutterActor::get_paint_volume() that wish to use
their allocation as the paint volume should have an idiomatic way of
doing so.
2010-09-29 15:13:00 +01:00
Emmanuele Bassi
5640a65046 text: Update get_paint_volume() implementation
In commit 9818eee4646e49e99beb5a43f1dafcbdcca41f94 I forgot to update
ClutterText as well as the other actors.
2010-09-29 15:13:00 +01:00
Emmanuele Bassi
16f7ee13f2 Move default paint volume computation into a function
This should reduce the amount of copy and paste for actor sub-classes
that use the default paint volume from the allocation.
2010-09-29 15:13:00 +01:00
Robert Bragg
fd41024d29 paint_volume: assert non-NULL pv in _volume_copy
Instead of carefully checking if the user passes NULL to
clutter_paint_volume_copy we now simply use g_return_val_if_fail.
2010-09-29 15:13:00 +01:00
Robert Bragg
3040b140bc paint_volume: Splits out clutter_paint_volume code
This splits out all the clutter_paint_volume code from clutter-actor.c
into clutter-paint-volume.c. Since clutter-actor.c and
clutter-paint-volume.c both needed the functionality of
_fully_transform_vertices, this function has now been moved to
clutter-utils.c as _clutter_util_fully_transform_vertices.
2010-09-29 15:13:00 +01:00
Robert Bragg
72eeb8e809 actor: make default get_paint_volume more conservative
There are too many examples where the default assumption that an actor
paints inside its allocation isn't true, so we now return FALSE in the
base implementation instead. This means that by default we are saying
"we don't know the paint volume of the actor", so developers need to
implement the get_paint_volume virtual to take advantage of culling and
clipped redraws with their actors.

This patch provides very conservative get_paint_volume implementations
for ClutterTexture, ClutterCairoTexture, ClutterRectangle and
ClutterText which all explicitly check the actor's object type to avoid
making any assumptions about subclasses.
2010-09-29 15:12:59 +01:00
Robert Bragg
d9a7f1b03b actor: don't always check needs_allocation for clipped redraw
We were always explicitly checking priv->needs_allocation in
_clutter_actor_queue_redraw_with_clip, but we only need to do that if
the CLUTTER_REDRAW_CLIPPED_TO_ALLOCATION flag is used.
2010-09-29 15:12:59 +01:00
Robert Bragg
072595a1bf actor: new actors should start with an empty paint box
This initializes priv->last_paint_box with a degenerate box, so a newly
allocated actor added to the scenegraph and made visible only needs to
trigger a redraw of its initial position. If we don't have a valid
last_paint_box though we would instead trigger a full stage redraw.
2010-09-29 15:12:59 +01:00
Robert Bragg
c2ea35b5ca actor: when culling/clipped redraws disable ignore paint box
To make comparing the performance with culling/clipped redraws
enabled/disabled fairer we now avoid querying the paint box when they
are disabled, so that results should reflect how the cost of
transforming paint volumes into screen space etc gets offset against the
benefit of culling.
2010-09-29 15:12:59 +01:00
Robert Bragg
5d1600d603 stage: only update viewport when allocation changes
In clutter_stage_allocate at the end we were always querying the latest
allocation set and using the geometry to assert the viewport and then
kicking a full redraw. These only need to be done when the allocation
really changes, so we now read the previous allocation at the start of
the function and compare at the end. This was stopping clipped redraws
from being used in a lot of cases.
2010-09-29 15:12:59 +01:00
Robert Bragg
1e7f22db3b glx: queue full redraws for the first 2 frames
To consider that we've see a number of drivers that can struggle to get
going and may produce a bad first frame we now force the first 2 frames
to be full redraws. This became a serious issue after we started using
clipped redraws more aggressively because we assumed that after the
first frame the full framebuffer was valid and we only redraw the
content that changes. With buggy drivers though, applications would be
left with junk covering a lot of the stage until some event triggered a
full redraw.
2010-09-29 15:12:59 +01:00
Robert Bragg
771348b369 x11: minimize nasty artefacts when resizing windows
This is a workaround for a race condition when resizing windows while
there are in-flight glXCopySubBuffer blits happening.

The problem stems from the fact that rectangles for the blits are
described relative to the bottom left of the window and because we can't
guarantee control over the X window gravity used when resizing so the
gravity is typically NorthWest not SouthWest.

This means if you grow a window vertically the server will make sure to
place the old contents of the window at the top-left/north-west of your
new larger window, but that may happen asynchronous to GLX preparing to
do a blit specified relative to the bottom-left/south-west of the window
(based on the old smaller window geometry).

When the GLX issued blit finally happens relative to the new bottom of
your window, the destination will have shifted relative to the top-left
where all the pixels you care about are so it will result in a nasty
artefact making resizing look very ugly!

We can't currently fix this completely, in-part because the window
manager tends to trample any gravity we might set.  This workaround
instead simply disables blits for a while if we are notified of any
resizes happening so if the user is resizing a window via the window
manager then they may see an artefact for one frame but then we will
fallback to redrawing the full stage until the cooling off period is
over.
2010-09-29 15:12:59 +01:00
Robert Bragg
012e4ab153 x11: Queue clipped redraws for Expose events
Instead of triggering a full stage redraw for Expose events we use the
geometry of the exposed region given in the event to queue a clipped
redraw of the stage.
2010-09-29 15:12:59 +01:00
Robert Bragg
105451d1be cogl: removes unused _cogl_setup_viewport
Clutter has now taken responsibility for managing its viewport,
projection matrix and view transform as part of ClutterStage so
_cogl_setup_viewport is no longer used by anything, and since it's quite
an obscure API anyway it's we've taken the opportunity to remove the
function.
2010-09-29 15:12:59 +01:00
Robert Bragg
95ff71d01c stage: Sometimes really force a full redraw
Since clutter_actor_queue_redraw now automatically clips redraws
according to the paint volume of the actor we have to be careful to
ensure we really force a full redraw when the stage is allocated a new
size or the stage viewport changes.
2010-09-29 15:12:59 +01:00
Robert Bragg
2235e70585 actor: don't immediately queue redraw when queuing relayout
We have bent the originally documented semantics a bit so now where we
say "Queueing a new layout automatically queues a redraw as well" it
might be clearer to say "Queuing a new layout implicitly queues a redraw
as well if anything in the layout changes".

This should be close enough to the original semantics to not cause any
problems.

Without this change then we we fail to take advantage of clipped redraws
in a lot of cases because queuing a redraw with priv->needs_allocation
== TRUE will automatically be promoted to a full stage redraw since it's
not possible to determine a valid paint-volume.

Also queuing a redraw here will end up registering a redundant clipped
redraw for the current location, doing quite a lot of redundant
transforms, and then later when re-allocated during layouting another
queue redraw would happen with the correct paint-volume.
2010-09-29 15:12:58 +01:00
Robert Bragg
b499696d83 Use paint volumes to do automatic culling
This uses actor paint volumes to perform culling during
clutter_actor_paint.

When performing a clipped redraw (because only a few localized actors
changed) then as we traverse the scenegraph painting the actors we can
now ignore actors that don't intersect the clip region. Early testing
shows this can have a big performance benefit; e.g. 100% fps improvement
for test-state with culling enabled and we hope that there are even much
more compelling examples than that in the real world,

Most Clutter applications are 2Dish interfaces and have quite a lot of
actors that get continuously painted when anything is animated. The
dynamic actors are often localized to an area of user focus though so
with culling we can completely avoid painting any of the static actors
outside the current clip region.

Obviously the cost of culling has to be offset against the cost of
painting to determine if it's a win, but our (limited) testing suggests
it should be a win for most applications.

Note: we hope we will be able to also bring another performance bump
from culling with another iteration - hopefully in the 1.6 cycle - to
avoid doing the culling in screen space and instead do it in the stage's
model space. This will hopefully let us minimize the cost of
transforming the actor volumes for culling.
2010-09-29 15:12:58 +01:00
Robert Bragg
ef8be9e25e actor: Use paint volumes to always queue clipped redraws
This makes clutter_actor_queue_redraw transparently use an actor's paint
volume to queue a clipped redraw.

We save the actors paint box each time it is painted so that when
clutter_actor_queue_redraw is called we can determine the old and new
location of the actor so we know the full bounds of what must be redrawn
to clear its old view and show the new.
2010-09-29 15:12:58 +01:00
Robert Bragg
13c4d7b95d actor: make _transform_and_project_box static
This makes _clutter_actor_transform_and_project_box a static function
and removes the prototype from clutter-private.h since it is no longer
used outside clutter-actor.c
2010-09-29 15:12:58 +01:00
Robert Bragg
120d7595e3 actor: _real_queue_relayout shouldn't queue redraw
The base implementation for the actor queue_relayout method was queuing
an implicit redraw, but there shouldn't be anything implied from the
mere process of queuing a redraw that should force us to queue a redraw.
If actors are moved as a part of relayouting later then they will queue
a redraw.  Also clutter_actor_queue_relayout() still also explicitly
queues a redraw so I think this may have been doubly redundant.
2010-09-29 15:12:58 +01:00
Robert Bragg
dc97692271 actor: re-allocation implies need to redraw
If clutter_actor_allocate finds it necessary to update an actors
allocation then it now also queue a redraw of that actor. Currently we
queue redraws for actors very early on when queuing a relayout instead
of waiting to determine the final outcome of relayouting to determine if
a redraw is really required. With this in place we can move away from
preemptive queuing of redraws.
2010-09-29 15:12:58 +01:00
Robert Bragg
267e458a43 actor: separate the queue redraw code
clutter_actor_queue_relayout currently queues a relayout and a redraw,
but the plan is to change it to only queue a relayout and honour the
documentation by assuming that the process of relayouting will
result queuing redraws for any actors whos allocation changes.

This doesn't make that change it just adds an internal
_clutter_actor_queue_only_relayout function which
clutter_actor_queue_relayout now uses as well as calling
clutter_actor_queue_redraw.
2010-09-29 15:12:58 +01:00
Robert Bragg
6d5f6449dd stage: make it possible to queue a relayout only
This adds a private ->relayout_pending boolean similar in spirit to
redraw_pending. This will allow us to queue a relayout without
implicitly queueing a redraw; instead we can depend on the actions
of a relayout to queue any necessary redraw.
2010-09-29 15:12:57 +01:00
Robert Bragg
f8a6e36f1b texture: Forward queue redraw/relayout for fbos
When clutter_texture_new_from_actor is use we need to track when the
source actor queues a redraw or a relayout so we can also queue a redraw
or relayout for the texture actor.
2010-09-29 15:12:57 +01:00
Robert Bragg
1ea7145efc Queue clipped redraws work in terms of paint volumes
There is an internal _clutter_actor_queue_redraw_with_clip API that gets
used for texture-from-pixmap to minimize what we redraw in response to
Damage events. It was previously working in terms of a ClutterActorBox
but it has now been changed so an actor can queue a redraw of volume
instead.

The plan is that clutter_actor_queue_redraw will start to transparently
use _clutter_actor_queue_redraw_with_clip when it can determine a paint
volume for the actor.
2010-09-29 15:12:57 +01:00
Robert Bragg
f3bffe5cab blur-effect: fix paint volume padding
For the blur effect we use a BLUR_PADDING constant to pad out the volume
of the source actor on the x and y axis. Previously we were offsetting
the origin negatively using BLUR_PADDING and then adding BLUR_PADDING
to the width and height, but we should have been adding 2*BLUR_PADDING
instead.
2010-09-29 15:12:57 +01:00
Robert Bragg
f60703cb1d debug: CLUTTER_DEBUG_REDRAWS: disable clipped redraws
This ensures that clipped redraws are disabled when using
CLUTTER_PAINT=redraws. This may seem unintuitive given that this option
is for debugging clipped redraws, but we can't draw an outline outside
the clip region and anything we draw inside the clip region is liable to
leave a trailing mess on the screen since it won't be cleared up by
later clipped redraws.
2010-09-29 15:12:57 +01:00
Robert Bragg
066220f983 paint volumes: CLUTTER_PAINT=paint-volumes debug option
This adds a debug option to visualize the paint volumes of all actors.
When CLUTTER_PAINT=paint-volumes is exported in the environment before
running a Clutter application then all actors will have their bounding
volume drawn in green with a label corresponding to the actors type.
2010-09-29 15:12:57 +01:00
Robert Bragg
3540d222e1 paint volumes: another pass at the design
This is a fairly extensive second pass at exposing paint volumes for
actors.

The API has changed to allow clutter_actor_get_paint_volume to fail
since there are times - such as when an actor isn't a descendent of the
stage - when the volume can't be determined. Another example is when
something has connected to the "paint" signal of the actor and we simply
have no way of knowing what might be drawn in that handler.

The API has also be changed to return a const ClutterPaintVolume pointer
(transfer none) so we can avoid having to dynamically allocate the
volumes in the most common/performance critical code paths. Profiling was
showing the slice allocation of volumes taking about 1% of an apps time,
for some fairly basic tests. Most volumes can now simply be allocated on
the stack; for clutter_actor_get_paint_volume we return a pointer to
&priv->paint_volume and if we need a more dynamic allocation there is
now a _clutter_stage_paint_volume_stack_allocate() mechanism which lets
us allocate data which expires at the start of the next frame.

The API has been extended to make it easier to implement
get_paint_volume for containers by using
clutter_actor_get_transformed_paint_volume and
clutter_paint_volume_union. The first allows you to query the paint
volume of a child but transformed into parent actor coordinates. The
second lets you combine volumes together so you can union all the
volumes for a container's children and report that as the container's
own volume.

The representation of paint volumes has been updated to consider that
2D actors are the most common.

The effect apis, clutter-texture and clutter-group have been update
accordingly.
2010-09-29 15:12:57 +01:00
Robert Bragg
48a24a2e08 actor-box: Adds clutter_actor_box_union utility
When using ClutterActorBoxs for representing clip regions it can be
convenient to be able to union multiple boxes together.
2010-09-29 15:12:57 +01:00
Robert Bragg
2da127dcff texture: size fbos using clutter_actor_get_paint_box
Previously we used the transformed allocation but that doesn't take
into account actors with depth which may be projected outside the
area covered by the transformed allocation.
2010-09-29 15:12:57 +01:00
Emmanuele Bassi
044809edb8 docs: Add PaintVolume to the API reference
And document the various related functions.
2010-09-29 15:12:57 +01:00
Emmanuele Bassi
a6e5ecebe3 blur-effect: Add padding to account for the blur
The blur effect will sample pixels on the edges of the offscreen buffer,
so we want to add a padding to avoid clamping the blur.

We do this by creating a larger target texture, and updating the paint
volume of the actor during paint to take that padding into account.
2010-09-29 15:12:57 +01:00
Emmanuele Bassi
5d97ca5f87 offscreen-effect: Use the paint box to size the FBO
We should be using the real, on-screen, transformed size of the actor to
size and position the offscreen buffer we use to paint the actor for an
effect.
2010-09-29 15:12:57 +01:00
Emmanuele Bassi
25abdf09b7 effect: Allow any effect to override the paint volume
An Effect implementation might override the paint volume of the actor to
which it is applied to. The get_paint_volume() virtual function should
be added to the Effect class vtable so that any effect can get the
current paint volume and update it.

The clutter_actor_get_paint_volume() function becomes context aware, and
does the right thing if called from within a ClutterEffect pre_paint()
or post_paint() implementation, by allowing all effects in the chain up
to the caller to modify the paint volume.
2010-09-29 15:12:56 +01:00
Emmanuele Bassi
94ce747f83 actor: Allow querying the paint volume
An actor has an implicit "paint volume", that is the volume in 3D space
occupied when painting itself.

The paint volume is defined as a cuboid with the origin placed at the
top-left corner of the actor; the size of the cuboid is given by three
vectors: width, height and depth.

ClutterActor provides API to convert the paint volume into a 2D box in
screen coordinates, to compute the on-screen area that an actor will
occupy when painted.

Actors can override the default implementation of the get_paint_volume()
virtual function to provide a different volume.
2010-09-29 15:12:56 +01:00
Emmanuele Bassi
8dd8fbdbdf build: Start moving to a non-recursive layout
*** WARNING: THIS COMMIT CHANGES THE BUILD ***

Do not recurse into the backend directories to build private, internal
libraries.

We only recurse from clutter/ into the cogl sub-directory; from there,
we don't recurse any further. All the backend-specific code in Cogl and
Clutter is compiled conditionally depending on the macros defined by the
configure script.

We still recurse from the top-level directory into doc, clutter and
tests, because gtk-doc and tests do not deal nicely with non-recursive
layouts.

This change makes Clutter compile slightly faster, and cleans up the
build system, especially when dealing with introspection data.

Ideally, we also want to make Cogl part of the top-level build, so that
we can finally drop the sed trick to change the shared library from the
GIR before compiling it.

Currently disabled:

  ‣ OSX backend
  ‣ Fruity backend

Currently enabled but untested:

  ‣ EGL backend
  ‣ Windows backend
2010-09-29 14:40:15 +01:00
Emmanuele Bassi
27aebb5c9d cally: Do not use deprecated functions
The function g_strcasecmp() has been deprecated since GLib 2.2.
2010-09-29 14:13:51 +01:00
Emmanuele Bassi
e798047ca0 animator: Code style fixes 2010-09-29 11:44:46 +01:00
Stephen Kennedy
3fe10e0bb1 ClutterAnimator doesn't ref timeline properly
ClutterAnimator currently has a number of bugs related to its
referencing of its internal timeline.

1) The default timeline created in _init is not unreffed (it appears the
programmer has wrongly thought ClutterTimeline has a floating reference
based on the use of g_object_ref_sink in _set_timeline)

2) The timeline and slave_timeline vars are unreffed in finalize instead
of dispose

3) The signal handlers set up in _set_timeline are not disconnected when
the animator is disposed

http://bugzilla.clutter-project.org/show_bug.cgi?id=2347

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-09-29 10:57:39 +01:00
Neil Roberts
3068520752 Simplify the loop for clutter_actor_contains
This reorganizes the loop for clutter_actor_contains so that it is a
for loop rather than a while loop. Although this is mostly just
nitpicking, I think this change could make the loop slightly faster if
not optimized because it doesn't perform the self == descendant check
twice and it is clearer.
2010-09-28 15:21:49 +01:00
Neil Roberts
99adb88e9b Document what happens when self==descendant in clutter_actor_contains
The documentation for clutter_actor_contains didn't specify what
happens when self==descendant. A strict reading of it might lead you
to think that it would return FALSE because in that case the
descendant isn't an immediate child or a deeper descendant. The code
actually would return TRUE. I think this is more useful so this patch
fixes the docs rather than the code.
2010-09-28 15:21:49 +01:00
Emmanuele Bassi
43e85836b4 actor: Dispose all constrains
We are leaking the ClutterMetaGroup with all the constraints when
disposing an Actor.
2010-09-26 16:52:58 +01:00
Emmanuele Bassi
fda1f3a8ba json: Allow NULL as a value for strings, arrays and objects
We should not warn when asking for a string, array or object if the
contents were 'null'.

Patch from JSON-GLib.
2010-09-25 20:23:41 +01:00
Øyvind Kolås
4640dad6af animator: fix removal of all keys
When removing all keys in a ClutterAnimator, the hash table with
object/property name pairs went out of sync. This change makes
the animator always clear this hash table upon key-removal; and
refreshing it if the animator's timeline is running.

Fixes bug #2335
2010-09-24 13:30:38 +01:00
Robert Bragg
f834b8b138 material: Don't prune ancestry if it owns some layers
Each time a material property changes we look to see if any of its
ancestry has become redundant and if so we prune that redundant
ancestry.

There was a problem with the logic that handles this though because we
weren't considering that a material which is a layer state authority may
still defer to ancestors to define the state of individual layers.

For example a material that derives from a parent with 5 layers can
become a STATE_LAYERS authority by simply changing it's ->n_layers count
to 4 and in that case it can still defer to its ancestors to define the
state of those 4 layers.

This patch checks first if a material is a layer state authority and if
so only tries to prune its ancestry if it also *owns* all the individual
layers it depends on. (I.e. if g_list_length
(material->layer_differences) != material->n_layers then it's not safe
to try pruning its ancestry!)

http://bugzilla-attachments.gnome.org/attachment.cgi?id=170907
2010-09-24 00:12:14 +01:00
Jammy Zhou
ffd5c32209 cogl-framebuffer.c: GL_DEPTH_STENCIL not supported in gles
There is GL_INVALID_ENUM error for GL_DEPTH_STENCIL when call
glRenderbufferStorage() with OpenGL ES backend. So enable this
only for OpenGL backend.

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2010-09-23 17:33:11 +01:00
Emmanuele Bassi
884ead03e1 Add some more argument validation
This is all internal, so we shouldn't need it; unfortunately, it seems
we're passing invalid data internally, so for the time being catching
inconsistencies should at least emit a warning for us to backtrace.
2010-09-23 16:17:24 +01:00
Robert Bragg
f66e1de0e3 actor: don't pass NULL to _stage_set_pick_buffer_valid
This adds a check in clutter_actor_real_queue_redraw after calling
_clutter_actor_get_stage_internal to check in case the actor doesn't yet
have an associated stage so we can avoid passing a NULL stage pointer to
_clutter_stage_set_pick_buffer_valid which could cause a crash.
2010-09-23 16:03:06 +01:00
Emmanuele Bassi
4c8867ea07 table-layout: Invert row/column in arguments
*** This is an API change ***

The general pattern for axis-aligned arguments is:

        x argument
        y argument

If we consider columns an x-aligned argument, and row a y-aligned
argument, then we need to update the TableLayout functions to be:

        column
        row

and not:

        row
        column
2010-09-23 15:17:58 +01:00
Robert Bragg
56929942a8 picking: Fix tracking of pick buffer validity
We have an optimization to track when there are multiple picks per
frame so we can do a full render of the pick buffer to reduce the
number of pick renders for a static scene.

There was a problem though in that we were tracking this information in
the ClutterMainContext, but conceptually this doesn't really make sense
because the pick buffer is associated with a stage framebuffer and there
can be multiple stages for one context.

This patch moves the state tracking to ClutterStage.
2010-09-23 11:45:27 +01:00
Robert Bragg
b2a56c9cda Revert "picking: Fix tracking of pick buffer validity"
This reverts commit d7e86e2696.

This was a half baked patch that was pushed a bit early since it broke
test-texture-pick-with-alpha + the commit message refers to a change on
the wip/paint-box branch that hasn't happened yet.
2010-09-23 11:45:04 +01:00
Robert Bragg
d7e86e2696 picking: Fix tracking of pick buffer validity
We have an optimization to track when there are multiple picks per
frames so we can do a full render of the pick buffer to reduce the
number of pick renders for a static scene.

There were two problems with how we were tracking this state though.
Firstly we were tracking this information in the ClutterMainContext, but
conceptually this doesn't really make sense because the pick buffer is
associated with a stage framebuffer and there can be multiple stages for
one context.  Secondly - since the change to how redraws are queued - we
weren't marking the pick buffer as invalid when a queuing a redraw, we
were only marking the buffer invalid when signaling/finishing the
queue-redraw process, which is now deferred until just before a paint.
This meant using clutter_stage_get_actor_at_pos after a scenegraph
change could give a wrong result if it just read from an existing (but
technically invalid) pick buffer.

This patch moves the state tracking to ClutterStage, and ensures the
buffer is invalidated in _clutter_stage_queue_actor_redraw.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2283

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-09-23 11:14:56 +01:00
Emmanuele Bassi
60c9dc25df box-layout: Small cleanups 2010-09-22 14:22:23 +01:00
Emmanuele Bassi
ddf1e4c77b effects: Make sure we're using GLSL 1.10 2010-09-21 13:32:31 +01:00
Emmanuele Bassi
9f2b62a595 introspection: Build ClutterJson before Clutter
Since the latter requires the former.
2010-09-21 13:17:51 +01:00
Neil Roberts
8f4d61e663 clutter-box-layout: Swap the default request mode
The request mode set by the box layout was previously width-for-height
in a vertical layout and height-for-width in a horizontal layout which
seems to be wrong. For example, if width-for-height is used in a
vertical layout then the width request will come second with the
for_height parameter set. However a vertical layout doesn't pass the
for_height parameter on to its children so doing the requests in that
order doesn't help. If the layout contains a ClutterText then both the
width and height request for it will have -1 for the for_width and
for_height parameters so the text would end up allocated too small.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2328
2010-09-20 16:33:57 +01:00
Emmanuele Bassi
af42cdbe87 docs: Description fixes for State.set_animator() 2010-09-20 14:31:53 +01:00
Bastian Winkler
695839c6f3 state: Request the animator for the default state
Try to use the default-state animator in case there is no animator for
this specific state change request.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2325
2010-09-20 14:25:21 +01:00
Bastian Winkler
172fc6bfed state: Fix the usage of ClutterAnimator in ClutterScript
Fix the transition parser to allow transitions that have only an
animator and no keys defined.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2325
2010-09-20 14:25:20 +01:00
Bastian Winkler
2d41d5afcb state: Create a new target state in clutter_state_set_animator
clutter_state_set_animator needs to create a new state in order to use a
ClutterAnimator with a target state that doesn't exist yet.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2325
2010-09-20 14:25:19 +01:00
Dominique Leuenberger
9399760030 build: Pass CLUTTER_CFLAGS to g-ir-scanner
http://bugzilla.clutter-project.org/show_bug.cgi?id=2327

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-09-20 14:17:14 +01:00
Emmanuele Bassi
ce174654bf docs: API reference fixes 2010-09-20 13:15:44 +01:00
Emmanuele Bassi
7fe0df393b texture: Add more validation on the material
If set_cogl_texture() is called after unsetting the Texture's material
then we really want to make a copy of the template.

Also, we should assert more often if the internal state goes horribly
wrong: at least, we'll have a backtrace.
2010-09-18 08:41:52 +01:00
Neil Roberts
66104f5112 Fix the ordering of the arguments for clutter_table_layout_set_span
The order of the row_span and column_span arguments was different in
the declaration from that in the definition. This was causing the
gtk-doc to also have the wrong order.
2010-09-17 17:22:17 +01:00
Neil Roberts
760fa8efd6 cogl-object-private.h: Include cogl-debug.h
If COGL_OBJECT_DEBUG is defined then cogl-object-private.h will call
COGL_NOTE in the ref and unref macros. For this to work the debug
header needs to also be included or COGL_NOTE won't necessarily be
defined.
2010-09-17 17:22:16 +01:00
Emmanuele Bassi
68da998c9b docs: Add sub-classing notes on ActorMeta and Constraint 2010-09-17 14:54:31 +01:00
Emmanuele Bassi
f7e8b47113 flow-layout: Blow the cached preferred size if needed
If the FlowLayout layout manager wasn't allocated the same size it
requested then it should blow its caches and recompute the layout
with the given allocation size.
2010-09-17 12:43:23 +01:00
Emmanuele Bassi
cdff2a9e7a constraint: Re-implement using update_allocation()
Instead of using the fixed position and size API, use the newly added
update_allocation() virtual function in ClutterConstraint to change the
allocation of a ClutterActor. This allows using constraints inside
layout managers, and also allows Constraints to react to changes in the
size of an actor without causing relayout cycles.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2319
2010-09-17 12:17:50 +01:00
Emmanuele Bassi
5da0064de7 constraint: Add ::update_allocation()
The Constraint should plug directly into the allocation mechanism, and
modify the allocation of the actor to which they are applied to. This is
similar to the mechanism used by the Effect class to modify the paint
sequence of an actor.
2010-09-17 12:17:50 +01:00
Robert Bragg
d1b4495f7f offscreen-effect: Update handling of transforms
In line with the changes made in f5f066df9c to clean up how Clutter
deals with transformations of actors this patch updates the code in
clutter-offscreen-effect.c. We now query the projection matrix from the
stage instead of the perspective and instead of duplicating the logic to
setup the stage view transform we now use
_clutter_actor_apply_modelview_transform for the stage instead.
2010-09-16 13:27:59 +01:00
Emmanuele Bassi
037a1b82cc build: Add cogl-debug-options.h 2010-09-15 16:12:56 +01:00
Emmanuele Bassi
7d2706e8ba docs: Fix the name of the parameters 2010-09-15 16:12:56 +01:00
Neil Roberts
7338541452 cogl: Make cogl_util_next_p2 internal and fix the documentation
cogl_util_next_p2 is declared in cogl-util.h which is a private header
so it shouldn't be possible for an application to use it. It's
probably not a function we'd like to export from Cogl so it seems
better to keep it private. This patch renames it to _cogl_util_next_p2
so that it won't be exported from the shared library.

The documentation for the function is also slightly wrong because it
stated that the function returned the next power greater than
'a'. However the code would actually return 'a' if it's already a
power of two. I think the actual behaviour is more useful so this
patch changes the documentation rather than the code.
2010-09-15 15:01:43 +01:00
Neil Roberts
42dacf97f8 cogl-vertex-buffer: Don't always set COGL_MATERIAL_FLUSH_FALLBACK_MASK
Previously CoglVertexBuffer would always set the flush options flags
to at least contain COGL_MATERIAL_FLUSH_FALLBACK_MASK. The code then
later checks whether any flags are set before deciding whether to copy
the material to implement the overrides. This means that it would
always end up copying the material even if there are no fallback
layers. This patch changes it so that it only sets
COGL_MATERIAL_FLUSH_FALLBACK_MASK if fallback_layers != 0.
2010-09-15 14:28:44 +01:00
Robert Bragg
8cfb158f63 material-arbfp: fix updating params if sharing progs
If a single arbfp program is being shared between multiple CoglMaterials
then we need to make sure we update all program.local params when
switching between materials. Previously we had a dirty flag to track
when combine_constant params were changed but didn't take in to account
that different materials sharing the same program may have different
combine constants.
2010-09-15 14:07:50 +01:00
Robert Bragg
d87522596d material-arbfp: Another pass at simplifying the code
Previously the backend private state was used to either link to an
authority material or provide authoritative program state. The mechanism
seemed overly complex and felt very fragile. I made a recent comment
which added a lot of documentation to make it easier to understand but
still it didn't feel very elegant.

This patch takes a slightly different approach; we now have a
ref-counted ArbfpProgramState object which encapsulates a single ARBfp
program and the backend private state now just has a single member which
is a pointer to one of these arbfp_program_state objects. We no longer
need to cache pointers to our arbfp-authority and so we can get rid of
a lot of awkward code that ensured these pointers were
updated/invalidated at the right times. The program state objects are
not tightly bound to a material so it will also allow us to later
implement a cache mechanism that lets us share state outside a materials
ancestry. This may help to optimize code not following the
recommendations of deriving materials from templates, avoiding one-shot
materials and not repeatedly modifying materials because even if a
material's ancestry doesn't naturally lead us to shareable state we can
fallback to searching for shareable state using central hash tables.
2010-09-15 14:07:50 +01:00
Robert Bragg
f6dc3ddcba material: Adds experimental cogl_material_foreach_layer API
This adds a way to iterate the layer indices of the given material since
cogl_material_get_layers has been deprecated. The user provides a
callback to be called once for each layer.

Because modification of layers in the callback may potentially
invalidate any number of the internal CoglMaterialLayer structures and
invalidate the material's layer cache this should be more robust than
cogl_material_get_layers() which used to return a const GList *
pointing directly to internal state.
2010-09-15 14:07:50 +01:00
Robert Bragg
d5eebedaa3 material: don't declare backend vtables in headers
This fixes the material backends to declare their constant vtable in the
c file with a corresponding extern declaration in the header. This
should fix complaints about duplicate symbols seen on OSX.
2010-09-15 14:07:50 +01:00
Robert Bragg
5583d9c12e material-arbfp: don't recompile for constant changes
Instead of lazily incorporating combine constants as arbfp PARAM
constants in the source directly we now use program.local parameters
instead so we can avoid repeating codegen if a material's combine
constant is updated. This should be a big win for applications animating
a constant used for example in an animated interpolation, such as
gnome-shell.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2280
2010-09-15 14:07:50 +01:00
Robert Bragg
2815cf4719 material-arbfp: don't redo codegen for texture changes
This makes it so we don't consider LAYER_STATE_TEXTURE changes to affect
the arbfp code. This should avoid a lot of unneeded passes of
code generation for applications modifying the texture for a layer.
2010-09-15 14:07:49 +01:00
Robert Bragg
3adeef6604 material: make layer/material_pre_changes mutually exclusive
This makes it so we only notify backends of either a single material
change or a single layer change. Previously all material STATE_LAYERS
changes would be followed by a more detailed layer change.

For backends that perform code generation for fragment processing they
typically need to understand the details of how layers get changed to
determine if they need to repeat codegen. It doesn't help them to report
a material STATE_LAYERS change for all layer changes since it's so
broad, they really need to wait for the layer change to be notified.

What does help though is to report a STATE_LAYERS change for a change in
material->n_layers because they typically do need to repeat codegen in
that case.
2010-09-15 14:07:49 +01:00
Robert Bragg
16e9794318 material-arbfp: fixes for how we track private state
This fixes a number of issues relating to how we track the arbfp private
state associated with CoglMaterials. At the same time it adds much more
extensive code documentation to try and make it a bit more approachable.
2010-09-15 14:07:49 +01:00
Robert Bragg
a114843f74 material: pass material owner for layer pre changes
When notifying a backend about a layer being modified we now pass the
layers current owner for reference. NB: Although a layer can indirectly
be referenced by multiple layers, a layer is considered immutable once
it has dependants, so there is only ever one material associated with a
layer being modified. Passing the material pointer to the backends
layer_pre_change callback can be useful for backends that associate
their private state with materials and may need to update that state in
response to layer changes.
2010-09-15 14:07:49 +01:00
Robert Bragg
d9a32f979c arbfp: rename get_arbfp_authority clarifying semantics
This renames the get_arbfp_authority function to
get_arbfp_authority_no_check to clarify that the function doesn't
validate that the authority cache is still valid by looking at the age
of the referenced material. The function should only be used when we
*know* the cache has already been checked.
2010-09-15 14:07:49 +01:00
Robert Bragg
ed1123a06b material: track if material change is layer change
We now pass a boolean to _cogl_material_pre_change_notify to know when
a material change is as a result of a layer change. We plan to use this
information to avoid notifying the backends about material changes if
they are as a result of layer changes. This will simplify the handling
of state changes in the backends because they can assume that layer and
material changes are mutually exclusive.
2010-09-15 14:07:49 +01:00
Robert Bragg
53acf4d1b0 material: Adds _get_layer_combine_constant API
This adds an internal _cogl_material_get_layer_combine_constant function
so we can query the current layer combine constant back. We should
probably make this a public property getter, but for now we just need
this so we can read the constant in the arbfp backend.
2010-09-15 14:07:49 +01:00
Robert Bragg
7f95015c6d material: track unit state with arbfp private state
We are going to start tracking more per-texture unit state with arbfp
private state so this adds an internal UnitState type and we allocate an
array of these when setting up a new private state structure. The first
thing that has been moved into this is the sampled boolean to know when
a particular texture unit gets sampled from in the generated arbfp code.
2010-09-15 14:07:49 +01:00
Emmanuele Bassi
98516061c3 Enumeration value should be on the same line
The glib-mkenums script is not clever enough to deal with

  FLAGS_VALUE = FLAGS_A |
                FLAGS_B

And since this breaks the enumeration GType and the introspection data,
we cannot really wait for it to be fixed.

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

http://bugzilla.clutter-project.org/show_bug.cgi?id=2238
2010-09-15 11:56:59 +01:00
Robert Bragg
d45c1671d1 cogl-framebuffer: fix leak when popping framebuffer
We were using g_slist_remove_link instead of g_slist_delete_link
resulting in a memory leak. Thanks to Simon Lanzmich for
reporting this bug.
2010-09-14 14:19:39 +01:00
Robert Bragg
88023d438d Initialize the cogl uprof state in cogl_create_context
This avoids the use of of gcc constructor and destructor attributes to
initialize the cogl uprof context and optionally print a cogl uprof
report at app exit. We now initialize the uprof context in
cogl_context_create instead.
2010-09-14 12:43:17 +01:00
Robert Bragg
d9ee3be835 journal: provide more detailed uprof instrumentation
This adds more timing around key stages of the journal flushing process.
2010-09-14 12:43:17 +01:00
Robert Bragg
fb7bf9ce02 profile: Update to uprof-0.3 dep for --enable-profile
When building with --enable-profile we now depend on the uprof-0.3
developer release which brings a few improvements:

» It lets us "fix" how we initialize uprof so that instead of using a shared
object constructor/destructor (which was a hack used when first adding
uprof support to Clutter) we can now initialize as part of clutter's
normal initialization code. As a side note though, I found that the way
Clutter initializes has some quite serious problems whenever it
involves GOptionGroups. It is not able to guarantee the initialization
of dependencies like uprof and Cogl. For this reason we still use the
contructor/destructor approach to initialize uprof in Cogl.

» uprof-0.3 provides a better API for adding custom columns when reporting
timer and counter statistics which lets us remove quite a lot of manual
report generation code in clutter-profile.c.

» uprof-0.3 provides a shared context for tracking mainloop timer
statistics. This means any mainloop based library following the same
"Mainloop" timer naming convention can use the shared context and no
matter who ends up owning the final mainloop the statistics will always
be in the same place. This allows profiling of Clutter with an
external mainloop such as with the Mutter compositor.

» uprof-0.3 can export statistics over dbus and comes with an ncurses
based ui to vizualize timer and counter stats live.

The latest version of uprof can be cloned from:
git://github.com/rib/UProf.git
2010-09-14 12:43:16 +01:00
Neil Roberts
a45f67bbdc cogl-framebuffer: Clear the renderbuffer list on failure
When try_creating_fbo fails it deletes any intermediate render buffers
that were created. However it doesn't clear the list so I think if it
failed a second time it would try to delete the render buffers
again. This could potentially cause problems if a subsequent fbo is
created because the destructor for the original might delete the
renderbuffers of the new fbo.
2010-09-13 18:54:02 +01:00
Robert Bragg
570fa3f044 clone: scale src with apply_transform not cogl_scale
Since a ClutterClone may be allocated a different size than its source
actor we need to apply a scale factor before painting the source actor.
We were manually using cogl_scale to do this in clutter_clone_paint but
really this kind of thing is best handled in an implementation of the
apply_transform virtual so Clutter can be aware of the transform for
other purposes, such as input transformations. Also we want to provide
an implementation of the get_paint_volume virtual where Clutter will
also expect to be able to use the apply_transform virtual to transform
the volume into its parent's coordinate space.
2010-09-13 18:18:35 +01:00
Robert Bragg
ad398d583b glx: Mark stage clip initialized even for NULL user clip
If a NULL clip is passed to clutter_stage_glx_add_redraw_clip then we
update the redraw clip to have width of 0, but we weren't setting
stage_glx->initialized_redraw_clip = TRUE. This could result in a full,
unclipped stage redraw being reduced to a clipped redraw.
2010-09-13 18:18:35 +01:00
Robert Bragg
8d2a3d6088 actor: warn if allocating actor not descending from stage
This adds a verbose warning that will be displayed if
clutter_actor_allocate is passed an actor that isn't a descendent of a
ClutterStage. Layouting should always bubble up from a stage so this
condition is likely to indicate a buggy container that allocating a
child that it has already unparented.
2010-09-13 18:18:34 +01:00
Robert Bragg
ff4c24f0a4 geometry: Adds a clutter_geometry_intersects API
This adds a public function named clutter_geometry_intersects which
determines if two geometries intersect or not returning TRUE if so else
FALSE.
2010-09-13 18:18:34 +01:00
Emmanuele Bassi
8a2e164354 actor-box: Correctly clamp to pixel
Use ceilf() to round up the right side of the actor's box, and floorf()
to round down the left side.
2010-09-13 18:18:34 +01:00
Robert Bragg
f5f066df9c Try to clean up how we handle actor transformations
When building actor relative transforms, instead of using the matrix
stack to combine transformations and making assumptions about what is
currently on the stack we now just explicitly initialize an identity
matrix and apply transforms to that.

This removes the full_vertex_t typedef for internal transformation code
and we just use ClutterVertex.

ClutterStage now implements apply_transform like any other actor now
and the code we had in _cogl_setup_viewport has been moved to the
stage's apply_transform instead.

ClutterStage now tracks an explicit projection matrix and viewport
geometry. The projection matrix is derived from the perspective whenever
that changes, and the viewport is updated when the stage gets a new
allocation. The SYNC_MATRICES mechanism has been removed in favour of
_clutter_stage_dirty_viewport/projection() APIs that get used when
switching between multiple stages to ensure cogl has the latest
information about the onscreen framebuffer.
2010-09-13 18:18:34 +01:00
Robert Bragg
ab008948cf actor: Add _get_stage_internal to clutter-private.h
This adds _clutter_actor_get_stage_internal to clutter-private.h since
we plan to use it in clutter-offscreen-effect when preparing to
redirect an actor offscreen.
2010-09-13 18:18:34 +01:00
Murray Cumming
28f28c0309 Remove trailin enum commas, avoiding C++ warnings.
http://bugzilla.clutter-project.org/show_bug.cgi?id=2314
2010-09-13 15:45:55 +01:00
Alejandro Piñeiro
209bef6f8a cally: fixing public headers
Cally headers were including specific clutter object headers.

This caused a problem including cally.h on a external program.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2234
2010-09-13 12:19:54 +01:00
Emmanuele Bassi
dec0863f58 build: Add tesselator to the include paths 2010-09-13 11:31:46 +01:00
Emmanuele Bassi
94e2c7a949 build: Generate ClutterJson in the top directory
Instead of doing the shlib trick, build ClutterJson (if needed) inside
the top-level clutter/ directory - similar to a non-recursive layout.

Hopefully, one day, we'll be able to do this with a real non-recursive
layout.
2010-09-13 02:26:47 +01:00
Emmanuele Bassi
c03458a861 build: Remove gir files from dist
The introspection data is going to be generated, so it should never be
in the dist.
2010-09-13 02:10:35 +01:00
Emmanuele Bassi
64924f0e98 build: Do not build a noinst library for the tesselator
Let's try to keep Cogl's build as non-recursive as possible, in the hope
that one day we'll be able to make it fully non-recursive along with the
rest of Clutter.
2010-09-12 19:25:47 +01:00
Emmanuele Bassi
4ee05f8e21 keysyms: Update the macros to CLUTTER_KEY_*
The keysyms defines in clutter-keysyms.h are generated from the X11 key
symbols headers by doing the equivalent of a pass of sed from XK_* to
CLUTTER_*. This might lead to namespace collisions, down the road.
Instead, we should use the CLUTTER_KEY_* namespace.

This commit includes the script, taken from GDK, that parses the X11
key symbols and generates two headers:

  - clutter-keysyms.h: the default included header, with CLUTTER_KEY_*
  - clutter-keysyms-compat.h: the compatibility header, with CLUTTER_*

The compat.h header file is included if CLUTTER_DISABLE_DEPRECATED is
not defined - essentially deprecating all the old key symbols.

This does not change any ABI and, assuming that an application or
library is not compiling with CLUTTER_DISABLE_DEPRECATED, the source
compatibility is still guaranteed.
2010-09-10 17:54:52 +01:00
Lucas Rocha
1447eff00f introspection: Add full path for the Clutter-1.0 inclusion
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-09-10 17:51:19 +01:00
Emmanuele Bassi
edb54574fa build: Disable deprecated API when building Clutter
Make sure we don't use deprecated API internally by adding
CLUTTER_DISABLE_DEPRECATED to the AM_CPPFLAGS.

This requires adding -UCLUTTER_DISABLE_DEPRECATED to the introspection
scanner CFLAGS, otherwise the deprecated API will never be introspected
and the data generated will not be compatible.
2010-09-10 17:51:18 +01:00
Emmanuele Bassi
d76f64a10c Do not use deprecated API internally 2010-09-10 17:51:13 +01:00
Emmanuele Bassi
01362effca actor: Add a method for querying key focus
A simple convenience method on Clutter.Actor for checking whether
it has key focus assigned on the Stage to which it belongs.
2010-09-10 11:42:11 +01:00
Emmanuele Bassi
71a4db6135 animation: Allow detaching an animation from an actor
When animating an actor through clutter_actor_animate() and friends we
might want forcibly detach the animation instance from the actor in
order to start a new one - for instance, in response to user
interaction.

Currently, there is no way to do that except in a very convoluted way,
by emitting the ::completed signal and adding a special case in the
signal handlers; this is due to the fact that clutter_actor_animate()
adds more logic than the one added by clutter_animation_set_object(),
so calling set_object(NULL) or unreferencing the animation instance
itself won't be enough.

The right way to approach this is to add a new method to Clutter.Actor
that detaches any eventual Animation currently referencing it.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2051
2010-09-10 11:18:53 +01:00
Colin Walters
3aa2d00c3b introspection: Don't look for installed Cogl-1.0.gir
If we're depending on an uninstalled .gir, use --include-uninstalled.
We need to explicitly specify Cogl to let the scanner know it's also
uninstalled.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-09-09 23:01:40 +01:00
Colin Walters
5f5369990f introspection: Don't look for installed Clutter-1.0.gir
If we're depending on an uninstalled .gir, use --include-uninstalled.
2010-09-09 18:44:03 +01:00
Chris Kühl
d86dc377de Added documentation for alpha parameter in Behaviour constructors.
http://bugzilla.clutter-project.org/show_bug.cgi?id=2304

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-09-09 16:34:21 +01:00
Neil Roberts
9e1cd15b48 cogl-vertex-buffer: Flush the framebuffer state first
Flushing the framebuffer state can cause some drawing to occur if the
framebuffer has a clip stack which needs the stencil buffer. This was
causing the array pointers set up by enable_state_for_drawing_buffer
to get mangled so it would crash when it hits glDrawArrays. This patch
moves the framebuffer state flush to before it sets up the array
pointers.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2297
2010-09-09 12:19:53 +01:00
Robert Bragg
bcf20955d3 ClutterX11TexturePixmap: Fix unbalanced error trapping
I think this is what commit 2cf1405506 intended to do since it
specifically mentioned cleaning up the trap in
clutter_x11_texture_pixmap_set_pixmap, but although it moved the untrap
to only be done in the case where Pixmap != None it left the position of
the trap itself unchanged. This meant the error trapping wouldn't be
balanced if pixmap == None since the untrap wouldn't be done. We now
only trap and untrap around the XGetGeometry call done when pixmap !=
None.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2303
2010-09-09 11:18:53 +01:00
Emmanuele Bassi
089a20e79d build: Add ClutterX11 introspection generation 2010-09-08 18:27:12 +01:00
Emmanuele Bassi
f8bd45dbce x11-texture-pixmap: Do not go through g_object_get()
The pixmap width and height are stored in our own private data
structure; going through g_object_get() is pointless overhead.
2010-09-08 17:39:04 +01:00
Owen W. Taylor
2cf1405506 Clean up CoglTexturePixmapX11 first
With currently distributed versions of Mesa, calling XFreePixmap()
before glxDestroyPixmap() will cause an X error from DRI. So, we
need to make sure that we get rid of the CoglTexturePixmapX11 before
we XFreePixmap().

clutter_x11_texture_pixmap_dispose(): Call
 clutter_x11_texture_pixmap_set_pixmap() instead of using XFreePixmap
 directly so that we leverage the text-clearing hack and destroy
 things in the right order.

clutter_x11_texture_pixmap_set_pixmap(): Don't do a pointless roundtrip
 and trap a pointless error when setting pixmap to None.

clutter_x11_texture_pixmap_set_pixmap(): Free damage resources when
 we are setting Pixmap to None.

clutter_x11_texture_pixmap_set_window(): When setting a new window
 or setting the window to None, immedediately  call
 cluter_x11_texture_pixmap_set_pixmap(). This means that set_window(None)
 immediately will free any referenced resources related to the window.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2303
2010-09-08 17:24:49 +01:00
Emmanuele Bassi
ca8db4c2ee Add caller-allocates annotations
For ClutterColor, ClutterUnits, ClutterInterval and the Perspective
accessor in ClutterStage.
2010-09-08 17:04:21 +01:00
Emmanuele Bassi
8a5686d835 Further annotation fixes 2010-09-08 16:41:47 +01:00
Owen W. Taylor
f1c44a27a1 introspection: Add missing (out) annotations
Comprehensively add (out) annotations to functions parameters
returning int/float/double.

Not handled here: structure out returns like ClutterColor or
ClutterPerspective or GValue that should get (out caller-allocates).

Not handled here: Cogl

http://bugzilla.clutter-project.org/show_bug.cgi?id=2302
2010-09-08 15:43:07 +01:00
Emmanuele Bassi
e4870ebaf4 Constify Event accessors and copy method
This is still C, but at least we can get some sort of safety net when
using the API correctly.
2010-09-08 15:15:57 +01:00
Javier Jardón
98cac30d82 build: Use upstream gettext instead the glib one
Fixes http://bugzilla.clutter-project.org/show_bug.cgi?id=2300
2010-09-08 11:46:36 +01:00
Owen W. Taylor
c4ca75350f introspection: Fix annotation for clutter_container_get_children()
(element-type) should have a full name like Clutter.Actor rather than
a non-namespaced name like Actor. gobject-introspection has become
more strict about this with the recent scanner rewrite.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2301
2010-09-08 01:05:27 +01:00
Henrik Hedberg
1eae9fcd7e drag-action: Added x-drag-threshold and y-drag-threshold properties
*** This is an API change ***

Replaced the original drag-threshold property with two separate
horizontal (x-drag-threshold) and vertical (y-drag-threshold)
thresholds.

It is some times necessary to have different drag thresholds for the
horizontal and vertical axes. For example, when a draggable actor is
inside a horizontal scrolling area, only vertical movement must begin
dragging. That can be achieved by setting the x-drag-threshold to
G_MAXUINT while y-drag-threshold is something usual, say, 20 pixels.

This is different than drag axis, because after the threshold
has been cleared by the pointer, the draggable actor can be dragged
along both axes (if allowed by the drag-axis property).

http://bugzilla.clutter-project.org/show_bug.cgi?id=2291

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-09-07 10:40:49 +01:00
Emmanuele Bassi
ba9aa3b332 texture: Move the material unref() in ::dispose 2010-09-06 18:09:19 +01:00
Emmanuele Bassi
128e981f6c texture: Do some more validation in get_cogl_texture()
Check the layer type, even though right now we only have one type
available.
2010-09-06 18:09:19 +01:00
Emmanuele Bassi
7e56a98413 texture: Use a base material for all instances
Creating new materials for every Texture instance results in a lot of
ARBfp programs being generated/compiled. Since most textures will just
be similar we should create a template material for all of them, and
then copy it in every instance. Cogl will try to optimize the generation
of the program and, hopefully, will reuse the same program most of the
time.

With this change, a simple test shows that loading 48 textures will
result in just two programs being compiled - with and without batching
enabled.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2295
2010-09-06 18:09:19 +01:00
Emmanuele Bassi
283dce8e21 material: Check before unreferencing a texture
When disposing a material layer of type 'texture' we should check that
the texture handle is still valid before calling cogl_handle_unref().
This avoids an assertion failure when disposing a ClutterTexture.
2010-09-06 18:09:19 +01:00
Emmanuele Bassi
b4120b81e4 Add some more introspection annotations 2010-09-06 16:11:46 +01:00
Emmanuele Bassi
7abe63953e cogl-shader: Add deprecation guards for cogl_program_uniform_* 2010-09-03 16:59:01 +01:00
Emmanuele Bassi
abef73bb58 Replace cogl_color_set_from_* with cogl_color_init_from_*
The former is not yet "officially" deprecated by the latter, but it's
confusing to have them both in the code base.
2010-09-03 16:58:47 +01:00
Emmanuele Bassi
0caef5c8aa docs: Fixes for gtk-doc 2010-09-03 16:12:24 +01:00
Emmanuele Bassi
3e74f42f07 introspection: Add annotations
Reduce the amount of warnings coming from g-ir-scanner.
2010-09-03 12:14:50 +01:00
Emmanuele Bassi
710c7aed40 build: Use Makefile.introspection
Whenever possible, instead of writing our own rules for generating GIR
files and typelibs.
2010-09-03 11:38:22 +01:00
Colin Walters
f7854dd90f introspection: Build fixes
This patch merges in substantial work from
Emmanuele Bassi <ebassi@linux.intel.com>

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

http://bugzilla.clutter-project.org/show_bug.cgi?id=2292
2010-09-03 11:38:22 +01:00
Damien Lespiau
24b12d626c cex100: Remove C99-ism
We were declaring a variable in the middle of the code. Blasphemy, for
non-c99 compilers.
2010-09-03 11:14:05 +01:00
Damien Lespiau
0216f0b281 cex100: Use % not # to document constants
gtk-doc contants should be prefixed by %, not # (types).
2010-09-03 11:13:57 +01:00
Damien Lespiau
0a0a59cf7b cex100: Add an API to configure the buffering mode of the GDL plane
GDL planes can be double or triple buffered. Let the user choose between
the two modes befored initalizing Clutter.
2010-09-03 11:13:35 +01:00
Damien Lespiau
01fcd11efd cex100: Add an API to configure the GDL plane to use
Intel CE3100 and CE4100 have several planes (framebuffers) and a
hardware blender to blend the planes togeteher to produce the final
image.

clutter_cex100_set_plane() lets you configure which framebuffer clutter
will use for its rendering.
2010-09-03 11:13:35 +01:00
Damien Lespiau
70dc3ecbd6 egl: Fix the installed headers
• Use the public COGL_HAS_GLES[12] define instead of the HAVE_COGL_*
   ones which are private and defined in config.h,
 • Install clutter-egl-headers.h which is needed by clutter-egl.h,
 • Remove clutter-stage.h as it's uneeded and does not work since the
   single clutter.h include policy,
 • Install the egl headers into their own egl directory as the x11 and
   glx backends do. The include should then be <clutter/egl/clutter-egl.h>,
   so document it. It does not really break anything as nobody could
   have used those broken headers.
2010-09-03 11:13:35 +01:00
Damien Lespiau
e1e5db0032 cex100: Add a Clutter EGL backend for CE3100/CE4100 SoCs
Intel CE3100 and CE4100 SoCs are designed for TVs. They have separate
framebuffers that are blended together by a piece of hardware to make
the final output. The library that allows you to initialize and
configure those planes is called GDL. A EGL GDL winsys can then be
use with those planes as NativeWindowType to select which plane to use.

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

Make ClutterStageEGL a subclass of either ClutterStageX11 or GObject
depending if you compile with X11 support (EGLX) or not (native).
2010-09-03 11:13:35 +01:00
Emmanuele Bassi
12a5bf2e06 offscreen-effect: Rename create_target to create_buffer
*** This is an API change ***

The create_target() virtual function should return a CoglHandle to a
texture; clutter_offscreen_effect_get_target(), instead, returns a
CoglMaterial to be painted in the implementation of the paint_target()
virtual function.

Instead of equating textures with materials, and confusing the user of
the API, we should mark the difference more prominently.

First of all, we should return a CoglMaterial* (now that we have that
as a public type) in get_target(); having handles all over the place
does not make it easier to distinguish the semantics of the virtual
functions.

Then we should rename create_target() to create_texture(), to make it
clear that what should be returned is a texture that is used as the
backing for the offscreen framebuffer.
2010-09-01 18:05:53 +01:00
Emmanuele Bassi
ac6256ae60 docs: Add @Title to the X11TexturePixmap gtk-doc section 2010-08-28 21:17:23 +01:00
Emmanuele Bassi
36d45b660f click-action: Add get_button()
Allow retrieving the pointer button that caused the ::clicked signal to
be emitted.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2287
2010-08-26 16:39:39 +01:00
Emmanuele Bassi
550d5ab621 click-action: Fix the release() method name
Documented and declared as release(), it's implemented as
force_release().

http://bugzilla.clutter-project.org/show_bug.cgi?id=2286
2010-08-26 16:39:39 +01:00
Bastian Winkler
cb58f1f68c script-parser: Apply child and layout properties to the right actor
http://bugzilla.clutter-project.org/show_bug.cgi?id=2285

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-08-25 16:18:25 +01:00
Neil Roberts
2e12768e3c win32: Fix the check for the 'IN_DESTRUCTION' flag
Commit eae4561929 tried to clean how it checks for the private actor
flags. However the check for the 'IN_DESTRUCTION' flag in the Win32
backend got inverted so it would always clear the current
context. This was causing _cogl_check_driver_valid to fail later and
then the realize would get stuck in a infinite loop.
2010-08-24 20:00:04 +01:00
Øyvind Kolås
04d55107f3 state: clutter_state_remove_key_internal fix memory corruption
When we free a state because there are no more keys with it as a target use a
goto to re-initialize temporary variables that have become invalid.

Fixing bug #2273
2010-08-23 14:01:08 +01:00
Neil Roberts
66018a7035 Invert the check for whether to clip the pick
In 965907deb3 the picking was changed to render the full stage
instead of a single pixel whenever picking is performed more than once
between paints. However the condition in the if-statement was
backwards so it would end up always doing a full stage render.
2010-08-23 11:55:14 +01:00
Neil Roberts
ddd08ba723 Add some debugging notes for picking
This adds a new CLUTTER_DEBUG option for picking. Currently this just
reports the position for each pick and whether it is clipped or not.
2010-08-23 11:55:13 +01:00
Alexandros Frantzis
12e58c7813 Hide internal glx and egl(x) backend symbols.
The glx and egl(x) backends export some internal symbols. Hide these
symbols (using '_' prefix) to reduce ABI differentiation between the
glx and eglx flavours.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2267

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-08-23 11:49:07 +01:00
Emmanuele Bassi
cda5afb419 box-layout: Use the correct name for the arguments
Since we're getting the preferred height for a given width, the width
argument should be named "for_width" and not "for_height".
2010-08-20 17:03:06 +01:00
Emmanuele Bassi
213bd1eab4 debug: Add a macro for checking debug flags 2010-08-19 13:57:10 +01:00
Emmanuele Bassi
459a6bb24c click-action: Add a method to force a release
It can be useful to be able to forcibly break the grab set up by the
ClickAction. The newly added release() method provides a mechanism to
release the grab and unset the :held state of the ClickAction.
2010-08-19 12:10:43 +01:00
Emmanuele Bassi
db7d821ef6 click-action: Add attribution
The ClickAction semantics were inspired by the StClickable widget in the
GNOME Shell Toolkit (St).
2010-08-19 11:26:51 +01:00
Robert Bragg
5ccaa61e4f docs: Clarifies that queue_redraw also applies to picking
This clarifies the documentation for clutter_actor_queue_redraw to
explain that custom actors should call this whenever some private state
changes that affects painting *or* picking.
2010-08-18 18:30:31 +01:00
Robert Bragg
f8940e3c9a clutter-texture: queue redraw when changing pick_with_alpha
The expectation is that actors should call clutter_actor_queue_redraw
when ever some private state changes that affects painting *or* picking.
ClutterTexture was not doing this for pick_with_alpha property changes.
2010-08-18 18:30:30 +01:00
Robert Bragg
965907deb3 Cache a full pick render if we have a static stage
The idea is that if we see multiple picks per frame then that implies
the visible scene has become static. In this case we can promote the
next pick render to be unclipped so we have valid pick values for the
entire stage. Now we can continue to read from this cached buffer until
the stage contents do visibly change.

Thanks to Luca Bruno on #clutter for this idea!
2010-08-18 18:30:30 +01:00
Emmanuele Bassi
c646a366c6 actor: Ignore paint() on actors being destroyed
OBVIOUS OPTIMIZATION IS OBVIOUS
2010-08-18 18:20:45 +01:00
Emmanuele Bassi
56097df60c docs: Improve paint() documentation 2010-08-18 18:20:04 +01:00
Emmanuele Bassi
ad0c36e1a1 docs: Fixes to avoid gtk-doc warnings 2010-08-17 14:54:20 +01:00
Emmanuele Bassi
92b1a33eb3 texture: Default square textures to height-for-width
Square textures should have a preferred geometry request set to
height-for-width, as it is the default for Clutter itself.
2010-08-16 15:56:49 +01:00
Emmanuele Bassi
271e0d9604 animator: Plug some leaks 2010-08-13 17:03:02 +01:00
Robert Bragg
12031ca2c5 material: Implements weak materials
Weak materials are ones that don't take a reference on their parent and
they are associated with a callback that notifies when the material is
destroyed, because its parent was freed or modified.

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

For now the concept is internal only but the plan is to make this public
at some point once we have tested the design internally.
2010-08-13 16:23:19 +01:00
Emmanuele Bassi
50c5ecfe87 state: Plug some memory leakage
Thanks to Valgrind, test-state-base now reports 0 bytes definitely lost.
2010-08-13 12:12:59 +01:00
Emmanuele Bassi
daf6e73936 Remove last uses of cogl_program_uniform*
Following the commits:

  c03544da - clutter-shader: use cogl_program_set_uniform_xyz API
  a26119b5 - tests: Remove use of cogl_program_use

Remove the users of cogl_program_uniform_* and cogl_program_use() in the
shader-based effects.
2010-08-12 17:08:26 +01:00
Robert Bragg
01a7272599 cogl-shader: get_info_log should always use strdup
In the case where there is no error log for arbfp we were returning a
"" string literal. The other paths were using g_strdup to return a
string that could be freed with g_free. This makes the arbfp path return
g_strdup ("") instead.
2010-08-12 16:50:47 +01:00
Robert Bragg
b50bdd7919 cogl-shader: correctly #ifdef guard an if else block
There are quite a few if {} else {} blocks for dealing with arbfp else
glsl and the first block is guarded with #ifdef HAVE_COGL_GL. In this
case though the #endif was before the else so it wouldn't compile for
gles.
2010-08-12 16:50:47 +01:00
Robert Bragg
94692370d2 material-glsl: #include "cogl-shader-private.h"
We need to include cogl-shader-private.h to have the
COGL_SHADER_TYPE_GLSL define. When building for opengl this wasn't
noticed probably because some other header indirectly includes this
file. It was a problem when building for gles2 though.
2010-08-12 16:50:47 +01:00
Robert Bragg
c03544daa6 clutter-shader: use cogl_program_set_uniform_xyz API
Instead of using the deprecated cogl_program_uniform_xyz functions we
now use the cogl_program_set_uniform methods. It looks like this should
also fix a problem with clutter-shader too in that previously we weren't
calling cogl_program_use before cogl_program_uniform_xyz so setting
uniforms would only work while the shader is enabled.
2010-08-12 16:50:46 +01:00
Robert Bragg
f03037d580 cogl-program: Adds use_uniform_xyz methods
Instead of exposing an API that provides an OpenGL state machine style
where you first have to bind the program to the context using
cogl_program_use() followed by updating uniforms using
cogl_program_uniform_xyz we now have uniform setter methods that take an
explicit CoglHandle for the program.

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

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

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

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

This also adds a function to recursively verify the cached state in
the nodes such as the remaining space and the number of
rectangles. This function is only called when the dump-atlas-image
debug flag is set because it is potentially quite slow.
2010-08-12 11:56:59 +01:00
Neil Roberts
e609a658a4 cogl-atlas: Increase the default minimum texture size
When initially creating a texture it would start with a minimum size
of 256x256. This increases the size so that it would try to match 1MB
of memory.
2010-08-12 11:56:59 +01:00
Neil Roberts
d03fbf9f64 cogl-pango: Use a CoglAtlas to maintain the glyph cache
The glyph cache is now stored in a CoglAtlas structure instead of the
custom atlasing code. This has the advantage that it can share code
with the main texture atlas and that it supports reorganizing the
atlas when it becomes full. Unlike the texture atlas, the glyph cache
can use multiple atlases which would be neccessary if the maximum
texture size is reached and we need to create a second
texture. Whenever a display list is created it now has to register a
callback with the glyph cache so that the display list can be
recreated whenever any of the atlases are reorganized. This is needed
because the display list directly stores texture coordinates within
the atlas texture and they would become invalid when the texture is
moved.

The ensure_glyphs_for_layout now works in two steps. First it reserves
space in the atlas for all of the glyphs. The atlas is created with
the DISABLE_MIGRATION flag so that it won't actually copy any textures
if any rearranging is needed. Whenever the position is updated for a
glyph then it is marked as dirty. After space for all of the glyphs
has been reserved it will iterate over all dirty glyphs and redraw
them using Cairo. The rendered glyph is then stored in the texture
with a sub texture update.

The glyphs need to all be set at the right location before starting to
create the display list because the display list stores the texture
coordinates of the glyph. If any of the glyphs were moved around then
the parts of the display list that was created already would become
invalid. To make this work, ensure_glyphs_for_layout is now always
called before rendering a layout or a layout line.
2010-08-12 11:56:59 +01:00
Neil Roberts
047227fbd7 cogl-atlas: Support multiple formats and clearing the texture
_cogl_atlas_new now has two extra parameters to specify the format of
the textures it creates as well as a set of flags to modify the
behavious of the atlas. One of the flags causes the new textures to be
cleared and the other causes migration to avoid actually copying the
textures. This is needed to use CoglAtlas from the pango glyph cache
because it needs to use COGL_PIXEL_A_8 and to clear the textures as it
does not fill in the gaps between glyphs. It needs to avoid copying
the textures so that it can work on GL implementations without FBO
support.
2010-08-12 11:56:59 +01:00
Neil Roberts
9b2f8179f0 cogl-atlas-texture: Split out the atlas data structure
Instead of storing a pointer to the CoglRectangleMap and a handle to
the atlas texture in the context, there is a now a separate data
structure called a CoglAtlas to manage these two. The context just
contains a pointer to this. The code to reorganise the atlas has been
moved from cogl-atlas-texture.c to cogl-atlas.c
2010-08-12 11:56:59 +01:00
Neil Roberts
0c8582aad8 cogl: Add an internal utility to maintain a list of callback functions
This adds an internal CoglCallbackList type which is just a GSList of
of function pointers along with a data pointer to form a
closure. There are functions to add and remove items and to invoke the
list of functions. This could be used in a number of places in Cogl.
2010-08-12 11:54:42 +01:00
Neil Roberts
4989000f55 cogl-atlas: Rename to CoglRectangleMap
This simply renames CoglAtlas to CoglRectangleMap without making any
functional changes. The old 'CoglAtlas' is just a data structure for
managing unused areas of a rectangle and it doesn't neccessarily have
to be used for an atlas so it wasn't a very good name.
2010-08-12 11:54:42 +01:00
Neil Roberts
89c535f50d cogl-material: Compare whether textures are equal by their GL handle
Textures within a layer were compared for equality by comparing their
texture handle. However this means that sub textures and atlas
textures which may be internally using the same GL handle would not be
batched together. Instead it now tries to determine the underlying GL
handle using either the slice override or _cogl_texture_get_gl_texture
and then compares those.
2010-08-12 11:36:18 +01:00
Neil Roberts
8538bdbdea cogl-atlas-texture: Accept formats with different component orders
When filtering on allowed formats for atlas textures, it now masks out
the BGR and AFIRST bits in addition to the premult bit. That way it
will accept RGB and RGBA formats in any component order.

In theory it could also accept luminance and alpha-only textures but I
haven't added this because presumably if the application has requested
these formats then it has some reason not to use a full RGB or RGBA
texture and we should respect that.
2010-08-12 10:03:52 +01:00
Emmanuele Bassi
2bf01dd959 build: Make the introspection generation quiet (again) 2010-08-12 09:03:58 +01:00
Emmanuele Bassi
9b736cfeba drag-action: Capture ENTER when dragging
This completes commit 9ab83cebf.
2010-08-12 08:53:06 +01:00
Emmanuele Bassi
ed39948ccf colorize-effect: Do not inherit from ShaderEffect
See commits:

  7daeb217 blur-effect: Do not inherit from ShaderEffect
  1ec57743 desaturate-effect: Do not inherit from ShaderEffect

We might avoid using shaders at all in the future for simple effects.
2010-08-11 17:43:15 +01:00
Emmanuele Bassi
d10ebe9fca effects: Check before using the cogl_shader_* API
Since BlurEffect and DesaturateEffect are using the shader API
implicitly and not using ClutterShaderEffect, we need to check if the
underlying GL implementation supports the GLSL shading language and warn
if not.
2010-08-11 17:25:17 +01:00
Emmanuele Bassi
9ab83cebfd drag-action: Capture stage leave
If we are dragging, we don't want the drag handle to emit a
::leave-event even if the pointer left the stage.
2010-08-11 14:42:56 +01:00
Emmanuele Bassi
1ec577438e desaturate-effect: Do not inherit from ShaderEffect
Hide the fact that we're using a fragment shader, in case we're able in
the future to use a material layer combine function when painting the
offscreen target texture.
2010-08-11 14:21:23 +01:00
Emmanuele Bassi
7daeb217bd blur-effect: Do not inherit from ShaderEffect
We might want to switch the BlurEffect from a box-blur to a
super-sampling of the texture target, in order to make it cheap(er).
If we inherit from ShaderEffect, though, we're setting in stone the
fact that we are going to use a fragment shader for blurring.

Since there is not parametrization of the blur, the code necessary
to implement effect is pretty small, and we can use the Cogl API
directly.
2010-08-11 14:21:23 +01:00
Emmanuele Bassi
eb4dee46b7 shader-effect: Attach the program to the target material
Instead of calling cogl_program_use() around the paint_target()
chain-up, we can use the newly added API in CoglMaterial to attach
user-defined shaders to the offscreen target material.
2010-08-11 14:21:23 +01:00
Emmanuele Bassi
c87bfef1eb stage: Fix the user-resizable property enumeration id 2010-08-11 12:40:22 +01:00
Emmanuele Bassi
59a9786942 actor: Use box origin instead of direct access 2010-08-11 11:39:24 +01:00
Emmanuele Bassi
5e1d40c07b Merge branch 'wip/table-layout'
* wip/table-layout:
  Add ClutterTableLayout, a layout showing children in rows and columns
  box-layout: Use allocate_align_fill()
  bin-layout: Migrate to allocate_align_fill()
  actor: Add allocate_align_fill()
  test-flow-layout: Use BindConstraints
2010-08-11 11:32:44 +01:00
José Dapena Paz
d14e294d86 Add ClutterTableLayout, a layout showing children in rows and columns
A TableLayout is a layout manager that allocates its children in rows
and columns. Each child is assigned to a cell (or more if a cell span
is set).

The supported child properties are:

  • x-expand and y-expand: if this cell with try to allocate the
    available extra space for the table.
  • x-fill and y-fill: if the child will get all the space available in
    the cell.
  • x-align and y-align: if the child does not fill the cell, then
    where the child will be aligned inside the cell.
  • row-span and col-span: number of cells the child will allocate for
    itself.

Also, the TableLayout has row-spacing and col-spacing for specifying
the space in pixels between rows and between columns.

We also include a simple test of the layout manager, and the
documentation updates.

The TableLayout was implemented starting from MxTable and
ClutterBoxLayout.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2038

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-08-10 23:20:06 +01:00
Emmanuele Bassi
1043e77a00 box-layout: Use allocate_align_fill()
Remove duplicated code, and use the newly added actor method to compute
the child allocation based on alignment and fill.
2010-08-10 22:25:12 +01:00
Emmanuele Bassi
6ad4126e17 bin-layout: Migrate to allocate_align_fill()
Now that we have the code in ClutterActor itself.
2010-08-10 22:25:11 +01:00
Emmanuele Bassi
07b01888ba actor: Add allocate_align_fill()
Layout managers are using the same code to allocate a child while taking
into consideration:

  • horizontal and vertical alignment
  • horizontal and vertical fill
  • the preferred minimum and natural size, depending
    on the :request-mode property
  • the text direction for the horizontal alignment
  • an offset given by the fixed position properties

Given the amount of code involved, and the amount of details that can go
horribly wrong while copy and pasting such code in various classes - let
alone various projects - Clutter should provide an allocate() variant
that does the right thing in the right way. This way, we have a single
point of failure.
2010-08-10 22:25:11 +01:00
Neil Roberts
8d51617979 Conditionally use g_object_notify_by_pspec
This adds a wrapper macro to clutter-private that will use
g_object_notify_by_pspec if it's compiled against a version of GLib
that is sufficiently new. Otherwise it will notify by the property
name as before by extracting the name from the pspec. The objects can
then store a static array of GParamSpecs and notify using those as
suggested in the documentation for g_object_notify_by_pspec.

Note that the name of the variable used for storing the array of
GParamSpecs is obj_props instead of properties as used in the
documentation because some places in Clutter uses 'properties' as the
name of a local variable.

Mose of the classes in Clutter have been converted using the script in
the bug report. Some classes have not been modified even though the
script picked them up as described here:

json-generator:

 We probably don't want to modify the internal copy of JSON

behaviour-depth:
rectangle:
score:
stage-manager:

 These aren't using the separate GParamSpec* variable style.

blur-effect:
win32/device-manager:

 Don't actually define any properties even though it has the enum.

box-layout:
flow-layout:

  Have some per-child properties that don't work automatically with
  the script.

clutter-model:

  The script gets confused with ClutterModelIter

stage:

  Script gets confused because PROP_USER_RESIZE doesn't match
  "user-resizable"

test-layout:

  Don't really want to modify the tests

http://bugzilla.clutter-project.org/show_bug.cgi?id=2150
2010-08-10 17:12:06 +01:00
Owen W. Taylor
de8276105f Always bind a new texture to unit 1 when necessary
The special handling for texture unit 1 caught the case where unit
1 was changed for transient purposes, but didn't properly handle
the case where the actual non-transient texture was different between
two materials with no transient binding in between.

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

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

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

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

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

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

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

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

Also we were initializing dest->n_layers before copying the layer
differences but the act of copying the differences will re-initialize
n_layers to 0 when adding the first layer_difference since it will
trigger a layer_pre_change_notify and since the dest material isn't yet
a STATE_LAYERS authority the state group is initialized before allowing
the change.
2010-08-09 17:12:26 +01:00
Robert Bragg
0e2880b067 material: don't dereference layer->texture directly
In _cogl_material_texture_storage_change_notify we were potentially
dereferencing layer->texture without checking first that it is the
authority of texture state. We now use
_cogl_material_layer_get_texture() instead.
2010-08-09 17:12:26 +01:00
Robert Bragg
9c46cb7f21 material: Improve the dot file debugging code
This improve the dot file output available when calling
_cogl_debug_dump_materials_dot_file. The material graph now directly
points into the layer graph and the layers now show the texture unit
index.
2010-08-09 17:12:25 +01:00
Emmanuele Bassi
1943b8e544 glx: Depend on libdrm
DRM is available on more platforms than Linux (e.g. kFreeBSD), but
Clutter currently FTBFS there because of not being an alternative to
the __linux__ code (where it should be HAVE_DRM).

Instead of copying the DRM data structures, we should use libdrm when
falling back to directly requesting to wait for the vblank.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2225

Based on a patch by: Emilio Pozuelo Monfort <pochu27@gmail.com>
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-08-09 11:29:03 +01:00
Emmanuele Bassi
28378f1bb4 layout-manager: Do not emit layout-changed on thaw
When thawing a LayoutManager, do not emit the ::layout-changed signal
since it might still be in the middle of a relayout.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2255
2010-08-09 11:06:44 +01:00
Emmanuele Bassi
306385c2eb animator: Remove redundant parenthesis 2010-08-09 08:50:18 +01:00
Emmanuele Bassi
74301da8e7 animator: Improve the key value copy
Use the same code used elsewhere in Clutter when dealing with values
that can be copied or transformed.
2010-08-08 19:18:46 +01:00
Emmanuele Bassi
1ca0c2a6d1 state: Return a boolean when getting the key value
Since the copy might fail, we should return a boolean value and not just
warn on the console - similarly to what ClutterAnimator does.
2010-08-08 19:17:14 +01:00
Emmanuele Bassi
d07a525ecc text: Do not set the markup unconditionally
When setting :use-markup we always pass the contents of the Text actor
to clutter_text_set_markup_internal(); if string contains any markup,
this ends up being parsed and used - even when :use-markup is set to
FALSE.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2239
2010-08-06 17:41:28 +01:00
Neil Roberts
fcbfd4ec34 cogl-material: Unref the texture when reverting authority
When the texture is set on a layer so that it is back to the parent's
texture it would clear the texture change flag but it wouldn't unref
the texture. The free function for a material layer does not unref the
texture if the change flag is cleared so the texture would end up
leaking. This happens for ClutterTexture because it disposes the
texture by setting layer 0 of the material to COGL_INVALID_HANDLE
which ends up the same as the default material.
2010-08-06 17:09:54 +01:00
Robert Bragg
8ac3cb29ea material: only deference layer->texture for authority
In _cogl_material_layer_pre_paint we were mistakenly dereferencing the
layer->texture member for the passed layer instead of dereferencing the
texture state authority which was causing crashes in some cases.
2010-08-06 14:16:35 +01:00
Emmanuele Bassi
069266f3ed layout-manager: Freeze ::layout-changed when creating LayoutMeta
LayoutMeta instances are created lazily. If an actor is added to a
container with a layout manager then the first time the layout manager
might be creating the LayoutMeta instance could be during the allocation
cycle caused by calling clutter_actor_show(). When a LayoutMeta is
instantiated for the first time, a list of properties can be set - and
this might lead to the emission of the ::layout-changed signal. The
signal is, most typically, going to cause a relayout to be queued, and a
warning will be printed on the terminal.

We should freeze the emission of the ::layout-changed signal during the
creation of the LayoutMeta instances, and thaw it after that.
2010-08-05 18:10:22 +01:00
Emmanuele Bassi
315965290b texture: Update the request mode depending on the size
If a Texture has been set to:

  • keep its size synchronized with the image data
  • maintain the aspect ratio of the image data

then it should also change its request mode depending on the orientation
of the image data, so that layout managers have a fighting chance of
sizing it correctly.
2010-08-05 16:19:51 +01:00
Emmanuele Bassi
2d4125a053 texture: Make the :filename property readable
UI builders and other tools are be interested in the file used to load
the image data.
2010-08-05 15:39:20 +01:00
Roman Kudiyarov
8326ea26f8 osx: Fixed stage resize policy
Added initialization of minimum window size property on Cocoa
side. This property works when user change window size by mouse
dragging. But when size is changed by clutter_actor_set_size this
property will not help and was added another check in
clutter_stage_osx_resize. Also osx_get_geometry was refactoried
because it returns incorrect values in many cases but now size is
saved in [Window reshape] in requisition_width/height and this value
will be returned in any case to frontend.
2010-08-04 15:13:12 +01:00
Roman Kudiyarov
c1f0b59911 test: Fixed test-rotate for osx platfom
There was a bug in clutter-shader-effect. We have to set to zero new object
of type GValue before we can use it in g_value_init.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
52b6a3cd49 osx: added resolution initialization in backend
It's important step of initialization because all features calls from
font rendering libs based on this parameter. By default it equals to
-1 and test-text-cache test crashes in this case.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
dc23b88de2 osx: Fixed warnings in osx event implementation 2010-08-04 15:13:11 +01:00
Roman Kudiyarov
af8308295c Added willResize delegate for osx stage.
By default a clutter stage is not user resizable and this delegate
controls this option while resizing the stage.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
49b2b62311 Fixed lack of reaction for keyboard events after showing stage on osx.
Trick with hiding view while showing the stage affects on responder
chain. The main view ceases to be first responder and we should
manually set first responder.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
e4c4ef6792 Fixed incorrect size return in osx stage if stage resizable by user.
For some reasons width&height was equal to 1 if flag user-resizable
was true.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
411b5a09bb osx: Added size initialization for stage
After stage creation it's size can be changed by user and it should be
taken into account in clutter_stage_osx_realize.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
8e2b45648f osx: Fixed problem with freezing application while checking behaviour.
Problem was in incorrect application initialization.
[NSApplication sharedApplication] should be call in backend init(not
in init stage). It doesn't require any data and only makes a
connection to window server.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
8c69a639cb osx: Fixed bug with creating context twice.
We should assign context and pixel_format vars to null to avoid
multiple context creation.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
50793eac51 osx: added create_context function in backend
Cleanup clutter_backend_osx_post_parse function and move context
initialization to clutter_backend_osx_create_context. The OpenGL pixel
format attributes were taken as is. Also move bringing application to
foreground in clutter_stage_osx_realize, it seems there is best place
for it.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
904f619419 osx: Implemented hide cursor backend implementation
Add implementation for hide cursor in stage. Also added using this
feature in test-animator.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
12e5011488 osx: Added missed function declaration for stage
Added empty functions for cursor and window resize functional with
notes FIXME and also they are added to iface.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
01c9570d16 osx: Remove drawing call while showing stage and add viewport init
Viewport didn't initialized before OGL drawing and it causes crash on
assert so added viewport initalization to
clutter_stage_osx_realize. Also showing the stage causes drawing
function but other part of the system(in particular conformance tests)
don't expect it and aren't ready at this moment.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
e3295050f5 osx: Fixed crash while features initialization
Clearing current context couses incorrect work of glGetString function
and all next GL functions that use it work incorrectly.
2010-08-04 15:13:10 +01:00
Emmanuele Bassi
24d1142ecf glx: Add more debugging notes
Should help debug the GLX visual selection.
2010-08-03 17:53:58 +01:00
Emmanuele Bassi
fa54b7c60d docs: Further clarifications
Mention the XFixes extension for compositors using input regions to let
events "pass through" the stage.

Thanks to: Robert Bragg <robert@linux.intel.com>
2010-08-03 16:48:53 +01:00
Emmanuele Bassi
da6b2660ba docs: Clarify the event retrieval disable behaviour
When we disable the event retrieval, we now just disable the X11 event
source, not the event selection. We need to make that clear to
applications, especially compositors, which might expect complete
control over the selection.
2010-08-03 16:30:04 +01:00
Emmanuele Bassi
609560b1cb glx: Unconditionally select X11/GLX events
Currently, we select input events and GLX events conditionally,
depending on whether the user has disabled event retrieval.

We should, instead, unconditionally select input events even with event
retrieval disabled because we need to guarantee that the Clutter
internal state is maintained when calling clutter_x11_handle_event()
without requiring applications or embedding toolkits to select events
themselves. If we did that, we'd have to document the events to be
selected, and also update applications and embedding toolkits each time
we added a new mask, or a new class of events - something that's clearly
not possible.

See:

  http://bugzilla.clutter-project.org/show_bug.cgi?id=998

for the rationale of why we did conditional selection. It is now clear
that a compositor should clear out the input region, since it cannot
assume a perfectly clean slate coming from us.

See:

  http://bugzilla.clutter-project.org/show_bug.cgi?id=2228

for an example of things that break if we do conditional event
selection on GLX events. In that specific case, the X11 server ≤ 1.8
always pushed GLX events on the queue, even without selecting them; this
has been fixed in the X11 server ≥ 1.9, which means that applications
like Mutter or toolkit integration libraries like Clutter-GTK would stop
working on recent Intel drivers providing the GLX_INTEL_swap_event
extension.

This change has been tested with Mutter and Clutter-GTK.
2010-08-03 16:11:52 +01:00
Robert Bragg
10c5cb1800 cogl-program: gles2: bind programs lazily as for GL
This makes the gles2 cogl_program_use consistent with the GL version by
not binding the program immediately and instead leaving it to
cogl-material.c to bind the program when actually drawing something.
2010-08-03 15:00:07 +01:00
Robert Bragg
4a9321b60c gles2: Have CoglProgram track uniforms per program
Previously custom uniforms were tracked in _CoglGles2Wrapper but as part
of a process to consolidate the gl/gles2 shader code it seems to make
sense for this state to be tracked in the CoglProgram object instead.

http://bugzilla.o-hand.com/show_bug.cgi?id=2179
2010-08-03 15:00:04 +01:00
Robert Bragg
c26f4ffa22 cogl-shader: unifies the driver/{gl,gles} shader files
The per driver implementations of cogl-shader.c had become almost
identical we now have a single cogl/cogl-shader.c instead.
2010-08-03 12:41:37 +01:00
Robert Bragg
8021d3e2eb cogl-shader: Store the CoglShaderType in CoglShader
Instead of having to query GL and translate the GL enum into a
CoglShaderType each time cogl_shader_get_type is called we now keep
track of the type in CoglShader.
2010-08-03 12:41:34 +01:00
Robert Bragg
467c33a3e3 cogl: don't include cogl-debug.h in cogl.h or install
cogl-debug.h is an internal header so it shouldn't have been included by
cogl.h and the header shouldn't be installed either.
2010-08-02 17:41:42 +01:00
Emmanuele Bassi
c23b283968 animatable: Allow passing a NULL animation
The Animatable interface was created specifically for the Animation
class. It turns out that it might be fairly useful to others - such as
ClutterAnimator and ClutterState.

The newly-added API in this cycle for querying and accessing custom
properties should not require that we pass a ClutterAnimation to the
implementations: the Animatable itself should be enough.

This is necessary to allow language bindings to wrap
clutter_actor_animate() correctly and do type validation and
demarshalling between native values and GValues; an Animation instance
is not available until the animate() call returns, and validation must
be performed before that happens.

There is nothing we can do about the animate_property() virtual
function - but in that case we might want to be able to access the
animation from an Animatable implementation to get the Interval for
the property, just like ClutterActor does in order to animate
ClutterActorMeta objects.
2010-07-31 10:56:09 +01:00
Emmanuele Bassi
c65c0f08d8 docs: Fix the BindConstraint example
A constraint was created but not added to the actor.
2010-07-31 10:39:53 +01:00
Emmanuele Bassi
a20a509584 x11: Split out conditions and warnings
XGetGeometry is a great piece of API, since it gets a lot of stuff that
are moderately *not* geometry related - the root window, and the depth
being two.

Since we have multiple conditions depending on the result of that call
we should split them up depending on the actual error - and each of them
should have a separate error message. This makes debugging simpler.
2010-07-29 17:18:25 +01:00
Emmanuele Bassi
0736cb7323 actor: Make set_flags() safe from unrefs
It's possible - though not recommended - that user code causes the
destruction of an actor in one of the notification handlers for
flag-based properties. We should protect the multiple notification
emission with g_object_ref/unref.
2010-07-29 17:00:24 +01:00
Øyvind Kolås
3d806f498f effect: fix conversion from degrees to radians 2010-07-23 12:16:37 +01:00
Neil Roberts
ec26466cdc gles/cogl-shader.c: Store the shader type in CoglShader
Nothing was storing the shader type when a shader was created so it
would get confused about whether it was a custom vertex or fragment
shader.

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

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

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

This removes the mapping and changes some of the documentation.

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

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

http://bugzilla.clutter-project.org/show_bug.cgi?id=2232
2010-07-22 17:50:56 +01:00
Chris Kühl
24b9748f0a Fixed more set using *_get_* typos.
http://bugzilla.clutter-project.org/show_bug.cgi?id=2233
2010-07-22 11:03:04 +01:00
Emmanuele Bassi
99d7d31318 docs: Improve the text of X11 event-related functions
We need to make sure that people disabling event handling in Clutter
call clutter_x11_handle_event() to update Clutter's internal state.
2010-07-22 10:48:21 +01:00
Neil Roberts
1dee65770a Minor fix to the documentation for clutter_texture_get_sync_size
The documentation was recursively referring to itself causing a stack
overflow in the reader's brain.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2233
2010-07-22 10:06:26 +01:00
Emmanuele Bassi
eae4561929 Clean up the private flags for ClutterActor
Provide macros to quickly query a flag, and remove all namespacing
except the initial 'CLUTTER'.
2010-07-21 16:10:46 +01:00
Emmanuele Bassi
0dfbf010b8 x11: Add more checks to set_stage_foreign()
Check all the pre-requisites to avoid segfaults later on.
2010-07-21 15:21:08 +01:00
Emmanuele Bassi
8538e1bf58 x11: Clean up TexturePixmap header and private data structure
Align the header file and use bitfields instead of booleans.
2010-07-21 15:14:36 +01:00
Neil Roberts
0e80747a68 cogl-material: Consider the shader when deciding if materials equate
_cogl_material_equal was ignoring the user shader state so rectangles
with different shaders would get batched together.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2220
2010-07-20 17:21:12 +01:00
Emmanuele Bassi
f2d0f0ab5f stage: Ignore redraws on destroyed stages
We might get requests to redraw even during destruction; we should
ignore them and do some NULL checks instead of blindly invoking
functions.
2010-07-20 14:39:43 +01:00
Emmanuele Bassi
7b6b2ea55b stage-window: Add argument guards
Validate the arguments passed to StageWindow's methods.
2010-07-20 14:39:01 +01:00
Neil Roberts
76d8119a7f cogl-material-arbfp: Use separate buffers when calling g_ascii_dtostr
g_ascii_dtostr was being used in four separate arguments to
g_string_append_printf but all invocations of it were using the same
buffer. This would end up with all of the arguments having the same
value which would depend on whichever order the compiler evaluates
them in. This patches changes it to use a multi-dimensional array and
a loop to fill in the separate buffers.

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

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

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

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

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

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

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

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

There is also _cogl_bitmap_new_shared. This creates a bitmap using a
reference to another CoglBitmap for the data. This is a bit of a hack
but it is needed by the atlas texture backend which wants to divert
the set_region virtual to another texture but it needs to override the
format of the bitmap to ignore the premult flag.
2010-07-15 17:24:01 +01:00
Neil Roberts
fd886d9fc2 cogl-texture-2d-sliced: Store the internal format not image format
The 'format' member of CoglTexture2DSliced is returned by
cogl_texture_get_format. All of the other backends return the internal
format of the GL texture in this case. However the sliced backend was
returning the format of the image data used to create the texture. It
doesn't make any sense to retain this information because it doesn't
necessarily indicate the format of the actual texture. This patch
changes it to store the internal format instead.
2010-07-15 14:31:23 +01:00
Emmanuele Bassi
fd27ca7398 Mark property strings for translation
Both the nick and the blurb fields should be translatable, for UI
builders and other introspection-based tools.
2010-07-15 14:07:07 +01:00
Emmanuele Bassi
8be43b5285 Add P_() macro for translating property strings
The P_() macro adds a context for the property nick and blurb. In order
to make xgettext recognize it, we need to drop glib-gettexize inside the
autogen.sh script and ship a modified Makefile.in.in with Clutter.
2010-07-15 12:09:01 +01:00
Nate Stedman
fff5558ad2 Fixes build with GLX on Mac OS X.
Moves preprocessor #ifdef __linux_ above else statement, avoiding the
lack of an else block if __linux__ is not defined.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2212

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-07-15 00:31:23 +01:00
Emmanuele Bassi
e7ae71e072 build: Fix include path for Cally's introspection
The introspection scanner does not include '.' by default, so it was
always using the installed copy of Clutter-1.0.gir. Which obviously
wouldn't work if we didn't have one.
2010-07-15 00:27:43 +01:00
Neil Roberts
54b2e1781e gles/cogl-texture-driver.c: Fix the include for cogl-material-private
In ddb9016be4 the GL texture driver backend was changed to include
cogl-material-opengl-private.h instead of cogl-material-private.h.
However the gles texture backend was missed from this so it was giving
a compiler warning about using an undeclared function.
2010-07-14 17:49:16 +01:00
Neil Roberts
ccdcbbb46b cogl-texture-3d: Use glTexSubImage3D through an indirect pointer
glTexSubImage3D was being called directly in cogl-texture-3d.c but the
function is only available since GL version 1.2 so on Windows it won't
be possible to directly link to it. Also under GLES it is only
available conditionally in an extension.
2010-07-14 17:45:15 +01:00
Neil Roberts
943266db3b cogl-texture-3d: Fix the cogl-material-private header include
In ddb9016be4 the texture backends were changed to include
cogl-material-opengl-private.h instead of cogl-material-private.h.
However the 3D texture backend was missed from this so it was giving a
compiler warning about using an undeclared function.
2010-07-14 16:35:33 +01:00
Neil Roberts
d0d72e4d97 cogl-texture-3d: Don't include cogl-texture-2d-private.h
I think this was included by a cut-and-paste error as it isn't needed
anywhere in the source.
2010-07-14 16:34:42 +01:00
Robert Bragg
5e66970385 material: splits out all the state flushing code
This moves the code supporting _cogl_material_flush_gl_state into
cogl-material-opengl.c as part of an effort to reduce the size of
cogl-material.c to keep it manageable.
2010-07-13 19:26:58 +01:00
Robert Bragg
ddb9016be4 material: split the texture unit management out
In general cogl-material.c has become far to large to manage in one
source file. As one of the ways to try and break it down this patch
starts to move some of lower level texture unit state management out
into cogl-material-opengl.c. The naming is such because the plan is to
follow up and migrate the very GL specific state flushing code into the
same file.
2010-07-13 19:26:58 +01:00
Robert Bragg
9e893e684e material: copy_differences: handle copying fog state
When the support for redirecting the legacy fog state through cogl
material was added in 9b9e764dc, the code to handle copying the fog
state in _cogl_material_copy_differences was missed.
2010-07-13 19:26:57 +01:00
Neil Roberts
ceb57087a7 Add a GL_GENERATE_MIPMAP fallback to the texture 2d and 3d backends
The CoglTexture2DSliced backend has a fallback for when the
framebuffer extension is missing so it's not possible to use
glGenerateMipmap. This involves keeping a copy of the upper-left pixel
of the tex image so that we can temporarily enable GL_GENERATE_MIPMAP
on the texture object and do a sub texture update by reuploading the
contents of the first pixel. This patch copies that mechanism to the
2D and 3D backends. The CoglTexturePixel structure which was
previously internal to the sliced backend has been moved to
cogl-texture-private.h so that it can be shared.
2010-07-13 18:41:01 +01:00
Emmanuele Bassi
ff56f4ac6f Merge branch 'wip/xkb-support'
* wip/xkb-support:
  x11: Use XKB to translate keycodes into key symbols
  x11: Use XKB to track the Locks state
  x11: Use XKB detectable auto-repeat
  x11: Add a Keymap ancillary object
  x11: Store the group inside the event platform data
  events: Add platform-data to allocated Events
  build: Check for the XKB extension
2010-07-13 16:12:14 +01:00
Emmanuele Bassi
0cbfabcda4 stage: Add the NO_CLEAR_ON_PAINT hint
Some apps or some use cases don't need to clear the stage on immediate
rendering GPUs. A media player playing a fullscreen video or a
tile-based game, for instance.

These apps are redrawing the whole screen, so we can avoid clearing the
color buffer when preparing to paint the stage, since there is no
blending with the stage color being performed.

We can add an private set of hints to ClutterStage, and expose accessors
for each potential hint; the first hint is the 'no-clear' one.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2058
2010-07-13 14:57:48 +01:00
Neil Roberts
984e04cae8 Make the material functions for setting the p wrap mode public
Now that we have 3D texture support it makes sense to expose the wrap
mode for the p coordinate.
2010-07-13 14:29:07 +01:00
Neil Roberts
192cfa7a58 Rename the third texure coordinate from 'r' to 'p'
Using 'r' to name the third component is problematic because that is
commonly used to represent the red component of a vector representing
a color. Under GLSL this is awkward because the texture swizzling for
a vector uses a single letter for each component and the names for
colors, textures and positions are synonymous. GLSL works around this
by naming the components of the texture s, t, p and q. Cogl already
effectively already exposes this naming because it exposes GLSL so it
makes sense to use that naming consistently. Another alternative could
be u, v and w. This is what Blender and Direct3D use. However the w
component conflicts with the w component of a position vertex.
2010-07-13 14:29:07 +01:00
Neil Roberts
dfea57b45a Add a Cogl texture 3D backend
This adds a publicly exposed experimental API for a 3D texture
backend. There is a feature flag which can be checked for whether 3D
textures are supported. Although we require OpenGL 1.2 which has 3D
textures in core, GLES only provides them through an extension so the
feature can be used to detect that.

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

cogl_texture_3d_new_with_size

 and

cogl_texture_3d_new_from_data

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

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

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

This adds a couple of functions to cogl-texture-driver for uploading
3D data and querying the 3D proxy
texture. prep_gl_for_pixels_upload_full now also takes sets the
GL_UNPACK_IMAGE_HEIGHT parameter so that 3D textures can have padding
between the images. Whenever 3D texture is uploading, both the height
of the images and the height of all of the data is specified (either
explicitly or implicilty from the CoglBitmap) so that the image height
can be deduced by dividing by the depth.
2010-07-13 14:28:52 +01:00
Neil Roberts
8ccf8f6f08 configure: Include gl2ext.h or glext.h under GLES
Under big GL, glext.h is included automatically by gl.h. However under
GLES this doesn't appear to happen so it has to be included explicitly
to get the defines for extensions. This patch changes the
clutter_gl_header to be called cogl_gl_headers and it can now take a
space seperated list of multiple headers. This is then later converted
to a list of #include lines which ends up cogl-defines.h. The gles2
and gles1 backends now add their respective ext header to this list.
2010-07-13 14:28:51 +01:00
Neil Roberts
8940c30681 Make a public CoglBitmapError enum
There are many places in the texture backend that need to do
conversion using the CoglBitmap code. Currently none of these
functions can throw an error but they do return a value to indicate
failure. In future it would make sense if new texture functions could
throw an error and in that case they would want to use a CoglBitmap
error if the failure was due to the conversion. This moves the
internal CoglBitmap error from the quartz backend to be public in
cogl-bitmap.h so that it can be used in this way.
2010-07-13 14:28:45 +01:00
Neil Roberts
539b3f83e1 Rename COGL_ERROR_MISSING_FEATURE to COGL_ERROR_UNSUPPORTED
We can use this error in more unsupported situations than just when we
have a Cogl feature flag for the error. For example if a non-sliced
texture is created with dimensions that are too large then we could
throw this error. Therefore it seems good to rename to something more
general.
2010-07-13 14:28:36 +01:00
Neil Roberts
423f712871 Move _cogl_texture_2d_is_pot to cogl-util.h
This function could be used in many places in Cogl so it makes sense
to share it in cogl-util.h as _cogl_util_is_pot().
2010-07-13 14:28:35 +01:00
Neil Roberts
31c127bfa7 cogl-gles2-wrapper: Layers aren't equal if one is enabled and one is not
Previously when comparing whether the settings for a layer are equal
it would only check if one of them was enabled. If so then it would
assume the other one was enabled and continue to compare the texture
environment. Now it also checks whether the enabledness differs.
2010-07-13 14:28:35 +01:00
Emmanuele Bassi
6c913aa55e x11: Use XKB to translate keycodes into key symbols
And fall back to XKeycodeToKeysym() if XKB is not available.
2010-07-13 11:54:44 +01:00
Emmanuele Bassi
1ea4c50041 x11: Use XKB to track the Locks state
For Caps Lock and Num Lock. Store the state of both in the
platform-specific per-event data structure. No accessors, yet.
2010-07-13 09:15:21 +01:00
Emmanuele Bassi
bf2f8d670d x11: Use XKB detectable auto-repeat
If we have XKB support then we should be using it to turn on the
detectable auto-repeat; this allows avoiding the peeking trick
that emulates it inside the event handling code.
2010-07-13 08:27:48 +01:00
Emmanuele Bassi
bea657d3d5 x11: Add a Keymap ancillary object
We should try to abstract everything that is related with the key mapping
to its own object, to avoid complicating ClutterBackendX11 any further.
2010-07-13 08:27:48 +01:00
Emmanuele Bassi
d345a61e6c x11: Store the group inside the event platform data
Now that we have private, per-event platform data, we can start putting
it to good use. The first, most simple use is to store the key group
given the event's modifiers. Since we assume a modern X11, we use XKB
to retrieve it, or we simply fall back to 0 by default.

The data is exposed as a ClutterX11-specific function, within the
sanctioned clutter_x11_* namespace.
2010-07-13 08:27:48 +01:00
Emmanuele Bassi
f44ccba42e events: Add platform-data to allocated Events
Events allocated by Clutter should have a pointer to platform-specific
data; this would allow backends to add separate structures for holding
ancillary data, whilst retaining the ClutterEvent structure for use on
the stack.

In theory, for Clutter 2.x we might just want to drop Event and use an
opaque structure, or a typed data structure inheriting from
GTypeInstance instead.
2010-07-13 08:27:48 +01:00
Øyvind Kolås
25dd0ae356 state: swap clutter_state_set_state and clutter_state_warp_to_state
Got the boolean arguments for the old clutter_state_change wrong,
making the methods do the opposite of what they should.
2010-07-12 17:34:17 +01:00
Neil Roberts
90acc6a2a9 Add the deprecated ref-counting for cogl_program
cogl_program has always had cogl_program_ref and cogl_program_unref
but this was missed from 89cb325fd4 so they got removed.
2010-07-09 19:09:49 +01:00
Neil Roberts
8a85088196 Don't define public cogl_is_* functions for internal types
This adds a COGL_OBJECT_INTERNAL_DEFINE macro and friends that are the
same as COGL_OBJECT_DEFINE except that they prefix the cogl_is_*
function with an underscore so that it doesn't get exported in the
shared library.
2010-07-09 18:57:54 +01:00
Neil Roberts
0e839c3769 Add cogl_vertex_buffer_is_indices to the public headers
This function has always been defined in the shared library but it was
missed from the public headers.
2010-07-09 18:57:54 +01:00
Neil Roberts
89cb325fd4 cogl: Don't define the deprecated ref/unref accessors for new types
Previously COGL_OBJECT_DEFINE would always define deprecated
cogl_$type_{ref,unref} functions even if the type is new or if the
type is entirely internal. An application would still find it
difficult to use these because they wouldn't be in the headers, but it
still looks bad that they are exported from the shared library. This
patch changes it so that the deprecated ref counting functions are
defined using a separate macro and only the types that have these
functions in the headers call this macro.
2010-07-09 18:57:54 +01:00
Emmanuele Bassi
903560c6c8 text: Layouts for single-line-mode entries are boundless
A PangoLayout for an editable, single-line text entry is by definition
without a given width, since the actor will be clipped when being drawn.
2010-07-09 18:38:45 +01:00
Robert Bragg
1635a2db12 material: use common node type for materials and layers
Since 365605cf42, materials and layers are represented in a tree
structure that allows traversing up through parents and iterating down
through children.  This re-works the related typedefs and reparenting
code so that they can be shared.
2010-07-09 18:04:27 +01:00
Damien Lespiau
9e82fe3944 cogl-texture-pixmap-x11: This API is new in 1.4, not 1.2
CoglTexturePixmapX11 has been introduced in the 1.3 development cycle. A
Stability: Unstable tag was missing too, so add it.
2010-07-09 17:55:31 +01:00
Damien Lespiau
892aa45513 cogl: Add Stability tag to new experimental API
Functions guarded with COGL_ENABLE_EXPERIMENTAL API should be also maked
as being Unstable with the Stability gtk-doc tag.

Fixes: http://bugzilla.clutter-project.org/show_bug.cgi?id=2175
2010-07-09 17:17:11 +01:00
Emmanuele Bassi
b7f99ddd3c script: Let ClutterActor parse behaviours
Up until now, the "behaviours" member of an actor definition was parsed
by the ClutterScript parser itself - even though it's not strictly
necessary.

In an effort to minimize the ad hoc code in the Script parser, we should
let ClutterActor handle all the special cases that involve
actor-specific members.
2010-07-09 14:59:32 +01:00
Neil Roberts
a65429363e Use GL_MAX_TEXTURE_SIZE on GLES when checking supported tex size
Under big GL, _cogl_texture_driver_size_supported uses the proxy
texture to check whether the given texture size is supported. Proxy
textures aren't available under GLES so previously this would just
return TRUE to assume all texture sizes are supported. This patch
makes it use glGetIntegerv with GL_MAX_TEXTURE_SIZE to give a second
best guess.

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

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

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

* _cogl_material_layer_texture_equal did not take into account the
  override.

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

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

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

There is also a corresponding get function.

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

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

http://bugzilla.openedhand.com/show_bug.cgi?id=2047
2010-07-08 16:34:30 +01:00
Robert Bragg
b2decfe762 material: support dumping layer state graph to dot file
Recently I added a _cogl_debug_dump_materials_dot_file function for
debugging the sparse material state. This extends the state dumped to
include the graph of layer state also.
2010-07-07 20:46:50 +01:00
Robert Bragg
7eedf0f234 material: set ->layer_index on new layers for unit0
We were mistakenly only initializing layer->layer_index for new layers
associated with texture units > 0. This had gone unnoticed because
normally layers associated with texture unit0 have a layer index of 0
too. Mutter was hitting this issue because it was initializing layer 1
before layer 0 for one of its materials so layer 1 was temporarily
associated with texture unit 0.
2010-07-07 20:46:04 +01:00
Øyvind Kolås
9e730727ca state: add clutter_state_set_state and clutter_state_warp_to_state
Replaced clutter_state_change with a boolean argument for animating the
transition or not with two separate argument-less methods.
2010-07-07 18:17:09 +01:00
Emmanuele Bassi
f87e4037a8 build: Distcheck fixes after the Cally merge 2010-07-07 16:30:31 +01:00
Emmanuele Bassi
e3a8ece54d Merge branch 'cally-merge'
* cally-merge:
  cally: Add introspection generation
  cally: Improving cally doc
  cally: Cleaning CallyText
  cally: Refactoring "window:create" and "window:destroy" emission code
  cally: Use proper backend information on CallyActor
  cally: Check HAVE_CONFIG_H on cally-util.c
  docs: Fix Cally documentation
  cally: Clean up the headers
  Add binaries of the Cally examples to the ignore file
  docs: Add Cally API reference
  Avoid to load cally module on a11y examples
  Add accessibility tests
  Initialize accessibility support on clutter_init
  Rename some methods and includes to avoid -Wshadow warnings
  Cally initialization code
  Add Cally
2010-07-07 16:06:30 +01:00
Emmanuele Bassi
a3c69dc27c cally: Add introspection generation
Toolkits and applications not written in C might still need access to
the Cally API to write accessibility extensions based on it for their
own native elements.
2010-07-07 15:57:43 +01:00
Emmanuele Bassi
608a5a8ae6 x11: Clean up NET_WM_STATE modifiers
Use a separate function to avoid code duplication.
2010-07-07 14:52:19 +01:00
Emmanuele Bassi
eca398f113 x11: Do not swallow XSettings events
We might want pieces higher in the stack (like Mx) to handle XSettings
events as well, and swallowing them by removing them from the events
queue would make it impossible.
2010-07-07 14:52:19 +01:00
Alejandro Piñeiro
a2f8ce175f cally: Improving cally doc
* Add documentation for all undocumented symbols
  * Add an overview section
2010-07-07 15:48:08 +02:00
Alejandro Piñeiro
c931e11e3d cally: Cleaning CallyText
* Removing superfluous g_return_if_fail
  * Removing unused ClutterText::text-changed callback
2010-07-07 15:48:00 +02:00
Alejandro Piñeiro
137790bec9 cally: Refactoring "window:create" and "window:destroy" emission code
Previously "window:create" and "window:destroy" were emitted on
CallyUtil. Although it works, and CallyUtil already have callbacks to
stage_added/removed signals, I think that it is more tidy/clear to do
that on CallyRoot:

  * CallyRoot already has code to manage ClutterStage addition/removal

  * In fact, we can see CallyRoot as the object exposing the a11y
    information from ClutterStageManager, so it fits better here.

  * CallyUtil callbacks these signals are related to key event
    listeners (key snooper simulation). One of the main CallyUtil
    responsabilities is managing event (connecting, emitting), so I
    would prefer to not start to add/mix more functionalities here.

Ideally it would be better to emit all CallyStage methods from
CallyStage, but it is clear that "create" and "destroy" are more easy
to emit from a external object
2010-07-07 15:47:56 +02:00
Alejandro Piñeiro
ffd1f12560 cally: Use proper backend information on CallyActor
It uses HAVE_CLUTTER_GLX to check the current backend in use for
some accessibility related methods.

Fixes CB#2071
2010-07-07 15:47:45 +02:00
Alejandro Piñeiro
d45499f88b cally: Check HAVE_CONFIG_H on cally-util.c 2010-07-07 15:46:34 +02:00
Robert Bragg
1dd174add3 framebuffer: Replace CoglHandle with CoglFramebuffer *
One more object converted to stop using CoglHandle re:a8c8cbee513
2010-07-07 14:41:54 +01:00