/* PIKA - Photo and Image Kooker Application
 * a rebranding of The GNU Image Manipulation Program (created with heckimp)
 * A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
 *
 * Original copyright, applying to most contents (license remains unchanged): 
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * pikaapplicator.h
 * Copyright (C) 2012-2013 Michael Natterer <mitch@gimp.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef __PIKA_APPLICATOR_H__
#define __PIKA_APPLICATOR_H__


#define PIKA_TYPE_APPLICATOR            (pika_applicator_get_type ())
#define PIKA_APPLICATOR(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_APPLICATOR, PikaApplicator))
#define PIKA_APPLICATOR_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_APPLICATOR, PikaApplicatorClass))
#define PIKA_IS_APPLICATOR(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_APPLICATOR))
#define PIKA_IS_APPLICATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_APPLICATOR))
#define PIKA_APPLICATOR_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_APPLICATOR, PikaApplicatorClass))


typedef struct _PikaApplicatorClass PikaApplicatorClass;

struct _PikaApplicator
{
  GObject                 parent_instance;

  GeglNode               *node;
  GeglNode               *input_node;
  GeglNode               *aux_node;
  GeglNode               *output_node;

  gboolean                active;

  GeglBuffer             *apply_buffer;
  GeglNode               *apply_src_node;

  gint                    apply_offset_x;
  gint                    apply_offset_y;
  GeglNode               *apply_offset_node;

  gdouble                 opacity;
  PikaLayerMode           paint_mode;
  PikaLayerColorSpace     blend_space;
  PikaLayerColorSpace     composite_space;
  PikaLayerCompositeMode  composite_mode;
  GeglNode               *mode_node;

  PikaComponentMask       affect;
  GeglNode               *affect_node;

  const Babl             *output_format;
  GeglNode               *convert_format_node;

  gboolean                cache_enabled;
  GeglNode               *cache_node;

  gboolean                crop_enabled;
  GeglRectangle           crop_rect;
  GeglNode               *crop_node;

  GeglBuffer             *src_buffer;
  GeglNode               *src_node;

  GeglBuffer             *dest_buffer;
  GeglNode               *dest_node;

  GeglBuffer             *mask_buffer;
  GeglNode               *mask_node;

  gint                    mask_offset_x;
  gint                    mask_offset_y;
  GeglNode               *mask_offset_node;
};

struct _PikaApplicatorClass
{
  GObjectClass  parent_class;
};


GType        pika_applicator_get_type          (void) G_GNUC_CONST;

PikaApplicator * pika_applicator_new           (GeglNode             *parent);

void         pika_applicator_set_active        (PikaApplicator       *applicator,
                                                gboolean              active);

void         pika_applicator_set_src_buffer    (PikaApplicator       *applicator,
                                                GeglBuffer           *dest_buffer);
void         pika_applicator_set_dest_buffer   (PikaApplicator       *applicator,
                                                GeglBuffer           *dest_buffer);

void         pika_applicator_set_mask_buffer   (PikaApplicator       *applicator,
                                                GeglBuffer           *mask_buffer);
void         pika_applicator_set_mask_offset   (PikaApplicator       *applicator,
                                                gint                  mask_offset_x,
                                                gint                  mask_offset_y);

void         pika_applicator_set_apply_buffer  (PikaApplicator       *applicator,
                                                GeglBuffer           *apply_buffer);
void         pika_applicator_set_apply_offset  (PikaApplicator       *applicator,
                                                gint                  apply_offset_x,
                                                gint                  apply_offset_y);

void         pika_applicator_set_opacity       (PikaApplicator       *applicator,
                                                gdouble               opacity);
void         pika_applicator_set_mode          (PikaApplicator       *applicator,
                                                PikaLayerMode         paint_mode,
                                                PikaLayerColorSpace   blend_space,
                                                PikaLayerColorSpace   composite_space,
                                                PikaLayerCompositeMode composite_mode);
void         pika_applicator_set_affect        (PikaApplicator       *applicator,
                                                PikaComponentMask     affect);

void         pika_applicator_set_output_format (PikaApplicator       *applicator,
                                                const Babl           *format);
const Babl * pika_applicator_get_output_format (PikaApplicator       *applicator);

void         pika_applicator_set_cache         (PikaApplicator       *applicator,
                                                gboolean              enable);
gboolean     pika_applicator_get_cache         (PikaApplicator       *applicator);
GeglBuffer * pika_applicator_get_cache_buffer  (PikaApplicator       *applicator,
                                                GeglRectangle       **rectangles,
                                                gint                 *n_rectangles);

void         pika_applicator_set_crop          (PikaApplicator       *applicator,
                                                const GeglRectangle  *rect);
const GeglRectangle * pika_applicator_get_crop (PikaApplicator       *applicator);

void         pika_applicator_blit              (PikaApplicator       *applicator,
                                                const GeglRectangle  *rect);


#endif  /*  __PIKA_APPLICATOR_H__  */
