I haven’t look into the details yet, but it looks like my blur module’s shadows aren’t happy on JUCE 8 Direct2D. It looks like maybe when compositing from single color to rgba, it’s painting the color at full opacity vs. using the opacity values in the single color image…
OK, here’s something strange. All of my tests are failing locally, it seems like part of the reason is that Image#getPixelAt is always returning transparent black. For example, this fails:
juce::Image result (juce::Image::ARGB, 9, 9, true);
juce::Graphics g (result);
g.fillAll (juce::Colours::white);
jassert (result.getPixelAt (2, 2).toDisplayString (true) == "FFFFFFFF");
The behavior of the Graphics object for the D2D and OpenGL renderers is that the image is not completely written/flushed intil the Graphics object goes out of scope. The example you provided should work if you add a scope around the Graphics object. If that’s still broken, please let us know.
juce::Image result (juce::Image::ARGB, 9, 9, true);
{
juce::Graphics g (result);
g.fillAll (juce::Colours::white);
}
jassert (result.getPixelAt (2, 2).toDisplayString (true) == "FFFFFFFF");
This has come up at least once in the past, so we should probably update the docs to make this a bit clearer.
It doesn’t look like there’s another way to sync/flush, so I’ll go restructure my tests and see what I run into next!
Documenting sounds useful. Maybe it could be part of the general JUCE 8 release notes / docs too. I tried to poke around to see if i could disable Direct2D (JUCE_DIRECT2D=0) and use the old renderer on JUCE 8, but it seems like that isn’t possible?
I’m pretty sure this is esoterica — sizes of the default font differ slightly between versions and the text size was almost at the limit of not being painted on JUCE 7. For example if I g.setFont(g.getCurrentFont().withHeight(16)); on JUCE 7, I also get a blank image.
Maybe there should be an assertion here vs. just the empty image? But worst case someone, someday will get value from this…
Even though this project really exercises juce::Graphics and friends, upgrading to JUCE 8 was relatively painless, much more so than other frameworks I’ve used in the past.
As @fuo pointed out, you can switch the renderer for a window by calling setCurrentRenderingEngine. I usually set the renderer from the parentHierarchyChanged callback; here’s an example.
Note that this will only set the renderer for the current window. If you are rendering to an Image, you will still be using Direct2D by default unless you explicitly specify a software image.
@matt, it would be useful to have a convertedToType Image method to convert from one type to another.
This would for example let us use the native renderer to capture a component (as the differences in font rendering are pretty visible between the Direct2D and software renderers, especially for small fonts), and then convert it to software for further manipulations (eg animated fading, etc).
Thanks! Matt and I chatted yesterday about exactly this option, as in this case it’s literally CPU blurring (we were discussing maybe geeking out over GPU backed mela blurs too, though!). I might leave the scope in the tests since speed isn’t essential there, but i’ll prob have to switch to software backed for the single channel shadow images. I’m curious on the benchmark difference…