diff options
author | Benjamin Otte <otte@redhat.com> | 2016-12-08 20:19:56 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-12-09 18:35:51 +0100 |
commit | c160ef16c10c2f144a8d0ab5c70ec55b021755fc (patch) | |
tree | eda55dc32840a66297321121006ff02ca9104594 /gsk/gskvulkanimage.c | |
parent | 85bc9ff36b4a8cb0e1b2b87a0d13bc98605fd590 (diff) | |
download | gtk+-c160ef16c10c2f144a8d0ab5c70ec55b021755fc.tar.gz |
vulkan: Turn GskVulkanImage into a GObject
This way, we can do real refcounting on them.
Diffstat (limited to 'gsk/gskvulkanimage.c')
-rw-r--r-- | gsk/gskvulkanimage.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/gsk/gskvulkanimage.c b/gsk/gskvulkanimage.c index 279d7bb147..f57c5d556e 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 |