The OpenD Programming Language

XlibSurface

The XLib surface is used to render cairo graphics to X Window System windows and pixmaps using the XLib library.

Note that the XLib surface automatically takes advantage of X render extension if it is available.

Constructors

this
this(cairo_surface_t* ptr)

Create a XlibSurface from a existing cairo_surface_t*. XlibSurface is a garbage collected class. It will call cairo_surface_destroy when it gets collected by the GC or when dispose() is called.

this
this(Display* dpy, Drawable drawable, Visual* visual, int width, int height)

Creates an Xlib surface that draws to the given drawable. The way that colors are represented in the drawable is specified by the provided visual.

this
this(Display* dpy, Pixmap bitmap, Screen* screen, int width, int height)

Creates an Xlib surface that draws to the given bitmap. This will be drawn to as a CAIRO_FORMAT_A1 object.

Members

Functions

getDepth
int getDepth()

Get the number of bits used to represent each pixel value.

getDisplay
Display* getDisplay()

Get the X Display for the underlying X Drawable.

getDrawable
Drawable getDrawable()

Get the underlying X Drawable used for the surface.

getHeight
int getHeight()

Get the height of the X Drawable underlying the surface in pixels

getScreen
Screen* getScreen()

Get the X Screen for the underlying X Drawable.

getVisual
Visual* getVisual()

Gets the X Visual associated with surface, suitable for use with the underlying X Drawable. If surface was created by cairo_xlib_surface_create(), the return value is the Visual passed to that constructor.

getWidth
int getWidth()

Get the width of the X Drawable underlying the surface in pixels

setDrawable
void setDrawable(Drawable drawable, int width, int height)

Informs cairo of a new X Drawable underlying the surface. The drawable must match the display, screen and format of the existing drawable or the application will get X protocol errors and will probably terminate. No checks are done by this function to ensure this compatibility.

setSize
void setSize(int width, int height)

Informs cairo of the new size of the X Drawable underlying the surface. For a surface created for a Window (rather than a Pixmap), this function must be called each time the size of the window changes. (For a subwindow, you are normally resizing the window yourself, but for a toplevel window, it is necessary to listen for ConfigureNotify events.)

Inherited Members

From Surface

__anonymous
mixin CairoCountedClass!(cairo_surface_t*, "cairo_surface_")
checkError
void checkError()

Method for use in subclasses. Calls cairo_surface_status(nativePointer) and throws an exception if the status isn't CAIRO_STATUS_SUCCESS

createFromNative
Surface createFromNative(cairo_surface_t* ptr, bool adjRefCount)

The createFromNative method for the Surface classes. See https://github.com/jpf91/cairoD/wiki/Memory-Management#createFromNative for more information.

createSimilar
Surface createSimilar(Surface other, Content content, int width, int height)

Create a new surface that is as compatible as possible with an existing surface. For example the new surface will have the same fallback resolution and font options as other. Generally, the new surface will also use the same backend as other, unless that is not possible for some reason. The type of the returned surface may be examined with Surface.getType().

createForRectangle
Surface createForRectangle(Surface target, Rectangle!double rect)

Create a new surface that is a rectangle within the target surface. All operations drawn to this surface are then clipped and translated onto the target surface. Nothing drawn via this sub-surface outside of its bounds is drawn onto the target surface, making this a useful method for passing constrained child surfaces to library routines that draw directly onto the parent surface, i.e. with no further backend allocations, double buffering or copies.

finish
void finish()

This function finishes the surface and drops all references to external resources. For example, for the Xlib backend it means that cairo will no longer access the drawable, which can be freed. After calling Surface.finish() the only valid operations on a surface are getting and setting user, referencing and destroying, and flushing and finishing it.

flush
void flush()

Do any pending drawing for the surface and also restore any temporary modifications cairo has made to the surface's state. This function must be called before switching from drawing on the surface with cairo to drawing on it directly with native APIs. If the surface doesn't support direct access, then this function does nothing.

getDevice
Device getDevice()

This function returns the device for a surface. See Device.

device
alias device = getDevice

Convenience alias

getFontOptions
FontOptions getFontOptions()

Retrieves the default font rendering options for the surface. This allows display surfaces to report the correct subpixel order for rendering on them, print surfaces to disable hinting of metrics and so forth. The result can then be used with $(new ScaledFont()).

fontOptions
alias fontOptions = getFontOptions

Convenience alias

getContent
Content getContent()

This function returns the content type of surface which indicates whether the surface contains color and/or alpha information. See Content.

content
alias content = getContent

Convenience alias

markDirty
void markDirty()

Tells cairo that drawing has been done to surface using means other than cairo, and that cairo should reread any cached areas. Note that you must call Surface.flush() before doing such drawing.

markDirtyRectangle
void markDirtyRectangle(int x, int y, int width, int height)
void markDirtyRectangle(Rectangle!int rect)

Like Surface.markDirty(), but drawing has been done only to the specified rectangle, so that cairo can retain cached contents for other parts of the surface.

setDeviceOffset
void setDeviceOffset(double x_offset, double y_offset)
void setDeviceOffset(Point!double offset)

Sets an offset that is added to the device coordinates determined by the CTM when drawing to surface. One use case for this function is when we want to create a Surface that redirects drawing for a portion of an onscreen surface to an offscreen surface in a way that is completely invisible to the user of the cairo API. Setting a transformation via Context.translate() isn't sufficient to do this, since functions like Context.deviceToUser() will expose the hidden offset.

getDeviceOffset
Point!double getDeviceOffset()

This function returns the previous device offset set by Surface.setDeviceOffset().

deviceOffset
Point!double deviceOffset [@property setter]
Point!double deviceOffset [@property getter]

Convenience property function ditto

setFallbackResolution
void setFallbackResolution(Resolution res)

Set the horizontal and vertical resolution for image fallbacks.

getFallbackResolution
Resolution getFallbackResolution()

This function returns the previous fallback resolution set by setFallbackResolution(), or default fallback resolution if never set.

fallbackResolution
Resolution fallbackResolution [@property setter]
Resolution fallbackResolution [@property getter]

Convenience property function

getType
SurfaceType getType()

This function returns the C type of a Surface. See SurfaceType for available types.

type
alias type = getType

convenience alias

copyPage
void copyPage()

Emits the current page for backends that support multiple pages, but doesn't clear it, so that the contents of the current page will be retained for the next page. Use Surface.showPage() if you want to get an empty page after the emission.

showPage
void showPage()

Emits and clears the current page for backends that support multiple pages. Use Surface.copyPage() if you don't want to clear the page.

hasShowTextGlyphs
bool hasShowTextGlyphs()

Returns whether the surface supports sophisticated showTextGlyphs() operations. That is, whether it actually uses the provided text and cluster data to a showTextGlyphs() call.

setMimeData
void setMimeData(string type, ubyte* data, ulong length, cairo_destroy_func_t destroy, void* closure)

Attach an image in the format mime_type to surface. To remove the data from a surface, call this function with same mime type and NULL for data.

getMimeData
void getMimeData(string type, ubyte* data, ulong length)

Return mime data previously attached to surface using the specified mime type. If no data has been attached with the given mime type, data is set null.

Meta