FIX: 多样式不生效
parent
cf3dd43a4a
commit
4ec58dbb8b
|
@ -893,7 +893,7 @@ bool angleLargeThanPi(vec2 a, vec2 b)
|
||||||
|
|
||||||
/************************************************************************************/
|
/************************************************************************************/
|
||||||
|
|
||||||
void drawLine(in float d, inout uint styleIndex, out vec4 elementColor, out vec2 metallicRoughness)
|
void drawLine(in float d, uint styleIndex, out vec4 elementColor, out vec2 metallicRoughness)
|
||||||
{
|
{
|
||||||
elementColor = vec4(1);
|
elementColor = vec4(1);
|
||||||
metallicRoughness = vec2(0.8);
|
metallicRoughness = vec2(0.8);
|
||||||
|
@ -969,6 +969,30 @@ void drawLine(in float d, inout uint styleIndex, out vec4 elementColor, out vec2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nextStyleIndex(inout uint styleIndex)
|
||||||
|
{
|
||||||
|
uint headUint = floatBitsToUint(style[styleIndex + 1]);
|
||||||
|
vec4 head = unpackUnorm4x8(headUint);
|
||||||
|
switch (int(head.a * 100) % 10)
|
||||||
|
{
|
||||||
|
/// Plain
|
||||||
|
case 0: {
|
||||||
|
styleIndex += 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/// RadialGradient
|
||||||
|
case 1: {
|
||||||
|
uint size = headUint % (1 << 15);
|
||||||
|
styleIndex += 2 + size * 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool shouldFillBeginCap(vec2 localUV, bool onVeryBegin, int endType, vec2 p0, vec2 tangentBegin, vec2 tangentEndLast)
|
bool shouldFillBeginCap(vec2 localUV, bool onVeryBegin, int endType, vec2 p0, vec2 tangentBegin, vec2 tangentEndLast)
|
||||||
{
|
{
|
||||||
vec2 normal;
|
vec2 normal;
|
||||||
|
@ -1015,9 +1039,8 @@ void main()
|
||||||
vec4 color = vec4(0);
|
vec4 color = vec4(0);
|
||||||
// if(isinf(path[0].x)) imageStore(gBaseColor, ivec2(pixelLocation),
|
// if(isinf(path[0].x)) imageStore(gBaseColor, ivec2(pixelLocation),
|
||||||
// vec4(vec2(pixelLocation)/vec2(imageSize(gBaseColor)), 1,1)); return;
|
// vec4(vec2(pixelLocation)/vec2(imageSize(gBaseColor)), 1,1)); return;
|
||||||
for (uint styleIndex = 0; styleIndex < styleSize; styleIndex++)
|
for (uint styleIndex = 0; styleIndex < styleSize;)
|
||||||
{
|
{
|
||||||
|
|
||||||
styleIndex += 6;
|
styleIndex += 6;
|
||||||
vec2 localUV = vec2(pixelLocation) / pixelRatio + leftTop;
|
vec2 localUV = vec2(pixelLocation) / pixelRatio + leftTop;
|
||||||
|
|
||||||
|
@ -1056,6 +1079,7 @@ void main()
|
||||||
elementColor = vec4(unpackUnorm4x8(floatBitsToUint(style[++styleIndex])).rgb, 1);
|
elementColor = vec4(unpackUnorm4x8(floatBitsToUint(style[++styleIndex])).rgb, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else // Stroke
|
else // Stroke
|
||||||
{
|
{
|
||||||
|
@ -1129,8 +1153,8 @@ void main()
|
||||||
|
|
||||||
// if (onBegin ? shouldFillBeginCap(localUV, onVeryBegin, endType, p[0], tangentBegin,
|
// if (onBegin ? shouldFillBeginCap(localUV, onVeryBegin, endType, p[0], tangentBegin,
|
||||||
// tangentEndLast)
|
// tangentEndLast)
|
||||||
// : (onEnd ? /*shouldFillEndCap(localUV, onVeryEnd, endType, p[3], tangentEnd,
|
// : (onEnd ? shouldFillEndCap(localUV, onVeryEnd, endType, p[3], tangentEnd,
|
||||||
// tangentBeginNext)*/ false
|
// tangentBeginNext)
|
||||||
// : d < minDistance))
|
// : d < minDistance))
|
||||||
bool hit = d < minDistance;
|
bool hit = d < minDistance;
|
||||||
if (onBegin)
|
if (onBegin)
|
||||||
|
@ -1183,10 +1207,11 @@ void main()
|
||||||
{
|
{
|
||||||
// hitElement = shouldFillEndCap(localUV, true, endType, p3Last, tangentEndLast);
|
// hitElement = shouldFillEndCap(localUV, true, endType, p3Last, tangentEndLast);
|
||||||
}
|
}
|
||||||
|
nextStyleIndex(styleIndex);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (hitElement)
|
if (hitElement)
|
||||||
color = elementColor;
|
color = elementColor;
|
||||||
styleIndex += 100;
|
|
||||||
}
|
}
|
||||||
if (color.a != 0)
|
if (color.a != 0)
|
||||||
imageStore(gBaseColor, ivec2(pixelLocation), color);
|
imageStore(gBaseColor, ivec2(pixelLocation), color);
|
||||||
|
|
|
@ -77,6 +77,7 @@ std::vector<GLfloat> generateStyleBuffer(const std::vector<BaseStyle>& styles)
|
||||||
styleBuffer.push_back(glm::uintBitsToFloat(glm::packUnorm2x16(style.transform->flip)));
|
styleBuffer.push_back(glm::uintBitsToFloat(glm::packUnorm2x16(style.transform->flip)));
|
||||||
auto encoded = style.material->encoded();
|
auto encoded = style.material->encoded();
|
||||||
styleBuffer.insert(styleBuffer.end(), encoded.begin(), encoded.end());
|
styleBuffer.insert(styleBuffer.end(), encoded.begin(), encoded.end());
|
||||||
|
qDebug() << "style size" << styleBuffer.size();
|
||||||
}
|
}
|
||||||
return styleBuffer;
|
return styleBuffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ using namespace Renderer;
|
||||||
|
|
||||||
namespace UnitTest
|
namespace UnitTest
|
||||||
{
|
{
|
||||||
|
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg);
|
||||||
|
|
||||||
TEST_CLASS(ElementRendererStokeTypeTest)
|
TEST_CLASS(ElementRendererStokeTypeTest)
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -20,6 +22,7 @@ namespace UnitTest
|
||||||
|
|
||||||
TEST_METHOD_INITIALIZE(initialize)
|
TEST_METHOD_INITIALIZE(initialize)
|
||||||
{
|
{
|
||||||
|
qInstallMessageHandler(messageHandler);
|
||||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||||
|
|
Loading…
Reference in New Issue