Debian Codegraph @

doc/defuns-cairo-surface.xml.texi

raw
1
2 @c %start of fragment
3
4 @deffn Function cairo-surface-create-similar (@var{other}@tie{}@code{<cairo-surface-t>}) (@var{content}@tie{}@code{<cairo-content-t>}) (@var{width}@tie{}@code{<int>}) (@var{height}@tie{}@code{<int>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-surface-t >})
5 Create a new surface that is as compatible as possible with an existing
6 surface. For example the new surface will have the same fallback
7 resolution and font options as @var{other}. Generally, the new surface
8 will also use the same backend as @var{other}, unless that is not
9 possible for some reason. The type of the returned surface may be
10 examined with @code{cairo-surface-get-type}.
11
12 Initially the surface contents are all 0 (transparent if contents have
13 transparency, black otherwise.)
14
15 @table @var
16 @item other
17 an existing surface used to select the backend of the new surface
18
19 @item content
20 the content for the new surface
21
22 @item width
23 width of the new surface, (in device-space units)
24
25 @item height
26 height of the new surface (in device-space units)
27
28 @item ret
29 a pointer to the newly allocated surface. The caller owns the surface
30 and should call @code{cairo-surface-destroy} when done with it. This
31 function always returns a valid pointer, but it will return a pointer to
32 a "nil" surface if @var{other} is already in an error state or any other
33 error occurs.
34
35 @end table
36
37 @end deffn
38
39 @deffn Function cairo-surface-create-for-rectangle (@var{target}@tie{}@code{<cairo-surface-t>}) (@var{x}@tie{}@code{<double>}) (@var{y}@tie{}@code{<double>}) (@var{width}@tie{}@code{<double>}) (@var{height}@tie{}@code{<double>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-surface-t >})
40 Create a new surface that is a rectangle within the target surface. All
41 operations drawn to this surface are then clipped and translated onto
42 the target surface. Nothing drawn via this sub-surface outside of its
43 bounds is drawn onto the target surface, making this a useful method for
44 passing constrained child surfaces to library routines that draw
45 directly onto the parent surface, i.e. with no further backend
46 allocations, double buffering or copies.
47
48 The semantics of subsurfaces have not been finalized yet unless the
49 rectangle is in full device units, is contained within the extents of
50 the target surface, and the target or subsurface's device transforms are
51 not changed.
52
53 @table @var
54 @item target
55 an existing surface for which the sub-surface will point to
56
57 @item x
58 the x-origin of the sub-surface from the top-left of the target surface
59 (in device-space units)
60
61 @item y
62 the y-origin of the sub-surface from the top-left of the target surface
63 (in device-space units)
64
65 @item width
66 width of the sub-surface (in device-space units)
67
68 @item height
69 height of the sub-surface (in device-space units)
70
71 @item ret
72 a pointer to the newly allocated surface. The caller owns the surface
73 and should call @code{cairo-surface-destroy} when done with it. This
74 function always returns a valid pointer, but it will return a pointer to
75 a "nil" surface if @var{other} is already in an error state or any other
76 error occurs.
77
78 @end table
79
80 Since 1.10
81
82 @end deffn
83
84 @deffn Function cairo-surface-finish (@var{surface}@tie{}@code{<cairo-surface-t>})
85 This function finishes the surface and drops all references to external
86 resources. For example, for the Xlib backend it means that cairo will no
87 longer access the drawable, which can be freed. After calling
88 @code{cairo-surface-finish} the only valid operations on a surface are
89 getting and setting user, referencing and destroying, and flushing and
90 finishing it. Further drawing to the surface will not affect the surface
91 but will instead trigger a @samp{CAIRO_STATUS_SURFACE_FINISHED} error.
92
93 When the last call to @code{cairo-surface-destroy} decreases the
94 reference count to zero, cairo will call @code{cairo-surface-finish} if
95 it hasn't been called already, before freeing the resources associated
96 with the surface.
97
98 @table @var
99 @item surface
100 the @code{<cairo-surface-t>} to finish
101
102 @end table
103
104 @end deffn
105
106 @deffn Function cairo-surface-flush (@var{surface}@tie{}@code{<cairo-surface-t>})
107 Do any pending drawing for the surface and also restore any temporary
108 modifications cairo has made to the surface's state. This function must
109 be called before switching from drawing on the surface with cairo to
110 drawing on it directly with native APIs. If the surface doesn't support
111 direct access, then this function does nothing.
112
113 @table @var
114 @item surface
115 a @code{<cairo-surface-t>}
116
117 @end table
118
119 @end deffn
120
121 @deffn Function cairo-surface-get-device (@var{surface}@tie{}@code{<cairo-surface-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-device-t >})
122 This function returns the device for a @var{surface}. See
123 @code{<cairo-device-t>}.
124
125 @table @var
126 @item surface
127 a @code{<cairo-surface-t>}
128
129 @item ret
130 The device for @var{surface} or @samp{@code{#f}} if the surface does not
131 have an associated device.
132
133 @end table
134
135 Since 1.10
136
137 @end deffn
138
139 @deffn Function cairo-surface-get-font-options (@var{surface}@tie{}@code{<cairo-surface-t>}) (@var{options}@tie{}@code{<cairo-font-options-t>})
140 Retrieves the default font rendering options for the surface. This
141 allows display surfaces to report the correct subpixel order for
142 rendering on them, print surfaces to disable hinting of metrics and so
143 forth. The result can then be used with @code{cairo-scaled-font-create}.
144
145 @table @var
146 @item surface
147 a @code{<cairo-surface-t>}
148
149 @item options
150 a @code{<cairo-font-options-t>} object into which to store the retrieved
151 options. All existing values are overwritten
152
153 @end table
154
155 @end deffn
156
157 @deffn Function cairo-surface-get-content (@var{surface}@tie{}@code{<cairo-surface-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-content-t>})
158 This function returns the content type of @var{surface} which indicates
159 whether the surface contains color and/or alpha information. See
160 @code{<cairo-content-t>}.
161
162 @table @var
163 @item surface
164 a @code{<cairo-surface-t>}
165
166 @item ret
167 The content type of @var{surface}.
168
169 @end table
170
171 Since 1.2
172
173 @end deffn
174
175 @deffn Function cairo-surface-mark-dirty (@var{surface}@tie{}@code{<cairo-surface-t>})
176 Tells cairo that drawing has been done to surface using means other than
177 cairo, and that cairo should reread any cached areas. Note that you must
178 call @code{cairo-surface-flush} before doing such drawing.
179
180 @table @var
181 @item surface
182 a @code{<cairo-surface-t>}
183
184 @end table
185
186 @end deffn
187
188 @deffn Function cairo-surface-mark-dirty-rectangle (@var{surface}@tie{}@code{<cairo-surface-t>}) (@var{x}@tie{}@code{<int>}) (@var{y}@tie{}@code{<int>}) (@var{width}@tie{}@code{<int>}) (@var{height}@tie{}@code{<int>})
189 Like @code{cairo-surface-mark-dirty}, but drawing has been done only to
190 the specified rectangle, so that cairo can retain cached contents for
191 other parts of the surface.
192
193 Any cached clip set on the surface will be reset by this function, to
194 make sure that future cairo calls have the clip set that they expect.
195
196 @table @var
197 @item surface
198 a @code{<cairo-surface-t>}
199
200 @item x
201 X coordinate of dirty rectangle
202
203 @item y
204 Y coordinate of dirty rectangle
205
206 @item width
207 width of dirty rectangle
208
209 @item height
210 height of dirty rectangle
211
212 @end table
213
214 @end deffn
215
216 @deffn Function cairo-surface-set-device-offset (@var{surface}@tie{}@code{<cairo-surface-t>}) (@var{x-offset}@tie{}@code{<double>}) (@var{y-offset}@tie{}@code{<double>})
217 Sets an offset that is added to the device coordinates determined by the
218 CTM when drawing to @var{surface}. One use case for this function is
219 when we want to create a @code{<cairo-surface-t>} that redirects drawing
220 for a portion of an onscreen surface to an offscreen surface in a way
221 that is completely invisible to the user of the cairo API. Setting a
222 transformation via @code{cairo-translate} isn't sufficient to do this,
223 since functions like @code{cairo-device-to-user} will expose the hidden
224 offset.
225
226 Note that the offset affects drawing to the surface as well as using the
227 surface in a source pattern.
228
229 @table @var
230 @item surface
231 a @code{<cairo-surface-t>}
232
233 @item x-offset
234 the offset in the X direction, in device units
235
236 @item y-offset
237 the offset in the Y direction, in device units
238
239 @end table
240
241 @end deffn
242
243 @deffn Function cairo-surface-get-device-offset (@var{surface}@tie{}@code{<cairo-surface-t>}) @result{}@tie{} (@var{x-offset}@tie{}@code{<double>}) (@var{y-offset}@tie{}@code{<double>})
244 This function returns the previous device offset set by
245 @code{cairo-surface-set-device-offset}.
246
247 @table @var
248 @item surface
249 a @code{<cairo-surface-t>}
250
251 @item x-offset
252 the offset in the X direction, in device units
253
254 @item y-offset
255 the offset in the Y direction, in device units
256
257 @end table
258
259 Since 1.2
260
261 @end deffn
262
263 @deffn Function cairo-surface-get-type (@var{surface}@tie{}@code{<cairo-surface-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-surface-type-t>})
264 This function returns the type of the backend used to create a surface.
265 See @code{<cairo-surface-type-t>} for available types.
266
267 @table @var
268 @item surface
269 a @code{<cairo-surface-t>}
270
271 @item ret
272 The type of @var{surface}.
273
274 @end table
275
276 Since 1.2
277
278 @end deffn
279
280 @deffn Function cairo-surface-copy-page (@var{surface}@tie{}@code{<cairo-surface-t>})
281 Emits the current page for backends that support multiple pages, but
282 doesn't clear it, so that the contents of the current page will be
283 retained for the next page. Use @code{cairo-surface-show-page} if you
284 want to get an empty page after the emission.
285
286 There is a convenience function for this that takes a @code{<cairo-t>},
287 namely @code{cairo-copy-page}.
288
289 @table @var
290 @item surface
291 a @code{<cairo-surface-t>}
292
293 @end table
294
295 Since 1.6
296
297 @end deffn
298
299 @deffn Function cairo-surface-show-page (@var{surface}@tie{}@code{<cairo-surface-t>})
300 Emits and clears the current page for backends that support multiple
301 pages. Use @code{cairo-surface-copy-page} if you don't want to clear the
302 page.
303
304 There is a convenience function for this that takes a @code{<cairo-t>},
305 namely @code{cairo-show-page}.
306
307 @table @var
308 @item surface
309 a @code{<cairo--surface-t>}
310
311 @end table
312
313 Since 1.6
314
315 @end deffn
316
317 @deffn Function cairo-surface-has-show-text-glyphs (@var{surface}@tie{}@code{<cairo-surface-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-bool-t>})
318 Returns whether the surface supports sophisticated
319 @code{cairo-show-text-glyphs} operations. That is, whether it actually
320 uses the provided text and cluster data to a
321 @code{cairo-show-text-glyphs} call.
322
323 Note: Even if this function returns @samp{@code{#f}}, a
324 @code{cairo-show-text-glyphs} operation targeted at @var{surface} will
325 still succeed. It just will act like a @code{cairo-show-glyphs}
326 operation. Users can use this function to avoid computing UTF-8 text and
327 cluster mapping if the target surface does not use it.
328
329 @table @var
330 @item surface
331 a @code{<cairo-surface-t>}
332
333 @item ret
334 @samp{@code{#t}} if @var{surface} supports
335 @code{cairo-show-text-glyphs}, @samp{@code{#f}} otherwise
336
337 @end table
338
339 Since 1.8
340
341 @end deffn
342
343 @deffn Function cairo-surface-get-mime-data (@var{surface}@tie{}@code{<cairo-surface-t>}) (@var{mime-type}@tie{}@code{<string>}) @result{}@tie{} (@var{ret}@tie{}@code{<bytevector>})
344 Return data previously associated with the surface with the given
345 @var{mime-type}.
346
347 @table @var
348 @item surface
349 a @code{<cairo-surface-t>}
350
351 @item mime-type
352 a string denoting the MIME type, for example @code{"image/jpeg"},
353 @code{"image/png"}, @code{"image/jp2"}, or @code{"text/x-uri"}
354
355 @item ret
356 @code{#f} if no data was associated with the surface, otherwise a
357 fresh bytevector holding a copy of the data
358
359 @end table
360
361 Since 1.11
362
363 @end deffn
364
365 @deffn Function cairo-surface-set-mime-data (@var{surface}@tie{}@code{<cairo-surface-t>}) (@var{mime-type}@tie{}@code{<string>}) (@var{data}@tie{}@code{<bytevector>})
366 Associate image data with a surface with the given @var{mime-type}.
367
368 Attach an image in the format @var{mime_type} to @var{surface}. To
369 remove the data from a surface, call this function with same mime type
370 and @code{#f} for @var{data}.
371
372 The attached image (or filename) data can later be used by backends
373 which support it (currently: PDF, PS, SVG and Win32 Printing surfaces)
374 to emit this data instead of making a snapshot of the @var{surface}.
375 This approach tends to be faster and requires less memory and disk
376 space.
377
378 See corresponding backend surface docs for details about which MIME
379 types it can handle. Caution: the associated MIME data will be
380 discarded if you draw on the surface afterwards. Use this function
381 with care.
382
383 Even if a backend supports a MIME type, that does not mean cairo
384 will always be able to use the attached MIME data. For example, if
385 the backend does not natively support the compositing operation used
386 to apply the MIME data to the backend. In that case, the MIME data
387 will be ignored. Therefore, to apply an image in all cases, it is best
388 to create an image surface which contains the decoded image data and
389 then attach the MIME data to that. This ensures the image will always
390 be used while still allowing the MIME data to be used whenever
391 possible.
392
393 @table @var
394 @item surface
395 a @code{<cairo-surface-t>}
396
397 @item mime-type
398 a string denoting the MIME type, for example @code{"image/jpeg"},
399 @code{"image/png"}, @code{"image/jp2"}, or @code{"text/x-uri"}
400
401 @item data
402 a bytevector of data to associate with the surface, or @code{#f} to
403 remove the association
404
405 @end table
406
407 Since 1.11
408
409 @end deffn
410
411 @c %end of fragment