fix: reduce shader usage
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <qsggeometry.h>
|
||||
#include <qsgnode.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
BlobInvertedRect::BlobInvertedRect(QQuickItem* parent) : BlobShape(parent) {}
|
||||
@@ -129,6 +130,10 @@ QSGNode* BlobInvertedRect::updatePaintNode(
|
||||
material->m_invertedInner,
|
||||
m_cachedInvertedInner,
|
||||
sizeof(m_cachedInvertedInner));
|
||||
memcpy(
|
||||
material->m_invertedOuterRadii,
|
||||
m_cachedInvertedOuterRadii,
|
||||
sizeof(m_cachedInvertedOuterRadii));
|
||||
|
||||
const int count =
|
||||
static_cast<int>(qMin(m_cachedRects.size(), qsizetype(16)));
|
||||
@@ -173,6 +178,64 @@ void BlobInvertedRect::setBorderBottom(qreal v) {
|
||||
if (m_group) m_group->markDirty();
|
||||
}
|
||||
|
||||
void BlobInvertedRect::setOuterRadius(qreal v) {
|
||||
if (qFuzzyCompare(m_outerRadius, v)) return;
|
||||
m_outerRadius = v;
|
||||
emit outerRadiusChanged();
|
||||
if (m_group) m_group->markDirty();
|
||||
}
|
||||
|
||||
void BlobInvertedRect::setOuterTopLeftRadius(qreal v) {
|
||||
if (qFuzzyCompare(m_outerTopLeftRadius, v)) return;
|
||||
m_outerTopLeftRadius = v;
|
||||
emit outerTopLeftRadiusChanged();
|
||||
if (m_group) m_group->markDirty();
|
||||
}
|
||||
|
||||
void BlobInvertedRect::setOuterTopRightRadius(qreal v) {
|
||||
if (qFuzzyCompare(m_outerTopRightRadius, v)) return;
|
||||
m_outerTopRightRadius = v;
|
||||
emit outerTopRightRadiusChanged();
|
||||
if (m_group) m_group->markDirty();
|
||||
}
|
||||
|
||||
void BlobInvertedRect::setOuterBottomLeftRadius(qreal v) {
|
||||
if (qFuzzyCompare(m_outerBottomLeftRadius, v)) return;
|
||||
m_outerBottomLeftRadius = v;
|
||||
emit outerBottomLeftRadiusChanged();
|
||||
if (m_group) m_group->markDirty();
|
||||
}
|
||||
|
||||
void BlobInvertedRect::setOuterBottomRightRadius(qreal v) {
|
||||
if (qFuzzyCompare(m_outerBottomRightRadius, v)) return;
|
||||
m_outerBottomRightRadius = v;
|
||||
emit outerBottomRightRadiusChanged();
|
||||
if (m_group) m_group->markDirty();
|
||||
}
|
||||
|
||||
void BlobInvertedRect::outerCornerRadii(float out[4]) const {
|
||||
const auto maxR = static_cast<float>(std::min(width(), height())) * 0.5f;
|
||||
const auto base = std::min(static_cast<float>(m_outerRadius), maxR);
|
||||
out[0] = std::min(
|
||||
m_outerTopRightRadius >= 0 ? static_cast<float>(m_outerTopRightRadius)
|
||||
: base,
|
||||
maxR);
|
||||
out[1] = std::min(
|
||||
m_outerBottomRightRadius >= 0
|
||||
? static_cast<float>(m_outerBottomRightRadius)
|
||||
: base,
|
||||
maxR);
|
||||
out[2] = std::min(
|
||||
m_outerBottomLeftRadius >= 0
|
||||
? static_cast<float>(m_outerBottomLeftRadius)
|
||||
: base,
|
||||
maxR);
|
||||
out[3] = std::min(
|
||||
m_outerTopLeftRadius >= 0 ? static_cast<float>(m_outerTopLeftRadius)
|
||||
: base,
|
||||
maxR);
|
||||
}
|
||||
|
||||
void BlobInvertedRect::registerWithGroup() {
|
||||
if (m_group) m_group->setInvertedRect(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user