[gtk+/wip/otte/vulkan: 51/62] vulkan: Turn GskVulkanImage into a GObject
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/vulkan: 51/62] vulkan: Turn GskVulkanImage into a GObject
- Date: Fri, 9 Dec 2016 17:39:14 +0000 (UTC)
commit c160ef16c10c2f144a8d0ab5c70ec55b021755fc
Author: Benjamin Otte <otte redhat com>
Date: Thu Dec 8 20:19:56 2016 +0100
vulkan: Turn GskVulkanImage into a GObject
This way, we can do real refcounting on them.
gsk/gskvulkanimage.c | 25 +++++++++++++++++++++----
gsk/gskvulkanimageprivate.h | 5 +++--
gsk/gskvulkanrender.c | 2 +-
3 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/gsk/gskvulkanimage.c b/gsk/gskvulkanimage.c
index 279d7bb..f57c5d5 100644
--- a/gsk/gskvulkanimage.c
+++ b/gsk/gskvulkanimage.c
@@ -8,6 +8,8 @@
struct _GskVulkanImage
{
+ GObject parent_instance;
+
GdkVulkanContext *vulkan;
VkImage vk_image;
@@ -16,6 +18,8 @@ struct _GskVulkanImage
GskVulkanMemory *memory;
};
+G_DEFINE_TYPE (GskVulkanImage, gsk_vulkan_image, G_TYPE_OBJECT)
+
static GskVulkanImage *
gsk_vulkan_image_new (GdkVulkanContext *context,
gsize width,
@@ -27,7 +31,7 @@ gsk_vulkan_image_new (GdkVulkanContext *context,
VkMemoryRequirements requirements;
GskVulkanImage *self;
- self = g_slice_new0 (GskVulkanImage);
+ self = g_object_new (GSK_TYPE_VULKAN_IMAGE, NULL);
self->vulkan = g_object_ref (context);
@@ -251,7 +255,7 @@ gsk_vulkan_image_new_from_data_via_staging_image (GdkVulkanContext *context,
});
/* XXX: Is this okay or do we need to keep the staging image around until the commands execute */
- gsk_vulkan_image_free (staging);
+ g_object_unref (staging);
gsk_vulkan_image_ensure_view (self);
@@ -323,8 +327,10 @@ gsk_vulkan_image_new_from_data (GdkVulkanContext *context,
}
void
-gsk_vulkan_image_free (GskVulkanImage *self)
+gsk_vulkan_image_finalize (GObject *object)
{
+ GskVulkanImage *self = GSK_VULKAN_IMAGE (object);
+
if (self->vk_image_view != VK_NULL_HANDLE)
{
vkDestroyImageView (gdk_vulkan_context_get_device (self->vulkan),
@@ -340,7 +346,18 @@ gsk_vulkan_image_free (GskVulkanImage *self)
g_object_unref (self->vulkan);
- g_slice_free (GskVulkanImage, self);
+ G_OBJECT_CLASS (gsk_vulkan_image_parent_class)->finalize (object);
+}
+
+static void
+gsk_vulkan_image_class_init (GskVulkanImageClass *klass)
+{
+ G_OBJECT_CLASS (klass)->finalize = gsk_vulkan_image_finalize;
+}
+
+static void
+gsk_vulkan_image_init (GskVulkanImage *self)
+{
}
VkImage
diff --git a/gsk/gskvulkanimageprivate.h b/gsk/gskvulkanimageprivate.h
index 57686ea..a706a41 100644
--- a/gsk/gskvulkanimageprivate.h
+++ b/gsk/gskvulkanimageprivate.h
@@ -5,7 +5,9 @@
G_BEGIN_DECLS
-typedef struct _GskVulkanImage GskVulkanImage;
+#define GSK_TYPE_VULKAN_IMAGE (gsk_vulkan_image_get_type ())
+
+G_DECLARE_FINAL_TYPE (GskVulkanImage, gsk_vulkan_image, GSK, VULKAN_IMAGE, GObject)
GskVulkanImage * gsk_vulkan_image_new_from_data (GdkVulkanContext *context,
VkCommandBuffer
command_buffer,
@@ -13,7 +15,6 @@ GskVulkanImage * gsk_vulkan_image_new_from_data (GdkVulk
gsize width,
gsize height,
gsize stride);
-void gsk_vulkan_image_free (GskVulkanImage *image);
VkImage gsk_vulkan_image_get_image (GskVulkanImage *self);
VkImageView gsk_vulkan_image_get_image_view (GskVulkanImage *self);
diff --git a/gsk/gskvulkanrender.c b/gsk/gskvulkanrender.c
index 640c321..fa51779 100644
--- a/gsk/gskvulkanrender.c
+++ b/gsk/gskvulkanrender.c
@@ -303,7 +303,7 @@ gsk_vulkan_render_cleanup (GskVulkanRender *self)
g_slist_free_full (self->render_passes, (GDestroyNotify) gsk_vulkan_render_pass_free);
self->render_passes = NULL;
- g_slist_free_full (self->cleanup_images, (GDestroyNotify) gsk_vulkan_image_free);
+ g_slist_free_full (self->cleanup_images, g_object_unref);
self->cleanup_images = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]