[mutter] wayland: Put the MetaWaylandBuffer implementation in a new file



commit c1613a16c099b52d63026e1405d45018c00897c5
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Oct 7 19:39:00 2014 -0700

    wayland: Put the MetaWaylandBuffer implementation in a new file

 src/Makefile.am                    |    2 +
 src/wayland/meta-wayland-buffer.c  |   82 ++++++++++++++++++++++++++++++++++++
 src/wayland/meta-wayland-buffer.h  |   47 ++++++++++++++++++++
 src/wayland/meta-wayland-pointer.c |    1 +
 src/wayland/meta-wayland-private.h |    4 --
 src/wayland/meta-wayland-surface.c |    1 +
 src/wayland/meta-wayland-surface.h |   10 ----
 src/wayland/meta-wayland-types.h   |    1 -
 src/wayland/meta-wayland.c         |   55 ------------------------
 9 files changed, 133 insertions(+), 70 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 3a92f5f..e8ff00a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -234,6 +234,8 @@ libmutter_la_SOURCES +=                             \
        wayland/meta-xwayland.c                 \
        wayland/meta-xwayland.h                 \
        wayland/meta-xwayland-private.h         \
+       wayland/meta-wayland-buffer.c           \
+       wayland/meta-wayland-buffer.h           \
        wayland/meta-wayland-data-device.c      \
        wayland/meta-wayland-data-device.h      \
        wayland/meta-wayland-keyboard.c         \
diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c
new file mode 100644
index 0000000..1c1e76e
--- /dev/null
+++ b/src/wayland/meta-wayland-buffer.c
@@ -0,0 +1,82 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2014 Endless Mobile
+ *
+ * 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.
+ *
+ * Written by:
+ *     Jasper St. Pierre <jstpierre mecheye net>
+ */
+
+#include "config.h"
+
+#include "meta-wayland-buffer.h"
+
+static void
+meta_wayland_buffer_destroy_handler (struct wl_listener *listener,
+                                     void *data)
+{
+  MetaWaylandBuffer *buffer =
+    wl_container_of (listener, buffer, destroy_listener);
+
+  wl_signal_emit (&buffer->destroy_signal, buffer);
+  g_slice_free (MetaWaylandBuffer, buffer);
+}
+
+void
+meta_wayland_buffer_ref (MetaWaylandBuffer *buffer)
+{
+  buffer->ref_count++;
+}
+
+void
+meta_wayland_buffer_unref (MetaWaylandBuffer *buffer)
+{
+  buffer->ref_count--;
+  if (buffer->ref_count == 0)
+    {
+      g_clear_pointer (&buffer->texture, cogl_object_unref);
+      wl_resource_queue_event (buffer->resource, WL_BUFFER_RELEASE);
+    }
+}
+
+MetaWaylandBuffer *
+meta_wayland_buffer_from_resource (struct wl_resource *resource)
+{
+  MetaWaylandBuffer *buffer;
+  struct wl_listener *listener;
+
+  listener =
+    wl_resource_get_destroy_listener (resource,
+                                      meta_wayland_buffer_destroy_handler);
+
+  if (listener)
+    {
+      buffer = wl_container_of (listener, buffer, destroy_listener);
+    }
+  else
+    {
+      buffer = g_slice_new0 (MetaWaylandBuffer);
+
+      buffer->resource = resource;
+      wl_signal_init (&buffer->destroy_signal);
+      buffer->destroy_listener.notify = meta_wayland_buffer_destroy_handler;
+      wl_resource_add_destroy_listener (resource, &buffer->destroy_listener);
+    }
+
+  return buffer;
+}
diff --git a/src/wayland/meta-wayland-buffer.h b/src/wayland/meta-wayland-buffer.h
new file mode 100644
index 0000000..1b08333
--- /dev/null
+++ b/src/wayland/meta-wayland-buffer.h
@@ -0,0 +1,47 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2014 Endless Mobile
+ *
+ * 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.
+ *
+ * Written by:
+ *     Jasper St. Pierre <jstpierre mecheye net>
+ */
+
+#ifndef META_WAYLAND_BUFFER_H
+#define META_WAYLAND_BUFFER_H
+
+#include <cogl/cogl.h>
+#include <wayland-server.h>
+
+#include "meta-wayland-types.h"
+
+struct _MetaWaylandBuffer
+{
+  struct wl_resource *resource;
+  struct wl_signal destroy_signal;
+  struct wl_listener destroy_listener;
+
+  CoglTexture *texture;
+  uint32_t ref_count;
+};
+
+MetaWaylandBuffer *     meta_wayland_buffer_from_resource       (struct wl_resource    *resource);
+void                    meta_wayland_buffer_ref                 (MetaWaylandBuffer     *buffer);
+void                    meta_wayland_buffer_unref               (MetaWaylandBuffer     *buffer);
+
+#endif /* META_WAYLAND_BUFFER_H */
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index 5ae685f..24c2818 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -48,6 +48,7 @@
 
 #include "meta-wayland-pointer.h"
 #include "meta-wayland-private.h"
