Skip to content

Commit

Permalink
Optimization: If a DivNode is inactive, don't call preRender for its …
Browse files Browse the repository at this point in the history
…children.
  • Loading branch information
uzadow committed Sep 21, 2017
1 parent be42c16 commit c3464a7
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/player/DivNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,17 +305,19 @@ void DivNode::preRender(const VertexArrayPtr& pVA, bool bIsParentActive,
float parentEffectiveOpacity)
{
AreaNode::preRender(pVA, bIsParentActive, parentEffectiveOpacity);
if (getCrop() && getSize() != glm::vec2(0,0)) {
pVA->startSubVA(m_ClipVA);
glm::vec2 viewport = getSize();
m_ClipVA.appendPos(glm::vec2(0,0), glm::vec2(0,0), Pixel32(0,0,0,0));
m_ClipVA.appendPos(glm::vec2(0,viewport.y), glm::vec2(0,0), Pixel32(0,0,0,0));
m_ClipVA.appendPos(glm::vec2(viewport.x,0), glm::vec2(0,0), Pixel32(0,0,0,0));
m_ClipVA.appendPos(viewport, glm::vec2(0,0), Pixel32(0,0,0,0));
m_ClipVA.appendQuadIndexes(0, 1, 2, 3);
}
for (unsigned i = 0; i < getNumChildren(); i++) {
m_Children[i]->preRender(pVA, bIsParentActive, getEffectiveOpacity());
if (getActive()) {
if (getCrop() && getSize() != glm::vec2(0,0)) {
pVA->startSubVA(m_ClipVA);
glm::vec2 viewport = getSize();
m_ClipVA.appendPos(glm::vec2(0,0), glm::vec2(0,0), Pixel32(0,0,0,0));
m_ClipVA.appendPos(glm::vec2(0,viewport.y), glm::vec2(0,0), Pixel32(0,0,0,0));
m_ClipVA.appendPos(glm::vec2(viewport.x,0), glm::vec2(0,0), Pixel32(0,0,0,0));
m_ClipVA.appendPos(viewport, glm::vec2(0,0), Pixel32(0,0,0,0));
m_ClipVA.appendQuadIndexes(0, 1, 2, 3);
}
for (unsigned i = 0; i < getNumChildren(); i++) {
m_Children[i]->preRender(pVA, bIsParentActive, getEffectiveOpacity());
}
}
}

Expand Down

0 comments on commit c3464a7

Please sign in to comment.