# Aros/Developer/Cairo

* Navbar for the Aros wikibook
* Aros User
* Aros User Docs
* Aros User FAQs
* Aros User Applications
* Aros User DOS Shell
* Aros/User/AmigaLegacy
* Aros Dev Docs
* Aros Developer Docs
* Porting Software from AmigaOS/SDL
* For Zune Beginners
* Zune .MUI Classes
* For SDL Beginners
* Aros Developer BuildSystem
* Specific platforms
* Aros x86 Complete System HCL
* Aros x86 Audio/Video Support
* Aros x86 Network Support
* Aros Intel AMD x86 Installing
* Aros Storage Support IDE SATA etc
* Aros Poseidon USB Support
* x86-64 Support
* Motorola 68k Amiga Support
* Linux and FreeBSD Support
* Windows Mingw and MacOSX Support
* Android Support
* Arm Raspberry Pi Support
* PPC Power Architecture
* misc
* Aros Public License
There are currently two ports (1.5 and 1.12) of the Cairo graphics library. Both are located in the Aros contrib sources.
You'll find a quite recent version in "contrib/development/libs/cairo". It is a patch to Cairo version 1.12.0. This version builds into a static link library.
To compile the link library run the following commands in your Aros source directory:
make development-fontconfig
fc-cache
make development-cairo
This will build the dependencies and the Cairo and Pixman library.

## Cairo 1.12 examples

Cairo 1.12, using directly the image surface (that processes everything in system memory) gives much faster results, say probably about 60% faster than the old 1.5.
Using the image surface, blit the rgba data to your custom area class in draw method, using cairo_image_get_data.

## Cairo 1.5 examples

The Cairo version (1.5) in "contrib/gfx/libs/cairo/" is rather old. But in contrast to the other version it has the great advantage that it support Aros as a native backend. This means it comes with a function "cairo_aros_surface_create" that can render to Intuition RastPorts. First parameter was the pointer to the RastPort, the other parameters specified X/Y-offset, width and height. Also this port builds into a Aros shared library. In the Aros-Exec Archives you'll also find a static link library of Cairo that supports "cairo_aros_surface_create".
The old 1.5 version was entirely software-driven and it involved reads from the bitmap in video ram, which is highly inefficient.
The second example below shows a simple example of how native Aros surfaces are created and used.
Simple Cairo example that creates a PNG image
Compile with: gcc test.c -lcairo -lpixman -lfreetype2 -lfontconfig -liconv -lxml2 -lz -lpng
Simple Cairo example using Aros native RastPort backend

## References
### Direct Access Functions

cairo_image_get_data and other direct access functions are often misused by applications because they don't call cairo_surface_flush and/or cairo_surface_mark_dirty around the code which accesses the surface data directly. You must call cairo_surface_flush before reading from or writing to the surface and that you must use cairo_surface_mark_dirty after modifying it.
Cairo Library Calls

#### Surface

cairo_surface_create_similar cairo_surface_create_similar_image cairo_surface_create_for_rectangle cairo_surface_reference cairo_surface_destroy cairo_surface_status cairo_surface_finish cairo_surface_flush cairo_surface_get_device cairo_surface_get_font_options cairo_surface_get_content cairo_surface_mark_dirty cairo_surface_mark_dirty_rectangle cairo_surface_set_device_offset cairo_surface_get_device_offset cairo_surface_set_fallback_resolution cairo_surface_get_fallback_resolution cairo_surface_get_type cairo_surface_get_reference_count cairo_surface_set_user_data cairo_surface_get_user_data cairo_surface_copy_page cairo_surface_show_page cairo_surface_has_show_text_glyphs cairo_surface_set_mime_data cairo_surface_get_mime_data cairo_surface_supports_mime_type cairo_surface_map_to_image cairo_surface_unmap_image

#### Devices

cairo_device_reference cairo_device_destroy cairo_device_status cairo_device_finish cairo_device_flush cairo_device_get_type cairo_device_get_reference_count cairo_device_set_user_data cairo_device_get_user_data cairo_device_acquire cairo_device_release