Gfxprim
Threads by month
- ----- 2026 -----
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 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
- 929 discussions
[repo.or.cz] gfxprim.git branch master updated: 3f35d87f9ab132a5e60d3c6d7d8324af2da43653
by metan 20 Oct '12
by metan 20 Oct '12
20 Oct '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 3f35d87f9ab132a5e60d3c6d7d8324af2da43653 (commit)
from 82d3a2388b9c9001295fbaf68efe9a11469dbf65 (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 -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/3f35d87f9ab132a5e60d3c6d7d8324af2da4…
commit 3f35d87f9ab132a5e60d3c6d7d8324af2da43653
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Oct 20 12:46:32 2012 +0200
tests: loaders: More JPEG and PNG tests.
diff --git a/tests/loaders/data/jpeg/valid/100x100-red.jpeg b/tests/loaders/data/jpeg/valid/100x100-red.jpeg
new file mode 100644
index 0000000..0101283
Binary files /dev/null and b/tests/loaders/data/jpeg/valid/100x100-red.jpeg differ
diff --git a/tests/loaders/data/png/valid/100x100-red-alpha.png b/tests/loaders/data/png/valid/100x100-red-alpha.png
new file mode 100644
index 0000000..31ca1bc
Binary files /dev/null and b/tests/loaders/data/png/valid/100x100-red-alpha.png differ
diff --git a/tests/loaders/data/png/valid/100x100-red.png b/tests/loaders/data/png/valid/100x100-red.png
new file mode 100644
index 0000000..4bf87f3
Binary files /dev/null and b/tests/loaders/data/png/valid/100x100-red.png differ
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c
index de84a8e..c87c6f9 100644
--- a/tests/loaders/loaders_suite.c
+++ b/tests/loaders/loaders_suite.c
@@ -561,6 +561,71 @@ static int test_load_BMP_8bpp_1x64000(void)
return test_load_BMP("8bpp-1x64000.bmp");
}
+static int test_load_PNG(const char *path)
+{
+ GP_Context *img;
+
+ img = GP_LoadPNG(path, NULL);
+
+ if (img == NULL) {
+ switch (errno) {
+ case ENOSYS:
+ tst_report(0, "Not Implemented");
+ return TST_SKIPPED;
+ default:
+ tst_report(0, "Got %s", strerror(errno));
+ return TST_FAILED;
+ }
+ }
+
+ /*
+ * TODO: check correct data.
+ */
+ GP_ContextFree(img);
+
+ return TST_SUCCESS;
+}
+
+static int test_load_PNG_100x100(void)
+{
+ return test_load_PNG("100x100-red.png");
+}
+
+static int test_load_PNG_100x100_alpha(void)
+{
+ return test_load_PNG("100x100-red-alpha.png");
+}
+
+static int test_load_JPEG(const char *path)
+{
+ GP_Context *img;
+
+ img = GP_LoadJPG(path, NULL);
+
+ if (img == NULL) {
+ switch (errno) {
+ case ENOSYS:
+ tst_report(0, "Not Implemented");
+ return TST_SKIPPED;
+ default:
+ tst_report(0, "Got %s", strerror(errno));
+ return TST_FAILED;
+ }
+ }
+
+ /*
+ * TODO: check correct data.
+ */
+ GP_ContextFree(img);
+
+ return TST_SUCCESS;
+}
+
+static int test_load_JPEG_100x100(void)
+{
+ return test_load_JPEG("100x100-red.jpeg");
+}
+
const struct tst_suite tst_suite = {
.suite_name = "Image Loaders testsuite",
.tests = {
@@ -615,29 +680,60 @@ const struct tst_suite tst_suite = {
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
/* BPM loader tests */
- {.name = "BMP Load 1bpp 1x1", .tst_fn = test_load_BMP_1bpp_1x1,
- .flags = TST_TMPDIR, .res_path = "data/bmp/bitmaps/valid/1bpp-1x1.bmp"},
+ {.name = "BMP Load 1bpp 1x1",
+ .tst_fn = test_load_BMP_1bpp_1x1,
+ .res_path = "data/bmp/bitmaps/valid/1bpp-1x1.bmp",
+ .flags = TST_TMPDIR},
- {.name = "BMP Load 4bpp 1x1", .tst_fn = test_load_BMP_4bpp_1x1,
- .flags = TST_TMPDIR, .res_path = "data/bmp/bitmaps/valid/4bpp-1x1.bmp"},
+ {.name = "BMP Load 4bpp 1x1",
+ .tst_fn = test_load_BMP_4bpp_1x1,
+ .res_path = "data/bmp/bitmaps/valid/4bpp-1x1.bmp",
+ .flags = TST_TMPDIR},
- {.name = "BMP Load 8bpp 1x1", .tst_fn = test_load_BMP_8bpp_1x1,
- .flags = TST_TMPDIR, .res_path = "data/bmp/bitmaps/valid/8bpp-1x1.bmp"},
+ {.name = "BMP Load 8bpp 1x1",
+ .tst_fn = test_load_BMP_8bpp_1x1,
+ .res_path = "data/bmp/bitmaps/valid/8bpp-1x1.bmp",
+ .flags = TST_TMPDIR},
- {.name = "BMP 24bpp 1x1", .tst_fn = test_load_BMP_24bpp_1x1,
- .flags = TST_TMPDIR, .res_path = "data/bmp/bitmaps/valid/24bpp-1x1.bmp"},
+ {.name = "BMP 24bpp 1x1",
+ .tst_fn = test_load_BMP_24bpp_1x1,
+ .res_path = "data/bmp/bitmaps/valid/24bpp-1x1.bmp",
+ .flags = TST_TMPDIR},
- {.name = "BMP 32bpp 1x1", .tst_fn = test_load_BMP_32bpp_1x1,
- .flags = TST_TMPDIR, .res_path = "data/bmp/bitmaps/valid/32bpp-1x1.bmp"},
+ {.name = "BMP 32bpp 1x1",
+ .tst_fn = test_load_BMP_32bpp_1x1,
+ .res_path = "data/bmp/bitmaps/valid/32bpp-1x1.bmp",
+ .flags = TST_TMPDIR},
- {.name = "BMP 555 1x1", .tst_fn = test_load_BMP_555_1x1,
- .flags = TST_TMPDIR, .res_path = "data/bmp/bitmaps/valid/555-1x1.bmp"},
+ {.name = "BMP 555 1x1",
+ .tst_fn = test_load_BMP_555_1x1,
+ .res_path = "data/bmp/bitmaps/valid/555-1x1.bmp",
+ .flags = TST_TMPDIR},
- {.name = "BMP 565 1x1", .tst_fn = test_load_BMP_565_1x1,
- .flags = TST_TMPDIR, .res_path = "data/bmp/bitmaps/valid/565-1x1.bmp"},
+ {.name = "BMP 565 1x1",
+ .tst_fn = test_load_BMP_565_1x1,
+ .res_path = "data/bmp/bitmaps/valid/565-1x1.bmp",
+ .flags = TST_TMPDIR},
+
+ {.name = "BMP 8bpp 1x64000",
+ .tst_fn = test_load_BMP_8bpp_1x64000,
+ .res_path = "data/bmp/bitmaps/valid/8bpp-1x64000.bmp",
+ .flags = TST_TMPDIR},
+
+ /* PNG loader tests */
+ {.name = "PNG 100x100", .tst_fn = test_load_PNG_100x100,
+ .res_path = "data/png/valid/100x100-red.png",
+ .flags = TST_TMPDIR},
- {.name = "BMP 8bpp 1x64000", .tst_fn = test_load_BMP_8bpp_1x64000,
- .flags = TST_TMPDIR, .res_path = "data/bmp/bitmaps/valid/8bpp-1x64000.bmp"},
+ {.name = "PNG 100x100 50% alpha",
+ .tst_fn = test_load_PNG_100x100_alpha,
+ .res_path = "data/png/valid/100x100-red-alpha.png",
+ .flags = TST_TMPDIR},
+
+ /* JPEG loader tests */
+ {.name = "JPEG 100x100", .tst_fn = test_load_JPEG_100x100,
+ .res_path = "data/jpeg/valid/100x100-red.jpeg",
+ .flags = TST_TMPDIR},
{.name = NULL},
}
-----------------------------------------------------------------------
Summary of changes:
tests/loaders/data/jpeg/valid/100x100-red.jpeg | Bin 0 -> 382 bytes
tests/loaders/data/png/valid/100x100-red-alpha.png | Bin 0 -> 315 bytes
tests/loaders/data/png/valid/100x100-red.png | Bin 0 -> 309 bytes
tests/loaders/loaders_suite.c | 128 +++++++++++++++++---
4 files changed, 112 insertions(+), 16 deletions(-)
create mode 100644 tests/loaders/data/jpeg/valid/100x100-red.jpeg
create mode 100644 tests/loaders/data/png/valid/100x100-red-alpha.png
create mode 100644 tests/loaders/data/png/valid/100x100-red.png
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 82d3a2388b9c9001295fbaf68efe9a11469dbf65
by metan 20 Oct '12
by metan 20 Oct '12
20 Oct '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 82d3a2388b9c9001295fbaf68efe9a11469dbf65 (commit)
from 101233f4b4f483e4633302fe978f051ee5c4e472 (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 -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/82d3a2388b9c9001295fbaf68efe9a11469d…
commit 82d3a2388b9c9001295fbaf68efe9a11469dbf65
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Oct 20 11:45:59 2012 +0200
tests: core: More cases for GetPutPixel.
diff --git a/tests/core/GetPutPixel.gen.c.t b/tests/core/GetPutPixel.gen.c.t
index b462bce..5f1354a 100644
--- a/tests/core/GetPutPixel.gen.c.t
+++ b/tests/core/GetPutPixel.gen.c.t
@@ -35,8 +35,8 @@ static void fill_context(GP_Context *c, GP_Pixel p)
{
GP_Coord x, y;
- for (x = 0; x < c->w; x++)
- for (y = 0; y < c->h; y++)
+ for (x = 0; x < (GP_Coord)c->w; x++)
+ for (y = 0; y < (GP_Coord)c->h; y++)
GP_PutPixel(c, x, y, p);
}
@@ -47,8 +47,8 @@ static int check_filled(GP_Context *c)
p = GP_GetPixel(c, 0, 0);
- for (x = 0; x < c->w; x++)
- for (y = 0; y < c->h; y++)
+ for (x = 0; x < (GP_Coord)c->w; x++)
+ for (y = 0; y < (GP_Coord)c->h; y++)
if (p != GP_GetPixel(c, x, y)) {
tst_report(0, "Pixels different %i %i", x, y);
return 1;
@@ -80,7 +80,7 @@ static int GetPutPixel_{{ pt.name }}(void)
if (c == NULL) {
tst_report(0, "GP_ContextAlloc() failed");
- return TST_FAILED;
+ return TST_UNTESTED;
}
if (try_pattern(c, 0x55555555 & {{ 2 ** pt.pixelsize.size - 1}}))
@@ -105,6 +105,51 @@ static int GetPutPixel_{{ pt.name }}(void)
%% endif
%% endfor
+%% for pt in pixeltypes
+%% if not pt.is_unknown()
+static int GetPutPixel_Clipping_{{ pt.name }}(void)
+{
+ GP_Context *c;
+
+ c = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt.name }});
+
+ if (c == NULL) {
+ tst_report(0, "GP_ContextAlloc() failed");
+ return TST_UNTESTED;
+ }
+
+ fill_context(c, 0xffffffff);
+
+ GP_Coord x, y;
+ int err = 0;
+
+ for (x = -1000; x < 200; x++) {
+ for (y = -1000; y < 200; y++) {
+ if (x > 0 && x < 100 && y > 0 && y < 100)
+ continue;
+
+ /* Must be no-op */
+ GP_PutPixel(c, x, y, 0);
+
+ /* Must return 0 */
+ if (GP_GetPixel(c, x, y) != 0) {
+ tst_report(0, "GP_GetPixel returned non-zero "
+ "at %i %i", x, y);
+ err++;
+ }
+ }
+ }
+
+ GP_ContextFree(c);
+
+ if (err)
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+%% endif
+%% endfor
+
const struct tst_suite tst_suite = {
.suite_name = "GetPutPixel Testsuite",
.tests = {
@@ -114,6 +159,13 @@ const struct tst_suite tst_suite = {
.tst_fn = GetPutPixel_{{ pt.name }}},
%% endif
%% endfor
+
+%% for pt in pixeltypes
+%% if not pt.is_unknown()
+ {.name = "GetPutPixel Clipping {{ pt.name }}",
+ .tst_fn = GetPutPixel_Clipping_{{ pt.name }}},
+%% endif
+%% endfor
{.name = NULL}
}
-----------------------------------------------------------------------
Summary of changes:
tests/core/GetPutPixel.gen.c.t | 62 ++++++++++++++++++++++++++++++++++++---
1 files changed, 57 insertions(+), 5 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 101233f4b4f483e4633302fe978f051ee5c4e472
by metan 20 Oct '12
by metan 20 Oct '12
20 Oct '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 101233f4b4f483e4633302fe978f051ee5c4e472 (commit)
from 7d30cb21d991fc207b0cc99038494e647307a598 (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 -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/101233f4b4f483e4633302fe978f051ee5c4…
commit 101233f4b4f483e4633302fe978f051ee5c4e472
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Oct 20 11:13:41 2012 +0200
tests: framework: Add UNTESTED test status.
diff --git a/tests/framework/test.c b/tests/framework/test.c
index f4a8692..ccef65d 100644
--- a/tests/framework/test.c
+++ b/tests/framework/test.c
@@ -186,11 +186,25 @@ int fail_FILE(void)
return TST_SUCCESS;
}
+/*
+ * This status is returned when the could not be started
+ * because of unsufficient configuration
+ */
static int skipped_fn(void)
{
return TST_SKIPPED;
}
+/*
+ * This status is returned when there was failure prior
+ * the actuall testing so we could not test the feature
+ * at all.
+ */
+static int untested_fn(void)
+{
+ return TST_UNTESTED;
+}
+
static int res_fn(void)
{
if (access("test.c", R_OK) == 0)
@@ -226,6 +240,7 @@ const struct tst_suite tst_suite = {
.tests = {
{.name = "Success test", .tst_fn = success_fn},
{.name = "Skipped test", .tst_fn = skipped_fn},
+ {.name = "Untested test", .tst_fn = untested_fn},
{.name = "Sigsegv test", .tst_fn = sigsegv_fn},
{.name = "Failed test", .tst_fn = failed_fn},
{.name = "Stack overflow test", .tst_fn = stack_overflow_fn},
diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c
index a1f7272..8a0789b 100644
--- a/tests/framework/tst_job.c
+++ b/tests/framework/tst_job.c
@@ -77,6 +77,9 @@ static void stop_test(struct tst_job *job)
case TST_SKIPPED:
result = "[ e[1;30mSKIPPEDe[0m ]";
break;
+ case TST_UNTESTED:
+ result = "[ e[1;34mUNTESTEDe[0m ]";
+ break;
case TST_INTERR:
result = "[ e[1;31mINTERNAL ERRORe[0m ]";
break;
diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c
index 772b20b..a70f8c0 100644
--- a/tests/framework/tst_log.c
+++ b/tests/framework/tst_log.c
@@ -36,6 +36,8 @@ static const char *ret_to_bg_color(enum tst_ret ret)
return "#008000";
case TST_SKIPPED:
return "#888888";
+ case TST_UNTESTED:
+ return "#0000bb";
case TST_INTERR:
return "#800000";
case TST_SIGSEGV:
@@ -64,6 +66,8 @@ static const char *ret_to_str(enum tst_ret ret)
return "Success";
case TST_SKIPPED:
return "Skipped";
+ case TST_UNTESTED:
+ return "Untested";
case TST_INTERR:
return "Internal Error";
case TST_SIGSEGV:
diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h
index b9a0c17..c6ef4fe 100644
--- a/tests/framework/tst_test.h
+++ b/tests/framework/tst_test.h
@@ -24,15 +24,16 @@
#define TST_TEST_H
enum tst_ret {
- TST_SUCCESS, /* Test succedded */
- TST_SKIPPED, /* Test skipped due to not enough memory, ENOSYS ... */
- TST_INTERR, /* Test framework error */
- TST_SIGSEGV, /* Test ended with SIGSEGV */
- TST_TIMEOUT, /* Test hasn't finished in time */
- TST_ABORTED, /* The abort() was called (possible double free) */
- TST_FPE, /* Floating point exception */
- TST_MEMLEAK, /* Memory leak was detected */
- TST_FAILED, /* Test failed */
+ TST_SUCCESS, /* Test succedded */
+ TST_SKIPPED, /* Test skipped due to not enough memory, ENOSYS ... */
+ TST_UNTESTED, /* Test not finished because of failure */
+ TST_INTERR, /* Test framework error */
+ TST_SIGSEGV, /* Test ended with SIGSEGV */
+ TST_TIMEOUT, /* Test hasn't finished in time */
+ TST_ABORTED, /* The abort() was called (possible double free) */
+ TST_FPE, /* Floating point exception */
+ TST_MEMLEAK, /* Memory leak was detected */
+ TST_FAILED, /* Test failed */
TST_MAX = TST_FAILED+1,
};
-----------------------------------------------------------------------
Summary of changes:
tests/framework/test.c | 15 +++++++++++++++
tests/framework/tst_job.c | 3 +++
tests/framework/tst_log.c | 4 ++++
tests/framework/tst_test.h | 19 ++++++++++---------
4 files changed, 32 insertions(+), 9 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 7d30cb21d991fc207b0cc99038494e647307a598
by metan 20 Oct '12
by metan 20 Oct '12
20 Oct '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 7d30cb21d991fc207b0cc99038494e647307a598 (commit)
from f5e28f46785b6f44488672e5a1a6a878137a44be (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 -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/7d30cb21d991fc207b0cc99038494e647307…
commit 7d30cb21d991fc207b0cc99038494e647307a598
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Oct 20 00:17:14 2012 +0200
tests: framework: Fix benchmark JSON output.
diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c
index b1e43b8..772b20b 100644
--- a/tests/framework/tst_log.c
+++ b/tests/framework/tst_log.c
@@ -341,7 +341,7 @@ static void append_benchmark_json(struct tst_job *job, FILE *f)
fprintf(f, "tttt"Iterations": %in", job->bench_iter);
- fprintf(f, "ttt}n");
+ fprintf(f, "ttt},n");
}
static int hack_json_start = 0;
-----------------------------------------------------------------------
Summary of changes:
tests/framework/tst_log.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: f5e28f46785b6f44488672e5a1a6a878137a44be
by metan 19 Oct '12
by metan 19 Oct '12
19 Oct '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via f5e28f46785b6f44488672e5a1a6a878137a44be (commit)
from a5f3ffffa6adc218386bcec41f5cd1ebe691a7df (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 -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/f5e28f46785b6f44488672e5a1a6a878137a…
commit f5e28f46785b6f44488672e5a1a6a878137a44be
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Oct 19 23:30:11 2012 +0200
tests: core: Created GetPutPixel test.
diff --git a/tests/core/GetPutPixel.gen.c.t b/tests/core/GetPutPixel.gen.c.t
new file mode 100644
index 0000000..b462bce
--- /dev/null
+++ b/tests/core/GetPutPixel.gen.c.t
@@ -0,0 +1,122 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+%% extends "base.test.c.t"
+
+%% block body
+
+#include <stdio.h>
+
+#include <core/GP_Context.h>
+#include <core/GP_GetPutPixel.h>
+
+#include "tst_test.h"
+
+static void fill_context(GP_Context *c, GP_Pixel p)
+{
+ GP_Coord x, y;
+
+ for (x = 0; x < c->w; x++)
+ for (y = 0; y < c->h; y++)
+ GP_PutPixel(c, x, y, p);
+}
+
+static int check_filled(GP_Context *c)
+{
+ GP_Coord x, y;
+ GP_Pixel p;
+
+ p = GP_GetPixel(c, 0, 0);
+
+ for (x = 0; x < c->w; x++)
+ for (y = 0; y < c->h; y++)
+ if (p != GP_GetPixel(c, x, y)) {
+ tst_report(0, "Pixels different %i %i", x, y);
+ return 1;
+ }
+
+ return 0;
+}
+
+static int try_pattern(GP_Context *c, GP_Pixel p)
+{
+ fill_context(c, p);
+
+ tst_report(0, "Filling pattern 0x%x", p);
+
+ if (check_filled(c))
+ return 1;
+
+ return 0;
+}
+
+%% for pt in pixeltypes
+%% if not pt.is_unknown()
+static int GetPutPixel_{{ pt.name }}(void)
+{
+ GP_Context *c;
+ int err = 0;
+
+ c = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt.name }});
+
+ if (c == NULL) {
+ tst_report(0, "GP_ContextAlloc() failed");
+ return TST_FAILED;
+ }
+
+ if (try_pattern(c, 0x55555555 & {{ 2 ** pt.pixelsize.size - 1}}))
+ err++;
+
+ if (try_pattern(c, 0xaaaaaaaa & {{ 2 ** pt.pixelsize.size - 1}}))
+ err++;
+
+ if (try_pattern(c, 0x0f0f0f0f & {{ 2 ** pt.pixelsize.size - 1}}))
+ err++;
+
+ if (try_pattern(c, 0xf0f0f0f0 & {{ 2 ** pt.pixelsize.size - 1}}))
+ err++;
+
+ GP_ContextFree(c);
+
+ if (err)
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+%% endif
+%% endfor
+
+const struct tst_suite tst_suite = {
+ .suite_name = "GetPutPixel Testsuite",
+ .tests = {
+%% for pt in pixeltypes
+%% if not pt.is_unknown()
+ {.name = "GetPutPixel {{ pt.name }}",
+ .tst_fn = GetPutPixel_{{ pt.name }}},
+%% endif
+%% endfor
+
+ {.name = NULL}
+ }
+};
+
+%% endblock body
diff --git a/tests/core/Makefile b/tests/core/Makefile
index 6b8b9a0..54d105a 100644
--- a/tests/core/Makefile
+++ b/tests/core/Makefile
@@ -7,9 +7,9 @@ CSOURCES=Context.c
# hack
LIBNAME=core
-GENSOURCES+=WritePixel_testsuite.gen.c
+GENSOURCES+=WritePixel_testsuite.gen.c GetPutPixel.gen.c
-APPS=WritePixel_testsuite.gen Context
+APPS=WritePixel_testsuite.gen Context GetPutPixel.gen
include ../tests.mk
diff --git a/tests/core/runtest.sh b/tests/core/runtest.sh
index a392647..7e20739 100755
--- a/tests/core/runtest.sh
+++ b/tests/core/runtest.sh
@@ -11,3 +11,4 @@ export LIBC_FATAL_STDERR_=1
LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./WritePixel_testsuite.gen "$@"
LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Context "$@"
+LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./GetPutPixel.gen "$@"
-----------------------------------------------------------------------
Summary of changes:
tests/core/{Context.c => GetPutPixel.gen.c.t} | 127 ++++++++++++++-----------
tests/core/Makefile | 4 +-
tests/core/runtest.sh | 1 +
3 files changed, 74 insertions(+), 58 deletions(-)
copy tests/core/{Context.c => GetPutPixel.gen.c.t} (57%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: a5f3ffffa6adc218386bcec41f5cd1ebe691a7df
by metan 19 Oct '12
by metan 19 Oct '12
19 Oct '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via a5f3ffffa6adc218386bcec41f5cd1ebe691a7df (commit)
from 54a1f43dff8349c620ab43306651236f9143e5ee (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 -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/a5f3ffffa6adc218386bcec41f5cd1ebe691…
commit a5f3ffffa6adc218386bcec41f5cd1ebe691a7df
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Oct 19 22:16:01 2012 +0200
core+all: Finally GP_RetCode free.
diff --git a/doc/drawing_api.txt b/doc/drawing_api.txt
index 75b6aa2..0304138 100644
--- a/doc/drawing_api.txt
+++ b/doc/drawing_api.txt
@@ -247,8 +247,8 @@ typedef enum GP_TextAlign {
GP_VALIGN_BELOW = 0x40 /* below the point */
} GP_TextAlign;
-GP_RetCode GP_Text(GP_Context *context, const GP_TextStyle *style,
- int x, int y, int align, const char *str, GP_Pixel pixel);
+void GP_Text(GP_Context *context, const GP_TextStyle *style,
+ int x, int y, int align, const char *str, GP_Pixel pixel);
--------------------------------------------------------------------------------
Draws text at the position x and y; the alignment of the text in relation
diff --git a/include/SDL/GP_SDL_Context.h b/include/SDL/GP_SDL_Context.h
index af53f54..5f27a4a 100644
--- a/include/SDL/GP_SDL_Context.h
+++ b/include/SDL/GP_SDL_Context.h
@@ -27,8 +27,7 @@
#define GP_SDL_CONTEXT_H
#include "GP.h"
-#include "core/GP_RetCode.h"
-GP_RetCode GP_SDL_ContextFromSurface(GP_Context *context, SDL_Surface *surf);
+int GP_SDL_ContextFromSurface(GP_Context *context, SDL_Surface *surf);
#endif /* GP_SDL_CONTEXT_H */
diff --git a/include/SDL/GP_SDL_VideoInit.h b/include/SDL/GP_SDL_VideoInit.h
index 99927b6..ad26c10 100644
--- a/include/SDL/GP_SDL_VideoInit.h
+++ b/include/SDL/GP_SDL_VideoInit.h
@@ -27,9 +27,8 @@
#define GP_SDL_VIDEOINIT_H
#include "GP.h"
-#include "core/GP_RetCode.h"
-GP_RetCode GP_SDL_VideoInit(GP_Context *context, int width, int height,
+int GP_SDL_VideoInit(GP_Context *context, int width, int height,
int argc, char **argv);
#endif /* GP_SDL_VIDEOINIT_H */
diff --git a/include/core/GP_RetCode.h b/include/core/GP_RetCode.h
deleted file mode 100644
index ce875fd..0000000
--- a/include/core/GP_RetCode.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*****************************************************************************
- * 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-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#ifndef CORE_GP_RETCODE_H
-#define CORE_GP_RETCODE_H
-
-typedef enum GP_RetCode {
- GP_ESUCCESS,
- GP_EINVAL,
- GP_ENOIMPL,
- GP_EUNPRECISE,
- GP_ENULLPTR, /* some argument was unexpectedly NULL */
- GP_ENOBACKEND, /* no backend available */
- GP_EBACKENDLOST, /* lost connection to the backend */
- GP_EBADCONTEXT, /* context contains invalid data */
- GP_EBADFILE, /* error in file, or bad file format */
- GP_ENOENT, /* no such file or another object */
- GP_ENOMEM, /* not enough memory */
- GP_EINTR, /* operation interrupted by user */
- GP_EMAX,
-} GP_RetCode;
-
-const char *GP_RetCodeName(GP_RetCode code);
-
-#endif /* CORE_GP_RETCODE_H */
diff --git a/libs/SDL/GP_SDL_Context.c b/libs/SDL/GP_SDL_Context.c
index 5ced9cc..cbe5ca4 100644
--- a/libs/SDL/GP_SDL_Context.c
+++ b/libs/SDL/GP_SDL_Context.c
@@ -31,14 +31,14 @@
#include "GP_SDL.h"
-GP_RetCode GP_SDL_ContextFromSurface(GP_Context *context, SDL_Surface *surf)
+int GP_SDL_ContextFromSurface(GP_Context *context, SDL_Surface *surf)
{
if (surf == NULL || surf->pixels == NULL || context == NULL)
- return GP_ENULLPTR;
+ return 1;
/* sanity checks on the SDL surface */
if (surf->format->BytesPerPixel == 0 || surf->format->BytesPerPixel > 4)
- return GP_ENOIMPL;
+ return 1;
enum GP_PixelType pixeltype = GP_PixelRGBMatch(surf->format->Rmask,
surf->format->Gmask,
@@ -47,7 +47,7 @@ GP_RetCode GP_SDL_ContextFromSurface(GP_Context *context, SDL_Surface *surf)
surf->format->BitsPerPixel);
if (pixeltype == GP_PIXEL_UNKNOWN)
- return GP_ENOIMPL;
+ return 1;
/* basic structure and size */
context->pixels = surf->pixels;
@@ -62,7 +62,7 @@ GP_RetCode GP_SDL_ContextFromSurface(GP_Context *context, SDL_Surface *surf)
context->x_swap = 0;
context->y_swap = 0;
- return GP_ESUCCESS;
+ return 0;
}
#endif /* HAVE_LIBSDL */
diff --git a/libs/SDL/GP_SDL_VideoInit.c b/libs/SDL/GP_SDL_VideoInit.c
index 8ce6419..b7462ff 100644
--- a/libs/SDL/GP_SDL_VideoInit.c
+++ b/libs/SDL/GP_SDL_VideoInit.c
@@ -33,11 +33,11 @@
#include <stdio.h>
#include <string.h>
-GP_RetCode GP_SDL_VideoInit(GP_Context *context, int width, int height,
+int GP_SDL_VideoInit(GP_Context *context, int width, int height,
int argc, char **argv)
{
if (context == NULL)
- return GP_ENULLPTR;
+ return 1;
/* switches that can be set on the command line */
int display_bpp = 0;
@@ -46,7 +46,7 @@ GP_RetCode GP_SDL_VideoInit(GP_Context *context, int width, int height,
if (argc > 0) {
if (argv == NULL)
- return GP_ENULLPTR;
+ return 1;
/* extract settings from the command line */
int i;
@@ -69,7 +69,7 @@ GP_RetCode GP_SDL_VideoInit(GP_Context *context, int width, int height,
fprintf(stderr, "Error: Could not initialize SDL: %sn",
SDL_GetError());
}
- return GP_EBACKENDLOST;
+ return 1;
}
SDL_Surface *display = NULL;
@@ -80,7 +80,7 @@ GP_RetCode GP_SDL_VideoInit(GP_Context *context, int width, int height,
SDL_GetError());
}
SDL_Quit();
- return GP_EINVAL;
+ return 1;
}
if (debug) {
@@ -94,18 +94,16 @@ GP_RetCode GP_SDL_VideoInit(GP_Context *context, int width, int height,
display->format->Bmask, display->format->Amask);
}
- GP_RetCode retcode;
- retcode = GP_SDL_ContextFromSurface(context, display);
- if (retcode != GP_ESUCCESS) {
+ int retcode = GP_SDL_ContextFromSurface(context, display);
+ if (retcode != 0) {
if (debug) {
- fprintf(stderr, "Error: Could not create context: %sn",
- GP_RetCodeName(retcode));
+ fprintf(stderr, "Error: Could not create context");
}
SDL_Quit();
return retcode;
}
- return GP_ESUCCESS;
+ return 0;
}
#endif /* HAVE_LIBSDL */
diff --git a/libs/core/GP_RetCode.c b/libs/core/GP_RetCode.c
deleted file mode 100644
index f14b5cc..0000000
--- a/libs/core/GP_RetCode.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*****************************************************************************
- * 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-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include "GP_RetCode.h"
-
-/* Names of return codes; must be in the same order as the codes */
-static char *ret_code_names[] = {
- "Success",
- "Invalid operation",
- "Not implemented",
- "Imprecise result",
- "Unexpected null pointer",
- "No backend available",
- "Connection with backend lost",
- "Bad context",
- "Bad file",
- "Not found",
- "Not enough memory",
- "Operation interrupted"
-};
-
-const char *GP_RetCodeName(GP_RetCode code)
-{
- if (code >= GP_EMAX)
- return "Invalid return code";
-
- return ret_code_names[code];
-}
-----------------------------------------------------------------------
Summary of changes:
doc/drawing_api.txt | 4 +-
include/SDL/GP_SDL_Context.h | 3 +-
include/SDL/GP_SDL_VideoInit.h | 3 +-
include/core/GP_RetCode.h | 47 -------------------------------------
libs/SDL/GP_SDL_Context.c | 10 ++++----
libs/SDL/GP_SDL_VideoInit.c | 20 +++++++--------
libs/core/GP_RetCode.c | 50 ----------------------------------------
7 files changed, 18 insertions(+), 119 deletions(-)
delete mode 100644 include/core/GP_RetCode.h
delete mode 100644 libs/core/GP_RetCode.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 54a1f43dff8349c620ab43306651236f9143e5ee
by metan 19 Oct '12
by metan 19 Oct '12
19 Oct '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 54a1f43dff8349c620ab43306651236f9143e5ee (commit)
via 06eae5a43e1b6e46979c1e42e392475cbde92947 (commit)
from 5f13bc0a920bfb4b903a6982b66a091825c4228e (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 -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/54a1f43dff8349c620ab43306651236f9143…
commit 54a1f43dff8349c620ab43306651236f9143e5ee
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Oct 19 21:49:18 2012 +0200
demos: c_simple: Port linetest to backends.
diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile
index 2c03ec8..f703dd1 100644
--- a/demos/c_simple/Makefile
+++ b/demos/c_simple/Makefile
@@ -9,7 +9,7 @@ LDLIBS+=-lrt `$(TOPDIR)/gfxprim-config --libs --libs-backends`
APPS=backend_example loaders_example loaders filters_symmetry gfx_koch virtual_backend_example meta_data meta_data_dump tmp_file showimage v4l2_show v4l2_grab convolution weighted_median shapetest koch input- fileview
+ fileview linetest
v4l2_show: LDLIBS+=-lGP_grabbers
v4l2_grab: LDLIBS+=-lGP_grabbers
diff --git a/demos/c_simple/linetest.c b/demos/c_simple/linetest.c
new file mode 100644
index 0000000..9e7078b
--- /dev/null
+++ b/demos/c_simple/linetest.c
@@ -0,0 +1,137 @@
+/*****************************************************************************
+ * 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-2010 Jiri "BlueBear" Dluhos *
+ * <jiri.bluebear.dluhos(a)gmail.com> *
+ * *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <math.h>
+
+#include <GP.h>
+
+/* Values for color pixels in display format. */
+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;
+
+void redraw_screen(void)
+{
+ double angle;
+ int x, y;
+ int w = win->context->w;
+ int h = win->context->h;
+ int xcenter = w/2;
+ int ycenter = h/2;
+
+ GP_Fill(win->context, black);
+
+ for (angle = 0.0; angle < 2*M_PI; angle += 0.1) {
+ x = (int) (w/2 * cos(start_angle + angle));
+ y = (int) (h/2 * sin(start_angle + angle));
+
+ 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->context->pixel_type);
+
+ if (aa_flag) {
+ GP_LineAA_Raw(win->context, 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->context, xcenter + x, ycenter + y, xcenter, ycenter, pixel);
+ GP_Line(win->context, xcenter, ycenter, xcenter + x, ycenter + y, pixel);
+ }
+ }
+
+ GP_BackendFlip(win);
+
+ /* axes */
+// GP_HLineXYW(&context, 0, ycenter, display->w, white);
+// GP_VLineXYH(&context, xcenter, 0, display->h, white);
+}
+
+void event_loop(void)
+{
+ GP_Event ev;
+
+ while (GP_EventGet(&ev)) {
+ switch (ev.type) {
+ case GP_EV_KEY:
+ if (ev.code != GP_EV_KEY_DOWN)
+ continue;
+
+ switch (ev.val.key.key) {
+ case GP_KEY_A:
+ aa_flag = !aa_flag;
+ break;
+ case GP_KEY_ESC:
+ GP_BackendExit(win);
+ exit(0);
+ break;
+ case GP_KEY_P:
+ pause_flag = !pause_flag;
+ break;
+ }
+ }
+ }
+}
+
+int main(void)
+{
+ const char *backend_opts = "X11";
+
+ win = GP_BackendInit(backend_opts, "Line Test", stderr);
+
+ if (win == NULL) {
+ fprintf(stderr, "Failed to initalize backend '%s'n",
+ backend_opts);
+ return 1;
+ }
+
+ white = GP_ColorToContextPixel(GP_COL_WHITE, win->context);
+ black = GP_ColorToContextPixel(GP_COL_BLACK, win->context);
+
+ redraw_screen();
+
+ for (;;) {
+ GP_BackendPoll(win);
+ event_loop();
+
+ usleep(20000);
+
+ if (pause_flag)
+ continue;
+
+ redraw_screen();
+ GP_BackendFlip(win);
+
+ start_angle += 0.01;
+ if (start_angle > 2*M_PI) {
+ start_angle = 0.0;
+ }
+ }
+}
diff --git a/tests/SDL/Makefile b/tests/SDL/Makefile
index 9dd15e9..1002fcb 100644
--- a/tests/SDL/Makefile
+++ b/tests/SDL/Makefile
@@ -7,7 +7,7 @@ LDLIBS+=-lGP -L$(TOPDIR)/build/ -lGP_SDL -lSDL
ifeq ($(HAVE_LIBSDL),yes)
CSOURCES=$(shell echo *.c)
-APPS=pixeltest fonttest linetest randomshapetest+APPS=pixeltest fonttest randomshapetest symbolstest textaligntest blittest subcontext aatest mixpixeltest
endif
diff --git a/tests/SDL/linetest.c b/tests/SDL/linetest.c
deleted file mode 100644
index 5a2e082..0000000
--- a/tests/SDL/linetest.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*****************************************************************************
- * 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-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <SDL/SDL.h>
-
-#include "GP.h"
-#include "GP_SDL.h"
-
-/* The surface used as a display (in fact it is a software surface). */
-SDL_Surface *display = NULL;
-GP_Context context;
-
-/* Timer used for refreshing the display */
-SDL_TimerID timer;
-
-/* An event used for signaling that the timer was triggered. */
-SDL_UserEvent timer_event;
-
-/* Values for color pixels in display format. */
-GP_Pixel black, white;
-
-Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
- __attribute__((unused)) void * param)
-{
- timer_event.type = SDL_USEREVENT;
- SDL_PushEvent((SDL_Event *) &timer_event);
- return 30;
-}
-
-double start_angle = 0.0;
-
-static int aa_flag = 0;
-static int pause_flag = 0;
-
-void redraw_screen(void)
-{
- double angle;
- int x, y;
- int xcenter = display->w/2;
- int ycenter = display->h/2;
-
- SDL_LockSurface(display);
- GP_Fill(&context, black);
-
- for (angle = 0.0; angle < 2*M_PI; angle += 0.1) {
- x = (int) (display->w/2 * cos(start_angle + angle));
- y = (int) (display->h/2 * sin(start_angle + angle));
-
- Uint8 r = 127.0 + 127.0 * cos(start_angle + angle);
- Uint8 b = 127.0 + 127.0 * sin(start_angle + angle);
-
- GP_Pixel pixel;
- pixel = GP_RGBToPixel(r, 0, b, context.pixel_type);
-
- if (aa_flag) {
- GP_LineAA_Raw(&context, 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(&context, xcenter + x, ycenter + y, xcenter, ycenter, pixel);
- GP_Line(&context, xcenter, ycenter, xcenter + x, ycenter + y, pixel);
- }
- }
-
- /* axes */
-// GP_HLineXYW(&context, 0, ycenter, display->w, white);
-// GP_VLineXYH(&context, xcenter, 0, display->h, white);
-
- SDL_UnlockSurface(display);
-}
-
-void event_loop(void)
-{
- SDL_Event event;
-
- while (SDL_WaitEvent(&event) > 0) {
- switch (event.type) {
- case SDL_USEREVENT:
- redraw_screen();
- SDL_Flip(display);
-
- if (pause_flag)
- continue;
-
- start_angle += 0.01;
- if (start_angle > 2*M_PI) {
- start_angle = 0.0;
- }
- break;
- case SDL_KEYDOWN:
- switch (event.key.keysym.sym) {
- case SDLK_a:
- aa_flag = !aa_flag;
- break;
- case SDLK_p:
- pause_flag = !pause_flag;
- break;
- default:
- return;
- }
- break;
- case SDL_QUIT:
- return;
- }
- }
-}
-
-int main(int argc, char **argv)
-{
- GP_RetCode retcode;
- retcode = GP_SDL_VideoInit(&context, 640, 480, argc, argv);
- if (retcode != GP_ESUCCESS) {
- fprintf(stderr, "Video initialization failed: %sn",
- GP_RetCodeName(retcode));
- return 1;
- }
-
- display = SDL_GetVideoSurface();
- GP_SDL_ContextFromSurface(&context, display);
-
- /* Load colors in display format */
- black = GP_ColorToContextPixel(GP_COL_BLACK, &context);
- white = GP_ColorToContextPixel(GP_COL_WHITE, &context);
-
- /* Set up the refresh timer */
- timer = SDL_AddTimer(30, timer_callback, NULL);
- if (timer == 0) {
- fprintf(stderr, "Could not set up timer: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Enter the event loop */
- event_loop();
-
- /* We're done */
- SDL_Quit();
- return 0;
-
-fail:
- SDL_Quit();
- return 1;
-}
-
http://repo.or.cz/w/gfxprim.git/commit/06eae5a43e1b6e46979c1e42e392475cbde9…
commit 06eae5a43e1b6e46979c1e42e392475cbde92947
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Oct 19 21:43:02 2012 +0200
input: Make use of GP_WARN().
diff --git a/libs/input/GP_Event.c b/libs/input/GP_Event.c
index fe118ff..eab6b2e 100644
--- a/libs/input/GP_Event.c
+++ b/libs/input/GP_Event.c
@@ -24,7 +24,9 @@
#include <string.h>
#include <stdlib.h>
-#include "GP_Common.h"
+#include <core/GP_Debug.h>
+#include <core/GP_Common.h>
+
#include "GP_Event.h"
/* Screen size for clipping the cursor possition */
@@ -202,7 +204,7 @@ static void event_put(struct GP_Event *ev)
uint32_t next = (queue_last + 1) % GP_EVENT_QUEUE_SIZE;
if (next == queue_first) {
- fprintf(stderr, "Event queue full, dropping eventn");
+ GP_WARN("Event queue full, dropping event.");
return;
}
@@ -359,7 +361,7 @@ void GP_EventPushKey(uint32_t key, uint8_t code, struct timeval *time)
case GP_EV_KEY_REPEAT:
break;
default:
- fprintf(stderr, "Invalid key event code %un", code);
+ GP_WARN("Invalid key event code %u", code);
return;
}
diff --git a/libs/input/GP_InputDriverSDL.c b/libs/input/GP_InputDriverSDL.c
index 04cf416..18da085 100644
--- a/libs/input/GP_InputDriverSDL.c
+++ b/libs/input/GP_InputDriverSDL.c
@@ -24,7 +24,7 @@
#ifdef HAVE_LIBSDL
-#include "core/GP_Debug.h"
+#include <core/GP_Debug.h>
#include "GP_Event.h"
#include "GP_InputDriverSDL.h"
@@ -138,7 +138,7 @@ void GP_InputDriverSDLEventPut(SDL_Event *ev)
key = keysym_table2[keysym - 256];
if (key == 0) {
- fprintf(stderr, "Unmapped SDL keysym %un", keysym);
+ GP_WARN("Unmapped SDL keysym %u", keysym);
return;
}
-----------------------------------------------------------------------
Summary of changes:
demos/c_simple/Makefile | 2 +-
demos/c_simple/linetest.c | 137 ++++++++++++++++++++++++++++++++
libs/input/GP_Event.c | 8 +-
libs/input/GP_InputDriverSDL.c | 4 +-
tests/SDL/Makefile | 2 +-
tests/SDL/linetest.c | 167 ----------------------------------------
6 files changed, 146 insertions(+), 174 deletions(-)
create mode 100644 demos/c_simple/linetest.c
delete mode 100644 tests/SDL/linetest.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 5f13bc0a920bfb4b903a6982b66a091825c4228e
by metan 19 Oct '12
by metan 19 Oct '12
19 Oct '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 5f13bc0a920bfb4b903a6982b66a091825c4228e (commit)
via f4623e257dda0ce2f5afffc51be40f4f9022160e (commit)
via 5fb5fa695cc7e152587edb6f8d76ed531f0cc6cb (commit)
from 472dae1467a2add6bd116bd024c68ff6a5557534 (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 -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/5f13bc0a920bfb4b903a6982b66a091825c4…
commit 5f13bc0a920bfb4b903a6982b66a091825c4228e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Oct 19 20:09:36 2012 +0200
tests: Remove trianglefps.
diff --git a/tests/SDL/Makefile b/tests/SDL/Makefile
index c11568d..9dd15e9 100644
--- a/tests/SDL/Makefile
+++ b/tests/SDL/Makefile
@@ -8,7 +8,7 @@ ifeq ($(HAVE_LIBSDL),yes)
CSOURCES=$(shell echo *.c)
APPS=pixeltest fonttest linetest randomshapetest- symbolstest textaligntest trianglefps blittest subcontext+ symbolstest textaligntest blittest subcontext aatest mixpixeltest
endif
diff --git a/tests/SDL/trianglefps.c b/tests/SDL/trianglefps.c
deleted file mode 100644
index 5eda430..0000000
--- a/tests/SDL/trianglefps.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*****************************************************************************
- * 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-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <SDL/SDL.h>
-
-#include "GP.h"
-#include "GP_SDL.h"
-
-/* Draw filled triangles? */
-int filled = 0;
-
-/* The surface used as a display (in fact it is a software surface). */
-SDL_Surface *display = NULL;
-GP_Context context;
-
-/* Frames per second. */
-int fps = 0, fps_min = 1000000, fps_max = 0;
-
-/* Color pixel values in display format. */
-GP_Pixel black, white;
-
-/*
- * Timer used for FPS measurement and key reactions.
- * SDL_USEREVENT is triggered each second.
- */
-
-SDL_TimerID timer;
-
-SDL_UserEvent timer_event;
-
-Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
- __attribute__((unused)) void * param)
-{
- timer_event.type = SDL_USEREVENT;
- SDL_PushEvent((SDL_Event *) &timer_event);
- return 1000;
-}
-
-
-void draw_frame(void)
-{
- int x0 = 0;
- int y0 = random() % display->h;
- int x1 = display->w;
- int y1 = random() % display->h;
- int x2 = display->w/2;
- int y2 = random() % display->h;
-
- GP_Pixel pixel;
- pixel = GP_RGBToPixel(random() % 255, random() % 255,
- random() % 255, context.pixel_type);
-
- if (filled)
- GP_FillTriangle(&context, x0, y0, x1, y1, x2, y2, pixel);
- else
- GP_Triangle(&context, x0, y0, x1, y1, x2, y2, pixel);
-}
-
-void event_loop(void)
-{
- SDL_Event event;
-
- for (;;) {
- while (SDL_PollEvent(&event) > 0) {
- switch (event.type) {
- case SDL_USEREVENT:
- SDL_Flip(display);
- fprintf(stdout, "%d triangles/second, min = %d, max = %dr", fps, fps_min, fps_max);
- fflush(stdout);
-
- /* Update frames per second */
- if (fps < fps_min)
- fps_min = fps;
- if (fps > fps_max)
- fps_max = fps;
- fps = 0;
- break;
- case SDL_KEYDOWN:
- case SDL_QUIT:
- return;
- }
- }
- draw_frame();
- fps++;
- }
-}
-
-int main(int argc, char ** argv)
-{
- int bit_depth = 0;
-
- int i;
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-f") == 0) {
- filled = 1;
- }
- else if (strcmp(argv[i], "-16") == 0) {
- bit_depth = 16;
- }
- else if (strcmp(argv[i], "-24") == 0) {
- bit_depth = 24;
- }
- else if (strcmp(argv[i], "-32") == 0) {
- bit_depth = 32;
- }
- }
-
- /* Initialize SDL */
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
- fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError());
- return 1;
- }
-
- /* Create a window with a software back surface */
- display = SDL_SetVideoMode(640, 480, bit_depth, SDL_SWSURFACE);
- if (display == NULL) {
- fprintf(stderr, "Could not open display: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Print basic information about the surface */
- printf("Display surface properties:n");
- printf(" width: %4d, height: %4d, pitch: %4dn",
- display->w, display->h, display->pitch);
- printf(" bits per pixel: %2d, bytes per pixel: %2dn",
- display->format->BitsPerPixel, display->format->BytesPerPixel);
- printf("Machine properties:n");
- printf(" sizeof(int) = %u, sizeof(long) = %un",
- (unsigned int)sizeof(int), (unsigned int)sizeof(long));
-
- /* Set up a clipping rectangle to test proper clipping of pixels */
- SDL_Rect clip_rect = { 10, 10, 620, 460 };
- SDL_SetClipRect(display, &clip_rect);
-
- GP_SDL_ContextFromSurface(&context, display);
-
- white = GP_ColorToContextPixel(GP_COL_WHITE, &context);
- black = GP_ColorToContextPixel(GP_COL_BLACK, &context);
-
- /* Set up the timer */
- timer = SDL_AddTimer(1000, timer_callback, NULL);
- if (timer == 0) {
- fprintf(stderr, "Could not set up timer: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Enter the event loop */
- event_loop();
-
- /* Preserve the last result by a newline */
- fprintf(stdout, "n");
-
- /* We're done */
- SDL_Quit();
- return 0;
-
-fail:
- SDL_Quit();
- return 1;
-}
-
http://repo.or.cz/w/gfxprim.git/commit/f4623e257dda0ce2f5afffc51be40f4f9022…
commit f4623e257dda0ce2f5afffc51be40f4f9022160e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Oct 19 20:06:47 2012 +0200
tests: Remove more unused files.
diff --git a/tests/common/GP_TestingRandom.c b/tests/common/GP_TestingRandom.c
deleted file mode 100644
index 17281a9..0000000
--- a/tests/common/GP_TestingRandom.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*****************************************************************************
- * 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) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <stdlib.h>
-
-#include "GP_Common.h"
-#include "GP_TestingRandom.h"
-
-/*
- * State array for testing random generator
- *
- * The idea is to have a seperate random generator for generating
- * random inputs for tests in case tested algorithms also use
- * the random generator. Change in the tested algorithm must not
- * change the input data generated for this or other part of the test.
- *
- * Take care when changing the values - unrelated test might start
- * exhibiting a bug, some tests may rely on the exact result.
- */
-#define GP_RandomStateSize 256
-static char GP_RandomTestingState[GP_RandomStateSize];
-static struct random_data GP_RandomTestingData;
-
-long int GP_TestingRandom(void)
-{
- int32_t r;
- GP_ASSERT(random_r(&GP_RandomTestingData, &r) == 0);
- return r;
-}
-
-void GP_InitTestingRandom(const char *text, uint64_t seed)
-{
- const char *p = text;
- for (; (p) && (*p); p++)
- seed = ((seed * 327) + *p) % 0x7B391D50A10A3LL; // TODO replace with large primes
- GP_ASSERT(initstate_r(seed, GP_RandomTestingState, GP_RandomStateSize,
- &GP_RandomTestingData) == 0);
-}
-
diff --git a/tests/common/GP_TestingRandom.h b/tests/common/GP_TestingRandom.h
deleted file mode 100644
index 9f267fb..0000000
--- a/tests/common/GP_TestingRandom.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*****************************************************************************
- * 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) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-/*
- * These routines use a pseudorandom generator with internal state.
- * Use this only to provide tests with pseudo-random inputs.
- * The seed is initialized with the test name, so the random numbers
- * (and therefore inputs) are the same for a test, and do not depend
- * on random() called in the tested routines or other tests.
- */
-
-#ifndef GP_TESTING_RANDOM_H
-#define GP_TESTING_RANDOM_H
-
-#include <stdint.h>
-
-/*
- * Return next random value from the testing random generator
- */
-long int GP_TestingRandom(void);
-
-/*
- * Initialize the random generator to a seed computed from the given string
- * and the given seed value. Needs to be called at least once.
- *
- * The string may be for example the name of the test, the seed the number of test iteration.
- */
-void GP_InitTestingRandom(const char *text, uint64_t seed);
-
-#endif /* GP_TESTING_RANDOM_H */
diff --git a/tests/common/GP_Tests.c b/tests/common/GP_Tests.c
deleted file mode 100644
index 736c05c..0000000
--- a/tests/common/GP_Tests.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*****************************************************************************
- * 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) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <getopt.h>
-#include <check.h>
-
-typedef Suite* (SuiteFactory)(void);
-
-/*
- * Declare all the manualy created Suite-generating functions here:
- */
-
-SuiteFactory* manual_suites[] = {
- NULL /* Sentinel */
-};
-
-/*
- * Generated function creating and adding all the suites
- */
-
-void GP_AddSuitesToSRunner(SRunner *sr);
-
-
-const char usage[] = "Usage:n%s [-v] [-q]n";
-
-int main(int argc, char *argv[])
-{
- int verb = CK_NORMAL;
-
- int opt;
- while((opt = getopt(argc, argv, "vq")) >= 0)
- switch(opt) {
- case 'v':
- verb = CK_VERBOSE;
- break;
- case 'q':
- verb = CK_SILENT;
- break;
- default:
- fprintf(stderr, usage, argv[0]);
- return(EXIT_FAILURE);
- }
-
- SRunner *sr = srunner_create(NULL);
-
- SuiteFactory **s;
- for (s = manual_suites; *s; s++) {
- srunner_add_suite(sr, (*s)());
- }
- GP_AddSuitesToSRunner(sr);
-
- srunner_run_all(sr, verb);
- int number_failed = srunner_ntests_failed(sr);
- srunner_free(sr);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
diff --git a/tests/common/GP_Tests.h b/tests/common/GP_Tests.h
deleted file mode 100644
index 72c83bb..0000000
--- a/tests/common/GP_Tests.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*****************************************************************************
- * 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) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-/*
- * Wrappers around check.h unit-test library
- *
- * Create a .test.c file with (example):
- *
- * GP_SUITE(suite_name)
- *
- * GP_TEST(test1)
- * {
- * fail_unless(1 == 1);
- * fail_if(1 < 0, "Impossible!");
- * int i = 3;
- * if (1 + 1 == i) fail("Arrgh, 1 + 1 is %d", i);
- * }
- * GP_ENDTEST
- *
- * The tests are collected automatically by find_tests.py.
- * See below for more options.
- */
-
-#include <check.h>
-#include "GP_TestingRandom.h"
-
-/*
- * Helper macro to allow auto-generation of test-cases and suites.
- * Searched for by find_tests.py.
- *
- * Use alone on a line as
- * GP_TEST(testname)
- * or
- * GP_TEST(testname, "foo=1, bar='baz'")
- * The optional string is passed as parameters to Python dict() as parameters
- * for the testcase-generator.
- * Currently, the following parameters are recognized:
- * suite -- name of the suite
- * loop_start -- test will be repeated as with:
- * loop_end for (int _i = loop_start; _i < loop_end; i++) { ... }
- * expect_exit -- expect the function to exit with given exitcode
- * expect_signal -- expect the function to exit with given exitcode
- *
- * Parameters name, fname, line are used internally, do not use them
- */
-
-#define GP_TEST(name, ...) static void name(int); void GP_TEST_##name(int i) {- GP_InitTestingRandom( #name, i); name(i); } - START_TEST(name)
-
-#define GP_ENDTEST END_TEST
-
-/*
- * Helper macro to allow auto-generation of suites.
- * Defines suite from this point until EOF or redefinition.
- * Searched for by find_tests.py
- *
- * Use alone on a line as
- * GP_SUITE(suitename)
- */
-
-#define GP_SUITE(name, ...)
-
http://repo.or.cz/w/gfxprim.git/commit/5fb5fa695cc7e152587edb6f8d76ed531f0c…
commit 5fb5fa695cc7e152587edb6f8d76ed531f0cc6cb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Oct 19 20:04:09 2012 +0200
tests: core: Add simple context test.
diff --git a/tests/core/Context.c b/tests/core/Context.c
new file mode 100644
index 0000000..ec83876
--- /dev/null
+++ b/tests/core/Context.c
@@ -0,0 +1,107 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+/*
+
+ Very basic GP_Context tests.
+
+ */
+
+#include <core/GP_Context.h>
+
+#include "tst_test.h"
+
+/*
+ * Check that Context is correctly allocated and freed
+ */
+static int Context_Alloc_Free(void)
+{
+ GP_Context *c;
+
+ c = GP_ContextAlloc(100, 200, GP_PIXEL_RGB888);
+
+ if (c == NULL) {
+ tst_report(0, "GP_ContextAlloc() failed");
+ return TST_FAILED;
+ }
+
+ /* Assert context properties */
+ if (c->bpp != 24) {
+ tst_report(0, "Context->bpp != 24 (== %i)", c->bpp);
+ return TST_FAILED;
+ }
+
+ if (c->bytes_per_row != 3 * c->w) {
+ tst_report(0, "Context->bytes_per_row != %i (== %i)",
+ 3 * c->w, c->bytes_per_row);
+ return TST_FAILED;
+ }
+
+ if (c->w != 100) {
+ tst_report(0, "Context->w != 100 (== %i)", c->w);
+ return TST_FAILED;
+ }
+
+ if (c->h != 200) {
+ tst_report(0, "Context->h != 200 (== %i)", c->h);
+ return TST_FAILED;
+ }
+
+ if (c->offset != 0) {
+ tst_report(0, "Context->offset != 0");
+ return TST_FAILED;
+ }
+
+ if (c->pixel_type != GP_PIXEL_RGB888) {
+ tst_report(0, "Context->pixel_type != GP_PIXEL_RGB888");
+ return TST_FAILED;
+ }
+
+ if (c->gamma != NULL) {
+ tst_report(0, "Context->gamma != NULL");
+ return TST_FAILED;
+ }
+
+ if (c->axes_swap != 0 || c->x_swap != 0 || c->y_swap != 0) {
+ tst_report(0, "Wrong default orientation %i %i %i",
+ c->axes_swap, c->x_swap, c->y_swap);
+ return TST_FAILED;
+ }
+
+ /* access the pixel buffer */
+ *(char*)GP_PIXEL_ADDR(c, 0, 0) = 0;
+ *(char*)GP_PIXEL_ADDR(c, 100, 100) = 0;
+
+ GP_ContextFree(c);
+
+ return TST_SUCCESS;
+}
+
+const struct tst_suite tst_suite = {
+ .suite_name = "Context Testsuite",
+ .tests = {
+ {.name = "Context Alloc Free", .tst_fn = Context_Alloc_Free,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = NULL},
+ }
+};
diff --git a/tests/core/Makefile b/tests/core/Makefile
index f030894..6b8b9a0 100644
--- a/tests/core/Makefile
+++ b/tests/core/Makefile
@@ -2,14 +2,14 @@ TOPDIR=../..
include $(TOPDIR)/pre.mk
-#CSOURCES=$(shell echo *.c)
+CSOURCES=Context.c
# hack
LIBNAME=core
GENSOURCES+=WritePixel_testsuite.gen.c
-APPS=WritePixel_testsuite.gen
+APPS=WritePixel_testsuite.gen Context
include ../tests.mk
diff --git a/tests/core/runtest.sh b/tests/core/runtest.sh
index 0a9821e..a392647 100755
--- a/tests/core/runtest.sh
+++ b/tests/core/runtest.sh
@@ -10,3 +10,4 @@
export LIBC_FATAL_STDERR_=1
LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./WritePixel_testsuite.gen "$@"
+LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Context "$@"
-----------------------------------------------------------------------
Summary of changes:
tests/SDL/Makefile | 2 +-
tests/SDL/trianglefps.c | 186 -------------------------
tests/common/GP_TestingRandom.c | 58 --------
tests/common/GP_TestingRandom.h | 49 -------
tests/common/GP_Tests.c | 79 -----------
tests/common/GP_Tests.h | 82 -----------
tests/{framework/tst_job.h => core/Context.c} | 127 +++++++++--------
tests/core/Makefile | 4 +-
tests/core/runtest.sh | 1 +
9 files changed, 73 insertions(+), 515 deletions(-)
delete mode 100644 tests/SDL/trianglefps.c
delete mode 100644 tests/common/GP_TestingRandom.c
delete mode 100644 tests/common/GP_TestingRandom.h
delete mode 100644 tests/common/GP_Tests.c
delete mode 100644 tests/common/GP_Tests.h
copy tests/{framework/tst_job.h => core/Context.c} (51%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 472dae1467a2add6bd116bd024c68ff6a5557534
by metan 14 Oct '12
by metan 14 Oct '12
14 Oct '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 472dae1467a2add6bd116bd024c68ff6a5557534 (commit)
via 3524e835e17a0775ecb2e86f9eca90885b16368a (commit)
from fccae75f5221a0307cb52a5e8d7aa6cf820ec6df (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 -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/472dae1467a2add6bd116bd024c68ff6a555…
commit 472dae1467a2add6bd116bd024c68ff6a5557534
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Oct 14 11:48:06 2012 +0200
tests: Move common Makefile constants into one place.
This also adds -lrt which is needed for clock_gettime
on some glibc versions.
diff --git a/tests/core/Makefile b/tests/core/Makefile
index bafa3c2..f030894 100644
--- a/tests/core/Makefile
+++ b/tests/core/Makefile
@@ -7,18 +7,11 @@ include $(TOPDIR)/pre.mk
# hack
LIBNAME=core
-LDFLAGS+=-L../framework/ -L$(TOPDIR)/build/
-LDLIBS+=$(shell $(TOPDIR)/gfxprim-config --libs --libs-loaders)
-LDLIBS+=-ltst_preload -ldl -ltst
-CFLAGS+=-I../framework/
-
GENSOURCES+=WritePixel_testsuite.gen.c
APPS=WritePixel_testsuite.gen
-$(APPS): ../framework/libtst.a
-
-CLEAN+=log.html log.json
+include ../tests.mk
include $(TOPDIR)/gen.mk
include $(TOPDIR)/app.mk
diff --git a/tests/framework/Makefile b/tests/framework/Makefile
index 7169bb7..f3e22a1 100644
--- a/tests/framework/Makefile
+++ b/tests/framework/Makefile
@@ -5,7 +5,7 @@ CSOURCES=$(shell echo *.c)
INCLUDE=
LDFLAGS+=-L.
-LDLIBS+=-ltst_preload -ldl -ltst
+LDLIBS+=-ltst_preload -ldl -ltst -lrt
CFLAGS+=
test: libtst.a
diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile
index ec97b78..71e9223 100644
--- a/tests/gfx/Makefile
+++ b/tests/gfx/Makefile
@@ -3,16 +3,9 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
-LDFLAGS+=-L../framework/ -L$(TOPDIR)/build/
-LDLIBS+=$(shell $(TOPDIR)/gfxprim-config --libs --libs-loaders)
-LDLIBS+=-ltst_preload -ldl -ltst
-CFLAGS+=-I../framework/
-
APPS=gfx_benchmark
-$(APPS): ../framework/libtst.a
-
-CLEAN+=log.html log.json
+include ../tests.mk
include $(TOPDIR)/app.mk
include $(TOPDIR)/post.mk
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile
index f076cd7..9497586 100644
--- a/tests/loaders/Makefile
+++ b/tests/loaders/Makefile
@@ -3,16 +3,9 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
-LDFLAGS+=-L../framework/ -L$(TOPDIR)/build/
-LDLIBS+=$(shell $(TOPDIR)/gfxprim-config --libs --libs-loaders)
-LDLIBS+=-ltst_preload -ldl -ltst
-CFLAGS+=-I../framework/
-
APPS=loaders_suite
-$(APPS): ../framework/libtst.a
-
-CLEAN+=log.html log.json
+include ../tests.mk
include $(TOPDIR)/app.mk
include $(TOPDIR)/post.mk
diff --git a/tests/gfx/Makefile b/tests/tests.mk
similarity index 52%
copy from tests/gfx/Makefile
copy to tests/tests.mk
index ec97b78..f2d8eef 100644
--- a/tests/gfx/Makefile
+++ b/tests/tests.mk
@@ -1,18 +1,10 @@
-TOPDIR=../..
-include $(TOPDIR)/pre.mk
-
-CSOURCES=$(shell echo *.c)
+# Constants for tests build
LDFLAGS+=-L../framework/ -L$(TOPDIR)/build/
LDLIBS+=$(shell $(TOPDIR)/gfxprim-config --libs --libs-loaders)
-LDLIBS+=-ltst_preload -ldl -ltst
+LDLIBS+=-ltst_preload -ldl -ltst -lrt
CFLAGS+=-I../framework/
-APPS=gfx_benchmark
-
$(APPS): ../framework/libtst.a
CLEAN+=log.html log.json
-
-include $(TOPDIR)/app.mk
-include $(TOPDIR)/post.mk
http://repo.or.cz/w/gfxprim.git/commit/3524e835e17a0775ecb2e86f9eca90885b16…
commit 3524e835e17a0775ecb2e86f9eca90885b16368a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Oct 13 20:29:20 2012 +0200
tests: Remove now unused files.
diff --git a/tests/core_old/GP_Blit.test.c b/tests/core_old/GP_Blit.test.c
deleted file mode 100644
index cc20992..0000000
--- a/tests/core_old/GP_Blit.test.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*****************************************************************************
- * 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) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <GP_Tests.h>
-#include <GP_Common.h>
-#include <unistd.h>
-
-GP_SUITE(GP_Blit)
-
diff --git a/tests/core_old/GP_WritePixel.test.gen.c.t b/tests/core_old/GP_WritePixel.test.gen.c.t
deleted file mode 100644
index e488ce7..0000000
--- a/tests/core_old/GP_WritePixel.test.gen.c.t
+++ /dev/null
@@ -1,76 +0,0 @@
-%% extends "base.test.c.t"
-
-%% block body
-#include "GP_Tests.h"
-#include "GP_WritePixel.h"
-#include "GP_TestingCore.h"
-
-GP_SUITE(GP_WritePixel)
-
-static void dump_buffer(const char *name, char *buf, unsigned int buf_len)
-{
- unsigned int i;
-
- printf("%s:n{", name);
-
- for (i = 0; i < buf_len; i++) {
- printf("%i", !!buf[i]);
-
- if (i != buf_len - 1)
- printf(", ");
-
- if (i % 26 == 25)
- printf("n ");
- }
-
- printf("}n");
-}
-
-/*
- * Compares two statically defined buffers
- */
-#define COMPARE_BUFFERS(id, buf1, buf2) do { - unsigned int buf1_len = sizeof(buf1)/sizeof(*buf1); - unsigned int buf2_len = sizeof(buf2)/sizeof(*buf2); - unsigned int i; - - fail_unless(buf1_len == buf2_len); - - for (i = 0; i < buf1_len; i++) - if(buf1[i] != buf2[i]) { - printf("%sn", id); - dump_buffer("wrote", buf1, buf1_len); - dump_buffer("gen", buf2, buf2_len); - fail("buffers are different"); - } -} while (0)
-
-%% for pixelsize in [8, 16, 24, 32]
-%% for offset in range(0, 4)
-%% for len in range(0, 6)
-%% for aligment in [0, 1]
-GP_TEST(GP_WritePixel{{ "%i_%i_%i_%i"|format(pixelsize, offset, len, aligment) }}, {{ ""offset=%i, len=%i, aligment=%i,""|format(offset, len, aligment) }})
-{
- char write_buf[{{ 25 * pixelsize//8 }}] = {};
- char gen_buf[{{ 25 * pixelsize//8 }}] = {};
-
- /*
- * Fill the compare buffer
- */
-%% for i in range(0, len)
-%% for j in range(0, pixelsize//8)
- gen_buf[{{aligment + offset * pixelsize//8 + i * pixelsize//8 + j}}] = 0xff;
-%% endfor
-%% endfor
-
- GP_WritePixels{{ pixelsize }}bpp(write_buf + {{aligment + offset * pixelsize//8}}, {{ len }}, 0xffffffff>>{{32 - pixelsize}});
-
- COMPARE_BUFFERS({{""p=%i o=%i l=%i a=%i""|format(pixelsize, offset, len, aligment)}}, write_buf, gen_buf);
-}
-GP_ENDTEST
-%% endfor
-%% endfor
-%% endfor
-%% endfor
-
-%% endblock body
diff --git a/tests/core_old/Makefile b/tests/core_old/Makefile
deleted file mode 100644
index c848cb0..0000000
--- a/tests/core_old/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-TOPDIR=../..
-
-include $(TOPDIR)/pre.mk
-
-LIBNAME=core
-TESTSUITE=core_suite
-LDLIBS+=-lGP -L$(TOPDIR)/build/ -lcheck -lm -lSDL
-GENSOURCES+=GP_Convert.test.gen.c GP_WritePixel.test.gen.c - GP_MixPixels.test.gen.c
-
-all: $(TESTSUITE)
-
-include $(TOPDIR)/tests.mk
-include $(TOPDIR)/post.mk
-
-----------------------------------------------------------------------
Summary of changes:
tests/core/Makefile | 9 +---
tests/core_old/GP_Blit.test.c | 28 -----------
tests/core_old/GP_WritePixel.test.gen.c.t | 76 -----------------------------
tests/core_old/Makefile | 15 ------
tests/framework/Makefile | 2 +-
tests/gfx/Makefile | 9 +---
tests/loaders/Makefile | 9 +---
tests/{gfx/Makefile => tests.mk} | 12 +----
8 files changed, 6 insertions(+), 154 deletions(-)
delete mode 100644 tests/core_old/GP_Blit.test.c
delete mode 100644 tests/core_old/GP_WritePixel.test.gen.c.t
delete mode 100644 tests/core_old/Makefile
copy tests/{gfx/Makefile => tests.mk} (52%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: fccae75f5221a0307cb52a5e8d7aa6cf820ec6df
by metan 13 Oct '12
by metan 13 Oct '12
13 Oct '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via fccae75f5221a0307cb52a5e8d7aa6cf820ec6df (commit)
from 8caa76a32fdad0cc36b1a4ac6038b205f17b504e (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 -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/fccae75f5221a0307cb52a5e8d7aa6cf820e…
commit fccae75f5221a0307cb52a5e8d7aa6cf820ec6df
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Oct 13 20:23:37 2012 +0200
core: Remove unused GP_Counter.
diff --git a/include/core/GP_Core.h b/include/core/GP_Core.h
index cd5555d..d10152f 100644
--- a/include/core/GP_Core.h
+++ b/include/core/GP_Core.h
@@ -71,9 +71,6 @@
/* Threads utils */
#include "core/GP_Threads.h"
-/* Debug counters */
-#include "core/GP_Counter.h"
-
/* Mix Pixel */
#include "core/GP_MixPixels.h"
diff --git a/include/core/GP_Counter.h b/include/core/GP_Counter.h
deleted file mode 100644
index 0429df9..0000000
--- a/include/core/GP_Counter.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*****************************************************************************
- * 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) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#ifndef CORE_GP_COUNTER_H
-#define CORE_GP_COUNTER_H
-
-/*
- * Simple global named 64-bit counters.
- *
- * Intended for accounting of expensive operations ("quantitative warnings").
- * All operations accept NULL as GP_Counter.
- *
- * If GP_IMPLEMENT_COUNTERS is undefined, all operations are NOP and
- * no memory is allocated.
- */
-#define GP_IMPLEMENT_COUNTERS
-
-/*
- * Maximum length of counter name,
- * maximum number of counters (~40 bytes each)
- */
-#define GP_COUNTER_NAME_LEN 24
-#define GP_COUNTER_MAX 256
-
-/*
- * Basic types.
- * Only use GP_Counter in your programs.
- */
-typedef int64_t GP_Counter_t;
-typedef GP_Counter_t *GP_Counter;
-
-/*
- * Increase a counter by 1.
- */
-static inline void GP_IncCounter(GP_Counter counter)
-{
-#ifdef GP_IMPLEMENT_COUNTERS
- if (!counter)
- return;
- (*counter)++;
-#endif /* GP_IMPLEMENT_COUNTERS */
-}
-
-/*
- * Increase a counter by delta (may be negative).
- * No checks for underflow.
- */
-static inline void GP_AddCounter(GP_Counter counter, GP_Counter_t delta)
-{
-#ifdef GP_IMPLEMENT_COUNTERS
- if (!counter)
- return;
- (*counter) += delta;
-#endif /* GP_IMPLEMENT_COUNTERS */
-}
-
-/*
- * Set counter to given value.
- */
-static inline void GP_SetCounter(GP_Counter counter, GP_Counter_t value)
-{
-#ifdef GP_IMPLEMENT_COUNTERS
- if (!counter)
- return;
- (*counter) = value;
-#endif /* GP_IMPLEMENT_COUNTERS */
-}
-
-/*
- * Return counter value
- */
-static inline GP_Counter_t GP_CounterVal(GP_Counter counter)
-{
-#ifdef GP_IMPLEMENT_COUNTERS
- if (!counter)
- return 0;
- return *counter;
-#else /* GP_IMPLEMENT_COUNTERS */
- return 0;
-#endif /* GP_IMPLEMENT_COUNTERS */
-}
-
-/*
- * Pretty-printing of all counters and their values to f
- * Includes info about counter-list overflow
- */
-#include <stdio.h>
-void GP_PrintCounters(FILE *f);
-
-/*
- * Lookup a counter by name, possibly creating a new one.
- *
- * May return NULL if no space is left in the counter list.
- * The returned value is not unallocated in any way.
- *
- * NOTE: Current implementation has very slow adds (O(current_counters)),
- * but the lookup is reasonably fast (bisection)
- */
-GP_Counter GP_GetCounter(const char *name);
-
-#endif /* CORE_GP_COUNTER_H */
diff --git a/libs/core/GP_Counter.c b/libs/core/GP_Counter.c
deleted file mode 100644
index 7ba619e..0000000
--- a/libs/core/GP_Counter.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*****************************************************************************
- * 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) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <string.h>
-#include "GP_Common.h"
-#include "GP_Counter.h"
-
-/*
- * Internal struct used in counter list
- */
-struct GP_CounterRecord {
- char name[GP_COUNTER_NAME_LEN];
- GP_Counter counter;
-};
-
-/*
- * variables local to module (static)
- */
-#ifdef GP_IMPLEMENT_COUNTERS
-
-static GP_Counter_t GP_counters[GP_COUNTER_MAX];
-static int GP_used_counters = 0;
-static struct GP_CounterRecord GP_counter_list[GP_COUNTER_MAX];
-static GP_Counter_t GP_counter_list_overflow = 0;
-
-#endif /* GP_IMPLEMENT_COUNTERS */
-
-void GP_PrintCounters(FILE *f)
-{
-#ifdef GP_IMPLEMENT_COUNTERS
- int i;
- GP_CHECK(f != NULL);
- if (GP_used_counters == 0)
- fprintf(f, "[ no counters defined ]n");
- for (i = 0; i < GP_used_counters; i++)
- fprintf(f, "%*s : %llun", -GP_COUNTER_NAME_LEN,
- GP_counter_list[i].name,
- (long long unsigned int)*(GP_counter_list[i].counter));
- if (GP_counter_list_overflow > 0)
- fprintf(f, "[ unable to allocate new counter %llu times ]n",
- (long long unsigned int)GP_counter_list_overflow);
-#endif /* GP_IMPLEMENT_COUNTERS */
-}
-
-GP_Counter GP_GetCounter(const char *name)
-{
-#ifdef GP_IMPLEMENT_COUNTERS
- int l = 0;
- int r = GP_used_counters;
-
- GP_CHECK(name != NULL);
- GP_CHECK(strlen(name) + 1 <= GP_COUNTER_NAME_LEN);
-
- /*
- * Bisect GP_counter_list to find either the counter or a place for it
- * interval [l, r) (not incl. r)
- */
- while (r > l) {
- int med = (r + l) / 2; /* Here never equal to r, might be l */
- int cmp = strcmp(GP_counter_list[med].name, name);
- if (cmp == 0)
- return GP_counter_list[med].counter;
- if (cmp < 0)
- l = med + 1;
- else
- r = med;
- }
- GP_CHECK(l == r);
- if ((l < GP_used_counters) && (strcmp(GP_counter_list[l].name, name) == 0))
- return GP_counter_list[l].counter;
-
- /* Add a new counter */
- if (GP_used_counters >= GP_COUNTER_MAX) {
- GP_counter_list_overflow++;
- return NULL;
- }
-
- /* Move the counter records up and initialize a new one */
- memmove(GP_counter_list + l + 1, GP_counter_list + l,
- sizeof(struct GP_CounterRecord) * GP_used_counters - l);
- strcpy(GP_counter_list[l].name, name);
- GP_counter_list[l].counter = GP_counters + GP_used_counters;
-
- GP_used_counters++;
- return GP_counter_list[l].counter;
-#else /* GP_IMPLEMENT_COUNTERS */
- return NULL;
-#endif /* GP_IMPLEMENT_COUNTERS */
-}
diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i
index 67777dd..6ddfc29 100644
--- a/pylib/gfxprim/core/core.i
+++ b/pylib/gfxprim/core/core.i
@@ -9,14 +9,11 @@
* Basic types and common methods
*/
-ERROR_ON_NULL(GP_GetCounter);
-
%include "GP_Common.h"
%include "GP_Core.h"
%include "GP_Debug.h"
%include "GP_Types.h"
%include "GP_Transform.h"
-%include "GP_Counter.h"
%include "GP_GetSetBits.h"
%include "GP_Transform.h"
%include "GP_ProgressCallback.h"
diff --git a/tests/core_old/GP_Counter.test.c b/tests/core_old/GP_Counter.test.c
deleted file mode 100644
index 6bd9ab7..0000000
--- a/tests/core_old/GP_Counter.test.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*****************************************************************************
- * 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) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <string.h>
-#include <stdio.h>
-
-#include "GP_Tests.h"
-#include "GP_Counter.h"
-
-GP_SUITE(GP_Counter)
-
-GP_TEST(Smoke)
-{
- fail_unless(GP_CounterVal(NULL) == 0);
- GP_IncCounter(NULL);
- GP_AddCounter(NULL, -10);
- fail_unless(GP_GetCounter("") != NULL);
-
- GP_IncCounter(GP_GetCounter("a"));
- fail_unless(GP_CounterVal(GP_GetCounter("a")) == 1);
-
- GP_PrintCounters(fopen("/dev/null","wt"));
-}
-END_TEST
-
-GP_TEST(Allocation)
-{
- /* random-like operations with counters,
- * should test reasonably many combinations */
- GP_SetCounter(GP_GetCounter("a"), 11);
- GP_AddCounter(GP_GetCounter("e"), -42);
- GP_Counter b = GP_GetCounter("b");
- GP_IncCounter(GP_GetCounter("a"));
- GP_GetCounter("d");
- GP_AddCounter(GP_GetCounter("c"), 21);
- GP_IncCounter(GP_GetCounter("b"));
- GP_AddCounter(GP_GetCounter("b"), -8);
- GP_IncCounter(b);
- GP_SetCounter(GP_GetCounter("f"), 91);
- GP_SetCounter(GP_GetCounter("f"), -1);
-
- fail_unless(GP_CounterVal(GP_GetCounter("a")) == 12);
- fail_unless(GP_CounterVal(GP_GetCounter("b")) == -6);
- fail_unless(GP_CounterVal(GP_GetCounter("c")) == 21);
- fail_unless(GP_CounterVal(GP_GetCounter("d")) == 0);
- fail_unless(GP_CounterVal(GP_GetCounter("e")) == -42);
- fail_unless(GP_CounterVal(GP_GetCounter("f")) == -1);
-}
-END_TEST
-
-GP_TEST(Overflow)
-{
- char buf[8];
- int i;
- for (i = 0; i < GP_COUNTER_MAX; i++) {
- sprintf(buf, "%d", i);
- fail_if(GP_GetCounter(buf) == NULL);
- }
- fail_unless(GP_GetCounter("next") == NULL);
-}
-END_TEST
-
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Core.h | 3 -
include/core/GP_Counter.h | 121 --------------------------------------
libs/core/GP_Counter.c | 109 ----------------------------------
pylib/gfxprim/core/core.i | 3 -
tests/core_old/GP_Counter.test.c | 81 -------------------------
5 files changed, 0 insertions(+), 317 deletions(-)
delete mode 100644 include/core/GP_Counter.h
delete mode 100644 libs/core/GP_Counter.c
delete mode 100644 tests/core_old/GP_Counter.test.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0