ucw.cz
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
List overview
Download
Gfxprim
February 2018
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
gfxprim@ucw.cz
1 participants
1 discussions
Start a n
N
ew thread
[repo.or.cz] gfxprim.git branch master updated: 1.0.0-rc1-204-g200d270c0bdb
by metan
10 Feb '18
10 Feb '18
This is an automated email generated because a ref change occurred in the git repository for project gfxprim.git. The branch, master has been updated via 200d270c0bdbb20d7aa1b1b82de8497699227811 (commit) via 2bb5961d3e38dc828df9182a02d51c13943a7470 (commit) via 63d25236813b53eb15fbdf494d157e90a95119a9 (commit) via d63701916dc11f1349f5807efe66a0cb125c234c (commit) via 60ac88e1ae2150b7ab5836fa882141324a642a4b (commit) via 7afea0007af1aed1fe11a4762703eecb15395516 (commit) via c570ae390cbf5726c9f9a1c603f3c4058e840881 (commit) via 2edcd7667a4e2377cdda83bac4608ba454fdf426 (commit) via ebc9d039449151402a121e0c45203ace0bb6d365 (commit) via 5f00fa3f08d6b1a8809a751b90a72884dd71e112 (commit) from 69d7c9ef5642dee09b76da64d79f5f5e474501e5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 200d270c0bdbb20d7aa1b1b82de8497699227811 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sat, 10 Feb 2018 16:07:07 +0100 URL: <
http://repo.or.cz/gfxprim.git/200d270c0bdbb20d
> filters/gp_filter_resize_alloc: Check w and h Check that at least one of w and h are non-zero. If one is zero the second one is computed accordingly to new_size/old_size ratio. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- libs/filters/GP_Resize.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libs/filters/GP_Resize.c b/libs/filters/GP_Resize.c index a1ba2d60b323..562bdca21e03 100644 --- a/libs/filters/GP_Resize.c +++ b/libs/filters/GP_Resize.c @@ -86,8 +86,21 @@ gp_pixmap *gp_filter_resize_alloc(const gp_pixmap *src, gp_interpolation_type type, gp_progress_cb *callback) { - gp_pixmap *res = gp_pixmap_alloc(w, h, src->pixel_type); + gp_pixmap *res; + if (!w && !h) { + GP_WARN("Invalid result size 0x0!"); + errno = EINVAL; + return NULL; + } + + if (!w) + w = (h * src->w + src->h/2) / src->h; + + if (!h) + h = (w * src->h + src->w/2) / src->w; + + res = gp_pixmap_alloc(w, h, src->pixel_type); if (!res) return NULL; commit 2bb5961d3e38dc828df9182a02d51c13943a7470 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sat, 10 Feb 2018 15:51:34 +0100 URL: <
http://repo.or.cz/gfxprim.git/2bb5961d3e38dc82
> demos/loaders_register: Small fixup * Resize the image before we attempt to create ASCII Art * Use twice as more characters * etc. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- demos/c_simple/loaders_register.c | 36 ++++++++++++++----------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/demos/c_simple/loaders_register.c b/demos/c_simple/loaders_register.c index c53218d05bed..e03e3a56395a 100644 --- a/demos/c_simple/loaders_register.c +++ b/demos/c_simple/loaders_register.c @@ -43,7 +43,7 @@ static int write_data(const gp_pixmap *img, gp_io *io, gp_io *bio; int err; - if (img->pixel_type != GP_PIXEL_G2) { + if (img->pixel_type != GP_PIXEL_G4) { errno = ENOSYS; return 1; } @@ -55,26 +55,14 @@ static int write_data(const gp_pixmap *img, gp_io *io, return 1; unsigned int i, j; + const char *const table[] = {" ", ".", ",", "-", "=", "#", "O", "$"}; for (j = 0; j < img->h; j++) { for (i = 0; i < img->w; i++) { gp_pixel p = gp_getpixel_raw(img, i, j); + const char *c = table[p>>1]; - switch (p) { - case 0: - err = gp_io_flush(bio, " ", 2); - break; - case 1: - err = gp_io_flush(bio, "..", 2); - break; - case 2: - err = gp_io_flush(bio, "()", 2); - break; - case 3: - err = gp_io_flush(bio, "OO", 2); - break; - } - + err = gp_io_flush(bio, c, 1); if (err) return 1; } @@ -88,12 +76,13 @@ static int write_data(const gp_pixmap *img, gp_io *io, } } + gp_io_close(bio); gp_progress_cb_done(callback); return 0; } static gp_pixel_type save_ptypes[] = { - GP_PIXEL_G2, + GP_PIXEL_G4, GP_PIXEL_UNKNOWN, }; @@ -106,7 +95,7 @@ const gp_loader loader = { int main(int argc, char *argv[]) { - gp_pixmap *c, *gc; + gp_pixmap *c, *gc, *sc; gp_loader_register(&loader); @@ -121,13 +110,20 @@ int main(int argc, char *argv[]) /* Now load image and save it using our loader */ c = gp_load_image(argv[1], NULL); - if (c == NULL) { fprintf(stderr, "Failed to load image: %s\n", strerror(errno)); return 1; } - gc = gp_filter_floyd_steinberg_alloc(c, GP_PIXEL_G2, NULL); + /* + * Font letters are not square resize the image so that it's twice it + * original width. + */ + gp_size w = 120; + gp_size h = (w/2 * c->h + c->w/2)/c->w; + + sc = gp_filter_resize_alloc(c, w, h, GP_INTERP_LINEAR_LF_INT, NULL); + gc = gp_filter_floyd_steinberg_alloc(sc, GP_PIXEL_G4, NULL); if (gc == NULL) { fprintf(stderr, "FloydSteinberg: %s\n", strerror(errno)); commit 63d25236813b53eb15fbdf494d157e90a95119a9 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sat, 13 Jan 2018 00:17:27 +0100 URL: <
http://repo.or.cz/gfxprim.git/63d25236813b53eb
> gfx: New gp_fill_triangle() implementation + tests Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- libs/gfx/GP_FillTriangle.gen.c.t | 108 ++++++++++++++ libs/gfx/GP_Triangle.c | 9 -- libs/gfx/Makefile | 2 +- tests/gfx/.gitignore | 2 + tests/gfx/Makefile | 5 +- tests/gfx/compare.h | 114 +++++++++++++++ tests/gfx/fill_triangle.c | 244 +++++++++++++++++++++++++++++++ tests/gfx/fill_triangle.gen.c.t | 55 +++++++ tests/gfx/line_symmetry.gen.c.t | 88 +---------- tests/gfx/test_list.txt | 3 + 10 files changed, 531 insertions(+), 99 deletions(-) create mode 100644 libs/gfx/GP_FillTriangle.gen.c.t create mode 100644 tests/gfx/compare.h create mode 100644 tests/gfx/fill_triangle.c create mode 100644 tests/gfx/fill_triangle.gen.c.t diff --git a/libs/gfx/GP_FillTriangle.gen.c.t b/libs/gfx/GP_FillTriangle.gen.c.t new file mode 100644 index 000000000000..20897730d497 --- /dev/null +++ b/libs/gfx/GP_FillTriangle.gen.c.t @@ -0,0 +1,108 @@ +@ include source.t +/* + * Filled triangle drawing algorithm. + * + * Copyright (C) 2009-2018 Cyril Hrubis <metan(a)ucw.cz> + */ + +#include <core/GP_Common.h> +#include <core/GP_GetPutPixel.h> +#include <core/GP_FnPerBpp.h> +#include <gfx/GP_HLine.h> + +typedef struct gp_line { + gp_coord x, dx, dy, error, xstep; +} gp_line; + +static void gp_line_init(gp_line *self, gp_coord x0, gp_coord y0, + gp_coord x1, gp_coord y1) +{ + if (y0 > y1) { + GP_SWAP(x0, x1); + GP_SWAP(y0, y1); + } + + self->x = 0; + self->dy = y1 - y0; + self->dx = GP_ABS(x1 - x0); + self->error = self->dx/2; + self->xstep = (x0 < x1) ? 1 : -1; +} + +static void gp_line_nexty(gp_line *self) +{ + self->error -= self->dx; + + while (self->error < 0) { + self->x += self->xstep; + self->error += self->dy; + } +} + +@ for ps in pixelsizes: +static void fill_triangle_{{ ps.suffix }}(gp_pixmap *pixmap, + gp_coord x0, gp_coord y0, + gp_coord x1, gp_coord y1, + gp_coord x2, gp_coord y2, + gp_pixel pixval) +{ + if (y0 > y1) { + GP_SWAP(x0, x1); + GP_SWAP(y0, y1); + } + + if (y0 > y2) { + GP_SWAP(x0, x2); + GP_SWAP(y0, y2); + } + + if (y1 > y2) { + GP_SWAP(x1, x2); + GP_SWAP(y1, y2); + } + + if (y0 == y2) { + gp_hline_raw_{{ ps.suffix }}(pixmap, + GP_MIN3(x0, x1, x2), + GP_MAX3(x0, x1, x2), + y0, pixval); + return; + } + + gp_line l1, l2; + gp_line_init(&l1, x0, y0, x1, y1); + gp_line_init(&l2, x0, y0, x2, y2); + + gp_coord y, deltay; + + deltay = y1 - y0; + + for (y = 0; y < deltay; y++) { + gp_hline_raw_{{ ps.suffix }}(pixmap, x0 + l1.x, x0 + l2.x, y0 + y, pixval); + gp_line_nexty(&l1); + gp_line_nexty(&l2); + } + + deltay = y2 - y1; + + gp_line_init(&l1, x1, y1, x2, y2); + + for (y = 0; y < deltay; y++) { + gp_hline_raw_{{ ps.suffix }}(pixmap, x1 + l1.x, x0 + l2.x, y1 + y, pixval); + gp_line_nexty(&l1); + gp_line_nexty(&l2); + } + + gp_hline_raw_{{ ps.suffix }}(pixmap, x1 + l1.x, x0 + l2.x, y1 + y, pixval); +} + +@ end + +void gp_fill_triangle_raw(gp_pixmap *pixmap, gp_coord x0, gp_coord y0, + gp_coord x1, gp_coord y1, gp_coord x2, gp_coord y2, gp_pixel pixel) +{ + GP_CHECK_PIXMAP(pixmap); + + GP_FN_PER_BPP_PIXMAP(fill_triangle, pixmap, pixmap, x0, y0, x1, y1, x2, y2, + pixel); +} diff --git a/libs/gfx/GP_Triangle.c b/libs/gfx/GP_Triangle.c index 10ed2f4fb767..67a62b77d6c8 100644 --- a/libs/gfx/GP_Triangle.c +++ b/libs/gfx/GP_Triangle.c @@ -51,15 +51,6 @@ void gp_triangle(gp_pixmap *pixmap, gp_coord x0, gp_coord y0, gp_triangle_raw(pixmap, x0, y0, x1, y1, x2, y2, pixel); } -void gp_fill_triangle_raw(gp_pixmap *pixmap, gp_coord x0, gp_coord y0, - gp_coord x1, gp_coord y1, - gp_coord x2, gp_coord y2, gp_pixel pixel) -{ - const gp_coord coords[6] = {x0, y0, x1, y1, x2, y2}; - - gp_fill_polygon_raw(pixmap, 3, coords, pixel); -} - void gp_fill_triangle(gp_pixmap *pixmap, gp_coord x0, gp_coord y0, gp_coord x1, gp_coord y1, gp_coord x2, gp_coord y2, gp_pixel pixel) diff --git a/libs/gfx/Makefile b/libs/gfx/Makefile index 8ffe38a0282c..5a775c895fc7 100644 --- a/libs/gfx/Makefile +++ b/libs/gfx/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/pre.mk CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c)) GENSOURCES=GP_Line.gen.c GP_HLine.gen.c GP_LineAA.gen.c GP_PutPixelAA.gen.c \ GP_HLineAA.gen.c GP_VLineAA.gen.c GP_FillCircle.gen.c GP_VLine.gen.c \ - GP_FillEllipse.gen.c + GP_FillEllipse.gen.c GP_FillTriangle.gen.c LIBNAME=gfx include $(TOPDIR)/gen.mk diff --git a/tests/gfx/.gitignore b/tests/gfx/.gitignore index 191fe86f5955..e7006bc21b07 100644 --- a/tests/gfx/.gitignore +++ b/tests/gfx/.gitignore @@ -14,3 +14,5 @@ /VLine /gfx_benchmark line_symmetry.gen +fill_triangle +fill_triangle.gen diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile index 4a5dc18b09a2..5250ad6ba9fc 100644 --- a/tests/gfx/Makefile +++ b/tests/gfx/Makefile @@ -2,11 +2,11 @@ TOPDIR=../.. include $(TOPDIR)/pre.mk CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c)) -GENSOURCES=APICoverage.gen.c line_symmetry.gen.c +GENSOURCES=APICoverage.gen.c line_symmetry.gen.c fill_triangle.gen.c APPS=gfx_benchmark Circle FillCircle Line CircleSeg Polygon Ellipse HLine\ VLine PutPixelAA HLineAA LineAA FillEllipse FillRect APICoverage.gen\ - line_symmetry.gen + line_symmetry.gen fill_triangle.gen fill_triangle Circle: common.o FillCircle: common.o @@ -21,6 +21,7 @@ PutPixelAA: common.o HLineAA: common.o LineAA: common.o FillRect: common.o +fill_triangle: common.o include ../tests.mk diff --git a/tests/gfx/compare.h b/tests/gfx/compare.h new file mode 100644 index 000000000000..9cabaf1a069c --- /dev/null +++ b/tests/gfx/compare.h @@ -0,0 +1,114 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> * + * * + *****************************************************************************/ + +#ifndef COMPARE_H__ +#define COMPARE_H__ + +#include <stdio.h> +#include <core/GP_GetPutPixel.h> + +static inline void print_diff(gp_pixmap *p1, gp_pixmap *p2) +{ + gp_size x, y; + + printf(" "); + for (x = 0; x < p1->w; x++) + printf("-"); + printf("\n"); + + for (y = 0; y < p1->h; y++) { + printf("|"); + for (x = 0; x < p1->w; x++) { + gp_pixel px1 = gp_getpixel_raw_8BPP(p1, x, y); + gp_pixel px2 = gp_getpixel_raw_8BPP(p2, x, y); + + if (px1 == px2) { + if (px1) + printf("*"); + else + printf(" "); + } else { + if (px1) + printf("1"); + else + printf("2"); + } + } + printf("|\n"); + } + + printf(" "); + for (x = 0; x < p1->w; x++) + printf("-"); + printf("\n"); +} + +static inline void print(gp_pixmap *p) +{ + gp_size x, y; + + printf(" "); + for (x = 0; x < p->w; x++) + printf("-"); + printf("\n"); + + for (y = 0; y < p->h; y++) { + printf("|"); + for (x = 0; x < p->w; x++) { + gp_pixel px = gp_getpixel_raw_8BPP(p, x, y); + + if (px) + printf("*"); + else + printf(" "); + } + printf("|\n"); + } + + printf(" "); + for (x = 0; x < p->w; x++) + printf("-"); + printf("\n"); +} + +static inline int compare_pixmaps(gp_pixmap *p1, gp_pixmap *p2) +{ + gp_size x, y; + print(p1); + for (x = 0; x < p1->w; x++) { + for (y = 0; y < p1->h; y++) { + gp_pixel px1 = gp_getpixel_raw_8BPP(p1, x, y); + gp_pixel px2 = gp_getpixel_raw_8BPP(p2, x, y); + + if (px1 != px2) { + print(p1); + print(p2); + print_diff(p1, p2); + return TST_FAILED; + } + } + } + + return TST_SUCCESS; +} + +#endif /* COMPARE_H__ */ diff --git a/tests/gfx/fill_triangle.c b/tests/gfx/fill_triangle.c new file mode 100644 index 000000000000..22d61f9baf7b --- /dev/null +++ b/tests/gfx/fill_triangle.c @@ -0,0 +1,244 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2018 Cyril Hrubis <metan(a)ucw.cz> * + * * + *****************************************************************************/ + +#include <string.h> +#include <errno.h> +#include <sys/stat.h> + +#include <core/GP_Pixmap.h> +#include <gfx/GP_Triangle.h> + +#include <gfx/GP_Line.h> + +#include "tst_test.h" + +#include "common.h" + +struct testcase { + /* line description */ + gp_coord x0; + gp_coord y0; + gp_coord x1; + gp_coord y1; + gp_coord x2; + gp_coord y2; + + /* expected result */ + gp_size w, h; + const char pixmap[]; +}; + +static int test_fill_triangle(const struct testcase *t) +{ + gp_pixmap *c; + int err; + + c = gp_pixmap_alloc(t->w, t->h, GP_PIXEL_G8); + + if (c == NULL) { + tst_err("Failed to allocate pixmap"); + return TST_UNTESTED; + } + + /* zero the pixels buffer */ + memset(c->pixels, 0, c->w * c->h); +/* + gp_line(c, t->x0, t->y0, t->x1, t->y1, 1); + gp_line(c, t->x0, t->y0, t->x2, t->y2, 1); + gp_line(c, t->x2, t->y2, t->x1, t->y1, 1); +*/ + gp_fill_triangle(c, t->x0, t->y0, t->x1, t->y1, t->x2, t->y2, 1); + + err = compare_buffers(t->pixmap, c); + + if (err) + return TST_FAILED; + + return TST_SUCCESS; +} + +static struct testcase triangle_point = { + .x0 = 1, + .y0 = 1, + .x1 = 1, + .y1 = 1, + .x2 = 1, + .y2 = 1, + + .w = 3, + .h = 3, + + .pixmap = { + 0, 0, 0, + 0, 1, 0, + 0, 0, 0, + } +}; + +static struct testcase triangle_hline = { + .x0 = 1, + .y0 = 1, + .x1 = 2, + .y1 = 1, + .x2 = 3, + .y2 = 1, + + .w = 5, + .h = 3, + + .pixmap = { + 0, 0, 0, 0, 0, + 0, 1, 1, 1, 0, + 0, 0, 0, 0, 0, + } +}; + +static struct testcase triangle_vline = { + .x0 = 1, + .y0 = 1, + .x1 = 1, + .y1 = 2, + .x2 = 1, + .y2 = 3, + + .w = 3, + .h = 5, + + .pixmap = { + 0, 0, 0, + 0, 1, 0, + 0, 1, 0, + 0, 1, 0, + 0, 0, 0, + } +}; + +static struct testcase triangle1 = { + .x0 = 1, + .y0 = 2, + .x1 = 3, + .y1 = 2, + .x2 = 2, + .y2 = 1, + + .w = 5, + .h = 4, + + .pixmap = { + 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 1, 1, 1, 0, + 0, 0, 0, 0, 0, + } +}; + +static struct testcase triangle2 = { + .x0 = 1, + .y0 = 1, + .x1 = 3, + .y1 = 1, + .x2 = 2, + .y2 = 2, + + .w = 5, + .h = 4, + + .pixmap = { + 0, 0, 0, 0, 0, + 0, 1, 1, 1, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, + } +}; + +static struct testcase triangle3 = { + .x0 = 2, + .y0 = 2, + .x1 = 1, + .y1 = 1, + .x2 = 2, + .y2 = 1, + + .w = 4, + .h = 4, + + .pixmap = { + 0, 0, 0, 0, + 0, 1, 1, 0, + 0, 0, 1, 0, + 0, 0, 0, 0, + } +}; + +static struct testcase triangle4 = { + .x0 = 2, + .y0 = 2, + .x1 = 1, + .y1 = 1, + .x2 = 1, + .y2 = 2, + + .w = 4, + .h = 4, + + .pixmap = { + 0, 0, 0, 0, + 0, 1, 0, 0, + 0, 1, 1, 0, + 0, 0, 0, 0, + } +}; + +const struct tst_suite tst_suite = { + .suite_name = "Fill Triangle Testsuite", + .tests = { + {.name = "Fill Triangle point", + .tst_fn = test_fill_triangle, + .data = &triangle_point}, + + {.name = "Fill Triangle hline", + .tst_fn = test_fill_triangle, + .data = &triangle_hline}, + + {.name = "Fill Triangle vline", + .tst_fn = test_fill_triangle, + .data = &triangle_vline}, + + {.name = "Fill Triangle 1", + .tst_fn = test_fill_triangle, + .data = &triangle1}, + + {.name = "Fill Triangle 2", + .tst_fn = test_fill_triangle, + .data = &triangle2}, + + {.name = "Fill Triangle 3", + .tst_fn = test_fill_triangle, + .data = &triangle3}, + + {.name = "Fill Triangle 4", + .tst_fn = test_fill_triangle, + .data = &triangle4}, + + {.name = NULL} + } +}; diff --git a/tests/gfx/fill_triangle.gen.c.t b/tests/gfx/fill_triangle.gen.c.t new file mode 100644 index 000000000000..b069f511f232 --- /dev/null +++ b/tests/gfx/fill_triangle.gen.c.t @@ -0,0 +1,55 @@ +@ include source.t +/* + * Copyright (C) 2018 Cyril Hrubis <metan(a)ucw.cz> + */ + +#include <stdio.h> + +#include <core/GP_Pixmap.h> +#include <gfx/GP_Gfx.h> +#include <filters/GP_Rotate.h> + +#include "tst_test.h" +#include "compare.h" + +@ max_x = 10 +@ max_y = 3 + +static void prep(gp_pixmap **p1, gp_pixmap **p2, gp_size w, gp_size h) +{ + *p1 = gp_pixmap_alloc(w, h, GP_PIXEL_G8); + *p2 = gp_pixmap_alloc(w, h, GP_PIXEL_G8); + + gp_fill(*p1, 0); + gp_fill(*p2, 0); +} + +@ for x in range(2, max_x, 2): +@ for y in range(1, max_y): +static int isosceles_symmetry_{{ x }}_{{ y }}(void) +{ + gp_pixmap *p1, *p2; + + prep(&p1, &p2, {{ x }}+1, {{ y }}+1); + + gp_fill_triangle(p1, {{ x }}/2, 0, 0, {{ y }}, {{ x }}, {{ y }}, 1); + gp_fill_triangle(p2, {{ x }}/2, 0, 0, {{ y }}, {{ x }}, {{ y }}, 1); + + gp_filter_mirror_h(p2, p2, NULL); + + return compare_pixmaps(p1, p2); +} + +@ end +@ +const struct tst_suite tst_suite = { + .suite_name = "Triangle fill testsuite", + .tests = { +@ for x in range(2, max_x, 2): +@ for y in range(1, max_y): + {.name = "Isosceles symmetry {{ x }}, {{ y }}", + .tst_fn = isosceles_symmetry_{{ x }}_{{ y }}}, +@ end + {.name = NULL} + } +}; diff --git a/tests/gfx/line_symmetry.gen.c.t b/tests/gfx/line_symmetry.gen.c.t index 8f1b5710b631..1415a4fee2d9 100644 --- a/tests/gfx/line_symmetry.gen.c.t +++ b/tests/gfx/line_symmetry.gen.c.t @@ -5,102 +5,16 @@ * Copyright (C) 2018 Cyril Hrubis <metan(a)ucw.cz> */ -#include <stdio.h> - #include <core/GP_Pixmap.h> #include <gfx/GP_Gfx.h> #include <filters/GP_Rotate.h> #include "tst_test.h" +#include "compare.h" @ max_x = 21 @ max_y = 21 -static void print_diff(gp_pixmap *p1, gp_pixmap *p2) -{ - gp_size x, y; - - printf(" "); - for (x = 0; x < p1->w; x++) - printf("-"); - printf("\n"); - - for (y = 0; y < p1->h; y++) { - printf("|"); - for (x = 0; x < p1->w; x++) { - gp_pixel px1 = gp_getpixel_raw_8BPP(p1, x, y); - gp_pixel px2 = gp_getpixel_raw_8BPP(p2, x, y); - - if (px1 == px2) { - if (px1) - printf("*"); - else - printf(" "); - } else { - if (px1) - printf("1"); - else - printf("2"); - } - } - printf("|\n"); - } - - printf(" "); - for (x = 0; x < p1->w; x++) - printf("-"); - printf("\n"); -} - -static void print(gp_pixmap *p) -{ - gp_size x, y; - - printf(" "); - for (x = 0; x < p->w; x++) - printf("-"); - printf("\n"); - - for (y = 0; y < p->h; y++) { - printf("|"); - for (x = 0; x < p->w; x++) { - gp_pixel px = gp_getpixel_raw_8BPP(p, x, y); - - if (px) - printf("*"); - else - printf(" "); - } - printf("|\n"); - } - - printf(" "); - for (x = 0; x < p->w; x++) - printf("-"); - printf("\n"); -} - -static int compare_pixmaps(gp_pixmap *p1, gp_pixmap *p2) -{ - gp_size x, y; - - for (x = 0; x < p1->w; x++) { - for (y = 0; y < p1->h; y++) { - gp_pixel px1 = gp_getpixel_raw_8BPP(p1, x, y); - gp_pixel px2 = gp_getpixel_raw_8BPP(p2, x, y); - - if (px1 != px2) { - print(p1); - print(p2); - print_diff(p1, p2); - return TST_FAILED; - } - } - } - - return TST_SUCCESS; -} - static void prep(gp_pixmap **p1, gp_pixmap **p2, gp_size w, gp_size h) { *p1 = gp_pixmap_alloc(w, h, GP_PIXEL_G8); diff --git a/tests/gfx/test_list.txt b/tests/gfx/test_list.txt index b8ee7ea73c5c..ef716fb60cb7 100644 --- a/tests/gfx/test_list.txt +++ b/tests/gfx/test_list.txt @@ -17,3 +17,6 @@ FillRect PutPixelAA HLineAA LineAA + +fill_triangle +fill_triangle.gen commit d63701916dc11f1349f5807efe66a0cb125c234c Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sat, 13 Jan 2018 00:16:34 +0100 URL: <
http://repo.or.cz/gfxprim.git/d63701916dc11f13
> core/GP_Common: Add MIN3() Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- include/core/GP_Common.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h index ee61735eee90..6d80730a4c1a 100644 --- a/include/core/GP_Common.h +++ b/include/core/GP_Common.h @@ -44,6 +44,16 @@ }) /* + * Returns maximum from three numbers. + */ +#define GP_MIN3(a, b, c) ({ \ + typeof(a) _a = (a); \ + typeof(b) _b = (b); \ + typeof(c) _c = (c); \ + _a < _b ? (_a < _c ? _a : _c) : (_b < _c ? _b : _c); \ +}) + +/* * Returns a maximum of the two numbers. */ #define GP_MAX(a, b) ({ \ commit 60ac88e1ae2150b7ab5836fa882141324a642a4b Author: Cyril Hrubis <metan(a)ucw.cz> Date: Thu, 11 Jan 2018 18:44:03 +0100 URL: <
http://repo.or.cz/gfxprim.git/60ac88e1ae2150b7
> gfx: Fix line drawing + symmetry tests The Bresenham's line does not draw symetric line by default, if you want line that is symmetrical when mirrored horizontally or vertically or when rotated by multiples of 90 degrees you have to draw only half of the line and draw second half symetrically to the line center. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- libs/gfx/GP_Line.gen.c.t | 100 ++++++++------ tests/gfx/.gitignore | 1 + tests/gfx/Line.c | 223 +++++++++++++++++++++++++++++++- tests/gfx/Makefile | 5 +- tests/gfx/gfx_benchmark.c | 4 +- tests/gfx/line_symmetry.gen.c.t | 173 +++++++++++++++++++++++++ tests/gfx/test_list.txt | 1 + 7 files changed, 460 insertions(+), 47 deletions(-) create mode 100644 tests/gfx/line_symmetry.gen.c.t diff --git a/libs/gfx/GP_Line.gen.c.t b/libs/gfx/GP_Line.gen.c.t index 6e41be9f47d7..bbccb58369ad 100644 --- a/libs/gfx/GP_Line.gen.c.t +++ b/libs/gfx/GP_Line.gen.c.t @@ -4,7 +4,7 @@ * * Copyright (C) 2009-2012 Jiri "BlueBear" Dluhos * <jiri.bluebear.dluhos(a)gmail.com> - * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz> + * Copyright (C) 2009-2018 Cyril Hrubis <metan(a)ucw.cz> */ #include "core/GP_Common.h" @@ -23,6 +23,60 @@ */ @ for ps in pixelsizes: +static void line_dy_{{ ps.suffix }}(gp_pixmap *pixmap, int x0, int y0, int x1, int y1, gp_pixel pixval) +{ + if (y0 > y1) { + GP_SWAP(y0, y1); + GP_SWAP(x0, x1); + } + + int deltay = y1 - y0; + int deltax = GP_ABS(x1 - x0); + + int error = deltay / 2; + + int x = 0, y; + int xstep = (x0 < x1) ? 1 : -1; + + for (y = 0; y <= deltay/2; y++) { + gp_putpixel_raw_{{ ps.suffix }}(pixmap, x0+x, y0+y, pixval); + gp_putpixel_raw_{{ ps.suffix }}(pixmap, x1-x, y1-y, pixval); + + error -= deltax; + if (error < 0) { + x += xstep; + error += deltay; + } + } +} + +static void line_dx_{{ ps.suffix }}(gp_pixmap *pixmap, int x0, int y0, int x1, int y1, gp_pixel pixval) +{ + if (x0 > x1) { + GP_SWAP(x0, x1); + GP_SWAP(y0, y1); + } + + int deltax = x1 - x0; + int deltay = GP_ABS(y1 - y0); + + int error = deltax/2; + + int y = 0, x; + int ystep = (y0 < y1) ? 1 : -1; + + for (x = 0; x <= deltax/2; x++) { + gp_putpixel_raw_{{ ps.suffix }}(pixmap, x0+x, y0+y, pixval); + gp_putpixel_raw_{{ ps.suffix }}(pixmap, x1-x, y1-y, pixval); + + error -= deltay; + if (error < 0) { + y += ystep; + error += deltax; + } + } +} + void gp_line_raw_{{ ps.suffix }}(gp_pixmap *pixmap, int x0, int y0, int x1, int y1, gp_pixel pixval) { @@ -41,7 +95,7 @@ void gp_line_raw_{{ ps.suffix }}(gp_pixmap *pixmap, int x0, int y0, x0, y0, pixval); return; } - gp_vline_raw(pixmap, x0, y0, y1, pixval); + gp_vline_raw_{{ ps.suffix }}(pixmap, x0, y0, y1, pixval); return; } if (y0 == y1) { @@ -53,44 +107,10 @@ void gp_line_raw_{{ ps.suffix }}(gp_pixmap *pixmap, int x0, int y0, * Which axis is longer? Swap the coordinates if necessary so * that the X axis is always the longer one and Y is shorter. */ - int steep = abs(y1 - y0) / abs(x1 - x0); - if (steep) { - GP_SWAP(x0, y0); - GP_SWAP(x1, y1); - } - if (x0 > x1) { - GP_SWAP(x0, x1); - GP_SWAP(y0, y1); - } - - /* iterate over the longer axis, calculate values on the shorter */ - int deltax = x1 - x0; - int deltay = abs(y1 - y0); - - /* - * start with error of 0.5 (multiplied by deltax for integer-only math), - * this reflects the fact that ideally, the coordinate should be - * in the middle of the pixel - */ - int error = deltax / 2; - - int y = y0, x; - int ystep = (y0 < y1) ? 1 : -1; - for (x = x0; x <= x1; x++) { - - if (steep) - gp_putpixel_raw_{{ ps.suffix }}(pixmap, y, x, - pixval); - else - gp_putpixel_raw_{{ ps.suffix }}(pixmap, x, y, - pixval); - - error -= deltay; - if (error < 0) { - y += ystep; /* next step on the shorter axis */ - error += deltax; - } - } + if ((y1 - y0) / (x1 - x0)) + line_dy_{{ ps.suffix }}(pixmap, x0, y0, x1, y1, pixval); + else + line_dx_{{ ps.suffix }}(pixmap, x0, y0, x1, y1, pixval); } @ end diff --git a/tests/gfx/.gitignore b/tests/gfx/.gitignore index 92632603d889..191fe86f5955 100644 --- a/tests/gfx/.gitignore +++ b/tests/gfx/.gitignore @@ -13,3 +13,4 @@ /PutPixelAA /VLine /gfx_benchmark +line_symmetry.gen diff --git a/tests/gfx/Line.c b/tests/gfx/Line.c index 1e1b2d47c25e..1b89e843ad61 100644 --- a/tests/gfx/Line.c +++ b/tests/gfx/Line.c @@ -153,7 +153,7 @@ static struct testcase testcase_line_45 = { static struct testcase testcase_line_15 = { .x0 = 0, .y0 = 1, - .x1 = 11, + .x1 = 10, .y1 = 6, .w = 11, @@ -163,11 +163,11 @@ static struct testcase testcase_line_15 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, } }; @@ -205,6 +205,183 @@ static struct testcase testcase_line_large_xy = { } }; +static struct testcase line_nearly_vertical = { + .x0 = 0, + .y0 = 0, + .x1 = 1, + .y1 = 9, + + .w = 2, + .h = 10, + + .pixmap = { + 1, 0, + 1, 0, + 1, 0, + 1, 0, + 1, 0, + 0, 1, + 0, 1, + 0, 1, + 0, 1, + 0, 1, + } +}; + +static struct testcase line_nearly_horizontal = { + .x0 = 0, + .y0 = 0, + .x1 = 9, + .y1 = 1, + + .w = 10, + .h = 2, + + .pixmap = { + 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, + } +}; + +static struct testcase line_0_0_1_2 = { + .x0 = 0, + .y0 = 0, + .x1 = 1, + .y1 = 2, + + .w = 2, + .h = 3, + + .pixmap = { + 1, 0, + 1, 1, + 0, 1, + } +}; + +static struct testcase line_0_0_1_4 = { + .x0 = 0, + .y0 = 0, + .x1 = 1, + .y1 = 4, + + .w = 2, + .h = 5, + + .pixmap = { + 1, 0, + 1, 0, + 1, 1, + 0, 1, + 0, 1, + } +}; + +static struct testcase line_0_0_2_1 = { + .x0 = 0, + .y0 = 0, + .x1 = 2, + .y1 = 1, + + .w = 3, + .h = 2, + + .pixmap = { + 1, 1, 0, + 0, 1, 1, + } +}; + +static struct testcase line_0_0_4_1 = { + .x0 = 0, + .y0 = 0, + .x1 = 4, + .y1 = 1, + + .w = 5, + .h = 2, + + .pixmap = { + 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, + } +}; + +static struct testcase line_0_0_2_4 = { + .x0 = 0, + .y0 = 0, + .x1 = 2, + .y1 = 4, + + .w = 3, + .h = 5, + + .pixmap = { + 1, 0, 0, + 1, 0, 0, + 0, 1, 0, + 0, 0, 1, + 0, 0, 1, + } +}; + +static struct testcase line_0_0_4_2 = { + .x0 = 0, + .y0 = 0, + .x1 = 4, + .y1 = 2, + + .w = 5, + .h = 3, + + .pixmap = { + 1, 1, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 1, 1, + } +}; + +static struct testcase line_0_0_8_4 = { + .x0 = 0, + .y0 = 0, + .x1 = 8, + .y1 = 4, + + .w = 9, + .h = 5, + + .pixmap = { + 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 1, + } +}; + +static struct testcase line_0_0_4_8 = { + .x0 = 0, + .y0 = 0, + .x1 = 4, + .y1 = 8, + + .w = 5, + .h = 9, + + .pixmap = { + 1, 0, 0, 0, 0, + 1, 0, 0, 0, 0, + 0, 1, 0, 0, 0, + 0, 1, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 1, 0, + 0, 0, 0, 1, 0, + 0, 0, 0, 0, 1, + 0, 0, 0, 0, 1, + } +}; + + const struct tst_suite tst_suite = { .suite_name = "Line Testsuite", .tests = { @@ -228,6 +405,46 @@ const struct tst_suite tst_suite = { .tst_fn = test_line, .data = &testcase_line_15}, + {.name = "Line nearly vertical", + .tst_fn = test_line, + .data = &line_nearly_vertical}, + + {.name = "Line nearly horizontal", + .tst_fn = test_line, + .data = &line_nearly_horizontal}, + + {.name = "Line 0, 0, 1, 2", + .tst_fn = test_line, + .data = &line_0_0_1_2}, + + {.name = "line 0, 0, 1, 4", + .tst_fn = test_line, + .data = &line_0_0_1_4}, + + {.name = "Line 0, 0, 2, 1", + .tst_fn = test_line, + .data = &line_0_0_2_1}, + + {.name = "line 0, 0, 4, 1", + .tst_fn = test_line, + .data = &line_0_0_4_1}, + + {.name = "line 0, 0, 2, 4", + .tst_fn = test_line, + .data = &line_0_0_2_4}, + + {.name = "line 0, 0, 4, 2", + .tst_fn = test_line, + .data = &line_0_0_4_2}, + + {.name = "line 0, 0, 8, 4", + .tst_fn = test_line, + .data = &line_0_0_8_4}, + + {.name = "line 0, 0, 4, 8", + .tst_fn = test_line, + .data = &line_0_0_4_8}, + {.name = "Line clipping", .tst_fn = test_line, .data = &testcase_line_clip}, diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile index 750d4553f096..4a5dc18b09a2 100644 --- a/tests/gfx/Makefile +++ b/tests/gfx/Makefile @@ -2,10 +2,11 @@ TOPDIR=../.. include $(TOPDIR)/pre.mk CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c)) -GENSOURCES=APICoverage.gen.c +GENSOURCES=APICoverage.gen.c line_symmetry.gen.c APPS=gfx_benchmark Circle FillCircle Line CircleSeg Polygon Ellipse HLine\ - VLine PutPixelAA HLineAA LineAA FillEllipse FillRect APICoverage.gen + VLine PutPixelAA HLineAA LineAA FillEllipse FillRect APICoverage.gen\ + line_symmetry.gen Circle: common.o FillCircle: common.o diff --git a/tests/gfx/gfx_benchmark.c b/tests/gfx/gfx_benchmark.c index 282ed20e3ca0..66be751ae86f 100644 --- a/tests/gfx/gfx_benchmark.c +++ b/tests/gfx/gfx_benchmark.c @@ -36,7 +36,7 @@ static int bench_line(gp_pixel_type type) unsigned int i; - for (i = 0; i < 100000; i++) { + for (i = 0; i < 20000; i++) { gp_line(img, 0 + i % 100, 0 - i % 100, 800 - i%200, 600 + i%200, i % 0xff); } @@ -80,7 +80,7 @@ static int bench_circle(gp_pixel_type type) unsigned int i; - for (i = 0; i < 100000; i++) { + for (i = 0; i < 5000; i++) { gp_circle(img, img->w/2, img->h/2, i % 1000, i%0xff); } diff --git a/tests/gfx/line_symmetry.gen.c.t b/tests/gfx/line_symmetry.gen.c.t new file mode 100644 index 000000000000..8f1b5710b631 --- /dev/null +++ b/tests/gfx/line_symmetry.gen.c.t @@ -0,0 +1,173 @@ +@ include source.t +/* + * Tests that lines horizontally and vertically symetric lines are symetric. + * + * Copyright (C) 2018 Cyril Hrubis <metan(a)ucw.cz> + */ + +#include <stdio.h> + +#include <core/GP_Pixmap.h> +#include <gfx/GP_Gfx.h> +#include <filters/GP_Rotate.h> + +#include "tst_test.h" + +@ max_x = 21 +@ max_y = 21 + +static void print_diff(gp_pixmap *p1, gp_pixmap *p2) +{ + gp_size x, y; + + printf(" "); + for (x = 0; x < p1->w; x++) + printf("-"); + printf("\n"); + + for (y = 0; y < p1->h; y++) { + printf("|"); + for (x = 0; x < p1->w; x++) { + gp_pixel px1 = gp_getpixel_raw_8BPP(p1, x, y); + gp_pixel px2 = gp_getpixel_raw_8BPP(p2, x, y); + + if (px1 == px2) { + if (px1) + printf("*"); + else + printf(" "); + } else { + if (px1) + printf("1"); + else + printf("2"); + } + } + printf("|\n"); + } + + printf(" "); + for (x = 0; x < p1->w; x++) + printf("-"); + printf("\n"); +} + +static void print(gp_pixmap *p) +{ + gp_size x, y; + + printf(" "); + for (x = 0; x < p->w; x++) + printf("-"); + printf("\n"); + + for (y = 0; y < p->h; y++) { + printf("|"); + for (x = 0; x < p->w; x++) { + gp_pixel px = gp_getpixel_raw_8BPP(p, x, y); + + if (px) + printf("*"); + else + printf(" "); + } + printf("|\n"); + } + + printf(" "); + for (x = 0; x < p->w; x++) + printf("-"); + printf("\n"); +} + +static int compare_pixmaps(gp_pixmap *p1, gp_pixmap *p2) +{ + gp_size x, y; + + for (x = 0; x < p1->w; x++) { + for (y = 0; y < p1->h; y++) { + gp_pixel px1 = gp_getpixel_raw_8BPP(p1, x, y); + gp_pixel px2 = gp_getpixel_raw_8BPP(p2, x, y); + + if (px1 != px2) { + print(p1); + print(p2); + print_diff(p1, p2); + return TST_FAILED; + } + } + } + + return TST_SUCCESS; +} + +static void prep(gp_pixmap **p1, gp_pixmap **p2, gp_size w, gp_size h) +{ + *p1 = gp_pixmap_alloc(w, h, GP_PIXEL_G8); + *p2 = gp_pixmap_alloc(w, h, GP_PIXEL_G8); + + gp_fill(*p1, 0); + gp_fill(*p2, 0); +} + +@ for x in range(1, max_x): +@ for y in range(1, max_y): +static int line_{{ x }}_{{ y }}_h(void) +{ + gp_pixmap *p1, *p2; + + prep(&p1, &p2, {{ x }}+1, {{ y }}+1); + + gp_line(p1, 0, 0, {{ x }}, {{ y }}, 1); + gp_line(p2, 0, {{ y }}, {{ x }}, 0, 1); + + gp_filter_mirror_h(p2, p2, NULL); + + return compare_pixmaps(p1, p2); +} + +static int line_{{ x }}_{{ y }}_v(void) +{ + gp_pixmap *p1, *p2; + + prep(&p1, &p2, {{ x }}+1, {{ y }}+1); + + gp_line(p1, 0, 0, {{ x }}, {{ y }}, 1); + gp_line(p2, {{ x }}, 0, 0, {{ y }}, 1); + + gp_filter_mirror_v(p2, p2, NULL); + + return compare_pixmaps(p1, p2); +} + +static int line_{{ x }}_{{ y }}_rot(void) +{ + gp_pixmap *p1, *p2; + gp_size w = GP_MAX({{ x }}, {{ y }}) + 1; + + prep(&p1, &p2, w, w); + + gp_line(p1, 0, 0, {{ x }}, {{ y }}, 1); + gp_line(p2, 0, w-1, {{ y }}, w - 1 - {{ x }}, 1); + p2 = gp_filter_rotate_90_alloc(p2, NULL); + + return compare_pixmaps(p1, p2); +} + +@ end +@ +const struct tst_suite tst_suite = { + .suite_name = "Line symmetry testsuite", + .tests = { +@ for x in range(1, max_x): +@ for y in range(1, max_y): + {.name = "line_h 0, 0, {{ x }}, {{ y }} vs 0, {{ y }}, {{ x }}, 0", + .tst_fn = line_{{ x }}_{{ y }}_h}, + {.name = "line_v 0, 0, {{ x }}, {{ y }} vs {{ x }}, 0, 0, {{ y }}", + .tst_fn = line_{{ x }}_{{ y }}_v}, + {.name = "line 0, 0, {{ x }}, {{ y }} rot 90", + .tst_fn = line_{{ x }}_{{ y }}_rot}, +@ end + {.name = NULL} + } +}; diff --git a/tests/gfx/test_list.txt b/tests/gfx/test_list.txt index b801c5baa93e..b8ee7ea73c5c 100644 --- a/tests/gfx/test_list.txt +++ b/tests/gfx/test_list.txt @@ -5,6 +5,7 @@ APICoverage.gen HLine VLine Line +line_symmetry.gen Circle FillCircle Ellipse commit 7afea0007af1aed1fe11a4762703eecb15395516 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Wed, 13 Dec 2017 22:14:49 +0100 URL: <
http://repo.or.cz/gfxprim.git/7afea0007af1aed1
> Rename API to snake_case. The Python API no uses snake_case for functions and MixedCase for classes. Also the Python API has been broken for quite some time and as a side effect this a few bugs has been fixed, we really need tests otherwise it will break again sooner or later. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- build/check_symbols.sh | 14 +- build/syms/Backend_symbols.txt | 27 - build/syms/Core_symbols.txt | 78 --- build/syms/Filters_symbols.txt | 134 ----- build/syms/GFX_symbols.txt | 107 ---- build/syms/Grabbers_symbols.txt | 1 - build/syms/Input_symbols.txt | 33 -- build/syms/Loaders_symbols.txt | 165 ------ build/syms/Text_symbols.txt | 33 -- build/syms/backend_symbols.txt | 19 + build/syms/core_symbols.txt | 309 ++++++++++ build/syms/filters_symbols.txt | 0 build/syms/gfx_symbols.txt | 0 build/syms/grabbers_symbols.txt | 1 + build/syms/input_symbols.txt | 0 build/syms/loaders_symbols.txt | 100 ++++ build/syms/text_symbols.txt | 0 demos/bogoman/bogoman.c | 30 +- demos/bogoman/bogoman_render.c | 120 ++-- demos/bogoman/bogoman_render.h | 5 +- demos/c_simple/SDL_glue.c | 20 +- demos/c_simple/backend_example.c | 40 +- demos/c_simple/backend_timers_example.c | 36 +- demos/c_simple/blittest.c | 68 +-- demos/c_simple/convolution.c | 18 +- demos/c_simple/data_storage.c | 26 +- demos/c_simple/debug_handler.c | 14 +- demos/c_simple/fileview.c | 90 +-- demos/c_simple/filters_symmetry.c | 24 +- demos/c_simple/fonttest.c | 108 ++-- demos/c_simple/gaussian_noise.c | 10 +- demos/c_simple/gfx_koch.c | 22 +- demos/c_simple/input_example.c | 75 +-- demos/c_simple/koch.c | 50 +- demos/c_simple/linetest.c | 44 +- demos/c_simple/loaders.c | 14 +- demos/c_simple/loaders_example.c | 10 +- demos/c_simple/loaders_register.c | 42 +- demos/c_simple/memory_io.c | 32 +- demos/c_simple/meta_data.c | 12 +- demos/c_simple/pretty_print.c | 10 +- demos/c_simple/randomshapetest.c | 74 +-- demos/c_simple/shapetest.c | 134 ++--- demos/c_simple/showimage.c | 28 +- demos/c_simple/textaligntest.c | 70 +-- demos/c_simple/timers.c | 28 +- demos/c_simple/v4l2_grab.c | 21 +- demos/c_simple/v4l2_show.c | 54 +- demos/c_simple/version.c | 2 +- demos/c_simple/virtual_backend_example.c | 84 +-- demos/c_simple/weighted_median.c | 16 +- demos/c_simple/x11_windows.c | 54 +- demos/c_simple/zip_container.c | 42 +- demos/grinder/grinder.c | 144 ++--- demos/grinder/histogram.c | 35 +- demos/grinder/histogram.h | 4 +- demos/particle/particle_demo.c | 44 +- demos/particle/space.c | 52 +- demos/particle/space.h | 4 +- demos/py_simple/backends.py | 18 +- demos/py_simple/blit.py | 30 +- demos/py_simple/blur.py | 6 +- demos/py_simple/cam_view.py | 18 +- demos/py_simple/convolution.py | 6 +- demos/py_simple/dither.py | 8 +- demos/py_simple/font_style.py | 20 +- demos/py_simple/gfx.py | 88 +-- demos/py_simple/gfxprim_qt.py | 6 +- demos/py_simple/invert.py | 10 +- demos/py_simple/loaders_example.py | 8 +- demos/py_simple/progress_callback.py | 6 +- demos/py_simple/resize.py | 10 +- demos/py_simple/rotate90.py | 12 +- demos/py_simple/showimage.py | 14 +- demos/py_simple/x11_windows.py | 26 +- demos/spiv/image_cache.c | 28 +- demos/spiv/image_cache.h | 14 +- demos/spiv/image_list.c | 2 +- demos/spiv/image_loader.c | 36 +- demos/spiv/image_loader.h | 4 +- demos/spiv/spiv.c | 220 ++++---- demos/spiv/spiv_config.c | 15 +- demos/spiv/spiv_config.h | 6 +- demos/spiv/spiv_help.c | 40 +- demos/spiv/spiv_help.h | 4 +- demos/termini/termini.c | 98 ++-- demos/ttf2img/ttf2img.c | 22 +- doc/about.txt | 6 +- doc/backends.txt | 226 ++++---- doc/basic_types.txt | 10 +- doc/blits.txt | 52 +- doc/coding_style.txt | 18 +- doc/convert.txt | 20 +- doc/coordinate_system.txt | 4 +- doc/core_common.txt | 22 +- doc/core_python.txt | 34 +- doc/debug.txt | 20 +- doc/environment_variables.txt | 16 +- doc/event_queue.txt | 69 +-- doc/example_SDL_glue.txt | 2 +- doc/example_loader_registration.txt | 6 +- doc/filters.txt | 503 ++++++++--------- doc/filters_dithering.txt | 28 +- doc/filters_python.txt | 2 +- doc/filters_resize.txt | 90 +-- doc/gamma.txt | 21 +- doc/get_put_pixel.txt | 20 +- doc/gfx.txt | 139 +++-- doc/grabbers.txt | 38 +- doc/input.txt | 98 ++-- doc/loaders.txt | 456 +++++++-------- doc/loaders_io.txt | 28 +- doc/pixels.txt | 78 +-- doc/pixmap.txt | 94 ++-- doc/progress_callback.txt | 8 +- doc/text.txt | 76 +-- gen/include/pixeltype.py | 2 +- include/Makefile | 2 +- include/backends/GP_AALib.h | 4 +- include/backends/GP_Backend.h | 150 +++-- include/backends/GP_BackendInit.h | 2 +- include/backends/GP_BackendVirtual.h | 14 +- include/backends/GP_LinuxFB.h | 6 +- include/backends/GP_SDL.h | 13 +- include/backends/GP_SDL_Pixmap.h | 6 +- include/backends/GP_X11.h | 16 +- include/core/GP_BitSwap.h | 6 +- include/core/GP_Blit.h | 80 ++- include/core/GP_Common.h | 13 +- include/core/GP_Convert.gen.h.t | 28 +- include/core/GP_Convert.h | 54 +- include/core/GP_Debug.h | 22 +- include/core/GP_Fill.h | 4 +- include/core/GP_FnPerBpp.h | 20 +- include/core/GP_Gamma.h | 48 +- include/core/GP_GammaCorrection.gen.h.t | 58 +- include/core/GP_GammaCorrection.h | 6 +- include/core/GP_GammaPixel.gen.h.t | 20 +- include/core/GP_GetPutPixel.gen.h.t | 15 +- include/core/GP_GetPutPixel.h | 30 +- include/core/GP_MixPixels.gen.h.t | 51 +- include/core/GP_MixPixels2.gen.h.t | 26 +- include/core/GP_Pixel.gen.h.t | 12 +- include/core/GP_Pixel.h | 91 ++- include/core/GP_Pixmap.h | 88 ++- include/core/GP_ProgressCallback.h | 22 +- include/core/GP_TempAlloc.h | 28 +- .../core/{GP_TempAlloc.h => GP_TempAlloc2.h} | 109 ++-- include/core/GP_Threads.h | 20 +- include/core/GP_Transform.h | 2 +- include/core/GP_Types.h | 34 +- include/core/GP_WritePixel.gen.h.t | 4 +- include/filters/GP_ApplyTables.h | 28 +- include/filters/GP_Arithmetic.h | 84 +-- include/filters/GP_Blur.h | 46 +- include/filters/GP_Convolution.h | 68 +-- include/filters/GP_Dither.h | 26 +- include/filters/GP_EdgeDetection.h | 14 +- include/filters/GP_Filters.h | 2 +- include/filters/GP_GaussianNoise.h | 50 +- include/filters/GP_HilbertCurve.h | 14 +- include/filters/GP_Laplace.h | 18 +- include/filters/GP_Linear.h | 90 ++- include/filters/GP_LinearThreads.h | 11 +- include/filters/GP_Median.h | 48 +- include/filters/GP_MultiTone.h | 63 +-- include/filters/GP_Point.h | 402 ++++++------- include/filters/GP_Rand.h | 4 +- include/filters/GP_Resize.h | 24 +- include/filters/GP_ResizeCubic.h | 28 +- include/filters/GP_ResizeLinear.h | 28 +- include/filters/GP_ResizeNN.h | 16 +- include/filters/GP_Rotate.h | 70 +-- include/filters/GP_Sepia.h | 44 +- include/filters/GP_Sigma.h | 54 +- include/filters/GP_Stats.h | 43 +- include/filters/GP_WeightedMedian.h | 52 +- include/gfx/GP_Arc.h | 16 +- include/gfx/GP_Circle.h | 32 +- include/gfx/GP_CircleSeg.h | 20 +- include/gfx/GP_Ellipse.h | 16 +- include/gfx/GP_HLine.gen.h.t | 4 +- include/gfx/GP_HLine.h | 30 +- include/gfx/GP_HLineAA.h | 8 +- include/gfx/GP_Line.h | 8 +- include/gfx/GP_LineAA.h | 8 +- include/gfx/GP_LineClip.h | 2 +- include/gfx/GP_Polygon.h | 16 +- include/gfx/GP_PutPixelAA.h | 10 +- include/gfx/GP_Rect.h | 62 +-- include/gfx/GP_Tetragon.h | 24 +- include/gfx/GP_Triangle.h | 24 +- include/gfx/GP_VLine.gen.h.t | 4 +- include/gfx/GP_VLine.h | 30 +- include/gfx/GP_VLineAA.h | 8 +- include/{GP.h => gfxprim.h} | 6 +- include/grabbers/GP_Grabber.h | 44 +- include/grabbers/GP_V4L2.h | 8 +- include/input/GP_Event.h | 53 +- include/input/GP_EventQueue.h | 76 +-- include/input/GP_Input.h | 2 +- include/input/GP_InputDriverKBD.h | 6 +- include/input/GP_InputDriverLinux.h | 18 +- include/input/GP_TimeStamp.h | 2 +- include/input/GP_Timer.h | 34 +- .../{loaders/GP_ZIP.h => input/GP_Types.h} | 24 +- include/loaders/GP_BMP.h | 68 --- include/loaders/GP_Container.h | 53 +- include/loaders/GP_DataStorage.h | 72 +-- include/loaders/GP_Exif.h | 8 +- include/loaders/GP_GIF.h | 54 -- include/loaders/GP_IO.h | 101 ++-- include/loaders/GP_IOZlib.h | 4 +- include/loaders/GP_JP2.h | 57 -- include/loaders/GP_JPG.h | 72 --- include/loaders/GP_LineConvert.h | 10 +- include/loaders/GP_Loader.h | 74 +-- include/loaders/GP_Loaders.gen.h.t | 44 ++ include/loaders/GP_Loaders.h | 27 +- include/loaders/GP_PCX.h | 60 -- include/loaders/GP_PNG.h | 74 --- include/loaders/GP_PNM.h | 106 ---- include/loaders/GP_PSD.h | 55 -- include/loaders/GP_PSP.h | 62 --- include/loaders/GP_TIFF.h | 65 --- include/loaders/GP_ZIP.h | 10 +- include/loaders/Makefile | 8 + include/text/GP_DefaultFont.h | 32 -- include/text/GP_Font.h | 75 +-- include/text/GP_Fonts.h | 23 +- include/text/GP_Text.h | 52 +- include/text/GP_TextMetric.h | 22 +- include/text/GP_TextStyle.h | 14 +- libs/backends/GP_AALib.c | 63 +-- libs/backends/GP_Backend.c | 122 ++-- libs/backends/GP_BackendInit.c | 42 +- libs/backends/GP_BackendVirtual.c | 100 ++-- libs/backends/GP_InputDriverSDL.c | 29 +- libs/backends/GP_InputDriverSDL.h | 5 +- libs/backends/GP_LinuxFB.c | 69 +-- libs/backends/GP_SDL.c | 95 ++-- libs/backends/GP_X11.c | 132 ++--- libs/backends/GP_X11_Input.h | 31 +- libs/backends/GP_X11_Win.h | 2 +- libs/core/GP_Blit.c | 104 ++-- libs/core/GP_Blit.gen.c.t | 109 ++-- libs/core/GP_Common.c | 6 +- libs/core/GP_Convert.gen.c.t | 12 +- libs/core/GP_Debug.c | 23 +- libs/core/GP_Fill.gen.c.t | 10 +- libs/core/GP_Gamma.c | 48 +- libs/core/GP_GammaCorrection.gen.c.t | 4 +- libs/core/GP_GetPutPixel.c | 10 +- libs/core/GP_Pixel.c | 73 +-- libs/core/GP_Pixel.gen.c.t | 14 +- libs/core/GP_Pixmap.c | 103 ++-- libs/core/GP_Threads.c | 8 +- libs/core/GP_WritePixel.c | 20 +- .../{GP_Addition.gen.c.t => GP_Add.gen.c.t} | 6 +- libs/filters/GP_ApplyTables.c | 24 +- libs/filters/GP_ApplyTables.gen.c.t | 42 +- libs/filters/GP_Blur.c | 86 +-- libs/filters/GP_Brightness.gen.c.t | 4 +- libs/filters/GP_BrightnessContrast.gen.c.t | 4 +- libs/filters/GP_Contrast.gen.c.t | 4 +- libs/filters/GP_Convolution.c | 52 +- libs/filters/GP_Cubic.gen.c.t | 2 +- libs/filters/GP_Cubic.h | 4 +- ...{GP_Difference.gen.c.t => GP_Diff.gen.c.t} | 4 +- libs/filters/GP_Edge.c | 76 +-- libs/filters/GP_FloydSteinberg.gen.c.t | 72 +-- libs/filters/GP_GaussianNoise.gen.c.t | 303 +++++----- libs/filters/GP_HilbertPeano.gen.c.t | 66 +-- libs/filters/GP_Histogram.c | 34 +- libs/filters/GP_Histogram.gen.c.t | 32 +- libs/filters/GP_Invert.gen.c.t | 2 +- libs/filters/GP_Laplace.c | 46 +- libs/filters/GP_LinearConvolution.c | 55 +- libs/filters/GP_LinearConvolution.gen.c.t | 166 +++--- libs/filters/GP_LinearThreads.c | 69 +-- libs/filters/GP_Max.gen.c.t | 4 +- libs/filters/GP_Median.c | 104 ++-- libs/filters/GP_Min.gen.c.t | 4 +- libs/filters/GP_MirrorH.gen.c.t | 50 +- .../{GP_Multiply.gen.c.t => GP_Mul.gen.c.t} | 6 +- libs/filters/GP_MultiTone.gen.c.t | 82 +-- libs/filters/GP_Posterize.gen.c.t | 2 +- libs/filters/GP_Rand.c | 7 +- libs/filters/GP_Resize.c | 49 +- libs/filters/GP_ResizeCubic.gen.c.t | 52 +- libs/filters/GP_ResizeCubicFloat.c | 46 +- libs/filters/GP_ResizeLinear.gen.c.t | 84 ++- libs/filters/GP_ResizeNN.gen.c.t | 38 +- libs/filters/GP_Rotate.c | 72 ++- libs/filters/GP_Rotate.gen.c.t | 114 ++-- libs/filters/GP_Sepia.c | 54 +- libs/filters/GP_Sigma.c | 117 ++-- libs/filters/GP_WeightedMedian.c | 110 ++-- libs/filters/Makefile | 4 +- libs/filters/arithmetic_filter.t | 56 +- libs/filters/point_filter.t | 139 +++-- libs/gfx/GP_Arc.c | 28 +- libs/gfx/GP_Circle.c | 44 +- libs/gfx/GP_CircleSeg.c | 29 +- libs/gfx/GP_Ellipse.c | 14 +- libs/gfx/GP_FillCircle.gen.c.t | 46 +- libs/gfx/GP_FillEllipse.gen.c.t | 26 +- libs/gfx/GP_HLine.c | 26 +- libs/gfx/GP_HLine.gen.c.t | 10 +- libs/gfx/GP_HLineAA.c | 19 +- libs/gfx/GP_HLineAA.gen.c.t | 24 +- libs/gfx/GP_Line.gen.c.t | 30 +- libs/gfx/GP_LineAA.c | 17 +- libs/gfx/GP_LineAA.gen.c.t | 56 +- libs/gfx/GP_LineClip.c | 8 +- libs/gfx/GP_Polygon.c | 78 +-- libs/gfx/GP_PutPixelAA.gen.c.t | 30 +- libs/gfx/GP_Rect.c | 58 +- libs/gfx/GP_Tetragon.c | 42 +- libs/gfx/GP_Triangle.c | 38 +- libs/gfx/GP_VLine.c | 26 +- libs/gfx/GP_VLine.gen.c.t | 6 +- libs/gfx/GP_VLineAA.c | 18 +- libs/gfx/GP_VLineAA.gen.c.t | 24 +- libs/grabbers/GP_V4L2.c | 41 +- libs/input/GP_Event.c | 16 +- libs/input/GP_EventQueue.c | 96 ++-- libs/input/GP_InputDriverKBD.c | 14 +- libs/input/GP_InputDriverLinux.c | 50 +- libs/input/GP_TimeStamp.c | 8 +- libs/input/GP_Timer.c | 53 +- libs/loaders/GP_BMP.c | 221 ++++---- libs/loaders/GP_BMP_RLE.h | 24 +- libs/loaders/GP_Container.c | 20 +- libs/loaders/GP_DataStorage.c | 133 +++-- libs/loaders/GP_Exif.c | 44 +- libs/loaders/GP_GIF.c | 73 +-- libs/loaders/GP_IO.c | 152 ++--- libs/loaders/GP_IOZlib.c | 39 +- libs/loaders/GP_JP2.c | 72 +-- libs/loaders/GP_JPG.c | 148 +++-- libs/loaders/GP_LineConvert.c | 33 +- libs/loaders/GP_Loader.c | 162 +++--- libs/loaders/GP_PCX.c | 176 +++--- libs/loaders/GP_PNG.c | 134 ++--- libs/loaders/GP_PNM.c | 382 ++++++------- libs/loaders/GP_PSD.c | 168 +++--- libs/loaders/GP_PSP.c | 97 ++-- libs/loaders/GP_TIFF.c | 138 ++--- libs/loaders/GP_ZIP.c | 108 ++-- libs/text/GP_DefaultFont.c | 10 +- libs/text/GP_Font.c | 13 +- libs/text/GP_FontC64.c | 4 +- libs/text/GP_FontTiny.c | 4 +- libs/text/GP_FontTinyMono.c | 4 +- libs/text/GP_FreeType.c | 14 +- libs/text/GP_HaxorNarrow15.c | 9 +- libs/text/GP_HaxorNarrow16.c | 9 +- libs/text/GP_HaxorNarrow17.c | 9 +- libs/text/GP_Text.c | 80 +-- libs/text/GP_Text.gen.c.t | 74 +-- libs/text/GP_TextMetric.c | 62 +-- libs/text/GP_TextStyle.c | 36 -- pylib/gfxprim/backends/__init__.py | 16 +- pylib/gfxprim/backends/_extend_backend.py | 62 +-- pylib/gfxprim/backends/backends.i | 36 +- pylib/gfxprim/common.i | 10 +- pylib/gfxprim/core/__init__.py | 88 +-- pylib/gfxprim/core/core.i | 96 ++-- pylib/gfxprim/filters/__init__.py | 138 ++--- pylib/gfxprim/filters/filters.i | 106 ++-- pylib/gfxprim/gfx/__init__.py | 32 +- pylib/gfxprim/gfx/gfx.i | 18 +- pylib/gfxprim/grabbers/__init__.py | 32 +- pylib/gfxprim/grabbers/grabbers.i | 24 +- pylib/gfxprim/input/__init__.py | 2 +- pylib/gfxprim/input/input.i | 12 +- pylib/gfxprim/loaders/__init__.py | 54 +- pylib/gfxprim/loaders/loaders.i | 133 ++--- pylib/gfxprim/text/__init__.py | 10 +- pylib/gfxprim/text/text.i | 30 +- tests/afl/loaders.c | 8 +- tests/core/BlitClipped.c | 30 +- tests/core/BlitConv.gen.c.t | 50 +- tests/core/Convert.gen.c.t | 18 +- tests/core/Debug.c | 6 +- tests/core/GetPutPixel.gen.c.t | 50 +- tests/core/Pixel.c | 11 +- tests/core/Pixmap.c | 54 +- tests/core/WritePixel.gen.c.t | 4 +- tests/drivers/framebuffer_test.c | 58 +- tests/drivers/linux_input.c | 18 +- tests/filters/APICoverage.gen.c.t | 526 +++++++++--------- tests/filters/FilterMirrorH.c | 58 +- tests/filters/FiltersCompare.gen.c.t | 164 +++--- tests/filters/LinearConvolution.c | 22 +- tests/filters/Makefile | 4 +- tests/filters/common.c | 6 +- tests/filters/common.h | 4 +- tests/gfx/APICoverage.gen.c.t | 38 +- tests/gfx/Circle.c | 14 +- tests/gfx/CircleSeg.c | 10 +- tests/gfx/Ellipse.c | 16 +- tests/gfx/FillCircle.c | 14 +- tests/gfx/FillEllipse.c | 16 +- tests/gfx/FillRect.c | 16 +- tests/gfx/HLine.c | 20 +- tests/gfx/HLineAA.c | 14 +- tests/gfx/Line.c | 16 +- tests/gfx/LineAA.c | 16 +- tests/gfx/Makefile | 2 +- tests/gfx/Polygon.c | 10 +- tests/gfx/PutPixelAA.c | 12 +- tests/gfx/VLine.c | 20 +- tests/gfx/common.c | 6 +- tests/gfx/common.h | 4 +- tests/gfx/gfx_benchmark.c | 12 +- tests/input/TimeStamp.c | 6 +- tests/input/Timer.c | 46 +- tests/loaders/DataStorage.c | 116 ++-- tests/loaders/Exif.c | 14 +- tests/loaders/GIF.c | 14 +- tests/loaders/IO.c | 116 ++-- tests/loaders/JPG.c | 36 +- tests/loaders/Loader.c | 32 +- tests/loaders/Loader.h | 74 +-- tests/loaders/Makefile | 1 + tests/loaders/PBM.c | 6 +- tests/loaders/PCX.c | 52 +- tests/loaders/PGM.c | 6 +- tests/loaders/PNG.c | 30 +- tests/loaders/PNM.c | 2 +- tests/loaders/PPM.c | 6 +- tests/loaders/SaveAbort.gen.c.t | 16 +- tests/loaders/SaveLoad.gen.c.t | 26 +- tests/loaders/ZIP.c | 20 +- tests/loaders/loaders_suite.c | 232 ++++---- tests/loaders/savers.t | 2 +- tests/pylib/test_core.py | 54 +- tests/pylib/test_gfx.py | 54 +- tests/pylib/testutils.py | 6 +- 441 files changed, 9666 insertions(+), 10875 deletions(-) delete mode 100644 build/syms/Backend_symbols.txt delete mode 100644 build/syms/Core_symbols.txt delete mode 100644 build/syms/Filters_symbols.txt delete mode 100644 build/syms/GFX_symbols.txt delete mode 100644 build/syms/Grabbers_symbols.txt delete mode 100644 build/syms/Input_symbols.txt delete mode 100644 build/syms/Loaders_symbols.txt delete mode 100644 build/syms/Text_symbols.txt create mode 100644 build/syms/backend_symbols.txt create mode 100644 build/syms/core_symbols.txt create mode 100644 build/syms/filters_symbols.txt create mode 100644 build/syms/gfx_symbols.txt create mode 100644 build/syms/grabbers_symbols.txt create mode 100644 build/syms/input_symbols.txt create mode 100644 build/syms/loaders_symbols.txt create mode 100644 build/syms/text_symbols.txt rewrite include/core/GP_GammaCorrection.gen.h.t (68%) copy include/core/{GP_TempAlloc.h => GP_TempAlloc2.h} (50%) rewrite include/filters/GP_Point.h (68%) rename include/{GP.h => gfxprim.h} (97%) copy include/{loaders/GP_ZIP.h => input/GP_Types.h} (84%) delete mode 100644 include/loaders/GP_BMP.h delete mode 100644 include/loaders/GP_GIF.h delete mode 100644 include/loaders/GP_JP2.h delete mode 100644 include/loaders/GP_JPG.h create mode 100644 include/loaders/GP_Loaders.gen.h.t delete mode 100644 include/loaders/GP_PCX.h delete mode 100644 include/loaders/GP_PNG.h delete mode 100644 include/loaders/GP_PNM.h delete mode 100644 include/loaders/GP_PSD.h delete mode 100644 include/loaders/GP_PSP.h delete mode 100644 include/loaders/GP_TIFF.h create mode 100644 include/loaders/Makefile delete mode 100644 include/text/GP_DefaultFont.h rename libs/filters/{GP_Addition.gen.c.t => GP_Add.gen.c.t} (70%) rename libs/filters/{GP_Difference.gen.c.t => GP_Diff.gen.c.t} (67%) rewrite libs/filters/GP_GaussianNoise.gen.c.t (64%) rename libs/filters/{GP_Multiply.gen.c.t => GP_Mul.gen.c.t} (74%) rewrite libs/filters/point_filter.t (71%) delete mode 100644 libs/text/GP_TextStyle.c rewrite pylib/gfxprim/loaders/loaders.i (78%) rewrite tests/filters/APICoverage.gen.c.t (65%) diff --git a/build/check_symbols.sh b/build/check_symbols.sh index 61be791b48fd..ede319f45d16 100755 --- a/build/check_symbols.sh +++ b/build/check_symbols.sh @@ -61,19 +61,19 @@ do_check() rm $SYMTMPFILE } -do_check libgfxprim.so syms/Core_symbols.txt syms/Input_symbols.txt \ - syms/Filters_symbols.txt syms/GFX_symbols.txt \ - syms/Text_symbols.txt +do_check libgfxprim.so syms/core_symbols.txt syms/input_symbols.txt \ + syms/filters_symbols.txt syms/gfx_symbols.txt \ + syms/text_symbols.txt -do_check libgfxprim-backends.so syms/Backend_symbols.txt +do_check libgfxprim-backends.so syms/backend_symbols.txt -do_check libgfxprim-grabbers.so syms/Grabbers_symbols.txt +do_check libgfxprim-grabbers.so syms/grabbers_symbols.txt -do_check libgfxprim-loaders.so syms/Loaders_symbols.txt +do_check libgfxprim-loaders.so syms/loaders_symbols.txt if [ -n "$FOUND" ]; then echo - echo "Set them static or update lists of exported functions in syms/Foo_symbols.txt" + echo "Set them static or update lists of exported functions in syms/foo_symbols.txt" echo echo "$WARN" else diff --git a/build/syms/Backend_symbols.txt b/build/syms/Backend_symbols.txt deleted file mode 100644 index 24bbc8b6f2c6..000000000000 --- a/build/syms/Backend_symbols.txt +++ /dev/null @@ -1,27 +0,0 @@ -GP_BackendInit - -GP_BackendLinuxFBInit - -GP_BackendVirtualInit - -GP_BackendX11Init -GP_BackendIsX11 -GP_BackendX11RequestFullscreen - -GP_BackendSDLInit -GP_PixmapFromSDLSurface - -GP_BackendAALibInit - -GP_BackendResize -GP_BackendResizeAck -GP_BackendUpdateRectXYXY -GP_BackendFlip -GP_BackendWait -GP_BackendPoll -GP_BackendWaitEvent -GP_BackendPollEvent -GP_BackendAddTimer -GP_BackendRemTimer - -GP_InputDriverSDLEventPut diff --git a/build/syms/Core_symbols.txt b/build/syms/Core_symbols.txt deleted file mode 100644 index b49ab7670191..000000000000 --- a/build/syms/Core_symbols.txt +++ /dev/null @@ -1,78 +0,0 @@ -GP_PixelTypes -GP_PixelHasFlags - -GP_PixmapAlloc -GP_PixmapSetGamma -GP_PixmapResize -GP_PixmapConvertAlloc -GP_PixmapPrintInfo -GP_PixmapRotateCCW -GP_SubPixmapAlloc -GP_PixmapConvert -GP_PixmapRotateCW -GP_PixmapFree -GP_PixmapInit -GP_SubPixmap -GP_PixmapCopy -GP_PixmapEqual -GP_PixelAddrOffset - -GP_GammaRelease -GP_GammaCopy -GP_GammaAcquire -GP_GammaPrint - -GP_DebugPrint -GP_SetDebugLevel -GP_GetDebugLevel -GP_SetDebugHandler - -GP_PrintAbortInfo - -GP_RGBA8888ToPixel -GP_PixelRGBMatch -GP_PixelTypeByName -GP_RGB888ToPixel - -GP_PixelPrint -GP_PixelSNPrint - -GP_BlitXYXY -GP_BlitXYXY_Fast -GP_BlitXYWH -GP_BlitXYWH_Clipped -GP_BlitXYXY_Clipped -GP_BlitXYXY_Raw_Fast -GP_BlitXYWH_Raw -GP_BlitXYXY_Raw - -GP_WritePixels_1BPP_LE -GP_WritePixels_2BPP_LE -GP_WritePixels_4BPP_LE -GP_WritePixels_1BPP_BE -GP_WritePixels_2BPP_BE -GP_WritePixels_4BPP_BE -GP_WritePixels_8BPP -GP_WritePixels_16BPP -GP_WritePixels_18BPP_LE -GP_WritePixels_24BPP -GP_WritePixels_32BPP - -GP_PutPixel -GP_GetPixel -GP_PixelRGBLookup -GP_PixelToRGB888 -GP_PixelToRGBA8888 - -GP_Fill - -GP_NrThreads -GP_NrThreadsSet -GP_ProgressCallbackMP - -SWIG_exception - -GP_Gamma8_Linear10 -GP_Linear10_Gamma8 - -GP_DebugPrintCStack diff --git a/build/syms/Filters_symbols.txt b/build/syms/Filters_symbols.txt deleted file mode 100644 index 52e078f53ad2..000000000000 --- a/build/syms/Filters_symbols.txt +++ /dev/null @@ -1,134 +0,0 @@ -GP_CubicTable - -GP_FilterTablesApply -GP_FilterTablesAlloc -GP_FilterTablesInit -GP_FilterTablesFree - -GP_FilterInvertEx -GP_FilterInvertExAlloc - -GP_FilterBrightnessEx -GP_FilterBrightnessExAlloc - -GP_FilterContrastEx -GP_FilterContrastExAlloc - -GP_FilterBrightnessContrastEx -GP_FilterBrightnessContrastExAlloc - -GP_FilterPosterizeEx -GP_FilterPosterizeExAlloc - -GP_FilterAddition -GP_FilterAdditionAlloc -GP_FilterAddition_Raw - -GP_FilterConvolutionEx -GP_FilterConvolutionExAlloc -GP_FilterConvolutionMP_Raw - -GP_FilterDifference -GP_FilterDifferenceAlloc -GP_FilterDifference_Raw - -GP_FilterEdgePrewitt - -GP_FilterEdgeSharpening -GP_FilterEdgeSharpeningAlloc - -GP_FilterEdgeSobel - -GP_FilterFloydSteinberg -GP_FilterFloydSteinbergAlloc - -GP_FilterHilbertPeano -GP_FilterHilbertPeanoAlloc - -GP_FilterGaussianBlurEx -GP_FilterGaussianBlurExAlloc -GP_FilterGaussianBlur_Raw - -GP_FilterGaussianNoiseAddEx -GP_FilterGaussianNoiseAddExAlloc -GP_FilterGaussianNoiseAdd_Raw - -GP_FilterHConvolutionMP_Raw -GP_FilterHLinearConvolution_Raw - -GP_FilterHistogram -GP_HistogramAlloc -GP_HistogramFree -GP_HistogramChannelByName - -GP_FilterKernelPrint_Raw - -GP_FilterLaplace -GP_FilterLaplaceAlloc -GP_FilterLinearConvolution_Raw - -GP_FilterMax -GP_FilterMaxAlloc -GP_FilterMax_Raw - -GP_FilterMedianEx -GP_FilterMedianExAlloc - -GP_FilterMin -GP_FilterMinAlloc -GP_FilterMin_Raw - -GP_FilterMirrorH -GP_FilterMirrorHAlloc -GP_FilterMirrorH_Raw - -GP_FilterMirrorV -GP_FilterMirrorVAlloc -GP_FilterMirrorV_Raw - -GP_FilterMultiply -GP_FilterMultiplyAlloc -GP_FilterMultiply_Raw - -GP_FilterResize -GP_FilterResizeAlloc - -GP_FilterResizeLinearInt -GP_FilterResizeLinearLFInt -GP_FilterResizeNN -GP_FilterResizeCubicInt -GP_FilterResizeCubic - -GP_FilterRotate180 -GP_FilterRotate180Alloc - -GP_FilterRotate270 -GP_FilterRotate270Alloc - -GP_FilterRotate90 -GP_FilterRotate90Alloc - -GP_FilterSigmaEx -GP_FilterSigmaExAlloc - -GP_FilterSymmetry -GP_FilterSymmetryByName -GP_FilterSymmetryNames -GP_FilterSymmetryAlloc - -GP_FilterVConvolutionMP_Raw -GP_FilterVHLinearConvolution_Raw -GP_FilterVLinearConvolution_Raw - -GP_FilterWeightedMedianEx -GP_FilterWeightedMedianExAlloc - -GP_FilterMultiToneEx -GP_FilterMultiToneExAlloc - -GP_FilterSepiaEx -GP_FilterSepiaExAlloc - -GP_InterpolationTypeName - -GP_NormInt diff --git a/build/syms/GFX_symbols.txt b/build/syms/GFX_symbols.txt deleted file mode 100644 index 58326502f2ee..000000000000 --- a/build/syms/GFX_symbols.txt +++ /dev/null @@ -1,107 +0,0 @@ -GP_Line -GP_Line_Raw -GP_LineAA -GP_LineAA_Raw -GP_LineClip - -GP_Line_Raw_4BPP_LE -GP_Line_Raw_2BPP_BE -GP_Line_Raw_32BPP -GP_Line_Raw_8BPP -GP_Line_Raw_2BPP_LE -GP_Line_Raw_16BPP -GP_Line_Raw_24BPP -GP_Line_Raw_18BPP_LE -GP_Line_Raw_1BPP_LE -GP_Line_Raw_4BPP_BE -GP_Line_Raw_1BPP_BE - -GP_HLineXYW_Raw -GP_HLine_Raw_8BPP -GP_HLineAA -GP_HLineXYW -GP_HLine_Raw_1BPP_LE -GP_HLine_Raw_4BPP_BE -GP_HLine_Raw_2BPP_BE -GP_HLine_Raw_24BPP -GP_HLine_Raw_32BPP -GP_HLineXXY -GP_HLine_Raw_4BPP_LE -GP_HLineXXY_Raw -GP_HLine_Raw_1BPP_BE -GP_HLine_Raw_2BPP_LE -GP_HLine_Raw_16BPP -GP_HLine_Raw_18BPP_LE -GP_HLineAA_Raw - -GP_VLineXYY_Raw -GP_VLineAA -GP_VLineAA_Raw -GP_VLineXYH_Raw -GP_VLineXYY -GP_VLineXYH -GP_VLine_Raw_16BPP -GP_VLine_Raw_1BPP_LE -GP_VLine_Raw_18BPP_LE -GP_VLine_Raw_2BPP_BE -GP_VLine_Raw_4BPP_BE -GP_VLine_Raw_8BPP -GP_VLine_Raw_2BPP_LE -GP_VLine_Raw_32BPP -GP_VLine_Raw_4BPP_LE -GP_VLine_Raw_24BPP -GP_VLine_Raw_1BPP_BE - -GP_Circle -GP_Circle_Raw -GP_FillCircle -GP_FillCircle_Raw - -GP_CircleSeg -GP_CircleSeg_Raw - -GP_Ring -GP_Ring_Raw -GP_FillRing_Raw -GP_FillRing - -GP_Ellipse -GP_Ellipse_Raw -GP_FillEllipse -GP_FillEllipse_Raw - -GP_RectXYXY -GP_RectXYXY_Raw -GP_RectXYWH -GP_RectXYWH_Raw -GP_FillRectXYXY -GP_FillRectXYXY_Raw -GP_FillRectXYWH -GP_FillRectXYWH_Raw - -GP_Triangle -GP_Triangle_Raw -GP_FillTriangle -GP_FillTriangle_Raw - -GP_Tetragon -GP_Tetragon_Raw -GP_FillTetragon -GP_FillTetragon_Raw - -GP_Polygon -GP_Polygon_Raw -GP_FillPolygon -GP_FillPolygon_Raw - -GP_Symbol -GP_Symbol_Raw -GP_FillSymbol -GP_FillSymbol_Raw - -GP_PutPixelAA -GP_PutPixelAA_Raw -GP_PutPixelAA_Raw_Clipped - -GP_ArcSegment -GP_ArcSegment_Raw diff --git a/build/syms/Grabbers_symbols.txt b/build/syms/Grabbers_symbols.txt deleted file mode 100644 index 1cf56e17cadc..000000000000 --- a/build/syms/Grabbers_symbols.txt +++ /dev/null @@ -1 +0,0 @@ -GP_GrabberV4L2Init diff --git a/build/syms/Input_symbols.txt b/build/syms/Input_symbols.txt deleted file mode 100644 index e6742b7f2fb8..000000000000 --- a/build/syms/Input_symbols.txt +++ /dev/null @@ -1,33 +0,0 @@ -GP_EventKeyName -GP_EventDump - -GP_InputDriverLinuxRead -GP_InputDriverLinuxOpen -GP_InputDriverLinuxClose -GP_InputDriverKBDEventPut - -GP_EventQueueSetCursorPosition -GP_EventQueueSetScreenSize -GP_EventQueueGet -GP_EventQueuePeek -GP_EventQueuePutBack -GP_EventQueueEventsQueued -GP_EventQueueInit -GP_EventQueueFree -GP_EventQueueAlloc - -GP_EventQueuePut -GP_EventQueuePutEvent -GP_EventQueuePushRelTo -GP_EventQueuePushRel -GP_EventQueuePushKey -GP_EventQueuePushAbs -GP_EventQueuePush -GP_EventQueuePushResize - -GP_TimerQueueDump -GP_TimerQueueProcess -GP_TimerQueueInsert -GP_TimerQueueRemove - -GP_GetTimeStamp diff --git a/build/syms/Loaders_symbols.txt b/build/syms/Loaders_symbols.txt deleted file mode 100644 index 5f8d7494cd3b..000000000000 --- a/build/syms/Loaders_symbols.txt +++ /dev/null @@ -1,165 +0,0 @@ - -GP_MatchJPG -GP_ReadJPG -GP_ReadJPGEx -GP_LoadJPG -GP_LoadJPGEx -GP_WriteJPG -GP_SaveJPG -GP_JPG - -GP_MatchPNG -GP_ReadPNG -GP_ReadPNGEx -GP_LoadPNG -GP_LoadPNGEx -GP_WritePNG -GP_SavePNG -GP_PNG - -GP_MatchBMP -GP_WriteBMP -GP_LoadBMP -GP_LoadBMPEx -GP_ReadBMP -GP_ReadBMPEx -GP_SaveBMP -GP_BMP - -GP_MatchPSP -GP_ReadPSP -GP_ReadPSPEx -GP_LoadPSP -GP_LoadPSPEx -GP_PSP - -GP_MatchGIF -GP_ReadGIF -GP_ReadGIFEx -GP_LoadGIF -GP_LoadGIFEx -GP_GIF - -GP_ReadTIFF -GP_LoadTIFF -GP_ReadTIFFEx -GP_LoadTIFFEx -GP_MatchTIFF -GP_WriteTIFF -GP_SaveTIFF -GP_TIFF - -GP_ReadPBM -GP_ReadPBMEx -GP_LoadPBM -GP_WritePBM -GP_SavePBM -GP_MatchPBM -GP_PBM - -GP_ReadPGM -GP_ReadPGMEx -GP_LoadPGM -GP_WritePGM -GP_SavePGM -GP_MatchPGM -GP_PGM - -GP_ReadPPM -GP_ReadPPMEx -GP_LoadPPM -GP_WritePPM -GP_SavePPM -GP_MatchPPM -GP_PPM - -GP_ReadPNM -GP_ReadPNMEx -GP_LoadPNM -GP_WritePNM -GP_SavePNM -GP_MatchPNM -GP_PNM - -GP_ReadJP2 -GP_LoadJP2 -GP_ReadJP2Ex -GP_LoadJP2Ex -GP_MatchJP2 -GP_JP2 - -GP_ReadPCX -GP_LoadPCX -GP_ReadPCXEx -GP_LoadPCXEx -GP_MatchPCX -GP_PCX - -GP_ReadPSD -GP_ReadPSDEx -GP_LoadPSD -GP_LoadPSDEx -GP_MatchPSD -GP_PSD - -GP_ReadExif - -GP_LoaderBySignature -GP_LoaderByFilename -GP_LoaderLoadImage -GP_LoaderLoadImageEx -GP_LoaderReadImage -GP_LoaderReadImageEx -GP_LoaderSaveImage -GP_ReadImage -GP_ReadImageEx -GP_LoadImage -GP_LoadImageEx -GP_LoadMetaData -GP_SaveImage -GP_ListLoaders -GP_LoaderRegister -GP_LoaderUnregister - -GP_ContainerLoad -GP_ContainerLoadEx -GP_ContainerSeek - -GP_MatchZip -GP_OpenZip - -GP_LineConvertible -GP_LineConvertGet - -GP_IOFile -GP_IOMem -GP_IOSubIO -GP_IOWBuffer -GP_IOMark -GP_IOSize -GP_IOFill -GP_IOFlush -GP_IOReadF -GP_IOReadB2 -GP_IOReadB4 -GP_IOWriteF -GP_IOPrintF - -GP_IOZlib -GP_IOZlibReset - -GP_DataStorageCreate -GP_DataStorageDestroy -GP_DataStorageClear -GP_DataStorageRoot -GP_DataDictFirst -GP_DataStorageGet -GP_DataStorageGetByPath -GP_DataStorageAdd -GP_DataStorageAddInt -GP_DataStorageAddDouble -GP_DataStorageAddString -GP_DataStorageAddRational -GP_DataStorageAddDict -GP_DataTypeName -GP_DataPrint diff --git a/build/syms/Text_symbols.txt b/build/syms/Text_symbols.txt deleted file mode 100644 index 83b1b2001b11..000000000000 --- a/build/syms/Text_symbols.txt +++ /dev/null @@ -1,33 +0,0 @@ -GP_FontFaceLoad -GP_FontFaceFree - -GP_Text_Raw -GP_TextAscent -GP_TextMaxStrWidth -GP_DefaultTextStyle -GP_GetGlyphCount -GP_GetGlyphBitmap -GP_TextClear -GP_TextMaxWidth -GP_TextHeight -GP_TextWidth -GP_TextLenWidth -GP_TextDescent -GP_TextClearStr -GP_Text -GP_Print -GP_VPrint - -GP_DefaultStyle - -GP_DefaultProportionalFont -GP_DefaultConsoleFont -GP_FontTiny -GP_FontTinyMono -GP_FontC64 -GP_FontHaxorNarrow15 -GP_FontHaxorNarrowBold15 -GP_FontHaxorNarrow16 -GP_FontHaxorNarrowBold16 -GP_FontHaxorNarrow17 -GP_FontHaxorNarrowBold17 diff --git a/build/syms/backend_symbols.txt b/build/syms/backend_symbols.txt new file mode 100644 index 000000000000..7e1426652e60 --- /dev/null +++ b/build/syms/backend_symbols.txt @@ -0,0 +1,19 @@ +gp_backend_rem_timer +gp_linux_fb_init +gp_input_driver_sdl_event_put +gp_backend_resize +gp_backend_poll_event +gp_backend_virt_init +gp_backend_init +gp_backend_poll +gp_backend_update_rect_xyxy +gp_backend_wait_event +gp_x11_fullscreen +gp_sdl_init +gp_backend_wait +gp_backend_add_timer +gp_x11_init +gp_backend_resize_ack +gp_pixmap_from_sdl_surface +gp_backend_is_x11 +gp_aalib_init diff --git a/build/syms/core_symbols.txt b/build/syms/core_symbols.txt new file mode 100644 index 000000000000..6defb418d0a4 --- /dev/null +++ b/build/syms/core_symbols.txt @@ -0,0 +1,309 @@ +gp_pixmap_convert +gp_font_tiny_mono +gp_sub_pixmap_alloc +gp_write_pixels_16BPP +gp_blit_xywh_clipped +gp_filter_min +gp_triangle_raw +gp_hline_raw_32BPP +gp_font_gfxprim +gp_pixel_addr_offset +gp_pixmap_alloc +gp_tetragon_raw +gp_set_debug_level +gp_filter_sepia_ex_alloc +gp_filter_max_alloc +gp_text_max_width_chars +gp_vline_raw_1BPP_BE +gp_fill_circle_seg +gp_vline_xyy_raw +gp_filter_max +gp_filter_resize +gp_event_queue_alloc +gp_circle_seg_raw +gp_filter_edge_sharpening_alloc +gp_filter_tables_alloc +gp_fill_circle +gp_filter_resize_linear_lf_int +gp_filter_edge_prewitt +gp_filter_brightness_contrast_ex_alloc +gp_pixmap_set_gamma +gp_pixel_has_flags +gp_vline_raw_18BPP_LE +gp_fill_circle_seg_raw +gp_hline_raw_24BPP +gp_filter_add_alloc +gp_get_glyph_count +gp_font_face_load +gp_vline_aa_raw +gp_pixmap_resize +gp_pixmap_rotate_cw +gp_filter_symmetry_by_name +gp_line_clip +gp_filter_multitone_ex +gp_line_raw_32BPP +gp_default_style +gp_timer_queue_process +gp_pixel_rgb_match +gp_ellipse_raw +gp_event_queue_init +gp_filter_laplace +gp_temp_alloc_ +gp_tetragon +gp_filter_gaussian_blur_ex +gp_hline_raw_16BPP +gp_gamma_copy +gp_line_raw_8BPP +gp_set_debug_handler +gp_get_debug_level +gp_line_raw_18BPP_LE +gp_font_face_free +gp_line_raw_2BPP_BE +gp_pixel_to_RGBA8888 +gp_filter_hilbert_peano_alloc +gp_filter_convolution_mp_raw +gp_filter_median_ex_alloc +gp_print +gp_line_raw_24BPP +gp_gamma_release +gp_hline_raw_1BPP_LE +gp_write_pixels_1BPP_LE +gp_text_raw +gp_filter_hlinear_convolution_raw +gp_filter_resize_nn +gp_filter_rotate_180_alloc +gp_event_queue_free +gp_filter_brightness_ex +gp_ring_raw +gp_histogram_free +gp_blit_xywh_raw +gp_filter_max_raw +gp_progress_cb_mp +gp_line_raw_4BPP_BE +gp_text_clear_str +gp_event_queue_get +gp_hline_xyw_raw +gp_filter_vconvolution_mp_raw +gp_pixmap_convert_alloc +gp_fill_ellipse_raw +gp_filter_diff_raw +gp_line_aa_raw +gp_filter_linear_convolution_raw +gp_filter_resize_alloc +gp_filter_brightness_contrast_ex +gp_vline_raw_1BPP_LE +gp_filter_symmetry_names +gp_line_raw_16BPP +gp_text_clear +gp_filter_mul_raw +gp_event_dump +gp_pixel_snprint +gp_filter_weighted_median_ex_alloc +gp_putpixel +_edata +gp_cubic_table +gp_vline_aa +gp_circle +gp_fill_triangle_raw +gp_rect_xywh_raw +gp_filter_resize_cubic +gp_filter_diff +gp_text_descent +gp_fill_tetragon_raw +gp_font_haxor_narrow_15 +gp_font_haxor_narrow_16 +gp_event_queue_push_resize +gp_font_haxor_narrow_17 +gp_event_queue_push_rel +gp_filter_tables_init +gp_text_width_len +gp_filter_mirror_v_alloc +gp_hline_aa +gp_putpixel_aa +gp_filter_contrast_ex_alloc +gp_line_raw +gp_filter_edge_sharpening +gp_blit_xyxy_raw_fast +gp_default_font +gp_pixmap_rotate_ccw +gp_fill_polygon +gp_filter_min_raw +gp_temp_alloc_save +gp_vline_raw_8BPP +gp_fill_tetragon +gp_event_queue_push_key +gp_circle_seg +gp_putpixel_aa_raw_clipped +gp_vline_xyh +gp_arc_segment +gp_filter_tables_free +gp_filter_convolution_ex_alloc +gp_pixel_print +gp_line_aa +gp_RGBA8888_to_pixel +gp_filter_mirror_v_raw +gp_line_raw_2BPP_LE +gp_hline_aa_raw +gp_print_abort_info +gp_fill_circle_raw +gp_font_c64 +gp_triangle +gp_get_glyph +gp_filter_laplace_alloc +gp_debug_print_cstack +gp_fill_ellipse +gp_fill_ring_raw +gp_vline_xyy +gp_debug_print +gp_pixmap_init +gp_filter_mul +gp_filter_rotate_270_alloc +gp_rect_xywh +gp_line_raw_4BPP_LE +gp_blit_xyxy_raw +gp_filter_gaussian_noise_add_ex_alloc +gp_input_driver_linux_read +gp_filter_mirror_h_alloc +gp_gamma_print +gp_write_pixels_8BPP +gp_interpolation_type_name +gp_event_queue_put +gp_pixel_to_RGB888 +gp_filter_weighted_median_ex +gp_event_key_name +gp_vline_xyh_raw +gp_event_queue_put_back +gp_filter_symmetry +gp_filter_gaussian_noise_add_ex +gp_write_pixels_2BPP_BE +gp_hline_raw_2BPP_BE +gp_filter_rotate_90 +gp_pixmap_free +gp_fill_triangle +gp_filter_posterize_ex_alloc +gp_nr_threads +gp_filter_contrast_ex +gp_rect_xyxy_raw +gp_filter_rotate_90_alloc +gp_polygon +gp_line_raw_1BPP_BE +gp_filter_floyd_steinberg_alloc +gp_text_max_width +gp_pixmap_equal +gp_gamma_acquire +gp_event_queue_push_abs +gp_pixel_types +gp_getpixel +gp_pixmap_print_info +gp_event_queue_set_screen_size +gp_filter_rotate_180 +gp_filter_hilbert_peano +gp_hline_raw_4BPP_BE +gp_norm_int +gp_write_pixels_4BPP_BE +gp_filter_rotate_270 +gp_vline_raw_2BPP_BE +gp_vprint +gp_fill_rect_xywh_raw +gp_filter_add +gp_filter_convolution_ex +gp_ellipse +gp_filter_median_ex +gp_putpixel_aa_raw +gp_temp_allocRestore +gp_filter_invert_ex +gp_input_driver_linux_open +gp_pixmap_copy +gp_fill_ring +gp_text_width +gp_vline_raw_32BPP +gp_blit_xywh +gp_rect_xyxy +gp_vline_raw_4BPP_BE +gp_timer_queue_insert +gp_blit_xyxy_clipped +gp_event_queue_set_cursor_pos +gp_event_queue_events_queued +gp_event_queue_push_rel_to +gp_fill_rect_xywh +gp_filter_vlinear_convolution_raw +gp_filter_floyd_steinberg +gp_filter_sepia_ex +gp_text_height +gp_hline_xxy +gp_filter_symmetry_alloc +gp_time_stamp +gp_polygon_raw +gp_vline_raw_24BPP +gp_gamma8_linear10 +gp_sub_pixmap +gp_filter_mul_alloc +gp_hline_raw_8BPP +gp_filter_brightness_ex_alloc +gp_filter_resize_cubic_int +gp_filter_mirror_h +gp_histogram_alloc +gp_hline_raw_2BPP_LE +gp_histogram_channel_by_name +gp_write_pixels_2BPP_LE +gp_arc_segment_raw +gp_ring +gp_input_driver_linux_close +gp_filter_gaussian_noise_add_raw +gp_filter_add_raw +gp_input_driver_kbd_event_put +gp_circle_raw +gp_timer_queue_remove +gp_filter_sigma_ex +gp_hline_raw_18BPP_LE +gp_filter_min_alloc +gp_write_pixels_32BPP +gp_event_queue_push +gp_line_raw_1BPP_LE +gp_text +gp_event_queue_peek +gp_vline_raw_16BPP +gp_filter_multitone_ex_alloc +gp_hline_xyw +gp_font_gfxprim_mono +gp_filter_mirror_v +gp_linear10_gamma8 +gp_font_tiny +gp_write_pixels_4BPP_LE +gp_hline_raw_4BPP_LE +gp_fill +gp_filter_gaussian_blur_ex_alloc +gp_blit_xyxy +gp_filter_diff_alloc +gp_vline_raw_2BPP_LE +gp_fill_polygon_raw +gp_blit_xyxy_fast +gp_filter_tables_apply +gp_hline_xxy_raw +gp_filter_gaussian_blur_raw +gp_RGB888_to_pixel +gp_filter_posterize_ex +gp_fill_rect_xyxy_raw +gp_fill_rect_xyxy +gp_pixel_type_by_name +gp_pixel_rgb_lookup +gp_filter_edge_sobel +gp_write_pixels_24BPP +gp_text_ascent +gp_timer_queue_dump +gp_filter_sigma_ex_alloc +gp_filter_kernel_print_raw +gp_vline_raw_4BPP_LE +gp_nr_threads_set +gp_temp_allocDestroy +gp_filter_vhlinear_convolution_raw +gp_filter_histogram +gp_line +gp_font_haxor_narrow_bold_15 +gp_hline_raw_1BPP_BE +gp_write_pixels_1BPP_BE +gp_font_haxor_narrow_bold_16 +gp_filter_resize_linear_int +gp_font_haxor_narrow_bold_17 +gp_filter_invert_ex_alloc +gp_filter_hconvolution_mp_raw diff --git a/build/syms/filters_symbols.txt b/build/syms/filters_symbols.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/build/syms/gfx_symbols.txt b/build/syms/gfx_symbols.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/build/syms/grabbers_symbols.txt b/build/syms/grabbers_symbols.txt new file mode 100644 index 000000000000..2b12d1ce49a9 --- /dev/null +++ b/build/syms/grabbers_symbols.txt @@ -0,0 +1 @@ +gp_grabber_v4l2_init diff --git a/build/syms/input_symbols.txt b/build/syms/input_symbols.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/build/syms/loaders_symbols.txt b/build/syms/loaders_symbols.txt new file mode 100644 index 000000000000..f88e147edb75 --- /dev/null +++ b/build/syms/loaders_symbols.txt @@ -0,0 +1,100 @@ +gp_save_image +gp_loader_register +gp_io_mem +gp_match_gif +gp_io_wbuffer +gp_load_image +gp_line_convertible +gp_pbm +gp_read_psp_ex +gp_loader_read_image +gp_loader_read_image_ex +gp_match_jpg +gp_png +gp_loader_by_filename +gp_read_jp2_ex +gp_read_pcx_ex +gp_data_type_name +gp_write_pbm +gp_line_convert_get +gp_loader_unregister +gp_data_print +gp_write_png +gp_pnm +gp_storage_add_dict +gp_loader_save_image +gp_io_writef +gp_load_image_ex +gp_container_load_ex +gp_match_pcx +gp_write_pnm +gp_io_zlib +gp_storage_root +gp_tiff +gp_read_psd_ex +gp_storage_add_int +gp_io_printf +gp_match_tiff +gp_gif +gp_loader_by_signature +gp_match_bmp +gp_storage_destroy +gp_load_meta_data +gp_storage_get_by_path +gp_read_gif_ex +gp_jpg +gp_match_zip +gp_match_psd +gp_storage_create +gp_match_pgm +gp_write_jpg +gp_io_read_b2 +gp_open_zip +gp_write_tiff +gp_io_read_b4 +gp_storage_clear +gp_match_ppm +gp_pcx +gp_match_jp2 +gp_match_psp +gp_io_mark +gp_read_image_ex +gp_read_ppm_ex +gp_storage_add_string +gp_loader_load_image_ex +gp_read_exif +gp_read_pnm_ex +gp_bmp +gp_storage_add_rational +gp_io_readf +gp_storage_get +gp_read_tiff_ex +gp_write_bmp +gp_read_pgm_ex +gp_match_pbm +gp_psd +gp_read_png_ex +gp_match_png +gp_pgm +gp_read_jpg_ex +gp_read_pbm_ex +gp_io_sub_io +gp_data_dict_first +gp_write_pgm +gp_io_zlib_reset +gp_storage_add +gp_loaders_lists +gp_match_pnm +gp_ppm +gp_jp2 +gp_io_flush +gp_loader_load_image +gp_psp +gp_write_ppm +gp_io_file +gp_read_bmp_ex +gp_read_image +gp_container_seek +gp_io_size +gp_storage_add_double +gp_io_fill diff --git a/build/syms/text_symbols.txt b/build/syms/text_symbols.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/demos/bogoman/bogoman.c b/demos/bogoman/bogoman.c index cd0def6c3a67..f0a9d029c426 100644 --- a/demos/bogoman/bogoman.c +++ b/demos/bogoman/bogoman.c @@ -20,7 +20,7 @@ * * *****************************************************************************/ -#include <GP.h> +#include <gfxprim.h> #include "bogoman_debug.h" #include "bogoman_map.h" @@ -32,13 +32,13 @@ static void save_png(struct bogoman_map *map, unsigned int elem_size, const char *filename) { - GP_Pixmap *pixmap; + gp_pixmap *pixmap; unsigned int rx, ry; rx = elem_size * map->w; ry = elem_size * map->h; - pixmap = GP_PixmapAlloc(rx, ry, GP_PIXEL_RGB888); + pixmap = gp_pixmap_alloc(rx, ry, GP_PIXEL_RGB888); if (pixmap == NULL) return; @@ -53,22 +53,22 @@ static void save_png(struct bogoman_map *map, unsigned int elem_size, bogoman_render(&render, BOGOMAN_RENDER_ALL); - GP_SavePNG(pixmap, filename, NULL); - GP_PixmapFree(pixmap); + gp_save_png(pixmap, filename, NULL); + gp_pixmap_free(pixmap); } -static struct GP_Backend *backend; +static struct gp_backend *backend; -static void event_loop(struct bogoman_render *render, GP_Backend *backend) +static void event_loop(struct bogoman_render *render, gp_backend *backend) { struct bogoman_map *map = render->map; char path[128]; static int screenshots; - while (GP_BackendEventsQueued(backend)) { - GP_Event ev; + while (gp_backend_events_queued(backend)) { + gp_event ev; - GP_BackendGetEvent(backend, &ev); + gp_backend_get_event(backend, &ev); switch (ev.type) { case GP_EV_KEY: @@ -77,7 +77,7 @@ static void event_loop(struct bogoman_render *render, GP_Backend *backend) switch (ev.val.val) { case GP_KEY_ESC: - GP_BackendExit(backend); + gp_backend_exit(backend); exit(0); break; case GP_KEY_RIGHT: @@ -103,7 +103,7 @@ static void event_loop(struct bogoman_render *render, GP_Backend *backend) case GP_EV_SYS: switch (ev.code) { case GP_EV_SYS_RESIZE: - GP_BackendResizeAck(backend); + gp_backend_resize_ack(backend); bogoman_render(render, BOGOMAN_RENDER_ALL); break; } @@ -140,7 +140,7 @@ int main(int argc, char *argv[]) unsigned int cw = map->w * ELEM_SIZE; unsigned int ch = map->h * ELEM_SIZE; - backend = GP_BackendX11Init(NULL, 0, 0, cw, ch, "Bogoman", 0); + backend = gp_x11_init(NULL, 0, 0, cw, ch, "Bogoman", 0); if (backend == NULL) { fprintf(stderr, "Failed to initialize backend"); @@ -158,10 +158,10 @@ int main(int argc, char *argv[]) bogoman_render(&render, BOGOMAN_RENDER_ALL); - GP_BackendAddTimer(backend, &timer); + gp_backend_add_timer(backend, &timer); for (;;) { - GP_BackendWait(backend); + gp_backend_wait(backend); event_loop(&render, backend); } diff --git a/demos/bogoman/bogoman_render.c b/demos/bogoman/bogoman_render.c index c045b541935b..f23d3bc7284e 100644 --- a/demos/bogoman/bogoman_render.c +++ b/demos/bogoman/bogoman_render.c @@ -20,7 +20,7 @@ * * *****************************************************************************/ -#include <GP.h> +#include <gfxprim.h> #include "bogoman_map.h" #include "bogoman_debug.h" @@ -29,44 +29,44 @@ struct render_colors { /* global background */ - GP_Pixel bg; + gp_pixel bg; /* player color */ - GP_Pixel player; + gp_pixel player; /* frames around things */ - GP_Pixel frames; + gp_pixel frames; /* diamod color */ - GP_Pixel diamond; + gp_pixel diamond; /* wall color */ - GP_Pixel wall; + gp_pixel wall; /* moveable color */ - GP_Pixel moveable; + gp_pixel moveable; /* edible color */ - GP_Pixel edible; + gp_pixel edible; /* particle colors */ - GP_Pixel particle; - GP_Pixel particle_dir; + gp_pixel particle; + gp_pixel particle_dir; }; static struct render_colors colors; -static void init_colors(GP_Pixmap *pixmap, struct render_colors *colors) +static void init_colors(gp_pixmap *pixmap, struct render_colors *colors) { - colors->bg = GP_RGBToPixmapPixel(0xee, 0xee, 0xee, pixmap); - colors->player = GP_RGBToPixmapPixel(0x00, 0xee, 0x00, pixmap); - colors->frames = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); - colors->diamond = GP_RGBToPixmapPixel(0x00, 0x00, 0xee, pixmap); - colors->wall = GP_RGBToPixmapPixel(0x66, 0x66, 0x66, pixmap); - colors->moveable = GP_RGBToPixmapPixel(0xff, 0xff, 0x60, pixmap); - colors->edible = GP_RGBToPixmapPixel(0xff, 0x7f, 0x50, pixmap); - colors->particle = GP_RGBToPixmapPixel(0xff, 0xff, 0x00, pixmap); - colors->particle_dir = GP_RGBToPixmapPixel(0xff, 0x44, 0x00, pixmap); + colors->bg = gp_rgb_to_pixmap_pixel(0xee, 0xee, 0xee, pixmap); + colors->player = gp_rgb_to_pixmap_pixel(0x00, 0xee, 0x00, pixmap); + colors->frames = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, pixmap); + colors->diamond = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0xee, pixmap); + colors->wall = gp_rgb_to_pixmap_pixel(0x66, 0x66, 0x66, pixmap); + colors->moveable = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0x60, pixmap); + colors->edible = gp_rgb_to_pixmap_pixel(0xff, 0x7f, 0x50, pixmap); + colors->particle = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0x00, pixmap); + colors->particle_dir = gp_rgb_to_pixmap_pixel(0xff, 0x44, 0x00, pixmap); } static void render_none(struct bogoman_render *render, @@ -77,7 +77,7 @@ static void render_none(struct bogoman_render *render, (void) elem; - GP_FillRectXYWH(render->pixmap, x, y, w, w, colors.bg); + gp_fill_rect_xywh(render->pixmap, x, y, w, w, colors.bg); } static void render_player(struct bogoman_render *render, @@ -88,10 +88,10 @@ static void render_player(struct bogoman_render *render, (void) elem; - GP_FillRectXYWH(render->pixmap, x, y, w, w, colors.bg); + gp_fill_rect_xywh(render->pixmap, x, y, w, w, colors.bg); - GP_FillCircle(render->pixmap, x + w/2, y + w/2, w/2 - 1, colors.player); - GP_FillRing(render->pixmap, x + w/2, y + w/2, w/2 - 1, w/2 - 2, colors.frames); + gp_fill_circle(render->pixmap, x + w/2, y + w/2, w/2 - 1, colors.player); + gp_fill_ring(render->pixmap, x + w/2, y + w/2, w/2 - 1, w/2 - 2, colors.frames); } static void render_wall(struct bogoman_render *render, @@ -100,26 +100,26 @@ static void render_wall(struct bogoman_render *render, { unsigned int w = render->map_elem_size; - GP_FillRectXYWH(render->pixmap, x, y, w, w, colors.wall); + gp_fill_rect_xywh(render->pixmap, x, y, w, w, colors.wall); if (!(elem->flags & BOGOMAN_LEFT)) { - GP_VLineXYH(render->pixmap, x, y, w, colors.frames); - GP_VLineXYH(render->pixmap, x+1, y, w, colors.frames); + gp_vline_xyh(render->pixmap, x, y, w, colors.frames); + gp_vline_xyh(render->pixmap, x+1, y, w, colors.frames); } if (!(elem->flags & BOGOMAN_RIGHT)) { - GP_VLineXYH(render->pixmap, x + w - 1, y, w, colors.frames); - GP_VLineXYH(render->pixmap, x + w - 2, y, w, colors.frames); + gp_vline_xyh(render->pixmap, x + w - 1, y, w, colors.frames); + gp_vline_xyh(render->pixmap, x + w - 2, y, w, colors.frames); } if (!(elem->flags & BOGOMAN_UP)) { - GP_HLineXYW(render->pixmap, x, y, w, colors.frames); - GP_HLineXYW(render->pixmap, x, y+1, w, colors.frames); + gp_hline_xyw(render->pixmap, x, y, w, colors.frames); + gp_hline_xyw(render->pixmap, x, y+1, w, colors.frames); } if (!(elem->flags & BOGOMAN_DOWN)) { - GP_HLineXYW(render->pixmap, x, y + w - 1, w, colors.frames); - GP_HLineXYW(render->pixmap, x, y + w - 2, w, colors.frames); + gp_hline_xyw(render->pixmap, x, y + w - 1, w, colors.frames); + gp_hline_xyw(render->pixmap, x, y + w - 2, w, colors.frames); } } @@ -129,16 +129,16 @@ static void render_diamond(struct bogoman_render *render, { unsigned int w = render->map_elem_size; - GP_FillRectXYWH(render->pixmap, x, y, w, w, colors.bg); + gp_fill_rect_xywh(render->pixmap, x, y, w, w, colors.bg); (void) elem; - GP_FillTetragon(render->pixmap, x + w/2, y, x + w - 1, y + w/2, + gp_fill_tetragon(render->pixmap, x + w/2, y, x + w - 1, y + w/2, x + w/2, y + w - 1, x, y + w/2, colors.diamond); - GP_Tetragon(render->pixmap, x + w/2, y, x + w - 1, y + w/2, + gp_tetragon(render->pixmap, x + w/2, y, x + w - 1, y + w/2, x + w/2, y + w - 1, x, y + w/2, colors.frames); - GP_Tetragon(render->pixmap, x + w/2, y+1, x + w - 2, y + w/2, + gp_tetragon(render->pixmap, x + w/2, y+1, x + w - 2, y + w/2, x + w/2, y + w - 2, x+1, y + w/2, colors.frames); } @@ -150,11 +150,11 @@ static void render_moveable(struct bogoman_render *render, (void) elem; - GP_FillRectXYWH(render->pixmap, x, y, w, w, colors.bg); + gp_fill_rect_xywh(render->pixmap, x, y, w, w, colors.bg); - GP_FillRectXYWH(render->pixmap, x + 1, y + 1, w - 2, w - 2, colors.moveable); - GP_RectXYWH(render->pixmap, x + 1, y + 1, w - 2, w - 2, colors.frames); - GP_RectXYWH(render->pixmap, x + 2, y + 2, w - 4, w - 4, colors.frames); + gp_fill_rect_xywh(render->pixmap, x + 1, y + 1, w - 2, w - 2, colors.moveable); + gp_rect_xywh(render->pixmap, x + 1, y + 1, w - 2, w - 2, colors.frames); + gp_rect_xywh(render->pixmap, x + 2, y + 2, w - 4, w - 4, colors.frames); } static void render_edible(struct bogoman_render *render, @@ -165,9 +165,9 @@ static void render_edible(struct bogoman_render *render, (void) elem; - GP_FillRectXYWH(render->pixmap, x, y, w, w, colors.bg); + gp_fill_rect_xywh(render->pixmap, x, y, w, w, colors.bg); - GP_FillRectXYWH(render->pixmap, x + 1, y + 1, w - 2, w - 2, colors.edible); + gp_fill_rect_xywh(render->pixmap, x + 1, y + 1, w - 2, w - 2, colors.edible); } static void render_particle(struct bogoman_render *render, @@ -177,43 +177,43 @@ static void render_particle(struct bogoman_render *render, unsigned int w = render->map_elem_size; int dir = elem->flags & BOGOMAN_DIRECTION_MASK; - GP_FillRectXYWH(render->pixmap, x, y, w, w, colors.bg); + gp_fill_rect_xywh(render->pixmap, x, y, w, w, colors.bg); switch (elem->flags & ~BOGOMAN_DIRECTION_MASK) { case BOGOMAN_PARTICLE_ROUND: - GP_FillCircle(render->pixmap, x + w/2, y + w/2, w/2-1, colors.particle); - GP_FillRing(render->pixmap, x + w/2, y + w/2, w/2 - 1, w/2 - 2, colors.frames); + gp_fill_circle(render->pixmap, x + w/2, y + w/2, w/2-1, colors.particle); + gp_fill_ring(render->pixmap, x + w/2, y + w/2, w/2 - 1, w/2 - 2, colors.frames); break; case BOGOMAN_PARTICLE_SQUARE: - GP_FillRectXYWH(render->pixmap, x+1, y+1, w-2, w-2, colors.particle); - GP_RectXYWH(render->pixmap, x+1, y+1, w-2, w-2, colors.frames); - GP_RectXYWH(render->pixmap, x+2, y+2, w-4, w-4, colors.frames); + gp_fill_rect_xywh(render->pixmap, x+1, y+1, w-2, w-2, colors.particle); + gp_rect_xywh(render->pixmap, x+1, y+1, w-2, w-2, colors.frames); + gp_rect_xywh(render->pixmap, x+2, y+2, w-4, w-4, colors.frames); break; } switch (dir) { case BOGOMAN_LEFT: - GP_FillTriangle(render->pixmap, x + w/4, y + w/2, + gp_fill_triangle(render->pixmap, x + w/4, y + w/2, x + 5*w/8, y + w/4, x + 5*w/8, y + 3*w/4, colors.particle_dir); - GP_Triangle(render->pixmap, x + w/4, y + w/2, + gp_triangle(render->pixmap, x + w/4, y + w/2, x + 5*w/8, y + w/4, x + 5*w/8, y + 3*w/4, colors.frames); break; case BOGOMAN_RIGHT: - GP_FillTriangle(render->pixmap, x + 3*w/4, y + w/2, + gp_fill_triangle(render->pixmap, x + 3*w/4, y + w/2, x + 3*w/8, y + w/4, x + 3*w/8, y + 3*w/4, colors.particle_dir); - GP_Triangle(render->pixmap, x + 3*w/4, y + w/2, + gp_triangle(render->pixmap, x + 3*w/4, y + w/2, x + 3*w/8, y + w/4, x + 3*w/8, y + 3*w/4, colors.frames); break; case BOGOMAN_UP: - GP_FillTriangle(render->pixmap, x + w/2, y + w/4, + gp_fill_triangle(render->pixmap, x + w/2, y + w/4, x + w/4, y + 5*w/8, x + 3*w/4, y + 5*w/8, colors.particle_dir); - GP_Triangle(render->pixmap, x + w/2, y + w/4, + gp_triangle(render->pixmap, x + w/2, y + w/4, x + w/4, y + 5*w/8, x + 3*w/4, y + 5*w/8, colors.frames); break; case BOGOMAN_DOWN: - GP_FillTriangle(render->pixmap, x + w/2, y + 3*w/4, + gp_fill_triangle(render->pixmap, x + w/2, y + 3*w/4, x + w/4, y + 3*w/8, x + 3*w/4, y + 3*w/8, colors.particle_dir); - GP_Triangle(render->pixmap, x + w/2, y + 3*w/4, + gp_triangle(render->pixmap, x + w/2, y + 3*w/4, x + w/4, y + 3*w/8, x + 3*w/4, y + 3*w/8, colors.frames); break; } @@ -257,7 +257,7 @@ static void render_elem(struct bogoman_render *render, renders[elem->id](render, cx, cy, elem); if (flags & BOGOMAN_RENDER_DIRTY && render->backend) { - GP_BackendUpdateRect(render->backend, cx, cy, + gp_backend_update_rect(render->backend, cx, cy, cx + render->map_elem_size, cy + render->map_elem_size); } @@ -271,7 +271,7 @@ void bogoman_render(struct bogoman_render *render, int flags) init_colors(render->pixmap, &colors); if (flags & BOGOMAN_RENDER_ALL) - GP_Fill(render->pixmap, colors.bg); + gp_fill(render->pixmap, colors.bg); for (y = render->map_x_offset; y < render->map->h; y++) { for (x = render->map_x_offset; x < render->map->w; x++) @@ -279,5 +279,5 @@ void bogoman_render(struct bogoman_render *render, int flags) } if (flags & BOGOMAN_RENDER_ALL && render->backend) - GP_BackendFlip(render->backend); + gp_backend_flip(render->backend); } diff --git a/demos/bogoman/bogoman_render.h b/demos/bogoman/bogoman_render.h index 38b7f0d59722..747437fc82f0 100644 --- a/demos/bogoman/bogoman_render.h +++ b/demos/bogoman/bogoman_render.h @@ -24,7 +24,6 @@ #define __BOGOMAN_RENDER_H__ struct bogoman_map; -struct GP_Pixmap; struct bogoman_render { /* both in map elements */ @@ -35,10 +34,10 @@ struct bogoman_render { struct bogoman_map *map; /* pixmap to be used for rendering */ - struct GP_Pixmap *pixmap; + struct gp_pixmap *pixmap; /* if not NULL is used to update screen */ - struct GP_Backend *backend; + struct gp_backend *backend; /* elem size in pixels */ unsigned int map_elem_size; diff --git a/demos/c_simple/SDL_glue.c b/demos/c_simple/SDL_glue.c index ef360e0b0e84..447598e7d8d0 100644 --- a/demos/c_simple/SDL_glue.c +++ b/demos/c_simple/SDL_glue.c @@ -32,28 +32,28 @@ #include <stdio.h> #include <stdlib.h> #include <SDL/SDL.h> -#include <GP.h> +#include <gfxprim.h> #include <backends/GP_SDL_Pixmap.h> #define W 320 #define H 240 static SDL_Surface *display = NULL; -static GP_Pixmap pixmap; +static gp_pixmap pixmap; -static GP_Pixel black_pixel, darkgray_pixel; +static gp_pixel black_pixel, darkgray_pixel; void redraw_screen(void) { SDL_LockSurface(display); - GP_Fill(&pixmap, black_pixel); + gp_fill(&pixmap, black_pixel); - GP_Text(&pixmap, NULL, W/2, 20, GP_ALIGN_CENTER | GP_VALIGN_BELOW, + gp_text(&pixmap, NULL, W/2, 20, GP_ALIGN_CENTER | GP_VALIGN_BELOW, darkgray_pixel, black_pixel, "GFXprim SDL Demo"); - GP_Line(&pixmap, 0, 0, W-1, H-1, darkgray_pixel); - GP_Line(&pixmap, 0, H-1, W-1, 0, darkgray_pixel); + gp_line(&pixmap, 0, 0, W-1, H-1, darkgray_pixel); + gp_line(&pixmap, 0, H-1, W-1, 0, darkgray_pixel); SDL_UnlockSurface(display); } @@ -100,10 +100,10 @@ int main(void) return 1; } - GP_PixmapFromSDLSurface(&pixmap, display); + gp_pixmap_from_sdl_surface(&pixmap, display); - black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, &pixmap); - darkgray_pixel = GP_RGBToPixmapPixel(0x7f, 0x7f, 0x7f, &pixmap); + black_pixel = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, &pixmap); + darkgray_pixel = gp_rgb_to_pixmap_pixel(0x7f, 0x7f, 0x7f, &pixmap); redraw_screen(); SDL_Flip(display); diff --git a/demos/c_simple/backend_example.c b/demos/c_simple/backend_example.c index 6c8288347871..65f22dbf90d9 100644 --- a/demos/c_simple/backend_example.c +++ b/demos/c_simple/backend_example.c @@ -27,27 +27,27 @@ */ #include <stdio.h> -#include <GP.h> +#include <gfxprim.h> -static void redraw(GP_Backend *self) +static void redraw(gp_backend *self) { - GP_Pixmap *pixmap = self->pixmap; - GP_Pixel white_pixel, black_pixel; + gp_pixmap *pixmap = self->pixmap; + gp_pixel white_pixel, black_pixel; - black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); - white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, pixmap); + black_pixel = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, pixmap); + white_pixel = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0xff, pixmap); - GP_Fill(pixmap, black_pixel); - GP_Line(pixmap, 0, 0, pixmap->w - 1, pixmap->h - 1, white_pixel); - GP_Line(pixmap, 0, pixmap->h - 1, pixmap->w - 1, 0, white_pixel); + gp_fill(pixmap, black_pixel); + gp_line(pixmap, 0, 0, pixmap->w - 1, pixmap->h - 1, white_pixel); + gp_line(pixmap, 0, pixmap->h - 1, pixmap->w - 1, 0, white_pixel); /* Update the backend screen */ - GP_BackendFlip(self); + gp_backend_flip(self); } int main(int argc, char *argv[]) { - GP_Backend *backend; + gp_backend *backend; const char *backend_opts = "X11:100x100"; int opt; @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) backend_opts = optarg; break; case 'h': - GP_BackendInit(NULL, NULL); + gp_backend_init(NULL, NULL); return 0; break; default: @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) } } - backend = GP_BackendInit(backend_opts, "Backend Example"); + backend = gp_backend_init(backend_opts, "Backend Example"); if (backend == NULL) { fprintf(stderr, "Failed to initialize backend\n"); @@ -77,18 +77,18 @@ int main(int argc, char *argv[]) /* Handle events */ for (;;) { - GP_Event ev; + gp_event ev; - GP_BackendWaitEvent(backend, &ev); + gp_backend_wait_event(backend, &ev); - GP_EventDump(&ev); + gp_event_dump(&ev); switch (ev.type) { case GP_EV_KEY: switch (ev.val.val) { case GP_KEY_ESC: case GP_KEY_Q: - GP_BackendExit(backend); + gp_backend_exit(backend); return 0; break; } @@ -96,11 +96,11 @@ int main(int argc, char *argv[]) case GP_EV_SYS: switch (ev.code) { case GP_EV_SYS_RESIZE: - GP_BackendResizeAck(backend); + gp_backend_resize_ack(backend); redraw(backend); break; case GP_EV_SYS_QUIT: - GP_BackendExit(backend); + gp_backend_exit(backend); return 0; break; } @@ -108,7 +108,7 @@ int main(int argc, char *argv[]) } } - GP_BackendExit(backend); + gp_backend_exit(backend); return 0; } diff --git a/demos/c_simple/backend_timers_example.c b/demos/c_simple/backend_timers_example.c index 16912fb592df..3b9282f2cc66 100644 --- a/demos/c_simple/backend_timers_example.c +++ b/demos/c_simple/backend_timers_example.c @@ -27,20 +27,20 @@ */ #include <stdio.h> -#include <GP.h> +#include <gfxprim.h> -static void redraw(GP_Backend *self) +static void redraw(gp_backend *self) { - GP_Pixmap *pixmap = self->pixmap; - GP_Pixel black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); + gp_pixmap *pixmap = self->pixmap; + gp_pixel black_pixel = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, pixmap); - GP_Fill(pixmap, black_pixel); + gp_fill(pixmap, black_pixel); /* Update the backend screen */ - GP_BackendFlip(self); + gp_backend_flip(self); } -static uint32_t timer_callback(GP_Timer *self) +static uint32_t timer_callback(gp_timer *self) { uint32_t next = random() % 10000; @@ -52,10 +52,10 @@ static uint32_t timer_callback(GP_Timer *self) int main(void) { - GP_Backend *backend; + gp_backend *backend; const char *backend_opts = "X11:100x100"; - backend = GP_BackendInit(backend_opts, "Backend Timers Example"); + backend = gp_backend_init(backend_opts, "Backend Timers Example"); if (backend == NULL) { fprintf(stderr, "Failed to initialize backend\n"); @@ -76,23 +76,23 @@ int main(void) */ GP_TIMER_DECLARE(timer2, 5000, 0, "Timer 2", timer_callback, NULL); - GP_BackendAddTimer(backend, &timer1); - GP_BackendAddTimer(backend, &timer2); + gp_backend_add_timer(backend, &timer1); + gp_backend_add_timer(backend, &timer2); /* Handle events */ for (;;) { - GP_Event ev; + gp_event ev; - GP_BackendWaitEvent(backend, &ev); + gp_backend_wait_event(backend, &ev); - GP_EventDump(&ev); + gp_event_dump(&ev); switch (ev.type) { case GP_EV_KEY: switch (ev.val.val) { case GP_KEY_ESC: case GP_KEY_Q: - GP_BackendExit(backend); + gp_backend_exit(backend); return 0; break; } @@ -100,11 +100,11 @@ int main(void) case GP_EV_SYS: switch (ev.code) { case GP_EV_SYS_RESIZE: - GP_BackendResizeAck(backend); + gp_backend_resize_ack(backend); redraw(backend); break; case GP_EV_SYS_QUIT: - GP_BackendExit(backend); + gp_backend_exit(backend); return 0; break; } @@ -112,7 +112,7 @@ int main(void) } } - GP_BackendExit(backend); + gp_backend_exit(backend); return 0; } diff --git a/demos/c_simple/blittest.c b/demos/c_simple/blittest.c index c12c8fe70b35..cc134d4704cd 100644 --- a/demos/c_simple/blittest.c +++ b/demos/c_simple/blittest.c @@ -24,14 +24,14 @@ *****************************************************************************/ #include <stdio.h> -#include <GP.h> +#include <gfxprim.h> -static GP_Pixel black; -static GP_Pixel white; +static gp_pixel black; +static gp_pixel white; -static GP_Backend *win; +static gp_backend *win; -static GP_Pixmap *bitmap, *bitmap_raw, *bitmap_conv; +static gp_pixmap *bitmap, *bitmap_raw, *bitmap_conv; static int bitmap_x, bitmap_y, bitmap_vx = -3, bitmap_vy = -3; static int pause_flag = 0; @@ -42,7 +42,7 @@ void redraw_screen(void) bitmap_x += bitmap_vx; bitmap_y += bitmap_vy; - if (bitmap_x + GP_PixmapW(bitmap) > win->pixmap->w) { + if (bitmap_x + gp_pixmap_w(bitmap) > win->pixmap->w) { bitmap_vx = -bitmap_vx; bitmap_x += bitmap_vx; } @@ -52,7 +52,7 @@ void redraw_screen(void) bitmap_x += bitmap_vx; } - if (bitmap_y + GP_PixmapH(bitmap) > win->pixmap->h) { + if (bitmap_y + gp_pixmap_h(bitmap) > win->pixmap->h) { bitmap_vy = -bitmap_vy; bitmap_y += bitmap_vy; } @@ -62,21 +62,21 @@ void redraw_screen(void) bitmap_y += bitmap_vy; } - GP_FillRectXYWH(win->pixmap, 20, 20, 300, 50, black); + gp_fill_rect_xywh(win->pixmap, 20, 20, 300, 50, black); - GP_Text(win->pixmap, NULL, 20, 20, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + gp_text(win->pixmap, NULL, 20, 20, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, white, black, text_buf); - GP_Print(win->pixmap, NULL, 250, 20, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + gp_print(win->pixmap, NULL, 250, 20, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, white, black, "%c|%c|%c", bitmap->x_swap ? 'x' : ' ', bitmap->y_swap ? 'y' : ' ', bitmap->axes_swap ? 'a' : ' '); - GP_Blit(bitmap, 0, 0, GP_PixmapW(bitmap), GP_PixmapH(bitmap), - win->pixmap, bitmap_x, bitmap_y); + gp_blit(bitmap, 0, 0, gp_pixmap_w(bitmap), gp_pixmap_h(bitmap), + win->pixmap, bitmap_x, bitmap_y); - GP_BackendUpdateRectXYWH(win, bitmap_x, bitmap_y, - GP_PixmapW(bitmap), GP_PixmapH(bitmap)); - GP_BackendUpdateRectXYWH(win, 20, 20, 400, 50); + gp_backend_update_rect_xywh(win, bitmap_x, bitmap_y, + gp_pixmap_w(bitmap), gp_pixmap_h(bitmap)); + gp_backend_update_rect_xywh(win, 20, 20, 400, 50); } static void change_bitmap(void) @@ -87,16 +87,16 @@ static void change_bitmap(void) bitmap = bitmap_raw; snprintf(text_buf, sizeof(text_buf), "'%s' -> '%s'", - GP_PixelTypeName(bitmap->pixel_type), - GP_PixelTypeName(win->pixmap->pixel_type)); + gp_pixel_type_name(bitmap->pixel_type), + gp_pixel_type_name(win->pixmap->pixel_type)); } void event_loop(void) { - GP_Event ev; + gp_event ev; - while (GP_BackendGetEvent(win, &ev)) { - GP_EventDump(&ev); + while (gp_backend_get_event(win, &ev)) { + gp_event_dump(&ev); switch (ev.type) { case GP_EV_KEY: @@ -120,7 +120,7 @@ void event_loop(void) change_bitmap(); break; case GP_KEY_ESC: - GP_BackendExit(win); + gp_backend_exit(win); exit(0); break; } @@ -128,13 +128,13 @@ void event_loop(void) case GP_EV_SYS: switch(ev.code) { case GP_EV_SYS_QUIT: - GP_BackendExit(win); + gp_backend_exit(win); exit(0); break; case GP_EV_SYS_RESIZE: - GP_BackendResizeAck(win); - GP_Fill(win->pixmap, black); - GP_BackendFlip(win); + gp_backend_resize_ack(win); + gp_fill(win->pixmap, black); + gp_backend_flip(win); break; } break; @@ -160,14 +160,14 @@ int main(void) print_instructions(); - bitmap_raw = GP_LoadImage(sprite, NULL); + bitmap_raw = gp_load_image(sprite, NULL); if (!bitmap_raw) { fprintf(stderr, "Failed to load '%s'\n", sprite); return 1; } - win = GP_BackendInit(backend_opts, "Blit Test"); + win = gp_backend_init(backend_opts, "Blit Test"); if (win == NULL) { fprintf(stderr, "Failed to initalize backend '%s'\n", @@ -175,18 +175,18 @@ int main(void) return 1; } - bitmap_conv = GP_PixmapConvertAlloc(bitmap_raw, - win->pixmap->pixel_type); + bitmap_conv = gp_pixmap_convert_alloc(bitmap_raw, + win->pixmap->pixel_type); change_bitmap(); - black = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win->pixmap); - white = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win->pixmap); + black = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, win->pixmap); + white = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0xff, win->pixmap); - GP_Fill(win->pixmap, black); - GP_BackendFlip(win); + gp_fill(win->pixmap, black); + gp_backend_flip(win); for (;;) { - GP_BackendPoll(win); + gp_backend_poll(win); event_loop(); usleep(8000); diff --git a/demos/c_simple/convolution.c b/demos/c_simple/convolution.c index 7d26f17563f2..8501cd7df24b 100644 --- a/demos/c_simple/convolution.c +++ b/demos/c_simple/convolution.c @@ -30,14 +30,14 @@ #include <string.h> #include <errno.h> -#include <GP.h> +#include <gfxprim.h> struct callback_priv { char *op; char *name; }; -static int progress_callback(GP_ProgressCallback *self) +static int progress_callback(gp_progress_cb *self) { struct callback_priv *priv = self->priv; @@ -53,9 +53,9 @@ static int progress_callback(GP_ProgressCallback *self) int main(int argc, char *argv[]) { - GP_Pixmap *img; + gp_pixmap *img; struct callback_priv priv; - GP_ProgressCallback callback = {.callback = progress_callback, + gp_progress_cb callback = {.callback = progress_callback, .priv = &priv}; if (argc != 2) { @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) priv.op = "Loading"; priv.name = argv[1]; - img = GP_LoadImage(argv[1], &callback); + img = gp_load_image(argv[1], &callback); if (img == NULL) { fprintf(stderr, "Failed to load image '%s': %s\n", argv[1], @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) printf("\n"); - GP_FilterKernel2D box = { + gp_filter_kernel_2d box = { .w = 5, .h = 5, .div = 11.8, @@ -95,15 +95,15 @@ int main(int argc, char *argv[]) /* * Blur in-place, inner rectangle of the image. */ - GP_FilterConvolutionEx(img, img->w/4, img->h/4, img->w/2, img->h/2, - img, img->w/4, img->h/4, &box, &callback); + gp_filter_convolution_ex(img, img->w/4, img->h/4, img->w/2, img->h/2, + img, img->w/4, img->h/4, &box, &callback); printf("\n"); priv.op = "Saving"; priv.name = "out.png"; - if (GP_SavePNG(img, "out.png", &callback)) { + if (gp_save_png(img, "out.png", &callback)) { fprintf(stderr, "Failed to save image: %s", strerror(errno)); return 1; } diff --git a/demos/c_simple/data_storage.c b/demos/c_simple/data_storage.c index 902bbdbb871f..71437e406ce9 100644 --- a/demos/c_simple/data_storage.c +++ b/demos/c_simple/data_storage.c @@ -28,48 +28,48 @@ #include <stdio.h> -#include <GP.h> +#include <gfxprim.h> int main(void) { - GP_DataStorage *storage = GP_DataStorageCreate(); - GP_DataNode *flags; + gp_storage *storage = gp_storage_create(); + gp_data_node *flags; if (storage == NULL) return 1; printf("Empty storage -----------------------\n"); - GP_DataPrint(GP_DataStorageRoot(storage)); + gp_data_print(gp_storage_root(storage)); printf("-------------------------------------\n\n"); - GP_DataNode data = { + gp_data_node data = { .type = GP_DATA_INT, .value.i = 300, .id = "dpi" }; - GP_DataStorageAdd(storage, NULL, &data); + gp_storage_add(storage, NULL, &data); - GP_DataStorageAddString(storage, NULL, "orientation", "top-down"); + gp_storage_add_string(storage, NULL, "orientation", "top-down"); printf("Flat storage ------------------------\n"); - GP_DataPrint(GP_DataStorageRoot(storage)); + gp_data_print(gp_storage_root(storage)); printf("-------------------------------------\n\n"); - flags = GP_DataStorageAddDict(storage, NULL, "flags"); + flags = gp_storage_add_dict(storage, NULL, "flags"); data.type = GP_DATA_INT; data.id = "compression_level"; data.value.i = 10; - GP_DataStorageAdd(storage, flags, &data); + gp_storage_add(storage, flags, &data); printf("Recursive storage -------------------\n"); - GP_DataPrint(GP_DataStorageRoot(storage)); + gp_data_print(gp_storage_root(storage)); printf("-------------------------------------\n\n"); - GP_DataPrint(GP_DataStorageGet(storage, NULL, "dpi")); - GP_DataStorageDestroy(storage); + gp_data_print(gp_storage_get(storage, NULL, "dpi")); + gp_storage_destroy(storage); return 0; } diff --git a/demos/c_simple/debug_handler.c b/demos/c_simple/debug_handler.c index 5c472fd61e4f..23c5e1e1b1b6 100644 --- a/demos/c_simple/debug_handler.c +++ b/demos/c_simple/debug_handler.c @@ -27,7 +27,7 @@ */ #include <stdio.h> -#include <GP.h> +#include <gfxprim.h> static char level_to_c(int level) { @@ -47,7 +47,7 @@ static char level_to_c(int level) } } -void debug_handler(const struct GP_DebugMsg *msg) +void debug_handler(const struct gp_debug_msg *msg) { printf("%c: %s->%s():%u: %s\n", level_to_c(msg->level), msg->file, msg->fn, msg->line, msg->msg); @@ -56,20 +56,20 @@ void debug_handler(const struct GP_DebugMsg *msg) int main(void) { /* Set custom debug handler */ - GP_SetDebugHandler(debug_handler); + gp_set_debug_handler(debug_handler); /* Print some debug messages */ GP_WARN("This is a warning"); GP_FATAL("This is a fatal condition"); /* Turn on verbose debug and call some library functions */ - GP_SetDebugLevel(10); + gp_set_debug_level(10); - GP_Pixmap *pixmap = GP_PixmapAlloc(1000, 1000, 1); + gp_pixmap *pixmap = gp_pixmap_alloc(1000, 1000, 1); - GP_FilterGaussianBlur(pixmap, pixmap, 10, 10, NULL); + gp_filter_gaussian_blur(pixmap, pixmap, 10, 10, NULL); - GP_PixmapFree(pixmap); + gp_pixmap_free(pixmap); return 0; } diff --git a/demos/c_simple/fileview.c b/demos/c_simple/fileview.c index d5c870b65f8c..79837447f919 100644 --- a/demos/c_simple/fileview.c +++ b/demos/c_simple/fileview.c @@ -27,12 +27,12 @@ #include <stdlib.h> #include <string.h> -#include <GP.h> +#include <gfxprim.h> -static GP_Pixmap *win; -static GP_Backend *backend; +static gp_pixmap *win; +static gp_backend *backend; -static GP_Pixel white_pixel, gray_pixel, dark_gray_pixel, black_pixel, +static gp_pixel white_pixel, gray_pixel, dark_gray_pixel, black_pixel, red_pixel, blue_pixel; static int font_flag = 0; @@ -41,38 +41,38 @@ static int tracking = 0; static int mul = 1; static int space = 0; -static GP_FontFace *font; +static gp_font_face *font; -struct FileLine { +struct file_line { char *text; - struct FileLine *next; - struct FileLine *prev; + struct file_line *next; + struct file_line *prev; }; -struct FileLine *first_line = NULL; -struct FileLine *last_line = NULL; +struct file_line *first_line = NULL; +struct file_line *last_line = NULL; void redraw_screen(void) { - GP_Fill(win, gray_pixel); + gp_fill(win, gray_pixel); - GP_TextStyle style = GP_DEFAULT_TEXT_STYLE; + gp_text_style style = GP_DEFAULT_TEXT_STYLE; switch (font_flag) { case 0: - style.font = &GP_DefaultConsoleFont; + style.font = gp_font_gfxprim_mono; break; case 1: - style.font = &GP_DefaultProportionalFont; + style.font = gp_font_gfxprim; break; case 2: - style.font = GP_FontTinyMono; + style.font = gp_font_tiny_mono; break; case 3: - style.font = GP_FontTiny; + style.font = gp_font_tiny; break; case 4: - style.font = GP_FontC64; + style.font = gp_font_c64; break; case 5: style.font = font; @@ -90,12 +90,12 @@ void redraw_screen(void) */ int align = GP_ALIGN_RIGHT|GP_VALIGN_BELOW; - struct FileLine *line = first_line; + struct file_line *line = first_line; unsigned int i; - for (i = 0; i < win->h/GP_TextHeight(&style); i++) { + for (i = 0; i < win->h/gp_text_height(&style); i++) { if (line == NULL) break; - GP_Text(win, &style, 16, 16 + (1.0 * GP_TextHeight(&style))*i, + gp_text(win, &style, 16, 16 + (1.0 * gp_text_height(&style))*i, align, black_pixel, gray_pixel, line->text); line = line->next; } @@ -108,7 +108,7 @@ static void warp_up(int lines) first_line = first_line->prev; redraw_screen(); - GP_BackendFlip(backend); + gp_backend_flip(backend); } static void warp_down(int lines) @@ -118,15 +118,15 @@ static void warp_down(int lines) first_line = first_line->next; redraw_screen(); - GP_BackendFlip(backend); + gp_backend_flip(backend); } void event_loop(void) { - GP_Event ev; + gp_event ev; for (;;) { - GP_BackendWaitEvent(backend, &ev); + gp_backend_wait_event(backend, &ev); switch (ev.type) { case GP_EV_KEY: @@ -141,17 +141,17 @@ void event_loop(void) font_flag = (font_flag + 1) % 5; redraw_screen(); - GP_BackendFlip(backend); + gp_backend_flip(backend); break; case GP_KEY_RIGHT: tracking++; redraw_screen(); - GP_BackendFlip(backend); + gp_backend_flip(backend); break; case GP_KEY_LEFT: tracking--; redraw_screen(); - GP_BackendFlip(backend); + gp_backend_flip(backend); break; case GP_KEY_UP: warp_up(1); @@ -162,23 +162,23 @@ void event_loop(void) case GP_KEY_DOT: space++; redraw_screen(); - GP_BackendFlip(backend); + gp_backend_flip(backend); break; case GP_KEY_COMMA: space--; redraw_screen(); - GP_BackendFlip(backend); + gp_backend_flip(backend); break; case GP_KEY_RIGHT_BRACE: mul++; redraw_screen(); - GP_BackendFlip(backend); + gp_backend_flip(backend); break; case GP_KEY_LEFT_BRACE: if (mul > 0) mul--; redraw_screen(); - GP_BackendFlip(backend); + gp_backend_flip(backend); break; case GP_KEY_PAGE_UP: warp_up(30); @@ -187,7 +187,7 @@ void event_loop(void) warp_down(30); break; case GP_KEY_ESC: - GP_BackendExit(backend); + gp_backend_exit(backend); exit(0); break; } @@ -195,13 +195,13 @@ void event_loop(void) case GP_EV_SYS: switch(ev.code) { case GP_EV_SYS_QUIT: - GP_BackendExit(backend); + gp_backend_exit(backend); exit(0); break; case GP_EV_SYS_RESIZE: - GP_BackendResizeAck(backend); + gp_backend_resize_ack(backend); redraw_screen(); - GP_BackendFlip(backend); + gp_backend_flip(backend); break; } break; @@ -224,7 +224,7 @@ static int read_file_head(const char *filename) if (fgets(buf, 511, f) == NULL) break; - struct FileLine *line = malloc(sizeof(*line)); + struct file_line *line = malloc(sizeof(*line)); line->text = strdup(buf); line->next = NULL; line->prev = NULL; @@ -253,12 +253,12 @@ int main(int argc, char *argv[]) } if (argc > 2) - font = GP_FontFaceLoad(argv[2], 0, 16); + font = gp_font_face_load(argv[2], 0, 16); if (!read_file_head(argv[1])) return 1; - backend = GP_BackendInit(backend_opts, "File View"); + backend = gp_backend_init(backend_opts, "File View"); if (backend == NULL) { fprintf(stderr, "Failed to initalize backend '%s'\n", @@ -268,15 +268,15 @@ int main(int argc, char *argv[]) win = backend->pixmap; - white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win); - gray_pixel = GP_RGBToPixmapPixel(0xbe, 0xbe, 0xbe, win); - dark_gray_pixel = GP_RGBToPixmapPixel(0x7f, 0x7f, 0x7f, win); - black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win); - red_pixel = GP_RGBToPixmapPixel(0xff, 0x00, 0x00, win); - blue_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0xff, win); + white_pixel = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0xff, win); + gray_pixel = gp_rgb_to_pixmap_pixel(0xbe, 0xbe, 0xbe, win); + dark_gray_pixel = gp_rgb_to_pixmap_pixel(0x7f, 0x7f, 0x7f, win); + black_pixel = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, win); + red_pixel = gp_rgb_to_pixmap_pixel(0xff, 0x00, 0x00, win); + blue_pixel = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0xff, win); redraw_screen(); - GP_BackendFlip(backend); + gp_backend_flip(backend); event_loop(); diff --git a/demos/c_simple/filters_symmetry.c b/demos/c_simple/filters_symmetry.c index 926445354f9a..aacff3478add 100644 --- a/demos/c_simple/filters_symmetry.c +++ b/demos/c_simple/filters_symmetry.c @@ -31,24 +31,24 @@ #include <errno.h> #include <getopt.h> -#include <GP.h> +#include <gfxprim.h> static void usage_and_exit(int ret) { int i; printf("filter_symmetry [-d debug_level] -s {"); - for (i = 0; GP_FilterSymmetryNames[i+1] != NULL; i++) - printf("%s, ", GP_FilterSymmetryNames[i]); + for (i = 0; gp_filter_symmetry_names[i+1] != NULL; i++) + printf("%s, ", gp_filter_symmetry_names[i]); - printf("%s} image_in image_out\n", GP_FilterSymmetryNames[i]); + printf("%s} image_in image_out\n", gp_filter_symmetry_names[i]); exit(ret); } int main(int argc, char *argv[]) { - GP_Pixmap *src, *res; + gp_pixmap *src, *res; const char *symmetry = NULL; int opt, sym, debug = 0; @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) } /* Turn on debug messages */ - GP_SetDebugLevel(debug); + gp_set_debug_level(debug); if (symmetry == NULL) { printf("Symmetry not specified\n"); @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) usage_and_exit(1); } - sym = GP_FilterSymmetryByName(symmetry); + sym = gp_filter_symmetry_by_name(symmetry); if (sym < 0) { printf("Invalid symmetry name '%s'\n", symmetry); @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) } /* Load Image */ - src = GP_LoadImage(argv[optind], NULL); + src = gp_load_image(argv[optind], NULL); if (src == NULL) { fprintf(stderr, "Failed to load image '%s': %s\n", @@ -99,18 +99,18 @@ int main(int argc, char *argv[]) } /* Apply a symmetry filter */ - res = GP_FilterSymmetryAlloc(src, sym, NULL); + res = gp_filter_symmetry_alloc(src, sym, NULL); /* Save Image */ - if (GP_SaveImage(res, argv[optind+1], NULL)) { + if (gp_save_image(res, argv[optind+1], NULL)) { fprintf(stderr, "Failed to save image '%s': %s\n", argv[optind+1], strerror(errno)); return 1; } /* Cleanup */ - GP_PixmapFree(src); - GP_PixmapFree(res); + gp_pixmap_free(src); + gp_pixmap_free(res); return 0; } diff --git a/demos/c_simple/fonttest.c b/demos/c_simple/fonttest.c index e2e5dd6c2b82..fef4c7e6ad1d 100644 --- a/demos/c_simple/fonttest.c +++ b/demos/c_simple/fonttest.c @@ -27,14 +27,14 @@ #include <stdlib.h> #include <string.h> -#include <GP.h> +#include <gfxprim.h> -static GP_Backend *win; +static gp_backend *win; static const char *font_path = NULL; static unsigned int font_h = 16; -static GP_Pixel white_pixel, gray_pixel, dark_gray_pixel, black_pixel, +static gp_pixel white_pixel, gray_pixel, dark_gray_pixel, black_pixel, red_pixel, blue_pixel; static const char *test_strings[] = { @@ -46,9 +46,9 @@ static const char *test_strings[] = { static int font_flag = 0; static int tracking = 0; -static GP_FontFace *font = NULL; +static gp_font_face *font = NULL; -static const char *glyph_bitmap_format_name(const GP_FontBitmapFormat format) +static const char *glyph_bitmap_format_name(const gp_font_bitmap_format format) { switch (format) { case GP_FONT_BITMAP_1BPP: @@ -62,9 +62,9 @@ static const char *glyph_bitmap_format_name(const GP_FontBitmapFormat format) } } -static void print_character_metadata(const GP_FontFace *font, int c) +static void print_character_metadata(const gp_font_face *font, int c) { - const GP_GlyphBitmap *glyph = GP_GetGlyphBitmap(font, c); + const gp_glyph *glyph = gp_get_glyph(font, c); fprintf(stderr, "Properties of the character '%c':\n", c); if (glyph) { @@ -79,18 +79,18 @@ static void print_character_metadata(const GP_FontFace *font, int c) } } -static void print_font_properties(const GP_FontFace *font) +static void print_font_properties(const gp_font_face *font) { fprintf(stderr, "Font '%s %s' properties:\n", - GP_FontFamily(font), GP_FontStyle(font)); + gp_font_family(font), gp_font_style(font)); fprintf(stderr, " Height: ascend: %d, descend: %d\n", - GP_FontAscend(font), GP_FontDescend(font)); + gp_font_ascend(font), gp_font_descend(font)); fprintf(stderr, " Max advance_x: %u\n", - GP_FontMaxAdvanceX(font)); + gp_font_max_advance_x(font)); fprintf(stderr, " Glyph bitmap format: %s\n", glyph_bitmap_format_name(font->glyph_bitmap_format)); fprintf(stderr, " Bounding box width: %d, heigth: %d\n", - GP_FontMaxWidth(font), GP_FontHeight(font)); + gp_font_max_width(font), gp_font_height(font)); print_character_metadata(font, 'a'); print_character_metadata(font, 'm'); @@ -101,25 +101,25 @@ static void print_font_properties(const GP_FontFace *font) void redraw_screen(void) { - GP_Fill(win->pixmap, black_pixel); + gp_fill(win->pixmap, black_pixel); - GP_TextStyle style = GP_DEFAULT_TEXT_STYLE; + gp_text_style style = GP_DEFAULT_TEXT_STYLE; switch (font_flag) { case 0: - style.font = &GP_DefaultProportionalFont; + style.font = gp_font_gfxprim; break; case 1: - style.font = &GP_DefaultConsoleFont; + style.font = gp_font_gfxprim_mono; break; case 2: - style.font = GP_FontTiny; + style.font = gp_font_tiny; break; case 3: - style.font = GP_FontTinyMono; + style.font = gp_font_tiny_mono; break; case 4: - style.font = GP_FontC64; + style.font = gp_font_c64; break; case 5: style.font = font; @@ -144,31 +144,31 @@ void redraw_screen(void) style.pixel_yspace = 0; style.char_xspace = tracking; - GP_FillRectXYWH(win->pixmap, + gp_fill_rect_xywh(win->pixmap, 16, SPACING*i + 16, - GP_TextWidth(&style, test_string), - GP_FontHeight(style.font), + gp_text_width(&style, test_string), + gp_font_height(style.font), dark_gray_pixel); - GP_RectXYWH(win->pixmap, + gp_rect_xywh(win->pixmap, 15, SPACING*i + 15, - GP_TextMaxWidth(&style, strlen(test_string)) + 1, - GP_FontHeight(style.font) + 1, + gp_text_max_width(&style, strlen(test_string)) + 1, + gp_font_height(style.font) + 1, blue_pixel); - GP_Text(win->pixmap, &style, 16, SPACING*i + 16, align, + gp_text(win->pixmap, &style, 16, SPACING*i + 16, align, white_pixel, dark_gray_pixel, test_string); style.pixel_xmul = 2; style.pixel_ymul = 2; style.pixel_yspace = 1; - GP_Text(win->pixmap, &style, 34, SPACING * i + 44, align, + gp_text(win->pixmap, &style, 34, SPACING * i + 44, align, white_pixel, black_pixel, test_string); - GP_RectXYWH(win->pixmap, 33, SPACING * i + 43, - GP_TextWidth(&style, test_string) + 1, - GP_TextHeight(&style) + 1, dark_gray_pixel); + gp_rect_xywh(win->pixmap, 33, SPACING * i + 43, + gp_text_width(&style, test_string) + 1, + gp_text_height(&style) + 1, dark_gray_pixel); style.pixel_xmul = 4; style.pixel_ymul = 2; @@ -184,17 +184,17 @@ void redraw_screen(void) style.pixel_yspace = 2; } - GP_Text(win->pixmap, &style, 64, SPACING*i + 88, align, + gp_text(win->pixmap, &style, 64, SPACING*i + 88, align, dark_gray_pixel, black_pixel, test_string); } } void event_loop(void) { - GP_Event ev; + gp_event ev; for (;;) { - GP_BackendWaitEvent(win, &ev); + gp_backend_wait_event(win, &ev); switch (ev.type) { case GP_EV_KEY: @@ -209,38 +209,38 @@ void event_loop(void) font_flag = (font_flag + 1) % 5; redraw_screen(); - GP_BackendFlip(win); + gp_backend_flip(win); break; case GP_KEY_UP: tracking++; redraw_screen(); - GP_BackendFlip(win); + gp_backend_flip(win); break; case GP_KEY_DOWN: tracking--; redraw_screen(); - GP_BackendFlip(win); + gp_backend_flip(win); break; case GP_KEY_B: font_h++; if (font_path) { - GP_FontFaceFree(font); - font = GP_FontFaceLoad(font_path, 0, font_h); + gp_font_face_free(font); + font = gp_font_face_load(font_path, 0, font_h); redraw_screen(); - GP_BackendFlip(win); + gp_backend_flip(win); } break; case GP_KEY_S: font_h--; if (font_path) { - GP_FontFaceFree(font); - font = GP_FontFaceLoad(font_path, 0, font_h); + gp_font_face_free(font); + font = gp_font_face_load(font_path, 0, font_h); redraw_screen(); - GP_BackendFlip(win); + gp_backend_flip(win); } break; case GP_KEY_ESC: - GP_BackendExit(win); + gp_backend_exit(win); exit(0); break; } @@ -248,9 +248,9 @@ void event_loop(void) case GP_EV_SYS: switch(ev.code) { case GP_EV_SYS_RESIZE: - GP_BackendResizeAck(win); + gp_backend_resize_ack(win); redraw_screen(); - GP_BackendFlip(win); + gp_backend_flip(win); break; } break; @@ -276,10 +276,10 @@ int main(int argc, char *argv[]) if (argc > 1) { font_path = argv[1]; fprintf(stderr, "\nLoading font '%s'\n", argv[1]); - font = GP_FontFaceLoad(argv[1], 0, font_h); + font = gp_font_face_load(argv[1], 0, font_h); } - win = GP_BackendInit(backend_opts, "Font Test"); + win = gp_backend_init(backend_opts, "Font Test"); if (win == NULL) { fprintf(stderr, "Failed to initalize backend '%s'\n", @@ -287,15 +287,15 @@ int main(int argc, char *argv[]) return 1; } - white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win->pixmap); - gray_pixel = GP_RGBToPixmapPixel(0xbe, 0xbe, 0xbe, win->pixmap); - dark_gray_pixel = GP_RGBToPixmapPixel(0x7f, 0x7f, 0x7f, win->pixmap); - black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win->pixmap); - red_pixel = GP_RGBToPixmapPixel(0xff, 0x00, 0x00, win->pixmap); - blue_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0xff, win->pixmap); + white_pixel = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0xff, win->pixmap); + gray_pixel = gp_rgb_to_pixmap_pixel(0xbe, 0xbe, 0xbe, win->pixmap); + dark_gray_pixel = gp_rgb_to_pixmap_pixel(0x7f, 0x7f, 0x7f, win->pixmap); + black_pixel = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, win->pixmap); + red_pixel = gp_rgb_to_pixmap_pixel(0xff, 0x00, 0x00, win->pixmap); + blue_pixel = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0xff, win->pixmap); redraw_screen(); - GP_BackendFlip(win); + gp_backend_flip(win); event_loop(); diff --git a/demos/c_simple/gaussian_noise.c b/demos/c_simple/gaussian_noise.c index 8c0cb152ebc9..fb5c7cd5b9d2 100644 --- a/demos/c_simple/gaussian_noise.c +++ b/demos/c_simple/gaussian_noise.c @@ -31,7 +31,7 @@ #include <string.h> #include <errno.h> -#include <GP.h> +#include <gfxprim.h> static void help(const char *app) { @@ -42,7 +42,7 @@ static void help(const char *app) int main(int argc, char *argv[]) { - GP_Pixmap *img; + gp_pixmap *img; float sigma = 0.1, mu = 0.1; int opt; @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) return 1; } - img = GP_LoadImage(argv[optind], NULL); + img = gp_load_image(argv[optind], NULL); if (img == NULL) { fprintf(stderr, "Failed to load image '%s': %s\n", @@ -73,9 +73,9 @@ int main(int argc, char *argv[]) return 1; } - GP_Pixmap *res = GP_FilterGaussianNoiseAddAlloc(img, sigma, mu, NULL); + gp_pixmap *res = gp_filter_gaussian_noise_add_alloc(img, sigma, mu, NULL); - if (GP_SaveImage(res, argv[optind + 1], NULL)) { + if (gp_save_image(res, argv[optind + 1], NULL)) { fprintf(stderr, "Failed to save image '%s': %s", argv[optind + 1], strerror(errno)); return 1; diff --git a/demos/c_simple/gfx_koch.c b/demos/c_simple/gfx_koch.c index 615f2345ce9e..7e54166fb5a0 100644 --- a/demos/c_simple/gfx_koch.c +++ b/demos/c_simple/gfx_koch.c @@ -30,7 +30,7 @@ #include <string.h> #include <errno.h> -#include <GP.h> +#include <gfxprim.h> /* Set to 1 to use Anti Aliased drawing */ static int aa_flag = 0; @@ -41,7 +41,7 @@ static int aa_flag = 0; * We could do this only and only because the pixmap * pixel type is fixed to GP_PIXEL_RGB888. */ -static GP_Pixel do_color(int xc, int yc, float x, float y) +static gp_pixel do_color(int xc, int yc, float x, float y) { float dx = GP_ABS(1.00 * xc - x)/(2*xc); float dy = GP_ABS(1.00 * yc - y)/(2*yc); @@ -66,17 +66,17 @@ static GP_Pixel do_color(int xc, int yc, float x, float y) return bmask | (gmask<<8) | (rmask << 16); } -static void draw(GP_Pixmap *img, int level, float x0, float y0, float x1, float y1) +static void draw(gp_pixmap *img, int level, float x0, float y0, float x1, float y1) { if (level == 0) { - GP_Pixel pixel; + gp_pixel pixel; pixel = do_color(img->w/2, img->h/2, 1.00 * (x0+x1)/2, 1.00 * (y0 + y1)/2); if (aa_flag) - GP_LineAA(img, x0 * 256, y0 * 256, x1 * 256, y1 * 256, pixel); + gp_line_aa(img, x0 * 256, y0 * 256, x1 * 256, y1 * 256, pixel); else - GP_Line(img, x0, y0, x1, y1, pixel); + gp_line(img, x0, y0, x1, y1, pixel); return; } @@ -106,10 +106,10 @@ static void draw(GP_Pixmap *img, int level, float x0, float y0, float x1, float int main(void) { - GP_Pixmap *img; + gp_pixmap *img; /* Create RGB 24 bit image */ - img = GP_PixmapAlloc(600, 600, GP_PIXEL_RGB888); + img = gp_pixmap_alloc(600, 600, GP_PIXEL_RGB888); if (img == NULL) { fprintf(stderr, "Failed to allocate pixmap"); @@ -117,19 +117,19 @@ int main(void) } /* Clean up the bitmap */ - GP_Fill(img, 0); + gp_fill(img, 0); /* Draw a fractal */ draw(img, 4, 0, 0, img->w - 1, img->h - 1); draw(img, 4, 0, img->h - 1, img->w - 1, 0); - if (GP_SavePNG(img, "out.png", NULL)) { + if (gp_save_png(img, "out.png", NULL)) { fprintf(stderr, "Failed to save image %s", strerror(errno)); return 1; } /* Cleanup */ - GP_PixmapFree(img); + gp_pixmap_free(img); return 0; } diff --git a/demos/c_simple/input_example.c b/demos/c_simple/input_example.c index 5ac76d302a1f..70b6c0ff2ef7 100644 --- a/demos/c_simple/input_example.c +++ b/demos/c_simple/input_example.c @@ -27,40 +27,40 @@ #include <stdlib.h> #include <unistd.h> -#include "GP.h" +#include "gfxprim.h" -static GP_Pixmap *win; -static GP_Backend *backend; +static gp_pixmap *win; +static gp_backend *backend; -static GP_Pixel red, green, white, black; +static gp_pixel red, green, white, black; -static void draw_event(GP_Event *ev) +static void draw_event(gp_event *ev) { - static GP_Size size = 0; + static gp_size size = 0; if (ev->type != GP_EV_KEY) return; int align = GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM; - GP_TextClear(win, NULL, 20, 20, align, black, size); - size = GP_Print(win, NULL, 20, 20, align, + gp_text_clear(win, NULL, 20, 20, align, black, size); + size = gp_print(win, NULL, 20, 20, align, white, black, "Key=%s", - GP_EventKeyName(ev->val.key.key)); + gp_event_key_name(ev->val.key.key)); - GP_BackendFlip(backend); + gp_backend_flip(backend); } static void event_loop(void) { for (;;) { - GP_BackendWait(backend); + gp_backend_wait(backend); - while (GP_BackendEventsQueued(backend)) { - GP_Event ev; + while (gp_backend_events_queued(backend)) { + gp_event ev; - GP_BackendGetEvent(backend, &ev); - GP_EventDump(&ev); + gp_backend_get_event(backend, &ev); + gp_event_dump(&ev); switch (ev.type) { case GP_EV_KEY: @@ -68,17 +68,17 @@ static void event_loop(void) switch (ev.val.key.key) { case GP_KEY_ESC: - GP_BackendExit(backend); + gp_backend_exit(backend); exit(0); break; case GP_BTN_LEFT: - GP_HLineXXY(win, ev.cursor_x - 3, + gp_hline_xxy(win, ev.cursor_x - 3, ev.cursor_x + 3, ev.cursor_y, red); - GP_VLineXYY(win, ev.cursor_x, + gp_vline_xyy(win, ev.cursor_x, ev.cursor_y - 3, ev.cursor_y + 3, red); - GP_BackendFlip(backend); + gp_backend_flip(backend); break; default: break; @@ -88,29 +88,30 @@ static void event_loop(void) switch (ev.code) { static int size = 0; case GP_EV_REL_POS: - if (GP_EventGetKey(&ev, GP_BTN_LEFT)) { - GP_PutPixel(win, ev.cursor_x, - ev.cursor_y, green); + if (gp_event_get_key(&ev, GP_BTN_LEFT)) { + gp_putpixel(win, ev.cursor_x, + ev.cursor_y, + green); } int align = GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM; - GP_TextClear(win, NULL, 20, 40, align, - black, size); - size = GP_Print(win, NULL, 20, 40, align, + gp_text_clear(win, NULL, 20, 40, align, + black, size); + size = gp_print(win, NULL, 20, 40, align, white, black, "X=%3u Y=%3u dX=%3i dY=%3i", ev.cursor_x, ev.cursor_y, ev.val.rel.rx, ev.val.rel.ry); - GP_BackendFlip(backend); + gp_backend_flip(backend); break; } break; case GP_EV_SYS: switch (ev.code) { case GP_EV_SYS_RESIZE: - GP_BackendResizeAck(backend); + gp_backend_resize_ack(backend); break; case GP_EV_SYS_QUIT: - GP_BackendExit(backend); + gp_backend_exit(backend); exit(0); break; } @@ -131,7 +132,7 @@ int main(int argc, char *argv[]) backend_opts = optarg; break; case 'h': - GP_BackendInit("help", NULL); + gp_backend_init("help", NULL); return 0; break; default: @@ -140,7 +141,7 @@ int main(int argc, char *argv[]) } } - backend = GP_BackendInit(backend_opts, "Input Test"); + backend = gp_backend_init(backend_opts, "Input Test"); if (backend == NULL) { fprintf(stderr, "Failed to initalize backend '%s'\n", @@ -150,16 +151,16 @@ int main(int argc, char *argv[]) win = backend->pixmap; - red = GP_RGBToPixmapPixel(0xff, 0x00, 0x00, win); - green = GP_RGBToPixmapPixel(0x00, 0xff, 0x00, win); - white = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win); - black = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win); + red = gp_rgb_to_pixmap_pixel(0xff, 0x00, 0x00, win); + green = gp_rgb_to_pixmap_pixel(0x00, 0xff, 0x00, win); + white = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0xff, win); + black = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, win); - GP_Fill(win, black); - GP_BackendFlip(backend); + gp_fill(win, black); + gp_backend_flip(backend); for (;;) { - GP_BackendWait(backend); + gp_backend_wait(backend); event_loop(); } } diff --git a/demos/c_simple/koch.c b/demos/c_simple/koch.c index b5558c06f9ab..f421570dd424 100644 --- a/demos/c_simple/koch.c +++ b/demos/c_simple/koch.c @@ -31,7 +31,7 @@ #include <math.h> -#include <GP.h> +#include <gfxprim.h> #define TIMER_TICK 20000 #define DISPLAY_W 640 @@ -39,21 +39,21 @@ #define sqr(x) ((x)*(x)) #define sgn(x) ((x)>0 ? 1 : -1) -static GP_Backend *backend; -static GP_Pixmap *pixmap; +static gp_backend *backend; +static gp_pixmap *pixmap; static int iter, l, way = 1, draw_edge = 1; -static GP_Pixel black, blue, gray, red; +static gp_pixel black, blue, gray, red; static void sierpinsky(double x1, double y1, double x4, double y4, int iter) { double x2, y2, x3, y3, x5, y5; - GP_Pixel pixel; - pixel = GP_RGBToPixel(0, 0, 255-16*iter, pixmap->pixel_type); + gp_pixel pixel; + pixel = gp_rgb_to_pixel(0, 0, 255-16*iter, pixmap->pixel_type); if (iter <= 0) { if (draw_edge) - GP_Line(pixmap, x1, y1, x4, y4, black); + gp_line(pixmap, x1, y1, x4, y4, black); return; } @@ -66,11 +66,11 @@ static void sierpinsky(double x1, double y1, double x4, double y4, int iter) x5 = (x1+x4)/2 + (y2 - y3)*sqrt(3.00/4); y5 = (y1+y4)/2 + (x3 - x2)*sqrt(3.00/4); - GP_FillTriangle(pixmap, x2, y2, x3, y3, x5, y5, pixel); + gp_fill_triangle(pixmap, x2, y2, x3, y3, x5, y5, pixel); - GP_PutPixel(pixmap, x2, y2, red); - GP_PutPixel(pixmap, x3, y3, red); - GP_PutPixel(pixmap, x5, y5, red); + gp_putpixel(pixmap, x2, y2, red); + gp_putpixel(pixmap, x3, y3, red); + gp_putpixel(pixmap, x5, y5, red); sierpinsky(x1, y1, x2, y2, iter - 1); sierpinsky(x2, y2, x5, y5, iter - 1); @@ -95,15 +95,15 @@ static void draw(int x, int y, int l, int iter) x3 = sin(1.00 * (iter+240)/57) * l + x; y3 = cos(1.00 * (iter+240)/57) * l + y; - GP_Fill(pixmap, gray); + gp_fill(pixmap, gray); - GP_FillTriangle(pixmap, x1, y1, x2, y2, x3, y3, blue); + gp_fill_triangle(pixmap, x1, y1, x2, y2, x3, y3, blue); sierpinsky(x1, y1, x2, y2, iter/60%6); sierpinsky(x2, y2, x3, y3, iter/60%6); sierpinsky(x3, y3, x1, y1, iter/60%6); - GP_BackendFlip(backend); + gp_backend_flip(backend); } static int paused = 0; @@ -128,7 +128,7 @@ int main(void) { const char *backend_opts = "X11"; - backend = GP_BackendInit(backend_opts, "Koch"); + backend = gp_backend_init(backend_opts, "Koch"); if (backend == NULL) { fprintf(stderr, "Failed to initalize backend '%s'\n", @@ -138,23 +138,23 @@ int main(void) pixmap = backend->pixmap; - black = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); - blue = GP_RGBToPixmapPixel(0x00, 0x00, 0xff, pixmap); - gray = GP_RGBToPixmapPixel(0xbe, 0xbe, 0xbe, pixmap); - red = GP_RGBToPixmapPixel(0xff, 0x00, 0x00, pixmap); + black = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, pixmap); + blue = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0xff, pixmap); + gray = gp_rgb_to_pixmap_pixel(0xbe, 0xbe, 0xbe, pixmap); + red = gp_rgb_to_pixmap_pixel(0xff, 0x00, 0x00, pixmap); iter = 0; draw(pixmap->w/2, pixmap->h/2, l, iter); for (;;) { - GP_Event ev; + gp_event ev; redraw(); - GP_BackendPoll(backend); + gp_backend_poll(backend); - while (GP_BackendGetEvent(backend, &ev)) { - GP_EventDump(&ev); + while (gp_backend_get_event(backend, &ev)) { + gp_event_dump(&ev); switch (ev.type) { case GP_EV_KEY: @@ -169,14 +169,14 @@ int main(void) draw_edge = !draw_edge; break; case GP_KEY_ESC: - GP_BackendExit(backend); + gp_backend_exit(backend); return 0; break; } break; case GP_EV_SYS: if (ev.code == GP_EV_SYS_RESIZE) - GP_BackendResizeAck(backend); + gp_backend_resize_ack(backend); } } usleep(TIMER_TICK); diff --git a/demos/c_simple/linetest.c b/demos/c_simple/linetest.c index 7e535df94a61..2d418d650ef1 100644 --- a/demos/c_simple/linetest.c +++ b/demos/c_simple/linetest.c @@ -25,17 +25,17 @@ #include <math.h> -#include <GP.h> +#include <gfxprim.h> /* Values for color pixels in display format. */ -static GP_Pixel black, white; +static gp_pixel black, white; static double start_angle = 0.0; static int aa_flag = 0; static int pause_flag = 0; -static GP_Backend *win; +static gp_backend *win; void redraw_screen(void) { @@ -46,7 +46,7 @@ void redraw_screen(void) int xcenter = w/2; int ycenter = h/2; - GP_Fill(win->pixmap, black); + gp_fill(win->pixmap, black); for (angle = 0.0; angle < 2*M_PI; angle += 0.1) { x = (int) (w/2 * cos(start_angle + angle)); @@ -55,30 +55,30 @@ void redraw_screen(void) int r = 127.0 + 127.0 * cos(start_angle + angle); int b = 127.0 + 127.0 * sin(start_angle + angle); - GP_Pixel pixel; - pixel = GP_RGBToPixel(r, 0, b, win->pixmap->pixel_type); + gp_pixel pixel; + pixel = gp_rgb_to_pixel(r, 0, b, win->pixmap->pixel_type); if (aa_flag) { - GP_LineAA_Raw(win->pixmap, GP_FP_FROM_INT(xcenter), GP_FP_FROM_INT(ycenter), + gp_line_aa_raw(win->pixmap, GP_FP_FROM_INT(xcenter), GP_FP_FROM_INT(ycenter), GP_FP_FROM_INT(xcenter + x), GP_FP_FROM_INT(ycenter + y), pixel); } else { - GP_Line(win->pixmap, xcenter + x, ycenter + y, xcenter, ycenter, pixel); - GP_Line(win->pixmap, xcenter, ycenter, xcenter + x, ycenter + y, pixel); + gp_line(win->pixmap, xcenter + x, ycenter + y, xcenter, ycenter, pixel); + gp_line(win->pixmap, xcenter, ycenter, xcenter + x, ycenter + y, pixel); } } - GP_BackendFlip(win); + gp_backend_flip(win); /* axes */ -// GP_HLineXYW(&pixmap, 0, ycenter, display->w, white); -// GP_VLineXYH(&pixmap, xcenter, 0, display->h, white); +// gp_hline_xyw(&pixmap, 0, ycenter, display->w, white); +// gp_vlineXYH(&pixmap, xcenter, 0, display->h, white); } void event_loop(void) { - GP_Event ev; + gp_event ev; - while (GP_BackendGetEvent(win, &ev)) { + while (gp_backend_get_event(win, &ev)) { switch (ev.type) { case GP_EV_KEY: if (ev.code != GP_EV_KEY_DOWN) @@ -89,7 +89,7 @@ void event_loop(void) aa_flag = !aa_flag; break; case GP_KEY_ESC: - GP_BackendExit(win); + gp_backend_exit(win); exit(0); break; case GP_KEY_P: @@ -100,11 +100,11 @@ void event_loop(void) case GP_EV_SYS: switch(ev.code) { case GP_EV_SYS_QUIT: - GP_BackendExit(win); + gp_backend_exit(win); exit(0); break; case GP_EV_SYS_RESIZE: - GP_BackendResizeAck(win); + gp_backend_resize_ack(win); break; } break; @@ -127,7 +127,7 @@ int main(int argc, char *argv[]) } } - win = GP_BackendInit(backend_opts, "Line Test"); + win = gp_backend_init(backend_opts, "Line Test"); if (win == NULL) { fprintf(stderr, "Failed to initalize backend '%s'\n", @@ -135,13 +135,13 @@ int main(int argc, char *argv[]) return 1; } - white = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win->pixmap); - black = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win->pixmap); + white = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0xff, win->pixmap); + black = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, win->pixmap); redraw_screen(); for (;;) { - GP_BackendPoll(win); + gp_backend_poll(win); event_loop(); usleep(20000); @@ -150,7 +150,7 @@ int main(int argc, char *argv[]) continue; redraw_screen(); - GP_BackendFlip(win); + gp_backend_flip(win); start_angle += 0.01; if (start_angle > 2*M_PI) { diff --git a/demos/c_simple/loaders.c b/demos/c_simple/loaders.c index e9a3a306c1c3..68ab1901d708 100644 --- a/demos/c_simple/loaders.c +++ b/demos/c_simple/loaders.c @@ -30,14 +30,14 @@ #include <string.h> #include <errno.h> -#include <GP.h> +#include <gfxprim.h> struct callback_priv { char *op; char *name; }; -static int progress_callback(GP_ProgressCallback *self) +static int progress_callback(gp_progress_cb *self) { struct callback_priv *priv = self->priv; @@ -53,10 +53,10 @@ static int progress_callback(GP_ProgressCallback *self) int main(int argc, char *argv[]) { - GP_Pixmap *img; + gp_pixmap *img; struct callback_priv priv; - GP_ProgressCallback callback = {.callback = progress_callback, - .priv = &priv}; + gp_progress_cb callback = {.callback = progress_callback, + .priv = &priv}; if (argc != 2) { fprintf(stderr, "Takes an image as an parameter\n"); @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) priv.op = "Loading"; priv.name = argv[1]; - img = GP_LoadImage(argv[1], &callback); + img = gp_load_image(argv[1], &callback); if (img == NULL) { fprintf(stderr, "Failed to load image '%s':%s\n", argv[1], @@ -80,7 +80,7 @@ int main(int argc, char *argv[]) priv.op = "Saving"; priv.name = "out.png"; - if (GP_SavePNG(img, "out.png", &callback)) { + if (gp_save_png(img, "out.png", &callback)) { fprintf(stderr, "Failed to save image %s", strerror(errno)); return 1; } diff --git a/demos/c_simple/loaders_example.c b/demos/c_simple/loaders_example.c index b240aea952aa..7f74289ba8c8 100644 --- a/demos/c_simple/loaders_example.c +++ b/demos/c_simple/loaders_example.c @@ -30,21 +30,21 @@ #include <string.h> #include <errno.h> -#include <GP.h> +#include <gfxprim.h> int main(int argc, char *argv[]) { - GP_Pixmap *img; + gp_pixmap *img; /* Turn on debug messages */ - GP_SetDebugLevel(10); + gp_set_debug_level(10); if (argc != 2) { fprintf(stderr, "Takes an image as an parameter\n"); return 1; } - img = GP_LoadImage(argv[1], NULL); + img = gp_load_image(argv[1], NULL); if (img == NULL) { fprintf(stderr, "Failed to load image '%s':%s\n", argv[1], @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) return 1; } - if (GP_SavePNG(img, "out.png", NULL)) { + if (gp_save_png(img, "out.png", NULL)) { fprintf(stderr, "Failed to save image %s", strerror(errno)); return 1; } diff --git a/demos/c_simple/loaders_register.c b/demos/c_simple/loaders_register.c index cc2c0a15adba..c53218d05bed 100644 --- a/demos/c_simple/loaders_register.c +++ b/demos/c_simple/loaders_register.c @@ -32,15 +32,15 @@ #include <string.h> #include <errno.h> -#include <GP.h> +#include <gfxprim.h> /* * Saves 2 bpp grayscale image as ASCII Art */ -static int write_data(const GP_Pixmap *img, GP_IO *io, - GP_ProgressCallback *callback) +static int write_data(const gp_pixmap *img, gp_io *io, + gp_progress_cb *callback) { - GP_IO *bio; + gp_io *bio; int err; if (img->pixel_type != GP_PIXEL_G2) { @@ -49,7 +49,7 @@ static int write_data(const GP_Pixmap *img, GP_IO *io, } /* Create buffered I/O */ - bio = GP_IOWBuffer(io, 0); + bio = gp_io_wbuffer(io, 0); if (!bio) return 1; @@ -58,20 +58,20 @@ static int write_data(const GP_Pixmap *img, GP_IO *io, for (j = 0; j < img->h; j++) { for (i = 0; i < img->w; i++) { - GP_Pixel p = GP_GetPixel_Raw(img, i, j); + gp_pixel p = gp_getpixel_raw(img, i, j); switch (p) { case 0: - err = GP_IOFlush(bio, " ", 2); + err = gp_io_flush(bio, " ", 2); break; case 1: - err = GP_IOFlush(bio, "..", 2); + err = gp_io_flush(bio, "..", 2); break; case 2: - err = GP_IOFlush(bio, "()", 2); + err = gp_io_flush(bio, "()", 2); break; case 3: - err = GP_IOFlush(bio, "OO", 2); + err = gp_io_flush(bio, "OO", 2); break; } @@ -79,25 +79,25 @@ static int write_data(const GP_Pixmap *img, GP_IO *io, return 1; } - if (GP_IOFlush(bio, "\n", 1)) + if (gp_io_flush(bio, "\n", 1)) return 1; - if (GP_ProgressCallbackReport(callback, j, img->h, img->w)) { + if (gp_progress_cb_report(callback, j, img->h, img->w)) { errno = ECANCELED; return 1; } } - GP_ProgressCallbackDone(callback); + gp_progress_cb_done(callback); return 0; } -static GP_PixelType save_ptypes[] = { +static gp_pixel_type save_ptypes[] = { GP_PIXEL_G2, GP_PIXEL_UNKNOWN, }; -GP_Loader loader = { +const gp_loader loader = { .Write = write_data, .save_ptypes = save_ptypes, .fmt_name = "ASCII Art", @@ -106,12 +106,12 @@ GP_Loader loader = { int main(int argc, char *argv[]) { - GP_Pixmap *c, *gc; + gp_pixmap *c, *gc; - GP_LoaderRegister(&loader); + gp_loader_register(&loader); /* List all loaders */ - GP_ListLoaders(); + gp_loaders_lists(); printf("\n\n"); if (argc != 2) { @@ -120,14 +120,14 @@ int main(int argc, char *argv[]) } /* Now load image and save it using our loader */ - c = GP_LoadImage(argv[1], NULL); + c = gp_load_image(argv[1], NULL); if (c == NULL) { fprintf(stderr, "Failed to load image: %s\n", strerror(errno)); return 1; } - gc = GP_FilterFloydSteinbergAlloc(c, GP_PIXEL_G2, NULL); + gc = gp_filter_floyd_steinberg_alloc(c, GP_PIXEL_G2, NULL); if (gc == NULL) { fprintf(stderr, "FloydSteinberg: %s\n", strerror(errno)); @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) printf("Saving to test.txt\n"); - if (GP_SaveImage(gc, "test.txt", NULL)) { + if (gp_save_image(gc, "test.txt", NULL)) { fprintf(stderr, "Failed to save image: %s\n", strerror(errno)); return 1; } diff --git a/demos/c_simple/memory_io.c b/demos/c_simple/memory_io.c index 57d09174473f..43aa53f805f7 100644 --- a/demos/c_simple/memory_io.c +++ b/demos/c_simple/memory_io.c @@ -27,7 +27,7 @@ */ #include <stdio.h> -#include <GP.h> +#include <gfxprim.h> /* * Binary PGM stored in an array @@ -55,48 +55,48 @@ static char pgm[] = { int main(void) { - GP_Backend *b; - GP_Pixmap *img; - GP_IO *io; + gp_backend *b; + gp_pixmap *img; + gp_io *io; - io = GP_IOMem(pgm, sizeof(pgm), NULL); + io = gp_io_mem(pgm, sizeof(pgm), NULL); if (!io) { fprintf(stderr, "Failed to initialize IO\n"); return 1; } - img = GP_ReadPGM(io, NULL); - GP_IOClose(io); + img = gp_read_pgm(io, NULL); + gp_io_close(io); if (!img) { fprintf(stderr, "Failed to load image\n"); return 1; } - b = GP_BackendX11Init(NULL, 0, 0, WIN_W, WIN_H, "IO Example", 0); + b = gp_x11_init(NULL, 0, 0, WIN_W, WIN_H, "IO Example", 0); if (!b) { fprintf(stderr, "Failed to initialize backend\n"); return 1; } - GP_Fill(b->pixmap, 0); - GP_Blit_Clipped(img, 0, 0, img->w, img->h, b->pixmap, + gp_fill(b->pixmap, 0); + gp_blit_clipped(img, 0, 0, img->w, img->h, b->pixmap, (WIN_W - img->w)/2, (WIN_H - img->h)/2); - GP_BackendFlip(b); + gp_backend_flip(b); for (;;) { - GP_Event ev; + gp_event ev; - GP_BackendWaitEvent(b, &ev); + gp_backend_wait_event(b, &ev); switch (ev.type) { case GP_EV_KEY: switch (ev.val.val) { case GP_KEY_ESC: case GP_KEY_Q: - GP_BackendExit(b); + gp_backend_exit(b); return 0; break; } @@ -105,7 +105,7 @@ int main(void) switch (ev.code) { case GP_EV_SYS_RESIZE: case GP_EV_SYS_QUIT: - GP_BackendExit(b); + gp_backend_exit(b); return 0; break; } @@ -113,6 +113,6 @@ int main(void) } } - GP_BackendExit(b); + gp_backend_exit(b); return 0; } diff --git a/demos/c_simple/meta_data.c b/demos/c_simple/meta_data.c index 2e21781833b8..57a0b448f641 100644 --- a/demos/c_simple/meta_data.c +++ b/demos/c_simple/meta_data.c @@ -30,14 +30,14 @@ #include <string.h> #include <errno.h> -#include <GP.h> +#include <gfxprim.h> #define SEP \ "-----------------------------------------------------------------------------" int main(int argc, char *argv[]) { - GP_DataStorage *storage; + gp_storage *storage; int i; if (argc < 2) { @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) return 1; } - storage = GP_DataStorageCreate(); + storage = gp_storage_create(); if (!storage) { fprintf(stderr, "Failed to create data storage\n"); @@ -56,13 +56,13 @@ int main(int argc, char *argv[]) puts(SEP); printf("Opening '%s'\n", argv[i]); - GP_DataStorageClear(storage); + gp_storage_clear(storage); - if (GP_LoadMetaData(argv[i], storage)) { + if (gp_load_meta_data(argv[i], storage)) { fprintf(stderr, "Failed to read '%s' meta-data: %s\n", argv[i], strerror(errno)); } else { - GP_DataStoragePrint(storage); + gp_storage_print(storage); } } diff --git a/demos/c_simple/pretty_print.c b/demos/c_simple/pretty_print.c index ddd79bbacd25..c068dc9d79cb 100644 --- a/demos/c_simple/pretty_print.c +++ b/demos/c_simple/pretty_print.c @@ -26,18 +26,18 @@ */ -#include <GP.h> +#include <gfxprim.h> int main(void) { - GP_Pixmap *pixmap = GP_PixmapAlloc(100, 100, GP_PIXEL_RGB888); - GP_Pixel pix = ~(GP_Pixel)0; + gp_pixmap *pixmap = gp_pixmap_alloc(100, 100, GP_PIXEL_RGB888); + gp_pixel pix = ~(gp_pixel)0; /* Pretty prints pixel values */ - GP_PixelPrint(pix, GP_PIXEL_RGB888); + gp_pixel_print(pix, GP_PIXEL_RGB888); /* Pretty prints pixmap info */ - GP_PixmapPrintInfo(pixmap); + gp_pixmap_print_info(pixmap); return 0; } diff --git a/demos/c_simple/randomshapetest.c b/demos/c_simple/randomshapetest.c index 766b48e5ee92..e8a469be2d99 100644 --- a/demos/c_simple/randomshapetest.c +++ b/demos/c_simple/randomshapetest.c @@ -26,12 +26,12 @@ #include <stdio.h> #include <stdlib.h> -#include <GP.h> +#include <gfxprim.h> -static GP_Backend *win; +static gp_backend *win; /* Globally used colors. */ -static GP_Pixel white, black; +static gp_pixel white, black; /* Holding flag (pauses drawing). */ static int pause_flag = 0; @@ -56,7 +56,7 @@ static int fill_flag = 1; /* Do a clipping test? */ static int cliptest_flag = 0; -void random_point(const GP_Pixmap *c, int *x, int *y) +void random_point(const gp_pixmap *c, int *x, int *y) { if (cliptest_flag) { *x = random() % (3*c->w) - c->w; @@ -67,26 +67,26 @@ void random_point(const GP_Pixmap *c, int *x, int *y) } } -void random_point_AA(const GP_Pixmap *c, int *x, int *y) +void random_point_AA(const gp_pixmap *c, int *x, int *y) { *x = random() % (c->w<<8); *y = random() % (c->h<<8); } -void draw_random_circle(GP_Pixel pixel) +void draw_random_circle(gp_pixel pixel) { int x, y; random_point(win->pixmap, &x, &y); int r = random() % 50; if (fill_flag) - GP_FillCircle(win->pixmap, x, y, r, pixel); + gp_fill_circle(win->pixmap, x, y, r, pixel); if (outline_flag) - GP_Circle(win->pixmap, x, y, r, white); + gp_circle(win->pixmap, x, y, r, white); } -void draw_random_ellipse(GP_Pixel pixel) +void draw_random_ellipse(gp_pixel pixel) { int x, y; random_point(win->pixmap, &x, &y); @@ -94,13 +94,13 @@ void draw_random_ellipse(GP_Pixel pixel) int ry = random() % 50; if (fill_flag) - GP_FillEllipse(win->pixmap, x, y, rx, ry, pixel); + gp_fill_ellipse(win->pixmap, x, y, rx, ry, pixel); if (outline_flag) - GP_Ellipse(win->pixmap, x, y, rx, ry, white); + gp_ellipse(win->pixmap, x, y, rx, ry, white); } -void draw_random_triangle(GP_Pixel pixel) +void draw_random_triangle(gp_pixel pixel) { int x0, y0, x1, y1, x2, y2; random_point(win->pixmap, &x0, &y0); @@ -108,26 +108,26 @@ void draw_random_triangle(GP_Pixel pixel) random_point(win->pixmap, &x2, &y2); if (fill_flag) - GP_FillTriangle(win->pixmap, x0, y0, x1, y1, x2, y2, pixel); + gp_fill_triangle(win->pixmap, x0, y0, x1, y1, x2, y2, pixel); if (outline_flag) - GP_Triangle(win->pixmap, x0, y0, x1, y1, x2, y2, white); + gp_triangle(win->pixmap, x0, y0, x1, y1, x2, y2, white); } -void draw_random_rectangle(GP_Pixel pixel) +void draw_random_rectangle(gp_pixel pixel) { int x0, y0, x1, y1; random_point(win->pixmap, &x0, &y0); random_point(win->pixmap, &x1, &y1); if (fill_flag) - GP_FillRect(win->pixmap, x0, y0, x1, y1, pixel); + gp_fill_rect(win->pixmap, x0, y0, x1, y1, pixel); if (outline_flag) - GP_Rect(win->pixmap, x0, y0, x1, y1, white); + gp_rect(win->pixmap, x0, y0, x1, y1, white); } -void draw_random_tetragon(GP_Pixel pixel) +void draw_random_tetragon(gp_pixel pixel) { int x0, y0, x1, y1, x2, y2, x3, y3; random_point(win->pixmap, &x0, &y0); @@ -136,28 +136,28 @@ void draw_random_tetragon(GP_Pixel pixel) random_point(win->pixmap, &x3, &y3); if (fill_flag) - GP_FillTetragon(win->pixmap, x0, y0, x1, y1, x2, y2, x3, y3, pixel); + gp_fill_tetragon(win->pixmap, x0, y0, x1, y1, x2, y2, x3, y3, pixel); if (outline_flag) - GP_Tetragon(win->pixmap, x0, y0, x1, y1, x2, y2, x3, y3, pixel); + gp_tetragon(win->pixmap, x0, y0, x1, y1, x2, y2, x3, y3, pixel); } -void draw_random_polygon(GP_Pixel pixel) +void draw_random_polygon(gp_pixel pixel) { - GP_Coord xy[10]; + gp_coord xy[10]; int i; for (i = 0; i < 5; i++) { random_point(win->pixmap, xy + 2*i, xy + 2*i + 1); } - GP_FillPolygon_Raw(win->pixmap, 5, xy, pixel); + gp_fill_polygon_raw(win->pixmap, 5, xy, pixel); } void clear_screen(void) { - GP_Fill(win->pixmap, black); - GP_BackendFlip(win); + gp_fill(win->pixmap, black); + gp_backend_flip(win); } void redraw_screen(void) @@ -166,8 +166,8 @@ void redraw_screen(void) return; /* Pick a random color for drawing. */ - GP_Pixel pixel; - pixel = GP_RGBToPixel(random() % 256, random() % 256, + gp_pixel pixel; + pixel = gp_rgb_to_pixel(random() % 256, random() % 256, random() % 256, win->pixmap->pixel_type); switch (shape) { @@ -194,9 +194,9 @@ void redraw_screen(void) void event_loop(void) { - GP_Event ev; + gp_event ev; - while (GP_BackendGetEvent(win, &ev)) { + while (gp_backend_get_event(win, &ev)) { switch (ev.type) { case GP_EV_KEY: if (ev.code != GP_EV_KEY_DOWN) @@ -230,16 +230,16 @@ void event_loop(void) clear_screen(); break; case GP_KEY_ESC: - GP_BackendExit(win); + gp_backend_exit(win); exit(0); break; } break; case GP_EV_SYS: if (ev.code == GP_EV_SYS_RESIZE) { - GP_BackendResizeAck(win); + gp_backend_resize_ack(win); clear_screen(); - GP_BackendFlip(win); + gp_backend_flip(win); } break; } @@ -250,7 +250,7 @@ int main(void) { const char *backend_opts = "X11"; - win = GP_BackendInit(backend_opts, "Random Shape Test"); + win = gp_backend_init(backend_opts, "Random Shape Test"); if (win == NULL) { fprintf(stderr, "Failed to initalize backend '%s'\n", @@ -258,11 +258,11 @@ int main(void) return 1; } - white = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win->pixmap); - black = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win->pixmap); + white = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0xff, win->pixmap); + black = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, win->pixmap); for (;;) { - GP_BackendPoll(win); + gp_backend_poll(win); event_loop(); usleep(20000); @@ -271,7 +271,7 @@ int main(void) continue; redraw_screen(); - GP_BackendFlip(win); + gp_backend_flip(win); } } diff --git a/demos/c_simple/shapetest.c b/demos/c_simple/shapetest.c index 71d82c85af60..4819e37f5522 100644 --- a/demos/c_simple/shapetest.c +++ b/demos/c_simple/shapetest.c @@ -26,13 +26,13 @@ #include <stdio.h> #include <stdlib.h> -#include <GP.h> +#include <gfxprim.h> -static GP_Pixmap *win; -static GP_Backend *backend; +static gp_pixmap *win; +static gp_backend *backend; /* Basic colors in display-specific format. */ -static GP_Pixel black, white, yellow, green, red, gray, darkgray; +static gp_pixel black, white, yellow, green, red, gray, darkgray; /* Radius of the shape being drawn */ static int xradius = 5; @@ -109,61 +109,61 @@ void draw_testing_triangle(int x, int y, int xradius, int yradius) /* draw the three vertices green; they should never be visible * because the red triangle should cover them; if they are visible, * it means we don't draw to the end */ - GP_PutPixel(win, x0, y0, green); - GP_PutPixel(win, x1, y1, green); - GP_PutPixel(win, x2, y2, green); + gp_putpixel(win, x0, y0, green); + gp_putpixel(win, x1, y1, green); + gp_putpixel(win, x2, y2, green); if (outline == 1) - GP_Triangle(win, x0, y0, x1, y1, x2, y2, yellow); + gp_triangle(win, x0, y0, x1, y1, x2, y2, yellow); if (fill) - GP_FillTriangle(win, x0, y0, x1, y1, x2, y2, red); + gp_fill_triangle(win, x0, y0, x1, y1, x2, y2, red); if (outline == 2) - GP_Triangle(win, x0, y0, x1, y1, x2, y2, white); + gp_triangle(win, x0, y0, x1, y1, x2, y2, white); } void draw_testing_circle(int x, int y, int xradius, __attribute__((unused)) int yradius) { if (outline == 1) - GP_Circle(win, x, y, xradius, yellow); + gp_circle(win, x, y, xradius, yellow); if (fill) - GP_FillCircle(win, x, y, xradius, red); + gp_fill_circle(win, x, y, xradius, red); if (outline == 2) - GP_Circle(win, x, y, xradius, white); + gp_circle(win, x, y, xradius, white); } void draw_testing_ring(int x, int y, int xradius, __attribute__((unused)) int yradius) { if (outline == 1) - GP_Ring(win, x, y, xradius, yradius, yellow); + gp_ring(win, x, y, xradius, yradius, yellow); if (fill) - GP_FillRing(win, x, y, xradius, yradius, red); + gp_fill_ring(win, x, y, xradius, yradius, red); if (outline == 2) - GP_Ring(win, x, y, xradius, yradius, white); + gp_ring(win, x, y, xradius, yradius, white); } void draw_testing_ellipse(int x, int y, int xradius, int yradius) { if (outline == 1) - GP_Ellipse(win, x, y, xradius, yradius, yellow); + gp_ellipse(win, x, y, xradius, yradius, yellow); if (fill) - GP_FillEllipse(win, x, y, xradius, yradius, red); + gp_fill_ellipse(win, x, y, xradius, yradius, red); if (outline == 2) - GP_Ellipse(win, x, y, xradius, yradius, white); + gp_ellipse(win, x, y, xradius, yradius, white); } void draw_testing_arc(int x, int y, int xradius, int yradius) { - GP_ArcSegment(win, x, y, xradius, yradius, -1, + gp_arc_segment(win, x, y, xradius, yradius, -1, M_PI - M_PI/8.0, M_PI/4.0, red); } @@ -173,13 +173,13 @@ void draw_testing_rectangle(int x, int y, int xradius, int yradius) int x1 = x + xradius, y1 = y + yradius; if (outline == 1) - GP_Rect(win, x0, y0, x1, y1, yellow); + gp_rect(win, x0, y0, x1, y1, yellow); if (fill) - GP_FillRect(win, x0, y0, x1, y1, red); + gp_fill_rect(win, x0, y0, x1, y1, red); if (outline == 2) - GP_Rect(win, x0, y0, x1, y1, white); + gp_rect(win, x0, y0, x1, y1, white); } void draw_testing_tetragon(int x, int y, int xradius, int yradius) @@ -190,18 +190,18 @@ void draw_testing_tetragon(int x, int y, int xradius, int yradius) int x3 = x, y3 = y + yradius; if (outline == 1) - GP_Tetragon(win, x0, y0, x1, y1, x2, y2, x3, y3, yellow); + gp_tetragon(win, x0, y0, x1, y1, x2, y2, x3, y3, yellow); if (fill) - GP_FillTetragon(win, x0, y0, x1, y1, x2, y2, x3, y3, red); + gp_fill_tetragon(win, x0, y0, x1, y1, x2, y2, x3, y3, red); if (outline == 2) - GP_Tetragon(win, x0, y0, x1, y1, x2, y2, x3, y3, white); + gp_tetragon(win, x0, y0, x1, y1, x2, y2, x3, y3, white); } void draw_testing_polygon(int x, int y, int xradius, int yradius) { - GP_Coord xy[14]; + gp_coord xy[14]; unsigned int edges = 7; xy[0] = x + xradius; @@ -226,42 +226,42 @@ void draw_testing_polygon(int x, int y, int xradius, int yradius) xy[13] = y - yradius / 4; if (outline == 1) - GP_Polygon(win, edges, xy, yellow); + gp_polygon(win, edges, xy, yellow); if (fill) - GP_FillPolygon(win, edges, xy, red); + gp_fill_polygon(win, edges, xy, red); if (outline == 2) - GP_Polygon(win, edges, xy, white); + gp_polygon(win, edges, xy, white); } void redraw_screen(void) { /* text style for the label */ - GP_TextStyle style = { - .font = &GP_DefaultConsoleFont, + gp_text_style style = { + .font = gp_font_gfxprim_mono, .pixel_xmul = 2, .pixel_ymul = 1, .pixel_xspace = 0, .pixel_yspace = 1, }; - GP_Fill(win, black); + gp_fill(win, black); /* axes */ if (show_axes) { int w, h; - w = GP_PixmapW(win); - h = GP_PixmapH(win); + w = gp_pixmap_w(win); + h = gp_pixmap_h(win); - GP_HLine(win, 0, w, center_y, gray); - GP_HLine(win, 0, w, center_y-yradius, darkgray); - GP_HLine(win, 0, w, center_y+yradius, darkgray); - GP_VLine(win, center_x, 0, h, gray); - GP_VLine(win, center_x-xradius, 0, h, darkgray); - GP_VLine(win, center_x+xradius, 0, h, darkgray); + gp_hline(win, 0, w, center_y, gray); + gp_hline(win, 0, w, center_y-yradius, darkgray); + gp_hline(win, 0, w, center_y+yradius, darkgray); + gp_vline(win, center_x, 0, h, gray); + gp_vline(win, center_x-xradius, 0, h, darkgray); + gp_vline(win, center_x+xradius, 0, h, darkgray); } /* the shape */ @@ -301,16 +301,16 @@ void redraw_screen(void) break; } - GP_Text(win, &style, 16, 16, GP_ALIGN_RIGHT|GP_VALIGN_BELOW, + gp_text(win, &style, 16, 16, GP_ALIGN_RIGHT|GP_VALIGN_BELOW, white, black, title); - GP_BackendFlip(backend); + gp_backend_flip(backend); } static void xradius_add(int xradius_add) { if (xradius + xradius_add > 1 && - xradius + xradius_add < (int)GP_PixmapW(win)) + xradius + xradius_add < (int) gp_pixmap_w(win)) xradius += xradius_add; } @@ -318,21 +318,21 @@ static void xradius_add(int xradius_add) static void yradius_add(int yradius_add) { if (yradius + yradius_add > 1 && - yradius + yradius_add < (int)GP_PixmapH(win)) + yradius + yradius_add < (int) gp_pixmap_h(win)) yradius += yradius_add; } static void xcenter_add(int xcenter_add) { if (center_x + xcenter_add > 1 && - center_x + xcenter_add < (int)GP_PixmapW(win)/2) + center_x + xcenter_add < (int) gp_pixmap_w(win)/2) center_x += xcenter_add; } static void ycenter_add(int ycenter_add) { if (center_y + ycenter_add > 1 && - center_y + ycenter_add < (int)GP_PixmapH(win)/2) + center_y + ycenter_add < (int) gp_pixmap_h(win)/2) center_y += ycenter_add; } @@ -340,15 +340,15 @@ void event_loop(void) { int shift_pressed; - GP_Event ev; + gp_event ev; for (;;) { - GP_BackendWaitEvent(backend, &ev); + gp_backend_wait_event(backend, &ev); - //GP_EventDump(&ev); + //gp_eventDump(&ev); - shift_pressed = GP_EventGetKey(&ev, GP_KEY_LEFT_SHIFT) || - GP_EventGetKey(&ev, GP_KEY_RIGHT_SHIFT); + shift_pressed = gp_event_get_key(&ev, GP_KEY_LEFT_SHIFT) || + gp_event_get_key(&ev, GP_KEY_RIGHT_SHIFT); switch (ev.type) { case GP_EV_KEY: @@ -364,8 +364,8 @@ void event_loop(void) break; case GP_KEY_R: win->axes_swap = !win->axes_swap; - center_x = GP_PixmapW(win) / 2; - center_y = GP_PixmapH(win) / 2; + center_x = gp_pixmap_w(win) / 2; + center_y = gp_pixmap_h(win) / 2; break; case GP_KEY_F: fill = !fill; @@ -438,7 +438,7 @@ void event_loop(void) yradius_add(-1); break; case GP_KEY_ESC: - GP_BackendExit(backend); + gp_backend_exit(backend); exit(0); break; } @@ -446,14 +446,14 @@ void event_loop(void) case GP_EV_SYS: switch(ev.code) { case GP_EV_SYS_QUIT: - GP_BackendExit(backend); + gp_backend_exit(backend); exit(0); break; case GP_EV_SYS_RESIZE: - GP_BackendResizeAck(backend); + gp_backend_resize_ack(backend); win = backend->pixmap; - center_x = GP_PixmapW(win) / 2; - center_y = GP_PixmapH(win) / 2; + center_x = gp_pixmap_w(win) / 2; + center_y = gp_pixmap_h(win) / 2; break; } break; @@ -498,7 +498,7 @@ int main(int argc, char *argv[]) } } - backend = GP_BackendInit(backend_opts, "Shapetest"); + backend = gp_backend_init(backend_opts, "Shapetest"); if (backend == NULL) { fprintf(stderr, "Failed to initalize backend '%s'\n", @@ -512,13 +512,13 @@ int main(int argc, char *argv[]) center_y = win->h / 2; /* Load colors compatible with the display */ - black = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win); - white = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win); - yellow = GP_RGBToPixmapPixel(0xff, 0xff, 0x00, win); - green = GP_RGBToPixmapPixel(0x00, 0xff, 0x00, win); - red = GP_RGBToPixmapPixel(0xff, 0x00, 0x00, win); - gray = GP_RGBToPixmapPixel(0xbe, 0xbe, 0xbe, win); - darkgray = GP_RGBToPixmapPixel(0x7f, 0x7f, 0x7f, win); + black = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, win); + white = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0xff, win); + yellow = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0x00, win); + green = gp_rgb_to_pixmap_pixel(0x00, 0xff, 0x00, win); + red = gp_rgb_to_pixmap_pixel(0xff, 0x00, 0x00, win); + gray = gp_rgb_to_pixmap_pixel(0xbe, 0xbe, 0xbe, win); + darkgray = gp_rgb_to_pixmap_pixel(0x7f, 0x7f, 0x7f, win); print_instructions(); redraw_screen(); diff --git a/demos/c_simple/showimage.c b/demos/c_simple/showimage.c index 4208b201c0b5..d87491612fe6 100644 --- a/demos/c_simple/showimage.c +++ b/demos/c_simple/showimage.c @@ -30,12 +30,12 @@ #include <errno.h> #include <string.h> -#include <GP.h> +#include <gfxprim.h> int main(int argc, char *argv[]) { - GP_Backend *backend; - GP_Pixmap *image; + gp_backend *backend; + gp_pixmap *image; if (argc != 2) { fprintf(stderr, "Takes image as an argument\n"); @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) } /* Load image */ - image = GP_LoadImage(argv[1], NULL); + image = gp_load_image(argv[1], NULL); if (!image) { fprintf(stderr, "Failed to load bitmap: %s\n", strerror(errno)); @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) } /* Initalize backend */ - backend = GP_BackendX11Init(NULL, 0, 0, image->w, image->h, argv[1], 0); + backend = gp_x11_init(NULL, 0, 0, image->w, image->h, argv[1], 0); if (!backend) { fprintf(stderr, "Failed to initalize backend\n"); @@ -59,31 +59,31 @@ int main(int argc, char *argv[]) } /* Blit image into the window and show it */ - GP_Blit(image, 0, 0, image->w, image->h, backend->pixmap, 0, 0); - GP_BackendFlip(backend); + gp_blit(image, 0, 0, image->w, image->h, backend->pixmap, 0, 0); + gp_backend_flip(backend); /* Wait for events */ for (;;) { - GP_Event ev; + gp_event ev; - GP_BackendWaitEvent(backend, &ev); + gp_backend_wait_event(backend, &ev); if (ev.type == GP_EV_KEY && ev.val.val == GP_KEY_Q) { - GP_BackendExit(backend); + gp_backend_exit(backend); return 0; } if (ev.type == GP_EV_SYS && ev.code == GP_EV_SYS_RESIZE) { int cx, cy; - GP_BackendResizeAck(backend); + gp_backend_resize_ack(backend); cx = ((int)backend->pixmap->w - (int)image->w) / 2; cy = ((int)backend->pixmap->h - (int)image->h) / 2; - GP_Fill(backend->pixmap, 0); - GP_Blit_Clipped(image, 0, 0, image->w, image->h, backend->pixmap, cx, cy); - GP_BackendFlip(backend); + gp_fill(backend->pixmap, 0); + gp_blit_clipped(image, 0, 0, image->w, image->h, backend->pixmap, cx, cy); + gp_backend_flip(backend); } } diff --git a/demos/c_simple/textaligntest.c b/demos/c_simple/textaligntest.c index 9827ee6b96a0..1977cb1bdf5f 100644 --- a/demos/c_simple/textaligntest.c +++ b/demos/c_simple/textaligntest.c @@ -24,9 +24,9 @@ *****************************************************************************/ #include <stdio.h> -#include <GP.h> +#include <gfxprim.h> -static GP_Pixel black_pixel, red_pixel, yellow_pixel, green_pixel, blue_pixel, +static gp_pixel black_pixel, red_pixel, yellow_pixel, green_pixel, blue_pixel, darkgray_pixel, white_pixel; static int font_flag = 0; @@ -34,60 +34,60 @@ static int font_flag = 0; static int X = 640; static int Y = 480; -static GP_FontFace *font = NULL; -static GP_TextStyle style = GP_DEFAULT_TEXT_STYLE; +static gp_font_face *font = NULL; +static gp_text_style style = GP_DEFAULT_TEXT_STYLE; -static GP_Backend *win; +static gp_backend *win; void redraw_screen(void) { - GP_Fill(win->pixmap, black_pixel); + gp_fill(win->pixmap, black_pixel); /* draw axes intersecting in the middle, where text should be shown */ - GP_HLine(win->pixmap, 0, X, Y/2, darkgray_pixel); - GP_VLine(win->pixmap, X/2, 0, Y, darkgray_pixel); + gp_hline(win->pixmap, 0, X, Y/2, darkgray_pixel); + gp_vline(win->pixmap, X/2, 0, Y, darkgray_pixel); switch (font_flag) { case 0: - style.font = &GP_DefaultProportionalFont; + style.font = gp_font_gfxprim; break; case 1: - style.font = &GP_DefaultConsoleFont; + style.font = gp_font_gfxprim_mono; break; case 2: - style.font = GP_FontTinyMono; + style.font = gp_font_tiny_mono; break; case 3: - style.font = GP_FontTiny; + style.font = gp_font_tiny; break; case 4: - style.font = GP_FontC64; + style.font = gp_font_c64; break; case 5: style.font = font; break; } - GP_Text(win->pixmap, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_BELOW, + gp_text(win->pixmap, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_BELOW, yellow_pixel, black_pixel, "bottom left"); - GP_Text(win->pixmap, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_BELOW, + gp_text(win->pixmap, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_BELOW, red_pixel, black_pixel, "bottom right"); - GP_Text(win->pixmap, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_ABOVE, + gp_text(win->pixmap, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_ABOVE, blue_pixel, black_pixel, "top right"); - GP_Text(win->pixmap, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_ABOVE, + gp_text(win->pixmap, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_ABOVE, green_pixel, black_pixel, "top left"); - GP_HLine(win->pixmap, 0, X, Y/3, darkgray_pixel); - GP_Text(win->pixmap, &style, X/2, Y/3, GP_ALIGN_CENTER|GP_VALIGN_BASELINE, + gp_hline(win->pixmap, 0, X, Y/3, darkgray_pixel); + gp_text(win->pixmap, &style, X/2, Y/3, GP_ALIGN_CENTER|GP_VALIGN_BASELINE, white_pixel, black_pixel, "x center y baseline"); } static void event_loop(void) { - GP_Event ev; + gp_event ev; for (;;) { - GP_BackendWaitEvent(win, &ev); + gp_backend_wait_event(win, &ev); switch (ev.type) { case GP_EV_KEY: @@ -133,7 +133,7 @@ static void event_loop(void) style.pixel_ymul--; break; case GP_KEY_ESC: - GP_BackendExit(win); + gp_backend_exit(win); exit(0); break; } @@ -141,11 +141,11 @@ static void event_loop(void) case GP_EV_SYS: switch(ev.code) { case GP_EV_SYS_QUIT: - GP_BackendExit(win); + gp_backend_exit(win); exit(0); break; case GP_EV_SYS_RESIZE: - GP_BackendResizeAck(win); + gp_backend_resize_ack(win); X = win->pixmap->w; Y = win->pixmap->h; break; @@ -154,7 +154,7 @@ static void event_loop(void) } redraw_screen(); - GP_BackendFlip(win); + gp_backend_flip(win); } } @@ -174,11 +174,11 @@ int main(int argc, char *argv[]) const char *backend_opts = "X11"; if (argc > 1) - font = GP_FontFaceLoad(argv[1], 0, 20); + font = gp_font_face_load(argv[1], 0, 20); print_instructions(); - win = GP_BackendInit(backend_opts, "Font Align Test"); + win = gp_backend_init(backend_opts, "Font Align Test"); if (win == NULL) { fprintf(stderr, "Failed to initalize backend '%s'\n", @@ -186,16 +186,16 @@ int main(int argc, char *argv[]) return 1; } - black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win->pixmap); - red_pixel = GP_RGBToPixmapPixel(0xff, 0x00, 0x00, win->pixmap); - blue_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0xff, win->pixmap); - green_pixel = GP_RGBToPixmapPixel(0x00, 0xff, 0x00, win->pixmap); - yellow_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0x00, win->pixmap); - white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win->pixmap); - darkgray_pixel = GP_RGBToPixmapPixel(0x7f, 0x7f, 0x7f, win->pixmap); + black_pixel = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, win->pixmap); + red_pixel = gp_rgb_to_pixmap_pixel(0xff, 0x00, 0x00, win->pixmap); + blue_pixel = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0xff, win->pixmap); + green_pixel = gp_rgb_to_pixmap_pixel(0x00, 0xff, 0x00, win->pixmap); + yellow_pixel = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0x00, win->pixmap); + white_pixel = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0xff, win->pixmap); + darkgray_pixel = gp_rgb_to_pixmap_pixel(0x7f, 0x7f, 0x7f, win->pixmap); redraw_screen(); - GP_BackendFlip(win); + gp_backend_flip(win); event_loop(); return 0; diff --git a/demos/c_simple/timers.c b/demos/c_simple/timers.c index e98315374e4e..512617c189fe 100644 --- a/demos/c_simple/timers.c +++ b/demos/c_simple/timers.c @@ -26,7 +26,7 @@ */ -#include <GP.h> +#include <gfxprim.h> uint32_t callback1() { @@ -45,41 +45,41 @@ int main(void) GP_TIMER_DECLARE(oneshot, 30, 0, "Oneshot", callback1, NULL); GP_TIMER_DECLARE(recurrent, 0, 4, "Recurrent", callback1, NULL); GP_TIMER_DECLARE(random, 10, 0, "Random", callback3, NULL); - GP_Timer timers[MAX]; - GP_Timer *queue = NULL; + gp_timer timers[MAX]; + gp_timer *queue = NULL; uint64_t now; int i, ret; char ids[MAX][8]; - GP_SetDebugLevel(10); + gp_set_debug_level(10); - GP_TimerQueueInsert(&queue, 0, &oneshot); - GP_TimerQueueInsert(&queue, 0, &recurrent); - GP_TimerQueueInsert(&queue, 0, &random); + gp_timer_queue_insert(&queue, 0, &oneshot); + gp_timer_queue_insert(&queue, 0, &recurrent); + gp_timer_queue_insert(&queue, 0, &random); for (i = 0; i < MAX; i++) { timers[i].expires = MAX - i; timers[i].period = 0; - timers[i].Callback = callback1; + timers[i].callback = callback1; timers[i].priv = NULL; sprintf(ids[i], "Timer%i", MAX - i); timers[i].id = ids[i]; - GP_TimerQueueInsert(&queue, 0, &timers[i]); + gp_timer_queue_insert(&queue, 0, &timers[i]); } - GP_TimerQueueDump(queue); + gp_timer_queue_dump(queue); - GP_TimerQueueRemove(&queue, &timers[MAX-1]); + gp_timer_queue_remove(&queue, &timers[MAX-1]); - GP_TimerQueueDump(queue); + gp_timer_queue_dump(queue); for (now = 0; now < 100; now += 3) { printf("NOW %u\n", (unsigned int) now); printf("-------------------------------------\n"); - ret = GP_TimerQueueProcess(&queue, now); + ret = gp_timer_queue_process(&queue, now); printf("Processed %i timer events\n", ret); printf("--------------------------------------\n"); - GP_TimerQueueDump(queue); + gp_timer_queue_dump(queue); printf("--------------------------------------\n\n"); } diff --git a/demos/c_simple/v4l2_grab.c b/demos/c_simple/v4l2_grab.c index 6498fb82ae8f..87ef85a2e986 100644 --- a/demos/c_simple/v4l2_grab.c +++ b/demos/c_simple/v4l2_grab.c @@ -30,32 +30,32 @@ #include <errno.h> #include <stdio.h> -#include <GP.h> +#include <gfxprim.h> -static int get_image(const char *filename, GP_Grabber *grabber) +static int get_image(const char *filename, gp_grabber *grabber) { /* turn on grabber */ - if (GP_GrabberStart(grabber)) { + if (gp_grabber_start(grabber)) { fprintf(stderr, "Failed to start grabber\n"); return 1; } /* throw away first frame, it's usually wrong */ - while (!GP_GrabberPoll(grabber)) + while (!gp_grabber_poll(grabber)) usleep(100000); - while (!GP_GrabberPoll(grabber)) + while (!gp_grabber_poll(grabber)) usleep(100000); /* save image */ - if (GP_SaveJPG(grabber->frame, filename, NULL)) { + if (gp_save_jpg(grabber->frame, filename, NULL)) { fprintf(stderr, "Failed to save image '%s': %s", filename, strerror(errno)); return 1; } /* turn off grabber */ - if (GP_GrabberStop(grabber)) { + if (gp_grabber_stop(grabber)) { fprintf(stderr, "Failed to start grabber\n"); return 1; } @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) secs = atoi(optarg); break; case 'l': - GP_SetDebugLevel(atoi(optarg)); + gp_set_debug_level(atoi(optarg)); break; case 'h': printf("Usage; %s opts\n", argv[0]); @@ -108,7 +108,7 @@ int main(int argc, char *argv[]) } } - GP_Grabber *grabber = GP_GrabberV4L2Init(v4l2_device, w, h); + gp_grabber *grabber = gp_grabber_v4l2_init(v4l2_device, w, h); if (grabber == NULL) { fprintf(stderr, "Failed to initalize grabber '%s': %s\n", @@ -118,7 +118,7 @@ int main(int argc, char *argv[]) if (secs == 0) { get_image(image_filename, grabber); - GP_GrabberExit(grabber); + gp_grabber_exit(grabber); return 0; } @@ -137,6 +137,5 @@ int main(int argc, char *argv[]) sleep(secs); } - return 0; } diff --git a/demos/c_simple/v4l2_show.c b/demos/c_simple/v4l2_show.c index 5f5dacf86c72..6c5b0163ff49 100644 --- a/demos/c_simple/v4l2_show.c +++ b/demos/c_simple/v4l2_show.c @@ -30,12 +30,12 @@ #include <string.h> #include <stdio.h> -#include <GP.h> +#include <gfxprim.h> int main(int argc, char *argv[]) { - GP_Backend *backend; - GP_Grabber *grabber; + gp_backend *backend; + gp_grabber *grabber; const char *v4l2_device = "/dev/video0"; unsigned int w = 640, h = 480; int mode = 0; @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) h = atoi(optarg); break; case 'l': - GP_SetDebugLevel(atoi(optarg)); + gp_set_debug_level(atoi(optarg)); break; case 'h': printf("Usage; %s opts\n", argv[0]); @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) } } - grabber = GP_GrabberV4L2Init(v4l2_device, w, h); + grabber = gp_grabber_v4l2_init(v4l2_device, w, h); if (grabber == NULL) { fprintf(stderr, "Failed to initalize grabber '%s': %s\n", @@ -78,59 +78,59 @@ int main(int argc, char *argv[]) return 1; } - backend = GP_BackendX11Init(NULL, 0, 0, grabber->frame->w, + backend = gp_x11_init(NULL, 0, 0, grabber->frame->w, grabber->frame->h, "V4L2", 0); if (backend == NULL) { - GP_GrabberExit(grabber); + gp_grabber_exit(grabber); return 1; } - if (GP_GrabberStart(grabber)) { + if (gp_grabber_start(grabber)) { fprintf(stderr, "Failed to start grabber\n"); - GP_BackendExit(backend); - GP_GrabberExit(grabber); + gp_backend_exit(backend); + gp_grabber_exit(grabber); return 1; } printf("Press SPACE to change mode and Q to exit.\n"); for (;;) { - if (GP_GrabberPoll(grabber) > 0) { - GP_Pixmap *res, *img = grabber->frame; + if (gp_grabber_poll(grabber) > 0) { + gp_pixmap *res, *img = grabber->frame; switch (mode) { case 0: res = img; break; case 1: - // GP_FilterEdgePrewitt(img, &res, NULL, NULL); - GP_FilterEdgeSobel(img, &res, NULL, NULL); + // gp_filter_edge_prewitt(img, &res, NULL, NULL); + gp_filter_edge_sobel(img, &res, NULL, NULL); break; case 2: - GP_FilterGaussianBlur(img, img, 1, 1, NULL); - res = GP_FilterFloydSteinbergAlloc(img, GP_PIXEL_G2, NULL); + gp_filter_gaussian_blur(img, img, 1, 1, NULL); + res = gp_filter_floyd_steinberg_alloc(img, GP_PIXEL_G2, NULL); break; } unsigned int c_x = (backend->pixmap->w - res->w) / 2; unsigned int c_y = (backend->pixmap->h - res->h) / 2; - GP_Blit_Clipped(res, 0, 0, res->w, res->h, backend->pixmap, c_x, c_y); - GP_BackendFlip(backend); + gp_blit_clipped(res, 0, 0, res->w, res->h, backend->pixmap, c_x, c_y); + gp_backend_flip(backend); if (mode) - GP_PixmapFree(res); + gp_pixmap_free(res); } usleep(1000); - GP_BackendPoll(backend); + gp_backend_poll(backend); /* Read and parse events */ - GP_Event ev; + gp_event ev; - while (GP_BackendGetEvent(backend, &ev)) { + while (gp_backend_get_event(backend, &ev)) { switch (ev.type) { case GP_EV_KEY: @@ -141,8 +141,8 @@ int main(int argc, char *argv[]) switch (ev.val.key.key) { case GP_KEY_ESC: case GP_KEY_Q: - GP_BackendExit(backend); - GP_GrabberExit(grabber); + gp_backend_exit(backend); + gp_grabber_exit(grabber); return 0; break; case GP_KEY_SPACE: @@ -156,15 +156,15 @@ int main(int argc, char *argv[]) break; case GP_EV_SYS: if (ev.code == GP_EV_SYS_RESIZE) { - GP_BackendResizeAck(backend); - GP_Fill(backend->pixmap, 0); + gp_backend_resize_ack(backend); + gp_fill(backend->pixmap, 0); } break; } } } - GP_BackendExit(backend); + gp_backend_exit(backend); return 0; } diff --git a/demos/c_simple/version.c b/demos/c_simple/version.c index 874bf2bf5a3e..86d403d8ddb2 100644 --- a/demos/c_simple/version.c +++ b/demos/c_simple/version.c @@ -26,7 +26,7 @@ */ -#include <GP.h> +#include <gfxprim.h> int main(void) { diff --git a/demos/c_simple/virtual_backend_example.c b/demos/c_simple/virtual_backend_example.c index b1d8199f5b89..f77fe3624bb3 100644 --- a/demos/c_simple/virtual_backend_example.c +++ b/demos/c_simple/virtual_backend_example.c @@ -29,66 +29,66 @@ */ -#include <GP.h> +#include <gfxprim.h> -static GP_Pixel white_pixel, black_pixel, red_pixel, blue_pixel, green_pixel; +static gp_pixel white_pixel, black_pixel, red_pixel, blue_pixel, green_pixel; -static void redraw(GP_Backend *backend) +static void redraw(gp_backend *backend) { - GP_Pixmap *pixmap = backend->pixmap; + gp_pixmap *pixmap = backend->pixmap; /* Now draw some testing patters */ - black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); - white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, pixmap); - red_pixel = GP_RGBToPixmapPixel(0xff, 0x00, 0x00, pixmap); - blue_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0xff, pixmap); - green_pixel = GP_RGBToPixmapPixel(0x00, 0xff, 0x00, pixmap); + black_pixel = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, pixmap); + white_pixel = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0xff, pixmap); + red_pixel = gp_rgb_to_pixmap_pixel(0xff, 0x00, 0x00, pixmap); + blue_pixel = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0xff, pixmap); + green_pixel = gp_rgb_to_pixmap_pixel(0x00, 0xff, 0x00, pixmap); - GP_Fill(pixmap, white_pixel); + gp_fill(pixmap, white_pixel); unsigned int i, j; for (i = 0; i < 40; i++) { - GP_HLineXYW(pixmap, 0, i, i, black_pixel); - GP_HLineXYW(pixmap, 1, i + 40, i, black_pixel); - GP_HLineXYW(pixmap, 2, i + 80, i, black_pixel); - GP_HLineXYW(pixmap, 3, i + 120, i, black_pixel); - GP_HLineXYW(pixmap, 4, i + 160, i, black_pixel); - GP_HLineXYW(pixmap, 5, i + 200, i, black_pixel); - GP_HLineXYW(pixmap, 6, i + 240, i, black_pixel); - GP_HLineXYW(pixmap, 7, i + 280, i, black_pixel); + gp_hline_xyw(pixmap, 0, i, i, black_pixel); + gp_hline_xyw(pixmap, 1, i + 40, i, black_pixel); + gp_hline_xyw(pixmap, 2, i + 80, i, black_pixel); + gp_hline_xyw(pixmap, 3, i + 120, i, black_pixel); + gp_hline_xyw(pixmap, 4, i + 160, i, black_pixel); + gp_hline_xyw(pixmap, 5, i + 200, i, black_pixel); + gp_hline_xyw(pixmap, 6, i + 240, i, black_pixel); + gp_hline_xyw(pixmap, 7, i + 280, i, black_pixel); } for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { uint8_t val = 1.00 * sqrt(i*i + j*j)/sqrt(2) + 0.5; - GP_Pixel pix = GP_RGBToPixmapPixel(i, j, val, pixmap); - GP_PutPixel(pixmap, i + 60, j + 10, pix); + gp_pixel pix = gp_rgb_to_pixmap_pixel(i, j, val, pixmap); + gp_putpixel(pixmap, i + 60, j + 10, pix); } } - GP_Text(pixmap, NULL, 60, 270, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, + gp_text(pixmap, NULL, 60, 270, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, black_pixel, white_pixel, "Lorem Ipsum dolor sit..."); - GP_Text(pixmap, NULL, 60, 290, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, + gp_text(pixmap, NULL, 60, 290, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, red_pixel, white_pixel, "Lorem Ipsum dolor sit..."); - GP_Text(pixmap, NULL, 60, 310, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, + gp_text(pixmap, NULL, 60, 310, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, green_pixel, white_pixel, "Lorem Ipsum dolor sit..."); - GP_Text(pixmap, NULL, 60, 330, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, + gp_text(pixmap, NULL, 60, 330, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, blue_pixel, white_pixel, "Lorem Ipsum dolor sit..."); /* Update the backend screen */ - GP_BackendFlip(backend); + gp_backend_flip(backend); } int main(int argc, char *argv[]) { - GP_Backend *backend; + gp_backend *backend; const char *backend_opts = "X11:350x350"; int opt; - GP_PixelType emul_type = GP_PIXEL_UNKNOWN; + gp_pixel_type emul_type = GP_PIXEL_UNKNOWN; while ((opt = getopt(argc, argv, "b:h:p:")) != -1) { switch (opt) { @@ -96,7 +96,7 @@ int main(int argc, char *argv[]) backend_opts = optarg; break; case 'p': - emul_type = GP_PixelTypeByName(optarg); + emul_type = gp_pixel_type_by_name(optarg); if (emul_type == GP_PIXEL_UNKNOWN) { fprintf(stderr, "Invalid pixel type '%s'\n", optarg); @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) } break; case 'h': - GP_BackendInit("help", NULL); + gp_backend_init("help", NULL); return 0; break; default: @@ -114,12 +114,12 @@ int main(int argc, char *argv[]) } /* Turn on debug messages */ - GP_SetDebugLevel(10); + gp_set_debug_level(10); - backend = GP_BackendInit(backend_opts, "Virtual Backend Example"); + backend = gp_backend_init(backend_opts, "Virtual Backend Example"); if (emul_type != GP_PIXEL_UNKNOWN) { - GP_Backend *emul; + gp_backend *emul; /* * Create an emulated backend on the top of real backend. @@ -128,11 +128,11 @@ int main(int argc, char *argv[]) * emulated backend, the real backend exit will be called as * well. */ - emul = GP_BackendVirtualInit(backend, emul_type, GP_BACKEND_CALL_EXIT); + emul = gp_backend_virt_init(backend, emul_type, GP_BACKEND_CALL_EXIT); if (emul == NULL) { fprintf(stderr, "Failed to create Virtual Backend\n"); - GP_BackendExit(backend); + gp_backend_exit(backend); return 1; } @@ -143,24 +143,24 @@ int main(int argc, char *argv[]) redraw(backend); for (;;) { - if (backend->Poll) - GP_BackendPoll(backend); + if (backend->poll) + gp_backend_poll(backend); usleep(1000); /* Read and parse events */ - GP_Event ev; + gp_event ev; - while (GP_BackendGetEvent(backend, &ev)) { + while (gp_backend_get_event(backend, &ev)) { - GP_EventDump(&ev); + gp_event_dump(&ev); switch (ev.type) { case GP_EV_KEY: switch (ev.val.key.key) { case GP_KEY_ESC: case GP_KEY_Q: - GP_BackendExit(backend); + gp_backend_exit(backend); return 0; break; } @@ -168,7 +168,7 @@ int main(int argc, char *argv[]) case GP_EV_SYS: switch(ev.code) { case GP_EV_SYS_RESIZE: - GP_BackendResizeAck(backend); + gp_backend_resize_ack(backend); redraw(backend); break; } @@ -177,7 +177,7 @@ int main(int argc, char *argv[]) } } - GP_BackendExit(backend); + gp_backend_exit(backend); return 0; } diff --git a/demos/c_simple/weighted_median.c b/demos/c_simple/weighted_median.c index dc481603f9d5..b52247ded411 100644 --- a/demos/c_simple/weighted_median.c +++ b/demos/c_simple/weighted_median.c @@ -30,14 +30,14 @@ #include <string.h> #include <errno.h> -#include <GP.h> +#include <gfxprim.h> struct callback_priv { char *op; char *name; }; -static int progress_callback(GP_ProgressCallback *self) +static int progress_callback(gp_progress_cb *self) { struct callback_priv *priv = self->priv; @@ -53,9 +53,9 @@ static int progress_callback(GP_ProgressCallback *self) int main(int argc, char *argv[]) { - GP_Pixmap *img; + gp_pixmap *img; struct callback_priv priv; - GP_ProgressCallback callback = {.callback = progress_callback, + gp_progress_cb callback = {.callback = progress_callback, .priv = &priv}; if (argc != 2) { @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) priv.op = "Loading"; priv.name = argv[1]; - img = GP_LoadImage(argv[1], &callback); + img = gp_load_image(argv[1], &callback); if (img == NULL) { fprintf(stderr, "Failed to load image '%s': %s\n", argv[1], @@ -133,7 +133,7 @@ int main(int argc, char *argv[]) 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, }; - GP_MedianWeights weights = { + gp_median_weights weights = { .w = 11, .h = 11, .weights = circle, @@ -141,14 +141,14 @@ int main(int argc, char *argv[]) priv.op = "Weighted Median"; - GP_Pixmap *res = GP_FilterWeightedMedianAlloc(img, &weights, &callback); + gp_pixmap *res = gp_filter_weighted_median_alloc(img, &weights, &callback); printf("\n"); priv.op = "Saving"; priv.name = "out.png"; - if (GP_SavePNG(res, "out.png", &callback)) { + if (gp_save_png(res, "out.png", &callback)) { fprintf(stderr, "Failed to save image: %s", strerror(errno)); return 1; } diff --git a/demos/c_simple/x11_windows.c b/demos/c_simple/x11_windows.c index da9d8d8b8041..7364e1ebd268 100644 --- a/demos/c_simple/x11_windows.c +++ b/demos/c_simple/x11_windows.c @@ -27,39 +27,39 @@ */ #include <stdio.h> -#include <GP.h> +#include <gfxprim.h> -static void redraw(struct GP_Pixmap *pixmap) +static void redraw(struct gp_pixmap *pixmap) { - GP_Pixel white_pixel, black_pixel; + gp_pixel white_pixel, black_pixel; - black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); - white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, pixmap); + black_pixel = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, pixmap); + white_pixel = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0xff, pixmap); - GP_Fill(pixmap, black_pixel); - GP_Line(pixmap, 0, 0, pixmap->w - 1, pixmap->h - 1, white_pixel); - GP_Line(pixmap, 0, pixmap->h - 1, pixmap->w - 1, 0, white_pixel); + gp_fill(pixmap, black_pixel); + gp_line(pixmap, 0, 0, pixmap->w - 1, pixmap->h - 1, white_pixel); + gp_line(pixmap, 0, pixmap->h - 1, pixmap->w - 1, 0, white_pixel); } -static int ev_loop(struct GP_Backend *backend, const char *name) +static int ev_loop(struct gp_backend *backend, const char *name) { - GP_Event ev; + gp_event ev; if (backend == NULL) return 0; - while (GP_BackendGetEvent(backend, &ev)) { + while (gp_backend_get_event(backend, &ev)) { printf("-------------------------- %s\n", name); - GP_EventDump(&ev); + gp_event_dump(&ev); switch (ev.type) { case GP_EV_KEY: switch (ev.val.val) { case GP_KEY_ESC: case GP_KEY_Q: - GP_BackendExit(backend); + gp_backend_exit(backend); return 1; break; } @@ -67,12 +67,12 @@ static int ev_loop(struct GP_Backend *backend, const char *name) case GP_EV_SYS: switch (ev.code) { case GP_EV_SYS_RESIZE: - GP_BackendResizeAck(backend); + gp_backend_resize_ack(backend); redraw(backend->pixmap); - GP_BackendFlip(backend); + gp_backend_flip(backend); break; case GP_EV_SYS_QUIT: - GP_BackendExit(backend); + gp_backend_exit(backend); return 1; break; } @@ -87,14 +87,14 @@ static int ev_loop(struct GP_Backend *backend, const char *name) int main(void) { - GP_Backend *win_1, *win_2; + gp_backend *win_1, *win_2; - win_1 = GP_BackendX11Init(NULL, 0, 0, 300, 300, "win 1", 0); - win_2 = GP_BackendX11Init(NULL, 0, 0, 300, 300, "win 2", 0); + win_1 = gp_x11_init(NULL, 0, 0, 300, 300, "win 1", 0); + win_2 = gp_x11_init(NULL, 0, 0, 300, 300, "win 2", 0); if (win_1 == NULL || win_2 == NULL) { - GP_BackendExit(win_1); - GP_BackendExit(win_2); + gp_backend_exit(win_1); + gp_backend_exit(win_2); return 1; } @@ -102,8 +102,8 @@ int main(void) redraw(win_1->pixmap); redraw(win_2->pixmap); - GP_BackendFlip(win_1); - GP_BackendFlip(win_2); + gp_backend_flip(win_1); + gp_backend_flip(win_2); for (;;) { /* @@ -111,12 +111,12 @@ int main(void) * * Either window is fine as they share connection. */ - GP_Backend *b = win_1 ? win_1 : win_2; + gp_backend *b = win_1 ? win_1 : win_2; if (b == NULL) return 0; - GP_BackendWait(b); + gp_backend_wait(b); if (ev_loop(win_1, "win 1")) win_1 = NULL; @@ -125,8 +125,8 @@ int main(void) win_2 = NULL; } - GP_BackendExit(win_1); - GP_BackendExit(win_2); + gp_backend_exit(win_1); + gp_backend_exit(win_2); return 0; } diff --git a/demos/c_simple/zip_container.c b/demos/c_simple/zip_container.c index 4cf77fd9aef1..e277e53c4326 100644 --- a/demos/c_simple/zip_container.c +++ b/demos/c_simple/zip_container.c @@ -30,11 +30,11 @@ #include <errno.h> #include <string.h> -#include <GP.h> +#include <gfxprim.h> -static GP_Backend *backend; -static GP_Pixmap *image; -static GP_Container *container; +static gp_backend *backend; +static gp_pixmap *image; +static gp_container *container; /* * Try to load next image in container, if image has different size than the @@ -45,21 +45,21 @@ static GP_Container *container; */ static void load_next(void) { - GP_PixmapFree(image); + gp_pixmap_free(image); - image = GP_ContainerLoadNext(container, NULL); + image = gp_container_load_next(container, NULL); if (image == NULL) return; if (image->w != backend->pixmap->w || image->h != backend->pixmap->h) { - GP_BackendResize(backend, image->w, image->h); + gp_backend_resize(backend, image->w, image->h); return; } - GP_Blit_Clipped(image, 0, 0, image->w, image->h, backend->pixmap, 0, 0); - GP_BackendFlip(backend); + gp_blit_clipped(image, 0, 0, image->w, image->h, backend->pixmap, 0, 0); + gp_backend_flip(backend); } int main(int argc, char *argv[]) @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) } /* Open zip container */ - container = GP_OpenZip(argv[1]); + container = gp_open_zip(argv[1]); if (container == NULL) { fprintf(stderr, "Failed to open container: %s\n", strerror(errno)); @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) } /* Load image */ - image = GP_ContainerLoadNext(container, NULL); + image = gp_container_load_next(container, NULL); if (image == NULL) { fprintf(stderr, "Failed to load image %s\n", strerror(errno)); @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) } /* Initalize backend */ - backend = GP_BackendX11Init(NULL, 0, 0, image->w, image->h, argv[1], 0); + backend = gp_x11_init(NULL, 0, 0, image->w, image->h, argv[1], 0); if (backend == NULL) { fprintf(stderr, "Failed to initalize backend\n"); @@ -95,23 +95,23 @@ int main(int argc, char *argv[]) } /* Blit image into the window and show it */ - GP_Blit_Clipped(image, 0, 0, image->w, image->h, backend->pixmap, 0, 0); - GP_BackendFlip(backend); + gp_blit_clipped(image, 0, 0, image->w, image->h, backend->pixmap, 0, 0); + gp_backend_flip(backend); /* Wait for events */ for (;;) { - GP_Event ev; + gp_event ev; - GP_BackendWaitEvent(backend, &ev); + gp_backend_wait_event(backend, &ev); switch (ev.type) { case GP_EV_KEY: - if (!ev.code == GP_EV_KEY_DOWN) + if (!(ev.code == GP_EV_KEY_DOWN)) continue; switch (ev.val.val) { case GP_KEY_Q: - GP_BackendExit(backend); + gp_backend_exit(backend); return 0; break; case GP_KEY_SPACE: @@ -121,10 +121,10 @@ int main(int argc, char *argv[]) break; case GP_EV_SYS: if (ev.code == GP_EV_SYS_RESIZE) { - GP_BackendResizeAck(backend); - GP_Blit_Clipped(image, 0, 0, image->w, image->h, + gp_backend_resize_ack(backend); + gp_blit_clipped(image, 0, 0, image->w, image->h, backend->pixmap, 0, 0); - GP_BackendFlip(backend); + gp_backend_flip(backend); } break; } diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index fe40e2529e2a..79dbfd98b6f4 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -26,16 +26,16 @@ #include <string.h> #include <errno.h> -#include "GP.h" +#include "gfxprim.h" #include "params.h" #include "histogram.h" -static GP_ProgressCallback *progress_callback = NULL; +static gp_progress_cb *progress_callback = NULL; static const char *progress_prefix = NULL; -static int show_progress(GP_ProgressCallback *self) +static int show_progress(gp_progress_cb *self) { fprintf(stderr, "\r%s %3.2f%%", progress_prefix, self->percentage); @@ -106,7 +106,7 @@ static struct param resize_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int resize(GP_Pixmap **c, const char *params) +static int resize(gp_pixmap **c, const char *params) { int alg = 1; float ratio = -1; @@ -120,16 +120,16 @@ static int resize(GP_Pixmap **c, const char *params) return EINVAL; } - GP_Size w = ratio * (*c)->w; - GP_Size h = ratio * (*c)->h; - GP_Pixmap *res = NULL; + gp_size w = ratio * (*c)->w; + gp_size h = ratio * (*c)->h; + gp_pixmap *res = NULL; - res = GP_FilterResizeAlloc(*c, w, h, alg, progress_callback); + res = gp_filter_resize_alloc(*c, w, h, alg, progress_callback); if (res == NULL) return EINVAL; - GP_PixmapFree(*c); + gp_pixmap_free(*c); *c = res; return 0; @@ -164,7 +164,7 @@ static struct param scale_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int scale(GP_Pixmap **c, const char *params) +static int scale(gp_pixmap **c, const char *params) { int alg = 1; int w = -1; @@ -185,14 +185,14 @@ static int scale(GP_Pixmap **c, const char *params) if (h == -1) h = (*c)->h * (1.00 * w/(*c)->w) + 0.5; - GP_Pixmap *res = NULL; + gp_pixmap *res = NULL; - res = GP_FilterResizeAlloc(*c, w, h, alg, progress_callback); + res = gp_filter_resize_alloc(*c, w, h, alg, progress_callback); if (res == NULL) return EINVAL; - GP_PixmapFree(*c); + gp_pixmap_free(*c); *c = res; return 0; @@ -211,7 +211,7 @@ static struct param rotate_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int rotate(GP_Pixmap **c, const char *params) +static int rotate(gp_pixmap **c, const char *params) { int rot = -1; @@ -223,24 +223,24 @@ static int rotate(GP_Pixmap **c, const char *params) return EINVAL; } - GP_Pixmap *res = NULL; + gp_pixmap *res = NULL; switch (rot) { case 0: - res = GP_FilterRotate90Alloc(*c, progress_callback); + res = gp_filter_rotate_90_alloc(*c, progress_callback); break; case 1: - res = GP_FilterRotate180Alloc(*c, progress_callback); + res = gp_filter_rotate_180_alloc(*c, progress_callback); break; case 2: - res = GP_FilterRotate270Alloc(*c, progress_callback); + res = gp_filter_rotate_270_alloc(*c, progress_callback); break; } if (res == NULL) return ENOMEM; - GP_PixmapFree(*c); + gp_pixmap_free(*c); *c = res; return 0; @@ -254,7 +254,7 @@ static struct param mirror_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int mirror(GP_Pixmap **c, const char *params) +static int mirror(gp_pixmap **c, const char *params) { int vert = 0, horiz = 0; @@ -262,10 +262,10 @@ static int mirror(GP_Pixmap **c, const char *params) return EINVAL; if (vert) - GP_FilterMirrorV(*c, *c, progress_callback); + gp_filter_mirror_v(*c, *c, progress_callback); if (horiz) - GP_FilterMirrorH(*c, *c, progress_callback); + gp_filter_mirror_h(*c, *c, progress_callback); return 0; } @@ -277,14 +277,14 @@ static struct param bright_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int bright(GP_Pixmap **c, const char *params) +static int bright(gp_pixmap **c, const char *params) { float bright = 0; if (param_parse(params, bright_params, "bright", param_err, &bright)) return EINVAL; - GP_FilterBrightness(*c, *c, bright, progress_callback); + gp_filter_brightness(*c, *c, bright, progress_callback); return 0; } @@ -296,7 +296,7 @@ static struct param contrast_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int contrast(GP_Pixmap **c, const char *params) +static int contrast(gp_pixmap **c, const char *params) { float mul = 0; @@ -308,7 +308,7 @@ static int contrast(GP_Pixmap **c, const char *params) return EINVAL; } - GP_FilterContrast(*c, *c, mul, progress_callback); + gp_filter_contrast(*c, *c, mul, progress_callback); return 0; } @@ -319,12 +319,12 @@ static struct param invert_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int invert(GP_Pixmap **c, const char *params) +static int invert(gp_pixmap **c, const char *params) { if (param_parse(params, invert_params, "invert", param_err)) return EINVAL; - GP_FilterInvert(*c, *c, progress_callback); + gp_filter_invert(*c, *c, progress_callback); return 0; } @@ -338,7 +338,7 @@ static struct param blur_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int blur(GP_Pixmap **c, const char *params) +static int blur(gp_pixmap **c, const char *params) { float sigma = 0; float sigma_x = 0; @@ -357,7 +357,7 @@ static int blur(GP_Pixmap **c, const char *params) return EINVAL; } - GP_FilterGaussianBlur(*c, *c, sigma_x, sigma_y, progress_callback); + gp_filter_gaussian_blur(*c, *c, sigma_x, sigma_y, progress_callback); return 0; } @@ -375,7 +375,7 @@ static const char *dither_formats[] = { NULL, }; -static const GP_PixelType dither_pixel_types[] = { +static const gp_pixel_type dither_pixel_types[] = { GP_PIXEL_G1, GP_PIXEL_G2, GP_PIXEL_G4, @@ -389,7 +389,7 @@ static struct param dither_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int dither(GP_Pixmap **c, const char *params) +static int dither(gp_pixmap **c, const char *params) { int fmt = -1; @@ -401,15 +401,15 @@ static int dither(GP_Pixmap **c, const char *params) return EINVAL; } - GP_Pixmap *bw; - bw = GP_FilterFloydSteinbergAlloc(*c, dither_pixel_types[fmt], + gp_pixmap *bw; + bw = gp_filter_floyd_steinberg_alloc(*c, dither_pixel_types[fmt], progress_callback); //TODO: so far we convert the pixmap back to RGB888 //(so we can do further work with it) - GP_Blit(bw, 0, 0, GP_PixmapW(bw), GP_PixmapH(bw), *c, 0, 0); + gp_blit(bw, 0, 0, gp_pixmap_w(bw), gp_pixmap_h(bw), *c, 0, 0); - GP_PixmapFree(bw); + gp_pixmap_free(bw); return 0; } @@ -421,7 +421,7 @@ static struct param save_jpg_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int save_jpg(GP_Pixmap **c, const char *params) +static int save_jpg(gp_pixmap **c, const char *params) { char *file = NULL; @@ -433,7 +433,7 @@ static int save_jpg(GP_Pixmap **c, const char *params) return EINVAL; } - GP_SaveJPG(*c, file, progress_callback); + gp_save_jpg(*c, file, progress_callback); return 0; } @@ -445,7 +445,7 @@ static struct param save_png_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int save_png(GP_Pixmap **c, const char *params) +static int save_png(gp_pixmap **c, const char *params) { char *file = NULL; @@ -457,7 +457,7 @@ static int save_png(GP_Pixmap **c, const char *params) return EINVAL; } - GP_SavePNG(*c, file, progress_callback); + gp_save_png(*c, file, progress_callback); return 0; } @@ -471,7 +471,7 @@ static struct param median_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int median(GP_Pixmap **c, const char *params) +static int median(gp_pixmap **c, const char *params) { int rad = -1, rad_x, rad_y; @@ -486,12 +486,12 @@ static int median(GP_Pixmap **c, const char *params) if (rad_x < 0 || rad_y < 0) return EINVAL; - GP_Pixmap *ret = GP_FilterMedianAlloc(*c, rad_x, rad_y, progress_callback); + gp_pixmap *ret = gp_filter_median_alloc(*c, rad_x, rad_y, progress_callback); if (ret == NULL) return ENOMEM; - GP_PixmapFree(*c); + gp_pixmap_free(*c); *c = ret; return 0; @@ -508,7 +508,7 @@ static struct param sigma_mean_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int sigma_mean(GP_Pixmap **c, const char *params) +static int sigma_mean(gp_pixmap **c, const char *params) { int rad = -1, rad_x, rad_y, min = 0; float sigma = 0.1; @@ -525,14 +525,14 @@ static int sigma_mean(GP_Pixmap **c, const char *params) if (rad_x < 0 || rad_y < 0) return EINVAL; - (*c)->gamma = GP_GammaAcquire((*c)->pixel_type, 1.2); + (*c)->gamma = gp_gamma_acquire((*c)->pixel_type, 1.2); - GP_Pixmap *ret = GP_FilterSigmaAlloc(*c, rad_x, rad_y, min, sigma, progress_callback); + gp_pixmap *ret = gp_filter_sigma_alloc(*c, rad_x, rad_y, min, sigma, progress_callback); if (ret == NULL) return ENOMEM; - GP_PixmapFree(*c); + gp_pixmap_free(*c); *c = ret; return 0; @@ -545,19 +545,19 @@ static struct param sharpen_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int sharpen(GP_Pixmap **c, const char *params) +static int sharpen(gp_pixmap **c, const char *params) { float weight = 0.1; if (param_parse(params, sharpen_params, "sigma", param_err, &weight)) return EINVAL; - GP_Pixmap *ret = GP_FilterEdgeSharpeningAlloc(*c, weight, progress_callback); + gp_pixmap *ret = gp_filter_edge_sharpening_alloc(*c, weight, progress_callback); if (ret == NULL) return ENOMEM; - GP_PixmapFree(*c); + gp_pixmap_free(*c); *c = ret; return 0; @@ -571,7 +571,7 @@ static struct param gauss_noise_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int gauss_noise(GP_Pixmap **c, const char *params) +static int gauss_noise(gp_pixmap **c, const char *params) { float sigma = 0.1; float mu = 0; @@ -579,7 +579,7 @@ static int gauss_noise(GP_Pixmap **c, const char *params) if (param_parse(params, gauss_noise_params, "gaussian noise", param_err, &sigma, &mu)) return EINVAL; - GP_FilterGaussianNoiseAdd(*c, *c, sigma, mu, progress_callback); + gp_filter_gaussian_noise_add(*c, *c, sigma, mu, progress_callback); return 0; } @@ -601,7 +601,7 @@ static struct param arithmetic_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int arithmetic(GP_Pixmap **c, const char *params) +static int arithmetic(gp_pixmap **c, const char *params) { char *file = NULL; int op = -1; @@ -614,35 +614,35 @@ static int arithmetic(GP_Pixmap **c, const char *params) return EINVAL; } - GP_Pixmap *img, *res = NULL; + gp_pixmap *img, *res = NULL; - if ((img = GP_LoadImage(file, progress_callback)) == NULL) { + if ((img = gp_load_image(file, progress_callback)) == NULL) { print_error("arithmetic: Invalid image."); return EINVAL; } switch (op) { case 0: - res = GP_FilterDifferenceAlloc(*c, img, progress_callback); + res = gp_filter_diff_alloc(*c, img, progress_callback); break; case 1: - res = GP_FilterAdditionAlloc(*c, img, progress_callback); + res = gp_filter_add_alloc(*c, img, progress_callback); break; case 2: - res = GP_FilterMultiplyAlloc(*c, img, progress_callback); + res = gp_filter_mul_alloc(*c, img, progress_callback); break; case 3: - res = GP_FilterMinAlloc(*c, img, progress_callback); + res = gp_filter_min_alloc(*c, img, progress_callback); break; case 4: - res = GP_FilterMaxAlloc(*c, img, progress_callback); + res = gp_filter_max_alloc(*c, img, progress_callback); break; } if (res == NULL) return ENOMEM; - GP_PixmapFree(*c); + gp_pixmap_free(*c); *c = res; @@ -656,7 +656,7 @@ static struct param histogram_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int histogram(GP_Pixmap **c, const char *params) +static int histogram(gp_pixmap **c, const char *params) { char *file = "histogram.png"; @@ -678,7 +678,7 @@ struct filter { const char *name; const char *desc; struct param *param_desc; - int (*apply)(GP_Pixmap **c, const char *params); + int (*apply)(gp_pixmap **c, const char *params); }; static struct filter filter_table[] = { @@ -763,7 +763,7 @@ static void add_filter(char *params) filter_params[filter_cnt++] = params; } -static void apply_filters(GP_Pixmap **src) +static void apply_filters(gp_pixmap **src) { unsigned int i; int ret; @@ -845,18 +845,18 @@ static void check_fmt(const char *fmt) exit(1); } -static void save_by_fmt(struct GP_Pixmap *bitmap, const char *name, const char *fmt) +static void save_by_fmt(struct gp_pixmap *bitmap, const char *name, const char *fmt) { int ret; progress_prefix = "Saving Image"; if (!strcmp(fmt, "ppm")) - ret = GP_SavePPM(bitmap, name, progress_callback); + ret = gp_save_ppm(bitmap, name, progress_callback); else if (!strcmp(fmt, "jpg")) - ret = GP_SaveJPG(bitmap, name, progress_callback); + ret = gp_save_jpg(bitmap, name, progress_callback); else if (!strcmp(fmt, "png")) - ret = GP_SavePNG(bitmap, name, progress_callback); + ret = gp_save_png(bitmap, name, progress_callback); else { printf("Invalid format %s\n", fmt); exit(1); @@ -874,11 +874,11 @@ static void save_by_fmt(struct GP_Pixmap *bitmap, const char *name, const char * int main(int argc, char *argv[]) { - GP_Pixmap *bitmap; + gp_pixmap *bitmap; int opt, i; const char *out_fmt = "ppm"; - GP_ProgressCallback callback = { + gp_progress_cb callback = { .callback = show_progress, }; @@ -898,7 +898,7 @@ int main(int argc, char *argv[]) return 1; } - GP_SetDebugLevel(i); + gp_set_debug_level(i); break; case 'o': out_fmt = optarg; @@ -929,7 +929,7 @@ int main(int argc, char *argv[]) progress_prefix = "Loading image"; - if ((bitmap = GP_LoadImage(argv[i], progress_callback)) == NULL) { + if ((bitmap = gp_load_image(argv[i], progress_callback)) == NULL) { fprintf(stderr, "Failed to load bitmap: %s\n", strerror(errno)); return 1; } diff --git a/demos/grinder/histogram.c b/demos/grinder/histogram.c index d02f17518235..fb42a4ff9f14 100644 --- a/demos/grinder/histogram.c +++ b/demos/grinder/histogram.c @@ -22,44 +22,44 @@ #include "histogram.h" -void histogram_to_png(const GP_Pixmap *src, const char *filename) +void histogram_to_png(const gp_pixmap *src, const char *filename) { - GP_Histogram *hist; + gp_histogram *hist; - hist = GP_HistogramAlloc(src->pixel_type); + hist = gp_histogram_alloc(src->pixel_type); if (!hist) { fprintf(stderr, "Failed to allocate histogram\n"); return; } - GP_FilterHistogram(hist, src, NULL); + gp_filter_histogram(hist, src, NULL); unsigned int i, j; - GP_Pixmap *res = GP_PixmapAlloc(257*4, 256, GP_PIXEL_RGB888); + gp_pixmap *res = gp_pixmap_alloc(257 * 4, 256, GP_PIXEL_RGB888); - GP_Fill(res, 0xffffff); + gp_fill(res, 0xffffff); - GP_HistogramChannel *hist_r = GP_HistogramChannelByName(hist, "R"); + gp_histogram_channel *hist_r = gp_histogram_channel_by_name(hist, "R"); for (i = 0; i < hist_r->len; i++) - GP_VLineXYH(res, i, 256, -255.00 * hist_r->hist[i] / hist_r->max + 0.5 , 0xff0000); + gp_vline_xyh(res, i, 256, -255.00 * hist_r->hist[i] / hist_r->max + 0.5 , 0xff0000); - GP_HistogramChannel *hist_g = GP_HistogramChannelByName(hist, "G"); + gp_histogram_channel *hist_g = gp_histogram_channel_by_name(hist, "G"); for (i = 0; i < hist_g->len; i++) - GP_VLineXYH(res, i+257, 256, -255.00 * hist_g->hist[i] / hist_g->max + 0.5 , 0x00ff00); + gp_vline_xyh(res, i+257, 256, -255.00 * hist_g->hist[i] / hist_g->max + 0.5 , 0x00ff00); - GP_HistogramChannel *hist_b = GP_HistogramChannelByName(hist, "B"); + gp_histogram_channel *hist_b = gp_histogram_channel_by_name(hist, "B"); for (i = 0; i < hist_b->len; i++) - GP_VLineXYH(res, i+514, 256, -255.00 * hist_b->hist[i] / hist_b->max + 0.5 , 0x0000ff); + gp_vline_xyh(res, i+514, 256, -255.00 * hist_b->hist[i] / hist_b->max + 0.5 , 0x0000ff); uint32_t max = GP_MAX3(hist_r->max, hist_g->max, hist_b->max); for (i = 0; i < hist_r->len; i++) { for (j = 0; j < hist_r->len; j++) { - GP_Pixel pix = 0; + gp_pixel pix = 0; if (255 * hist_r->hist[i] / max + 0.5 > j) pix |= 0xff0000; @@ -70,12 +70,11 @@ void histogram_to_png(const GP_Pixmap *src, const char *filename) if (255 * hist_b->hist[i] / max + 0.5 > j) pix |= 0x0000ff; - GP_PutPixel(res, i+771, 256-j, pix); + gp_putpixel(res, i + 771, 256 - j, pix); } } - GP_SavePNG(res, filename, NULL); - - GP_PixmapFree(res); - GP_HistogramFree(hist); + gp_save_png(res, filename, NULL); + gp_pixmap_free(res); + gp_histogram_free(hist); } diff --git a/demos/grinder/histogram.h b/demos/grinder/histogram.h index e58dfd4c4527..da530d0672aa 100644 --- a/demos/grinder/histogram.h +++ b/demos/grinder/histogram.h @@ -23,8 +23,8 @@ #ifndef HISTOGRAM_H #define HISTOGRAM_H -#include <GP.h> +#include <gfxprim.h> -void histogram_to_png(const GP_Pixmap *src, const char *filename); +void histogram_to_png(const gp_pixmap *src, const char *filename); #endif /* HISTOGRAM_H */ diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c index e4226c27114b..9a3422f24181 100644 --- a/demos/particle/particle_demo.c +++ b/demos/particle/particle_demo.c @@ -28,21 +28,21 @@ #include <signal.h> #include <string.h> -#include <GP.h> +#include <gfxprim.h> #include <backends/GP_Backends.h> #include "space.h" -static GP_Pixel black_pixel; -static GP_Pixel white_pixel; +static gp_pixel black_pixel; +static gp_pixel white_pixel; -static GP_Backend *backend = NULL; -static GP_Pixmap *pixmap = NULL; +static gp_backend *backend = NULL; +static gp_pixmap *pixmap = NULL; static void sighandler(int signo) { if (backend != NULL) - GP_BackendExit(backend); + gp_backend_exit(backend); fprintf(stderr, "Got signal %i\n", signo); @@ -51,7 +51,7 @@ static void sighandler(int signo) static void init_backend(const char *backend_opts) { - backend = GP_BackendInit(backend_opts, "Particles"); + backend = gp_backend_init(backend_opts, "Particles"); if (backend == NULL) { fprintf(stderr, "Failed to initalize backend '%s'\n", backend_opts); @@ -79,8 +79,6 @@ int main(int argc, char *argv[]) } } -// GP_SetDebugLevel(10); - signal(SIGINT, sighandler); signal(SIGSEGV, sighandler); signal(SIGBUS, sighandler); @@ -90,27 +88,27 @@ int main(int argc, char *argv[]) pixmap = backend->pixmap; - black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); - white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, pixmap); + black_pixel = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, pixmap); + white_pixel = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0xff, pixmap); - GP_Fill(pixmap, black_pixel); - GP_BackendFlip(backend); + gp_fill(pixmap, black_pixel); + gp_backend_flip(backend); struct space *space; space = space_create(particles, 10<<8, 10<<8, (pixmap->w - 10)<<8, (pixmap->h - 10)<<8); for (;;) { - if (backend->Poll) - GP_BackendPoll(backend); + if (backend->poll) + gp_backend_poll(backend); usleep(1000); /* Read and parse events */ - GP_Event ev; + gp_event ev; - while (GP_BackendGetEvent(backend, &ev)) { + while (gp_backend_get_event(backend, &ev)) { - GP_EventDump(&ev); + gp_event_dump(&ev); switch (ev.type) { case GP_EV_KEY: @@ -121,7 +119,7 @@ int main(int argc, char *argv[]) case GP_KEY_ESC: case GP_KEY_ENTER: case GP_KEY_Q: - GP_BackendExit(backend); + gp_backend_exit(backend); return 0; break; case GP_KEY_P: @@ -138,11 +136,11 @@ int main(int argc, char *argv[]) case GP_EV_SYS: switch(ev.code) { case GP_EV_SYS_QUIT: - GP_BackendExit(backend); + gp_backend_exit(backend); exit(0); break; case GP_EV_SYS_RESIZE: - GP_BackendResizeAck(backend); + gp_backend_resize_ack(backend); space_destroy(space); space = space_create(particles, 10<<8, 10<<8, @@ -157,11 +155,11 @@ int main(int argc, char *argv[]) if (!pause_flag) { space_time_tick(space, 1); space_draw_particles(pixmap, space); - GP_BackendFlip(backend); + gp_backend_flip(backend); } } - GP_BackendExit(backend); + gp_backend_exit(backend); return 0; } diff --git a/demos/particle/space.c b/demos/particle/space.c index 8dfc956d656a..87928bf21340 100644 --- a/demos/particle/space.c +++ b/demos/particle/space.c @@ -67,19 +67,19 @@ void space_destroy(struct space *space) #define SQUARE(x) ((x) * (x)) -void space_draw_particles(GP_Pixmap *pixmap, struct space *space) +void space_draw_particles(gp_pixmap *pixmap, struct space *space) { unsigned int i; - GP_Fill(pixmap, 0x000000); + gp_fill(pixmap, 0x000000); for (i = 0; i < space->particle_count; i++) { - GP_Pixel color; + gp_pixel color; - GP_Coord x = space->particles[i].x; - GP_Coord y = space->particles[i].y; - GP_Coord a1 = GP_FP_1 * 4; - GP_Coord a2 = GP_FP_1_2 * 2; + gp_coord x = space->particles[i].x; + gp_coord y = space->particles[i].y; + gp_coord a1 = GP_FP_1 * 4; + gp_coord a2 = GP_FP_1_2 * 2; /* if (i == 0) { @@ -88,9 +88,9 @@ void space_draw_particles(GP_Pixmap *pixmap, struct space *space) } */ - color = GP_RGBToPixmapPixel(0xee, 0xee, 0xee, pixmap); + color = gp_rgb_to_pixmap_pixel(0xee, 0xee, 0xee, pixmap); - GP_PutPixelAA(pixmap, x, y, color); + gp_putpixel_aa(pixmap, x, y, color); int val = SQUARE(space->particles[i].vx) + SQUARE(space->particles[i].vy); @@ -99,29 +99,29 @@ void space_draw_particles(GP_Pixmap *pixmap, struct space *space) if (val > 255) val = 255; - color = GP_RGBToPixmapPixel(val, val, 0x40, pixmap); + color = gp_rgb_to_pixmap_pixel(val, val, 0x40, pixmap); /* Hexagons */ - GP_LineAA(pixmap, x - a2, y - a1, x + a2, y - a1, color); - // GP_LineAA(pixmap, x + a2, y - a1, x + a1, y - a2, color); - GP_LineAA(pixmap, x + a1, y - a2, x + a1, y + a2, color); - // GP_LineAA(pixmap, x + a1, y + a2, x + a2, y + a1, color); - GP_LineAA(pixmap, x + a2, y + a1, x - a2, y + a1, color); - // GP_LineAA(pixmap, x - a2, y + a1, x - a1, y + a2, color); - GP_LineAA(pixmap, x - a1, y + a2, x - a1, y - a2, color); - // GP_LineAA(pixmap, x - a1, y - a2, x - a2, y - a1, color); + gp_line_aa(pixmap, x - a2, y - a1, x + a2, y - a1, color); + // gp_line_aa(pixmap, x + a2, y - a1, x + a1, y - a2, color); + gp_line_aa(pixmap, x + a1, y - a2, x + a1, y + a2, color); + // gp_line_aa(pixmap, x + a1, y + a2, x + a2, y + a1, color); + gp_line_aa(pixmap, x + a2, y + a1, x - a2, y + a1, color); + // gp_line_aa(pixmap, x - a2, y + a1, x - a1, y + a2, color); + gp_line_aa(pixmap, x - a1, y + a2, x - a1, y - a2, color); + // gp_line_aa(pixmap, x - a1, y - a2, x - a2, y - a1, color); /* - GP_PutPixelAA(pixmap, x + a2, y - a1, 0xffffff); - GP_PutPixelAA(pixmap, x + a1, y - a2, 0xffffff); + gp_putpixel_aa(pixmap, x + a2, y - a1, 0xffffff); + gp_putpixel_aa(pixmap, x + a1, y - a2, 0xffffff); - GP_PutPixelAA(pixmap, x + a1, y + a2, 0xffffff); - GP_PutPixelAA(pixmap, x + a2, y + a1, 0xffffff); + gp_putpixel_aa(pixmap, x + a1, y + a2, 0xffffff); + gp_putpixel_aa(pixmap, x + a2, y + a1, 0xffffff); - GP_PutPixelAA(pixmap, x - a2, y + a1, 0xffffff); - GP_PutPixelAA(pixmap, x - a1, y + a2, 0xffffff); + gp_putpixel_aa(pixmap, x - a2, y + a1, 0xffffff); + gp_putpixel_aa(pixmap, x - a1, y + a2, 0xffffff); - GP_PutPixelAA(pixmap, x - a1, y - a2, 0xffffff); - GP_PutPixelAA(pixmap, x - a2, y - a1, 0xffffff); + gp_putpixel_aa(pixmap, x - a1, y - a2, 0xffffff); + gp_putpixel_aa(pixmap, x - a2, y - a1, 0xffffff); */ } } diff --git a/demos/particle/space.h b/demos/particle/space.h index 021d615b36fc..31c994424c67 100644 --- a/demos/particle/space.h +++ b/demos/particle/space.h @@ -29,7 +29,7 @@ #ifndef PARTICLE_H #define PARTICLE_H -#include <GP.h> +#include <gfxprim.h> struct particle { /* fixed point coordinates */ @@ -69,7 +69,7 @@ struct space *space_create(unsigned int particle_count, int min_w, int min_h, void space_destroy(struct space *space); -void space_draw_particles(GP_Pixmap *pixmap, struct space *space); +void space_draw_particles(gp_pixmap *pixmap, struct space *space); void space_time_tick(struct space *space, int time); diff --git a/demos/py_simple/backends.py b/demos/py_simple/backends.py index 84715526aa2c..c8ca7a3f07f5 100755 --- a/demos/py_simple/backends.py +++ b/demos/py_simple/backends.py @@ -11,15 +11,15 @@ import gfxprim.input as input def redraw(bk): c = bk.pixmap - black = c.RGBToPixel(0, 0, 0) - white = c.RGBToPixel(0xff, 0xff, 0xff) + black = c.rgb_to_pixel(0, 0, 0) + white = c.rgb_to_pixel(0xff, 0xff, 0xff) - c.gfx.Fill(black) + c.gfx.fill(black) align = text.C.ALIGN_CENTER | text.C.VALIGN_CENTER - c.text.Text(None, c.w//2, c.h//2, align, white, black, "Hello World!") + c.text.text(None, c.w//2, c.h//2, align, white, black, "Hello World!") - bk.Flip() + bk.flip() def main(): backend_string = "X11:100x100" @@ -32,16 +32,16 @@ def main(): sys.exit(1) # Create backend window - bk = backends.BackendInit(backend_string, "Backend Example") + bk = backends.backend_init(backend_string, "Backend Example") assert(bk) redraw(bk) # Event loop while True: - ev = bk.WaitEvent() + ev = bk.wait_event() - input.EventDump(ev) + input.event_dump(ev) if (ev.type == input.EV_KEY): sys.exit(0) @@ -49,7 +49,7 @@ def main(): if (ev.code == input.EV_SYS_QUIT): sys.exit(0) if (ev.code == input.EV_SYS_RESIZE): - bk.ResizeAck() + bk.resize_ack() redraw(bk) if __name__ == '__main__': diff --git a/demos/py_simple/blit.py b/demos/py_simple/blit.py index e76b8c08e0aa..7e637b5c85df 100755 --- a/demos/py_simple/blit.py +++ b/demos/py_simple/blit.py @@ -10,7 +10,7 @@ import gfxprim.input as input class Ball: def __init__(self, x, y, dx, dy, path, bg_img): - self.ball = loaders.Load(path) + self.ball = loaders.load(path) assert(self.ball) self.x = x @@ -21,13 +21,13 @@ class Ball: self.bg_img = bg_img def draw(self, bk): - self.ball.Blit(0, 0, bk.pixmap, self.x, self.y, self.ball.w, self.ball.h) + self.ball.blit(0, 0, bk.pixmap, self.x, self.y, self.ball.w, self.ball.h) def move(self, bk): old_x = self.x; old_y = self.y; - self.bg_img.Blit(old_x, old_y, bk.pixmap, old_x, old_y, self.ball.w, self.ball.h) + self.bg_img.blit(old_x, old_y, bk.pixmap, old_x, old_y, self.ball.w, self.ball.h) self.x += self.dx self.y += self.dy @@ -38,18 +38,18 @@ class Ball: if (self.y <= 0 or self.y >= self.bg_img.h - self.ball.h): self.dy = -self.dy - self.ball.Blit(0, 0, bk.pixmap, self.x, self.y, self.ball.w, self.ball.h) - bk.UpdateRect(min(old_x, self.x), min(self.y, old_y), - max(old_x, self.x) + self.ball.w - 1, - max(old_y, self.y) + self.ball.h - 1) + self.ball.blit(0, 0, bk.pixmap, self.x, self.y, self.ball.w, self.ball.h) + bk.update_rect(min(old_x, self.x), min(self.y, old_y), + max(old_x, self.x) + self.ball.w - 1, + max(old_y, self.y) + self.ball.h - 1) def main(): if len(sys.argv) != 2: print("Takes an image as an argument") sys.exit(1) - # Load Backgroudn Image and ball sprite - bg = loaders.Load(sys.argv[1]) + # load Backgroudn Image and ball sprite + bg = loaders.load(sys.argv[1]) assert(bg) ball1 = Ball(bg.w//2, bg.h//2, -3, -3, 'ball_red.png', bg) @@ -57,28 +57,30 @@ def main(): ball3 = Ball(bg.w//2, bg.h//2, 2, -3, 'ball_blue.png', bg) # Create X11 window - bk = backends.BackendX11Init(None, 0, 0, bg.w, bg.h, sys.argv[1], 0) + bk = backends.x11_init(None, 0, 0, bg.w, bg.h, sys.argv[1], 0) assert(bk) - bg.Blit(0, 0, bk.pixmap, 0, 0, bg.w, bg.h) + bg.blit(0, 0, bk.pixmap, 0, 0, bg.w, bg.h) - bk.Flip() + bk.flip() # Event loop while True: while True: - ev = bk.PollEvent() + ev = bk.poll_event() if (ev is None): break - input.EventDump(ev) + input.event_dump(ev) if (ev.type == input.EV_KEY and ev.val.val == input.KEY_ESC): sys.exit(0) elif (ev.type == input.EV_SYS): if (ev.code == input.EV_SYS_QUIT): sys.exit(0) + if (ev.code == input.EV_SYS_RESIZE): + bk.resize_ack() sleep(0.005) diff --git a/demos/py_simple/blur.py b/demos/py_simple/blur.py index 70e9da5af4ff..e6713d2b06ea 100755 --- a/demos/py_simple/blur.py +++ b/demos/py_simple/blur.py @@ -13,11 +13,11 @@ def main(): radii = float(sys.argv[1]) # Load Image - img = loaders.Load(sys.argv[2]) + img = loaders.load(sys.argv[2]) # Do in-place gaussian blur - filters.GaussianBlur(img, img, radii, radii) + filters.gaussian_blur(img, img, radii, radii) # Save result - img.loaders.SaveJPG("out.jpg") + img.loaders.save_jpg("out.jpg") if __name__ == '__main__': main() diff --git a/demos/py_simple/cam_view.py b/demos/py_simple/cam_view.py index dd7bcc88286c..f17457d71754 100755 --- a/demos/py_simple/cam_view.py +++ b/demos/py_simple/cam_view.py @@ -10,36 +10,38 @@ import gfxprim.grabbers as grabbers def main(): # Open grabber (i.e. web camera) - grabber = grabbers.GrabberV4L2Init("/dev/video0", 320, 240); + grabber = grabbers.grabber_v4l2_init("/dev/video0", 320, 240); assert(grabber) # Create X11 window - bk = backends.BackendX11Init(None, 0, 0, grabber.frame.w, grabber.frame.h, "Grabbers test", 0) + bk = backends.x11_init(None, 0, 0, grabber.frame.w, grabber.frame.h, "Grabbers test", 0) assert(bk) # Start grabber capture - grabber.Start(); + grabber.start(); # Event loop while True: sleep(0.01) - if (grabber.Poll()): - grabber.frame.Blit(0, 0, bk.pixmap, 0, 0, grabber.frame.w, grabber.frame.h) - bk.Flip() + if (grabber.poll()): + grabber.frame.blit(0, 0, bk.pixmap, 0, 0, grabber.frame.w, grabber.frame.h) + bk.flip() - ev = bk.PollEvent() + ev = bk.poll_event() if (ev is None): continue - input.EventDump(ev) + input.event_dump(ev) if (ev.type == input.EV_KEY): exit(0) elif (ev.type == input.EV_SYS): if (ev.code == input.EV_SYS_QUIT): exit(0) + if (ev.code == input.EV_SYS_RESIZE): + bk.resize_ack() if __name__ == '__main__': main() diff --git a/demos/py_simple/convolution.py b/demos/py_simple/convolution.py index 3dbc975b6ca1..320def9cd74c 100755 --- a/demos/py_simple/convolution.py +++ b/demos/py_simple/convolution.py @@ -11,16 +11,16 @@ def main(): sys.exit(1) # Load Image - img = loaders.Load(sys.argv[1]) + img = loaders.load(sys.argv[1]) # Box blur kernel kern = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]] - res = img.filters.ConvolutionAlloc(kern, 25); + res = img.filters.convolution_alloc(kern, 25); # Save result into png - res.loaders.SavePNG("out.png") + res.loaders.save_png("out.png") if __name__ == '__main__': main() diff --git a/demos/py_simple/dither.py b/demos/py_simple/dither.py index d2b9e043c0cf..9b6d7e9f2a68 100755 --- a/demos/py_simple/dither.py +++ b/demos/py_simple/dither.py @@ -10,12 +10,12 @@ def main(): print("usage: dither.py image") sys.exit(1) - # Load Image - img = loaders.Load(sys.argv[1]) + # load Image + img = loaders.load(sys.argv[1]) # Use Floyd-Steinberg dithering - res = img.filters.FloydSteinbergAlloc(core.C.PIXEL_G1) + res = img.filters.floyd_steinberg_alloc(core.C.PIXEL_G1) # Save result into grayscale png - res.loaders.SavePNG("out.png") + res.loaders.save_png("out.png") if __name__ == '__main__': main() diff --git a/demos/py_simple/font_style.py b/demos/py_simple/font_style.py index 1799253d8a10..62b3d67afc73 100755 --- a/demos/py_simple/font_style.py +++ b/demos/py_simple/font_style.py @@ -11,39 +11,39 @@ import gfxprim.text as text def redraw(win): c = win.pixmap - black = c.RGBToPixel(0, 0, 0) - white = c.RGBToPixel(0xff, 0xff, 0xff) + black = c.rgb_to_pixel(0, 0, 0) + white = c.rgb_to_pixel(0xff, 0xff, 0xff) - c.gfx.Fill(black) + c.gfx.fill(black) align = text.C.ALIGN_CENTER | text.C.VALIGN_CENTER - style = text.TextStyle(text.DefaultProportionalFont, 0, 0, 1, 1, 1) + style = text.text_style(text.font_gfxprim, 0, 0, 1, 1, 1) spacing = 20 y = 20 while y < c.h: - y += text.TextHeight(style) + spacing - c.text.Text(style, c.w//2, y, align, white, black, "Lorem Ipsum Dolor Sit Amet.") + y += text.text_height(style) + spacing + c.text.text(style, c.w//2, y, align, white, black, "Lorem Ipsum Dolor Sit Amet.") style.pixel_xspace += 1 style.pixel_yspace += 1 style.pixel_xmul += 1 style.pixel_ymul += 1 - win.Flip() + win.flip() def main(): # Create X11 window - win = backends.BackendX11Init(None, 0, 0, 800, 600, "Fonts", 0) + win = backends.x11_init(None, 0, 0, 800, 600, "Fonts", 0) assert(win) redraw(win) # Event loop while True: - ev = win.WaitEvent() + ev = win.wait_event() if (ev.type == input.EV_KEY and ev.val.val == input.KEY_ESC): sys.exit(0) @@ -51,7 +51,7 @@ def main(): if (ev.code == input.EV_SYS_QUIT): sys.exit(0) if (ev.code == input.EV_SYS_RESIZE): - win.ResizeAck() + win.resize_ack() redraw(win) if __name__ == '__main__': diff --git a/demos/py_simple/gfx.py b/demos/py_simple/gfx.py index 0ee8dbe6517e..c580d4aa320d 100755 --- a/demos/py_simple/gfx.py +++ b/demos/py_simple/gfx.py @@ -8,85 +8,85 @@ import gfxprim.backends as backends import gfxprim.input as input def fill(bk): - color = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) - bk.pixmap.gfx.Fill(color) - bk.Flip() + color = bk.pixmap.rgb_to_pixel(0xee, 0xee, 0xee) + bk.pixmap.gfx.fill(color) + bk.flip() def hline(bk): - fg = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) - bg = bk.pixmap.RGBToPixel(0, 0, 0); + fg = bk.pixmap.rgb_to_pixel(0xee, 0xee, 0xee) + bg = bk.pixmap.rgb_to_pixel(0, 0, 0); - bk.pixmap.gfx.Fill(bg) + bk.pixmap.gfx.fill(bg) for i in range(0, bk.pixmap.h, 10): - bk.pixmap.gfx.HLine(0, bk.pixmap.w, i, fg) - bk.Flip() + bk.pixmap.gfx.hline(0, bk.pixmap.w, i, fg) + bk.flip() def vline(bk): - fg = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) - bg = bk.pixmap.RGBToPixel(0, 0, 0); + fg = bk.pixmap.rgb_to_pixel(0xee, 0xee, 0xee) + bg = bk.pixmap.rgb_to_pixel(0, 0, 0); - bk.pixmap.gfx.Fill(bg) + bk.pixmap.gfx.fill(bg) for i in range(0, bk.pixmap.w, 10): - bk.pixmap.gfx.VLine(i, 0, bk.pixmap.h, fg) + bk.pixmap.gfx.vline(i, 0, bk.pixmap.h, fg) - bk.Flip() + bk.flip() def line(bk): - fg = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) - bg = bk.pixmap.RGBToPixel(0, 0, 0); + fg = bk.pixmap.rgb_to_pixel(0xee, 0xee, 0xee) + bg = bk.pixmap.rgb_to_pixel(0, 0, 0); - bk.pixmap.gfx.Fill(bg) + bk.pixmap.gfx.fill(bg) for i in range(0, 2 * max(bk.pixmap.w, bk.pixmap.h), 13): - bk.pixmap.gfx.Line(0, i, i, 0, fg) + bk.pixmap.gfx.line(0, i, i, 0, fg) - bk.Flip() + bk.flip() def rect(bk): - fg = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) - bg = bk.pixmap.RGBToPixel(0, 0, 0); + fg = bk.pixmap.rgb_to_pixel(0xee, 0xee, 0xee) + bg = bk.pixmap.rgb_to_pixel(0, 0, 0); - bk.pixmap.gfx.Fill(bg) + bk.pixmap.gfx.fill(bg) for i in range(10, 130, 10): - bk.pixmap.gfx.Rect(i, i, bk.pixmap.w - i, bk.pixmap.h - i, fg) + bk.pixmap.gfx.rect(i, i, bk.pixmap.w - i, bk.pixmap.h - i, fg) - bk.Flip() + bk.flip() def triangle(bk): - fg = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) - bg = bk.pixmap.RGBToPixel(0, 0, 0); + fg = bk.pixmap.rgb_to_pixel(0xee, 0xee, 0xee) + bg = bk.pixmap.rgb_to_pixel(0, 0, 0); - bk.pixmap.gfx.Fill(bg) + bk.pixmap.gfx.fill(bg) w = bk.pixmap.w h = bk.pixmap.h for i in range(10, 90, 10): - bk.pixmap.gfx.Triangle(2*i, i, w - 2*i, i, w//2, h - 2*i, fg) + bk.pixmap.gfx.triangle(2*i, i, w - 2*i, i, w//2, h - 2*i, fg) - bk.Flip() + bk.flip() def tetragon(bk): - fg = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) - bg = bk.pixmap.RGBToPixel(0, 0, 0); + fg = bk.pixmap.rgb_to_pixel(0xee, 0xee, 0xee) + bg = bk.pixmap.rgb_to_pixel(0, 0, 0); - bk.pixmap.gfx.Fill(bg) + bk.pixmap.gfx.fill(bg) w = bk.pixmap.w h = bk.pixmap.h for i in range(10, 70, 10): - bk.pixmap.gfx.Tetragon(i, i, w-2*i, i, w-i, h-i, 2*i, h-i, fg) + bk.pixmap.gfx.tetragon(i, i, w-2*i, i, w-i, h-i, 2*i, h-i, fg) - bk.Flip() + bk.flip() def polygon(bk): - fg = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) - bg = bk.pixmap.RGBToPixel(0, 0, 0); + fg = bk.pixmap.rgb_to_pixel(0xee, 0xee, 0xee) + bg = bk.pixmap.rgb_to_pixel(0, 0, 0); - bk.pixmap.gfx.Fill(bg) + bk.pixmap.gfx.fill(bg) w = bk.pixmap.w h = bk.pixmap.h @@ -98,9 +98,9 @@ def polygon(bk): (w-10, (h-10)//3), (w-10, 10), (2*(w-10)//3, 10), ((w-10)//2, (h-10)//3), ((w-10)//3, 10)] - bk.pixmap.gfx.Polygon(polygon, fg) + bk.pixmap.gfx.polygon(polygon, fg) - bk.Flip() + bk.flip() def next(bk, i): @@ -137,10 +137,10 @@ def next(bk, i): def main(): # Create X11 window - bk = backends.BackendX11Init(None, 0, 0, 320, 240, "GFX demo", 0) + bk = backends.x11_init(None, 0, 0, 320, 240, "GFX demo", 0) assert(bk) - bk.Flip() + bk.flip() i = 0 @@ -148,9 +148,9 @@ def main(): # Event loop while True: - ev = bk.WaitEvent() + ev = bk.wait_event() - input.EventDump(ev) + input.event_dump(ev) if (ev.type == input.EV_KEY and ev.code == input.EV_KEY_DOWN): @@ -163,9 +163,9 @@ def main(): if (ev.code == input.EV_SYS_QUIT): sys.exit(0) elif (ev.code == input.EV_SYS_RESIZE): - bk.ResizeAck() + bk.resize_ack() fill(bk) - bk.Flip() + bk.flip() if __name__ == '__main__': main() diff --git a/demos/py_simple/gfxprim_qt.py b/demos/py_simple/gfxprim_qt.py index 61eabb2d5180..f6fbe1591c93 100755 --- a/demos/py_simple/gfxprim_qt.py +++ b/demos/py_simple/gfxprim_qt.py @@ -6,10 +6,10 @@ import gfxprim.core as core import gfxprim.loaders as loaders def getpixmap(path): - img = loaders.Load(path) + img = loaders.load(path) if img.pixel_type != core.C.PIXEL_BGR888: - img = img.Convert(core.C.PIXEL_BGR888) - qt_img = QtGui.QImage(img.ToByteArray(), img.w, img.h, + img = img.convert(core.C.PIXEL_BGR888) + qt_img = QtGui.QImage(img.to_byte_array(), img.w, img.h, img.bytes_per_row, QtGui.QImage.Format_RGB888) pix = QtGui.QPixmap.fromImage(qt_img) return pix diff --git a/demos/py_simple/invert.py b/demos/py_simple/invert.py index 684facc79746..4b316305042b 100755 --- a/demos/py_simple/invert.py +++ b/demos/py_simple/invert.py @@ -10,12 +10,12 @@ def main(): print("usage: invert.py image") sys.exit(1) - # Load Image - img = loaders.Load(sys.argv[1]) - # Invert image in-place - img.filters.Invert(img); + # load Image + img = loaders.load(sys.argv[1]) + # invert image in-place + img.filters.invert(img); # Save result into png - img.loaders.SavePNG("out.png") + img.loaders.save_png("out.png") if __name__ == '__main__': main() diff --git a/demos/py_simple/loaders_example.py b/demos/py_simple/loaders_example.py index 9b463d516a8c..55b0a1fad31f 100755 --- a/demos/py_simple/loaders_example.py +++ b/demos/py_simple/loaders_example.py @@ -10,10 +10,10 @@ def main(): print("Takes an image as an argument") sys.exit(1) - # Load Image - img = loaders.Load(sys.argv[1]) - # Save result - img.loaders.Save("out.png"); + # load Image + img = loaders.load(sys.argv[1]) + # save result + img.loaders.save("out.png"); if __name__ == '__main__': main() diff --git a/demos/py_simple/progress_callback.py b/demos/py_simple/progress_callback.py index 17b1570494fd..344400d8e1d4 100755 --- a/demos/py_simple/progress_callback.py +++ b/demos/py_simple/progress_callback.py @@ -7,7 +7,7 @@ import gfxprim.loaders as loaders import gfxprim.filters as filters def progress_callback1(perc): - sys.stdout.write("\rLoading %3.2f%%" % perc) + sys.stdout.write("\rloading %3.2f%%" % perc) sys.stdout.flush() return 0 @@ -22,7 +22,7 @@ def main(): sys.exit(1) try: - img = loaders.Load(sys.argv[1], progress_callback1) + img = loaders.load(sys.argv[1], progress_callback1) print('') except OSError as detail: print("Failed to load image '%s': %s" % (sys.argv[1], detail)) @@ -30,7 +30,7 @@ def main(): try: callback = (progress_callback2, "Gaussian Blur") - img = img.filters.GaussianBlurAlloc(50, 50, callback) + img = img.filters.gaussian_blur_alloc(50, 50, callback) print('') except OSError: print("Filter Aborted") diff --git a/demos/py_simple/resize.py b/demos/py_simple/resize.py index 7d11e2290f37..8fdb30455e36 100755 --- a/demos/py_simple/resize.py +++ b/demos/py_simple/resize.py @@ -10,12 +10,12 @@ def main(): print("USAGE: %s imput_image output_image" % sys.argv[0]); sys.exit(1) - # Load Image - src = loaders.Load(sys.argv[1]) + # load Image + src = loaders.load(sys.argv[1]) # Resize image to the half of the original - res = src.filters.ResizeLFIntAlloc(src.w//2, src.h//2) - # Save Image - res.loaders.Save(sys.argv[2]) + res = src.filters.resize_linear_lf_int_alloc(src.w//2, src.h//2) + # save Image + res.loaders.save(sys.argv[2]) if __name__ == '__main__': main() diff --git a/demos/py_simple/rotate90.py b/demos/py_simple/rotate90.py index 3a49af161de3..f73efd507573 100755 --- a/demos/py_simple/rotate90.py +++ b/demos/py_simple/rotate90.py @@ -11,14 +11,14 @@ def main(): sys.exit(1) # Turns on debug messages - core.SetDebugLevel(10); + core.set_debug_level(10); - # Load Image - src = loaders.Load(sys.argv[1]) + # load Image + src = loaders.load(sys.argv[1]) # Rotate by 90 degrees - res = src.filters.Rotate90Alloc() - # Save Image - res.loaders.Save(sys.argv[2]) + res = src.filters.rotate_90_alloc() + # save Image + res.loaders.save(sys.argv[2]) if __name__ == '__main__': main() diff --git a/demos/py_simple/showimage.py b/demos/py_simple/showimage.py index 07c54b41913a..7e6dc71f2519 100755 --- a/demos/py_simple/showimage.py +++ b/demos/py_simple/showimage.py @@ -12,20 +12,20 @@ def main(): print("Takes an image as an argument") sys.exit(1) - # Load Image - img = loaders.Load(sys.argv[1]) + # load Image + img = loaders.load(sys.argv[1]) # Create X11 window - bk = backends.BackendX11Init(None, 0, 0, img.w, img.h, sys.argv[1], 0) + bk = backends.x11_init(None, 0, 0, img.w, img.h, sys.argv[1], 0) assert(bk) - img.Blit(0, 0, bk.pixmap, 0, 0, img.w, img.h) - bk.Flip() + img.blit(0, 0, bk.pixmap, 0, 0, img.w, img.h) + bk.flip() # Event loop while True: - ev = bk.WaitEvent() + ev = bk.wait_event() - input.EventDump(ev) + input.event_dump(ev) if (ev.type == input.EV_KEY): sys.exit(0) diff --git a/demos/py_simple/x11_windows.py b/demos/py_simple/x11_windows.py index 3c34ff7a941e..2dda31265964 100755 --- a/demos/py_simple/x11_windows.py +++ b/demos/py_simple/x11_windows.py @@ -11,28 +11,28 @@ import gfxprim.text as text def redraw(bk, id): c = bk.pixmap - black = c.RGBToPixel(0, 0, 0) - white = c.RGBToPixel(0xff, 0xff, 0xff) + black = c.rgb_to_pixel(0, 0, 0) + white = c.rgb_to_pixel(0xff, 0xff, 0xff) - c.gfx.Fill(black) + c.gfx.fill(black) align = text.C.ALIGN_CENTER | text.C.VALIGN_CENTER - c.text.Text(None, c.w//2, c.h//2, align, white, black, "%s - %sx%s" % (id, c.w, c.h)) + c.text.text(None, c.w//2, c.h//2, align, white, black, "%s - %sx%s" % (id, c.w, c.h)) - bk.Flip() + bk.flip() def parse_events(bk, id): print("------ Window %s -------" % (id)) while True: - ev = bk.GetEvent() + ev = bk.get_event() if (ev == None): print("--------------------------") return - input.EventDump(ev) + input.event_dump(ev) if (ev.type == input.EV_KEY and ev.val.val == input.KEY_ESC): sys.exit(0) @@ -40,13 +40,13 @@ def parse_events(bk, id): if (ev.code == input.EV_SYS_QUIT): sys.exit(0) if (ev.code == input.EV_SYS_RESIZE): - bk.ResizeAck() + bk.resize_ack() redraw(bk, id) def main(): # Create X11 windows - win1 = backends.BackendX11Init(None, 0, 0, 200, 100, "Win 1", 0) - win2 = backends.BackendX11Init(None, 0, 0, 200, 100, "Win 2", 0) + win1 = backends.x11_init(None, 0, 0, 200, 100, "Win 1", 0) + win2 = backends.x11_init(None, 0, 0, 200, 100, "Win 2", 0) assert(win1) assert(win2) @@ -55,12 +55,12 @@ def main(): # Event loop while True: - win1.Wait() + win1.wait() - if (win1.EventsQueued()): + if (win1.events_queued()): parse_events(win1, "win1") - if (win2.EventsQueued()): + if (win2.events_queued()): parse_events(win2, "win2") if __name__ == '__main__': diff --git a/demos/spiv/image_cache.c b/demos/spiv/image_cache.c index 28ea5bbbfc22..37631e4f8243 100644 --- a/demos/spiv/image_cache.c +++ b/demos/spiv/image_cache.c @@ -22,12 +22,12 @@ #include <stdarg.h> #include <string.h> -#include <GP.h> +#include <gfxprim.h> #include "image_cache.h" struct image { - GP_Pixmap *pixmap; - GP_DataStorage *meta_data; + gp_pixmap *pixmap; + gp_storage *meta_data; struct image *prev; struct image *next; @@ -73,11 +73,11 @@ size_t image_cache_get_ram_size(void) /* * Reports correct image record size. */ -static size_t image_size2(GP_Pixmap *pixmap, GP_DataStorage *meta_data, +static size_t image_size2(gp_pixmap *pixmap, gp_storage *meta_data, const char *path) { size_t meta_data_size = 0; - size_t pixmap_size = pixmap->bytes_per_row * pixmap->h + sizeof(GP_Pixmap); + size_t pixmap_size = pixmap->bytes_per_row * pixmap->h + sizeof(gp_pixmap); //TODO! 4096 is a size of single block, data storage may have more blocks if (meta_data) @@ -135,8 +135,8 @@ static void remove_img_free(struct image_cache *self, ...e-mail trimmed, has been too large.
1
0
0
0
Results per page:
10
25
50
100
200