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