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: 301969902482047daf10a8d766ddadef816cba8c
by metan 31 Dec '12
by metan 31 Dec '12
31 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 301969902482047daf10a8d766ddadef816cba8c (commit)
via 8767e9dbd7ebcb8929ce9ab5c6faf168e6ae240a (commit)
from 10ac58d34771e81c0c00f1e5d6d812427af2c2d8 (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/301969902482047daf10a8d766ddadef816c…
commit 301969902482047daf10a8d766ddadef816cba8c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Dec 31 21:40:32 2012 +0100
doc: Customize the html header and footer.
diff --git a/doc/api.txt b/doc/api.txt
index 4a75fd4..f005a82 100644
--- a/doc/api.txt
+++ b/doc/api.txt
@@ -1,7 +1,3 @@
-GFXprim Documentation
-=====================
-Cyril Hrubis <metan(a)ucw.cz>
-
GFXprim API
-----------
diff --git a/doc/asciidoc.conf b/doc/asciidoc.conf
index f5f7361..bc30e9a 100644
--- a/doc/asciidoc.conf
+++ b/doc/asciidoc.conf
@@ -1,5 +1,110 @@
[attributes]
-# link css instead of copying it into each file
-linkcss
+# use image icons
icons
-max-width=50em
+
+[header]
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{lang=en}">
+<head>
+<meta http-equiv="Content-Type" content="{quirks=application/xhtml+xml}{quirks?text/html}; charset={encoding}" />
+<meta name="generator" content="AsciiDoc {asciidoc-version}" />
+<meta name="description" content="{description}" />
+<meta name="keywords" content="{keywords}" />
+<title>{title}</title>
+{title%}<title>{doctitle=}</title>
+<link rel="stylesheet" href="{stylesdir=.}/{theme=asciidoc}.css" type="text/css" />
+{doctype-manpage}<link rel="stylesheet" href="{stylesdir=.}/{theme=asciidoc}-manpage.css" type="text/css" />
+ifdef::quirks[]
+<link rel="stylesheet" href="{stylesdir=.}/xhtml11-quirks.css" type="text/css" />
+endif::quirks[]
+ifdef::pygments[<link rel="stylesheet" href="{stylesdir=.}/pygments.css" type="text/css" />]
+ifdef::toc2[<link rel="stylesheet" href="{stylesdir=.}/toc2.css" type="text/css" />]
+<link rel="stylesheet" href="{stylesdir=.}/{stylesheet}" type="text/css" />
+ifndef::disable-javascript[]
+<script type="text/javascript" src="{scriptsdir=.}/asciidoc.js"></script>
+<script type="text/javascript">
+# Escape as CDATA to pass validators.
+/*<![CDATA[*/
+asciidoc.install({toc,toc2?{toclevels}});
+/*]]>*/
+</script>
+endif::disable-javascript[]
+ifdef::asciimath[]
+<script type="text/javascript" src="{scriptsdir=.}/ASCIIMathML.js"></script>
+endif::asciimath[]
+ifdef::latexmath[]
+<script type="text/javascript" src="{scriptsdir=.}/LaTeXMathML.js"></script>
+endif::latexmath[]
+{docinfo1,docinfo2#}{include:{docdir}/docinfo.html}
+{docinfo,docinfo2#}{include:{docdir}/{docname}-docinfo.html}
+</head>
+<body class="{doctype}" style="max-width:55em; margin-left: auto; margin-right: auto;">
+# Article, book header.
+<div class="logo">
+<h1>GFXprim documentation</h1>
+</div>
+ifndef::doctype-manpage[]
+<div id="header">
+ifndef::notitle[<h1>{doctitle}</h1>]
+ifdef::doctitle[]
+<span id="author">{author}</span><br />
+<span id="email"><tt><<a href="mailto:{email}">{email}</a>></tt></span><br />
+<span id="revnumber">version {revnumber}{revdate?,}</span>
+<span id="revdate">{revdate}</span>
+<br /><span id="revremark">{revremark}</span>
+endif::doctitle[]
+ifdef::toc,toc2[{template:toc}]
+</div>
+endif::doctype-manpage[]
+# Man page header.
+ifdef::doctype-manpage[]
+<div id="header">
+<h1>
+{doctitle} Manual Page
+</h1>
+ifdef::toc,toc2[{template:toc}]
+<h2>{manname-title}</h2>
+<div class="sectionbody">
+<p>{manname} -
+ {manpurpose}
+</p>
+</div>
+</div>
+endif::doctype-manpage[]
+<div class="content">
+
+[footer]
+<div id="footer">
+<div id="footer-text">
+template::[footer-text]
+</div>
+ifdef::badges[]
+<div id="footer-badges">
+ifndef::icons[]
+Valid <a href="http://validator.w3.org/check?uri=referer">XHTML</a>
+and <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>.
+endif::icons[]
+ifdef::icons[]
+<a href="http://validator.w3.org/check?uri=referer">
+ <img style="border:0;width:88px;height:31px"
+ src="http://www.w3.org/Icons/valid-xhtml11-blue"
+ alt="Valid XHTML 1.1" height="31" width="88" />
+</a>
+<a href="http://jigsaw.w3.org/css-validator/">
+ <img style="border:0;width:88px;height:31px"
+ src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
+ alt="Valid CSS!" />
+</a>
+<a href="http://www.mozilla.org/products/firefox/">
+ <img style="border:none; width:110px; height:32px;"
+ src="http://www.spreadfirefox.com/community/images/affiliates/Buttons/110x32/saf…"
+ alt="Get Firefox!" />
+</a>
+endif::icons[]
+</div>
+endif::badges[]
+</div>
+</div>
+</body>
+</html>
diff --git a/doc/asciidoc.css b/doc/asciidoc.css
index 1475be7..4b19932 100644
--- a/doc/asciidoc.css
+++ b/doc/asciidoc.css
@@ -3,6 +3,7 @@
/* Default font. */
body {
font-family: Georgia,serif;
+ background: white;
}
/* Title font. */
@@ -113,6 +114,14 @@ pre {
margin-top: 1.5em;
margin-bottom: 1.5em;
}
+
+div.logo h1 {
+ border-bottom: 0px;
+ margin-top: 1em;
+ margin-bottom: 0em;
+ color: gray;
+}
+
div.imageblock, div.exampleblock, div.verseblock,
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
div.admonitionblock {
@@ -127,7 +136,7 @@ div.admonitionblock {
}
div.content { /* Block element content. */
- padding: 0;
+ padding: 0em;
}
/* Block element titles. */
http://repo.or.cz/w/gfxprim.git/commit/8767e9dbd7ebcb8929ce9ab5c6faf168e6ae…
commit 8767e9dbd7ebcb8929ce9ab5c6faf168e6ae240a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Dec 31 21:39:51 2012 +0100
doc: gen: Fix typo and scale down the images.
diff --git a/doc/gen.txt b/doc/gen.txt
index 830a0d4..cac6b9d 100644
--- a/doc/gen.txt
+++ b/doc/gen.txt
@@ -74,6 +74,7 @@ BE
["graphviz", "bit-endian-be-1bit.png"]
------------------------------------------------------------------------------
digraph bit_endian {
+ graph [ dpi = 70 ];
node [shape = record];
rankdir = LR;
@@ -93,6 +94,7 @@ digraph bit_endian {
["graphviz", "bit-endian-be-2bits.png"]
------------------------------------------------------------------------------
digraph bit_endian {
+ graph [ dpi = 70 ];
node [shape = record];
rankdir = LR;
@@ -115,6 +117,7 @@ LE
["graphviz", "bit-endian-le-1bit.png"]
------------------------------------------------------------------------------
digraph bit_endian {
+ graph [ dpi = 70 ];
node [shape = record];
rankdir = LR;
@@ -134,6 +137,7 @@ digraph bit_endian {
["graphviz", "bit-endian-le-2bits.png"]
------------------------------------------------------------------------------
digraph bit_endian {
+ graph [ dpi = 70 ];
node [shape = record];
rankdir = LR;
@@ -220,7 +224,7 @@ Jinja2 basics:
'variable' or 'expression'
- 'Variable' is text enclosed between +{{+ and +}}+
- * +{{ ps.size }}' or +{{ ps.suffix }}+
+ * +{{ ps.size }}+ or +{{ ps.suffix }}+
* +{{ 2 ** i }}+
* +{{ int(2 ** (7 - i)) }} >> {{ 8 - i }}+
-----------------------------------------------------------------------
Summary of changes:
doc/api.txt | 4 --
doc/asciidoc.conf | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++-
doc/asciidoc.css | 11 +++++-
doc/gen.txt | 6 ++-
4 files changed, 123 insertions(+), 9 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 10ac58d34771e81c0c00f1e5d6d812427af2c2d8
by metan 31 Dec '12
by metan 31 Dec '12
31 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 10ac58d34771e81c0c00f1e5d6d812427af2c2d8 (commit)
from fd131ab40d827e66825dfe9202e2e02021ba07c1 (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/10ac58d34771e81c0c00f1e5d6d812427af2…
commit 10ac58d34771e81c0c00f1e5d6d812427af2c2d8
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Dec 31 17:28:54 2012 +0100
doc: backends, coding_style: Typos and fixes.
diff --git a/doc/backends.txt b/doc/backends.txt
index a4fb226..aca70f6 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -7,7 +7,8 @@ initialization interface each backend has it's specific function and semantics
but once backend is initialized the backend structure provides unified API for
controlling the drawing.
-So far there are backends for Linux mmaped frame-buffer, libSDL and X11.
+So far there are backends for Linux mmaped 'frame-buffer', 'libSDL' and
+'X Window System'.
TIP: For example usage see backend link:example_backend.html[example].
@@ -220,9 +221,9 @@ WARNING: It's very important to call this functions on application exit. If you
doesn't do so, the state of the display, resolution etc. may not be
reset back to its original state. This includes program crashes and
iterruptions. Also this function may not be signal-async-safe, it's
- better to set signal hanlers that calls it as this usually works and
- not doing so may leave non-working system with black display or
- non-responding keyboard.
+ better to set signal hanlers that calls it on SEGFAULT and SIGBUS
+ as this usually works and not doing so may leave non-working system
+ with black display or non-responding keyboard.
[source,c]
-------------------------------------------------------------------------------
@@ -273,14 +274,16 @@ void GP_BackendWait(GP_Backend *backend);
Blocks until backend event arrives.
-NOTE: Events recieved by backend are not necessarily translated into the input
- events.
+[NOTE]
+Events recieved by backend are not necessarily translated into the input
+events.
-WARNING: Using GP_BackendWait() in multithreaded program will most likely
- cause deadlocks. As the backend data structures and connection is
- guarded by a lock any other backend function (called from different
- thread while GP_BackendWait() is blocking) will lock until
- GP_BackendWait() returns (i.e. event was recieved).
+[WARNING]
+Using GP_BackendWait() in multithreaded program will most likely cause
+deadlocks. As the backend data structures and connection is guarded by a lock
+any other backend function (called from different thread while
+GP_BackendWait() is blocking) will lock until GP_BackendWait() returns (i.e.
+event was recieved).
[source,c]
-------------------------------------------------------------------------------
@@ -326,4 +329,4 @@ multithreaded application where one threads waits for events and others draws
into the buffer so you can stop the drawing threads before the backend context
size change.
-See input link:input.html[input events] for more information.
+TIP: For more information see link:input.html[input events] documentation.
diff --git a/doc/coding_style.txt b/doc/coding_style.txt
index 37bb19e..b4afeaf 100644
--- a/doc/coding_style.txt
+++ b/doc/coding_style.txt
@@ -19,7 +19,7 @@ enligthening reading).
* We use tabs for indentation and tab is eight spaces wide.
-* Lines should be maximally 80 chars long.
+* Lines should be at most 80 chars long.
* No additional whitespaces (other than newline) at the end of line.
@@ -101,26 +101,26 @@ break;
}
----
-TIP: You can use Linux Kernel +scripts/checkpatch.pl+ to check your code.
+TIP: You can use Linux Kernel 'scripts/checkpatch.pl' to check your code.
GFXprim Specific Rules
^^^^^^^^^^^^^^^^^^^^^^
* Library external API uses CamelCase
-** Together with mandatory +GP_+ prefix.
-** For example +GP_PixelType+, +GP_Context+, etc.
+** Together with mandatory 'GP_' prefix.
+** For example 'GP_PixelType', 'GP_Context', etc.
** We will not change that, get over it. (It could have been worse, trust me.)
* Basic library types are typedefed
-** We have +GP_Size+ and +GP_Coord+ integer types to better distinguish
+** We have 'GP_Size' and 'GP_Coord' integer types to better distinguish
roles of function parameters.
-** The basic structures are also typedefed so you can wite +GP_Context+
- instead of +struct GP_Context+.
+** The basic structures are also typedefed so you can wite 'GP_Context'
+ instead of 'struct GP_Context'.
** Other uses of typedef are frowned upon.
-* When you add a externally symbol visible symbol, i.e. new API function
- please add its name into the corresponding file at +build/syms/+. You may
- also run the +buld/check_symbols.sh+ script to check that you haven't
+* When you add an externally visible symbol, i.e. new API function
+ please add its name into the corresponding file at 'build/syms/'. You may
+ also run the 'buld/check_symbols.sh' script to check that you haven't
accidentally exposed intenal only interfaces.
Python Coding Style
-----------------------------------------------------------------------
Summary of changes:
doc/backends.txt | 27 +++++++++++++++------------
doc/coding_style.txt | 20 ++++++++++----------
2 files changed, 25 insertions(+), 22 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: fd131ab40d827e66825dfe9202e2e02021ba07c1
by metan 31 Dec '12
by metan 31 Dec '12
31 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 fd131ab40d827e66825dfe9202e2e02021ba07c1 (commit)
from 526d3b35fea6668250aaf0f6a71303bd46adba45 (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/fd131ab40d827e66825dfe9202e2e02021ba…
commit fd131ab40d827e66825dfe9202e2e02021ba07c1
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Dec 31 17:08:21 2012 +0100
doc: Add coding style document.
diff --git a/doc/Makefile b/doc/Makefile
index bbb1ab0..23d87e7 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 coordinate_system.txt
+ gen.txt pixels.txt coordinate_system.txt coding_style.txt
EXAMPLE_SOURCES=$(wildcard example_*.txt)
diff --git a/doc/api.txt b/doc/api.txt
index 7d4898a..4a75fd4 100644
--- a/doc/api.txt
+++ b/doc/api.txt
@@ -80,3 +80,11 @@ GFXprim Internals
Describes structure and basic usage of the templating engine (C code
generator).
+
+
+Development
+-----------
+
+. link:coding_style.html[Coding Style]
+ +
+ C and Python coding style.
+ +
diff --git a/doc/coding_style.txt b/doc/coding_style.txt
new file mode 100644
index 0000000..37bb19e
--- /dev/null
+++ b/doc/coding_style.txt
@@ -0,0 +1,129 @@
+Coding Style
+------------
+
+This document defines coding style for GFXprim.
+
+C Coding Style
+~~~~~~~~~~~~~~
+
+GFXprim is written in C. There is no C++ code in and I mean it. A few headers
+do contain '#ifndef __cplusplus' so that you can interface GFXprim headers as
+'extern C' without problems. If this doesn't work, let us know.
+
+GFXprim follows mostly Linux Kernel coding style, see
+'Documentation/CodingStyle' in the Linux Kernel source or follow this
+link:http://www.kernel.org/doc/Documentation/CodingStyle[link] (it's funny and
+enligthening reading).
+
+.Indentation and whitespaces
+
+* We use tabs for indentation and tab is eight spaces wide.
+
+* Lines should be maximally 80 chars long.
+
+* No additional whitespaces (other than newline) at the end of line.
+
+* Each file must end with newline (most editors do that automatically, beware
+ of Kate).
+
+.Braces and Spaces
+
+* Avoid tricky expressions if possible ;)
+
+* Do not put multiple statements on a single line.
++
+[source,c]
+----
+/* WRONG */
+if (something) do_work();
+ do_other();
+
+/* RIGHT */
+if (something)
+ do_work();
+
+do_other();
+----
+
+* Each block that has more than one line should be enclosed in
+ curly braces.
++
+Also if one part of if then else is enclosed in
+curly braces the other one should be enclosed too.
++
+[source,c]
+----
+/* WRONG */
+if (something)
+ do_other_thing();
+ else if (something_else)
+ do_thing();
+ else
+ return;
+
+/* RIGHT */
+if (something) {
+ do_other_thing();
+} else {
+ if (something_else)
+ do_thing();
+ else
+ return;
+}
+----
+
+* On the other hand do not use braces unnecesarily.
++
+[source,c]
+----
+/* WRONG */
+if (something) {
+ do_work();
+}
+
+/* RIGHT */
+if (something)
+ do_work();
+----
+
+* The preffered way of writing switch is as follows:
++
+[source,c]
+----
+switch (var) {
+case XYZ:
+ do_something():
+break;
+case ABC:
+ return 1;
+default:
+break;
+}
+----
+
+TIP: You can use Linux Kernel +scripts/checkpatch.pl+ to check your code.
+
+GFXprim Specific Rules
+^^^^^^^^^^^^^^^^^^^^^^
+
+* Library external API uses CamelCase
+** Together with mandatory +GP_+ prefix.
+** For example +GP_PixelType+, +GP_Context+, etc.
+** We will not change that, get over it. (It could have been worse, trust me.)
+
+* Basic library types are typedefed
+** We have +GP_Size+ and +GP_Coord+ integer types to better distinguish
+ roles of function parameters.
+** The basic structures are also typedefed so you can wite +GP_Context+
+ instead of +struct GP_Context+.
+** Other uses of typedef are frowned upon.
+
+* When you add a externally symbol visible symbol, i.e. new API function
+ please add its name into the corresponding file at +build/syms/+. You may
+ also run the +buld/check_symbols.sh+ script to check that you haven't
+ accidentally exposed intenal only interfaces.
+
+Python Coding Style
+~~~~~~~~~~~~~~~~~~~
+
+TODO
-----------------------------------------------------------------------
Summary of changes:
doc/Makefile | 2 +-
doc/api.txt | 8 +++
doc/coding_style.txt | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 138 insertions(+), 1 deletions(-)
create mode 100644 doc/coding_style.txt
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 526d3b35fea6668250aaf0f6a71303bd46adba45
by metan 31 Dec '12
by metan 31 Dec '12
31 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 526d3b35fea6668250aaf0f6a71303bd46adba45 (commit)
from d15c6dd78c9e1605830aec10a58dad1dd4e7c39a (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/526d3b35fea6668250aaf0f6a71303bd46ad…
commit 526d3b35fea6668250aaf0f6a71303bd46adba45
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Dec 31 16:59:28 2012 +0100
doc: Edhance the html output.
diff --git a/doc/Makefile b/doc/Makefile
index 35c23aa..bbb1ab0 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -5,6 +5,8 @@ SOURCES=general.txt context.txt loaders.txt filters.txt basic_types.txt
EXAMPLE_SOURCES=$(wildcard example_*.txt)
+ASCIIDOC_PARAMS=--conf-file asciidoc.conf
+
#
# Names of generated images for cleanup
#
@@ -17,8 +19,11 @@ PAGES+=$(subst .txt,.html,$(EXAMPLE_SOURCES))
.PHONY: toolcheck clean
+
all: toolcheck examples.html $(PAGES) api.html
+$(PAGES): asciidoc.conf
+
#
# Check if we have all the needed tools
#
@@ -36,10 +41,10 @@ toolcheck:
# Create page for each part of API description
#
$(PAGES): %.html: %.txt
- asciidoc $<
+ asciidoc $(ASCIIDOC_PARAMS) $<
examples.html: examples.txt ../demos/c_simple/*.c ../demos/py_simple/*.py
- asciidoc -a toc examples.txt
+ asciidoc $(ASCIIDOC_PARAMS) -a toc examples.txt
#
# Clean up generated images
diff --git a/doc/asciidoc.conf b/doc/asciidoc.conf
new file mode 100644
index 0000000..f5f7361
--- /dev/null
+++ b/doc/asciidoc.conf
@@ -0,0 +1,5 @@
+[attributes]
+# link css instead of copying it into each file
+linkcss
+icons
+max-width=50em
diff --git a/doc/asciidoc.css b/doc/asciidoc.css
new file mode 100644
index 0000000..1475be7
--- /dev/null
+++ b/doc/asciidoc.css
@@ -0,0 +1,508 @@
+/* Shared CSS for AsciiDoc xhtml11 and html5 backends */
+
+/* Default font. */
+body {
+ font-family: Georgia,serif;
+}
+
+/* Title font. */
+h1, h2, h3, h4, h5, h6,
+div.title, caption.title,
+thead, p.table.header,
+#toctitle,
+#author, #revnumber, #revdate, #revremark,
+#footer {
+ font-family: Arial,Helvetica,sans-serif;
+}
+
+body {
+ margin: 1em 5% 1em 5%;
+}
+
+a {
+ color: blue;
+ text-decoration: underline;
+}
+a:visited {
+ color: fuchsia;
+}
+
+em {
+ font-style: italic;
+ color: navy;
+}
+
+strong {
+ font-weight: bold;
+ color: #083194;
+}
+
+h1, h2, h3, h4, h5, h6 {
+ color: #527bbd;
+ margin-top: 1.2em;
+ margin-bottom: 0.5em;
+ line-height: 1.3;
+}
+
+h1, h2, h3 {
+ border-bottom: 2px solid silver;
+}
+h2 {
+ padding-top: 0.5em;
+}
+h3 {
+ float: left;
+}
+h3 + * {
+ clear: left;
+}
+h5 {
+ font-size: 1.0em;
+}
+
+div.sectionbody {
+ margin-left: 0;
+}
+
+hr {
+ border: 1px solid silver;
+}
+
+p {
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+}
+
+ul, ol, li > p {
+ margin-top: 0;
+}
+ul > li { color: #aaa; }
+ul > li > * { color: black; }
+
+pre {
+ padding: 0;
+ margin: 0;
+}
+
+#author {
+ color: #527bbd;
+ font-weight: bold;
+ font-size: 1.1em;
+}
+#email {
+}
+#revnumber, #revdate, #revremark {
+}
+
+#footer {
+ font-size: small;
+ border-top: 2px solid silver;
+ padding-top: 0.5em;
+ margin-top: 4.0em;
+}
+#footer-text {
+ float: left;
+ padding-bottom: 0.5em;
+}
+#footer-badges {
+ float: right;
+ padding-bottom: 0.5em;
+}
+
+#preamble {
+ margin-top: 1.5em;
+ margin-bottom: 1.5em;
+}
+div.imageblock, div.exampleblock, div.verseblock,
+div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
+div.admonitionblock {
+ margin-top: 1.0em;
+ margin-bottom: 1.5em;
+}
+div.admonitionblock {
+ margin-top: 2.0em;
+ margin-bottom: 2.0em;
+ margin-right: 10%;
+ color: #606060;
+}
+
+div.content { /* Block element content. */
+ padding: 0;
+}
+
+/* Block element titles. */
+div.title, caption.title {
+ color: #527bbd;
+ font-weight: bold;
+ text-align: left;
+ margin-top: 1.0em;
+ margin-bottom: 0.5em;
+}
+div.title + * {
+ margin-top: 0;
+}
+
+td div.title:first-child {
+ margin-top: 0.0em;
+}
+div.content div.title:first-child {
+ margin-top: 0.0em;
+}
+div.content + div.title {
+ margin-top: 0.0em;
+}
+
+div.sidebarblock > div.content {
+ background: #ffffee;
+ border: 1px solid #dddddd;
+ border-left: 4px solid #f0f0f0;
+ padding: 0.5em;
+}
+
+div.listingblock > div.content {
+ border: 1px solid #dddddd;
+ border-left: 5px solid #f0f0f0;
+ background: #f8f8f8;
+ padding: 0.5em;
+}
+
+div.quoteblock, div.verseblock {
+ padding-left: 1.0em;
+ margin-left: 1.0em;
+ margin-right: 10%;
+ border-left: 5px solid #f0f0f0;
+ color: #777777;
+}
+
+div.quoteblock > div.attribution {
+ padding-top: 0.5em;
+ text-align: right;
+}
+
+div.verseblock > pre.content {
+ font-family: inherit;
+ font-size: inherit;
+}
+div.verseblock > div.attribution {
+ padding-top: 0.75em;
+ text-align: left;
+}
+/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
+div.verseblock + div.attribution {
+ text-align: left;
+}
+
+div.admonitionblock .icon {
+ vertical-align: top;
+ font-size: 1.1em;
+ font-weight: bold;
+ text-decoration: underline;
+ color: #527bbd;
+ padding-right: 0.5em;
+}
+div.admonitionblock td.content {
+ padding-left: 0.5em;
+ border-left: 3px solid #dddddd;
+}
+
+div.exampleblock > div.content {
+ border-left: 3px solid #dddddd;
+ padding-left: 0.5em;
+}
+
+div.imageblock div.content { padding-left: 0; }
+span.image img { border-style: none; }
+a.image:visited { color: white; }
+
+dl {
+ margin-top: 0.8em;
+ margin-bottom: 0.8em;
+}
+dt {
+ margin-top: 0.5em;
+ margin-bottom: 0;
+ font-style: normal;
+ color: navy;
+}
+dd > *:first-child {
+ margin-top: 0.1em;
+}
+
+ul, ol {
+ list-style-position: outside;
+}
+ol.arabic {
+ list-style-type: decimal;
+}
+ol.loweralpha {
+ list-style-type: lower-alpha;
+}
+ol.upperalpha {
+ list-style-type: upper-alpha;
+}
+ol.lowerroman {
+ list-style-type: lower-roman;
+}
+ol.upperroman {
+ list-style-type: upper-roman;
+}
+
+div.compact ul, div.compact ol,
+div.compact p, div.compact p,
+div.compact div, div.compact div {
+ margin-top: 0.1em;
+ margin-bottom: 0.1em;
+}
+
+tfoot {
+ font-weight: bold;
+}
+td > div.verse {
+ white-space: pre;
+}
+
+div.hdlist {
+ margin-top: 0.8em;
+ margin-bottom: 0.8em;
+}
+div.hdlist tr {
+ padding-bottom: 15px;
+}
+dt.hdlist1.strong, td.hdlist1.strong {
+ font-weight: bold;
+}
+td.hdlist1 {
+ vertical-align: top;
+ font-style: normal;
+ padding-right: 0.8em;
+ color: navy;
+}
+td.hdlist2 {
+ vertical-align: top;
+}
+div.hdlist.compact tr {
+ margin: 0;
+ padding-bottom: 0;
+}
+
+.comment {
+ background: yellow;
+}
+
+.footnote, .footnoteref {
+ font-size: 0.8em;
+}
+
+span.footnote, span.footnoteref {
+ vertical-align: super;
+}
+
+#footnotes {
+ margin: 20px 0 20px 0;
+ padding: 7px 0 0 0;
+}
+
+#footnotes div.footnote {
+ margin: 0 0 5px 0;
+}
+
+#footnotes hr {
+ border: none;
+ border-top: 1px solid silver;
+ height: 1px;
+ text-align: left;
+ margin-left: 0;
+ width: 20%;
+ min-width: 100px;
+}
+
+div.colist td {
+ padding-right: 0.5em;
+ padding-bottom: 0.3em;
+ vertical-align: top;
+}
+div.colist td img {
+ margin-top: 0.3em;
+}
+
+@media print {
+ #footer-badges { display: none; }
+}
+
+#toc {
+ margin-bottom: 2.5em;
+}
+
+#toctitle {
+ color: #527bbd;
+ font-size: 1.1em;
+ font-weight: bold;
+ margin-top: 1.0em;
+ margin-bottom: 0.1em;
+}
+
+div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+div.toclevel2 {
+ margin-left: 2em;
+ font-size: 0.9em;
+}
+div.toclevel3 {
+ margin-left: 4em;
+ font-size: 0.9em;
+}
+div.toclevel4 {
+ margin-left: 6em;
+ font-size: 0.9em;
+}
+
+span.aqua { color: aqua; }
+span.black { color: black; }
+span.blue { color: blue; }
+span.fuchsia { color: fuchsia; }
+span.gray { color: gray; }
+span.green { color: green; }
+span.lime { color: lime; }
+span.maroon { color: maroon; }
+span.navy { color: navy; }
+span.olive { color: olive; }
+span.purple { color: purple; }
+span.red { color: red; }
+span.silver { color: silver; }
+span.teal { color: teal; }
+span.white { color: white; }
+span.yellow { color: yellow; }
+
+span.aqua-background { background: aqua; }
+span.black-background { background: black; }
+span.blue-background { background: blue; }
+span.fuchsia-background { background: fuchsia; }
+span.gray-background { background: gray; }
+span.green-background { background: green; }
+span.lime-background { background: lime; }
+span.maroon-background { background: maroon; }
+span.navy-background { background: navy; }
+span.olive-background { background: olive; }
+span.purple-background { background: purple; }
+span.red-background { background: red; }
+span.silver-background { background: silver; }
+span.teal-background { background: teal; }
+span.white-background { background: white; }
+span.yellow-background { background: yellow; }
+
+span.big { font-size: 2em; }
+span.small { font-size: 0.6em; }
+
+span.underline { text-decoration: underline; }
+span.overline { text-decoration: overline; }
+span.line-through { text-decoration: line-through; }
+
+
+/*
+ * xhtml11 specific
+ *
+ * */
+
+tt {
+ font-family: monospace;
+ font-size: inherit;
+ color: navy;
+}
+
+div.tableblock {
+ margin-top: 1.0em;
+ margin-bottom: 1.5em;
+}
+div.tableblock > table {
+ border: 3px solid #527bbd;
+}
+thead, p.table.header {
+ font-weight: bold;
+ color: #527bbd;
+}
+p.table {
+ margin-top: 0;
+}
+/* Because the table frame attribute is overriden by CSS in most browsers. */
+div.tableblock > table[frame="void"] {
+ border-style: none;
+}
+div.tableblock > table[frame="hsides"] {
+ border-left-style: none;
+ border-right-style: none;
+}
+div.tableblock > table[frame="vsides"] {
+ border-top-style: none;
+ border-bottom-style: none;
+}
+
+
+/*
+ * html5 specific
+ *
+ * */
+
+.monospaced {
+ font-family: monospace;
+ font-size: inherit;
+ color: navy;
+}
+
+table.tableblock {
+ margin-top: 1.0em;
+ margin-bottom: 1.5em;
+}
+thead, p.tableblock.header {
+ font-weight: bold;
+ color: #527bbd;
+}
+p.tableblock {
+ margin-top: 0;
+}
+table.tableblock {
+ border-width: 3px;
+ border-spacing: 0px;
+ border-style: solid;
+ border-color: #527bbd;
+ border-collapse: collapse;
+}
+th.tableblock, td.tableblock {
+ border-width: 1px;
+ padding: 4px;
+ border-style: solid;
+ border-color: #527bbd;
+}
+
+table.tableblock.frame-topbot {
+ border-left-style: hidden;
+ border-right-style: hidden;
+}
+table.tableblock.frame-sides {
+ border-top-style: hidden;
+ border-bottom-style: hidden;
+}
+table.tableblock.frame-none {
+ border-style: hidden;
+}
+
+th.tableblock.halign-left, td.tableblock.halign-left {
+ text-align: left;
+}
+th.tableblock.halign-center, td.tableblock.halign-center {
+ text-align: center;
+}
+th.tableblock.halign-right, td.tableblock.halign-right {
+ text-align: right;
+}
+
+th.tableblock.valign-top, td.tableblock.valign-top {
+ vertical-align: top;
+}
+th.tableblock.valign-middle, td.tableblock.valign-middle {
+ vertical-align: middle;
+}
+th.tableblock.valign-bottom, td.tableblock.valign-bottom {
+ vertical-align: bottom;
+}
diff --git a/doc/images/icons/caution.png b/doc/images/icons/caution.png
new file mode 100644
index 0000000..9a8c515
Binary files /dev/null and b/doc/images/icons/caution.png differ
diff --git a/doc/images/icons/example.png b/doc/images/icons/example.png
new file mode 100644
index 0000000..1199e86
Binary files /dev/null and b/doc/images/icons/example.png differ
diff --git a/doc/images/icons/home.png b/doc/images/icons/home.png
new file mode 100644
index 0000000..37a5231
Binary files /dev/null and b/doc/images/icons/home.png differ
diff --git a/doc/images/icons/important.png b/doc/images/icons/important.png
new file mode 100644
index 0000000..be685cc
Binary files /dev/null and b/doc/images/icons/important.png differ
diff --git a/doc/images/icons/next.png b/doc/images/icons/next.png
new file mode 100644
index 0000000..64e126b
Binary files /dev/null and b/doc/images/icons/next.png differ
diff --git a/doc/images/icons/note.png b/doc/images/icons/note.png
new file mode 100644
index 0000000..7c1f3e2
Binary files /dev/null and b/doc/images/icons/note.png differ
diff --git a/doc/images/icons/prev.png b/doc/images/icons/prev.png
new file mode 100644
index 0000000..3e8f12f
Binary files /dev/null and b/doc/images/icons/prev.png differ
diff --git a/doc/images/icons/tip.png b/doc/images/icons/tip.png
new file mode 100644
index 0000000..f087c73
Binary files /dev/null and b/doc/images/icons/tip.png differ
diff --git a/doc/images/icons/up.png b/doc/images/icons/up.png
new file mode 100644
index 0000000..2db1ce6
Binary files /dev/null and b/doc/images/icons/up.png differ
diff --git a/doc/images/icons/warning.png b/doc/images/icons/warning.png
new file mode 100644
index 0000000..d41edb9
Binary files /dev/null and b/doc/images/icons/warning.png differ
-----------------------------------------------------------------------
Summary of changes:
doc/Makefile | 9 +-
doc/asciidoc.conf | 5 +
doc/asciidoc.css | 508 ++++++++++++++++++++++++++++++++++++++++
doc/images/icons/caution.png | Bin 0 -> 2734 bytes
doc/images/icons/example.png | Bin 0 -> 2599 bytes
doc/images/icons/home.png | Bin 0 -> 1340 bytes
doc/images/icons/important.png | Bin 0 -> 2980 bytes
doc/images/icons/next.png | Bin 0 -> 1302 bytes
doc/images/icons/note.png | Bin 0 -> 2494 bytes
doc/images/icons/prev.png | Bin 0 -> 1348 bytes
doc/images/icons/tip.png | Bin 0 -> 2718 bytes
doc/images/icons/up.png | Bin 0 -> 1320 bytes
doc/images/icons/warning.png | Bin 0 -> 3214 bytes
13 files changed, 520 insertions(+), 2 deletions(-)
create mode 100644 doc/asciidoc.conf
create mode 100644 doc/asciidoc.css
create mode 100644 doc/images/icons/caution.png
create mode 100644 doc/images/icons/example.png
create mode 100644 doc/images/icons/home.png
create mode 100644 doc/images/icons/important.png
create mode 100644 doc/images/icons/next.png
create mode 100644 doc/images/icons/note.png
create mode 100644 doc/images/icons/prev.png
create mode 100644 doc/images/icons/tip.png
create mode 100644 doc/images/icons/up.png
create mode 100644 doc/images/icons/warning.png
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: d15c6dd78c9e1605830aec10a58dad1dd4e7c39a
by metan 30 Dec '12
by metan 30 Dec '12
30 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 d15c6dd78c9e1605830aec10a58dad1dd4e7c39a (commit)
via 8f11a42580586ca3fd0c71f3de3c6017ec9f50f0 (commit)
via 15218977e283fb9d7f61db2f336b662350bfecd7 (commit)
via 66288dc8cf7dc3f0e2308a5913820f49814181af (commit)
via 3b0b817ad655b1c5a7172d41d971793fafd4e033 (commit)
via f65e8ed5951cb097f67d212da67b48604c47bd66 (commit)
via 785fcafc3003d9af67c6d17a1451efc00d3544d1 (commit)
via afe7e710ea1a940e90b80a511ba05b598491b16c (commit)
from ee2a7bf0f846b6283b0c3cab6acb7c5afb4ca93b (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/d15c6dd78c9e1605830aec10a58dad1dd4e7…
commit d15c6dd78c9e1605830aec10a58dad1dd4e7c39a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Dec 30 20:56:06 2012 +0100
core: GP_ContextEqual: Minor coding style fix.
diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c
index c749fcc..c082c53 100644
--- a/libs/core/GP_Context.c
+++ b/libs/core/GP_Context.c
@@ -348,10 +348,15 @@ void GP_ContextRotateCCW(GP_Context *context)
int GP_ContextEqual(const GP_Context *ctx1, const GP_Context *ctx2)
{
- if (ctx1->pixel_type != ctx2->pixel_type) return 0;
- if (GP_ContextW(ctx1) != GP_ContextW(ctx2)) return 0;
- if (GP_ContextH(ctx1) != GP_ContextH(ctx2)) return 0;
+ if (ctx1->pixel_type != ctx2->pixel_type)
+ return 0;
+ if (GP_ContextW(ctx1) != GP_ContextW(ctx2))
+ return 0;
+
+ if (GP_ContextH(ctx1) != GP_ContextH(ctx2))
+ return 0;
+
GP_Coord x, y, w = GP_ContextW(ctx1), h = GP_ContextH(ctx1);
for (x = 0; x < w; x++)
http://repo.or.cz/w/gfxprim.git/commit/8f11a42580586ca3fd0c71f3de3c6017ec9f…
commit 8f11a42580586ca3fd0c71f3de3c6017ec9f50f0
Merge: f65e8ed 1521897
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Dec 30 20:52:41 2012 +0100
Merge gfxprim
http://repo.or.cz/w/gfxprim.git/commit/15218977e283fb9d7f61db2f336b662350bf…
commit 15218977e283fb9d7f61db2f336b662350bfecd7
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sun Dec 30 16:38:43 2012 +0100
core: pylib: Tests for Context equality
diff --git a/tests/pylib/test_core.py b/tests/pylib/test_core.py
index 2752c64..f1703a5 100644
--- a/tests/pylib/test_core.py
+++ b/tests/pylib/test_core.py
@@ -1,3 +1,4 @@
+"core.Context"
### Helper imports and decorators
# TODO: separate (nose plugin?)
@@ -25,15 +26,19 @@ def test_basic_types_exist():
assert core.C.PIXEL_RGBA8888 > 0
assert core.C.PIXEL_G8 > 0
-def test_create_context():
- c = Context.Create(7, 9, core.C.PIXEL_RGB888)
- assert c.w == 7
- assert c.h == 9
+@alltypes()
+def test_create_by_pixeltype(t):
+ "Allocate Context by pixeltype"
+ c = Context.Create(13, 15, t.type)
+@alltypes()
+def test_create_by_number(t):
+ "Allocation by pixeltype number"
+ c = Context.Create(3, 5, t)
@alltypes()
-def test_create_context_and_check_sanity(t):
- "Allocate Context by pixeltype and check basic invariants"
+def test_check_attributes(t):
+ "Context attributes"
c = Context.Create(13, 15, t.type)
assert c.w == 13
assert c.h == 15
@@ -42,13 +47,8 @@ def test_create_context_and_check_sanity(t):
assert c._free_pixels
@alltypes()
-def test_create_by_number(t):
- "Allocation by pixeltype number"
- c = Context.Create(3, 5, t)
-
-@alltypes()
def test_context_convert_from_RGB888(t):
- "Test conversion from RGB888"
+ "Conversion from RGB888"
if 'P' in t.name:
raise SkipTest("Palette conversion os TODO")
c = Context.Create(17, 19, core.C.PIXEL_RGB888)
@@ -59,10 +59,32 @@ def test_context_convert_from_RGB888(t):
assert c3.pixel_type == t.type
@alltypes()
-def test_context_convert_to_RGB888(t):
- "Test conversion to RGB888"
+def test_convert_to_RGB888(t):
+ "Conversion to RGB888"
if 'P' in t.name:
raise SkipTest("Palette conversion os TODO")
c = Context.Create(1, 1, t)
c2 = c.Convert(core.C.PIXEL_RGB888)
assert c2.pixel_type == core.C.PIXEL_RGB888
+
+@alltypes()
+def test_equality_same_type(t):
+ "Basics of equality"
+ c1 = Context.Create(2, 1, t)
+ assert c1 == c1
+ c2 = Context.Create(1, 2, t)
+ assert c2 == c2
+ assert c1 != c2
+ assert c2 != c1
+
+@alltypes()
+def test_equality_data(t):
+ "Equality of data"
+ c1 = Context.Create(1, 1, t)
+ c1.PutPixel(0, 0, 1)
+ c2 = Context.Create(1, 1, t)
+ c2.PutPixel(0, 0, 1)
+ assert c1 == c2
+ c2.PutPixel(0, 0, 0)
+ assert c1 != c2
+
http://repo.or.cz/w/gfxprim.git/commit/66288dc8cf7dc3f0e2308a5913820f498141…
commit 66288dc8cf7dc3f0e2308a5913820f49814181af
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sun Dec 30 16:37:31 2012 +0100
core: pylib: Context equality
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py
index 27c32e3..1b082f5 100644
--- a/pylib/gfxprim/core/__init__.py
+++ b/pylib/gfxprim/core/__init__.py
@@ -24,16 +24,22 @@ def _init(module):
import re
from ..utils import extend, extend_direct, add_swig_getmethod, add_swig_setmethod
from ..utils import import_members
- _context = module['Context']
+
+ ### PixelTypeDescription
+
_ptdescr = c_core.GP_PixelTypeDescription
- # String representation
+ # String representation of
@extend(_ptdescr, name='__str__')
@extend(_ptdescr, name='__repr__')
def ptdescr_str(self):
return "<PixelTypeDescription %s>" % (self.name, )
+ ### Context
+
+ _context = module['Context']
+
# String representation
@extend(_context, name='__str__')
@@ -44,6 +50,15 @@ def _init(module):
"" if self.thisown else "not ",
"with" if self.parent else "no")
+ # Equality
+
+ @extend(_context, name='__eq__')
+ def ContextEqual(self, other):
+ "Compare Contexts - pixel types, sizes and data must match (gamma ignored)."
+ if not isinstance(other, _context):
+ raise TypeError("Can only compare two Contexts.")
+ return bool(c_core.GP_ContextEqual(self, other))
+
# Creation
def pixeltype_no(pixeltype):
http://repo.or.cz/w/gfxprim.git/commit/3b0b817ad655b1c5a7172d41d971793fafd4…
commit 3b0b817ad655b1c5a7172d41d971793fafd4e033
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sun Dec 30 15:19:41 2012 +0100
core: Added GP_COntextEqual (naive version)
diff --git a/include/core/GP_Context.h b/include/core/GP_Context.h
index 9de8572..0977a27 100644
--- a/include/core/GP_Context.h
+++ b/include/core/GP_Context.h
@@ -252,4 +252,17 @@ static inline GP_Size GP_ContextH(const GP_Context *context)
return context->h;
}
+/*
+ * Compare two contexts. Returns true only if all of types, sizes and
+ * bitmap data match. Takes transformations into account.
+ *
+ * For now ignores gamma tables.
+ *
+ * Currently rather slow (getpixel).
+ * TODO: speed up for same rotation and same bit-offset data (per-row memcpy).
+ */
+
+int GP_ContextEqual(const GP_Context *ctx1, const GP_Context *ctx2);
+
#endif /* CORE_GP_CONTEXT_H */
+
diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c
index 8b66a3b..c749fcc 100644
--- a/libs/core/GP_Context.c
+++ b/libs/core/GP_Context.c
@@ -345,3 +345,20 @@ void GP_ContextRotateCCW(GP_Context *context)
context->x_swap = 1;
}
+
+int GP_ContextEqual(const GP_Context *ctx1, const GP_Context *ctx2)
+{
+ if (ctx1->pixel_type != ctx2->pixel_type) return 0;
+ if (GP_ContextW(ctx1) != GP_ContextW(ctx2)) return 0;
+ if (GP_ContextH(ctx1) != GP_ContextH(ctx2)) return 0;
+
+ GP_Coord x, y, w = GP_ContextW(ctx1), h = GP_ContextH(ctx1);
+
+ for (x = 0; x < w; x++)
+ for (y = 0; y < h; y++)
+ if (GP_GetPixel(ctx1, x, y) != GP_GetPixel(ctx2, x, y))
+ return 0;
+
+ return 1;
+}
+
http://repo.or.cz/w/gfxprim.git/commit/f65e8ed5951cb097f67d212da67b48604c47…
commit f65e8ed5951cb097f67d212da67b48604c47bd66
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Dec 30 12:29:49 2012 +0100
gfx: HLine: Split HLine && cleanup.
This commit splits HLine implementation
and remove unused files.
diff --git a/libs/gfx/GP_HLine.c b/libs/gfx/GP_HLine.c
new file mode 100644
index 0000000..2255660
--- /dev/null
+++ b/libs/gfx/GP_HLine.c
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * 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-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include "core/GP_Transform.h"
+
+#include "gfx/GP_HLine.h"
+#include "gfx/GP_VLine.h"
+
+void GP_HLineXXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_FN_PER_BPP_CONTEXT(GP_HLine_Raw, context, context, x0, x1, y,
+ pixel);
+}
+
+void GP_HLineXYW_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
+ GP_Pixel pixel)
+{
+ if (w == 0)
+ return;
+
+ GP_HLineXXY_Raw(context, x, x + w - 1, y, pixel);
+}
+
+void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y,
+ GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ if (context->axes_swap) {
+ GP_TRANSFORM_Y(context, x0);
+ GP_TRANSFORM_Y(context, x1);
+ GP_TRANSFORM_X(context, y);
+ GP_VLine_Raw(context, y, x0, x1, pixel);
+ } else {
+ GP_TRANSFORM_X(context, x0);
+ GP_TRANSFORM_X(context, x1);
+ GP_TRANSFORM_Y(context, y);
+ GP_HLine_Raw(context, x0, x1, y, pixel);
+ }
+}
+
+void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
+ GP_Pixel pixel)
+{
+ if (w == 0)
+ return;
+
+ GP_HLineXXY(context, x, x + w - 1, y, pixel);
+}
diff --git a/libs/gfx/GP_HLine.gen.c.t b/libs/gfx/GP_HLine.gen.c.t
index 8fe9169..5e0a761 100644
--- a/libs/gfx/GP_HLine.gen.c.t
+++ b/libs/gfx/GP_HLine.gen.c.t
@@ -29,14 +29,9 @@
%% block body
-#include "core/GP_FnPerBpp.h"
#include "core/GP_WritePixel.h"
-#include "core/GP_Transform.h"
-
-/* #include "algo/HLine.algo.h" */
#include "gfx/GP_HLine.h"
-#include "gfx/GP_VLine.h"
%% for ps in pixelsizes
@@ -48,8 +43,7 @@ void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int x1, int y,
GP_SWAP(x0, x1);
/* return immediately if the line is completely out of surface */
- if (y < 0 || y >= (int) context->h ||
- x1 < 0 || x0 >= (int) context->w)
+ if (y < 0 || y >= (int) context->h || x1 < 0 || x0 >= (int) context->w)
return;
/* clip the line against surface boundaries */
@@ -68,68 +62,4 @@ void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int x1, int y,
}
%% endfor
-
-/* Generate drawing functions for various bit depths. */
-
-//TODO: BIT ENDIANESS
-/*
-DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels_1BPP_LE)
-DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp)
-DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels_2BPP_LE)
-DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
-DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels_4BPP_LE)
-DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels4bpp)
-DEF_HLINE_BU_FN(GP_HLine_Raw_18BPP_LE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels18bpp)
-
-DEF_HLINE_FN(GP_HLine_Raw_8BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels8bpp)
-DEF_HLINE_FN(GP_HLine_Raw_16BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels16bpp)
-DEF_HLINE_FN(GP_HLine_Raw_24BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels24bpp)
-DEF_HLINE_FN(GP_HLine_Raw_32BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels32bpp)
-*/
-
-void GP_HLineXXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel)
-{
- GP_CHECK_CONTEXT(context);
-
- GP_FN_PER_BPP_CONTEXT(GP_HLine_Raw, context, context, x0, x1, y,
- pixel);
-}
-
-void GP_HLineXYW_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
- GP_Pixel pixel)
-{
- if (w == 0)
- return;
-
- GP_HLineXXY_Raw(context, x, x + w - 1, y, pixel);
-}
-
-void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y,
- GP_Pixel pixel)
-{
- GP_CHECK_CONTEXT(context);
-
- if (context->axes_swap) {
- GP_TRANSFORM_Y(context, x0);
- GP_TRANSFORM_Y(context, x1);
- GP_TRANSFORM_X(context, y);
- GP_VLine_Raw(context, y, x0, x1, pixel);
- } else {
- GP_TRANSFORM_X(context, x0);
- GP_TRANSFORM_X(context, x1);
- GP_TRANSFORM_Y(context, y);
- GP_HLine_Raw(context, x0, x1, y, pixel);
- }
-}
-
-void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
- GP_Pixel pixel)
-{
- if (w == 0)
- return;
-
- GP_HLineXXY(context, x, x + w - 1, y, pixel);
-}
-
%% endblock body
diff --git a/libs/gfx/algo/HLine.algo.h b/libs/gfx/algo/HLine.algo.h
deleted file mode 100644
index 91dd35f..0000000
--- a/libs/gfx/algo/HLine.algo.h
+++ /dev/null
@@ -1,75 +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 horizontal 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 (x0 > x1) - GP_SWAP(x0, x1); - if (y < 0 || y >= (int) context->h || - x1 < 0 || x0 >= (int) context->w) - return; - x0 = GP_MAX(x0, 0); - x1 = GP_MIN(x1, (int) context->w - 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, x, y)
- * 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_HLINE_FN(FN_NAME, CONTEXT_T, PIXEL_T, PIXEL_ADDRESS, WRITE_PIXELS) -void FN_NAME(CONTEXT_T context, int x0, int x1, int y, PIXEL_T pixel) -{ - ORDER_AND_CLIP_COORDS; -- size_t length = 1 + x1 - x0; - void *start = PIXEL_ADDRESS(context, x0, y); -- WRITE_PIXELS(start, length, pixel); -}
-
-/*
- * Not byte aligned pixels. The number of bits per pixel must be power of two.
- */
-#define DEF_HLINE_BU_FN(FN_NAME, CONTEXT_T, PIXEL_T, PIXEL_ADDRESS, WRITE_PIXELS) -void FN_NAME(CONTEXT_T context, int x0, int x1, int y, PIXEL_T pixel) -{ - ORDER_AND_CLIP_COORDS; -- size_t length = 1 + x1 - x0; - void *start = PIXEL_ADDRESS(context, x0, y); -- WRITE_PIXELS(start, x0 % (8 / context->bpp), length, pixel); -}
http://repo.or.cz/w/gfxprim.git/commit/785fcafc3003d9af67c6d17a1451efc00d35…
commit 785fcafc3003d9af67c6d17a1451efc00d3544d1
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Dec 30 11:50:11 2012 +0100
tests: gfx: Add very basic HLine testsuite.
diff --git a/tests/gfx/HLine.c b/tests/gfx/HLine.c
new file mode 100644
index 0000000..ddab1c7
--- /dev/null
+++ b/tests/gfx/HLine.c
@@ -0,0 +1,292 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <string.h>
+#include <errno.h>
+
+#include <core/GP_Context.h>
+#include <gfx/GP_HLine.h>
+
+#include "tst_test.h"
+
+#include "common.h"
+
+struct testcase {
+ /* HLine description */
+ GP_Coord x0;
+ GP_Coord x1;
+ GP_Coord y;
+
+ GP_Coord x;
+ GP_Size lw;
+
+ int flag;
+
+ /* expected result */
+ GP_Size w, h;
+ const char pixmap[];
+};
+
+static int test_hline(struct testcase *t)
+{
+ GP_Context *c;
+ int err;
+
+ c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8);
+
+ if (c == NULL) {
+ tst_err("Failed to allocate context");
+ return TST_UNTESTED;
+ }
+
+ /* zero the pixels buffer */
+ memset(c->pixels, 0, c->w * c->h);
+
+ if (t->flag)
+ GP_HLineXYW(c, t->x, t->y, t->lw, 1);
+ else
+ GP_HLine(c, t->x0, t->x1, t->y, 1);
+
+ err = compare_buffers(t->pixmap, c);
+
+ if (err) {
+ tst_msg("Patterns are different");
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+
+static struct testcase testcase_1_px = {
+ .x0 = 1,
+ .x1 = 1,
+ .y = 1,
+
+ .w = 3,
+ .h = 3,
+ .pixmap = {
+ 0, 0, 0,
+ 0, 1, 0,
+ 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_3_px_1 = {
+ .x0 = 1,
+ .x1 = 3,
+ .y = 1,
+
+ .w = 5,
+ .h = 3,
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_3_px_2 = {
+ .x0 = 3,
+ .x1 = 1,
+ .y = 1,
+
+ .w = 5,
+ .h = 3,
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_clipping_1 = {
+ .x0 = -10000,
+ .x1 = 10000,
+ .y = 1,
+
+ .w = 5,
+ .h = 3,
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_clipping_2 = {
+ .x0 = -10000,
+ .x1 = 10000,
+ .y = 4,
+
+ .w = 5,
+ .h = 3,
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_clipping_3 = {
+ .x0 = -100000,
+ .x1 = 100000,
+ .y = -4,
+
+ .w = 5,
+ .h = 3,
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_xyw_1 = {
+ .x = 1,
+ .y = 1,
+ .lw = 0,
+
+ .flag = 1,
+
+ .w = 3,
+ .h = 3,
+ .pixmap = {
+ 0, 0, 0,
+ 0, 1, 0,
+ 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_xyw_2 = {
+ .x = 1,
+ .y = 1,
+ .lw = 1,
+
+ .flag = 1,
+
+ .w = 4,
+ .h = 3,
+ .pixmap = {
+ 0, 0, 0, 0,
+ 0, 1, 1, 0,
+ 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_xyw_clipp_1 = {
+ .x = -10000,
+ .y = 1,
+ .lw = 20000,
+
+ .flag = 1,
+
+ .w = 3,
+ .h = 3,
+ .pixmap = {
+ 0, 0, 0,
+ 1, 1, 1,
+ 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_xyw_clipp_2 = {
+ .x = 1,
+ .y = 1,
+ .lw = 200000,
+
+ .flag = 1,
+
+ .w = 3,
+ .h = 3,
+ .pixmap = {
+ 0, 0, 0,
+ 0, 1, 1,
+ 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_xyw_clipp_3 = {
+ .x = -10000,
+ .y = -10000,
+ .lw = -1,
+
+ .flag = 1,
+
+ .w = 3,
+ .h = 3,
+ .pixmap = {
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0,
+ }
+};
+
+const struct tst_suite tst_suite = {
+ .suite_name = "HLine Testsuite",
+ .tests = {
+ {.name = "HLine 1px",
+ .tst_fn = test_hline,
+ .data = &testcase_1_px},
+
+ {.name = "HLine 3px 1",
+ .tst_fn = test_hline,
+ .data = &testcase_3_px_1},
+
+ {.name = "HLine 3px 2",
+ .tst_fn = test_hline,
+ .data = &testcase_3_px_2},
+
+ {.name = "HLine clipping 1",
+ .tst_fn = test_hline,
+ .data = &testcase_clipping_1},
+
+ {.name = "HLine clipping 2",
+ .tst_fn = test_hline,
+ .data = &testcase_clipping_2},
+
+ {.name = "HLine clipping 3",
+ .tst_fn = test_hline,
+ .data = &testcase_clipping_3},
+
+ {.name = "HLineXYW 1",
+ .tst_fn = test_hline,
+ .data = &testcase_xyw_1},
+
+ {.name = "HLineXYW 2",
+ .tst_fn = test_hline,
+ .data = &testcase_xyw_2},
+
+ {.name = "HLineXYW clipping 1",
+ .tst_fn = test_hline,
+ .data = &testcase_xyw_clipp_1},
+
+ {.name = "HLineXYW clipping 2",
+ .tst_fn = test_hline,
+ .data = &testcase_xyw_clipp_2},
+
+ {.name = "HLineXYW clipping 3",
+ .tst_fn = test_hline,
+ .data = &testcase_xyw_clipp_3},
+
+ {.name = NULL}
+ }
+};
diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile
index d8090a9..1edbb99 100644
--- a/tests/gfx/Makefile
+++ b/tests/gfx/Makefile
@@ -3,7 +3,7 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
-APPS=gfx_benchmark Circle FillCircle Line CircleSeg Polygon Ellipse
+APPS=gfx_benchmark Circle FillCircle Line CircleSeg Polygon Ellipse HLine
Circle: common.o
FillCircle: common.o
@@ -11,6 +11,7 @@ Ellipse: common.o
Line: common.o
CircleSeg: common.o
Polygon: common.o
+HLine: common.o
include ../tests.mk
diff --git a/tests/gfx/runtest.sh b/tests/gfx/runtest.sh
index 2edd6b4..c890920 100755
--- a/tests/gfx/runtest.sh
+++ b/tests/gfx/runtest.sh
@@ -10,6 +10,7 @@
export LIBC_FATAL_STDERR_=1
#LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./gfx_benchmark "$@"
+LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./HLine "$@"
LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Line "$@"
LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Circle "$@"
LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./FillCircle "$@"
http://repo.or.cz/w/gfxprim.git/commit/afe7e710ea1a940e90b80a511ba05b598491…
commit afe7e710ea1a940e90b80a511ba05b598491b16c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Dec 30 11:28:26 2012 +0100
gfx: HLine: Generate HLine per BPP header too.
diff --git a/include/gfx/GP_HLine.gen.h.t b/include/gfx/GP_HLine.gen.h.t
new file mode 100644
index 0000000..873f727
--- /dev/null
+++ b/include/gfx/GP_HLine.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 %}HLine generated header{% endblock %}
+
+{% block body %}
+
+%% for ps in pixelsizes
+void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord x0,
+ GP_Coord x1, GP_Coord y, GP_Pixel pixel);
+
+%% endfor
+
+{% endblock body %}
diff --git a/include/gfx/GP_HLine.h b/include/gfx/GP_HLine.h
index 0737f66..50f9a12 100644
--- a/include/gfx/GP_HLine.h
+++ b/include/gfx/GP_HLine.h
@@ -19,52 +19,19 @@
* 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_HLINE_H
-#define GP_HLINE_H
+#ifndef GFX_GP_HLINE_H
+#define GFX_GP_HLINE_H
#include "core/GP_Context.h"
/* Raw per BPP HLines */
-
-void GP_HLine_Raw_1BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_HLine_Raw_1BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_HLine_Raw_2BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_HLine_Raw_2BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_HLine_Raw_4BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_HLine_Raw_4BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_HLine_Raw_8BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_HLine_Raw_18BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_HLine_Raw_16BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_HLine_Raw_24BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
-
-void GP_HLine_Raw_32BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
+#include "gfx/GP_HLine.gen.h"
/* Generic HLines */
-
void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y,
GP_Pixel pixel);
@@ -90,4 +57,4 @@ static inline void GP_HLine(GP_Context *context, GP_Coord x0, GP_Coord x1,
GP_HLineXXY(context, x0, x1, y, p);
}
-#endif /* GP_HLINE_H */
+#endif /* GFX_GP_HLINE_H */
diff --git a/include/gfx/Makefile b/include/gfx/Makefile
index 7548d55..894b898 100644
--- a/include/gfx/Makefile
+++ b/include/gfx/Makefile
@@ -2,7 +2,7 @@ TOPDIR=../..
include $(TOPDIR)/pre.mk
-GENHEADERS=GP_VLine.gen.h
+GENHEADERS=GP_VLine.gen.h GP_HLine.gen.h
include $(TOPDIR)/gen.mk
include $(TOPDIR)/post.mk
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Context.h | 13 +
include/gfx/{GP_VLine.gen.h.t => GP_HLine.gen.h.t} | 6 +-
include/gfx/GP_HLine.h | 43 +---
include/gfx/Makefile | 2 +-
libs/core/GP_Context.c | 22 ++
libs/gfx/{GP_Arc.c => GP_HLine.c} | 63 +++--
libs/gfx/GP_HLine.gen.c.t | 72 +-----
libs/gfx/algo/HLine.algo.h | 75 -----
pylib/gfxprim/core/__init__.py | 19 ++-
tests/gfx/HLine.c | 292 ++++++++++++++++++++
tests/gfx/Makefile | 3 +-
tests/gfx/runtest.sh | 1 +
tests/pylib/test_core.py | 50 +++-
13 files changed, 431 insertions(+), 230 deletions(-)
copy include/gfx/{GP_VLine.gen.h.t => GP_HLine.gen.h.t} (91%)
copy libs/gfx/{GP_Arc.c => GP_HLine.c} (64%)
delete mode 100644 libs/gfx/algo/HLine.algo.h
create mode 100644 tests/gfx/HLine.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: ee2a7bf0f846b6283b0c3cab6acb7c5afb4ca93b
by metan 29 Dec '12
by metan 29 Dec '12
29 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 ee2a7bf0f846b6283b0c3cab6acb7c5afb4ca93b (commit)
from 3d1396ad2aa8763807e048d91cde205e764b237f (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/ee2a7bf0f846b6283b0c3cab6acb7c5afb4c…
commit ee2a7bf0f846b6283b0c3cab6acb7c5afb4ca93b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Dec 29 11:38:51 2012 +0100
loaders: GP_Loader: Fix previous commit.
We need to do access() first then stat().
diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c
index 05b1240..c3769a6 100644
--- a/libs/loaders/GP_Loader.c
+++ b/libs/loaders/GP_Loader.c
@@ -234,16 +234,7 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
{
int saved_errno;
struct stat st;
-
- if (stat(src_path, &st)) {
- GP_WARN("Failed to stat '%s': %s", src_path, strerror(errno));
- } else {
- if (st.st_mode & S_IFDIR) {
- errno = EISDIR;
- return NULL;
- }
- }
-
+
if (access(src_path, R_OK)) {
saved_errno = errno;
@@ -256,6 +247,15 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
return NULL;
}
+ if (stat(src_path, &st)) {
+ GP_WARN("Failed to stat '%s': %s", src_path, strerror(errno));
+ } else {
+ if (st.st_mode & S_IFDIR) {
+ errno = EISDIR;
+ return NULL;
+ }
+ }
+
GP_Context *img;
const GP_Loader *ext_load = NULL, *sig_load;
-----------------------------------------------------------------------
Summary of changes:
libs/loaders/GP_Loader.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 3d1396ad2aa8763807e048d91cde205e764b237f
by metan 29 Dec '12
by metan 29 Dec '12
29 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 3d1396ad2aa8763807e048d91cde205e764b237f (commit)
from 458bf7bf0abdd984b499c4deadc7551232108c5e (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/3d1396ad2aa8763807e048d91cde205e764b…
commit 3d1396ad2aa8763807e048d91cde205e764b237f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Dec 29 00:22:20 2012 +0100
loaders: GP_Load: Add check for directory.
diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c
index fdd2641..05b1240 100644
--- a/libs/loaders/GP_Loader.c
+++ b/libs/loaders/GP_Loader.c
@@ -29,6 +29,9 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include "core/GP_Debug.h"
@@ -230,7 +233,17 @@ static const GP_Loader *loader_by_signature(const char *path)
GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
{
int saved_errno;
-
+ struct stat st;
+
+ if (stat(src_path, &st)) {
+ GP_WARN("Failed to stat '%s': %s", src_path, strerror(errno));
+ } else {
+ if (st.st_mode & S_IFDIR) {
+ errno = EISDIR;
+ return NULL;
+ }
+ }
+
if (access(src_path, R_OK)) {
saved_errno = errno;
@@ -242,7 +255,7 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
return NULL;
}
-
+
GP_Context *img;
const GP_Loader *ext_load = NULL, *sig_load;
-----------------------------------------------------------------------
Summary of changes:
libs/loaders/GP_Loader.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 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: 458bf7bf0abdd984b499c4deadc7551232108c5e
by metan 28 Dec '12
by metan 28 Dec '12
28 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 458bf7bf0abdd984b499c4deadc7551232108c5e (commit)
from f1688be3cd5e34c596afc0027b9c07d2cfec4325 (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/458bf7bf0abdd984b499c4deadc755123210…
commit 458bf7bf0abdd984b499c4deadc7551232108c5e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Dec 28 21:40:51 2012 +0100
spiv: Add different zoom modes.
A little hacky support for two more zoom modes.
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index cbb77a0..6059199 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -49,6 +49,24 @@ static GP_Backend *backend = NULL;
static int abort_flag = 0;
static int show_progress = 0;
+enum zoom_type {
+ /*
+ * Resize image to fit current size of the window.
+ */
+ ZOOM_FIT,
+
+ /*
+ * Use zoom set in zoom float and zoom offsets.
+ */
+ ZOOM_FIXED,
+
+ /*
+ * Fixed zoom but spiv tries to change
+ * the window size to fit the image size
+ */
+ ZOOM_FIXED_WIN,
+};
+
struct loader_params {
/* current image path */
const char *img_path;
@@ -71,6 +89,14 @@ struct loader_params {
/* resampling method */
int resampling_method;
+ /* offset in pixels */
+ unsigned int zoom_x_offset;
+ unsigned int zoom_y_offset;
+
+ /* zoom */
+ enum zoom_type zoom_type;
+ float zoom;
+
/* caches for loaded images */
struct image_cache *img_resized_cache;
struct image_cache *img_orig_cache;
@@ -108,14 +134,47 @@ static int image_loader_callback(GP_ProgressCallback *self)
return 0;
}
+static GP_Context *load_image(struct loader_params *params, int elevate);
-static float calc_img_size(uint32_t img_w, uint32_t img_h,
+/*
+ * Ask backend to resize window may not be implemented or authorized. If
+ * backend (window) is resized we will get SYS_RESIZE event, see the main event
+ * loop.
+ */
+static void resize_backend(struct loader_params *params, float ratio, int shift_flag)
+{
+ GP_Context *img = load_image(params, 1);
+
+ if (!shift_flag)
+ ratio = 1.00 / ratio;
+
+ unsigned int w = img->w * ratio + 0.5;
+ unsigned int h = img->h * ratio + 0.5;
+
+ GP_BackendResize(backend, w, h);
+}
+
+
+static float calc_img_size(struct loader_params *params,
+ uint32_t img_w, uint32_t img_h,
uint32_t src_w, uint32_t src_h)
{
- float w_rat = 1.00 * src_w / img_w;
- float h_rat = 1.00 * src_h / img_h;
+ float w_rat;
+ float h_rat;
+
+ switch (params->zoom_type) {
+ case ZOOM_FIT:
+ w_rat = 1.00 * src_w / img_w;
+ h_rat = 1.00 * src_h / img_h;
+ return GP_MIN(w_rat, h_rat);
+ case ZOOM_FIXED:
+ return params->zoom;
+ case ZOOM_FIXED_WIN:
+ resize_backend(params, params->zoom, 0);
+ return params->zoom;
+ }
- return GP_MIN(w_rat, h_rat);
+ return 1;
}
static const char *img_name(const char *img_path)
@@ -142,7 +201,7 @@ static void set_caption(const char *path, float rat)
/*
* Loads image
*/
-GP_Context *load_image(struct loader_params *params, int elevate)
+static GP_Context *load_image(struct loader_params *params, int elevate)
{
struct cpu_timer timer;
GP_Context *img, *context = backend->context;
@@ -218,8 +277,20 @@ static void update_display(struct loader_params *params, GP_Context *img)
if (img == NULL)
return;
- uint32_t cx = (context->w - img->w)/2;
- uint32_t cy = (context->h - img->h)/2;
+ int cx = 0;
+ int cy = 0;
+
+ switch (params->zoom_type) {
+ case ZOOM_FIT:
+ cx = (context->w - img->w)/2;
+ cy = (context->h - img->h)/2;
+ break;
+ case ZOOM_FIXED:
+ case ZOOM_FIXED_WIN:
+ cx = params->zoom_x_offset;
+ cy = params->zoom_y_offset;
+ break;
+ }
GP_Context sub_display;
@@ -231,19 +302,27 @@ static void update_display(struct loader_params *params, GP_Context *img)
GP_FilterFloydSteinberg_RGB888(img, &sub_display, NULL);
// GP_FilterHilbertPeano_RGB888(img, &sub_display, NULL);
} else {
- GP_Blit_Raw(img, 0, 0, img->w, img->h, context, cx, cy);
+ GP_Blit_Clipped(img, 0, 0, img->w, img->h, context, cx, cy);
}
cpu_timer_stop(&timer);
if (params->rotate)
GP_ContextFree(img);
-
+
/* clean up the rest of the display */
GP_FillRectXYWH(context, 0, 0, cx, context->h, black_pixel);
GP_FillRectXYWH(context, 0, 0, context->w, cy, black_pixel);
- GP_FillRectXYWH(context, img->w + cx, 0, context->w - img->w - cx, context->h, black_pixel);
- GP_FillRectXYWH(context, 0, img->h + cy, context->w, context->h - img->h - cy, black_pixel);
+
+ int w = context->w - img->w - cx;
+
+ if (w > 0)
+ GP_FillRectXYWH(context, img->w + cx, 0, w, context->h, black_pixel);
+
+ int h = context->h - img->h - cy;
+
+ if (h > 0)
+ GP_FillRectXYWH(context, 0, img->h + cy, context->w, h, black_pixel);
set_caption(params->img_path, params->rat);
@@ -394,7 +473,11 @@ static void *image_loader(void *ptr)
if ((img = load_image(params, 0)) == NULL)
return NULL;
- params->rat = calc_img_size(img->w, img->h, w, h);
+ params->rat = calc_img_size(params, img->w, img->h, w, h);
+
+ /* Special case => no need to resize */
+ if (params->rat == 1.0)
+ goto update;
w = img->w;
h = img->h;
@@ -407,8 +490,8 @@ static void *image_loader(void *ptr)
image_cache_print(params->img_resized_cache);
image_cache_print(params->img_orig_cache);
+update:
update_display(params, img);
-
cpu_timer_stop(&sum_timer);
return NULL;
@@ -445,6 +528,24 @@ static void show_image(struct loader_params *params, const char *path)
}
}
+static void zoom_offset_horiz(struct loader_params *params, int size)
+{
+ params->zoom_x_offset += size;
+ show_image(params, NULL);
+}
+
+static void zoom_offset_vert(struct loader_params *params, int size)
+{
+ params->zoom_y_offset += size;
+ show_image(params, NULL);
+}
+
+static void zoom_mul(struct loader_params *params, float mul)
+{
+ params->zoom *= mul;
+ show_image(params, NULL);
+}
+
static void sighandler(int signo)
{
if (backend != NULL)
@@ -560,23 +661,6 @@ static void init_caches(struct loader_params *params)
// params->img_orig_cache = NULL;
}
-/*
- * Ask backend to resize window. Once window is resized we will
- * get SYS_RESIZE event, see the main event loop.
- */
-static void resize_backend(struct loader_params *params, float ratio, int shift_flag)
-{
- GP_Context *img = load_image(params, 1);
-
- if (!shift_flag)
- ratio = 1.00 / ratio;
-
- unsigned int w = img->w * ratio + 0.5;
- unsigned int h = img->h * ratio + 0.5;
-
- GP_BackendResize(backend, w, h);
-}
-
static const char *keys_help[] = {
"Keyboard control:",
"",
@@ -685,11 +769,14 @@ int main(int argc, char *argv[])
.rotate = 0,
.resampling_method = GP_INTERP_LINEAR_LF_INT,
+ .zoom_type = ZOOM_FIT,
+ .zoom = 1,
+
.img_resized_cache = NULL,
.img_orig_cache = NULL,
};
- while ((opt = getopt(argc, argv, "b:cd:e:fhIPs:r:")) != -1) {
+ while ((opt = getopt(argc, argv, "b:cd:e:fhIPs:r:z:")) != -1) {
switch (opt) {
case 'I':
params.show_info = 1;
@@ -735,6 +822,16 @@ int main(int argc, char *argv[])
print_help();
exit(0);
break;
+ case 'z':
+ switch (optarg[0]) {
+ case 'f':
+ params.zoom_type = ZOOM_FIXED;
+ break;
+ case 'w':
+ params.zoom_type = ZOOM_FIXED_WIN;
+ break;
+ }
+ break;
default:
fprintf(stderr, "Invalid paramter '%c'n", opt);
print_help();
@@ -894,15 +991,31 @@ int main(int argc, char *argv[])
break;
next:
case GP_KEY_RIGHT:
+ if (shift_flag) {
+ zoom_offset_horiz(¶ms, 10);
+ break;
+ }
case GP_KEY_UP:
+ if (shift_flag) {
+ zoom_offset_vert(¶ms, -10);
+ break;
+ }
case GP_KEY_SPACE:
params.show_progress_once = 1;
show_image(¶ms, image_list_move(list, 1));
break;
prev:
- case GP_KEY_BACKSPACE:
case GP_KEY_LEFT:
+ if (shift_flag) {
+ zoom_offset_horiz(¶ms, -10);
+ break;
+ }
case GP_KEY_DOWN:
+ if (shift_flag) {
+ zoom_offset_vert(¶ms, 10);
+ break;
+ }
+ case GP_KEY_BACKSPACE:
params.show_progress_once = 1;
show_image(¶ms, image_list_move(list, -1));
break;
@@ -933,6 +1046,12 @@ int main(int argc, char *argv[])
case GP_KEY_9:
resize_backend(¶ms, 9, shift_flag);
break;
+ case GP_KEY_DOT:
+ zoom_mul(¶ms, 1.5);
+ break;
+ case GP_KEY_COMMA:
+ zoom_mul(¶ms, 1/1.5);
+ break;
}
break;
case GP_EV_SYS:
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 183 +++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 151 insertions(+), 32 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: f1688be3cd5e34c596afc0027b9c07d2cfec4325
by metan 28 Dec '12
by metan 28 Dec '12
28 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 f1688be3cd5e34c596afc0027b9c07d2cfec4325 (commit)
via 4cc70c909eb0e232bee1263f970d3f2262e34d96 (commit)
via 49cc14c142e17b791edbcce2a3b6ad5eef503227 (commit)
via 160879734f14a7aa8f676660fdc1bee7a2b256bb (commit)
from e13f2d1266a1d8fd179ac4c1b7276dbd831b6436 (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/f1688be3cd5e34c596afc0027b9c07d2cfec…
commit f1688be3cd5e34c596afc0027b9c07d2cfec4325
Merge: 4cc70c9 e13f2d1
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Dec 28 11:46:53 2012 +0100
Merge ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/4cc70c909eb0e232bee1263f970d3f2262e3…
commit 4cc70c909eb0e232bee1263f970d3f2262e34d96
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Dec 28 11:46:01 2012 +0100
spiv: Filter out non image files in dir traversal.
diff --git a/demos/spiv/image_list.c b/demos/spiv/image_list.c
index 1376130..fd35669 100644
--- a/demos/spiv/image_list.c
+++ b/demos/spiv/image_list.c
@@ -28,6 +28,7 @@
#include <errno.h>
#include <string.h>
+#include <loaders/GP_Loader.h>
#include <core/GP_Debug.h>
#include "image_list.h"
@@ -64,8 +65,10 @@ static int dir_filter(const struct dirent *d)
if (!strcmp(d->d_name, ".."))
return 0;
- //TODO: filter out directories, non-image files?
-
+ //TODO: filter out directories
+
+ if (GP_MatchExtension(d->d_name) == NULL)
+ return 0;
GP_DEBUG(4, "Adding file '%s'", d->d_name);
http://repo.or.cz/w/gfxprim.git/commit/49cc14c142e17b791edbcce2a3b6ad5eef50…
commit 49cc14c142e17b791edbcce2a3b6ad5eef503227
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Dec 28 11:43:11 2012 +0100
loaders: Add function to match loader by filename.
diff --git a/build/syms/Loaders_symbols.txt b/build/syms/Loaders_symbols.txt
index 2de93ed..bce6650 100644
--- a/build/syms/Loaders_symbols.txt
+++ b/build/syms/Loaders_symbols.txt
@@ -53,6 +53,7 @@ GP_SaveTmpFile
GP_LoadTmpFile
GP_MatchSignature
+GP_MatchExtension
GP_LoadImage
GP_SaveImage
GP_LoadMetaData
diff --git a/doc/loaders.txt b/doc/loaders.txt
index aa16606..907a171 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -41,7 +41,7 @@ Image Loader
[source,c]
-------------------------------------------------------------------------------
-#include <loaders/GP_Loaders.h>
+#include <loaders/GP_Loader.h>
/* or */
#include <GP.h>
@@ -66,7 +66,7 @@ stdout.
[source,c]
-------------------------------------------------------------------------------
-#include <loaders/GP_Loaders.h>
+#include <loaders/GP_Loader.h>
/* or */
#include <GP.h>
@@ -164,7 +164,7 @@ link:example_loader_registration.html[example].
[source,c]
-------------------------------------------------------------------------------
-#include <loaders/GP_Loaders.h>
+#include <loaders/GP_Loader.h>
/* or */
#include <GP.h>
@@ -175,6 +175,19 @@ Returns pointer to image loader accordingly to image signature or 'NULL' if no
suitable loader was found. The buf pointer must point to a buffer at least 32
bytes long.
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_Loader.h>
+/* or */
+#include <GP.h>
+
+const GP_Loader *GP_MatchExtension(const char *path)
+-------------------------------------------------------------------------------
+
+Matches loader by the file extension. This function does not check that the
+file exists or that it could be opened it only looks at the extension (i.e.
+string after the dot) and matches it agains known extensions.
+
WARNING: If you attempt to modify the content of the strucutre the behavior is
undefined. Most likely the program will crash.
diff --git a/include/loaders/GP_Loader.h b/include/loaders/GP_Loader.h
index 6730613..f80cf58 100644
--- a/include/loaders/GP_Loader.h
+++ b/include/loaders/GP_Loader.h
@@ -108,6 +108,11 @@ typedef struct GP_Loader {
*/
const GP_Loader *GP_MatchSignature(const void *buf);
+/*
+ * Tries to match loader by extension. Returns NULL if no loader was found.
+ */
+const GP_Loader *GP_MatchExtension(const char *path);
+
void GP_LoaderRegister(GP_Loader *self);
void GP_LoaderUnregister(GP_Loader *self);
diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c
index 1d15ec7..fdd2641 100644
--- a/libs/loaders/GP_Loader.c
+++ b/libs/loaders/GP_Loader.c
@@ -248,7 +248,7 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
ext_load = loader_by_filename(src_path);
- if (ext_load != NULL) {
+ if (ext_load != NULL && ext_load->Load != NULL) {
img = ext_load->Load(src_path, callback);
if (img)
@@ -259,7 +259,7 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
* Avoid further work if signature was correct but the loader issued
* ENOSYS.
*/
- if (errno == ENOSYS)
+ if (ext_load != NULL && errno == ENOSYS)
return NULL;
sig_load = loader_by_signature(src_path);
@@ -269,7 +269,7 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
src_path, ext_load->fmt_name, sig_load->fmt_name);
}
- if (sig_load)
+ if (sig_load && sig_load->Load != NULL)
return sig_load->Load(src_path, callback);
errno = ENOSYS;
@@ -445,3 +445,8 @@ const GP_Loader *GP_MatchSignature(const void *buf)
return NULL;
}
+
+const GP_Loader *GP_MatchExtension(const char *path)
+{
+ return loader_by_filename(path);
+}
http://repo.or.cz/w/gfxprim.git/commit/160879734f14a7aa8f676660fdc1bee7a2b2…
commit 160879734f14a7aa8f676660fdc1bee7a2b256bb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Dec 27 11:45:47 2012 +0100
doc: Add more text formatting.
diff --git a/doc/api.txt b/doc/api.txt
index a03d282..7d4898a 100644
--- a/doc/api.txt
+++ b/doc/api.txt
@@ -70,6 +70,8 @@ GFXprim API
Video grabbers interface such as V4L2.
+
+TIP: There is also a nice page with code link:examples.html[examples].
+
GFXprim Internals
-----------------
@@ -78,5 +80,3 @@ GFXprim Internals
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/backends.txt b/doc/backends.txt
index 5ee7e78..a4fb226 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -9,7 +9,7 @@ controlling the drawing.
So far there are backends for Linux mmaped frame-buffer, libSDL and X11.
-For example usage see backend link:example_backend.html[example].
+TIP: For example usage see backend link:example_backend.html[example].
Initialization functions
------------------------
diff --git a/doc/core.txt b/doc/core.txt
index 3e20ee2..a59938d 100644
--- a/doc/core.txt
+++ b/doc/core.txt
@@ -86,7 +86,7 @@ bitmap loaders 'errno' is set to 'ECANCELED'.
The callback, if supported, is the last parameter of a function.
-For example usage see progress callback
+TIP: For example usage see progress callback
link:example_loaders_progress_callback.html[example].
Temporary Buffer Allocator
diff --git a/doc/grabbers.txt b/doc/grabbers.txt
index a794847..ce71654 100644
--- a/doc/grabbers.txt
+++ b/doc/grabbers.txt
@@ -8,7 +8,7 @@ There is currently V4L2 driver that implements a grabber.
To link against grabbers use +-lGP_grabbers+ or better
+`gfxprim-config --libs-grabbers`+ in your linker flags.
-For example usage see grabber link:example_v4l2.html[examples].
+TIP: For example usage see grabber link:example_v4l2.html[examples].
Grabber API
~~~~~~~~~~~
diff --git a/doc/input.txt b/doc/input.txt
index 35ff473..f48f24d 100644
--- a/doc/input.txt
+++ b/doc/input.txt
@@ -15,7 +15,7 @@ difference is that events that belongs together are delivered together (the
kernel input API sends one event for each value i.e. x or y coordinate and has
sync event that finalizes the changes in the values).
-For example usage see input events link:example_input.html[example].
+TIP: For example usage see input events link:example_input.html[example].
Event Structure Description
~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/doc/loaders.txt b/doc/loaders.txt
index e12c6f8..aa16606 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -159,7 +159,7 @@ unregister your own loaders by 'GP_LoaderRegister()' and
'GP_LoaderUnregister()'. Once image loader is registered the generic loading
functions could use it to load and save images.
-For example usage see image loader registration
+TIP: For example usage see image loader registration
link:example_loader_registration.html[example].
[source,c]
-----------------------------------------------------------------------
Summary of changes:
build/syms/Loaders_symbols.txt | 1 +
demos/spiv/image_list.c | 7 +++++--
doc/api.txt | 4 ++--
doc/backends.txt | 2 +-
doc/core.txt | 2 +-
doc/grabbers.txt | 2 +-
doc/input.txt | 2 +-
doc/loaders.txt | 21 +++++++++++++++++----
include/loaders/GP_Loader.h | 5 +++++
libs/loaders/GP_Loader.c | 11 ++++++++---
10 files changed, 42 insertions(+), 15 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: e13f2d1266a1d8fd179ac4c1b7276dbd831b6436
by gavento 28 Dec '12
by gavento 28 Dec '12
28 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 e13f2d1266a1d8fd179ac4c1b7276dbd831b6436 (commit)
via 67b0b61db1e6e49583be60eb07807bacc77273f2 (commit)
via 25e233552995b48bf90f7631e075a8e83782b8fa (commit)
via 8cd7aa8c4396771f0e28b1677b571cfff171f1f1 (commit)
via aa090dff3b0c8343388fca5586e73653e9d66c12 (commit)
via 2bdf13f554c7ce4edf977dd73abcf520e145da64 (commit)
from df87777210da0ea03b70f5d8cf138050a5399e05 (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/e13f2d1266a1d8fd179ac4c1b7276dbd831b…
commit e13f2d1266a1d8fd179ac4c1b7276dbd831b6436
Merge: 67b0b61 df87777
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Fri Dec 28 02:15:23 2012 +0100
Merge branch 'master' of ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/67b0b61db1e6e49583be60eb07807bacc772…
commit 67b0b61db1e6e49583be60eb07807bacc77273f2
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Fri Dec 28 02:14:25 2012 +0100
core: pylib: Fix a bug in Context.Convert
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py
index 366d049..27c32e3 100644
--- a/pylib/gfxprim/core/__init__.py
+++ b/pylib/gfxprim/core/__init__.py
@@ -79,8 +79,8 @@ def _init(module):
@extend(_context)
def Convert(self, target_type):
"""Converts context to a different pixel type, allocates new context.
- See GP_ContextConvert() for details."""
- return c_core.GP_ContextConvert(self, pixeltype_no(target_type))
+ See GP_ContextConvertAlloc() for details."""
+ return c_core.GP_ContextConvertAlloc(self, pixeltype_no(target_type))
# Manipulation
extend_direct(_context, "PutPixel", c_core.GP_PutPixel,
http://repo.or.cz/w/gfxprim.git/commit/25e233552995b48bf90f7631e075a8e83782…
commit 25e233552995b48bf90f7631e075a8e83782b8fa
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Fri Dec 28 02:13:50 2012 +0100
core: pylib: Extend PixelTypeDescription with __str__
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py
index a4301f5..366d049 100644
--- a/pylib/gfxprim/core/__init__.py
+++ b/pylib/gfxprim/core/__init__.py
@@ -25,6 +25,14 @@ def _init(module):
from ..utils import extend, extend_direct, add_swig_getmethod, add_swig_setmethod
from ..utils import import_members
_context = module['Context']
+ _ptdescr = c_core.GP_PixelTypeDescription
+
+ # String representation
+
+ @extend(_ptdescr, name='__str__')
+ @extend(_ptdescr, name='__repr__')
+ def ptdescr_str(self):
+ return "<PixelTypeDescription %s>" % (self.name, )
# String representation
http://repo.or.cz/w/gfxprim.git/commit/8cd7aa8c4396771f0e28b1677b571cfff171…
commit 8cd7aa8c4396771f0e28b1677b571cfff171f1f1
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Fri Dec 28 02:12:37 2012 +0100
core: pylib: First Context tests and a runner
diff --git a/tests/pylib/runtests.sh b/tests/pylib/runtests.sh
new file mode 100755
index 0000000..a64a8c0
--- /dev/null
+++ b/tests/pylib/runtests.sh
@@ -0,0 +1,2 @@
+cd ../..
+./gp_run.sh nosetests -w tests/pylib/ "$@"
diff --git a/tests/pylib/test_core.py b/tests/pylib/test_core.py
new file mode 100644
index 0000000..2752c64
--- /dev/null
+++ b/tests/pylib/test_core.py
@@ -0,0 +1,68 @@
+
+### Helper imports and decorators
+# TODO: separate (nose plugin?)
+
+from unittest import SkipTest
+
+def alltypes(_filter=None):
+ def decorate(f):
+ def gen():
+ for t in core.PixelTypes[1:]:
+ if (_filter is None) or _filter(t):
+ yield f, t
+ gen.__name__ = f.__name__
+ return gen
+ return decorate
+
+
+### The actual tests
+
+from gfxprim import core
+from gfxprim.core import Context
+
+def test_basic_types_exist():
+ assert core.C.PIXEL_RGB888 > 0
+ assert core.C.PIXEL_RGBA8888 > 0
+ assert core.C.PIXEL_G8 > 0
+
+def test_create_context():
+ c = Context.Create(7, 9, core.C.PIXEL_RGB888)
+ assert c.w == 7
+ assert c.h == 9
+
+
+@alltypes()
+def test_create_context_and_check_sanity(t):
+ "Allocate Context by pixeltype and check basic invariants"
+ c = Context.Create(13, 15, t.type)
+ assert c.w == 13
+ assert c.h == 15
+ assert c._bit_endian == t.bit_endian
+ assert c.bpp == t.size
+ assert c._free_pixels
+
+@alltypes()
+def test_create_by_number(t):
+ "Allocation by pixeltype number"
+ c = Context.Create(3, 5, t)
+
+@alltypes()
+def test_context_convert_from_RGB888(t):
+ "Test conversion from RGB888"
+ if 'P' in t.name:
+ raise SkipTest("Palette conversion os TODO")
+ c = Context.Create(17, 19, core.C.PIXEL_RGB888)
+ # both by number and the pixeltype
+ c2 = c.Convert(t)
+ assert c2.pixel_type == t.type
+ c3 = c.Convert(t.type)
+ assert c3.pixel_type == t.type
+
+@alltypes()
+def test_context_convert_to_RGB888(t):
+ "Test conversion to RGB888"
+ if 'P' in t.name:
+ raise SkipTest("Palette conversion os TODO")
+ c = Context.Create(1, 1, t)
+ c2 = c.Convert(core.C.PIXEL_RGB888)
+ assert c2.pixel_type == core.C.PIXEL_RGB888
http://repo.or.cz/w/gfxprim.git/commit/aa090dff3b0c8343388fca5586e73653e9d6…
commit aa090dff3b0c8343388fca5586e73653e9d66c12
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Fri Dec 28 02:09:11 2012 +0100
Update .gitignore for pylib
diff --git a/.gitignore b/.gitignore
index 7007e36..f6c7e20 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,7 @@
config.h
config.gen.mk
gfxprim-config
+pylib/gfxprim/*/*_c.py
+pylib/gfxprim/*/*_wrap.c
+pylib/gfxprim/*/c_*.py
+
http://repo.or.cz/w/gfxprim.git/commit/2bdf13f554c7ce4edf977dd73abcf520e145…
commit 2bdf13f554c7ce4edf977dd73abcf520e145da64
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Thu Dec 27 21:24:06 2012 +0100
Make gp_run.sh (slightly) more robust
diff --git a/gp_run.sh b/gp_run.sh
index 4c76693..e1d60f3 100755
--- a/gp_run.sh
+++ b/gp_run.sh
@@ -2,7 +2,7 @@
# Very simple script to run python, ipython and GP executables
-BDIR=.
+BDIR=`pwd`
export LD_LIBRARY_PATH=$BDIR/build/
export PYTHONPATH=$BDIR/pylib/
-----------------------------------------------------------------------
Summary of changes:
.gitignore | 4 ++
gp_run.sh | 2 +-
pylib/gfxprim/core/__init__.py | 12 ++++++-
tests/pylib/runtests.sh | 2 +
tests/pylib/test_core.py | 68 ++++++++++++++++++++++++++++++++++++++++
5 files changed, 85 insertions(+), 3 deletions(-)
create mode 100755 tests/pylib/runtests.sh
create mode 100644 tests/pylib/test_core.py
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