17 fl_texture_registrar_impl,
19 TEXTURE_REGISTRAR_IMPL,
22struct _FlTextureRegistrarImpl {
23 GObject parent_instance;
39 GMutex textures_mutex;
43 FlTextureRegistrarInterface* iface);
45G_DEFINE_INTERFACE(FlTextureRegistrar, fl_texture_registrar, G_TYPE_OBJECT)
48 FlTextureRegistrarImpl,
49 fl_texture_registrar_impl,
51 G_IMPLEMENT_INTERFACE(fl_texture_registrar_get_type(),
54static
void fl_texture_registrar_default_init(
55 FlTextureRegistrarInterface* iface) {}
58 FlTextureRegistrarImpl*
self = FL_TEXTURE_REGISTRAR_IMPL(
object);
60 g_mutex_lock(&
self->textures_mutex);
61 g_clear_pointer(&
self->textures, g_hash_table_unref);
62 g_mutex_unlock(&
self->textures_mutex);
64 g_weak_ref_clear(&
self->engine);
65 g_mutex_clear(&
self->textures_mutex);
67 G_OBJECT_CLASS(fl_texture_registrar_impl_parent_class)->dispose(
object);
71 FlTextureRegistrarImplClass* klass) {
77 FlTextureRegistrarImpl*
self = FL_TEXTURE_REGISTRAR_IMPL(registrar);
79 if (FL_IS_TEXTURE_GL(
texture) || FL_IS_PIXEL_BUFFER_TEXTURE(
texture)) {
90 int64_t
id =
reinterpret_cast<int64_t
>(
texture);
93 g_mutex_lock(&
self->textures_mutex);
96 g_mutex_unlock(&
self->textures_mutex);
109 FlTextureRegistrarImpl*
self = FL_TEXTURE_REGISTRAR_IMPL(registrar);
110 g_mutex_lock(&
self->textures_mutex);
111 FlTexture*
texture =
reinterpret_cast<FlTexture*
>(
112 g_hash_table_lookup(
self->textures, GINT_TO_POINTER(
texture_id)));
113 g_mutex_unlock(&
self->textures_mutex);
119 FlTextureRegistrarImpl*
self = FL_TEXTURE_REGISTRAR_IMPL(registrar);
132 FlTextureRegistrarImpl*
self = FL_TEXTURE_REGISTRAR_IMPL(registrar);
142 g_mutex_lock(&
self->textures_mutex);
143 if (!g_hash_table_remove(
self->textures,
145 g_warning(
"Unregistering a non-existent texture %p",
texture);
147 g_mutex_unlock(&
self->textures_mutex);
152static void shutdown(FlTextureRegistrar* registrar) {
153 FlTextureRegistrarImpl*
self = FL_TEXTURE_REGISTRAR_IMPL(registrar);
156 g_mutex_lock(&
self->textures_mutex);
158 self->textures = g_hash_table_new_full(g_direct_hash, g_direct_equal,
nullptr,
160 g_hash_table_remove_all(textures);
161 g_mutex_unlock(&
self->textures_mutex);
165 FlTextureRegistrarInterface* iface) {
175 self->textures = g_hash_table_new_full(g_direct_hash, g_direct_equal,
nullptr,
178 g_mutex_init(&
self->textures_mutex);
181G_MODULE_EXPORT gboolean
184 g_return_val_if_fail(FL_IS_TEXTURE_REGISTRAR(
self), FALSE);
185 g_return_val_if_fail(FL_IS_TEXTURE(
texture), FALSE);
187 return FL_TEXTURE_REGISTRAR_GET_IFACE(
self)->register_texture(
self,
texture);
192 g_return_val_if_fail(FL_IS_TEXTURE_REGISTRAR(
self), NULL);
197G_MODULE_EXPORT gboolean
200 g_return_val_if_fail(FL_IS_TEXTURE_REGISTRAR(
self), FALSE);
202 return FL_TEXTURE_REGISTRAR_GET_IFACE(
self)->mark_texture_frame_available(
206G_MODULE_EXPORT gboolean
209 g_return_val_if_fail(FL_IS_TEXTURE_REGISTRAR(
self), FALSE);
211 return FL_TEXTURE_REGISTRAR_GET_IFACE(
self)->unregister_texture(
self,
216 g_return_if_fail(FL_IS_TEXTURE_REGISTRAR(
self));
218 return FL_TEXTURE_REGISTRAR_GET_IFACE(
self)->shutdown(
self);
222 FlTextureRegistrarImpl*
self = FL_TEXTURE_REGISTRAR_IMPL(
223 g_object_new(fl_texture_registrar_impl_get_type(),
nullptr));
226 FL_IS_TEXTURE_REGISTRAR_IMPL(
self);
228 g_weak_ref_init(&
self->engine, G_OBJECT(
engine));
230 return FL_TEXTURE_REGISTRAR(
self);
g_autoptr(GMutexLocker) locker
gboolean fl_engine_mark_texture_frame_available(FlEngine *self, int64_t texture_id)
gboolean fl_engine_unregister_external_texture(FlEngine *self, int64_t texture_id)
gboolean fl_engine_register_external_texture(FlEngine *self, int64_t texture_id)
g_hash_table_insert(self->handlers, g_strdup(channel), handler_new(handler, user_data, destroy_notify))
G_MODULE_EXPORT int64_t fl_texture_get_id(FlTexture *self)
void fl_texture_set_id(FlTexture *self, int64_t id)
static gboolean register_texture(FlTextureRegistrar *registrar, FlTexture *texture)
static gboolean mark_texture_frame_available(FlTextureRegistrar *registrar, FlTexture *texture)
G_MODULE_EXPORT gboolean fl_texture_registrar_register_texture(FlTextureRegistrar *self, FlTexture *texture)
void fl_texture_registrar_shutdown(FlTextureRegistrar *self)
G_DEFINE_TYPE_WITH_CODE(FlTextureRegistrarImpl, fl_texture_registrar_impl, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(fl_texture_registrar_get_type(), fl_texture_registrar_impl_iface_init)) static void fl_texture_registrar_default_init(FlTextureRegistrarInterface *iface)
static void fl_texture_registrar_impl_init(FlTextureRegistrarImpl *self)
G_DECLARE_FINAL_TYPE(FlTextureRegistrarImpl, fl_texture_registrar_impl, FL, TEXTURE_REGISTRAR_IMPL, GObject) struct _FlTextureRegistrarImpl
G_MODULE_EXPORT gboolean fl_texture_registrar_unregister_texture(FlTextureRegistrar *self, FlTexture *texture)
G_MODULE_EXPORT gboolean fl_texture_registrar_mark_texture_frame_available(FlTextureRegistrar *self, FlTexture *texture)
static void shutdown(FlTextureRegistrar *registrar)
FlTexture * fl_texture_registrar_lookup_texture(FlTextureRegistrar *self, int64_t texture_id)
static FlTexture * lookup_texture(FlTextureRegistrar *registrar, int64_t texture_id)
static void fl_texture_registrar_impl_dispose(GObject *object)
static gboolean unregister_texture(FlTextureRegistrar *registrar, FlTexture *texture)
FlTextureRegistrar * fl_texture_registrar_new(FlEngine *engine)
static void fl_texture_registrar_impl_class_init(FlTextureRegistrarImplClass *klass)
static void fl_texture_registrar_impl_iface_init(FlTextureRegistrarInterface *iface)