1X11::Protocol::Ext::DOUUBsLeEr_BCUoFnFtErRi(b3u)ted PerlX1D1o:c:uPmreonttoactoilo:n:Ext::DOUBLE_BUFFER(3)
2
3
4

NAME

6       X11::Protocol::Ext::DOUBLE_BUFFER - window off-screen double buffering
7

SYNOPSIS

9        use X11::Protocol;
10        $X = X11::Protocol->new;
11        $X->init_extension('DOUBLE-BUFFER')
12          or print "DOUBLE-BUFFER extension not available";
13

DESCRIPTION

15       The DOUBLE-BUFFER extension lets a program draw into an off-screen
16       "back buffer" on a window and when ready swap it to the user-visible
17       "front".  A back buffer is a drawable with the same size, depth,
18       visibility, etc as the window proper.
19
20       Drawing off-screen then swapping to visible is good for smooth frame by
21       frame animations or if some drawing is complex or poorly implemented
22       and has clears or overwriting which would flash if done directly to the
23       window.
24
25       Off-screen drawing can also be implemented by a pixmap and copy into
26       the window but the server might implement a back buffer more
27       efficiently.  In particular the back buffer only needs to be visible
28       portions of a window so memory is not used for overlapped areas.
29
30       The server might support double buffering only on certain visuals.
31       DbeGetVisualInfo() lists those which are supported, or just try to
32       create a back buffer for a window and watch for an error reply.
33
34       See examples/dbe-swap.pl for a simple program drawing with double
35       buffering.
36

REQUESTS

38       The following requests are made available with an init_extension() per
39       "EXTENSIONS" in X11::Protocol.
40
41           my $bool = $X->init_extension('DOUBLE-BUFFER');
42
43       "($server_major, $server_minor) = $X->DbeGetVersion ($client_major,
44       $client_minor)"
45           Negotiate a protocol version with the server.  $client_major and
46           $client_minor is what the client would like, the returned
47           $server_major and $server_minor is what the server will do, which
48           might be less than requested (but not higher).
49
50           The code here supports 1.0 and automatically negotiates within
51           init_extension() so direct use of DbeGetVersion() is not necessary.
52
53       "$X->DbeAllocateBackBufferName ($window, $buffer, $action_hint)"
54           Create $buffer (a new XID) as the back buffer on $window.  $buffer
55           is a drawable and can be used with all usual drawing operations.
56
57               my $buffer = $X->new_rsrc;
58               $X->DbeAllocateBackBufferName ($window, $buffer, 'Copied');
59
60           $action_hint is the most likely $action in later DbeSwapBuffers()
61           requests (see below).  But this is just a hint and doesn't restrict
62           what can be done.
63
64           If $window is already double buffered then $buffer becomes another
65           reference to that back buffer.
66
67           If $window is destroyed (DestroyWindow()) then $buffer continues to
68           exist and should still be deallocated (below), but attempting to
69           draw into it gives a "Resource" error reply.
70
71       "$X->DbeDellocateBackBufferName ($buffer)"
72           Deallocate $buffer and release that XID.
73
74           If multiple DbeAllocateBackBufferName() requests have been made on
75           a window then all the other XIDs continue to refer to the window
76           back buffer.  The underlying buffer remains until all buffer XIDs
77           for it are deallocated.
78
79       "$X->DbeSwapBuffers ($window1,$action1, $window2,$action2,...)"
80           Swap the front and back buffers on each given $window (XIDs).  The
81           back buffer becomes visible and what was the front becomes the
82           back.
83
84             $X->DbeSwapBuffers ($window1, 'Background',
85                                 $window2, 'Untouched');
86
87           Only the content is swapped, the XIDs are unchanged, so $window is
88           still the visible window front and any $buffer XIDs to it are still
89           the back.
90
91           The contents of each back buffer after swapping are controlled by
92           the corresponding $action for each window (string type
93           "DbeSwapAction"),
94
95                $action        new back buffer contents
96               ---------       --------------------------
97               "Undefined"     undefined contents
98               "Background"    cleared to the window background
99               "Untouched"     left at current content (previous visible)
100               "Copied"        content of the old back buffer (unchanged)
101
102           "Untouched" means the contents of the front buffer are swapped to
103           the back buffer unchanged.
104
105           "Copied" is as if the back buffer content is copied to the front,
106           making both now the same.
107
108       "$X->DbeBeginIdiom ()"
109       "$X->DbeEndIdiom ()"
110           Hint to the server that a sequence of swap and/or drawing
111           operations between Begin and End might be done as an atomic
112           combination for higher performance.  If the server doesn't
113           recognise the sequence then it runs it sequentially as normal.
114
115           If a DbeSwapBuffers() is in the idiom then it should be the first
116           request, immediately following the Begin.
117
118               # swap then clear back buffer to a GC stipple
119               # no guarantee any server would actually optimize this!
120               $X->DbeBeginIdiom;
121               $X->DbeSwapBuffers ($window, 'Undefined');
122               $X->PolyFillRectangle ($buffer, $gc, [0,0,$width,$height]);
123               $X->DbeEndIdiom;
124
125           There doesn't need to be a swap in an idiom.  For example a
126           CopyArea() of some parts of the back buffer to the window might be
127           in a Begin/End and might perhaps be optimized by the server.
128
129               $X->DbeBeginIdiom;
130               $X->CopyArea ($buffer, $window,  # from buffer to window
131                             $gc, $x,$y,$width,$height, $dstx,$dsty);
132               # more stuff ...
133               $X->DbeEndIdiom;
134
135           The idea of idiom groupings is to have a flexible way to express
136           combination operations, including things not yet imagined, rather
137           than adding specific requests to the protocol.  In principle the
138           server can always optimize consecutive requests but that depends on
139           them arriving at the server together.  A DbeBeginIdiom() is like
140           permission to the server to defer performing the requests and wait,
141           if it wishes, to see if what follows can be combined.
142
143       "@infos = $X->DbeGetVisualInfo ($drawable1, $drawable2, ...)"
144       "@infos = $X->DbeGetVisualInfo ()"
145           For each $drawable, return a list of the visual IDs on that screen
146           which support double-buffering.
147
148               my ($info_aref_drawable1, $info_aref_drawable2)
149                 = $X->DbeGetVisualInfo ($drawable1, $drawable2);
150
151           If no drawables are given then return information about each screen
152           on the server.
153
154               my @list_of_info_aref = $X->DbeGetVisualInfo ();
155
156           Each returned value is an arrayref.  Each arrayref contains a list
157           of visual ID and visual data pairs,
158
159               # each $info_aref is
160               [ $visual_id1, [ $depth, $perflevel ],
161                 $visual_id2, [ $depth, $perflevel ],
162                 ...
163               ]
164
165           $depth is the visual's depth the same as in the server info
166           "$X->{'visuals'}->{$visual_id}->{'depth'}".
167
168           $perflevel is an integer indicating how good the performance of
169           double buffering is on this visual.  A higher value means higher
170           performance, but the actual number has no meaning and in particular
171           cannot be compared between different servers.
172
173           If enquiring about a single drawable's screen then use a list
174           context like the following.  The result in scalar context is
175           unspecified as yet.
176
177               my ($info_aref) = $X->DbeGetVisualInfo ($X->root);
178
179           The visual+perf are pairs so they can be put into a hash to check
180           support for double buffering on a given visual,
181
182               my %hash = @$info_aref;   # pairs $visualid => [$d,$p]
183               if ($hash{$my_visual_id}) {
184                 print "double buffering is available on my_visual_id\n";
185               }
186
187           If you've got a choice of equally suitable visuals for application
188           display then the performance level might be compared to choose the
189           best.
190
191           "List::Pairwise" has some grep and map functions for pair lists
192           like the $info_aref.
193
194           See examples/dbe-info.pl for a simple program printing this info.
195
196       "$window = $X->DbeGetBackBufferAttributes ($buffer)"
197           Return the window (an integer XID) which $buffer is for.  If its
198           target window has been destroyed (DestroyWindow()) then the return
199           is "None".
200

