Tizen 2.0 Release
[framework/graphics/cairo.git] / src / cairo-pdf-surface-private.h
1 /* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
2 /* cairo - a vector graphics library with display and print output
3  *
4  * Copyright © 2004 Red Hat, Inc
5  * Copyright © 2006 Red Hat, Inc
6  * Copyright © 2007, 2008 Adrian Johnson
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it either under the terms of the GNU Lesser General Public
10  * License version 2.1 as published by the Free Software Foundation
11  * (the "LGPL") or, at your option, under the terms of the Mozilla
12  * Public License Version 1.1 (the "MPL"). If you do not alter this
13  * notice, a recipient may use your version of this file under either
14  * the MPL or the LGPL.
15  *
16  * You should have received a copy of the LGPL along with this library
17  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
19  * You should have received a copy of the MPL along with this library
20  * in the file COPYING-MPL-1.1
21  *
22  * The contents of this file are subject to the Mozilla Public License
23  * Version 1.1 (the "License"); you may not use this file except in
24  * compliance with the License. You may obtain a copy of the License at
25  * http://www.mozilla.org/MPL/
26  *
27  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
28  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
29  * the specific language governing rights and limitations.
30  *
31  * The Original Code is the cairo graphics library.
32  *
33  * The Initial Developer of the Original Code is University of Southern
34  * California.
35  *
36  * Contributor(s):
37  *      Kristian Høgsberg <krh@redhat.com>
38  *      Carl Worth <cworth@cworth.org>
39  *      Adrian Johnson <ajohnson@redneon.com>
40  */
41
42 #ifndef CAIRO_PDF_SURFACE_PRIVATE_H
43 #define CAIRO_PDF_SURFACE_PRIVATE_H
44
45 #include "cairo-pdf.h"
46
47 #include "cairo-surface-private.h"
48 #include "cairo-surface-clipper-private.h"
49 #include "cairo-pdf-operators-private.h"
50 #include "cairo-path-fixed-private.h"
51
52 typedef struct _cairo_pdf_resource {
53     unsigned int id;
54 } cairo_pdf_resource_t;
55
56 #define CAIRO_NUM_OPERATORS (CAIRO_OPERATOR_HSL_LUMINOSITY + 1)
57
58 typedef struct _cairo_pdf_group_resources {
59     cairo_bool_t  operators[CAIRO_NUM_OPERATORS];
60     cairo_array_t alphas;
61     cairo_array_t smasks;
62     cairo_array_t patterns;
63     cairo_array_t shadings;
64     cairo_array_t xobjects;
65     cairo_array_t fonts;
66 } cairo_pdf_group_resources_t;
67
68 typedef struct _cairo_pdf_source_surface_entry {
69     cairo_hash_entry_t base;
70     unsigned int id;
71     unsigned char *unique_id;
72     unsigned long unique_id_length;
73     cairo_bool_t interpolate;
74     cairo_bool_t stencil_mask;
75     cairo_pdf_resource_t surface_res;
76     int width;
77     int height;
78     cairo_rectangle_int_t extents;
79 } cairo_pdf_source_surface_entry_t;
80
81 typedef struct _cairo_pdf_source_surface {
82     cairo_pattern_type_t type;
83     cairo_surface_t *surface;
84     cairo_pattern_t *raster_pattern;
85     cairo_pdf_source_surface_entry_t *hash_entry;
86 } cairo_pdf_source_surface_t;
87
88 typedef struct _cairo_pdf_pattern {
89     double width;
90     double height;
91     cairo_rectangle_int_t extents;
92     cairo_pattern_t *pattern;
93     cairo_pdf_resource_t pattern_res;
94     cairo_pdf_resource_t gstate_res;
95     cairo_bool_t is_shading;
96 } cairo_pdf_pattern_t;
97
98 typedef enum _cairo_pdf_operation {
99     PDF_PAINT,
100     PDF_MASK,
101     PDF_FILL,
102     PDF_STROKE,
103     PDF_SHOW_GLYPHS
104 } cairo_pdf_operation_t;
105
106 typedef struct _cairo_pdf_smask_group {
107     double                width;
108     double                height;
109     cairo_rectangle_int_t extents;
110     cairo_pdf_resource_t  group_res;
111     cairo_pdf_operation_t operation;
112     cairo_pattern_t      *source;
113     cairo_pdf_resource_t  source_res;
114     cairo_pattern_t      *mask;
115     cairo_path_fixed_t    path;
116     cairo_fill_rule_t     fill_rule;
117     cairo_stroke_style_t  style;
118     cairo_matrix_t        ctm;
119     cairo_matrix_t        ctm_inverse;
120     char                 *utf8;
121     int                   utf8_len;
122     cairo_glyph_t        *glyphs;
123     int                   num_glyphs;
124     cairo_text_cluster_t *clusters;
125     int                   num_clusters;
126     cairo_bool_t          cluster_flags;
127     cairo_scaled_font_t  *scaled_font;
128 } cairo_pdf_smask_group_t;
129
130 typedef struct _cairo_pdf_surface cairo_pdf_surface_t;
131
132 struct _cairo_pdf_surface {
133     cairo_surface_t base;
134
135     /* Prefer the name "output" here to avoid confusion over the
136      * structure within a PDF document known as a "stream". */
137     cairo_output_stream_t *output;
138
139     double width;
140     double height;
141     cairo_matrix_t cairo_to_pdf;
142
143     cairo_array_t objects;
144     cairo_array_t pages;
145     cairo_array_t rgb_linear_functions;
146     cairo_array_t alpha_linear_functions;
147     cairo_array_t page_patterns;
148     cairo_array_t page_surfaces;
149     cairo_hash_table_t *all_surfaces;
150     cairo_array_t smask_groups;
151     cairo_array_t knockout_group;
152
153     cairo_scaled_font_subsets_t *font_subsets;
154     cairo_array_t fonts;
155
156     cairo_pdf_resource_t next_available_resource;
157     cairo_pdf_resource_t pages_resource;
158
159     cairo_pdf_version_t pdf_version;
160     cairo_bool_t compress_content;
161
162     cairo_pdf_resource_t content;
163     cairo_pdf_resource_t content_resources;
164     cairo_pdf_group_resources_t resources;
165     cairo_bool_t has_fallback_images;
166     cairo_bool_t header_emitted;
167
168     struct {
169         cairo_bool_t active;
170         cairo_pdf_resource_t self;
171         cairo_pdf_resource_t length;
172         long start_offset;
173         cairo_bool_t compressed;
174         cairo_output_stream_t *old_output;
175     } pdf_stream;
176
177     struct {
178         cairo_bool_t active;
179         cairo_output_stream_t *stream;
180         cairo_output_stream_t *mem_stream;
181         cairo_output_stream_t *old_output;
182         cairo_pdf_resource_t   resource;
183         cairo_box_double_t     bbox;
184         cairo_bool_t is_knockout;
185     } group_stream;
186
187     cairo_surface_clipper_t clipper;
188
189     cairo_pdf_operators_t pdf_operators;
190     cairo_paginated_mode_t paginated_mode;
191     cairo_bool_t select_pattern_gstate_saved;
192
193     cairo_bool_t force_fallbacks;
194
195     cairo_operator_t current_operator;
196     cairo_bool_t current_pattern_is_solid_color;
197     cairo_bool_t current_color_is_stroke;
198     double current_color_red;
199     double current_color_green;
200     double current_color_blue;
201     double current_color_alpha;
202
203     cairo_surface_t *paginated_surface;
204 };
205
206 #endif /* CAIRO_PDF_SURFACE_PRIVATE_H */