diff --git a/recipes/cairo/recipe.sh b/recipes/cairo/recipe.sh new file mode 100755 index 0000000000000000000000000000000000000000..26ac8fa622ed098b94810dc457947b2aaf76532d --- /dev/null +++ b/recipes/cairo/recipe.sh @@ -0,0 +1,43 @@ +VERSION="1.16.0" +TAR=https://www.cairographics.org/releases/cairo-$VERSION.tar.xz +BUILD_DEPENDS=(zlib pixman freetype libpng) + +function recipe_version { + echo "$VERSION" + skip=1 +} + +function recipe_update { + echo "skipping update" + skip=1 +} + +function recipe_build { + #Workaround to disable the not redox compatible tests + printf "all:\n\ninstall:\n" > ./test/Makefile.in + printf "all:\n\ninstall:\n" > ./perf/Makefile.in + + sysroot="$(realpath ../sysroot)" + export LDFLAGS="-L$sysroot/lib" + export CPPFLAGS="-I$sysroot/include" + CFLAGS="-DCAIRO_NO_MUTEX=1" ./configure --host=${HOST} --prefix=/ --enable-xlib=no --enable-script=no --enable-interpreter=no + make + skip=1 +} + +function recipe_test { + echo "skipping test" + skip=1 +} + +function recipe_clean { + make clean + skip=1 +} + +function recipe_stage { + echo "skipping stage" + dest="$(realpath $1)" + make DESTDIR="$dest" install + skip=1 +} diff --git a/recipes/cairodemo/cairodemo.c b/recipes/cairodemo/cairodemo.c new file mode 100755 index 0000000000000000000000000000000000000000..8f474e9eaa2469e4cf5231d0b54775eea5f1129a --- /dev/null +++ b/recipes/cairodemo/cairodemo.c @@ -0,0 +1,129 @@ +#include <stdint.h> +#include <math.h> +#include <stdlib.h> +#include <cairo/cairo.h> +#include <orbital.h> + +#ifndef M_PI +#define M_PI 3.14159265 +#endif + +static int width = 800; +static int height = 600; + +static void +travel_path (cairo_t *cr) +{ + + cairo_pattern_t *pat; + + pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, 256.0); + cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 1); + cairo_pattern_add_color_stop_rgba (pat, 0, 1, 1, 1, 1); + cairo_rectangle (cr, 0, 0, 256, 256); + cairo_set_source (cr, pat); + cairo_fill (cr); + cairo_pattern_destroy (pat); + + pat = cairo_pattern_create_radial (115.2, 102.4, 25.6, + 102.4, 102.4, 128.0); + cairo_pattern_add_color_stop_rgba (pat, 0, 1, 1, 1, 1); + cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 1); + cairo_set_source (cr, pat); + cairo_arc (cr, 128.0, 128.0, 76.8, 0, 2 * M_PI); + cairo_fill (cr); + cairo_pattern_destroy (pat); + + + double x = 305.6, /* parameters like cairo_rectangle */ + y = 25.6, + width = 204.8, + height = 204.8, + aspect = 1.0, /* aspect ratio */ + corner_radius = height / 10.0; /* and corner curvature radius */ + + double radius = corner_radius / aspect; + double degrees = M_PI / 180.0; + + cairo_new_sub_path (cr); + cairo_arc (cr, x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees); + cairo_arc (cr, x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees); + cairo_arc (cr, x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees); + cairo_arc (cr, x + radius, y + radius, radius, 180 * degrees, 270 * degrees); + cairo_close_path (cr); + + cairo_set_source_rgb (cr, 0.5, 0.5, 1); + cairo_fill_preserve (cr); + cairo_set_source_rgba (cr, 0.5, 0, 0, 0.5); + cairo_set_line_width (cr, 10.0); + cairo_stroke (cr); + + + double xc = 128.0; + double yc = 128.0; + radius = 100.0; + double angle1 = 45.0 * (M_PI/180.0); /* angles are specified */ + double angle2 = 180.0 * (M_PI/180.0); /* in radians */ + + cairo_set_line_width (cr, 10.0); + cairo_arc (cr, xc, yc, radius, angle1, angle2); + cairo_stroke (cr); + + /* draw helping lines */ + cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6); + cairo_set_line_width (cr, 6.0); + + cairo_arc (cr, xc, yc, 10.0, 0, 2*M_PI); + cairo_fill (cr); + + cairo_arc (cr, xc, yc, radius, angle1, angle1); + cairo_line_to (cr, xc, yc); + cairo_arc (cr, xc, yc, radius, angle2, angle2); + cairo_line_to (cr, xc, yc); + cairo_stroke (cr); +} + +static void +draw (cairo_surface_t *surface) +{ + cairo_t *cr; + cr = cairo_create (surface); + travel_path (cr); + cairo_destroy (cr); +} + +int +main(int argc, char *argv[]) +{ + void * window = orb_window_new(-1, -1, width, height, "CairoDemo"); + + //Cairo + uint32_t * frame_data = orb_window_data(window); + cairo_surface_t *surface = cairo_image_surface_create_for_data((uint8_t*) frame_data, CAIRO_FORMAT_ARGB32, width, height, cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width)); + cairo_create(surface); + draw (surface); + + orb_window_sync(window); + + char running = 1; + while (running) { + void * event_iter = orb_window_events(window); + + OrbEventOption event_option; + do { + event_option = orb_events_next(event_iter); + switch (event_option.tag) { + case OrbEventOption_Quit: + running = 0; + break; + default: + break; + } + } while (running && event_option.tag != OrbEventOption_None); + + orb_events_destroy(event_iter); + } + orb_window_destroy(window); + return 0; /* ANSI C requires main to return int. */ +} + diff --git a/recipes/cairodemo/recipe.sh b/recipes/cairodemo/recipe.sh new file mode 100755 index 0000000000000000000000000000000000000000..628d53ecad59cadc9ae4ac750588d25aae9fc197 --- /dev/null +++ b/recipes/cairodemo/recipe.sh @@ -0,0 +1,44 @@ +BUILD_DEPENDS=(liborbital cairo pixman zlib libpng freetype) + +function recipe_version { + printf "1.0.0" + skip=1 +} + +function recipe_update { + echo "skipping update" + skip=1 +} + +function recipe_prepare { + rm -rf source + mkdir source + cp cairodemo.c source +} + +function recipe_build { + sysroot="$(realpath ../sysroot)" + export LDFLAGS="-L$sysroot/lib" + export CPPFLAGS="-I$sysroot/include" + set -x + "${CXX}" -I "$sysroot/include" -L "$sysroot/lib" cairodemo.c -o cairodemo -lorbital -lcairo -lpixman-1 -lfreetype -lpng -lz -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lm + set +x + skip=1 +} + +function recipe_test { + echo "skipping test" + skip=1 +} + +function recipe_clean { + make clean + skip=1 +} + +function recipe_stage { + dest="$(realpath $1)" + mkdir -pv "$dest/bin" + cp -v "cairodemo" "$dest/bin/cairodemo" + skip=1 +} diff --git a/recipes/libpng/recipe.sh b/recipes/libpng/recipe.sh index 1aa63ed9245ef5d297de1e6802210dfd08c68ae6..4c2ca0c0a23cdeba167e8014ef5e4e84f379e72b 100644 --- a/recipes/libpng/recipe.sh +++ b/recipes/libpng/recipe.sh @@ -16,7 +16,7 @@ function recipe_build { sysroot="$(realpath ../sysroot)" export LDFLAGS="-L$sysroot/lib" export CPPFLAGS="-I$sysroot/include" - ./autogen.sh + #./autogen.sh chmod +w config.sub wget -O config.sub http://git.savannah.gnu.org/cgit/config.git/plain/config.sub ./configure --host=${HOST} --prefix='/' diff --git a/recipes/pixman/recipe.sh b/recipes/pixman/recipe.sh new file mode 100755 index 0000000000000000000000000000000000000000..88274193b2b29b05e37e57e360fcc400873c9206 --- /dev/null +++ b/recipes/pixman/recipe.sh @@ -0,0 +1,36 @@ +VERSION="0.36.0" +TAR=https://www.cairographics.org/releases/pixman-$VERSION.tar.gz + +function recipe_version { + echo "$VERSION" + skip=1 +} + +function recipe_update { + echo "skipping update" + skip=1 +} + +function recipe_build { + sysroot="$(realpath ../sysroot)" + ./configure --host=${HOST} --prefix=/ + make -j"$(nproc)" + skip=1 +} + +function recipe_test { + echo "skipping test" + skip=1 +} + +function recipe_clean { + make clean + skip=1 +} + +function recipe_stage { + echo "skipping stage" + dest="$(realpath $1)" + make DESTDIR="$dest" install + skip=1 +}