2016-11-29 15:33:14 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gskvulkanrendererprivate.h"
|
|
|
|
|
|
|
|
#include "gskdebugprivate.h"
|
2016-12-05 01:50:06 +00:00
|
|
|
#include "gskprivate.h"
|
2016-11-29 15:33:14 +00:00
|
|
|
#include "gskrendererprivate.h"
|
|
|
|
#include "gskrendernodeprivate.h"
|
2016-12-05 01:50:06 +00:00
|
|
|
#include "gskvulkanbufferprivate.h"
|
2016-12-06 13:42:46 +00:00
|
|
|
#include "gskvulkanimageprivate.h"
|
2016-12-05 01:50:06 +00:00
|
|
|
#include "gskvulkanpipelineprivate.h"
|
2016-12-07 13:50:52 +00:00
|
|
|
#include "gskvulkanrenderprivate.h"
|
2017-09-19 23:32:04 +00:00
|
|
|
#include "gskvulkanglyphcacheprivate.h"
|
2016-11-29 15:33:14 +00:00
|
|
|
|
2017-11-02 20:39:00 +00:00
|
|
|
#include "gdk/gdktextureprivate.h"
|
2018-05-19 19:35:02 +00:00
|
|
|
#include "gdk/gdkprofilerprivate.h"
|
2017-11-02 20:39:00 +00:00
|
|
|
|
2016-12-07 00:48:31 +00:00
|
|
|
#include <graphene.h>
|
|
|
|
|
2016-12-09 06:23:04 +00:00
|
|
|
typedef struct _GskVulkanTextureData GskVulkanTextureData;
|
|
|
|
|
|
|
|
struct _GskVulkanTextureData {
|
2017-11-02 20:39:00 +00:00
|
|
|
GdkTexture *texture;
|
2016-12-09 06:23:04 +00:00
|
|
|
GskVulkanImage *image;
|
|
|
|
GskVulkanRenderer *renderer;
|
|
|
|
};
|
|
|
|
|
2016-11-29 15:33:14 +00:00
|
|
|
#ifdef G_ENABLE_DEBUG
|
2017-09-25 22:37:22 +00:00
|
|
|
typedef struct {
|
|
|
|
GQuark frames;
|
2017-09-28 12:29:14 +00:00
|
|
|
GQuark render_passes;
|
2017-09-26 01:02:21 +00:00
|
|
|
GQuark fallback_pixels;
|
2017-09-30 14:39:04 +00:00
|
|
|
GQuark texture_pixels;
|
2017-09-25 22:37:22 +00:00
|
|
|
} ProfileCounters;
|
|
|
|
|
2016-11-29 15:33:14 +00:00
|
|
|
typedef struct {
|
|
|
|
GQuark cpu_time;
|
|
|
|
GQuark gpu_time;
|
|
|
|
} ProfileTimers;
|
|
|
|
|
2018-05-19 19:35:02 +00:00
|
|
|
static guint texture_pixels_counter;
|
|
|
|
static guint fallback_pixels_counter;
|
2020-01-29 13:03:56 +00:00
|
|
|
#endif
|
2018-05-19 19:35:02 +00:00
|
|
|
|
2016-11-29 15:33:14 +00:00
|
|
|
struct _GskVulkanRenderer
|
|
|
|
{
|
|
|
|
GskRenderer parent_instance;
|
|
|
|
|
|
|
|
GdkVulkanContext *vulkan;
|
2016-11-30 01:08:17 +00:00
|
|
|
|
|
|
|
guint n_targets;
|
2016-12-08 21:35:16 +00:00
|
|
|
GskVulkanImage **targets;
|
2016-11-30 02:59:28 +00:00
|
|
|
|
2016-12-09 05:13:14 +00:00
|
|
|
GskVulkanRender *render;
|
2016-12-08 17:40:35 +00:00
|
|
|
|
2016-12-09 06:23:04 +00:00
|
|
|
GSList *textures;
|
|
|
|
|
2017-09-19 23:32:04 +00:00
|
|
|
GskVulkanGlyphCache *glyph_cache;
|
2017-09-01 20:58:42 +00:00
|
|
|
|
2016-11-29 15:33:14 +00:00
|
|
|
#ifdef G_ENABLE_DEBUG
|
2017-09-25 22:37:22 +00:00
|
|
|
ProfileCounters profile_counters;
|
2016-11-29 15:33:14 +00:00
|
|
|
ProfileTimers profile_timers;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GskVulkanRendererClass
|
|
|
|
{
|
|
|
|
GskRendererClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GskVulkanRenderer, gsk_vulkan_renderer, GSK_TYPE_RENDERER)
|
|
|
|
|
2016-11-30 01:08:17 +00:00
|
|
|
static void
|
|
|
|
gsk_vulkan_renderer_free_targets (GskVulkanRenderer *self)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < self->n_targets; i++)
|
|
|
|
{
|
2016-12-08 21:35:16 +00:00
|
|
|
g_object_unref (self->targets[i]);
|
2016-11-30 01:08:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_clear_pointer (&self->targets, g_free);
|
|
|
|
self->n_targets = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gsk_vulkan_renderer_update_images_cb (GdkVulkanContext *context,
|
|
|
|
GskVulkanRenderer *self)
|
|
|
|
{
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *window;
|
2020-07-24 13:54:49 +00:00
|
|
|
int scale_factor;
|
2016-12-08 20:14:41 +00:00
|
|
|
gsize width, height;
|
2016-11-30 01:08:17 +00:00
|
|
|
guint i;
|
|
|
|
|
|
|
|
gsk_vulkan_renderer_free_targets (self);
|
|
|
|
|
|
|
|
self->n_targets = gdk_vulkan_context_get_n_images (context);
|
2016-12-08 21:35:16 +00:00
|
|
|
self->targets = g_new (GskVulkanImage *, self->n_targets);
|
2016-11-30 01:08:17 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
window = gsk_renderer_get_surface (GSK_RENDERER (self));
|
2018-03-20 10:40:08 +00:00
|
|
|
scale_factor = gdk_surface_get_scale_factor (window);
|
|
|
|
width = gdk_surface_get_width (window) * scale_factor;
|
|
|
|
height = gdk_surface_get_height (window) * scale_factor;
|
2016-12-08 20:14:41 +00:00
|
|
|
|
2016-11-30 01:08:17 +00:00
|
|
|
for (i = 0; i < self->n_targets; i++)
|
|
|
|
{
|
2016-12-08 21:35:16 +00:00
|
|
|
self->targets[i] = gsk_vulkan_image_new_for_swapchain (self->vulkan,
|
|
|
|
gdk_vulkan_context_get_image (context, i),
|
|
|
|
gdk_vulkan_context_get_image_format (self->vulkan),
|
|
|
|
width, height);
|
2016-11-30 01:08:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-29 15:33:14 +00:00
|
|
|
static gboolean
|
|
|
|
gsk_vulkan_renderer_realize (GskRenderer *renderer,
|
2021-10-20 18:30:08 +00:00
|
|
|
GdkSurface *surface,
|
2016-11-30 01:08:17 +00:00
|
|
|
GError **error)
|
2016-11-29 15:33:14 +00:00
|
|
|
{
|
|
|
|
GskVulkanRenderer *self = GSK_VULKAN_RENDERER (renderer);
|
|
|
|
|
2021-10-20 18:30:08 +00:00
|
|
|
if (surface == NULL)
|
|
|
|
{
|
|
|
|
g_set_error (error, GDK_VULKAN_ERROR, GDK_VULKAN_ERROR_UNSUPPORTED,
|
|
|
|
"The Vulkan renderer does not support surfaceless rendering yet.");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
self->vulkan = gdk_surface_create_vulkan_context (surface, error);
|
2016-11-29 15:33:14 +00:00
|
|
|
if (self->vulkan == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2016-11-30 01:08:17 +00:00
|
|
|
g_signal_connect (self->vulkan,
|
|
|
|
"images-updated",
|
|
|
|
G_CALLBACK (gsk_vulkan_renderer_update_images_cb),
|
|
|
|
self);
|
|
|
|
gsk_vulkan_renderer_update_images_cb (self->vulkan, self);
|
|
|
|
|
2016-12-09 05:13:14 +00:00
|
|
|
self->render = gsk_vulkan_render_new (renderer, self->vulkan);
|
2016-12-08 17:40:35 +00:00
|
|
|
|
2018-01-14 14:52:52 +00:00
|
|
|
self->glyph_cache = gsk_vulkan_glyph_cache_new (renderer, self->vulkan);
|
2017-09-11 01:55:22 +00:00
|
|
|
|
2016-11-29 15:33:14 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gsk_vulkan_renderer_unrealize (GskRenderer *renderer)
|
|
|
|
{
|
|
|
|
GskVulkanRenderer *self = GSK_VULKAN_RENDERER (renderer);
|
2016-12-09 06:23:04 +00:00
|
|
|
GSList *l;
|
|
|
|
|
2017-09-19 23:32:04 +00:00
|
|
|
g_clear_object (&self->glyph_cache);
|
2017-09-11 01:55:22 +00:00
|
|
|
|
2016-12-09 06:23:04 +00:00
|
|
|
for (l = self->textures; l; l = l->next)
|
|
|
|
{
|
|
|
|
GskVulkanTextureData *data = l->data;
|
|
|
|
|
|
|
|
data->renderer = NULL;
|
2017-11-02 20:39:00 +00:00
|
|
|
gdk_texture_clear_render_data (data->texture);
|
2016-12-09 06:23:04 +00:00
|
|
|
}
|
2018-07-28 17:53:48 +00:00
|
|
|
g_clear_pointer (&self->textures, g_slist_free);
|
2016-11-30 02:59:28 +00:00
|
|
|
|
2016-12-09 05:13:14 +00:00
|
|
|
g_clear_pointer (&self->render, gsk_vulkan_render_free);
|
2016-12-08 17:40:35 +00:00
|
|
|
|
2016-11-30 01:08:17 +00:00
|
|
|
gsk_vulkan_renderer_free_targets (self);
|
|
|
|
g_signal_handlers_disconnect_by_func(self->vulkan,
|
|
|
|
gsk_vulkan_renderer_update_images_cb,
|
|
|
|
self);
|
2016-11-30 02:59:28 +00:00
|
|
|
|
2016-11-29 15:33:14 +00:00
|
|
|
g_clear_object (&self->vulkan);
|
|
|
|
}
|
|
|
|
|
2017-11-02 20:39:00 +00:00
|
|
|
static GdkTexture *
|
2016-12-22 18:01:07 +00:00
|
|
|
gsk_vulkan_renderer_render_texture (GskRenderer *renderer,
|
|
|
|
GskRenderNode *root,
|
|
|
|
const graphene_rect_t *viewport)
|
|
|
|
{
|
|
|
|
GskVulkanRenderer *self = GSK_VULKAN_RENDERER (renderer);
|
|
|
|
GskVulkanRender *render;
|
|
|
|
GskVulkanImage *image;
|
2017-11-02 20:39:00 +00:00
|
|
|
GdkTexture *texture;
|
2016-12-22 18:01:07 +00:00
|
|
|
#ifdef G_ENABLE_DEBUG
|
|
|
|
GskProfiler *profiler;
|
2020-08-19 22:49:34 +00:00
|
|
|
gint64 cpu_time;
|
|
|
|
gint64 start_time G_GNUC_UNUSED;
|
2016-12-22 18:01:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef G_ENABLE_DEBUG
|
|
|
|
profiler = gsk_renderer_get_profiler (renderer);
|
2017-09-26 01:02:21 +00:00
|
|
|
gsk_profiler_counter_set (profiler, self->profile_counters.fallback_pixels, 0);
|
2017-09-30 14:39:04 +00:00
|
|
|
gsk_profiler_counter_set (profiler, self->profile_counters.texture_pixels, 0);
|
2017-09-28 12:29:14 +00:00
|
|
|
gsk_profiler_counter_set (profiler, self->profile_counters.render_passes, 0);
|
2016-12-22 18:01:07 +00:00
|
|
|
gsk_profiler_timer_begin (profiler, self->profile_timers.cpu_time);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
render = gsk_vulkan_render_new (renderer, self->vulkan);
|
|
|
|
|
|
|
|
image = gsk_vulkan_image_new_for_framebuffer (self->vulkan,
|
|
|
|
ceil (viewport->size.width),
|
|
|
|
ceil (viewport->size.height));
|
|
|
|
|
2018-03-28 13:01:34 +00:00
|
|
|
gsk_vulkan_render_reset (render, image, viewport, NULL);
|
2016-12-22 18:01:07 +00:00
|
|
|
|
|
|
|
gsk_vulkan_render_add_node (render, root);
|
|
|
|
|
|
|
|
gsk_vulkan_render_upload (render);
|
|
|
|
|
2017-09-30 02:38:59 +00:00
|
|
|
gsk_vulkan_render_draw (render);
|
2016-12-22 18:01:07 +00:00
|
|
|
|
|
|
|
texture = gsk_vulkan_render_download_target (render);
|
|
|
|
|
|
|
|
g_object_unref (image);
|
|
|
|
gsk_vulkan_render_free (render);
|
|
|
|
|
|
|
|
#ifdef G_ENABLE_DEBUG
|
2018-05-19 19:35:02 +00:00
|
|
|
start_time = gsk_profiler_timer_get_start (profiler, self->profile_timers.cpu_time);
|
2016-12-22 18:01:07 +00:00
|
|
|
cpu_time = gsk_profiler_timer_end (profiler, self->profile_timers.cpu_time);
|
|
|
|
gsk_profiler_timer_set (profiler, self->profile_timers.cpu_time, cpu_time);
|
|
|
|
|
|
|
|
gsk_profiler_push_samples (profiler);
|
2018-05-19 19:35:02 +00:00
|
|
|
|
2020-02-12 10:05:01 +00:00
|
|
|
if (GDK_PROFILER_IS_RUNNING)
|
2018-05-19 19:35:02 +00:00
|
|
|
{
|
2020-08-19 22:49:34 +00:00
|
|
|
gdk_profiler_add_mark (start_time * 1000, cpu_time * 1000, "render", "");
|
2018-05-19 19:35:02 +00:00
|
|
|
gdk_profiler_set_int_counter (texture_pixels_counter,
|
|
|
|
gsk_profiler_counter_get (profiler, self->profile_counters.texture_pixels));
|
|
|
|
gdk_profiler_set_int_counter (fallback_pixels_counter,
|
|
|
|
gsk_profiler_counter_get (profiler, self->profile_counters.fallback_pixels));
|
|
|
|
}
|
2016-12-22 18:01:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return texture;
|
|
|
|
}
|
|
|
|
|
2016-11-29 15:33:14 +00:00
|
|
|
static void
|
2018-03-28 13:01:34 +00:00
|
|
|
gsk_vulkan_renderer_render (GskRenderer *renderer,
|
|
|
|
GskRenderNode *root,
|
|
|
|
const cairo_region_t *region)
|
2016-11-29 15:33:14 +00:00
|
|
|
{
|
|
|
|
GskVulkanRenderer *self = GSK_VULKAN_RENDERER (renderer);
|
2016-12-08 16:46:08 +00:00
|
|
|
GskVulkanRender *render;
|
2018-04-20 22:58:53 +00:00
|
|
|
const cairo_region_t *clip;
|
2016-11-29 15:33:14 +00:00
|
|
|
#ifdef G_ENABLE_DEBUG
|
|
|
|
GskProfiler *profiler;
|
|
|
|
gint64 cpu_time;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef G_ENABLE_DEBUG
|
|
|
|
profiler = gsk_renderer_get_profiler (renderer);
|
2017-09-28 00:56:01 +00:00
|
|
|
gsk_profiler_counter_set (profiler, self->profile_counters.fallback_pixels, 0);
|
2017-09-30 14:39:04 +00:00
|
|
|
gsk_profiler_counter_set (profiler, self->profile_counters.texture_pixels, 0);
|
2017-09-28 12:29:14 +00:00
|
|
|
gsk_profiler_counter_set (profiler, self->profile_counters.render_passes, 0);
|
2016-11-29 15:33:14 +00:00
|
|
|
gsk_profiler_timer_begin (profiler, self->profile_timers.cpu_time);
|
|
|
|
#endif
|
|
|
|
|
2018-04-23 15:28:55 +00:00
|
|
|
gdk_draw_context_begin_frame (GDK_DRAW_CONTEXT (self->vulkan), region);
|
2016-12-09 05:13:14 +00:00
|
|
|
render = self->render;
|
2016-12-08 17:40:35 +00:00
|
|
|
|
2018-04-20 22:58:53 +00:00
|
|
|
clip = gdk_draw_context_get_frame_region (GDK_DRAW_CONTEXT (self->vulkan));
|
2018-03-28 13:01:34 +00:00
|
|
|
gsk_vulkan_render_reset (render, self->targets[gdk_vulkan_context_get_draw_index (self->vulkan)], NULL, clip);
|
2016-12-07 13:50:52 +00:00
|
|
|
|
2016-12-08 16:46:08 +00:00
|
|
|
gsk_vulkan_render_add_node (render, root);
|
2016-12-07 13:50:52 +00:00
|
|
|
|
2016-12-08 16:46:08 +00:00
|
|
|
gsk_vulkan_render_upload (render);
|
2016-12-07 13:50:52 +00:00
|
|
|
|
2017-09-30 02:38:59 +00:00
|
|
|
gsk_vulkan_render_draw (render);
|
2016-12-05 01:50:06 +00:00
|
|
|
|
2016-11-29 15:33:14 +00:00
|
|
|
#ifdef G_ENABLE_DEBUG
|
2017-09-25 22:37:22 +00:00
|
|
|
gsk_profiler_counter_inc (profiler, self->profile_counters.frames);
|
|
|
|
|
2016-11-29 15:33:14 +00:00
|
|
|
cpu_time = gsk_profiler_timer_end (profiler, self->profile_timers.cpu_time);
|
|
|
|
gsk_profiler_timer_set (profiler, self->profile_timers.cpu_time, cpu_time);
|
|
|
|
|
|
|
|
gsk_profiler_push_samples (profiler);
|
|
|
|
#endif
|
2016-12-01 03:07:20 +00:00
|
|
|
|
2018-04-23 15:28:55 +00:00
|
|
|
gdk_draw_context_end_frame (GDK_DRAW_CONTEXT (self->vulkan));
|
2016-12-01 03:07:20 +00:00
|
|
|
}
|
|
|
|
|
2016-11-29 15:33:14 +00:00
|
|
|
static void
|
|
|
|
gsk_vulkan_renderer_class_init (GskVulkanRendererClass *klass)
|
|
|
|
{
|
|
|
|
GskRendererClass *renderer_class = GSK_RENDERER_CLASS (klass);
|
|
|
|
|
|
|
|
renderer_class->realize = gsk_vulkan_renderer_realize;
|
|
|
|
renderer_class->unrealize = gsk_vulkan_renderer_unrealize;
|
|
|
|
renderer_class->render = gsk_vulkan_renderer_render;
|
2016-12-22 18:01:07 +00:00
|
|
|
renderer_class->render_texture = gsk_vulkan_renderer_render_texture;
|
2016-11-29 15:33:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gsk_vulkan_renderer_init (GskVulkanRenderer *self)
|
|
|
|
{
|
|
|
|
#ifdef G_ENABLE_DEBUG
|
|
|
|
GskProfiler *profiler = gsk_renderer_get_profiler (GSK_RENDERER (self));
|
2016-12-05 01:50:06 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
gsk_ensure_resources ();
|
2016-11-29 15:33:14 +00:00
|
|
|
|
2016-12-05 01:50:06 +00:00
|
|
|
#ifdef G_ENABLE_DEBUG
|
2017-09-25 22:37:22 +00:00
|
|
|
self->profile_counters.frames = gsk_profiler_add_counter (profiler, "frames", "Frames", FALSE);
|
2017-09-28 12:29:14 +00:00
|
|
|
self->profile_counters.render_passes = gsk_profiler_add_counter (profiler, "render-passes", "Render passes", FALSE);
|
2017-09-26 01:02:21 +00:00
|
|
|
self->profile_counters.fallback_pixels = gsk_profiler_add_counter (profiler, "fallback-pixels", "Fallback pixels", TRUE);
|
2017-09-30 14:39:04 +00:00
|
|
|
self->profile_counters.texture_pixels = gsk_profiler_add_counter (profiler, "texture-pixels", "Texture pixels", TRUE);
|
2017-09-26 01:02:21 +00:00
|
|
|
|
2016-11-29 15:33:14 +00:00
|
|
|
self->profile_timers.cpu_time = gsk_profiler_add_timer (profiler, "cpu-time", "CPU time", FALSE, TRUE);
|
2018-01-14 20:11:33 +00:00
|
|
|
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), SYNC))
|
2017-09-28 14:27:58 +00:00
|
|
|
self->profile_timers.gpu_time = gsk_profiler_add_timer (profiler, "gpu-time", "GPU time", FALSE, TRUE);
|
2018-05-19 19:35:02 +00:00
|
|
|
|
|
|
|
if (texture_pixels_counter == 0)
|
|
|
|
{
|
|
|
|
texture_pixels_counter = gdk_profiler_define_int_counter ("texture-pixels", "Texture Pixels");
|
|
|
|
fallback_pixels_counter = gdk_profiler_define_int_counter ("fallback-pixels", "Fallback Pixels");
|
|
|
|
}
|
|
|
|
|
2016-11-29 15:33:14 +00:00
|
|
|
#endif
|
|
|
|
}
|
2016-12-09 06:23:04 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gsk_vulkan_renderer_clear_texture (gpointer p)
|
|
|
|
{
|
|
|
|
GskVulkanTextureData *data = p;
|
|
|
|
|
|
|
|
if (data->renderer != NULL)
|
|
|
|
data->renderer->textures = g_slist_remove (data->renderer->textures, data);
|
|
|
|
|
|
|
|
g_object_unref (data->image);
|
|
|
|
|
2023-03-03 11:48:49 +00:00
|
|
|
g_free (data);
|
2016-12-09 06:23:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GskVulkanImage *
|
2016-12-17 03:22:44 +00:00
|
|
|
gsk_vulkan_renderer_ref_texture_image (GskVulkanRenderer *self,
|
2017-11-02 20:39:00 +00:00
|
|
|
GdkTexture *texture,
|
2016-12-17 03:22:44 +00:00
|
|
|
GskVulkanUploader *uploader)
|
2016-12-09 06:23:04 +00:00
|
|
|
{
|
|
|
|
GskVulkanTextureData *data;
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
GskVulkanImage *image;
|
|
|
|
|
2017-11-02 20:39:00 +00:00
|
|
|
data = gdk_texture_get_render_data (texture, self);
|
2016-12-09 06:23:04 +00:00
|
|
|
if (data)
|
|
|
|
return g_object_ref (data->image);
|
|
|
|
|
2017-11-02 20:39:00 +00:00
|
|
|
surface = gdk_texture_download_surface (texture);
|
2016-12-17 03:22:44 +00:00
|
|
|
image = gsk_vulkan_image_new_from_data (uploader,
|
2016-12-09 06:23:04 +00:00
|
|
|
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);
|
|
|
|
|
2023-03-03 11:48:49 +00:00
|
|
|
data = g_new0 (GskVulkanTextureData, 1);
|
2016-12-09 06:23:04 +00:00
|
|
|
data->image = image;
|
|
|
|
data->texture = texture;
|
|
|
|
data->renderer = self;
|
|
|
|
|
2017-11-02 20:39:00 +00:00
|
|
|
if (gdk_texture_set_render_data (texture, self, data, gsk_vulkan_renderer_clear_texture))
|
2016-12-09 06:23:04 +00:00
|
|
|
{
|
|
|
|
g_object_ref (data->image);
|
|
|
|
self->textures = g_slist_prepend (self->textures, data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-03-03 11:48:49 +00:00
|
|
|
g_free (data);
|
2016-12-09 06:23:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return image;
|
|
|
|
}
|
2017-09-01 20:58:42 +00:00
|
|
|
|
2017-09-19 22:53:32 +00:00
|
|
|
GskVulkanImage *
|
|
|
|
gsk_vulkan_renderer_ref_glyph_image (GskVulkanRenderer *self,
|
|
|
|
GskVulkanUploader *uploader,
|
|
|
|
guint index)
|
2017-09-11 01:55:22 +00:00
|
|
|
{
|
2017-09-19 23:32:04 +00:00
|
|
|
return g_object_ref (gsk_vulkan_glyph_cache_get_glyph_image (self->glyph_cache, uploader, index));
|
2017-09-11 01:55:22 +00:00
|
|
|
}
|
2017-09-01 20:58:42 +00:00
|
|
|
|
2019-07-25 21:50:31 +00:00
|
|
|
guint
|
|
|
|
gsk_vulkan_renderer_cache_glyph (GskVulkanRenderer *self,
|
|
|
|
PangoFont *font,
|
|
|
|
PangoGlyph glyph,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
float scale)
|
|
|
|
{
|
|
|
|
return gsk_vulkan_glyph_cache_lookup (self->glyph_cache, TRUE, font, glyph, x, y, scale)->texture_index;
|
|
|
|
}
|
|
|
|
|
2017-09-19 22:53:32 +00:00
|
|
|
GskVulkanCachedGlyph *
|
|
|
|
gsk_vulkan_renderer_get_cached_glyph (GskVulkanRenderer *self,
|
|
|
|
PangoFont *font,
|
2017-10-28 17:13:31 +00:00
|
|
|
PangoGlyph glyph,
|
2019-07-25 21:50:31 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
2017-10-28 17:13:31 +00:00
|
|
|
float scale)
|
2017-09-11 01:55:22 +00:00
|
|
|
{
|
2019-07-25 21:50:31 +00:00
|
|
|
return gsk_vulkan_glyph_cache_lookup (self->glyph_cache, FALSE, font, glyph, x, y, scale);
|
2017-09-01 20:58:42 +00:00
|
|
|
}
|
2019-05-02 00:57:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gsk_vulkan_renderer_new:
|
|
|
|
*
|
|
|
|
* Creates a new Vulkan renderer.
|
|
|
|
*
|
|
|
|
* The Vulkan renderer is a renderer that uses the Vulkan library for
|
|
|
|
* rendering.
|
|
|
|
*
|
|
|
|
* This function is only available when GTK was compiled with Vulkan
|
|
|
|
* support.
|
|
|
|
*
|
|
|
|
* Returns: a new Vulkan renderer
|
|
|
|
**/
|
|
|
|
GskRenderer *
|
|
|
|
gsk_vulkan_renderer_new (void)
|
|
|
|
{
|
|
|
|
return g_object_new (GSK_TYPE_VULKAN_RENDERER, NULL);
|
|
|
|
}
|