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: 019030bda9e79cde4165d8a9f9ca78be39a5ea28
by metan 02 Nov '12
by metan 02 Nov '12
02 Nov '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 019030bda9e79cde4165d8a9f9ca78be39a5ea28 (commit)
via 8e61c5d90064c9b6ab07cba610604e2de02f4522 (commit)
via 51c0091e49c24df4bf762499d1728fc9271610e3 (commit)
via 95079c548cf33566bfc19a6a2fb861c38b3137b4 (commit)
via 23876fbfc0681a3f3b8694316038679276c95d4e (commit)
from de06f184c1474e76daba31543187ad4b0205c5c3 (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/019030bda9e79cde4165d8a9f9ca78be39a5…
commit 019030bda9e79cde4165d8a9f9ca78be39a5ea28
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 2 14:48:34 2012 +0100
tests: filters: convolution: Make use of ENOSYS.
diff --git a/tests/filters/LinearConvolution.c b/tests/filters/LinearConvolution.c
index cbad724..78d1bd4 100644
--- a/tests/filters/LinearConvolution.c
+++ b/tests/filters/LinearConvolution.c
@@ -68,7 +68,10 @@ static int test_lin_conv_box_3x3(void)
.kernel = box_3x3,
};
- GP_FilterConvolution(in, in, &box_3x3_kernel, NULL);
+ if (GP_FilterConvolution(in, in, &box_3x3_kernel, NULL)) {
+ if (errno == ENOSYS)
+ return TST_SKIPPED;
+ }
/* Check result */
//TODO
@@ -89,8 +92,11 @@ static int test_h_lin_conv_box_3_raw(void)
/* Apply the convolution */
float kernel[] = {1, 1, 1};
- GP_FilterHLinearConvolution_Raw(in, 0, 0, in->w, in->h, in, 0, 0,
- kernel, 3, 3, NULL);
+ if (GP_FilterHLinearConvolution_Raw(in, 0, 0, in->w, in->h, in, 0, 0,
+ kernel, 3, 3, NULL)) {
+ if (errno == ENOSYS)
+ return TST_SKIPPED;
+ }
/* Check result */
//TODO
@@ -113,8 +119,11 @@ static int test_v_lin_conv_box_3_raw(void)
/* Apply the convolution */
float kernel[] = {1, 1, 1};
- GP_FilterVLinearConvolution_Raw(in, 0, 0, in->w, in->h, in, 0, 0,
- kernel, 3, 3, NULL);
+ if (GP_FilterVLinearConvolution_Raw(in, 0, 0, in->w, in->h, in, 0, 0,
+ kernel, 3, 3, NULL)) {
+ if (errno == ENOSYS)
+ return TST_SKIPPED;
+ }
/* Check result */
//TODO
http://repo.or.cz/w/gfxprim.git/commit/8e61c5d90064c9b6ab07cba610604e2de02f…
commit 8e61c5d90064c9b6ab07cba610604e2de02f4522
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 2 14:46:46 2012 +0100
filters: convolution: Fix segfault on unsupported pixel types.
This temporarily solves segfault on unsupported pixel
types by returning ENOSYS.
diff --git a/libs/filters/GP_Linear.c b/libs/filters/GP_Linear.c
index 1655ca8..a87372f 100644
--- a/libs/filters/GP_Linear.c
+++ b/libs/filters/GP_Linear.c
@@ -20,6 +20,8 @@
* *
*****************************************************************************/
+#include <errno.h>
+
#include "core/GP_Context.h"
#include "core/GP_GetPutPixel.h"
#include "core/GP_TempAlloc.h"
@@ -48,6 +50,12 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src,
"offset %ix%i rectangle %ux%u",
kw, x_src, y_src, w_src, h_src);
+ /* Not yet implemented */
+ if (src->pixel_type != GP_PIXEL_RGB888) {
+ errno = ENOSYS;
+ return 1;
+ }
+
for (i = 0; i < kw; i++)
ikernel[i] = kernel[i] * MUL + 0.5;
@@ -157,6 +165,12 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src,
GP_DEBUG(1, "Vertical linear convolution kernel width %u "
"offset %ix%i rectangle %ux%u",
kh, x_src, y_src, w_src, h_src);
+
+ /* Not yet implemented */
+ if (src->pixel_type != GP_PIXEL_RGB888) {
+ errno = ENOSYS;
+ return 1;
+ }
ikern_div = kern_div * MUL + 0.5;
@@ -310,6 +324,12 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src,
GP_DEBUG(1, "Linear convolution kernel %ix%i rectangle %ux%u",
kw, kh, w_src, h_src);
+
+ /* Not yet implemented */
+ if (src->pixel_type != GP_PIXEL_RGB888) {
+ errno = ENOSYS;
+ return 1;
+ }
/* Do linear convolution */
for (y = 0; y < (GP_Coord)h_src; y++) {
http://repo.or.cz/w/gfxprim.git/commit/51c0091e49c24df4bf762499d1728fc92716…
commit 51c0091e49c24df4bf762499d1728fc9271610e3
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 2 14:45:42 2012 +0100
tests: framework: Avoid division by zero.
Fix division by zero when no tests were finished.
diff --git a/tests/framework/tst_test.c b/tests/framework/tst_test.c
index 1981302..4df0ef1 100644
--- a/tests/framework/tst_test.c
+++ b/tests/framework/tst_test.c
@@ -96,9 +96,16 @@ void tst_run_suite(const struct tst_suite *suite, const char *tst_name)
tst_log_close(html, TST_LOG_HTML);
tst_log_close(json, TST_LOG_JSON);
+ float percents;
+
+ if (counter == 0)
+ percents = 100;
+ else
+ percents = 100.00 * counters[0] / counter;
+
fprintf(stderr, "nSummary: succedded %u out of "
"%u %.2f%% (skipped %u)n",
- counters[0], counter, 100.00 * counters[0] / counter,
+ counters[0], counter, percents,
counters[TST_SKIPPED]);
}
http://repo.or.cz/w/gfxprim.git/commit/95079c548cf33566bfc19a6a2fb861c38b31…
commit 95079c548cf33566bfc19a6a2fb861c38b3137b4
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 2 14:43:25 2012 +0100
tests: framework: Split tst_job_wait().
This is preparation for parallel test execution.
diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c
index 2c19c08..d208b66 100644
--- a/tests/framework/tst_job.c
+++ b/tests/framework/tst_job.c
@@ -487,65 +487,78 @@ static void parent_read(struct tst_job *job, void *ptr, ssize_t size)
tst_warn("parent: read(): %s", strerror(errno));
}
-void tst_job_wait(struct tst_job *job)
+void tst_job_read(struct tst_job *job)
{
- int status, ret;
char ch;
+ int ret;
if (!job->running)
- tst_warn("Job %s (pid %i) not in running state",
+ tst_warn("job_read: Job %s (pid %i) not in running state",
job->test->name, job->pid);
- while (job->running) {
- ret = read(job->pipefd, &ch, 1);
+ errno = 0;
- if (ret < 0) {
- tst_warn("job_wait: read() failed: %s",
- strerror(errno));
- job->running = 0;
- continue;
- }
+ ret = read(job->pipefd, &ch, 1);
- /* Child exited => read returns end of file */
- if (ret == 0) {
- job->running = 0;
- continue;
- }
+ if (ret < 0) {
+ tst_warn("job_read: read() failed: %s", strerror(errno));
+ job->running = 0;
+
+ //TODO: kill the process?
- switch (ch) {
- /* test exited normally */
- case 'x':
- job->running = 0;
- break;
- /* cpu consumed time */
- case 'c':
- read_timespec(job, &job->cpu_time);
- break;
- case 'C':
- read_timespec(job, &job->cpu_time);
- break;
- /* benchmark data */
- case 'M':
- read_timespec(job, &job->bench_mean);
- break;
- case 'V':
- read_timespec(job, &job->bench_var);
- break;
- /* test message as generated by tst_report() */
- case 'm':
- parent_read_msg(job);
- break;
- /* malloc stats */
- case 's':
- parent_read(job, &job->malloc_stats,
- sizeof(job->malloc_stats));
- break;
- default:
- tst_warn("parent: Invalid characters received");
- break;
+ return;
+ }
+
+ /* Child exited => read returns end of file */
+ if (ret == 0) {
+ if (errno == EAGAIN) {
+ tst_warn("job_read: read() returned EAGAIN");
+ return;
}
+
+ job->running = 0;
+
+ return;
}
+ switch (ch) {
+ /* test exited normally */
+ case 'x':
+ job->running = 0;
+ break;
+ /* cpu consumed time */
+ case 'c':
+ read_timespec(job, &job->cpu_time);
+ break;
+ case 'C':
+ read_timespec(job, &job->cpu_time);
+ break;
+ /* benchmark data */
+ case 'M':
+ read_timespec(job, &job->bench_mean);
+ break;
+ case 'V':
+ read_timespec(job, &job->bench_var);
+ break;
+ /* test message as generated by tst_report() */
+ case 'm':
+ parent_read_msg(job);
+ break;
+ /* malloc stats */
+ case 's':
+ parent_read(job, &job->malloc_stats,
+ sizeof(job->malloc_stats));
+ break;
+ default:
+ tst_warn("parent: Invalid characters received");
+ break;
+ }
+}
+
+void tst_job_collect(struct tst_job *job)
+{
+ int status;
+
/* collect the test return status */
waitpid(job->pid, &status, 0);
@@ -578,7 +591,7 @@ void tst_job_wait(struct tst_job *job)
job->result = TST_ABORTED;
break;
default:
- printf("%in", WTERMSIG(status));
+ tst_warn("Test signaled with %in", WTERMSIG(status));
job->result = TST_INTERR;
}
}
@@ -588,3 +601,11 @@ void tst_job_wait(struct tst_job *job)
stop_test(job);
}
+
+void tst_job_wait(struct tst_job *job)
+{
+ while (job->running)
+ tst_job_read(job);
+
+ tst_job_collect(job);
+}
http://repo.or.cz/w/gfxprim.git/commit/23876fbfc0681a3f3b8694316038679276c9…
commit 23876fbfc0681a3f3b8694316038679276c95d4e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 2 14:41:16 2012 +0100
tests: framework: Change the test driver output.
The line was too long to fit to 80 chars even with
reasonably short test names so this removes the
line with CPU Time.
diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c
index 1266f9b..2c19c08 100644
--- a/tests/framework/tst_job.c
+++ b/tests/framework/tst_job.c
@@ -61,7 +61,7 @@ void tst_diff_timespec(int *sec, int *nsec, struct timespec *start,
}
}
-#define NAME_PADD 21
+#define NAME_PADD 35
static void stop_test(struct tst_job *job)
{
@@ -113,11 +113,8 @@ static void stop_test(struct tst_job *job)
for (i = strlen(name); i < NAME_PADD; i++)
fprintf(stderr, " ");
- fprintf(stderr, " finished (Time %3i.%03is, CPU %3i.%03is) %sn",
- sec, nsec/1000000,
- (int)job->cpu_time.tv_sec,
- (int)job->cpu_time.tv_nsec/1000000,
- result);
+ fprintf(stderr, " finished (Time %3i.%03is) %sn",
+ sec, nsec/1000000, result);
if (job->bench_iter) {
for (i = 0; i < NAME_PADD; i++)
-----------------------------------------------------------------------
Summary of changes:
libs/filters/GP_Linear.c | 20 ++++++
tests/filters/LinearConvolution.c | 19 ++++--
tests/framework/tst_job.c | 126 +++++++++++++++++++++----------------
tests/framework/tst_test.c | 9 +++-
4 files changed, 114 insertions(+), 60 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: de06f184c1474e76daba31543187ad4b0205c5c3
by metan 02 Nov '12
by metan 02 Nov '12
02 Nov '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 de06f184c1474e76daba31543187ad4b0205c5c3 (commit)
via 0de9265c1f8dbd2860ccea964a7d22507f845657 (commit)
via b8f76479c697120adbb7468aff93a98315dd3dba (commit)
from fa2fab96f4932dece35de36740e2f1e4af38afd2 (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/de06f184c1474e76daba31543187ad4b0205…
commit de06f184c1474e76daba31543187ad4b0205c5c3
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 2 14:20:53 2012 +0100
filters: Add header + minor cleanup.
diff --git a/include/filters/GP_Convolution.h b/include/filters/GP_Convolution.h
index 8c158ff..0cd9089 100644
--- a/include/filters/GP_Convolution.h
+++ b/include/filters/GP_Convolution.h
@@ -30,6 +30,7 @@
#define FILTERS_GP_CONVOLUTION_H
#include "GP_Filter.h"
+#include "GP_Linear.h"
/*
* 2D convolution kernel.
diff --git a/libs/filters/GP_Convolution.c b/libs/filters/GP_Convolution.c
index 7ee3b62..0b81e55 100644
--- a/libs/filters/GP_Convolution.c
+++ b/libs/filters/GP_Convolution.c
@@ -21,10 +21,9 @@
*****************************************************************************/
#include "core/GP_Debug.h"
-
#include "GP_Linear.h"
-
#include "GP_Convolution.h"
+
int GP_FilterConvolutionEx(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
GP_Size w_src, GP_Coord h_src,
http://repo.or.cz/w/gfxprim.git/commit/0de9265c1f8dbd2860ccea964a7d22507f84…
commit 0de9265c1f8dbd2860ccea964a7d22507f845657
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 2 14:19:41 2012 +0100
tests: framework: Copy only content of resource dir.
diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c
index 8a0789b..1266f9b 100644
--- a/tests/framework/tst_job.c
+++ b/tests/framework/tst_job.c
@@ -29,6 +29,7 @@
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/stat.h>
#include <stdarg.h>
#include <math.h>
@@ -185,22 +186,40 @@ static void prepare_tmpdir(const char *name, const char *res_path,
}
/* Create template from test name */
- snprintf(template, size, "/tmp/ctest_%s_XXXXXX", tmp);
+ snprintf(template, size, "/tmp/test_%s_XXXXXX", tmp);
if (mkdtemp(template) == NULL) {
tst_warn("mkdtemp(%s) failed: %s", template, strerror(errno));
exit(TST_INTERR);
}
- /* Copy resources if needed */
+ /*
+ * Copy resources if needed
+ *
+ * If resource is directory, copy only it's content.
+ */
if (res_path != NULL) {
- snprintf(tmp, sizeof(tmp), "cp -r '%s' '%s'",
- res_path, template);
+ struct stat st;
+ char *p = "";
+
+ if (stat(res_path, &st)) {
+ tst_warn("failed to stat resource '%s': %s",
+ res_path, strerror(errno));
+ rmdir(template);
+ exit(TST_INTERR);
+ }
+
+ if (S_ISDIR(st.st_mode))
+ p = "/*";
+
+ snprintf(tmp, sizeof(tmp), "cp -r '%s'%s '%s'",
+ res_path, p, template);
ret = system(tmp);
if (ret) {
tst_warn("failed to copy resource '%s'", res_path);
+ rmdir(template);
exit(TST_INTERR);
}
}
http://repo.or.cz/w/gfxprim.git/commit/b8f76479c697120adbb7468aff93a98315dd…
commit b8f76479c697120adbb7468aff93a98315dd3dba
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 2 14:16:24 2012 +0100
tests, filters: Convolution tests, not yet working.
diff --git a/tests/filters/LinearConvolution.c b/tests/filters/LinearConvolution.c
new file mode 100644
index 0000000..cbad724
--- /dev/null
+++ b/tests/filters/LinearConvolution.c
@@ -0,0 +1,142 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include <core/GP_Context.h>
+#include <loaders/GP_Loaders.h>
+#include <filters/GP_Convolution.h>
+
+#include "tst_test.h"
+
+static int load_resources(const char *path1, const char *path2,
+ GP_Context **c1, GP_Context **c2)
+{
+ *c1 = GP_LoadImage(path1, NULL);
+ *c2 = GP_LoadImage(path2, NULL);
+
+ if (*c1 == NULL || *c2 == NULL) {
+ tst_report(0, "Failed to load resource");
+ return TST_INTERR;
+ }
+
+ return TST_SUCCESS;
+}
+
+static int test_lin_conv_box_3x3(void)
+{
+ GP_Context *in, *out;
+ int ret;
+
+ ret = load_resources("in.pgm", "out.pgm", &in, &out);
+
+ if (ret != TST_SUCCESS)
+ return ret;
+
+ /* Apply the convolution */
+ float box_3x3[] = {
+ 1, 1, 1,
+ 1, 1, 1,
+ 1, 1, 1,
+ };
+
+ GP_FilterKernel2D box_3x3_kernel = {
+ .w = 3,
+ .h = 3,
+ .div = 9,
+ .kernel = box_3x3,
+ };
+
+ GP_FilterConvolution(in, in, &box_3x3_kernel, NULL);
+
+ /* Check result */
+ //TODO
+
+ return TST_SUCCESS;
+}
+
+static int test_h_lin_conv_box_3_raw(void)
+{
+ GP_Context *in, *out;
+ int ret;
+
+ ret = load_resources("in.pgm", "out.pgm", &in, &out);
+
+ if (ret != TST_SUCCESS)
+ return ret;
+
+ /* Apply the convolution */
+ float kernel[] = {1, 1, 1};
+
+ GP_FilterHLinearConvolution_Raw(in, 0, 0, in->w, in->h, in, 0, 0,
+ kernel, 3, 3, NULL);
+
+ /* Check result */
+ //TODO
+
+ return TST_SUCCESS;
+}
+
+static int test_v_lin_conv_box_3_raw(void)
+{
+ GP_Context *in, *out;
+ int ret;
+
+ ret = load_resources("in.pgm", "out.pgm", &in, &out);
+
+ if (ret != TST_SUCCESS)
+ return ret;
+
+ GP_SetDebugLevel(10);
+
+ /* Apply the convolution */
+ float kernel[] = {1, 1, 1};
+
+ GP_FilterVLinearConvolution_Raw(in, 0, 0, in->w, in->h, in, 0, 0,
+ kernel, 3, 3, NULL);
+
+ /* Check result */
+ //TODO
+
+ return TST_SUCCESS;
+}
+
+const struct tst_suite tst_suite = {
+ .suite_name = "Linear Convolution Testsuite",
+ .tests = {
+ {.name = "LinearConvolution Box 3x3",
+ .tst_fn = test_lin_conv_box_3x3,
+ .res_path = "data/conv/box_3x3/",
+ .flags = TST_TMPDIR},
+ {.name = "HLinearConvolution_Raw Kern 3",
+ .tst_fn = test_h_lin_conv_box_3_raw,
+ .res_path = "data/conv/box_3x3/",
+ .flags = TST_TMPDIR},
+ {.name = "VLinearConvolution_Raw Kern 3",
+ .tst_fn = test_v_lin_conv_box_3_raw,
+ .res_path = "data/conv/box_3x3/",
+ .flags = TST_TMPDIR},
+ {.name = NULL}
+ }
+};
diff --git a/tests/filters/Makefile b/tests/filters/Makefile
new file mode 100644
index 0000000..aaa6125
--- /dev/null
+++ b/tests/filters/Makefile
@@ -0,0 +1,11 @@
+TOPDIR=../..
+include $(TOPDIR)/pre.mk
+
+CSOURCES=$(shell echo *.c)
+
+APPS=LinearConvolution
+
+include ../tests.mk
+
+include $(TOPDIR)/app.mk
+include $(TOPDIR)/post.mk
diff --git a/tests/filters/data/conv/box_3x3/in.pgm b/tests/filters/data/conv/box_3x3/in.pgm
new file mode 100644
index 0000000..2adeee4
--- /dev/null
+++ b/tests/filters/data/conv/box_3x3/in.pgm
@@ -0,0 +1,14 @@
+P2
+# This is white square in the middle of an image
+10 10
+255
+ 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 255 255 255 255 0 0 0
+ 0 0 0 255 255 255 255 0 0 0
+ 0 0 0 255 255 255 255 0 0 0
+ 0 0 0 255 255 255 255 0 0 0
+ 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0
diff --git a/tests/filters/data/conv/box_3x3/out.pgm b/tests/filters/data/conv/box_3x3/out.pgm
new file mode 100644
index 0000000..6eae0df
--- /dev/null
+++ b/tests/filters/data/conv/box_3x3/out.pgm
@@ -0,0 +1,15 @@
+P2
+# This is white square in the middle of an image
+# after applying 3x3 box linear convolution
+10 10
+255
+ 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0
+ 0 0 28 57 85 85 57 28 0 0
+ 0 0 57 113 170 170 113 57 0 0
+ 0 0 85 170 255 255 170 85 0 0
+ 0 0 85 170 255 255 170 85 0 0
+ 0 0 57 113 170 170 113 57 0 0
+ 0 0 28 57 85 85 57 28 0 0
+ 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0
diff --git a/tests/filters/runtest.sh b/tests/filters/runtest.sh
new file mode 100755
index 0000000..9efe909
--- /dev/null
+++ b/tests/filters/runtest.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+#
+# By default the glibc __libc_message() writes to /dev/tty before calling
+# the abort(). Exporting this macro makes it to use stderr instead.
+#
+# The main usage of the function are malloc assertions, so this makes us catch
+# the malloc error message by catching stderr output.
+#
+export LIBC_FATAL_STDERR_=1
+
+LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./LinearConvolution "$@"
-----------------------------------------------------------------------
Summary of changes:
include/filters/GP_Convolution.h | 1 +
libs/filters/GP_Convolution.c | 3 +-
tests/filters/LinearConvolution.c | 142 +++++++++++++++++++++++++++++++
tests/{loaders => filters}/Makefile | 2 +-
tests/filters/data/conv/box_3x3/in.pgm | 14 +++
tests/filters/data/conv/box_3x3/out.pgm | 15 +++
tests/{loaders => filters}/runtest.sh | 2 +-
tests/framework/tst_job.c | 27 +++++-
8 files changed, 198 insertions(+), 8 deletions(-)
create mode 100644 tests/filters/LinearConvolution.c
copy tests/{loaders => filters}/Makefile (85%)
create mode 100644 tests/filters/data/conv/box_3x3/in.pgm
create mode 100644 tests/filters/data/conv/box_3x3/out.pgm
copy tests/{loaders => filters}/runtest.sh (91%)
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: fa2fab96f4932dece35de36740e2f1e4af38afd2
by metan 02 Nov '12
by metan 02 Nov '12
02 Nov '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 fa2fab96f4932dece35de36740e2f1e4af38afd2 (commit)
from d0bab795ded3a1c36fcc330aa7dcc91748351fd3 (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/fa2fab96f4932dece35de36740e2f1e4af38…
commit fa2fab96f4932dece35de36740e2f1e4af38afd2
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 2 12:38:44 2012 +0100
tests: Remove symboltests.
diff --git a/tests/SDL/Makefile b/tests/SDL/Makefile
index 9e60d18..1a27121 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=symbolstest textaligntest blittest subcontext+APPS=textaligntest blittest subcontext aatest mixpixeltest
endif
diff --git a/tests/SDL/symbolstest.c b/tests/SDL/symbolstest.c
deleted file mode 100644
index be96422..0000000
--- a/tests/SDL/symbolstest.c
+++ /dev/null
@@ -1,195 +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 <stdio.h>
-#include <stdlib.h>
-#include <SDL/SDL.h>
-
-#include "GP_SDL.h"
-
-static GP_Pixel black;
-
-/* 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;
-
-static int pause_flag = 0;
-
-static int fill_flag = 0;
-
-Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
- __attribute__((unused)) void *param)
-{
- timer_event.type = SDL_USEREVENT;
- SDL_PushEvent((SDL_Event *) &timer_event);
- return 60;
-}
-
-void random_point(SDL_Surface *surf, int *x, int *y)
-{
- *x = random() % surf->w;
- *y = random() % surf->h;
-}
-
-void draw_random_symbol(GP_Pixel pixel)
-{
- int x, y, w, h;
- random_point(display, &x, &y);
-
- w = (random() % 10) + 5;
- h = (random() % 10) + 5;
-
- if (fill_flag)
- GP_FillSymbol(&context, random() % GP_SYM_MAX, x, y, w, h,
- pixel);
- else
- GP_Symbol(&context, random() % GP_SYM_MAX, x, y, w, h,
- pixel);
-}
-
-void clear_screen(void)
-{
- SDL_LockSurface(display);
- GP_Fill(&context, black);
- SDL_UnlockSurface(display);
-}
-
-void redraw_screen(void)
-{
- if (pause_flag)
- return;
-
- SDL_LockSurface(display);
-
- GP_Pixel pixel;
- pixel = GP_RGBToPixel(random() % 256, random() % 256,
- random() % 256, context.pixel_type);
-
- draw_random_symbol(pixel);
-
- 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);
- break;
-
- case SDL_KEYDOWN:
- switch (event.key.keysym.sym) {
- case SDLK_SPACE:
- fill_flag = !fill_flag;
- clear_screen();
- break;
- case SDLK_p:
- pause_flag = !pause_flag;
- break;
- case SDLK_ESCAPE:
- return;
-
- default:
- break;
- }
- break;
- case SDL_QUIT:
- return;
- default:
- break;
- }
- }
-}
-
-int main(int argc, char *argv[])
-{
- /* Bits per pixel to be set for the display surface. */
- int display_bpp = 0;
-
- int i;
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-16") == 0) {
- display_bpp = 16;
- }
- else if (strcmp(argv[i], "-24") == 0) {
- display_bpp = 24;
- }
- else if (strcmp(argv[i], "-32") == 0) {
- display_bpp = 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, display_bpp, SDL_SWSURFACE);
- if (display == NULL) {
- fprintf(stderr, "Could not open display: %sn", SDL_GetError());
- goto fail;
- }
-
- /* 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);
-
- black = GP_ColorToContextPixel(GP_COL_BLACK, &context);
-
- /* Set up the refresh timer */
- timer = SDL_AddTimer(60, 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;
-}
-
-----------------------------------------------------------------------
Summary of changes:
tests/SDL/Makefile | 2 +-
tests/SDL/symbolstest.c | 195 -----------------------------------------------
2 files changed, 1 insertions(+), 196 deletions(-)
delete mode 100644 tests/SDL/symbolstest.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: d0bab795ded3a1c36fcc330aa7dcc91748351fd3
by metan 02 Nov '12
by metan 02 Nov '12
02 Nov '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 d0bab795ded3a1c36fcc330aa7dcc91748351fd3 (commit)
from 1b12b87ffd658031b16cd398bbf7a38637d774ce (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/d0bab795ded3a1c36fcc330aa7dcc9174835…
commit d0bab795ded3a1c36fcc330aa7dcc91748351fd3
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 2 11:52:41 2012 +0100
tests, demos: Ported fonttest to backends.
diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile
index 042c208..8cc06a0 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 linetest randomshapetest
+ fileview linetest randomshapetest fonttest
v4l2_show: LDLIBS+=-lGP_grabbers
v4l2_grab: LDLIBS+=-lGP_grabbers
diff --git a/tests/SDL/fonttest.c b/demos/c_simple/fonttest.c
similarity index 78%
rename from tests/SDL/fonttest.c
rename to demos/c_simple/fonttest.c
index 2fdf194..b9a5898 100644
--- a/tests/SDL/fonttest.c
+++ b/demos/c_simple/fonttest.c
@@ -25,13 +25,11 @@
#include <stdio.h>
#include <stdlib.h>
-#include <SDL/SDL.h>
+#include <string.h>
-#include "GP.h"
-#include "GP_SDL.h"
+#include <GP.h>
-SDL_Surface *display = NULL;
-GP_Context context;
+static GP_Backend *win;
static const char *font_path = NULL;
static unsigned int font_h = 16;
@@ -48,7 +46,7 @@ static const char *test_strings[] = {
static int font_flag = 0;
static int tracking = 0;
-GP_FontFace *font = NULL;
+static GP_FontFace *font = NULL;
static const char *glyph_bitmap_format_name(const GP_FontBitmapFormat format)
{
@@ -103,9 +101,7 @@ static void print_font_properties(const GP_FontFace *font)
void redraw_screen(void)
{
- SDL_LockSurface(display);
-
- GP_Fill(&context, black_pixel);
+ GP_Fill(win->context, black_pixel);
GP_TextStyle style = GP_DEFAULT_TEXT_STYLE;
@@ -139,29 +135,29 @@ void redraw_screen(void)
style.pixel_yspace = 0;
style.char_xspace = tracking;
- GP_FillRectXYWH(&context,
+ GP_FillRectXYWH(win->context,
16, SPACING*i + 16,
GP_TextWidth(&style, test_string),
GP_FontHeight(style.font),
dark_gray_pixel);
- GP_RectXYWH(&context,
+ GP_RectXYWH(win->context,
15, SPACING*i + 15,
GP_TextMaxWidth(&style, strlen(test_string)) + 1,
GP_FontHeight(style.font) + 1,
blue_pixel);
- GP_Text(&context, &style, 16, SPACING*i + 16, align,
+ GP_Text(win->context, &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(&context, &style, 34, SPACING * i + 44, align,
+ GP_Text(win->context, &style, 34, SPACING * i + 44, align,
white_pixel, black_pixel, test_string);
- GP_RectXYWH(&context, 33, SPACING * i + 43,
+ GP_RectXYWH(win->context, 33, SPACING * i + 43,
GP_TextWidth(&style, test_string) + 1,
GP_TextHeight(&style) + 1, dark_gray_pixel);
@@ -170,73 +166,64 @@ void redraw_screen(void)
style.pixel_xspace = 1;
style.pixel_yspace = 1;
- GP_Text(&context, &style, 64, SPACING*i + 88, align,
+ GP_Text(win->context, &style, 64, SPACING*i + 88, align,
dark_gray_pixel, black_pixel, test_string);
}
-
- SDL_UnlockSurface(display);
}
void event_loop(void)
{
- SDL_Event event;
-
- while (SDL_WaitEvent(&event) > 0) {
- switch (event.type) {
-
- case SDL_VIDEOEXPOSE:
- redraw_screen();
- SDL_Flip(display);
- break;
-
- case SDL_KEYDOWN:
- switch (event.key.keysym.sym) {
- case SDLK_SPACE:
+ 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_SPACE:
if (font)
font_flag = (font_flag + 1) % 3;
else
font_flag = (font_flag + 1) % 2;
redraw_screen();
- SDL_Flip(display);
+ GP_BackendFlip(win);
break;
- case SDLK_UP:
+ case GP_KEY_UP:
tracking++;
redraw_screen();
- SDL_Flip(display);
+ GP_BackendFlip(win);
break;
- case SDLK_DOWN:
+ case GP_KEY_DOWN:
tracking--;
redraw_screen();
- SDL_Flip(display);
+ GP_BackendFlip(win);
break;
- case SDLK_b:
+ case GP_KEY_B:
font_h++;
if (font_path) {
GP_FontFaceFree(font);
font = GP_FontFaceLoad(font_path, 0, font_h);
redraw_screen();
- SDL_Flip(display);
+ GP_BackendFlip(win);
}
break;
- case SDLK_s:
+ case GP_KEY_S:
font_h--;
if (font_path) {
GP_FontFaceFree(font);
font = GP_FontFaceLoad(font_path, 0, font_h);
redraw_screen();
- SDL_Flip(display);
+ GP_BackendFlip(win);
}
break;
- case SDLK_ESCAPE:
- return;
- default:
+ case GP_KEY_ESC:
+ GP_BackendExit(win);
+ exit(0);
break;
}
- break;
-
- case SDL_QUIT:
- return;
}
}
}
@@ -252,46 +239,38 @@ void print_instructions(void)
int main(int argc, char *argv[])
{
+ const char *backend_opts = "X11";
+
print_instructions();
GP_SetDebugLevel(10);
-
+
if (argc > 1) {
font_path = argv[1];
fprintf(stderr, "nLoading font '%s'n", argv[1]);
font = GP_FontFaceLoad(argv[1], 0, font_h);
}
+
+ win = GP_BackendInit(backend_opts, "Font Test", stderr);
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
- fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError());
+ if (win == NULL) {
+ fprintf(stderr, "Failed to initalize backend '%s'n",
+ backend_opts);
return 1;
}
-
- display = SDL_SetVideoMode(640, 500, 0, SDL_SWSURFACE);
- if (display == NULL) {
- fprintf(stderr, "Could not open display: %sn", SDL_GetError());
- goto fail;
- }
-
- GP_SDL_ContextFromSurface(&context, display);
-
- white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, &context);
- gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, &context);
- dark_gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_DARK, &context);
- black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, &context);
- red_pixel = GP_ColorToContextPixel(GP_COL_RED, &context);
- blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, &context);
+
+ white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, win->context);
+ gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, win->context);
+ dark_gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_DARK, win->context);
+ black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, win->context);
+ red_pixel = GP_ColorToContextPixel(GP_COL_RED, win->context);
+ blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, win->context);
redraw_screen();
- SDL_Flip(display);
+ GP_BackendFlip(win);
- event_loop();
-
- SDL_Quit();
- return 0;
-
-fail:
- SDL_Quit();
- return 1;
+ for (;;) {
+ GP_BackendWait(win);
+ event_loop();
+ }
}
-
diff --git a/tests/SDL/Makefile b/tests/SDL/Makefile
index 35a76e1..9e60d18 100644
--- a/tests/SDL/Makefile
+++ b/tests/SDL/Makefile
@@ -7,8 +7,7 @@ LDLIBS+=-lGP -L$(TOPDIR)/build/ -lGP_SDL -lSDL
ifeq ($(HAVE_LIBSDL),yes)
CSOURCES=$(shell echo *.c)
-APPS=fonttest- symbolstest textaligntest blittest subcontext+APPS=symbolstest textaligntest blittest subcontext aatest mixpixeltest
endif
-----------------------------------------------------------------------
Summary of changes:
demos/c_simple/Makefile | 2 +-
{tests/SDL => demos/c_simple}/fonttest.c | 127 ++++++++++++-----------------
tests/SDL/Makefile | 3 +-
3 files changed, 55 insertions(+), 77 deletions(-)
rename {tests/SDL => demos/c_simple}/fonttest.c (78%)
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: 1b12b87ffd658031b16cd398bbf7a38637d774ce
by metan 31 Oct '12
by metan 31 Oct '12
31 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 1b12b87ffd658031b16cd398bbf7a38637d774ce (commit)
from 5fb7aa901f930330ad55c1441a96869424d3c3c7 (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/1b12b87ffd658031b16cd398bbf7a38637d7…
commit 1b12b87ffd658031b16cd398bbf7a38637d774ce
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Oct 31 19:38:02 2012 +0100
tests: gfx: Add very basic tests for Line.
diff --git a/tests/gfx/Line.c b/tests/gfx/Line.c
new file mode 100644
index 0000000..5821b25
--- /dev/null
+++ b/tests/gfx/Line.c
@@ -0,0 +1,133 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include <core/GP_Context.h>
+#include <gfx/GP_Line.h>
+
+#include "tst_test.h"
+
+#include "common.h"
+
+static const char line_5_5_5_5_11x11[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,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1,
+};
+
+static int test_line(const char *pattern, GP_Size w, GP_Size h,
+ GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1)
+{
+ GP_Context *c;
+ int err;
+
+ c = GP_ContextAlloc(w, h, GP_PIXEL_G8);
+
+ if (c == NULL) {
+ tst_report(0, "Failed to allocate context");
+ return TST_UNTESTED;
+ }
+
+ /* zero the pixels buffer */
+ memset(c->pixels, 0, c->w * c->h);
+
+ GP_Line(c, x0, y0, x1, y1, 1);
+
+ err = compare_buffers(pattern, c);
+
+ if (err) {
+ tst_report(0, "Patterns are different");
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+
+static int test_line_5_5_5_5(void)
+{
+ return test_line(line_5_5_5_5_11x11, 11, 11, 5, 5, 5, 5);
+}
+
+static int test_line_1_5_9_5(void)
+{
+ return test_line(line_1_5_9_5_11x11, 11, 11, 1, 5, 9, 5);
+}
+
+static int test_line_0_0_10_10(void)
+{
+ return test_line(line_0_0_10_10_11x11, 11, 11, 0, 0, 10, 10);
+}
+
+static int test_line__1__1_11_11(void)
+{
+ return test_line(line_0_0_10_10_11x11, 11, 11, -1, -1, 11, 11);
+}
+
+const struct tst_suite tst_suite = {
+ .suite_name = "GFX Line Testsuite",
+ .tests = {
+ {.name = "Line 5x5 - 5x5", .tst_fn = test_line_5_5_5_5},
+ {.name = "Line 1x5 - 9x5", .tst_fn = test_line_1_5_9_5},
+ {.name = "Line 0x0 - 10x10", .tst_fn = test_line_0_0_10_10},
+ {.name = "Line -1x-1 - 11x11", .tst_fn = test_line__1__1_11_11},
+ {.name = NULL}
+ }
+};
diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile
index 4cbf36a..d3c9b0e 100644
--- a/tests/gfx/Makefile
+++ b/tests/gfx/Makefile
@@ -3,9 +3,10 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
-APPS=gfx_benchmark Circle CircleSeg
+APPS=gfx_benchmark Circle Line CircleSeg
Circle: common.o
+Line: common.o
CircleSeg: common.o
include ../tests.mk
diff --git a/tests/gfx/runtest.sh b/tests/gfx/runtest.sh
index e9ba8ef..bcef95e 100755
--- a/tests/gfx/runtest.sh
+++ b/tests/gfx/runtest.sh
@@ -11,4 +11,5 @@ export LIBC_FATAL_STDERR_=1
#LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./gfx_benchmark "$@"
LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Circle "$@"
+LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Line "$@"
LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./CircleSeg "$@"
-----------------------------------------------------------------------
Summary of changes:
tests/gfx/{Circle.c => Line.c} | 104 +++++++++++-----------------------------
tests/gfx/Makefile | 3 +-
tests/gfx/runtest.sh | 1 +
3 files changed, 32 insertions(+), 76 deletions(-)
copy tests/gfx/{Circle.c => Line.c} (55%)
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: 5fb7aa901f930330ad55c1441a96869424d3c3c7
by metan 31 Oct '12
by metan 31 Oct '12
31 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 5fb7aa901f930330ad55c1441a96869424d3c3c7 (commit)
via 1f78ab9179ac3d887fea911e05418de46be3bbfe (commit)
via 8cc879f18c8ac80554a923ed3c4d7587402d974a (commit)
from ff0706d61e00ba22fcb83e4902461b1832ab1023 (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/5fb7aa901f930330ad55c1441a96869424d3…
commit 5fb7aa901f930330ad55c1441a96869424d3c3c7
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Oct 31 19:18:00 2012 +0100
gfx: algo: Fix negative and zero radius for CircleSeg.
diff --git a/libs/gfx/algo/CircleSeg.algo.h b/libs/gfx/algo/CircleSeg.algo.h
index dc176a3..0b3931b 100644
--- a/libs/gfx/algo/CircleSeg.algo.h
+++ b/libs/gfx/algo/CircleSeg.algo.h
@@ -74,10 +74,21 @@
* FN_NAME - name of the function to be defined
*/
#define DEF_CIRCLE_SEG_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) -void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, unsigned int r, +void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, int r, uint8_t seg_flags, PIXVAL_T pixval) { int x, y, error; ++ /* Special case for r == 0 */ + if (r == 0) { + if (seg_flags) + PUTPIXEL(context, xcenter, ycenter, pixval); + return; + } ++ /* Clip negative r */ + r = r < 0 ? -r : r; + for (x = 0, error = -r, y = r; y >= 0; y--) { /* Iterate X until we can pass to the next line. */
http://repo.or.cz/w/gfxprim.git/commit/1f78ab9179ac3d887fea911e05418de46be3…
commit 1f78ab9179ac3d887fea911e05418de46be3bbfe
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Oct 31 19:17:39 2012 +0100
tests: gfx: Add tests for CircleSeg.
diff --git a/tests/gfx/CircleSeg.c b/tests/gfx/CircleSeg.c
new file mode 100644
index 0000000..69767ec
--- /dev/null
+++ b/tests/gfx/CircleSeg.c
@@ -0,0 +1,257 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include <core/GP_Context.h>
+#include <gfx/GP_CircleSeg.h>
+
+#include "tst_test.h"
+
+#include "common.h"
+
+static const char circle_empty_11x11[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+
+static const char circle_r_0_11x11[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 0,
+};
+
+static int test_circle(const char *pattern, GP_Size w, GP_Size h,
+ GP_Coord x, GP_Coord y, const int r, uint8_t seg_flag)
+{
+ GP_Context *c;
+ int err;
+
+ c = GP_ContextAlloc(w, h, GP_PIXEL_G8);
+
+ if (c == NULL) {
+ tst_report(0, "Failed to allocate context");
+ return TST_UNTESTED;
+ }
+
+ /* zero the pixels buffer */
+ memset(c->pixels, 0, c->w * c->h);
+
+ GP_CircleSeg(c, x, y, r, seg_flag, 1);
+
+ err = compare_buffers(pattern, c);
+
+ if (err) {
+ tst_report(0, "Patterns are different");
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+
+static int test_circle_r_0_s_1(void)
+{
+ return test_circle(circle_r_0_11x11, 11, 11, 5, 5, 0, GP_CIRCLE_SEG1);
+}
+
+static int test_circle_r_0_s_0(void)
+{
+ return test_circle(circle_empty_11x11, 11, 11, 5, 5, 0, 0);
+}
+
+static int test_circle_r_1_s_1(void)
+{
+ return test_circle(circle_r_1_s_1_11x11, 11, 11, 5, 5, 1, GP_CIRCLE_SEG1);
+}
+
+static int test_circle_r_1_s_2(void)
+{
+ return test_circle(circle_r_1_s_2_11x11, 11, 11, 5, 5, 1, GP_CIRCLE_SEG2);
+}
+
+static int test_circle_r_1_s_3(void)
+{
+ return test_circle(circle_r_1_s_3_11x11, 11, 11, 5, 5, 1, GP_CIRCLE_SEG3);
+}
+
+static int test_circle_r_1_s_4(void)
+{
+ return test_circle(circle_r_1_s_4_11x11, 11, 11, 5, 5, 1, GP_CIRCLE_SEG4);
+}
+
+static int test_circle_r_2_s_1_2(void)
+{
+ return test_circle(circle_r_2_s_1_2_11x11, 11, 11, 5, 5, 2,
+ GP_CIRCLE_SEG1|GP_CIRCLE_SEG2);
+}
+
+static int test_circle_r_2_s_1_3(void)
+{
+ return test_circle(circle_r_2_s_1_3_11x11, 11, 11, 5, 5, 2,
+ GP_CIRCLE_SEG1|GP_CIRCLE_SEG3);
+}
+
+static int test_circle_r_2_s_1_4(void)
+{
+ return test_circle(circle_r_2_s_1_4_11x11, 11, 11, 5, 5, 2,
+ GP_CIRCLE_SEG1|GP_CIRCLE_SEG4);
+}
+
+static int test_circle_r__2_s_1_3(void)
+{
+ return test_circle(circle_r_2_s_1_3_11x11, 11, 11, 5, 5, -2,
+ GP_CIRCLE_SEG1|GP_CIRCLE_SEG3);
+}
+
+const struct tst_suite tst_suite = {
+ .suite_name = "GFX CircleSeg Testsuite",
+ .tests = {
+ {.name = "CircleSeg Seg0 r=0", .tst_fn = test_circle_r_0_s_0},
+ {.name = "CircleSeg Seg1 r=0", .tst_fn = test_circle_r_0_s_1},
+ {.name = "CircleSeg Seg1 r=1", .tst_fn = test_circle_r_1_s_1},
+ {.name = "CircleSeg Seg2 r=1", .tst_fn = test_circle_r_1_s_2},
+ {.name = "CircleSeg Seg3 r=1", .tst_fn = test_circle_r_1_s_3},
+ {.name = "CircleSeg Seg4 r=1", .tst_fn = test_circle_r_1_s_4},
+ {.name = "CircleSeg Seg1|2 r=2", .tst_fn = test_circle_r_2_s_1_2},
+ {.name = "CircleSeg Seg1|3 r=2", .tst_fn = test_circle_r_2_s_1_3},
+ {.name = "CircleSeg Seg1|4 r=2", .tst_fn = test_circle_r_2_s_1_4},
+ {.name = "CircleSeg Seg1|3 r=-2", .tst_fn = test_circle_r__2_s_1_3},
+ {.name = NULL}
+ }
+};
diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile
index aa601b9..4cbf36a 100644
--- a/tests/gfx/Makefile
+++ b/tests/gfx/Makefile
@@ -3,9 +3,10 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
-APPS=gfx_benchmark Circle
+APPS=gfx_benchmark Circle CircleSeg
Circle: common.o
+CircleSeg: common.o
include ../tests.mk
diff --git a/tests/gfx/runtest.sh b/tests/gfx/runtest.sh
index 6761955..e9ba8ef 100755
--- a/tests/gfx/runtest.sh
+++ b/tests/gfx/runtest.sh
@@ -11,3 +11,4 @@ export LIBC_FATAL_STDERR_=1
#LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./gfx_benchmark "$@"
LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Circle "$@"
+LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./CircleSeg "$@"
http://repo.or.cz/w/gfxprim.git/commit/8cc879f18c8ac80554a923ed3c4d7587402d…
commit 8cc879f18c8ac80554a923ed3c4d7587402d974a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Oct 31 18:46:33 2012 +0100
tests: gfx: Move common code to file.
diff --git a/tests/gfx/Circle.c b/tests/gfx/Circle.c
index 0482e99..d159632 100644
--- a/tests/gfx/Circle.c
+++ b/tests/gfx/Circle.c
@@ -29,6 +29,8 @@
#include "tst_test.h"
+#include "common.h"
+
static const char circle_r_0_11x11[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -99,45 +101,6 @@ static const char circle_r_5_half_11x11[] = {
1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
};
-static void dump_buffer(const char *pattern, int x, int y)
-{
- int i, j;
-
- for (i = 0; i < y; i++) {
- for (j = 0; j < x; j++)
- printf("%2x ", pattern[j + i * y]);
- printf("n");
- }
-}
-
-static void dump_buffers(const char *pattern, const GP_Context *c)
-{
- printf("Expected patternn");
- dump_buffer(pattern, c->w, c->h);
- printf("Rendered patternn");
- dump_buffer((char*)c->pixels, c->w, c->h);
-}
-
-static int compare_buffers(const char *pattern, const GP_Context *c)
-{
- GP_Size x, y;
- int err = 0;
-
- for (x = 0; x < c->w; x++) {
- for (y = 0; y < c->h; y++) {
- if (pattern[x + y * c->h] !=
- ((char*)c->pixels)[x + y * c->h]) {
- err++;
- }
- }
- }
-
- if (err)
- dump_buffers(pattern, c);
-
- return err;
-}
-
static int test_circle(const char *pattern, GP_Size w, GP_Size h,
GP_Coord x, GP_Coord y, const int r)
{
diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile
index 15c1984..aa601b9 100644
--- a/tests/gfx/Makefile
+++ b/tests/gfx/Makefile
@@ -5,6 +5,8 @@ CSOURCES=$(shell echo *.c)
APPS=gfx_benchmark Circle
+Circle: common.o
+
include ../tests.mk
include $(TOPDIR)/app.mk
diff --git a/tests/gfx/common.c b/tests/gfx/common.c
new file mode 100644
index 0000000..d261dfd
--- /dev/null
+++ b/tests/gfx/common.c
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+#include <stdio.h>
+
+#include "common.h"
+
+static void dump_buffer(const char *pattern, int x, int y)
+{
+ int i, j;
+
+ for (i = 0; i < y; i++) {
+ for (j = 0; j < x; j++)
+ printf("%2x ", pattern[j + i * y]);
+ printf("n");
+ }
+}
+
+void dump_buffers(const char *pattern, const GP_Context *c)
+{
+ printf("Expected patternn");
+ dump_buffer(pattern, c->w, c->h);
+ printf("Rendered patternn");
+ dump_buffer((char*)c->pixels, c->w, c->h);
+}
+
+int compare_buffers(const char *pattern, const GP_Context *c)
+{
+ GP_Size x, y;
+ int err = 0;
+
+ for (x = 0; x < c->w; x++) {
+ for (y = 0; y < c->h; y++) {
+ if (pattern[x + y * c->h] !=
+ ((char*)c->pixels)[x + y * c->h]) {
+ err++;
+ }
+ }
+ }
+
+ if (err)
+ dump_buffers(pattern, c);
+
+ return err;
+}
diff --git a/tests/gfx/common.h b/tests/gfx/common.h
new file mode 100644
index 0000000..65b9d19
--- /dev/null
+++ b/tests/gfx/common.h
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * 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 __COMMON_H__
+#define __COMMON_H__
+
+#include <core/GP_Context.h>
+
+void dump_buffers(const char *pattern, const GP_Context *c);
+
+int compare_buffers(const char *pattern, const GP_Context *c);
+
+#endif /* __COMMON_H__ */
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/algo/CircleSeg.algo.h | 13 +-
tests/gfx/Circle.c | 41 +---
tests/gfx/CircleSeg.c | 257 ++++++++++++++++++++
tests/gfx/Makefile | 5 +-
.../loaders_example.c => tests/gfx/common.c | 59 +++---
include/input/GP_Input.h => tests/gfx/common.h | 15 +-
tests/gfx/runtest.sh | 1 +
7 files changed, 315 insertions(+), 76 deletions(-)
create mode 100644 tests/gfx/CircleSeg.c
copy demos/c_simple/loaders_example.c => tests/gfx/common.c (70%)
copy include/input/GP_Input.h => tests/gfx/common.h (88%)
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: ff0706d61e00ba22fcb83e4902461b1832ab1023
by metan 31 Oct '12
by metan 31 Oct '12
31 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 ff0706d61e00ba22fcb83e4902461b1832ab1023 (commit)
from d0453af494e305191b9d85f6f35fbc06b828d61d (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/ff0706d61e00ba22fcb83e4902461b1832ab…
commit ff0706d61e00ba22fcb83e4902461b1832ab1023
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Oct 31 18:30:59 2012 +0100
gfx: algo: Fix negative and zero radius for Circle
The gfx prototypes are not correct though.
diff --git a/libs/gfx/algo/Circle.algo.h b/libs/gfx/algo/Circle.algo.h
index f5f5acc..76deb83 100644
--- a/libs/gfx/algo/Circle.algo.h
+++ b/libs/gfx/algo/Circle.algo.h
@@ -74,10 +74,20 @@
* FN_NAME - name of the function to be defined
*/
#define DEF_CIRCLE_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) -void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, unsigned int r, +void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, int r, PIXVAL_T pixval) { int x, y, error; ++ /* Special case for r == 0 */ + if (r == 0) { + PUTPIXEL(context, xcenter, ycenter, pixval); + return; + } ++ /* Clip negative r */ + r = r < 0 ? -r : r; + for (x = 0, error = -r, y = r; y >= 0; y--) { /* Iterate X until we can pass to the next line. */
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/algo/Circle.algo.h | 12 +++++++++++-
1 files changed, 11 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: d0453af494e305191b9d85f6f35fbc06b828d61d
by metan 31 Oct '12
by metan 31 Oct '12
31 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 d0453af494e305191b9d85f6f35fbc06b828d61d (commit)
from a74fce450b62265d5dc4b80f43a89bfeb570e271 (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/d0453af494e305191b9d85f6f35fbc06b828…
commit d0453af494e305191b9d85f6f35fbc06b828d61d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Oct 31 18:13:50 2012 +0100
tests: gfx: Basic tests for a circle.
diff --git a/tests/gfx/Circle.c b/tests/gfx/Circle.c
new file mode 100644
index 0000000..0482e99
--- /dev/null
+++ b/tests/gfx/Circle.c
@@ -0,0 +1,216 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include <core/GP_Context.h>
+#include <gfx/GP_Circle.h>
+
+#include "tst_test.h"
+
+static const char circle_r_0_11x11[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+
+static const char circle_r_1_11x11[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+
+static const char circle_r_2_11x11[] = {
+ 0,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, 0, 0, 0, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+
+static void dump_buffer(const char *pattern, int x, int y)
+{
+ int i, j;
+
+ for (i = 0; i < y; i++) {
+ for (j = 0; j < x; j++)
+ printf("%2x ", pattern[j + i * y]);
+ printf("n");
+ }
+}
+
+static void dump_buffers(const char *pattern, const GP_Context *c)
+{
+ printf("Expected patternn");
+ dump_buffer(pattern, c->w, c->h);
+ printf("Rendered patternn");
+ dump_buffer((char*)c->pixels, c->w, c->h);
+}
+
+static int compare_buffers(const char *pattern, const GP_Context *c)
+{
+ GP_Size x, y;
+ int err = 0;
+
+ for (x = 0; x < c->w; x++) {
+ for (y = 0; y < c->h; y++) {
+ if (pattern[x + y * c->h] !=
+ ((char*)c->pixels)[x + y * c->h]) {
+ err++;
+ }
+ }
+ }
+
+ if (err)
+ dump_buffers(pattern, c);
+
+ return err;
+}
+
+static int test_circle(const char *pattern, GP_Size w, GP_Size h,
+ GP_Coord x, GP_Coord y, const int r)
+{
+ GP_Context *c;
+ int err;
+
+ c = GP_ContextAlloc(w, h, GP_PIXEL_G8);
+
+ if (c == NULL) {
+ tst_report(0, "Failed to allocate context");
+ return TST_UNTESTED;
+ }
+
+ /* zero the pixels buffer */
+ memset(c->pixels, 0, c->w * c->h);
+
+ GP_Circle(c, x, y, r, 1);
+
+ err = compare_buffers(pattern, c);
+
+ if (err) {
+ tst_report(0, "Patterns are different");
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+
+static int test_circle_r_0(void)
+{
+ return test_circle(circle_r_0_11x11, 11, 11, 5, 5, 0);
+}
+
+static int test_circle_r_1(void)
+{
+ return test_circle(circle_r_1_11x11, 11, 11, 5, 5, 1);
+}
+
+static int test_circle_r_2(void)
+{
+ return test_circle(circle_r_2_11x11, 11, 11, 5, 5, 2);
+}
+
+static int test_circle_r_3(void)
+{
+ return test_circle(circle_r_3_11x11, 11, 11, 5, 5, 3);
+}
+
+static int test_circle_r__1(void)
+{
+ return test_circle(circle_r_1_11x11, 11, 11, 5, 5, -1);
+}
+
+static int test_circle_r__2(void)
+{
+ return test_circle(circle_r_2_11x11, 11, 11, 5, 5, -2);
+}
+
+static int test_circle_r_5_half(void)
+{
+ return test_circle(circle_r_5_half_11x11, 11, 11, 0, 5, 5);
+}
+
+const struct tst_suite tst_suite = {
+ .suite_name = "GFX Circle Testsuite",
+ .tests = {
+ {.name = "Circle r=0", .tst_fn = test_circle_r_0},
+ {.name = "Circle r=1", .tst_fn = test_circle_r_1},
+ {.name = "Circle r=2", .tst_fn = test_circle_r_2},
+ {.name = "Circle r=3", .tst_fn = test_circle_r_3},
+ {.name = "Circle r=5 half", .tst_fn = test_circle_r_5_half},
+ {.name = "Circle r=-1", .tst_fn = test_circle_r__1},
+ {.name = "Circle r=-2", .tst_fn = test_circle_r__2},
+ {.name = NULL}
+ }
+};
diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile
index 71e9223..15c1984 100644
--- a/tests/gfx/Makefile
+++ b/tests/gfx/Makefile
@@ -3,7 +3,7 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
-APPS=gfx_benchmark
+APPS=gfx_benchmark Circle
include ../tests.mk
diff --git a/tests/gfx/runtest.sh b/tests/gfx/runtest.sh
index 71a411b..6761955 100755
--- a/tests/gfx/runtest.sh
+++ b/tests/gfx/runtest.sh
@@ -9,4 +9,5 @@
#
export LIBC_FATAL_STDERR_=1
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./gfx_benchmark "$@"
+#LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./gfx_benchmark "$@"
+LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Circle "$@"
-----------------------------------------------------------------------
Summary of changes:
tests/gfx/Circle.c | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++
tests/gfx/Makefile | 2 +-
tests/gfx/runtest.sh | 3 +-
3 files changed, 219 insertions(+), 2 deletions(-)
create mode 100644 tests/gfx/Circle.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: a74fce450b62265d5dc4b80f43a89bfeb570e271
by metan 30 Oct '12
by metan 30 Oct '12
30 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 a74fce450b62265d5dc4b80f43a89bfeb570e271 (commit)
from 8701e8765185f90507ff6a02c03fcf0c22ae1e8f (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/a74fce450b62265d5dc4b80f43a89bfeb570…
commit a74fce450b62265d5dc4b80f43a89bfeb570e271
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Oct 30 22:25:02 2012 +0100
tests: Remove pixeltests.
diff --git a/tests/SDL/Makefile b/tests/SDL/Makefile
index 6985861..35a76e1 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+APPS=fonttest symbolstest textaligntest blittest subcontext aatest mixpixeltest
endif
diff --git a/tests/SDL/pixeltest.c b/tests/SDL/pixeltest.c
deleted file mode 100644
index 6d7ccf0..0000000
--- a/tests/SDL/pixeltest.c
+++ /dev/null
@@ -1,169 +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 <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 red_pixel, green_pixel, blue_pixel, white_pixel;
-
-Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
- __attribute__((unused)) void *param)
-{
- timer_event.type = SDL_USEREVENT;
- SDL_PushEvent((SDL_Event *) &timer_event);
- return 30;
-}
-
-void draw_pixel(void)
-{
- GP_Pixel pixel;
- int x = random() % 320;
- int y = random() % 240;
-
- pixel = GP_GetPixel(&context, x, y);
-
- if (pixel == blue_pixel) {
- GP_PutPixel(&context, x, y, green_pixel);
- }
- else if (pixel == red_pixel) {
- GP_PutPixel(&context, x, y, white_pixel);
- }
- else {
- if (x < 160) {
- GP_PutPixel(&context, x, y, blue_pixel);
- } else {
- GP_PutPixel(&context, x, y, red_pixel);
- }
- }
-}
-
-void draw_pixels(void)
-{
- SDL_LockSurface(display);
-
- /* Draw some pixels (exact number is not important). */
- int i;
- for (i = 0; i < 30; i++)
- draw_pixel();
-
- SDL_UnlockSurface(display);
-}
-
-void event_loop(void)
-{
- SDL_Event event;
-
- while (SDL_WaitEvent(&event) > 0) {
- switch (event.type) {
- case SDL_USEREVENT:
- draw_pixels();
- SDL_Flip(display);
- break;
- case SDL_KEYDOWN:
- case SDL_QUIT:
- return;
- }
- }
-}
-
-int main(int argc, char **argv)
-{
- int display_bpp = 0;
-
- int i;
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-16") == 0) {
- display_bpp = 16;
- } else if (strcmp(argv[i], "-24") == 0) {
- display_bpp = 24;
- }
- }
-
- /* 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(320, 240, display_bpp, 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);
-
- /* Set up a clipping rectangle to test proper clipping of pixels */
- SDL_Rect clip_rect = {10, 10, 300, 220};
- SDL_SetClipRect(display, &clip_rect);
-
- GP_SDL_ContextFromSurface(&context, display);
-
- /* Load pixel values compatible with the display. */
- red_pixel = GP_ColorToContextPixel(GP_COL_RED, &context);
- green_pixel = GP_ColorToContextPixel(GP_COL_GREEN, &context);
- blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, &context);
- white_pixel = 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;
-}
-----------------------------------------------------------------------
Summary of changes:
tests/SDL/Makefile | 2 +-
tests/SDL/pixeltest.c | 169 -------------------------------------------------
2 files changed, 1 insertions(+), 170 deletions(-)
delete mode 100644 tests/SDL/pixeltest.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: 8701e8765185f90507ff6a02c03fcf0c22ae1e8f
by metan 30 Oct '12
by metan 30 Oct '12
30 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 8701e8765185f90507ff6a02c03fcf0c22ae1e8f (commit)
from 3f35d87f9ab132a5e60d3c6d7d8324af2da43653 (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/8701e8765185f90507ff6a02c03fcf0c22ae…
commit 8701e8765185f90507ff6a02c03fcf0c22ae1e8f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Oct 30 22:22:16 2012 +0100
tests, demos: Port randomshapetest to backends.
diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile
index f703dd1..042c208 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 linetest
+ fileview linetest randomshapetest
v4l2_show: LDLIBS+=-lGP_grabbers
v4l2_grab: LDLIBS+=-lGP_grabbers
diff --git a/tests/SDL/randomshapetest.c b/demos/c_simple/randomshapetest.c
similarity index 50%
rename from tests/SDL/randomshapetest.c
rename to demos/c_simple/randomshapetest.c
index f7c8939..b699348 100644
--- a/tests/SDL/randomshapetest.c
+++ b/demos/c_simple/randomshapetest.c
@@ -19,40 +19,23 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
-#include <SDL/SDL.h>
-#include "GP_SDL.h"
+#include <GP.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;
+static GP_Backend *win;
/* Globally used colors. */
-GP_Pixel white, black;
+static GP_Pixel white, black;
/* Holding flag (pauses drawing). */
static int pause_flag = 0;
-Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
- __attribute__((unused)) void *param)
-{
- timer_event.type = SDL_USEREVENT;
- SDL_PushEvent((SDL_Event *) &timer_event);
- return 60;
-}
-
/* Shape to draw */
#define SHAPE_FIRST 1
#define SHAPE_CIRCLE 1
@@ -73,111 +56,110 @@ static int fill_flag = 1;
/* Do a clipping test? */
static int cliptest_flag = 0;
-void random_point(SDL_Surface *surf, int *x, int *y)
+void random_point(const GP_Context *c, int *x, int *y)
{
if (cliptest_flag) {
- *x = random() % (3*surf->w) - surf->w;
- *y = random() % (3*surf->h) - surf->h;
+ *x = random() % (3*c->w) - c->w;
+ *y = random() % (3*c->h) - c->h;
} else {
- *x = random() % surf->w;
- *y = random() % surf->h;
+ *x = random() % c->w;
+ *y = random() % c->h;
}
}
-void random_point_AA(SDL_Surface *surf, int *x, int *y)
+void random_point_AA(const GP_Context *c, int *x, int *y)
{
- *x = random() % (surf->w<<8);
- *y = random() % (surf->h<<8);
+ *x = random() % (c->w<<8);
+ *y = random() % (c->h<<8);
}
void draw_random_circle(GP_Pixel pixel)
{
int x, y;
- random_point(display, &x, &y);
+ random_point(win->context, &x, &y);
int r = random() % 50;
if (fill_flag)
- GP_FillCircle(&context, x, y, r, pixel);
+ GP_FillCircle(win->context, x, y, r, pixel);
if (outline_flag)
- GP_Circle(&context, x, y, r, white);
+ GP_Circle(win->context, x, y, r, white);
}
void draw_random_ellipse(GP_Pixel pixel)
{
int x, y;
- random_point(display, &x, &y);
+ random_point(win->context, &x, &y);
int rx = random() % 50;
int ry = random() % 50;
if (fill_flag)
- GP_FillEllipse(&context, x, y, rx, ry, pixel);
+ GP_FillEllipse(win->context, x, y, rx, ry, pixel);
if (outline_flag)
- GP_Ellipse(&context, x, y, rx, ry, white);
+ GP_Ellipse(win->context, x, y, rx, ry, white);
}
void draw_random_triangle(GP_Pixel pixel)
{
int x0, y0, x1, y1, x2, y2;
- random_point(display, &x0, &y0);
- random_point(display, &x1, &y1);
- random_point(display, &x2, &y2);
+ random_point(win->context, &x0, &y0);
+ random_point(win->context, &x1, &y1);
+ random_point(win->context, &x2, &y2);
if (fill_flag)
- GP_FillTriangle(&context, x0, y0, x1, y1, x2, y2, pixel);
+ GP_FillTriangle(win->context, x0, y0, x1, y1, x2, y2, pixel);
if (outline_flag)
- GP_Triangle(&context, x0, y0, x1, y1, x2, y2, white);
+ GP_Triangle(win->context, x0, y0, x1, y1, x2, y2, white);
}
void draw_random_rectangle(GP_Pixel pixel)
{
int x0, y0, x1, y1;
- random_point(display, &x0, &y0);
- random_point(display, &x1, &y1);
+ random_point(win->context, &x0, &y0);
+ random_point(win->context, &x1, &y1);
if (fill_flag)
- GP_FillRect(&context, x0, y0, x1, y1, pixel);
+ GP_FillRect(win->context, x0, y0, x1, y1, pixel);
if (outline_flag)
- GP_Rect(&context, x0, y0, x1, y1, white);
+ GP_Rect(win->context, x0, y0, x1, y1, white);
}
void draw_random_tetragon(GP_Pixel pixel)
{
int x0, y0, x1, y1, x2, y2, x3, y3;
- random_point(display, &x0, &y0);
- random_point(display, &x1, &y1);
- random_point(display, &x2, &y2);
- random_point(display, &x3, &y3);
+ random_point(win->context, &x0, &y0);
+ random_point(win->context, &x1, &y1);
+ random_point(win->context, &x2, &y2);
+ random_point(win->context, &x3, &y3);
if (fill_flag)
- GP_FillTetragon(&context, x0, y0, x1, y1, x2, y2, x3, y3, pixel);
+ GP_FillTetragon(win->context, x0, y0, x1, y1, x2, y2, x3, y3, pixel);
if (outline_flag)
- GP_Tetragon(&context, x0, y0, x1, y1, x2, y2, x3, y3, pixel);
+ GP_Tetragon(win->context, x0, y0, x1, y1, x2, y2, x3, y3, pixel);
}
void draw_random_rectangle_AA(GP_Pixel pixel)
{
int x0, y0, x1, y1;
- random_point_AA(display, &x0, &y0);
- random_point_AA(display, &x1, &y1);
+ random_point_AA(win->context, &x0, &y0);
+ random_point_AA(win->context, &x1, &y1);
// if (fill_flag)
- GP_FillRect_AA(&context, x0, y0, x1, y1, pixel);
+ GP_FillRect_AA(win->context, x0, y0, x1, y1, pixel);
// if (outline_flag)
-// GP_Rect(&context, x0, y0, x1, y1, white);
+// GP_Rect(win->context, x0, y0, x1, y1, white);
}
void clear_screen(void)
{
- SDL_LockSurface(display);
- GP_Fill(&context, black);
- SDL_UnlockSurface(display);
+ GP_Fill(win->context, black);
+ GP_BackendFlip(win);
}
void redraw_screen(void)
@@ -185,12 +167,10 @@ void redraw_screen(void)
if (pause_flag)
return;
- SDL_LockSurface(display);
-
/* Pick a random color for drawing. */
GP_Pixel pixel;
pixel = GP_RGBToPixel(random() % 256, random() % 256,
- random() % 256, context.pixel_type);
+ random() % 256, win->context->pixel_type);
switch (shape) {
case SHAPE_CIRCLE:
@@ -212,133 +192,80 @@ void redraw_screen(void)
draw_random_rectangle_AA(pixel);
break;
}
-
- 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);
- break;
-
- case SDL_KEYDOWN:
- switch (event.key.keysym.sym) {
-
- case SDLK_SPACE:
+ 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_SPACE:
shape++;
if (shape > SHAPE_LAST)
shape = SHAPE_FIRST;
clear_screen();
- SDL_Flip(display);
pause_flag = 0;
- break;
-
- case SDLK_p:
+ break;
+ case GP_KEY_P:
pause_flag = !pause_flag;
- break;
-
- case SDLK_f:
+ break;
+ case GP_KEY_F:
fill_flag = !fill_flag;
- if (!fill_flag && !outline_flag) {
+ if (!fill_flag && !outline_flag)
outline_flag = 1;
- }
- break;
-
- case SDLK_o:
+ break;
+ case GP_KEY_O:
outline_flag = !outline_flag;
- if (!fill_flag && !outline_flag) {
+ if (!fill_flag && !outline_flag)
fill_flag = 1;
- }
- break;
-
- case SDLK_c:
+ break;
+ case GP_KEY_C:
cliptest_flag = !cliptest_flag;
- break;
-
- case SDLK_x:
+ break;
+ case GP_KEY_X:
clear_screen();
- SDL_Flip(display);
- break;
-
- case SDLK_ESCAPE:
- return;
-
- default:
- break;
- }
break;
- case SDL_QUIT:
- return;
- default:
+ case GP_KEY_ESC:
+ GP_BackendExit(win);
+ exit(0);
break;
+ }
}
}
}
-int main(int argc, char *argv[])
+int main(void)
{
- /* Bits per pixel to be set for the display surface. */
- int display_bpp = 0;
-
- int i;
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-16") == 0) {
- display_bpp = 16;
- }
- else if (strcmp(argv[i], "-24") == 0) {
- display_bpp = 24;
- }
- else if (strcmp(argv[i], "-32") == 0) {
- display_bpp = 32;
- }
- }
+ const char *backend_opts = "X11";
+
+ win = GP_BackendInit(backend_opts, "Random Shape Test", stderr);
- /* Initialize SDL */
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
- fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError());
+ if (win == NULL) {
+ fprintf(stderr, "Failed to initalize backend '%s'n",
+ backend_opts);
return 1;
}
-
- /* Create a window with a software back surface */
- display = SDL_SetVideoMode(640, 480, display_bpp, SDL_SWSURFACE);
- if (display == NULL) {
- fprintf(stderr, "Could not open display: %sn", SDL_GetError());
- goto fail;
- }
-
- /* 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 refresh timer */
- timer = SDL_AddTimer(60, timer_callback, NULL);
- if (timer == 0) {
- fprintf(stderr, "Could not set up timer: %sn", SDL_GetError());
- goto fail;
+
+ white = GP_ColorToContextPixel(GP_COL_WHITE, win->context);
+ black = GP_ColorToContextPixel(GP_COL_BLACK, win->context);
+
+ for (;;) {
+ GP_BackendPoll(win);
+ event_loop();
+
+ usleep(20000);
+
+ if (pause_flag)
+ continue;
+
+ redraw_screen();
+ GP_BackendFlip(win);
}
-
- /* Enter the event loop */
- event_loop();
-
- /* We're done */
- SDL_Quit();
- return 0;
-
-fail:
- SDL_Quit();
- return 1;
}
diff --git a/tests/SDL/Makefile b/tests/SDL/Makefile
index 1002fcb..6985861 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 randomshapetest+APPS=pixeltest fonttest symbolstest textaligntest blittest subcontext aatest mixpixeltest
endif
-----------------------------------------------------------------------
Summary of changes:
demos/c_simple/Makefile | 2 +-
{tests/SDL => demos/c_simple}/randomshapetest.c | 249 ++++++++---------------
tests/SDL/Makefile | 2 +-
3 files changed, 90 insertions(+), 163 deletions(-)
rename {tests/SDL => demos/c_simple}/randomshapetest.c (50%)
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