1
0
Fork 0
Commit graph

203 commits

Author SHA1 Message Date
Emmanuele Bassi
ee33357fd5 stage: Only clutter_stage_get_default() creates the default stage
The introduction of the StageManager in 0.8 implied that the first Stage
instance to be created was automatically assigned the status of "default
stage". This was all well and good, since the default stage was created
behind the curtains by the initialization sequence.

Now that the initialization sequence does not create a default stage any
longer, it means that the first stage created using clutter_stage_new()
gets to be the default, and all special and warm and fuzzy - which also
means that the first stage created by clutter_stage_new() cannot be
destroyed or handled as any other stage. Whoopsie.

Let's go back to the old semantics: the stage created by the first
invocation of clutter_stage_get_default() is the default stage, and
nothing else can be set as default. One day we'll be able to break the
API and the whole default stage business will be a thing of the past.
2010-02-18 17:01:57 +00:00
Chris Lord
1117b6a9ac [stage-x11] Fix switching fullscreen mode
Setting/unsetting fullscreen on a mapped or unmapped window now works
correctly.

If you unfullscreen a window that was initially full-screened, it will
unset the fullscreen hint and the WM will likely push the size down to
the largest valid size.

If the window was previously un-fullscreened, Clutter will restore the
previous size.

Fullscreening also now works if the WM switches the hint without the
application's knowledge (as happens when you resize a window to the size
of the screen, for example, with stock metacity).
2010-02-16 14:55:53 +00:00
Chris Lord
2fcb644e4f [stage] Fix some races to do with window resizing
When we resize, we relied on the stage's allocate to re-initialise the
GL viewport. Unfortunately, if we resized within Clutter, the new size
was cached before the window is actually resized, so glViewport wasn't
being called after resizing (some of the time, it's a race condition).

Change the way resizing works slightly so that we only resize when the
geometry size doesn't match our preferred size, and queue a relayout on
ConfigureNotify so the glViewport gets called.

Also change window creation slightly so that setting the size of a
window before it's realized works correctly.
2010-02-15 18:56:50 +00:00
Emmanuele Bassi
2229cafc38 stage: Add sanity checks for get_pending_swaps()
The master clock might have a Stage during its destruction phase,
without a StageWindow attached to it. If this happens and we try
to dereference the StageWindow to get its class and call a virtual
function we might experience some slight turbulence and... then...
explode.

http://bugzilla.openedhand.com/show_bug.cgi?id=1987
2010-02-15 12:04:50 +00:00
Emmanuele Bassi
c2d434e3af analysis: ClutterStage
Remove unused variables.
2010-02-12 14:50:11 +00:00
Robert Bragg
b898f0e227 never presume queuing redraws on invisible actors is redundant
This replaces code like this:
  if (CLUTTER_ACTOR_IS_VISIBLE (self))
    clutter_actor_queue_redraw (self);
with:
  clutter_actor_queue_redraw (self);

clutter_actor_queue_redraw internally knows what can be optimized when
the actor is not visible, but it also knows that the queue_redraw signal
must always be sent in case a ClutterClone is cloning a hidden actor.
2010-02-12 14:05:00 +00:00
Robert Bragg
5d702853b8 glx backend: Adds support for GLX_INTEL_swap_event
If your OpenGL driver supports GLX_INTEL_swap_event that means when
glXSwapBuffers is called it returns immediatly and an XEvent is sent when
the actual swap has finished.

Clutter can use the events that notify swap completion as a means to
throttle rendering in the master clock without blocking the CPU and so it
should help improve the performance of CPU bound applications.
2010-02-09 22:19:41 +00:00
Chris Lord
c82c94e620 [stage-x11] Set the default size differently
We want to set the default size without triggering the layout machinary,
so change the window creation process slightly so we start with a
640x480 window.
2010-02-07 19:17:43 +01:00
Chris Lord
b968defae9 [stage] Set default size correctly
Due to the way the new sizing works, clutter stage must set its size in
init (to maintain old behaviour) and the properties on the X11 stage
must be initialised to 1x1 so that it actually goes ahead with the
resize.

Fixes stages that aren't user resizable and have no size set from
appearing at 1x1.
2010-02-07 14:18:14 +01:00
Chris Lord
cea9de7f04 [stage] Now that get_geometry works, use it
We want the actual window geometry in clutter_stage_set_minimum_size,
not the set size. Now that the geometry function has been changed to do
what it says, use it.
2010-02-06 15:41:01 +01:00
Chris Lord
27e33aa14f [stage] Get the current size correctly
Get the current size of the stage correctly in
clutter_stage_set_minimum_size. The get_geometry StageWindow function is
not equivalent of the current size, use clutter_actor_get_size().
2010-02-06 14:59:51 +01:00
Chris Lord
be11564b55 [stage] Set minimum width/height to 1x1
Whoops, to maintain the old behaviour, make sure the default minimum
width/height are 1x1.
2010-02-06 14:04:47 +01:00
Chris Lord
fd11d3098f [stage] Add set/get_minumum_size
Add two functions to set/get the minimum stage size. This takes effect
when a stage is set to user resizable.
2010-02-06 11:23:37 +00:00
Emmanuele Bassi
ede2cbfab0 stage: Create the default stage on demand
Instead of creating the default stage during initialization we can
now safely create it whenever clutter_stage_get_default() is called.

To maintain the invariant, the default stage is immediately realized
by Clutter itself.
2010-02-03 16:34:27 +00:00
Emmanuele Bassi
a8daaa8222 stage: Move default title in Stage.init
The default title should be set from within clutter_stage_init(); at
that point clutter_init() must have been called.
2010-02-03 16:34:27 +00:00
Emmanuele Bassi
6fbed66add Delay default stage creation
The default stage creation should be delayed as much as possible,
ideally at the end of the init() process.
2010-02-03 16:34:27 +00:00
Emmanuele Bassi
5f1c8a17e4 Merge branch 'device-manager'
* device-manager: (37 commits)
  x11: Re-enable XI1 extension keyboards
  x11: Always handle core device events before XI events
  docs: Documentation fixes for DeviceManager
  device-manager: Fix the signals definition
  docs: Add sections for InputDevice and DeviceManager
  docs: Add clutter_input_device_get_device_name()
  tests: Print out the device details on motion
  Always register core devices
  device: Remove unused is_default member
  win32: Experimental implementation of device support
  tests: Print the device name, as well as its Id
  x11: Fill out the :name property of the InputDevices
  device: Add the :name property to InputDevice
  x11: Store core devices on the X11 Backend singleton
  device: Unset the cursor actor when leaving the stage
  device: Add pointer actor getter
  x11: Discard the LeaveNotify for off-stage ButtonRelease
  device: Do not overwrite the stage for an InputDevice
  event: Off-stage button releases have a click count of 1
  event: Scroll events do not have click count
  ...
2010-02-01 11:26:56 +00:00
Emmanuele Bassi
579a9a2665 stage: Add :key-focus property
ClutterStage has both set_key_focus() and get_key_focus() methods, but
there is no :key-focus property. This means that it is not possible to
get notifications when the key-focus has changes except by connecting to
both the ::key-focus-in and ::key-focus-out signals and do additional
bookkeeping.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-02-01 11:09:13 +00:00
Emmanuele Bassi
8736b53d7c device: Do not overwrite the stage for an InputDevice
The Stage field of an InputDevice is set by the backend, whenever the
pointer enters or leaves the Stage. The Stage should not overwrite the
stage field for every event it processes.
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
9506510d1c Move all picking-related operations inside InputDevice
The InputDevice objects stores pointer coordinates, state, stage and
the actor under the cursor, so if the current backend provides us with
one attached to the Event structure then we want the InputDevice itself
to update its state and give us the ClutterActor underneath the
pointer's cursor.
2010-01-20 00:38:08 +00:00
Emmanuele Bassi
1c6ffc8a23 stage: Add the delete-event signal
Using the ::event signal to match the CLUTTER_DELETE event type (and
block the stage destruction) can be costly, since it means checking
every single event.

The ::delete-event signal is similar in spirit to any other specialized
signal handler dealing with events, and retains the same semantics.
2010-01-12 15:58:27 +00:00
Robert Bragg
0057755854 profiling: Adds initial UProf support across clutter
UProf is a small library that aims to help applications/libraries provide
domain specific reports about performance.  It currently provides high
precision timer primitives (rdtsc on x86) and simple counters, the ability
to link statistics between optional components at runtime and makes report
generation easy.

This adds initial accounting for:
- Total mainloop time
- Painting
- Picking
- Layouting
- Idle time

The timing done by uprof is of wall clock time. It's not based on stochastic
samples we simply sample a counter at the start and end.  When dealing with
the complexities of GPU drivers and with various kinds of IO this form of
profiling can be quite enlightening as it will be able to represent where
your application is blocking unlike tools such as sysprof.

To enable uprof accounting you must configure Clutter with --enable-profile
and have uprof-0.2 installed from git://git.moblin.org/uprof

If you want to see a report of statistics when Clutter applications exit you
should export CLUTTER_PROFILE_OUTPUT_REPORT=1 before running them.

Just a final word of caution; this stuff is new and the manual nature of
adding uprof instrumentation means it is prone to some errors when modifying
code.  This just means that when you question strange results don't rule out
a mistake in the instrumentation.  Obviously though we hope the benfits out
weigh e.g.  by focusing on very key stats and by having automatic reporting.
2010-01-08 20:19:49 +00:00
Emmanuele Bassi
1208e47198 stage: Add accessors for :use-alpha
Use real accessors for the :use-alpha property.
2009-12-09 02:05:24 +00:00
Emmanuele Bassi
3a3c815286 stage: Premultiply the stage color
In case we are using Stage:use-alpha then we need to premultiply the
stage color to get the correct blending from the compositor.
2009-12-09 01:46:09 +00:00
Emmanuele Bassi
6a3f6a460e stage: Composite the opacity with the alpha channel
The Stage's opacity should be composited with the alpha component of the
Stage's background color.
2009-12-07 17:35:17 +00:00
Emmanuele Bassi
2f7ff4d3e3 stage: Add :use-alpha property
The ClutterStage:use-alpha property is used to let a stage know that it
should honour the alpha component of the ClutterStage:color property.

If :use-alpha is set to FALSE the stage always uses the full opacity
when clearing itself before a paint(); otherwise, the alpha value is
used.
2009-12-01 16:25:54 +00:00
Robert Bragg
47db7af4d3 picking: avoid redundant picking geometry for the stage.
The stage's pick id can be written to the framebuffer when we call
cogl_clear so there's no need for the stage to also chain up in it's pick
function resulting in clutter-actor.c also emitting a rectangle for the
stage.
2009-11-27 00:43:57 +00:00
Neil Roberts
568c29ba49 Validate that the GL version is >= 1.2
There is a new internal Cogl function called _cogl_check_driver_valid
which looks at the value of the GL_VERSION string to determine whether
the driver is supported. Clutter now calls this after the stage is
realized. If it fails then the stage is marked as unrealized and a
warning is shown.

_cogl_features_init now also checks the version number before getting
the function pointers for glBlendFuncSeparate and
glBlendEquationSeparate. It is not safe to just check for the presence
of the functions because some drivers may define the function without
fully implementing the spec.

The GLES version of _cogl_check_driver_valid just always returns TRUE
because there are no version requirements yet.

Eventually the function could also check for mandatory extensions if
there were any.

http://bugzilla.openedhand.com/show_bug.cgi?id=1875
2009-11-13 15:55:48 +00:00
Neil Roberts
568ad044eb Clear pending events for a stage when it is destroyed
We can not process events for a stage that has been destroyed so we
should make sure that the events for the stage are removed from the
global event queue during dispose.

http://bugzilla.openedhand.com/show_bug.cgi?id=1882
2009-11-13 15:27:38 +00:00
Robert Bragg
12af275139 [cogl] Make sure Cogl always knows the current window geometry
Because Cogl defines the origin of viewport and window coordinates to be
top-left it always needs to know the size of the current window so that Cogl
window/viewport coordinates can be transformed into OpenGL coordinates.

This also fixes cogl_read_pixels to use the current draw buffer height
instead of the viewport height to determine the OpenGL y coordinate to use
for glReadPixels.
2009-11-04 03:23:20 +00:00
Robert Bragg
15d7a86621 [backends] Remove the idea of offscreen stages from all backends
The only backend that tried to implement offscreen stages was the GLX backend
and even this has apparently be broken for some time without anyone noticing.

The property still remains and since the property already clearly states that
it may not work I don't expect anyone to notice.

This simplifies quite a bit of the GLX code which is very desireable from the
POV that we want to start migrating window system code down to Cogl and the
simpler the code is the more straight forward this work will be.

In the future when Cogl has a nicely designed API for framebuffer objects then
re-implementing offscreen stages cleanly for *all* backends should be quite
straightforward.
2009-10-16 18:58:47 +01:00
Emmanuele Bassi
6988744db7 [stage] Rework the Stage implementation class
Instead of using ClutterActor for the base class of the Stage
implementation we should extend the StageWindow interface with
the required bits (geometry, realization) and use a simple object
class.

This require a wee bit of changes across Backend, Stage and
StageWindow, even though it's mostly re-shuffling.

First of all, StageWindow should get new virtual functions:

  * geometry:
    - resize()
    - get_geometry()

  * realization
    - realize()
    - unrealize()

This covers all the bits that we use from ClutterActor currently
inside the stage implementations.

The ClutterBackend::create_stage() virtual function should create
a StageWindow, and not an Actor (it should always have been; the
fact that it returned an Actor was a leak of the black magic going
on underneath). Since we never guaranteed ABI compatibility for
the Backend class, this is not a problem.

Internally to ClutterStage we can finally drop the shenanigans of
setting/unsetting actor flags on the implementation: if the realization
succeeds, for instance, we set the REALIZED flag on the Stage and
we're done.

As an initial proof of concept, the X11 and GLX stage implementations
have been ported to the New World Order(tm) and show no regressions.
2009-09-08 10:52:58 +01:00
Colin Walters
d3e06bc1e5 Add (allow-none) for clutter_stage_set_key_focus()
The @actor argument can be NULL to unset the key focus.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-08-13 10:49:39 +01:00
Emmanuele Bassi
fe0e7f9f74 [stage] Add a warning for :offscreen usage
The Stage:offscreen property hasn't been tested for ages, and it
should really just use a FBO, not indirect rendering on a X Pixmap
only on X11. There are better ways anyway to get the current
contents of ClutterStage as a buffer anyway.

We might remove it at any later date, or actually make it work
properly.
2009-07-27 15:42:31 +01:00
Emmanuele Bassi
56ef6727b5 Allow disabling motion event throttling
It might be desirable for some applications and/or platforms to get
every motion event that was delivered to Clutter from the windowing
backend. By adding a per-stage flag we can bypass the throttling
done when processing the events.

  http://bugzilla.openedhand.com/show_bug.cgi?id=1665
2009-07-20 11:44:52 +01:00
Neil Roberts
7b811f8be4 [stage] Force an allocation before showing the stage
A lot of applications change the size of the stage from the default
before the stage is initially shown. The size change won't take affect
until the first allocation run. However we want the window to be at
the correct size when we first map it so we should force an allocation
run before showing the stage.

There was an explicit call to XResizeWindow in
clutter_stage_x11_show. This is not needed anymore because
XResizeWindow will already have been called by the allocate method.
2009-07-17 12:43:52 +01:00
Robert Bragg
24ca92951f [cogl] Adds cogl_read_pixels to replace direct use of glReadPixels
To allow for flushing of batched geometry within Cogl we can't support users
directly calling glReadPixels.  glReadPixels is also awkward, not least
because it returns upside down image data.

All the unit tests have been swithed over and clutter_stage_read_pixels now
sits on top of this too.
2009-06-29 23:49:06 +01:00
Emmanuele Bassi
c6fba47a52 Hide clutter_context_get_default()
The clutter_context_get_default() function is private, but shared
across Clutter. For this reason, it should be prefixed by '_' so
that the symbol is hidden from the shared object.
2009-06-18 14:20:28 +01:00
Emmanuele Bassi
9f83e7dc2e [stage] Remove an assertion
We might get a size request on destruction, so it should be safe
to avoid an assertion failure because we don't have the stage
implementation anymore.
2009-06-16 16:43:00 +01:00
Robert Bragg
96827db740 Bug 1406 - Handling of premultiplication in clutter
Merge branch 'premultiplication'

[cogl-texture docs] Improves the documentation of the internal_format args
[test-premult] Adds a unit test for texture upload premultiplication semantics
[fog] Document that fogging only works with opaque or unmultipled colors
[test-blend-strings] Explicitly request RGBA_888 tex format for test textures
[premultiplication] Be more conservative with what data gets premultiplied
[bitmap] Fixes _cogl_bitmap_fallback_unpremult
[cogl-bitmap] Fix minor copy and paste error in _cogl_bitmap_fallback_premult
Avoid unnecesary unpremultiplication when saving to local data
Don't unpremultiply Cairo data
Default to a blend function that expects premultiplied colors
Implement premultiplication for CoglBitmap
Use correct texture format for pixmap textures and FBO's
Add cogl_color_premultiply()
2009-06-11 16:00:28 +01:00
Robert Bragg
70636b4815 [fog] Document that fogging only works with opaque or unmultipled colors
The fixed function fogging provided by OpenGL only works with unmultiplied
colors (or if the color has an alpha of 1.0) so since we now premultiply
textures and colors by default a note to this affect has been added to
clutter_stage_set_fog and cogl_set_fog.

test-depth.c no longer uses clutter_stage_set_fog for this reason.

In the future when we can depend on fragment shaders we should also be
able to support fogging of premultiplied primitives.
2009-06-11 14:17:53 +01:00
Emmanuele Bassi
61c45da90a Bug 1637 - Master clock improvements
Merge branch 'master-clock-updates'

* master-clock-updates: (22 commits)
  Change the paint forcing on the Text cache text
  [timelines] Improve marker hit check and don't fudge the delta
  Revert "[timeline] Don't clamp the elapsed time when a looping tl reaches the end"
  [tests] Don't add a newline to the end of g_test_message calls
  [test-timeline] Add a marker at the beginning of the timeline
  [timeline] Don't clamp the elapsed time when a looping tl reaches the end
  [master-clock] Throttle if no redraw was performed
  [docs] Update Clutter's API reference
  Force a paint instead of calling clutter_redraw()
  Fix clutter_redraw() to match the redraw cycle
  Run the repaint functions inside the redraw cycle
  Remove useless manual timeline ticking
  Move elapsed-time calculations into ClutterTimeline
  Limit the frame rate when not syncing to VBLANK
  Decrease the main-loop priority of the frame cycle
  Avoid motion-compression in test-picking test
  Compress events as part of the frame cycle
  Remove stage update idle and do updates from the master clock
  Call g_main_context_wakeup() when we start running timelines
  Remove unused msecs_delta member
  ...
2009-06-11 13:01:34 +01:00
Tommi Komulainen
bf0c21e015 stage: set key focus actor to NULL before emitting focus-out
Someone might hide the previously focused actor in the focus-out signal
handler and as key focus still appears to be on that actor we'd get
re-entrant call and get glib critical from g_object_weak_unref

This changes clutter_stage_get_key_focus() to return stage/NULL during
focus-out signal emission. It used to be the actor focus-out was being
emitted on.

Fixes bug:

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-11 12:14:10 +01:00
Neil Roberts
acf7722a41 [master-clock] Throttle if no redraw was performed
A flag in the master clock is now set whenever the dispatch caused an
actual redraw of a stage. If this flag is not set during the prepare
and check functions then it will resort to limiting the redraw
attempts to the default frame rate as if vblank syncing was
disabled. Otherwise if a timeline is running that does not cause the
scene to change then it would busy-wait with 100% CPU until the next
frame.

This fix was suggested by Owen Taylor in:

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-10 15:50:27 +01:00
Emmanuele Bassi
0f9dea0337 Force a paint instead of calling clutter_redraw()
We do not need the whole redraw machinery inside
clutter_stage_read_pixels(): instead, we want Clutter to drop everything,
paint and call glReadPixels() with the current buffer.
2009-06-10 14:52:53 +01:00
Emmanuele Bassi
e1cac4fece Fix clutter_redraw() to match the redraw cycle
The clutter_redraw() function is used by embedding toolkits to
force a redraw on a stage. Since everything is performed by
toggling a flag inside the Stage itself and then letting the
master clock advance, we need a ClutterStage method to ensure
that we start the master clock and redraw.
2009-06-09 16:29:29 +01:00
Owen W. Taylor
dcd8d28314 Limit the frame rate when not syncing to VBLANK
clutter-master-clock.c clutter-master-clock.h: When the
  SYNC_TO_VBLANK feature is not available, wait for 1/frame_rate
  seconds since the start of the last frame before drawing the next
  frame. Add _clutter_master_clock_start_running() to abstract
  the usage of g_main_context_wakeup()

clutter-stage.c: Add _clutter_master_clock_start_running()

clutter-main.c: Update docs for clutter_set_default_frame_rate()
  clutter_get_default_frame_rate() to no longer talk about timeline
  frame rates.

test-text-perf.c test-text.c: Set a frame rate of 1000fps so that
  frame-rate limiting doesn't affect the result.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-09 15:03:56 +01:00
Owen W. Taylor
6e69692e22 Compress events as part of the frame cycle
Instead of trying to guess about which motion events are
extraneous, queue up all events until we process a frame.
This allows us to look ahead and reliably compress consecutive
sequence of motion events.

clutter-main.c: Feed received events to the stage for queueing.
  Remove old compression code. Remove clutter_get_motion_events_frequency()
  clutter_set_motion_events_frequency()
clutter-stage.c: Keep a queue of pending events.
clutter-master-clock.c: Add processng of queued events to the
  clock source dispatch function.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-09 15:03:56 +01:00
Owen W. Taylor
89a8fd7755 Remove stage update idle and do updates from the master clock
When a redraw is queued on a stage, simply set a flag; then in
the check/prepare functions of the master clock source, check
for stages that need redrawing.

This avoids the complexity of having multiple competing sources
at the same priority and makes the update ordering more reliable and
understandable.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-06-09 15:03:56 +01:00
Emmanuele Bassi
19c2e66398 [docs] Various gtk-docs fixes 2009-06-09 14:47:36 +01:00