[empathy] call: fix the video preview



commit 9cbcf1de02b6dab83d24f68f9881faf7c5d64eae
Author: Fabrice Bellet <fabrice bellet info>
Date:   Fri Nov 18 14:57:29 2016 +0100

    call: fix the video preview
    
    The port to clutter-gst 3.0 broke the video preview window.
    The rounded texture effect is now provided by a ClutterEffect
    sub-class, and the horizontal flip of the preview is done
    directly with a cogl transformation. This last modification
    using cogl_push_matrix()/cogl_pop_matrix(), the deprecation
    warning of cogl has been lowered from 1.14 to 1.8.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751185

 configure.ac                                       |    4 +-
 src/Makefile.am                                    |    4 +-
 src/empathy-call-window.c                          |   17 ++++--
 ...-rounded-texture.c => empathy-rounded-effect.c} |   44 ++++++++------
 src/empathy-rounded-effect.h                       |   62 ++++++++++++++++++++
 src/empathy-rounded-texture.h                      |   62 --------------------
 6 files changed, 102 insertions(+), 91 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ce1ae4e..2867329 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,8 +58,8 @@ AC_DEFINE(TP_SEAL_ENABLE, 1, [Prevent to use sealed variables])
 AC_DEFINE(TP_DISABLE_SINGLE_INCLUDE, 1, [Disable single include header])
 
 COGL_REQUIRED=1.14
-AC_DEFINE(COGL_VERSION_MIN_REQUIRED, COGL_VERSION_1_14, [Ignore post 1.14 deprecations])
-AC_DEFINE(COGL_VERSION_MAX_ALLOWED, COGL_VERSION_1_14, [Ignore post 1.14 deprecations])
+AC_DEFINE(COGL_VERSION_MIN_REQUIRED, COGL_VERSION_1_8, [Ignore post 1.8 deprecations])
+AC_DEFINE(COGL_VERSION_MAX_ALLOWED, COGL_VERSION_1_14, [Prevent post 1.14 APIs])
 
 GSTREAMER_REQUIRED=0.10.32
 TP_FS_REQUIRED=0.6.0
diff --git a/src/Makefile.am b/src/Makefile.am
index 8806ae4..7c854e9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -129,8 +129,8 @@ empathy_call_SOURCES = \
        empathy-rounded-actor.h \
        empathy-rounded-rectangle.c \
        empathy-rounded-rectangle.h \
-       empathy-rounded-texture.c \
-       empathy-rounded-texture.h \
+       empathy-rounded-effect.c \
+       empathy-rounded-effect.h \
        empathy-mic-monitor.c \
        empathy-mic-monitor.h
 
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index 5ab8a9a..ac867aa 100644
--- a/src/empathy-call-window.c
+++ b/src/empathy-call-window.c
@@ -47,7 +47,7 @@
 #include "empathy-request-util.h"
 #include "empathy-rounded-actor.h"
 #include "empathy-rounded-rectangle.h"
-#include "empathy-rounded-texture.h"
+#include "empathy-rounded-effect.h"
 #include "empathy-sound-manager.h"
 #include "empathy-ui-utils.h"
 #include "empathy-utils.h"
@@ -146,6 +146,7 @@ struct _EmpathyCallWindowPriv
   ClutterActor *preview_rectangle3;
   ClutterActor *preview_rectangle4;
   ClutterActor *preview_spinner_actor;
+  ClutterContent *preview_content;
   GtkWidget *preview_spinner_widget;
   GtkWidget *video_container;
   GtkWidget *remote_user_avatar_widget;
@@ -1072,9 +1073,10 @@ create_video_preview (EmpathyCallWindow *self)
 
   pos = g_settings_get_enum (priv->settings, "camera-position");
 
-  preview = empathy_rounded_texture_new ();
+  preview = clutter_actor_new ();
   clutter_actor_set_size (preview,
       SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGHT);
+  clutter_actor_add_effect (preview, empathy_rounded_effect_new ());
 
   priv->video_preview_sink = GST_ELEMENT (clutter_gst_video_sink_new ());
   g_object_add_weak_pointer (G_OBJECT (priv->video_preview_sink), (gpointer) &priv->video_preview_sink);
@@ -1086,10 +1088,9 @@ create_video_preview (EmpathyCallWindow *self)
   clutter_actor_set_size (priv->video_preview,
       SELF_VIDEO_SECTION_WIDTH + 2 * SELF_VIDEO_SECTION_MARGIN,
       SELF_VIDEO_SECTION_HEIGHT + 2 * SELF_VIDEO_SECTION_MARGIN);
-  clutter_actor_set_content (priv->video_preview,
-      g_object_new (CLUTTER_GST_TYPE_ASPECTRATIO,
-                    "sink", priv->video_preview,
-                    NULL));
+  priv->preview_content = clutter_gst_content_new_with_sink (
+      CLUTTER_GST_VIDEO_SINK (priv->video_preview_sink));
+  clutter_actor_set_content (preview, priv->preview_content);
 
   /* Spinner for when changing the camera device */
   priv->preview_spinner_widget = gtk_spinner_new ();
@@ -2576,6 +2577,10 @@ empathy_call_window_reset_pipeline (EmpathyCallWindow *self)
         clutter_actor_destroy (priv->video_preview);
       priv->video_preview = NULL;
 
+      if (priv->preview_content != NULL)
+        g_object_unref (priv->preview_content);
+      priv->preview_content = NULL;
+
       /* If we destroy the preview while it's being dragged, we won't
        * get the ::drag-end signal, so manually destroy the clone */
       if (priv->drag_preview != NULL)
