The OpenD Programming Language

Device

* Devices are the abstraction Cairo employs for the rendering system used * by a Surface. You can get the device of a surface using * Surface.getDevice(). * * Devices are created using custom functions specific to the rendering * system you want to use. See the documentation for the surface types * for those functions. * * An important function that devices fulfill is sharing access to the * rendering system between Cairo and your application. If you want to access * a device directly that you used to draw to with Cairo, you must first * call Device.flush() to ensure that Cairo finishes all operations * on the device and resets it to a clean state. * * Cairo also provides the functions Device.acquire() and * Device.release() to synchronize access to the rendering system * in a multithreaded environment. This is done internally, but can also * be used by applications. * * Note: * Please refer to the documentation of each backend for additional usage * requirements, guarantees provided, and interactions with existing surface * API of the device functions for surfaces of that type. * * Examples: * ------------------------- * void my_device_modifying_function(Device device) * { * // Ensure the device is properly reset * device.flush(); * try * { * // Try to acquire the device * device.acquire(); * } * catch(CairoException e) * { * writeln(""); * } * * // Release the device when done. * scope(exit) * device.release(); * * // Do the custom operations on the device here. * // But do not call any Cairo functions that might acquire devices. * * } * -------------------------

Constructors

this
this(cairo_device_t* ptr)

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

Members

Aliases

type
alias type = getType

Convenience alias

Functions

acquire
void acquire()

Acquires the device for the current thread. This function will block until no other thread has acquired the device.

checkError
void checkError()

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

finish
void finish()

This function finishes the device and drops all references to external resources. All surfaces, fonts and other objects created for this device will be finished, too. Further operations on the device will not affect the device but will instead trigger a CAIRO_STATUS_DEVICE_FINISHED exception.

flush
void flush()

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

getType
DeviceType getType()

This function returns the C type of a Device. See DeviceType for available types.

release
void release()

Releases a device previously acquired using Device.acquire(). See that function for details.

Mixins

__anonymous
mixin CairoCountedClass!(cairo_device_t*, "cairo_device_")

Mixed In Members

From mixin CairoCountedClass!(cairo_device_t*, "cairo_device_")

_count
uint _count [@property getter]

Reference count. For use in child classes

_reference
void _reference()

Increase reference count. For use in child classes

_dereference
void _dereference()

Decrease reference count. For use in child classes

nativePointer
T nativePointer;

The underlying $(T) handle

debugging
bool debugging;

Enable / disable memory management debugging for this instance. Only available if both cairoD and the cairoD user code were compiled with "debug=RefCounted"

dispose
void dispose()

Explicitly drecrease the reference count.

~this
~this()

Destructor. Call dispose() if it hasn't been called manually.

Meta