Bug: Incorrect FillType rendering under Direct2D

Hi, I’ve run into a pretty strange bug when using g.setFillType(fillType) in conjunction with fillType’s transform member.

In certain DAWs, applying a certain AffineTransforms to FillType::transform and then using that FillType for a Graphics context results in the fill being placed incorrectly. It seems to vary based on the position of the component being drawn into - it always draws correctly if the component is at 0,0, but not anywhere else.

I’ve observed the bug in Live and Pro Tools. It does not occur in a standlone app, nor in Reaper, Cubase, and Studio One. Weirdly, changing the Display Scaling on my machine (100% up through 200%) doesn’t change the result in the misbehaving DAWs.

Here’s a screenshot of what I expect to see when using a gradient for the FillType, taken in Cubase (with a scale() transform applied to stretch the x-axis and squish the y-axis of the fill):

And here’s what happens in e.g. Live:

This only happens when using the Direct2D renderer on Window - no issue on Mac, nor when forcing the plugin to use the software renderer on Windows. FillTypes containing Image and ColourGradient are affected.

Perhaps one clue is that the “Hello World” is rendered much crisper in the “behaving” instance (seemingly HiDPI), whereas it’s fuzzier in the “misbehaving” instance (seemingly not HiDPI). So perhaps Direct2D is not accounting for some scale factor properly?

Here are the files for a minimal example:

RadialComp.h (1014 Bytes)

PluginEditor.h (750 Bytes)

PluginEditor.cpp (1.1 KB)

2 Likes

Oh, some additional context I should have added:

  • AffineTransform::scale() and AffineTransform::rotation() seem broken, but AffineTransform::translation() does not.
  • Setting the “behaving” DAW executable’s “Properties” → “Compatibility” →”Change HiDPI Settings” to be overridden with the “System” option causes the bug to appear. Which IMO further points at some HiDPI / scaling issue.
1 Like

Hey JUCE team, any chance to look into the above issue?

I was just about to post this. A fix has been released on develop. Thank you for reporting this and for the helpful repro project as well.

4 Likes

Thanks @attila ! I can confirm the fix works on my end.