Clipped DropShadow render issue using J8 Direct2D

While comparing the ‘DropShadow for Paths’ rendering on macOS and Windows I found an edge case in the D2D Renderer that leads to a visible line where Shadows should fade out. I guess this is another one for @matt . Feels like it’s an edge case related to non-int coordinates from scaling for images and clipping.

Using this code I see a faint line where the top shadow should fade out.
This only happens for specific offsets (this -11) and scaling factors and doesn’t happen if the shadow isn’t clipped:

void MainComponent::paint (juce::Graphics& g)
{
    g.fillAll (juce::Colours::grey);

	juce::DropShadow ds(juce::Colours::black.withAlpha(0.7f), 10, {1, 2});

    // Top (clipped)
	juce::Path p3;
	p3.addRectangle(juce::Rectangle<int>{0, -11, getWidth(), 10});
	ds.drawForPath(g, p3);

    // Left
	ds.drawForRectangle(g, {80, 80, 40, 40});

    // Middle
	juce::Path p;
	p.addRectangle(juce::Rectangle<int>(160, 80, 40, 40));
	ds.drawForPath(g, p);

    // Right
	juce::Path p2;
	p2.addEllipse(juce::Rectangle<float>(240, 80, 40, 40));
	ds.drawForPath(g, p2);
}

This happens on the latest 8.0.6 develop. This is with Windows Scaling 150%

And 200%

The same code renders correctly with Windows scaling set to 125% or 100%.

OK. I’m going to be traveling for bit; I’ll check it out when I can.

Matt

I think the problem is that the blur/shadow image is rendered at the logical pixel size, and then scaled up. Rendering the blur directly at the final screen scale seems to fix the problem. I’ve got a fix on the way.

1 Like

There’s a fix for this issue available on the develop branch: