diff --git a/gsk/gpu/gskgldevice.c b/gsk/gpu/gskgldevice.c index 705afec2db..4dc889c51f 100644 --- a/gsk/gpu/gskgldevice.c +++ b/gsk/gpu/gskgldevice.c @@ -91,6 +91,20 @@ gsk_gl_device_create_upload_image (GskGpuDevice *device, height); } +static GskGpuImage * +gsk_gl_device_create_download_image (GskGpuDevice *device, + GdkMemoryDepth depth, + gsize width, + gsize height) +{ + GskGLDevice *self = GSK_GL_DEVICE (device); + + return gsk_gl_image_new (self, + gdk_memory_depth_get_format (depth), + width, + height); +} + static GskGpuImage * gsk_gl_device_create_atlas_image (GskGpuDevice *device, gsize width, @@ -129,6 +143,7 @@ gsk_gl_device_class_init (GskGLDeviceClass *klass) gpu_device_class->create_offscreen_image = gsk_gl_device_create_offscreen_image; gpu_device_class->create_atlas_image = gsk_gl_device_create_atlas_image; gpu_device_class->create_upload_image = gsk_gl_device_create_upload_image; + gpu_device_class->create_download_image = gsk_gl_device_create_download_image; object_class->finalize = gsk_gl_device_finalize; } diff --git a/gsk/gpu/gskgpudevice.c b/gsk/gpu/gskgpudevice.c index 38b3de9b89..5c2abb7ac0 100644 --- a/gsk/gpu/gskgpudevice.c +++ b/gsk/gpu/gskgpudevice.c @@ -454,6 +454,15 @@ gsk_gpu_device_create_upload_image (GskGpuDevice *self, return GSK_GPU_DEVICE_GET_CLASS (self)->create_upload_image (self, with_mipmap, format, width, height); } +GskGpuImage * +gsk_gpu_device_create_download_image (GskGpuDevice *self, + GdkMemoryDepth depth, + gsize width, + gsize height) +{ + return GSK_GPU_DEVICE_GET_CLASS (self)->create_download_image (self, depth, width, height); +} + /* This rounds up to the next number that has <= 2 bits set: * 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, ... * That is roughly sqrt(2), so it should limit waste diff --git a/gsk/gpu/gskgpudeviceprivate.h b/gsk/gpu/gskgpudeviceprivate.h index c4b66dd444..42a565d038 100644 --- a/gsk/gpu/gskgpudeviceprivate.h +++ b/gsk/gpu/gskgpudeviceprivate.h @@ -37,6 +37,10 @@ struct _GskGpuDeviceClass GdkMemoryFormat format, gsize width, gsize height); + GskGpuImage * (* create_download_image) (GskGpuDevice *self, + GdkMemoryDepth depth, + gsize width, + gsize height); }; GType gsk_gpu_device_get_type (void) G_GNUC_CONST; @@ -61,6 +65,10 @@ GskGpuImage * gsk_gpu_device_create_upload_image (GskGpuD GdkMemoryFormat format, gsize width, gsize height); +GskGpuImage * gsk_gpu_device_create_download_image (GskGpuDevice *self, + GdkMemoryDepth depth, + gsize width, + gsize height); GskGpuImage * gsk_gpu_device_lookup_texture_image (GskGpuDevice *self, GdkTexture *texture, diff --git a/gsk/gpu/gskgpurenderer.c b/gsk/gpu/gskgpurenderer.c index 3b68b1abc2..a32cae5b4e 100644 --- a/gsk/gpu/gskgpurenderer.c +++ b/gsk/gpu/gskgpurenderer.c @@ -202,11 +202,10 @@ gsk_gpu_renderer_fallback_render_texture (GskGpuRenderer *self, depth = gsk_render_node_get_preferred_depth (root); do { - image = gsk_gpu_device_create_offscreen_image (priv->device, - FALSE, - gsk_render_node_get_preferred_depth (root), - MIN (max_size, rounded_viewport->size.width), - MIN (max_size, rounded_viewport->size.height)); + image = gsk_gpu_device_create_download_image (priv->device, + gsk_render_node_get_preferred_depth (root), + MIN (max_size, rounded_viewport->size.width), + MIN (max_size, rounded_viewport->size.height)); max_size /= 2; } while (image == NULL); @@ -227,11 +226,10 @@ gsk_gpu_renderer_fallback_render_texture (GskGpuRenderer *self, { texture = NULL; if (image == NULL) - image = gsk_gpu_device_create_offscreen_image (priv->device, - FALSE, - depth, - MIN (image_width, width - x), - MIN (image_height, height - y)); + image = gsk_gpu_device_create_download_image (priv->device, + depth, + MIN (image_width, width - x), + MIN (image_height, height - y)); frame = gsk_gpu_renderer_create_frame (self); gsk_gpu_frame_render (frame, @@ -283,11 +281,10 @@ gsk_gpu_renderer_render_texture (GskRenderer *renderer, viewport->origin.y, ceil (viewport->size.width), ceil (viewport->size.height)); - image = gsk_gpu_device_create_offscreen_image (priv->device, - FALSE, - gsk_render_node_get_preferred_depth (root), - rounded_viewport.size.width, - rounded_viewport.size.height); + image = gsk_gpu_device_create_download_image (priv->device, + gsk_render_node_get_preferred_depth (root), + rounded_viewport.size.width, + rounded_viewport.size.height); if (image == NULL) return gsk_gpu_renderer_fallback_render_texture (self, root, &rounded_viewport); diff --git a/gsk/gpu/gskvulkandevice.c b/gsk/gpu/gskvulkandevice.c index 7e50788d2d..7dab7963c1 100644 --- a/gsk/gpu/gskvulkandevice.c +++ b/gsk/gpu/gskvulkandevice.c @@ -392,6 +392,24 @@ gsk_vulkan_device_create_upload_image (GskGpuDevice *device, height); } +static GskGpuImage * +gsk_vulkan_device_create_download_image (GskGpuDevice *device, + GdkMemoryDepth depth, + gsize width, + gsize height) +{ + GskVulkanDevice *self = GSK_VULKAN_DEVICE (device); + GskGpuImage *image; + + image = gsk_vulkan_image_new_for_offscreen (self, + FALSE, + gdk_memory_depth_get_format (depth), + width, + height); + + return image; +} + static void gsk_vulkan_device_finalize (GObject *object) { @@ -459,6 +477,7 @@ gsk_vulkan_device_class_init (GskVulkanDeviceClass *klass) gpu_device_class->create_offscreen_image = gsk_vulkan_device_create_offscreen_image; gpu_device_class->create_atlas_image = gsk_vulkan_device_create_atlas_image; gpu_device_class->create_upload_image = gsk_vulkan_device_create_upload_image; + gpu_device_class->create_download_image = gsk_vulkan_device_create_download_image; object_class->finalize = gsk_vulkan_device_finalize; }