Suggestion: Renderers need to know where they're drawing


As we discussed in this topic:

Subpixel rendering needs to know the pixel orientation of the monitor it is rendering to. I've got all other code set up for this, so that i know what monitors is what configuration etc., only thing is: LowLevelSoftwareRenderers don't know where they are drawing, beyond an offset to an arbitrary image. This means it cannot identify what pixel setting it should use, account for screen rotations/resolutions and so on.

Also, another thing that would be nice is, if the renderer knows whether it is rendering to a screen context or an image (similarly to isVectorDevice()).

Jules, how do you propose one solves this problem? 

One solution, without breaking anything, would be to add something like:

virtual juce::LowLevelGraphicsContext * LookAndFeel::createGraphicsContextAdvanced(
    const Image & buffer, const Point<int> origin, const RectangleList<int> clip, bool isScreenContext, const Point<int> componentPosition)
    // default implementation just forwards:
    return createGraphicsContext(buffer, origin, clip);

Such that you can override this if you can use the additional information. All the normal places that would create a graphics context (like paint handlers) would now call this instead. I realize that this is really crippling the abstraction, but if you want to optimize rendering per-display you'll need something like this sooner or later.. 


Also, another thing: Would it be possible to listen to system notifications related to screen resolution/resizing etc? Currently, they get dumped into Desktop::Displays::refresh(). If Displays could have a listener interface, that would be sweet.



Retina/non Retina detection & several displays

Hi Mayae, unfortunately I can't help with you're problem specifically, but would you care to share how you are checking the monitor information? I need to find out if the monitor my GUI is being shown on is retina or not :)


The code is still WIP on osx. You can find some examples in the zip i posted in the op of this topic:


For checking if a screen is retina-like, I suppose something like this would work:

bool isScreenScaled = juce::Desktop::getInstance().getDisplays().getDisplayContaining(<WHERE YOU WANT TO RENDER>).scale != 1;

If you need to get in-depth information about monitors on OSX, you will need to iterate [NSSCreen screens] and get a dictionary out of them. For specific components, I'm pretty sure you can just use Component::getDesktopScaleFactor()?


However, you cannot do this yet unless jules implements the change i suggested in the OP - because renderers do not know their position on the screen. Unless - if you're doing this inside your paint() or similar method, then just use topLeftPosition of the last parent of your component!


Yes, sounds like these would need to become properties of the low level context object - adding a virtual method to ask whether it has a sub-pixel ordering or not would be the thing to do.