1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __GIMP_DRAWABLE_H__
19 #define __GIMP_DRAWABLE_H__
20 
21 
22 #include "gimpitem.h"
23 
24 
25 #define GIMP_TYPE_DRAWABLE            (gimp_drawable_get_type ())
26 #define GIMP_DRAWABLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DRAWABLE, GimpDrawable))
27 #define GIMP_DRAWABLE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE, GimpDrawableClass))
28 #define GIMP_IS_DRAWABLE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DRAWABLE))
29 #define GIMP_IS_DRAWABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE))
30 #define GIMP_DRAWABLE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DRAWABLE, GimpDrawableClass))
31 
32 
33 typedef struct _GimpDrawablePrivate GimpDrawablePrivate;
34 typedef struct _GimpDrawableClass   GimpDrawableClass;
35 
36 struct _GimpDrawable
37 {
38   GimpItem             parent_instance;
39 
40   GimpDrawablePrivate *private;
41 };
42 
43 struct _GimpDrawableClass
44 {
45   GimpItemClass  parent_class;
46 
47   /*  signals  */
48   void          (* update)                (GimpDrawable         *drawable,
49                                            gint                  x,
50                                            gint                  y,
51                                            gint                  width,
52                                            gint                  height);
53   void          (* format_changed)        (GimpDrawable         *drawable);
54   void          (* alpha_changed)         (GimpDrawable         *drawable);
55   void          (* bounding_box_changed)  (GimpDrawable         *drawable);
56 
57   /*  virtual functions  */
58   gint64        (* estimate_memsize)      (GimpDrawable         *drawable,
59                                            GimpComponentType     component_type,
60                                            gint                  width,
61                                            gint                  height);
62   void          (* update_all)            (GimpDrawable         *drawable);
63   void          (* invalidate_boundary)   (GimpDrawable         *drawable);
64   void          (* get_active_components) (GimpDrawable         *drawable,
65                                            gboolean             *active);
66   GimpComponentMask (* get_active_mask)   (GimpDrawable         *drawable);
67   gboolean      (* supports_alpha)        (GimpDrawable         *drawable);
68   void          (* convert_type)          (GimpDrawable         *drawable,
69                                            GimpImage            *dest_image,
70                                            const Babl           *new_format,
71                                            GimpColorProfile     *dest_profile,
72                                            GeglDitherMethod      layer_dither_type,
73                                            GeglDitherMethod      mask_dither_type,
74                                            gboolean              push_undo,
75                                            GimpProgress         *progress);
76   void          (* apply_buffer)          (GimpDrawable         *drawable,
77                                            GeglBuffer           *buffer,
78                                            const GeglRectangle  *buffer_region,
79                                            gboolean              push_undo,
80                                            const gchar          *undo_desc,
81                                            gdouble               opacity,
82                                            GimpLayerMode         mode,
83                                            GimpLayerColorSpace   blend_space,
84                                            GimpLayerColorSpace   composite_space,
85                                            GimpLayerCompositeMode composite_mode,
86                                            GeglBuffer           *base_buffer,
87                                            gint                  base_x,
88                                            gint                  base_y);
89   GeglBuffer  * (* get_buffer)            (GimpDrawable         *drawable);
90   void          (* set_buffer)            (GimpDrawable         *drawable,
91                                            gboolean              push_undo,
92                                            const gchar          *undo_desc,
93                                            GeglBuffer           *buffer,
94                                            const GeglRectangle  *bounds);
95   GeglRectangle (* get_bounding_box)      (GimpDrawable         *drawable);
96   void          (* push_undo)             (GimpDrawable         *drawable,
97                                            const gchar          *undo_desc,
98                                            GeglBuffer           *buffer,
99                                            gint                  x,
100                                            gint                  y,
101                                            gint                  width,
102                                            gint                  height);
103   void          (* swap_pixels)           (GimpDrawable         *drawable,
104                                            GeglBuffer           *buffer,
105                                            gint                  x,
106                                            gint                  y);
107   GeglNode    * (* get_source_node)       (GimpDrawable         *drawable);
108 };
109 
110 
111 GType           gimp_drawable_get_type           (void) G_GNUC_CONST;
112 
113 GimpDrawable  * gimp_drawable_new                (GType               type,
114                                                   GimpImage          *image,
115                                                   const gchar        *name,
116                                                   gint                offset_x,
117                                                   gint                offset_y,
118                                                   gint                width,
119                                                   gint                height,
120                                                   const Babl         *format);
121 
122 gint64          gimp_drawable_estimate_memsize   (GimpDrawable       *drawable,
123                                                   GimpComponentType   component_type,
124                                                   gint                width,
125                                                   gint                height);
126 
127 void            gimp_drawable_update             (GimpDrawable       *drawable,
128                                                   gint                x,
129                                                   gint                y,
130                                                   gint                width,
131                                                   gint                height);
132 void            gimp_drawable_update_all         (GimpDrawable       *drawable);
133 
134 void           gimp_drawable_invalidate_boundary (GimpDrawable       *drawable);
135 void         gimp_drawable_get_active_components (GimpDrawable       *drawable,
136                                                   gboolean           *active);
137 GimpComponentMask gimp_drawable_get_active_mask  (GimpDrawable       *drawable);
138 
139 gboolean        gimp_drawable_supports_alpha     (GimpDrawable       *drawable);
140 
141 void            gimp_drawable_convert_type       (GimpDrawable       *drawable,
142                                                   GimpImage          *dest_image,
143                                                   GimpImageBaseType   new_base_type,
144                                                   GimpPrecision       new_precision,
145                                                   gboolean            new_has_alpha,
146                                                   GimpColorProfile   *dest_profile,
147                                                   GeglDitherMethod    layer_dither_type,
148                                                   GeglDitherMethod    mask_dither_type,
149                                                   gboolean            push_undo,
150                                                   GimpProgress       *progress);
151 
152 void            gimp_drawable_apply_buffer       (GimpDrawable        *drawable,
153                                                   GeglBuffer          *buffer,
154                                                   const GeglRectangle *buffer_rect,
155                                                   gboolean             push_undo,
156                                                   const gchar         *undo_desc,
157                                                   gdouble              opacity,
158                                                   GimpLayerMode        mode,
159                                                   GimpLayerColorSpace  blend_space,
160                                                   GimpLayerColorSpace  composite_space,
161                                                   GimpLayerCompositeMode composite_mode,
162                                                   GeglBuffer          *base_buffer,
163                                                   gint                 base_x,
164                                                   gint                 base_y);
165 
166 GeglBuffer    * gimp_drawable_get_buffer         (GimpDrawable       *drawable);
167 void            gimp_drawable_set_buffer         (GimpDrawable       *drawable,
168                                                   gboolean            push_undo,
169                                                   const gchar        *undo_desc,
170                                                   GeglBuffer         *buffer);
171 void            gimp_drawable_set_buffer_full    (GimpDrawable       *drawable,
172                                                   gboolean            push_undo,
173                                                   const gchar        *undo_desc,
174                                                   GeglBuffer         *buffer,
175                                                   const GeglRectangle *bounds,
176                                                   gboolean            update);
177 
178 void            gimp_drawable_steal_buffer       (GimpDrawable       *drawable,
179                                                   GimpDrawable       *src_drawable);
180 
181 GeglNode      * gimp_drawable_get_source_node    (GimpDrawable       *drawable);
182 GeglNode      * gimp_drawable_get_mode_node      (GimpDrawable       *drawable);
183 
184 GeglRectangle   gimp_drawable_get_bounding_box   (GimpDrawable       *drawable);
185 gboolean        gimp_drawable_update_bounding_box
186                                                  (GimpDrawable       *drawable);
187 
188 void            gimp_drawable_swap_pixels        (GimpDrawable       *drawable,
189                                                   GeglBuffer         *buffer,
190                                                   gint                x,
191                                                   gint                y);
192 
193 void            gimp_drawable_push_undo          (GimpDrawable       *drawable,
194                                                   const gchar        *undo_desc,
195                                                   GeglBuffer         *buffer,
196                                                   gint                x,
197                                                   gint                y,
198                                                   gint                width,
199                                                   gint                height);
200 
201 const Babl      * gimp_drawable_get_format           (GimpDrawable    *drawable);
202 const Babl      * gimp_drawable_get_format_with_alpha(GimpDrawable    *drawable);
203 const Babl      * gimp_drawable_get_format_without_alpha
204                                                      (GimpDrawable    *drawable);
205 gboolean          gimp_drawable_get_linear           (GimpDrawable    *drawable);
206 gboolean          gimp_drawable_has_alpha            (GimpDrawable    *drawable);
207 GimpImageBaseType gimp_drawable_get_base_type        (GimpDrawable    *drawable);
208 GimpComponentType gimp_drawable_get_component_type   (GimpDrawable    *drawable);
209 GimpPrecision     gimp_drawable_get_precision        (GimpDrawable    *drawable);
210 gboolean          gimp_drawable_is_rgb               (GimpDrawable    *drawable);
211 gboolean          gimp_drawable_is_gray              (GimpDrawable    *drawable);
212 gboolean          gimp_drawable_is_indexed           (GimpDrawable    *drawable);
213 
214 const Babl      * gimp_drawable_get_component_format (GimpDrawable    *drawable,
215                                                       GimpChannelType  channel);
216 gint              gimp_drawable_get_component_index  (GimpDrawable    *drawable,
217                                                       GimpChannelType  channel);
218 
219 const guchar    * gimp_drawable_get_colormap         (GimpDrawable    *drawable);
220 
221 void              gimp_drawable_start_paint          (GimpDrawable    *drawable);
222 gboolean          gimp_drawable_end_paint            (GimpDrawable    *drawable);
223 gboolean          gimp_drawable_flush_paint          (GimpDrawable    *drawable);
224 gboolean          gimp_drawable_is_painting          (GimpDrawable    *drawable);
225 
226 
227 #endif /* __GIMP_DRAWABLE_H__ */
228