Commit Graph

267 Commits

Author SHA1 Message Date
Emmanuele Bassi
2567049ce3 Fix missing/redundant declarations 2012-03-07 12:36:43 +00:00
Emmanuele Bassi
cc25deade0 texture: Fix the async loop ceiling
The comment says that we're going to load textures in a loop until we
still have work to do, or if one iteration took more than 5
milliseconds, to avoid blowing up our frame budget, but the check is for
5 seconds, which is hardly a sensible value.
2012-03-06 15:42:00 +00:00
Emmanuele Bassi
78b237b535 Clean up the included headers
Especially inside ClutterStage.
2012-02-23 17:21:57 +00:00
Robert Bragg
a8e631543e Reduce our internal dependence on the Cogl 1.x api
Since Cogl has started restricting what cogl 1.x api is exposed when
COGL_ENABLE_EXPERIMENTAL_2_0_API is defined and since we build all
Clutter internals with COGL_ENABLE_EXPERIMENTAL_2_0_API defined this
patch makes a first pass at reducing our internal use of the Cogl 1.x
api.

The most notable api that's no longer exposed to us internally is
the cogl_material_ api so this switches all Clutter internals to use the
cogl_pipeline_ api instead. This patch also makes quite a bit of
progress removing internal uses of CoglHandle although there is still
more to go.
2012-02-21 17:46:11 +00:00
Neil Roberts
0e542aa306 clutter-texture: Don't create a dummy texture
All of the pipelines used for ClutterTexture actors share a common
pipeline ancestor created with cogl_pipeline_copy. Previously this
ancestor had a dummy 1x1 texture attached to it so that it would end
up with the same state as the child pipelines that will render with a
texture. Cogl now has a mechanism to specify that a texture will be
used with a pipeline layer without having to create an actual texture.
This patch makes it use that to avoid having an unused texture.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2012-02-14 12:09:18 +00:00
Emmanuele Bassi
1d84bf2b04 texture: Deprecate YUV setter
The YUV support depends on the driver support, and not only not many
drivers support YUV natively: the supported colorspaces are pretty much
useless.

The proper way to do YUV to RGB colorspace conversion on the GPU is to
use a fragment shader; for that, ClutterTexture and Cogl provide enough
API to achieve a good result - see the Clutter-GStreamer implementation,
for instance.
2012-01-31 10:28:04 +00:00
Emmanuele Bassi
c95b126571 texture: It's bytes per pixel, not bits
Clarify the error message when checking the bpp argument.
2012-01-31 10:23:48 +00:00
Emmanuele Bassi
8462b5ba45 Do not use set_parent()/unparent() internally
Use add_child()/remove_child() instead.
2012-01-16 23:35:13 +00:00
Emmanuele Bassi
2d76407016 debug: Remove CLUTTER_MARK
The debug macro is seldom used, and it's a bit lame at that.
2011-11-18 17:30:39 +00:00
Emmanuele Bassi
f63891f030 texture: Do not use clutter_get_timestamp()
The clutter_get_timestamp() output depends on whether Clutter was
compiled with debugging support — it's meant to be used only by the
debugging notes, and it should not be used for anything else.
2011-11-15 14:59:50 +00:00
Emmanuele Bassi
72da6f808e texture: Disable deprecation warnings
Sadly, ClutterTexture is still using internally deprecated API, like
clutter_actor_get_shader().
2011-10-12 12:36:41 +01:00
Emmanuele Bassi
389d247278 texture: Drop G_MUTEX_INIT
The static initializer for GMutex has been removed from GLib.

The g_thread_supported() call can also be removed: threading is always
enabled in GLib ≥ 2.31.
2011-10-07 15:09:47 +01:00
Emmanuele Bassi
56c7d9b0b3 texture: Simplify asynchronous loading code
The asynchronous loading code could do with some modernization.

First of all, we should drop the internal GMutex held when manipulating
the boolean flags: it's far too expensive for its role, and modern GLib
provides us with bitlocks that are quite a lot faster.

Then we should consolidate most of the implementation into something
smaller and more manageable.
2011-09-28 13:52:53 +01:00
Emmanuele Bassi
11c585c420 texture: Remove GStaticMutex
It's now possible to statically initialize a GMutex.
2011-09-28 13:52:53 +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
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
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
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
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
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
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
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
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
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
694632ce95 build: Re-arrange headers
Try to minimize the included headers, especially in clutter-actor.h.
2010-11-18 18:23:49 +00:00
Emmanuele Bassi
63cef64d17 docs: Fix some wrong function/signal/property names 2010-11-18 15:21:16 +00:00
Damien Lespiau
a318fe5ca5 texture: Warn when the file loaded from a ClutterScript can't be found
Telling the user about files not found when loading a ClutterScript with
ClutterTextures in it is very useful and can save a few minutes (or
hours) of frustation because it "does not work".
2010-11-01 11:43:35 +00:00
Emmanuele Bassi
46c597a1f6 Clean up clutter-private.h/6
Move all Actor private API to a separate file.
2010-10-21 12:22:17 +01:00
Emmanuele Bassi
8613013ab0 Clean up clutter-private.h/3
Move Stage private API to a separate header.
2010-10-21 11:33:26 +01:00
Damien Lespiau
155bde2465 texture: Fix the typos in the blurbs and make them not end with '.'
All the nifty things you discover when translating strings not exposed
to anyone. First the clutter-wide record of the number of typos in one
string. Second, ClutterTexture happened to have the only property blurbs
ending with a '.', remove them.
2010-10-05 08:39:40 +01:00
Damien Lespiau
a13182c740 cogl: Use Cogl (not COGL) consistently
If I remember correctly, Robert wants to name Cogl, Cogl (not COGL) so
start by having a consistent naming in the code.
2010-10-05 08:03:19 +01:00
Emmanuele Bassi
16f7ee13f2 Move default paint volume computation into a function
This should reduce the amount of copy and paste for actor sub-classes
that use the default paint volume from the allocation.
2010-09-29 15:13:00 +01:00
Robert Bragg
72eeb8e809 actor: make default get_paint_volume more conservative
There are too many examples where the default assumption that an actor
paints inside its allocation isn't true, so we now return FALSE in the
base implementation instead. This means that by default we are saying
"we don't know the paint volume of the actor", so developers need to
implement the get_paint_volume virtual to take advantage of culling and
clipped redraws with their actors.

