"Trail" bug when using setBufferedToImage and transforms

In this screenshot of the JUCE demo*, the leftmost slider looks wrong:


To make it happen I just enabled s->setBufferedToImage (true); for that slider, then ran the demo and played with the transform and this slider. In small transforms it happens.

I think that this happens due to this piece of code in juce_Component.cpp:

Graphics imG (image);
LowLevelGraphicsContext& lg = imG.getInternalContext();

lg.addTransform (AffineTransform::scale (scale));

for (const Rectangle<int>* i = validArea.begin(), * const e = validArea.end(); i != e; ++i)
    lg.excludeClipRectangle (*i);

if (! owner.isOpaque())
{
    lg.setFill (Colours::transparentBlack);
    lg.fillRect (imageBounds, true);
    lg.setFill (Colours::black);
}

owner.paintEntireComponent (imG, true);

The lg.fillRect (imageBounds, true); part is performed after lg.addTransform (AffineTransform::scale (scale)); which changes lg's coordinates from image-based to component-based.

It seems that changing it to lg.fillRect (compBounds, true); fixes this bug.

Cheers, Yair

1 Like

Sorry that this took so long and thank you for your fix. It’s on develop now.

1 Like