ClutterVertex *vertices_out,
int n_vertices);
+void _clutter_util_rectangle_union (const cairo_rectangle_int_t *src1,
+ const cairo_rectangle_int_t *src2,
+ cairo_rectangle_int_t *dest);
+
typedef struct _ClutterPlane
{
CoglVector3 v0;
/* stage */
ClutterStageWindow *_clutter_stage_get_default_window (void);
-void _clutter_stage_do_paint (ClutterStage *stage,
- const ClutterGeometry *clip);
+
+void _clutter_stage_do_paint (ClutterStage *stage,
+ const cairo_rectangle_int_t *clip);
+
void _clutter_stage_set_window (ClutterStage *stage,
ClutterStageWindow *stage_window);
ClutterStageWindow *_clutter_stage_get_window (ClutterStage *stage);
}
void
-_clutter_stage_window_get_geometry (ClutterStageWindow *window,
- ClutterGeometry *geometry)
+_clutter_stage_window_get_geometry (ClutterStageWindow *window,
+ cairo_rectangle_int_t *geometry)
{
CLUTTER_STAGE_WINDOW_GET_IFACE (window)->get_geometry (window, geometry);
}
}
void
-_clutter_stage_window_add_redraw_clip (ClutterStageWindow *window,
- ClutterGeometry *stage_clip)
+_clutter_stage_window_add_redraw_clip (ClutterStageWindow *window,
+ cairo_rectangle_int_t *stage_clip)
{
ClutterStageWindowIface *iface;
g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window));
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
- if (iface->add_redraw_clip)
+ if (iface->add_redraw_clip != NULL)
iface->add_redraw_clip (window, stage_clip);
}
g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE);
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
- if (iface->has_redraw_clips)
+ if (iface->has_redraw_clips != NULL)
return iface->has_redraw_clips (window);
return FALSE;
g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE);
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
- if (iface->ignoring_redraw_clips)
+ if (iface->ignoring_redraw_clips != NULL)
return iface->ignoring_redraw_clips (window);
return TRUE;
g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE);
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
- if (iface->get_redraw_clip_bounds)
+ if (iface->get_redraw_clip_bounds != NULL)
return iface->get_redraw_clip_bounds (window, stage_clip);
return FALSE;
gint width,
gint height);
void (* get_geometry) (ClutterStageWindow *stage_window,
- ClutterGeometry *geometry);
+ cairo_rectangle_int_t *geometry);
int (* get_pending_swaps) (ClutterStageWindow *stage_window);
- void (* add_redraw_clip) (ClutterStageWindow *stage_window,
- ClutterGeometry *stage_rectangle);
- gboolean (* has_redraw_clips) (ClutterStageWindow *stage_window);
- gboolean (* ignoring_redraw_clips) (ClutterStageWindow *stage_window);
- gboolean (* get_redraw_clip_bounds) (ClutterStageWindow *stage_window,
+ void (* add_redraw_clip) (ClutterStageWindow *stage_window,
+ cairo_rectangle_int_t *stage_rectangle);
+ gboolean (* has_redraw_clips) (ClutterStageWindow *stage_window);
+ gboolean (* ignoring_redraw_clips) (ClutterStageWindow *stage_window);
+ gboolean (* get_redraw_clip_bounds) (ClutterStageWindow *stage_window,
cairo_rectangle_int_t *clip);
gint width,
gint height);
void _clutter_stage_window_get_geometry (ClutterStageWindow *window,
- ClutterGeometry *geometry);
+ cairo_rectangle_int_t *geometry);
int _clutter_stage_window_get_pending_swaps (ClutterStageWindow *window);
-void _clutter_stage_window_add_redraw_clip (ClutterStageWindow *window,
- ClutterGeometry *stage_clip);
-gboolean _clutter_stage_window_has_redraw_clips (ClutterStageWindow *window);
-gboolean _clutter_stage_window_ignoring_redraw_clips (ClutterStageWindow *window);
-gboolean _clutter_stage_window_get_redraw_clip_bounds (ClutterStageWindow *window,
+void _clutter_stage_window_add_redraw_clip (ClutterStageWindow *window,
+ cairo_rectangle_int_t *stage_clip);
+gboolean _clutter_stage_window_has_redraw_clips (ClutterStageWindow *window);
+gboolean _clutter_stage_window_ignoring_redraw_clips (ClutterStageWindow *window);
+gboolean _clutter_stage_window_get_redraw_clip_bounds (ClutterStageWindow *window,
cairo_rectangle_int_t *clip);
void _clutter_stage_window_set_accept_focus (ClutterStageWindow *window,
- gboolean accept_focus);
+ gboolean accept_focus);
void _clutter_stage_window_redraw (ClutterStageWindow *window);
gfloat *natural_width_p)
{
ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
- ClutterGeometry geom = { 0, };
+ cairo_rectangle_int_t geom;
if (priv->impl == NULL)
return;
gfloat *natural_height_p)
{
ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
- ClutterGeometry geom = { 0, };
+ cairo_rectangle_int_t geom;
if (priv->impl == NULL)
return;
ClutterAllocationFlags flags)
{
ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv;
- ClutterGeometry prev_geom;
- ClutterGeometry geom = { 0, };
+ ClutterGeometry prev_geom, geom;
+ cairo_rectangle_int_t window_size;
gboolean origin_changed;
gint width, height;
- origin_changed = (flags & CLUTTER_ABSOLUTE_ORIGIN_CHANGED) ? TRUE : FALSE;
+ origin_changed = (flags & CLUTTER_ABSOLUTE_ORIGIN_CHANGED)
+ ? TRUE
+ : FALSE;
if (priv->impl == NULL)
return;
+ /* our old allocation */
clutter_actor_get_allocation_geometry (self, &prev_geom);
+ /* the current allocation */
width = clutter_actor_box_get_width (box);
height = clutter_actor_box_get_height (box);
- _clutter_stage_window_get_geometry (priv->impl, &geom);
- /* if the stage is fixed size (for instance, it's using a frame-buffer)
+ /* the current Stage implementation size */
+ _clutter_stage_window_get_geometry (priv->impl, &window_size);
+
+ /* if the stage is fixed size (for instance, it's using a EGL framebuffer)
* then we simply ignore any allocation request and override the
- * allocation chain.
+ * allocation chain - because we cannot forcibly change the size of the
+ * stage window.
*/
if ((!clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC)))
{
priv->min_size_changed = FALSE;
}
- if ((geom.width != width) || (geom.height != height))
- _clutter_stage_window_resize (priv->impl, width, height);
+ if (window_size.width != width ||
+ window_size.height != height)
+ {
+ _clutter_stage_window_resize (priv->impl, width, height);
+ }
}
}
else
ClutterActorBox override = { 0, };
ClutterActorClass *klass;
+ /* override the passed allocation */
override.x1 = 0;
override.y1 = 0;
- override.x2 = geom.width;
- override.y2 = geom.height;
+ override.x2 = window_size.width;
+ override.y2 = window_size.height;
CLUTTER_NOTE (LAYOUT,
"Overrigin original allocation of %dx%d "
* Clutter need to manually keep it informed of the current window
* size. We do this after the allocation above so that the stage
* window has a chance to update the window size based on the
- * allocation. */
- _clutter_stage_window_get_geometry (priv->impl, &geom);
- cogl_onscreen_clutter_backend_set_size (geom.width, geom.height);
+ * allocation.
+ */
+ _clutter_stage_window_get_geometry (priv->impl, &window_size);
+ cogl_onscreen_clutter_backend_set_size (window_size.width,
+ window_size.height);
+ /* reset the viewport if the allocation effectively changed */
clutter_actor_get_allocation_geometry (self, &geom);
- if (geom.width != prev_geom.width || geom.height != prev_geom.height)
+ if (geom.width != prev_geom.width ||
+ geom.height != prev_geom.height)
{
_clutter_stage_set_viewport (CLUTTER_STAGE (self),
- 0, 0, geom.width, geom.height);
+ 0, 0,
+ geom.width,
+ geom.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. */
+ * viewport before the stage was really allocated its new size.
+ */
queue_full_redraw (CLUTTER_STAGE (self));
}
}
* be able to cull them.
*/
void
-_clutter_stage_do_paint (ClutterStage *stage, const ClutterGeometry *clip)
+_clutter_stage_do_paint (ClutterStage *stage,
+ const cairo_rectangle_int_t *clip)
{
ClutterStagePrivate *priv = stage->priv;
float clip_poly[8];
- ClutterGeometry geom;
+ cairo_rectangle_int_t geom;
_clutter_stage_window_get_geometry (priv->impl, &geom);
clutter_stage_real_fullscreen (ClutterStage *stage)
{
ClutterStagePrivate *priv = stage->priv;
- ClutterGeometry geom;
+ cairo_rectangle_int_t geom;
ClutterActorBox box;
/* we need to force an allocation here because the size
{
ClutterStage *stage = CLUTTER_STAGE (actor);
ClutterStageWindow *stage_window;
- ClutterGeometry stage_clip;
ClutterPaintVolume *redraw_clip;
ClutterActorBox bounding_box;
ClutterActorBox intersection_box;
- ClutterGeometry geom;
+ cairo_rectangle_int_t geom, stage_clip;
if (CLUTTER_ACTOR_IN_DESTRUCTION (actor))
return;
if (!_clutter_stage_window_get_redraw_clip_bounds (priv->impl, clip))
{
- ClutterGeometry geometry;
-
/* Set clip to the full extents of the stage */
- _clutter_stage_window_get_geometry (priv->impl, &geometry);
- clip->x = 0;
- clip->y = 0;
- clip->width = geometry.width;
- clip->height = geometry.height;
+ _clutter_stage_window_get_geometry (priv->impl, clip);
}
}
{
ClutterStagePrivate *priv;
ClutterBackend *backend;
- ClutterGeometry geom;
+ cairo_rectangle_int_t geom;
/* a stage is a top-level object */
CLUTTER_SET_PRIVATE_FLAGS (self, CLUTTER_IS_TOPLEVEL);
}
}
+/*< private >
+ * _clutter_util_rectangle_union:
+ * @src1: first rectangle to union
+ * @src2: second rectangle to union
+ * @dest: (out): return location for the unioned rectangle
+ *
+ * Calculates the union of two rectangles.
+ *
+ * The union of rectangles @src1 and @src2 is the smallest rectangle which
+ * includes both @src1 and @src2 within it.
+ *
+ * It is allowed for @dest to be the same as either @src1 or @src2.
+ *
+ * This function should really be in Cairo.
+ */
+void
+_clutter_util_rectangle_union (const cairo_rectangle_int_t *src1,
+ const cairo_rectangle_int_t *src2,
+ cairo_rectangle_int_t *dest)
+{
+ int dest_x, dest_y;
+
+ dest_x = MIN (src1->x, src2->x);
+ dest_y = MIN (src1->y, src2->y);
+
+ dest->width = MAX (src1->x + src1->width, src2->x + src2->width) - dest_x;
+ dest->height = MAX (src1->y + src1->height, src2->y + src2->height) - dest_y;
+ dest->x = dest_x;
+ dest->y = dest_y;
+}
}
static void
-clutter_stage_cogl_get_geometry (ClutterStageWindow *stage_window,
- ClutterGeometry *geometry)
+clutter_stage_cogl_get_geometry (ClutterStageWindow *stage_window,
+ cairo_rectangle_int_t *geometry)
{
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
* buffer.
*/
static void
-clutter_stage_cogl_add_redraw_clip (ClutterStageWindow *stage_window,
- ClutterGeometry *stage_clip)
+clutter_stage_cogl_add_redraw_clip (ClutterStageWindow *stage_window,
+ cairo_rectangle_int_t *stage_clip)
{
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
if (!stage_cogl->initialized_redraw_clip)
{
- stage_cogl->bounding_redraw_clip.x = stage_clip->x;
- stage_cogl->bounding_redraw_clip.y = stage_clip->y;
- stage_cogl->bounding_redraw_clip.width = stage_clip->width;
- stage_cogl->bounding_redraw_clip.height = stage_clip->height;
+ stage_cogl->bounding_redraw_clip = *stage_clip;
}
else if (stage_cogl->bounding_redraw_clip.width > 0)
{
- clutter_geometry_union (&stage_cogl->bounding_redraw_clip, stage_clip,
- &stage_cogl->bounding_redraw_clip);
+ _clutter_util_rectangle_union (&stage_cogl->bounding_redraw_clip,
+ stage_clip,
+ &stage_cogl->bounding_redraw_clip);
}
stage_cogl->initialized_redraw_clip = TRUE;
}
static gboolean
-clutter_stage_cogl_get_redraw_clip_bounds (ClutterStageWindow *stage_window,
+clutter_stage_cogl_get_redraw_clip_bounds (ClutterStageWindow *stage_window,
cairo_rectangle_int_t *stage_clip)
{
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
if (stage_cogl->using_clipped_redraw)
{
- stage_clip->x = stage_cogl->bounding_redraw_clip.x;
- stage_clip->y = stage_cogl->bounding_redraw_clip.y;
- stage_clip->width = stage_cogl->bounding_redraw_clip.width;
- stage_clip->height = stage_cogl->bounding_redraw_clip.height;
+ *stage_clip = stage_cogl->bounding_redraw_clip;
return TRUE;
}
G_UNLIKELY ((clutter_paint_debug_flags & CLUTTER_DEBUG_REDRAWS)))
{
static CoglMaterial *outline = NULL;
- ClutterGeometry *clip = &stage_cogl->bounding_redraw_clip;
+ cairo_rectangle_int_t *clip = &stage_cogl->bounding_redraw_clip;
ClutterActor *actor = CLUTTER_ACTOR (wrapper);
CoglHandle vbo;
float x_1 = clip->x;
/* push on the screen */
if (use_clipped_redraw)
{
- ClutterGeometry *clip = &stage_cogl->bounding_redraw_clip;
+ cairo_rectangle_int_t *clip = &stage_cogl->bounding_redraw_clip;
int copy_area[4];
/* XXX: It seems there will be a race here in that the stage
#endif
#include <glib-object.h>
+#include <cairo.h>
#include <clutter/clutter-stage.h>
#ifdef COGL_HAS_X11_SUPPORT
* junk frames to start with. */
unsigned long frame_count;
- ClutterGeometry bounding_redraw_clip;
+ cairo_rectangle_int_t bounding_redraw_clip;
guint initialized_redraw_clip : 1;
}
static void
-clutter_stage_osx_get_geometry (ClutterStageWindow *stage_window,
- ClutterGeometry *geometry)
+clutter_stage_osx_get_geometry (ClutterStageWindow *stage_window,
+ cairo_rectangle_int_t *geometry)
{
ClutterBackend *backend = clutter_get_default_backend ();
ClutterStageOSX *self = CLUTTER_STAGE_OSX (stage_window);
}
static ClutterStageWaylandWaylandBuffer *
wayland_create_shm_buffer (ClutterBackendWayland *backend_wayland,
- ClutterGeometry *geom)
+ cairo_rectangle_int_t *geom)
{
ClutterStageWaylandWaylandBufferSHM *buffer;
struct wl_visual *visual;
buffer->buffer.type = BUFFER_TYPE_SHM;
- tex = cogl_texture_new_with_size ((unsigned int)geom->width,
- (unsigned int)geom->height,
- flags, format);
+ tex = cogl_texture_new_with_size ((unsigned int) geom->width,
+ (unsigned int) geom->height,
+ flags, format);
buffer->format = format;
buffer->stride = cogl_texture_get_rowstride(tex);
buffer->size = cogl_texture_get_data(tex, format, buffer->stride, NULL);
static ClutterStageWaylandWaylandBuffer *
wayland_create_drm_buffer (ClutterBackendWayland *backend_wayland,
- ClutterGeometry *geom)
+ cairo_rectangle_int_t *geom)
{
EGLDisplay edpy = clutter_wayland_get_egl_display ();
struct wl_visual *visual;
}
static ClutterStageWaylandWaylandBuffer *
-wayland_create_buffer (ClutterGeometry *geom)
+wayland_create_buffer (cairo_rectangle_int_t *geom)
{
ClutterBackend *backend = clutter_get_default_backend ();
ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (backend);
}
static void
-clutter_stage_wayland_get_geometry (ClutterStageWindow *stage_window,
- ClutterGeometry *geometry)
+clutter_stage_wayland_get_geometry (ClutterStageWindow *stage_window,
+ cairo_rectangle_int_t *geometry)
{
- ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window);
-
- if (geometry)
+ if (geometry != NULL)
{
+ ClutterStageWayland *stage_wayland =
+ CLUTTER_STAGE_WAYLAND (stage_window);
+
*geometry = stage_wayland->allocation;
}
}
gint height)
{
ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window);
- cairo_rectangle_int_t rect;
fprintf (stderr, "resize %dx%d\n", width, height);
stage_wayland->pending_allocation.height = height;
/* FIXME: Shouldn't the stage repaint everything when it gets resized? */
- rect.x = stage_wayland->pending_allocation.x;
- rect.y = stage_wayland->pending_allocation.y;
- rect.width = stage_wayland->pending_allocation.width;
- rect.height = stage_wayland->pending_allocation.height;
- cairo_region_union_rectangle (stage_wayland->repaint_region, &rect);
+ cairo_region_union_rectangle (stage_wayland->repaint_region,
+ &stage_wayland->pending_allocation);
}
#define CAIRO_REGION_FULL ((cairo_region_t *) 1)
}
static void
-clutter_stage_wayland_add_redraw_clip (ClutterStageWindow *stage_window,
- ClutterGeometry *stage_clip)
+clutter_stage_wayland_add_redraw_clip (ClutterStageWindow *stage_window,
+ cairo_rectangle_int_t *stage_clip)
{
ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window);
cairo_rectangle_int_t rect;
if (stage_clip == NULL)
- {
- rect.x = stage_wayland->allocation.x;
- rect.y = stage_wayland->allocation.y;
- rect.width = stage_wayland->allocation.width;
- rect.height = stage_wayland->allocation.height;
- }
+ rect = stage_wayland->allocation;
else
- {
- rect.x = stage_clip->x;
- rect.y = stage_clip->y;
- rect.width = stage_clip->width;
- rect.height = stage_clip->height;
- }
+ rect = stage_clip;
if (stage_wayland->repaint_region == NULL)
stage_wayland->repaint_region = cairo_region_create_rectangle (&rect);
_clutter_stage_wayland_repaint_region (ClutterStageWayland *stage_wayland,
ClutterStage *stage)
{
- ClutterGeometry geom;
cairo_rectangle_int_t rect;
int i, count;
{
cairo_region_get_rectangle (stage_wayland->repaint_region, i, &rect);
- cogl_clip_push_window_rectangle (rect.x - 1, rect.y - 1,
- rect.width + 2, rect.height + 2);
+ cogl_clip_push_window_rectangle (rect.x - 1,
+ rect.y - 1,
+ rect.width + 2,
+ rect.height + 2);
- geom.x = rect.x;
- geom.y = rect.y;
- geom.width = rect.width;
- geom.height = rect.height;
/* FIXME: We should pass geom in as second arg, but some actors
* cull themselves a little to much. Disable for now.*/
_clutter_stage_do_paint (stage, NULL);
stage_wayland->allocation = stage_wayland->pending_allocation;
if (!stage_wayland->back_buffer)
+ {
stage_wayland->back_buffer =
- wayland_create_buffer (&stage_wayland->allocation);
+ wayland_create_buffer (&stage_wayland->allocation);
+ }
cogl_set_framebuffer (stage_wayland->back_buffer->offscreen);
_clutter_stage_maybe_setup_viewport (stage_wayland->wrapper);
/* back pointer to the backend */
ClutterBackendWayland *backend;
- ClutterGeometry allocation;
- ClutterGeometry save_allocation;
- ClutterGeometry pending_allocation;
+ cairo_rectangle_int_t allocation;
+ cairo_rectangle_int_t save_allocation;
+ cairo_rectangle_int_t pending_allocation;
struct wl_surface *wayland_surface;
int pending_swaps;
}
static void
-clutter_stage_win32_get_geometry (ClutterStageWindow *stage_window,
- ClutterGeometry *geometry)
+clutter_stage_win32_get_geometry (ClutterStageWindow *stage_window,
+ cairo_rectangle_int_t *geometry)
{
ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (stage_window);
if ((stage_win32->state & CLUTTER_STAGE_STATE_FULLSCREEN))
{
- geometry->width = (stage_win32->fullscreen_rect.right
- - stage_win32->fullscreen_rect.left);
- geometry->height = (stage_win32->fullscreen_rect.bottom
- - stage_win32->fullscreen_rect.top);
+ geometry->width = stage_win32->fullscreen_rect.right
+ - stage_win32->fullscreen_rect.left;
+ geometry->height = stage_win32->fullscreen_rect.bottom
+ - stage_win32->fullscreen_rect.top;
return;
}
}
static void
-clutter_stage_x11_get_geometry (ClutterStageWindow *stage_window,
- ClutterGeometry *geometry)
+clutter_stage_x11_get_geometry (ClutterStageWindow *stage_window,
+ cairo_rectangle_int_t *geometry)
{
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (stage_window);
ClutterBackendX11 *backend_x11 = stage_x11->backend;