Commit Graph

4896 Commits

Author SHA1 Message Date
Emmanuele Bassi
2f445682b1 cairo-texture: Use signal-based drawing
The current "create context/draw/destroy context" pattern presents
various problems. The first issue is that it defers memory management to
the caller of the create() or create_region() methods, which makes
bookkeeping of the cairo_t* harder for language bindings and third party
libraries. The second issue is that, while it's easier for
draw-and-forget texturs, this API is needlessly complicated for contents
that have to change programmatically - and it introduces constraints
like calling the drawing code explicitly after a surface resize (e.g.
inside an allocate() implementation).

By using a signal-based approach we can make the CairoTexture actor
behave like other actors, and like other libraries using Cairo as their
2D drawing API.

The semantics of the newly-introduced ::draw signal are the same as the
one used by GTK+:

  - the signal is emitted on invalidation;
  - the cairo_t* context is owned by the actor;
  - it is safe to have multiple callbacks attached to the same
    signal, to allow composition;
  - the cairo_t* is already clipped to the invalidated area, so
    that Cairo can discard geometry immediately before we upload
    the texture data.

There are possible future improvements, like coalescing multiple
invalidations inside regions, and performing clipped draws during
the paint cycle; we could even perform clipped redraws if we know the
extent of the invalidated area.
2011-07-26 12:40:52 +01:00
Emmanuele Bassi
e1327f5591 actor: Clean up the allocate() checks
Move the conditions to their own boolean flags, to avoid making the
if() incomprehensible.
2011-07-19 14:03:02 +01:00
Emmanuele Bassi
123bd41e6c texture: Clean up error reporting
ClutterTexture relies too much on GError, even for things that are
clearly programmer errors. Also, no error message passed to GError
is marked for translation as it should.

We should move the programmer errors, like passing the wrong bpp
value with regards to the presence of the alpha channel, to real
warnings; we should also try and harmonize all the error messages,
and not mention Cogl — especially in the ones marked for translation.
2011-07-18 18:06:57 +01:00
Robert Bragg
672bc337ba build: don't explicitly include and egl or gl headers
This avoids explicitly including gl or egl headers in
clutter-egl-headers.h. We were getting build failures when building
clutter against a libcogl that has runtime support for GL and GLES
because cogl-defines.h was including gl.h and then clutter-egl-headers.h
was later including GLES2/gl.h with typedef conflicts. Clutter relies on
Cogl to abstract GL and GLES and the winsys APIs like EGL and GLX so
Clutter should just rely on cogl.h to include the appropriate egl.h in
clutter-egl-headers.h.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-07-18 17:07:40 +01:00
Damien Lespiau
a4b9eaf3ec alpha: Don't use the GClosure to compute the alpha when possible
Setting up the call and calling the GClosure was showing up in profiles
and seemed an easy one to remove.

Instead of calling the closure, let's remember the alpha func and the
user_data when possible (ie set_mode() and set_func()) and use it in
get_alpha().

https://bugzilla.gnome.org/show_bug.cgi?id=654727
2011-07-18 15:17:15 +01:00
Damien Lespiau
4d58534fbb text: Fix the default value of "editable"
The "editable" property is documented to default to TRUE, but is
initialized to FALSE in the _init() function.

Third party code would be affected if we changed the default to be
TRUE, so we have to change the default value in the GParamSpec.

https://bugzilla.gnome.org/show_bug.cgi?id=654726
2011-07-18 13:57:44 +01:00
Emmanuele Bassi
e25e48efb3 Do not use return with void functions
https://bugzilla.gnome.org/show_bug.cgi?id=654718
2011-07-18 13:53:16 +01:00
Emmanuele Bassi
1402c05112 timeline: Cast elapsed time before emitting ::new-frame
When emitting a new-frame signal, priv->elapsed_time is passed as a
parameter. This is a gint64. The closure marshal uses an INT. On some
platforms, this is not received correctly by signal handlers (they
receive 0). One solution is to cast priv->elapsed_time to a gint when
emitting the signal.

We cannot change the signature of the signal without breaking ABI.

https://bugzilla.gnome.org/show_bug.cgi?id=654066
2011-07-18 13:45:55 +01:00
Bastian Winkler
c9cbe58343 snap-constraint: Fix allocation for CLUTTER_SNAP_EDGE_RIGHT
Use source_with instead of source_height to calculate the the x1/x2
positions for CLUTTER_SNAP_EDGE_RIGHT

https://bugzilla.gnome.org/show_bug.cgi?id=654024
2011-07-18 13:43:29 +01:00
Emmanuele Bassi
bc1c3e003d x11/event: Avoid compiler warnings with HAVE_XGE undefined 2011-07-15 16:08:38 +01:00
Emmanuele Bassi
538559391c actor: Plug a leak in an error path
If the meta for the animation property is not found, the name of the
property to look for is still from the token, and we need to free the
memory allocated for it.
2011-07-15 15:53:55 +01:00
Carlos Garnacho
075a4ed86c x11: Improve XGenericEventCookie data allocation
https://bugzilla.gnome.org/show_bug.cgi?id=654656

Clutter may be used together with GTK+, which indirectly may use
XInput2 too, so the cookie data must persist when both are handling
events.

What happens now in a nutshell is, Clutter is only guaranteed to allocate
the cookie itself after XNextEvent(), and only frees the cookie if its
XGetEventData() call allocated the cookie data.

The X[Get|Free]EventData() calls happen now in clutter-event-x11.c as
hypothetically different event translators could also handle other set
of X Generic Events, or other libraries handling events for that matter.
2011-07-15 13:46:33 +02:00
Robert Bragg
c6a0427c69 pick: Use Cogl API not GL API to disable dithering
When picking we need to disable dithering to be sure that the hardware
will not modify the colors we use as actor identifiers. Clutter was
manually calling glEnable/Disable GL_DITHER to handle this, but that was
a layering violation since Cogl is intended to handle all interactions
with OpenGL. Since we are now striving for GL vs GLES to be a runtime
choice we need to remove this last direct usage of GL from Clutter so it
doesn't have to be linked with GL at build time.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-07-14 13:54:16 +01:00
Robert Bragg
3183240fef Provide stable paint-boxes for fixed sized actors
This updates _clutter_paint_volume_get_stage_paint_box to try and
calculate more stable paint-box sizes for fixed sized paint-volumes by
not basing the size on the volume's sub-pixel position.

So the aim is that for a given rectangle defined with floating point
coordinates we want to determine a stable quantized size in pixels that
doesn't vary due to the original box's sub-pixel position.

The reason this is important is because effects will use this API to
determine the size of offscreen framebuffers and so for a fixed-size
object that may be animated across the screen we want to make sure that
the stage paint-box has an equally stable size so that effects aren't
made to continuously re-allocate a corresponding fbo.

The other thing we consider is that the calculation of this box is
subject to floating point precision issues that might be slightly
different to the precision issues involved with actually painting the
actor, which might result in painting slightly leaking outside the
user's calculated paint-volume. This patch now adds padding to consider
this too.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-07-14 13:54:12 +01:00
Robert Bragg
df751a8a25 actor: improve rounding in get_allocation_geometry
Instead of relying on C to round the floating point allocation to
integers by flooring the values we now use CLUTTER_NEARBYINT to round
the allocation's position and size to the nearest integers instead. Using
floor leads to rather unstable rounding for the width and height when
there may be tiny fluctuations in the floating point width/height.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-07-14 13:54:09 +01:00
Robert Bragg
32487af55b Adds a CLUTTER_NEARBYINT macro for float rounding
This is a replacement for the nearbyint function which always rounds to
the nearest integer. nearbyint is a C99 function so it might not always
be available but also it seems in glibc it is defined as a function call
so this macro could end up faster anyway. We can't just add 0.5 because
it will break for negative numbers.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-07-14 13:54:05 +01:00
Robert Bragg
ad234b303c paint-volume: don't round paint-volume from allocation
The implementation of _clutter_actor_set_default_paint_volume which
simply uses the actor's allocation to determine a paint-volume was
needlessly using the allocation rounded to integers by internally using
clutter_actor_get_allocation_geometry instead of
clutter_actor_get_allocation_box. This was introducing a lot of
instability into the paint-volume due to the way rounding was done.

The code has now been updated to use clutter_actor_get_allocation_box
so we are dealing with the floating point allocation instead.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-07-14 13:54:01 +01:00
Tomeu Vizoso
01cf70594d Make sure the gesture is cancelled even if we miss the release event 2011-07-14 13:11:12 +02:00
Tomeu Vizoso
439c7e6ee7 Remove unneeded class closure 2011-07-14 11:46:12 +02:00
Emmanuele Bassi
18b3da95ef osx: Code style cleanups 2011-07-13 19:33:11 +01:00
Tomeu Vizoso
c8e3db105c Add default closures for the signals in ClutterGestureAction
Also make sure we cancel the gesture as soon as we know we have to
2011-07-13 19:15:20 +02:00
Dinh Bowman
48426c28bf Fixed typo of bidng to bind
https://bugzilla.gnome.org/show_bug.cgi?id=654103
2011-07-13 15:19:22 +01:00
Emmanuele Bassi
9a3b97b55e Revert "build: Detect the appropriate default flavour"
Ouch, butterfingers and git commit -a.

This reverts commit 81e8c8dec9.
2011-07-13 14:26:05 +01:00
Emmanuele Bassi
81e8c8dec9 build: Detect the appropriate default flavour
If we're building on/for Windows, set 'win32' as the default flavour; if
we're building on OS X, set 'osx' as the default flavour. For everything
else, use 'glx'.
2011-07-13 14:20:47 +01:00
Neil Roberts
a72237b876 clutter-stage: Add clutter_stage_get_redraw_clip_bounds
This adds a public function to get the bounds of the current clipped
redraw on a stage. This should only be called while the stage is being
painted. The function diverts to a virtual function on the
ClutterStageWindow implementation. If the function isn't implemented
or it returns FALSE then the entire stage is reported. The clip bounds
are in integer pixel coordinates in the stage's coordinate space.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2421
2011-07-13 13:54:50 +01:00
Damien Lespiau
25a7435a86 uprof: Add the units in the name of the "Per Frame" timer attribute
So it shows up in the profile report. Take the opportunity to write a
better long description for the attribute.

https://bugzilla.gnome.org/show_bug.cgi?id=654363
2011-07-12 10:57:18 +01:00
Robert Bragg
ab6be41ea0 build: update cogl_onscreen_x11 syms to cogl_x11_onscreen
Cogl recently renamed symbols with the form
cogl_onscreen_<platform>_blah to be consistent with other platform
specific APIs so they are now named like cogl_<platform>_onscreen_blah.
This makes the corresponding change to clutter.
2011-07-11 16:59:26 +01:00
Robert Bragg
d182d5a171 backend-cogl: update _get_egl_context symbol name
Cogl changed has changed the name of cogl_context_egl_get_egl_context to
cogl_egl_context_get_egl_context to be consistent with other platform
specific symbols.
2011-07-11 16:59:26 +01:00
Robert Bragg
71d0872b76 don't call cogl_set_default_context since it's been removed
cogl_set_default_context has been removed from Cogl so this updates
Clutter in-line with that change.
2011-07-11 16:59:26 +01:00
Damien Lespiau
c17ddfd6a9 uprof: Rename timers to remove the EGL specific bits
Cogl abstracts the winsys, Remove the egl prefix from the timer names.

https://bugzilla.gnome.org/show_bug.cgi?id=654361
2011-07-11 01:53:53 +01:00
Emmanuele Bassi
5d10a7141c text: Make sure that the selection box is big enough
Do not use integers to store the result of the PANGO_UNITS scaling to
avoid rounding issues with the default C rules. We should use cielf()
instead.
2011-07-10 10:24:40 +01:00
Emmanuele Bassi
f6cdeb9858 osx: Fix a compiler warning
No declaration after statement.
2011-07-10 10:12:08 +01:00
Emmanuele Bassi
96440acffe texture: Deprecate the new_from_actor() function
Now that we have proper offscreen and shader handling using the
ClutterEffect API, we can finally deprecate this hard to bind, easy
to break function.
2011-07-08 12:08:19 +01:00
Emmanuele Bassi
e677ebc3e8 Deprecate ClutterScore
The class is of dubious utility, now that we have a complex animation
API in ClutterAnimator and ClutterState, as opposed to a simple one
in ClutterBehaviour. The Score API also suffers from some naïve design
issues that made it far less useful than intended.
2011-07-08 12:01:08 +01:00
Philippe Normand
eb28d16300 a11y: cally-text get_offset_at_point implementation
See http://bugzilla.clutter-project.org/show_bug.cgi?id=1733
2011-07-06 17:05:49 +02:00
Philippe Normand
7565fcaab0 a11y: cally-text get_character_extents implementation
See http://bugzilla.clutter-project.org/show_bug.cgi?id=1733
2011-07-06 16:56:30 +02:00
Philippe Normand
61ea64c8c1 a11y: expose _cally_actor_get_top_level_origin in cally-actor-private
As this function is needed for atktext get_character_extents and
get_offset_at_point implementations.
2011-07-06 16:55:55 +02:00
Philippe Normand
ae0aa9e4cf a11y: get_default_attributes implementation on cally-text
See http://bugzilla.clutter-project.org/show_bug.cgi?id=1733
2011-07-06 16:51:49 +02:00
Philippe Normand
11efaf8297 a11y: use actor color if no fgcolor found in pango attributes 2011-07-06 16:44:40 +02:00
Philippe Normand
49d4317420 a11y: factor some PangoAttributes->AtkTextAttributes mappings
That code can then be used by get_run_attributes and
get_default_attributes implementations.
2011-07-06 16:34:36 +02:00
Alejandro Piñeiro
7e9ee85c7d [a11y] Exposing via ATK the proper toolkit name and version 2011-07-06 14:25:02 +02:00
Neil Roberts
bd3762b719 clutter-actor: Don't apply shaders during picking
Commit 0ede622f51 inadvertently made it so that shaders are applied
during picking. This was making test-shader fail to respond to clicks.

The commit also makes it so that culling is applied during
picking. Presumably this is also unintentional because the commit
message does not mention it. However I think it may make sense to do
culling during picking so it might as well stay that way.

https://bugzilla.gnome.org/show_bug.cgi?id=653959
2011-07-05 13:30:42 +01:00
Emmanuele Bassi
87f35a3434 build: Fix the path to the tslib event source 2011-07-04 16:09:41 +01:00
Samuel Degrande
2544e87869 clutter-media: mention the asynchronous behavior of set_playing() in the doc.
Depending on the ClutterMedia implementation, the set_playing()
call can be asynchronous, the playing state's change being not
immediate.

https://bugzilla.gnome.org/show_bug.cgi?id=650675
2011-07-04 15:58:08 +01:00
Jasper St. Pierre
037138d3bf clutter-text: Always update cursor positions when painting
The cursor's on-screen rectangle is defined in terms of the text
length, the current index, and text_x and text_y, which hold the text
offset in overflowing text fields.

When deleting large amounts of text, text_x is set to 0. In some
edge case branch paths, the cursor rectangle could be calculated
after the current index and text length were updated, but before
the text_x offset could be. This left a negative x position, which
consequently blew up Cogl and the widget.

