diff --git a/libs/image/CMakeLists.txt b/libs/image/CMakeLists.txt index a28bbf86ca..182a273503 100644 --- a/libs/image/CMakeLists.txt +++ b/libs/image/CMakeLists.txt @@ -1,380 +1,382 @@ add_subdirectory( tests ) add_subdirectory( tiles3 ) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty ${CMAKE_CURRENT_SOURCE_DIR}/brushengine ${CMAKE_CURRENT_SOURCE_DIR}/commands ${CMAKE_CURRENT_SOURCE_DIR}/commands_new ${CMAKE_CURRENT_SOURCE_DIR}/filter ${CMAKE_CURRENT_SOURCE_DIR}/floodfill ${CMAKE_CURRENT_SOURCE_DIR}/generator ${CMAKE_CURRENT_SOURCE_DIR}/layerstyles ${CMAKE_CURRENT_SOURCE_DIR}/processing ${CMAKE_SOURCE_DIR}/sdk/tests ) include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR} ) if(FFTW3_FOUND) include_directories(${FFTW3_INCLUDE_DIR}) endif() if(HAVE_VC) include_directories(SYSTEM ${Vc_INCLUDE_DIR} ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS}) ko_compile_for_all_implementations(__per_arch_circle_mask_generator_objs kis_brush_mask_applicator_factories.cpp) else() set(__per_arch_circle_mask_generator_objs kis_brush_mask_applicator_factories.cpp) endif() set(kritaimage_LIB_SRCS tiles3/kis_tile.cc tiles3/kis_tile_data.cc tiles3/kis_tile_data_store.cc tiles3/kis_tile_data_pooler.cc tiles3/kis_tiled_data_manager.cc tiles3/KisTiledExtentManager.cpp tiles3/kis_memento_manager.cc tiles3/kis_hline_iterator.cpp tiles3/kis_vline_iterator.cpp tiles3/kis_random_accessor.cc tiles3/swap/kis_abstract_compression.cpp tiles3/swap/kis_lzf_compression.cpp tiles3/swap/kis_abstract_tile_compressor.cpp tiles3/swap/kis_legacy_tile_compressor.cpp tiles3/swap/kis_tile_compressor_2.cpp tiles3/swap/kis_chunk_allocator.cpp tiles3/swap/kis_memory_window.cpp tiles3/swap/kis_swapped_data_store.cpp tiles3/swap/kis_tile_data_swapper.cpp kis_distance_information.cpp kis_painter.cc kis_painter_blt_multi_fixed.cpp kis_marker_painter.cpp KisPrecisePaintDeviceWrapper.cpp kis_progress_updater.cpp brushengine/kis_paint_information.cc brushengine/kis_random_source.cpp brushengine/KisPerStrokeRandomSource.cpp brushengine/kis_stroke_random_source.cpp brushengine/kis_paintop.cc brushengine/kis_paintop_factory.cpp brushengine/kis_paintop_preset.cpp brushengine/kis_paintop_registry.cc brushengine/kis_paintop_settings.cpp brushengine/kis_paintop_settings_update_proxy.cpp brushengine/kis_paintop_utils.cpp brushengine/kis_no_size_paintop_settings.cpp brushengine/kis_locked_properties.cc brushengine/kis_locked_properties_proxy.cpp brushengine/kis_locked_properties_server.cpp brushengine/kis_paintop_config_widget.cpp brushengine/kis_uniform_paintop_property.cpp brushengine/kis_combo_based_paintop_property.cpp brushengine/kis_slider_based_paintop_property.cpp brushengine/kis_standard_uniform_properties_factory.cpp brushengine/KisStrokeSpeedMeasurer.cpp brushengine/KisPaintopSettingsIds.cpp commands/kis_deselect_global_selection_command.cpp commands/KisDeselectActiveSelectionCommand.cpp commands/kis_image_change_layers_command.cpp commands/kis_image_change_visibility_command.cpp commands/kis_image_command.cpp - commands/kis_image_set_projection_color_space_command.cpp commands/kis_image_layer_add_command.cpp commands/kis_image_layer_move_command.cpp commands/kis_image_layer_remove_command.cpp commands/kis_image_layer_remove_command_impl.cpp commands/kis_image_lock_command.cpp commands/kis_node_command.cpp commands/kis_node_compositeop_command.cpp commands/kis_node_opacity_command.cpp commands/kis_node_property_list_command.cpp commands/kis_reselect_global_selection_command.cpp commands/KisReselectActiveSelectionCommand.cpp commands/kis_set_global_selection_command.cpp commands/KisNodeRenameCommand.cpp commands_new/kis_saved_commands.cpp commands_new/kis_processing_command.cpp commands_new/kis_image_resize_command.cpp commands_new/kis_image_set_resolution_command.cpp commands_new/kis_node_move_command2.cpp commands_new/kis_set_layer_style_command.cpp commands_new/kis_selection_move_command2.cpp commands_new/kis_update_command.cpp commands_new/kis_switch_current_time_command.cpp commands_new/kis_change_projection_color_command.cpp commands_new/kis_activate_selection_mask_command.cpp commands_new/kis_transaction_based_command.cpp commands_new/KisHoldUIUpdatesCommand.cpp + commands_new/KisChangeChannelFlagsCommand.cpp + commands_new/KisChangeChannelLockFlagsCommand.cpp processing/kis_do_nothing_processing_visitor.cpp processing/kis_simple_processing_visitor.cpp + processing/kis_convert_color_space_processing_visitor.cpp + processing/kis_assign_profile_processing_visitor.cpp processing/kis_crop_processing_visitor.cpp processing/kis_crop_selections_processing_visitor.cpp processing/kis_transform_processing_visitor.cpp processing/kis_mirror_processing_visitor.cpp processing/KisSelectionBasedProcessingHelper.cpp filter/kis_filter.cc filter/kis_filter_category_ids.cpp filter/kis_filter_configuration.cc filter/kis_color_transformation_configuration.cc filter/kis_filter_registry.cc filter/kis_color_transformation_filter.cc generator/kis_generator.cpp generator/kis_generator_layer.cpp generator/kis_generator_registry.cpp floodfill/kis_fill_interval_map.cpp floodfill/kis_scanline_fill.cpp lazybrush/kis_min_cut_worker.cpp lazybrush/kis_lazy_fill_tools.cpp lazybrush/kis_multiway_cut.cpp lazybrush/KisWatershedWorker.cpp lazybrush/kis_colorize_mask.cpp lazybrush/kis_colorize_stroke_strategy.cpp KisDelayedUpdateNodeInterface.cpp KisCroppedOriginalLayerInterface.cpp kis_adjustment_layer.cc kis_selection_based_layer.cpp kis_node_filter_interface.cpp kis_base_accessor.cpp kis_base_node.cpp kis_base_processor.cpp kis_bookmarked_configuration_manager.cc kis_node_uuid_info.cpp kis_clone_layer.cpp - kis_colorspace_convert_visitor.cpp kis_config_widget.cpp kis_convolution_kernel.cc kis_convolution_painter.cc kis_gaussian_kernel.cpp kis_edge_detection_kernel.cpp kis_cubic_curve.cpp kis_default_bounds.cpp kis_default_bounds_base.cpp kis_effect_mask.cc kis_fast_math.cpp kis_fill_painter.cc kis_filter_mask.cpp kis_filter_strategy.cc kis_transform_mask.cpp kis_transform_mask_params_interface.cpp kis_recalculate_transform_mask_job.cpp kis_recalculate_generator_layer_job.cpp kis_transform_mask_params_factory_registry.cpp kis_safe_transform.cpp kis_gradient_painter.cc kis_gradient_shape_strategy.cpp kis_cached_gradient_shape_strategy.cpp kis_polygonal_gradient_shape_strategy.cpp kis_iterator_ng.cpp kis_async_merger.cpp kis_merge_walker.cc kis_updater_context.cpp kis_update_job_item.cpp kis_stroke_strategy_undo_command_based.cpp kis_simple_stroke_strategy.cpp KisRunnableBasedStrokeStrategy.cpp KisRunnableStrokeJobDataBase.cpp KisRunnableStrokeJobData.cpp KisRunnableStrokeJobsInterface.cpp KisFakeRunnableStrokeJobsExecutor.cpp kis_stroke_job_strategy.cpp kis_stroke_strategy.cpp kis_stroke.cpp kis_strokes_queue.cpp KisStrokesQueueMutatedJobInterface.cpp kis_simple_update_queue.cpp kis_update_scheduler.cpp kis_queues_progress_updater.cpp kis_composite_progress_proxy.cpp kis_sync_lod_cache_stroke_strategy.cpp kis_lod_capable_layer_offset.cpp kis_update_time_monitor.cpp KisImageConfigNotifier.cpp kis_group_layer.cc kis_count_visitor.cpp kis_histogram.cc kis_image_interfaces.cpp kis_image_animation_interface.cpp kis_time_range.cpp kis_node_graph_listener.cpp kis_image.cc kis_image_signal_router.cpp KisImageSignals.cpp kis_image_config.cpp kis_projection_updates_filter.cpp kis_suspend_projection_updates_stroke_strategy.cpp kis_regenerate_frame_stroke_strategy.cpp kis_switch_time_stroke_strategy.cpp kis_crop_saved_extra_data.cpp kis_timed_signal_threshold.cpp kis_layer.cc kis_indirect_painting_support.cpp kis_abstract_projection_plane.cpp kis_layer_projection_plane.cpp kis_layer_utils.cpp kis_mask_projection_plane.cpp kis_projection_leaf.cpp KisSafeNodeProjectionStore.cpp kis_mask.cc kis_base_mask_generator.cpp kis_rect_mask_generator.cpp kis_circle_mask_generator.cpp kis_gauss_circle_mask_generator.cpp kis_gauss_rect_mask_generator.cpp ${__per_arch_circle_mask_generator_objs} kis_curve_circle_mask_generator.cpp kis_curve_rect_mask_generator.cpp kis_math_toolbox.cpp kis_memory_statistics_server.cpp kis_name_server.cpp kis_node.cpp kis_node_facade.cpp kis_node_progress_proxy.cpp kis_busy_progress_indicator.cpp kis_node_visitor.cpp kis_paint_device.cc kis_paint_device_debug_utils.cpp kis_fixed_paint_device.cpp KisOptimizedByteArray.cpp kis_paint_layer.cc kis_perspective_math.cpp kis_pixel_selection.cpp kis_processing_information.cpp kis_properties_configuration.cc kis_random_accessor_ng.cpp kis_random_generator.cc kis_random_sub_accessor.cpp kis_wrapped_random_accessor.cpp kis_selection.cc KisSelectionUpdateCompressor.cpp kis_selection_mask.cpp kis_update_outline_job.cpp kis_update_selection_job.cpp kis_serializable_configuration.cc kis_transaction_data.cpp kis_transform_worker.cc kis_perspectivetransform_worker.cpp bsplines/kis_bspline_1d.cpp bsplines/kis_bspline_2d.cpp bsplines/kis_nu_bspline_2d.cpp kis_warptransform_worker.cc kis_cage_transform_worker.cpp kis_liquify_transform_worker.cpp kis_green_coordinates_math.cpp kis_transparency_mask.cc kis_undo_adapter.cpp kis_macro_based_undo_store.cpp kis_surrogate_undo_adapter.cpp kis_legacy_undo_adapter.cpp kis_post_execution_undo_adapter.cpp kis_processing_visitor.cpp kis_processing_applicator.cpp krita_utils.cpp kis_outline_generator.cpp kis_layer_composition.cpp kis_selection_filters.cpp KisProofingConfiguration.h KisRecycleProjectionsJob.cpp kis_keyframe.cpp kis_keyframe_channel.cpp kis_keyframe_commands.cpp kis_scalar_keyframe_channel.cpp kis_raster_keyframe_channel.cpp kis_onion_skin_compositor.cpp kis_onion_skin_cache.cpp kis_idle_watcher.cpp kis_psd_layer_style.cpp kis_layer_properties_icons.cpp layerstyles/kis_multiple_projection.cpp layerstyles/kis_layer_style_filter.cpp layerstyles/kis_layer_style_filter_environment.cpp layerstyles/kis_layer_style_filter_projection_plane.cpp layerstyles/kis_layer_style_projection_plane.cpp layerstyles/kis_ls_drop_shadow_filter.cpp layerstyles/kis_ls_satin_filter.cpp layerstyles/kis_ls_stroke_filter.cpp layerstyles/kis_ls_bevel_emboss_filter.cpp layerstyles/kis_ls_overlay_filter.cpp layerstyles/kis_ls_utils.cpp layerstyles/gimp_bump_map.cpp layerstyles/KisLayerStyleKnockoutBlower.cpp KisProofingConfiguration.cpp kis_node_query_path.cc ) set(einspline_SRCS 3rdparty/einspline/bspline_create.cpp 3rdparty/einspline/bspline_data.cpp 3rdparty/einspline/multi_bspline_create.cpp 3rdparty/einspline/nubasis.cpp 3rdparty/einspline/nubspline_create.cpp 3rdparty/einspline/nugrid.cpp ) add_library(kritaimage SHARED ${kritaimage_LIB_SRCS} ${einspline_SRCS}) generate_export_header(kritaimage BASE_NAME kritaimage) target_link_libraries(kritaimage PUBLIC kritaversion kritawidgets kritaglobal kritapsd kritaodf kritapigment kritacommand kritawidgetutils kritametadata Qt5::Concurrent ) target_link_libraries(kritaimage PUBLIC ${Boost_SYSTEM_LIBRARY}) if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB) if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB) target_link_libraries(kritaimage PUBLIC atomic) endif() endif() if(OPENEXR_FOUND) target_link_libraries(kritaimage PUBLIC ${OPENEXR_LIBRARIES}) endif() if(FFTW3_FOUND) target_link_libraries(kritaimage PRIVATE ${FFTW3_LIBRARIES}) endif() if(HAVE_VC) target_link_libraries(kritaimage PUBLIC ${Vc_LIBRARIES}) endif() if (NOT GSL_FOUND) message (WARNING "KRITA WARNING! No GNU Scientific Library was found! Krita's Shaped Gradients might be non-normalized! Please install GSL library.") else () target_link_libraries(kritaimage PRIVATE ${GSL_LIBRARIES} ${GSL_CBLAS_LIBRARIES}) endif () target_include_directories(kritaimage PUBLIC $ $ $ $ $ ) set_target_properties(kritaimage PROPERTIES VERSION ${GENERIC_KRITA_LIB_VERSION} SOVERSION ${GENERIC_KRITA_LIB_SOVERSION} ) install(TARGETS kritaimage ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/libs/image/commands/kis_image_commands.h b/libs/image/commands/kis_image_commands.h index 3f401f4de7..7d253a84f0 100644 --- a/libs/image/commands/kis_image_commands.h +++ b/libs/image/commands/kis_image_commands.h @@ -1,31 +1,30 @@ /* * Copyright (c) 2008 Boudewijn Rempt * * 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_IMAGE_COMMANDS #define KIS_IMAGE_COMMANDS #include "kis_image_change_layers_command.h" #include "kis_image_command.h" -#include "kis_image_set_projection_color_space_command.h" #include "kis_image_layer_add_command.h" #include "kis_image_layer_move_command.h" #include "kis_image_layer_remove_command.h" #include "kis_image_lock_command.h" #include "kis_image_change_visibility_command.h" #endif diff --git a/libs/image/commands/kis_image_set_projection_color_space_command.cpp b/libs/image/commands/kis_image_set_projection_color_space_command.cpp deleted file mode 100644 index e4d2a3293f..0000000000 --- a/libs/image/commands/kis_image_set_projection_color_space_command.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2002 Patrick Julien - * Copyright (c) 2007 Sven Langkamp - * - * 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 "kis_image_commands.h" - -#include "KoColorSpace.h" -#include "kis_image.h" - -#include - - -KisImageSetProjectionColorSpaceCommand::KisImageSetProjectionColorSpaceCommand(KisImageWSP image, const KoColorSpace * afterColorSpace) - : KisImageCommand(kundo2_i18n("Convert Image Type"), image) -{ - KisImageSP imageSP = image.toStrongRef(); - if (imageSP) { - m_beforeColorSpace = imageSP->colorSpace(); - m_afterColorSpace = afterColorSpace; - } -} - -void KisImageSetProjectionColorSpaceCommand::redo() -{ - KisImageSP image = m_image.toStrongRef(); - if (image) { - image->setProjectionColorSpace(m_afterColorSpace); - } -} - -void KisImageSetProjectionColorSpaceCommand::undo() -{ - KisImageSP image = m_image.toStrongRef(); - if (image) { - image->setProjectionColorSpace(m_beforeColorSpace); - } -} diff --git a/libs/image/commands/kis_image_set_projection_color_space_command.h b/libs/image/commands/kis_image_set_projection_color_space_command.h deleted file mode 100644 index bb6e096f9d..0000000000 --- a/libs/image/commands/kis_image_set_projection_color_space_command.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2002 Patrick Julien - * Copyright (c) 2007 Sven Langkamp - * - * 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_IMAGE_SET_PROJECTION_COLOR_SPACE_COMMAND_H_ -#define KIS_IMAGE_SET_PROJECTION_COLOR_SPACE_COMMAND_H_ - -#include "kis_image_command.h" - -class KoColorSpace; - -class KisImageSetProjectionColorSpaceCommand : public KisImageCommand -{ -public: - KisImageSetProjectionColorSpaceCommand(KisImageWSP image, const KoColorSpace * afterColorSpace); - - void redo() override; - void undo() override; - -private: - const KoColorSpace * m_beforeColorSpace; - const KoColorSpace * m_afterColorSpace; -}; - - -#endif /* KIS_IMAGE_SET_PROJECTION_COLOR_SPACE_COMMAND_H_ */ diff --git a/libs/image/commands_new/KisChangeChannelFlagsCommand.cpp b/libs/image/commands_new/KisChangeChannelFlagsCommand.cpp new file mode 100644 index 0000000000..ac835091cb --- /dev/null +++ b/libs/image/commands_new/KisChangeChannelFlagsCommand.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019 Dmitry Kazakov + * + * 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 "KisChangeChannelFlagsCommand.h" +#include "kis_layer.h" + +#include + +KisChangeChannelFlagsCommand::KisChangeChannelFlagsCommand(const QBitArray &newFlags, const QBitArray &oldFlags, + KisLayerSP layer, KUndo2Command *parentCommand) + : KUndo2Command(kundo2_noi18n("change-channel-flags-command"), parentCommand), + m_layer(layer), + m_oldFlags(oldFlags), + m_newFlags(newFlags) +{ +} + +KisChangeChannelFlagsCommand::KisChangeChannelFlagsCommand(const QBitArray &newFlags, KisLayerSP layer, KUndo2Command *parentCommand) + : KisChangeChannelFlagsCommand(newFlags, layer->channelFlags(), layer, parentCommand) +{ +} + +void KisChangeChannelFlagsCommand::redo() +{ + m_layer->setChannelFlags(m_newFlags); +} + +void KisChangeChannelFlagsCommand::undo() +{ + m_layer->setChannelFlags(m_oldFlags); +} diff --git a/libs/image/commands_new/KisChangeChannelFlagsCommand.h b/libs/image/commands_new/KisChangeChannelFlagsCommand.h new file mode 100644 index 0000000000..310a7888b4 --- /dev/null +++ b/libs/image/commands_new/KisChangeChannelFlagsCommand.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2019 Dmitry Kazakov + * + * 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_CHANGE_CHANNEL_FLAGS_COMMAND_H_ +#define KIS_CHANGE_CHANNEL_FLAGS_COMMAND_H_ + +#include + +#include + +#include "kis_types.h" +#include + +class KisChangeChannelFlagsCommand : public KUndo2Command +{ + +public: + KisChangeChannelFlagsCommand(const QBitArray &newFlags, + KisLayerSP layer, + KUndo2Command *parentCommand = 0); + + + KisChangeChannelFlagsCommand(const QBitArray &newFlags, + const QBitArray &oldFlags, + KisLayerSP layer, + KUndo2Command *parentCommand = 0); + + void redo() override; + void undo() override; + +protected: + KisLayerSP m_layer; + QBitArray m_oldFlags; + QBitArray m_newFlags; +}; + +#endif diff --git a/libs/image/commands_new/KisChangeChannelLockFlagsCommand.cpp b/libs/image/commands_new/KisChangeChannelLockFlagsCommand.cpp new file mode 100644 index 0000000000..cdc12a464a --- /dev/null +++ b/libs/image/commands_new/KisChangeChannelLockFlagsCommand.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019 Dmitry Kazakov + * + * 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 "KisChangeChannelLockFlagsCommand.h" +#include "kis_paint_layer.h" + +#include + +KisChangeChannelLockFlagsCommand::KisChangeChannelLockFlagsCommand(const QBitArray &newFlags, const QBitArray &oldFlags, + KisPaintLayerSP layer, KUndo2Command *parentCommand) + : KUndo2Command(kundo2_noi18n("change-channel-lock-flags-command"), parentCommand), + m_layer(layer), + m_oldFlags(oldFlags), + m_newFlags(newFlags) +{ +} + +KisChangeChannelLockFlagsCommand::KisChangeChannelLockFlagsCommand(const QBitArray &newFlags, KisPaintLayerSP layer, KUndo2Command *parentCommand) + : KisChangeChannelLockFlagsCommand(newFlags, layer->channelLockFlags(), layer, parentCommand) +{ +} + +void KisChangeChannelLockFlagsCommand::redo() +{ + m_layer->setChannelLockFlags(m_newFlags); +} + +void KisChangeChannelLockFlagsCommand::undo() +{ + m_layer->setChannelLockFlags(m_oldFlags); +} diff --git a/libs/image/commands_new/KisChangeChannelLockFlagsCommand.h b/libs/image/commands_new/KisChangeChannelLockFlagsCommand.h new file mode 100644 index 0000000000..6d7530b6de --- /dev/null +++ b/libs/image/commands_new/KisChangeChannelLockFlagsCommand.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2019 Dmitry Kazakov + * + * 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_CHANGE_CHANNEL_LOCK_FLAGS_COMMAND_H_ +#define KIS_CHANGE_CHANNEL_LOCK_FLAGS_COMMAND_H_ + +#include + +#include + +#include "kis_types.h" +#include + +class KisChangeChannelLockFlagsCommand : public KUndo2Command +{ + +public: + KisChangeChannelLockFlagsCommand(const QBitArray &newFlags, + KisPaintLayerSP layer, + KUndo2Command *parentCommand = 0); + + + KisChangeChannelLockFlagsCommand(const QBitArray &newFlags, + const QBitArray &oldFlags, + KisPaintLayerSP layer, + KUndo2Command *parentCommand = 0); + + void redo() override; + void undo() override; + +protected: + KisPaintLayerSP m_layer; + QBitArray m_oldFlags; + QBitArray m_newFlags; +}; + +#endif diff --git a/libs/image/commands_new/kis_processing_command.cpp b/libs/image/commands_new/kis_processing_command.cpp index 8ce924afd4..d2ccf9420e 100644 --- a/libs/image/commands_new/kis_processing_command.cpp +++ b/libs/image/commands_new/kis_processing_command.cpp @@ -1,46 +1,47 @@ /* * Copyright (c) 2011 Dmitry Kazakov * * 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 "kis_processing_command.h" #include "kis_node.h" #include "kis_processing_visitor.h" KisProcessingCommand::KisProcessingCommand(KisProcessingVisitorSP visitor, KisNodeSP node, KUndo2Command *parent) : KUndo2Command(kundo2_noi18n("processing_command"), parent), m_visitor(visitor), m_node(node), m_visitorExecuted(false) { } void KisProcessingCommand::redo() { if(!m_visitorExecuted) { m_node->accept(*m_visitor, &m_undoAdapter); m_visitorExecuted = true; + m_visitor = 0; } else { m_undoAdapter.redoAll(); } } void KisProcessingCommand::undo() { m_undoAdapter.undoAll(); } diff --git a/libs/image/kis_change_profile_visitor.h b/libs/image/kis_change_profile_visitor.h deleted file mode 100644 index 0f0928f3e7..0000000000 --- a/libs/image/kis_change_profile_visitor.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2006 Boudewijn Rempt - -/** - * The Change Profile visitor walks over all layers and if the current - * layer has the specified colorspace AND the specified old profile, sets - * the colorspace to the same colorspace with the NEW profile, without doing - * conversions. This is essential if you have loaded an image that didn't - * have an embedded profile to which you want to attach the right profile. - */ -class KRITAIMAGE_EXPORT KisChangeProfileVisitor : public KisNodeVisitor -{ -public: - - using KisNodeVisitor::visit; - - KisChangeProfileVisitor(const KoColorSpace * oldColorSpace, - const KoColorSpace *dstColorSpace) - : KisNodeVisitor() - , m_oldColorSpace(oldColorSpace) - , m_dstColorSpace(dstColorSpace) { - } - - ~KisChangeProfileVisitor() override { - } - - bool visit(KisExternalLayer *) override { - return true; - } - - bool visit(KisGroupLayer * layer) override { - // Clear the projection, we will have to re-render everything. - layer->resetCache(); - - KisLayerSP child = dynamic_cast(layer->firstChild().data()); - while (child) { - child->accept(*this); - child = dynamic_cast(child->nextSibling().data()); - } - return true; - } - - - bool visit(KisPaintLayer *layer) override { - return updatePaintDevice(layer); - } - - bool visit(KisGeneratorLayer *layer) override { - return updatePaintDevice(layer); - } - - bool visit(KisAdjustmentLayer * layer) override { - layer->resetCache(); - return true; - } - - bool visit(KisNode*) override { - return true; - } - bool visit(KisCloneLayer*) override { - return true; - } - bool visit(KisFilterMask*) override { - return true; - } - bool visit(KisTransformMask*) override { - return true; - } - bool visit(KisTransparencyMask*) override { - return true; - } - bool visit(KisSelectionMask*) override { - return true; - } - - bool visit(KisColorizeMask *mask) override { - if (mask->colorSpace()->colorModelId() == m_oldColorSpace->colorModelId()) { - mask->setProfile(m_dstColorSpace->profile()); - } - return true; - } - -private: - - bool updatePaintDevice(KisLayer *layer) { - if (!layer) return false; - if (!layer->paintDevice()) return false; - if (!layer->paintDevice()->colorSpace()) return false; - - const KoColorSpace *cs = layer->paintDevice()->colorSpace(); - - if (cs->colorModelId() == m_oldColorSpace->colorModelId()) { - layer->paintDevice()->setProfile(m_dstColorSpace->profile()); - if (layer->projection() != layer->paintDevice()) { - layer->projection()->setProfile(m_dstColorSpace->profile()); - } - } - - - return true; - } - - const KoColorSpace *m_oldColorSpace; - const KoColorSpace *m_dstColorSpace; -}; - -#endif // KIS_CHANGE_PROFILE_VISITOR_H_ - diff --git a/libs/image/kis_colorspace_convert_visitor.cpp b/libs/image/kis_colorspace_convert_visitor.cpp deleted file mode 100644 index ce003e8967..0000000000 --- a/libs/image/kis_colorspace_convert_visitor.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2005 C. Boemann - * - * 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 "kis_colorspace_convert_visitor.h" -#include "kis_image.h" -#include "kis_paint_device.h" -#include "kis_undo_adapter.h" -#include "kis_adjustment_layer.h" -#include "kis_paint_layer.h" -#include "kis_group_layer.h" -#include "lazybrush/kis_colorize_mask.h" -#include "kis_external_layer_iface.h" -#include "filter/kis_filter_configuration.h" -#include "filter/kis_filter_registry.h" -#include "filter/kis_filter.h" -#include "kis_generator.h" -#include "kis_generator_registry.h" -#include "generator/kis_generator_layer.h" -#include "kis_time_range.h" -#include - -KisColorSpaceConvertVisitor::KisColorSpaceConvertVisitor(KisImageWSP image, - const KoColorSpace *srcColorSpace, - const KoColorSpace *dstColorSpace, - KoColorConversionTransformation::Intent renderingIntent, - KoColorConversionTransformation::ConversionFlags conversionFlags) - : KisNodeVisitor() - , m_image(image) - , m_srcColorSpace(srcColorSpace) - , m_dstColorSpace(dstColorSpace) - , m_renderingIntent(renderingIntent) - , m_conversionFlags(conversionFlags) -{ -} - -KisColorSpaceConvertVisitor::~KisColorSpaceConvertVisitor() -{ -} - -bool KisColorSpaceConvertVisitor::visit(KisGroupLayer * layer) -{ - convertPaintDevice(layer); - KisLayerSP child = qobject_cast(layer->firstChild().data()); - while (child) { - child->accept(*this); - child = qobject_cast(child->nextSibling().data()); - } - - layer->resetCache(); - - return true; -} - -bool KisColorSpaceConvertVisitor::visit(KisPaintLayer *layer) -{ - return convertPaintDevice(layer); -} - -bool KisColorSpaceConvertVisitor::visit(KisGeneratorLayer *layer) -{ - layer->resetCache(); - return true; -} - -bool KisColorSpaceConvertVisitor::visit(KisAdjustmentLayer * layer) -{ - // XXX: Make undoable! - if (layer->filter()->name() == "perchannel") { - // Per-channel filters need to be reset because of different number - // of channels. This makes undo very tricky, but so be it. - // XXX: Make this more generic for after 1.6, when we'll have many - // channel-specific filters. - KisFilterSP f = KisFilterRegistry::instance()->value("perchannel"); - layer->setFilter(f->defaultConfiguration()); - } - - layer->resetCache(); - return true; -} - -bool KisColorSpaceConvertVisitor::convertPaintDevice(KisLayer* layer) -{ - - if (*m_dstColorSpace == *layer->colorSpace()) return true; - - bool alphaLock = false; - - if (m_srcColorSpace->colorModelId() != m_dstColorSpace->colorModelId()) { - layer->setChannelFlags(m_emptyChannelFlags); - KisPaintLayer *paintLayer = 0; - if ((paintLayer = dynamic_cast(layer))) { - alphaLock = paintLayer->alphaLocked(); - paintLayer->setChannelLockFlags(QBitArray()); - } - } - - KisImageSP image = m_image.toStrongRef(); - if (!image) { - return false; - } - - KUndo2Command *parentConversionCommand = new KUndo2Command(); - - if (layer->original()) { - layer->original()->convertTo(m_dstColorSpace, m_renderingIntent, m_conversionFlags, parentConversionCommand); - } - - if (layer->paintDevice()) { - layer->paintDevice()->convertTo(m_dstColorSpace, m_renderingIntent, m_conversionFlags, parentConversionCommand); - } - - if (layer->projection()) { - layer->projection()->convertTo(m_dstColorSpace, m_renderingIntent, m_conversionFlags, parentConversionCommand); - } - - image->undoAdapter()->addCommand(parentConversionCommand); - - KisPaintLayer *paintLayer = 0; - if ((paintLayer = dynamic_cast(layer))) { - paintLayer->setAlphaLocked(alphaLock); - } - layer->setDirty(); - layer->invalidateFrames(KisTimeRange::infinite(0), layer->extent()); - - return true; - -} - -bool KisColorSpaceConvertVisitor::visit(KisColorizeMask *mask) -{ - KisImageSP image = m_image.toStrongRef(); - if (!image) { - return false; - } - KUndo2Command* cmd = mask->setColorSpace(m_dstColorSpace, m_renderingIntent, m_conversionFlags); - if (cmd) { - image->undoAdapter()->addCommand(cmd); - } - return true; -} diff --git a/libs/image/kis_colorspace_convert_visitor.h b/libs/image/kis_colorspace_convert_visitor.h deleted file mode 100644 index 348e5331ba..0000000000 --- a/libs/image/kis_colorspace_convert_visitor.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2005 C. Boemann - * - * 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_COLORSPACE_CONVERT_VISITOR_H_ -#define KIS_COLORSPACE_CONVERT_VISITOR_H_ - - -#include -#include - -#include -#include "kis_types.h" -#include "kis_node_visitor.h" - - -/** - * This will convert all layers to the destination color space. - */ -class KRITAIMAGE_EXPORT KisColorSpaceConvertVisitor : public KisNodeVisitor -{ -public: - KisColorSpaceConvertVisitor(KisImageWSP image, - const KoColorSpace *srcColorSpace, - const KoColorSpace *dstColorSpace, - KoColorConversionTransformation::Intent renderingIntent, - KoColorConversionTransformation::ConversionFlags conversionFlags); - ~KisColorSpaceConvertVisitor() override; - -public: - - bool visit(KisPaintLayer *layer) override; - bool visit(KisGroupLayer *layer) override; - bool visit(KisAdjustmentLayer* layer) override; - bool visit(KisGeneratorLayer * layer) override; - - bool visit(KisExternalLayer *) override { - return true; - } - - bool visit(KisNode*) override { - return true; - } - - bool visit(KisCloneLayer*) override { - return true; - } - - bool visit(KisFilterMask*) override { - return true; - } - - bool visit(KisTransformMask*) override { - return true; - } - - bool visit(KisTransparencyMask*) override { - return true; - } - - bool visit(KisSelectionMask*) override { - return true; - } - - bool visit(KisColorizeMask *mask) override; - -private: - - bool convertPaintDevice(KisLayer* layer); - - KisImageWSP m_image; - const KoColorSpace *m_srcColorSpace; - const KoColorSpace *m_dstColorSpace; - KoColorConversionTransformation::Intent m_renderingIntent; - KoColorConversionTransformation::ConversionFlags m_conversionFlags; - QBitArray m_emptyChannelFlags; -}; - - -#endif // KIS_COLORSPACE_CONVERT_VISITOR_H_ - diff --git a/libs/image/kis_do_something_command.h b/libs/image/kis_do_something_command.h index b66f9c01ab..a196cb7ed1 100644 --- a/libs/image/kis_do_something_command.h +++ b/libs/image/kis_do_something_command.h @@ -1,70 +1,71 @@ /* * Copyright (c) 2014 Dmitry Kazakov * * 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_DO_SOMETHING_COMMAND_H #define __KIS_DO_SOMETHING_COMMAND_H #include template