Translucent Windows in X

Translucent Windows in X

Translucent Windows in X Keith Packard XFree86 Core Team, SuSE Inc. [email protected] Abstract Visually, translucent objects appear to affect the color and brightness of objects beyond them. The X Window System allows multiple windows to oc- The effect of light on a translucent object can be sim- cupy the same coordinates on the screen. The core pro- ulated by blending the color of the translucent object tocol defines which portions of each window are visible with that of objects beyond it. When dealing with com- and which are occluded by overlapping windows, but the puter images, translucency can be described as a math- overlapping windows are always completely opaque. ematical operation on the color data of a collection of images. This mathematical composition of images was Various techniques can be used to simulate non-opaque formally defined by Thomas Porter and Tom Duff in windows in controlled environments. The Shape Exten- 1984 [PD84]. They define formulae which use color sion can be used to make areas of the window transpar- data in conjunction with a per-pixel opacity value called ent. A background of “None” can be used to inherit the “alpha”. With these formulae many intuitive image ma- contents of the screen in the region occupied by the win- nipulations can be performed. dow when it is first mapped. Where available, hardware overlays can be used which expose a transparent pixel value. 1.1 Image Compositing Operators None of these techniques can be used for translucency in Each of the operators defined by Porter and Duff oper- a general way; hardware overlays and the Shape Exten- ate independently on each of the color channels in each sion can only provide transparency and cannot blend the pixel. The equations are abbreviated to show the opera- pixel colors together. A background of “None” cannot tion on a single channel of a single pixel. be used when the occluding windows are to be reconfig- ured or when the occluded region contents are expected A common compositing operation is to place one image to change. over another. Transparent areas of the overlying image allow the underlying image to show through. Opaque The X Translucent Window Extension is described areas hide the underlying image while translucent areas which solves the general translucency problem by as- blend the two images together. By defining the “alpha” signing alpha values for pixels in occluding windows. of a pixel as a number from 0 to 1 measuring its opacity, These values are used to blend the occluding window a simple equation combines two pixel colors together: contents with the occluded region for display. The de- £¥¤§¦©¨ ¨ tails of managing translucent window hierarchies, re- ¢ ¢ result ¡ under over over over parenting translucent windows and X visual differences Porter and Duff call this the “over” operator. between blended pixels are discussed. Another common operation is to mask an image with another; transparent areas in the mask are removed from the image while opaque areas of the mask leave the im- 1 Translucency age visible. ¨ ¢ result ¡ mask image Physically, translucent objects absorb some, but not all, This is the “in” operator. They provide a complete com- of the light passing through them. The color of the object positing algebra including other operations; only these affects which wavelengths are most strongly absorbed. two are needed for this extension. One important aspect of this model is that it creates a 2.1 Window Management Effects new image description which attaches another value “al- pha” to each pixel. This value measures the “opacity” of the pixel and can be operated on by the rendering func- It is possible to simulate translucency during some win- tions along with the color components. dow manipulation operations to provide additional feed- back for the user. This can be implemented by capturing a static image of the window and the desktop, blending 1.2 Destination Alpha them, and updating the display. This means that any changes that occur to the window Sometimes it is useful to create composite images which contents during the operation cannot be reflected dy- are themselves translucent, in other words, contain alpha namically on the screen, limiting this to window move- values. This effect can be achieved by augmenting the ment operations. Moving the blending operations into operators with an operation which produces a composite the window system allows for the dynamic composition alpha value along with the color values. For the “over” of application and underlying images. operator, the composite alpha value is defined as: Applications should not be required to cooperate to pro- ¨ ¨ £¥¤ ¦©¨ ¨ ¢ result ¡ under result over vide these effects. This requires an external control over window hierarchy translucence. The “in” operator composite alpha value is: ¨ ¨ ¨ ¢ result ¡ mask image 2.2 Transient Data The resulting images can now be used in additional ren- dering operations. User interface elements which appear transiently over application windows such as menus and dialog boxes often occlude information useful in the operation of the 1.3 Premultiplied Alpha transient action. By making the background of the tran- sient window transparent and using translucency to high- light dialog elements, an effective user interface element Visible in the above equations for computing the “over” can be usable and yet still allow interpretation of oc- operator is the asymmetry in the computation of alpha cluded application data. and the color components: ¨ £¥¤§¦©¨ ¨ ¨ While this can be effected by eliminating windowing for ¢ ¡ over over result under the transient elements and rendering them directly to the £¥¤§¦©¨ ¨ application window, the ability to continue to use win- ¢ ¢ result ¡ under over over over dow management and other windowing metaphors for This is “fixed” by respecifying the image data as being these elements provides a strong incentive to incorporate “premultiplied by alpha”. Each color component in the these semantics into the window system. image is replaced by that component multiplied by the associated alpha value. Blinn [Bli94] notes that premul- tiplied images easily provide the correct results when 2.3 Overlays and Annotation run through long sequences of operations, while non- premultiplied images involve awkward computations. Applications with complex image displays frequently present the ability for users to overlay associated in- formation or annotate the image without affecting the 2 Uses For Translucent Windows underlying image data. These needs are satisfied today only with graphics hardware that supports overlays. But even where supported, the annotations are usually lim- As user interface design moves forward with increas- ited to fewer color planes than the main image and can- ing graphics performance, things formerly passed over not incorporate translucence in the image, only opacity as computationally intractable are now quite reasonable. and transparency. Here are a couple of ideas how translucent windows could be used. Again, these effects can be implemented by the appli- cation, however, the underlying graphics are often ex- 3.2 Rendering Operators pensive to redisplay. Moving these operations into the window system provides the ability to use overlay hard- ware where available and gracefully fallback to software The X Rendering Extension uses a modified version of when necessary. the Plan 9 rendering primitive [Pik00] as the basis for image composition: £ Both transient windows and annotations require per- IN OP result ¡ image mask result pixel translucency that tracks rendering operations. In the Plan 9 window system, OP is always OVER. The extension allows any of the operators defined by Porter and Duff along with a special operator designed for drawing anti-aliased graphics adapted from OpenGL. 3 The X Rendering Extension Using this basic rendering primitive, the extension de- fines geometric operations by specifying the construc- tion of an implicit mask which is then used in the general primitive above. Anti-aliased graphics can be simulated The X Window System [SG92] is a networked, exten- by generating implicit masks with partial opacity along sible window system providing hierarchical windows. the edges. It was designed to operate on a wide variety of graph- ics hardware, from simple frame buffers to high-end graphics systems with overlays, underlays, accumula- 3.3 Color Management tion buffers, z-buffers, double buffering, etc. Over the last 12 years, it has become the standard window system for Unix and Unix-like systems. The core X protocol defines all rendering primitives in terms of pixel values. While this works when the ren- The X Rendering Extension [Pac00] provides a new ren- dering is done with boolean operations, it’s color-based dering architecture for X applications including image rendering must have a color interpretation for each pixel compositing, sub-pixel positioned geometric primitives value. and application management of glyphs. The X Translu- cent Window Extension builds on the image composi- The PictFormat object contains the information neces- tion ideas and mechanisms provided by the X Rendering sary to translate a pixel value into a color. The converted Extension. color can then be composited with other colors to gener- ate the displayed color. Once a final color is computed, the extension converts it back to a pixel value using a fixed palette with optional dithering to improve color fi- delity. Pseudo color displays use a fixed palette gen- 3.1 New Objects erated by the server for all images; the flexibility of a dynamic palette was discarded in favor of reduced col- ormap flashing and simpler code. The “PictFormat” object holds information needed to translate X pixel values into color and alpha data. For TrueColor visuals, the color data are extracted directly 4 Windowing Semantics from the pixel while pseudo color visuals use a separate Colormap. The PictFormat references the appropriate Colormap in that case. It also indicates the portion of X provides a hierarchical window system.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us