https://bugzilla.gnome.org/show_bug.cgi?id=651079
2011-07-04 15:58:08 +01:00
Emmanuele Bassi
e9a42f23fe Deprecate mallum's add() macros for Group and Stage
I think we're way past overdue.
2011-07-04 15:58:08 +01:00
Robert Bragg
d65161a7fd build: fix Makefile.am to build glx tfp code on x11 platforms
It was already the intention that the ClutterGLXTexturePixmap API should
be built and made available on any X11 based platforms since there was
nothing specific about the API and it is useful to have for
compatibility. There was a mistake in the Makefile.am though which meant
only the header was getting installed but the code wasn't being built.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-07-04 15:41:38 +01:00
Robert Bragg
5ab10e0f7a glx-tfp: Don't include glx.h
Since the implementation of ClutterGLXTexturePixmap has nothing GLX
specific about it (it is simply layered on top of
ClutterX11TexturePixmap) we don't need to include glx.h. Removing this
include also means that the code can be built for compatibility against
GLES drivers.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-07-04 15:41:38 +01:00
Peter Ward
c94e8d1292 Arrays in parameters were not correctly annotated.
https://bugzilla.gnome.org/show_bug.cgi?id=653607
2011-07-01 12:32:19 +01:00
Robert Bragg
8bc265d22c paint-volume: remove more is_axis_aligned assertions
This removes the is_axis_aligned assertions for the width/height/depth
getters and setters, since for example it is legitimate to query the
width, height or depth of a container's child actors which aren't
necessarily axis aligned.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-06-30 14:53:40 +01:00
Robert Bragg
cc5808387e backend-cogl: update in line with Cogl API change
cogl_renderer_xlib_set_foreign_display was renamed to
cogl_xlib_renderer_set_foriegn_display so this is the corresponding
change to clutter.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-06-30 14:53:40 +01:00
Robert Bragg
aacdbb4a55 win32: use typesafe cogl_win32_renderer_handle_event
The generic cogl_renderer_handle_native_event API was removed from the
Cogl public API in favour of typesafe functions, so this updates the
win32 backend in line with that change.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-06-30 14:53:40 +01:00
Peter Ward
2dc8e2f866 Annotate ClutterTexture::load-finished with the correct type for error.
https://bugzilla.gnome.org/show_bug.cgi?id=653307
2011-06-27 11:49:19 +01:00
Emmanuele Bassi
478014041b build: Create and install clutter-glx pkg-config file
For backward compatibility.
2011-06-24 19:22:22 +01:00
Peter Ward
2528ad8cb8 Support multiple pointers in ClutterDragAction.
https://bugzilla.gnome.org/show_bug.cgi?id=653066
2011-06-21 18:29:01 +01:00
Emmanuele Bassi
459e1e7fc9 docs: Fix the GLX section
The whole thing should just go away.
2011-06-20 19:45:14 +01:00
Emmanuele Bassi
f3f1c87d8c docs: Fix deprecation notice for ClutterBehaviour 2011-06-20 19:44:55 +01:00
Emmanuele Bassi
513f218c38 docs: Add the Deprecate tag to Behaviours
And link the migration guide.
2011-06-20 18:46:48 +01:00
Emmanuele Bassi
7b064a0bda build: Build the GLX symbols
The change from the GLX backend to the Cogl backend left out the GLX
source code from the list of source files to be built.
2011-06-20 18:26:34 +01:00
Emmanuele Bassi
71b6554176 Fix the deprecation guard for ClutterGLXTexturePixmap
It's CLUTTER_DISABLE_DEPRECATED.
2011-06-20 18:22:06 +01:00
Emmanuele Bassi
e5641dabf8 docs: Document ClutterDropAction
And add it to the API reference.

https://bugzilla.gnome.org/show_bug.cgi?id=652842
2011-06-20 15:25:54 +01:00
Emmanuele Bassi
1238e0ddf9 Add ClutterDropAction
ClutterDropAction is an Action sub-class that allows writing actors that
react to dragged actors being dropped on them.

https://bugzilla.gnome.org/show_bug.cgi?id=652842
2011-06-20 15:25:53 +01:00
Emmanuele Bassi
a6a57d7967 drag-action: Remove the drag handle on destruction
When the drag handle actor is destroyed we should unset the field inside
the DragAction, to avoid having stale pointers lying around.

https://bugzilla.gnome.org/show_bug.cgi?id=652842
2011-06-20 14:31:07 +01:00
Emmanuele Bassi
0dea846096 drag-action: Use the dragged actor private API
Use the newly added private API on ClutterStage to track the currently
dragged actor.

https://bugzilla.gnome.org/show_bug.cgi?id=652842
2011-06-20 14:31:07 +01:00
Emmanuele Bassi
530a13f02f stage: Allow tracking dragged actors
We should be able to internally attach the actor currently being dragged
to the device that is dragging it.

https://bugzilla.gnome.org/show_bug.cgi?id=652842
2011-06-20 14:31:07 +01:00
Emmanuele Bassi
e4756fd764 docs: Fix up the API reference 2011-06-20 14:26:57 +01:00
Emmanuele Bassi
d5ea422c8f stage: Maintain the motion event delivery invariants
It is possible, by calling clutter_set_motion_events_enabled() prior to
the creation of any stage, to control the per-actor motion event
delivery flag on each newly created stage. Since we deprecated the
global accessor functions in favour of the per-Stage ones, we need to
remove the call to clutter_get_motion_events_enabled() inside the
ClutterStage instance initialization, and replace it with an internal
function.

This code will go away when we can finally break API and remove the
deprecated functions.
2011-06-20 13:53:09 +01:00
Emmanuele Bassi
b6eb5728e1 stage: Make per-actor motion event delivery accessors public
Complete the quest of commit bc548dc862
by making the ClutterStage methods for controlling the per-actor motion
and crossing event delivery public, and deprecating the global ones.
2011-06-20 11:41:28 +01:00
Robert Bragg
b66c22ac1c actor: documents _get/apply_relative_transform_matrix
Although this patch doesn't make them public, it documents the
_clutter_actor_get/apply_relative_transform_matrix functions so they
could easily be made public if desired. I think these API could be
useful to have publicly, and I originally documented them because I
thought they would be needed in the MX toolkit.
2011-06-17 18:38:29 +01:00
Neil Roberts
87d55ffcfa actor: Don't use propagated_one_redraw to determine effect dirty state
Previously ClutterActor was using priv->propagated_one_redraw to
determine whether to pass CLUTTER_EFFECT_PAINT_ACTOR_DIRTY to the
paint method of the effect. This isn't a good idea because the
propagated_one_redraw flag is cleared whenever clutter_actor_paint is
called, even if the actor isn't actually painted because of the zero
opacity shortcut. Instead of this, ClutterActor now has a separate
flag called is_dirty that gets set whenever queue_redraw_full is
called or whenever the queue redraw signal is bubbled up from a child
actor. The flag is only cleared in clutter_actor_paint if the effects
are actually run. Therefore it will stay set even if the opacity is
zero or if the parent actor decides not to paint the child.

Previously there were two places set propagated_one_redraw to FALSE -
once if the opacity is zero and once just before we emit the paint
signal.  Now that propagated_one_redraw is only used to determine
whether to pass on the queue redraw signal it seems to make sense to
just clear it in one place right at the start of clutter_actor_paint.

https://bugzilla.gnome.org/show_bug.cgi?id=651784
2011-06-17 18:06:51 +01:00
Robert Bragg
1720b77d29 actor: review use of _apply_modelview_transform_recursive
On reviewing the clutter-actor.c code using
_apply_modelview_transform_recursive I noticed various comments stating
that it will never call the stage's ->apply_transform vfunc to transform
into eye coordinates, but actually looking at the implementation that's
not true. The comments probably got out of sync with an earlier
implementation that had that constraint. This removes the miss-leading
comments and also updates various uses of the api where we were manually
applying the stage->apply_transform.
2011-06-17 17:44:16 +01:00
Robert Bragg
ddc9eb5fa5 group: Handle list modification while destroying children
This makes the dispose code that destroys children resilient against
priv->children being modified during child destruction.
2011-06-17 17:23:32 +01:00
Robert Bragg
1741c805be debug: Use cogl_primitive api for paint-volume visualization
Instead of using the cogl_vertex_buffer API this uses the more concise
cogl_primitive API instead. The aim is to get rid of the
cogl_vertex_buffer API eventually so we should be trying out the
replacement API wherever possible.
2011-06-17 16:59:20 +01:00
Robert Bragg
7f64772984 debug: disable culling with CLUTTER_PAINT=paint-volumes
When using CLUTTER_PAINT=paint-volumes to visualize the paint-volumes of
actors we were already disabling clipped-redraws because we are drawing
extra geometry that the actors don't know about but we didn't disable
culling. This was resulting in actors disappearing while using this
debug option.
2011-06-17 16:58:36 +01:00
Robert Bragg
d7bf214397 debug: avoid visualization code during picking
This makes sure we don't try and draw paint-volumes or culling results
during a pick cycle since that results in us reading back invalid ids
from the pick-buffer.
2011-06-17 16:58:36 +01:00
Neil Roberts
1e2e0f21b8 clutter-actor: Add a debug flag for disabling offscreen redirect
This adds CLUTTER_PAINT=disable-offscreen-redirect to help diagnose
problems with the correct opacity changes. This just makes it so that
it never installs the flatten effect so it will never automatically
redirect an actor offscreen.
2011-06-17 12:15:19 +01:00
Emmanuele Bassi
78fbac71f2 keysyms: Update the key symbols
Re-sync with the X.org headers.
2011-06-17 12:14:15 +01:00
Emmanuele Bassi
c79f613c25 Remove an unused variable
And the compiler warning that comes with it.
2011-06-17 12:03:21 +01:00
Robert Bragg
e936b9591a paint-volumes: remove is_axis_aligned assert for _union
This removes the pv->is_xis_aligned assertion in
_clutter_paint_volume_union. We were already considering the case where
the second volume may not be axis aligned and aligning it into a
temporary variable in that case, but we now also consider that the first
pv may also not be aligned.
2011-06-16 15:28:23 +01:00
Robert Bragg
4dc30c255f paint-volumes: avoid is_complete assert in _axis_align
The removes the pv->is_complete assertion from
_clutter_paint_volume_axis_align() and instead if the volume isn't
complete it calls _clutter_paint_volume_complete().
2011-06-16 15:28:23 +01:00
Robert Bragg
923b1657d9 paint-volumes: fix unioning with empty volumes
When calculating the union of a volume with an empty volume we aim to
simply take the contents of the non-empty volume, but we were not
copying the flags across. We now use
_clutter_paint_volume_set_from_volume which copies all the flags except
the is_static flag.
2011-06-16 12:40:22 +01:00
Robert Bragg
394512b274 paint-volumes: remove alignment constraint for _set_origin
The implementation for clutter_paint_volume_set_origin can cope with
volumes that are not axis aligned so this remove the is_axis_aligned
assertion.
2011-06-16 12:40:22 +01:00
Robert Bragg
30eb3be781 paint-volumes: avoid trashing is_static state
In _clutter_paint_volume_set_from_volume we were using memcpy to simply
copy everything from one volume to another, but that meant we were
trashing the is_static flag which determines if the destination
paint-volume was slice allocated or not.
2011-06-16 12:40:11 +01:00
Robert Bragg
a9789616b9 paint-volumes: remove alignment constraint for completion
This removes the constraint that a paint-volume must be axis aligned
before _clutter_paint_volume_complete can be called. NB: A paint volume
is represented by one origin vertex and then three axis vertices to
define the width, height and depth of the volume. It's straightforward
to use the vectors from the origin to the axis vertices to deduce the
other 4 vertices so we can remove the is_axis_aligned assertion.
2011-06-16 12:39:51 +01:00
Robert Bragg
34600949ed clutter-stage: Allow a wider range of visible z values
Since eef9078f the translation of the camera away from the z=zero
plane was hardcoded at 50 which is approximately half way between the
default z_near and z_far values. This ended up with quite a small
distance in user-space coordinates to the far plane with the default
stage size and this was causing test-texture-quality to clip the actor
early.

This patch makes it try to calculate a reasonable value for the
position of the z=0 plane as well as a value for z_far so we maximize
the space in between the z=0 plane and the near plane and we have a
predictable amount of space behind the stage before hitting the far
clipping plane, while considering the trade off of loosing depth
precision by pushing the far plane too far back relative to the near
plane.

With the default fov of 60° it's not possible to use the stage size to
define the gap in-front of the stage plane; only ~87% of the stage size
is possible as an upper limit. We make 85% of the stage_height available
assuming you have a fov of 60°. We consistently provide 10 times the
stage height of space behind the stage regardless of the fov.

It seems worth noting here that we went around in circles a few times
over how to calculate the gaps since there are a number of trade offs to
consider and they also affect the complexity of the solution. In the end
we went for simplicity but commented the issues well enough hopefully so
we can develop a more elaborate solution if we ever have a use-case.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2625
2011-06-15 18:17:06 +01:00
Neil Roberts
2022e4c100 clutter-stage: Don't override the user's perspective matrix
Since eef9078f ClutterStage updates the aspect ratio of the
perspective matrix whenever the size of the stage changes. This meant
that if an application tries to set its own perspective matrix then
part of it would get overridden. It's not really clear what the
use-case of setting the perspective on the stage should be but it
seems like the safest bet is to always try to preserve the
application's request. The documentation for the function has been
tweaked to discourage its use.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2625
2011-06-15 18:03:53 +01:00
Robert Bragg
d90c849e80 make some parts of the stage-window interface optional
Some parts of the StageWindow interface aren't meaningful for all window
systems. This makes stage_window_set_title/fullscreen/cursor_visible
optional instead of requiring those window systems to implement empty
stubs. Notably the empty stubs we had in the Cogl backend (previously
the EGL backend) used g_warning to report the feature as unsupported and
that was causing conformance test failures.
2011-06-15 15:46:38 +01:00
Emmanuele Bassi
fa8e6d368a Do not include clutter-egl.h unconditionally 2011-06-15 13:05:18 +01:00
Robert Bragg
6a73cece71 backend-cogl: fix s/egl/cogl/ naming left-over 2011-06-15 12:43:47 +01:00
Robert Bragg
b3c93bca20 build: Adds missing clutter-glx.h 2011-06-15 12:41:17 +01:00
Robert Bragg
dd02c56bdb build: Adds missing clutter-egl-headers.h 2011-06-15 12:40:02 +01:00
Robert Bragg
2d8083bab8 unify egl and glx backends as "cogl" backend
Since GLX and EGL are abstracted by Cogl the two backends are both
implementing everything using the Cogl API and they are almost
identical.

This updates the egl backend to support everything that the glx backend
supports. Now that EGL and GLX are abstracted by Cogl, the plan is that
we will squash the clutter-egl/glx backends into one. Since the EGL
backend in clutter can conditionally not depend on X11 we will use the
EGL backend as the starting point of our common backend.

https://bugzilla.gnome.org/show_bug.cgi?id=649826
2011-06-14 20:35:18 +01:00
Robert Bragg
951cb82ec5 egl: fix args to cogl_onscreen_x11_set_foreign_window_xid
We hadn't updated the egl backend inline with a change to the arguments
that cogl_onscreen_x11_set_foreign_window_xid would expect and that was
causing a compilation error.
2011-06-14 20:19:27 +01:00
Emmanuele Bassi
05bcd40729 stage: Ignore do_update() on unrealized stages
An unrealized stage has no resources set yet, so we might as well skip
it during the master clock spin.

https://bugzilla.gnome.org/show_bug.cgi?id=652566
2011-06-14 16:11:54 +01:00
Emmanuele Bassi
81e9bf6127 backend: Do not call ensure_context() with NULL stage
Always call ensure_context() if we have a valid Stage.

https://bugzilla.gnome.org/show_bug.cgi?id=652566
2011-06-14 15:55:06 +01:00
Emmanuele Bassi
0b20739232 glx: Ignore ensuring context on NULL stages
https://bugzilla.gnome.org/show_bug.cgi?id=652566
2011-06-14 15:55:06 +01:00
Emmanuele Bassi
a7fc76a1c5 build: Disable deprecated symbols during development cycles
And add a configure switch to toggle them.
2011-06-14 14:50:10 +01:00
Emmanuele Bassi
4382e6588c glx: Remove unused Atom members from ClutterBackendGLX
The atoms were moved to the shared X11 backend structure ages ago.
2011-06-14 11:36:01 +01:00
Colin Walters
b046bc354c ClutterModifierType: Port fix from GDK to clutter's GDK copy
See https://bugzilla.gnome.org/show_bug.cgi?id=634994 where GDK was
modified to include all flag values, which helps bindings.  Port this
fix to Clutter's copy of GDK.

https://bugzilla.gnome.org/show_bug.cgi?id=650329
2011-06-14 00:05:33 +01:00
Philippe Normand
494629d4b9 clutter-text: new clutter_text_get_layout_offsets API
This new function can be used to retrieve the coordinates where the
ClutterText will draw the PangoLayout representing the text.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2553
2011-06-13 16:15:22 +01:00
Emmanuele Bassi
74a9b71060 effect: Rename RunFlags to PaintFlags
Since run() was replaced and both paint() and pick() use the
enumeration.

https://bugzilla.gnome.org/show_bug.cgi?id=651700
2011-06-13 16:00:45 +01:00
Tomeu Vizoso
0ede622f51 Give a chance to effects for running when picking
Some effects can change the actor's shape and position, so they need
to run when picking.

