Compare commits

...

211 Commits

Author SHA1 Message Date
9321249b8d wayland: Implement the "inputfd" wayland protocols
This allows lending control to applications of evdev devices,
and withdrawing it with focus.
2020-06-10 20:32:19 +02:00
932340a989 background-content: Shut up warning
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1303
2020-06-10 10:42:18 +02:00
ca0156e9a7 background-content: Render background slices relative to actor box
The current code assumes that the actor will always have the same
size and position of the background texture, but part of the implicit
contract of being a ClutterContent is being able to render itself
at any given actor, at any given size.

For example, if the current code is given an actor with 0x0+100+100
as geometry, and no clipped region, it'll render not the whole
background, but the 0x0+100+100 rectangle of the background. In
practice, the actor geometry acts like a "clip mask" over the
background texture, due to the assumption that the actor will
always have the same size of the monitor.

Make the calculation of the texture slices relative to the actor
box.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1302
2020-06-09 17:07:02 -03:00
6d75b4fc53 background-content: Simplify method call
It's always passing the same pipeline and texture rect, simplify
by passing the MetaBackgroundContent instance itself.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1302
2020-06-09 17:07:02 -03:00
6bd382ad23 background-actor: Use MetaBackgroundContent
MetaBackgroundActor is still necessary for culling purposes,
but now the actual rendering of the background is delegated
to MetaBackgroundContent, as well as the sizing information.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1302
2020-06-09 17:07:02 -03:00
a1b3d1a2a7 Introduce MetaBackgroundContent
MetaBackgroundContent is a ClutterContent implementation
that can render a background to any attached actor. Right
now, it preserves all the properties and the rendering
model of MetaBackgroundActor.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1302
2020-06-09 17:07:02 -03:00
53f61f3778 stack-tracker: Don't log warnings on race conditions
X11 window stacking operations are by nature prone to race conditions.
For example, we might queue a "raise above" operation, but before it
actually takes place, the sibling the window was to be rased above, is
withdrawn.

In these cases we'd log warnings even though they are expected to
happen. Downgrade these warnings to debug messages, only printed when
MUTTER_VERBOSE is set.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1300
2020-06-09 18:46:38 +00:00
74c0d9140c stack-tracker: Fix coding style of meta_stack_op_apply()
Change tabs to spaces, clean up variable declarations.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1300
2020-06-09 18:46:38 +00:00
268336c21a clutter/actor: Allow animating content properties
ClutterActor allows animating effects, constraints, actions,
and the layout manager for property transitions. Extend this
functionality to the content as well.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1301
2020-06-09 15:09:26 -03:00
49e983b06e tests: Add a test for ClutterActors stage_views() API
Test that the stage-views list of ClutterActor is correct when moving an
actor, reparenting it, or hiding an actor up the hierarchy. Also test
that the "stage-views-changed" signal works as expected.

Don't test actor transforms for now because those aren't supported yet.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196
2020-06-09 16:07:46 +00:00
0f97196d84 clutter/actor: Don't traverse whole actor tree for updating stage-views
We currently go through the whole tree of mapped actors on every paint
cycle to update the stage views actors are on. Even if no actors need
updating of their stage views, traversing the actor tree is still quite
expensive and shows up when using a profiler.

So tone down the amounts of full-tree traversals we have to do on every
paint cycle and only traverse a subtree if it includes an actor which
actually needs updating of its stage views.

We do that by setting the `needs_update_stage_views` flag to TRUE
recursively for all parents up to the stage when the stage-views list of
an actor gets invalidated. This way we end up updating a few more actors
than necessary, but can avoid searching the whole actor tree for actors
which have `needs_update_stage_views` set to TRUE.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196
2020-06-09 16:07:46 +00:00
18c792d6f8 clutter/actor: Emit a signal when the stage-views an actor is on change
Add a new signal that's emitted when the stage views an actor being
painted on have changed, "stage-views-changed". For example this signal
can be helpful when tracking whether an actor is painted on multiple
stage views or only one.

Since we must clear the stage-views list when an actor leaves the stage
(actors that aren't attached to a stage don't get notified about the
stage views being changed/replaced), we also emit the new signal when an
actor gets detached from the stage (otherwise there would be an edge
case where no signal is emitted but it really should: An actor is
visible on a stage view, then detached from the stage, and then attached
again and immeditely moved outside the view).

Also skip the comparison of the old stage-views list and the new one if
nobody is listening to the signal to save some resources.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196
2020-06-09 16:07:46 +00:00
675a97d58e clutter/actor: Add API to get the stage-views an actor is painted on
There are certain rendering techniques and optimizations, for example
the unredirection of non-fullscreen windows, where information about the
output/stage-view an actor is on is needed to determine whether the
optimization can be enabled.

So add a new method to ClutterActor that allows listing the stage-views
the actor is being painted on: clutter_actor_peek_stage_views()

With the way Clutter works, the only point where we can reliably get
this information is during or right before the paint phase, when the
layout phase of the stage has been completed and no more changes to the
actors transformation matrices happen. So to get the stage views the
actor is on, introduce a new step that's done on every master clock tick
between layout and paint cycle: Traversing through the actor tree and
updating the stage-views the mapped actors are going to be painted on.

We're doing this in a separate step instead of inside
clutter_actor_paint() itself for a few reasons: It keeps the code
separate from the painting code, making profiling easier and issues
easier to track down (hopefully), it allows for a new
"stage-views-changed" signal that doesn't interfere with painting, and
finally, it will make it very easy to update the resource scales in the
same step in the future.

Currently, this list is only invalidated on allocation changes of
actors, but not on changes to the transformation matrices. That's
because there's no proper API to invalidate the transformation matrices
ClutterActor implementations can apply through the apply_transform()
vfunc.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196
2020-06-09 16:07:46 +00:00
8127494e52 clutter/stage: Rename update_resource_scales to clear_stage_views
When the stage views the stage is shown on are changed, ClutterStage
currently provides a clutter_stage_update_resource_scales() method
that allows invalidating the resource scales of all actors. With the new
stage-views API that's going to be added to ClutterActor, we also need a
method to invalidate the stage-views lists of actors in case the stage
views are rebuilt and fortunately we can re-use the infrastructure for
invalidating resource scales for that.

So since resource scales depend on the stage views an actor is on,
rename clutter_stage_update_resource_scales() and related methods to
clutter_stage_clear_stage_views(), which also covers resource scales.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196
2020-06-09 16:07:46 +00:00
670f4f22fe clutter/stage: Remove _clutter_stage_get_max_view_scale_factor_for_rect
Since we now have _clutter_stage_get_views_for_rect(), we can easily
replace _clutter_stage_get_max_view_scale_factor_for_rect() with it and
remove that private method.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196
2020-06-09 16:07:46 +00:00
e27d2702a8 clutter/stage: Add private method to get the stage-views of a rectangle
We'll need this method for implementing a new stage-views-on API for
ClutterActor which lists the stage views an actor is on.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1196
2020-06-09 16:07:46 +00:00
dfe33897db meson_options: Use libGLESv2.so.2 for COGL_DRIVER=gles2, not libGLESv2.so
The former is present on any system that supports OpenGL|ES 2. The latter
is just provided in developer packages. Since we access the library via
`g_module_open` it's safe to just rely on `libGLESv2.so.2`.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1282

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1298
2020-06-09 18:32:01 +08:00
90c20b185b clutter/actor: Disconnect from "layout-changed" signal on destroy
While the layout manager of a ClutterActor does get properly unset when
destroying an actor, we currently forget to disconnect the
"layout-changed" signal from it.

So do that, and while at it, also switch to using the signal id for
disconnecting from the signal instead of
g_signal_handlers_disconnect_by_func(), which caused problems before
because it might traverse the signal handler list.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1281
2020-06-08 17:23:05 +00:00
4d7c8d68bc clutter/actor: Mark offscreen-redirect property as flag everywhere
We currently are confusing g_param_spec_enum and g_param_spec_flags for
the offscreen-redirect property of ClutterActor. Since it's actually a
flag, make it a flag everywhere.

Fun fact: This was already partly done with
d7814cf63e, but that commit missed the
setter.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1292
2020-06-08 15:25:11 +00:00
455de5d6d3 clutter/align-constraint: Listen to queue-relayout signal of source
Just like the ClutterBindConstraint, the ClutterAlignConstraint should
listen to "queue-relayout" of its source actor, not
"notify::allocation". That's because the latter will queue a relayout
during an allocation cycle and might cause relayout loops.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1296
2020-06-08 14:58:15 +00:00
99c9f4c1fa wayland/data-device: Don't create and leak unused memory on dnd
"offer" is overwritten with the result of meta_wayland_data_offer_new a
few lines later.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1293
2020-06-08 12:11:11 +00:00
dd32ff018a wayland: Free selection streams streams after transfer
They were only being closed but never freed.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1293
2020-06-08 12:11:11 +00:00
019643bad0 core: Free clipboard selection source on shutdown
The clipboard manager is the only code to ever set the display selection
source, so it should also be responsible for unsetting it when the
clipboard manager gets shut down.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1293
2020-06-08 12:11:11 +00:00
a031ac067e core: Fix memory selection source leak after clipboard owner disappears
When an app disappears after some data from it has been copied to the
clipboard, the owner of the clipboard selection becomes a new memory
selection source. The initial reference this new selection source is
never unref'ed, which leads to this being leaked on the next clipboard
selection owner change.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1293
2020-06-08 12:11:11 +00:00
f712387325 compositor: use XDG_CONFIG_HOME as initial lookup path for xkb
Using XDG_CONFIG_HOME allows users to place their keyboard configuration into
their home directory and have them loaded automatically.
libxkbcommon now defaults to XDG_CONFIG_HOME/xkb/ first, see
https://github.com/xkbcommon/libxkbcommon/pull/117

However - libxkbcommon uses secure_getenv() to obtain XDG_CONFIG_HOME and thus
fails to load this for the mutter context which has cap_sys_nice.
We need to manually add that search path as lookup path.

As we can only append paths to libxkbcommon's context, we need to start with
an empty search path set, add our custom path, then append the default search
paths.

The net effect is nil where a user doesn't have XDG_CONFIG_HOME/xkb/.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/936
2020-06-08 11:29:30 +00:00
1eaf9e5f63 tests/clutter/timeline-interpolate: Maximize error tolerance
Simply to make it less flaky.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1291
2020-06-06 00:27:40 +02:00
7222bdde57 tests/clutter/timeline: Lower FPS even further
It's still flaky running in CI, lets run it even slower.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1291
2020-06-06 00:27:40 +02:00
007d27fa40 tests/conform: Use the clutter stage from mutter
The tests created their own stage, which caused various issues. Lets use
the one from mutter instead.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
01609de587 clutter/stage: Clear pick stack when hiding
Hiding a compositor stage is not something that's really supported, but
will still be used by tests, to get closer to a "fresh" stage for each
test case, when the tests eventually start using the mutter provided
stage.

It'll use that stage simply because creating standalone stages isn't
supported.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
83ee122fad cogl/frame-info: Stop passing the CoglOutput
It's unused, and if it would be, it'd be unreliable, as it'd only be
valid on the Xlib and GLX cogl backends.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
55302dbb38 cursor-renderer: Pass backend to constructor
Then use the backend passed instead of the global singleton.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
7876018755 backends/native: Get clutter backend from backend
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
e3c332fa10 backend: Remove unused freeze/thaw functions
They are no longer used, so remove them.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
faa831f2f6 backend: Remove cursor renderer construction fallback
All backends have their own cursor renderer constuctors, so remove the
unused fallback.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
1a915f06cf clutter: Remove CLUTTER_REPAINT_FLAGS_QUEUE_REDRAW_ON_ADD
It was unused, and will simplify things when we're without a master
clock.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
6754195580 clutter/script-parser: Don't skip construct parameters when constructing
The script parser only included G_PARAM_CONSTRUCT_ONLY parameters when
constructing objects. This causes issues if an object requires a
parameter to be set during construction, but may also change after. Fix
this by including G_PARAM_CONSTRUCT parameters when constructing script
objects as well.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
25f9406e69 compositor: Get the stage via the backend
We would get the MetaDisplay from the backend singleton before creating
the MetaCompositor, then in MetaCompositor, get the backend singleton
again to get the stage. To get rid of the extra singleton fetching, just
pass the backend the MetaCompositor constructors, and fetch the stage
directly from the backend everytime it's needed.

This also makes it available earlier than before, as we didn't set our
instance private stage pointer until the manage() call.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
9fc428f2e7 clutter/stage: Remove unused function clutter_stage_ensure_redraw()
Not used by anything, and redraws are eventually not going to be stage
global anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
a05dd813da clutter/timeline: Remove clutter_timeline_clone()
It was deprecated long ago, and users should switch to using te regular
constructors.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
08b30d6fe2 clutter/timeline: Remove deprecated 'loop' property
It was since long ago replaced by a 'repeat-count' property.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
84f55d38dd clutter/pan-action: Clean up line lengths
The file stood out and was hard to read because lines were very long
compared to the rest of clutter and mutter. Clean that up by cutting
lines into pieces where appropriate.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
75b5e079cf clutter/timeline: Add meaning to constructor argument variable name
Start follow the convention used in ClutterFrameClock by including the
meaning as well as time granularity in the variable name. The
constructor takes the intended duration of the constructed timeline in
milli seconds, so call the constructor argument `duration_ms`. This is
done in preparation for adding more constuctors.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
d742f9331c tests/clutter: Port timeline-rewind to current test suite
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
420ca31f0b tests/clutter: Port timeline-progress to current test suite
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
73da901cd3 tests/clutter: Port timeline-interpolate to current test suite
The error tolerance is increased dramatically to make the test less
flaky when running in CI.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
dd16fac0c7 tests/clutter: Port timeline tests to current test suite
Also fix a test that dependends on a specific element order in a list
that wasn't defined to have any particular order.

The frames per second is decreased from 30 to 10, to make the test less
flaky when running in CI.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
1b2af2891f tests/clutter/conform: Default to print test logs
To change to the old behavior, pass --quiet. The aim is to be make it
easier to debug issues only reproducing in the CI.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
050c21c24f tests/clutter/conform: Don't run tests in parallel
Might end up failing to acquire D-Bus names, resulting in warnings.
Avoid that by not running the tests in parallel.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:26 +00:00
7b45de941b tests/test-client: Disable shadow for Wayland client too
The shadow was disabled for the X11 client as it was far to unreliable
when comparing sizes.

It seems that the Wayland backend has been somewhat unreliable as well,
where some race condition causing incorrect sizes thus a flaky test.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1288
2020-06-05 00:15:52 +02:00
8d84449941 test-runner: Wait before finding MetaWindow when showing
A "show" command calls gtk_window_show() and gdk_display_sync(), then
returns. This means that the X11 window objects are guaranteed to have
been created in the X11 server.

After that, the test runner will look up the window's associated
MetaWindow and wait for it to be shown.

What this doesn't account for is if mutter didn't get enough CPU time to
see the new window. When this happens, the 'default-size' stacking test
sometimes failed after hiding and showing the X11 window.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1288
2020-06-05 00:15:52 +02:00
f61d4b4e70 Bump version to 3.37.2
Update NEWS.
2020-06-03 01:11:15 +02:00
dcb42d3b25 clutter/actor: Sanity check new allocations
Apparently some shell extensions are setting invalid NaN allocations,
leading to weird crashes like
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1849.

Even though an implementation error like this probably deserves a crash,
those can be hard to debug since the crash can happen anywhere the
allocation is being used later. So let Clutter be the good guy and
prevent implementations from setting invalid allocations by
sanity-checking the ClutterActorBoxes using g_return_if_fail.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1849

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1280
2020-06-02 20:53:12 +00:00
59a2bff8e2 cogl tests: Normally skip tests that are not expected to succeed
If a test is not expected to succeed, then running it could be considered
to be a waste of resources, particularly if the failure might manifest
as an indefinite hang (see cogl!11), or if the test is likely to dump core
and trigger "expensive" crash-reporting mechanisms like systemd-coredump,
corekeeper, abrt or apport.

Skip the tests that are expected to fail. They can still be requested via
an environment variable, which can be set after fixing a bug to check which
tests are now passing.

Originally cogl!15, adapted for mutter's fork of cogl to use gboolean
instead of CoglBool.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1272

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-06-02 20:15:26 +00:00
720360b07a clutter/actor: Don't allocate actors if only the absolute origin changed
For actors which don't have needs_allocation set to TRUE and where the
new allocation wouldn't be different from the old one, the allocate()
vfunc doesn't have to be called. We still did this in case a parent
actor was moved though (so the absolute origin changed), because we
needed to propagate the ABSOLUTE_ORIGIN_CHANGED allocation flag down to
all actors.

Since that flag is now removed and got replaced with a private property,
we can simply notify the children about the absolute allocation change
using the existing infrastructure and safely stop allocating children at
this point.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1247
2020-06-02 19:44:42 +00:00
9b39e37fee clutter/actor: Notify hidden actors about absolute allocation changes
With commit 0eab73dc2e we introduced an optimization of not doing
allocations for actors which are hidden. This broke the propagation of
absolute origin changes to hidden actors, so if an actor is moved while
its child is hidden, the child will not get
priv->needs_compute_resource_scale set to TRUE, which means the resource
scale won't be updated when the child gets mapped and shown again.

Since we now have priv->absolute_origin_changed, we can simply check
whether that is TRUE for our parent before bailing out of
clutter_actor_allocate() and if it is, notify the whole hidden sub-tree
about the absolute origin change.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1247
2020-06-02 19:44:42 +00:00
38104755a2 clutter/stage: Make set_viewport() a static method
Since clutter_stage_set_viewport() is only used inside clutter-stage.c
anyway, we can make it a static method. Also we can remove the x and y
arguments from it since they're always set to 0 anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1247
2020-06-02 19:44:42 +00:00
7abf0f1e2d clutter/stage: Set viewport without getting the last allocation
When getting the last allocation using
clutter_actor_get_allocation_box(), Clutter will do an immediate
relayout of the stage in case an actor has an invalid allocation. Since
the allocation is always invalid when the allocate() vfunc is called,
clutter_stage_allocate() always forces another allocation cycle.

To fix that, stop comparing the old allocation to the new one to find
out whether the viewport changed, but instead use the existing check in
_clutter_stage_set_viewport() and implement the behavior of rounding the
viewport to the nearest int using roundf() (which should behave just as
CLUTTER_NEARBYINT()) since we're passing around floats anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1247
2020-06-02 19:44:42 +00:00
0a37c32a72 clutter/actor: Update absolute_origin_changed inside set_allocation()
When manipulating the allocation of a ClutterActor from an allocate()
vfunc override, clutter_actor_set_allocation() is used to let Clutter
know about the changes.

If the actors allocation or its absolute origin did not change before
that, this can also affect the actors absolute_origin_changed property
used by the children to detect changes to their absolute position.

So fix this bug (which luckily didn't seem to affect us so far) and set
priv->absolute_origin_changed to TRUE in case the origin changes inside
clutter_actor_set_allocation_internal(). Since this function is always
called when our allocation changes, we no longer need to update
absolute_origin_changed in clutter_actor_allocate() now.

Since a change to the absolute origin always affects the resource scale,
too, we also need to move that check from clutter_actor_allocate() here
to make sure we update the resource scale.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1247
2020-06-02 19:44:42 +00:00
9f121a211d clutter/actor: Always reset absolute_origin_changed after relayout
Since the introduction of the shallow relayout functionality it's
possible to start an allocation cycle at any point in the tree, not only
at the stage. Now when starting an allocation at an actor that's not the
stage, we'd still look at the absolute_origin_changed property of this
actors parent, which might still be set to TRUE from the parents last
allocation.

So avoid using the parents absolute_origin_changed property from the
last allocation in case a shallow relayout is being done and always
reset the absolute_origin_changed property to FALSE after the allocation
cycle.

This broke with the removal of the ABSOLUTE_ORIGIN_CHANGED
ClutterAllocationFlag that was done in commit dc8e5c7f.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1247
2020-06-02 19:44:42 +00:00
c823b5ddba renderer-native: Don't leak DMA buffer CoglFramebuffer
When we created the DMA buffer backed CoglFramebuffer, we handed it over
to CoglDmaBufHandle which took its own reference. What we failed to do
was to release our own reference to it, effectively leaking it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1283
2020-06-02 18:39:27 +02:00
97175f8fa1 screen-cast-src: Destroy hash dmabuf table after stream
The stream will clean up the buffers, so let it do that before we
destroy them under its feet. Note that it'll only do this after the
following PipeWire commit:

    commit fbaa4ddedd84afdffca16f090dcc4b0db8ccfc29
    Author: Wim Taymans <wtaymans@redhat.com>
    Date:   Mon Jun 1 15:36:09 2020 +0200

        stream: allow NULL param and 0 buffers in disconnect

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1283
2020-06-02 18:39:23 +02:00
c5b1bdc0fe tests/stacking/restore-position: Always use wait_reconfigure
wait_reconfigure ensures that the whole configure back and forth
completes before continuing. Doing this after every state change ensures
that we always end up with the expected state, thus fixes flakyness of
the restore-position stacking test.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1279
2020-05-29 14:47:10 +00:00
f8e2234ce5 backends/native: Drop external keyboard detection for ::touch-mode
This cannot be made to work reliably. Some factoids:

- Internal devices may be connected via USB.
- The ACPI spec provides the _PLD (Physical location of device) hook to
  determine how is an USB device connected, with an anecdotal success
  rate. Internal devices may be seen as external and vice-versa, there is
  also an "unknown" value that is widely used.
- There may be non-USB keyboards, the old "AT Translated Set 2 Keyboard"
  interface does not change on hotplugging.
- Libinput has an internal series of quirks to classify keyboards as
  internal of external, also with an "unknown" value.

These heuristics are kinda hopeless to get right by our own hand. Drop
this external keyboard detection in the hope that there will be something
more deterministic to rely on in the future (e.g. the libinput quirks
made available to us directly or indirectly).

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2378
Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2353

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1277
2020-05-29 14:37:21 +00:00
38bbd9593b backends/x11: Implement ClutterSeat::touch-mode for the X11 backend
This only checks touchscreen availability as we have no access to
tablet-mode switch events as we do on the native backend.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1242

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1278
2020-05-29 12:39:59 +00:00
a3cc62c285 cogl tests: Force defined behaviour for 24-bit left-shifts
When r is 128 or more, running tests compiled with the undefined behaviour
sanitizer (ubsan) reports:

test-utils.c:312:45: runtime error: left shift of 128 by 24 places cannot be represented in type 'int'

which indeed it cannot. Force the type to be unsigned 32-bit so that we
get defined behaviour.

Similarly, in test-atlas-migration, the left-shifted guint8 is promoted
to int, which again does not have enough non-sign bits available to
left-shift a value >= 128 by 24 bits. Again, force the shift to be done
in unsigned 32-bit space.

This was originally cogl!22, but applies equally to mutter's fork of cogl.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1271

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-05-27 21:26:49 +00:00
c3bf10d19a cogl test-premult: Don't free texture data until CoglBitmap is freed
According to the cogl_bitmap_new_for_data documentation, the data is not
copied, so the application must keep the buffer alive for the lifetime
of the CoglBitmap. Freeing it too early led to a use-after-free in the
cogl unit tests. With that fixed, the test passes, so remove the known
failure annotation.

This AddressSanitizer trace is from the original cogl, but the bug and
fix apply equally to mutter's fork of cogl:

==6223==ERROR: AddressSanitizer: heap-use-after-free on address 0x62100001a500 at pc 0x7f3e2d4e7f4e bp 0x7ffcd9c41f30 sp 0x7ffcd9c416e0
READ of size 4096 at 0x62100001a500 thread T0
    #0 0x7f3e2d4e7f4d  (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x96f4d)
    #1 0x7f3e260c7f6b in util_copy_box ../src/gallium/auxiliary/util/u_surface.c:131
    #2 0x7f3e268c6c10 in u_default_texture_subdata ../src/gallium/auxiliary/util/u_transfer.c:67
    #3 0x7f3e26486459 in st_TexSubImage ../src/mesa/state_tracker/st_cb_texture.c:1480
    #4 0x7f3e26487029 in st_TexImage ../src/mesa/state_tracker/st_cb_texture.c:1709
    #5 0x7f3e26487029 in st_TexImage ../src/mesa/state_tracker/st_cb_texture.c:1691
    #6 0x7f3e2644bdba in teximage ../src/mesa/main/teximage.c:3105
    #7 0x7f3e2644bdba in teximage_err ../src/mesa/main/teximage.c:3132
    #8 0x7f3e2644d84f in _mesa_TexImage2D ../src/mesa/main/teximage.c:3170
    #9 0x7f3e2cd1f7df in _cogl_texture_driver_upload_to_gl driver/gl/gl/cogl-texture-driver-gl.c:347
    #10 0x7f3e2ccd441b in allocate_from_bitmap driver/gl/cogl-texture-2d-gl.c:255
    #11 0x7f3e2ccd441b in _cogl_texture_2d_gl_allocate driver/gl/cogl-texture-2d-gl.c:462
    #12 0x7f3e2ce3a6c0 in cogl_texture_allocate cogl/cogl-texture.c:1398
    #13 0x7f3e2ce3e116 in _cogl_texture_pre_paint cogl/cogl-texture.c:359
    #14 0x7f3e2cdee177 in _cogl_pipeline_layer_pre_paint cogl/cogl-pipeline-layer.c:864
    #15 0x7f3e2cd574af in _cogl_rectangles_validate_layer_cb cogl/cogl-primitives.c:542
    #16 0x7f3e2cdd742f in cogl_pipeline_foreach_layer cogl/cogl-pipeline.c:735
    #17 0x7f3e2cd5c8b0 in _cogl_framebuffer_draw_multitextured_rectangles cogl/cogl-primitives.c:658
    #18 0x7f3e2cd60152 in cogl_rectangle cogl/cogl-primitives.c:858
    #19 0x5570a71ed6a0 in check_texture tests/conform/test-premult.c:103
    #20 0x5570a71ed946 in test_premult tests/conform/test-premult.c:159
    #21 0x5570a71df0d6 in main tests/conform/test-conform-main.c:58
    #22 0x7f3e2bcd809a in __libc_start_main ../csu/libc-start.c:308
    #23 0x5570a71e0869 in _start (/home/smcv/src/debian/cogl/tests/conform/.libs/test-conformance+0x33869)

0x62100001a500 is located 0 bytes inside of 4096-byte region [0x62100001a500,0x62100001b500)
freed by thread T0 here:
    #0 0x7f3e2d5581d7 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x1071d7)
    #1 0x5570a71ed58b in make_texture tests/conform/test-premult.c:69

previously allocated by thread T0 here:
    #0 0x7f3e2d558588 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x107588)
    #1 0x7f3e2d384500 in g_malloc ../../../glib/gmem.c:99

This was originally cogl!12.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1274

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-05-27 15:50:36 +01:00
0b6a3166ed clutter/text: Also queue relayout if the actor has no valid allocation
In clutter_text_queue_redraw_or_relayout() we check whether the size
of the layout has changed and queue a relayout if it did, otherwise we
only queue a redraw and save some resources.

The current check for this also queues a redraw if the actor has no
valid allocation. That seems right on the first glance since the actor
will be allocated anyway, but we actually want to call
clutter_actor_queue_relayout() again here because that also invalidates
the size cache of the actor which might have been updated and marked
valid in the meantime.

So make sure the size cache is always properly invalidated after the
size of the layout changed and also call clutter_actor_queue_relayout()
in case the actor has no allocation.

This fixes a bug where getting the preferred width of a non-allocated
ClutterText, then changing the string of the ClutterText, and then
getting the preferred width again would return the old cached width (the
width before we changed the string).

The only place where this bug is currently happening is in the overview,
where we call get_preferred_width() on the unallocated ClutterText of
the window clone title: When the window title changes while the
ClutterText is unallocated the size of the title is going to be wrong
and the text might end up ellipsized or too large.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1150
2020-05-27 08:41:31 +00:00
066bc5986d wayland: Drive frame callbacks from stage updates
Don't tie frame callbacks to actor painting, as it may end up in
situations where we miss sending frame callbacks when we should have. An
example of this is when a surface is partially off screen, and then
reports damage that is fully off screen. When this happen, we are likely
not to repaint anything, thus we won't send any frame callbacks even
though it's "suitable" for rendering again, as the surface is not on a
separate workspace or fully obscured.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/817
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1152

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:46:57 +02:00
e8b09df8d2 wayland/compositor: Pass backend when constructing
This is so that it can be retrieved later without going via the global
singleton.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:35:01 +02:00
1571f8078a Reshuffle Wayland initailization
Move Wayland support (i.e. the MetaWaylandCompositor object) made to be
part of the backend. This is due to the fact that it is needed by the
backend initialization, e.g. the Wayland EGLDisplay server support.

The backend is changed to be more involved in Wayland and clutter
initialization, so that the parts needed for clutter initialization
happens before clutter itself initialization happens, and the rest
happens after. This simplifies the setup a bit, as clutter and Wayland
init now happens as part of the backend initialization.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:35:00 +02:00
510cbef15a surface-actor: Move out some X11-ism to X11 subclass
On X11 we don't update the texture in certain circumstances, such as if
the surface is a fullscreen unredirect, or doesn't have a Pixmap. On
Wayland we only want to avoid updating the texture if there is no
texture, but as this is handled implicitly by MetashapedTexture, we
don't need to try to emulate the X11-y conditions in the generic layer
and instead just have the implementations handle update processing
themself.

This doesn't have any functional changes, but removes a vfunc from
MetaSurfaceActorClass.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:35:00 +02:00
99c9a14bc8 clutter/stage: Make clutter_stage_schedule_update() public API
It's effectively used by mutter by abusing a ClutterTimeline to scedule
updates.  Timelines are not really suited in places that is done, as it
is really just about getting a single new update scheduled whenever
suitable, so expose the API so we can use it directly.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:35:00 +02:00
b8003807b0 clutter/stage: Make clutter_stage_schedule_update() always schedule
We could call clutter_stage_schedule_update() and it wouldn't actually
schedule anything, as the master frame clock only tries to reschedule if
1) there is an active timeline, 2) there are pending relayouts, 3) there
are pending redraws, or 4) there are pending events. Thus, a call to
clutter_stage_schedule_update() didn't have any effect if it was called
at the wrong time.

Fix this by adding a boolean state "needs_update" to the stage, set on
clutter_stage_schedule_update() and cleared on
_clutter_stage_do_update(), that will make the master clock reschedule
an update if it is TRUE.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:35:00 +02:00
8e1bd64e05 clutter/stage-cogl: Use view fb instead of onscreen fb for debug-drawing
We need to use the framebuffer of the view instead of the onscreen
framebuffer when painting the damage region, otherwise the redraw clips
on rotated monitors won't be shown correctly.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
5aa56aa7f5 clutter/stage-cogl: Remove unneeded helper
The helper called a single function; lets just call it directly instead.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
c2c4f74923 clutter/stage-view: Add tile based shadow damage detection
Compare, tile by tile, whether actual damage actually changed any
pixels. While this requires mmap():ing DMA buffers and comparing their
content, we should only ever use shadow buffers when we're using the
software renderer, meaning mmap() is cheap as it doesn't involve any
downloading.

This works by making the shadow framebuffer double buffered, while
keeping track of damage history. When we're about to swap the onscreen
buffer, we compare what part of the posted damage actually changed,
records that into a damage history, then given the onscreen buffer age,
collect all actual damage for that age. The intersection of these tiles,
and the actual damage, is then used when blitting the shadow buffer to
the onscreen framebuffer.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1157

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
f8daa6bc70 cogl/dma-buf: Add mmap/munmap helpers
Avoids dealing directly with mmap() and munmap().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
5b07ccd0a7 cogl/dma-buf: Add API to synchronize reading
Used before and after accessing DMA buffer content using mmap().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
ae4d299499 clutter/stage-cogl: Extract damage history logic
Move the damage history tracking to a new ClutterDamageHistory helper
type. The aim is to be able to track damage history elsewhere without
reimplementing the data structure and tracking logic.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
8798325489 clutter/stage-view: Only blit the damage part of the shadow buffer
This fixes the last "copy everything" paths when clutter doesn't
directly paint onto the onscreen framebuffer. It adds a new hook into
the stage view called before the swap buffer, as at this point, we have
the swap buffer damag regions ready, which corresponds to the regions we
must blit according to the damage reported to clutter.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
9e34028742 clutter/stage-cogl: Only construct damage array if it'll be used
It's only used when we actually swap buffers, which we only do if the
target framebuffer is an onscreen.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
258f859e8d clutter/stage-view: Only paint redraw clip from offscreen
The rest didn't change, so only actually paint the part of the offscreen
that was composited as part of the stage painting. In practice, this
means that, unless a shadow buffer is used, we now only paint the
damaged part of the stage, and copy the damage part of the offscreen to
the onscreen.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
9d3e4fd402 clutter/stage-cogl: Use buffer age when view monitor is rotated
We failed to use the buffer age when monitors were rotated, as when they
are, we first composite to an offscreen framebuffer, then later again to
the onscreen. The buffer age checking happened on the offscreen, and an
offscreen being single buffered, they can't possible support buffer
ages.

Instead, move the buffer age check to check the actual onscreen
framebuffer. The offscreen to onscreen painting is still always full
frame, but that will be fixed in a later commit.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
03c65b93e6 region-utils: Make transform util const correct
The input should be const, as it will not be altered.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
db975bd2a8 clutter/stage-view: Simplify painting of offscreen slightly
We will only ever have an "offscreen" if we're painting transformed in
some way, so the 'can_blit' checking is unnecessary. Remove it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
4e27a4ea1d clutter/stage-view: Always use cogl_blit_framebuffer() from shadowfb
It should only be used when direct blitting is supported, so there is no
reason we should have to deal with pipelines etc when blitting from the
shadow buffer to the onscreen.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
346cadeddb renderer/native: Only enable shadowfbs if we can blit
There is no point in enabling shadow buffers if we can't as that'd be
even slower than not having them at all.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
f60c485117 cogl: Make private BLIT_FRAMEBUFFER feature public
Will be a requirement for enabling shadow buffers.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
19550c28f9 clutter/stage-view: Change set_dirty..() API to invalidate..()
The manual "cleaning" of the viewport and projection state is removed,
and we only ever try to invalidate the state so that it'll be updated
next time. Change the API used to reflect this.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
c4949b553d clutter/stage-view: Move fb viewport and projection setting to here
The stage would fetch the front framebuffer and set the viewport and
projection matrix, but if we are going to more than one front buffer,
that won't work, so let the stage just pass the viewport and projection
matrix to the view and have the view deal with the framebuffer(s).

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
675a2d13b9 clutter/stage-view: Move shadowfb struct fields into anonymous struct
With the aim to collect shadow buffer related things in one place, place
them in an anonymous struct.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
f4d9953b9c renderer-native: Move shadow fb construction to the stage view
The stage view will need a more involved approach to shadow buffers, in
order to implement things such double buffered shadow buffers and damage
detection.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
6db94a0b77 clutter/stage-view: Add name property
Will be used for logging to identify what view a log entry concerns. For
the native and nested backend this is the name of the output the CRTC is
assigned to drive; for X11 it's just "X11 screen", and for the legacy
"X11 screen" emulation mode of the nested backend it's called "legacy
nested".

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
9bf6faf639 output: Add name getter
This will return the name of the connector, e.g. DP-2.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
4434a17d08 cogl/dma-buf-handle: Pass more metadata to handle constructor
Could be useful would one want to mmap the dmabuf and deal with its
content manually in CPU space.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
c65f63b647 wayland/actor-surface: Don't notify geometry-changed on mapped changes
There's no reason to notify the surface that its geometry changed when
the visibility of the actor changes. This is only needed to update the
outputs of the surface, so do that directly instead.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1235
2020-05-26 14:54:57 +02:00
79d981aac9 wayland/actor-surface: Factor in mapped clones in mapped check
We started listening to notify::mapped with commit
5eb5f72434 in order to emit
wl_surface.leave events consistently when a surface gets hidden. This
caused a problem with the ClutterClones used in the overview, since
those temporarily map and unmap the windows for painting, spamming
wl_surface.leave and enter events to all surfaces.

We can easily fix that by also treating mapped clones as mapped, which
means the surface should also be on a wl_output when the overview is
shown.

Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/1141

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1235
2020-05-26 14:54:57 +02:00
2791f5b466 clutter/actor: Make has_mapped_clones() factor in parent actors
All existing users of clutter_actor_has_mapped_clones() actually want to
know whether the actor is being cloned by a visible clone, it doesn't
matter to them if that clone is attached to an actor somewhere else in
the tree or to the actor itself.

So make clutter_actor_has_mapped_clones() a bit more convenient to use
and also check the clones of the parent-actors in that function.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1235
2020-05-26 14:54:57 +02:00
e68bb27df2 wayland/actor-surface: Don't listen to notify::position signal
We started listening to "notify::position" on surface actors with commit
08e4cb54. This commit was done to fix a regression from commit cf1edff9,
which forgot to handle some cases like the actual WindowActor and not
the SurfaceActor (which is a child of the WindowActor) moving (that was
fixed by listening to MetaWindows "position-changed" signal). Also that
commit introduced meta_wayland_surface_update_outputs_recursively(),
which updates the outputs of all (sub-)surfaces in case any position
changed and made sure subsurfaces also get their outputs updated in case
the parent actor moved.

Connecting to the "notify::position" signal, which the above commit also
did is now superflous though because position changes will queue a
relayout and the actors allocation will change during the next
allocation cycle, notifying the "allocation" property which we also
listen to.

So save some resources and stop listening to that signal.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1235
2020-05-26 14:52:15 +02:00
e12b2c417e clutter/actor: Use priv->allocation instead of get_allocation_box()
The comment in _clutter_actor_get_allocation_clip() explicitely notices
that it doesn't need the behavior of doing an immediate relayout as
clutter_actor_get_allocation_box() does. The comment is also still valid
since the code calling _clutter_actor_get_allocation_clip() checks for
priv->needs_allocation just before.

So let's just use the allocation directly here instead of going through
that function.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1264
2020-05-23 10:35:25 +00:00
0fbda366e8 native: Return an error if no drm devices are found
Without this, we'll end up segfaulting when trying to log the
non-existing error.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1217
2020-05-22 20:25:06 +00:00
106d332c71 backend/xcursor: Support a "blank" cursor type
We don't have enough Xlib code in mutter ...

Joking aside, it can be useful to make the cursor invisible
without hiding it, for example for replacing the actual cursor
with an actor in gnome-shell; the real cursor should still
update the focus surface in that case, and not sneak into
screenshots or -casts.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1244
2020-05-22 14:10:50 +00:00
c42c11583d clutter: Use G_DECLARE_DERIVABLE_TYPE for ClutterAction and subclasses
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/788
2020-05-22 08:56:23 +00:00
8c131b32b1 clutter/actor-meta: Use G_DECLARE_DERIVABLE_TYPE
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/788
2020-05-22 08:56:23 +00:00
c8e12ead08 screen-cast-src: Notify about the stream being closed after dispatch
We're iterating inside the PipeWire loop when detecting PipeWire errors,
and shouldn't destroy the PipeWire objects mid-iteration. Avoid this by
first disabling the stream src (effectively stopping the recording),
then notifying about it being closed in an idle callback. The
notification eventually makes the rest of the screen cast code clean up
the objects, including the src and the associated PipeWire objects, but
will do so outside the PipeWire loop iteration.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1251

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1251
2020-05-22 00:15:48 +00:00
8a541c08fb stage-x11: Move view management to renderer
In the native backend, the MetaRenderer manages the view by creating one
per CRTC, but until now the MetaStageX11 managed the view for the X11
backend. This caused some issues as it meant meta_renderer_get_views()
not returning anything, and that the view of the X11 screen not being a
MetaRendererView, while in the other backends, all views are.

Fix this by moving the view management responsibility to
MetaRendererX11Cm, and have MetaStageX11 only operate on it via
meta_renderer_x11_cm_*() API. The MetaRendererX11Cm takes care of making
sure the view is always added to the list in the renderer, and turning
X11 screen sizes into "layouts" etc.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1251
2020-05-22 00:15:48 +00:00
dfed5f6a11 stage-x11: Clean up include macros
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1251
2020-05-22 00:15:48 +00:00
96dd794fd1 screen-cast-stream-src: Don't throttle if max framerate is 1/0
The max framerate 1/0 means variable without any particular max, so
don't throttle if that was set.

Not doing this would end up with a floating point exception.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1251
2020-05-22 00:15:48 +00:00
73a436362a renderer: Change 'set_legacy_view()' to 'add_view()'
"Legacy" is a misleading name, it's just how the native backend and the
X11 backend behaves differently. Instead rename it to 'add_view()' and
add the sanity check to the caller.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1251
2020-05-22 00:15:48 +00:00
7343b8d817 wayland/dma-buf: Make gbm_bo import function better named
It imports a DMA buffer as a gbm_bo, but only if it can be used to scan
it out, so name it import_scanout_gbm_bo().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1261
2020-05-21 23:59:56 +00:00
dbf47b652e wayland/dma-buf: Handle failing to import scanout DMA buffer
A DMA buffer might not be able to scanout, and in that case the import
with GBM_BO_USE_SCANOUT will fail. Handle that by failing to scanout,
effectively falling back to compositing.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1261
2020-05-21 23:59:56 +00:00
b97a6e62a3 window: Add a note about the trustworthiness of the client PID
Since PIDs are inherently insecure because they are reused after a
certain amount of processes was started, it's possible the client PID
was spoofed by the client.

So make sure users of the meta_window_get_pid() API are aware of those
issues and add a note to the documentation that the PID can not be
totally trusted.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
4fac1a4862 window: Cache the client PID
Since the PID of a window can't change as long as the window exists, we
can safely cache it after we got a valid PID once, so do that by adding
a new `window->client_pid` private property.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
70ba844c3c window: Return pid_t in meta_window_get_pid()
Just as with the last commit, pid_t is compatible with all platforms and
we should use that everywhere, so also make meta_window_get_pid() return
a pid_t.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
bc0b9f7628 window: Use pid_t for get_client_pid() vfunc
It makes sense to use pid_t when getting the PID since that will work on
all platforms and architectures.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
c971d6ea1f window: Remove support for _NET_WM_PID
We have the client pid API that works on both Wayland and X11 nowadays,
so the _NET_WM_PID property is no longer needed, remove it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
dac09a8e23 window: Use client PID for meta_window_get_pid()
The shell uses the PID of windows to map them to apps or to find out
which window/app triggered a dialog. It currently fails to do that in
some situations on Wayland, because meta_window_get_pid() only returns a
valid PID for x11 clients.

So use the client PID instead of the X11-exclusive _NET_WM_PID property
to find out the PID of the process that started the window. We can do
that by simply renaming the already existing
meta_window_get_client_pid() API to meta_window_get_pid() and moving
the old API providing the _NET_WM_PID to meta_window_get_netwm_pid().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
11f224f4b0 clutter/box-layout: Remove child meta
ClutterBoxLayout's layout policy of using the generic ClutterActor
align/expand properties for children that are expanded and a custom
meta otherwise is confusing, in particular as the x-fill/y-fill
defaults don't match the default CLUTTER_ACTOR_ALIGN_FILL align.

StBoxLayout's own custom child meta (which was deprecated last
cycle) is probably the only consumer. And luckily, the St meta
uses different x-fill/y-fill default that match the ClutterActor
defaults, so removing it will not affect code that doesn't use
the deprecated properties themselves.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1265
2020-05-21 15:49:31 +02:00
a1be7cdbd7 tests/clutter: Don't test BoxLayout's child properties
They are about to become ex-properties.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1265
2020-05-21 15:49:31 +02:00
82d96aebe1 clutter/box-layout: Remove deprecated API
This stuff has been deprecated for a very long time, and given that
ClutterBoxLayout is most commonly used via StBoxLayout, the impact of
removing it should be low. It will however open the door to further
cleanups.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1265
2020-05-21 15:49:31 +02:00
c14ba5937f clutter/tests: Stop using deprecated BoxLayout API
... so that we can remove it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1265
2020-05-21 15:49:31 +02:00
e50e14af82 clutter/actor: Remove "allocation-changed" signal
Since we now no have ClutterAllocationFlags, there's no reason anymore
for keeping the "allocation-changed" signal, so remove it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
787d9a5a15 clutter: Use notify::allocation instead of allocation-changed
We're going to remove the "allocation-changed" signal from ClutterActor
since it's no longer needed now that ClutterAllocationFlags are gone.

So listen to "notify-allocation" instead, which has been the recommended
thing to do for some time now anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
3c29bf7491 clutter: Remove allocation flags
Since there are now no more allocation flags, we can remove
ClutterAllocationFlags from Clutter.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
dc8e5c7f8b clutter/actor: Replace ABSOLUTE_ORIGIN_CHANGED flag with a property
The ABSOLUTE_ORIGIN_CHANGED allocation flag is only really useful to
propagate the information of the absolute origin of an actor having
changed inside Clutter. It wasn't used anywhere else besides for some
debug messages and it probably shouldn't be used in custom layout
implementations anyway since 1) actors shouldn't have to be aware of
absolute allocation changes and 2) it doesn't factor in changes to the
transformation matrix of a parent.

Also the propagation of absolute origin changes using this flag broke
with commit 0eab73dc2e and now hidden actors are no longer notified
about those changes.

Additionally, this flag gets in the way of a few potential optimizations
since it has to be propagated even if the allocation box of the child
hasn't changed, forcing a reallocation of the child.

So replace this flag with a simple new private property of ClutterActor
absolute_origin_changed, but keep the exact same behavior for now.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
0a986fc885 clutter/tests: Remove usage of ABSOLUTE_ORIGIN_CHANGED flag
We're going to remove this allocation flag, so stop using in the
interactive test-layout test.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
04e983383f clutter/stage: Remove ABSOLUTE_ORIGIN_CHANGED flag from debug message
The ABSOLUTE_ORIGIN_CHANGED allocation flag is going to be removed from
Clutter, so stop using it for this debug message.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
7ae6e0101c clutter/actor: Remove clutter_actor_maybe_layout_children()
Since we now only layout the children ourselves in case the actor
implementation doesn't override the allocate vfunc, we can remove
clutter_actor_maybe_layout_children() and move the functionality inside
clutter_actor_real_allocate().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
affb3de829 clutter/actor: Don't layout children inside set_allocation()
Now that we no longer have the DELEGATE_LAYOUT we expect all actors
overriding the allocate() vfunc to allocate their children themselves.

Since clutter_actor_set_allocation() is only called from custom
vfunc_allocate() implementations, the condition in
clutter_actor_maybe_layout_children() would always fail, which makes
calling the function useless anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:30 +00:00
24d7a7ad0b clutter: Remove DELEGATE_LAYOUT allocation flag
The CLUTTER_DELEGATE_LAYOUT flag is unintuitive and makes the allocation
process inside Clutter unnecessarily complicated. It's very easy for
actors overriding the allocate() vfunc to layout their children
themselves (in fact most of them do this), and it also never made sense
that clutter_actor_set_allocation() does eventually layout children.

There was no ClutterActor implementation in mutter or gnome-shell which
actually used the DELEGATE_LAYOUT flag, but even without it, it's fairly
easy to archive the same behavior now: In the allocate() override,
adjust the allocation as wanted, then chain up to the parent vfunc
without calling clutter_actor_set_allocation().

So remove the CLUTTER_DELEGATE_LAYOUT flag, which will allow making the
relayout code in Clutter a bit easier to follow.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:30 +00:00
4729cb779e clutter/stage: Stop using DELEGATE_LAYOUT allocation flag
We're going to remove allocation flags, so stop depending on the
DELEGATE_LAYOUT flag in ClutterStage and call
clutter_layout_manager_allocate() directly, which is pretty
straightforward.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:30 +00:00
c8837a8de5 backends: Make uniform checks on remote desktop input dbus methods
They all checked that the remote session service talked with the
correct peer, and some of them did check that there is an associated
screencast session.

Add a new check for the session being started (as it's state is
decoupled with screencast session availability) and move all checks
to a function that is called from all input-oriented DBus methods.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1254

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1258
2020-05-20 10:19:24 +00:00
283cccbe9f backends: Ensure remote desktop dbus interface state
Ensure that it does receive Start and Stop orderly, and error out
otherwise.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1258
2020-05-20 10:19:24 +00:00
a7bf6322e3 clutter/actor: Use priv->parent instead of public API sometimes
The public API to get the parent actor, clutter_actor_get_parent() does
a type check whether the actor is actually a ClutterActor. In case of
_clutter_actor_apply_relative_transformation_matrix(), which is called
recursively and very often during the paint process, this type check
shows up with almost twice the amount of hits than the actual matrix
multiplication.

So use the parent pointer directly in some code paths that are executed
very often and avoid the expensive type checking there, we can do that
since both places are not public API.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1259
2020-05-19 08:17:09 +00:00
1d5f9b6917 backend-x11: Reintroduce XInitThreads
It was removed in 3.34 as part of 6ed5d2e2. And we thought that was the
only thread that might exist and use X11. But the top gnome-shell crasher
in 3.36 seems to suggest otherwise.

We don't know what or where the offending thread is, but since:

 1. We used XInitThreads for years already prior to 3.34; and

 2. Extensions or any change to mutter/gnome-shell could conceivably use
    threads to make X calls, directly or indirectly,

it's probably a good idea to reintroduce XInitThreads. The failing assertion
in libx11 is also accompanied by a strong hint:

```
fprintf(stderr, "[xcb] Most likely this is a multi-threaded client " \
                "and XInitThreads has not been called\n");
```

https://bugs.launchpad.net/bugs/1877075

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1252

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1256
2020-05-15 15:30:09 +08:00
3c068ef135 wayland/surface: Simplify state cleanup after merge
Instead of manually freeing things, use the existing helper function.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1232
2020-05-14 00:34:49 +02:00
2becb3dd29 wayland: Add support for wayland-protocols primary selection protocol
This protocol was added some time ago. Supporting it fell through the
cracks. Add new data device/source/offer implementations for it,
interoperation between primary selection protocols (and X11 primary
selection for that matter) comes for free.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/943

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1255
2020-05-13 18:27:46 +02:00
55f5177fe0 build: Build scaffolding for primary-selection wayland protocol
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1255
2020-05-13 18:18:18 +02:00
037b68ab8e wayland: Rename gtk primary protocol files to "legacy"
We want to make room for the wayland-protocols primary selection
protocol. Rename our private protocol as "legacy".

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1255
2020-05-13 18:18:14 +02:00
b45d5ef3f5 wayland: Send primary offer to all data devices from the same client
Make the data device track the keyboard focus, and use that list to
forward the primary selection to all data devices from the same
client.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1253
2020-05-13 14:44:55 +00:00
7e4e371466 wayland: Send clipboard offers to all data devices from the same client
Make the data device track the keyboard focus, and use that list to
forward the clipboard selection to all data devices from the same
client.

This is however not the case of DnD data offers, as the semantics
of multiple in-flight offers is unclear.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1250

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1253
2020-05-13 14:44:55 +00:00
fbfa136bbb clutter/stage-cogl: Cleanup damage history (un-)scaling a bit
Reverting the scale and offset applied to the damage history can be done
in one step, using a few less temporary allocations by passing the
offset right away to a new scale_offset_and_clamp_region() function.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:54 +00:00
434845dbe5 clutter/stage-cogl: Don't loop through region rects twice
There's no reason for using two loops to fill the rects array in
offset_scale_and_clamp_region(), we can do that using only one loop.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:54 +00:00
967511be61 clutter/stage-cogl: Don't intersect the damage region with the view
Since the damage history region is tracked per-view, all the regions it
includes should be inside the current view anyway, so don't
unnecessarily intersect that region with the view.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
43c7a82461 clutter/stage-cogl: Cleanup setting of the damage history
Since we now check for the buffer age before setting up the
fb_clip_region, that region will be set to the full extents of the view
in case the buffer age is invalid. This in turn means we don't have to
do this again later and can simply fill the damage history with the
fb_clip_region that's already set for us.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
066e78c9b3 clutter/stage-cogl: Warn if the fb_clip_region is empty
Since a NULL redraw_clip means that a full view redraw should be done
and an empty redraw clip may never be set (see the width/height checks
in clutter_stage_view_add_redraw_clip()), the fb_clip_region should
always be set to a reasonable region that's either the whole view or
individual regions inside the view.

So make sure that's actually the case by warning and that the
fb_clip_region isn't empty, which allows dropping another few lines of
code.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
08f47fee16 clutter/stage-cogl: Check for DISABLE_CLIPPED_REDRAWS earlier
Right now we're checking for the DISABLE_CLIPPED_REDRAWS debug flag
after creating the fb_clip_region and adjusting the redraw_clip. That
means that if may_use_clipped_redraw was TRUE, the redraw_clip will
still be set to the region and thus cause the stage to only be partially
redrawn. Since we don't push a clip to the framebuffer though
(use_clipped_redraw is now FALSE), parts of the view will get corrupted.

To fix that, disable clipped redraws right away if the debug flag is
set. This also allows removing the may_use_clipped_redraw bool and
replacing it entirely with use_clipped_redraw.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
afe4cd482e clutter/stage-cogl: Stop painting redraw clip outline
We already have a better way to paint the redraw clip: Painting the
damage region paints the individual rects of the clip region and not
only the bounding rect.

So stop painting an outline around the redraw clip bounding rect when
CLUTTER_DEBUG_REDRAWS is set.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
3fed768db4 clutter/stage-cogl: Don't push scissor clip with one clip rectangle
While this is meant as an optimzation to only use the scissor clip and
not the stencil buffer if there's only one clip rectangle, it's not
needed since this optimization is going to be applied to region clips
anyway inside _cogl_clip_stack_gl_flush() (see cogl-clip-stack-gl.c).

So remove the unnecessary optimization here and rely on cogl-clip-stack
to do it for us.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
8c52b431bb clutter/stage-cogl: Stop doing subpixel compensation
This was introduced with commit 9ab338d7b6 because the clipping of
fractionally scaled redraws caused glitches, it seems like this is no
longer needed nowadays, so let's remove it.

This should make obscured region culling work a bit better for
fractionally scaled framebuffers because because we overdraw a slightly
smaller region than the actually damaged one. We still do overdraw
though since the clipping region is stored using integers and thus
any non-integer values have to be extended to the bounding rect.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
d9ffbf0576 clutter/stage-cogl: Don't clip when clipped redraws are disabled
It doesn't make sense to set the redraw clip when painting the stage if
clipped redraws are disabled. That's because when visualizing the redraw
clip and any new redraws are clipped, the old visualiziations would
remain visible, leaving multiple confusing rectangles on the screen.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
b0953b92ba clutter/stage-cogl: Remove scale_and_clamp_rect() function
This function  is only used in offset_scale_and_clamp_region() and can
simply be included there.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1113
2020-05-13 11:08:53 +00:00
819f9afa31 shaped-texture: Fix typo in documentation
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1252
2020-05-13 12:12:01 +02:00
7a0bc5af7f background: Limit mipmap levels to avoid loss of visible detail
When the wallpaper image is larger than the monitor resolution we already
use mipmapping to scale it down smoothly in hardware. We use
`GL_TEXTURE_MIN_FILTER` = `GL_LINEAR_MIPMAP_LINEAR` for the highest quality
scaling that GL can do. However that option is designed for 3D use cases
where the mipmap level is changing over time or space.

Since our wallpaper is not changing distance from us we can improve the
rendering quality even more than `GL_LINEAR_MIPMAP_LINEAR`. To do this we
now set `GL_TEXTURE_MAX_LEVEL` (if available) to limit the mipmap level or
blurriness level to the lowest resolution (highest level) that is still
equal to or higher than the monitor itself. This way we get the benefits
of mipmapping (downscaling in hardware) *and* retain the maximum possible
sharpness for the monitor resolution -- something that
`GL_LINEAR_MIPMAP_LINEAR` alone doesn't do.

Example:

  Monitor is 1920x1080
  Wallpaper photo is 4000x3000
  Mipmaps stored on the GPU are 4000x3000, 2000x1500, 1000x750, ...

  Before: You would see an average of the 2000x1500 and 1000x750 images.
  After:  You will now only see the 2000x1500 image, linearly sampled.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1003
2020-05-13 09:37:31 +00:00
c5fbab6bad cogl: Add new function cogl_pipeline_set_layer_max_mipmap_level()
To configure an exact value of `GL_TEXTURE_MAX_LEVEL` clamped to within
the range of possible levels.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1003
2020-05-13 09:37:31 +00:00
f4301b77fa cogl: Generalize maybe_update_max_level() into set_max_level()
This way the caller can choose their own precondition.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1003
2020-05-13 09:37:31 +00:00
a3f27dfd89 cogl: Ensure GL_TEXTURE_MAX_LEVEL is set before using it
Just in case it was lower before. So that `upload_subregion_to_gl` is
not trying to upload to a disallowed mipmap level.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1003
2020-05-13 09:37:31 +00:00
73ce9c2e81 cogl: Replace an outdated #ifdef
The feature `GL_TEXTURE_MAX_LEVEL` it is hiding actually exists
in ES>=3.0, so the #ifdef is not appropriate.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1003
2020-05-13 09:37:31 +00:00
fd27c7c444 cogl: Delete a duplicate (masked) variable declaration
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1003
2020-05-13 09:37:31 +00:00
a51807fc1e tests: Move monitor test functions into common utils
It's very useful to have common functions for easily creating a monitor
test setup for all kinds of tests, so move create_monitor_test_setup()
and check_monitor_configuration() and all the structs those are using to
monitor-test-utils.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1243
2020-05-13 08:38:40 +00:00
3c35a78769 tests/monitor-store-unit-tests: Rename some structs
We're going to move some structs from monitor-unit-tests.c to
monitor-test-utils.h and some names are currently clashing with the
struct names here, so rename those to be specific to the
MonitorStoreUnitTests.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1243
2020-05-13 08:38:40 +00:00
ae7cb7a3bf tests/monitor-unit-tests: Check test state outside of common function
check_monitor_test_clients_state() is a function that's only meant to be
used in the monitor-unit-tests, and since we're going to move the
functions for creating MonitorTestSetups into a common file, this
function is going to be in the way of that. So move the checking of the
test client state outside of check_monitor_test_clients_state().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1243
2020-05-13 08:38:39 +00:00
531b0ab300 tests/monitor-unit-tests: Use TestCaseExpect for checking configuration
Similar to the last commit, allow checking configurations without
passing the whole MonitorTestCase, but instead only the
MonitorTestCaseExpect object.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1243
2020-05-13 08:38:39 +00:00
7cc604b9e5 tests/monitor-unit-tests: Use TestCaseSetup for building TestSetup
We're going to move the functions for building MonitorTestSetups to the
common monitor-test-utils.c file.

To make building test setups a bit more straightforward in case no
TestCaseExpect is wanted, change create_monitor_test_setup() to take a
MonitorTestCaseSetup instead of a MonitorTestCase as an argument.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1243
2020-05-13 08:38:39 +00:00
f3a65c9b32 tests/monitor-test-utils: Remove unused function definition
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1243
2020-05-13 08:38:39 +00:00
dec97a6541 tests/monitor-transform: Also test invert()
Commit e06daa58c3 changed the tested values to use corresponding valid
enum values instead of negative ones. Unfortunately that made one value
become a duplicate of an existing one and also in part defeated the original
intention of checking the implementation of
`meta_output_crtc_to_logical_transform`.

Use `meta_monitor_transform_invert` to fix both shortcomings.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1242
2020-05-13 08:19:42 +00:00
cfa2d1abf7 shaped-texture: Add a few explanatory comments
One of the important classes in Mutter's handling of client textures is
the `MetaShapedTexture`. This commit adds a few gtk-doc comments which
explain its purpose, with special attention to the viewport methods.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1210
2020-05-13 07:57:58 +00:00
d9fb6b5ca2 wayland/surface: Connect to "output-destroyed" in surface_entered_output
Since we're now connecting to one more signal of MetaWaylandOutput, keep
signal connections in one place and move connecting the
"output-destroyed" signal to surface_entered_output() and disconnecting
it to surface_left_output().

This also allows us to use the "outputs_to_destroy_notify_id" as a
simple set and rename it to "outputs".

While at it, also use g_hash_table_destroy() instead of
g_hash_table_unref() since destroy is more clear than unref and does the
same thing in this case.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1230
2020-05-11 18:06:58 +00:00
696b534570 wayland/surface: Send enter event when a client binds to wl_output late
When hotplugging a new monitor, we recreate all the MetaWaylandOutputs
and need to emit leave events to the surfaces for the old wl_outputs and
enter events for the newly created ones.

There's a race condition though: We might update the monitors a surface
is on (and thus emit enter/leave events for the wl_outputs) before the
Wayland client is registered with the new wl_output (ie. the
bind_output() callback of MetaWaylandOutput was called), which means we
don't send an enter event to the client in surface_entered_output().
Since MetaWaylandSurface now has the MetaWaylandOutput in its outputs
hashtable, it thinks the client has been notified and won't send any
more enter events.

To fix that, make MetaWaylandOutput emit a new signal "output-bound"
when a client bound to the output and make all surfaces which are on
that output listen to the signal. In the signal handler compare the
newly added client to the client the surface belongs to, and if it's the
same one, send an enter event to that client.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1230
2020-05-11 18:06:58 +00:00
38db4a5a65 wayland/wl-output: Emit "output-destroyed" signal earlier
The "output-destroyed" signal is used for notifying MetaWaylandSurfaces
that an output they are shown just got invalid (for example because a
monitor hotplug happened).

While we delay the destroying of outputs by 10 seconds since commit
1923db97 because of a race-condition, it doesn't make sense to wait 10
seconds until we let surfaces know that an output was destroyed.

So move the emission of the "output-destroyed" signal to
make_output_inert(), which is called before we start the 10 seconds
delay.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1230
2020-05-11 18:06:58 +00:00
6f62c5b575 core/place: Use work area when centering new window.
use the workarea instead of the logical monitor

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/964
2020-05-09 09:47:42 +00:00
d823a54b5d monitor-transform: Don't call abs on non-negative enum
It causes Clang to show a lot of warnings during compilation because it
thinks the abs call is useless.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1234
2020-05-09 01:02:22 +02:00
e06daa58c3 tests/monitor-transform: Test only valid enums
This test was introduces assuming we'd do interger math outside
of `meta-monitor-transform`. We later agreed to not do that and require
valid enums, but forgot to remove the corresponding test case.

Test the corresponding valid enums instead of negative ones.

See https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1064

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1234
2020-05-09 01:02:22 +02:00
1880e22229 clutter-actor: Remove unused clutter_actor_get_allocation_vertices
It was also apparently broken (mutter#1126)

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1126
2020-05-08 09:52:49 +00:00
bd28581471 monitor-manager: Remove "supports-mirroring" from D-Bus desciption file
This is unused since commit 0a6034ef3a

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1134
2020-05-08 06:50:16 +00:00
82470cd40d tests/stacking: Add test checking the initial size
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:25 +00:00
b4972f573c tests/stacking: Add test for checking restored positions
Going maximized -> unmaximized should restore the previous position. The
same for untiling, or going from tiled, to maximized, to floating.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:25 +00:00
c97c409c50 tests/test-runner: Add 'move' and 'assert_position'
Make it possible for tests to move the windows, and check their
positions.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:25 +00:00
989e2ccc46 tests/restore-size: Also test that untiling restores correctly
Tiling, then untiling should restore to the size prior to tiling.

Tiling, maximizing, then unmaximizing should also restore to the size
prior to tiling.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:25 +00:00
e09e62d585 tests/test-runner: Add tile and untile commands
This allows test cases to tile windows to the right or left, and untile,
just as the keyboard shortcuts does.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
033f0d11bf window: Set fall-back tile monitor if not set
When tiling, we want to set the tile monitor. To not have to do this
from the call site, make meta_window_tile() fall back to the current
monitor if nothing set it prior to the call.

This will make it more convenient for test cases to test tiling
behavior.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
668eb318c7 window: Add meta_window_untile()
It does the same as the untile keyboard shortcut does, i.e. handles
going back to saved maximized state. It's split out to be able to be
tested by the stacking tests.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
449cbe153b tests/stacking: Test some maximize fullscreen interaction
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
9b8e5a05f5 tests/test-client: Add 'fullscreen' and 'unfullscreen' commands
This needs some hand holding when calculating the "full" size of the
window, as the titlebar isn't actually shown.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
d14c8cf9a4 tests/stacking: Check that unmaximize to new size works
A client that set a new fallback size while being maximized should not
restore to the one prior to being maximized.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
4571de5772 tests/stacking: Add test to verify we unmaximize correctly
The test tests that (for both X11 and Wayland) that:

 * The client unmaximizes after mapping maximized to a predictable size
 * That the client unmaximizes to the same size after toggling maximize

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
62f449d7d5 tests/test-runner: Add a 'wait_reconfigure' command
This makes sure that a client has properly responded to a configure
event it itself triggered. In practice, this is just two 'wait'
commands, with a 'dispatch' in between, which is needed because a single
one does not reliably include the two way round trip happening when e.g.
responding to a unmaximize configure event triggered by a unmaximize
request.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
476ef76de6 tests/test-runner: Add 'assert_size' command
The 'assert_size' command checks that the size of the window, both
client side and compositor side, corresponds to an expected size set by
the test case.

The size comparison can only be done when the window is using 'csd', in
order for both the client and server to have the same amount of
understanding of the title bar. For ssd, the client cannot know how
large the title bar, thus cannot verify the full window size.

Sizes can be specified to mean the size of the monitor divided by a
number. This is that one can make sure a window is maximized or
fullscreened correctly.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
48de81b63e tests/test-client: Remove shadow from X11 test client CSS style
Gtk is quite buggy and "fluid" in how it handles the shadow margins for
windows under X11. The "size" of the window fluctuate between including and
excluding a shadow margin in a way that causes issues, as there are no
atomic update of any state going on.

In order to avoid running into those particular issues now, lets get rid
of shadows so the margins are always zero, when the client is using the
X11 backend.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
2ee3d5392b tests/test-client: Make 'resize' client command include the titlebar
To get some kind of consistency between what 'resize' means for the
compositor and the client, make the size correspond to the "frame rect"
of the window, i.e. the window geometry in the Wayland case, and the
window size including the titlebar in the X11 case.

This is so that the window size later can be reliably compared both in
the compositor and in the client using the same expected dimensions.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
0f2a33cc9c tests/test-client: Add line breaks to warning messages
When toying with the test client to try to reproduce issues (e.g.
writing commands on stdin to create and manipulate windows), when you
write a command incorrectly you'll get a warning printed to standard
out. The problem, however, is that it doesn't include a line break in
the end, meaning when you type the correct command, it won't be on a new
line.

Fix this minor annoyance by adding line breaks to all warning messages.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
2ce622f057 tests/test-runner: Plumb "resize" command
The test client could already understand the resize command, but they
could not be added to metatests as the command was not properly plumbed
via the test runner. Establish the plumbing for the resize command so
that resize tests can be added.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
76083d76af tests/test-client: Add commands to maximize/unmaximize
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
132060db21 ci: Save built artifacts only for the test build
We only test the meson-build job, so there's no point to save artifacts for
the other test-build only builds.

So, only save meson logs artifacts (with a default gitlab expiration time)
for the other build-without-* jobs

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1236
2020-05-07 22:08:44 +00:00
c7f2ae1b16 build: Add configuration summary line about coverage being enabled
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1236
2020-05-07 22:08:44 +00:00
24a0e72ae9 ci: Remove the MALLOC_PERTURB_ definition
meson already provides one by default [1].

[1] https://github.com/mesonbuild/meson/blob/master/docs/markdown/Unit-tests.md#malloc_perturb_

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1236
2020-05-07 22:08:44 +00:00
5c4938e479 ci: Enable coverage reports in test build
While we don't have an high number of tests, we still have some code
coverage and so we can track this via gitlab CI, given that it supports it
natively.

So add gcovr to the DockerFile dependency, build with -Db_coverage=true
meson native parameter, and add another manual job to make ninja to generate
the coverage reports on requests or in any master or tag ref.

Keep the artifacts around to be able to browse the generated HTML files and
eventually print the text reports so that they can be parsed by gitlab.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1236
2020-05-07 22:08:44 +00:00
322b51cded clutter: Remove ClutterAnimation
This removes ClutterAnimation and related tests. ClutterAnimation has
been deprecated for a long time, and replacements exist and are used by
e.g. GNOME Shell since a while back.

This also disables a few relatively unrelated interactive tests, as they
rely on ClutterAnimation to implement some animations they use to
illustrate what they actually test.

As interactive tests currently are more or less untestable due to any
interaction with them crashing, as well as they in practice means
rewriting the tests using non-deprecated animation APIs, they are not
ported right now. To actually port the interactive tests, it needs to be
possible to fist interact with them.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
b46bc98d44 tests/clutter/conform: Remove left-over ClutterAnimator scripts
ClutterAnimator is long gone; remove some leftover test scripts.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
da5be1fdea clutter/animatable: Remove left-over vfunc
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
bc18438cb0 clutter/box-layout: Make 'easing-mode' be an enum
In the past, it was a odd mix of possible different types, all coalesced
into an unsigned integer. Now, hovewer, it's always a
ClutterAnimationType, so lets change the name of getter, setter and
property to what it really is.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
e3c0fcf7d5 tests/clutter: Add back redhand_alpha.png and light0.png
They were removed long long ago, but are still used, so add them back to
get the relevant tests usable again.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
73cb96ddb9 clutter: Remove 'ClutterAlpha'
It was some kind of deprecated interpolation mechanism used in
ClutterAnimation. We're not using it, and have non-deprecated
replacement functionality, so lets drop it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
1cb59f44ab clutter/layout-manager: Remove unused animation API
One less unused animation API to care about.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
a55a286b15 clutter: Remove deprecated 'ClutterState'
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
18e7b814f2 tests/wayland: Don't test file sealing on the fallback case
When memfd_create isn't used, the file isn't sealed. Therefore, we
should skip test_readonly_seals on the fallback case. This fixes
compilation error on FreeBSD 12, which does not support memfd_create.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1229
2020-05-07 19:39:13 +00:00
e073076119 backends/native: Unset the correct button codes when a virtual device is destroyed
We were iterating through evcodes, but using API that expects Clutter button
numbers. Instead of transforming those to Clutter numbers to have those translated
back, use the inner seat API that already takes evcodes.

Fixes stuck buttons keys after a virtual device is destroyed while those are
pressed.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1239
2020-05-07 17:01:05 +00:00
5d58156134 wayland/keyboard: Chain finalize up to the parent class
Finalize the parent class of the Wayland keyboard object.

Suggested-by: Marco Trevisan (Treviño) <mail@3v1n0.net>
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1238
2020-05-07 10:27:32 +00:00
c38fa4fa5c clutter: Remove CLUTTER_ACTOR_IN_REPARENT flag
The CLUTTER_ACTOR_IN_REPARENT and the CLUTTER_IN_REPARENT flag are never
set and the logic for skipping unmap, unrealize and the emission of the
"parent-set" signal during reparents has been solved differently by
leaving out the CHECK_STATE and EMIT_PARENT_SET flags when calling
add_child_internal() and remove_child_internal().

The only place where those REPARENT flags are theoretically still useful
is in the clutter_actor_verify_map_state() debugging function, but that
is never called during reparent anyway, so simply leave the comment
regarding reparent there.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1228
2020-05-07 09:01:31 +00:00
5201d77b0b keybindings: Use current monitor for move-to-center
Move to center uses all monitors for calculating work area.

This can lead to an unexpected behaviour on some monitor
configurations resulting in current window being split between
monitors. We should move window to the center of the active display.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1073
2020-05-06 16:03:45 +05:00
aedf692e0c backends: move 'input_device' to HAVE_LIBWACOM scope
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1231
2020-05-03 23:35:03 +01:00
275 changed files with 8961 additions and 12677 deletions

View File

@ -4,6 +4,7 @@ stages:
- review
- build
- test
- coverage
check-commit-log:
stage: review
@ -17,7 +18,7 @@ check-commit-log:
build-mutter:
stage: build
script:
- meson . build -Dbuildtype=debugoptimized -Degl_device=true -Dwayland_eglstream=true --werror --prefix /usr
- meson . build -Dbuildtype=debugoptimized -Db_coverage=true -Degl_device=true -Dwayland_eglstream=true --werror --prefix /usr
- ninja -C build
- ninja -C build install
artifacts:
@ -35,9 +36,8 @@ build-without-opengl-and-glx:
- ninja -C build
- ninja -C build install
artifacts:
expire_in: 1 day
paths:
- build
- build/meson-logs
only:
- merge_requests
- /^.*$/
@ -49,9 +49,8 @@ build-without-native-backend-and-wayland:
- ninja -C build
- ninja -C build install
artifacts:
expire_in: 1 day
paths:
- build
- build/meson-logs
only:
- merge_requests
- /^.*$/
@ -66,7 +65,6 @@ test-mutter:
G_SLICE: "always-malloc"
MALLOC_CHECK_: "3"
NO_AT_BRIDGE: "1"
MALLOC_PERTURB_: "123"
script:
- dconf update
- mkdir -m 700 $XDG_RUNTIME_DIR
@ -74,10 +72,30 @@ test-mutter:
- >
dbus-run-session -- xvfb-run -s '+iglx -noreset'
meson test -C build --no-rebuild -t 10 --verbose --no-stdsplit --print-errorlogs --wrap catchsegv
artifacts:
expire_in: 1 day
paths:
- build
only:
- merge_requests
- /^.*$/
test-mutter-coverage:
stage: coverage
dependencies:
- test-mutter
script:
- ninja -C build coverage
- cat build/meson-logs/coverage.txt
artifacts:
paths:
- build/meson-logs
when: manual
except:
refs:
- tags
- master
can-build-gnome-shell:
stage: test
dependencies:

View File

@ -16,7 +16,7 @@ RUN dnf -y update && dnf -y upgrade && \
# For running unit tests
dnf install -y xorg-x11-server-Xvfb mesa-dri-drivers dbus dbus-x11 \
'*/xvfb-run' gdm-lib accountsservice-libs gnome-control-center \
'*/xvfb-run' gdm-lib accountsservice-libs gnome-control-center gcovr \
--setopt=install_weak_deps=False && \
# GNOME Shell

27
NEWS
View File

@ -1,3 +1,30 @@
3.37.2
======
* Fix move-to-center keybinding with multiple monitors [Sergey; #1073]
* Fix stuck buttons when a virtual device is destroyed [Carlos; !1239]
* Use workarea when centering new windows [Akatsuki; #964]
* Limit mipmap levels when rendering background [Daniel; !1003]
* Broadcast clipboard/primary offers [Carlos; !1253]
* Support primary-selection protocol from wayland-protocols [Carlos; !1255]
* Fix monitor screen cast on X11 [Jonas Å.; !1251]
* Support a "blank" cursor type [Florian; !1244]
* Improve stage view damage tracking [Jonas Å.; !1237]
* Implement touch-mode detecation for the X11 backend [Carlos; !1278]
* Drop external keyboard detection from touch-mode heuristics [Carlos; !1277]
* Optimize actor allocations [Jonas D.; !1247]
* Fixed crashes [Daniel, Carlos, Jonas Å., Jonas D.; !1256, !1258, !1217, !1280]
* Misc. bug fixes and cleanups [Christian, Jonas D., Olivier, Ting-Wei,
Jonas Å., Marco, Corentin, Daniel, Robert, Niels, Florian, Simon; !1231,
!1228, !1238, !1229, !1192, !1236, !1171, !1134, #1126, !1234, !1230, !1210,
!1242, !1243, !1252, !1113, !1232, !1259, !1245, !1265, !1180, !1261, !788,
!1264, !1235, !1218, !1150, !1274, !1271, !1279, !1283, !1272]
Contributors:
Marco Trevisan (Treviño), Akatsuki, Jonas Dreßler, Olivier Fourdan,
Carlos Garnacho, Niels De Graef, Ting-Wei Lan, Robert Mader, Simon McVittie,
Florian Müllner, Corentin Noël, Christian Rauch, Daniel van Vugt,
Sergey Zigachev, Jonas Ådahl
3.37.1
======
* Fix screencasting non-maximized windows [Jonas Å.; !1174]

View File

@ -33,28 +33,11 @@
G_BEGIN_DECLS
#define CLUTTER_TYPE_ACTION (clutter_action_get_type ())
#define CLUTTER_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ACTION, ClutterAction))
#define CLUTTER_IS_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ACTION))
#define CLUTTER_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_ACTION, ClutterActionClass))
#define CLUTTER_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_ACTION))
#define CLUTTER_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_ACTION, ClutterActionClass))
#define CLUTTER_TYPE_ACTION (clutter_action_get_type ())
typedef struct _ClutterActionClass ClutterActionClass;
/**
* ClutterAction:
*
* The #ClutterAction structure contains only private data and
* should be accessed using the provided API.
*
* Since: 1.4
*/
struct _ClutterAction
{
/*< private >*/
ClutterActorMeta parent_instance;
};
CLUTTER_EXPORT
G_DECLARE_DERIVABLE_TYPE (ClutterAction, clutter_action,
CLUTTER, ACTION, ClutterActorMeta);
/**
* ClutterActionClass:
@ -78,9 +61,6 @@ struct _ClutterActionClass
void (* _clutter_action8) (void);
};
CLUTTER_EXPORT
GType clutter_action_get_type (void) G_GNUC_CONST;
/* ClutterActor API */
CLUTTER_EXPORT
void clutter_actor_add_action (ClutterActor *self,

View File

@ -81,38 +81,47 @@ static void
on_actor_destroy (ClutterActor *actor,
ClutterActorMeta *meta)
{
meta->priv->actor = NULL;
ClutterActorMetaPrivate *priv =
clutter_actor_meta_get_instance_private (meta);
priv->actor = NULL;
}
static void
clutter_actor_meta_real_set_actor (ClutterActorMeta *meta,
ClutterActor *actor)
{
g_warn_if_fail (!meta->priv->actor ||
!CLUTTER_ACTOR_IN_PAINT (meta->priv->actor));
ClutterActorMetaPrivate *priv =
clutter_actor_meta_get_instance_private (meta);
g_warn_if_fail (!priv->actor ||
!CLUTTER_ACTOR_IN_PAINT (priv->actor));
g_warn_if_fail (!actor || !CLUTTER_ACTOR_IN_PAINT (actor));
if (meta->priv->actor == actor)
if (priv->actor == actor)
return;
g_clear_signal_handler (&meta->priv->destroy_id, meta->priv->actor);
g_clear_signal_handler (&priv->destroy_id, priv->actor);
meta->priv->actor = actor;
priv->actor = actor;
if (meta->priv->actor != NULL)
meta->priv->destroy_id = g_signal_connect (meta->priv->actor, "destroy",
G_CALLBACK (on_actor_destroy),
meta);
if (priv->actor != NULL)
priv->destroy_id = g_signal_connect (priv->actor, "destroy",
G_CALLBACK (on_actor_destroy),
meta);
}
static void
clutter_actor_meta_real_set_enabled (ClutterActorMeta *meta,
gboolean is_enabled)
{
g_warn_if_fail (!meta->priv->actor ||
!CLUTTER_ACTOR_IN_PAINT (meta->priv->actor));
ClutterActorMetaPrivate *priv =
clutter_actor_meta_get_instance_private (meta);
meta->priv->is_enabled = is_enabled;
g_warn_if_fail (!priv->actor ||
!CLUTTER_ACTOR_IN_PAINT (priv->actor));
priv->is_enabled = is_enabled;
g_object_notify_by_pspec (G_OBJECT (meta), obj_props[PROP_ENABLED]);
}
@ -147,20 +156,21 @@ clutter_actor_meta_get_property (GObject *gobject,
GValue *value,
GParamSpec *pspec)
{
ClutterActorMeta *meta = CLUTTER_ACTOR_META (gobject);
ClutterActorMetaPrivate *priv =
clutter_actor_meta_get_instance_private (CLUTTER_ACTOR_META (gobject));
switch (prop_id)
{
case PROP_ACTOR:
g_value_set_object (value, meta->priv->actor);
g_value_set_object (value, priv->actor);
break;
case PROP_NAME:
g_value_set_string (value, meta->priv->name);
g_value_set_string (value, priv->name);
break;
case PROP_ENABLED:
g_value_set_boolean (value, meta->priv->is_enabled);
g_value_set_boolean (value, priv->is_enabled);
break;
default:
@ -172,7 +182,8 @@ clutter_actor_meta_get_property (GObject *gobject,
static void
clutter_actor_meta_finalize (GObject *gobject)
{
ClutterActorMetaPrivate *priv = CLUTTER_ACTOR_META (gobject)->priv;
ClutterActorMetaPrivate *priv =
clutter_actor_meta_get_instance_private (CLUTTER_ACTOR_META (gobject));
if (priv->actor != NULL)
g_clear_signal_handler (&priv->destroy_id, priv->actor);
@ -243,9 +254,11 @@ clutter_actor_meta_class_init (ClutterActorMetaClass *klass)
void
clutter_actor_meta_init (ClutterActorMeta *self)
{
self->priv = clutter_actor_meta_get_instance_private (self);
self->priv->is_enabled = TRUE;
self->priv->priority = CLUTTER_ACTOR_META_PRIORITY_DEFAULT;
ClutterActorMetaPrivate *priv =
clutter_actor_meta_get_instance_private (self);
priv->is_enabled = TRUE;
priv->priority = CLUTTER_ACTOR_META_PRIORITY_DEFAULT;
}
/**
@ -263,13 +276,17 @@ void
clutter_actor_meta_set_name (ClutterActorMeta *meta,
const gchar *name)
{
ClutterActorMetaPrivate *priv;
g_return_if_fail (CLUTTER_IS_ACTOR_META (meta));
if (g_strcmp0 (meta->priv->name, name) == 0)
priv = clutter_actor_meta_get_instance_private (meta);
if (g_strcmp0 (priv->name, name) == 0)
return;
g_free (meta->priv->name);
meta->priv->name = g_strdup (name);
g_free (priv->name);
priv->name = g_strdup (name);
g_object_notify_by_pspec (G_OBJECT (meta), obj_props[PROP_NAME]);
}
@ -290,9 +307,13 @@ clutter_actor_meta_set_name (ClutterActorMeta *meta,
const gchar *
clutter_actor_meta_get_name (ClutterActorMeta *meta)
{
ClutterActorMetaPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_ACTOR_META (meta), NULL);
return meta->priv->name;
priv = clutter_actor_meta_get_instance_private (meta);
return priv->name;
}
/**
@ -308,11 +329,14 @@ void
clutter_actor_meta_set_enabled (ClutterActorMeta *meta,
gboolean is_enabled)
{
ClutterActorMetaPrivate *priv;
g_return_if_fail (CLUTTER_IS_ACTOR_META (meta));
priv = clutter_actor_meta_get_instance_private (meta);
is_enabled = !!is_enabled;
if (meta->priv->is_enabled == is_enabled)
if (priv->is_enabled == is_enabled)
return;
CLUTTER_ACTOR_META_GET_CLASS (meta)->set_enabled (meta, is_enabled);
@ -331,9 +355,13 @@ clutter_actor_meta_set_enabled (ClutterActorMeta *meta,
gboolean
clutter_actor_meta_get_enabled (ClutterActorMeta *meta)
{
ClutterActorMetaPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_ACTOR_META (meta), FALSE);
return meta->priv->is_enabled;
priv = clutter_actor_meta_get_instance_private (meta);
return priv->is_enabled;
}
/*
@ -369,40 +397,54 @@ _clutter_actor_meta_set_actor (ClutterActorMeta *meta,
ClutterActor *
clutter_actor_meta_get_actor (ClutterActorMeta *meta)
{
ClutterActorMetaPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_ACTOR_META (meta), NULL);
return meta->priv->actor;
priv = clutter_actor_meta_get_instance_private (meta);
return priv->actor;
}
void
_clutter_actor_meta_set_priority (ClutterActorMeta *meta,
gint priority)
{
ClutterActorMetaPrivate *priv;
g_return_if_fail (CLUTTER_IS_ACTOR_META (meta));
priv = clutter_actor_meta_get_instance_private (meta);
/* This property shouldn't be modified after the actor meta is in
use because ClutterMetaGroup doesn't resort the list when it
changes. If we made the priority public then we could either make
the priority a construct-only property or listen for
notifications on the property from the ClutterMetaGroup and
resort. */
g_return_if_fail (meta->priv->actor == NULL);
g_return_if_fail (priv->actor == NULL);
meta->priv->priority = priority;
priv->priority = priority;
}
gint
_clutter_actor_meta_get_priority (ClutterActorMeta *meta)
{
ClutterActorMetaPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_ACTOR_META (meta), 0);
return meta->priv->priority;
priv = clutter_actor_meta_get_instance_private (meta);
return priv->priority;
}
gboolean
_clutter_actor_meta_is_internal (ClutterActorMeta *meta)
{
gint priority = meta->priv->priority;
ClutterActorMetaPrivate *priv =
clutter_actor_meta_get_instance_private (meta);
gint priority = priv->priority;
return (priority <= CLUTTER_ACTOR_META_PRIORITY_INTERNAL_LOW ||
priority >= CLUTTER_ACTOR_META_PRIORITY_INTERNAL_HIGH);
@ -449,19 +491,21 @@ void
_clutter_meta_group_add_meta (ClutterMetaGroup *group,
ClutterActorMeta *meta)
{
ClutterActorMetaPrivate *priv =
clutter_actor_meta_get_instance_private (meta);
GList *prev = NULL, *l;
if (meta->priv->actor != NULL)
if (priv->actor != NULL)
{
g_warning ("The meta of type '%s' with name '%s' is "
"already attached to actor '%s'",
G_OBJECT_TYPE_NAME (meta),
meta->priv->name != NULL
? meta->priv->name
priv->name != NULL
? priv->name
: "<unknown>",
clutter_actor_get_name (meta->priv->actor) != NULL
? clutter_actor_get_name (meta->priv->actor)
: G_OBJECT_TYPE_NAME (meta->priv->actor));
clutter_actor_get_name (priv->actor) != NULL
? clutter_actor_get_name (priv->actor)
: G_OBJECT_TYPE_NAME (priv->actor));
return;
}
@ -497,13 +541,16 @@ void
_clutter_meta_group_remove_meta (ClutterMetaGroup *group,
ClutterActorMeta *meta)
{
if (meta->priv->actor != group->actor)
ClutterActorMetaPrivate *priv =
clutter_actor_meta_get_instance_private (meta);
if (priv->actor != group->actor)
{
g_warning ("The meta of type '%s' with name '%s' is not "
"attached to the actor '%s'",
G_OBJECT_TYPE_NAME (meta),
meta->priv->name != NULL
? meta->priv->name
priv->name != NULL
? priv->name
: "<unknown>",
clutter_actor_get_name (group->actor) != NULL
? clutter_actor_get_name (group->actor)
@ -646,8 +693,10 @@ _clutter_meta_group_get_meta (ClutterMetaGroup *group,
for (l = group->meta; l != NULL; l = l->next)
{
ClutterActorMeta *meta = l->data;
ClutterActorMetaPrivate *priv =
clutter_actor_meta_get_instance_private (meta);
if (g_strcmp0 (meta->priv->name, name) == 0)
if (g_strcmp0 (priv->name, name) == 0)
return meta;
}
@ -667,6 +716,8 @@ _clutter_meta_group_get_meta (ClutterMetaGroup *group,
const gchar *
_clutter_actor_meta_get_debug_name (ClutterActorMeta *meta)
{
return meta->priv->name != NULL ? meta->priv->name
: G_OBJECT_TYPE_NAME (meta);
ClutterActorMetaPrivate *priv =
clutter_actor_meta_get_instance_private (meta);
return priv->name != NULL ? priv->name : G_OBJECT_TYPE_NAME (meta);
}

View File

@ -33,31 +33,13 @@
G_BEGIN_DECLS
#define CLUTTER_TYPE_ACTOR_META (clutter_actor_meta_get_type ())
#define CLUTTER_ACTOR_META(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ACTOR_META, ClutterActorMeta))
#define CLUTTER_IS_ACTOR_META(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ACTOR_META))
#define CLUTTER_ACTOR_META_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_ACTOR_META, ClutterActorMetaClass))
#define CLUTTER_IS_ACTOR_META_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_ACTOR_META))
#define CLUTTER_ACTOR_META_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_ACTOR_META, ClutterActorMetaClass))
#define CLUTTER_TYPE_ACTOR_META (clutter_actor_meta_get_type ())
typedef struct _ClutterActorMetaPrivate ClutterActorMetaPrivate;
typedef struct _ClutterActorMetaClass ClutterActorMetaClass;
CLUTTER_EXPORT
G_DECLARE_DERIVABLE_TYPE (ClutterActorMeta, clutter_actor_meta,
CLUTTER, ACTOR_META, GInitiallyUnowned);
/**
* ClutterActorMeta:
*
* The #ClutterActorMeta structure contains only
* private data and should be accessed using the provided API
*
* Since: 1.4
*/
struct _ClutterActorMeta
{
/*< private >*/
GInitiallyUnowned parent_instance;
ClutterActorMetaPrivate *priv;
};
typedef struct _ClutterActorMetaPrivate ClutterActorMetaPrivate;
/**
* ClutterActorMetaClass:
@ -99,9 +81,6 @@ struct _ClutterActorMetaClass
void (* _clutter_meta6) (void);
};
CLUTTER_EXPORT
GType clutter_actor_meta_get_type (void) G_GNUC_CONST;
CLUTTER_EXPORT
void clutter_actor_meta_set_name (ClutterActorMeta *meta,
const gchar *name);

View File

@ -313,7 +313,7 @@ void _clutter_actor_detach_clone
void _clutter_actor_queue_redraw_on_clones (ClutterActor *actor);
void _clutter_actor_queue_relayout_on_clones (ClutterActor *actor);
void _clutter_actor_queue_only_relayout (ClutterActor *actor);
void _clutter_actor_queue_update_resource_scale_recursive (ClutterActor *actor);
void clutter_actor_clear_stage_views_recursive (ClutterActor *actor);
gboolean _clutter_actor_get_real_resource_scale (ClutterActor *actor,
float *resource_scale);
@ -321,6 +321,8 @@ gboolean _clutter_actor_get_real_resource_scale
ClutterPaintNode * clutter_actor_create_texture_paint_node (ClutterActor *self,
CoglTexture *texture);
void clutter_actor_update_stage_views (ClutterActor *self);
G_END_DECLS
#endif /* __CLUTTER_ACTOR_PRIVATE_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -175,9 +175,12 @@ struct _ClutterActor
* @get_preferred_height: virtual function, used when querying the minimum
* and natural heights of an actor for a given width; it is used by
* clutter_actor_get_preferred_height()
* @allocate: virtual function, used when settings the coordinates of an
* actor; it is used by clutter_actor_allocate(); it must chain up to
* the parent's implementation, or call clutter_actor_set_allocation()
* @allocate: virtual function, used when setting the coordinates of an
* actor; it is used by clutter_actor_allocate(); when overriding this
* function without chaining up, clutter_actor_set_allocation() must be
* called and children must be allocated by the implementation, when
* chaining up though, those things will be done by the parent's
* implementation.
* @apply_transform: virtual function, used when applying the transformations
* to an actor before painting it or when transforming coordinates or
* the allocation; it must chain up to the parent's implementation
@ -253,8 +256,7 @@ struct _ClutterActorClass
gfloat *min_height_p,
gfloat *natural_height_p);
void (* allocate) (ClutterActor *self,
const ClutterActorBox *box,
ClutterAllocationFlags flags);
const ClutterActorBox *box);
/* transformations */
void (* apply_transform) (ClutterActor *actor,
@ -415,38 +417,29 @@ void clutter_actor_get_preferred_size
gfloat *natural_height_p);
CLUTTER_EXPORT
void clutter_actor_allocate (ClutterActor *self,
const ClutterActorBox *box,
ClutterAllocationFlags flags);
const ClutterActorBox *box);
CLUTTER_EXPORT
void clutter_actor_allocate_preferred_size (ClutterActor *self,
ClutterAllocationFlags flags);
void clutter_actor_allocate_preferred_size (ClutterActor *self);
CLUTTER_EXPORT
void clutter_actor_allocate_available_size (ClutterActor *self,
gfloat x,
gfloat y,
gfloat available_width,
gfloat available_height,
ClutterAllocationFlags flags);
gfloat available_height);
CLUTTER_EXPORT
void clutter_actor_allocate_align_fill (ClutterActor *self,
const ClutterActorBox *box,
gdouble x_align,
gdouble y_align,
gboolean x_fill,
gboolean y_fill,
ClutterAllocationFlags flags);
gboolean y_fill);
CLUTTER_EXPORT
void clutter_actor_set_allocation (ClutterActor *self,
const ClutterActorBox *box,
ClutterAllocationFlags flags);
const ClutterActorBox *box);
CLUTTER_EXPORT
void clutter_actor_get_allocation_box (ClutterActor *self,
ClutterActorBox *box);
CLUTTER_EXPORT
void clutter_actor_get_allocation_vertices (ClutterActor *self,
ClutterActor *ancestor,
graphene_point3d_t *verts);
CLUTTER_EXPORT
gboolean clutter_actor_has_allocation (ClutterActor *self);
CLUTTER_EXPORT
void clutter_actor_set_size (ClutterActor *self,
@ -926,6 +919,9 @@ void clutter_actor_pick_box (ClutterActor *self,
ClutterPickContext *pick_context,
const ClutterActorBox *box);
CLUTTER_EXPORT
GList * clutter_actor_peek_stage_views (ClutterActor *self);
G_END_DECLS
#endif /* __CLUTTER_ACTOR_H__ */

View File

@ -84,13 +84,11 @@ G_DEFINE_TYPE (ClutterAlignConstraint,
CLUTTER_TYPE_CONSTRAINT);
static void
source_position_changed (ClutterActor *actor,
const ClutterActorBox *allocation,
ClutterAllocationFlags flags,
ClutterAlignConstraint *align)
source_queue_relayout (ClutterActor *actor,
ClutterAlignConstraint *align)
{
if (align->actor != NULL)
clutter_actor_queue_relayout (align->actor);
_clutter_actor_queue_only_relayout (align->actor);
}
static void
@ -187,7 +185,7 @@ clutter_align_constraint_dispose (GObject *gobject)
G_CALLBACK (source_destroyed),
align);
g_signal_handlers_disconnect_by_func (align->source,
G_CALLBACK (source_position_changed),
G_CALLBACK (source_queue_relayout),
align);
align->source = NULL;
}
@ -403,15 +401,15 @@ clutter_align_constraint_set_source (ClutterAlignConstraint *align,
G_CALLBACK (source_destroyed),
align);
g_signal_handlers_disconnect_by_func (old_source,
G_CALLBACK (source_position_changed),
G_CALLBACK (source_queue_relayout),
align);
}
align->source = source;
if (align->source != NULL)
{
g_signal_connect (align->source, "allocation-changed",
G_CALLBACK (source_position_changed),
g_signal_connect (align->source, "queue-relayout",
G_CALLBACK (source_queue_relayout),
align);
g_signal_connect (align->source, "destroy",
G_CALLBACK (source_destroyed),

View File

@ -27,35 +27,23 @@
* @short_description: Interface for animatable classes
*
* #ClutterAnimatable is an interface that allows a #GObject class
* to control how a #ClutterAnimation will animate a property.
* to control how an actor will animate a property.
*
* Each #ClutterAnimatable should implement the
* #ClutterAnimatableInterface.interpolate_property() virtual function of the
* interface to compute the animation state between two values of an interval
* depending on a progress factor, expressed as a floating point value.
*
* If a #ClutterAnimatable is animated by a #ClutterAnimation
* instance, the #ClutterAnimation will call
* clutter_animatable_interpolate_property() passing the name of the
* currently animated property; the values interval; and the progress factor.
* The #ClutterAnimatable implementation should return the computed value for
* the animated
* property.
*
* #ClutterAnimatable is available since Clutter 1.0
*/
#include "clutter-build-config.h"
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include "clutter-animatable.h"
#include "clutter-interval.h"
#include "clutter-debug.h"
#include "clutter-private.h"
#include "deprecated/clutter-animation.h"
G_DEFINE_INTERFACE (ClutterAnimatable, clutter_animatable, G_TYPE_OBJECT);
static void

View File

@ -42,8 +42,6 @@ G_DECLARE_INTERFACE (ClutterAnimatable, clutter_animatable,
/**
* ClutterAnimatableInterface:
* @animate_property: virtual function for custom interpolation of a
* property. This virtual function is deprecated
* @find_property: virtual function for retrieving the #GParamSpec of
* an animatable property
* @get_initial_state: virtual function for retrieving the initial
@ -53,9 +51,6 @@ G_DECLARE_INTERFACE (ClutterAnimatable, clutter_animatable,
* @interpolate_value: virtual function for interpolating the progress
* of a property
*
* Base interface for #GObject<!-- -->s that can be animated by a
* a #ClutterAnimation.
*
* Since: 1.0
*/
struct _ClutterAnimatableInterface
@ -64,13 +59,6 @@ struct _ClutterAnimatableInterface
GTypeInterface parent_iface;
/*< public >*/
gboolean (* animate_property) (ClutterAnimatable *animatable,
ClutterAnimation *animation,
const gchar *property_name,
const GValue *initial_value,
const GValue *final_value,
gdouble progress,
GValue *value);
GParamSpec *(* find_property) (ClutterAnimatable *animatable,
const gchar *property_name);
void (* get_initial_state) (ClutterAnimatable *animatable,

View File

@ -30,9 +30,7 @@
#ifndef __GI_SCANNER__
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterAction, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterActor, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterActorMeta, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterAlignConstraint, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBackend, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBindConstraint, g_object_unref)
@ -43,7 +41,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBoxLayout, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBrightnessContrastEffect, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterCanvas, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterChildMeta, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterClickAction, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterClone, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterColorizeEffect, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterConstraint, g_object_unref)
@ -53,7 +50,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDesaturateEffect, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterEffect, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterFixedLayout, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterFlowLayout, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterGestureAction, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterGridLayout, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterImage, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterInputDevice, g_object_unref)

View File

@ -406,8 +406,7 @@ get_actor_align_factor (ClutterActorAlign alignment)
static void
clutter_bin_layout_allocate (ClutterLayoutManager *manager,
ClutterContainer *container,
const ClutterActorBox *allocation,
ClutterAllocationFlags flags)
const ClutterActorBox *allocation)
{
gfloat allocation_x, allocation_y;
gfloat available_w, available_h;
@ -515,8 +514,7 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager,
clutter_actor_allocate_align_fill (child, &child_alloc,
x_align, y_align,
x_fill, y_fill,
flags);
x_fill, y_fill);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -105,64 +105,6 @@ void clutter_box_layout_set_pack_start (ClutterBoxLayou
CLUTTER_EXPORT
gboolean clutter_box_layout_get_pack_start (ClutterBoxLayout *layout);
CLUTTER_DEPRECATED_FOR(clutter_box_layout_set_orientation)
void clutter_box_layout_set_vertical (ClutterBoxLayout *layout,
gboolean vertical);
CLUTTER_DEPRECATED_FOR(clutter_box_layout_get_orientation)
gboolean clutter_box_layout_get_vertical (ClutterBoxLayout *layout);
CLUTTER_EXPORT
void clutter_box_layout_pack (ClutterBoxLayout *layout,
ClutterActor *actor,
gboolean expand,
gboolean x_fill,
gboolean y_fill,
ClutterBoxAlignment x_align,
ClutterBoxAlignment y_align);
CLUTTER_DEPRECATED
void clutter_box_layout_set_alignment (ClutterBoxLayout *layout,
ClutterActor *actor,
ClutterBoxAlignment x_align,
ClutterBoxAlignment y_align);
CLUTTER_DEPRECATED
void clutter_box_layout_get_alignment (ClutterBoxLayout *layout,
ClutterActor *actor,
ClutterBoxAlignment *x_align,
ClutterBoxAlignment *y_align);
CLUTTER_DEPRECATED
void clutter_box_layout_set_fill (ClutterBoxLayout *layout,
ClutterActor *actor,
gboolean x_fill,
gboolean y_fill);
CLUTTER_DEPRECATED
void clutter_box_layout_get_fill (ClutterBoxLayout *layout,
ClutterActor *actor,
gboolean *x_fill,
gboolean *y_fill);
CLUTTER_DEPRECATED
void clutter_box_layout_set_expand (ClutterBoxLayout *layout,
ClutterActor *actor,
gboolean expand);
CLUTTER_DEPRECATED
gboolean clutter_box_layout_get_expand (ClutterBoxLayout *layout,
ClutterActor *actor);
CLUTTER_DEPRECATED
void clutter_box_layout_set_use_animations (ClutterBoxLayout *layout,
gboolean animate);
CLUTTER_DEPRECATED
gboolean clutter_box_layout_get_use_animations (ClutterBoxLayout *layout);
CLUTTER_DEPRECATED
void clutter_box_layout_set_easing_mode (ClutterBoxLayout *layout,
gulong mode);
CLUTTER_DEPRECATED
gulong clutter_box_layout_get_easing_mode (ClutterBoxLayout *layout);
CLUTTER_DEPRECATED
void clutter_box_layout_set_easing_duration (ClutterBoxLayout *layout,
guint msecs);
CLUTTER_DEPRECATED
guint clutter_box_layout_get_easing_duration (ClutterBoxLayout *layout);
G_END_DECLS
#endif /* __CLUTTER_BOX_LAYOUT_H__ */

View File

@ -159,7 +159,8 @@ static inline void
click_action_set_pressed (ClutterClickAction *action,
gboolean is_pressed)
{
ClutterClickActionPrivate *priv = action->priv;
ClutterClickActionPrivate *priv =
clutter_click_action_get_instance_private (action);
is_pressed = !!is_pressed;
@ -174,7 +175,8 @@ static inline void
click_action_set_held (ClutterClickAction *action,
gboolean is_held)
{
ClutterClickActionPrivate *priv = action->priv;
ClutterClickActionPrivate *priv =
clutter_click_action_get_instance_private (action);
is_held = !!is_held;
@ -189,7 +191,8 @@ static gboolean
click_action_emit_long_press (gpointer data)
{
ClutterClickAction *action = data;
ClutterClickActionPrivate *priv = action->priv;
ClutterClickActionPrivate *priv =
clutter_click_action_get_instance_private (action);
ClutterActor *actor;
gboolean result;
@ -213,7 +216,8 @@ click_action_emit_long_press (gpointer data)
static inline void
click_action_query_long_press (ClutterClickAction *action)
{
ClutterClickActionPrivate *priv = action->priv;
ClutterClickActionPrivate *priv =
clutter_click_action_get_instance_private (action);
ClutterActor *actor;
gboolean result = FALSE;
gint timeout;
@ -249,7 +253,8 @@ click_action_query_long_press (ClutterClickAction *action)
static inline void
click_action_cancel_long_press (ClutterClickAction *action)
{
ClutterClickActionPrivate *priv = action->priv;
ClutterClickActionPrivate *priv =
clutter_click_action_get_instance_private (action);
if (priv->long_press_id != 0)
{
@ -272,7 +277,8 @@ on_event (ClutterActor *actor,
ClutterEvent *event,
ClutterClickAction *action)
{
ClutterClickActionPrivate *priv = action->priv;
ClutterClickActionPrivate *priv =
clutter_click_action_get_instance_private (action);
gboolean has_button = TRUE;
if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (action)))
@ -342,7 +348,8 @@ on_captured_event (ClutterActor *stage,
ClutterEvent *event,
ClutterClickAction *action)
{
ClutterClickActionPrivate *priv = action->priv;
ClutterClickActionPrivate *priv =
clutter_click_action_get_instance_private (action);
ClutterActor *actor;
ClutterModifierType modifier_state;
gboolean has_button = TRUE;
@ -434,7 +441,8 @@ clutter_click_action_set_actor (ClutterActorMeta *meta,
ClutterActor *actor)
{
ClutterClickAction *action = CLUTTER_CLICK_ACTION (meta);
ClutterClickActionPrivate *priv = action->priv;
ClutterClickActionPrivate *priv =
clutter_click_action_get_instance_private (action);
if (priv->event_id != 0)
{
@ -488,7 +496,8 @@ clutter_click_action_set_property (GObject *gobject,
const GValue *value,
GParamSpec *pspec)
{
ClutterClickActionPrivate *priv = CLUTTER_CLICK_ACTION (gobject)->priv;
ClutterClickActionPrivate *priv =
clutter_click_action_get_instance_private (CLUTTER_CLICK_ACTION (gobject));
switch (prop_id)
{
@ -512,7 +521,8 @@ clutter_click_action_get_property (GObject *gobject,
GValue *value,
GParamSpec *pspec)
{
ClutterClickActionPrivate *priv = CLUTTER_CLICK_ACTION (gobject)->priv;
ClutterClickActionPrivate *priv =
clutter_click_action_get_instance_private (CLUTTER_CLICK_ACTION (gobject));
switch (prop_id)
{
@ -541,7 +551,8 @@ clutter_click_action_get_property (GObject *gobject,
static void
clutter_click_action_dispose (GObject *gobject)
{
ClutterClickActionPrivate *priv = CLUTTER_CLICK_ACTION (gobject)->priv;
ClutterClickActionPrivate *priv =
clutter_click_action_get_instance_private (CLUTTER_CLICK_ACTION (gobject));
g_clear_signal_handler (&priv->event_id,
clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (gobject)));
@ -699,9 +710,11 @@ clutter_click_action_class_init (ClutterClickActionClass *klass)
static void
clutter_click_action_init (ClutterClickAction *self)
{
self->priv = clutter_click_action_get_instance_private (self);
self->priv->long_press_threshold = -1;
self->priv->long_press_duration = -1;
ClutterClickActionPrivate *priv =
clutter_click_action_get_instance_private (self);
priv->long_press_threshold = -1;
priv->long_press_duration = -1;
}
/**
@ -741,7 +754,7 @@ clutter_click_action_release (ClutterClickAction *action)
g_return_if_fail (CLUTTER_IS_CLICK_ACTION (action));
priv = action->priv;
priv = clutter_click_action_get_instance_private (action);
if (!priv->is_held)
return;
@ -767,9 +780,13 @@ clutter_click_action_release (ClutterClickAction *action)
guint
clutter_click_action_get_button (ClutterClickAction *action)
{
ClutterClickActionPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_CLICK_ACTION (action), 0);
return action->priv->press_button;
priv = clutter_click_action_get_instance_private (action);
return priv->press_button;
}
/**
@ -785,9 +802,13 @@ clutter_click_action_get_button (ClutterClickAction *action)
ClutterModifierType
clutter_click_action_get_state (ClutterClickAction *action)
{
ClutterClickActionPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_CLICK_ACTION (action), 0);
return action->priv->modifier_state;
priv = clutter_click_action_get_instance_private (action);
return priv->modifier_state;
}
/**
@ -805,11 +826,15 @@ clutter_click_action_get_coords (ClutterClickAction *action,
gfloat *press_x,
gfloat *press_y)
{
ClutterClickActionPrivate *priv;
g_return_if_fail (CLUTTER_IS_ACTION (action));
priv = clutter_click_action_get_instance_private (action);
if (press_x != NULL)
*press_x = action->priv->press_x;
*press_x = priv->press_x;
if (press_y != NULL)
*press_y = action->priv->press_y;
*press_y = priv->press_y;
}

View File

@ -37,32 +37,13 @@
G_BEGIN_DECLS
#define CLUTTER_TYPE_CLICK_ACTION (clutter_click_action_get_type ())
#define CLUTTER_CLICK_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_CLICK_ACTION, ClutterClickAction))
#define CLUTTER_IS_CLICK_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_CLICK_ACTION))
#define CLUTTER_CLICK_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_CLICK_ACTION, ClutterClickActionClass))
#define CLUTTER_IS_CLICK_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_CLICK_ACTION))
#define CLUTTER_CLICK_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_CLICK_ACTION, ClutterClickActionClass))
#define CLUTTER_TYPE_CLICK_ACTION (clutter_click_action_get_type ())
typedef struct _ClutterClickAction ClutterClickAction;
typedef struct _ClutterClickActionPrivate ClutterClickActionPrivate;
typedef struct _ClutterClickActionClass ClutterClickActionClass;
CLUTTER_EXPORT
G_DECLARE_DERIVABLE_TYPE (ClutterClickAction, clutter_click_action,
CLUTTER, CLICK_ACTION, ClutterAction);
/**
* ClutterClickAction:
*
* The #ClutterClickAction structure contains
* only private data and should be accessed using the provided API
*
* Since: 1.4
*/
struct _ClutterClickAction
{
/*< private >*/
ClutterAction parent_instance;
ClutterClickActionPrivate *priv;
};
typedef struct _ClutterClickActionPrivate ClutterClickActionPrivate;
/**
* ClutterClickActionClass:
@ -97,9 +78,6 @@ struct _ClutterClickActionClass
void (* _clutter_click_action7) (void);
};
CLUTTER_EXPORT
GType clutter_click_action_get_type (void) G_GNUC_CONST;
CLUTTER_EXPORT
ClutterAction * clutter_click_action_new (void);

View File

@ -240,15 +240,14 @@ clutter_clone_has_overlaps (ClutterActor *actor)
static void
clutter_clone_allocate (ClutterActor *self,
const ClutterActorBox *box,
ClutterAllocationFlags flags)
const ClutterActorBox *box)
{
ClutterClonePrivate *priv = CLUTTER_CLONE (self)->priv;
ClutterActorClass *parent_class;
/* chain up */
parent_class = CLUTTER_ACTOR_CLASS (clutter_clone_parent_class);
parent_class->allocate (self, box, flags);
parent_class->allocate (self, box);
if (priv->clone_source == NULL)
return;
@ -258,7 +257,7 @@ clutter_clone_allocate (ClutterActor *self,
*/
if (clutter_actor_get_parent (priv->clone_source) != NULL &&
!clutter_actor_has_allocation (priv->clone_source))
clutter_actor_allocate_preferred_size (priv->clone_source, flags);
clutter_actor_allocate_preferred_size (priv->clone_source);
#if 0
/* XXX - this is wrong: ClutterClone cannot clone unparented
@ -273,7 +272,7 @@ clutter_clone_allocate (ClutterActor *self,
* paint cycle, we can safely give it as much size as it requires
*/
if (clutter_actor_get_parent (priv->clone_source) == NULL)
clutter_actor_allocate_preferred_size (priv->clone_source, flags);
clutter_actor_allocate_preferred_size (priv->clone_source);
#endif
}

View File

@ -0,0 +1,92 @@
/*
* Copyright (C) 2007,2008,2009,2010,2011 Intel Corporation.
* Copyright (C) 2020 Red Hat Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "clutter-build-config.h"
#include "clutter-damage-history.h"
#define DAMAGE_HISTORY_LENGTH 0x10
struct _ClutterDamageHistory
{
cairo_region_t *damages[DAMAGE_HISTORY_LENGTH];
int index;
};
ClutterDamageHistory *
clutter_damage_history_new (void)
{
ClutterDamageHistory *history;
history = g_new0 (ClutterDamageHistory, 1);
return history;
}
void
clutter_damage_history_free (ClutterDamageHistory *history)
{
int i;
for (i = 0; i < G_N_ELEMENTS (history->damages); i++)
g_clear_pointer (&history->damages[i], cairo_region_destroy);
g_free (history);
}
gboolean
clutter_damage_history_is_age_valid (ClutterDamageHistory *history,
int age)
{
if (age >= DAMAGE_HISTORY_LENGTH ||
age < 1)
return FALSE;
if (!clutter_damage_history_lookup (history, age))
return FALSE;
return TRUE;
}
void
clutter_damage_history_record (ClutterDamageHistory *history,
const cairo_region_t *damage)
{
g_clear_pointer (&history->damages[history->index], cairo_region_destroy);
history->damages[history->index] = cairo_region_copy (damage);
}
static inline int
step_damage_index (int current,
int diff)
{
return (current + diff) & (DAMAGE_HISTORY_LENGTH - 1);
}
void
clutter_damage_history_step (ClutterDamageHistory *history)
{
history->index = step_damage_index (history->index, 1);
}
const cairo_region_t *
clutter_damage_history_lookup (ClutterDamageHistory *history,
int age)
{
return history->damages[step_damage_index (history->index, -age)];
}

View File

@ -0,0 +1,42 @@
/*
* Copyright (C) 2007,2008,2009,2010,2011 Intel Corporation.
* Copyright (C) 2020 Red Hat Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CLUTTER_DAMAGE_HISTORY_H
#define CLUTTER_DAMAGE_HISTORY_H
#include <cairo.h>
#include <glib.h>
typedef struct _ClutterDamageHistory ClutterDamageHistory;
ClutterDamageHistory * clutter_damage_history_new (void);
void clutter_damage_history_free (ClutterDamageHistory *history);
gboolean clutter_damage_history_is_age_valid (ClutterDamageHistory *history,
int age);
void clutter_damage_history_record (ClutterDamageHistory *history,
const cairo_region_t *damage);
void clutter_damage_history_step (ClutterDamageHistory *history);
const cairo_region_t * clutter_damage_history_lookup (ClutterDamageHistory *history,
int age);
#endif /* CLUTTER_DAMAGE_HISTORY_H */

View File

@ -128,10 +128,9 @@ clutter_deform_effect_deform_vertex (ClutterDeformEffect *effect,
}
static void
vbo_invalidate (ClutterActor *actor,
const ClutterActorBox *allocation,
ClutterAllocationFlags flags,
ClutterDeformEffect *effect)
vbo_invalidate (ClutterActor *actor,
GParamSpec *pspec,
ClutterDeformEffect *effect)
{
effect->priv->is_dirty = TRUE;
}
@ -156,7 +155,7 @@ clutter_deform_effect_set_actor (ClutterActorMeta *meta,
* changes
*/
if (actor != NULL)
priv->allocation_id = g_signal_connect (actor, "allocation-changed",
priv->allocation_id = g_signal_connect (actor, "notify::allocation",
G_CALLBACK (vbo_invalidate),
meta);

View File

@ -4,14 +4,11 @@
#define __CLUTTER_DEPRECATED_H_INSIDE__
#include "deprecated/clutter-actor.h"
#include "deprecated/clutter-alpha.h"
#include "deprecated/clutter-animation.h"
#include "deprecated/clutter-box.h"
#include "deprecated/clutter-container.h"
#include "deprecated/clutter-group.h"
#include "deprecated/clutter-rectangle.h"
#include "deprecated/clutter-stage.h"
#include "deprecated/clutter-state.h"
#include "deprecated/clutter-timeline.h"
#undef __CLUTTER_DEPRECATED_H_INSIDE__

View File

@ -190,7 +190,7 @@ typedef enum /*< prefix=CLUTTER_REQUEST >*/
* @CLUTTER_ANIMATION_LAST: last animation mode, used as a guard for
* registered global alpha functions
*
* The animation modes used by #ClutterAlpha and #ClutterAnimation. This
* The animation modes used by #ClutterAnimatable. This
* enumeration can be expanded in later versions of Clutter.
*
* <figure id="easing-modes">
@ -554,32 +554,6 @@ typedef enum /*< prefix=CLUTTER_OFFSCREEN_REDIRECT >*/
CLUTTER_OFFSCREEN_REDIRECT_ON_IDLE = 1 << 2
} ClutterOffscreenRedirect;
/**
* ClutterAllocationFlags:
* @CLUTTER_ALLOCATION_NONE: No flag set
* @CLUTTER_ABSOLUTE_ORIGIN_CHANGED: Whether the absolute origin of the
* actor has changed; this implies that any ancestor of the actor has
* been moved.
* @CLUTTER_DELEGATE_LAYOUT: Whether the allocation should be delegated
* to the #ClutterLayoutManager instance stored inside the
* #ClutterActor:layout-manager property of #ClutterActor. This flag
* should only be used if you are subclassing #ClutterActor and
* overriding the #ClutterActorClass.allocate() virtual function, but
* you wish to use the default implementation of the virtual function
* inside #ClutterActor. Added in Clutter 1.10.
*
* Flags passed to the #ClutterActorClass.allocate() virtual function
* and to the clutter_actor_allocate() function.
*
* Since: 1.0
*/
typedef enum
{
CLUTTER_ALLOCATION_NONE = 0,
CLUTTER_ABSOLUTE_ORIGIN_CHANGED = 1 << 1,
CLUTTER_DELEGATE_LAYOUT = 1 << 2
} ClutterAllocationFlags;
/**
* ClutterAlignAxis:
* @CLUTTER_ALIGN_X_AXIS: Maintain the alignment on the X axis
@ -1343,8 +1317,6 @@ typedef enum
* painting the stages
* @CLUTTER_REPAINT_FLAGS_POST_PAINT: Run the repaint function after
* painting the stages
* @CLUTTER_REPAINT_FLAGS_QUEUE_REDRAW_ON_ADD: Ensure that a new frame
* is queued after adding the repaint function
*
* Flags to pass to clutter_threads_add_repaint_func_full().
*
@ -1354,7 +1326,6 @@ typedef enum
{
CLUTTER_REPAINT_FLAGS_PRE_PAINT = 1 << 0,
CLUTTER_REPAINT_FLAGS_POST_PAINT = 1 << 1,
CLUTTER_REPAINT_FLAGS_QUEUE_REDRAW_ON_ADD = 1 << 2
} ClutterRepaintFlags;
/**

View File

@ -131,8 +131,7 @@ clutter_fixed_layout_get_preferred_height (ClutterLayoutManager *manager,
static void
clutter_fixed_layout_allocate (ClutterLayoutManager *manager,
ClutterContainer *container,
const ClutterActorBox *allocation,
ClutterAllocationFlags flags)
const ClutterActorBox *allocation)
{
ClutterActor *child;
@ -140,7 +139,7 @@ clutter_fixed_layout_allocate (ClutterLayoutManager *manager,
child != NULL;
child = clutter_actor_get_next_sibling (child))
{
clutter_actor_allocate_preferred_size (child, flags);
clutter_actor_allocate_preferred_size (child);
}
}

View File

@ -566,8 +566,7 @@ clutter_flow_layout_get_preferred_height (ClutterLayoutManager *manager,
static void
clutter_flow_layout_allocate (ClutterLayoutManager *manager,
ClutterContainer *container,
const ClutterActorBox *allocation,
ClutterAllocationFlags flags)
const ClutterActorBox *allocation)
{
ClutterFlowLayoutPrivate *priv = CLUTTER_FLOW_LAYOUT (manager)->priv;
ClutterActor *actor, *child;
@ -729,7 +728,7 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager,
child_alloc.y1 = ceil (item_y);
child_alloc.x2 = ceil (child_alloc.x1 + item_width);
child_alloc.y2 = ceil (child_alloc.y1 + item_height);
clutter_actor_allocate (child, &child_alloc, flags);
clutter_actor_allocate (child, &child_alloc);
if (priv->orientation == CLUTTER_FLOW_HORIZONTAL)
item_x = new_x;

View File

@ -157,7 +157,8 @@ G_DEFINE_TYPE_WITH_PRIVATE (ClutterGestureAction, clutter_gesture_action, CLUTTE
static GesturePoint *
gesture_register_point (ClutterGestureAction *action, ClutterEvent *event)
{
ClutterGestureActionPrivate *priv = action->priv;
ClutterGestureActionPrivate *priv =
clutter_gesture_action_get_instance_private (action);
GesturePoint *point = NULL;
if (priv->points->len >= MAX_GESTURE_POINTS)
@ -190,7 +191,8 @@ gesture_find_point (ClutterGestureAction *action,
ClutterEvent *event,
gint *position)
{
ClutterGestureActionPrivate *priv = action->priv;
ClutterGestureActionPrivate *priv =
clutter_gesture_action_get_instance_private (action);
GesturePoint *point = NULL;
ClutterEventType type = clutter_event_type (event);
ClutterInputDevice *device = clutter_event_get_device (event);
@ -220,9 +222,10 @@ gesture_find_point (ClutterGestureAction *action,
static void
gesture_unregister_point (ClutterGestureAction *action, gint position)
{
ClutterGestureActionPrivate *priv = action->priv;
ClutterGestureActionPrivate *priv =
clutter_gesture_action_get_instance_private (action);
if (action->priv->points->len == 0)
if (priv->points->len == 0)
return;
g_array_remove_index (priv->points, position);
@ -303,7 +306,8 @@ gesture_point_unset (GesturePoint *point)
static void
cancel_gesture (ClutterGestureAction *action)
{
ClutterGestureActionPrivate *priv = action->priv;
ClutterGestureActionPrivate *priv =
clutter_gesture_action_get_instance_private (action);
ClutterActor *actor;
priv->in_gesture = FALSE;
@ -313,14 +317,15 @@ cancel_gesture (ClutterGestureAction *action)
actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (action));
g_signal_emit (action, gesture_signals[GESTURE_CANCEL], 0, actor);
g_array_set_size (action->priv->points, 0);
g_array_set_size (priv->points, 0);
}
static gboolean
begin_gesture (ClutterGestureAction *action,
ClutterActor *actor)
{
ClutterGestureActionPrivate *priv = action->priv;
ClutterGestureActionPrivate *priv =
clutter_gesture_action_get_instance_private (action);
gboolean return_value;
priv->in_gesture = TRUE;
@ -353,7 +358,8 @@ stage_captured_event_cb (ClutterActor *stage,
ClutterEvent *event,
ClutterGestureAction *action)
{
ClutterGestureActionPrivate *priv = action->priv;
ClutterGestureActionPrivate *priv =
clutter_gesture_action_get_instance_private (action);
ClutterActor *actor;
gint position;
float threshold_x, threshold_y;
@ -488,7 +494,8 @@ actor_captured_event_cb (ClutterActor *actor,
ClutterEvent *event,
ClutterGestureAction *action)
{
ClutterGestureActionPrivate *priv = action->priv;
ClutterGestureActionPrivate *priv =
clutter_gesture_action_get_instance_private (action);
GesturePoint *point G_GNUC_UNUSED;
if ((clutter_event_type (event) != CLUTTER_BUTTON_PRESS) &&
@ -522,7 +529,8 @@ static void
clutter_gesture_action_set_actor (ClutterActorMeta *meta,
ClutterActor *actor)
{
ClutterGestureActionPrivate *priv = CLUTTER_GESTURE_ACTION (meta)->priv;
ClutterGestureActionPrivate *priv =
clutter_gesture_action_get_instance_private (CLUTTER_GESTURE_ACTION (meta));
ClutterActorMetaClass *meta_class =
CLUTTER_ACTOR_META_CLASS (clutter_gesture_action_parent_class);
@ -563,7 +571,8 @@ clutter_gesture_action_set_enabled (ClutterActorMeta *meta,
ClutterActorMetaClass *meta_class =
CLUTTER_ACTOR_META_CLASS (clutter_gesture_action_parent_class);
ClutterGestureAction *gesture_action = CLUTTER_GESTURE_ACTION (meta);
ClutterGestureActionPrivate *priv = gesture_action->priv;
ClutterGestureActionPrivate *priv =
clutter_gesture_action_get_instance_private (gesture_action);
if (!is_enabled && priv->in_gesture)
cancel_gesture (gesture_action);
@ -585,6 +594,8 @@ clutter_gesture_action_set_property (GObject *gobject,
GParamSpec *pspec)
{
ClutterGestureAction *self = CLUTTER_GESTURE_ACTION (gobject);
ClutterGestureActionPrivate *priv =
clutter_gesture_action_get_instance_private (self);
switch (prop_id)
{
@ -597,11 +608,15 @@ clutter_gesture_action_set_property (GObject *gobject,
break;
case PROP_THRESHOLD_TRIGGER_DISTANCE_X:
clutter_gesture_action_set_threshold_trigger_distance (self, g_value_get_float (value), self->priv->distance_y);
clutter_gesture_action_set_threshold_trigger_distance (self,
g_value_get_float (value),
priv->distance_y);
break;
case PROP_THRESHOLD_TRIGGER_DISTANCE_Y:
clutter_gesture_action_set_threshold_trigger_distance (self, self->priv->distance_x, g_value_get_float (value));
clutter_gesture_action_set_threshold_trigger_distance (self,
priv->distance_x,
g_value_get_float (value));
break;
default:
@ -616,28 +631,29 @@ clutter_gesture_action_get_property (GObject *gobject,
GValue *value,
GParamSpec *pspec)
{
ClutterGestureAction *self = CLUTTER_GESTURE_ACTION (gobject);
ClutterGestureActionPrivate *priv =
clutter_gesture_action_get_instance_private (CLUTTER_GESTURE_ACTION (gobject));
switch (prop_id)
{
case PROP_N_TOUCH_POINTS:
g_value_set_int (value, self->priv->requested_nb_points);
g_value_set_int (value, priv->requested_nb_points);
break;
case PROP_THRESHOLD_TRIGGER_EDGE:
g_value_set_enum (value, self->priv->edge);
g_value_set_enum (value, priv->edge);
break;
case PROP_THRESHOLD_TRIGGER_DISTANCE_X:
if (self->priv->distance_x > 0.0)
g_value_set_float (value, self->priv->distance_x);
if (priv->distance_x > 0.0)
g_value_set_float (value, priv->distance_x);
else
g_value_set_float (value, gesture_get_default_threshold ());
break;
case PROP_THRESHOLD_TRIGGER_DISTANCE_Y:
if (self->priv->distance_y > 0.0)
g_value_set_float (value, self->priv->distance_y);
if (priv->distance_y > 0.0)
g_value_set_float (value, priv->distance_y);
else
g_value_set_float (value, gesture_get_default_threshold ());
break;
@ -651,7 +667,8 @@ clutter_gesture_action_get_property (GObject *gobject,
static void
clutter_gesture_action_finalize (GObject *gobject)
{
ClutterGestureActionPrivate *priv = CLUTTER_GESTURE_ACTION (gobject)->priv;
ClutterGestureActionPrivate *priv =
clutter_gesture_action_get_instance_private (CLUTTER_GESTURE_ACTION (gobject));
g_array_unref (priv->points);
@ -843,13 +860,14 @@ clutter_gesture_action_class_init (ClutterGestureActionClass *klass)
static void
clutter_gesture_action_init (ClutterGestureAction *self)
{
self->priv = clutter_gesture_action_get_instance_private (self);
ClutterGestureActionPrivate *priv =
clutter_gesture_action_get_instance_private (self);
self->priv->points = g_array_sized_new (FALSE, TRUE, sizeof (GesturePoint), 3);
g_array_set_clear_func (self->priv->points, (GDestroyNotify) gesture_point_unset);
priv->points = g_array_sized_new (FALSE, TRUE, sizeof (GesturePoint), 3);
g_array_set_clear_func (priv->points, (GDestroyNotify) gesture_point_unset);
self->priv->requested_nb_points = 1;
self->priv->edge = CLUTTER_GESTURE_TRIGGER_EDGE_NONE;
priv->requested_nb_points = 1;
priv->edge = CLUTTER_GESTURE_TRIGGER_EDGE_NONE;
}
/**
@ -888,16 +906,21 @@ clutter_gesture_action_get_press_coords (ClutterGestureAction *action,
gfloat *press_x,
gfloat *press_y)
{
ClutterGestureActionPrivate *priv;
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
g_return_if_fail (action->priv->points->len > point);
priv = clutter_gesture_action_get_instance_private (action);
g_return_if_fail (priv->points->len > point);
if (press_x)
*press_x = g_array_index (action->priv->points,
*press_x = g_array_index (priv->points,
GesturePoint,
point).press_x;
if (press_y)
*press_y = g_array_index (action->priv->points,
*press_y = g_array_index (priv->points,
GesturePoint,
point).press_y;
}
@ -923,16 +946,21 @@ clutter_gesture_action_get_motion_coords (ClutterGestureAction *action,
gfloat *motion_x,
gfloat *motion_y)
{
ClutterGestureActionPrivate *priv;
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
g_return_if_fail (action->priv->points->len > point);
priv = clutter_gesture_action_get_instance_private (action);
g_return_if_fail (priv->points->len > point);
if (motion_x)
*motion_x = g_array_index (action->priv->points,
*motion_x = g_array_index (priv->points,
GesturePoint,
point).last_motion_x;
if (motion_y)
*motion_y = g_array_index (action->priv->points,
*motion_y = g_array_index (priv->points,
GesturePoint,
point).last_motion_y;
}
@ -960,15 +988,19 @@ clutter_gesture_action_get_motion_delta (ClutterGestureAction *action,
gfloat *delta_x,
gfloat *delta_y)
{
ClutterGestureActionPrivate *priv;
gfloat d_x, d_y;
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), 0);
g_return_val_if_fail (action->priv->points->len > point, 0);
d_x = g_array_index (action->priv->points,
priv = clutter_gesture_action_get_instance_private (action);
g_return_val_if_fail (priv->points->len > point, 0);
d_x = g_array_index (priv->points,
GesturePoint,
point).last_delta_x;
d_y = g_array_index (action->priv->points,
d_y = g_array_index (priv->points,
GesturePoint,
point).last_delta_y;
@ -1002,16 +1034,21 @@ clutter_gesture_action_get_release_coords (ClutterGestureAction *action,
gfloat *release_x,
gfloat *release_y)
{
ClutterGestureActionPrivate *priv;
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
g_return_if_fail (action->priv->points->len > point);
priv = clutter_gesture_action_get_instance_private (action);
g_return_if_fail (priv->points->len > point);
if (release_x)
*release_x = g_array_index (action->priv->points,
*release_x = g_array_index (priv->points,
GesturePoint,
point).release_x;
if (release_y)
*release_y = g_array_index (action->priv->points,
*release_y = g_array_index (priv->points,
GesturePoint,
point).release_y;
}
@ -1037,16 +1074,20 @@ clutter_gesture_action_get_velocity (ClutterGestureAction *action,
gfloat *velocity_x,
gfloat *velocity_y)
{
ClutterGestureActionPrivate *priv;
gfloat d_x, d_y, distance, velocity;
gint64 d_t;
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), 0);
g_return_val_if_fail (action->priv->points->len > point, 0);
priv = clutter_gesture_action_get_instance_private (action);
g_return_val_if_fail (priv->points->len > point, 0);
distance = clutter_gesture_action_get_motion_delta (action, point,
&d_x, &d_y);
d_t = g_array_index (action->priv->points,
d_t = g_array_index (priv->points,
GesturePoint,
point).last_delta_time;
@ -1073,9 +1114,13 @@ clutter_gesture_action_get_velocity (ClutterGestureAction *action,
gint
clutter_gesture_action_get_n_touch_points (ClutterGestureAction *action)
{
ClutterGestureActionPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), 0);
return action->priv->requested_nb_points;
priv = clutter_gesture_action_get_instance_private (action);
return priv->requested_nb_points;
}
/**
@ -1096,7 +1141,7 @@ clutter_gesture_action_set_n_touch_points (ClutterGestureAction *action,
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
g_return_if_fail (nb_points >= 1);
priv = action->priv;
priv = clutter_gesture_action_get_instance_private (action);
if (priv->requested_nb_points == nb_points)
return;
@ -1150,9 +1195,13 @@ clutter_gesture_action_set_n_touch_points (ClutterGestureAction *action,
guint
clutter_gesture_action_get_n_current_points (ClutterGestureAction *action)
{
ClutterGestureActionPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), 0);
return action->priv->points->len;
priv = clutter_gesture_action_get_instance_private (action);
return priv->points->len;
}
/**
@ -1170,10 +1219,15 @@ ClutterEventSequence *
clutter_gesture_action_get_sequence (ClutterGestureAction *action,
guint point)
{
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), NULL);
g_return_val_if_fail (action->priv->points->len > point, NULL);
ClutterGestureActionPrivate *priv;
return g_array_index (action->priv->points, GesturePoint, point).sequence;
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), NULL);
priv = clutter_gesture_action_get_instance_private (action);
g_return_val_if_fail (priv->points->len > point, NULL);
return g_array_index (priv->points, GesturePoint, point).sequence;
}
/**
@ -1192,10 +1246,15 @@ ClutterInputDevice *
clutter_gesture_action_get_device (ClutterGestureAction *action,
guint point)
{
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), NULL);
g_return_val_if_fail (action->priv->points->len > point, NULL);
ClutterGestureActionPrivate *priv;
return g_array_index (action->priv->points, GesturePoint, point).device;
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), NULL);
priv = clutter_gesture_action_get_instance_private (action);
g_return_val_if_fail (priv->points->len > point, NULL);
return g_array_index (priv->points, GesturePoint, point).device;
}
/**
@ -1215,11 +1274,15 @@ clutter_gesture_action_get_last_event (ClutterGestureAction *action,
guint point)
{
GesturePoint *gesture_point;
ClutterGestureActionPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action), NULL);
g_return_val_if_fail (action->priv->points->len > point, NULL);
gesture_point = &g_array_index (action->priv->points, GesturePoint, point);
priv = clutter_gesture_action_get_instance_private (action);
g_return_val_if_fail (priv->points->len > point, NULL);
gesture_point = &g_array_index (priv->points, GesturePoint, point);
return gesture_point->last_event;
}
@ -1256,12 +1319,16 @@ void
clutter_gesture_action_set_threshold_trigger_edge (ClutterGestureAction *action,
ClutterGestureTriggerEdge edge)
{
ClutterGestureActionPrivate *priv;
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
if (action->priv->edge == edge)
priv = clutter_gesture_action_get_instance_private (action);
if (priv->edge == edge)
return;
action->priv->edge = edge;
priv->edge = edge;
g_object_notify_by_pspec (G_OBJECT (action), gesture_props[PROP_THRESHOLD_TRIGGER_EDGE]);
}
@ -1280,10 +1347,14 @@ clutter_gesture_action_set_threshold_trigger_edge (ClutterGestureAction *ac
ClutterGestureTriggerEdge
clutter_gesture_action_get_threshold_trigger_edge (ClutterGestureAction *action)
{
ClutterGestureActionPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_GESTURE_ACTION (action),
CLUTTER_GESTURE_TRIGGER_EDGE_NONE);
return action->priv->edge;
priv = clutter_gesture_action_get_instance_private (action);
return priv->edge;
}
/**
@ -1323,17 +1394,21 @@ clutter_gesture_action_set_threshold_trigger_distance (ClutterGestureAction
float x,
float y)
{
ClutterGestureActionPrivate *priv;
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
if (fabsf (x - action->priv->distance_x) > FLOAT_EPSILON)
priv = clutter_gesture_action_get_instance_private (action);
if (fabsf (x - priv->distance_x) > FLOAT_EPSILON)
{
action->priv->distance_x = x;
priv->distance_x = x;
g_object_notify_by_pspec (G_OBJECT (action), gesture_props[PROP_THRESHOLD_TRIGGER_DISTANCE_X]);
}
if (fabsf (y - action->priv->distance_y) > FLOAT_EPSILON)
if (fabsf (y - priv->distance_y) > FLOAT_EPSILON)
{
action->priv->distance_y = y;
priv->distance_y = y;
g_object_notify_by_pspec (G_OBJECT (action), gesture_props[PROP_THRESHOLD_TRIGGER_DISTANCE_Y]);
}
}
@ -1354,19 +1429,23 @@ clutter_gesture_action_get_threshold_trigger_distance (ClutterGestureAction *act
float *x,
float *y)
{
ClutterGestureActionPrivate *priv;
g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
priv = clutter_gesture_action_get_instance_private (action);
if (x != NULL)
{
if (action->priv->distance_x > 0.0)
*x = action->priv->distance_x;
if (priv->distance_x > 0.0)
*x = priv->distance_x;
else
*x = gesture_get_default_threshold ();
}
if (y != NULL)
{
if (action->priv->distance_y > 0.0)
*y = action->priv->distance_y;
if (priv->distance_y > 0.0)
*y = priv->distance_y;
else
*y = gesture_get_default_threshold ();
}

View File

@ -34,32 +34,13 @@
G_BEGIN_DECLS
#define CLUTTER_TYPE_GESTURE_ACTION (clutter_gesture_action_get_type ())
#define CLUTTER_GESTURE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_GESTURE_ACTION, ClutterGestureAction))
#define CLUTTER_IS_GESTURE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_GESTURE_ACTION))
#define CLUTTER_GESTURE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_GESTURE_ACTION, ClutterGestureActionClass))
#define CLUTTER_IS_GESTURE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_GESTURE_ACTION))
#define CLUTTER_GESTURE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_GESTURE_ACTION, ClutterGestureActionClass))
#define CLUTTER_TYPE_GESTURE_ACTION (clutter_gesture_action_get_type ())
typedef struct _ClutterGestureAction ClutterGestureAction;
typedef struct _ClutterGestureActionPrivate ClutterGestureActionPrivate;
typedef struct _ClutterGestureActionClass ClutterGestureActionClass;
CLUTTER_EXPORT
G_DECLARE_DERIVABLE_TYPE (ClutterGestureAction, clutter_gesture_action,
CLUTTER, GESTURE_ACTION, ClutterAction);
/**
* ClutterGestureAction:
*
* The #ClutterGestureAction structure contains
* only private data and should be accessed using the provided API
*
* Since: 1.8
*/
struct _ClutterGestureAction
{
/*< private >*/
ClutterAction parent_instance;
ClutterGestureActionPrivate *priv;
};
typedef struct _ClutterGestureActionPrivate ClutterGestureActionPrivate;
/**
* ClutterGestureActionClass:
@ -101,9 +82,6 @@ struct _ClutterGestureActionClass
void (* _clutter_gesture_action6) (void);
};
CLUTTER_EXPORT
GType clutter_gesture_action_get_type (void) G_GNUC_CONST;
CLUTTER_EXPORT
ClutterAction * clutter_gesture_action_new (void);

View File

@ -1391,8 +1391,7 @@ allocate_child (ClutterGridRequest *request,
static void
clutter_grid_layout_allocate (ClutterLayoutManager *layout,
ClutterContainer *container,
const ClutterActorBox *allocation,
ClutterAllocationFlags flags)
const ClutterActorBox *allocation)
{
ClutterGridLayout *self = CLUTTER_GRID_LAYOUT (layout);
ClutterOrientation orientation;
@ -1453,7 +1452,7 @@ clutter_grid_layout_allocate (ClutterLayoutManager *layout,
child_allocation.x2 = child_allocation.x1 + width;
child_allocation.y2 = child_allocation.y1 + height;
clutter_actor_allocate (child, &child_allocation, flags);
clutter_actor_allocate (child, &child_allocation);
}
}

View File

@ -37,9 +37,6 @@
* any object taking a reference on a #ClutterInterval instance should
* also take ownership of the interval by using g_object_ref_sink().
*
* #ClutterInterval is used by #ClutterAnimation to define the
* interval of values that an implicit animation should tween over.
*
* #ClutterInterval can be subclassed to override the validation
* and value computation.
*

View File

@ -136,7 +136,6 @@
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include "deprecated/clutter-container.h"
#include "deprecated/clutter-alpha.h"
#include "clutter-debug.h"
#include "clutter-layout-manager.h"
@ -164,7 +163,6 @@ G_DEFINE_ABSTRACT_TYPE (ClutterLayoutManager,
G_TYPE_INITIALLY_UNOWNED)
static GQuark quark_layout_meta = 0;
static GQuark quark_layout_alpha = 0;
static guint manager_signals[LAST_SIGNAL] = { 0, };
@ -255,8 +253,7 @@ layout_manager_real_get_preferred_height (ClutterLayoutManager *manager,
static void
layout_manager_real_allocate (ClutterLayoutManager *manager,
ClutterContainer *container,
const ClutterActorBox *allocation,
ClutterAllocationFlags flags)
const ClutterActorBox *allocation)
{
LAYOUT_MANAGER_WARN_NOT_IMPLEMENTED (manager, "allocate");
}
@ -301,96 +298,12 @@ layout_manager_real_get_child_meta_type (ClutterLayoutManager *manager)
return G_TYPE_INVALID;
}
/* XXX:2.0 - Remove */
static ClutterAlpha *
layout_manager_real_begin_animation (ClutterLayoutManager *manager,
guint duration,
gulong mode)
{
ClutterTimeline *timeline;
ClutterAlpha *alpha;
alpha = g_object_get_qdata (G_OBJECT (manager), quark_layout_alpha);
if (alpha != NULL)
{
clutter_alpha_set_mode (alpha, mode);
timeline = clutter_alpha_get_timeline (alpha);
clutter_timeline_set_duration (timeline, duration);
clutter_timeline_rewind (timeline);
return alpha;
};
timeline = clutter_timeline_new (duration);
alpha = clutter_alpha_new_full (timeline, mode);
/* let the alpha take ownership of the timeline */
g_object_unref (timeline);
g_signal_connect_swapped (timeline, "new-frame",
G_CALLBACK (clutter_layout_manager_layout_changed),
manager);
g_object_set_qdata_full (G_OBJECT (manager),
quark_layout_alpha, alpha,
(GDestroyNotify) g_object_unref);
clutter_timeline_start (timeline);
return alpha;
}
/* XXX:2.0 - Remove */
static gdouble
layout_manager_real_get_animation_progress (ClutterLayoutManager *manager)
{
ClutterAlpha *alpha;
alpha = g_object_get_qdata (G_OBJECT (manager), quark_layout_alpha);
if (alpha == NULL)
return 1.0;
return clutter_alpha_get_alpha (alpha);
}
/* XXX:2.0 - Remove */
static void
layout_manager_real_end_animation (ClutterLayoutManager *manager)
{
ClutterTimeline *timeline;
ClutterAlpha *alpha;
alpha = g_object_get_qdata (G_OBJECT (manager), quark_layout_alpha);
if (alpha == NULL)
return;
timeline = clutter_alpha_get_timeline (alpha);
g_assert (timeline != NULL);
if (clutter_timeline_is_playing (timeline))
clutter_timeline_stop (timeline);
g_signal_handlers_disconnect_by_func (timeline,
G_CALLBACK (clutter_layout_manager_layout_changed),
manager);
g_object_set_qdata (G_OBJECT (manager), quark_layout_alpha, NULL);
clutter_layout_manager_layout_changed (manager);
}
static void
clutter_layout_manager_class_init (ClutterLayoutManagerClass *klass)
{
quark_layout_meta =
g_quark_from_static_string ("clutter-layout-manager-child-meta");
/* XXX:2.0 - Remove */
quark_layout_alpha =
g_quark_from_static_string ("clutter-layout-manager-alpha");
klass->get_preferred_width = layout_manager_real_get_preferred_width;
klass->get_preferred_height = layout_manager_real_get_preferred_height;
klass->allocate = layout_manager_real_allocate;
@ -398,9 +311,6 @@ clutter_layout_manager_class_init (ClutterLayoutManagerClass *klass)
klass->get_child_meta_type = layout_manager_real_get_child_meta_type;
/* XXX:2.0 - Remove */
klass->begin_animation = layout_manager_real_begin_animation;
klass->get_animation_progress = layout_manager_real_get_animation_progress;
klass->end_animation = layout_manager_real_end_animation;
klass->set_container = layout_manager_real_set_container;
/**
@ -523,7 +433,6 @@ clutter_layout_manager_get_preferred_height (ClutterLayoutManager *manager,
* @container: the #ClutterContainer using @manager
* @allocation: the #ClutterActorBox containing the allocated area
* of @container
* @flags: the allocation flags
*
* Allocates the children of @container given an area
*
@ -534,8 +443,7 @@ clutter_layout_manager_get_preferred_height (ClutterLayoutManager *manager,
void
clutter_layout_manager_allocate (ClutterLayoutManager *manager,
ClutterContainer *container,
const ClutterActorBox *allocation,
ClutterAllocationFlags flags)
const ClutterActorBox *allocation)
{
ClutterLayoutManagerClass *klass;
@ -544,7 +452,7 @@ clutter_layout_manager_allocate (ClutterLayoutManager *manager,
g_return_if_fail (allocation != NULL);
klass = CLUTTER_LAYOUT_MANAGER_GET_CLASS (manager);
klass->allocate (manager, container, allocation, flags);
klass->allocate (manager, container, allocation);
}
/**

View File

@ -115,8 +115,7 @@ struct _ClutterLayoutManagerClass
gfloat *nat_height_p);
void (* allocate) (ClutterLayoutManager *manager,
ClutterContainer *container,
const ClutterActorBox *allocation,
ClutterAllocationFlags flags);
const ClutterActorBox *allocation);
void (* set_container) (ClutterLayoutManager *manager,
ClutterContainer *container);
@ -126,15 +125,6 @@ struct _ClutterLayoutManagerClass
ClutterContainer *container,
ClutterActor *actor);
/* deprecated */
ClutterAlpha * (* begin_animation) (ClutterLayoutManager *manager,
guint duration,
gulong mode);
/* deprecated */
gdouble (* get_animation_progress) (ClutterLayoutManager *manager);
/* deprecated */
void (* end_animation) (ClutterLayoutManager *manager);
void (* layout_changed) (ClutterLayoutManager *manager);
/*< private >*/
@ -167,8 +157,7 @@ void clutter_layout_manager_get_preferred_height (ClutterLayoutMa
CLUTTER_EXPORT
void clutter_layout_manager_allocate (ClutterLayoutManager *manager,
ClutterContainer *container,
const ClutterActorBox *allocation,
ClutterAllocationFlags flags);
const ClutterActorBox *allocation);
CLUTTER_EXPORT
void clutter_layout_manager_set_container (ClutterLayoutManager *manager,

View File

@ -2392,8 +2392,7 @@ clutter_threads_add_repaint_func_full (ClutterRepaintFlags flags,
repaint_func->id = context->last_repaint_id++;
/* mask out QUEUE_REDRAW_ON_ADD, since we're going to consume it */
repaint_func->flags = flags & ~CLUTTER_REPAINT_FLAGS_QUEUE_REDRAW_ON_ADD;
repaint_func->flags = flags;
repaint_func->func = func;
repaint_func->data = data;
repaint_func->notify = notify;
@ -2403,13 +2402,6 @@ clutter_threads_add_repaint_func_full (ClutterRepaintFlags flags,
_clutter_context_unlock ();
if ((flags & CLUTTER_REPAINT_FLAGS_QUEUE_REDRAW_ON_ADD) != 0)
{
ClutterMasterClock *master_clock = _clutter_master_clock_get_default ();
_clutter_master_clock_ensure_next_iteration (master_clock);
}
return repaint_func->id;
}

View File

@ -199,7 +199,7 @@ master_clock_schedule_stage_updates (ClutterMasterClockDefault *master_clock)
stages = clutter_stage_manager_peek_stages (stage_manager);
for (l = stages; l != NULL; l = l->next)
_clutter_stage_schedule_update (l->data);
clutter_stage_schedule_update (l->data);
}
static GSList *
@ -252,7 +252,7 @@ master_clock_reschedule_stage_updates (ClutterMasterClockDefault *master_clock,
if (master_clock->timelines ||
_clutter_stage_has_queued_events (l->data) ||
_clutter_stage_needs_update (l->data))
_clutter_stage_schedule_update (l->data);
clutter_stage_schedule_update (l->data);
}
}

View File

@ -75,7 +75,7 @@ CLUTTER_EXPORT
void clutter_stage_thaw_updates (ClutterStage *stage);
CLUTTER_EXPORT
void clutter_stage_update_resource_scales (ClutterStage *stage);
void clutter_stage_clear_stage_views (ClutterStage *stage);
CLUTTER_EXPORT
void clutter_stage_view_assign_next_scanout (ClutterStageView *stage_view,

View File

@ -136,7 +136,8 @@ enum
static guint pan_signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE_WITH_PRIVATE (ClutterPanAction, clutter_pan_action, CLUTTER_TYPE_GESTURE_ACTION)
G_DEFINE_TYPE_WITH_PRIVATE (ClutterPanAction, clutter_pan_action,
CLUTTER_TYPE_GESTURE_ACTION)
static void
emit_pan (ClutterPanAction *self,
@ -156,14 +157,18 @@ emit_pan (ClutterPanAction *self,
gfloat scroll_threshold = G_PI_4/2;
gfloat drag_angle;
clutter_gesture_action_get_motion_delta (CLUTTER_GESTURE_ACTION (self), 0, &delta_x, &delta_y);
clutter_gesture_action_get_motion_delta (CLUTTER_GESTURE_ACTION (self),
0,
&delta_x,
&delta_y);
if (delta_x != 0.0f)
drag_angle = atanf (delta_y / delta_x);
else
drag_angle = G_PI_2;
if ((drag_angle > -scroll_threshold) && (drag_angle < scroll_threshold))
if ((drag_angle > -scroll_threshold) &&
(drag_angle < scroll_threshold))
priv->pin_state = SCROLL_PINNED_HORIZONTAL;
else if ((drag_angle > (G_PI_2 - scroll_threshold)) ||
(drag_angle < -(G_PI_2 - scroll_threshold)))
@ -282,7 +287,10 @@ gesture_end (ClutterGestureAction *gesture,
gfloat tau;
gint duration;
clutter_gesture_action_get_release_coords (CLUTTER_GESTURE_ACTION (self), 0, &priv->release_x, &priv->release_y);
clutter_gesture_action_get_release_coords (CLUTTER_GESTURE_ACTION (self),
0,
&priv->release_x,
&priv->release_y);
if (!priv->should_interpolate)
{
@ -293,7 +301,9 @@ gesture_end (ClutterGestureAction *gesture,
priv->state = PAN_STATE_INTERPOLATING;
clutter_gesture_action_get_motion_delta (gesture, 0, &delta_x, &delta_y);
velocity = clutter_gesture_action_get_velocity (gesture, 0, &velocity_x, &velocity_y);
velocity = clutter_gesture_action_get_velocity (gesture, 0,
&velocity_x,
&velocity_y);
/* Exponential timing constant v(t) = v(0) * exp(-t/tau)
* tau = 1000ms / (frame_per_second * - ln(decay_per_frame))
@ -304,17 +314,22 @@ gesture_end (ClutterGestureAction *gesture,
/* See where the decreasing velocity reaches $min_velocity px/ms
* v(t) = v(0) * exp(-t/tau) = min_velocity
* t = - tau * ln( min_velocity / |v(0)|) */
duration = - tau * logf (min_velocity / (ABS (velocity) * priv->acceleration_factor));
duration = - tau * logf (min_velocity / (ABS (velocity) *
priv->acceleration_factor));
/* Target point: x(t) = v(0) * tau * [1 - exp(-t/tau)] */
priv->target_x = velocity_x * priv->acceleration_factor * tau * (1 - exp ((float)-duration / tau));
priv->target_y = velocity_y * priv->acceleration_factor * tau * (1 - exp ((float)-duration / tau));
priv->target_x = (velocity_x * priv->acceleration_factor * tau *
(1 - exp ((float)-duration / tau)));
priv->target_y = (velocity_y * priv->acceleration_factor * tau *
(1 - exp ((float)-duration / tau)));
if (ABS (velocity) * priv->acceleration_factor > min_velocity && duration > FLOAT_EPSILON)
if (ABS (velocity) * priv->acceleration_factor > min_velocity &&
duration > FLOAT_EPSILON)
{
priv->interpolated_x = priv->interpolated_y = 0.0f;
priv->deceleration_timeline = clutter_timeline_new (duration);
clutter_timeline_set_progress_mode (priv->deceleration_timeline, CLUTTER_EASE_OUT_EXPO);
clutter_timeline_set_progress_mode (priv->deceleration_timeline,
CLUTTER_EASE_OUT_EXPO);
g_signal_connect (priv->deceleration_timeline, "new_frame",
G_CALLBACK (on_deceleration_new_frame), self);
@ -367,7 +382,8 @@ clutter_pan_action_set_property (GObject *gobject,
break;
case PROP_ACCELERATION_FACTOR :
clutter_pan_action_set_acceleration_factor (self, g_value_get_double (value));
clutter_pan_action_set_acceleration_factor (self,
g_value_get_double (value));
break;
default:
@ -411,9 +427,11 @@ static void
clutter_pan_action_constructed (GObject *gobject)
{
ClutterGestureAction *gesture;
ClutterGestureTriggerEdge edge;
gesture = CLUTTER_GESTURE_ACTION (gobject);
clutter_gesture_action_set_threshold_trigger_edge (gesture, CLUTTER_GESTURE_TRIGGER_EDGE_AFTER);
edge = CLUTTER_GESTURE_TRIGGER_EDGE_AFTER;
clutter_gesture_action_set_threshold_trigger_edge (gesture, edge);
}
static void
@ -442,7 +460,8 @@ clutter_pan_action_set_actor (ClutterActorMeta *meta,
g_clear_object (&priv->deceleration_timeline);
}
CLUTTER_ACTOR_META_CLASS (clutter_pan_action_parent_class)->set_actor (meta, actor);
CLUTTER_ACTOR_META_CLASS (clutter_pan_action_parent_class)->set_actor (meta,
actor);
}
@ -880,7 +899,9 @@ clutter_pan_action_get_constrained_motion_delta (ClutterPanAction *self,
priv = self->priv;
distance = clutter_pan_action_get_motion_delta (self, point, &delta_x, &delta_y);
distance = clutter_pan_action_get_motion_delta (self, point,
&delta_x,
&delta_y);
switch (priv->pan_axis)
{

View File

@ -65,7 +65,6 @@ typedef struct _ClutterVertex4 ClutterVertex4;
#define CLUTTER_ACTOR_IS_TOPLEVEL(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IS_TOPLEVEL) != FALSE)
#define CLUTTER_ACTOR_IN_DESTRUCTION(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_DESTRUCTION) != FALSE)
#define CLUTTER_ACTOR_IN_REPARENT(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_REPARENT) != FALSE)
#define CLUTTER_ACTOR_IN_PAINT(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_PAINT) != FALSE)
#define CLUTTER_ACTOR_IN_PICK(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_PICK) != FALSE)
#define CLUTTER_ACTOR_IN_RELAYOUT(a) ((CLUTTER_PRIVATE_FLAGS (a) & CLUTTER_IN_RELAYOUT) != FALSE)
@ -99,7 +98,6 @@ typedef enum
CLUTTER_IN_DESTRUCTION = 1 << 0,
CLUTTER_IS_TOPLEVEL = 1 << 1,
CLUTTER_IN_REPARENT = 1 << 2,
CLUTTER_IN_PREF_WIDTH = 1 << 3,
CLUTTER_IN_PREF_HEIGHT = 1 << 4,

View File

@ -34,7 +34,6 @@
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include "deprecated/clutter-container.h"
#include "deprecated/clutter-alpha.h"
#include "clutter-actor.h"
#include "clutter-debug.h"
@ -799,232 +798,6 @@ parse_signals (ClutterScript *script,
return retval;
}
static ClutterTimeline *
construct_timeline (ClutterScript *script,
JsonObject *object)
{
ClutterTimeline *retval = NULL;
ObjectInfo *oinfo;
GList *members, *l;
/* we fake an ObjectInfo so we can reuse clutter_script_construct_object()
* here; we do not save it inside the hash table, because if this had
* been a named object then we wouldn't have ended up here in the first
* place
*/
oinfo = g_slice_new0 (ObjectInfo);
oinfo->gtype = CLUTTER_TYPE_TIMELINE;
oinfo->id = g_strdup ("dummy");
members = json_object_get_members (object);
for (l = members; l != NULL; l = l->next)
{
const gchar *name = l->data;
JsonNode *node = json_object_get_member (object, name);
PropertyInfo *pinfo = g_slice_new0 (PropertyInfo);
pinfo->name = g_strdelimit (g_strdup (name), G_STR_DELIMITERS, '-');
pinfo->node = json_node_copy (node);
oinfo->properties = g_list_prepend (oinfo->properties, pinfo);
}
g_list_free (members);
_clutter_script_construct_object (script, oinfo);
_clutter_script_apply_properties (script, oinfo);
retval = CLUTTER_TIMELINE (oinfo->object);
/* we transfer ownership to the alpha function, so we ref before
* destroying the ObjectInfo to avoid the timeline going away
*/
g_object_ref (retval);
object_info_free (oinfo);
return retval;
}
/* define the names of the animation modes to match the ones
* that developers might be more accustomed to
*/
static const struct
{
const gchar *name;
ClutterAnimationMode mode;
} animation_modes[] = {
{ "linear", CLUTTER_LINEAR },
{ "easeInQuad", CLUTTER_EASE_IN_QUAD },
{ "easeOutQuad", CLUTTER_EASE_OUT_QUAD },
{ "easeInOutQuad", CLUTTER_EASE_IN_OUT_QUAD },
{ "easeInCubic", CLUTTER_EASE_IN_CUBIC },
{ "easeOutCubic", CLUTTER_EASE_OUT_CUBIC },
{ "easeInOutCubic", CLUTTER_EASE_IN_OUT_CUBIC },
{ "easeInQuart", CLUTTER_EASE_IN_QUART },
{ "easeOutQuart", CLUTTER_EASE_OUT_QUART },
{ "easeInOutQuart", CLUTTER_EASE_IN_OUT_QUART },
{ "easeInQuint", CLUTTER_EASE_IN_QUINT },
{ "easeOutQuint", CLUTTER_EASE_OUT_QUINT },
{ "easeInOutQuint", CLUTTER_EASE_IN_OUT_QUINT },
{ "easeInSine", CLUTTER_EASE_IN_SINE },
{ "easeOutSine", CLUTTER_EASE_OUT_SINE },
{ "easeInOutSine", CLUTTER_EASE_IN_OUT_SINE },
{ "easeInExpo", CLUTTER_EASE_IN_EXPO },
{ "easeOutExpo", CLUTTER_EASE_OUT_EXPO },
{ "easeInOutExpo", CLUTTER_EASE_IN_OUT_EXPO },
{ "easeInCirc", CLUTTER_EASE_IN_CIRC },
{ "easeOutCirc", CLUTTER_EASE_OUT_CIRC },
{ "easeInOutCirc", CLUTTER_EASE_IN_OUT_CIRC },
{ "easeInElastic", CLUTTER_EASE_IN_ELASTIC },
{ "easeOutElastic", CLUTTER_EASE_OUT_ELASTIC },
{ "easeInOutElastic", CLUTTER_EASE_IN_OUT_ELASTIC },
{ "easeInBack", CLUTTER_EASE_IN_BACK },
{ "easeOutBack", CLUTTER_EASE_OUT_BACK },
{ "easeInOutBack", CLUTTER_EASE_IN_OUT_BACK },
{ "easeInBounce", CLUTTER_EASE_IN_BOUNCE },
{ "easeOutBounce", CLUTTER_EASE_OUT_BOUNCE },
{ "easeInOutBounce", CLUTTER_EASE_IN_OUT_BOUNCE },
};
static const gint n_animation_modes = G_N_ELEMENTS (animation_modes);
gulong
_clutter_script_resolve_animation_mode (JsonNode *node)
{
gint i, res = CLUTTER_CUSTOM_MODE;
if (JSON_NODE_TYPE (node) != JSON_NODE_VALUE)
return CLUTTER_CUSTOM_MODE;
if (json_node_get_value_type (node) == G_TYPE_INT64)
return json_node_get_int (node);
if (json_node_get_value_type (node) == G_TYPE_STRING)
{
const gchar *name = json_node_get_string (node);
/* XXX - we might be able to optimize by changing the ordering
* of the animation_modes array, e.g.
* - special casing linear
* - tokenizing ('ease', 'In', 'Sine') and matching on token
* - binary searching?
*/
for (i = 0; i < n_animation_modes; i++)
{
if (strcmp (animation_modes[i].name, name) == 0)
return animation_modes[i].mode;
}
if (_clutter_script_enum_from_string (CLUTTER_TYPE_ANIMATION_MODE,
name,
&res))
return res;
g_warning ("Unable to find the animation mode '%s'", name);
}
return CLUTTER_CUSTOM_MODE;
}
static ClutterAlphaFunc
resolve_alpha_func (const gchar *name)
{
static GModule *module = NULL;
ClutterAlphaFunc func;
CLUTTER_NOTE (SCRIPT, "Looking up '%s' alpha function", name);
if (G_UNLIKELY (!module))
module = g_module_open (NULL, 0);
if (g_module_symbol (module, name, (gpointer) &func))
{
CLUTTER_NOTE (SCRIPT, "Found '%s' alpha function in the symbols table",
name);
return func;
}
return NULL;
}
GObject *
_clutter_script_parse_alpha (ClutterScript *script,
JsonNode *node)
{
GObject *retval = NULL;
JsonObject *object;
ClutterTimeline *timeline = NULL;
ClutterAlphaFunc alpha_func = NULL;
ClutterAnimationMode mode = CLUTTER_CUSTOM_MODE;
JsonNode *val;
gboolean unref_timeline = FALSE;
if (JSON_NODE_TYPE (node) != JSON_NODE_OBJECT)
return NULL;
object = json_node_get_object (node);
val = json_object_get_member (object, "timeline");
if (val)
{
if (JSON_NODE_TYPE (val) == JSON_NODE_VALUE &&
json_node_get_string (val) != NULL)
{
const gchar *id_ = json_node_get_string (val);
timeline =
CLUTTER_TIMELINE (clutter_script_get_object (script, id_));
}
else if (JSON_NODE_TYPE (val) == JSON_NODE_OBJECT)
{
timeline = construct_timeline (script, json_node_get_object (val));
unref_timeline = TRUE;
}
}
val = json_object_get_member (object, "mode");
if (val != NULL)
mode = _clutter_script_resolve_animation_mode (val);
if (mode == CLUTTER_CUSTOM_MODE)
{
val = json_object_get_member (object, "function");
if (val && json_node_get_string (val) != NULL)
{
alpha_func = resolve_alpha_func (json_node_get_string (val));
if (!alpha_func)
{
g_warning ("Unable to find the function '%s' in the "
"Clutter alpha functions or the symbols table",
json_node_get_string (val));
}
}
}
CLUTTER_NOTE (SCRIPT, "Parsed alpha: %s timeline (%p) (mode:%d, func:%p)",
unref_timeline ? "implicit" : "explicit",
timeline ? timeline : 0x0,
mode != CLUTTER_CUSTOM_MODE ? mode : 0,
alpha_func ? alpha_func : 0x0);
retval = g_object_new (CLUTTER_TYPE_ALPHA, NULL);
if (mode != CLUTTER_CUSTOM_MODE)
clutter_alpha_set_mode (CLUTTER_ALPHA (retval), mode);
if (alpha_func != NULL)
clutter_alpha_set_func (CLUTTER_ALPHA (retval), alpha_func, NULL, NULL);
clutter_alpha_set_timeline (CLUTTER_ALPHA (retval), timeline);
/* if we created an implicit timeline, the Alpha has full ownership
* of it now, since it won't be accessible from ClutterScript
*/
if (unref_timeline)
g_object_unref (timeline);
return retval;
}
static void
clutter_script_parser_object_end (JsonParser *json_parser,
JsonObject *object)
@ -1750,7 +1523,7 @@ clutter_script_construct_parameters (ClutterScript *script,
continue;
}
if (!(pspec->flags & G_PARAM_CONSTRUCT_ONLY))
if (!(pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)))
{
unparsed = g_list_prepend (unparsed, pinfo);
continue;

View File

@ -110,8 +110,6 @@ gboolean _clutter_script_parse_node (ClutterScript *script,
GType _clutter_script_get_type_from_symbol (const gchar *symbol);
GType _clutter_script_get_type_from_class (const gchar *name);
gulong _clutter_script_resolve_animation_mode (JsonNode *node);
gboolean _clutter_script_enum_from_string (GType gtype,
const gchar *string,
gint *enum_value);
@ -128,8 +126,6 @@ gboolean _clutter_script_parse_rect (ClutterScript *script,
gboolean _clutter_script_parse_color (ClutterScript *script,
JsonNode *node,
ClutterColor *color);
GObject *_clutter_script_parse_alpha (ClutterScript *script,
JsonNode *node);
gboolean _clutter_script_parse_point (ClutterScript *script,
JsonNode *node,
graphene_point_t *point);

View File

@ -98,49 +98,6 @@
* respectively) and the "object" string member for calling
* g_signal_connect_object() instead of g_signal_connect().
*
* Signals can also be directly attached to a specific state defined
* inside a #ClutterState instance, for instance:
*
* |[
* ...
* "signals" : [
* {
* "name" : "enter-event",
* "states" : "button-states",
* "target-state" : "hover"
* },
* {
* "name" : "leave-event",
* "states" : "button-states",
* "target-state" : "base"
* },
* {
* "name" : "button-press-event",
* "states" : "button-states",
* "target-state" : "active",
* },
* {
* "name" : "key-press-event",
* "states" : "button-states",
* "target-state" : "key-focus",
* "warp" : true
* }
* ],
* ...
* ]|
*
* The "states" key defines the #ClutterState instance to be used to
* resolve the "target-state" key; it can be either a script id for a
* #ClutterState built by the same #ClutterScript instance, or to a
* #ClutterState built in code and associated to the #ClutterScript
* instance through the clutter_script_add_states() function. If no
* "states" key is present, then the default #ClutterState associated to
* the #ClutterScript instance will be used; the default #ClutterState
* can be set using clutter_script_add_states() using a %NULL name. The
* "warp" key can be used to warp to a specific state instead of
* animating to it. State changes on signal emission will not affect
* the signal emission chain.
*
* Clutter reserves the following names, so classes defining properties
* through the usual GObject registration process should avoid using these
* names to avoid collisions:
@ -184,9 +141,7 @@
#include "clutter-private.h"
#include "clutter-debug.h"
#include "deprecated/clutter-alpha.h"
#include "deprecated/clutter-container.h"
#include "deprecated/clutter-state.h"
enum
{
@ -210,8 +165,6 @@ struct _ClutterScriptPrivate
ClutterScriptParser *parser;
GHashTable *states;
gchar **search_paths;
gchar *translation_domain;
@ -264,7 +217,6 @@ signal_info_free (gpointer data)
g_free (sinfo->name);
g_free (sinfo->handler);
g_free (sinfo->object);
g_free (sinfo->state);
g_free (sinfo->target);
g_slice_free (SignalInfo, sinfo);
@ -319,7 +271,6 @@ clutter_script_finalize (GObject *gobject)
g_hash_table_destroy (priv->objects);
g_strfreev (priv->search_paths);
g_free (priv->filename);
g_hash_table_destroy (priv->states);
g_free (priv->translation_domain);
G_OBJECT_CLASS (clutter_script_parent_class)->finalize (gobject);
@ -454,9 +405,6 @@ clutter_script_init (ClutterScript *script)
priv->objects = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL,
object_info_free);
priv->states = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free,
(GDestroyNotify) g_object_unref);
}
/**
@ -972,65 +920,12 @@ clutter_script_connect_signals (ClutterScript *script,
g_free (cd);
}
typedef struct {
ClutterState *state;
GObject *emitter;
gchar *target;
gulong signal_id;
gulong hook_id;
gboolean warp_to;
} HookData;
typedef struct {
ClutterScript *script;
ClutterScriptConnectFunc func;
gpointer user_data;
} SignalConnectData;
static void
hook_data_free (gpointer data)
{
if (G_LIKELY (data != NULL))
{
HookData *hook_data = data;
g_free (hook_data->target);
g_slice_free (HookData, hook_data);
}
}
static gboolean
clutter_script_state_change_hook (GSignalInvocationHint *ihint,
guint n_params,
const GValue *params,
gpointer user_data)
{
HookData *hook_data = user_data;
GObject *emitter;
emitter = g_value_get_object (&params[0]);
if (emitter == hook_data->emitter)
{
if (hook_data->warp_to)
clutter_state_warp_to_state (hook_data->state, hook_data->target);
else
clutter_state_set_state (hook_data->state, hook_data->target);
}
return TRUE;
}
static void
clutter_script_remove_state_change_hook (gpointer user_data,
GObject *object_p)
{
HookData *hook_data = user_data;
g_signal_remove_emission_hook (hook_data->signal_id,
hook_data->hook_id);
}
static void
connect_each_object (gpointer key,
gpointer value,
@ -1070,64 +965,7 @@ connect_each_object (gpointer key,
}
else
{
GObject *state_object = NULL;
const gchar *signal_name, *signal_detail;
gchar **components;
GQuark signal_quark;
guint signal_id;
HookData *hook_data;
if (sinfo->state == NULL)
state_object = (GObject *) clutter_script_get_states (script, NULL);
else
{
state_object = clutter_script_get_object (script, sinfo->state);
if (state_object == NULL)
state_object = (GObject *) clutter_script_get_states (script, sinfo->state);
}
if (state_object == NULL)
continue;
components = g_strsplit (sinfo->name, "::", 2);
if (g_strv_length (components) == 2)
{
signal_name = components[0];
signal_detail = components[1];
}
else
{
signal_name = components[0];
signal_detail = NULL;
}
signal_id = g_signal_lookup (signal_name, G_OBJECT_TYPE (object));
if (signal_id == 0)
{
g_strfreev (components);
continue;
}
if (signal_detail != NULL)
signal_quark = g_quark_from_string (signal_detail);
else
signal_quark = 0;
hook_data = g_slice_new (HookData);
hook_data->emitter = object;
hook_data->state = CLUTTER_STATE (state_object);
hook_data->target = g_strdup (sinfo->target);
hook_data->warp_to = sinfo->warp_to;
hook_data->signal_id = signal_id;
hook_data->hook_id =
g_signal_add_emission_hook (signal_id, signal_quark,
clutter_script_state_change_hook,
hook_data,
hook_data_free);
g_object_weak_ref (hook_data->emitter,
clutter_script_remove_state_change_hook,
hook_data);
g_warn_if_reached ();
}
signal_info_free (sinfo);
@ -1352,72 +1190,6 @@ clutter_script_list_objects (ClutterScript *script)
return retval;
}
/**
* clutter_script_add_states:
* @script: a #ClutterScript
* @name: (allow-none): a name for the @state, or %NULL to
* set the default #ClutterState
* @state: a #ClutterState
*
* Associates a #ClutterState to the #ClutterScript instance using the given
* name.
*
* The #ClutterScript instance will use @state to resolve target states when
* connecting signal handlers.
*
* The #ClutterScript instance will take a reference on the #ClutterState
* passed to this function.
*
* Since: 1.8
*
* Deprecated: 1.12
*/
void
clutter_script_add_states (ClutterScript *script,
const gchar *name,
ClutterState *state)
{
g_return_if_fail (CLUTTER_IS_SCRIPT (script));
g_return_if_fail (CLUTTER_IS_STATE (state));
if (name == NULL || *name == '\0')
name = "__clutter_script_default_state";
g_hash_table_replace (script->priv->states,
g_strdup (name),
g_object_ref (state));
}
/**
* clutter_script_get_states:
* @script: a #ClutterScript
* @name: (allow-none): the name of the #ClutterState, or %NULL
*
* Retrieves the #ClutterState for the given @state_name.
*
* If @name is %NULL, this function will return the default
* #ClutterState instance.
*
* Return value: (transfer none): a pointer to the #ClutterState for the
* given name. The #ClutterState is owned by the #ClutterScript instance
* and it should not be unreferenced
*
* Since: 1.8
*
* Deprecated: 1.12
*/
ClutterState *
clutter_script_get_states (ClutterScript *script,
const gchar *name)
{
g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), NULL);
if (name == NULL || *name == '\0')
name = "__clutter_script_default_state";
return g_hash_table_lookup (script->priv->states, name);
}
/**
* clutter_script_set_translation_domain:
* @script: a #ClutterScript

View File

@ -179,15 +179,6 @@ void clutter_script_unmerge_objects (ClutterScript
CLUTTER_EXPORT
void clutter_script_ensure_objects (ClutterScript *script);
CLUTTER_DEPRECATED
void clutter_script_add_states (ClutterScript *script,
const gchar *name,
ClutterState *state);
CLUTTER_DEPRECATED
ClutterState * clutter_script_get_states (ClutterScript *script,
const gchar *name);
CLUTTER_EXPORT
void clutter_script_connect_signals (ClutterScript *script,
gpointer user_data);

View File

@ -682,7 +682,6 @@ clutter_seat_warp_pointer (ClutterSeat *seat,
* requirements are fulfilled:
*
* - A touchscreen is available
* - No external keyboard is attached to the device
* - A tablet mode switch, if present, is enabled
*
* Returns: %TRUE if the device is a tablet that doesn't have an external

View File

@ -50,11 +50,6 @@ ClutterStageWindow *_clutter_stage_get_window (ClutterStage
void _clutter_stage_get_projection_matrix (ClutterStage *stage,
CoglMatrix *projection);
void _clutter_stage_dirty_projection (ClutterStage *stage);
void _clutter_stage_set_viewport (ClutterStage *stage,
float x,
float y,
float width,
float height);
void _clutter_stage_get_viewport (ClutterStage *stage,
float *x,
float *y,
@ -74,7 +69,6 @@ void _clutter_stage_queue_event (ClutterStage *stage,
gboolean _clutter_stage_has_queued_events (ClutterStage *stage);
void _clutter_stage_process_queued_events (ClutterStage *stage);
void _clutter_stage_update_input_devices (ClutterStage *stage);
void _clutter_stage_schedule_update (ClutterStage *stage);
gint64 _clutter_stage_get_update_time (ClutterStage *stage);
void _clutter_stage_clear_update_time (ClutterStage *stage);
gboolean _clutter_stage_has_full_redraw_queued (ClutterStage *stage);
@ -131,9 +125,6 @@ gboolean _clutter_stage_update_state (ClutterStage *stag
void _clutter_stage_set_scale_factor (ClutterStage *stage,
int factor);
gboolean _clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage *stage,
graphene_rect_t *rect,
float *view_scale);
void _clutter_stage_presented (ClutterStage *stage,
CoglFrameEvent frame_event,
@ -142,6 +133,9 @@ void _clutter_stage_presented (ClutterStage *stag
void clutter_stage_queue_actor_relayout (ClutterStage *stage,
ClutterActor *actor);
GList * clutter_stage_get_views_for_rect (ClutterStage *stage,
const graphene_rect_t *rect);
G_END_DECLS
#endif /* __CLUTTER_STAGE_PRIVATE_H__ */

View File

@ -20,17 +20,28 @@
#include "clutter/clutter-stage-view.h"
void clutter_stage_view_after_paint (ClutterStageView *view);
void clutter_stage_view_after_paint (ClutterStageView *view,
cairo_region_t *redraw_clip);
void clutter_stage_view_before_swap_buffer (ClutterStageView *view,
const cairo_region_t *swap_region);
gboolean clutter_stage_view_is_dirty_viewport (ClutterStageView *view);
void clutter_stage_view_set_dirty_viewport (ClutterStageView *view,
gboolean dirty);
void clutter_stage_view_invalidate_viewport (ClutterStageView *view);
void clutter_stage_view_set_viewport (ClutterStageView *view,
float x,
float y,
float width,
float height);
gboolean clutter_stage_view_is_dirty_projection (ClutterStageView *view);
void clutter_stage_view_set_dirty_projection (ClutterStageView *view,
gboolean dirty);
void clutter_stage_view_invalidate_projection (ClutterStageView *view);
void clutter_stage_view_set_projection (ClutterStageView *view,
const CoglMatrix *matrix);
void clutter_stage_view_add_redraw_clip (ClutterStageView *view,
const cairo_rectangle_int_t *clip);
@ -45,4 +56,10 @@ cairo_region_t * clutter_stage_view_take_redraw_clip (ClutterStageView *view);
CoglScanout * clutter_stage_view_take_scanout (ClutterStageView *view);
void clutter_stage_view_transform_rect_to_onscreen (ClutterStageView *view,
const cairo_rectangle_int_t *src_rect,
int dst_width,
int dst_height,
cairo_rectangle_int_t *dst_rect);
#endif /* __CLUTTER_STAGE_VIEW_PRIVATE_H__ */

View File

@ -23,6 +23,7 @@
#include <cairo-gobject.h>
#include <math.h>
#include "clutter/clutter-damage-history.h"
#include "clutter/clutter-private.h"
#include "clutter/clutter-mutter.h"
#include "cogl/cogl.h"
@ -31,10 +32,11 @@ enum
{
PROP_0,
PROP_NAME,
PROP_LAYOUT,
PROP_FRAMEBUFFER,
PROP_OFFSCREEN,
PROP_SHADOWFB,
PROP_USE_SHADOWFB,
PROP_SCALE,
PROP_LAST
@ -44,6 +46,8 @@ static GParamSpec *obj_props[PROP_LAST];
typedef struct _ClutterStageViewPrivate
{
char *name;
cairo_rectangle_int_t layout;
float scale;
CoglFramebuffer *framebuffer;
@ -51,8 +55,16 @@ typedef struct _ClutterStageViewPrivate
CoglOffscreen *offscreen;
CoglPipeline *offscreen_pipeline;
CoglOffscreen *shadowfb;
CoglPipeline *shadowfb_pipeline;
gboolean use_shadowfb;
struct {
struct {
CoglDmaBufHandle *handles[2];
int current_idx;
ClutterDamageHistory *damage_history;
} dma_buf;
CoglOffscreen *framebuffer;
} shadow;
CoglScanout *next_scanout;
@ -91,8 +103,8 @@ clutter_stage_view_get_framebuffer (ClutterStageView *view)
if (priv->offscreen)
return priv->offscreen;
else if (priv->shadowfb)
return priv->shadowfb;
else if (priv->shadow.framebuffer)
return priv->shadow.framebuffer;
else
return priv->framebuffer;
}
@ -152,19 +164,6 @@ clutter_stage_view_ensure_offscreen_blit_pipeline (ClutterStageView *view)
view_class->setup_offscreen_blit_pipeline (view, priv->offscreen_pipeline);
}
static void
clutter_stage_view_ensure_shadowfb_blit_pipeline (ClutterStageView *view)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
if (priv->shadowfb_pipeline)
return;
priv->shadowfb_pipeline =
clutter_stage_view_create_framebuffer_pipeline (priv->shadowfb);
}
void
clutter_stage_view_invalidate_offscreen_blit_pipeline (ClutterStageView *view)
{
@ -174,85 +173,563 @@ clutter_stage_view_invalidate_offscreen_blit_pipeline (ClutterStageView *view)
g_clear_pointer (&priv->offscreen_pipeline, cogl_object_unref);
}
void
clutter_stage_view_transform_rect_to_onscreen (ClutterStageView *view,
const cairo_rectangle_int_t *src_rect,
int dst_width,
int dst_height,
cairo_rectangle_int_t *dst_rect)
{
ClutterStageViewClass *view_class = CLUTTER_STAGE_VIEW_GET_CLASS (view);
return view_class->transform_rect_to_onscreen (view,
src_rect,
dst_width,
dst_height,
dst_rect);
}
static void
clutter_stage_view_copy_to_framebuffer (ClutterStageView *view,
CoglPipeline *pipeline,
CoglFramebuffer *src_framebuffer,
CoglFramebuffer *dst_framebuffer,
gboolean can_blit)
paint_transformed_framebuffer (ClutterStageView *view,
CoglPipeline *pipeline,
CoglFramebuffer *src_framebuffer,
CoglFramebuffer *dst_framebuffer,
const cairo_region_t *redraw_clip)
{
CoglMatrix matrix;
unsigned int n_rectangles, i;
int dst_width, dst_height;
cairo_rectangle_int_t view_layout;
cairo_rectangle_int_t onscreen_layout;
float view_scale;
float *coordinates;
/* First, try with blit */
if (can_blit)
{
if (cogl_blit_framebuffer (src_framebuffer,
dst_framebuffer,
0, 0,
0, 0,
cogl_framebuffer_get_width (dst_framebuffer),
cogl_framebuffer_get_height (dst_framebuffer),
NULL))
return;
}
dst_width = cogl_framebuffer_get_width (dst_framebuffer);
dst_height = cogl_framebuffer_get_height (dst_framebuffer);
clutter_stage_view_get_layout (view, &view_layout);
clutter_stage_view_transform_rect_to_onscreen (view,
&(cairo_rectangle_int_t) {
.width = view_layout.width,
.height = view_layout.height,
},
view_layout.width,
view_layout.height,
&onscreen_layout);
view_scale = clutter_stage_view_get_scale (view);
/* If blit fails, fallback to the slower painting method */
cogl_framebuffer_push_matrix (dst_framebuffer);
cogl_matrix_init_identity (&matrix);
cogl_matrix_translate (&matrix, -1, 1, 0);
cogl_matrix_scale (&matrix, 2, -2, 0);
cogl_matrix_scale (&matrix,
1.0 / (dst_width / 2.0),
-1.0 / (dst_height / 2.0), 0);
cogl_matrix_translate (&matrix,
-(dst_width / 2.0),
-(dst_height / 2.0), 0);
cogl_framebuffer_set_projection_matrix (dst_framebuffer, &matrix);
cogl_framebuffer_set_viewport (dst_framebuffer,
0, 0, dst_width, dst_height);
cogl_framebuffer_draw_rectangle (dst_framebuffer,
pipeline,
0, 0, 1, 1);
n_rectangles = cairo_region_num_rectangles (redraw_clip);
coordinates = g_newa (float, 2 * 4 * n_rectangles);
for (i = 0; i < n_rectangles; i++)
{
cairo_rectangle_int_t src_rect;
cairo_rectangle_int_t dst_rect;
cairo_region_get_rectangle (redraw_clip, i, &src_rect);
_clutter_util_rectangle_offset (&src_rect,
-view_layout.x,
-view_layout.y,
&src_rect);
clutter_stage_view_transform_rect_to_onscreen (view,
&src_rect,
onscreen_layout.width,
onscreen_layout.height,
&dst_rect);
coordinates[i * 8 + 0] = (float) dst_rect.x * view_scale;
coordinates[i * 8 + 1] = (float) dst_rect.y * view_scale;
coordinates[i * 8 + 2] = ((float) (dst_rect.x + dst_rect.width) *
view_scale);
coordinates[i * 8 + 3] = ((float) (dst_rect.y + dst_rect.height) *
view_scale);
coordinates[i * 8 + 4] = (((float) dst_rect.x / (float) dst_width) *
view_scale);
coordinates[i * 8 + 5] = (((float) dst_rect.y / (float) dst_height) *
view_scale);
coordinates[i * 8 + 6] = ((float) (dst_rect.x + dst_rect.width) /
(float) dst_width) * view_scale;
coordinates[i * 8 + 7] = ((float) (dst_rect.y + dst_rect.height) /
(float) dst_height) * view_scale;
}
cogl_framebuffer_draw_textured_rectangles (dst_framebuffer,
pipeline,
coordinates,
n_rectangles);
cogl_framebuffer_pop_matrix (dst_framebuffer);
}
static gboolean
is_shadowfb_double_buffered (ClutterStageView *view)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
return priv->shadow.dma_buf.handles[0] && priv->shadow.dma_buf.handles[1];
}
static gboolean
init_dma_buf_shadowfbs (ClutterStageView *view,
CoglContext *cogl_context,
int width,
int height,
GError **error)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
CoglRenderer *cogl_renderer = cogl_context_get_renderer (cogl_context);
CoglFramebuffer *initial_shadowfb;
if (!cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"Buffer age not supported");
return FALSE;
}
if (!cogl_is_onscreen (priv->framebuffer))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"Tried to use shadow buffer without onscreen");
return FALSE;
}
priv->shadow.dma_buf.handles[0] = cogl_renderer_create_dma_buf (cogl_renderer,
width, height,
error);
if (!priv->shadow.dma_buf.handles[0])
return FALSE;
priv->shadow.dma_buf.handles[1] = cogl_renderer_create_dma_buf (cogl_renderer,
width, height,
error);
if (!priv->shadow.dma_buf.handles[1])
{
g_clear_pointer (&priv->shadow.dma_buf.handles[0],
cogl_dma_buf_handle_free);
return FALSE;
}
priv->shadow.dma_buf.damage_history = clutter_damage_history_new ();
initial_shadowfb =
cogl_dma_buf_handle_get_framebuffer (priv->shadow.dma_buf.handles[0]);
priv->shadow.framebuffer = cogl_object_ref (initial_shadowfb);
return TRUE;
}
static CoglOffscreen *
create_offscreen_framebuffer (CoglContext *context,
int width,
int height,
GError **error)
{
CoglOffscreen *framebuffer;
CoglTexture2D *texture;
texture = cogl_texture_2d_new_with_size (context, width, height);
cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (texture),
FALSE);
if (!cogl_texture_allocate (COGL_TEXTURE (texture), error))
{
cogl_object_unref (texture);
return FALSE;
}
framebuffer = cogl_offscreen_new_with_texture (COGL_TEXTURE (texture));
cogl_object_unref (texture);
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (framebuffer), error))
{
cogl_object_unref (framebuffer);
return FALSE;
}
return framebuffer;
}
static gboolean
init_fallback_shadowfb (ClutterStageView *view,
CoglContext *cogl_context,
int width,
int height,
GError **error)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
CoglOffscreen *offscreen;
offscreen = create_offscreen_framebuffer (cogl_context, width, height, error);
if (!offscreen)
return FALSE;
priv->shadow.framebuffer = offscreen;
return TRUE;
}
static void
init_shadowfb (ClutterStageView *view)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
g_autoptr (GError) error = NULL;
int width;
int height;
CoglContext *cogl_context;
width = cogl_framebuffer_get_width (priv->framebuffer);
height = cogl_framebuffer_get_height (priv->framebuffer);
cogl_context = cogl_framebuffer_get_context (priv->framebuffer);
if (init_dma_buf_shadowfbs (view, cogl_context, width, height, &error))
{
g_message ("Initialized double buffered shadow fb for %s", priv->name);
return;
}
g_warning ("Failed to initialize double buffered shadow fb for %s: %s",
priv->name, error->message);
g_clear_error (&error);
if (!init_fallback_shadowfb (view, cogl_context, width, height, &error))
{
g_warning ("Failed to initialize single buffered shadow fb for %s: %s",
priv->name, error->message);
}
else
{
g_message ("Initialized single buffered shadow fb for %s", priv->name);
}
}
void
clutter_stage_view_after_paint (ClutterStageView *view)
clutter_stage_view_after_paint (ClutterStageView *view,
cairo_region_t *redraw_clip)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
if (priv->offscreen)
{
gboolean can_blit;
CoglMatrix matrix;
clutter_stage_view_ensure_offscreen_blit_pipeline (view);
clutter_stage_view_get_offscreen_transformation_matrix (view, &matrix);
can_blit = cogl_matrix_is_identity (&matrix);
if (priv->shadowfb)
if (priv->shadow.framebuffer)
{
clutter_stage_view_copy_to_framebuffer (view,
priv->offscreen_pipeline,
priv->offscreen,
priv->shadowfb,
can_blit);
paint_transformed_framebuffer (view,
priv->offscreen_pipeline,
priv->offscreen,
priv->shadow.framebuffer,
redraw_clip);
}
else
{
clutter_stage_view_copy_to_framebuffer (view,
priv->offscreen_pipeline,
priv->offscreen,
priv->framebuffer,
can_blit);
paint_transformed_framebuffer (view,
priv->offscreen_pipeline,
priv->offscreen,
priv->framebuffer,
redraw_clip);
}
}
}
static gboolean
is_tile_dirty (cairo_rectangle_int_t *tile,
uint8_t *current_data,
uint8_t *prev_data,
int bpp,
int stride)
{
int y;
for (y = tile->y; y < tile->y + tile->height; y++)
{
if (memcmp (prev_data + y * stride + tile->x * bpp,
current_data + y * stride + tile->x * bpp,
tile->width * bpp) != 0)
return TRUE;
}
return FALSE;
}
static int
flip_dma_buf_idx (int idx)
{
return (idx + 1) % 2;
}
static cairo_region_t *
find_damaged_tiles (ClutterStageView *view,
const cairo_region_t *damage_region,
GError **error)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
cairo_region_t *tile_damage_region;
cairo_rectangle_int_t damage_extents;
cairo_rectangle_int_t fb_rect;
int prev_dma_buf_idx;
CoglDmaBufHandle *prev_dma_buf_handle;
uint8_t *prev_data;
int current_dma_buf_idx;
CoglDmaBufHandle *current_dma_buf_handle;
uint8_t *current_data;
int width, height, stride, bpp;
int tile_x_min, tile_x_max;
int tile_y_min, tile_y_max;
int tile_x, tile_y;
const int tile_size = 16;
prev_dma_buf_idx = flip_dma_buf_idx (priv->shadow.dma_buf.current_idx);
prev_dma_buf_handle = priv->shadow.dma_buf.handles[prev_dma_buf_idx];
current_dma_buf_idx = priv->shadow.dma_buf.current_idx;
current_dma_buf_handle = priv->shadow.dma_buf.handles[current_dma_buf_idx];
width = cogl_dma_buf_handle_get_width (current_dma_buf_handle);
height = cogl_dma_buf_handle_get_height (current_dma_buf_handle);
stride = cogl_dma_buf_handle_get_stride (current_dma_buf_handle);
bpp = cogl_dma_buf_handle_get_bpp (current_dma_buf_handle);
cogl_framebuffer_finish (priv->shadow.framebuffer);
if (!cogl_dma_buf_handle_sync_read_start (prev_dma_buf_handle, error))
return NULL;
if (!cogl_dma_buf_handle_sync_read_start (current_dma_buf_handle, error))
goto err_sync_read_current;
prev_data = cogl_dma_buf_handle_mmap (prev_dma_buf_handle, error);
if (!prev_data)
goto err_mmap_prev;
current_data = cogl_dma_buf_handle_mmap (current_dma_buf_handle, error);
if (!current_data)
goto err_mmap_current;
fb_rect = (cairo_rectangle_int_t) {
.width = width,
.height = height,
};
cairo_region_get_extents (damage_region, &damage_extents);
tile_x_min = damage_extents.x / tile_size;
tile_x_max = ((damage_extents.x + damage_extents.width + tile_size - 1) /
tile_size);
tile_y_min = damage_extents.y / tile_size;
tile_y_max = ((damage_extents.y + damage_extents.height + tile_size - 1) /
tile_size);
tile_damage_region = cairo_region_create ();
for (tile_y = tile_y_min; tile_y <= tile_y_max; tile_y++)
{
for (tile_x = tile_x_min; tile_x <= tile_x_max; tile_x++)
{
cairo_rectangle_int_t tile = {
.x = tile_x * tile_size,
.y = tile_y * tile_size,
.width = tile_size,
.height = tile_size,
};
if (cairo_region_contains_rectangle (damage_region, &tile) ==
CAIRO_REGION_OVERLAP_OUT)
continue;
_clutter_util_rectangle_intersection (&tile, &fb_rect, &tile);
if (is_tile_dirty (&tile, current_data, prev_data, bpp, stride))
cairo_region_union_rectangle (tile_damage_region, &tile);
}
}
if (priv->shadowfb)
if (!cogl_dma_buf_handle_sync_read_end (prev_dma_buf_handle, error))
{
clutter_stage_view_ensure_shadowfb_blit_pipeline (view);
clutter_stage_view_copy_to_framebuffer (view,
priv->shadowfb_pipeline,
priv->shadowfb,
priv->framebuffer,
TRUE);
g_warning ("Failed to end DMA buffer read synchronization: %s",
(*error)->message);
g_clear_error (error);
}
if (!cogl_dma_buf_handle_sync_read_end (current_dma_buf_handle, error))
{
g_warning ("Failed to end DMA buffer read synchronization: %s",
(*error)->message);
g_clear_error (error);
}
cogl_dma_buf_handle_munmap (prev_dma_buf_handle, prev_data, NULL);
cogl_dma_buf_handle_munmap (current_dma_buf_handle, current_data, NULL);
cairo_region_intersect (tile_damage_region, damage_region);
return tile_damage_region;
err_mmap_current:
cogl_dma_buf_handle_munmap (prev_dma_buf_handle, prev_data, NULL);
err_mmap_prev:
cogl_dma_buf_handle_sync_read_end (current_dma_buf_handle, NULL);
err_sync_read_current:
cogl_dma_buf_handle_sync_read_end (prev_dma_buf_handle, NULL);
return NULL;
}
static void
swap_dma_buf_framebuffer (ClutterStageView *view)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
int next_idx;
CoglDmaBufHandle *next_dma_buf_handle;
CoglOffscreen *next_framebuffer;
next_idx = ((priv->shadow.dma_buf.current_idx + 1) %
G_N_ELEMENTS (priv->shadow.dma_buf.handles));
priv->shadow.dma_buf.current_idx = next_idx;
next_dma_buf_handle = priv->shadow.dma_buf.handles[next_idx];
next_framebuffer =
cogl_dma_buf_handle_get_framebuffer (next_dma_buf_handle);
cogl_clear_object (&priv->shadow.framebuffer);
priv->shadow.framebuffer = cogl_object_ref (next_framebuffer);
}
static void
copy_shadowfb_to_onscreen (ClutterStageView *view,
const cairo_region_t *swap_region)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
ClutterDamageHistory *damage_history = priv->shadow.dma_buf.damage_history;
cairo_region_t *damage_region;
int age;
int i;
if (cairo_region_is_empty (swap_region))
{
cairo_rectangle_int_t full_damage = {
.width = cogl_framebuffer_get_width (priv->framebuffer),
.height = cogl_framebuffer_get_height (priv->framebuffer),
};
damage_region = cairo_region_create_rectangle (&full_damage);
}
else
{
damage_region = cairo_region_copy (swap_region);
}
if (is_shadowfb_double_buffered (view))
{
CoglOnscreen *onscreen = COGL_ONSCREEN (priv->framebuffer);
cairo_region_t *changed_region;
if (cogl_onscreen_get_frame_counter (onscreen) >= 1)
{
g_autoptr (GError) error = NULL;
changed_region = find_damaged_tiles (view, damage_region, &error);
if (!changed_region)
{
int other_dma_buf_idx;
g_warning ("Disabling actual damage detection: %s",
error->message);
other_dma_buf_idx =
flip_dma_buf_idx (priv->shadow.dma_buf.current_idx);
g_clear_pointer (&priv->shadow.dma_buf.handles[other_dma_buf_idx],
cogl_dma_buf_handle_free);
}
}
else
{
changed_region = cairo_region_copy (damage_region);
}
if (changed_region)
{
int buffer_age;
clutter_damage_history_record (damage_history, changed_region);
buffer_age = cogl_onscreen_get_buffer_age (onscreen);
if (clutter_damage_history_is_age_valid (damage_history, buffer_age))
{
for (age = 1; age <= buffer_age; age++)
{
const cairo_region_t *old_damage;
old_damage = clutter_damage_history_lookup (damage_history, age);
cairo_region_union (changed_region, old_damage);
}
cairo_region_destroy (damage_region);
damage_region = g_steal_pointer (&changed_region);
}
else
{
cairo_region_destroy (changed_region);
}
clutter_damage_history_step (damage_history);
}
}
for (i = 0; i < cairo_region_num_rectangles (damage_region); i++)
{
g_autoptr (GError) error = NULL;
cairo_rectangle_int_t rect;
cairo_region_get_rectangle (damage_region, i, &rect);
if (!cogl_blit_framebuffer (priv->shadow.framebuffer,
priv->framebuffer,
rect.x, rect.y,
rect.x, rect.y,
rect.width, rect.height,
&error))
{
g_warning ("Failed to blit shadow buffer: %s", error->message);
cairo_region_destroy (damage_region);
return;
}
}
cairo_region_destroy (damage_region);
if (is_shadowfb_double_buffered (view))
swap_dma_buf_framebuffer (view);
}
void
clutter_stage_view_before_swap_buffer (ClutterStageView *view,
const cairo_region_t *swap_region)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
if (priv->shadow.framebuffer)
copy_shadowfb_to_onscreen (view, swap_region);
}
float
@ -264,6 +741,47 @@ clutter_stage_view_get_scale (ClutterStageView *view)
return priv->scale;
}
typedef void (*FrontBufferCallback) (CoglFramebuffer *framebuffer,
gconstpointer user_data);
static void
clutter_stage_view_foreach_front_buffer (ClutterStageView *view,
FrontBufferCallback callback,
gconstpointer user_data)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
if (priv->offscreen)
{
callback (priv->offscreen, user_data);
}
else if (priv->shadow.framebuffer)
{
if (is_shadowfb_double_buffered (view))
{
int i;
for (i = 0; i < G_N_ELEMENTS (priv->shadow.dma_buf.handles); i++)
{
CoglDmaBufHandle *handle = priv->shadow.dma_buf.handles[i];
CoglFramebuffer *framebuffer =
cogl_dma_buf_handle_get_framebuffer (handle);
callback (framebuffer, user_data);
}
}
else
{
callback (priv->shadow.framebuffer, user_data);
}
}
else
{
callback (priv->framebuffer, user_data);
}
}
gboolean
clutter_stage_view_is_dirty_viewport (ClutterStageView *view)
{
@ -274,13 +792,47 @@ clutter_stage_view_is_dirty_viewport (ClutterStageView *view)
}
void
clutter_stage_view_set_dirty_viewport (ClutterStageView *view,
gboolean dirty)
clutter_stage_view_invalidate_viewport (ClutterStageView *view)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
priv->dirty_viewport = dirty;
priv->dirty_viewport = TRUE;
}
static void
set_framebuffer_viewport (CoglFramebuffer *framebuffer,
gconstpointer user_data)
{
const graphene_rect_t *rect = user_data;
cogl_framebuffer_set_viewport (framebuffer,
rect->origin.x,
rect->origin.y,
rect->size.width,
rect->size.height);
}
void
clutter_stage_view_set_viewport (ClutterStageView *view,
float x,
float y,
float width,
float height)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
graphene_rect_t rect;
priv->dirty_viewport = FALSE;
rect = (graphene_rect_t) {
.origin = { .x = x, .y = y },
.size = { .width = width, .height = height },
};
clutter_stage_view_foreach_front_buffer (view,
set_framebuffer_viewport,
&rect);
}
gboolean
@ -292,14 +844,33 @@ clutter_stage_view_is_dirty_projection (ClutterStageView *view)
return priv->dirty_projection;
}
static void
set_framebuffer_projection_matrix (CoglFramebuffer *framebuffer,
gconstpointer user_data)
{
cogl_framebuffer_set_projection_matrix (framebuffer, user_data);
}
void
clutter_stage_view_set_dirty_projection (ClutterStageView *view,
gboolean dirty)
clutter_stage_view_invalidate_projection (ClutterStageView *view)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
priv->dirty_projection = dirty;
priv->dirty_projection = TRUE;
}
void
clutter_stage_view_set_projection (ClutterStageView *view,
const CoglMatrix *matrix)
{
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
priv->dirty_projection = FALSE;
clutter_stage_view_foreach_front_buffer (view,
set_framebuffer_projection_matrix,
matrix);
}
void
@ -391,19 +962,6 @@ clutter_stage_view_take_redraw_clip (ClutterStageView *view)
return g_steal_pointer (&priv->redraw_clip);
}
void
clutter_stage_view_transform_to_onscreen (ClutterStageView *view,
gfloat *x,
gfloat *y)
{
gfloat z = 0, w = 1;
CoglMatrix matrix;
clutter_stage_view_get_offscreen_transformation_matrix (view, &matrix);
cogl_matrix_get_inverse (&matrix, &matrix);
cogl_matrix_transform_point (&matrix, x, y, &z, &w);
}
static void
clutter_stage_default_get_offscreen_transformation_matrix (ClutterStageView *view,
CoglMatrix *matrix)
@ -442,6 +1000,9 @@ clutter_stage_view_get_property (GObject *object,
switch (prop_id)
{
case PROP_NAME:
g_value_set_string (value, priv->name);
break;
case PROP_LAYOUT:
g_value_set_boxed (value, &priv->layout);
break;
@ -451,8 +1012,8 @@ clutter_stage_view_get_property (GObject *object,
case PROP_OFFSCREEN:
g_value_set_boxed (value, priv->offscreen);
break;
case PROP_SHADOWFB:
g_value_set_boxed (value, priv->shadowfb);
case PROP_USE_SHADOWFB:
g_value_set_boolean (value, priv->use_shadowfb);
break;
case PROP_SCALE:
g_value_set_float (value, priv->scale);
@ -475,6 +1036,9 @@ clutter_stage_view_set_property (GObject *object,
switch (prop_id)
{
case PROP_NAME:
priv->name = g_value_dup_string (value);
break;
case PROP_LAYOUT:
layout = g_value_get_boxed (value);
priv->layout = *layout;
@ -499,8 +1063,8 @@ clutter_stage_view_set_property (GObject *object,
case PROP_OFFSCREEN:
priv->offscreen = g_value_dup_boxed (value);
break;
case PROP_SHADOWFB:
priv->shadowfb = g_value_dup_boxed (value);
case PROP_USE_SHADOWFB:
priv->use_shadowfb = g_value_get_boolean (value);
break;
case PROP_SCALE:
priv->scale = g_value_get_float (value);
@ -511,17 +1075,40 @@ clutter_stage_view_set_property (GObject *object,
}
static void
clutter_stage_view_dispose (GObject *object)
clutter_stage_view_constructed (GObject *object)
{
ClutterStageView *view = CLUTTER_STAGE_VIEW (object);
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
if (priv->use_shadowfb)
init_shadowfb (view);
G_OBJECT_CLASS (clutter_stage_view_parent_class)->constructed (object);
}
static void
clutter_stage_view_dispose (GObject *object)
{
ClutterStageView *view = CLUTTER_STAGE_VIEW (object);
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
int i;
g_clear_pointer (&priv->name, g_free);
g_clear_pointer (&priv->framebuffer, cogl_object_unref);
g_clear_pointer (&priv->shadowfb, cogl_object_unref);
g_clear_pointer (&priv->shadow.framebuffer, cogl_object_unref);
for (i = 0; i < G_N_ELEMENTS (priv->shadow.dma_buf.handles); i++)
{
g_clear_pointer (&priv->shadow.dma_buf.handles[i],
cogl_dma_buf_handle_free);
}
g_clear_pointer (&priv->shadow.dma_buf.damage_history,
clutter_damage_history_free);
g_clear_pointer (&priv->offscreen, cogl_object_unref);
g_clear_pointer (&priv->offscreen_pipeline, cogl_object_unref);
g_clear_pointer (&priv->shadowfb_pipeline, cogl_object_unref);
g_clear_pointer (&priv->redraw_clip, cairo_region_destroy);
G_OBJECT_CLASS (clutter_stage_view_parent_class)->dispose (object);
@ -548,8 +1135,17 @@ clutter_stage_view_class_init (ClutterStageViewClass *klass)
object_class->get_property = clutter_stage_view_get_property;
object_class->set_property = clutter_stage_view_set_property;
object_class->constructed = clutter_stage_view_constructed;
object_class->dispose = clutter_stage_view_dispose;
obj_props[PROP_NAME] =
g_param_spec_string ("name",
"Name",
"Name of view",
NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
obj_props[PROP_LAYOUT] =
g_param_spec_boxed ("layout",
"View layout",
@ -577,14 +1173,14 @@ clutter_stage_view_class_init (ClutterStageViewClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
obj_props[PROP_SHADOWFB] =
g_param_spec_boxed ("shadowfb",
"Shadow framebuffer",
"Framebuffer used as intermediate shadow buffer",
COGL_TYPE_HANDLE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
obj_props[PROP_USE_SHADOWFB] =
g_param_spec_boolean ("use-shadowfb",
"Use shadowfb",
"Whether to use one or more shadow framebuffers",
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
obj_props[PROP_SCALE] =
g_param_spec_float ("scale",

View File

@ -43,6 +43,12 @@ struct _ClutterStageViewClass
void (* get_offscreen_transformation_matrix) (ClutterStageView *view,
CoglMatrix *matrix);
void (* transform_rect_to_onscreen) (ClutterStageView *view,
const cairo_rectangle_int_t *src_rect,
int dst_width,
int dst_height,
cairo_rectangle_int_t *dst_rect);
};
CLUTTER_EXPORT
@ -56,11 +62,6 @@ CoglFramebuffer *clutter_stage_view_get_onscreen (ClutterStageView *view);
CLUTTER_EXPORT
void clutter_stage_view_invalidate_offscreen_blit_pipeline (ClutterStageView *view);
CLUTTER_EXPORT
void clutter_stage_view_transform_to_onscreen (ClutterStageView *view,
gfloat *x,
gfloat *y);
CLUTTER_EXPORT
float clutter_stage_view_get_scale (ClutterStageView *view);

View File

@ -142,6 +142,8 @@ struct _ClutterStagePrivate
int update_freeze_count;
gboolean needs_update;
guint redraw_pending : 1;
guint throttle_motion_events : 1;
guint min_size_changed : 1;
@ -187,6 +189,9 @@ static void capture_view_into (ClutterStage *stage,
uint8_t *data,
int stride);
static void clutter_stage_update_view_perspective (ClutterStage *stage);
static void clutter_stage_set_viewport (ClutterStage *stage,
float width,
float height);
static void clutter_container_iface_init (ClutterContainerIface *iface);
@ -613,23 +618,18 @@ stage_is_default (ClutterStage *stage)
static void
clutter_stage_allocate (ClutterActor *self,
const ClutterActorBox *box,
ClutterAllocationFlags flags)
const ClutterActorBox *box)
{
ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
ClutterActorBox alloc = CLUTTER_ACTOR_BOX_INIT_ZERO;
float old_width, old_height;
float new_width, new_height;
float width, height;
cairo_rectangle_int_t window_size;
ClutterLayoutManager *layout_manager = clutter_actor_get_layout_manager (self);
if (priv->impl == NULL)
return;
/* our old allocation */
clutter_actor_get_allocation_box (self, &alloc);
clutter_actor_box_get_size (&alloc, &old_width, &old_height);
/* the current allocation */
clutter_actor_box_get_size (box, &width, &height);
@ -643,15 +643,21 @@ clutter_stage_allocate (ClutterActor *self,
*/
if (!clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC))
{
CLUTTER_NOTE (LAYOUT,
"Following allocation to %.2fx%.2f (absolute origin %s)",
width, height,
(flags & CLUTTER_ABSOLUTE_ORIGIN_CHANGED)
? "changed"
: "not changed");
ClutterActorBox children_box;
clutter_actor_set_allocation (self, box,
flags | CLUTTER_DELEGATE_LAYOUT);
children_box.x1 = children_box.y1 = 0.f;
children_box.x2 = box->x2 - box->x1;
children_box.y2 = box->y2 - box->y1;
CLUTTER_NOTE (LAYOUT,
"Following allocation to %.2fx%.2f",
width, height);
clutter_actor_set_allocation (self, box);
clutter_layout_manager_allocate (layout_manager,
CLUTTER_CONTAINER (self),
&children_box);
/* Ensure the window is sized correctly */
if (priv->min_size_changed)
@ -699,39 +705,23 @@ clutter_stage_allocate (ClutterActor *self,
CLUTTER_NOTE (LAYOUT,
"Overriding original allocation of %.2fx%.2f "
"with %.2fx%.2f (absolute origin %s)",
"with %.2fx%.2f",
width, height,
override.x2, override.y2,
(flags & CLUTTER_ABSOLUTE_ORIGIN_CHANGED)
? "changed"
: "not changed");
override.x2, override.y2);
/* and store the overridden allocation */
clutter_actor_set_allocation (self, &override,
flags | CLUTTER_DELEGATE_LAYOUT);
clutter_actor_set_allocation (self, &override);
clutter_layout_manager_allocate (layout_manager,
CLUTTER_CONTAINER (self),
&override);
}
/* reset the viewport if the allocation effectively changed */
/* set the viewport to the new allocation */
clutter_actor_get_allocation_box (self, &alloc);
clutter_actor_box_get_size (&alloc, &new_width, &new_height);
if (CLUTTER_NEARBYINT (old_width) != CLUTTER_NEARBYINT (new_width) ||
CLUTTER_NEARBYINT (old_height) != CLUTTER_NEARBYINT (new_height))
{
int real_width = CLUTTER_NEARBYINT (new_width);
int real_height = CLUTTER_NEARBYINT (new_height);
_clutter_stage_set_viewport (CLUTTER_STAGE (self),
0, 0,
real_width,
real_height);
/* Note: we don't assume that set_viewport will queue a full redraw
* since it may bail-out early if something preemptively set the
* viewport before the stage was really allocated its new size.
*/
queue_full_redraw (CLUTTER_STAGE (self));
}
clutter_stage_set_viewport (CLUTTER_STAGE (self), new_width, new_height);
}
typedef struct _Vector4
@ -1081,6 +1071,7 @@ clutter_stage_hide (ClutterActor *self)
ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
g_assert (priv->impl != NULL);
_clutter_stage_clear_pick_stack (CLUTTER_STAGE (self));
_clutter_stage_window_hide (priv->impl);
CLUTTER_ACTOR_CLASS (clutter_stage_parent_class)->hide (self);
@ -1170,7 +1161,7 @@ _clutter_stage_queue_event (ClutterStage *stage,
{
ClutterMasterClock *master_clock = _clutter_master_clock_get_default ();
_clutter_master_clock_start_running (master_clock);
_clutter_stage_schedule_update (stage);
clutter_stage_schedule_update (stage);
}
}
@ -1302,7 +1293,9 @@ _clutter_stage_needs_update (ClutterStage *stage)
priv = stage->priv;
return priv->redraw_pending || g_hash_table_size (priv->pending_relayouts) > 0;
return (priv->redraw_pending ||
priv->needs_update ||
g_hash_table_size (priv->pending_relayouts) > 0);
}
void
@ -1312,7 +1305,7 @@ clutter_stage_queue_actor_relayout (ClutterStage *stage,
ClutterStagePrivate *priv = stage->priv;
if (g_hash_table_size (priv->pending_relayouts) == 0)
_clutter_stage_schedule_update (stage);
clutter_stage_schedule_update (stage);
g_hash_table_add (priv->pending_relayouts, g_object_ref (actor));
priv->pending_relayouts_version++;
@ -1359,8 +1352,7 @@ _clutter_stage_maybe_relayout (ClutterActor *actor)
CLUTTER_SET_PRIVATE_FLAGS (queued_actor, CLUTTER_IN_RELAYOUT);
old_version = priv->pending_relayouts_version;
clutter_actor_allocate_preferred_size (queued_actor,
CLUTTER_ALLOCATION_NONE);
clutter_actor_allocate_preferred_size (queued_actor);
CLUTTER_UNSET_PRIVATE_FLAGS (queued_actor, CLUTTER_IN_RELAYOUT);
@ -1477,6 +1469,14 @@ _clutter_stage_check_updated_pointers (ClutterStage *stage)
return updating;
}
static void
update_actor_stage_views (ClutterStage *stage)
{
ClutterActor *actor = CLUTTER_ACTOR (stage);
clutter_actor_update_stage_views (actor);
}
/**
* _clutter_stage_do_update:
* @stage: A #ClutterStage
@ -1494,6 +1494,8 @@ _clutter_stage_do_update (ClutterStage *stage)
priv->stage_was_relayout = FALSE;
priv->needs_update = FALSE;
/* if the stage is being destroyed, or if the destruction already
* happened and we don't have an StageWindow any more, then we
* should bail out
@ -1522,6 +1524,10 @@ _clutter_stage_do_update (ClutterStage *stage)
if (stage_was_relayout)
pointers = _clutter_stage_check_updated_pointers (stage);
COGL_TRACE_BEGIN (ClutterStageUpdateActorStageViews, "Actor stage-views");
update_actor_stage_views (stage);
COGL_TRACE_END (ClutterStageUpdateActorStageViews);
COGL_TRACE_BEGIN (ClutterStagePaint, "Paint");
clutter_stage_maybe_finish_queue_redraws (stage);
@ -2246,10 +2252,7 @@ clutter_stage_init (ClutterStage *self)
g_signal_connect (self, "notify::min-height",
G_CALLBACK (clutter_stage_notify_min_size), NULL);
_clutter_stage_set_viewport (self,
0, 0,
geom.width,
geom.height);
clutter_stage_set_viewport (self, geom.width, geom.height);
priv->paint_volume_stack =
g_array_new (FALSE, FALSE, sizeof (ClutterPaintVolume));
@ -2429,15 +2432,13 @@ _clutter_stage_dirty_projection (ClutterStage *stage)
{
ClutterStageView *view = l->data;
clutter_stage_view_set_dirty_projection (view, TRUE);
clutter_stage_view_invalidate_projection (view);
}
}
/*
* clutter_stage_set_viewport:
* @stage: A #ClutterStage
* @x: The X postition to render the stage at, in window coordinates
* @y: The Y position to render the stage at, in window coordinates
* @width: The width to render the stage at, in window coordinates
* @height: The height to render the stage at, in window coordinates
*
@ -2470,19 +2471,22 @@ _clutter_stage_dirty_projection (ClutterStage *stage)
*
* Since: 1.6
*/
void
_clutter_stage_set_viewport (ClutterStage *stage,
float x,
float y,
float width,
float height)
static void
clutter_stage_set_viewport (ClutterStage *stage,
float width,
float height)
{
ClutterStagePrivate *priv;
float x, y;
g_return_if_fail (CLUTTER_IS_STAGE (stage));
priv = stage->priv;
x = 0.f;
y = 0.f;
width = roundf (width);
height = roundf (height);
if (x == priv->viewport[0] &&
y == priv->viewport[1] &&
@ -2519,7 +2523,7 @@ _clutter_stage_dirty_viewport (ClutterStage *stage)
{
ClutterStageView *view = l->data;
clutter_stage_view_set_dirty_viewport (view, TRUE);
clutter_stage_view_invalidate_viewport (view);
}
}
@ -3142,7 +3146,6 @@ _clutter_stage_maybe_setup_viewport (ClutterStage *stage,
ClutterStageView *view)
{
ClutterStagePrivate *priv = stage->priv;
CoglFramebuffer *fb = clutter_stage_view_get_framebuffer (view);
if (clutter_stage_view_is_dirty_viewport (view))
{
@ -3169,54 +3172,18 @@ _clutter_stage_maybe_setup_viewport (ClutterStage *stage,
viewport_y = roundf (priv->viewport[1] * fb_scale - viewport_offset_y);
viewport_width = roundf (priv->viewport[2] * fb_scale);
viewport_height = roundf (priv->viewport[3] * fb_scale);
cogl_framebuffer_set_viewport (fb,
viewport_x, viewport_y,
viewport_width, viewport_height);
clutter_stage_view_set_dirty_viewport (view, FALSE);
clutter_stage_view_set_viewport (view,
viewport_x, viewport_y,
viewport_width, viewport_height);
}
if (clutter_stage_view_is_dirty_projection (view))
{
cogl_framebuffer_set_projection_matrix (fb, &priv->projection);
clutter_stage_view_set_dirty_projection (view, FALSE);
}
clutter_stage_view_set_projection (view, &priv->projection);
}
#undef _DEG_TO_RAD
/**
* clutter_stage_ensure_redraw:
* @stage: a #ClutterStage
*
* Ensures that @stage is redrawn
*
* This function should not be called by applications: it is
* used when embedding a #ClutterStage into a toolkit with
* another windowing system, like GTK+.
*
* Since: 1.0
*/
void
clutter_stage_ensure_redraw (ClutterStage *stage)
{
ClutterMasterClock *master_clock;
ClutterStagePrivate *priv;
g_return_if_fail (CLUTTER_IS_STAGE (stage));
priv = stage->priv;
if (!_clutter_stage_needs_update (stage))
_clutter_stage_schedule_update (stage);
priv->redraw_pending = TRUE;
master_clock = _clutter_master_clock_get_default ();
_clutter_master_clock_start_running (master_clock);
}
/**
* clutter_stage_is_redraw_queued: (skip)
*/
@ -3437,13 +3404,13 @@ clutter_stage_get_minimum_size (ClutterStage *stage,
}
/**
* _clutter_stage_schedule_update:
* @window: a #ClutterStage actor
* clutter_stage_schedule_update:
* @stage: a #ClutterStage actor
*
* Schedules a redraw of the #ClutterStage at the next optimal timestamp.
*/
void
_clutter_stage_schedule_update (ClutterStage *stage)
clutter_stage_schedule_update (ClutterStage *stage)
{
ClutterStageWindow *stage_window;
@ -3454,6 +3421,8 @@ _clutter_stage_schedule_update (ClutterStage *stage)
if (stage_window == NULL)
return;
stage->priv->needs_update = TRUE;
return _clutter_stage_window_schedule_update (stage_window,
stage->priv->sync_delay);
}
@ -3463,7 +3432,7 @@ _clutter_stage_schedule_update (ClutterStage *stage)
* @stage: a #ClutterStage actor
*
* Returns the earliest time in which the stage is ready to update. The update
* time is set when _clutter_stage_schedule_update() is called. This can then
* time is set when clutter_stage_schedule_update() is called. This can then
* be used by e.g. the #ClutterMasterClock to know when the stage needs to be
* redrawn.
*
@ -3573,7 +3542,7 @@ _clutter_stage_queue_actor_redraw (ClutterStage *stage,
CLUTTER_NOTE (PAINT, "First redraw request");
_clutter_stage_schedule_update (stage);
clutter_stage_schedule_update (stage);
priv->redraw_pending = TRUE;
master_clock = _clutter_master_clock_get_default ();
@ -4120,20 +4089,29 @@ clutter_stage_get_capture_final_size (ClutterStage *stage,
int *out_height,
float *out_scale)
{
float max_scale;
float max_scale = 1.0;
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
if (rect)
{
graphene_rect_t capture_rect;
g_autoptr (GList) views = NULL;
GList *l;
_clutter_util_rect_from_rectangle (rect, &capture_rect);
if (!_clutter_stage_get_max_view_scale_factor_for_rect (stage,
&capture_rect,
&max_scale))
views = clutter_stage_get_views_for_rect (stage, &capture_rect);
if (!views)
return FALSE;
for (l = views; l; l = l->next)
{
ClutterStageView *view = l->data;
max_scale = MAX (clutter_stage_view_get_scale (view), max_scale);
}
if (out_width)
*out_width = (gint) roundf (rect->width * max_scale);
@ -4414,18 +4392,17 @@ clutter_stage_peek_stage_views (ClutterStage *stage)
}
void
clutter_stage_update_resource_scales (ClutterStage *stage)
clutter_stage_clear_stage_views (ClutterStage *stage)
{
_clutter_actor_queue_update_resource_scale_recursive (CLUTTER_ACTOR (stage));
clutter_actor_clear_stage_views_recursive (CLUTTER_ACTOR (stage));
}
gboolean
_clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage *stage,
graphene_rect_t *rect,
float *view_scale)
GList *
clutter_stage_get_views_for_rect (ClutterStage *stage,
const graphene_rect_t *rect)
{
ClutterStagePrivate *priv = stage->priv;
float scale = 0.0f;
GList *views_for_rect = NULL;
GList *l;
for (l = _clutter_stage_window_get_views (priv->impl); l; l = l->next)
@ -4438,12 +4415,8 @@ _clutter_stage_get_max_view_scale_factor_for_rect (ClutterStage *stage,
_clutter_util_rect_from_rectangle (&view_layout, &view_rect);
if (graphene_rect_intersection (&view_rect, rect, NULL))
scale = MAX (clutter_stage_view_get_scale (view), scale);
views_for_rect = g_list_prepend (views_for_rect, view);
}
if (scale == 0.0)
return FALSE;
*view_scale = scale;
return TRUE;
return views_for_rect;
}

View File

@ -195,8 +195,6 @@ guchar * clutter_stage_read_pixels (ClutterStage
CLUTTER_EXPORT
void clutter_stage_ensure_viewport (ClutterStage *stage);
CLUTTER_EXPORT
void clutter_stage_ensure_redraw (ClutterStage *stage);
CLUTTER_EXPORT
gboolean clutter_stage_is_redraw_queued (ClutterStage *stage);
@ -209,6 +207,9 @@ CLUTTER_EXPORT
void clutter_stage_skip_sync_delay (ClutterStage *stage);
#endif
CLUTTER_EXPORT
void clutter_stage_schedule_update (ClutterStage *stage);
CLUTTER_EXPORT
gboolean clutter_stage_get_capture_final_size (ClutterStage *stage,
cairo_rectangle_int_t *rect,

View File

@ -3037,8 +3037,7 @@ clutter_text_get_preferred_height (ClutterActor *self,
static void
clutter_text_allocate (ClutterActor *self,
const ClutterActorBox *box,
ClutterAllocationFlags flags)
const ClutterActorBox *box)
{
ClutterText *text = CLUTTER_TEXT (self);
ClutterActorClass *parent_class;
@ -3058,7 +3057,7 @@ clutter_text_allocate (ClutterActor *self,
box->y2 - box->y1);
parent_class = CLUTTER_ACTOR_CLASS (clutter_text_parent_class);
parent_class->allocate (self, box, flags);
parent_class->allocate (self, box);
}
static gboolean
@ -4787,11 +4786,11 @@ clutter_text_queue_redraw_or_relayout (ClutterText *self)
clutter_text_get_preferred_height (actor, preferred_width, NULL, &preferred_height);
if (clutter_actor_has_allocation (actor) &&
(fabsf (preferred_width - clutter_actor_get_width (actor)) > 0.001 ||
fabsf (preferred_height - clutter_actor_get_height (actor)) > 0.001))
clutter_actor_queue_relayout (actor);
else
fabsf (preferred_width - clutter_actor_get_width (actor)) <= 0.001 &&
fabsf (preferred_height - clutter_actor_get_height (actor)) <= 0.001)
clutter_text_queue_redraw (actor);
else
clutter_actor_queue_relayout (actor);
}
static void

View File

@ -24,7 +24,6 @@
/**
* SECTION:clutter-timeline
* @short_description: A class for time-based events
* @see_also: #ClutterAnimation, #ClutterAnimator, #ClutterState
*
* #ClutterTimeline is a base class for managing time-based event that cause
* Clutter to redraw a stage, such as animations.
@ -71,7 +70,7 @@
* when reaching completion by using the #ClutterTimeline:auto-reverse property.
*
* Timelines are used in the Clutter animation framework by classes like
* #ClutterAnimation, #ClutterAnimator, and #ClutterState.
* #ClutterTransition.
*
* ## Defining Timelines in ClutterScript
*
@ -173,7 +172,6 @@ enum
{
PROP_0,
PROP_LOOP,
PROP_DELAY,
PROP_DURATION,
PROP_DIRECTION,
@ -291,23 +289,6 @@ clutter_timeline_add_marker_internal (ClutterTimeline *timeline,
g_hash_table_insert (priv->markers_by_name, marker->name, marker);
}
static inline void
clutter_timeline_set_loop_internal (ClutterTimeline *timeline,
gboolean loop)
{
gint old_repeat_count;
old_repeat_count = timeline->priv->repeat_count;
if (loop)
clutter_timeline_set_repeat_count (timeline, -1);
else
clutter_timeline_set_repeat_count (timeline, 0);
if (old_repeat_count != timeline->priv->repeat_count)
g_object_notify_by_pspec (G_OBJECT (timeline), obj_props[PROP_LOOP]);
}
/* Scriptable */
typedef struct _ParseClosure {
ClutterTimeline *timeline;
@ -449,10 +430,6 @@ clutter_timeline_set_property (GObject *object,
switch (prop_id)
{
case PROP_LOOP:
clutter_timeline_set_loop_internal (timeline, g_value_get_boolean (value));
break;
case PROP_DELAY:
clutter_timeline_set_delay (timeline, g_value_get_uint (value));
break;
@ -494,10 +471,6 @@ clutter_timeline_get_property (GObject *object,
switch (prop_id)
{
case PROP_LOOP:
g_value_set_boolean (value, priv->repeat_count != 0);
break;
case PROP_DELAY:
g_value_set_uint (value, priv->delay);
break;
@ -573,25 +546,6 @@ clutter_timeline_class_init (ClutterTimelineClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
/**
* ClutterTimeline:loop:
*
* Whether the timeline should automatically rewind and restart.
*
* As a side effect, setting this property to %TRUE will set the
* #ClutterTimeline:repeat-count property to -1, while setting this
* property to %FALSE will set the #ClutterTimeline:repeat-count
* property to 0.
*
* Deprecated: 1.10: Use the #ClutterTimeline:repeat-count property instead.
*/
obj_props[PROP_LOOP] =
g_param_spec_boolean ("loop",
P_("Loop"),
P_("Should the timeline automatically restart"),
FALSE,
CLUTTER_PARAM_READWRITE | G_PARAM_DEPRECATED);
/**
* ClutterTimeline:delay:
*
@ -1252,45 +1206,6 @@ clutter_timeline_stop (ClutterTimeline *timeline)
g_signal_emit (timeline, timeline_signals[STOPPED], 0, FALSE);
}
/**
* clutter_timeline_set_loop:
* @timeline: a #ClutterTimeline
* @loop: %TRUE for enable looping
*
* Sets whether @timeline should loop.
*
* This function is equivalent to calling clutter_timeline_set_repeat_count()
* with -1 if @loop is %TRUE, and with 0 if @loop is %FALSE.
*
* Deprecated: 1.10: Use clutter_timeline_set_repeat_count() instead.
*/
void
clutter_timeline_set_loop (ClutterTimeline *timeline,
gboolean loop)
{
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
clutter_timeline_set_loop_internal (timeline, loop);
}
/**
* clutter_timeline_get_loop:
* @timeline: a #ClutterTimeline
*
* Gets whether @timeline is looping
*
* Return value: %TRUE if the timeline is looping
*
* Deprecated: 1.10: Use clutter_timeline_get_repeat_count() instead.
*/
gboolean
clutter_timeline_get_loop (ClutterTimeline *timeline)
{
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), FALSE);
return timeline->priv->repeat_count != 0;
}
/**
* clutter_timeline_rewind:
* @timeline: A #ClutterTimeline
@ -1406,49 +1321,11 @@ clutter_timeline_is_playing (ClutterTimeline *timeline)
return timeline->priv->is_playing;
}
/**
* clutter_timeline_clone:
* @timeline: #ClutterTimeline to duplicate.
*
* Create a new #ClutterTimeline instance which has property values
* matching that of supplied timeline. The cloned timeline will not
* be started and will not be positioned to the current position of
* the original @timeline: you will have to start it with
* clutter_timeline_start().
*
* The only cloned properties are:
*
* - #ClutterTimeline:duration
* - #ClutterTimeline:loop
* - #ClutterTimeline:delay
* - #ClutterTimeline:direction
*
* Return value: (transfer full): a new #ClutterTimeline, cloned
* from @timeline
*
* Since: 0.4
*
* Deprecated: 1.10: Use clutter_timeline_new() or g_object_new()
* instead
*/
ClutterTimeline *
clutter_timeline_clone (ClutterTimeline *timeline)
{
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), NULL);
return g_object_new (CLUTTER_TYPE_TIMELINE,
"duration", timeline->priv->duration,
"loop", timeline->priv->repeat_count != 0,
"delay", timeline->priv->delay,
"direction", timeline->priv->direction,
NULL);
}
/**
* clutter_timeline_new:
* @msecs: Duration of the timeline in milliseconds
* @duration_ms: Duration of the timeline in milliseconds
*
* Creates a new #ClutterTimeline with a duration of @msecs.
* Creates a new #ClutterTimeline with a duration of @duration_ms milli seconds.
*
* Return value: the newly created #ClutterTimeline instance. Use
* g_object_unref() when done using it
@ -1456,10 +1333,10 @@ clutter_timeline_clone (ClutterTimeline *timeline)
* Since: 0.6
*/
ClutterTimeline *
clutter_timeline_new (guint msecs)
clutter_timeline_new (guint duration_ms)
{
return g_object_new (CLUTTER_TYPE_TIMELINE,
"duration", msecs,
"duration", duration_ms,
NULL);
}

View File

@ -119,7 +119,7 @@ CLUTTER_EXPORT
GType clutter_timeline_get_type (void) G_GNUC_CONST;
CLUTTER_EXPORT
ClutterTimeline * clutter_timeline_new (guint msecs);
ClutterTimeline * clutter_timeline_new (guint duration_ms);
CLUTTER_EXPORT
guint clutter_timeline_get_duration (ClutterTimeline *timeline);

View File

@ -79,10 +79,6 @@ typedef struct _ClutterKnot ClutterKnot;
typedef struct _ClutterMargin ClutterMargin;
typedef struct _ClutterPerspective ClutterPerspective;
typedef struct _ClutterAlpha ClutterAlpha;
typedef struct _ClutterAnimation ClutterAnimation;
typedef struct _ClutterState ClutterState;
typedef struct _ClutterInputDeviceTool ClutterInputDeviceTool;
typedef struct _ClutterInputDevice ClutterInputDevice;
typedef struct _ClutterVirtualInputDevice ClutterVirtualInputDevice;

View File

@ -38,6 +38,7 @@
#include "clutter-actor-private.h"
#include "clutter-backend-private.h"
#include "clutter-damage-history.h"
#include "clutter-debug.h"
#include "clutter-event.h"
#include "clutter-enum-types.h"
@ -51,13 +52,9 @@
typedef struct _ClutterStageViewCoglPrivate
{
/*
* List of previous damaged areas in stage view framebuffer coordinate space.
/* Damage history, in stage view render target framebuffer coordinate space.
*/
#define DAMAGE_HISTORY_MAX 16
#define DAMAGE_HISTORY(x) ((x) & (DAMAGE_HISTORY_MAX - 1))
cairo_region_t * damage_history[DAMAGE_HISTORY_MAX];
unsigned int damage_index;
ClutterDamageHistory *damage_history;
} ClutterStageViewCoglPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (ClutterStageViewCogl, clutter_stage_view_cogl,
@ -288,26 +285,13 @@ clutter_stage_cogl_resize (ClutterStageWindow *stage_window,
{
}
static inline gboolean
valid_buffer_age (ClutterStageViewCogl *view_cogl,
int age)
{
ClutterStageViewCoglPrivate *view_priv =
clutter_stage_view_cogl_get_instance_private (view_cogl);
if (age <= 0)
return FALSE;
return age < MIN (view_priv->damage_index, DAMAGE_HISTORY_MAX);
}
static void
paint_damage_region (ClutterStageWindow *stage_window,
ClutterStageView *view,
cairo_region_t *swap_region,
cairo_region_t *queued_redraw_clip)
{
CoglFramebuffer *framebuffer = clutter_stage_view_get_onscreen (view);
CoglFramebuffer *framebuffer = clutter_stage_view_get_framebuffer (view);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
static CoglPipeline *overlay_blue = NULL;
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
@ -378,24 +362,26 @@ swap_framebuffer (ClutterStageWindow *stage_window,
gboolean swap_with_damage)
{
CoglFramebuffer *framebuffer = clutter_stage_view_get_onscreen (view);
int *damage, n_rects, i;
n_rects = cairo_region_num_rectangles (swap_region);
damage = g_newa (int, n_rects * 4);
for (i = 0; i < n_rects; i++)
{
cairo_rectangle_int_t rect;
cairo_region_get_rectangle (swap_region, i, &rect);
damage[i * 4] = rect.x;
damage[i * 4 + 1] = rect.y;
damage[i * 4 + 2] = rect.width;
damage[i * 4 + 3] = rect.height;
}
clutter_stage_view_before_swap_buffer (view, swap_region);
if (cogl_is_onscreen (framebuffer))
{
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
int *damage, n_rects, i;
n_rects = cairo_region_num_rectangles (swap_region);
damage = g_newa (int, n_rects * 4);
for (i = 0; i < n_rects; i++)
{
cairo_rectangle_int_t rect;
cairo_region_get_rectangle (swap_region, i, &rect);
damage[i * 4] = rect.x;
damage[i * 4 + 1] = rect.y;
damage[i * 4 + 2] = rect.width;
damage[i * 4 + 3] = rect.height;
}
/* push on the screen */
if (n_rects > 0 && !swap_with_damage)
@ -430,18 +416,6 @@ swap_framebuffer (ClutterStageWindow *stage_window,
}
}
static void
scale_and_clamp_rect (const graphene_rect_t *rect,
float scale,
cairo_rectangle_int_t *dest)
{
graphene_rect_t tmp = *rect;
graphene_rect_scale (&tmp, scale, scale, &tmp);
_clutter_util_rectangle_int_extents (&tmp, dest);
}
static cairo_region_t *
offset_scale_and_clamp_region (const cairo_region_t *region,
int offset_x,
@ -463,15 +437,52 @@ offset_scale_and_clamp_region (const cairo_region_t *region,
rects = freeme = g_new (cairo_rectangle_int_t, n_rects);
for (i = 0; i < n_rects; i++)
cairo_region_get_rectangle (region, i, &rects[i]);
{
cairo_rectangle_int_t *rect = &rects[i];
graphene_rect_t tmp;
cairo_region_get_rectangle (region, i, rect);
_clutter_util_rect_from_rectangle (rect, &tmp);
graphene_rect_offset (&tmp, offset_x, offset_y);
graphene_rect_scale (&tmp, scale, scale, &tmp);
_clutter_util_rectangle_int_extents (&tmp, rect);
}
return cairo_region_create_rectangles (rects, n_rects);
}
static cairo_region_t *
scale_offset_and_clamp_region (const cairo_region_t *region,
float scale,
int offset_x,
int offset_y)
{
int n_rects, i;
cairo_rectangle_int_t *rects;
g_autofree cairo_rectangle_int_t *freeme = NULL;
n_rects = cairo_region_num_rectangles (region);
if (n_rects == 0)
return cairo_region_create ();
if (n_rects < MAX_STACK_RECTS)
rects = g_newa (cairo_rectangle_int_t, n_rects);
else
rects = freeme = g_new (cairo_rectangle_int_t, n_rects);
for (i = 0; i < n_rects; i++)
{
cairo_rectangle_int_t *rect = &rects[i];
graphene_rect_t tmp;
_clutter_util_rect_from_rectangle (&rects[i], &tmp);
cairo_region_get_rectangle (region, i, rect);
_clutter_util_rect_from_rectangle (rect, &tmp);
graphene_rect_scale (&tmp, scale, scale, &tmp);
graphene_rect_offset (&tmp, offset_x, offset_y);
scale_and_clamp_rect (&tmp, scale, &rects[i]);
_clutter_util_rectangle_int_extents (&tmp, rect);
}
return cairo_region_create_rectangles (rects, n_rects);
@ -487,107 +498,38 @@ paint_stage (ClutterStageCogl *stage_cogl,
_clutter_stage_maybe_setup_viewport (stage, view);
clutter_stage_paint_view (stage, view, redraw_clip);
clutter_stage_view_after_paint (view);
}
static void
fill_current_damage_history (ClutterStageView *view,
cairo_region_t *damage)
{
ClutterStageViewCogl *view_cogl = CLUTTER_STAGE_VIEW_COGL (view);
ClutterStageViewCoglPrivate *view_priv =
clutter_stage_view_cogl_get_instance_private (view_cogl);
cairo_region_t **current_fb_damage;
current_fb_damage =
&view_priv->damage_history[DAMAGE_HISTORY (view_priv->damage_index)];
g_clear_pointer (current_fb_damage, cairo_region_destroy);
*current_fb_damage = cairo_region_copy (damage);
view_priv->damage_index++;
}
static void
fill_current_damage_history_rectangle (ClutterStageView *view,
const cairo_rectangle_int_t *rect)
{
cairo_region_t *damage;
damage = cairo_region_create_rectangle (rect);
fill_current_damage_history (view, damage);
cairo_region_destroy (damage);
clutter_stage_view_after_paint (view, redraw_clip);
}
static cairo_region_t *
transform_swap_region_to_onscreen (ClutterStageView *view,
cairo_region_t *swap_region)
{
CoglFramebuffer *framebuffer;
cairo_rectangle_int_t layout;
gint width, height;
CoglFramebuffer *onscreen = clutter_stage_view_get_onscreen (view);
int n_rects, i;
cairo_rectangle_int_t *rects;
cairo_region_t *transformed_region;
int width, height;
framebuffer = clutter_stage_view_get_onscreen (view);
clutter_stage_view_get_layout (view, &layout);
width = cogl_framebuffer_get_width (framebuffer);
height = cogl_framebuffer_get_height (framebuffer);
width = cogl_framebuffer_get_width (onscreen);
height = cogl_framebuffer_get_height (onscreen);
n_rects = cairo_region_num_rectangles (swap_region);
rects = g_newa (cairo_rectangle_int_t, n_rects);
for (i = 0; i < n_rects; i++)
{
gfloat x1, y1, x2, y2;
cairo_region_get_rectangle (swap_region, i, &rects[i]);
x1 = (float) rects[i].x / layout.width;
y1 = (float) rects[i].y / layout.height;
x2 = (float) (rects[i].x + rects[i].width) / layout.width;
y2 = (float) (rects[i].y + rects[i].height) / layout.height;
clutter_stage_view_transform_to_onscreen (view, &x1, &y1);
clutter_stage_view_transform_to_onscreen (view, &x2, &y2);
x1 = floor (x1 * width);
y1 = floor (height - (y1 * height));
x2 = ceil (x2 * width);
y2 = ceil (height - (y2 * height));
rects[i].x = x1;
rects[i].y = y1;
rects[i].width = x2 - x1;
rects[i].height = y2 - y1;
clutter_stage_view_transform_rect_to_onscreen (view,
&rects[i],
width,
height,
&rects[i]);
}
transformed_region = cairo_region_create_rectangles (rects, n_rects);
return transformed_region;
}
static void
calculate_scissor_region (cairo_rectangle_int_t *fb_clip_region,
int subpixel_compensation,
int fb_width,
int fb_height,
cairo_rectangle_int_t *out_scissor_rect)
{
*out_scissor_rect = *fb_clip_region;
if (subpixel_compensation == 0)
return;
if (fb_clip_region->x > 0)
out_scissor_rect->x += subpixel_compensation;
if (fb_clip_region->y > 0)
out_scissor_rect->y += subpixel_compensation;
if (fb_clip_region->x + fb_clip_region->width < fb_width)
out_scissor_rect->width -= 2 * subpixel_compensation;
if (fb_clip_region->y + fb_clip_region->height < fb_height)
out_scissor_rect->height -= 2 * subpixel_compensation;
}
static inline gboolean
is_buffer_age_enabled (void)
{
@ -606,27 +548,21 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
ClutterStageViewCoglPrivate *view_priv =
clutter_stage_view_cogl_get_instance_private (view_cogl);
CoglFramebuffer *fb = clutter_stage_view_get_framebuffer (view);
CoglFramebuffer *onscreen = clutter_stage_view_get_onscreen (view);
cairo_rectangle_int_t view_rect;
gboolean is_full_redraw;
gboolean may_use_clipped_redraw;
gboolean use_clipped_redraw;
gboolean can_blit_sub_buffer;
gboolean has_buffer_age;
gboolean do_swap_buffer;
gboolean swap_with_damage;
ClutterActor *wrapper;
cairo_region_t *redraw_clip;
cairo_region_t *queued_redraw_clip = NULL;
cairo_region_t *fb_clip_region;
cairo_region_t *swap_region;
cairo_rectangle_int_t redraw_rect;
gboolean clip_region_empty;
float fb_scale;
int subpixel_compensation = 0;
int fb_width, fb_height;
int buffer_age;
wrapper = CLUTTER_ACTOR (stage_cogl->wrapper);
gboolean res;
clutter_stage_view_get_layout (view, &view_rect);
fb_scale = clutter_stage_view_get_scale (view);
@ -634,10 +570,10 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
fb_height = cogl_framebuffer_get_height (fb);
can_blit_sub_buffer =
cogl_is_onscreen (fb) &&
cogl_is_onscreen (onscreen) &&
cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION);
has_buffer_age = cogl_is_onscreen (fb) && is_buffer_age_enabled ();
has_buffer_age = cogl_is_onscreen (onscreen) && is_buffer_age_enabled ();
redraw_clip = clutter_stage_view_take_redraw_clip (view);
if (G_UNLIKELY (clutter_paint_debug_flags & CLUTTER_DEBUG_PAINT_DAMAGE_REGION))
@ -649,51 +585,35 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
else
is_full_redraw = FALSE;
may_use_clipped_redraw =
if (has_buffer_age)
{
buffer_age = cogl_onscreen_get_buffer_age (COGL_ONSCREEN (onscreen));
if (!clutter_damage_history_is_age_valid (view_priv->damage_history,
buffer_age))
{
CLUTTER_NOTE (CLIPPING,
"Invalid back buffer(age=%d): forcing full redraw\n",
buffer_age);
use_clipped_redraw = FALSE;
}
}
use_clipped_redraw =
use_clipped_redraw &&
!(clutter_paint_debug_flags & CLUTTER_DEBUG_DISABLE_CLIPPED_REDRAWS) &&
_clutter_stage_window_can_clip_redraws (stage_window) &&
(can_blit_sub_buffer || has_buffer_age) &&
!is_full_redraw &&
/* some drivers struggle to get going and produce some junk
* frames when starting up... */
cogl_onscreen_get_frame_counter (COGL_ONSCREEN (fb)) > 3;
cogl_onscreen_get_frame_counter (COGL_ONSCREEN (onscreen)) > 3;
if (has_buffer_age)
{
buffer_age = cogl_onscreen_get_buffer_age (COGL_ONSCREEN (fb));
if (!valid_buffer_age (view_cogl, buffer_age))
{
CLUTTER_NOTE (CLIPPING, "Invalid back buffer(age=%d): forcing full redraw\n", buffer_age);
may_use_clipped_redraw = FALSE;
}
}
if (may_use_clipped_redraw)
if (use_clipped_redraw)
{
fb_clip_region = offset_scale_and_clamp_region (redraw_clip,
-view_rect.x,
-view_rect.y,
fb_scale);
if (fb_scale != floorf (fb_scale))
{
int n_rects, i;
cairo_rectangle_int_t *rects;
subpixel_compensation = ceilf (fb_scale);
n_rects = cairo_region_num_rectangles (fb_clip_region);
rects = g_newa (cairo_rectangle_int_t, n_rects);
for (i = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (fb_clip_region, i, &rects[i]);
rects[i].x -= subpixel_compensation;
rects[i].y -= subpixel_compensation;
rects[i].width += 2 * subpixel_compensation;
rects[i].height += 2 * subpixel_compensation;
}
cairo_region_destroy (fb_clip_region);
fb_clip_region = cairo_region_create_rectangles (rects, n_rects);
}
}
else
{
@ -709,46 +629,40 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
redraw_clip = cairo_region_create_rectangle (&view_rect);
}
if (may_use_clipped_redraw &&
G_LIKELY (!(clutter_paint_debug_flags & CLUTTER_DEBUG_DISABLE_CLIPPED_REDRAWS)))
use_clipped_redraw = TRUE;
else
use_clipped_redraw = FALSE;
clip_region_empty = may_use_clipped_redraw && cairo_region_is_empty (fb_clip_region);
g_return_val_if_fail (!cairo_region_is_empty (fb_clip_region), FALSE);
swap_with_damage = FALSE;
if (has_buffer_age)
{
if (use_clipped_redraw && !clip_region_empty)
clutter_damage_history_record (view_priv->damage_history,
fb_clip_region);
if (use_clipped_redraw)
{
cairo_region_t *fb_damage;
cairo_region_t *view_damage;
int i;
fill_current_damage_history (view, fb_clip_region);
int age;
fb_damage = cairo_region_create ();
for (i = 1; i <= buffer_age; i++)
for (age = 1; age <= buffer_age; age++)
{
int damage_index;
const cairo_region_t *old_damage;
damage_index = DAMAGE_HISTORY (view_priv->damage_index - i - 1);
cairo_region_union (fb_damage,
view_priv->damage_history[damage_index]);
old_damage =
clutter_damage_history_lookup (view_priv->damage_history, age);
cairo_region_union (fb_damage, old_damage);
}
/* Update the fb clip region with the extra damage. */
cairo_region_union (fb_clip_region, fb_damage);
view_damage = offset_scale_and_clamp_region (fb_damage,
0, 0,
1.0f / fb_scale);
cairo_region_translate (view_damage, view_rect.x, view_rect.y);
cairo_region_intersect_rectangle (view_damage, &view_rect);
/* Update the redraw clip with the extra damage done to the view */
view_damage = scale_offset_and_clamp_region (fb_damage,
1.0f / fb_scale,
view_rect.x,
view_rect.y);
/* Update the redraw clip region with the extra damage. */
cairo_region_union (redraw_clip, view_damage);
cairo_region_destroy (view_damage);
@ -760,55 +674,13 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
swap_with_damage = TRUE;
}
else if (!use_clipped_redraw)
{
cairo_rectangle_int_t fb_damage;
fb_damage = (cairo_rectangle_int_t) {
.x = 0,
.y = 0,
.width = ceilf (view_rect.width * fb_scale),
.height = ceilf (view_rect.height * fb_scale)
};
fill_current_damage_history_rectangle (view, &fb_damage);
}
clutter_damage_history_step (view_priv->damage_history);
}
if (use_clipped_redraw && clip_region_empty)
if (use_clipped_redraw)
{
CLUTTER_NOTE (CLIPPING, "Empty stage output paint\n");
}
else if (use_clipped_redraw)
{
cairo_rectangle_int_t clip_rect;
cairo_rectangle_int_t scissor_rect;
if (cairo_region_num_rectangles (fb_clip_region) == 1)
{
cairo_region_get_extents (fb_clip_region, &clip_rect);
calculate_scissor_region (&clip_rect,
subpixel_compensation,
fb_width, fb_height,
&scissor_rect);
CLUTTER_NOTE (CLIPPING,
"Stage clip pushed: x=%d, y=%d, width=%d, height=%d\n",
scissor_rect.x,
scissor_rect.y,
scissor_rect.width,
scissor_rect.height);
cogl_framebuffer_push_scissor_clip (fb,
scissor_rect.x,
scissor_rect.y,
scissor_rect.width,
scissor_rect.height);
}
else
{
cogl_framebuffer_push_region_clip (fb, fb_clip_region);
}
cogl_framebuffer_push_region_clip (fb, fb_clip_region);
paint_stage (stage_cogl, view, redraw_clip);
@ -818,77 +690,7 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
{
CLUTTER_NOTE (CLIPPING, "Unclipped stage paint\n");
/* If we are trying to debug redraw issues then we want to pass
* the redraw_clip so it can be visualized */
if (G_UNLIKELY (clutter_paint_debug_flags & CLUTTER_DEBUG_DISABLE_CLIPPED_REDRAWS) &&
may_use_clipped_redraw &&
!clip_region_empty)
{
cairo_rectangle_int_t clip_rect;
cairo_rectangle_int_t scissor_rect;
cairo_region_get_extents (fb_clip_region, &clip_rect);
calculate_scissor_region (&clip_rect,
subpixel_compensation,
fb_width, fb_height,
&scissor_rect);
cogl_framebuffer_push_scissor_clip (fb,
scissor_rect.x,
scissor_rect.y,
scissor_rect.width,
scissor_rect.height);
paint_stage (stage_cogl, view, redraw_clip);
cogl_framebuffer_pop_clip (fb);
}
else
{
paint_stage (stage_cogl, view, redraw_clip);
}
}
cairo_region_get_extents (redraw_clip, &redraw_rect);
if (may_use_clipped_redraw &&
G_UNLIKELY ((clutter_paint_debug_flags & CLUTTER_DEBUG_REDRAWS)))
{
CoglContext *ctx = cogl_framebuffer_get_context (fb);
static CoglPipeline *outline = NULL;
ClutterActor *actor = CLUTTER_ACTOR (wrapper);
float x_1 = redraw_rect.x;
float x_2 = redraw_rect.x + redraw_rect.width;
float y_1 = redraw_rect.y;
float y_2 = redraw_rect.y + redraw_rect.height;
CoglVertexP2 quad[4] = {
{ x_1, y_1 },
{ x_2, y_1 },
{ x_2, y_2 },
{ x_1, y_2 }
};
CoglPrimitive *prim;
CoglMatrix modelview;
if (outline == NULL)
{
outline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (outline, 0xff, 0x00, 0x00, 0xff);
}
prim = cogl_primitive_new_p2 (ctx,
COGL_VERTICES_MODE_LINE_LOOP,
4, /* n_vertices */
quad);
cogl_framebuffer_push_matrix (fb);
cogl_matrix_init_identity (&modelview);
_clutter_actor_apply_modelview_transform (actor, &modelview);
cogl_framebuffer_set_modelview_matrix (fb, &modelview);
cogl_framebuffer_draw_primitive (fb, outline, prim);
cogl_framebuffer_pop_matrix (fb);
cogl_object_unref (prim);
paint_stage (stage_cogl, view, redraw_clip);
}
/* XXX: It seems there will be a race here in that the stage
@ -900,65 +702,42 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
* artefacts.
*/
if (use_clipped_redraw)
{
if (clip_region_empty)
{
do_swap_buffer = FALSE;
}
else
{
swap_region = cairo_region_copy (fb_clip_region);
do_swap_buffer = TRUE;
}
}
swap_region = cairo_region_copy (fb_clip_region);
else
{
swap_region = cairo_region_create ();
do_swap_buffer = TRUE;
}
swap_region = cairo_region_create ();
g_clear_pointer (&redraw_clip, cairo_region_destroy);
g_clear_pointer (&fb_clip_region, cairo_region_destroy);
if (do_swap_buffer)
COGL_TRACE_BEGIN_SCOPED (ClutterStageCoglRedrawViewSwapFramebuffer,
"Paint (swap framebuffer)");
if (clutter_stage_view_get_onscreen (view) !=
clutter_stage_view_get_framebuffer (view))
{
gboolean res;
COGL_TRACE_BEGIN_SCOPED (ClutterStageCoglRedrawViewSwapFramebuffer,
"Paint (swap framebuffer)");
if (clutter_stage_view_get_onscreen (view) !=
clutter_stage_view_get_framebuffer (view))
{
cairo_region_t *transformed_swap_region;
transformed_swap_region =
transform_swap_region_to_onscreen (view, swap_region);
cairo_region_destroy (swap_region);
swap_region = transformed_swap_region;
}
if (queued_redraw_clip)
{
paint_damage_region (stage_window, view,
swap_region, queued_redraw_clip);
cairo_region_destroy (queued_redraw_clip);
}
res = swap_framebuffer (stage_window,
view,
swap_region,
swap_with_damage);
cairo_region_t *transformed_swap_region;
transformed_swap_region =
transform_swap_region_to_onscreen (view, swap_region);
cairo_region_destroy (swap_region);
swap_region = transformed_swap_region;
}
return res;
}
else
if (queued_redraw_clip)
{
g_clear_pointer (&queued_redraw_clip, cairo_region_destroy);
return FALSE;
paint_damage_region (stage_window, view,
swap_region, queued_redraw_clip);
cairo_region_destroy (queued_redraw_clip);
}
res = swap_framebuffer (stage_window,
view,
swap_region,
swap_with_damage);
cairo_region_destroy (swap_region);
return res;
}
static void
@ -1083,12 +862,31 @@ _clutter_stage_cogl_init (ClutterStageCogl *stage)
stage->update_time = -1;
}
static void
clutter_stage_view_cogl_finalize (GObject *object)
{
ClutterStageViewCogl *view_cogl = CLUTTER_STAGE_VIEW_COGL (object);
ClutterStageViewCoglPrivate *view_priv =
clutter_stage_view_cogl_get_instance_private (view_cogl);
clutter_damage_history_free (view_priv->damage_history);
G_OBJECT_CLASS (clutter_stage_view_cogl_parent_class)->finalize (object);
}
static void
clutter_stage_view_cogl_init (ClutterStageViewCogl *view_cogl)
{
ClutterStageViewCoglPrivate *view_priv =
clutter_stage_view_cogl_get_instance_private (view_cogl);
view_priv->damage_history = clutter_damage_history_new ();
}
static void
clutter_stage_view_cogl_class_init (ClutterStageViewCoglClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = clutter_stage_view_cogl_finalize;
}

View File

@ -1,819 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Authored By Matthew Allum <mallum@openedhand.com>
* Jorn Baayen <jorn@openedhand.com>
* Emmanuele Bassi <ebassi@openedhand.com>
* Tomas Frydrych <tf@openedhand.com>
*
* Copyright (C) 2006, 2007, 2008 OpenedHand
* Copyright (C) 2009, 2010 Intel Corp.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* SECTION:clutter-alpha
* @short_description: A class for calculating a value as a function of time
*
* #ClutterAlpha is a class for calculating an floating point value
* dependent only on the position of a #ClutterTimeline.
*
* For newly written code, it is recommended to use the
* #ClutterTimeline:progress-mode property of #ClutterTimeline, or the
* clutter_timeline_set_progress_func() function instead of #ClutterAlpha.
* The #ClutterAlpha class will be deprecated in the future, and will not
* be available any more in the next major version of Clutter.
*
* A #ClutterAlpha binds a #ClutterTimeline to a progress function which
* translates the time T into an adimensional factor alpha.
*
* You should provide a #ClutterTimeline and bind it to the #ClutterAlpha
* instance using clutter_alpha_set_timeline(). You should also set an
* "animation mode", by using the #ClutterAnimationMode values that
* Clutter provides.
*
* Instead of a #ClutterAnimationMode you may provide a function returning
* the alpha value depending on the progress of the timeline, using
* clutter_alpha_set_func() or clutter_alpha_set_closure(). The alpha
* function will be executed each time a new frame in the #ClutterTimeline
* is reached.
*
* Since the alpha function is controlled by the timeline instance, you can
* pause, stop or resume the #ClutterAlpha from calling the alpha function by
* using the appropriate functions of the #ClutterTimeline object.
*
* #ClutterAlpha is available since Clutter 0.2.
*
* #ClutterAlpha is deprecated since Clutter 1.12. #ClutterTimeline and
* the #ClutterTimeline:progress-mode property replace this whole class.
*
* ## ClutterAlpha custom properties for #ClutterScript
*
* #ClutterAlpha defines a custom `function` property for
* #ClutterScript which allows to reference a custom alpha function
* available in the source code. Setting the `function` property
* is equivalent to calling clutter_alpha_set_func() with the
* specified function name. No user data or #GDestroyNotify is
* available to be passed.
*
* The following JSON fragment defines a #ClutterAlpha
* using a #ClutterTimeline with id "sine-timeline" and an alpha
* function called `my_sine_alpha`.
*
* |[
* {
* "id" : "sine-alpha",
* "timeline" : {
* "id" : "sine-timeline",
* "duration" : 500,
* "loop" : true
* },
* "function" : "my_sine_alpha"
* }
* ]|
*/
#include "clutter-build-config.h"
#include <math.h>
#include <gmodule.h>
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include "clutter-alpha.h"
#include "clutter-debug.h"
#include "clutter-enum-types.h"
#include "clutter-easing.h"
#include "clutter-main.h"
#include "clutter-marshal.h"
#include "clutter-private.h"
#include "clutter-scriptable.h"
#include "clutter-script-private.h"
struct _ClutterAlphaPrivate
{
ClutterTimeline *timeline;
guint timeline_new_frame_id;
gdouble alpha;
GClosure *closure;
ClutterAlphaFunc func;
gpointer user_data;
GDestroyNotify notify;
gulong mode;
};
enum
{
PROP_0,
PROP_TIMELINE,
PROP_ALPHA,
PROP_MODE,
PROP_LAST
};
static GParamSpec *obj_props[PROP_LAST];
static void clutter_scriptable_iface_init (ClutterScriptableIface *iface);
G_DEFINE_TYPE_WITH_CODE (ClutterAlpha,
clutter_alpha,
G_TYPE_INITIALLY_UNOWNED,
G_ADD_PRIVATE (ClutterAlpha)
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_SCRIPTABLE,
clutter_scriptable_iface_init));
static void
timeline_new_frame_cb (ClutterTimeline *timeline,
guint msecs,
ClutterAlpha *alpha)
{
ClutterAlphaPrivate *priv = alpha->priv;
/* Update alpha value and notify */
priv->alpha = clutter_alpha_get_alpha (alpha);
g_object_notify_by_pspec (G_OBJECT (alpha), obj_props[PROP_ALPHA]);
}
static void
clutter_alpha_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ClutterAlpha *alpha = CLUTTER_ALPHA (object);
switch (prop_id)
{
case PROP_TIMELINE:
clutter_alpha_set_timeline (alpha, g_value_get_object (value));
break;
case PROP_MODE:
clutter_alpha_set_mode (alpha, g_value_get_ulong (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clutter_alpha_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ClutterAlphaPrivate *priv = CLUTTER_ALPHA (object)->priv;
switch (prop_id)
{
case PROP_TIMELINE:
g_value_set_object (value, priv->timeline);
break;
case PROP_ALPHA:
g_value_set_double (value, priv->alpha);
break;
case PROP_MODE:
g_value_set_ulong (value, priv->mode);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clutter_alpha_finalize (GObject *object)
{
ClutterAlphaPrivate *priv = CLUTTER_ALPHA (object)->priv;
if (priv->notify != NULL)
priv->notify (priv->user_data);
else if (priv->closure != NULL)
g_closure_unref (priv->closure);
G_OBJECT_CLASS (clutter_alpha_parent_class)->finalize (object);
}
static void
clutter_alpha_dispose (GObject *object)
{
ClutterAlpha *self = CLUTTER_ALPHA(object);
clutter_alpha_set_timeline (self, NULL);
G_OBJECT_CLASS (clutter_alpha_parent_class)->dispose (object);
}
static ClutterAlphaFunc
resolve_alpha_func (const gchar *name)
{
static GModule *module = NULL;
ClutterAlphaFunc func;
CLUTTER_NOTE (SCRIPT, "Looking up '%s' alpha function", name);
if (G_UNLIKELY (module == NULL))
module = g_module_open (NULL, 0);
if (g_module_symbol (module, name, (gpointer) &func))
{
CLUTTER_NOTE (SCRIPT, "Found '%s' alpha function in the symbols table",
name);
return func;
}
return NULL;
}
static void
clutter_alpha_set_custom_property (ClutterScriptable *scriptable,
ClutterScript *script,
const gchar *name,
const GValue *value)
{
if (strncmp (name, "function", 8) == 0)
{
g_assert (G_VALUE_HOLDS (value, G_TYPE_POINTER));
if (g_value_get_pointer (value) != NULL)
{
clutter_alpha_set_func (CLUTTER_ALPHA (scriptable),
g_value_get_pointer (value),
NULL, NULL);
}
}
else
g_object_set_property (G_OBJECT (scriptable), name, value);
}
static gboolean
clutter_alpha_parse_custom_node (ClutterScriptable *scriptable,
ClutterScript *script,
GValue *value,
const gchar *name,
JsonNode *node)
{
if (strncmp (name, "function", 8) == 0)
{
const gchar *func_name = json_node_get_string (node);
g_value_init (value, G_TYPE_POINTER);
g_value_set_pointer (value, resolve_alpha_func (func_name));
return TRUE;
}
/* we need to do this because we use gulong in place
* of ClutterAnimationMode for ClutterAlpha:mode
*/
if (strncmp (name, "mode", 4) == 0)
{
gulong mode;
mode = _clutter_script_resolve_animation_mode (node);
g_value_init (value, G_TYPE_ULONG);
g_value_set_ulong (value, mode);
return TRUE;
}
return FALSE;
}
static void
clutter_scriptable_iface_init (ClutterScriptableIface *iface)
{
iface->parse_custom_node = clutter_alpha_parse_custom_node;
iface->set_custom_property = clutter_alpha_set_custom_property;
}
static void
clutter_alpha_class_init (ClutterAlphaClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = clutter_alpha_set_property;
object_class->get_property = clutter_alpha_get_property;
object_class->finalize = clutter_alpha_finalize;
object_class->dispose = clutter_alpha_dispose;
/**
* ClutterAlpha:timeline:
*
* A #ClutterTimeline instance used to drive the alpha function.
*
* Since: 0.2
*
* Deprecated: 1.12
*/
obj_props[PROP_TIMELINE] =
g_param_spec_object ("timeline",
P_("Timeline"),
P_("Timeline used by the alpha"),
CLUTTER_TYPE_TIMELINE,
CLUTTER_PARAM_READWRITE);
/**
* ClutterAlpha:alpha:
*
* The alpha value as computed by the alpha function. The linear
* interval is 0.0 to 1.0, but the Alpha allows overshooting by
* one unit in each direction, so the valid interval is -1.0 to 2.0.
*
* Since: 0.2
* Deprecated: 1.12: Use #ClutterTimeline::new-frame and
* clutter_timeline_get_progress() instead
*/
obj_props[PROP_ALPHA] =
g_param_spec_double ("alpha",
P_("Alpha value"),
P_("Alpha value as computed by the alpha"),
-1.0, 2.0,
0.0,
CLUTTER_PARAM_READABLE);
/**
* ClutterAlpha:mode:
*
* The progress function logical id - a value from the
* #ClutterAnimationMode enumeration.
*
* If %CLUTTER_CUSTOM_MODE is used then the function set using
* clutter_alpha_set_closure() or clutter_alpha_set_func()
* will be used.
*
* Since: 1.0
* Deprecated: 1.12: Use #ClutterTimeline:progress-mode
*/
obj_props[PROP_MODE] =
g_param_spec_ulong ("mode",
P_("Mode"),
P_("Progress mode"),
0, G_MAXULONG,
CLUTTER_CUSTOM_MODE,
G_PARAM_CONSTRUCT | CLUTTER_PARAM_READWRITE);
g_object_class_install_properties (object_class,
PROP_LAST,
obj_props);
}
static void
clutter_alpha_init (ClutterAlpha *self)
{
self->priv = clutter_alpha_get_instance_private (self);
self->priv->mode = CLUTTER_CUSTOM_MODE;
self->priv->alpha = 0.0;
}
/**
* clutter_alpha_get_alpha:
* @alpha: A #ClutterAlpha
*
* Query the current alpha value.
*
* Return Value: The current alpha value for the alpha
*
* Since: 0.2
*
* Deprecated: 1.12: Use clutter_timeline_get_progress()
*/
gdouble
clutter_alpha_get_alpha (ClutterAlpha *alpha)
{
ClutterAlphaPrivate *priv;
gdouble retval = 0;
g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), 0);
priv = alpha->priv;
if (G_LIKELY (priv->func))
{
return priv->func (alpha, priv->user_data);
}
else if (priv->closure)
{
GValue params = G_VALUE_INIT;
GValue result_value = G_VALUE_INIT;
g_object_ref (alpha);
g_value_init (&result_value, G_TYPE_DOUBLE);
g_value_init (&params, CLUTTER_TYPE_ALPHA);
g_value_set_object (&params, alpha);
g_closure_invoke (priv->closure, &result_value, 1, &params, NULL);
retval = g_value_get_double (&result_value);
g_value_unset (&result_value);
g_value_unset (&params);
g_object_unref (alpha);
}
return retval;
}
/*
* clutter_alpha_set_closure_internal:
* @alpha: a #ClutterAlpha
* @closure: a #GClosure
*
* Sets the @closure for @alpha. This function does not
* set the #ClutterAlpha:mode property and does not emit
* the #GObject::notify signal for it.
*/
static inline void
clutter_alpha_set_closure_internal (ClutterAlpha *alpha,
GClosure *closure)
{
ClutterAlphaPrivate *priv = alpha->priv;
if (priv->notify != NULL)
priv->notify (priv->user_data);
else if (priv->closure != NULL)
g_closure_unref (priv->closure);
priv->func = NULL;
priv->user_data = NULL;
priv->notify = NULL;
if (closure == NULL)
return;
/* need to take ownership of the closure before sinking it */
priv->closure = g_closure_ref (closure);
g_closure_sink (closure);
/* set the marshaller */
if (G_CLOSURE_NEEDS_MARSHAL (closure))
{
GClosureMarshal marshal = _clutter_marshal_DOUBLE__VOID;
g_closure_set_marshal (priv->closure, marshal);
}
}
/**
* clutter_alpha_set_closure:
* @alpha: A #ClutterAlpha
* @closure: A #GClosure
*
* Sets the #GClosure used to compute the alpha value at each
* frame of the #ClutterTimeline bound to @alpha.
*
* Since: 0.8
*
* Deprecated: 1.12: Use clutter_timeline_set_progress_func()
*/
void
clutter_alpha_set_closure (ClutterAlpha *alpha,
GClosure *closure)
{
ClutterAlphaPrivate *priv;
g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
g_return_if_fail (closure != NULL);
priv = alpha->priv;
clutter_alpha_set_closure_internal (alpha, closure);
priv->mode = CLUTTER_CUSTOM_MODE;
g_object_notify_by_pspec (G_OBJECT (alpha), obj_props[PROP_MODE]);
}
/**
* clutter_alpha_set_func:
* @alpha: A #ClutterAlpha
* @func: A #ClutterAlphaFunc
* @data: user data to be passed to the alpha function, or %NULL
* @destroy: notify function used when disposing the alpha function
*
* Sets the #ClutterAlphaFunc function used to compute
* the alpha value at each frame of the #ClutterTimeline
* bound to @alpha.
*
* This function will not register @func as a global alpha function.
*
* Since: 0.2
*
* Deprecated: 1.12: Use clutter_timeline_set_progress_func()
*/
void
clutter_alpha_set_func (ClutterAlpha *alpha,
ClutterAlphaFunc func,
gpointer data,
GDestroyNotify destroy)
{
ClutterAlphaPrivate *priv;
g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
g_return_if_fail (func != NULL);
priv = alpha->priv;
if (priv->notify != NULL)
{
priv->notify (priv->user_data);
}
else if (priv->closure != NULL)
{
g_closure_unref (priv->closure);
priv->closure = NULL;
}
priv->func = func;
priv->user_data = data;
priv->notify = destroy;
priv->mode = CLUTTER_CUSTOM_MODE;
g_object_notify_by_pspec (G_OBJECT (alpha), obj_props[PROP_MODE]);
}
/**
* clutter_alpha_set_timeline:
* @alpha: A #ClutterAlpha
* @timeline: A #ClutterTimeline
*
* Binds @alpha to @timeline.
*
* Since: 0.2
*
* Deprecated: 1.12: Use #ClutterTimeline directly
*/
void
clutter_alpha_set_timeline (ClutterAlpha *alpha,
ClutterTimeline *timeline)
{
ClutterAlphaPrivate *priv;
g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
g_return_if_fail (timeline == NULL || CLUTTER_IS_TIMELINE (timeline));
priv = alpha->priv;
if (priv->timeline == timeline)
return;
if (priv->timeline)
{
g_signal_handlers_disconnect_by_func (priv->timeline,
timeline_new_frame_cb,
alpha);
g_object_unref (priv->timeline);
priv->timeline = NULL;
}
if (timeline)
{
priv->timeline = g_object_ref (timeline);
g_signal_connect (priv->timeline, "new-frame",
G_CALLBACK (timeline_new_frame_cb),
alpha);
}
g_object_notify_by_pspec (G_OBJECT (alpha), obj_props[PROP_TIMELINE]);
}
/**
* clutter_alpha_get_timeline:
* @alpha: A #ClutterAlpha
*
* Gets the #ClutterTimeline bound to @alpha.
*
* Return value: (transfer none): a #ClutterTimeline instance
*
* Since: 0.2
*
* Deprecated: 1.12: Use #ClutterTimeline directlry
*/
ClutterTimeline *
clutter_alpha_get_timeline (ClutterAlpha *alpha)
{
g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), NULL);
return alpha->priv->timeline;
}
/**
* clutter_alpha_new:
*
* Creates a new #ClutterAlpha instance. You must set a function
* to compute the alpha value using clutter_alpha_set_func() and
* bind a #ClutterTimeline object to the #ClutterAlpha instance
* using clutter_alpha_set_timeline().
*
* Return value: the newly created empty #ClutterAlpha instance.
*
* Since: 0.2
*
* Deprecated: 1.12: Use #ClutterTimeline instead
*/
ClutterAlpha *
clutter_alpha_new (void)
{
return g_object_new (CLUTTER_TYPE_ALPHA, NULL);
}
/**
* clutter_alpha_new_full:
* @timeline: #ClutterTimeline timeline
* @mode: animation mode
*
* Creates a new #ClutterAlpha instance and sets the timeline
* and animation mode.
*
* See also clutter_alpha_set_timeline() and clutter_alpha_set_mode().
*
* Return Value: the newly created #ClutterAlpha
*
* Since: 1.0
*
* Deprecated: 1.12: Use #ClutterTimeline instead
*/
ClutterAlpha *
clutter_alpha_new_full (ClutterTimeline *timeline,
gulong mode)
{
g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), NULL);
g_return_val_if_fail (mode != CLUTTER_ANIMATION_LAST, NULL);
return g_object_new (CLUTTER_TYPE_ALPHA,
"timeline", timeline,
"mode", mode,
NULL);
}
/**
* clutter_alpha_get_mode:
* @alpha: a #ClutterAlpha
*
* Retrieves the #ClutterAnimationMode used by @alpha.
*
* Return value: the animation mode
*
* Since: 1.0
*
* Deprecated: 1.12: Use #ClutterTimeline instead
*/
gulong
clutter_alpha_get_mode (ClutterAlpha *alpha)
{
g_return_val_if_fail (CLUTTER_IS_ALPHA (alpha), CLUTTER_CUSTOM_MODE);
return alpha->priv->mode;
}
typedef struct _AlphaData {
guint closure_set : 1;
ClutterAlphaFunc func;
gpointer data;
GClosure *closure;
} AlphaData;
static GPtrArray *clutter_alphas = NULL;
static gdouble
clutter_alpha_easing_func (ClutterAlpha *alpha,
gpointer data G_GNUC_UNUSED)
{
ClutterAlphaPrivate *priv = alpha->priv;
ClutterTimeline *timeline = priv->timeline;
gdouble t, d;
if (G_UNLIKELY (priv->timeline == NULL))
return 0.0;
t = clutter_timeline_get_elapsed_time (timeline);
d = clutter_timeline_get_duration (timeline);
return clutter_easing_for_mode (priv->mode, t, d);
}
/**
* clutter_alpha_set_mode:
* @alpha: a #ClutterAlpha
* @mode: a #ClutterAnimationMode
*
* Sets the progress function of @alpha using the symbolic value
* of @mode, as taken by the #ClutterAnimationMode enumeration.
*
* Since: 1.0
*
* Deprecated: 1.12: Use #ClutterTimeline and
* clutter_timeline_set_progress_mode() instead
*/
void
clutter_alpha_set_mode (ClutterAlpha *alpha,
gulong mode)
{
ClutterAlphaPrivate *priv;
g_return_if_fail (CLUTTER_IS_ALPHA (alpha));
g_return_if_fail (mode != CLUTTER_ANIMATION_LAST);
priv = alpha->priv;
if (mode == CLUTTER_CUSTOM_MODE)
{
priv->mode = mode;
}
else if (mode < CLUTTER_ANIMATION_LAST)
{
if (priv->mode == mode)
return;
/* sanity check to avoid getting an out of sync
* enum/function mapping
*/
g_assert (clutter_get_easing_func_for_mode (mode) != NULL);
clutter_alpha_set_closure_internal (alpha, NULL);
priv->mode = mode;
CLUTTER_NOTE (ANIMATION, "New easing mode '%s'[%lu]\n",
clutter_get_easing_name_for_mode (priv->mode),
priv->mode);
priv->func = clutter_alpha_easing_func;
priv->user_data = NULL;
priv->notify = NULL;
}
else if (mode > CLUTTER_ANIMATION_LAST)
{
AlphaData *alpha_data = NULL;
gulong real_index = 0;
if (priv->mode == mode)
return;
if (G_UNLIKELY (clutter_alphas == NULL))
{
g_warning ("No alpha functions defined for ClutterAlpha to use. ");
return;
}
real_index = mode - CLUTTER_ANIMATION_LAST - 1;
alpha_data = g_ptr_array_index (clutter_alphas, real_index);
if (G_UNLIKELY (alpha_data == NULL))
{
g_warning ("No alpha function registered for mode %lu.",
mode);
return;
}
if (alpha_data->closure_set)
clutter_alpha_set_closure (alpha, alpha_data->closure);
else
{
clutter_alpha_set_closure_internal (alpha, NULL);
priv->func = alpha_data->func;
priv->user_data = alpha_data->data;
priv->notify = NULL;
}
priv->mode = mode;
}
else
g_assert_not_reached ();
g_object_notify_by_pspec (G_OBJECT (alpha), obj_props[PROP_MODE]);
}

View File

@ -1,138 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Authored By Matthew Allum <mallum@openedhand.com>
* Jorn Baayen <jorn@openedhand.com>
* Emmanuele Bassi <ebassi@openedhand.com>
* Tomas Frydrych <tf@openedhand.com>
*
* Copyright (C) 2006, 2007, 2008 OpenedHand
* Copyright (C) 2009 Intel Corp.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
#error "Only <clutter/clutter.h> can be included directly."
#endif
#ifndef __CLUTTER_ALPHA_H__
#define __CLUTTER_ALPHA_H__
#include <clutter/clutter-timeline.h>
#include <clutter/clutter-types.h>
G_BEGIN_DECLS
#define CLUTTER_TYPE_ALPHA (clutter_alpha_get_type ())
#define CLUTTER_ALPHA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ALPHA, ClutterAlpha))
#define CLUTTER_ALPHA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_ALPHA, ClutterAlphaClass))
#define CLUTTER_IS_ALPHA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ALPHA))
#define CLUTTER_IS_ALPHA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_ALPHA))
#define CLUTTER_ALPHA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_ALPHA, ClutterAlphaClass))
typedef struct _ClutterAlphaClass ClutterAlphaClass;
typedef struct _ClutterAlphaPrivate ClutterAlphaPrivate;
/**
* ClutterAlphaFunc:
* @alpha: a #ClutterAlpha
* @user_data: user data passed to the function
*
* A function returning a value depending on the position of
* the #ClutterTimeline bound to @alpha.
*
* Return value: a floating point value
*
* Since: 0.2
*
* Deprecated: 1.12: Use #ClutterTimelineProgressFunc instead.
*/
typedef gdouble (*ClutterAlphaFunc) (ClutterAlpha *alpha,
gpointer user_data);
/**
* ClutterAlpha:
*
* #ClutterAlpha combines a #ClutterTimeline and a function.
* The contents of the #ClutterAlpha structure are private and should
* only be accessed using the provided API.
*
* Since: 0.2
*
* Deprecated: 1.12: Use #ClutterTimeline instead
*/
struct _ClutterAlpha
{
/*< private >*/
GInitiallyUnowned parent;
ClutterAlphaPrivate *priv;
};
/**
* ClutterAlphaClass:
*
* Base class for #ClutterAlpha
*
* Since: 0.2
*
* Deprecated: 1.12: Use #ClutterTimeline instead
*/
struct _ClutterAlphaClass
{
/*< private >*/
GInitiallyUnownedClass parent_class;
void (*_clutter_alpha_1) (void);
void (*_clutter_alpha_2) (void);
void (*_clutter_alpha_3) (void);
void (*_clutter_alpha_4) (void);
void (*_clutter_alpha_5) (void);
};
CLUTTER_DEPRECATED
GType clutter_alpha_get_type (void) G_GNUC_CONST;
CLUTTER_DEPRECATED
ClutterAlpha * clutter_alpha_new (void);
CLUTTER_DEPRECATED
ClutterAlpha * clutter_alpha_new_full (ClutterTimeline *timeline,
gulong mode);
CLUTTER_DEPRECATED
gdouble clutter_alpha_get_alpha (ClutterAlpha *alpha);
CLUTTER_DEPRECATED
void clutter_alpha_set_func (ClutterAlpha *alpha,
ClutterAlphaFunc func,
gpointer data,
GDestroyNotify destroy);
CLUTTER_DEPRECATED
void clutter_alpha_set_closure (ClutterAlpha *alpha,
GClosure *closure);
CLUTTER_DEPRECATED
void clutter_alpha_set_timeline (ClutterAlpha *alpha,
ClutterTimeline *timeline);
CLUTTER_DEPRECATED
ClutterTimeline *clutter_alpha_get_timeline (ClutterAlpha *alpha);
CLUTTER_DEPRECATED
void clutter_alpha_set_mode (ClutterAlpha *alpha,
gulong mode);
CLUTTER_DEPRECATED
gulong clutter_alpha_get_mode (ClutterAlpha *alpha);
G_END_DECLS
#endif /* __CLUTTER_ALPHA_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,152 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2008 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Author:
* Emmanuele Bassi <ebassi@linux.intel.com>
*/
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
#error "Only <clutter/clutter.h> can be included directly."
#endif
#ifndef __CLUTTER_ANIMATION_H__
#define __CLUTTER_ANIMATION_H__
#include <clutter/clutter-types.h>
G_BEGIN_DECLS
#define CLUTTER_TYPE_ANIMATION (clutter_animation_get_type ())
#define CLUTTER_ANIMATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_ANIMATION, ClutterAnimation))
#define CLUTTER_IS_ANIMATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_ANIMATION))
#define CLUTTER_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_ANIMATION, ClutterAnimationClass))
#define CLUTTER_IS_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_ANIMATION))
#define CLUTTER_ANIMATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_ANIMATION, ClutterAnimationClass))
typedef struct _ClutterAnimationPrivate ClutterAnimationPrivate;
typedef struct _ClutterAnimationClass ClutterAnimationClass;
/**
* ClutterAnimation:
*
* The #ClutterAnimation structure contains only private data and should
* be accessed using the provided functions.
*
* Since: 1.0
*
* Deprecated: 1.12: Use the implicit animation on #ClutterActor
*/
struct _ClutterAnimation
{
/*< private >*/
GObject parent_instance;
ClutterAnimationPrivate *priv;
};
/**
* ClutterAnimationClass:
* @started: class handler for the #ClutterAnimation::started signal
* @completed: class handler for the #ClutterAnimation::completed signal
*
* The #ClutterAnimationClass structure contains only private data and
* should be accessed using the provided functions.
*
* Since: 1.0
*
* Deprecated: 1.12: Use the implicit animation on #ClutterActor
*/
struct _ClutterAnimationClass
{
/*< private >*/
GObjectClass parent_class;
/*< public >*/
void (* started) (ClutterAnimation *animation);
void (* completed) (ClutterAnimation *animation);
/*< private >*/
/* padding for future expansion */
void (*_clutter_reserved1) (void);
void (*_clutter_reserved2) (void);
void (*_clutter_reserved3) (void);
void (*_clutter_reserved4) (void);
void (*_clutter_reserved5) (void);
void (*_clutter_reserved6) (void);
void (*_clutter_reserved7) (void);
void (*_clutter_reserved8) (void);
};
CLUTTER_DEPRECATED
GType clutter_animation_get_type (void) G_GNUC_CONST;
CLUTTER_DEPRECATED_FOR(clutter_property_transition_new)
ClutterAnimation * clutter_animation_new (void);
CLUTTER_DEPRECATED_FOR(clutter_transition_set_animatable)
void clutter_animation_set_object (ClutterAnimation *animation,
GObject *object);
CLUTTER_DEPRECATED_FOR(clutter_timeline_set_progress_mode)
void clutter_animation_set_mode (ClutterAnimation *animation,
gulong mode);
CLUTTER_DEPRECATED_FOR(clutter_timeline_get_progress_mode)
gulong clutter_animation_get_mode (ClutterAnimation *animation);
CLUTTER_DEPRECATED_FOR(clutter_timeline_set_duration)
void clutter_animation_set_duration (ClutterAnimation *animation,
guint msecs);
CLUTTER_DEPRECATED_FOR(clutter_timeline_get_duration)
guint clutter_animation_get_duration (ClutterAnimation *animation);
CLUTTER_DEPRECATED_FOR(clutter_timeline_set_repeat_count)
void clutter_animation_set_loop (ClutterAnimation *animation,
gboolean loop);
CLUTTER_DEPRECATED_FOR(clutter_timeline_get_repeat_count)
gboolean clutter_animation_get_loop (ClutterAnimation *animation);
CLUTTER_DEPRECATED
void clutter_animation_set_timeline (ClutterAnimation *animation,
ClutterTimeline *timeline);
CLUTTER_DEPRECATED
ClutterTimeline * clutter_animation_get_timeline (ClutterAnimation *animation);
CLUTTER_DEPRECATED
gboolean clutter_animation_has_property (ClutterAnimation *animation,
const gchar *property_name);
CLUTTER_DEPRECATED
ClutterInterval * clutter_animation_get_interval (ClutterAnimation *animation,
const gchar *property_name);
/*
* ClutterActor API
*/
CLUTTER_DEPRECATED
ClutterAnimation * clutter_actor_animate (ClutterActor *actor,
gulong mode,
guint duration,
const gchar *first_property_name,
...) G_GNUC_NULL_TERMINATED;
CLUTTER_DEPRECATED
ClutterAnimation * clutter_actor_animate_with_timeline (ClutterActor *actor,
gulong mode,
ClutterTimeline *timeline,
const gchar *first_property_name,
...) G_GNUC_NULL_TERMINATED;
G_END_DECLS
#endif /* __CLUTTER_ANIMATION_DEPRECATED_H__ */

View File

@ -333,21 +333,20 @@ clutter_group_real_get_preferred_height (ClutterActor *actor,
static void
clutter_group_real_allocate (ClutterActor *actor,
const ClutterActorBox *allocation,
ClutterAllocationFlags flags)
const ClutterActorBox *allocation)
{
ClutterGroupPrivate *priv = CLUTTER_GROUP (actor)->priv;
ClutterActorClass *klass;
klass = CLUTTER_ACTOR_CLASS (clutter_group_parent_class);
klass->allocate (actor, allocation, flags);
klass->allocate (actor, allocation);
if (priv->children == NULL)
return;
clutter_layout_manager_allocate (priv->layout,
CLUTTER_CONTAINER (actor),
allocation, flags);
allocation);
}
static void

File diff suppressed because it is too large Load Diff

View File

@ -1,147 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Authored By Øyvind Kolås <pippin@linux.intel.com>
*
* Copyright (C) 2009 Intel Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __CLUTTER_STATE_H__
#define __CLUTTER_STATE_H__
#include <clutter/clutter-types.h>
G_BEGIN_DECLS
#define CLUTTER_TYPE_STATE_KEY (clutter_state_key_get_type ())
#define CLUTTER_TYPE_STATE (clutter_state_get_type ())
#define CLUTTER_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_STATE, ClutterState))
#define CLUTTER_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_STATE, ClutterStateClass))
#define CLUTTER_IS_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_STATE))
#define CLUTTER_IS_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_STATE))
#define CLUTTER_STATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_STATE, ClutterStateClass))
typedef struct _ClutterStatePrivate ClutterStatePrivate;
typedef struct _ClutterStateClass ClutterStateClass;
/**
* ClutterStateKey:
*
* #ClutterStateKey is an opaque structure whose
* members cannot be accessed directly
*
* Since: 1.4
*/
typedef struct _ClutterStateKey ClutterStateKey;
/**
* ClutterState:
*
* The #ClutterState structure contains only
* private data and should be accessed using the provided API
*
* Since: 1.4
*/
struct _ClutterState
{
/*< private >*/
GObject parent;
ClutterStatePrivate *priv;
};
/**
* ClutterStateClass:
* @completed: class handler for the #ClutterState::completed signal
*
* The #ClutterStateClass structure contains
* only private data
*
* Since: 1.4
*
* Deprecated: 1.12
*/
struct _ClutterStateClass
{
/*< private >*/
GObjectClass parent_class;
/*< public >*/
void (* completed) (ClutterState *state);
/*< private >*/
/* padding for future expansion */
gpointer _padding_dummy[8];
};
CLUTTER_DEPRECATED
GType clutter_state_get_type (void) G_GNUC_CONST;
CLUTTER_DEPRECATED
ClutterState *clutter_state_new (void);
CLUTTER_DEPRECATED
ClutterTimeline * clutter_state_set_state (ClutterState *state,
const gchar *target_state_name);
CLUTTER_DEPRECATED
ClutterTimeline * clutter_state_warp_to_state (ClutterState *state,
const gchar *target_state_name);
CLUTTER_DEPRECATED
ClutterState * clutter_state_set_key (ClutterState *state,
const gchar *source_state_name,
const gchar *target_state_name,
GObject *object,
const gchar *property_name,
guint mode,
const GValue *value,
gdouble pre_delay,
gdouble post_delay);
CLUTTER_DEPRECATED
void clutter_state_set_duration (ClutterState *state,
const gchar *source_state_name,
const gchar *target_state_name,
guint duration);
CLUTTER_DEPRECATED
guint clutter_state_get_duration (ClutterState *state,
const gchar *source_state_name,
const gchar *target_state_name);
CLUTTER_DEPRECATED
void clutter_state_set (ClutterState *state,
const gchar *source_state_name,
const gchar *target_state_name,
gpointer first_object,
const gchar *first_property_name,
gulong first_mode,
...) G_GNUC_NULL_TERMINATED;
CLUTTER_DEPRECATED
GList * clutter_state_get_states (ClutterState *state);
CLUTTER_DEPRECATED
const gchar * clutter_state_get_state (ClutterState *state);
/*
* ClutterStateKey
*/
CLUTTER_DEPRECATED
GType clutter_state_key_get_type (void) G_GNUC_CONST;
CLUTTER_DEPRECATED
GType clutter_state_key_get_property_type (const ClutterStateKey *key);
G_END_DECLS
#endif /* __CLUTTER_STATE_H__ */

View File

@ -26,16 +26,6 @@
G_BEGIN_DECLS
CLUTTER_DEPRECATED_FOR(clutter_timeline_new)
ClutterTimeline * clutter_timeline_clone (ClutterTimeline *timeline);
CLUTTER_DEPRECATED_FOR(clutter_timeline_set_repeat_count)
void clutter_timeline_set_loop (ClutterTimeline *timeline,
gboolean loop);
CLUTTER_DEPRECATED_FOR(clutter_timeline_get_repeat_count)
gboolean clutter_timeline_get_loop (ClutterTimeline *timeline);
G_END_DECLS
#endif /* __CLUTTER_TIMELINE_PRIVATE_H__ */

View File

@ -114,6 +114,7 @@ clutter_sources = [
'clutter-constraint.c',
'clutter-container.c',
'clutter-content.c',
'clutter-damage-history.c',
'clutter-deform-effect.c',
'clutter-desaturate-effect.c',
'clutter-effect.c',
@ -185,6 +186,7 @@ clutter_private_headers = [
'clutter-bezier.h',
'clutter-constraint-private.h',
'clutter-content-private.h',
'clutter-damage-history.h',
'clutter-debug.h',
'clutter-easing.h',
'clutter-effect-private.h',
@ -219,24 +221,18 @@ clutter_nonintrospected_sources = [
clutter_deprecated_headers = [
'deprecated/clutter-actor.h',
'deprecated/clutter-alpha.h',
'deprecated/clutter-animation.h',
'deprecated/clutter-box.h',
'deprecated/clutter-container.h',
'deprecated/clutter-group.h',
'deprecated/clutter-rectangle.h',
'deprecated/clutter-stage.h',
'deprecated/clutter-state.h',
'deprecated/clutter-timeline.h',
]
clutter_deprecated_sources = [
'deprecated/clutter-alpha.c',
'deprecated/clutter-animation.c',
'deprecated/clutter-box.c',
'deprecated/clutter-group.c',
'deprecated/clutter-rectangle.c',
'deprecated/clutter-state.c',
]
clutter_backend_sources = []

View File

@ -158,7 +158,7 @@ _cogl_blit_framebuffer_begin (CoglBlitData *data)
supported. */
if ((_cogl_texture_get_format (data->src_tex) & COGL_PREMULT_BIT) !=
(_cogl_texture_get_format (data->dst_tex) & COGL_PREMULT_BIT) ||
!_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_BLIT_FRAMEBUFFER))
!cogl_has_feature (ctx, COGL_FEATURE_ID_BLIT_FRAMEBUFFER))
return FALSE;
dst_offscreen = _cogl_offscreen_new_with_texture_full

View File

@ -193,6 +193,8 @@ cogl_is_context (void *object);
* expected to return age values other than 0.
* @COGL_FEATURE_ID_PRESENTATION_TIME: Whether frame presentation
* time stamps will be recorded in #CoglFrameInfo objects.
* @COGL_FEATURE_ID_BLIT_FRAMEBUFFER: Whether blitting using
* cogl_blit_framebuffer() is supported.
*
* All the capabilities that can vary between different GPUs supported
* by Cogl. Applications that depend on any of these features should explicitly
@ -211,6 +213,7 @@ typedef enum _CoglFeatureID
COGL_FEATURE_ID_TEXTURE_RG,
COGL_FEATURE_ID_BUFFER_AGE,
COGL_FEATURE_ID_TEXTURE_EGL_IMAGE_EXTERNAL,
COGL_FEATURE_ID_BLIT_FRAMEBUFFER,
/*< private >*/
_COGL_N_FEATURE_IDS /*< skip >*/

View File

@ -34,12 +34,22 @@
#include "cogl-dma-buf-handle.h"
#include "cogl-object.h"
#include <errno.h>
#include <gio/gio.h>
#include <linux/dma-buf.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <unistd.h>
struct _CoglDmaBufHandle
{
CoglFramebuffer *framebuffer;
int dmabuf_fd;
int width;
int height;
int stride;
int offset;
int bpp;
gpointer user_data;
GDestroyNotify destroy_func;
};
@ -47,6 +57,11 @@ struct _CoglDmaBufHandle
CoglDmaBufHandle *
cogl_dma_buf_handle_new (CoglFramebuffer *framebuffer,
int dmabuf_fd,
int width,
int height,
int stride,
int offset,
int bpp,
gpointer user_data,
GDestroyNotify destroy_func)
{
@ -61,6 +76,12 @@ cogl_dma_buf_handle_new (CoglFramebuffer *framebuffer,
dmabuf_handle->user_data = user_data;
dmabuf_handle->destroy_func = destroy_func;
dmabuf_handle->width = width;
dmabuf_handle->height = height;
dmabuf_handle->stride = stride;
dmabuf_handle->offset = offset;
dmabuf_handle->bpp = bpp;
return dmabuf_handle;
}
@ -80,6 +101,93 @@ cogl_dma_buf_handle_free (CoglDmaBufHandle *dmabuf_handle)
g_free (dmabuf_handle);
}
static gboolean
sync_read (CoglDmaBufHandle *dmabuf_handle,
uint64_t start_or_end,
GError **error)
{
struct dma_buf_sync sync = { 0 };
sync.flags = start_or_end | DMA_BUF_SYNC_READ;
while (TRUE)
{
int ret;
ret = ioctl (dmabuf_handle->dmabuf_fd, DMA_BUF_IOCTL_SYNC, &sync);
if (ret == -1 && errno == EINTR)
{
continue;
}
else if (ret == -1)
{
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
"ioctl: %s", g_strerror (errno));
return FALSE;
}
else
{
break;
}
}
return TRUE;
}
gboolean
cogl_dma_buf_handle_sync_read_start (CoglDmaBufHandle *dmabuf_handle,
GError **error)
{
return sync_read (dmabuf_handle, DMA_BUF_SYNC_START, error);
}
gboolean
cogl_dma_buf_handle_sync_read_end (CoglDmaBufHandle *dmabuf_handle,
GError **error)
{
return sync_read (dmabuf_handle, DMA_BUF_SYNC_END, error);
}
gpointer
cogl_dma_buf_handle_mmap (CoglDmaBufHandle *dmabuf_handle,
GError **error)
{
size_t size;
gpointer data;
size = dmabuf_handle->height * dmabuf_handle->stride;
data = mmap (NULL, size, PROT_READ, MAP_PRIVATE,
dmabuf_handle->dmabuf_fd,
dmabuf_handle->offset);
if (data == MAP_FAILED)
{
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
"mmap failed: %s", g_strerror (errno));
return NULL;
}
return data;
}
gboolean
cogl_dma_buf_handle_munmap (CoglDmaBufHandle *dmabuf_handle,
gpointer data,
GError **error)
{
size_t size;
size = dmabuf_handle->height * dmabuf_handle->stride;
if (munmap (data, size) != 0)
{
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
"munmap failed: %s", g_strerror (errno));
return FALSE;
}
return TRUE;
}
CoglFramebuffer *
cogl_dma_buf_handle_get_framebuffer (CoglDmaBufHandle *dmabuf_handle)
{
@ -92,3 +200,32 @@ cogl_dma_buf_handle_get_fd (CoglDmaBufHandle *dmabuf_handle)
return dmabuf_handle->dmabuf_fd;
}
int
cogl_dma_buf_handle_get_width (CoglDmaBufHandle *dmabuf_handle)
{
return dmabuf_handle->width;
}
int
cogl_dma_buf_handle_get_height (CoglDmaBufHandle *dmabuf_handle)
{
return dmabuf_handle->height;
}
int
cogl_dma_buf_handle_get_stride (CoglDmaBufHandle *dmabuf_handle)
{
return dmabuf_handle->stride;
}
int
cogl_dma_buf_handle_get_offset (CoglDmaBufHandle *dmabuf_handle)
{
return dmabuf_handle->offset;
}
int
cogl_dma_buf_handle_get_bpp (CoglDmaBufHandle *dmabuf_handle)
{
return dmabuf_handle->bpp;
}

View File

@ -46,7 +46,12 @@
COGL_EXPORT CoglDmaBufHandle *
cogl_dma_buf_handle_new (CoglFramebuffer *framebuffer,
int dmabuf_fd,
gpointer data,
int width,
int height,
int stride,
int offset,
int bpp,
gpointer user_data,
GDestroyNotify destroy_func);
/**
@ -58,6 +63,23 @@ cogl_dma_buf_handle_new (CoglFramebuffer *framebuffer,
COGL_EXPORT void
cogl_dma_buf_handle_free (CoglDmaBufHandle *dmabuf_handle);
COGL_EXPORT gboolean
cogl_dma_buf_handle_sync_read_start (CoglDmaBufHandle *dmabuf_handle,
GError **error);
COGL_EXPORT gboolean
cogl_dma_buf_handle_sync_read_end (CoglDmaBufHandle *dmabuf_handle,
GError **error);
COGL_EXPORT gpointer
cogl_dma_buf_handle_mmap (CoglDmaBufHandle *dmabuf_handle,
GError **error);
COGL_EXPORT gboolean
cogl_dma_buf_handle_munmap (CoglDmaBufHandle *dmabuf_handle,
gpointer data,
GError **error);
/**
* cogl_dma_buf_handle_get_framebuffer: (skip)
*
@ -79,5 +101,44 @@ cogl_dma_buf_handle_get_framebuffer (CoglDmaBufHandle *dmabuf_handle);
COGL_EXPORT int
cogl_dma_buf_handle_get_fd (CoglDmaBufHandle *dmabuf_handle);
/**
* cogl_dmabuf_handle_get_width: (skip)
*
* Returns: the buffer width
*/
COGL_EXPORT int
cogl_dma_buf_handle_get_width (CoglDmaBufHandle *dmabuf_handle);
/**
* cogl_dmabuf_handle_get_height: (skip)
*
* Returns: the buffer height
*/
COGL_EXPORT int
cogl_dma_buf_handle_get_height (CoglDmaBufHandle *dmabuf_handle);
/**
* cogl_dmabuf_handle_get_stride: (skip)
*
* Returns: the buffer stride
*/
COGL_EXPORT int
cogl_dma_buf_handle_get_stride (CoglDmaBufHandle *dmabuf_handle);
/**
* cogl_dmabuf_handle_get_offset: (skip)
*
* Returns: the buffer offset
*/
COGL_EXPORT int
cogl_dma_buf_handle_get_offset (CoglDmaBufHandle *dmabuf_handle);
/**
* cogl_dmabuf_handle_get_bpp: (skip)
*
* Returns: the number of bytes per pixel
*/
COGL_EXPORT int
cogl_dma_buf_handle_get_bpp (CoglDmaBufHandle *dmabuf_handle);
#endif /* __COGL_DMA_BUF_HANDLE_H__ */

View File

@ -43,8 +43,6 @@ struct _CoglFrameInfo
float refresh_rate;
int64_t global_frame_counter;
CoglOutput *output;
};
CoglFrameInfo *_cogl_frame_info_new (void);

View File

@ -72,12 +72,6 @@ cogl_frame_info_get_refresh_rate (CoglFrameInfo *info)
return info->refresh_rate;
}
CoglOutput *
cogl_frame_info_get_output (CoglFrameInfo *info)
{
return info->output;
}
int64_t
cogl_frame_info_get_global_frame_counter (CoglFrameInfo *info)
{

View File

@ -126,20 +126,6 @@ int64_t cogl_frame_info_get_presentation_time (CoglFrameInfo *info);
COGL_EXPORT
float cogl_frame_info_get_refresh_rate (CoglFrameInfo *info);
/**
* cogl_frame_info_get_output:
* @info: a #CoglFrameInfo object
*
* Gets the #CoglOutput that the swapped frame was presented to.
*
* Return value: (transfer none): The #CoglOutput that the frame was
* presented to, or %NULL if this could not be determined.
* Since: 1.14
* Stability: unstable
*/
COGL_EXPORT CoglOutput *
cogl_frame_info_get_output (CoglFrameInfo *info);
/**
* cogl_frame_info_get_global_frame_counter: (skip)
*/

View File

@ -1292,7 +1292,7 @@ cogl_blit_framebuffer (CoglFramebuffer *src,
int src_x1, src_y1, src_x2, src_y2;
int dst_x1, dst_y1, dst_x2, dst_y2;
if (!_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_BLIT_FRAMEBUFFER))
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_BLIT_FRAMEBUFFER))
{
g_set_error_literal (error, COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,

View File

@ -1509,7 +1509,7 @@ cogl_is_framebuffer (void *object);
*
* This blits a region of the color buffer of the source buffer
* to the destination buffer. This function should only be
* called if the COGL_PRIVATE_FEATURE_BLIT_FRAMEBUFFER feature is
* called if the COGL_FEATURE_ID_BLIT_FRAMEBUFFER feature is
* advertised.
*
* The source and destination rectangles are defined in offscreen

View File

@ -1361,6 +1361,17 @@ cogl_pipeline_set_layer_filters (CoglPipeline *pipeline,
sampler_state);
}
void
cogl_pipeline_set_layer_max_mipmap_level (CoglPipeline *pipeline,
int layer,
int max_level)
{
CoglTexture *texture = cogl_pipeline_get_layer_texture (pipeline, layer);
if (texture != NULL)
cogl_texture_set_max_level (texture, max_level);
}
const CoglSamplerCacheEntry *
_cogl_pipeline_layer_get_sampler_state (CoglPipelineLayer *layer)
{

View File

@ -568,6 +568,11 @@ cogl_pipeline_add_layer_snippet (CoglPipeline *pipeline,
int layer,
CoglSnippet *snippet);
COGL_EXPORT void
cogl_pipeline_set_layer_max_mipmap_level (CoglPipeline *pipeline,
int layer,
int max_level);
G_END_DECLS
#endif /* __COGL_PIPELINE_LAYER_STATE_H__ */

View File

@ -42,7 +42,6 @@ typedef enum
{
COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE,
COGL_PRIVATE_FEATURE_MESA_PACK_INVERT,
COGL_PRIVATE_FEATURE_BLIT_FRAMEBUFFER,
COGL_PRIVATE_FEATURE_PBOS,
COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL,
COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL,

View File

@ -204,7 +204,8 @@ struct _CoglTexture
CoglContext *context;
CoglTextureLoader *loader;
GList *framebuffers;
int max_level;
int max_level_set;
int max_level_requested;
int width;
int height;
gboolean allocated;
@ -377,6 +378,10 @@ _cogl_texture_needs_premult_conversion (CoglPixelFormat src_format,
int
_cogl_texture_get_n_levels (CoglTexture *texture);
void
cogl_texture_set_max_level (CoglTexture *texture,
int max_level);
void
_cogl_texture_get_level_size (CoglTexture *texture,
int level,

View File

@ -115,7 +115,8 @@ _cogl_texture_init (CoglTexture *texture,
const CoglTextureVtable *vtable)
{
texture->context = context;
texture->max_level = 0;
texture->max_level_set = 0;
texture->max_level_requested = 1000; /* OpenGL default GL_TEXTURE_MAX_LEVEL */
texture->width = width;
texture->height = height;
texture->allocated = FALSE;
@ -229,8 +230,16 @@ _cogl_texture_get_n_levels (CoglTexture *texture)
int width = cogl_texture_get_width (texture);
int height = cogl_texture_get_height (texture);
int max_dimension = MAX (width, height);
int n_levels = _cogl_util_fls (max_dimension);
return _cogl_util_fls (max_dimension);
return MIN (n_levels, texture->max_level_requested + 1);
}
void
cogl_texture_set_max_level (CoglTexture *texture,
int max_level)
{
texture->max_level_requested = max_level;
}
void

View File

@ -388,8 +388,8 @@ _cogl_framebuffer_gl_flush_state (CoglFramebuffer *draw_buffer,
{
/* NB: Currently we only take advantage of binding separate
* read/write buffers for framebuffer blit purposes. */
g_return_if_fail (_cogl_has_private_feature
(ctx, COGL_PRIVATE_FEATURE_BLIT_FRAMEBUFFER));
g_return_if_fail (cogl_has_feature
(ctx, COGL_FEATURE_ID_BLIT_FRAMEBUFFER));
_cogl_framebuffer_gl_bind (draw_buffer, GL_DRAW_FRAMEBUFFER);
_cogl_framebuffer_gl_bind (read_buffer, GL_READ_FRAMEBUFFER);

View File

@ -567,6 +567,9 @@ _cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d,
&gl_format,
&gl_type);
if (tex->max_level_set < level)
cogl_texture_gl_set_max_level (tex, level);
status = ctx->texture_driver->upload_subregion_to_gl (ctx,
tex,
src_x, src_y,
@ -580,8 +583,6 @@ _cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d,
cogl_object_unref (upload_bmp);
_cogl_texture_gl_maybe_update_max_level (tex, level);
return status;
}

View File

@ -53,8 +53,8 @@ _cogl_texture_gl_flush_legacy_texobj_filters (CoglTexture *texture,
unsigned int mag_filter);
void
_cogl_texture_gl_maybe_update_max_level (CoglTexture *texture,
int max_level);
cogl_texture_gl_set_max_level (CoglTexture *texture,
int max_level);
void
_cogl_texture_gl_generate_mipmaps (CoglTexture *texture);

View File

@ -97,32 +97,36 @@ _cogl_texture_gl_flush_legacy_texobj_filters (CoglTexture *texture,
min_filter, mag_filter);
}
/* GL and GLES3 have this by default, but GLES2 does not except via extension.
* So really it's probably always available. Even if we used it and it wasn't
* available in some driver then there are no adverse consequences to the
* command simply being ignored...
*/
#ifndef GL_TEXTURE_MAX_LEVEL
#define GL_TEXTURE_MAX_LEVEL 0x813D
#endif
void
_cogl_texture_gl_maybe_update_max_level (CoglTexture *texture,
int max_level)
cogl_texture_gl_set_max_level (CoglTexture *texture,
int max_level)
{
/* This isn't supported on GLES */
#ifdef HAVE_COGL_GL
CoglContext *ctx = texture->context;
if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_TEXTURE_MAX_LEVEL) &&
texture->max_level < max_level)
if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_TEXTURE_MAX_LEVEL))
{
CoglContext *ctx = texture->context;
GLuint gl_handle;
GLenum gl_target;
cogl_texture_get_gl_texture (texture, &gl_handle, &gl_target);
texture->max_level = max_level;
texture->max_level_set = max_level;
_cogl_bind_gl_texture_transient (gl_target,
gl_handle);
GE( ctx, glTexParameteri (gl_target,
GL_TEXTURE_MAX_LEVEL, texture->max_level));
GL_TEXTURE_MAX_LEVEL, texture->max_level_set));
}
#endif /* HAVE_COGL_GL */
}
void
@ -133,7 +137,8 @@ _cogl_texture_gl_generate_mipmaps (CoglTexture *texture)
GLuint gl_handle;
GLenum gl_target;
_cogl_texture_gl_maybe_update_max_level (texture, n_levels - 1);
if (texture->max_level_set != n_levels - 1)
cogl_texture_gl_set_max_level (texture, n_levels - 1);
cogl_texture_get_gl_texture (texture, &gl_handle, &gl_target);

View File

@ -455,8 +455,8 @@ _cogl_driver_update_features (CoglContext *ctx,
TRUE);
if (ctx->glBlitFramebuffer)
COGL_FLAGS_SET (private_features,
COGL_PRIVATE_FEATURE_BLIT_FRAMEBUFFER, TRUE);
COGL_FLAGS_SET (ctx->features,
COGL_FEATURE_ID_BLIT_FRAMEBUFFER, TRUE);
COGL_FLAGS_SET (private_features, COGL_PRIVATE_FEATURE_PBOS, TRUE);

View File

@ -255,7 +255,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
* glTexImage2D first to assert that the storage for this
* level exists.
*/
if (texture->max_level < level)
if (texture->max_level_set < level)
{
ctx->glTexImage2D (gl_target,
level,

View File

@ -318,8 +318,8 @@ _cogl_driver_update_features (CoglContext *context,
COGL_FLAGS_SET (private_features, COGL_PRIVATE_FEATURE_SAMPLER_OBJECTS, TRUE);
if (context->glBlitFramebuffer)
COGL_FLAGS_SET (private_features,
COGL_PRIVATE_FEATURE_BLIT_FRAMEBUFFER, TRUE);
COGL_FLAGS_SET (context->features,
COGL_FEATURE_ID_BLIT_FRAMEBUFFER, TRUE);
if (_cogl_check_extension ("GL_OES_element_index_uint", gl_extensions))
{

View File

@ -303,7 +303,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
* glTexImage2D first to assert that the storage for this
* level exists.
*/
if (texture->max_level < level)
if (texture->max_level_set < level)
{
ctx->glTexImage2D (gl_target,
level,

View File

@ -1662,8 +1662,6 @@ set_frame_info_output (CoglOnscreen *onscreen,
{
CoglFrameInfo *info = g_queue_peek_tail (&onscreen->pending_frame_infos);
info->output = output;
if (output)
{
float refresh_rate = cogl_output_get_refresh_rate (output);

View File

@ -17,6 +17,7 @@ cogl_config_h = configure_file(
cogl_pkg_deps = [
glib_dep,
gio_dep,
gobject_dep,
graphene_dep,
]

View File

@ -77,7 +77,7 @@ is_boolean_env_set (const char *variable)
return ret;
}
void
gboolean
test_utils_init (TestFlags requirement_flags,
TestFlags known_failure_flags)
{
@ -156,6 +156,8 @@ test_utils_init (TestFlags requirement_flags,
g_print ("WARNING: Missing required feature[s] for this test\n");
else if (known_failure)
g_print ("WARNING: Test is known to fail\n");
return (!missing_requirement && !known_failure);
}
void
@ -250,7 +252,17 @@ void
test_utils_check_pixel_rgb (CoglFramebuffer *test_fb,
int x, int y, int r, int g, int b)
{
test_utils_check_pixel (test_fb, x, y, (r << 24) | (g << 16) | (b << 8));
g_return_if_fail (r >= 0);
g_return_if_fail (g >= 0);
g_return_if_fail (b >= 0);
g_return_if_fail (r <= 0xFF);
g_return_if_fail (g <= 0xFF);
g_return_if_fail (b <= 0xFF);
test_utils_check_pixel (test_fb, x, y,
(((guint32) r) << 24) |
(((guint32) g) << 16) |
(((guint32) b) << 8));
}
void

View File

@ -68,7 +68,7 @@ typedef enum
extern CoglContext *test_ctx;
extern CoglFramebuffer *test_fb;
void
gboolean
test_utils_init (TestFlags requirement_flags,
TestFlags known_failure_flags);

View File

@ -99,9 +99,9 @@ verify_texture (CoglTexture *texture, int size)
};
test_utils_compare_pixel (p,
(real_color.red << 24) |
(real_color.green << 16) |
(real_color.blue << 8) |
(((guint32) real_color.red) << 24) |
(((guint32) real_color.green) << 16) |
(((guint32) real_color.blue) << 8) |
opacity);
g_assert_cmpint (p[3], ==, opacity);

View File

@ -15,10 +15,17 @@
G_STMT_START { \
if (strcmp (#FUNC, argv[1]) == 0) \
{ \
test_utils_init (REQUIREMENTS, KNOWN_FAIL_REQUIREMENTS); \
FUNC (); \
test_utils_fini (); \
exit (0); \
if (test_utils_init (REQUIREMENTS, KNOWN_FAIL_REQUIREMENTS) \
|| g_getenv ("COGL_TEST_TRY_EVERYTHING") != NULL) \
{ \
FUNC (); \
test_utils_fini (); \
exit (0); \
} \
else \
{ \
exit (1); \
} \
} \
} G_STMT_END
@ -55,7 +62,7 @@ main (int argc, char **argv)
ADD_TEST (test_pipeline_user_matrix, 0, 0);
ADD_TEST (test_blend_strings, 0, 0);
ADD_TEST (test_blend, 0, 0);
ADD_TEST (test_premult, 0, TEST_KNOWN_FAILURE);
ADD_TEST (test_premult, 0, 0);
UNPORTED_TEST (test_readpixels);
ADD_TEST (test_depth_test, 0, 0);
ADD_TEST (test_backface_culling, 0, TEST_REQUIREMENT_NPOT);

View File

@ -50,6 +50,7 @@ make_texture (uint32_t color,
CoglPixelFormat src_format,
MakeTextureFlags flags)
{
static CoglUserDataKey bitmap_free_key;
CoglTexture2D *tex_2d;
guchar *tex_data = gen_tex_data (color);
CoglBitmap *bmp = cogl_bitmap_new_for_data (test_ctx,
@ -58,6 +59,10 @@ make_texture (uint32_t color,
src_format,
QUAD_WIDTH * 4,
tex_data);
cogl_object_set_user_data (COGL_OBJECT (bmp),
&bitmap_free_key,
tex_data,
g_free);
tex_2d = cogl_texture_2d_new_from_bitmap (bmp);
@ -67,7 +72,6 @@ make_texture (uint32_t color,
cogl_texture_set_premultiplied (tex_2d, FALSE);
cogl_object_unref (bmp);
g_free (tex_data);
return tex_2d;
}

View File

@ -36,10 +36,16 @@ main (int argc, char **argv)
return 1;
}
test_utils_init (unit_test->requirement_flags,
unit_test->known_failure_flags);
unit_test->run ();
test_utils_fini ();
return 0;
if (test_utils_init (unit_test->requirement_flags,
unit_test->known_failure_flags)
|| g_getenv ("COGL_TEST_TRY_EVERYTHING") != NULL)
{
unit_test->run ();
test_utils_fini ();
return 0;
}
else
{
return 1;
}
}

View File

@ -1,5 +1,5 @@
project('mutter', 'c',
version: '3.37.1',
version: '3.37.2',
meson_version: '>= 0.50.0',
license: 'GPLv2+'
)
@ -487,6 +487,7 @@ output = [
' Cogl tests............... ' + have_cogl_tests.to_string(),
' Clutter tests............ ' + have_clutter_tests.to_string(),
' Installed tests.......... ' + have_installed_tests.to_string(),
' Coverage................. ' + get_option('b_coverage').to_string(),
'',
' Now type \'ninja -C ' + meson.build_root() + '\' to build ' + meson.project_name(),
'',

View File

@ -12,7 +12,7 @@ option('opengl_libname',
option('gles2_libname',
type: 'string',
value: 'libGLESv2.so',
value: 'libGLESv2.so.2',
description: 'GLESv2 library file name'
)

View File

@ -108,6 +108,14 @@ struct _MetaBackendClass
void meta_init_backend (GType backend_gtype);
#ifdef HAVE_WAYLAND
MetaWaylandCompositor * meta_backend_get_wayland_compositor (MetaBackend *backend);
void meta_backend_init_wayland_display (MetaBackend *backend);
void meta_backend_init_wayland (MetaBackend *backend);
#endif
ClutterBackend * meta_backend_get_clutter_backend (MetaBackend *backend);
MetaIdleMonitor * meta_backend_get_idle_monitor (MetaBackend *backend,
@ -148,10 +156,6 @@ xkb_layout_index_t meta_backend_get_keymap_layout_group (MetaBackend *backend);
gboolean meta_backend_is_lid_closed (MetaBackend *backend);
void meta_backend_freeze_updates (MetaBackend *backend);
void meta_backend_thaw_updates (MetaBackend *backend);
void meta_backend_update_last_device (MetaBackend *backend,
ClutterInputDevice *device);

View File

@ -21,6 +21,8 @@
#ifndef META_BACKEND_TYPE_H
#define META_BACKEND_TYPE_H
typedef struct _MetaBackend MetaBackend;
typedef struct _MetaMonitorManager MetaMonitorManager;
typedef struct _MetaMonitorConfigManager MetaMonitorConfigManager;
@ -54,4 +56,6 @@ typedef struct _MetaScreenCast MetaScreenCast;
typedef struct _MetaScreenCastSession MetaScreenCastSession;
typedef struct _MetaScreenCastStream MetaScreenCastStream;
typedef struct _MetaWaylandCompositor MetaWaylandCompositor;
#endif /* META_BACKEND_TYPE_H */

View File

@ -81,6 +81,10 @@
#include "backends/native/meta-backend-native.h"
#endif
#ifdef HAVE_WAYLAND
#include "wayland/meta-wayland.h"
#endif
enum
{
KEYMAP_CHANGED,
@ -130,6 +134,10 @@ struct _MetaBackendPrivate
MetaRemoteDesktop *remote_desktop;
#endif
#ifdef HAVE_WAYLAND
MetaWaylandCompositor *wayland_compositor;
#endif
#ifdef HAVE_PROFILER
MetaProfiler *profiler;
#endif
@ -567,12 +575,6 @@ meta_backend_real_post_init (MetaBackend *backend)
}
}
static MetaCursorRenderer *
meta_backend_real_create_cursor_renderer (MetaBackend *backend)
{
return meta_cursor_renderer_new ();
}
static gboolean
meta_backend_real_grab_device (MetaBackend *backend,
int device_id,
@ -754,7 +756,6 @@ meta_backend_class_init (MetaBackendClass *klass)
object_class->constructed = meta_backend_constructed;
klass->post_init = meta_backend_real_post_init;
klass->create_cursor_renderer = meta_backend_real_create_cursor_renderer;
klass->grab_device = meta_backend_real_grab_device;
klass->ungrab_device = meta_backend_real_ungrab_device;
klass->select_stage_events = meta_backend_real_select_stage_events;
@ -864,6 +865,120 @@ system_bus_gotten_cb (GObject *object,
NULL);
}
#ifdef HAVE_WAYLAND
MetaWaylandCompositor *
meta_backend_get_wayland_compositor (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
return priv->wayland_compositor;
}
void
meta_backend_init_wayland_display (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
priv->wayland_compositor = meta_wayland_compositor_new (backend);
}
void
meta_backend_init_wayland (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
meta_wayland_compositor_setup (priv->wayland_compositor);
}
#endif
/* Mutter is responsible for pulling events off the X queue, so Clutter
* doesn't need (and shouldn't) run its normal event source which polls
* the X fd, but we do have to deal with dispatching events that accumulate
* in the clutter queue. This happens, for example, when clutter generate
* enter/leave events on mouse motion - several events are queued in the
* clutter queue but only one dispatched. It could also happen because of
* explicit calls to clutter_event_put(). We add a very simple custom
* event loop source which is simply responsible for pulling events off
* of the queue and dispatching them before we block for new events.
*/
static gboolean
clutter_source_prepare (GSource *source,
int *timeout)
{
*timeout = -1;
return clutter_events_pending ();
}
static gboolean
clutter_source_check (GSource *source)
{
return clutter_events_pending ();
}
static gboolean
clutter_source_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data)
{
ClutterEvent *event = clutter_event_get ();
if (event)
{
clutter_do_event (event);
clutter_event_free (event);
}
return TRUE;
}
static GSourceFuncs clutter_source_funcs = {
clutter_source_prepare,
clutter_source_check,
clutter_source_dispatch
};
static ClutterBackend *
meta_get_clutter_backend (void)
{
MetaBackend *backend = meta_get_backend ();
return meta_backend_get_clutter_backend (backend);
}
static gboolean
init_clutter (MetaBackend *backend,
GError **error)
{
GSource *source;
clutter_set_custom_backend_func (meta_get_clutter_backend);
if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Unable to initialize Clutter");
return FALSE;
}
source = g_source_new (&clutter_source_funcs, sizeof (GSource));
g_source_attach (source, NULL);
g_source_unref (source);
return TRUE;
}
static void
meta_backend_post_init (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
META_BACKEND_GET_CLASS (backend)->post_init (backend);
meta_settings_post_init (priv->settings);
}
static gboolean
meta_backend_initable_init (GInitable *initable,
GCancellable *cancellable,
@ -902,6 +1017,11 @@ meta_backend_initable_init (GInitable *initable,
priv->profiler = meta_profiler_new ();
#endif
if (!init_clutter (backend, error))
return FALSE;
meta_backend_post_init (backend);
return TRUE;
}
@ -917,16 +1037,6 @@ meta_backend_init (MetaBackend *backend)
_backend = backend;
}
static void
meta_backend_post_init (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
META_BACKEND_GET_CLASS (backend)->post_init (backend);
meta_settings_post_init (priv->settings);
}
/**
* meta_backend_get_idle_monitor: (skip)
*/
@ -1158,24 +1268,6 @@ meta_backend_get_stage (MetaBackend *backend)
return priv->stage;
}
void
meta_backend_freeze_updates (MetaBackend *backend)
{
ClutterStage *stage;
stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
clutter_stage_freeze_updates (stage);
}
void
meta_backend_thaw_updates (MetaBackend *backend)
{
ClutterStage *stage;
stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
clutter_stage_thaw_updates (stage);
}
static gboolean
update_last_device (MetaBackend *backend)
{
@ -1258,54 +1350,6 @@ meta_backend_set_client_pointer_constraint (MetaBackend *backend,
priv->client_pointer_constraint = g_object_ref (constraint);
}
/* Mutter is responsible for pulling events off the X queue, so Clutter
* doesn't need (and shouldn't) run its normal event source which polls
* the X fd, but we do have to deal with dispatching events that accumulate
* in the clutter queue. This happens, for example, when clutter generate
* enter/leave events on mouse motion - several events are queued in the
* clutter queue but only one dispatched. It could also happen because of
* explicit calls to clutter_event_put(). We add a very simple custom
* event loop source which is simply responsible for pulling events off
* of the queue and dispatching them before we block for new events.
*/
static gboolean
event_prepare (GSource *source,
gint *timeout_)
{
*timeout_ = -1;
return clutter_events_pending ();
}
static gboolean
event_check (GSource *source)
{
return clutter_events_pending ();
}
static gboolean
event_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data)
{
ClutterEvent *event = clutter_event_get ();
if (event)
{
clutter_do_event (event);
clutter_event_free (event);
}
return TRUE;
}
static GSourceFuncs event_funcs = {
event_prepare,
event_check,
event_dispatch
};
ClutterBackend *
meta_backend_get_clutter_backend (MetaBackend *backend)
{
@ -1320,14 +1364,6 @@ meta_backend_get_clutter_backend (MetaBackend *backend)
return priv->clutter_backend;
}
static ClutterBackend *
meta_get_clutter_backend (void)
{
MetaBackend *backend = meta_get_backend ();
return meta_backend_get_clutter_backend (backend);
}
void
meta_init_backend (GType backend_gtype)
{
@ -1344,29 +1380,6 @@ meta_init_backend (GType backend_gtype)
}
}
/**
* meta_clutter_init: (skip)
*/
void
meta_clutter_init (void)
{
GSource *source;
clutter_set_custom_backend_func (meta_get_clutter_backend);
if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
{
g_warning ("Unable to initialize Clutter.\n");
exit (1);
}
source = g_source_new (&event_funcs, sizeof (GSource));
g_source_attach (source, NULL);
g_source_unref (source);
meta_backend_post_init (_backend);
}
/**
* meta_is_stage_views_enabled:
*

View File

@ -38,8 +38,21 @@
G_DEFINE_INTERFACE (MetaHwCursorInhibitor, meta_hw_cursor_inhibitor,
G_TYPE_OBJECT)
enum
{
PROP_0,
PROP_BACKEND,
N_PROPS
};
static GParamSpec *obj_props[N_PROPS];
struct _MetaCursorRendererPrivate
{
MetaBackend *backend;
float current_x;
float current_y;
@ -89,8 +102,7 @@ align_cursor_position (MetaCursorRenderer *renderer,
{
MetaCursorRendererPrivate *priv =
meta_cursor_renderer_get_instance_private (renderer);
MetaBackend *backend = meta_get_backend ();
ClutterActor *stage = meta_backend_get_stage (backend);
ClutterActor *stage = meta_backend_get_stage (priv->backend);
ClutterStageView *view;
cairo_rectangle_int_t view_layout;
float view_scale;
@ -115,8 +127,7 @@ queue_redraw (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite)
{
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
MetaBackend *backend = meta_get_backend ();
ClutterActor *stage = meta_backend_get_stage (backend);
ClutterActor *stage = meta_backend_get_stage (priv->backend);
CoglTexture *texture;
graphene_rect_t rect = GRAPHENE_RECT_INIT_ZERO;
@ -165,13 +176,54 @@ meta_cursor_renderer_real_update_cursor (MetaCursorRenderer *renderer,
return FALSE;
}
static void
meta_cursor_renderer_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
MetaCursorRenderer *renderer = META_CURSOR_RENDERER (object);
MetaCursorRendererPrivate *priv =
meta_cursor_renderer_get_instance_private (renderer);
switch (prop_id)
{
case PROP_BACKEND:
g_value_set_object (value, priv->backend);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
meta_cursor_renderer_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
MetaCursorRenderer *renderer = META_CURSOR_RENDERER (object);
MetaCursorRendererPrivate *priv =
meta_cursor_renderer_get_instance_private (renderer);
switch (prop_id)
{
case PROP_BACKEND:
priv->backend = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
meta_cursor_renderer_finalize (GObject *object)
{
MetaCursorRenderer *renderer = META_CURSOR_RENDERER (object);
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
MetaBackend *backend = meta_get_backend ();
ClutterActor *stage = meta_backend_get_stage (backend);
ClutterActor *stage = meta_backend_get_stage (priv->backend);
if (priv->stage_overlay)
meta_stage_remove_cursor_overlay (META_STAGE (stage), priv->stage_overlay);
@ -186,9 +238,21 @@ meta_cursor_renderer_class_init (MetaCursorRendererClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = meta_cursor_renderer_get_property;
object_class->set_property = meta_cursor_renderer_set_property;
object_class->finalize = meta_cursor_renderer_finalize;
klass->update_cursor = meta_cursor_renderer_real_update_cursor;
obj_props[PROP_BACKEND] =
g_param_spec_object ("backend",
"backend",
"MetaBackend",
META_TYPE_BACKEND,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, obj_props);
signals[CURSOR_PAINTED] = g_signal_new ("cursor-painted",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
@ -273,9 +337,11 @@ meta_cursor_renderer_update_cursor (MetaCursorRenderer *renderer,
}
MetaCursorRenderer *
meta_cursor_renderer_new (void)
meta_cursor_renderer_new (MetaBackend *backend)
{
return g_object_new (META_TYPE_CURSOR_RENDERER, NULL);
return g_object_new (META_TYPE_CURSOR_RENDERER,
"backend", backend,
NULL);
}
void

View File

@ -54,7 +54,7 @@ struct _MetaCursorRendererClass
MetaCursorSprite *cursor_sprite);
};
MetaCursorRenderer * meta_cursor_renderer_new (void);
MetaCursorRenderer * meta_cursor_renderer_new (MetaBackend *backend);
void meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite);

View File

@ -84,6 +84,7 @@ translate_meta_cursor (MetaCursor cursor)
return "crosshair";
case META_CURSOR_IBEAM:
return "xterm";
case META_CURSOR_BLANK:
case META_CURSOR_NONE:
case META_CURSOR_LAST:
break;
@ -93,6 +94,48 @@ translate_meta_cursor (MetaCursor cursor)
return NULL;
}
static Cursor
create_blank_cursor (Display *xdisplay)
{
Pixmap pixmap;
XColor color;
Cursor cursor;
XGCValues gc_values;
GC gc;
pixmap = XCreatePixmap (xdisplay, DefaultRootWindow (xdisplay), 1, 1, 1);
gc_values.foreground = BlackPixel (xdisplay, DefaultScreen (xdisplay));
gc = XCreateGC (xdisplay, pixmap, GCForeground, &gc_values);
XFillRectangle (xdisplay, pixmap, gc, 0, 0, 1, 1);
color.pixel = 0;
color.red = color.blue = color.green = 0;
cursor = XCreatePixmapCursor (xdisplay, pixmap, pixmap, &color, &color, 1, 1);
XFreeGC (xdisplay, gc);
XFreePixmap (xdisplay, pixmap);
return cursor;
}
static XcursorImages *
create_blank_cursor_images (void)
{
XcursorImages *images;
images = XcursorImagesCreate (1);
images->images[0] = XcursorImageCreate (1, 1);
images->images[0]->xhot = 0;
images->images[0]->yhot = 0;
memset (images->images[0]->pixels, 0, sizeof(int32_t));
return images;
}
MetaCursor
meta_cursor_sprite_xcursor_get_cursor (MetaCursorSpriteXcursor *sprite_xcursor)
{
@ -103,12 +146,18 @@ Cursor
meta_create_x_cursor (Display *xdisplay,
MetaCursor cursor)
{
if (cursor == META_CURSOR_BLANK)
return create_blank_cursor (xdisplay);
return XcursorLibraryLoadCursor (xdisplay, translate_meta_cursor (cursor));
}
static XcursorImages *
load_cursor_on_client (MetaCursor cursor, int scale)
{
if (cursor == META_CURSOR_BLANK)
return create_blank_cursor_images ();
return XcursorLibraryLoadImages (translate_meta_cursor (cursor),
meta_prefs_get_cursor_theme (),
meta_prefs_get_cursor_size () * scale);

Some files were not shown because too many files have changed in this diff Show More