diff --git a/src/empathy-rounded-texture.c b/src/empathy-rounded-effect.c
similarity index 55%
rename from src/empathy-rounded-texture.c
rename to src/empathy-rounded-effect.c
index 46c0b21..ce00913 100644
--- a/src/empathy-rounded-texture.c
+++ b/src/empathy-rounded-effect.c
@@ -1,5 +1,5 @@
 /*
- * empathy-rounded-texture.c - Source for EmpathyRoundedTexture
+ * empathy-rounded-effect.c - Source for EmpathyRoundedEffect
  * Copyright (C) 2011 Collabora Ltd.
  * @author Emilio Pozuelo Monfort <emilio pozuelo collabora co uk>
  *
@@ -19,19 +19,23 @@
  */
 
 #include "config.h"
-#include "empathy-rounded-texture.h"
+#include "empathy-rounded-effect.h"
 
-G_DEFINE_TYPE (EmpathyRoundedTexture,
-    empathy_rounded_texture,
-    CLUTTER_TYPE_TEXTURE)
+G_DEFINE_TYPE (EmpathyRoundedEffect,
+    empathy_rounded_effect,
+    CLUTTER_TYPE_EFFECT)
 
 static void
-empathy_rounded_texture_paint (ClutterActor *texture)
+empathy_rounded_effect_paint (ClutterEffect *effect,
+    ClutterEffectPaintFlags flags)
 {
+  EmpathyRoundedEffect *self = EMPATHY_ROUNDED_EFFECT (effect);
+  ClutterActor *actor;
   ClutterActorBox allocation = { 0, };
   gfloat width, height;
 
-  clutter_actor_get_allocation_box (texture, &allocation);
+  actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (self));
+  clutter_actor_get_allocation_box (actor, &allocation);
   clutter_actor_box_get_size (&allocation, &width, &height);
 
   cogl_path_new ();
@@ -41,31 +45,33 @@ empathy_rounded_texture_paint (ClutterActor *texture)
 
   cogl_clip_push_from_path ();
 
-  CLUTTER_ACTOR_CLASS (empathy_rounded_texture_parent_class)->paint (texture);
-
   /* Flip */
-  cogl_rectangle_with_texture_coords (0, 0, width, height,
-      1., 0., 0., 1.);
+  cogl_push_matrix ();
+  cogl_translate (width, 0, 0);
+  cogl_scale (-1, 1, 1);
+
+  clutter_actor_continue_paint (actor);
 
+  cogl_pop_matrix ();
   cogl_clip_pop ();
 }
 
 static void
-empathy_rounded_texture_init (EmpathyRoundedTexture *self)
+empathy_rounded_effect_init (EmpathyRoundedEffect *self)
 {
 }
 
 static void
-empathy_rounded_texture_class_init (EmpathyRoundedTextureClass *klass)
+empathy_rounded_effect_class_init (EmpathyRoundedEffectClass *klass)
 {
-  ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
+  ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass);
 
-  actor_class->paint = empathy_rounded_texture_paint;
+  effect_class->paint = empathy_rounded_effect_paint;
 }
 
-ClutterActor *
-empathy_rounded_texture_new (void)
+ClutterEffect *
+empathy_rounded_effect_new (void)
 {
-  return CLUTTER_ACTOR (
-    g_object_new (EMPATHY_TYPE_ROUNDED_TEXTURE, NULL));
+  return CLUTTER_EFFECT (
+    g_object_new (EMPATHY_TYPE_ROUNDED_EFFECT, NULL));
 }
diff --git a/src/empathy-rounded-effect.h b/src/empathy-rounded-effect.h
new file mode 100644
index 0000000..e9c37cb
--- /dev/null
+++ b/src/empathy-rounded-effect.h
@@ -0,0 +1,62 @@
+/*
+ * empathy-rounded-effect.h - Header for EmpathyRoundedEffect
+ * Copyright (C) 2011 Collabora Ltd.
+ * @author Emilio Pozuelo Monfort <emilio pozuelo collabora co uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __EMPATHY_ROUNDED_EFFECT_H__
+#define __EMPATHY_ROUNDED_EFFECT_H__
+
+#include <clutter/clutter.h>
+
+G_BEGIN_DECLS
+
+typedef struct _EmpathyRoundedEffect EmpathyRoundedEffect;
+typedef struct _EmpathyRoundedEffectClass EmpathyRoundedEffectClass;
+
+struct _EmpathyRoundedEffectClass {
+    ClutterEffectClass parent_class;
+};
+
+struct _EmpathyRoundedEffect {
+    ClutterEffect parent;
+};
+
+GType empathy_rounded_effect_get_type (void);
+
+/* TYPE MACROS */
+#define EMPATHY_TYPE_ROUNDED_EFFECT \
+  (empathy_rounded_effect_get_type ())
+#define EMPATHY_ROUNDED_EFFECT(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_ROUNDED_EFFECT, \
+    EmpathyRoundedEffect))
+#define EMPATHY_ROUNDED_EFFECT_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_ROUNDED_EFFECT, \
+    EmpathyRoundedEffectClass))
+#define EMPATHY_IS_ROUNDED_EFFECT(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_ROUNDED_EFFECT))
+#define EMPATHY_IS_ROUNDED_EFFECT_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_ROUNDED_EFFECT))
+#define EMPATHY_ROUNDED_EFFECT_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ROUNDED_EFFECT, \
+    EmpathyRoundedEffectClass))
+
+ClutterEffect *empathy_rounded_effect_new (void);
+
+G_END_DECLS
+
+#endif /* #ifndef __EMPATHY_ROUNDED_EFFECT_H__*/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]