Skip to content

Commit

Permalink
Merge pull request xbmc#23022 from sarbes/scissor-culling
Browse files Browse the repository at this point in the history
Cull GUI elements not in scissor bounds
  • Loading branch information
sarbes committed Apr 20, 2024
2 parents ae30850 + 46d0ada commit 46d9d48
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
22 changes: 22 additions & 0 deletions xbmc/guilib/GUIControl.cpp
Expand Up @@ -180,6 +180,10 @@ void CGUIControl::Process(unsigned int currentTime, CDirtyRegionList &dirtyregio
// 3. reset the animation transform
void CGUIControl::DoRender()
{
if (IsControlRenderable() &&
!m_renderRegion.Intersects(CServiceBroker::GetWinSystem()->GetGfxContext().GetScissors()))
return;

if (IsVisible() && !m_isCulled)
{
bool hasStereo =
Expand Down Expand Up @@ -954,6 +958,24 @@ void CGUIControl::UpdateControlStats()
}
}

bool CGUIControl::IsControlRenderable()
{
switch (ControlType)
{
case GUICONTAINER_EPGGRID:
case GUICONTAINER_FIXEDLIST:
case GUICONTAINER_LIST:
case GUICONTAINER_PANEL:
case GUICONTAINER_WRAPLIST:
case GUICONTROL_GROUP:
case GUICONTROL_GROUPLIST:
case GUICONTROL_LISTGROUP:
return false;
default:
return true;
}
}

void CGUIControl::SetHitRect(const CRect& rect, const UTILS::COLOR::Color& color)
{
m_hitRect = rect;
Expand Down
5 changes: 5 additions & 0 deletions xbmc/guilib/GUIControl.h
Expand Up @@ -306,6 +306,11 @@ class CGUIControl
};
GUICONTROLTYPES GetControlType() const { return ControlType; }

/*! \brief Test whether the control is "drawable" (not a group or similar)
\return true if the control has textures/labels it wants to render
*/
bool IsControlRenderable();

enum GUIVISIBLE { HIDDEN = 0, DELAYED, VISIBLE };

enum GUISCROLLVALUE { FOCUS = 0, NEVER, ALWAYS };
Expand Down
5 changes: 5 additions & 0 deletions xbmc/utils/Geometry.h
Expand Up @@ -281,6 +281,11 @@ template <typename T> class CRectGen
return (x1 <= point.x && point.x <= x2 && y1 <= point.y && point.y <= y2);
};

constexpr bool Intersects(const this_type& rect) const
{
return (x1 < rect.x2 && x2 > rect.x1 && y1 < rect.y2 && y2 > rect.y1);
};

this_type& operator-=(const point_type &point) XBMC_FORCE_INLINE
{
x1 -= point.x;
Expand Down

0 comments on commit 46d9d48

Please sign in to comment.