Commit Graph

3742 Commits

Author SHA1 Message Date
Emmanuele Bassi
1520ba6190 actor: Add internal child flag
ClutterActor checks, when destroying and reparenting, if the parent
actor implements the Container interface, and automatically calls the
remove() method to perform a clean removal.

Actors implementing Container, though, might have internal children;
that is, children that are not added through the Container API. It is
already possible to iterate through them using the Container API to
avoid breaking invariants - but calling clutter_actor_destroy() on
these children (even from the Container implementation, and thus outside
of Clutter's control) will either lead to leaks or to segmentation
faults.

Clutter needs a way to distinguish a clutter_actor_set_parent() done on
an internal child from one done on a "public" child; for this reason, a
push/pop pair of functions should be available to Actor implementations
to mark the section where they wish to add internal children:

  ➔ clutter_actor_push_internal ();
    ...
    clutter_actor_set_parent (child1, parent);
    clutter_actor_set_parent (child2, parent);
    ...
  ➔ clutter_actor_pop_internal ();

The set_parent() call will automatically set the newly added
INTERNAL_CHILD private flag on each child, and both
clutter_actor_destroy() and clutter_actor_unparent() will check for the
flag before deciding whether to call the Container's remove method.
2009-12-18 23:33:14 +00:00
Emmanuele Bassi
4a21425f48 layout: Let begin_animation() return the Alpha
When beginning a new animation for a LayoutManager, the implementation
should return the ClutterAlpha used. This allows controlling the
timeline and/or modifying the animation parameters on the fly.
2009-12-13 01:23:54 +00:00
Emmanuele Bassi
2e6397c391 box-layout: Add knobs for controlling animations
ClutterLayoutManager does not have any state associated with it, and
defers all the state to its sub-classes.

The BoxLayout is thus in charge of controlling:

  • whether or not animations should be used
  • the duration of the animation
  • the easing mode of the animation

By adding three new properties:

  • ClutterBoxLayout:use-animations
  • ClutterBoxLayout:easing-duration
  • ClutterBoxLayout:easing-mode

And their relative accessors pairs we can make BoxLayout decide whether
or not, and with which parameters, call the begin_animation() method of
ClutterLayoutManager.

The test-box-layout has been modified to reflect this new functionality,
by checking the key-press event for the 'a' key symbol to toggle the use
of animations.
2009-12-13 01:15:02 +00:00
Emmanuele Bassi
3c2e91aef5 box-layout: Animate layout properties
Use the newly added animation support inside LayoutManager to animate
between state changes of the BoxLayout properties.

The implementation is based on equivalent code from Mx, written by:

  Thomas Wood <thomas.wood@intel.com>
2009-12-13 01:14:16 +00:00
Emmanuele Bassi
f94a903d9e layout: Add animation support to LayoutManager
In order to animate a fluid layout we cannot use the common animation
code paths as they will override the size request and allocation paths
that are handled by the layout manager itself.

One way to introduce animations in the allocation sequence is to use a
Timeline and an Alpha to compute a progress value and then use that
value to interpolate an ActorBox between the initial and final states of
the animation - with the initial state being the last allocation of the
child prior to the animation start, and the final state the allocation
of the child at the end; for every frame of the Timeline we then queue a
relayout on the layout manager's container, which will result in an
animation.

ClutterLayoutManager is the most likely place to add a generic API for
beginning and ending an animation, as well as the place to provide a
default code path to create the ancillary Timeline and Alpha instances
needed to drive the animation.

A LayoutManager sub-class will need to:

  • call clutter_layout_manager_begin_animation() whenever it should
    animate between two states, for instance: whenever a layout property
    changes value;
  • eventually override begin_animation() and end_animation() in case
    further state needs to be set up, and then chain up to the default
    implementation provided by LayoutManager;
  • if a completely different implementation is required, the layout
    manager sub-class should override begin_animation(), end_animation()
    and get_animation_progress().

Inside the allocate() implementation the sub-class should also
interpolate between the last known allocation of a child and the newly
computed allocation.
2009-12-13 01:13:42 +00:00
Emmanuele Bassi
999359d64c Add ActorBox animation methods
ClutterActorBox should have an interpolate() method that allows to
compute the intermediate values between two states, given a progress
value, e.g.:

        clutter_actor_box_interpolate (start, end, alpha, &result);

Another utility method, useful for layout managers, is a modifier
that clamps the members of the actor box to the nearest integer
value.
2009-12-11 23:48:58 +00:00
Emmanuele Bassi
d2ea7cd6a8 Clean up whitespace, indentation and comments 2009-12-11 20:17:58 +00:00
Emmanuele Bassi
7b53aa7510 Merge branch 'get-current-event' into ebassi-next
* get-current-event:
  Add clutter_get_current_event
2009-12-10 23:36:04 +00:00
Colin Walters
1374b5aac9 Add clutter_get_current_event
When getting signals from higher level toolkits, occasionally
one wants access to the underlying event; say for a Button
widget's "clicked" signal, to get the keyboard state.

Rather than having all of the highlevel widgets emit
ClutterEvent just for the more unusual use cases,
add a global function to access the event state.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-12-10 22:20:36 +00:00
Emmanuele Bassi
60a6bff313 Merge branch 'no-layout-flag' into ebassi-next
* no-layout-flag:
  actor: Add a NO_LAYOUT flag for actors
2009-12-09 23:32:41 +00:00
Emmanuele Bassi
dc47550bc8 Merge branch 'size-cache' into ebassi-next
* size-cache:
  tests: Clean up the BoxLayout interactive test
  actor: Add debugging notes for size cache
  Add a cache of size requests
2009-12-09 23:32:18 +00:00
Emmanuele Bassi
86ce92eec1 x11: Emulate XKB's detectable key auto-repeat
Old-style X11 terminals require that even modern X11 send KeyPress
and KeyRelease pairs when auto-repeating. For this reason modern(-ish)
API like XKB has a way to detect auto-repeat and do a single KeyRelease
at the end of a KeyPress sequence.

The newly added check emulates XKB's detectable auto-repeat by peeking
the next event after a KeyRelease and checking if it's a KeyPress for
the same key and timestamp - and then ignoring the KeyRelease if it
matches.
2009-12-09 18:46:25 +00:00
Emmanuele Bassi
9242d6b934 docs: Move RELEASING under docs/ 2009-12-09 18:10:52 +00:00
Emmanuele Bassi
1ffd2ccb87 stage: Deprecate default stage size macros
The macros for getting the size of the default stage are a relic of the
past and they should be deprecated.
2009-12-09 17:19:32 +00:00
Emmanuele Bassi
34913378fb tests: Use accessor methods for :use-alpha
Instead of using g_object_set().
2009-12-09 17:17:33 +00:00
Emmanuele Bassi
1208e47198 stage: Add accessors for :use-alpha
Use real accessors for the :use-alpha property.
2009-12-09 02:05:24 +00:00
Emmanuele Bassi
3b075b6dc4 tests: Allow setting the stage opacity in test-paint-wrapper
This allows testing the Stage:use-alpha property and the blending done
by a compositor.
2009-12-09 01:46:52 +00:00
Emmanuele Bassi
3a3c815286 stage: Premultiply the stage color
In case we are using Stage:use-alpha then we need to premultiply the
stage color to get the correct blending from the compositor.
2009-12-09 01:46:09 +00:00
Emmanuele Bassi
e957e277b8 x11: Do not manage a foreign window
If a Stage has been set to use a foreign Window then Clutter should not
be managing it; calling XWithdrawWindow and XMapWindow should be
reserved to the windows we manage ourselves.
2009-12-08 18:24:30 +00:00
Emmanuele Bassi
28cb2cdab5 Remove clutter_set_default_text_direction()
Setting the default text direction programmatically is wrong: it is a
value dependent on the locale or by the environment.
2009-12-07 19:00:55 +00:00
Emmanuele Bassi
3b9575baf8 Queue a relayout when the default text direction changes
We need a relayout cycle if the default direction for the text changes
while the main loop is running.
2009-12-07 18:41:15 +00:00
Emmanuele Bassi
6a3f6a460e stage: Composite the opacity with the alpha channel
The Stage's opacity should be composited with the alpha component of the
Stage's background color.
2009-12-07 17:35:17 +00:00
Emmanuele Bassi
c4f27b1556 actor: Add a NO_LAYOUT flag for actors
Some actor implementation might avoid imposing any layout on their
children. The Actor base class usually assumes some sort of layout
management is in place, so it will queue relayouts when, for instance,
an actor is shown or is hidden. If the parent of the actor does not
impose any layout, though, showing or hiding one of its children will
not affect the layout of the others.

An example of this kind of container is ClutterGroup.

By adding a new Actor flag, CLUTTER_ACTOR_NO_LAYOUT, and by making
the Group actor set it on itself, the Actor base class can now decide
whether or not to queue a relayout. The flag is not meant to be used
by application code, and should only be set when implementing a new
container.

http://bugzilla.openedhand.com/show_bug.cgi?id=1838
2009-12-07 14:14:35 +00:00
Neil Roberts
34b50934be cogl-material: Ensure mipmaps before doing anything else on a texture
When the texture is in the atlas, ensuring the mipmaps can effectively
make it become a completely different texture so we should do this
before getting the GL handle.
2009-12-05 14:20:00 +00:00
Neil Roberts
231cfffa18 cogl-atlas-texture: Remove textures from the atlas when mipmapping is required
Mipmaps don't work very well in the current atlas because there is not
enough padding between the textures. If ensure_mipmaps is called it
will now create a new texture and migrate the atlased texture to
it. It will use the same blit mechanism as when migrating so it will
try to use an FBO for a fast blit. However if this is not possible it
will end up downloading the data for the entire atlas which is not
ideal.
2009-12-05 14:11:57 +00:00
Neil Roberts
6cf5ee2cbd cogl-atlas-texture: Try to do texture blits using an FBO
When reorganizing the textures, we can avoid downloading the entire
texture data if we bind the source texture in a framebuffer object and
copy the destination using glCopyTexSubImage2D. This is also
implemented using a much faster path in Mesa.

Currently it is calling the GL framebuffer API directly but ideally it
would use the Cogl offscreen API. However there is no way to tell Cogl
not to create a stencil renderbuffer which seems like a waste in this
situation.

If FBOs are not available it will fallback to reading back the entire
texture data as before.
2009-12-05 14:11:31 +00:00
Neil Roberts
c51a31a2fc cogl-atlas: Add a debug option to visualize the atlas
This adds a 'dump-atlas-image' debug category. When enabled, CoglAtlas
will use Cairo to create a png which visualizes the leaf rectangles of
the atlas.
2009-12-04 20:29:12 +00:00
Neil Roberts
032d6e8aa0 cogl-texture-atlas: Add some debugging notes
This adds an 'atlas' category to the COGL_DEBUG environment
variable. When enabled Cogl will display messages when textures are
added to the atlas and when the atlas is reorganized.
2009-12-04 20:29:12 +00:00
Neil Roberts
bc845e26d9 cogl-atlas-texture: Support reorganizing the atlas when it is full
When space can't be found in the atlas for a new texture it will now
try to reorganize the atlas to make space. A new CoglAtlas is created
and all of the textures are readded in decreasing size order. If the
textures still don't fit then the size of the atlas is doubled until
either we find a space or we reach the texture size limits. If we
successfully find an organization that fits then all of the textures
will be migrated to a new texture. This involves copying the texture
data into CPU memory and then uploading it again. Potentially it could
eventually use a PBO or an FBO to transfer the image without going
through the CPU.

The algorithm for laying out the textures works a lot better if the
rectangles are added in order so we might eventually want some API for
creating multiple textures in one go to avoid reorganizing the atlas
as far as possible.
2009-12-04 20:27:02 +00:00
Neil Roberts
1fb32167ec cogl: Add an atlased texture backend
This adds a CoglAtlas type which is a data structure that keeps track
of unused sub rectangles of a larger rectangle. There is a new atlased
texture backend which uses this to put multiple textures into a single
larger texture.

Currently the atlas is always sized 256x256 and the textures are never
moved once they are put in. Eventually it needs to be able to
reorganise the atlas and grow it if necessary. It also needs to
migrate the textures out of the atlas if mipmaps are required.
2009-12-04 20:26:39 +00:00
Emmanuele Bassi
b33b6287a1 tests: Clean up the BoxLayout interactive test 2009-12-04 17:39:04 +00:00
Emmanuele Bassi
cf62b8fe4a actor: Add debugging notes for size cache
Add a note for cache hits, and another one for cache misses.
2009-12-04 17:38:26 +00:00
Emmanuele Bassi
9ccdf2eb02 box: Add relative packing methods
ClutterBox should provide some convenience functions to pack a new child
at a given position, either an absolute index or relative to a sibling.
2009-12-04 16:54:22 +00:00
Johan Bilien
c9b7efec96 Add a cache of size requests
clutter_actor_get_preferred_width/height currently caches only one size
requests, for a given height / width.

It's common for a layout manager to call get_preferred_width with 2
different heights during the same allocation cycle. Typically once in
the size request, once in the allocation. If
clutter_actor_get_preferred_width is called
alternatively with 2 different for_height, the cache is totally
inefficient, and we end up always querying the actor size even
when the actor does not need a re-allocation.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-12-03 18:19:50 +00:00
Bastian Winkler
18860eb16f flow-layout: Use the natural size
Fix a copy-and-paste thinko where the cell size was computed using the
minimum size instead of the natural size. For actors with a minimum size
of zero, like Textures, this implied always a zero allocation.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-12-03 15:38:05 +00:00
Neil Roberts
6c3e1989e4 cogl-sub-texture: Fix the height of sub textures
The code which is used to get the texture height was accidentally
using the width due to a cut-and-paste fail.
2009-12-03 14:46:20 +00:00
Neil Roberts
97f8eed119 cogl: Add a CoglTexture2D backend
This is an optimised version of CoglTexture2DSliced that always deals
with a single texture and always uses the GL_TEXTURE_2D
target. cogl_texture_new_from_bitmap now tries to use this backend
first. If it can't create a texture with that size then it falls back
the sliced backend.

cogl_texture_upload_data_prepare has been split into two functions
because the sliced backend needs to know the real internal format
before the conversion is performed. Otherwise the converted bitmap
will be wasted if the backend can't support the size.
2009-12-02 22:03:27 +00:00
Neil Roberts
f3df76d512 cogl: Add _cogl_texture_driver_upload_to_gl
This provides a way to upload the entire data for a texture without
having to first call glTexImage and then glTexSubImage. This should be
faster especially with indirect rendering where it would needlessy
send the data for the texture twice.
2009-12-02 22:03:26 +00:00
Neil Roberts
19a19579ba cogl: Move some of the texture_2d_sliced_new_* functions into cogl-texture
new_from_data and new_from_file can be implemented in terms of
new_from_bitmap so it makes sense to move these to cogl-texture rather
than having to implement them in every texture backend.
2009-12-02 22:03:26 +00:00
Neil Roberts
27c4eb483d cogl: Add a conformance test for sub textures
This tests creating a sub texture from a larger texture using various
different texture coordinates. It also tries to read back the texture
data using cogl_texture_get_data.
2009-12-02 22:03:16 +00:00
Neil Roberts
9752493272 cogl: Add a sub texture backend
This adds a new texture backend which represents a sub texture of a
larger texture. The texture is created with a reference to the full
texture and a set of coordinates describing the region. The backend
simply defers to the full texture for all operations and maps the
coordinates to the other range. You can also use coordinates outside
the range [0,1] to create a repeated version of the full texture.

A new public API function called cogl_texture_new_from_sub_texture is
available to create the sub texture.
2009-12-02 22:03:08 +00:00
Neil Roberts
070a91f311 cogl: Make the callback for foreach_sub_texture_in_region use const
The CoglTextureSliceCallback function pointer now takes const pointers
for the texture coordinates. This makes it clearer that the callback
should not modify the array and therefore the backend can use the same
array for both sets of coords.
2009-12-02 22:03:08 +00:00
Neil Roberts
1a1de0e278 cogl: Add a texture utility function for manually repeating
Given a region of texture coordinates this utility invokes a callback
enough times to cover the region with a subregion that spans the
texture at most once. Eg, if called with tx1 and tx2 as 0.5 and 3.0 it
it would invoke the callback with:

0.5,1.0  1.0,2.0  2.0,3.0

Manual repeating is needed by all texture backends regardless of
whether they can support hardware repeating because when Cogl calls
the foreach_sub_texture_in_region method then it sets the wrap mode to
GL_CLAMP_TO_EDGE and no hardware repeating is possible.
2009-12-02 22:03:08 +00:00
Neil Roberts
5fcb29c916 cogl-primitives: Check for repeating after the coordinate transform
In _cogl_multitexture_quad_single_primitive we use a wrap mode of
GL_CLAMP_TO_EDGE if the texture coordinates are all in the range [0,1]
or GL_REPEAT otherwise. This is to avoid pulling in pixels from either
side when using GL_LINEAR filter mode and rendering the entire
texture. Previously it was checking using the unconverted texture
coordinates. This is ok unless the texture backend is radically
transforming the texture coordinates, such as in the sub texture
backend where the coordinates may map to something completely
different. We now check whether the coordinates are in range after
converting them.
2009-12-02 22:03:07 +00:00
Neil Roberts
812d4d25bb cogl: Move all of the fields from CoglTexture to CoglTexture2DSliced
Most of the fields that were previously in CoglTexture are specific to
the implementation of CoglTexture2DSliced so they should be placed
there instead. For example, the 'mipmaps_dirty' flag is an
implementation detail of the ensure_mipmaps function so it doesn't
make sense to force all texture backends to have this function.

Other fields such as width, height, gl_format and format may make
sense for all textures but I've added them as virtual functions
instead. This may make more sense for a sub-texture backend for
example where it can calculate these based on the full texture.
2009-12-02 22:03:07 +00:00
Neil Roberts
071dea2fbc cogl: Move data only used for upload out of CoglTexture
The CoglTexture struct previously contained some fields which are only
used to upload data such as the CoglBitmap and the source GL
format. These are now moved to a separate CoglTextureUploadData struct
which only exists for the duration of one of the cogl_texture_*_new
functions. In cogl-texture there are utility functions which operate
on this new struct rather than on CoglTexture directly.

Some of the fields that were previously stored in the CoglBitmap
struct are now copied to the CoglTexture such as the width, height,
format and internal GL format.

The rowstride was previously stored in CoglTexture and this was
publicly accessible with the cogl_texture_get_rowstride
function. However this doesn't seem to be a useful function because
there is no need to use the same rowstride again when uploading or
downloading new data. Instead cogl_texture_get_rowstride now just
calculates a suitable rowstride from the format and width of the
texture.
2009-12-02 22:03:07 +00:00
Neil Roberts
7f58c14dcd cogl: Use #ifdef GL around GL_TEXTURE_RECTANGLE_ARB
Commit 558b17ee1e added support for rectangle textures to the
framebuffer code. Under GLES there is no GL_TEXTURE_RECTANGLE_ARB
definition so this was breaking the build. The rest of Cogl uses
ifdef's around that constant so we should do the same here.
2009-12-02 21:59:58 +00:00
Emmanuele Bassi
59d84f7806 build: Fix CPP and LD flags
• The debug flags are pre-processor ones, so they should be listed
  inside AM_CPPFLAGS.

• Clutter's publicly exported symbols match the following regular
  expression:

    ^(clutter|cogl|json)_*

  The old one also listed "pango" as a possible prefix, but the
  Pango API is now under the Cogl namespace.
2009-12-02 16:03:55 +00:00
Emmanuele Bassi
17e3b526d5 docs: Document Clutter's threading model
Be explicit on how to deal with threads and Clutter.
2009-12-02 14:15:43 +00:00
Emmanuele Bassi
fc7bbf1abf docs: Fix docbook syntax
The <variablename> tag is really called <varname> in DocBook.
2009-12-02 14:15:19 +00:00