1
/* $Xorg: pcnst.c,v 1.4 2001/02/09 02:04:20 xorgcvs Exp $ */
2
/**** module pcnst.c ****/
3
/******************************************************************************
5
Copyright 1993, 1994, 1998 The Open Group
7
Permission to use, copy, modify, distribute, and sell this software and its
8
documentation for any purpose is hereby granted without fee, provided that
9
the above copyright notice appear in all copies and that both that
10
copyright notice and this permission notice appear in supporting
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall not be
24
used in advertising or otherwise to promote the sale, use or other dealings
25
in this Software without prior written authorization from The Open Group.
30
This software is being provided by AGE Logic, Inc. under the
31
following license. By obtaining, using and/or copying this software,
32
you agree that you have read, understood, and will comply with these
35
Permission to use, copy, modify, distribute and sell this
36
software and its documentation for any purpose and without
37
fee or royalty and to grant others any or all rights granted
38
herein is hereby granted, provided that you agree to comply
39
with the following copyright notice and statements, including
40
the disclaimer, and that the same appears on all copies and
41
derivative works of the software and documentation you make.
43
"Copyright 1993, 1994 by AGE Logic, Inc."
45
THIS SOFTWARE IS PROVIDED "AS IS". AGE LOGIC MAKES NO
46
REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. By way of
47
example, but not limitation, AGE LOGIC MAKE NO
48
REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS
49
FOR ANY PARTICULAR PURPOSE OR THAT THE SOFTWARE DOES NOT
50
INFRINGE THIRD-PARTY PROPRIETARY RIGHTS. AGE LOGIC
51
SHALL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE. IN NO
52
EVENT SHALL EITHER PARTY BE LIABLE FOR ANY INDIRECT,
53
INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS
54
OF PROFITS, REVENUE, DATA OR USE, INCURRED BY EITHER PARTY OR
55
ANY THIRD PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT OR
56
BASED ON A WARRANTY, EVEN IF AGE LOGIC LICENSEES
57
HEREUNDER HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
60
The name of AGE Logic, Inc. may not be used in
61
advertising or publicity pertaining to this software without
62
specific, written prior permission from AGE Logic.
64
Title to this software shall at all times remain with AGE
66
*****************************************************************************
68
pcnst..c -- DIXIE routines for managing the Constrain element
70
Dean Verheiden -- AGE Logic, Inc. May 1993
72
*****************************************************************************/
73
/* $XFree86: xc/programs/Xserver/XIE/dixie/process/pcnst.c,v 3.6 2001/12/14 19:58:04 dawes Exp $ */
103
* routines internal to this module
105
static Bool PrepPConstrain(floDefPtr flo, peDefPtr ped);
108
* dixie element entry points
110
static diElemVecRec pConstrainVec = {
111
PrepPConstrain /* prepare for analysis and execution */
114
/*------------------------------------------------------------------------
115
-------------------- routine: make a constrain element ------------------
116
------------------------------------------------------------------------*/
117
peDefPtr MakeConstrain(floDefPtr flo, xieTypPhototag tag, xieFlo *pe)
120
ELEMENT(xieFloConstrain);
121
ELEMENT_AT_LEAST_SIZE(xieFloConstrain);
122
ELEMENT_NEEDS_1_INPUT(src);
124
if(!(ped = MakePEDef(1, (CARD32)stuff->elemLength<<2, 0)))
125
FloAllocError(flo,tag,xieElemConstrain, return(NULL)) ;
127
ped->diVec = &pConstrainVec;
129
ped->flags.process = TRUE;
130
raw = (xieFloConstrain *)ped->elemRaw;
132
* copy the client element parameters (swap if necessary)
134
if( flo->reqClient->swapped ) {
135
raw->elemType = stuff->elemType;
136
raw->elemLength = stuff->elemLength;
137
cpswaps(stuff->src, raw->src);
138
cpswapl(stuff->levels0, raw->levels0);
139
cpswapl(stuff->levels1, raw->levels1);
140
cpswapl(stuff->levels2, raw->levels2);
141
cpswaps(stuff->lenParams, raw->lenParams);
142
cpswaps(stuff->constrain, raw->constrain);
145
memcpy((char *)raw, (char *)stuff, sizeof(xieFloConstrain));
147
* copy technique data (if any)
149
if(!(ped->techVec = FindTechnique(xieValConstrain, raw->constrain)) ||
150
!(ped->techVec->copyfnc(flo, ped, &stuff[1], &raw[1], raw->lenParams, 0)))
151
TechniqueError(flo,ped,xieValConstrain,raw->constrain,raw->lenParams,
155
* assign phototag to inFlo
157
ped->inFloLst[SRCtag].srcTag = raw->src;
161
} /* end MakePConstrain */
163
/*------------------------------------------------------------------------
164
---------------- routine: copy routine for no param techniques -------------
165
------------------------------------------------------------------------*/
167
Bool CopyPConstrainStandard(TECHNQ_COPY_ARGS)
172
/*------------------------------------------------------------------------
173
---------------- routine: copy routine for Clip-Scale technique ---------
174
------------------------------------------------------------------------*/
177
#define sparms ((xieTecClipScale *)sParms)
179
#define rparms ((xieTecClipScale *)rParms)
181
Bool CopyPConstrainClipScale(TECHNQ_COPY_ARGS)
185
VALIDATE_TECHNIQUE_SIZE(ped->techVec, tsize, FALSE);
187
if (!(ped->techPvt = (pointer )XieMalloc(sizeof(pCnstDefRec))))
188
FloAllocError(flo, ped->phototag,xieElemConstrain, return(TRUE));
190
pvt = (pCnstDefPtr)ped->techPvt;
192
if( flo->reqClient->swapped ) {
193
pvt->input_low[0] = ConvertFromIEEE(lswapl(sparms->inputLow0));
194
pvt->input_low[1] = ConvertFromIEEE(lswapl(sparms->inputLow1));
195
pvt->input_low[2] = ConvertFromIEEE(lswapl(sparms->inputLow2));
196
pvt->input_high[0] = ConvertFromIEEE(lswapl(sparms->inputHigh0));
197
pvt->input_high[1] = ConvertFromIEEE(lswapl(sparms->inputHigh1));
198
pvt->input_high[2] = ConvertFromIEEE(lswapl(sparms->inputHigh2));
199
cpswapl(sparms->outputLow0, pvt->output_low[0]);
200
cpswapl(sparms->outputLow1, pvt->output_low[1]);
201
cpswapl(sparms->outputLow2, pvt->output_low[2]);
202
cpswapl(sparms->outputHigh0, pvt->output_high[0]);
203
cpswapl(sparms->outputHigh1, pvt->output_high[1]);
204
cpswapl(sparms->outputHigh2, pvt->output_high[2]);
206
pvt->input_low[0] = ConvertFromIEEE(sparms->inputLow0);
207
pvt->input_low[1] = ConvertFromIEEE(sparms->inputLow1);
208
pvt->input_low[2] = ConvertFromIEEE(sparms->inputLow2);
209
pvt->input_high[0] = ConvertFromIEEE(sparms->inputHigh0);
210
pvt->input_high[1] = ConvertFromIEEE(sparms->inputHigh1);
211
pvt->input_high[2] = ConvertFromIEEE(sparms->inputHigh2);
212
pvt->output_low[0] = sparms->outputLow0;
213
pvt->output_low[1] = sparms->outputLow1;
214
pvt->output_low[2] = sparms->outputLow2;
215
pvt->output_high[0] = sparms->outputHigh0;
216
pvt->output_high[1] = sparms->outputHigh1;
217
pvt->output_high[2] = sparms->outputHigh2;
222
/*------------------------------------------------------------------------
223
---------------- routine: prep routine for no param techniques -------------
224
------------------------------------------------------------------------*/
225
Bool PrepPConstrainStandard(
233
/*------------------------------------------------------------------------
234
---------------- routine: prep routine for Clip Scale technique ----------
235
------------------------------------------------------------------------*/
236
Bool PrepPConstrainClipScale(
239
xieTecClipScale *raw,
240
xieTecClipScale *tec)
242
pCnstDefPtr pvt = (pCnstDefPtr)ped->techPvt;
244
if (pvt->input_low[0] == pvt->input_high[0] ||
245
pvt->output_low[0] > ped->outFlo.format[0].levels - 1 ||
246
pvt->output_high[0] > ped->outFlo.format[0].levels - 1)
248
if (ped->outFlo.bands > 1) {
249
if ( pvt->input_low[1] == pvt->input_high[1] ||
250
pvt->output_low[1] > ped->outFlo.format[1].levels - 1 ||
251
pvt->output_high[1] > ped->outFlo.format[1].levels - 1 ||
252
pvt->input_low[2] == pvt->input_high[2] ||
253
pvt->output_low[2] > ped->outFlo.format[2].levels - 1 ||
254
pvt->output_high[2] > ped->outFlo.format[2].levels - 1)
261
/*------------------------------------------------------------------------
262
---------------- routine: prepare for analysis and execution -------------
263
------------------------------------------------------------------------*/
265
static Bool PrepPConstrain(
269
inFloPtr inf = &ped->inFloLst[SRCtag];
270
outFloPtr src = &inf->srcDef->outFlo;
271
outFloPtr dst = &ped->outFlo;
272
xieFloConstrain *raw = (xieFloConstrain *)ped->elemRaw;
275
/* grab a copy of the src attributes and propagate them to our input */
276
dst->bands = inf->bands = src->bands;
277
for(b = 0; b < src->bands; b++) {
279
/* This should be impossible */
280
if (IsntCanonic(src->format[b].class))
281
ImplementationError(flo, ped, return(FALSE));
283
inf->format[b] = src->format[b];
285
/* Copy outFlo values that are unchanged by constrain */
286
dst->format[b].band = b;
287
dst->format[b].interleaved = src->format[b].interleaved;
288
dst->format[b].width = src->format[b].width;
289
dst->format[b].height = src->format[b].height;
291
/* Pull in levels information from the element description */
292
if ((dst->format[0].levels = raw->levels0) > MAX_LEVELS(src->bands))
293
ValueError(flo,ped,raw->levels0,return(FALSE));
294
if (dst->bands > 1) {
295
if ((dst->format[1].levels = raw->levels1) > MAX_LEVELS(src->bands))
296
ValueError(flo,ped,raw->levels1,return(FALSE));
297
if ((dst->format[2].levels = raw->levels2) > MAX_LEVELS(src->bands))
298
ValueError(flo,ped,raw->levels2,return(FALSE));
300
/* Set depth, class, stride, and pitch */
301
if(!UpdateFormatfromLevels(ped))
302
MatchError(flo,ped, return(FALSE));
304
/* Take care of any technique parameters */
305
if (!(ped->techVec->prepfnc(flo, ped, raw, &raw[1])))
306
TechniqueError(flo,ped,xieValConstrain,raw->constrain,raw->lenParams,
311
/* end module pcnst.c */