Compare commits
1 Commits
gpu-desc-n
...
inline-vec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd06452b0f |
@@ -5,7 +5,6 @@
|
||||
#include "gskglbufferprivate.h"
|
||||
#include "gskglimageprivate.h"
|
||||
|
||||
|
||||
struct _GskGLDescriptors
|
||||
{
|
||||
GskGpuDescriptors parent_instance;
|
||||
@@ -14,12 +13,16 @@ struct _GskGLDescriptors
|
||||
guint n_external;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskGLDescriptors, gsk_gl_descriptors, GSK_TYPE_GPU_DESCRIPTORS)
|
||||
|
||||
static void
|
||||
gsk_gl_descriptors_finalize (GskGpuDescriptors *desc)
|
||||
gsk_gl_descriptors_finalize (GObject *object)
|
||||
{
|
||||
GskGLDescriptors *self = GSK_GL_DESCRIPTORS (desc);
|
||||
GskGLDescriptors *self = GSK_GL_DESCRIPTORS (object);
|
||||
|
||||
g_object_unref (self->device);
|
||||
|
||||
G_OBJECT_CLASS (gsk_gl_descriptors_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -69,24 +72,33 @@ gsk_gl_descriptors_add_buffer (GskGpuDescriptors *desc,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GskGpuDescriptorsClass GSK_GL_DESCRIPTORS_CLASS =
|
||||
static void
|
||||
gsk_gl_descriptors_class_init (GskGLDescriptorsClass *klass)
|
||||
{
|
||||
.finalize = gsk_gl_descriptors_finalize,
|
||||
.add_image = gsk_gl_descriptors_add_image,
|
||||
.add_buffer = gsk_gl_descriptors_add_buffer,
|
||||
};
|
||||
GskGpuDescriptorsClass *descriptors_class = GSK_GPU_DESCRIPTORS_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gsk_gl_descriptors_finalize;
|
||||
|
||||
descriptors_class->add_image = gsk_gl_descriptors_add_image;
|
||||
descriptors_class->add_buffer = gsk_gl_descriptors_add_buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_descriptors_init (GskGLDescriptors *self)
|
||||
{
|
||||
}
|
||||
|
||||
GskGpuDescriptors *
|
||||
gsk_gl_descriptors_new (GskGLDevice *device)
|
||||
{
|
||||
GskGpuDescriptors *desc;
|
||||
GskGLDescriptors *self;
|
||||
|
||||
desc = gsk_gpu_descriptors_new ((GskGpuDescriptorsClass *) &GSK_GL_DESCRIPTORS_CLASS,
|
||||
sizeof (GskGLDescriptors));
|
||||
self = g_object_new (GSK_TYPE_GL_DESCRIPTORS, NULL);
|
||||
|
||||
GSK_GL_DESCRIPTORS (desc)->device = g_object_ref (device);
|
||||
self->device = g_object_ref (device);
|
||||
|
||||
return desc;
|
||||
return GSK_GPU_DESCRIPTORS (self);
|
||||
}
|
||||
|
||||
guint
|
||||
@@ -98,7 +110,7 @@ gsk_gl_descriptors_get_n_external (GskGLDescriptors *self)
|
||||
void
|
||||
gsk_gl_descriptors_use (GskGLDescriptors *self)
|
||||
{
|
||||
GskGpuDescriptors *desc = &self->parent_instance;
|
||||
GskGpuDescriptors *desc = GSK_GPU_DESCRIPTORS (self);
|
||||
gsize i, ext, n_textures;
|
||||
|
||||
n_textures = 16 - 3 * self->n_external;
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GskGLDescriptors GskGLDescriptors;
|
||||
|
||||
#define GSK_GL_DESCRIPTORS(d) ((GskGLDescriptors *) (d))
|
||||
#define GSK_TYPE_GL_DESCRIPTORS (gsk_gl_descriptors_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskGLDescriptors, gsk_gl_descriptors, GSK, GL_DESCRIPTORS, GskGpuDescriptors)
|
||||
|
||||
GskGpuDescriptors * gsk_gl_descriptors_new (GskGLDevice *device);
|
||||
|
||||
|
||||
@@ -52,39 +52,43 @@ gsk_gpu_buffer_entry_clear (gpointer data)
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
|
||||
typedef struct _GskGpuDescriptorsPrivate GskGpuDescriptorsPrivate;
|
||||
|
||||
struct _GskGpuDescriptorsPrivate
|
||||
{
|
||||
GskGpuImageEntries images;
|
||||
GskGpuBufferEntries buffers;
|
||||
};
|
||||
|
||||
static inline GskGpuDescriptorsPrivate *
|
||||
gsk_gpu_descriptors_get_instance_private (GskGpuDescriptors *self)
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GskGpuDescriptors, gsk_gpu_descriptors, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gsk_gpu_descriptors_finalize (GObject *object)
|
||||
{
|
||||
return (GskGpuDescriptorsPrivate *) (((guchar *)self) - sizeof (GskGpuDescriptorsPrivate));
|
||||
GskGpuDescriptors *self = GSK_GPU_DESCRIPTORS (object);
|
||||
GskGpuDescriptorsPrivate *priv = gsk_gpu_descriptors_get_instance_private (self);
|
||||
|
||||
gsk_gpu_image_entries_clear (&priv->images);
|
||||
gsk_gpu_buffer_entries_clear (&priv->buffers);
|
||||
|
||||
G_OBJECT_CLASS (gsk_gpu_descriptors_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/* Just for subclasses */
|
||||
GskGpuDescriptors *
|
||||
gsk_gpu_descriptors_new (GskGpuDescriptorsClass *desc_class,
|
||||
gsize child_size)
|
||||
static void
|
||||
gsk_gpu_descriptors_class_init (GskGpuDescriptorsClass *klass)
|
||||
{
|
||||
GskGpuDescriptors *self;
|
||||
GskGpuDescriptorsPrivate *priv;
|
||||
guchar *data;
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
data = g_new0 (guchar, child_size + sizeof (GskGpuDescriptorsPrivate));
|
||||
object_class->finalize = gsk_gpu_descriptors_finalize;
|
||||
}
|
||||
|
||||
priv = (GskGpuDescriptorsPrivate *) data;
|
||||
self = (GskGpuDescriptors *) (data + sizeof (GskGpuDescriptorsPrivate));
|
||||
|
||||
self->ref_count = 1;
|
||||
self->desc_class = desc_class;
|
||||
static void
|
||||
gsk_gpu_descriptors_init (GskGpuDescriptors *self)
|
||||
{
|
||||
GskGpuDescriptorsPrivate *priv = gsk_gpu_descriptors_get_instance_private (self);
|
||||
|
||||
gsk_gpu_image_entries_init (&priv->images);
|
||||
gsk_gpu_buffer_entries_init (&priv->buffers);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
gsize
|
||||
@@ -185,7 +189,7 @@ gsk_gpu_descriptors_add_image (GskGpuDescriptors *self,
|
||||
}
|
||||
}
|
||||
|
||||
if (!self->desc_class->add_image (self, image, sampler, &descriptor))
|
||||
if (!GSK_GPU_DESCRIPTORS_GET_CLASS (self)->add_image (self, image, sampler, &descriptor))
|
||||
return FALSE;
|
||||
|
||||
gsk_gpu_image_entries_append (&priv->images,
|
||||
@@ -220,7 +224,7 @@ gsk_gpu_descriptors_add_buffer (GskGpuDescriptors *self,
|
||||
}
|
||||
}
|
||||
|
||||
if (!self->desc_class->add_buffer (self, buffer, &descriptor))
|
||||
if (!GSK_GPU_DESCRIPTORS_GET_CLASS (self)->add_buffer (self, buffer, &descriptor))
|
||||
return FALSE;
|
||||
|
||||
gsk_gpu_buffer_entries_append (&priv->buffers,
|
||||
@@ -234,28 +238,3 @@ gsk_gpu_descriptors_add_buffer (GskGpuDescriptors *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GskGpuDescriptors *
|
||||
gsk_gpu_descriptors_ref (GskGpuDescriptors *self)
|
||||
{
|
||||
self->ref_count++;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gpu_descriptors_unref (GskGpuDescriptors *self)
|
||||
{
|
||||
self->ref_count--;
|
||||
|
||||
if (self->ref_count == 0)
|
||||
{
|
||||
GskGpuDescriptorsPrivate *priv = gsk_gpu_descriptors_get_instance_private (self);
|
||||
|
||||
self->desc_class->finalize (self);
|
||||
|
||||
gsk_gpu_image_entries_clear (&priv->images);
|
||||
gsk_gpu_buffer_entries_clear (&priv->buffers);
|
||||
|
||||
g_free (priv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,23 +4,24 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GskGpuDescriptors GskGpuDescriptors;
|
||||
typedef struct _GskGpuDescriptorsClass GskGpuDescriptorsClass;
|
||||
typedef struct _GskGpuDescriptorsPrivate GskGpuDescriptorsPrivate;
|
||||
#define GSK_TYPE_GPU_DESCRIPTORS (gsk_gpu_descriptors_get_type ())
|
||||
#define GSK_GPU_DESCRIPTORS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSK_TYPE_GPU_DESCRIPTORS, GskGpuDescriptors))
|
||||
#define GSK_GPU_DESCRIPTORS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GSK_TYPE_GPU_DESCRIPTORS, GskGpuDescriptorsClass))
|
||||
#define GSK_IS_GPU_DESCRIPTORS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSK_TYPE_GPU_DESCRIPTORS))
|
||||
#define GSK_IS_GPU_DESCRIPTORS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSK_TYPE_GPU_DESCRIPTORS))
|
||||
#define GSK_GPU_DESCRIPTORS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSK_TYPE_GPU_DESCRIPTORS, GskGpuDescriptorsClass))
|
||||
|
||||
#define GSK_GPU_DESCRIPTORS(d) ((GskGpuDescriptors *) (d))
|
||||
typedef struct _GskGpuDescriptorsClass GskGpuDescriptorsClass;
|
||||
|
||||
struct _GskGpuDescriptors
|
||||
{
|
||||
GskGpuDescriptorsClass *desc_class;
|
||||
int ref_count;
|
||||
|
||||
GskGpuDescriptorsPrivate *priv;
|
||||
GObject parent_instance;
|
||||
};
|
||||
|
||||
struct _GskGpuDescriptorsClass
|
||||
{
|
||||
void (* finalize) (GskGpuDescriptors *self);
|
||||
GObjectClass parent_class;
|
||||
|
||||
gboolean (* add_image) (GskGpuDescriptors *self,
|
||||
GskGpuImage *image,
|
||||
GskGpuSampler sampler,
|
||||
@@ -30,8 +31,7 @@ struct _GskGpuDescriptorsClass
|
||||
guint32 *out_id);
|
||||
};
|
||||
|
||||
GskGpuDescriptors * gsk_gpu_descriptors_ref (GskGpuDescriptors *self);
|
||||
void gsk_gpu_descriptors_unref (GskGpuDescriptors *self);
|
||||
GType gsk_gpu_descriptors_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gsize gsk_gpu_descriptors_get_n_images (GskGpuDescriptors *self);
|
||||
gsize gsk_gpu_descriptors_get_n_buffers (GskGpuDescriptors *self);
|
||||
@@ -55,8 +55,7 @@ gboolean gsk_gpu_descriptors_add_buffer (GskGpuD
|
||||
GskGpuBuffer *buffer,
|
||||
guint32 *out_descriptor);
|
||||
|
||||
GskGpuDescriptors *gsk_gpu_descriptors_new (GskGpuDescriptorsClass *desc_class,
|
||||
gsize child_size);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GskGpuDescriptors, g_object_unref)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "gskdebugprivate.h"
|
||||
#include "gskpath.h"
|
||||
#include "gskrectprivate.h"
|
||||
#include "gskvec2private.h"
|
||||
#include "gskrendernodeprivate.h"
|
||||
#include "gskroundedrectprivate.h"
|
||||
#include "gskstrokeprivate.h"
|
||||
@@ -152,7 +153,7 @@ static void
|
||||
gsk_gpu_node_processor_finish (GskGpuNodeProcessor *self)
|
||||
{
|
||||
g_clear_pointer (&self->modelview, gsk_transform_unref);
|
||||
g_clear_pointer (&self->desc, gsk_gpu_descriptors_unref);
|
||||
g_clear_object (&self->desc);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -170,7 +171,7 @@ gsk_gpu_node_processor_init (GskGpuNodeProcessor *self,
|
||||
|
||||
self->frame = frame;
|
||||
if (desc)
|
||||
self->desc = gsk_gpu_descriptors_ref (desc);
|
||||
self->desc = g_object_ref (desc);
|
||||
else
|
||||
self->desc = NULL;
|
||||
|
||||
@@ -195,9 +196,9 @@ gsk_gpu_node_processor_init (GskGpuNodeProcessor *self,
|
||||
|
||||
self->modelview = NULL;
|
||||
gsk_gpu_image_get_projection_matrix (target, &self->projection);
|
||||
graphene_vec2_init (&self->scale,
|
||||
width / viewport->size.width,
|
||||
height / viewport->size.height);
|
||||
gsk_vec2_init (&self->scale,
|
||||
width / viewport->size.width,
|
||||
height / viewport->size.height);
|
||||
self->offset = GRAPHENE_POINT_INIT (-viewport->origin.x,
|
||||
-viewport->origin.y);
|
||||
self->opacity = 1.0;
|
||||
@@ -268,7 +269,7 @@ gsk_gpu_node_processor_add_image (GskGpuNodeProcessor *self,
|
||||
if (gsk_gpu_descriptors_add_image (self->desc, image, sampler, &descriptor))
|
||||
return descriptor;
|
||||
|
||||
gsk_gpu_descriptors_unref (self->desc);
|
||||
g_object_unref (self->desc);
|
||||
}
|
||||
|
||||
self->desc = gsk_gpu_frame_create_descriptors (self->frame);
|
||||
@@ -319,8 +320,8 @@ rect_round_to_pixels (const graphene_rect_t *src,
|
||||
{
|
||||
float x, y, xscale, yscale, inv_xscale, inv_yscale;
|
||||
|
||||
xscale = graphene_vec2_get_x (pixel_scale);
|
||||
yscale = graphene_vec2_get_y (pixel_scale);
|
||||
xscale = gsk_vec2_get_x (pixel_scale);
|
||||
yscale = gsk_vec2_get_y (pixel_scale);
|
||||
inv_xscale = 1.0f / xscale;
|
||||
inv_yscale = 1.0f / yscale;
|
||||
|
||||
@@ -345,8 +346,8 @@ gsk_gpu_node_processor_init_draw (GskGpuNodeProcessor *self,
|
||||
|
||||
area.x = 0;
|
||||
area.y = 0;
|
||||
area.width = ceilf (graphene_vec2_get_x (scale) * viewport->size.width - EPSILON);
|
||||
area.height = ceilf (graphene_vec2_get_y (scale) * viewport->size.height - EPSILON);
|
||||
area.width = ceilf (gsk_vec2_get_x (scale) * viewport->size.width - EPSILON);
|
||||
area.height = ceilf (gsk_vec2_get_y (scale) * viewport->size.height - EPSILON);
|
||||
|
||||
image = gsk_gpu_device_create_offscreen_image (gsk_gpu_frame_get_device (frame),
|
||||
FALSE,
|
||||
@@ -545,7 +546,7 @@ gsk_gpu_pattern_writer_finish (GskGpuPatternWriter *self)
|
||||
{
|
||||
pattern_buffer_clear (&self->buffer);
|
||||
g_assert (self->stack == 0);
|
||||
g_clear_pointer (&self->desc, gsk_gpu_descriptors_unref);
|
||||
g_clear_object (&self->desc);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -629,8 +630,8 @@ gsk_gpu_node_processor_rect_is_integer (GskGpuNodeProcessor *self,
|
||||
cairo_rectangle_int_t *int_rect)
|
||||
{
|
||||
graphene_rect_t transformed_rect;
|
||||
float scale_x = graphene_vec2_get_x (&self->scale);
|
||||
float scale_y = graphene_vec2_get_y (&self->scale);
|
||||
float scale_x = gsk_vec2_get_x (&self->scale);
|
||||
float scale_y = gsk_vec2_get_y (&self->scale);
|
||||
|
||||
switch (gsk_transform_get_category (self->modelview))
|
||||
{
|
||||
@@ -1030,7 +1031,7 @@ gsk_gpu_node_processor_blur_op (GskGpuNodeProcessor *self,
|
||||
|
||||
gsk_gpu_node_processor_sync_globals (&other, 0);
|
||||
|
||||
graphene_vec2_init (&direction, blur_radius, 0.0f);
|
||||
gsk_vec2_init (&direction, blur_radius, 0.0f);
|
||||
gsk_gpu_blur_op (other.frame,
|
||||
gsk_gpu_clip_get_shader_clip (&other.clip, &other.offset, &intermediate_rect),
|
||||
source_desc,
|
||||
@@ -1044,7 +1045,7 @@ gsk_gpu_node_processor_blur_op (GskGpuNodeProcessor *self,
|
||||
|
||||
real_offset = GRAPHENE_POINT_INIT (self->offset.x + shadow_offset->x,
|
||||
self->offset.y + shadow_offset->y);
|
||||
graphene_vec2_init (&direction, 0.0f, blur_radius);
|
||||
gsk_vec2_init (&direction, 0.0f, blur_radius);
|
||||
intermediate_descriptor = gsk_gpu_node_processor_add_image (self, intermediate, GSK_GPU_SAMPLER_TRANSPARENT);
|
||||
if (shadow_color)
|
||||
{
|
||||
@@ -1581,8 +1582,8 @@ gsk_gpu_node_processor_add_transform_node (GskGpuNodeProcessor *self,
|
||||
gsk_gpu_clip_scale (&self->clip, &old_clip, scale_x, scale_y);
|
||||
self->offset.x = (self->offset.x + dx) / scale_x;
|
||||
self->offset.y = (self->offset.y + dy) / scale_y;
|
||||
graphene_vec2_init (&self->scale, fabs (scale_x), fabs (scale_y));
|
||||
graphene_vec2_multiply (&self->scale, &old_scale, &self->scale);
|
||||
gsk_vec2_init (&self->scale, fabs (scale_x), fabs (scale_y));
|
||||
gsk_vec2_multiply (&self->scale, &old_scale, &self->scale);
|
||||
self->modelview = gsk_transform_scale (self->modelview,
|
||||
scale_x / fabs (scale_x),
|
||||
scale_y / fabs (scale_y));
|
||||
@@ -1642,15 +1643,15 @@ gsk_gpu_node_processor_add_transform_node (GskGpuNodeProcessor *self,
|
||||
old_modelview = gsk_transform_ref (self->modelview);
|
||||
|
||||
self->modelview = gsk_transform_scale (self->modelview,
|
||||
graphene_vec2_get_x (&self->scale),
|
||||
graphene_vec2_get_y (&self->scale));
|
||||
gsk_vec2_get_x (&self->scale),
|
||||
gsk_vec2_get_y (&self->scale));
|
||||
self->modelview = gsk_transform_transform (self->modelview, clip_transform);
|
||||
gsk_transform_unref (clip_transform);
|
||||
|
||||
extract_scale_from_transform (self->modelview, &scale_x, &scale_y);
|
||||
|
||||
old_pixels = MAX (graphene_vec2_get_x (&old_scale) * old_clip.rect.bounds.size.width,
|
||||
graphene_vec2_get_y (&old_scale) * old_clip.rect.bounds.size.height);
|
||||
old_pixels = MAX (gsk_vec2_get_x (&old_scale) * old_clip.rect.bounds.size.width,
|
||||
gsk_vec2_get_y (&old_scale) * old_clip.rect.bounds.size.height);
|
||||
new_pixels = MAX (scale_x * self->clip.rect.bounds.size.width,
|
||||
scale_y * self->clip.rect.bounds.size.height);
|
||||
|
||||
@@ -1663,7 +1664,7 @@ gsk_gpu_node_processor_add_transform_node (GskGpuNodeProcessor *self,
|
||||
}
|
||||
|
||||
self->modelview = gsk_transform_scale (self->modelview, 1 / scale_x, 1 / scale_y);
|
||||
graphene_vec2_init (&self->scale, scale_x, scale_y);
|
||||
gsk_vec2_init (&self->scale, scale_x, scale_y);
|
||||
self->offset = *graphene_point_zero ();
|
||||
}
|
||||
break;
|
||||
@@ -1735,8 +1736,8 @@ gsk_gpu_node_processor_create_transform_pattern (GskGpuPatternWriter *self,
|
||||
self->bounds.size.width *= inv_sx;
|
||||
self->bounds.size.height *= inv_sy;
|
||||
self->offset = GRAPHENE_POINT_INIT (0, 0);
|
||||
graphene_vec2_init (&self->scale, fabs (sx), fabs (sy));
|
||||
graphene_vec2_multiply (&self->scale, &old_scale, &self->scale);
|
||||
gsk_vec2_init (&self->scale, fabs (sx), fabs (sy));
|
||||
gsk_vec2_multiply (&self->scale, &old_scale, &self->scale);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1820,8 +1821,8 @@ gsk_gpu_node_processor_add_color_node (GskGpuNodeProcessor *self,
|
||||
return;
|
||||
}
|
||||
|
||||
scale_x = graphene_vec2_get_x (&self->scale);
|
||||
scale_y = graphene_vec2_get_y (&self->scale);
|
||||
scale_x = gsk_vec2_get_x (&self->scale);
|
||||
scale_y = gsk_vec2_get_y (&self->scale);
|
||||
clipped = GRAPHENE_RECT_INIT (int_clipped.x / scale_x, int_clipped.y / scale_y,
|
||||
int_clipped.width / scale_x, int_clipped.height / scale_y);
|
||||
shader_clip = gsk_gpu_clip_get_shader_clip (&self->clip, graphene_point_zero(), &clipped);
|
||||
@@ -1948,8 +1949,8 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self,
|
||||
}
|
||||
|
||||
if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_MIPMAP) &&
|
||||
(gdk_texture_get_width (texture) > 2 * node->bounds.size.width * graphene_vec2_get_x (&self->scale) ||
|
||||
gdk_texture_get_height (texture) > 2 * node->bounds.size.height * graphene_vec2_get_y (&self->scale)))
|
||||
(gdk_texture_get_width (texture) > 2 * node->bounds.size.width * gsk_vec2_get_x (&self->scale) ||
|
||||
gdk_texture_get_height (texture) > 2 * node->bounds.size.height * gsk_vec2_get_y (&self->scale)))
|
||||
{
|
||||
guint32 descriptor;
|
||||
|
||||
@@ -2015,8 +2016,8 @@ gsk_gpu_node_processor_create_texture_pattern (GskGpuPatternWriter *self,
|
||||
}
|
||||
|
||||
if (gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_MIPMAP) &&
|
||||
(gdk_texture_get_width (texture) > 2 * node->bounds.size.width * graphene_vec2_get_x (&self->scale) ||
|
||||
gdk_texture_get_height (texture) > 2 * node->bounds.size.height * graphene_vec2_get_y (&self->scale)))
|
||||
(gdk_texture_get_width (texture) > 2 * node->bounds.size.width * gsk_vec2_get_x (&self->scale) ||
|
||||
gdk_texture_get_height (texture) > 2 * node->bounds.size.height * gsk_vec2_get_y (&self->scale)))
|
||||
{
|
||||
image = gsk_gpu_node_processor_ensure_image (self->frame,
|
||||
image,
|
||||
@@ -2060,7 +2061,7 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self,
|
||||
gboolean need_mipmap, need_offscreen;
|
||||
|
||||
need_offscreen = self->modelview != NULL ||
|
||||
!graphene_vec2_equal (&self->scale, graphene_vec2_one ());
|
||||
gsk_vec2_equal (&self->scale, graphene_vec2_one ());
|
||||
if (need_offscreen)
|
||||
{
|
||||
GskGpuImage *offscreen;
|
||||
@@ -3000,12 +3001,8 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
|
||||
guint i, num_glyphs;
|
||||
float scale, inv_scale;
|
||||
GdkRGBA color;
|
||||
float align_scale_x, align_scale_y;
|
||||
float inv_align_scale_x, inv_align_scale_y;
|
||||
unsigned int flags_mask;
|
||||
GskGpuImage *last_image;
|
||||
guint32 descriptor;
|
||||
const float inv_pango_scale = 1.f / PANGO_SCALE;
|
||||
gboolean glyph_align;
|
||||
gboolean hinting;
|
||||
|
||||
if (self->opacity < 1.0 &&
|
||||
gsk_text_node_has_color_glyphs (node))
|
||||
@@ -3025,41 +3022,48 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
|
||||
offset.x += self->offset.x;
|
||||
offset.y += self->offset.y;
|
||||
|
||||
scale = MAX (graphene_vec2_get_x (&self->scale), graphene_vec2_get_y (&self->scale));
|
||||
scale = MAX (gsk_vec2_get_x (&self->scale), gsk_vec2_get_y (&self->scale));
|
||||
inv_scale = 1.f / scale;
|
||||
|
||||
if (gsk_font_get_hint_style (font) != CAIRO_HINT_STYLE_NONE)
|
||||
{
|
||||
align_scale_x = scale * 4;
|
||||
align_scale_y = scale;
|
||||
flags_mask = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
align_scale_x = align_scale_y = scale * 4;
|
||||
flags_mask = 15;
|
||||
}
|
||||
glyph_align = gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_GLYPH_ALIGN);
|
||||
hinting = gsk_font_get_hint_style (font) != CAIRO_HINT_STYLE_NONE;
|
||||
|
||||
inv_align_scale_x = 1 / align_scale_x;
|
||||
inv_align_scale_y = 1 / align_scale_y;
|
||||
|
||||
last_image = NULL;
|
||||
descriptor = 0;
|
||||
for (i = 0; i < num_glyphs; i++)
|
||||
{
|
||||
GskGpuImage *image;
|
||||
graphene_rect_t glyph_bounds, glyph_tex_rect;
|
||||
graphene_point_t glyph_offset, glyph_origin;
|
||||
guint32 descriptor;
|
||||
GskGpuGlyphLookupFlags flags;
|
||||
|
||||
glyph_origin = GRAPHENE_POINT_INIT (offset.x + glyphs[i].geometry.x_offset * inv_pango_scale,
|
||||
offset.y + glyphs[i].geometry.y_offset * inv_pango_scale);
|
||||
glyph_origin = GRAPHENE_POINT_INIT (offset.x + (float) glyphs[i].geometry.x_offset / PANGO_SCALE,
|
||||
offset.y + (float) glyphs[i].geometry.y_offset / PANGO_SCALE);
|
||||
|
||||
glyph_origin.x = floorf (glyph_origin.x * align_scale_x + 0.5f);
|
||||
glyph_origin.y = floorf (glyph_origin.y * align_scale_y + 0.5f);
|
||||
flags = (((int) glyph_origin.x & 3) | (((int) glyph_origin.y & 3) << 2)) & flags_mask;
|
||||
glyph_origin.x *= inv_align_scale_x;
|
||||
glyph_origin.y *= inv_align_scale_y;
|
||||
if (hinting && glyph_align)
|
||||
{
|
||||
/* Force glyph_origin.y to be device pixel aligned.
|
||||
* The hinter expects that.
|
||||
*/
|
||||
glyph_origin.x = floor (glyph_origin.x * scale * 4 + .5);
|
||||
flags = ((int) glyph_origin.x & 3);
|
||||
glyph_origin.x = 0.25 * inv_scale * glyph_origin.x;
|
||||
glyph_origin.y = floor (glyph_origin.y * scale + .5) * inv_scale;
|
||||
}
|
||||
else if (glyph_align)
|
||||
{
|
||||
glyph_origin.x = floor (glyph_origin.x * scale * 4 + .5);
|
||||
glyph_origin.y = floor (glyph_origin.y * scale * 4 + .5);
|
||||
flags = ((int) glyph_origin.x & 3) |
|
||||
(((int) glyph_origin.y & 3) << 2);
|
||||
glyph_origin.x = 0.25 * inv_scale * glyph_origin.x;
|
||||
glyph_origin.y = 0.25 * inv_scale * glyph_origin.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
glyph_origin.x = floor (glyph_origin.x * scale + .5) * inv_scale;
|
||||
glyph_origin.y = floor (glyph_origin.y * scale + .5) * inv_scale;
|
||||
flags = 0;
|
||||
}
|
||||
|
||||
image = gsk_gpu_device_lookup_glyph_image (device,
|
||||
self->frame,
|
||||
@@ -3081,11 +3085,7 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
|
||||
glyph_origin = GRAPHENE_POINT_INIT (glyph_origin.x - glyph_offset.x * inv_scale,
|
||||
glyph_origin.y - glyph_offset.y * inv_scale);
|
||||
|
||||
if (image != last_image)
|
||||
{
|
||||
descriptor = gsk_gpu_node_processor_add_image (self, image, GSK_GPU_SAMPLER_DEFAULT);
|
||||
last_image = image;
|
||||
}
|
||||
descriptor = gsk_gpu_node_processor_add_image (self, image, GSK_GPU_SAMPLER_DEFAULT);
|
||||
|
||||
if (glyphs[i].attr.is_color)
|
||||
gsk_gpu_texture_op (self->frame,
|
||||
@@ -3105,7 +3105,7 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
|
||||
&glyph_tex_rect,
|
||||
&color);
|
||||
|
||||
offset.x += glyphs[i].geometry.width * inv_pango_scale;
|
||||
offset.x += (float) glyphs[i].geometry.width / PANGO_SCALE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3122,10 +3122,8 @@ gsk_gpu_node_processor_create_glyph_pattern (GskGpuPatternWriter *self,
|
||||
guint32 tex_id;
|
||||
GskGpuImage *last_image;
|
||||
graphene_point_t offset;
|
||||
float align_scale_x, align_scale_y;
|
||||
float inv_align_scale_x, inv_align_scale_y;
|
||||
unsigned int flags_mask;
|
||||
const float inv_pango_scale = 1.f / PANGO_SCALE;
|
||||
gboolean glyph_align;
|
||||
gboolean hinting;
|
||||
|
||||
if (gsk_text_node_has_color_glyphs (node))
|
||||
return FALSE;
|
||||
@@ -3138,27 +3136,15 @@ gsk_gpu_node_processor_create_glyph_pattern (GskGpuPatternWriter *self,
|
||||
offset.x += self->offset.x;
|
||||
offset.y += self->offset.y;
|
||||
|
||||
scale = MAX (graphene_vec2_get_x (&self->scale), graphene_vec2_get_y (&self->scale));
|
||||
scale = MAX (gsk_vec2_get_x (&self->scale), gsk_vec2_get_y (&self->scale));
|
||||
inv_scale = 1.f / scale;
|
||||
|
||||
gsk_gpu_pattern_writer_append_uint (self, GSK_GPU_PATTERN_GLYPHS);
|
||||
gsk_gpu_pattern_writer_append_rgba (self, gsk_text_node_get_color (node));
|
||||
gsk_gpu_pattern_writer_append_uint (self, num_glyphs);
|
||||
|
||||
if (gsk_font_get_hint_style (font) != CAIRO_HINT_STYLE_NONE)
|
||||
{
|
||||
align_scale_x = scale * 4;
|
||||
align_scale_y = scale;
|
||||
flags_mask = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
align_scale_x = align_scale_y = scale * 4;
|
||||
flags_mask = 15;
|
||||
}
|
||||
|
||||
inv_align_scale_x = 1 / align_scale_x;
|
||||
inv_align_scale_y = 1 / align_scale_y;
|
||||
glyph_align = gsk_gpu_frame_should_optimize (self->frame, GSK_GPU_OPTIMIZE_GLYPH_ALIGN);
|
||||
hinting = gsk_font_get_hint_style (font) != CAIRO_HINT_STYLE_NONE;
|
||||
|
||||
last_image = NULL;
|
||||
for (i = 0; i < num_glyphs; i++)
|
||||
@@ -3168,14 +3154,34 @@ gsk_gpu_node_processor_create_glyph_pattern (GskGpuPatternWriter *self,
|
||||
graphene_point_t glyph_offset, glyph_origin;
|
||||
GskGpuGlyphLookupFlags flags;
|
||||
|
||||
glyph_origin = GRAPHENE_POINT_INIT (offset.x + glyphs[i].geometry.x_offset * inv_pango_scale,
|
||||
offset.y + glyphs[i].geometry.y_offset * inv_pango_scale);
|
||||
glyph_origin = GRAPHENE_POINT_INIT (offset.x + (float) glyphs[i].geometry.x_offset / PANGO_SCALE,
|
||||
offset.y + (float) glyphs[i].geometry.y_offset / PANGO_SCALE);
|
||||
|
||||
glyph_origin.x = floorf (glyph_origin.x * align_scale_x + 0.5f);
|
||||
glyph_origin.y = floorf (glyph_origin.y * align_scale_y + 0.5f);
|
||||
flags = (((int) glyph_origin.x & 3) | (((int) glyph_origin.y & 3) << 2)) & flags_mask;
|
||||
glyph_origin.x *= inv_align_scale_x;
|
||||
glyph_origin.y *= inv_align_scale_y;
|
||||
if (hinting && glyph_align)
|
||||
{
|
||||
/* Force glyph_origin.y to be device pixel aligned.
|
||||
* The hinter expects that.
|
||||
*/
|
||||
glyph_origin.x = roundf (glyph_origin.x * scale * 4);
|
||||
flags = ((int) glyph_origin.x & 3);
|
||||
glyph_origin.x = 0.25 * inv_scale * glyph_origin.x;
|
||||
glyph_origin.y = roundf (glyph_origin.y * scale) * inv_scale;
|
||||
}
|
||||
else if (glyph_align)
|
||||
{
|
||||
glyph_origin.x = roundf (glyph_origin.x * scale * 4);
|
||||
glyph_origin.y = roundf (glyph_origin.y * scale * 4);
|
||||
flags = ((int) glyph_origin.x & 3) |
|
||||
(((int) glyph_origin.y & 3) << 2);
|
||||
glyph_origin.x = 0.25 * inv_scale * glyph_origin.x;
|
||||
glyph_origin.y = 0.25 * inv_scale * glyph_origin.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
glyph_origin.x = roundf (glyph_origin.x * scale) * inv_scale;
|
||||
glyph_origin.y = roundf (glyph_origin.y * scale) * inv_scale;
|
||||
flags = 0;
|
||||
}
|
||||
|
||||
image = gsk_gpu_device_lookup_glyph_image (device,
|
||||
self->frame,
|
||||
@@ -3215,7 +3221,7 @@ gsk_gpu_node_processor_create_glyph_pattern (GskGpuPatternWriter *self,
|
||||
),
|
||||
&glyph_origin);
|
||||
|
||||
offset.x += glyphs[i].geometry.width * inv_pango_scale;
|
||||
offset.x += (float) glyphs[i].geometry.width / PANGO_SCALE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -30,6 +30,7 @@ static const GdkDebugKey gsk_gpu_optimization_keys[] = {
|
||||
{ "blit", GSK_GPU_OPTIMIZE_BLIT, "Use shaders instead of vkCmdBlit()/glBlitFramebuffer()" },
|
||||
{ "gradients", GSK_GPU_OPTIMIZE_GRADIENTS, "Don't supersample gradients" },
|
||||
{ "mipmap", GSK_GPU_OPTIMIZE_MIPMAP, "Avoid creating mipmaps" },
|
||||
{ "glyph-align", GSK_GPU_OPTIMIZE_GLYPH_ALIGN, "Never align glyphs to the subpixel grid" },
|
||||
|
||||
{ "gl-baseinstance", GSK_GPU_OPTIMIZE_GL_BASE_INSTANCE, "Assume no ARB/EXT_base_instance support" },
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@ gsk_gpu_shader_op_finish (GskGpuOp *op)
|
||||
{
|
||||
GskGpuShaderOp *self = (GskGpuShaderOp *) op;
|
||||
|
||||
g_clear_pointer (&self->desc, gsk_gpu_descriptors_unref);
|
||||
g_clear_object (&self->desc);
|
||||
}
|
||||
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
@@ -197,7 +197,7 @@ gsk_gpu_shader_op_alloc (GskGpuFrame *frame,
|
||||
self->variation = variation;
|
||||
self->clip = clip;
|
||||
if (desc)
|
||||
self->desc = gsk_gpu_descriptors_ref (desc);
|
||||
self->desc = g_object_ref (desc);
|
||||
else
|
||||
self->desc = NULL;
|
||||
self->vertex_offset = gsk_gpu_frame_reserve_vertex_data (frame, op_class->vertex_size);
|
||||
|
||||
@@ -118,7 +118,8 @@ typedef enum {
|
||||
GSK_GPU_OPTIMIZE_BLIT = 1 << 3,
|
||||
GSK_GPU_OPTIMIZE_GRADIENTS = 1 << 4,
|
||||
GSK_GPU_OPTIMIZE_MIPMAP = 1 << 5,
|
||||
GSK_GPU_OPTIMIZE_GLYPH_ALIGN = 1 << 6,
|
||||
/* These require hardware support */
|
||||
GSK_GPU_OPTIMIZE_GL_BASE_INSTANCE = 1 << 6,
|
||||
GSK_GPU_OPTIMIZE_GL_BASE_INSTANCE = 1 << 7,
|
||||
} GskGpuOptimizations;
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "gdk/gdkglcontextprivate.h"
|
||||
#include "gsk/gskdebugprivate.h"
|
||||
#include "gskvec2private.h"
|
||||
|
||||
static GskGpuOp *
|
||||
gsk_gpu_upload_op_gl_command_with_area (GskGpuOp *op,
|
||||
@@ -465,8 +466,8 @@ gsk_gpu_upload_cairo_op (GskGpuFrame *frame,
|
||||
self->image = gsk_gpu_device_create_upload_image (gsk_gpu_frame_get_device (frame),
|
||||
FALSE,
|
||||
GDK_MEMORY_DEFAULT,
|
||||
ceil (graphene_vec2_get_x (scale) * viewport->size.width),
|
||||
ceil (graphene_vec2_get_y (scale) * viewport->size.height));
|
||||
ceil (gsk_vec2_get_x (scale) * viewport->size.width),
|
||||
ceil (gsk_vec2_get_y (scale) * viewport->size.height));
|
||||
self->viewport = *viewport;
|
||||
self->func = func;
|
||||
self->user_data = user_data;
|
||||
|
||||
@@ -6,13 +6,22 @@
|
||||
#include "gskvulkanframeprivate.h"
|
||||
#include "gskvulkanimageprivate.h"
|
||||
|
||||
G_DEFINE_TYPE (GskVulkanDescriptors, gsk_vulkan_descriptors, GSK_TYPE_GPU_DESCRIPTORS)
|
||||
|
||||
static void
|
||||
gsk_vulkan_descriptors_class_init (GskVulkanDescriptorsClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_descriptors_init (GskVulkanDescriptors *self)
|
||||
{
|
||||
}
|
||||
|
||||
GskVulkanPipelineLayout *
|
||||
gsk_vulkan_descriptors_get_pipeline_layout (GskVulkanDescriptors *self)
|
||||
{
|
||||
GskGpuDescriptors *desc = GSK_GPU_DESCRIPTORS (self);
|
||||
GskVulkanDescriptorsClass *class = GSK_VULKAN_DESCRIPTORS_CLASS (desc->desc_class);
|
||||
|
||||
return class->get_pipeline_layout (self);
|
||||
return GSK_VULKAN_DESCRIPTORS_GET_CLASS (self)->get_pipeline_layout (self);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -39,19 +48,5 @@ gsk_vulkan_descriptors_bind (GskVulkanDescriptors *self,
|
||||
GskVulkanDescriptors *previous,
|
||||
VkCommandBuffer vk_command_buffer)
|
||||
{
|
||||
GskGpuDescriptors *desc = GSK_GPU_DESCRIPTORS (self);
|
||||
GskVulkanDescriptorsClass *class = GSK_VULKAN_DESCRIPTORS_CLASS (desc->desc_class);
|
||||
|
||||
return class->bind (self, previous, vk_command_buffer);
|
||||
}
|
||||
|
||||
GskVulkanDescriptors *
|
||||
gsk_vulkan_descriptors_new (GskVulkanDescriptorsClass *desc_class,
|
||||
gsize child_size)
|
||||
{
|
||||
GskGpuDescriptors *desc;
|
||||
|
||||
desc = gsk_gpu_descriptors_new ((GskGpuDescriptorsClass *)desc_class, child_size);
|
||||
|
||||
return GSK_VULKAN_DESCRIPTORS (desc);
|
||||
return GSK_VULKAN_DESCRIPTORS_GET_CLASS (self)->bind (self, previous, vk_command_buffer);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,14 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GskVulkanDescriptors GskVulkanDescriptors;
|
||||
typedef struct _GskVulkanDescriptorsClass GskVulkanDescriptorsClass;
|
||||
#define GSK_TYPE_VULKAN_DESCRIPTORS (gsk_vulkan_descriptors_get_type ())
|
||||
#define GSK_VULKAN_DESCRIPTORS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSK_TYPE_VULKAN_DESCRIPTORS, GskVulkanDescriptors))
|
||||
#define GSK_VULKAN_DESCRIPTORS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GSK_TYPE_VULKAN_DESCRIPTORS, GskVulkanDescriptorsClass))
|
||||
#define GSK_IS_VULKAN_DESCRIPTORS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSK_TYPE_VULKAN_DESCRIPTORS))
|
||||
#define GSK_IS_VULKAN_DESCRIPTORS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSK_TYPE_VULKAN_DESCRIPTORS))
|
||||
#define GSK_VULKAN_DESCRIPTORS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSK_TYPE_VULKAN_DESCRIPTORS, GskVulkanDescriptorsClass))
|
||||
|
||||
#define GSK_VULKAN_DESCRIPTORS(d) ((GskVulkanDescriptors *) (d))
|
||||
#define GSK_VULKAN_DESCRIPTORS_CLASS(d) ((GskVulkanDescriptorsClass *) (d))
|
||||
typedef struct _GskVulkanDescriptorsClass GskVulkanDescriptorsClass;
|
||||
|
||||
struct _GskVulkanDescriptors
|
||||
{
|
||||
@@ -27,6 +30,8 @@ struct _GskVulkanDescriptorsClass
|
||||
VkCommandBuffer vk_command_buffer);
|
||||
};
|
||||
|
||||
GType gsk_vulkan_descriptors_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GskVulkanPipelineLayout * gsk_vulkan_descriptors_get_pipeline_layout (GskVulkanDescriptors *self);
|
||||
|
||||
void gsk_vulkan_descriptors_transition (GskVulkanDescriptors *self,
|
||||
@@ -36,9 +41,7 @@ void gsk_vulkan_descriptors_bind
|
||||
GskVulkanDescriptors *previous,
|
||||
VkCommandBuffer vk_command_buffer);
|
||||
|
||||
GskVulkanDescriptors * gsk_vulkan_descriptors_new (GskVulkanDescriptorsClass *desc_class,
|
||||
gsize child_size);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GskVulkanDescriptors, g_object_unref)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -13,16 +13,10 @@
|
||||
#include "gdk/gdkdisplayprivate.h"
|
||||
#include "gdk/gdkdmabuftextureprivate.h"
|
||||
|
||||
static inline void
|
||||
gsk_vulkan_real_descriptors_unref (GskVulkanRealDescriptors *desc)
|
||||
{
|
||||
gsk_gpu_descriptors_unref (GSK_GPU_DESCRIPTORS (desc));
|
||||
}
|
||||
|
||||
#define GDK_ARRAY_NAME gsk_descriptors
|
||||
#define GDK_ARRAY_TYPE_NAME GskDescriptors
|
||||
#define GDK_ARRAY_ELEMENT_TYPE GskVulkanRealDescriptors *
|
||||
#define GDK_ARRAY_FREE_FUNC gsk_vulkan_real_descriptors_unref
|
||||
#define GDK_ARRAY_FREE_FUNC g_object_unref
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
|
||||
@@ -268,7 +262,7 @@ gsk_vulkan_frame_create_descriptors (GskGpuFrame *frame)
|
||||
desc = gsk_vulkan_real_descriptors_new (self);
|
||||
gsk_descriptors_append (&self->descriptors, desc);
|
||||
|
||||
return gsk_gpu_descriptors_ref (GSK_GPU_DESCRIPTORS (desc));
|
||||
return GSK_GPU_DESCRIPTORS (g_object_ref (desc));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
#include "gskvulkanrealdescriptorsprivate.h"
|
||||
|
||||
#include "gskvulkanbufferprivate.h"
|
||||
#include "gskvulkanframeprivate.h"
|
||||
#include "gskvulkanimageprivate.h"
|
||||
|
||||
#define GDK_ARRAY_NAME gsk_descriptor_image_infos
|
||||
#define GDK_ARRAY_TYPE_NAME GskDescriptorImageInfos
|
||||
#define GDK_ARRAY_ELEMENT_TYPE VkDescriptorImageInfo
|
||||
@@ -41,6 +45,8 @@ struct _GskVulkanRealDescriptors
|
||||
VkDescriptorSet descriptor_sets[GSK_VULKAN_N_DESCRIPTOR_SETS];
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskVulkanRealDescriptors, gsk_vulkan_real_descriptors, GSK_TYPE_VULKAN_DESCRIPTORS)
|
||||
|
||||
static GskVulkanPipelineLayout *
|
||||
gsk_vulkan_real_descriptors_get_pipeline_layout (GskVulkanDescriptors *desc)
|
||||
{
|
||||
@@ -148,9 +154,9 @@ gsk_vulkan_real_descriptors_add_buffer (GskGpuDescriptors *desc,
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_real_descriptors_finalize (GskGpuDescriptors *desc)
|
||||
gsk_vulkan_real_descriptors_finalize (GObject *object)
|
||||
{
|
||||
GskVulkanRealDescriptors *self = GSK_VULKAN_REAL_DESCRIPTORS (desc);
|
||||
GskVulkanRealDescriptors *self = GSK_VULKAN_REAL_DESCRIPTORS (object);
|
||||
|
||||
gsk_samplers_clear (&self->immutable_samplers);
|
||||
gsk_descriptor_image_infos_clear (&self->descriptor_immutable_images);
|
||||
@@ -159,18 +165,25 @@ gsk_vulkan_real_descriptors_finalize (GskGpuDescriptors *desc)
|
||||
|
||||
gsk_vulkan_device_release_pipeline_layout (GSK_VULKAN_DEVICE (gsk_gpu_frame_get_device (GSK_GPU_FRAME (self->frame))),
|
||||
self->pipeline_layout);
|
||||
|
||||
G_OBJECT_CLASS (gsk_vulkan_real_descriptors_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static GskVulkanDescriptorsClass GSK_VULKAN_REAL_DESCRIPTORS_CLASS =
|
||||
static void
|
||||
gsk_vulkan_real_descriptors_class_init (GskVulkanRealDescriptorsClass *klass)
|
||||
{
|
||||
.parent_class = (GskGpuDescriptorsClass) {
|
||||
.finalize = gsk_vulkan_real_descriptors_finalize,
|
||||
.add_image = gsk_vulkan_real_descriptors_add_image,
|
||||
.add_buffer = gsk_vulkan_real_descriptors_add_buffer,
|
||||
},
|
||||
.get_pipeline_layout = gsk_vulkan_real_descriptors_get_pipeline_layout,
|
||||
.bind = gsk_vulkan_real_descriptors_bind
|
||||
};
|
||||
GskVulkanDescriptorsClass *vulkan_descriptors_class = GSK_VULKAN_DESCRIPTORS_CLASS (klass);
|
||||
GskGpuDescriptorsClass *descriptors_class = GSK_GPU_DESCRIPTORS_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gsk_vulkan_real_descriptors_finalize;
|
||||
|
||||
descriptors_class->add_image = gsk_vulkan_real_descriptors_add_image;
|
||||
descriptors_class->add_buffer = gsk_vulkan_real_descriptors_add_buffer;
|
||||
|
||||
vulkan_descriptors_class->get_pipeline_layout = gsk_vulkan_real_descriptors_get_pipeline_layout;
|
||||
vulkan_descriptors_class->bind = gsk_vulkan_real_descriptors_bind;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_real_descriptors_init (GskVulkanRealDescriptors *self)
|
||||
@@ -185,14 +198,9 @@ GskVulkanRealDescriptors *
|
||||
gsk_vulkan_real_descriptors_new (GskVulkanFrame *frame)
|
||||
{
|
||||
GskVulkanRealDescriptors *self;
|
||||
GskVulkanDescriptors *desc;
|
||||
|
||||
desc = gsk_vulkan_descriptors_new (&GSK_VULKAN_REAL_DESCRIPTORS_CLASS,
|
||||
sizeof (GskVulkanRealDescriptors));
|
||||
self = g_object_new (GSK_TYPE_VULKAN_REAL_DESCRIPTORS, NULL);
|
||||
|
||||
self = GSK_VULKAN_REAL_DESCRIPTORS (desc);
|
||||
|
||||
gsk_vulkan_real_descriptors_init (self);
|
||||
self->frame = frame;
|
||||
|
||||
return self;
|
||||
|
||||
@@ -3,17 +3,11 @@
|
||||
#include "gskvulkandescriptorsprivate.h"
|
||||
#include "gskvulkanframeprivate.h"
|
||||
|
||||
#include "gskvulkanbufferprivate.h"
|
||||
#include "gskvulkanframeprivate.h"
|
||||
#include "gskvulkanimageprivate.h"
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GskVulkanRealDescriptors GskVulkanRealDescriptors;
|
||||
|
||||
#define GSK_VULKAN_REAL_DESCRIPTORS(d) ((GskVulkanRealDescriptors *) (d))
|
||||
#define GSK_TYPE_VULKAN_REAL_DESCRIPTORS (gsk_vulkan_real_descriptors_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskVulkanRealDescriptors, gsk_vulkan_real_descriptors, GSK, VULKAN_REAL_DESCRIPTORS, GskVulkanDescriptors)
|
||||
|
||||
GskVulkanRealDescriptors * gsk_vulkan_real_descriptors_new (GskVulkanFrame *frame);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "gskvulkansubdescriptorsprivate.h"
|
||||
|
||||
|
||||
struct _GskVulkanSubDescriptors
|
||||
{
|
||||
GskVulkanDescriptors parent_instance;
|
||||
@@ -10,31 +9,7 @@ struct _GskVulkanSubDescriptors
|
||||
GskVulkanDescriptors *parent;
|
||||
};
|
||||
|
||||
|
||||
static void gsk_vulkan_sub_descriptors_finalize (GskGpuDescriptors *desc);
|
||||
static gboolean gsk_vulkan_sub_descriptors_add_buffer (GskGpuDescriptors *desc,
|
||||
GskGpuBuffer *buffer,
|
||||
guint32 *out_descriptor);
|
||||
static gboolean gsk_vulkan_sub_descriptors_add_image (GskGpuDescriptors *desc,
|
||||
GskGpuImage *image,
|
||||
GskGpuSampler sampler,
|
||||
guint32 *out_descriptor);
|
||||
static GskVulkanPipelineLayout *
|
||||
gsk_vulkan_sub_descriptors_get_pipeline_layout (GskVulkanDescriptors *desc);
|
||||
static void gsk_vulkan_sub_descriptors_bind (GskVulkanDescriptors *desc,
|
||||
GskVulkanDescriptors *previous,
|
||||
VkCommandBuffer vk_command_buffer);
|
||||
|
||||
static GskVulkanDescriptorsClass GSK_VULKAN_SUB_DESCRIPTORS_CLASS =
|
||||
{
|
||||
.parent_class = (GskGpuDescriptorsClass) {
|
||||
.finalize = gsk_vulkan_sub_descriptors_finalize,
|
||||
.add_image = gsk_vulkan_sub_descriptors_add_image,
|
||||
.add_buffer = gsk_vulkan_sub_descriptors_add_buffer,
|
||||
},
|
||||
.get_pipeline_layout = gsk_vulkan_sub_descriptors_get_pipeline_layout,
|
||||
.bind = gsk_vulkan_sub_descriptors_bind,
|
||||
};
|
||||
G_DEFINE_TYPE (GskVulkanSubDescriptors, gsk_vulkan_sub_descriptors, GSK_TYPE_VULKAN_DESCRIPTORS)
|
||||
|
||||
static GskVulkanPipelineLayout *
|
||||
gsk_vulkan_sub_descriptors_get_pipeline_layout (GskVulkanDescriptors *desc)
|
||||
@@ -51,7 +26,7 @@ gsk_vulkan_sub_descriptors_bind (GskVulkanDescriptors *desc,
|
||||
{
|
||||
GskVulkanSubDescriptors *self = GSK_VULKAN_SUB_DESCRIPTORS (desc);
|
||||
|
||||
if (GSK_GPU_DESCRIPTORS (previous)->desc_class == (GskGpuDescriptorsClass *) &GSK_VULKAN_SUB_DESCRIPTORS_CLASS)
|
||||
if (GSK_IS_VULKAN_SUB_DESCRIPTORS (previous))
|
||||
previous = GSK_VULKAN_SUB_DESCRIPTORS (previous)->parent;
|
||||
|
||||
if (self->parent == previous)
|
||||
@@ -87,24 +62,45 @@ gsk_vulkan_sub_descriptors_add_buffer (GskGpuDescriptors *desc,
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_sub_descriptors_finalize (GskGpuDescriptors *desc)
|
||||
gsk_vulkan_sub_descriptors_finalize (GObject *object)
|
||||
{
|
||||
GskVulkanSubDescriptors *self = GSK_VULKAN_SUB_DESCRIPTORS (desc);
|
||||
GskVulkanSubDescriptors *self = GSK_VULKAN_SUB_DESCRIPTORS (object);
|
||||
|
||||
gsk_gpu_descriptors_unref (GSK_GPU_DESCRIPTORS (self->parent));
|
||||
g_object_unref (self->parent);
|
||||
|
||||
G_OBJECT_CLASS (gsk_vulkan_sub_descriptors_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_sub_descriptors_class_init (GskVulkanSubDescriptorsClass *klass)
|
||||
{
|
||||
GskVulkanDescriptorsClass *vulkan_descriptors_class = GSK_VULKAN_DESCRIPTORS_CLASS (klass);
|
||||
GskGpuDescriptorsClass *descriptors_class = GSK_GPU_DESCRIPTORS_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gsk_vulkan_sub_descriptors_finalize;
|
||||
|
||||
descriptors_class->add_image = gsk_vulkan_sub_descriptors_add_image;
|
||||
descriptors_class->add_buffer = gsk_vulkan_sub_descriptors_add_buffer;
|
||||
|
||||
vulkan_descriptors_class->get_pipeline_layout = gsk_vulkan_sub_descriptors_get_pipeline_layout;
|
||||
vulkan_descriptors_class->bind = gsk_vulkan_sub_descriptors_bind;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_sub_descriptors_init (GskVulkanSubDescriptors *self)
|
||||
{
|
||||
}
|
||||
|
||||
GskVulkanSubDescriptors *
|
||||
gsk_vulkan_sub_descriptors_new (GskVulkanDescriptors *parent)
|
||||
{
|
||||
GskVulkanSubDescriptors *self;
|
||||
GskVulkanDescriptors *desc;
|
||||
|
||||
desc = gsk_vulkan_descriptors_new (&GSK_VULKAN_SUB_DESCRIPTORS_CLASS,
|
||||
sizeof (GskVulkanSubDescriptors));
|
||||
self = g_object_new (GSK_TYPE_VULKAN_SUB_DESCRIPTORS, NULL);
|
||||
|
||||
self = GSK_VULKAN_SUB_DESCRIPTORS (desc);
|
||||
self->parent = GSK_VULKAN_DESCRIPTORS (gsk_gpu_descriptors_ref (GSK_GPU_DESCRIPTORS (parent)));
|
||||
self->parent = g_object_ref (parent);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GskVulkanSubDescriptors GskVulkanSubDescriptors;
|
||||
|
||||
#define GSK_VULKAN_SUB_DESCRIPTORS(d) ((GskVulkanSubDescriptors *) (d))
|
||||
#define GSK_TYPE_VULKAN_SUB_DESCRIPTORS (gsk_vulkan_sub_descriptors_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskVulkanSubDescriptors, gsk_vulkan_sub_descriptors, GSK, VULKAN_SUB_DESCRIPTORS, GskVulkanDescriptors)
|
||||
|
||||
GskVulkanSubDescriptors * gsk_vulkan_sub_descriptors_new (GskVulkanDescriptors *parent);
|
||||
|
||||
|
||||
20
gsk/gskpointprivate.h
Normal file
20
gsk/gskpointprivate.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <graphene.h>
|
||||
|
||||
static inline void G_GNUC_PURE
|
||||
gsk_point_interpolate (const graphene_point_t *p1,
|
||||
const graphene_point_t *p2,
|
||||
float t,
|
||||
graphene_point_t *p)
|
||||
{
|
||||
p->x = p1->x * (1 - t) + p2->x * t;
|
||||
p->Y = p1->y * (1 - t) + p2->y * t;
|
||||
}
|
||||
|
||||
static inline float G_GNUC_PURE
|
||||
gsk_point_distance (const graphene_point_t *p1,
|
||||
const graphene_point_t *p2)
|
||||
{
|
||||
return sqrtf ((p1->x - p2->x)*(p1->x - p2->x) + (p1->y - p2->y)*(p1->y - p2->y));
|
||||
}
|
||||
43
gsk/gskvec2private.h
Normal file
43
gsk/gskvec2private.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <graphene.h>
|
||||
#include <math.h>
|
||||
|
||||
static inline float
|
||||
gsk_vec2_get_x (const graphene_vec2_t *v)
|
||||
{
|
||||
return graphene_simd4f_get_x (v->__graphene_private_value);
|
||||
}
|
||||
|
||||
static inline float
|
||||
gsk_vec2_get_y (const graphene_vec2_t *v)
|
||||
{
|
||||
return graphene_simd4f_get_y (v->__graphene_private_value);
|
||||
}
|
||||
|
||||
static inline graphene_vec2_t *
|
||||
gsk_vec2_init (graphene_vec2_t *v,
|
||||
float x,
|
||||
float y)
|
||||
{
|
||||
v->__graphene_private_value = graphene_simd4f_init (x, y, 0.f, 0.f);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline void
|
||||
gsk_vec2_multiply (const graphene_vec2_t *a,
|
||||
const graphene_vec2_t *b,
|
||||
graphene_vec2_t *res)
|
||||
{
|
||||
res->__graphene_private_value = graphene_simd4f_mul (a->__graphene_private_value,
|
||||
b->__graphene_private_value);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
gsk_vec2_equal (const graphene_vec2_t *v1,
|
||||
const graphene_vec2_t *v2)
|
||||
{
|
||||
return graphene_simd4f_cmp_eq (v1->__graphene_private_value, v2->__graphene_private_value);
|
||||
}
|
||||
|
||||
@@ -3639,19 +3639,6 @@ avahi_request_printer_list (GtkPrintBackendCups *cups_backend)
|
||||
g_bus_get (G_BUS_TYPE_SYSTEM, cups_backend->avahi_cancellable, avahi_create_browsers, cups_backend);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print backend can be disposed together with all its printers
|
||||
* as a reaction to user stopping enumeration of printers.
|
||||
*/
|
||||
static void
|
||||
backend_finalized_cb (gpointer data,
|
||||
GObject *where_the_object_was)
|
||||
{
|
||||
gboolean *backend_finalized = data;
|
||||
|
||||
*backend_finalized = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
||||
GtkCupsResult *result,
|
||||
@@ -3664,7 +3651,6 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
||||
GList *removed_printer_checklist;
|
||||
char *remote_default_printer = NULL;
|
||||
GList *iter;
|
||||
gboolean backend_finalized = FALSE;
|
||||
|
||||
list_has_changed = FALSE;
|
||||
|
||||
@@ -3697,8 +3683,6 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
||||
*/
|
||||
removed_printer_checklist = gtk_print_backend_get_printer_list (backend);
|
||||
|
||||
g_object_weak_ref (G_OBJECT (backend), backend_finalized_cb, &backend_finalized);
|
||||
|
||||
response = gtk_cups_result_get_response (result);
|
||||
for (attr = ippFirstAttribute (response); attr != NULL;
|
||||
attr = ippNextAttribute (response))
|
||||
@@ -3816,9 +3800,6 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
||||
{
|
||||
g_signal_emit_by_name (backend, "printer-added", printer);
|
||||
|
||||
if (backend_finalized)
|
||||
break;
|
||||
|
||||
gtk_printer_set_is_new (printer, FALSE);
|
||||
}
|
||||
|
||||
@@ -3856,44 +3837,36 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!backend_finalized)
|
||||
/* look at the removed printers checklist and mark any printer
|
||||
as inactive if it is in the list, emitting a printer_removed signal */
|
||||
if (removed_printer_checklist != NULL)
|
||||
{
|
||||
g_object_weak_unref (G_OBJECT (backend), backend_finalized_cb, &backend_finalized);
|
||||
|
||||
/* look at the removed printers checklist and mark any printer
|
||||
as inactive if it is in the list, emitting a printer_removed signal */
|
||||
if (removed_printer_checklist != NULL)
|
||||
for (iter = removed_printer_checklist; iter; iter = iter->next)
|
||||
{
|
||||
for (iter = removed_printer_checklist; iter; iter = iter->next)
|
||||
if (!GTK_PRINTER_CUPS (iter->data)->avahi_browsed)
|
||||
{
|
||||
if (!GTK_PRINTER_CUPS (iter->data)->avahi_browsed)
|
||||
{
|
||||
mark_printer_inactive (GTK_PRINTER (iter->data), backend);
|
||||
list_has_changed = TRUE;
|
||||
}
|
||||
mark_printer_inactive (GTK_PRINTER (iter->data), backend);
|
||||
list_has_changed = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free (removed_printer_checklist);
|
||||
g_list_free (removed_printer_checklist);
|
||||
}
|
||||
|
||||
done:
|
||||
if (!backend_finalized)
|
||||
if (list_has_changed)
|
||||
g_signal_emit_by_name (backend, "printer-list-changed");
|
||||
|
||||
gtk_print_backend_set_list_done (backend);
|
||||
|
||||
if (!cups_backend->got_default_printer && remote_default_printer != NULL)
|
||||
{
|
||||
if (list_has_changed)
|
||||
g_signal_emit_by_name (backend, "printer-list-changed");
|
||||
|
||||
gtk_print_backend_set_list_done (backend);
|
||||
|
||||
if (!cups_backend->got_default_printer && remote_default_printer != NULL)
|
||||
{
|
||||
set_default_printer (cups_backend, remote_default_printer);
|
||||
g_free (remote_default_printer);
|
||||
}
|
||||
|
||||
if (!cups_backend->got_default_printer && cups_backend->avahi_default_printer != NULL)
|
||||
set_default_printer (cups_backend, cups_backend->avahi_default_printer);
|
||||
set_default_printer (cups_backend, remote_default_printer);
|
||||
g_free (remote_default_printer);
|
||||
}
|
||||
|
||||
if (!cups_backend->got_default_printer && cups_backend->avahi_default_printer != NULL)
|
||||
set_default_printer (cups_backend, cups_backend->avahi_default_printer);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user