Retina display support & QCView?

douglasheriot's picture

So, I’ve got my nice new retina display MacBook Pro, and an app I’ve created that displays timers, using a quartz composition in a QCView. However, it appears pixelated as it doesn’t render at HiDPI resolution. (see screenshot)

Normally it’d be displayed on a projector so it’s not a huge issue (I don’t ever see ‘retina display’ projectors ever coming out soon), but it’s a bit disappointing it doesn’t look any good on my MacBook’s display.

The Quartz Composer application itself doesn’t preview compositions in HiDPI mode either, but I don’t expect there’s much we can do about that for now. Is there anything I can do in my application to make the QCView render at a higher resolution?

PreviewAttachmentSize
Screen Shot 2012-07-08 at 4.48.17 PM.png
Screen Shot 2012-07-08 at 4.48.17 PM.png18.03 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

gtoledo3's picture
Re: Retina display support & QCView?

This is because of the rasterization scale of the QCView defaulting to 1. That said, I'm not sure how to control that with QCView... I'm not sure if there's a method for it.

I think if I was in your scenario I'd investigate QCCompositionLayer since it inherits from CAOpenGLLayer, which may be able to control the rasterization level (?).

dust's picture
Re: Retina display support & QCView?

i don't have a retina display so you will have to try this out yourself. a qcview inherits from nsview and a nsview is ca layer backed so you should be able to set the content scale factor of the a qc view the same way you would on an iPhone....

[qcView.layer setContentsScale:NSScreen+mainScreen]+backingScaleFactor;

if that fails you could try the same thing on a view containing a qc view like....

[view.layer setContentsScale:NSScreen+mainScreen]+backingScaleFactor;

if that fails than I'm sure you would be able to do something with a ca quartz layer like george mentioned or roll your own view with a qc renderer and set the scale manually by passing the the gl context into a CG routine. also

you could make a simple qc plugin that returns the backing scale of the screen.

[[NSScreen mainScreen] backingScaleFactor]

with this info you could do some logic inside of qc with a math patch and a render dimensions patch attached to a render in image patch or image resized or something. the logic would be something like if backingScaleFactor greater than one multiply the width and height by 2 or something similar using the aspect ratio.

let me know if you figure it out i would like to know.

douglasheriot's picture
Re: Retina display support & QCView?

I got it to work!

Firstly, NSViews (and also QCViews) aren’t layer backed by default on OS X (unlike iOS, where everything is). Originally, my QCView was not layer-backed, so modifying the layer’s properties wouldn’t make any sense.

As soon as I turned on setWantsLayer:YES (by clicking the checkbox in Interface Builder), it worked in retina resolution automatically!

The render destination dimensions patch correctly returns the real number of pixels at the backing scale (eg. 2880x1800 if it’s full screen in my app). However, if moved onto another regular display, it continues to render at the full retina resolution.

QCCompositionLayer behaves slightly differently. It will only display in retina resolution if you explicitly set its contentScaleFactor (like self.qcCompositionLayerView.layer.contentsScale = self.qcCompositionLayerView.window.backingScaleFactor;) As you may guess, this also doesn’t automatically change itself when moving between displays.

While I was investigating this, I ran into a few really annoying bugs – I’ll have more to say about that later. (Are there known issues with multiple QCViews in the same app? – they seem to be getting their dimensions continually mixed up? – really weird) You can see my sample project here: (not complete) https://github.com/DouglasHeriot/RetinaQC

gtoledo3's picture
Re: Retina display support & QCView?

THAT IS GREAT!

Thanks for the rundown - I haven't been able to get a machine to test with, and haven't waded into those changes yet. That's slick and simple.

I've used multiple QCViews in an app before, but only once, and they were in different windows. In general, QCView is the highly abstracted (eg., you don't have as much to setup), so it's the biggest p.i.t.a when it comes to little bugs and when you need to dive down "lower" to more specific control.

W/ QCCompositionLayer, there is probably some way of telling if the current monitor is Retina or not, and then controlling the scaling factor accordingly. There's probably more talk about this on the Core Animation and Cocoa developer lists (or docs @ Apple), in reference to CALayer, but the techniques likely will be the same.

(As an aside, the retina macbooks may be able to runs lots of desktops, but it sure is easy to make them fart out. I spent a little time on one and the gpu seems like seriously weak sauce. Non-QC tests too.)

franz's picture
Re: Retina display support & QCView?

OT: Am I the only one not enthusiastic at all about this massive resolution ?

2800*1800 pixels just for the desktop with a 1GB VRAM gfx card ? nah ... there's not much left for my DVI output...

gtoledo3's picture
Re: Retina display support & QCView?

You're not alone. I question the concept greatly, though I like the superficial results from viewing stuff that only has to deal with still texture. It feels like a tremendous hack, and like the gpu's and slim lining are at odds with the toll the high resolution exacts on the system. Then, allowing it to run more external monitors... It seems pretty pro-sumer.

dust's picture
Re: Retina display support & QCView?

great you got it working. that is defiantly wierd your render dimensions are not changing from screen to screen and neither is your scale factor ? there has to be a way... maybe pass in your render dimensions via a published input instead of using the render dimensions patch inside qc. that way you could get your screen or window frame size and use it possibly.