dbelib.xml revision a5602400
1e8a5466aSmrg<?xml version="1.0" encoding="UTF-8" ?> 2a5602400Smrg<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 3a5602400Smrg "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> 4e8a5466aSmrg 5e8a5466aSmrg 6e8a5466aSmrg<!-- lifted from troff+ms+XMan by doclifter --> 7e8a5466aSmrg<book id="dbelib"> 8e8a5466aSmrg 9e8a5466aSmrg<bookinfo> 10e8a5466aSmrg <title>Double Buffer Extension Library</title> 11e8a5466aSmrg <subtitle>X Consortium Standard</subtitle> 12e8a5466aSmrg <!-- <releaseinfo>X Version 11, Release 6.4</releaseinfo> --> 13e8a5466aSmrg <authorgroup> 14e8a5466aSmrg <author> 15e8a5466aSmrg <firstname>Ian</firstname><surname>Elliot</surname> 16e8a5466aSmrg </author> 17e8a5466aSmrg </authorgroup> 18e8a5466aSmrg <othercredit> 19e8a5466aSmrg <firstname>Davide</firstname><surname>Wiggins</surname> 20e8a5466aSmrg </othercredit> 21e8a5466aSmrg <corpname>Hewlett-Packard Company</corpname> 22e8a5466aSmrg <copyright><year>1989</year><holder>X Consortium, Inc and Digital Equipment Corporation</holder></copyright> 23e8a5466aSmrg <copyright><year>1992</year><holder>X Consortium, Inc and Intergraph Corporation</holder></copyright> 24e8a5466aSmrg <copyright><year>1993</year><holder>X Consortium, Inc and Silicon Graphics, Inc.</holder></copyright> 25e8a5466aSmrg <copyright><year>1994</year><holder>X Consortium, Inc and Hewlett-Packard Company</holder></copyright> 26e8a5466aSmrg <copyright><year>1995</year><holder>X Consortium, Inc and Hewlett-Packard Company</holder></copyright> 27e8a5466aSmrg <releaseinfo>Version 1.0</releaseinfo> 28e8a5466aSmrg <affiliation><orgname>X Consortium</orgname></affiliation> 29e8a5466aSmrg <productnumber>X Version 11, Release 7</productnumber> 30e8a5466aSmrg 31e8a5466aSmrg<legalnotice> 32e8a5466aSmrg<para> 33e8a5466aSmrgPermission to use, copy, modify, and distribute this documentation for any 34e8a5466aSmrgpurpose and without fee is hereby granted, provided that the above copyright 35e8a5466aSmrgnotice and this permission notice appear in all copies. Digital Equipment 36e8a5466aSmrgCorporation, Intergraph Corporation, Silicon Graphics, Hewlett-Packard, and 37e8a5466aSmrgthe X Consortium make no representations about the suitability for any 38e8a5466aSmrgpurpose of the information in this document. This documentation is provided 39e8a5466aSmrg"as is" without express or implied warranty. 40e8a5466aSmrg</para> 41e8a5466aSmrg 42e8a5466aSmrg</legalnotice> 43e8a5466aSmrg 44e8a5466aSmrg</bookinfo> 45e8a5466aSmrg 46e8a5466aSmrg<chapter id="introduction"> 47e8a5466aSmrg<title>Introduction</title> 48e8a5466aSmrg<para> 49e8a5466aSmrgThe Double Buffer Extension (DBE) provides a standard way to utilize 50e8a5466aSmrgdouble-buffering within the framework of the X Window System. 51e8a5466aSmrgDouble-buffering uses two buffers, called front and back, which hold images. 52e8a5466aSmrgThe front buffer is visible to the user; the back buffer is not. Successive 53e8a5466aSmrgframes of an animation are rendered into the back buffer while the previously 54e8a5466aSmrgrendered frame is displayed in the front buffer. When a new frame is ready, 55e8a5466aSmrgthe back and front buffers swap roles, making the new frame visible. Ideally, 56e8a5466aSmrgthis exchange appears to happen instantaneously to the user and with no 57e8a5466aSmrgvisual artifacts. Thus, only completely rendered images are presented to the 58e8a5466aSmrguser, and they remain visible during the entire time it takes to render a new 59e8a5466aSmrgframe. The result is a flicker-free animation. 60e8a5466aSmrg</para> 61e8a5466aSmrg 62e8a5466aSmrg</chapter> 63e8a5466aSmrg 64e8a5466aSmrg<chapter id="goals"> 65e8a5466aSmrg<title>Goals</title> 66e8a5466aSmrg 67e8a5466aSmrg<para> 68e8a5466aSmrgThis extension should enable clients to: 69e8a5466aSmrg</para> 70e8a5466aSmrg<itemizedlist> 71e8a5466aSmrg <listitem> 72e8a5466aSmrg <para> 73e8a5466aSmrgAllocate and deallocate double-buffering for a window. 74e8a5466aSmrg </para> 75e8a5466aSmrg </listitem> 76e8a5466aSmrg <listitem> 77e8a5466aSmrg <para> 78e8a5466aSmrgDraw to and read from the front and back buffers associated with a window. 79e8a5466aSmrg </para> 80e8a5466aSmrg </listitem> 81e8a5466aSmrg <listitem> 82e8a5466aSmrg <para> 83e8a5466aSmrgSwap the front and back buffers associated with a window. 84e8a5466aSmrg </para> 85e8a5466aSmrg </listitem> 86e8a5466aSmrg <listitem> 87e8a5466aSmrg <para> 88e8a5466aSmrgSpecify a wide range of actions to be taken when a window is swapped. 89e8a5466aSmrgThis includes explicit, simple swap actions (defined below), and more 90e8a5466aSmrgcomplex actions (for example, clearing ancillary buffers) that can be put 91e8a5466aSmrgtogether within explicit "begin" and "end" requests (defined below). 92e8a5466aSmrg </para> 93e8a5466aSmrg </listitem> 94e8a5466aSmrg <listitem> 95e8a5466aSmrg <para> 96e8a5466aSmrgRequest that the front and back buffers associated with multiple 97e8a5466aSmrgdouble-buffered windows be swapped simultaneously. 98e8a5466aSmrg </para> 99e8a5466aSmrg </listitem> 100e8a5466aSmrg</itemizedlist> 101e8a5466aSmrg 102e8a5466aSmrg<para> 103e8a5466aSmrgIn addition, the extension should: 104e8a5466aSmrg</para> 105e8a5466aSmrg<itemizedlist> 106e8a5466aSmrg <listitem> 107e8a5466aSmrg <para> 108e8a5466aSmrgAllow multiple clients to use double-buffering on the same window. 109e8a5466aSmrg </para> 110e8a5466aSmrg </listitem> 111e8a5466aSmrg <listitem> 112e8a5466aSmrg <para> 113e8a5466aSmrgSupport a range of implementation methods that can capitalize on 114e8a5466aSmrgexisting hardware features. 115e8a5466aSmrg </para> 116e8a5466aSmrg </listitem> 117e8a5466aSmrg <listitem> 118e8a5466aSmrg <para> 119e8a5466aSmrgAdd no new event types. 120e8a5466aSmrg </para> 121e8a5466aSmrg </listitem> 122e8a5466aSmrg <listitem> 123e8a5466aSmrg <para> 124e8a5466aSmrgBe reasonably easy to integrate with a variety of direct graphics 125e8a5466aSmrghardware access (DGHA) architectures. 126e8a5466aSmrg </para> 127e8a5466aSmrg </listitem> 128e8a5466aSmrg</itemizedlist> 129e8a5466aSmrg 130e8a5466aSmrg</chapter> 131e8a5466aSmrg 132e8a5466aSmrg<chapter id="concepts"> 133e8a5466aSmrg<title>Concepts</title> 134e8a5466aSmrg<para> 135e8a5466aSmrgNormal windows are created using the core CreateWindow request, which 136e8a5466aSmrgallocates a set of window attributes and, for InputOutput windows, a front 137e8a5466aSmrgbuffer, into which an image can be drawn. The contents of this buffer will be 138e8a5466aSmrgdisplayed when the window is visible. 139e8a5466aSmrg</para> 140e8a5466aSmrg<para> 141e8a5466aSmrgThis extension enables applications to use double-buffering with a window. 142e8a5466aSmrgThis involves creating a second buffer, called a back buffer, and associating 143e8a5466aSmrgone or more back buffer names (XIDs) with the window for use when referring 144e8a5466aSmrgto (that is, drawing to or reading from) the window’s back buffer. The back 145e8a5466aSmrgbuffer name is a DRAWABLE of type BACKBUFFER. 146e8a5466aSmrg</para> 147e8a5466aSmrg<para> 148e8a5466aSmrgDBE provides a relative double-buffering model. One XID, the window, 149e8a5466aSmrgalways refers to the front buffer. One or more other XIDs, the back buffer 150e8a5466aSmrgnames, always refer to the back buffer. After a buffer swap, the window 151e8a5466aSmrgcontinues to refer to the (new) front buffer, and the back buffer name 152e8a5466aSmrgcontinues to refer to the (new) back buffer. Thus, applications and toolkits 153e8a5466aSmrgthat want to just render to the back buffer always use the back buffer name 154e8a5466aSmrgfor all drawing requests to the window. Portions of an application that want 155e8a5466aSmrgto render to the front buffer always use the window XID for all drawing 156e8a5466aSmrgrequests to the window. 157e8a5466aSmrg</para> 158e8a5466aSmrg<para> 159e8a5466aSmrgMultiple clients and toolkits can all use double-buffering on the same window. 160e8a5466aSmrgDBE does not provide a request for querying whether a window has 161e8a5466aSmrgdouble-buffering support, and if so, what the back buffer name is. Given the 162e8a5466aSmrgasynchronous nature of the X Window System, this would cause race 163e8a5466aSmrgconditions. Instead, DBE allows multiple back buffer names to exist for the 164e8a5466aSmrgsame window; they all refer to the same physical back buffer. The first time a 165e8a5466aSmrgback buffer name is allocated for a window, the window becomes 166e8a5466aSmrgdouble-buffered and the back buffer name is associated with the window. 167e8a5466aSmrgSubsequently, the window already is a double-buffered window, and nothing 168e8a5466aSmrgabout the window changes when a new back buffer name is allocated, except 169e8a5466aSmrgthat the new back buffer name is associated with the window. The window 170e8a5466aSmrgremains double-buffered until either the window is destroyed or until all of the 171e8a5466aSmrgback buffer names for the window are deallocated. 172e8a5466aSmrg</para> 173e8a5466aSmrg<para> 174e8a5466aSmrgIn general, both the front and back buffers are treated the same. 175e8a5466aSmrgparticular, here are some important characteristics: 176e8a5466aSmrg</para> 177e8a5466aSmrg<itemizedlist> 178e8a5466aSmrg <listitem> 179e8a5466aSmrg <para> 180e8a5466aSmrgOnly one buffer per window can be visible at a time (the front buffer). 181e8a5466aSmrg </para> 182e8a5466aSmrg </listitem> 183e8a5466aSmrg <listitem> 184e8a5466aSmrg <para> 185e8a5466aSmrgBoth buffers associated with a window have the same visual type, depth, 186e8a5466aSmrgwidth, height, and shape as the window. 187e8a5466aSmrg </para> 188e8a5466aSmrg </listitem> 189e8a5466aSmrg <listitem> 190e8a5466aSmrg <para> 191e8a5466aSmrgBoth buffers associated with a window are "visible" (or "obscured") in 192e8a5466aSmrgthe same way. When an Expose event is generated for a window, both 193e8a5466aSmrgbuffers should be considered to be damaged in the exposed area. 194e8a5466aSmrgDamage that occurs to either buffer will result in an Expose event on 195e8a5466aSmrgthe window. When a double-buffered window is exposed, both buffers 196e8a5466aSmrgare tiled with the window background, exactly as stated by the core 197e8a5466aSmrgprotocol. Even though the back buffer is not visible, terms such as 198e8a5466aSmrgobscure apply to the back buffer as well as to the front buffer. 199e8a5466aSmrg </para> 200e8a5466aSmrg </listitem> 201e8a5466aSmrg <listitem> 202e8a5466aSmrg <para> 203e8a5466aSmrgIt is acceptable at any time to pass a BACKBUFFER in any request, 204e8a5466aSmrgnotably any core or extension drawing request, that expects a 205e8a5466aSmrgDRAWABLE. This enables an application to draw directly into 206e8a5466aSmrgBACKBUFFERs in the same fashion as it would draw into any other 207e8a5466aSmrgDRAWABLE. 208e8a5466aSmrg </para> 209e8a5466aSmrg </listitem> 210e8a5466aSmrg <listitem> 211e8a5466aSmrg <para> 212e8a5466aSmrgIt is an error (Window) to pass a BACKBUFFER in a core request that 213e8a5466aSmrgexpects a Window. 214e8a5466aSmrg </para> 215e8a5466aSmrg </listitem> 216e8a5466aSmrg <listitem> 217e8a5466aSmrg <para> 218e8a5466aSmrgA BACKBUFFER will never be sent by core X in a reply, event, or 219e8a5466aSmrgerror where a Window is specified. 220e8a5466aSmrg </para> 221e8a5466aSmrg </listitem> 222e8a5466aSmrg <listitem> 223e8a5466aSmrg <para> 224e8a5466aSmrgIf core X11 backing-store and save-under applies to a double-buffered 225e8a5466aSmrgwindow, it applies to both buffers equally. 226e8a5466aSmrg </para> 227e8a5466aSmrg </listitem> 228e8a5466aSmrg <listitem> 229e8a5466aSmrg <para> 230e8a5466aSmrgIf the core ClearArea request is executed on a double-buffered window, 231e8a5466aSmrgthe same area in both the front and back buffers is cleared. 232e8a5466aSmrg </para> 233e8a5466aSmrg </listitem> 234e8a5466aSmrg</itemizedlist> 235e8a5466aSmrg 236e8a5466aSmrg<para> 237e8a5466aSmrgThe effect of passing a window to a request that accepts a 238e8a5466aSmrg<function>DRAWABLE</function> is 239e8a5466aSmrgunchanged by this extension. The window and front buffer are synonomous 240e8a5466aSmrgwith each other. This includes obeying the <function>GetImage</function> 241e8a5466aSmrgsemantics and the 242e8a5466aSmrgsubwindow-mode semantics if a core graphics context is involved. Regardless 243e8a5466aSmrgof whether the window was explicitly passed in a 244e8a5466aSmrg<function>GetImage</function> request, or 245e8a5466aSmrgimplicitly referenced (that is, one of the window’s ancestors was passed in the 246e8a5466aSmrgrequest), the front (that is, visible) buffer is always referenced. Thus, 247e8a5466aSmrgDBE-naive screen dump clients will always get the front buffer. 248e8a5466aSmrg<function>GetImage</function> on 249e8a5466aSmrga back buffer returns undefined image contents for any obscured regions of the 250e8a5466aSmrgback buffer that fall within the image. 251e8a5466aSmrg</para> 252e8a5466aSmrg<para> 253e8a5466aSmrgDrawing to a back buffer always uses the clip region that would be used to 254e8a5466aSmrgdraw to the front buffer with a GC subwindow-mode of 255e8a5466aSmrg<function>ClipByChildren</function>. If 256e8a5466aSmrgan ancestor of a double-buffered window is drawn to with a core GC having a 257e8a5466aSmrgsubwindow-mode of IncludeInferiors, the effect on the double-buffered 258e8a5466aSmrgwindow’s back buffer depends on the depth of the double-buffered window 259e8a5466aSmrgand the ancestor. If the depths are the same, the contents of the back buffer 260e8a5466aSmrgof the double-buffered window are not changed. If the depths are different, 261e8a5466aSmrgthe contents of the back buffer of the double-buffered window are undefined 262e8a5466aSmrgfor the pixels that the <function>IncludeInferiors</function> drawing touched. 263e8a5466aSmrg</para> 264e8a5466aSmrg 265e8a5466aSmrg 266e8a5466aSmrg<para> 267e8a5466aSmrgDBE adds no new events. DBE does not extend the semantics of any existing 268e8a5466aSmrgevents with the exception of adding a new DRAWABLE type called 269e8a5466aSmrgBACKBUFFER. If events, replies, or errors that contain a DRAWABLE (for 270e8a5466aSmrgexample, <function>GraphicsExpose</function>) are generated in response to 271e8a5466aSmrga request, the 272e8a5466aSmrgDRAWABLE returned will be the one specified in the request. 273e8a5466aSmrg</para> 274e8a5466aSmrg<para> 275e8a5466aSmrgDBE advertises which visuals support double-buffering. 276e8a5466aSmrg</para> 277e8a5466aSmrg<para> 278e8a5466aSmrgDBE does not include any timing or synchronization facilities. Applications 279e8a5466aSmrgthat need such facilities (for example, to maintain a constant frame rate) 280e8a5466aSmrgshould investigate the Synchronization Extension, an X Consortium standard. 281e8a5466aSmrg</para> 282e8a5466aSmrg 283e8a5466aSmrg<sect1 id="window_management_operations"> 284e8a5466aSmrg<title>Window Management Operations</title> 285e8a5466aSmrg 286e8a5466aSmrg<para> 287e8a5466aSmrgThe basic philosophy of DBE is that both buffers are treated the same by core 288e8a5466aSmrgX window management operations. 289e8a5466aSmrg</para> 290e8a5466aSmrg<para> 291e8a5466aSmrgWhen the core <function>DestroyWindow</function> is executed on a 292e8a5466aSmrgdouble-buffered window, both buffers associated with the window are 293e8a5466aSmrgdestroyed, and all back buffer names associated with the window are freed. 294e8a5466aSmrg</para> 295e8a5466aSmrg<para> 296e8a5466aSmrgIf the core <function>ConfigureWindow</function> request changes the size 297e8a5466aSmrgof a window, both buffers assume the new size. If the window’s size 298e8a5466aSmrgincreases, the effect on the buffers depends on whether the implementation 299e8a5466aSmrghonors bit gravity for buffers. 300e8a5466aSmrgIf bit gravity is implemented, then the contents of both buffers are moved in 301e8a5466aSmrgaccordance with the window’s bit gravity (see the core 302e8a5466aSmrg<function>ConfigureWindow</function> 303e8a5466aSmrgrequest), and the remaining areas are tiled with the window background. If 304e8a5466aSmrgbit gravity is not implemented, then the entire unobscured region of both 305e8a5466aSmrgbuffers is tiled with the window background. In either case, 306e8a5466aSmrg<function>Expose</function> events are 307e8a5466aSmrggenerated for the region that is tiled with the window background. 308e8a5466aSmrgIf the core GetGeometry request is executed on a BACKBUFFER, the 309e8a5466aSmrgreturned x, y, and border-width will be zero. 310e8a5466aSmrg</para> 311e8a5466aSmrg<para> 312e8a5466aSmrgIf the Shape extension 313e8a5466aSmrg<function>ShapeRectangles</function>, 314e8a5466aSmrg<function>ShapeMask</function>, 315e8a5466aSmrg<function>ShapeCombine</function>, or 316e8a5466aSmrg<function>ShapeOffset</function> 317e8a5466aSmrgrequest is executed on a double-buffered window, both buffers 318e8a5466aSmrgare reshaped to match the new window shape. The region difference is the 319e8a5466aSmrgfollowing: 320e8a5466aSmrg</para> 321e8a5466aSmrg 322e8a5466aSmrg<literallayout remap='Ds'> 323e8a5466aSmrg D = newshape − oldshape 324e8a5466aSmrg</literallayout> 325e8a5466aSmrg 326e8a5466aSmrg<para> 327e8a5466aSmrgIt is tiled with the window background in both buffers, and 328e8a5466aSmrg<function>Expose</function> 329e8a5466aSmrgevents are generated for D. 330e8a5466aSmrg</para> 331e8a5466aSmrg 332e8a5466aSmrg</sect1> 333e8a5466aSmrg 334e8a5466aSmrg<sect1 id="complex_swap_actions"> 335e8a5466aSmrg<title>Complex Swap Actions</title> 336e8a5466aSmrg<para> 337e8a5466aSmrgDBE has no explicit knowledge of ancillary buffers (for example, depth buffers 338e8a5466aSmrgor alpha buffers), and only has a limited set of defined swap actions. Some 339e8a5466aSmrgapplications may need a richer set of swap actions than DBE provides. Some 340e8a5466aSmrgDBE implementations have knowledge of ancillary buffers, and/or can provide 341e8a5466aSmrga rich set of swap actions. Instead of continually extending DBE to increase 342e8a5466aSmrgits set of swap actions, DBE provides a flexible "idiom" mechanism. If an 343e8a5466aSmrgapplication’s needs are served by the defined swap actions, it should use them; 344e8a5466aSmrgotherwise, it should use the following method of expressing a complex swap 345e8a5466aSmrgaction as an idiom. Following this policy will ensure the best possible 346e8a5466aSmrgperformance across a wide variety of implementations. 347e8a5466aSmrg</para> 348e8a5466aSmrg<para> 349e8a5466aSmrgAs suggested by the term "idiom," a complex swap action should be expressed 350e8a5466aSmrgas a group/series of requests. Taken together, this group of requests may be 351e8a5466aSmrgcombined into an atomic operation by the implementation, in order to 352e8a5466aSmrgmaximize performance. The set of idioms actually recognized for optimization 353e8a5466aSmrgis implementation dependent. 354e8a5466aSmrgTo help with idiom expression and 355e8a5466aSmrginterpretation, an idiom must be surrounded by two protocol requests: 356e8a5466aSmrg<function>DBEBeginIdiom</function> and <function>DBEEndIdiom</function>. 357e8a5466aSmrgUnless this begin-end pair surrounds the idiom, it may not be recognized 358e8a5466aSmrgby a given implementation, and performance will suffer. 359e8a5466aSmrg</para> 360e8a5466aSmrg<para> 361e8a5466aSmrgFor example, if an application wants to swap buffers for two windows, and use 362e8a5466aSmrgcore X to clear only certain planes of the back buffers, the application would 363e8a5466aSmrgissue the following protocol requests as a group, and in the following order: 364e8a5466aSmrg</para> 365e8a5466aSmrg 366e8a5466aSmrg<itemizedlist> 367e8a5466aSmrg <listitem> 368e8a5466aSmrg <para> 369e8a5466aSmrg<function>DBEBeginIdiom</function> request. 370e8a5466aSmrg </para> 371e8a5466aSmrg </listitem> 372e8a5466aSmrg <listitem> 373e8a5466aSmrg <para> 374e8a5466aSmrg<function>DBESwapBuffers</function> request with XIDs for two windows, each of which uses 375e8a5466aSmrga swap action of Untouched. 376e8a5466aSmrg </para> 377e8a5466aSmrg </listitem> 378e8a5466aSmrg <listitem> 379e8a5466aSmrg <para> 380e8a5466aSmrgCore X <function>PolyFillRectangle</function> request to the back buffer of one window. 381e8a5466aSmrg </para> 382e8a5466aSmrg </listitem> 383e8a5466aSmrg <listitem> 384e8a5466aSmrg <para> 385e8a5466aSmrgCore X <function>PolyFillRectangle</function> request to the back buffer of the other 386e8a5466aSmrgwindow. 387e8a5466aSmrg </para> 388e8a5466aSmrg </listitem> 389e8a5466aSmrg <listitem> 390e8a5466aSmrg <para> 391e8a5466aSmrg<function>DBEEndIdiom</function> request. 392e8a5466aSmrg </para> 393e8a5466aSmrg </listitem> 394e8a5466aSmrg</itemizedlist> 395e8a5466aSmrg 396e8a5466aSmrg<para> 397e8a5466aSmrgThe <function>DBEBeginIdiom</function> and <function>DBEEndIdiom</function> 398e8a5466aSmrgrequests do not perform any actions 399e8a5466aSmrgthemselves. They are treated as markers by implementations that can 400e8a5466aSmrgcombine certain groups/series of requests as idioms, and are ignored by other 401e8a5466aSmrgimplementations or for nonrecognized groups/series of requests. If these 402e8a5466aSmrgrequests are sent out of order, or are mismatched, no errors are sent, and the 403e8a5466aSmrgrequests are executed as usual, though performance may suffer. 404e8a5466aSmrg</para> 405e8a5466aSmrg 406e8a5466aSmrg<para> 407e8a5466aSmrg 408e8a5466aSmrgAn idiom need not include a <function>DBESwapBuffers</function> request. 409e8a5466aSmrgFor example, if a swap action of <function>Copied</function> is desired, 410e8a5466aSmrgbut only some of the planes should be copied, a core X 411e8a5466aSmrg<function>CopyArea</function> request may be used instead of 412e8a5466aSmrg<function>DBESwapBuffers</function>. If 413e8a5466aSmrg<function>DBESwapBuffers</function> is included in an idiom, it should 414e8a5466aSmrgimmediately follow the 415e8a5466aSmrg<function>DBEBeginIdiom</function> request. Also, when the 416e8a5466aSmrg<function>DBESwapBuffers</function> is included in an idiom, that 417e8a5466aSmrgrequest’s swap action will still be valid, and if the swap action 418e8a5466aSmrgmight overlap with another request, then the final result of the idiom must be 419e8a5466aSmrgas if the separate requests were executed serially. For example, if the 420e8a5466aSmrgspecified swap action is <function>Untouched</function>, and if a 421e8a5466aSmrg<function>PolyFillRectangle</function> using a client clip 422e8a5466aSmrgrectangle is done to the window’s back buffer after the 423e8a5466aSmrg<function>DBESwapBuffers</function> request, then the contents of the new 424e8a5466aSmrgback buffer (after the idiom) will be the 425e8a5466aSmrgsame as if the idiom was not recognized by the implementation. 426e8a5466aSmrg</para> 427e8a5466aSmrg<para> 428e8a5466aSmrgIt is highly recommended that Application Programming Interface (API) 429e8a5466aSmrgproviders define, and application developers use, "convenience" functions that 430e8a5466aSmrgallow client applications to call one procedure that encapsulates common 431e8a5466aSmrgidioms. These functions will generate the 432e8a5466aSmrg<function>DBEBeginIdiom</function> request, the idiom 433e8a5466aSmrgrequests, and <function>DBEEndIdiom</function> request. Usage of these 434e8a5466aSmrgfunctions will ensure best possible performance across a wide 435e8a5466aSmrgvariety of implementations. 436e8a5466aSmrg</para> 437e8a5466aSmrg 438e8a5466aSmrg</sect1> 439e8a5466aSmrg</chapter> 440e8a5466aSmrg 441e8a5466aSmrg<chapter id="c_language_bindings"> 442e8a5466aSmrg<title>C Language Binding</title> 443e8a5466aSmrg<para> 444e8a5466aSmrgAll identifier The header for this extension is <X11/extensions/Xdbe.h>. 445e8a5466aSmrgnames provided by this header begin with Xdbe. 446e8a5466aSmrg</para> 447e8a5466aSmrg 448e8a5466aSmrg<sect1 id="types"> 449e8a5466aSmrg<title>Types</title> 450e8a5466aSmrg 451e8a5466aSmrg<para> 452e8a5466aSmrgThe type <function>XdbeBackBuffer</function> is a <function>Drawable</function>. 453e8a5466aSmrg</para> 454e8a5466aSmrg 455e8a5466aSmrg<para> 456e8a5466aSmrgThe type <function>XdbeSwapAction</function> can be one of the constants 457e8a5466aSmrg<function>XdbeUndefined</function>, 458e8a5466aSmrg<function>XdbeBackground</function>, 459e8a5466aSmrg<function>XdbeUntouched</function>, or 460e8a5466aSmrg<function>XdbeCopied</function>. 461e8a5466aSmrg</para> 462e8a5466aSmrg 463e8a5466aSmrg</sect1> 464e8a5466aSmrg 465e8a5466aSmrg<sect1 id="c_functions"> 466e8a5466aSmrg<title>C Functions</title> 467e8a5466aSmrg<para> 468e8a5466aSmrgThe C functions provide direct access to the protocol and add no additional 469e8a5466aSmrgsemantics. For complete details on the effects of these functions, refer to the 470e8a5466aSmrgappropriate protocol request, which can be derived by replacing Xdbe at the 471e8a5466aSmrgstart of the function name with DBE. All functions that have return type 472e8a5466aSmrg<function>Status</function> will return nonzero for success and 473e8a5466aSmrgzero for failure. 474e8a5466aSmrg</para> 475e8a5466aSmrg 476e8a5466aSmrg<funcsynopsis> 477e8a5466aSmrg<funcprototype> 478e8a5466aSmrg <funcdef>Status <function>XdbeQueryExtension</function></funcdef> 479e8a5466aSmrg <paramdef>Display <parameter> *dpy</parameter></paramdef> 480e8a5466aSmrg <paramdef>int <parameter> *major_version_return</parameter></paramdef> 481e8a5466aSmrg <paramdef>int <parameter> *minor_version_return</parameter></paramdef> 482e8a5466aSmrg</funcprototype> 483e8a5466aSmrg</funcsynopsis> 484e8a5466aSmrg 485e8a5466aSmrg<para> 486e8a5466aSmrg<function>XdbeQueryExtension</function> sets major version return and minor 487e8a5466aSmrgversion return to the major and minor DBE protocol version supported by 488e8a5466aSmrgthe server. If the DBE library is compatible with the version returned by 489e8a5466aSmrgthe server, it returns nonzero. If dpy does not support the DBE extension, 490e8a5466aSmrgor if there was an error during communication with the server, or if the 491e8a5466aSmrgserver and library protocol versions are incompatible, it returns zero. 492e8a5466aSmrgNo other Xdbe functions may be called before this function. If a client 493e8a5466aSmrgviolates this rule, the effects of all subsequent Xdbe calls that it makes 494e8a5466aSmrgare undefined. 495e8a5466aSmrg</para> 496e8a5466aSmrg 497e8a5466aSmrg<funcsynopsis> 498e8a5466aSmrg<funcprototype> 499e8a5466aSmrg <funcdef>XdbeScreenVisualInfo *<function>XdbeGetVisualInfo</function></funcdef> 500e8a5466aSmrg <paramdef>Display <parameter> *dpy</parameter></paramdef> 501e8a5466aSmrg <paramdef>Drawable <parameter> *screen_specifiers</parameter></paramdef> 502e8a5466aSmrg <paramdef>int <parameter> *num_screens</parameter></paramdef> 503e8a5466aSmrg</funcprototype> 504e8a5466aSmrg</funcsynopsis> 505e8a5466aSmrg 506e8a5466aSmrg<para> 507e8a5466aSmrg 508e8a5466aSmrg<function>XdbeGetVisualInfo</function> returns information about which 509e8a5466aSmrgvisuals support double buffering. The argument num_screens specifies how 510e8a5466aSmrgmany elements there are in the screen_specifiers list. Each drawable in 511e8a5466aSmrgscreen_specifiers designates a screen for which the supported visuals are 512e8a5466aSmrgbeing requested. If num_screens is zero, information for all screens is 513e8a5466aSmrgrequested. In this case, upon return from this function, num_screens will 514e8a5466aSmrgbe set to the number of screens that were found. If an error occurs, 515e8a5466aSmrgthis function returns NULL; otherwise, it returns a pointer to a list of 516e8a5466aSmrg<function>XdbeScreenVisualInfo</function> 517e8a5466aSmrgstructures of length num_screens. The nth element in the returned list 518e8a5466aSmrgcorresponds to the nth drawable in the screen_specifiers list, unless 519e8a5466aSmrg 520e8a5466aSmrgelement in the returned list corresponds to the nth screen of the server, 521e8a5466aSmrgstarting with screen zero. 522e8a5466aSmrg</para> 523e8a5466aSmrg 524e8a5466aSmrg 525e8a5466aSmrg<para> 526e8a5466aSmrgThe XdbeScreenVisualInfo structure has the following fields: 527e8a5466aSmrg</para> 528e8a5466aSmrg<literallayout remap='Ds'> 529e8a5466aSmrgint count number of items in visinfo 530e8a5466aSmrgXdbeVisualInfo* visinfo list of visuals and depths for this screen 531e8a5466aSmrg</literallayout> 532e8a5466aSmrg 533e8a5466aSmrg<para> 534e8a5466aSmrgThe <function>XdbeVisualInfo</function> structure has the following fields: 535e8a5466aSmrg</para> 536e8a5466aSmrg 537e8a5466aSmrg<literallayout remap='Ds'> 538e8a5466aSmrgVisualID visual one visual ID that supports double-buffering 539e8a5466aSmrgint depth depth of visual in bits 540e8a5466aSmrgint perflevel performance level of visual 541e8a5466aSmrg</literallayout> 542e8a5466aSmrg 543e8a5466aSmrg 544e8a5466aSmrg<funcsynopsis> 545e8a5466aSmrg<funcprototype> 546e8a5466aSmrg <funcdef>void XdbeFreeVisualInfo <function>XdbeGetVisualInfo</function></funcdef> 547e8a5466aSmrg <paramdef>XdbeScreenVisualInfo <parameter> *visual_info</parameter></paramdef> 548e8a5466aSmrg</funcprototype> 549e8a5466aSmrg</funcsynopsis> 550e8a5466aSmrg 551e8a5466aSmrg<para> 552e8a5466aSmrg<function>XdbeFreeVisualInfo</function> frees the list of 553e8a5466aSmrg<function>XdbeScreenVisualInfo</function> returned by 554e8a5466aSmrg<function>XdbeGetVisualInfo</function>. 555e8a5466aSmrg</para> 556e8a5466aSmrg 557e8a5466aSmrg 558e8a5466aSmrg<funcsynopsis> 559e8a5466aSmrg<funcprototype> 560e8a5466aSmrg <funcdef>XdbeBackBuffer <function>XdbeAllocateBackBufferName</function></funcdef> 561e8a5466aSmrg <paramdef>Display <parameter> *dpy</parameter></paramdef> 562e8a5466aSmrg <paramdef>Window <parameter> *window</parameter></paramdef> 563e8a5466aSmrg <paramdef>XdbeSwapAction <parameter> swap_action</parameter></paramdef> 564e8a5466aSmrg</funcprototype> 565e8a5466aSmrg</funcsynopsis> 566e8a5466aSmrg 567e8a5466aSmrg 568e8a5466aSmrg<para> 569e8a5466aSmrg<function>XdbeAllocateBackBufferName</function> returns a drawable ID used 570e8a5466aSmrgto refer to the back buffer of the specified window. The swap_action is a 571e8a5466aSmrghint to indicate the swap_action that will likely be used in subsequent 572e8a5466aSmrgcalls to <function>XdbeSwapBuffers</function>. The actual swap_action 573e8a5466aSmrgused in calls to <function>XdbeSwapBuffers</function> does not have to be 574e8a5466aSmrgthe same as the swap_action passed to this function, though clients are 575e8a5466aSmrgencouraged to provide accurate information whenever possible. 576e8a5466aSmrg</para> 577e8a5466aSmrg 578e8a5466aSmrg<funcsynopsis> 579e8a5466aSmrg<funcprototype> 580e8a5466aSmrg <funcdef>Status <function>XdbeDeallocateBackBufferName</function></funcdef> 581e8a5466aSmrg <paramdef>Display <parameter> *dpy</parameter></paramdef> 582e8a5466aSmrg <paramdef>XdbeBackBuffer <parameter> buffer</parameter></paramdef> 583e8a5466aSmrg</funcprototype> 584e8a5466aSmrg</funcsynopsis> 585e8a5466aSmrg 586e8a5466aSmrg<para> 587e8a5466aSmrg<function>XdbeDeallocateBackBufferName</function> frees the specified 588e8a5466aSmrgdrawable ID, buffer, that was obtained via 589e8a5466aSmrg<function>XdbeAllocateBackBufferName</function>. The buffer must be a valid 590e8a5466aSmrgname for the back buffer of a window, or an 591e8a5466aSmrg<function>XdbeBadBuffer</function> error results. 592e8a5466aSmrg</para> 593e8a5466aSmrg 594e8a5466aSmrg<funcsynopsis> 595e8a5466aSmrg<funcprototype> 596e8a5466aSmrg <funcdef>Status <function>XdbeSwapBuffers</function></funcdef> 597e8a5466aSmrg <paramdef>Display <parameter> *dpy</parameter></paramdef> 598e8a5466aSmrg <paramdef>XdbeSwapInfo <parameter> *swap_info</parameter></paramdef> 599e8a5466aSmrg <paramdef>int <parameter> num_windows</parameter></paramdef> 600e8a5466aSmrg</funcprototype> 601e8a5466aSmrg</funcsynopsis> 602e8a5466aSmrg 603e8a5466aSmrg<para> 604e8a5466aSmrg<function>XdbeSwapBuffers</function> swaps the front and back buffers 605e8a5466aSmrgfor a list of windows. The argument num_windows specifies how many windows 606e8a5466aSmrgare to have their buffers swapped; it is the number of elements in the 607e8a5466aSmrgswap_info array. The argument swap_info specifies the information needed 608e8a5466aSmrgper window to do the swap. 609e8a5466aSmrg</para> 610e8a5466aSmrg<para> 611e8a5466aSmrgThe XdbeSwapInfo structure has the following fields: 612e8a5466aSmrg</para> 613e8a5466aSmrg 614e8a5466aSmrg<literallayout remap='Ds'> 615e8a5466aSmrgWindow swap_window window for which to swap buffers 616e8a5466aSmrgXdbeSwapAction swap_action swap action to use for this swap window 617e8a5466aSmrg</literallayout> 618e8a5466aSmrg 619e8a5466aSmrg<funcsynopsis> 620e8a5466aSmrg<funcprototype> 621e8a5466aSmrg <funcdef>Status <function>XdbeBeginIdiom</function></funcdef> 622e8a5466aSmrg <paramdef>Display <parameter> *dpy</parameter></paramdef> 623e8a5466aSmrg</funcprototype> 624e8a5466aSmrg</funcsynopsis> 625e8a5466aSmrg 626e8a5466aSmrg<para> 627e8a5466aSmrg<function>XdbeBeginIdiom</function> marks the beginning of an idiom 628e8a5466aSmrgsequence. See 629e8a5466aSmrg<link linkend="complex_swap_actions"> 630e8a5466aSmrg<xref linkend="complex_swap_actions"></xref></link> 631e8a5466aSmrgfor a complete discussion of idioms. 632e8a5466aSmrg</para> 633e8a5466aSmrg 634e8a5466aSmrg<funcsynopsis> 635e8a5466aSmrg<funcprototype> 636e8a5466aSmrg <funcdef>Status <function>XdbeEndIdiom</function></funcdef> 637e8a5466aSmrg <paramdef>Display <parameter> *dpy</parameter></paramdef> 638e8a5466aSmrg</funcprototype> 639e8a5466aSmrg</funcsynopsis> 640e8a5466aSmrg 641e8a5466aSmrg<para> 642e8a5466aSmrg<function>XdbeEndIdiom</function> marks the end of an idiom sequence. 643e8a5466aSmrg</para> 644e8a5466aSmrg 645e8a5466aSmrg<funcsynopsis> 646e8a5466aSmrg<funcprototype> 647e8a5466aSmrg <funcdef>XdbeBackBufferAttributes *<function>XdbeGetBackBufferAttributes</function></funcdef> 648e8a5466aSmrg <paramdef>Display <parameter> *dpy</parameter></paramdef> 649e8a5466aSmrg <paramdef>XdbeBackBuffer <parameter> buffer</parameter></paramdef> 650e8a5466aSmrg</funcprototype> 651e8a5466aSmrg</funcsynopsis> 652e8a5466aSmrg 653e8a5466aSmrg<para> 654e8a5466aSmrg<function>XdbeGetBackBufferAttributes</function> returns the attributes associated with 655e8a5466aSmrgthe specified buffer. 656e8a5466aSmrg</para> 657e8a5466aSmrg<para> 658e8a5466aSmrgThe XdbeBackBufferAttributes structure has the following fields: 659e8a5466aSmrg</para> 660e8a5466aSmrg 661e8a5466aSmrg<literallayout remap='Ds'> 662e8a5466aSmrgWindow window window that buffer belongs to 663e8a5466aSmrg</literallayout> 664e8a5466aSmrg 665e8a5466aSmrg<para> 666e8a5466aSmrgIf buffer is not a valid <function>XdbeBackBuffer</function>, window is 667e8a5466aSmrgset to None. 668e8a5466aSmrg</para> 669e8a5466aSmrg<para> 670e8a5466aSmrgThe returned <function>XdbeBackBufferAttributes</function> structure 671e8a5466aSmrgcan be freed with the Xlib function <function>XFree</function>. 672e8a5466aSmrg</para> 673e8a5466aSmrg</sect1> 674e8a5466aSmrg 675e8a5466aSmrg<sect1 id="errors"> 676e8a5466aSmrg<title>Errors</title> 677e8a5466aSmrg<para> 678e8a5466aSmrgThe <function>XdbeBufferError</function> structure has the following fields: 679e8a5466aSmrg</para> 680e8a5466aSmrg<literallayout remap='Ds'> 681e8a5466aSmrgint type 682e8a5466aSmrgDisplay * display Display the event was read from 683e8a5466aSmrgXdbeBackBuffer buffer resource id 684e8a5466aSmrgunsigned long serial serial number of failed request 685e8a5466aSmrgunsigned char error code error base + <function>XdbeBadBuffer</function> 686e8a5466aSmrgunsigned char request code Major op-code of failed request 687e8a5466aSmrgunsigned char minor code Minor op-code of failed request 688e8a5466aSmrg</literallayout> 689e8a5466aSmrg</sect1> 690e8a5466aSmrg</chapter> 691e8a5466aSmrg 692e8a5466aSmrg<chapter id="acknowledgements"> 693e8a5466aSmrg<title>Acknowledgements</title> 694e8a5466aSmrg 695e8a5466aSmrg<para> 696e8a5466aSmrgWe wish to thank the following individuals who have contributed their time 697e8a5466aSmrgand talent toward shaping the DBE specification: 698e8a5466aSmrg</para> 699e8a5466aSmrg<para> 700e8a5466aSmrgT. Alex Chen, IBM; Peter Daifuku, Silicon Graphics, Inc.; Ian Elliott, 701e8a5466aSmrgHewlett-Packard Company; Stephen Gildea, X Consortium, Inc.; Jim Graham, 702e8a5466aSmrgSun; Larry Hare, AGE Logic; Jay Hersh, X Consortium, Inc.; Daryl Huff, 703e8a5466aSmrgSun; Deron Dann Johnson, Sun; Louis Khouw, Sun; Mark Kilgard, Silicon 704e8a5466aSmrgGraphics, Inc.; Rob Lembree, Digital Equipment Corporation; Alan Ricker, 705e8a5466aSmrgMetheus; Michael Rosenblum, Digital Equipment Corporation; Bob Scheifler, 706e8a5466aSmrgX Consortium, Inc.; Larry Seiler, Digital Equipment Corporation; Jeanne 707e8a5466aSmrgSparlin Smith, IBM; Jeff Stevenson, Hewlett-Packard Company; Walter 708e8a5466aSmrgStrand, Metheus; Ken Tidwell, Hewlett-Packard Company; and David P. 709e8a5466aSmrgWiggins, X Consortium, Inc. 710e8a5466aSmrg</para> 711e8a5466aSmrg<para> 712e8a5466aSmrgMark provided the impetus to start the DBE project. Ian wrote the first draft 713e8a5466aSmrgof the specification. David served as architect. 714e8a5466aSmrg</para> 715e8a5466aSmrg 716e8a5466aSmrg</chapter> 717e8a5466aSmrg<chapter id="references"> 718e8a5466aSmrg<title>References</title> 719e8a5466aSmrg<para> 720e8a5466aSmrgJeffrey Friedberg, Larry Seiler, and Jeff Vroom, "Multi-buffering Extension 721e8a5466aSmrgSpecification Version 3.3." 722e8a5466aSmrg</para> 723e8a5466aSmrg<para> 724e8a5466aSmrgTim Glauert, Dave Carver, Jim Gettys, and David P. Wiggins, "X 725e8a5466aSmrgSynchronization Extension Version 3.0." 726e8a5466aSmrg</para> 727e8a5466aSmrg</chapter> 728e8a5466aSmrg</book> 729