[mutter/wip/texture-purge-on-nvidia: 53/66] screen-cast: Add screen-cast-window interface



commit eb64b9b043e7a68f79f2f0202be47945c05addb9
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Wed Dec 5 08:48:41 2018 +0100

    screen-cast: Add screen-cast-window interface
    
    Typically, to stream the content of a window, we need a way to copy the
    content of its window-actor into a buffer, transform relative input
    coordinates to relative position within the window-actor and a mean to
    get the window bounds within the buffer.
    
    For this purpose, add a new GType interface `MetaScreenCastWindow` with
    the methods needed for screen-cast window mode:
    
     * meta_screen_cast_window_get_buffer_bounds()
     * meta_screen_cast_window_get_frame_bounds()
     * meta_screen_cast_window_transform_relative_position()
     * meta_screen_cast_window_capture_into()
    
    This interface is meant to be implemented by `MetaWindowActor` which has
    access to all the necessary bits to implement them.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
    (cherry picked from commit 20c9ca25c01a9160d4a2ddfad29b48eb86a9142a)

 src/Makefile.am                        |  2 +
 src/backends/meta-screen-cast-window.c | 71 ++++++++++++++++++++++++++++++++
 src/backends/meta-screen-cast-window.h | 74 ++++++++++++++++++++++++++++++++++
 3 files changed, 147 insertions(+)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index bd879f203..93586a281 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -159,6 +159,8 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES =      \
        backends/meta-output.h                  \
        backends/meta-pointer-constraint.c      \
        backends/meta-pointer-constraint.h      \
+       backends/meta-screen-cast-window.c      \
+       backends/meta-screen-cast-window.h      \
        backends/meta-settings.c                \
        backends/meta-settings-private.h        \
        backends/meta-stage-private.h           \
diff --git a/src/backends/meta-screen-cast-window.c b/src/backends/meta-screen-cast-window.c
new file mode 100644
index 000000000..21629a0cd
--- /dev/null
+++ b/src/backends/meta-screen-cast-window.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2018 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include "backends/meta-screen-cast-window.h"
+
+G_DEFINE_INTERFACE (MetaScreenCastWindow, meta_screen_cast_window, G_TYPE_OBJECT)
+
+static void
+meta_screen_cast_window_default_init (MetaScreenCastWindowInterface *iface)
+{
+}
+
+void
+meta_screen_cast_window_get_buffer_bounds (MetaScreenCastWindow *screen_cast_window,
+                                           MetaRectangle        *bounds)
+{
+  META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window)->get_buffer_bounds (screen_cast_window,
+                                                                             bounds);
+}
+
+void
+meta_screen_cast_window_get_frame_bounds (MetaScreenCastWindow *screen_cast_window,
+                                          MetaRectangle        *bounds)
+{
+  META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window)->get_frame_bounds (screen_cast_window,
+                                                                            bounds);
+}
+
+void
+meta_screen_cast_window_transform_relative_position (MetaScreenCastWindow *screen_cast_window,
+                                                     double                x,
+                                                     double                y,
+                                                     double               *x_out,
+                                                     double               *y_out)
+{
+  META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window)->transform_relative_position (screen_cast_window,
+                                                                                       x,
+                                                                                       y,
+                                                                                       x_out,
+                                                                                       y_out);
+}
+
+
+void
+meta_screen_cast_window_capture_into (MetaScreenCastWindow *screen_cast_window,
+                                      MetaRectangle        *bounds,
+                                      uint8_t              *data)
+{
+  META_SCREEN_CAST_WINDOW_GET_IFACE (screen_cast_window)->capture_into (screen_cast_window,
+                                                                        bounds,
+                                                                        data);
+}
diff --git a/src/backends/meta-screen-cast-window.h b/src/backends/meta-screen-cast-window.h
new file mode 100644
index 000000000..e023d3e17
--- /dev/null
+++ b/src/backends/meta-screen-cast-window.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2018 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ */
+
+#ifndef META_SCREEN_CAST_WINDOW_H
+#define META_SCREEN_CAST_WINDOW_H
+
+#include <stdint.h>
+#include <glib-object.h>
+
+#include "meta/boxes.h"
+
+G_BEGIN_DECLS
+
+#define META_TYPE_SCREEN_CAST_WINDOW (meta_screen_cast_window_get_type ())
+G_DECLARE_INTERFACE (MetaScreenCastWindow, meta_screen_cast_window,
+                     META, SCREEN_CAST_WINDOW, GObject)
+
+struct _MetaScreenCastWindowInterface
+{
+  GTypeInterface parent_iface;
+
+  void (*get_buffer_bounds) (MetaScreenCastWindow *screen_cast_window,
+                             MetaRectangle        *bounds);
+
+  void (*get_frame_bounds) (MetaScreenCastWindow *screen_cast_window,
+                            MetaRectangle        *bounds);
+
+  void (*transform_relative_position) (MetaScreenCastWindow *screen_cast_window,
+                                       double                x,
+                                       double                y,
+                                       double               *x_out,
+                                       double               *y_out);
+
+  void (*capture_into) (MetaScreenCastWindow *screen_cast_window,
+                        MetaRectangle        *bounds,
+                        uint8_t              *data);
+};
+
+void meta_screen_cast_window_get_buffer_bounds (MetaScreenCastWindow *screen_cast_window,
+                                                MetaRectangle        *bounds);
+
+void meta_screen_cast_window_get_frame_bounds (MetaScreenCastWindow *screen_cast_window,
+                                               MetaRectangle        *bounds);
+
+void meta_screen_cast_window_transform_relative_position (MetaScreenCastWindow *screen_cast_window,
+                                                          double                x,
+                                                          double                y,
+                                                          double               *x_out,
+                                                          double               *y_out);
+
+void meta_screen_cast_window_capture_into (MetaScreenCastWindow *screen_cast_window,
+                                           MetaRectangle        *bounds,
+                                           uint8_t              *data);
+
+G_END_DECLS
+
+#endif /* META_SCREEN_CAST_WINDOW_H */


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