/* ColorblindnessCorrectionEffect.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from ColorblindnessCorrectionEffect.vala, do not modify */

/*
 * Copyright 2023 elementary, Inc. <https://elementary.io>
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include <clutter/clutter.h>
#include <glib-object.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>

#define GALA_COLORBLINDNESS_CORRECTION_EFFECT_EFFECT_NAME "colorblindness-correction-filter"
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define GALA_TYPE_COLORBLINDNESS_CORRECTION_EFFECT (gala_colorblindness_correction_effect_get_type ())
#define GALA_COLORBLINDNESS_CORRECTION_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_COLORBLINDNESS_CORRECTION_EFFECT, GalaColorblindnessCorrectionEffect))
#define GALA_COLORBLINDNESS_CORRECTION_EFFECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_COLORBLINDNESS_CORRECTION_EFFECT, GalaColorblindnessCorrectionEffectClass))
#define GALA_IS_COLORBLINDNESS_CORRECTION_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_COLORBLINDNESS_CORRECTION_EFFECT))
#define GALA_IS_COLORBLINDNESS_CORRECTION_EFFECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_COLORBLINDNESS_CORRECTION_EFFECT))
#define GALA_COLORBLINDNESS_CORRECTION_EFFECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_COLORBLINDNESS_CORRECTION_EFFECT, GalaColorblindnessCorrectionEffectClass))

typedef struct _GalaColorblindnessCorrectionEffect GalaColorblindnessCorrectionEffect;
typedef struct _GalaColorblindnessCorrectionEffectClass GalaColorblindnessCorrectionEffectClass;
typedef struct _GalaColorblindnessCorrectionEffectPrivate GalaColorblindnessCorrectionEffectPrivate;
enum  {
	GALA_COLORBLINDNESS_CORRECTION_EFFECT_0_PROPERTY,
	GALA_COLORBLINDNESS_CORRECTION_EFFECT_MODE_PROPERTY,
	GALA_COLORBLINDNESS_CORRECTION_EFFECT_STRENGTH_PROPERTY,
	GALA_COLORBLINDNESS_CORRECTION_EFFECT_PAUSE_FOR_SCREENSHOT_PROPERTY,
	GALA_COLORBLINDNESS_CORRECTION_EFFECT_TRANSITION_ACTOR_PROPERTY,
	GALA_COLORBLINDNESS_CORRECTION_EFFECT_NUM_PROPERTIES
};
static GParamSpec* gala_colorblindness_correction_effect_properties[GALA_COLORBLINDNESS_CORRECTION_EFFECT_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_bytes_unref0(var) ((var == NULL) ? NULL : (var = (g_bytes_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _GalaColorblindnessCorrectionEffect {
	ClutterShaderEffect parent_instance;
	GalaColorblindnessCorrectionEffectPrivate * priv;
};

struct _GalaColorblindnessCorrectionEffectClass {
	ClutterShaderEffectClass parent_class;
};

struct _GalaColorblindnessCorrectionEffectPrivate {
	gint _mode;
	gdouble _strength;
	ClutterActor* _transition_actor;
};

static gint GalaColorblindnessCorrectionEffect_private_offset;
static gpointer gala_colorblindness_correction_effect_parent_class = NULL;

VALA_EXTERN GType gala_colorblindness_correction_effect_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaColorblindnessCorrectionEffect, g_object_unref)
VALA_EXTERN GalaColorblindnessCorrectionEffect* gala_colorblindness_correction_effect_new (gint mode,
                                                                               gdouble strength);
VALA_EXTERN GalaColorblindnessCorrectionEffect* gala_colorblindness_correction_effect_construct (GType object_type,
                                                                                     gint mode,
                                                                                     gdouble strength);
VALA_EXTERN void gala_colorblindness_correction_effect_set_pause_for_screenshot (GalaColorblindnessCorrectionEffect* self,
                                                                     gboolean value);
VALA_EXTERN gint gala_colorblindness_correction_effect_get_mode (GalaColorblindnessCorrectionEffect* self);
VALA_EXTERN void gala_colorblindness_correction_effect_set_mode (GalaColorblindnessCorrectionEffect* self,
                                                     gint value);
VALA_EXTERN gdouble gala_colorblindness_correction_effect_get_strength (GalaColorblindnessCorrectionEffect* self);
VALA_EXTERN void gala_colorblindness_correction_effect_set_strength (GalaColorblindnessCorrectionEffect* self,
                                                         gdouble value);
VALA_EXTERN ClutterActor* gala_colorblindness_correction_effect_get_transition_actor (GalaColorblindnessCorrectionEffect* self);
VALA_EXTERN void gala_colorblindness_correction_effect_set_transition_actor (GalaColorblindnessCorrectionEffect* self,
                                                                 ClutterActor* value);
static void gala_colorblindness_correction_effect_finalize (GObject * obj);
static GType gala_colorblindness_correction_effect_get_type_once (void);
static void _vala_gala_colorblindness_correction_effect_get_property (GObject * object,
                                                               guint property_id,
                                                               GValue * value,
                                                               GParamSpec * pspec);
static void _vala_gala_colorblindness_correction_effect_set_property (GObject * object,
                                                               guint property_id,
                                                               const GValue * value,
                                                               GParamSpec * pspec);

static inline gpointer
gala_colorblindness_correction_effect_get_instance_private (GalaColorblindnessCorrectionEffect* self)
{
	return G_STRUCT_MEMBER_P (self, GalaColorblindnessCorrectionEffect_private_offset);
}

GalaColorblindnessCorrectionEffect*
gala_colorblindness_correction_effect_construct (GType object_type,
                                                 gint mode,
                                                 gdouble strength)
{
	GalaColorblindnessCorrectionEffect * self = NULL;
	GError* _inner_error0_ = NULL;
	self = (GalaColorblindnessCorrectionEffect*) g_object_new (object_type, "shader-type", CLUTTER_FRAGMENT_SHADER, "mode", mode, "strength", strength, NULL);
	{
		GBytes* bytes = NULL;
		GBytes* _tmp0_;
		gsize _tmp1_ = 0;
		guint8* _tmp2_;
		_tmp0_ = g_resources_lookup_data ("/io/elementary/desktop/gala/shaders/colorblindness-correction.frag", G_RESOURCE_LOOKUP_FLAGS_NONE, &_inner_error0_);
		bytes = _tmp0_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = g_bytes_get_data (bytes, &_tmp1_);
		clutter_shader_effect_set_shader_source ((ClutterShaderEffect*) self, (const gchar*) _tmp2_);
		_g_bytes_unref0 (bytes);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_critical ("ColorblindnessCorrectionEffect.vala:53: Unable to load colorblindness-" \
"correction.frag: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	gala_colorblindness_correction_effect_set_pause_for_screenshot (self, FALSE);
	return self;
}

GalaColorblindnessCorrectionEffect*
gala_colorblindness_correction_effect_new (gint mode,
                                           gdouble strength)
{
	return gala_colorblindness_correction_effect_construct (GALA_TYPE_COLORBLINDNESS_CORRECTION_EFFECT, mode, strength);
}

gint
gala_colorblindness_correction_effect_get_mode (GalaColorblindnessCorrectionEffect* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_mode;
	return result;
}

void
gala_colorblindness_correction_effect_set_mode (GalaColorblindnessCorrectionEffect* self,
                                                gint value)
{
	GValue _tmp0_ = {0};
	g_return_if_fail (self != NULL);
	self->priv->_mode = value;
	g_value_init (&_tmp0_, G_TYPE_INT);
	g_value_set_int (&_tmp0_, self->priv->_mode);
	clutter_shader_effect_set_uniform_value ((ClutterShaderEffect*) self, "COLORBLIND_MODE", &_tmp0_);
	G_IS_VALUE (&_tmp0_) ? (g_value_unset (&_tmp0_), NULL) : NULL;
	g_object_notify_by_pspec ((GObject *) self, gala_colorblindness_correction_effect_properties[GALA_COLORBLINDNESS_CORRECTION_EFFECT_MODE_PROPERTY]);
}

gdouble
gala_colorblindness_correction_effect_get_strength (GalaColorblindnessCorrectionEffect* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, 0.0);
	result = self->priv->_strength;
	return result;
}

void
gala_colorblindness_correction_effect_set_strength (GalaColorblindnessCorrectionEffect* self,
                                                    gdouble value)
{
	GValue _tmp0_ = {0};
	g_return_if_fail (self != NULL);
	self->priv->_strength = value;
	g_value_init (&_tmp0_, G_TYPE_DOUBLE);
	g_value_set_double (&_tmp0_, value);
	clutter_shader_effect_set_uniform_value ((ClutterShaderEffect*) self, "STRENGTH", &_tmp0_);
	G_IS_VALUE (&_tmp0_) ? (g_value_unset (&_tmp0_), NULL) : NULL;
	clutter_effect_queue_repaint ((ClutterEffect*) self);
	g_object_notify_by_pspec ((GObject *) self, gala_colorblindness_correction_effect_properties[GALA_COLORBLINDNESS_CORRECTION_EFFECT_STRENGTH_PROPERTY]);
}

void
gala_colorblindness_correction_effect_set_pause_for_screenshot (GalaColorblindnessCorrectionEffect* self,
                                                                gboolean value)
{
	GValue _tmp0_ = {0};
	g_return_if_fail (self != NULL);
	g_value_init (&_tmp0_, G_TYPE_INT);
	g_value_set_int (&_tmp0_, (gint) value);
	clutter_shader_effect_set_uniform_value ((ClutterShaderEffect*) self, "PAUSE_FOR_SCREENSHOT", &_tmp0_);
	G_IS_VALUE (&_tmp0_) ? (g_value_unset (&_tmp0_), NULL) : NULL;
	clutter_effect_queue_repaint ((ClutterEffect*) self);
	g_object_notify_by_pspec ((GObject *) self, gala_colorblindness_correction_effect_properties[GALA_COLORBLINDNESS_CORRECTION_EFFECT_PAUSE_FOR_SCREENSHOT_PROPERTY]);
}

ClutterActor*
gala_colorblindness_correction_effect_get_transition_actor (GalaColorblindnessCorrectionEffect* self)
{
	ClutterActor* result;
	ClutterActor* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_transition_actor;
	result = _tmp0_;
	return result;
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

void
gala_colorblindness_correction_effect_set_transition_actor (GalaColorblindnessCorrectionEffect* self,
                                                            ClutterActor* value)
{
	ClutterActor* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_colorblindness_correction_effect_get_transition_actor (self);
	if (old_value != value) {
		ClutterActor* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_transition_actor);
		self->priv->_transition_actor = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_colorblindness_correction_effect_properties[GALA_COLORBLINDNESS_CORRECTION_EFFECT_TRANSITION_ACTOR_PROPERTY]);
	}
}

static void
gala_colorblindness_correction_effect_class_init (GalaColorblindnessCorrectionEffectClass * klass,
                                                  gpointer klass_data)
{
	gala_colorblindness_correction_effect_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaColorblindnessCorrectionEffect_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_colorblindness_correction_effect_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_colorblindness_correction_effect_set_property;
	G_OBJECT_CLASS (klass)->finalize = gala_colorblindness_correction_effect_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_COLORBLINDNESS_CORRECTION_EFFECT_MODE_PROPERTY, gala_colorblindness_correction_effect_properties[GALA_COLORBLINDNESS_CORRECTION_EFFECT_MODE_PROPERTY] = g_param_spec_int ("mode", "mode", "mode", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_COLORBLINDNESS_CORRECTION_EFFECT_STRENGTH_PROPERTY, gala_colorblindness_correction_effect_properties[GALA_COLORBLINDNESS_CORRECTION_EFFECT_STRENGTH_PROPERTY] = g_param_spec_double ("strength", "strength", "strength", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_COLORBLINDNESS_CORRECTION_EFFECT_PAUSE_FOR_SCREENSHOT_PROPERTY, gala_colorblindness_correction_effect_properties[GALA_COLORBLINDNESS_CORRECTION_EFFECT_PAUSE_FOR_SCREENSHOT_PROPERTY] = g_param_spec_boolean ("pause-for-screenshot", "pause-for-screenshot", "pause-for-screenshot", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_COLORBLINDNESS_CORRECTION_EFFECT_TRANSITION_ACTOR_PROPERTY, gala_colorblindness_correction_effect_properties[GALA_COLORBLINDNESS_CORRECTION_EFFECT_TRANSITION_ACTOR_PROPERTY] = g_param_spec_object ("transition-actor", "transition-actor", "transition-actor", clutter_actor_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
gala_colorblindness_correction_effect_instance_init (GalaColorblindnessCorrectionEffect * self,
                                                     gpointer klass)
{
	self->priv = gala_colorblindness_correction_effect_get_instance_private (self);
	self->priv->_transition_actor = NULL;
}

static void
gala_colorblindness_correction_effect_finalize (GObject * obj)
{
	GalaColorblindnessCorrectionEffect * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_COLORBLINDNESS_CORRECTION_EFFECT, GalaColorblindnessCorrectionEffect);
	_g_object_unref0 (self->priv->_transition_actor);
	G_OBJECT_CLASS (gala_colorblindness_correction_effect_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_colorblindness_correction_effect_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaColorblindnessCorrectionEffectClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_colorblindness_correction_effect_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaColorblindnessCorrectionEffect), 0, (GInstanceInitFunc) gala_colorblindness_correction_effect_instance_init, NULL };
	GType gala_colorblindness_correction_effect_type_id;
	gala_colorblindness_correction_effect_type_id = g_type_register_static (clutter_shader_effect_get_type (), "GalaColorblindnessCorrectionEffect", &g_define_type_info, 0);
	GalaColorblindnessCorrectionEffect_private_offset = g_type_add_instance_private (gala_colorblindness_correction_effect_type_id, sizeof (GalaColorblindnessCorrectionEffectPrivate));
	return gala_colorblindness_correction_effect_type_id;
}

GType
gala_colorblindness_correction_effect_get_type (void)
{
	static gsize gala_colorblindness_correction_effect_type_id__once = 0;
	if (g_once_init_enter (&gala_colorblindness_correction_effect_type_id__once)) {
		GType gala_colorblindness_correction_effect_type_id;
		gala_colorblindness_correction_effect_type_id = gala_colorblindness_correction_effect_get_type_once ();
		g_once_init_leave (&gala_colorblindness_correction_effect_type_id__once, gala_colorblindness_correction_effect_type_id);
	}
	return gala_colorblindness_correction_effect_type_id__once;
}

static void
_vala_gala_colorblindness_correction_effect_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec)
{
	GalaColorblindnessCorrectionEffect * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_COLORBLINDNESS_CORRECTION_EFFECT, GalaColorblindnessCorrectionEffect);
	switch (property_id) {
		case GALA_COLORBLINDNESS_CORRECTION_EFFECT_MODE_PROPERTY:
		g_value_set_int (value, gala_colorblindness_correction_effect_get_mode (self));
		break;
		case GALA_COLORBLINDNESS_CORRECTION_EFFECT_STRENGTH_PROPERTY:
		g_value_set_double (value, gala_colorblindness_correction_effect_get_strength (self));
		break;
		case GALA_COLORBLINDNESS_CORRECTION_EFFECT_TRANSITION_ACTOR_PROPERTY:
		g_value_set_object (value, gala_colorblindness_correction_effect_get_transition_actor (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_colorblindness_correction_effect_set_property (GObject * object,
                                                          guint property_id,
                                                          const GValue * value,
                                                          GParamSpec * pspec)
{
	GalaColorblindnessCorrectionEffect * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_COLORBLINDNESS_CORRECTION_EFFECT, GalaColorblindnessCorrectionEffect);
	switch (property_id) {
		case GALA_COLORBLINDNESS_CORRECTION_EFFECT_MODE_PROPERTY:
		gala_colorblindness_correction_effect_set_mode (self, g_value_get_int (value));
		break;
		case GALA_COLORBLINDNESS_CORRECTION_EFFECT_STRENGTH_PROPERTY:
		gala_colorblindness_correction_effect_set_strength (self, g_value_get_double (value));
		break;
		case GALA_COLORBLINDNESS_CORRECTION_EFFECT_PAUSE_FOR_SCREENSHOT_PROPERTY:
		gala_colorblindness_correction_effect_set_pause_for_screenshot (self, g_value_get_boolean (value));
		break;
		case GALA_COLORBLINDNESS_CORRECTION_EFFECT_TRANSITION_ACTOR_PROPERTY:
		gala_colorblindness_correction_effect_set_transition_actor (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

