1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
|
Copyright (c) 2005 X.Org Foundation L.L.C.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
$Header: /cvs/xtest/xtest/xts5/tset/Xlib9/XCopyPlane/XCopyPlane.m,v 1.3 2005-11-03 08:43:52 jmichael Exp $
Copyright (c) 2003 The Open Group
Copyright (c) Applied Testing and Technology, Inc. 1995
All Rights Reserved.
>># Project: VSW5
>>#
>># File: xts5/tset/Xlib9/XCopyPlane/XCopyPlane.m
>>#
>># Description:
>># Tests for XCopyPlane()
>>#
>># Modifications:
>># $Log: cpypln.m,v $
>># Revision 1.3 2005-11-03 08:43:52 jmichael
>># clean up all vsw5 paths to use xts5 instead.
>>#
>># Revision 1.2 2005/04/21 09:40:42 ajosey
>># resync to VSW5.1.5
>>#
>># Revision 8.2 2005/01/21 10:51:46 gwc
>># Updated copyright notice
>>#
>># Revision 8.1 2003/12/08 12:27:28 gwc
>># PR2288: tp42 - changed (1<<vp->depth) to (1UL<<vp->depth)
>>#
>># Revision 8.0 1998/12/23 23:27:43 mar
>># Branch point for Release 5.0.2
>>#
>># Revision 7.0 1998/10/30 22:46:09 mar
>># Branch point for Release 5.0.2b1
>>#
>># Revision 6.0 1998/03/02 05:19:53 tbr
>># Branch point for Release 5.0.1
>>#
>># Revision 5.0 1998/01/26 03:16:23 tbr
>># Branch point for Release 5.0.1b1
>>#
>># Revision 4.1 1996/05/09 00:36:11 andy
>># Corrected Xproto include
>>#
>># Revision 4.0 1995/12/15 08:51:35 tbr
>># Branch point for Release 5.0.0
>>#
>># Revision 3.1 1995/12/15 00:52:37 andy
>># Prepare for GA Release
>>#
/*
Portions of this software are based on Xlib and X Protocol Test Suite.
We have used this material under the terms of its copyright, which grants
free use, subject to the conditions below. Note however that those
portions of this software that are based on the original Test Suite have
been significantly revised and that all such revisions are copyright (c)
1995 Applied Testing and Technology, Inc. Insomuch as the proprietary
revisions cannot be separated from the freely copyable material, the net
result is that use of this software is governed by the ApTest copyright.
Copyright (c) 1990, 1991 X Consortium
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.
Permission to use, copy, modify, distribute, and sell this software and
its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of UniSoft not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission. UniSoft
makes no representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied warranty.
*/
>>TITLE XCopyPlane Xlib9
void
XCopyPlane(display, src, dest, gc, src_x, src_y, width, height, dest_x, dest_y, plane);
Display *display = Dsp;
Drawable src;
Drawable dest;
GC gc;
int src_x = 6;
int src_y = 5;
unsigned int width = 30;
unsigned int height = 40;
int dest_x = 5;
int dest_y = 9;
unsigned long plane = 1;
>>EXTERN
#include "X11/Xproto.h"
#include "limits.h"
#define CPYPL_PIX 0x55555555
#define XOFF 50
#define TRIM 20
>>ASSERTION Good A
A call to xname
uses the
.M foreground
pixel in the GC for each bit
in
.A src
that is set to 1 and the
.M background
pixel in the GC for each bit in
.A src
that is set to 0 and
combines the specified rectangle of
.A src
with the specified rectangle of
.A dest .
>>#according to the
>>#.M function
>>#in the argument
>>#.A gc .
>>STRATEGY
Create pair of windows.
Fill one window with pixel having some bits set and some unset.
Call XCopyPlane to copy one plane of an area.
Check that the copied area is set to the foreground when
the plane contains 1 and background when the plane contains 0.
>>CODE
XVisualInfo *vp;
struct area area;
unsigned long depth;
unsigned long fg;
for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
winpair(display, vp, &src, &dest);
dset(display, src, CPYPL_PIX);
gc = makegc(display, dest);
depth = vp->depth;
for (plane = 1; depth-- > 0; plane <<= 1) {
XCALL;
area.x = dest_x;
area.y = dest_y;
area.width = width;
area.height = height;
/*
* Is the plane we are dealing with set to 1? In which case
* the area should be the foreground; or 0 in which case
* the area should be the background.
*/
fg = (plane & CPYPL_PIX)? W_FG: W_BG;
if (checkarea(display, dest, &area, fg, W_BG, CHECK_ALL)) {
if (plane == 1)
CHECK;
} else {
report("Window did not have expected contents");
FAIL;
}
}
}
CHECKPASS(nvinf());
>>ASSERTION def
A call to xname uses a single bit plane of the specified source rectangle
.A src
combined with the specified GC to modify the specified rectangle of
.A dest .
>># NOTE - In testing, what this means is that the contents of other
>># bit planes make no difference to the action of xname. DPJC
>>ASSERTION Good A
If the screen supports drawables of more than one depth:
.in +2
The drawables need not have the same depth.
.in -2
>>STRATEGY
If there is a visual with depth other than one.
Copy between it and a pixmap of depth one.
Else
Report UNSUPPORTED.
>>CODE
XVisualInfo *vp;
struct area area;
unsigned long depth;
unsigned long fg;
depth = 0;
for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
if (vp->depth != 1) {
depth = vp->depth;
break;
}
}
if (depth == 0) {
report("Only one depth is supported");
tet_result(TET_UNSUPPORTED);
return;
}
src = makewin(display, vp);
vp->depth = 1;
dest = makepixm(display, vp);
dset(display, src, CPYPL_PIX);
gc = makegc(display, dest);
for (plane = 1; depth-- > 0; plane <<= 1) {
XCALL;
area.x = dest_x;
area.y = dest_y;
area.width = width;
area.height = height;
/*
* Is the plane we are dealing with set to 1? In which case
* the area should be the foreground; or 0 in which case
* the area should be the background.
*/
fg = (plane & CPYPL_PIX)? W_FG: W_BG;
if (checkarea(display, dest, &area, fg, W_BG, CHECK_ALL)) {
if (plane == 1)
CHECK;
} else {
report("Window did not have expected contents");
FAIL;
}
}
CHECKPASS(1);
>>ASSERTION Good A
When regions of the source rectangle are obscured and have not been
retained in backing store
or regions outside the boundaries of the source drawable are specified,
then
those regions are not copied.
>>STRATEGY
make src window and draw into it (background of 0)
make dest window with background of 1 and draw into it
copy region that extends off the edge of the source drawable
verify that it is not copied.
>>CODE
Window w1, w2;
XVisualInfo *vp;
Pixmap pm;
struct area area;
/*
* I have taken this assertion to deal with pixmaps, while the similar
* one that mentions background tiling is used to deal with windows.
*/
for (resetvinf(VI_PIX); nextvinf(&vp); ) {
winpair(display, vp, &w1, &w2);
pattern(display, w1);
src = w1;
dest = w2;
gc = makegc(display, dest);
/*
* Use a width of the size of the window minus TRIM, therefore
* it will extend off the edge of the window by width-src_x pixels.
*/
getsize(display, w1, &width, (unsigned int*)0);
src_x = width-XOFF;
width -= TRIM;
dest_x = 0;
dest_y = 0;
plane = 1;
XCALL;
area.x = dest_x;
area.y = dest_y;
area.width = width;
area.height = height;
if (checkarea(display, dest, &area, 0, W_BG, CHECK_OUT) == False) {
report("window modified outside the target area");
FAIL;
} else
CHECK;
}
CHECKPASS(nvinf());
>>ASSERTION Good A
When regions of the source rectangle are obscured and have not been
retained in backing store
or regions outside the boundaries of the source drawable are specified
and the destination is a window with a background other than
.S None ,
then all corresponding destination regions that are either
visible or are retained in backing store
are tiled with that background
with plane-mask of all ones and
.S GXcopy
function.
>>STRATEGY
make src window and draw into it (background of 0)
make dest window with background of 1 and draw into it
copy region that extends off the edge of the source drawable
verify that it is not copied.
>>CODE
Window w1, w2;
XVisualInfo *vp;
Pixmap pm;
struct area area;
for (resetvinf(VI_WIN); nextvinf(&vp); ) {
winpair(display, vp, &w1, &w2);
pattern(display, w1);
src = w1;
dest = w2;
gc = makegc(display, dest);
/*
* Set the destination background pixmap.
*/
pm = maketile(display, w2);
XSetWindowBackgroundPixmap(display, w2, pm);
/*
* Use a width of the size of the window minus TRIM, therefore
* it will extend off the edge of the window by width-src_x pixels.
*/
getsize(display, w1, &width, (unsigned int*)0);
src_x = width-XOFF;
width -= TRIM;
dest_x = 0;
dest_y = 0;
plane = 1;
XCALL;
area.x = dest_x;
area.y = dest_y;
area.width = width;
area.height = height;
if (checkarea(display, dest, &area, 0, W_BG, CHECK_OUT) == False) {
report("window modified outside the target area");
FAIL;
} else
CHECK;
area.x = XOFF;
area.width = width - XOFF - TRIM;
if (checktile(display, dest, &area, 0, 0, pm) == False) {
report("area was not copied properly");
FAIL;
} else
CHECK;
}
CHECKPASS(2*nvinf());
>>ASSERTION Good A
When
.M graphics-exposures
is
.S True ,
then
.S GraphicsExpose
events for all corresponding destination regions are generated.
>>STRATEGY
Set graphics-exposures to True.
Enable All Events.
DO as above.
Check events received, and x,y,width,height in each.
>>CODE
Window w1, w2;
XEvent event;
XVisualInfo *vp;
XGraphicsExposeEvent ge;
int n;
for (resetvinf(VI_WIN); nextvinf(&vp); ) {
winpair(display, vp, &w1, &w2);
src = w1;
dest = w2;
getsize(display, w1, &width, (unsigned int*)0);
src_x = XOFF;
dest_x = 0;
plane = 1;
gc = makegc(display, dest);
XSelectInput(display, src, ALLEVENTS);
XCALL;
XSelectInput(display, dest, NoEventMask);
if (getevent(display, &event) != 1 || event.type != GraphicsExpose) {
report("Expecting one GraphicsExpose event");
FAIL;
return;
}
ge.type = GraphicsExpose;
ge.display = display;
ge.drawable = dest;
ge.x = dest_x+width-XOFF;
ge.y = dest_y;
ge.width = XOFF;
ge.height = height;
ge.count = 0;
ge.major_code = X_CopyPlane;
ge.minor_code = 0;
n = checkevent((XEvent*)&ge, &event);
if (n == 0)
CHECK;
else {
report("error in %d field%s of event", n, (n!=1)?"s":"");
tet_result(TET_FAIL);
}
}
CHECKPASS(nvinf());
>>ASSERTION Good A
When
.M graphics-exposures
is
.S True
and no
.S GraphicsExpose
events are generated, then a
.S NoExpose
event is generated.
>>STRATEGY
As above, but copy visable area
check for NoExpose event
>>CODE
Window w1, w2;
XEvent event;
XNoExposeEvent ge;
XVisualInfo *vp;
int n;
for (resetvinf(VI_WIN); nextvinf(&vp); ) {
winpair(display, vp, &w1, &w2);
src = w1;
dest = w2;
plane = 1;
gc = makegc(display, dest);
XSelectInput(display, src, ALLEVENTS);
XCALL;
XSelectInput(display, dest, NoEventMask);
if (getevent(display, &event) != 1 || event.type != NoExpose) {
report("Expecting one NoExpose event");
FAIL;
return;
}
ge.type = NoExpose;
ge.display = display;
ge.drawable = dest;
ge.major_code = X_CopyPlane;
ge.minor_code = 0;
n = checkevent((XEvent*)&ge, &event);
if (n == 0)
CHECK;
else {
report("error in %d field%s of event", n, (n!=1)?"s":"");
tet_result(TET_FAIL);
}
}
CHECKPASS(nvinf());
>>ASSERTION gc
On a call to xname the GC components
.M function ,
.M plane-mask ,
.M foreground ,
.M background ,
.M subwindow-mode ,
.M graphics-exposures ,
.M clip-x-origin ,
.M clip-y-origin ,
and
.M clip-mask
are used.
>>ASSERTION Bad A
.ER BadDrawable
>>ASSERTION Bad A
.ER BadGC
>>ASSERTION Bad A
.ER BadMatch inputonly
>>ASSERTION Bad A
.ER BadMatch gc-drawable-screen
>>ASSERTION Bad A
When the bit set in
.A plane
does not refer to a valid plane for the screen, then a
.S BadValue
error occurs.
>>STRATEGY
For each drawable type
Ignore those that have no invalid planes.
Call XCopyPlane with plane set to first invalid number.
Verify that a BadValue error occurred.
>>CODE BadValue
XVisualInfo *vp;
int unsupp = 0;
for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
/*
* If all planes are valid then a BadValue is not possible
* with this drawable
*/
if (vp->depth >= CHAR_BIT*sizeof(long)) {
trace("Visual with depth of %d, no planes invalid", vp->depth);
unsupp++;
continue;
}
winpair(display, vp, &src, &dest);
gc = makegc(display, dest);
plane = (1UL<<vp->depth);
XCALL;
if (geterr() == BadValue)
CHECK;
}
if (unsupp == nvinf()) {
/*
* This can't happen when we are including pixmaps since depth 1
* pixmap is always supported.
*/
report("All planes are valid on all drawables");
tet_result(TET_UNSUPPORTED);
return;
}
CHECKPASS(nvinf()-unsupp);
>>ASSERTION Bad A
When
.A plane
does not have exactly one bit set to 1, then
a
.S BadValue
error occurs.
>>STRATEGY
For each drawable type
Make window pair.
Call XCopyPlane with plane set to 0.
Verify that BadValue error occurs.
If depth is greater than 1
Call XCopyPlane with plane set to 3.
Verify that BadValue error occurs.
>>CODE BadValue
XVisualInfo *vp;
int unsupp = 0;
for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
winpair(display, vp, &src, &dest);
gc = makegc(display, dest);
plane = 0;
XCALL;
if (geterr() == BadValue)
CHECK;
if (vp->depth > 1) {
plane = 0x3;
XCALL;
if (geterr() == BadValue)
CHECK;
} else
unsupp++;
}
CHECKPASS(2*nvinf()-unsupp);
>># HISTORY steve Completed Written in new format and style
>># HISTORY kieron Completed Global and pixel checking to do - 19/11/90
>># HISTORY dave Completed Final checking to do - 21/11/90
|