diff --git a/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.cpp b/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.cpp index 6eec65d..f3875a5 100644 --- a/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.cpp +++ b/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.cpp @@ -32,9 +32,9 @@ void ElementPoolWidget::setElementList(std::vector elements) { // //QString strPath = QString("C:\\Users\\86177\\Pictures\\Screenshots\\test.png"); //QPixmap itemPixmap(strPath); - QPixmap itemPixmap(QSize(200,200)); - itemPixmap.fill(Qt::red); - //QPixmap itemPixmap = elements[index]->getPaintObject().getDetail(); + //QPixmap itemPixmap(QSize(200,200)); + //itemPixmap.fill(Qt::red); + QPixmap itemPixmap = elements[index]->getPaintObject().getDetail(); qDebug() << this->parentWidget()->size(); //auto p = new QWidget(); //auto lb = new QLabel(p); diff --git a/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp b/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp index 53e894c..082ac27 100644 --- a/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp +++ b/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp @@ -36,7 +36,6 @@ void PreviewWindow::show() void PreviewWindow::initializeGL() { - this->renderer->initialize(); initializeOpenGLFunctions(); } diff --git a/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp b/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp index ccd742e..d7744a7 100644 --- a/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp +++ b/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp @@ -12,11 +12,6 @@ #include "../Painting/MaterialStyleStroke.h" using namespace Renderer; -Renderer::ElementRenderer::ElementRenderer(QOpenGLWidget* glWidget) - : glWidget(glWidget) -{ -} - std::vector generatePathBuffer(const QPainterPath& path) { std::vector pathBuffer; @@ -119,18 +114,14 @@ QRectF calcBoundingRect(const QPainterPath& path, const std::vector& return QRectF(QPointF(leftTop.x, leftTop.y), QPointF(rightBottom.x, rightBottom.y)); } -void Renderer::ElementRenderer::initialize() +Renderer::ElementRenderer::ElementRenderer(QOpenGLWidget* glWidget) + : glWidget(glWidget) { - auto mainContext = QOpenGLContext::currentContext(); - auto mainSurface = mainContext->surface(); - surface.setFormat(mainContext->format()); surface.create(); - mainContext->doneCurrent(); thread = std::jthread([&] { + std::cout << thread.get_id(); QOpenGLContext context; - context.setFormat(mainContext->format()); - context.setShareContext(mainContext); context.create(); context.makeCurrent(&surface); @@ -190,9 +181,6 @@ void Renderer::ElementRenderer::initialize() while (!initialized) std::this_thread::yield(); - - mainContext->makeCurrent(mainSurface); - } std::pair Renderer::ElementRenderer::drawElement(const QPainterPath& path, const ElementStyle& style, float pixelRatio) diff --git a/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.h b/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.h index 6cf9410..c2f10b9 100644 --- a/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.h +++ b/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.h @@ -12,11 +12,6 @@ namespace Renderer public: ElementRenderer(QOpenGLWidget* glWidget); - /** - * @brief 须在initializeGL函数中调用 - */ - void initialize(); - /** * @brief 将图元绘制到QImage * @param path 图元几何数据 @@ -37,7 +32,6 @@ namespace Renderer bool needDraw = false; std::condition_variable draw; std::mutex drawMutex; - const QPainterPath* path; const ElementStyle* style; float pixelRatio;