mirror of
https://github.com/brl/mutter.git
synced 2025-02-17 05:44:08 +00:00
offscreen-effect: Use the paint box to size the FBO
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.
This commit is contained in:
parent
25abdf09b7
commit
5d97ca5f87
@ -153,7 +153,13 @@ update_fbo (ClutterEffect *effect)
|
|||||||
* FIXME - this is actually not enough: we need the paint area
|
* FIXME - this is actually not enough: we need the paint area
|
||||||
* to make this work reliably
|
* to make this work reliably
|
||||||
*/
|
*/
|
||||||
clutter_actor_get_transformed_size (priv->actor, &width, &height);
|
{
|
||||||
|
ClutterActorBox box = { 0, };
|
||||||
|
|
||||||
|
clutter_actor_get_paint_box (priv->actor, &box);
|
||||||
|
clutter_actor_box_get_size (&box, &width, &height);
|
||||||
|
}
|
||||||
|
|
||||||
if (priv->target_width == width &&
|
if (priv->target_width == width &&
|
||||||
priv->target_height == height)
|
priv->target_height == height)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -202,36 +208,23 @@ get_screen_offsets (ClutterActor *actor,
|
|||||||
gfloat *x_offset,
|
gfloat *x_offset,
|
||||||
gfloat *y_offset)
|
gfloat *y_offset)
|
||||||
{
|
{
|
||||||
ClutterVertex verts[4];
|
|
||||||
gfloat x_min = G_MAXFLOAT, y_min = G_MAXFLOAT;
|
|
||||||
gfloat v[4] = { 0, };
|
gfloat v[4] = { 0, };
|
||||||
gint i;
|
|
||||||
|
|
||||||
/* Get the actors allocation transformed into screen coordinates.
|
if (CLUTTER_ACTOR_IS_TOPLEVEL (actor))
|
||||||
*
|
|
||||||
* XXX: Note: this may not be a bounding box for the actor, since an
|
|
||||||
* actor with depth may escape the box due to its perspective
|
|
||||||
* projection. */
|
|
||||||
clutter_actor_get_abs_allocation_vertices (actor, verts);
|
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (verts); ++i)
|
|
||||||
{
|
{
|
||||||
if (verts[i].x < x_min)
|
/* trivial optimization: a top-level actor is always going to
|
||||||
x_min = verts[i].x;
|
* have a (0, 0) offset
|
||||||
|
*/
|
||||||
if (verts[i].y < y_min)
|
*x_offset = 0.0f;
|
||||||
y_min = verts[i].y;
|
*y_offset = 0.0f;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ClutterActorBox box = { 0, };
|
||||||
|
|
||||||
/* XXX: It's not good enough to round by simply truncating the fraction here
|
clutter_actor_get_paint_box (actor, &box);
|
||||||
* via a cast, as it results in offscreen rendering being offset by 1 pixel
|
clutter_actor_box_get_origin (&box, x_offset, y_offset);
|
||||||
* in many cases... */
|
}
|
||||||
#define ROUND(x) ((x) >= 0 ? (long)((x) + 0.5) : (long)((x) - 0.5))
|
|
||||||
|
|
||||||
*x_offset = ROUND (x_min);
|
|
||||||
*y_offset = ROUND (y_min);
|
|
||||||
|
|
||||||
#undef ROUND
|
|
||||||
|
|
||||||
/* since we're setting up a viewport with a negative offset to paint
|
/* since we're setting up a viewport with a negative offset to paint
|
||||||
* in an FBO with the same modelview and projection matrices as the
|
* in an FBO with the same modelview and projection matrices as the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user