|
View:
New views
16 Messages
—
Rating Filter:
Alert me
|
|
|
Review request: Masks support compositeOps and opacityHi, all!
Sorry for not using reviewboard, it doesn't accept git patches and svn creates quite messy patches when a file is moved to a different location =) Well, here is a patch that allows masks to use different compositeOps and opacity. Now a user can choose how a mask will be applied to the layer. It makes sense in some circumstances. You can test it with a test file in attachment. Tetscase: 1) If you set mask's composition to "normal", then a selection will be darker than a background. 2) If you set it to "Alpha darken", then it will dissolve in a background. To achieve this i moved colorspace, composition and opacity stuff from KisLayer to KisBaseNode, therefore masks can use it too. Have i forgotten to move something connected to colorspaces alongside? Waiting for your critique! =) -- Dmitry Kazakov [00_masks_composite_ops.diff] diff --git a/krita/image/CMakeLists.txt b/krita/image/CMakeLists.txt index 5ef43f0..10fd12d 100644 --- a/krita/image/CMakeLists.txt +++ b/krita/image/CMakeLists.txt @@ -74,9 +74,10 @@ set(kritaimage_LIB_SRCS commands/kis_image_props_command.cpp commands/kis_image_resize_command.cpp commands/kis_layer_command.cpp - commands/kis_layer_compositeop_command.cpp - commands/kis_layer_opacity_command.cpp commands/kis_layer_props_command.cpp + commands/kis_node_command.cpp + commands/kis_node_compositeop_command.cpp + commands/kis_node_opacity_command.cpp commands/kis_node_move_command.cpp commands/kis_node_property_list_command.cpp commands/kis_reselect_global_selection_command.cpp diff --git a/krita/image/commands/kis_layer_command.cpp b/krita/image/commands/kis_layer_command.cpp index d409648..f88d278 100644 --- a/krita/image/commands/kis_layer_command.cpp +++ b/krita/image/commands/kis_layer_command.cpp @@ -17,12 +17,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "commands/kis_layer_commands.h" #include <klocale.h> - -#include <KoCompositeOp.h> - #include "kis_layer.h" +#include "commands/kis_layer_commands.h" KisLayerCommand::KisLayerCommand(const QString& name, KisLayerSP layer) : QUndoCommand(name), m_layer(layer) diff --git a/krita/image/commands/kis_layer_command.h b/krita/image/commands/kis_layer_command.h index ee2515e..b661d9c 100644 --- a/krita/image/commands/kis_layer_command.h +++ b/krita/image/commands/kis_layer_command.h @@ -19,14 +19,10 @@ #ifndef KIS_LAYER_COMMAND_H_ #define KIS_LAYER_COMMAND_H_ -#include <krita_export.h> #include <QUndoCommand> -#include <QRect> -#include <QPoint> - +#include <krita_export.h> #include "kis_types.h" -class KoCompositeOp; class KisLayer; /// the base command for commands altering a layer diff --git a/krita/image/commands/kis_layer_commands.h b/krita/image/commands/kis_layer_commands.h index d7deb3c..fafb07f 100644 --- a/krita/image/commands/kis_layer_commands.h +++ b/krita/image/commands/kis_layer_commands.h @@ -20,8 +20,6 @@ #define KIS_LAYER_COMMANDS_H #include "kis_layer_command.h" -#include "kis_layer_compositeop_command.h" -#include "kis_layer_opacity_command.h" #include "kis_layer_props_command.h" #endif diff --git a/krita/image/commands/kis_layer_compositeop_command.cpp b/krita/image/commands/kis_layer_compositeop_command.cpp deleted file mode 100644 index 406fcff..0000000 --- a/krita/image/commands/kis_layer_compositeop_command.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2002 Patrick Julien <freak@...> - * Copyright (c) 2005 Casper Boemann <cbr@...> - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "commands/kis_layer_commands.h" -#include <klocale.h> - -#include <KoCompositeOp.h> - -#include "kis_layer.h" - -KisLayerCompositeOpCommand::KisLayerCompositeOpCommand(KisLayerSP layer, const QString& oldCompositeOp, - const QString& newCompositeOp) : - KisLayerCommand(i18n("Layer Composite Mode"), layer) -{ - m_oldCompositeOp = oldCompositeOp; - m_newCompositeOp = newCompositeOp; -} - -void KisLayerCompositeOpCommand::redo() -{ - m_layer->setCompositeOp(m_newCompositeOp); - m_layer->setDirty(); -} - -void KisLayerCompositeOpCommand::undo() -{ - m_layer->setCompositeOp(m_oldCompositeOp); - m_layer->setDirty(); -} diff --git a/krita/image/commands/kis_layer_compositeop_command.h b/krita/image/commands/kis_layer_compositeop_command.h deleted file mode 100644 index bab1f49..0000000 --- a/krita/image/commands/kis_layer_compositeop_command.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2002 Patrick Julien <freak@...> - * Copyright (c) 2005 Casper Boemann <cbr@...> - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#ifndef KIS_LAYER_COMPOSITEOP_COMMAND_H -#define KIS_LAYER_COMPOSITEOP_COMMAND_H - -#include <krita_export.h> -#include <QUndoCommand> -#include <QRect> -#include <QPoint> - -#include "kis_types.h" -#include "kis_layer_command.h" - -class KoCompositeOp; -class KisLayer; - -/// The command for setting the composite op -class KRITAIMAGE_EXPORT KisLayerCompositeOpCommand : public KisLayerCommand -{ - -public: - /** - * Constructor - * @param layer The layer the command will be working on. - * @param oldCompositeOp the old layer composite op - * @param newCompositeOp the new layer composite op - */ - KisLayerCompositeOpCommand(KisLayerSP layer, const QString& oldCompositeOp, const QString& newCompositeOp); - - virtual void redo(); - virtual void undo(); - -private: - QString m_oldCompositeOp; - QString m_newCompositeOp; -}; -#endif - diff --git a/krita/image/commands/kis_layer_opacity_command.cpp b/krita/image/commands/kis_layer_opacity_command.cpp deleted file mode 100644 index 3d98fdf..0000000 --- a/krita/image/commands/kis_layer_opacity_command.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2002 Patrick Julien <freak@...> - * Copyright (c) 2005 Casper Boemann <cbr@...> - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "commands/kis_layer_commands.h" -#include <klocale.h> - -#include <KoCompositeOp.h> - -#include "kis_layer.h" - -KisLayerOpacityCommand::KisLayerOpacityCommand(KisLayerSP layer, quint8 oldOpacity, quint8 newOpacity) : - KisLayerCommand(i18n("Layer Opacity"), layer) -{ - m_oldOpacity = oldOpacity; - m_newOpacity = newOpacity; -} - -void KisLayerOpacityCommand::redo() -{ - m_layer->setOpacity(m_newOpacity); - m_layer->setDirty(); -} - -void KisLayerOpacityCommand::undo() -{ - m_layer->setOpacity(m_oldOpacity); - m_layer->setDirty(); -} diff --git a/krita/image/commands/kis_layer_opacity_command.h b/krita/image/commands/kis_layer_opacity_command.h deleted file mode 100644 index bd43a98..0000000 --- a/krita/image/commands/kis_layer_opacity_command.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2002 Patrick Julien <freak@...> - * Copyright (c) 2005 Casper Boemann <cbr@...> - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#ifndef KIS_LAYER_OPACITY_COMMAND_H -#define KIS_LAYER_OPACITY_COMMAND_H - -#include <krita_export.h> -#include <QUndoCommand> -#include <QRect> -#include <QPoint> - -#include "kis_types.h" -#include "kis_layer_command.h" - -class KoCompositeOp; -class KisLayer; - -/// The command for setting the layer opacity -class KRITAIMAGE_EXPORT KisLayerOpacityCommand : public KisLayerCommand -{ - -public: - /** - * Constructor - * @param layer The layer the command will be working on. - * @param oldOpacity the old layer opacity - * @param newOpacity the new layer opacity - */ - KisLayerOpacityCommand(KisLayerSP layer, quint8 oldOpacity, quint8 newOpacity); - - virtual void redo(); - virtual void undo(); - -private: - quint8 m_oldOpacity; - quint8 m_newOpacity; -}; - -#endif diff --git a/krita/image/commands/kis_node_command.cpp b/krita/image/commands/kis_node_command.cpp new file mode 100644 index 0000000..876f99b --- /dev/null +++ b/krita/image/commands/kis_node_command.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2002 Patrick Julien <freak@...> + * Copyright (c) 2005 Casper Boemann <cbr@...> + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "commands/kis_node_command.h" + +#include "kis_node.h" + +KisNodeCommand::KisNodeCommand(const QString& name, KisNodeSP node) + : QUndoCommand(name), m_node(node) +{ +} + +KisNodeCommand::~KisNodeCommand() +{ +} diff --git a/krita/image/commands/kis_node_command.h b/krita/image/commands/kis_node_command.h new file mode 100644 index 0000000..8d780d9 --- /dev/null +++ b/krita/image/commands/kis_node_command.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2002 Patrick Julien <freak@...> + * Copyright (c) 2005 Casper Boemann <cbr@...> + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef KIS_NODE_COMMAND_H_ +#define KIS_NODE_COMMAND_H_ + +#include <krita_export.h> +#include <QUndoCommand> +#include "kis_types.h" + +class KisNode; + +/// the base command for commands altering a node +class KRITAIMAGE_EXPORT KisNodeCommand : public QUndoCommand +{ + +public: + /** + * Constructor + * @param name The name that will be shown in the ui + * @param node The node the command will be working on. + */ + KisNodeCommand(const QString& name, KisNodeSP node); + virtual ~KisNodeCommand(); + +protected: + KisNodeSP m_node; +}; + +#endif /* KIS_NODE_COMMAND_H_*/ diff --git a/krita/image/commands/kis_node_commands.h b/krita/image/commands/kis_node_commands.h index 368eb62..680beb3 100644 --- a/krita/image/commands/kis_node_commands.h +++ b/krita/image/commands/kis_node_commands.h @@ -22,6 +22,8 @@ #include "kis_change_filter_command.h" #include "kis_change_generator_command.h" #include "kis_node_move_command.h" +#include "kis_node_compositeop_command.h" +#include "kis_node_opacity_command.h" #endif diff --git a/krita/image/commands/kis_node_compositeop_command.cpp b/krita/image/commands/kis_node_compositeop_command.cpp new file mode 100644 index 0000000..4403b81 --- /dev/null +++ b/krita/image/commands/kis_node_compositeop_command.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2002 Patrick Julien <freak@...> + * Copyright (c) 2005 Casper Boemann <cbr@...> + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <klocale.h> +#include <KoCompositeOp.h> +#include "kis_node.h" +#include "commands/kis_node_commands.h" + + +KisNodeCompositeOpCommand::KisNodeCompositeOpCommand(KisNodeSP node, const QString& oldCompositeOp, + const QString& newCompositeOp) : + KisNodeCommand(i18n("Node Composite Mode"), node) +{ + m_oldCompositeOp = oldCompositeOp; + m_newCompositeOp = newCompositeOp; +} + +void KisNodeCompositeOpCommand::redo() +{ + m_node->setCompositeOp(m_newCompositeOp); + m_node->setDirty(); +} + +void KisNodeCompositeOpCommand::undo() +{ + m_node->setCompositeOp(m_oldCompositeOp); + m_node->setDirty(); +} diff --git a/krita/image/commands/kis_node_compositeop_command.h b/krita/image/commands/kis_node_compositeop_command.h new file mode 100644 index 0000000..705357d --- /dev/null +++ b/krita/image/commands/kis_node_compositeop_command.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2002 Patrick Julien <freak@...> + * Copyright (c) 2005 Casper Boemann <cbr@...> + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef KIS_NODE_COMPOSITEOP_COMMAND_H +#define KIS_NODE_COMPOSITEOP_COMMAND_H + +#include "kis_node_command.h" + + +/// The command for setting the composite op +class KRITAIMAGE_EXPORT KisNodeCompositeOpCommand : public KisNodeCommand +{ + +public: + /** + * Constructor + * @param node The node the command will be working on. + * @param oldCompositeOp the old node composite op + * @param newCompositeOp the new node composite op + */ + KisNodeCompositeOpCommand(KisNodeSP node, const QString& oldCompositeOp, const QString& newCompositeOp); + + virtual void redo(); + virtual void undo(); + +private: + QString m_oldCompositeOp; + QString m_newCompositeOp; +}; + +#endif /* KIS_NODE_COMPOSITEOP_COMMAND_H */ diff --git a/krita/image/commands/kis_node_move_command.cpp b/krita/image/commands/kis_node_move_command.cpp index 62b8118..d9f5aff 100644 --- a/krita/image/commands/kis_node_move_command.cpp +++ b/krita/image/commands/kis_node_move_command.cpp @@ -17,12 +17,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "kis_node_commands.h" +#include <klocale.h> +#include <QPoint> +#include <QRect> #include "kis_node.h" +#include "commands/kis_node_move_command.h" + KisNodeMoveCommand::KisNodeMoveCommand(KisNodeSP node, const QPoint& oldpos, const QPoint& newpos) : - QUndoCommand(i18n("Move")), - m_node(node) + KisNodeCommand(i18n("Move"), node) { m_oldPos = oldpos; m_newPos = newpos; diff --git a/krita/image/commands/kis_node_move_command.h b/krita/image/commands/kis_node_move_command.h index 0468c9f..45c03ed 100644 --- a/krita/image/commands/kis_node_move_command.h +++ b/krita/image/commands/kis_node_move_command.h @@ -18,15 +18,12 @@ #ifndef KIS_NODE_MOVE_COMMAND_H #define KIS_NODE_MOVE_COMMAND_H -#include <krita_export.h> -#include <QUndoCommand> -#include <QRect> -#include "kis_types.h" -#include <klocale.h> -#include "filter/kis_filter_configuration.h" +#include "kis_node_command.h" + +class QPoint; /// The command for moving of a node -class KRITAIMAGE_EXPORT KisNodeMoveCommand : public QUndoCommand +class KRITAIMAGE_EXPORT KisNodeMoveCommand : public KisNodeCommand { public: @@ -46,7 +43,6 @@ private: void moveTo(const QPoint& pos); private: - KisNodeSP m_node; QRect m_updateRect; QPoint m_oldPos; QPoint m_newPos; diff --git a/krita/image/commands/kis_node_opacity_command.cpp b/krita/image/commands/kis_node_opacity_command.cpp new file mode 100644 index 0000000..2d445ac --- /dev/null +++ b/krita/image/commands/kis_node_opacity_command.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2002 Patrick Julien <freak@...> + * Copyright (c) 2005 Casper Boemann <cbr@...> + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <klocale.h> +#include "kis_node.h" +#include "commands/kis_node_opacity_command.h" + + +KisNodeOpacityCommand::KisNodeOpacityCommand(KisNodeSP node, quint8 oldOpacity, quint8 newOpacity) : + KisNodeCommand(i18n("Node Opacity"), node) +{ + m_oldOpacity = oldOpacity; + m_newOpacity = newOpacity; +} + +void KisNodeOpacityCommand::redo() +{ + m_node->setOpacity(m_newOpacity); + m_node->setDirty(); +} + +void KisNodeOpacityCommand::undo() +{ + m_node->setOpacity(m_oldOpacity); + m_node->setDirty(); +} diff --git a/krita/image/commands/kis_node_opacity_command.h b/krita/image/commands/kis_node_opacity_command.h new file mode 100644 index 0000000..d296f4a --- /dev/null +++ b/krita/image/commands/kis_node_opacity_command.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2002 Patrick Julien <freak@...> + * Copyright (c) 2005 Casper Boemann <cbr@...> + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef KIS_NODE_OPACITY_COMMAND_H +#define KIS_NODE_OPACITY_COMMAND_H + +#include "kis_node_command.h" + + +/// The command for setting the node opacity +class KRITAIMAGE_EXPORT KisNodeOpacityCommand : public KisNodeCommand +{ + +public: + /** + * Constructor + * @param node The node the command will be working on. + * @param oldOpacity the old node opacity + * @param newOpacity the new node opacity + */ + KisNodeOpacityCommand(KisNodeSP node, quint8 oldOpacity, quint8 newOpacity); + + virtual void redo(); + virtual void undo(); + +private: + quint8 m_oldOpacity; + quint8 m_newOpacity; +}; + +#endif /* KIS_NODE_OPACITY_COMMAND_H */ diff --git a/krita/image/commands/kis_node_property_list_command.cpp b/krita/image/commands/kis_node_property_list_command.cpp index e8932b4..7d22d34 100644 --- a/krita/image/commands/kis_node_property_list_command.cpp +++ b/krita/image/commands/kis_node_property_list_command.cpp @@ -16,16 +16,20 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "kis_node_property_list_command.h" -#include <QString> - #include <klocale.h> +#include "kis_node.h" +#include "commands/kis_node_property_list_command.h" -#include "kis_image.h" -#include "kis_undo_adapter.h" KisNodePropertyListCommand::KisNodePropertyListCommand(KisNodeSP node, KoDocumentSectionModel::PropertyList newPropertyList) - : QUndoCommand(i18n("Property Changes")), m_node(node), m_newPropertyList(newPropertyList), m_oldPropertyList(m_node->sectionModelProperties()) // TODO instead of "Property Changes" check which property has been changed and display either lock/unlock, visible/hidden or "Property Changes" (this require new strings) + : KisNodeCommand(i18n("Property Changes"), node), + m_newPropertyList(newPropertyList), + m_oldPropertyList(node->sectionModelProperties()) +/** + * TODO instead of "Property Changes" check which property + * has been changed and display either lock/unlock, visible/hidden + * or "Property Changes" (this require new strings) + */ { } diff --git a/krita/image/commands/kis_node_property_list_command.h b/krita/image/commands/kis_node_property_list_command.h index 1211c42..8e494a9 100644 --- a/krita/image/commands/kis_node_property_list_command.h +++ b/krita/image/commands/kis_node_property_list_command.h @@ -19,15 +19,12 @@ #ifndef KIS_IMAGE_NODE_PROPERTY_LIST_COMMAND_H_ #define KIS_IMAGE_NODE_PROPERTY_LIST_COMMAND_H_ -#include <krita_export.h> - -#include "kis_types.h" -#include "kis_image_command.h" +#include "kis_node_command.h" #include "KoDocumentSectionModel.h" /// The command for changing the property list of a layer -class KRITAIMAGE_EXPORT KisNodePropertyListCommand : public QUndoCommand +class KRITAIMAGE_EXPORT KisNodePropertyListCommand : public KisNodeCommand { public: @@ -41,7 +38,6 @@ public: virtual void undo(); private: - KisNodeSP m_node; KoDocumentSectionModel::PropertyList m_newPropertyList; KoDocumentSectionModel::PropertyList m_oldPropertyList; }; diff --git a/krita/image/kis_base_node.cpp b/krita/image/kis_base_node.cpp index 7b2fae1..c4e3cf3 100644 --- a/krita/image/kis_base_node.cpp +++ b/krita/image/kis_base_node.cpp @@ -20,12 +20,15 @@ #include <klocale.h> #include <KoProperties.h> +#include <KoColorSpace.h> +#include <KoCompositeOp.h> #include "kis_paint_device.h" class KisBaseNode::Private { public: + QString compositeOp; KoProperties properties; KisBaseNodeSP linkedTo; bool systemLocked; @@ -38,6 +41,7 @@ KisBaseNode::KisBaseNode() setUserLocked(false); setSystemLocked(false); m_d->linkedTo = 0; + m_d->compositeOp = COMPOSITE_OVER; } @@ -52,6 +56,7 @@ KisBaseNode::KisBaseNode(const KisBaseNode & rhs) m_d->properties.setProperty(iter.key(), iter.value()); } m_d->linkedTo = rhs.m_d->linkedTo; + m_d->compositeOp = rhs.m_d->compositeOp; } KisBaseNode::~KisBaseNode() @@ -74,6 +79,40 @@ KisPaintDeviceSP KisBaseNode::projection() const return 0; } +quint8 KisBaseNode::opacity() const +{ + return nodeProperties().intProperty("opacity", OPACITY_OPAQUE); +} + +void KisBaseNode::setOpacity(quint8 val) +{ + if (opacity() != val) { + nodeProperties().setProperty("opacity", val); + } +} + +quint8 KisBaseNode::percentOpacity() const +{ + return int(float(opacity() * 100) / 255 + 0.5); +} + +void KisBaseNode::setPercentOpacity(quint8 val) +{ + setOpacity(int(float(val * 255) / 100 + 0.5)); +} + +const QString& KisBaseNode::compositeOpId() const +{ + return m_d->compositeOp; +} + +/** + * FIXME: Rename this function to setCompositeOpId() + */ +void KisBaseNode::setCompositeOp(const QString& compositeOp) +{ + m_d->compositeOp = compositeOp; +} KoDocumentSectionModel::PropertyList KisBaseNode::sectionModelProperties() const { diff --git a/krita/image/kis_base_node.h b/krita/image/kis_base_node.h index 915b0ce..d094315 100644 --- a/krita/image/kis_base_node.h +++ b/krita/image/kis_base_node.h @@ -27,7 +27,8 @@ #include "KoDocumentSectionModel.h" class KoProperties; - +class KoColorSpace; +class KoCompositeOp; class KisNodeVisitor; /** @@ -86,6 +87,49 @@ public: */ virtual KisPaintDeviceSP projection() const; + virtual const KoColorSpace * colorSpace() const = 0; + + /** + * Return the opacity of this layer, scaled to a range between 0 + * and 255. + * XXX: Allow true float opacity + */ + quint8 opacity() const; //0-255 + + /** + * Set the opacity for this layer. The range is between 0 and 255. + * The layer will be marked dirty. + * + * XXX: Allow true float opacity + */ + void setOpacity(quint8 val); //0-255 + + /** + * return the 8-bit opacity of this layer scaled to the range + * 0-100 + * + * XXX: Allow true float opacity + */ + quint8 percentOpacity() const; //0-100 + + /** + * Set the opacity of this layer with a number between 0 and 100; + * the number will be scaled to between 0 and 255. + * XXX: Allow true float opacity + */ + void setPercentOpacity(quint8 val); //0-100 + + /** + * Return the composite op associated with this layer. + */ + virtual const KoCompositeOp * compositeOp() const = 0; + const QString& compositeOpId() const; + + /** + * Set a new composite op for this layer. The layer will be marked + * dirty. + */ + void setCompositeOp(const QString& compositeOpId); /** * return the name of this node. This is the same as the diff --git a/krita/image/kis_layer.cc b/krita/image/kis_layer.cc index 4d1d2a5..d90c45b 100644 --- a/krita/image/kis_layer.cc +++ b/krita/image/kis_layer.cc @@ -51,7 +51,6 @@ public: KisImageWSP image; QBitArray channelFlags; - QString compositeOp; KisEffectMaskSP previewMask; KisMetaData::Store* metaDataStore; KisPaintDeviceSP projection; @@ -65,7 +64,6 @@ KisLayer::KisLayer(KisImageWSP img, const QString &name, quint8 opacity) setName(name); setOpacity(opacity); m_d->image = img; - m_d->compositeOp = COMPOSITE_OVER; m_d->metaDataStore = new KisMetaData::Store(); } @@ -75,7 +73,6 @@ KisLayer::KisLayer(const KisLayer& rhs) { if (this != &rhs) { m_d->image = rhs.m_d->image; - m_d->compositeOp = rhs.m_d->compositeOp; m_d->metaDataStore = new KisMetaData::Store(*rhs.m_d->metaDataStore); } } @@ -93,6 +90,23 @@ const KoColorSpace * KisLayer::colorSpace() const return 0; } +const KoCompositeOp * KisLayer::compositeOp() const +{ + /** + * FIXME: This function duplicates the same function from + * KisMask. We can't move it to KisBaseNode as it doesn't + * know anything about parent() method of KisNode + * Please think it over... + */ + + KisNodeSP parentNode = parent(); + if (!parentNode) return 0; + + if (!parentNode->colorSpace()) return 0; + const KoCompositeOp* op = parentNode->colorSpace()->compositeOp(compositeOpId()); + return op ? op : parentNode->colorSpace()->compositeOp(COMPOSITE_OVER); +} + KoDocumentSectionModel::PropertyList KisLayer::sectionModelProperties() const { KoDocumentSectionModel::PropertyList l = KisBaseNode::sectionModelProperties(); @@ -121,28 +135,6 @@ QBitArray & KisLayer::channelFlags() const return m_d->channelFlags; } -quint8 KisLayer::opacity() const -{ - return nodeProperties().intProperty("opacity", OPACITY_OPAQUE); -} - -void KisLayer::setOpacity(quint8 val) -{ - if (opacity() != val) { - nodeProperties().setProperty("opacity", val); - } -} - -quint8 KisLayer::percentOpacity() const -{ - return int(float(opacity() * 100) / 255 + 0.5); -} - -void KisLayer::setPercentOpacity(quint8 val) -{ - setOpacity(int(float(val * 255) / 100 + 0.5)); -} - bool KisLayer::temporary() const { return nodeProperties().boolProperty("temporary", false); @@ -153,27 +145,6 @@ void KisLayer::setTemporary(bool t) nodeProperties().setProperty("temporary", t); } -const QString& KisLayer::compositeOpId() const -{ - return m_d->compositeOp; -} - -const KoCompositeOp * KisLayer::compositeOp() const -{ - KisLayerSP parent = parentLayer(); - if (!parent) { - return 0; - } - const KoCompositeOp* op = parent->colorSpace()->compositeOp(m_d->compositeOp); - if (op) return op; - return parent->colorSpace()->compositeOp(COMPOSITE_OVER); -} - -void KisLayer::setCompositeOp(const QString& compositeOp) -{ - m_d->compositeOp = compositeOp; -} - KisImageWSP KisLayer::image() const { return m_d->image; diff --git a/krita/image/kis_layer.h b/krita/image/kis_layer.h index d209c5d..2964b8c 100644 --- a/krita/image/kis_layer.h +++ b/krita/image/kis_layer.h @@ -38,8 +38,6 @@ class QStack; class QIcon; class QBitArray; -class KoColorSpace; -class KoCompositeOp; class KisGroupLayer; class KisNodeVisitor; @@ -71,7 +69,8 @@ public: KisLayer(const KisLayer& rhs); virtual ~KisLayer(); - virtual const KoColorSpace * colorSpace() const; + const KoColorSpace * colorSpace() const; + const KoCompositeOp * compositeOp() const; /** * Ask the layer to assemble its data & apply all the effect masks @@ -130,37 +129,6 @@ public: */ QBitArray & channelFlags() const; - - /** - * Return the opacity of this layer, scaled to a range between 0 - * and 255. - * XXX: Allow true float opacity - */ - quint8 opacity() const; //0-255 - - /** - * Set the opacity for this layer. The range is between 0 and 255. - * The layer will be marked dirty. - * - * XXX: Allow true float opacity - */ - void setOpacity(quint8 val); //0-255 - - /** - * return the 8-bit opacity of this layer scaled to the range - * 0-100 - * - * XXX: Allow true float opacity - */ - quint8 percentOpacity() const; //0-100 - - /** - * Set the opacity of this layer with a number between 0 and 100; - * the number will be scaled to between 0 and 255. - * XXX: Allow true float opacity - */ - void setPercentOpacity(quint8 val); //0-100 - /** * Returns true if this layer is temporary: i.e., it should not * appear in the layerbox, even though it is temporarily in the @@ -175,19 +143,6 @@ public: */ void setTemporary(bool t); - /** - * Return the composite op associated with this layer. - */ - const KoCompositeOp * compositeOp() const; - const QString& compositeOpId() const; - - /** - * Set a new composite op for this layer. The layer will be marked - * dirty. - */ - void setCompositeOp(const QString& compositeOpId); - - KisImageWSP image() const; /** diff --git a/krita/image/kis_mask.cc b/krita/image/kis_mask.cc index 0b7b859..63c5cee 100644 --- a/krita/image/kis_mask.cc +++ b/krita/image/kis_mask.cc @@ -57,6 +57,29 @@ KisMask::~KisMask() delete m_d; } +const KoColorSpace * KisMask::colorSpace() const +{ + KisNodeSP parentNode = parent(); + return parentNode ? parentNode->colorSpace() : 0; +} + +const KoCompositeOp * KisMask::compositeOp() const +{ + /** + * FIXME: This function duplicates the same function from + * KisLayer. We can't move it to KisBaseNode as it doesn't + * know anything about parent() method of KisNode + * Please think it over... + */ + + KisNodeSP parentNode = parent(); + if (!parentNode) return 0; + + if (!parentNode->colorSpace()) return 0; + const KoCompositeOp* op = parentNode->colorSpace()->compositeOp(compositeOpId()); + return op ? op : parentNode->colorSpace()->compositeOp(COMPOSITE_OVER); +} + KisSelectionSP KisMask::selection() const { if (!m_d->selection) { @@ -117,7 +140,8 @@ void KisMask::apply(KisPaintDeviceSP projection, const QRect & rc) const * FIXME: ALPHA_DARKEN vs OVER */ KisPainter gc(projection); - gc.setCompositeOp(projection->colorSpace()->compositeOp(COMPOSITE_OVER)); + gc.setCompositeOp(compositeOp()); + gc.setOpacity(opacity()); gc.setSelection(m_d->selection); gc.bitBlt(updatedRect.topLeft(), cacheDevice, updatedRect); } else { diff --git a/krita/image/kis_mask.h b/krita/image/kis_mask.h index 73da84c..8949995 100644 --- a/krita/image/kis_mask.h +++ b/krita/image/kis_mask.h @@ -82,6 +82,9 @@ public: virtual ~KisMask(); + const KoColorSpace * colorSpace() const; + const KoCompositeOp * compositeOp() const; + /** * Return the selection associated with this mask. A selection can * contain both a paint device and shapes. diff --git a/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp b/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp index c08a68a..ceeb2e0 100644 --- a/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp +++ b/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp @@ -425,8 +425,7 @@ void KisLayerBox::slotPropertiesClicked() void KisLayerBox::slotDuplicateClicked() { - if (KisNodeSP active = m_nodeManager->activeNode()) - m_nodeManager->duplicateActiveNode(active); + m_nodeManager->duplicateActiveNode(); } void KisLayerBox::slotNodeActivated(const QModelIndex & node) diff --git a/krita/ui/kis_layer_manager.cc b/krita/ui/kis_layer_manager.cc index db5ff99..2cdeae6 100644 --- a/krita/ui/kis_layer_manager.cc +++ b/krita/ui/kis_layer_manager.cc @@ -213,34 +213,6 @@ void KisLayerManager::imgResizeToActiveLayer() } } -void KisLayerManager::layerCompositeOp(const KoCompositeOp* compositeOp) -{ - KisLayerSP layer = activeLayer(); - if (!layer) return; - - m_doc->addCommand(new KisLayerCompositeOpCommand(layer, layer->compositeOpId(), compositeOp->id())); -} - -// range: 0 - 100 -void KisLayerManager::layerOpacity(double opacity, bool final) -{ - KisLayerSP layer = activeLayer(); - if (!layer) return; - - opacity = int(opacity * 2.55 + 0.5); - if (opacity > 255) - opacity = 255; - - if (opacity == layer->opacity()) return; - - if (!final) { - layer->setOpacity(static_cast<int>(opacity)); - layer->setDirty(); - } else { - m_doc->addCommand(new KisLayerOpacityCommand(layer, layer->opacity(), static_cast<int>(opacity))); - } -} - void KisLayerManager::actLayerVisChanged(int show) { m_actLayerVis = (show != 0); diff --git a/krita/ui/kis_layer_manager.h b/krita/ui/kis_layer_manager.h index c8d2145..84e680c 100644 --- a/krita/ui/kis_layer_manager.h +++ b/krita/ui/kis_layer_manager.h @@ -74,8 +74,6 @@ public slots: void imgResizeToActiveLayer(); - void layerCompositeOp(const KoCompositeOp* compositeOp); - void layerOpacity(double opacity, bool final); void actLayerVisChanged(int show); void layerProperties(); diff --git a/krita/ui/kis_node_commands_adapter.cpp b/krita/ui/kis_node_commands_adapter.cpp index 178edd3..fccf354 100644 --- a/krita/ui/kis_node_commands_adapter.cpp +++ b/krita/ui/kis_node_commands_adapter.cpp @@ -18,6 +18,7 @@ #include "./kis_node_commands_adapter.h" +#include <KoCompositeOp.h> #include "kis_undo_adapter.h" #include "kis_image.h" #include "commands/kis_image_layer_add_command.h" @@ -27,6 +28,7 @@ #include "commands/kis_image_node_raise_command.h" #include "commands/kis_image_node_to_bottom_command.h" #include "commands/kis_image_node_to_top_command.h" +#include "commands/kis_node_commands.h" #include "kis_view2.h" KisNodeCommandsAdapter::KisNodeCommandsAdapter(KisView2 * view) @@ -106,6 +108,22 @@ void KisNodeCommandsAdapter::toTop(KisNodeSP node) m_view->image()->undoAdapter()->addCommand(new KisImageNodeToTopCommand(m_view->image(), node)); } +void KisNodeCommandsAdapter::setOpacity(KisNodeSP node, qint32 opacity) +{ + Q_ASSERT(m_view->image()->undoAdapter()); + m_view->image()->undoAdapter()->addCommand( + new KisNodeOpacityCommand(node, node->opacity(), opacity)); +} + +void KisNodeCommandsAdapter::setCompositeOp(KisNodeSP node, + const KoCompositeOp* compositeOp) +{ + Q_ASSERT(m_view->image()->undoAdapter()); + m_view->image()->undoAdapter()->addCommand( + new KisNodeCompositeOpCommand(node, node->compositeOpId(), + compositeOp->id())); +} + void KisNodeCommandsAdapter::undoLastCommand() { Q_ASSERT(m_view->image()->undoAdapter()); diff --git a/krita/ui/kis_node_commands_adapter.h b/krita/ui/kis_node_commands_adapter.h index 46a8df0..182cd65 100644 --- a/krita/ui/kis_node_commands_adapter.h +++ b/krita/ui/kis_node_commands_adapter.h @@ -20,6 +20,7 @@ #define KIS_NODE_COMMANDS_ADAPTER_H class KisView2; +class KoCompositeOp; #include <kis_types.h> #include <krita_export.h> @@ -49,6 +50,8 @@ public: void raise(KisNodeSP node); void toBottom(KisNodeSP node); void toTop(KisNodeSP node); + void setOpacity(KisNodeSP node, qint32 opacity); + void setCompositeOp(KisNodeSP node, const KoCompositeOp* compositeOp); void undoLastCommand(); private: diff --git a/krita/ui/kis_node_manager.cpp b/krita/ui/kis_node_manager.cpp index f70f645..13a29a7 100644 --- a/krita/ui/kis_node_manager.cpp +++ b/krita/ui/kis_node_manager.cpp @@ -109,21 +109,12 @@ KisNodeSP KisNodeManager::activeNode() return m_d->activeNode; } -KisPaintDeviceSP KisNodeManager::activePaintDevice() -{ - if (m_d->maskManager->activeMask()) { - return m_d->maskManager->activeDevice(); - } else { - return m_d->layerManager->activeDevice(); - } -} - const KoColorSpace* KisNodeManager::activeColorSpace() { Q_ASSERT(m_d->maskManager); if (m_d->maskManager->activeDevice()) { - Q_ASSERT(m_d->maskManager->activeDevice()); +// Q_ASSERT(m_d->maskManager->activeDevice()); return m_d->maskManager->activeDevice()->colorSpace(); } else { Q_ASSERT(m_d->layerManager); @@ -332,6 +323,13 @@ void KisNodeManager::nodesUpdated() } +KisPaintDeviceSP KisNodeManager::activePaintDevice() +{ + return m_d->maskManager->activeMask() ? + m_d->maskManager->activeDevice() : + m_d->layerManager->activeDevice(); +} + void KisNodeManager::nodeProperties(KisNodeSP node) { if (node->inherits("KisLayer")) { @@ -341,18 +339,60 @@ void KisNodeManager::nodeProperties(KisNodeSP node) } } -void KisNodeManager::nodeOpacityChanged(qreal opacity, bool final) +qint32 KisNodeManager::convertOpacityToInt(qreal opacity) { - m_d->layerManager->layerOpacity(opacity, final); + /** + * Scales opacity from the range 0...1 + * to the integer range 0...255 + */ + + return qMin(255, int(opacity * 2.55 + 0.5)); +} + +void KisNodeManager::setNodeOpacity(KisNodeSP node, qint32 opacity, + bool finalChange) +{ + if (!node) return; + if (node->opacity() == opacity) return; + + if (!finalChange) { + node->setOpacity(opacity); + node->setDirty(); + } else { + m_d->commandsAdapter->setOpacity(node, opacity); + } +} + +void KisNodeManager::setNodeCompositeOp(KisNodeSP node, + const KoCompositeOp* compositeOp) +{ + if (!node) return; + if (node->compositeOp() == compositeOp) return; + + m_d->commandsAdapter->setCompositeOp(node, compositeOp); +} + +void KisNodeManager::nodeOpacityChanged(qreal opacity, bool finalChange) +{ + KisNodeSP node = activeNode(); + + setNodeOpacity(node, convertOpacityToInt(opacity), finalChange); } void KisNodeManager::nodeCompositeOpChanged(const KoCompositeOp* op) { - m_d->layerManager->layerCompositeOp(op); + KisNodeSP node = activeNode(); + + setNodeCompositeOp(node, op); } -void KisNodeManager::duplicateActiveNode(KisNodeSP node) +void KisNodeManager::duplicateActiveNode() { + KisNodeSP node = activeNode(); + + // FIXME: can't imagine how it may happen + Q_ASSERT(node); + if (node->inherits("KisLayer")) { m_d->layerManager->layerDuplicate(); } else if (node->inherits("KisMask")) { @@ -415,19 +455,21 @@ void KisNodeManager::removeNode(KisNodeSP node) void KisNodeManager::mirrorNodeX() { - if (m_d->maskManager->activeMask()) { - return m_d->maskManager->mirrorMaskX(); - } else { - return m_d->layerManager->mirrorLayerX(); + KisNodeSP node = activeNode(); + if (node->inherits("KisLayer")) { + m_d->layerManager->mirrorLayerX(); + } else if (node->inherits("KisMask")) { + m_d->maskManager->mirrorMaskX(); } } void KisNodeManager::mirrorNodeY() { - if (m_d->maskManager->activeMask()) { - return m_d->maskManager->mirrorMaskY(); - } else { - return m_d->layerManager->mirrorLayerY(); + KisNodeSP node = activeNode(); + if (node->inherits("KisLayer")) { + m_d->layerManager->mirrorLayerY(); + } else if (node->inherits("KisMask")) { + m_d->maskManager->mirrorMaskY(); } } diff --git a/krita/ui/kis_node_manager.h b/krita/ui/kis_node_manager.h index 4168dd0..dadea43 100644 --- a/krita/ui/kis_node_manager.h +++ b/krita/ui/kis_node_manager.h @@ -69,6 +69,16 @@ public: */ const KoColorSpace* activeColorSpace(); + /** + * Sets opacity for the node in a universal way (masks/layers) + */ + void setNodeOpacity(KisNodeSP node, qint32 opacity, bool finalChange); + + /** + * Sets compositeOp for the node in a universal way (masks/layers) + */ + void setNodeCompositeOp(KisNodeSP node, const KoCompositeOp* compositeOp); + /// Get the class that manages the layer user interface KisLayerManager * layerManager(); @@ -89,9 +99,9 @@ public slots: void activateNode(KisNodeSP layer); void nodesUpdated(); void nodeProperties(KisNodeSP node); - void nodeOpacityChanged(qreal opacity, bool final); + void nodeOpacityChanged(qreal opacity, bool finalChange); void nodeCompositeOpChanged(const KoCompositeOp* op); - void duplicateActiveNode(KisNodeSP node); + void duplicateActiveNode(); void removeNode(KisNodeSP node); void mirrorNodeX(); void mirrorNodeY(); @@ -123,6 +133,12 @@ public slots: private: void getNewNodeLocation(const QString & nodeType, KisNodeSP &parent, KisNodeSP &above, KisNodeSP active); + /** + * Scales opacity from the range 0...1 + * to the integer range 0...255 + */ + qint32 convertOpacityToInt(qreal opacity); + struct Private; Private * const m_d; Q_PRIVATE_SLOT(m_d, void slotLayersChanged(KisGroupLayerSP)) _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacityOn Friday 23 October 2009, Dmitry Kazakov wrote:
> Hi, all! > > Sorry for not using reviewboard, it doesn't accept git patches and svn > creates quite messy patches when a file is moved to a different location =) > > Well, here is a patch that allows masks to use different compositeOps and > opacity. Now a user can choose how a mask will be applied to the layer. It > makes sense in some circumstances. You can test it with a test file in > attachment. > > Tetscase: > 1) If you set mask's composition to "normal", then a selection will be > darker than a background. > 2) If you set it to "Alpha darken", then it will dissolve in a background. > > To achieve this i moved colorspace, composition and opacity stuff from > KisLayer to KisBaseNode, therefore masks can use it too. > > Have i forgotten to move something connected to colorspaces alongside? > > Waiting for your critique! =) > Meh, I see your git-svn version has the same problem as mine: it destroys the history of renamed files. ----------- Note: don't replace things like if(op) return op; return parent->colorSpace()->compositeOp(COMPOSITE_OVER) with return op ? op : parentNode->colorSpace()->compositeOp(COMPOSITE_OVER); Whether the one or the other is more readable is purely personal preference, and for the compiler it doesn't matter, so respect the decision of the original author. --------- Same for: if (!parent) { return 0; } Don't replace that with if (!parent) return 0; In principle, I want braces used _everywhere_ because we've had more than enough problems with the short form causing bugs when people add (debug) code. Just respect what has been written, and don't rewrite it. ---------- About KisBaseNode not knowing about the parent: it has been a conscious desicion to separate the the graph part from the base bart. So, if setCompositeOpn needs to know about the parent, there is no need for duplication, move that code to KisNode from KisLayer and KisMask. We could also decide that all nodes must have a composite op set, COMPOSITE_OVER by default, so they don't go back to their parent anymore. That might be even simpler. ----------- This is just from eyeballing the source: I haven't been able to run it yet, because I get a compile error: [ 48%] Building CXX object krita/image/tests/CMakeFiles/KisBaseNodeTest.dir/kis_base_node_test.o /home/boud/kde/src/koffice/krita/image/tests/kis_base_node_test.cpp: In member function ‘void KisBaseNodeTest::testCreation()’: /home/boud/kde/src/koffice/krita/image/tests/kis_base_node_test.cpp:42: error: cannot allocate an object of abstract type ‘TestNode’ /home/boud/kde/src/koffice/krita/image/tests/kis_base_node_test.cpp:30: note: because the following virtual functions are pure within ‘TestNode’: /home/boud/kde/src/koffice/krita/image/kis_base_node.h:90: note: virtual const KoColorSpace* KisBaseNode::colorSpace() const /home/boud/kde/src/koffice/krita/image/kis_base_node.h:125: note: virtual const KoCompositeOp* KisBaseNode::compositeOp() const /home/boud/kde/src/koffice/krita/image/tests/kis_base_node_test.cpp: In member function ‘void KisBaseNodeTest::testContract()’: /home/boud/kde/src/koffice/krita/image/tests/kis_base_node_test.cpp:54: error: cannot allocate an object of abstract type ‘TestNode’ /home/boud/kde/src/koffice/krita/image/tests/kis_base_node_test.cpp:30: note: since type ‘TestNode’ has pure virtual functions /home/boud/kde/src/koffice/krita/image/tests/kis_base_node_test.cpp: In member function ‘void KisBaseNodeTest::testProperties()’: /home/boud/kde/src/koffice/krita/image/tests/kis_base_node_test.cpp:83: error: cannot allocate an object of abstract type ‘TestNode’ /home/boud/kde/src/koffice/krita/image/tests/kis_base_node_test.cpp:30: note: since type ‘TestNode’ has pure virtual functions make[2]: *** [krita/image/tests/CMakeFiles/KisBaseNodeTest.dir/kis_base_node_test.o] Error 1 make[1]: *** [krita/image/tests/CMakeFiles/KisBaseNodeTest.dir/all] Error 2 make: *** [all] Error 2 -- Boudewijn Rempt | http://www.valdyas.org _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacity
I'm fully agree that a graph part and a base one should be in separate classes. =) Don't think KisNode is a good place for compositeOp as this class is for graph part. I think as a long-term solution we could swap names for KisBaseNode and KisNode. What i mean: now: KisNode - graph part KisBaseNode - base part how it could be: KisNode - base part KisBaseNode - graph part In such a case every function from a base part will be able to access graph functions. Just an idea... We could also decide that all nodes must have a composite op set, I'm afraid parent is needed as a compositeOp should be prepared for merging operation that is done in parent's colorSpace, that, in general case, can differ from this->colorSpace(). ----------- [] Ah yes! Forgot to compile tests. =) Here is an additional patch in attachment (should be added to the previous one). I've done tests. Kis{,Base}Node tests are done successfully, but some Masks and Selections tests fail with segmentation. Could you check whether this is a regression or not? Dmitry Kazakov [01_masks_composite_ops_tests_fix.diff] diff --git a/krita/image/tests/kis_base_node_test.cpp b/krita/image/tests/kis_base_node_test.cpp index 14a8d10..42fc63b 100644 --- a/krita/image/tests/kis_base_node_test.cpp +++ b/krita/image/tests/kis_base_node_test.cpp @@ -35,6 +35,14 @@ class TestNode : public KisBaseNode KisPaintDeviceSP paintDevice() const { return 0; } + + const KoColorSpace * colorSpace() const { + return 0; + } + + virtual const KoCompositeOp * compositeOp() const { + return 0; + } }; void KisBaseNodeTest::testCreation() diff --git a/krita/image/tests/kis_count_visitor_test.h b/krita/image/tests/kis_count_visitor_test.h index 1ddf80c..16a848f 100644 --- a/krita/image/tests/kis_count_visitor_test.h +++ b/krita/image/tests/kis_count_visitor_test.h @@ -33,6 +33,12 @@ public: bool allowAsChild(KisNodeSP) const { return true; } + const KoColorSpace * colorSpace() const { + return 0; + } + virtual const KoCompositeOp * compositeOp() const { + return 0; + } }; @@ -46,6 +52,12 @@ public: bool allowAsChild(KisNodeSP) const { return true; } + const KoColorSpace * colorSpace() const { + return 0; + } + virtual const KoCompositeOp * compositeOp() const { + return 0; + } }; class TestNodeB : public KisNode @@ -58,6 +70,12 @@ public: bool allowAsChild(KisNodeSP) const { return true; } + const KoColorSpace * colorSpace() const { + return 0; + } + virtual const KoCompositeOp * compositeOp() const { + return 0; + } }; class TestNodeC : public KisNode @@ -70,6 +88,12 @@ public: bool allowAsChild(KisNodeSP) const { return true; } + const KoColorSpace * colorSpace() const { + return 0; + } + virtual const KoCompositeOp * compositeOp() const { + return 0; + } }; diff --git a/krita/image/tests/kis_node_facade_test.h b/krita/image/tests/kis_node_facade_test.h index 7d8c10a..f63d23b 100644 --- a/krita/image/tests/kis_node_facade_test.h +++ b/krita/image/tests/kis_node_facade_test.h @@ -34,6 +34,12 @@ public: bool allowAsChild(KisNodeSP) const { return true; } + const KoColorSpace * colorSpace() const { + return 0; + } + virtual const KoCompositeOp * compositeOp() const { + return 0; + } }; diff --git a/krita/image/tests/kis_node_test.h b/krita/image/tests/kis_node_test.h index 3eb5cd1..c59b3be 100644 --- a/krita/image/tests/kis_node_test.h +++ b/krita/image/tests/kis_node_test.h @@ -34,6 +34,12 @@ public: bool allowAsChild(KisNodeSP) const { return true; } + const KoColorSpace * colorSpace() const { + return 0; + } + virtual const KoCompositeOp * compositeOp() const { + return 0; + } using KisNode::setDirty; @@ -56,6 +62,12 @@ public: bool allowAsChild(KisNodeSP) const { return true; } + const KoColorSpace * colorSpace() const { + return 0; + } + virtual const KoCompositeOp * compositeOp() const { + return 0; + } }; class TestNodeB : public KisNode @@ -68,6 +80,12 @@ public: bool allowAsChild(KisNodeSP) const { return true; } + const KoColorSpace * colorSpace() const { + return 0; + } + virtual const KoCompositeOp * compositeOp() const { + return 0; + } }; class TestNodeC : public KisNode @@ -80,6 +98,12 @@ public: bool allowAsChild(KisNodeSP) const { return true; } + const KoColorSpace * colorSpace() const { + return 0; + } + virtual const KoCompositeOp * compositeOp() const { + return 0; + } }; _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacityOn Monday 26 October 2009, Dmitry Kazakov wrote:
> > About KisBaseNode not knowing about the parent: it has been a conscious > > desicion to separate the the graph part from the base bart. So, if > > setCompositeOpn needs to know about the parent, there is no need for > > duplication, move that code to KisNode from KisLayer and KisMask. > > I'm fully agree that a graph part and a base one should be in separate > classes. =) > Don't think KisNode is a good place for compositeOp as this class is for > graph part. > > I think as a long-term solution we could swap names for KisBaseNode and > KisNode. > What i mean: > > now: > KisNode - graph part > KisBaseNode - base part > > how it could be: > KisNode - base part > KisBaseNode - graph part > > In such a case every function from a base part will be able to access graph > functions. > > Just an idea... > > > We could also decide that all nodes must have a composite op set, > > > COMPOSITE_OVER by default, so they don't go back to their parent anymore. > > That might be even simpler. > > I'm afraid parent is needed as a compositeOp should be prepared for merging > operation that is done in parent's colorSpace, that, in general case, can > differ from this->colorSpace(). > > > ----------- > > > This is just from eyeballing the source: I haven't been able to run it > > yet, because I get a compile error: > > [] > > Ah yes! Forgot to compile tests. =) > Here is an additional patch in attachment (should be added to the previous > one). > > I've done tests. Kis{,Base}Node tests are done successfully, but some Masks > and Selections tests fail with segmentation. Could you check whether this > is a regression or not? well, they didn't fail when we branched 2.1: in fact, we had 100% success on all tests at that moment. However, I enabled your tile engine and the pyramid, and that caused some tests to fail. I can check whether there are more failures with this patch, of course. Btw, since enabling the new tile engine, saving is broken. I think Lukas is creating a bug for that. -- Boudewijn Rempt | http://www.valdyas.org _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacityOn Monday 26 October 2009, Dmitry Kazakov wrote:
> > now: > KisNode - graph part > KisBaseNode - base part > > how it could be: > KisNode - base part > KisBaseNode - graph part > > In such a case every function from a base part will be able to access graph > functions. > > Just an idea... > I agree, that's a good idea. -- Boudewijn Rempt | http://www.valdyas.org _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacity
Wait.. My working copy doesn't have new tile engine enabled! It hasn't been updated to your commit yet! So, that is not the reason =) I can check whether there are more failures with this patch, of course. -- Dmitry Kazakov _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacityOn Wednesday 28 October 2009, Dmitry Kazakov wrote:
> > > I've done tests. Kis{,Base}Node tests are done successfully, but some > > > > Masks > > > > > and Selections tests fail with segmentation. Could you check whether > > > this is a regression or not? > > > > well, they didn't fail when we branched 2.1: in fact, we had 100% success > > on > > all tests at that moment. However, I enabled your tile engine and the > > pyramid, > > and that caused some tests to fail. > > Wait.. My working copy doesn't have new tile engine enabled! It hasn't been > updated to your commit yet! So, that is not the reason =) > > I can check whether there are more > With patch and tiles3: 93% tests passed, 6 tests failed out of 81 The following tests FAILED: 8 - krita-image-KisIteratorTest (Failed) 15 - krita-image-KisTransactionTest (Failed) 18 - krita-image-KisFilterMaskTest (Failed) 29 - krita-image-KisCropVisitorTest (Failed) 72 - krita-image-KisTransformWorkerTest (Failed) 73 - krita-image-KisTransparencyMaskTest (Failed) Errors while running CTest With tiles3, without your patch: 95% tests passed, 4 tests failed out of 81 The following tests FAILED: 8 - krita-image-KisIteratorTest (Failed) 15 - krita-image-KisTransactionTest (Failed) 29 - krita-image-KisCropVisitorTest (Failed) 72 - krita-image-KisTransformWorkerTest (Failed) Errors while running CTest with tiles1, without your patch: 100% tests passed, 0 tests failed out of 81 > > failures with this patch, of course. > > > > Btw, since enabling the new tile engine, saving is broken. I think Lukas > > is creating a bug for that. > > Strange, saving worked in August. > right now, the layer that is saved is 3 bytes in size, there must be something weird going on when saving, it isn't recomposition when loading that's the problem. Have you also seen the undo problem? I'll ask Enkithan to make a bug report. -- Boudewijn Rempt | http://www.valdyas.org _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacitytests.
ok. i'll look at them soon. saving - fixed and committed undo. This one? - https://bugs.kde.org/show_bug.cgi?id=212235 I'll take a look at it friday evening || sunday evening -- Dmitry Kazakov _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacityOn Wednesday 28 October 2009, Dmitry Kazakov wrote:
> tests. > ok. i'll look at them soon. > > saving - fixed and committed > Wondeful! That means that there's much more chance of m4v and enkithan testing with trunk! > undo. > This one? - https://bugs.kde.org/show_bug.cgi?id=212235 > I'll take a look at it friday evening || sunday evening Great! -- Boudewijn Rempt | http://www.valdyas.org _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacityI've fixed regressions of the patch. The third patch in a patchset is attached.
Just a reminder, this patchset allows a user to choose a compositeOp for a mask. A test-file is in my first mail. -- Dmitry Kazakov [02_masks_composite_ops_filter_and_transp_masks_test_fix.diff] diff --git a/krita/image/kis_mask.cc b/krita/image/kis_mask.cc index 63c5cee..b2e494f 100644 --- a/krita/image/kis_mask.cc +++ b/krita/image/kis_mask.cc @@ -89,7 +89,7 @@ KisSelectionSP KisMask::selection() const * e.g. "Selected by default" or "Deselected by default" */ if (parent()) - m_d->selection->getOrCreatePixelSelection()->select(parent()->extent(), MAX_SELECTED); + m_d->selection->getOrCreatePixelSelection()->select(parent()->exactBounds(), MAX_SELECTED); m_d->selection->updateProjection(); } diff --git a/krita/image/kis_paint_layer.cc b/krita/image/kis_paint_layer.cc index d78c631..6b05a8e 100644 --- a/krita/image/kis_paint_layer.cc +++ b/krita/image/kis_paint_layer.cc @@ -77,6 +77,7 @@ KisPaintLayer::KisPaintLayer(const KisPaintLayer& rhs) , m_d(new Private) { m_d->paintDevice = new KisPaintDevice(*rhs.m_d->paintDevice.data()); + // FIXME: check this. repeat in other constructors? m_d->paintDevice->setParentNode(this); } diff --git a/krita/image/tests/kis_filter_mask_test.cpp b/krita/image/tests/kis_filter_mask_test.cpp index d3927ac..c72ffb6 100644 --- a/krita/image/tests/kis_filter_mask_test.cpp +++ b/krita/image/tests/kis_filter_mask_test.cpp @@ -34,13 +34,26 @@ #include "testutil.h" +#define IMAGE_WIDTH 1000 +#define IMAGE_HEIGHT 1000 + void KisFilterMaskTest::testCreation() { KisFilterMaskSP mask = new KisFilterMask(); } +#define initImage(image, layer, device, mask) do { \ + image = new KisImage(0, IMAGE_WIDTH, IMAGE_HEIGHT, 0, "tests"); \ + layer = new KisPaintLayer(KisImageWSP(0), "", 100, device); \ + image->addNode(layer); \ + image->addNode(mask, layer); \ + } while(0) + void KisFilterMaskTest::testProjectionNotSelected() { + KisImageWSP image; + KisPaintLayerSP layer; + const KoColorSpace * cs = KoColorSpaceRegistry::instance()->colorSpace("RGBA", 0); QImage qimg(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.png"); @@ -56,10 +69,12 @@ void KisFilterMaskTest::testProjectionNotSelected() // Check basic apply(). Shouldn't do anything, since nothing is selected yet. KisPaintDeviceSP projection = new KisPaintDevice(cs); + initImage(image, layer, projection, mask); + projection->convertFromQImage(qimg, 0, 0, 0); mask->createNodeProgressProxy(); - mask->apply(projection, QRect(0, 0, qimg.width(), qimg.height())); mask->select(qimg.rect(), MIN_SELECTED); + mask->apply(projection, QRect(0, 0, qimg.width(), qimg.height())); QPoint errpoint; if (!TestUtil::compareQImages(errpoint, qimg, projection->convertToQImage(0, 0, 0, qimg.width(), qimg.height()))) { @@ -70,6 +85,9 @@ void KisFilterMaskTest::testProjectionNotSelected() void KisFilterMaskTest::testProjectionSelected() { + KisImageWSP image; + KisPaintLayerSP layer; + const KoColorSpace * cs = KoColorSpaceRegistry::instance()->colorSpace("RGBA", 0); QImage qimg(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.png"); @@ -85,7 +103,9 @@ void KisFilterMaskTest::testProjectionSelected() mask->createNodeProgressProxy(); KisPaintDeviceSP projection = new KisPaintDevice(cs); + initImage(image, layer, projection, mask); projection->convertFromQImage(qimg, 0, 0, 0); + mask->select(qimg.rect(), MAX_SELECTED); mask->apply(projection, QRect(0, 0, qimg.width(), qimg.height())); QCOMPARE(mask->exactBounds(), QRect(0, 0, qimg.width(), qimg.height())); diff --git a/krita/image/tests/kis_transparency_mask_test.cpp b/krita/image/tests/kis_transparency_mask_test.cpp index a4221e2..a601ae4 100644 --- a/krita/image/tests/kis_transparency_mask_test.cpp +++ b/krita/image/tests/kis_transparency_mask_test.cpp @@ -20,11 +20,16 @@ #include <qtest_kde.h> #include "kis_transparency_mask.h" +#include "kis_paint_layer.h" +#include "kis_image.h" #include "kis_fill_painter.h" #include "testutil.h" #include "kis_selection.h" #include "kis_pixel_selection.h" +#define IMAGE_WIDTH 1000 +#define IMAGE_HEIGHT 1000 + KisPaintDeviceSP createDevice() { const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); @@ -44,14 +49,26 @@ void KisTransparencyMaskTest::testCreation() KisTransparencyMask test; } +#define initImage(image, layer, device, mask) do { \ + image = new KisImage(0, IMAGE_WIDTH, IMAGE_HEIGHT, 0, "tests"); \ + device = createDevice(); \ + layer = new KisPaintLayer(KisImageWSP(0), "", 100, device); \ + mask = new KisTransparencyMask(); \ + image->addNode(layer); \ + image->addNode(mask, layer); \ + } while(0) + void KisTransparencyMaskTest::testApply() { QPoint errpoint; - KisTransparencyMaskSP mask = new KisTransparencyMask(); + KisImageWSP image; + KisPaintLayerSP layer; + KisPaintDeviceSP dev; + KisTransparencyMaskSP mask; // Nothing is selected -- therefore everything should be filtered out on apply - KisPaintDeviceSP dev = createDevice(); + initImage(image, layer, dev, mask); mask->apply(dev, QRect(0, 0, 200, 100)); QImage qimg = dev->convertToQImage(0, 0, 0, 200, 100); @@ -62,7 +79,7 @@ void KisTransparencyMaskTest::testApply() } // Invert the mask -- everything is selected - dev = createDevice(); + initImage(image, layer, dev, mask); mask->selection()->getOrCreatePixelSelection()->invert(); mask->apply(dev, QRect(0, 0, 200, 100)); qimg = dev->convertToQImage(0, 0, 0, 200, 100); @@ -74,7 +91,7 @@ void KisTransparencyMaskTest::testApply() } // Invert back, and select a small area - dev = createDevice(); + initImage(image, layer, dev, mask); mask->selection()->getOrCreatePixelSelection()->invert(); mask->select(QRect(50, 0, 100, 100)); mask->apply(dev, QRect(0, 0, 200, 100)); _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacityOn Monday 02 November 2009, Dmitry Kazakov wrote:
> I've fixed regressions of the patch. The third patch in a patchset is > attached. > > Just a reminder, this patchset allows a user to choose a compositeOp for a > mask. A test-file is in my first mail. > Does this change give performance issues? - m_d->selection->getOrCreatePixelSelection()->select(parent()- >extent(), MAX_SELECTED); + m_d->selection->getOrCreatePixelSelection()->select(parent()- >exactBounds(), MAX_SELECTED); For the rest, looks okay, and if you're sure this change doesn't cause problems, I'm fine with committing. (As far as I am concernted, you can also swap KisBaseNode and KisNode, so the graph is the base and the properties the extension.) -- Boudewijn Rempt | http://www.valdyas.org _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacityOn Wed, Nov 4, 2009 at 9:49 PM, Boudewijn Rempt <boud@...> wrote:
It shouldn't cause anything as it is called only once during creation of the mask (of it's selection). In theory, it is more right form the user's point of view. For example, i the first case, if he decides to move a mask with a moving tool, he'll see that borders of the mask are bigger than actual image and have bogus values. The second variant adds distinctness to this usecase. (As far as I am concernted, you can also swap KisBaseNode and KisNode, so the I'll try to do this. -- Dmitry Kazakov _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacityOn Fri, 6 Nov 2009, Dmitry Kazakov wrote:
> It shouldn't cause anything as it is called only once during creation of the > mask (of it's selection). > In theory, it is more right form the user's point of view. For example, i > the first case, if he decides to move a mask with a moving tool, he'll see > that borders of the mask are bigger than actual image and have bogus values. > The second variant adds distinctness to this usecase. Ok, thanks for the explanation. Please commit :-). > > > > (As far as I am concernted, you can also swap KisBaseNode and KisNode, so > > the > > graph is the base and the properties the extension.) > > > I'll try to do this. > > > -- > Dmitry Kazakov > _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacity> Ok, thanks for the explanation. Please commit :-).
Ah, you just did :-) Boud _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacityAbout swapping KisNode<->KisBaseNode.
If we do this, KisBaseNode::parent() and friends will return KisBaseNodeSP instead of KisNodeSP. All the code outside use KisNode only. It means that it will introduce a constant type conversion KisBaseNode* -> KisNode*. I don't know what to do with this. -- Dmitry Kazakov _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
|
|
Re: Review request: Masks support compositeOps and opacityOn Friday 06 November 2009, Dmitry Kazakov wrote:
> About swapping KisNode<->KisBaseNode. > > If we do this, KisBaseNode::parent() and friends will return KisBaseNodeSP > instead of KisNodeSP. All the code outside use KisNode only. It means that > it will introduce a constant type conversion KisBaseNode* -> KisNode*. I > don't know what to do with this. > Hm... That's a good point. I'll have to think on that. -- Boudewijn Rempt | http://www.valdyas.org _______________________________________________ kimageshop mailing list kimageshop@... https://mail.kde.org/mailman/listinfo/kimageshop |
| Free embeddable forum powered by Nabble | Forum Help |