+#include "meta-wayland-buffer.h"
 #include "meta-cursor.h"
 #include "meta-cursor-tracker-private.h"
 #include "meta-surface-actor-wayland.h"
diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h
index 0edc725..5d1a62b 100644
--- a/src/wayland/meta-wayland-private.h
+++ b/src/wayland/meta-wayland-private.h
@@ -80,8 +80,4 @@ struct _MetaWaylandCompositor
   MetaWaylandSeat *seat;
 };
 
-MetaWaylandBuffer *     meta_wayland_buffer_from_resource       (struct wl_resource    *resource);
-void                    meta_wayland_buffer_ref                 (MetaWaylandBuffer     *buffer);
-void                    meta_wayland_buffer_unref               (MetaWaylandBuffer     *buffer);
-
 #endif /* META_WAYLAND_PRIVATE_H */
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 2f92b14..e178889 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -43,6 +43,7 @@
 
 #include "meta-wayland-private.h"
 #include "meta-xwayland-private.h"
+#include "meta-wayland-buffer.h"
 #include "meta-wayland-seat.h"
 #include "meta-wayland-keyboard.h"
 #include "meta-wayland-pointer.h"
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index 105a449..6288d67 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -36,16 +36,6 @@ struct _MetaWaylandSerial {
   uint32_t value;
 };
 
-struct _MetaWaylandBuffer
-{
-  struct wl_resource *resource;
-  struct wl_signal destroy_signal;
-  struct wl_listener destroy_listener;
-
-  CoglTexture *texture;
-  uint32_t ref_count;
-};
-
 typedef struct
 {
   /* wl_surface.attach */
diff --git a/src/wayland/meta-wayland-types.h b/src/wayland/meta-wayland-types.h
index 7217431..66b33aa 100644
--- a/src/wayland/meta-wayland-types.h
+++ b/src/wayland/meta-wayland-types.h
@@ -32,7 +32,6 @@ typedef struct _MetaWaylandDataSource MetaWaylandDataSource;
 typedef struct _MetaWaylandDataDevice MetaWaylandDataDevice;
 
 typedef struct _MetaWaylandBuffer MetaWaylandBuffer;
-typedef struct _MetaWaylandBufferReference MetaWaylandBufferReference;
 
 typedef struct _MetaWaylandSurface MetaWaylandSurface;
 
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index ce4a022..6336cec 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -126,61 +126,6 @@ wayland_event_source_new (struct wl_display *display)
   return &source->source;
 }
 
-static void
-meta_wayland_buffer_destroy_handler (struct wl_listener *listener,
-                                     void *data)
-{
-  MetaWaylandBuffer *buffer =
-    wl_container_of (listener, buffer, destroy_listener);
-
-  wl_signal_emit (&buffer->destroy_signal, buffer);
-  g_slice_free (MetaWaylandBuffer, buffer);
-}
-
-void
-meta_wayland_buffer_ref (MetaWaylandBuffer *buffer)
-{
-  buffer->ref_count++;
-}
-
-void
-meta_wayland_buffer_unref (MetaWaylandBuffer *buffer)
-{
-  buffer->ref_count--;
-  if (buffer->ref_count == 0)
-    {
-      g_clear_pointer (&buffer->texture, cogl_object_unref);
-      wl_resource_queue_event (buffer->resource, WL_BUFFER_RELEASE);
-    }
-}
-
-MetaWaylandBuffer *
-meta_wayland_buffer_from_resource (struct wl_resource *resource)
-{
-  MetaWaylandBuffer *buffer;
-  struct wl_listener *listener;
-
-  listener =
-    wl_resource_get_destroy_listener (resource,
-                                      meta_wayland_buffer_destroy_handler);
-
-  if (listener)
-    {
-      buffer = wl_container_of (listener, buffer, destroy_listener);
-    }
-  else
-    {
-      buffer = g_slice_new0 (MetaWaylandBuffer);
-
-      buffer->resource = resource;
-      wl_signal_init (&buffer->destroy_signal);
-      buffer->destroy_listener.notify = meta_wayland_buffer_destroy_handler;
-      wl_resource_add_destroy_listener (resource, &buffer->destroy_listener);
-    }
-
-  return buffer;
-}
-
 void
 meta_wayland_compositor_set_input_focus (MetaWaylandCompositor *compositor,
                                          MetaWindow            *window)


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