ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Graphical Composition in Avalon
Subject:   macos x already works like this
Date:   2004-03-10 09:58:42
From:   igriffiths
Response to: macos x already works like this

"where is the logic in waiting six years for a graphics technology. "


The same place as the logic in waiting about 15 years between the release of the first Mac, and the availability of Quartz, surely!


In 2000, graphics hardware wasn't up to running Avalon. The performance problems that Quartz suffered from in its early days pretty much answer your question for you - the early versions were slow because the typical hardware of the time wasn't quite ready for the architecture. This is why you have to wait - arguably Apple didn't wait quite long enough with Quartz. Hardware acceleration didn't come along until Quartz Extreme, and that placed some minimum requirements on the hardware - older machines can't run Quartz Extreme, and are stuck with crummy performance because the graphics architecture is just too heavy to fly on those systems. (Indeed, I gather that Apple now offer refunds to people who bought Mac OS X for some older systems, because they've had to admit that the machines simply cannot cope.)


These days (four years down the line), typical modern graphics hardware is good enough to cope with Quartz Extreme. Two years hence, things will have moved on again. Avalon is designed explicitly to exploit what will be available on high end systems in two years time (and on mainstream systems in three to four years time). If Avalon had been available in 2000, it wouldn't have worked because it makes assumptions about graphics hardware that simply weren't true back then. That's why we wait.


You could ask the exact same question with something like Java. Why wait 25 years for virtual execution environments to come along when you could write assembly language programs just fine in 1980? Java would never have worked in 1980. But very few people write assembly language today - we've all moved on. The platforms and development tools evolve to take best advantage of current hardware. In 1980 you had to wait 25 years for something like Java because that's how long it took for hardware to evolve to the point where Java made sense as a solution. In 2000, Windows made good use of typical graphics hardware from that era. In 2003, Quartz Extreme made good use of typical contemporary graphics hardware. In 2006, Avalon will make good use of graphics hardware that'll be available in 2006. And on it will go - once Quartz reaches the end of its useful life, Apple will no doubt come up with something more appropriate for whatever graphics hardware can do by then, thus leapfrogging Microsoft.


Is 6 years too long? I'm not sure. You can't change architecture every 2 years - it takes years to move developers over from one system to the next. (At least it does on Windows - a lot of Microsoft developers are comparatively conservative. I'm not sure what Mac developers tend to be like - maybe they're happier to undertake the necessary reengineering more often. But Microsoft know that every time they make a change, some customers will just stick with the old stuff for years. Look how many places still use Windows NT 4.0 - it's a conservative world out there.)



As for your other questions, the answer to the control composition and the rectangle/ellipse composition is the same: a heavily qualified yes. You can do this in Quartz *unless* you want to use transformations, in which case you can't use the compositor. If you want to do this with transforms, you have to abandon the compositor. You can still draw what you want by using Quartz 2D to draw everything into a single surface, but then you get no hardware acceleration, and no integration with anything else in the composition tree. (The lack of acceleration there is just a shortcoming of the current Quartz Extreme implementation by the way - in theory they could probably fix that specific problem in a future version.) Quartz supports transformations, but only in the same limited way as GDI+ (the Windows 2D technology which has been around for about as long as Quartz): it doesn't support transformations at the composition level. So this makes the compositor entirely useless for anything involving transformations. (Unless you're prepared to put up with the low image quality you get when performing affine transformations on bitmaps.) One reason that's important is that you absolutely need this for high-dpi displays to be supported automatically for all applications. (High-dpi support is seen by Microsoft as a key feature.) It's also important if you want to support refresh-rate animation. (E.g., although Quartz seems to be able to do video and 3D at the refresh rate, 2D drawing seems to be very much slower. I think it's no coincidence that 3D and video are accelerated and don't require the application to regenerate the entire display on a regular basis, unlike the Quartz 2D stuff, and these are the only bits of Quartz that really cut the mustard for performance today.)


As for the GPU playing a major role, Quartz Extreme doesn't use it at all for 2D drawing as far as I know. (All the articles I've read say that it accelerates composition and 3D, but not 2D drawing. I've not actually done any independent analysis to confirm this myself, but I'm assuming they can't all be wrong.) In Avalon it accelerates everything. So it's not really the same thing at all. And given that most drawing done by most applications is in fact 2D, it's curious that Apple leave this path unaccelerated. (I suspect it's because their most egregious performance problems were caused by the pre-Extreme compositor so they decided to fix that first.) So no, that's not what Quartz Extreme is all about. Quartz Extreme was all about accelerating one specific thing (composition), and leaving 2D in software. (Meanwhile, composition has been accelerated in Windows since Windows 2000. But I concede that Quartz Extreme's composition is more capable than Windows 2000's.)


You mention that Quartz does vector transformations, which is partially correct: transformations are a part of Quartz 2D. They are *not* a part of Quartz Composition, and that is the fundamental difference. This is what I was talking about in my earlier comment when I said that the Quartz Composition engine happens entirely downstream of the rasterizer.


So yes, as you say, I am "stuck on the notion that a retained vector representation" is important. This is the crucial difference. The big difference with having this handled by the platform, rather than requiring the application to issue the drawing commands on demand (which is how GDI+ and Quartz both work) is that the latter is very much slower due the the extremely chatty nature of the API, and impossible to integrate with the composition engine without resorting to bitmap-based composition. (Which is why both GDI+ and Quartz use bitmap-based composition.)


It's a popular meme that quartz is a form of display postscript, but everything I've seen and read indicates that what this really means is that as a developer, you get to issue commands to execute all of the postscript primitives, but that retention is entirely bitmap-based. So it's true that the 2D API has postscript-like features, but none of that permeates any of the rest of the Quartz architecture.


OpenGL is an entirely different matter by the way. The whole rendering pipeline is hardware accelerated there in Mac OS X, which is why you get good performance on that. (And if we're comparing things with Windows, today's OpenGL support in Mac OS X is not significantly different in architecture from today's DirectX 3D support in Windows today.)



As to your final point, yes, the end result of all the magic is a bitmap - ultimately it has to end up on a raster display of some kind, so that's inevitable. But I wouldn't agree that this makes the end-to-end vector support that differentiates Avalon from Quartz pointless. Dropping down to bitmaps too early in the pipeline has a performance impact, because it substantially increases the amount of communication required between the application and the display subsystem, and furthermore, it is likely to hamper the ability to support high-DPI displays. So both systems eventually have to produce bitmap as their final output, I'm just saying that in my opinion, Quartz drops down to bitmaps prematurely for 2D rendering.



But even if none of the above applied, there's also the fact that this is an article about Avalon, not Mac OS X. When I wrote the article, I had in mind a mainly Microsoft audience, for whom many of the concepts of composition will be new. If I had chosen to target a Mac developer audience, I would have written the article differently. I'm sorry if you felt the article wasn't very interesting.


1 to 1 of 1
  1. macos x already works like this
    2004-03-10 13:20:16  zootbobbalu [View]

    • macos x already works like this
      2004-04-06 05:50:12  musnat [View]

    • Ian Griffiths photo macos x already works like this
      2004-03-11 04:58:13  Ian Griffiths | O'Reilly Author [View]

      • macos x already works like this
        2004-03-11 13:40:55  rosyna [View]

        • Ian Griffiths photo macos x already works like this
          2004-03-12 00:28:19  Ian Griffiths | O'Reilly Author [View]

          • macos x already works like this
            2004-03-14 10:23:25  mweiher [View]

            • Ian Griffiths photo macos x already works like this
              2004-03-15 05:51:48  Ian Griffiths | O'Reilly Author [View]

              • macos x already works like this
                2004-04-06 06:17:25  musnat [View]

              • Ian Griffiths photo macos x already works like this
                2004-03-17 04:33:50  Ian Griffiths | O'Reilly Author [View]

              • macos x already works like this
                2004-03-15 13:58:01  mweiher [View]

                • macos x already works like this
                  2004-04-06 06:16:16  musnat [View]

                • Ian Griffiths photo macos x already works like this
                  2004-03-17 04:29:36  Ian Griffiths | O'Reilly Author [View]

                • Ian Griffiths photo macos x already works like this
                  2004-03-16 04:43:14  Ian Griffiths | O'Reilly Author [View]

                  • macos x already works like this
                    2004-03-19 17:33:59  mweiher [View]

                    • Ian Griffiths photo macos x already works like this
                      2004-03-21 11:57:47  Ian Griffiths | O'Reilly Author [View]

                      • macos x already works like this
                        2004-03-22 12:32:11  mweiher [View]

                        • ...
                  • macos x already works like this
                    2004-03-18 16:28:15  mweiher [View]

                    • Ian Griffiths photo macos x already works like this
                      2004-03-21 14:39:30  Ian Griffiths | O'Reilly Author [View]

                      • macos x already works like this
                        2004-05-23 22:06:41  glenlow [View]

                      • macos x already works like this
                        2004-03-22 15:32:48  mweiher [View]

                    • macos x already works like this
                      2004-03-19 20:59:37  rosyna [View]

1 to 1 of 1