1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = cairo-cairo-surface-t.html
27  * outPack = cairo
28  * outFile = Surface
29  * strct   = cairo_surface_t
30  * realStrct=
31  * ctorStrct=
32  * clss    = Surface
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- cairo_surface_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * 	- cairo_surface_get_mime_data
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- cairo.Device
49  * 	- cairo.FontOption
50  * 	- gdk.Window
51  * 	- gtkc.gdk
52  * structWrap:
53  * 	- cairo_device_t* -> Device
54  * 	- cairo_font_options_t* -> FontOption
55  * 	- cairo_surface_t* -> Surface
56  * module aliases:
57  * local aliases:
58  * overrides:
59  */
60 
61 module cairo.Surface;
62 
63 public  import gtkc.cairotypes;
64 
65 private import gtkc.cairo;
66 private import glib.ConstructionException;
67 
68 
69 private import glib.Str;
70 private import cairo.Device;
71 private import cairo.FontOption;
72 private import gdk.Window;
73 private import gtkc.gdk;
74 
75 
76 
77 
78 /**
79  * cairo_surface_t is the abstract type representing all different drawing
80  * targets that cairo can render to. The actual drawings are
81  * performed using a cairo context.
82  *
83  * A cairo surface is created by using backend-specific
84  * constructors, typically of the form
85  * cairo_backend_surface_create().
86  *
87  * Most surface types allow accessing the surface without using Cairo
88  * functions. If you do this, keep in mind that it is mandatory that you call
89  * cairo_surface_flush() before reading from or writing to the surface and that
90  * you must use cairo_surface_mark_dirty() after modifying it.
91  *
92  * $(DDOC_COMMENT example)
93  *
94  * Note that for other surface types it might be necessary to acquire the
95  * surface's device first. See cairo_device_acquire() for a discussion of
96  * devices.
97  */
98 public class Surface
99 {
100 	
101 	/** the main Gtk struct */
102 	protected cairo_surface_t* cairo_surface;
103 	
104 	
105 	public cairo_surface_t* getSurfaceStruct()
106 	{
107 		return cairo_surface;
108 	}
109 	
110 	
111 	/** the main Gtk struct as a void* */
112 	protected void* getStruct()
113 	{
114 		return cast(void*)cairo_surface;
115 	}
116 	
117 	/**
118 	 * Sets our main struct and passes it to the parent class
119 	 */
120 	public this (cairo_surface_t* cairo_surface)
121 	{
122 		this.cairo_surface = cairo_surface;
123 	}
124 	
125 	this(Window window, cairo_content_t content, int width,int height)
126 	{
127 		this(gdk_window_create_similar_surface(window.getWindowStruct(), content, width, height));
128 	}
129 	
130 	/**
131 	 * Return mime data previously attached to surface using the
132 	 * specified mime type. If no data has been attached with the given
133 	 * mime type, data is set NULL.
134 	 * Since 1.10
135 	 * Params:
136 	 * mimeType = the mime type of the image data
137 	 * data = the image data to attached to the surface
138 	 */
139 	public void getMimeData(string mimeType, out ubyte[] data)
140 	{
141 		// void cairo_surface_get_mime_data (cairo_surface_t *surface,  const char *mime_type,  unsigned char **data,  unsigned long *length);
142 		uchar* outdata = null;
143 		ulong length;
144 		
145 		cairo_surface_get_mime_data(cairo_surface, Str.toStringz(mimeType), &outdata, &length);
146 		
147 		data = outdata[0 .. cast(size_t)length];
148 	}
149 	
150 	/**
151 	 */
152 	
153 	/**
154 	 * Create a new surface that is as compatible as possible with an
155 	 * existing surface. For example the new surface will have the same
156 	 * fallback resolution and font options as other. Generally, the new
157 	 * surface will also use the same backend as other, unless that is
158 	 * not possible for some reason. The type of the returned surface may
159 	 * be examined with cairo_surface_get_type().
160 	 * Initially the surface contents are all 0 (transparent if contents
161 	 * have transparency, black otherwise.)
162 	 * Use cairo_surface_create_similar_image() if you need an image surface
163 	 * which can be painted quickly to the target surface.
164 	 * Since 1.0
165 	 * Params:
166 	 * content = the content for the new surface
167 	 * width = width of the new surface, (in device-space units)
168 	 * height = height of the new surface (in device-space units)
169 	 * Returns: a pointer to the newly allocated surface. The caller owns the surface and should call cairo_surface_destroy() when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" surface if other is already in an error state or any other error occurs.
170 	 */
171 	public Surface createSimilar(cairo_content_t content, int width, int height)
172 	{
173 		// cairo_surface_t * cairo_surface_create_similar (cairo_surface_t *other,  cairo_content_t content,  int width,  int height);
174 		auto p = cairo_surface_create_similar(cairo_surface, content, width, height);
175 		
176 		if(p is null)
177 		{
178 			return null;
179 		}
180 		
181 		return new Surface(cast(cairo_surface_t*) p);
182 	}
183 	
184 	/**
185 	 * Create a new image surface that is as compatible as possible for uploading
186 	 * to and the use in conjunction with an existing surface. However, this surface
187 	 * can still be used like any normal image surface.
188 	 * Initially the surface contents are all 0 (transparent if contents
189 	 * have transparency, black otherwise.)
190 	 * Use cairo_surface_create_similar() if you don't need an image surface.
191 	 * Since 1.12
192 	 * Params:
193 	 * format = the format for the new surface
194 	 * width = width of the new surface, (in device-space units)
195 	 * height = height of the new surface (in device-space units)
196 	 * Returns: a pointer to the newly allocated image surface. The caller owns the surface and should call cairo_surface_destroy() when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" surface if other is already in an error state or any other error occurs.
197 	 */
198 	public Surface createSimilarImage(cairo_format_t format, int width, int height)
199 	{
200 		// cairo_surface_t * cairo_surface_create_similar_image (cairo_surface_t *other,  cairo_format_t format,  int width,  int height);
201 		auto p = cairo_surface_create_similar_image(cairo_surface, format, width, height);
202 		
203 		if(p is null)
204 		{
205 			return null;
206 		}
207 		
208 		return new Surface(cast(cairo_surface_t*) p);
209 	}
210 	
211 	/**
212 	 * Create a new surface that is a rectangle within the target surface.
213 	 * All operations drawn to this surface are then clipped and translated
214 	 * onto the target surface. Nothing drawn via this sub-surface outside of
215 	 * its bounds is drawn onto the target surface, making this a useful method
216 	 * for passing constrained child surfaces to library routines that draw
217 	 * directly onto the parent surface, i.e. with no further backend allocations,
218 	 * double buffering or copies.
219 	 * Note
220 	 * The semantics of subsurfaces have not been finalized yet
221 	 * unless the rectangle is in full device units, is contained within
222 	 * the extents of the target surface, and the target or subsurface's
223 	 * device transforms are not changed.
224 	 * Since 1.10
225 	 * Params:
226 	 * x = the x-origin of the sub-surface from the top-left of the target surface (in device-space units)
227 	 * y = the y-origin of the sub-surface from the top-left of the target surface (in device-space units)
228 	 * width = width of the sub-surface (in device-space units)
229 	 * height = height of the sub-surface (in device-space units)
230 	 * Returns: a pointer to the newly allocated surface. The caller owns the surface and should call cairo_surface_destroy() when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" surface if other is already in an error state or any other error occurs.
231 	 */
232 	public Surface createForRectangle(double x, double y, double width, double height)
233 	{
234 		// cairo_surface_t * cairo_surface_create_for_rectangle (cairo_surface_t *target,  double x,  double y,  double width,  double height);
235 		auto p = cairo_surface_create_for_rectangle(cairo_surface, x, y, width, height);
236 		
237 		if(p is null)
238 		{
239 			return null;
240 		}
241 		
242 		return new Surface(cast(cairo_surface_t*) p);
243 	}
244 	
245 	/**
246 	 * Increases the reference count on surface by one. This prevents
247 	 * surface from being destroyed until a matching call to
248 	 * cairo_surface_destroy() is made.
249 	 * The number of references to a cairo_surface_t can be get using
250 	 * cairo_surface_get_reference_count().
251 	 * Since 1.0
252 	 * Returns: the referenced cairo_surface_t.
253 	 */
254 	public Surface reference()
255 	{
256 		// cairo_surface_t * cairo_surface_reference (cairo_surface_t *surface);
257 		auto p = cairo_surface_reference(cairo_surface);
258 		
259 		if(p is null)
260 		{
261 			return null;
262 		}
263 		
264 		return new Surface(cast(cairo_surface_t*) p);
265 	}
266 	
267 	/**
268 	 * Decreases the reference count on surface by one. If the result is
269 	 * zero, then surface and all associated resources are freed. See
270 	 * cairo_surface_reference().
271 	 * Since 1.0
272 	 */
273 	public void destroy()
274 	{
275 		// void cairo_surface_destroy (cairo_surface_t *surface);
276 		cairo_surface_destroy(cairo_surface);
277 	}
278 	
279 	/**
280 	 * Checks whether an error has previously occurred for this
281 	 * surface.
282 	 * Since 1.0
283 	 * Returns: CAIRO_STATUS_SUCCESS, CAIRO_STATUS_NULL_POINTER, CAIRO_STATUS_NO_MEMORY, CAIRO_STATUS_READ_ERROR, CAIRO_STATUS_INVALID_CONTENT, CAIRO_STATUS_INVALID_FORMAT, or CAIRO_STATUS_INVALID_VISUAL.
284 	 */
285 	public cairo_status_t status()
286 	{
287 		// cairo_status_t cairo_surface_status (cairo_surface_t *surface);
288 		return cairo_surface_status(cairo_surface);
289 	}
290 	
291 	/**
292 	 * This function finishes the surface and drops all references to
293 	 * external resources. For example, for the Xlib backend it means
294 	 * that cairo will no longer access the drawable, which can be freed.
295 	 * After calling cairo_surface_finish() the only valid operations on a
296 	 * surface are getting and setting user, referencing and
297 	 * destroying, and flushing and finishing it.
298 	 * Further drawing to the surface will not affect the
299 	 * surface but will instead trigger a CAIRO_STATUS_SURFACE_FINISHED
300 	 * error.
301 	 * When the last call to cairo_surface_destroy() decreases the
302 	 * reference count to zero, cairo will call cairo_surface_finish() if
303 	 * it hasn't been called already, before freeing the resources
304 	 * associated with the surface.
305 	 * Since 1.0
306 	 */
307 	public void finish()
308 	{
309 		// void cairo_surface_finish (cairo_surface_t *surface);
310 		cairo_surface_finish(cairo_surface);
311 	}
312 	
313 	/**
314 	 * Do any pending drawing for the surface and also restore any
315 	 * temporary modifications cairo has made to the surface's
316 	 * state. This function must be called before switching from
317 	 * drawing on the surface with cairo to drawing on it directly
318 	 * with native APIs. If the surface doesn't support direct access,
319 	 * then this function does nothing.
320 	 * Since 1.0
321 	 */
322 	public void flush()
323 	{
324 		// void cairo_surface_flush (cairo_surface_t *surface);
325 		cairo_surface_flush(cairo_surface);
326 	}
327 	
328 	/**
329 	 * This function returns the device for a surface.
330 	 * See cairo_device_t.
331 	 * Since 1.10
332 	 * Returns: The device for surface or NULL if the surface does not have an associated device.
333 	 */
334 	public Device getDevice()
335 	{
336 		// cairo_device_t * cairo_surface_get_device (cairo_surface_t *surface);
337 		auto p = cairo_surface_get_device(cairo_surface);
338 		
339 		if(p is null)
340 		{
341 			return null;
342 		}
343 		
344 		return new Device(cast(cairo_device_t*) p);
345 	}
346 	
347 	/**
348 	 * Retrieves the default font rendering options for the surface.
349 	 * This allows display surfaces to report the correct subpixel order
350 	 * for rendering on them, print surfaces to disable hinting of
351 	 * metrics and so forth. The result can then be used with
352 	 * cairo_scaled_font_create().
353 	 * Since 1.0
354 	 * Params:
355 	 * options = a cairo_font_options_t object into which to store
356 	 * the retrieved options. All existing values are overwritten
357 	 */
358 	public void getFontOptions(FontOption options)
359 	{
360 		// void cairo_surface_get_font_options (cairo_surface_t *surface,  cairo_font_options_t *options);
361 		cairo_surface_get_font_options(cairo_surface, (options is null) ? null : options.getFontOptionStruct());
362 	}
363 	
364 	/**
365 	 * This function returns the content type of surface which indicates
366 	 * whether the surface contains color and/or alpha information. See
367 	 * cairo_content_t.
368 	 * Since 1.2
369 	 * Returns: The content type of surface.
370 	 */
371 	public cairo_content_t getContent()
372 	{
373 		// cairo_content_t cairo_surface_get_content (cairo_surface_t *surface);
374 		return cairo_surface_get_content(cairo_surface);
375 	}
376 	
377 	/**
378 	 * Tells cairo that drawing has been done to surface using means other
379 	 * than cairo, and that cairo should reread any cached areas. Note
380 	 * that you must call cairo_surface_flush() before doing such drawing.
381 	 * Since 1.0
382 	 */
383 	public void markDirty()
384 	{
385 		// void cairo_surface_mark_dirty (cairo_surface_t *surface);
386 		cairo_surface_mark_dirty(cairo_surface);
387 	}
388 	
389 	/**
390 	 * Like cairo_surface_mark_dirty(), but drawing has been done only to
391 	 * the specified rectangle, so that cairo can retain cached contents
392 	 * for other parts of the surface.
393 	 * Any cached clip set on the surface will be reset by this function,
394 	 * to make sure that future cairo calls have the clip set that they
395 	 * expect.
396 	 * Since 1.0
397 	 * Params:
398 	 * x = X coordinate of dirty rectangle
399 	 * y = Y coordinate of dirty rectangle
400 	 * width = width of dirty rectangle
401 	 * height = height of dirty rectangle
402 	 */
403 	public void markDirtyRectangle(int x, int y, int width, int height)
404 	{
405 		// void cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface,  int x,  int y,  int width,  int height);
406 		cairo_surface_mark_dirty_rectangle(cairo_surface, x, y, width, height);
407 	}
408 	
409 	/**
410 	 * Sets an offset that is added to the device coordinates determined
411 	 * by the CTM when drawing to surface. One use case for this function
412 	 * is when we want to create a cairo_surface_t that redirects drawing
413 	 * for a portion of an onscreen surface to an offscreen surface in a
414 	 * way that is completely invisible to the user of the cairo
415 	 * API. Setting a transformation via cairo_translate() isn't
416 	 * sufficient to do this, since functions like
417 	 * cairo_device_to_user() will expose the hidden offset.
418 	 * Note that the offset affects drawing to the surface as well as
419 	 * using the surface in a source pattern.
420 	 * Since 1.0
421 	 * Params:
422 	 * xOffset = the offset in the X direction, in device units
423 	 * yOffset = the offset in the Y direction, in device units
424 	 */
425 	public void setDeviceOffset(double xOffset, double yOffset)
426 	{
427 		// void cairo_surface_set_device_offset (cairo_surface_t *surface,  double x_offset,  double y_offset);
428 		cairo_surface_set_device_offset(cairo_surface, xOffset, yOffset);
429 	}
430 	
431 	/**
432 	 * This function returns the previous device offset set by
433 	 * cairo_surface_set_device_offset().
434 	 * Since 1.2
435 	 * Params:
436 	 * xOffset = the offset in the X direction, in device units
437 	 * yOffset = the offset in the Y direction, in device units
438 	 */
439 	public void getDeviceOffset(out double xOffset, out double yOffset)
440 	{
441 		// void cairo_surface_get_device_offset (cairo_surface_t *surface,  double *x_offset,  double *y_offset);
442 		cairo_surface_get_device_offset(cairo_surface, &xOffset, &yOffset);
443 	}
444 	
445 	/**
446 	 * Set the horizontal and vertical resolution for image fallbacks.
447 	 * When certain operations aren't supported natively by a backend,
448 	 * cairo will fallback by rendering operations to an image and then
449 	 * overlaying that image onto the output. For backends that are
450 	 * natively vector-oriented, this function can be used to set the
451 	 * resolution used for these image fallbacks, (larger values will
452 	 * result in more detailed images, but also larger file sizes).
453 	 * Some examples of natively vector-oriented backends are the ps, pdf,
454 	 * and svg backends.
455 	 * For backends that are natively raster-oriented, image fallbacks are
456 	 * still possible, but they are always performed at the native
457 	 * device resolution. So this function has no effect on those
458 	 * backends.
459 	 * Note: The fallback resolution only takes effect at the time of
460 	 * completing a page (with cairo_show_page() or cairo_copy_page()) so
461 	 * there is currently no way to have more than one fallback resolution
462 	 * in effect on a single page.
463 	 * The default fallback resoultion is 300 pixels per inch in both
464 	 * dimensions.
465 	 * Since 1.2
466 	 * Params:
467 	 * xPixelsPerInch = horizontal setting for pixels per inch
468 	 * yPixelsPerInch = vertical setting for pixels per inch
469 	 */
470 	public void setFallbackResolution(double xPixelsPerInch, double yPixelsPerInch)
471 	{
472 		// void cairo_surface_set_fallback_resolution  (cairo_surface_t *surface,  double x_pixels_per_inch,  double y_pixels_per_inch);
473 		cairo_surface_set_fallback_resolution(cairo_surface, xPixelsPerInch, yPixelsPerInch);
474 	}
475 	
476 	/**
477 	 * This function returns the previous fallback resolution set by
478 	 * cairo_surface_set_fallback_resolution(), or default fallback
479 	 * resolution if never set.
480 	 * Since 1.8
481 	 * Params:
482 	 * xPixelsPerInch = horizontal pixels per inch
483 	 * yPixelsPerInch = vertical pixels per inch
484 	 */
485 	public void getFallbackResolution(out double xPixelsPerInch, out double yPixelsPerInch)
486 	{
487 		// void cairo_surface_get_fallback_resolution  (cairo_surface_t *surface,  double *x_pixels_per_inch,  double *y_pixels_per_inch);
488 		cairo_surface_get_fallback_resolution(cairo_surface, &xPixelsPerInch, &yPixelsPerInch);
489 	}
490 	
491 	/**
492 	 * This function returns the type of the backend used to create
493 	 * a surface. See cairo_surface_type_t for available types.
494 	 * Since 1.2
495 	 * Params:
496 	 * surface = a cairo_surface_t
497 	 * Returns: The type of surface.
498 	 */
499 	public cairo_surface_type_t getType()
500 	{
501 		// cairo_surface_type_t cairo_surface_get_type (cairo_surface_t *surface);
502 		return cairo_surface_get_type(cairo_surface);
503 	}
504 	
505 	/**
506 	 * Returns the current reference count of surface.
507 	 * Since 1.4
508 	 * Returns: the current reference count of surface. If the object is a nil object, 0 will be returned.
509 	 */
510 	public uint getReferenceCount()
511 	{
512 		// unsigned int cairo_surface_get_reference_count (cairo_surface_t *surface);
513 		return cairo_surface_get_reference_count(cairo_surface);
514 	}
515 	
516 	/**
517 	 * Attach user data to surface. To remove user data from a surface,
518 	 * call this function with the key that was used to set it and NULL
519 	 * for data.
520 	 * Since 1.0
521 	 * Params:
522 	 * key = the address of a cairo_user_data_key_t to attach the user data to
523 	 * userData = the user data to attach to the surface
524 	 * destroy = a cairo_destroy_func_t which will be called when the
525 	 * surface is destroyed or when new user data is attached using the
526 	 * same key.
527 	 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY if a slot could not be allocated for the user data.
528 	 */
529 	public cairo_status_t setUserData(cairo_user_data_key_t* key, void* userData, cairo_destroy_func_t destroy)
530 	{
531 		// cairo_status_t cairo_surface_set_user_data (cairo_surface_t *surface,  const cairo_user_data_key_t *key,  void *user_data,  cairo_destroy_func_t destroy);
532 		return cairo_surface_set_user_data(cairo_surface, key, userData, destroy);
533 	}
534 	
535 	/**
536 	 * Return user data previously attached to surface using the specified
537 	 * key. If no user data has been attached with the given key this
538 	 * function returns NULL.
539 	 * Since 1.0
540 	 * Params:
541 	 * key = the address of the cairo_user_data_key_t the user data was
542 	 * attached to
543 	 * Returns: the user data previously attached or NULL.
544 	 */
545 	public void* getUserData(cairo_user_data_key_t* key)
546 	{
547 		// void * cairo_surface_get_user_data (cairo_surface_t *surface,  const cairo_user_data_key_t *key);
548 		return cairo_surface_get_user_data(cairo_surface, key);
549 	}
550 	
551 	/**
552 	 * Emits the current page for backends that support multiple pages,
553 	 * but doesn't clear it, so that the contents of the current page will
554 	 * be retained for the next page. Use cairo_surface_show_page() if you
555 	 * want to get an empty page after the emission.
556 	 * There is a convenience function for this that takes a cairo_t,
557 	 * namely cairo_copy_page().
558 	 * Since 1.6
559 	 */
560 	public void copyPage()
561 	{
562 		// void cairo_surface_copy_page (cairo_surface_t *surface);
563 		cairo_surface_copy_page(cairo_surface);
564 	}
565 	
566 	/**
567 	 * Emits and clears the current page for backends that support multiple
568 	 * pages. Use cairo_surface_copy_page() if you don't want to clear the page.
569 	 * There is a convenience function for this that takes a cairo_t,
570 	 * namely cairo_show_page().
571 	 * Since 1.6
572 	 */
573 	public void showPage()
574 	{
575 		// void cairo_surface_show_page (cairo_surface_t *surface);
576 		cairo_surface_show_page(cairo_surface);
577 	}
578 	
579 	/**
580 	 * Returns whether the surface supports
581 	 * sophisticated cairo_show_text_glyphs() operations. That is,
582 	 * whether it actually uses the provided text and cluster data
583 	 * to a cairo_show_text_glyphs() call.
584 	 * Note: Even if this function returns FALSE, a
585 	 * cairo_show_text_glyphs() operation targeted at surface will
586 	 * still succeed. It just will
587 	 * act like a cairo_show_glyphs() operation. Users can use this
588 	 * function to avoid computing UTF-8 text and cluster mapping if the
589 	 * target surface does not use it.
590 	 * Since 1.8
591 	 * Returns: TRUE if surface supports cairo_show_text_glyphs(), FALSE otherwise
592 	 */
593 	public cairo_bool_t hasShowTextGlyphs()
594 	{
595 		// cairo_bool_t cairo_surface_has_show_text_glyphs (cairo_surface_t *surface);
596 		return cairo_surface_has_show_text_glyphs(cairo_surface);
597 	}
598 	
599 	/**
600 	 * Attach an image in the format mime_type to surface. To remove
601 	 * the data from a surface, call this function with same mime type
602 	 * and NULL for data.
603 	 * The attached image (or filename) data can later be used by backends
604 	 * which support it (currently: PDF, PS, SVG and Win32 Printing
605 	 * surfaces) to emit this data instead of making a snapshot of the
606 	 * surface. This approach tends to be faster and requires less
607 	 * memory and disk space.
608 	 * The recognized MIME types are the following: CAIRO_MIME_TYPE_JPEG,
609 	 * CAIRO_MIME_TYPE_PNG, CAIRO_MIME_TYPE_JP2, CAIRO_MIME_TYPE_URI.
610 	 * See corresponding backend surface docs for details about which MIME
611 	 * types it can handle. Caution: the associated MIME data will be
612 	 * discarded if you draw on the surface afterwards. Use this function
613 	 * with care.
614 	 * Since 1.10
615 	 * Params:
616 	 * mimeType = the MIME type of the image data
617 	 * data = the image data to attach to the surface
618 	 * destroy = a cairo_destroy_func_t which will be called when the
619 	 * surface is destroyed or when new image data is attached using the
620 	 * same mime type.
621 	 * closure = the data to be passed to the destroy notifier
622 	 * Returns: CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY if a slot could not be allocated for the user data.
623 	 */
624 	public cairo_status_t setMimeData(string mimeType, ubyte[] data, cairo_destroy_func_t destroy, void* closure)
625 	{
626 		// cairo_status_t cairo_surface_set_mime_data (cairo_surface_t *surface,  const char *mime_type,  const unsigned char *data,  unsigned long  length,  cairo_destroy_func_t destroy,  void *closure);
627 		return cairo_surface_set_mime_data(cairo_surface, Str.toStringz(mimeType), data.ptr, cast(int) data.length, destroy, closure);
628 	}
629 	
630 	/**
631 	 * Return whether surface supports mime_type.
632 	 * Since 1.12
633 	 * Params:
634 	 * mimeType = the mime type
635 	 * Returns: TRUE if surface supports mime_type, FALSE otherwise
636 	 */
637 	public cairo_bool_t supportsMimeType(string mimeType)
638 	{
639 		// cairo_bool_t cairo_surface_supports_mime_type (cairo_surface_t *surface,  const char *mime_type);
640 		return cairo_surface_supports_mime_type(cairo_surface, Str.toStringz(mimeType));
641 	}
642 	
643 	/**
644 	 * Returns an image surface that is the most efficient mechanism for
645 	 * modifying the backing store of the target surface. The region retrieved
646 	 * may be limited to the extents or NULL for the whole surface
647 	 * Note, the use of the original surface as a target or source whilst it is
648 	 * mapped is undefined. The result of mapping the surface multiple times is
649 	 * undefined. Calling cairo_surface_destroy() or cairo_surface_finish() on the
650 	 * resulting image surface results in undefined behavior.
651 	 * Since 1.12
652 	 * Params:
653 	 * extents = limit the extraction to an rectangular region
654 	 * Returns: a pointer to the newly allocated image surface. The caller must use cairo_surface_unmap_image() to destroy this image surface. This function always returns a valid pointer, but it will return a pointer to a "nil" surface if other is already in an error state or any other error occurs.
655 	 */
656 	public Surface mapToImage(ref cairo_rectangle_int_t extents)
657 	{
658 		// cairo_surface_t * cairo_surface_map_to_image (cairo_surface_t *surface,  const cairo_rectangle_int_t *extents);
659 		auto p = cairo_surface_map_to_image(cairo_surface, &extents);
660 		
661 		if(p is null)
662 		{
663 			return null;
664 		}
665 		
666 		return new Surface(cast(cairo_surface_t*) p);
667 	}
668 	
669 	/**
670 	 * Unmaps the image surface as returned from #cairo_surface_map_to_image().
671 	 * The content of the image will be uploaded to the target surface.
672 	 * Afterwards, the image is destroyed.
673 	 * Using an image surface which wasn't returned by cairo_surface_map_to_image()
674 	 * results in undefined behavior.
675 	 * Since 1.12
676 	 * Params:
677 	 * image = the currently mapped image
678 	 */
679 	public void unmapImage(Surface image)
680 	{
681 		// void cairo_surface_unmap_image (cairo_surface_t *surface,  cairo_surface_t *image);
682 		cairo_surface_unmap_image(cairo_surface, (image is null) ? null : image.getSurfaceStruct());
683 	}
684 }