Skip to content

Commit

Permalink
Re-include reverted fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BertholdKrevert committed Mar 11, 2024
1 parent c7ca607 commit 56f997f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 44 deletions.
15 changes: 0 additions & 15 deletions src/RiveQtQuickItem/renderer/riveqtfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,6 @@ RiveQSGRenderNode *RiveQtFactory::renderNode(QQuickWindow *window, std::weak_ptr
}
}

rive::rcp<rive::RenderBuffer> RiveQtFactory::makeBufferU16(rive::Span<const uint16_t> data)
{
return nullptr;
}

rive::rcp<rive::RenderBuffer> RiveQtFactory::makeBufferU32(rive::Span<const uint32_t> data)
{
return nullptr;
}

rive::rcp<rive::RenderBuffer> RiveQtFactory::makeBufferF32(rive::Span<const float> data)
{
return nullptr;
}

rive::rcp<rive::RenderBuffer> RiveQtFactory::makeRenderBuffer(rive::RenderBufferType renderBufferType, rive::RenderBufferFlags renderBufferFlags, size_t size)
{
return rive::make_rcp<rive::DataRenderBuffer>(renderBufferType, renderBufferFlags, size);;
Expand Down
5 changes: 0 additions & 5 deletions src/RiveQtQuickItem/renderer/riveqtfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ class RiveQtFactory : public rive::Factory
void setRenderSettings(const RiveRenderSettings &renderSettings) { m_renderSettings = renderSettings; }

RiveQSGRenderNode *renderNode(QQuickWindow *window, std::weak_ptr<rive::ArtboardInstance> artboardInstance, const QRectF &geometry);

rive::rcp<rive::RenderBuffer> makeBufferU16(rive::Span<const uint16_t> data);
rive::rcp<rive::RenderBuffer> makeBufferU32(rive::Span<const uint32_t> data);
rive::rcp<rive::RenderBuffer> makeBufferF32(rive::Span<const float> data);

rive::rcp<rive::RenderBuffer> makeRenderBuffer(rive::RenderBufferType, rive::RenderBufferFlags, size_t) override;

rive::rcp<rive::RenderShader> makeLinearGradient(float, float, float, float, const rive::ColorInt[], const float[], size_t) override;
Expand Down
38 changes: 20 additions & 18 deletions src/RiveQtQuickItem/renderer/riveqtrhirenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,28 +97,30 @@ void RiveQtRhiRenderer::drawPath(rive::RenderPath *path, rive::RenderPaint *pain
}

RiveQtPath clipResult;
QPair<QPainterPath, QMatrix4x4> firstLevel = m_rhiRenderStack.back().m_allClipPainterPathesApplied.first();
if (!m_rhiRenderStack.back().m_allClipPainterPathesApplied.empty()) {
QPair<QPainterPath, QMatrix4x4> firstLevel = m_rhiRenderStack.back().m_allClipPainterPathesApplied.first();

clipResult.setQPainterPath(firstLevel.first);
clipResult.applyMatrix(firstLevel.second);

for (int i = 1; i < m_rhiRenderStack.back().m_allClipPainterPathesApplied.count(); ++i) {
RiveQtPath a;
const auto &entry = m_rhiRenderStack.back().m_allClipPainterPathesApplied[i];
a.setQPainterPath(entry.first);
a.applyMatrix(entry.second);
clipResult.intersectWith(a.toQPainterPath());
}

clipResult.setQPainterPath(firstLevel.first);
clipResult.applyMatrix(firstLevel.second);
// #if 0 // this allows to draw the clipping area which it useful for debugging :)
// TextureTargetNode *drawClipping = getRiveDrawTargetNode();
// drawClipping->setOpacity(currentOpacity()); // inherit the opacity from the parent
// drawClipping->setColor(QColor(255, 0, 0, 29));
// drawClipping->updateGeometry(clipResult.toVertices(), QMatrix4x4());
// #endif

for (int i = 1; i < m_rhiRenderStack.back().m_allClipPainterPathesApplied.count(); ++i) {
RiveQtPath a;
const auto &entry = m_rhiRenderStack.back().m_allClipPainterPathesApplied[i];
a.setQPainterPath(entry.first);
a.applyMatrix(entry.second);
clipResult.intersectWith(a.toQPainterPath());
node->updateClippingGeometry(clipResult.toVertices());
}

// #if 0 // this allows to draw the clipping area which it useful for debugging :)
// TextureTargetNode *drawClipping = getRiveDrawTargetNode();
// drawClipping->setOpacity(currentOpacity()); // inherit the opacity from the parent
// drawClipping->setColor(QColor(255, 0, 0, 29));
// drawClipping->updateGeometry(clipResult.toVertices(), QMatrix4x4());
// #endif

node->updateClippingGeometry(clipResult.toVertices());

node->updateGeometry(pathData, transformMatrix());
}

Expand Down
12 changes: 6 additions & 6 deletions src/RiveQtQuickItem/riveqtquickitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ void RiveQtQuickItem::updateInternalArtboard()

if (m_currentArtboardIndex == -1) {
m_currentArtboardInstance = m_riveFile->artboardDefault();
} else {
m_currentArtboardInstance = m_riveFile->artboardAt(m_currentArtboardIndex);
} else if (!m_currentArtboardInstance || m_riveFile->artboardAt(m_currentArtboardIndex).get() != m_currentArtboardInstance->artboard()) {
m_currentArtboardInstance = m_riveFile->artboardAt(m_currentArtboardIndex);
}

if (!m_currentArtboardInstance) {
Expand Down Expand Up @@ -193,11 +193,15 @@ QSGNode *RiveQtQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
// of course the calls to the stateMachineInterface wont do anything

m_renderNode->updateArtboardInstance(std::weak_ptr<rive::ArtboardInstance>());
m_currentArtboardInstance.reset();

// reset all
m_riveFile = nullptr;
m_scheduleArtboardChange = true;
m_scheduleStateMachineChange = true;
m_currentArtboardIndex = -1;
m_initialArtboardIndex = -1;


// now load the file from the main thread -> connected as Queued Connection to make sure its called in its owning thread
emit loadFileAfterUnloading(m_fileSource);
Expand Down Expand Up @@ -485,10 +489,6 @@ void RiveQtQuickItem::loadRiveFile(const QString &source)
return;
}

if (m_currentArtboardInstance) {
m_currentArtboardInstance.reset();
}

QByteArray fileData = file.readAll();
file.close();

Expand Down

0 comments on commit 56f997f

Please sign in to comment.