添加单向渲染逻辑和内存强制回收措施
parent
aa9743d4e7
commit
5d5ea2307f
|
@ -212,7 +212,7 @@
|
||||||
<ClInclude Include="src\Editor\LayerWrapper.h" />
|
<ClInclude Include="src\Editor\LayerWrapper.h" />
|
||||||
<ClInclude Include="src\Editor\util\EncodeUtil.hpp" />
|
<ClInclude Include="src\Editor\util\EncodeUtil.hpp" />
|
||||||
<ClInclude Include="src\Editor\util\JsonUtil.hpp" />
|
<ClInclude Include="src\Editor\util\JsonUtil.hpp" />
|
||||||
<ClInclude Include="src\Editor\ElementManager.h" />
|
<QtMoc Include="src\Editor\ElementManager.h" />
|
||||||
<QtMoc Include="src\Editor\ElementPoolWidget.h" />
|
<QtMoc Include="src\Editor\ElementPoolWidget.h" />
|
||||||
<ClInclude Include="src\Editor\GraphicElement.h" />
|
<ClInclude Include="src\Editor\GraphicElement.h" />
|
||||||
<ClInclude Include="src\Editor\LayerManager.h" />
|
<ClInclude Include="src\Editor\LayerManager.h" />
|
||||||
|
|
|
@ -329,6 +329,9 @@
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerContainerListWidget.h">
|
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerContainerListWidget.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
|
<QtMoc Include="src\Editor\ElementManager.h">
|
||||||
|
<Filter>Header Files\Editor\Element</Filter>
|
||||||
|
</QtMoc>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\data.json" />
|
<None Include="..\data.json" />
|
||||||
|
@ -519,9 +522,6 @@
|
||||||
<ClInclude Include="src\Editor\util\EncodeUtil.hpp">
|
<ClInclude Include="src\Editor\util\EncodeUtil.hpp">
|
||||||
<Filter>Header Files\Editor\util</Filter>
|
<Filter>Header Files\Editor\util</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Editor\ElementManager.h">
|
|
||||||
<Filter>Header Files\Editor\Element</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Editor\GraphicElement.h">
|
<ClInclude Include="src\Editor\GraphicElement.h">
|
||||||
<Filter>Header Files\Editor\Element</Filter>
|
<Filter>Header Files\Editor\Element</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
|
@ -18,6 +18,14 @@ ElementManager::ElementManager(QJsonObject source, QString fileHome)
|
||||||
}
|
}
|
||||||
for (auto element : elements)
|
for (auto element : elements)
|
||||||
element->index = index++;
|
element->index = index++;
|
||||||
|
timer = new QTimer();
|
||||||
|
timer->setInterval(30000);
|
||||||
|
connect(timer, &QTimer::timeout, this, [this]() {
|
||||||
|
for (auto element : elements)
|
||||||
|
if (typeid(*element) == typeid(SimpleElement))
|
||||||
|
((SimpleElement*)element)->forceRefresh = true;
|
||||||
|
});
|
||||||
|
timer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElementManager::addElement(GraphicElement *element)
|
void ElementManager::addElement(GraphicElement *element)
|
||||||
|
|
|
@ -4,17 +4,20 @@
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include "../Renderer/Preview/ElementRenderer.h"
|
#include "../Renderer/Preview/ElementRenderer.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <QTimer>
|
||||||
using std::vector;
|
using std::vector;
|
||||||
class LayerManager;
|
class LayerManager;
|
||||||
class GraphicElement;
|
class GraphicElement;
|
||||||
class Renderer::ElementRenderer;
|
class Renderer::ElementRenderer;
|
||||||
class FolderLayerWrapper;
|
class FolderLayerWrapper;
|
||||||
|
|
||||||
class ElementManager
|
class ElementManager : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
vector<GraphicElement *> elements;
|
vector<GraphicElement *> elements;
|
||||||
QString fileHome;
|
QString fileHome;
|
||||||
|
QTimer* timer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ElementManager(QJsonObject source, QString fileHome);
|
ElementManager(QJsonObject source, QString fileHome);
|
||||||
|
|
|
@ -112,12 +112,12 @@ void SimpleElement::paint(QPainter* painter, QTransform transform, const LayerSt
|
||||||
maxScale = std::max(fabs(transform.m11() / cos(angle)), fabs(transform.m22() / cos(angle)));
|
maxScale = std::max(fabs(transform.m11() / cos(angle)), fabs(transform.m22() / cos(angle)));
|
||||||
else
|
else
|
||||||
maxScale = std::max(fabs(transform.m12() / sin(angle)), fabs(transform.m21() / sin(angle)));
|
maxScale = std::max(fabs(transform.m12() / sin(angle)), fabs(transform.m21() / sin(angle)));
|
||||||
//double pixelRatio = maxScale * QGuiApplication::primaryScreen()->devicePixelRatio();
|
double pixelRatio = maxScale * QGuiApplication::primaryScreen()->devicePixelRatio();
|
||||||
double pixelRatio = 5;
|
//double pixelRatio = 5;
|
||||||
if (painterPath == painterPathPrev && styles.getHash() == stylesHashValue && fabs(pixelRatio - pixelRatioPrev) < 1e-3)
|
if (painterPath == painterPathPrev && styles.getHash() == stylesHashValue && pixelRatioPrev >= pixelRatio && !forceRefresh)
|
||||||
{
|
{
|
||||||
transform.translate(movPrev.x(), movPrev.y());
|
transform.translate(movPrev.x(), movPrev.y());
|
||||||
painter->setTransform(transform.scale(1 / pixelRatio, 1 / pixelRatio));
|
painter->setTransform(transform.scale(1 / pixelRatioPrev, 1 / pixelRatioPrev));
|
||||||
painter->drawImage(0, 0, imagePrev);
|
painter->drawImage(0, 0, imagePrev);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -131,6 +131,7 @@ void SimpleElement::paint(QPainter* painter, QTransform transform, const LayerSt
|
||||||
imagePrev = img;
|
imagePrev = img;
|
||||||
movPrev = mov;
|
movPrev = mov;
|
||||||
pixelRatioPrev = pixelRatio;
|
pixelRatioPrev = pixelRatio;
|
||||||
|
forceRefresh = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ public:
|
||||||
void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override;
|
void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) override;
|
||||||
bool isClosed() const override;
|
bool isClosed() const override;
|
||||||
void paintPreview(QPainter* painter) override;
|
void paintPreview(QPainter* painter) override;
|
||||||
|
bool forceRefresh = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GroupElement : public GraphicElement
|
class GroupElement : public GraphicElement
|
||||||
|
|
Loading…
Reference in New Issue