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 94726f09c80a120c03ee251338f2a2800bdaa076 (commit)
from 951e4bf59ad725f05fce1600e8da2ca8f4a8f8c0 (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/94726f09c80a120c03ee251338f2a2800bda…
commit 94726f09c80a120c03ee251338f2a2800bdaa076
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Dec 20 15:53:05 2012 +0100
doc: Add clear bitendian definition.
diff --git a/doc/.gitignore b/doc/.gitignore
index 4b4703c..670b96a 100644
--- a/doc/.gitignore
+++ b/doc/.gitignore
@@ -9,3 +9,7 @@ discrete_linear_convolution_alg2.png
laplacian_edge_sharpening.png
laplacian_kernel.png
+bit-endian-be-1bit.png
+bit-endian-be-2bits.png
+bit-endian-le-1bit.png
+bit-endian-le-2bits.png
diff --git a/doc/README b/doc/README
index ae93336..400ede1 100644
--- a/doc/README
+++ b/doc/README
@@ -2,4 +2,5 @@ This directory contains asciidoc documentation.
The html pages are generated by typing 'make'.
-In order to do that asciidoc and source-highlight, latex and dvipng must be installed.
+In order to do that asciidoc and source-highlight, latex and dvipng and
+graphviz must be installed.
diff --git a/doc/gen.txt b/doc/gen.txt
index 28b438d..949f585 100644
--- a/doc/gen.txt
+++ b/doc/gen.txt
@@ -38,13 +38,98 @@ per pixel. It also contains suffix that is a string used as a suffix for
functions that manipulates with this pixel size.
The 'bit_endian' determines direction of bits in bitmaps and graymaps (i.e.
-most significant bit left or right). It can be either 'BE' or 'LE'.
-
-Note that different pixels can share the same pixel size as for certain types
-of operations the function doesn't depend on actual arrangements of the color
-channels in pixel (i.e. Get/Put Pixel, Rotate buffer 90 degrees, etc...).
-
-TODO: Which bit endian is which?
+most significant bit left or right). It can be either 'BE' or 'LE'. To avoid
+confusion following two figures describes bits layout in 1 bit and 2 bits
+grayscale bitmaps. The rectangles in the figures represents bytes as they are
+in the buffer. The start of the image (i.e. topleft corner and coodinate 0,0)
+is on the left side. The numbers describes position of the bit in the byte (as
+seen by shifts and bitmask from within C language implementation).
+
+BE
+~~
+
+["graphviz", "bit-endian-be-1bit.png"]
+------------------------------------------------------------------------------
+digraph bit_endian {
+ node [shape = record];
+ rankdir = LR;
+
+ node0 [label = "{<e> ...}"];
+ node1 [label = "{7 | 6 | 5 | 4 | 3 | 2 | 1 | <e> 0}"];
+ node2 [label = "{<b> 7 | 6 | 5 | 4 | 3 | 2 | 1 | <e> 0}"];
+ node3 [label = "{<b> 7 | 6 | 5 | 4 | 3 | 2 | 1 | <e> 0}"];
+ node4 [label = "{<b> ...}"];
+
+ node0:e -> node1:b;
+ node1:e -> node2:b;
+ node2:e -> node3:b;
+ node3:e -> node4:b;
+}
+------------------------------------------------------------------------------
+
+["graphviz", "bit-endian-be-2bits.png"]
+------------------------------------------------------------------------------
+digraph bit_endian {
+ node [shape = record];
+ rankdir = LR;
+
+ node0 [label = "{<e> ...}"];
+ node1 [label = "{7 6 | 5 4 | 3 2 | <e> 1 0}"];
+ node2 [label = "{<b> 7 6 | 5 4 | 3 2 | <e> 1 0}"];
+ node3 [label = "{<b> 7 6 | 5 4 | 3 2 | <e> 1 0}"];
+ node4 [label = "{<b> ...}"];
+
+ node0:e -> node1:b;
+ node1:e -> node2:b;
+ node2:e -> node3:b;
+ node3:e -> node4:b;
+}
+------------------------------------------------------------------------------
+
+LE
+~~
+
+["graphviz", "bit-endian-le-1bit.png"]
+------------------------------------------------------------------------------
+digraph bit_endian {
+ node [shape = record];
+ rankdir = LR;
+
+ node0 [label = "{<e> ...}"];
+ node1 [label = "{0 | 1 | 2 | 3 | 4 | 5 | 6 | <e> 7}"];
+ node2 [label = "{<b> 0 | 1 | 2 | 3 | 4 | 5 | 6 | <e> 7}"];
+ node3 [label = "{<b> 0 | 1 | 2 | 3 | 4 | 5 | 6 | <e> 7}"];
+ node4 [label = "{<b> ...}"];
+
+ node0:e -> node1:b;
+ node1:e -> node2:b;
+ node2:e -> node3:b;
+ node3:e -> node4:b;
+}
+------------------------------------------------------------------------------
+
+["graphviz", "bit-endian-le-2bits.png"]
+------------------------------------------------------------------------------
+digraph bit_endian {
+ node [shape = record];
+ rankdir = LR;
+
+ node0 [label = "<e> ..."];
+ node1 [label = "{0 1 | 2 3 | 4 5 | <e> 6 7}"];
+ node2 [label = "{<b> 0 1 | 2 3 | 4 5 | <e> 6 7}"];
+ node3 [label = "{<b> 0 1 | 2 3 | 4 5 | <e> 6 7}"];
+ node4 [label = "{<b> ...}"];
+
+ node0:e -> node1:b;
+ node1:e -> node2:b;
+ node2:e -> node3:b;
+ node3:e -> node4:b;
+}
+------------------------------------------------------------------------------
+
+NOTE: Different pixels can share the same pixel size as for certain types
+ of operations the function doesn't depend on actual arrangements of the
+ color channels in pixel (i.e. Get/Put Pixel, Rotate buffer 90 degrees, etc...).
TODO: Rename size to bpp?
-----------------------------------------------------------------------
Summary of changes:
doc/.gitignore | 4 ++
doc/README | 3 +-
doc/gen.txt | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 98 insertions(+), 8 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.")
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 951e4bf59ad725f05fce1600e8da2ca8f4a8f8c0 (commit)
via ddbd27fd085cc515d61fdae1a159922090eb327b (commit)
from 3a66b0d92c78955b31e8b825f3b2049ffdf3487a (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/951e4bf59ad725f05fce1600e8da2ca8f4a8…
commit 951e4bf59ad725f05fce1600e8da2ca8f4a8f8c0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Dec 20 13:46:29 2012 +0100
demos: spiv: Move image listing code into separate file.
diff --git a/demos/spiv/Makefile b/demos/spiv/Makefile
index f533179..95e7560 100644
--- a/demos/spiv/Makefile
+++ b/demos/spiv/Makefile
@@ -8,7 +8,7 @@ LDLIBS+=-lrt `$(TOPDIR)/gfxprim-config --libs --libs-backends`
APPS=spiv
-spiv: cpu_timer.o image_cache.o
+spiv: cpu_timer.o image_cache.o image_list.o
include $(TOPDIR)/pre.mk
include $(TOPDIR)/app.mk
diff --git a/demos/spiv/image_list.c b/demos/spiv/image_list.c
new file mode 100644
index 0000000..390275f
--- /dev/null
+++ b/demos/spiv/image_list.c
@@ -0,0 +1,110 @@
+/*****************************************************************************
+ * 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 <stdlib.h>
+
+#include <core/GP_Debug.h>
+
+#include "image_list.h"
+
+struct image_list {
+ /* list we got from the app */
+ const char **args;
+ unsigned int cur_arg;
+ unsigned int max_arg;
+
+ /* path to the currently loaded image */
+ char path[1024];
+ int path_loaded:1;
+};
+
+static void next_img(struct image_list *self)
+{
+ if (++self->cur_arg == self->max_arg)
+ self->cur_arg = 0;
+
+ self->path_loaded = 0;
+}
+
+static void prev_img(struct image_list *self)
+{
+ if (self->cur_arg == 0)
+ self->cur_arg = self->max_arg - 1;
+ else
+ self->cur_arg--;
+
+ self->path_loaded = 0;
+}
+
+static void load_path(struct image_list *self)
+{
+ snprintf(self->path, sizeof(self->path), "%s", self->args[self->cur_arg]);
+
+ self->path_loaded = 1;
+}
+
+const char *image_list_move(struct image_list *self, int direction)
+{
+ GP_DEBUG(2, "Moving list by %i", direction);
+
+ int i;
+
+ for (i = 0; i < direction; i++)
+ next_img(self);
+
+ for (i = 0; i > direction; i--)
+ prev_img(self);
+
+ return image_list_img_path(self);
+}
+
+struct image_list *image_list_create(const char *args[])
+{
+ struct image_list *self;
+
+ GP_DEBUG(1, "Creating image list");
+
+ self = malloc(sizeof(struct image_list));
+
+ if (self == NULL)
+ return NULL;
+
+ self->args = args;
+ self->cur_arg = 0;
+
+ self->path_loaded = 0;
+
+ self->max_arg = 0;
+ while (args[++self->max_arg] != NULL);
+
+ return self;
+}
+
+const char *image_list_img_path(struct image_list *self)
+{
+ if (!self->path_loaded)
+ load_path(self);
+
+ GP_DEBUG(2, "Returning path '%s'", self->path);
+
+ return self->path;
+}
diff --git a/demos/spiv/image_list.h b/demos/spiv/image_list.h
new file mode 100644
index 0000000..e7b299a
--- /dev/null
+++ b/demos/spiv/image_list.h
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+ /*
+
+ Image list.
+
+ */
+
+#ifndef __IMAGE_LIST_H__
+#define __IMAGE_LIST_H__
+
+struct image_list;
+
+/*
+ * Takes NULL-terminated array of paths as parameter
+ */
+struct image_list *image_list_create(const char *args[]);
+
+/*
+ * Returns path to the current image.
+ */
+const char *image_list_img_path(struct image_list *self);
+
+/*
+ * Moves the current image direction images and returns pointer to current
+ * path.
+ */
+const char *image_list_move(struct image_list *self, int direction);
+
+#endif /* __IMAGE_LIST_H__ */
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 7c3dd20..82a8e75 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -37,6 +37,7 @@
#include <input/GP_InputDriverLinux.h>
#include "image_cache.h"
+#include "image_list.h"
#include "cpu_timer.h"
static GP_Pixel black_pixel;
@@ -325,7 +326,7 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size
cpu_timer_stop(&timer);
}
-// img->gamma = GP_GammaAcquire(img->pixel_type, 2.2);
+// img->gamma = GP_GammaAcquire(img->pixel_type, 0.45);
cpu_timer_start(&timer, "Resampling");
callback.priv = "Resampling Image";
@@ -637,7 +638,7 @@ int main(int argc, char *argv[])
int opt, debug_level = 0;
int shift_flag;
GP_PixelType emul_type = GP_PIXEL_UNKNOWN;
-
+
struct loader_params params = {
.img_path = NULL,
@@ -730,21 +731,16 @@ int main(int argc, char *argv[])
GP_Fill(context, black_pixel);
GP_BackendFlip(backend);
- int argf = optind;
- int argn = argf;
+
+ struct image_list *list = image_list_create((const char**)argv + optind);
params.show_progress_once = 1;
- show_image(¶ms, argv[argf]);
+ show_image(¶ms, image_list_img_path(list));
for (;;) {
/* wait for event or a timeout */
- if (wait_for_event(sleep_sec * 1000)) {
- argn++;
- if (argn >= argc)
- argn = argf;
-
- show_image(¶ms, argv[argn]);
- }
+ if (wait_for_event(sleep_sec * 1000))
+ show_image(¶ms, image_list_move(list, 1));
/* Read and parse events */
GP_Event ev;
@@ -809,7 +805,7 @@ int main(int argc, char *argv[])
}
params.show_progress_once = 1;
- show_image(¶ms, argv[argn]);
+ show_image(¶ms, image_list_img_path(list));
break;
case GP_KEY_LEFT_BRACE:
if (params.resampling_method == 0)
@@ -826,13 +822,13 @@ int main(int argc, char *argv[])
}
params.show_progress_once = 1;
- show_image(¶ms, argv[argn]);
+ show_image(¶ms, image_list_img_path(list));
break;
case GP_KEY_L:
params.use_low_pass = !params.use_low_pass;
params.show_progress_once = 1;
- show_image(¶ms, argv[argn]);
+ show_image(¶ms, image_list_img_path(list));
break;
case GP_KEY_D:
image_cache_drop(params.img_resized_cache);
@@ -847,45 +843,26 @@ int main(int argc, char *argv[])
return 0;
break;
case GP_KEY_PAGE_UP:
- argn+=10;
- //TODO
- if (argn >= argc)
- argn = argf;
-
params.show_progress_once = 1;
- show_image(¶ms, argv[argn]);
+ show_image(¶ms, image_list_move(list, 10));
break;
case GP_KEY_PAGE_DOWN:
- argn-=10;
- //TODO
- if (argn < argf)
- argn = argc - 1 ;
-
params.show_progress_once = 1;
- show_image(¶ms, argv[argn]);
+ show_image(¶ms, image_list_move(list, -10));
break;
next:
case GP_KEY_RIGHT:
case GP_KEY_UP:
case GP_KEY_SPACE:
- argn++;
- if (argn >= argc)
- argn = argf;
-
params.show_progress_once = 1;
- show_image(¶ms, argv[argn]);
+ show_image(¶ms, image_list_move(list, 1));
break;
prev:
case GP_KEY_BACKSPACE:
case GP_KEY_LEFT:
case GP_KEY_DOWN:
- argn--;
-
- if (argn < argf)
- argn = argc - 1;
-
params.show_progress_once = 1;
- show_image(¶ms, argv[argn]);
+ show_image(¶ms, image_list_move(list, -1));
break;
case GP_KEY_1:
resize_backend(¶ms, 1, shift_flag);
http://repo.or.cz/w/gfxprim.git/commit/ddbd27fd085cc515d61fdae1a159922090eb…
commit ddbd27fd085cc515d61fdae1a159922090eb327b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Dec 20 13:16:51 2012 +0100
build: configure: The -lXext should be in LDFLAGS.
diff --git a/configure b/configure
index a13f914..db5733f 100755
--- a/configure
+++ b/configure
@@ -255,7 +255,7 @@ if __name__ == '__main__':
[header_exists, "X11/Xlib.h"], "", "-lX11", ["backends"]],
["X_SHM",
"MIT-SHM X Extension",
- [header_exists, "X11/extensions/XShm.h"], "-lXext", "", ["backends"]],
+ [header_exists, "X11/extensions/XShm.h"], "", "-lXext", ["backends"]],
["freetype",
"A high-quality and portable font engine",
[header_exists, "ft2build.h"], "", "`freetype-config --libs`", ["core"]],
-----------------------------------------------------------------------
Summary of changes:
configure | 2 +-
demos/spiv/Makefile | 2 +-
.../framework/tst_msg.c => demos/spiv/image_list.c | 122 +++++++++++---------
demos/spiv/{cpu_timer.h => image_list.h} | 30 +++---
demos/spiv/spiv.c | 53 +++------
5 files changed, 100 insertions(+), 109 deletions(-)
copy tests/framework/tst_msg.c => demos/spiv/image_list.c (53%)
copy demos/spiv/{cpu_timer.h => image_list.h} (77%)
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.")
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 3a66b0d92c78955b31e8b825f3b2049ffdf3487a (commit)
via 9176505d3276942f16192b028d57ca9571c81797 (commit)
from 57c57c59cd6ce43a4df21a9309cdbb7cd5e1bf16 (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/3a66b0d92c78955b31e8b825f3b2049ffdf3…
commit 3a66b0d92c78955b31e8b825f3b2049ffdf3487a
Merge: 9176505 57c57c5
Author: Jiri BlueBear Dluhos <jiri.bluebear.dluhos(a)gmail.com>
Date: Tue Dec 18 22:59:03 2012 +0100
Merge branch 'master' of ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/9176505d3276942f16192b028d57ca9571c8…
commit 9176505d3276942f16192b028d57ca9571c81797
Author: Jiri BlueBear Dluhos <jiri.bluebear.dluhos(a)gmail.com>
Date: Tue Dec 18 22:58:16 2012 +0100
First stab at analytic line clipping.
diff --git a/include/gfx/GP_LineClip.h b/include/gfx/GP_LineClip.h
new file mode 100644
index 0000000..32ad6af
--- /dev/null
+++ b/include/gfx/GP_LineClip.h
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+#ifndef GP_LINECLIP_H
+#define GP_LINECLIP_H
+
+int GP_LineClip(int *px0, int *py0, int *px1, int *py1, int xmax, int ymax);
+
+#endif
diff --git a/libs/gfx/GP_Line.gen.c.t b/libs/gfx/GP_Line.gen.c.t
index edc5382..668d89f 100644
--- a/libs/gfx/GP_Line.gen.c.t
+++ b/libs/gfx/GP_Line.gen.c.t
@@ -36,6 +36,7 @@
#include "gfx/GP_VLine.h"
#include "gfx/GP_HLine.h"
#include "gfx/GP_Line.h"
+#include "gfx/GP_LineClip.h"
/*
* The classical Bresenham line drawing algorithm.
@@ -48,6 +49,14 @@
void GP_Line_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int y0,
int x1, int y1, GP_Pixel pixval)
{
+ if (!GP_LineClip(&x0, &y0, &x1, &y1, context->w - 1, context->h - 1))
+ return;
+
+ GP_ASSERT(x0 >= 0 && x0 <= (int) context->w-1);
+ GP_ASSERT(x1 >= 0 && x1 <= (int) context->w-1);
+ GP_ASSERT(y0 >= 0 && y0 <= (int) context->h-1);
+ GP_ASSERT(y1 >= 0 && y1 <= (int) context->h-1);
+
/* special cases: vertical line, horizontal line, single point */
if (x0 == x1) {
if (y0 == y1) {
@@ -93,10 +102,10 @@ void GP_Line_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int y0,
for (x = x0; x <= x1; x++) {
if (steep)
- GP_PutPixel_Raw_Clipped_{{ ps.suffix }}(context, y, x,
+ GP_PutPixel_Raw_{{ ps.suffix }}(context, y, x,
pixval);
else
- GP_PutPixel_Raw_Clipped_{{ ps.suffix }}(context, x, y,
+ GP_PutPixel_Raw_{{ ps.suffix }}(context, x, y,
pixval);
error -= deltay;
diff --git a/libs/gfx/GP_LineClip.c b/libs/gfx/GP_LineClip.c
new file mode 100644
index 0000000..6a1f76e
--- /dev/null
+++ b/libs/gfx/GP_LineClip.c
@@ -0,0 +1,129 @@
+/*****************************************************************************
+ * 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-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include "core/GP_Common.h"
+#include "core/GP_Types.h"
+#include "gfx/GP_LineClip.h"
+
+int GP_LineClip(int *px0, int *py0, int *px1, int *py1, int xmax, int ymax)
+{
+ float x0 = (float) *px0;
+ float y0 = (float) *py0;
+ float x1 = (float) *px1;
+ float y1 = (float) *py1;
+
+ /* horizontal and vertical line are special cases */
+ if (y0 == y1) {
+
+ /* orient the line from left to right */
+ if (x1 < x0) {
+ GP_SWAP(x0, x1);
+ GP_SWAP(y0, y1);
+ }
+
+ /* check if it is not completely outside */
+ if (x1 < 0 || x0 > xmax || y0 < 0 || y0 > ymax)
+ return 0;
+
+ x0 = GP_MAX(x0, 0);
+ x1 = GP_MIN(x1, xmax);
+ goto give_result;
+ }
+ if (x0 == x1) {
+
+ /* orient the line from top to down */
+ if (x1 < x0) {
+ GP_SWAP(x0, x1);
+ GP_SWAP(y0, y1);
+ }
+
+ /* check if it is not completely outside */
+ if (y1 < 0 || y0 > ymax || x0 < 0 || x0 > xmax)
+ return 0;
+
+ /* clip it to the valid range */
+ y0 = GP_MAX(y0, 0);
+ y1 = GP_MIN(y1, ymax);
+ goto give_result;
+ }
+
+ /* orient the line from left to right */
+ if (x1 < x0) {
+ GP_SWAP(x0, x1);
+ GP_SWAP(y0, y1);
+ }
+
+ if (x1 < 0 || x0 > xmax || (y0 < 0 && y1 < 0) || (y0 > ymax && y1 > ymax)) {
+
+ /* the line lies completely outside the rectangle */
+ return 0;
+ }
+
+ float dx = (float)(x1 - x0);
+ float dy = (float)(y1 - y0);
+ float dyx = dy/dx;
+ float dxy = dx/dy;
+
+ /* clip the line against the left and right side of the rectangle */
+ if (x0 < 0) {
+ y0 = y0 - x0*dyx;
+ x0 = 0;
+ }
+ if (x1 > xmax) {
+ x1 = xmax;
+ y1 = y0 + (x1-x0)*dyx;
+ }
+
+ if (y0 < 0.0f) {
+ x0 = x0 - y0*dxy;
+ y0 = 0.0f;
+ } else if (y0 > ymax) {
+ x0 = x0 + (ymax-y0)*dxy;
+ y0 = ymax;
+ }
+
+ if (y1 < 0.0f) {
+ x1 = x1 - y1*dxy;
+ y1 = 0.0f;
+ }
+ else if (y1 > ymax) {
+ x1 = x1 - (y1 - ymax)*dxy;
+ y1 = ymax;
+ }
+
+ if (x0 < 0 || x0 > xmax || x1 < 0 || x1 > xmax) {
+
+ /* the line misses the clip rectangle around the corner */
+ return 0;
+ }
+
+give_result:
+
+ *px0 = (int) x0;
+ *py0 = (int) y0;
+ *px1 = (int) x1;
+ *py1 = (int) y1;
+ return 1;
+}
-----------------------------------------------------------------------
Summary of changes:
.../GP_TextStyle.c => include/gfx/GP_LineClip.h | 17 +--
libs/gfx/GP_Line.gen.c.t | 13 ++-
include/core/GP_Core.h => libs/gfx/GP_LineClip.c | 154 +++++++++++++-------
3 files changed, 120 insertions(+), 64 deletions(-)
copy libs/text/GP_TextStyle.c => include/gfx/GP_LineClip.h (85%)
copy include/core/GP_Core.h => libs/gfx/GP_LineClip.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.")
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 57c57c59cd6ce43a4df21a9309cdbb7cd5e1bf16 (commit)
via 78c4f27c1460b40d07c59ab79a5050601756cf40 (commit)
from 6339f5f64899ddc8158072a7354703eb71ef2e49 (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/57c57c59cd6ce43a4df21a9309cdbb7cd5e1…
commit 57c57c59cd6ce43a4df21a9309cdbb7cd5e1bf16
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Dec 18 19:20:58 2012 +0100
doc: backends: Update X11 API.
diff --git a/doc/backends.txt b/doc/backends.txt
index d760daf..5ee7e78 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -81,16 +81,27 @@ pixel type to match given surface).
For example usage see 'SDL' glue link:example_SDL_glue.html[example].
-X server
+X Server
~~~~~~~~
[source,c]
-------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <backends/GP_X11.h>
+
enum GP_BackendX11Flags {
- /*
- * When set, w and h is ignored and root window is used
- */
- GP_X11_USE_ROOT_WIN = 0x01,
+ /* When set, w and h is ignored and root window is used */
+ GP_X11_USE_ROOT_WIN = 0x01,
+
+ /* Create new borderless window above the root window */
+ GP_X11_CREATE_ROOT_WIN = 0x02,
+
+ /* Start fullscreen */
+ GP_X11_FULLSCREEN = 0x04,
+
+ /* Do not use MIT SHM even if available */
+ GP_X11_DISABLE_SHM = 0x08,
};
GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
@@ -106,8 +117,33 @@ time).
This backend feeds key events into global input queue.
-Note this is experimental version of X11 backend and will be changed to support
-more windows at a time.
+TODO: X11 backend will be changed to support more windows at a time.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <backends/GP_X11.h>
+
+/*
+ * Returns non-zero if backend is X11 backend
+ */
+int GP_BackendIsX11(GP_Backend *self);
+
+/*
+ * Changes full screen mode.
+ *
+ * 0 = off
+ * 1 = on
+ * 2 = toggle
+ */
+void GP_BackendX11RequestFullscreen(GP_Backend *self, int mode);
+-------------------------------------------------------------------------------
+
+The 'GP_BackendIsX11' functions allows us to detect if we are running using
+X11 backend.
+
+The 'GP_BackendX11RequestFullscreen' can toggle fullscreen mode at runtime.
Overall init function
~~~~~~~~~~~~~~~~~~~~~
http://repo.or.cz/w/gfxprim.git/commit/78c4f27c1460b40d07c59ab79a5050601756…
commit 78c4f27c1460b40d07c59ab79a5050601756cf40
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Dec 18 19:11:04 2012 +0100
doc: pixels: Add basic docs for pixel.
diff --git a/doc/Makefile b/doc/Makefile
index cc981fb..eef29cd 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -1,7 +1,7 @@
SOURCES=general.txt context.txt loaders.txt filters.txt basic_types.txt drawing_api.txt backends.txt gamma.txt grabbers.txt environment_variables.txt debug.txt core.txt api.txt input.txt - gen.txt
+ gen.txt pixels.txt
EXAMPLE_SOURCES=$(wildcard example_*.txt)
diff --git a/doc/api.txt b/doc/api.txt
index cee4d1a..69d460a 100644
--- a/doc/api.txt
+++ b/doc/api.txt
@@ -11,6 +11,10 @@ Cyril Hrubis <metan(a)ucw.cz>
+
Describes functions and macros in library core.
+
+. link:pixels.html[Pixel Types]
+ +
+ Describes pixel types.
+ +
. link:debug.html[Debug Messages]
+
Interface to debug layer.
diff --git a/doc/pixels.txt b/doc/pixels.txt
new file mode 100644
index 0000000..b226453
--- /dev/null
+++ b/doc/pixels.txt
@@ -0,0 +1,87 @@
+Pixel Description
+-----------------
+
+This pages describes library core functions for handling pixels.
+
+Pixel Type
+~~~~~~~~~~
+
+Pixels are described by a pixel type, which is enumeration type. The enum is
+defined at the generated 'GP_Pixel.gen.h' header and must contain at least
+following members:
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <core/GP_Pixel.h>
+
+typedef enum GP_PixelType {
+ GP_PIXEL_UNKNOWN,
+ GP_PIXEL_xRGB8888,
+ GP_PIXEL_RGBA8888,
+ GP_PIXEL_RGB888,
+ GP_PIXEL_BGR888,
+ GP_PIXEL_G1,
+ GP_PIXEL_G2,
+ GP_PIXEL_G4,
+ GP_PIXEL_G8,
+ GP_PIXEL_MAX,
+} GP_PixelType;
+
+-------------------------------------------------------------------------------
+
+Each pixel type has accompanying record in global array of pixel types
+declared as follows:
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <core/GP_Pixel.h>
+
+typedef struct {
+ char name[8]; /* Channel name */
+ uint8_t offset; /* Offset in bits */
+ uint8_t size; /* Bit-size */
+} GP_PixelTypeChannel;
+
+typedef struct {
+ GP_PixelType type; /* Number of the type */
+ const char name[16]; /* Name */
+ uint8_t size; /* Size in bits */
+ GP_BIT_ENDIAN bit_endian; /* Order of pixels in a byte */
+ uint8_t numchannels; /* Number of channels */
+ /* String describing the bit-representaton (as in "RRRRRGGGGGGBBBBB")*/
+ const char bitmap[GP_PIXEL_BITS + 1];
+ /* Individual channels */
+ const GP_PixelTypeChannel channels[GP_PIXELTYPE_MAX_CHANNELS];
+} GP_PixelTypeDescription;
+
+extern const GP_PixelTypeDescription const GP_PixelTypes[];
+
+const char *GP_PixelTypeName(GP_PixelType type);
+
+uint32_t GP_PixelSize(GP_PixelType type);
+-------------------------------------------------------------------------------
+
+There are also pixel matching functions that returns pixel type given RGB
+channel masks or sizes and offsets:
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <core/GP_Pixel.h>
+
+GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
+ GP_Pixel bmask, GP_Pixel amask,
+ uint8_t bits_per_pixel);
+
+GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff,
+ uint32_t gsize, uint32_t goff,
+ uint32_t bsize, uint32_t boff,
+ uint32_t asize, uint32_t aoff,
+ uint8_t bits_per_pixel);
+-------------------------------------------------------------------------------
+
-----------------------------------------------------------------------
Summary of changes:
doc/Makefile | 2 +-
doc/api.txt | 4 ++
doc/backends.txt | 50 ++++++++++++++++++++++++++----
doc/pixels.txt | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 135 insertions(+), 8 deletions(-)
create mode 100644 doc/pixels.txt
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.")
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 6339f5f64899ddc8158072a7354703eb71ef2e49 (commit)
from 15959b401d7f06790ed593ba0515b9502fce9502 (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/6339f5f64899ddc8158072a7354703eb71ef…
commit 6339f5f64899ddc8158072a7354703eb71ef2e49
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Dec 18 18:42:47 2012 +0100
doc: input: further fixes.
diff --git a/doc/input.txt b/doc/input.txt
index cdb7cc9..35ff473 100644
--- a/doc/input.txt
+++ b/doc/input.txt
@@ -53,7 +53,7 @@ typedef struct GP_Event {
} GP_Event;
-------------------------------------------------------------------------------
-The GP_Event structure is basic block that describes input event (i.e. key was
+The 'GP_Event' structure describes an input event (i.e. key was
pressed/released, mouse was moved, window was resized by user).
[source,c]
@@ -70,9 +70,9 @@ enum GP_EventType {
The event 'type' determines highlevel nature of the event.
* Key events covers keyboard button presses, mouse buttons, etc.
-* Relative events covers mostly mouse coordinates
+* Relative events covers mouse coordinates, mouse wheel, etc.
* Absolute events covers touchscreens and tablets
-* System events are used mostly for propagating window close and window
+* System events are used for propagating window close and window
resize events
* Values greater than 'GP_EV_MAX' are free for user events
@@ -137,16 +137,16 @@ struct GP_EventSys {
};
-------------------------------------------------------------------------------
-The event value is a union that could hold different information. The right
-format of the data is known from the 'type' and 'code'. For some types of the
-events it's not used at all.
+The event 'value' is a union that could hold different information. The right
+format of the data is known from the 'type' and 'code'. Some types of the
+events has no value at all.
* The relative coordinates are used for 'GP_EV_REL_POS' and absolute coordinates
for 'GP_EV_ABS_POS'.
* The key event value is used for keypresses, additionally it holds the key
value mapped to ASCII if conversion is applicable otherwise it's set to
- zero. You should consult the header 'input/GP_Event.h' for comprehensive
+ zero. You should consult the header 'input/GP_Event.h' for the comprehensive
list of key values.
* And finally the system event is used with 'GP_EV_SYS_RESIZE' and informs you
@@ -199,7 +199,7 @@ by ev pointer.
void GP_EventDump(struct GP_Event *ev);
-------------------------------------------------------------------------------
-Dumps event in human-readable format into the 'stdout'.
+The 'GP_EventDump' dumps event in human-readable format into the 'stdout'.
[source,c]
-------------------------------------------------------------------------------
@@ -215,8 +215,6 @@ void GP_EventSetScreenCursor(uint32_t x, uint32_t y);
Sets screen size and pointer position, which is needed for calculating the
'cursor_x' and 'cursor_y' coordinates.
-void GP_EventPushRel(int32_t rx, int32_t ry, struct timeval *time);
-
[source,c]
-------------------------------------------------------------------------------
#include <GP.h>
@@ -224,6 +222,12 @@ void GP_EventPushRel(int32_t rx, int32_t ry, struct timeval *time);
#include <input/GP_Event.h>
/*
+ * Pushes relative event.
+ */
+void GP_EventPushRel(int32_t rx, int32_t ry, struct timeval *time);
+
+
+/*
* Produces relative event that moves to the point x, y
*/
void GP_EventPushRelTo(uint32_t x, uint32_t y, struct timeval *time);
-----------------------------------------------------------------------
Summary of changes:
doc/input.txt | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 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.")
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 15959b401d7f06790ed593ba0515b9502fce9502 (commit)
from 4439632f9d4310733582659f9463f979de583b4a (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/15959b401d7f06790ed593ba0515b9502fce…
commit 15959b401d7f06790ed593ba0515b9502fce9502
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Dec 18 18:33:36 2012 +0100
doc: input: Clarify wording in few cases.
diff --git a/doc/input.txt b/doc/input.txt
index 6a85ebf..cdb7cc9 100644
--- a/doc/input.txt
+++ b/doc/input.txt
@@ -11,10 +11,11 @@ is created only together with graphics driver, this is the case for example
for X Window backends or SDL backends.
The basic structure is roughly modeled after Linux kernel input API. The main
-difference is that events that belongs together are delivered together. For
-example mouse coordinates are bundled in one event.
+difference is that events that belongs together are delivered together (the
+kernel input API sends one event for each value i.e. x or y coordinate and has
+sync event that finalizes the changes in the values).
-For example usage see backend link:example_input.html[example].
+For example usage see input events link:example_input.html[example].
Event Structure Description
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -156,12 +157,12 @@ The 'dev_id' is not used at the moment and may be removed.
The timeval structure 'time' holds time when the event was created (or
received by GFXprim input driver).
-The 'cursor_x' and 'cursor_y' holds pointer coodinates merged from all input
-sources.
+The 'cursor_x' and 'cursor_y' holds current pointer coodinates. (All relative
+and absolute events are mixed together to compute current cursor position.)
The 'key_pressed' is bitflag array of currently pressed keys which is useful
-for using keys as modificators. The array holds most of the standard keyboard
-keys and mouse buttons.
+for using keys as modificators. The array always holds state of the standard
+keyboard keys and mouse buttons.
Event API
~~~~~~~~~
-----------------------------------------------------------------------
Summary of changes:
doc/input.txt | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 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.")
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 5f214b37219110e2e9051b3bfffbbd65498002b7 (commit)
from 910d31f9711c5e518189c5e5f47761125ef06207 (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/5f214b37219110e2e9051b3bfffbbd654980…
commit 5f214b37219110e2e9051b3bfffbbd65498002b7
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Dec 18 14:33:22 2012 +0100
Grammar fix
diff --git a/doc/input.txt b/doc/input.txt
index 44da370..6a85ebf 100644
--- a/doc/input.txt
+++ b/doc/input.txt
@@ -38,7 +38,7 @@ typedef struct GP_Event {
struct timeval time;
/*
- * Cursor possition, possition on screen accumulated
+ * Cursor position, possition on screen accumulated
* from all pointer devices
*/
uint32_t cursor_x;
diff --git a/include/input/GP_Event.h b/include/input/GP_Event.h
index de5d93e..162a5d2 100644
--- a/include/input/GP_Event.h
+++ b/include/input/GP_Event.h
@@ -271,7 +271,7 @@ typedef struct GP_Event {
struct timeval time;
/*
- * Cursor possition, possition on screen accumulated
+ * Cursor position, position on screen accumulated
* from all pointer devices
*/
uint32_t cursor_x;
@@ -290,7 +290,7 @@ typedef struct GP_Event {
void GP_EventSetScreenSize(uint32_t w, uint32_t h);
/*
- * Sets global cursor possition, doesn't generate event.
+ * Sets global cursor position, doesn't generate an event.
*
* Use for initial cursor placement.
*/
diff --git a/include/loaders/GP_JPG.h b/include/loaders/GP_JPG.h
index 5906b11..5ee57ce 100644
--- a/include/loaders/GP_JPG.h
+++ b/include/loaders/GP_JPG.h
@@ -40,7 +40,7 @@
int GP_OpenJPG(const char *src_path, FILE **f);
/*
- * Reads JPG from an open FILE. Expects the file possition set after the eight
+ * Reads JPG from an open FILE. Expects the file position set after the eight
* bytes JPG signature.
*/
GP_Context *GP_ReadJPG(FILE *f, GP_ProgressCallback *callback);
diff --git a/include/loaders/GP_PNG.h b/include/loaders/GP_PNG.h
index 4b6e3bb..cbb4b70 100644
--- a/include/loaders/GP_PNG.h
+++ b/include/loaders/GP_PNG.h
@@ -47,13 +47,13 @@
/*
* Opens up file and checks signature. Upon successful return (zero is
- * returned) the file possition would be set to eight bytes (exactly after the
+ * returned) the file position would be set to eight bytes (exactly after the
* PNG signature).
*/
int GP_OpenPNG(const char *src_path, FILE **f);
/*
- * Reads PNG from an open FILE. Expects the file possition set after the eight
+ * Reads PNG from an open FILE. Expects the file position set after the eight
* bytes PNG signature.
*
* Upon succesfull return pointer to newly allocated context is returned.
diff --git a/libs/input/GP_Event.c b/libs/input/GP_Event.c
index cb66c4f..efd82c9 100644
--- a/libs/input/GP_Event.c
+++ b/libs/input/GP_Event.c
@@ -29,7 +29,7 @@
#include "GP_Event.h"
-/* Screen size for clipping the cursor possition */
+/* Screen size for clipping the cursor position */
static uint32_t screen_w = 0, screen_h = 0;
/* Event queue */
diff --git a/libs/loaders/GP_PNM.h b/libs/loaders/GP_PNM.h
index af59319..2ce48a3 100644
--- a/libs/loaders/GP_PNM.h
+++ b/libs/loaders/GP_PNM.h
@@ -32,7 +32,7 @@
#include <stdint.h>
/*
- * Loads image header, returns pointer to FILE* (with file possition pointing
+ * Loads image header, returns pointer to FILE* (with file position pointing
* to the start of the data stream) on success, fills image metadata into
* arguments.
*/
-----------------------------------------------------------------------
Summary of changes:
doc/input.txt | 2 +-
include/input/GP_Event.h | 4 ++--
include/loaders/GP_JPG.h | 2 +-
include/loaders/GP_PNG.h | 4 ++--
libs/input/GP_Event.c | 2 +-
libs/loaders/GP_PNM.h | 2 +-
6 files changed, 8 insertions(+), 8 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.")