I want to do some drawing optimation using the following pattern:
class MyComponent : public Component
{
public:
/*
...
*/
Rectangle clipA, clipB; // WITH EMPTY INTERSECTION
void repaintAandB()
{
repaint(clipA.getX(), clipA.getY(), clipA.getWidth(), clipA.getHeight());
repaint(clipB.getX(), clipB.getY(), clipB.getWidth(), clipB.getHeight());
}
bool needsFullPaint(Graphics& g, bool doQuick = true)
{
const RectangleList rl(g.getClipRegion()); // !!!!!!!! ERROR !!!!!!!!
// => 'getClipRegion' : is not a member of 'juce::Graphics'
if (doQuick)
{
RectangleList::Iterator it(rl);
while (it.next())
{
const Rectangle *rect = it.getRectangle();
if (*rect != clipA && *rect != clipB)
return true;
}
return false;
}
else
{
RectangleList rlc = rl;
rlc.subtract(clipA);
rlc.subtract(clipB);
return !rlc.isEmpty();
}
}
void paint (Graphics& g)
{
if (needsFullPaint(g))
{
// ...
}
// ...
}
};
The method getClipRegion has been mentioned several times before in this forum, but it doesn’t exist anymore in the current juce version (Allthough it still is mentioned in the documentation at Graphics::getClipBounds). getClipBounds is not usable for this purpose as it gives the enclosing Rectangle. To use clipRegionIntersects would be quite cumbersome and reduceClipRegion would change the clipping region. I think this is a very common task, am I missing something?
Thanx for any help.
Jan