| Sign In/My Account | View Cart |
| Article: |
Graphical Composition in Avalon | |
| Subject: | macos x already works like this | |
| Date: | 2004-03-09 13:14:57 | |
| From: | zootbobbalu | |
|
Response to: macos x already works like this
|
||
|
I'm not a Quartz expert, but you have to admit that your article is void of any mention of Quartz. For someone that claims to have developed with Quartz, I find it odd that you were so displeased with Quartz you came to the conclusion that a six-year wait for a technology to do your work is not that big of a deal.
|
||
Showing messages 1 through 28 of 28.
0 setgray
/Times-Italic 50 selectfont
50 150 moveto (This is an example of Quartz transparency!) show
1 0 0 setrgbcolor
.5 setalpha
100 100 200 200 rectfill
1. Application that provides smooth zoom
Just modify your NSImageView a tiny little bit. Add a class BetterNSImageView with an instance variable id pdfImageRep.
To this add the following two methods:
-(void)drawRect:(NSRect)r
{
if ( pdfImageRep ) {
[pdfImageRep drawInRect:r];
} else {
[super drawRect:r];
}
}
-(void)setImage:(NSImage*)anImage
{
[anImage setDataRetained:YES];
pdfImageRep=[[[anImage representations]
lastObject] retain];
[super setImage:anImage];
}
(This code will leak the image-rep, but that's OK for us here)
The clou here is drawing the PDF directly, instead of recaching an NSImage each time around. That makes things significantly faster. I haven't put in the code that takes care of keeping the aspect ratio the same, this doesn't affect the speed and is left as an exercise for the reader.
This redraws interactively on my dual 1 GHz G4 and my 867 MHz 12" PowerBook, though it is a bit more sluggish on the PowerBook. Or, to put numbers on that, add the following trivial "benchmark" code:
-(void)doScaleBench:sender
{
int i;
NSWindow* win=[self window];
NSRect r=[win frame];
NSLog(@"start %@",[NSDate date]);
for (i=0;i<10 ;i++) {
r.size.width++;
r.size.height++;
[win setFrame:r display:YES];
}
NSLog(@"stop %@",[NSDate date]);
}
Hook that up to a menu item in Interface Builder.
On my 867MHz 12" PowerBook, that yields between 7.41 redraws/s for a complex PDF with a full page of text and 17.2 redraws a second for a simple PDF with a couple of shapes and a small amount of text. A full page of text being rescaled is very rough, because text is expensive to render and you aren't getting much use out of the text cache.
On the 1 GHz G4, we get 12.5 and 31 redraws / second, respectively. A current model G5 should be more than twice as fast, and I wonder what will be available by the time Longhorn/Avalon ships. But it's always surprised me how much faster Safari is on my 12" PowerBook than the 1.4 GHz Dell I have at work. Apart from looking incomparably better...
2. "wether mac os x has a [retained vector] mechanism like this"
*double cough* This is from the start of my first post to this thread:
"The fact is that Mac OS X already *does* work mostly like this, except for retained vectors"
To which you replied:
"But my point is that the retained vectors are crucial."
'nuff said.
3. Quartz compositor hypotheses
Just complete bollocks. Completely unrelated. Apart from being untrue, this is still bitmaps being drawn with Quartz 2D, not stuff that is turning into bitmaps as a result of the Quartz compositor, which has nothing to do with that at all.
4. OpenGL + QuickTime + Quartz
5. Diffuse worries
OK, so you had bad experiences with Windows drawing APIs that just didn't work as advertised. Yes, that is also what I heard. Especially the transition from the initial GDI to the one that supported a "Postscript-like" imaging model, with arbitrary affine transformations. I remember thinking to myself "hey, this does all I need", but then hearing that, in fact, it doesn't actually work. However, I never tried it myself, but you seem to corroborate this.
This is also where I get confused as to which Windows API is which. I remember that the original GDI did not support arbitrary (affine) transformations, or bezier-based paths. Did it support path-based clipping? The API that followed was very closely modelled after the Postscript imaging model, but that was the one that didn't really work as advertised, at least initially. Was that GDI+? I seem to be getting conflicting messages on that. You seem to say that GDI+ came with XP, but that would mean there must have been an intermediate API. Was there some renaming in the meantime?
Anyway, whatever bad experience you had with Windows APIS, the good news is: Quartz Just Works(tm), as did DPS. Your worries, as applicable as they are in the Windows world, simply do not apply here. I have lots of ideas why this is the case, but these aren't really that important. What is important is that it does just work.
[Possible reasons: well-defined drawing model, with precisely specified rendering semantics; history of implementations that have always been and continue to be device-independent stretching back more than two decades; surrounding APIs that have traditionally always worked in conjunction with a fully device-independent imaging model and count on that working correctly; developers that have worked with a device-indepndent imaging model for more than a decade etc.]
6. Concrete compositing worries
Anyway, you do give one concrete reason why there were problems with Windows, which is that windows are composed of lots of smaller windows. This isn't the case with normal Quartz windows. It is only true (to a much lesser degree) when the Quartz compositor is used to combine other media-types.
However, virtually all the concrete worries you have expressed about (sub-)pixel boundaries, arbitrary scaling and so forth already apply today in exactly the same way! So either everything is as broken as you think it will be in the future today, or it won't be broken in the future either.
[Exposé as 'proof' of compositor limitations: how many more #$%!@# lame examples are you going to come up with?! Exposé is intended to give you a rough overview over your windows, not provide precise rendering. Also, if anything it is an example of limitations of GPU-based drawing...]
7. One big Quartz 2D surface
For most windows, that is exactly what it is. The only exceptions are those that explicitly include dynamic media such as QuickTime movies and OpenGL-rendered 3D graphics
.And yes, of course it is the compositor that is placing those QuickTime streams inside Quartz windows. What else? I really understand where you're getting all this from. You seem to have a profound misunderstanding of how all this works somewhere, but I am at a bit of a loss where it is.
8. "At 300 dpi, your 128x128 pixel image is now less than half an inch across."
This makes me wonder wether you understand what device-independent graphics means at all. Probably not. The same image will be precisely the same size as it was before. It will also look (almost) exactly the same. It just won't improve as much as a vector drawing will. However, most of the time those 128 x 128 icons are drawn much smaller than 1:1, and at those sizes a higer DPI display will display those icons with much finer details than possible today.
Incidentally, that applies to all the other bitmaps in the UI, for example the traffic-light close/minimize buttons. They will render just fine even at the higher resolution, they just won't benefit much from it. That is what device-independent rendering is all about. Of course, it will be trivial for Apple to provide higher-resolution bitmaps for those higher resolution displays, or vectorized versions if that is appropriate/desirable.
9. Static vs. dynamic graphics pipelines (and retained vectors)
'"As you yourself have pointed out, both speed and quality requirements are different for dynamic and static media" Actually I don't think I did say that.'
Er, yes you did. Earlier. On bitmap-stretching used by, for example, the genie effect:
"Quartz gets away with this for high-speed animations like minimization because they're over before you have a chance to see the imperfections. But it would not stand up to close sustained scrutiny. And a crummy image would completely defeat the purpose of a high-dpi display!"
So, at high speeds, you can get a way with imperfections. At low speeds, or a static display, you can't.
So once again, for 3D and video work, you have the fast 3D and video pipelines. For mostly static displays, you have the very high quality Quartz 2D pipeline (and you can mix in the other pipelines when necessary). Quartz 2D is plenty fast for 2D non-media, non-movie work, and offers precision/quality that other APIs can't match.
Also, you still haven't explained how 2D retained vectors would improve movie playback or OpenGL based 3D work. Are we going to vectorize movies on the fly? Is OpenGL going to render to a 2D vector representation? I don't think so.
10. "retained vectors" ... "may not the only possible solution" for "High DPI"
Good, we are making progress, then. However, it turns out that wether vectors are retained or not is completely irrelevant to the High DPI "problem".
Unless you are going to make the absolutely absurd claim that QuickTime movies are going to vectorized on the fly and OpenGL will render down to 2D vectors instead of bitmaps, you are still going to have to composite at least some bitmaps together when you join up these different pipelines, at some point, wether you have a retained vector representation or not. It only happens at a different point in the pipeline that is all, but the actual issues of compositing the bitmaps together remains exactly the same.
The other issue is bitmaps shoved into the graphics pipeline at the application end. Again, this has nothing to do with wether you have the ability to retain (vector) representations inside your graphics subsystem (or on the graphics card for that matter) at all. It is *solely* a matter of the applications providing vector or bitmap data. So once again, the API makes no difference whatsoever
.
(1) I thought that most developers likely to be reading a Microsoft-centric site such as ONdotnet would not be Mac developers. I don't believe that drawing comparisons of the form "This is a bit like something you've never used" are very helpful, so any comparison would only have benefited a minority of readers. If I underestimated how many readers would come to see what the other guys are doing, then I apologise for that, but I still think it would not have been useful to mention Quartz because:
(2) It's not actually that similar, so even if you are familiar with Quartz or Quartz extreme, there aren't many useful comparisons you can draw. So this reduces it to "This is quite different from this other thing." In fact for most readers, the result is "This is quite different from this other thing that you've never used," which I don't believe is very useful.
And in general, I find competitive comparisons pretty unedifying - they have an unpleasant tendency to end up in 'My OS is better than your OS' slanging matches with little to no useful content.
But since you seem to be saying that the article could have been improved through the addition of my opinion on the comparative merits, here goes: I was disappointed with Quartz mainly because it didn't seem like a great leap forward; all the hype had led me to believe it would be significantly better than where Windows is today. Layered Windows, which were introduced in Windows 2000, provide hardware composition for top level windows, and that has been around since long before Quartz Extreme. I mentioned layered windows briefly in the article, but I didn't go into much depth, because layered windows aren't that interesting - they suffer from the same set of limitations that Quartz Extreme suffers from today: they offer only bitmap based composition, and at a level that is removed from the rest of the drawing APIs. If this had been an article on layered windows, then a comparison with Quartz and Quartz Extreme would have been appropriate, because there are some very important similarities. But that's not what the article was about.
Also, GDI+, which was introduced with Windows XP in October 2001 (and which has also been available since then for installation on older versions of Windows back to NT 4.0) has offered vector-based drawing features that Mac OS X didn't catch up with until Mac OS X 10.2. Again, if this had been an article about GDI+, then a comparison with the 2D parts of Quartz [Extreme] would have been a good idea, because there are many similarities here. But again, that's not what it was about.
In short, it's pretty disingenuous to claim that Quartz Extreme is ahead of where Windows is today. (It's ahead of Windows ME, but not Windows XP.) Max OS X looks far prettier, but that has nothing to do with technology - technologically there's a fairly small difference, despite the claims made in the hype.
I can't offer a comparison between Avalon and the Mac equivalent (i.e., whatever the Mac graphics technology will be in 2006) because as far as I know, Apple haven't announced what it will be.
I don't think any of the above tells you anything more about Avalon, which is why I didn't feel it would have been a productive use of space in the main article. I thought most readers would find such comparisons completely irrelevant, and the remaining readers would have found them only barely relevant. And I didn't have any particular desire to engage in any Mac bashing, which is how I suspect this comment will come across to the Mac faithful. (It isn't intended as such - I like my Mac, despite being disappointed by Quartz, so I don't have any desire to criticize it. The above is just a dispassionate attempt to make an accuaret comparison.)
If Apple were telling us what their plans for the next generation of their graphics architecture was, then it would obviously be a different story - then there would be something useful to make comparisons with. If this information had been available to me, I would have included it in the article. But as far as I am aware, Apple haven't released any such information.
As for the "Avalon actually leapfrogs Quartz", that was in response to the wholly inaccurate "macos x already works like this" claim. I wasn't making a big deal of the fact that Avalon will leapfrog today's Mac OS X technology - obviously it will, and obviously we'd all be hugely disappointed if it didn't. But the original post in this thread suggested that Mac OS X is already ahead of where Avalon will be. I was simply pointing out that this is not true. Mac OS X does not already work like Avalon will work, despite what the subject line of this thread claims.