<commit_before>#include <math.h>
#include <epoxy/gl.h>

#include "gthreescene.h"
#include "gthreelight.h"

#include "gthreeobjectprivate.h"

typedef struct {
  GdkGLContext *context;
  gint context_count;
  GList *added_objects;
  GList *removed_objects;
  GList *lights;
  GdkRGBA bg_color;
  gboolean bg_color_is_set;
  GthreeTexture *bg_texture;
} GthreeScenePrivate;


G_DEFINE_TYPE_WITH_PRIVATE (GthreeScene, gthree_scene, GTHREE_TYPE_OBJECT);

GthreeScene *
gthree_scene_new ()
{
  GthreeScene *scene;

  scene = g_object_new (gthree_scene_get_type (),
                         NULL);

  return scene;
}

static void
gthree_scene_init (GthreeScene *scene)
{
  gthree_object_set_matrix_auto_update (GTHREE_OBJECT (scene), FALSE);
}

static void
gthree_scene_finalize (GObject *obj)
{
  GthreeScene *scene = GTHREE_SCENE (obj);
  GthreeScenePrivate *priv = gthree_scene_get_instance_private (scene);

  // These should all have been freed during dispose
  g_assert (priv->lights == NULL);
  g_assert (priv->added_objects == NULL);

  g_clear_object (&priv->bg_texture);

  g_list_free_full (priv->removed_objects, g_object_unref);
  G_OBJECT_CLASS (gthree_scene_parent_class)->finalize (obj);
}

const GdkRGBA *
gthree_scene_get_background_color (GthreeScene *scene)
{
  GthreeScenePrivate *priv = gthree_scene_get_instance_private (scene);
  if (priv->bg_color_is_set)
    return &priv->bg_color;
  return NULL;
}

void
gthree_scene_set_background_color   (GthreeScene   *scene,
                                     GdkRGBA       *color)
{
  GthreeScenePrivate *priv = gthree_scene_get_instance_private (scene);
  if (color != NULL)
    {
      priv->bg_color_is_set = TRUE;
      priv->bg_color = *color;
    }
  else
    priv->bg_color_is_set = FALSE;
}

GthreeTexture *
gthree_scene_get_background_texture (GthreeScene   *scene)
{
  GthreeScenePrivate *priv = gthree_scene_get_instance_private (scene);

  return priv->bg_texture;
}

void
gthree_scene_set_background_texture (GthreeScene   *scene,
                                     GthreeTexture *texture)
{
  GthreeScenePrivate *priv = gthree_scene_get_instance_private (scene);
<commit_msg>Scene: ensure bg_texture is marked used<commit_after>#include <math.h>
#include <epoxy/gl.h>

#include "gthreescene.h"
#include "gthreelight.h"

#include "gthreeobjectprivate.h"

typedef struct {
  GdkGLContext *context;
  gint context_count;
  GList *added_objects;
  GList *removed_objects;
  GList *lights;
  GdkRGBA bg_color;
  gboolean bg_color_is_set;
  GthreeTexture *bg_texture;
} GthreeScenePrivate;


G_DEFINE_TYPE_WITH_PRIVATE (GthreeScene, gthree_scene, GTHREE_TYPE_OBJECT);

GthreeScene *
gthree_scene_new ()
{
  GthreeScene *scene;

  scene = g_object_new (gthree_scene_get_type (),
                         NULL);

  return scene;
}

static void
gthree_scene_init (GthreeScene *scene)
{
  gthree_object_set_matrix_auto_update (GTHREE_OBJECT (scene), FALSE);
}

static void
gthree_scene_finalize (GObject *obj)
{
  GthreeScene *scene = GTHREE_SCENE (obj);
  GthreeScenePrivate *priv = gthree_scene_get_instance_private (scene);

  // These should all have been freed during dispose
  g_assert (priv->lights == NULL);
  g_assert (priv->added_objects == NULL);

  if (priv->bg_texture)
    {
      gthree_resource_unuse (GTHREE_RESOURCE (priv->bg_texture));
      g_clear_object (&priv->bg_texture);
    }

  g_list_free_full (priv->removed_objects, g_object_unref);
  G_OBJECT_CLASS (gthree_scene_parent_class)->finalize (obj);
}

const GdkRGBA *
gthree_scene_get_background_color (GthreeScene *scene)
{
  GthreeScenePrivate *priv = gthree_scene_get_instance_private (scene);
  if (priv->bg_color_is_set)
    return &priv->bg_color;
  return NULL;
}

void
gthree_scene_set_background_color   (GthreeScene   *scene,
                                     GdkRGBA       *color)
{
  GthreeScenePrivate *priv = gthree_scene_get_instance_private (scene);
  if (color != NULL)
    {
      priv->bg_color_is_set = TRUE;
      priv->bg_color = *color;
    }
  else
    priv->bg_color_is_set = FALSE;
}

GthreeTexture *
gthree_scene_get_background_texture (GthreeScene   *scene)
{
  GthreeScenePrivate *priv = gthree_scene_get_instance_private (scene);

  return priv->bg_texture;
}

void
gthree_scene_set_background_texture (GthreeScene   *scene,
                                     GthreeTexture *texture)
{
  GthreeScenePrivate *priv = gthree_scene_get_instance_private (scene);

  if (texture)
    gthree_resource_use (GTHREE_RESOURCE (texture));
  if (priv->bg_texture)
    gthree_resource_unuse (GTHREE_RESOURCE (priv->bg_texture));

{'fraction_non_alphanumeric': 0.0927094668117519, 'fraction_numerical': 0.0, 'mean_word_length': 4.175675675675675, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2089168', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1603, 'n_words': 304}