diff options
author | Stefan Kemper <stefan.kemper@artifex.com> | 2004-08-04 19:36:13 +0000 |
---|---|---|
committer | Stefan Kemper <stefan.kemper@artifex.com> | 2004-08-04 19:36:13 +0000 |
commit | 6c95585894bbef5272bc99f7504e2304b92d6236 (patch) | |
tree | fad6c41436d9698d33babe98ec7f394de1af6e3d /gs/src/zshade.c | |
parent | 53cf8957cca90409aac0092a899afbc18cae33a1 (diff) | |
download | ghostpdl-6c95585894bbef5272bc99f7504e2304b92d6236.tar.gz |
Addition of a Library Context to start the process of removing globals.
DETAILS :
The goals is to remove globals from the system, this includes static
globals that would hinder multiple threads from running at once.
gs_lib_ctx is intended to be used as the opaque "handle" object
that a client would use to associate with a thread running through
the library. Independent of a gs or a language switch build, this
needs a new iapi2.h that allows the use of better job control from the
client side.
gs_lib_ctx is stashed under the gs_memory_t object and all memory objects
used by a thread refer to the same gs_lib_ctx. This storage location was
choosen as a convenence since a memory_t pointer is common throughout the
system. Most of the turmoil is adding memory_t pointers to functions that
used global variables but didn't have a memory pointer.
FILE stdin, stdout, stderr are one per process by default.
stdin and stdout may be changed but stderr may not.
FILE stderr is one per process and shouldn't be changed.
Note the stderr_fn is also one per process, changing this function pointer
will not help as most users of stderr printing do not have a thread handle.
Changing to a thread local storage mechanism can solve this.
gs_id's are currently per thread with each thread starting over at 1.
This can be moved to per process with mutexes if so desired.
A library context has a pointer to the top_of_system the intent is that this
a void handle avaliable to make top of the system calls without knowing the
data type. In a postscript only build this would be gs_main_instance but
in a language switched build this would be an object above that main_universe.
Other members of gs_lib_ctx_t are nothing more than global objects relocated
to this "bag". gs_name_table, dict_autoexpand are examples of this. There
are a few more globals that will be moved.
At the moment iapi is still constrained to one thread, since some of the
globals haven't been removed yet.
The display device's callback function setting is supported for now
but this interface should be changed to a sDEVICE style call.
gs_memory_t is the base type the abstract type gs_raw_memory_t is gone,
this means that all memory types must derive from gs_memory_t.
In addition to a pointer to the gs_lib_ctx there is a pointer to a
non_gc_memory this will always point to a non garbage collected memory,
it maybe the current object or an object below the current gargabe
collected memory space. This can be used were the previous code
used the global gs_malloc_memory. gs_malloc() now takes a memory pointer,
it finds the non-gc memory from a valid memory pointer and allocates from it.
The gdevbit device has an improved algorthym for converting from cmyk to rgb,
this is never used by postscript but for pcl rops it puts the k plane into rgb.
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@5215 a1074d23-0009-0410-80fe-cf8c14f379e6
Diffstat (limited to 'gs/src/zshade.c')
-rw-r--r-- | gs/src/zshade.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/gs/src/zshade.c b/gs/src/zshade.c index d2c097e69..1f4d7a50c 100644 --- a/gs/src/zshade.c +++ b/gs/src/zshade.c @@ -100,7 +100,7 @@ zbuildshadingpattern(i_ctx_t *i_ctx_p) check_type(*op2, t_dictionary); check_dict_read(*op2); gs_pattern2_init(&template); - if ((code = read_matrix(op - 1, &mat)) < 0 || + if ((code = read_matrix(imemory, op - 1, &mat)) < 0 || (code = dict_uid_param(op2, &template.uid, 1, imemory, i_ctx_p)) != 1 || (code = shading_param(op, &template.Shading)) < 0 || (code = int_pattern_alloc(&pdata, op2, imemory)) < 0 @@ -187,7 +187,7 @@ build_shading(i_ctx_t *i_ctx_p, build_shading_proc_t proc) } pcc->pattern = 0; params.Background = pcc; - code = dict_floats_param(op, "Background", + code = dict_floats_param(imemory, op, "Background", gs_color_space_num_components(pcs), pcc->paint.values, NULL); if (code < 0) @@ -196,7 +196,8 @@ build_shading(i_ctx_t *i_ctx_p, build_shading_proc_t proc) } if (dict_find_string(op, "BBox", &pvalue) <= 0) params.have_BBox = false; - else if ((code = dict_floats_param(op, "BBox", 4, box, NULL)) == 4) { + else if ((code = dict_floats_param(imemory, op, "BBox", + 4, box, NULL)) == 4) { params.BBox.p.x = box[0]; params.BBox.p.y = box[1]; params.BBox.q.x = box[2]; @@ -248,7 +249,7 @@ build_shading_function(i_ctx_t *i_ctx_p, const ref * op, gs_function_t ** ppfn, for (i = 0; i < size; ++i) { ref rsubfn; - array_get(pFunction, (long)i, &rsubfn); + array_get(imemory, pFunction, (long)i, &rsubfn); code = fn_build_function(i_ctx_p, &rsubfn, &Functions[i], mem); if (code < 0) break; @@ -301,10 +302,11 @@ build_shading_1(i_ctx_t *i_ctx_p, const ref * op, const gs_shading_params_t * pc *(gs_shading_params_t *)¶ms = *pcommon; gs_make_identity(¶ms.Matrix); params.Function = 0; - if ((code = dict_floats_param(op, "Domain", 4, params.Domain, + if ((code = dict_floats_param(imemory, op, "Domain", + 4, params.Domain, default_Domain)) < 0 || (dict_find_string(op, "Matrix", &pmatrix) > 0 && - (code = read_matrix(pmatrix, ¶ms.Matrix)) < 0) || + (code = read_matrix(imemory, pmatrix, ¶ms.Matrix)) < 0) || (code = build_shading_function(i_ctx_p, op, ¶ms.Function, 2, mem)) < 0 || (code = check_indexed_vs_function(params.ColorSpace, params.Function)) < 0 || (code = gs_shading_Fb_init(ppsh, ¶ms, mem)) < 0 @@ -327,13 +329,14 @@ build_directional_shading(i_ctx_t *i_ctx_p, const ref * op, float *Coords, int n float Domain[2], gs_function_t ** pFunction, bool Extend[2], gs_memory_t *mem) { - int code = dict_floats_param(op, "Coords", num_Coords, Coords, NULL); + int code = dict_floats_param(imemory, op, "Coords", + num_Coords, Coords, NULL); static const float default_Domain[2] = {0, 1}; ref *pExtend; *pFunction = 0; if (code < 0 || - (code = dict_floats_param(op, "Domain", 2, Domain, + (code = dict_floats_param(imemory, op, "Domain", 2, Domain, default_Domain)) < 0 || (code = build_shading_function(i_ctx_p, op, pFunction, 1, mem)) < 0 ) @@ -349,8 +352,10 @@ build_directional_shading(i_ctx_t *i_ctx_p, const ref * op, float *Coords, int n return_error(e_typecheck); else if (r_size(pExtend) != 2) return_error(e_rangecheck); - else if ((array_get(pExtend, 0L, &E0), !r_has_type(&E0, t_boolean)) || - (array_get(pExtend, 1L, &E1), !r_has_type(&E1, t_boolean)) + else if ((array_get(imemory, pExtend, 0L, &E0), + !r_has_type(&E0, t_boolean)) || + (array_get(imemory, pExtend, 1L, &E1), + !r_has_type(&E1, t_boolean)) ) return_error(e_typecheck); Extend[0] = E0.value.boolval, Extend[1] = E1.value.boolval; @@ -432,7 +437,7 @@ build_mesh_shading(i_ctx_t *i_ctx_p, const ref * op, "build_mesh_shading"); if (data == 0) return_error(e_VMerror); - code = process_float_array(pDataSource, size, data); + code = process_float_array(mem, pDataSource, size, data); if (code < 0) { gs_free_object(mem, data, "build_mesh_shading"); return code; @@ -480,7 +485,7 @@ build_mesh_shading(i_ctx_t *i_ctx_p, const ref * op, if (*pDecode == 0) code = gs_note_error(e_VMerror); else { - code = dict_floats_param(op, "Decode", num_decode, *pDecode, NULL); + code = dict_floats_param(mem, op, "Decode", num_decode, *pDecode, NULL); if (code < 0) { gs_free_object(mem, *pDecode, "build_mesh_shading"); *pDecode = 0; |