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

ENUM TYPES

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

BUGS

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

SEE ALSO

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

HOME PAGE

238       <http://user42.tuxfamily.org/x11-protocol-other/index.html>
239

LICENSE

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