https://bugzilla.gnome.org/show_bug.cgi?id=651700
2011-06-13 15:45:36 +01:00
Tomeu Vizoso
700c543850 Rename ClutterEffect::run to ClutterEffect::paint
In preparation for adding ClutterEffect::pick

https://bugzilla.gnome.org/show_bug.cgi?id=651700
2011-06-13 15:44:58 +01:00
Emmanuele Bassi
165b2f9599 docs: Fix Clutter API reference 2011-06-13 15:36:07 +01:00
Emmanuele Bassi
cd2b36ed91 Merge branch 'swipe-action'
* swipe-action:
  test-swipe-action: Clean up the test code
  docs: Add the new actions to the API reference
  gesture-action: Remove the multi-device entry points
  swipe-action: Remove the required devices call
  swipe-action: Clean up
  gesture-action: Clean up
  Add ClutterSwipeAction and ClutterGestureAction
2011-06-13 14:39:03 +01:00
Emmanuele Bassi
4f0769d69d docs: Update missing documentation 2011-06-13 13:47:09 +01:00
Emmanuele Bassi
8625f07c3b script: Plug a leak
The SignalInfo structure gained a couple of string fields that should be
deallocated when destroying the structure.
2011-06-13 13:47:09 +01:00
Emmanuele Bassi
a9dd5abfcc script: Allow warping to states
Do not just allow animating states connected to signals: add a "warp"
optional key that ends up calling clutter_state_warp_to_state(). This
is useful for debugging.
2011-06-13 13:47:09 +01:00
Emmanuele Bassi
3017a48228 Skip introspection for GValue ↔ CoglFixed API
It's pointless to introspect an API that it's not meant to be used
through introspection.
2011-06-13 13:47:09 +01:00
Emmanuele Bassi
d9c1a2ebbb script: Use a weak ref to remove the signal emission hook
When an object goes away we should remove the emission hook for the
state transitions, to avoid leaving hooks around.
2011-06-13 13:47:09 +01:00
Emmanuele Bassi
b33973f9f8 script: Rename "state" → "states"
Make it clear that the key used when defining a state-based signal is
linked to the states of a ClutterState.
2011-06-13 13:47:08 +01:00
Emmanuele Bassi
29d7c5a297 script: Allow resolving signals states added from code
Currently, defining states for object signals can only be done by
defining a ClutterState inside the ClutterScript definition. We should
allow creating a (named) ClutterState in code, and associating it to a
ClutterScript instance — and have the Script resolve the "state" field
of a signal definition correctly.
2011-06-13 13:47:08 +01:00
Emmanuele Bassi
dd8cf63a62 script: Allow connecting signal to ClutterState states
One of the uses of a ClutterState state machine along with ClutterScript
is to provide a quick way to transition from state to state in response
to signal emitted on specific instances.

Connecting a real function, in code, to a specific signal does not
improve the ease of use of ClutterScript to define scenes.

By adding a new signal definition to the current one we can have both a
simple way to define application logic in code and in the UI definition
file.

The new syntax is trivial:

  {
    "name" : <signal name>,
    "state" : <state machine script id>,
    "target-state" : <target state>
  }

The ClutterState instance is identified by its script id, and the target
state is resolved at run-time, so it can be defined both in
ClutterScript or in code. Ideally, we should find a way to associate a
default ClutterState instance to the ClutterScript one that parses the
definition; this way we would be able to remove the "state" member, or
even "style" the behaviour of an object by replacing the ClutterState
instance.

The implementation uses a signal emission hook, to avoid knowing the
signal signature; we check the emitter of the signal against the object
that defined the signal, to avoid erroneous state changes.
2011-06-13 13:47:08 +01:00
Robert Bragg
7b4f7cd3e0 build: include <cairo.h> not <cairo/cairo.h>
cairo.h is intended to be included as <cairo.h> not <cairo/cairo.h> as
is the style for clutter.h. If you have installed cairo to a custom
prefix then using cairo/cairo.h can result in unintentional use of the
system cairo headers, or if they aren't installed then it will result in
a failure to find the header.
2011-06-10 17:57:18 +01:00
Emmanuele Bassi
2c791da70a gesture-action: Remove the multi-device entry points
GestureAction supports a single device/touch point. We'll need touch
events supported in Clutter before adding the ability to set required
device/touch points on gestures.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2585
2011-06-10 15:15:15 +01:00
Emmanuele Bassi
f9ce901496 swipe-action: Remove the required devices call
The SwipeAction requires one device/touch point, and that is the default
for GestureAction — if GestureAction supported multiple devices/touch
points.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2585
2011-06-10 15:15:15 +01:00
Emmanuele Bassi
11d961b605 swipe-action: Clean up
Clean up the documentation, and use a type safe GFlags marshaller for
the ::swept signal's @direction argument - instead of a generic integer
marshaller.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2585
2011-06-10 15:15:15 +01:00
Emmanuele Bassi
0058c78b79 gesture-action: Clean up
The GestureAction is marked as abstract, but it has a constructor. It
should be possible to create simple gesture recognizers through signal
handling alone, so we might as well have GestureAction be a concrete
class from the start.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2585
2011-06-10 15:15:15 +01:00
Tomeu Vizoso
ba72235b66 Add ClutterSwipeAction and ClutterGestureAction
To allow actors to handle gestures in a more organized way.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2585
2011-06-10 14:02:17 +01:00
Neil Roberts
d151d789f6 clutter-text: Use the ink rect in the paint volume
Previously ClutterText was just reporting the allocation as the paint
volume. The preferred size of a ClutterText is just the logical
rectangle of the layout. A pango layout can sometimes draw outside of
its logical rectangle for example with an italicised font with large
serifs. Additionally, ClutterText doesn't make any attempt to clip the
text if the actor gets allocated a size too small for the text so it
would also end up drawing outside of the paint volume in that case. To
fix this, the paint volume is now reported as the ink rect of the
Pango layout. The rectangle for the cursor and selection is also
unioned into that because it won't necessarily be within the ink
rectangle.

The function for drawing the selection rectangles has been split up
into a generic function that calculates the rectangles that need to be
drawn and a function that draws them. That way the get_paint_volume
virtual can share the code to calculate the rectangles.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2599
2011-06-10 14:02:07 +01:00
Neil Roberts
a20a8071ed clutter-text: Don't move the cursor to the left when at pos 0
When the cursor is at the leftmost position in the text the drawn
pixel position is moved to the left by the size of the cursor. There's
no explanation for why this happens and it doesn't seem to make any
sense so this patch removes it. It makes multi-line texts looks odd
because the cursor ends up at a different horizontal position when it
is on the first line from any other line. It also makes using
priv->cursor_pos difficult in any other part of the code because the
paint function modifies it.

The original patch that added this can be traced back to Tidy commit
c356487c15. There's no explanation in the commit message either.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2599
2011-06-10 13:07:11 +01:00
Emmanuele Bassi
46cab9c8c6 event: Add clutter_event_set_source() declaration
The function was defined but not declared in the header.
2011-06-09 15:40:26 +01:00
Emmanuele Bassi
b91ec2a82e Fix deprecation guards for ClutterGLXTexturePixmap 2011-06-09 15:28:39 +01:00
Emmanuele Bassi
23a9980c72 click-action: Add support for long press detection
A long press is a special form of click action; the default
implementation uses a single signal with multiple states: query, action
and cancel. On click we use the "query" state to check whether the
ClutterClickAction supports long presses; if the callback returns TRUE
then we install a timeout and we either emit the "activate" state when
the timeout expires or we emit the "cancel" state if the pointer leaves
the actor, or if the pointer moves outside a certain threshold. If the
long press reached the "activate" state then we skip the clicked signal
emission.
2011-06-09 15:12:41 +01:00
Emmanuele Bassi
93207d08f8 settings: Add the :long-press-duration
A property to control the minimum time that has to elapse before a press
is recognized as a long press. This will be used by ClutterClickAction,
but it can be shared across touch-based gestures.
2011-06-09 14:43:34 +01:00
Emmanuele Bassi
2b81d90dd7 Eliminate G_CONST_RETURN
The G_CONST_RETURN define in GLib is, and has always been, a bit fuzzy.

We always used it to conform to the platform, at least for public-facing
API.

At first I assumed it has something to do with brain-damaged compilers
or with weird platforms where const was not really supported; sadly,
it's something much, much worse: it's a define that can be toggled at
compile-time to remove const from the signature of public API. This is a
truly terrifying feature that I assume was added in the past century,
and whose inception clearly had something to do with massive doses of
absynthe and opium — because any other explanation would make the
existence of such a feature even worse than assuming drugs had anything
to do with it.

Anyway, and pleasing the gods, this dubious feature is being
removed/deprecated in GLib; see bug:

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

Before deprecation, though, we should just remove its usage from the
whole API. We should especially remove its usage from Cally's internals,
since there it never made sense in the first place.
2011-06-07 16:06:24 +01:00
Tomeu Vizoso
e636a0bbce Sync allocation in ClutterBoxLayout with the one in GtkBox
https://bugzilla.gnome.org/show_bug.cgi?id=650487

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-06-07 14:43:52 +01:00
Craig R. Hughes
9ecddeb1c3 osx: Handle bare modifier keypresses
http://bugzilla.clutter-project.org/show_bug.cgi?id=2644
2011-06-07 14:39:01 +01:00
Emmanuele Bassi
22cc9b35cb stage: Bail out of do_update() when no impl is set
If the Stage has been destroyed the StageWindow implementation is not
going to be available, but the IN_DESTRUCTION flag will have already
been cleared.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2656
2011-06-07 14:34:19 +01:00
Emmanuele Bassi
19c986c0c6 actor: Avoid queueing redraws during destruction
If an actor or the stage to which it belongs are being destroyed then
there is no point in queueing a redraw that will not be seen anyway.
Bailing out early also avoids the case in which a redraw is queued
during destruction wil cause redraw entries will be added to the Stage,
which will take references on it and cause the Stage never to be
finalized.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2652
2011-06-07 14:25:17 +01:00
Emmanuele Bassi
835fc2381c Deprecate ClutterShader
With the instantiatable ClutterShaderEffect, the only reason for
ClutterShader to exist is to make the ClutterActor::paint implementation
miserable.

Yes, ClutterShader doesn't use a FBO, so it's "more efficient" on
ClutterTextures. It's also generally wrong unless you know *exactly* how
the actor's pipeline is set up — something we cannot even guarantee
internally unless we start doing lame type checks.
2011-06-07 14:09:53 +01:00
Emmanuele Bassi
53483896a8 shader-effect: Allow instantiating ShaderEffect
ClutterShaderEffect doesn't require to be sub-classed in order to be
useful. It is possible to just create an instance, set the source and
the uniforms, and attach it to an actor. This should effectively replace
ClutterShader for good.
2011-06-07 14:09:53 +01:00
Alexandre Franke
1a85b87fc9 Fix typo 2011-06-02 22:16:45 +02:00
Robert Bragg
588d97c2c7 culling: Use vertex_count not '4' to determine partial culls
We were mistakenly using the constant 4 to determine the number of
vertices that need to be culled for a paint-volume to be considered
fully culled too. This is only ok for 2d volumes and was resulting in
some 3d volumes being considered culled whenever 4 out of 8 vertices
were culled. This fix is simply to reference the vertex_count variable
instead of assuming 4.
2011-06-02 21:02:11 +01:00
Øyvind Kolås
ba8cc8e064 stage: ensure correct stage is current when picking
_clutter_stage_do_pick called by interactive picking and
clutter_stage_get_actor_at_pos could be accidentally reading back the wrong
actor id's if an other stage has had a more recent render due to animation.

This should resolve some multi stage / ClutterGtk related pick id warnings.
2011-06-01 22:46:26 +01:00
Emmanuele Bassi
eed1744612 stage: Use the debug name for the pick buffer dump stem
This avoids overwriting files in the multi-stage case.
2011-06-01 18:34:09 +01:00
Peter Ward
c836b8c53c device: Prevent segfault
When disposing a slave device without a master.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2655
2011-05-31 11:57:20 +01:00
Dan Winship
e83a7851ad clutter-id-pool: fix warning on bad pick
Commit 13ac1fe7 purported to extend the _clutter_id_pool_lookup()
warning to the case where the id referred to a deleted actor, but did
not actually do so, because _clutter_id_pool_remove() set deleted IDs
to 0xdecafbad, not NULL. Fix this.

https://bugzilla.gnome.org/show_bug.cgi?id=650597
2011-05-26 08:48:13 -04:00
Alejandro Piñeiro
46aadb745b [cally] Removed default actions on CallyActor 2011-05-21 00:55:01 +02:00
Alejandro Piñeiro
d007155ac4 [cally] CallyRoot is the parent of any CallyStage object
http://bugzilla.clutter-project.org/show_bug.cgi?id=2597
2011-05-20 14:18:09 +02:00
Alejandro Piñeiro
58adcb4022 [cally] Added old cally Changelog (pre clutter-cally merge)
http://bugzilla.clutter-project.org/show_bug.cgi?id=2484
2011-05-20 14:13:14 +02:00
Alejandro Piñeiro
153532297c [cally] Removing default name and description
Those were added on the old "just for automatic testing" times. That was
somewhat silly on that moment. Now is just silly (ie: having the stage
returning as default name "Stage").

The real description should be set by the app, or provided by the
context of a specific actor feature (like the tooltip on StWidget).

The current information provided by the default description can be
mostly obtained from the ATK_ROLE, and the indirect debugging
advantage of having always a meaningful description is just not enough
to justify them, and you can solve that by proper debug logging.

Fixes: http://bugzilla.clutter-project.org/show_bug.cgi?id=2482
2011-05-20 14:07:47 +02:00
Tomeu Vizoso
e59fff7a3f clutter-offscreen-effect: use target size when setting up the viewport
https://bugzilla.gnome.org/show_bug.cgi?id=650650
2011-05-20 13:27:01 +02:00
Neil Roberts
7d233241f1 Fix include location for cogl-pango.h
In Cogl, cogl-pango.h has moved to <cogl-pango/cogl-pango.h>. When
using the experimental 2.0 API (which Clutter does) it is no longer
possible to include it under the old name of <cogl/cogl-pango.h> so we
need to update the include location.
2011-05-16 16:04:27 +01:00
Chris Lord
f9d7650b97 actor: Ensure the validity of the queue_redraw_entry pointer
In _clutter_actor_queue_redraw_with_clip, there was the possibility that
the actor will add itself to the stage's redraw queue without keeping track
of the allocated list member.

In clutter_actor_unparent, the redraw queue entry was being invalidated
before the mapped notify signal was being fired, meaning that queueing a
redraw of an unmapped actor in the mapped notification callback could
cause a crash.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2621
2011-05-14 01:14:22 +01:00
Emmanuele Bassi
ba4615cd4b text: Check the has_focus flag in selection_paint()
It is the only place were it is used, so it should only be checked
there, and not in the general paint() implementation.
2011-05-13 15:44:08 +01:00
Emmanuele Bassi
729e9985c1 text: Implement the ::has_overlaps virtual
Since ClutterText has overlapping primitives when selecting, or a
visible cursor, then we need to report that to Clutter, to avoid
bleeding colors through when a Text actor is non-fully opaque.
2011-05-13 15:44:08 +01:00
Jasper St. Pierre
94c9c07509 clutter-text: Add a selected-text-color
http://bugzilla.clutter-project.org/show_bug.cgi?id=2595
2011-05-13 15:44:08 +01:00
Neil Roberts
d95258e987 clutter-actor: Store the queue_redraw_entry when queueing a redraw
_clutter_stage_queue_actor_redraw returns a pointer to the
ClutterStageQueueRedrawEntry struct which it allocates. The actor is
expected to store a pointer to this so that it doesn't need to search
the list of queued redraws next time a queue redraw is called. However
_clutter_actor_queue_redraw_full wasn't storing this pointer which
meant that it thought every queue redraw was the first queue
redraw. That meant that queueing a redraw with a clip or an effect
would override any previous attempts to queue a redraw instead of
trying to combine them.

I think this happened because the old queue_redraw_with_clip also
didn't store the pointer and queue_redraw_full was based on that.
2011-05-13 15:36:38 +01:00
Neil Roberts
701440efd8 clutter-actor: Add a 'has_overlaps' virtual
This adds a virtual to ClutterActor so that an actor subclass can
report whether it has overlapping primitives. ClutterActor uses this
to determine whether it needs to use ClutterFlattenEffect to implement
the opacity property. The default implementation of the virtual
returns TRUE which means that most actors will end up being redirected
offscreen when the opacity != 255. ClutterTexture and ClutterRectangle
override this to return FALSE because they should never need to be
redirected. ClutterClone overrides it to divert to the source.

The values for the ClutterOffscreenRedirect enum have changed to:

AUTOMATIC_FOR_OPACITY

 The actor will only be redirected if has_overlaps returns TRUE and
 the opacity is < 255

ALWAYS_FOR_OPACITY

 The actor will always be redirected if the opacity < 255 regardless
 of the return value of has_overlaps

ALWAYS

 The actor will always be redirected offscreen.

This means that the property can't be used to prevent the actor from
being redirected but only to increase the likelihood that it will be
redirected.

ClutterActor now adds and removes the flatten effect depending on
whether flattening is needed directly in clutter_actor_paint(). There
are new internal versions of add/remove_effect that don't queue a
redraw. This means that ClutterFlattenEffect is now just a no-op
subclass of ClutterOffscreen. It is only needed because
ClutterOffscreen is abstract. Removing the effect also makes it so
that the cached image will be freed as soon as an actor is repainted
without being flattened.
2011-05-13 01:46:32 +01:00
Neil Roberts
7f78237ee5 clutter-actor: Add an 'offscreen-redirect' property
This adds a property which can be used to redirect the actor through
an FBO before painting so that it becomes flattened in an image. The
image can be used as a cache to avoid having to repaint the actor if
something unrelated in the scene changes. It can also be used to
implement correct opacity even if the actor has overlapping
primitives. The property is an enum that takes three values:

CLUTTER_OFFSCREEN_REDIRECT_NEVER: The default behaviour which is to
  never flatten the actor.

CLUTTER_OFFSCREEN_REDIRECT_ALWAYS: The actor is always redirected
  through an FBO.

CLUTTER_OFFSCREEN_REDIRECT_ONLY_FOR_OPACITY: The actor is only
  redirected through an FBO if the paint opacity is not 255. This
  value would be used if the actor wants correct opacity. It will
  avoid the overhead of using an FBO whenever the actor is fully
  opaque.

The property is implemented by installing a ClutterFlattenEffect.
ClutterFlattenEffect is a new internal class which subclasses
ClutterOffscreen to redirect the painting to an FBO. When
ClutterOffscreen paints, the effect sets an opacity override on the
actor so that the image will always contain the actor at full
opacity. The opacity is then applied to the resulting image before
painting it to the stage. This means the actor does not need to be
redrawn while the opacity is being animated.

The effect has a high internal priority so that it will always occur
before any other effects and it gets hidden from the application.
2011-05-13 01:46:32 +01:00
Neil Roberts
8df8d4ff0f clutter-actor: Redraw or relayout when clearing effects or constraints
When calling clutter_actor_clear_constraints the layout of the actor
may change so we need to queue a relayout. Similarly when the effects
are cleared we need to queue a redraw.
2011-05-13 01:46:32 +01:00
Neil Roberts
9423214783 clutter-actor-meta: Add an internal 'priority' property
This adds a priority property to all ClutterActorMetas. The
ClutterMetaGroup keeps the list sorted so that higher priority metas
remain at the beginning of the list. The priority is a signed integer
with the default as zero. An actor meta can therefore be put before
all default metas with a positive number, or after with a negative
number.

There are constants to set an 'internal' priority. The intention is
that applications wouldn't be allowed to use these values so that we
can keep special internal metas to that are before or after all
application metas.

The property isn't a real GObject property because for now it is
completely internal and only used to implement the 'transparency'
property of ClutterActor. ClutterMetaGroup doesn't currently resort
the list if the property changes so if we wanted to make it public we
should either make it construct-only or make the meta group listen for
changes on the property and resort accordingly.

The methods in ClutterActor that get the list of metas now use a new
function that filters out internal metas from the meta
group. Similarly for clearing the metas, the internal metas are left
in.
2011-05-13 01:46:32 +01:00
Neil Roberts
00b733a85a clutter-effect: Add clutter_effect_queue_rerun
This adds a new public function to queue a rerun of an effect. If
nothing else queues a redraw then when the effect's actor is painted
the effect will be run without the CLUTTER_EFFECT_RUN_ACTOR_DIRTY
flag. This allows parametrised offscreen effects to report that they
need to redraw the image without having to redraw the underlying
actor. This will be used to implement the 'transparency' effect of
ClutterActor.

If multiple redraws are queued with different effects then redrawing
is started from the one that occurs last in the list of effects.

Internally the function is a wrapper around the new function
_clutter_actor_queue_redraw_full. This is intended to be the sole
point of code for queuing redraws on an actor. It has parameters for
the clip and the effect. The other two existing functions to queue a
redraw (one with a clip and one without) now wrap around this function
by passing a NULL effect.
2011-05-13 01:46:32 +01:00
Neil Roberts
11443ed480 clutter-offscreen-effect: Don't redraw the actor if cached offscreen
When painting an actor, it now tries to determine if the last paint of
the offscreen was using the same matrix and the actor isn't dirty. If
so, it can skip calling clutter_actor_continue_paint and avoid
actually painting the actor. Instead just the offscreen image will be
painted.
2011-05-13 01:46:32 +01:00
Neil Roberts
c3aa4d24bf clutter-effect: Add a 'run' virtual
This adds a new virtual to ClutterEffect which is intended to be a
more flexible replacement for the pre and post_paint functions. The
implementation of a run virtual would look something like this:

void
effect_run (ClutterEffect *effect,
            ClutterEffectRunFlags flags)
{
  /* Set up state */
  /* ... */

  /* Chain to the next item in the paint sequence */
  clutter_actor_continue_paint (priv->actor);

  /* Clean up state */
  /* ... */
}

ClutterActor now just calls this virtual instead of the pre_paint and
post_paint functions. It keeps track of the next effect in the list so
that it knows what to do when clutter_actor_continue_paint is
called. clutter_actor_continue_paint is a new function added just for
implementing effects.

The default implementation of the run virtual just calls pre_paint and
post_paint so that existing effects will continue to work.

An effect is allowed to conditionally skip calling
clutter_actor_continue_paint(). This is useful to implement effects
that cache the image of an actor. The flags parameter can be used to
determine if the actor is dirty since the last paint. ClutterActor
sets this flag whenever propagated_one_redraw is TRUE which means that
a redraw for this actor or one of its children was queued.
2011-05-13 01:46:31 +01:00
Neil Roberts
f5ace7b2a5 win32: Use the Cogl WGL winsys
Cogl now has a full WGL winsys so Clutter doesn't need to directly
deal with WGL itself.
2011-05-10 17:06:33 +01:00
Emmanuele Bassi
043f804452 Make the pick id pool per Stage
The id pool used for the actor's id should be a per-stage field. At some
point, we might have a Stage mapped to multiple framebuffers, or each
Stage mapped to a different framebuffer; also, on backend with low
color precision we don't want to exhaust the size of the available ids
with a global pool. Finally, it's yet another thing we can remove from
the global Clutter context.

Having the id pool allocated per-stage, and the pick id assigned on
Actor:mapped will make the whole pick-id more reliable and future proof.

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

https://bugzilla.gnome.org/show_bug.cgi?id=647876
2011-05-06 17:47:41 +01:00
Emmanuele Bassi
f6e6c803d9 Deprecate actor id
The actor's id, which is currently used to generate the pick color,
should not be part of the public API: it's an internal detail of the
pick implementation, and having it exposed is like punching a hole
through the abstraction.

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

https://bugzilla.gnome.org/show_bug.cgi?id=647876
2011-05-06 17:47:41 +01:00
Emmanuele Bassi
ea502fd492 build: Depend on cogl-pango-1.0
For both builds and introspection.
2011-05-06 17:21:00 +01:00
Emmanuele Bassi
21786cccd6 build: Fix introspection rules
Remove some cruft after the surgery that split Cogl out of tree.
2011-05-06 16:55:10 +01:00
Robert Bragg
589c80e41e Remove last dependency on the GdkPixbuf API
In test-pixmap.c instead of using the GdkPixbuf API to load the
redhand.png image we now use the cairo API to load the png into a xlib
surface which wraps our Pixmap.

This test was the last thing that depended on the gdk API and since
it's more concise to use Cairo here which is a hard dependency for
Clutter this change means we avoid depending on GdkPixbuf directly.
2011-05-06 15:44:13 +01:00
Robert Bragg
223e14811c Removes Cogl from the repository
Cogl has now been split out into a standalone project with a separate
repository at git://git.gnome.org/cogl. From now on the Clutter build
will now simply look for a cogl-1.0 pkg-config file to find a suitable
Cogl library to link against at build time.
2011-05-06 15:44:08 +01:00
Emmanuele Bassi
00f2a39ac5 stage: Use Cairo to dump the pick buffer
Do not use GdkPixbuf just for getting image data down into a PNG; Cairo
is perfectly capable of doing the same, at least just for debugging
purposes.

https://bugzilla.gnome.org/show_bug.cgi?id=647875
2011-05-06 15:06:07 +01:00
Emmanuele Bassi
3a071a4787 cairo-texture: Make the pixel order macro public
It stands to reason that any piece of code using Cairo and Cogl at the
same time, and dealing with texture data, will want to use the same
logic Clutter uses to determine the compatible pixel format between the
two.

https://bugzilla.gnome.org/show_bug.cgi?id=647875
2011-05-06 15:06:06 +01:00
Neil Roberts
6d9458debb cogl-debug: Add an option to disable atlasing sharing
If COGL_DEBUG contains disable-shared-atlas Cogl will not try to share
the atlas between glyphs and images.
2011-05-05 16:17:08 +01:00
Neil Roberts
77cd2ca08e cogl_pipeline_equal: Handle COGL_WRAP_MODE_AUTOMATIC better
When comparing the wrap modes of two pipeline layers it now considers
COGL_WRAP_MODE_AUTOMATIC to be equivalent to CLAMP_TO_EDGE. By the
time the pipeline is in the journal, the upper primitive code is
expected to have overridden this wrap mode with something else if it
wants any other behaviour. This is important for getting text to batch
together with textures because the text explicitly sets the wrap mode
to CLAMP_TO_EDGE on its pipeline.
2011-05-05 16:14:45 +01:00
Neil Roberts
41e464fc9e cogl-pango: Don't set the special combine function for atlased textures
The material cache will now only set the special combine mode if the
texture only has an alpha component. The atlased textures will have
all four components so it will leave the combine functions at the
default. This increases the chances of batching between glyphs and
images.

When using the global atlas, the glyph from cairo is now rendered into
an ARGB surface rather than an alpha-only surface.
2011-05-05 16:14:45 +01:00
Neil Roberts
9083fc8e1f cogl-pango: Use a seperate cache of pipelines
Instead of creating just two materials (one for texturing and one for
solid primitives) the pango renderer now maintains a cache of
pipelines. The display list can request a pipeline for a texture from
the cache. The same pipeline cache is used by all display lists so
that the pipelines can be shared. This avoids changing the texture on
the material during a paint run.
2011-05-05 16:14:25 +01:00
Neil Roberts
22ce8a7111 cogl-pango-glyph-cache: Don't put zero-sized glyphs in the cache
It now avoids trying to reserve space for zero-sized glyphs. That
happens for example when the layout contains a space. This was causing
the regular glyph cache to be used because the global atlas does not
support zero-sized images. That would then break up the
batching. Instead it now still reserves an entry in the cache but
leaves the texture as COGL_INVALID_HANDLE.
2011-05-05 16:10:17 +01:00
Neil Roberts
0c755f6909 Revert "cogl-pango-display-list: Don't use VBOs if the texture can't handle it"
This reverts commit 32c91793e4.

This commit is no longer needed since the display list will now only
have primitive textures in it.
2011-05-05 16:09:22 +01:00
Neil Roberts
9cb45144a8 cogl-pango-render: Add the base texture to the display list
When rendering a glyph from a texture, instead of adding the glyph's
texture handle to the display list it now retrieves the base texture
using _cogl_texture_foreach_subtexture_in_region and adds that
instead. That way the display can recognise that glyphs in the global
atlas are sharing the same texture and combine them into one VBO.
2011-05-05 16:09:01 +01:00
Neil Roberts
22649b810f cogl-bitmap-private.h: Include cogl-bitmap.h
There was a header dependency problem which meant that
cogl-texture-private.h couldn't be included without first including
cogl-bitmap.h
2011-05-05 16:09:01 +01:00
Neil Roberts
d0a615e17b cogl-pango-glyph-cache: Notify of reorg for global atlased glyphs
Whenever the glyph cache puts a glyph in the global atlas it will now
register for notifications of reorganisation of the global
atlases. When this happens it will forward this on as a notification
of reorganisation of the glyph cache.
2011-05-05 16:09:01 +01:00
Neil Roberts
241c3c0d43 cogl-atlas-texture: Add a callback for when any atlas reorganizes
This adds cogl_atlas_texture_* functions to register a callback that
will get invoked whenever any of the CoglAtlas's the textures use get
reorganized. The callback is global and is not tied to any particular
atlas texture.
2011-05-05 16:09:01 +01:00
Neil Roberts
e3c57941bd pango-glyph-cache: Try to put glyphs in the global atlas
If mipmapping is disabled, it will now try to create a standalone
atlas texture for a glyph rather than putting it in the atlas.

If the atlas texture can't be created then it will fallback to the
glyph cache.
2011-05-05 16:09:01 +01:00
Neil Roberts
9aaaee0308 cogl-atlas-texture: Split out new_from_bitmap to new_with_size
This adds a new function called _cogl_atlas_texture_new_with_size. The
old new_from_bitmap function now just calls this and updates the
texture with the data.
2011-05-05 16:09:01 +01:00
Neil Roberts
32c91793e4 cogl-pango-display-list: Don't use VBOs if the texture can't handle it
If the texture can't be hardware repeated (ie, if it is sliced or it
has waste) then Cogl will reject the layer when rendering with a
VBO. In this case we should always fall back to rendering with
cogl_rectangle.

This commit is only needed temporarily because Cogl will end up
putting atlas textures in the display list. A later commit in the
series will make it so that the display list always has primitive
textures in it so this commit can be reverted.
2011-05-05 16:06:45 +01:00
Neil Roberts
51eec9bf53 cogl-pango: Use a separate glyph cache for mipmapped rendering
This reverts the changes in 54d8aadf which combined the two glyph
caches into one. We want to start using separate caches again so that
we can non-mipmapped textures into the global atlas.
2011-05-05 15:29:01 +01:00
Robert Bragg
4d3bf09e60 Adds a way for Cogl to control event_mask of foreign wins
This extends cogl_onscreen_x11_set_foreign_xid to take a callback to a
function that details the event mask the Cogl requires the application
to select on foreign windows. This is required because Cogl, for
example, needs to track size changes of a window and may also in the
future want other notifications such as map/unmap.

