From 4ff5406acc199351670261fbbd298bd54bd0bebd Mon Sep 17 00:00:00 2001 From: wuyize Date: Thu, 16 Mar 2023 19:29:38 +0800 Subject: [PATCH] =?UTF-8?q?FIX:=20qt-material-widgets=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=9C=AA=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Editor/util/PainterPathUtil.cpp | 4 ++-- .../src/Editor/util/PainterPathUtil.h | 2 +- .../src/Renderer/Painting/MaterialStyleStroke.cpp | 2 +- .../src/Renderer/Preview/ElementRenderer.cpp | 6 ++++-- ArchitectureColoredPainting/src/main.cpp | 1 + 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.cpp b/ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.cpp index e7d3b49..104abb6 100644 --- a/ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.cpp +++ b/ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.cpp @@ -15,7 +15,7 @@ vector> PainterPathUtil::transformToLines(const QPainterPath& pai for (int elementIndex = 0; elementIndex < painterPath.elementCount(); elementIndex++) { auto element = painterPath.elementAt(elementIndex); point = element; - qDebug() << element; + //qDebug() << element; if (element.isMoveTo()) { if (line.size() >= 2) { lines.push_back(line); @@ -43,7 +43,7 @@ vector> PainterPathUtil::transformToLines(const QPainterPath& pai return lines; } -QPainterPath PainterPathUtil::monotonization(QPainterPath& painterPath) { +QPainterPath PainterPathUtil::monotonization(const QPainterPath& painterPath) { QPainterPath resPath; vector > lines = transformToLines(painterPath); vector> linePtrVector; diff --git a/ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.h b/ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.h index f6fabcb..196142c 100644 --- a/ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.h +++ b/ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.h @@ -7,7 +7,7 @@ class PainterPathUtil { public: static std::vector> transformToLines(const QPainterPath& painterPath); - static QPainterPath monotonization(QPainterPath& painterPath); + static QPainterPath monotonization(const QPainterPath& painterPath); static std::pair normalized(const QPainterPath& path, float width = 0); static std::pair>, float> toNormalizedLines(const QPainterPath& path, float width = 0); }; diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.cpp index 3c8686b..0d72542 100644 --- a/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.cpp +++ b/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.cpp @@ -59,7 +59,7 @@ std::vector Renderer::StrokeRadialGradient::encoded() const v.y = pair.first; result.push_back(glm::uintBitsToFloat(glm::packUnorm2x16(v))); result.push_back(glm::uintBitsToFloat(glm::packUnorm4x8(color))); - qDebug() << pair.first; + //qDebug() << pair.first; } return result; } diff --git a/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp b/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp index 45b700a..3be860f 100644 --- a/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp +++ b/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp @@ -10,6 +10,7 @@ #include "../Painting/Element.h" #include "../Painting/Painting.h" #include "../Painting/MaterialStyleStroke.h" +#include using namespace Renderer; std::vector generatePathBuffer(const QPainterPath& path) @@ -78,7 +79,7 @@ std::vector generateStyleBuffer(const std::vector& styles) auto encoded = style.material->encoded(); styleBuffer.insert(styleBuffer.end(), encoded.begin(), encoded.end()); - qDebug() << "style size" << styleBuffer.size(); + //qDebug() << "style size" << styleBuffer.size(); } return styleBuffer; } @@ -199,7 +200,8 @@ std::pair Renderer::ElementRenderer::drawElement(const QPainter std::unique_lock lock(drawMutex); draw.wait(lock, [&] {return drawFinished; }); drawFinished = false; - this->path = &path; + QPainterPath monotonized = PainterPathUtil::monotonization(path); + this->path = &monotonized; this->style = &style; this->pixelRatio = pixelRatio; needDraw = true; diff --git a/ArchitectureColoredPainting/src/main.cpp b/ArchitectureColoredPainting/src/main.cpp index e43c971..6ef683c 100644 --- a/ArchitectureColoredPainting/src/main.cpp +++ b/ArchitectureColoredPainting/src/main.cpp @@ -49,6 +49,7 @@ int main(int argc, char* argv[]) //QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); QApplication a(argc, argv); + Q_INIT_RESOURCE(resources); //FramelessHelper::Core::setApplicationOSThemeAware(); FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur); //FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);