ENUM TYPES

202       The following types are available for "$X->interp()" and "$X->num()",
203       after init_extension().
204
205       DbeSwapAction
206               "Undefined"    0
207               "Background"   1
208               "Untouched"    2
209               "Copied"       3
210
211       For example,
212
213           my $num = $X->num("DbeSwapAction", "Background");
214           # sets $num to 2
215

BUGS

217       In some XFree86 3.x servers there was a bug in DbeGetVisualInfo() where
218       the reply length was miscalculated, being bytes instead of CARD32s,
219       resulting in a length value bigger than the actual data sent.  The
220       symptom is the client hangs waiting for data the length says should
221       follow but which never does.
222
223       This affects all client code, including the Xlib XdbeGetVisualInfo() as
224       used for instance by the "xdpyinfo" program.
225
226       Is there a good way to notice the problem?  Probably not beyond looking
227       at the server name and version and either forbidding the request or
228       doing something nasty to the way handle_input() reads as a workaround.
229

SEE ALSO

231       X11::Protocol, X11::Protocol::Ext::Composite
232
233       /usr/share/doc/x11proto-xext-dev/dbe.txt.gz
234

HOME PAGE

236       <http://user42.tuxfamily.org/x11-protocol-other/index.html>
237

LICENSE

239       Copyright 2011, 2012, 2013, 2014, 2017 Kevin Ryde
240
241       X11-Protocol-Other is free software; you can redistribute it and/or
242       modify it under the terms of the GNU General Public License as
243       published by the Free Software Foundation; either version 3, or (at
244       your option) any later version.
245
246       X11-Protocol-Other is distributed in the hope that it will be useful,
247       but WITHOUT ANY WARRANTY; without even the implied warranty of
248       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
249       General Public License for more details.
250
251       You should have received a copy of the GNU General Public License along
252       with X11-Protocol-Other.  If not, see <http://www.gnu.org/licenses/>.
253
254
255
256perl v5.36.0                      2023-01-2X011::Protocol::Ext::DOUBLE_BUFFER(3)
Impressum