From e5a22bd02afe3c41fe32813ffb5795aefab452f5 Mon Sep 17 00:00:00 2001 From: wuyize Date: Wed, 1 Feb 2023 22:46:30 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E7=A1=AE=E5=AE=9AStyle?= =?UTF-8?q?=E7=9A=84=E7=BB=93=E6=9E=84=EF=BC=8C=E4=BF=AE=E5=A4=8D=E4=BA=86?= =?UTF-8?q?=E7=BC=96=E8=AF=91FramelessHelper=E6=97=B6=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ArchitectureColoredPainting.sln | 20 +- .../ArchitectureColoredPainting.vcxproj | 10 +- ...rchitectureColoredPainting.vcxproj.filters | 18 ++ .../Shaders/painting.comp | 33 ++- .../src/Renderer/Model.cpp | 97 ++++--- .../src/Renderer/Painting/BaseStyle.cpp | 3 + .../src/Renderer/Painting/BaseStyle.h | 33 +++ .../src/Renderer/Painting/Element.h | 23 +- .../src/Renderer/Painting/ElementStyle.cpp | 17 +- .../src/Renderer/Painting/ElementStyle.h | 25 +- .../Renderer/Painting/MaterialStyleFill.cpp | 48 +++ .../src/Renderer/Painting/MaterialStyleFill.h | 41 +++ .../Renderer/Painting/MaterialStyleStroke.cpp | 57 ++++ .../Renderer/Painting/MaterialStyleStroke.h | 47 +++ .../src/Renderer/Painting/Painting.cpp | 132 ++++++--- .../src/Renderer/Painting/Painting.h | 48 ++- .../{ => FramelessHelperCore}/.qmake.stash | 26 +- .../FramelessHelperCore.pro | 6 +- .../FramelessHelperCore.vcxproj | 86 +++--- .../FramelessHelperCore.vcxproj.filters | 70 ++--- .../qmake/FramelessHelperWidgets/.qmake.stash | 23 ++ .../FramelessHelperWidgets.pro | 4 +- .../FramelessHelperWidgets.vcxproj | 60 ++-- .../FramelessHelperWidgets.vcxproj.filters | 44 +-- FramelessHelper/qmake/core.vcxproj | 274 ------------------ FramelessHelper/qmake/core.vcxproj.filters | 186 ------------ 26 files changed, 681 insertions(+), 750 deletions(-) create mode 100644 ArchitectureColoredPainting/src/Renderer/Painting/BaseStyle.cpp create mode 100644 ArchitectureColoredPainting/src/Renderer/Painting/BaseStyle.h create mode 100644 ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleFill.cpp create mode 100644 ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleFill.h create mode 100644 ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.cpp create mode 100644 ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.h rename FramelessHelper/qmake/{ => FramelessHelperCore}/.qmake.stash (62%) rename FramelessHelper/qmake/{ => FramelessHelperCore}/FramelessHelperCore.pro (94%) rename FramelessHelper/qmake/{ => FramelessHelperCore}/FramelessHelperCore.vcxproj (78%) rename FramelessHelper/qmake/{ => FramelessHelperCore}/FramelessHelperCore.vcxproj.filters (61%) create mode 100644 FramelessHelper/qmake/FramelessHelperWidgets/.qmake.stash rename FramelessHelper/qmake/{ => FramelessHelperWidgets}/FramelessHelperWidgets.pro (92%) rename FramelessHelper/qmake/{ => FramelessHelperWidgets}/FramelessHelperWidgets.vcxproj (81%) rename FramelessHelper/qmake/{ => FramelessHelperWidgets}/FramelessHelperWidgets.vcxproj.filters (61%) delete mode 100644 FramelessHelper/qmake/core.vcxproj delete mode 100644 FramelessHelper/qmake/core.vcxproj.filters diff --git a/ArchitectureColoredPainting.sln b/ArchitectureColoredPainting.sln index dbfe560..a700f6a 100644 --- a/ArchitectureColoredPainting.sln +++ b/ArchitectureColoredPainting.sln @@ -5,9 +5,9 @@ VisualStudioVersion = 17.2.32519.379 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ArchitectureColoredPainting", "ArchitectureColoredPainting\ArchitectureColoredPainting.vcxproj", "{3FE96A33-2BB7-4686-A710-3EB8E3BBD709}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FramelessHelperCore", "FramelessHelper\qmake\FramelessHelperCore.vcxproj", "{F1BC586E-F1ED-320C-899E-76CCB5660AE1}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FramelessHelperCore", "FramelessHelper\qmake\FramelessHelperCore\FramelessHelperCore.vcxproj", "{954D3D24-DF86-33A3-8867-D1735CCBDB10}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FramelessHelperWidgets", "FramelessHelper\qmake\FramelessHelperWidgets.vcxproj", "{61651EC8-A30E-3935-BD0C-A01AE3EE0AD9}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FramelessHelperWidgets", "FramelessHelper\qmake\FramelessHelperWidgets\FramelessHelperWidgets.vcxproj", "{E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -19,14 +19,14 @@ Global {3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Debug|x64.Build.0 = Debug|x64 {3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Release|x64.ActiveCfg = Release|x64 {3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Release|x64.Build.0 = Release|x64 - {F1BC586E-F1ED-320C-899E-76CCB5660AE1}.Debug|x64.ActiveCfg = Debug|x64 - {F1BC586E-F1ED-320C-899E-76CCB5660AE1}.Debug|x64.Build.0 = Debug|x64 - {F1BC586E-F1ED-320C-899E-76CCB5660AE1}.Release|x64.ActiveCfg = Release|x64 - {F1BC586E-F1ED-320C-899E-76CCB5660AE1}.Release|x64.Build.0 = Release|x64 - {61651EC8-A30E-3935-BD0C-A01AE3EE0AD9}.Debug|x64.ActiveCfg = Debug|x64 - {61651EC8-A30E-3935-BD0C-A01AE3EE0AD9}.Debug|x64.Build.0 = Debug|x64 - {61651EC8-A30E-3935-BD0C-A01AE3EE0AD9}.Release|x64.ActiveCfg = Release|x64 - {61651EC8-A30E-3935-BD0C-A01AE3EE0AD9}.Release|x64.Build.0 = Release|x64 + {954D3D24-DF86-33A3-8867-D1735CCBDB10}.Debug|x64.ActiveCfg = Debug|x64 + {954D3D24-DF86-33A3-8867-D1735CCBDB10}.Debug|x64.Build.0 = Debug|x64 + {954D3D24-DF86-33A3-8867-D1735CCBDB10}.Release|x64.ActiveCfg = Release|x64 + {954D3D24-DF86-33A3-8867-D1735CCBDB10}.Release|x64.Build.0 = Release|x64 + {E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Debug|x64.ActiveCfg = Debug|x64 + {E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Debug|x64.Build.0 = Debug|x64 + {E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Release|x64.ActiveCfg = Release|x64 + {E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj index 79ab108..88298bf 100644 --- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj +++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj @@ -114,6 +114,7 @@ + @@ -122,10 +123,12 @@ + + @@ -179,10 +182,13 @@ + + + @@ -207,8 +213,8 @@ - - {61651ec8-a30e-3935-bd0c-a01ae3ee0ad9} + + {e7a71e05-4aa5-31db-a17d-542fc7bd83a3} diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters index 70e0c28..142c944 100644 --- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters +++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters @@ -184,6 +184,15 @@ Source Files\Renderer\Painting + + Source Files\Renderer\Painting + + + Source Files\Renderer\Painting + + + Source Files\Renderer\Painting + @@ -377,6 +386,15 @@ Header Files\Renderer\Painting + + Header Files\Renderer\Painting + + + Header Files\Renderer\Painting + + + Header Files\Renderer\Painting + diff --git a/ArchitectureColoredPainting/Shaders/painting.comp b/ArchitectureColoredPainting/Shaders/painting.comp index 96fbdbd..46b31cc 100644 --- a/ArchitectureColoredPainting/Shaders/painting.comp +++ b/ArchitectureColoredPainting/Shaders/painting.comp @@ -898,12 +898,13 @@ void drawLine(in float d, in uint styleIndex, out vec4 elementColor, out vec2 me { elementColor = vec4(1); metallicRoughness = vec2(0.8); - switch(int(elementData[styleIndex+3])) + //switch(int(elementData[styleIndex+3])) + switch(0) { case 0: { - elementColor = vec4(elementData[styleIndex+7],elementData[styleIndex+8],elementData[styleIndex+9],1); - metallicRoughness = vec2(elementData[styleIndex+10],elementData[styleIndex+11]); + elementColor = vec4(unpackUnorm4x8(floatBitsToUint(elementData[styleIndex+2])).rgb,1); + metallicRoughness = vec2(unpackUnorm4x8(floatBitsToUint(elementData[styleIndex+1])).rg); break; } case 1: @@ -972,9 +973,10 @@ bool drawElement(uint elementIndex, vec2 localUV, out vec3 color, out vec2 metal } //uint styleIndex = bvhChildren[elementBvhRoot + elementBvhIndex].y; //uint elementType = bvhChildren[elementBvhRoot + elementBvhIndex].y; - float elementType = elementData[styleIndex]; + //float elementType = elementData[styleIndex]; + bool isFillStyle = elementData[styleIndex]<=0; // for(int i = 0; i<200;i++) - if (elementType == 0) //Ãæ + if (isFillStyle) //Ãæ { uint contourIndex = linesOffset + leftChild - 0x80000000; @@ -1015,22 +1017,25 @@ bool drawElement(uint elementIndex, vec2 localUV, out vec3 color, out vec2 metal { hitElement = true; elementColor = vec4(1,1,0,0); - if(elementData[styleIndex+1]==0) + + vec4 head = unpackUnorm4x8(floatBitsToUint(elementData[styleIndex])); + if(head.z==0) { - elementColor = vec4(elementData[styleIndex+2],elementData[styleIndex+3],elementData[styleIndex+4],0); - metallicRoughness = vec2(elementData[styleIndex+5],elementData[styleIndex+6]); + elementColor = vec4(unpackUnorm4x8(floatBitsToUint(elementData[styleIndex+1])).rgb,0); + metallicRoughness = head.xy; } } } - else if (elementType == 1) //Ïß + else //Ïß { - float strokeWidth = elementData[styleIndex+1]; + float strokeWidth = elementData[styleIndex]; uint contourIndex = linesOffset + leftChild - 0x80000000; float minDistance = 1e38; uint lineCount = elementIndexs[contourIndex]; - float lineType = elementData[styleIndex+4]; + //float lineType = elementData[styleIndex+4]; + float lineType = 2; vec2 p3Last = vec2(1e38); vec2 p2Last = vec2(1e38); int debugBegin = 0; @@ -1169,9 +1174,9 @@ void main() uint leftChild = bvhChildren[index].x; if (leftChild >= bvhLength) { - uint zIndex = bvhChildren[index].y / 65535; + uint zIndex = bvhChildren[index].y >> 18; + bvec2 flip = bvec2(bvhChildren[index].y & (1<<16), bvhChildren[index].y & (1<<17)); float angle = (float(bvhChildren[index].y) / 65535.0 - zIndex) * 2 * PI; - mat2 rotation = {{cos(angle), -sin(angle)}, {sin(angle), cos(angle)}}; vec2 localUV = uv - (bound.xy + bound.zw) / 2; localUV = rotation * localUV; @@ -1184,6 +1189,8 @@ void main() //debugBVH.bg += 0.5 * (localUV + vec2(1)); //debugBVH = vec3(0); + if(flip.x) localUV.x = -localUV.x; + if(flip.y) localUV.y = -localUV.y; vec3 elementColor; vec2 elementMetallicRoughness; if(drawElement(leftChild - 0x80000000, localUV, elementColor, elementMetallicRoughness, debugBVH)) diff --git a/ArchitectureColoredPainting/src/Renderer/Model.cpp b/ArchitectureColoredPainting/src/Renderer/Model.cpp index d648b44..b33f599 100644 --- a/ArchitectureColoredPainting/src/Renderer/Model.cpp +++ b/ArchitectureColoredPainting/src/Renderer/Model.cpp @@ -350,50 +350,54 @@ GLuint Renderer::Model::loadPainting(std::string path) std::make_shared(SvgParser("M377,459.61a11.26,11.26,0,0,1,11.27-11.27H696.12a11.27,11.27,0,0,0,11-8.62A359.84,359.84,0,0,0,708,280.56a11.26,11.26,0,0,0-11-8.73H388.27A11.26,11.26,0,0,1,377,260.57h0a11.26,11.26,0,0,1,11.27-11.26H683.71A11.32,11.32,0,0,0,694.28,234C649.8,113.69,542.57,23.85,412.3,4.12a11.22,11.22,0,0,0-12.76,11.17v158.9a11.26,11.26,0,0,0,11.26,11.27H583.12a11.32,11.32,0,0,0,9.26-17.75c-31.67-46.59-78.51-75.2-109.11-90.07a11.25,11.25,0,0,0-16.13,10.17V115.2a11.24,11.24,0,0,0,6.22,10.07l7.51,3.76a11.28,11.28,0,0,1,5,15.12h0a11.27,11.27,0,0,1-15.11,5l-20-10a11.27,11.27,0,0,1-6.22-10.07V54a11.27,11.27,0,0,1,14.62-10.75c5.11,1.59,125.66,40.35,172.24,149A11.27,11.27,0,0,1,621.11,208H388.27A11.26,11.26,0,0,1,377,196.73V11.36A11.32,11.32,0,0,0,365.89.08C363.34,0,360.79,0,358.22,0s-5.11,0-7.66.08a11.32,11.32,0,0,0-11.11,11.28V196.74A11.26,11.26,0,0,1,328.18,208H95.35A11.27,11.27,0,0,1,85,192.3c46.57-108.67,167.12-147.42,172.23-149A11.26,11.26,0,0,1,271.86,54v75.11a11.25,11.25,0,0,1-6.23,10.07l-20,10a11.27,11.27,0,0,1-15.11-5h0a11.26,11.26,0,0,1,5-15.11l7.52-3.76a11.27,11.27,0,0,0,6.22-10.07V87.82a11.25,11.25,0,0,0-16.14-10.16c-30.6,14.87-77.45,43.48-109.1,90.07a11.3,11.3,0,0,0,9.25,17.74H305.66a11.26,11.26,0,0,0,11.27-11.26V15.31A11.22,11.22,0,0,0,304.17,4.14C173.88,23.86,66.66,113.71,22.17,234a11.32,11.32,0,0,0,10.56,15.29H328.18a11.26,11.26,0,0,1,11.27,11.26v0a11.26,11.26,0,0,1-11.27,11.26H19.52a11.26,11.26,0,0,0-11,8.72,359.84,359.84,0,0,0,.83,159.16,11.26,11.26,0,0,0,11,8.61H328.18a11.26,11.26,0,0,1,11.27,11.27h0a11.26,11.26,0,0,1-11.27,11.26h-294a11.32,11.32,0,0,0-10.53,15.4C69,604.65,175.3,692.78,304.16,712.3a11.21,11.21,0,0,0,12.76-11.16V542.22A11.26,11.26,0,0,0,305.66,531h-166c-9.53,0-14.89,11.22-8.69,18.47,34.09,39.77,74.45,65.66,101.77,80.18a11.25,11.25,0,0,0,16.53-10V591a11.26,11.26,0,0,1,11.26-11.26h0A11.26,11.26,0,0,1,271.85,591v63.85A11.27,11.27,0,0,1,256.8,665.5c-4.45-1.59-109.58-40-171-139.9a11.27,11.27,0,0,1,9.59-17.17H328.18a11.26,11.26,0,0,1,11.27,11.26V705.08a11.32,11.32,0,0,0,11.11,11.28q3.82.07,7.66.08c2.57,0,5.12,0,7.67-.08A11.32,11.32,0,0,0,377,705.08V519.69a11.25,11.25,0,0,1,11.27-11.26H621.1a11.26,11.26,0,0,1,9.59,17.16c-61.46,99.87-166.59,138.3-171,139.9a11.27,11.27,0,0,1-15-10.61V591a11.26,11.26,0,0,1,11.26-11.26h0A11.26,11.26,0,0,1,467.14,591v28.6a11.25,11.25,0,0,0,16.53,10c27.33-14.53,67.68-40.42,101.77-80.19,6.2-7.23.85-18.46-8.69-18.46h-166a11.26,11.26,0,0,0-11.26,11.26V701.12a11.21,11.21,0,0,0,12.76,11.17c128.86-19.51,235.14-107.66,280.48-226a11.33,11.33,0,0,0-10.53-15.41h-294A11.25,11.25,0,0,1,377,459.61ZM35.27,399.53V316.9a11.26,11.26,0,0,1,11.27-11.26H669.92a11.25,11.25,0,0,1,11.26,11.26v82.63a11.25,11.25,0,0,1-11.26,11.26H46.54a11.27,11.27,0,0,1-11.27-11.26Z", 716.45, 716.44).parse()) }; - + //vector> style = { + // std::make_shared(std::vector{ + // //strokeStyle + // //stroke + // 1, + // //strokeWidth + // 0.02, + // //strokeEndType + // 0, //Ô²½Ç + // //strokeFillType + // 0, //µ¥É« + // //ÏßÀàÐÍ + // 0, //Ë«²à + // //ÏßÍâÃè±ß¿í¶È + // 0, + // //ÏßÍâÃè±ß·½Ê½ + // 0, //µ¥É« + // //strokeFillColorMetallicRoughness + // 1,0,1, 0,0.8, + // }), + // std::make_shared(std::vector{ + // //fillStyle + // //fill + // 0, + // //fillType + // 0, //µ¥É« + // //fillColorMetallicRoughness + // 240 / 255., 220 / 255., 160 / 255., 0.996, 0.18, + // }), + // std::make_shared(std::vector{ + // //fillStyle + // //fill + // 0, + // //fillType + // 0, //µ¥É« + // //fillColorMetallicRoughness + // 24 / 255., 220 / 255., 16 / 255., 0., 0.18, + // }), + //}; - vector> style = { - std::make_shared(std::vector{ - //strokeStyle - //stroke - 1, - //strokeWidth - 0.02, - //strokeEndType - 0, //Ô²½Ç - //strokeFillType - 0, //µ¥É« - //ÏßÀàÐÍ - 0, //Ë«²à - //ÏßÍâÃè±ß¿í¶È - 0, - //ÏßÍâÃè±ß·½Ê½ - 0, //µ¥É« - //strokeFillColorMetallicRoughness - 1,0,1, 0,0.8, - }), - std::make_shared(std::vector{ - //fillStyle - //fill - 0, - //fillType - 0, //µ¥É« - //fillColorMetallicRoughness - 240 / 255., 220 / 255., 160 / 255., 0.996, 0.18, - }), - std::make_shared(std::vector{ - //fillStyle - //fill - 0, - //fillType - 0, //µ¥É« - //fillColorMetallicRoughness - 24 / 255., 220 / 255., 16 / 255., 0., 0.18, - }), + vector> style = { + std::make_shared(), + std::make_shared() }; + vector> element = { - std::make_shared(Element{ contour[0], style[1]}), - std::make_shared(Element{ contour[1], style[0]}), + std::make_shared(Element{ contour[0], style[0]}), + std::make_shared(Element{ contour[1], style[1]}), std::make_shared(Element{ contour[2], style[0]}), }; Painting painting; @@ -406,9 +410,14 @@ GLuint Renderer::Model::loadPainting(std::string path) // //rootBvhTreeData.push_back(BvhTreeData(QVector4D(x, y, z, w), 0, encodeZIndexAngle(1, (float)rand() / RAND_MAX * 360))); // painting.addElement(element[i%3], QVector4D(x, y, z, w), (float)rand() / RAND_MAX * 360, 1); //} - painting.addElement(element[0], QVector4D(-0.8, -0.8, -0.2, -0.1), 0, 0); - painting.addElement(element[1], QVector4D(-0.7, 0.2, -0.2, 0.7), 0, 0); - painting.addElement(element[2], QVector4D(0.2, -0.8, 0.8, -0.1), 0, 0); + painting.addElement(*element[0], ElementTransform{ glm::vec2(-0.5,-0.45), glm::vec2(0.6,0.7), 0, glm::bvec2(true, false), 0 }); + painting.addElement(*element[1], ElementTransform{ glm::vec2(-0.45,0.45), glm::vec2(0.5,0.5), 0, glm::bvec2(false), 0 }); + painting.addElement(*element[2], ElementTransform{ glm::vec2(0.5,-0.45), glm::vec2(0.6,0.7), 0, glm::bvec2(false), 0 }); + + + //painting.addElement(element[0], QVector4D(-0.8, -0.8, -0.2, -0.1), 0, 0); + //painting.addElement(element[1], QVector4D(-0.7, 0.2, -0.2, 0.7), 0, 0); + //painting.addElement(element[2], QVector4D(0.2, -0.8, 0.8, -0.1), 0, 0); painting.generateBuffers(); ///////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/BaseStyle.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/BaseStyle.cpp new file mode 100644 index 0000000..f690a9c --- /dev/null +++ b/ArchitectureColoredPainting/src/Renderer/Painting/BaseStyle.cpp @@ -0,0 +1,3 @@ +#include "BaseStyle.h" + +using namespace Renderer; \ No newline at end of file diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/BaseStyle.h b/ArchitectureColoredPainting/src/Renderer/Painting/BaseStyle.h new file mode 100644 index 0000000..b02a657 --- /dev/null +++ b/ArchitectureColoredPainting/src/Renderer/Painting/BaseStyle.h @@ -0,0 +1,33 @@ +#pragma once +#include +#include +#include +#include + +namespace Renderer +{ + /// Ïà¶Ô±ä»»£¬ÓÃÓÚÖÆ×÷ÒõÓ°µÈЧ¹û + struct TransformStyle + { + glm::vec2 translation = glm::vec2(0); + glm::vec2 scale = glm::vec2(1); + float rotation = 0; + glm::bvec2 flip = glm::bvec2(false); + }; + + enum class MaterialStyleType { kFill, kStroke }; + + class MaterialStyle + { + public: + virtual MaterialStyleType type() const = 0; + virtual std::vector encoded() const = 0; + virtual bool operator==(const MaterialStyle&) const = 0; + }; + + struct BaseStyle + { + std::shared_ptr transform; + std::shared_ptr material; + }; +} diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/Element.h b/ArchitectureColoredPainting/src/Renderer/Painting/Element.h index ac8361a..d4f887f 100644 --- a/ArchitectureColoredPainting/src/Renderer/Painting/Element.h +++ b/ArchitectureColoredPainting/src/Renderer/Painting/Element.h @@ -2,17 +2,24 @@ #include #include #include "Line.h" +#include "ElementStyle.h" namespace Renderer { - class Element - { - public: - std::vector bvhChildren; - std::vector bvhBound; - std::vector elementIndex; - std::vector points; + using Contour = std::vector>; - Element(std::vector> lines); + struct Element + { + std::shared_ptr contour; + std::shared_ptr style; + }; + + struct ElementTransform + { + glm::vec2 center; + glm::vec2 size; + float rotation; /// ½Ç¶ÈÖÆ + glm::bvec2 flip; + GLuint zIndex; }; } \ No newline at end of file diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/ElementStyle.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/ElementStyle.cpp index 685165e..e65ce5f 100644 --- a/ArchitectureColoredPainting/src/Renderer/Painting/ElementStyle.cpp +++ b/ArchitectureColoredPainting/src/Renderer/Painting/ElementStyle.cpp @@ -1,18 +1,17 @@ #include "ElementStyle.h" +#include "MaterialStyleFill.h" +#include "MaterialStyleStroke.h" using namespace Renderer; -ElementStyle::ElementStyle(std::vector style) - :style(style) +std::vector Renderer::ElementStyleFillDemo::toBaseStyles() const { + return { BaseStyle(std::make_shared(), + std::make_shared(std::make_shared(QColor(0, 255, 0), 0, 0.8))) }; } -bool Renderer::ElementStyle::isLine() +std::vector Renderer::ElementStyleStrokeDemo::toBaseStyles() const { - return style[0]; -} - -std::vector ElementStyle::encoded() -{ - return style; + return { BaseStyle(std::make_shared(), + std::make_shared(0.02, StrokeType::kBothSides, StrokeEndType::kRound, std::make_shared(QColor(0, 0, 255), 0, 0.8))) }; } diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/ElementStyle.h b/ArchitectureColoredPainting/src/Renderer/Painting/ElementStyle.h index 18a61f4..53cb306 100644 --- a/ArchitectureColoredPainting/src/Renderer/Painting/ElementStyle.h +++ b/ArchitectureColoredPainting/src/Renderer/Painting/ElementStyle.h @@ -1,16 +1,31 @@ #pragma once #include #include +#include "BaseStyle.h" namespace Renderer { class ElementStyle { public: - ElementStyle(std::vector style); - bool isLine(); - std::vector encoded(); - private: - std::vector style; + /** + * @brief ½«Í¼ÔªÑùʽתΪÈô¸É»ù±¾Ñùʽ + * @return BaseStyleÊý×飬Êý×éϱê˳Ðò¼´ÎªzIndex˳Ðò£¬Êý×é´óС²»µÃ´óÓÚ10 + */ + virtual std::vector toBaseStyles() const = 0; + }; + + // TODO: ´ËΪʾÀý£¬½¨Òéдµ½Editor²¿·Ö±ãÓÚÓëUI°ó¶¨ + class ElementStyleFillDemo : public ElementStyle + { + public: + virtual std::vector toBaseStyles() const override; + }; + + // TODO: ´ËΪʾÀý£¬½¨Òéдµ½Editor²¿·Ö±ãÓÚÓëUI°ó¶¨ + class ElementStyleStrokeDemo : public ElementStyle + { + public: + virtual std::vector toBaseStyles() const override; }; } diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleFill.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleFill.cpp new file mode 100644 index 0000000..889b72e --- /dev/null +++ b/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleFill.cpp @@ -0,0 +1,48 @@ +#include "MaterialStyleFill.h" + +using namespace Renderer; + +Renderer::FillPlain::FillPlain(QColor color, float metallic, float roughness) + : color(color), metallic(metallic), roughness(roughness) +{ +} + +MaterialFillType Renderer::FillPlain::type() const +{ + return MaterialFillType::kPlain; +} + +std::vector Renderer::FillPlain::encoded() const +{ + return { glm::uintBitsToFloat(glm::packUnorm4x8(glm::vec4(metallic, roughness, 0, 1))), + glm::uintBitsToFloat(glm::packUnorm4x8(glm::vec4(color.redF(), color.greenF(), color.blueF(), color.alphaF())))}; +} + +bool Renderer::FillPlain::operator==(const MaterialFill& m) const +{ + return type() == m.type() + && color == static_cast(m).color + && metallic == static_cast(m).metallic + && roughness == static_cast(m).roughness; +} + + +Renderer::MaterialStyleFill::MaterialStyleFill(std::shared_ptr materialFill) + : materialFill(materialFill) +{ +} + +MaterialStyleType Renderer::MaterialStyleFill::type() const +{ + return MaterialStyleType::kFill; +} + +std::vector Renderer::MaterialStyleFill::encoded() const +{ + return materialFill->encoded(); +} + +bool Renderer::MaterialStyleFill::operator==(const MaterialStyle& m) const +{ + return type() == m.type() && *materialFill == *static_cast(m).materialFill; +} diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleFill.h b/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleFill.h new file mode 100644 index 0000000..40e5c37 --- /dev/null +++ b/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleFill.h @@ -0,0 +1,41 @@ +#pragma once +#include "BaseStyle.h" + +namespace Renderer +{ + enum class MaterialFillType { kPlain, kLinearGradient, kRadialGradient }; + + class MaterialFill + { + public: + virtual MaterialFillType type() const = 0; + virtual std::vector encoded() const = 0; + virtual bool operator==(const MaterialFill&) const = 0; + }; + + class FillPlain : public MaterialFill + { + public: + FillPlain(QColor color, float metallic, float roughness); + virtual MaterialFillType type() const override; + virtual std::vector encoded() const override; + virtual bool operator==(const MaterialFill&) const override; + + QColor color; + float metallic; + float roughness; + }; + + class MaterialStyleFill : public MaterialStyle + { + public: + MaterialStyleFill(std::shared_ptr materialFill); + virtual MaterialStyleType type() const override; + virtual std::vector encoded() const override; + virtual bool operator==(const MaterialStyle&) const override; + protected: + std::shared_ptr materialFill; + }; + + +} diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.cpp new file mode 100644 index 0000000..4948314 --- /dev/null +++ b/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.cpp @@ -0,0 +1,57 @@ +#include "MaterialStyleStroke.h" + +using namespace Renderer; + +Renderer::StrokePlain::StrokePlain(QColor color, float metallic, float roughness) + : color(color), metallic(metallic), roughness(roughness) +{ +} + +MaterialStrokeType Renderer::StrokePlain::type() const +{ + return MaterialStrokeType::kPlain; +} + +std::vector Renderer::StrokePlain::encoded() const +{ + return { glm::uintBitsToFloat(glm::packUnorm4x8(glm::vec4(metallic, roughness, 0, 0))), + glm::uintBitsToFloat(glm::packUnorm4x8(glm::vec4(color.redF(), color.greenF(), color.blueF(), color.alphaF()))) }; +} + +bool Renderer::StrokePlain::operator==(const MaterialStroke& m) const +{ + return type() == m.type() + && color == static_cast(m).color + && metallic == static_cast(m).metallic + && roughness == static_cast(m).roughness; +} + +Renderer::MaterialStyleStroke::MaterialStyleStroke(float width, StrokeType strokeType, StrokeEndType endType, std::shared_ptr materialStroke) + : width(width), strokeType(strokeType), endType(endType), materialStroke(materialStroke) +{ +} + +MaterialStyleType Renderer::MaterialStyleStroke::type() const +{ + return MaterialStyleType::kStroke; +} + +std::vector Renderer::MaterialStyleStroke::encoded() const +{ + std::vector v = { width }; + auto encoded = materialStroke->encoded(); + v.insert(v.end(), encoded.begin(), encoded.end()); + return v; +} + +bool Renderer::MaterialStyleStroke::operator==(const MaterialStyle& m) const +{ + return type() == m.type() && *materialStroke == *static_cast(m).materialStroke; +} + +float Renderer::MaterialStyleStroke::getWidth() const +{ + return width; +} + + diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.h b/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.h new file mode 100644 index 0000000..b9b8fbd --- /dev/null +++ b/ArchitectureColoredPainting/src/Renderer/Painting/MaterialStyleStroke.h @@ -0,0 +1,47 @@ +#pragma once +#include "BaseStyle.h" + +namespace Renderer +{ + enum class MaterialStrokeType { kPlain }; + + class MaterialStroke + { + public: + virtual MaterialStrokeType type() const = 0; + virtual std::vector encoded() const = 0; + virtual bool operator==(const MaterialStroke&) const = 0; + }; + + class StrokePlain : public MaterialStroke + { + public: + StrokePlain(QColor color, float metallic, float roughness); + virtual MaterialStrokeType type() const override; + virtual std::vector encoded() const override; + virtual bool operator==(const MaterialStroke&) const override; + + QColor color; + float metallic; + float roughness; + }; + + + enum class StrokeType { kBothSides = 2, kLeftSide = 1, kRightSide = 0 }; + enum class StrokeEndType { kRound }; + + class MaterialStyleStroke : public MaterialStyle + { + public: + MaterialStyleStroke(float width, StrokeType strokeType, StrokeEndType endType, std::shared_ptr materialStroke); + virtual MaterialStyleType type() const override; + virtual std::vector encoded() const override; + virtual bool operator==(const MaterialStyle&) const override; + float getWidth() const; + protected: + float width; + StrokeType strokeType; + StrokeEndType endType; + std::shared_ptr materialStroke; + }; +} diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/Painting.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/Painting.cpp index 6fd5edc..5539faf 100644 --- a/ArchitectureColoredPainting/src/Renderer/Painting/Painting.cpp +++ b/ArchitectureColoredPainting/src/Renderer/Painting/Painting.cpp @@ -2,6 +2,7 @@ #include "../../SvgParser.h" #include "ShortCutTree.h" #include "LineTree.h" +#include "MaterialStyleStroke.h" #include using namespace Renderer; @@ -18,46 +19,80 @@ void Renderer::Painting::addElement(ElementWithTransform elementWithTransform) if (it == elementPool.end()) { auto element = elementWithTransform.element; - auto iter = contourPool.insert({ element->contour, {nullptr, nullptr} }).first; + auto iter = contourPool.insert({ element.contour, {nullptr, nullptr} }).first; - if (!element->style->isLine() && iter->second.first == nullptr) + switch (element.style->type()) { - qDebug() << "Build ShortCutTree---------------------------------------------------------------------------------------------------"; - ShortCutTree shortCutTree(maxLineCount); - shortCutTree.buildShortCutTree(*element->contour); - ContourBuffer elementBuffer; - std::vector bvhLeaves = shortCutTree.getPointLineAndBvhTree(elementBuffer.pointBuffer, elementBuffer.lineBuffer); - BvhTree bvhTree; - bvhTree.buildBvhTree(bvhLeaves.data(), bvhLeaves.size()); - bvhTree.getBvhArray(elementBuffer.bvhChildren, elementBuffer.bvhBounds); - iter->second.first = std::make_shared(elementBuffer); - qDebug() << "---------------------------------------------------------------------------------------------------------------------"; + case MaterialStyleType::kFill: + if (iter->second.first == nullptr) + { + qDebug() << "Build ShortCutTree---------------------------------------------------------------------------------------------------"; + ShortCutTree shortCutTree(maxLineCount); + shortCutTree.buildShortCutTree(*element.contour); + ContourBuffer elementBuffer; + std::vector bvhLeaves = shortCutTree.getPointLineAndBvhTree(elementBuffer.pointBuffer, elementBuffer.lineBuffer); + BvhTree bvhTree; + bvhTree.buildBvhTree(bvhLeaves.data(), bvhLeaves.size()); + bvhTree.getBvhArray(elementBuffer.bvhChildren, elementBuffer.bvhBounds); + iter->second.first = std::make_shared(elementBuffer); + qDebug() << "---------------------------------------------------------------------------------------------------------------------"; + } + break; + case MaterialStyleType::kStroke: + if (iter->second.second == nullptr) + { + qDebug() << "Build LineTree-------------------------------------------------------------------------------------------------------"; + LineTree lineTree(maxLineCount); + lineTree.buildLineTree(*element.contour, std::static_pointer_cast(element.style)->getWidth()); + ContourBuffer elementBuffer; + std::vector bvhLeaves = lineTree.getPointLineAndBvhTree(elementBuffer.pointBuffer, elementBuffer.lineBuffer); + BvhTree bvhTree; + bvhTree.buildBvhTree(bvhLeaves.data(), bvhLeaves.size()); + bvhTree.getBvhArray(elementBuffer.bvhChildren, elementBuffer.bvhBounds); + iter->second.second = std::make_shared(elementBuffer); + qDebug() << "---------------------------------------------------------------------------------------------------------------------"; + } + break; } - else if (element->style->isLine() && iter->second.second == nullptr) - { - qDebug() << "Build LineTree-------------------------------------------------------------------------------------------------------"; - LineTree lineTree(maxLineCount); - lineTree.buildLineTree(*element->contour, element->style->encoded()[1]); - ContourBuffer elementBuffer; - std::vector bvhLeaves = lineTree.getPointLineAndBvhTree(elementBuffer.pointBuffer, elementBuffer.lineBuffer); - BvhTree bvhTree; - bvhTree.buildBvhTree(bvhLeaves.data(), bvhLeaves.size()); - bvhTree.getBvhArray(elementBuffer.bvhChildren, elementBuffer.bvhBounds); - iter->second.second = std::make_shared(elementBuffer); - qDebug() << "---------------------------------------------------------------------------------------------------------------------"; - - - } - stylePool.insert({ element->style, 0 }); - elementPool.insert({ element, 0}); + stylePool.insert({ element.style, 0 }); + elementPool.insert({ element, 0 }); } elements.push_back(elementWithTransform); } +void Renderer::Painting::addElement(const Element& element, const ElementTransform& transform) +{ + auto contour = element.contour; + auto it = elementStyleMap.find(element.style); + if (it == elementStyleMap.end()) + { + std::vector baseStyles; + for (auto& style : element.style->toBaseStyles()) + { + auto [iter, _] = styleSet.insert(style.material); + baseStyles.push_back(BaseStyle{ style.transform, *iter }); + } + it = elementStyleMap.insert({ element.style, baseStyles }).first; + } + for (int i = 0; i < it->second.size(); i++) + { + auto& style = it->second[i]; + ElementTransform trans = transform; + trans.center += style.transform->translation; + trans.size *= style.transform->scale; + trans.rotation += style.transform->rotation; + trans.flip ^= style.transform->flip; + trans.zIndex = trans.zIndex * 10 + i; + addElement(ElementWithTransform{ BaseElement{element.contour, style.material}, BaseTransform(trans) }); + } +} + + + void Renderer::Painting::addElement(std::shared_ptr element, QVector4D bound, float rotation, int zIndex) { - addElement(ElementWithTransform{ element, bound, rotation, zIndex }); + } GLuint encodeZIndexRotation(GLuint zIndex, float rotation) @@ -65,11 +100,19 @@ GLuint encodeZIndexRotation(GLuint zIndex, float rotation) return GLuint(rotation / 360 * 0x10000 + zIndex * 0x10000); } +BvhTreeData Painting::encodeElementLeaf(ElementWithTransform e) +{ + QVector4D bound(e.transform.bound.x, e.transform.bound.y, e.transform.bound.z, e.transform.bound.w); + GLuint rightSon = GLuint(glm::mod(e.transform.rotation, 360.f) * (1 << 16)) + + (e.transform.flip.x << 16) + (e.transform.flip.y << 17) + (e.transform.zIndex << 18); + return BvhTreeData(bound, elementPool[e.element], rightSon); +} + void Painting::generateBuffers() { - qDebug() << elementPool.size(); - qDebug() << contourPool.size(); - qDebug() << stylePool.size(); + qDebug() << "Element Count: " << elementPool.size(); + qDebug() << "Coutour Count: " << contourPool.size(); + qDebug() << " Style Count: " << stylePool.size(); bvhChildren.clear(); @@ -85,10 +128,10 @@ void Painting::generateBuffers() } std::vector rootBvhTreeData; - for (auto& i:elements) + for (auto& i : elements) { - rootBvhTreeData.push_back(BvhTreeData(i.bound, elementPool[i.element], encodeZIndexRotation(i.zIndex, i.rotation))); - //rootBvhTreeData.push_back(BvhTreeData(i.bound, 1, encodeZIndexRotation(i.zIndex, i.rotation))); + rootBvhTreeData.push_back(encodeElementLeaf(i)); + //rootBvhTreeData.back().show(); } BvhTree rootBvhTree; rootBvhTree.buildBvhTree(rootBvhTreeData.data(), rootBvhTreeData.size()); @@ -117,8 +160,8 @@ void Painting::generateBuffers() for (auto& i : elementPool) { //qDebug() <<"element:" << i.second; - std::shared_ptr contourBuffer = i.first->style->isLine() ? contourPool[i.first->contour].second : contourPool[i.first->contour].first; - elementOffset.push_back({ contourBuffer->bvhOffset, stylePool[i.first->style], contourBuffer->pointsOffset, contourBuffer->linesOffset }); + std::shared_ptr contourBuffer = i.first.style->type()==MaterialStyleType::kStroke ? contourPool[i.first.contour].second : contourPool[i.first.contour].first; + elementOffset.push_back({ contourBuffer->bvhOffset, stylePool[i.first.style], contourBuffer->pointsOffset, contourBuffer->linesOffset }); //std::cout << std::format("{} {} {} {}\n", contourBuffer->bvhOffset, stylePool[i.first->style], contourBuffer->pointsOffset, contourBuffer->linesOffset); } } @@ -139,3 +182,16 @@ void Renderer::Painting::insertContourBuffer(std::shared_ptr buff bvhChildren.insert(bvhChildren.end(), buffer->bvhChildren.begin(), buffer->bvhChildren.end()); bvhBounds.insert(bvhBounds.end(), buffer->bvhBounds.begin(), buffer->bvhBounds.end()); } + +bool Renderer::BaseElement::operator<(const BaseElement& e) const +{ + return contour == e.contour ? style < e.style : contour < e.contour; +} + +Renderer::BaseTransform::BaseTransform(ElementTransform t) + : bound(glm::vec4(t.center - t.size / 2.f, t.center + t.size / 2.f)) + , rotation(t.rotation) + , flip(t.flip) + , zIndex(t.zIndex) +{ +} diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/Painting.h b/ArchitectureColoredPainting/src/Renderer/Painting/Painting.h index e8ce576..496d879 100644 --- a/ArchitectureColoredPainting/src/Renderer/Painting/Painting.h +++ b/ArchitectureColoredPainting/src/Renderer/Painting/Painting.h @@ -1,28 +1,35 @@ #pragma once #include +#include #include +#include #include "Line.h" #include "BvhTree.h" #include "ElementStyle.h" -#include -//#include "Element.h" +#include "Element.h" namespace Renderer { - using Contour = std::vector>; - - struct Element + struct BaseElement { std::shared_ptr contour; - std::shared_ptr style; + std::shared_ptr style; + bool operator<(const BaseElement& e) const; + }; + + struct BaseTransform + { + glm::vec4 bound; + float rotation; + glm::bvec2 flip; + GLuint zIndex; + BaseTransform(ElementTransform t); }; struct ElementWithTransform { - std::shared_ptr element; - QVector4D bound; - float rotation; - int zIndex; + BaseElement element; + BaseTransform transform; }; struct ContourBuffer @@ -37,6 +44,18 @@ namespace Renderer GLuint bvhOffset; }; + struct CompareMaterialStyle + { + inline bool operator()(const std::shared_ptr& left, const std::shared_ptr& right) const + { + if (left == right || *left == *right) + return false; + else + return left < right; + } + }; + + class Painting { public: @@ -49,16 +68,19 @@ namespace Renderer Painting(); void addElement(ElementWithTransform element); + void addElement(const Element& element, const ElementTransform& transform); void addElement(std::shared_ptr element, QVector4D bound, float rotation, int zIndex); void generateBuffers(); GLuint getElementCount(); private: std::unordered_map, std::pair/*Ãæ*/, std::shared_ptr/*Ïß*/>> contourPool; - std::unordered_map, GLuint> stylePool; - std::map, GLuint> elementPool; + std::set, CompareMaterialStyle> styleSet; + std::unordered_map, std::vector> elementStyleMap; + std::unordered_map, GLuint> stylePool; + std::map elementPool; std::vector elements; void insertContourBuffer(std::shared_ptr buffer); - + BvhTreeData encodeElementLeaf(ElementWithTransform e); }; } diff --git a/FramelessHelper/qmake/.qmake.stash b/FramelessHelper/qmake/FramelessHelperCore/.qmake.stash similarity index 62% rename from FramelessHelper/qmake/.qmake.stash rename to FramelessHelper/qmake/FramelessHelperCore/.qmake.stash index 6978fc8..b04d932 100644 --- a/FramelessHelper/qmake/.qmake.stash +++ b/FramelessHelper/qmake/FramelessHelperCore/.qmake.stash @@ -1,23 +1,23 @@ QMAKE_CXX.QT_COMPILER_STDCXX = 199711L -QMAKE_CXX.QMAKE_MSC_VER = 1933 -QMAKE_CXX.QMAKE_MSC_FULL_VER = 193331630 +QMAKE_CXX.QMAKE_MSC_VER = 1934 +QMAKE_CXX.QMAKE_MSC_FULL_VER = 193431937 QMAKE_CXX.COMPILER_MACROS = \ QT_COMPILER_STDCXX \ QMAKE_MSC_VER \ QMAKE_MSC_FULL_VER QMAKE_CXX.INCDIRS = \ - "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.33.31629\\include" \ - "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.33.31629\\ATLMFC\\include" \ + "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\include" \ + "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\ATLMFC\\include" \ "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\VS\\include" \ - "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\ucrt" \ - "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.19041.0\\\\um" \ - "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.19041.0\\\\shared" \ - "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.19041.0\\\\winrt" \ - "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.19041.0\\\\cppwinrt" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.22000.0\\ucrt" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\um" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\shared" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\winrt" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\cppwinrt" \ "C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\include\\um" QMAKE_CXX.LIBDIRS = \ - "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.33.31629\\ATLMFC\\lib\\x64" \ - "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.33.31629\\lib\\x64" \ + "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\ATLMFC\\lib\\x64" \ + "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\lib\\x64" \ "C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\lib\\um\\x64" \ - "C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.19041.0\\ucrt\\x64" \ - "C:\\Program Files (x86)\\Windows Kits\\10\\\\lib\\10.0.19041.0\\\\um\\x64" + "C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.22000.0\\ucrt\\x64" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\\\lib\\10.0.22000.0\\\\um\\x64" diff --git a/FramelessHelper/qmake/FramelessHelperCore.pro b/FramelessHelper/qmake/FramelessHelperCore/FramelessHelperCore.pro similarity index 94% rename from FramelessHelper/qmake/FramelessHelperCore.pro rename to FramelessHelper/qmake/FramelessHelperCore/FramelessHelperCore.pro index c91662e..526567f 100644 --- a/FramelessHelper/qmake/FramelessHelperCore.pro +++ b/FramelessHelper/qmake/FramelessHelperCore/FramelessHelperCore.pro @@ -1,9 +1,9 @@ QT += core core-private gui gui-private -CORE_PUB_INC_DIR = $$PWD/../include/FramelessHelper/Core +CORE_PUB_INC_DIR = $$PWD/../../include/FramelessHelper/Core CORE_PRIV_INC_DIR = $$CORE_PUB_INC_DIR/private -CORE_EXTRA_INC_DIR = $$PWD/inc/core -CORE_SRC_DIR = $$PWD/../src/core +CORE_EXTRA_INC_DIR = $$PWD/../inc/core +CORE_SRC_DIR = $$PWD/../../src/core DEFINES += \ FRAMELESSHELPER_CORE_STATIC diff --git a/FramelessHelper/qmake/FramelessHelperCore.vcxproj b/FramelessHelper/qmake/FramelessHelperCore/FramelessHelperCore.vcxproj similarity index 78% rename from FramelessHelper/qmake/FramelessHelperCore.vcxproj rename to FramelessHelper/qmake/FramelessHelperCore/FramelessHelperCore.vcxproj index 699fe08..735f6a0 100644 --- a/FramelessHelper/qmake/FramelessHelperCore.vcxproj +++ b/FramelessHelper/qmake/FramelessHelperCore/FramelessHelperCore.vcxproj @@ -11,11 +11,11 @@ - {F1BC586E-F1ED-320C-899E-76CCB5660AE1} + {954D3D24-DF86-33A3-8867-D1735CCBDB10} FramelessHelperCore QtVS_v304 - 10.0.19041.0 - 10.0.19041.0 + 10.0.22000.0 + 10.0.22000.0 $(MSBuildProjectDirectory)\QtMsBuild @@ -78,7 +78,7 @@ - GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\include\FramelessHelper\Core;..\include\FramelessHelper\Core\private;inc\core;release;E:\VulkanSDK\1.3.216.0\include;%(AdditionalIncludeDirectories) + GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\..\include\FramelessHelper\Core;..\..\include\FramelessHelper\Core\private;..\inc\core;release;E:\VulkanSDK\1.3.216.0\include;%(AdditionalIncludeDirectories) -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) release\ false @@ -121,7 +121,7 @@ msvc - D:/??2022/ArchitectureColoredPainting/FramelessHelper/qmake/$(Configuration)/moc_predefs.h + ./$(Configuration)/moc_predefs.h Moc'ing %(Identity)... output $(Configuration) @@ -137,7 +137,7 @@ - GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\include\FramelessHelper\Core;..\include\FramelessHelper\Core\private;inc\core;debug;E:\VulkanSDK\1.3.216.0\include;%(AdditionalIncludeDirectories) + GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\..\include\FramelessHelper\Core;..\..\include\FramelessHelper\Core\private;..\inc\core;debug;E:\VulkanSDK\1.3.216.0\include;%(AdditionalIncludeDirectories) -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) debug\ false @@ -146,7 +146,7 @@ Sync debug\ Disabled - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;FRAMELESSHELPER_CORE_STATIC;QT_NO_CAST_TO_ASCII;QT_NO_CAST_FROM_ASCII;QT_NO_CAST_FROM_BYTEARRAY;QT_NO_URL_CAST_FROM_STRING;QT_NO_NARROWING_CONVERSIONS_IN_CONNECT;QT_NO_FOREACH;QT_USE_QSTRINGBUILDER;QT_USE_FAST_OPERATOR_PLUS;QT_DEPRECATED_WARNINGS;QT_DEPRECATED_WARNINGS_SINCE=0x070000;QT_WARN_DEPRECATED_UP_TO=0x070000;QT_DISABLE_DEPRECATED_BEFORE=0x070000;QT_DISABLE_DEPRECATED_UP_TO=0x070000;QT_NO_KEYWORDS;%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;FRAMELESSHELPER_CORE_STATIC;%(PreprocessorDefinitions) false MultiThreadedDebugDLL true @@ -184,7 +184,7 @@ msvc - D:/??2022/ArchitectureColoredPainting/FramelessHelper/qmake/$(Configuration)/moc_predefs.h + ./$(Configuration)/moc_predefs.h Moc'ing %(Identity)... output $(Configuration) @@ -192,53 +192,53 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - + - + - - + + - - - + + + - + - + - + - + - + - + - - + + - + - + @@ -259,10 +259,10 @@ - + - - + + diff --git a/FramelessHelper/qmake/FramelessHelperCore.vcxproj.filters b/FramelessHelper/qmake/FramelessHelperCore/FramelessHelperCore.vcxproj.filters similarity index 61% rename from FramelessHelper/qmake/FramelessHelperCore.vcxproj.filters rename to FramelessHelper/qmake/FramelessHelperCore/FramelessHelperCore.vcxproj.filters index 6a1d510..d972081 100644 --- a/FramelessHelper/qmake/FramelessHelperCore.vcxproj.filters +++ b/FramelessHelper/qmake/FramelessHelperCore/FramelessHelperCore.vcxproj.filters @@ -37,102 +37,102 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files @@ -173,13 +173,13 @@ - + Resource Files - + Resource Files - + Resource Files diff --git a/FramelessHelper/qmake/FramelessHelperWidgets/.qmake.stash b/FramelessHelper/qmake/FramelessHelperWidgets/.qmake.stash new file mode 100644 index 0000000..b04d932 --- /dev/null +++ b/FramelessHelper/qmake/FramelessHelperWidgets/.qmake.stash @@ -0,0 +1,23 @@ +QMAKE_CXX.QT_COMPILER_STDCXX = 199711L +QMAKE_CXX.QMAKE_MSC_VER = 1934 +QMAKE_CXX.QMAKE_MSC_FULL_VER = 193431937 +QMAKE_CXX.COMPILER_MACROS = \ + QT_COMPILER_STDCXX \ + QMAKE_MSC_VER \ + QMAKE_MSC_FULL_VER +QMAKE_CXX.INCDIRS = \ + "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\include" \ + "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\ATLMFC\\include" \ + "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\VS\\include" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.22000.0\\ucrt" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\um" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\shared" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\winrt" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\cppwinrt" \ + "C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\include\\um" +QMAKE_CXX.LIBDIRS = \ + "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\ATLMFC\\lib\\x64" \ + "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\lib\\x64" \ + "C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\lib\\um\\x64" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.22000.0\\ucrt\\x64" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\\\lib\\10.0.22000.0\\\\um\\x64" diff --git a/FramelessHelper/qmake/FramelessHelperWidgets.pro b/FramelessHelper/qmake/FramelessHelperWidgets/FramelessHelperWidgets.pro similarity index 92% rename from FramelessHelper/qmake/FramelessHelperWidgets.pro rename to FramelessHelper/qmake/FramelessHelperWidgets/FramelessHelperWidgets.pro index 0f1e999..fe8d3c3 100644 --- a/FramelessHelper/qmake/FramelessHelperWidgets.pro +++ b/FramelessHelper/qmake/FramelessHelperWidgets/FramelessHelperWidgets.pro @@ -1,8 +1,8 @@ QT += widgets widgets-private -WIDGETS_PUB_INC_DIR = $$PWD/../include/FramelessHelper/Widgets +WIDGETS_PUB_INC_DIR = $$PWD/../../include/FramelessHelper/Widgets WIDGETS_PRIV_INC_DIR = $$WIDGETS_PUB_INC_DIR/private -WIDGETS_SRC_DIR = $$PWD/../src/widgets +WIDGETS_SRC_DIR = $$PWD/../../src/widgets DEFINES += \ FRAMELESSHELPER_WIDGETS_STATIC diff --git a/FramelessHelper/qmake/FramelessHelperWidgets.vcxproj b/FramelessHelper/qmake/FramelessHelperWidgets/FramelessHelperWidgets.vcxproj similarity index 81% rename from FramelessHelper/qmake/FramelessHelperWidgets.vcxproj rename to FramelessHelper/qmake/FramelessHelperWidgets/FramelessHelperWidgets.vcxproj index 1d7795e..411cfb0 100644 --- a/FramelessHelper/qmake/FramelessHelperWidgets.vcxproj +++ b/FramelessHelper/qmake/FramelessHelperWidgets/FramelessHelperWidgets.vcxproj @@ -11,11 +11,11 @@ - {61651EC8-A30E-3935-BD0C-A01AE3EE0AD9} + {E7A71E05-4AA5-31DB-A17D-542FC7BD83A3} FramelessHelperWidgets QtVS_v304 - 10.0.19041.0 - 10.0.19041.0 + 10.0.22000.0 + 10.0.22000.0 $(MSBuildProjectDirectory)\QtMsBuild @@ -78,7 +78,7 @@ - GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\include\FramelessHelper\Widgets;..\include\FramelessHelper\Widgets\private;release;E:\VulkanSDK\1.3.216.0\include;%(AdditionalIncludeDirectories) + GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\..\include\FramelessHelper\Widgets;..\..\include\FramelessHelper\Widgets\private;release;E:\VulkanSDK\1.3.216.0\include;%(AdditionalIncludeDirectories) -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) release\ false @@ -130,7 +130,7 @@ - ..\include\FramelessHelper\Widgets;..\include\FramelessHelper\Widgets\private;..\include\FramelessHelper\Core\..\..;..\include\FramelessHelper\Core;..\include\FramelessHelper\Core\private;inc\core;%(AdditionalIncludeDirectories) + GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\..\include\FramelessHelper\Widgets;..\..\include\FramelessHelper\Widgets\private;debug;..\..\include;..\inc\core;..\..\include\FramelessHelper\Core;%(AdditionalIncludeDirectories) -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) debug\ false @@ -139,7 +139,7 @@ Sync debug\ Disabled - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;FRAMELESSHELPER_WIDGETS_STATIC;QT_NO_CAST_TO_ASCII;QT_NO_CAST_FROM_ASCII;QT_NO_CAST_FROM_BYTEARRAY;QT_NO_URL_CAST_FROM_STRING;QT_NO_NARROWING_CONVERSIONS_IN_CONNECT;QT_NO_FOREACH;QT_USE_QSTRINGBUILDER;QT_USE_FAST_OPERATOR_PLUS;QT_DEPRECATED_WARNINGS;QT_DEPRECATED_WARNINGS_SINCE=0x070000;QT_WARN_DEPRECATED_UP_TO=0x070000;QT_DISABLE_DEPRECATED_BEFORE=0x070000;QT_DISABLE_DEPRECATED_UP_TO=0x070000;QT_NO_KEYWORDS;%(PreprocessorDefinitions) + _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;FRAMELESSHELPER_WIDGETS_STATIC;%(PreprocessorDefinitions) false MultiThreadedDebugDLL true @@ -178,42 +178,42 @@ - - - - - - - - + + + + + + + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + @@ -235,8 +235,8 @@ - - {f1bc586e-f1ed-320c-899e-76ccb5660ae1} + + {954d3d24-df86-33a3-8867-d1735ccbdb10} diff --git a/FramelessHelper/qmake/FramelessHelperWidgets.vcxproj.filters b/FramelessHelper/qmake/FramelessHelperWidgets/FramelessHelperWidgets.vcxproj.filters similarity index 61% rename from FramelessHelper/qmake/FramelessHelperWidgets.vcxproj.filters rename to FramelessHelper/qmake/FramelessHelperWidgets/FramelessHelperWidgets.vcxproj.filters index 428a464..58050a2 100644 --- a/FramelessHelper/qmake/FramelessHelperWidgets.vcxproj.filters +++ b/FramelessHelper/qmake/FramelessHelperWidgets/FramelessHelperWidgets.vcxproj.filters @@ -27,72 +27,72 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files diff --git a/FramelessHelper/qmake/core.vcxproj b/FramelessHelper/qmake/core.vcxproj deleted file mode 100644 index f8e45a9..0000000 --- a/FramelessHelper/qmake/core.vcxproj +++ /dev/null @@ -1,274 +0,0 @@ - - - - - Release - x64 - - - Debug - x64 - - - - {E5BE9C30-42FE-3F03-9A8E-F9C7795F516F} - - - QtVS_v304 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - FramelessHelperCore - - - - v142 - release\ - false - NotSet - Application - release\ - core - - - v143 - debug\ - false - NotSet - StaticLibrary - debug\ - core - - - - - - - - - - - - - - - - - - debug\ - debug\ - core - true - - - release\ - release\ - core - true - false - - - 5.15.2_msvc2019_64 - core;core-private;gui;gui-private - - - 5.15.2_msvc2019_64 - core;core-private;gui;gui-private - - - - - - - GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\include\FramelessHelper\Core;..\include\FramelessHelper\Core\private;inc\core;release;E:\VulkanSDK\1.3.216.0\include;%(AdditionalIncludeDirectories) - -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) - release\ - false - None - 4577;4467;%(DisableSpecificWarnings) - Sync - release\ - MaxSpeed - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;FRAMELESSHELPER_CORE_STATIC;NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions) - false - - - MultiThreadedDLL - true - true - Level3 - true - - - user32.lib;gdi32.lib;shell32.lib;shell32.lib;%(AdditionalDependencies) - C:\openssl\lib;C:\Utils\my_sql\mysql-5.7.25-winx64\lib;C:\Utils\postgresql\pgsql\lib;%(AdditionalLibraryDirectories) - "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions) - true - false - true - false - true - $(OutDir)\core.exe - true - Windows - true - - - Unsigned - None - 0 - - - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;FRAMELESSHELPER_CORE_STATIC;NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions) - - - msvc - D:/??2022/ArchitectureColoredPainting/FramelessHelper/qmake/$(Configuration)/moc_predefs.h - Moc'ing %(Identity)... - output - $(Configuration) - moc_%(Filename).cpp - - - default - framelesshelpercore - Rcc'ing %(Identity)... - $(Configuration) - qrc_%(Filename).cpp - - - - - GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;..\include\FramelessHelper\Core;..\include\FramelessHelper\Core\private;inc\core;debug;E:\VulkanSDK\1.3.216.0\include;%(AdditionalIncludeDirectories) - -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) - debug\ - false - ProgramDatabase - 4577;4467;%(DisableSpecificWarnings) - Sync - debug\ - Disabled - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;FRAMELESSHELPER_CORE_STATIC;%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - true - Level3 - true - stdcpp17 - - - user32.lib;gdi32.lib;shell32.lib;shell32.lib;%(AdditionalDependencies) - C:\openssl\lib;C:\Utils\my_sql\mysql-5.7.25-winx64\lib;C:\Utils\postgresql\pgsql\lib;%(AdditionalLibraryDirectories) - "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions) - true - true - true - $(OutDir)\core.exe - true - Windows - true - - - Unsigned - None - 0 - - - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;FRAMELESSHELPER_CORE_STATIC;_DEBUG;%(PreprocessorDefinitions) - - - framelesshelpercore - default - Rcc'ing %(Identity)... - $(Configuration) - qrc_%(Filename).cpp - - - msvc - D:/??2022/ArchitectureColoredPainting/FramelessHelper/qmake/$(Configuration)/moc_predefs.h - Moc'ing %(Identity)... - output - $(Configuration) - moc_%(Filename).cpp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Document - true - $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) - cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >debug\moc_predefs.h - Generate moc_predefs.h - debug\moc_predefs.h;%(Outputs) - - - Document - $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) - cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h - Generate moc_predefs.h - release\moc_predefs.h;%(Outputs) - true - - - - - - - - - - - - - - \ No newline at end of file diff --git a/FramelessHelper/qmake/core.vcxproj.filters b/FramelessHelper/qmake/core.vcxproj.filters deleted file mode 100644 index 6a1d510..0000000 --- a/FramelessHelper/qmake/core.vcxproj.filters +++ /dev/null @@ -1,186 +0,0 @@ - - - - - {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} - cpp;c;cxx;moc;h;def;odl;idl;res; - - - {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} - cpp;c;cxx;moc;h;def;odl;idl;res; - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} - qrc;* - false - - - {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} - qrc;* - false - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - - - - - - - - - - - - - - - - - - Generated Files - - - Generated Files - - - - - - - - - - - - - - - Resource Files - - - Resource Files - - - Resource Files - - - \ No newline at end of file From e6ff316d0e26e094fa22d94908ec2cf2a708e772 Mon Sep 17 00:00:00 2001 From: "yang.yongquan" <3395816735@qq.com> Date: Thu, 2 Feb 2023 17:04:34 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ArchitectureColoredPainting.vcxproj | 17 ++--- ...rchitectureColoredPainting.vcxproj.filters | 75 +++++++++---------- .../SvgHelper.cpp | 0 .../SvgHelper.h | 0 .../qquick/qquicksvgparser.cpp | 0 .../qquick/qquicksvgparser_p.h | 0 .../qquick/qtquickglobal.h | 0 .../qquick/qtquickglobal_p.h | 0 .../util/SvgFileLoader.cpp | 17 ++++- .../util/SvgFileLoader.h | 1 + 10 files changed, 57 insertions(+), 53 deletions(-) rename ArchitectureColoredPainting/src/Editor/{third-party modules => ThirdPartyLib}/SvgHelper.cpp (100%) rename ArchitectureColoredPainting/src/Editor/{third-party modules => ThirdPartyLib}/SvgHelper.h (100%) rename ArchitectureColoredPainting/src/Editor/{third-party modules => ThirdPartyLib}/qquick/qquicksvgparser.cpp (100%) rename ArchitectureColoredPainting/src/Editor/{third-party modules => ThirdPartyLib}/qquick/qquicksvgparser_p.h (100%) rename ArchitectureColoredPainting/src/Editor/{third-party modules => ThirdPartyLib}/qquick/qtquickglobal.h (100%) rename ArchitectureColoredPainting/src/Editor/{third-party modules => ThirdPartyLib}/qquick/qtquickglobal_p.h (100%) rename ArchitectureColoredPainting/src/Editor/{third-party modules => }/util/SvgFileLoader.cpp (92%) rename ArchitectureColoredPainting/src/Editor/{third-party modules => }/util/SvgFileLoader.h (90%) diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj index 79ab108..12bf848 100644 --- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj +++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj @@ -108,8 +108,9 @@ - - + + + @@ -135,7 +136,6 @@ - @@ -167,18 +167,17 @@ - - - - - - + + + + + diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters index 70e0c28..7c086ef 100644 --- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters +++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters @@ -41,23 +41,23 @@ {22909273-2b23-49fa-84ab-444cefb09656} + + {11f273e9-b41f-4982-b4ca-12851a03aaae} + - {e3c323ec-d150-4876-8618-5800c87a4941} + {727fd876-d2b0-4928-80a7-2da7cafe1519} - - {30b46cf2-d980-47be-94c4-d2ec1dcc54ed} + + {169687a8-6807-4571-802c-c4a95858db3a} - - {5028c879-8b07-4033-81ac-e538a873a837} + + {0567e730-5508-4380-8304-86ded8ea3b2f} - - {555d169f-4fa2-4501-b67c-695197b9e6ae} - - - {0b29331b-03b9-44fe-916f-28f5061b4147} + + {cfa316d0-97e0-49b0-9911-baebfea49236} - {d7c7ab61-0d05-4e67-9e89-852f3e56fa2f} + {96f98afe-4250-44cb-a505-682a1d5932c3} @@ -165,16 +165,6 @@ Source Files\Renderer\Painting - - Source Files\Editor\third-party modules\qquick - - - Source Files\Editor\util - - - Source Files\Editor\third-party modules - Source Files\Editor\third-party modules - Source Files @@ -184,6 +174,15 @@ Source Files\Renderer\Painting + + Source Files\Editor\ThirdPartyLib\qquick + + + Source Files\Editor\ThirdPartyLib + + + Source Files\Editor\util + @@ -352,31 +351,27 @@ Header Files\Renderer\Painting - - Header Files\Editor\third-party modules - - - Header Files\Editor\third-party modules\qquick - - - Header Files\Editor\third-party modules\qquick - - - Header Files\Editor\third-party modules\qquick - - - Header Files\Editor\util - - - Header Files\Editor - Header Files\Editor\third-party modules\qquick - Header Files\Editor\util Header Files\Renderer\Painting + + Header Files\Editor\ThirdPartyLib\qquick + + + Header Files\Editor\ThirdPartyLib\qquick + + + Header Files\Editor\ThirdPartyLib\qquick + + + Header Files\Editor\ThirdPartyLib + + + Header Files\Editor\util + diff --git a/ArchitectureColoredPainting/src/Editor/third-party modules/SvgHelper.cpp b/ArchitectureColoredPainting/src/Editor/ThirdPartyLib/SvgHelper.cpp similarity index 100% rename from ArchitectureColoredPainting/src/Editor/third-party modules/SvgHelper.cpp rename to ArchitectureColoredPainting/src/Editor/ThirdPartyLib/SvgHelper.cpp diff --git a/ArchitectureColoredPainting/src/Editor/third-party modules/SvgHelper.h b/ArchitectureColoredPainting/src/Editor/ThirdPartyLib/SvgHelper.h similarity index 100% rename from ArchitectureColoredPainting/src/Editor/third-party modules/SvgHelper.h rename to ArchitectureColoredPainting/src/Editor/ThirdPartyLib/SvgHelper.h diff --git a/ArchitectureColoredPainting/src/Editor/third-party modules/qquick/qquicksvgparser.cpp b/ArchitectureColoredPainting/src/Editor/ThirdPartyLib/qquick/qquicksvgparser.cpp similarity index 100% rename from ArchitectureColoredPainting/src/Editor/third-party modules/qquick/qquicksvgparser.cpp rename to ArchitectureColoredPainting/src/Editor/ThirdPartyLib/qquick/qquicksvgparser.cpp diff --git a/ArchitectureColoredPainting/src/Editor/third-party modules/qquick/qquicksvgparser_p.h b/ArchitectureColoredPainting/src/Editor/ThirdPartyLib/qquick/qquicksvgparser_p.h similarity index 100% rename from ArchitectureColoredPainting/src/Editor/third-party modules/qquick/qquicksvgparser_p.h rename to ArchitectureColoredPainting/src/Editor/ThirdPartyLib/qquick/qquicksvgparser_p.h diff --git a/ArchitectureColoredPainting/src/Editor/third-party modules/qquick/qtquickglobal.h b/ArchitectureColoredPainting/src/Editor/ThirdPartyLib/qquick/qtquickglobal.h similarity index 100% rename from ArchitectureColoredPainting/src/Editor/third-party modules/qquick/qtquickglobal.h rename to ArchitectureColoredPainting/src/Editor/ThirdPartyLib/qquick/qtquickglobal.h diff --git a/ArchitectureColoredPainting/src/Editor/third-party modules/qquick/qtquickglobal_p.h b/ArchitectureColoredPainting/src/Editor/ThirdPartyLib/qquick/qtquickglobal_p.h similarity index 100% rename from ArchitectureColoredPainting/src/Editor/third-party modules/qquick/qtquickglobal_p.h rename to ArchitectureColoredPainting/src/Editor/ThirdPartyLib/qquick/qtquickglobal_p.h diff --git a/ArchitectureColoredPainting/src/Editor/third-party modules/util/SvgFileLoader.cpp b/ArchitectureColoredPainting/src/Editor/util/SvgFileLoader.cpp similarity index 92% rename from ArchitectureColoredPainting/src/Editor/third-party modules/util/SvgFileLoader.cpp rename to ArchitectureColoredPainting/src/Editor/util/SvgFileLoader.cpp index 6ccf71f..da7dbe4 100644 --- a/ArchitectureColoredPainting/src/Editor/third-party modules/util/SvgFileLoader.cpp +++ b/ArchitectureColoredPainting/src/Editor/util/SvgFileLoader.cpp @@ -1,6 +1,6 @@ #include "SvgFileLoader.h" #include -#include "../qquick/qquicksvgparser_p.h" +#include "../ThirdPartyLib/qquick/qquicksvgparser_p.h" #include @@ -151,7 +151,7 @@ void SvgFileLoader::handleLabelCircle(QPainterPath& painterPath) { } } qDebug() << labelStyle; - painterPath.addEllipse(cx, cy, r, r); + addEllipse(cx, cy, r, r, painterPath); } void SvgFileLoader::handleLabelEllipse(QPainterPath& painterPath) { @@ -174,7 +174,7 @@ void SvgFileLoader::handleLabelEllipse(QPainterPath& painterPath) { } } qDebug() << labelStyle; - painterPath.addEllipse(cx, cy, rx, ry); + addEllipse(cx, cy, rx, ry, painterPath); } void SvgFileLoader::handleLabelPolyline(QPainterPath& painterPath) { @@ -199,8 +199,9 @@ void SvgFileLoader::handleLabelPolygon(QPainterPath & painterPath) { for (auto& attr : xmlReader->attributes()) { if (attr.name().toString() == QLatin1String("points")) { QPolygonF points = transformPoints(attr.value().toLatin1()); - points.push_back(*points.begin()); + //points.push_back(*points.begin()); painterPath.addPolygon(points); + painterPath.closeSubpath(); } else if (attr.name().toString() == QLatin1String("style")) { labelStyle = transformStyle(attr.value().toLatin1()); @@ -210,4 +211,12 @@ void SvgFileLoader::handleLabelPolygon(QPainterPath & painterPath) { } } qDebug() << labelStyle; +} + +void SvgFileLoader::addEllipse(double x, double y, double w, double h, QPainterPath& painterPath) { + double k = w / 0.75; + painterPath.moveTo(x, y - h); + painterPath.cubicTo(QPointF(x + k, y - h), QPointF(x + k, y + h), QPointF(x, y + h)); + painterPath.cubicTo(QPointF(x - k, y + h), QPointF(x - k, y - h), QPointF(x, y - h)); + painterPath.closeSubpath(); } \ No newline at end of file diff --git a/ArchitectureColoredPainting/src/Editor/third-party modules/util/SvgFileLoader.h b/ArchitectureColoredPainting/src/Editor/util/SvgFileLoader.h similarity index 90% rename from ArchitectureColoredPainting/src/Editor/third-party modules/util/SvgFileLoader.h rename to ArchitectureColoredPainting/src/Editor/util/SvgFileLoader.h index 7420c7c..93c2751 100644 --- a/ArchitectureColoredPainting/src/Editor/third-party modules/util/SvgFileLoader.h +++ b/ArchitectureColoredPainting/src/Editor/util/SvgFileLoader.h @@ -15,6 +15,7 @@ private: std::shared_ptr xmlReader; QPolygonF transformPoints(QString points); QMap transformStyle(QString style); + void addEllipse(double cx, double cy, double h, double w, QPainterPath& painterPath); void handleLabelG(QPainterPath& painterPath); void handleLabelPath(QPainterPath& painterPath); void handleLabelRect(QPainterPath& painterPath); From 2af24647458868e90f37d7a4ad5e0e8b524f2834 Mon Sep 17 00:00:00 2001 From: "yang.yongquan" <3395816735@qq.com> Date: Sat, 4 Feb 2023 20:20:40 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86QPainterPath?= =?UTF-8?q?=E8=BD=AC=E4=B8=BAvector<>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ArchitectureColoredPainting.vcxproj | 2 + ...rchitectureColoredPainting.vcxproj.filters | 12 +++--- .../src/Editor/GraphicElement.cpp | 2 +- .../src/Editor/util/PainterPathUtil.cpp | 41 +++++++++++++++++++ .../src/Editor/util/PainterPathUtil.h | 13 ++++++ .../src/Editor/util/SvgFileLoader.cpp | 6 ++- .../src/Editor/util/SvgFileLoader.h | 1 + .../src/Renderer/Painting/Line.h | 5 +++ 8 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.cpp create mode 100644 ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.h diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj index 5f5e54c..6fa88c1 100644 --- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj +++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj @@ -110,6 +110,7 @@ + @@ -180,6 +181,7 @@ + diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters index d6f4019..b747240 100644 --- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters +++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters @@ -192,6 +192,9 @@ Source Files\Editor\util + + Source Files\Editor\util + @@ -360,9 +363,6 @@ Header Files\Renderer\Painting - - Header Files\Editor\util - Header Files\Renderer\Painting @@ -387,12 +387,12 @@ Header Files\Renderer\Painting - - Header Files\Renderer\Painting - Header Files\Renderer\Painting + + Header Files\Editor\util + diff --git a/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp b/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp index 47f4ee1..87711c1 100644 --- a/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp +++ b/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp @@ -1,5 +1,5 @@ #include "GraphicElement.h" -#include "third-party modules/util/SvgFileLoader.h" +#include using namespace std; QPainterPath SimpleElement::getPaintObject() const { diff --git a/ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.cpp b/ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.cpp new file mode 100644 index 0000000..148906e --- /dev/null +++ b/ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.cpp @@ -0,0 +1,41 @@ +#include "PainterPathUtil.h" +#include + +using Renderer::Point; +using std::vector; + +vector > PainterPathUtil::transformToLines(QPainterPath& painterPath) { + vector line; line.clear(); + vector > lines; lines.clear(); + QPointF startPoint(0, 0); + Point point(0, 0); + for (int elementIndex = 0; elementIndex < painterPath.elementCount(); elementIndex++) { + auto element = painterPath.elementAt(elementIndex); + point = element; + qDebug() << element; + if (element.isMoveTo()) { + if (line.size() >= 2) { + lines.push_back(line); + } + line.clear(); + line.push_back(point); + } + else { + line.push_back(point); + if (element.isLineTo()) { + lines.push_back(line); + } + if (element.isCurveTo()) { + point = painterPath.elementAt(++elementIndex); + line.push_back(point); + point = painterPath.elementAt(++elementIndex); + line.push_back(point); + lines.push_back(line); + } + line.clear(); + line.push_back(point); + } + } + line.clear(); + return lines; +} diff --git a/ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.h b/ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.h new file mode 100644 index 0000000..3e1fd13 --- /dev/null +++ b/ArchitectureColoredPainting/src/Editor/util/PainterPathUtil.h @@ -0,0 +1,13 @@ +#pragma once +#include +#include +#include "../Renderer/Painting/Line.h" + +using Renderer::Point; + +class PainterPathUtil +{ +public: + static std::vector > transformToLines(QPainterPath& painterPath); +}; + diff --git a/ArchitectureColoredPainting/src/Editor/util/SvgFileLoader.cpp b/ArchitectureColoredPainting/src/Editor/util/SvgFileLoader.cpp index da7dbe4..30f0ae6 100644 --- a/ArchitectureColoredPainting/src/Editor/util/SvgFileLoader.cpp +++ b/ArchitectureColoredPainting/src/Editor/util/SvgFileLoader.cpp @@ -151,7 +151,8 @@ void SvgFileLoader::handleLabelCircle(QPainterPath& painterPath) { } } qDebug() << labelStyle; - addEllipse(cx, cy, r, r, painterPath); + //addEllipse(cx, cy, r, r, painterPath); + painterPath.addEllipse(cx, cy, r, r); } void SvgFileLoader::handleLabelEllipse(QPainterPath& painterPath) { @@ -174,7 +175,8 @@ void SvgFileLoader::handleLabelEllipse(QPainterPath& painterPath) { } } qDebug() << labelStyle; - addEllipse(cx, cy, rx, ry, painterPath); + //addEllipse(cx, cy, rx, ry, painterPath); + painterPath.addEllipse(cx, cy, rx, ry); } void SvgFileLoader::handleLabelPolyline(QPainterPath& painterPath) { diff --git a/ArchitectureColoredPainting/src/Editor/util/SvgFileLoader.h b/ArchitectureColoredPainting/src/Editor/util/SvgFileLoader.h index 93c2751..352b9b0 100644 --- a/ArchitectureColoredPainting/src/Editor/util/SvgFileLoader.h +++ b/ArchitectureColoredPainting/src/Editor/util/SvgFileLoader.h @@ -23,4 +23,5 @@ private: void handleLabelEllipse(QPainterPath& painterPath); void handleLabelPolyline(QPainterPath& painterPath); void handleLabelPolygon(QPainterPath& painterPath); + }; diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/Line.h b/ArchitectureColoredPainting/src/Renderer/Painting/Line.h index 7730fa6..b1caf2b 100644 --- a/ArchitectureColoredPainting/src/Renderer/Painting/Line.h +++ b/ArchitectureColoredPainting/src/Renderer/Painting/Line.h @@ -25,6 +25,11 @@ namespace Renderer bool operator< (const Point& a) const { return fabs(x - a.x) <= eps ? y < a.y : x < a.x; } + Point& operator= (const QPointF p){ + x = p.x(); + y = p.y(); + return *this; + } operator glm::dvec2() { return glm::dvec2(x, y); } From 994c711e34466cf10bbbedfcfa9e1974565ec488 Mon Sep 17 00:00:00 2001 From: wuyize Date: Mon, 6 Feb 2023 18:09:48 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E5=9B=BE=E5=85=83=E7=BB=98=E5=88=B6=E5=88=B0QImage=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ArchitectureColoredPainting.vcxproj | 7 +- ...rchitectureColoredPainting.vcxproj.filters | 21 +- ArchitectureColoredPainting/MainWindow.qrc | 1 + .../Shaders/element.comp | 1053 +++++++++++++++++ .../src/Editor/GraphicElement.cpp | 2 +- .../src/Renderer/Painting/Element.cpp | 15 + .../src/Renderer/Painting/Element.h | 3 + .../src/Renderer/Painting/Painting.cpp | 5 +- .../src/Renderer/Preview/ElementRenderer.cpp | 160 +++ .../src/Renderer/Preview/ElementRenderer.h | 35 + 10 files changed, 1290 insertions(+), 12 deletions(-) create mode 100644 ArchitectureColoredPainting/Shaders/element.comp create mode 100644 ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp create mode 100644 ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.h diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj index 5f5e54c..b85acdd 100644 --- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj +++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj @@ -133,6 +133,7 @@ + @@ -152,6 +153,7 @@ + @@ -159,7 +161,9 @@ - + + Document + @@ -188,6 +192,7 @@ + diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters index d6f4019..68a6fe6 100644 --- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters +++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters @@ -59,6 +59,12 @@ {96f98afe-4250-44cb-a505-682a1d5932c3} + + {2a8e109f-7791-46ad-8c86-fe22a651cbe7} + + + {7ead1a66-586a-4584-ae80-9e7a4e667364} + @@ -192,6 +198,9 @@ Source Files\Editor\util + + Source Files\Renderer\Preview + @@ -284,6 +293,9 @@ Resource Files + + Resource Files\Shaders + @@ -360,9 +372,6 @@ Header Files\Renderer\Painting - - Header Files\Editor\util - Header Files\Renderer\Painting @@ -387,12 +396,12 @@ Header Files\Renderer\Painting - - Header Files\Renderer\Painting - Header Files\Renderer\Painting + + Header Files\Renderer\Preview + diff --git a/ArchitectureColoredPainting/MainWindow.qrc b/ArchitectureColoredPainting/MainWindow.qrc index 8a9a1ea..a653907 100644 --- a/ArchitectureColoredPainting/MainWindow.qrc +++ b/ArchitectureColoredPainting/MainWindow.qrc @@ -23,6 +23,7 @@ images/icon_window_restore.png darkstyle.qss lightstyle.qss + Shaders/element.comp qt.conf diff --git a/ArchitectureColoredPainting/Shaders/element.comp b/ArchitectureColoredPainting/Shaders/element.comp new file mode 100644 index 0000000..7ccc0b6 --- /dev/null +++ b/ArchitectureColoredPainting/Shaders/element.comp @@ -0,0 +1,1053 @@ +#version 450 core + +layout(local_size_x = 8, local_size_y = 8) in; +layout(rgba8, binding = 0) uniform image2D gBaseColor; + +layout(std430, binding = 10) buffer pathBuffer +{ + vec2 path[]; +}; + +layout(std430, binding = 11) buffer styleBuffer +{ + float style[]; +}; + +uniform int pathSize; +uniform int styleSize; +uniform vec2 leftTop; +uniform float pixelRatio; + +/************************************************************************************/ + +// Modified from http://tog.acm.org/resources/GraphicsGems/gems/Roots3And4.c +// Credits to Doublefresh for hinting there +int solve_quadric(vec2 coeffs, inout vec2 roots) +{ + + // normal form: x^2 + px + q = 0 + float p = coeffs[1] / 2.; + float q = coeffs[0]; + + float D = p * p - q; + + if (D < 0.) + { + return 0; + } + else + { + roots[0] = -sqrt(D) - p; + roots[1] = sqrt(D) - p; + + return 2; + } +} + +// From Trisomie21 +// But instead of his cancellation fix i'm using a newton iteration +int solve_cubic(vec3 coeffs, inout vec3 r) +{ + + float a = coeffs[2]; + float b = coeffs[1]; + float c = coeffs[0]; + + float p = b - a * a / 3.0; + float q = a * (2.0 * a * a - 9.0 * b) / 27.0 + c; + float p3 = p * p * p; + float d = q * q + 4.0 * p3 / 27.0; + float offset = -a / 3.0; + if (d >= 0.0) + { // Single solution + float z = sqrt(d); + float u = (-q + z) / 2.0; + float v = (-q - z) / 2.0; + u = sign(u) * pow(abs(u), 1.0 / 3.0); + v = sign(v) * pow(abs(v), 1.0 / 3.0); + r[0] = offset + u + v; + + // Single newton iteration to account for cancellation + float f = ((r[0] + a) * r[0] + b) * r[0] + c; + float f1 = (3. * r[0] + 2. * a) * r[0] + b; + + r[0] -= f / f1; + + return 1; + } + float u = sqrt(-p / 3.0); + float v = acos(-sqrt(-27.0 / p3) * q / 2.0) / 3.0; + float m = cos(v), n = sin(v) * 1.732050808; + + // Single newton iteration to account for cancellation + //(once for every root) + r[0] = offset + u * (m + m); + r[1] = offset - u * (n + m); + r[2] = offset + u * (n - m); + + vec3 f = ((r + a) * r + b) * r + c; + vec3 f1 = (3. * r + 2. * a) * r + b; + + r -= f / f1; + + return 3; +} + +int segment_int_test(vec2 uv, vec2 p0, vec2 p1) +{ + p0 -= uv; + p1 -= uv; + + int ret; + + if (p0.y * p1.y < 0.) + { + vec2 nor = p0 - p1; + nor = vec2(nor.y, -nor.x); + + float sgn; + + if (p0.y > p1.y) + { + sgn = 1.; + } + else + { + sgn = -1.; + } + + if (dot(nor, p0) * sgn < 0.) + { + ret = 0; + } + else + { + ret = 1; + } + } + else + { + ret = 0; + } + + return ret; +} + +int cubic_bezier_int_test(vec2 uv, vec2 p0, vec2 p1, vec2 p2, vec2 p3) +{ + + float cu = (-p0.y + 3. * p1.y - 3. * p2.y + p3.y); + float qu = (3. * p0.y - 6. * p1.y + 3. * p2.y); + float li = (-3. * p0.y + 3. * p1.y); + float co = p0.y - uv.y; + + vec3 roots = vec3(1e38); + int n_roots; + + int n_ints = 0; + + if (uv.x < min(min(p0.x, p1.x), min(p2.x, p3.x))) + { + if (uv.y >= min(p0.y, p3.y) && uv.y <= max(p0.y, p3.y)) + { + n_ints = 1; + } + } + else + { + + if (abs(cu) < .0001) + { + n_roots = solve_quadric(vec2(co / qu, li / qu), roots.xy); + } + else + { + n_roots = solve_cubic(vec3(co / cu, li / cu, qu / cu), roots); + } + + for (int i = 0; i < n_roots; i++) + { + if (roots[i] >= 0. && roots[i] <= 1.) + { + float x_pos = -p0.x + 3. * p1.x - 3. * p2.x + p3.x; + x_pos = x_pos * roots[i] + 3. * p0.x - 6. * p1.x + 3. * p2.x; + x_pos = x_pos * roots[i] + -3. * p0.x + 3. * p1.x; + x_pos = x_pos * roots[i] + p0.x; + + if (x_pos > uv.x) + { + n_ints++; + } + } + } + } + + return n_ints; +} + +bvec3 segment_sign_test(vec2 uv, vec2 p0, vec2 p1) +{ + p0 -= uv; + p1 -= uv; + bvec3 ret; + vec2 nor = p0 - p1; + nor = vec2(nor.y, -nor.x); + + float sgn; + + if (p0.y > p1.y) + { + sgn = 1.; + } + else + { + sgn = -1.; + } + + if (dot(nor, p0) * sgn < 0.) + { + if (p0.y * p1.y < 0.) + ret.y = false; + else + ret.y = false; + ret.xz = bvec2(false); + } + else + { + if (p0.y * p1.y < 0.) + ret.y = true; + else + ret.y = false; + ret.xz = bvec2(true); + } + return ret; +} + +bvec3 cubic_bezier_sign_test(vec2 uv, vec2 p0, vec2 p1, vec2 p2, vec2 p3) +{ + // if(abs(p3.y-p0.y)< 1e-4) + // { + // return segment_sign_test(uv, p0,p3); + // } + + float cu = (-p0.y + 3. * p1.y - 3. * p2.y + p3.y); + float qu = (3. * p0.y - 6. * p1.y + 3. * p2.y); + float li = (-3. * p0.y + 3. * p1.y); + float co = p0.y - uv.y; + + vec3 roots = vec3(1e38); + int n_roots = solve_cubic(vec3(co / cu, li / cu, qu / cu), roots); + + // int n_ints = 0; + bvec3 result = bvec3(false); + for (int i = 0; i < 3; i++) + { + if (i < n_roots) + { + if (roots[i] >= 0. && roots[i] <= 1.) + { + float x_pos = -p0.x + 3. * p1.x - 3. * p2.x + p3.x; + x_pos = x_pos * roots[i] + 3. * p0.x - 6. * p1.x + 3. * p2.x; + x_pos = x_pos * roots[i] + -3. * p0.x + 3. * p1.x; + x_pos = x_pos * roots[i] + p0.x; + + if (x_pos > uv.x) + { + result[1] = !result[1]; + } + } + } + } + + vec2 tang1 = p0.xy - p1.xy; + vec2 tang2 = p2.xy - p3.xy; + + vec2 nor1 = vec2(tang1.y, -tang1.x); + vec2 nor2 = vec2(tang2.y, -tang2.x); + + if (p0.y < p1.y) + { + if ((uv.y <= p0.y) && (dot(uv - p0.xy, nor1) > 0.)) + { + result[0] = !result[0]; + } + } + else + { + if (!(uv.y <= p0.y) && !(dot(uv - p0.xy, nor1) > 0.)) + { + result[0] = !result[0]; + } + } + + if (p2.y < p3.y) + { + if (!(uv.y <= p3.y) && dot(uv - p3.xy, nor2) > 0.) + { + result[2] = !result[2]; + } + } + else + { + if ((uv.y <= p3.y) && !(dot(uv - p3.xy, nor2) > 0.)) + { + result[2] = !result[2]; + } + } + + return result; + // if(n_ints==0 || n_ints==2 || n_ints==4){ + // return 1; + // } + // else{ + // return 0; + // } +} + +const float eps = .000005; +const int halley_iterations = 8; +// lagrange positive real root upper bound +// see for example: https://doi.org/10.1016/j.jsc.2014.09.038 +float upper_bound_lagrange5(float a0, float a1, float a2, float a3, float a4) +{ + + vec4 coeffs1 = vec4(a0, a1, a2, a3); + + vec4 neg1 = max(-coeffs1, vec4(0)); + float neg2 = max(-a4, 0.); + + const vec4 indizes1 = vec4(0, 1, 2, 3); + const float indizes2 = 4.; + + vec4 bounds1 = pow(neg1, 1. / (5. - indizes1)); + float bounds2 = pow(neg2, 1. / (5. - indizes2)); + + vec2 min1_2 = min(bounds1.xz, bounds1.yw); + vec2 max1_2 = max(bounds1.xz, bounds1.yw); + + float maxmin = max(min1_2.x, min1_2.y); + float minmax = min(max1_2.x, max1_2.y); + + float max3 = max(max1_2.x, max1_2.y); + + float max_max = max(max3, bounds2); + float max_max2 = max(min(max3, bounds2), max(minmax, maxmin)); + + return max_max + max_max2; +} + +// lagrange upper bound applied to f(-x) to get lower bound +float lower_bound_lagrange5(float a0, float a1, float a2, float a3, float a4) +{ + + vec4 coeffs1 = vec4(-a0, a1, -a2, a3); + + vec4 neg1 = max(-coeffs1, vec4(0)); + float neg2 = max(-a4, 0.); + + const vec4 indizes1 = vec4(0, 1, 2, 3); + const float indizes2 = 4.; + + vec4 bounds1 = pow(neg1, 1. / (5. - indizes1)); + float bounds2 = pow(neg2, 1. / (5. - indizes2)); + + vec2 min1_2 = min(bounds1.xz, bounds1.yw); + vec2 max1_2 = max(bounds1.xz, bounds1.yw); + + float maxmin = max(min1_2.x, min1_2.y); + float minmax = min(max1_2.x, max1_2.y); + + float max3 = max(max1_2.x, max1_2.y); + + float max_max = max(max3, bounds2); + float max_max2 = max(min(max3, bounds2), max(minmax, maxmin)); + + return -max_max - max_max2; +} + +vec2 parametric_cub_bezier(float t, vec2 p0, vec2 p1, vec2 p2, vec2 p3) +{ + vec2 a0 = (-p0 + 3. * p1 - 3. * p2 + p3); + vec2 a1 = (3. * p0 - 6. * p1 + 3. * p2); + vec2 a2 = (-3. * p0 + 3. * p1); + vec2 a3 = p0; + + return (((a0 * t) + a1) * t + a2) * t + a3; +} + +void sort_roots3(inout vec3 roots) +{ + vec3 tmp; + + tmp[0] = min(roots[0], min(roots[1], roots[2])); + tmp[1] = max(roots[0], min(roots[1], roots[2])); + tmp[2] = max(roots[0], max(roots[1], roots[2])); + + roots = tmp; +} + +void sort_roots4(inout vec4 roots) +{ + vec4 tmp; + + vec2 min1_2 = min(roots.xz, roots.yw); + vec2 max1_2 = max(roots.xz, roots.yw); + + float maxmin = max(min1_2.x, min1_2.y); + float minmax = min(max1_2.x, max1_2.y); + + tmp[0] = min(min1_2.x, min1_2.y); + tmp[1] = min(maxmin, minmax); + tmp[2] = max(minmax, maxmin); + tmp[3] = max(max1_2.x, max1_2.y); + + roots = tmp; +} + +float eval_poly5(float a0, float a1, float a2, float a3, float a4, float x) +{ + + float f = ((((x + a4) * x + a3) * x + a2) * x + a1) * x + a0; + + return f; +} + +// halley's method +// basically a variant of newton raphson which converges quicker and has bigger basins of convergence +// see http://mathworld.wolfram.com/HalleysMethod.html +// or https://en.wikipedia.org/wiki/Halley%27s_method +float halley_iteration5(float a0, float a1, float a2, float a3, float a4, float x) +{ + + float f = ((((x + a4) * x + a3) * x + a2) * x + a1) * x + a0; + float f1 = (((5. * x + 4. * a4) * x + 3. * a3) * x + 2. * a2) * x + a1; + float f2 = ((20. * x + 12. * a4) * x + 6. * a3) * x + 2. * a2; + + return x - (2. * f * f1) / (2. * f1 * f1 - f * f2); +} + +float halley_iteration4(vec4 coeffs, float x) +{ + + float f = (((x + coeffs[3]) * x + coeffs[2]) * x + coeffs[1]) * x + coeffs[0]; + float f1 = ((4. * x + 3. * coeffs[3]) * x + 2. * coeffs[2]) * x + coeffs[1]; + float f2 = (12. * x + 6. * coeffs[3]) * x + 2. * coeffs[2]; + + return x - (2. * f * f1) / (2. * f1 * f1 - f * f2); +} + +// Modified from http://tog.acm.org/resources/GraphicsGems/gems/Roots3And4.c +// Credits to Doublefresh for hinting there +int solve_quartic(vec4 coeffs, inout vec4 s) +{ + + float a = coeffs[3]; + float b = coeffs[2]; + float c = coeffs[1]; + float d = coeffs[0]; + + /* substitute x = y - A/4 to eliminate cubic term: + x^4 + px^2 + qx + r = 0 */ + + float sq_a = a * a; + float p = -3. / 8. * sq_a + b; + float q = 1. / 8. * sq_a * a - 1. / 2. * a * b + c; + float r = -3. / 256. * sq_a * sq_a + 1. / 16. * sq_a * b - 1. / 4. * a * c + d; + + int num; + + /* doesn't seem to happen for me */ + // if(abs(r) -eps) + { + u = sqrt(abs(u)); + } + else + { + return 0; + } + + if (v > -eps) + { + v = sqrt(abs(v)); + } + else + { + return 0; + } + + vec2 quad_coeffs; + + quad_coeffs[0] = z - u; + quad_coeffs[1] = q < 0. ? -v : v; + + num = solve_quadric(quad_coeffs, s.xy); + + quad_coeffs[0] = z + u; + quad_coeffs[1] = q < 0. ? v : -v; + + vec2 tmp = vec2(1e38); + int old_num = num; + + num += solve_quadric(quad_coeffs, tmp); + if (old_num != num) + { + if (old_num == 0) + { + s[0] = tmp[0]; + s[1] = tmp[1]; + } + else + { // old_num == 2 + s[2] = tmp[0]; + s[3] = tmp[1]; + } + } + } + + /* resubstitute */ + + float sub = 1. / 4. * a; + + /* single halley iteration to fix cancellation */ + for (int i = 0; i < 4; i += 2) + { + if (i < num) + { + s[i] -= sub; + s[i] = halley_iteration4(coeffs, s[i]); + + s[i + 1] -= sub; + s[i + 1] = halley_iteration4(coeffs, s[i + 1]); + } + } + + return num; +} +float cubic_bezier_dis(vec2 uv, vec2 p0, vec2 p1, vec2 p2, vec2 p3, bool roundEnd) +{ + +// switch points when near to end point to minimize numerical error +// only needed when control point(s) very far away +#if 0 + vec2 mid_curve = parametric_cub_bezier(.5,p0,p1,p2,p3); + vec2 mid_points = (p0 + p3)/2.; + + vec2 tang = mid_curve-mid_points; + vec2 nor = vec2(tang.y,-tang.x); + + if(sign(dot(nor,uv-mid_curve)) != sign(dot(nor,p0-mid_curve))){ + vec2 tmp = p0; + p0 = p3; + p3 = tmp; + + tmp = p2; + p2 = p1; + p1 = tmp; + } +#endif + + vec2 a3 = (-p0 + 3. * p1 - 3. * p2 + p3); + vec2 a2 = (3. * p0 - 6. * p1 + 3. * p2); + vec2 a1 = (-3. * p0 + 3. * p1); + vec2 a0 = p0 - uv; + + // compute polynomial describing distance to current pixel dependent on a parameter t + float bc6 = dot(a3, a3); + float bc5 = 2. * dot(a3, a2); + float bc4 = dot(a2, a2) + 2. * dot(a1, a3); + float bc3 = 2. * (dot(a1, a2) + dot(a0, a3)); + float bc2 = dot(a1, a1) + 2. * dot(a0, a2); + float bc1 = 2. * dot(a0, a1); + float bc0 = dot(a0, a0); + + bc5 /= bc6; + bc4 /= bc6; + bc3 /= bc6; + bc2 /= bc6; + bc1 /= bc6; + bc0 /= bc6; + + // compute derivatives of this polynomial + + float b0 = bc1 / 6.; + float b1 = 2. * bc2 / 6.; + float b2 = 3. * bc3 / 6.; + float b3 = 4. * bc4 / 6.; + float b4 = 5. * bc5 / 6.; + + vec4 c1 = vec4(b1, 2. * b2, 3. * b3, 4. * b4) / 5.; + vec3 c2 = vec3(c1[1], 2. * c1[2], 3. * c1[3]) / 4.; + vec2 c3 = vec2(c2[1], 2. * c2[2]) / 3.; + float c4 = c3[1] / 2.; + + vec4 roots_drv = vec4(1e38); + + int num_roots_drv = solve_quartic(c1, roots_drv); + sort_roots4(roots_drv); + + float ub = upper_bound_lagrange5(b0, b1, b2, b3, b4); + float lb = lower_bound_lagrange5(b0, b1, b2, b3, b4); + + vec3 a = vec3(1e38); + vec3 b = vec3(1e38); + + vec3 roots = vec3(1e38); + + int num_roots = 0; + + // compute root isolating intervals by roots of derivative and outer root bounds + // only roots going form - to + considered, because only those result in a minimum + if (num_roots_drv == 4) + { + if (eval_poly5(b0, b1, b2, b3, b4, roots_drv[0]) > 0.) + { + a[0] = lb; + b[0] = roots_drv[0]; + num_roots = 1; + } + + if (sign(eval_poly5(b0, b1, b2, b3, b4, roots_drv[1])) != sign(eval_poly5(b0, b1, b2, b3, b4, roots_drv[2]))) + { + if (num_roots == 0) + { + a[0] = roots_drv[1]; + b[0] = roots_drv[2]; + num_roots = 1; + } + else + { + a[1] = roots_drv[1]; + b[1] = roots_drv[2]; + num_roots = 2; + } + } + + if (eval_poly5(b0, b1, b2, b3, b4, roots_drv[3]) < 0.) + { + if (num_roots == 0) + { + a[0] = roots_drv[3]; + b[0] = ub; + num_roots = 1; + } + else if (num_roots == 1) + { + a[1] = roots_drv[3]; + b[1] = ub; + num_roots = 2; + } + else + { + a[2] = roots_drv[3]; + b[2] = ub; + num_roots = 3; + } + } + } + else + { + if (num_roots_drv == 2) + { + if (eval_poly5(b0, b1, b2, b3, b4, roots_drv[0]) < 0.) + { + num_roots = 1; + a[0] = roots_drv[1]; + b[0] = ub; + } + else if (eval_poly5(b0, b1, b2, b3, b4, roots_drv[1]) > 0.) + { + num_roots = 1; + a[0] = lb; + b[0] = roots_drv[0]; + } + else + { + num_roots = 2; + + a[0] = lb; + b[0] = roots_drv[0]; + + a[1] = roots_drv[1]; + b[1] = ub; + } + } + else + { // num_roots_drv==0 + vec3 roots_snd_drv = vec3(1e38); + int num_roots_snd_drv = solve_cubic(c2, roots_snd_drv); + + vec2 roots_trd_drv = vec2(1e38); + int num_roots_trd_drv = solve_quadric(c3, roots_trd_drv); + num_roots = 1; + + a[0] = lb; + b[0] = ub; + } + + // further subdivide intervals to guarantee convergence of halley's method + // by using roots of further derivatives + vec3 roots_snd_drv = vec3(1e38); + int num_roots_snd_drv = solve_cubic(c2, roots_snd_drv); + sort_roots3(roots_snd_drv); + + int num_roots_trd_drv = 0; + vec2 roots_trd_drv = vec2(1e38); + + if (num_roots_snd_drv != 3) + { + num_roots_trd_drv = solve_quadric(c3, roots_trd_drv); + } + + for (int i = 0; i < 3; i++) + { + if (i < num_roots) + { + for (int j = 0; j < 3; j += 2) + { + if (j < num_roots_snd_drv) + { + if (a[i] < roots_snd_drv[j] && b[i] > roots_snd_drv[j]) + { + if (eval_poly5(b0, b1, b2, b3, b4, roots_snd_drv[j]) > 0.) + { + b[i] = roots_snd_drv[j]; + } + else + { + a[i] = roots_snd_drv[j]; + } + } + } + } + for (int j = 0; j < 2; j++) + { + if (j < num_roots_trd_drv) + { + if (a[i] < roots_trd_drv[j] && b[i] > roots_trd_drv[j]) + { + if (eval_poly5(b0, b1, b2, b3, b4, roots_trd_drv[j]) > 0.) + { + b[i] = roots_trd_drv[j]; + } + else + { + a[i] = roots_trd_drv[j]; + } + } + } + } + } + } + } + + float d0 = 1e38; + + // compute roots with halley's method + + for (int i = 0; i < 3; i++) + { + if (i < num_roots) + { + roots[i] = .5 * (a[i] + b[i]); + + for (int j = 0; j < halley_iterations; j++) + { + roots[i] = halley_iteration5(b0, b1, b2, b3, b4, roots[i]); + } + + // compute squared distance to nearest point on curve + if (roundEnd) + { + roots[i] = clamp(roots[i], 0., 1.); + vec2 to_curve = uv - parametric_cub_bezier(roots[i], p0, p1, p2, p3); + d0 = min(d0, dot(to_curve, to_curve)); + } + else + { + if (roots[i] < 0. || roots[i] > 1.) + d0 = min(d0, 1e38); + else + { + vec2 to_curve = uv - parametric_cub_bezier(roots[i], p0, p1, p2, p3); + d0 = min(d0, dot(to_curve, to_curve)); + } + } + } + } + + return sqrt(d0); +} + +int cubic_bezier_int_test2(vec2 uv, vec2 p0, vec2 p1, vec2 p2, vec2 p3, bool reverse) +{ + float cu = (-p0.y + 3. * p1.y - 3. * p2.y + p3.y); + float qu = (3. * p0.y - 6. * p1.y + 3. * p2.y); + float li = (-3. * p0.y + 3. * p1.y); + float co = p0.y - uv.y; + + vec3 roots = vec3(1e38); + int n_roots; + + int n_ints = 0; + + if (reverse ? uv.x > max(max(p0.x, p1.x), max(p2.x, p3.x)) : uv.x < min(min(p0.x, p1.x), min(p2.x, p3.x))) + { + if (uv.y >= min(p0.y, p3.y) && uv.y <= max(p0.y, p3.y)) + n_ints = 1; + } + else + { + if (abs(cu) < .0001) + n_roots = solve_quadric(vec2(co / qu, li / qu), roots.xy); + else + n_roots = solve_cubic(vec3(co / cu, li / cu, qu / cu), roots); + + for (int i = 0; i < n_roots; i++) + { + if (roots[i] >= 0. && roots[i] <= 1.) + { + float x_pos = -p0.x + 3. * p1.x - 3. * p2.x + p3.x; + x_pos = x_pos * roots[i] + 3. * p0.x - 6. * p1.x + 3. * p2.x; + x_pos = x_pos * roots[i] + -3. * p0.x + 3. * p1.x; + x_pos = x_pos * roots[i] + p0.x; + + if (reverse ? x_pos < uv.x : x_pos > uv.x) + n_ints++; + } + } + } + return n_ints; +} + +int ray_int_test(vec2 uv, vec2 p0, vec2 direction, bool reverse) +{ + p0 -= uv; + if (-p0.y * direction.y > 0.) + { + vec2 nor = -direction; + nor = vec2(nor.y, -nor.x); + float sgn = p0.y > direction.y ? 1. : -1.; + if (reverse) + sgn = -sgn; + return dot(nor, p0) * sgn < 0. ? 0 : 1; + } + else + return 0; +} + +vec2 bezierTangent(float t, vec2 p0, vec2 p1, vec2 p2, vec2 p3) +{ + float u = 1 - t; + float uu = u * u; + float tu = t * u; + float tt = t * t; + + vec2 P = p0 * 3 * uu * (-1.0); + P += p1 * 3 * (uu - 2 * tu); + P += p2 * 3 * (2 * tu - tt); + P += p3 * 3 * tt; + + // ·µ»Øµ¥Î»ÏòÁ¿ + return normalize(P); +} + +// ÅжÏÁ½ÏòÁ¿¼Ð½Ç(ÏòÁ¿AÄæʱÕëµ½ÏòÁ¿B)ÊÇ·ñ´óÓÚ180¡ã£¬´óÓÚ180¡ã·µ»ØÕ棬·ñÔò·µ»Ø¼Ù +bool angleLargeThanPi(vec2 a, vec2 b) +{ + return a.x * b.y - b.x * a.y < 0; +} + +/************************************************************************************/ + +void drawLine(in float d, in uint styleIndex, out vec4 elementColor, out vec2 metallicRoughness) +{ + elementColor = vec4(1); + metallicRoughness = vec2(0.8); + // switch(int(elementData[styleIndex+3])) + switch (0) + { + case 0: { + elementColor = vec4(unpackUnorm4x8(floatBitsToUint(style[styleIndex + 2])).rgb, 1); + metallicRoughness = vec2(unpackUnorm4x8(floatBitsToUint(style[styleIndex + 1])).rg); + break; + } + case 1: { + elementColor = vec4(mix(vec3(0), vec3(1), d), 1); + metallicRoughness = vec2(0, 0.8); + break; + } + case 2: { + float levels[] = {0.25, 0.5, 0.75}; + vec3 colors[] = {vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1), vec3(1, 1, 0)}; + int i = 0; + while (i < 3) + { + if (d < levels[i]) + { + elementColor = vec4(colors[i], 1); + metallicRoughness = vec2(0, 0.8); + break; + } + i++; + } + if (i == 3) + { + elementColor = vec4(colors[i], 1); + metallicRoughness = vec2(0, 0.8); + } + break; + } + } +} + +void main() +{ + uvec2 pixelLocation = gl_GlobalInvocationID.xy; + // imageStore(gBaseColor, ivec2(pixelLocation), vec4(vec2(pixelLocation)/vec2(imageSize(gBaseColor)), 1,1)); + + vec4 color = vec4(0); + // if(isinf(path[0].x)) imageStore(gBaseColor, ivec2(pixelLocation), + // vec4(vec2(pixelLocation)/vec2(imageSize(gBaseColor)), 1,1)); return; + for (uint styleIndex = 0; styleIndex < styleSize; styleIndex++) + { + + styleIndex += 6; + vec2 localUV = vec2(pixelLocation) / pixelRatio + leftTop; + + bool hitElement = false; + vec4 elementColor; + vec2 pBegin; + vec2 p3Last = vec2(1e38); + vec2 p2Last = vec2(1e38); + float strokeWidth = style[styleIndex]; + if (strokeWidth <= 0) // Fill + { + uint num_its = 0; + for (uint pathIndex = 0; pathIndex < pathSize; pathIndex++) + { + vec2 pTemp = path[pathIndex]; + if (isinf(pTemp.x)) + { + pBegin = path[++pathIndex]; + p3Last = pBegin; + continue; + } + mat4x2 p = mat4x2(p3Last, pTemp, path[++pathIndex], path[++pathIndex]); + + num_its += cubic_bezier_int_test(localUV, p[0], p[1], p[2], p[3]); + p3Last = p[3]; + p2Last = p[2]; + } + if (num_its % 2 == 1) + { + hitElement = true; + elementColor = vec4(1, 1, 0, 0); + + vec4 head = unpackUnorm4x8(floatBitsToUint(style[styleIndex])); + if (head.z == 0) + { + elementColor = vec4(unpackUnorm4x8(floatBitsToUint(style[++styleIndex])).rgb, 1); + } + } + } + else // Stroke + { + float minDistance = 1e38; + // float lineType = elementData[styleIndex+4]; + float lineType = 2; + int debugBegin = 0; + for (uint pathIndex = 0; pathIndex < pathSize; pathIndex++) + { + vec2 pTemp = path[pathIndex]; + if (isinf(pTemp.x)) + { + // TODO: ¼ì²âÊÇ·ñ·â±Õ²¢´¦Àí + + pBegin = path[++pathIndex]; + p3Last = pBegin; + continue; + } + mat4x2 p = mat4x2(p3Last, pTemp, path[++pathIndex], path[++pathIndex]); + + float d = cubic_bezier_dis(localUV, p[0], p[1], p[2], p[3], true); + if (d <= strokeWidth) + { + bool onBegin = distance(localUV, p[0]) <= strokeWidth && p3Last == p[0]; + bool fill = true; + if (onBegin) + { + vec2 normalLast = normalize(mat2(0, 1, -1, 0) * (p3Last - p2Last)); + vec2 normalNow = normalize(mat2(0, 1, -1, 0) * (p[1] - p[0])); + vec2 normal = normalLast + normalNow; + fill = angleLargeThanPi(normal, localUV - p[0]); + } + if (onBegin ? fill : d < minDistance) + { + minDistance = min(minDistance, d); + + bool reverse = p[3].y - p[0].y < 0.; + + vec2 tangentBegin = normalize(p[0] - p[1]); + vec2 tangentEnd = normalize(p[3] - p[2]); + if (tangentBegin.y == 0.) + tangentBegin.y = reverse ? eps : -eps; + if (tangentEnd.y == 0.) + tangentEnd.y = reverse ? -eps : eps; + int intTest = cubic_bezier_int_test2(localUV, p[0], p[1], p[2], p[3], reverse) + + ray_int_test(localUV, p[0], tangentBegin, reverse) + + ray_int_test(localUV, p[3], tangentEnd, reverse); + if (lineType == 2 || intTest % 2 == int(lineType)) + { + hitElement = true; + elementColor = vec4(1, 1, 0, 1); + // drawLine(minDistance / strokeWidth, styleIndex, elementColor, metallicRoughness); + } + else if (p3Last == p[0]) + hitElement = false; + } + } + p3Last = p[3]; + p2Last = p[2]; + } + } + if (hitElement) + color = elementColor; + styleIndex += 100; + } + if (color.a != 0) + imageStore(gBaseColor, ivec2(pixelLocation), color); +} \ No newline at end of file diff --git a/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp b/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp index 47f4ee1..21f210b 100644 --- a/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp +++ b/ArchitectureColoredPainting/src/Editor/GraphicElement.cpp @@ -1,5 +1,5 @@ #include "GraphicElement.h" -#include "third-party modules/util/SvgFileLoader.h" +#include "util/SvgFileLoader.h" using namespace std; QPainterPath SimpleElement::getPaintObject() const { diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/Element.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/Element.cpp index b716fa7..d697fa8 100644 --- a/ArchitectureColoredPainting/src/Renderer/Painting/Element.cpp +++ b/ArchitectureColoredPainting/src/Renderer/Painting/Element.cpp @@ -1 +1,16 @@ #include "Element.h" + +void Renderer::ElementTransform::applyTransformStyle(const TransformStyle& t) +{ + center += t.translation; + size *= t.scale; + rotation += t.rotation; + flip ^= t.flip; +} + +Renderer::ElementTransform Renderer::ElementTransform::appliedTransformStyle(const TransformStyle& t) const +{ + ElementTransform result = *this; + result.applyTransformStyle(t); + return result; +} diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/Element.h b/ArchitectureColoredPainting/src/Renderer/Painting/Element.h index d4f887f..bb869ff 100644 --- a/ArchitectureColoredPainting/src/Renderer/Painting/Element.h +++ b/ArchitectureColoredPainting/src/Renderer/Painting/Element.h @@ -21,5 +21,8 @@ namespace Renderer float rotation; /// ½Ç¶ÈÖÆ glm::bvec2 flip; GLuint zIndex; + + void applyTransformStyle(const TransformStyle& t); + ElementTransform appliedTransformStyle(const TransformStyle& t) const; }; } \ No newline at end of file diff --git a/ArchitectureColoredPainting/src/Renderer/Painting/Painting.cpp b/ArchitectureColoredPainting/src/Renderer/Painting/Painting.cpp index 5539faf..f1b8337 100644 --- a/ArchitectureColoredPainting/src/Renderer/Painting/Painting.cpp +++ b/ArchitectureColoredPainting/src/Renderer/Painting/Painting.cpp @@ -79,10 +79,7 @@ void Renderer::Painting::addElement(const Element& element, const ElementTransfo { auto& style = it->second[i]; ElementTransform trans = transform; - trans.center += style.transform->translation; - trans.size *= style.transform->scale; - trans.rotation += style.transform->rotation; - trans.flip ^= style.transform->flip; + trans.applyTransformStyle(*style.transform); trans.zIndex = trans.zIndex * 10 + i; addElement(ElementWithTransform{ BaseElement{element.contour, style.material}, BaseTransform(trans) }); } diff --git a/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp b/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp new file mode 100644 index 0000000..2787c96 --- /dev/null +++ b/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp @@ -0,0 +1,160 @@ +#include "ElementRenderer.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "../Painting/Element.h" +#include "../Painting/Painting.h" +#include "../Painting/MaterialStyleStroke.h" +using namespace Renderer; + +Renderer::ElementRenderer::ElementRenderer(QOpenGLWidget* glWidget) + : glWidget(glWidget) +{ +} + +void Renderer::ElementRenderer::initialize() +{ + initializeOpenGLFunctions(); + shader = std::make_shared(); + if (!shader->addShaderFromSourceFile(QOpenGLShader::Compute, ":/Shaders/element.comp")) + qDebug() << "ERROR: " << shader->log(); + if (!shader->link()) + qDebug() << "ERROR: " << shader->log(); + +} + +std::vector generatePathBuffer(const QPainterPath& path) +{ + std::vector pathBuffer; + for (int i = 0; i < path.elementCount(); i++) + { + QPainterPath::Element element = path.elementAt(i); + switch (element.type) + { + case QPainterPath::MoveToElement: + qDebug() << "MoveToElement"; + pathBuffer.push_back(glm::vec2(std::numeric_limits::infinity())); + pathBuffer.push_back(glm::vec2(element.x, element.y)); + break; + case QPainterPath::LineToElement: + qDebug() << "LineToElement"; + glm::vec2 end = glm::vec2(element.x, element.y); + glm::vec2 mid = (pathBuffer.back() + end) / 2.f; + pathBuffer.push_back(mid); + pathBuffer.push_back(mid); + pathBuffer.push_back(end); + break; + case QPainterPath::CurveToElement: + qDebug() << "CurveToElement"; + pathBuffer.push_back(glm::vec2(element.x, element.y)); + break; + case QPainterPath::CurveToDataElement: + qDebug() << "CurveToDataElement"; + pathBuffer.push_back(glm::vec2(element.x, element.y)); + break; + } + qDebug() << element; + } + return pathBuffer; +} + +std::vector generateStyleBuffer(const std::vector& styles) +{ + std::vector styleBuffer; + for (auto& style : styles) + { + styleBuffer.push_back(style.transform->translation.x); + styleBuffer.push_back(style.transform->translation.y); + styleBuffer.push_back(style.transform->scale.x); + styleBuffer.push_back(style.transform->scale.y); + styleBuffer.push_back(style.transform->rotation); + styleBuffer.push_back(glm::uintBitsToFloat(glm::packUnorm2x16(style.transform->flip))); + auto encoded = style.material->encoded(); + styleBuffer.insert(styleBuffer.end(), encoded.begin(), encoded.end()); + } + return styleBuffer; +} + +QRectF calcBoundingRect(const QPainterPath& path, const std::vector& styles) +{ + QRectF bound = path.boundingRect(); + + ElementTransform originTransform{ glm::vec2(bound.center().x(), bound.center().y()), glm::vec2(bound.width(), bound.height()), 0, glm::bvec2(false), 0 }; + + glm::vec2 leftTop(std::numeric_limits::max()), rightBottom(std::numeric_limits::min()); + + for (auto& baseStyle : styles) + { + BaseTransform transform(originTransform.appliedTransformStyle(*baseStyle.transform)); + if (baseStyle.material->type() == MaterialStyleType::kStroke) + { + float halfWidth = std::static_pointer_cast(baseStyle.material)->getWidth() / 2; + transform.bound.x -= halfWidth; + transform.bound.y -= halfWidth; + transform.bound.z += halfWidth; + transform.bound.w += halfWidth; + } + glm::vec2 points[] = { + glm::vec2(transform.bound.x, transform.bound.y), + glm::vec2(transform.bound.x, transform.bound.w), + glm::vec2(transform.bound.z, transform.bound.w), + glm::vec2(transform.bound.z, transform.bound.y) + }; + for (auto& point : points) + { + float angle = glm::radians(baseStyle.transform->rotation); + point = glm::mat2{ {cos(angle), -sin(angle)}, {sin(angle), cos(angle)} } *point; + leftTop = glm::min(leftTop, point); + rightBottom = glm::max(rightBottom, point); + } + } + return QRectF(QPointF(leftTop.x, leftTop.y), QPointF(rightBottom.x, rightBottom.y)); +} + +std::pair Renderer::ElementRenderer::drawElement(const QPainterPath& path, const ElementStyle& style, float pixelRatio, bool releaseContext) +{ + auto baseStyles = style.toBaseStyles(); + QRectF bound = calcBoundingRect(path, baseStyles); + QPointF leftTop = bound.topLeft(); + QSize size(ceil(bound.width() * pixelRatio), ceil(bound.height() * pixelRatio)); + + auto pathBuffer = generatePathBuffer(path); + auto styleBuffer = generateStyleBuffer(baseStyles); + + if (releaseContext) glWidget->makeCurrent(); + + GLuint ssbo[2]; + glGenBuffers(2, ssbo); + glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo[0]); + glBufferData(GL_SHADER_STORAGE_BUFFER, pathBuffer.size() * sizeof(glm::vec2), pathBuffer.data(), GL_STATIC_READ); + glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo[1]); + glBufferData(GL_SHADER_STORAGE_BUFFER, styleBuffer.size() * sizeof(GLfloat), styleBuffer.data(), GL_STATIC_READ); + glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); + + auto fbo = QOpenGLFramebufferObject(size, QOpenGLFramebufferObject::NoAttachment, GL_TEXTURE_2D); + fbo.bind(); + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + fbo.release(); + + shader->bind(); + shader->setUniformValue("pathSize", (GLint)pathBuffer.size()); + shader->setUniformValue("styleSize", (GLint)styleBuffer.size()); + shader->setUniformValue("leftTop", leftTop); + shader->setUniformValue("pixelRatio", pixelRatio); + glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 10, ssbo[0]); + glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 11, ssbo[1]); + glBindImageTexture(0, fbo.texture(), 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA8); + glDispatchCompute(ceil(size.width() / 8.), ceil(size.height() / 8.), 1); + shader->release(); + + auto image = fbo.toImage(false); + glDeleteBuffers(2, ssbo); + if (releaseContext) glWidget->doneCurrent(); + return { image, leftTop }; +} diff --git a/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.h b/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.h new file mode 100644 index 0000000..d105757 --- /dev/null +++ b/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.h @@ -0,0 +1,35 @@ +#pragma once +#include +#include +#include +#include "../Painting/ElementStyle.h" + +namespace Renderer +{ + class ElementRenderer : protected QOpenGLFunctions_4_5_Core + { + public: + ElementRenderer(QOpenGLWidget* glWidget); + + /** + * @brief ÐëÔÚinitializeGLº¯ÊýÖе÷Óà + */ + void initialize(); + + /** + * @brief ½«Í¼Ôª»æÖƵ½QImage + * @param path ͼԪ¼¸ºÎÊý¾Ý + * @param style ͼԪÑùʽ + * @param pixelRatio pathÖеĵ¥Î»×ø±ê¶ÔÓ¦µÄÏñËØ´óС + * @param releaseContext ÈôÔÚinitializeGL, resizeGL»òpaintGLÖе÷ÓÃÐë´«Èëfalse + * @return QImage »æÖƵõ½µÄλͼ + * @return QPointF λͼԭµã£¨×óÉϽǣ©ÔÚQPainterPath×ø±êϵϵÄ×ø±ê + */ + std::pair drawElement(const QPainterPath& path, const ElementStyle& style, float pixelRatio, bool releaseContext = true); + protected: + QOpenGLWidget* glWidget; + std::shared_ptr shader; + }; + +} + From 099b957bf746a84d561c9f55528d83427dca9696 Mon Sep 17 00:00:00 2001 From: wuyize Date: Mon, 6 Feb 2023 19:25:59 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E5=99=A8=E7=9A=84=E5=90=88=E5=B9=B6=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ArchitectureColoredPainting.vcxproj.filters | 2 -- 1 file changed, 2 deletions(-) diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters index 2bc7372..12795b5 100644 --- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters +++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters @@ -404,8 +404,6 @@ Header Files\Editor\util - - Header Files\Renderer\Painting Header Files\Renderer\Preview