Merge branch 'master' into async-textures
This commit is contained in:
commit
946c075a2a
@ -1013,7 +1013,8 @@ clutter_actor_apply_relative_transform_to_point (ClutterActor *self,
|
|||||||
ClutterVertex *vertex)
|
ClutterVertex *vertex)
|
||||||
{
|
{
|
||||||
ClutterFixed v[4];
|
ClutterFixed v[4];
|
||||||
ClutterFixed x, y, z, w;
|
ClutterUnit x, y, z, w;
|
||||||
|
fixed_vertex_t tmp;
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||||
g_return_if_fail (ancestor == NULL || CLUTTER_IS_ACTOR (ancestor));
|
g_return_if_fail (ancestor == NULL || CLUTTER_IS_ACTOR (ancestor));
|
||||||
@ -1026,8 +1027,7 @@ clutter_actor_apply_relative_transform_to_point (ClutterActor *self,
|
|||||||
w = COGL_FIXED_1;
|
w = COGL_FIXED_1;
|
||||||
|
|
||||||
/* First we tranform the point using the OpenGL modelview matrix */
|
/* First we tranform the point using the OpenGL modelview matrix */
|
||||||
clutter_actor_transform_point_relative (self, ancestor,
|
clutter_actor_transform_point_relative (self, ancestor, &x, &y, &z, &w);
|
||||||
&x, &y, &z, &w);
|
|
||||||
|
|
||||||
cogl_get_viewport (v);
|
cogl_get_viewport (v);
|
||||||
|
|
||||||
@ -1035,12 +1035,12 @@ clutter_actor_apply_relative_transform_to_point (ClutterActor *self,
|
|||||||
* The w[3] parameter should always be 1.0 here, so we ignore it; otherwise
|
* The w[3] parameter should always be 1.0 here, so we ignore it; otherwise
|
||||||
* we would have to divide the original verts with it.
|
* we would have to divide the original verts with it.
|
||||||
*/
|
*/
|
||||||
vertex->x =
|
tmp.x = COGL_FIXED_MUL (CLUTTER_UNITS_TO_FIXED (x) + COGL_FIXED_0_5, v[2]);
|
||||||
CLUTTER_UNITS_FROM_FIXED (COGL_FIXED_MUL ((x + COGL_FIXED_0_5), v[2]));
|
tmp.y = COGL_FIXED_MUL (COGL_FIXED_0_5 - CLUTTER_UNITS_TO_FIXED (y), v[3]);
|
||||||
vertex->y =
|
tmp.z = COGL_FIXED_MUL (CLUTTER_UNITS_TO_FIXED (z) + COGL_FIXED_0_5, v[2]);
|
||||||
CLUTTER_UNITS_FROM_FIXED (COGL_FIXED_MUL ((COGL_FIXED_0_5 - y), v[3]));
|
tmp.w = 0;
|
||||||
vertex->z =
|
|
||||||
CLUTTER_UNITS_FROM_FIXED (COGL_FIXED_MUL ((z + COGL_FIXED_0_5), v[2]));
|
fixed_vertex_to_units (&tmp, vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1060,6 +1060,7 @@ clutter_actor_apply_transform_to_point (ClutterActor *self,
|
|||||||
const ClutterVertex *point,
|
const ClutterVertex *point,
|
||||||
ClutterVertex *vertex)
|
ClutterVertex *vertex)
|
||||||
{
|
{
|
||||||
|
ClutterUnit x, y, z, w;
|
||||||
ClutterFixed mtx_p[16];
|
ClutterFixed mtx_p[16];
|
||||||
ClutterFixed v[4];
|
ClutterFixed v[4];
|
||||||
fixed_vertex_t tmp = { 0, };
|
fixed_vertex_t tmp = { 0, };
|
||||||
@ -1068,13 +1069,18 @@ clutter_actor_apply_transform_to_point (ClutterActor *self,
|
|||||||
g_return_if_fail (point != NULL);
|
g_return_if_fail (point != NULL);
|
||||||
g_return_if_fail (vertex != NULL);
|
g_return_if_fail (vertex != NULL);
|
||||||
|
|
||||||
tmp.x = CLUTTER_UNITS_TO_FIXED (vertex->x);
|
x = point->x;
|
||||||
tmp.y = CLUTTER_UNITS_TO_FIXED (vertex->y);
|
y = point->y;
|
||||||
tmp.z = CLUTTER_UNITS_TO_FIXED (vertex->z);
|
z = point->z;
|
||||||
tmp.w = COGL_FIXED_1;
|
w = CLUTTER_UNITS_FROM_INT (1);
|
||||||
|
|
||||||
/* First we tranform the point using the OpenGL modelview matrix */
|
/* First we tranform the point using the OpenGL modelview matrix */
|
||||||
clutter_actor_transform_point (self, &tmp.x, &tmp.y, &tmp.z, &tmp.w);
|
clutter_actor_transform_point (self, &x, &y, &z, &w);
|
||||||
|
|
||||||
|
tmp.x = CLUTTER_UNITS_TO_FIXED (x);
|
||||||
|
tmp.y = CLUTTER_UNITS_TO_FIXED (y);
|
||||||
|
tmp.z = CLUTTER_UNITS_TO_FIXED (z);
|
||||||
|
tmp.w = CLUTTER_UNITS_TO_FIXED (w);
|
||||||
|
|
||||||
cogl_get_projection_matrix (mtx_p);
|
cogl_get_projection_matrix (mtx_p);
|
||||||
cogl_get_viewport (v);
|
cogl_get_viewport (v);
|
||||||
@ -3244,8 +3250,9 @@ clutter_actor_get_preferred_width (ClutterActor *self,
|
|||||||
|
|
||||||
if (natural_width < min_width)
|
if (natural_width < min_width)
|
||||||
{
|
{
|
||||||
g_warning ("Actor of type %s reported a natural width of %d (%d px) "
|
g_warning ("Actor of type %s reported a natural width "
|
||||||
"lower than min width %d (%d px)",
|
"of %" CLUTTER_UNITS_FORMAT " (%d px) lower "
|
||||||
|
"than min width %" CLUTTER_UNITS_FORMAT " (%d px)",
|
||||||
G_OBJECT_TYPE_NAME (self),
|
G_OBJECT_TYPE_NAME (self),
|
||||||
natural_width, CLUTTER_UNITS_TO_DEVICE (natural_width),
|
natural_width, CLUTTER_UNITS_TO_DEVICE (natural_width),
|
||||||
min_width, CLUTTER_UNITS_TO_DEVICE (min_width));
|
min_width, CLUTTER_UNITS_TO_DEVICE (min_width));
|
||||||
@ -3314,8 +3321,9 @@ clutter_actor_get_preferred_height (ClutterActor *self,
|
|||||||
|
|
||||||
if (natural_height < min_height)
|
if (natural_height < min_height)
|
||||||
{
|
{
|
||||||
g_warning ("Actor of type %s reported a natural height of %d "
|
g_warning ("Actor of type %s reported a natural height "
|
||||||
"(%d px) lower than min height %d (%d px)",
|
"of %" CLUTTER_UNITS_FORMAT " (%d px) lower than "
|
||||||
|
"min height %" CLUTTER_UNITS_FORMAT " (%d px)",
|
||||||
G_OBJECT_TYPE_NAME (self),
|
G_OBJECT_TYPE_NAME (self),
|
||||||
natural_height, CLUTTER_UNITS_TO_DEVICE (natural_height),
|
natural_height, CLUTTER_UNITS_TO_DEVICE (natural_height),
|
||||||
min_height, CLUTTER_UNITS_TO_DEVICE (min_height));
|
min_height, CLUTTER_UNITS_TO_DEVICE (min_height));
|
||||||
|
@ -251,9 +251,6 @@ _clutter_backend_ensure_context (ClutterBackend *backend,
|
|||||||
* potential issue of GL calls with no context)
|
* potential issue of GL calls with no context)
|
||||||
*/
|
*/
|
||||||
current_context_stage = stage;
|
current_context_stage = stage;
|
||||||
|
|
||||||
if (stage)
|
|
||||||
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CLUTTER_NOTE (MULTISTAGE, "Stage is the same");
|
CLUTTER_NOTE (MULTISTAGE, "Stage is the same");
|
||||||
|
@ -49,6 +49,13 @@ typedef struct _ClutterCairoTexture ClutterCairoTexture;
|
|||||||
typedef struct _ClutterCairoTextureClass ClutterCairoTextureClass;
|
typedef struct _ClutterCairoTextureClass ClutterCairoTextureClass;
|
||||||
typedef struct _ClutterCairoTexturePrivate ClutterCairoTexturePrivate;
|
typedef struct _ClutterCairoTexturePrivate ClutterCairoTexturePrivate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClutterCairoTexture:
|
||||||
|
*
|
||||||
|
* The #ClutterCairoTexture struct contains only private data.
|
||||||
|
*
|
||||||
|
* Since: 1.0
|
||||||
|
*/
|
||||||
struct _ClutterCairoTexture
|
struct _ClutterCairoTexture
|
||||||
{
|
{
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
@ -57,6 +64,13 @@ struct _ClutterCairoTexture
|
|||||||
ClutterCairoTexturePrivate *priv;
|
ClutterCairoTexturePrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClutterCairoTextureClass:
|
||||||
|
*
|
||||||
|
* The #ClutterCairoTextureClass struct contains only private data.
|
||||||
|
*
|
||||||
|
* Since: 1.0
|
||||||
|
*/
|
||||||
struct _ClutterCairoTextureClass
|
struct _ClutterCairoTextureClass
|
||||||
{
|
{
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
|
@ -115,6 +115,8 @@ enum
|
|||||||
UNFULLSCREEN,
|
UNFULLSCREEN,
|
||||||
ACTIVATE,
|
ACTIVATE,
|
||||||
DEACTIVATE,
|
DEACTIVATE,
|
||||||
|
QUEUE_REDRAW,
|
||||||
|
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -335,6 +337,42 @@ clutter_stage_real_fullscreen (ClutterStage *stage)
|
|||||||
clutter_actor_allocate (CLUTTER_ACTOR (stage), &box, FALSE);
|
clutter_actor_allocate (CLUTTER_ACTOR (stage), &box, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
redraw_update_idle (gpointer user_data)
|
||||||
|
{
|
||||||
|
ClutterStage *stage = user_data;
|
||||||
|
ClutterStagePrivate *priv = stage->priv;
|
||||||
|
|
||||||
|
if (priv->update_idle)
|
||||||
|
{
|
||||||
|
g_source_remove (priv->update_idle);
|
||||||
|
priv->update_idle = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLUTTER_NOTE (MULTISTAGE, "redrawing via idle for stage:%p", stage);
|
||||||
|
clutter_redraw (stage);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_stage_real_queue_redraw (ClutterStage *stage)
|
||||||
|
{
|
||||||
|
ClutterStagePrivate *priv = stage->priv;
|
||||||
|
|
||||||
|
if (priv->update_idle == 0)
|
||||||
|
{
|
||||||
|
CLUTTER_TIMESTAMP (SCHEDULER, "Adding idle source for stage: %p", stage);
|
||||||
|
|
||||||
|
/* FIXME: weak_ref self in case we dissapear before paint? */
|
||||||
|
priv->update_idle =
|
||||||
|
clutter_threads_add_idle_full (CLUTTER_PRIORITY_REDRAW,
|
||||||
|
redraw_update_idle,
|
||||||
|
stage,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_stage_set_property (GObject *object,
|
clutter_stage_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
@ -687,8 +725,58 @@ clutter_stage_class_init (ClutterStageClass *klass)
|
|||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
clutter_marshal_VOID__VOID,
|
clutter_marshal_VOID__VOID,
|
||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
|
/**
|
||||||
|
* ClutterStage::queue-redraw:
|
||||||
|
* @stage: the stage which was queued for redraw
|
||||||
|
*
|
||||||
|
* The ::queue-redraw signal is emitted each time a #ClutterStage
|
||||||
|
* has been queued for a redraw. You can use this signal to know
|
||||||
|
* when clutter_stage_queue_redraw() has been called.
|
||||||
|
*
|
||||||
|
* Toolkits embedding a #ClutterStage which require a redraw and
|
||||||
|
* relayout cycle can stop the emission of this signal using the
|
||||||
|
* GSignal API, redraw the UI and then call clutter_redraw()
|
||||||
|
* themselves, like:
|
||||||
|
*
|
||||||
|
* |[
|
||||||
|
* static void
|
||||||
|
* on_redraw_complete (void)
|
||||||
|
* {
|
||||||
|
* /* execute the Clutter drawing pipeline */
|
||||||
|
* clutter_redraw ();
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* static void
|
||||||
|
* on_stage_queue_redraw (ClutterStage *stage)
|
||||||
|
* {
|
||||||
|
* /* this prevents the default handler to run */
|
||||||
|
* g_signal_stop_emission_by_name (stage, "queue-redraw");
|
||||||
|
*
|
||||||
|
* /* queue a redraw with the host toolkit and call
|
||||||
|
* * a function when the redraw has been completed
|
||||||
|
* */
|
||||||
|
* queue_a_redraw (G_CALLBACK (on_redraw_complete));
|
||||||
|
* }
|
||||||
|
* ]|
|
||||||
|
*
|
||||||
|
* <note><para>This signal is emitted before the Clutter paint
|
||||||
|
* pipeline is run. If you want to know when the pipeline has been
|
||||||
|
* completed you should connect to the ::paint signal on the Stage
|
||||||
|
* with g_signal_connect_after().</para></note>
|
||||||
|
*
|
||||||
|
* Since: 1.0
|
||||||
|
*/
|
||||||
|
stage_signals[QUEUE_REDRAW] =
|
||||||
|
g_signal_new (I_("queue-redraw"),
|
||||||
|
G_TYPE_FROM_CLASS (gobject_class),
|
||||||
|
G_SIGNAL_RUN_FIRST,
|
||||||
|
G_STRUCT_OFFSET (ClutterStageClass, queue_redraw),
|
||||||
|
NULL, NULL,
|
||||||
|
clutter_marshal_VOID__VOID,
|
||||||
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
klass->fullscreen = clutter_stage_real_fullscreen;
|
klass->fullscreen = clutter_stage_real_fullscreen;
|
||||||
|
klass->queue_redraw = clutter_stage_real_queue_redraw;
|
||||||
|
|
||||||
g_type_class_add_private (gobject_class, sizeof (ClutterStagePrivate));
|
g_type_class_add_private (gobject_class, sizeof (ClutterStagePrivate));
|
||||||
}
|
}
|
||||||
@ -1801,22 +1889,29 @@ clutter_stage_ensure_current (ClutterStage *stage)
|
|||||||
_clutter_backend_ensure_context (ctx->backend, stage);
|
_clutter_backend_ensure_context (ctx->backend, stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
/**
|
||||||
redraw_update_idle (gpointer user_data)
|
* clutter_stage_ensure_viewport:
|
||||||
|
* @stage: a #ClutterStage
|
||||||
|
*
|
||||||
|
* Ensures that the GL viewport is updated with the current
|
||||||
|
* stage window size.
|
||||||
|
*
|
||||||
|
* This function will queue a redraw of @stage.
|
||||||
|
*
|
||||||
|
* This function should not be called by applications; it is used
|
||||||
|
* when embedding a #ClutterStage into a toolkit with another
|
||||||
|
* windowing system, like GTK+.
|
||||||
|
*
|
||||||
|
* Since: 1.0
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
clutter_stage_ensure_viewport (ClutterStage *stage)
|
||||||
{
|
{
|
||||||
ClutterStage *stage = user_data;
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
||||||
ClutterStagePrivate *priv = stage->priv;
|
|
||||||
|
|
||||||
if (priv->update_idle)
|
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES);
|
||||||
{
|
|
||||||
g_source_remove (priv->update_idle);
|
|
||||||
priv->update_idle = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CLUTTER_NOTE (MULTISTAGE, "redrawing via idle for stage:%p", stage);
|
clutter_stage_queue_redraw (stage);
|
||||||
clutter_redraw (stage);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1835,17 +1930,7 @@ clutter_stage_queue_redraw (ClutterStage *stage)
|
|||||||
{
|
{
|
||||||
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
||||||
|
|
||||||
if (!stage->priv->update_idle)
|
g_signal_emit (stage, stage_signals[QUEUE_REDRAW], 0);
|
||||||
{
|
|
||||||
CLUTTER_TIMESTAMP (SCHEDULER, "Adding idle source for stage: %p", stage);
|
|
||||||
|
|
||||||
/* FIXME: weak_ref self in case we dissapear before paint? */
|
|
||||||
stage->priv->update_idle =
|
|
||||||
clutter_threads_add_idle_full (CLUTTER_PRIORITY_REDRAW,
|
|
||||||
redraw_update_idle,
|
|
||||||
stage,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,6 +106,8 @@ struct _ClutterStageClass
|
|||||||
void (* activate) (ClutterStage *stage);
|
void (* activate) (ClutterStage *stage);
|
||||||
void (* deactivate) (ClutterStage *stage);
|
void (* deactivate) (ClutterStage *stage);
|
||||||
|
|
||||||
|
void (* queue_redraw) (ClutterStage *stage);
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
/* padding for future expansion */
|
/* padding for future expansion */
|
||||||
gpointer _padding_dummy[32];
|
gpointer _padding_dummy[32];
|
||||||
@ -229,6 +231,7 @@ ClutterActor * clutter_stage_get_key_focus (ClutterStage *stage);
|
|||||||
void clutter_stage_ensure_current (ClutterStage *stage);
|
void clutter_stage_ensure_current (ClutterStage *stage);
|
||||||
void clutter_stage_queue_redraw (ClutterStage *stage);
|
void clutter_stage_queue_redraw (ClutterStage *stage);
|
||||||
gboolean clutter_stage_is_default (ClutterStage *stage);
|
gboolean clutter_stage_is_default (ClutterStage *stage);
|
||||||
|
void clutter_stage_ensure_viewport (ClutterStage *stage);
|
||||||
|
|
||||||
/* Commodity macro */
|
/* Commodity macro */
|
||||||
#define clutter_stage_add(stage,actor) G_STMT_START { \
|
#define clutter_stage_add(stage,actor) G_STMT_START { \
|
||||||
|
@ -688,11 +688,11 @@ clutter_text_get_property (GObject *gobject,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_POSITION:
|
case PROP_POSITION:
|
||||||
g_value_set_int (value, CLUTTER_FIXED_TO_FLOAT (priv->position));
|
g_value_set_int (value, priv->position);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_SELECTION_BOUND:
|
case PROP_SELECTION_BOUND:
|
||||||
g_value_set_int (value, CLUTTER_FIXED_TO_FLOAT (priv->selection_bound));
|
g_value_set_int (value, priv->selection_bound);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_EDITABLE:
|
case PROP_EDITABLE:
|
||||||
@ -719,6 +719,30 @@ clutter_text_get_property (GObject *gobject,
|
|||||||
g_value_set_boolean (value, priv->single_line_mode);
|
g_value_set_boolean (value, priv->single_line_mode);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_ELLIPSIZE:
|
||||||
|
g_value_set_enum (value, priv->ellipsize);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_LINE_WRAP:
|
||||||
|
g_value_set_boolean (value, priv->wrap);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_LINE_WRAP_MODE:
|
||||||
|
g_value_set_enum (value, priv->wrap_mode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_ALIGNMENT:
|
||||||
|
g_value_set_enum (value, priv->alignment);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_JUSTIFY:
|
||||||
|
g_value_set_boolean (value, priv->justify);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_ATTRIBUTES:
|
||||||
|
g_value_set_boxed (value, priv->attrs);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||||
}
|
}
|
||||||
@ -826,7 +850,7 @@ cursor_paint (ClutterText *self)
|
|||||||
gint n_ranges;
|
gint n_ranges;
|
||||||
gint *ranges;
|
gint *ranges;
|
||||||
gint i;
|
gint i;
|
||||||
gint index;
|
gint index_;
|
||||||
gint maxindex;
|
gint maxindex;
|
||||||
ClutterUnit y, height;
|
ClutterUnit y, height;
|
||||||
|
|
||||||
@ -838,10 +862,10 @@ cursor_paint (ClutterText *self)
|
|||||||
pango_layout_line_get_x_ranges (line, start_index, end_index,
|
pango_layout_line_get_x_ranges (line, start_index, end_index,
|
||||||
&ranges,
|
&ranges,
|
||||||
&n_ranges);
|
&n_ranges);
|
||||||
pango_layout_line_x_to_index (line, 0, &index, NULL);
|
pango_layout_line_x_to_index (line, 0, &index_, NULL);
|
||||||
|
|
||||||
clutter_text_position_to_coords (self,
|
clutter_text_position_to_coords (self,
|
||||||
bytes_to_offset (utf8, index),
|
bytes_to_offset (utf8, index_),
|
||||||
NULL, &y, &height);
|
NULL, &y, &height);
|
||||||
|
|
||||||
for (i = 0; i < n_ranges; i++)
|
for (i = 0; i < n_ranges; i++)
|
||||||
|
@ -59,6 +59,8 @@ typedef gint32 ClutterUnit;
|
|||||||
#define CLUTTER_UNITS_FROM_FIXED(x) (x)
|
#define CLUTTER_UNITS_FROM_FIXED(x) (x)
|
||||||
#define CLUTTER_UNITS_TO_FIXED(x) (x)
|
#define CLUTTER_UNITS_TO_FIXED(x) (x)
|
||||||
|
|
||||||
|
#define CLUTTER_UNITS_FORMAT "d"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CLUTTER_UNITS_FROM_DEVICE:
|
* CLUTTER_UNITS_FROM_DEVICE:
|
||||||
* @x: value in pixels
|
* @x: value in pixels
|
||||||
|
@ -427,6 +427,29 @@ CoglBitmap * cogl_bitmap_new_from_file (const gchar *filename,
|
|||||||
*/
|
*/
|
||||||
void cogl_bitmap_free (CoglBitmap *bmp);
|
void cogl_bitmap_free (CoglBitmap *bmp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_texture_multiple_rectangles:
|
||||||
|
* @handle: a @CoglHandle.
|
||||||
|
* @verts: an array of vertices
|
||||||
|
* @n_rects: number of rectangles to draw
|
||||||
|
*
|
||||||
|
* Draws a series of rectangles in the same way that
|
||||||
|
* cogl_texture_rectangle() does. In some situations it can give a
|
||||||
|
* significant performance boost to use this function rather than
|
||||||
|
* calling cogl_texture_rectangle() separately for each rectangle.
|
||||||
|
*
|
||||||
|
* @verts should point to an array of #CoglFixed<!-- -->s with
|
||||||
|
* @n_rects * 8 elements. Each group of 8 values corresponds to the
|
||||||
|
* parameters x1, y1, x2, y2, tx1, ty1, tx2 and ty2 and have the same
|
||||||
|
* meaning as in cogl_texture_rectangle().
|
||||||
|
*
|
||||||
|
* Since: 1.0
|
||||||
|
*/
|
||||||
|
void cogl_texture_multiple_rectangles
|
||||||
|
(CoglHandle handle,
|
||||||
|
const CoglFixed *verts,
|
||||||
|
guint n_rects);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __COGL_TEXTURE_H__ */
|
#endif /* __COGL_TEXTURE_H__ */
|
||||||
|
@ -93,27 +93,29 @@ typedef struct _CoglTextureVertex CoglTextureVertex;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* CoglPixelFormat:
|
* CoglPixelFormat:
|
||||||
* @COGL_PIXEL_FORMAT_ANY:
|
* @COGL_PIXEL_FORMAT_ANY: Any format
|
||||||
* @COGL_PIXEL_FORMAT_A_8:
|
* @COGL_PIXEL_FORMAT_A_8: 8 bits alpha mask
|
||||||
* @COGL_PIXEL_FORMAT_RGB_888:
|
* @COGL_PIXEL_FORMAT_RGB_565: RGB, 16 bits
|
||||||
* @COGL_PIXEL_FORMAT_BGR_888:
|
* @COGL_PIXEL_FORMAT_RGBA_4444: RGBA, 16 bits
|
||||||
* @COGL_PIXEL_FORMAT_RGBA_8888:
|
* @COGL_PIXEL_FORMAT_RGBA_5551: RGBA, 16 bits
|
||||||
* @COGL_PIXEL_FORMAT_BGRA_8888:
|
* @COGL_PIXEL_FORMAT_YUV: FIXME
|
||||||
* @COGL_PIXEL_FORMAT_ARGB_8888:
|
* @COGL_PIXEL_FORMAT_G_8: FIXME
|
||||||
* @COGL_PIXEL_FORMAT_ABGR_8888:
|
* @COGL_PIXEL_FORMAT_RGB_888: RGB, 24 bits
|
||||||
* @COGL_PIXEL_FORMAT_RGBA_8888_PRE:
|
* @COGL_PIXEL_FORMAT_BGR_888: BGR, 24 bits
|
||||||
* @COGL_PIXEL_FORMAT_BGRA_8888_PRE:
|
* @COGL_PIXEL_FORMAT_RGBA_8888: RGBA, 32 bits
|
||||||
* @COGL_PIXEL_FORMAT_ARGB_8888_PRE:
|
* @COGL_PIXEL_FORMAT_BGRA_8888: BGRA, 32 bits
|
||||||
* @COGL_PIXEL_FORMAT_ABGR_8888_PRE:
|
* @COGL_PIXEL_FORMAT_ARGB_8888: ARGB, 32 bits
|
||||||
* @COGL_PIXEL_FORMAT_RGB_565:
|
* @COGL_PIXEL_FORMAT_ABGR_8888: ABGR, 32 bits
|
||||||
* @COGL_PIXEL_FORMAT_RGBA_4444:
|
* @COGL_PIXEL_FORMAT_RGBA_8888_PRE: Premultiplied RGBA, 32 bits
|
||||||
* @COGL_PIXEL_FORMAT_RGBA_5551:
|
* @COGL_PIXEL_FORMAT_BGRA_8888_PRE: Premultiplied BGRA, 32 bits
|
||||||
* @COGL_PIXEL_FORMAT_RGBA_4444_PRE:
|
* @COGL_PIXEL_FORMAT_ARGB_8888_PRE: Premultiplied ARGB, 32 bits
|
||||||
* @COGL_PIXEL_FORMAT_RGBA_5551_PRE:
|
* @COGL_PIXEL_FORMAT_ABGR_8888_PRE: Premultiplied ABGR, 32 bits
|
||||||
* @COGL_PIXEL_FORMAT_YUV:
|
* @COGL_PIXEL_FORMAT_RGBA_4444_PRE: Premultiplied RGBA, 16 bits
|
||||||
* @COGL_PIXEL_FORMAT_G_8:
|
* @COGL_PIXEL_FORMAT_RGBA_5551_PRE: Premultiplied RGBA, 16 bits
|
||||||
*
|
*
|
||||||
* Pixel formats used by COGL.
|
* Pixel formats used by COGL.
|
||||||
|
*
|
||||||
|
* Since: 0.8
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -180,19 +182,21 @@ typedef enum
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* CoglFeatureFlags:
|
* CoglFeatureFlags:
|
||||||
* @COGL_FEATURE_TEXTURE_RECTANGLE:
|
* @COGL_FEATURE_TEXTURE_RECTANGLE: ARB_texture_rectangle support
|
||||||
* @COGL_FEATURE_TEXTURE_NPOT:
|
* @COGL_FEATURE_TEXTURE_NPOT: ARB_texture_non_power_of_two support
|
||||||
* @COGL_FEATURE_TEXTURE_YUV:
|
* @COGL_FEATURE_TEXTURE_YUV: ycbcr conversion support
|
||||||
* @COGL_FEATURE_TEXTURE_READ_PIXELS:
|
* @COGL_FEATURE_TEXTURE_READ_PIXELS: glReadPixels() support
|
||||||
* @COGL_FEATURE_SHADERS_GLSL:
|
* @COGL_FEATURE_SHADERS_GLSL: GLSL support
|
||||||
* @COGL_FEATURE_OFFSCREEN:
|
* @COGL_FEATURE_OFFSCREEN: FBO support
|
||||||
* @COGL_FEATURE_OFFSCREEN_MULTISAMPLE:
|
* @COGL_FEATURE_OFFSCREEN_MULTISAMPLE: Multisample support on FBOs
|
||||||
* @COGL_FEATURE_OFFSCREEN_BLIT:
|
* @COGL_FEATURE_OFFSCREEN_BLIT: Blit support on FBOs
|
||||||
* @COGL_FEATURE_FOUR_CLIP_PLANES:
|
* @COGL_FEATURE_FOUR_CLIP_PLANES: At least 4 clip planes available
|
||||||
* @COGL_FEATURE_STENCIL_BUFFER:
|
* @COGL_FEATURE_STENCIL_BUFFER: Stencil buffer support
|
||||||
* @COGL_FEATURE_VBOS:
|
* @COGL_FEATURE_VBOS: VBO support
|
||||||
*
|
*
|
||||||
* Flags for the supported features.
|
* Flags for the supported features.
|
||||||
|
*
|
||||||
|
* Since: 0.8
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -211,11 +215,13 @@ typedef enum
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* CoglBufferTarget:
|
* CoglBufferTarget:
|
||||||
* @COGL_WINDOW_BUFFER:
|
* @COGL_WINDOW_BUFFER: FIXME
|
||||||
* @COGL_MASK_BUFFER:
|
* @COGL_MASK_BUFFER: FIXME
|
||||||
* @COGL_OFFSCREEN_BUFFER:
|
* @COGL_OFFSCREEN_BUFFER: FIXME
|
||||||
*
|
*
|
||||||
|
* Target flags for FBOs.
|
||||||
*
|
*
|
||||||
|
* Since: 0.8
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@ INCLUDES = \
|
|||||||
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
|
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
|
||||||
-I$(top_builddir)/clutter \
|
-I$(top_builddir)/clutter \
|
||||||
-I$(top_builddir)/clutter/cogl \
|
-I$(top_builddir)/clutter/cogl \
|
||||||
|
-DG_LOG_DOMAIN=\"Cogl-Common\" \
|
||||||
-DCLUTTER_COMPILATION \
|
-DCLUTTER_COMPILATION \
|
||||||
$(CLUTTER_CFLAGS) \
|
$(CLUTTER_CFLAGS) \
|
||||||
$(CLUTTER_DEBUG_CFLAGS) \
|
$(CLUTTER_DEBUG_CFLAGS) \
|
||||||
|
@ -209,6 +209,8 @@ COGL_HANDLE_DEFINE (Mesh, mesh, mesh_handles);
|
|||||||
*
|
*
|
||||||
* This creates a Cogl handle for a new mesh that you can then start to add
|
* This creates a Cogl handle for a new mesh that you can then start to add
|
||||||
* attributes too.
|
* attributes too.
|
||||||
|
*
|
||||||
|
* Return value: a new #CoglHandle
|
||||||
*/
|
*/
|
||||||
CoglHandle
|
CoglHandle
|
||||||
cogl_mesh_new (guint n_vertices)
|
cogl_mesh_new (guint n_vertices)
|
||||||
|
@ -20,6 +20,7 @@ INCLUDES = \
|
|||||||
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
|
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
|
||||||
-I$(top_builddir)/clutter \
|
-I$(top_builddir)/clutter \
|
||||||
-I$(top_builddir)/clutter/cogl \
|
-I$(top_builddir)/clutter/cogl \
|
||||||
|
-DG_LOG_DOMAIN=\"Cogl-GL\" \
|
||||||
-DCLUTTER_COMPILATION \
|
-DCLUTTER_COMPILATION \
|
||||||
$(CLUTTER_CFLAGS) \
|
$(CLUTTER_CFLAGS) \
|
||||||
$(CLUTTER_DEBUG_CFLAGS) \
|
$(CLUTTER_DEBUG_CFLAGS) \
|
||||||
|
@ -56,8 +56,10 @@ cogl_create_context ()
|
|||||||
_context->last_path = 0;
|
_context->last_path = 0;
|
||||||
|
|
||||||
_context->texture_handles = NULL;
|
_context->texture_handles = NULL;
|
||||||
_context->texture_vertices_size = 0;
|
_context->texture_vertices = g_array_new (FALSE, FALSE,
|
||||||
_context->texture_vertices = NULL;
|
sizeof (CoglTextureGLVertex));
|
||||||
|
_context->texture_indices = g_array_new (FALSE, FALSE,
|
||||||
|
sizeof (GLushort));
|
||||||
|
|
||||||
_context->fbo_handles = NULL;
|
_context->fbo_handles = NULL;
|
||||||
_context->draw_buffer = COGL_WINDOW_BUFFER;
|
_context->draw_buffer = COGL_WINDOW_BUFFER;
|
||||||
@ -148,6 +150,11 @@ cogl_destroy_context ()
|
|||||||
if (_context->program_handles)
|
if (_context->program_handles)
|
||||||
g_array_free (_context->program_handles, TRUE);
|
g_array_free (_context->program_handles, TRUE);
|
||||||
|
|
||||||
|
if (_context->texture_vertices)
|
||||||
|
g_array_free (_context->texture_vertices, TRUE);
|
||||||
|
if (_context->texture_indices)
|
||||||
|
g_array_free (_context->texture_indices, TRUE);
|
||||||
|
|
||||||
g_free (_context);
|
g_free (_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +63,14 @@ typedef struct
|
|||||||
|
|
||||||
/* Textures */
|
/* Textures */
|
||||||
GArray *texture_handles;
|
GArray *texture_handles;
|
||||||
CoglTextureGLVertex *texture_vertices;
|
GArray *texture_vertices;
|
||||||
gulong texture_vertices_size;
|
GArray *texture_indices;
|
||||||
|
/* The gl texture number that the above vertices apply to. This to
|
||||||
|
detect when a different slice is encountered so that the vertices
|
||||||
|
can be flushed */
|
||||||
|
GLuint texture_current;
|
||||||
|
GLenum texture_target;
|
||||||
|
GLenum texture_wrap_mode;
|
||||||
|
|
||||||
/* Framebuffer objects */
|
/* Framebuffer objects */
|
||||||
GArray *fbo_handles;
|
GArray *fbo_handles;
|
||||||
|
@ -1919,6 +1919,95 @@ cogl_texture_get_data (CoglHandle handle,
|
|||||||
return byte_size;
|
return byte_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cogl_texture_flush_vertices (void)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
if (ctx->texture_vertices->len > 0)
|
||||||
|
{
|
||||||
|
int needed_indices;
|
||||||
|
CoglTextureGLVertex *p
|
||||||
|
= (CoglTextureGLVertex *) ctx->texture_vertices->data;
|
||||||
|
|
||||||
|
/* The indices are always the same sequence regardless of the
|
||||||
|
vertices so we only need to change it if there are more
|
||||||
|
vertices than ever before */
|
||||||
|
needed_indices = ctx->texture_vertices->len / 4 * 6;
|
||||||
|
if (needed_indices > ctx->texture_indices->len)
|
||||||
|
{
|
||||||
|
int old_len = ctx->texture_indices->len;
|
||||||
|
int vert_num = old_len / 6 * 4;
|
||||||
|
int i;
|
||||||
|
GLushort *q;
|
||||||
|
|
||||||
|
/* Add two triangles for each quad to the list of
|
||||||
|
indices. That makes six new indices but two of the
|
||||||
|
vertices in the triangles are shared. */
|
||||||
|
g_array_set_size (ctx->texture_indices, needed_indices);
|
||||||
|
q = &g_array_index (ctx->texture_indices, GLushort, old_len);
|
||||||
|
|
||||||
|
for (i = old_len;
|
||||||
|
i < ctx->texture_indices->len;
|
||||||
|
i += 6, vert_num += 4)
|
||||||
|
{
|
||||||
|
*(q++) = vert_num + 0;
|
||||||
|
*(q++) = vert_num + 1;
|
||||||
|
*(q++) = vert_num + 3;
|
||||||
|
|
||||||
|
*(q++) = vert_num + 1;
|
||||||
|
*(q++) = vert_num + 2;
|
||||||
|
*(q++) = vert_num + 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GE( glVertexPointer (2, GL_FLOAT,
|
||||||
|
sizeof (CoglTextureGLVertex), p->v ) );
|
||||||
|
GE( glTexCoordPointer (2, GL_FLOAT,
|
||||||
|
sizeof (CoglTextureGLVertex), p->t ) );
|
||||||
|
|
||||||
|
GE( glBindTexture (ctx->texture_target, ctx->texture_current) );
|
||||||
|
GE( ctx->pf_glDrawRangeElements (GL_TRIANGLES,
|
||||||
|
0, ctx->texture_vertices->len - 1,
|
||||||
|
needed_indices,
|
||||||
|
GL_UNSIGNED_SHORT,
|
||||||
|
ctx->texture_indices->data) );
|
||||||
|
|
||||||
|
g_array_set_size (ctx->texture_vertices, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cogl_texture_add_quad_vertices (GLfloat x1, GLfloat y1,
|
||||||
|
GLfloat x2, GLfloat y2,
|
||||||
|
GLfloat tx1, GLfloat ty1,
|
||||||
|
GLfloat tx2, GLfloat ty2)
|
||||||
|
{
|
||||||
|
CoglTextureGLVertex *p;
|
||||||
|
GLushort first_vert;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
/* Add the four vertices of the quad to the list of queued
|
||||||
|
vertices */
|
||||||
|
first_vert = ctx->texture_vertices->len;
|
||||||
|
g_array_set_size (ctx->texture_vertices, first_vert + 4);
|
||||||
|
p = &g_array_index (ctx->texture_vertices, CoglTextureGLVertex, first_vert);
|
||||||
|
|
||||||
|
p->v[0] = x1; p->v[1] = y1;
|
||||||
|
p->t[0] = tx1; p->t[1] = ty1;
|
||||||
|
p++;
|
||||||
|
p->v[0] = x1; p->v[1] = y2;
|
||||||
|
p->t[0] = tx1; p->t[1] = ty2;
|
||||||
|
p++;
|
||||||
|
p->v[0] = x2; p->v[1] = y2;
|
||||||
|
p->t[0] = tx2; p->t[1] = ty2;
|
||||||
|
p++;
|
||||||
|
p->v[0] = x2; p->v[1] = y1;
|
||||||
|
p->t[0] = tx2; p->t[1] = ty1;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_quad_sw (CoglTexture *tex,
|
_cogl_texture_quad_sw (CoglTexture *tex,
|
||||||
CoglFixed x1,
|
CoglFixed x1,
|
||||||
@ -1939,11 +2028,7 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
CoglFixed slice_tx2 , slice_ty2;
|
CoglFixed slice_tx2 , slice_ty2;
|
||||||
CoglFixed slice_qx1 , slice_qy1;
|
CoglFixed slice_qx1 , slice_qy1;
|
||||||
CoglFixed slice_qx2 , slice_qy2;
|
CoglFixed slice_qx2 , slice_qy2;
|
||||||
GLfloat tex_coords[8];
|
|
||||||
GLfloat quad_coords[8];
|
|
||||||
GLuint gl_handle;
|
GLuint gl_handle;
|
||||||
gulong enable_flags = (COGL_ENABLE_VERTEX_ARRAY
|
|
||||||
| COGL_ENABLE_TEXCOORD_ARRAY);
|
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
@ -1951,26 +2036,13 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
printf("=== Drawing Tex Quad (Software Tiling Mode) ===\n");
|
printf("=== Drawing Tex Quad (Software Tiling Mode) ===\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Prepare GL state */
|
|
||||||
if (tex->gl_target == CGL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
enable_flags |= COGL_ENABLE_TEXTURE_RECT;
|
|
||||||
else
|
|
||||||
enable_flags |= COGL_ENABLE_TEXTURE_2D;
|
|
||||||
|
|
||||||
if (ctx->color_alpha < 255
|
|
||||||
|| tex->bitmap.format & COGL_A_BIT)
|
|
||||||
{
|
|
||||||
enable_flags |= COGL_ENABLE_BLEND;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->enable_backface_culling)
|
|
||||||
enable_flags |= COGL_ENABLE_BACKFACE_CULLING;
|
|
||||||
|
|
||||||
cogl_enable (enable_flags);
|
|
||||||
|
|
||||||
/* We can't use hardware repeat so we need to set clamp to edge
|
/* 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 */
|
otherwise it might pull in edge pixels from the other side */
|
||||||
|
if (ctx->texture_vertices->len > 0
|
||||||
|
&& ctx->texture_wrap_mode != GL_CLAMP_TO_EDGE)
|
||||||
|
_cogl_texture_flush_vertices ();
|
||||||
_cogl_texture_set_wrap_mode_parameter (tex, GL_CLAMP_TO_EDGE);
|
_cogl_texture_set_wrap_mode_parameter (tex, GL_CLAMP_TO_EDGE);
|
||||||
|
ctx->texture_wrap_mode = GL_CLAMP_TO_EDGE;
|
||||||
|
|
||||||
/* If the texture coordinates are backwards then swap both the
|
/* If the texture coordinates are backwards then swap both the
|
||||||
geometry and texture coordinates so that the texture will be
|
geometry and texture coordinates so that the texture will be
|
||||||
@ -1995,9 +2067,6 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
ty2 = temp;
|
ty2 = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
GE( glTexCoordPointer (2, GL_FLOAT, 0, tex_coords) );
|
|
||||||
GE( glVertexPointer (2, GL_FLOAT, 0, quad_coords) );
|
|
||||||
|
|
||||||
/* Scale ratio from texture to quad widths */
|
/* Scale ratio from texture to quad widths */
|
||||||
tw = COGL_FIXED_FROM_INT (tex->bitmap.width);
|
tw = COGL_FIXED_FROM_INT (tex->bitmap.width);
|
||||||
th = COGL_FIXED_FROM_INT (tex->bitmap.height);
|
th = COGL_FIXED_FROM_INT (tex->bitmap.height);
|
||||||
@ -2095,24 +2164,22 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
iter_y.index * iter_x.array->len +
|
iter_y.index * iter_x.array->len +
|
||||||
iter_x.index);
|
iter_x.index);
|
||||||
|
|
||||||
GE( glBindTexture (tex->gl_target, gl_handle) );
|
/* If we're using a different texture from the one already queued
|
||||||
|
then flush the vertices */
|
||||||
|
if (ctx->texture_vertices->len > 0
|
||||||
|
&& gl_handle != ctx->texture_current)
|
||||||
|
_cogl_texture_flush_vertices ();
|
||||||
|
ctx->texture_target = tex->gl_target;
|
||||||
|
ctx->texture_current = gl_handle;
|
||||||
|
|
||||||
#define CFX_F COGL_FIXED_TO_FLOAT
|
_cogl_texture_add_quad_vertices (COGL_FIXED_TO_FLOAT (slice_qx1),
|
||||||
|
COGL_FIXED_TO_FLOAT (slice_qy1),
|
||||||
/* Draw textured quad */
|
COGL_FIXED_TO_FLOAT (slice_qx2),
|
||||||
tex_coords[0] = CFX_F(slice_tx1); tex_coords[1] = CFX_F(slice_ty2);
|
COGL_FIXED_TO_FLOAT (slice_qy2),
|
||||||
tex_coords[2] = CFX_F(slice_tx2); tex_coords[3] = CFX_F(slice_ty2);
|
COGL_FIXED_TO_FLOAT (slice_tx1),
|
||||||
tex_coords[4] = CFX_F(slice_tx1); tex_coords[5] = CFX_F(slice_ty1);
|
COGL_FIXED_TO_FLOAT (slice_ty1),
|
||||||
tex_coords[6] = CFX_F(slice_tx2); tex_coords[7] = CFX_F(slice_ty1);
|
COGL_FIXED_TO_FLOAT (slice_tx2),
|
||||||
|
COGL_FIXED_TO_FLOAT (slice_ty2));
|
||||||
quad_coords[0] = CFX_F(slice_qx1); quad_coords[1] = CFX_F(slice_qy2);
|
|
||||||
quad_coords[2] = CFX_F(slice_qx2); quad_coords[3] = CFX_F(slice_qy2);
|
|
||||||
quad_coords[4] = CFX_F(slice_qx1); quad_coords[5] = CFX_F(slice_qy1);
|
|
||||||
quad_coords[6] = CFX_F(slice_qx2); quad_coords[7] = CFX_F(slice_qy1);
|
|
||||||
|
|
||||||
GE (glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) );
|
|
||||||
|
|
||||||
#undef CFX_F
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2128,13 +2195,10 @@ _cogl_texture_quad_hw (CoglTexture *tex,
|
|||||||
CoglFixed tx2,
|
CoglFixed tx2,
|
||||||
CoglFixed ty2)
|
CoglFixed ty2)
|
||||||
{
|
{
|
||||||
GLfloat tex_coords[8];
|
|
||||||
GLfloat quad_coords[8];
|
|
||||||
GLuint gl_handle;
|
GLuint gl_handle;
|
||||||
CoglTexSliceSpan *x_span;
|
CoglTexSliceSpan *x_span;
|
||||||
CoglTexSliceSpan *y_span;
|
CoglTexSliceSpan *y_span;
|
||||||
gulong enable_flags = (COGL_ENABLE_VERTEX_ARRAY
|
GLenum wrap_mode;
|
||||||
| COGL_ENABLE_TEXCOORD_ARRAY);
|
|
||||||
|
|
||||||
#if COGL_DEBUG
|
#if COGL_DEBUG
|
||||||
printf("=== Drawing Tex Quad (Hardware Tiling Mode) ===\n");
|
printf("=== Drawing Tex Quad (Hardware Tiling Mode) ===\n");
|
||||||
@ -2142,24 +2206,6 @@ _cogl_texture_quad_hw (CoglTexture *tex,
|
|||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
/* Prepare GL state */
|
|
||||||
if (tex->gl_target == CGL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
enable_flags |= COGL_ENABLE_TEXTURE_RECT;
|
|
||||||
else
|
|
||||||
enable_flags |= COGL_ENABLE_TEXTURE_2D;
|
|
||||||
|
|
||||||
if (ctx->color_alpha < 255
|
|
||||||
|| tex->bitmap.format & COGL_A_BIT)
|
|
||||||
{
|
|
||||||
enable_flags |= COGL_ENABLE_BLEND;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->enable_backface_culling)
|
|
||||||
enable_flags |= COGL_ENABLE_BACKFACE_CULLING;
|
|
||||||
|
|
||||||
cogl_enable (enable_flags);
|
|
||||||
|
|
||||||
|
|
||||||
/* If the texture coords are all in the range [0,1] then we want to
|
/* If the texture coords are all in the range [0,1] then we want to
|
||||||
clamp the coords to the edge otherwise it can pull in edge pixels
|
clamp the coords to the edge otherwise it can pull in edge pixels
|
||||||
from the wrong side when scaled */
|
from the wrong side when scaled */
|
||||||
@ -2167,16 +2213,24 @@ _cogl_texture_quad_hw (CoglTexture *tex,
|
|||||||
&& tx2 >= 0 && tx2 <= COGL_FIXED_1
|
&& tx2 >= 0 && tx2 <= COGL_FIXED_1
|
||||||
&& ty1 >= 0 && ty1 <= COGL_FIXED_1
|
&& ty1 >= 0 && ty1 <= COGL_FIXED_1
|
||||||
&& ty2 >= 0 && ty2 <= COGL_FIXED_1)
|
&& ty2 >= 0 && ty2 <= COGL_FIXED_1)
|
||||||
_cogl_texture_set_wrap_mode_parameter (tex, GL_CLAMP_TO_EDGE);
|
wrap_mode = GL_CLAMP_TO_EDGE;
|
||||||
else
|
else
|
||||||
_cogl_texture_set_wrap_mode_parameter (tex, GL_REPEAT);
|
wrap_mode = GL_REPEAT;
|
||||||
|
|
||||||
GE( glTexCoordPointer (2, GL_FLOAT, 0, tex_coords) );
|
|
||||||
GE( glVertexPointer (2, GL_FLOAT, 0, quad_coords) );
|
|
||||||
|
|
||||||
/* Pick and bind opengl texture object */
|
/* Pick and bind opengl texture object */
|
||||||
gl_handle = g_array_index (tex->slice_gl_handles, GLuint, 0);
|
gl_handle = g_array_index (tex->slice_gl_handles, GLuint, 0);
|
||||||
GE( glBindTexture (tex->gl_target, gl_handle) );
|
|
||||||
|
/* If we're using a different texture from the one already queued
|
||||||
|
then flush the vertices */
|
||||||
|
if (ctx->texture_vertices->len > 0
|
||||||
|
&& (gl_handle != ctx->texture_current
|
||||||
|
|| ctx->texture_wrap_mode != wrap_mode))
|
||||||
|
_cogl_texture_flush_vertices ();
|
||||||
|
ctx->texture_target = tex->gl_target;
|
||||||
|
ctx->texture_current = gl_handle;
|
||||||
|
ctx->texture_wrap_mode = wrap_mode;
|
||||||
|
|
||||||
|
_cogl_texture_set_wrap_mode_parameter (tex, wrap_mode);
|
||||||
|
|
||||||
/* Don't include the waste in the texture coordinates */
|
/* Don't include the waste in the texture coordinates */
|
||||||
x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, 0);
|
x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, 0);
|
||||||
@ -2197,36 +2251,26 @@ _cogl_texture_quad_hw (CoglTexture *tex,
|
|||||||
ty2 *= y_span->size;
|
ty2 *= y_span->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CFX_F(x) COGL_FIXED_TO_FLOAT(x)
|
_cogl_texture_add_quad_vertices (COGL_FIXED_TO_FLOAT (x1),
|
||||||
|
COGL_FIXED_TO_FLOAT (y1),
|
||||||
/* Draw textured quad */
|
COGL_FIXED_TO_FLOAT (x2),
|
||||||
tex_coords[0] = CFX_F(tx1); tex_coords[1] = CFX_F(ty2);
|
COGL_FIXED_TO_FLOAT (y2),
|
||||||
tex_coords[2] = CFX_F(tx2); tex_coords[3] = CFX_F(ty2);
|
COGL_FIXED_TO_FLOAT (tx1),
|
||||||
tex_coords[4] = CFX_F(tx1); tex_coords[5] = CFX_F(ty1);
|
COGL_FIXED_TO_FLOAT (ty1),
|
||||||
tex_coords[6] = CFX_F(tx2); tex_coords[7] = CFX_F(ty1);
|
COGL_FIXED_TO_FLOAT (tx2),
|
||||||
|
COGL_FIXED_TO_FLOAT (ty2));
|
||||||
quad_coords[0] = CFX_F(x1); quad_coords[1] = CFX_F(y2);
|
|
||||||
quad_coords[2] = CFX_F(x2); quad_coords[3] = CFX_F(y2);
|
|
||||||
quad_coords[4] = CFX_F(x1); quad_coords[5] = CFX_F(y1);
|
|
||||||
quad_coords[6] = CFX_F(x2); quad_coords[7] = CFX_F(y1);
|
|
||||||
|
|
||||||
GE (glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) );
|
|
||||||
|
|
||||||
#undef CFX_F
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_texture_rectangle (CoglHandle handle,
|
cogl_texture_multiple_rectangles (CoglHandle handle,
|
||||||
CoglFixed x1,
|
const CoglFixed *verts,
|
||||||
CoglFixed y1,
|
guint n_rects)
|
||||||
CoglFixed x2,
|
|
||||||
CoglFixed y2,
|
|
||||||
CoglFixed tx1,
|
|
||||||
CoglFixed ty1,
|
|
||||||
CoglFixed tx2,
|
|
||||||
CoglFixed ty2)
|
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
CoglTexture *tex;
|
||||||
|
gulong enable_flags = (COGL_ENABLE_VERTEX_ARRAY
|
||||||
|
| COGL_ENABLE_TEXCOORD_ARRAY);
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
/* Check if valid texture */
|
/* Check if valid texture */
|
||||||
if (!cogl_is_texture (handle))
|
if (!cogl_is_texture (handle))
|
||||||
@ -2243,22 +2287,73 @@ cogl_texture_rectangle (CoglHandle handle,
|
|||||||
if (tex->slice_gl_handles->len == 0)
|
if (tex->slice_gl_handles->len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (tx1 == tx2 || ty1 == ty2)
|
/* Prepare GL state */
|
||||||
return;
|
if (tex->gl_target == CGL_TEXTURE_RECTANGLE_ARB)
|
||||||
|
enable_flags |= COGL_ENABLE_TEXTURE_RECT;
|
||||||
|
else
|
||||||
|
enable_flags |= COGL_ENABLE_TEXTURE_2D;
|
||||||
|
|
||||||
/* If there is only one GL texture and either the texture is NPOT
|
if (ctx->color_alpha < 255
|
||||||
(no waste) or all of the coordinates are in the range [0,1] then
|
|| tex->bitmap.format & COGL_A_BIT)
|
||||||
we can use hardware tiling */
|
enable_flags |= COGL_ENABLE_BLEND;
|
||||||
|
|
||||||
|
if (ctx->enable_backface_culling)
|
||||||
|
enable_flags |= COGL_ENABLE_BACKFACE_CULLING;
|
||||||
|
|
||||||
|
cogl_enable (enable_flags);
|
||||||
|
|
||||||
|
g_array_set_size (ctx->texture_vertices, 0);
|
||||||
|
|
||||||
|
while (n_rects-- > 0)
|
||||||
|
{
|
||||||
|
if (verts[4] != verts[6] && verts[5] != verts[7])
|
||||||
|
{
|
||||||
|
/* If there is only one GL texture and either the texture is
|
||||||
|
NPOT (no waste) or all of the coordinates are in the
|
||||||
|
range [0,1] then we can use hardware tiling */
|
||||||
if (tex->slice_gl_handles->len == 1
|
if (tex->slice_gl_handles->len == 1
|
||||||
&& ((cogl_features_available (COGL_FEATURE_TEXTURE_NPOT)
|
&& ((cogl_features_available (COGL_FEATURE_TEXTURE_NPOT)
|
||||||
&& tex->gl_target == GL_TEXTURE_2D)
|
&& tex->gl_target == GL_TEXTURE_2D)
|
||||||
|| (tx1 >= 0 && tx1 <= COGL_FIXED_1
|
|| (verts[4] >= 0 && verts[4] <= COGL_FIXED_1
|
||||||
&& tx2 >= 0 && tx2 <= COGL_FIXED_1
|
&& verts[6] >= 0 && verts[6] <= COGL_FIXED_1
|
||||||
&& ty1 >= 0 && ty1 <= COGL_FIXED_1
|
&& verts[5] >= 0 && verts[5] <= COGL_FIXED_1
|
||||||
&& ty2 >= 0 && ty2 <= COGL_FIXED_1)))
|
&& verts[7] >= 0 && verts[7] <= COGL_FIXED_1)))
|
||||||
_cogl_texture_quad_hw (tex, x1,y1, x2,y2, tx1,ty1, tx2,ty2);
|
_cogl_texture_quad_hw (tex, verts[0],verts[1], verts[2],verts[3],
|
||||||
|
verts[4],verts[5], verts[6],verts[7]);
|
||||||
else
|
else
|
||||||
_cogl_texture_quad_sw (tex, x1,y1, x2,y2, tx1,ty1, tx2,ty2);
|
_cogl_texture_quad_sw (tex, verts[0],verts[1], verts[2],verts[3],
|
||||||
|
verts[4],verts[5], verts[6],verts[7]);
|
||||||
|
}
|
||||||
|
|
||||||
|
verts += 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
_cogl_texture_flush_vertices ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_texture_rectangle (CoglHandle handle,
|
||||||
|
CoglFixed x1,
|
||||||
|
CoglFixed y1,
|
||||||
|
CoglFixed x2,
|
||||||
|
CoglFixed y2,
|
||||||
|
CoglFixed tx1,
|
||||||
|
CoglFixed ty1,
|
||||||
|
CoglFixed tx2,
|
||||||
|
CoglFixed ty2)
|
||||||
|
{
|
||||||
|
CoglFixed verts[8];
|
||||||
|
|
||||||
|
verts[0] = x1;
|
||||||
|
verts[1] = y1;
|
||||||
|
verts[2] = x2;
|
||||||
|
verts[3] = y2;
|
||||||
|
verts[4] = tx1;
|
||||||
|
verts[5] = ty1;
|
||||||
|
verts[6] = tx2;
|
||||||
|
verts[7] = ty2;
|
||||||
|
|
||||||
|
cogl_texture_multiple_rectangles (handle, verts, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -2307,22 +2402,8 @@ cogl_texture_polygon (CoglHandle handle,
|
|||||||
/* Make sure there is enough space in the global texture vertex
|
/* Make sure there is enough space in the global texture vertex
|
||||||
array. This is used so we can render the polygon with a single
|
array. This is used so we can render the polygon with a single
|
||||||
call to OpenGL but still support any number of vertices */
|
call to OpenGL but still support any number of vertices */
|
||||||
if (ctx->texture_vertices_size < n_vertices)
|
g_array_set_size (ctx->texture_vertices, n_vertices);
|
||||||
{
|
p = (CoglTextureGLVertex *) ctx->texture_vertices->data;
|
||||||
guint nsize = ctx->texture_vertices_size;
|
|
||||||
|
|
||||||
if (nsize == 0)
|
|
||||||
nsize = 1;
|
|
||||||
do
|
|
||||||
nsize *= 2;
|
|
||||||
while (nsize < n_vertices);
|
|
||||||
|
|
||||||
ctx->texture_vertices_size = nsize;
|
|
||||||
|
|
||||||
ctx->texture_vertices = g_realloc (ctx->texture_vertices,
|
|
||||||
nsize
|
|
||||||
* sizeof (CoglTextureGLVertex));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Prepare GL state */
|
/* Prepare GL state */
|
||||||
enable_flags = (COGL_ENABLE_VERTEX_ARRAY
|
enable_flags = (COGL_ENABLE_VERTEX_ARRAY
|
||||||
@ -2340,14 +2421,12 @@ cogl_texture_polygon (CoglHandle handle,
|
|||||||
if (use_color)
|
if (use_color)
|
||||||
{
|
{
|
||||||
enable_flags |= COGL_ENABLE_COLOR_ARRAY;
|
enable_flags |= COGL_ENABLE_COLOR_ARRAY;
|
||||||
GE( glColorPointer (4, GL_UNSIGNED_BYTE, sizeof (CoglTextureGLVertex),
|
GE( glColorPointer (4, GL_UNSIGNED_BYTE,
|
||||||
ctx->texture_vertices[0].c) );
|
sizeof (CoglTextureGLVertex), p->c) );
|
||||||
}
|
}
|
||||||
|
|
||||||
GE( glVertexPointer (3, GL_FLOAT, sizeof (CoglTextureGLVertex),
|
GE( glVertexPointer (3, GL_FLOAT, sizeof (CoglTextureGLVertex), p->v ) );
|
||||||
ctx->texture_vertices[0].v) );
|
GE( glTexCoordPointer (2, GL_FLOAT, sizeof (CoglTextureGLVertex), p->t ) );
|
||||||
GE( glTexCoordPointer (2, GL_FLOAT, sizeof (CoglTextureGLVertex),
|
|
||||||
ctx->texture_vertices[0].t) );
|
|
||||||
|
|
||||||
cogl_enable (enable_flags);
|
cogl_enable (enable_flags);
|
||||||
|
|
||||||
@ -2370,9 +2449,11 @@ cogl_texture_polygon (CoglHandle handle,
|
|||||||
|
|
||||||
gl_handle = g_array_index (tex->slice_gl_handles, GLuint, tex_num++);
|
gl_handle = g_array_index (tex->slice_gl_handles, GLuint, tex_num++);
|
||||||
|
|
||||||
|
p = (CoglTextureGLVertex *) ctx->texture_vertices->data;
|
||||||
|
|
||||||
/* Convert the vertices into an array of GLfloats ready to pass to
|
/* Convert the vertices into an array of GLfloats ready to pass to
|
||||||
OpenGL */
|
OpenGL */
|
||||||
for (i = 0, p = ctx->texture_vertices; i < n_vertices; i++, p++)
|
for (i = 0; i < n_vertices; i++, p++)
|
||||||
{
|
{
|
||||||
CoglFixed tx, ty;
|
CoglFixed tx, ty;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ INCLUDES = \
|
|||||||
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
|
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
|
||||||
-I$(top_builddir)/clutter \
|
-I$(top_builddir)/clutter \
|
||||||
-I$(top_builddir)/clutter/cogl \
|
-I$(top_builddir)/clutter/cogl \
|
||||||
|
-DG_LOG_DOMAIN=\"Cogl-GLES\" \
|
||||||
-DCLUTTER_COMPILATION \
|
-DCLUTTER_COMPILATION \
|
||||||
$(CLUTTER_CFLAGS) \
|
$(CLUTTER_CFLAGS) \
|
||||||
$(CLUTTER_DEBUG_CFLAGS) \
|
$(CLUTTER_DEBUG_CFLAGS) \
|
||||||
|
@ -59,8 +59,10 @@ cogl_create_context ()
|
|||||||
_context->last_path = 0;
|
_context->last_path = 0;
|
||||||
|
|
||||||
_context->texture_handles = NULL;
|
_context->texture_handles = NULL;
|
||||||
_context->texture_vertices_size = 0;
|
_context->texture_vertices = g_array_new (FALSE, FALSE,
|
||||||
_context->texture_vertices = NULL;
|
sizeof (CoglTextureGLVertex));
|
||||||
|
_context->texture_indices = g_array_new (FALSE, FALSE,
|
||||||
|
sizeof (GLushort));
|
||||||
|
|
||||||
_context->fbo_handles = NULL;
|
_context->fbo_handles = NULL;
|
||||||
_context->program_handles = NULL;
|
_context->program_handles = NULL;
|
||||||
@ -104,7 +106,9 @@ cogl_destroy_context ()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_context->texture_vertices)
|
if (_context->texture_vertices)
|
||||||
g_free (_context->texture_vertices);
|
g_array_free (_context->texture_vertices, TRUE);
|
||||||
|
if (_context->texture_indices)
|
||||||
|
g_array_free (_context->texture_indices, TRUE);
|
||||||
|
|
||||||
if (_context->texture_handles)
|
if (_context->texture_handles)
|
||||||
g_array_free (_context->texture_handles, TRUE);
|
g_array_free (_context->texture_handles, TRUE);
|
||||||
|
@ -65,8 +65,13 @@ typedef struct
|
|||||||
|
|
||||||
/* Textures */
|
/* Textures */
|
||||||
GArray *texture_handles;
|
GArray *texture_handles;
|
||||||
CoglTextureGLVertex *texture_vertices;
|
GArray *texture_vertices;
|
||||||
gulong texture_vertices_size;
|
GArray *texture_indices;
|
||||||
|
/* The gl texture number that the above vertices apply to. This to
|
||||||
|
detect when a different slice is encountered so that the vertices
|
||||||
|
can be flushed */
|
||||||
|
GLuint texture_current;
|
||||||
|
GLenum texture_target;
|
||||||
|
|
||||||
/* Framebuffer objects */
|
/* Framebuffer objects */
|
||||||
GArray *fbo_handles;
|
GArray *fbo_handles;
|
||||||
|
@ -2047,6 +2047,94 @@ cogl_texture_get_data (CoglHandle handle,
|
|||||||
return byte_size;
|
return byte_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cogl_texture_flush_vertices (void)
|
||||||
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
if (ctx->texture_vertices->len > 0)
|
||||||
|
{
|
||||||
|
int needed_indices;
|
||||||
|
CoglTextureGLVertex *p
|
||||||
|
= (CoglTextureGLVertex *) ctx->texture_vertices->data;
|
||||||
|
|
||||||
|
/* The indices are always the same sequence regardless of the
|
||||||
|
vertices so we only need to change it if there are more
|
||||||
|
vertices than ever before */
|
||||||
|
needed_indices = ctx->texture_vertices->len / 4 * 6;
|
||||||
|
if (needed_indices > ctx->texture_indices->len)
|
||||||
|
{
|
||||||
|
int old_len = ctx->texture_indices->len;
|
||||||
|
int vert_num = old_len / 6 * 4;
|
||||||
|
int i;
|
||||||
|
GLushort *q;
|
||||||
|
|
||||||
|
/* Add two triangles for each quad to the list of
|
||||||
|
indices. That makes six new indices but two of the
|
||||||
|
vertices in the triangles are shared. */
|
||||||
|
g_array_set_size (ctx->texture_indices, needed_indices);
|
||||||
|
q = &g_array_index (ctx->texture_indices, GLushort, old_len);
|
||||||
|
|
||||||
|
for (i = old_len;
|
||||||
|
i < ctx->texture_indices->len;
|
||||||
|
i += 6, vert_num += 4)
|
||||||
|
{
|
||||||
|
*(q++) = vert_num + 0;
|
||||||
|
*(q++) = vert_num + 1;
|
||||||
|
*(q++) = vert_num + 3;
|
||||||
|
|
||||||
|
*(q++) = vert_num + 1;
|
||||||
|
*(q++) = vert_num + 2;
|
||||||
|
*(q++) = vert_num + 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GE( glVertexPointer (2, GL_FLOAT,
|
||||||
|
sizeof (CoglTextureGLVertex), p->v ) );
|
||||||
|
GE( glTexCoordPointer (2, GL_FLOAT,
|
||||||
|
sizeof (CoglTextureGLVertex), p->t ) );
|
||||||
|
|
||||||
|
GE( glBindTexture (ctx->texture_target, ctx->texture_current) );
|
||||||
|
GE( glDrawElements (GL_TRIANGLES,
|
||||||
|
needed_indices,
|
||||||
|
GL_UNSIGNED_SHORT,
|
||||||
|
ctx->texture_indices->data) );
|
||||||
|
|
||||||
|
g_array_set_size (ctx->texture_vertices, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cogl_texture_add_quad_vertices (GLfloat x1, GLfloat y1,
|
||||||
|
GLfloat x2, GLfloat y2,
|
||||||
|
GLfloat tx1, GLfloat ty1,
|
||||||
|
GLfloat tx2, GLfloat ty2)
|
||||||
|
{
|
||||||
|
CoglTextureGLVertex *p;
|
||||||
|
GLushort first_vert;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
/* Add the four vertices of the quad to the list of queued
|
||||||
|
vertices */
|
||||||
|
first_vert = ctx->texture_vertices->len;
|
||||||
|
g_array_set_size (ctx->texture_vertices, first_vert + 4);
|
||||||
|
p = &g_array_index (ctx->texture_vertices, CoglTextureGLVertex, first_vert);
|
||||||
|
|
||||||
|
p->v[0] = x1; p->v[1] = y1;
|
||||||
|
p->t[0] = tx1; p->t[1] = ty1;
|
||||||
|
p++;
|
||||||
|
p->v[0] = x1; p->v[1] = y2;
|
||||||
|
p->t[0] = tx1; p->t[1] = ty2;
|
||||||
|
p++;
|
||||||
|
p->v[0] = x2; p->v[1] = y2;
|
||||||
|
p->t[0] = tx2; p->t[1] = ty2;
|
||||||
|
p++;
|
||||||
|
p->v[0] = x2; p->v[1] = y1;
|
||||||
|
p->t[0] = tx2; p->t[1] = ty1;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_quad_sw (CoglTexture *tex,
|
_cogl_texture_quad_sw (CoglTexture *tex,
|
||||||
CoglFixed x1,
|
CoglFixed x1,
|
||||||
@ -2067,12 +2155,7 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
CoglFixed slice_tx2 , slice_ty2;
|
CoglFixed slice_tx2 , slice_ty2;
|
||||||
CoglFixed slice_qx1 , slice_qy1;
|
CoglFixed slice_qx1 , slice_qy1;
|
||||||
CoglFixed slice_qx2 , slice_qy2;
|
CoglFixed slice_qx2 , slice_qy2;
|
||||||
GLfloat tex_coords[8];
|
|
||||||
GLfloat quad_coords[8];
|
|
||||||
GLuint gl_handle;
|
GLuint gl_handle;
|
||||||
gulong enable_flags = (COGL_ENABLE_TEXTURE_2D
|
|
||||||
| COGL_ENABLE_VERTEX_ARRAY
|
|
||||||
| COGL_ENABLE_TEXCOORD_ARRAY);
|
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
@ -2080,19 +2163,6 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
printf("=== Drawing Tex Quad (Software Tiling Mode) ===\n");
|
printf("=== Drawing Tex Quad (Software Tiling Mode) ===\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Prepare GL state */
|
|
||||||
if (ctx->color_alpha < 255
|
|
||||||
|| tex->bitmap.format & COGL_A_BIT)
|
|
||||||
{
|
|
||||||
enable_flags |= COGL_ENABLE_BLEND;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->enable_backface_culling)
|
|
||||||
enable_flags |= COGL_ENABLE_BACKFACE_CULLING;
|
|
||||||
|
|
||||||
cogl_enable (enable_flags);
|
|
||||||
|
|
||||||
/* If the texture coordinates are backwards then swap both the
|
/* If the texture coordinates are backwards then swap both the
|
||||||
geometry and texture coordinates so that the texture will be
|
geometry and texture coordinates so that the texture will be
|
||||||
flipped but we can still use the same algorithm to iterate the
|
flipped but we can still use the same algorithm to iterate the
|
||||||
@ -2116,9 +2186,6 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
ty2 = temp;
|
ty2 = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
GE( glTexCoordPointer (2, GL_FLOAT, 0, tex_coords) );
|
|
||||||
GE( glVertexPointer (2, GL_FLOAT, 0, quad_coords) );
|
|
||||||
|
|
||||||
/* Scale ratio from texture to quad widths */
|
/* Scale ratio from texture to quad widths */
|
||||||
tw = COGL_FIXED_FROM_INT (tex->bitmap.width);
|
tw = COGL_FIXED_FROM_INT (tex->bitmap.width);
|
||||||
th = COGL_FIXED_FROM_INT (tex->bitmap.height);
|
th = COGL_FIXED_FROM_INT (tex->bitmap.height);
|
||||||
@ -2168,7 +2235,6 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
slice_ty1 /= iter_y.span->size;
|
slice_ty1 /= iter_y.span->size;
|
||||||
slice_ty2 /= iter_y.span->size;
|
slice_ty2 /= iter_y.span->size;
|
||||||
|
|
||||||
|
|
||||||
/* Iterate until whole quad width covered */
|
/* Iterate until whole quad width covered */
|
||||||
for (_cogl_span_iter_begin (&iter_x, tex->slice_x_spans,
|
for (_cogl_span_iter_begin (&iter_x, tex->slice_x_spans,
|
||||||
first_tx, tx1, tx2) ;
|
first_tx, tx1, tx2) ;
|
||||||
@ -2211,25 +2277,22 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
iter_y.index * iter_x.array->len +
|
iter_y.index * iter_x.array->len +
|
||||||
iter_x.index);
|
iter_x.index);
|
||||||
|
|
||||||
GE( cogl_gles2_wrapper_bind_texture (tex->gl_target, gl_handle,
|
/* If we're using a different texture from the one already queued
|
||||||
tex->gl_intformat) );
|
then flush the vertices */
|
||||||
|
if (ctx->texture_vertices->len > 0
|
||||||
|
&& gl_handle != ctx->texture_current)
|
||||||
|
_cogl_texture_flush_vertices ();
|
||||||
|
ctx->texture_target = tex->gl_target;
|
||||||
|
ctx->texture_current = gl_handle;
|
||||||
|
|
||||||
#define CFX_F COGL_FIXED_TO_FLOAT
|
_cogl_texture_add_quad_vertices (COGL_FIXED_TO_FLOAT (slice_qx1),
|
||||||
|
COGL_FIXED_TO_FLOAT (slice_qy1),
|
||||||
/* Draw textured quad */
|
COGL_FIXED_TO_FLOAT (slice_qx2),
|
||||||
tex_coords[0] = CFX_F(slice_tx1); tex_coords[1] = CFX_F(slice_ty2);
|
COGL_FIXED_TO_FLOAT (slice_qy2),
|
||||||
tex_coords[2] = CFX_F(slice_tx2); tex_coords[3] = CFX_F(slice_ty2);
|
COGL_FIXED_TO_FLOAT (slice_tx1),
|
||||||
tex_coords[4] = CFX_F(slice_tx1); tex_coords[5] = CFX_F(slice_ty1);
|
COGL_FIXED_TO_FLOAT (slice_ty1),
|
||||||
tex_coords[6] = CFX_F(slice_tx2); tex_coords[7] = CFX_F(slice_ty1);
|
COGL_FIXED_TO_FLOAT (slice_tx2),
|
||||||
|
COGL_FIXED_TO_FLOAT (slice_ty2));
|
||||||
quad_coords[0] = CFX_F(slice_qx1); quad_coords[1] = CFX_F(slice_qy2);
|
|
||||||
quad_coords[2] = CFX_F(slice_qx2); quad_coords[3] = CFX_F(slice_qy2);
|
|
||||||
quad_coords[4] = CFX_F(slice_qx1); quad_coords[5] = CFX_F(slice_qy1);
|
|
||||||
quad_coords[6] = CFX_F(slice_qx2); quad_coords[7] = CFX_F(slice_qy1);
|
|
||||||
|
|
||||||
GE (glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) );
|
|
||||||
|
|
||||||
#undef CFX_F
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2245,14 +2308,9 @@ _cogl_texture_quad_hw (CoglTexture *tex,
|
|||||||
CoglFixed tx2,
|
CoglFixed tx2,
|
||||||
CoglFixed ty2)
|
CoglFixed ty2)
|
||||||
{
|
{
|
||||||
GLfloat tex_coords[8];
|
|
||||||
GLfloat quad_coords[8];
|
|
||||||
GLuint gl_handle;
|
GLuint gl_handle;
|
||||||
CoglTexSliceSpan *x_span;
|
CoglTexSliceSpan *x_span;
|
||||||
CoglTexSliceSpan *y_span;
|
CoglTexSliceSpan *y_span;
|
||||||
gulong enable_flags = (COGL_ENABLE_TEXTURE_2D
|
|
||||||
| COGL_ENABLE_VERTEX_ARRAY
|
|
||||||
| COGL_ENABLE_TEXCOORD_ARRAY);
|
|
||||||
|
|
||||||
#if COGL_DEBUG
|
#if COGL_DEBUG
|
||||||
printf("=== Drawing Tex Quad (Hardware Tiling Mode) ===\n");
|
printf("=== Drawing Tex Quad (Hardware Tiling Mode) ===\n");
|
||||||
@ -2260,25 +2318,16 @@ _cogl_texture_quad_hw (CoglTexture *tex,
|
|||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
/* Prepare GL state */
|
|
||||||
if (ctx->color_alpha < 255
|
|
||||||
|| tex->bitmap.format & COGL_A_BIT)
|
|
||||||
{
|
|
||||||
enable_flags |= COGL_ENABLE_BLEND;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->enable_backface_culling)
|
|
||||||
enable_flags |= COGL_ENABLE_BACKFACE_CULLING;
|
|
||||||
|
|
||||||
cogl_enable (enable_flags);
|
|
||||||
|
|
||||||
GE( glTexCoordPointer (2, GL_FLOAT, 0, tex_coords) );
|
|
||||||
GE( glVertexPointer (2, GL_FLOAT, 0, quad_coords) );
|
|
||||||
|
|
||||||
/* Pick and bind opengl texture object */
|
/* Pick and bind opengl texture object */
|
||||||
gl_handle = g_array_index (tex->slice_gl_handles, GLuint, 0);
|
gl_handle = g_array_index (tex->slice_gl_handles, GLuint, 0);
|
||||||
GE( cogl_gles2_wrapper_bind_texture (tex->gl_target, gl_handle,
|
|
||||||
tex->gl_intformat) );
|
/* If we're using a different texture from the one already queued
|
||||||
|
then flush the vertices */
|
||||||
|
if (ctx->texture_vertices->len > 0
|
||||||
|
&& gl_handle != ctx->texture_current)
|
||||||
|
_cogl_texture_flush_vertices ();
|
||||||
|
ctx->texture_target = tex->gl_target;
|
||||||
|
ctx->texture_current = gl_handle;
|
||||||
|
|
||||||
/* Don't include the waste in the texture coordinates */
|
/* Don't include the waste in the texture coordinates */
|
||||||
x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, 0);
|
x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, 0);
|
||||||
@ -2290,36 +2339,27 @@ _cogl_texture_quad_hw (CoglTexture *tex,
|
|||||||
ty1 = ty1 * (y_span->size - y_span->waste) / y_span->size;
|
ty1 = ty1 * (y_span->size - y_span->waste) / y_span->size;
|
||||||
ty2 = ty2 * (y_span->size - y_span->waste) / y_span->size;
|
ty2 = ty2 * (y_span->size - y_span->waste) / y_span->size;
|
||||||
|
|
||||||
#define CFX_F(x) COGL_FIXED_TO_FLOAT(x)
|
_cogl_texture_add_quad_vertices (COGL_FIXED_TO_FLOAT (x1),
|
||||||
|
COGL_FIXED_TO_FLOAT (y1),
|
||||||
/* Draw textured quad */
|
COGL_FIXED_TO_FLOAT (x2),
|
||||||
tex_coords[0] = CFX_F(tx1); tex_coords[1] = CFX_F(ty2);
|
COGL_FIXED_TO_FLOAT (y2),
|
||||||
tex_coords[2] = CFX_F(tx2); tex_coords[3] = CFX_F(ty2);
|
COGL_FIXED_TO_FLOAT (tx1),
|
||||||
tex_coords[4] = CFX_F(tx1); tex_coords[5] = CFX_F(ty1);
|
COGL_FIXED_TO_FLOAT (ty1),
|
||||||
tex_coords[6] = CFX_F(tx2); tex_coords[7] = CFX_F(ty1);
|
COGL_FIXED_TO_FLOAT (tx2),
|
||||||
|
COGL_FIXED_TO_FLOAT (ty2));
|
||||||
quad_coords[0] = CFX_F(x1); quad_coords[1] = CFX_F(y2);
|
|
||||||
quad_coords[2] = CFX_F(x2); quad_coords[3] = CFX_F(y2);
|
|
||||||
quad_coords[4] = CFX_F(x1); quad_coords[5] = CFX_F(y1);
|
|
||||||
quad_coords[6] = CFX_F(x2); quad_coords[7] = CFX_F(y1);
|
|
||||||
|
|
||||||
GE (glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) );
|
|
||||||
|
|
||||||
#undef CFX_F
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_texture_rectangle (CoglHandle handle,
|
cogl_texture_multiple_rectangles (CoglHandle handle,
|
||||||
CoglFixed x1,
|
const CoglFixed *verts,
|
||||||
CoglFixed y1,
|
guint n_rects)
|
||||||
CoglFixed x2,
|
|
||||||
CoglFixed y2,
|
|
||||||
CoglFixed tx1,
|
|
||||||
CoglFixed ty1,
|
|
||||||
CoglFixed tx2,
|
|
||||||
CoglFixed ty2)
|
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
CoglTexture *tex;
|
||||||
|
gulong enable_flags = (COGL_ENABLE_VERTEX_ARRAY
|
||||||
|
| COGL_ENABLE_TEXCOORD_ARRAY
|
||||||
|
| COGL_ENABLE_TEXTURE_2D);
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
/* Check if valid texture */
|
/* Check if valid texture */
|
||||||
if (!cogl_is_texture (handle))
|
if (!cogl_is_texture (handle))
|
||||||
@ -2336,30 +2376,68 @@ cogl_texture_rectangle (CoglHandle handle,
|
|||||||
if (tex->slice_gl_handles->len == 0)
|
if (tex->slice_gl_handles->len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (tx1 == tx2 || ty1 == ty2)
|
/* Prepare GL state */
|
||||||
return;
|
if (ctx->color_alpha < 255
|
||||||
|
|| tex->bitmap.format & COGL_A_BIT)
|
||||||
|
enable_flags |= COGL_ENABLE_BLEND;
|
||||||
|
|
||||||
/* Pick tiling mode according to hw support */
|
if (ctx->enable_backface_culling)
|
||||||
if (cogl_features_available (COGL_FEATURE_TEXTURE_NPOT)
|
enable_flags |= COGL_ENABLE_BACKFACE_CULLING;
|
||||||
&& tex->slice_gl_handles->len == 1)
|
|
||||||
|
cogl_enable (enable_flags);
|
||||||
|
|
||||||
|
g_array_set_size (ctx->texture_vertices, 0);
|
||||||
|
|
||||||
|
while (n_rects-- > 0)
|
||||||
{
|
{
|
||||||
_cogl_texture_quad_hw (tex, x1,y1, x2,y2, tx1,ty1, tx2,ty2);
|
if (verts[4] != verts[6] && verts[5] != verts[7])
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
/* If there is only one GL texture and either the texture is
|
||||||
|
NPOT (no waste) or all of the coordinates are in the
|
||||||
|
range [0,1] then we can use hardware tiling */
|
||||||
if (tex->slice_gl_handles->len == 1
|
if (tex->slice_gl_handles->len == 1
|
||||||
&& tx1 >= -COGL_FIXED_1
|
&& ((cogl_features_available (COGL_FEATURE_TEXTURE_NPOT)
|
||||||
&& tx2 <= COGL_FIXED_1
|
&& tex->gl_target == GL_TEXTURE_2D)
|
||||||
&& ty1 >= -COGL_FIXED_1
|
|| (verts[4] >= 0 && verts[4] <= COGL_FIXED_1
|
||||||
&& ty2 <= COGL_FIXED_1)
|
&& verts[6] >= 0 && verts[6] <= COGL_FIXED_1
|
||||||
{
|
&& verts[5] >= 0 && verts[5] <= COGL_FIXED_1
|
||||||
_cogl_texture_quad_hw (tex, x1,y1, x2,y2, tx1,ty1, tx2,ty2);
|
&& verts[7] >= 0 && verts[7] <= COGL_FIXED_1)))
|
||||||
}
|
_cogl_texture_quad_hw (tex, verts[0],verts[1], verts[2],verts[3],
|
||||||
|
verts[4],verts[5], verts[6],verts[7]);
|
||||||
else
|
else
|
||||||
|
_cogl_texture_quad_sw (tex, verts[0],verts[1], verts[2],verts[3],
|
||||||
|
verts[4],verts[5], verts[6],verts[7]);
|
||||||
|
}
|
||||||
|
|
||||||
|
verts += 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
_cogl_texture_flush_vertices ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_texture_rectangle (CoglHandle handle,
|
||||||
|
CoglFixed x1,
|
||||||
|
CoglFixed y1,
|
||||||
|
CoglFixed x2,
|
||||||
|
CoglFixed y2,
|
||||||
|
CoglFixed tx1,
|
||||||
|
CoglFixed ty1,
|
||||||
|
CoglFixed tx2,
|
||||||
|
CoglFixed ty2)
|
||||||
{
|
{
|
||||||
_cogl_texture_quad_sw (tex, x1,y1, x2,y2, tx1,ty1, tx2,ty2);
|
CoglFixed verts[8];
|
||||||
}
|
|
||||||
}
|
verts[0] = x1;
|
||||||
|
verts[1] = y1;
|
||||||
|
verts[2] = x2;
|
||||||
|
verts[3] = y2;
|
||||||
|
verts[4] = tx1;
|
||||||
|
verts[5] = ty1;
|
||||||
|
verts[6] = tx2;
|
||||||
|
verts[7] = ty2;
|
||||||
|
|
||||||
|
cogl_texture_multiple_rectangles (handle, verts, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -2405,22 +2483,8 @@ cogl_texture_polygon (CoglHandle handle,
|
|||||||
/* Make sure there is enough space in the global texture vertex
|
/* Make sure there is enough space in the global texture vertex
|
||||||
array. This is used so we can render the polygon with a single
|
array. This is used so we can render the polygon with a single
|
||||||
call to OpenGL but still support any number of vertices */
|
call to OpenGL but still support any number of vertices */
|
||||||
if (ctx->texture_vertices_size < n_vertices)
|
g_array_set_size (ctx->texture_vertices, n_vertices);
|
||||||
{
|
p = (CoglTextureGLVertex *) ctx->texture_vertices->data;
|
||||||
guint nsize = ctx->texture_vertices_size;
|
|
||||||
|
|
||||||
if (nsize == 0)
|
|
||||||
nsize = 1;
|
|
||||||
do
|
|
||||||
nsize *= 2;
|
|
||||||
while (nsize < n_vertices);
|
|
||||||
|
|
||||||
ctx->texture_vertices_size = nsize;
|
|
||||||
|
|
||||||
ctx->texture_vertices = g_realloc (ctx->texture_vertices,
|
|
||||||
nsize
|
|
||||||
* sizeof (CoglTextureGLVertex));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Prepare GL state */
|
/* Prepare GL state */
|
||||||
enable_flags = (COGL_ENABLE_TEXTURE_2D
|
enable_flags = (COGL_ENABLE_TEXTURE_2D
|
||||||
@ -2447,14 +2511,12 @@ cogl_texture_polygon (CoglHandle handle,
|
|||||||
if (use_color)
|
if (use_color)
|
||||||
{
|
{
|
||||||
enable_flags |= COGL_ENABLE_COLOR_ARRAY;
|
enable_flags |= COGL_ENABLE_COLOR_ARRAY;
|
||||||
GE( glColorPointer (4, GL_UNSIGNED_BYTE, sizeof (CoglTextureGLVertex),
|
GE( glColorPointer (4, GL_UNSIGNED_BYTE,
|
||||||
ctx->texture_vertices[0].c) );
|
sizeof (CoglTextureGLVertex), p->c) );
|
||||||
}
|
}
|
||||||
|
|
||||||
GE( glVertexPointer (3, GL_FLOAT, sizeof (CoglTextureGLVertex),
|
GE( glVertexPointer (3, GL_FLOAT, sizeof (CoglTextureGLVertex), p->v ) );
|
||||||
ctx->texture_vertices[0].v) );
|
GE( glTexCoordPointer (2, GL_FLOAT, sizeof (CoglTextureGLVertex), p->t ) );
|
||||||
GE( glTexCoordPointer (2, GL_FLOAT, sizeof (CoglTextureGLVertex),
|
|
||||||
ctx->texture_vertices[0].t) );
|
|
||||||
|
|
||||||
cogl_enable (enable_flags);
|
cogl_enable (enable_flags);
|
||||||
|
|
||||||
@ -2464,7 +2526,7 @@ cogl_texture_polygon (CoglHandle handle,
|
|||||||
|
|
||||||
/* Convert the vertices into an array of GLfloats ready to pass to
|
/* Convert the vertices into an array of GLfloats ready to pass to
|
||||||
OpenGL */
|
OpenGL */
|
||||||
for (i = 0, p = ctx->texture_vertices; i < n_vertices; i++, p++)
|
for (i = 0; i < n_vertices; i++, p++)
|
||||||
{
|
{
|
||||||
#define CFX_F COGL_FIXED_TO_FLOAT
|
#define CFX_F COGL_FIXED_TO_FLOAT
|
||||||
|
|
||||||
|
@ -319,6 +319,23 @@ create_cogl_texture (ClutterTexture *texture,
|
|||||||
ClutterGLXTexturePixmapPrivate *priv = texture_glx->priv;
|
ClutterGLXTexturePixmapPrivate *priv = texture_glx->priv;
|
||||||
CoglHandle handle;
|
CoglHandle handle;
|
||||||
gboolean using_rectangle;
|
gboolean using_rectangle;
|
||||||
|
GLint gl_format;
|
||||||
|
CoglPixelFormat cogl_format;
|
||||||
|
guint depth;
|
||||||
|
|
||||||
|
g_object_get (G_OBJECT (texture_glx), "pixmap-depth", &depth, NULL);
|
||||||
|
if (depth == 32)
|
||||||
|
{
|
||||||
|
gl_format = GL_RGBA;
|
||||||
|
cogl_format = COGL_PIXEL_FORMAT_RGBA_8888;
|
||||||
|
}
|
||||||
|
else if (depth == 24)
|
||||||
|
{
|
||||||
|
gl_format = GL_RGB;
|
||||||
|
cogl_format = COGL_PIXEL_FORMAT_RGB_888;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
g_critical ("Can't create a TFP cogl texture for pixmap with depth < 24");
|
||||||
|
|
||||||
/* We want to use the GL_ARB_texture_rectangle extension on some
|
/* We want to use the GL_ARB_texture_rectangle extension on some
|
||||||
chipsets because GL_ARB_texture_non_power_of_two is not always
|
chipsets because GL_ARB_texture_non_power_of_two is not always
|
||||||
@ -332,21 +349,20 @@ create_cogl_texture (ClutterTexture *texture,
|
|||||||
glGenTextures (1, &tex);
|
glGenTextures (1, &tex);
|
||||||
glBindTexture (CGL_TEXTURE_RECTANGLE_ARB, tex);
|
glBindTexture (CGL_TEXTURE_RECTANGLE_ARB, tex);
|
||||||
glTexImage2D (CGL_TEXTURE_RECTANGLE_ARB, 0,
|
glTexImage2D (CGL_TEXTURE_RECTANGLE_ARB, 0,
|
||||||
GL_RGBA, width, height,
|
GL_RGB, width, height,
|
||||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
|
||||||
handle = cogl_texture_new_from_foreign (tex, CGL_TEXTURE_RECTANGLE_ARB,
|
handle = cogl_texture_new_from_foreign (tex, CGL_TEXTURE_RECTANGLE_ARB,
|
||||||
width, height,
|
width, height,
|
||||||
0, 0,
|
0, 0,
|
||||||
COGL_PIXEL_FORMAT_RGBA_8888
|
cogl_format | COGL_BGR_BIT);
|
||||||
| COGL_BGR_BIT);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
handle
|
handle
|
||||||
= cogl_texture_new_with_size (width, height,
|
= cogl_texture_new_with_size (width, height,
|
||||||
-1, FALSE,
|
-1, FALSE,
|
||||||
COGL_PIXEL_FORMAT_RGBA_8888|COGL_BGR_BIT);
|
cogl_format | COGL_BGR_BIT);
|
||||||
|
|
||||||
using_rectangle = FALSE;
|
using_rectangle = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,10 @@ struct _CoglPangoRenderer
|
|||||||
CoglPangoGlyphCache *mipmapped_glyph_cache;
|
CoglPangoGlyphCache *mipmapped_glyph_cache;
|
||||||
|
|
||||||
gboolean use_mipmapping;
|
gboolean use_mipmapping;
|
||||||
|
|
||||||
|
/* Array of rectangles to draw from the current texture */
|
||||||
|
GArray *glyph_rectangles;
|
||||||
|
CoglHandle glyph_texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _CoglPangoRendererClass
|
struct _CoglPangoRendererClass
|
||||||
@ -58,6 +62,46 @@ struct _CoglPangoRendererClass
|
|||||||
PangoRendererClass class_instance;
|
PangoRendererClass class_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
cogl_pango_renderer_glyphs_end (CoglPangoRenderer *priv)
|
||||||
|
{
|
||||||
|
if (priv->glyph_rectangles->len > 0)
|
||||||
|
{
|
||||||
|
CoglFixed *rectangles = (CoglFixed *) priv->glyph_rectangles->data;
|
||||||
|
cogl_texture_multiple_rectangles (priv->glyph_texture, rectangles,
|
||||||
|
priv->glyph_rectangles->len / 8);
|
||||||
|
g_array_set_size (priv->glyph_rectangles, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cogl_pango_renderer_draw_glyph (CoglPangoRenderer *priv,
|
||||||
|
CoglPangoGlyphCacheValue *cache_value,
|
||||||
|
CoglFixed x1,
|
||||||
|
CoglFixed y1)
|
||||||
|
{
|
||||||
|
CoglFixed x2, y2;
|
||||||
|
CoglFixed *p;
|
||||||
|
|
||||||
|
if (priv->glyph_rectangles->len > 0
|
||||||
|
&& priv->glyph_texture != cache_value->texture)
|
||||||
|
cogl_pango_renderer_glyphs_end (priv);
|
||||||
|
|
||||||
|
priv->glyph_texture = cache_value->texture;
|
||||||
|
|
||||||
|
x2 = x1 + CLUTTER_INT_TO_FIXED (cache_value->draw_width);
|
||||||
|
y2 = y1 + CLUTTER_INT_TO_FIXED (cache_value->draw_height);
|
||||||
|
|
||||||
|
g_array_set_size (priv->glyph_rectangles, priv->glyph_rectangles->len + 8);
|
||||||
|
p = &g_array_index (priv->glyph_rectangles, CoglFixed,
|
||||||
|
priv->glyph_rectangles->len - 8);
|
||||||
|
|
||||||
|
*(p++) = x1; *(p++) = y1;
|
||||||
|
*(p++) = x2; *(p++) = y2;
|
||||||
|
*(p++) = cache_value->tx1; *(p++) = cache_value->ty1;
|
||||||
|
*(p++) = cache_value->tx2; *(p++) = cache_value->ty2;
|
||||||
|
}
|
||||||
|
|
||||||
#define COGL_PANGO_UNIT_TO_FIXED(x) ((x) << (COGL_FIXED_Q - 10))
|
#define COGL_PANGO_UNIT_TO_FIXED(x) ((x) << (COGL_FIXED_Q - 10))
|
||||||
|
|
||||||
static void cogl_pango_renderer_finalize (GObject *object);
|
static void cogl_pango_renderer_finalize (GObject *object);
|
||||||
@ -89,6 +133,7 @@ cogl_pango_renderer_init (CoglPangoRenderer *priv)
|
|||||||
priv->glyph_cache = cogl_pango_glyph_cache_new (FALSE);
|
priv->glyph_cache = cogl_pango_glyph_cache_new (FALSE);
|
||||||
priv->mipmapped_glyph_cache = cogl_pango_glyph_cache_new (TRUE);
|
priv->mipmapped_glyph_cache = cogl_pango_glyph_cache_new (TRUE);
|
||||||
priv->use_mipmapping = FALSE;
|
priv->use_mipmapping = FALSE;
|
||||||
|
priv->glyph_rectangles = g_array_new (FALSE, FALSE, sizeof (CoglFixed));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -111,6 +156,7 @@ cogl_pango_renderer_finalize (GObject *object)
|
|||||||
|
|
||||||
cogl_pango_glyph_cache_free (priv->mipmapped_glyph_cache);
|
cogl_pango_glyph_cache_free (priv->mipmapped_glyph_cache);
|
||||||
cogl_pango_glyph_cache_free (priv->glyph_cache);
|
cogl_pango_glyph_cache_free (priv->glyph_cache);
|
||||||
|
g_array_free (priv->glyph_rectangles, TRUE);
|
||||||
|
|
||||||
G_OBJECT_CLASS (cogl_pango_renderer_parent_class)->finalize (object);
|
G_OBJECT_CLASS (cogl_pango_renderer_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@ -454,6 +500,7 @@ cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer,
|
|||||||
int xi,
|
int xi,
|
||||||
int yi)
|
int yi)
|
||||||
{
|
{
|
||||||
|
CoglPangoRenderer *priv = (CoglPangoRenderer *) renderer;
|
||||||
CoglPangoGlyphCacheValue *cache_value;
|
CoglPangoGlyphCacheValue *cache_value;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -474,6 +521,8 @@ cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer,
|
|||||||
{
|
{
|
||||||
PangoFontMetrics *metrics;
|
PangoFontMetrics *metrics;
|
||||||
|
|
||||||
|
cogl_pango_renderer_glyphs_end (priv);
|
||||||
|
|
||||||
if (font == NULL ||
|
if (font == NULL ||
|
||||||
(metrics = pango_font_get_metrics (font, NULL)) == NULL)
|
(metrics = pango_font_get_metrics (font, NULL)) == NULL)
|
||||||
{
|
{
|
||||||
@ -503,10 +552,14 @@ cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer,
|
|||||||
gi->glyph);
|
gi->glyph);
|
||||||
|
|
||||||
if (cache_value == NULL)
|
if (cache_value == NULL)
|
||||||
|
{
|
||||||
|
cogl_pango_renderer_glyphs_end (priv);
|
||||||
|
|
||||||
cogl_pango_renderer_draw_box (COGL_FIXED_TO_INT (x),
|
cogl_pango_renderer_draw_box (COGL_FIXED_TO_INT (x),
|
||||||
COGL_FIXED_TO_INT (y),
|
COGL_FIXED_TO_INT (y),
|
||||||
PANGO_UNKNOWN_GLYPH_WIDTH,
|
PANGO_UNKNOWN_GLYPH_WIDTH,
|
||||||
PANGO_UNKNOWN_GLYPH_HEIGHT);
|
PANGO_UNKNOWN_GLYPH_HEIGHT);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CoglFixed width, height;
|
CoglFixed width, height;
|
||||||
@ -517,15 +570,12 @@ cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer,
|
|||||||
width = x + COGL_FIXED_FROM_INT (cache_value->draw_width);
|
width = x + COGL_FIXED_FROM_INT (cache_value->draw_width);
|
||||||
height = y + COGL_FIXED_FROM_INT (cache_value->draw_height);
|
height = y + COGL_FIXED_FROM_INT (cache_value->draw_height);
|
||||||
|
|
||||||
/* Render the glyph from the texture */
|
cogl_pango_renderer_draw_glyph (priv, cache_value, x, y);
|
||||||
cogl_texture_rectangle (cache_value->texture,
|
|
||||||
x, y,
|
|
||||||
width, height,
|
|
||||||
cache_value->tx1, cache_value->ty1,
|
|
||||||
cache_value->tx2, cache_value->ty2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xi += gi->geometry.width;
|
xi += gi->geometry.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cogl_pango_renderer_glyphs_end (priv);
|
||||||
}
|
}
|
||||||
|
@ -433,11 +433,23 @@ event_translate (ClutterBackend *backend,
|
|||||||
it from trying to resize the window again */
|
it from trying to resize the window again */
|
||||||
stage_x11->handling_configure = TRUE;
|
stage_x11->handling_configure = TRUE;
|
||||||
|
|
||||||
|
CLUTTER_NOTE (BACKEND, "%s: ConfigureNotify[%x] (%d, %d)",
|
||||||
|
G_STRLOC,
|
||||||
|
(unsigned int) stage_x11->xwin,
|
||||||
|
xevent->xconfigure.width,
|
||||||
|
xevent->xconfigure.height);
|
||||||
|
|
||||||
clutter_actor_set_size (CLUTTER_ACTOR (stage),
|
clutter_actor_set_size (CLUTTER_ACTOR (stage),
|
||||||
xevent->xconfigure.width,
|
xevent->xconfigure.width,
|
||||||
xevent->xconfigure.height);
|
xevent->xconfigure.height);
|
||||||
|
|
||||||
stage_x11->handling_configure = FALSE;
|
stage_x11->handling_configure = FALSE;
|
||||||
|
|
||||||
|
/* the resize process is complete, so we can ask the stage
|
||||||
|
* to set up the GL viewport with the new size
|
||||||
|
*/
|
||||||
|
CLUTTER_SET_PRIVATE_FLAGS (CLUTTER_ACTOR (stage_x11->wrapper),
|
||||||
|
CLUTTER_ACTOR_SYNC_MATRICES);
|
||||||
}
|
}
|
||||||
res = FALSE;
|
res = FALSE;
|
||||||
break;
|
break;
|
||||||
|
@ -282,13 +282,21 @@ clutter_stage_x11_allocate (ClutterActor *self,
|
|||||||
queue. Handling the first event will undo the work of setting
|
queue. Handling the first event will undo the work of setting
|
||||||
the second property which will cause it to keep generating
|
the second property which will cause it to keep generating
|
||||||
events in an infinite loop. See bug #810 */
|
events in an infinite loop. See bug #810 */
|
||||||
if (stage_x11->xwin != None
|
if (stage_x11->xwin != None &&
|
||||||
&& !stage_x11->is_foreign_xwin
|
!stage_x11->is_foreign_xwin &&
|
||||||
&& !stage_x11->handling_configure)
|
!stage_x11->handling_configure)
|
||||||
|
{
|
||||||
|
CLUTTER_NOTE (BACKEND, "%s: XResizeWindow[%x] (%d, %d)",
|
||||||
|
G_STRLOC,
|
||||||
|
(unsigned int) stage_x11->xwin,
|
||||||
|
stage_x11->xwin_width,
|
||||||
|
stage_x11->xwin_height);
|
||||||
|
|
||||||
XResizeWindow (stage_x11->xdpy,
|
XResizeWindow (stage_x11->xdpy,
|
||||||
stage_x11->xwin,
|
stage_x11->xwin,
|
||||||
stage_x11->xwin_width,
|
stage_x11->xwin_width,
|
||||||
stage_x11->xwin_height);
|
stage_x11->xwin_height);
|
||||||
|
}
|
||||||
|
|
||||||
clutter_stage_x11_fix_window_size (stage_x11);
|
clutter_stage_x11_fix_window_size (stage_x11);
|
||||||
|
|
||||||
@ -298,9 +306,6 @@ clutter_stage_x11_allocate (ClutterActor *self,
|
|||||||
clutter_actor_unrealize (self);
|
clutter_actor_unrealize (self);
|
||||||
clutter_actor_realize (self);
|
clutter_actor_realize (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLUTTER_SET_PRIVATE_FLAGS (CLUTTER_ACTOR (stage_x11->wrapper),
|
|
||||||
CLUTTER_ACTOR_SYNC_MATRICES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* chain up to fill in actor->priv->allocation */
|
/* chain up to fill in actor->priv->allocation */
|
||||||
@ -397,6 +402,8 @@ clutter_stage_x11_set_fullscreen (ClutterStageWindow *stage_window,
|
|||||||
if (!stage)
|
if (!stage)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES);
|
||||||
|
|
||||||
if (is_fullscreen)
|
if (is_fullscreen)
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -479,8 +486,6 @@ clutter_stage_x11_set_fullscreen (ClutterStageWindow *stage_window,
|
|||||||
stage_x11->fullscreen_on_map = FALSE;
|
stage_x11->fullscreen_on_map = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -740,6 +745,8 @@ clutter_x11_set_stage_foreign (ClutterStage *stage,
|
|||||||
clutter_actor_set_geometry (actor, &geom);
|
clutter_actor_set_geometry (actor, &geom);
|
||||||
clutter_actor_realize (actor);
|
clutter_actor_realize (actor);
|
||||||
|
|
||||||
|
CLUTTER_SET_PRIVATE_FLAGS (actor, CLUTTER_ACTOR_SYNC_MATRICES);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -769,4 +776,3 @@ clutter_stage_x11_unmap (ClutterStageX11 *stage_x11)
|
|||||||
CLUTTER_ACTOR_UNSET_FLAGS (stage_x11, CLUTTER_ACTOR_MAPPED);
|
CLUTTER_ACTOR_UNSET_FLAGS (stage_x11, CLUTTER_ACTOR_MAPPED);
|
||||||
CLUTTER_ACTOR_UNSET_FLAGS (stage_x11->wrapper, CLUTTER_ACTOR_MAPPED);
|
CLUTTER_ACTOR_UNSET_FLAGS (stage_x11->wrapper, CLUTTER_ACTOR_MAPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,8 +57,8 @@
|
|||||||
<xi:include href="xml/clutter-rectangle.xml"/>
|
<xi:include href="xml/clutter-rectangle.xml"/>
|
||||||
<xi:include href="xml/clutter-texture.xml"/>
|
<xi:include href="xml/clutter-texture.xml"/>
|
||||||
<xi:include href="xml/clutter-clone-texture.xml"/>
|
<xi:include href="xml/clutter-clone-texture.xml"/>
|
||||||
<xi:include href="xml/clutter-cairo-texture.xml"/>
|
|
||||||
<xi:include href="xml/clutter-text.xml"/>
|
<xi:include href="xml/clutter-text.xml"/>
|
||||||
|
<xi:include href="xml/clutter-cairo-texture.xml"/>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|
||||||
<chapter>
|
<chapter>
|
||||||
|
@ -28,6 +28,7 @@ clutter_media_get_type
|
|||||||
<FILE>clutter-units</FILE>
|
<FILE>clutter-units</FILE>
|
||||||
<TITLE>Unit conversion</TITLE>
|
<TITLE>Unit conversion</TITLE>
|
||||||
ClutterUnit
|
ClutterUnit
|
||||||
|
CLUTTER_UNITS_FORMAT
|
||||||
CLUTTER_UNITS_FROM_DEVICE
|
CLUTTER_UNITS_FROM_DEVICE
|
||||||
CLUTTER_UNITS_TO_DEVICE
|
CLUTTER_UNITS_TO_DEVICE
|
||||||
CLUTTER_UNITS_FROM_FIXED
|
CLUTTER_UNITS_FROM_FIXED
|
||||||
@ -1497,9 +1498,6 @@ clutter_shader_float_get_type
|
|||||||
clutter_shader_int_get_type
|
clutter_shader_int_get_type
|
||||||
clutter_shader_matrix_get_type
|
clutter_shader_matrix_get_type
|
||||||
clutter_shader_error_quark
|
clutter_shader_error_quark
|
||||||
clutter_shader_float_get_type
|
|
||||||
clutter_shader_int_get_type
|
|
||||||
clutter_shader_matrix_get_type
|
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
@ -1582,31 +1580,6 @@ ClutterIntervalPrivate
|
|||||||
clutter_interval_get_type
|
clutter_interval_get_type
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
|
||||||
<TITLE>Key Bindings</TITLE>
|
|
||||||
<FILE>clutter-binding-pool</FILE>
|
|
||||||
ClutterBindingPool
|
|
||||||
ClutterBindingActionFunc
|
|
||||||
|
|
||||||
<SUBSECTION>
|
|
||||||
clutter_binding_pool_new
|
|
||||||
clutter_binding_pool_get_for_class
|
|
||||||
clutter_binding_pool_find
|
|
||||||
|
|
||||||
<SUBSECTION>
|
|
||||||
clutter_binding_pool_install_action
|
|
||||||
clutter_binding_pool_install_closure
|
|
||||||
clutter_binding_pool_override_action
|
|
||||||
clutter_binding_pool_override_closure
|
|
||||||
clutter_binding_pool_find_action
|
|
||||||
clutter_binding_pool_remove_action
|
|
||||||
clutter_binding_pool_block_action
|
|
||||||
clutter_binding_pool_unblock_action
|
|
||||||
|
|
||||||
<SUBSECTION>
|
|
||||||
clutter_binding_pool_activate
|
|
||||||
</SECTION>
|
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>clutter-cairo-texture</FILE>
|
<FILE>clutter-cairo-texture</FILE>
|
||||||
<TITLE>ClutterCairoTexture</TITLE>
|
<TITLE>ClutterCairoTexture</TITLE>
|
||||||
@ -1634,6 +1607,7 @@ CLUTTER_CAIRO_TEXTURE_GET_CLASS
|
|||||||
<SUBSECTION Private>
|
<SUBSECTION Private>
|
||||||
ClutterCairoTexturePrivate
|
ClutterCairoTexturePrivate
|
||||||
clutter_cairo_texture_get_type
|
clutter_cairo_texture_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<TITLE>ClutterText</TITLE>
|
<TITLE>ClutterText</TITLE>
|
||||||
@ -1713,3 +1687,28 @@ CLUTTER_TYPE_TEXT
|
|||||||
ClutterTextPrivate
|
ClutterTextPrivate
|
||||||
clutter_text_get_type
|
clutter_text_get_type
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<TITLE>Key Bindings</TITLE>
|
||||||
|
<FILE>clutter-binding-pool</FILE>
|
||||||
|
ClutterBindingPool
|
||||||
|
ClutterBindingActionFunc
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
clutter_binding_pool_new
|
||||||
|
clutter_binding_pool_get_for_class
|
||||||
|
clutter_binding_pool_find
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
clutter_binding_pool_install_action
|
||||||
|
clutter_binding_pool_install_closure
|
||||||
|
clutter_binding_pool_override_action
|
||||||
|
clutter_binding_pool_override_closure
|
||||||
|
clutter_binding_pool_find_action
|
||||||
|
clutter_binding_pool_remove_action
|
||||||
|
clutter_binding_pool_block_action
|
||||||
|
clutter_binding_pool_unblock_action
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
clutter_binding_pool_activate
|
||||||
|
</SECTION>
|
||||||
|
@ -120,6 +120,7 @@ cogl_texture_set_region
|
|||||||
cogl_texture_ref
|
cogl_texture_ref
|
||||||
cogl_texture_unref
|
cogl_texture_unref
|
||||||
cogl_texture_rectangle
|
cogl_texture_rectangle
|
||||||
|
cogl_texture_multiple_rectangles
|
||||||
cogl_texture_polygon
|
cogl_texture_polygon
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ on_paint (ClutterActor *actor, CallbackData *data)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
ClutterGeometry stage_size;
|
ClutterGeometry stage_size;
|
||||||
guint hand_width, hand_height;
|
gint hand_width, hand_height;
|
||||||
GSList *node;
|
GSList *node;
|
||||||
|
|
||||||
clutter_actor_get_allocation_geometry (data->stage, &stage_size);
|
clutter_actor_get_allocation_geometry (data->stage, &stage_size);
|
||||||
|
@ -26,7 +26,7 @@ raise_top (gpointer ignored)
|
|||||||
static ClutterActor *
|
static ClutterActor *
|
||||||
clone_box (ClutterTexture *original)
|
clone_box (ClutterTexture *original)
|
||||||
{
|
{
|
||||||
guint width, height;
|
gint width, height;
|
||||||
ClutterActor *group;
|
ClutterActor *group;
|
||||||
ClutterActor *clone;
|
ClutterActor *clone;
|
||||||
|
|
||||||
|
@ -21,19 +21,19 @@ init_handles ()
|
|||||||
clutter_actor_set_position (p[i], 0, 0);
|
clutter_actor_set_position (p[i], 0, 0);
|
||||||
clutter_group_add (CLUTTER_GROUP (main_stage), p[i]);
|
clutter_group_add (CLUTTER_GROUP (main_stage), p[i]);
|
||||||
|
|
||||||
clutter_actor_set_position (p[i],
|
clutter_actor_set_positionu (p[i],
|
||||||
CLUTTER_FIXED_TO_INT (v[i].x) -
|
v[i].x -
|
||||||
clutter_actor_get_width (p[i])/2,
|
clutter_actor_get_widthu (p[i])/2,
|
||||||
CLUTTER_FIXED_TO_INT (v[i].y) -
|
v[i].y -
|
||||||
clutter_actor_get_height (p[i])/2);
|
clutter_actor_get_heightu (p[i])/2);
|
||||||
|
|
||||||
clutter_actor_raise_top (p[i]);
|
clutter_actor_raise_top (p[i]);
|
||||||
|
|
||||||
clutter_actor_show (p[i]);
|
clutter_actor_show (p[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
v1.x = CLUTTER_INT_TO_FIXED (clutter_actor_get_width (rect)/2);
|
v1.x = clutter_actor_get_widthu (rect) / 2;
|
||||||
v1.y = CLUTTER_INT_TO_FIXED (clutter_actor_get_height (rect)/2);
|
v1.y = clutter_actor_get_heightu (rect) / 2;
|
||||||
v1.z = 0;
|
v1.z = 0;
|
||||||
|
|
||||||
clutter_actor_apply_transform_to_point (rect, &v1, &v2);
|
clutter_actor_apply_transform_to_point (rect, &v1, &v2);
|
||||||
@ -41,11 +41,11 @@ init_handles ()
|
|||||||
clutter_actor_set_size (p[4], 5, 5);
|
clutter_actor_set_size (p[4], 5, 5);
|
||||||
clutter_actor_set_position (p[4], 0, 0);
|
clutter_actor_set_position (p[4], 0, 0);
|
||||||
clutter_group_add (CLUTTER_GROUP (main_stage), p[4]);
|
clutter_group_add (CLUTTER_GROUP (main_stage), p[4]);
|
||||||
clutter_actor_set_position (p[4],
|
clutter_actor_set_positionu (p[4],
|
||||||
CLUTTER_FIXED_TO_INT (v2.x) -
|
v2.x -
|
||||||
clutter_actor_get_width (p[4])/2,
|
clutter_actor_get_widthu (p[4])/2,
|
||||||
CLUTTER_FIXED_TO_INT (v2.y) -
|
v2.y -
|
||||||
clutter_actor_get_height (p[4])/2);
|
clutter_actor_get_heightu (p[4])/2);
|
||||||
|
|
||||||
clutter_actor_raise_top (p[4]);
|
clutter_actor_raise_top (p[4]);
|
||||||
|
|
||||||
@ -62,23 +62,21 @@ place_handles ()
|
|||||||
clutter_actor_get_abs_allocation_vertices (rect, v);
|
clutter_actor_get_abs_allocation_vertices (rect, v);
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
clutter_actor_set_position (p[i],
|
clutter_actor_set_positionu (p[i],
|
||||||
CLUTTER_FIXED_TO_INT (v[i].x) -
|
v[i].x -
|
||||||
clutter_actor_get_width (p[i])/2,
|
clutter_actor_get_widthu (p[i])/2,
|
||||||
CLUTTER_FIXED_TO_INT (v[i].y) -
|
v[i].y -
|
||||||
clutter_actor_get_height (p[i])/2);
|
clutter_actor_get_heightu (p[i])/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
v1.x = CLUTTER_INT_TO_FIXED (clutter_actor_get_width (rect)/2);
|
v1.x = clutter_actor_get_widthu (rect)/2;
|
||||||
v1.y = CLUTTER_INT_TO_FIXED (clutter_actor_get_height (rect)/2);
|
v1.y = clutter_actor_get_heightu (rect)/2;
|
||||||
v1.z = 0;
|
v1.z = 0;
|
||||||
|
|
||||||
clutter_actor_apply_transform_to_point (rect, &v1, &v2);
|
clutter_actor_apply_transform_to_point (rect, &v1, &v2);
|
||||||
clutter_actor_set_position (p[4],
|
clutter_actor_set_positionu (p[4],
|
||||||
CLUTTER_FIXED_TO_INT (v2.x) -
|
v2.x - clutter_actor_get_widthu (p[4])/2,
|
||||||
clutter_actor_get_width (p[4])/2,
|
v2.y - clutter_actor_get_heightu (p[4])/2);
|
||||||
CLUTTER_FIXED_TO_INT (v2.y) -
|
|
||||||
clutter_actor_get_height (p[4])/2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define M(m,row,col) (m)[col*4+row]
|
#define M(m,row,col) (m)[col*4+row]
|
||||||
@ -127,7 +125,7 @@ on_event (ClutterStage *stage,
|
|||||||
gint x, y;
|
gint x, y;
|
||||||
gint i;
|
gint i;
|
||||||
ClutterActorBox box1, box2;
|
ClutterActorBox box1, box2;
|
||||||
ClutterFixed xp, yp;
|
ClutterUnit xp, yp;
|
||||||
|
|
||||||
i = find_handle_index (dragging);
|
i = find_handle_index (dragging);
|
||||||
|
|
||||||
@ -139,25 +137,24 @@ on_event (ClutterStage *stage,
|
|||||||
clutter_actor_get_allocation_box (dragging, &box1);
|
clutter_actor_get_allocation_box (dragging, &box1);
|
||||||
clutter_actor_get_allocation_box (rect, &box2);
|
clutter_actor_get_allocation_box (rect, &box2);
|
||||||
|
|
||||||
xp = CLUTTER_INT_TO_FIXED (x-3) - box1.x1;
|
xp = CLUTTER_UNITS_FROM_DEVICE (x - 3) - box1.x1;
|
||||||
yp = CLUTTER_INT_TO_FIXED (y-3) - box1.y1;
|
yp = CLUTTER_UNITS_FROM_DEVICE (y - 3) - box1.y1;
|
||||||
|
|
||||||
if (i == 4)
|
if (i == 4)
|
||||||
{
|
{
|
||||||
g_debug ("moving box by %f, %f",
|
g_debug ("moving box by %f, %f",
|
||||||
CLUTTER_FIXED_TO_FLOAT (xp),
|
CLUTTER_UNITS_TO_FLOAT (xp),
|
||||||
CLUTTER_FIXED_TO_FLOAT (yp));
|
CLUTTER_UNITS_TO_FLOAT (yp));
|
||||||
|
|
||||||
clutter_actor_move_by (rect,
|
clutter_actor_move_byu (rect, xp, yp);
|
||||||
CLUTTER_FIXED_TO_INT(xp),
|
|
||||||
CLUTTER_FIXED_TO_INT(yp));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_debug ("adjusting box by %f, %f, handle %d",
|
g_debug ("adjusting box by %f, %f, handle %d",
|
||||||
CLUTTER_FIXED_TO_FLOAT (xp),
|
CLUTTER_UNITS_TO_FLOAT (xp),
|
||||||
CLUTTER_FIXED_TO_FLOAT (yp),
|
CLUTTER_UNITS_TO_FLOAT (yp),
|
||||||
i);
|
i);
|
||||||
|
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -1,94 +1,16 @@
|
|||||||
/* Try this text editor, it has issues but does work,
|
#include <stdlib.h>
|
||||||
* try ctrl+A, ctrl+C, ctrl+V, ctrl+X as well as selecting text with
|
|
||||||
* mouse and keyboard, /Øyvind K
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
|
|
||||||
#define FONT "Mono Bold 22px"
|
#define FONT "Mono Bold 22px"
|
||||||
|
|
||||||
static gchar *clipboard = NULL;
|
|
||||||
|
|
||||||
static gchar *runes =
|
static gchar *runes =
|
||||||
"ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ\n"
|
"ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ\n"
|
||||||
"ᛋᚳᛖᚪᛚ᛫ᚦᛖᚪᚻ᛫ᛗᚪᚾᚾᚪ᛫ᚷᛖᚻᚹᛦᛚᚳ᛫ᛗᛁᚳᛚᚢᚾ᛫ᚻᛦᛏ᛫ᛞᚫᛚᚪᚾ\n"
|
"ᛋᚳᛖᚪᛚ᛫ᚦᛖᚪᚻ᛫ᛗᚪᚾᚾᚪ᛫ᚷᛖᚻᚹᛦᛚᚳ᛫ᛗᛁᚳᛚᚢᚾ᛫ᚻᛦᛏ᛫ᛞᚫᛚᚪᚾ\n"
|
||||||
"ᚷᛁᚠ᛫ᚻᛖ᛫ᚹᛁᛚᛖ᛫ᚠᚩᚱ᛫ᛞᚱᛁᚻᛏᚾᛖ᛫ᛞᚩᛗᛖᛋ᛫ᚻᛚᛇᛏᚪᚾ᛬\n";
|
"ᚷᛁᚠ᛫ᚻᛖ᛫ᚹᛁᛚᛖ᛫ᚠᚩᚱ᛫ᛞᚱᛁᚻᛏᚾᛖ᛫ᛞᚩᛗᛖᛋ᛫ᚻᛚᛇᛏᚪᚾ᛬\n";
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
select_all (ClutterText *ttext,
|
|
||||||
const gchar *commandline,
|
|
||||||
ClutterEvent *event)
|
|
||||||
{
|
|
||||||
gint len;
|
|
||||||
len = g_utf8_strlen (clutter_text_get_text (ttext), -1);
|
|
||||||
|
|
||||||
clutter_text_set_cursor_position (ttext, 0);
|
|
||||||
clutter_text_set_selection_bound (ttext, len);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
copy (ClutterText *ttext,
|
|
||||||
const gchar *commandline,
|
|
||||||
ClutterEvent *event)
|
|
||||||
{
|
|
||||||
if (clipboard)
|
|
||||||
g_free (clipboard);
|
|
||||||
clipboard = clutter_text_get_selection (ttext);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
paste (ClutterText *ttext,
|
|
||||||
const gchar *commandline,
|
|
||||||
ClutterEvent *event)
|
|
||||||
{
|
|
||||||
const gchar *p;
|
|
||||||
if (!clipboard)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
for (p=clipboard; *p!='\0'; p=g_utf8_next_char (p))
|
|
||||||
{
|
|
||||||
clutter_text_insert_unichar (ttext, g_utf8_get_char_validated (p, 3));
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
cut (ClutterText *ttext,
|
|
||||||
const gchar *commandline,
|
|
||||||
ClutterEvent *event)
|
|
||||||
{
|
|
||||||
clutter_text_action (ttext, "copy", NULL);
|
|
||||||
clutter_text_action (ttext, "truncate-selection", NULL);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
pageup (ClutterText *ttext,
|
|
||||||
const gchar *commandline,
|
|
||||||
ClutterEvent *event)
|
|
||||||
{
|
|
||||||
gint i;
|
|
||||||
for (i=0;i<10;i++)
|
|
||||||
clutter_text_action (ttext, "move-up", event);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
pagedown (ClutterText *ttext,
|
|
||||||
const gchar *commandline,
|
|
||||||
ClutterEvent *event)
|
|
||||||
{
|
|
||||||
gint i;
|
|
||||||
for (i=0;i<10;i++)
|
|
||||||
clutter_text_action (ttext, "move-down", event);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cursor_event (ClutterText *text,
|
cursor_event (ClutterText *text,
|
||||||
ClutterGeometry *geometry)
|
ClutterGeometry *geometry)
|
||||||
@ -117,6 +39,7 @@ test_text_main (gint argc,
|
|||||||
ClutterColor text_color = { 0x33, 0xff, 0x33, 0xff };
|
ClutterColor text_color = { 0x33, 0xff, 0x33, 0xff };
|
||||||
ClutterColor cursor_color = { 0xff, 0x33, 0x33, 0xff };
|
ClutterColor cursor_color = { 0xff, 0x33, 0x33, 0xff };
|
||||||
ClutterColor background_color = { 0x00, 0x00, 0x00, 0xff };
|
ClutterColor background_color = { 0x00, 0x00, 0x00, 0xff };
|
||||||
|
|
||||||
clutter_init (&argc, &argv);
|
clutter_init (&argc, &argv);
|
||||||
|
|
||||||
stage = clutter_stage_get_default ();
|
stage = clutter_stage_get_default ();
|
||||||
@ -136,38 +59,24 @@ test_text_main (gint argc,
|
|||||||
clutter_text_set_selectable (CLUTTER_TEXT (text), TRUE);
|
clutter_text_set_selectable (CLUTTER_TEXT (text), TRUE);
|
||||||
clutter_text_set_cursor_color (CLUTTER_TEXT (text), &cursor_color);
|
clutter_text_set_cursor_color (CLUTTER_TEXT (text), &cursor_color);
|
||||||
|
|
||||||
#if 0
|
|
||||||
clutter_text_add_action (CLUTTER_TEXT (text), "select-all", select_all);
|
|
||||||
clutter_text_add_action (CLUTTER_TEXT (text), "copy", copy);
|
|
||||||
clutter_text_add_action (CLUTTER_TEXT (text), "paste", paste);
|
|
||||||
clutter_text_add_action (CLUTTER_TEXT (text), "cut", cut);
|
|
||||||
clutter_text_add_action (CLUTTER_TEXT (text), "pageup", pageup);
|
|
||||||
clutter_text_add_action (CLUTTER_TEXT (text), "pagedown", pagedown);
|
|
||||||
|
|
||||||
clutter_text_add_mapping (CLUTTER_TEXT (text),
|
|
||||||
CLUTTER_a, CLUTTER_CONTROL_MASK, "select-all");
|
|
||||||
clutter_text_add_mapping (CLUTTER_TEXT (text),
|
|
||||||
CLUTTER_c, CLUTTER_CONTROL_MASK, "copy");
|
|
||||||
clutter_text_add_mapping (CLUTTER_TEXT (text),
|
|
||||||
CLUTTER_v, CLUTTER_CONTROL_MASK, "paste");
|
|
||||||
clutter_text_add_mapping (CLUTTER_TEXT (text),
|
|
||||||
CLUTTER_x, CLUTTER_CONTROL_MASK, "cut");
|
|
||||||
clutter_text_add_mapping (CLUTTER_TEXT (text),
|
|
||||||
CLUTTER_Page_Up, 0, "pageup");
|
|
||||||
clutter_text_add_mapping (CLUTTER_TEXT (text),
|
|
||||||
CLUTTER_Page_Down, 0, "pagedown");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (argv[1])
|
if (argv[1])
|
||||||
{
|
{
|
||||||
|
GError *error = NULL;
|
||||||
gchar *utf8;
|
gchar *utf8;
|
||||||
g_file_get_contents (argv[1], &utf8, NULL, NULL);
|
|
||||||
|
g_file_get_contents (argv[1], &utf8, NULL, &error);
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
utf8 = g_strconcat ("Unable to open '", argv[1], "':\n",
|
||||||
|
error->message,
|
||||||
|
NULL);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
|
||||||
clutter_text_set_text (CLUTTER_TEXT (text), utf8);
|
clutter_text_set_text (CLUTTER_TEXT (text), utf8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
clutter_text_set_text (CLUTTER_TEXT (text), runes);
|
clutter_text_set_text (CLUTTER_TEXT (text), runes);
|
||||||
}
|
|
||||||
|
|
||||||
g_signal_connect (text, "cursor-event", G_CALLBACK (cursor_event), NULL);
|
g_signal_connect (text, "cursor-event", G_CALLBACK (cursor_event), NULL);
|
||||||
|
|
||||||
@ -175,5 +84,6 @@ test_text_main (gint argc,
|
|||||||
clutter_actor_show (stage);
|
clutter_actor_show (stage);
|
||||||
|
|
||||||
clutter_main ();
|
clutter_main ();
|
||||||
return 0;
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user