~ubuntu-branches/ubuntu/hardy/ghostscript/hardy

« back to all changes in this revision

Viewing changes to src/gsstate.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2007-11-22 12:17:43 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071122121743-cd70s3ypq0r243mp
Tags: 8.61.dfsg.1-0ubtuntu1
* New upstream release
  o Final 8.61 release
* debian/patches/09_ijs_krgb_support.dpatch: Adapted to upstream changes.
* debian/rules: Updated CUPS-related variables for "make install" calls.
* debian/rules: Remove /usr/include/ghostscript from the ghostscript
  package, they go into lings-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/* $Id: gsstate.c 8156 2007-07-31 14:19:45Z alexcher $ */
 
14
/* $Id: gsstate.c 8250 2007-09-25 13:31:24Z giles $ */
15
15
/* Miscellaneous graphics state operators for Ghostscript library */
16
16
#include "gx.h"
17
17
#include "memory_.h"
38
38
#include "gxpcolor.h"
39
39
 
40
40
/* Forward references */
41
 
private gs_state *gstate_alloc(gs_memory_t *, client_name_t,
 
41
static gs_state *gstate_alloc(gs_memory_t *, client_name_t,
42
42
                               const gs_state *);
43
 
private gs_state *gstate_clone(gs_state *, gs_memory_t *, client_name_t,
 
43
static gs_state *gstate_clone(gs_state *, gs_memory_t *, client_name_t,
44
44
                               gs_state_copy_reason_t);
45
 
private void gstate_free_contents(gs_state *);
46
 
private int gstate_copy(gs_state *, const gs_state *,
 
45
static void gstate_free_contents(gs_state *);
 
46
static int gstate_copy(gs_state *, const gs_state *,
47
47
                        gs_state_copy_reason_t, client_name_t);
 
48
static void clip_stack_rc_adjust(gx_clip_stack_t *cs, int delta, client_name_t cname);
48
49
 
49
50
/*
50
51
 * Graphics state storage management is complicated.  There are many
153
154
public_st_gs_state();
154
155
 
155
156
/* GC procedures for gs_state */
156
 
private ENUM_PTRS_WITH(gs_state_enum_ptrs, gs_state *gsvptr)
 
157
static ENUM_PTRS_WITH(gs_state_enum_ptrs, gs_state *gsvptr)
157
158
ENUM_PREFIX(st_imager_state, gs_state_num_ptrs + 2);
158
159
#define e1(i,elt) ENUM_PTR(i,gs_state,elt);
159
160
gs_state_do_ptrs(e1)
163
164
ENUM_RETURN(gsvptr->dfilter_stack);
164
165
#undef e1
165
166
ENUM_PTRS_END
166
 
private RELOC_PTRS_WITH(gs_state_reloc_ptrs, gs_state *gsvptr)
 
167
static RELOC_PTRS_WITH(gs_state_reloc_ptrs, gs_state *gsvptr)
167
168
{
168
169
    RELOC_PREFIX(st_imager_state);
169
170
    {
178
179
 
179
180
/* Copy client data, using the copy_for procedure if available, */
180
181
/* the copy procedure otherwise. */
181
 
private int
 
182
static int
182
183
gstate_copy_client_data(gs_state * pgs, void *dto, void *dfrom,
183
184
                        gs_state_copy_reason_t reason)
184
185
{
190
191
/* ------ Operations on the entire graphics state ------ */
191
192
 
192
193
/* Define the initial value of the graphics state. */
193
 
private const gs_imager_state gstate_initial = {
 
194
static const gs_imager_state gstate_initial = {
194
195
    gs_imager_state_initial(1.0)
195
196
};
196
197
 
201
202
 * built between the setcachedevice and the restore must not be freed.
202
203
 * If it weren't for this, we don't think stable memory would be needed.
203
204
 */
204
 
private gs_memory_t *
 
205
static gs_memory_t *
205
206
gstate_path_memory(gs_memory_t *mem)
206
207
{
207
208
    return gs_memory_stable(mem);
490
491
 
491
492
    pgs->view_clip = 0;
492
493
    pnew = gstate_clone(pgs, mem, "gs_gstate", copy_for_gstate);
493
 
    rc_increment(pnew->clip_stack);
 
494
    clip_stack_rc_adjust(pnew->clip_stack, 1, "gs_state_copy");
494
495
    rc_increment(pnew->dfilter_stack);
495
496
    pgs->view_clip = view_clip;
496
497
    if (pnew == 0)
807
808
/* ------ Internal routines ------ */
808
809
 
809
810
/* Free the privately allocated parts of a gstate. */
810
 
private void
 
811
static void
811
812
gstate_free_parts(const gs_state * parts, gs_memory_t * mem, client_name_t cname)
812
813
{
813
814
    gs_free_object(mem, parts->dev_color, cname);
819
820
}
820
821
 
821
822
/* Allocate the privately allocated parts of a gstate. */
822
 
private int
 
823
static int
823
824
gstate_alloc_parts(gs_state * parts, const gs_state * shared,
824
825
                   gs_memory_t * mem, client_name_t cname)
825
826
{
865
866
 * clip_path and view_clip) effective_clip_path share the segments of
866
867
 * pfrom's corresponding path(s).
867
868
 */
868
 
private gs_state *
 
869
static gs_state *
869
870
gstate_alloc(gs_memory_t * mem, client_name_t cname, const gs_state * pfrom)
870
871
{
871
872
    gs_state *pgs =
882
883
}
883
884
 
884
885
/* Copy the dash pattern from one gstate to another. */
885
 
private int
 
886
static int
886
887
gstate_copy_dash(gs_state * pto, const gs_state * pfrom)
887
888
{
888
889
    return gs_setdash(pto, pfrom->line_params.dash.pattern,
894
895
/* Return 0 if the allocation fails. */
895
896
/* If reason is for_gsave, the clone refers to the old contents, */
896
897
/* and we switch the old state to refer to the new contents. */
897
 
private gs_state *
 
898
static gs_state *
898
899
gstate_clone(gs_state * pfrom, gs_memory_t * mem, client_name_t cname,
899
900
             gs_state_copy_reason_t reason)
900
901
{
948
949
    return 0;
949
950
}
950
951
 
 
952
 
 
953
/* Adjust reference counters for the whole clip stack */
 
954
/* accessible from the given point */
 
955
static void
 
956
clip_stack_rc_adjust(gx_clip_stack_t *cs, int delta, client_name_t cname)
 
957
{
 
958
    gx_clip_stack_t *p = cs;  
 
959
 
 
960
    while(p) {
 
961
        gx_clip_stack_t *q = p;
 
962
        p = p->next;  
 
963
        rc_adjust(q, delta, cname);
 
964
    }
 
965
}
 
966
 
951
967
/* Release the composite parts of a graphics state, */
952
968
/* but not the state itself. */
953
 
private void
 
969
static void
954
970
gstate_free_contents(gs_state * pgs)
955
971
{
956
972
    gs_memory_t *mem = pgs->memory;
957
973
    const char *const cname = "gstate_free_contents";
958
974
 
959
975
    rc_decrement(pgs->device, cname);
960
 
    rc_decrement(pgs->clip_stack, cname);
 
976
    clip_stack_rc_adjust(pgs->clip_stack, -1, cname);
961
977
    rc_decrement(pgs->dfilter_stack, cname);
962
978
    cs_adjust_counts(pgs, -1);
963
979
    if (pgs->client_data != 0)
968
984
}
969
985
 
970
986
/* Copy one gstate to another. */
971
 
private int
 
987
static int
972
988
gstate_copy(gs_state * pto, const gs_state * pfrom,
973
989
            gs_state_copy_reason_t reason, client_name_t cname)
974
990
{
1009
1025
    *parts.ccolor = *pfrom->ccolor;
1010
1026
    *parts.dev_color = *pfrom->dev_color;
1011
1027
    /* Handle references from gstate object. */
1012
 
#define RCCOPY(element)\
1013
 
    rc_pre_assign(pto->element, pfrom->element, cname)
1014
 
    RCCOPY(device);
1015
 
    RCCOPY(clip_stack);
1016
 
    RCCOPY(dfilter_stack);
 
1028
    rc_pre_assign(pto->device, pfrom->device, cname);
 
1029
    rc_pre_assign(pto->dfilter_stack, pfrom->dfilter_stack, cname);
 
1030
    if (pto->clip_stack != pfrom->clip_stack) {
 
1031
        clip_stack_rc_adjust(pfrom->clip_stack, 1, cname);
 
1032
        clip_stack_rc_adjust(pto->clip_stack, -1, cname);
 
1033
    }
1017
1034
    {
1018
1035
        struct gx_pattern_cache_s *pcache = pto->pattern_cache;
1019
1036
        void *pdata = pto->client_data;
1038
1055
    }
1039
1056
    GSTATE_ASSIGN_PARTS(pto, &parts);
1040
1057
    cs_adjust_counts(pto, 1);
1041
 
#undef RCCOPY
1042
1058
    pto->show_gstate =
1043
1059
        (pfrom->show_gstate == pfrom ? pto : 0);
1044
1060
    return 0;