xref: /plan9/sys/src/cmd/gs/src/gxfunc.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1997, 1998, 1999 Aladdin Enterprises.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: gxfunc.h,v 1.10 2005/04/19 14:35:12 igor Exp $ */
18 /* Internal definitions for Functions */
19 
20 #ifndef gxfunc_INCLUDED
21 #  define gxfunc_INCLUDED
22 
23 #include "gsfunc.h"
24 #include "gsstruct.h"
25 
26 /* ---------------- Types and structures ---------------- */
27 
28 /* Define the generic Function structure type.  This is never instantiated. */
29 extern_st(st_function);
30 #define public_st_function()	/* in gsfunc.c */\
31   gs_public_st_ptrs2(st_function, gs_function_t, "gs_function_t",\
32     function_enum_ptrs, function_reloc_ptrs, params.Domain, params.Range)
33 
34 /* ---------------- Internal procedures ---------------- */
35 
36 /* Generic free_params implementation. */
37 void fn_common_free_params(gs_function_params_t * params, gs_memory_t * mem);
38 
39 /* Generic free implementation. */
40 void fn_common_free(gs_function_t * pfn, bool free_params, gs_memory_t * mem);
41 
42 /* Check the values of m, n, Domain, and (if supplied) Range. */
43 int fn_check_mnDR(const gs_function_params_t * params, int m, int n);
44 
45 /* Generic get_info implementation (no Functions or DataSource). */
46 FN_GET_INFO_PROC(gs_function_get_info_default);
47 
48 /*
49  * Write generic parameters (FunctionType, Domain, Range) on a parameter list.
50  */
51 int fn_common_get_params(const gs_function_t *pfn, gs_param_list *plist);
52 
53 /*
54  * Copy an array of numeric values when scaling a function.
55  */
56 void *fn_copy_values(const void *pvalues, int count, int size,
57 		     gs_memory_t *mem);
58 
59 /*
60  * If necessary, scale the Range or Decode array for fn_make_scaled.
61  * Note that we must always allocate a new array.
62  */
63 int fn_scale_pairs(const float **ppvalues, const float *pvalues, int npairs,
64 		   const gs_range_t *pranges, gs_memory_t *mem);
65 
66 /*
67  * Scale the generic part of a function (Domain and Range).
68  * The client must have copied the parameters already.
69  */
70 int fn_common_scale(gs_function_t *psfn, const gs_function_t *pfn,
71 		    const gs_range_t *pranges, gs_memory_t *mem);
72 
73 /* Serialize. */
74 int fn_common_serialize(const gs_function_t * pfn, stream *s);
75 
76 #endif /* gxfunc_INCLUDED */
77