summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Landwerlin <llandwerlin@gmail.com>2013-03-27 12:15:03 +0000
committerLionel Landwerlin <llandwerlin@gmail.com>2013-03-27 12:15:03 +0000
commit7b9affcbe92351127cec21151f82f20bf0f49578 (patch)
tree212e918b13772680c80a306b480bdb43ebe1e94a
parent3ebce92080647866cc60fe73cf5c5d7ce033538a (diff)
downloadclutter-gst-7b9affcbe92351127cec21151f82f20bf0f49578.tar.gz
Introduce ClutterGstBox to replace usage of (soon to be deprecated) ClutterActorBox
https://bugzilla.gnome.org/show_bug.cgi?id=696630
-rw-r--r--clutter-gst/clutter-gst-crop.c32
-rw-r--r--clutter-gst/clutter-gst-types.c21
-rw-r--r--clutter-gst/clutter-gst-types.h23
-rw-r--r--examples/pieces.js10
-rw-r--r--examples/video-flip.js10
-rw-r--r--examples/video-flip2.js10
-rw-r--r--examples/video-wall.js10
7 files changed, 81 insertions, 35 deletions
diff --git a/clutter-gst/clutter-gst-crop.c b/clutter-gst/clutter-gst-crop.c
index 857e611..c608cdb 100644
--- a/clutter-gst/clutter-gst-crop.c
+++ b/clutter-gst/clutter-gst-crop.c
@@ -36,8 +36,8 @@ G_DEFINE_TYPE (ClutterGstCrop, clutter_gst_crop, CLUTTER_GST_TYPE_ACTOR)
struct _ClutterGstCropPrivate
{
- ClutterActorBox input_region;
- ClutterActorBox output_region;
+ ClutterGstBox input_region;
+ ClutterGstBox output_region;
gboolean paint_borders;
gboolean cull_backface;
@@ -121,7 +121,7 @@ clutter_gst_crop_paint_frame (ClutterGstActor *self,
}
static gboolean
-_validate_box (ClutterActorBox *box)
+_validate_box (ClutterGstBox *box)
{
if (box->x1 >= 0 &&
box->x1 <= 1 &&
@@ -143,7 +143,7 @@ clutter_gst_crop_get_property (GObject *object,
GParamSpec *pspec)
{
ClutterGstCropPrivate *priv = CLUTTER_GST_CROP (object)->priv;
- ClutterActorBox *box;
+ ClutterGstBox *box;
switch (property_id)
{
@@ -154,11 +154,11 @@ clutter_gst_crop_get_property (GObject *object,
g_value_set_boolean (value, priv->cull_backface);
break;
case PROP_INPUT_REGION:
- box = (ClutterActorBox *) g_value_get_boxed (value);
+ box = (ClutterGstBox *) g_value_get_boxed (value);
*box = priv->input_region;
break;
case PROP_OUTPUT_REGION:
- box = (ClutterActorBox *) g_value_get_boxed (value);
+ box = (ClutterGstBox *) g_value_get_boxed (value);
*box = priv->output_region;
break;
default:
@@ -173,7 +173,7 @@ clutter_gst_crop_set_property (GObject *object,
GParamSpec *pspec)
{
ClutterGstCropPrivate *priv = CLUTTER_GST_CROP (object)->priv;
- ClutterActorBox *box;
+ ClutterGstBox *box;
switch (property_id)
{
@@ -184,17 +184,19 @@ clutter_gst_crop_set_property (GObject *object,
priv->cull_backface = g_value_get_boolean (value);
break;
case PROP_INPUT_REGION:
- box = (ClutterActorBox *) g_value_get_boxed (value);
- if (_validate_box (box))
+ box = (ClutterGstBox *) g_value_get_boxed (value);
+ if (_validate_box (box)) {
priv->input_region = *box;
- else
+ clutter_actor_queue_redraw (CLUTTER_ACTOR (object));
+ } else
g_warning ("Input region must be given in [0, 1] values.");
break;
case PROP_OUTPUT_REGION:
- box = (ClutterActorBox *) g_value_get_boxed (value);
- if (_validate_box (box))
+ box = (ClutterGstBox *) g_value_get_boxed (value);
+ if (_validate_box (box)) {
priv->output_region = *box;
- else
+ clutter_actor_queue_redraw (CLUTTER_ACTOR (object));
+ } else
g_warning ("Output region must be given in [0, 1] values.");
break;
default:
@@ -268,7 +270,7 @@ clutter_gst_crop_class_init (ClutterGstCropClass *klass)
pspec = g_param_spec_boxed ("input-region",
"Input Region",
"Input Region",
- CLUTTER_TYPE_ACTOR_BOX,
+ CLUTTER_GST_TYPE_BOX,
CLUTTER_GST_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_INPUT_REGION, pspec);
@@ -282,7 +284,7 @@ clutter_gst_crop_class_init (ClutterGstCropClass *klass)
pspec = g_param_spec_boxed ("output-region",
"Output Region",
"Output Region",
- CLUTTER_TYPE_ACTOR_BOX,
+ CLUTTER_GST_TYPE_BOX,
CLUTTER_GST_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_OUTPUT_REGION, pspec);
}
diff --git a/clutter-gst/clutter-gst-types.c b/clutter-gst/clutter-gst-types.c
index c4b7204..00b8a1b 100644
--- a/clutter-gst/clutter-gst-types.c
+++ b/clutter-gst/clutter-gst-types.c
@@ -77,3 +77,24 @@ G_DEFINE_BOXED_TYPE (ClutterGstFrame,
clutter_gst_frame,
clutter_gst_frame_copy,
clutter_gst_frame_free);
+
+static ClutterGstBox *
+clutter_gst_box_copy (const ClutterGstBox *box)
+{
+ if (G_LIKELY (box != NULL))
+ return g_slice_dup (ClutterGstBox, box);
+
+ return NULL;
+}
+
+static void
+clutter_gst_box_free (ClutterGstBox *box)
+{
+ if (G_LIKELY (box != NULL))
+ g_slice_free (ClutterGstBox, box);
+}
+
+G_DEFINE_BOXED_TYPE (ClutterGstBox,
+ clutter_gst_box,
+ clutter_gst_box_copy,
+ clutter_gst_box_free);
diff --git a/clutter-gst/clutter-gst-types.h b/clutter-gst/clutter-gst-types.h
index cccbb45..8a38106 100644
--- a/clutter-gst/clutter-gst-types.h
+++ b/clutter-gst/clutter-gst-types.h
@@ -35,7 +35,9 @@
#define __CLUTTER_GST_TYPES_H__
#define CLUTTER_GST_TYPE_FRAME (clutter_gst_frame_get_type ())
+#define CLUTTER_GST_TYPE_BOX (clutter_gst_box_get_type ())
+typedef struct _ClutterGstBox ClutterGstBox;
typedef struct _ClutterGstFrame ClutterGstFrame;
typedef struct _ClutterGstVideoResolution ClutterGstVideoResolution;
@@ -99,6 +101,27 @@ struct _ClutterGstFrame
};
+/**
+ * ClutterGstBox:
+ * @x1: X coordinate of the top left corner
+ * @y1: Y coordinate of the top left corner
+ * @x2: X coordinate of the bottom right corner
+ * @y2: Y coordinate of the bottom right corner
+ *
+ * Bounding box of an area in a video texture or actor's allocation.
+ * Coordinates are usually expressed in the [0, 1] interval.
+ */
+struct _ClutterGstBox
+{
+ gfloat x1;
+ gfloat y1;
+
+ gfloat x2;
+ gfloat y2;
+};
+
+
GType clutter_gst_frame_get_type (void) G_GNUC_CONST;
+GType clutter_gst_box_get_type (void) G_GNUC_CONST;
#endif /* __CLUTTER_GST_TYPES_H__ */
diff --git a/examples/pieces.js b/examples/pieces.js
index 9415250..f7a0b0b 100644
--- a/examples/pieces.js
+++ b/examples/pieces.js
@@ -129,11 +129,11 @@ for (let i = 0; i < ROWS; i++) {
if ((i * ROWS + j) >= (ROWS * COLUMNS - 1))
break;
- let input = new Clutter.ActorBox({ x1: j / COLUMNS,
- x2: (j + 1) / COLUMNS,
- y1: i / ROWS,
- y2: (i + 1) / ROWS,
- })
+ let input = new ClutterGst.Box({ x1: j / COLUMNS,
+ x2: (j + 1) / COLUMNS,
+ y1: i / ROWS,
+ y2: (i + 1) / ROWS,
+ })
let actor = new ClutterGst.Crop({ width: BIT_WIDTH,
height: BIT_HEIGHT,
player: player,
diff --git a/examples/video-flip.js b/examples/video-flip.js
index a3d3387..ba720ea 100644
--- a/examples/video-flip.js
+++ b/examples/video-flip.js
@@ -122,11 +122,11 @@ let positionActors = function() {
for (let i = 0; i < ROWS; i++) {
for (let j = 0; j < COLUMNS; j++) {
- let input = new Clutter.ActorBox({ x1: j / COLUMNS,
- x2: (j + 1) / COLUMNS,
- y1: i / ROWS,
- y2: (i + 1) / ROWS,
- })
+ let input = new ClutterGst.Box({ x1: j / COLUMNS,
+ x2: (j + 1) / COLUMNS,
+ y1: i / ROWS,
+ y2: (i + 1) / ROWS,
+ })
let actor =
new ClutterGst.Crop({ reactive: true,
cull_backface: true,
diff --git a/examples/video-flip2.js b/examples/video-flip2.js
index e0226a3..79c17a7 100644
--- a/examples/video-flip2.js
+++ b/examples/video-flip2.js
@@ -238,11 +238,11 @@ let positionActors = function() {
for (let i = 0; i < ROWS; i++) {
for (let j = 0; j < COLUMNS; j++) {
- let input = new Clutter.ActorBox({ x1: j / COLUMNS,
- x2: (j + 1) / COLUMNS,
- y1: i / ROWS,
- y2: (i + 1) / ROWS,
- })
+ let input = new ClutterGst.Box({ x1: j / COLUMNS,
+ x2: (j + 1) / COLUMNS,
+ y1: i / ROWS,
+ y2: (i + 1) / ROWS,
+ })
let actor =
new ClutterGst.Crop({ cull_backface: true,
pivot_point: new Clutter.Point({ x: 0.5,
diff --git a/examples/video-wall.js b/examples/video-wall.js
index 66e5e82..9318c1d 100644
--- a/examples/video-wall.js
+++ b/examples/video-wall.js
@@ -134,11 +134,11 @@ let pushActorsToFront = function(duration) {
for (let i = 0; i < ROWS; i++) {
for (let j = 0; j < COLUMNS; j++) {
- let input = new Clutter.ActorBox({ x1: j / COLUMNS,
- x2: (j + 1) / COLUMNS,
- y1: i / ROWS,
- y2: (i + 1) / ROWS,
- })
+ let input = new ClutterGst.Box({ x1: j / COLUMNS,
+ x2: (j + 1) / COLUMNS,
+ y1: i / ROWS,
+ y2: (i + 1) / ROWS,
+ })
let subActor = new ClutterGst.Crop({ width: 200,
height: 200,
player: player,