Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix bounding box of the Color Overlay mask in the Move and Transform Tools

Dmitry Kazakovf93cf17c0a71
diff --git a/libs/image/kis_mask_projection_plane.cpp b/libs/image/kis_mask_projection_plane.cpp
index a0c2b6749c..898f73a584 100644
--- a/libs/image/kis_mask_projection_plane.cpp
+++ b/libs/image/kis_mask_projection_plane.cpp
@@ -76,14 +76,14 @@ QRect KisMaskProjectionPlane::needRectForOriginal(const QRect &rect) const
QRect KisMaskProjectionPlane::tightUserVisibleBounds() const
{
// masks don't have any internal rendering subtrees,
- // so just return the extent of the mask
- return m_d->mask->extent();
+ // so just return the exact bounds of the mask
+ return m_d->mask->exactBounds();
}
QRect KisMaskProjectionPlane::looseUserVisibleBounds() const
{
// masks don't have anything complex inside, so just
- // fall back to tightUserVisibleBounds()
- return tightUserVisibleBounds();
+ // so just return the extent of the mask
+ return m_d->mask->extent();
}
diff --git a/plugins/tools/tool_transform2/strokes/inplace_transform_stroke_strategy.cpp b/plugins/tools/tool_transform2/strokes/inplace_transform_stroke_strategy.cpp
index ec5c9b21d9..00ab94a9b9 100644
--- a/plugins/tools/tool_transform2/strokes/inplace_transform_stroke_strategy.cpp
+++ b/plugins/tools/tool_transform2/strokes/inplace_transform_stroke_strategy.cpp
@@ -49,6 +49,7 @@
#include "kis_selection_mask.h"
#include "kis_undo_stores.h"
#include "kis_transparency_mask.h"
+#include "kis_filter_mask.h"
#include "commands_new/KisDisableDirtyRequestsCommand.h"
#include <kis_shape_layer.h>
#include "kis_raster_keyframe_channel.h"
@@ -552,6 +553,14 @@ void InplaceTransformStrokeStrategy::initStrokeCallback()
srcRect |= mask->selection()->selectedExactRect();
} else if (const KisTransparencyMask *mask = dynamic_cast<const KisTransparencyMask*>(node.data())) {
srcRect |= mask->selection()->selectedExactRect();
+ } else if (const KisFilterMask *mask = dynamic_cast<const KisFilterMask*>(node.data())) {
+ /// Filter masks have special handling of transparency. Their filter
+ /// may declare if they affect transparent pixels or not. In case of
+ /// transformations we don't care about that, we should just transform
+ /// non-default area of the mask.
+ if (mask->paintDevice()) {
+ srcRect |= mask->paintDevice()->nonDefaultPixelArea();
+ }
} else {
/// We shouldn't include masks or layer styles into the handles rect,
/// in the end, we process the paint device only
diff --git a/plugins/tools/tool_transform2/strokes/transform_stroke_strategy.cpp b/plugins/tools/tool_transform2/strokes/transform_stroke_strategy.cpp
index 763f2814ba..3d9cd3b586 100644
--- a/plugins/tools/tool_transform2/strokes/transform_stroke_strategy.cpp
+++ b/plugins/tools/tool_transform2/strokes/transform_stroke_strategy.cpp
@@ -33,6 +33,8 @@
#include "KisAnimAutoKey.h"
#include "kis_sequential_iterator.h"
#include "kis_selection_mask.h"
+#include "kis_transparency_mask.h"
+#include "kis_filter_mask.h"
#include "kis_image_config.h"
#include "kis_layer_utils.h"
#include <QQueue>
@@ -633,6 +635,16 @@ void TransformStrokeStrategy::initStrokeCallback()
srcRect |= mask->sourceDataBounds();
} else if (const KisSelectionMask *mask = dynamic_cast<const KisSelectionMask*>(node.data())) {
srcRect |= mask->selection()->selectedExactRect();
+ } else if (const KisTransparencyMask *mask = dynamic_cast<const KisTransparencyMask*>(node.data())) {
+ srcRect |= mask->selection()->selectedExactRect();
+ } else if (const KisFilterMask *mask = dynamic_cast<const KisFilterMask*>(node.data())) {
+ /// Filter masks have special handling of transparency. Their filter
+ /// may declare if they affect transparent pixels or not. In case of
+ /// transformations we don't care about that, we should just transform
+ /// non-default area of the mask.
+ if (mask->paintDevice()) {
+ srcRect |= mask->paintDevice()->nonDefaultPixelArea();
+ }
} else {
/// We shouldn't include masks or layer styles into the handles rect,
/// in the end, we process the paint device only