This patch provides very conservative get_paint_volume implementations
for ClutterTexture, ClutterCairoTexture, ClutterRectangle and
ClutterText which all explicitly check the actor's object type to avoid
making any assumptions about subclasses.
2010-09-29 15:12:59 +01:00
Robert Bragg
f8a6e36f1b texture: Forward queue redraw/relayout for fbos
When clutter_texture_new_from_actor is use we need to track when the
source actor queues a redraw or a relayout so we can also queue a redraw
or relayout for the texture actor.
2010-09-29 15:12:57 +01:00
Robert Bragg
3540d222e1 paint volumes: another pass at the design
This is a fairly extensive second pass at exposing paint volumes for
actors.

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

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

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

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

The effect apis, clutter-texture and clutter-group have been update
accordingly.
2010-09-29 15:12:57 +01:00
Robert Bragg
2da127dcff texture: size fbos using clutter_actor_get_paint_box
Previously we used the transformed allocation but that doesn't take
into account actors with depth which may be projected outside the
area covered by the transformed allocation.
2010-09-29 15:12:57 +01:00
Emmanuele Bassi
7fe0df393b texture: Add more validation on the material
If set_cogl_texture() is called after unsetting the Texture's material
then we really want to make a copy of the template.

Also, we should assert more often if the internal state goes horribly
wrong: at least, we'll have a backtrace.
2010-09-18 08:41:52 +01:00
Robert Bragg
f5f066df9c Try to clean up how we handle actor transformations
When building actor relative transforms, instead of using the matrix
stack to combine transformations and making assumptions about what is
currently on the stack we now just explicitly initialize an identity
matrix and apply transforms to that.

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

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

ClutterStage now tracks an explicit projection matrix and viewport
geometry. The projection matrix is derived from the perspective whenever
that changes, and the viewport is updated when the stage gets a new
allocation. The SYNC_MATRICES mechanism has been removed in favour of
_clutter_stage_dirty_viewport/projection() APIs that get used when
switching between multiple stages to ensure cogl has the latest
information about the onscreen framebuffer.
2010-09-13 18:18:34 +01:00
Emmanuele Bassi
ba9aa3b332 texture: Move the material unref() in ::dispose 2010-09-06 18:09:19 +01:00
Emmanuele Bassi
128e981f6c texture: Do some more validation in get_cogl_texture()
Check the layer type, even though right now we only have one type
available.
2010-09-06 18:09:19 +01:00
Emmanuele Bassi
7e56a98413 texture: Use a base material for all instances
Creating new materials for every Texture instance results in a lot of
ARBfp programs being generated/compiled. Since most textures will just
be similar we should create a template material for all of them, and
then copy it in every instance. Cogl will try to optimize the generation
of the program and, hopefully, will reuse the same program most of the
time.

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

http://bugzilla.clutter-project.org/show_bug.cgi?id=2295
2010-09-06 18:09:19 +01:00
Emmanuele Bassi
abef73bb58 Replace cogl_color_set_from_* with cogl_color_init_from_*
The former is not yet "officially" deprecated by the latter, but it's
confusing to have them both in the code base.
2010-09-03 16:58:47 +01:00
Emmanuele Bassi
3e74f42f07 introspection: Add annotations
Reduce the amount of warnings coming from g-ir-scanner.
2010-09-03 12:14:50 +01:00
Robert Bragg
f8940e3c9a clutter-texture: queue redraw when changing pick_with_alpha
The expectation is that actors should call clutter_actor_queue_redraw
when ever some private state changes that affects painting *or* picking.
ClutterTexture was not doing this for pick_with_alpha property changes.
2010-08-18 18:30:30 +01:00
Emmanuele Bassi
92b1a33eb3 texture: Default square textures to height-for-width
Square textures should have a preferred geometry request set to
height-for-width, as it is the default for Clutter itself.
2010-08-16 15:56:49 +01:00
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
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
Chris Kühl
24b9748f0a Fixed more set using *_get_* typos.
http://bugzilla.clutter-project.org/show_bug.cgi?id=2233
2010-07-22 11:03:04 +01:00
Neil Roberts
1dee65770a Minor fix to the documentation for clutter_texture_get_sync_size
The documentation was recursively referring to itself causing a stack
overflow in the reader's brain.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2233
2010-07-22 10:06:26 +01:00