mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
vulkan: Move some code
Add gsk_vulkan_image_new_from_texture() and use it. Also rewrite the actual code from using Cairo surfaces to using GdkTextureDownloader.
This commit is contained in:
parent
e7c86f4608
commit
cb4e92946b
@ -529,6 +529,27 @@ gsk_vulkan_image_new_from_data_directly (GskVulkanUploader *uploader,
|
||||
return self;
|
||||
}
|
||||
|
||||
GskVulkanImage *
|
||||
gsk_vulkan_image_new_from_texture (GskVulkanUploader *uploader,
|
||||
GdkTexture *texture)
|
||||
{
|
||||
GdkTextureDownloader *downloader;
|
||||
GskVulkanImage *result;
|
||||
GBytes *bytes;
|
||||
gsize stride;
|
||||
|
||||
downloader = gdk_texture_downloader_new (texture);
|
||||
bytes = gdk_texture_downloader_download_bytes (downloader, &stride);
|
||||
result = gsk_vulkan_image_new_from_data (uploader,
|
||||
g_bytes_get_data (bytes, NULL),
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
stride);
|
||||
g_bytes_unref (bytes);
|
||||
gdk_texture_downloader_free (downloader);
|
||||
return result;
|
||||
}
|
||||
|
||||
GskVulkanImage *
|
||||
gsk_vulkan_image_new_from_data (GskVulkanUploader *uploader,
|
||||
const guchar *data,
|
||||
|
@ -24,6 +24,8 @@ GskVulkanImage * gsk_vulkan_image_new_for_swapchain (GdkVulk
|
||||
VkFormat format,
|
||||
gsize width,
|
||||
gsize height);
|
||||
GskVulkanImage * gsk_vulkan_image_new_from_texture (GskVulkanUploader *uploader,
|
||||
GdkTexture *texture);
|
||||
GskVulkanImage * gsk_vulkan_image_new_from_data (GskVulkanUploader *uploader,
|
||||
const guchar *data,
|
||||
gsize width,
|
||||
|
@ -422,20 +422,13 @@ gsk_vulkan_renderer_ref_texture_image (GskVulkanRenderer *self,
|
||||
GskVulkanUploader *uploader)
|
||||
{
|
||||
GskVulkanTextureData *data;
|
||||
cairo_surface_t *surface;
|
||||
GskVulkanImage *image;
|
||||
|
||||
data = gdk_texture_get_render_data (texture, self);
|
||||
if (data)
|
||||
return g_object_ref (data->image);
|
||||
|
||||
surface = gdk_texture_download_surface (texture);
|
||||
image = gsk_vulkan_image_new_from_data (uploader,
|
||||
cairo_image_surface_get_data (surface),
|
||||
cairo_image_surface_get_width (surface),
|
||||
cairo_image_surface_get_height (surface),
|
||||
cairo_image_surface_get_stride (surface));
|
||||
cairo_surface_destroy (surface);
|
||||
image = gsk_vulkan_image_new_from_texture (uploader, texture);
|
||||
|
||||
data = g_new0 (GskVulkanTextureData, 1);
|
||||
data->image = image;
|
||||
|
Loading…
Reference in New Issue
Block a user