MacOS drawing on 2x screen super slow?

if you put this in a Window Paint event:

Dim p As New Picture( 256, 256, 32 )
p.Graphics.ForeColor = CMY(Rnd,Rnd,Rnd)
p.Graphics.FillOval 0,0,256,256
Dim t As Double = Microseconds

For x As Integer = 1 To 20
For y As Integer = 1 To 20
g.DrawPicture p, x*10,y*10
Next
Next
t = (Microseconds-t) / 1000000

Self.Title = Str(t)

Resize the window on a laptop screen and then do it on external monitor.

On my laptop screen( 2x) it’s a lot slower than on an external thats 1x
I’m seeing up to about 30x slower

Anyone else seeing this ?

Nope. Roughly same speed on either display. Of course, my external display has roughly the same resolution as my Retina laptop (3440x1440 vs 2880x1800). Time averaged around 0.002 seconds.

what does the title in the window say ?
drag it from one to the other
are both 1x or 2x or do they vary ?
here I see as much as a 30x difference (1x way faster)

First up on a Retina display you’re using bi-linear or bi-cubic scaling (I forget which one exactly).

Recommendations:

  1. use window.bitmapforcaching to get a pixel perfect image on the first line.
  2. graphics.antialias = false, draw picture, re-enable.
  3. Use CoreGraphics declares to disable the high quality scaling of images.

We talked about improvements with images on this thread Efficient Canvas Drawing

On my iMac27" it takes 3.36 seconds. 5120x2880 Retina
If I drag the window to my 19" screen it take 0.10 seconds 1280x1024 NonRetina

30 x slower on retina :frowning:

This wasnt to try and figure out how to optimize it just “is it really this much slower on retina?”

there’s at least 4x as many pixelsin a retina screen with a windows of the same size
but I sure wouldnt expect 30x difference which is what I see

[1000000](tel:1000000)

what is that?
I changed it to just 1000000

OH… this forum thought is was a PHONE#?

I guess ???

Because it’s a not a fair comparison.

The problem is that the code is drawing a 1x image on a 2x screen, by default this incurs up-scaling, which incurs resampling.

A fair test would be to replace

Dim p as new Picture

with

Dim p as new picture = window.bitmapForCaching( 256, 256 )

Then no up-scaling would take place on either.

How do you get the forum to format Xojo code?

with 3 back quotes ( the one under the tilde)
then “xojo”
write your code
close with 3 back quotes

that said you think the upsample would make it 30x slower?

edit : apparently it does
2x is still slower but its close to 4x which isnt unreasonable given there are 4x as many pixels

1 Like

Yeah sorry I hadnt noticed that in what I posted