home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-bin / x11r6.1 / man / cat3 / dbe.0 < prev    next >
Encoding:
Text File  |  1996-10-17  |  15.8 KB  |  397 lines

  1.  
  2.  
  3.  
  4. DBE(3X11)           X FUNCTIONS            DBE(3X11)
  5.  
  6.  
  7. NNAAMMEE
  8.        DBE - Double Buffer Extension
  9.  
  10. SSYYNNOOPPSSIISS
  11.        The  Double Buffer Extension (DBE) provides a standard way
  12.        to utilize double-buffering within the framework of the    X
  13.        Window  System.    Double-buffering uses two buffers, called
  14.        front and back, which hold images.  The    front  buffer  is
  15.        visible    to  the user; the back buffer is not.  Successive
  16.        frames of an animation are rendered into the  back  buffer
  17.        while  the  previously  rendered frame is displayed in the
  18.        front buffer.  When a new frame is  ready,  the    back  and
  19.        front  buffers  swap  roles, making the new frame visible.
  20.        Ideally, this exchange appears to  happen  instantaneously
  21.        to  the    user,  with no visual artifacts.  Thus, only com-
  22.        pletely rendered images are presented  to  the  user,  and
  23.        remain visible during the entire time it takes to render a
  24.        new frame.  The result is a flicker-free animation.
  25.  
  26. DDEESSCCRRIIPPTTIIOONN
  27.        CCoonncceeppttss
  28.           Normal windows are created using XXCCrreeaatteeWWiinnddooww(()) or
  29.           XXCCrreeaatteeSSiimmpplleeWWiinnddooww(()),, which allocate a set of win-
  30.           dow attributes  and,  for     InputOutput  windows,    a
  31.           front  buffer,  into  which  an image can be drawn.
  32.           The contents of this buffer will be displayed  when
  33.           the window is visible.
  34.  
  35.           This  extension enables applications to use double-
  36.           buffering with a window.    This involves creating    a
  37.           second  buffer, called a back buffer, and associat-
  38.           ing one or more back buffer names _(_X_I_D_s_)    with  the
  39.           window, for use when referring to (i.e., drawing to
  40.           or reading from) the  window's  back  buffer.   The
  41.           back  buffer  name  is a drawable of type _X_d_b_e_B_a_c_k_-
  42.           _B_u_f_f_e_r_.
  43.  
  44.           DBE provides  a  relative     double-buffering  model.
  45.           One  XID,     the  window,  always refers to the front
  46.           buffer.  One or more other XIDs,    the  back  buffer
  47.           names,  always  refer  to the back buffer.  After a
  48.           buffer swap, the window continues to refer  to  the
  49.           (new)  front  buffer, and the back buffer name con-
  50.           tinues to refer to the (new)  back  buffer.   Thus,
  51.           applications  and toolkits that want to just render
  52.           to the back buffer always use the back buffer  name
  53.           for  all    drawing requests to the window.     Portions
  54.           of an application that want to render to the  front
  55.           buffer  always  use  the window XID for all drawing
  56.           requests to the window.
  57.  
  58.           Multiple clients and toolkits can all  use  double-
  59.           buffering on the same window.  DBE does not provide
  60.           a request for querying whether a window has double-
  61.  
  62.  
  63.  
  64. X Version 11           Release 6.1                1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. DBE(3X11)           X FUNCTIONS            DBE(3X11)
  71.  
  72.  
  73.           buffering     support, and if so, what the back buffer
  74.           name is.    Given the asynchronous nature  of  the    X
  75.           Window  System,  this  would cause race conditions.
  76.           Instead, DBE allows multiple back buffer    names  to
  77.           exist  for  the  same window; they all refer to the
  78.           same physical back buffer.  The first time  a  back
  79.           buffer  name  is allocated for a window, the window
  80.           becomes double-buffered and the back buffer name is
  81.           associated with the window.  Subsequently, the win-
  82.           dow already is a double-buffered window, and  noth-
  83.           ing about the window changes when a new back buffer
  84.           name is allocated, except that the new back  buffer
  85.           name  is    associated  with  the window.  The window
  86.           remains double-buffered until either the window  is
  87.           destroyed,  or  until  all of the back buffer names
  88.           for the window are deallocated.
  89.  
  90.           In general, both the  front  and    back  buffers  ae
  91.           treated  the  same.   In    particular, here are some
  92.           important characteristics:
  93.  
  94.              Only one buffer per window can be visible at
  95.              a time (the front buffer).
  96.  
  97.              Both  buffers  associated with a window have
  98.              the same visual type, depth, width,  height,
  99.              and shape as the window.
  100.  
  101.              Both  buffers  associated    with a window are
  102.              "visible" (or "obscured") in the  same  way.
  103.              When an Expose event is generated for a win-
  104.              dow, this event is considered  to    apply  to
  105.              both   buffers   equally.     When  a  double-
  106.              buffered window is exposed, both buffers are
  107.              tiled  with  the  window  background.   Even
  108.              though the back buffer is not visible, terms
  109.              such  as obscure apply to the back buffer as
  110.              well as to the front buffer.
  111.  
  112.              It is acceptable at  any  time  to     pass  an
  113.              _X_d_b_e_B_a_c_k_B_u_f_f_e_r  in any function that expects
  114.              a drawable.  This enables an application  to
  115.              draw  directly  into  _X_d_b_e_B_a_c_k_B_u_f_f_e_r  in the
  116.              same fashion as it would draw into any other
  117.              drawable.
  118.  
  119.              It is an error (Window) to pass an _X_d_b_e_B_a_c_k_-
  120.              _B_u_f_f_e_r in a function that expects a  Window.
  121.  
  122.              An     _X_d_b_e_B_a_c_k_B_u_f_f_e_r     will  never be sent in a
  123.              reply, event, or error  where  a  Window  is
  124.              specified.
  125.  
  126.              If backing-store and save-under applies to a
  127.  
  128.  
  129.  
  130. X Version 11           Release 6.1                2
  131.  
  132.  
  133.  
  134.  
  135.  
  136. DBE(3X11)           X FUNCTIONS            DBE(3X11)
  137.  
  138.  
  139.              double-buffered window, it applies     to  both
  140.              buffers equally.
  141.  
  142.              If     the XXCClleeaarrAArreeaa(()) or XXCClleeaarrWWiinnddooww(()) func-
  143.              tion is executed on a  double-buffered  win-
  144.              dow,  the    same  area  in both the front and
  145.              back buffers is cleared.
  146.  
  147.           The effect of passing a window to a  function  that
  148.           accepts  a drawable is unchanged by this extension.
  149.           The window and front  buffer  are     synonomous  with
  150.           each  other.  This includes obeying the XXGGeettIImmaaggee(())
  151.           and XXGGeettSSuubbIImmaaggee(()) semantics and the subwindow-mode
  152.           semantics      if  a     graphics  context  is    involved.
  153.           Regardless of whether  the  window  was  explicitly
  154.           passed in an XXGGeettIImmaaggee(()) or XXGGeettSSuubbIImmaaggee(()) call, or
  155.           implicitly referenced (i.e., one    of  the     window's
  156.           ancestors     was  passed  in the function), the front
  157.           (i.e. visible) buffer is always referenced.   Thus,
  158.           DBE-naive     screen     dump clients will always get the
  159.           front buffer.  XXGGeettIImmaaggee(()) and XXGGeettSSuubbIImmaaggee(()) on    a
  160.           back buffer return undefined image contents for any
  161.           obscured regions    of  the     back  buffer  that  fall
  162.           within the image.
  163.  
  164.           Drawing  to  a  back  buffer  always  uses the clip
  165.           region that would be used     to  draw  to  the  front
  166.           buffer  with a GC subwindow-mode of ClipByChildren.
  167.           If an ancestor of a double-buffered window is drawn
  168.           to  with a GC having a subwindow-mode of IncludeIn-
  169.           feriors, the effect on the double-buffered window's
  170.           back  buffer  depends  on     the depth of the double-
  171.           buffered window and the ancestor.      If  the  depths
  172.           are  the    same,  the contents of the back buffer of
  173.           the double-buffered window are not changed.  If the
  174.           depths  are  different,  the  contents  of the back
  175.           buffer of the double-buffered window are    undefined
  176.           for  the    pixels    that the IncludeInferiors drawing
  177.           touched.
  178.  
  179.           DBE adds no new events.  DBE does     not  extend  the
  180.           semantics of any existing events with the exception
  181.           of adding a  new    drawable  type    called    _X_d_b_e_B_a_c_k_-
  182.           _B_u_f_f_e_r_.
  183.  
  184.           If  events, replies, or errors that contain a draw-
  185.           able  (e.g.,  GraphicsExpose)  are   generated   in
  186.           response    to  a request, the drawable returned will
  187.           be the one specified in the request.
  188.  
  189.           DBE advertises which visuals support double buffer-
  190.           ing.
  191.  
  192.           DBE  does not include any timing or synchronization
  193.  
  194.  
  195.  
  196. X Version 11           Release 6.1                3
  197.  
  198.  
  199.  
  200.  
  201.  
  202. DBE(3X11)           X FUNCTIONS            DBE(3X11)
  203.  
  204.  
  205.           facilities.  Applications that need such facilities
  206.           (e.g.,  to  maintain  a constant frame rate) should
  207.           investigate the  Synchronization    Extension,  an    X
  208.           Consortium standard.
  209.  
  210.        WWiinnddooww MMaannaaggeemmeenntt OOppeerraattiioonnss
  211.  
  212.           The  basic  philosophy  of DBE is that both buffers
  213.           are treated the same by X window management  opera-
  214.           tions.
  215.  
  216.           When  a  double-buffered    window is destroyed, both
  217.           buffers associated with the window  are  destroyed,
  218.           and  all back buffer names associated with the win-
  219.           dow are freed.
  220.  
  221.           If the size of a    double-buffered     window     changes,
  222.           both  buffers assume the new size.  If the window's
  223.           size increases, the effect on the     buffers  depends
  224.           on  whether  the    implementation honors bit gravity
  225.           for buffers.  If bit gravity is  implemented,  then
  226.           the  contents  of     both buffers are moved in accor-
  227.           dance  with  the    window's  bit  gravity,     and  the
  228.           remaining     areas    are  tiled  with the window back-
  229.           ground.  If bit gravity is  not  implemented,  then
  230.           the  entire  unobscured  region  of both buffers is
  231.           tiled with the window background.     In either  case,
  232.           Expose  events are generated for the region that is
  233.           tiled with the window background.
  234.  
  235.           If the XXGGeettGGeeoommeettrryy(()) function is     executed  on  an
  236.           _X_d_b_e_B_a_c_k_B_u_f_f_e_r_, the returned x, y, and border-width
  237.           will be zero.
  238.  
  239.           If the Shape extension SShhaappeeRReeccttaanngglleess,,  SShhaappeeMMaasskk,,
  240.           SShhaappeeCCoommbbiinnee,, or SShhaappeeOOffffsseett request is executed on
  241.           a double-buffered window, both buffers are reshaped
  242.           to  match the new window shape.  The region differ-
  243.           ence D = new shape - old shape is     tiled    with  the
  244.           window  background  in  both  buffers,  and  Expose
  245.           events are generated for D.
  246.  
  247.        CCoommpplleexx SSwwaapp AAccttiioonnss
  248.  
  249.           DBE has no explicit knowledge of ancillary  buffers
  250.           (e.g. depth buffers or alpha buffers), and only has
  251.           a limited set of defined swap actions.  Some appli-
  252.           cations  may need a richer set of swap actions than
  253.           DBE provides.  Some DBE implementations have knowl-
  254.           edge  of    ancillary  buffers,  and/or can provide a
  255.           rich set of swap actions.     Instead  of  continually
  256.           extending     DBE to increase its set of swap actions,
  257.           DBE provides a flexible "idiom" mechanism.   If  an
  258.           applications's needs are served by the defined swap
  259.  
  260.  
  261.  
  262. X Version 11           Release 6.1                4
  263.  
  264.  
  265.  
  266.  
  267.  
  268. DBE(3X11)           X FUNCTIONS            DBE(3X11)
  269.  
  270.  
  271.           actions, it should use them; otherwise,  it  should
  272.           use  the    following  method of expressing a complex
  273.           swap action as an     idiom.      Following  this  policy
  274.           will  ensure the best possible performance across a
  275.           wide variety of implementations.
  276.  
  277.           As suggested by the term "idiom,"     a  complex  swap
  278.           action  should  be  expressed  as a group/series of
  279.           requests.     Taken together, this group  of     requests
  280.           may  be  combined     into  an atomic operation by the
  281.           implementation, in order to  maximize  performance.
  282.           The set of idioms actually recognized for optimiza-
  283.           tion is implementation  dependent.   To  help  with
  284.           idiom  expression and interpretation, an idiom must
  285.           be surrounded by two function  calls:  XXddbbeeBBeeggiinnIIdd--
  286.           iioomm(())  and  XXddbbeeEEnnddIIddiioomm(())..   Unless this begin-end
  287.           pair surrounds the idiom, it may not be  recognized
  288.           by  a  given  implementation,  and performance will
  289.           suffer.
  290.  
  291.           For  example,  if     an  application  wants     to  swap
  292.           buffers  for  two     windows, and use X to clear only
  293.           certain planes of the back buffers, the application
  294.           would  make  the following calls as a group, and in
  295.           the following order:
  296.  
  297.              XXddbbeeBBeeggiinnIIddiioomm(())..
  298.  
  299.              XXddbbeeSSwwaappBBuuffffeerrss(()) with XIDs for two windows,
  300.              each   of     which    uses  a     swap  action  of
  301.              Untouched.
  302.  
  303.              XXFFiillllRReeccttaannggllee(()) to the back buffer  of  one
  304.              window.
  305.  
  306.              XXFFiillllRReeccttaannggllee(())  to  the back buffer of the
  307.              other window.
  308.  
  309.              XXddbbeeEEnnddIIddiioomm(())..
  310.  
  311.           The XXddbbeeBBeeggiinnIIddiioomm(()) and    XXddbbeeEEnnddIIddiioomm(())    functions
  312.           do  not  perform    any actions themselves.     They are
  313.           treated as markers by implementations that can com-
  314.           bine  certain  groups/series of requests as idioms,
  315.           and are ignored by  other     implementations  or  for
  316.           non-recognized groups/series of requests.     If these
  317.           function calls are made out of order, or    are  mis-
  318.           matched,    no errors are sent, and the functions are
  319.           executed as usual, though performance may suffer.
  320.  
  321.           XXddbbeeSSwwaappBBuuffffeerrss(()) need not be included in an idiom.
  322.           For example, if a swap action of Copied is desired,
  323.           but only some of the planes should be copied, XXCCoopp--
  324.           yyAArreeaa(())  may  be used instead of XXddbbeeSSwwaappBBuuffffeerrss(())..
  325.  
  326.  
  327.  
  328. X Version 11           Release 6.1                5
  329.  
  330.  
  331.  
  332.  
  333.  
  334. DBE(3X11)           X FUNCTIONS            DBE(3X11)
  335.  
  336.  
  337.           If XXddbbeeSSwwaappBBuuffffeerrss(()) is included in  an  idiom,  it
  338.           should   immediately  follow  the     XXddbbeeBBeeggiinnIIddiioomm(())
  339.           call.  Also, when the XXddbbeeSSwwaappBBuuffffeerrss(()) is included
  340.           in  an idiom, that request's swap action will still
  341.           be valid, and if the swap action might overlap with
  342.           another request, then the final result of the idiom
  343.           must be as if the separate requests  were     executed
  344.           serially.      For  example,     if  the  specified  swap
  345.           action is     Untouched,  and  if  a     XXFFiillllRReeccttaannggllee(())
  346.           using  a    client clip rectangle is done to the win-
  347.           dow's back buffer after the XXddbbeeSSwwaappBBuuffffeerrss(()) call,
  348.           then the contents of the new back buffer (after the
  349.           idiom) will be the same as if  the  idiom     was  not
  350.           recognized by the implementation.
  351.  
  352.           It is highly recommended that API providers define,
  353.           and application developers use, "convenience" func-
  354.           tions  that  allow  client applications to call one
  355.           procedure that encapsulates common  idioms.   These
  356.           functions      will     generate  the    XXddbbeeBBeeggiinnIIddiioomm(()),,
  357.           idiom, and XXddbbeeEEnnddIIddiioomm(()) calls.     Usage    of  these
  358.           functions     will  ensure  best  possible performance
  359.           across a wide variety of implementations.
  360.  
  361. SSEEEE AALLSSOO
  362.        _X_d_b_e_A_l_l_o_c_a_t_e_B_a_c_k_B_u_f_f_e_r_N_a_m_e_(_)_, _X_d_b_e_B_e_g_i_n_I_d_i_o_m_(_)_,    _X_d_b_e_D_e_a_l_-
  363.        _l_o_c_a_t_e_B_a_c_k_B_u_f_f_e_r_N_a_m_e_(_)_,     _X_d_b_e_E_n_d_I_d_i_o_m_(_)_,  _X_d_b_e_F_r_e_e_V_i_s_u_a_l_-
  364.        _I_n_f_o_(_)_,     _X_d_b_e_G_e_t_B_a_c_k_B_u_f_f_e_r_A_t_t_r_i_b_u_t_e_s_(_)_,       _X_d_b_e_G_e_t_V_i_s_u_a_l_-
  365.        _I_n_f_o_(_)_, _X_d_b_e_Q_u_e_r_y_E_x_t_e_n_s_i_o_n_(_)_, _X_d_b_e_S_w_a_p_B_u_f_f_e_r_s_(_)_.
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394. X Version 11           Release 6.1                6
  395.  
  396.  
  397.