1
0
Fork 0
Commit graph

3480 commits

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

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

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

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

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

The supported child properties are:

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

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

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

The TableLayout was implemented starting from MxTable and
ClutterBoxLayout.

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

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

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

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

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

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

json-generator:

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

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

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

blur-effect:
win32/device-manager:

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

box-layout:
flow-layout:

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

clutter-model:

  The script gets confused with ClutterModelIter

stage:

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

test-layout:

  Don't really want to modify the tests

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

then it should also change its request mode depending on the orientation
of the image data, so that layout managers have a fighting chance of
sizing it correctly.
2010-08-05 16:19:51 +01:00
Emmanuele Bassi
2d4125a053 texture: Make the :filename property readable
UI builders and other tools are be interested in the file used to load
the image data.
2010-08-05 15:39:20 +01:00
Roman Kudiyarov
8326ea26f8 osx: Fixed stage resize policy
Added initialization of minimum window size property on Cocoa
side. This property works when user change window size by mouse
dragging. But when size is changed by clutter_actor_set_size this
property will not help and was added another check in
clutter_stage_osx_resize. Also osx_get_geometry was refactoried
because it returns incorrect values in many cases but now size is
saved in [Window reshape] in requisition_width/height and this value
will be returned in any case to frontend.
2010-08-04 15:13:12 +01:00
Roman Kudiyarov
c1f0b59911 test: Fixed test-rotate for osx platfom
There was a bug in clutter-shader-effect. We have to set to zero new object
of type GValue before we can use it in g_value_init.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
52b6a3cd49 osx: added resolution initialization in backend
It's important step of initialization because all features calls from
font rendering libs based on this parameter. By default it equals to
-1 and test-text-cache test crashes in this case.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
dc23b88de2 osx: Fixed warnings in osx event implementation 2010-08-04 15:13:11 +01:00
Roman Kudiyarov
af8308295c Added willResize delegate for osx stage.
By default a clutter stage is not user resizable and this delegate
controls this option while resizing the stage.
2010-08-04 15:13:11 +01:00
Roman Kudiyarov
49b2b62311 Fixed lack of reaction for keyboard events after showing stage on osx.
Trick with hiding view while showing the stage affects on responder
chain. The main view ceases to be first responder and we should
manually set first responder.
2010-08-04 15:13:11 +01:00