static inline void container_remove_actor (ClutterContainer *container, ClutterActor *actor) { ClutterActor *parent; parent = clutter_actor_get_parent (actor); if (parent != CLUTTER_ACTOR (container)) { g_warning ("Attempting to remove actor of type '%s' from " "group of class '%s', but the container is not " "the actor's parent.", g_type_name (G_OBJECT_TYPE (actor)), g_type_name (G_OBJECT_TYPE (container))); return; } clutter_container_destroy_child_meta (container, actor); #ifdef CLUTTER_ENABLE_DEBUG if (G_UNLIKELY (_clutter_diagnostic_enabled ())) { ClutterContainerIface *iface = CLUTTER_CONTAINER_GET_IFACE (container); if (iface->remove != container_real_remove) _clutter_diagnostic_message ("The ClutterContainer::remove() virtual " "function has been deprecated and it " "should not be overridden by newly " "written code"); } #endif /* CLUTTER_ENABLE_DEBUG */ CLUTTER_CONTAINER_GET_IFACE (container)->remove (container, actor); }
/** * clutter_container_foreach_with_internals: * @container: a #ClutterContainer * @callback: (scope call): a function to be called for each child * @user_data: data to be passed to the function, or %NULL * * Calls @callback for each child of @container, including "internal" * children built in to the container itself that were never added * by the application. * * This function calls the #ClutterContainerIface.foreach_with_internals() * virtual function, which has been deprecated. * * Since: 1.0 * * Deprecated: 1.10: See clutter_container_foreach(). */ void clutter_container_foreach_with_internals (ClutterContainer *container, ClutterCallback callback, gpointer user_data) { ClutterContainerIface *iface; g_return_if_fail (CLUTTER_IS_CONTAINER (container)); g_return_if_fail (callback != NULL); iface = CLUTTER_CONTAINER_GET_IFACE (container); #ifdef CLUTTER_ENABLE_DEBUG if (G_UNLIKELY (_clutter_diagnostic_enabled ())) { if (iface->foreach_with_internals != NULL) _clutter_diagnostic_message ("The ClutterContainer::foreach_with_internals() " "virtual function has been deprecated " "and it should not be overridden by " "newly written code"); } #endif /* CLUTTER_ENABLE_DEBUG */ if (iface->foreach_with_internals != NULL) iface->foreach_with_internals (container, callback, user_data); else iface->foreach (container, callback, user_data); }
static inline void container_add_actor (ClutterContainer *container, ClutterActor *actor) { ClutterActor *parent; parent = clutter_actor_get_parent (actor); if (G_UNLIKELY (parent != NULL)) { g_warning ("Attempting to add actor of type '%s' to a " "container of type '%s', but the actor has " "already a parent of type '%s'.", g_type_name (G_OBJECT_TYPE (actor)), g_type_name (G_OBJECT_TYPE (container)), g_type_name (G_OBJECT_TYPE (parent))); return; } clutter_container_create_child_meta (container, actor); #ifdef CLUTTER_ENABLE_DEBUG if (G_UNLIKELY (_clutter_diagnostic_enabled ())) { ClutterContainerIface *iface = CLUTTER_CONTAINER_GET_IFACE (container); if (iface->add != container_real_add) _clutter_diagnostic_message ("The ClutterContainer::add() virtual " "function has been deprecated and it " "should not be overridden by newly " "written code"); } #endif /* CLUTTER_ENABLE_DEBUG */ CLUTTER_CONTAINER_GET_IFACE (container)->add (container, actor); }
static gboolean master_clock_update_stages (ClutterMasterClockDefault *master_clock, GSList *stages) { gboolean stages_updated = FALSE; GSList *l; #ifdef CLUTTER_ENABLE_DEBUG gint64 start = g_get_monotonic_time (); #endif _clutter_run_repaint_functions (CLUTTER_REPAINT_FLAGS_PRE_PAINT); /* Update any stage that needs redraw/relayout after the clock * is advanced. */ for (l = stages; l != NULL; l = l->next) stages_updated |= _clutter_stage_do_update (l->data); _clutter_run_repaint_functions (CLUTTER_REPAINT_FLAGS_POST_PAINT); #ifdef CLUTTER_ENABLE_DEBUG if (_clutter_diagnostic_enabled ()) clutter_warn_if_over_budget (master_clock, start, "Updating the stage"); master_clock->remaining_budget -= (g_get_monotonic_time () - start); #endif return stages_updated; }
/** * clutter_container_lower_child: (virtual lower) * @container: a #ClutterContainer * @actor: the actor to raise * @sibling: (allow-none): the sibling to lower to, or %NULL to lower * to the bottom * * Lowers @actor to @sibling level, in the depth ordering. * * This function calls the #ClutterContainerIface.lower() virtual function, * which has been deprecated. The default implementation will call * clutter_actor_set_child_below_sibling(). * * Since: 0.6 * * Deprecated: 1.10: Use clutter_actor_set_child_below_sibling() instead. */ void clutter_container_lower_child (ClutterContainer *container, ClutterActor *actor, ClutterActor *sibling) { ClutterContainerIface *iface; ClutterActor *self; g_return_if_fail (CLUTTER_IS_CONTAINER (container)); g_return_if_fail (CLUTTER_IS_ACTOR (actor)); g_return_if_fail (sibling == NULL || CLUTTER_IS_ACTOR (sibling)); if (actor == sibling) return; self = CLUTTER_ACTOR (container); if (clutter_actor_get_parent (actor) != self) { g_warning ("Actor of type '%s' is not a child of the container " "of type '%s'", g_type_name (G_OBJECT_TYPE (actor)), g_type_name (G_OBJECT_TYPE (container))); return; } if (sibling != NULL&& clutter_actor_get_parent (sibling) != self) { g_warning ("Actor of type '%s' is not a child of the container " "of type '%s'", g_type_name (G_OBJECT_TYPE (sibling)), g_type_name (G_OBJECT_TYPE (container))); return; } iface = CLUTTER_CONTAINER_GET_IFACE (container); #ifdef CLUTTER_ENABLE_DEBUG if (G_UNLIKELY (_clutter_diagnostic_enabled ())) { if (iface->lower != container_real_lower) _clutter_diagnostic_message ("The ClutterContainer::lower() " "virtual function has been deprecated " "and it should not be overridden by " "newly written code"); } #endif /* CLUTTER_ENABLE_DEBUG */ iface->lower (container, actor, sibling); }
/* * master_clock_advance_timelines: * @master_clock: a #ClutterMasterClock * * Advances all the timelines held by the master clock. This function * should be called before calling _clutter_stage_do_update() to * make sure that all the timelines are advanced and the scene is updated. */ static void master_clock_advance_timelines (ClutterMasterClockDefault *master_clock) { GSList *timelines, *l; #ifdef CLUTTER_ENABLE_DEBUG gint64 start = g_get_monotonic_time (); #endif /* we protect ourselves from timelines being removed during * the advancement by other timelines by copying the list of * timelines, taking a reference on them, iterating over the * copied list and then releasing the reference. * * we cannot simply take a reference on the timelines and still * use the list held by the master clock because the do_tick() * might result in the creation of a new timeline, which gets * added at the end of the list with no reference increase and * thus gets disposed at the end of the iteration. * * this implies that a newly added timeline will not be advanced * by this clock iteration, which is perfectly fine since we're * in its first cycle. * * we also cannot steal the master clock timelines list because * a timeline might be removed as the direct result of do_tick() * and remove_timeline() would not find the timeline, failing * and leaving a dangling pointer behind. */ timelines = g_slist_copy (master_clock->timelines); g_slist_foreach (timelines, (GFunc) g_object_ref, NULL); for (l = timelines; l != NULL; l = l->next) _clutter_timeline_do_tick (l->data, master_clock->cur_tick / 1000); g_slist_foreach (timelines, (GFunc) g_object_unref, NULL); g_slist_free (timelines); #ifdef CLUTTER_ENABLE_DEBUG if (_clutter_diagnostic_enabled ()) clutter_warn_if_over_budget (master_clock, start, "Animations"); master_clock->remaining_budget -= (g_get_monotonic_time () - start); #endif }
static void master_clock_process_events (ClutterMasterClockDefault *master_clock, GSList *stages) { GSList *l; #ifdef CLUTTER_ENABLE_DEBUG gint64 start = g_get_monotonic_time (); #endif /* Process queued events */ for (l = stages; l != NULL; l = l->next) _clutter_stage_process_queued_events (l->data); #ifdef CLUTTER_ENABLE_DEBUG if (_clutter_diagnostic_enabled ()) clutter_warn_if_over_budget (master_clock, start, "Event processing"); master_clock->remaining_budget -= (g_get_monotonic_time () - start); #endif }
/** * clutter_container_sort_depth_order: * @container: a #ClutterContainer * * Sorts a container's children using their depth. This function should not * be normally used by applications. * * Since: 0.6 * * Deprecated: 1.10: The #ClutterContainerIface.sort_depth_order() virtual * function should not be used any more; the default implementation in * #ClutterContainer does not do anything. */ void clutter_container_sort_depth_order (ClutterContainer *container) { ClutterContainerIface *iface; g_return_if_fail (CLUTTER_IS_CONTAINER (container)); iface = CLUTTER_CONTAINER_GET_IFACE (container); #ifdef CLUTTER_ENABLE_DEBUG if (G_UNLIKELY (_clutter_diagnostic_enabled ())) { if (iface->sort_depth_order != container_real_sort_depth_order) _clutter_diagnostic_message ("The ClutterContainer::sort_depth_order() " "virtual function has been deprecated " "and it should not be overridden by " "newly written code"); } #endif /* CLUTTER_ENABLE_DEBUG */ iface->sort_depth_order (container); }
static void clutter_canvas_emit_draw (ClutterCanvas *self) { ClutterCanvasPrivate *priv = self->priv; int real_width, real_height; cairo_surface_t *surface; gboolean mapped_buffer; unsigned char *data; CoglBuffer *buffer; int window_scale = 1; gboolean res; cairo_t *cr; g_assert (priv->height > 0 && priv->width > 0); priv->dirty = TRUE; if (priv->scale_factor_set) window_scale = priv->scale_factor; else g_object_get (clutter_settings_get_default (), "window-scaling-factor", &window_scale, NULL); real_width = priv->width * window_scale; real_height = priv->height * window_scale; CLUTTER_NOTE (MISC, "Creating Cairo surface with size %d x %d (real: %d x %d, scale: %d)", priv->width, priv->height, real_width, real_height, window_scale); if (priv->buffer == NULL) { CoglContext *ctx; ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ()); priv->buffer = cogl_bitmap_new_with_size (ctx, real_width, real_height, CLUTTER_CAIRO_FORMAT_ARGB32); } buffer = COGL_BUFFER (cogl_bitmap_get_buffer (priv->buffer)); if (buffer == NULL) return; cogl_buffer_set_update_hint (buffer, COGL_BUFFER_UPDATE_HINT_DYNAMIC); data = cogl_buffer_map (buffer, COGL_BUFFER_ACCESS_READ_WRITE, COGL_BUFFER_MAP_HINT_DISCARD); if (data != NULL) { int bitmap_stride = cogl_bitmap_get_rowstride (priv->buffer); surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32, real_width, real_height, bitmap_stride); mapped_buffer = TRUE; } else { surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, real_width, real_height); mapped_buffer = FALSE; } cairo_surface_set_device_scale (surface, window_scale, window_scale); self->priv->cr = cr = cairo_create (surface); g_signal_emit (self, canvas_signals[DRAW], 0, cr, priv->width, priv->height, &res); #ifdef CLUTTER_ENABLE_DEBUG if (_clutter_diagnostic_enabled () && cairo_status (cr)) { g_warning ("Drawing failed for <ClutterCanvas>[%p]: %s", self, cairo_status_to_string (cairo_status (cr))); } #endif self->priv->cr = NULL; cairo_destroy (cr); if (mapped_buffer) cogl_buffer_unmap (buffer); else { int size = cairo_image_surface_get_stride (surface) * priv->height; cogl_buffer_set_data (buffer, 0, cairo_image_surface_get_data (surface), size); } cairo_surface_destroy (surface); }