X11/Protocol/Ext/DOUBLE_BUFFER.pm

filter: Statementstmt 35.7% 25 / 70 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 36.8% 7 / 19 Podpod 0.0% 0 / 1 totaltotal 31.6% 32 / 101 CC 6 SCAR 13.8
CC
6
Cov
32%
_interp_none
12.0
__ANON__
6.0
_ext_requests_install
6.0
CRAP 4.0
« X11/Protocol/Ext/X_Resource.pm ↑ Summary X11/Protocol/Ext/Composite.pm »
1 # Copyright 2011, 2012, 2013, 2014, 2017 Kevin Ryde
2  
3 # This file is part of X11-Protocol-Other.
4 #
5 # X11-Protocol-Other is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as published
7 # by the Free Software Foundation; either version 3, or (at your option) any
8 # later version.
9 #
10 # X11-Protocol-Other is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13 # Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with X11-Protocol-Other. If not, see <http://www.gnu.org/licenses/>.
17  
18  
19 # /usr/share/doc/x11proto-xext-dev/dbe.txt.gz
20 # /usr/share/doc/x11proto-core-dev/x11protocol.txt.gz
21 # /usr/include/X11/extensions/dbe.h
22 # /usr/include/X11/extensions/dbeproto.h
23 # Protocol.
24 #
25 # /usr/share/doc/libxext-dev/dbelib.txt.gz
26 # /so/xfree/xfree86-3.3.2.3a/lib/Xext/Xdbe.c
27 # Xlib.
28 #
29 # /so/xfree/xfree86-3.3.2.3a/programs/Xserver/dbe/dbe.c
30 # /so/xorg/xorg-server-1.10.0/dbe/dbe.c
31 # Server.
32  
33  
34 1 ▶BEGIN { require 5 }
Subroutine BEGIN: called CC=1 SCAR=0.0
35 package X11::Protocol::Ext::DOUBLE_BUFFER;
36 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 ▶use X11::Protocol;
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 1 ▶use vars '$VERSION', '@CARP_NOT';
Subroutine BEGIN: called CC=1 SCAR=0.0
41 1 $VERSION = 31;
42 1 @CARP_NOT = ('X11::Protocol');
43  
44 # uncomment this to run the ### lines
45 #use Smart::Comments;
46  
47  
48 # these not documented yet ...
49 1 ▶use constant CLIENT_MAJOR_VERSION => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 1 ▶use constant CLIENT_MINOR_VERSION => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 my $reqs =
53 [
54 [ 'DbeGetVersion', # 0
55 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
56 0 my ($X, $client_major, $client_minor) = @_;
57 ### DbeGetVersion request
58 0 return pack 'CCxx', $client_major, $client_minor;
59 },
60 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
61 0 my ($X, $data) = @_;
62 0 return unpack 'x8CC', $data;
63 }],
64  
65 [ 'DbeAllocateBackBufferName', # 1
66 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
67 0 my ($X, $window, $buffer, $action_hint) = @_;
68 ### DbeAllocateBackBufferName request
69 0 return pack 'LLCxxx',
70 $window, $buffer, $X->num('DbeSwapAction',$action_hint);
71 } ],
72  
73 [ 'DbeDeallocateBackBufferName', # 2
74 \&_request_card32s ], # ($X,$buffer)
75  
76 [ 'DbeSwapBuffers', # 3
77 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
78 0 my $X = shift; # ($X, $window,$action, $window,$action, ...)
79 0 my $ret = pack 'L', scalar(@_)/2; # number of pairs
80 0 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
81 0 $ret .= pack 'LCxxx', shift, $X->num('DbeSwapAction',shift);
82 }
83 0 return $ret;
84 }],
85  
86 [ 'DbeBeginIdiom', # 4
87 \&_request_empty ],
88 [ 'DbeEndIdiom', # 5
89 \&_request_empty ],
90  
91 [ 'DbeGetVisualInfo', # 6
92 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
93 ### DbeGetVisualInfo request ...
94 0 my $X = shift; # ($X, $window, $window, ...)
95 ### num_windows: scalar(@_)
96 ### windows: @_
97 0 return pack 'L*', scalar(@_), @_; # (num_windows, window, window, ...)
98 },
99 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
100 0 my ($X, $data) = @_;
101 ### DbeGetVisualInfo reply ...
102  
103 0 my $num_screens = unpack 'x8L', $data;
104 ### $num_screens
105  
106 0 my $pos = 32;
107 # Maybe should return single aref in scalar context.
108 # The map{} ends up giving a count in scalar context (or does it?).
109 return map {
110 0 my $num_visuals = unpack 'L', substr($data,$pos,4);
111 0 $pos += 4;
112 0 [ map { my ($visual_id, $depth, $performance)
113 = unpack 'LCC', substr($data,($pos+=8)-8,6);
114 0 $visual_id => [ $depth, $performance ] }
115 1 .. $num_visuals ]
116 } 1 .. $num_screens;
117 }],
118  
119 [ 'DbeGetBackBufferAttributes', # 7
120 \&_request_card32s, # ($X,$buffer)
121 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
122 0 my ($X, $data) = @_;
123 0 return _interp_none($X, unpack('x8L',$data));
124 1 }],
125  
126 ];
127  
128 1 my $DbeSwapAction_array = ['Undefined', 'Background', 'Untouched', 'Copied'];
129 1 my $DbeSwapAction_hash
130 = { X11::Protocol::make_num_hash($DbeSwapAction_array) };
131  
132 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
133 0 my ($class, $X, $request_num, $event_num, $error_num) = @_;
134 ### DOUBLE_BUFFER new() ...
135  
136 # Constants
137 0 $X->{'ext_const'}->{'DbeSwapAction'} = $DbeSwapAction_array;
138 0 $X->{'ext_const_num'}->{'DbeSwapAction'} = $DbeSwapAction_hash;
139  
140 0 _ext_requests_install ($X, $request_num, $reqs);
141  
142 # Protocol spec says must negotiate version or the extension may or may
143 # not work.
144 0 my ($server_major, $server_minor) = $X->req('DbeGetVersion', 1, 0);
145 ### $server_major
146 ### $server_minor
147 0 return bless { major => $server_major,
148 minor => $server_minor,
149 }, $class;
150 }
151  
152 0 ▶sub _ext_requests_install {
Subroutine _ext_requests_install: not called CC=2 SCAR=17.9
153 0 my ($X, $request_num, $reqs) = @_;
154  
155 0 $X->{'ext_request'}->{$request_num} = $reqs;
156 0 my $href = $X->{'ext_request_num'};
157 0 my $i;
158 0 foreach $i (0 .. $#$reqs) {
159 0 $href->{$reqs->[$i]->[0]} = [$request_num, $i];
160 }
161 }
162  
163 0 ▶sub _request_empty {
Subroutine _request_empty: not called CC=2 SCAR=17.9
164 0 ▶ if (@_ > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
165 0 croak "No parameters in this request";
166 }
167 0 return '';
168 }
169  
170 0 ▶sub _request_card32s {
Subroutine _request_card32s: not called CC=1 SCAR=6.9
171 0 shift;
172 ### _request_card32s(): @_
173 0 return pack 'L*', @_;
174 }
175  
176 0 ▶sub _interp_none {
Subroutine _interp_none: not called CC=3 SCAR=24.8
177 0 my ($X, $xid) = @_;
178 0 ▶ if ($X->{'do_interp'} && $xid == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($X->{'do_interp'} and $xid == 0) { } 0 0 0
Condition0%0/3
$X->{"do_interp"} and $xid == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$X->{"do_interp"} and $xid == 0
$X->{"do_interp"} $xid == 0
Truth table0%0/3
A and B
A= $X->{"do_interp"}B= $xid == 0
ABresult
0X0
100
111
179 0 return 'None';
180 } else {
181 0 return $xid;
182 }
183 }
184  
185 1 1;
186 __END__
« X11/Protocol/Ext/X_Resource.pm ↑ Summary X11/Protocol/Ext/Composite.pm »