This recent commit breaks drop shadows drawn for a path and NativeImageType drawing on external monitors under specific conditions:
Here is the code I am using to test:
TestUIAudioProcessorEditor::TestUIAudioProcessorEditor (TestUIAudioProcessor& p)
: AudioProcessorEditor (&p), audioProcessor (p)
{
myImage = juce::Image(juce::Image::PixelFormat::ARGB, 5, 5, true, juce::NativeImageType{});
for (int i = 0; i < 5; ++i)
for (int j = 0; j < 5; ++j)
myImage.setPixelAt(i, j, juce::Colours::red);
dropShadow.colour = juce::Colours::transparentBlack.withAlpha(0.5f);
dropShadow.radius = 20;
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 300);
}
TestUIAudioProcessorEditor::~TestUIAudioProcessorEditor()
{
}
//==============================================================================
void TestUIAudioProcessorEditor::paint (juce::Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));
g.drawImage(myImage, juce::Rectangle<float>{ 0.f, 0.f, 5.f, 5.f});
juce::Path p;
p.addRoundedRectangle(getBounds().reduced(10), 10.f);
dropShadow.drawForPath(g, p);
}
void TestUIAudioProcessorEditor::resized()
{
}
The conditions to cause the problem:
- Laptop with external monitor. Both screens are active.
- Start the Standalone such when it opens it does so on the external monitor e.g. run it once, move it to the external monitor then close.
- The next time the Standalone opens this assert is hit: JUCE/modules/juce_graphics/native/juce_Direct2DGraphicsContext_windows.cpp at e2b9dd9a053b6b2bc0bed02a6b67de637324d80c · juce-framework/JUCE · GitHub
- Now, change the image type to
juce::SoftwareImageTypeand run again. - This time, the assert is not hit. However, the dropshadow is a solid rectangle. It does not fade around the edges.
- If you change the drop shadow to
drawForRectanglethen things seem to work fine.
Before this commit the assert is not hit and the drop shadow renders just fine.
With this commit, everything is fine if the UI opens on the laptop and is then moved to the external monitor. It is also fine if the laptop screen is closed and the Standalone opens on the external monitor.
Let me know if you need more details