Most applications wont need to use the foreign xwindow apis, but those
that do are required to pass a valid callback and update the event mask
of their window according to Cogl's requirements.
2011-05-05 15:05:42 +01:00
Robert Bragg
50d688399b Adds cogl_onscreen_show/hide functions
This adds Cogl API to show and hide onscreen framebuffers. We don't want
to go too far down the road of abstracting window system APIs with Cogl
since that would be out of its scope but the previous idea that we would
automatically map framebuffers on allocation except for those made from
foreign windows wasn't good enough. The problem is that we don't want to
make Clutter always create stages from foreign windows but with the
automatic map semantics then Clutter doesn't get an opportunity to
select for all the events it requires before mapping. This meant that we
wouldn't be delivered a mouse enter event for windows mapped underneath
the cursor which would break Clutters handling of button press events.
2011-05-05 15:05:42 +01:00
Robert Bragg
53395e732e add missing name mangle for cogl_onscreen_set_swap_throttled
We weren't mangling cogl_onscreen_set_swap_throttled to give it an _EXP
postfix to clarify that it is an experimental symbol.
2011-05-05 15:05:42 +01:00
Robert Bragg
06c64adb57 Add missing _cogl_winsys_has_feature prototype
This adds a private prototype for _cogl_winsys_has_feature in
cogl-winsys-private.h to avoid compilation warnings.
2011-05-05 15:05:42 +01:00
Robert Bragg
89fd655a9e cogl/pango/Makefile.am pass EXTRA_LDFLAGS for linking
When building on windows for example we need to ensure we pass
-no-undefined to the linker. Although we were substituting a
COGL_EXTRA_LDFLAGS variable from our configure.ac we forgot to
reference that when linking cogl-pango.
2011-05-05 15:05:42 +01:00
Robert Bragg
f2cd2d8be8 cogl/configure.ac: AC_SUBST an empty MAINTAINER_CFLAGS
For compatibility with the way we build Cogl as part of Clutter we now
substitute an empty MAINTAINER_CFLAGS variable. When building Cogl
standalone all our extra CFLAGS go through COGL_EXTRA_CFLAGS so the
separate MAINTAINER_CFLAGS aren't used, but automake will get confused
if a substitution isn't made.
2011-05-05 15:05:42 +01:00
Robert Bragg
a8e497e647 cogl/configure.ac: check when building for win32
This adds a check for when building on win32 so we can skip pkg-config
checks for opengl and can add appropriate flags to
COGL_EXTRA_{LD,C}FLAGS.
2011-05-05 15:05:42 +01:00
Robert Bragg
2303e4d603 cogl/configure.ac: fix pkg-config checks
This fixes the gdk-pixbuf check to not mistakenly check for the "xi"
package instead of gdk-pixbuf and remove a spurious listing "gl" in
COGL_PKG_REQUIRES which should only be there when we are using using
opengl not if we are using gles.
2011-05-05 15:05:41 +01:00
Robert Bragg
8bde73529f cogl/Makefile.am: pass EXTRA_LDFLAGS for linking
When building on windows for example we need to ensure we pass
-no-undefined to the linker. Although we were substituting a
COGL_EXTRA_LDFLAGS variable from our configure.ac we forgot to
reference that when linking cogl.
2011-05-05 15:05:41 +01:00
Robert Bragg
7a3d06c55c cogl: remove OSX/WIN32 specific bits in favour of a stub winsys
Until Cogl gains native win32/OSX support this remove the osx and win32
winsys files and instead we'll just rely on the stub-winsys.c to handle
these platforms. Since the only thing the platform specific files were
providing anyway was a get_proc_address function; it was trivial to
simply update the clutter backend code to handle this directly for now.
2011-05-05 15:05:41 +01:00
Robert Bragg
3d0a853c6f cogl-gl.c: remove really_enable_npot hack for OSX
This is a workaround for a bug on OSX for some radeon hardware that
we can't verify and the referenced bug link is no longer valid.

If this is really still a problem then a new bug should be opened and we
can look at putting the fix in some more appropriate place than
cogl-gl.c
2011-05-05 15:05:41 +01:00
Robert Bragg
723e5de4b6 cogl/configure.ac: Adds --enable-stub-winsys option
We want to be able to split Cogl out as a standalone project but there
are still some window systems that aren't natively supported by Cogl.
This allows Clutter to support those window systems directly but still
work with a standalone Cogl library.

This also ensures we set the SUPPORT_STUB conditional in clutter's
configure.ac when building for win32/osx and wayland.
2011-05-05 15:05:11 +01:00
Robert Bragg
799caeb588 winsys-glx: map X window automatically if not foreign
For now we are going for the semantics that when a CoglOnscreen is first
allocated then it will automatically be mapped. This is for convenience
and if you don't want that behaviour then it is possible to instead
create an Onscreen from a foreign X window and in that case it wont be
mapped automatically.

This approach means that Cogl doesn't need onscreen_map/unmap functions
but it's possible we'll decide later that we can't avoid adding such
functions and we'll have to change these semantics.
2011-05-05 14:46:03 +01:00
Robert Bragg
27770b913f cogl/configure.ac: make COGL_HAS_xyz defines public
Instead of using AC_DEFINE for the various COGL_HAS_PLATFORM defines
this now adds them to the COGL_DEFINES_SYMBOLS variable which gets
substituted into the public cogl-defines.h header.
2011-05-05 14:46:03 +01:00
Robert Bragg
136cf1b2d6 clutter/Makefile.am: mark clutter-cex100.h as BUILT_SOURCES
clutter-xcex100.h is generated from clutter-cex100.h.in when running
./configure so it should be added to automake's BUILT_SOURCES variable.
2011-05-05 14:46:03 +01:00
Robert Bragg
825a51b898 Adds Cogl Hello World and "X11 foreign" example applications
This adds a simple standalone Cogl application that can be used to
smoke test a standalone build of Cogl without Clutter.

This also adds an x11-foreign app that shows how a toolkit can ask Cogl
to draw to an X Window that it owns instead of Cogl being responsible
for automatically creating and mapping an X Window for CoglOnscreen.
2011-05-05 14:46:03 +01:00
Robert Bragg
1c502fbbc8 cogl/configure.ac: add options to control driver/egl platform
This allows more detailed control over the driver and winsys features
that Cogl should have. Cogl is designed so it can support multiple
window systems simultaneously so we have enable/disable options for
the drivers (gl vs gles1 vs gles2) and options for the individual window
systems; currently glx and egl. Egl is broken down into an option
for each platform.
2011-05-05 14:46:03 +01:00
Robert Bragg
e26a59afc8 EGL: Updates GDL platform support
The GDL API is used for example on intel ce4100 (aka Sodaville) based
systems as a way to allocate memory that can be composited using the
platforms overlay hardware. This updates the Cogl EGL winsys and the
support in Clutter so we can continue to support these platforms.
2011-05-05 14:46:02 +01:00
Robert Bragg
7f76ea2690 Don't reference GL_STACK_OVERFLOW/UNDERFLOW for GLES
These symbols aren't available when building with GLES so only reference
them when building with OpenGL.
2011-05-05 14:46:02 +01:00
Robert Bragg
fd42800d00 winsys: Expose environment variable to choose winsys
This makes it possible to override the winsys that cogl uses by setting
the COGL_RENDERER environment variable e.g. to "GLX" or "EGL"
2011-05-05 14:46:01 +01:00
Robert Bragg
75e6d734c1 Add a vtable of indirection to the winsys code
So that we can dynamically select what winsys backend to use at runtime
we need to have some indirection to how code accesses the winsys instead
of simply calling _cogl_winsys* functions that would collide if we
wanted to compile more than one backend into Cogl.
2011-05-05 14:46:01 +01:00
Robert Bragg
91bf1e24d4 texture-pixmap-x11: Move GLX code to cogl-winsys-glx.c
This moves the GLX specific code from cogl-texture-pixmap-x11.c into
cogl-winsys-glx.c. If we want the winsys components to by dynamically
loadable then we can't have GLX code scattered outside of
cogl-winsys-glx.c. This also sets us up for supporting the
EGL_texture_from_pixmap extension which is almost identical to the
GLX_texture_from_pixmap extension.
2011-05-05 14:46:01 +01:00
Robert Bragg
c55cffbb6b Moves all EGL code down from Clutter to Cogl
As was recently done for the GLX window system code, this commit moves
the EGL window system code down from the Clutter backend code into a
Cogl winsys.

Note: currently the cogl/configure.ac is hard coded to only build the GLX
winsys so currently this is only available when building Cogl as part
of Clutter.
2011-05-05 14:46:01 +01:00
Robert Bragg
ce0dc2160c remove references to unused DRM_SURFACELESS EGL platform
The "DRM_SURFACELESS" EGL platform was invented when we were adding the
wayland backend to Clutter but in the end we added a dedicated backend
instead of extending the EGL backend so actually the platform name isn't
used.
2011-05-05 14:46:01 +01:00
Neil Roberts
c383fdeeae cogl-context: Initialize context->stub_winsys
If Cogl is built using a full Winsys then it wasn't initialising
context->stub_winsys which sometimes made it crash later on.
2011-04-21 16:45:21 +01:00
Neil Roberts
b5279ed027 cogl-winsys-stub: Remove _cogl_winsys_has_feature
Commit b061f737 moved _cogl_winsys_has_feature to the common winsys
code so there's no need to define it in the stub winsys any more. This
was breaking builds for backends using the stub winsys.
2011-04-20 18:43:02 +01:00
Neil Roberts
66f22cfd60 cogl-winsys-glx: Fix the comparison in find_onscreen_for_xid
The comparison for finding onscreen framebuffers in
find_onscreen_for_xid had a small thinko so that it would ignore
framebuffers when the negation of the type is onscreen. This ends up
doing the right thing anyway because the onscreen type has the value 0
and the offscreen type has the value 1 but presumably it would fail if
we ever added any other framebuffer types.
2011-04-20 18:20:25 +01:00
Neil Roberts
49233af465 clutter-backend-glx: Protect against unrefing the Cogl context twice
The dispose function may be called multiple times during destruction
so it needs to be resilient against destroying any resources
twice. This wasn't the case for the reference to the Cogl context.
2011-04-20 18:20:20 +01:00
Neil Roberts
b061f73702 cogl-winsys: Move _cogl_winsys_has_feature to cogl-winsys.c
The code for _cogl_winsys_has_feature will be identical in all of the
winsys backends for the time being, so it seems to make sense to have
it in the common cogl-winsys.c file.
2011-04-20 18:20:20 +01:00
Neil Roberts
28c4a02191 cogl-context: Store winsys features in an array of unsigned ints
Previously the mask of available winsys features was stored in a
CoglBitmask. That isn't the ideal type to use for this because it is
intended for a growable array of bits so it can allocate extra memory
if there are more than 31 flags set. For the winsys feature flags the
highest used bit is known at compile time so it makes sense to
allocate a fixed array instead. This is conceptually similar to the
CoglDebugFlags which are stored in an array of integers with macros to
test a bit in the array. This moves the macros used for CoglDebugFlags
to cogl-flags.h and makes them more generic so they can be shared with
CoglContext.
2011-04-20 18:20:10 +01:00
Neil Roberts
d5022054eb cogl-renderer: Move the XEvent filters to be generic for all renderers
Instead of having cogl_renderer_xlib_add_filter and friends there is
now cogl_renderer_add_native_filter which can be used regardless of
the backend. The callback function for the filter now just takes a
void pointer instead of an XEvent pointer which should be interpreted
differently depending on the backend. For example, on Xlib it would
still be an XEvent but on Windows it could be a MSG. This simplifies
the code somewhat because the _cogl_xlib_add_filter no longer needs to
have its own filter list when a stub renderer is used because there is
always a renderer available.

cogl_renderer_xlib_handle_event has also been renamed to
cogl_renderer_handle_native_event. This just forwards the event on to
all of the listeners. The backend renderer is expected to register its
own event filter if it wants to process the events in some way.
2011-04-20 18:17:06 +01:00
Emmanuele Bassi
8816730081 evdev: Remove unused variable 2011-04-18 16:24:27 +01:00
Emmanuele Bassi
1b17ca5d8f cogl/glx: Silence a compiler warning 2011-04-18 15:53:25 +01:00
Emmanuele Bassi
57ebce8039 animation: Use ::destroy with animate()
ClutterAnimation uses the weak ref machinery of GObject when associated
to ClutterActor by clutter_actor_animate() and friends - all the while
taking a reference on the actor itself. In order to trigger the weak ref
callback, external code would need to unref the Actor at least twice,
which has slim chance of happening. Plus, the way to destroy an Actor is
to call destroy(), not call unref().

The destruction sequence of ClutterActor emits the ::destroy signal, which
should be used by classes to release external references the might be
holding. My oh my, this sounds *exactly* the case!

So, let's switch to using the ::destroy signal for clutter_actor_animate()
and friends, since we know that the object bound to the Animation is
an Actor, and has a ::destroy signal.

This change has the added benefit of allowing destroying an actor as the
result of the Animation::completed signal without getting a segfault or
other bad things to happen.

Obviously, the change does not affect other GObject classes, or Animation
instances created using clutter_animation_new(); for those, the current
"let's take a reference on the object to avoid it going away in-flight"
mechanism should still suffice.

Side note: it would be interesting if GObject had an interface for
"destructible" objects, so that we could do a safe type check. I guess
it's a Rainy Day Project(tm)...
2011-04-16 10:22:01 +01:00
Emmanuele Bassi
b01cbbb8c3 actor: Use _clutter_actor_meta_get_debug_name()
The ActorMeta name can be more informative than just the GType class
name.
2011-04-15 13:43:15 +01:00
Emmanuele Bassi
a5315de133 actor-meta: Add a get_debug_name() private method
Similar to ClutterActor's own get_debug_name().
2011-04-15 13:42:45 +01:00
Emmanuele Bassi
e467ad5ad1 Use the actor's debug name consistently
Do not use the generic GType class name: we have a :name property on
ClutterActor that is generally used for debugging purposes — so we
should use it when creating debugging spew in a consistent way.
2011-04-14 18:04:39 +01:00
Emmanuele Bassi
3889272f52 glx: Chain up in ::unrealize()
And avoid a segmentation fault on stage destruction if the main loop
keeps running.
2011-04-14 18:04:39 +01:00
Emmanuele Bassi
94c30a4f67 x11: Provide a StageWindow::unrealize implementation
The Cogl rework removed the Window creation from realize and its
relative destruction from unrealize; the two vfuncs also managed
the mapping between Window and Stage implementation that we use
when dealing with event handling. Sadly, the missing unrealization
left entries in the mapping dangling.

Since ClutterStageX11 already provides a ::realize implementation
that sub-classes are supposed to chain up to, and the Window ↔ Stage
mapping is private to clutter-stage-x11.c, it seems only fair that
the ClutterStageX11 should also provide an ::unrealize implementation
matching the ::realize.

This implementation just removes the StageX11 pointer from the X11
Window ↔ ClutterStageX11 mapping we set up in ::realize, since the
X11 Window is managed by Cogl, now.
2011-04-14 18:00:07 +01:00
James Athey
b80d5c8142 GL_IMG_TEXTURE_NPOT extension enables TEXTURE_NPOT features on GLES
Older drivers for PowerVR SGX hardware have the vendor-specific
GL_IMG_TEXTURE_NPOT extension instead of the
functionally-equivalent GL_OES_TEXTURE_NPOT extension.
2011-04-13 14:34:31 +01:00
James Athey
3d3ae619c6 determine evdev device type using g_udev_device_has_property
http://bugzilla.clutter-project.org/show_bug.cgi?id=2631
2011-04-12 21:15:50 +01:00
James Athey
aa4ff0b90f uniquely name and enable evdev ClutterInputDevice objects on creation
http://bugzilla.clutter-project.org/show_bug.cgi?id=2631
2011-04-12 21:15:48 +01:00
Emmanuele Bassi
a5fd1612f5 Silence another compiler warning 2011-04-12 21:02:14 +01:00
Emmanuele Bassi
6277c3d5a3 Silence the compiler by removing unused variables 2011-04-12 20:37:22 +01:00
Emmanuele Bassi
6aafb7d3de glx: Protect GLX SwapEvent symbols
We need to guard the usage of symbols related to the
GLX_INTEL_swap_event extension, to avoid breaking on platforms and/or
versions of Mesa that do not expose that extension.
2011-04-12 20:37:22 +01:00
Emmanuele Bassi
6a0857f17d glx: Remove unused variable
Make gcc not complain about it.
2011-04-12 17:04:06 +01:00
Robert Bragg
6f69f7769f Make cogl_framebuffer_get_width/height experimental public API
It's generally useful to be able to query the width and height of a
framebuffer and we expect to need this in Clutter when we move the
eglnative backend code into Cogl since Clutter will need to read back
the fixed size of the framebuffer when realizing the stage.
2011-04-11 17:54:36 +01:00
Robert Bragg
af366ad750 backend: remove untested fruity backend
This backend hasn't been used for years now and so because it is
untested code and almost certainly doesn't work any more it would be a
burdon to continue trying to maintain it. Considering that we are now
looking at moving OpenGL window system integration code down from
Clutter backends into Cogl that will be easier if we don't have to
consider this backend.
2011-04-11 17:54:36 +01:00
Robert Bragg
70767f08dc Adds a --with-system-cogl config option for Clutter
This makes it possible to build Clutter against a standalone build of
Cogl instead of having the Clutter build traverse into the clutter/cogl
subdirectory.
2011-04-11 17:54:36 +01:00
Robert Bragg
31da46c799 Adds the ability to build Cogl standalone
This adds an autogen.sh, configure.ac and build/autotool files etc under
clutter/cogl and makes some corresponding Makefile.am changes that make
it possible to build and install Cogl as a standalone library.

