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++

Revert "experiment: Try to delay complex operations in the text tool while resizing."

Dmitry Kazakov7b561ac8bd69
diff --git a/libs/flake/commands/KoShapeResizeCommand.cpp b/libs/flake/commands/KoShapeResizeCommand.cpp
index 43188f2dee..40dd42ed87 100644
--- a/libs/flake/commands/KoShapeResizeCommand.cpp
+++ b/libs/flake/commands/KoShapeResizeCommand.cpp
@@ -10,8 +10,6 @@
#include "kis_command_ids.h"
#include "kis_assert.h"
-#include <KoSvgTextShape.h>
-
struct Q_DECL_HIDDEN KoShapeResizeCommand::Private
{
@@ -49,13 +47,6 @@ KoShapeResizeCommand::KoShapeResizeCommand(const QList<KoShape*> &shapes,
Q_FOREACH (KoShape *shape, m_d->shapes) {
m_d->oldSizes << shape->size();
m_d->oldTransforms << shape->transformation();
-
- Q_FOREACH(KoShape *dependee, shape->dependees()) {
- KoSvgTextShape* text = dynamic_cast<KoSvgTextShape*>(dependee);
- if (text) {
- text->setRelayoutBlocked(true);
- }
- }
}
}
@@ -153,20 +144,6 @@ bool KoShapeResizeCommand::mergeWith(const KUndo2Command *command)
void KoShapeResizeCommand::replaceResizeAction(qreal scaleX, qreal scaleY, const QPointF &absoluteStillPoint)
{
- QMap<KoSvgTextShape *, QRectF> textUpdates;
- Q_FOREACH(KoShape *shape, m_d->shapes) {
- KoSvgTextShape* text = dynamic_cast<KoSvgTextShape*>(shape);
- if (!text) {
- Q_FOREACH(KoShape *dependee, shape->dependees()) {
- text = dynamic_cast<KoSvgTextShape*>(dependee);
-
- }
- }
- if (text) {
- text->setRelayoutBlocked(true);
- textUpdates.insert(text, text->boundingRect());
- }
- }
const QMap<KoShape*, QRectF> undoUpdates = undoNoUpdate();
m_d->scaleX = scaleX;
@@ -179,14 +156,6 @@ void KoShapeResizeCommand::replaceResizeAction(qreal scaleX, qreal scaleY, const
for (auto it = undoUpdates.begin(); it != undoUpdates.end(); ++it) {
KIS_SAFE_ASSERT_RECOVER_NOOP(redoUpdates.contains(it.key()));
- if (textUpdates.keys().contains(dynamic_cast<KoSvgTextShape*>(it.key()))) continue;
it.key()->updateAbsolute(it.value() | redoUpdates[it.key()]);
}
-
- for (auto it = textUpdates.begin(); it != textUpdates.end(); ++it) {
- it.key()->setRelayoutBlocked(false);
- it.key()->processComplexOperationsIfNecessary();
- it.key()->updateAbsolute( it.value()| it.key()->boundingRect());
- }
-
}
diff --git a/libs/flake/text/KoSvgTextLoader.cpp b/libs/flake/text/KoSvgTextLoader.cpp
index 179b0e36a8..fc0c54a670 100644
--- a/libs/flake/text/KoSvgTextLoader.cpp
+++ b/libs/flake/text/KoSvgTextLoader.cpp
@@ -34,7 +34,7 @@ KoSvgTextLoader::~KoSvgTextLoader()
d->shape->d->updateShapeGroup();
d->shape->cleanUp();
d->shape->d->isLoading = false;
- d->shape->d->updateTextWrappingAreas();
+ d->shape->relayout();
}
void KoSvgTextLoader::enterNodeSubtree()
diff --git a/libs/flake/text/KoSvgTextShape.cpp b/libs/flake/text/KoSvgTextShape.cpp
index d5cc956b87..06c696616d 100644
--- a/libs/flake/text/KoSvgTextShape.cpp
+++ b/libs/flake/text/KoSvgTextShape.cpp
@@ -178,8 +178,6 @@ KoShape *KoSvgTextShape::cloneShape() const
void KoSvgTextShape::shapeChanged(ChangeType type, KoShape *shape)
{
if (d->isLoading) {
- this->notifyChanged();
- d->dirty = true;
return;
}
KoShape::shapeChanged(type, shape);
@@ -214,7 +212,7 @@ void KoSvgTextShape::shapeChanged(ChangeType type, KoShape *shape)
d->updateTextWrappingAreas();
// NotifyChanged ensures that boundingRect() is called on this shape.
this->notifyChanged();
- if (d->shapesSubtract.contains(shape) || d->textPaths.contains(shape)) {
+ if (d->shapesSubtract.contains(shape)) {
// Shape subtract will otherwise only
// update it's own bounding rect.
this->update();
@@ -1938,17 +1936,6 @@ QList<QPainterPath> KoSvgTextShape::generateTextAreas(const QList<KoShape *> sha
return Private::generateShapes(shapesInside, shapesSubtract, props);
}
-bool KoSvgTextShape::processComplexOperationsIfNecessary()
-{
- if (d->dirty) {
- d->shapeGroup->setTransformation(this->absoluteTransformation());
- d->updateTextWrappingAreas();
- notifyChanged();
- return true;
- }
- return false;
-}
-
void KoSvgTextShape::paint(QPainter &painter) const
{
painter.save();
@@ -2296,11 +2283,7 @@ void KoSvgTextShape::addShapeContours(QList<KoShape *> shapes, const bool inside
}
}
notifyChanged(); // notify shape manager that our geometry has changed
- if (!d->isLoading) {
- d->updateTextWrappingAreas();
- } else {
- d->dirty = true;
- }
+ d->updateTextWrappingAreas();
d->updateInternalShapesList();
shapeChangedPriv(ContentChanged);
update();
@@ -2329,11 +2312,7 @@ void KoSvgTextShape::removeShapesFromContours(QList<KoShape *> shapes, bool call
}
if (callUpdate) {
notifyChanged(); // notify shape manager that our geometry has changed
- if (!d->isLoading) {
- d->updateTextWrappingAreas();
- } else {
- d->dirty = true;
- }
+ d->updateTextWrappingAreas();
d->updateInternalShapesList();
shapeChangedPriv(ContentChanged);
update();
@@ -2347,11 +2326,7 @@ void KoSvgTextShape::moveShapeInsideToIndex(KoShape *shapeInside, const int inde
// Update.
d->shapesInside.move(oldIndex, index);
- if (!d->isLoading) {
- d->updateTextWrappingAreas();
- } else {
- d->dirty = true;
- }
+ d->updateTextWrappingAreas();
d->updateInternalShapesList();
shapeChangedPriv(ContentChanged);
update();
@@ -2533,7 +2508,6 @@ QMap<QString, QString> KoSvgTextShape::shapeTypeSpecificStyles(SvgSavingContext
void KoSvgTextShape::relayout() const
{
d->relayout();
- d->dirty = false;
}
KoSvgTextShapeFactory::KoSvgTextShapeFactory()
diff --git a/libs/flake/text/KoSvgTextShape.h b/libs/flake/text/KoSvgTextShape.h
index 8de4b563e4..90beadc2e4 100644
--- a/libs/flake/text/KoSvgTextShape.h
+++ b/libs/flake/text/KoSvgTextShape.h
@@ -656,8 +656,6 @@ public:
*/
static QList<QPainterPath> generateTextAreas(const QList<KoShape*> shapesInside, const QList<KoShape*> shapesSubtract, const KoSvgTextProperties &props);
-
- bool processComplexOperationsIfNecessary();
protected:
void shapeChanged(ChangeType type, KoShape *shape) override;
diff --git a/libs/flake/text/KoSvgTextShape_p.h b/libs/flake/text/KoSvgTextShape_p.h
index 15758f1d79..c22accbf12 100644
--- a/libs/flake/text/KoSvgTextShape_p.h
+++ b/libs/flake/text/KoSvgTextShape_p.h
@@ -563,7 +563,6 @@ public:
KisForest<KoSvgTextContentElement> textData;
bool isLoading = false; ///< Turned on when loading in text data, blocks updates to shape listeners.
- bool dirty = false; ///< Enabled when updates come in while isLoading is enabled.
bool disableFontMatching = false; ///< Turn off font matching, which should speed up relayout slightly.
diff --git a/libs/flake/text/KoSvgTextShape_p_layout.cpp b/libs/flake/text/KoSvgTextShape_p_layout.cpp
index 17cdc3712a..0e0247a699 100644
--- a/libs/flake/text/KoSvgTextShape_p_layout.cpp
+++ b/libs/flake/text/KoSvgTextShape_p_layout.cpp
@@ -114,8 +114,9 @@ void KoSvgTextShape::Private::updateTextWrappingAreas()
{
KoSvgTextProperties rootProperties = textData.empty()? KoSvgTextProperties::defaultProperties(): textData.childBegin()->properties;
currentTextWrappingAreas = getShapes(shapesInside, shapesSubtract, rootProperties);
- relayout();
- dirty = false;
+ if (!isLoading) {
+ relayout();
+ }
}
QList<QPainterPath> KoSvgTextShape::Private::generateShapes(const QList<KoShape *> shapesInside, const QList<KoShape *> shapesSubtract, const KoSvgTextProperties &properties)