Browse Source

Rendering speed improvement and small viewport tweak.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
e7c8702d4e
3 changed files with 98 additions and 112 deletions
  1. +49
    -56
      juce_amalgamated.cpp
  2. +49
    -53
      src/gui/components/layout/juce_Viewport.cpp
  3. +0
    -3
      src/gui/graphics/geometry/juce_RectangleList.cpp

+ 49
- 56
juce_amalgamated.cpp View File

@@ -63262,12 +63262,12 @@ void Viewport::setViewedComponent (Component* const newViewedComponent)

int Viewport::getMaximumVisibleWidth() const
{
return jmax (0, getWidth() - (verticalScrollBar->isVisible() ? getScrollBarThickness() : 0));
return contentHolder->getWidth();
}

int Viewport::getMaximumVisibleHeight() const
{
return jmax (0, getHeight() - (horizontalScrollBar->isVisible() ? getScrollBarThickness() : 0));
return contentHolder->getHeight();
}

void Viewport::setViewPosition (const int xPixelsOffset, const int yPixelsOffset)
@@ -63347,27 +63347,12 @@ void Viewport::updateVisibleArea()
bool hBarVisible = canShowHBar && ! horizontalScrollBar->autoHides();
bool vBarVisible = canShowVBar && ! horizontalScrollBar->autoHides();

if (contentComp != 0)
{
Rectangle<int> contentArea (getLocalBounds());

if (! contentArea.contains (contentComp->getBounds()))
{
hBarVisible = canShowHBar && (hBarVisible || contentComp->getX() < 0 || contentComp->getRight() > contentArea.getWidth());
vBarVisible = canShowVBar && (vBarVisible || contentComp->getY() < 0 || contentComp->getBottom() > contentArea.getHeight());

if (vBarVisible)
contentArea.setWidth (getWidth() - scrollbarWidth);
Rectangle<int> contentArea (getLocalBounds());

if (hBarVisible)
contentArea.setHeight (getHeight() - scrollbarWidth);

if (! contentArea.contains (contentComp->getBounds()))
{
hBarVisible = canShowHBar && (hBarVisible || contentComp->getRight() > contentArea.getWidth());
vBarVisible = canShowVBar && (vBarVisible || contentComp->getBottom() > contentArea.getHeight());
}
}
if (contentComp != 0 && ! contentArea.contains (contentComp->getBounds()))
{
hBarVisible = canShowHBar && (hBarVisible || contentComp->getX() < 0 || contentComp->getRight() > contentArea.getWidth());
vBarVisible = canShowVBar && (vBarVisible || contentComp->getY() < 0 || contentComp->getBottom() > contentArea.getHeight());

if (vBarVisible)
contentArea.setWidth (getWidth() - scrollbarWidth);
@@ -63375,48 +63360,59 @@ void Viewport::updateVisibleArea()
if (hBarVisible)
contentArea.setHeight (getHeight() - scrollbarWidth);

const Point<int> visibleOrigin (-contentComp->getPosition());

if (hBarVisible)
if (! contentArea.contains (contentComp->getBounds()))
{
horizontalScrollBar->setBounds (0, contentArea.getHeight(), contentArea.getWidth(), scrollbarWidth);
horizontalScrollBar->setRangeLimits (0.0, contentComp->getWidth());
horizontalScrollBar->setCurrentRange (visibleOrigin.getX(), contentArea.getWidth());
horizontalScrollBar->setSingleStepSize (singleStepX);
hBarVisible = canShowHBar && (hBarVisible || contentComp->getRight() > contentArea.getWidth());
vBarVisible = canShowVBar && (vBarVisible || contentComp->getBottom() > contentArea.getHeight());
}
}

if (vBarVisible)
{
verticalScrollBar->setBounds (contentArea.getWidth(), 0, scrollbarWidth, contentArea.getHeight());
verticalScrollBar->setRangeLimits (0.0, contentComp->getHeight());
verticalScrollBar->setCurrentRange (visibleOrigin.getY(), contentArea.getHeight());
verticalScrollBar->setSingleStepSize (singleStepY);
}
if (vBarVisible)
contentArea.setWidth (getWidth() - scrollbarWidth);

// Force the visibility *after* setting the ranges to avoid flicker caused by edge conditions in the numbers.
horizontalScrollBar->setVisible (hBarVisible);
verticalScrollBar->setVisible (vBarVisible);
if (hBarVisible)
contentArea.setHeight (getHeight() - scrollbarWidth);

contentHolder->setBounds (contentArea);
contentHolder->setBounds (contentArea);

const Rectangle<int> visibleArea (visibleOrigin.getX(), visibleOrigin.getY(),
jmin (contentComp->getWidth() - visibleOrigin.getX(), contentArea.getWidth()),
jmin (contentComp->getHeight() - visibleOrigin.getY(), contentArea.getHeight()));
Rectangle<int> contentBounds;
if (contentComp != 0)
contentBounds = contentComp->getBounds();

if (lastVisibleArea != visibleArea)
{
lastVisibleArea = visibleArea;
visibleAreaChanged (visibleArea.getX(), visibleArea.getY(), visibleArea.getWidth(), visibleArea.getHeight());
}
const Point<int> visibleOrigin (-contentBounds.getPosition());

horizontalScrollBar->handleUpdateNowIfNeeded();
verticalScrollBar->handleUpdateNowIfNeeded();
if (hBarVisible)
{
horizontalScrollBar->setBounds (0, contentArea.getHeight(), contentArea.getWidth(), scrollbarWidth);
horizontalScrollBar->setRangeLimits (0.0, contentBounds.getWidth());
horizontalScrollBar->setCurrentRange (visibleOrigin.getX(), contentArea.getWidth());
horizontalScrollBar->setSingleStepSize (singleStepX);
}
else

if (vBarVisible)
{
horizontalScrollBar->setVisible (hBarVisible);
verticalScrollBar->setVisible (vBarVisible);
verticalScrollBar->setBounds (contentArea.getWidth(), 0, scrollbarWidth, contentArea.getHeight());
verticalScrollBar->setRangeLimits (0.0, contentBounds.getHeight());
verticalScrollBar->setCurrentRange (visibleOrigin.getY(), contentArea.getHeight());
verticalScrollBar->setSingleStepSize (singleStepY);
}

// Force the visibility *after* setting the ranges to avoid flicker caused by edge conditions in the numbers.
horizontalScrollBar->setVisible (hBarVisible);
verticalScrollBar->setVisible (vBarVisible);

const Rectangle<int> visibleArea (visibleOrigin.getX(), visibleOrigin.getY(),
jmin (contentBounds.getWidth() - visibleOrigin.getX(), contentArea.getWidth()),
jmin (contentBounds.getHeight() - visibleOrigin.getY(), contentArea.getHeight()));

if (lastVisibleArea != visibleArea)
{
lastVisibleArea = visibleArea;
visibleAreaChanged (visibleArea.getX(), visibleArea.getY(), visibleArea.getWidth(), visibleArea.getHeight());
}

horizontalScrollBar->handleUpdateNowIfNeeded();
verticalScrollBar->handleUpdateNowIfNeeded();
}