Some notable things about this are:
A standalone installation of Cogl installs 3 pkg-config files;
cogl-1.0.pc, cogl-gl-1.0.pc and cogl-2.0.pc. The second is only for
compatibility with what clutter installed though I'm not sure that
anything uses it so maybe we could remove it. cogl-1.0.pc is what
Clutter would use if it were updated to build against a standalone cogl
library. cogl-2.0.pc is what you would use if you were writing a
standalone Cogl application.

A standalone installation results in two libraries currently, libcogl.so
and libcogl-pango.so. Notably we don't include a major number in the
sonames because libcogl supports two major API versions; 1.x as used by
Clutter and the experimental 2.x API for standalone applications.
Parallel installation of later versions e.g. 3.x and beyond will be
supportable either with new sonames or if we can maintain ABI then we'll
continue to share libcogl.so.

The headers are similarly not installed into a directory with a major
version number since the same headers are shared to export the 1.x and
2.x APIs (The only difference is that cogl-2.0.pc ensures that
-DCOGL_ENABLE_EXPERIMENTAL_2_0_API is used). Parallel installation of
later versions is not precluded though since we can either continue
sharing or later add a major version suffix.
2011-04-11 17:54:36 +01:00
Robert Bragg
d6f110a4d2 Moves all GLX code down from Clutter to Cogl
This migrates all the GLX window system code down from the Clutter
backend code into a Cogl winsys. Moving OpenGL window system binding
code down from Clutter into Cogl is the biggest blocker to having Cogl
become a standalone 3D graphics library, so this is an important step in
that direction.
2011-04-11 17:54:36 +01:00
Robert Bragg
aa1a2cb661 Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...

The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.

Conceptually a CoglRenderer represents a means for rendering.  Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.

Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)

Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.

CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.

The default/simple way we expect most CoglContexts to be constructed
will be via something like:

 if (!cogl_context_new (NULL, &error))
   g_error ("Failed to construct a CoglContext: %s", error->message);

Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".

If you want some more control though you can manually construct a
CoglDisplay something like:

 display = cogl_display_new (NULL, NULL);
 cogl_gdl_display_set_plane (display, plane);
 if (!cogl_display_setup (display, &error))
   g_error ("Failed to setup a CoglDisplay: %s", error->message);

And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.

If you need to change the CoglOnscreen defaults you can provide a
template something like:
  chain = cogl_swap_chain_new ();
  cogl_swap_chain_set_has_alpha (chain, TRUE);
  cogl_swap_chain_set_length (chain, 3);

  onscreen_template = cogl_onscreen_template_new (chain);
  cogl_onscreen_template_set_pixel_format (onscreen_template,
                                           COGL_PIXEL_FORMAT_RGB565);

  display = cogl_display_new (NULL, onscreen_template);
  if (!cogl_display_setup (display, &error))
    g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-04-11 17:54:35 +01:00
Robert Bragg
a90862929b rename winsys files to be more consistent
This tries to make the naming style of files under cogl/winsys/
consistent with other cogl source files. In particular private header
files didn't have a '-private' infix.
2011-04-11 17:54:35 +01:00
Robert Bragg
532b563439 Add temporary cogl-clutter.h to aid splitting out Cogl
This gives us a way to clearly track the internal Cogl API that Clutter
depends on. The aim is to split Cogl out from Clutter into a standalone
3D graphics API and eventually we want to get rid of any private
interfaces for Clutter so its useful to have a handle on that task.
Actually it's not as bad as I was expecting though.
2011-04-11 17:54:35 +01:00
Robert Bragg
8557bc3d26 actor: visualize culling with CLUTTER_PAINT=redraws
This extends visualization for CLUTTER_PAINT=redraws so it now also
draws outlines for actors to show how they are being culled. Actors get
a green outline if they are fully inside the clip region, blue if fully
outside and greeny-blue if only partially inside.
2011-04-11 17:54:35 +01:00
Robert Bragg
c739cb2809 stage: adds internal_get_active_framebuffer API
This adds an internal _clutter_stage_get_active_framebuffer function
that can be used to get a pointer to the current CoglFramebuffer pointer
that is in use, in association with a given stage.

The "active" infix in the function name is there because we shouldn't
assume that a stage will always correspond to only a single framebuffer
so we aren't getting a pointer to a sole framebuffer, we are getting
a pointer to the framebuffer that is currently in use/being painted.

This API is now used for culling purposes where we need to check if we
are currently painting an actor to a framebuffer that is offscreen, that
doesn't correspond to the stage.
2011-04-11 15:28:53 +01:00
Robert Bragg
997ea0fdee framebuffer: expose experimental cogl_get_draw_framebuffer
This renames the two internal functions _cogl_get_draw/read_buffer
as cogl_get_draw_framebuffer and _cogl_get_read_framebuffer. The
former is now also exposed as experimental API.
2011-04-11 15:28:53 +01:00
Robert Bragg
dc5aa31429 framebuffer: track context as CoglFramebuffer member
The long term goal with the Cogl API is that we will get rid of the
default global context. As a step towards this, this patch tracks a
reference back to the context in each CoglFramebuffer so in a lot of
cases we can avoid using the _COGL_GET_CONTEXT macro.
2011-04-11 15:28:47 +01:00
Robert Bragg
8177afae05 remove unused _cogl_features_init prototype
There is no corresponding implementation of _cogl_features_init any more
so it was simply an oversight that the prototype wasn't removed when the
implementation was removed.
2011-04-11 15:26:25 +01:00
Robert Bragg
e381a159a7 Remove unused _cogl_swap_buffers_notify
Recently _cogl_swap_buffers_notify was added (in 142b229c5c) so that
Cogl would be notified when Clutter performs a swap buffers request for
a given onscreen framebuffer. It was expected this would be required for
the recent cogl_read_pixel optimization that was implemented (ref
1bdb0e6e98) but in the end it wasn't used.

Since it wasn't used in the end this patch removes the API.
2011-04-11 15:26:25 +01:00
Robert Bragg
47e93d4f7b cogl: consolidate _create_context_driver + _features_init
This moves the functionality of _cogl_create_context_driver from
driver/{gl,gles}/cogl-context-driver-{gl,gles}.c into
driver/{gl,gles}/cogl-{gl,gles}.c as a static function called
initialize_context_driver.

cogl-context-driver-{gl,gles}.[ch] have now been removed.
2011-04-11 15:26:25 +01:00
Robert Bragg
c1ab28e9ad cogl: Adds experimental cogl_context_new() API
This adds a new experimental function (you need to define
COGL_ENABLE_EXPERIMENTAL_API to access it) which takes us towards being
able to have a standalone Cogl API. This is really a minor aesthetic
change for now since all the GL context creation code still lives in
Clutter but it's a step forward none the less.

Since our current designs introduce a CoglDisplay object as something
that would be passed to the context constructor this provides a stub
cogl-display.h with CoglDisplay typedef.

_cogl_context_get_default() which Clutter uses to access the Cogl
context has been modified to use cogl_context_new() to initialize
the default context.

There is one rather nasty hack used in this patch which is that the
implementation of cogl_context_new() has to forcibly make the allocated
context become the default context because currently all the code in
Cogl assumes it can access the context using _COGL_GET_CONTEXT including
code used to initialize the context.
2011-04-11 15:26:20 +01:00
Robert Bragg
6484871c6e cogl: rename cogl-context.h cogl-context-private.h
Since we plan to add public cogl_context_* API we need to rename the
current cogl-context.h which contains private member details.
2011-04-11 15:18:12 +01:00
Robert Bragg
ec0b781466 stage: Move _clutter_do_pick to clutter-stage.c
This moves the implementation of _clutter_do_pick to clutter-stage.c and
renames it _clutter_stage_do_pick. This function can be compared to
_clutter_stage_do_update/redraw in that it prepares for and starts a
traversal of a scenegraph descending from a given stage. Since it is
desirable that this function should have access to the private state of
the stage it is awkward to maintain outside of clutter-stage.c.

Besides moving _clutter_do_pick this patch is also able to remove the
following private state accessors from clutter-stage-private.h:
_clutter_stage_set_pick_buffer_valid,
_clutter_stage_get_pick_buffer_valid,
_clutter_stage_increment_picks_per_frame_counter,
_clutter_stage_reset_picks_per_frame_counter and
_clutter_stage_get_picks_per_frame_counter.
2011-04-11 14:31:31 +01:00
Robert Bragg
114133c98c paint-volume: Fix culling bug to handle partial culls
This updates the inner loops of the cull function so now the vertices of
the polygon being culled are iterated in the inner loop instead of the
clip planes and we count how many vertices are outside the current
plane so we can bail out immediately if all the vertices are outside of
any plane and so we can correctly track partial intersections with the
clip region.

The previous approach could catch some partial intersections but for
example a rectangle that was larger than the clip region centred over
the clip region with all corners outside would be reported as outside,
not as a partial intersection.
2011-04-11 14:31:31 +01:00
Neil Roberts
b36dde6193 cogl-pango-glyph-cache: Fix the flags passed to cogl_atlas_new
In 047227fb cogl_atlas_new was changed so that it can take a flags
parameter to specify whether to clear the new atlases and whether to
copy images to the new atlas after reorganisation. This was done so
that the atlas code could be shared with the glyph cache. At some
point during the development of this patch the flag was just a single
boolean instead and this is accidentally how it is used from the glyph
cache. The glyph cache therefore passes 'TRUE' as the set of flags
which means it will only get the 'clear' flag and not the
'disable-migration' flag. When the glyph cache gets full it will
therefore try to copy the texture to the new atlas as well as
redrawing them with cairo. This causes problems because the glyph
cache needs to work in situations where there is no FBO support.
2011-04-06 17:36:00 +01:00
Neil Roberts
36528d3af0 cogl-pipeline: Be careful not to take ownership of root layer
In _cogl_pipeline_prune_empty_layer_difference if the layer's parent
has no owner then it just takes ownership of it. However this could
theoretically end up taking ownership of the root layer because
according to the comment above in the same function that should never
have an owner. This patch just adds an extra check to ensure that the
unowned layer has a parent.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2588
2011-04-05 18:24:09 +01:00
Robert Bragg
e625be6c96 pipeline: reclaim ownership if reverting to layer ancestor
In _cogl_pipeline_prune_empty_layer_difference if we are reverting to
the immediate parent of an empty/redundant layer then it is not enough
to simply add a reference to the pipeline's ->layer_differences list
without also updating parent_layer->owner to point back to its new
owner.

This oversight was leading us to break the invariable that all layers
referenced in layer_differences have an owner and was also causing us to
break another invariable whereby after calling
_cogl_pipeline_layer_pre_change_notify the returned layer must always be
owned by the given 'required_owner'.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2588
2011-04-05 18:24:09 +01:00
Emmanuele Bassi
02d14ec15c offscreen: Plug a leak in an error path
When creating a CoglOffscreen we take a reference on the texture handle,
but in case of error we never release it.

We should take that reference only on success.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2620
2011-04-04 14:42:36 +01:00
Emmanuele Bassi
28c0a4d6be osx: Do not unrealize on hide
Calling unrealize on ClutterStage::hide will cause an assertion
failure and other badness when we destroy the stage.
2011-04-02 22:36:38 +01:00
Robert Bragg
130c79ac03 glx: throttle clipped redraws
When we come to presenting the result of a clipped redraw to the front
buffer with a blit we need to ensure that all the rendering is done,
otherwise redraw operations that are slower than the framerate can queue
up in the pipeline during a heavy animation, causing a larger and larger
backlog of rendering visible as lag to the user.

Note: Since calling glFinish() and sycnrhonizing the CPU with the GPU is
far from ideal, we hope that this is only a short term solution.

One idea is to using sync objects to track render completion so we can
throttle the backlog (ideally with an additional extension that lets us
get notifications in our mainloop instead of having to busy wait for the
completion.)

Another option is to support clipped redraws by reusing the contents of
old back buffers such that we can flip instead of using a blit and then
we can use GLX_INTEL_swap_events to throttle. For this though we would
still probably want an additional extension so we can report the limited
region of the window damage to X/compositors.

Thanks to Owen Taylor and Alexander Larsson for reporting the problem.
2011-04-01 18:50:55 +01:00
Emmanuele Bassi
e368538ae0 align-constraint: Fix typo in the vertical align
We're clamping the x1 coordinate to the nearest pixel, instead of doing
so for the y1 coordinate.
2011-04-01 15:36:22 +01:00
Emmanuele Bassi
524eb23eb7 paint-volume: Zero-sized actors don't have paint volume
If an actor has an allocated dimension equal to 0 then it has no paint
volume.
2011-04-01 11:43:34 +01:00
Emmanuele Bassi
7e6bf1612b texture: Add some safeguards for paint volumes of empty textures
If the Texture has no material, and the image size is 0x0 then the actor
doesn't have any paint volume.
2011-04-01 11:42:41 +01:00
Emmanuele Bassi
a76e0041af drag-action: Fix a compiler warning
Use arguments of the right signedness when passing pointers.
2011-03-21 12:41:40 +00:00
Neil Roberts
fd89dee1b0 clutter-clone: Make clutter_clone_get_paint_volume static
clutter_clone_get_paint_volume was being exported from the shared
library because the function wasn't declared static. This function
shouldn't be exposed because it should be accessed through
clutter_actor_get_paint_volume.
2011-03-18 14:11:08 +00:00
Neil Roberts
1d14e7468b clutter-offscreen-effect: Paint with 'nearest' texture filter mode
The texture containing the image for the redirected actor will always
be painted at a 1:1 texel:pixel ratio so there's no need to use linear
filtering. This should also counteract some of the effects of rounding
errors when calculating the geometry for the quad.
2011-03-17 12:20:53 +00:00
Robert Bragg
e51749d33c win32: mkdir -p win32 needed for out of tree builds
if cross compiling clutter using mingw using an out of tree build
directory then a pre-requisite for creating the resources.o file
containing the transparent cursor is for the win32 directory itself to
be created at $(top_builddir)/clutter/win32.
2011-03-16 11:22:20 +00:00
Neil Roberts
e4e318c9f8 cogl: Use GHookList instead of CoglCallbackList
glib already has a data type to manage a list of callbacks called a
GHookList so we might as well use it instead of maintaining Cogl's own
type. The glib version may be slightly more efficient because it
avoids using a GList and instead encodes the prev and next pointers
directly in the GHook structure. It also has more features than
CoglCallbackList.
2011-03-14 18:18:15 +00:00
Øyvind Kolås
9753046ca0 stage: handle ACCEPT_FOCUS in set_/get_property 2011-03-11 17:14:54 +00:00
Robert Bragg
49ca9e8f12 culling: Don't cull actors not being painted on the stage
Previously we were applying the culling optimization to any actor
painted without considering that we may be painting to an offscreen
framebuffer where the stage clip isn't applicable.

For now we simply expose a getter for the current draw framebuffer
and we can assume that a return value of NULL corresponds to the
stage.

Note: This will need to be updated as stages start to be backed by real
CoglFramebuffer objects and so we won't get NULL in those cases.
2011-03-10 21:02:29 +00:00
Robert Bragg
5ce13b58fe debug: Add more CLIPPING debug notes
To give quick visibility to the things going on relating to clipping and
culling this adds some more CLIPPING debug notes to clutter-actor.c and
clutter-stage.c
2011-03-10 19:07:50 +00:00
Robert Bragg
3303b08174 culling: check volume->is_empty before ->is_complete
As documented in cogl-pipeline-private.h, there is a precedence to the
ClutterPaintVolume bitfields that should be considered whenever we
implement code that manipulates PaintVolumes...

Firstly if ->is_empty == TRUE then the values for ->is_complete and
->is_2d are undefined, so we should typically check ->is_empty as the
first priority.

