Graphics, ComponentPeer, LowLevel... changes

I’d like to write code like this:

void MyComponent::paint (Graphics& g)
{
  LowLevelGraphicsSoftwareRenderer* ren = dynamic_cast <LowLevelGraphicsSoftwareRenderer*>
    (&g.getInternalContext ());
  jassert (ren != nullptr);
}

For this to work, it needs to be possible to customize from within the ComponentPeer. It looks like ComponentPeer::handlePaint() has something like this but it seems only active for windows:

juce_win32_Windowing.cpp

ScopedPointer<LowLevelGraphicsContext> context (component.getLookAndFeel()
  .createGraphicsContext (offscreenImage, Point<int> (-x, -y), contextClip));

I’d like to be able to control the creation of the low level graphics context on all platforms, for my ComponentPeer. This way I can guarantee that it always uses the LowLevelGraphicsSoftwareRenderer.

Next, I’d like to be able to get the Image from a LowLevelGraphicsSoftwareRenderer. We need this function:

juce_LowLevelGraphicsSoftwareRenderer.h

Image getImage () { return savedState->image; }

If you don’t want LowLevelGraphicsSoftwareRenderer exposing the image, then let us subclass LowLevelGraphicsSoftwareRenderer so we can provide a function that does.

Haven’t enough brain capacity to think about this, but if you fire some suggested changes at me, I’ll see if they look ok…

Well actually…it looks like LookAndFeel has the necessary createGraphicsContext function. I thought it was missing from Mac but it was just that Visual Studio wasn’t looking into .mm sources when I do a Find in Files (since they aren’t part of the Visual Studio project).