2017-01-21 12:35:52 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
|
|
|
|
* gimpoperationlayermode.h
|
|
|
|
|
* Copyright (C) 2008 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
|
2018-07-11 14:47:19 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2017-01-21 12:35:52 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __GIMP_OPERATION_LAYER_MODE_H__
|
|
|
|
|
#define __GIMP_OPERATION_LAYER_MODE_H__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <gegl-plugin.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define GIMP_TYPE_OPERATION_LAYER_MODE (gimp_operation_layer_mode_get_type ())
|
|
|
|
|
#define GIMP_OPERATION_LAYER_MODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_LAYER_MODE, GimpOperationLayerMode))
|
|
|
|
|
#define GIMP_OPERATION_LAYER_MODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_LAYER_MODE, GimpOperationLayerModeClass))
|
|
|
|
|
#define GIMP_IS_OPERATION_LAYER_MODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_LAYER_MODE))
|
|
|
|
|
#define GIMP_IS_OPERATION_LAYER_MODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_LAYER_MODE))
|
|
|
|
|
#define GIMP_OPERATION_LAYER_MODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_LAYER_MODE, GimpOperationLayerModeClass))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _GimpOperationLayerModeClass GimpOperationLayerModeClass;
|
|
|
|
|
|
|
|
|
|
struct _GimpOperationLayerMode
|
|
|
|
|
{
|
|
|
|
|
GeglOperationPointComposer3 parent_instance;
|
|
|
|
|
|
2017-01-22 05:41:21 -08:00
|
|
|
GimpLayerMode layer_mode;
|
2017-01-21 12:35:52 -08:00
|
|
|
gdouble opacity;
|
2017-01-22 07:04:46 -08:00
|
|
|
GimpLayerColorSpace blend_space;
|
|
|
|
|
GimpLayerColorSpace composite_space;
|
2017-01-21 12:35:52 -08:00
|
|
|
GimpLayerCompositeMode composite_mode;
|
app: layer mode code shuffling
Commit 3635cf04ab69bafb76d7583da804f580f2d5fbf3 moved the special
handling of bottom-layer compositing to GimpOperationLayerMode.
This required giving the op more control over the process()
function of its subclasses. As a temporary workaround, the commit
bypassed the subclasses entirely, using "gimp:layer-mode" for all
modes. This is the reckoning :)
Add a process() virtual function to GimpOperationLayerMode, which
its subclasses should override instead of
GeglOperationPointComposer3's process() functions. Reinstate the
subclasses (by returning the correct op in
gimp_layer_mode_get_oepration()), and have them override this
function.
Improve the way gimp_operation_layer_mode_process() dispatches to
the actual process function, to slightly lower its overhead and
fix some thread-safety issues.
Remove the "function" field of the layer-mode info array, and have
gimp_layer_mode_get_function() return the
GimpOperationLayerMode::process() function of the corresponding
op's class (caching the result, to keep it cheap.) This reduces
redundancy, allows us to make the ops' process() functions private,
and simplifies SSE dispatching (only used by NORMAL mode,
currently.)
Move the blend and composite functions of the non-specialized
layer modes to gimpoperationlayermode-{blend,composite}.[hc],
respectively, to improve code organization.
Move the SSE2 composite functions to a separate file, so that they
can be built as part of libapplayermodes_sse2, allowing
libapplayermodes to be built without SSE2 compiler flags. This
allows building GIMP with SSE acceleration enabled, while running
the resulting binary on a target with no SSE accelration.
Add a "blend_function" field to the layer-mode info array, and use
it to specify the blend function for the non-specialized modes.
This replaces the separate switch() statement that we used
previously.
Remove the "affected_region" field of the layer-mode info array.
We don't need it anymore, since we can go back to using
GimpOperationLayerMode's virtual get_affected_region() function.
Last but not least, a bunch of code cleanups and consistency
adjustments.
2017-08-17 07:26:49 -07:00
|
|
|
|
|
|
|
|
GimpLayerCompositeMode real_composite_mode;
|
|
|
|
|
GimpLayerModeFunc function;
|
|
|
|
|
GimpLayerModeBlendFunc blend_function;
|
app: move bottom-layer special casing to GimpOperationLayerMode
GimpFilter's is_last_node field only reflects the item's position
within the parent stack. When a layer is contained in a pass-
through group, it can be the last layer of the group, while not
being the last layer in the graph as a whole (paticularly, if
there are visible layers below the group). In fact, when we have
nested pass-through groups, whether or not a layer is the last
node depends on which group we're considering as the root (since
we exclude the backdrop from the group's projection, resulting in
different graphs for different groups).
Instead of rolling our own graph traversal, just move the relevant
logic to GimpOperationLayerMode, and let GEGL do the work for us.
At processing time, we can tell if we're the last node by checking
if we have any input.
For this to work, GimpOperationLayerMode's process() function needs
to have control over what's going on. Replace the derived op
classes, which override process(), with a call to the layer mode's
function (as per gimp_layer_mode_get_function()) in
GimpOperationLayerMode's process() function. (Well, actually, this
commit keeps the ops around, and just hacks around them in
gimp_layer_mode_get_operation(), because laziness :P)
Keep using the layer's is_last_node property to do the invalidation.
2017-04-21 16:42:04 -07:00
|
|
|
gboolean is_last_node;
|
2017-01-21 12:35:52 -08:00
|
|
|
};
|
|
|
|
|
|
app: layer mode code shuffling
Commit 3635cf04ab69bafb76d7583da804f580f2d5fbf3 moved the special
handling of bottom-layer compositing to GimpOperationLayerMode.
This required giving the op more control over the process()
function of its subclasses. As a temporary workaround, the commit
bypassed the subclasses entirely, using "gimp:layer-mode" for all
modes. This is the reckoning :)
Add a process() virtual function to GimpOperationLayerMode, which
its subclasses should override instead of
GeglOperationPointComposer3's process() functions. Reinstate the
subclasses (by returning the correct op in
gimp_layer_mode_get_oepration()), and have them override this
function.
Improve the way gimp_operation_layer_mode_process() dispatches to
the actual process function, to slightly lower its overhead and
fix some thread-safety issues.
Remove the "function" field of the layer-mode info array, and have
gimp_layer_mode_get_function() return the
GimpOperationLayerMode::process() function of the corresponding
op's class (caching the result, to keep it cheap.) This reduces
redundancy, allows us to make the ops' process() functions private,
and simplifies SSE dispatching (only used by NORMAL mode,
currently.)
Move the blend and composite functions of the non-specialized
layer modes to gimpoperationlayermode-{blend,composite}.[hc],
respectively, to improve code organization.
Move the SSE2 composite functions to a separate file, so that they
can be built as part of libapplayermodes_sse2, allowing
libapplayermodes to be built without SSE2 compiler flags. This
allows building GIMP with SSE acceleration enabled, while running
the resulting binary on a target with no SSE accelration.
Add a "blend_function" field to the layer-mode info array, and use
it to specify the blend function for the non-specialized modes.
This replaces the separate switch() statement that we used
previously.
Remove the "affected_region" field of the layer-mode info array.
We don't need it anymore, since we can go back to using
GimpOperationLayerMode's virtual get_affected_region() function.
Last but not least, a bunch of code cleanups and consistency
adjustments.
2017-08-17 07:26:49 -07:00
|
|
|
struct _GimpOperationLayerModeClass
|
|
|
|
|
{
|
|
|
|
|
GeglOperationPointComposer3Class parent_class;
|
|
|
|
|
|
|
|
|
|
/* virtual functions */
|
|
|
|
|
gboolean (* process) (GeglOperation *operation,
|
|
|
|
|
void *in,
|
|
|
|
|
void *aux,
|
|
|
|
|
void *mask,
|
|
|
|
|
void *out,
|
|
|
|
|
glong samples,
|
|
|
|
|
const GeglRectangle *roi,
|
|
|
|
|
gint level);
|
|
|
|
|
|
|
|
|
|
/* Returns the composite region (any combination of the layer and the
|
|
|
|
|
* backdrop) that the layer mode affects. Most modes only affect the
|
|
|
|
|
* overlapping region, and don't need to override this function.
|
|
|
|
|
*/
|
|
|
|
|
GimpLayerCompositeRegion (* get_affected_region) (GimpOperationLayerMode *layer_mode);
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-21 12:35:52 -08:00
|
|
|
|
2017-05-07 12:42:22 -07:00
|
|
|
GType gimp_operation_layer_mode_get_type (void) G_GNUC_CONST;
|
2017-02-02 07:53:09 -08:00
|
|
|
|
2017-05-07 12:42:22 -07:00
|
|
|
GimpLayerCompositeRegion gimp_operation_layer_mode_get_affected_region (GimpOperationLayerMode *layer_mode);
|
2017-01-21 12:35:52 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* __GIMP_OPERATION_LAYER_MODE_H__ */
|