This fixes a bug in _clutter_paint_volume_cull() whereby we were
checking pv->is_complete before checking pv->is_empty which was
resulting in assertions for actors with no size.
2011-03-10 14:02:37 +00:00
Jasper St. Pierre
0b9aa1fa24 cogl-clip-state: Adapt to experimental cogl2 API.
The current clip state implementation couldn't be used in
conjunction with the CoglPath experimental API.

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

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-03-10 13:05:43 +00:00
Neil Roberts
9cba5b83bd cogl-path: Optimise paths that are just a rectangle
Drawing and clipping to paths is generally quite expensive because the
geometry has to be tessellated into triangles in a single VBO which
breaks up the journal batching. If we can detect when the path
contains just a single rectangle then we can instead divert to calling
cogl_rectangle which will take advantage of the journal, or by pushing
a rectangle clip which usually ends up just using the scissor.

This patch adds a boolean to each path to mark when it is a
rectangle. It gets cleared whenever a node is added or gets set to
TRUE whenever cogl2_path_rectangle is called. This doesn't try to
catch cases where a rectangle is composed by cogl_path_line_to and
cogl_path_move_to commands.
2011-03-09 18:28:48 +00:00
Emmanuele Bassi
82a30d8e0b drag-action: Allow using settings for the drag threshold
ClutterDragAction should be able to use the newly added ClutterSettings
property exposing the system's drag threshold.

Currently, the x-drag-threshold and the y-drag-threshold properties (and
relative accessors) use an unsigned integer for their values; we should
be able to safely expand the range to include -1 as the minimum value,
and use this new value to tell the ClutterDragAction that it should query
the ClutterSettings object for the drag threshold.

The storage of the properties has been changed, albeit in a compatible
way, as GObject installs a uint ↔ int transformation function for GValue
automatically.

The setter for the drag thresholds has been changes to use a signed
integer, but the getter has been updated to always Do The Right Thing™:
it never returns -1 but, instead, will return the valid drag threshold,
either from the value set or from the Settings singleton.

This change is ABI compatible.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2583
2011-03-09 14:21:01 +00:00
Emmanuele Bassi
bca7422f3d x11: Map Net/DndDragThreshold to ClutterSettings
Simple mapping between XSETTINGS key and ClutterSettings property.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2583
2011-03-09 14:21:00 +00:00
Emmanuele Bassi
b7685ad06b settings: Add dnd-drag-threshold property
The newly added ClutterSettings:dnd-drag-threshold stores the
threshold, in pixels, that should be passed by the cursor to
start a drag operation.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2583
2011-03-09 14:21:00 +00:00
Emmanuele Bassi
6d653fb6dd settings: Clean up property installation code
Use g_object_class_install_properties().

http://bugzilla.clutter-project.org/show_bug.cgi?id=2583
2011-03-09 14:21:00 +00:00
Emmanuele Bassi
ed27da6abe docs: Add an ClutterState definition section
ClutterState is missing some documentation on how to define transitions
using ClutterScript definitions; it is also missing some example code
for both the C API and the ClutterScript syntax.
2011-03-09 13:22:08 +00:00
Emmanuele Bassi
49d38b1e21 box: Implement the correct paint volume
The allocation of the ClutterBox is not enough to be used as the paint
volume, because children might decide to paint outside that area.

Instead, we should use the allocation if the Box has a background color
and then do what Group does, and union all the paint volumes of the
children.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2600
2011-03-08 19:27:07 +00:00
Neil Roberts
d1500c03c0 cogl-shader-boilerplate: Specify default precision earlier
In 9ff04e8a99 the builtin uniforms were moved to the common shader
boilerplate. However the common boilerplate is positioned before the
default precision specifier on GLES2 so it would fail to compile
because the uniforms end up with no precision in the fragment
shader. This patch just moves the precision specifier to above the
common boilerplate.
2011-03-08 13:21:24 +00:00
Emmanuele Bassi
41b815ebf4 event: Return the CrossingEvent.device field
The CLUTTER_ENTER and CLUTTER_LEAVE event types were mistakenly ignored
by clutter_event_get_device(), when returning the device from a
non-allocated ClutterEvent.
2011-03-08 10:05:57 +00:00
Emmanuele Bassi
1bacefd6d8 win32/event: Set the core pointer directly
Since we have a ClutterInputDevice pointer already we can just set it
instead of using event->crossing.device.
2011-03-08 10:01:53 +00:00
Emmanuele Bassi
da6b5eb7e1 event: Set the CrossingEvent device field
The CLUTTER_ENTER and CLUTTER_LEAVE should also have their device field
set when calling clutter_event_set_device().
2011-03-08 10:01:06 +00:00
Neil Roberts
d1c819b563 clutter-actor: Fix test for avoiding calculating the paint volume
There's an optimisation in clutter-actor.c to avoid calculating the
last known paint volume whenever culling and clipped redraws are both
disabled. However there was a small thinko in the logic so that it
would also avoid calculating the paint volume whenever only one of the
debug flags is enabled. This fixes it to explicitly check that the two
flags are not both enabled before skipping the paint volume
calculation.
2011-03-07 15:35:05 +00:00
Robert Bragg
9130dc1311 util: optimize _clutter_util_fully_transform_vertices
Instead of unconditionally combining the modelview and projection
matrices and then iterating each of the vertices to call
cogl_matrix_transform_point for each one in turn we now only combine the
matrices if there are more than 4 vertices (with less than 4 vertices
its less work to transform them separately) and we use the new
cogl_vertex_{transform,project}_points APIs which can hopefully
vectorize the transformations.

Finally the perspective divide and viewport scale is done in a separate
loop at the end and we don't do the spurious perspective divide and
viewport scale for the z component.
2011-03-07 13:26:20 +00:00
Robert Bragg
3b88029f38 actor: Cache per-actor transforms
Previously each time we needed to retrieve the model transform for a
given actor we would call the apply_transform vfunc which would build up
a transformation matrix based on the actor's current anchor point, its
scale, its allocation and rotation. The apply_transform implementation
would repeatedly call API like cogl_matrix_rotate, cogl_matrix_translate
and cogl_matrix_scale.

All this micro matrix manipulation APIs were starting to show up in the
profiles of dynamic applications so this adds priv->transform matrix
cache which maintains the combined result of the actors scale, rotation
and anchor point etc. Whenever something like the rotation changes then
then the matrix is marked as dirty, but so long as the matrix isn't
dirty then the apply_transform vfunc now just calls cogl_matrix_multiply
with the cached transform matrix.
2011-03-07 13:26:20 +00:00
Robert Bragg
19b8622983 Optimize culling by doing culling in eye-coordinates
This implements a variation of frustum culling whereby we convert screen
space clip rectangles into eye space mini-frustums so that we don't have
to repeatedly transform actor paint-volumes all the way into screen
coordinates to perform culling, we just have to apply the modelview
transform and then determine each points distance from the planes that
make up the clip frustum.

By avoiding the projective transform, perspective divide and viewport
scale for each point culled this makes culling much cheaper.
2011-03-07 13:26:20 +00:00
Robert Bragg
eef9078f89 stage: simplify apply_transform
This simplifies the implementation of the ClutterStage apply_transform
vfunc by using the new cogl_matrix_view_2d_in_perspective utility API
which can setup up a view transform for a given perspective so that a
cross section of the view frustum at an arbitrary depth can be mapped
directly to 2D stage coordinates with (0,0) at the top left.
2011-03-07 13:26:19 +00:00
Robert Bragg
ca30ac7835 matrix: adds 2d view transform conveniences
This adds two new experimental functions to cogl-matrix.c:
cogl_matrix_view_2d_in_perspective and cogl_matrix_view_2d_in_frustum
which can be used to setup a view transform that maps a 2D coordinate
system (0,0) top left and (width,height) bottom right to the current
viewport.

Toolkits such as Clutter that want to mix 2D and 3D drawing can use
these APIs to position a 2D coordinate system at an arbitrary depth
inside a 3D perspective projected viewing frustum.
2011-03-07 13:26:19 +00:00
Robert Bragg
1431b77747 stage: don't call glGetIntegerv in clutter_stage_read_pixels
Firstly Clutter shouldn't be using OpenGL directly so this needed
changing but also conceptually it doesn't make sense for
clutter_stage_read_pixels to validate the requested area to read against
the viewport it would make more sense to compare against the window
size. Finally checking that the width of the area is less than the
viewport or window width without considering the x isn't enough to know
if the area extends outside the windows bounds. (same for the height)

This patch removes the validation of the read area from
clutter_stage_read_pixels and instead we now simply rely on the
semantics of cogl_read_pixels for reading areas outside the window
bounds.
2011-03-07 13:26:19 +00:00
Robert Bragg
013b2433f0 viewport: consistently use floats for viewports
OpenGL < 4.0 only supports integer based viewports and internally we
have a mixture of code using floats and integers for viewports. This
patch switches all viewports throughout clutter and cogl to be
represented using floats considering that in the future we may want to
take advantage of floating point viewports with modern hardware/drivers.
2011-03-07 13:26:19 +00:00
Robert Bragg
54f85832b7 util: tune point_in_poly test for polys in screen coords
This makes a change to the original point_in_poly algorithm from:
http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

The aim was to tune the test so that tests against screen aligned
rectangles are more resilient to some in-precision in how we transformed
that rectangle into screen coordinates. In particular gnome-shell was
finding that for some stage sizes then row 0 of the stage would become a
dead zone when going through the software picking fast-path and this was
because the y position of screen aligned rectangles could end up as
something like 0.00024 and the way the algorithm works it doesn't have
any epsilon/fuz factor to consider that in-precision.

We've avoided introducing an epsilon factor to the comparisons since we
feel there's a risk of changing some semantics in ways that might not be
desirable. One of those is that if you transform two polygons which
share an edge and test a point close to that edge then this algorithm
will currently give a positive result for only one polygon.

Another concern is the way this algorithm resolves the corner case where
the horizontal ray being cast to count edge crossings may cross directly
through a vertex. The solution is based on the "idea of Simulation of
Simplicity" and "pretends to shift the ray infinitesimally down so that
it either clearly intersects, or clearly doesn't touch". I'm not
familiar with the idea myself so I expect a misplaced epsilon is likely
to break that aspect of the algorithm.

The simple solution this patch applies is to pixel align the polygon
vertices which should eradicate most noise due to in-precision.

https://bugzilla.gnome.org/show_bug.cgi?id=641197
2011-03-07 13:26:19 +00:00
Emmanuele Bassi
0194e9db2f glx: Use g_set_error_literal() where appropriate 2011-03-04 23:58:12 +00:00
Emmanuele Bassi
bed392b9a5 On error, return FALSE in the post_parse hook
Anything that is not CLUTTER_INIT_SUCCESS is to be considered an error.

This fixes the Clutter initialization sequence to actually error out
on pre-conditions and backend initialization failures.
2011-03-04 23:56:12 +00:00
Emmanuele Bassi
8bde5febd1 Clean up argument parsing GError handling
Pass a GError in, so that clutter_init() can effectively print out a
critical warning on initialization failure, like it used to do in the
olden days.
2011-03-04 23:55:02 +00:00
Emmanuele Bassi
4f3a4ab01b x11: Use g_set_error_literal()
The g_set_error() function takes a format string.
2011-03-04 23:53:45 +00:00
Neil Roberts
9e11aa3820 clutter-offscreen-effect: Use 0,0 as the offset if no actor box
clutter_offscreen_effect_pre_paint was using the unitialized value of
the ‘box’ variable whenever the actor doesn't have a paint
volume. This patch makes it just set the offset to 0,0 instead.
2011-03-04 17:04:02 +00:00
Neil Roberts
d306b4bb7d clutter-offscreen-effect: Preserve the old opacity override
When removing the opacity override in the post_paint implementation,
ClutterOffscreenEffect would always set the override back to -1. This
ends up cancelling out the effect of any overrides from outer effects
which means that if any actor has multiple effects attached then it
would apply the opacity multiple times.

To fix this, the effect now preserves the old value of the opacity
override and restores that instead of setting -1.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2541
2011-03-03 16:54:52 +00:00
Neil Roberts
3fab04805e clutter-actor: Add an internal _clutter_actor_get_opacity_override
This is needed if an effect wants to temporarily override the paint
opacity. It needs to be able to restore the old opacity override in
the post_paint handler otherwise it would replace the effect of the
opacity override from any outer effects.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2541
2011-03-03 16:54:51 +00:00
Jasper St. Pierre
0c576c0c33 Remove private helper #define's
Finish off the second half of 09a830d294.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2596
2011-03-03 11:47:49 +00:00
Dioselin
cfa32659e4 box: set default paint volume to allocation
http://bugzilla.clutter-project.org/show_bug.cgi?id=2589
2011-03-02 18:29:11 +00:00
Emmanuele Bassi
0be73bf401 effect: Queue a redraw on :enabled changes
ClutterEffect should queue a redraw if the :enabled property of its
parent class ClutterActorMeta changes.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2587
2011-03-01 19:04:31 +00:00
Emmanuele Bassi
bd8b09edda constraint: Queue a relayout on :enabled changes
ClutterConstraint should queue a relayout if the :enabled property of
its parent class ClutterActorMeta changes.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2587
2011-03-01 19:04:31 +00:00
Emmanuele Bassi
0c83e6a59a offscreen-effect: Add public accessor for target size
The OffscreenEffect class needs to expose a way for sub-classes to
track the size of FBO it creates, in case it has to do some geometry
deformations like the DeformEffect sub-classes.

Let's move the private symbol we used internally in 1.6 to fix
DeformEffect to the list of public symbols of OffscreenEffect.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2570
2011-02-28 14:34:36 +00:00
Emmanuele Bassi
e2b5762571 Move the keysym ↔ Unicode table to .rodata
The table we use for converting between keysyms and Unicode should be
static and constified, so that it can live in the .rodata section of
the ELF shared object, and be shared among processes.

This change moves the table to a source file, instead of an header; the
change also requires the clutter_keysym_to_unicode() function to be
moved from clutter-event.c into this new source file. The declaration is
still in clutter-event.h, so we don't need to do anything special.
2011-02-28 14:16:24 +00:00
Emmanuele Bassi
d3a7b7502e event: Add setters for ClutterEvent members
Creating a synthetic event requires direct access to the ClutterEvent
union members; this access does not map in bindings to high-level
languages, especially run-time bindings using GObject-Introspection.
It's also midly annoying from C, as it unnecessarily exposes the guts of
ClutterEvent - something we might want to fix in the future.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2575
2011-02-28 14:16:23 +00:00
Neil Roberts
3d34d9fea1 Add G_GNUC_WARN_UNUSED_RESULT to clutter_init and init_with_args
Many people expect clutter_init to work the same way as gtk_init which
exits the program on init failure. clutter_init however returns a
status code on failure which applications need to handle because if
the init fails then any further Clutter calls are likely to crash. In
Clutter 2.0 we may want to change this to be more like GTK+.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2574
2011-02-28 14:10:05 +00:00
Neil Roberts
4dd20f2678 cogl-blit: Disable blending when using texture render
When using a pipeline and the journal to blit images between
framebuffers, it should disable blending. Otherwise it will end up
blending the source texture with uninitialised garbage in the
destination texture.
2011-02-24 20:45:19 +00:00
Emmanuele Bassi
4442ddde82 text: Round up the size
Converting from Pango units to pixels by using the C conventions might
cause us to lose a pixel; since we're doing the same for the height, we
should use ceilf() to round up the width and the line height.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2573
2011-02-21 17:34:45 +00:00
Emmanuele Bassi
0d17b1463b device-manager/xi2: Silence a compiler warning 2011-02-19 16:48:59 +00:00
Emmanuele Bassi
fd3462170f cally: Remove unused variables 2011-02-19 16:47:20 +00:00
Emmanuele Bassi
dfdcc20670 clutter: Remove unused variables 2011-02-19 16:47:20 +00:00
Emmanuele Bassi
f99d2336f0 x11: Remove unused variables 2011-02-19 16:47:20 +00:00
Emmanuele Bassi
23598ea74b cogl: Remove unused variables 2011-02-19 16:47:11 +00:00
Emmanuele Bassi
ec02a8808e deform-effect: Use the FBO target size
The ClutterDeformEffect sub-classes are effectively deforming the
texture target of an FBO, not the actor itself. Thus, we need to
use the FBO's size, and not the actor's allocated size, given that
the actor might be transformed prior to applying an effect.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2571
2011-02-19 09:19:07 +00:00
Emmanuele Bassi
20f19fe06c offscreen-effect: Add private API for getting the target size
Since the FBO target might have a different size than the mere paint box
of the actor, we need API to get it out of the ClutterOffscreenEffect
private data structure and on to sub-classes.

