vulkan: Turn GskVulkanImage into a GObject
This way, we can do real refcounting on them.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user