Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0eff31d7d5 | |||
| 32e21d5402 | |||
| fb3d8b8523 | |||
| 380523b41b | |||
| 2fda256bb0 | |||
| c71a66b6f6 | |||
| cb92778478 | |||
| ab67936a64 | |||
| 0ae2c1a8a7 |
+14
-26
@@ -5,6 +5,7 @@
|
||||
#include "gskglbufferprivate.h"
|
||||
#include "gskglimageprivate.h"
|
||||
|
||||
|
||||
struct _GskGLDescriptors
|
||||
{
|
||||
GskGpuDescriptors parent_instance;
|
||||
@@ -13,16 +14,12 @@ struct _GskGLDescriptors
|
||||
guint n_external;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskGLDescriptors, gsk_gl_descriptors, GSK_TYPE_GPU_DESCRIPTORS)
|
||||
|
||||
static void
|
||||
gsk_gl_descriptors_finalize (GObject *object)
|
||||
gsk_gl_descriptors_finalize (GskGpuDescriptors *desc)
|
||||
{
|
||||
GskGLDescriptors *self = GSK_GL_DESCRIPTORS (object);
|
||||
GskGLDescriptors *self = GSK_GL_DESCRIPTORS (desc);
|
||||
|
||||
g_object_unref (self->device);
|
||||
|
||||
G_OBJECT_CLASS (gsk_gl_descriptors_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -72,33 +69,24 @@ gsk_gl_descriptors_add_buffer (GskGpuDescriptors *desc,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_descriptors_class_init (GskGLDescriptorsClass *klass)
|
||||
static GskGpuDescriptorsClass GSK_GL_DESCRIPTORS_CLASS =
|
||||
{
|
||||
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)
|
||||
{
|
||||
}
|
||||
.finalize = gsk_gl_descriptors_finalize,
|
||||
.add_image = gsk_gl_descriptors_add_image,
|
||||
.add_buffer = gsk_gl_descriptors_add_buffer,
|
||||
};
|
||||
|
||||
GskGpuDescriptors *
|
||||
gsk_gl_descriptors_new (GskGLDevice *device)
|
||||
{
|
||||
GskGLDescriptors *self;
|
||||
GskGpuDescriptors *desc;
|
||||
|
||||
self = g_object_new (GSK_TYPE_GL_DESCRIPTORS, NULL);
|
||||
desc = gsk_gpu_descriptors_new ((GskGpuDescriptorsClass *) &GSK_GL_DESCRIPTORS_CLASS,
|
||||
sizeof (GskGLDescriptors));
|
||||
|
||||
self->device = g_object_ref (device);
|
||||
GSK_GL_DESCRIPTORS (desc)->device = g_object_ref (device);
|
||||
|
||||
return GSK_GPU_DESCRIPTORS (self);
|
||||
return desc;
|
||||
}
|
||||
|
||||
guint
|
||||
@@ -110,7 +98,7 @@ gsk_gl_descriptors_get_n_external (GskGLDescriptors *self)
|
||||
void
|
||||
gsk_gl_descriptors_use (GskGLDescriptors *self)
|
||||
{
|
||||
GskGpuDescriptors *desc = GSK_GPU_DESCRIPTORS (self);
|
||||
GskGpuDescriptors *desc = &self->parent_instance;
|
||||
gsize i, ext, n_textures;
|
||||
|
||||
n_textures = 16 - 3 * self->n_external;
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_GL_DESCRIPTORS (gsk_gl_descriptors_get_type ())
|
||||
typedef struct _GskGLDescriptors GskGLDescriptors;
|
||||
|
||||
#define GSK_GL_DESCRIPTORS(d) ((GskGLDescriptors *) (d))
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskGLDescriptors, gsk_gl_descriptors, GSK, GL_DESCRIPTORS, GskGpuDescriptors)
|
||||
|
||||
GskGpuDescriptors * gsk_gl_descriptors_new (GskGLDevice *device);
|
||||
|
||||
|
||||
+45
-24
@@ -52,43 +52,39 @@ 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;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GskGpuDescriptors, gsk_gpu_descriptors, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gsk_gpu_descriptors_finalize (GObject *object)
|
||||
static inline GskGpuDescriptorsPrivate *
|
||||
gsk_gpu_descriptors_get_instance_private (GskGpuDescriptors *self)
|
||||
{
|
||||
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);
|
||||
return (GskGpuDescriptorsPrivate *) (((guchar *)self) - sizeof (GskGpuDescriptorsPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gpu_descriptors_class_init (GskGpuDescriptorsClass *klass)
|
||||
/* Just for subclasses */
|
||||
GskGpuDescriptors *
|
||||
gsk_gpu_descriptors_new (GskGpuDescriptorsClass *desc_class,
|
||||
gsize child_size)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GskGpuDescriptors *self;
|
||||
GskGpuDescriptorsPrivate *priv;
|
||||
guchar *data;
|
||||
|
||||
object_class->finalize = gsk_gpu_descriptors_finalize;
|
||||
}
|
||||
data = g_new0 (guchar, child_size + sizeof (GskGpuDescriptorsPrivate));
|
||||
|
||||
static void
|
||||
gsk_gpu_descriptors_init (GskGpuDescriptors *self)
|
||||
{
|
||||
GskGpuDescriptorsPrivate *priv = gsk_gpu_descriptors_get_instance_private (self);
|
||||
priv = (GskGpuDescriptorsPrivate *) data;
|
||||
self = (GskGpuDescriptors *) (data + sizeof (GskGpuDescriptorsPrivate));
|
||||
|
||||
self->ref_count = 1;
|
||||
self->desc_class = desc_class;
|
||||
|
||||
gsk_gpu_image_entries_init (&priv->images);
|
||||
gsk_gpu_buffer_entries_init (&priv->buffers);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
gsize
|
||||
@@ -189,7 +185,7 @@ gsk_gpu_descriptors_add_image (GskGpuDescriptors *self,
|
||||
}
|
||||
}
|
||||
|
||||
if (!GSK_GPU_DESCRIPTORS_GET_CLASS (self)->add_image (self, image, sampler, &descriptor))
|
||||
if (!self->desc_class->add_image (self, image, sampler, &descriptor))
|
||||
return FALSE;
|
||||
|
||||
gsk_gpu_image_entries_append (&priv->images,
|
||||
@@ -224,7 +220,7 @@ gsk_gpu_descriptors_add_buffer (GskGpuDescriptors *self,
|
||||
}
|
||||
}
|
||||
|
||||
if (!GSK_GPU_DESCRIPTORS_GET_CLASS (self)->add_buffer (self, buffer, &descriptor))
|
||||
if (!self->desc_class->add_buffer (self, buffer, &descriptor))
|
||||
return FALSE;
|
||||
|
||||
gsk_gpu_buffer_entries_append (&priv->buffers,
|
||||
@@ -238,3 +234,28 @@ 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,24 +4,23 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#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))
|
||||
|
||||
typedef struct _GskGpuDescriptors GskGpuDescriptors;
|
||||
typedef struct _GskGpuDescriptorsClass GskGpuDescriptorsClass;
|
||||
typedef struct _GskGpuDescriptorsPrivate GskGpuDescriptorsPrivate;
|
||||
|
||||
#define GSK_GPU_DESCRIPTORS(d) ((GskGpuDescriptors *) (d))
|
||||
|
||||
struct _GskGpuDescriptors
|
||||
{
|
||||
GObject parent_instance;
|
||||
GskGpuDescriptorsClass *desc_class;
|
||||
int ref_count;
|
||||
|
||||
GskGpuDescriptorsPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GskGpuDescriptorsClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (* finalize) (GskGpuDescriptors *self);
|
||||
gboolean (* add_image) (GskGpuDescriptors *self,
|
||||
GskGpuImage *image,
|
||||
GskGpuSampler sampler,
|
||||
@@ -31,7 +30,8 @@ struct _GskGpuDescriptorsClass
|
||||
guint32 *out_id);
|
||||
};
|
||||
|
||||
GType gsk_gpu_descriptors_get_type (void) G_GNUC_CONST;
|
||||
GskGpuDescriptors * gsk_gpu_descriptors_ref (GskGpuDescriptors *self);
|
||||
void gsk_gpu_descriptors_unref (GskGpuDescriptors *self);
|
||||
|
||||
gsize gsk_gpu_descriptors_get_n_images (GskGpuDescriptors *self);
|
||||
gsize gsk_gpu_descriptors_get_n_buffers (GskGpuDescriptors *self);
|
||||
@@ -55,7 +55,8 @@ 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
|
||||
|
||||
@@ -152,7 +152,7 @@ static void
|
||||
gsk_gpu_node_processor_finish (GskGpuNodeProcessor *self)
|
||||
{
|
||||
g_clear_pointer (&self->modelview, gsk_transform_unref);
|
||||
g_clear_object (&self->desc);
|
||||
g_clear_pointer (&self->desc, gsk_gpu_descriptors_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -170,7 +170,7 @@ gsk_gpu_node_processor_init (GskGpuNodeProcessor *self,
|
||||
|
||||
self->frame = frame;
|
||||
if (desc)
|
||||
self->desc = g_object_ref (desc);
|
||||
self->desc = gsk_gpu_descriptors_ref (desc);
|
||||
else
|
||||
self->desc = NULL;
|
||||
|
||||
@@ -268,7 +268,7 @@ gsk_gpu_node_processor_add_image (GskGpuNodeProcessor *self,
|
||||
if (gsk_gpu_descriptors_add_image (self->desc, image, sampler, &descriptor))
|
||||
return descriptor;
|
||||
|
||||
g_object_unref (self->desc);
|
||||
gsk_gpu_descriptors_unref (self->desc);
|
||||
}
|
||||
|
||||
self->desc = gsk_gpu_frame_create_descriptors (self->frame);
|
||||
@@ -545,7 +545,7 @@ gsk_gpu_pattern_writer_finish (GskGpuPatternWriter *self)
|
||||
{
|
||||
pattern_buffer_clear (&self->buffer);
|
||||
g_assert (self->stack == 0);
|
||||
g_clear_object (&self->desc);
|
||||
g_clear_pointer (&self->desc, gsk_gpu_descriptors_unref);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -3000,8 +3000,12 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
|
||||
guint i, num_glyphs;
|
||||
float scale, inv_scale;
|
||||
GdkRGBA color;
|
||||
gboolean glyph_align;
|
||||
gboolean hinting;
|
||||
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;
|
||||
|
||||
if (self->opacity < 1.0 &&
|
||||
gsk_text_node_has_color_glyphs (node))
|
||||
@@ -3024,45 +3028,38 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
|
||||
scale = MAX (graphene_vec2_get_x (&self->scale), graphene_vec2_get_y (&self->scale));
|
||||
inv_scale = 1.f / scale;
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
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 + (float) glyphs[i].geometry.x_offset / PANGO_SCALE,
|
||||
offset.y + (float) glyphs[i].geometry.y_offset / PANGO_SCALE);
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
|
||||
image = gsk_gpu_device_lookup_glyph_image (device,
|
||||
self->frame,
|
||||
@@ -3084,7 +3081,11 @@ 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);
|
||||
|
||||
descriptor = gsk_gpu_node_processor_add_image (self, image, GSK_GPU_SAMPLER_DEFAULT);
|
||||
if (image != last_image)
|
||||
{
|
||||
descriptor = gsk_gpu_node_processor_add_image (self, image, GSK_GPU_SAMPLER_DEFAULT);
|
||||
last_image = image;
|
||||
}
|
||||
|
||||
if (glyphs[i].attr.is_color)
|
||||
gsk_gpu_texture_op (self->frame,
|
||||
@@ -3104,7 +3105,7 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
|
||||
&glyph_tex_rect,
|
||||
&color);
|
||||
|
||||
offset.x += (float) glyphs[i].geometry.width / PANGO_SCALE;
|
||||
offset.x += glyphs[i].geometry.width * inv_pango_scale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3121,8 +3122,10 @@ gsk_gpu_node_processor_create_glyph_pattern (GskGpuPatternWriter *self,
|
||||
guint32 tex_id;
|
||||
GskGpuImage *last_image;
|
||||
graphene_point_t offset;
|
||||
gboolean glyph_align;
|
||||
gboolean hinting;
|
||||
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;
|
||||
|
||||
if (gsk_text_node_has_color_glyphs (node))
|
||||
return FALSE;
|
||||
@@ -3142,8 +3145,20 @@ gsk_gpu_node_processor_create_glyph_pattern (GskGpuPatternWriter *self,
|
||||
gsk_gpu_pattern_writer_append_rgba (self, gsk_text_node_get_color (node));
|
||||
gsk_gpu_pattern_writer_append_uint (self, num_glyphs);
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
last_image = NULL;
|
||||
for (i = 0; i < num_glyphs; i++)
|
||||
@@ -3153,34 +3168,14 @@ 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 + (float) glyphs[i].geometry.x_offset / PANGO_SCALE,
|
||||
offset.y + (float) glyphs[i].geometry.y_offset / PANGO_SCALE);
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
|
||||
image = gsk_gpu_device_lookup_glyph_image (device,
|
||||
self->frame,
|
||||
@@ -3220,7 +3215,7 @@ gsk_gpu_node_processor_create_glyph_pattern (GskGpuPatternWriter *self,
|
||||
),
|
||||
&glyph_origin);
|
||||
|
||||
offset.x += (float) glyphs[i].geometry.width / PANGO_SCALE;
|
||||
offset.x += glyphs[i].geometry.width * inv_pango_scale;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -30,7 +30,6 @@ 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_object (&self->desc);
|
||||
g_clear_pointer (&self->desc, gsk_gpu_descriptors_unref);
|
||||
}
|
||||
|
||||
#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 = g_object_ref (desc);
|
||||
self->desc = gsk_gpu_descriptors_ref (desc);
|
||||
else
|
||||
self->desc = NULL;
|
||||
self->vertex_offset = gsk_gpu_frame_reserve_vertex_data (frame, op_class->vertex_size);
|
||||
|
||||
@@ -118,8 +118,7 @@ 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 << 7,
|
||||
GSK_GPU_OPTIMIZE_GL_BASE_INSTANCE = 1 << 6,
|
||||
} GskGpuOptimizations;
|
||||
|
||||
|
||||
@@ -6,22 +6,13 @@
|
||||
#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)
|
||||
{
|
||||
return GSK_VULKAN_DESCRIPTORS_GET_CLASS (self)->get_pipeline_layout (self);
|
||||
GskGpuDescriptors *desc = GSK_GPU_DESCRIPTORS (self);
|
||||
GskVulkanDescriptorsClass *class = GSK_VULKAN_DESCRIPTORS_CLASS (desc->desc_class);
|
||||
|
||||
return class->get_pipeline_layout (self);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -48,5 +39,19 @@ gsk_vulkan_descriptors_bind (GskVulkanDescriptors *self,
|
||||
GskVulkanDescriptors *previous,
|
||||
VkCommandBuffer vk_command_buffer)
|
||||
{
|
||||
return GSK_VULKAN_DESCRIPTORS_GET_CLASS (self)->bind (self, previous, 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);
|
||||
}
|
||||
|
||||
@@ -6,15 +6,12 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#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))
|
||||
|
||||
typedef struct _GskVulkanDescriptors GskVulkanDescriptors;
|
||||
typedef struct _GskVulkanDescriptorsClass GskVulkanDescriptorsClass;
|
||||
|
||||
#define GSK_VULKAN_DESCRIPTORS(d) ((GskVulkanDescriptors *) (d))
|
||||
#define GSK_VULKAN_DESCRIPTORS_CLASS(d) ((GskVulkanDescriptorsClass *) (d))
|
||||
|
||||
struct _GskVulkanDescriptors
|
||||
{
|
||||
GskGpuDescriptors parent_instance;
|
||||
@@ -30,8 +27,6 @@ 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,
|
||||
@@ -41,7 +36,9 @@ void gsk_vulkan_descriptors_bind
|
||||
GskVulkanDescriptors *previous,
|
||||
VkCommandBuffer vk_command_buffer);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GskVulkanDescriptors, g_object_unref)
|
||||
GskVulkanDescriptors * gsk_vulkan_descriptors_new (GskVulkanDescriptorsClass *desc_class,
|
||||
gsize child_size);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -13,10 +13,16 @@
|
||||
#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 g_object_unref
|
||||
#define GDK_ARRAY_FREE_FUNC gsk_vulkan_real_descriptors_unref
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
|
||||
@@ -262,7 +268,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 (g_object_ref (desc));
|
||||
return gsk_gpu_descriptors_ref (GSK_GPU_DESCRIPTORS (desc));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
#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
|
||||
@@ -45,8 +41,6 @@ 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)
|
||||
{
|
||||
@@ -154,9 +148,9 @@ gsk_vulkan_real_descriptors_add_buffer (GskGpuDescriptors *desc,
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_real_descriptors_finalize (GObject *object)
|
||||
gsk_vulkan_real_descriptors_finalize (GskGpuDescriptors *desc)
|
||||
{
|
||||
GskVulkanRealDescriptors *self = GSK_VULKAN_REAL_DESCRIPTORS (object);
|
||||
GskVulkanRealDescriptors *self = GSK_VULKAN_REAL_DESCRIPTORS (desc);
|
||||
|
||||
gsk_samplers_clear (&self->immutable_samplers);
|
||||
gsk_descriptor_image_infos_clear (&self->descriptor_immutable_images);
|
||||
@@ -165,25 +159,18 @@ gsk_vulkan_real_descriptors_finalize (GObject *object)
|
||||
|
||||
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 void
|
||||
gsk_vulkan_real_descriptors_class_init (GskVulkanRealDescriptorsClass *klass)
|
||||
static GskVulkanDescriptorsClass GSK_VULKAN_REAL_DESCRIPTORS_CLASS =
|
||||
{
|
||||
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;
|
||||
}
|
||||
.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
|
||||
};
|
||||
|
||||
static void
|
||||
gsk_vulkan_real_descriptors_init (GskVulkanRealDescriptors *self)
|
||||
@@ -198,9 +185,14 @@ GskVulkanRealDescriptors *
|
||||
gsk_vulkan_real_descriptors_new (GskVulkanFrame *frame)
|
||||
{
|
||||
GskVulkanRealDescriptors *self;
|
||||
GskVulkanDescriptors *desc;
|
||||
|
||||
self = g_object_new (GSK_TYPE_VULKAN_REAL_DESCRIPTORS, NULL);
|
||||
desc = gsk_vulkan_descriptors_new (&GSK_VULKAN_REAL_DESCRIPTORS_CLASS,
|
||||
sizeof (GskVulkanRealDescriptors));
|
||||
|
||||
self = GSK_VULKAN_REAL_DESCRIPTORS (desc);
|
||||
|
||||
gsk_vulkan_real_descriptors_init (self);
|
||||
self->frame = frame;
|
||||
|
||||
return self;
|
||||
|
||||
@@ -3,11 +3,17 @@
|
||||
#include "gskvulkandescriptorsprivate.h"
|
||||
#include "gskvulkanframeprivate.h"
|
||||
|
||||
#include "gskvulkanbufferprivate.h"
|
||||
#include "gskvulkanframeprivate.h"
|
||||
#include "gskvulkanimageprivate.h"
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_VULKAN_REAL_DESCRIPTORS (gsk_vulkan_real_descriptors_get_type ())
|
||||
typedef struct _GskVulkanRealDescriptors GskVulkanRealDescriptors;
|
||||
|
||||
#define GSK_VULKAN_REAL_DESCRIPTORS(d) ((GskVulkanRealDescriptors *) (d))
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskVulkanRealDescriptors, gsk_vulkan_real_descriptors, GSK, VULKAN_REAL_DESCRIPTORS, GskVulkanDescriptors)
|
||||
|
||||
GskVulkanRealDescriptors * gsk_vulkan_real_descriptors_new (GskVulkanFrame *frame);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "gskvulkansubdescriptorsprivate.h"
|
||||
|
||||
|
||||
struct _GskVulkanSubDescriptors
|
||||
{
|
||||
GskVulkanDescriptors parent_instance;
|
||||
@@ -9,7 +10,31 @@ struct _GskVulkanSubDescriptors
|
||||
GskVulkanDescriptors *parent;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GskVulkanSubDescriptors, gsk_vulkan_sub_descriptors, GSK_TYPE_VULKAN_DESCRIPTORS)
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
static GskVulkanPipelineLayout *
|
||||
gsk_vulkan_sub_descriptors_get_pipeline_layout (GskVulkanDescriptors *desc)
|
||||
@@ -26,7 +51,7 @@ gsk_vulkan_sub_descriptors_bind (GskVulkanDescriptors *desc,
|
||||
{
|
||||
GskVulkanSubDescriptors *self = GSK_VULKAN_SUB_DESCRIPTORS (desc);
|
||||
|
||||
if (GSK_IS_VULKAN_SUB_DESCRIPTORS (previous))
|
||||
if (GSK_GPU_DESCRIPTORS (previous)->desc_class == (GskGpuDescriptorsClass *) &GSK_VULKAN_SUB_DESCRIPTORS_CLASS)
|
||||
previous = GSK_VULKAN_SUB_DESCRIPTORS (previous)->parent;
|
||||
|
||||
if (self->parent == previous)
|
||||
@@ -62,45 +87,24 @@ gsk_vulkan_sub_descriptors_add_buffer (GskGpuDescriptors *desc,
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_vulkan_sub_descriptors_finalize (GObject *object)
|
||||
gsk_vulkan_sub_descriptors_finalize (GskGpuDescriptors *desc)
|
||||
{
|
||||
GskVulkanSubDescriptors *self = GSK_VULKAN_SUB_DESCRIPTORS (object);
|
||||
GskVulkanSubDescriptors *self = GSK_VULKAN_SUB_DESCRIPTORS (desc);
|
||||
|
||||
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)
|
||||
{
|
||||
gsk_gpu_descriptors_unref (GSK_GPU_DESCRIPTORS (self->parent));
|
||||
}
|
||||
|
||||
GskVulkanSubDescriptors *
|
||||
gsk_vulkan_sub_descriptors_new (GskVulkanDescriptors *parent)
|
||||
{
|
||||
GskVulkanSubDescriptors *self;
|
||||
GskVulkanDescriptors *desc;
|
||||
|
||||
self = g_object_new (GSK_TYPE_VULKAN_SUB_DESCRIPTORS, NULL);
|
||||
desc = gsk_vulkan_descriptors_new (&GSK_VULKAN_SUB_DESCRIPTORS_CLASS,
|
||||
sizeof (GskVulkanSubDescriptors));
|
||||
|
||||
self->parent = g_object_ref (parent);
|
||||
self = GSK_VULKAN_SUB_DESCRIPTORS (desc);
|
||||
self->parent = GSK_VULKAN_DESCRIPTORS (gsk_gpu_descriptors_ref (GSK_GPU_DESCRIPTORS (parent)));
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GSK_TYPE_VULKAN_SUB_DESCRIPTORS (gsk_vulkan_sub_descriptors_get_type ())
|
||||
typedef struct _GskVulkanSubDescriptors GskVulkanSubDescriptors;
|
||||
|
||||
#define GSK_VULKAN_SUB_DESCRIPTORS(d) ((GskVulkanSubDescriptors *) (d))
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GskVulkanSubDescriptors, gsk_vulkan_sub_descriptors, GSK, VULKAN_SUB_DESCRIPTORS, GskVulkanDescriptors)
|
||||
|
||||
GskVulkanSubDescriptors * gsk_vulkan_sub_descriptors_new (GskVulkanDescriptors *parent);
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#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));
|
||||
}
|
||||
@@ -3639,6 +3639,19 @@ 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,
|
||||
@@ -3651,6 +3664,7 @@ 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;
|
||||
|
||||
@@ -3683,6 +3697,8 @@ 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))
|
||||
@@ -3800,6 +3816,9 @@ 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);
|
||||
}
|
||||
|
||||
@@ -3837,36 +3856,44 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
||||
break;
|
||||
}
|
||||
|
||||
/* 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)
|
||||
if (!backend_finalized)
|
||||
{
|
||||
for (iter = removed_printer_checklist; iter; iter = iter->next)
|
||||
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)
|
||||
{
|
||||
if (!GTK_PRINTER_CUPS (iter->data)->avahi_browsed)
|
||||
for (iter = removed_printer_checklist; iter; iter = iter->next)
|
||||
{
|
||||
mark_printer_inactive (GTK_PRINTER (iter->data), backend);
|
||||
list_has_changed = TRUE;
|
||||
if (!GTK_PRINTER_CUPS (iter->data)->avahi_browsed)
|
||||
{
|
||||
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 (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 (!backend_finalized)
|
||||
{
|
||||
set_default_printer (cups_backend, remote_default_printer);
|
||||
g_free (remote_default_printer);
|
||||
}
|
||||
if (list_has_changed)
|
||||
g_signal_emit_by_name (backend, "printer-list-changed");
|
||||
|
||||
if (!cups_backend->got_default_printer && cups_backend->avahi_default_printer != NULL)
|
||||
set_default_printer (cups_backend, cups_backend->avahi_default_printer);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user