1
/* $Xorg: query.c,v 1.4 2001/02/09 02:05:48 xorgcvs Exp $ */
3
/**** module query.c ****/
4
/******************************************************************************
6
Copyright 1993, 1994, 1998 The Open Group
8
Permission to use, copy, modify, distribute, and sell this software and its
9
documentation for any purpose is hereby granted without fee, provided that
10
the above copyright notice appear in all copies and that both that
11
copyright notice and this permission notice appear in supporting
14
The above copyright notice and this permission notice shall be included in
15
all copies or substantial portions of the Software.
17
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
Except as contained in this notice, the name of The Open Group shall not be
25
used in advertising or otherwise to promote the sale, use or other dealings
26
in this Software without prior written authorization from The Open Group.
31
This software is being provided by AGE Logic, Inc. under the
32
following license. By obtaining, using and/or copying this software,
33
you agree that you have read, understood, and will comply with these
36
Permission to use, copy, modify, distribute and sell this
37
software and its documentation for any purpose and without
38
fee or royalty and to grant others any or all rights granted
39
herein is hereby granted, provided that you agree to comply
40
with the following copyright notice and statements, including
41
the disclaimer, and that the same appears on all copies and
42
derivative works of the software and documentation you make.
44
"Copyright 1993, 1994 by AGE Logic, Inc."
46
THIS SOFTWARE IS PROVIDED "AS IS". AGE LOGIC MAKES NO
47
REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. By way of
48
example, but not limitation, AGE LOGIC MAKE NO
49
REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS
50
FOR ANY PARTICULAR PURPOSE OR THAT THE SOFTWARE DOES NOT
51
INFRINGE THIRD-PARTY PROPRIETARY RIGHTS. AGE LOGIC
52
SHALL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE. IN NO
53
EVENT SHALL EITHER PARTY BE LIABLE FOR ANY INDIRECT,
54
INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS
55
OF PROFITS, REVENUE, DATA OR USE, INCURRED BY EITHER PARTY OR
56
ANY THIRD PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT OR
57
BASED ON A WARRANTY, EVEN IF AGE LOGIC LICENSEES
58
HEREUNDER HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
61
The name of AGE Logic, Inc. may not be used in
62
advertising or publicity pertaining to this software without
63
specific, written prior permission from AGE Logic.
65
Title to this software shall at all times remain with AGE
67
*****************************************************************************
69
query.c -- query flo element test
71
Syd Logan -- AGE Logic, Inc.
73
*****************************************************************************/
74
/* $XFree86: xc/programs/xieperf/query.c,v 1.6 2001/12/14 20:01:51 dawes Exp $ */
80
static XiePhotomap XIEPhotomap;
81
static XieLut PhotofloTestLut1, PhotofloTestLut2;
82
static XieColorList XIEColorList;
84
static int flo_elements;
85
static XiePhotoElement *flograph;
86
static XiePhotoflo flo;
89
InitQueryTechniques(XParms xp, Parms p, int reps)
95
InitQueryColorList(XParms xp, Parms p, int reps)
97
/* allocate a color list */
99
if ( !(XIEColorList = XieCreateColorList( xp->d ) ) )
101
fprintf( stderr, "XieCreateColorList failed\n" );
108
InitQueryPhotomap(XParms xp, Parms p, int reps)
111
GetXIEPhotomap( xp, p, 1 ) ) == ( XiePhotomap ) NULL )
119
InitQueryPhotoflo(XParms xp, Parms p, int reps)
121
int lutSize, lutLevels;
122
unsigned char *lut1, *lut2;
126
flograph = ( XiePhotoElement * ) NULL;
127
flo = ( XiePhotoflo ) NULL;
128
lut1 = lut2 = ( unsigned char * ) NULL;
129
PhotofloTestLut1 = PhotofloTestLut2 = ( XieLut ) NULL;
132
flograph = XieAllocatePhotofloGraph(flo_elements);
133
lutSize = ( ( QueryParms * ) p->ts )->lutSize;
134
lutLevels = ( ( QueryParms * ) p->ts )->lutLevels;
135
if ( flograph == ( XiePhotoElement * ) NULL )
137
fprintf( stderr, "XieAllocatePhotofloGraph failed\n" );
142
lut1 = (unsigned char *)
143
malloc( lutSize * sizeof( unsigned char ) );
144
if ( lut1 == ( unsigned char * ) NULL )
148
lut2 = (unsigned char *)
149
malloc( lutSize * sizeof( unsigned char ) );
150
if ( lut2 == ( unsigned char * ) NULL )
159
if ( ( PhotofloTestLut1 = GetXIELut( xp, p, lut1, lutSize,
160
lutLevels ) ) == ( XieLut ) NULL )
164
else if ( ( PhotofloTestLut2 = GetXIELut( xp, p, lut2, lutSize,
165
lutLevels ) ) == ( XieLut ) NULL )
174
XieFloImportLUT(&flograph[0], PhotofloTestLut1 );
181
XieFloExportLUT(&flograph[1],
182
1, /* source phototag number */
187
flo = XieCreatePhotoflo( xp->d, flograph, flo_elements );
191
FreeQueryPhotofloStuff( xp, p );
202
DoQueryTechniques(XParms xp, Parms p, int reps)
204
XieTechniqueGroup techGroup;
205
XieTechnique *techVector;
208
techGroup = ( ( QueryParms * ) p->ts )->techGroup;
210
for ( i = 0; i < reps; i++ )
212
if ( !XieQueryTechniques( xp->d, techGroup, &numTech,
215
fprintf( stderr, "XieQueryTechniques: failed\n" );
221
for ( j = 0; j < numTech; j++ )
223
if ( techVector[ j ].name )
224
XFree( techVector[ j ].name );
229
techVector = ( XieTechnique * ) NULL;
235
DoQueryColorList(XParms xp, Parms p, int reps)
239
unsigned int ncolors;
240
unsigned long *colors;
242
for ( i = 0; i < reps; i++ )
244
colors = ( unsigned long * ) NULL;
245
if ( !XieQueryColorList( xp->d, XIEColorList, &cmap,
246
&ncolors, &colors ) )
248
fprintf( stderr, "XieQueryColorList failed\n" );
252
/* for alpha, the colorlist is empty. This will change
255
if ( cmap != ( Colormap ) 0 )
257
fprintf( stderr, "XieQueryColorList returned non-zero colormap\n" );
262
fprintf( stderr, "XieQueryColorList returned non-zero ncolors\n" );
265
if ( colors != ( unsigned long * ) NULL )
267
fprintf( stderr, "XieQueryColorList returned non-NULL colorlist\n" );
274
DoQueryPhotomap(XParms xp, Parms p, int reps)
280
XieDataType data_type;
283
XieDecodeTechnique decode;
286
image = p->finfo.image1;
291
for ( i = 0; i < reps && error == False; i++ )
293
if ( !XieQueryPhotomap( xp->d, XIEPhotomap, &pop, &data_type,
294
&cclass, &decode, width, height, levels ) )
296
fprintf( stderr, "XieQueryPhotomap failed\n" );
300
if ( levels[ 0 ] != image->levels[ 0 ] )
302
fprintf( stderr, "XieQueryPhotomap levels return invalid should be 0x%lx got 0x%lx\n", image->levels[ 0 ], levels[ 0 ] );
306
if ( width[ 0 ] != image->width[ 0 ] )
308
fprintf( stderr, "XieQueryPhotomap width return invalid should be 0x%x got 0x%lx\n", image->width[ 0 ], width[ 0 ] );
312
if ( height[ 0 ] != image->height[ 0 ] )
314
fprintf( stderr, "XieQueryPhotomap height return invalid should be 0x%x got 0x%lx\n", image->height[ 0 ], height[ 0 ] );
322
DoQueryPhotoflo(XParms xp, Parms p, int reps)
325
XiePhotofloState state;
326
XiePhototag *expected, *avail;
327
unsigned int nexpected, navail;
329
for ( i = 0; i < reps; i++ )
331
if ( !XieQueryPhotoflo( xp->d, 0, flo, &state, &expected,
332
&nexpected, &avail, &navail ) )
334
fprintf( stderr, "XieQueryPhotoflo failed\n" );
348
EndQueryTechniques(XParms xp, Parms p)
353
EndQueryColorList(XParms xp, Parms p)
355
FreeQueryColorListStuff( xp, p );
359
FreeQueryColorListStuff(XParms xp, Parms p)
363
XieDestroyColorList( xp->d, XIEColorList );
364
XIEColorList = ( XieColorList ) NULL;
369
EndQueryPhotomap(XParms xp, Parms p)
371
FreeQueryPhotomapStuff( xp, p );
375
FreeQueryPhotomapStuff(XParms xp, Parms p)
377
if ( XIEPhotomap && IsPhotomapInCache( XIEPhotomap ) == False )
379
XieDestroyPhotomap( xp->d, XIEPhotomap );
380
XIEPhotomap = ( XiePhotomap ) NULL;
385
EndQueryPhotoflo(XParms xp, Parms p)
387
FreeQueryPhotofloStuff( xp, p );
391
FreeQueryPhotofloStuff(XParms xp, Parms p)
393
if ( PhotofloTestLut1 )
395
XieDestroyLUT( xp->d, PhotofloTestLut1 );
396
PhotofloTestLut1 = ( XieLut ) NULL;
399
if ( PhotofloTestLut2 )
401
XieDestroyLUT( xp->d, PhotofloTestLut2 );
402
PhotofloTestLut2 = ( XieLut ) NULL;
407
XieFreePhotofloGraph(flograph,flo_elements);
408
flograph = ( XiePhotoElement * ) NULL;
413
XieDestroyPhotoflo( xp->d, flo );
414
flo = ( XiePhotoflo ) NULL;