home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / lib / PEXlib / pl_pc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-26  |  27.2 KB  |  1,101 lines

  1. /* $XConsortium: pl_pc.c,v 1.8 92/08/26 13:06:18 mor Exp $ */
  2.  
  3. /******************************************************************************
  4. Copyright 1987,1991 by Digital Equipment Corporation, Maynard, Massachusetts
  5. Copyright 1992 by the Massachusetts Institute of Technology
  6.  
  7.                         All Rights Reserved
  8.  
  9. Permission to use, copy, modify, distribute, and sell this software and its
  10. documentation for any purpose is hereby granted without fee, provided that
  11. the above copyright notice appear in all copies and that both that copyright
  12. notice and this permission notice appear in supporting documentation, and that
  13. the name of Digital or M.I.T. not be used in advertising or publicity
  14. pertaining to distribution of the software without specific, written prior
  15. permission.  Digital and M.I.T. make no representations about the suitability
  16. of this software for any purpose.  It is provided "as is" without express or
  17. implied warranty.
  18.  
  19. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  20. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  21. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  22. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  23. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  24. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  25. SOFTWARE.
  26. ******************************************************************************/
  27.  
  28. #include "PEXlib.h"
  29. #include "PEXlibint.h"
  30.  
  31. static void _PEXGeneratePCList();
  32. static void _PEXGeneratePCAttr();
  33.  
  34.  
  35. PEXPipelineContext
  36. PEXCreatePipelineContext (display, valueMask, values)
  37.  
  38. INPUT Display        *display;
  39. INPUT unsigned long    *valueMask;
  40. INPUT PEXPCAttributes    *values;
  41.  
  42. {
  43.     pexCreatePipelineContextReq        *req;
  44.     PEXPipelineContext            pc;
  45.     int                    convertFP;
  46.  
  47.  
  48.     /*
  49.      * Get a pipeline context resource id from X.
  50.      */
  51.  
  52.     pc = XAllocID (display);
  53.  
  54.  
  55.     /*
  56.      * Lock around the critical section, for multithreading.
  57.      */
  58.  
  59.     LockDisplay (display);
  60.  
  61.  
  62.     /*
  63.      * Put the request in the X request buffer.
  64.      */
  65.  
  66.     PEXGetFPReq (CreatePipelineContext, req, convertFP);
  67.     req->pc = pc;
  68.     req->itemMask0 = valueMask[0];
  69.     req->itemMask1 = valueMask[1];
  70.     req->itemMask2 = valueMask[2];
  71.  
  72.     if (valueMask[0] != 0 || valueMask[1] != 0 || valueMask[2] != 0)
  73.     {
  74.     _PEXGeneratePCList (display, (pexReq *) req, valueMask, values);
  75.     }
  76.  
  77.     /*
  78.      * Done, so unlock and check for synchronous-ness.
  79.      */
  80.  
  81.     UnlockDisplay (display);
  82.     PEXSyncHandle (display);
  83.  
  84.     return (pc);
  85. }
  86.  
  87.  
  88. void
  89. PEXFreePipelineContext (display, pc)
  90.  
  91. INPUT Display            *display;
  92. INPUT PEXPipelineContext    pc;
  93.  
  94. {
  95.     pexFreePipelineContextReq        *req;
  96.  
  97.  
  98.     /*
  99.      * Lock around the critical section, for multithreading.
  100.      */
  101.  
  102.     LockDisplay (display);
  103.  
  104.  
  105.     /*
  106.      * Put the request in the X request buffer.
  107.      */
  108.  
  109.     PEXGetReq (FreePipelineContext, req);
  110.     req->id = pc;
  111.  
  112.  
  113.     /*
  114.      * Done, so unlock and check for synchronous-ness.
  115.      */
  116.  
  117.     UnlockDisplay (display);
  118.     PEXSyncHandle (display);
  119. }
  120.  
  121.  
  122. void
  123. PEXCopyPipelineContext (display, valueMask, srcPc, destPc)
  124.  
  125. INPUT Display            *display;
  126. INPUT unsigned long        *valueMask;
  127. INPUT PEXPipelineContext    srcPc;
  128. INPUT PEXPipelineContext    destPc;
  129.  
  130. {
  131.     pexCopyPipelineContextReq        *req;
  132.  
  133.  
  134.     /*
  135.      * Lock around the critical section, for multithreading.
  136.      */
  137.  
  138.     LockDisplay (display);
  139.  
  140.  
  141.     /*
  142.      * Put the request in the X request buffer.
  143.      */
  144.  
  145.     PEXGetReq (CopyPipelineContext, req);
  146.     req->src = srcPc;
  147.     req->dst = destPc;
  148.     req->itemMask0 = valueMask[0];
  149.     req->itemMask1 = valueMask[1];
  150.     req->itemMask2 = valueMask[2];
  151.  
  152.  
  153.     /*
  154.      * Done, so unlock and check for synchronous-ness.
  155.      */
  156.  
  157.     UnlockDisplay (display);
  158.     PEXSyncHandle (display);
  159. }
  160.  
  161.  
  162. PEXPCAttributes *
  163. PEXGetPipelineContext (display, pc, valueMask)
  164.  
  165. INPUT Display            *display;
  166. INPUT PEXPipelineContext    pc;
  167. INPUT unsigned long        *valueMask;
  168.  
  169. {
  170.     pexGetPipelineContextReq    *req;
  171.     pexGetPipelineContextReply    rep;
  172.     unsigned long        *pv;
  173.     PEXPCAttributes        *ppca;
  174.     int                convertFP;
  175.  
  176.  
  177.     /*
  178.      * Lock around the critical section, for multithreading.
  179.      */
  180.  
  181.     LockDisplay (display);
  182.  
  183.  
  184.     /*
  185.      * Put the request in the X request buffer and get a reply.
  186.      */
  187.  
  188.     PEXGetFPReq (GetPipelineContext, req, convertFP);
  189.     req->pc = pc;
  190.     req->itemMask0 = valueMask[0];
  191.     req->itemMask1 = valueMask[1];
  192.     req->itemMask2 = valueMask[2];
  193.  
  194.     if (_XReply (display, &rep, 0, xFalse) == 0)
  195.     {
  196.     UnlockDisplay (display);
  197.     PEXSyncHandle (display);
  198.     return (NULL);         /* return an error */
  199.     }
  200.  
  201.     /*
  202.      * Allocate a scratch buffer and copy the reply data to the buffer.
  203.      */
  204.  
  205.     pv = (unsigned long *) _XAllocScratch (display,
  206.     (unsigned long) (rep.length << 2));
  207.     _XRead (display, (char *) pv, (long) (rep.length << 2));
  208.  
  209.  
  210.     /*
  211.      * Allocate a buffer for the replies to pass back to the client.
  212.      */
  213.  
  214.     ppca = (PEXPCAttributes *)
  215.     PEXAllocBuf ((unsigned) (sizeof (PEXPCAttributes)));
  216.  
  217.     _PEXGeneratePCAttr (pv, valueMask, ppca);
  218.  
  219.  
  220.     /*
  221.      * Done, so unlock and check for synchronous-ness.
  222.      */
  223.  
  224.     UnlockDisplay (display);
  225.     PEXSyncHandle (display);
  226.  
  227.     return (ppca);
  228. }
  229.  
  230.  
  231. void
  232. PEXChangePipelineContext (display, pc, valueMask, pcAttributes)
  233.  
  234. INPUT Display            *display;
  235. INPUT PEXPipelineContext    pc;
  236. INPUT unsigned long        *valueMask;
  237. INPUT PEXPCAttributes        *pcAttributes;
  238.  
  239. {
  240.     pexChangePipelineContextReq        *req;
  241.     int                    convertFP;
  242.  
  243.  
  244.     /*
  245.      * Lock around the critical section, for multithreading.
  246.      */
  247.  
  248.     LockDisplay (display);
  249.  
  250.  
  251.     /*
  252.      * Put the request in the X request buffer.
  253.      */
  254.  
  255.     PEXGetFPReq (ChangePipelineContext, req, convertFP);
  256.     req->pc = pc;
  257.     req->itemMask0 = valueMask[0];
  258.     req->itemMask1 = valueMask[1];
  259.     req->itemMask2 = valueMask[2];
  260.  
  261.     _PEXGeneratePCList (display, (pexReq *) req, valueMask, pcAttributes);
  262.  
  263.  
  264.     /*
  265.      * Done, so unlock and check for synchronous-ness.
  266.      */
  267.  
  268.     UnlockDisplay (display);
  269.     PEXSyncHandle (display);
  270. }
  271.  
  272.  
  273.  
  274. /*
  275.  * Routine to write a packed list of pc attributes into the transport buf.
  276.  */
  277.  
  278. static void
  279. _PEXGeneratePCList (display, req, valueMask, values)
  280.  
  281. INPUT Display             *display;
  282. INPUT pexReq              *req;
  283. INPUT unsigned long       *valueMask;
  284. INPUT PEXPCAttributes      *values;
  285.  
  286. {
  287.     long        *pv;
  288.     long        *pvSend;
  289.     unsigned long       f;
  290.     int            length, n;
  291.     int            sizeColor;
  292.     long        size;
  293.     Bool        bitSet;
  294.     int         pscType;
  295.     INT16        *pint;
  296.  
  297.  
  298.     /*
  299.      * f is the maximum size we might need to store the PC list.  Just
  300.      * use 2*sizeof(PEXPCAttributes) to account for padding between shorts.
  301.      */
  302.  
  303.     f = 2 * sizeof (PEXPCAttributes);
  304.  
  305.     if (valueMask[1] &
  306.     1L << (PEXPCModelClipVolume - PEXPCBFInteriorStyleIndex))
  307.     f += values->model_clip_volume.count * sizeof (pexHalfSpace);
  308.  
  309.     if (valueMask[1] & 1L << (PEXPCLightState - PEXPCBFInteriorStyleIndex))
  310.     f += PADDED_BYTES (values->light_state.count * sizeof (pexTableIndex));
  311.  
  312.     pv = pvSend = (long *) _XAllocScratch (display, (unsigned long) f);
  313.  
  314.     for (n = 0; n < (PEXPCMaxShift + 1); n++)
  315.     {
  316.     bitSet = valueMask[n >> 5] & (1L << (n & 0x1f));
  317.     if (bitSet != 0)
  318.         {
  319.             switch (n)
  320.         {
  321.         /* note that there are 2 bytes of pad between 2 byte items */
  322.             case PEXPCMarkerType:
  323.         *pv = values->marker_type;
  324.         pv++;
  325.         break;
  326.             case PEXPCMarkerScale:
  327.         *((float *) pv) = values->marker_scale;
  328.         pv++;
  329.         break;
  330.             case PEXPCMarkerColor:
  331.         PackColorSpecifier (&(values->marker_color), pv, sizeColor);
  332.         pv += NUMWORDS (sizeof (pexColorSpecifier) + sizeColor); 
  333.         break;
  334.             case PEXPCMarkerBundleIndex:
  335.         *pv = values->marker_bundle_index;
  336.         pv++;
  337.         break;
  338.             case PEXPCTextFont:
  339.         *pv = values->text_font;
  340.         pv++;
  341.         break;
  342.             case PEXPCTextPrecision:
  343.         *pv = values->text_precision;
  344.         pv++;
  345.         break;
  346.             case PEXPCCharExpansion:
  347.         *((float *) pv) = values->char_expansion;
  348.         pv++;
  349.         break;
  350.             case PEXPCCharSpacing:
  351.         *((float *) pv) = values->char_spacing;
  352.         pv++;
  353.         break;
  354.             case PEXPCTextColor:
  355.         PackColorSpecifier (&(values->text_color), pv, sizeColor);
  356.         pv += NUMWORDS (sizeof (pexColorSpecifier) + sizeColor); 
  357.         break;
  358.             case PEXPCCharHeight:
  359.         *((float *) pv) = values->char_height;
  360.         pv++;
  361.         break;
  362.             case PEXPCCharUpVector:
  363. #ifdef WORD64
  364. #else
  365.         *((pexVector2D *) pv) = *(pexVector2D *)
  366.             &(values->char_up_vector);
  367. #endif
  368.         pv += LENOF (pexVector2D); 
  369.         break;
  370.             case PEXPCTextPath:
  371.         *pv = values->text_path;
  372.         pv++;
  373.         break;
  374.             case PEXPCTextAlignment:
  375. #ifdef WORD64
  376. #else
  377.         *((pexTextAlignmentData *) pv) =
  378.             *(pexTextAlignmentData *) &(values->text_alignment);
  379. #endif
  380.         pv += LENOF (pexTextAlignmentData); 
  381.         break;
  382.             case PEXPCATextHeight:
  383.         *((float *) pv) = values->atext_height;
  384.         pv++;
  385.         break;
  386.             case PEXPCATextUpVector:
  387. #ifdef WORD64
  388. #else
  389.         *((pexVector2D *) pv) = *(pexVector2D *)
  390.             &(values->atext_up_vector);
  391. #endif
  392.         pv += LENOF (pexVector2D); 
  393.         break;
  394.             case PEXPCATextPath:
  395.         *pv = values->atext_path;
  396.         pv++;
  397.         break;
  398.             case PEXPCATextAlignment:
  399. #ifdef WORD64
  400. #else
  401.         *((pexTextAlignmentData *) pv) =
  402.             *(pexTextAlignmentData *) &(values->atext_alignment);
  403. #endif
  404.         pv += LENOF (pexTextAlignmentData); 
  405.         break;
  406.             case PEXPCATextStyle:
  407.         *pv = values->atext_style;
  408.         pv++;
  409.         break;
  410.             case PEXPCTextBundleIndex:
  411.         *pv = values->text_bundle_index;
  412.         pv++;
  413.         break;
  414.             case PEXPCLineType:
  415.         *pv = values->line_type;
  416.         pv++;
  417.         break;
  418.             case PEXPCLineWidth:
  419.         *((float *) pv) = values->line_width;
  420.         pv++;
  421.         break;
  422.             case PEXPCLineColor:
  423.         PackColorSpecifier (&(values->line_color), pv, sizeColor);
  424.         pv += NUMWORDS (sizeof (pexColorSpecifier) + sizeColor); 
  425.         break;
  426.             case PEXPCCurveApprox:
  427.         *pv = values->curve_approx.method;
  428.         pv++;
  429.         *((float *) pv) = values->curve_approx.tolerance;
  430.         pv++;
  431.         break;
  432.             case PEXPCPolylineInterp:
  433.         *pv = values->polyline_interp;
  434.         pv++;
  435.         break;
  436.             case PEXPCLineBundleIndex:
  437.         *pv = values->line_bundle_index;
  438.         pv++;
  439.         break;
  440.             case PEXPCInteriorStyle:
  441.         *pv = values->interior_style;
  442.         pv++;
  443.         break;
  444.             case PEXPCInteriorStyleIndex:
  445.         *pv = values->interior_style_index;
  446.         pv++;
  447.         break;
  448.             case PEXPCSurfaceColor:
  449.         PackColorSpecifier (&(values->surface_color), pv, sizeColor);
  450.         pv += NUMWORDS (sizeof (pexColorSpecifier) + sizeColor); 
  451.         break;
  452.             case PEXPCReflectionAttr:
  453.         ((pexReflectionAttr *) pv)->ambient = 
  454.             values->reflection_attr.ambient;
  455.         ((pexReflectionAttr *) pv)->diffuse = 
  456.             values->reflection_attr.diffuse;
  457.         ((pexReflectionAttr *) pv)->specular = 
  458.             values->reflection_attr.specular;
  459.         ((pexReflectionAttr *) pv)->specularConc = 
  460.             values->reflection_attr.specular_conc;
  461.         ((pexReflectionAttr *) pv)->transmission = 
  462.             values->reflection_attr.transmission;
  463.         PackColorSpecifier (&(values->reflection_attr.specular_color), 
  464.             &(((pexReflectionAttr *) pv)->specularColor), 
  465.             sizeColor);
  466.         pv += NUMWORDS (sizeof (pexReflectionAttr) + sizeColor); 
  467.         break;
  468.             case PEXPCReflectionModel:
  469.         *pv = values->reflection_model;
  470.         pv++;
  471.         break;
  472.             case PEXPCSurfaceInterp:
  473.         *pv = values->surface_interp;
  474.         pv++;
  475.         break;
  476.             case PEXPCBFInteriorStyle:
  477.         *pv = values->bf_interior_style;
  478.         pv++;
  479.         break;
  480.             case PEXPCBFInteriorStyleIndex:
  481.         *pv = values->bf_interior_style_index;
  482.         pv++;
  483.         break;
  484.             case PEXPCBFSurfaceColor:
  485.         PackColorSpecifier (&(values->bf_surface_color),
  486.             pv, sizeColor);
  487.         pv += NUMWORDS (sizeof (pexColorSpecifier) + sizeColor); 
  488.         break;
  489.             case PEXPCBFReflectionAttr:
  490.         ((pexReflectionAttr *) pv)->ambient = 
  491.             values->bf_reflection_attr.ambient;
  492.         ((pexReflectionAttr *) pv)->diffuse = 
  493.             values->bf_reflection_attr.diffuse;
  494.         ((pexReflectionAttr *) pv)->specular = 
  495.             values->bf_reflection_attr.specular;
  496.         ((pexReflectionAttr *) pv)->specularConc = 
  497.             values->bf_reflection_attr.specular_conc;
  498.         ((pexReflectionAttr *) pv)->transmission = 
  499.             values->bf_reflection_attr.transmission;
  500.         PackColorSpecifier (
  501.             &(values->bf_reflection_attr.specular_color), 
  502.             &(((pexReflectionAttr *) pv)->specularColor), 
  503.             sizeColor);
  504.         pv += NUMWORDS (sizeof (pexReflectionAttr) + sizeColor); 
  505.         break;
  506.             case PEXPCBFReflectionModel:
  507.         *pv = values->bf_reflection_model;
  508.         pv++;
  509.         break;
  510.             case PEXPCBFSurfaceInterp:
  511.         *pv = values->bf_surface_interp;
  512.         pv++;
  513.         break;
  514.             case PEXPCSurfaceApprox:
  515.         *pv = values->surface_approx.method;
  516.         pv++;
  517.         *((float *) pv) = values->surface_approx.u_tolerance;
  518.         pv++;
  519.         *((float *) pv) = values->surface_approx.v_tolerance;
  520.         pv++;
  521.         break;
  522.             case PEXPCCullingMode:
  523.         *pv = values->culling_mode;
  524.         pv++;
  525.         break;
  526.             case PEXPCDistinguishFlag:
  527.         *pv = values->distinguish;
  528.         pv++;
  529.         break;
  530.             case PEXPCPatternSize:
  531. #ifdef WORD64
  532. #else
  533.         *((pexCoord2D *) pv) = *(pexCoord2D *) &(values->pattern_size);
  534. #endif
  535.         pv += LENOF (pexCoord2D);
  536.         break;
  537.             case PEXPCPatternRefPoint:
  538. #ifdef WORD64
  539. #else
  540.         *((pexCoord3D *) pv) =
  541.             *(pexCoord3D *) &(values->pattern_ref_point);
  542. #endif
  543.         pv += LENOF (pexCoord3D);
  544.         break;
  545.             case PEXPCPatternRefVec1:
  546. #ifdef WORD64
  547. #else
  548.         *((pexVector3D *) pv) =
  549.             *(pexVector3D *) &(values->pattern_ref_vec1);
  550. #endif
  551.         pv += LENOF (pexVector3D);
  552.         break;
  553.             case PEXPCPatternRefVec2:
  554. #ifdef WORD64
  555. #else
  556.         *((pexVector3D *) pv) =
  557.             *(pexVector3D *) &(values->pattern_ref_vec2);
  558. #endif
  559.         pv += LENOF (pexVector3D);
  560.         break;
  561.             case PEXPCInteriorBundleIndex:
  562.         *pv = values->interior_bundle_index;
  563.         pv++;
  564.         break;
  565.             case PEXPCSurfaceEdgeFlag:
  566.         *pv = values->surface_edges;
  567.         pv++;
  568.         break;
  569.             case PEXPCSurfaceEdgeType:
  570.         *pv = values->surface_edge_type;
  571.         pv++;
  572.         break;
  573.             case PEXPCSurfaceEdgeWidth:
  574.         *((float *) pv) = values->surface_edge_width;
  575.         pv++;
  576.         break;
  577.             case PEXPCSurfaceEdgeColor:
  578.         PackColorSpecifier (&(values->surface_edge_color), pv, 
  579.             sizeColor);
  580.         pv += NUMWORDS (sizeof (pexColorSpecifier) + sizeColor); 
  581.         break;
  582.             case PEXPCEdgeBundleIndex:
  583.         *pv = values->edge_bundle_index;
  584.         pv++;
  585.         break;
  586.             case PEXPCLocalTransform:
  587.         COPY_AREA ((char *) values->local_transform,
  588.             (char *) pv, sizeof (pexMatrix));
  589.         pv += LENOF (pexMatrix);
  590.         break;
  591.             case PEXPCGlobalTransform:
  592.         COPY_AREA ((char *) values->global_transform,
  593.             (char *) pv, sizeof (pexMatrix));
  594.         pv += LENOF (pexMatrix);
  595.         break;
  596.             case PEXPCModelClip:
  597.         *pv = values->model_clip;
  598.         pv++;
  599.         break;
  600.             case PEXPCModelClipVolume:
  601.         size = values->model_clip_volume.count;
  602.         *((long *) pv) = size;
  603.         pv++;
  604.         size *= sizeof (pexHalfSpace);
  605.         COPY_AREA ((char *) values->model_clip_volume.half_spaces,
  606.             (char *) pv, size);
  607.         pv += NUMWORDS (size);
  608.         break;
  609.             case PEXPCViewIndex:
  610.         *pv = values->view_index;
  611.         pv++;
  612.         break;
  613.             case PEXPCLightState:
  614.         size = values->light_state.count;
  615.         *((long *) pv) = size;
  616.         pv++;
  617.         size *= sizeof (pexTableIndex);
  618.         COPY_AREA ((char *) values->light_state.indices,
  619.             (char *) pv, size);
  620.         pv += NUMWORDS (size);
  621.         break;
  622.             case PEXPCDepthCueIndex:
  623.         *pv = values->depth_cue_index;
  624.         pv++;
  625.         break;
  626.             case PEXPCPickID:
  627.         *((CARD32 *) pv) = values->pick_id;
  628.         pv++;
  629.         break;
  630.             case PEXPCHLHSRIdentifier:
  631.         *((CARD32 *) pv) = values->hlhsr_id;
  632.         pv++;
  633.         break;
  634.             case PEXPCNameSet:
  635.         *((pexNameSet *) pv) = values->name_set;
  636.         pv += LENOF (pexNameSet);
  637.         break;
  638.             case PEXPCASFValues:
  639.         *((unsigned long *) pv) = values->asf_enables;
  640.         pv++;
  641.         *((unsigned long *) pv) = values->asf_values;
  642.         pv++;
  643.         break;
  644.         case PEXPCColorApproxIndex:
  645.         *pv = values->color_approx_index;
  646.         pv++;
  647.         break;
  648.         case PEXPCRenderingColorModel:
  649.         *pv = values->rendering_color_model;
  650.         pv++;
  651.         break;
  652.         case PEXPCParaSurfCharacteristics:
  653.         pscType = values->para_surf_char.type;
  654.         pint = (INT16 *) pv;
  655.  
  656.         if (pscType == PEXPSCIsoCurves)
  657.         {
  658.             size = sizeof (PEXPSCIsoparametricCurves);
  659.             *(pint++) = PEXPSCIsoCurves;
  660.             *(pint++) = size;
  661.             pv = (long *) pint;
  662.  
  663.             COPY_AREA (&(values->para_surf_char.psc.iso_curves),
  664.                (char *) pv, sizeof (PEXPSCIsoparametricCurves));
  665.             pv = (long *) ((char *) pv +
  666.             sizeof (PEXPSCIsoparametricCurves));
  667.         }
  668.         else if (pscType == PEXPSCMCLevelCurves ||
  669.             pscType == PEXPSCWCLevelCurves)
  670.         {
  671.             int param_size = sizeof (float) *
  672.              values->para_surf_char.psc.level_curves.count;
  673.             size = sizeof (pexPSC_LevelCurves) + param_size;
  674.  
  675.             *(pint++) = pscType;
  676.             *(pint++) = size;
  677.             pv = (long *) pint;
  678.  
  679.             COPY_AREA (&(values->para_surf_char.psc.level_curves),
  680.                (char *) pv, sizeof (pexPSC_LevelCurves));
  681.             pv = (long *) ((char *) pv + sizeof (pexPSC_LevelCurves));
  682.             COPY_AREA ((char *)
  683.             values->para_surf_char.psc.level_curves.parameters,
  684.             (char *) pv, param_size);
  685.             pv = (long *) ((char *) pv + param_size);
  686.         }
  687.         break;
  688.         }
  689.     }
  690.     }
  691.  
  692.     length = pv - pvSend;
  693.     req->length += length;
  694.  
  695.     Data (display, (char *) pvSend, (length << 2));
  696. }
  697.  
  698.  
  699. /*
  700.  * Routine to fill in a PEXPCAttributes structure from the PC attributes
  701.  * part of a Get PC reply.
  702.  */
  703.  
  704. static void
  705. _PEXGeneratePCAttr (pv, valueMask, ppca)
  706.  
  707. INPUT unsigned long            *pv;
  708. INPUT unsigned long            valueMask[3];
  709. OUTPUT PEXPCAttributes            *ppca;
  710.  
  711. {
  712.     Bool            bitSet;
  713.     int                sizeColor;
  714.     int                size, n, pscType;
  715.     INT16            *pint;
  716.  
  717.  
  718.     /*
  719.      * PEXFreePCAttributes will check for NULL before freeing.
  720.      */
  721.  
  722.     ppca->model_clip_volume.count = 0;
  723.     ppca->model_clip_volume.half_spaces = NULL;
  724.     ppca->light_state.count = 0;
  725.     ppca->light_state.indices = NULL;
  726.     ppca->para_surf_char.type = 0;
  727.  
  728.  
  729.     /*
  730.      * Fill in the PC attributes.
  731.      */
  732.  
  733.     for (n = 0; n < (PEXPCMaxShift + 1); n++)
  734.     {
  735.     bitSet = valueMask[n >> 5] & (1L << (n & 0x1f));
  736.  
  737.     if (bitSet != 0)
  738.         {
  739.             switch (n)
  740.         {
  741.         /* note:  2 bytes of pad between 2 byte items */
  742.             case PEXPCMarkerType:
  743.         ppca->marker_type = *pv;
  744.         pv++;
  745.         break;
  746.             case PEXPCMarkerScale:
  747.         ppca->marker_scale = *((float *) pv);
  748.         pv++;
  749.         break;
  750.             case PEXPCMarkerColor:
  751.         PackColorSpecifier (pv, &(ppca->marker_color), sizeColor);
  752.         pv += NUMWORDS (sizeof (pexColorSpecifier) + sizeColor); 
  753.         break;
  754.             case PEXPCMarkerBundleIndex:
  755.         ppca->marker_bundle_index = *pv;
  756.         pv++;
  757.         break;
  758.             case PEXPCTextFont:
  759.         ppca->text_font = *pv;
  760.         pv++;
  761.         break;
  762.             case PEXPCTextPrecision:
  763.         ppca->text_precision = *pv;
  764.         pv++;
  765.         break;
  766.             case PEXPCCharExpansion:
  767.           ppca->char_expansion = *((float *) pv);
  768.         pv++;
  769.         break;
  770.             case PEXPCCharSpacing:
  771.         ppca->char_spacing = *((float *) pv);
  772.         pv++;
  773.         break;
  774.             case PEXPCTextColor:
  775.         PackColorSpecifier (pv, &(ppca->text_color), sizeColor);
  776.         pv += NUMWORDS (sizeof (pexColorSpecifier) + sizeColor); 
  777.         break;
  778.             case PEXPCCharHeight:
  779.         ppca->char_height = *((float *) pv);
  780.         pv++;
  781.         break;
  782.             case PEXPCCharUpVector:
  783. #ifdef WORD64
  784. #else
  785.         ppca->char_up_vector = *((PEXVector2D *) pv);
  786. #endif
  787.         pv += LENOF (pexVector2D); 
  788.         break;
  789.             case PEXPCTextPath:
  790.         ppca->text_path = *pv;
  791.         pv++;
  792.         break;
  793.             case PEXPCTextAlignment:
  794. #ifdef WORD64
  795. #else
  796.         ppca->text_alignment = *((PEXTextAlignment *)pv);
  797. #endif
  798.         pv += LENOF (pexTextAlignmentData);
  799.         break;
  800.             case PEXPCATextHeight:
  801.         ppca->atext_height = *((float *) pv);
  802.         pv++;
  803.         break;
  804.             case PEXPCATextUpVector:
  805. #ifdef WORD64
  806. #else
  807.         ppca->atext_up_vector = *((PEXVector2D *) pv);
  808. #endif
  809.         pv += LENOF (pexVector2D); 
  810.         break;
  811.             case PEXPCATextPath:
  812.         ppca->atext_path = *pv;
  813.         pv++;
  814.         break;
  815.             case PEXPCATextAlignment:
  816. #ifdef WORD64
  817. #else
  818.         ppca->atext_alignment = *((PEXTextAlignment *) pv);
  819. #endif
  820.         pv += LENOF (pexTextAlignmentData);
  821.         break;
  822.             case PEXPCATextStyle:
  823.         ppca->atext_style = *pv;
  824.         pv++;
  825.         break;
  826.             case PEXPCTextBundleIndex:
  827.         ppca->text_bundle_index = *pv;
  828.         pv++;
  829.         break;
  830.             case PEXPCLineType:
  831.         ppca->line_type = *pv;
  832.         pv++;
  833.         break;
  834.             case PEXPCLineWidth:
  835.         ppca->line_width = *((float *) pv);
  836.         pv++;
  837.         break;
  838.             case PEXPCLineColor:
  839.         PackColorSpecifier (pv, &(ppca->line_color), sizeColor);
  840.         pv += NUMWORDS (sizeof (pexColorSpecifier) + sizeColor); 
  841.         break;
  842.             case PEXPCCurveApprox:
  843.         ppca->curve_approx.method = *pv;
  844.         pv++;
  845.         ppca->curve_approx.tolerance = *((float *) pv);
  846.         pv++;
  847.         break;
  848.             case PEXPCPolylineInterp:
  849.         ppca->polyline_interp = *pv;
  850.         pv++;
  851.         break;
  852.             case PEXPCLineBundleIndex:
  853.         ppca->line_bundle_index = *pv;
  854.         pv++;
  855.         break;
  856.             case PEXPCInteriorStyle:
  857.         ppca->interior_style = *pv;
  858.         pv++;
  859.         break;
  860.             case PEXPCInteriorStyleIndex:
  861.         ppca->interior_style_index = *pv;
  862.         pv++;
  863.         break;
  864.             case PEXPCSurfaceColor:
  865.         PackColorSpecifier (pv, &(ppca->surface_color), sizeColor);
  866.         pv += NUMWORDS (sizeof (pexColorSpecifier) + sizeColor); 
  867.         break;
  868.             case PEXPCReflectionAttr:
  869.         ppca->reflection_attr.ambient = 
  870.             ((pexReflectionAttr *) pv)->ambient;
  871.         ppca->reflection_attr.diffuse = 
  872.             ((pexReflectionAttr *) pv)->diffuse;
  873.         ppca->reflection_attr.specular = 
  874.             ((pexReflectionAttr *) pv)->specular;
  875.         ppca->reflection_attr.specular_conc = 
  876.             ((pexReflectionAttr *) pv)->specularConc;
  877.         ppca->reflection_attr.transmission = 
  878.             ((pexReflectionAttr *) pv)->transmission;
  879.         PackColorSpecifier ( 
  880.             &(((pexReflectionAttr *) pv)->specularColor), 
  881.             &(ppca->reflection_attr.specular_color), sizeColor);
  882.         pv += NUMWORDS (sizeof (pexReflectionAttr) + sizeColor); 
  883.         break;
  884.             case PEXPCReflectionModel:
  885.         ppca->reflection_model = *pv;
  886.         pv++;
  887.         break;
  888.             case PEXPCSurfaceInterp:
  889.         ppca->surface_interp = *pv;
  890.         pv++;
  891.         break;
  892.             case PEXPCBFInteriorStyle:
  893.         ppca->bf_interior_style = *pv;
  894.         pv++;
  895.         break;
  896.             case PEXPCBFInteriorStyleIndex:
  897.         ppca->bf_interior_style_index = *pv;
  898.         pv++;
  899.         break;
  900.             case PEXPCBFSurfaceColor:
  901.         PackColorSpecifier (pv, &(ppca->bf_surface_color), sizeColor);
  902.         pv += NUMWORDS (sizeof (pexColorSpecifier) + sizeColor); 
  903.         break;
  904.             case PEXPCBFReflectionAttr:
  905.         ppca->bf_reflection_attr.ambient = 
  906.             ((pexReflectionAttr *) pv)->ambient;
  907.         ppca->bf_reflection_attr.diffuse = 
  908.             ((pexReflectionAttr *) pv)->diffuse;
  909.         ppca->bf_reflection_attr.specular = 
  910.             ((pexReflectionAttr *) pv)->specular;
  911.         ppca->bf_reflection_attr.specular_conc = 
  912.             ((pexReflectionAttr *) pv)->specularConc;
  913.         ppca->bf_reflection_attr.transmission = 
  914.             ((pexReflectionAttr *) pv)->transmission;
  915.         PackColorSpecifier ( 
  916.             &(((pexReflectionAttr *) pv)->specularColor), 
  917.             &(ppca->bf_reflection_attr.specular_color), sizeColor);
  918.         pv += NUMWORDS (sizeof (pexReflectionAttr) + sizeColor); 
  919.         break;
  920.             case PEXPCBFReflectionModel:
  921.         ppca->bf_reflection_model = *pv;
  922.         pv++;
  923.         break;
  924.             case PEXPCBFSurfaceInterp:
  925.         ppca->bf_surface_interp = *pv;
  926.         pv++;
  927.         break;
  928.             case PEXPCSurfaceApprox:
  929.         ppca->surface_approx.method = *pv;
  930.         pv++;
  931.         ppca->surface_approx.u_tolerance = *((float *) pv);
  932.         pv++;
  933.         ppca->surface_approx.v_tolerance = *((float *) pv);
  934.         pv++;
  935.         break;
  936.             case PEXPCCullingMode:
  937.         ppca->culling_mode = *pv;
  938.         pv++;
  939.         break;
  940.             case PEXPCDistinguishFlag:
  941.         ppca->distinguish = *pv;
  942.         pv++;
  943.         break;
  944.             case PEXPCPatternSize:
  945. #ifdef WORD64
  946. #else
  947.         ppca->pattern_size = *((PEXCoord2D *) pv);
  948. #endif
  949.         pv += LENOF (pexCoord2D);
  950.         break;
  951.             case PEXPCPatternRefPoint:
  952. #ifdef WORD64
  953. #else
  954.         ppca->pattern_ref_point = *((PEXCoord *) pv);
  955. #endif
  956.         pv += LENOF (pexCoord3D);
  957.         break;
  958.             case PEXPCPatternRefVec1:
  959. #ifdef WORD64
  960. #else
  961.         ppca->pattern_ref_vec1 = *((PEXVector *) pv);
  962. #endif
  963.         pv += LENOF (pexVector3D); 
  964.         break;
  965.             case PEXPCPatternRefVec2:
  966. #ifdef WORD64
  967. #else
  968.         ppca->pattern_ref_vec2 = *((PEXVector *) pv);
  969. #endif
  970.         pv += LENOF (pexVector3D); 
  971.         break;
  972.             case PEXPCInteriorBundleIndex:
  973.         ppca->interior_bundle_index = *pv;
  974.         pv++;
  975.         break;
  976.             case PEXPCSurfaceEdgeFlag:
  977.         ppca->surface_edges = *pv;
  978.         pv++;
  979.         break;
  980.             case PEXPCSurfaceEdgeType:
  981.         ppca->surface_edge_type = *pv;
  982.         pv++;
  983.         break;
  984.             case PEXPCSurfaceEdgeWidth:
  985.         ppca->surface_edge_width = *((float *) pv);
  986.         pv++;
  987.         break;
  988.             case PEXPCSurfaceEdgeColor:
  989.         PackColorSpecifier (pv, &(ppca->surface_edge_color),
  990.             sizeColor);
  991.         pv += NUMWORDS (sizeof (pexColorSpecifier) + sizeColor); 
  992.         break;
  993.             case PEXPCEdgeBundleIndex:
  994.         ppca->edge_bundle_index = *pv;
  995.         pv++;
  996.         break;
  997.             case PEXPCLocalTransform:
  998.         COPY_AREA ((char *) pv, (char *) ppca->local_transform,
  999.             sizeof (PEXMatrix));
  1000.         pv += LENOF (pexMatrix);
  1001.         break;
  1002.             case PEXPCGlobalTransform:
  1003.         COPY_AREA ((char *) pv, (char *) ppca->global_transform,
  1004.             sizeof (PEXMatrix));
  1005.         pv += LENOF (pexMatrix);
  1006.         break;
  1007.             case PEXPCModelClip:
  1008.         ppca->model_clip = *pv;
  1009.         pv++;
  1010.         break;
  1011.             case PEXPCModelClipVolume:
  1012.         size = *pv;
  1013.         pv++;
  1014.         ppca->model_clip_volume.count = size;
  1015.         size *= sizeof (PEXHalfSpace);
  1016.         ppca->model_clip_volume.half_spaces =
  1017.             (PEXHalfSpace *) PEXAllocBuf ((unsigned) size);
  1018.         COPY_AREA ((char *)pv,
  1019.             (char *) (ppca->model_clip_volume.half_spaces), size);
  1020.         pv += NUMWORDS (size);
  1021.         break;
  1022.             case PEXPCViewIndex:
  1023.         ppca->view_index = *pv;
  1024.         pv++;
  1025.         break;
  1026.             case PEXPCLightState:
  1027.         size = *pv;
  1028.         pv++;
  1029.         ppca->light_state.count = size;
  1030.         size *= sizeof (PEXTableIndex);
  1031.         ppca->light_state.indices =
  1032.             (PEXTableIndex *) PEXAllocBuf ((unsigned) size);
  1033.         COPY_AREA ((char *) pv,
  1034.             (char *) (ppca->light_state.indices), size);
  1035.         pv += NUMWORDS (size);
  1036.         break;
  1037.             case PEXPCDepthCueIndex:
  1038.         ppca->depth_cue_index = *pv;
  1039.         pv++;
  1040.         break;
  1041.             case PEXPCPickID:
  1042.         ppca->pick_id = *((INT32 *) pv);
  1043.         pv++;
  1044.         break;
  1045.             case PEXPCHLHSRIdentifier:
  1046.         ppca->hlhsr_id = *((CARD32 *) pv);
  1047.         pv++;
  1048.         break;
  1049.             case PEXPCNameSet:
  1050.         ppca->name_set = *((PEXNameSet *) pv);
  1051.         pv += LENOF (pexNameSet);
  1052.         break;
  1053.             case PEXPCASFValues:
  1054.         ppca->asf_enables = *((CARD32 *) pv);
  1055.         pv++;
  1056.         ppca->asf_values = *((CARD32 *) pv);
  1057.         pv++;
  1058.         break;
  1059.         case PEXPCColorApproxIndex:
  1060.         ppca->color_approx_index = *pv;
  1061.         pv++;
  1062.         break;
  1063.         case PEXPCRenderingColorModel:
  1064.         ppca->rendering_color_model = *pv;
  1065.         pv++;
  1066.         break;
  1067.         case PEXPCParaSurfCharacteristics:
  1068.         pint = (INT16 *) pv;
  1069.         ppca->para_surf_char.type = pscType = *(pint++);
  1070.         pv++;
  1071.         if (pscType == PEXPSCIsoCurves)
  1072.         {
  1073.             COPY_AREA ((char *) pv,
  1074.             (char *) &(ppca->para_surf_char.psc.iso_curves),
  1075.             sizeof (PEXPSCIsoparametricCurves));
  1076.             pv = (unsigned long *) ((char *) pv +
  1077.             sizeof (PEXPSCIsoparametricCurves));
  1078.         }
  1079.         else if (pscType == PEXPSCMCLevelCurves ||
  1080.             pscType == PEXPSCWCLevelCurves)
  1081.         {
  1082.             int param_size = *pint - sizeof (pexPSC_LevelCurves);
  1083.  
  1084.             COPY_AREA ((char *) pv,
  1085.                 (char *) &(ppca->para_surf_char.psc.level_curves),
  1086.                 sizeof (pexPSC_LevelCurves));
  1087.             pv = (unsigned long *) ((char *) pv +
  1088.             sizeof (pexPSC_LevelCurves));
  1089.             ppca->para_surf_char.psc.level_curves.parameters = 
  1090.                 (float *) PEXAllocBuf ((unsigned) param_size);
  1091.             COPY_AREA ((char *) pv, (char *)
  1092.             (ppca->para_surf_char.psc.level_curves.parameters),
  1093.                 param_size);
  1094.             pv = (unsigned long *) ((char *) pv + *pint);
  1095.         }
  1096.         break;
  1097.         }
  1098.     }
  1099.     }
  1100. }
  1101.