Merge branch 'main' of http://101.34.228.45:3000/BigC/ArchitectureColoredPainting
commit
14a1502a22
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>MainWindowClass</class>
|
<class>MainWindowClass</class>
|
||||||
<widget class="QMainWindow" name="MainWindowClass">
|
<widget class="QWidget" name="MainWindowClass">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
@ -10,56 +10,45 @@
|
||||||
<height>722</height>
|
<height>722</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
|
||||||
<string>MainWindow</string>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">font: 10pt "Segoe UI, Microsoft YaHei UI";</string>
|
<string notr="true">font: 10pt "Segoe UI, Microsoft YaHei UI";</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="sizePolicy">
|
<property name="spacing">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<number>0</number>
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<property name="leftMargin">
|
||||||
<property name="spacing">
|
<number>0</number>
|
||||||
<number>0</number>
|
</property>
|
||||||
</property>
|
<property name="topMargin">
|
||||||
<property name="leftMargin">
|
<number>0</number>
|
||||||
<number>0</number>
|
</property>
|
||||||
</property>
|
<property name="rightMargin">
|
||||||
<property name="topMargin">
|
<number>0</number>
|
||||||
<number>0</number>
|
</property>
|
||||||
</property>
|
<property name="bottomMargin">
|
||||||
<property name="rightMargin">
|
<number>0</number>
|
||||||
<number>0</number>
|
</property>
|
||||||
</property>
|
<item>
|
||||||
<property name="bottomMargin">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<number>0</number>
|
<property name="sizeConstraint">
|
||||||
</property>
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
<item>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<property name="topMargin">
|
||||||
<property name="sizeConstraint">
|
<number>0</number>
|
||||||
<enum>QLayout::SetDefaultConstraint</enum>
|
</property>
|
||||||
</property>
|
<property name="spacing">
|
||||||
<property name="topMargin">
|
<number>0</number>
|
||||||
<number>0</number>
|
</property>
|
||||||
</property>
|
<item row="0" column="0">
|
||||||
<property name="spacing">
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
<number>0</number>
|
<widget class="EditorWidget" name="editorWidget"/>
|
||||||
</property>
|
<widget class="Renderer::RendererWidget" name="rendererWidget"/>
|
||||||
<item row="0" column="0">
|
</widget>
|
||||||
<widget class="QStackedWidget" name="stackedWidget">
|
</item>
|
||||||
<widget class="EditorWidget" name="editorWidget"/>
|
</layout>
|
||||||
<widget class="Renderer::RendererWidget" name="rendererWidget"/>
|
</item>
|
||||||
</widget>
|
</layout>
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
|
|
@ -168,7 +168,7 @@ QTreeWidgetItem* LayerWrapper::getQTreeItem()
|
||||||
{
|
{
|
||||||
this->qTreeWidgetItem.setText(0, this->property.name);
|
this->qTreeWidgetItem.setText(0, this->property.name);
|
||||||
this->qTreeWidgetItem.setData(0, Qt::UserRole, QVariant::fromValue(this));
|
this->qTreeWidgetItem.setData(0, Qt::UserRole, QVariant::fromValue(this));
|
||||||
return &this->qTreeWidgetItem;
|
return new QTreeWidgetItem(this->qTreeWidgetItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeWidgetItem* FolderLayerWrapper::getQTreeItem()
|
QTreeWidgetItem* FolderLayerWrapper::getQTreeItem()
|
||||||
|
|
|
@ -12,14 +12,13 @@
|
||||||
|
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
|
|
||||||
CentralWidget::CentralWidget(QWidget* parent) : QMainWindow(parent)
|
CentralWidget::CentralWidget(QWidget* parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
NavigationBarWidget* navigationBarWidget = new NavigationBarWidget(this);
|
NavigationBarWidget* navigationBarWidget = new NavigationBarWidget(this);
|
||||||
ui.gridLayout->addWidget(navigationBarWidget, 0, 0, 1, 1, Qt::AlignTop | Qt::AlignHCenter);
|
ui.gridLayout->addWidget(navigationBarWidget, 0, 0, 1, 1, Qt::AlignTop | Qt::AlignHCenter);
|
||||||
QObject::connect(navigationBarWidget->tabs, &QtMaterialTabs::currentChanged, ui.stackedWidget, &QStackedWidget::setCurrentIndex);
|
QObject::connect(navigationBarWidget->tabs, &QtMaterialTabs::currentChanged, ui.stackedWidget, &QStackedWidget::setCurrentIndex);
|
||||||
QObject::connect(ui.stackedWidget, &QStackedWidget::currentChanged,
|
QObject::connect(ui.stackedWidget, &QStackedWidget::currentChanged, ui.rendererWidget, &Renderer::RendererWidget::currentTabChanged);
|
||||||
ui.rendererWidget, &Renderer::RendererWidget::currentTabChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CentralWidget::~CentralWidget()
|
CentralWidget::~CentralWidget()
|
||||||
|
@ -40,7 +39,7 @@ MainWindow::MainWindow(QWidget* parent, const Qt::WindowFlags flags)
|
||||||
m_titleBar->chromePalette()->setTitleBarActiveBackgroundColor(QColor(0, 0, 0, 0));
|
m_titleBar->chromePalette()->setTitleBarActiveBackgroundColor(QColor(0, 0, 0, 0));
|
||||||
m_titleBar->chromePalette()->setTitleBarInactiveBackgroundColor(QColor(0, 0, 0, 0));
|
m_titleBar->chromePalette()->setTitleBarInactiveBackgroundColor(QColor(0, 0, 0, 0));
|
||||||
|
|
||||||
m_central_widget = new CentralWidget();
|
m_central_widget = new CentralWidget(this);
|
||||||
|
|
||||||
setMenuWidget(m_titleBar);
|
setMenuWidget(m_titleBar);
|
||||||
setCentralWidget(m_central_widget);
|
setCentralWidget(m_central_widget);
|
||||||
|
@ -73,4 +72,5 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
||||||
|
|
||||||
if (result != QMessageBox::Yes)
|
if (result != QMessageBox::Yes)
|
||||||
event->ignore();*/
|
event->ignore();*/
|
||||||
|
qDebug() << "closeEvent";
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
class StandardTitleBar;
|
class StandardTitleBar;
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
class CentralWidget : public QMainWindow
|
class CentralWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -117,12 +117,16 @@ QRectF calcBoundingRect(const QPainterPath& path, const std::vector<BaseStyle>&
|
||||||
Renderer::ElementRenderer::ElementRenderer()
|
Renderer::ElementRenderer::ElementRenderer()
|
||||||
{
|
{
|
||||||
surface.create();
|
surface.create();
|
||||||
thread = std::jthread([&] {
|
thread = std::jthread([&](std::stop_token stop) {
|
||||||
|
std::stop_callback cb(stop, [&] {
|
||||||
|
draw.notify_all();
|
||||||
|
});
|
||||||
|
|
||||||
QOpenGLContext context;
|
QOpenGLContext context;
|
||||||
context.create();
|
context.create();
|
||||||
context.makeCurrent(&surface);
|
context.makeCurrent(&surface);
|
||||||
|
|
||||||
initializeOpenGLFunctions();
|
auto gl = context.versionFunctions<QOpenGLFunctions_4_5_Core>();
|
||||||
shader = std::make_unique<QOpenGLShaderProgram>();
|
shader = std::make_unique<QOpenGLShaderProgram>();
|
||||||
if (!shader->addShaderFromSourceFile(QOpenGLShader::Compute, ":/Shaders/element.comp"))
|
if (!shader->addShaderFromSourceFile(QOpenGLShader::Compute, ":/Shaders/element.comp"))
|
||||||
qDebug() << "ERROR: " << shader->log();
|
qDebug() << "ERROR: " << shader->log();
|
||||||
|
@ -131,10 +135,11 @@ Renderer::ElementRenderer::ElementRenderer()
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
while (true)
|
while (!stop.stop_requested())
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(drawMutex);
|
std::unique_lock<std::mutex> lock(drawMutex);
|
||||||
draw.wait(lock, [&] {return needDraw; });
|
draw.wait(lock, [&] {return needDraw || stop.stop_requested(); });
|
||||||
|
if (needDraw)
|
||||||
{
|
{
|
||||||
needDraw = false;
|
needDraw = false;
|
||||||
auto baseStyles = style->toBaseStyles();
|
auto baseStyles = style->toBaseStyles();
|
||||||
|
@ -146,14 +151,14 @@ Renderer::ElementRenderer::ElementRenderer()
|
||||||
auto styleBuffer = generateStyleBuffer(baseStyles);
|
auto styleBuffer = generateStyleBuffer(baseStyles);
|
||||||
|
|
||||||
GLuint ssbo[2];
|
GLuint ssbo[2];
|
||||||
glCreateBuffers(2, ssbo);
|
gl->glCreateBuffers(2, ssbo);
|
||||||
glNamedBufferData(ssbo[0], pathBuffer.size() * sizeof(glm::vec2), pathBuffer.data(), GL_STATIC_READ);
|
gl->glNamedBufferData(ssbo[0], pathBuffer.size() * sizeof(glm::vec2), pathBuffer.data(), GL_STATIC_READ);
|
||||||
glNamedBufferData(ssbo[1], styleBuffer.size() * sizeof(GLfloat), styleBuffer.data(), GL_STATIC_READ);
|
gl->glNamedBufferData(ssbo[1], styleBuffer.size() * sizeof(GLfloat), styleBuffer.data(), GL_STATIC_READ);
|
||||||
|
|
||||||
auto fbo = QOpenGLFramebufferObject(size, QOpenGLFramebufferObject::NoAttachment, GL_TEXTURE_2D);
|
auto fbo = QOpenGLFramebufferObject(size, QOpenGLFramebufferObject::NoAttachment, GL_TEXTURE_2D);
|
||||||
fbo.bind();
|
fbo.bind();
|
||||||
glClearColor(0, 0, 0, 0);
|
gl->glClearColor(0, 0, 0, 0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
gl->glClear(GL_COLOR_BUFFER_BIT);
|
||||||
fbo.release();
|
fbo.release();
|
||||||
|
|
||||||
shader->bind();
|
shader->bind();
|
||||||
|
@ -161,19 +166,20 @@ Renderer::ElementRenderer::ElementRenderer()
|
||||||
shader->setUniformValue("styleSize", (GLint)styleBuffer.size());
|
shader->setUniformValue("styleSize", (GLint)styleBuffer.size());
|
||||||
shader->setUniformValue("leftTop", leftTop);
|
shader->setUniformValue("leftTop", leftTop);
|
||||||
shader->setUniformValue("pixelRatio", pixelRatio);
|
shader->setUniformValue("pixelRatio", pixelRatio);
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 10, ssbo[0]);
|
gl->glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 10, ssbo[0]);
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 11, ssbo[1]);
|
gl->glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 11, ssbo[1]);
|
||||||
glBindImageTexture(0, fbo.texture(), 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA8);
|
gl->glBindImageTexture(0, fbo.texture(), 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA8);
|
||||||
glDispatchCompute(ceil(size.width() / 8.), ceil(size.height() / 8.), 1);
|
gl->glDispatchCompute(ceil(size.width() / 8.), ceil(size.height() / 8.), 1);
|
||||||
shader->release();
|
shader->release();
|
||||||
|
|
||||||
auto image = fbo.toImage(false);
|
auto image = fbo.toImage(false);
|
||||||
glDeleteBuffers(2, ssbo);
|
gl->glDeleteBuffers(2, ssbo);
|
||||||
result = { image, leftTop };
|
result = { image, leftTop };
|
||||||
drawFinished = true;
|
drawFinished = true;
|
||||||
}
|
}
|
||||||
draw.notify_all();
|
draw.notify_all();
|
||||||
}
|
}
|
||||||
|
context.doneCurrent();
|
||||||
});
|
});
|
||||||
|
|
||||||
while (!initialized)
|
while (!initialized)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
namespace Renderer
|
namespace Renderer
|
||||||
{
|
{
|
||||||
class ElementRenderer : protected QOpenGLFunctions_4_5_Core
|
class ElementRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static ElementRenderer* instance();
|
static ElementRenderer* instance();
|
||||||
|
|
|
@ -18,7 +18,7 @@ Renderer::VirtualTextureManager::VirtualTextureManager(GladGLContext* glMain)
|
||||||
surface.create();
|
surface.create();
|
||||||
mainContext->doneCurrent();
|
mainContext->doneCurrent();
|
||||||
|
|
||||||
thread = std::jthread([&] {
|
thread = std::jthread([&](std::stop_token stop) {
|
||||||
QOpenGLContext context;
|
QOpenGLContext context;
|
||||||
context.setFormat(mainContext->format());
|
context.setFormat(mainContext->format());
|
||||||
context.setShareContext(mainContext);
|
context.setShareContext(mainContext);
|
||||||
|
@ -67,7 +67,7 @@ Renderer::VirtualTextureManager::VirtualTextureManager(GladGLContext* glMain)
|
||||||
GLuint pageLoadTimeQuery;
|
GLuint pageLoadTimeQuery;
|
||||||
gl->GenQueries(1, &pageLoadTimeQuery);
|
gl->GenQueries(1, &pageLoadTimeQuery);
|
||||||
|
|
||||||
while (true)
|
while (!stop.stop_requested())
|
||||||
{
|
{
|
||||||
if (needUpdate)
|
if (needUpdate)
|
||||||
{
|
{
|
||||||
|
@ -85,6 +85,7 @@ Renderer::VirtualTextureManager::VirtualTextureManager(GladGLContext* glMain)
|
||||||
//qDebug() << duration;
|
//qDebug() << duration;
|
||||||
pageLoadDuration += duration;
|
pageLoadDuration += duration;
|
||||||
}
|
}
|
||||||
|
std::this_thread::yield();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue