2.10. Application ServicesThis layer could be perceived as providing two types of services: those specialized for graphics and multimedia applications and those usable by any kind of an application. 2.10.1. Graphics and Multimedia ServicesThe graphics and multimedia services layer provides APIs for using 2D graphics, 3D graphics, video, and audio. Figure 219 shows how this layer fits in the overall graphics and multimedia architecture. Figure 219. The Mac OS X graphics and multimedia architecture2.10.1.1. QuartzThe core of the Mac OS X imaging model is called Quartz, which provides support for rendering 2D shapes and text. Its graphics-rendering functionality is exported via the Quartz 2D client API, which is implemented in the Core Graphics framework (CoreGraphics.framework)a subframework of the Application Services umbrella framework. Quartz is also used for window management. It provides a lightweight window server, the Quartz Compositor, which is implemented partly in the WindowServer application[39] and partly in the Core Graphics framework. Figure 220 shows a conceptual view of Quartz's constituents.
Figure 220. The key constituents of QuartzQuartz 2DQuartz 2D uses the Portable Document Format (PDF) as the native format for its drawing model.[40] In other words, Quartz stores rendered content internally as PDF. This facilitates features such as automatically generating PDF files (so you can save a screenshot "directly" to PDF), importing PDF data into native applications, and rasterizing PDF data (including PostScript and Encapsulated PostScript conversion). Quartz 2D is also responsible for device- and resolution-independent rendering of bitmap images, vector graphics, and anti-aliased text.
Beginning with Mac OS X 10.4, Quartz includes the PDF Kit (PDFKit.framework)a Cocoa framework containing classes and methods for accessing, manipulating, and displaying PDF files. Quartz CompositorThe Quartz Compositor is so called because of how it operates. Compositing refers to the process of overlaying independently rendered images into a single final image, while taking into account aspects such as transparency. Quartz implements layered compositing whereby an on-screen pixel can be shared between multiple windows in real time. The Quartz Compositor can composite pixels belonging to content from sources such as Quartz 2D, OpenGL, and QuickTime. In this sense, it follows a video-mixer model. Its implementation consists of the WindowServer program, which is an OpenGL application, and some private Apple libraries. Note that the Compositor does not perform any rendering itselfrendering is OpenGL's responsibility and is hardware accelerated when possible. Quartz ServicesWhereas the window server APIs are private, certain low-level features of the window server are exposed through the Quartz Services API. In particular, the API provides functions for accessing and manipulating display hardware. It also provides functions to access low-level window server events, thus allowing a program to "drive" the system remotely. Quartz ExtremeQuartz has an integrated hardware acceleration layer called Quartz Extreme, which automatically becomes active if suitable hardware is available. Specific hardware features required for Quartz Extreme include a minimum of 16MB video memory and a graphics card that supports arbitrary texture sizes, multitexturing, and pixel formats used by Quartz. Quartz Extreme is an implementation technique that uses OpenGL support in the graphics card so that the graphics processing unit (GPU)rather than the CPUdoes the compositing of window backing-stores[41] to the framebuffer. Consequently, the CPU is freer, leading to improvements in system responsiveness and performance. Figure 221 shows an overview of Quartz Extreme.
Figure 221. An overview of Quartz ExtremeAs Figure 221 shows, even when Quartz Extreme is active, the CPU is used to place pixels into window backing-stores, which reside in main memory. The GPU uses direct memory access (DMA) to asynchronously transfer the backing stores. It was not until Mac OS X 10.4 that Quartz 2D gained the capability to use the GPU for the entire drawing pathfrom the application to the framebuffer. This feature, called Quartz Extreme with Accelerated 2D (QE2D), is an evolution of Quartz Extreme. It can move data from an application to a window backing-store using DMA, while keeping track of frequently used data sets in an adaptively purged in-memory cache. QE2D strives to make rendering much faster than software rendering, while maintaining almost software-like quality. Common operations such as drawing glyphs, images, lines, and rectangles are implemented using OpenGL. Uncommon drawing operations, or those that cannot be handled well without software rendering,[42] are handled through an optimized CPU drawing path. QE2D requires a GPU with the ARB_fragment_program OpenGL extension. Figure 222 shows an overview of QE2D. Note that backing stores are now cached in video memory. Moreover, graphics resources such as colors, images, layers, and patterns are also cached. For this scheme to work well, the programmer must judiciously retain references to resources.
Figure 222. An overview of Quartz Extreme with Accelerated 2DQuartz also uses hardware vector processing, when available on the CPU, to enhance performance. 2.10.1.2. QuickDraw 2DQuickDraw 2D is a deprecated API for creating, manipulating, and displaying 2D shapes, text, and pictures. QuickDraw on Mac OS X is a reimplementation of the legacy QuickDraw API. It exists for the benefit of older projects as they transition to Quartz. QuickDraw makes use of the Velocity Engine but does not use graphics hardware acceleration like Quartz 2D. You can also make Quartz rendering calls from within QuickDraw, but mixing QuickDraw and Quartz 2D code in an application will result in hardware acceleration being disabled altogether for the rendering. 2.10.1.3. OpenGLMac OS X includes an implementation of OpenGLa cross-platform graphics API standard for creating 3D and 2D graphics. OpenGL works with Quartz 2D and the Quartz Compositor, enabling system-wide visual effects and the graphical aspects of features such as Exposé and Dashboard. As Figure 223 shows, there are several interfaces to OpenGL in Mac OS X. Figure 223. Interfaces to OpenGL in Mac OS X
2.10.1.4. Core Image and Core VideoCore Image is a high-level image-processing interface to a GPU-based media technology. Using Core Image, application developers can harness the GPU without needing to resort to low-level programming. Depending on available hardware, Core Image uses GPU-based acceleration and vector processing to improve performance. It supports 32-bit floating-point pixels for enhanced accuracy. It also uses other, more fundamental graphical technologies such as OpenGL,[43] Quartz, and QuickTime for optimal image processing.
Core Image uses a plug-in architecture[44] for accessing filters, transitions, and effects packagesthese are called Image Units. Developers can use the various Image Units shipped with Core Image or create their own by describing filters and effects using dynamically compiled expressions. Examples of bundled Image Units include filters for blurring and sharpening, color adjustment, compositing, distortion, gradients, halftones, tiling, and transitions. Figure 224 shows a conceptual view of image processing with Core Image. The key components of Core Image include the following:
Figure 224. Image processing with Core ImageCore Video applies concepts similar to Core Image to video, allowing video filters and effects to benefit from hardware acceleration. It could be seen as a bridge between QuickTime and the graphics hardware for processing video data by enhancing performance and lowering CPU requirements. Figure 225 shows a conceptual overview of using both Core Image and Core Video in an instance of the QuickTime video-rendering pipeline. Figure 225. Core Image and Core Video in the QuickTime video-rendering pipelineCore Image and Core Video are both parts of the Quartz Core framework.
2.10.1.5. QuickTimeQuickTime is both a graphics environment and an application environment. It provides features for working with interactive multimedia. Depending on the media type, QuickTime allows you to manipulate media in several ways, such as:
QuickTime works with several types of media such as video, graphics, animation, virtual reality, audio, and textin a variety of file and streaming formats. The media could reside on a local disk, be accessed over the network in its entirety, or be streamed in real time. The QuickTime architecture is modular and extensible. QuickTime components can be written to implement support for new media types, to implement a new codec, and to interact with custom media capture hardware. As indicated in Figure 225, beginning with Mac OS X 10.4, QuickTime cooperates with Core Image and Core Video to improve performance. Besides being an integrated technology in Mac OS X, QuickTime is available for other platforms such as Java, Mac OS 9, and several versions of Microsoft Windows. 2.10.1.6. Core AudioThe Core Audio layer (see Figure 219) allows management of audio software and hardware. It uses a plug-in architecture in which a plug-in can perform software operations on audio data or interact with audio hardware. Core Audio's hardware abstraction layer hides unnecessary details of the underlying hardware from applications. Core Audio APIs provide functionality for performing operations such as the following:
Apple's AU Lab digital mixing application (AULab.app) allows blending audio from multiple sources: the input of an audio device, audio generated by an Audio Unit Instrument, and audio generated from an Audio Unit Generator. It supports multiple outputs. OpenALThe Open Audio Library (OpenAL) is a cross-platform 3D audio API for use in games or other applications that require high-quality spatialized audio. It is available for systems such as BSD, IRIX, Linux, Solaris, Microsoft Windows, Mac OS 8, Mac OS 9, Sony PlayStation 2, Microsoft Xbox/Xbox360, and Nintendo GameCube. On Mac OS X, OpenAL is implemented using Core Audio as the underlying device. In the OpenAL specification, which is inspired by the OpenGL specification for graphics, a device is defined as an implementation-dependent entity that can be a hardware device, a daemon, or a system service. 2.10.2. Other Application ServicesThe Application Services umbrella framework contains subframeworks that facilitate development of many types of applicationshence the name. The following are examples of this framework's subframeworks.
|