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: df87777210da0ea03b70f5d8cf138050a5399e05
by metan 27 Dec '12
by metan 27 Dec '12
27 Dec '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 df87777210da0ea03b70f5d8cf138050a5399e05 (commit)
from 57673b3b830b3d6434956c656d0cec95156314cc (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/df87777210da0ea03b70f5d8cf138050a539…
commit df87777210da0ea03b70f5d8cf138050a5399e05
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Dec 27 01:38:23 2012 +0100
demos: c_simple: Update backend example.
diff --git a/demos/c_simple/backend_example.c b/demos/c_simple/backend_example.c
index 063da75..3d565ef 100644
--- a/demos/c_simple/backend_example.c
+++ b/demos/c_simple/backend_example.c
@@ -71,10 +71,8 @@ int main(int argc, char *argv[])
GP_BackendFlip(backend);
for (;;) {
- if (backend->Poll)
- GP_BackendPoll(backend);
-
- usleep(1000);
+ /* Wait for backend event */
+ GP_BackendWait(backend);
/* Read and parse events */
GP_Event ev;
@@ -85,13 +83,20 @@ int main(int argc, char *argv[])
switch (ev.type) {
case GP_EV_KEY:
- switch (ev.val.key.key) {
+ switch (ev.val.val) {
case GP_KEY_ESC:
case GP_KEY_Q:
GP_BackendExit(backend);
return 0;
break;
}
+ break;
+ case GP_EV_SYS:
+ case GP_EV_SYS_QUIT:
+ GP_BackendExit(backend);
+ return 0;
+ break;
+ break;
}
}
}
-----------------------------------------------------------------------
Summary of changes:
demos/c_simple/backend_example.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 57673b3b830b3d6434956c656d0cec95156314cc
by metan 27 Dec '12
by metan 27 Dec '12
27 Dec '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 57673b3b830b3d6434956c656d0cec95156314cc (commit)
from 8728ce4ba9c41b1ae214808623111c5c869f31ad (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/57673b3b830b3d6434956c656d0cec951563…
commit 57673b3b830b3d6434956c656d0cec95156314cc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Dec 27 01:08:39 2012 +0100
doc: Add word about coordinate system.
diff --git a/doc/Makefile b/doc/Makefile
index 7bda21b..35c23aa 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 pixels.txt
+ gen.txt pixels.txt coordinate_system.txt
EXAMPLE_SOURCES=$(wildcard example_*.txt)
diff --git a/doc/api.txt b/doc/api.txt
index 69d460a..a03d282 100644
--- a/doc/api.txt
+++ b/doc/api.txt
@@ -1,12 +1,19 @@
-GFXprim API
-===========
+GFXprim Documentation
+=====================
Cyril Hrubis <metan(a)ucw.cz>
+GFXprim API
+-----------
+
. link:basic_types.html[Basic library types]
+
Describes how colors and pixels are handled also describes progress callback
in great detail.
+
+. link:coordinate_system.html[Coordinate system]
+ +
+ Describes briefly coordinate system and relation to pixels.
+ +
. link:core.html[Library Core overview]
+
Describes functions and macros in library core.
@@ -62,5 +69,14 @@ Cyril Hrubis <metan(a)ucw.cz>
+
Video grabbers interface such as V4L2.
+
-
+
+GFXprim Internals
+-----------------
+
+. link:gen.html[Templating engine]
+ +
+ Describes structure and basic usage of the templating engine (C code
+ generator).
+ +
+
There is also a nice page with code link:examples.html[examples].
diff --git a/doc/basic_types.txt b/doc/basic_types.txt
index 1542083..2d9b342 100644
--- a/doc/basic_types.txt
+++ b/doc/basic_types.txt
@@ -1,7 +1,7 @@
Basic types
-----------
-Coordinates and Size/Length
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Coordinates and Size and Length
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Most of the drawing functions use typedefed 'GP_Coord' and 'GP_Size' integer
types for parameters.
diff --git a/doc/coordinate_system.txt b/doc/coordinate_system.txt
new file mode 100644
index 0000000..fb3f408
--- /dev/null
+++ b/doc/coordinate_system.txt
@@ -0,0 +1,11 @@
+Coordinate System
+-----------------
+
+GFXprim uses Cartesian coordinate system. The pixel +(0, 0)+ lies at the upper
+left corner of the bitmap and coordinates grows to the right and to the
+bottom. The last valid pixel, that still lies in the bitmap of size +w+ and
++h+, occupies coordinates +(w - 1, h - 1)+. The precise position of the point
+with integer coordinates is in the middle of the pixel (and borders between
+the pixels lies are integers + 0.5).
+
+image:coordinates-1.svg[Coordinate System]
diff --git a/doc/coordinates-1.svg b/doc/coordinates-1.svg
new file mode 100644
index 0000000..841444d
--- /dev/null
+++ b/doc/coordinates-1.svg
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ width="546.91302"
+ height="426.914"
+ id="svg2"
+ xml:space="preserve"><metadata
+ id="metadata8"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
+ id="defs6"><clipPath
+ id="clipPath18"><path
+ d="m 0,0 437.5304,0 0,341.5312 L 0,341.5312 0,0 z"
+ inkscape:connector-curvature="0"
+ id="path20" /></clipPath></defs><g
+ transform="matrix(1.25,0,0,-1.25,0,426.914)"
+ id="g10"><g
+ id="g12"><g
+ id="g14"><g
+ clip-path="url(#clipPath18)"
+ id="g16"><g
+ transform="translate(0,341.5312)"
+ id="g22"><g
+ transform="translate(3.5304,-339.5312)"
+ id="g24"><path
+ d="M 0,0 432,0"
+ inkscape:connector-curvature="0"
+ id="path26"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 0,48 432,0"
+ inkscape:connector-curvature="0"
+ id="path28"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 0,96 432,0"
+ inkscape:connector-curvature="0"
+ id="path30"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 0,144 432,0"
+ inkscape:connector-curvature="0"
+ id="path32"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 0,192 432,0"
+ inkscape:connector-curvature="0"
+ id="path34"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 0,240 432,0"
+ inkscape:connector-curvature="0"
+ id="path36"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 0,288 432,0"
+ inkscape:connector-curvature="0"
+ id="path38"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 0,336 432,0"
+ inkscape:connector-curvature="0"
+ id="path40"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="M 0,0 0,336"
+ inkscape:connector-curvature="0"
+ id="path42"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 48,0 0,336"
+ inkscape:connector-curvature="0"
+ id="path44"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 96,0 0,336"
+ inkscape:connector-curvature="0"
+ id="path46"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 144,0 0,336"
+ inkscape:connector-curvature="0"
+ id="path48"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 192,0 0,336"
+ inkscape:connector-curvature="0"
+ id="path50"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 240,0 0,336"
+ inkscape:connector-curvature="0"
+ id="path52"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 288,0 0,336"
+ inkscape:connector-curvature="0"
+ id="path54"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 336,0 0,336"
+ inkscape:connector-curvature="0"
+ id="path56"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 384,0 0,336"
+ inkscape:connector-curvature="0"
+ id="path58"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 432,0 0,336"
+ inkscape:connector-curvature="0"
+ id="path60"
+ style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="M 0,336 0,0"
+ inkscape:connector-curvature="0"
+ id="path62"
+ style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="M -1.5304,3.6946 0,0 l 1.5304,3.6946 -3.0608,0 z"
+ inkscape:connector-curvature="0"
+ id="path64"
+ style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="M 0,0 432,0"
+ inkscape:connector-curvature="0"
+ id="path66"
+ style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 432,0 0,336"
+ inkscape:connector-curvature="0"
+ id="path68"
+ style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 0,336 432,0"
+ inkscape:connector-curvature="0"
+ id="path70"
+ style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="M 428.30338,334.46877 432,336 l -3.69662,1.53123 0,-3.06246 z"
+ inkscape:connector-curvature="0"
+ id="path72"
+ style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><g
+ transform="translate(0,341.5312)"
+ id="g74"><text
+ transform="matrix(1,0,0,-1,12.1001,-24.0405)"
+ id="text76"><tspan
+ x="0 3.8744552 8.8557549 14.940911 19.922211"
+ y="0"
+ id="tspan78"
+ style="font-size:9.96259975px;font-variant:normal;font-weight:normal;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;font-family:CMR10;-inkscape-font-specification:CMR10">(0,0)</tspan></text>
+<g
+ transform="translate(0,-341.5312)"
+ id="g80"><path
+ d="m 24,312 0,0"
+ inkscape:connector-curvature="0"
+ id="path82"
+ style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><g
+ transform="translate(0,341.5312)"
+ id="g84"><text
+ transform="matrix(1,0,0,-1,386.4142,-312.0405)"
+ id="text86"><tspan
+ x="0 3.8744552 11.069445 14.389979 19.371279 25.456436 30.991655 34.312191 39.293491"
+ y="0"
+ id="tspan88"
+ style="font-size:9.96259975px;font-variant:normal;font-weight:normal;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;font-family:CMR10;-inkscape-font-specification:CMR10">(w-1,h-1)</tspan></text>
+<g
+ transform="translate(0,-341.5312)"
+ id="g90"><path
+ d="m 408,24 0,0"
+ inkscape:connector-curvature="0"
+ id="path92"
+ style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><g
+ transform="translate(0,341.5312)"
+ id="g94"><text
+ transform="matrix(1,0,0,-1,98.1,-120.9405)"
+ id="text96"><tspan
+ x="0 3.8744552 8.8557549 11.623365 16.604666 22.689821 27.671122"
+ y="0"
+ id="tspan98"
+ style="font-size:9.96259975px;font-variant:normal;font-weight:normal;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;font-family:CMR10;-inkscape-font-specification:CMR10">(1.5,2)</tspan></text>
+<g
+ transform="translate(0,-341.5312)"
+ id="g100"><path
+ d="m 96,216 0,0"
+ inkscape:connector-curvature="0"
+ id="path102"
+ style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none" /><g
+ transform="translate(0,341.5312)"
+ id="g104" /></g></g></g></g></g></g></g></g></g></g></g></g></svg>
No newline at end of file
diff --git a/doc/coordinates.mp b/doc/coordinates.mp
new file mode 100644
index 0000000..404ff70
--- /dev/null
+++ b/doc/coordinates.mp
@@ -0,0 +1,40 @@
+%
+% Compile to svg by:
+%
+% mptopdf coordinates.mp; inkscape -l coordinates-1.svg coordinates-1.pdf
+%
+beginfig(1)
+ % Draw grid
+ u := 48;
+ w := 9;
+ h := 7;
+
+ for i=0 upto h:
+ draw (0, i * u) -- (w * u, i * u);
+ endfor
+
+ for i=0 upto w:
+ draw (i * u, 0) -- (i * u, h * u);
+ endfor
+
+ % Draw frame
+ pair A, B, C, D;
+
+ A = (0, 0);
+ B = (w * u, 0);
+ C = (w * u, h * u);
+ D = (0, h * u);
+
+ drawarrow D -- A withpen pencircle scaled 4;
+ draw A -- B withpen pencircle scaled 2;
+ draw B -- C withpen pencircle scaled 2;
+ drawarrow D -- C withpen pencircle scaled 4;
+
+ % Draw labels
+ dotlabel.top(btex (0, 0) etex, (u/2, h * u - u/2));
+ dotlabel.top(btex (w-1, h-1) etex, (w * u - u/2, u/2));
+
+ dotlabel.urt(btex (1.5, 2) etex, (2 * u, h * u - 2 * u - u/2));
+
+endfig;
+end
diff --git a/doc/drawing_api.txt b/doc/drawing_api.txt
index 0304138..e2e50db 100644
--- a/doc/drawing_api.txt
+++ b/doc/drawing_api.txt
@@ -1,6 +1,8 @@
Drawing primitives
------------------
+NOTE: You may want to see the link:coordinate_system.html[coordinate system] first.
+
Fill
~~~~
-----------------------------------------------------------------------
Summary of changes:
doc/Makefile | 2 +-
doc/api.txt | 22 +++++-
doc/basic_types.txt | 4 +-
doc/coordinate_system.txt | 11 +++
doc/coordinates-1.svg | 176 +++++++++++++++++++++++++++++++++++++++++++++
doc/coordinates.mp | 40 ++++++++++
doc/drawing_api.txt | 2 +
7 files changed, 251 insertions(+), 6 deletions(-)
create mode 100644 doc/coordinate_system.txt
create mode 100644 doc/coordinates-1.svg
create mode 100644 doc/coordinates.mp
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: 8728ce4ba9c41b1ae214808623111c5c869f31ad
by metan 26 Dec '12
by metan 26 Dec '12
26 Dec '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 8728ce4ba9c41b1ae214808623111c5c869f31ad (commit)
via 95609738c5d91412e53a1fadc18ed6200825ce1d (commit)
via 43664f1f57cd6092e77765fa72234cf92d4ad074 (commit)
via 082e5eed64755a0130dafab53ef3b5252ce745e6 (commit)
from 0d714fd8292c2805d3cdc23d89345d41c9f23815 (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/8728ce4ba9c41b1ae214808623111c5c869f…
commit 8728ce4ba9c41b1ae214808623111c5c869f31ad
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Dec 26 21:12:36 2012 +0100
core: Prepare for correct WritePixels implementation.
* The Write Pixels header is correctly generated now
* C sources are generated for Write Pixels functions
that are not written by hand (currently the body is
empty)
* The Write Pixels for 1BPP, 2BPP and 4BPP are now
all correct and fast (hopefully)
TODO: Generated Write Pixels, tests
diff --git a/include/core/GP_WritePixel.gen.h.t b/include/core/GP_WritePixel.gen.h.t
new file mode 100644
index 0000000..91237bc
--- /dev/null
+++ b/include/core/GP_WritePixel.gen.h.t
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+%% extends 'base.h.t'
+
+{% block description %}Write Pixels generated header{% endblock %}
+
+{% block body %}
+
+/*
+ * These functions writes cnt pixels using value val starting at start address
+ * and additionally (for pixel sizes that are not aligned to the whole bytes)
+ * at off offset in the first byte (i.e. byte at the start address).
+ */
+
+%% for ps in pixelsizes
+%% if ps.needs_bit_endian()
+void GP_WritePixels_{{ ps.suffix }}(void *start, uint8_t off,
+ size_t cnt, unsigned int val);
+
+%% else
+void GP_WritePixels_{{ ps.suffix }}(void *start, size_t cnt, unsigned int val);
+
+%% endif
+%% endfor
+
+{% endblock body %}
diff --git a/include/core/GP_WritePixel.h b/include/core/GP_WritePixel.h
index bb79b1f..b5005ec 100644
--- a/include/core/GP_WritePixel.h
+++ b/include/core/GP_WritePixel.h
@@ -26,51 +26,9 @@
#ifndef CORE_GP_WRITEPIXEL_H
#define CORE_GP_WRITEPIXEL_H
+#include <stddef.h>
#include <stdint.h>
-#include <unistd.h>
-/*
- * Writes cnt pixels starting at offset off.
- */
-void GP_WritePixels_1BPP_LE(uint8_t *start, uint8_t off,
- size_t cnt, uint8_t val);
-
-/*
- * Writes cnt pixels starting at offset off (offset is in pixel sizes not in
- * bits).
- */
-void GP_WritePixels_2BPP_LE(uint8_t *start, uint8_t off,
- size_t cnt, uint8_t val);
-
-/*
- * Writes cnt pixels starting at offset off (offset is in pixel sizes not in
- * bits i.e. offset could be either 0 or 1).
- */
-void GP_WritePixels_4BPP_LE(uint8_t *start, uint8_t off,
- size_t cnt, uint8_t val);
-
-/*
- * These calls are not byte aligned, thus need start offset.
- */
-void GP_WritePixels_1BPP_BE(uint8_t *start, uint8_t off,
- size_t cnt, uint8_t val);
-
-void GP_WritePixels_2BPP_BE(uint8_t *start, uint8_t off,
- size_t cnt, uint8_t val);
-
-void GP_WritePixels_4BPP_BE(uint8_t *start, uint8_t off,
- size_t cnt, uint8_t val);
-
-void GP_WritePixels_18BPP_BE(void *start, uint8_t off,
- size_t count, uint32_t value);
-
-void GP_WritePixels_18BPP_LE(void *start, uint8_t off,
- size_t count, uint32_t value);
-
-/* Byte-aligned calls. */
-void GP_WritePixels_8BPP(void *start, size_t count, uint8_t value);
-void GP_WritePixels_16BPP(void *start, size_t count, uint16_t value);
-void GP_WritePixels_24BPP(void *start, size_t count, uint32_t value);
-void GP_WritePixels_32BPP(void *start, size_t count, uint32_t value);
+#include "core/GP_WritePixel.gen.h"
#endif /* CORE_GP_WRITEPIXEL_H */
diff --git a/include/core/Makefile b/include/core/Makefile
index 5606d74..0dac795 100644
--- a/include/core/Makefile
+++ b/include/core/Makefile
@@ -4,7 +4,8 @@ include $(TOPDIR)/pre.mk
GENHEADERS=GP_Convert_Scale.gen.h GP_Pixel.gen.h GP_GetPutPixel.gen.h GP_Convert.gen.h GP_FnPerBpp.gen.h - GP_MixPixels.gen.h GP_GammaCorrection.gen.h GP_GammaPixel.gen.h
+ GP_MixPixels.gen.h GP_GammaCorrection.gen.h GP_GammaPixel.gen.h + GP_WritePixel.gen.h
include $(TOPDIR)/gen.mk
include $(TOPDIR)/post.mk
diff --git a/libs/core/GP_WritePixel.c b/libs/core/GP_WritePixel.c
index a6829b0..916f9ef 100644
--- a/libs/core/GP_WritePixel.c
+++ b/libs/core/GP_WritePixel.c
@@ -30,8 +30,8 @@
static const uint8_t bytes_1BPP[] = {0x00, 0xff};
-void GP_WritePixels_1BPP_LE(uint8_t *start, uint8_t off,
- size_t cnt, uint8_t val)
+void GP_WritePixels_1BPP_LE(void *start, uint8_t off,
+ size_t cnt, unsigned int val)
{
int len = cnt;
@@ -104,10 +104,84 @@ void GP_WritePixels_1BPP_LE(uint8_t *start, uint8_t off,
}
}
+void GP_WritePixels_1BPP_BE(void *start, uint8_t off,
+ size_t cnt, unsigned int val)
+{
+ int len = cnt;
+
+ /* Write start of the line */
+ switch (off) {
+ case 0:
+ break;
+ case 1:
+ GP_SET_BITS1_ALIGNED(6, 1, start, val);
+
+ if (--len == 0)
+ return;
+ case 2:
+ GP_SET_BITS1_ALIGNED(5, 1, start, val);
+
+ if (--len == 0)
+ return;
+ case 3:
+ GP_SET_BITS1_ALIGNED(4, 1, start, val);
+
+ if (--len == 0)
+ return;
+ case 4:
+ GP_SET_BITS1_ALIGNED(3, 1, start, val);
+
+ if (--len == 0)
+ return;
+ case 5:
+ GP_SET_BITS1_ALIGNED(2, 1, start, val);
+
+ if (--len == 0)
+ return;
+ case 6:
+ GP_SET_BITS1_ALIGNED(1, 1, start, val);
+
+ if (--len == 0)
+ return;
+ case 7:
+ GP_SET_BITS1_ALIGNED(0, 1, start, val);
+
+ if (--len == 0)
+ return;
+
+ start++;
+ break;
+ }
+
+ /* Write as many bytes as possible */
+ memset(start, bytes_1BPP[val & 0x01], len/8);
+
+ start+=len/8;
+
+ /* And the rest */
+ switch (len%8) {
+ case 7:
+ GP_SET_BITS1_ALIGNED(1, 1, start, val);
+ case 6:
+ GP_SET_BITS1_ALIGNED(2, 1, start, val);
+ case 5:
+ GP_SET_BITS1_ALIGNED(3, 1, start, val);
+ case 4:
+ GP_SET_BITS1_ALIGNED(4, 1, start, val);
+ case 3:
+ GP_SET_BITS1_ALIGNED(5, 1, start, val);
+ case 2:
+ GP_SET_BITS1_ALIGNED(6, 1, start, val);
+ case 1:
+ GP_SET_BITS1_ALIGNED(7, 1, start, val);
+ break;
+ }
+}
+
static const uint8_t bytes_2BPP[] = {0x00, 0x55, 0xaa, 0xff};
-void GP_WritePixels_2BPP_LE(uint8_t *start, uint8_t off,
- size_t cnt, uint8_t val)
+void GP_WritePixels_2BPP_LE(void *start, uint8_t off,
+ size_t cnt, unsigned int val)
{
int len = cnt;
@@ -152,13 +226,59 @@ void GP_WritePixels_2BPP_LE(uint8_t *start, uint8_t off,
}
}
+void GP_WritePixels_2BPP_BE(void *start, uint8_t off,
+ size_t cnt, unsigned int val)
+{
+ int len = cnt;
+
+ /* Write start of the line */
+ switch (off) {
+ case 0:
+ break;
+ case 1:
+ GP_SET_BITS1_ALIGNED(6, 2, start, val);
+
+ if (--len == 0)
+ return;
+ case 2:
+ GP_SET_BITS1_ALIGNED(4, 2, start, val);
+
+ if (--len == 0)
+ return;
+ case 3:
+ GP_SET_BITS1_ALIGNED(2, 2, start, val);
+
+ if (--len == 0)
+ return;
+
+ start++;
+ break;
+ }
+
+ /* Write as many bytes as possible */
+ memset(start, bytes_2BPP[val & 0x03], len/4);
+
+ start+=len/4;
+
+ /* And the rest */
+ switch (len%4) {
+ case 3:
+ GP_SET_BITS1_ALIGNED(0, 2, start, val);
+ case 2:
+ GP_SET_BITS1_ALIGNED(2, 2, start, val);
+ case 1:
+ GP_SET_BITS1_ALIGNED(4, 2, start, val);
+ break;
+ }
+}
+
static const uint8_t bytes_4BPP[] = {
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
};
-void GP_WritePixels_4BPP_LE(uint8_t *start, uint8_t off,
- size_t cnt, uint8_t val)
+void GP_WritePixels_4BPP_LE(void *start, uint8_t off,
+ size_t cnt, unsigned int val)
{
int len = cnt;
@@ -189,116 +309,45 @@ void GP_WritePixels_4BPP_LE(uint8_t *start, uint8_t off,
}
}
-static const uint8_t chunks_1bpp[8] = {
- 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe,
-};
-
-void GP_WritePixels_1BPP_BE(uint8_t *start, uint8_t off, size_t cnt, uint8_t val)
-{
- uint8_t s_off = off % 8;
- uint8_t e_off = (cnt + s_off) % 8;
- uint32_t len = (cnt + s_off) / 8;
- uint8_t col = val ? 0xff : 0x00;
-
- /* handle special cases */
- if (cnt < 8) {
- uint8_t u_chunk = chunks_1bpp[cnt] >> off;
- uint8_t l_chunk = chunks_1bpp[cnt] << (8 - off);
-
- if (val) {
- start[0] |= u_chunk;
- start[1] |= l_chunk;
- } else {
- start[0] &= ~u_chunk;
- start[1] &= ~l_chunk;
- }
-
- return;
- }
-
- /* write len - 2 bytes */
- if (len > 1)
- GP_WritePixels_8BPP(start + 1, len - 2, col);
-
- /* deal with the start and end */
- if (val) {
- start[0] |= ~chunks_1bpp[s_off];
- start[len] |= chunks_1bpp[e_off];
- } else {
- start[0] &= chunks_1bpp[s_off];
- start[len] &= ~chunks_1bpp[e_off];
- }
-}
-
-static const uint8_t colors_2bpp[4] = {
- 0x00, 0x55, 0xaa, 0xff
-};
-
-#define PUT_PIXEL_2BPP(p, off, pix) *(p) = (*(p) & ~(0xc0>>(off))) | (pix<<(6 - off))
-
-void GP_WritePixels_2BPP_BE(uint8_t *start, uint8_t off, size_t cnt, uint8_t val)
+void GP_WritePixels_4BPP_BE(void *start, uint8_t off,
+ size_t cnt, unsigned int val)
{
- uint8_t s_off = off % 4;
- uint8_t e_off = 2 * ((cnt + s_off) % 4);
- uint8_t len = (cnt + s_off) / 4;
-
- s_off *= 2;
- val %= 4;
-
- /* handle special cases */
- if (cnt < 4) {
- uint8_t len = s_off + 2*cnt;
- uint8_t max = GP_MIN(s_off + 2*cnt, 8u);
+ int len = cnt;
- for (off = s_off; off < max; off+=2)
- PUT_PIXEL_2BPP(start, off, val);
+ /* Write start of the line */
+ switch (off) {
+ case 0:
+ break;
+ case 1:
+ GP_SET_BITS1_ALIGNED(0, 4, start, val);
- if (len <= 8)
+ if (--len == 0)
return;
- for (off = 0; off < len%8; off+=2)
- PUT_PIXEL_2BPP(start+1, off, val);
-
- return;
+ start++;
+ break;
}
- /* write len - 2 bytes */
- if (len > 1)
- GP_WritePixels_8BPP(start + 1, len - 2, colors_2bpp[val]);
-
- /* handle start and end */
- start[0] = (start[0] & (0xff << (8 - s_off))) |
- (colors_2bpp[val] >> s_off);
-
- start[len] = (start[len] & (0xff >> e_off)) |
- (colors_2bpp[val] << (8 - e_off));
-}
-
-
-void GP_WritePixels_4BPP_BE(uint8_t *start, uint8_t off, size_t cnt, uint8_t val)
-{
- uint8_t s_off = off % 2;
- uint8_t e_off = (cnt + s_off) % 2;
- uint32_t len = (cnt - s_off - e_off) / 2;
-
- val %= 16;
- uint8_t col = (val << 4)& val;
+ /* Write as many bytes as possible */
+ memset(start, bytes_4BPP[val & 0x0f], len/2);
- if (len > 0)
- GP_WritePixels_8BPP(start + s_off, len, val);
+ start+=len/2;
- /* handle start and end */
- if (s_off) GP_SET_BITS(4, 4, start[0], col);
- if (e_off) GP_SET_BITS(0, 4, start[len+s_off], val);
+ /* And the rest */
+ switch (len%2) {
+ case 1:
+ GP_SET_BITS1_ALIGNED(4, 4, start, val);
+ break;
+ }
}
-void GP_WritePixels_8BPP(void *start, size_t count, uint8_t value)
+void GP_WritePixels_8BPP(void *start, size_t count, unsigned int value)
{
memset(start, value, count);
}
-void GP_WritePixels_16BPP(void *start, size_t count, uint16_t value)
+void GP_WritePixels_16BPP(void *start, size_t count, unsigned int value)
{
uint16_t *p = (uint16_t *) start;
size_t i;
@@ -323,17 +372,7 @@ void GP_WritePixels_16BPP(void *start, size_t count, uint16_t value)
}
}
-void GP_WritePixels_18BPP_LE(void *start, uint8_t off, size_t count, uint32_t value)
-{
- #warning TODO
-}
-
-void GP_WritePixels_18BPP_BE(void *start, uint8_t off, size_t count, uint32_t value)
-{
- #warning TODO
-}
-
-void GP_WritePixels_24BPP(void *start, size_t count, uint32_t value)
+void GP_WritePixels_24BPP(void *start, size_t count, unsigned int value)
{
uint8_t *bytep = (uint8_t *) start;
@@ -453,7 +492,7 @@ void GP_WritePixels_24BPP(void *start, size_t count, uint32_t value)
}
}
-void GP_WritePixels_32BPP(void *start, size_t count, uint32_t value)
+void GP_WritePixels_32BPP(void *start, size_t count, unsigned int value)
{
/*
* Inspired by GNU libc's wmemset() (by Ulrich Drepper, licensed under LGPL).
diff --git a/libs/core/GP_WritePixel.gen.c.t b/libs/core/GP_WritePixel.gen.c.t
new file mode 100644
index 0000000..2bc89b3
--- /dev/null
+++ b/libs/core/GP_WritePixel.gen.c.t
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+%% extends 'base.h.t'
+
+{% block description %}Write pixel{% endblock %}
+
+{% block body %}
+
+#include "core/GP_GetSetBits.h"
+#include "core/GP_GetPutPixel.h"
+#include "core/GP_WritePixel.gen.h"
+
+{# Some pixel types has hand written optimized functions #}
+%% set hand_optimized = ['1BPP_LE', '1BPP_BE',
+ '2BPP_LE', '2BPP_BE',
+ '4BPP_LE', '4BPP_BE',
+ '8BPP', '16BPP',
+ '24BPP', '32BPP']
+
+%% for ps in pixelsizes
+%% if ps.suffix not in hand_optimized
+%% if ps.needs_bit_endian()
+void GP_WritePixels_{{ ps.suffix }}(void *start, uint8_t off,
+ size_t cnt, unsigned int val)
+{
+ //TODO:
+}
+%% else
+void GP_WritePixels_{{ ps.suffix }}(void *start, size_t cnt, unsigned int val)
+{
+ //TODO:
+}
+%% endif
+
+%% endif
+%% endfor
+
+{% endblock body %}
diff --git a/libs/core/Makefile b/libs/core/Makefile
index cd08e30..46a46d3 100644
--- a/libs/core/Makefile
+++ b/libs/core/Makefile
@@ -2,7 +2,8 @@ TOPDIR=../..
include $(TOPDIR)/pre.mk
GENSOURCES=GP_Pixel.gen.c GP_Blit.gen.c GP_Convert.gen.c - GP_GammaCorrection.gen.c
+ GP_GammaCorrection.gen.c GP_WritePixel.gen.c
+
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
LIBNAME=core
http://repo.or.cz/w/gfxprim.git/commit/95609738c5d91412e53a1fadc18ed6200825…
commit 95609738c5d91412e53a1fadc18ed6200825ce1d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Dec 26 21:02:59 2012 +0100
doc: gen: Add quick jinja2 help.
diff --git a/doc/gen.txt b/doc/gen.txt
index 73e9e15..830a0d4 100644
--- a/doc/gen.txt
+++ b/doc/gen.txt
@@ -210,3 +210,27 @@ And most importantly objects generated from the configuration files:
* 'pixelsizes' list of all pixel size objects
* 'pixeltypes' list of all pixel type objects
+
+Quick Syntax Help
+^^^^^^^^^^^^^^^^^
+
+Jinja2 basics:
+
+- Each written line is reproduces as it is unless it contains template
+ 'variable' or 'expression'
+
+- 'Variable' is text enclosed between +{{+ and +}}+
+ * +{{ ps.size }}' or +{{ ps.suffix }}+
+ * +{{ 2 ** i }}+
+ * +{{ int(2 ** (7 - i)) }} >> {{ 8 - i }}+
+
+- 'Expression' is either line that starts with +%%+ or a text enclosed between
+ +{%+ and +%}+
+ * +%% for ps in pixel_size+
+ * +%% endfor+
+ * +{% if ps.needs_bit_endian() %} ... {% endif %}+
+
+- Comments are enclosed in +{#+ and +#}+
+
+More complete documentation could be found in
+http://jinja.pocoo.org/docs/templates/[Jinja official documentation]
http://repo.or.cz/w/gfxprim.git/commit/43664f1f57cd6092e77765fa72234cf92d4a…
commit 43664f1f57cd6092e77765fa72234cf92d4ad074
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Dec 26 20:20:59 2012 +0100
doc: gen: Add needs_bit_endian() function.
diff --git a/doc/gen.txt b/doc/gen.txt
index 1cdf906..73e9e15 100644
--- a/doc/gen.txt
+++ b/doc/gen.txt
@@ -25,7 +25,11 @@ class PixelSize(object):
self.suffix = suffix
self.bit_endian = bit_endian
- ...
+
+ def needs_bit_endian(self):
+ ...
+
+ ...
-------------------------------------------------------------------------------
@@ -41,10 +45,13 @@ The 'bit_endian' determines the ordering of pixel bits within a byte in bitmaps
and graymaps. This is significant in pixel types with pixel boundaries
within a byte, i.e. 1 bpp, 4 bpp or 17 bpp.
-It can be either 'BE' or 'LE' (i.e. most significant bit left or right in the bitmap).
-Usually, the bitmap is ordered with left bits earlier in the memory, but the
-earlier/later relationship is important.
-This is defined in terms of natural pixel ordering within the memory.
+The function 'needs_bit_endian()' returns true for pixel sizes that are not
+aligned to the whole bytes.
+
+The bit endian can be either 'BE' or 'LE' (i.e. most significant bit left or
+right in the bitmap). Usually, the bitmap is ordered with left bits earlier
+in the memory, but the earlier/later relationship is important. This is
+defined in terms of natural pixel ordering within the memory.
'BE' means that the earlier (usually left-most) pixels use the higher ("big")
bits of the byte. I.e. in 1 bpp, the first pixel would have value 128, the second 64
http://repo.or.cz/w/gfxprim.git/commit/082e5eed64755a0130dafab53ef3b5252ce7…
commit 082e5eed64755a0130dafab53ef3b5252ce745e6
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Dec 26 19:18:40 2012 +0100
core: GP_Common: Reimplement the abort message.
Move the abort message code from the header to
the C source.
diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile
index cce46d8..cb6fe82 100644
--- a/demos/c_simple/Makefile
+++ b/demos/c_simple/Makefile
@@ -18,7 +18,7 @@ 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_example fileview linetest randomshapetest fonttest- loaders_register blittest textaligntest
+ loaders_register blittest textaligntest abort
ifeq ($(HAVE_LIBSDL),yes)
APPS+=SDL_glue
diff --git a/demos/c_simple/abort.c b/demos/c_simple/abort.c
new file mode 100644
index 0000000..d9c3e18
--- /dev/null
+++ b/demos/c_simple/abort.c
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * 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 <GP.h>
+
+int main(void)
+{
+ GP_Context *ctx;
+
+ /* this call causes library to abort because of invalid parameters */
+ ctx = GP_ContextAlloc(0, 0, -1);
+
+ return 0;
+}
diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h
index 1140e76..1352c76 100644
--- a/include/core/GP_Common.h
+++ b/include/core/GP_Common.h
@@ -100,29 +100,19 @@
* GP_GENERAL_CHECK is a check with specified message prefix
* (for assert and check)
*/
+#define GP_INTERNAL_ABORT(...) do { + GP_PrintAbortInfo(__FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + abort(); +} while (0)
/*
* Print as much trace info as possible. Currently, the (C) call stack and
* the Python stack if a Python interpreter is set up. In case more wrappers
* are written, it should print a trace for the currently active.
*/
-void GP_PrintAbortInfo(void);
-
-#define GP_INTERNAL_ABORT_BUFSIZE 1024
-#define GP_INTERNAL_ABORT(str_abort_msg_, ...) do { - char bufstart[GP_INTERNAL_ABORT_BUFSIZE], *buf = bufstart; - char *bufend = buf + GP_INTERNAL_ABORT_BUFSIZE; - buf += snprintf(buf, bufend - buf, "*** gfxprim: %s:%d: in %s: %s", - __FILE__, __LINE__, __FUNCTION__, str_abort_msg_); - if (buf > bufend) buf = bufend; - if (! (#__VA_ARGS__ [0])) - buf += snprintf(buf, bufend - buf, "abort()"); - else - buf += snprintf(buf, bufend - buf, " " __VA_ARGS__); - fprintf(stderr, "%sn", bufstart); - GP_PrintAbortInfo(); - abort(); -} while (0)
+void GP_PrintAbortInfo(const char *file, const char *function, unsigned int line,
+ const char *msg, const char *fmt, ...)
+ __attribute__ ((format (printf, 5, 6)));
#define GP_GENERAL_CHECK(check_cond_, check_message_, ...) do { if (unlikely(!(check_cond_))) { @@ -138,10 +128,11 @@ void GP_PrintAbortInfo(void);
* Aborts and prints the message along with the location in code
* to stderr. Used for fatal errors.
*
- * Use as either GP_ABORT(), GP_ABORT(msg) or GP_ABORT(format, params...) where
+ * Use as either GP_ABORT(msg) or GP_ABORT(format, params...) where
* msg and format must be string constants.
*/
-#define GP_ABORT(...) GP_INTERNAL_ABORT("", ##__VA_ARGS__)
+#define GP_ABORT(...) + GP_INTERNAL_ABORT("n", __VA_ARGS__)
/*
* Checks the condition and aborts immediately if it is not satisfied,
@@ -153,7 +144,7 @@ void GP_PrintAbortInfo(void);
* constants.
*/
#define GP_ASSERT(check_cond_, ...) - GP_GENERAL_CHECK(check_cond_, "assertion failed: ", ##__VA_ARGS__);
+ GP_GENERAL_CHECK(check_cond_, "assertion failed: ", ##__VA_ARGS__)
/*
* Perform a runtime check, on failure abort and print a message.
@@ -164,6 +155,6 @@ void GP_PrintAbortInfo(void);
* constants.
*/
#define GP_CHECK(check_cond_, ...) - GP_GENERAL_CHECK(check_cond_, "check failed: ", ##__VA_ARGS__);
+ GP_GENERAL_CHECK(check_cond_, "check failed: ", ##__VA_ARGS__)
#endif /* CORE_GP_COMMON_H */
diff --git a/libs/core/GP_Common.c b/libs/core/GP_Common.c
index ae1365e..1d608ff 100644
--- a/libs/core/GP_Common.c
+++ b/libs/core/GP_Common.c
@@ -26,6 +26,7 @@
#include "../config.h"
#include <stdio.h>
+#include <stdarg.h>
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
@@ -70,9 +71,20 @@ static void print_python_stack(void)
#endif /* HAVE_DL */
}
-void GP_PrintAbortInfo(void)
+void GP_PrintAbortInfo(const char *file, const char *func, unsigned int line,
+ const char *msg, const char *fmt, ...)
{
+ va_list va;
+
+ fprintf(stderr, "*** gfxprim: %s:%d: in %s: %sn",
+ file, line, func, msg);
+
+ va_start(va, fmt);
+ vfprintf(stderr, fmt, va);
+ va_end(va);
+
+ fprintf(stderr, "n");
+
print_python_stack();
print_c_stack();
}
-
-----------------------------------------------------------------------
Summary of changes:
demos/c_simple/Makefile | 2 +-
.../GP_Grabbers.h => demos/c_simple/abort.c | 14 +-
doc/gen.txt | 41 +++-
include/core/GP_Common.h | 33 +--
.../core/GP_WritePixel.gen.h.t | 24 +-
include/core/GP_WritePixel.h | 46 +----
include/core/Makefile | 3 +-
libs/core/GP_Common.c | 16 +-
libs/core/GP_WritePixel.c | 263 +++++++++++---------
.../GP_WritePixel.gen.c.t} | 30 ++-
libs/core/Makefile | 3 +-
11 files changed, 264 insertions(+), 211 deletions(-)
copy include/grabbers/GP_Grabbers.h => demos/c_simple/abort.c (90%)
copy libs/gfx/GP_VLine.gen.c.t => include/core/GP_WritePixel.gen.h.t (76%)
copy libs/{gfx/GP_VLine.gen.c.t => core/GP_WritePixel.gen.c.t} (71%)
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: 0d714fd8292c2805d3cdc23d89345d41c9f23815
by metan 26 Dec '12
by metan 26 Dec '12
26 Dec '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 0d714fd8292c2805d3cdc23d89345d41c9f23815 (commit)
from 65cea9aefed176553293e6d5b18ad5eb24b9b704 (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/0d714fd8292c2805d3cdc23d89345d41c9f2…
commit 0d714fd8292c2805d3cdc23d89345d41c9f23815
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Dec 26 17:15:04 2012 +0100
build: Fix the parallel build.
diff --git a/Makefile b/Makefile
index 7c5480f..3da6589 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,10 @@
TOPDIR=.
+
+include $(TOPDIR)/pre.mk
+
+TOP_MAKE=1
+
SUBDIRS=include libs tests pylib demos build
-include post.mk
libs: include
build: libs
@@ -30,3 +34,5 @@ endif
tar:
$(MAKE) clean
cd .. && tar cf gfxprim-`date +%Y-%b-%d-%HH%MM`.tar gfxprim
+
+include $(TOPDIR)/post.mk
diff --git a/app.mk b/app.mk
index c5aef12..77bd5e7 100644
--- a/app.mk
+++ b/app.mk
@@ -7,6 +7,6 @@ CLEAN+=$(APPS)
ifdef VERBOSE
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group -o $@
else
- @echo "LD $@"
+ @echo "LD $@"
@$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group -o $@
endif
diff --git a/build/Makefile b/build/Makefile
index 59afb71..2c1aa01 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -12,38 +12,32 @@ clean:
ifdef VERBOSE
rm -rf libGP.a libGP.so libGP.so.0 .lock
else
- @echo "RM libGP.a libGP.so libGP.so.0 .lock"
+ @echo "RM libGP.a libGP.so libGP.so.0 .lock"
@rm -rf libGP.a libGP.so libGP.so.0 .lock
endif
libGP.a:
- @. ./liblock.sh; spinlock .
ifdef VERBOSE
$(AR) rcs libGP.a $(LIB_OBJECTS)
else
- @echo "AR libGP.a"
+ @echo "AR libGP.a"
@$(AR) rcs libGP.a $(LIB_OBJECTS)
endif
- @. ./liblock.sh; spinunlock .
libGP.so:
- @. ./liblock.sh; spinlock .
ifdef VERBOSE
$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,libGP.so.0 $(LIB_OBJECTS) -o libGP.so
else
- @echo "LD libGP.so"
+ @echo "LD libGP.so"
@$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,libGP.so.0 $(LIB_OBJECTS) -o libGP.so
endif
- @. ./liblock.sh; spinunlock .
libGP.so.0: libGP.so
- @. ./liblock.sh; spinlock .
ifdef VERBOSE
rm -f libGP.so.0
ln -s libGP.so libGP.so.0
else
- @echo "LN libGP.so.0"
+ @echo "LN libGP.so.0"
@rm -f libGP.so.0
@ln -s libGP.so libGP.so.0
endif
- @. ./liblock.sh; spinunlock .
diff --git a/build/liblock.sh b/build/liblock.sh
deleted file mode 100644
index 2af11e4..0000000
--- a/build/liblock.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Takes directory as parameter
-#
-spinlock()
-{
- I=0
- #echo -n "Trying to acquire lock in '$1' ."
- while ! `mkdir "$1/.lock" &> /dev/null`; do
- sleep 1;
- ((I=I+1))
- echo $I
- if [ $I -gt 10 ]; then
- echo "Failed to acquire lock '`pwd`/.lock'"
- exit 1
- fi
- # echo -n .
- done
- #echo " done"
-}
-
-spinunlock()
-{
- #echo "Removing lock in '$1'"
- rmdir "$1/.lock" &> /dev/null
-}
diff --git a/lib.mk b/lib.mk
index d9a6f0b..98a7e5a 100644
--- a/lib.mk
+++ b/lib.mk
@@ -29,7 +29,7 @@ ifdef VERBOSE
else
@rm -f $(LIBP)$(LIB).so.0
@cd $(LIBP) && ln -s $(LIB).so $(LIB).so.0
- @echo "LD $@"
+ @echo "LD $@"
@$(CC) -fPIC --shared -Wl,-soname -Wl,$(LIB).so.0 $(OBJECTS) -o $@
endif
@@ -37,7 +37,7 @@ $(LIBP)$(LIB).a: $(OBJS)
ifdef VERBOSE
$(AR) rcs $@ $(OBJECTS)
else
- @echo "AR $@"
+ @echo "AR $@"
@$(AR) rcs $@ $(OBJECTS)
endif
@@ -45,7 +45,7 @@ else
# BUILDLIB = no
include $(TOPDIR)/config.mk
-ifeq ($(REBUILD_LIBGP),yes)
+ifndef TOP_MAKE
ALL+=rebuild_lib
rebuild_lib:
diff --git a/libs/backends/Makefile b/libs/backends/Makefile
index e59e2c1..39ea7d2 100644
--- a/libs/backends/Makefile
+++ b/libs/backends/Makefile
@@ -1,8 +1,9 @@
TOPDIR=../..
+include $(TOPDIR)/pre.mk
+
CSOURCES=$(shell ls *.c)
LIBNAME=backends
BUILDLIB=yes
-include $(TOPDIR)/pre.mk
include $(TOPDIR)/lib.mk
include $(TOPDIR)/post.mk
diff --git a/libs/core/Makefile b/libs/core/Makefile
index 65d8440..cd08e30 100644
--- a/libs/core/Makefile
+++ b/libs/core/Makefile
@@ -1,10 +1,11 @@
TOPDIR=../..
+include $(TOPDIR)/pre.mk
+
GENSOURCES=GP_Pixel.gen.c GP_Blit.gen.c GP_Convert.gen.c GP_GammaCorrection.gen.c
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
LIBNAME=core
-include $(TOPDIR)/pre.mk
include $(TOPDIR)/gen.mk
include $(TOPDIR)/lib.mk
include $(TOPDIR)/post.mk
diff --git a/libs/filters/Makefile b/libs/filters/Makefile
index cedc55a..1773151 100644
--- a/libs/filters/Makefile
+++ b/libs/filters/Makefile
@@ -1,4 +1,5 @@
TOPDIR=../..
+include $(TOPDIR)/pre.mk
STATS_FILTERS=GP_Histogram.gen.c
@@ -17,7 +18,6 @@ CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
LIBNAME=filters
INCLUDE=core
-include $(TOPDIR)/pre.mk
include $(TOPDIR)/gen.mk
include $(TOPDIR)/lib.mk
include $(TOPDIR)/post.mk
diff --git a/libs/gfx/Makefile b/libs/gfx/Makefile
index e46a8ef..4511495 100644
--- a/libs/gfx/Makefile
+++ b/libs/gfx/Makefile
@@ -1,10 +1,11 @@
TOPDIR=../..
+include $(TOPDIR)/pre.mk
+
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
GENSOURCES=GP_Line.gen.c GP_HLine.gen.c GP_LineAA.gen.c GP_PutPixelAA.gen.c GP_HLineAA.gen.c GP_VLineAA.gen.c GP_FillCircle.gen.c GP_VLine.gen.c
LIBNAME=gfx
-include $(TOPDIR)/pre.mk
include $(TOPDIR)/gen.mk
include $(TOPDIR)/lib.mk
include $(TOPDIR)/post.mk
diff --git a/libs/grabbers/Makefile b/libs/grabbers/Makefile
index 4df5769..919a0ef 100644
--- a/libs/grabbers/Makefile
+++ b/libs/grabbers/Makefile
@@ -1,8 +1,9 @@
TOPDIR=../..
+include $(TOPDIR)/pre.mk
+
CSOURCES=$(shell ls *.c)
LIBNAME=grabbers
BUILDLIB=yes
-include $(TOPDIR)/pre.mk
include $(TOPDIR)/lib.mk
include $(TOPDIR)/post.mk
diff --git a/libs/input/Makefile b/libs/input/Makefile
index 4896a22..5d58e4c 100644
--- a/libs/input/Makefile
+++ b/libs/input/Makefile
@@ -1,8 +1,9 @@
TOPDIR=../..
+include $(TOPDIR)/pre.mk
+
CSOURCES=$(shell ls *.c)
INCLUDE=core
LIBNAME=input
-include $(TOPDIR)/pre.mk
include $(TOPDIR)/lib.mk
include $(TOPDIR)/post.mk
diff --git a/libs/loaders/Makefile b/libs/loaders/Makefile
index 0adfcfb..076b940 100644
--- a/libs/loaders/Makefile
+++ b/libs/loaders/Makefile
@@ -1,8 +1,9 @@
TOPDIR=../..
+include $(TOPDIR)/pre.mk
+
CSOURCES=$(shell ls *.c)
INCLUDE=core
LIBNAME=loaders
-include $(TOPDIR)/pre.mk
include $(TOPDIR)/lib.mk
include $(TOPDIR)/post.mk
diff --git a/post.mk b/post.mk
index 84ef703..881a42f 100644
--- a/post.mk
+++ b/post.mk
@@ -82,10 +82,10 @@ endif
#
$(SUBDIRS):
ifdef VERBOSE
- $(MAKE) -C $@ $(MAKECMDGOALS)
+ $(MAKE) -C $@ $(MAKECMDGOALS) TOP_MAKE=$(TOP_MAKE)
else
- @export CURSUBDIR="$$CURSUBDIR/$@" && echo "DIR $$CURSUBDIR" &&- $(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS)
+ @export CURSUBDIR="$$CURSUBDIR/$@" && echo "DIR $$CURSUBDIR" &&+ $(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS) TOP_MAKE=$(TOP_MAKE)
endif
#
@@ -95,7 +95,7 @@ $(DEPFILES): %.dep: %.c
ifdef VERBOSE
$(CC) -MM $(CFLAGS) $< -o $@
else
- @echo "DEP -I(include $(INCLUDE)) $@"
+ @echo "DEP -I(include $(INCLUDE)) $@"
@$(CC) -MM $(CFLAGS) $< -o $@
endif
@@ -103,7 +103,7 @@ $(OBJECTS): %.o: %.c
ifdef VERBOSE
$(CC) $(CFLAGS) -c $< -o $@
else
- @echo "CC -I(include $(INCLUDE)) $@"
+ @echo "CC -I(include $(INCLUDE)) $@"
@$(CC) $(CFLAGS) -c $< -o $@
endif
@@ -112,7 +112,7 @@ clean:
ifdef VERBOSE
rm -f $(CLEAN)
else
- @echo "RM $(CLEAN)"
+ @echo "RM $(CLEAN)"
@rm -f $(CLEAN)
endif
endif
diff --git a/pywrap.mk b/pywrap.mk
index 2b527b8..f41ce63 100644
--- a/pywrap.mk
+++ b/pywrap.mk
@@ -29,7 +29,7 @@ $(SWIG_LIB): $(SWIG_C)
ifdef VERBOSE
$(CC) $< $(CFLAGS) -D_GNU_SOURCE=1 $(LDFLAGS) -I$(PYTHON_INCLUDE) --shared -lGP $(LDLIBS) -L$(TOPDIR)/build/ -o $@
else # VERBOSE
- @echo "LD $@"
+ @echo "LD $@"
@$(CC) $< $(CFLAGS) -D_GNU_SOURCE=1 $(LDFLAGS) -I$(PYTHON_INCLUDE) --shared -lGP $(LDLIBS) -L$(TOPDIR)/build/ -o $@
endif # VERBOSE
-----------------------------------------------------------------------
Summary of changes:
Makefile | 8 +++++++-
app.mk | 2 +-
build/Makefile | 14 ++++----------
build/liblock.sh | 25 -------------------------
lib.mk | 6 +++---
libs/backends/Makefile | 3 ++-
libs/core/Makefile | 3 ++-
libs/filters/Makefile | 2 +-
libs/gfx/Makefile | 3 ++-
libs/grabbers/Makefile | 3 ++-
libs/input/Makefile | 3 ++-
libs/loaders/Makefile | 3 ++-
post.mk | 12 ++++++------
pywrap.mk | 2 +-
14 files changed, 35 insertions(+), 54 deletions(-)
delete mode 100644 build/liblock.sh
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: 65cea9aefed176553293e6d5b18ad5eb24b9b704
by metan 26 Dec '12
by metan 26 Dec '12
26 Dec '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 65cea9aefed176553293e6d5b18ad5eb24b9b704 (commit)
via 9405c62813a1cc0ce1584a512ca07384899244b2 (commit)
via e9931e042beccee51ddb1855ba2cecc22dc8d0ea (commit)
from 36422459f0fc8293fb52d4818dc94c8342615a1c (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/65cea9aefed176553293e6d5b18ad5eb24b9…
commit 65cea9aefed176553293e6d5b18ad5eb24b9b704
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Dec 26 16:02:33 2012 +0100
build: pywrap: Fix the dependencies.
Make can't create rule that produces two
or more files so we use small trick with
with dummy rule to fix this.
diff --git a/pywrap.mk b/pywrap.mk
index d8b18f6..2b527b8 100644
--- a/pywrap.mk
+++ b/pywrap.mk
@@ -13,7 +13,11 @@ INCLUDES+=$(addprefix -I$(TOPDIR)/include/, $(INCLUDE))
ALL+=$(SWIG_LIB) $(SWIG_PY)
-$(SWIG_C) $(SWIG_PY): $(SWIG_SRC)
+# Empty rule to satisfy SWIG_PY
+$(SWIG_PY): $(SWIG_C)
+ @
+
+$(SWIG_C): $(SWIG_SRC)
ifdef VERBOSE
$(SWIG) $(SWIGOPTS) -python $(INCLUDES) $<
else # VERBOSE
http://repo.or.cz/w/gfxprim.git/commit/9405c62813a1cc0ce1584a512ca073848992…
commit 9405c62813a1cc0ce1584a512ca07384899244b2
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Dec 26 15:55:35 2012 +0100
build: Fix dependencies for library build.
Now the library is rebuild only once after
the sources has been changed.
diff --git a/build/Makefile b/build/Makefile
index 7ac79b2..59afb71 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -1,7 +1,10 @@
LIB_OBJECTS=$(shell ./get_objs.sh)
all: libGP.a libGP.so libGP.so.0
-.PHONY: libGP.a libGP.so libGP.so.0
+
+libGP.a: $(LIB_OBJECTS)
+libGP.so: $(LIB_OBJECTS)
+libGP.so.0: $(LIB_OBJECTS)
rebuild: all
http://repo.or.cz/w/gfxprim.git/commit/e9931e042beccee51ddb1855ba2cecc22dc8…
commit e9931e042beccee51ddb1855ba2cecc22dc8d0ea
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Dec 26 15:52:20 2012 +0100
Remove long obsolete TODO file.
diff --git a/TODO b/TODO
deleted file mode 100644
index 04e7bdc..0000000
--- a/TODO
+++ /dev/null
@@ -1,15 +0,0 @@
-What's not implemented (and should be)
---------------------------------------
-
-* Meditate about bit endians and why these aren't separate pixel types
- (which would make our lives a bit easier)
-
-Advanced features
------------------
-
-* bitmaps
- - alpha channel
-
-* gfx primitives
- - drawing with alpha channel
- - anti aliasing
-----------------------------------------------------------------------
Summary of changes:
TODO | 15 ---------------
build/Makefile | 5 ++++-
pywrap.mk | 6 +++++-
3 files changed, 9 insertions(+), 17 deletions(-)
delete mode 100644 TODO
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: 36422459f0fc8293fb52d4818dc94c8342615a1c
by metan 26 Dec '12
by metan 26 Dec '12
26 Dec '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 36422459f0fc8293fb52d4818dc94c8342615a1c (commit)
via 833048c796ea1e1edd87616fd55cc6d8b83c2e24 (commit)
via af5118fc6050c831cac9fdb26e1d4a0f2d081626 (commit)
from 8bfdadb7f739f7eb614d3c4f427a3d075a0669a1 (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/36422459f0fc8293fb52d4818dc94c834261…
commit 36422459f0fc8293fb52d4818dc94c8342615a1c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Dec 26 15:40:08 2012 +0100
all: Fix some warnings.
diff --git a/demos/c_simple/blittest.c b/demos/c_simple/blittest.c
index 013bf07..5a80233 100644
--- a/demos/c_simple/blittest.c
+++ b/demos/c_simple/blittest.c
@@ -147,7 +147,7 @@ void print_instructions(void)
printf(" P ............... pausen");
}
-int main(int argc, char *argv[])
+int main(void)
{
const char *sprite = "ball.ppm";
const char *backend_opts = "X11";
diff --git a/include/filters/GP_Sigma.h b/include/filters/GP_Sigma.h
index 18275f0..a9e35e9 100644
--- a/include/filters/GP_Sigma.h
+++ b/include/filters/GP_Sigma.h
@@ -47,18 +47,21 @@ int GP_FilterSigmaEx(const GP_Context *src,
GP_Size w_src, GP_Size h_src,
GP_Context *dst,
GP_Coord x_dst, GP_Coord y_dst,
- int xrad, int yrad, int min, float sigma,
+ int xrad, int yrad,
+ unsigned int min, float sigma,
GP_ProgressCallback *callback);
GP_Context *GP_FilterSigmaExAlloc(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
GP_Size w_src, GP_Size h_src,
- int xrad, int yrad, int min, float sigma,
+ int xrad, int yrad,
+ unsigned int min, float sigma,
GP_ProgressCallback *callback);
static inline int GP_FilterSigma(const GP_Context *src,
GP_Context *dst,
- int xrad, int yrad, int min, float sigma,
+ int xrad, int yrad,
+ unsigned int min, float sigma,
GP_ProgressCallback *callback)
{
return GP_FilterSigmaEx(src, 0, 0, src->w, src->h,
@@ -67,7 +70,7 @@ static inline int GP_FilterSigma(const GP_Context *src,
static inline GP_Context *GP_FilterSigmaAlloc(const GP_Context *src,
int xrad, int yrad,
- int min, float sigma,
+ unsigned int min, float sigma,
GP_ProgressCallback *callback)
{
return GP_FilterSigmaExAlloc(src, 0, 0, src->w, src->h,
diff --git a/libs/filters/GP_Sigma.c b/libs/filters/GP_Sigma.c
index 876e21d..2d1f6aa 100644
--- a/libs/filters/GP_Sigma.c
+++ b/libs/filters/GP_Sigma.c
@@ -37,7 +37,8 @@ static int GP_FilterSigma_Raw(const GP_Context *src,
GP_Size w_src, GP_Size h_src,
GP_Context *dst,
GP_Coord x_dst, GP_Coord y_dst,
- int xrad, int yrad, int min, float sigma,
+ int xrad, int yrad,
+ unsigned int min, float sigma,
GP_ProgressCallback *callback)
{
int x, y;
@@ -68,7 +69,7 @@ static int GP_FilterSigma_Raw(const GP_Context *src,
for (x = 0; x < (int)w; x++) {
int xi = GP_CLAMP(x_src + x - xrad, 0, (int)src->w - 1);
- for (y = 0; y < ydiam; y++) {
+ for (y = 0; y < (int)ydiam; y++) {
int yi = GP_CLAMP(y_src + y - yrad, 0, (int)src->h - 1);
GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, xi, yi);
@@ -206,7 +207,8 @@ int GP_FilterSigmaEx(const GP_Context *src,
GP_Size w_src, GP_Size h_src,
GP_Context *dst,
GP_Coord x_dst, GP_Coord y_dst,
- int xrad, int yrad, int min, float sigma,
+ int xrad, int yrad,
+ unsigned int min, float sigma,
GP_ProgressCallback *callback)
{
GP_CHECK(src->pixel_type == dst->pixel_type);
@@ -225,7 +227,8 @@ int GP_FilterSigmaEx(const GP_Context *src,
GP_Context *GP_FilterSigmaExAlloc(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
GP_Size w_src, GP_Size h_src,
- int xrad, int yrad, int min, float sigma,
+ int xrad, int yrad,
+ unsigned int min, float sigma,
GP_ProgressCallback *callback)
{
int ret;
diff --git a/libs/loaders/GP_TmpFile.c b/libs/loaders/GP_TmpFile.c
index cacbf32..2796652 100644
--- a/libs/loaders/GP_TmpFile.c
+++ b/libs/loaders/GP_TmpFile.c
@@ -39,7 +39,7 @@ GP_Context *GP_LoadTmpFile(const char *src_path, GP_ProgressCallback *callback)
enum GP_PixelType pixel_type;
char sig[sizeof(file_sig)];
GP_Context *ret;
- int err;
+ int err, i;
f = fopen(src_path, "r");
@@ -58,15 +58,15 @@ GP_Context *GP_LoadTmpFile(const char *src_path, GP_ProgressCallback *callback)
goto err0;
}
- /* Read context metadata */
- fread(&w, sizeof(w), 1, f);
- fread(&h, sizeof(h), 1, f);
- fread(&offset, sizeof(offset), 1, f);
- fread(&bpr, sizeof(bpr), 1, f);
- fread(&pixel_type, sizeof(pixel_type), 1, f);
- fread(&flags, 1, 1, f);
+ /* Read context metadata */
+ i = fread(&w, sizeof(w), 1, f);
+ i += fread(&h, sizeof(h), 1, f);
+ i += fread(&offset, sizeof(offset), 1, f);
+ i += fread(&bpr, sizeof(bpr), 1, f);
+ i += fread(&pixel_type, sizeof(pixel_type), 1, f);
+ i += fread(&flags, 1, 1, f);
- if (ferror(f)) {
+ if (i != 6 || ferror(f)) {
err = EIO;
goto err0;
}
@@ -121,7 +121,7 @@ int GP_SaveTmpFile(const GP_Context *src, const char *dst_path,
{
FILE *f;
int err;
- uint32_t y;
+ uint32_t y, i;
f = fopen(dst_path, "w");
@@ -129,14 +129,14 @@ int GP_SaveTmpFile(const GP_Context *src, const char *dst_path,
return 1;
/* Write a signature */
- fwrite(file_sig, sizeof(file_sig), 1, f);
+ i = fwrite(file_sig, sizeof(file_sig), 1, f);
/* Write block of metadata */
- fwrite(&src->w, sizeof(src->w), 1, f);
- fwrite(&src->h, sizeof(src->h), 1, f);
- fwrite(&src->offset, sizeof(src->offset), 1, f);
- fwrite(&src->bytes_per_row, sizeof(src->bytes_per_row), 1, f);
- fwrite(&src->pixel_type, sizeof(src->pixel_type), 1, f);
+ i += fwrite(&src->w, sizeof(src->w), 1, f);
+ i += fwrite(&src->h, sizeof(src->h), 1, f);
+ i += fwrite(&src->offset, sizeof(src->offset), 1, f);
+ i += fwrite(&src->bytes_per_row, sizeof(src->bytes_per_row), 1, f);
+ i += fwrite(&src->pixel_type, sizeof(src->pixel_type), 1, f);
uint8_t flags = 0;
@@ -149,7 +149,12 @@ int GP_SaveTmpFile(const GP_Context *src, const char *dst_path,
if (src->y_swap)
flags |= 0x04;
- fwrite(&flags, 1, 1, f);
+ i += fwrite(&flags, 1, 1, f);
+
+ if (i != 7) {
+ err = EIO;
+ goto err1;
+ }
/* And pixels */
for (y = 0; y < src->h; y++) {
diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i
index c59ae6c..89c0301 100644
--- a/pylib/gfxprim/core/core.i
+++ b/pylib/gfxprim/core/core.i
@@ -38,7 +38,7 @@ ERROR_ON_NULL(GP_ColorToColorName);
%inline %{
const GP_PixelTypeDescription *GP_PixelTypes_access(GP_PixelType no)
{
- if (no < 0 || no >= GP_PIXEL_MAX) no = GP_PIXEL_UNKNOWN;
+ if ((signed)no < 0 || no >= GP_PIXEL_MAX) no = GP_PIXEL_UNKNOWN;
return &GP_PixelTypes[no];
}
%}
diff --git a/tests/filters/LinearConvolution.c b/tests/filters/LinearConvolution.c
index 0264ddd..42ac872 100644
--- a/tests/filters/LinearConvolution.c
+++ b/tests/filters/LinearConvolution.c
@@ -114,7 +114,7 @@ static int test_v_lin_conv_box_3_raw(void)
if (ret != TST_SUCCESS)
return ret;
- GP_SetDebugLevel(10);
+// GP_SetDebugLevel(10);
/* Apply the convolution */
float kernel[] = {1, 1, 1};
http://repo.or.cz/w/gfxprim.git/commit/833048c796ea1e1edd87616fd55cc6d8b83c…
commit 833048c796ea1e1edd87616fd55cc6d8b83c2e24
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Dec 26 15:34:47 2012 +0100
pywrap: loaders: Ignore GP_Loader structure.
Don't generate accessors for GP_Loader structure members.
diff --git a/pylib/gfxprim/loaders/loaders.i b/pylib/gfxprim/loaders/loaders.i
index f72a3e8..33a2fbd 100644
--- a/pylib/gfxprim/loaders/loaders.i
+++ b/pylib/gfxprim/loaders/loaders.i
@@ -6,6 +6,8 @@
#include "loaders/GP_Loaders.h"
%}
+%ignore GP_Loader;
+
%import ../core/core.i
ERROR_ON_NULL(GP_LoadImage);
http://repo.or.cz/w/gfxprim.git/commit/af5118fc6050c831cac9fdb26e1d4a0f2d08…
commit af5118fc6050c831cac9fdb26e1d4a0f2d081626
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Dec 26 15:20:28 2012 +0100
tests: framework: Use more portable posix_memalign.
diff --git a/tests/framework/tst_alloc_barriers.c b/tests/framework/tst_alloc_barriers.c
index 315480e..fb745b6 100644
--- a/tests/framework/tst_alloc_barriers.c
+++ b/tests/framework/tst_alloc_barriers.c
@@ -31,10 +31,9 @@ void *tst_alloc_barrier_right(size_t size)
{
size_t pagesize = sysconf(_SC_PAGESIZE);
size_t pages = size/pagesize + !!(size%pagesize) + 1;
-
- char *buf = memalign(pagesize, pages * pagesize);
-
- if (buf == NULL)
+ char *buf;
+
+ if (posix_memalign((void*)&buf, pagesize, pages * pagesize))
return NULL;
/*
@@ -70,9 +69,9 @@ void *tst_alloc_barrier_left(size_t size)
size_t pagesize = sysconf(_SC_PAGESIZE);
size_t pages = size/pagesize + !!(size%pagesize) + 1;
- char *buf = memalign(pagesize, pages * pagesize);
-
- if (buf == NULL)
+ char *buf;
+
+ if (posix_memalign((void*)&buf, pagesize, pages * pagesize))
return NULL;
/*
-----------------------------------------------------------------------
Summary of changes:
demos/c_simple/blittest.c | 2 +-
include/filters/GP_Sigma.h | 11 ++++++---
libs/filters/GP_Sigma.c | 11 ++++++---
libs/loaders/GP_TmpFile.c | 39 +++++++++++++++++++--------------
pylib/gfxprim/core/core.i | 2 +-
pylib/gfxprim/loaders/loaders.i | 2 +
tests/filters/LinearConvolution.c | 2 +-
tests/framework/tst_alloc_barriers.c | 13 +++++------
8 files changed, 47 insertions(+), 35 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: 8bfdadb7f739f7eb614d3c4f427a3d075a0669a1
by gavento 25 Dec '12
by gavento 25 Dec '12
25 Dec '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 8bfdadb7f739f7eb614d3c4f427a3d075a0669a1 (commit)
via 55afb5fd376150afe14f6388749547e07fc02c42 (commit)
from 08e5a448761d5d3b25abcf1d42967458e8cdfa62 (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/8bfdadb7f739f7eb614d3c4f427a3d075a06…
commit 8bfdadb7f739f7eb614d3c4f427a3d075a0669a1
Merge: 55afb5f 08e5a44
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Dec 25 03:28:02 2012 +0100
Merge branch 'master' of ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/55afb5fd376150afe14f6388749547e07fc0…
commit 55afb5fd376150afe14f6388749547e07fc02c42
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Dec 25 03:26:45 2012 +0100
loaders: pylib: cleanup and Context submodule
diff --git a/pylib/gfxprim/loaders/__init__.py b/pylib/gfxprim/loaders/__init__.py
index 5dd476e..621099a 100644
--- a/pylib/gfxprim/loaders/__init__.py
+++ b/pylib/gfxprim/loaders/__init__.py
@@ -1,11 +1,31 @@
-from . import loaders_c
+from . import c_loaders
+
+
+def Load(filename, callback=None):
+ "Load image from given file, guessing the type."
+ c = c_loaders.GP_LoadImage(filename, callback)
+ return c
+
def _init(module):
+ "Extend Context with loaders submodule"
+
+ from ..utils import extend, add_swig_getmethod, add_swig_setmethod
+ from ..core import Context as _context
+
+ class LoadersSubmodule(object):
+ def __init__(self, ctx):
+ self.ctx = ctx
+
+ _context._submodules['loaders'] = LoadersSubmodule
+
+ @extend(LoadersSubmodule)
+ def Save(self, filename, callback=None):
+ """Save the image, guessing the type from the extension.
- # Extend Context with convenience methods
- from ._extend_context import extend_context
- from ..core import Context
- extend_context(Context)
+ Generally, not all pixel types work with all formats.
+ """
+ c_loaders.GP_SaveImage(self.ctx, filename, callback)
# Imports from the SWIG module
import re
@@ -14,11 +34,13 @@ def _init(module):
# Import functions from the SWIG module
from ..utils import import_members
- import_members(loaders_c, module, sub=strip_GP,
- exclude=[
- '^w+_swigregister$',
- '^gfxprim$',
- '^_w+$'])
+ import_members(c_loaders, module, sub=strip_GP,
+ include=[
+ '^GP_Load[A-Z]{3}.*',
+ '^GP_Save[A-Z]{3}.*',
+ '^GP_ListLoaders$',
+ '^GP_LoadMetaData$',
+ ])
_init(locals())
del _init
diff --git a/pylib/gfxprim/loaders/loaders.i b/pylib/gfxprim/loaders/loaders.i
index 7c9d903..f72a3e8 100644
--- a/pylib/gfxprim/loaders/loaders.i
+++ b/pylib/gfxprim/loaders/loaders.i
@@ -1,5 +1,5 @@
%include "../common.i"
-%module(package="gfxprim.loaders") loaders_c
+%module(package="gfxprim.loaders") c_loaders
%{
#include "core/GP_Core.h"
@@ -14,7 +14,7 @@ ERROR_ON_NONZERO(GP_SaveImage);
%newobject GP_LoadImage;
-%include "GP_Loaders.h"
+%include "GP_Loader.h"
ERROR_ON_NONZERO(GP_OpenJPG);
ERROR_ON_NULL(GP_ReadJPG);
-----------------------------------------------------------------------
Summary of changes:
pylib/gfxprim/loaders/__init__.py | 42 ++++++++++++++++++++++++++++--------
pylib/gfxprim/loaders/loaders.i | 4 +-
2 files changed, 34 insertions(+), 12 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: 08e5a448761d5d3b25abcf1d42967458e8cdfa62
by metan 25 Dec '12
by metan 25 Dec '12
25 Dec '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 08e5a448761d5d3b25abcf1d42967458e8cdfa62 (commit)
via 8112b2d6aa79952028fc73c6d3a831878804d84b (commit)
via f0949124262c1ba843c8abe8bc85f3e21703c16a (commit)
from 0d0f7852bb88e81f1e248e9776022232454d218e (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/08e5a448761d5d3b25abcf1d42967458e8cd…
commit 08e5a448761d5d3b25abcf1d42967458e8cdfa62
Merge: 8112b2d 0d0f785
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Dec 25 02:38:34 2012 +0100
Merge ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/8112b2d6aa79952028fc73c6d3a831878804…
commit 8112b2d6aa79952028fc73c6d3a831878804d84b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Dec 25 02:38:03 2012 +0100
build: syms: Update lists of exported symbols.
diff --git a/build/syms/Backend_symbols.txt b/build/syms/Backend_symbols.txt
index abcd681..580f390 100644
--- a/build/syms/Backend_symbols.txt
+++ b/build/syms/Backend_symbols.txt
@@ -1,7 +1,13 @@
GP_BackendInit
+
GP_BackendLinuxFBInit
+
GP_BackendVirtualInit
+
GP_BackendX11Init
+GP_BackendIsX11
+GP_BackendX11RequestFullscreen
+
GP_BackendSDLInit
GP_ContextFromSurface
diff --git a/build/syms/Core_symbols.txt b/build/syms/Core_symbols.txt
index 5033860..3de2293 100644
--- a/build/syms/Core_symbols.txt
+++ b/build/syms/Core_symbols.txt
@@ -22,6 +22,8 @@ GP_DebugPrint
GP_SetDebugLevel
GP_GetDebugLevel
+GP_PrintAbortInfo
+
GP_ColorToPixel
GP_ColorLoadPixels
GP_RGBA8888ToPixel
http://repo.or.cz/w/gfxprim.git/commit/f0949124262c1ba843c8abe8bc85f3e21703…
commit f0949124262c1ba843c8abe8bc85f3e21703c16a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Dec 25 02:37:14 2012 +0100
core: GP_Common: Make local functions static.
diff --git a/libs/core/GP_Common.c b/libs/core/GP_Common.c
index 52c4920..ae1365e 100644
--- a/libs/core/GP_Common.c
+++ b/libs/core/GP_Common.c
@@ -16,7 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
+ * Copyright (C) 2011-2012 Tomas Gavenciak <gavento(a)ucw.cz> *
+ * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -39,7 +40,7 @@
#define GP_ABORT_INFO_TRACE_LEVELS 20
-void GP_PrintCStack(void)
+static void print_c_stack(void)
{
#ifdef HAVE_BACKTRACE
#if GP_ABORT_INFO_TRACE_LEVELS > 0
@@ -52,7 +53,7 @@ void GP_PrintCStack(void)
#endif /* HAVE_BACKTRACE */
}
-void GP_PrintPythonStack(void)
+static void print_python_stack(void)
{
#ifdef HAVE_DL
/* Print python stack trace in case python lib is loaded and
@@ -65,13 +66,13 @@ void GP_PrintPythonStack(void)
fprintf(stderr, "nPython stack trace (most recent call last; ignore last line):n");
fflush(stderr);
dl_PyRun_SimpleString("import traceback; traceback.print_stack();");
- }
+ }
#endif /* HAVE_DL */
}
void GP_PrintAbortInfo(void)
{
- GP_PrintPythonStack();
- GP_PrintCStack();
+ print_python_stack();
+ print_c_stack();
}
-----------------------------------------------------------------------
Summary of changes:
build/syms/Backend_symbols.txt | 6 ++++++
build/syms/Core_symbols.txt | 2 ++
libs/core/GP_Common.c | 13 +++++++------
3 files changed, 15 insertions(+), 6 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: 0d0f7852bb88e81f1e248e9776022232454d218e
by gavento 25 Dec '12
by gavento 25 Dec '12
25 Dec '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 0d0f7852bb88e81f1e248e9776022232454d218e (commit)
via 324bfb6f6762369f769774df7765f871330d262e (commit)
via 9fd530170199db0cf53d4d4b7223f07b44c2554d (commit)
via fb131160d2f7320ef2998d1165dab70a6ac2f97e (commit)
via f5cecdf0ef17c206a2481873bedcb2b6178ccefa (commit)
from 77ca5e065797236b928b1ee5a3e869c564620191 (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/0d0f7852bb88e81f1e248e9776022232454d…
commit 0d0f7852bb88e81f1e248e9776022232454d218e
Merge: 324bfb6 77ca5e0
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Dec 25 02:18:26 2012 +0100
Merge branch 'master' of ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/324bfb6f6762369f769774df7765f871330d…
commit 324bfb6f6762369f769774df7765f871330d262e
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Dec 25 02:15:22 2012 +0100
core: pylib: Cleanup of gfxprim.core and imports
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py
index 4e90c66..a4301f5 100644
--- a/pylib/gfxprim/core/__init__.py
+++ b/pylib/gfxprim/core/__init__.py
@@ -55,7 +55,6 @@ def _init(module):
c.parent = None
return c
- extend_direct
@extend(_context)
def SubContext(self, x, y, w, h):
"Create a subcontext (a rectangular view)."
@@ -162,112 +161,15 @@ def _init(module):
# Bulk import of functions
import_members(c_core, module, sub=strip_GP,
- exclude=const_regexes + [
- '^GP_Blitw+$',
- '^GP_Contextw+$',
- '^GP_PixelSNPrintw+$',
- '^GP_WritePixelsw+$',
- '.*_Raw.*',
- '^w+_swigregister$',
- '^cvar$',
- '^_w+$'])
+ include=[
+ '^GP_Color.*$', # Might use trimming
+ '^GP_[GS]etDebugLevel$',
+ '^GP_PixelRGB.*$', # ...Lookup and ...Match
+ '^GP_PixelToRGB.*$', # Needs love
+ '^GP_RGB.*$', # Needs filtering
+ #'^GP_ProgressCallback.*$', # Needs work
+ ])
_init(locals())
del _init
-"""
-TODO: on entering any func from Python, set up error reporting on GP_ABORT
-(raise an exception, restore stack and return, possibly longjmp?
-(or just force python trace?)
-
-!! LIST of symbols to implement
-
-! Pixeltype table and objects
-
-GP_PixelTypes - FIX
-
-! IN Context class
-
-GP_ContextAlloc C
-GP_ContextResize C
-GP_ContextConvertAlloc C
-GP_ContextPrintInfo N
-GP_ContextRotateCCW C
-GP_SubContextAlloc C
-GP_ContextConvert N
-GP_ContextRotateCW C
-GP_ContextFree Ci
-GP_ContextInit N
-GP_SubContext N
-GP_ContextCopy C
-GP_PixelAddrOffset N
-
-! ?
-
-# GP_GammaRelease
-# GP_GammaCopy
-# GP_GammaAcquire
-
-! ?
-
-# GP_DebugPrint
-# GP_SetDebugLevel
-# GP_GetDebugLevel
-
-! Color conversion
-
-GP_RGBA8888ToPixel N
-GP_RGB888ToPixel N
-GP_PixelToRGB888
-GP_PixelToRGBA8888
-GP_ColorNameToPixel
-GP_ColorToPixel
-
-GP_PixelTypeByName - reimplement
-
-# GP_PixelRGBMatch
-# GP_ColorLoadPixels
-# GP_PixelRGBLookup
-# GP_ColorNameToColor
-# GP_ColorToColorName
-
-! IN Context class
-
-Blit - reimplement with keyword args, no raw
-
-# GP_BlitXYXY
-# GP_BlitXYXY_Fast
-# GP_BlitXYWH
-# GP_BlitXYWH_Clipped
-# GP_BlitXYXY_Clipped
-# GP_BlitXYXY_Raw_Fast
-# GP_BlitXYWH_Raw
-# GP_BlitXYXY_Raw
-
-! Do not want
-
-# GP_WritePixels_1BPP_LE
-# GP_WritePixels_2BPP_LE
-# GP_WritePixels_4BPP_LE
-# GP_WritePixels1bpp
-# GP_WritePixels2bpp
-# GP_WritePixels4bpp
-# GP_WritePixels8bpp
-# GP_WritePixels16bpp
-# GP_WritePixels18bpp
-# GP_WritePixels32bpp
-# GP_WritePixels24bpp
-
-! IN Context - basic drawing
-
-GP_PutPixel C
-GP_GetPixel C
-
-! ?
-
-# GP_NrThreads
-# GP_NrThreadsSet
-# GP_ProgressCallbackMP
-# SWIG_exception
-"""
-
http://repo.or.cz/w/gfxprim.git/commit/9fd530170199db0cf53d4d4b7223f07b44c2…
commit 9fd530170199db0cf53d4d4b7223f07b44c2554d
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Dec 25 02:14:38 2012 +0100
core: pylib: GP_PixelTypes related access
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py
index cc4577d..4e90c66 100644
--- a/pylib/gfxprim/core/__init__.py
+++ b/pylib/gfxprim/core/__init__.py
@@ -149,7 +149,18 @@ def _init(module):
# every Context also points to C for convenience
extend(_context, name='C')(C)
- # Bulk import of functions - TODO: only import specified
+ # Arrays with pixel type info
+ module['PixelTypes'] = [c_core.GP_PixelTypes_access(i)
+ for i in range(C.PIXEL_MAX)]
+
+ module['PixelTypesDict'] = dict(((t.name, t) for t in module['PixelTypes']))
+
+ def PixelTypeByName(name):
+ "Return a PixelType descriptor by name, raise KeyError if no such type exists."
+ return module['PixelTypesDict'][name]
+ module['PixelTypeByName'] = PixelTypeByName
+
+ # Bulk import of functions
import_members(c_core, module, sub=strip_GP,
exclude=const_regexes + [
'^GP_Blitw+$',
diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i
index 6e1d017..c59ae6c 100644
--- a/pylib/gfxprim/core/core.i
+++ b/pylib/gfxprim/core/core.i
@@ -35,6 +35,14 @@ ERROR_ON_NULL(GP_ColorToColorName);
%import "GP_FnPerBpp.h"
%import "GP_FnPerBpp.gen.h"
+%inline %{
+const GP_PixelTypeDescription *GP_PixelTypes_access(GP_PixelType no)
+{
+ if (no < 0 || no >= GP_PIXEL_MAX) no = GP_PIXEL_UNKNOWN;
+ return &GP_PixelTypes[no];
+}
+%}
+
/*
* GP_Context wrapping
*/
http://repo.or.cz/w/gfxprim.git/commit/fb131160d2f7320ef2998d1165dab70a6ac2…
commit fb131160d2f7320ef2998d1165dab70a6ac2f97e
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Dec 25 01:40:24 2012 +0100
core: Explicit size of GP_PixelTypes
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h
index f40c8a6..d058ab3 100644
--- a/include/core/GP_Pixel.h
+++ b/include/core/GP_Pixel.h
@@ -114,7 +114,7 @@ typedef struct {
/*
* Array of size GP_PIXEL_MAX describing known pixel types
*/
-extern const GP_PixelTypeDescription const GP_PixelTypes[];
+extern const GP_PixelTypeDescription const GP_PixelTypes[GP_PIXEL_MAX];
#define GP_CHECK_VALID_PIXELTYPE(type) GP_CHECK(((type) > 0) && ((type) < GP_PIXEL_MAX), "Invalid PixelType %d", (type))
diff --git a/libs/core/GP_Pixel.gen.c.t b/libs/core/GP_Pixel.gen.c.t
index f41625b..8374856 100644
--- a/libs/core/GP_Pixel.gen.c.t
+++ b/libs/core/GP_Pixel.gen.c.t
@@ -2,7 +2,6 @@
%% block descr
Pixel type definitions and functions
-Do not include directly, use GP_Pixel.h
%% endblock
%% block body
@@ -13,7 +12,7 @@ Do not include directly, use GP_Pixel.h
/*
* Description of all known pixel types
*/
-const GP_PixelTypeDescription const GP_PixelTypes [] = {
+const GP_PixelTypeDescription const GP_PixelTypes [GP_PIXEL_MAX] = {
%% for pt in pixeltypes
/* GP_PIXEL_{{ pt.name }} */ {
.type = GP_PIXEL_{{ pt.name }},
http://repo.or.cz/w/gfxprim.git/commit/f5cecdf0ef17c206a2481873bedcb2b6178c…
commit f5cecdf0ef17c206a2481873bedcb2b6178ccefa
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Dec 25 01:39:30 2012 +0100
core: pylib: Pythonic Context.Blit
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py
index 3bf8d08..cc4577d 100644
--- a/pylib/gfxprim/core/__init__.py
+++ b/pylib/gfxprim/core/__init__.py
@@ -91,6 +91,26 @@ def _init(module):
extend_direct(_context, "Resize", c_core.GP_ContextResize,
"Resize the context bitmap (reallocate). Fails on subcontexts.")
+ # Blit
+
+ @extend(_context)
+ def Blit(self, sx, sy, target, tx, ty, w=None, h=None, sx2=None, sy2=None,
+ tx2=None, ty2=None):
+ """Copy a rectangle from self to target. (sx,sy) and (tx,ty) define
+ upper-left corners, rectangle size is given by (width, height), lower-right
+ corner in source or lower-right corner in the target. Clipped."""
+ assert sum([w is not None, sx2 is not None, tx2 is not None]) == 1
+ assert sum([h is not None, sy2 is not None, ty2 is not None]) == 1
+ if sx2 is not None:
+ w = max(0, sx2 - sx)
+ if tx2 is not None:
+ w = max(0, tx2 - tx)
+ if sy2 is not None:
+ h = max(0, sy2 - sy)
+ if ty2 is not None:
+ h = max(0, ty2 - ty)
+ return c_core.GP_BlitXYWH_Clipped(self, sx, sy, target, tx, ty, w, h)
+
# Color conversions
@extend(_context)
@@ -163,7 +183,7 @@ GP_ContextConvertAlloc C
GP_ContextPrintInfo N
GP_ContextRotateCCW C
GP_SubContextAlloc C
-GP_ContextConvert C
+GP_ContextConvert N
GP_ContextRotateCW C
GP_ContextFree Ci
GP_ContextInit N
@@ -190,10 +210,10 @@ GP_RGB888ToPixel N
GP_PixelToRGB888
GP_PixelToRGBA8888
GP_ColorNameToPixel
+GP_ColorToPixel
GP_PixelTypeByName - reimplement
-# GP_ColorToPixel
# GP_PixelRGBMatch
# GP_ColorLoadPixels
# GP_PixelRGBLookup
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Pixel.h | 2 +-
libs/core/GP_Pixel.gen.c.t | 3 +-
pylib/gfxprim/core/__init__.py | 147 +++++++++++-----------------------------
pylib/gfxprim/core/core.i | 8 ++
4 files changed, 50 insertions(+), 110 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: 77ca5e065797236b928b1ee5a3e869c564620191
by metan 25 Dec '12
by metan 25 Dec '12
25 Dec '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 77ca5e065797236b928b1ee5a3e869c564620191 (commit)
via e8c9a59408d797c9f58085f0656450d4993005cc (commit)
from 33b95fd86ead735cd54f3b0f7cf87c779a4370ad (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/77ca5e065797236b928b1ee5a3e869c56462…
commit 77ca5e065797236b928b1ee5a3e869c564620191
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Dec 25 02:17:09 2012 +0100
gfx: VLine: Fix the VLine implementation.
diff --git a/build/syms/GFX_symbols.txt b/build/syms/GFX_symbols.txt
index c8482d3..d6ed889 100644
--- a/build/syms/GFX_symbols.txt
+++ b/build/syms/GFX_symbols.txt
@@ -5,37 +5,21 @@ GP_HLine_Raw_32BPP
GP_LineAA
GP_Line_Raw_32BPP
GP_HLineXYW_Raw
-GP_VLine_18BPP_LE
-GP_VLine_8BPP
-GP_VLine_1BPP_LE
GP_HLine_Raw_8BPP
-GP_VLineAA
GP_HLineAA
-GP_VLine_4BPP_BE
GP_HLineXYW
-GP_VLineAA_Raw
-GP_VLine_16BPP
GP_HLine_Raw_1BPP_LE
-GP_VLine_2BPP_LE
-GP_VLine_24BPP
GP_HLine_Raw_4BPP_BE
GP_HLine_Raw_2BPP_BE
GP_HLine_Raw_24BPP
GP_Line_Raw_24BPP
GP_Line_Raw_1BPP_BE
-GP_VLineXYH_Raw
-GP_VLine_4BPP_LE
-GP_VLine_32BPP
GP_HLineXXY
GP_HLine_Raw_4BPP_LE
GP_Line_Raw_18BPP_LE
GP_Line_Raw_1BPP_LE
-GP_VLineXYY_Raw
GP_Line_Raw_4BPP_BE
-GP_VLineXYY
-GP_VLineXYH
GP_HLineXXY_Raw
-GP_VLine_2BPP_BE
GP_HLine_Raw_1BPP_BE
GP_Line
GP_Line_Raw_8BPP
@@ -46,7 +30,24 @@ GP_Line_Raw_16BPP
GP_HLine_Raw_2BPP_LE
GP_HLine_Raw_16BPP
GP_LineAA_Raw
-GP_VLine_1BPP_BE
+
+GP_VLineXYY_Raw
+GP_VLineAA
+GP_VLineAA_Raw
+GP_VLineXYH_Raw
+GP_VLineXYY
+GP_VLineXYH
+GP_VLine_Raw_16BPP
+GP_VLine_Raw_1BPP_LE
+GP_VLine_Raw_18BPP_LE
+GP_VLine_Raw_2BPP_BE
+GP_VLine_Raw_4BPP_BE
+GP_VLine_Raw_8BPP
+GP_VLine_Raw_2BPP_LE
+GP_VLine_Raw_32BPP
+GP_VLine_Raw_4BPP_LE
+GP_VLine_Raw_24BPP
+GP_VLine_Raw_1BPP_BE
GP_Circle
GP_Circle_Raw
@@ -112,3 +113,4 @@ GP_FillRectXYWH_AA_Raw
GP_AngleInRange
GP_NormalizeAngle
+
diff --git a/include/Makefile b/include/Makefile
index f098ae0..f41af14 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -1,3 +1,3 @@
TOPDIR=..
-SUBDIRS=core
+SUBDIRS=core gfx
include $(TOPDIR)/post.mk
diff --git a/include/gfx/GP_VLine.gen.h.t b/include/gfx/GP_VLine.gen.h.t
new file mode 100644
index 0000000..296e69a
--- /dev/null
+++ b/include/gfx/GP_VLine.gen.h.t
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+%% extends 'base.h.t'
+
+{% block description %}VLine generated header{% endblock %}
+
+{% block body %}
+
+%% for ps in pixelsizes
+void GP_VLine_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord x,
+ GP_Coord y0, GP_Coord y1, GP_Pixel pixel);
+
+%% endfor
+
+{% endblock body %}
diff --git a/include/gfx/GP_VLine.h b/include/gfx/GP_VLine.h
index a070f53..269d57a 100644
--- a/include/gfx/GP_VLine.h
+++ b/include/gfx/GP_VLine.h
@@ -19,49 +19,17 @@
* Copyright (C) 2009-2011 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> *
* *
*****************************************************************************/
-#ifndef GP_VLINE_H
-#define GP_VLINE_H
+#ifndef GFX_GP_VLINE_H
+#define GFX_GP_VLINE_H
#include "core/GP_Context.h"
/* Raw per BPP HLines */
-
-void GP_VLine_Raw_1BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_VLine_Raw_1BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_VLine_Raw_2BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_VLine_Raw_2BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_VLine_Raw_4BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_VLine_Raw_4BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_VLine_Raw_8BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_VLine_Raw_18BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_VLine_Raw_16BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_VLine_Raw_24BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_VLine_Raw_32BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
+#include "gfx/GP_VLine.gen.h"
void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0,
GP_Coord y1, GP_Pixel pixel);
@@ -88,4 +56,4 @@ static inline void GP_VLine_Raw(GP_Context *context, GP_Coord x,
GP_VLineXYY_Raw(context, x, y0, y1, pixel);
}
-#endif /* GP_VLINE_H */
+#endif /* GFX_GP_VLINE_H */
diff --git a/include/gfx/Makefile b/include/gfx/Makefile
new file mode 100644
index 0000000..7548d55
--- /dev/null
+++ b/include/gfx/Makefile
@@ -0,0 +1,8 @@
+TOPDIR=../..
+
+include $(TOPDIR)/pre.mk
+
+GENHEADERS=GP_VLine.gen.h
+
+include $(TOPDIR)/gen.mk
+include $(TOPDIR)/post.mk
diff --git a/libs/gfx/GP_VLine.c b/libs/gfx/GP_VLine.c
index 910033d..08d075c 100644
--- a/libs/gfx/GP_VLine.c
+++ b/libs/gfx/GP_VLine.c
@@ -23,23 +23,35 @@
* *
*****************************************************************************/
+#include "core/GP_Common.h"
#include "core/GP_GetPutPixel.h"
#include "core/GP_FnPerBpp.h"
#include "gfx/GP_VLine.h"
#include "gfx/GP_HLine.h"
-#include "algo/VLine.algo.h"
-
-/* Generate drawing functions for various bit depths. */
-GP_DEF_DRAW_FN_PER_BPP(GP_VLine, DEF_VLINE_FN)
+/*
+ * Ensures that coordinates are in correct order, and clips them.
+ * Exits immediately if the line is completely clipped out.
+ */
+#define ORDER_AND_CLIP_COORDS do { + if (y0 > y1) + GP_SWAP(y0, y1); + if (x < 0 || x >= (int) context->w || + y1 < 0 || y0 >= (int) context->h) + return; + y0 = GP_MAX(y0, 0); + y1 = GP_MIN(y1, (int) context->h - 1); +} while (0)
void GP_VLineXYY_Raw(GP_Context *context, GP_Coord x, GP_Coord y0,
GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
+
+ ORDER_AND_CLIP_COORDS;
- GP_FN_PER_BPP_CONTEXT(GP_VLine, context, context, x, y0, y1, pixel);
+ GP_FN_PER_BPP_CONTEXT(GP_VLine_Raw, context, context, x, y0, y1, pixel);
}
void GP_VLineXYH_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size h,
diff --git a/libs/gfx/GP_VLine.gen.c.t b/libs/gfx/GP_VLine.gen.c.t
new file mode 100644
index 0000000..8700d8f
--- /dev/null
+++ b/libs/gfx/GP_VLine.gen.c.t
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+%% extends 'base.h.t'
+
+{% block description %}Vertical Line{% endblock %}
+
+{% block body %}
+
+#include "core/GP_GetPutPixel.h"
+#include "gfx/GP_VLine.gen.h"
+
+%% for ps in pixelsizes
+void GP_VLine_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord x,
+ GP_Coord y0, GP_Coord y1, GP_Pixel pixel)
+{
+ int y;
+
+ for (y = y0; y <= y1; y++)
+ GP_PutPixel_Raw_{{ ps.suffix }}(context, x, y, pixel);
+}
+
+%% endfor
+
+{% endblock body %}
diff --git a/libs/gfx/Makefile b/libs/gfx/Makefile
index d80e49a..e46a8ef 100644
--- a/libs/gfx/Makefile
+++ b/libs/gfx/Makefile
@@ -1,7 +1,7 @@
TOPDIR=../..
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
GENSOURCES=GP_Line.gen.c GP_HLine.gen.c GP_LineAA.gen.c GP_PutPixelAA.gen.c - GP_HLineAA.gen.c GP_VLineAA.gen.c GP_FillCircle.gen.c
+ GP_HLineAA.gen.c GP_VLineAA.gen.c GP_FillCircle.gen.c GP_VLine.gen.c
LIBNAME=gfx
include $(TOPDIR)/pre.mk
diff --git a/libs/gfx/algo/VLine.algo.h b/libs/gfx/algo/VLine.algo.h
deleted file mode 100644
index b33a448..0000000
--- a/libs/gfx/algo/VLine.algo.h
+++ /dev/null
@@ -1,60 +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-2011 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-/* A vertical line drawing algorithm. */
-
-/* Ensures that coordinates are in correct order, and clips them.
- * Exits immediately if the line is completely clipped out.
- */
-#define ORDER_AND_CLIP_COORDS do { - if (y0 > y1) - GP_SWAP(y0, y1); - if (x < 0 || x >= (int) context->w || - y1 < 0 || y0 >= (int) context->h) - return; - y0 = GP_MAX(y0, 0); - y1 = GP_MIN(y1, (int) context->h - 1); -} while (0)
-
-/*
- * This macro defines a horizontal line drawing function.
- * Arguments:
- * CONTEXT_T - user-defined type of drawing context (passed to PUTPIXEL)
- * PIXVAL_T - user-defined pixel value type (passed to PUTPIXEL)
- * PIXEL_ADDRESS - a function that returns a pointer to a pixel in memory,
- * in form f(context, y, x)
- * WRITE_PIXELS - a function that fills a linear block with pixel value,
- * in form f(start, length, pixel)
- * FN_NAME - name of the function to be defined
- */
-#define DEF_VLINE_FN(FN_NAME, CONTEXT_T, PIXEL_T, PUT_PIXEL) -void FN_NAME(CONTEXT_T context, int x, int y0, int y1, PIXEL_T pixel) -{ - ORDER_AND_CLIP_COORDS; - int y; -- for (y = y0; y <= y1; y++) - PUT_PIXEL(context, x, y, pixel); -}
http://repo.or.cz/w/gfxprim.git/commit/e8c9a59408d797c9f58085f0656450d49930…
commit e8c9a59408d797c9f58085f0656450d4993005cc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Dec 25 01:23:10 2012 +0100
core: WritePixel: Small cleanup first.
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h
index f40c8a6..3b9d254 100644
--- a/include/core/GP_Pixel.h
+++ b/include/core/GP_Pixel.h
@@ -61,7 +61,6 @@ typedef uint32_t GP_Pixel;
* Information about ordering of pixels in byte for 1, 2 and 4 bpp
* used in a one bit variable in GP_Context
*/
-
typedef enum {
/* less significant bits contain pixels with lower indices */
/* also used for irrelevant bit-endian */
@@ -80,7 +79,6 @@ typedef enum {
* A - opacity (0=transparent)
* P - palette (index)
*/
-
typedef struct {
char name[8]; /* Channel name */
uint8_t offset; /* Offset in bits */
@@ -90,7 +88,6 @@ typedef struct {
/*
* Maximum number of channels in a PixelType
*/
-
#define GP_PIXELTYPE_MAX_CHANNELS 8
/*
@@ -98,7 +95,6 @@ typedef struct {
* Assumes name with at most 15 chars
* Assumes at most 8 channels
*/
-
typedef struct {
GP_PixelType type; /* Number of the type */
const char name[16]; /* Name */
diff --git a/include/core/GP_WritePixel.h b/include/core/GP_WritePixel.h
index d9530f9..bb79b1f 100644
--- a/include/core/GP_WritePixel.h
+++ b/include/core/GP_WritePixel.h
@@ -16,15 +16,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2012 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
* Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-#ifndef GP_WRITEPIXEL_H
-#define GP_WRITEPIXEL_H
+#ifndef CORE_GP_WRITEPIXEL_H
+#define CORE_GP_WRITEPIXEL_H
#include <stdint.h>
#include <unistd.h>
@@ -52,10 +52,20 @@ void GP_WritePixels_4BPP_LE(uint8_t *start, uint8_t off,
/*
* These calls are not byte aligned, thus need start offset.
*/
-void GP_WritePixels_1BPP_BE(uint8_t *start, uint8_t off, size_t cnt, uint8_t val);
-void GP_WritePixels_2BPP_BE(uint8_t *start, uint8_t off, size_t cnt, uint8_t val);
-void GP_WritePixels_4BPP_BE(uint8_t *start, uint8_t off, size_t cnt, uint8_t val);
-void GP_WritePixels_18BPP_BE(void *start, uint8_t off, size_t count, uint32_t value);
+void GP_WritePixels_1BPP_BE(uint8_t *start, uint8_t off,
+ size_t cnt, uint8_t val);
+
+void GP_WritePixels_2BPP_BE(uint8_t *start, uint8_t off,
+ size_t cnt, uint8_t val);
+
+void GP_WritePixels_4BPP_BE(uint8_t *start, uint8_t off,
+ size_t cnt, uint8_t val);
+
+void GP_WritePixels_18BPP_BE(void *start, uint8_t off,
+ size_t count, uint32_t value);
+
+void GP_WritePixels_18BPP_LE(void *start, uint8_t off,
+ size_t count, uint32_t value);
/* Byte-aligned calls. */
void GP_WritePixels_8BPP(void *start, size_t count, uint8_t value);
@@ -63,14 +73,4 @@ void GP_WritePixels_16BPP(void *start, size_t count, uint16_t value);
void GP_WritePixels_24BPP(void *start, size_t count, uint32_t value);
void GP_WritePixels_32BPP(void *start, size_t count, uint32_t value);
-/* aliases for older names */
-#define GP_WritePixels1bpp GP_WritePixels_1BPP_BE
-#define GP_WritePixels2bpp GP_WritePixels_2BPP_BE
-#define GP_WritePixels4bpp GP_WritePixels_4BPP_BE
-#define GP_WritePixels18bpp GP_WritePixels_18BPP_BE
-#define GP_WritePixels8bpp GP_WritePixels_8BPP
-#define GP_WritePixels16bpp GP_WritePixels_16BPP
-#define GP_WritePixels24bpp GP_WritePixels_24BPP
-#define GP_WritePixels32bpp GP_WritePixels_32BPP
-
-#endif /* GP_WRITEPIXEL_H */
+#endif /* CORE_GP_WRITEPIXEL_H */
diff --git a/tests/core/WritePixel_testsuite.gen.c.t b/tests/core/WritePixel_testsuite.gen.c.t
index df49d2d..0807e0f 100644
--- a/tests/core/WritePixel_testsuite.gen.c.t
+++ b/tests/core/WritePixel_testsuite.gen.c.t
@@ -93,7 +93,7 @@ static int WritePixel{{ "_%i_%i_%i_%i"|format(pixelsize, offset, len, aligment)
%% endfor
%% endfor
- GP_WritePixels{{ pixelsize }}bpp(write_buf + {{aligment + offset * pixelsize//8}}, {{ len }}, 0xffffffff>>{{32 - pixelsize}});
+ GP_WritePixels_{{ pixelsize }}BPP(write_buf + {{aligment + offset * pixelsize//8}}, {{ len }}, 0xffffffff>>{{32 - pixelsize}});
COMPARE_BUFFERS({{""p=%i o=%i l=%i a=%i""|format(pixelsize, offset, len, aligment)}}, write_buf, gen_buf);
}
-----------------------------------------------------------------------
Summary of changes:
build/syms/GFX_symbols.txt | 36 ++++++------
include/Makefile | 2 +-
include/core/GP_Pixel.h | 4 -
include/core/GP_WritePixel.h | 36 ++++++------
.../GP_InputDriverX11.h => gfx/GP_VLine.gen.h.t} | 20 +++----
include/gfx/GP_VLine.h | 42 ++------------
include/gfx/Makefile | 8 +++
libs/gfx/GP_VLine.c | 22 ++++++--
.../gfx/GP_VLine.gen.c.t | 24 +++++---
libs/gfx/Makefile | 2 +-
libs/gfx/algo/VLine.algo.h | 60 --------------------
tests/core/WritePixel_testsuite.gen.c.t | 2 +-
12 files changed, 94 insertions(+), 164 deletions(-)
copy include/{input/GP_InputDriverX11.h => gfx/GP_VLine.gen.h.t} (86%)
create mode 100644 include/gfx/Makefile
copy include/filters/GP_LinearThreads.h => libs/gfx/GP_VLine.gen.c.t (79%)
delete mode 100644 libs/gfx/algo/VLine.algo.h
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