1. 29 Sep, 2010 37 commits
    • Emmanuele Bassi's avatar
      Move default paint volume computation into a function · 16f7ee13
      Emmanuele Bassi authored
      This should reduce the amount of copy and paste for actor sub-classes
      that use the default paint volume from the allocation.
      16f7ee13
    • Robert Bragg's avatar
      paint_volume: assert non-NULL pv in _volume_copy · fd41024d
      Robert Bragg authored
      Instead of carefully checking if the user passes NULL to
      clutter_paint_volume_copy we now simply use g_return_val_if_fail.
      fd41024d
    • Robert Bragg's avatar
      paint_volume: Splits out clutter_paint_volume code · 3040b140
      Robert Bragg authored
      This splits out all the clutter_paint_volume code from clutter-actor.c
      into clutter-paint-volume.c. Since clutter-actor.c and
      clutter-paint-volume.c both needed the functionality of
      _fully_transform_vertices, this function has now been moved to
      clutter-utils.c as _clutter_util_fully_transform_vertices.
      3040b140
    • Robert Bragg's avatar
      actor: make default get_paint_volume more conservative · 72eeb8e8
      Robert Bragg authored
      There are too many examples where the default assumption that an actor
      paints inside its allocation isn't true, so we now return FALSE in the
      base implementation instead. This means that by default we are saying
      "we don't know the paint volume of the actor", so developers need to
      implement the get_paint_volume virtual to take advantage of culling and
      clipped redraws with their actors.
      
      This patch provides very conservative get_paint_volume implementations
      for ClutterTexture, ClutterCairoTexture, ClutterRectangle and
      ClutterText which all explicitly check the actor's object type to avoid
      making any assumptions about subclasses.
      72eeb8e8
    • Robert Bragg's avatar
      actor: don't always check needs_allocation for clipped redraw · d9a7f1b0
      Robert Bragg authored
      We were always explicitly checking priv->needs_allocation in
      _clutter_actor_queue_redraw_with_clip, but we only need to do that if
      the CLUTTER_REDRAW_CLIPPED_TO_ALLOCATION flag is used.
      d9a7f1b0
    • Robert Bragg's avatar
      actor: new actors should start with an empty paint box · 072595a1
      Robert Bragg authored
      This initializes priv->last_paint_box with a degenerate box, so a newly
      allocated actor added to the scenegraph and made visible only needs to
      trigger a redraw of its initial position. If we don't have a valid
      last_paint_box though we would instead trigger a full stage redraw.
      072595a1
    • Robert Bragg's avatar
      actor: when culling/clipped redraws disable ignore paint box · c2ea35b5
      Robert Bragg authored
      To make comparing the performance with culling/clipped redraws
      enabled/disabled fairer we now avoid querying the paint box when they
      are disabled, so that results should reflect how the cost of
      transforming paint volumes into screen space etc gets offset against the
      benefit of culling.
      c2ea35b5
    • Robert Bragg's avatar
      stage: only update viewport when allocation changes · 5d1600d6
      Robert Bragg authored
      In clutter_stage_allocate at the end we were always querying the latest
      allocation set and using the geometry to assert the viewport and then
      kicking a full redraw. These only need to be done when the allocation
      really changes, so we now read the previous allocation at the start of
      the function and compare at the end. This was stopping clipped redraws
      from being used in a lot of cases.
      5d1600d6
    • Robert Bragg's avatar
      glx: queue full redraws for the first 2 frames · 1e7f22db
      Robert Bragg authored
      To consider that we've see a number of drivers that can struggle to get
      going and may produce a bad first frame we now force the first 2 frames
      to be full redraws. This became a serious issue after we started using
      clipped redraws more aggressively because we assumed that after the
      first frame the full framebuffer was valid and we only redraw the
      content that changes. With buggy drivers though, applications would be
      left with junk covering a lot of the stage until some event triggered a
      full redraw.
      1e7f22db
    • Robert Bragg's avatar
      x11: minimize nasty artefacts when resizing windows · 771348b3
      Robert Bragg authored
      This is a workaround for a race condition when resizing windows while
      there are in-flight glXCopySubBuffer blits happening.
      
      The problem stems from the fact that rectangles for the blits are
      described relative to the bottom left of the window and because we can't
      guarantee control over the X window gravity used when resizing so the
      gravity is typically NorthWest not SouthWest.
      
      This means if you grow a window vertically the server will make sure to
      place the old contents of the window at the top-left/north-west of your
      new larger window, but that may happen asynchronous to GLX preparing to
      do a blit specified relative to the bottom-left/south-west of the window
      (based on the old smaller window geometry).
      
      When the GLX issued blit finally happens relative to the new bottom of
      your window, the destination will have shifted relative to the top-left
      where all the pixels you care about are so it will result in a nasty
      artefact making resizing look very ugly!
      
      We can't currently fix this completely, in-part because the window
      manager tends to trample any gravity we might set.  This workaround
      instead simply disables blits for a while if we are notified of any
      resizes happening so if the user is resizing a window via the window
      manager then they may see an artefact for one frame but then we will
      fallback to redrawing the full stage until the cooling off period is
      over.
      771348b3
    • Robert Bragg's avatar
      x11: Queue clipped redraws for Expose events · 012e4ab1
      Robert Bragg authored
      Instead of triggering a full stage redraw for Expose events we use the
      geometry of the exposed region given in the event to queue a clipped
      redraw of the stage.
      012e4ab1
    • Robert Bragg's avatar
      cogl: removes unused _cogl_setup_viewport · 105451d1
      Robert Bragg authored
      Clutter has now taken responsibility for managing its viewport,
      projection matrix and view transform as part of ClutterStage so
      _cogl_setup_viewport is no longer used by anything, and since it's quite
      an obscure API anyway it's we've taken the opportunity to remove the
      function.
      105451d1
    • Robert Bragg's avatar
      stage: Sometimes really force a full redraw · 95ff71d0
      Robert Bragg authored
      Since clutter_actor_queue_redraw now automatically clips redraws
      according to the paint volume of the actor we have to be careful to
      ensure we really force a full redraw when the stage is allocated a new
      size or the stage viewport changes.
      95ff71d0
    • Robert Bragg's avatar
      actor: don't immediately queue redraw when queuing relayout · 2235e705
      Robert Bragg authored
      We have bent the originally documented semantics a bit so now where we
      say "Queueing a new layout automatically queues a redraw as well" it
      might be clearer to say "Queuing a new layout implicitly queues a redraw
      as well if anything in the layout changes".
      
      This should be close enough to the original semantics to not cause any
      problems.
      
      Without this change then we we fail to take advantage of clipped redraws
      in a lot of cases because queuing a redraw with priv->needs_allocation
      == TRUE will automatically be promoted to a full stage redraw since it's
      not possible to determine a valid paint-volume.
      
      Also queuing a redraw here will end up registering a redundant clipped
      redraw for the current location, doing quite a lot of redundant
      transforms, and then later when re-allocated during layouting another
      queue redraw would happen with the correct paint-volume.
      2235e705
    • Robert Bragg's avatar
      Use paint volumes to do automatic culling · b499696d
      Robert Bragg authored
      This uses actor paint volumes to perform culling during
      clutter_actor_paint.
      
      When performing a clipped redraw (because only a few localized actors
      changed) then as we traverse the scenegraph painting the actors we can
      now ignore actors that don't intersect the clip region. Early testing
      shows this can have a big performance benefit; e.g. 100% fps improvement
      for test-state with culling enabled and we hope that there are even much
      more compelling examples than that in the real world,
      
      Most Clutter applications are 2Dish interfaces and have quite a lot of
      actors that get continuously painted when anything is animated. The
      dynamic actors are often localized to an area of user focus though so
      with culling we can completely avoid painting any of the static actors
      outside the current clip region.
      
      Obviously the cost of culling has to be offset against the cost of
      painting to determine if it's a win, but our (limited) testing suggests
      it should be a win for most applications.
      
      Note: we hope we will be able to also bring another performance bump
      from culling with another iteration - hopefully in the 1.6 cycle - to
      avoid doing the culling in screen space and instead do it in the stage's
      model space. This will hopefully let us minimize the cost of
      transforming the actor volumes for culling.
      b499696d
    • Robert Bragg's avatar
      actor: Use paint volumes to always queue clipped redraws · ef8be9e2
      Robert Bragg authored
      This makes clutter_actor_queue_redraw transparently use an actor's paint
      volume to queue a clipped redraw.
      
      We save the actors paint box each time it is painted so that when
      clutter_actor_queue_redraw is called we can determine the old and new
      location of the actor so we know the full bounds of what must be redrawn
      to clear its old view and show the new.
      ef8be9e2
    • Robert Bragg's avatar
      actor: make _transform_and_project_box static · 13c4d7b9
      Robert Bragg authored
      This makes _clutter_actor_transform_and_project_box a static function
      and removes the prototype from clutter-private.h since it is no longer
      used outside clutter-actor.c
      13c4d7b9
    • Robert Bragg's avatar
      actor: _real_queue_relayout shouldn't queue redraw · 120d7595
      Robert Bragg authored
      The base implementation for the actor queue_relayout method was queuing
      an implicit redraw, but there shouldn't be anything implied from the
      mere process of queuing a redraw that should force us to queue a redraw.
      If actors are moved as a part of relayouting later then they will queue
      a redraw.  Also clutter_actor_queue_relayout() still also explicitly
      queues a redraw so I think this may have been doubly redundant.
      120d7595
    • Robert Bragg's avatar
      actor: re-allocation implies need to redraw · dc976922
      Robert Bragg authored
      If clutter_actor_allocate finds it necessary to update an actors
      allocation then it now also queue a redraw of that actor. Currently we
      queue redraws for actors very early on when queuing a relayout instead
      of waiting to determine the final outcome of relayouting to determine if
      a redraw is really required. With this in place we can move away from
      preemptive queuing of redraws.
      dc976922
    • Robert Bragg's avatar
      actor: separate the queue redraw code · 267e458a
      Robert Bragg authored
      clutter_actor_queue_relayout currently queues a relayout and a redraw,
      but the plan is to change it to only queue a relayout and honour the
      documentation by assuming that the process of relayouting will
      result queuing redraws for any actors whos allocation changes.
      
      This doesn't make that change it just adds an internal
      _clutter_actor_queue_only_relayout function which
      clutter_actor_queue_relayout now uses as well as calling
      clutter_actor_queue_redraw.
      267e458a
    • Robert Bragg's avatar
      stage: make it possible to queue a relayout only · 6d5f6449
      Robert Bragg authored
      This adds a private ->relayout_pending boolean similar in spirit to
      redraw_pending. This will allow us to queue a relayout without
      implicitly queueing a redraw; instead we can depend on the actions
      of a relayout to queue any necessary redraw.
      6d5f6449
    • Robert Bragg's avatar
      texture: Forward queue redraw/relayout for fbos · f8a6e36f
      Robert Bragg authored
      When clutter_texture_new_from_actor is use we need to track when the
      source actor queues a redraw or a relayout so we can also queue a redraw
      or relayout for the texture actor.
      f8a6e36f
    • Robert Bragg's avatar
      Queue clipped redraws work in terms of paint volumes · 1ea7145e
      Robert Bragg authored
      There is an internal _clutter_actor_queue_redraw_with_clip API that gets
      used for texture-from-pixmap to minimize what we redraw in response to
      Damage events. It was previously working in terms of a ClutterActorBox
      but it has now been changed so an actor can queue a redraw of volume
      instead.
      
      The plan is that clutter_actor_queue_redraw will start to transparently
      use _clutter_actor_queue_redraw_with_clip when it can determine a paint
      volume for the actor.
      1ea7145e
    • Robert Bragg's avatar
      blur-effect: fix paint volume padding · f3bffe5c
      Robert Bragg authored
      For the blur effect we use a BLUR_PADDING constant to pad out the volume
      of the source actor on the x and y axis. Previously we were offsetting
      the origin negatively using BLUR_PADDING and then adding BLUR_PADDING
      to the width and height, but we should have been adding 2*BLUR_PADDING
      instead.
      f3bffe5c
    • Robert Bragg's avatar
      debug: CLUTTER_DEBUG_REDRAWS: disable clipped redraws · f60703cb
      Robert Bragg authored
      This ensures that clipped redraws are disabled when using
      CLUTTER_PAINT=redraws. This may seem unintuitive given that this option
      is for debugging clipped redraws, but we can't draw an outline outside
      the clip region and anything we draw inside the clip region is liable to
      leave a trailing mess on the screen since it won't be cleared up by
      later clipped redraws.
      f60703cb
    • Robert Bragg's avatar
      paint volumes: CLUTTER_PAINT=paint-volumes debug option · 066220f9
      Robert Bragg authored
      This adds a debug option to visualize the paint volumes of all actors.
      When CLUTTER_PAINT=paint-volumes is exported in the environment before
      running a Clutter application then all actors will have their bounding
      volume drawn in green with a label corresponding to the actors type.
      066220f9
    • Robert Bragg's avatar
      paint volumes: another pass at the design · 3540d222
      Robert Bragg authored
      This is a fairly extensive second pass at exposing paint volumes for
      actors.
      
      The API has changed to allow clutter_actor_get_paint_volume to fail
      since there are times - such as when an actor isn't a descendent of the
      stage - when the volume can't be determined. Another example is when
      something has connected to the "paint" signal of the actor and we simply
      have no way of knowing what might be drawn in that handler.
      
      The API has also be changed to return a const ClutterPaintVolume pointer
      (transfer none) so we can avoid having to dynamically allocate the
      volumes in the most common/performance critical code paths. Profiling was
      showing the slice allocation of volumes taking about 1% of an apps time,
      for some fairly basic tests. Most volumes can now simply be allocated on
      the stack; for clutter_actor_get_paint_volume we return a pointer to
      &priv->paint_volume and if we need a more dynamic allocation there is
      now a _clutter_stage_paint_volume_stack_allocate() mechanism which lets
      us allocate data which expires at the start of the next frame.
      
      The API has been extended to make it easier to implement
      get_paint_volume for containers by using
      clutter_actor_get_transformed_paint_volume and
      clutter_paint_volume_union. The first allows you to query the paint
      volume of a child but transformed into parent actor coordinates. The
      second lets you combine volumes together so you can union all the
      volumes for a container's children and report that as the container's
      own volume.
      
      The representation of paint volumes has been updated to consider that
      2D actors are the most common.
      
      The effect apis, clutter-texture and clutter-group have been update
      accordingly.
      3540d222
    • Robert Bragg's avatar
      actor-box: Adds clutter_actor_box_union utility · 48a24a2e
      Robert Bragg authored
      When using ClutterActorBoxs for representing clip regions it can be
      convenient to be able to union multiple boxes together.
      48a24a2e
    • Robert Bragg's avatar
      texture: size fbos using clutter_actor_get_paint_box · 2da127dc
      Robert Bragg authored
      Previously we used the transformed allocation but that doesn't take
      into account actors with depth which may be projected outside the
      area covered by the transformed allocation.
      2da127dc
    • Emmanuele Bassi's avatar
      docs: Add PaintVolume to the API reference · 044809ed
      Emmanuele Bassi authored
      And document the various related functions.
      044809ed
    • Emmanuele Bassi's avatar
      blur-effect: Add padding to account for the blur · a6e5eceb
      Emmanuele Bassi authored
      The blur effect will sample pixels on the edges of the offscreen buffer,
      so we want to add a padding to avoid clamping the blur.
      
      We do this by creating a larger target texture, and updating the paint
      volume of the actor during paint to take that padding into account.
      a6e5eceb
    • Emmanuele Bassi's avatar
      offscreen-effect: Use the paint box to size the FBO · 5d97ca5f
      Emmanuele Bassi authored
      We should be using the real, on-screen, transformed size of the actor to
      size and position the offscreen buffer we use to paint the actor for an
      effect.
      5d97ca5f
    • Emmanuele Bassi's avatar
      effect: Allow any effect to override the paint volume · 25abdf09
      Emmanuele Bassi authored
      An Effect implementation might override the paint volume of the actor to
      which it is applied to. The get_paint_volume() virtual function should
      be added to the Effect class vtable so that any effect can get the
      current paint volume and update it.
      
      The clutter_actor_get_paint_volume() function becomes context aware, and
      does the right thing if called from within a ClutterEffect pre_paint()
      or post_paint() implementation, by allowing all effects in the chain up
      to the caller to modify the paint volume.
      25abdf09
    • Emmanuele Bassi's avatar
      actor: Allow querying the paint volume · 94ce747f
      Emmanuele Bassi authored
      An actor has an implicit "paint volume", that is the volume in 3D space
      occupied when painting itself.
      
      The paint volume is defined as a cuboid with the origin placed at the
      top-left corner of the actor; the size of the cuboid is given by three
      vectors: width, height and depth.
      
      ClutterActor provides API to convert the paint volume into a 2D box in
      screen coordinates, to compute the on-screen area that an actor will
      occupy when painted.
      
      Actors can override the default implementation of the get_paint_volume()
      virtual function to provide a different volume.
      94ce747f
    • Emmanuele Bassi's avatar
      cally: Do not use deprecated functions · 27aebb5c
      Emmanuele Bassi authored
      The function g_strcasecmp() has been deprecated since GLib 2.2.
      27aebb5c
    • Emmanuele Bassi's avatar
      animator: Code style fixes · e798047c
      Emmanuele Bassi authored
      e798047c
    • Stephen Kennedy's avatar
      ClutterAnimator doesn't ref timeline properly · 3fe10e0b
      Stephen Kennedy authored
      ClutterAnimator currently has a number of bugs related to its
      referencing of its internal timeline.
      
      1) The default timeline created in _init is not unreffed (it appears the
      programmer has wrongly thought ClutterTimeline has a floating reference
      based on the use of g_object_ref_sink in _set_timeline)
      
      2) The timeline and slave_timeline vars are unreffed in finalize instead
      of dispose
      
      3) The signal handlers set up in _set_timeline are not disconnected when
      the animator is disposed
      
      http://bugzilla.clutter-project.org/show_bug.cgi?id=2347Signed-off-by: default avatarEmmanuele Bassi <ebassi@linux.intel.com>
      3fe10e0b
  2. 28 Sep, 2010 3 commits
    • Neil Roberts's avatar
      Add a conformance test for clutter_actor_contains · d0cab856
      Neil Roberts authored
      This adds a conformance test for clutter_actor_contains to assert that
      it gets the expected results for the given tree of actors.
      d0cab856
    • Neil Roberts's avatar
      Simplify the loop for clutter_actor_contains · 30685207
      Neil Roberts authored
      This reorganizes the loop for clutter_actor_contains so that it is a
      for loop rather than a while loop. Although this is mostly just
      nitpicking, I think this change could make the loop slightly faster if
      not optimized because it doesn't perform the self == descendant check
      twice and it is clearer.
      30685207
    • Neil Roberts's avatar
      Document what happens when self==descendant in clutter_actor_contains · 99adb88e
      Neil Roberts authored
      The documentation for clutter_actor_contains didn't specify what
      happens when self==descendant. A strict reading of it might lead you
      to think that it would return FALSE because in that case the
      descendant isn't an immediate child or a deeper descendant. The code
      actually would return TRUE. I think this is more useful so this patch
      fixes the docs rather than the code.
      99adb88e