Compare commits
No commits in common. "e004809164f1558dd3b36ea2b9d5fffa481c9ce2" and "870531a0bec46361abbfb86ad576e61ad3d1ba9a" have entirely different histories.
e004809164
...
870531a0be
|
@ -1033,9 +1033,8 @@ void main()
|
|||
if (lineType == 2 || intTest % 2 == int(lineType))
|
||||
{
|
||||
hitElement = true;
|
||||
//elementColor = vec4(1, 1, 0, 1);
|
||||
vec2 metallicRoughness;
|
||||
drawLine(minDistance / strokeWidth, styleIndex, elementColor, metallicRoughness);
|
||||
elementColor = vec4(1, 1, 0, 1);
|
||||
// drawLine(minDistance / strokeWidth, styleIndex, elementColor, metallicRoughness);
|
||||
}
|
||||
else if (p3Last == p[0])
|
||||
hitElement = false;
|
||||
|
|
|
@ -1034,9 +1034,8 @@ bool drawElement(uint elementIndex, vec2 localUV, out vec3 color, out vec2 metal
|
|||
uint contourIndex = linesOffset + leftChild - 0x80000000;
|
||||
float minDistance = 1e38;
|
||||
uint lineCount = elementIndexs[contourIndex];
|
||||
vec4 styleHead = unpackUnorm4x8(floatBitsToUint(elementData[styleIndex+1]));
|
||||
float lineType = floor(styleHead.b*10);
|
||||
//float lineType = 2;
|
||||
//float lineType = elementData[styleIndex+4];
|
||||
float lineType = 2;
|
||||
vec2 p3Last = vec2(1e38);
|
||||
vec2 p2Last = vec2(1e38);
|
||||
int debugBegin = 0;
|
||||
|
|
|
@ -45,12 +45,12 @@ PixelPath GroupElement::getPaintObject() const
|
|||
//TODO: apply styles and send back
|
||||
PixelPath SimpleElement::getPaintObject(std::vector<Renderer::ElementStyleStrokeDemo> styles) const {
|
||||
PixelPath result;
|
||||
Renderer::ElementStyleStrokeDemo demo(2);
|
||||
Renderer::ElementStyleStrokeDemo demo;
|
||||
qDebug() << (renderer==nullptr)<<"------------";
|
||||
auto [img, mov] = renderer->drawElement(painterPath, demo, 1.0, false);
|
||||
//auto [img, mov] = renderer->drawElement(painterPath,demo,1.0,false);
|
||||
//qDebug() << img << " ------";
|
||||
result.addImage(img, mov);
|
||||
//result.addPath(painterPath);
|
||||
//result.addImage(img, mov);
|
||||
result.addPath(painterPath);
|
||||
// QImage img(80,80,QImage::Format_ARGB32);
|
||||
// QPainter pt(&img);
|
||||
//pt.setPen(QPen(Qt::red, 2));
|
||||
|
|
|
@ -392,7 +392,7 @@ GLuint Renderer::Model::loadPainting(std::string path)
|
|||
|
||||
vector<std::shared_ptr<ElementStyle>> style = {
|
||||
std::make_shared<ElementStyleFillDemo>(),
|
||||
std::make_shared<ElementStyleStrokeDemo>(0.02)
|
||||
std::make_shared<ElementStyleStrokeDemo>()
|
||||
};
|
||||
|
||||
vector<std::shared_ptr<Element>> element = {
|
||||
|
|
|
@ -1,13 +1,3 @@
|
|||
#include "BaseStyle.h"
|
||||
|
||||
using namespace Renderer;
|
||||
|
||||
bool Renderer::Material::operator==(const Material& m) const
|
||||
{
|
||||
return color == m.color && metallic == m.metallic && roughness == m.roughness;
|
||||
}
|
||||
|
||||
std::pair<glm::vec4, glm::vec2> Renderer::Material::toVec() const
|
||||
{
|
||||
return { glm::vec4(color.redF(), color.greenF(), color.blueF(), color.alphaF()), glm::vec2(metallic, roughness)};
|
||||
}
|
||||
|
|
|
@ -30,13 +30,4 @@ namespace Renderer
|
|||
std::shared_ptr<TransformStyle> transform;
|
||||
std::shared_ptr<MaterialStyle> material;
|
||||
};
|
||||
|
||||
struct Material
|
||||
{
|
||||
QColor color;
|
||||
float metallic;
|
||||
float roughness;
|
||||
bool operator==(const Material&) const;
|
||||
std::pair<glm::vec4, glm::vec2> toVec() const;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -10,13 +10,8 @@ std::vector<BaseStyle> Renderer::ElementStyleFillDemo::toBaseStyles() const
|
|||
std::make_shared<MaterialStyleFill>(std::make_shared<FillPlain>(QColor(0, 255, 0), 0, 0.8))) };
|
||||
}
|
||||
|
||||
Renderer::ElementStyleStrokeDemo::ElementStyleStrokeDemo(float width)
|
||||
: width(width)
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<BaseStyle> Renderer::ElementStyleStrokeDemo::toBaseStyles() const
|
||||
{
|
||||
return { BaseStyle(std::make_shared<TransformStyle>(),
|
||||
std::make_shared<MaterialStyleStroke>(width, StrokeType::kLeftSide, StrokeEndType::kRound, std::make_shared<StrokePlain>(QColor(0, 0, 255), 0, 0.8))) };
|
||||
std::make_shared<MaterialStyleStroke>(0.02, StrokeType::kBothSides, StrokeEndType::kRound, std::make_shared<StrokePlain>(QColor(0, 0, 255), 0, 0.8))) };
|
||||
}
|
||||
|
|
|
@ -26,9 +26,6 @@ namespace Renderer
|
|||
class ElementStyleStrokeDemo : public ElementStyle
|
||||
{
|
||||
public:
|
||||
ElementStyleStrokeDemo(float width);
|
||||
virtual std::vector<BaseStyle> toBaseStyles() const override;
|
||||
protected:
|
||||
float width;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
using namespace Renderer;
|
||||
|
||||
Renderer::StrokePlain::StrokePlain(QColor color, float metallic, float roughness)
|
||||
: material{ color,metallic,roughness }
|
||||
: color(color), metallic(metallic), roughness(roughness)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -14,14 +14,16 @@ MaterialStrokeType Renderer::StrokePlain::type() const
|
|||
|
||||
std::vector<GLfloat> Renderer::StrokePlain::encoded() const
|
||||
{
|
||||
return { glm::uintBitsToFloat(glm::packUnorm4x8(glm::vec4(material.toVec().second, 0.f, 0.f))),
|
||||
glm::uintBitsToFloat(glm::packUnorm4x8(material.toVec().first)) };
|
||||
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()
|
||||
&& material == static_cast<const StrokePlain&>(m).material;
|
||||
&& color == static_cast<const StrokePlain&>(m).color
|
||||
&& metallic == static_cast<const StrokePlain&>(m).metallic
|
||||
&& roughness == static_cast<const StrokePlain&>(m).roughness;
|
||||
}
|
||||
|
||||
Renderer::MaterialStyleStroke::MaterialStyleStroke(float width, StrokeType strokeType, StrokeEndType endType, std::shared_ptr<MaterialStroke> materialStroke)
|
||||
|
@ -38,10 +40,6 @@ std::vector<GLfloat> Renderer::MaterialStyleStroke::encoded() const
|
|||
{
|
||||
std::vector<GLfloat> v = { width };
|
||||
auto encoded = materialStroke->encoded();
|
||||
glm::vec4 head = glm::unpackUnorm4x8(glm::floatBitsToUint(encoded[0]));
|
||||
head.b = (float)strokeType / 10. + (float)endType / 100.;
|
||||
head.a = 1; /// Ô¤Áô
|
||||
encoded[0] = glm::uintBitsToFloat(glm::packUnorm4x8(head));
|
||||
v.insert(v.end(), encoded.begin(), encoded.end());
|
||||
return v;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace Renderer
|
||||
{
|
||||
enum class MaterialStrokeType { kPlain, kLinearGradient, kRadialGradient};
|
||||
enum class MaterialStrokeType { kPlain };
|
||||
|
||||
class MaterialStroke
|
||||
{
|
||||
|
@ -21,22 +21,14 @@ namespace Renderer
|
|||
virtual std::vector<GLfloat> encoded() const override;
|
||||
virtual bool operator==(const MaterialStroke&) const override;
|
||||
|
||||
Material material;
|
||||
QColor color;
|
||||
float metallic;
|
||||
float roughness;
|
||||
};
|
||||
|
||||
class StrokeRadialGradient : public MaterialStroke
|
||||
{
|
||||
public:
|
||||
StrokeRadialGradient(QColor color, float metallic, float roughness);
|
||||
virtual MaterialStrokeType type() const override;
|
||||
virtual std::vector<GLfloat> encoded() const override;
|
||||
virtual bool operator==(const MaterialStroke&) const override;
|
||||
|
||||
//std::map<
|
||||
};
|
||||
|
||||
enum class StrokeType { kBothSides = 2, kLeftSide = 1, kRightSide = 0 };
|
||||
enum class StrokeEndType { kRound = 0 };
|
||||
enum class StrokeEndType { kRound };
|
||||
|
||||
class MaterialStyleStroke : public MaterialStyle
|
||||
{
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
#include "MainWindow.h"
|
||||
#include "Renderer/Painting/CubicBezier.h"
|
||||
#include <QGuiApplication>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
||||
|
||||
using Renderer::CubicBezier;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
_declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
|
||||
|
@ -17,7 +20,7 @@ int main(int argc, char* argv[])
|
|||
//QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
QApplication a(argc, argv);
|
||||
//FramelessHelper::Core::setApplicationOSThemeAware();
|
||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
||||
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
|
||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
#include "CppUnitTest.h"
|
||||
#include <QGuiApplication>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include "ElementRendererTest.h"
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
TEST_CLASS(ElementRendererTest)
|
||||
{
|
||||
public:
|
||||
TEST_METHOD(TestMethod1)
|
||||
{
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
char arg[] = "";
|
||||
char* argv[] = { arg };
|
||||
int argc = 1;
|
||||
QApplication a(argc, argv);
|
||||
TestGLWidget w;
|
||||
w.show();
|
||||
a.exec();
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
#pragma once
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QPainter>
|
||||
#include "Renderer/Preview/ElementRenderer.h"
|
||||
#include "Editor/ThirdPartyLib/qquick/qquicksvgparser_p.h"
|
||||
#include "Renderer/Painting/MaterialStyleStroke.h"
|
||||
#include "Renderer/Painting/ElementStyle.h"
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class TestGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
Renderer::ElementRenderer renderer;
|
||||
public:
|
||||
TestGLWidget(QWidget* parent = nullptr) : QOpenGLWidget(parent), renderer(this) {};
|
||||
void initializeGL() override
|
||||
{
|
||||
initializeOpenGLFunctions();
|
||||
renderer.initialize();
|
||||
};
|
||||
void paintGL() override
|
||||
{
|
||||
glClearColor(1.0, 1.0, 1.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
QPainterPath path;
|
||||
QQuickSvgParser::parsePathDataFast("M100,100C-.5,100,0,100.5,0,0L40,.07C40,59.5,39.5,60,100,60Z", path);
|
||||
auto [img, pos] = renderer.drawElement(path, Renderer::ElementStyleStrokeDemo(2), 1, false);
|
||||
QPainter painter(this);
|
||||
painter.drawImage(pos, img);
|
||||
};
|
||||
void resizeGL(int w, int h) override {};
|
||||
};
|
||||
}
|
|
@ -105,12 +105,6 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="UnitTest.ui" />
|
||||
<ClCompile Include="ElementRendererTest.cpp">
|
||||
<DynamicSource Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">input</DynamicSource>
|
||||
<QtMocFileName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).moc</QtMocFileName>
|
||||
<DynamicSource Condition="'$(Configuration)|$(Platform)'=='Release|x64'">input</DynamicSource>
|
||||
<QtMocFileName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).moc</QtMocFileName>
|
||||
</ClCompile>
|
||||
<ClCompile Include="UnitTest.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -122,9 +116,6 @@
|
|||
<Value>$(QtDllPath)</Value>
|
||||
</T4ParameterValues>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="ElementRendererTest.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
|
||||
<Import Project="$(QtMsBuild)\qt.targets" />
|
||||
|
|
|
@ -33,14 +33,4 @@
|
|||
<ItemGroup>
|
||||
<None Include="Qt.runsettings.tt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="ElementRendererTest.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ElementRendererTest.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue