| Sign In/My Account | View Cart |
| Article: |
Graphical Composition in Avalon | |
| Subject: | macos x already works like this | |
| Date: | 2004-03-10 13:20:16 | |
| From: | zootbobbalu | |
|
Response to: macos x already works like this
|
||
|
“The same place as the logic in waiting about 15 years between the release of the first Mac, and the availability of Quartz, surely!”
|
||
Showing messages 1 through 23 of 23.
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
.
This is a site for windows programmer, and a mac idiot who has no idea on what's going on in the graphical APIs come and say that he didn't like what he heard about his beloved technology. Because he is too stupid to believe in everything Apple told him and that after spending thousands of dollars to a mac he doesn't want anybodyelse to say anything "negative" about his mac, even though everything is true. He doesn't even understand what's going on here.
I am completely suprised by the author's mature raction. Frankly, it is quite obvious that he is dealing with a mac idiot who will never ever get what he is saying.
By the way, this is obviously not about mac vs windows, except for this little idiot. The problem is to me, an idiot who views everything as mac vs windows is coming here and trying to discredit someone without putting anything to the table, by pure personal attacks. The above statement is a good indacation on where this idiot stands.