Pre-rendering to Image and retina displays


#1

I’m using ImageCache to save some complex widgets as images to improve rendering time.

I do …

image = ImageCache::get...
if (!image.isValid())
{
... render
... save to cache
    g.drawImageAt(newImage, 0, 0);
}
else
{
  g.drawImageAt(image, 0, 0);
}

But this isn’t good if you have a retina display. What’s the right approach to cope with non-unity values from getPhysicalPixelScaleFactor()?


#2

If you create a component and use its setBufferedToImage, then it’ll take care of getting the resolution right.


#3

Mmm, it’s not quite as simple as that, I’ve got a zillion of these little components many of which are showing the same image. Caching just the one component isn’t getting the speed up! I’ll look at what that function does tho maybe…


#4

Yeah - cheers Jules, StandardCachedComponentImage looks like it has the magic spell needed…


#5

Whahaha - this is harder than it ought to be without buying a retina display … just discovered it down renders with tiny images … maybe I need to apply another transform here somewhere :slight_smile:


#6

What happens if a component is displayed across two displays?


#7

IME on mac it will switch at some point while you are dragging, you can see it on the other display with an alpha applied either up or down scaled accordingly then it will switch the display resolution and switch which side of the window has no alpha and which side has an alpha applied - in other words the OS handles this for you and you will only ever have one display resolution at a time (I believe). Unless there is some way to enable it there is no way to actually display the plug-in across two monitors, once you release from dragging the window, it will only show the part of the window that is displayed on the screen the resolution is applicable to. If you are not already use Quartz Debug to simulate a retina display.


#8

That’s a great plan. I forgot that even existed.


#9

IIRC on Mac you can also simulate a retina monitor using the regular System Preferences: just open the Monitor settings and choose whatever HiDPI resolution appears in the list that shows when you don’t choose to use the default resolution for the monitor.


#10

I think I had to use Quartz Debug in order to add that mode initially.


#11

For me, it worked out of the box, never used Quartz Debug (did not even know of its existence, honestly :grin: )