void Viewport::setSingleStepSizes (const int stepX, const int stepY)
@@ -91085,9 +91081,6 @@ void RectangleList::subtract (const Rectangle<int>& rect)
}
}
}

if (rects.size() > originalNumRects + 10)
consolidate();
}
}



+ 49
- 53
src/gui/components/layout/juce_Viewport.cpp View File

@@ -94,12 +94,12 @@ void Viewport::setViewedComponent (Component* const newViewedComponent)
int Viewport::getMaximumVisibleWidth() const
{
return jmax (0, getWidth() - (verticalScrollBar->isVisible() ? getScrollBarThickness() : 0));
return contentHolder->getWidth();
}
int Viewport::getMaximumVisibleHeight() const
{
return jmax (0, getHeight() - (horizontalScrollBar->isVisible() ? getScrollBarThickness() : 0));
return contentHolder->getHeight();
}
void Viewport::setViewPosition (const int xPixelsOffset, const int yPixelsOffset)
@@ -181,27 +181,12 @@ void Viewport::updateVisibleArea()
bool hBarVisible = canShowHBar && ! horizontalScrollBar->autoHides();
bool vBarVisible = canShowVBar && ! horizontalScrollBar->autoHides();
if (contentComp != 0)
{
Rectangle<int> contentArea (getLocalBounds());
if (! contentArea.contains (contentComp->getBounds()))
{
hBarVisible = canShowHBar && (hBarVisible || contentComp->getX() < 0 || contentComp->getRight() > contentArea.getWidth());
vBarVisible = canShowVBar && (vBarVisible || contentComp->getY() < 0 || contentComp->getBottom() > contentArea.getHeight());
if (vBarVisible)
contentArea.setWidth (getWidth() - scrollbarWidth);
if (hBarVisible)
contentArea.setHeight (getHeight() - scrollbarWidth);
Rectangle<int> contentArea (getLocalBounds());
if (! contentArea.contains (contentComp->getBounds()))
{
hBarVisible = canShowHBar && (hBarVisible || contentComp->getRight() > contentArea.getWidth());
vBarVisible = canShowVBar && (vBarVisible || contentComp->getBottom() > contentArea.getHeight());
}
}
if (contentComp != 0 && ! contentArea.contains (contentComp->getBounds()))
{
hBarVisible = canShowHBar && (hBarVisible || contentComp->getX() < 0 || contentComp->getRight() > contentArea.getWidth());
vBarVisible = canShowVBar && (vBarVisible || contentComp->getY() < 0 || contentComp->getBottom() > contentArea.getHeight());
if (vBarVisible)
contentArea.setWidth (getWidth() - scrollbarWidth);
@@ -209,48 +194,59 @@ void Viewport::updateVisibleArea()
if (hBarVisible)
contentArea.setHeight (getHeight() - scrollbarWidth);
const Point<int> visibleOrigin (-contentComp->getPosition());
if (hBarVisible)
if (! contentArea.contains (contentComp->getBounds()))
{
horizontalScrollBar->setBounds (0, contentArea.getHeight(), contentArea.getWidth(), scrollbarWidth);
horizontalScrollBar->setRangeLimits (0.0, contentComp->getWidth());
horizontalScrollBar->setCurrentRange (visibleOrigin.getX(), contentArea.getWidth());
horizontalScrollBar->setSingleStepSize (singleStepX);
hBarVisible = canShowHBar && (hBarVisible || contentComp->getRight() > contentArea.getWidth());
vBarVisible = canShowVBar && (vBarVisible || contentComp->getBottom() > contentArea.getHeight());
}
}
if (vBarVisible)
{
verticalScrollBar->setBounds (contentArea.getWidth(), 0, scrollbarWidth, contentArea.getHeight());
verticalScrollBar->setRangeLimits (0.0, contentComp->getHeight());
verticalScrollBar->setCurrentRange (visibleOrigin.getY(), contentArea.getHeight());
verticalScrollBar->setSingleStepSize (singleStepY);
}
if (vBarVisible)
contentArea.setWidth (getWidth() - scrollbarWidth);
// Force the visibility *after* setting the ranges to avoid flicker caused by edge conditions in the numbers.
horizontalScrollBar->setVisible (hBarVisible);
verticalScrollBar->setVisible (vBarVisible);
if (hBarVisible)
contentArea.setHeight (getHeight() - scrollbarWidth);
contentHolder->setBounds (contentArea);
contentHolder->setBounds (contentArea);
const Rectangle<int> visibleArea (visibleOrigin.getX(), visibleOrigin.getY(),
jmin (contentComp->getWidth() - visibleOrigin.getX(), contentArea.getWidth()),
jmin (contentComp->getHeight() - visibleOrigin.getY(), contentArea.getHeight()));
Rectangle<int> contentBounds;
if (contentComp != 0)
contentBounds = contentComp->getBounds();
if (lastVisibleArea != visibleArea)
{
lastVisibleArea = visibleArea;
visibleAreaChanged (visibleArea.getX(), visibleArea.getY(), visibleArea.getWidth(), visibleArea.getHeight());
}
const Point<int> visibleOrigin (-contentBounds.getPosition());
horizontalScrollBar->handleUpdateNowIfNeeded();
verticalScrollBar->handleUpdateNowIfNeeded();
if (hBarVisible)
{
horizontalScrollBar->setBounds (0, contentArea.getHeight(), contentArea.getWidth(), scrollbarWidth);
horizontalScrollBar->setRangeLimits (0.0, contentBounds.getWidth());
horizontalScrollBar->setCurrentRange (visibleOrigin.getX(), contentArea.getWidth());
horizontalScrollBar->setSingleStepSize (singleStepX);
}
else
if (vBarVisible)
{
horizontalScrollBar->setVisible (hBarVisible);
verticalScrollBar->setVisible (vBarVisible);
verticalScrollBar->setBounds (contentArea.getWidth(), 0, scrollbarWidth, contentArea.getHeight());
verticalScrollBar->setRangeLimits (0.0, contentBounds.getHeight());
verticalScrollBar->setCurrentRange (visibleOrigin.getY(), contentArea.getHeight());
verticalScrollBar->setSingleStepSize (singleStepY);
}
// Force the visibility *after* setting the ranges to avoid flicker caused by edge conditions in the numbers.
horizontalScrollBar->setVisible (hBarVisible);
verticalScrollBar->setVisible (vBarVisible);
const Rectangle<int> visibleArea (visibleOrigin.getX(), visibleOrigin.getY(),
jmin (contentBounds.getWidth() - visibleOrigin.getX(), contentArea.getWidth()),
jmin (contentBounds.getHeight() - visibleOrigin.getY(), contentArea.getHeight()));
if (lastVisibleArea != visibleArea)
{
lastVisibleArea = visibleArea;
visibleAreaChanged (visibleArea.getX(), visibleArea.getY(), visibleArea.getWidth(), visibleArea.getHeight());
}
horizontalScrollBar->handleUpdateNowIfNeeded();
verticalScrollBar->handleUpdateNowIfNeeded();
}
//==============================================================================


+ 0
- 3
src/gui/graphics/geometry/juce_RectangleList.cpp View File

@@ -260,9 +260,6 @@ void RectangleList::subtract (const Rectangle<int>& rect)
}
}
}
if (rects.size() > originalNumRects + 10)
consolidate();
}
}


Loading…
Cancel
Save