From 9fdc9ca583e1b3e0dd81d7322732156d3eb121b7 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Tue, 21 Apr 2009 14:15:19 +0100 Subject: [PATCH 01/66] [ClutterText] Fix actors with a width but no wrapping and the wrap modes Setting the wrap mode on the PangoLayout seems to have disappeared during the text-actor-layout-height branch merge so this brings it back. The test for this in test-text-cache no longer needs to be disabled. We also shouldn't set the width on the layout if there is no wrapping or ellipsizing because otherwise it implicitly enables wrapping. This only matters if the actor gets allocated smaller than its natural size. --- clutter/clutter-text.c | 10 +++++++--- tests/conform/test-text-cache.c | 2 -- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 9ece4b8d7..c57559560 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -284,6 +284,7 @@ clutter_text_create_layout_no_cache (ClutterText *text, pango_layout_set_alignment (layout, priv->alignment); pango_layout_set_single_paragraph_mode (layout, priv->single_line_mode); pango_layout_set_justify (layout, priv->justify); + pango_layout_set_wrap (layout, priv->wrap_mode); /* Cases, assuming ellipsize != NONE on actor: * @@ -309,11 +310,14 @@ clutter_text_create_layout_no_cache (ClutterText *text, } } - /* we do not limit the layout width on editable, single-line - * text actors, since those can scroll the layout + /* We do not limit the layout width on editable, single-line text + * actors, since those can scroll the layout. For non-editable + * actors we only want to set the width if wrapping or ellipsizing + * is enabled. */ if (allocation_width > 0 && - !(priv->editable && priv->single_line_mode)) + (priv->editable ? !priv->single_line_mode + : (priv->ellipsize != PANGO_ELLIPSIZE_NONE || priv->wrap))) { gint width; diff --git a/tests/conform/test-text-cache.c b/tests/conform/test-text-cache.c index f7237b1d6..ac650528d 100644 --- a/tests/conform/test-text-cache.c +++ b/tests/conform/test-text-cache.c @@ -202,7 +202,6 @@ do_tests (CallbackData *data) pango_layout_set_wrap (data->test_layout, PANGO_WRAP_WORD); g_assert (check_result (data, "Enable line wrap", TRUE) == FALSE); -#if 0 /* TEST 11: change wrap mode * FIXME - broken */ @@ -210,7 +209,6 @@ do_tests (CallbackData *data) PANGO_WRAP_CHAR); pango_layout_set_wrap (data->test_layout, PANGO_WRAP_CHAR); g_assert (check_result (data, "Change wrap mode", TRUE) == FALSE); -#endif /* TEST 12: enable justify */ clutter_text_set_justify (CLUTTER_TEXT (data->label), TRUE); From 44fefa2afec991d9b60ae5694e511617b1369d1f Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 29 Apr 2009 15:14:40 +0100 Subject: [PATCH 02/66] [model] Add :filter-set Currently, there is no way for implementations of the ClutterModel abstract class to know whether there is a filter in place. Since subclasses might implement some optimization in case there is no filter present, we need a simple (and public) API to ask the model itself. --- clutter/clutter-model.c | 67 ++++++++++++++++++++++++++++++++++++++++- clutter/clutter-model.h | 1 + 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-model.c b/clutter/clutter-model.c index 9a11d6cba..e1380fb74 100644 --- a/clutter/clutter-model.c +++ b/clutter/clutter-model.c @@ -133,9 +133,15 @@ #include "clutter-private.h" #include "clutter-debug.h" - G_DEFINE_ABSTRACT_TYPE (ClutterModel, clutter_model, G_TYPE_OBJECT); +enum +{ + PROP_0, + + PROP_FILTER_SET +}; + enum { ROW_ADDED, @@ -249,11 +255,33 @@ clutter_model_finalize (GObject *object) G_OBJECT_CLASS (clutter_model_parent_class)->finalize (object); } +static void +clutter_model_get_property (GObject *gobject, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + ClutterModelPrivate *priv = CLUTTER_MODEL (gobject)->priv; + + switch (prop_id) + { + case PROP_FILTER_SET: + g_value_set_boolean (value, priv->filter_func != NULL); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); + break; + } +} + static void clutter_model_class_init (ClutterModelClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GParamSpec *pspec; + gobject_class->get_property = clutter_model_get_property; gobject_class->finalize = clutter_model_finalize; g_type_class_add_private (gobject_class, sizeof (ClutterModelPrivate)); @@ -263,6 +291,23 @@ clutter_model_class_init (ClutterModelClass *klass) klass->get_n_columns = clutter_model_real_get_n_columns; klass->get_n_rows = clutter_model_real_get_n_rows; + /** + * ClutterModel:filter-set: + * + * Whether the #ClutterModel has a filter set + * + * This property is set to %TRUE if a filter function has been + * set using clutter_model_set_filter() + * + * Since: 1.0 + */ + pspec = g_param_spec_boolean ("filter-set", + "Filter Set", + "Whether the model has a filter", + FALSE, + CLUTTER_PARAM_READABLE); + g_object_class_install_property (gobject_class, PROP_FILTER_SET, pspec); + /** * ClutterModel::row-added: * @model: the #ClutterModel on which the signal is emitted @@ -1356,6 +1401,26 @@ clutter_model_set_filter (ClutterModel *model, priv->filter_notify = notify; g_signal_emit (model, model_signals[FILTER_CHANGED], 0); + g_object_notify (G_OBJECT (model), "filter-set"); +} + +/** + * clutter_model_get_filter_set: + * @model: a #ClutterModel + * + * Returns whether the @model has a filter in place, set + * using clutter_model_set_filter() + * + * Return value: %TRUE if a filter is set + * + * Since: 1.0 + */ +gboolean +clutter_model_get_filter_set (ClutterModel *model) +{ + g_return_val_if_fail (CLUTTER_IS_MODEL (model), FALSE); + + return model->priv->filter_func != NULL; } /* diff --git a/clutter/clutter-model.h b/clutter/clutter-model.h index d20335f3e..2bf13dabd 100644 --- a/clutter/clutter-model.h +++ b/clutter/clutter-model.h @@ -248,6 +248,7 @@ void clutter_model_set_filter (ClutterModel *model, ClutterModelFilterFunc func, gpointer user_data, GDestroyNotify notify); +gboolean clutter_model_get_filter_set (ClutterModel *model); void clutter_model_resort (ClutterModel *model); gboolean clutter_model_filter_row (ClutterModel *model, From 01d172293ce3c6dd8576319657ab316c479e6acc Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 29 Apr 2009 15:26:05 +0100 Subject: [PATCH 03/66] [model] Rework Model behaviour with a filter Currently ClutterModel::get_iter_at_row() ignores whether we have a filter in place. This also extends to the get_n_rows() method. The more consistent, more intuitive and surely more correct way to handle a Model with a filter in place is to take into account the presence of the filter itself -- that is: - get_n_rows() should take into account the filter and return the number of *filtered* rows - get_iter_at_row() should also take the filter into account and get the first non-filtered row These two changes make the ClutterModel with a filter function behave like a subset of the original Model without a filter in place. For instance, given a model with three rows: - [row 0] - [row 1] - [row 2] - [row 3] The get_n_rows() method will return "2", since only two rows will match the filter; the get_first_iter() method will ask for the zero-eth row, which will return an iterator pointing to the contents of row 1 (but the :row property of the iterator will be set to 0); the get_last_iter() method will ask for the last row, which will return an iterator pointing to the contents of row 2 (but the :row property of the iterator will be set to 1). This changes will hopefully make the Model API more consistent in its usage whether there is a filter in place or not. --- clutter/clutter-list-model.c | 100 +++++++++++++++++----------- clutter/clutter-model.c | 125 +++++++++++++++++++++-------------- clutter/clutter-model.h | 2 +- 3 files changed, 138 insertions(+), 89 deletions(-) diff --git a/clutter/clutter-list-model.c b/clutter/clutter-list-model.c index 39d265193..8b560cee7 100644 --- a/clutter/clutter-list-model.c +++ b/clutter/clutter-list-model.c @@ -214,13 +214,11 @@ clutter_list_model_iter_is_first (ClutterModelIter *iter) ClutterModelIter *temp_iter; GSequence *sequence; GSequenceIter *begin, *end; - guint row; iter_default = CLUTTER_LIST_MODEL_ITER (iter); g_assert (iter_default->seq_iter != NULL); model = clutter_model_iter_get_model (iter); - row = clutter_model_iter_get_row (iter); sequence = CLUTTER_LIST_MODEL (model)->priv->sequence; @@ -234,7 +232,6 @@ clutter_list_model_iter_is_first (ClutterModelIter *iter) while (!g_sequence_iter_is_begin (begin)) { CLUTTER_LIST_MODEL_ITER (temp_iter)->seq_iter = begin; - g_object_set (G_OBJECT (temp_iter), "row", row, NULL); if (clutter_model_filter_iter (model, temp_iter)) { @@ -243,7 +240,6 @@ clutter_list_model_iter_is_first (ClutterModelIter *iter) } begin = g_sequence_iter_next (begin); - row += 1; } g_object_unref (temp_iter); @@ -264,7 +260,6 @@ clutter_list_model_iter_is_last (ClutterModelIter *iter) ClutterModel *model; GSequence *sequence; GSequenceIter *begin, *end; - guint row; iter_default = CLUTTER_LIST_MODEL_ITER (iter); g_assert (iter_default->seq_iter != NULL); @@ -273,7 +268,6 @@ clutter_list_model_iter_is_last (ClutterModelIter *iter) return TRUE; model = clutter_model_iter_get_model (iter); - row = clutter_model_iter_get_row (iter); sequence = CLUTTER_LIST_MODEL (model)->priv->sequence; @@ -288,7 +282,6 @@ clutter_list_model_iter_is_last (ClutterModelIter *iter) while (!g_sequence_iter_is_begin (begin)) { CLUTTER_LIST_MODEL_ITER (temp_iter)->seq_iter = begin; - g_object_set (G_OBJECT (temp_iter), "row", row, NULL); if (clutter_model_filter_iter (model, temp_iter)) { @@ -297,7 +290,6 @@ clutter_list_model_iter_is_last (ClutterModelIter *iter) } begin = g_sequence_iter_prev (begin); - row += 1; } g_object_unref (temp_iter); @@ -323,7 +315,7 @@ clutter_list_model_iter_next (ClutterModelIter *iter) g_assert (iter_default->seq_iter != NULL); model = clutter_model_iter_get_model (iter); - row = clutter_model_iter_get_row (iter) + 1; + row = clutter_model_iter_get_row (iter); filter_next = g_sequence_iter_next (iter_default->seq_iter); g_assert (filter_next != NULL); @@ -335,22 +327,20 @@ clutter_list_model_iter_next (ClutterModelIter *iter) while (!g_sequence_iter_is_end (filter_next)) { CLUTTER_LIST_MODEL_ITER (temp_iter)->seq_iter = filter_next; - g_object_set (G_OBJECT (temp_iter), "row", row, NULL); if (clutter_model_filter_iter (model, temp_iter)) - break; + { + row += 1; + break; + } filter_next = g_sequence_iter_next (filter_next); - row += 1; } g_object_unref (temp_iter); - /* We do this because the 'end_iter' is always *after* the last valid iter. - * Otherwise loops will go on forever - */ - if (filter_next == iter_default->seq_iter) - filter_next = g_sequence_iter_next (filter_next); + if (g_sequence_iter_is_end (filter_next)) + row += 1; /* update the iterator and return it */ g_object_set (G_OBJECT (iter_default), "model", model, "row", row, NULL); @@ -372,7 +362,7 @@ clutter_list_model_iter_prev (ClutterModelIter *iter) g_assert (iter_default->seq_iter != NULL); model = clutter_model_iter_get_model (iter); - row = clutter_model_iter_get_row (iter) - 1; + row = clutter_model_iter_get_row (iter); filter_prev = g_sequence_iter_prev (iter_default->seq_iter); g_assert (filter_prev != NULL); @@ -384,22 +374,20 @@ clutter_list_model_iter_prev (ClutterModelIter *iter) while (!g_sequence_iter_is_begin (filter_prev)) { CLUTTER_LIST_MODEL_ITER (temp_iter)->seq_iter = filter_prev; - g_object_set (G_OBJECT (temp_iter), "row", row, NULL); if (clutter_model_filter_iter (model, temp_iter)) - break; + { + row -= 1; + break; + } filter_prev = g_sequence_iter_prev (filter_prev); - row -= 1; } g_object_unref (temp_iter); - /* We do this because the 'end_iter' is always *after* the last valid iter. - * Otherwise loops will go on forever - */ - if (filter_prev == iter_default->seq_iter) - filter_prev = g_sequence_iter_prev (filter_prev); + if (g_sequence_iter_is_begin (filter_prev)) + row -= 1; /* update the iterator and return it */ g_object_set (G_OBJECT (iter_default), "model", model, "row", row, NULL); @@ -466,16 +454,61 @@ clutter_list_model_get_iter_at_row (ClutterModel *model, { ClutterListModel *model_default = CLUTTER_LIST_MODEL (model); GSequence *sequence = model_default->priv->sequence; + gint seq_length = g_sequence_get_length (sequence); ClutterListModelIter *retval; - if (row >= g_sequence_get_length (sequence)) + if (row >= seq_length) return NULL; retval = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER, "model", model, "row", row, NULL); - retval->seq_iter = g_sequence_get_iter_at_pos (sequence, row); + + /* short-circuit in case we don't have a filter in place */ + if (!clutter_model_get_filter_set (model)) + { + retval->seq_iter = g_sequence_get_iter_at_pos (sequence, row); + + return CLUTTER_MODEL_ITER (retval); + } + + if (row == 0) + { + GSequenceIter *filter_next; + + filter_next = g_sequence_get_begin_iter (sequence); + g_assert (filter_next != NULL); + + while (!g_sequence_iter_is_end (filter_next)) + { + retval->seq_iter = filter_next; + + if (clutter_model_filter_iter (model, CLUTTER_MODEL_ITER (retval))) + break; + + filter_next = g_sequence_iter_next (filter_next); + } + } + else + { + GSequenceIter *filter_prev; + + filter_prev = g_sequence_get_end_iter (sequence); + g_assert (filter_prev != NULL); + + filter_prev = g_sequence_iter_prev (filter_prev); + + while (!g_sequence_iter_is_begin (filter_prev)) + { + retval->seq_iter = filter_prev; + + if (clutter_model_filter_iter (model, CLUTTER_MODEL_ITER (retval))) + break; + + filter_prev = g_sequence_iter_prev (filter_prev); + } + } return CLUTTER_MODEL_ITER (retval); } @@ -507,7 +540,7 @@ clutter_list_model_insert_row (ClutterModel *model, if (index_ < 0) { seq_iter = g_sequence_append (sequence, array); - pos = g_sequence_get_length (sequence); + pos = g_sequence_get_length (sequence) - 1; } else if (index_ == 0) { @@ -574,14 +607,6 @@ clutter_list_model_remove_row (ClutterModel *model, } } -static guint -clutter_list_model_get_n_rows (ClutterModel *model) -{ - ClutterListModel *model_default = CLUTTER_LIST_MODEL (model); - - return g_sequence_get_length (model_default->priv->sequence); -} - typedef struct { ClutterModel *model; @@ -668,7 +693,6 @@ clutter_list_model_class_init (ClutterListModelClass *klass) gobject_class->finalize = clutter_list_model_finalize; - model_class->get_n_rows = clutter_list_model_get_n_rows; model_class->get_iter_at_row = clutter_list_model_get_iter_at_row; model_class->insert_row = clutter_list_model_insert_row; model_class->remove_row = clutter_list_model_remove_row; diff --git a/clutter/clutter-model.c b/clutter/clutter-model.c index e1380fb74..cfca42897 100644 --- a/clutter/clutter-model.c +++ b/clutter/clutter-model.c @@ -208,28 +208,6 @@ clutter_model_real_get_n_columns (ClutterModel *model) return model->priv->n_columns; } -static guint -clutter_model_real_get_n_rows (ClutterModel *model) -{ - ClutterModelIter *iter; - guint n_rows = 0; - - iter = clutter_model_get_first_iter (model); - if (!iter) - return 0; - - while (!clutter_model_iter_is_last (iter)) - { - n_rows += 1; - - clutter_model_iter_next (iter); - } - - g_object_unref (iter); - - return n_rows; -} - static void clutter_model_finalize (GObject *object) { @@ -289,7 +267,6 @@ clutter_model_class_init (ClutterModelClass *klass) klass->get_column_name = clutter_model_real_get_column_name; klass->get_column_type = clutter_model_real_get_column_type; klass->get_n_columns = clutter_model_real_get_n_columns; - klass->get_n_rows = clutter_model_real_get_n_rows; /** * ClutterModel:filter-set: @@ -519,7 +496,7 @@ clutter_model_filter_row (ClutterModel *model, return TRUE; iter = clutter_model_get_iter_at_row (model, row); - if (!iter) + if (iter == NULL) return FALSE; res = priv->filter_func (model, iter, priv->filter_data); @@ -1162,6 +1139,10 @@ clutter_model_get_column_type (ClutterModel *model, * * Retrieves a #ClutterModelIter representing the row at the given index. * + * If a filter function has been set using clutter_model_set_filter() + * then the @model implementation will return the first non filtered + * row. + * * Return value: (transfer full): A new #ClutterModelIter, or %NULL if @row was * out of bounds. When done using the iterator object, call g_object_unref() * to deallocate its resources @@ -1188,49 +1169,65 @@ clutter_model_get_iter_at_row (ClutterModel *model, * clutter_model_get_first_iter: * @model: a #ClutterModel * - * Retrieves a #ClutterModelIter representing the first row in @model. + * Retrieves a #ClutterModelIter representing the first non-filtered + * row in @model. * - * Return value: (transfer full): A new #ClutterModelIter. Call g_object_unref() when - * done using it + * Return value: (transfer full): A new #ClutterModelIter. + * Call g_object_unref() when done using it * * Since: 0.6 */ ClutterModelIter * clutter_model_get_first_iter (ClutterModel *model) { + ClutterModelIter *retval; + g_return_val_if_fail (CLUTTER_IS_MODEL (model), NULL); - return clutter_model_get_iter_at_row (model, 0); + retval = clutter_model_get_iter_at_row (model, 0); + if (retval != NULL) + { + g_assert (clutter_model_filter_iter (model, retval) != FALSE); + g_assert (clutter_model_iter_get_row (retval) == 0); + } + + return retval; } /** * clutter_model_get_last_iter: * @model: a #ClutterModel * - * Retrieves a #ClutterModelIter representing the last row in @model. + * Retrieves a #ClutterModelIter representing the last non-filtered + * row in @model. * - * Return value: (transfer full): A new #ClutterModelIter. Call g_object_unref() when - * done using it + * Return value: (transfer full): A new #ClutterModelIter. + * Call g_object_unref() when done using it * * Since: 0.6 */ ClutterModelIter * clutter_model_get_last_iter (ClutterModel *model) { + ClutterModelIter *retval; guint length; g_return_val_if_fail (CLUTTER_IS_MODEL (model), NULL); length = clutter_model_get_n_rows (model); + retval = clutter_model_get_iter_at_row (model, length - 1); + if (retval != NULL) + g_assert (clutter_model_filter_iter (model, retval) != FALSE); - return clutter_model_get_iter_at_row (model, length - 1); + return retval; } /** * clutter_model_get_n_rows: * @model: a #ClutterModel * - * Retrieves the number of rows inside @model. + * Retrieves the number of rows inside @model, eventually taking + * into account any filtering function set using clutter_model_set_filter(). * * Return value: The length of the @model. If there is a filter set, then * the length of the filtered @model is returned. @@ -1240,9 +1237,35 @@ clutter_model_get_last_iter (ClutterModel *model) guint clutter_model_get_n_rows (ClutterModel *model) { + ClutterModelClass *klass; + guint row_count; + g_return_val_if_fail (CLUTTER_IS_MODEL (model), 0); - return CLUTTER_MODEL_GET_CLASS (model)->get_n_rows (model); + klass = CLUTTER_MODEL_GET_CLASS (model); + if (klass->get_n_rows) + row_count = klass->get_n_rows (model); + else + { + ClutterModelIter *iter; + + iter = clutter_model_get_first_iter (model); + if (iter == NULL) + return 0; + + row_count = 0; + while (!clutter_model_iter_is_last (iter)) + { + if (clutter_model_filter_iter (model, iter)) + row_count += 1; + + iter = clutter_model_iter_next (iter); + } + + g_object_unref (iter); + } + + return row_count; } @@ -1358,6 +1381,9 @@ clutter_model_set_sort (ClutterModel *model, ClutterModelPrivate *priv; g_return_if_fail (CLUTTER_IS_MODEL (model)); + g_return_if_fail ((func != NULL && column >= 0) || + (func == NULL && column == -1)); + priv = model->priv; if (priv->sort_notify) @@ -1604,7 +1630,8 @@ clutter_model_iter_set_property (GObject *object, static void clutter_model_iter_class_init (ClutterModelIterClass *klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GParamSpec *pspec; gobject_class->get_property = clutter_model_iter_get_property; gobject_class->set_property = clutter_model_iter_set_property; @@ -1628,28 +1655,26 @@ clutter_model_iter_class_init (ClutterModelIterClass *klass) * * Since: 0.6 */ - g_object_class_install_property (gobject_class, - ITER_PROP_MODEL, - g_param_spec_object ("model", - "Model", - "The model to which the iterator belongs to", - CLUTTER_TYPE_MODEL, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_object ("model", + "Model", + "The model to which the iterator belongs to", + CLUTTER_TYPE_MODEL, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (gobject_class, ITER_PROP_MODEL, pspec); - /** + /** * ClutterModelIter:row: * * The row number to which this iter points to. * * Since: 0.6 */ - g_object_class_install_property (gobject_class, - ITER_PROP_ROW, - g_param_spec_uint ("row", - "Row", - "The row to which the iterator points to", - 0, G_MAXUINT, 0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_uint ("row", + "Row", + "The row to which the iterator points to", + 0, G_MAXUINT, 0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (gobject_class, ITER_PROP_ROW, pspec); g_type_class_add_private (gobject_class, sizeof (ClutterModelIterPrivate)); } diff --git a/clutter/clutter-model.h b/clutter/clutter-model.h index 2bf13dabd..bae1faf3b 100644 --- a/clutter/clutter-model.h +++ b/clutter/clutter-model.h @@ -129,7 +129,7 @@ struct _ClutterModel * @get_iter_at_row: virtual function for returning an iterator for the * given row * @get_n_rows: virtual function for returning the number of rows - * of the model, not considering any filter function if present + * of the model * @get_n_columns: virtual function for retuning the number of columns * of the model * @resort: virtual function for sorting the model using the passed From f3e33bd25a0f9710166d5e72524163966f3c2982 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 29 Apr 2009 15:39:23 +0100 Subject: [PATCH 04/66] [tests] Exercise the Model filtering Add a test unit that exercises the ClutterModel iteration API when there is a filter in place. --- tests/conform/test-conform-main.c | 1 + tests/conform/test-model.c | 138 ++++++++++++++++++++++++++++-- 2 files changed, 133 insertions(+), 6 deletions(-) diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c index d4ea35dfc..1996e03d7 100644 --- a/tests/conform/test-conform-main.c +++ b/tests/conform/test-conform-main.c @@ -139,6 +139,7 @@ main (int argc, char **argv) TEST_CONFORM_SIMPLE ("/model", test_list_model_populate); TEST_CONFORM_SIMPLE ("/model", test_list_model_iterate); + TEST_CONFORM_SIMPLE ("/model", test_list_model_filter); return g_test_run (); } diff --git a/tests/conform/test-model.c b/tests/conform/test-model.c index ef7a29b0c..45ffc6492 100644 --- a/tests/conform/test-model.c +++ b/tests/conform/test-model.c @@ -64,25 +64,50 @@ static const struct { { "String 1", 1 }, }; +static const struct { + const gchar *expected_foo; + gint expected_bar; +} filter_odd[] = { + { "String 1", 1 }, + { "String 3", 3 }, + { "String 5", 5 }, + { "String 7", 7 }, + { "String 9", 9 }, +}; + +static const struct { + const gchar *expected_foo; + gint expected_bar; +} filter_even[] = { + { "String 8", 8 }, + { "String 6", 6 }, + { "String 4", 4 }, + { "String 2", 2 }, +}; + static inline void compare_iter (ClutterModelIter *iter, + const gint expected_row, const gchar *expected_foo, const gint expected_bar) { gchar *foo = NULL; gint bar = 0; + gint row = 0; + row = clutter_model_iter_get_row (iter); clutter_model_iter_get (iter, COLUMN_FOO, &foo, COLUMN_BAR, &bar, -1); if (g_test_verbose ()) - g_print ("Row %d: Got [ '%s', '%d' ], expected [ '%s', '%d' ]\n", - clutter_model_iter_get_row (iter), + g_print ("Row %d => %d: Got [ '%s', '%d' ], expected [ '%s', '%d' ]\n", + row, expected_row, foo, bar, expected_foo, expected_bar); + g_assert_cmpint (row, ==, expected_row); g_assert_cmpstr (foo, ==, expected_foo); g_assert_cmpint (bar, ==, expected_bar); @@ -97,12 +122,114 @@ on_row_added (ClutterModel *model, ModelData *model_data = data; compare_iter (iter, + model_data->n_row, base_model[model_data->n_row].expected_foo, base_model[model_data->n_row].expected_bar); model_data->n_row += 1; } +static gboolean +filter_even_rows (ClutterModel *model, + ClutterModelIter *iter, + gpointer dummy G_GNUC_UNUSED) +{ + gint bar_value; + + clutter_model_iter_get (iter, COLUMN_BAR, &bar_value, -1); + + if (bar_value % 2 == 0) + return TRUE; + + return FALSE; +} + +static gboolean +filter_odd_rows (ClutterModel *model, + ClutterModelIter *iter, + gpointer dummy G_GNUC_UNUSED) +{ + gint bar_value; + + clutter_model_iter_get (iter, COLUMN_BAR, &bar_value, -1); + + if (bar_value % 2 != 0) + return TRUE; + + return FALSE; +} + +void +test_list_model_filter (TestConformSimpleFixture *fixture, + gconstpointer data) +{ + ModelData test_data = { NULL, 0 }; + ClutterModelIter *iter; + gint i; + + test_data.model = clutter_list_model_new (N_COLUMNS, + G_TYPE_STRING, "Foo", + G_TYPE_INT, "Bar"); + test_data.n_row = 0; + + for (i = 1; i < 10; i++) + { + gchar *foo = g_strdup_printf ("String %d", i); + + clutter_model_append (test_data.model, + COLUMN_FOO, foo, + COLUMN_BAR, i, + -1); + + g_free (foo); + } + + if (g_test_verbose ()) + g_print ("Forward iteration (filter odd)...\n"); + + clutter_model_set_filter (test_data.model, filter_odd_rows, NULL, NULL); + + iter = clutter_model_get_first_iter (test_data.model); + g_assert (iter != NULL); + + i = 0; + while (!clutter_model_iter_is_last (iter)) + { + compare_iter (iter, i, + filter_odd[i].expected_foo, + filter_odd[i].expected_bar); + + iter = clutter_model_iter_next (iter); + i += 1; + } + + g_object_unref (iter); + + if (g_test_verbose ()) + g_print ("Backward iteration (filter even)...\n"); + + clutter_model_set_filter (test_data.model, filter_even_rows, NULL, NULL); + + iter = clutter_model_get_last_iter (test_data.model); + g_assert (iter != NULL); + + i = 0; + do + { + compare_iter (iter, G_N_ELEMENTS (filter_even) - i - 1, + filter_even[i].expected_foo, + filter_even[i].expected_bar); + + iter = clutter_model_iter_prev (iter); + i += 1; + } + while (!clutter_model_iter_is_first (iter)); + + g_object_unref (iter); + + g_object_unref (test_data.model); +} + void test_list_model_iterate (TestConformSimpleFixture *fixture, gconstpointer data) @@ -141,7 +268,7 @@ test_list_model_iterate (TestConformSimpleFixture *fixture, i = 0; while (!clutter_model_iter_is_last (iter)) { - compare_iter (iter, + compare_iter (iter, i, forward_base[i].expected_foo, forward_base[i].expected_bar); @@ -158,10 +285,9 @@ test_list_model_iterate (TestConformSimpleFixture *fixture, g_assert (iter != NULL); i = 0; - do { - compare_iter (iter, + compare_iter (iter, G_N_ELEMENTS (backward_base) - i - 1, backward_base[i].expected_foo, backward_base[i].expected_bar); @@ -170,7 +296,7 @@ test_list_model_iterate (TestConformSimpleFixture *fixture, } while (!clutter_model_iter_is_first (iter)); - compare_iter (iter, + compare_iter (iter, G_N_ELEMENTS (backward_base) - i - 1, backward_base[i].expected_foo, backward_base[i].expected_bar); From d2cd636fb69e313e3105a21f6194b98b4a5cba30 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 29 Apr 2009 15:40:13 +0100 Subject: [PATCH 05/66] [docs] Add ClutterModel::get_filter_set() --- doc/reference/clutter/clutter-sections.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 7d645072e..ccbc16148 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1238,6 +1238,7 @@ clutter_model_set_sort clutter_model_resort ClutterModelFilterFunc clutter_model_set_filter +clutter_model_get_filter_set clutter_model_filter_iter clutter_model_filter_row From 48ac45f060a6b2df7a2adfecd6019ce18ae3db3b Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 29 Apr 2009 15:41:12 +0100 Subject: [PATCH 06/66] [gitignore] Update with the new Model test --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c0630e0a7..c473b18e1 100644 --- a/.gitignore +++ b/.gitignore @@ -187,6 +187,7 @@ stamp-h1 /tests/conform/test-vertex-buffer-mutability /tests/conform/test-list-model-iterate /tests/conform/test-list-model-populate +/tests/conform/test-list-model-filter /tests/conform/test-npot-texture /tests/conform/redhand.png /tests/micro-bench/test-glyph-perf From 8e6e09c8ef646f20bbcde7fdff02069d0d20167e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Thu, 30 Apr 2009 11:54:09 +0100 Subject: [PATCH 07/66] [events] Added handling of missing type to clutter_event_get_state clutter_event_get_state wasn't returning the state for CLUTTER_BUTTON_RELEASE, the information was there it just needed to be returned correctly. --- clutter/clutter-event.c | 1 + 1 file changed, 1 insertion(+) diff --git a/clutter/clutter-event.c b/clutter/clutter-event.c index a275c4da9..90d096b01 100644 --- a/clutter/clutter-event.c +++ b/clutter/clutter-event.c @@ -95,6 +95,7 @@ clutter_event_get_state (ClutterEvent *event) case CLUTTER_KEY_RELEASE: return event->key.modifier_state; case CLUTTER_BUTTON_PRESS: + case CLUTTER_BUTTON_RELEASE: return event->button.modifier_state; case CLUTTER_MOTION: return event->motion.modifier_state; From 4f692cc3ee9089c568952e758406954bc5cf72dd Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 30 Apr 2009 14:32:19 +0100 Subject: [PATCH 08/66] [ClutterTexture] Attach the FBO texture to a layer in the material Bug 1565 - test-fbo case failed in many platform clutter_texture_new_from_actor was broken because it created the FBO texture but then never attached it to the material so it was never used for rendering. The old behaviour in Clutter 0.8 was to assign the texture directly to priv->tex. In 0.9 priv->tex is replaced with priv->material which has a reference to the tex in layer 0. So putting the FBO texture directly in layer 0 more closely matches the original behaviour. --- clutter/clutter-texture.c | 47 ++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index 52dc01c98..9eb1a3152 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -82,7 +82,6 @@ struct _ClutterTexturePrivate gint max_tile_waste; ClutterTextureQuality filter_quality; CoglHandle material; - CoglHandle fbo_texture; gboolean no_slice; ClutterActor *fbo_source; @@ -289,31 +288,34 @@ clutter_texture_realize (ClutterActor *actor) CoglTextureFlags flags = COGL_TEXTURE_NONE; gint min_filter, mag_filter; gint max_waste = -1; + CoglHandle tex; /* Handle FBO's */ - if (priv->fbo_texture != COGL_INVALID_HANDLE) - cogl_handle_unref (priv->fbo_texture); - if (!priv->no_slice) max_waste = priv->max_tile_waste; if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH) flags |= COGL_TEXTURE_AUTO_MIPMAP; - priv->fbo_texture = - cogl_texture_new_with_size (priv->width, - priv->height, - max_waste, flags, - COGL_PIXEL_FORMAT_RGBA_8888); + tex = cogl_texture_new_with_size (priv->width, + priv->height, + max_waste, flags, + COGL_PIXEL_FORMAT_RGBA_8888); + + cogl_material_set_layer (priv->material, 0, tex); clutter_texture_quality_to_filters (priv->filter_quality, &min_filter, &mag_filter); - cogl_texture_set_filters (priv->fbo_texture, min_filter, mag_filter); + cogl_texture_set_filters (tex, min_filter, mag_filter); - priv->fbo_handle = cogl_offscreen_new_to_texture (priv->fbo_texture); + priv->fbo_handle = cogl_offscreen_new_to_texture (tex); + + /* The material now has a reference to the texture so it will + stick around */ + cogl_handle_unref (tex); if (priv->fbo_handle == COGL_INVALID_HANDLE) { @@ -1216,7 +1218,6 @@ clutter_texture_init (ClutterTexture *self) priv->repeat_y = FALSE; priv->sync_actor_size = TRUE; priv->material = cogl_material_new (); - priv->fbo_texture = COGL_INVALID_HANDLE; priv->fbo_handle = COGL_INVALID_HANDLE; priv->local_data = NULL; priv->keep_aspect_ratio = FALSE; @@ -2299,6 +2300,7 @@ on_fbo_source_size_change (GObject *object, { CoglTextureFlags flags = COGL_TEXTURE_NONE; gint min_filter, mag_filter; + CoglHandle tex; /* tear down the FBO */ cogl_handle_unref (priv->fbo_handle); @@ -2311,20 +2313,25 @@ on_fbo_source_size_change (GObject *object, if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH) flags |= COGL_TEXTURE_AUTO_MIPMAP; - priv->fbo_texture = - cogl_texture_new_with_size (MAX (priv->width, 1), - MAX (priv->height, 1), - -1, - flags, - COGL_PIXEL_FORMAT_RGBA_8888); + tex = cogl_texture_new_with_size (MAX (priv->width, 1), + MAX (priv->height, 1), + -1, + flags, + COGL_PIXEL_FORMAT_RGBA_8888); + + cogl_material_set_layer (priv->material, 0, tex); clutter_texture_quality_to_filters (priv->filter_quality, &min_filter, &mag_filter); - cogl_texture_set_filters (priv->fbo_texture, min_filter, mag_filter); + cogl_texture_set_filters (tex, min_filter, mag_filter); - priv->fbo_handle = cogl_offscreen_new_to_texture (priv->fbo_texture); + priv->fbo_handle = cogl_offscreen_new_to_texture (tex); + + /* The material now has a reference to the texture so it will + stick around */ + cogl_handle_unref (tex); if (priv->fbo_handle == COGL_INVALID_HANDLE) { From 20cd885c3d6b8fce611c156a491ca93ea7ba13c6 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 30 Apr 2009 15:00:01 +0100 Subject: [PATCH 09/66] [ClutterTexture] Check before unrefing the fbo_handle When replacing the fbo_handle with a new handle it first unrefs the old handle. This was previously a call to cogl_offscreen_unref which silently ignored attempts to unref COGL_INVALID_HANDLE. However the new cogl_handle_unref does check for this so we should make sure the handle is valid to avoid the warning. --- clutter/clutter-texture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index 9eb1a3152..e4a380178 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -2303,7 +2303,8 @@ on_fbo_source_size_change (GObject *object, CoglHandle tex; /* tear down the FBO */ - cogl_handle_unref (priv->fbo_handle); + if (priv->fbo_handle != COGL_INVALID_HANDLE) + cogl_handle_unref (priv->fbo_handle); texture_free_gl_resources (texture); From 741c4bb5e92c5f7f86188a89b9697b842783d714 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Fri, 24 Apr 2009 18:09:52 +0100 Subject: [PATCH 10/66] [cogl] Adds a bitfield argument to cogl_clear for specifying which buffers to clear Redundant clearing of depth and stencil buffers every render can be very expensive, so cogl now gives control over which auxiliary buffers are cleared. Note: For now clutter continues to clear the color, depth and stencil buffer each paint. --- README | 5 +++-- clutter/clutter-main.c | 5 ++++- clutter/clutter-stage.c | 5 ++++- clutter/clutter-texture.c | 8 +++++++- clutter/cogl/cogl.h.in | 21 ++++++++++++++++--- clutter/cogl/common/cogl.c | 42 +++++++++++++++++++++----------------- 6 files changed, 59 insertions(+), 27 deletions(-) diff --git a/README b/README index 6719889be..2bc9afb8d 100644 --- a/README +++ b/README @@ -295,8 +295,9 @@ Release Notes for Clutter 1.0 * cogl_clip_set* and cogl_clip_unset have been renamed to cogl_clip_push and cogl_clip_pop respectively so they self document their stacking semantics. -* cogl_paint_init was renamed to cogl_clear and no longer disables lighting - and fogging. +* cogl_paint_init was renamed to cogl_clear and no longer disables lighting and + fogging. cogl_clear also now takes a mask of the auxiliary buffers you want + to clear so you can avoid redundant clears of buffers you aren't using. * cogl_fog_set was renamed to cogl_set_fog and it now takes a mode argument giving control over the fogging blend factor equation, so that the diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 31b24d23f..d759fb774 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -372,7 +372,10 @@ _clutter_do_pick (ClutterStage *stage, cogl_color_set_from_4ub (&white, 255, 255, 255, 255); cogl_disable_fog (); - cogl_clear (&white); + cogl_clear (&white, + COGL_BUFFER_BIT_COLOR | + COGL_BUFFER_BIT_DEPTH | + COGL_BUFFER_BIT_STENCIL); /* Disable dithering (if any) when doing the painting in pick mode */ dither_was_on = glIsEnabled (GL_DITHER); diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index a9a7bf942..0833dee63 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -222,7 +222,10 @@ clutter_stage_paint (ClutterActor *self) priv->color.green, priv->color.blue, priv->color.alpha); - cogl_clear (&stage_color); + cogl_clear (&stage_color, + COGL_BUFFER_BIT_COLOR | + COGL_BUFFER_BIT_DEPTH | + COGL_BUFFER_BIT_STENCIL); if (priv->use_fog) { diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index e4a380178..6580e0b02 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -593,7 +593,10 @@ clutter_texture_paint (ClutterActor *self) /* cogl_clear is called to clear the buffers */ cogl_color_set_from_4ub (&transparent_col, 0, 0, 0, 0); - cogl_clear (&transparent_col); + cogl_clear (&transparent_col, + COGL_BUFFER_BIT_COLOR | + COGL_BUFFER_BIT_DEPTH | + COGL_BUFFER_BIT_STENCIL); cogl_disable_fog (); /* Clear the clipping stack so that if the FBO actor is being @@ -1454,6 +1457,9 @@ clutter_texture_set_cogl_texture (ClutterTexture *texture, g_object_notify (G_OBJECT (texture), "cogl-texture"); + /* Re-assert the filter quality on the new cogl texture */ + clutter_texture_set_filter_quality (texture, CLUTTER_TEXTURE_QUALITY_MEDIUM); + /* If resized actor may need resizing but paint() will do this */ if (CLUTTER_ACTOR_IS_VISIBLE (texture)) clutter_actor_queue_redraw (CLUTTER_ACTOR (texture)); diff --git a/clutter/cogl/cogl.h.in b/clutter/cogl/cogl.h.in index 5b5347c16..134b03df1 100644 --- a/clutter/cogl/cogl.h.in +++ b/clutter/cogl/cogl.h.in @@ -363,14 +363,29 @@ void cogl_set_fog (const CoglColor *fog_color, */ void cogl_disable_fog (void); +/** + * CoglBufferBit: + * @COGL_BUFFER_BIT_COLOR: Selects the primary color buffer + * @COGL_BUFFER_BIT_DEPTH: Selects the depth buffer + * @COGL_BUFFER_BIT_STENCIL: Selects the stencil buffer + */ +typedef enum _CoglBufferBit +{ + COGL_BUFFER_BIT_COLOR = 1L<<0, + COGL_BUFFER_BIT_DEPTH = 1L<<1, + COGL_BUFFER_BIT_STENCIL = 1L<<2 +} CoglBufferBit; + /** * cogl_clear: * @color: Background color to clear to + * @buffers: A mask of @CoglBufferBit's identifying which auxiliary + * buffers to clear * - * Clears the color buffer to @color. The depth buffer and stencil - * buffers are also cleared. + * Clears all the auxiliary buffers identified in the @buffers mask, and if + * that includes the color buffer then the specified @color is used. */ -void cogl_clear (const CoglColor *color); +void cogl_clear (const CoglColor *color, gulong buffers); /** * cogl_set_source: diff --git a/clutter/cogl/common/cogl.c b/clutter/cogl/common/cogl.c index c077983e5..34165a57c 100644 --- a/clutter/cogl/common/cogl.c +++ b/clutter/cogl/common/cogl.c @@ -82,32 +82,36 @@ _cogl_error_string(GLenum errorCode) #endif void -cogl_clear (const CoglColor *color) +cogl_clear (const CoglColor *color, gulong buffers) { + GLbitfield gl_buffers = 0; + #if COGL_DEBUG fprintf(stderr, "\n ============== Paint Start ================ \n"); #endif - GE( glClearColor (cogl_color_get_red_float (color), - cogl_color_get_green_float (color), - cogl_color_get_blue_float (color), - 0.0) ); + if (buffers & COGL_BUFFER_BIT_COLOR) + { + GE( glClearColor (cogl_color_get_red_float (color), + cogl_color_get_green_float (color), + cogl_color_get_blue_float (color), + 0.0) ); + gl_buffers |= GL_COLOR_BUFFER_BIT; + } + if (buffers & COGL_BUFFER_BIT_DEPTH) + gl_buffers |= GL_DEPTH_BUFFER_BIT; + if (buffers & COGL_BUFFER_BIT_STENCIL) + gl_buffers |= GL_STENCIL_BUFFER_BIT; - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + if (!gl_buffers) + { + static gboolean shown = FALSE; + if (!shown) + g_warning ("You should specify at least one auxiliary buffer when calling cogl_clear"); + return; + } - /* - * Disable the depth test for now as has some strange side effects, - * mainly on x/y axis rotation with multiple layers at same depth - * (eg rotating text on a bg has very strange effect). Seems no clean - * 100% effective way to fix without other odd issues.. So for now - * move to application to handle and add cogl_enable_depth_test() - * as for custom actors (i.e groups) to enable if need be. - * - * glEnable (GL_DEPTH_TEST); - * glEnable (GL_ALPHA_TEST) - * glDepthFunc (GL_LEQUAL); - * glAlphaFunc (GL_GREATER, 0.1); - */ + glClear (gl_buffers); } static inline gboolean From f85377372cc1317f8301a78423e76c668e281f3b Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Mon, 27 Apr 2009 15:48:12 +0100 Subject: [PATCH 11/66] [cogl] Updates all file headers and removes lots of trailing white space Adds missing notices, and ensures all the notices are consistent. The Cogl blurb also now reads: * Cogl * * An object oriented GL/GLES Abstraction/Utility Layer --- clutter/cogl/cogl-color.h | 12 +- clutter/cogl/cogl-debug.h | 23 ++++ clutter/cogl/cogl-deprecated.h | 23 ++++ clutter/cogl/cogl-fixed.h | 14 +- clutter/cogl/cogl-material.h | 23 ++++ clutter/cogl/cogl-matrix.h | 26 ++++ clutter/cogl/cogl-offscreen.h | 14 +- clutter/cogl/cogl-path.h | 12 +- clutter/cogl/cogl-shader.h | 12 +- clutter/cogl/cogl-texture.h | 12 +- clutter/cogl/cogl-types.h | 21 +-- clutter/cogl/cogl-vertex-buffer.h | 17 +-- clutter/cogl/cogl.h.in | 9 +- clutter/cogl/common/cogl-bitmap-fallback.c | 52 ++++---- clutter/cogl/common/cogl-bitmap-pixbuf.c | 38 +++--- clutter/cogl/common/cogl-bitmap.c | 40 +++--- clutter/cogl/common/cogl-clip-stack.c | 8 +- clutter/cogl/common/cogl-clip-stack.h | 8 +- clutter/cogl/common/cogl-color.c | 23 ++++ clutter/cogl/common/cogl-current-matrix.c | 11 +- clutter/cogl/common/cogl-current-matrix.h | 11 +- clutter/cogl/common/cogl-debug.c | 23 ++++ clutter/cogl/common/cogl-fixed.c | 23 ++++ clutter/cogl/common/cogl-handle.h | 8 +- clutter/cogl/common/cogl-internal.h | 5 +- clutter/cogl/common/cogl-material-private.h | 26 ++++ clutter/cogl/common/cogl-material.c | 25 ++++ clutter/cogl/common/cogl-matrix-stack.c | 11 +- clutter/cogl/common/cogl-matrix-stack.h | 11 +- clutter/cogl/common/cogl-matrix.c | 26 ++++ clutter/cogl/common/cogl-primitives.c | 122 +++++++++--------- clutter/cogl/common/cogl-primitives.h | 8 +- clutter/cogl/common/cogl-util.c | 16 +-- clutter/cogl/common/cogl-util.h | 10 +- .../cogl/common/cogl-vertex-buffer-private.h | 15 ++- clutter/cogl/common/cogl-vertex-buffer.c | 17 +-- clutter/cogl/common/cogl.c | 5 +- clutter/cogl/gl/cogl-context.c | 8 +- clutter/cogl/gl/cogl-context.h | 8 +- clutter/cogl/gl/cogl-defines.h.in | 22 ++-- clutter/cogl/gl/cogl-fbo.c | 84 ++++++------ clutter/cogl/gl/cogl-fbo.h | 8 +- clutter/cogl/gl/cogl-internal.h | 8 +- clutter/cogl/gl/cogl-primitives.c | 8 +- clutter/cogl/gl/cogl-program.c | 16 +-- clutter/cogl/gl/cogl-program.h | 8 +- clutter/cogl/gl/cogl-shader-private.h | 8 +- clutter/cogl/gl/cogl-shader.c | 10 +- clutter/cogl/gl/cogl-texture-private.h | 8 +- clutter/cogl/gl/cogl-texture.c | 13 +- clutter/cogl/gl/cogl.c | 4 +- clutter/cogl/gles/cogl-context.c | 8 +- clutter/cogl/gles/cogl-context.h | 8 +- clutter/cogl/gles/cogl-fbo.c | 8 +- clutter/cogl/gles/cogl-fbo.h | 8 +- clutter/cogl/gles/cogl-gles2-wrapper.c | 10 +- clutter/cogl/gles/cogl-gles2-wrapper.h | 8 +- clutter/cogl/gles/cogl-internal.h | 8 +- clutter/cogl/gles/cogl-primitives.c | 8 +- clutter/cogl/gles/cogl-program.c | 12 +- clutter/cogl/gles/cogl-program.h | 8 +- clutter/cogl/gles/cogl-shader-private.h | 8 +- clutter/cogl/gles/cogl-shader.c | 10 +- clutter/cogl/gles/cogl-texture-private.h | 8 +- clutter/cogl/gles/cogl-texture.c | 8 +- clutter/cogl/gles/cogl-util.c | 10 +- clutter/cogl/gles/cogl-util.h | 10 +- clutter/cogl/gles/cogl.c | 4 +- clutter/cogl/gles/stringify.sh | 30 ++++- 69 files changed, 684 insertions(+), 463 deletions(-) diff --git a/clutter/cogl/cogl-color.h b/clutter/cogl/cogl-color.h index 76be2053c..0cbc479a4 100644 --- a/clutter/cogl/cogl-color.h +++ b/clutter/cogl/cogl-color.h @@ -1,7 +1,9 @@ -/* cogl-color.h: Color type for COGL - * This file is part of Clutter +/* + * Cogl * - * Copyright (C) 2008 Intel Corporation. + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -14,7 +16,9 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) diff --git a/clutter/cogl/cogl-debug.h b/clutter/cogl/cogl-debug.h index 7440831b9..79a425282 100644 --- a/clutter/cogl/cogl-debug.h +++ b/clutter/cogl/cogl-debug.h @@ -1,3 +1,26 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2007,2008,2009 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + #ifndef __COGL_DEBUG_H__ #define __COGL_DEBUG_H__ diff --git a/clutter/cogl/cogl-deprecated.h b/clutter/cogl/cogl-deprecated.h index 17d1fe4d9..2111e48b4 100644 --- a/clutter/cogl/cogl-deprecated.h +++ b/clutter/cogl/cogl-deprecated.h @@ -1,3 +1,26 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2008,2009 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + #ifndef COGL_DEPRECATED_H #define cogl_color cogl_color_REPLACED_BY_cogl_set_source_color diff --git a/clutter/cogl/cogl-fixed.h b/clutter/cogl/cogl-fixed.h index 0e51c3584..904913ea6 100644 --- a/clutter/cogl/cogl-fixed.h +++ b/clutter/cogl/cogl-fixed.h @@ -1,7 +1,9 @@ -/* cogl-fixed.h: Fixed point API - * This file is part of Clutter +/* + * Cogl * - * Copyright (C) 2008 Intel Corporation. + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -14,7 +16,9 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) @@ -725,7 +729,7 @@ CoglFixed cogl_angle_cos (CoglAngle angle); /*< private >*/ #if defined (G_CAN_INLINE) -G_INLINE_FUNC CoglFixed +G_INLINE_FUNC CoglFixed cogl_fixed_mul (CoglFixed a, CoglFixed b) { diff --git a/clutter/cogl/cogl-material.h b/clutter/cogl/cogl-material.h index 949daed20..c77b09100 100644 --- a/clutter/cogl/cogl-material.h +++ b/clutter/cogl/cogl-material.h @@ -1,3 +1,26 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2007,2008,2009 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) #error "Only can be included directly." #endif diff --git a/clutter/cogl/cogl-matrix.h b/clutter/cogl/cogl-matrix.h index 9bf0e802e..ca643f146 100644 --- a/clutter/cogl/cogl-matrix.h +++ b/clutter/cogl/cogl-matrix.h @@ -1,3 +1,29 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2008,2009 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Robert Bragg + */ + #ifndef __COGL_MATRIX_H #define __COGL_MATRIX_H diff --git a/clutter/cogl/cogl-offscreen.h b/clutter/cogl/cogl-offscreen.h index a494052a7..17d2e54d6 100644 --- a/clutter/cogl/cogl-offscreen.h +++ b/clutter/cogl/cogl-offscreen.h @@ -1,7 +1,9 @@ -/* cogl-offscreen.h: Offscreen objects - * This file is part of Clutter +/* + * Cogl * - * Copyright (C) 2008 Intel Corporation. + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -14,7 +16,9 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) @@ -48,7 +52,7 @@ CoglHandle cogl_offscreen_new_to_texture (CoglHandle texhandle); /** * cogl_offscreen_new_multisample: - * + * * * Returns: */ diff --git a/clutter/cogl/cogl-path.h b/clutter/cogl/cogl-path.h index 47c46d0aa..be5a979e3 100644 --- a/clutter/cogl/cogl-path.h +++ b/clutter/cogl/cogl-path.h @@ -1,7 +1,9 @@ -/* cogl-path.h: Path primitives - * This file is part of Clutter +/* + * Cogl * - * Copyright (C) 2008 Intel Corporation. + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -14,7 +16,9 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) diff --git a/clutter/cogl/cogl-shader.h b/clutter/cogl/cogl-shader.h index 7678a6e25..4b5648265 100644 --- a/clutter/cogl/cogl-shader.h +++ b/clutter/cogl/cogl-shader.h @@ -1,7 +1,9 @@ -/* cogl-shader.h: Shaders and programmable pipeline - * This file is part of Clutter +/* + * Cogl * - * Copyright (C) 2008 Intel Corporation. + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -14,7 +16,9 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) diff --git a/clutter/cogl/cogl-texture.h b/clutter/cogl/cogl-texture.h index 4befd811d..f75abb3e5 100644 --- a/clutter/cogl/cogl-texture.h +++ b/clutter/cogl/cogl-texture.h @@ -1,7 +1,9 @@ -/* cogl-texture.h: Texture objects - * This file is part of Clutter +/* + * Cogl * - * Copyright (C) 2008 Intel Corporation. + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -14,7 +16,9 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) diff --git a/clutter/cogl/cogl-types.h b/clutter/cogl/cogl-types.h index 2773882fe..d00da14c6 100644 --- a/clutter/cogl/cogl-types.h +++ b/clutter/cogl/cogl-types.h @@ -1,13 +1,14 @@ -/* cogl-types.h: Shared COGL types +/* + * Cogl * - * This file is part of Clutter + * An object oriented GL/GLES Abstraction/Utility Layer * - * Copyright (C) 2008 Intel Corporation. + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +16,9 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) @@ -137,7 +140,7 @@ typedef enum COGL_PIXEL_FORMAT_RGBA_5551 = 6 | COGL_A_BIT, COGL_PIXEL_FORMAT_YUV = 7, COGL_PIXEL_FORMAT_G_8 = 8, - + COGL_PIXEL_FORMAT_RGB_888 = COGL_PIXEL_FORMAT_24, COGL_PIXEL_FORMAT_BGR_888 = (COGL_PIXEL_FORMAT_24 | @@ -178,7 +181,7 @@ typedef enum COGL_PREMULT_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT), - + COGL_PIXEL_FORMAT_RGBA_4444_PRE = (COGL_PIXEL_FORMAT_RGBA_4444 | COGL_A_BIT | COGL_PREMULT_BIT), @@ -186,8 +189,8 @@ typedef enum COGL_PIXEL_FORMAT_RGBA_5551_PRE = (COGL_PIXEL_FORMAT_RGBA_5551 | COGL_A_BIT | COGL_PREMULT_BIT), - - + + } CoglPixelFormat; #define COGL_TYPE_PIXEL_FORMAT (cogl_pixel_format_get_type ()) diff --git a/clutter/cogl/cogl-vertex-buffer.h b/clutter/cogl/cogl-vertex-buffer.h index 35016dafc..717281db0 100644 --- a/clutter/cogl/cogl-vertex-buffer.h +++ b/clutter/cogl/cogl-vertex-buffer.h @@ -1,13 +1,9 @@ /* - * Cogl. + * Cogl * - * An OpenGL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Vertex Buffer API: Handle extensible arrays of vertex attributes - * - * Copyright (C) 2008 Intel Corporation. - * - * Authored by: Robert Bragg + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,7 +16,12 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Robert Bragg */ #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) diff --git a/clutter/cogl/cogl.h.in b/clutter/cogl/cogl.h.in index 134b03df1..3e7860a61 100644 --- a/clutter/cogl/cogl.h.in +++ b/clutter/cogl/cogl.h.in @@ -1,13 +1,12 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. diff --git a/clutter/cogl/common/cogl-bitmap-fallback.c b/clutter/cogl/common/cogl-bitmap-fallback.c index cb9b9040c..b9ba9b737 100644 --- a/clutter/cogl/common/cogl-bitmap-fallback.c +++ b/clutter/cogl/common/cogl-bitmap-fallback.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -164,7 +162,7 @@ inline static void _cogl_unpremult_alpha_last (const guchar *src, guchar *dst) { guchar alpha = src[3]; - + dst[0] = ((((gulong) src[0] >> 16) & 0xff) * 255 ) / alpha; dst[1] = ((((gulong) src[1] >> 8) & 0xff) * 255 ) / alpha; dst[2] = ((((gulong) src[2] >> 0) & 0xff) * 255 ) / alpha; @@ -175,7 +173,7 @@ inline static void _cogl_unpremult_alpha_first (const guchar *src, guchar *dst) { guchar alpha = src[0]; - + dst[0] = alpha; dst[1] = ((((gulong) src[1] >> 16) & 0xff) * 255 ) / alpha; dst[2] = ((((gulong) src[2] >> 8) & 0xff) * 255 ) / alpha; @@ -187,23 +185,23 @@ _cogl_bitmap_fallback_can_convert (CoglPixelFormat src, CoglPixelFormat dst) { if (src == dst) return FALSE; - + switch (src & COGL_UNORDERED_MASK) { case COGL_PIXEL_FORMAT_G_8: case COGL_PIXEL_FORMAT_24: case COGL_PIXEL_FORMAT_32: - + if ((dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_24 && (dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_32 && (dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_G_8) return FALSE; break; - + default: return FALSE; } - + return TRUE; } @@ -224,11 +222,11 @@ _cogl_bitmap_fallback_convert (const CoglBitmap *bmp, gint dst_bpp; gint x,y; guchar temp_rgba[4] = {0,0,0,0}; - + /* Make sure conversion supported */ if (!_cogl_bitmap_fallback_can_convert (bmp->format, dst_format)) return FALSE; - + src_bpp = _cogl_get_format_bpp (bmp->format); dst_bpp = _cogl_get_format_bpp (dst_format); @@ -237,18 +235,18 @@ _cogl_bitmap_fallback_convert (const CoglBitmap *bmp, dst_bmp->rowstride = sizeof(guchar) * dst_bpp * dst_bmp->width; dst_bmp->format = ((bmp->format & COGL_PREMULT_BIT) | (dst_format & COGL_UNPREMULT_MASK)); - + /* Allocate a new buffer to hold converted data */ dst_bmp->data = g_malloc (sizeof(guchar) * dst_bmp->height * dst_bmp->rowstride); - + /* FIXME: Optimize */ for (y = 0; y < bmp->height; y++) { src = (guchar*)bmp->data + y * bmp->rowstride; dst = (guchar*)dst_bmp->data + y * dst_bmp->rowstride; - + for (x = 0; x < bmp->width; x++) { /* FIXME: Would be nice to at least remove this inner @@ -273,7 +271,7 @@ _cogl_bitmap_fallback_convert (const CoglBitmap *bmp, default: break; } - + switch (dst_format & COGL_UNPREMULT_MASK) { case COGL_PIXEL_FORMAT_G_8: @@ -293,12 +291,12 @@ _cogl_bitmap_fallback_convert (const CoglBitmap *bmp, default: break; } - + src += src_bpp; dst += dst_bpp; } } - + return TRUE; } @@ -310,28 +308,28 @@ _cogl_bitmap_fallback_unpremult (const CoglBitmap *bmp, guchar *dst; gint bpp; gint x,y; - + /* Make sure format supported for un-premultiplication */ if (!_cogl_bitmap_fallback_can_unpremult (bmp->format)) return FALSE; - + bpp = _cogl_get_format_bpp (bmp->format); - + /* Initialize destination bitmap */ *dst_bmp = *bmp; dst_bmp->format = (bmp->format & COGL_UNPREMULT_MASK); - + /* Allocate a new buffer to hold converted data */ dst_bmp->data = g_malloc (sizeof(guchar) * dst_bmp->height * dst_bmp->rowstride); - + /* FIXME: Optimize */ for (y = 0; y < bmp->height; y++) { src = (guchar*)bmp->data + y * bmp->rowstride; dst = (guchar*)dst_bmp->data + y * dst_bmp->rowstride; - + for (x = 0; x < bmp->width; x++) { /* FIXME: Would be nice to at least remove this inner @@ -351,12 +349,12 @@ _cogl_bitmap_fallback_unpremult (const CoglBitmap *bmp, else _cogl_unpremult_alpha_last (src, dst); } - + src += bpp; dst += bpp; } } - + return TRUE; } diff --git a/clutter/cogl/common/cogl-bitmap-pixbuf.c b/clutter/cogl/common/cogl-bitmap-pixbuf.c index 8d86d94e4..4108e321a 100644 --- a/clutter/cogl/common/cogl-bitmap-pixbuf.c +++ b/clutter/cogl/common/cogl-bitmap-pixbuf.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -222,7 +220,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, guchar *out_data; guchar *out; gint r; - + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); if (bmp == NULL) @@ -232,7 +230,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, pixbuf = gdk_pixbuf_new_from_file (filename, error); if (pixbuf == NULL) return FALSE; - + /* Get pixbuf properties */ has_alpha = gdk_pixbuf_get_has_alpha (pixbuf); color_space = gdk_pixbuf_get_colorspace (pixbuf); @@ -241,10 +239,10 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, rowstride = gdk_pixbuf_get_rowstride (pixbuf); bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf); n_channels = gdk_pixbuf_get_n_channels (pixbuf); - + /* The docs say this is the right way */ last_row_size = width * ((n_channels * bits_per_sample + 7) / 8); - + /* According to current docs this should be true and so * the translation to cogl pixel format below valid */ g_assert (bits_per_sample == 8); @@ -253,7 +251,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, g_assert (n_channels == 4); else g_assert (n_channels == 3); - + /* Translate to cogl pixel format */ switch (color_space) { @@ -263,19 +261,19 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888; break; - + default: /* Ouch, spec changed! */ g_object_unref (pixbuf); return FALSE; } - + /* FIXME: Any way to destroy pixbuf but retain pixel data? */ - + pixels = gdk_pixbuf_get_pixels (pixbuf); out_data = (guchar*) g_malloc (height * rowstride); out = out_data; - + /* Copy up to last row */ for (r = 0; r < height-1; ++r) { @@ -283,13 +281,13 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, pixels += rowstride; out += rowstride; } - + /* Copy last row */ memcpy (out, pixels, last_row_size); - + /* Destroy GdkPixbuf object */ g_object_unref (pixbuf); - + /* Store bitmap info */ bmp->data = out_data; /* The stored data the same alignment constraints as a * gdkpixbuf but stores a full rowstride in the last @@ -299,7 +297,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, bmp->width = width; bmp->height = height; bmp->rowstride = rowstride; - + return TRUE; } @@ -335,14 +333,14 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, if (bmp == NULL) return FALSE; - + /* Load from file using stb */ pixels = stbi_load (filename, &width, &height, &stb_pixel_format, STBI_rgb_alpha); if (pixels == NULL) return FALSE; - + /* Store bitmap info */ bmp->data = g_memdup (pixels, height * width * 4); bmp->format = COGL_PIXEL_FORMAT_RGBA_8888; diff --git a/clutter/cogl/common/cogl-bitmap.c b/clutter/cogl/common/cogl-bitmap.c index b0a3b7138..af3bc53b6 100644 --- a/clutter/cogl/common/cogl-bitmap.c +++ b/clutter/cogl/common/cogl-bitmap.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -47,7 +45,7 @@ _cogl_get_format_bpp (CoglPixelFormat format) 2, /* YUV */ 1 /* G_8 */ }; - + return bpp_lut [format & COGL_UNORDERED_MASK]; } @@ -59,7 +57,7 @@ _cogl_bitmap_convert_and_premult (const CoglBitmap *bmp, CoglBitmap tmp_bmp = *bmp; CoglBitmap new_bmp = *bmp; gboolean new_bmp_owner = FALSE; - + /* Is base format different (not considering premult status)? */ if ((bmp->format & COGL_UNPREMULT_MASK) != (dst_format & COGL_UNPREMULT_MASK)) @@ -71,12 +69,12 @@ _cogl_bitmap_convert_and_premult (const CoglBitmap *bmp, if (!_cogl_bitmap_fallback_convert (&new_bmp, &tmp_bmp, dst_format)) return FALSE; } - + /* Update bitmap with new data */ new_bmp = tmp_bmp; new_bmp_owner = TRUE; } - + /* Do we need to unpremultiply */ if ((bmp->format & COGL_PREMULT_BIT) == 0 && (dst_format & COGL_PREMULT_BIT) > 0) @@ -89,19 +87,19 @@ _cogl_bitmap_convert_and_premult (const CoglBitmap *bmp, { if (new_bmp_owner) g_free (new_bmp.data); - + return FALSE; } } - + /* Update bitmap with new data */ if (new_bmp_owner) g_free (new_bmp.data); - + new_bmp = tmp_bmp; new_bmp_owner = TRUE; } - + /* Do we need to premultiply */ if ((bmp->format & COGL_PREMULT_BIT) > 0 && (dst_format & COGL_PREMULT_BIT) == 0) @@ -109,13 +107,13 @@ _cogl_bitmap_convert_and_premult (const CoglBitmap *bmp, /* FIXME: implement premultiplication */ if (new_bmp_owner) g_free (new_bmp.data); - + return FALSE; } - + /* Output new bitmap info */ *dst_bmp = new_bmp; - + return TRUE; } @@ -133,14 +131,14 @@ _cogl_bitmap_copy_subregion (CoglBitmap *src, guchar *dstdata; gint bpp; gint line; - + /* Intended only for fast copies when format is equal! */ g_assert (src->format == dst->format); bpp = _cogl_get_format_bpp (src->format); - + srcdata = src->data + src_y * src->rowstride + src_x * bpp; dstdata = dst->data + dst_y * dst->rowstride + dst_x * bpp; - + for (line=0; line - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/common/cogl-clip-stack.h b/clutter/cogl/common/cogl-clip-stack.h index cbabc7381..324097b17 100644 --- a/clutter/cogl/common/cogl-clip-stack.h +++ b/clutter/cogl/common/cogl-clip-stack.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/common/cogl-color.c b/clutter/cogl/common/cogl-color.c index 1a9e24e9b..306005f2f 100644 --- a/clutter/cogl/common/cogl-color.c +++ b/clutter/cogl/common/cogl-color.c @@ -1,3 +1,26 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2008,2009 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/clutter/cogl/common/cogl-current-matrix.c b/clutter/cogl/common/cogl-current-matrix.c index 1ccb4c6dd..0080af0d1 100644 --- a/clutter/cogl/common/cogl-current-matrix.c +++ b/clutter/cogl/common/cogl-current-matrix.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Havoc Pennington for litl - * - * Copyright (C) 2009 OpenedHand + * Copyright (C) 2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -21,6 +19,9 @@ * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. + * + * Authors: + * Havoc Pennington for litl */ #ifdef HAVE_CONFIG_H diff --git a/clutter/cogl/common/cogl-current-matrix.h b/clutter/cogl/common/cogl-current-matrix.h index 3e271c97a..d1b1bdec7 100644 --- a/clutter/cogl/common/cogl-current-matrix.h +++ b/clutter/cogl/common/cogl-current-matrix.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Havoc Pennington for litl - * - * Copyright (C) 2009 OpenedHand + * Copyright (C) 2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -21,6 +19,9 @@ * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. + * + * Authors: + * Havoc Pennington for litl */ #ifndef __COGL_CURRENT_MATRIX_H diff --git a/clutter/cogl/common/cogl-debug.c b/clutter/cogl/common/cogl-debug.c index 2200b1f19..2763314d5 100644 --- a/clutter/cogl/common/cogl-debug.c +++ b/clutter/cogl/common/cogl-debug.c @@ -1,3 +1,26 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2009 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/clutter/cogl/common/cogl-fixed.c b/clutter/cogl/common/cogl-fixed.c index 846ede800..13a967651 100644 --- a/clutter/cogl/common/cogl-fixed.c +++ b/clutter/cogl/common/cogl-fixed.c @@ -1,3 +1,26 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2007,2008,2009 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + #define G_IMPLEMENT_INLINES #ifdef HAVE_CONFIG_H diff --git a/clutter/cogl/common/cogl-handle.h b/clutter/cogl/common/cogl-handle.h index 95e85e34e..8ca3400af 100644 --- a/clutter/cogl/common/cogl-handle.h +++ b/clutter/cogl/common/cogl-handle.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/common/cogl-internal.h b/clutter/cogl/common/cogl-internal.h index 559e1faab..595242168 100644 --- a/clutter/cogl/common/cogl-internal.h +++ b/clutter/cogl/common/cogl-internal.h @@ -1,10 +1,9 @@ /* * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Copyright (C) 2007, 2008 OpenedHand - * Copyright (C) 2009 Intel Corp. + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/common/cogl-material-private.h b/clutter/cogl/common/cogl-material-private.h index 4044894dd..05d4242dd 100644 --- a/clutter/cogl/common/cogl-material-private.h +++ b/clutter/cogl/common/cogl-material-private.h @@ -1,3 +1,29 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2008,2009 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Robert Bragg + */ + #ifndef __COGL_MATERIAL_PRIVATE_H #define __COGL_MATERIAL_PRIVATE_H diff --git a/clutter/cogl/common/cogl-material.c b/clutter/cogl/common/cogl-material.c index 498c85979..699ea0a10 100644 --- a/clutter/cogl/common/cogl-material.c +++ b/clutter/cogl/common/cogl-material.c @@ -1,3 +1,28 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2008,2009 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Robert Bragg + */ #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/clutter/cogl/common/cogl-matrix-stack.c b/clutter/cogl/common/cogl-matrix-stack.c index 38429fc6c..a72af000d 100644 --- a/clutter/cogl/common/cogl-matrix-stack.c +++ b/clutter/cogl/common/cogl-matrix-stack.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Havoc Pennington for litl - * - * Copyright (C) 2009 OpenedHand + * Copyright (C) 2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -21,6 +19,9 @@ * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. + * + * Authors: + * Havoc Pennington for litl */ #ifdef HAVE_CONFIG_H diff --git a/clutter/cogl/common/cogl-matrix-stack.h b/clutter/cogl/common/cogl-matrix-stack.h index 9f8001692..00db51685 100644 --- a/clutter/cogl/common/cogl-matrix-stack.h +++ b/clutter/cogl/common/cogl-matrix-stack.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Havoc Pennington for litl - * - * Copyright (C) 2009 OpenedHand + * Copyright (C) 2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -21,6 +19,9 @@ * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. + * + * Authors: + * Havoc Pennington for litl */ #ifndef __COGL_MATRIX_STACK_H diff --git a/clutter/cogl/common/cogl-matrix.c b/clutter/cogl/common/cogl-matrix.c index 0a041e7e3..6b6f20fae 100644 --- a/clutter/cogl/common/cogl-matrix.c +++ b/clutter/cogl/common/cogl-matrix.c @@ -1,3 +1,29 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2008,2009 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Robert Bragg + */ + #include #include diff --git a/clutter/cogl/common/cogl-primitives.c b/clutter/cogl/common/cogl-primitives.c index a1b0e2bc2..deeea562d 100644 --- a/clutter/cogl/common/cogl-primitives.c +++ b/clutter/cogl/common/cogl-primitives.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -1322,9 +1320,9 @@ cogl_path_fill_preserve (void) _COGL_GET_CONTEXT (ctx, NO_RETVAL); cogl_clip_ensure (); - + if (ctx->path_nodes->len == 0) - return; + return; _cogl_path_fill_nodes (); } @@ -1341,12 +1339,12 @@ void cogl_path_stroke_preserve (void) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + cogl_clip_ensure (); if (ctx->path_nodes->len == 0) return; - + _cogl_path_stroke_nodes(); } @@ -1355,14 +1353,14 @@ cogl_path_move_to (float x, float y) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + /* FIXME: handle multiple contours maybe? */ - + _cogl_path_add_node (TRUE, x, y); - + ctx->path_start.x = x; ctx->path_start.y = y; - + ctx->path_pen = ctx->path_start; } @@ -1371,7 +1369,7 @@ cogl_path_rel_move_to (float x, float y) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + cogl_path_move_to (ctx->path_pen.x + x, ctx->path_pen.y + y); } @@ -1381,9 +1379,9 @@ cogl_path_line_to (float x, float y) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + _cogl_path_add_node (FALSE, x, y); - + ctx->path_pen.x = x; ctx->path_pen.y = y; } @@ -1393,7 +1391,7 @@ cogl_path_rel_line_to (float x, float y) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + cogl_path_line_to (ctx->path_pen.x + x, ctx->path_pen.y + y); } @@ -1402,7 +1400,7 @@ void cogl_path_close (void) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + _cogl_path_add_node (FALSE, ctx->path_start.x, ctx->path_start.y); ctx->path_pen = ctx->path_start; } @@ -1430,9 +1428,9 @@ cogl_path_polyline (float *coords, gint num_points) { gint c = 0; - + cogl_path_move_to (coords[0], coords[1]); - + for (c = 1; c < num_points; ++c) cogl_path_line_to (coords[2*c], coords[2*c+1]); } @@ -1473,17 +1471,17 @@ _cogl_path_arc (float center_x, float sina = 0x0; float px = 0x0; float py = 0x0; - + /* Fix invalid angles */ - + if (angle_1 == angle_2 || angle_step == 0x0) return; - + if (angle_step < 0x0) angle_step = -angle_step; - + /* Walk the arc by given step */ - + a = angle_1; while (a != angle_2) { @@ -1492,12 +1490,12 @@ _cogl_path_arc (float center_x, px = center_x + (cosa * radius_x); py = center_y + (sina * radius_y); - + if (a == angle_1 && move_first) cogl_path_move_to (px, py); else cogl_path_line_to (px, py); - + if (G_LIKELY (angle_2 > angle_1)) { a += angle_step; @@ -1513,7 +1511,7 @@ _cogl_path_arc (float center_x, } /* Make sure the final point is drawn */ - + cosa = cosf (angle_2 * (G_PI/180.0)); sina = sinf (angle_2 * (G_PI/180.0)); @@ -1530,7 +1528,7 @@ cogl_path_arc (float center_x, float radius_y, float angle_1, float angle_2) -{ +{ float angle_step = 10; /* it is documented that a move to is needed to create a freestanding * arc @@ -1552,7 +1550,7 @@ cogl_path_arc_rel (float center_x, float angle_step) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + _cogl_path_arc (ctx->path_pen.x + center_x, ctx->path_pen.y + center_y, radius_x, radius_y, @@ -1567,15 +1565,15 @@ cogl_path_ellipse (float center_x, float radius_y) { float angle_step = 10; - + /* FIXME: if shows to be slow might be optimized * by mirroring just a quarter of it */ - + _cogl_path_arc (center_x, center_y, radius_x, radius_y, 0, 360, angle_step, 1 /* move first */); - + cogl_path_close(); } @@ -1589,7 +1587,7 @@ cogl_path_round_rectangle (float x_1, { float inner_width = x_2 - x_1 - radius * 2; float inner_height = y_2 - y_1 - radius * 2; - + _COGL_GET_CONTEXT (ctx, NO_RETVAL); cogl_path_move_to (x_1, y_1 + radius); @@ -1598,7 +1596,7 @@ cogl_path_round_rectangle (float x_1, 180, 270, arc_step); - + cogl_path_line_to (ctx->path_pen.x + inner_width, ctx->path_pen.y); cogl_path_arc_rel (0, radius, @@ -1606,7 +1604,7 @@ cogl_path_round_rectangle (float x_1, -90, 0, arc_step); - + cogl_path_line_to (ctx->path_pen.x, ctx->path_pen.y + inner_height); @@ -1615,7 +1613,7 @@ cogl_path_round_rectangle (float x_1, 0, 90, arc_step); - + cogl_path_line_to (ctx->path_pen.x - inner_width, ctx->path_pen.y); cogl_path_arc_rel (0, -radius, @@ -1623,7 +1621,7 @@ cogl_path_round_rectangle (float x_1, 90, 180, arc_step); - + cogl_path_close (); } @@ -1644,16 +1642,16 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic) floatVec2 c4; floatVec2 c5; gint cindex; - + /* Put first curve on stack */ cubics[0] = *cubic; cindex = 0; - + while (cindex >= 0) { c = &cubics[cindex]; - - + + /* Calculate distance of control points from their * counterparts on the line between end points */ dif1.x = (c->p2.x * 3) - (c->p1.x * 2) - c->p4.x; @@ -1669,12 +1667,12 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic) dif2.x = -dif2.x; if (dif2.y < 0) dif2.y = -dif2.y; - - + + /* Pick the greatest of two distances */ if (dif1.x < dif2.x) dif1.x = dif2.x; if (dif1.y < dif2.y) dif1.y = dif2.y; - + /* Cancel if the curve is flat enough */ if (dif1.x + dif1.y <= 1.0 || cindex == _COGL_MAX_BEZ_RECURSE_DEPTH-1) @@ -1689,10 +1687,10 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic) continue; } - + /* Left recursion goes on top of stack! */ cright = c; cleft = &cubics[++cindex]; - + /* Subdivide into 2 sub-curves */ c1.x = ((c->p1.x + c->p2.x) / 2); c1.y = ((c->p1.y + c->p2.y) / 2); @@ -1700,21 +1698,21 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic) mm.y = ((c->p2.y + c->p3.y) / 2); c5.x = ((c->p3.x + c->p4.x) / 2); c5.y = ((c->p3.y + c->p4.y) / 2); - + c2.x = ((c1.x + mm.x) / 2); c2.y = ((c1.y + mm.y) / 2); c4.x = ((mm.x + c5.x) / 2); c4.y = ((mm.y + c5.y) / 2); - + c3.x = ((c2.x + c4.x) / 2); c3.y = ((c2.y + c4.y) / 2); - + /* Add left recursion to stack */ cleft->p1 = c->p1; cleft->p2 = c1; cleft->p3 = c2; cleft->p4 = c3; - + /* Add right recursion to stack */ cright->p1 = c3; cright->p2 = c4; @@ -1761,7 +1759,7 @@ cogl_path_rel_curve_to (float x_1, float y_3) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + cogl_path_curve_to (ctx->path_pen.x + x_1, ctx->path_pen.y + y_1, ctx->path_pen.x + x_2, @@ -1789,17 +1787,17 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad) floatVec2 c2; floatVec2 c3; gint qindex; - + /* Put first curve on stack */ quads[0] = *quad; qindex = 0; - + /* While stack is not empty */ while (qindex >= 0) { - + q = &quads[qindex]; - + /* Calculate distance of control point from its * counterpart on the line between end points */ mid.x = ((q->p1.x + q->p3.x) / 2); @@ -1808,7 +1806,7 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad) dif.y = (q->p2.y - mid.y); if (dif.x < 0) dif.x = -dif.x; if (dif.y < 0) dif.y = -dif.y; - + /* Cancel if the curve is flat enough */ if (dif.x + dif.y <= 1.0 || qindex == _COGL_MAX_BEZ_RECURSE_DEPTH - 1) @@ -1818,10 +1816,10 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad) _cogl_path_add_node (FALSE, q->p3.x, q->p3.y); --qindex; continue; } - + /* Left recursion goes on top of stack! */ qright = q; qleft = &quads[++qindex]; - + /* Subdivide into 2 sub-curves */ c1.x = ((q->p1.x + q->p2.x) / 2); c1.y = ((q->p1.y + q->p2.y) / 2); @@ -1829,12 +1827,12 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad) c3.y = ((q->p2.y + q->p3.y) / 2); c2.x = ((c1.x + c3.x) / 2); c2.y = ((c1.y + c3.y) / 2); - + /* Add left recursion onto stack */ qleft->p1 = q->p1; qleft->p2 = c1; qleft->p3 = c2; - + /* Add right recursion onto stack */ qright->p1 = c2; qright->p2 = c3; @@ -1861,7 +1859,7 @@ cogl_path_curve2_to (float x_1, /* Run subdivision */ _cogl_path_bezier2_sub (&quad); - + /* Add last point */ _cogl_path_add_node (FALSE, quad.p3.x, quad.p3.y); ctx->path_pen = quad.p3; diff --git a/clutter/cogl/common/cogl-primitives.h b/clutter/cogl/common/cogl-primitives.h index e792432b6..268fba3cd 100644 --- a/clutter/cogl/common/cogl-primitives.h +++ b/clutter/cogl/common/cogl-primitives.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/common/cogl-util.c b/clutter/cogl/common/cogl-util.c index 61b08e228..1eb0db10e 100644 --- a/clutter/cogl/common/cogl-util.c +++ b/clutter/cogl/common/cogl-util.c @@ -1,18 +1,14 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By: Matthew Allum - * Emmanuele Bassi - * - * Copyright (C) 2007, 2008 OpenedHand - * Copyright (C) 2009 Intel Corp. + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,7 +16,9 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H diff --git a/clutter/cogl/common/cogl-util.h b/clutter/cogl/common/cogl-util.h index 759da8cc7..589ddd35a 100644 --- a/clutter/cogl/common/cogl-util.h +++ b/clutter/cogl/common/cogl-util.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,7 +24,7 @@ #ifndef __COGL_UTIL_H #define __COGL_UTIL_H -int +int cogl_util_next_p2 (int a); #endif /* __COGL_UTIL_H */ diff --git a/clutter/cogl/common/cogl-vertex-buffer-private.h b/clutter/cogl/common/cogl-vertex-buffer-private.h index 79117dd46..68a709b54 100644 --- a/clutter/cogl/common/cogl-vertex-buffer-private.h +++ b/clutter/cogl/common/cogl-vertex-buffer-private.h @@ -1,11 +1,9 @@ /* - * Cogl. + * Cogl * - * An OpenGL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Copyright (C) 2008 Intel Corporation. - * - * Authored By: Robert Bragg + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,7 +16,12 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Robert Bragg */ #ifndef __COGL_VERTEX_BUFFER_H diff --git a/clutter/cogl/common/cogl-vertex-buffer.c b/clutter/cogl/common/cogl-vertex-buffer.c index 7f6ed0f52..73e9a1c0c 100644 --- a/clutter/cogl/common/cogl-vertex-buffer.c +++ b/clutter/cogl/common/cogl-vertex-buffer.c @@ -1,13 +1,9 @@ /* - * Cogl. + * Cogl * - * An OpenGL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Vertex Buffer API: Handle extensible arrays of vertex attributes - * - * Copyright (C) 2008, 2009 Intel Corporation. - * - * Authored by: Robert Bragg + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,7 +16,12 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: + * Robert Bragg */ /* XXX: For an overview of the functionality implemented here, please diff --git a/clutter/cogl/common/cogl.c b/clutter/cogl/common/cogl.c index 34165a57c..3e1b33bbf 100644 --- a/clutter/cogl/common/cogl.c +++ b/clutter/cogl/common/cogl.c @@ -1,10 +1,9 @@ /* * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Copyright (C) 2007, 2008 OpenedHand - * Copyright (C) 2009 Intel Corp. + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gl/cogl-context.c b/clutter/cogl/gl/cogl-context.c index 5663e81ad..7f757f45e 100644 --- a/clutter/cogl/gl/cogl-context.c +++ b/clutter/cogl/gl/cogl-context.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gl/cogl-context.h b/clutter/cogl/gl/cogl-context.h index 7d025fc9f..602240793 100644 --- a/clutter/cogl/gl/cogl-context.h +++ b/clutter/cogl/gl/cogl-context.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gl/cogl-defines.h.in b/clutter/cogl/gl/cogl-defines.h.in index f9a3bced6..1c0c1636a 100644 --- a/clutter/cogl/gl/cogl-defines.h.in +++ b/clutter/cogl/gl/cogl-defines.h.in @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -865,26 +863,26 @@ typedef void typedef void (APIENTRYP COGL_PFNGLBINDBUFFERARBPROC) - (GLenum target, + (GLenum target, GLuint buffer); typedef void (APIENTRYP COGL_PFNGLBUFFERDATAARBPROC) - (GLenum target, - GLsizeiptr size, - const GLvoid *data, + (GLenum target, + GLsizeiptr size, + const GLvoid *data, GLenum usage); typedef void (APIENTRYP COGL_PFNGLBUFFERSUBDATAARBPROC) - (GLenum target, - GLintptr offset, + (GLenum target, + GLintptr offset, GLsizeiptr size, const GLvoid *data); typedef void * (APIENTRYP COGL_PFNGLMAPBUFFERARBPROC) - (GLenum target, + (GLenum target, GLenum access); typedef GLboolean diff --git a/clutter/cogl/gl/cogl-fbo.c b/clutter/cogl/gl/cogl-fbo.c index 13463d345..ce703d9a6 100644 --- a/clutter/cogl/gl/cogl-fbo.c +++ b/clutter/cogl/gl/cogl-fbo.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -71,25 +69,25 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle) GLuint fbo_gl_handle; GLuint gl_stencil_handle; GLenum status; - + _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); - + if (!cogl_features_available (COGL_FEATURE_OFFSCREEN)) return COGL_INVALID_HANDLE; - + /* Make texhandle is a valid texture object */ if (!cogl_is_texture (texhandle)) return COGL_INVALID_HANDLE; - + tex = _cogl_texture_pointer_from_handle (texhandle); - + /* The texture must not be sliced */ if (tex->slice_gl_handles == NULL) return COGL_INVALID_HANDLE; - + if (tex->slice_gl_handles->len != 1) return COGL_INVALID_HANDLE; - + /* Pick the single texture slice width, height and GL id */ x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, 0); y_span = &g_array_index (tex->slice_y_spans, CoglTexSliceSpan, 0); @@ -111,10 +109,10 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle) GE( glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, gl_stencil_handle) ); - + /* Make sure it's complete */ status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT); - + if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { /* Stencil renderbuffers aren't always supported. Try again @@ -125,9 +123,9 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle) 0) ); GE( glDeleteRenderbuffersEXT (1, &gl_stencil_handle) ); gl_stencil_handle = 0; - + status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT); - + if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { /* Still failing, so give up */ @@ -136,9 +134,9 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle) return COGL_INVALID_HANDLE; } } - + GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0) ); - + /* Allocate and init a CoglFbo object (store non-wasted size for subsequent blits and viewport setup) */ fbo = (CoglFbo*) g_malloc (sizeof (CoglFbo)); @@ -155,7 +153,7 @@ cogl_offscreen_new_multisample () { if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_MULTISAMPLE)) return COGL_INVALID_HANDLE; - + return COGL_INVALID_HANDLE; } @@ -186,22 +184,22 @@ cogl_offscreen_blit_region (CoglHandle src_buffer, { CoglFbo *src_fbo; CoglFbo *dst_fbo; - + _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_BLIT)) return; - + /* Make sure these are valid fbo handles */ if (!cogl_is_offscreen (src_buffer)) return; - + if (!cogl_is_offscreen (dst_buffer)) return; - + src_fbo = _cogl_offscreen_pointer_from_handle (src_buffer); dst_fbo = _cogl_offscreen_pointer_from_handle (dst_buffer); - + /* Copy (and scale) a region from one to another framebuffer */ GE( glBindFramebufferEXT (GL_READ_FRAMEBUFFER_EXT, src_fbo->gl_handle) ); GE( glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, dst_fbo->gl_handle) ); @@ -216,22 +214,22 @@ cogl_offscreen_blit (CoglHandle src_buffer, { CoglFbo *src_fbo; CoglFbo *dst_fbo; - + _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_BLIT)) return; - + /* Make sure these are valid fbo handles */ if (!cogl_is_offscreen (src_buffer)) return; - + if (!cogl_is_offscreen (dst_buffer)) return; - + src_fbo = _cogl_offscreen_pointer_from_handle (src_buffer); dst_fbo = _cogl_offscreen_pointer_from_handle (dst_buffer); - + /* Copy (and scale) whole image from one to another framebuffer */ GE( glBindFramebufferEXT (GL_READ_FRAMEBUFFER_EXT, src_fbo->gl_handle) ); GE( glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, dst_fbo->gl_handle) ); @@ -244,17 +242,17 @@ void cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) { CoglFbo *fbo = NULL; - + _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + if (target == COGL_OFFSCREEN_BUFFER) { /* Make sure it is a valid fbo handle */ if (!cogl_is_offscreen (offscreen)) return; - + fbo = _cogl_offscreen_pointer_from_handle (offscreen); - + /* Check current draw buffer target */ if (ctx->draw_buffer != COGL_OFFSCREEN_BUFFER) { @@ -280,16 +278,16 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) _cogl_set_current_matrix (COGL_MATRIX_MODELVIEW); _cogl_current_matrix_identity (); } - + /* Setup new viewport and matrices */ GE( glViewport (0, 0, fbo->width, fbo->height) ); _cogl_current_matrix_translate (-1.0f, -1.0f, 0.0f); _cogl_current_matrix_scale (2.0f / fbo->width, 2.0f / fbo->height, 1.0f); - + /* Bind offscreen framebuffer object */ GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fbo->gl_handle) ); GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) ); - + /* Some implementation require a clear before drawing to an fbo. Luckily it is affected by scissor test. */ /* FIXME: test where exactly this is needed end whether @@ -299,7 +297,7 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) GE( glEnable (GL_SCISSOR_TEST) ); GE( glClear (GL_COLOR_BUFFER_BIT) ); GE( glPopAttrib () ); - + } else if ((target & COGL_WINDOW_BUFFER) || (target & COGL_MASK_BUFFER)) @@ -317,11 +315,11 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) _cogl_set_current_matrix (COGL_MATRIX_MODELVIEW); _cogl_current_matrix_pop (); } - + /* Bind window framebuffer object */ GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0) ); - - + + if (target == COGL_WINDOW_BUFFER) { /* Draw to RGB channels */ @@ -338,7 +336,7 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) ); } } - + /* Store new target */ ctx->draw_buffer = target; } diff --git a/clutter/cogl/gl/cogl-fbo.h b/clutter/cogl/gl/cogl-fbo.h index 308c1d955..8499f8fb0 100644 --- a/clutter/cogl/gl/cogl-fbo.h +++ b/clutter/cogl/gl/cogl-fbo.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gl/cogl-internal.h b/clutter/cogl/gl/cogl-internal.h index b4ef91a01..0e83e7a52 100644 --- a/clutter/cogl/gl/cogl-internal.h +++ b/clutter/cogl/gl/cogl-internal.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gl/cogl-primitives.c b/clutter/cogl/gl/cogl-primitives.c index 8195a3d60..f3c11c134 100644 --- a/clutter/cogl/gl/cogl-primitives.c +++ b/clutter/cogl/gl/cogl-primitives.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gl/cogl-program.c b/clutter/cogl/gl/cogl-program.c index 6ee3775ec..1f652c95e 100644 --- a/clutter/cogl/gl/cogl-program.c +++ b/clutter/cogl/gl/cogl-program.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -96,7 +94,7 @@ cogl_program_attach_shader (CoglHandle program_handle, CoglShader *shader; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + if (!cogl_is_program (program_handle) || !cogl_is_shader (shader_handle)) return; @@ -111,7 +109,7 @@ cogl_program_link (CoglHandle handle) { CoglProgram *program; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + if (!cogl_is_program (handle)) return; @@ -126,7 +124,7 @@ cogl_program_use (CoglHandle handle) CoglProgram *program; GLhandleARB gl_handle; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + if (handle != COGL_INVALID_HANDLE && !cogl_is_program (handle)) return; @@ -147,7 +145,7 @@ cogl_program_get_uniform_location (CoglHandle handle, { CoglProgram *program; _COGL_GET_CONTEXT (ctx, 0); - + if (!cogl_is_program (handle)) return 0; diff --git a/clutter/cogl/gl/cogl-program.h b/clutter/cogl/gl/cogl-program.h index fa75f63b6..3a6bdf5b5 100644 --- a/clutter/cogl/gl/cogl-program.h +++ b/clutter/cogl/gl/cogl-program.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gl/cogl-shader-private.h b/clutter/cogl/gl/cogl-shader-private.h index 4c8fbbb44..f698c6c60 100644 --- a/clutter/cogl/gl/cogl-shader-private.h +++ b/clutter/cogl/gl/cogl-shader-private.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gl/cogl-shader.c b/clutter/cogl/gl/cogl-shader.c index 309db01cd..0d0896c09 100644 --- a/clutter/cogl/gl/cogl-shader.c +++ b/clutter/cogl/gl/cogl-shader.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -75,7 +73,7 @@ cogl_shader_source (CoglHandle handle, { CoglShader *shader; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + if (!cogl_is_shader (handle)) return; diff --git a/clutter/cogl/gl/cogl-texture-private.h b/clutter/cogl/gl/cogl-texture-private.h index 2a3a4a5a1..2905175bb 100644 --- a/clutter/cogl/gl/cogl-texture-private.h +++ b/clutter/cogl/gl/cogl-texture-private.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gl/cogl-texture.c b/clutter/cogl/gl/cogl-texture.c index 1c7b747bd..59132c2d4 100644 --- a/clutter/cogl/gl/cogl-texture.c +++ b/clutter/cogl/gl/cogl-texture.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -21,6 +19,11 @@ * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. + * + * Authors: + * Matthew Allum + * Neil Roberts + * Robert Bragg */ #ifdef HAVE_CONFIG_H diff --git a/clutter/cogl/gl/cogl.c b/clutter/cogl/gl/cogl.c index 47fe9d759..b2c5417e7 100644 --- a/clutter/cogl/gl/cogl.c +++ b/clutter/cogl/gl/cogl.c @@ -1,9 +1,9 @@ /* * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Copyright (C) 2007,2008,2009 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gles/cogl-context.c b/clutter/cogl/gles/cogl-context.c index 5630506e1..c5bc2e3c6 100644 --- a/clutter/cogl/gles/cogl-context.c +++ b/clutter/cogl/gles/cogl-context.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gles/cogl-context.h b/clutter/cogl/gles/cogl-context.h index 2a358de97..994b100ff 100644 --- a/clutter/cogl/gles/cogl-context.h +++ b/clutter/cogl/gles/cogl-context.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gles/cogl-fbo.c b/clutter/cogl/gles/cogl-fbo.c index c3a2cfd96..6f2aef569 100644 --- a/clutter/cogl/gles/cogl-fbo.c +++ b/clutter/cogl/gles/cogl-fbo.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gles/cogl-fbo.h b/clutter/cogl/gles/cogl-fbo.h index 308c1d955..8499f8fb0 100644 --- a/clutter/cogl/gles/cogl-fbo.h +++ b/clutter/cogl/gles/cogl-fbo.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.c b/clutter/cogl/gles/cogl-gles2-wrapper.c index 54a1d8c55..523676dd2 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.c +++ b/clutter/cogl/gles/cogl-gles2-wrapper.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -356,7 +354,7 @@ cogl_gles2_get_fragment_shader (const CoglGles2WrapperSettings *settings) g_string_append (shader_source, cogl_fixed_fragment_shader_main_declare); g_string_append (shader_source, cogl_fixed_fragment_shader_main_start); - + /* This pointless extra variable is needed to work around an apparent bug in the PowerVR drivers. Without it the alpha blending seems to stop working */ diff --git a/clutter/cogl/gles/cogl-gles2-wrapper.h b/clutter/cogl/gles/cogl-gles2-wrapper.h index 4d4fd1a43..bd7f6d978 100644 --- a/clutter/cogl/gles/cogl-gles2-wrapper.h +++ b/clutter/cogl/gles/cogl-gles2-wrapper.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gles/cogl-internal.h b/clutter/cogl/gles/cogl-internal.h index 5b9c8ab32..6ca9c7a82 100644 --- a/clutter/cogl/gles/cogl-internal.h +++ b/clutter/cogl/gles/cogl-internal.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gles/cogl-primitives.c b/clutter/cogl/gles/cogl-primitives.c index ae91aa061..1e03e1ea2 100644 --- a/clutter/cogl/gles/cogl-primitives.c +++ b/clutter/cogl/gles/cogl-primitives.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gles/cogl-program.c b/clutter/cogl/gles/cogl-program.c index 3c7096012..317310c32 100644 --- a/clutter/cogl/gles/cogl-program.c +++ b/clutter/cogl/gles/cogl-program.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -89,7 +87,7 @@ cogl_program_attach_shader (CoglHandle program_handle, CoglProgram *program; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + if (!cogl_is_program (program_handle) || !cogl_is_shader (shader_handle)) return; @@ -116,7 +114,7 @@ void cogl_program_use (CoglHandle handle) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + if (handle != COGL_INVALID_HANDLE && !cogl_is_program (handle)) return; diff --git a/clutter/cogl/gles/cogl-program.h b/clutter/cogl/gles/cogl-program.h index fdf52cd67..23b7ebeba 100644 --- a/clutter/cogl/gles/cogl-program.h +++ b/clutter/cogl/gles/cogl-program.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gles/cogl-shader-private.h b/clutter/cogl/gles/cogl-shader-private.h index e95fcd7d9..2b905d89f 100644 --- a/clutter/cogl/gles/cogl-shader-private.h +++ b/clutter/cogl/gles/cogl-shader-private.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gles/cogl-shader.c b/clutter/cogl/gles/cogl-shader.c index 5ea438406..d261e1a0b 100644 --- a/clutter/cogl/gles/cogl-shader.c +++ b/clutter/cogl/gles/cogl-shader.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -69,7 +67,7 @@ cogl_shader_source (CoglHandle handle, { CoglShader *shader; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + if (!cogl_is_shader (handle)) return; diff --git a/clutter/cogl/gles/cogl-texture-private.h b/clutter/cogl/gles/cogl-texture-private.h index 2a3a4a5a1..2905175bb 100644 --- a/clutter/cogl/gles/cogl-texture-private.h +++ b/clutter/cogl/gles/cogl-texture-private.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gles/cogl-texture.c b/clutter/cogl/gles/cogl-texture.c index e2a5ec90b..66af941c2 100644 --- a/clutter/cogl/gles/cogl-texture.c +++ b/clutter/cogl/gles/cogl-texture.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gles/cogl-util.c b/clutter/cogl/gles/cogl-util.c index b024e763e..4fc90b8e6 100644 --- a/clutter/cogl/gles/cogl-util.c +++ b/clutter/cogl/gles/cogl-util.c @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -44,7 +42,7 @@ cogl_util_next_p2 (int a) { int rval=1; - while(rval < a) + while(rval < a) rval <<= 1; return rval; diff --git a/clutter/cogl/gles/cogl-util.h b/clutter/cogl/gles/cogl-util.h index 759da8cc7..589ddd35a 100644 --- a/clutter/cogl/gles/cogl-util.h +++ b/clutter/cogl/gles/cogl-util.h @@ -1,11 +1,9 @@ /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2007 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,7 +24,7 @@ #ifndef __COGL_UTIL_H #define __COGL_UTIL_H -int +int cogl_util_next_p2 (int a); #endif /* __COGL_UTIL_H */ diff --git a/clutter/cogl/gles/cogl.c b/clutter/cogl/gles/cogl.c index 5b49a1901..0fcf4fc3b 100644 --- a/clutter/cogl/gles/cogl.c +++ b/clutter/cogl/gles/cogl.c @@ -1,9 +1,9 @@ /* * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Copyright (C) 2007,2008,2009 OpenedHand + * Copyright (C) 2007,2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/clutter/cogl/gles/stringify.sh b/clutter/cogl/gles/stringify.sh index bb8e7574d..a60d28d72 100644 --- a/clutter/cogl/gles/stringify.sh +++ b/clutter/cogl/gles/stringify.sh @@ -1,16 +1,36 @@ #! /bin/sh +# Cogl +# +# An object oriented GL/GLES Abstraction/Utility Layer +# +# Copyright (C) 2008,2009 Intel Corporation. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + + output_copyright () { cat < "$1"; /* - * Clutter COGL + * Cogl * - * A basic GL/GLES Abstraction/Utility Layer + * An object oriented GL/GLES Abstraction/Utility Layer * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand + * Copyright (C) 2008,2009 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public From ee57192f47e38a62828e0f2c1a1f966b7aa4fba3 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 29 Apr 2009 19:49:09 +0100 Subject: [PATCH 12/66] [cogl-material] make _cogl_material_layer_free check for an invalid texture handle It is valid in some situations to have a material layer with an invalid texture handle (e.g. if you setup a texture combine mode before setting the texture) and so _cogl_material_layer_free needs to check for a valid handle before attempting to unref it. --- clutter/cogl/common/cogl-material.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clutter/cogl/common/cogl-material.c b/clutter/cogl/common/cogl-material.c index 699ea0a10..2c7df33c8 100644 --- a/clutter/cogl/common/cogl-material.c +++ b/clutter/cogl/common/cogl-material.c @@ -644,7 +644,8 @@ cogl_material_set_layer_matrix (CoglHandle material_handle, static void _cogl_material_layer_free (CoglMaterialLayer *layer) { - cogl_handle_unref (layer->texture); + if (layer->texture != COGL_INVALID_HANDLE) + cogl_handle_unref (layer->texture); g_free (layer); } From d5fc61102fccf49a9156b2a2bdd2954207d87c38 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 30 Apr 2009 18:00:22 +0100 Subject: [PATCH 13/66] [cogl] Only expose CoglBitmap as a CoglHandle It was inconsistent that we exposed the CoglBitmap struct instead of an opaque CoglHandle. --- clutter/clutter-texture.c | 8 +- clutter/cogl/cogl-bitmap.h | 78 +++++++++++++++++++ clutter/cogl/cogl-texture.h | 45 +---------- clutter/cogl/cogl-types.h | 7 -- clutter/cogl/cogl.h.in | 1 + clutter/cogl/common/Makefile.am | 2 +- clutter/cogl/common/cogl-bitmap-fallback.c | 2 +- clutter/cogl/common/cogl-bitmap-pixbuf.c | 2 +- .../{cogl-bitmap.h => cogl-bitmap-private.h} | 7 +- clutter/cogl/common/cogl-bitmap.c | 25 +++--- clutter/cogl/gl/Makefile.am | 2 + clutter/cogl/gl/cogl-texture-private.h | 2 +- clutter/cogl/gl/cogl-texture.c | 13 +++- clutter/cogl/gles/Makefile.am | 2 + clutter/cogl/gles/cogl-texture-private.h | 2 +- clutter/cogl/gles/cogl-texture.c | 12 +-- doc/reference/cogl/cogl-sections.txt | 13 ++-- 17 files changed, 139 insertions(+), 84 deletions(-) create mode 100644 clutter/cogl/cogl-bitmap.h rename clutter/cogl/common/{cogl-bitmap.h => cogl-bitmap-private.h} (96%) diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index 6580e0b02..afa094453 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -127,7 +127,7 @@ struct _ClutterTextureAsyncData guint load_idle; gchar *load_filename; - CoglBitmap *load_bitmap; + CoglHandle load_bitmap; GError *load_error; }; @@ -674,7 +674,7 @@ clutter_texture_async_data_free (ClutterTextureAsyncData *data) g_free (data->load_filename); if (data->load_bitmap) - cogl_bitmap_free (data->load_bitmap); + cogl_handle_unref (data->load_bitmap); if (data->load_error) g_error_free (data->load_error); @@ -1651,7 +1651,7 @@ clutter_texture_set_from_yuv_data (ClutterTexture *texture, /* * clutter_texture_async_load_complete: * @self: a #ClutterTexture - * @bitmap: a #CoglBitmap + * @bitmap: a handle to a CoglBitmap * @error: load error * * If @error is %NULL, loads @bitmap into a #CoglTexture. @@ -1660,7 +1660,7 @@ clutter_texture_set_from_yuv_data (ClutterTexture *texture, */ static void clutter_texture_async_load_complete (ClutterTexture *self, - CoglBitmap *bitmap, + CoglHandle bitmap, const GError *error) { ClutterTexturePrivate *priv = self->priv; diff --git a/clutter/cogl/cogl-bitmap.h b/clutter/cogl/cogl-bitmap.h new file mode 100644 index 000000000..1bb3eb3db --- /dev/null +++ b/clutter/cogl/cogl-bitmap.h @@ -0,0 +1,78 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2007,2008,2009 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __COGL_BITMAP_H__ +#define __COGL_BITMAP_H__ + +G_BEGIN_DECLS + +#include + +/** + * SECTION:cogl-bitmap + * @short_description: Fuctions for loading images but not directly + * into textures + * + * Cogl allows loading image data into memory as CoglBitmaps without + * loading them immediately into GPU textures. + */ + + +/** + * cogl_bitmap_new_from_file: + * @filename: the file to load. + * @error: a #GError or %NULL. + * + * Load an image file from disk. This function can be safely called from + * within a thread. + * + * Returns: A CoglBitmap to the new loaded image data, or %NULL if loading + * the image failed. + * + * Since: 1.0 + */ +CoglHandle cogl_bitmap_new_from_file (const gchar *filename, + GError **error); + +/** + * cogl_bitmap_get_size_from_file: + * @filename: the file to check + * @width: return location for the bitmap width + * @height: return location for the bitmap height + * + * Parses an image file enough to extract the width and height + * of the bitmap. + * + * Since: 1.0 + */ +gboolean cogl_bitmap_get_size_from_file (const gchar *filename, + gint *width, + gint *height); + +G_END_DECLS + +#endif /* __COGL_BITMAP_H__ */ diff --git a/clutter/cogl/cogl-texture.h b/clutter/cogl/cogl-texture.h index f75abb3e5..ccf55eb0c 100644 --- a/clutter/cogl/cogl-texture.h +++ b/clutter/cogl/cogl-texture.h @@ -146,21 +146,21 @@ CoglHandle cogl_texture_new_from_foreign (GLuint gl_handle, /** * cogl_texture_new_from_bitmap: - * @bitmap: a #CoglBitmap + * @bmp_handle: A CoglBitmap handle * @max_waste: maximum extra horizontal and|or vertical margin pixels * to make the texture fit GPU limitations * @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE * @internal_format: the #CoglPixelFormat to use for the GPU storage of the * texture * - * Creates a COGL texture from a #CoglBitmap. + * Creates a COGL texture from a CoglBitmap. * * Return value: a #CoglHandle to the newly created texture or * %COGL_INVALID_HANDLE on failure * * Since: 1.0 */ -CoglHandle cogl_texture_new_from_bitmap (CoglBitmap *bitmap, +CoglHandle cogl_texture_new_from_bitmap (CoglHandle bmp_handle, gint max_waste, CoglTextureFlags flags, CoglPixelFormat internal_format); @@ -363,45 +363,6 @@ CoglHandle cogl_texture_ref (CoglHandle handle); */ void cogl_texture_unref (CoglHandle handle); -/** - * cogl_bitmap_new_from_file: - * @filename: the file to load. - * @error: a #GError or %NULL. - * - * Load an image file from disk. This function can be safely called from - * within a thread. - * - * Returns: A #CoglBitmap to the new loaded image data, or %NULL if loading - * the image failed. - * - * Since: 1.0 - */ -CoglBitmap * cogl_bitmap_new_from_file (const gchar *filename, - GError **error); - -/** - * cogl_bitmap_get_size_from_file: - * @filename: the file to check - * @width: return location for the bitmap width - * @height: return location for the bitmap height - * - * Parses an image file enough to extract the width and height - * of the bitmap. - * - * Since: 1.0 - */ -gboolean cogl_bitmap_get_size_from_file (const gchar *filename, - gint *width, - gint *height); - -/** - * cogl_bitmap_free: - * @bmp: a #CoglBitmap. - * - * Frees a #CoglBitmap. - */ -void cogl_bitmap_free (CoglBitmap *bmp); - /** * cogl_rectangle_with_texture_coords: * @x1: x coordinate upper left on screen. diff --git a/clutter/cogl/cogl-types.h b/clutter/cogl/cogl-types.h index d00da14c6..b2c082bc8 100644 --- a/clutter/cogl/cogl-types.h +++ b/clutter/cogl/cogl-types.h @@ -32,13 +32,6 @@ G_BEGIN_DECLS -/** - * CoglBitmap: - * - * Type used for storing image data. - */ -typedef struct _CoglBitmap CoglBitmap; - /** * CoglHandle: * diff --git a/clutter/cogl/cogl.h.in b/clutter/cogl/cogl.h.in index 3e7860a61..2422cd1da 100644 --- a/clutter/cogl/cogl.h.in +++ b/clutter/cogl/cogl.h.in @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/clutter/cogl/common/Makefile.am b/clutter/cogl/common/Makefile.am index c2c8310dc..a4f0bfbb7 100644 --- a/clutter/cogl/common/Makefile.am +++ b/clutter/cogl/common/Makefile.am @@ -22,7 +22,7 @@ libclutter_cogl_common_la_SOURCES = \ cogl.c \ cogl-util.h \ cogl-util.c \ - cogl-bitmap.h \ + cogl-bitmap-private.h \ cogl-bitmap.c \ cogl-bitmap-fallback.c \ cogl-current-matrix.c \ diff --git a/clutter/cogl/common/cogl-bitmap-fallback.c b/clutter/cogl/common/cogl-bitmap-fallback.c index b9ba9b737..e118459e1 100644 --- a/clutter/cogl/common/cogl-bitmap-fallback.c +++ b/clutter/cogl/common/cogl-bitmap-fallback.c @@ -27,7 +27,7 @@ #include "cogl.h" #include "cogl-internal.h" -#include "cogl-bitmap.h" +#include "cogl-bitmap-private.h" #include diff --git a/clutter/cogl/common/cogl-bitmap-pixbuf.c b/clutter/cogl/common/cogl-bitmap-pixbuf.c index 4108e321a..f1e500534 100644 --- a/clutter/cogl/common/cogl-bitmap-pixbuf.c +++ b/clutter/cogl/common/cogl-bitmap-pixbuf.c @@ -27,7 +27,7 @@ #include "cogl.h" #include "cogl-internal.h" -#include "cogl-bitmap.h" +#include "cogl-bitmap-private.h" #include diff --git a/clutter/cogl/common/cogl-bitmap.h b/clutter/cogl/common/cogl-bitmap-private.h similarity index 96% rename from clutter/cogl/common/cogl-bitmap.h rename to clutter/cogl/common/cogl-bitmap-private.h index 953ac5a32..f54961bd0 100644 --- a/clutter/cogl/common/cogl-bitmap.h +++ b/clutter/cogl/common/cogl-bitmap-private.h @@ -28,14 +28,17 @@ #include -struct _CoglBitmap +#include "cogl-handle.h" + +typedef struct _CoglBitmap { + CoglHandleObject _parent; guchar *data; CoglPixelFormat format; gint width; gint height; gint rowstride; -}; +} CoglBitmap; gboolean _cogl_bitmap_can_convert (CoglPixelFormat src, CoglPixelFormat dst); diff --git a/clutter/cogl/common/cogl-bitmap.c b/clutter/cogl/common/cogl-bitmap.c index af3bc53b6..f4c322abb 100644 --- a/clutter/cogl/common/cogl-bitmap.c +++ b/clutter/cogl/common/cogl-bitmap.c @@ -27,10 +27,21 @@ #include "cogl.h" #include "cogl-internal.h" -#include "cogl-bitmap.h" +#include "cogl-bitmap-private.h" #include +static void _cogl_bitmap_free (CoglBitmap *bmp); + +COGL_HANDLE_DEFINE (Bitmap, bitmap); + +static void +_cogl_bitmap_free (CoglBitmap *bmp) +{ + g_free (bmp->data); + g_free (bmp); +} + gint _cogl_get_format_bpp (CoglPixelFormat format) { @@ -155,11 +166,12 @@ cogl_bitmap_get_size_from_file (const gchar *filename, return _cogl_bitmap_get_size_from_file (filename, width, height); } -CoglBitmap * +CoglHandle cogl_bitmap_new_from_file (const gchar *filename, GError **error) { CoglBitmap bmp; + CoglBitmap *ret; g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE); @@ -176,12 +188,7 @@ cogl_bitmap_new_from_file (const gchar *filename, } } - return (CoglBitmap *) g_memdup (&bmp, sizeof (CoglBitmap)); + ret = g_memdup (&bmp, sizeof (CoglBitmap)); + return _cogl_bitmap_handle_new (ret); } -void -cogl_bitmap_free (CoglBitmap *bmp) -{ - g_free (bmp->data); - g_free (bmp); -} diff --git a/clutter/cogl/gl/Makefile.am b/clutter/cogl/gl/Makefile.am index 12e2ee92a..b143e8e9b 100644 --- a/clutter/cogl/gl/Makefile.am +++ b/clutter/cogl/gl/Makefile.am @@ -8,6 +8,7 @@ libclutterinclude_HEADERS = \ $(top_builddir)/clutter/cogl/cogl-offscreen.h \ $(top_builddir)/clutter/cogl/cogl-path.h \ $(top_builddir)/clutter/cogl/cogl-shader.h \ + $(top_builddir)/clutter/cogl/cogl-bitmap.h \ $(top_builddir)/clutter/cogl/cogl-texture.h \ $(top_builddir)/clutter/cogl/cogl-types.h \ $(top_builddir)/clutter/cogl/cogl-vertex-buffer.h \ @@ -43,6 +44,7 @@ libclutter_cogl_la_SOURCES = \ $(top_builddir)/clutter/cogl/cogl-offscreen.h \ $(top_builddir)/clutter/cogl/cogl-path.h \ $(top_builddir)/clutter/cogl/cogl-shader.h \ + $(top_builddir)/clutter/cogl/cogl-bitmap.h \ $(top_builddir)/clutter/cogl/cogl-texture.h \ $(top_builddir)/clutter/cogl/cogl-types.h \ $(top_builddir)/clutter/cogl/cogl-debug.h \ diff --git a/clutter/cogl/gl/cogl-texture-private.h b/clutter/cogl/gl/cogl-texture-private.h index 2905175bb..cd60528e4 100644 --- a/clutter/cogl/gl/cogl-texture-private.h +++ b/clutter/cogl/gl/cogl-texture-private.h @@ -24,7 +24,7 @@ #ifndef __COGL_TEXTURE_H #define __COGL_TEXTURE_H -#include "cogl-bitmap.h" +#include "cogl-bitmap-private.h" #include "cogl-handle.h" typedef struct _CoglTexture CoglTexture; diff --git a/clutter/cogl/gl/cogl-texture.c b/clutter/cogl/gl/cogl-texture.c index 59132c2d4..8fb4980f5 100644 --- a/clutter/cogl/gl/cogl-texture.c +++ b/clutter/cogl/gl/cogl-texture.c @@ -34,6 +34,7 @@ #include "cogl-internal.h" #include "cogl-util.h" #include "cogl-bitmap.h" +#include "cogl-bitmap-private.h" #include "cogl-texture-private.h" #include "cogl-material.h" #include "cogl-context.h" @@ -1339,12 +1340,15 @@ cogl_texture_new_from_data (guint width, } CoglHandle -cogl_texture_new_from_bitmap (CoglBitmap *bmp, +cogl_texture_new_from_bitmap (CoglHandle bmp_handle, gint max_waste, CoglTextureFlags flags, CoglPixelFormat internal_format) { CoglTexture *tex; + CoglBitmap *bmp = (CoglBitmap *)bmp_handle; + + g_return_val_if_fail (bmp_handle != COGL_INVALID_HANDLE, COGL_INVALID_HANDLE); /* Create new texture and fill with loaded data */ tex = (CoglTexture*) g_malloc ( sizeof (CoglTexture)); @@ -1402,19 +1406,20 @@ cogl_texture_new_from_file (const gchar *filename, CoglPixelFormat internal_format, GError **error) { - CoglBitmap *bmp; + CoglHandle bmp; CoglHandle handle; g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE); - if (!(bmp = cogl_bitmap_new_from_file (filename, error))) + bmp = cogl_bitmap_new_from_file (filename, error); + if (bmp == COGL_INVALID_HANDLE) return COGL_INVALID_HANDLE; handle = cogl_texture_new_from_bitmap (bmp, max_waste, flags, internal_format); - cogl_bitmap_free (bmp); + cogl_handle_unref (bmp); return handle; } diff --git a/clutter/cogl/gles/Makefile.am b/clutter/cogl/gles/Makefile.am index 1ec4ae789..409f655b8 100644 --- a/clutter/cogl/gles/Makefile.am +++ b/clutter/cogl/gles/Makefile.am @@ -8,6 +8,7 @@ libclutterinclude_HEADERS = \ $(top_builddir)/clutter/cogl/cogl-offscreen.h \ $(top_builddir)/clutter/cogl/cogl-path.h \ $(top_builddir)/clutter/cogl/cogl-shader.h \ + $(top_builddir)/clutter/cogl/cogl-bitmap.h \ $(top_builddir)/clutter/cogl/cogl-texture.h \ $(top_builddir)/clutter/cogl/cogl-types.h \ $(top_builddir)/clutter/cogl/cogl-vertex-buffer.h \ @@ -43,6 +44,7 @@ libclutter_cogl_la_SOURCES = \ $(top_builddir)/clutter/cogl/cogl-offscreen.h \ $(top_builddir)/clutter/cogl/cogl-path.h \ $(top_builddir)/clutter/cogl/cogl-shader.h \ + $(top_builddir)/clutter/cogl/cogl-bitmap.h \ $(top_builddir)/clutter/cogl/cogl-texture.h \ $(top_builddir)/clutter/cogl/cogl-types.h \ $(top_builddir)/clutter/cogl/cogl-debug.h \ diff --git a/clutter/cogl/gles/cogl-texture-private.h b/clutter/cogl/gles/cogl-texture-private.h index 2905175bb..cd60528e4 100644 --- a/clutter/cogl/gles/cogl-texture-private.h +++ b/clutter/cogl/gles/cogl-texture-private.h @@ -24,7 +24,7 @@ #ifndef __COGL_TEXTURE_H #define __COGL_TEXTURE_H -#include "cogl-bitmap.h" +#include "cogl-bitmap-private.h" #include "cogl-handle.h" typedef struct _CoglTexture CoglTexture; diff --git a/clutter/cogl/gles/cogl-texture.c b/clutter/cogl/gles/cogl-texture.c index 66af941c2..959332919 100644 --- a/clutter/cogl/gles/cogl-texture.c +++ b/clutter/cogl/gles/cogl-texture.c @@ -28,7 +28,7 @@ #include "cogl.h" #include "cogl-internal.h" #include "cogl-util.h" -#include "cogl-bitmap.h" +#include "cogl-bitmap-private.h" #include "cogl-texture-private.h" #include "cogl-material.h" #include "cogl-context.h" @@ -1433,12 +1433,13 @@ cogl_texture_new_from_data (guint width, } CoglHandle -cogl_texture_new_from_bitmap (CoglBitmap *bmp, +cogl_texture_new_from_bitmap (CoglHandle bmp_handle, gint max_waste, CoglTextureFlags flags, CoglPixelFormat internal_format) { CoglTexture *tex; + CoglBitmap *bmp = (CoglBitmap *)bmp_handle; /* Create new texture and fill with loaded data */ tex = (CoglTexture*) g_malloc ( sizeof (CoglTexture)); @@ -1496,19 +1497,20 @@ cogl_texture_new_from_file (const gchar *filename, CoglPixelFormat internal_format, GError **error) { - CoglBitmap *bmp; + CoglHandle bmp; CoglHandle handle; g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE); - if (!(bmp = cogl_bitmap_new_from_file (filename, error))) + bmp = cogl_bitmap_new_from_file (filename, error); + if (bmp == COGL_INVALID_HANDLE) return COGL_INVALID_HANDLE; handle = cogl_texture_new_from_bitmap (bmp, max_waste, flags, internal_format); - cogl_bitmap_free (bmp); + cogl_handle_unref (bmp); return handle; } diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt index f99461c43..bc9d6afc1 100644 --- a/doc/reference/cogl/cogl-sections.txt +++ b/doc/reference/cogl/cogl-sections.txt @@ -103,6 +103,13 @@ cogl_path_stroke_preserve cogl_color +
+cogl-bitmap +Bitmaps +cogl_bitmap_new_from_file +cogl_bitmap_get_size_from_file +
+
cogl-texture Textures @@ -130,12 +137,6 @@ cogl_texture_get_gl_texture cogl_texture_get_data cogl_texture_set_filters cogl_texture_set_region - - -CoglBitmap -cogl_bitmap_new_from_file -cogl_bitmap_free -cogl_bitmap_get_size_from_file
From e47b19822510344e4cae854e99a5ef0a76304980 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Thu, 19 Feb 2009 22:37:08 -0500 Subject: [PATCH 14/66] add cogl_push_draw_buffer() and cogl_pop_draw_buffer() These are necessary if nesting redirections to an fbo, otherwise there's no way to know how to restore previous state. glPushAttrib(GL_COLOR_BUFFER_BIT) would save draw buffer state, but also saves a lot of other stuff, and cogl_draw_buffer() relies on knowing about all draw buffer state changes. So we have to implement a draw buffer stack ourselves. Signed-off-by: Robert Bragg --- clutter/cogl/cogl-offscreen.h | 14 ++++++ clutter/cogl/gl/cogl-context.c | 7 ++- clutter/cogl/gl/cogl-context.h | 8 +++- clutter/cogl/gl/cogl-fbo.c | 75 ++++++++++++++++++++++++++++++-- clutter/cogl/gles/cogl-context.c | 7 ++- clutter/cogl/gles/cogl-context.h | 8 +++- clutter/cogl/gles/cogl-fbo.c | 75 ++++++++++++++++++++++++++++++-- 7 files changed, 184 insertions(+), 10 deletions(-) diff --git a/clutter/cogl/cogl-offscreen.h b/clutter/cogl/cogl-offscreen.h index 17d2e54d6..6be6cf0f2 100644 --- a/clutter/cogl/cogl-offscreen.h +++ b/clutter/cogl/cogl-offscreen.h @@ -128,6 +128,20 @@ void cogl_offscreen_blit_region (CoglHandle src_buffer, void cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen); +/** + * cogl_push_draw_buffer: + * + * Save cogl_draw_buffer() state. + */ +void cogl_push_draw_buffer (void); + +/** + * cogl_pop_draw_buffer: + * + * Restore cogl_draw_buffer() state. + */ +void cogl_pop_draw_buffer (void); + G_END_DECLS #endif /* __COGL_OFFSCREEN_H__ */ diff --git a/clutter/cogl/gl/cogl-context.c b/clutter/cogl/gl/cogl-context.c index 7f757f45e..986da8aa8 100644 --- a/clutter/cogl/gl/cogl-context.c +++ b/clutter/cogl/gl/cogl-context.c @@ -42,6 +42,7 @@ cogl_create_context () { GLubyte default_texture_data[] = { 0xff, 0xff, 0xff, 0x0 }; gulong enable_flags = 0; + CoglDrawBufferState *draw_buffer; if (_context != NULL) return FALSE; @@ -78,7 +79,11 @@ cogl_create_context () sizeof (CoglLayerInfo)); _context->n_texcoord_arrays_enabled = 0; - _context->draw_buffer = COGL_WINDOW_BUFFER; + draw_buffer = g_slice_new0 (CoglDrawBufferState); + draw_buffer->target = COGL_WINDOW_BUFFER; + draw_buffer->offscreen = COGL_INVALID_HANDLE; + _context->draw_buffer_stack = + g_slist_prepend (NULL, draw_buffer); _context->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode)); _context->last_path = 0; diff --git a/clutter/cogl/gl/cogl-context.h b/clutter/cogl/gl/cogl-context.h index 602240793..2660ed812 100644 --- a/clutter/cogl/gl/cogl-context.h +++ b/clutter/cogl/gl/cogl-context.h @@ -36,6 +36,12 @@ typedef struct GLubyte c[4]; } CoglTextureGLVertex; +typedef struct +{ + CoglBufferTarget target; + CoglHandle offscreen; +} CoglDrawBufferState; + typedef struct { /* Features cache */ @@ -82,7 +88,7 @@ typedef struct guint n_texcoord_arrays_enabled; /* Framebuffer objects */ - CoglBufferTarget draw_buffer; + GSList *draw_buffer_stack; /* Clip stack */ CoglClipStackState clip; diff --git a/clutter/cogl/gl/cogl-fbo.c b/clutter/cogl/gl/cogl-fbo.c index ce703d9a6..a5f6e22fd 100644 --- a/clutter/cogl/gl/cogl-fbo.c +++ b/clutter/cogl/gl/cogl-fbo.c @@ -242,9 +242,13 @@ void cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) { CoglFbo *fbo = NULL; + CoglDrawBufferState *draw_buffer; _COGL_GET_CONTEXT (ctx, NO_RETVAL); + g_assert (ctx->draw_buffer_stack != NULL); + draw_buffer = ctx->draw_buffer_stack->data; + if (target == COGL_OFFSCREEN_BUFFER) { /* Make sure it is a valid fbo handle */ @@ -254,7 +258,7 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) fbo = _cogl_offscreen_pointer_from_handle (offscreen); /* Check current draw buffer target */ - if (ctx->draw_buffer != COGL_OFFSCREEN_BUFFER) + if (draw_buffer->target != COGL_OFFSCREEN_BUFFER) { /* Push the viewport and matrix setup if redirecting from a non-screen buffer */ @@ -303,7 +307,7 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) (target & COGL_MASK_BUFFER)) { /* Check current draw buffer target */ - if (ctx->draw_buffer == COGL_OFFSCREEN_BUFFER) + if (draw_buffer->target == COGL_OFFSCREEN_BUFFER) { /* Pop viewport and matrices if redirecting back from an offscreen buffer */ @@ -338,5 +342,70 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) } /* Store new target */ - ctx->draw_buffer = target; + draw_buffer->target = target; + if (draw_buffer->offscreen != offscreen) + { + if (draw_buffer->offscreen != COGL_INVALID_HANDLE) + cogl_handle_unref (draw_buffer->offscreen); + if (offscreen != COGL_INVALID_HANDLE) + cogl_handle_ref (offscreen); + draw_buffer->offscreen = offscreen; + } +} + +void +cogl_push_draw_buffer(void) +{ + CoglDrawBufferState *old; + CoglDrawBufferState *draw_buffer; + + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + + g_assert (ctx->draw_buffer_stack != NULL); + old = ctx->draw_buffer_stack->data; + + draw_buffer = g_slice_new0 (CoglDrawBufferState); + *draw_buffer = *old; + + ctx->draw_buffer_stack = + g_slist_prepend (ctx->draw_buffer_stack, draw_buffer); +} + +void +cogl_pop_draw_buffer(void) +{ + CoglDrawBufferState *to_pop; + CoglDrawBufferState *to_restore; + + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + + g_assert (ctx->draw_buffer_stack != NULL); + if (ctx->draw_buffer_stack->next == NULL) + { + g_warning ("1 more cogl_pop_draw_buffer() than cogl_push_draw_buffer()"); + return; + } + + to_pop = ctx->draw_buffer_stack->data; + to_restore = ctx->draw_buffer_stack->next->data; + + /* the logic in cogl_draw_buffer() only works if + * to_pop is still on top of the stack, because + * cogl_draw_buffer() needs to know the previous + * state. + */ + cogl_draw_buffer (to_restore->target, to_restore->offscreen); + + /* cogl_draw_buffer() should have set top of stack + * to to_restore + */ + g_assert (to_restore->target == to_pop->target); + g_assert (to_restore->offscreen == to_pop->offscreen); + + g_assert (ctx->draw_buffer_stack->data == to_pop); + ctx->draw_buffer_stack = + g_slist_remove_link (ctx->draw_buffer_stack, + ctx->draw_buffer_stack); + + g_slice_free (CoglDrawBufferState, to_pop); } diff --git a/clutter/cogl/gles/cogl-context.c b/clutter/cogl/gles/cogl-context.c index c5bc2e3c6..d70d59d35 100644 --- a/clutter/cogl/gles/cogl-context.c +++ b/clutter/cogl/gles/cogl-context.c @@ -44,6 +44,7 @@ cogl_create_context () { GLubyte default_texture_data[] = { 0xff, 0xff, 0xff, 0x0 }; gulong enable_flags = 0; + CoglDrawBufferState *draw_buffer; if (_context != NULL) return FALSE; @@ -81,7 +82,11 @@ cogl_create_context () sizeof (CoglLayerInfo)); _context->n_texcoord_arrays_enabled = 0; - _context->draw_buffer = COGL_WINDOW_BUFFER; + draw_buffer = g_slice_new0 (CoglDrawBufferState); + draw_buffer->target = COGL_WINDOW_BUFFER; + draw_buffer->offscreen = COGL_INVALID_HANDLE; + _context->draw_buffer_stack = + g_slist_prepend (NULL, draw_buffer); _context->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode)); _context->last_path = 0; diff --git a/clutter/cogl/gles/cogl-context.h b/clutter/cogl/gles/cogl-context.h index 994b100ff..3542e038d 100644 --- a/clutter/cogl/gles/cogl-context.h +++ b/clutter/cogl/gles/cogl-context.h @@ -38,6 +38,12 @@ typedef struct GLubyte c[4]; } CoglTextureGLVertex; +typedef struct +{ + CoglBufferTarget target; + CoglHandle offscreen; +} CoglDrawBufferState; + typedef struct { /* Features cache */ @@ -84,7 +90,7 @@ typedef struct guint n_texcoord_arrays_enabled; /* Framebuffer objects */ - CoglBufferTarget draw_buffer; + GSList *draw_buffer_stack; /* Clip stack */ CoglClipStackState clip; diff --git a/clutter/cogl/gles/cogl-fbo.c b/clutter/cogl/gles/cogl-fbo.c index 6f2aef569..2b8aa46fa 100644 --- a/clutter/cogl/gles/cogl-fbo.c +++ b/clutter/cogl/gles/cogl-fbo.c @@ -180,9 +180,13 @@ void cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) { CoglFbo *fbo = NULL; + CoglDrawBufferState *draw_buffer; _COGL_GET_CONTEXT (ctx, NO_RETVAL); + g_assert (ctx->draw_buffer_stack != NULL); + draw_buffer = ctx->draw_buffer_stack->data; + if (target == COGL_OFFSCREEN_BUFFER) { GLboolean scissor_enabled; @@ -195,7 +199,7 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) fbo = _cogl_offscreen_pointer_from_handle (offscreen); /* Check current draw buffer target */ - if (ctx->draw_buffer != COGL_OFFSCREEN_BUFFER) + if (draw_buffer->target != COGL_OFFSCREEN_BUFFER) { /* Push the viewport and matrix setup if redirecting from a non-screen buffer */ @@ -249,7 +253,7 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) (target & COGL_MASK_BUFFER)) { /* Check current draw buffer target */ - if (ctx->draw_buffer == COGL_OFFSCREEN_BUFFER) + if (draw_buffer->target == COGL_OFFSCREEN_BUFFER) { /* Pop viewport and matrices if redirecting back from an offscreen buffer */ @@ -285,7 +289,72 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) } /* Store new target */ - ctx->draw_buffer = target; + draw_buffer->target = target; + if (draw_buffer->offscreen != offscreen) + { + if (draw_buffer->offscreen != COGL_INVALID_HANDLE) + cogl_handle_unref (draw_buffer->offscreen); + if (offscreen != COGL_INVALID_HANDLE) + cogl_handle_ref (offscreen); + draw_buffer->offscreen = offscreen; + } +} + +void +cogl_push_draw_buffer(void) +{ + CoglDrawBufferState *old; + CoglDrawBufferState *draw_buffer; + + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + + g_assert (ctx->draw_buffer_stack != NULL); + old = ctx->draw_buffer_stack->data; + + draw_buffer = g_slice_new0 (CoglDrawBufferState); + *draw_buffer = *old; + + ctx->draw_buffer_stack = + g_slist_prepend (ctx->draw_buffer_stack, draw_buffer); +} + +void +cogl_pop_draw_buffer(void) +{ + CoglDrawBufferState *to_pop; + CoglDrawBufferState *to_restore; + + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + + g_assert (ctx->draw_buffer_stack != NULL); + if (ctx->draw_buffer_stack->next == NULL) + { + g_warning ("1 more cogl_pop_draw_buffer() than cogl_push_draw_buffer()"); + return; + } + + to_pop = ctx->draw_buffer_stack->data; + to_restore = ctx->draw_buffer_stack->next->data; + + /* the logic in cogl_draw_buffer() only works if + * to_pop is still on top of the stack, because + * cogl_draw_buffer() needs to know the previous + * state. + */ + cogl_draw_buffer (to_restore->target, to_restore->offscreen); + + /* cogl_draw_buffer() should have set top of stack + * to to_restore + */ + g_assert (to_restore->target == to_pop->target); + g_assert (to_restore->offscreen == to_pop->offscreen); + + g_assert (ctx->draw_buffer_stack->data == to_pop); + ctx->draw_buffer_stack = + g_slist_remove_link (ctx->draw_buffer_stack, + ctx->draw_buffer_stack); + + g_slice_free (CoglDrawBufferState, to_pop); } #else /* HAVE_COGL_GLES2 */ From a5cdfdfd87b2fa559460ac117f4ed27474a6f47f Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 30 Apr 2009 22:19:43 +0100 Subject: [PATCH 15/66] [cogl-offscreen] Cleans up the cogl offscreen API and adds documentation There were several functions I believe no one is currently using that were only implemented in the GL backend (cogl_offscreen_blit_region and cogl_offscreen_blit) that have simply been removed so we have a chance to think about design later with a real use case. There was one nonsense function (cogl_offscreen_new_multisample) that sounded exciting but in all cases it just returned COGL_INVALID_HANDLE (though at least for GL it checked for multisampling support first!?) it has also been removed. The MASK draw buffer type has been removed. If we want to expose color masking later then I think it at least would be nicer to have the mask be a property that can be set on any draw buffer. The cogl_draw_buffer and cogl_{push,pop}_draw_buffer function prototypes have been moved up into cogl.h since they are for managing global Cogl state and not for modifying or creating the actual offscreen buffers. This also documents the API so for example desiphering the semantics of cogl_offscreen_new_to_texture() should be a bit easier now. --- README | 54 +++++++----- clutter/clutter-texture.c | 4 +- clutter/cogl/cogl-offscreen.h | 99 ++++++--------------- clutter/cogl/cogl-types.h | 4 +- clutter/cogl/cogl.h.in | 29 +++++++ clutter/cogl/common/cogl-util.c | 1 - clutter/cogl/gl/cogl-fbo.c | 109 ++---------------------- clutter/cogl/gles/cogl-fbo.c | 91 ++------------------ clutter/cogl/gles/cogl-texture.c | 5 -- doc/reference/cogl/cogl-sections.txt | 4 +- tests/interactive/test-cogl-offscreen.c | 4 +- 11 files changed, 105 insertions(+), 299 deletions(-) diff --git a/README b/README index 2bc9afb8d..2bf2a039a 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ Clutter 1.0 README ================== Clutter is an open source software library for creating fast, visually -rich and animated graphical user interfaces. +rich and animated graphical user interfaces. Clutter currently requires: @@ -11,15 +11,15 @@ Clutter currently requires: * OpenGL >= 1.4, OpenGL ES 1.1 or OpenGL ES 2.0 * GLX, SDL, WGL or an EGL Implementation -The official website is: +The official website is: http://www.clutter-project.org The Clutter blog is at http://www.clutter-project.org/blog -To subscribe to the Clutter mailing list, send mail to: - clutter+subscribe@o-hand.com -The official mailing list archive is: +To subscribe to the Clutter mailing list, send mail to: + clutter+subscribe@o-hand.com +The official mailing list archive is: http://lists.o-hand.com/clutter/ -New bug page on Bugzilla: +New bug page on Bugzilla: http://bugzilla.o-hand.com/enter_bug.cgi?product=Clutter Clutter is licensed under the terms of the GNU Lesser General Public @@ -32,7 +32,7 @@ See the INSTALL file. Info on specific Clutter options; --enable-debug=[no/minimum/yes] Turn on debugging (default=yes): - yes: All glib asserts, checks and runtime clutter verbose messages. + yes: All glib asserts, checks and runtime clutter verbose messages. minimum: Just glib cast checks and runtime clutter verbose messagaes. no: No glib asserts or checks and no runtime clutter verbose messages (Only really of use in extreme performance cases) @@ -40,15 +40,15 @@ See the INSTALL file. Info on specific Clutter options; --enable-maintainer-flags=[no/yes] Use strict compiler flags (default=no) - --enable-gtk-doc - use gtk-doc to build API documentation (default=no). Requires gtk-doc + --enable-gtk-doc + use gtk-doc to build API documentation (default=no). Requires gtk-doc present on system --enable-manual=[no/yes] Build application developers manual. Requires jw and xmlto binaries. Presently incomplete. - --without-fpu + --without-fpu Assume target hardware has no floating point unit. Useful only for embedded targets such as ARM. @@ -307,6 +307,16 @@ Release Notes for Clutter 1.0 * cogl_get_*_matrix were changed to use the CoglMatrix type instead of GLfloat m[16] arrays. +* cogl_offscreen_blit_region, cogl_offscreen_blit were removed since they were + only implemnted for GL, not GLES, and it was assumed no one was using them. + +* cogl_offscreen_new_multisample was removed since it only ever returned + COGL_INVALID_HANDLE so it wasn't usefull. + +* The COGL_MASK_BUFFER type was removed, since there should be nicer ways of + exposing color mask if anyone wants it later. It was assumed that no one was + using this currently. + Release Notes for Clutter 0.8 ------------------------------- @@ -318,7 +328,7 @@ Release Notes for Clutter 0.8 support. It is now also fully documented. * GL Texture Rectangle ext is no longer used, the regular 2D NPOTS - extension is preffered instead but not required. + extension is preffered instead but not required. * Clutter now has basic suppport for multiple input devices assuming the backend supports it (currently X11 based via XInput and Fruity @@ -327,7 +337,7 @@ Release Notes for Clutter 0.8 clutter_grab_pointer_for_device & clutter_ungrab_pointer_for_device. XInput support needs to be explicitly enabled at runtime by calling - clutter_x11_enable_xinput () before clutter_init. clutter_x11_has_xinput () + clutter_x11_enable_xinput () before clutter_init. clutter_x11_has_xinput () can then be called after to check if XInput extension present and use-able. * The functions that return the transformed position of an actor have @@ -423,16 +433,16 @@ Release Notes for Clutter 0.8 * Clutter now features support for multiple stages assuming supported by the backend. See test-multistage.c for example of usage. This does not change the automatic creation of the default stage. - A single GL context is used across all stages meaning GL resources - are shared. + A single GL context is used across all stages meaning GL resources + are shared. * There is now an experimental native iPod Touch/iPhone UIKit backend named 'fruity'. * There is now an experimental native Win32 WGL backend. -* COGL (and therefor Clutter) now optionally features initial support for - OpenGL ES 2.0. It features support for shaders. +* COGL (and therefor Clutter) now optionally features initial support for + OpenGL ES 2.0. It features support for shaders. * Some more focused timeline unit tests have been added and some tweaks to timeline semantics were made; E.g. For a 10 frame timeline here are some @@ -469,7 +479,7 @@ Release Notes for Clutter 0.8 X Drawables (such as windows as pixmaps) via the 'texture_from_pixmap' GLX extension if available and fallback to slower XGetImage copies if not. -* ClutterContainer can have per child custom properties via ClutterChildMeta. +* ClutterContainer can have per child custom properties via ClutterChildMeta. Release Notes for Clutter 0.6 ------------------------------- @@ -582,11 +592,11 @@ Release Notes for Clutter 0.4.0 Release Notes for Clutter 0.3.1 ------------------------------- -* clutter_actor_apply_transform_to_point() parameters changed to use +* clutter_actor_apply_transform_to_point() parameters changed to use ClutterVertices. -* New 'Native API' backend expects EGL implementation to provide a - CreateNativeWindow() API call. +* New 'Native API' backend expects EGL implementation to provide a + CreateNativeWindow() API call. * Exisiting X11 based egl backend public API calls now prefixed eglx. @@ -600,7 +610,7 @@ Release Notes for Clutter 0.3 clutter_texture_set_from_yuv_data(). * The GLX specific API has been moved to the GLX backend code and - it's now under the ClutterGlx namespace. + it's now under the ClutterGlx namespace. * The priority of the various users of the GLib main loop has been reviewed and changed were necessary. Every paint is queued with a @@ -635,7 +645,7 @@ Release Notes for Clutter 0.3 * clutter_color_parse() now handles color definitions with alpha. Alpha will default to fully Opaque rather than fully transparent if not specified. -* The Clutter examples/ directory has been removed and replaced with a +* The Clutter examples/ directory has been removed and replaced with a tests/ directory. * The ClutterEvent API has been changed, and specific functions have been diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index afa094453..8c0dab500 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -563,7 +563,7 @@ clutter_texture_paint (ClutterActor *self) clutter_shader_set_is_enabled (shader, FALSE); /* Redirect drawing to the fbo */ - cogl_draw_buffer (COGL_OFFSCREEN_BUFFER, priv->fbo_handle); + cogl_set_draw_buffer (COGL_OFFSCREEN_BUFFER, priv->fbo_handle); if ((stage = clutter_actor_get_stage (self))) { @@ -609,7 +609,7 @@ clutter_texture_paint (ClutterActor *self) cogl_clip_stack_restore (); /* Restore drawing to the frame buffer */ - cogl_draw_buffer (COGL_WINDOW_BUFFER, COGL_INVALID_HANDLE); + cogl_set_draw_buffer (COGL_WINDOW_BUFFER, COGL_INVALID_HANDLE); /* Restore the perspective matrix using cogl_perspective so that the inverse matrix will be right */ diff --git a/clutter/cogl/cogl-offscreen.h b/clutter/cogl/cogl-offscreen.h index 6be6cf0f2..ca4edb49c 100644 --- a/clutter/cogl/cogl-offscreen.h +++ b/clutter/cogl/cogl-offscreen.h @@ -35,43 +35,47 @@ G_BEGIN_DECLS /** * SECTION:cogl-offscreen * @short_description: Fuctions for creating and manipulating offscreen - * frame buffer objects + * frame buffer objects * - * COGL allows creating and operating on FBOs (Framebuffer Objects). + * Cogl allows creating and operating on offscreen render targets. */ /* Offscreen api */ /** * cogl_offscreen_new_to_texture: - * @texhandle: + * @handle: A CoglHandle for a Cogl texture * - * Returns: + * This creates an offscreen buffer object using the given texture as the + * primary color buffer. It doesn't just initialize the contents of the + * offscreen buffer with the texture; they are tightly bound so that + * drawing to the offscreen buffer effectivly updates the contents of the + * given texture. You don't need to destroy the offscreen buffer before + * you can use the texture again. + * + * Note: This does not work with sliced Cogl textures. + * + * Returns: a CoglHandle for the new offscreen buffer or COGL_INVALID_HANDLE + * if it wasn't possible to create the buffer. */ CoglHandle cogl_offscreen_new_to_texture (CoglHandle texhandle); -/** - * cogl_offscreen_new_multisample: - * - * - * Returns: - */ -CoglHandle cogl_offscreen_new_multisample (void); - /** * cogl_offscreen_ref: - * @handle: + * @handle: A CoglHandle for an offscreen buffer * - * Returns: + * Increments the reference count on the offscreen buffer. + * + * Returns: For convenience it returns the given CoglHandle */ CoglHandle cogl_offscreen_ref (CoglHandle handle); /** * cogl_is_offscreen: - * @handle: A CoglHandle + * @handle: A CoglHandle for an offscreen buffer * - * Gets whether the given handle references an existing offscreen - * buffer object. + * Gets whether the given handle references an existing offscreen buffer + * object. * * Returns: %TRUE if the handle references an offscreen buffer, * %FALSE otherwise @@ -80,68 +84,13 @@ gboolean cogl_is_offscreen (CoglHandle handle); /** * cogl_offscreen_unref: - * @handle: + * @handle: A CoglHandle for an offscreen buffer * + * Decreases the reference count for the offscreen buffer and frees it when + * the count reaches 0. */ void cogl_offscreen_unref (CoglHandle handle); -/** - * cogl_offscreen_blit: - * @src_buffer: - * @dst_buffer: - * - */ -void cogl_offscreen_blit (CoglHandle src_buffer, - CoglHandle dst_buffer); - -/** - * cogl_offscreen_blit_region: - * @src_buffer: - * @dst_buffer: - * @src_x: - * @src_y: - * @src_w: - * @src_h: - * @dst_x: - * @dst_y: - * @dst_w: - * @dst_h: - * - */ -void cogl_offscreen_blit_region (CoglHandle src_buffer, - CoglHandle dst_buffer, - gint src_x, - gint src_y, - gint src_w, - gint src_h, - gint dst_x, - gint dst_y, - gint dst_w, - gint dst_h); - -/** - * cogl_draw_buffer: - * @target: - * @offscreen: - * - */ -void cogl_draw_buffer (CoglBufferTarget target, - CoglHandle offscreen); - -/** - * cogl_push_draw_buffer: - * - * Save cogl_draw_buffer() state. - */ -void cogl_push_draw_buffer (void); - -/** - * cogl_pop_draw_buffer: - * - * Restore cogl_draw_buffer() state. - */ -void cogl_pop_draw_buffer (void); - G_END_DECLS #endif /* __COGL_OFFSCREEN_H__ */ diff --git a/clutter/cogl/cogl-types.h b/clutter/cogl/cogl-types.h index b2c082bc8..a4ecd4193 100644 --- a/clutter/cogl/cogl-types.h +++ b/clutter/cogl/cogl-types.h @@ -228,7 +228,6 @@ GType cogl_feature_flags_get_type (void) G_GNUC_CONST; /** * CoglBufferTarget: * @COGL_WINDOW_BUFFER: FIXME - * @COGL_MASK_BUFFER: FIXME * @COGL_OFFSCREEN_BUFFER: FIXME * * Target flags for FBOs. @@ -238,8 +237,7 @@ GType cogl_feature_flags_get_type (void) G_GNUC_CONST; typedef enum { COGL_WINDOW_BUFFER = (1 << 1), - COGL_MASK_BUFFER = (1 << 2), - COGL_OFFSCREEN_BUFFER = (1 << 3) + COGL_OFFSCREEN_BUFFER = (1 << 2) } CoglBufferTarget; #define COGL_TYPE_BUFFER_TARGET (cogl_buffer_target_get_type ()) diff --git a/clutter/cogl/cogl.h.in b/clutter/cogl/cogl.h.in index 2422cd1da..594fc77ca 100644 --- a/clutter/cogl/cogl.h.in +++ b/clutter/cogl/cogl.h.in @@ -578,6 +578,35 @@ void cogl_clip_stack_save (void); */ void cogl_clip_stack_restore (void); +/** + * cogl_set_draw_buffer: + * @target: A #CoglBufferTarget that specifies what kind of draw buffer you + * are setting as the render target. + * @offscreen: If you are setting a draw buffer of type COGL_OFFSCREEN_BUFFER + * then this is a CoglHandle for the offscreen buffer. + * + * This redirects all subsequent drawing to the specified draw buffer. This + * can either be an offscreen buffer created with + * cogl_offscreen_new_to_texture () or you can revert to your original + * on screen window buffer. + */ +void cogl_set_draw_buffer (CoglBufferTarget target, + CoglHandle offscreen); + +/** + * cogl_push_draw_buffer: + * + * Save cogl_set_draw_buffer() state. + */ +void cogl_push_draw_buffer (void); + +/** + * cogl_pop_draw_buffer: + * + * Restore cogl_set_draw_buffer() state. + */ +void cogl_pop_draw_buffer (void); + /** * cogl_flush_gl_state: * @flags: flags controlling what is flushed; currently unused, pass in 0 diff --git a/clutter/cogl/common/cogl-util.c b/clutter/cogl/common/cogl-util.c index 1eb0db10e..d71b9ffd8 100644 --- a/clutter/cogl/common/cogl-util.c +++ b/clutter/cogl/common/cogl-util.c @@ -179,7 +179,6 @@ cogl_buffer_target_get_type (void) { static const GFlagsValue values[] = { { COGL_WINDOW_BUFFER, "COGL_WINDOW_BUFFER", "window-buffer" }, - { COGL_MASK_BUFFER, "COGL_MASK_BUFFER", "mask-buffer" }, { COGL_OFFSCREEN_BUFFER, "COGL_OFFSCREEN_BUFFER", "offscreen-buffer" }, { 0, NULL, NULL } }; diff --git a/clutter/cogl/gl/cogl-fbo.c b/clutter/cogl/gl/cogl-fbo.c index a5f6e22fd..db99e6ace 100644 --- a/clutter/cogl/gl/cogl-fbo.c +++ b/clutter/cogl/gl/cogl-fbo.c @@ -148,15 +148,6 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle) return _cogl_offscreen_handle_new (fbo); } -CoglHandle -cogl_offscreen_new_multisample () -{ - if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_MULTISAMPLE)) - return COGL_INVALID_HANDLE; - - return COGL_INVALID_HANDLE; -} - static void _cogl_offscreen_free (CoglFbo *fbo) { @@ -171,75 +162,7 @@ _cogl_offscreen_free (CoglFbo *fbo) } void -cogl_offscreen_blit_region (CoglHandle src_buffer, - CoglHandle dst_buffer, - int src_x, - int src_y, - int src_w, - int src_h, - int dst_x, - int dst_y, - int dst_w, - int dst_h) -{ - CoglFbo *src_fbo; - CoglFbo *dst_fbo; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_BLIT)) - return; - - /* Make sure these are valid fbo handles */ - if (!cogl_is_offscreen (src_buffer)) - return; - - if (!cogl_is_offscreen (dst_buffer)) - return; - - src_fbo = _cogl_offscreen_pointer_from_handle (src_buffer); - dst_fbo = _cogl_offscreen_pointer_from_handle (dst_buffer); - - /* Copy (and scale) a region from one to another framebuffer */ - GE( glBindFramebufferEXT (GL_READ_FRAMEBUFFER_EXT, src_fbo->gl_handle) ); - GE( glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, dst_fbo->gl_handle) ); - GE( glBlitFramebufferEXT (src_x, src_y, src_x + src_w, src_y + src_h, - dst_x, dst_y, dst_x + dst_w, dst_y + dst_h, - GL_COLOR_BUFFER_BIT, GL_LINEAR) ); -} - -void -cogl_offscreen_blit (CoglHandle src_buffer, - CoglHandle dst_buffer) -{ - CoglFbo *src_fbo; - CoglFbo *dst_fbo; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_BLIT)) - return; - - /* Make sure these are valid fbo handles */ - if (!cogl_is_offscreen (src_buffer)) - return; - - if (!cogl_is_offscreen (dst_buffer)) - return; - - src_fbo = _cogl_offscreen_pointer_from_handle (src_buffer); - dst_fbo = _cogl_offscreen_pointer_from_handle (dst_buffer); - - /* Copy (and scale) whole image from one to another framebuffer */ - GE( glBindFramebufferEXT (GL_READ_FRAMEBUFFER_EXT, src_fbo->gl_handle) ); - GE( glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, dst_fbo->gl_handle) ); - GE( glBlitFramebufferEXT (0, 0, src_fbo->width, src_fbo->height, - 0, 0, dst_fbo->width, dst_fbo->height, - GL_COLOR_BUFFER_BIT, GL_LINEAR) ); -} - -void -cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) +cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) { CoglFbo *fbo = NULL; CoglDrawBufferState *draw_buffer; @@ -301,10 +224,8 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) GE( glEnable (GL_SCISSOR_TEST) ); GE( glClear (GL_COLOR_BUFFER_BIT) ); GE( glPopAttrib () ); - } - else if ((target & COGL_WINDOW_BUFFER) || - (target & COGL_MASK_BUFFER)) + else if (target & COGL_WINDOW_BUFFER) { /* Check current draw buffer target */ if (draw_buffer->target == COGL_OFFSCREEN_BUFFER) @@ -322,23 +243,6 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) /* Bind window framebuffer object */ GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0) ); - - - if (target == COGL_WINDOW_BUFFER) - { - /* Draw to RGB channels */ - GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE) ); - } - else if (target == COGL_MASK_BUFFER) - { - /* Draw only to ALPHA channel */ - GE( glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE) ); - } - else - { - /* Draw to all channels */ - GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) ); - } } /* Store new target */ @@ -389,14 +293,14 @@ cogl_pop_draw_buffer(void) to_pop = ctx->draw_buffer_stack->data; to_restore = ctx->draw_buffer_stack->next->data; - /* the logic in cogl_draw_buffer() only works if + /* the logic in cogl_set_draw_buffer() only works if * to_pop is still on top of the stack, because - * cogl_draw_buffer() needs to know the previous + * cogl_set_draw_buffer() needs to know the previous * state. */ - cogl_draw_buffer (to_restore->target, to_restore->offscreen); + cogl_set_draw_buffer (to_restore->target, to_restore->offscreen); - /* cogl_draw_buffer() should have set top of stack + /* cogl_set_draw_buffer() should have set top of stack * to to_restore */ g_assert (to_restore->target == to_pop->target); @@ -409,3 +313,4 @@ cogl_pop_draw_buffer(void) g_slice_free (CoglDrawBufferState, to_pop); } + diff --git a/clutter/cogl/gles/cogl-fbo.c b/clutter/cogl/gles/cogl-fbo.c index 2b8aa46fa..08b6cff13 100644 --- a/clutter/cogl/gles/cogl-fbo.c +++ b/clutter/cogl/gles/cogl-fbo.c @@ -130,15 +130,6 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle) return _cogl_offscreen_handle_new (fbo); } -CoglHandle -cogl_offscreen_new_multisample () -{ - if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_MULTISAMPLE)) - return COGL_INVALID_HANDLE; - - return COGL_INVALID_HANDLE; -} - static void _cogl_offscreen_free (CoglFbo *fbo) { @@ -153,31 +144,7 @@ _cogl_offscreen_free (CoglFbo *fbo) } void -cogl_offscreen_blit_region (CoglHandle src_buffer, - CoglHandle dst_buffer, - int src_x, - int src_y, - int src_w, - int src_h, - int dst_x, - int dst_y, - int dst_w, - int dst_h) -{ - /* Not supported on GLES */ - return; -} - -void -cogl_offscreen_blit (CoglHandle src_buffer, - CoglHandle dst_buffer) -{ - /* Not supported on GLES */ - return; -} - -void -cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) +cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) { CoglFbo *fbo = NULL; CoglDrawBufferState *draw_buffer; @@ -249,8 +216,7 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) scissor_box[2], scissor_box[3]); } - else if ((target & COGL_WINDOW_BUFFER) || - (target & COGL_MASK_BUFFER)) + else if (target & COGL_WINDOW_BUFFER) { /* Check current draw buffer target */ if (draw_buffer->target == COGL_OFFSCREEN_BUFFER) @@ -269,23 +235,6 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) /* Bind window framebuffer object */ GE( glBindFramebuffer (GL_FRAMEBUFFER, 0) ); - - - if (target == COGL_WINDOW_BUFFER) - { - /* Draw to RGB channels */ - GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) ); - } - else if (target == COGL_MASK_BUFFER) - { - /* Draw only to ALPHA channel */ - GE( glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE) ); - } - else - { - /* Draw to all channels */ - GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) ); - } } /* Store new target */ @@ -336,14 +285,14 @@ cogl_pop_draw_buffer(void) to_pop = ctx->draw_buffer_stack->data; to_restore = ctx->draw_buffer_stack->next->data; - /* the logic in cogl_draw_buffer() only works if + /* the logic in cogl_set_draw_buffer() only works if * to_pop is still on top of the stack, because - * cogl_draw_buffer() needs to know the previous + * cogl_set_draw_buffer() needs to know the previous * state. */ - cogl_draw_buffer (to_restore->target, to_restore->offscreen); + cogl_set_draw_buffer (to_restore->target, to_restore->offscreen); - /* cogl_draw_buffer() should have set top of stack + /* cogl_set_draw_buffer() should have set top of stack * to to_restore */ g_assert (to_restore->target == to_pop->target); @@ -373,12 +322,6 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle) return COGL_INVALID_HANDLE; } -CoglHandle -cogl_offscreen_new_multisample () -{ - return COGL_INVALID_HANDLE; -} - CoglHandle cogl_offscreen_ref (CoglHandle handle) { @@ -391,27 +334,7 @@ cogl_offscreen_unref (CoglHandle handle) } void -cogl_offscreen_blit_region (CoglHandle src_buffer, - CoglHandle dst_buffer, - int src_x, - int src_y, - int src_w, - int src_h, - int dst_x, - int dst_y, - int dst_w, - int dst_h) -{ -} - -void -cogl_offscreen_blit (CoglHandle src_buffer, - CoglHandle dst_buffer) -{ -} - -void -cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) +cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen) { } diff --git a/clutter/cogl/gles/cogl-texture.c b/clutter/cogl/gles/cogl-texture.c index 959332919..0954798d9 100644 --- a/clutter/cogl/gles/cogl-texture.c +++ b/clutter/cogl/gles/cogl-texture.c @@ -483,9 +483,6 @@ _cogl_texture_download_from_gl (CoglTexture *tex, _cogl_current_matrix_push (); _cogl_current_matrix_identity (); - /* Draw to all channels */ - cogl_draw_buffer (COGL_WINDOW_BUFFER | COGL_MASK_BUFFER, 0); - /* Direct copy operation */ if (ctx->texture_download_material == COGL_INVALID_HANDLE) @@ -582,8 +579,6 @@ _cogl_texture_download_from_gl (CoglTexture *tex, _cogl_set_current_matrix (COGL_MATRIX_MODELVIEW); _cogl_current_matrix_pop (); - cogl_draw_buffer (COGL_WINDOW_BUFFER, 0); - return TRUE; } diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt index bc9d6afc1..ff8df1cbc 100644 --- a/doc/reference/cogl/cogl-sections.txt +++ b/doc/reference/cogl/cogl-sections.txt @@ -173,9 +173,7 @@ cogl_offscreen_new_to_texture cogl_offscreen_ref cogl_offscreen_unref cogl_is_offscreen -cogl_offscreen_blit -cogl_offscreen_blit_region -cogl_draw_buffer +cogl_set_draw_buffer cogl_offscreen_new_multisample
diff --git a/tests/interactive/test-cogl-offscreen.c b/tests/interactive/test-cogl-offscreen.c index e03ff8fe2..366053dc9 100644 --- a/tests/interactive/test-cogl-offscreen.c +++ b/tests/interactive/test-cogl-offscreen.c @@ -95,7 +95,7 @@ test_coglbox_paint(ClutterActor *self) 0, 0, 6, 6); - cogl_draw_buffer (COGL_OFFSCREEN_BUFFER, priv->offscreen_id); + cogl_set_draw_buffer (COGL_OFFSCREEN_BUFFER, priv->offscreen_id); cogl_set_source_color4ub (0xff, 0, 0, 0xff); cogl_rectangle (20, 20, 20 + 100, 20 + 100); @@ -103,7 +103,7 @@ test_coglbox_paint(ClutterActor *self) cogl_set_source_color4ub (0, 0xff, 0, 0xff); cogl_rectangle (80, 80, 80 + 100, 80 + 100); - cogl_draw_buffer (COGL_WINDOW_BUFFER, 0); + cogl_set_draw_buffer (COGL_WINDOW_BUFFER, 0); material = cogl_material_new (); cogl_material_set_color4ub (material, 0xff, 0xff, 0xff, 0x88); From 353187ce49f681b590ffc02a19fb378e96d42dc3 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Fri, 1 May 2009 09:53:20 +0100 Subject: [PATCH 16/66] [cogl-material] Adds a cogl_material_set_color4f convenience function This is simply a wrapper around cogl_color_set_from_4f and cogl_material_set_color. We already had a prototype for this, it was an oversight that it wasn't already implemented. --- clutter/cogl/cogl-material.h | 4 ++-- clutter/cogl/common/cogl-material.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/clutter/cogl/cogl-material.h b/clutter/cogl/cogl-material.h index c77b09100..95a474831 100644 --- a/clutter/cogl/cogl-material.h +++ b/clutter/cogl/cogl-material.h @@ -109,7 +109,7 @@ void cogl_material_set_color (CoglHandle material, const CoglColor *color); * * This is the basic color of the material, used when no lighting is enabled. * - * The default value is (1.0, 1.0, 1.0, 1.0) + * The default value is (0xff, 0xff, 0xff, 0xff) * * Since 1.0 */ @@ -134,7 +134,7 @@ void cogl_material_set_color4ub (CoglHandle material, * Since 1.0 */ void cogl_material_set_color4f (CoglHandle material, - float red, + float red, float green, float blue, float alpha); diff --git a/clutter/cogl/common/cogl-material.c b/clutter/cogl/common/cogl-material.c index 2c7df33c8..c456cac6a 100644 --- a/clutter/cogl/common/cogl-material.c +++ b/clutter/cogl/common/cogl-material.c @@ -193,6 +193,18 @@ cogl_material_set_color4ub (CoglHandle handle, cogl_material_set_color (handle, &color); } +void +cogl_material_set_color4f (CoglHandle handle, + float red, + float green, + float blue, + float alpha) +{ + CoglColor color; + cogl_color_set_from_4f (&color, red, green, blue, alpha); + cogl_material_set_color (handle, &color); +} + void cogl_material_get_ambient (CoglHandle handle, CoglColor *ambient) From b2fbc2c95c8b3f0bebb6f1f4a8579dd303163078 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 5 May 2009 19:39:26 +0100 Subject: [PATCH 17/66] [list-model] Use an internal iterator for comparisons In order to carry out various comparisons for e.g. identifying the first iterator in the model we need a ClutterModelIter. This change switches from creating a new iterator each time to reusing an existing iterator. --- clutter/clutter-list-model.c | 45 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/clutter/clutter-list-model.c b/clutter/clutter-list-model.c index 8b560cee7..90ed80b5d 100644 --- a/clutter/clutter-list-model.c +++ b/clutter/clutter-list-model.c @@ -81,6 +81,8 @@ typedef struct _ClutterModelIterClass ClutterListModelIterClass; struct _ClutterListModelPrivate { GSequence *sequence; + + ClutterModelIter *temp_iter; }; struct _ClutterListModelIter @@ -225,9 +227,7 @@ clutter_list_model_iter_is_first (ClutterModelIter *iter) begin = g_sequence_get_begin_iter (sequence); end = iter_default->seq_iter; - temp_iter = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER, - "model", model, - NULL); + temp_iter = CLUTTER_LIST_MODEL (model)->priv->temp_iter; while (!g_sequence_iter_is_begin (begin)) { @@ -242,8 +242,6 @@ clutter_list_model_iter_is_first (ClutterModelIter *iter) begin = g_sequence_iter_next (begin); } - g_object_unref (temp_iter); - /* This is because the 'begin_iter' is always *before* the last valid * iter, otherwise we'd have endless loops */ @@ -275,9 +273,7 @@ clutter_list_model_iter_is_last (ClutterModelIter *iter) begin = g_sequence_iter_prev (begin); end = iter_default->seq_iter; - temp_iter = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER, - "model", model, - NULL); + temp_iter = CLUTTER_LIST_MODEL (model)->priv->temp_iter; while (!g_sequence_iter_is_begin (begin)) { @@ -292,8 +288,6 @@ clutter_list_model_iter_is_last (ClutterModelIter *iter) begin = g_sequence_iter_prev (begin); } - g_object_unref (temp_iter); - /* This is because the 'end_iter' is always *after* the last valid iter. * Otherwise we'd have endless loops */ @@ -320,9 +314,7 @@ clutter_list_model_iter_next (ClutterModelIter *iter) filter_next = g_sequence_iter_next (iter_default->seq_iter); g_assert (filter_next != NULL); - temp_iter = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER, - "model", model, - NULL); + temp_iter = CLUTTER_LIST_MODEL (model)->priv->temp_iter; while (!g_sequence_iter_is_end (filter_next)) { @@ -337,8 +329,6 @@ clutter_list_model_iter_next (ClutterModelIter *iter) filter_next = g_sequence_iter_next (filter_next); } - g_object_unref (temp_iter); - if (g_sequence_iter_is_end (filter_next)) row += 1; @@ -367,9 +357,7 @@ clutter_list_model_iter_prev (ClutterModelIter *iter) filter_prev = g_sequence_iter_prev (iter_default->seq_iter); g_assert (filter_prev != NULL); - temp_iter = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER, - "model", model, - NULL); + temp_iter = CLUTTER_LIST_MODEL (model)->priv->temp_iter; while (!g_sequence_iter_is_begin (filter_prev)) { @@ -384,8 +372,6 @@ clutter_list_model_iter_prev (ClutterModelIter *iter) filter_prev = g_sequence_iter_prev (filter_prev); } - g_object_unref (temp_iter); - if (g_sequence_iter_is_begin (filter_prev)) row -= 1; @@ -683,6 +669,20 @@ clutter_list_model_finalize (GObject *gobject) G_OBJECT_CLASS (clutter_list_model_parent_class)->finalize (gobject); } +static void +clutter_list_model_dispose (GObject *gobject) +{ + ClutterListModel *model = CLUTTER_LIST_MODEL (gobject); + + if (model->priv->temp_iter) + { + g_object_unref (model->priv->temp_iter); + model->priv->temp_iter = NULL; + } + + G_OBJECT_CLASS (clutter_list_model_parent_class)->finalize (gobject); +} + static void clutter_list_model_class_init (ClutterListModelClass *klass) { @@ -692,6 +692,7 @@ clutter_list_model_class_init (ClutterListModelClass *klass) g_type_class_add_private (klass, sizeof (ClutterListModelPrivate)); gobject_class->finalize = clutter_list_model_finalize; + gobject_class->dispose = clutter_list_model_dispose; model_class->get_iter_at_row = clutter_list_model_get_iter_at_row; model_class->insert_row = clutter_list_model_insert_row; @@ -707,6 +708,10 @@ clutter_list_model_init (ClutterListModel *model) model->priv = CLUTTER_LIST_MODEL_GET_PRIVATE (model); model->priv->sequence = g_sequence_new (NULL); + model->priv->temp_iter = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER, + "model", + model, + NULL); } /** From 41bb88548605948787d53475fce68194ad441db3 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 5 May 2009 20:15:01 +0100 Subject: [PATCH 18/66] [model] Add a private row mutator to ClutterModelIter When calling clutter_model_iter_next () / clutter_model_iter_prev () we need to update the row for the iterator. In order to improve the peformance of iterating this change adds a private row mutator and switches ClutterListModel to use it. --- clutter/clutter-list-model.c | 4 ++-- clutter/clutter-model-private.h | 3 +++ clutter/clutter-model.c | 10 ++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/clutter/clutter-list-model.c b/clutter/clutter-list-model.c index 90ed80b5d..d83dc7988 100644 --- a/clutter/clutter-list-model.c +++ b/clutter/clutter-list-model.c @@ -333,7 +333,7 @@ clutter_list_model_iter_next (ClutterModelIter *iter) row += 1; /* update the iterator and return it */ - g_object_set (G_OBJECT (iter_default), "model", model, "row", row, NULL); + clutter_model_iter_set_row (CLUTTER_MODEL_ITER (iter_default), row); iter_default->seq_iter = filter_next; return CLUTTER_MODEL_ITER (iter_default); @@ -376,7 +376,7 @@ clutter_list_model_iter_prev (ClutterModelIter *iter) row -= 1; /* update the iterator and return it */ - g_object_set (G_OBJECT (iter_default), "model", model, "row", row, NULL); + clutter_model_iter_set_row (CLUTTER_MODEL_ITER (iter_default), row); iter_default->seq_iter = filter_prev; return CLUTTER_MODEL_ITER (iter_default); diff --git a/clutter/clutter-model-private.h b/clutter/clutter-model-private.h index 051ca1565..51aad05e8 100644 --- a/clutter/clutter-model-private.h +++ b/clutter/clutter-model-private.h @@ -19,6 +19,9 @@ void clutter_model_set_column_name (ClutterModel *model, gint column, const gchar *name); +void clutter_model_iter_set_row (ClutterModelIter *iter, + guint row); + G_END_DECLS #endif /* __CLUTTER_MODEL_PRIVATE_H__ */ diff --git a/clutter/clutter-model.c b/clutter/clutter-model.c index cfca42897..3fb9d952a 100644 --- a/clutter/clutter-model.c +++ b/clutter/clutter-model.c @@ -441,6 +441,8 @@ clutter_model_check_type (GType gtype) return FALSE; } + + /** * clutter_model_resort: * @model: a #ClutterModel @@ -1509,6 +1511,14 @@ clutter_model_iter_real_get_row (ClutterModelIter *iter) return iter->priv->row; } +/* private function */ +void +clutter_model_iter_set_row (ClutterModelIter *iter, + guint row) +{ + iter->priv->row = row; +} + static void clutter_model_iter_get_value_unimplemented (ClutterModelIter *iter, guint column, From c065524b9f15aa73f9d73044b41a62644fc76a91 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 6 May 2009 10:35:28 +0100 Subject: [PATCH 19/66] Fix inclusion guards and headers The C++ inclusion guards G_BEGIN_DECLS and G_END_DECLS are defined by GLib; so we need to include glib.h before using them. --- clutter/cogl/cogl-bitmap.h | 4 ++-- clutter/cogl/cogl-shader.h | 2 +- clutter/cogl/cogl-texture.h | 4 ++-- clutter/cogl/gl/cogl-defines.h.in | 1 + clutter/cogl/gles/cogl-defines.h.in | 1 + 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/clutter/cogl/cogl-bitmap.h b/clutter/cogl/cogl-bitmap.h index 1bb3eb3db..e018452a8 100644 --- a/clutter/cogl/cogl-bitmap.h +++ b/clutter/cogl/cogl-bitmap.h @@ -28,10 +28,10 @@ #ifndef __COGL_BITMAP_H__ #define __COGL_BITMAP_H__ -G_BEGIN_DECLS - #include +G_BEGIN_DECLS + /** * SECTION:cogl-bitmap * @short_description: Fuctions for loading images but not directly diff --git a/clutter/cogl/cogl-shader.h b/clutter/cogl/cogl-shader.h index 4b5648265..cd0bc8c8b 100644 --- a/clutter/cogl/cogl-shader.h +++ b/clutter/cogl/cogl-shader.h @@ -28,7 +28,7 @@ #ifndef __COGL_SHADER_H__ #define __COGL_SHADER_H__ -#include +#include G_BEGIN_DECLS diff --git a/clutter/cogl/cogl-texture.h b/clutter/cogl/cogl-texture.h index ccf55eb0c..c63041bbd 100644 --- a/clutter/cogl/cogl-texture.h +++ b/clutter/cogl/cogl-texture.h @@ -28,10 +28,10 @@ #ifndef __COGL_TEXTURE_H__ #define __COGL_TEXTURE_H__ -G_BEGIN_DECLS - #include +G_BEGIN_DECLS + /** * SECTION:cogl-texture * @short_description: Fuctions for creating and manipulating textures diff --git a/clutter/cogl/gl/cogl-defines.h.in b/clutter/cogl/gl/cogl-defines.h.in index 1c0c1636a..100cd74a0 100644 --- a/clutter/cogl/gl/cogl-defines.h.in +++ b/clutter/cogl/gl/cogl-defines.h.in @@ -24,6 +24,7 @@ #ifndef __COGL_DEFINES_H__ #define __COGL_DEFINES_H__ +#include #include <@CLUTTER_GL_HEADER@> G_BEGIN_DECLS diff --git a/clutter/cogl/gles/cogl-defines.h.in b/clutter/cogl/gles/cogl-defines.h.in index a40d5d610..d6010509b 100644 --- a/clutter/cogl/gles/cogl-defines.h.in +++ b/clutter/cogl/gles/cogl-defines.h.in @@ -26,6 +26,7 @@ #ifndef __COGL_DEFINES_H__ #define __COGL_DEFINES_H__ +#include #include <@CLUTTER_GL_HEADER@> G_BEGIN_DECLS From 43fa38fcf5178bf91b8b49fc1ddf0b36b07f4b59 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 6 May 2009 10:55:17 +0100 Subject: [PATCH 20/66] [build] Clean up the makefile Split out the files into their own variables to clean up the Makefile template; also use top_srcdir with the header files instead of top_builddir. --- clutter/cogl/gl/Makefile.am | 102 ++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/clutter/cogl/gl/Makefile.am b/clutter/cogl/gl/Makefile.am index b143e8e9b..64fb8cb78 100644 --- a/clutter/cogl/gl/Makefile.am +++ b/clutter/cogl/gl/Makefile.am @@ -1,66 +1,66 @@ -libclutterincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/cogl -libclutterinclude_HEADERS = \ - $(top_builddir)/clutter/cogl/cogl.h \ - $(top_builddir)/clutter/cogl/cogl-defines-gl.h \ - $(top_builddir)/clutter/cogl/cogl-color.h \ - $(top_builddir)/clutter/cogl/cogl-deprecated.h \ - $(top_builddir)/clutter/cogl/cogl-fixed.h \ - $(top_builddir)/clutter/cogl/cogl-offscreen.h \ - $(top_builddir)/clutter/cogl/cogl-path.h \ - $(top_builddir)/clutter/cogl/cogl-shader.h \ - $(top_builddir)/clutter/cogl/cogl-bitmap.h \ - $(top_builddir)/clutter/cogl/cogl-texture.h \ - $(top_builddir)/clutter/cogl/cogl-types.h \ - $(top_builddir)/clutter/cogl/cogl-vertex-buffer.h \ - $(top_builddir)/clutter/cogl/cogl-material.h \ - $(top_builddir)/clutter/cogl/cogl-matrix.h \ - $(top_builddir)/clutter/cogl/cogl-debug.h +NULL = + +cogl_headers = \ + $(top_builddir)/clutter/cogl/cogl-defines-gl.h \ + $(top_srcdir)/clutter/cogl/cogl-color.h \ + $(top_srcdir)/clutter/cogl/cogl-deprecated.h \ + $(top_srcdir)/clutter/cogl/cogl-fixed.h \ + $(top_srcdir)/clutter/cogl/cogl-offscreen.h \ + $(top_srcdir)/clutter/cogl/cogl-path.h \ + $(top_srcdir)/clutter/cogl/cogl-shader.h \ + $(top_srcdir)/clutter/cogl/cogl-bitmap.h \ + $(top_srcdir)/clutter/cogl/cogl-texture.h \ + $(top_srcdir)/clutter/cogl/cogl-types.h \ + $(top_srcdir)/clutter/cogl/cogl-vertex-buffer.h \ + $(top_srcdir)/clutter/cogl/cogl-material.h \ + $(top_srcdir)/clutter/cogl/cogl-matrix.h \ + $(top_srcdir)/clutter/cogl/cogl-debug.h \ + $(NULL) + +cogl_priv_headers = \ + cogl-internal.h \ + cogl-texture-private.h \ + cogl-fbo.h \ + cogl-shader-private.h \ + cogl-program.h \ + cogl-context.h \ + $(NULL) + +cogl_sources = \ + cogl.c \ + cogl-primitives.c \ + cogl-texture.c \ + cogl-fbo.c \ + cogl-shader.c \ + cogl-program.c \ + cogl-context.c \ + $(NULL) + +coglincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/cogl +coglinclude_HEADERS = \ + $(cogl_headers) \ + $(top_builddir)/clutter/cogl/cogl.h INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/clutter \ -I$(top_srcdir)/clutter/cogl \ -I$(top_srcdir)/clutter/cogl/common \ -I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \ -I$(top_builddir)/clutter \ - -I$(top_builddir)/clutter/cogl \ - -DG_LOG_DOMAIN=\"Cogl-GL\" \ - -DCLUTTER_COMPILATION \ - $(CLUTTER_CFLAGS) \ - $(CLUTTER_DEBUG_CFLAGS) \ - $(MAINTAINER_CFLAGS) \ - $(GCC_FLAGS) + -DG_LOG_DOMAIN=\"Cogl-GL\" \ + -DCLUTTER_COMPILATION + +AM_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) LDADD = $(CLUTTER_LIBS) noinst_LTLIBRARIES = libclutter-cogl.la libclutter_cogl_la_SOURCES = \ - $(top_builddir)/clutter/cogl/cogl.h \ - $(top_builddir)/clutter/cogl/cogl-defines-gl.h \ - $(top_builddir)/clutter/cogl/cogl-color.h \ - $(top_builddir)/clutter/cogl/cogl-deprecated.h \ - $(top_builddir)/clutter/cogl/cogl-fixed.h \ - $(top_builddir)/clutter/cogl/cogl-offscreen.h \ - $(top_builddir)/clutter/cogl/cogl-path.h \ - $(top_builddir)/clutter/cogl/cogl-shader.h \ - $(top_builddir)/clutter/cogl/cogl-bitmap.h \ - $(top_builddir)/clutter/cogl/cogl-texture.h \ - $(top_builddir)/clutter/cogl/cogl-types.h \ - $(top_builddir)/clutter/cogl/cogl-debug.h \ - cogl-internal.h \ - cogl-texture-private.h \ - cogl-fbo.h \ - cogl-shader-private.h \ - cogl-program.h \ - cogl-context.h \ - cogl.c \ - cogl-primitives.c \ - cogl-texture.c \ - cogl-fbo.c \ - cogl-shader.c \ - cogl-program.c \ - cogl-context.c + $(top_builddir)/clutter/cogl/cogl.h \ + $(cogl_headers) \ + $(cogl_priv_headers) \ + $(cogl_sources) \ + $(NULL) EXTRA_DIST = cogl-defines.h.in From 8ca46d728ddd1c86869b0e04494b3a73d99e2133 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 6 May 2009 11:18:31 +0100 Subject: [PATCH 21/66] [build] Build Cogl introspection data Currently, the introspection data for Cogl is built right into Clutter's own typelib. This makes functions like: cogl_path_round_rectangle() Appear as: Clutter.cogl_path_round_rectangle() It should be possible, instead, to have a Cogl namespace and: Cogl.path_round_rectangle() This means building introspection data for Cogl alone. Unfortunately, there are three types defined in Cogl that confuse the introspection scanner, and make it impossible to build a typelib: COGLint COGLuint COGLenum These three types should go away before 1.0, substituted by int, unsigned int and proper enumeration types. For this reason, we can just set up the GIR build and wait until the last moment to create the typelib. Once that has been done, we will be able to safely remove the Cogl API from the Clutter GIR and typelib and let people import Cogl if they want to use the Cogl API via introspection. --- clutter/cogl/Makefile.am | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/clutter/cogl/Makefile.am b/clutter/cogl/Makefile.am index da2a04409..94f5e2a15 100644 --- a/clutter/cogl/Makefile.am +++ b/clutter/cogl/Makefile.am @@ -20,3 +20,60 @@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = $(pc_files) CLEANFILES = $(pc_files) + +AM_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) + +if HAVE_INTROSPECTION + +cogl_headers = \ + $(top_srcdir)/clutter/cogl/cogl-bitmap.h \ + $(top_srcdir)/clutter/cogl/cogl-color.h \ + $(top_srcdir)/clutter/cogl/cogl-debug.h \ + $(top_srcdir)/clutter/cogl/cogl-fixed.h \ + $(top_srcdir)/clutter/cogl/cogl-material.h \ + $(top_srcdir)/clutter/cogl/cogl-matrix.h \ + $(top_srcdir)/clutter/cogl/cogl-offscreen.h \ + $(top_srcdir)/clutter/cogl/cogl-path.h \ + $(top_srcdir)/clutter/cogl/cogl-shader.h \ + $(top_srcdir)/clutter/cogl/cogl-texture.h \ + $(top_srcdir)/clutter/cogl/cogl-types.h \ + $(top_srcdir)/clutter/cogl/cogl-vertex-buffer.h + +Cogl-@CLUTTER_API_VERSION@.gir: $(INTROSPECTION_SCANNER) $(CLUTTER_COGL)/libclutter-cogl.la + $(QUIET_GEN)$(INTROSPECTION_SCANNER) -v \ + --namespace Cogl --nsversion=@CLUTTER_API_VERSION@ \ + -I$(top_srcdir)/clutter/cogl \ + -I$(top_srcdir)/clutter/cogl/common \ + -I$(top_srcdir)/clutter/cogl/@CLUTTER_COGL@ \ + -I$(top_builddir)/clutter \ + -DCLUTTER_COMPILATION \ + --include=GL-1.0 \ + --include=GObject-2.0 \ + --library=clutter-@CLUTTER_FLAVOUR@-@CLUTTER_API_VERSION@ \ + --libtool="$(top_builddir)/doltlibtool" \ + --pkg gobject-2.0 \ + --output $@ \ + $(top_builddir)/clutter/cogl/cogl-defines-@CLUTTER_COGL@.h \ + $(top_builddir)/clutter/cogl/cogl.h \ + $(cogl_headers) + +BUILT_GIRSOURCES = Cogl-@CLUTTER_API_VERSION@.gir + +girdir = $(datadir)/gir-1.0 +gir_DATA = $(BUILT_GIRSOURCES) + +#typelibsdir = $(libdir)/girepository-1.0 +#typelibs_DATA = Cogl-@CLUTTER_API_VERSION@.typelib + +#%.typelib: %.gir $(INTROSPECTION_COMPILER) +# $(QUIET_GEN)$(DEBUG) $(INTROSPECTION_COMPILER) \ +# --includedir=$(top_builddir)/clutter \ +# --includedir=$(top_srcdir)/clutter \ +# --includedir=$(srcdir) \ +# --includedir=. \ +# $(INTROSPECTION_COMPILER_OPTS) \ +# $< -o $(@F) + +CLEANFILES += $(BUILT_GIRSOURCES) #$(typelibs_DATA) + +endif From 2ae9d84a2a917993ea2efb4f6980ed325a711371 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 6 May 2009 18:32:17 +0100 Subject: [PATCH 22/66] [x11] Use -1 as the default screen guard Currently, the default screen guard value is 0, which is a valid screen number on X11, and it might not be the default. Patch suggested by: Owen W. Taylor --- clutter/x11/clutter-backend-x11.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clutter/x11/clutter-backend-x11.c b/clutter/x11/clutter-backend-x11.c index 28fe3e825..b8d17ab72 100644 --- a/clutter/x11/clutter-backend-x11.c +++ b/clutter/x11/clutter-backend-x11.c @@ -95,7 +95,7 @@ static Display *_foreign_dpy = NULL; /* options */ static gchar *clutter_display_name = NULL; -static gint clutter_screen = 0; +static gint clutter_screen = -1; static gboolean clutter_synchronise = FALSE; /* X error trap */ @@ -167,7 +167,7 @@ clutter_backend_x11_post_parse (ClutterBackend *backend, CLUTTER_NOTE (BACKEND, "Getting the X screen"); - if (clutter_screen == 0) + if (clutter_screen == -1) backend_x11->xscreen = DefaultScreenOfDisplay (backend_x11->xdpy); else backend_x11->xscreen = ScreenOfDisplay (backend_x11->xdpy, From 692c50ba672b55d809e12b97184e7ee21d9f3fda Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 8 May 2009 10:57:56 +0100 Subject: [PATCH 23/66] [list-model] Return NULL for first row in a fully filtered model If the filter means that the there should be no rows left in the model, clutter_model_get_iter_at_row (model, 0) should return NULL. Howevever the currene implementation misbehaves and returns a bad iterator. This change resolves the issue by tracking if we actually found any non-filtered rows in our pass through the sequence. OH Bugzilla: 1591 --- clutter/clutter-list-model.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-list-model.c b/clutter/clutter-list-model.c index d83dc7988..bca5a47f2 100644 --- a/clutter/clutter-list-model.c +++ b/clutter/clutter-list-model.c @@ -462,6 +462,7 @@ clutter_list_model_get_iter_at_row (ClutterModel *model, if (row == 0) { GSequenceIter *filter_next; + gboolean row_found = FALSE; filter_next = g_sequence_get_begin_iter (sequence); g_assert (filter_next != NULL); @@ -471,10 +472,21 @@ clutter_list_model_get_iter_at_row (ClutterModel *model, retval->seq_iter = filter_next; if (clutter_model_filter_iter (model, CLUTTER_MODEL_ITER (retval))) - break; + { + /* We've found a row that is valid under the filter */ + row_found = TRUE; + break; + } filter_next = g_sequence_iter_next (filter_next); } + + /* Everything has been filtered -> there is no first row */ + if (!row_found) + { + g_object_unref (retval); + return NULL; + } } else { From d00cac635325e5e279fb9dce87bfc36954d314b7 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 10 May 2009 00:41:17 +0100 Subject: [PATCH 24/66] [build] Unbreak compilation When building Clutter with introspection enabled everything stops at Cogl GIR generation because it depends on the installed library to work. Since we still require some changes in the API to be able to build the GIR and the typelib for Cogl we should disable the generation of the GIR as well. --- clutter/cogl/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clutter/cogl/Makefile.am b/clutter/cogl/Makefile.am index 94f5e2a15..4435e8c64 100644 --- a/clutter/cogl/Makefile.am +++ b/clutter/cogl/Makefile.am @@ -59,8 +59,8 @@ Cogl-@CLUTTER_API_VERSION@.gir: $(INTROSPECTION_SCANNER) $(CLUTTER_COGL)/libclut BUILT_GIRSOURCES = Cogl-@CLUTTER_API_VERSION@.gir -girdir = $(datadir)/gir-1.0 -gir_DATA = $(BUILT_GIRSOURCES) +#girdir = $(datadir)/gir-1.0 +#gir_DATA = $(BUILT_GIRSOURCES) #typelibsdir = $(libdir)/girepository-1.0 #typelibs_DATA = Cogl-@CLUTTER_API_VERSION@.typelib From 10783e053be104c14bfab24dff7c54046790af60 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Tue, 12 May 2009 14:15:37 +0100 Subject: [PATCH 25/66] [build] Fix out-of-tree builds for Cogl Commit 43fa38fcf5 broke out-of-tree builds by removing some of the builddir directories from the include path. builddir/clutter/cogl and builddir/clutter are needed because cogl.h and cogl-defines-gl.h are automatically generated by the configure script. The main clutter headers are in the srcdir so this needs to be in the path too. --- clutter/cogl/gl/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clutter/cogl/gl/Makefile.am b/clutter/cogl/gl/Makefile.am index 64fb8cb78..4d360e63d 100644 --- a/clutter/cogl/gl/Makefile.am +++ b/clutter/cogl/gl/Makefile.am @@ -45,7 +45,9 @@ INCLUDES = \ -I$(top_srcdir)/clutter/cogl \ -I$(top_srcdir)/clutter/cogl/common \ -I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \ + -I$(top_srcdir)/clutter \ -I$(top_builddir)/clutter \ + -I$(top_builddir)/clutter/cogl \ -DG_LOG_DOMAIN=\"Cogl-GL\" \ -DCLUTTER_COMPILATION From 08a73a215f2cf18abcfd7d93e8047583511497bd Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 6 May 2009 19:01:09 +0100 Subject: [PATCH 26/66] Don't call glFinish in _clutter_do_pick Calling glReadPixels is bad enough in forcing us to synchronize the CPU with the GPU, but glFinish has even stronger synchonization semantics than glReadPixels which may negate some driver optimizations possible in glReadPixels. --- clutter/clutter-main.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index d759fb774..aec1dd2aa 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -379,7 +379,8 @@ _clutter_do_pick (ClutterStage *stage, /* Disable dithering (if any) when doing the painting in pick mode */ dither_was_on = glIsEnabled (GL_DITHER); - glDisable (GL_DITHER); + if (dither_was_on) + glDisable (GL_DITHER); /* Render the entire scence in pick mode - just single colored silhouette's * are drawn offscreen (as we never swap buffers) @@ -391,11 +392,6 @@ _clutter_do_pick (ClutterStage *stage, /* Calls should work under both GL and GLES, note GLES needs RGBA */ glGetIntegerv(GL_VIEWPORT, viewport); - /* Below to be safe, particularly on GL ES. an EGL wait call or full - * could be nicer. - */ - glFinish(); - /* Read the color of the screen co-ords pixel */ glReadPixels (x, viewport[3] - y -1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel); From cea711cc7e5c2d8f8328d8ce072f43b8b034d13e Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 12 May 2009 14:20:22 +0100 Subject: [PATCH 27/66] [ClutterTexture] Remove a spurious line I accidentally committed in 741c4bb5 I accidentally changed clutter_texture_set_cogl_texture to always set the filter quality for the new Cogl texture to medium. --- clutter/clutter-texture.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index 8c0dab500..bb7a001f2 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -1457,9 +1457,6 @@ clutter_texture_set_cogl_texture (ClutterTexture *texture, g_object_notify (G_OBJECT (texture), "cogl-texture"); - /* Re-assert the filter quality on the new cogl texture */ - clutter_texture_set_filter_quality (texture, CLUTTER_TEXTURE_QUALITY_MEDIUM); - /* If resized actor may need resizing but paint() will do this */ if (CLUTTER_ACTOR_IS_VISIBLE (texture)) clutter_actor_queue_redraw (CLUTTER_ACTOR (texture)); From 36cfb6030784791a4420a1e52a8c18d56b1d0c69 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 12 May 2009 14:15:18 +0100 Subject: [PATCH 28/66] [cogl] Remove the COGL{enum,int,uint} typedefs COGLenum, COGLint and COGLuint which were simply typedefs for GL{enum,int,uint} have been removed from the API and replaced with specialised enum typedefs, int and unsigned int. These were causing problems for generating bindings and also considered poor style. The cogl texture filter defines CGL_NEAREST and CGL_LINEAR etc are now replaced by a namespaced typedef 'CoglTextureFilter' so they should be replaced with COGL_TEXTURE_FILTER_NEAREST and COGL_TEXTURE_FILTER_LINEAR etc. The shader type defines CGL_VERTEX_SHADER and CGL_FRAGMENT_SHADER are handled by a CoglShaderType typedef and should be replaced with COGL_SHADER_TYPE_VERTEX and COGL_SHADER_TYPE_FRAGMENT. cogl_shader_get_parameteriv has been replaced by cogl_shader_get_type and cogl_shader_is_compiled. More getters can be added later if desired. --- README | 16 +++++ clutter/clutter-shader-types.c | 10 +-- clutter/clutter-shader-types.h | 2 +- clutter/clutter-shader.c | 21 +++--- clutter/clutter-texture.c | 14 ++-- clutter/cogl/cogl-shader.h | 81 ++++++++++++--------- clutter/cogl/cogl-texture.h | 54 ++++++++++++-- clutter/cogl/gl/cogl-defines.h.in | 13 ---- clutter/cogl/gl/cogl-program.c | 14 ++-- clutter/cogl/gl/cogl-shader.c | 73 +++++++++++++++---- clutter/cogl/gl/cogl-texture-private.h | 4 +- clutter/cogl/gl/cogl-texture.c | 20 +++--- clutter/cogl/gles/cogl-defines.h.in | 16 ----- clutter/cogl/gles/cogl-program.c | 26 +++---- clutter/cogl/gles/cogl-shader.c | 88 +++++++++++++++++------ clutter/cogl/gles/cogl-texture-private.h | 4 +- clutter/cogl/gles/cogl-texture.c | 8 +-- clutter/glx/clutter-glx-texture-pixmap.c | 50 +++++++------ clutter/pango/cogl-pango-glyph-cache.c | 8 +-- doc/reference/cogl/cogl-sections.txt | 3 +- tests/interactive/test-cogl-tex-polygon.c | 44 ++++++------ tests/interactive/test-cogl-tex-tile.c | 49 ++++++------- 22 files changed, 375 insertions(+), 243 deletions(-) diff --git a/README b/README index 2bf2a039a..e28a467f3 100644 --- a/README +++ b/README @@ -317,6 +317,22 @@ Release Notes for Clutter 1.0 exposing color mask if anyone wants it later. It was assumed that no one was using this currently. +* COGLenum, COGLint and COGLuint which were simply typedefs for GL{enum,int,uint} + have been removed from the API and replaced with specialised enum typedefs, + int and unsigned int. These were causing problems for generating bindings and + also considered poor style. + +* The cogl texture filter defines CGL_NEAREST and CGL_LINEAR etc are now + replaced by a namespaced typedef 'CoglTextureFilter' so they should be + replaced with COGL_TEXTURE_FILTER_NEAREST and COGL_TEXTURE_FILTER_LINEAR etc. + +* The shader type defines CGL_VERTEX_SHADER and CGL_FRAGMENT_SHADER are handled + by a CoglShaderType typedef and should be replaced with + COGL_SHADER_TYPE_VERTEX and COGL_SHADER_TYPE_FRAGMENT. + +* cogl_shader_get_parameteriv has been replaced by cogl_shader_get_type and + cogl_shader_is_compiled. More getters can be added later if desired. + Release Notes for Clutter 0.8 ------------------------------- diff --git a/clutter/clutter-shader-types.c b/clutter/clutter-shader-types.c index 9b3c6b60f..e03d906b2 100644 --- a/clutter/clutter-shader-types.c +++ b/clutter/clutter-shader-types.c @@ -88,7 +88,7 @@ struct _ClutterShaderFloat struct _ClutterShaderInt { gint size; - COGLint value[4]; + int value[4]; }; struct _ClutterShaderMatrix @@ -223,7 +223,7 @@ clutter_value_collect_shader_int (GValue *value, guint collect_flags) { gint int_count = collect_values[0].v_int; - const COGLint *ints = collect_values[1].v_pointer; + const int *ints = collect_values[1].v_pointer; if (!ints) return g_strdup_printf ("value location for '%s' passed as NULL", @@ -242,7 +242,7 @@ clutter_value_lcopy_shader_int (const GValue *value, guint collect_flags) { gint *int_count = collect_values[0].v_pointer; - COGLint **ints = collect_values[1].v_pointer; + int **ints = collect_values[1].v_pointer; ClutterShaderInt *shader_int = value->data[0].v_pointer; if (!int_count || !ints) @@ -250,7 +250,7 @@ clutter_value_lcopy_shader_int (const GValue *value, G_VALUE_TYPE_NAME (value)); *int_count = shader_int->size; - *ints = g_memdup (shader_int->value, shader_int->size * sizeof (COGLint)); + *ints = g_memdup (shader_int->value, shader_int->size * sizeof (int)); return NULL; } @@ -514,7 +514,7 @@ clutter_value_get_shader_float (const GValue *value, * * Since: 0.8 */ -G_CONST_RETURN COGLint * +G_CONST_RETURN int * clutter_value_get_shader_int (const GValue *value, gsize *length) { diff --git a/clutter/clutter-shader-types.h b/clutter/clutter-shader-types.h index fd36fe1c6..1b4842645 100644 --- a/clutter/clutter-shader-types.h +++ b/clutter/clutter-shader-types.h @@ -86,7 +86,7 @@ void clutter_value_set_shader_matrix (GValue *value, const gfloat *matrix); G_CONST_RETURN gfloat * clutter_value_get_shader_float (const GValue *value, gsize *length); -G_CONST_RETURN COGLint *clutter_value_get_shader_int (const GValue *value, +G_CONST_RETURN gint * clutter_value_get_shader_int (const GValue *value, gsize *length); G_CONST_RETURN gfloat * clutter_value_get_shader_matrix (const GValue *value, gsize *length); diff --git a/clutter/clutter-shader.c b/clutter/clutter-shader.c index b23c70af3..e2ba66ce7 100644 --- a/clutter/clutter-shader.c +++ b/clutter/clutter-shader.c @@ -84,7 +84,7 @@ struct _ClutterShaderPrivate CoglHandle fragment_shader; }; -enum +enum { PROP_0, @@ -126,11 +126,11 @@ clutter_shader_set_property (GObject *object, switch (prop_id) { case PROP_VERTEX_SOURCE: - clutter_shader_set_vertex_source (shader, + clutter_shader_set_vertex_source (shader, g_value_get_string (value), -1); break; case PROP_FRAGMENT_SOURCE: - clutter_shader_set_fragment_source (shader, + clutter_shader_set_fragment_source (shader, g_value_get_string (value), -1); break; case PROP_ENABLED: @@ -427,20 +427,19 @@ clutter_shader_glsl_bind (ClutterShader *self, GError **error) { ClutterShaderPrivate *priv = self->priv; - GLint is_compiled = CGL_FALSE; CoglHandle shader = COGL_INVALID_HANDLE; switch (shader_type) { case CLUTTER_VERTEX_SHADER: - shader = cogl_create_shader (CGL_VERTEX_SHADER); + shader = cogl_create_shader (COGL_SHADER_TYPE_VERTEX); cogl_shader_source (shader, priv->vertex_source); priv->vertex_shader = shader; break; case CLUTTER_FRAGMENT_SHADER: - shader = cogl_create_shader (CGL_FRAGMENT_SHADER); + shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT); cogl_shader_source (shader, priv->fragment_source); priv->fragment_shader = shader; @@ -450,11 +449,7 @@ clutter_shader_glsl_bind (ClutterShader *self, g_assert (shader != COGL_INVALID_HANDLE); cogl_shader_compile (shader); - cogl_shader_get_parameteriv (shader, - CGL_OBJECT_COMPILE_STATUS, - &is_compiled); - - if (is_compiled != CGL_TRUE) + if (!cogl_shader_is_compiled (shader)) { gchar error_buf[512]; @@ -739,7 +734,7 @@ clutter_shader_set_uniform (ClutterShader *shader, } else if (CLUTTER_VALUE_HOLDS_SHADER_INT (value)) { - const COGLint *ints; + const int *ints; ints = clutter_value_get_shader_int (value, &size); cogl_program_uniform_int (location, size, 1, ints); @@ -759,7 +754,7 @@ clutter_shader_set_uniform (ClutterShader *shader, } else if (G_VALUE_HOLDS_INT (value)) { - COGLint int_val = g_value_get_int (value); + int int_val = g_value_get_int (value); cogl_program_uniform_int (location, 1, 1, &int_val); } diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index bb7a001f2..b44d57d8a 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -187,18 +187,18 @@ clutter_texture_quality_to_filters (ClutterTextureQuality quality, switch (quality) { case CLUTTER_TEXTURE_QUALITY_LOW: - min_filter = CGL_NEAREST; - mag_filter = CGL_NEAREST; + min_filter = COGL_TEXTURE_FILTER_NEAREST; + mag_filter = COGL_TEXTURE_FILTER_NEAREST; break; case CLUTTER_TEXTURE_QUALITY_MEDIUM: - min_filter = CGL_LINEAR; - mag_filter = CGL_LINEAR; + min_filter = COGL_TEXTURE_FILTER_LINEAR; + mag_filter = COGL_TEXTURE_FILTER_LINEAR; break; case CLUTTER_TEXTURE_QUALITY_HIGH: - min_filter = CGL_LINEAR_MIPMAP_LINEAR; - mag_filter = CGL_LINEAR; + min_filter = COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR; + mag_filter = COGL_TEXTURE_FILTER_LINEAR; break; } @@ -1891,7 +1891,7 @@ clutter_texture_async_load (ClutterTexture *self, * If #ClutterTexture:load-async is set to %TRUE, this function * will return as soon as possible, and the actual image loading * from disk will be performed asynchronously. #ClutterTexture::size-change - * will be emitten when the size of the texture is available and + * will be emitten when the size of the texture is available and * #ClutterTexture::load-finished will be emitted when the image has been * loaded or if an error occurred. * diff --git a/clutter/cogl/cogl-shader.h b/clutter/cogl/cogl-shader.h index cd0bc8c8b..59c75ede6 100644 --- a/clutter/cogl/cogl-shader.h +++ b/clutter/cogl/cogl-shader.h @@ -42,6 +42,17 @@ G_BEGIN_DECLS * The only supported format is GLSL shaders. */ +/** + * CoglShaderType: + * @COGL_SHADER_TYPE_VERTEX: A program for proccessing vertices + * @COGL_SHADER_TYPE_FRAGMENT: A program for processing fragments + */ +typedef enum _CoglShaderType +{ + COGL_SHADER_TYPE_VERTEX, + COGL_SHADER_TYPE_FRAGMENT +} CoglShaderType; + /** * cogl_create_shader: * @shader_type: CGL_VERTEX_SHADER or CGL_FRAGMENT_SHADER. @@ -51,7 +62,7 @@ G_BEGIN_DECLS * * Returns: a new shader handle. */ -CoglHandle cogl_create_shader (COGLenum shader_type); +CoglHandle cogl_create_shader (CoglShaderType shader_type); /** * cogl_shader_ref: @@ -91,8 +102,8 @@ gboolean cogl_is_shader (CoglHandle handle); * Replaces the current GLSL source associated with a shader with a new * one. */ -void cogl_shader_source (CoglHandle shader, - const gchar *source); +void cogl_shader_source (CoglHandle shader, + const char *source); /** * cogl_shader_compile: * @handle: #CoglHandle for a shader. @@ -113,22 +124,26 @@ void cogl_shader_compile (CoglHandle handle); * messages that caused a shader to not compile correctly, mainly useful for * debugging purposes. */ -void cogl_shader_get_info_log (CoglHandle handle, - guint size, - gchar *buffer); +void cogl_shader_get_info_log (CoglHandle handle, + size_t size, + char *buffer); /** - * cogl_shader_get_parameteriv: + * cogl_shader_get_type: * @handle: #CoglHandle for a shader. - * @pname: the named COGL parameter to retrieve. - * @dest: storage location for COGLint return value. * - * Retrieve a named parameter from a shader can be used to query to compile - * satus of a shader by passing in CGL_OBJECT_COMPILE_STATUS for @pname. + * Returns: COGL_SHADER_TYPE_VERTEX if the shader is a vertex processor + * or COGL_SHADER_TYPE_FRAGMENT if the shader is a frament processor */ -void cogl_shader_get_parameteriv (CoglHandle handle, - COGLenum pname, - COGLint *dest); +CoglShaderType cogl_shader_get_type (CoglHandle handle); + +/** + * cogl_shader_is_compiled: + * @handle: #CoglHandle for a shader. + * + * Returns: TRUE if the shader object has sucessfully be compiled else FALSE + */ +gboolean cogl_shader_is_compiled (CoglHandle handle); /** * cogl_create_program: @@ -213,9 +228,9 @@ void cogl_program_use (CoglHandle handle); * This uniform can be set using cogl_program_uniform_1f() when the * program is in use. */ -COGLint cogl_program_get_uniform_location - (CoglHandle handle, - const gchar *uniform_name); +int cogl_program_get_uniform_location + (CoglHandle handle, + const char *uniform_name); /** * cogl_program_uniform_1f: @@ -225,8 +240,8 @@ COGLint cogl_program_get_uniform_location * Changes the value of a floating point uniform in the currently * used (see cogl_program_use()) shader program. */ -void cogl_program_uniform_1f (COGLint uniform_no, - gfloat value); +void cogl_program_uniform_1f (int uniform_no, + float value); /** * cogl_program_uniform_1i: @@ -236,8 +251,8 @@ void cogl_program_uniform_1f (COGLint uniform_no, * Changes the value of an integer uniform in the currently * used (see cogl_program_use()) shader program. */ -void cogl_program_uniform_1i (COGLint uniform_no, - gint value); +void cogl_program_uniform_1i (int uniform_no, + int value); /** * cogl_program_uniform_float: @@ -249,9 +264,9 @@ void cogl_program_uniform_1i (COGLint uniform_no, * Changes the value of a float vector uniform, or uniform array in the * currently used (see #cogl_program_use) shader program. */ -void cogl_program_uniform_float (COGLint uniform_no, - gint size, - gint count, +void cogl_program_uniform_float (int uniform_no, + int size, + int count, const GLfloat *value); /** @@ -264,10 +279,10 @@ void cogl_program_uniform_float (COGLint uniform_no, * Changes the value of a int vector uniform, or uniform array in the * currently used (see cogl_program_use()) shader program. */ -void cogl_program_uniform_int (COGLint uniform_no, - gint size, - gint count, - const COGLint *value); +void cogl_program_uniform_int (int uniform_no, + int size, + int count, + const int *value); /** * cogl_program_uniform_matrix: @@ -281,11 +296,11 @@ void cogl_program_uniform_int (COGLint uniform_no, * currently used (see cogl_program_use()) shader program. The @size * parameter is used to determine the square size of the matrix. */ -void cogl_program_uniform_matrix (COGLint uniform_no, - gint size, - gint count, - gboolean transpose, - const GLfloat *value); +void cogl_program_uniform_matrix (int uniform_no, + int size, + int count, + gboolean transpose, + const float *value); G_END_DECLS diff --git a/clutter/cogl/cogl-texture.h b/clutter/cogl/cogl-texture.h index c63041bbd..6a8b00a01 100644 --- a/clutter/cogl/cogl-texture.h +++ b/clutter/cogl/cogl-texture.h @@ -228,6 +228,52 @@ guint cogl_texture_get_rowstride (CoglHandle handle); */ gint cogl_texture_get_max_waste (CoglHandle handle); +/** + * CoglTextureFilter: + * @COGL_TEXTURE_FILTER_NEAREST: Measuring in manhatten distance from the, + * current pixel center, use the nearest texture + * texel. + * @COGL_TEXTURE_FILTER_LINEAR: Use the weighted average of the 4 texels + * nearest the current pixel center. + * @COGL_TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST: Select the mimap level whose + * texel size most closely matches + * the current pixel, and use the + * COGL_TEXTURE_FILTER_NEAREST + * criterion. + * @COGL_TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST: Select the mimap level whose + * texel size most closely matches + * the current pixel, and use the + * COGL_TEXTURE_FILTER_LINEAR + * criterion. + * @COGL_TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR: Select the two mimap levels + * whose texel size most closely + * matches the current pixel, use + * the COGL_TEXTURE_FILTER_NEAREST + * criterion on each one and take + * their weighted average. + * @COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR: Select the two mimap levels + * whose texel size most closely + * matches the current pixel, use + * the COGL_TEXTURE_FILTER_LINEAR + * criterion on each one and take + * their weighted average. + * + * Texture filtering is used whenever the current pixel maps either to more + * than one texture element (texel) or less than one. These filter enums + * correspond to different strategies used to come up with a pixel color, by + * possibly referring to multiple neighbouring texels and taking a weighted + * average or simply using the nearest texel. + */ +typedef enum _CoglTextureFilter +{ + COGL_TEXTURE_FILTER_NEAREST = GL_NEAREST, + COGL_TEXTURE_FILTER_LINEAR = GL_LINEAR, + COGL_TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST, + COGL_TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST = GL_LINEAR_MIPMAP_NEAREST, + COGL_TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR = GL_NEAREST_MIPMAP_LINEAR, + COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR +} CoglTextureFilter; + /** * cogl_texture_get_min_filter: * @handle: a #CoglHandle for a texture. @@ -236,7 +282,7 @@ gint cogl_texture_get_max_waste (CoglHandle handle); * * Returns: the current downscaling filter for a cogl texture. */ -COGLenum cogl_texture_get_min_filter (CoglHandle handle); +CoglTextureFilter cogl_texture_get_min_filter (CoglHandle handle); /** * cogl_texture_get_mag_filter: @@ -246,7 +292,7 @@ COGLenum cogl_texture_get_min_filter (CoglHandle handle); * * Returns: the current downscaling filter for a cogl texture. */ -COGLenum cogl_texture_get_mag_filter (CoglHandle handle); +CoglTextureFilter cogl_texture_get_mag_filter (CoglHandle handle); /** * cogl_texture_is_sliced: @@ -307,8 +353,8 @@ gint cogl_texture_get_data (CoglHandle handle, * drawn at other scales than 100%. */ void cogl_texture_set_filters (CoglHandle handle, - COGLenum min_filter, - COGLenum mag_filter); + CoglTextureFilter min_filter, + CoglTextureFilter mag_filter); /** diff --git a/clutter/cogl/gl/cogl-defines.h.in b/clutter/cogl/gl/cogl-defines.h.in index 100cd74a0..8e2df9ec3 100644 --- a/clutter/cogl/gl/cogl-defines.h.in +++ b/clutter/cogl/gl/cogl-defines.h.in @@ -29,10 +29,6 @@ G_BEGIN_DECLS -typedef GLenum COGLenum; -typedef GLint COGLint; -typedef GLuint COGLuint; - /* FIXME + DOCUMENT */ #define COPENSTEP OPENSTEP @@ -226,7 +222,6 @@ typedef GLuint COGLuint; #define CGL_FOG_INDEX GL_FOG_INDEX #define CGL_FOG_START GL_FOG_START #define CGL_FOG_END GL_FOG_END -#define CGL_LINEAR GL_LINEAR #define CGL_EXP GL_EXP #define CGL_LOGIC_OP GL_LOGIC_OP #define CGL_INDEX_LOGIC_OP GL_INDEX_LOGIC_OP @@ -419,10 +414,6 @@ typedef GLuint COGLuint; #define CGL_TEXTURE_ALPHA_SIZE GL_TEXTURE_ALPHA_SIZE #define CGL_TEXTURE_LUMINANCE_SIZE GL_TEXTURE_LUMINANCE_SIZE #define CGL_TEXTURE_INTENSITY_SIZE GL_TEXTURE_INTENSITY_SIZE -#define CGL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_NEAREST -#define CGL_NEAREST_MIPMAP_LINEAR GL_NEAREST_MIPMAP_LINEAR -#define CGL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_NEAREST -#define CGL_LINEAR_MIPMAP_LINEAR GL_LINEAR_MIPMAP_LINEAR #define CGL_OBJECT_LINEAR GL_OBJECT_LINEAR #define CGL_OBJECT_PLANE GL_OBJECT_PLANE #define CGL_EYE_LINEAR GL_EYE_LINEAR @@ -430,7 +421,6 @@ typedef GLuint COGLuint; #define CGL_SPHERE_MAP GL_SPHERE_MAP #define CGL_DECAL GL_DECAL #define CGL_MODULATE GL_MODULATE -#define CGL_NEAREST GL_NEAREST #define CGL_REPEAT GL_REPEAT #define CGL_CLAMP GL_CLAMP #define CGL_S GL_S @@ -692,9 +682,6 @@ typedef GLuint COGLuint; #define CGL_UNSIGNED_SHORT_8_8_MESA 0 #endif -#define CGL_FRAGMENT_SHADER GL_FRAGMENT_SHADER_ARB -#define CGL_VERTEX_SHADER GL_VERTEX_SHADER_ARB - #define CGL_OBJECT_COMPILE_STATUS GL_OBJECT_COMPILE_STATUS_ARB #define CLUTTER_COGL_HAS_GL 1 diff --git a/clutter/cogl/gl/cogl-program.c b/clutter/cogl/gl/cogl-program.c index 1f652c95e..0a10cd4c4 100644 --- a/clutter/cogl/gl/cogl-program.c +++ b/clutter/cogl/gl/cogl-program.c @@ -139,7 +139,7 @@ cogl_program_use (CoglHandle handle) glUseProgramObjectARB (gl_handle); } -COGLint +int cogl_program_get_uniform_location (CoglHandle handle, const gchar *uniform_name) { @@ -155,7 +155,7 @@ cogl_program_get_uniform_location (CoglHandle handle, } void -cogl_program_uniform_1f (COGLint uniform_no, +cogl_program_uniform_1f (int uniform_no, gfloat value) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -163,7 +163,7 @@ cogl_program_uniform_1f (COGLint uniform_no, } void -cogl_program_uniform_1i (COGLint uniform_no, +cogl_program_uniform_1i (int uniform_no, gint value) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -171,7 +171,7 @@ cogl_program_uniform_1i (COGLint uniform_no, } void -cogl_program_uniform_float (COGLint uniform_no, +cogl_program_uniform_float (int uniform_no, gint size, gint count, const GLfloat *value) @@ -198,10 +198,10 @@ cogl_program_uniform_float (COGLint uniform_no, } void -cogl_program_uniform_int (COGLint uniform_no, +cogl_program_uniform_int (int uniform_no, gint size, gint count, - const COGLint *value) + const int *value) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -225,7 +225,7 @@ cogl_program_uniform_int (COGLint uniform_no, } void -cogl_program_uniform_matrix (COGLint uniform_no, +cogl_program_uniform_matrix (int uniform_no, gint size, gint count, gboolean transpose, diff --git a/clutter/cogl/gl/cogl-shader.c b/clutter/cogl/gl/cogl-shader.c index 0d0896c09..944e6736f 100644 --- a/clutter/cogl/gl/cogl-shader.c +++ b/clutter/cogl/gl/cogl-shader.c @@ -55,21 +55,33 @@ _cogl_shader_free (CoglShader *shader) } CoglHandle -cogl_create_shader (COGLenum shaderType) +cogl_create_shader (CoglShaderType type) { CoglShader *shader; + GLenum gl_type; - _COGL_GET_CONTEXT (ctx, 0); + _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); + + if (type == COGL_SHADER_TYPE_VERTEX) + gl_type = GL_VERTEX_SHADER; + else if (type == COGL_SHADER_TYPE_FRAGMENT) + gl_type = GL_FRAGMENT_SHADER; + else + { + g_warning ("Unexpected shader type (0x%08lX) given to " + "cogl_create_shader", (unsigned long) type); + return COGL_INVALID_HANDLE; + } shader = g_slice_new (CoglShader); - shader->gl_handle = glCreateShaderObjectARB (shaderType); + shader->gl_handle = glCreateShaderObjectARB (gl_type); return _cogl_shader_handle_new (shader); } void cogl_shader_source (CoglHandle handle, - const gchar *source) + const char *source) { CoglShader *shader; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -98,11 +110,11 @@ cogl_shader_compile (CoglHandle handle) void cogl_shader_get_info_log (CoglHandle handle, - guint size, - gchar *buffer) + size_t size, + char *buffer) { CoglShader *shader; - COGLint len; + int len; _COGL_GET_CONTEXT (ctx, NO_RETVAL); if (!cogl_is_shader (handle)) @@ -114,18 +126,51 @@ cogl_shader_get_info_log (CoglHandle handle, buffer[len]='\0'; } -void -cogl_shader_get_parameteriv (CoglHandle handle, - COGLenum pname, - COGLint *dest) +CoglShaderType +cogl_shader_get_type (CoglHandle handle) { + GLint type; CoglShader *shader; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + + _COGL_GET_CONTEXT (ctx, COGL_SHADER_TYPE_VERTEX); if (!cogl_is_shader (handle)) - return; + { + g_warning ("Non shader handle type passed to cogl_shader_get_type"); + return COGL_SHADER_TYPE_VERTEX; + } shader = _cogl_shader_pointer_from_handle (handle); - glGetObjectParameterivARB (shader->gl_handle, pname, dest); + GE (glGetObjectParameterivARB (shader->gl_handle, GL_SHADER_TYPE, &type)); + if (type == GL_VERTEX_SHADER) + return COGL_SHADER_TYPE_VERTEX; + else if (type == GL_FRAGMENT_SHADER) + return COGL_SHADER_TYPE_VERTEX; + else + { + g_warning ("Unexpected shader type 0x%08lX", (unsigned long)type); + return COGL_SHADER_TYPE_VERTEX; + } } + +gboolean +cogl_shader_is_compiled (CoglHandle handle) +{ + GLint status; + CoglShader *shader; + + _COGL_GET_CONTEXT (ctx, FALSE); + + if (!cogl_is_shader (handle)) + return FALSE; + + shader = _cogl_shader_pointer_from_handle (handle); + + GE (glGetObjectParameterivARB (shader->gl_handle, GL_COMPILE_STATUS, &status)); + if (status == GL_TRUE) + return TRUE; + else + return FALSE; +} + diff --git a/clutter/cogl/gl/cogl-texture-private.h b/clutter/cogl/gl/cogl-texture-private.h index cd60528e4..7cf6fe951 100644 --- a/clutter/cogl/gl/cogl-texture-private.h +++ b/clutter/cogl/gl/cogl-texture-private.h @@ -68,8 +68,8 @@ struct _CoglTexture GArray *slice_y_spans; GArray *slice_gl_handles; gint max_waste; - COGLenum min_filter; - COGLenum mag_filter; + CoglTextureFilter min_filter; + CoglTextureFilter mag_filter; gboolean is_foreign; GLint wrap_mode; gboolean auto_mipmap; diff --git a/clutter/cogl/gl/cogl-texture.c b/clutter/cogl/gl/cogl-texture.c index 8fb4980f5..cd02bc719 100644 --- a/clutter/cogl/gl/cogl-texture.c +++ b/clutter/cogl/gl/cogl-texture.c @@ -1247,8 +1247,8 @@ cogl_texture_new_with_size (guint width, tex->slice_gl_handles = NULL; tex->max_waste = max_waste; - tex->min_filter = CGL_NEAREST; - tex->mag_filter = CGL_NEAREST; + tex->min_filter = COGL_TEXTURE_FILTER_NEAREST; + tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST; /* Find closest GL format match */ tex->bitmap.format = @@ -1308,8 +1308,8 @@ cogl_texture_new_from_data (guint width, tex->slice_gl_handles = NULL; tex->max_waste = max_waste; - tex->min_filter = CGL_NEAREST; - tex->mag_filter = CGL_NEAREST; + tex->min_filter = COGL_TEXTURE_FILTER_NEAREST; + tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST; /* FIXME: If upload fails we should set some kind of * error flag but still return texture handle (this @@ -1365,8 +1365,8 @@ cogl_texture_new_from_bitmap (CoglHandle bmp_handle, tex->slice_gl_handles = NULL; tex->max_waste = max_waste; - tex->min_filter = CGL_NEAREST; - tex->mag_filter = CGL_NEAREST; + tex->min_filter = COGL_TEXTURE_FILTER_NEAREST; + tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST; /* FIXME: If upload fails we should set some kind of * error flag but still return texture handle if the @@ -1693,7 +1693,7 @@ cogl_texture_get_gl_texture (CoglHandle handle, return TRUE; } -COGLenum +CoglTextureFilter cogl_texture_get_min_filter (CoglHandle handle) { CoglTexture *tex; @@ -1706,7 +1706,7 @@ cogl_texture_get_min_filter (CoglHandle handle) return tex->min_filter; } -COGLenum +CoglTextureFilter cogl_texture_get_mag_filter (CoglHandle handle) { CoglTexture *tex; @@ -1721,8 +1721,8 @@ cogl_texture_get_mag_filter (CoglHandle handle) void cogl_texture_set_filters (CoglHandle handle, - COGLenum min_filter, - COGLenum mag_filter) + CoglTextureFilter min_filter, + CoglTextureFilter mag_filter) { CoglTexture *tex; GLuint gl_handle; diff --git a/clutter/cogl/gles/cogl-defines.h.in b/clutter/cogl/gles/cogl-defines.h.in index d6010509b..2a356e873 100644 --- a/clutter/cogl/gles/cogl-defines.h.in +++ b/clutter/cogl/gles/cogl-defines.h.in @@ -430,10 +430,6 @@ G_BEGIN_DECLS #define CGL_WEIGHT_ARRAY_BUFFER_BINDING_OES GL_WEIGHT_ARRAY_BUFFER_BINDING_OES #define CGL_TEXTURE_CROP_RECT_OES GL_TEXTURE_CROP_RECT_OES -typedef GLenum COGLenum; -typedef GLint COGLint; -typedef GLuint COGLuint; - /* extras */ /* YUV textures also unsupported */ @@ -441,18 +437,6 @@ typedef GLuint COGLuint; #define CGL_UNSIGNED_SHORT_8_8_REV_MESA 0 #define CGL_UNSIGNED_SHORT_8_8_MESA 0 -#ifdef GL_FRAGMENT_SHADER -#define CGL_FRAGMENT_SHADER GL_FRAGMENT_SHADER -#else -#define CGL_FRAGMENT_SHADER 0 -#endif - -#ifdef GL_VERTEX_SHADER -#define CGL_VERTEX_SHADER GL_VERTEX_SHADER -#else -#define CGL_VERTEX_SHADER 0 -#endif - #if defined(GL_OBJECT_COMPILE_STATUS) #define CGL_OBJECT_COMPILE_STATUS GL_OBJECT_COMPILE_STATUS #elif defined(GL_COMPILE_STATUS) diff --git a/clutter/cogl/gles/cogl-program.c b/clutter/cogl/gles/cogl-program.c index 317310c32..e8fc6a0f0 100644 --- a/clutter/cogl/gles/cogl-program.c +++ b/clutter/cogl/gles/cogl-program.c @@ -122,7 +122,7 @@ cogl_program_use (CoglHandle handle) ctx->gles2.settings_dirty = TRUE; } -COGLint +int cogl_program_get_uniform_location (CoglHandle handle, const gchar *uniform_name) { @@ -155,21 +155,21 @@ cogl_program_get_uniform_location (CoglHandle handle, } void -cogl_program_uniform_1f (COGLint uniform_no, +cogl_program_uniform_1f (int uniform_no, gfloat value) { cogl_program_uniform_float (uniform_no, 1, 1, &value); } void -cogl_program_uniform_1i (COGLint uniform_no, +cogl_program_uniform_1i (int uniform_no, gint value) { cogl_program_uniform_int (uniform_no, 1, 1, &value); } static void -cogl_program_uniform_x (COGLint uniform_no, +cogl_program_uniform_x (int uniform_no, gint size, gint count, CoglBoxedType type, @@ -215,7 +215,7 @@ cogl_program_uniform_x (COGLint uniform_no, } void -cogl_program_uniform_float (COGLint uniform_no, +cogl_program_uniform_float (int uniform_no, gint size, gint count, const GLfloat *value) @@ -225,7 +225,7 @@ cogl_program_uniform_float (COGLint uniform_no, } void -cogl_program_uniform_int (COGLint uniform_no, +cogl_program_uniform_int (int uniform_no, gint size, gint count, const GLint *value) @@ -235,7 +235,7 @@ cogl_program_uniform_int (COGLint uniform_no, } void -cogl_program_uniform_matrix (COGLint uniform_no, +cogl_program_uniform_matrix (int uniform_no, gint size, gint count, gboolean transpose, @@ -296,7 +296,7 @@ cogl_program_use (CoglHandle program_handle) { } -COGLint +int cogl_program_get_uniform_location (CoglHandle program_handle, const gchar *uniform_name) { @@ -304,13 +304,13 @@ cogl_program_get_uniform_location (CoglHandle program_handle, } void -cogl_program_uniform_1f (COGLint uniform_no, +cogl_program_uniform_1f (int uniform_no, gfloat value) { } void -cogl_program_uniform_float (COGLint uniform_no, +cogl_program_uniform_float (int uniform_no, gint size, gint count, const GLfloat *value) @@ -318,15 +318,15 @@ cogl_program_uniform_float (COGLint uniform_no, } void -cogl_program_uniform_int (COGLint uniform_no, +cogl_program_uniform_int (int uniform_no, gint size, gint count, - const COGLint *value) + const int *value) { } void -cogl_program_uniform_matrix (COGLint uniform_no, +cogl_program_uniform_matrix (int uniform_no, gint size, gint count, gboolean transpose, diff --git a/clutter/cogl/gles/cogl-shader.c b/clutter/cogl/gles/cogl-shader.c index d261e1a0b..ff5f0c58a 100644 --- a/clutter/cogl/gles/cogl-shader.c +++ b/clutter/cogl/gles/cogl-shader.c @@ -48,22 +48,31 @@ _cogl_shader_free (CoglShader *shader) } CoglHandle -cogl_create_shader (COGLenum shaderType) +cogl_create_shader (CoglShaderType type) { CoglShader *shader; + GLenum gl_type; - _COGL_GET_CONTEXT (ctx, 0); + if (type == COGL_SHADER_TYPE_VERTEX) + gl_type = GL_VERTEX_SHADER; + else if (type == COGL_SHADER_TYPE_FRAGMENT) + gl_type = GL_FRAGMENT_SHADER; + else + { + g_warning ("Unexpected shader type (0x%08lX) given to " + "cogl_create_shader", (unsigned long) type); + return COGL_INVALID_HANDLE; + } shader = g_slice_new (CoglShader); - shader->gl_handle = glCreateShader (shaderType); - shader->type = shaderType; + shader->gl_handle = glCreateShader (gl_type); return _cogl_shader_handle_new (shader); } void cogl_shader_source (CoglHandle handle, - const gchar *source) + const char *source) { CoglShader *shader; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -92,11 +101,11 @@ cogl_shader_compile (CoglHandle handle) void cogl_shader_get_info_log (CoglHandle handle, - guint size, - gchar *buffer) + size_t size, + char *buffer) { CoglShader *shader; - COGLint len = 0; + int len = 0; _COGL_GET_CONTEXT (ctx, NO_RETVAL); if (!cogl_is_shader (handle)) @@ -108,20 +117,48 @@ cogl_shader_get_info_log (CoglHandle handle, buffer[len] = '\0'; } -void -cogl_shader_get_parameteriv (CoglHandle handle, - COGLenum pname, - COGLint *dest) +CoglShaderType +cogl_shader_get_type (CoglHandle handle) { + GLint type; CoglShader *shader; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); if (!cogl_is_shader (handle)) - return; + { + g_warning ("Non shader handle type passed to cogl_shader_get_type"); + return COGL_SHADER_TYPE_VERTEX; + } shader = _cogl_shader_pointer_from_handle (handle); - glGetShaderiv (shader->gl_handle, pname, dest); + GE (glGetShaderiv (shader->gl_handle, GL_SHADER_TYPE, &type)); + if (type == GL_VERTEX_SHADER) + return COGL_SHADER_TYPE_VERTEX; + else if (type == GL_FRAGMENT_SHADER) + return COGL_SHADER_TYPE_VERTEX; + else + { + g_warning ("Unexpected shader type 0x%08lX", (unsigned long)type); + return COGL_SHADER_TYPE_VERTEX; + } +} + +gboolean +cogl_shader_is_compiled (CoglHandle handle) +{ + GLint status; + CoglShader *shader; + + if (!cogl_is_shader (handle)) + return FALSE; + + shader = _cogl_shader_pointer_from_handle (handle); + + GE (glGetShaderiv (shader->gl_handle, GL_COMPILE_STATUS, &status)); + if (status == GL_TRUE) + return TRUE; + else + return FALSE; } #else /* HAVE_COGL_GLES2 */ @@ -129,7 +166,7 @@ cogl_shader_get_parameteriv (CoglHandle handle, /* No support on regular OpenGL 1.1 */ CoglHandle -cogl_create_shader (COGLenum shaderType) +cogl_create_shader (CoglShaderType type) { return COGL_INVALID_HANDLE; } @@ -153,7 +190,7 @@ cogl_shader_unref (CoglHandle handle) void cogl_shader_source (CoglHandle shader, - const gchar *source) + const char *source) { } @@ -164,16 +201,21 @@ cogl_shader_compile (CoglHandle shader_handle) void cogl_shader_get_info_log (CoglHandle handle, - guint size, - gchar *buffer) + size_t size, + char *buffer) { } -void -cogl_shader_get_parameteriv (CoglHandle handle, - COGLenum pname, - COGLint *dest) +CoglShaderType +cogl_shader_get_type (CoglHandle handle) { + return COGL_SHADER_TYPE_VERTEX; +} + +gboolean +cogl_shader_is_compiled (CoglHandle handle) +{ + return FALSE; } #endif /* HAVE_COGL_GLES2 */ diff --git a/clutter/cogl/gles/cogl-texture-private.h b/clutter/cogl/gles/cogl-texture-private.h index cd60528e4..7cf6fe951 100644 --- a/clutter/cogl/gles/cogl-texture-private.h +++ b/clutter/cogl/gles/cogl-texture-private.h @@ -68,8 +68,8 @@ struct _CoglTexture GArray *slice_y_spans; GArray *slice_gl_handles; gint max_waste; - COGLenum min_filter; - COGLenum mag_filter; + CoglTextureFilter min_filter; + CoglTextureFilter mag_filter; gboolean is_foreign; GLint wrap_mode; gboolean auto_mipmap; diff --git a/clutter/cogl/gles/cogl-texture.c b/clutter/cogl/gles/cogl-texture.c index 0954798d9..ce5d4fe26 100644 --- a/clutter/cogl/gles/cogl-texture.c +++ b/clutter/cogl/gles/cogl-texture.c @@ -1778,7 +1778,7 @@ cogl_texture_get_gl_texture (CoglHandle handle, return TRUE; } -COGLenum +CoglTextureFilter cogl_texture_get_min_filter (CoglHandle handle) { CoglTexture *tex; @@ -1791,7 +1791,7 @@ cogl_texture_get_min_filter (CoglHandle handle) return tex->min_filter; } -COGLenum +CoglTextureFilter cogl_texture_get_mag_filter (CoglHandle handle) { CoglTexture *tex; @@ -1806,8 +1806,8 @@ cogl_texture_get_mag_filter (CoglHandle handle) void cogl_texture_set_filters (CoglHandle handle, - COGLenum min_filter, - COGLenum mag_filter) + CoglTextureFilter min_filter, + CoglTextureFilter mag_filter) { CoglTexture *tex; GLuint gl_handle; diff --git a/clutter/glx/clutter-glx-texture-pixmap.c b/clutter/glx/clutter-glx-texture-pixmap.c index 4a41070b5..c2f5aadcc 100644 --- a/clutter/glx/clutter-glx-texture-pixmap.c +++ b/clutter/glx/clutter-glx-texture-pixmap.c @@ -25,7 +25,7 @@ * Boston, MA 02111-1307, USA. */ -/* TODO: +/* TODO: * - Automagically handle named pixmaps, and window resizes (i.e * essentially handle window id's being passed in) ? */ @@ -94,8 +94,6 @@ static RectangleState _rectangle_state = CLUTTER_GLX_RECTANGLE_ALLOW; struct _ClutterGLXTexturePixmapPrivate { - COGLenum target_type; - guint texture_id; GLXPixmap glx_pixmap; gboolean use_fallback; @@ -107,14 +105,14 @@ struct _ClutterGLXTexturePixmapPrivate gboolean using_rectangle; }; -static void +static void clutter_glx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture, gint x, gint y, gint width, gint height); -static void +static void clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *tex); static ClutterX11TexturePixmapClass *parent_class = NULL; @@ -137,12 +135,12 @@ texture_bind (ClutterGLXTexturePixmap *tex) /* FIXME: fire off an error here? */ glBindTexture (target, handle); - if (clutter_texture_get_filter_quality (CLUTTER_TEXTURE (tex)) + if (clutter_texture_get_filter_quality (CLUTTER_TEXTURE (tex)) == CLUTTER_TEXTURE_QUALITY_HIGH && tex->priv->can_mipmap) { - cogl_texture_set_filters (cogl_tex, - CGL_LINEAR_MIPMAP_LINEAR, - CGL_LINEAR); + cogl_texture_set_filters (cogl_tex, + COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR, + COGL_TEXTURE_FILTER_LINEAR); } return TRUE; @@ -157,13 +155,13 @@ on_glx_texture_pixmap_pre_paint (ClutterGLXTexturePixmap *texture, GLuint handle = 0; GLenum target = 0; CoglHandle cogl_tex; - cogl_tex = clutter_texture_get_cogl_texture + cogl_tex = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE(texture)); texture_bind (texture); cogl_texture_get_gl_texture (cogl_tex, &handle, &target); - + _gl_generate_mipmap (target); texture->priv->mipmap_generate_queued = 0; @@ -408,11 +406,11 @@ clutter_glx_texture_pixmap_realize (ClutterActor *actor) "pixmap-width", &pixmap_width, "pixmap-height", &pixmap_height, NULL); - + if (!pixmap) return; - if (!create_cogl_texture (CLUTTER_TEXTURE (actor), + if (!create_cogl_texture (CLUTTER_TEXTURE (actor), pixmap_width, pixmap_height)) { CLUTTER_NOTE (TEXTURE, "Unable to create a valid pixmap"); @@ -460,7 +458,7 @@ clutter_glx_texture_pixmap_unrealize (ClutterActor *actor) priv->bound = FALSE; } - + CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); } @@ -739,8 +737,8 @@ clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *texture) if (glx_pixmap != None) { priv->glx_pixmap = glx_pixmap; - - create_cogl_texture (CLUTTER_TEXTURE (texture), + + create_cogl_texture (CLUTTER_TEXTURE (texture), pixmap_width, pixmap_height); CLUTTER_NOTE (TEXTURE, "Created GLXPixmap"); @@ -762,7 +760,7 @@ clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *texture) priv->glx_pixmap = None; /* Some fucky logic here - we've fallen back and need to make sure - * we realize here.. + * we realize here.. */ clutter_actor_realize (CLUTTER_ACTOR (texture)); } @@ -800,22 +798,22 @@ clutter_glx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture, if (priv->glx_pixmap == None) return; - + if (texture_bind (CLUTTER_GLX_TEXTURE_PIXMAP(texture))) { CLUTTER_NOTE (TEXTURE, "Really updating via GLX"); clutter_x11_trap_x_errors (); - + (_gl_bind_tex_image) (dpy, priv->glx_pixmap, GLX_FRONT_LEFT_EXT, NULL); - + XSync (clutter_x11_get_default_display(), FALSE); - + /* Note above fires X error for non name pixmaps - but - * things still seem to work - i.e pixmap updated + * things still seem to work - i.e pixmap updated */ if (clutter_x11_untrap_x_errors ()) CLUTTER_NOTE (TEXTURE, "Update bind_tex_image failed"); @@ -829,7 +827,7 @@ clutter_glx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture, { /* FIXME: It may make more sense to set a flag here and only * generate the mipmap on a pre paint.. compressing need - * to call generate mipmap + * to call generate mipmap * May break clones however.. */ priv->mipmap_generate_queued++; @@ -870,7 +868,7 @@ clutter_glx_texture_pixmap_class_init (ClutterGLXTexturePixmapClass *klass) * clutter_glx_texture_pixmap_using_extension: * @texture: A #ClutterGLXTexturePixmap * - * Return value: A boolean indicating if the texture is using the + * Return value: A boolean indicating if the texture is using the * GLX_EXT_texture_from_pixmap OpenGL extension or falling back to * slower software mechanism. * @@ -883,8 +881,8 @@ clutter_glx_texture_pixmap_using_extension (ClutterGLXTexturePixmap *texture) priv = CLUTTER_GLX_TEXTURE_PIXMAP (texture)->priv; - return (_have_tex_from_pixmap_ext && !priv->use_fallback); - /* Assume NPOT TFP's are supported even if regular NPOT isn't advertised + return (_have_tex_from_pixmap_ext && !priv->use_fallback); + /* Assume NPOT TFP's are supported even if regular NPOT isn't advertised * but tfp is. Seemingly some Intel drivers do this ? */ /* && clutter_feature_available (COGL_FEATURE_TEXTURE_NPOT)); */ diff --git a/clutter/pango/cogl-pango-glyph-cache.c b/clutter/pango/cogl-pango-glyph-cache.c index 04e7805e4..892255623 100644 --- a/clutter/pango/cogl-pango-glyph-cache.c +++ b/clutter/pango/cogl-pango-glyph-cache.c @@ -311,12 +311,12 @@ cogl_pango_glyph_cache_set (CoglPangoGlyphCache *cache, if (cache->use_mipmapping) cogl_texture_set_filters (texture->texture, - CGL_LINEAR_MIPMAP_LINEAR, - CGL_LINEAR); + COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR, + COGL_TEXTURE_FILTER_LINEAR); else cogl_texture_set_filters (texture->texture, - CGL_LINEAR, - CGL_LINEAR); + COGL_TEXTURE_FILTER_LINEAR, + COGL_TEXTURE_FILTER_LINEAR); } band = g_slice_new (CoglPangoGlyphCacheBand); diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt index ff8df1cbc..3032a6863 100644 --- a/doc/reference/cogl/cogl-sections.txt +++ b/doc/reference/cogl/cogl-sections.txt @@ -149,7 +149,8 @@ cogl_is_shader cogl_shader_source cogl_shader_compile cogl_shader_get_info_log -cogl_shader_get_parameteriv +cogl_shader_get_type +cogl_shader_is_compiled cogl_create_program cogl_program_ref diff --git a/tests/interactive/test-cogl-tex-polygon.c b/tests/interactive/test-cogl-tex-polygon.c index c288815a3..0132802a4 100644 --- a/tests/interactive/test-cogl-tex-polygon.c +++ b/tests/interactive/test-cogl-tex-polygon.c @@ -9,7 +9,7 @@ *--------------------------------------------------*/ G_BEGIN_DECLS - + #define TEST_TYPE_COGLBOX test_coglbox_get_type() #define TEST_COGLBOX(obj) \ @@ -44,7 +44,7 @@ struct _TestCoglbox TestCoglboxPrivate *priv; }; -struct _TestCoglboxClass +struct _TestCoglboxClass { ClutterActorClass parent_class; @@ -91,7 +91,7 @@ test_coglbox_fade_texture (CoglHandle tex_id, { CoglTextureVertex vertices[4]; int i; - + vertices[0].x = x1; vertices[0].y = y1; vertices[0].z = 0; @@ -142,7 +142,7 @@ test_coglbox_triangle_texture (CoglHandle tex_id, CoglTextureVertex vertices[3]; int tex_width = cogl_texture_get_width (tex_id); int tex_height = cogl_texture_get_height (tex_id); - + vertices[0].x = x + tx1 * tex_width; vertices[0].y = y + ty1 * tex_height; vertices[0].z = 0; @@ -176,9 +176,11 @@ test_coglbox_paint (ClutterActor *self) cogl_texture_set_filters (tex_handle, priv->use_linear_filtering - ? CGL_LINEAR : CGL_NEAREST, + ? COGL_TEXTURE_FILTER_LINEAR : + COGL_TEXTURE_FILTER_NEAREST, priv->use_linear_filtering - ? CGL_LINEAR : CGL_NEAREST); + ? COGL_TEXTURE_FILTER_LINEAR : + COGL_TEXTURE_FILTER_NEAREST); cogl_push_matrix (); cogl_translate (tex_width / 2, 0, 0); @@ -227,11 +229,11 @@ static void test_coglbox_dispose (GObject *object) { TestCoglboxPrivate *priv; - + priv = TEST_COGLBOX_GET_PRIVATE (object); cogl_handle_unref (priv->not_sliced_tex); cogl_handle_unref (priv->sliced_tex); - + G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object); } @@ -244,7 +246,7 @@ test_coglbox_init (TestCoglbox *self) priv->use_linear_filtering = FALSE; priv->use_sliced = FALSE; - + priv->sliced_tex = cogl_texture_new_from_file ("redhand.png", 10, COGL_TEXTURE_NONE, @@ -286,9 +288,9 @@ test_coglbox_class_init (TestCoglboxClass *klass) ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); gobject_class->finalize = test_coglbox_finalize; - gobject_class->dispose = test_coglbox_dispose; + gobject_class->dispose = test_coglbox_dispose; actor_class->paint = test_coglbox_paint; - + g_type_class_add_private (gobject_class, sizeof (TestCoglboxPrivate)); } @@ -304,7 +306,7 @@ frame_cb (ClutterTimeline *timeline, gpointer data) { TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data); - + priv->frame = frame_num; clutter_actor_queue_redraw (CLUTTER_ACTOR (data)); } @@ -330,11 +332,11 @@ make_toggle (const char *label_text, gboolean *toggle_val) ClutterActor *group = clutter_group_new (); ClutterActor *label = clutter_text_new_with_text ("Sans 14", label_text); ClutterActor *button = clutter_text_new_with_text ("Sans 14", ""); - + clutter_actor_set_reactive (button, TRUE); update_toggle_text (CLUTTER_TEXT (button), *toggle_val); - + clutter_actor_set_position (button, clutter_actor_get_width (label) + 10, 0); clutter_container_add (CLUTTER_CONTAINER (group), label, button, NULL); @@ -354,19 +356,19 @@ test_cogl_tex_polygon_main (int argc, char *argv[]) ClutterActor *note; ClutterTimeline *timeline; ClutterColor blue = { 0x30, 0x30, 0xff, 0xff }; - + clutter_init (&argc, &argv); - + /* Stage */ stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &blue); clutter_actor_set_size (stage, 640, 480); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test"); - + /* Cogl Box */ coglbox = test_coglbox_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox); - + /* Timeline for animation */ timeline = clutter_timeline_new (360, 60); /* num frames, fps */ g_object_set (timeline, "loop", TRUE, NULL); /* have it loop */ @@ -398,10 +400,10 @@ test_cogl_tex_polygon_main (int argc, char *argv[]) filtering_toggle, note, NULL); - + clutter_actor_show (stage); - + clutter_main (); - + return 0; } diff --git a/tests/interactive/test-cogl-tex-tile.c b/tests/interactive/test-cogl-tex-tile.c index 9a40ae66c..1402d2e28 100644 --- a/tests/interactive/test-cogl-tex-tile.c +++ b/tests/interactive/test-cogl-tex-tile.c @@ -10,7 +10,7 @@ *--------------------------------------------------*/ G_BEGIN_DECLS - + #define TEST_TYPE_COGLBOX test_coglbox_get_type() #define TEST_COGLBOX(obj) \ @@ -45,7 +45,7 @@ struct _TestCoglbox TestCoglboxPrivate *priv; }; -struct _TestCoglboxClass +struct _TestCoglboxClass { ClutterActorClass parent_class; @@ -89,34 +89,34 @@ test_coglbox_paint (ClutterActor *self) sin_frame = sinf ((float) priv->frame); cos_frame = cosf ((float) priv->frame); - + pingpong_frame = (priv->frame <= 180 ? priv->frame : 360 - priv->frame); frac_frame = (float) pingpong_frame / 180.0; frac_frame += 0.5; frac_frame *= 2; - + for (t=0; t<4; t+=2) { texcoords[t] += cos_frame; texcoords[t+1] += sin_frame; - + texcoords[t] = (texcoords[t] * frac_frame); texcoords[t+1] = (texcoords[t+1] * frac_frame); } - + priv = TEST_COGLBOX_GET_PRIVATE (self); - + cogl_push_matrix (); cogl_set_source_color4ub (0x66, 0x66, 0xdd, 0xff); cogl_rectangle (0, 0, 400, 400); - + cogl_translate (100, 100, 0); cogl_set_source_texture (priv->cogl_tex_id); cogl_rectangle_with_texture_coords (0, 0, 200, 213, texcoords[0], texcoords[1], texcoords[2], texcoords[3]); - + cogl_pop_matrix(); } @@ -130,10 +130,10 @@ static void test_coglbox_dispose (GObject *object) { TestCoglboxPrivate *priv; - + priv = TEST_COGLBOX_GET_PRIVATE (object); cogl_handle_unref (priv->cogl_tex_id); - + G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object); } @@ -142,14 +142,15 @@ test_coglbox_init (TestCoglbox *self) { TestCoglboxPrivate *priv; self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self); - + priv->cogl_tex_id = cogl_texture_new_from_file ("redhand.png", 0, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_ANY, NULL); - + cogl_texture_set_filters (priv->cogl_tex_id, - CGL_LINEAR, CGL_LINEAR); + COGL_TEXTURE_FILTER_LINEAR, + COGL_TEXTURE_FILTER_LINEAR); } static void @@ -159,9 +160,9 @@ test_coglbox_class_init (TestCoglboxClass *klass) ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); gobject_class->finalize = test_coglbox_finalize; - gobject_class->dispose = test_coglbox_dispose; + gobject_class->dispose = test_coglbox_dispose; actor_class->paint = test_coglbox_paint; - + g_type_class_add_private (gobject_class, sizeof (TestCoglboxPrivate)); } @@ -177,7 +178,7 @@ frame_cb (ClutterTimeline *timeline, gpointer data) { TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data); - + priv->frame = frame_num; clutter_actor_queue_redraw (CLUTTER_ACTOR (data)); } @@ -188,27 +189,27 @@ test_cogl_tex_tile_main (int argc, char *argv[]) ClutterActor *stage; ClutterActor *coglbox; ClutterTimeline *timeline; - + clutter_init(&argc, &argv); - + /* Stage */ stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test"); - + /* Cogl Box */ coglbox = test_coglbox_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox); - + /* Timeline for animation */ timeline = clutter_timeline_new (360, 60); /* num frames, fps */ g_object_set (timeline, "loop", TRUE, NULL); /* have it loop */ g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), coglbox); clutter_timeline_start (timeline); - + clutter_actor_show_all (stage); - + clutter_main (); - + return 0; } From e9b863eba28564dd0b19f982610e5afe93ac17eb Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Tue, 12 May 2009 15:36:16 +0100 Subject: [PATCH 29/66] Don't clear the stencil buffer before painting and picking The stencil buffer is always cleared the first time a clip is used that needs it and the stencil test is disabled otherwise so there is no need to clear before a paint. --- clutter/clutter-main.c | 3 +-- clutter/clutter-stage.c | 3 +-- clutter/clutter-texture.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index aec1dd2aa..af46230fd 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -374,8 +374,7 @@ _clutter_do_pick (ClutterStage *stage, cogl_disable_fog (); cogl_clear (&white, COGL_BUFFER_BIT_COLOR | - COGL_BUFFER_BIT_DEPTH | - COGL_BUFFER_BIT_STENCIL); + COGL_BUFFER_BIT_DEPTH); /* Disable dithering (if any) when doing the painting in pick mode */ dither_was_on = glIsEnabled (GL_DITHER); diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 0833dee63..a4c0fcc1f 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -224,8 +224,7 @@ clutter_stage_paint (ClutterActor *self) priv->color.alpha); cogl_clear (&stage_color, COGL_BUFFER_BIT_COLOR | - COGL_BUFFER_BIT_DEPTH | - COGL_BUFFER_BIT_STENCIL); + COGL_BUFFER_BIT_DEPTH); if (priv->use_fog) { diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index b44d57d8a..cce419482 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -595,8 +595,7 @@ clutter_texture_paint (ClutterActor *self) cogl_color_set_from_4ub (&transparent_col, 0, 0, 0, 0); cogl_clear (&transparent_col, COGL_BUFFER_BIT_COLOR | - COGL_BUFFER_BIT_DEPTH | - COGL_BUFFER_BIT_STENCIL); + COGL_BUFFER_BIT_DEPTH); cogl_disable_fog (); /* Clear the clipping stack so that if the FBO actor is being From e80fcbc298812b7fc333cec34049a4ee806f469a Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Fri, 8 May 2009 16:32:01 +0100 Subject: [PATCH 30/66] [cogl-clip-stack] Support pushing rectangles onto the stack using window coords Previously clipping could only be specified in object coordinates, now rectangles can also be pushed in window coordinates. Internally rectangles pushed this way are intersected and then clipped using scissoring. We also transparently try to convert rectangles pushed in object coordinates into window coordinates as we anticipate the scissoring path will be faster then the clip planes and undoubtably it will be faster than using the stencil buffer. --- clutter/cogl/cogl.h.in | 21 ++++ clutter/cogl/common/cogl-clip-stack.c | 165 ++++++++++++++++++++++++-- clutter/cogl/common/cogl.c | 2 + 3 files changed, 180 insertions(+), 8 deletions(-) diff --git a/clutter/cogl/cogl.h.in b/clutter/cogl/cogl.h.in index 594fc77ca..b3b0584b0 100644 --- a/clutter/cogl/cogl.h.in +++ b/clutter/cogl/cogl.h.in @@ -490,6 +490,27 @@ void cogl_set_source_texture (CoglHandle texture_handle); * intersected with the previous region. */ +/** + * cogl_clip_push_window_rect: + * @x_offset: left edge of the clip rectangle in window coordinates + * @y_offset: top edge of the clip rectangle in window coordinates + * @width: width of the clip rectangle + * @height: height of the clip rectangle + * + * Specifies a rectangular clipping area for all subsequent drawing + * operations. Any drawing commands that extend outside the rectangle + * will be clipped so that only the portion inside the rectangle will + * be displayed. The rectangle dimensions are not transformed by the + * current model-view matrix. + * + * The rectangle is intersected with the current clip region. To undo + * the effect of this function, call cogl_clip_pop(). + */ +void cogl_clip_push_window_rect (float x_offset, + float y_offset, + float width, + float height); + /** * cogl_clip_push: * @x_offset: left edge of the clip rectangle diff --git a/clutter/cogl/common/cogl-clip-stack.c b/clutter/cogl/common/cogl-clip-stack.c index 7f3dcdfc0..896fe9bae 100644 --- a/clutter/cogl/common/cogl-clip-stack.c +++ b/clutter/cogl/common/cogl-clip-stack.c @@ -26,10 +26,14 @@ #endif #include + +#include + #include "cogl.h" #include "cogl-clip-stack.h" #include "cogl-primitives.h" #include "cogl-context.h" +#include "cogl-internal.h" /* These are defined in the particular backend (float in GL vs fixed in GL ES) */ @@ -55,11 +59,13 @@ void _cogl_set_matrix (const CoglMatrix *matrix); typedef struct _CoglClipStack CoglClipStack; typedef struct _CoglClipStackEntryRect CoglClipStackEntryRect; +typedef struct _CoglClipStackEntryWindowRect CoglClipStackEntryWindowRect; typedef struct _CoglClipStackEntryPath CoglClipStackEntryPath; typedef enum { COGL_CLIP_STACK_RECT, + COGL_CLIP_STACK_WINDOW_RECT, COGL_CLIP_STACK_PATH } CoglClipStackEntryType; @@ -70,7 +76,7 @@ struct _CoglClipStack struct _CoglClipStackEntryRect { - CoglClipStackEntryType type; + CoglClipStackEntryType type; /* The rectangle for this clip */ float x_offset; @@ -82,20 +88,126 @@ struct _CoglClipStackEntryRect CoglMatrix matrix; }; +struct _CoglClipStackEntryWindowRect +{ + CoglClipStackEntryType type; + + /* The window space rectangle for this clip */ + float x0; + float y0; + float x1; + float y1; +}; + struct _CoglClipStackEntryPath { - CoglClipStackEntryType type; + CoglClipStackEntryType type; /* The matrix that was current when the clip was set */ - CoglMatrix matrix; + CoglMatrix matrix; floatVec2 path_nodes_min; floatVec2 path_nodes_max; - guint path_size; - CoglPathNode path[1]; + guint path_size; + CoglPathNode path[1]; }; +void +cogl_clip_push_window_rect (float x_offset, + float y_offset, + float width, + float height) +{ + CoglClipStackEntryWindowRect *entry; + CoglClipStack *stack; + float v[4]; + + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + + stack = (CoglClipStack *) ctx->clip.stacks->data; + + cogl_get_viewport (v); + + entry = g_slice_new (CoglClipStackEntryWindowRect); + + /* We convert from coords with (0,0) at top left to coords + * with (0,0) at bottom left. */ + entry->type = COGL_CLIP_STACK_WINDOW_RECT; + entry->x0 = x_offset; + entry->y0 = v[3] - y_offset - height; + entry->x1 = x_offset + width; + entry->y1 = v[3] - y_offset; + + /* Store it in the stack */ + stack->stack_top = g_list_prepend (stack->stack_top, entry); + + ctx->clip.stack_dirty = TRUE; +} + +/* Scale from OpenGL <-1,1> coordinates system to window coordinates + * <0,window-size> with (0,0) being top left. */ +#define VIEWPORT_SCALE_X(x, w, width, origin) \ + ((((((x) / (w)) + 1.0) / 2) * (width)) + (origin)) +#define VIEWPORT_SCALE_Y(y, w, height, origin) \ + ((height) - (((((y) / (w)) + 1.0) / 2) * (height)) + (origin)) + +static void +transform_point (CoglMatrix *matrix_mv, + CoglMatrix *matrix_p, + float *viewport, + float *x, + float *y) +{ + float z = 0; + float w = 1; + + /* Apply the model view matrix */ + cogl_matrix_transform_point (matrix_mv, x, y, &z, &w); + + /* Apply the projection matrix */ + cogl_matrix_transform_point (matrix_p, x, y, &z, &w); + /* Apply viewport transform */ + *x = VIEWPORT_SCALE_X (*x, w, viewport[2], viewport[0]); + *y = VIEWPORT_SCALE_Y (*y, w, viewport[3], viewport[1]); +} + +#undef VIEWPORT_SCALE_X +#undef VIEWPORT_SCALE_Y + +/* Try to push a rectangle given in object coordinates as a rectangle in window + * coordinates instead of object coordinates */ +gboolean +try_pushing_rect_as_window_rect (float x_offset, + float y_offset, + float width, + float height) +{ + CoglMatrix matrix; + CoglMatrix matrix_p; + float v[4]; + float _x0 = x_offset; + float _y0 = y_offset; + float _x1 = x_offset + width; + float _y1 = y_offset + height; + + cogl_get_modelview_matrix (&matrix); + + if (matrix.xy != 0 || matrix.xz != 0 || + matrix.yx != 0 || matrix.yz != 0 || + matrix.zx != 0 || matrix.zy != 0) + return FALSE; + + cogl_get_projection_matrix (&matrix_p); + cogl_get_viewport (v); + + transform_point (&matrix, &matrix_p, v, &_x0, &_y0); + transform_point (&matrix, &matrix_p, v, &_x1, &_y1); + + cogl_clip_push_window_rect (_x0, _y0, _x1 - _x0, _y1 - _y0); + return TRUE; +} + void cogl_clip_push (float x_offset, float y_offset, @@ -107,6 +219,11 @@ cogl_clip_push (float x_offset, _COGL_GET_CONTEXT (ctx, NO_RETVAL); + /* Try and catch window space rectangles so we can redirect to + * cogl_clip_push_window_rect which will use scissoring. */ + if (try_pushing_rect_as_window_rect (x_offset, y_offset, width, height)) + return; + stack = (CoglClipStack *) ctx->clip.stacks->data; entry = g_slice_new (CoglClipStackEntryRect); @@ -167,6 +284,7 @@ cogl_clip_pop (void) { gpointer entry; CoglClipStack *stack; + CoglClipStackEntryType type; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -175,10 +293,13 @@ cogl_clip_pop (void) g_return_if_fail (stack->stack_top != NULL); entry = stack->stack_top->data; + type = *(CoglClipStackEntryType *) entry; /* Remove the top entry from the stack */ - if (*(CoglClipStackEntryType *) entry == COGL_CLIP_STACK_RECT) + if (type == COGL_CLIP_STACK_RECT) g_slice_free (CoglClipStackEntryRect, entry); + else if (type == COGL_CLIP_STACK_WINDOW_RECT) + g_slice_free (CoglClipStackEntryWindowRect, entry); else g_free (entry); @@ -196,6 +317,10 @@ _cogl_clip_stack_rebuild (void) gboolean using_stencil_buffer = FALSE; GList *node; CoglClipStack *stack; + guint scissor_x0 = 0; + guint scissor_y0 = 0; + guint scissor_x1 = G_MAXUINT; + guint scissor_y1 = G_MAXUINT; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -206,6 +331,7 @@ _cogl_clip_stack_rebuild (void) _cogl_disable_clip_planes (); _cogl_disable_stencil_buffer (); + GE (glDisable (GL_SCISSOR_TEST)); /* If the stack is empty then there's nothing else to do */ if (stack->stack_top == NULL) @@ -218,8 +344,9 @@ _cogl_clip_stack_rebuild (void) for (; node; node = node->prev) { gpointer entry = node->data; + CoglClipStackEntryType type = *(CoglClipStackEntryType *) entry; - if (*(CoglClipStackEntryType *) entry == COGL_CLIP_STACK_PATH) + if (type == COGL_CLIP_STACK_PATH) { CoglClipStackEntryPath *path = (CoglClipStackEntryPath *) entry; @@ -239,7 +366,7 @@ _cogl_clip_stack_rebuild (void) /* We can't use clip planes any more */ has_clip_planes = FALSE; } - else + else if (type == COGL_CLIP_STACK_RECT) { CoglClipStackEntryRect *rect = (CoglClipStackEntryRect *) entry; @@ -270,6 +397,16 @@ _cogl_clip_stack_rebuild (void) cogl_pop_matrix (); } + else + { + /* Get the intersection of all window space rectangles in the clip + * stack */ + CoglClipStackEntryWindowRect *window_rect = entry; + scissor_x0 = MAX (scissor_x0, window_rect->x0); + scissor_y0 = MAX (scissor_y0, window_rect->y0); + scissor_x1 = MIN (scissor_x1, window_rect->x1); + scissor_y1 = MIN (scissor_y1, window_rect->y1); + } } /* Enabling clip planes is delayed to now so that they won't affect @@ -277,6 +414,18 @@ _cogl_clip_stack_rebuild (void) if (using_clip_planes) _cogl_enable_clip_planes (); + if (scissor_x0 >= scissor_x1 || scissor_y0 >= scissor_y1) + scissor_x0 = scissor_y0 = scissor_x1 = scissor_y1 = 0; + + if (!(scissor_x0 == 0 && scissor_y0 == 0 && + scissor_x1 == G_MAXUINT && scissor_y1 == G_MAXUINT)) + { + GE (glEnable (GL_SCISSOR_TEST)); + GE (glScissor (scissor_x0, scissor_y0, + scissor_x1 - scissor_x0, + scissor_y1 - scissor_y0)); + } + ctx->clip.stencil_used = using_stencil_buffer; } diff --git a/clutter/cogl/common/cogl.c b/clutter/cogl/common/cogl.c index 3e1b33bbf..e6341a8ac 100644 --- a/clutter/cogl/common/cogl.c +++ b/clutter/cogl/common/cogl.c @@ -89,6 +89,8 @@ cogl_clear (const CoglColor *color, gulong buffers) fprintf(stderr, "\n ============== Paint Start ================ \n"); #endif + cogl_clip_ensure (); + if (buffers & COGL_BUFFER_BIT_COLOR) { GE( glClearColor (cogl_color_get_red_float (color), From d1fa83039d12f8501075d3e9f7fd17a42cbdd7c8 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 12 May 2009 01:02:25 +0100 Subject: [PATCH 31/66] [picking] Use cogl_clip_push_window_rect to greatly reduce the cost of picking. cogl_clip_push_window_rect is implemented using GPU scissoring which allows the GPU to cull anything that falls outside a given rectangle. Since in the case of picking we only ever care about a single pixel we can get the GPU to ignore all geometry that doesn't intersect that pixel and only rasterize for one pixel. --- clutter/clutter-main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index af46230fd..dd91a8c5e 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -370,6 +370,7 @@ _clutter_do_pick (ClutterStage *stage, /* needed for when a context switch happens */ _clutter_stage_maybe_setup_viewport (stage); + cogl_clip_push_window_rect (x, y, 1, 1); cogl_color_set_from_4ub (&white, 255, 255, 255, 255); cogl_disable_fog (); cogl_clear (&white, @@ -387,6 +388,7 @@ _clutter_do_pick (ClutterStage *stage, context->pick_mode = mode; clutter_actor_paint (CLUTTER_ACTOR (stage)); context->pick_mode = CLUTTER_PICK_NONE; + cogl_clip_pop (); /* Calls should work under both GL and GLES, note GLES needs RGBA */ glGetIntegerv(GL_VIEWPORT, viewport); From 62e2f276041365853838122b3a7326a27c7c733e Mon Sep 17 00:00:00 2001 From: Chris Lord Date: Tue, 12 May 2009 16:17:51 +0100 Subject: [PATCH 32/66] [tests/micro-bench] Add a picking performance test Approved by Robert Bragg. --- tests/micro-bench/Makefile.am | 4 +- tests/micro-bench/test-picking.c | 128 +++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 tests/micro-bench/test-picking.c diff --git a/tests/micro-bench/Makefile.am b/tests/micro-bench/Makefile.am index e58bae620..b20678fb9 100644 --- a/tests/micro-bench/Makefile.am +++ b/tests/micro-bench/Makefile.am @@ -1,5 +1,6 @@ noinst_PROGRAMS = \ - test-text + test-text \ + test-picking INCLUDES = -I$(top_srcdir)/ -I$(top_srcdir)/clutter -I$(top_builddir)/clutter LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.la @@ -10,4 +11,5 @@ AM_CFLAGS = \ AM_LDFLAGS = $(CLUTTER_LIBS) test_text_SOURCES = test-text.c +test_picking_SOURCES = test-picking.c diff --git a/tests/micro-bench/test-picking.c b/tests/micro-bench/test-picking.c new file mode 100644 index 000000000..563616dbe --- /dev/null +++ b/tests/micro-bench/test-picking.c @@ -0,0 +1,128 @@ + +#include +#include +#include + +#define N_ACTORS 100 +#define N_EVENTS 5 + +static gboolean +motion_event_cb (ClutterActor *actor, ClutterEvent *event, gpointer user_data) +{ + return FALSE; +} + +static void +do_events (ClutterActor *stage) +{ + glong i; + static gdouble angle = 0; + ClutterEvent event; + + for (i = 0; i < N_EVENTS; i++) + { + angle += (2.0 * M_PI) / (gdouble)N_ACTORS; + while (angle > M_PI * 2.0) + angle -= M_PI * 2.0; + + event.type = CLUTTER_MOTION; + event.any.stage = CLUTTER_STAGE (stage); + event.any.time = CLUTTER_CURRENT_TIME; + event.motion.flags = 0; + event.motion.source = NULL; + event.motion.x = (gint)(256.0 + 206.0 * cos (angle)); + event.motion.y = (gint)(256.0 + 206.0 * sin (angle)); + event.motion.modifier_state = 0; + event.motion.axes = NULL; + event.motion.device = NULL; + + clutter_event_put (&event); + } +} + +static gboolean +fps_cb (gpointer data) +{ + ClutterActor *stage = CLUTTER_ACTOR (data); + + static GTimer *timer = NULL; + static gint fps = 0; + + if (!timer) + { + timer = g_timer_new (); + g_timer_start (timer); + } + + if (g_timer_elapsed (timer, NULL) >= 1) + { + printf ("fps: %d\n", fps); + g_timer_start (timer); + fps = 0; + } + + clutter_actor_paint (stage); + do_events (stage); + ++fps; + + return TRUE; +} + +int +main (int argc, char **argv) +{ + glong i; + gdouble angle; + const ClutterColor black = { 0x00, 0x00, 0x00, 0xff }; + ClutterColor color = { 0x00, 0x00, 0x00, 0xff }; + + ClutterActor *stage, *rect; + + clutter_init (&argc, &argv); + + stage = clutter_stage_get_default (); + clutter_actor_set_size (stage, 512, 512); + clutter_stage_set_color (CLUTTER_STAGE (stage), &black); + + printf ("Picking performance test with " + "%d actors and %d events per frame\n", + N_ACTORS, + N_EVENTS); + + for (i = N_ACTORS-1; i >= 0; i--) + { + angle = ((2.0 * M_PI) / (gdouble)N_ACTORS) * i; + + color.red = (1.0 - ABS ((MAX (0, MIN (N_ACTORS/2.0 + 0, i))) / + (gdouble)(N_ACTORS/4.0) - 1.0)) * 255.0; + color.green = (1.0 - ABS ((MAX (0, MIN (N_ACTORS/2.0 + 0, + fmod (i + (N_ACTORS/3.0)*2, N_ACTORS)))) / + (gdouble)(N_ACTORS/4) - 1.0)) * 255.0; + color.blue = (1.0 - ABS ((MAX (0, MIN (N_ACTORS/2.0 + 0, + fmod ((i + (N_ACTORS/3.0)), N_ACTORS)))) / + (gdouble)(N_ACTORS/4.0) - 1.0)) * 255.0; + + rect = clutter_rectangle_new_with_color (&color); + clutter_actor_set_size (rect, 100, 100); + clutter_actor_set_anchor_point_from_gravity (rect, + CLUTTER_GRAVITY_CENTER); + clutter_actor_set_position (rect, + 256 + 206 * cos (angle), + 256 + 206 * sin (angle)); + clutter_actor_set_reactive (rect, TRUE); + g_signal_connect (rect, "motion-event", + G_CALLBACK (motion_event_cb), NULL); + + clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); + } + + clutter_actor_show (stage); + + g_idle_add (fps_cb, (gpointer)stage); + + clutter_main (); + + return 0; +} + + From df85b70ab44c564f65605d38abc923822f70f405 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sat, 9 May 2009 20:09:42 -0400 Subject: [PATCH 33/66] Fix chain-up in clutter_list_model_dispose() Chain up to parent class's dispose() method not parent class's finalize() method. http://bugzilla.openedhand.com/show_bug.cgi?id=1595 Signed-off-by: Emmanuele Bassi --- clutter/clutter-list-model.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clutter/clutter-list-model.c b/clutter/clutter-list-model.c index bca5a47f2..d7f2f6ff5 100644 --- a/clutter/clutter-list-model.c +++ b/clutter/clutter-list-model.c @@ -692,7 +692,7 @@ clutter_list_model_dispose (GObject *gobject) model->priv->temp_iter = NULL; } - G_OBJECT_CLASS (clutter_list_model_parent_class)->finalize (gobject); + G_OBJECT_CLASS (clutter_list_model_parent_class)->dispose (gobject); } static void From 979f089ef9e5ef3486fd81f8ec4d38579bb7e7b7 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 12 May 2009 19:22:25 +0100 Subject: [PATCH 34/66] [tests] Add command line option to the picking test The picking test has two configurables: the number of actors and the number of events per frame. It makes sense to have them as command line options to test with multiple configurations without having to change defines and recompile. --- tests/micro-bench/test-picking.c | 54 ++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/tests/micro-bench/test-picking.c b/tests/micro-bench/test-picking.c index 563616dbe..71b08472d 100644 --- a/tests/micro-bench/test-picking.c +++ b/tests/micro-bench/test-picking.c @@ -6,6 +6,25 @@ #define N_ACTORS 100 #define N_EVENTS 5 +static gint n_actors = N_ACTORS; +static gint n_events = N_EVENTS; + +static GOptionEntry entries[] = { + { + "num-actors", 'a', + 0, + G_OPTION_ARG_INT, &n_actors, + "Number of actors", "ACTORS" + }, + { + "num-events", 'e', + 0, + G_OPTION_ARG_INT, &n_events, + "Number of events", "EVENTS" + }, + { NULL } +}; + static gboolean motion_event_cb (ClutterActor *actor, ClutterEvent *event, gpointer user_data) { @@ -19,9 +38,9 @@ do_events (ClutterActor *stage) static gdouble angle = 0; ClutterEvent event; - for (i = 0; i < N_EVENTS; i++) + for (i = 0; i < n_events; i++) { - angle += (2.0 * M_PI) / (gdouble)N_ACTORS; + angle += (2.0 * M_PI) / (gdouble)n_actors; while (angle > M_PI * 2.0) angle -= M_PI * 2.0; @@ -75,10 +94,13 @@ main (int argc, char **argv) gdouble angle; const ClutterColor black = { 0x00, 0x00, 0x00, 0xff }; ClutterColor color = { 0x00, 0x00, 0x00, 0xff }; - ClutterActor *stage, *rect; - clutter_init (&argc, &argv); + clutter_init_with_args (&argc, &argv, + NULL, + entries, + NULL, + NULL); stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 512, 512); @@ -86,21 +108,21 @@ main (int argc, char **argv) printf ("Picking performance test with " "%d actors and %d events per frame\n", - N_ACTORS, - N_EVENTS); + n_actors, + n_events); - for (i = N_ACTORS-1; i >= 0; i--) + for (i = n_actors - 1; i >= 0; i--) { - angle = ((2.0 * M_PI) / (gdouble)N_ACTORS) * i; + angle = ((2.0 * M_PI) / (gdouble) n_actors) * i; - color.red = (1.0 - ABS ((MAX (0, MIN (N_ACTORS/2.0 + 0, i))) / - (gdouble)(N_ACTORS/4.0) - 1.0)) * 255.0; - color.green = (1.0 - ABS ((MAX (0, MIN (N_ACTORS/2.0 + 0, - fmod (i + (N_ACTORS/3.0)*2, N_ACTORS)))) / - (gdouble)(N_ACTORS/4) - 1.0)) * 255.0; - color.blue = (1.0 - ABS ((MAX (0, MIN (N_ACTORS/2.0 + 0, - fmod ((i + (N_ACTORS/3.0)), N_ACTORS)))) / - (gdouble)(N_ACTORS/4.0) - 1.0)) * 255.0; + color.red = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0, i))) / + (gdouble)(n_actors/4.0) - 1.0)) * 255.0; + color.green = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0, + fmod (i + (n_actors/3.0)*2, n_actors)))) / + (gdouble)(n_actors/4) - 1.0)) * 255.0; + color.blue = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0, + fmod ((i + (n_actors/3.0)), n_actors)))) / + (gdouble)(n_actors/4.0) - 1.0)) * 255.0; rect = clutter_rectangle_new_with_color (&color); clutter_actor_set_size (rect, 100, 100); From 2b1759385e8f3373497b5d99c733266c2ecae1ee Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 13 May 2009 12:11:54 +0100 Subject: [PATCH 35/66] [text] Ensure clutter_text_get_selection copes with start/end positions of -1 I was seeing clutter_text_get_selection trying to malloc up to 4Gb due to unexpected negative arithmetic for the start/end offsets which resulted in a crash. This just tests for positions of -1 before deciding if the start/end positions need to be swapped. The conversion from position to byte offset already works with -1. --- clutter/clutter-text.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index c57559560..070591232 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -2859,7 +2859,8 @@ clutter_text_get_selection (ClutterText *self) if (end_index == start_index) return g_strdup (""); - if (end_index < start_index) + if ((end_index != -1 && end_index < start_index) || + start_index == -1) { gint temp = start_index; start_index = end_index; From 447e04bdce9b95bb1fc544d4c931071fa3665825 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 13 May 2009 23:04:25 +0100 Subject: [PATCH 36/66] [text] Return the correct minimum height If text is set, ClutterText should never return less than the layout height for minimum and preferred heights. This holds unless ellipsize and wrap are enabled, in which case the minimum height should be the height of the first line -- which is the height needed to at the very least show the ellipsization. Based on a patch by: Thomas Wood Fixes bug: http://bugzilla.openedhand.com/show_bug.cgi?id=1598 Signed-off-by: Emmanuele Bassi --- clutter/clutter-text.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 070591232..99bd975f6 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -1448,7 +1448,7 @@ clutter_text_get_preferred_height (ClutterActor *self, ClutterUnit *min_height_p, ClutterUnit *natural_height_p) { - ClutterText *text = CLUTTER_TEXT (self); + ClutterTextPrivate *priv = CLUTTER_TEXT (self)->priv; if (for_width == 0) { @@ -1465,7 +1465,8 @@ clutter_text_get_preferred_height (ClutterActor *self, gint logical_height; ClutterUnit layout_height; - layout = clutter_text_create_layout (text, for_width, -1); + layout = clutter_text_create_layout (CLUTTER_TEXT (self), + for_width, -1); pango_layout_get_extents (layout, NULL, &logical_rect); @@ -1474,13 +1475,26 @@ clutter_text_get_preferred_height (ClutterActor *self, * the height accordingly */ logical_height = logical_rect.y + logical_rect.height; - layout_height = CLUTTER_UNITS_FROM_PANGO_UNIT (logical_height); if (min_height_p) { - if (text->priv->ellipsize) - *min_height_p = 1; + /* if we wrap and ellipsize then the minimum height is + * going to be at least the size of the first line + */ + if (priv->ellipsize && priv->wrap) + { + PangoLayoutLine *line; + ClutterUnit line_height; + + line = pango_layout_get_line_readonly (layout, 0); + pango_layout_line_get_extents (line, NULL, &logical_rect); + + logical_height = logical_rect.y + logical_rect.height; + line_height = CLUTTER_UNITS_FROM_PANGO_UNIT (logical_height); + + *min_height_p = line_height; + } else *min_height_p = layout_height; } From d8aa6827ee310115b3f0a466c0798e4e5c1e5780 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Wed, 13 May 2009 23:14:24 +0100 Subject: [PATCH 37/66] Don't build Cogl.gir against installed Clutter library Passing: --library=clutter-@CLUTTER_FLAVOUR@-@CLUTTER_API_VERSION@ to g-ir-scanner, when building Cogl was causing g-ir-scanner to link the introspection program against the installed clutter library, if it existed or fail otherwise. Instead copy the handling from the json/ directory where we link against the convenience library to scan, and do the generation of the typelib later in the main clutter/directory. Fixes bug: http://bugzilla.openedhand.com/show_bug.cgi?id=1594 Signed-off-by: Emmanuele Bassi --- .gitignore | 5 +++-- clutter/Makefile.am | 30 ++++++++++++++++++++---------- clutter/cogl/Makefile.am | 29 +++++++++++------------------ 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index c473b18e1..83fd0ac2c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,8 +23,8 @@ clutter/stamp-* /clutter/cogl/*.pc /clutter/cogl/gles/cogl-fixed-vertex-shader.[ch] /clutter/cogl/gles/cogl-fixed-fragment-shader.[ch] -/clutter/*.gir -/clutter/*.typelib +*.gir +*.typelib /clutter/json/*.gir cogl-defines.h config.* @@ -192,6 +192,7 @@ stamp-h1 /tests/conform/redhand.png /tests/micro-bench/test-glyph-perf /tests/micro-bench/test-text +/tests/micro-bench/test-picking /tests/tools/disable-npots.sh /clutter/x11/clutter-x11-enum-types.[ch] /clutter/x11/stamp-clutter-x11-enum-types.h diff --git a/clutter/Makefile.am b/clutter/Makefile.am index 4f53a5a2e..5b838cea5 100644 --- a/clutter/Makefile.am +++ b/clutter/Makefile.am @@ -205,16 +205,16 @@ source_h_priv = \ libclutter_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_LIBADD = \ $(CLUTTER_LIBS) \ + $(top_builddir)/clutter/cogl/libclutter-cogl.la \ $(top_builddir)/clutter/pango/libcoglpango.la \ $(top_builddir)/clutter/$(CLUTTER_FLAVOUR)/libclutter-$(CLUTTER_FLAVOUR).la \ - $(top_builddir)/clutter/cogl/$(CLUTTER_COGL)/libclutter-cogl.la \ $(clutter_json_libadd) \ $(backendextralib) libclutter_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_DEPENDENCIES = \ + $(top_builddir)/clutter/cogl/libclutter-cogl.la \ $(top_builddir)/clutter/pango/libcoglpango.la \ $(top_builddir)/clutter/$(CLUTTER_FLAVOUR)/libclutter-$(CLUTTER_FLAVOUR).la \ - $(top_builddir)/clutter/cogl/$(CLUTTER_COGL)/libclutter-cogl.la \ $(clutter_json_dep) \ $(backendextralib) @@ -245,8 +245,8 @@ json_gir_include_path=--add-include-path=json endif # We can't reference the list of COGL header files, since they are in a -# subdir Makefile.am, so just extract them from cogl.h instead. The doc comments -# for COGL are in the headers, so we don't need the source files. +# subdir Makefile.am, so just extract them from cogl.h instead. The doc +# comments for COGL are in the headers, so we don't need the source files. Clutter-@CLUTTER_API_VERSION@.gir: $(INTROSPECTION_SCANNER) libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_API_VERSION@.la headers=`sed -n "s/#include ]*\)>/\1/p" < $(top_srcdir)/clutter/cogl/cogl.h` ; \ cogl_headers="" ; \ @@ -274,11 +274,20 @@ Clutter-@CLUTTER_API_VERSION@.gir: $(INTROSPECTION_SCANNER) libclutter-@CLUTTER_ BUILT_GIRSOURCES += Clutter-@CLUTTER_API_VERSION@.gir +# We build Cogl.gir in the cogl/ subdir, but it needs to reference the shared +# library that it's built into, so we delay compiling the gir into typelib +# until after we've built the shared library. To create the final Cogl.gir +# that we compile and install, we transfer the shared-library="" line from +# Clutter.gir to Cogl.gir +Cogl-@CLUTTER_API_VERSION@.gir: Clutter-@CLUTTER_API_VERSION@.gir cogl/Cogl-@CLUTTER_API_VERSION@.gir + shlib=`sed -n 's/.*shared-library="\([^"]*\)".*/\1/p' < Clutter-@CLUTTER_API_VERSION@.gir` ; \ + sed "s/shared-library=\"clutter-cogl\"/shared-library=\"$$shlib\"/"< cogl/Cogl-@CLUTTER_API_VERSION@.gir > $@ + +BUILT_GIRSOURCES += Cogl-@CLUTTER_API_VERSION@.gir + if LOCAL_JSON_GLIB -# We build ClutterJson.gir in the json/ subdir, but it needs to reference the shared library -# that it's built into, so we delay compiling the gir into typelib until after we've built -# the shared library. To create the final ClutterJson.gir that we compiler and install, we -# transfer the shared-library="" line from Clutter.gir to ClutterJson.gir +# If we are building it, ClutterJson gets the same handling as described +# for Cogl above ClutterJson-@CLUTTER_API_VERSION@.gir: Clutter-@CLUTTER_API_VERSION@.gir json/ClutterJson-@CLUTTER_API_VERSION@.gir shlib=`sed -n 's/.*shared-library="\([^"]*\)".*/\1/p' < Clutter-@CLUTTER_API_VERSION@.gir` ; \ sed "s/shared-library=\"clutter-json\"/shared-library=\"$$shlib\"/"< json/ClutterJson-@CLUTTER_API_VERSION@.gir > $@ @@ -286,12 +295,13 @@ ClutterJson-@CLUTTER_API_VERSION@.gir: Clutter-@CLUTTER_API_VERSION@.gir json/Cl BUILT_GIRSOURCES += ClutterJson-@CLUTTER_API_VERSION@.gir endif -# INTROSPECTION_GIRDIR/INTROSPECTION_TYPELIBDIR aren't the right place to install -# thing - we need to install inside our prefix. +# INTROSPECTION_GIRDIR/INTROSPECTION_TYPELIBDIR aren't the right place to +# install anything - we need to install inside our prefix. girdir = $(datadir)/gir-1.0 gir_DATA = $(BUILT_GIRSOURCES) typelibsdir = $(libdir)/girepository-1.0/ + typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib) %.typelib: %.gir $(INTROSPECTION_COMPILER) diff --git a/clutter/cogl/Makefile.am b/clutter/cogl/Makefile.am index 4435e8c64..10ae24481 100644 --- a/clutter/cogl/Makefile.am +++ b/clutter/cogl/Makefile.am @@ -24,7 +24,6 @@ CLEANFILES = $(pc_files) AM_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) if HAVE_INTROSPECTION - cogl_headers = \ $(top_srcdir)/clutter/cogl/cogl-bitmap.h \ $(top_srcdir)/clutter/cogl/cogl-color.h \ @@ -39,6 +38,13 @@ cogl_headers = \ $(top_srcdir)/clutter/cogl/cogl-types.h \ $(top_srcdir)/clutter/cogl/cogl-vertex-buffer.h +# HACK - gobject-introspection can't scan a library in another directory +# so we create a libclutter-cogl.la that's just identical to the one +# in the subdir +noinst_LTLIBRARIES = libclutter-cogl.la +libclutter_cogl_la_LIBADD = $(CLUTTER_COGL)/libclutter-cogl.la +libclutter_cogl_la_SOURCES = $(cogl_headers) + Cogl-@CLUTTER_API_VERSION@.gir: $(INTROSPECTION_SCANNER) $(CLUTTER_COGL)/libclutter-cogl.la $(QUIET_GEN)$(INTROSPECTION_SCANNER) -v \ --namespace Cogl --nsversion=@CLUTTER_API_VERSION@ \ @@ -49,7 +55,7 @@ Cogl-@CLUTTER_API_VERSION@.gir: $(INTROSPECTION_SCANNER) $(CLUTTER_COGL)/libclut -DCLUTTER_COMPILATION \ --include=GL-1.0 \ --include=GObject-2.0 \ - --library=clutter-@CLUTTER_FLAVOUR@-@CLUTTER_API_VERSION@ \ + --library=clutter-cogl \ --libtool="$(top_builddir)/doltlibtool" \ --pkg gobject-2.0 \ --output $@ \ @@ -59,21 +65,8 @@ Cogl-@CLUTTER_API_VERSION@.gir: $(INTROSPECTION_SCANNER) $(CLUTTER_COGL)/libclut BUILT_GIRSOURCES = Cogl-@CLUTTER_API_VERSION@.gir -#girdir = $(datadir)/gir-1.0 -#gir_DATA = $(BUILT_GIRSOURCES) - -#typelibsdir = $(libdir)/girepository-1.0 -#typelibs_DATA = Cogl-@CLUTTER_API_VERSION@.typelib - -#%.typelib: %.gir $(INTROSPECTION_COMPILER) -# $(QUIET_GEN)$(DEBUG) $(INTROSPECTION_COMPILER) \ -# --includedir=$(top_builddir)/clutter \ -# --includedir=$(top_srcdir)/clutter \ -# --includedir=$(srcdir) \ -# --includedir=. \ -# $(INTROSPECTION_COMPILER_OPTS) \ -# $< -o $(@F) - -CLEANFILES += $(BUILT_GIRSOURCES) #$(typelibs_DATA) +girdir = $(datadir)/gir-1.0 +gir_DATA = $(BUILT_GIRSOURCES) +CLEANFILES += $(BUILT_GIRSOURCES) endif From 724e58a85a35e249490e54d27e7f9411033db3a9 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 14 May 2009 08:32:46 +0100 Subject: [PATCH 38/66] [build] Do not rebuild the conformance tests scripts Make the build output a little bit cleaner by not re-creating the small shell scripts that allow launching the test units separately. --- .gitignore | 1 + tests/conform/Makefile.am | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 83fd0ac2c..c78e8bd95 100644 --- a/.gitignore +++ b/.gitignore @@ -128,6 +128,7 @@ stamp-h1 /tests/interactive/redhand_alpha.png /tests/interactive/test-script.json /tests/interactive/test-clutter-cairo-flowers +/tests/conform/stamp-test-conformance /tests/conform/test-anchors /tests/conform/test-conformance /tests/conform/test-conformance-results.xml diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am index adbb22070..5fd68034a 100644 --- a/tests/conform/Makefile.am +++ b/tests/conform/Makefile.am @@ -35,14 +35,17 @@ test_conformance_SOURCES = \ UNIT_TESTS = `./test-conformance -l -m thorough | $(GREP) '^/'` -wrappers: test-conformance$(EXEEXT) +wrappers: stamp-test-conformance + @true +stamp-test-conformance: test-conformance$(EXEEXT) @for i in $(UNIT_TESTS); \ do \ unit=`basename $$i | sed -e s/_/-/g`; \ echo " GEN $$unit"; \ ( echo "#!/bin/sh" ; echo "$(top_srcdir)/tests/conform/test-launcher.sh '$$i'" ) > $$unit$(EXEEXT) ; \ chmod +x $$unit$(EXEEXT); \ - done + done \ + && echo timestamp > $(@F) clean-wrappers: @for i in $(UNIT_TESTS); \ @@ -50,7 +53,8 @@ clean-wrappers: unit=`basename $$i | sed -e s/_/-/g`; \ echo "RM $$unit"; \ rm -f $$unit$(EXEEXT) ; \ - done + done \ + && rm -f stamp-test-conformance # NB: BUILT_SOURCES here a misnomer. We aren't building source, just inserting # a phony rule that will generate symlink scripts for running individual tests From 608c3e3ab45ab262e9b89f8a78cdf2f057dca570 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 14 May 2009 10:02:06 +0100 Subject: [PATCH 39/66] [build] Fix with --disable-introspection The required "fake" libclutter-cogl.la upon with the main clutter shared object depends is only built with introspection enabled instead of being built unconditionally. --- clutter/cogl/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clutter/cogl/Makefile.am b/clutter/cogl/Makefile.am index 10ae24481..225b66100 100644 --- a/clutter/cogl/Makefile.am +++ b/clutter/cogl/Makefile.am @@ -23,7 +23,6 @@ CLEANFILES = $(pc_files) AM_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) -if HAVE_INTROSPECTION cogl_headers = \ $(top_srcdir)/clutter/cogl/cogl-bitmap.h \ $(top_srcdir)/clutter/cogl/cogl-color.h \ @@ -45,6 +44,7 @@ noinst_LTLIBRARIES = libclutter-cogl.la libclutter_cogl_la_LIBADD = $(CLUTTER_COGL)/libclutter-cogl.la libclutter_cogl_la_SOURCES = $(cogl_headers) +if HAVE_INTROSPECTION Cogl-@CLUTTER_API_VERSION@.gir: $(INTROSPECTION_SCANNER) $(CLUTTER_COGL)/libclutter-cogl.la $(QUIET_GEN)$(INTROSPECTION_SCANNER) -v \ --namespace Cogl --nsversion=@CLUTTER_API_VERSION@ \ From 8174f66cc60a70e60eb98b0097416f898e8df485 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 14 May 2009 11:50:42 +0100 Subject: [PATCH 40/66] [text] Reset the cursor when setting empty text When setting the contents of Text to an empty string we should reset the cursor position and selection bound to -1. --- clutter/clutter-text.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 99bd975f6..b9b5428ee 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -3141,6 +3141,8 @@ clutter_text_set_text_internal (ClutterText *self, { ClutterTextPrivate *priv = self->priv; + g_object_freeze_notify (G_OBJECT (self)); + if (priv->max_length > 0) { gint len = g_utf8_strlen (text, -1); @@ -3176,8 +3178,16 @@ clutter_text_set_text_internal (ClutterText *self, priv->n_chars = g_utf8_strlen (text, -1); } + if (priv->n_bytes == 0) + { + clutter_text_set_cursor_position (self, -1); + clutter_text_set_selection_bound (self, -1); + } + g_signal_emit (self, text_signals[TEXT_CHANGED], 0); g_object_notify (G_OBJECT (self), "text"); + + g_object_thaw_notify (G_OBJECT (self)); } static inline void From 0d43d81ee04ea456edb3159aa0e0c71e2f869f62 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 14 May 2009 12:00:51 +0100 Subject: [PATCH 41/66] [text] Maintain the cursor at the end when deleting If the cursor is already at the end of the Text contents then we need to maintain its position when deleting the previous character using the relative key binding. --- clutter/clutter-text.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index b9b5428ee..5b0aa1422 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -1765,17 +1765,17 @@ clutter_text_real_del_prev (ClutterText *self, { if (pos == -1) { - clutter_text_set_cursor_position (self, len - 1); - clutter_text_set_selection_bound (self, len - 1); - clutter_text_delete_text (self, len - 1, len); + + clutter_text_set_cursor_position (self, -1); + clutter_text_set_selection_bound (self, -1); } else { + clutter_text_delete_text (self, pos - 1, pos); + clutter_text_set_cursor_position (self, pos - 1); clutter_text_set_selection_bound (self, pos - 1); - - clutter_text_delete_text (self, pos - 1, pos); } } From 92e439105697fe65d8c6dda08d1658774245e9cb Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 14 May 2009 12:05:57 +0100 Subject: [PATCH 42/66] [tests] Verify cursor position Print out the cursor and selection positions in order to verify the behaviour of the Text actor. This is a likely candidate for a conformance test unit as well. --- tests/interactive/test-text-field.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/interactive/test-text-field.c b/tests/interactive/test-text-field.c index 260fc5fca..fbb51de68 100644 --- a/tests/interactive/test-text-field.c +++ b/tests/interactive/test-text-field.c @@ -28,7 +28,10 @@ static void on_entry_activate (ClutterText *text, gpointer data) { - g_print ("Text activated: %s\n", clutter_text_get_text (text)); + g_print ("Text activated: %s (cursor: %d, selection at: %d)\n", + clutter_text_get_text (text), + clutter_text_get_cursor_position (text), + clutter_text_get_selection_bound (text)); } static ClutterActor * From cd86e70f4150505a035ea074aed06e4bd3fbb9df Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Thu, 14 May 2009 09:53:41 +0100 Subject: [PATCH 43/66] [text] take text padding into account when in single line mode In single line mode, extra padding is added to the text which must be taken into account when reporting the natural size of the actor. --- clutter/clutter-text.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 5b0aa1422..6b1d693f9 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -1439,7 +1439,12 @@ clutter_text_get_preferred_width (ClutterActor *self, } if (natural_width_p) - *natural_width_p = layout_width; + { + if (priv->editable && priv->single_line_mode) + *natural_width_p = layout_width + TEXT_PADDING * 2; + else + *natural_width_p = layout_width; + } } static void From e162d0b0607e9221b360cfe7b0d61a2b4b44edd9 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Thu, 14 May 2009 10:17:24 +0100 Subject: [PATCH 44/66] [text] position the cursor correctly in single line mode The position of the text should be increased by the value of TEXT_PADDING and the cursor offset by the same value as the text offset. --- clutter/clutter-text.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 6b1d693f9..53f249768 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -1354,11 +1354,10 @@ clutter_text_paint (ClutterActor *self) if (priv->position == -1) { text_x = actor_width - text_width; - priv->cursor_pos.x += text_x + TEXT_PADDING; } else if (priv->position == 0) { - text_x = 0; + text_x = TEXT_PADDING; } else { @@ -1375,9 +1374,9 @@ clutter_text_paint (ClutterActor *self) } else { - text_x = 0; - priv->cursor_pos.x += text_x + TEXT_PADDING; + text_x = TEXT_PADDING; } + priv->cursor_pos.x += text_x; } else text_x = 0; From 16185c78fc59f8538f0a439908bd43ae8ee981fe Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Thu, 14 May 2009 10:51:58 +0100 Subject: [PATCH 45/66] [text] take scrolling into account when calculating cursor position Account for the scrolling in single line more when calculating the cursor position from coordinates. --- clutter/clutter-text.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 53f249768..7e295a497 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -463,6 +463,10 @@ clutter_text_coords_to_position (ClutterText *text, gint px, py; gint trailing; + /* Take any offset due to scrolling into account */ + if (text->priv->single_line_mode) + x += text->priv->text_x * -1; + px = x * PANGO_SCALE; py = y * PANGO_SCALE; From e79fd1055d5d220a2460fc5ada0e74d7456aedf2 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Thu, 14 May 2009 10:53:44 +0100 Subject: [PATCH 46/66] [text] account for scrolling in clutter_text_position_to_coords Add any scrolling offset to the x value when in single line mode. Now that the offset is taken into account in the position_to_coords function, we do not need to adjust the cursor x manually in clutter_text_paint. --- clutter/clutter-text.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 7e295a497..4a169219f 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -535,6 +535,15 @@ clutter_text_position_to_coords (ClutterText *self, if (line_height) *line_height = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.height); + if (self->priv->single_line_mode) + { + /* Take any offset due to scrolling into account */ + if (x) + *x += self->priv->text_x; + } + + + /* FIXME: should return false if coords were outside text */ return TRUE; } @@ -1380,7 +1389,6 @@ clutter_text_paint (ClutterActor *self) { text_x = TEXT_PADDING; } - priv->cursor_pos.x += text_x; } else text_x = 0; From cf6c2d9721b96123f20c9ed26f8066dba502a035 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Thu, 14 May 2009 10:55:25 +0100 Subject: [PATCH 47/66] [text] account for scrolling in text selections Account for any scrolling offset in single line mode when calculating the area that should be selected. --- clutter/clutter-text.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 4a169219f..3594e5ec2 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -962,6 +962,12 @@ cursor_paint (ClutterText *self) range_x = ranges[i * 2] / PANGO_SCALE; + + /* Account for any scrolling in single line mode */ + if (priv->single_line_mode) + range_x += priv->text_x; + + range_width = (ranges[i * 2 + 1] - ranges[i * 2]) / PANGO_SCALE; From a3a5fe5594301778ec78f161dfeffac113d89901 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Thu, 14 May 2009 13:31:51 +0100 Subject: [PATCH 48/66] [text] scroll to the cursor position if it is outside the allocation Adjust the text offset to keep the cursor within the allocation. This means the text will scroll per character --- clutter/clutter-text.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 3594e5ec2..e82793ae3 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -1368,7 +1368,7 @@ clutter_text_paint (ClutterActor *self) if (actor_width < text_width) { - gint cursor_x = priv->cursor_pos.x; + gint cursor_x = priv->cursor_pos.x - alloc.x1; if (priv->position == -1) { @@ -1380,16 +1380,19 @@ clutter_text_paint (ClutterActor *self) } else { - if (text_x <= 0) + if (cursor_x < 0) { - gint diff = -1 * text_x; - - if (cursor_x < diff) - text_x += diff - cursor_x; - else if (cursor_x > (diff + actor_width)) - text_x -= cursor_x - (diff - actor_width); + text_x = text_x - cursor_x - TEXT_PADDING; + } + else if (cursor_x > actor_width) + { + text_x = text_x + (actor_width - cursor_x) - TEXT_PADDING; } } + /* Update the absolute cursor position as it may have moved due to + * scrolling */ + clutter_text_ensure_cursor_position (text); + } else { @@ -1399,6 +1402,8 @@ clutter_text_paint (ClutterActor *self) else text_x = 0; + priv->text_x = text_x; + cursor_paint (text); real_opacity = clutter_actor_get_paint_opacity (self) @@ -1417,7 +1422,6 @@ clutter_text_paint (ClutterActor *self) if (clip_set) cogl_clip_pop (); - priv->text_x = text_x; } static void From 81a536238d539fb87b24b7815408c4916fa63da6 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Thu, 14 May 2009 15:08:31 +0100 Subject: [PATCH 49/66] [text] fix problems with scrolling interaction The cursor x position is already translated, so we do not need to take the actors allocation into account when calculating scrolling. Additionally, we need to update the text_x value before running clutter_text_ensure_cursor_position. --- clutter/clutter-text.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index e82793ae3..5a1fd5ac2 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -1368,7 +1368,7 @@ clutter_text_paint (ClutterActor *self) if (actor_width < text_width) { - gint cursor_x = priv->cursor_pos.x - alloc.x1; + gint cursor_x = priv->cursor_pos.x; if (priv->position == -1) { @@ -1391,6 +1391,7 @@ clutter_text_paint (ClutterActor *self) } /* Update the absolute cursor position as it may have moved due to * scrolling */ + priv->text_x = text_x; clutter_text_ensure_cursor_position (text); } From 1c6580afd67526d1f8e7ee114fdcd69b83e9f4c6 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 14 May 2009 09:28:12 -0400 Subject: [PATCH 50/66] [cairo-texture] Document redrawing behavior Document that repeated calls to clutter_cairo_texture_create() continue drawing on the same cairo_surface_t. Add clutter_cairo_texture_clear() for when you don't want that behavior. http://bugzilla.openedhand.com/show_bug.cgi?id=1599 Signed-off-by: Emmanuele Bassi --- clutter/clutter-cairo-texture.c | 31 +++++++++++++++++++++++++++++++ clutter/clutter-cairo-texture.h | 6 ++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/clutter/clutter-cairo-texture.c b/clutter/clutter-cairo-texture.c index f638ff9c9..8c3e3519f 100644 --- a/clutter/clutter-cairo-texture.c +++ b/clutter/clutter-cairo-texture.c @@ -54,6 +54,12 @@ * cairo_destroy (cr); * ]| * + * Although a new #cairo_t is created each time you call + * clutter_cairo_texture_create() or + * clutter_cairo_texture_create_region(), it uses the same + * #cairo_surface_t each time. You can call + * clutter_cairo_texture_clear() to erase the contents between calls. + * * Note that you should never use the code above inside the * #ClutterActor::paint or #ClutterActor::pick virtual functions or * signal handlers because it will lead to performance @@ -760,3 +766,28 @@ clutter_cairo_texture_get_surface_size (ClutterCairoTexture *self, if (height) *height = self->priv->height; } + +/** + * clutter_cairo_texture_clear: + * @self: a #ClutterCairoTexture + * + * Clears @self's internal drawing surface, so that the next upload + * will replace the previous contents of the #ClutterCairoTexture + * rather than adding to it. + * + * Since: 1.0 + */ +void +clutter_cairo_texture_clear (ClutterCairoTexture *self) +{ + ClutterCairoTexturePrivate *priv; + + g_return_if_fail (CLUTTER_IS_CAIRO_TEXTURE (self)); + + priv = self->priv; + + if (!priv->cr_surface_data) + return; + + memset (priv->cr_surface_data, 0, priv->height * priv->rowstride); +} diff --git a/clutter/clutter-cairo-texture.h b/clutter/clutter-cairo-texture.h index b7816fef6..2c4c9a417 100644 --- a/clutter/clutter-cairo-texture.h +++ b/clutter/clutter-cairo-texture.h @@ -98,8 +98,10 @@ void clutter_cairo_texture_get_surface_size (ClutterCairoTexture *self, guint *width, guint *height); -void clutter_cairo_set_source_color (cairo_t *cr, - const ClutterColor *color); +void clutter_cairo_texture_clear (ClutterCairoTexture *self); + +void clutter_cairo_set_source_color (cairo_t *cr, + const ClutterColor *color); G_END_DECLS From 092b41d53b793a985d5234acfa9df007b16be4c3 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 6 May 2009 16:42:57 +0100 Subject: [PATCH 51/66] [docs] Document the destructor for Timeline The rest of the API reference lists the destructor for the class inside the constructor's return value -- except Timeline. --- clutter/clutter-timeline.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clutter/clutter-timeline.c b/clutter/clutter-timeline.c index 72abc0b48..4eaeeb66c 100644 --- a/clutter/clutter-timeline.c +++ b/clutter/clutter-timeline.c @@ -1235,7 +1235,8 @@ clutter_timeline_clone (ClutterTimeline *timeline) * the value of the ClutterTimeline:fps property to compute the * equivalent number of frames. * - * Return value: the newly created #ClutterTimeline + * Return value: the newly created #ClutterTimeline instance. Use + * g_object_unref() when done using it * * Since: 0.6 */ @@ -1254,7 +1255,8 @@ clutter_timeline_new_for_duration (guint msecs) * * Create a new #ClutterTimeline instance. * - * Return Value: a new #ClutterTimeline + * Return Value: the newly created #ClutterTimeline instance. Use + * g_object_unref() when done using it */ ClutterTimeline* clutter_timeline_new (guint n_frames, From 0f7a3b973952505e85e93d0bde59be48973fbeb2 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 6 May 2009 16:43:52 +0100 Subject: [PATCH 52/66] [docs] Add Animation get_type() function We need to reference clutter_animation_get_type() if we want the properties, signals and object hierarchy to show up in the API reference --- doc/reference/clutter/clutter.types | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/reference/clutter/clutter.types b/doc/reference/clutter/clutter.types index 7734a16c8..6926447d9 100644 --- a/doc/reference/clutter/clutter.types +++ b/doc/reference/clutter/clutter.types @@ -29,3 +29,4 @@ clutter_child_meta_get_type clutter_cairo_texture_get_type clutter_text_get_type clutter_animatable_get_type +clutter_animation_get_type From 79cb0a3515325dcf183684eb9809fd66abff478a Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 6 May 2009 17:01:44 +0100 Subject: [PATCH 53/66] [animation] Remove InitiallyUnowned from Animation ClutterAnimation currently inherits the initial floating reference semantics from GInitiallyUnowned. An Animation is, though, meant to be used as a top-level object, like a Timeline or a Behaviour, and not "owned" by another object. For this reason, the initial floating reference does not make any sense. --- clutter/clutter-animation.c | 18 ++++++++---------- clutter/clutter-animation.h | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/clutter/clutter-animation.c b/clutter/clutter-animation.c index 24b9c3f08..d835694b4 100644 --- a/clutter/clutter-animation.c +++ b/clutter/clutter-animation.c @@ -102,7 +102,7 @@ static guint animation_signals[LAST_SIGNAL] = { 0, }; static GQuark quark_object_animation = 0; -G_DEFINE_TYPE (ClutterAnimation, clutter_animation, G_TYPE_INITIALLY_UNOWNED); +G_DEFINE_TYPE (ClutterAnimation, clutter_animation, G_TYPE_OBJECT); static void on_animation_weak_notify (gpointer data, GObject *animation_pointer); @@ -853,9 +853,8 @@ on_animation_weak_notify (gpointer data, * lifetime of a #ClutterAnimation instance, so you should consider using * those functions instead of manually creating an animation. * - * Return value: the newly created #ClutterAnimation. Use g_object_ref_sink() - * to take ownership of the Animation instance, and g_object_unref() to - * release the associated resources + * Return value: the newly created #ClutterAnimation. Use g_object_unref() + * to release the associated resources * * Since: 1.0 */ @@ -886,8 +885,6 @@ clutter_animation_set_object (ClutterAnimation *animation, priv = animation->priv; - g_object_ref (object); - if (priv->object) { g_object_weak_unref (G_OBJECT (animation), @@ -897,13 +894,14 @@ clutter_animation_set_object (ClutterAnimation *animation, g_object_unref (priv->object); } - priv->object = object; + priv->object = g_object_ref (object); g_object_weak_ref (G_OBJECT (animation), on_animation_weak_notify, priv->object); - g_object_set_qdata (G_OBJECT (priv->object), - quark_object_animation, - animation); + g_object_set_qdata_full (G_OBJECT (priv->object), + quark_object_animation, + animation, + NULL); g_object_notify (G_OBJECT (animation), "object"); } diff --git a/clutter/clutter-animation.h b/clutter/clutter-animation.h index 0990309ce..d8cf74d8c 100644 --- a/clutter/clutter-animation.h +++ b/clutter/clutter-animation.h @@ -59,7 +59,7 @@ typedef struct _ClutterAnimationClass ClutterAnimationClass; struct _ClutterAnimation { /*< private >*/ - GInitiallyUnowned parent_instance; + GObject parent_instance; ClutterAnimationPrivate *priv; }; @@ -77,7 +77,7 @@ struct _ClutterAnimation struct _ClutterAnimationClass { /*< private >*/ - GInitiallyUnownedClass parent_class; + GObjectClass parent_class; /*< public >*/ void (* started) (ClutterAnimation *animation); From ca238387521d2df289e8df81ddf9e01597bed046 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 6 May 2009 17:08:25 +0100 Subject: [PATCH 54/66] [text] Add ClutterText::delete_selection() Add a method for deleting the current selection inside a Text actor. This is useful for subclasses. See bug: http://bugzilla.openedhand.com/show_bug.cgi?id=1521 Based on a patch by: Raymond Liu --- clutter/clutter-text.c | 47 +++++++++++++++------- clutter/clutter-text.h | 1 + doc/reference/clutter/clutter-sections.txt | 1 + 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 5a1fd5ac2..856b7df1b 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -415,10 +415,10 @@ clutter_text_create_layout (ClutterText *text, /* If this cached layout is using the same size then we can * just return that directly */ - CLUTTER_NOTE (ACTOR, "ClutterText: %p: cache hit for size %i x %i", + CLUTTER_NOTE (ACTOR, "ClutterText: %p: cache hit for size %.2fx%.2f", text, - CLUTTER_UNITS_TO_DEVICE (allocation_width), - CLUTTER_UNITS_TO_DEVICE (allocation_height)); + allocation_width, + allocation_height); return priv->cached_layouts[i].layout; } @@ -429,10 +429,10 @@ clutter_text_create_layout (ClutterText *text, } } - CLUTTER_NOTE (ACTOR, "ClutterText: %p: cache miss for size %i x %i", + CLUTTER_NOTE (ACTOR, "ClutterText: %p: cache miss for size %.2fx%.2f", text, - CLUTTER_UNITS_TO_DEVICE (allocation_width), - CLUTTER_UNITS_TO_DEVICE (allocation_height)); + allocation_width, + allocation_height); /* If we make it here then we didn't have a cached version so we need to recreate the layout */ @@ -562,10 +562,10 @@ clutter_text_ensure_cursor_position (ClutterText *self) &x, &y, &cursor_height); - cursor_pos.x = CLUTTER_UNITS_TO_DEVICE (x); - cursor_pos.y = CLUTTER_UNITS_TO_DEVICE (y); + cursor_pos.x = x; + cursor_pos.y = y; cursor_pos.width = priv->cursor_size; - cursor_pos.height = CLUTTER_UNITS_TO_DEVICE (cursor_height) - 2; + cursor_pos.height = cursor_height - 2; x_changed = priv->cursor_pos.x != cursor_pos.x; y_changed = priv->cursor_pos.y != cursor_pos.y; @@ -580,13 +580,30 @@ clutter_text_ensure_cursor_position (ClutterText *self) } } -static gboolean -clutter_text_truncate_selection (ClutterText *self) +/** + * clutter_text_delete_selection: + * @self: a #ClutterText + * + * Deletes the currently selected text + * + * This function is only useful in subclasses of #ClutterText + * + * Return value: %TRUE if text was deleted or if the text actor + * is empty, and %FALSE otherwise + * + * Since: 1.0 + */ +gboolean +clutter_text_delete_selection (ClutterText *self) { - ClutterTextPrivate *priv = self->priv; + ClutterTextPrivate *priv; gint start_index; gint end_index; + g_return_val_if_fail (CLUTTER_IS_TEXT (self), FALSE); + + priv = self->priv; + if (!priv->text) return TRUE; @@ -1310,7 +1327,7 @@ clutter_text_key_press (ClutterActor *actor, /* truncate the eventual selection so that the * Unicode character can replace it */ - clutter_text_truncate_selection (self); + clutter_text_delete_selection (self); clutter_text_insert_unichar (self, key_unichar); return TRUE; @@ -1760,7 +1777,7 @@ clutter_text_real_del_next (ClutterText *self, gint pos; gint len; - if (clutter_text_truncate_selection (self)) + if (clutter_text_delete_selection (self)) return TRUE; pos = priv->position; @@ -1782,7 +1799,7 @@ clutter_text_real_del_prev (ClutterText *self, gint pos; gint len; - if (clutter_text_truncate_selection (self)) + if (clutter_text_delete_selection (self)) return TRUE; pos = priv->position; diff --git a/clutter/clutter-text.h b/clutter/clutter-text.h index fd7eb07c5..01b058cf7 100644 --- a/clutter/clutter-text.h +++ b/clutter/clutter-text.h @@ -186,6 +186,7 @@ void clutter_text_set_selection_color (ClutterText *sel const ClutterColor *color); void clutter_text_get_selection_color (ClutterText *self, ClutterColor *color); +gboolean clutter_text_delete_selection (ClutterText *self); void clutter_text_set_password_char (ClutterText *self, gunichar wc); gunichar clutter_text_get_password_char (ClutterText *self); diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index ccbc16148..fcfc97ebb 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1584,6 +1584,7 @@ clutter_text_insert_text clutter_text_insert_unichar clutter_text_delete_chars clutter_text_delete_text +clutter_text_delete_selection clutter_text_get_chars clutter_text_set_cursor_color clutter_text_get_cursor_color From 21e3901d6248ceb9fd4e3c0c82565817774f463f Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 6 May 2009 17:18:12 +0100 Subject: [PATCH 55/66] [text] Expose position_to_coords() The clutter_text_position_to_coords() is useful for ClutterText subclasses. See bug: http://bugzilla.openedhand.com/show_bug.cgi?id=1521 Based on a patch by: Raymond Liu --- clutter/clutter-text.c | 33 +++++++++++++--------- clutter/clutter-text.h | 5 ++++ doc/reference/clutter/clutter-sections.txt | 1 + 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 856b7df1b..a3de0b72d 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -477,7 +477,7 @@ clutter_text_coords_to_position (ClutterText *text, return index_ + trailing; } -/* +/** * clutter_text_position_to_coords: * @self: a #ClutterText * @position: position in characters @@ -488,19 +488,28 @@ clutter_text_coords_to_position (ClutterText *text, * Retrieves the coordinates of the given @position. * * Return value: %TRUE if the conversion was successful + * + * Since: 1.0 */ -static gboolean +gboolean clutter_text_position_to_coords (ClutterText *self, gint position, ClutterUnit *x, ClutterUnit *y, ClutterUnit *line_height) { - ClutterTextPrivate *priv = self->priv; + ClutterTextPrivate *priv; PangoRectangle rect; gint password_char_bytes = 1; gint index_; + g_return_val_if_fail (CLUTTER_IS_TEXT (self), FALSE); + + priv = self->priv; + + if (position < -1 || position > priv->n_chars) + return FALSE; + if (priv->password_char != 0) password_char_bytes = g_unichar_to_utf8 (priv->password_char, NULL); @@ -527,7 +536,13 @@ clutter_text_position_to_coords (ClutterText *self, &rect, NULL); if (x) - *x = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.x); + { + *x = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.x); + + /* Take any offset due to scrolling into account */ + if (priv->single_line_mode) + *x += priv->text_x; + } if (y) *y = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.y); @@ -535,16 +550,6 @@ clutter_text_position_to_coords (ClutterText *self, if (line_height) *line_height = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.height); - if (self->priv->single_line_mode) - { - /* Take any offset due to scrolling into account */ - if (x) - *x += self->priv->text_x; - } - - - - /* FIXME: should return false if coords were outside text */ return TRUE; } diff --git a/clutter/clutter-text.h b/clutter/clutter-text.h index 01b058cf7..f34ff967a 100644 --- a/clutter/clutter-text.h +++ b/clutter/clutter-text.h @@ -198,6 +198,11 @@ void clutter_text_set_single_line_mode (ClutterText *sel gboolean clutter_text_get_single_line_mode (ClutterText *self); gboolean clutter_text_activate (ClutterText *self); +gboolean clutter_text_position_to_coords (ClutterText *self, + gint position, + gfloat *x, + gfloat *y, + gfloat *line_height); G_END_DECLS diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index fcfc97ebb..9cebff45d 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1599,6 +1599,7 @@ clutter_text_get_cursor_size clutter_text_activate +clutter_text_position_to_coords CLUTTER_IS_TEXT From 2f5012e38cd6566d01b98fb44679c9b431dbd473 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 7 May 2009 18:39:07 +0100 Subject: [PATCH 56/66] [animation] Do not leak timelines The timeline created when calling set_timeline(NULL) is referenced even though we implicitly own it. When the Animation is destroyed, the timeline is then leaked. Thanks to: Richard Heatley Fixes bug: http://bugzilla.openedhand.com/show_bug.cgi?id=1548 --- clutter/clutter-animation.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/clutter/clutter-animation.c b/clutter/clutter-animation.c index d835694b4..6eb7d85f3 100644 --- a/clutter/clutter-animation.c +++ b/clutter/clutter-animation.c @@ -1115,12 +1115,12 @@ clutter_animation_set_timeline (ClutterAnimation *animation, priv = animation->priv; - if (timeline && priv->timeline == timeline) + if (timeline != NULL && priv->timeline == timeline) return; g_object_freeze_notify (G_OBJECT (animation)); - if (priv->timeline) + if (priv->timeline != NULL) { if (priv->timeline_started_id) g_signal_handler_disconnect (priv->timeline, @@ -1136,13 +1136,17 @@ clutter_animation_set_timeline (ClutterAnimation *animation, priv->timeline = 0; } - if (!timeline) - timeline = g_object_new (CLUTTER_TYPE_TIMELINE, - "duration", priv->duration, - "loop", priv->loop, - NULL); + if (timeline == NULL) + { + timeline = g_object_new (CLUTTER_TYPE_TIMELINE, + "duration", priv->duration, + "loop", priv->loop, + NULL); + } else { + g_object_ref (timeline); + priv->duration = clutter_timeline_get_duration (timeline); g_object_notify (G_OBJECT (animation), "duration"); @@ -1150,7 +1154,7 @@ clutter_animation_set_timeline (ClutterAnimation *animation, g_object_notify (G_OBJECT (animation), "loop"); } - priv->timeline = g_object_ref (timeline); + priv->timeline = timeline; g_object_notify (G_OBJECT (animation), "timeline"); priv->timeline_started_id = From 08ac50faaeca28703e3f5495c76a72edca3c17f0 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 14 May 2009 19:51:03 +0100 Subject: [PATCH 57/66] [build] List cogl-internal.h During the Makefile clean up, cogl-internal.h got lost and this broke the dist. Let's put it back in. --- clutter/cogl/common/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clutter/cogl/common/Makefile.am b/clutter/cogl/common/Makefile.am index a4f0bfbb7..d3f836093 100644 --- a/clutter/cogl/common/Makefile.am +++ b/clutter/cogl/common/Makefile.am @@ -2,6 +2,7 @@ INCLUDES = \ -I$(top_srcdir) \ -I$(top_srcdir)/clutter \ -I$(top_srcdir)/clutter/cogl \ + -I$(top_srcdir)/clutter/cogl/common \ -I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \ -I$(top_builddir)/clutter \ -I$(top_builddir)/clutter/cogl \ @@ -19,6 +20,7 @@ EXTRA_DIST = stb_image.c libclutter_cogl_common_la_SOURCES = \ cogl-handle.h \ + cogl-internal.h \ cogl.c \ cogl-util.h \ cogl-util.c \ From cd3acca2b793c45c81ea4fdc053f82aa2b0ffe21 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 14 May 2009 23:23:00 +0100 Subject: [PATCH 58/66] [build] Link Cogl against -lm We use math routines inside Cogl, so it's correct to have it in the LIBADD line. In normal usage something else was pulling in -lm, but the introspection is relying on linking against the convenience library. Based on a patch by: Colin Walters Signed-off-by: Emmanuele Bassi --- clutter/cogl/common/Makefile.am | 10 +++------- clutter/cogl/gl/Makefile.am | 9 +++------ clutter/cogl/gles/Makefile.am | 13 ++++--------- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/clutter/cogl/common/Makefile.am b/clutter/cogl/common/Makefile.am index d3f836093..47d24199b 100644 --- a/clutter/cogl/common/Makefile.am +++ b/clutter/cogl/common/Makefile.am @@ -7,17 +7,13 @@ INCLUDES = \ -I$(top_builddir)/clutter \ -I$(top_builddir)/clutter/cogl \ -DG_LOG_DOMAIN=\"Cogl-Common\" \ - -DCLUTTER_COMPILATION \ - $(CLUTTER_CFLAGS) \ - $(CLUTTER_DEBUG_CFLAGS) \ - $(MAINTAINER_CFLAGS) \ - $(GCC_FLAGS) - -LDADD = $(CLUTTER_LIBS) + -DCLUTTER_COMPILATION noinst_LTLIBRARIES = libclutter-cogl-common.la EXTRA_DIST = stb_image.c +libclutter_cogl_common_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) +libclutter_cogl_common_la_LIBADD = -lm $(CLUTTER_LIBS) libclutter_cogl_common_la_SOURCES = \ cogl-handle.h \ cogl-internal.h \ diff --git a/clutter/cogl/gl/Makefile.am b/clutter/cogl/gl/Makefile.am index 4d360e63d..0e251f457 100644 --- a/clutter/cogl/gl/Makefile.am +++ b/clutter/cogl/gl/Makefile.am @@ -51,12 +51,11 @@ INCLUDES = \ -DG_LOG_DOMAIN=\"Cogl-GL\" \ -DCLUTTER_COMPILATION -AM_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) - -LDADD = $(CLUTTER_LIBS) - noinst_LTLIBRARIES = libclutter-cogl.la +libclutter_cogl_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) +libclutter_cogl_la_LIBADD = -lm $(CLUTTER_LIBS) $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la +libclutter_cogl_la_DEPENDENCIES = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la libclutter_cogl_la_SOURCES = \ $(top_builddir)/clutter/cogl/cogl.h \ $(cogl_headers) \ @@ -65,5 +64,3 @@ libclutter_cogl_la_SOURCES = \ $(NULL) EXTRA_DIST = cogl-defines.h.in - -libclutter_cogl_la_LIBADD = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la diff --git a/clutter/cogl/gles/Makefile.am b/clutter/cogl/gles/Makefile.am index 409f655b8..5a2b8e429 100644 --- a/clutter/cogl/gles/Makefile.am +++ b/clutter/cogl/gles/Makefile.am @@ -25,16 +25,13 @@ INCLUDES = \ -I$(top_builddir)/clutter \ -I$(top_builddir)/clutter/cogl \ -DG_LOG_DOMAIN=\"Cogl-GLES\" \ - -DCLUTTER_COMPILATION \ - $(CLUTTER_CFLAGS) \ - $(CLUTTER_DEBUG_CFLAGS) \ - $(MAINTAINER_CFLAGS) \ - $(GCC_FLAGS) - -LDADD = $(CLUTTER_LIBS) + -DCLUTTER_COMPILATION noinst_LTLIBRARIES = libclutter-cogl.la +libclutter_cogl_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) +libclutter_cogl_la_LIBADD = -lm $(CLUTTER_LIBS) $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la +libclutter_cogl_la_DEPENDENCIES = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la libclutter_cogl_la_SOURCES = \ $(top_builddir)/clutter/cogl/cogl.h \ $(top_builddir)/clutter/cogl/cogl-defines-gles.h \ @@ -77,8 +74,6 @@ EXTRA_DIST = cogl-defines.h.in \ cogl-fixed-vertex-shader.glsl \ cogl-fixed-fragment-shader.glsl -libclutter_cogl_la_LIBADD = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la - .glsl.h : /bin/sh $(top_srcdir)/clutter/cogl/gles/stringify.sh -h $< From e725bd21bf6b0760ed099b6e7136765774cf2093 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 19 May 2009 12:53:37 +0100 Subject: [PATCH 59/66] [gitignore] Add more gtk-doc droppings --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c78e8bd95..97fd50282 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,7 @@ doc/reference/clutter/clutter.interfaces doc/reference/clutter/clutter.prerequisites doc/reference/clutter/clutter.signals doc/reference/clutter/*.stamp +doc/reference/clutter/*.bak doc/reference/cogl/cogl-*.txt !/doc/reference/cogl/cogl-sections.txt doc/reference/cogl/html @@ -55,6 +56,7 @@ doc/reference/cogl/cogl.interfaces doc/reference/cogl/cogl.prerequisites doc/reference/cogl/cogl.signals doc/reference/cogl/*.stamp +doc/reference/cogl/*.bak doltcompile doltlibtool gtk-doc.make From 3115a6168836ff65ce58c31458d7672400458d74 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 18 May 2009 19:38:03 +0100 Subject: [PATCH 60/66] [cogl] Rework the GL-error-to-string conversion The code for the conversion of the GL error enumeration code into a string is not following the code style and conventions we follow in Clutter and COGL. The GE() macro is also using fprintf(stderr) directly instead of using g_warning() -- which is redirectable to an alternative logging system using the g_log* API. --- clutter/cogl/common/cogl-internal.h | 20 +++++------ clutter/cogl/common/cogl.c | 52 +++++++++++++++-------------- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/clutter/cogl/common/cogl-internal.h b/clutter/cogl/common/cogl-internal.h index 595242168..6e7867e81 100644 --- a/clutter/cogl/common/cogl-internal.h +++ b/clutter/cogl/common/cogl-internal.h @@ -55,17 +55,17 @@ typedef struct _CoglBoxedValue #include -const char *_cogl_error_string(GLenum errorCode); +const gchar *cogl_gl_error_to_string (GLenum error_code); -#define GE(x...) G_STMT_START { \ - GLenum err; \ - (x); \ - while ((err = glGetError()) != GL_NO_ERROR) { \ - fprintf(stderr, "glError: %s caught at %s:%u\n", \ - (char *)_cogl_error_string(err), \ - __FILE__, __LINE__); \ - } \ -} G_STMT_END +#define GE(x...) G_STMT_START { \ + GLenum __err; \ + (x); \ + while ((err = glGetError ()) != GL_NO_ERROR) \ + { \ + g_warning ("%s: GL error (%d): %s\n", \ + G_STRLOC, \ + cogl_gl_error_to_string (err));\ + } } G_STMT_END #else /* COGL_DEBUG */ diff --git a/clutter/cogl/common/cogl.c b/clutter/cogl/common/cogl.c index e6341a8ac..f002231d7 100644 --- a/clutter/cogl/common/cogl.c +++ b/clutter/cogl/common/cogl.c @@ -46,39 +46,41 @@ typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName); #include "cogl-gles2-wrapper.h" #endif +#ifdef COGL_DEBUG /* GL error to string conversion */ -#if COGL_DEBUG -struct token_string -{ - GLuint Token; - const char *String; -}; +static const struct { + GLuint error_code; + const gchar *error_string; +} gl_errors[] = { + { GL_NO_ERROR, "No error" }, + { GL_INVALID_ENUM, "Invalid enumeration value" }, + { GL_INVALID_VALUE, "Invalid value" }, + { GL_INVALID_OPERATION, "Invalid operation" }, + { GL_STACK_OVERFLOW, "Stack overflow" }, + { GL_STACK_UNDERFLOW, "Stack underflow" }, + { GL_OUT_OF_MEMORY, "Out of memory" }, -static const struct token_string Errors[] = { - { GL_NO_ERROR, "no error" }, - { GL_INVALID_ENUM, "invalid enumerant" }, - { GL_INVALID_VALUE, "invalid value" }, - { GL_INVALID_OPERATION, "invalid operation" }, - { GL_STACK_OVERFLOW, "stack overflow" }, - { GL_STACK_UNDERFLOW, "stack underflow" }, - { GL_OUT_OF_MEMORY, "out of memory" }, #ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT - { GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "invalid framebuffer operation" }, + { GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "Invalid framebuffer operation" } #endif - { ~0, NULL } }; -const char* -_cogl_error_string(GLenum errorCode) +static const guint n_gl_errors = G_N_ELEMENTS (gl_errors); + +const gchar * +cogl_gl_error_to_string (GLenum error_code) { - int i; - for (i = 0; Errors[i].String; i++) { - if (Errors[i].Token == errorCode) - return Errors[i].String; - } - return "unknown"; + gint i; + + for (i = 0; i < n_gl_errors; i++) + { + if (gl_errors[i].error_code == error_code) + return gl_errors[i].error_string; + } + + return "Unknown error"; } -#endif +#endif /* COGL_DEBUG */ void cogl_clear (const CoglColor *color, gulong buffers) From 407ac5075fb5737aff3730773ec9ccba2dbe7fd0 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 19 May 2009 12:51:29 +0100 Subject: [PATCH 61/66] [texture] Add missing accessors ClutterTexture has many properties that can only be accessed using the GObject API. This is fairly inefficient and makes binding the class overly complicated. The Texture class should have accessor methods for all its properties, properly documented. --- clutter/clutter-texture.c | 453 +++++++++++++++++---- clutter/clutter-texture.h | 45 +- doc/reference/clutter/clutter-sections.txt | 13 + 3 files changed, 429 insertions(+), 82 deletions(-) diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index cce419482..918e3c110 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -783,83 +783,83 @@ clutter_texture_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - ClutterTexture *texture; + ClutterTexture *texture; ClutterTexturePrivate *priv; - texture = CLUTTER_TEXTURE(object); + texture = CLUTTER_TEXTURE (object); priv = texture->priv; switch (prop_id) { case PROP_MAX_TILE_WASTE: - clutter_texture_set_max_tile_waste (texture, - g_value_get_int (value)); + clutter_texture_set_max_tile_waste (texture, g_value_get_int (value)); break; + case PROP_SYNC_SIZE: - priv->sync_actor_size = g_value_get_boolean (value); - clutter_actor_queue_relayout (CLUTTER_ACTOR (texture)); + clutter_texture_set_sync_size (texture, g_value_get_boolean (value)); break; + case PROP_REPEAT_X: - if (priv->repeat_x != g_value_get_boolean (value)) - { - priv->repeat_x = !priv->repeat_x; - if (CLUTTER_ACTOR_IS_VISIBLE (texture)) - clutter_actor_queue_redraw (CLUTTER_ACTOR (texture)); - } + clutter_texture_set_repeat (texture, + g_value_get_boolean (value), + priv->repeat_y); break; + case PROP_REPEAT_Y: - if (priv->repeat_y != g_value_get_boolean (value)) - { - priv->repeat_y = !priv->repeat_y; - if (CLUTTER_ACTOR_IS_VISIBLE (texture)) - clutter_actor_queue_redraw (CLUTTER_ACTOR (texture)); - } + clutter_texture_set_repeat (texture, + priv->repeat_x, + g_value_get_boolean (value)); break; + case PROP_FILTER_QUALITY: clutter_texture_set_filter_quality (texture, g_value_get_enum (value)); break; + case PROP_COGL_TEXTURE: - clutter_texture_set_cogl_texture - (texture, (CoglHandle) g_value_get_boxed (value)); + { + CoglHandle hnd = g_value_get_boxed (value); + + clutter_texture_set_cogl_texture (texture, hnd); + } break; -#if EXPOSE_COGL_MATERIAL_PROP + case PROP_COGL_MATERIAL: - clutter_texture_set_cogl_material - (texture, (CoglHandle) g_value_get_boxed (value)); + { + CoglHandle hnd = g_value_get_boxed (value); + + clutter_texture_set_cogl_material (texture, hnd); + } break; -#endif + case PROP_FILENAME: clutter_texture_set_from_file (texture, g_value_get_string (value), NULL); break; + case PROP_NO_SLICE: priv->no_slice = g_value_get_boolean (value); break; + case PROP_KEEP_ASPECT_RATIO: - priv->keep_aspect_ratio = g_value_get_boolean (value); - clutter_actor_queue_relayout (CLUTTER_ACTOR (object)); + clutter_texture_set_keep_aspect_ratio (texture, + g_value_get_boolean (value)); break; + case PROP_LOAD_DATA_ASYNC: - if (g_value_get_boolean (value)) - { - priv->load_async_set = TRUE; - priv->load_data_async = TRUE; - } + clutter_texture_set_load_data_async (texture, + g_value_get_boolean (value)); break; + case PROP_LOAD_ASYNC: - if (g_value_get_boolean (value)) - { - priv->load_data_async = TRUE; - priv->load_async_set = TRUE; - priv->load_size_async = TRUE; - } + clutter_texture_set_load_async (texture, g_value_get_boolean (value)); break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; - } + } } static void @@ -870,7 +870,6 @@ clutter_texture_get_property (GObject *object, { ClutterTexture *texture; ClutterTexturePrivate *priv; - CoglHandle cogl_texture; texture = CLUTTER_TEXTURE(object); priv = texture->priv; @@ -880,37 +879,43 @@ clutter_texture_get_property (GObject *object, case PROP_MAX_TILE_WASTE: g_value_set_int (value, clutter_texture_get_max_tile_waste (texture)); break; + case PROP_PIXEL_FORMAT: - cogl_texture = clutter_texture_get_cogl_texture (texture); - if (cogl_texture == COGL_INVALID_HANDLE) - g_value_set_int (value, COGL_PIXEL_FORMAT_ANY); - else - g_value_set_int (value, cogl_texture_get_format (cogl_texture)); + g_value_set_enum (value, clutter_texture_get_pixel_format (texture)); break; + case PROP_SYNC_SIZE: g_value_set_boolean (value, priv->sync_actor_size); break; + case PROP_REPEAT_X: g_value_set_boolean (value, priv->repeat_x); break; + case PROP_REPEAT_Y: g_value_set_boolean (value, priv->repeat_y); break; + case PROP_FILTER_QUALITY: g_value_set_enum (value, clutter_texture_get_filter_quality (texture)); break; + case PROP_COGL_TEXTURE: g_value_set_boxed (value, clutter_texture_get_cogl_texture (texture)); break; + case PROP_COGL_MATERIAL: g_value_set_boxed (value, clutter_texture_get_cogl_material (texture)); break; + case PROP_NO_SLICE: g_value_set_boolean (value, priv->no_slice); break; + case PROP_KEEP_ASPECT_RATIO: g_value_set_boolean (value, priv->keep_aspect_ratio); break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -920,11 +925,8 @@ clutter_texture_get_property (GObject *object, static void clutter_texture_class_init (ClutterTextureClass *klass) { - GObjectClass *gobject_class; - ClutterActorClass *actor_class; - - gobject_class = (GObjectClass*) klass; - actor_class = (ClutterActorClass*) klass; + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); g_type_class_add_private (klass, sizeof (ClutterTexturePrivate)); @@ -1003,13 +1005,12 @@ clutter_texture_class_init (ClutterTextureClass *klass) g_object_class_install_property (gobject_class, PROP_PIXEL_FORMAT, - g_param_spec_int ("pixel-format", - "Texture pixel format", - "CoglPixelFormat to use.", - 0, - G_MAXINT, - COGL_PIXEL_FORMAT_RGBA_8888, - G_PARAM_READABLE)); + g_param_spec_enum ("pixel-format", + "Texture pixel format", + "CoglPixelFormat to use.", + COGL_TYPE_PIXEL_FORMAT, + COGL_PIXEL_FORMAT_RGBA_8888, + CLUTTER_PARAM_READABLE)); g_object_class_install_property (gobject_class, PROP_COGL_TEXTURE, @@ -2159,27 +2160,19 @@ clutter_texture_new (void) /** * clutter_texture_get_base_size: - * @texture: A #ClutterTexture - * @width: Pointer to gint to be populated with width value if non NULL. - * @height: Pointer to gint to be populated with height value if non NULL. + * @texture: a #ClutterTexture + * @width: (out): return location for the width, or %NULL + * @height: (out): return location for the height, or %NULL * - * Gets the size in pixels of the untransformed underlying texture pixbuf data. - * - **/ -void /* FIXME: rename to get_image_size */ + * Gets the size in pixels of the untransformed underlying image + */ +void clutter_texture_get_base_size (ClutterTexture *texture, gint *width, gint *height) { g_return_if_fail (CLUTTER_IS_TEXTURE (texture)); - /* Attempt to realize, mainly for subclasses ( such as labels ) - * which may not create pixbuf data and thus base size until - * realization happens. - */ - if (!CLUTTER_ACTOR_IS_REALIZED (texture)) - clutter_actor_realize (CLUTTER_ACTOR (texture)); - if (width) *width = texture->priv->width; @@ -2562,3 +2555,323 @@ texture_fbo_free_resources (ClutterTexture *texture) priv->fbo_handle = COGL_INVALID_HANDLE; } } + +/** + * clutter_texture_set_sync_size: + * @texture: a #ClutterTexture + * @sync_size: %TRUE if the texture should have the same size of the + * underlying image data + * + * Sets whether @texture should have the same preferred size as the + * underlying image data. + * + * Since: 1.0 + */ +void +clutter_texture_set_sync_size (ClutterTexture *texture, + gboolean sync_size) +{ + ClutterTexturePrivate *priv; + + g_return_if_fail (CLUTTER_IS_TEXTURE (texture)); + + priv = texture->priv; + + if (priv->sync_actor_size != sync_size) + { + priv->sync_actor_size = sync_size; + + clutter_actor_queue_relayout (CLUTTER_ACTOR (texture)); + + g_object_notify (G_OBJECT (texture), "sync-size"); + } +} + +/** + * clutter_texture_get_sync_size: + * @texture: a #ClutterTexture + * + * Retrieves the value set with clutter_texture_get_sync_size() + * + * Return value: %TRUE if the #ClutterTexture should have the same + * preferred size of the underlying image data + * + * Since: 1.0 + */ +gboolean +clutter_texture_get_sync_size (ClutterTexture *texture) +{ + g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), FALSE); + + return texture->priv->sync_actor_size; +} + +/** + * clutter_texture_set_repeat: + * @texture: a #ClutterTexture + * @repeat_x: %TRUE if the texture should repeat horizontally + * @repeat_y: %TRUE if the texture should repeat vertically + * + * Sets whether the @texture should repeat horizontally or + * vertically when the actor size is bigger than the image size + * + * Since: 1.0 + */ +void +clutter_texture_set_repeat (ClutterTexture *texture, + gboolean repeat_x, + gboolean repeat_y) +{ + ClutterTexturePrivate *priv; + gboolean changed = FALSE; + + g_return_if_fail (CLUTTER_IS_TEXTURE (texture)); + + priv = texture->priv; + + g_object_freeze_notify (G_OBJECT (texture)); + + if (priv->repeat_x != repeat_x) + { + priv->repeat_x = repeat_x; + + g_object_notify (G_OBJECT (texture), "repeat-x"); + + changed = TRUE; + } + + if (priv->repeat_y != repeat_y) + { + priv->repeat_y = repeat_y; + + g_object_notify (G_OBJECT (texture), "repeat-y"); + + changed = TRUE; + } + + if (changed) + clutter_actor_queue_redraw (CLUTTER_ACTOR (texture)); + + g_object_thaw_notify (G_OBJECT (texture)); +} + +/** + * clutter_texture_get_repeat: + * @texture: a #ClutterTexture + * @repeat_x: (out): return location for the horizontal repeat + * @repeat_y: (out): return location for the vertical repeat + * + * Retrieves the horizontal and vertical repeat values set + * using clutter_texture_set_repeat() + * + * Since: 1.0 + */ +void +clutter_texture_get_repeat (ClutterTexture *texture, + gboolean *repeat_x, + gboolean *repeat_y) +{ + g_return_if_fail (CLUTTER_IS_TEXTURE (texture)); + + if (repeat_x != NULL) + *repeat_x = texture->priv->repeat_x; + + if (repeat_y != NULL) + *repeat_y = texture->priv->repeat_y; +} + +/** + * clutter_texture_get_pixel_format: + * @texture: a #ClutterTexture + * + * Retrieves the pixel format used by @texture. This is + * equivalent to: + * + * |[ + * handle = clutter_texture_get_pixel_format (texture); + * + * if (handle != COGL_INVALID_HANDLE) + * format = cogl_texture_get_format (handle); + * ]| + * + * Return value: a #CoglPixelFormat value + * + * Since: 1.0 + */ +CoglPixelFormat +clutter_texture_get_pixel_format (ClutterTexture *texture) +{ + CoglHandle cogl_texture; + + g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), COGL_PIXEL_FORMAT_ANY); + + cogl_texture = clutter_texture_get_cogl_texture (texture); + if (cogl_texture == COGL_INVALID_HANDLE) + return COGL_PIXEL_FORMAT_ANY; + + return cogl_texture_get_format (cogl_texture); +} + +/** + * clutter_texture_set_keep_aspect_ratio: + * @texture: a #ClutterTexture + * @keep_aspect: %TRUE to maintain aspect ratio + * + * Sets whether @texture should have a preferred size maintaining + * the aspect ratio of the underlying image + * + * Since: 1.0 + */ +void +clutter_texture_set_keep_aspect_ratio (ClutterTexture *texture, + gboolean keep_aspect) +{ + ClutterTexturePrivate *priv; + + g_return_if_fail (CLUTTER_IS_TEXTURE (texture)); + + priv = texture->priv; + + if (priv->keep_aspect_ratio != keep_aspect) + { + priv->keep_aspect_ratio = keep_aspect; + + clutter_actor_queue_relayout (CLUTTER_ACTOR (texture)); + + g_object_notify (G_OBJECT (texture), "keep-aspect-ratio"); + } +} + +/** + * clutter_texture_get_keep_aspect_ratio: + * @texture: a #ClutterTexture + * + * Retrieves the value set using clutter_texture_get_keep_aspect_ratio() + * + * Return value: %TRUE if the #ClutterTexture should maintain the + * aspect ratio of the underlying image + * + * Since: 1.0 + */ +gboolean +clutter_texture_get_keep_aspect_ratio (ClutterTexture *texture) +{ + g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), FALSE); + + return texture->priv->keep_aspect_ratio; +} + +/** + * clutter_texture_set_load_async: + * @texture: a #ClutterTexture + * @load_sync: %TRUE if the texture should asynchronously load data + * from a filename + * + * Sets whether @texture should use a worker thread to load the data + * from disk asynchronously. Setting @load_async to %TRUE will make + * clutter_texture_set_from_file() return immediately. + * + * See the #ClutterTexture:load-async property documentation, and + * clutter_texture_set_load_data_async(). + * + * Since: 1.0 + */ +void +clutter_texture_set_load_async (ClutterTexture *texture, + gboolean load_async) +{ + ClutterTexturePrivate *priv; + + g_return_if_fail (CLUTTER_IS_TEXTURE (texture)); + + priv = texture->priv; + + if (priv->load_async_set != load_async) + { + priv->load_data_async = load_async; + priv->load_size_async = load_async; + + priv->load_async_set = load_async; + + g_object_notify (G_OBJECT (texture), "load-async"); + g_object_notify (G_OBJECT (texture), "load-data-async"); + } +} + +/** + * clutter_texture_get_load_async: + * @texture: a #ClutterTexture + * + * Retrieves the value set using clutter_texture_get_load_async() + * + * Return value: %TRUE if the #ClutterTexture should load the data from + * disk asynchronously + * + * Since: 1.0 + */ +gboolean +clutter_texture_get_load_async (ClutterTexture *texture) +{ + g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), FALSE); + + return texture->priv->load_async_set; +} + +/** + * clutter_texture_set_load_data_async: + * @texture: a #ClutterTexture + * @load_async: %TRUE if the texture should asynchronously load data + * from a filename + * + * Sets whether @texture should use a worker thread to load the data + * from disk asynchronously. Setting @load_async to %TRUE will make + * clutter_texture_set_from_file() block until the #ClutterTexture has + * determined the width and height of the image data. + * + * See the #ClutterTexture:load-async property documentation, and + * clutter_texture_set_load_async(). + * + * Since: 1.0 + */ +void +clutter_texture_set_load_data_async (ClutterTexture *texture, + gboolean load_async) +{ + ClutterTexturePrivate *priv; + + g_return_if_fail (CLUTTER_IS_TEXTURE (texture)); + + priv = texture->priv; + + if (priv->load_data_async != load_async) + { + /* load-data-async always unsets load-size-async */ + priv->load_data_async = load_async; + priv->load_size_async = FALSE; + + priv->load_async_set = load_async; + + g_object_notify (G_OBJECT (texture), "load-async"); + g_object_notify (G_OBJECT (texture), "load-data-async"); + } +} + +/** + * clutter_texture_get_load_data_async: + * @texture: a #ClutterTexture + * + * Retrieves the value set by clutter_texture_set_load_data_async() + * + * Return value: %TRUE if the #ClutterTexture should load the image + * data from a file asynchronously + * + * Since: 1.0 + */ +gboolean +clutter_texture_get_load_data_async (ClutterTexture *texture) +{ + g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), FALSE); + + return texture->priv->load_async_set && + texture->priv->load_data_async; +} diff --git a/clutter/clutter-texture.h b/clutter/clutter-texture.h index 466e5f8c6..1049910f1 100644 --- a/clutter/clutter-texture.h +++ b/clutter/clutter-texture.h @@ -10,7 +10,7 @@ * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -105,12 +105,12 @@ struct _ClutterTextureClass ClutterActorClass parent_class; /*< public >*/ - void (*size_change) (ClutterTexture *texture, - gint width, - gint height); - void (*pixbuf_change) (ClutterTexture *texture); - void (*load_finished) (ClutterTexture *texture, - GError *error); + void (* size_change) (ClutterTexture *texture, + gint width, + gint height); + void (* pixbuf_change) (ClutterTexture *texture); + void (* load_finished) (ClutterTexture *texture, + const GError *error); /*< private >*/ /* padding, for future expansion */ @@ -123,6 +123,7 @@ struct _ClutterTextureClass /** * ClutterTextureFlags: + * @CLUTTER_TEXTURE_NONE: No flags * @CLUTTER_TEXTURE_RGB_FLAG_BGR: FIXME * @CLUTTER_TEXTURE_RGB_FLAG_PREMULT: FIXME * @CLUTTER_TEXTURE_YUV_FLAG_YUV2: FIXME @@ -133,11 +134,12 @@ struct _ClutterTextureClass * Since: 0.4 */ typedef enum { /*< prefix=CLUTTER_TEXTURE >*/ - CLUTTER_TEXTURE_RGB_FLAG_BGR = 1 << 1, - CLUTTER_TEXTURE_RGB_FLAG_PREMULT = 1 << 2, /* FIXME: not handled */ - CLUTTER_TEXTURE_YUV_FLAG_YUV2 = 1 << 3 + CLUTTER_TEXTURE_NONE = 0, + CLUTTER_TEXTURE_RGB_FLAG_BGR = 1 << 1, + CLUTTER_TEXTURE_RGB_FLAG_PREMULT = 1 << 2, /* FIXME: not handled */ + CLUTTER_TEXTURE_YUV_FLAG_YUV2 = 1 << 3 - /* FIXME: add compressed types ? */ + /* FIXME: add compressed types ? */ } ClutterTextureFlags; /** @@ -154,7 +156,7 @@ typedef enum { /*< prefix=CLUTTER_TEXTURE >*/ * Since: 0.8 */ typedef enum { /*< prefix=CLUTTER_TEXTURE_QUALITY >*/ - CLUTTER_TEXTURE_QUALITY_LOW = 0, + CLUTTER_TEXTURE_QUALITY_LOW, CLUTTER_TEXTURE_QUALITY_MEDIUM, CLUTTER_TEXTURE_QUALITY_HIGH } ClutterTextureQuality; @@ -209,6 +211,25 @@ void clutter_texture_set_cogl_texture (ClutterTexture CoglHandle clutter_texture_get_cogl_material (ClutterTexture *texture); void clutter_texture_set_cogl_material (ClutterTexture *texture, CoglHandle cogl_material); +void clutter_texture_set_sync_size (ClutterTexture *texture, + gboolean sync_size); +gboolean clutter_texture_get_sync_size (ClutterTexture *texture); +void clutter_texture_set_repeat (ClutterTexture *texture, + gboolean repeat_x, + gboolean repeat_y); +void clutter_texture_get_repeat (ClutterTexture *texture, + gboolean *repeat_x, + gboolean *repeat_y); +CoglPixelFormat clutter_texture_get_pixel_format (ClutterTexture *texture); +void clutter_texture_set_keep_aspect_ratio (ClutterTexture *texture, + gboolean keep_aspect); +gboolean clutter_texture_get_keep_aspect_ratio (ClutterTexture *texture); +void clutter_texture_set_load_async (ClutterTexture *texture, + gboolean load_async); +gboolean clutter_texture_get_load_async (ClutterTexture *texture); +void clutter_texture_set_load_data_async (ClutterTexture *texture, + gboolean load_async); +gboolean clutter_texture_get_load_data_async (ClutterTexture *texture); G_END_DECLS diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 9cebff45d..8aefb9350 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -448,6 +448,8 @@ ClutterTextureQuality clutter_texture_new clutter_texture_new_from_file clutter_texture_new_from_actor + + CLUTTER_TEXTURE_ERROR ClutterTextureError clutter_texture_set_from_file @@ -455,6 +457,7 @@ clutter_texture_set_from_rgb_data clutter_texture_set_from_yuv_data clutter_texture_set_area_from_rgb_data clutter_texture_get_base_size +clutter_texture_get_pixel_format clutter_texture_get_filter_quality clutter_texture_set_filter_quality clutter_texture_get_max_tile_waste @@ -463,6 +466,16 @@ clutter_texture_get_cogl_texture clutter_texture_set_cogl_texture clutter_texture_get_cogl_material clutter_texture_set_cogl_material +clutter_texture_get_sync_size +clutter_texture_set_sync_size +clutter_texture_get_repeat +clutter_texture_set_repeat +clutter_texture_get_keep_aspect_ratio +clutter_texture_set_keep_aspect_ratio +clutter_texture_get_load_async +clutter_texture_set_load_async +clutter_texture_get_load_data_async +clutter_texture_set_load_data_async CLUTTER_TEXTURE From 529e48fbbe95f9fe2d8db631b129391d9c2f36c9 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 19 May 2009 14:42:37 +0100 Subject: [PATCH 62/66] Remove duplicate cogl-internal.h header The cogl-internal.h header has been moved inside cogl/common in commit 8a1b4f8326 but has been left behind inside cogl/gl and cogl/gles. --- clutter/cogl/gl/Makefile.am | 1 - clutter/cogl/gl/cogl-internal.h | 66 ---------------------- clutter/cogl/gles/Makefile.am | 1 - clutter/cogl/gles/cogl-internal.h | 93 ------------------------------- 4 files changed, 161 deletions(-) delete mode 100644 clutter/cogl/gl/cogl-internal.h delete mode 100644 clutter/cogl/gles/cogl-internal.h diff --git a/clutter/cogl/gl/Makefile.am b/clutter/cogl/gl/Makefile.am index 0e251f457..26fadc42c 100644 --- a/clutter/cogl/gl/Makefile.am +++ b/clutter/cogl/gl/Makefile.am @@ -18,7 +18,6 @@ cogl_headers = \ $(NULL) cogl_priv_headers = \ - cogl-internal.h \ cogl-texture-private.h \ cogl-fbo.h \ cogl-shader-private.h \ diff --git a/clutter/cogl/gl/cogl-internal.h b/clutter/cogl/gl/cogl-internal.h deleted file mode 100644 index 0e83e7a52..000000000 --- a/clutter/cogl/gl/cogl-internal.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Cogl - * - * An object oriented GL/GLES Abstraction/Utility Layer - * - * Copyright (C) 2007,2008,2009 Intel Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __COGL_INTERNAL_H -#define __COGL_INTERNAL_H - -#define COGL_DEBUG 0 - -#if COGL_DEBUG - -#include - -const char *_cogl_error_string(GLenum errorCode); - -#define GE(x...) G_STMT_START { \ - GLenum err; \ - (x); \ - while ((err = glGetError()) != GL_NO_ERROR) { \ - fprintf(stderr, "glError: %s caught at %s:%u\n", \ - (char *)_cogl_error_string(err), \ - __FILE__, __LINE__); \ - } \ -} G_STMT_END - -#else /* COGL_DEBUG */ - -#define GE(x) (x) - -#endif /* COGL_DEBUG */ - -#define COGL_ENABLE_BLEND (1<<1) -#define COGL_ENABLE_ALPHA_TEST (1<<2) -#define COGL_ENABLE_VERTEX_ARRAY (1<<3) -#define COGL_ENABLE_COLOR_ARRAY (1<<4) -#define COGL_ENABLE_BACKFACE_CULLING (1<<5) - -gint -_cogl_get_format_bpp (CoglPixelFormat format); - -void -cogl_enable (gulong flags); - -gulong -cogl_get_enable (); - -#endif /* __COGL_INTERNAL_H */ diff --git a/clutter/cogl/gles/Makefile.am b/clutter/cogl/gles/Makefile.am index 5a2b8e429..abebf7275 100644 --- a/clutter/cogl/gles/Makefile.am +++ b/clutter/cogl/gles/Makefile.am @@ -45,7 +45,6 @@ libclutter_cogl_la_SOURCES = \ $(top_builddir)/clutter/cogl/cogl-texture.h \ $(top_builddir)/clutter/cogl/cogl-types.h \ $(top_builddir)/clutter/cogl/cogl-debug.h \ - cogl-internal.h \ cogl-texture-private.h \ cogl-fbo.h \ cogl-context.h \ diff --git a/clutter/cogl/gles/cogl-internal.h b/clutter/cogl/gles/cogl-internal.h deleted file mode 100644 index 6ca9c7a82..000000000 --- a/clutter/cogl/gles/cogl-internal.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Cogl - * - * An object oriented GL/GLES Abstraction/Utility Layer - * - * Copyright (C) 2007,2008,2009 Intel Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __COGL_INTERNAL_H -#define __COGL_INTERNAL_H - -typedef enum { - COGL_BOXED_NONE, - COGL_BOXED_INT, - COGL_BOXED_FLOAT, - COGL_BOXED_MATRIX -} CoglBoxedType; - -typedef struct _CoglBoxedValue -{ - CoglBoxedType type; - int size, count; - gboolean transpose; - - union { - gfloat float_value[4]; - gint int_value[4]; - gfloat matrix[16]; - gfloat *float_array; - gint *int_array; - gpointer array; - } v; -} CoglBoxedValue; - - -#define COGL_DEBUG 0 - -#if COGL_DEBUG - -#include - -const char *_cogl_error_string(GLenum errorCode); - -#define GE(x...) G_STMT_START { \ - GLenum err; \ - (x); \ - while ((err = glGetError()) != GL_NO_ERROR) { \ - fprintf(stderr, "glError: %s caught at %s:%u\n", \ - (char *)_cogl_error_string(err), \ - __FILE__, __LINE__); \ - } \ -} G_STMT_END - -#else /* COGL_DEBUG */ - -#define GE(x) (x) - -#endif /* COGL_DEBUG */ - -#define COGL_ENABLE_BLEND (1<<1) -#define COGL_ENABLE_ALPHA_TEST (1<<2) -#define COGL_ENABLE_VERTEX_ARRAY (1<<3) -#define COGL_ENABLE_COLOR_ARRAY (1<<4) -#define COGL_ENABLE_BACKFACE_CULLING (1<<5) - -void -_cogl_features_init (void); - -gint -_cogl_get_format_bpp (CoglPixelFormat format); - -void -cogl_enable (gulong flags); - -gulong -cogl_get_enable (); - -#endif /* __COGL_INTERNAL_H */ From df1a9b7a74880d60fe1f00a7e35b8b620705701a Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 19 May 2009 14:44:29 +0100 Subject: [PATCH 63/66] [cogl] Rework the debug messages COGL has a debug message system like Clutter's own. In parallel, it also uses a coupld of #defines. Spread around there are also calls to printf() instead to the more correct g_log* wrappers. This commit tries to unify and clean up the macros and the debug message handling inside COGL to be more consistent. --- clutter/cogl/common/cogl-handle.h | 145 ++++++++++++-------------- clutter/cogl/common/cogl-internal.h | 43 ++++---- clutter/cogl/common/cogl-primitives.c | 30 +++--- clutter/cogl/common/cogl.c | 31 ++++-- clutter/cogl/gl/cogl-texture.c | 22 +--- clutter/cogl/gles/cogl-texture.c | 11 -- 6 files changed, 131 insertions(+), 151 deletions(-) diff --git a/clutter/cogl/common/cogl-handle.h b/clutter/cogl/common/cogl-handle.h index 8ca3400af..e1f1e3c8a 100644 --- a/clutter/cogl/common/cogl-handle.h +++ b/clutter/cogl/common/cogl-handle.h @@ -46,65 +46,59 @@ typedef struct _CoglHandleObject /* Helper macro to encapsulate the common code for COGL reference counted handles */ -#if COGL_DEBUG +#ifdef COGL_HANDLE_DEBUG #define _COGL_HANDLE_DEBUG_NEW(type_name, obj) \ - printf ("COGL " G_STRINGIFY (type_name) " NEW %p %i\n", \ + g_debug ("COGL " G_STRINGIFY (type_name) " NEW %p %i\n", \ (obj), (obj)->ref_count) -#define _COGL_HANDLE_DEBUG_REF(type_name, handle) \ - do { \ - CoglHandleObject *obj = (CoglHandleObject *)handle; \ - printf ("COGL %s REF %p %i\n", \ - g_quark_to_string ((obj)->klass->type), \ - (obj), (obj)->ref_count); \ - } while (0) +#define _COGL_HANDLE_DEBUG_REF(type_name, handle) G_STMT_START { \ + CoglHandleObject *__obj = (CoglHandleObject *)handle; \ + g_debug ("COGL %s REF %p %i\n", \ + g_quark_to_string ((__obj)->klass->type), \ + (__obj), (__obj)->ref_count); } G_STMT_END -#define _COGL_HANDLE_DEBUG_UNREF(type_name, handle) \ - do { \ - CoglHandleObject *obj = (CoglHandleObject *)handle; \ - printf ("COGL %s UNREF %p %i\n", \ - g_quark_to_string ((obj)->klass->type), \ - (obj), (obj)->ref_count - 1); \ - } while (0) +#define _COGL_HANDLE_DEBUG_UNREF(type_name, handle) G_STMT_START { \ + CoglHandleObject *__obj = (CoglHandleObject *)handle; \ + g_debug ("COGL %s UNREF %p %i\n", \ + g_quark_to_string ((__obj)->klass->type), \ + (__obj), (__obj)->ref_count - 1); } G_STMT_END -#define COGL_HANDLE_DEBUG_FREE(obj) \ - printf ("COGL %s FREE %p\n", \ - g_quark_to_string ((obj)->klass->type), (obj)) \ +#define COGL_HANDLE_DEBUG_FREE(obj) \ + g_debug ("COGL %s FREE %p\n", g_quark_to_string ((obj)->klass->type), (obj)) -#else /* COGL_DEBUG */ +#else /* !COGL_HANDLE_DEBUG */ #define _COGL_HANDLE_DEBUG_NEW(type_name, obj) #define _COGL_HANDLE_DEBUG_REF(type_name, obj) #define _COGL_HANDLE_DEBUG_UNREF(type_name, obj) #define COGL_HANDLE_DEBUG_FREE(obj) -#endif /* COGL_DEBUG */ +#endif /* COGL_HANDLE_DEBUG */ #define COGL_HANDLE_DEFINE(TypeName, type_name) \ \ - static CoglHandleClass _cogl_##type_name##_class; \ +static CoglHandleClass _cogl_##type_name##_class; \ \ - static GQuark \ - _cogl_##type_name##_get_type (void) \ - { \ - static GQuark type = 0; \ - if (!type) \ - type = g_quark_from_static_string ("Cogl"#TypeName); \ - return type; \ - } \ +static GQuark \ +_cogl_##type_name##_get_type (void) \ +{ \ + static GQuark type = 0; \ + if (!type) \ + type = g_quark_from_static_string ("Cogl"#TypeName); \ + return type; \ +} \ \ - static CoglHandle \ - _cogl_##type_name##_handle_new (Cogl##TypeName *new_obj) \ - { \ - CoglHandleObject *obj = &new_obj->_parent; \ - obj->ref_count = 1; \ +static CoglHandle \ +_cogl_##type_name##_handle_new (Cogl##TypeName *new_obj) \ +{ \ + CoglHandleObject *obj = &new_obj->_parent; \ + obj->ref_count = 1; \ \ - obj->klass = &_cogl_##type_name##_class; \ - if (!obj->klass->type) \ - { \ - obj->klass->type = \ - _cogl_##type_name##_get_type (); \ + obj->klass = &_cogl_##type_name##_class; \ + if (!obj->klass->type) \ + { \ + obj->klass->type = _cogl_##type_name##_get_type (); \ obj->klass->virt_free = _cogl_##type_name##_free; \ } \ \ @@ -112,51 +106,50 @@ typedef struct _CoglHandleObject return (CoglHandle) new_obj; \ } \ \ - Cogl##TypeName * \ - _cogl_##type_name##_pointer_from_handle (CoglHandle handle) \ - { \ - return (Cogl##TypeName *) handle; \ - } \ +Cogl##TypeName * \ +_cogl_##type_name##_pointer_from_handle (CoglHandle handle) \ +{ \ + return (Cogl##TypeName *) handle; \ +} \ \ - gboolean \ - cogl_is_##type_name (CoglHandle handle) \ - { \ - CoglHandleObject *obj = (CoglHandleObject *)handle; \ +gboolean \ +cogl_is_##type_name (CoglHandle handle) \ +{ \ + CoglHandleObject *obj = (CoglHandleObject *)handle; \ \ - if (handle == COGL_INVALID_HANDLE) \ - return FALSE; \ + if (handle == COGL_INVALID_HANDLE) \ + return FALSE; \ \ - return (obj->klass->type == \ - _cogl_##type_name##_get_type ()); \ - } \ + return (obj->klass->type == _cogl_##type_name##_get_type ()); \ +} \ \ - CoglHandle G_GNUC_DEPRECATED \ - cogl_##type_name##_ref (CoglHandle handle) \ - { \ - if (!cogl_is_##type_name (handle)) \ - return COGL_INVALID_HANDLE; \ +CoglHandle G_GNUC_DEPRECATED \ +cogl_##type_name##_ref (CoglHandle handle) \ +{ \ + if (!cogl_is_##type_name (handle)) \ + return COGL_INVALID_HANDLE; \ \ - _COGL_HANDLE_DEBUG_REF (TypeName, handle); \ + _COGL_HANDLE_DEBUG_REF (TypeName, handle); \ \ - cogl_handle_ref (handle); \ + cogl_handle_ref (handle); \ \ - return handle; \ - } \ + return handle; \ +} \ \ - void G_GNUC_DEPRECATED \ - cogl_##type_name##_unref (CoglHandle handle) \ - { \ - if (!cogl_is_##type_name (handle)) \ - { \ - g_warning (G_STRINGIFY (cogl_##type_name##_unref) \ - ": Ignoring unref of Cogl handle " \ - "due to type missmatch"); \ - return; \ - } \ +void G_GNUC_DEPRECATED \ +cogl_##type_name##_unref (CoglHandle handle) \ +{ \ + if (!cogl_is_##type_name (handle)) \ + { \ + g_warning (G_STRINGIFY (cogl_##type_name##_unref) \ + ": Ignoring unref of Cogl handle " \ + "due to type mismatch"); \ + return; \ + } \ \ - _COGL_HANDLE_DEBUG_UNREF (TypeName, handle); \ + _COGL_HANDLE_DEBUG_UNREF (TypeName, handle); \ \ - cogl_handle_unref (handle); \ - } + cogl_handle_unref (handle); \ +} #endif /* __COGL_HANDLE_H */ diff --git a/clutter/cogl/common/cogl-internal.h b/clutter/cogl/common/cogl-internal.h index 6e7867e81..b71de0f7c 100644 --- a/clutter/cogl/common/cogl-internal.h +++ b/clutter/cogl/common/cogl-internal.h @@ -49,29 +49,28 @@ typedef struct _CoglBoxedValue } CoglBoxedValue; #endif -#define COGL_DEBUG 0 +/* XXX - set to 1 to enable checks on every GL call */ +#define COGL_GL_DEBUG 0 -#if COGL_DEBUG - -#include +#if COGL_GL_DEBUG const gchar *cogl_gl_error_to_string (GLenum error_code); -#define GE(x...) G_STMT_START { \ - GLenum __err; \ - (x); \ - while ((err = glGetError ()) != GL_NO_ERROR) \ - { \ - g_warning ("%s: GL error (%d): %s\n", \ - G_STRLOC, \ - cogl_gl_error_to_string (err));\ - } } G_STMT_END +#define GE(x...) G_STMT_START { \ + GLenum __err; \ + (x); \ + while ((__err = glGetError ()) != GL_NO_ERROR) \ + { \ + g_warning ("%s: GL error (%d): %s\n", \ + G_STRLOC, \ + cogl_gl_error_to_string (__err)); \ + } } G_STMT_END -#else /* COGL_DEBUG */ +#else /* !COGL_GL_DEBUG */ #define GE(x) (x) -#endif /* COGL_DEBUG */ +#endif /* COGL_GL_DEBUG */ #define COGL_ENABLE_BLEND (1<<1) #define COGL_ENABLE_ALPHA_TEST (1<<2) @@ -79,16 +78,10 @@ const gchar *cogl_gl_error_to_string (GLenum error_code); #define COGL_ENABLE_COLOR_ARRAY (1<<4) #define COGL_ENABLE_BACKFACE_CULLING (1<<5) -void -_cogl_features_init (void); +void _cogl_features_init (void); +gint _cogl_get_format_bpp (CoglPixelFormat format); -gint -_cogl_get_format_bpp (CoglPixelFormat format); - -void -cogl_enable (gulong flags); - -gulong -cogl_get_enable (); +void cogl_enable (gulong flags); +gulong cogl_get_enable (void); #endif /* __COGL_INTERNAL_H */ diff --git a/clutter/cogl/common/cogl-primitives.c b/clutter/cogl/common/cogl-primitives.c index deeea562d..224769ca2 100644 --- a/clutter/cogl/common/cogl-primitives.c +++ b/clutter/cogl/common/cogl-primitives.c @@ -372,9 +372,7 @@ _cogl_texture_sliced_quad (CoglTexture *tex, _COGL_GET_CONTEXT (ctx, NO_RETVAL); -#if COGL_DEBUG - printf("=== Drawing Tex Quad (Sliced Mode) ===\n"); -#endif + COGL_NOTE (DRAW, "Drawing Tex Quad (Sliced Mode)"); /* We can't use hardware repeat so we need to set clamp to edge otherwise it might pull in edge pixels from the other side */ @@ -485,17 +483,21 @@ _cogl_texture_sliced_quad (CoglTexture *tex, slice_tx2 /= iter_x.span->size; } -#if COGL_DEBUG - printf("~~~~~ slice (%d,%d)\n", iter_x.index, iter_y.index); - printf("qx1: %f\n", (slice_qx1)); - printf("qy1: %f\n", (slice_qy1)); - printf("qx2: %f\n", (slice_qx2)); - printf("qy2: %f\n", (slice_qy2)); - printf("tx1: %f\n", (slice_tx1)); - printf("ty1: %f\n", (slice_ty1)); - printf("tx2: %f\n", (slice_tx2)); - printf("ty2: %f\n", (slice_ty2)); -#endif + COGL_NOTE (DRAW, + "~~~~~ slice (%d, %d)\n" + "qx1: %f\t" + "qy1: %f\n" + "qx2: %f\t" + "qy2: %f\n" + "tx1: %f\t" + "ty1: %f\n" + "tx2: %f\t" + "ty2: %f\n", + iter_x.index, iter_y.index, + slice_qx1, slice_qy1, + slice_qx2, slice_qy2, + slice_tx1, slice_ty1, + slice_tx2, slice_ty2); /* Pick and bind opengl texture object */ gl_handle = g_array_index (tex->slice_gl_handles, GLuint, diff --git a/clutter/cogl/common/cogl.c b/clutter/cogl/common/cogl.c index f002231d7..2495d8172 100644 --- a/clutter/cogl/common/cogl.c +++ b/clutter/cogl/common/cogl.c @@ -38,6 +38,7 @@ typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName); #endif +#include "cogl-debug.h" #include "cogl-internal.h" #include "cogl-util.h" #include "cogl-context.h" @@ -46,7 +47,7 @@ typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName); #include "cogl-gles2-wrapper.h" #endif -#ifdef COGL_DEBUG +#ifdef COGL_GL_DEBUG /* GL error to string conversion */ static const struct { GLuint error_code; @@ -78,18 +79,16 @@ cogl_gl_error_to_string (GLenum error_code) return gl_errors[i].error_string; } - return "Unknown error"; + return "Unknown GL error"; } -#endif /* COGL_DEBUG */ +#endif /* COGL_GL_DEBUG */ void cogl_clear (const CoglColor *color, gulong buffers) { GLbitfield gl_buffers = 0; -#if COGL_DEBUG - fprintf(stderr, "\n ============== Paint Start ================ \n"); -#endif + COGL_NOTE (DRAW, "Clear begin"); cogl_clip_ensure (); @@ -101,20 +100,29 @@ cogl_clear (const CoglColor *color, gulong buffers) 0.0) ); gl_buffers |= GL_COLOR_BUFFER_BIT; } + if (buffers & COGL_BUFFER_BIT_DEPTH) gl_buffers |= GL_DEPTH_BUFFER_BIT; + if (buffers & COGL_BUFFER_BIT_STENCIL) gl_buffers |= GL_STENCIL_BUFFER_BIT; if (!gl_buffers) { static gboolean shown = FALSE; + if (!shown) - g_warning ("You should specify at least one auxiliary buffer when calling cogl_clear"); + { + g_warning ("You should specify at least one auxiliary buffer " + "when calling cogl_clear"); + } + return; } glClear (gl_buffers); + + COGL_NOTE (DRAW, "Clear end"); } static inline gboolean @@ -563,24 +571,31 @@ cogl_get_viewport (float v[4]) } void -cogl_get_bitmasks (gint *red, gint *green, gint *blue, gint *alpha) +cogl_get_bitmasks (gint *red, + gint *green, + gint *blue, + gint *alpha) { GLint value; + if (red) { GE( glGetIntegerv(GL_RED_BITS, &value) ); *red = value; } + if (green) { GE( glGetIntegerv(GL_GREEN_BITS, &value) ); *green = value; } + if (blue) { GE( glGetIntegerv(GL_BLUE_BITS, &value) ); *blue = value; } + if (alpha) { GE( glGetIntegerv(GL_ALPHA_BITS, &value ) ); diff --git a/clutter/cogl/gl/cogl-texture.c b/clutter/cogl/gl/cogl-texture.c index cd02bc719..ce2ee11ed 100644 --- a/clutter/cogl/gl/cogl-texture.c +++ b/clutter/cogl/gl/cogl-texture.c @@ -44,17 +44,6 @@ #include #include -/* -#define COGL_DEBUG 1 - -#define GE(x) \ -{ \ - glGetError(); x; \ - GLuint err = glGetError(); \ - if (err != 0) \ - printf("err: 0x%x\n", err); \ -} */ - #ifdef HAVE_COGL_GL #define glDrawRangeElements ctx->pf_glDrawRangeElements @@ -943,12 +932,11 @@ _cogl_texture_slices_create (CoglTexture *tex) { x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, x); -#if COGL_DEBUG - printf ("CREATE SLICE (%d,%d)\n", x,y); - printf ("size: (%d x %d)\n", - x_span->size - x_span->waste, - y_span->size - y_span->waste); -#endif + COGL_NOTE (TEXTURE, "CREATE SLICE (%d,%d)\tsize (%d,%d)", + x, y, + x_span->size - x_span->waste, + y_span->size - y_span->waste); + /* Setup texture parameters */ GE( glBindTexture (tex->gl_target, gl_handles[y * n_x_slices + x]) ); diff --git a/clutter/cogl/gles/cogl-texture.c b/clutter/cogl/gles/cogl-texture.c index ce5d4fe26..1564faf2a 100644 --- a/clutter/cogl/gles/cogl-texture.c +++ b/clutter/cogl/gles/cogl-texture.c @@ -40,17 +40,6 @@ #include #include -/* -#define COGL_DEBUG 1 - -#define GE(x) \ -{ \ - glGetError(); x; \ - GLuint err = glGetError(); \ - if (err != 0) \ - printf("err: 0x%x\n", err); \ -} */ - extern void _cogl_journal_flush (void); static void _cogl_texture_free (CoglTexture *tex); From 1f1d19f63450f52caa7231738cad84067486a2ba Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 19 May 2009 16:00:18 +0100 Subject: [PATCH 64/66] [cogl] Move debugging to a configure-time switch Currently, COGL depends on defining debug symbols by manually modifying the source code. When it's done, it will forcefully print stuff to the console. Since COGL has also a pretty, runtime selectable debugging API we might as well switch everything to it. In order for this to happen, configure needs a new: --enable-cogl-debug command line switch; this will enable COGL debugging, the CoglHandle debugging and will also turn on the error checking for each GL operation. The default setting for the COGL debug defines is off, since it slows down the GL operations; enabling it for a particular debug build is trivial, though. --- clutter/cogl/cogl-debug.h | 3 ++- clutter/cogl/common/Makefile.am | 2 +- clutter/cogl/common/cogl-debug.c | 3 ++- clutter/cogl/common/cogl-handle.h | 23 ++++++++++++----------- clutter/cogl/common/cogl-internal.h | 7 +++---- clutter/cogl/gl/Makefile.am | 2 +- clutter/cogl/gles/Makefile.am | 2 +- configure.ac | 21 ++++++++++++++++++++- 8 files changed, 42 insertions(+), 21 deletions(-) diff --git a/clutter/cogl/cogl-debug.h b/clutter/cogl/cogl-debug.h index 79a425282..b31a36c52 100644 --- a/clutter/cogl/cogl-debug.h +++ b/clutter/cogl/cogl-debug.h @@ -36,7 +36,8 @@ typedef enum { COGL_DEBUG_OFFSCREEN = 1 << 4, COGL_DEBUG_DRAW = 1 << 5, COGL_DEBUG_PANGO = 1 << 6, - COGL_DEBUG_RECTANGLES = 1 << 7 + COGL_DEBUG_RECTANGLES = 1 << 7, + COGL_DEBUG_HANDLE = 1 << 8 } CoglDebugFlags; #ifdef COGL_ENABLE_DEBUG diff --git a/clutter/cogl/common/Makefile.am b/clutter/cogl/common/Makefile.am index 47d24199b..138893a14 100644 --- a/clutter/cogl/common/Makefile.am +++ b/clutter/cogl/common/Makefile.am @@ -12,7 +12,7 @@ INCLUDES = \ noinst_LTLIBRARIES = libclutter-cogl-common.la EXTRA_DIST = stb_image.c -libclutter_cogl_common_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) +libclutter_cogl_common_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(COGL_DEBUG_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) libclutter_cogl_common_la_LIBADD = -lm $(CLUTTER_LIBS) libclutter_cogl_common_la_SOURCES = \ cogl-handle.h \ diff --git a/clutter/cogl/common/cogl-debug.c b/clutter/cogl/common/cogl-debug.c index 2763314d5..85721fc22 100644 --- a/clutter/cogl/common/cogl-debug.c +++ b/clutter/cogl/common/cogl-debug.c @@ -38,7 +38,8 @@ static const GDebugKey cogl_debug_keys[] = { { "offscreen", COGL_DEBUG_OFFSCREEN }, { "draw", COGL_DEBUG_DRAW }, { "pango", COGL_DEBUG_PANGO }, - { "rectangles", COGL_DEBUG_RECTANGLES } + { "rectangles", COGL_DEBUG_RECTANGLES }, + { "handle", COGL_DEBUG_HANDLE } }; static const gint n_cogl_debug_keys = G_N_ELEMENTS (cogl_debug_keys); diff --git a/clutter/cogl/common/cogl-handle.h b/clutter/cogl/common/cogl-handle.h index e1f1e3c8a..7851932db 100644 --- a/clutter/cogl/common/cogl-handle.h +++ b/clutter/cogl/common/cogl-handle.h @@ -48,24 +48,25 @@ typedef struct _CoglHandleObject #ifdef COGL_HANDLE_DEBUG -#define _COGL_HANDLE_DEBUG_NEW(type_name, obj) \ - g_debug ("COGL " G_STRINGIFY (type_name) " NEW %p %i\n", \ - (obj), (obj)->ref_count) +#define _COGL_HANDLE_DEBUG_NEW(type_name, obj) \ + COGL_NOTE (HANDLE, "COGL " G_STRINGIFY (type_name) " NEW %p %i\n", \ + (obj), (obj)->ref_count) #define _COGL_HANDLE_DEBUG_REF(type_name, handle) G_STMT_START { \ CoglHandleObject *__obj = (CoglHandleObject *)handle; \ - g_debug ("COGL %s REF %p %i\n", \ - g_quark_to_string ((__obj)->klass->type), \ - (__obj), (__obj)->ref_count); } G_STMT_END + COGL_NOTE (HANDLE, "COGL %s REF %p %i\n", \ + g_quark_to_string ((__obj)->klass->type), \ + (__obj), (__obj)->ref_count); } G_STMT_END #define _COGL_HANDLE_DEBUG_UNREF(type_name, handle) G_STMT_START { \ CoglHandleObject *__obj = (CoglHandleObject *)handle; \ - g_debug ("COGL %s UNREF %p %i\n", \ - g_quark_to_string ((__obj)->klass->type), \ - (__obj), (__obj)->ref_count - 1); } G_STMT_END + COGL_NOTE (HANDLE, "COGL %s UNREF %p %i\n", \ + g_quark_to_string ((__obj)->klass->type), \ + (__obj), (__obj)->ref_count - 1); } G_STMT_END -#define COGL_HANDLE_DEBUG_FREE(obj) \ - g_debug ("COGL %s FREE %p\n", g_quark_to_string ((obj)->klass->type), (obj)) +#define COGL_HANDLE_DEBUG_FREE(obj) \ + COGL_NOTE (HANDLE, "COGL %s FREE %p\n", \ + g_quark_to_string ((obj)->klass->type), (obj)) #else /* !COGL_HANDLE_DEBUG */ diff --git a/clutter/cogl/common/cogl-internal.h b/clutter/cogl/common/cogl-internal.h index b71de0f7c..f148c35b6 100644 --- a/clutter/cogl/common/cogl-internal.h +++ b/clutter/cogl/common/cogl-internal.h @@ -24,6 +24,8 @@ #ifndef __COGL_INTERNAL_H #define __COGL_INTERNAL_H +#include "cogl-debug.h" + #ifdef HAVE_COGL_GLES2 typedef enum { COGL_BOXED_NONE, @@ -49,10 +51,7 @@ typedef struct _CoglBoxedValue } CoglBoxedValue; #endif -/* XXX - set to 1 to enable checks on every GL call */ -#define COGL_GL_DEBUG 0 - -#if COGL_GL_DEBUG +#ifdef COGL_GL_DEBUG const gchar *cogl_gl_error_to_string (GLenum error_code); diff --git a/clutter/cogl/gl/Makefile.am b/clutter/cogl/gl/Makefile.am index 26fadc42c..367f674f2 100644 --- a/clutter/cogl/gl/Makefile.am +++ b/clutter/cogl/gl/Makefile.am @@ -52,7 +52,7 @@ INCLUDES = \ noinst_LTLIBRARIES = libclutter-cogl.la -libclutter_cogl_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) +libclutter_cogl_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(COGL_DEBUG_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) libclutter_cogl_la_LIBADD = -lm $(CLUTTER_LIBS) $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la libclutter_cogl_la_DEPENDENCIES = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la libclutter_cogl_la_SOURCES = \ diff --git a/clutter/cogl/gles/Makefile.am b/clutter/cogl/gles/Makefile.am index abebf7275..3f84b4b2f 100644 --- a/clutter/cogl/gles/Makefile.am +++ b/clutter/cogl/gles/Makefile.am @@ -29,7 +29,7 @@ INCLUDES = \ noinst_LTLIBRARIES = libclutter-cogl.la -libclutter_cogl_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) +libclutter_cogl_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(COGL_DEBUG_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS) libclutter_cogl_la_LIBADD = -lm $(CLUTTER_LIBS) $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la libclutter_cogl_la_DEPENDENCIES = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la libclutter_cogl_la_SOURCES = \ diff --git a/configure.ac b/configure.ac index 085670927..024fda1d7 100644 --- a/configure.ac +++ b/configure.ac @@ -585,6 +585,24 @@ fi AC_SUBST(CLUTTER_DEBUG_CFLAGS) +m4_define([cogl_debug_default], [no]) +AC_ARG_ENABLE([cogl-debug], + [AC_HELP_STRING([--enable-cogl-debug=@<:@no/yes@:>@], + [Turn on COGL debugging])], + [], + [enable_debug=debug_default]) + +AS_CASE([$enable_debug], + + [yes], [COGL_DEBUG_CFLAGS="-DCOGL_GL_DEBUG -DCOGL_HANDLE_DEBUG -DCOGL_ENABLE_DEBUG"], + + [no], [COGL_DEBUG_CFLAGS=""], + + [*], [AC_MSG_ERROR([Invalid value for --enable-cogl-debug])] +) + +AC_SUBST(COGL_DEBUG_CFLAGS) + dnl = Enable strict compiler flags ========================================= # use strict compiler flags only on development releases @@ -726,7 +744,8 @@ fi echo " GL Headers: ${CLUTTER_GL_HEADER}" echo " Image backend: ${imagebackend}" echo " Target library: ${clutterbackendlib}" -echo " Debug level: ${enable_debug}" +echo " Clutter Debug level: ${enable_debug}" +echo " Enable COGL debug flags: ${enable_cogl_debug}" echo " Compiler flags: ${CPPFLAGS} ${MAINTAINER_CFLAGS}" echo " Build API Documentation: ${enable_gtk_doc}" echo " Build Manual Documentation: ${enable_manual}" From c74586d019a4651d52938610894c0396f02294bb Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 20 May 2009 15:15:25 +0100 Subject: [PATCH 65/66] [cogl] Do no include gprintf.h We are not using any of the g_printf* family of functions, so we can import glib.h instead. --- clutter/cogl/common/cogl-vertex-buffer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clutter/cogl/common/cogl-vertex-buffer.c b/clutter/cogl/common/cogl-vertex-buffer.c index 73e9a1c0c..b7e004a49 100644 --- a/clutter/cogl/common/cogl-vertex-buffer.c +++ b/clutter/cogl/common/cogl-vertex-buffer.c @@ -127,7 +127,7 @@ #include #include -#include +#include #include "cogl.h" #include "cogl-internal.h" @@ -1776,4 +1776,3 @@ _cogl_vertex_buffer_free (CoglVertexBuffer *buffer) g_slice_free (CoglVertexBuffer, buffer); } - From 4f5a5f38f7068d4ec0dca9967f304a39901e8fec Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 20 May 2009 16:06:09 +0100 Subject: [PATCH 66/66] Add more padding in Model and ModelIter classes ClutterModel and ClutterModelIter have 4 padding slots, but if they have to survive the 1.x API cycle they will need at least twice that amount. --- clutter/clutter-model.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/clutter/clutter-model.h b/clutter/clutter-model.h index bae1faf3b..0a9e56d2a 100644 --- a/clutter/clutter-model.h +++ b/clutter/clutter-model.h @@ -177,11 +177,15 @@ struct _ClutterModelClass void (* filter_changed) (ClutterModel *model); /*< private >*/ - /* padding for future */ + /* padding for future expansion */ void (*_clutter_model_1) (void); void (*_clutter_model_2) (void); void (*_clutter_model_3) (void); void (*_clutter_model_4) (void); + void (*_clutter_model_5) (void); + void (*_clutter_model_6) (void); + void (*_clutter_model_7) (void); + void (*_clutter_model_8) (void); }; GType clutter_model_get_type (void) G_GNUC_CONST; @@ -334,11 +338,15 @@ struct _ClutterModelIterClass ClutterModelIter *(* copy) (ClutterModelIter *iter); /*< private >*/ - /* padding for future */ + /* padding for future expansion */ void (*_clutter_model_iter_1) (void); void (*_clutter_model_iter_2) (void); void (*_clutter_model_iter_3) (void); void (*_clutter_model_iter_4) (void); + void (*_clutter_model_iter_5) (void); + void (*_clutter_model_iter_6) (void); + void (*_clutter_model_iter_7) (void); + void (*_clutter_model_iter_8) (void); }; GType clutter_model_iter_get_type (void) G_GNUC_CONST;