Since we cannot add new API in a stable cycle, we need a private
function; we'll leave it there even when opening 1.7, since it's useful
for internal purposes.
2011-02-19 09:15:34 +00:00
Emmanuele Bassi
a923375f0a drag-action: Use per-stage motion event toggle
Similar to what we did for the ClutterDeviceManager, use per-stage
granularity when toggling the motion event delivery while dragging.
2011-02-18 19:41:57 +00:00
Emmanuele Bassi
cca2e5bc9c device-manager: Use per-stage motion event toggle
Now that we have internal support for per-stage granularity of motion
event delivery, let's use it when updating the state of the input
devices.
2011-02-18 19:41:57 +00:00
Emmanuele Bassi
bc548dc862 Store the motion event deliver flag in ClutterStage
Once upon a time, the land of Clutter had a stage singleton. It was
created automatically at initialization time and stayed around even
after the main loop was terminated. The singleton was content in
being all there was. There also was a global API to handle the
configuration of the stage singleton that would affect the behaviour
on other classes, signals and properties.

Then, an evil wizard came along and locked the stage singleton in his
black tower, and twisted it until it was possible to create new stages.
These new stages were pesky, and didn't have the same semantics of the
singleton: they didn't stay around when closed, or terminate the main
loop on delete events.

The evil wizard also started moving all the stage-related API from the
global context into class-specific methods.

Finally, the evil wizard cast a spell, and the stage singleton was
demoted to creation on demand - and until somebody called the
clutter_stage_get_default() function, the singleton remained in a limbo
of NULL pointers and undefined memory areas.

There was a last bit - literally - of information still held by the
global API; a tiny, little flag that disabled per-actor motion events.
The evil wizard added private accessors for it, and stored it inside the
stage private structure, in preparation for a deprecation that would
come in a future development cycle.

The evil wizard looked down upon the land of Clutter from the height of
his black tower; the lay of the land had been reshaped into a crucible
of potential, and the last dregs of the original force of creation were
either molted into new, useful shapes, or blasted away by the sheer fury
of his will.

All was good.
2011-02-18 19:41:41 +00:00
Emmanuele Bassi
7500b77b2b Assert if we call backend API without a valid backend
This is a backend programming error, and we should not tolerate
failures in these cases.
2011-02-18 17:51:01 +00:00
Emmanuele Bassi
7e42da123f Clean up clutter-private.h
Move macros at the top, and clean up whitespace.
2011-02-18 16:53:58 +00:00
Emmanuele Bassi
cdd9fd1af1 Move ActorMeta private function in the private header
No reason to leave it in the installed header.
2011-02-18 16:53:31 +00:00
Emmanuele Bassi
3e5aa9ed63 Add private header for event-related API 2011-02-18 16:35:36 +00:00
Emmanuele Bassi
d27b335b61 Move ClutterEffect private symbols to a private header
No point in cluttering up clutter-private.h even more than necessary.
2011-02-18 16:00:39 +00:00
Emmanuele Bassi
3addeb91cc Privatize all ClutterIdPool functions
The clutter-id-pool.h header is private and not installed; yet, all the
clutter_id_pool_* symbols are public. Let's correct this oversight we've
been stringing along since forever.
2011-02-18 15:53:27 +00:00
Emmanuele Bassi
37fe8c509a Clean up usage of CLUTTER_CONTEXT and remove the macro
Only allow access to the ClutterMainContext through the private
_clutter_context_get_default() function, so we can easily grep
it and remove the unwanted usage of the global context.
2011-02-18 15:47:35 +00:00
Emmanuele Bassi
689aac56c9 Wrap id-pool access
The ClutterIdPool is held by the ClutterMainContext; we should hide its
direct usage into sensible private API.
2011-02-18 15:46:13 +00:00
Emmanuele Bassi
2593bbaadc Wrap shader stack into private functions
The shader stack held by ClutterMainContext should only be accessed
using functions, and not directly.

Since it's a stack, we can use stack-like operations: push, pop and
peek.
2011-02-18 15:44:17 +00:00
Emmanuele Bassi
28b0f8b938 stage: Make the redraw_count a stage counter
We don't care about redraws issued on stages that are not currently
being repainted.
2011-02-18 14:38:54 +00:00
Emmanuele Bassi
4635c8f9fd Make _clutter_pixel_to_id() private
It's only used in the same file that declares it.
2011-02-18 14:38:24 +00:00
Emmanuele Bassi
92ddaa9c13 stage: Move stage redraw logic into clutter-stage.c
The _clutter_do_redraw() function should really be moved inside
ClutterStage, since all it does is calling private stage and
backend functions. This also allows us to change a long-standing
issue with a global fps counter for all stages, instead of a\
per-stage one.
2011-02-18 12:56:17 +00:00
Emmanuele Bassi
89a0d514b4 Continue hiding the ClutterMainContext
We should strive to make the main context as transparent as possible,
and hide accessing its data through private functions.
2011-02-18 12:56:13 +00:00
Emmanuele Bassi
fc89513295 actor: Move the ShaderData out of the private data
Let's try and start reducing the size of ClutterActorPrivate by moving
some optional, out-of-band data from it to GObject data.

The ShaderData structure is a prime candidate for this migration: it
does not need to be inspected by the actor, and its relationship with an
actor is transient and optional.

By attaching it to the actor's instance through g_object_set_data() we
neatly tie its lifetime to the instance, and we don't have to care
cleaning it up in the finalize()/dispose() implementation of
ClutterActor itself.
2011-02-18 11:43:27 +00:00
Neil Roberts
9ea2567a2f cogl-atlas-texture: Don't let textures be destroyed during migration
If an atlas texture's last reference is held by the journal or by the
last flushed pipeline then if an atlas migration is started it can
cause a crash. This is because the atlas migration will cause a
journal flush and can sometimes change the current pipeline which
means that the texture would be destroyed during migration.

This patch adds an extra 'post_reorganize' callback to the existing
'reorganize' callback (which is now renamed to 'pre_reorganize'). The
pre_reorganize callback is now called before the atlas grabs a list of
the current textures instead of after so that it doesn't matter if the
journal flush destroys some of those textures. The pre_reorganize
callback for CoglAtlasTexture grabs a reference to all of the textures
so that they can not be destroyed when the migration changes the
pipeline. In the post_reorganize callback the reference is removed
again.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2538
2011-02-17 13:39:30 +00:00
Neil Roberts
71f57eef1b clutter-actor: Free the paint volume when queue a clip redraw
In _clutter_actor_queue_redraw_with_clip it has a local variable to
mark when a new paint volume for the clip is created so that it can be
freed when the function returns. However the actual code to free the
paint volume went missing in 3b789490d2 so the variable did
nothing. This patch just adds the free back in.
2011-02-16 19:00:05 +00:00
Neil Roberts
0e32da6650 clutter-color-size-effect: Fix a minor typo in the docs
'Since:' was spelt 'SinceL' which I assume was a typo.
2011-02-16 14:11:59 +00:00
Emmanuele Bassi
354f7b0e25 backend: Remove usage of CLUTTER_STAGE_TYPE
It's only used for debugging purposes, and it's of limited usage since
the stage creation is deferred to the backend implementation itself.
2011-02-15 14:48:41 +00:00
Neil Roberts
ca94d0cc37 cogl-atlas: Fix a compiler warning when Cogl debug is disabled
When Cogl debugging is disabled then the 'waste' variable is not used
so it throws a compiler warning. This patch removes the variable and
the value is calculated directly as the parameter to COGL_NOTE.
2011-02-15 14:26:18 +00:00
Neil Roberts
c5f057822e cogl-debug: Don't define _cogl_debug_flags when debugging disabled
_cogl_debug_flags isn't used when COGL_DEBUG is not defined so there's
no need to declare it.

Based on a patch by Fan, Chun-wei

http://bugzilla.clutter-project.org/show_bug.cgi?id=2561
2011-02-15 14:26:17 +00:00
Neil Roberts
fb3321d4fe cogl: Avoid pointer arithmetic on void* pointers
Some code was doing pointer arithmetic on the return value from
cogl_buffer_map which is void* pointer. This is a GCC extension so we
should try to avoid it. This patch adds casts to guint8* where
appropriate.

Based on a patch by Fan, Chun-wei.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2561
2011-02-15 14:26:17 +00:00
Emmanuele Bassi
92d13a1966 build: Re-enable --warn-all for g-ir-scanner
Now that I don't have to see a bunch of false positives any more, we can
finally use warnings to catch issues.
2011-02-15 12:40:12 +00:00
Emmanuele Bassi
6309fd6cd7 introspection: Override the GParamSpec type
About other assorted boneheadedness, the GType for GParamSpec is
called 'GParam'. Why? Who knows. I assume alcohol was involved,
but I honestly don't want to know.

This removes the last g-ir-scanner warning in Clutter.
2011-02-15 12:40:12 +00:00
Emmanuele Bassi
6655bedba7 Fix ISO C90 compiler warnings in Cogl
Mixing declarations and statements and unused variables.
2011-02-15 12:40:11 +00:00
Emmanuele Bassi
5c398c18ad More ISO C90 warning fixes in Clutter
This time, in Clutter core.

The ObjC standard library provides a type called 'id', which obviously
requires any library to either drop the useful shadowed variable warning
or stop using 'id' as a variable name.

Yes, it's almost unbearably stupid. Well, at least it's not 'index' in
string.h, or 'y2' in math.h.
2011-02-15 12:40:11 +00:00
Emmanuele Bassi
54a4511247 Fix some ISO C90 warnings on OSX 2011-02-15 12:14:17 +00:00
Neil Roberts
e90ded6c23 cogl-atlas: Try 4 different approaches for migrating textures
Instead of directly banging GL to migrate textures the atlas now uses
the CoglFramebuffer API. It will use one of four approaches; it can
set up two FBOs and use _cogl_blit_framebuffer to copy between them;
it can use a single target fbo and then render the source texture to
the FBO using a Cogl draw call; it can use a single FBO and call
glCopyTexSubImage2D; or it can fallback to reading all of the texture
data back to system memory and uploading it again with a sub texture
update.

Previously GL calls were used directly because Cogl wasn't able to
create a framebuffer without a stencil and depth buffer. However there
is now an internal version of cogl_offscreen_new_to_texture which
takes a set of flags to disable the two buffers.

The code for blitting has now been moved into a separate file called
cogl-blit.c because it has become quite long and it may be useful
outside of the atlas at some point.

The 4 different methods have a fixed order of preference which is:

* Texture render between two FBOs
* glBlitFramebuffer
* glCopyTexSubImage2D
* glGetTexImage + glTexSubImage2D

Once a method is succesfully used it is tried first for all subsequent
blits. The default default can be overridden by setting the
environment variable COGL_ATLAS_DEFAULT_BLIT_MODE to one of the
following values:

* texture-render
* framebuffer
* copy-tex-sub-image
* get-tex-data
2011-02-15 12:10:54 +00:00
Neil Roberts
7b369445b3 cogl-texture-2d: Add _cogl_is_texture_2d to the private header
This adds a declaration for _cogl_is_texture_2d to the private header
so that it can be used in cogl-blit.c to determine if the target
texture is a simple 2D texture.
2011-02-15 12:10:54 +00:00
Neil Roberts
f947fe958f cogl-texture-2d: Add an internal wrapper around glCopyTexSubImage2D
This adds a function called _cogl_texture_2d_copy_from_framebuffer
which is a simple wrapper around glCopyTexSubImage2D. It is currently
specific to the texture 2D backend.
2011-02-15 12:10:54 +00:00
Neil Roberts
5cc062c16c cogl-framebuffer: Add _cogl_blit_framebuffer
This adds the _cogl_blit_framebuffer internal function which is a
wrapper around glBlitFramebuffer. The API is changed from the GL
version of the function to reflect the limitations provided by the
GL_ANGLE_framebuffer_blit extension (eg, no scaling or mirroring).
2011-02-15 12:10:54 +00:00
Neil Roberts
5a159fcef4 cogl-gles: Check for the GL_ANGLE_framebuffer_blit extension
This extension is the GLES equivalent of the GL_EXT_framebuffer_blit
extension except that it has some extra restrictions. We need to check
for some extension that provides glBlitFramebuffer so that we can
unconditionally use ctx->drv.pf_glBlitFramebuffer in both GL and GLES
code. Even with the restrictions, the extension provides enough
features for what Cogl needs.
2011-02-15 12:10:54 +00:00
Neil Roberts
80bae51c01 cogl-atlas-texture: Make copying a texture out more robust
Previously when _cogl_atlas_texture_migrate_out_of_atlas is called it
would unreference the atlas texture's sub-texture before calling
_cogl_atlas_copy_rectangle. This would leave the atlas texture in an
inconsistent state during the copy. This doesn't normally matter but
if the copy ends up doing a render then the atlas texture may end up
being referenced. In particular it would cause problems if the texture
is left in a texture unit because then Cogl may try to call
get_gl_texture even though the texture isn't actually being used for
rendering. To fix this the sub texture is now unrefed after the copy
call instead.
2011-02-15 12:10:54 +00:00
Neil Roberts
e57aa3ca3e cogl-framebuffer: Separate the draw and read buffer
The current framebuffer is now internally separated so that there can
be a different draw and read buffer. This is required to use the
GL_EXT_framebuffer_blit extension. The current draw and read buffers
are stored as a pair in a single stack so that pushing the draw and
read buffer is done simultaneously with the new
_cogl_push_framebuffers internal function. Calling
cogl_pop_framebuffer will restore both the draw and read buffer to the
previous state. The public cogl_push_framebuffer function is layered
on top of the new function so that it just pushes the same buffer for
both drawing and reading.

When flushing the framebuffer state, the cogl_framebuffer_flush_state
function now tackes a pointer to both the draw and the read
buffer. Anywhere that was just flushing the state for the current
framebuffer with _cogl_get_framebuffer now needs to call both
_cogl_get_draw_buffer and _cogl_get_read_buffer.
2011-02-15 12:10:54 +00:00
Emmanuele Bassi
bdb309cbd6 annotations: Use caller-allocates for color getters
This should avoid a separate initialization of a ClutterColor in
language bindings.
2011-02-14 18:41:18 +00:00
Adel Gadllah
3d8445807a backend-glx: Remove redundant glFlush()
As noted in commit ce3f55292a an explict glFlush is needed for
both glBlitFramebuffer and glXCopySubBuffer.

_clutter_backend_glx_blit_sub_buffer was already doing an explicit
flush when using glBlitFramebuffer, so just do it unconditonally
and remove the call from clutter_stage_glx_redraw.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2558
2011-02-14 12:55:49 +00:00
Emmanuele Bassi
3a378b849b stage/glx: Code clean ups 2011-02-14 12:00:31 +00:00
Emmanuele Bassi
48f2cb1f09 stage/x11: Clean up ClutterStageX11 struct
Use the right parent instance and class structure; the X11 stage
implementation hasn't been a ClutterGroup in a long, long time.
2011-02-14 11:59:49 +00:00
Emmanuele Bassi
169df02a56 stage: Call ClutterStageWindow::unrealize() on dispose
Since we realize on creation we need to unrealize on destruction. This
makes sure that the ClutterStageWindow implementation can tear down any
resource set up during the realization phase.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2559
2011-02-13 19:26:29 +00:00
Emmanuele Bassi
7c356fd05b stage/x11: Add a debug note for unrealization
We remove the ClutterStageWindow ↔ Window mapping in the ::unrealize
implementation; let's just check that we get there using a simple
debug note.
2011-02-13 19:25:21 +00:00
Emmanuele Bassi
2abf56fe92 Merge remote-tracking branch 'nobled/wayland-fixes2'
* nobled/wayland-fixes2:
  wayland: fix shm buffers
  wayland: set renderable type on dummy surface
  wayland: check for egl extensions explicitly
  wayland: fall back to shm buffers if drm fails
  wayland: add shm buffer code
  wayland: make buffer handling generic
  wayland: really fix buffer format selection
  wayland: fix pixel format
  wayland: clean up buffer creation code
  wayland: don't require the surfaceless extensions
  wayland: check for API-specific surfaceless extension
  wayland: fix GLES context creation
  wayland: use EGL_NO_SURFACE
  wayland: update to new api
  wayland: fix connecting to default socket
  fix ClutterContainer docs
2011-02-11 16:45:45 +00:00