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
November 2014
- 1 participants
- 3 discussions
23 Nov '14
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 acd8e4467957c330d8585838a54a054b58f24aca (commit)
from 1176d24e31d0d820628edf8b4d5ba74db4d51cb5 (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/acd8e4467957c330d8585838a54a054b58f2…
commit acd8e4467957c330d8585838a54a054b58f24aca
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Nov 23 09:50:55 2014 +0100
configure: Check for both ft2build.h and freetype2/ft2build.h
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/configure b/configure
index 4208355a..708233fb 100755
--- a/configure
+++ b/configure
@@ -7,18 +7,19 @@ import sys
from optparse import OptionParser
import subprocess
-def header_exists(cfg, filename):
- fpath = cfg['include_path'][0] + '/' + filename
+def header_exists(cfg, *filenames):
+ for filename in filenames:
+ fpath = cfg['include_path'][0] + '/' + filename
- sys.stderr.write("Checking for '%s' ... " % fpath)
+ sys.stderr.write("Checking for '%s' ... " % fpath)
- try:
- st = os.stat(fpath)
- sys.stderr.write("Yesn")
- return True
- except os.error:
- sys.stderr.write("Non")
- return False
+ try:
+ st = os.stat(fpath)
+ sys.stderr.write("Yesn")
+ return True
+ except os.error:
+ sys.stderr.write("Non")
+ return False
def c_try_compile(cfg, code, msg):
sys.stderr.write(msg)
@@ -411,7 +412,8 @@ if __name__ == '__main__':
[header_exists, "aalib.h"], "", "-laa", ["backends"]],
["freetype",
"A high-quality and portable font engine",
- [header_exists, "ft2build.h"], "", "`freetype-config --libs`", ["core"]],
+ [header_exists, "ft2build.h", "freetype2/ft2build.h"],
+ "", "`freetype-config --libs`", ["core"]],
["dl",
"Dynamic linker",
[header_exists, "dlfcn.h"], "", "-ldl", ["core"]],
-----------------------------------------------------------------------
Summary of changes:
configure | 24 +++++++++++++-----------
1 files changed, 13 insertions(+), 11 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
05 Nov '14
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
discards 7277e9f644891feda13a940bf14b3a6597d19d9f (commit)
This update discarded existing revisions and left the branch pointing at
a previous point in the repository history.
* -- * -- N (1176d24e31d0d820628edf8b4d5ba74db4d51cb5)
O -- O -- O (7277e9f644891feda13a940bf14b3a6597d19d9f)
The removed revisions are not necessarily gone - if another reference
still refers to them they will stay in the repository.
No new revisions were added by this update.
Summary of changes:
gen/bin/cct.py | 298 -----------------------------
gen/include/functions.t | 48 -----
gen/include/gfxprim_config.py | 136 -------------
gen/include/gfxprimconfig.py | 73 -------
gen/include/header.t | 11 -
gen/include/license.t | 10 -
gen/include/pixelsize.py | 39 ----
gen/include/pixeltype.py | 104 ----------
gen/include/source.t | 4 -
genn.mk | 48 -----
include/core/GP_Clamp.h | 7 -
include/core/GP_Convert.gen.h.t | 160 +++++++++-------
include/core/GP_Convert_Scale.gen.h.t | 55 ++++--
include/core/GP_FnPerBpp.gen.h.t | 69 ++++---
include/core/GP_GammaCorrection.gen.h.t | 45 ++++-
include/core/GP_GammaPixel.gen.h.t | 61 ++++--
include/core/GP_GetPutPixel.gen.h.t | 102 +++++++----
include/core/GP_MixPixels.gen.h.t | 96 ++++++---
include/core/GP_MixPixels2.gen.h.t | 54 ++++--
include/core/GP_Pixel.gen.h.t | 90 ++++++---
include/core/GP_WritePixel.gen.h.t | 43 ++++-
include/core/Makefile | 2 +-
include/gfx/GP_HLine.gen.h.t | 40 +++-
include/gfx/GP_VLine.gen.h.t | 40 +++-
include/gfx/Makefile | 2 +-
libs/core/GP_Blit.gen.c.t | 128 ++++++++-----
libs/core/GP_Convert.gen.c.t | 69 +++++--
libs/core/GP_Fill.gen.c.t | 54 ++++--
libs/core/GP_GammaCorrection.gen.c.t | 45 ++++-
libs/core/GP_Pixel.gen.c.t | 91 +++++----
libs/core/Makefile | 2 +-
libs/core/WritePixels.t | 37 +++-
libs/filters/GP_ApplyTables.gen.c.t | 63 +++++--
libs/filters/GP_Cubic.gen.c.t | 52 ++++-
libs/filters/GP_FloydSteinberg.gen.c.t | 145 ++++++++------
libs/filters/GP_GaussianNoise.gen.c.t | 81 +++++---
libs/filters/GP_HilbertPeano.gen.c.t | 83 ++++++---
libs/filters/GP_LinearConvolution.gen.c.t | 177 ++++++++++-------
libs/filters/GP_MirrorH.gen.c.t | 42 ++++-
libs/filters/GP_MultiTone.gen.c.t | 70 +++++--
libs/filters/GP_ResizeCubic.gen.c.t | 160 +++++++++-------
libs/filters/GP_ResizeLinear.gen.c.t | 203 +++++++++++---------
libs/filters/GP_ResizeNN.gen.c.t | 52 ++++--
libs/filters/GP_Rotate.gen.c.t | 69 +++++---
libs/filters/Makefile | 16 +-
libs/gfx/GP_FillCircle.gen.c.t | 45 ++++-
libs/gfx/GP_FillEllipse.gen.c.t | 42 ++++-
libs/gfx/GP_HLine.gen.c.t | 69 +++++--
libs/gfx/GP_HLineAA.gen.c.t | 8 +-
libs/gfx/GP_Line.gen.c.t | 45 ++++-
libs/gfx/GP_LineAA.gen.c.t | 8 +-
libs/gfx/GP_PutPixelAA.gen.c.t | 9 +-
libs/gfx/GP_VLine.gen.c.t | 38 +++-
libs/gfx/GP_VLineAA.gen.c.t | 8 +-
libs/gfx/Makefile | 2 +-
libs/text/GP_Text.gen.c.t | 91 ++++++---
libs/text/Makefile | 2 +-
tests/core/BlitConv.gen.c.t | 162 ++++++++++------
tests/core/Convert.gen.c.t | 236 +++++++++++++----------
tests/core/Convert_Scale.gen.c.t | 63 +++++--
tests/core/GetPutPixel.gen.c.t | 63 +++++--
tests/core/GetSetBits.gen.c.t | 73 +++++--
tests/core/Makefile | 2 +-
tests/core/WritePixel.gen.c.t | 96 +++++++---
tests/gfx/APICoverage.gen.c.t | 203 ++++++++++++--------
tests/gfx/Makefile | 2 +-
66 files changed, 2478 insertions(+), 2065 deletions(-)
delete mode 100755 gen/bin/cct.py
delete mode 100644 gen/include/functions.t
delete mode 100644 gen/include/gfxprim_config.py
delete mode 100644 gen/include/gfxprimconfig.py
delete mode 100644 gen/include/header.t
delete mode 100644 gen/include/license.t
delete mode 100644 gen/include/pixelsize.py
delete mode 100644 gen/include/pixeltype.py
delete mode 100644 gen/include/source.t
delete mode 100644 genn.mk
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
05 Nov '14
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 7277e9f644891feda13a940bf14b3a6597d19d9f (commit)
via 1176d24e31d0d820628edf8b4d5ba74db4d51cb5 (commit)
via c962710c01d67f93a2a39d49db5b5a678df8070e (commit)
via c0cfb2f6ac22689db526b97aa65cb0ca89bbb1cf (commit)
from 334730ba119db655383ca862373271fb11fd9d87 (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/7277e9f644891feda13a940bf14b3a6597d1…
commit 7277e9f644891feda13a940bf14b3a6597d19d9f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Oct 23 15:12:38 2014 +0200
Switch from jinj2 to cct
https://github.com/metan-ucw/cct
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/gen/bin/cct.py b/gen/bin/cct.py
new file mode 100755
index 00000000..29030ba6
--- /dev/null
+++ b/gen/bin/cct.py
@@ -0,0 +1,298 @@
+#!/usr/bin/env python
+#
+# Distributed under GPLv2.1 or any later
+#
+# Copyright (C) 2014 Tomas Gavenciak <gavento(a)ucw.cz>
+# Copyright (C) 2014 Cyril Hrubis <metan(a)ucw.cz>
+#
+
+import re
+import getopt
+from sys import argv, exit
+from os import path, remove, system
+
+def perror(filename, line, lineno, row, error):
+ print('%s:%i:%i: error: %sn' % (filename, lineno, row, error))
+ print(line)
+ print(' ' * row + '^n')
+ exit(1)
+
+# parse {{ expression }} blocks, escape special chars
+def transform_verbatim(filename, line, lineno, startrow=0):
+ tokens = re.split('({{|}})', line)
+ code = '"'
+ row = 0
+ in_code = False
+ for token in tokens:
+ if token == '{{':
+ if in_code:
+ perror(filename, line, lineno, row + startrow, 'Unexpected {{')
+ else:
+ in_code = True
+ code = code + '" + str('
+ elif token == '}}':
+ if in_code:
+ in_code = False
+ code = code + ') + "'
+ else:
+ perror(filename, line, lineno, row + startrow, 'Unexpected }}')
+ else:
+ # escape and " but only in verbatim mode
+ if not in_code:
+ token = token.replace("\", "\").replace('"', '\"')
+ code = code + token
+
+ row += len(token)
+
+ if in_code:
+ perror(filename, line, lineno, row + startrow, 'Unterminated {{')
+
+ return code + '"'
+
+def transform(filename, lines, include_dirs, startindent, indent_depth):
+ out = []
+ lastindent = 0
+ lineno = 0
+
+ for l in lines:
+ lineno += 1
+ l = l.rstrip('n')
+
+ if l == '@':
+ continue;
+
+ if re.match('s*(a)s.*', l):
+ padd = l[:len(l) - len(l.lstrip())]
+ l = l.lstrip()
+ # lines with '@ end' ends intent block by setting new indent
+ if re.match('@s*ends*', l):
+ lastindent = len(l[2:]) - len(l[2:].lstrip())
+ elif re.match('@s*include.*', l):
+ include_filename = re.sub('@s*includes*', '', l)
+ include_path = ''
+
+ if not include_filename:
+ perror(filename, l, lineno, len(l), 'Expected filename')
+
+ for dirname in include_dirs:
+ if path.isfile(dirname + '/' + include_filename):
+ include_path = dirname + '/' + include_filename
+ break
+
+ if not include_path:
+ perror(filename, l, lineno, len(l) - len(include_filename),
+ "Failed to locate '%s' in %s" %
+ (include_filename, include_dirs))
+
+ try:
+ infile = open(include_path, 'r')
+ except Exception as err:
+ perror(filename, l, lineno, len(l) - len(include_filename), str(err))
+
+ out = out + transform(include_filename, infile.readlines(),
+ include_dirs, lastindent + startindent,
+ indent_depth)
+
+ infile.close()
+ else:
+ code = re.sub('t', ' ', l[2:]).rstrip()
+ # full-line comments do not change last indent
+ if code and not re.match('^[ ]*#', code):
+ if code.endswith(':'):
+ lastindent = len(code) - len(code.lstrip()) + indent_depth
+ if (padd):
+ out.append(' ' * startindent + 'cct.set_padd("%s")' % padd)
+ out.append(' ' * startindent + code)
+ if (padd):
+ out.append(' ' * startindent + 'cct.set_padd("")')
+ # special handling for {@ call() @}
+ elif re.match('.*{@.*@}.*', l):
+ tokens = re.split('{@|@}', l)
+ if len(tokens) > 3:
+ row = len((tokens[0] + tokens[1] + tokens[2]).replace('t', ' '))
+ perror(filename, l, lineno, row + 4,
+ "Only one {@ call() @} per line is allowed")
+ prefix = transform_verbatim(filename, tokens[0], lineno)
+ startrow = len((tokens[0] + tokens[1]).replace('t', ' ')) + 2
+ suffix = transform_verbatim(filename, tokens[2], lineno, startrow)
+ out.append(' ' * (lastindent + startindent) + 'cct.set_prefix(' + prefix + ')')
+ out.append(' ' * (lastindent + startindent) + 'cct.set_suffix(' + suffix + ')')
+ out.append(' ' * (lastindent + startindent) + tokens[1].strip())
+ out.append(' ' * (lastindent + startindent) + 'cct.reset()')
+ else:
+ code = transform_verbatim(filename, l, lineno)
+ out.append(' ' * (lastindent + startindent) + 'cct.write(' + code + ')')
+
+ return out
+
+header = [
+ "#!/usr/bin/env python",
+ "#",
+ "# Generated file do _not_ edit by hand!",
+ "#",
+ "from sys import exit",
+ "from os import remove, path",
+ "",
+ "class cct:",
+ " def __init__(self, outfile_path, filename):",
+ " self.first = True",
+ " self.filename = filename",
+ " self.outfile_path = outfile_path",
+ " self.suffix = []",
+ " self.prefix = []",
+ " try:",
+ " self.outfile = open(outfile_path, 'w')",
+ " except Exception as err:",
+ " self.error('Failed to open file: ' + outfile_path + ' : ' + str(err))",
+ "",
+ " def error_cleanup(self):",
+ " self.outfile.close()",
+ " remove(self.outfile_path)",
+ "",
+ " def error(self, string):",
+ " self.error_cleanup()",
+ " print('cct: error: ' + string)",
+ " exit(1)",
+ "",
+ " def write(self, line):",
+ " if self.first:",
+ " if 'cct_header' in globals():",
+ " self.first = False",
+ " cct_header(path.basename(self.outfile_path), self.filename)",
+ " if not line and not ''.join(self.suffix):",
+ " prefix = ''.join(self.prefix).rstrip()",
+ " else:",
+ " prefix = ''.join(self.prefix)",
+ " self.outfile.write(prefix + line + ''.join(self.suffix) + '
')",
+ "",
+ " def set_prefix(self, prefix):",
+ " self.prefix.append(prefix)",
+ "",
+ " def set_suffix(self, suffix):",
+ " self.suffix.append(suffix)",
+ "",
+ " def reset(self):",
+ " self.suffix.pop()",
+ " self.prefix.pop()",
+ "",
+ " def close(self):",
+ " if 'cct_footer' in globals():",
+ " cct_footer(path.basename(self.outfile_path), self.filename)",
+ "",
+ " try:",
+ " self.outfile.close()",
+ " except Exception as err:",
+ " self.error('Failed to write ' + self.outfile_path + ' : ' + str(err))",
+ "",
+]
+
+footer = [
+ "except Exception as err:",
+ " cct.error_cleanup()",
+ " raise",
+ "cct.close()",
+]
+
+def generate(filename, lines, include_dirs, indent_depth, outfile):
+ out = header
+ out.append("cct = cct('%s', '%s')" % (outfile, filename))
+ out.append("")
+ out.append("try:")
+ res = transform(filename, lines, include_dirs, indent_depth, indent_depth)
+ out = out + res + footer
+ return 'n'.join(out)
+
+def error(error):
+ print(error)
+ exit(1)
+
+def usage():
+ print('Usage:ncct [-Idir] [-v] [-o outfile] file.c.tn')
+ print('-EntStops at first phase, leaves python script')
+ print('-intSets indenntation depth, default is 4')
+ print('-IntAdds include path(s)')
+ print('-ontSets output file')
+ print('-vntSets verbose mode')
+ print('-h | --helpntPrints this help.')
+
+def write_script(script_name, t):
+ try:
+ result = open(script_name, 'w')
+ except Exception as err:
+ error('Failed to open file: ' + script_name + ' : ' + str(err))
+
+ result.write(t)
+
+ try:
+ result.close()
+ except Exception as err:
+ error('Failed to close file: ' + script_name + ' : ' + str(err))
+
+def main():
+ try:
+ opts, args = getopt.getopt(argv[1:], 'Eho:i:I:v', ['help'])
+ except getopt.GetoptError as err:
+ print(str(err))
+ usage()
+ exit(1)
+
+ include_dirs = ['.']
+ verbose = False
+ outfile = ''
+ execute = True
+ indent_depth = 4
+
+ for opt, arg in opts:
+ if opt in ('-h', '--help'):
+ usage()
+ exit(0)
+ elif opt == '-i':
+ indent_depth = int(arg)
+ elif opt == '-I':
+ include_dirs.append(arg)
+ elif opt == '-v':
+ verbose = True
+ elif opt == '-o':
+ outfile = arg
+ elif opt == '-E':
+ execute = False
+
+ if len(args) != 1:
+ error('No input files.')
+
+ if not outfile:
+ if not args[0].endswith('.t'):
+ error('No outfile set and template does not end with .t')
+
+ outfile = args[0][:-2]
+
+ if verbose:
+ print("Settingsn--------")
+ print("Include Dirs: %s" % include_dirs)
+ print("Template File: %s" % args[0])
+ print("Output File: %s" % outfile)
+ print("Indentation Depth: %i" % indent_depth)
+ print("")
+
+ with open(args[0], 'rt') as f:
+ t = generate(args[0], f.readlines(), include_dirs, indent_depth, outfile)
+
+ script_name = outfile + '.py'
+
+ if execute:
+ try:
+ glob = {}
+ exec(t, glob)
+ except Exception:
+ # Something failed fallback to writing file
+ # and executing it because the error trace
+ # from exec() tends to be less informative
+ write_script(script_name, t)
+ system('python ' + script_name)
+ remove(script_name)
+ exit(1)
+ else:
+ write_script(script_name, t)
+
+if __name__ == '__main__':
+ main()
diff --git a/gen/include/functions.t b/gen/include/functions.t
new file mode 100644
index 00000000..81e995dd
--- /dev/null
+++ b/gen/include/functions.t
@@ -0,0 +1,48 @@
+@ from gfxprim_config import config
+@ pixelsizes = config.pixelsizes
+@ pixeltypes_dict = config.pixeltypes_dict
+@ pixeltypes = config.pixeltypes
+@ pixelsizes_by_bpp = config.pixelsizes_by_bpp
+@
+@ def arr_to_params(array, prefix='', suffix=''):
+@ res = []
+@ for i in array:
+@ res.append(prefix + str(i) + suffix)
+@ return ', '.join(res)
+@ end
+@
+@ def gamma_in_bits(size):
+@ if size + 2 > 8:
+@ return 16
+@ else:
+@ return 8
+@ end
+@
+@ def gamma_out_bits(size):
+@ if size > 8:
+@ return 16
+@ else:
+@ return 8
+@ end
+@
+@ def fetch_gamma_tables(pt, ctx, pref="", suff=""):
+/* prepare Gamma tables */
+@ for c in pt.chanslist:
+uint{{ gamma_in_bits(c[2]) }}_t *{{ pref + c.name }}_2_LIN{{ suff }} = NULL;
+@ end
+@ for c in pt.chanslist:
+uint{{ gamma_out_bits(c[2]) }}_t *{{ pref + c.name }}_2_GAMMA{{ suff }} = NULL;
+@ end
+@ i = 0
+
+if ({{ ctx }}->gamma) {
+@ for c in pt.chanslist:
+ {{ pref + c.name }}_2_LIN{{ suff }} = {{ ctx }}->gamma->tables[{{ i }}]->u{{ gamma_in_bits(c[2]) }};
+@ i = i + 1
+@ i = len(pt.chanslist)
+@ for c in pt.chanslist:
+ {{ pref + c.name }}_2_GAMMA{{ suff }} = {{ ctx }}->gamma->tables[{{ i }}]->u{{ gamma_out_bits(c[2]) }};
+@ i = i + 1
+@ end
+}
+@ end
diff --git a/gen/include/gfxprim_config.py b/gen/include/gfxprim_config.py
new file mode 100644
index 00000000..3682ccf4
--- /dev/null
+++ b/gen/include/gfxprim_config.py
@@ -0,0 +1,136 @@
+#
+# gfxprim_config.py - module configuring GfxPrim code generation and
+# known PixelTypes
+#
+
+#
+# 2011 Tomas Gavenciak <gavento(a)ucw.cz>
+# 2011-2013 Cyril Hrubis <metan(a)ucw.cz>
+#
+# This file is sourced by all the generating scripts.
+# Moreover, the generated files are sourced by almost all Gfxprim sources,
+# so a complete recompilation is required after any change.
+#
+
+from pixeltype import PixelType
+from pixelsize import PixelSize, LE, BE
+from gfxprimconfig import GfxPrimConfig
+
+# Declared pixel sizes:
+PS_1BPP_LE = PixelSize(1, bit_endian=LE)
+PS_1BPP_BE = PixelSize(1, bit_endian=BE)
+PS_2BPP_LE = PixelSize(2, bit_endian=LE)
+PS_2BPP_BE = PixelSize(2, bit_endian=BE)
+PS_4BPP_LE = PixelSize(4, bit_endian=LE)
+PS_4BPP_BE = PixelSize(4, bit_endian=BE)
+PS_8BPP = PixelSize(8)
+PS_16BPP = PixelSize(16)
+PS_24BPP = PixelSize(24)
+PS_32BPP = PixelSize(32)
+# Experimental:
+PS_18BPP_LE = PixelSize(18, bit_endian=LE)
+
+config = GfxPrimConfig(
+
+ # C name and bit-size of the GP_pixel type
+ pixel_type = "uint32_t",
+ pixel_size = 32,
+
+ # List of pixel sizes (bpp), explicit on purpose
+ pixelsizes = [PS_1BPP_LE, PS_1BPP_BE, PS_2BPP_LE, PS_2BPP_BE, PS_4BPP_LE, PS_4BPP_BE,
+ PS_8BPP, PS_16BPP, PS_24BPP, PS_32BPP,
+ PS_18BPP_LE,
+ ],
+
+ # List of PixelTypes, order defines the numbering.
+ # The "Undefined" type is added automatically.
+ pixeltypes = [
+
+ #
+ # Standard RGB types
+ #
+ PixelType(name='xRGB8888', pixelsize=PS_32BPP, chanslist=[
+ ('R', 16, 8),
+ ('G', 8, 8),
+ ('B', 0, 8)]),
+
+ PixelType(name='RGBA8888', pixelsize=PS_32BPP, chanslist=[
+ ('R', 24, 8),
+ ('G', 16, 8),
+ ('B', 8, 8),
+ ('A', 0, 8)]),
+
+ PixelType(name='RGB888', pixelsize=PS_24BPP, chanslist=[
+ ('R', 16, 8),
+ ('G', 8, 8),
+ ('B', 0, 8)]),
+
+ PixelType(name='BGR888', pixelsize=PS_24BPP, chanslist=[
+ ('B', 16, 8),
+ ('G', 8, 8),
+ ('R', 0, 8)]),
+
+ PixelType(name='RGB555', pixelsize=PS_16BPP, chanslist=[
+ ('R', 10, 5),
+ ('G', 5, 5),
+ ('B', 0, 5)]),
+
+ PixelType(name='RGB565', pixelsize=PS_16BPP, chanslist=[
+ ('R', 11, 5),
+ ('G', 5, 6),
+ ('B', 0, 5)]),
+
+ PixelType(name='RGB666', pixelsize=PS_18BPP_LE, chanslist=[
+ ('R', 12, 6),
+ ('G', 6, 6),
+ ('B', 0, 6)]),
+
+ PixelType(name='RGB332', pixelsize=PS_8BPP, chanslist=[
+ ('R', 5, 3),
+ ('G', 2, 3),
+ ('B', 0, 2)]),
+
+ #
+ # CMYK
+ #
+ PixelType(name="CMYK8888", pixelsize=PS_32BPP, chanslist=[
+ ('K', 24, 8),
+ ('Y', 16, 8),
+ ('M', 8, 8),
+ ('C', 0, 8)]),
+
+ #
+ # Palette types
+ #
+ PixelType(name='P2', pixelsize=PS_2BPP_LE, chanslist=[
+ ('P', 0, 2)]),
+
+ PixelType(name='P4', pixelsize=PS_4BPP_LE, chanslist=[
+ ('P', 0, 4)]),
+
+ PixelType(name='P8', pixelsize=PS_8BPP, chanslist=[
+ ('P', 0, 8)]),
+
+ #
+ # Gray-only pixel types
+ #
+ PixelType(name='G1', pixelsize=PS_1BPP_LE, chanslist=[
+ ('V', 0, 1)]),
+
+ PixelType(name='G2', pixelsize=PS_2BPP_LE, chanslist=[
+ ('V', 0, 2)]),
+
+ PixelType(name='G4', pixelsize=PS_4BPP_LE, chanslist=[
+ ('V', 0, 4)]),
+
+ PixelType(name='G8', pixelsize=PS_8BPP, chanslist=[
+ ('V', 0, 8)]),
+
+ PixelType(name='GA88', pixelsize=PS_16BPP, chanslist=[
+ ('V', 0, 8),
+ ('A', 8, 8)]),
+
+ PixelType(name='G16', pixelsize=PS_16BPP, chanslist=[
+ ('V', 0, 16)]),
+ ]
+ )
diff --git a/gen/include/gfxprimconfig.py b/gen/include/gfxprimconfig.py
new file mode 100644
index 00000000..fb990dff
--- /dev/null
+++ b/gen/include/gfxprimconfig.py
@@ -0,0 +1,73 @@
+#
+# gfxprimconfig - Class for (global) GfxPrim configuration
+#
+# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
+# 2011 - Cyril Hrubis <metan(a)ucw.cz>
+
+import os
+import logging as log
+from pixeltype import PixelType
+from pixelsize import PixelSize
+
+class GfxPrimConfig(object):
+ def __init__(self, pixel_type = None, pixel_size=None, pixelsizes=None,
+ pixeltypes=None):
+ """Initialize GfxPrim code generation config
+
+ pixel_type: name of C type for a pixel value
+ pixel_size: number of bits of pixel_type
+ pixelsizes: list of generated and allowed PixelSizes
+ pixelsizes_by_bpp: dictionary of bitendians by BPP
+ pixeltypes: list of generated PixelTypes, not incl. UNKNOWN
+ """
+
+ self.pixel_type = pixel_type
+ assert self.pixel_type
+ assert isinstance(self.pixel_type, str)
+
+ self.pixel_size = pixel_size
+ assert isinstance(self.pixel_size, int)
+ assert self.pixel_size % 8 == 0
+ assert self.pixel_size > 0
+
+ # Allowed bit-sizes of pixel types
+ self.pixelsizes = pixelsizes
+ assert isinstance(self.pixelsizes, list)
+ assert self.pixel_size in [i.size for i in self.pixelsizes]
+ for i in self.pixelsizes:
+ assert i.size <= self.pixel_size
+
+ # Dictionary of all pixelsizes by BPP { bpp : list of BE, LE }
+ self.pixelsizes_by_bpp = dict()
+ for i in self.pixelsizes:
+ if i.size not in self.pixelsizes_by_bpp:
+ self.pixelsizes_by_bpp[i.size] = [i.bit_endian]
+ else:
+ self.pixelsizes_by_bpp[i.size].append(i.bit_endian)
+
+ # Set of all encountered channel names
+ self.channels = set()
+
+ # Dictionary of all pixeltypes { name : PixelType }
+ self.pixeltypes_dict = {}
+ # List of all PixelTypes in order. "Unknown" MUST be first.
+ self.pixeltypes = []
+
+ self.add_pixeltype(PixelType("UNKNOWN", PixelSize(0), []))
+ if pixeltypes:
+ for t in pixeltypes:
+ self.add_pixeltype(t)
+
+ def add_pixeltype(self, pixeltype):
+ "Add a PixelType and check its against the config"
+
+ assert pixeltype not in self.pixeltypes
+ self.pixeltypes.append(pixeltype)
+ assert pixeltype.name not in self.pixeltypes_dict
+ self.pixeltypes_dict[pixeltype.name] = pixeltype
+ self.channels.update(set(pixeltype.chans.keys()))
+ try:
+ pixeltype.valid_for_config(self)
+ except AssertionError:
+ log.error("Error checking PixelType %sn" % pixeltype.name)
+
diff --git a/gen/include/header.t b/gen/include/header.t
new file mode 100644
index 00000000..210cf243
--- /dev/null
+++ b/gen/include/header.t
@@ -0,0 +1,11 @@
+@ include functions.t
+@
+@ def cct_header(filename, template):
+@ include license.t
+@ guard = filename.upper().replace('.', '_')
+#ifndef {{ guard }}
+#define {{ guard }}
+
+@ def cct_footer(filename, template):
+@ guard = filename.upper().replace('.', '_')
+#endif /* {{ guard }} */
diff --git a/gen/include/license.t b/gen/include/license.t
new file mode 100644
index 00000000..6d651b5d
--- /dev/null
+++ b/gen/include/license.t
@@ -0,0 +1,10 @@
+@ from datetime import datetime
+/*
+ * Distributed under GPLv2 or any later.
+ *
+ * {{ filename }}
+ *
+ * GENERATED on {{ datetime.now().strftime("%Y %m %d %H:%M:%S") }} from {{ template }}
+ *
+ * DO NOT MODIFY THIS FILE DIRECTLY!
+ */
diff --git a/gen/include/pixelsize.py b/gen/include/pixelsize.py
new file mode 100644
index 00000000..59f7c910
--- /dev/null
+++ b/gen/include/pixelsize.py
@@ -0,0 +1,39 @@
+#
+# gfxprim.pixelsize
+#
+# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
+#
+
+LE = "LE"
+BE = "BE"
+
+class PixelSize(object):
+ def __init__(self, size, bit_endian=None, suffix=None):
+ self.size = size
+ assert self.size >= 0
+
+ self.bit_endian = bit_endian
+ assert self.bit_endian in [None, LE, BE]
+ assert (bit_endian is not None) == self.needs_bit_endian()
+ self.bit_endian_const = "GP_BIT_ENDIAN_" + (self.bit_endian or LE)
+
+ self.suffix = suffix
+ if not self.suffix:
+ if self.size == 0:
+ self.suffix = "INVALID"
+ else:
+ if bit_endian:
+ self.suffix = '%dBPP_%s' % (size, bit_endian)
+ else:
+ self.suffix = '%dBPP' % (size,)
+
+ def needs_bit_endian(self):
+ return (self.size % 8) != 0
+
+ def description(self):
+ if self.bit_endian:
+ return "pixel size %d, bit endian %s, suffix %s" % (self.size,
+ self.bit_endian, self.suffix)
+ else:
+ return "pixel size %d, suffix %s" % (self.size, self.suffix)
+
diff --git a/gen/include/pixeltype.py b/gen/include/pixeltype.py
new file mode 100644
index 00000000..e42e103e
--- /dev/null
+++ b/gen/include/pixeltype.py
@@ -0,0 +1,104 @@
+#
+# gfxprim.pixeltype - Module with PixelType descrition class
+#
+# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
+# 2013 Cyril Hrubis <metan(a)ucw.cz>
+#
+
+import re
+from pixelsize import PixelSize
+
+class PixelChannel(list):
+ def __init__(self, triplet, idx):
+ (name, offset, size) = triplet
+ # Create the list -> backward compatibility with triplets
+ self.append(name)
+ self.append(offset)
+ self.append(size)
+ # Add index (position in pixel from left)
+ self.idx = idx
+ # Add some convinience variables
+ self.name = name
+ self.off = offset
+ self.size = size
+ # Shift ready to used in C
+ self.C_shift = " << " + hex(offset)
+ # Maximal channel value as an integer
+ self.max = 2 ** size - 1
+ # Maximal value as a C string
+ self.C_max = hex(self.max)
+ # Chanel bitmask as int
+ self.mask = self.max * (2 ** offset)
+ # Channel bitmas as hex string
+ self.C_mask = hex(self.mask)
+
+class PixelType(object):
+ """Representation of one GP_PixelType"""
+
+ def __init__(self, name, pixelsize, chanslist):
+ """`name` must be a valid C identifier
+ `pixelsize` is an instance of PixelSize
+ `chanslist` is a list of triplets describing individual channels as
+ [ (`chan_name`, `bit_offset`, `bit_size`) ]
+ where `chan_name` is usually one of: R, G, B,
+ V (value, used for grayscale), A (opacity)
+ """
+ assert re.match('A[A-Za-z][A-Za-z0-9_]*Z', name)
+ self.name = name
+ # Create channel list with convinience variables
+ new_chanslist = []
+ self.chan_names = []
+ idx = 0
+ for i in chanslist:
+ new_chanslist.append(PixelChannel(i, idx))
+ idx = idx + 1
+ self.chan_names.append(i[0])
+ self.chanslist = new_chanslist
+ self.chans = dict() # { chan_name: (offset, size) }
+ self.pixelsize = pixelsize
+ # C enum as defined in GP_Pixel.gen.h
+ self.C_type = "GP_PIXEL_" + self.name
+
+ # Verify channel bits for overlaps
+ # also builds a bit-map of the PixelType
+ self.bits = ['x'] * pixelsize.size
+ for c in new_chanslist:
+ assert c[0] not in self.chans.keys()
+ self.chans[c[0]] = c
+ for i in range(c[1], c[1] + c[2]):
+ assert(i < self.pixelsize.size)
+ assert(self.bits[i] == 'x')
+ self.bits[i] = c[0]
+
+ def valid_for_config(self, config):
+ "Check PixelType compatibility with given GfxPrimConfig."
+
+ # all types except UNKNOWN must have one of these sizes
+ if not self.is_unknown():
+ assert(self.pixelsize in config.pixelsizes)
+
+ def __str__(self):
+ return "<PixelType " + self.name + ">"
+
+ def is_palette(self):
+ return ('P' in self.chans)
+
+ def is_unknown(self):
+ return (self.name == "UNKNOWN")
+
+ def is_rgb(self):
+ for i in 'RGB':
+ if i not in self.chans: return False
+ return True
+
+ def is_gray(self):
+ return ('V' in self.chans)
+
+ def is_cmyk(self):
+ for i in 'CMYK':
+ if i not in self.chans: return False
+ return True
+
+ def is_alpha(self):
+ return ('A' in self.chans)
+
diff --git a/gen/include/source.t b/gen/include/source.t
new file mode 100644
index 00000000..f3b08b12
--- /dev/null
+++ b/gen/include/source.t
@@ -0,0 +1,4 @@
+@ include functions.t
+@
+@ def cct_header(filename, template):
+@ include license.t
diff --git a/genn.mk b/genn.mk
new file mode 100644
index 00000000..235cd5fc
--- /dev/null
+++ b/genn.mk
@@ -0,0 +1,48 @@
+#
+# This is makefile rule for generating C sources from python templates
+#
+ifndef GENHEADERS
+GENHEADERS=
+endif
+
+ifndef GENSOURCES
+GENSOURCES=
+endif
+
+#
+# We add these to CSOURCES which is handled in post.mk
+#
+CSOURCES+=$(GENSOURCES)
+
+#
+# Make the genrated headers actually build
+#
+ALL+=$(GENHEADERS) $(GENSOURCES)
+
+#
+# Base common templates location
+#
+TEMPLATEDIR=$(TOPDIR)/gen/include/
+CCT=$(TOPDIR)/gen/bin/cct.py
+
+#
+# And clean them
+#
+CLEAN+=$(GENSOURCES) $(GENHEADERS)
+
+#
+# Some base dependencies
+#
+$(GENSOURCES): $(TEMPLATEDIR)/source.t $(TEMPLATEDIR)/license.t
+$(GENHEADERS): $(TEMPLATEDIR)/header.t $(TEMPLATEDIR)/license.t
+
+#
+# Generated files depend on python generators and the template
+#
+$(GENSOURCES) $(GENHEADERS): %: %.t
+ifdef VERBOSE
+ PYTHONPATH=$(TEMPLATEDIR) ${CCT} -I $(TEMPLATEDIR) "$@.t"
+else
+ @echo "CCT $@"
+ @PYTHONPATH=$(TEMPLATEDIR) ${CCT} -I $(TEMPLATEDIR) "$@.t"
+endif
diff --git a/include/core/GP_Clamp.h b/include/core/GP_Clamp.h
index ac87cb73..bc32507d 100644
--- a/include/core/GP_Clamp.h
+++ b/include/core/GP_Clamp.h
@@ -62,4 +62,11 @@
GP_CLAMP_GENERIC(val, min, max); })
+#define GP_CLAMP_DOWN(val, max) ({ + typeof(val) _val = (val); + typeof(val) _max = (max); + _val = _val > _max ? _max : _val; + _val; +})
+
#endif /* CORE_GP_CLAMP_H */
diff --git a/include/core/GP_Convert.gen.h.t b/include/core/GP_Convert.gen.h.t
index b59990a0..ee266eaf 100644
--- a/include/core/GP_Convert.gen.h.t
+++ b/include/core/GP_Convert.gen.h.t
@@ -1,41 +1,22 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2011-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.h.t"
-
-{% block descr %}Convert PixelType values macros and functions{% endblock %}
-
-{# RGB -> CMYK requires special handling #}
-%% macro rgb_to_cmyk(in, out)
-%% set R = in.chans['R']
-%% set G = in.chans['G']
-%% set B = in.chans['B']
-%% set C = out.chans['C']
-%% set M = out.chans['M']
-%% set Y = out.chans['Y']
-%% set K = out.chans['K']
-%% set max_size = max(R.size, G.size, B.size)
-%% set max_val = 2 ** max_size - 1
+@ include header.t
+/*
+ * Convert PixelType values macros and functions
+ *
+ * Copyright (C) 2011-2014 Cyril Hrubis <metan(a)ucw.cz>
+ * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz>
+ */
+@
+@ # RGB -> CMYK requires special handling
+@ def rgb_to_cmyk(in_pix, out_pix):
+@ R = in_pix.chans['R']
+@ G = in_pix.chans['G']
+@ B = in_pix.chans['B']
+@ C = out_pix.chans['C']
+@ M = out_pix.chans['M']
+@ Y = out_pix.chans['Y']
+@ K = out_pix.chans['K']
+@ max_size = max(R.size, G.size, B.size)
+@ max_val = 2 ** max_size - 1
GP_Pixel _R = GP_SCALE_VAL_{{ R.size }}_{{ max_size }}(GP_GET_BITS({{ R.off }}+o1, {{ R.size }}, p1)); GP_Pixel _G = GP_SCALE_VAL_{{ G.size }}_{{ max_size }}(GP_GET_BITS({{ G.off }}+o1, {{ G.size }}, p1)); GP_Pixel _B = GP_SCALE_VAL_{{ B.size }}_{{ max_size }}(GP_GET_BITS({{ B.off }}+o1, {{ B.size }}, p1)); @@ -44,85 +25,78 @@
GP_SET_BITS({{ M.off }}+o2, {{ M.size }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ M.size }}((_K - _G))); GP_SET_BITS({{ Y.off }}+o2, {{ Y.size }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ Y.size }}((_K - _B))); GP_SET_BITS({{ K.off }}+o2, {{ K.size }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ K.size }}({{ max_val }} - _K)); -%% endmacro
-
-%% macro GP_Pixel_TYPE_TO_TYPE(pt1, pt2)
+@ end
+@
+@ def GP_Pixel_TYPE_TO_TYPE(pt1, pt2):
/*** {{ pt1.name }} -> {{ pt2.name }} ***
* macro reads p1 ({{ pt1.name }} at bit-offset o1)
* and writes to p2 ({{ pt2.name }} at bit-offset o2)
* the relevant part of p2 is assumed to be cleared (zero) */
#define GP_Pixel_{{ pt1.name }}_TO_{{ pt2.name }}_OFFSET(p1, o1, p2, o2) do { -{# special cases -#}
-%% if pt1.is_rgb() and pt2.is_cmyk()
-{{ rgb_to_cmyk(pt1, pt2) -}}
-%% else
-%% for c2 in pt2.chanslist
-{# case 1: just copy a channel -#}
-%% if c2[0] in pt1.chans.keys()
-%% set c1 = pt1.chans[c2[0]]
+@ # special cases
+@ if pt1.is_rgb() and pt2.is_cmyk():
+@ rgb_to_cmyk(pt1, pt2)
+@ else:
+@ for c2 in pt2.chanslist:
+@ # case 1: just copy a channel
+@ if c2[0] in pt1.chans.keys():
+@ c1 = pt1.chans[c2[0]]
/* {{ c2[0] }}:={{ c1[0] }} */ GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2, GP_SCALE_VAL_{{ c1.size }}_{{ c2.size }}(GP_GET_BITS({{ c1.off }}+o1, {{ c1.size }}, p1))); -{# case 2: set A to full opacity (not present in source) -#}
-%% elif c2[0]=='A'
+@ # case 2: set A to full opacity (not present in source)
+@ elif c2[0]=='A':
/* A:={{ c2.C_max }} */GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2, {{ c2.C_max }}); -{# case 3: calculate V as average of RGB -#}
-%% elif c2[0]=='V' and pt1.is_rgb()
+@ # case 3: calculate V as average of RGB
+@ elif c2[0]=='V' and pt1.is_rgb():
/* V:=RGB_avg */ GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2, ( -%% for c1 in [pt1.chans['R'], pt1.chans['G'], pt1.chans['B']]
+@ for c1 in [pt1.chans['R'], pt1.chans['G'], pt1.chans['B']]:
/* {{ c1.name }} */ GP_SCALE_VAL_{{ c1.size }}_{{ c2.size }}(GP_GET_BITS({{ c1.off }}+o1, {{ c1.size }}, p1)) + -%% endfor
+@ end
0)/3);-{# case 4: set each RGB to V -#}
-%% elif c2[0] in 'RGB' and pt1.is_gray()
-%% set c1 = pt1.chans['V']
+@ # case 4: set each RGB to V -#}
+@ elif c2[0] in 'RGB' and pt1.is_gray():
+@ c1 = pt1.chans['V']
/* {{ c2[0] }}:=V */ GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2, GP_SCALE_VAL_{{ c1.size }}_{{ c2.size }}(GP_GET_BITS({{ c1.off }}+o1, {{ c1.size }}, p1))); -{# case 5: CMYK to RGB -#}
-%% elif c2[0] in 'RGB' and pt1.is_cmyk()
-%% set K = pt1.chans['K']
-{# Get the right channel -#}
-%% if c2[0] == 'R'
-%% set V = pt1.chans['C']
-%% elif c2[0] == 'G'
-%% set V = pt1.chans['M']
-%% else
-%% set V = pt1.chans['Y']
-%% endif
+@ # case 5: CMYK to RGB
+@ elif c2[0] in 'RGB' and pt1.is_cmyk():
+@ K = pt1.chans['K']
+@ if c2[0] == 'R':
+@ V = pt1.chans['C']
+@ elif c2[0] == 'G':
+@ V = pt1.chans['M']
+@ else:
+@ V = pt1.chans['Y']
+@ end
GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2, (({{ c2.C_max }} * ({{ K.C_max }} - GP_GET_BITS({{ K.off }}+o1, {{ K.size }}, p1)) * ({{ V.C_max }} - GP_GET_BITS({{ V.off }}+o1, {{ V.size }}, p1)))) / ({{ K.C_max }} * {{ V.C_max }})); -{# case 7: invalid mapping -#}
-%% else
+@ # case 7: invalid mapping
+@ else:
{{ error('Channel conversion ' + pt1.name + ' to ' + pt2.name + ' not supported.') }}
-%% endif
-%% endfor
-%% endif
+@ end
} while (0)
/* a version without offsets */
#define GP_Pixel_{{ pt1.name }}_TO_{{ pt2.name }}(p1, p2) GP_Pixel_{{ pt1.name }}_TO_{{ pt2.name }}_OFFSET(p1, 0, p2, 0)
-%% endmacro
+@ end
-
-%% block body
#include "GP_GetSetBits.h"
#include "GP_Context.h"
#include "GP_Pixel.h"
-{#
- # Loop around "central" pixel types
--#}
-%% for pt in [pixeltypes_dict['RGB888'], pixeltypes_dict['RGBA8888']]
-%% for i in pixeltypes
-%% if not i.is_unknown() and not i.is_palette()
-{{ GP_Pixel_TYPE_TO_TYPE(pt, i) }}
-%% if i.name not in ['RGB888', 'RGBA8888']
-{{ GP_Pixel_TYPE_TO_TYPE(i, pt) }}
-%% endif
-%% endif
-%% endfor
+@
+@ # Loop around "central" pixel types
+@
+@ for pt in [pixeltypes_dict['RGB888'], pixeltypes_dict['RGBA8888']]:
+@ for i in pixeltypes:
+@ if not i.is_unknown() and not i.is_palette():
+@ GP_Pixel_TYPE_TO_TYPE(pt, i)
+@ if i.name not in ['RGB888', 'RGBA8888']:
+@ GP_Pixel_TYPE_TO_TYPE(i, pt)
+@ end
/*
* Convert {{ pt.name }} to any other PixelType
@@ -136,10 +110,8 @@ GP_Pixel GP_{{ pt.name }}ToPixel(GP_Pixel pixel, GP_PixelType type);
*/
GP_Pixel GP_PixelTo{{ pt.name }}(GP_Pixel pixel, GP_PixelType type);
-%% endfor
+@ end
/* Experimental macros testing generated scripts */
-{{ GP_Pixel_TYPE_TO_TYPE(pixeltypes_dict['RGB565'], pixeltypes_dict['RGBA8888']) }}
-{{ GP_Pixel_TYPE_TO_TYPE(pixeltypes_dict['RGBA8888'], pixeltypes_dict['G2']) }}
-
-%% endblock body
+@ GP_Pixel_TYPE_TO_TYPE(pixeltypes_dict['RGB565'], pixeltypes_dict['RGBA8888'])
+@ GP_Pixel_TYPE_TO_TYPE(pixeltypes_dict['RGBA8888'], pixeltypes_dict['G2'])
diff --git a/include/core/GP_Convert_Scale.gen.h.t b/include/core/GP_Convert_Scale.gen.h.t
index b0156ad4..335cdbd9 100644
--- a/include/core/GP_Convert_Scale.gen.h.t
+++ b/include/core/GP_Convert_Scale.gen.h.t
@@ -1,35 +1,15 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * Copyright (C) 2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.h.t"
-
-{% block descr %}Fast value scaling macros{% endblock %}
+@ include header.t
+/*
+ * Fast value scaling macros
+ *
+ * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz>
+ * Copyright (C) 2013-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
-{% macro multcoef(s1, s2) -%}
-(0{% for i in range((s2 + s1 - 1) // s1) %}+{{ hex(2 ** (i * s1)) }}{% endfor %})
-{%- endmacro %}
+@ def multcoef(s1, s2):
+(0+{{'+'.join([hex(2 ** (i * s1)) for i in range((s2 + s1 - 1)//s1)])}})
+@ end
-%% block body
/*
* Helper macros to transfer s1-bit value to s2-bit value.
* Efficient and accurate for both up- and downscaling.
@@ -37,14 +17,9 @@
*/
#define GP_SCALE_VAL(s1, s2, val) ( GP_SCALE_VAL_##s1##_##s2(val) )
-%% for s1 in range(1,33)
-%% for s2 in range(1,17)
-%% if s2 > s1
-#define GP_SCALE_VAL_{{s1}}_{{s2}}(val) (((val) * {{ multcoef(s1, s2) }}) >> {{ (-s2) % s1 }})
-%% else
+@ for s1 in range(1,33):
+@ for s2 in range(1,17):
+@ if s2 > s1:
+#define GP_SCALE_VAL_{{s1}}_{{s2}}(val) (((val) * {@ multcoef(s1, s2) @}) >> {{ (-s2) % s1 }})
+@ else:
#define GP_SCALE_VAL_{{s1}}_{{s2}}(val) ((val) >> {{ s1 - s2 }})
-%% endif
-%% endfor
-%% endfor
-
-%% endblock body
diff --git a/include/core/GP_FnPerBpp.gen.h.t b/include/core/GP_FnPerBpp.gen.h.t
index 9b1cdcdb..e2364e5f 100644
--- a/include/core/GP_FnPerBpp.gen.h.t
+++ b/include/core/GP_FnPerBpp.gen.h.t
@@ -1,58 +1,42 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2011-2012 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends 'base.h.t'
-
-{% block descr %}All FnPerBpp macros{% endblock %}
-
-{% block body %}
+@ include header.t
+/*
+ * All FnPerBpp macros
+ *
+ * Copyright (C) 2011-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
/*
* Macros used to create draving functions from macros.
*/
#define GP_DEF_FN_PER_BPP(fname, MACRO_NAME, fdraw) -%% for ps in pixelsizes
+@ for ps in pixelsizes:
GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, {{ ps.suffix }}) -{% endfor %}
+@ end
+@
+@ def bpp_suffix(suffix):
+@ if suffix == "LE" or suffix == "BE":
+_{{ suffix }}
+@ else:
-{% macro bpp_suffix(suffix) %}{% if suffix == "LE" or suffix == "BE" %}_{{ suffix }}{% endif %}{% endmacro %}
+@ end
/*
* Branch on bpp and bit_endian.
*/
#define GP_FN_PER_BPP(FN_NAME, bpp, bit_endian, ...) switch (bpp) { -%% for bpp in pixelsizes_by_bpp.keys()
+@ for bpp in pixelsizes_by_bpp.keys():
case {{ bpp }}: -%% if len(pixelsizes_by_bpp[bpp]) == 1
- FN_NAME##_{{ bpp }}BPP{{ bpp_suffix(pixelsizes_by_bpp[bpp][0]) }}(__VA_ARGS__); -%% else
+@ if len(pixelsizes_by_bpp[bpp]) == 1:
+ FN_NAME##_{{ bpp }}BPP{@ bpp_suffix(pixelsizes_by_bpp[bpp][0]) @}(__VA_ARGS__); +@ else:
if (bit_endian == GP_BIT_ENDIAN_LE) FN_NAME##_{{ bpp }}BPP_LE(__VA_ARGS__); else FN_NAME##_{{ bpp }}BPP_BE(__VA_ARGS__); -%% endif
+@ end
break; -%% endfor
+@ end
}
/*
@@ -60,18 +44,17 @@
*/
#define GP_FN_RET_PER_BPP(FN_NAME, bpp, bit_endian, ...) switch (bpp) { -%% for bpp in pixelsizes_by_bpp.keys()
+@ for bpp in pixelsizes_by_bpp.keys():
case {{ bpp }}: -%% if len(pixelsizes_by_bpp[bpp]) == 1
- return FN_NAME##_{{ bpp }}BPP{{ bpp_suffix(pixelsizes_by_bpp[bpp][0]) }}(__VA_ARGS__); -%% else
+@ if len(pixelsizes_by_bpp[bpp]) == 1:
+ return FN_NAME##_{{ bpp }}BPP{@ bpp_suffix(pixelsizes_by_bpp[bpp][0]) @}(__VA_ARGS__); +@ else:
if (bit_endian == GP_BIT_ENDIAN_LE) return FN_NAME##_{{ bpp }}BPP_LE(__VA_ARGS__); else return FN_NAME##_{{ bpp }}BPP_BE(__VA_ARGS__); -%% endif
+@ end
break; -%% endfor
+@ end
}
-{% endblock body %}
diff --git a/include/core/GP_GammaCorrection.gen.h.t b/include/core/GP_GammaCorrection.gen.h.t
index 76df078f..59610665 100644
--- a/include/core/GP_GammaCorrection.gen.h.t
+++ b/include/core/GP_GammaCorrection.gen.h.t
@@ -1,49 +1,24 @@
-/*****************************************************************************
- * 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) 2012 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.h.t"
-
-{% block descr %}Gamma corrections.{% endblock %}
-
-%% block body
-
+@ include header.t
+/*
+ * Gamma corrections
+ *
+ * Copyright (C) 2012-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
extern uint16_t *GP_Gamma8_Linear10;
extern uint8_t *GP_Linear10_Gamma8;
-%% for i in range(1, 9)
+@ for i in range(1, 9):
static inline uint16_t GP_Gamma{{ i }}ToLinear10(uint8_t val)
{
return GP_Gamma8_Linear10[val<<{{8 - i}}];
}
-%% endfor
-
-%% for i in range(1, 9)
+@ end
+@ for i in range(1, 9):
static inline uint8_t GP_Linear10ToGamma{{ i }}(uint16_t val)
{
return (GP_Linear10_Gamma8[val] + {{ int(2 ** (7 - i))}})>>{{8 - i}};
}
-%% endfor
-
-%% endblock body
+@ end
diff --git a/include/core/GP_GammaPixel.gen.h.t b/include/core/GP_GammaPixel.gen.h.t
index cefb5cca..14ace8a4 100644
--- a/include/core/GP_GammaPixel.gen.h.t
+++ b/include/core/GP_GammaPixel.gen.h.t
@@ -1,39 +1,18 @@
-/*****************************************************************************
- * 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) 2012 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.h.t"
-
-{% block descr %}Gamma correction for pixels.{% endblock %}
-
-%% block body
+@ include header.t
+/*
+ * Gamma correction for pixels
+ *
+ * Copyright (C) 2012-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include "GP_Context.h"
#include "GP_GammaCorrection.h"
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_palette()
-%% set idx = 0
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
+@ idx = 0
-%% for c in pt.chanslist
+@ for c in pt.chanslist:
/*
* Converts gamma encoded pixel value to linear value.
@@ -41,11 +20,11 @@
* Parameters are, converted value and GP_Gamma structure.
*/
#define GP_Gamma2Lin_{{ pt.name }}_{{ c[0] }}(val, gamma) ({ -%% if c[2] > 6
+@ if c[2] > 6:
gamma->tables[{{ idx }}]->u16[val]; -%% else
+@ else:
gamma->tables[{{ idx }}]->u8[val]; -%% endif
+@ end
})
/*
@@ -54,11 +33,11 @@
* Parameters are, converted value and GP_Gamma structure.
*/
#define GP_Lin2Gamma_{{ pt.name }}_{{ c[0] }}(val, gamma) ({ -%% if c[2] > 8
+@ if c[2] > 8:
gamma->tables[{{ len(pt.chanslist) + idx}}]->u16[val]; -%% else
+@ else:
gamma->tables[{{ len(pt.chanslist) + idx}}]->u8[val]; -%% endif
+@ end
})
static inline GP_GammaTable *GP_GammaTable_{{ pt.name }}_{{ c[0] }}(GP_Gamma *gamma)
@@ -71,10 +50,8 @@ static inline GP_GammaTable *GP_GammaInverseTable_{{ pt.name }}_{{ c[0] }}(GP_Ga
return gamma->tables[{{ len(pt.chanslist) + idx }}];
}
-%% set idx = idx + 1
-%% endfor
-%% endif
-%% endfor
+@ idx = idx + 1
+@ end
#define GP_Gamma2Lin(val, chan_bits, gamma_table) ({ #if chan_bits > 6
@@ -91,5 +68,3 @@ static inline GP_GammaTable *GP_GammaInverseTable_{{ pt.name }}_{{ c[0] }}(GP_Ga
gamma_table->table8[val] #endif
})
-
-%% endblock body
diff --git a/include/core/GP_GetPutPixel.gen.h.t b/include/core/GP_GetPutPixel.gen.h.t
index 28ee82d7..39c4d06c 100644
--- a/include/core/GP_GetPutPixel.gen.h.t
+++ b/include/core/GP_GetPutPixel.gen.h.t
@@ -1,35 +1,11 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2011 Cyril Hrubis <metan(a)ucw.cz> *
- * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.h.t"
-
-%% block descr
-Access pixel bytes, Get and PutPixel
-Do not include directly, use GP_Pixel.h
-%% endblock
-
-%% block body
-
+@ include header.t
+/*
+ * Access pixel bytes, Get and PutPixel
+ * Do not include directly, use GP_Pixel.h
+ *
+ * Copyright (C) 2011-2014 Cyril Hrubis <metan(a)ucw.cz>
+ * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz>
+ */
/*
@@ -75,7 +51,7 @@ Do not include directly, use GP_Pixel.h
#include "GP_GetSetBits.h"
#include "GP_Context.h"
-%% for ps in pixelsizes
+@ for ps in pixelsizes:
/*
* macro to get address of pixel in a {{ ps.suffix }} context
*/
@@ -86,45 +62,42 @@ Do not include directly, use GP_Pixel.h
* macro to get bit-offset of pixel in {{ ps.suffix }} context
*/
#define GP_PIXEL_ADDR_OFFSET_{{ ps.suffix }}(x) -%% if not ps.needs_bit_endian()
+@ if not ps.needs_bit_endian():
(0)
-%% else
-%% if ps.bit_endian == LE
-%% if ps.size < 8
+@ else:
+@ if ps.bit_endian == 'LE':
+@ if ps.size < 8:
(((x) % {{ 8 // ps.size }}) * {{ ps.size }})
-%% else
+@ else:
(({{ ps.size }} * (x)) % 8)
-%% endif
-%% else
-%% if ps.size < 8
+@ else:
+@ if ps.size < 8:
({{ 8 - ps.size }} - ((x) % {{ 8 // ps.size }}) * {{ ps.size }})
-%% else
+@ else:
{{ error('Insanity check: big bit-endian with >8 bpp. Are you sure?') }}
-%% endif
-%% endif
-%% endif
+@ end
/*
* GP_GetPixel for {{ ps.suffix }}
*/
static inline GP_Pixel GP_GetPixel_Raw_{{ ps.suffix }}(const GP_Context *c, int x, int y)
{
-%% if ps.size == 32
+@ if ps.size == 32:
/*
* 32 BPP is expected to have aligned pixels
*/
return *((uint32_t*)GP_PIXEL_ADDR_{{ ps.suffix }}(c, x, y));
-%% elif ps.size == 16
+@ elif ps.size == 16:
/*
* 16 BPP is expected to have aligned pixels
*/
return *((uint16_t*)GP_PIXEL_ADDR_{{ ps.suffix }}(c, x, y));
-%% elif ps.size == 8
+@ elif ps.size == 8:
/*
* 8 BPP is byte aligned
*/
return *((uint8_t*)GP_PIXEL_ADDR_{{ ps.suffix }}(c, x, y));
-%% elif ps.size == 1 or ps.size == 2 or ps.size == 4 or ps.size == 8
+@ elif ps.size == 1 or ps.size == 2 or ps.size == 4 or ps.size == 8:
/*
* Whole pixel is stored only and only in one byte
*
@@ -132,7 +105,7 @@ static inline GP_Pixel GP_GetPixel_Raw_{{ ps.suffix }}(const GP_Context *c, int
*/
return GP_GET_BITS1_ALIGNED(GP_PIXEL_ADDR_OFFSET_{{ ps.suffix }}(x), {{ ps.size }},
*(GP_PIXEL_ADDR_{{ ps.suffix }}(c, x, y)));
-%% elif ps.size <= 10 or ps.size == 12 or ps.size == 16
+@ elif ps.size <= 10 or ps.size == 12 or ps.size == 16:
/*
* The pixel is stored in one or two bytes
*
@@ -146,7 +119,7 @@ static inline GP_Pixel GP_GetPixel_Raw_{{ ps.suffix }}(const GP_Context *c, int
*/
return GP_GET_BITS2_ALIGNED(GP_PIXEL_ADDR_OFFSET_{{ ps.suffix }}(x), {{ ps.size }},
*(GP_PIXEL_ADDR_{{ ps.suffix }}(c, x, y)));
-%% elif ps.size <= 18 or ps.size == 20 or ps.size == 24
+@ elif ps.size <= 18 or ps.size == 20 or ps.size == 24:
/*
* The pixel is stored in two or three bytes
*
@@ -160,7 +133,7 @@ static inline GP_Pixel GP_GetPixel_Raw_{{ ps.suffix }}(const GP_Context *c, int
*/
return GP_GET_BITS3_ALIGNED(GP_PIXEL_ADDR_OFFSET_{{ ps.suffix }}(x), {{ ps.size }},
*(GP_PIXEL_ADDR_{{ ps.suffix }}(c, x, y)));
-%% elif ps.size <= 23 or ps.size == 25 or ps.size == 26 or ps.size == 28 or ps.size == 32
+@ elif ps.size <= 23 or ps.size == 25 or ps.size == 26 or ps.size == 28 or ps.size == 32:
/*
* The pixel is stored in three or four bytes
*
@@ -174,9 +147,9 @@ static inline GP_Pixel GP_GetPixel_Raw_{{ ps.suffix }}(const GP_Context *c, int
*/
return GP_GET_BITS4_ALIGNED(GP_PIXEL_ADDR_OFFSET_{{ ps.suffix }}(x), {{ ps.size }},
*(GP_PIXEL_ADDR_{{ ps.suffix }}(c, x, y)));
-%% else
+@ else:
#error not implemented
-%% endif
+@ end
}
/*
@@ -184,22 +157,22 @@ static inline GP_Pixel GP_GetPixel_Raw_{{ ps.suffix }}(const GP_Context *c, int
*/
static inline void GP_PutPixel_Raw_{{ ps.suffix }}(GP_Context *c, int x, int y, GP_Pixel p)
{
-%% if ps.size == 32
+@ if ps.size == 32:
/*
* 32 BPP is expected to have aligned pixels
*/
*((uint32_t*)GP_PIXEL_ADDR_{{ ps.suffix }}(c, x, y)) = p;
-%% elif ps.size == 16
+@ elif ps.size == 16:
/*
* 16 BPP is expected to have aligned pixels
*/
*((uint16_t*)GP_PIXEL_ADDR_{{ ps.suffix }}(c, x, y)) = p;
-%% elif ps.size == 8
+@ elif ps.size == 8:
/*
* 8 BPP is byte aligned
*/
*((uint8_t*)GP_PIXEL_ADDR_{{ ps.suffix }}(c, x, y)) = p;
-%% elif ps.size == 1 or ps.size == 2 or ps.size == 4 or ps.size == 8
+@ elif ps.size == 1 or ps.size == 2 or ps.size == 4 or ps.size == 8:
/*
* Whole pixel is stored only and only in one byte
*
@@ -207,7 +180,7 @@ static inline void GP_PutPixel_Raw_{{ ps.suffix }}(GP_Context *c, int x, int y,
*/
GP_SET_BITS1_ALIGNED(GP_PIXEL_ADDR_OFFSET_{{ ps.suffix }}(x), {{ ps.size }},
GP_PIXEL_ADDR_{{ ps.suffix }}(c, x, y), p);
-%% elif ps.size <= 10 or ps.size == 12 or ps.size == 16
+@ elif ps.size <= 10 or ps.size == 12 or ps.size == 16:
/*
* The pixel is stored in one or two bytes
*
@@ -221,7 +194,7 @@ static inline void GP_PutPixel_Raw_{{ ps.suffix }}(GP_Context *c, int x, int y,
*/
GP_SET_BITS2_ALIGNED(GP_PIXEL_ADDR_OFFSET_{{ ps.suffix }}(x), {{ ps.size }},
GP_PIXEL_ADDR_{{ ps.suffix }}(c, x, y), p);
-%% elif ps.size <= 18 or ps.size == 20 or ps.size == 24
+@ elif ps.size <= 18 or ps.size == 20 or ps.size == 24:
/*
* The pixel is stored in two or three bytes
*
@@ -235,7 +208,7 @@ static inline void GP_PutPixel_Raw_{{ ps.suffix }}(GP_Context *c, int x, int y,
*/
GP_SET_BITS3_ALIGNED(GP_PIXEL_ADDR_OFFSET_{{ ps.suffix }}(x), {{ ps.size }},
GP_PIXEL_ADDR_{{ ps.suffix }}(c, x, y), p);
-%% elif ps.size <= 23 or ps.size == 25 or ps.size == 26 or ps.size == 28 or ps.size == 32
+@ elif ps.size <= 23 or ps.size == 25 or ps.size == 26 or ps.size == 28 or ps.size == 32:
/*
* The pixel is stored in three or four bytes
*
@@ -249,9 +222,9 @@ static inline void GP_PutPixel_Raw_{{ ps.suffix }}(GP_Context *c, int x, int y,
*/
GP_SET_BITS4_ALIGNED(GP_PIXEL_ADDR_OFFSET_{{ ps.suffix }}(x), {{ ps.size }},
GP_PIXEL_ADDR_{{ ps.suffix }}(c, x, y), p);
-%% else
+@ else:
#error not implemented
-%% endif
+@ end
}
static inline void GP_PutPixel_Raw_Clipped_{{ ps.suffix }}(GP_Context *c, GP_Coord x, GP_Coord y, GP_Pixel p)
@@ -262,6 +235,3 @@ static inline void GP_PutPixel_Raw_Clipped_{{ ps.suffix }}(GP_Context *c, GP_Coo
GP_PutPixel_Raw_{{ ps.suffix }}(c, x, y, p);
}
-%% endfor
-
-%% endblock body
diff --git a/include/core/GP_MixPixels.gen.h.t b/include/core/GP_MixPixels.gen.h.t
index 7333fe9f..518ed9bc 100644
--- a/include/core/GP_MixPixels.gen.h.t
+++ b/include/core/GP_MixPixels.gen.h.t
@@ -1,40 +1,17 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2011-2012 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.h.t"
-
-%% block descr
-Macros to mix two pixels accordingly to percentage.
-%% endblock
-
-%% block body
+@ include header.t
+/*
+ * Macros to mix two pixels accordingly to percentage.
+ *
+ * Copyright (C) 2011-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include "core/GP_Context.h"
#include "core/GP_Pixel.h"
#include "core/GP_GetPutPixel.h"
#include "core/GP_GammaCorrection.h"
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
/*
* Mixes two {{ pt.name }} pixels.
@@ -42,16 +19,16 @@ Macros to mix two pixels accordingly to percentage.
* The percentage is expected as 8 bit unsigned integer [0 .. 255]
*/
#define GP_MIX_PIXELS_LINEAR_{{ pt.name }}(pix1, pix2, perc) ({ -%% for c in pt.chanslist
+@ for c in pt.chanslist:
GP_Pixel {{ c[0] }}; {{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix1) * (perc); {{ c[0] }} += GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix2) * (255 - (perc)); {{ c[0] }} = ({{ c[0] }} + 128) / 255; -%% endfor
+@ end
- GP_Pixel_CREATE_{{ pt.name }}({{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, {{ c[0] }}{% endfor %}); + GP_Pixel_CREATE_{{ pt.name }}({{ ', '.join(pt.chan_names) }}); })
/*
@@ -60,7 +37,7 @@ Macros to mix two pixels accordingly to percentage.
* The percentage is expected as 8 bit unsigned integer [0 .. 255]
*/
#define GP_MIX_PIXELS_GAMMA_{{ pt.name }}(pix1, pix2, perc) ({ -%% for c in pt.chanslist
+@ for c in pt.chanslist:
GP_Pixel {{ c[0] }}; {{ c[0] }} = GP_Gamma{{ c[2] }}ToLinear10(GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix1)) * (perc); @@ -68,39 +45,35 @@ Macros to mix two pixels accordingly to percentage.
{{ c[0] }} = ({{ c[0] }} + 128) / 255; {{ c[0] }} = GP_Linear10ToGamma{{ c[2] }}({{ c[0] }}); -%% endfor
+@ end
- GP_Pixel_CREATE_{{ pt.name }}({{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, {{ c[0] }}{% endfor %}); + GP_Pixel_CREATE_{{ pt.name }}({{ ", ".join(pt.chan_names) }}); })
#define GP_MIX_PIXELS_{{ pt.name }}(pix1, pix2, perc) -%% if pt.is_rgb()
+@ if pt.is_rgb():
GP_MIX_PIXELS_LINEAR_{{ pt.name }}(pix1, pix2, perc)
-%% else
+@ else:
GP_MIX_PIXELS_LINEAR_{{ pt.name }}(pix1, pix2, perc)
-%% endif
-
-%% endif
-%% endfor
+@ end
static inline GP_Pixel GP_MixPixels(GP_Pixel pix1, GP_Pixel pix2,
uint8_t perc, GP_PixelType pixel_type)
{
switch (pixel_type) {
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
case GP_PIXEL_{{ pt.name }}:
return GP_MIX_PIXELS_LINEAR_{{ pt.name }}(pix1, pix2, perc);
-%% endif
-%% endfor
+@ end
default:
GP_ABORT("Unknown pixeltype");
}
}
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
static inline void GP_MixPixel_Raw_{{ pt.name }}(GP_Context *context,
GP_Coord x, GP_Coord y, GP_Pixel pixel, uint8_t perc)
{
@@ -109,11 +82,10 @@ static inline void GP_MixPixel_Raw_{{ pt.name }}(GP_Context *context,
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(context, x, y, pix);
}
-%% endif
-%% endfor
+@ end
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
static inline void GP_MixPixel_Raw_Clipped_{{ pt.name }}(GP_Context *context,
GP_Coord x, GP_Coord y, GP_Pixel pixel, uint8_t perc)
{
@@ -123,20 +95,18 @@ static inline void GP_MixPixel_Raw_Clipped_{{ pt.name }}(GP_Context *context,
GP_MixPixel_Raw_{{ pt.name }}(context, x, y, pixel, perc);
}
-%% endif
-%% endfor
+@ end
static inline void GP_MixPixel_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
GP_Pixel pixel, uint8_t perc)
{
switch (context->pixel_type) {
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
case GP_PIXEL_{{ pt.name }}:
GP_MixPixel_Raw_{{ pt.name }}(context, x, y, pixel, perc);
break;
-%% endif
-%% endfor
+@ end
default:
GP_ABORT("Unknown pixeltype");
}
@@ -147,16 +117,14 @@ static inline void GP_MixPixel_Raw_Clipped(GP_Context *context,
GP_Pixel pixel, uint8_t perc)
{
switch (context->pixel_type) {
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
case GP_PIXEL_{{ pt.name }}:
GP_MixPixel_Raw_Clipped_{{ pt.name }}(context, x, y, pixel, perc);
break;
-%% endif
-%% endfor
+@ end
default:
GP_ABORT("Unknown pixeltype");
}
}
-%% endblock body
diff --git a/include/core/GP_MixPixels2.gen.h.t b/include/core/GP_MixPixels2.gen.h.t
index 084ae551..d2ffcd1a 100644
--- a/include/core/GP_MixPixels2.gen.h.t
+++ b/include/core/GP_MixPixels2.gen.h.t
@@ -1,43 +1,20 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.h.t"
-
-%%- block descr
-Macros to mix two pixels. The source must have alpha channel.
-%%- endblock
-
-%% block body
+@ include header.t
+/*
+ * Macros to mix two pixels. The source must have alpha channel.
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include "core/GP_GammaCorrection.h"
#include "core/GP_Pixel.h"
//TODO: Fix blit where both source and destination have alpha channel
-%% for src in pixeltypes
-%% if not src.is_unknown() and not src.is_palette()
-%% for dst in pixeltypes
-%% if not dst.is_unknown() and not dst.is_palette()
-%% if src.is_alpha()
+@ for src in pixeltypes:
+@ if not src.is_unknown() and not src.is_palette():
+@ for dst in pixeltypes:
+@ if not dst.is_unknown() and not dst.is_palette():
+@ if src.is_alpha():
static inline GP_Pixel GP_MixPixels_{{ src.name }}_{{ dst.name }}(GP_Pixel src, GP_Pixel dst)
{
@@ -61,7 +38,7 @@ static inline GP_Pixel GP_MixPixels_{{ src.name }}_{{ dst.name }}(GP_Pixel src,
dg = GP_Pixel_GET_G_RGB888(dst_rgb);
db = GP_Pixel_GET_B_RGB888(dst_rgb);
-%% set a_max = 2 ** src.chans['A'][2] - 1
+@ a_max = 2 ** src.chans['A'][2] - 1
dr = (dr * ({{ a_max }} - alpha) + sr * alpha + {{ a_max // 2 }}) / {{ a_max }};
dg = (dg * ({{ a_max }} - alpha) + sg * alpha + {{ a_max // 2 }}) / {{ a_max }};
@@ -74,10 +51,3 @@ static inline GP_Pixel GP_MixPixels_{{ src.name }}_{{ dst.name }}(GP_Pixel src,
return res;
}
-%% endif
-%% endif
-%% endfor
-%% endif
-%% endfor
-
-%% endblock
diff --git a/include/core/GP_Pixel.gen.h.t b/include/core/GP_Pixel.gen.h.t
index 2bc54690..eba8b3ea 100644
--- a/include/core/GP_Pixel.gen.h.t
+++ b/include/core/GP_Pixel.gen.h.t
@@ -1,68 +1,45 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * Copyright (C) 2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.h.t"
-
-%% block descr
-Pixel type definitions and functions.
-Do not include directly, use GP_Pixel.h
-%% endblock
-
-%% block body
+@ include header.t
+/*
+ * Pixel type definitions and functions.
+ * Do not include directly, use GP_Pixel.h
+ *
+ * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz>
+ * Copyright (C) 2013 Cyril Hrubis <metan(a)ucw.cz>
+ */
/*
* List of all known pixel types
*/
typedef enum GP_PixelType {
-%% for pt in pixeltypes
+@ for pt in pixeltypes:
GP_PIXEL_{{ pt.name }},
-%% endfor
+@ end
GP_PIXEL_MAX,
} GP_PixelType;
-%% for pt in pixeltypes
+@ for pt in pixeltypes:
#define GP_PIXEL_{{ pt.name }} GP_PIXEL_{{ pt.name }}
-%% endfor
+@ end
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
/* Automatically generated code for pixel type {{ pt.name }}
*
* Size (bpp): {{ pt.pixelsize.size }} ({{ pt.pixelsize.suffix }})
* Bit endian: {{ pt.pixelsize.bit_endian_const }}
- * Pixel structure: {{ pt.bits|join("") }}
+ * Pixel structure: {{ "".join(pt.bits) }}
* Channels:
-%% for c in pt.chanslist
+@ for c in pt.chanslist:
* {{ c[0] }} offset:{{ c[1] }} size:{{ c[2] }}
-%% endfor
+@ end
*/
/*
* macros to get channels of pixel type {{ pt.name }}
*/
-%% for c in pt.chanslist
+@ for c in pt.chanslist:
#define GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(p) (GP_GET_BITS({{ c[1] }}, {{ c[2] }}, (p)))
-%% endfor
+@ end
/*
* macros to get address and bit-offset of a pixel {{ pt.name }} in a context
@@ -74,32 +51,29 @@ typedef enum GP_PixelType {
* macros to create GP_Pixel of pixel type {{ pt.name }} directly from given values.
* The values MUST be already clipped/converted to relevant value ranges.
*/
-#define GP_Pixel_CREATE_{{ pt.name }}({{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, {{ c[0] }}{% endfor %}) (0-%% for c in pt.chanslist
+#define GP_Pixel_CREATE_{{ pt.name }}({{ ', '.join(pt.chan_names) }}) (0+@ for c in pt.chanslist:
+ (({{ c[0] }}) << {{ c[1] }}) -%% endfor
+@ end
)
-%% endif
-%% endfor
+@ end
/*
* macros for branching on PixelType (similar to GP_FnPerBpp macros)
*/
-%% for r in ['', 'return ']
-#define GP_FN_{% if r %}RET_{% endif %}PER_PIXELTYPE(FN_NAME, type, ...)+@ for r in [('', ''), ('return ', 'RET_')]:
+#define GP_FN_{{ r[1] }}PER_PIXELTYPE(FN_NAME, type, ...) switch (type) { -%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
case GP_PIXEL_{{ pt.name }}:- {{ r }}FN_NAME{{'##'}}_{{ pt.name }}(__VA_ARGS__);- break;-%% endif
-%% endfor
+ {{ r[0] }}FN_NAME{{'##'}}_{{ pt.name }}(__VA_ARGS__);+@ if not r[0]:
+ break;+@ end
+@ end
default: GP_ABORT("Invalid PixelType %d", type); }
-%% endfor
-
-%% endblock body
diff --git a/include/core/GP_WritePixel.gen.h.t b/include/core/GP_WritePixel.gen.h.t
index 015dc7c3..3e611f2d 100644
--- a/include/core/GP_WritePixel.gen.h.t
+++ b/include/core/GP_WritePixel.gen.h.t
@@ -1,30 +1,9 @@
-/*****************************************************************************
- * 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 descr %}Write Pixels generated header{% endblock %}
-
-{% block body %}
+@ include header.t
+/*
+ * Write Pixels generated header
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
/*
* These functions writes cnt pixels using value val starting at start address
@@ -32,15 +11,11 @@
* at off offset in the first byte (i.e. byte at the start address).
*/
-%% for ps in pixelsizes
-%% if ps.needs_bit_endian()
+@ for ps in pixelsizes:
+@ if ps.needs_bit_endian():
void GP_WritePixels_{{ ps.suffix }}(void *start, uint8_t off,
size_t cnt, unsigned int val);
-%% else
+@ else:
void GP_WritePixels_{{ ps.suffix }}(void *start, size_t cnt, unsigned int val);
-%% endif
-%% endfor
-
-{% endblock body %}
diff --git a/include/core/Makefile b/include/core/Makefile
index 6267d32f..fb723b95 100644
--- a/include/core/Makefile
+++ b/include/core/Makefile
@@ -7,5 +7,5 @@ GENHEADERS=GP_Convert_Scale.gen.h GP_Pixel.gen.h GP_MixPixels.gen.h GP_GammaCorrection.gen.h GP_GammaPixel.gen.h GP_WritePixel.gen.h GP_MixPixels2.gen.h
-include $(TOPDIR)/gen.mk
+include $(TOPDIR)/genn.mk
include $(TOPDIR)/post.mk
diff --git a/include/gfx/GP_HLine.gen.h.t b/include/gfx/GP_HLine.gen.h.t
index 8e696a7f..1ed91346 100644
--- a/include/gfx/GP_HLine.gen.h.t
+++ b/include/gfx/GP_HLine.gen.h.t
@@ -1,35 +1,11 @@
-/*****************************************************************************
- * 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 descr %}HLine generated header{% endblock %}
-
-{% block body %}
-
-%% for ps in pixelsizes
+@ include header.t
+/*
+ * HLine generated header
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
+
+@ 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_VLine.gen.h.t b/include/gfx/GP_VLine.gen.h.t
index 11a8702e..0261557d 100644
--- a/include/gfx/GP_VLine.gen.h.t
+++ b/include/gfx/GP_VLine.gen.h.t
@@ -1,35 +1,11 @@
-/*****************************************************************************
- * 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 descr %}VLine generated header{% endblock %}
-
-{% block body %}
-
-%% for ps in pixelsizes
+@ include header.t
+/*
+ * VLine generated header
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
+
+@ for ps in pixelsizes:
void GP_VLine_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord x,
GP_Coord y0, GP_Coord y1, GP_Pixel pixel);
-%% endfor
-
-{% endblock body %}
diff --git a/include/gfx/Makefile b/include/gfx/Makefile
index 894b8985..9f6929c7 100644
--- a/include/gfx/Makefile
+++ b/include/gfx/Makefile
@@ -4,5 +4,5 @@ include $(TOPDIR)/pre.mk
GENHEADERS=GP_VLine.gen.h GP_HLine.gen.h
-include $(TOPDIR)/gen.mk
+include $(TOPDIR)/genn.mk
include $(TOPDIR)/post.mk
diff --git a/libs/core/GP_Blit.gen.c.t b/libs/core/GP_Blit.gen.c.t
index b702e88c..c7f17388 100644
--- a/libs/core/GP_Blit.gen.c.t
+++ b/libs/core/GP_Blit.gen.c.t
@@ -1,31 +1,11 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * Copyright (C) 2011-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.c.t"
-
-{% block descr %}Specialized blit functions and macros.{% endblock %}
+@ include source.t
+/*
+ * Specialized blit functions and macros.
+ *
+ * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz>
+ * Copyright (C) 2011-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
-%% block body
#include <string.h>
#include "core/GP_Pixel.h"
@@ -60,7 +40,7 @@ static void blitXYXY_Naive_Raw(const GP_Context *src,
}
}
-%% for ps in pixelsizes
+@ for ps in pixelsizes:
/*
* Blit for equal pixel types {{ ps.suffix }}
*/
@@ -68,7 +48,7 @@ static void blitXYXY_Raw_{{ ps.suffix }}(const GP_Context *src,
GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1,
GP_Context *dst, GP_Coord x2, GP_Coord y2)
{
-%% if not ps.needs_bit_endian()
+@ if not ps.needs_bit_endian():
/* memcpy() each horizontal line */
GP_Coord y;
@@ -76,8 +56,9 @@ static void blitXYXY_Raw_{{ ps.suffix }}(const GP_Context *src,
memcpy(GP_PIXEL_ADDR_{{ ps.suffix }}(dst, x2, y2 + y),
GP_PIXEL_ADDR_{{ ps.suffix }}(src, x0, y0 + y),
{{ int(ps.size/8) }} * (x1 - x0 + 1));
-%% else
-{# /* Rectangles may not be bit-aligned in the same way! */
+@ else:
+# if 0
+ /* Rectangles may not be bit-aligned in the same way! */
/* Alignment (index) of first bits in the first byte */
//TODO: This is wrong for subcontexts where the offset
// needs to be summed with context->offset and moduled
@@ -109,22 +90,21 @@ static void blitXYXY_Raw_{{ ps.suffix }}(const GP_Context *src,
end_p2 += dst->bytes_per_row;
}
} else /* Different bit-alignment, can't use memcpy() */
-#}
+#endif
blitXYXY_Naive_Raw(src, x0, y0, x1, y1, dst, x2, y2);
-%% endif
+@ end
}
-%% endfor
-
+@ end
/*
* Generate Blits, I know this is n^2 variants but the gain is in speed is
* more than 50% and the size footprint for two for cycles is really small.
*/
-%% for src in pixeltypes
-%% if not src.is_unknown() and not src.is_palette()
-%% for dst in pixeltypes
-%% if not dst.is_unknown() and not dst.is_palette()
-%% if dst.name != src.name
+@ for src in pixeltypes:
+@ if not src.is_unknown() and not src.is_palette():
+@ for dst in pixeltypes:
+@ if not dst.is_unknown() and not dst.is_palette():
+@ if dst.name != src.name:
/*
* Blits {{ src.name }} to {{ dst.name }}
*/
@@ -142,23 +122,19 @@ static void blitXYXY_Raw_{{ src.name }}_{{ dst.name }}(const GP_Context *src,
GP_Pixel p1, p2 = 0, p3 = 0;
p1 = GP_GetPixel_Raw_{{ src.pixelsize.suffix }}(src, x, y);
-%% if src.is_alpha()
+@ if src.is_alpha():
p2 = GP_GetPixel_Raw_{{ dst.pixelsize.suffix }}(dst, dx, dy);
p3 = GP_MixPixels_{{ src.name }}_{{ dst.name }}(p1, p2);
-%% else
+@ else:
GP_Pixel_{{ src.name }}_TO_RGB888(p1, p2);
GP_Pixel_RGB888_TO_{{ dst.name }}(p2, p3);
-%% endif
+@ end
GP_PutPixel_Raw_{{ dst.pixelsize.suffix }}(dst, dx, dy, p3);
}
}
}
-%% endif
-%% endif
-%% endfor
-%% endif
-%% endfor
+@ end
void GP_BlitXYXY_Raw_Fast(const GP_Context *src,
GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1,
@@ -173,26 +149,23 @@ void GP_BlitXYXY_Raw_Fast(const GP_Context *src,
/* Specialized functions */
switch (src->pixel_type) {
-%% for src in pixeltypes
-%% if not src.is_unknown() and not src.is_palette()
+@ for src in pixeltypes:
+@ if not src.is_unknown() and not src.is_palette():
case GP_PIXEL_{{ src.name }}:
switch (dst->pixel_type) {
-%% for dst in pixeltypes
-%% if not dst.is_unknown() and not dst.is_palette()
-%% if dst.name != src.name
+@ for dst in pixeltypes:
+@ if not dst.is_unknown() and not dst.is_palette():
+@ if dst.name != src.name:
case GP_PIXEL_{{ dst.name }}:
blitXYXY_Raw_{{ src.name }}_{{ dst.name }}(src, x0, y0, x1, y1, dst, x2, y2);
break;
-%% endif
-%% endif
-%% endfor
+@ end
default:
GP_ABORT("Invalid destination pixel %s",
GP_PixelTypeName(dst->pixel_type));
}
break;
-%% endif
-%% endfor
+@ end
default:
GP_ABORT("Invalid source pixel %s",
GP_PixelTypeName(src->pixel_type));
@@ -202,11 +175,11 @@ void GP_BlitXYXY_Raw_Fast(const GP_Context *src,
/*
* And the same for non-raw variants.
*/
-%% for src in pixeltypes
-%% if not src.is_unknown() and not src.is_palette()
-%% for dst in pixeltypes
-%% if not dst.is_unknown() and not dst.is_palette()
-%% if dst.name != src.name
+@ for src in pixeltypes:
+@ if not src.is_unknown() and not src.is_palette():
+@ for dst in pixeltypes:
+@ if not dst.is_unknown() and not dst.is_palette():
+@ if dst.name != src.name:
/*
* Blits {{ src.name }} to {{ dst.name }}
*/
@@ -231,16 +204,12 @@ static void blitXYXY_{{ src.name }}_{{ dst.name }}(const GP_Context *src,
}
}
-%% endif
-%% endif
-%% endfor
-%% endif
-%% endfor
+@ end
/*
* Same pixel type but with rotation.
*/
-%% for ps in pixelsizes
+@ for ps in pixelsizes:
/*
* Blits for same pixel type and bpp {{ ps.suffix }}
*/
@@ -262,7 +231,7 @@ static void blitXYXY_{{ ps.suffix }}(const GP_Context *src,
GP_PutPixel_Raw_{{ ps.suffix }}(dst, xt, yt, p);
}
}
-%% endfor
+@ end
void GP_BlitXYXY_Fast(const GP_Context *src,
GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1,
@@ -286,30 +255,25 @@ void GP_BlitXYXY_Fast(const GP_Context *src,
/* Specialized functions */
switch (src->pixel_type) {
-%% for src in pixeltypes
-%% if not src.is_unknown() and not src.is_palette()
+@ for src in pixeltypes:
+@ if not src.is_unknown() and not src.is_palette():
case GP_PIXEL_{{ src.name }}:
switch (dst->pixel_type) {
-%% for dst in pixeltypes
-%% if not dst.is_unknown() and not dst.is_palette()
-%% if dst.name != src.name
+@ for dst in pixeltypes:
+@ if not dst.is_unknown() and not dst.is_palette():
+@ if dst.name != src.name:
case GP_PIXEL_{{ dst.name }}:
blitXYXY_{{ src.name }}_{{ dst.name }}(src, x0, y0, x1, y1, dst, x2, y2);
break;
-%% endif
-%% endif
-%% endfor
+@ end
default:
GP_ABORT("Invalid destination pixel %s",
GP_PixelTypeName(dst->pixel_type));
}
break;
-%% endif
-%% endfor
+@ end
default:
GP_ABORT("Invalid source pixel %s",
GP_PixelTypeName(src->pixel_type));
}
}
-
-%% endblock body
diff --git a/libs/core/GP_Convert.gen.c.t b/libs/core/GP_Convert.gen.c.t
index ef004e44..674e04dc 100644
--- a/libs/core/GP_Convert.gen.c.t
+++ b/libs/core/GP_Convert.gen.c.t
@@ -1,90 +1,61 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * Copyright (C) 2011 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.c.t"
-
-{% block descr %}Convert PixelType values macros and functions{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * Convert PixelType values macros and functions
+ *
+ * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz>
+ * Copyright (C) 2011-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include "GP_Convert.h"
-
-{#
- # Loop around pixel types central for the conversion.
--#}
-%% for pt in [pixeltypes_dict['RGB888'], pixeltypes_dict['RGBA8888']]
+@
+@ # Loop around pixel types central for the conversion.
+@ for pt in [pixeltypes_dict['RGB888'], pixeltypes_dict['RGBA8888']]:
GP_Pixel GP_{{ pt.name }}ToPixel(GP_Pixel pixel, GP_PixelType type)
{
GP_Pixel p = 0;
switch (type) {
-%% for tf in pixeltypes
-%% if tf.is_unknown()
+@ for tf in pixeltypes:
+@ if tf.is_unknown():
case GP_PIXEL_UNKNOWN:
GP_ABORT("Cannot convert {{ pt.name }} to GP_PIXEL_UNKNOWN");
break;
-%% elif tf.is_palette()
+@ elif tf.is_palette():
case GP_PIXEL_{{ tf.name }}:
GP_ABORT("Cannot convert {{ pt.name }} to palette type {{ tf.name }}");
break;
-%% else
+@ else:
case GP_PIXEL_{{ tf.name }}:
GP_Pixel_{{ pt.name }}_TO_{{ tf.name }}(pixel, p);
break;
-%% endif
-%% endfor
+@ end
default:
GP_ABORT("Unknown PixelType %ud", type);
}
return p;
}
-
GP_Pixel GP_PixelTo{{ pt.name }}(GP_Pixel pixel, GP_PixelType type)
{
GP_Pixel p = 0;
switch (type) {
-%% for sf in pixeltypes
-%% if sf.is_unknown()
+@ for sf in pixeltypes:
+@ if sf.is_unknown():
case GP_PIXEL_UNKNOWN:
GP_ABORT("Cannot convert from GP_PIXEL_UNKNOWN");
break;
-%% elif sf.is_palette()
+@ elif sf.is_palette():
case GP_PIXEL_{{ sf.name }}:
GP_ABORT("Cannot convert from palette type {{ sf.name }} (yet)");
break;
-%% else
+@ else:
case GP_PIXEL_{{ sf.name }}:
GP_Pixel_{{ sf.name }}_TO_{{ pt.name }}(pixel, p);
break;
-%% endif
-%% endfor
+@ end
default:
GP_ABORT("Unknown PixelType %u", type);
}
return p;
}
-%% endfor
-
-%% endblock body
diff --git a/libs/core/GP_Fill.gen.c.t b/libs/core/GP_Fill.gen.c.t
index f2c4b8d0..49f8edec 100644
--- a/libs/core/GP_Fill.gen.c.t
+++ b/libs/core/GP_Fill.gen.c.t
@@ -1,32 +1,10 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends 'base.c.t'
-
-{% block descr %}
-Optimized fill functions.
-{% endblock descr %}
-
-%% block body
+@ include source.t
+@ include WritePixels.t
+/*
+ * Optimized fill functions.
+ *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include "core/GP_Context.h"
#include "core/GP_WritePixel.h"
@@ -34,34 +12,30 @@ Optimized fill functions.
#include "core/GP_FnPerBpp.h"
#include "core/GP_Fill.h"
-%% from './WritePixels.t' import optimized_writepixels
-
-%% for ps in pixelsizes
+@ for ps in pixelsizes:
static void fill_{{ ps.suffix }}(GP_Context *ctx, GP_Pixel val)
{
unsigned int y;
for (y = 0; y < ctx->h; y++) {
-%% if ps.suffix in optimized_writepixels
+@ if ps.suffix in optimized_writepixels:
void *start = GP_PIXEL_ADDR(ctx, 0, y);
-%% if ps.needs_bit_endian()
+@ if ps.needs_bit_endian():
GP_WritePixels_{{ ps.suffix }}(start, 0, ctx->w, val);
-%% else
+@ else:
GP_WritePixels_{{ ps.suffix }}(start, ctx->w, val);
-%% endif
-%% else
+@ else:
unsigned int x;
for (x = 0; x < ctx->w; x++)
GP_PutPixel_Raw_{{ ps.suffix }}(ctx, x, y, val);
-%% endif
+@ end
}
}
-%% endfor
+@ end
void GP_Fill(GP_Context *ctx, GP_Pixel val)
{
GP_FN_PER_BPP_CONTEXT(fill, ctx, ctx, val);
}
-%% endblock body
diff --git a/libs/core/GP_GammaCorrection.gen.c.t b/libs/core/GP_GammaCorrection.gen.c.t
index 72883b28..18713dc6 100644
--- a/libs/core/GP_GammaCorrection.gen.c.t
+++ b/libs/core/GP_GammaCorrection.gen.c.t
@@ -1,35 +1,8 @@
-/*****************************************************************************
- * 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) 2012 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.c.t"
-
-{% block descr %}Gamma correction tables for Gamma = 2.2{% endblock %}
-
-%% block body
-
+@ include source.t
/*
- * Gamma correction tables.
+ * Gamma correction tables for Gamma = 2.2
*
- * Copyright (c) 2012 Cyril Hrubis <metan(a)ucw.cz>
+ * Copyright (C) 2012-2014 Cyril Hrubis <metan(a)ucw.cz>
*/
#include <stdint.h>
@@ -38,24 +11,22 @@
* Converts 8 bit gamma to 10 bit linear.
*/
static uint16_t gamma8_linear10[] = {
-%% for i in range(0, 256)
+@ for i in range(0, 256):
{{ int(((float(i)/255) ** 2.2) * 1024 + 0.5) }}, /* {{i}} */
-%% endfor
+@ end
};
/*
* Converts 10 bit linear to 8 bit gamma.
*/
static uint8_t linear10_gamma8[] = {
-%% for i in range(0, 1025)
+@ for i in range(0, 1025):
{{ int(((float(i)/1024) ** (1/2.2)) * 255 + 0.5) }}, /* {{i}} */
-%% endfor
+@ end
};
/*
* Pointers to tables
*/
uint16_t *GP_Gamma8_Linear10 = gamma8_linear10;
-uint8_t *GP_Linear10_Gamma8 = linear10_gamma8;
-
-%% endblock body
+uint8_t *GP_Linear10_Gamma8 = linear10_gamma8;
diff --git a/libs/core/GP_Pixel.gen.c.t b/libs/core/GP_Pixel.gen.c.t
index 302655f4..8a13a568 100644
--- a/libs/core/GP_Pixel.gen.c.t
+++ b/libs/core/GP_Pixel.gen.c.t
@@ -1,79 +1,68 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2011-2012 Tomas Gavenciak <gavento(a)ucw.cz> *
- * Copyright (C) 2011-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.c.t"
-
-%% block descr
-Pixel type definitions and functions
-%% endblock
+@ include source.t
+/*
+ * Pixel type definitions and functions
+ *
+ * Copyright (C) 2011-2012 Tomas Gavenciak <gavento(a)ucw.cz>
+ * Copyright (C) 2011-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
-%% block body
#include <stdio.h>
#include "GP_Pixel.h"
#include "GP_GetSetBits.h"
-
-%%- macro getflags(pt)
-{% if pt.is_alpha() %} | GP_PIXEL_HAS_ALPHA{% endif -%}
-{% if pt.is_rgb() %} | GP_PIXEL_IS_RGB{% endif -%}
-{% if pt.is_palette() %} | GP_PIXEL_IS_PALETTE{% endif -%}
-{% if pt.is_gray() %} | GP_PIXEL_IS_GRAYSCALE{% endif -%}
-{% if pt.is_cmyk() %} | GP_PIXEL_IS_CMYK{% endif -%}
-%%- endmacro
+@
+@ def getflags(pt):
+@ flags = []
+@ if pt.is_alpha():
+@ flags.append('GP_PIXEL_HAS_ALPHA')
+@ if pt.is_rgb():
+@ flags.append('GP_PIXEL_IS_RGB')
+@ if pt.is_palette():
+@ flags.append('GP_PIXEL_IS_PALETTE')
+@ if pt.is_gray():
+@ flags.append('GP_PIXEL_IS_GRAYSCALE')
+@ if pt.is_cmyk():
+@ flags.append('GP_PIXEL_IS_CMYK')
+@ if flags:
+@ return ' | '.join(flags)
+@ else:
+@ return 0
+@ end
/*
* Description of all known pixel types
*/
const GP_PixelTypeDescription GP_PixelTypes [GP_PIXEL_MAX] = {
-%% for pt in pixeltypes
+@ for pt in pixeltypes:
/* GP_PIXEL_{{ pt.name }} */ {
.type = GP_PIXEL_{{ pt.name }},
.name = "{{ pt.name }}",
.size = {{ pt.pixelsize.size }},
.bit_endian = {{ pt.pixelsize.bit_endian_const }},
.numchannels = {{ len(pt.chanslist) }},
- .bitmap = "{{ pt.bits|join("") }}",
- .flags = 0{{ getflags(pt) }},
+ .bitmap = "{{ ''.join(pt.bits) }}",
+ .flags = {{ getflags(pt) }},
.channels = {
-%% for c in pt.chanslist
+@ for c in pt.chanslist:
{ .name = "{{ c[0] }}", .offset = {{ c[1] }}, .size = {{ c[2] }} },
-%% endfor
- } },
-%% endfor
+@ end
+ }
+ },
+@ end
};
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
/*
* snprintf a human readable value of pixel type {{pt.name}}
*/
static void GP_PixelSNPrint_{{ pt.name }}(char *buf, size_t len, GP_Pixel p)
{
- snprintf(buf, len, "{{ pt.name }} 0x%0{{ (pt.pixelsize.size+3)//4 }}x{% for c in pt.chanslist %} {{ c[0] }}=%d{% endfor %}",
- GP_GET_BITS(0, {{ pt.pixelsize.size }}, p){% for c in pt.chanslist %}, GP_Pixel_GET_{{ c.name}}_{{ pt.name }}(p){% endfor %});
+ snprintf(buf, len, "{{ pt.name }} 0x%0{{ (pt.pixelsize.size+3)//4 }}x {{ '=%d '.join(pt.chan_names) + '=%d' }}",
+ GP_GET_BITS(0, {{ pt.pixelsize.size }}, p),
+ {{ arr_to_params(pt.chan_names, 'GP_Pixel_GET_', '_' + pt.name + '(p)') }});
}
-%% endif
-%% endfor
+@ end
void GP_PixelSNPrint(char *buf, size_t len, GP_Pixel p, GP_PixelType pixel_type)
{
@@ -86,5 +75,3 @@ void GP_PixelPrint(GP_Pixel p, GP_PixelType pixel_type)
GP_PixelSNPrint(buf, sizeof(buf), p, pixel_type);
puts(buf);
}
-
-%% endblock body
diff --git a/libs/core/Makefile b/libs/core/Makefile
index 37e61703..2e98fee3 100644
--- a/libs/core/Makefile
+++ b/libs/core/Makefile
@@ -7,6 +7,6 @@ GENSOURCES=GP_Pixel.gen.c GP_Blit.gen.c GP_Convert.gen.c CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
LIBNAME=core
-include $(TOPDIR)/gen.mk
+include $(TOPDIR)/genn.mk
include $(TOPDIR)/lib.mk
include $(TOPDIR)/post.mk
diff --git a/libs/core/WritePixels.t b/libs/core/WritePixels.t
index ef8ba94f..06a9895f 100644
--- a/libs/core/WritePixels.t
+++ b/libs/core/WritePixels.t
@@ -1,30 +1,7 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-{# Explicit list of BPP that have optimized write pixel #}
-%% set optimized_writepixels = ['1BPP_LE', '1BPP_BE',
- '2BPP_LE', '2BPP_BE',
- '4BPP_LE', '4BPP_BE',
- '8BPP',
- '16BPP',
- '24BPP',
- '32BPP']
+@ optimized_writepixels = ['1BPP_LE', '1BPP_BE',
+@ '2BPP_LE', '2BPP_BE',
+@ '4BPP_LE', '4BPP_BE',
+@ '8BPP',
+@ '16BPP',
+@ '24BPP',
+@ '32BPP']
diff --git a/libs/filters/GP_ApplyTables.gen.c.t b/libs/filters/GP_ApplyTables.gen.c.t
index f166af3a..dd3581cf 100644
--- a/libs/filters/GP_ApplyTables.gen.c.t
+++ b/libs/filters/GP_ApplyTables.gen.c.t
@@ -1,32 +1,9 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "filter.c.t"
-
-%% block descr
-Generic Point filer
-%% endblock
-
-%% block body
+@ include source.t
+/*
+ * Generic Point filer
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <errno.h>
@@ -36,8 +13,8 @@ Generic Point filer
#include "filters/GP_ApplyTables.h"
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
static int apply_tables_{{ pt.name }}(const GP_Context *const src,
GP_Coord x_src, GP_Coord y_src,
GP_Size w_src, GP_Size h_src,
@@ -50,9 +27,9 @@ static int apply_tables_{{ pt.name }}(const GP_Context *const src,
unsigned int x, y;
-%% for c in pt.chanslist
+@ for c in pt.chanslist:
GP_Pixel {{ c.name }};
-%% endfor
+@ end
for (y = 0; y < h_src; y++) {
for (x = 0; x < w_src; x++) {
@@ -63,12 +40,12 @@ static int apply_tables_{{ pt.name }}(const GP_Context *const src,
GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, src_x, src_y);
-%% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }} = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix);
{{ c.name }} = tables->table[{{ c.idx }}][{{ c.name }}];
-%% endfor
+@ end
- pix = GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "", "") }});
+ pix = GP_Pixel_CREATE_{{ pt.name }}({{ arr_to_params(pt.chan_names) }});
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, dst_x, dst_y, pix);
}
@@ -83,9 +60,8 @@ static int apply_tables_{{ pt.name }}(const GP_Context *const src,
return 0;
}
-%% endif
-%% endfor
-
+@ end
+@
int GP_FilterTablesApply(const GP_Context *const src,
GP_Coord x_src, GP_Coord y_src,
GP_Size w_src, GP_Size h_src,
@@ -98,20 +74,17 @@ int GP_FilterTablesApply(const GP_Context *const src,
//TODO: Assert size
switch (src->pixel_type) {
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
case GP_PIXEL_{{ pt.name }}:
return apply_tables_{{ pt.name }}(src, x_src, y_src,
w_src, h_src, dst,
x_dst, y_dst,
tables, callback);
break;
-%% endif
-%% endfor
+@ end
default:
errno = EINVAL;
return -1;
}
}
-
-%% endblock body
diff --git a/libs/filters/GP_Cubic.gen.c.t b/libs/filters/GP_Cubic.gen.c.t
index e5f5cf43..c9590628 100644
--- a/libs/filters/GP_Cubic.gen.c.t
+++ b/libs/filters/GP_Cubic.gen.c.t
@@ -1,49 +1,19 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.c.t"
-
-{% block descr %}Table for fixed point cubic coeficients for A=0.5{% endblock %}
-
-%% block body
-
+@ include source.t
/*
- * Fixed point cubic coeficients.
+ * Table for fixed point cubic coeficients for A=0.5
*
- * Copyright (c) 2012 Cyril Hrubis <metan(a)ucw.cz>
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
*/
#include <stdint.h>
int16_t GP_CubicTable[2047] = {
-%% set A=0.5
-%% for i in range(0, 1023)
-%% set x = i/1024
- {{ round(((2 - A)*x*x*x + (A - 3)*x*x + 1) * 1024) }}, /* {{ i }} {{ x }} */
-%% endfor
-%% for i in range(1024, 2047)
-%% set x = i/1024
- {{ round((-A*x*x*x + 5*A*x*x - 8*A*x + 4*A) * 1024) }}, /* {{ i }} {{ x }} */
-%% endfor
+@ A=0.5
+@ for i in range(0, 1023):
+@ x = i/1024
+ {{ round(((2 - A)*x*x*x + (A - 3)*x*x + 1) * 1024) }}, /* {{ '%-4i %.6f' % (i, x) }} */
+@ for i in range(1024, 2047):
+@ x = i/1024
+ {{ round((-A*x*x*x + 5*A*x*x - 8*A*x + 4*A) * 1024) }}, /* {{ '%-4i %.6f' % (i, x) }} */
+@ end
};
-
-%% endblock body
diff --git a/libs/filters/GP_FloydSteinberg.gen.c.t b/libs/filters/GP_FloydSteinberg.gen.c.t
index f63c8cce..77492b1e 100644
--- a/libs/filters/GP_FloydSteinberg.gen.c.t
+++ b/libs/filters/GP_FloydSteinberg.gen.c.t
@@ -1,54 +1,33 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "common.c.t"
-
-{% block descr %}Floyd Steinberg dithering RGB888 -> any pixel{% endblock %}
-
-%% block body
-
+@ include source.t
+/*
+ * Floyd Steinberg dithering RGB888 -> any pixel
+ *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <string.h>
#include <errno.h>
#include "core/GP_Core.h"
#include "core/GP_Pixel.h"
+#include "core/GP_Clamp.h"
#include "filters/GP_Filter.h"
#include "filters/GP_Dither.h"
-%% macro distribute_error(errors, x, y, w, err)
- if ({{ x }} + 1 < {{ w }})
- {{ errors }}[{{ y }}%2][{{ x }}+1] += 7 * {{ err }} / 16;
+@ def distribute_error(errors, x, y, w, err):
+if ({{ x }} + 1 < {{ w }})
+ {{ errors }}[{{ y }}%2][{{ x }}+1] += 7 * {{ err }} / 16;
- if ({{ x }} > 1)
- {{ errors }}[!({{ y }}%2)][{{ x }}-1] += 3 * {{ err }} / 16;
+if ({{ x }} > 1)
+ {{ errors }}[!({{ y }}%2)][{{ x }}-1] += 3 * {{ err }} / 16;
- {{ errors }}[!({{ y }}%2)][{{ x }}] += 5 * {{ err }} / 16;
+{{ errors }}[!({{ y }}%2)][{{ x }}] += 5 * {{ err }} / 16;
- if ({{ x }} + 1 < {{ w }})
- {{ errors }}[!({{ y }}%2)][{{ x }}+1] += {{ err }} / 16;
-%% endmacro
-
-%% for pt in pixeltypes
-%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha()
+if ({{ x }} + 1 < {{ w }})
+ {{ errors }}[!({{ y }}%2)][{{ x }}+1] += {{ err }} / 16;
+@ end
+@
+@ for pt in pixeltypes:
+@ if pt.is_gray() or pt.is_rgb() and not pt.is_alpha():
/*
* Floyd Steinberg to {{ pt.name }}
*/
@@ -56,9 +35,9 @@ static int floyd_steinberg_to_{{ pt.name }}_Raw(const GP_Context *src,
GP_Context *dst,
GP_ProgressCallback *callback)
{
-%% for c in pt.chanslist
- float errors_{{ c[0] }}[2][src->w];
-%% endfor
+@ for c in pt.chanslist:
+ float errors_{{ c.name }}[2][src->w];
+@ end
GP_DEBUG(1, "Floyd Steinberg %s to %s %ux%u",
GP_PixelTypeName(src->pixel_type),
@@ -67,10 +46,10 @@ static int floyd_steinberg_to_{{ pt.name }}_Raw(const GP_Context *src,
GP_Coord x, y;
-%% for c in pt.chanslist
- memset(errors_{{ c[0] }}[0], 0, src->w * sizeof(float));
- memset(errors_{{ c[0] }}[1], 0, src->w * sizeof(float));
-%% endfor
+@ for c in pt.chanslist:
+ memset(errors_{{ c.name }}[0], 0, src->w * sizeof(float));
+ memset(errors_{{ c.name }}[1], 0, src->w * sizeof(float));
+@ end
for (y = 0; y < (GP_Coord)src->h; y++) {
for (x = 0; x < (GP_Coord)src->w; x++) {
@@ -79,42 +58,42 @@ static int floyd_steinberg_to_{{ pt.name }}_Raw(const GP_Context *src,
pix = GP_GetPixel_Raw(src, x, y);
pix = GP_PixelToRGB888(pix, src->pixel_type);
-%% for c in pt.chanslist
-%% if pt.is_gray()
- float val_{{ c[0] }} = GP_Pixel_GET_R_RGB888(pix) +
+@ for c in pt.chanslist:
+@ if pt.is_gray():
+ float val_{{ c.name }} = GP_Pixel_GET_R_RGB888(pix) +
GP_Pixel_GET_G_RGB888(pix) +
GP_Pixel_GET_B_RGB888(pix);
-%% else
- float val_{{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_RGB888(pix);
-%% endif
- val_{{ c[0] }} += errors_{{ c[0] }}[y%2][x];
-
- float err_{{ c[0] }} = val_{{ c[0] }};
-%% if pt.is_gray()
- GP_Pixel res_{{ c[0] }} = {{ 2 ** c[2] - 1}} * val_{{ c[0] }} / (3 * 255);
- err_{{ c[0] }} -= res_{{ c[0] }} * (3 * 255) / {{ 2 ** c[2] - 1}};
-%% else
- GP_Pixel res_{{ c[0] }} = {{ 2 ** c[2] - 1}} * val_{{ c[0] }} / 255;
- err_{{ c[0] }} -= res_{{ c[0] }} * 255 / {{ 2 ** c[2] - 1}};
-%% endif
-
-{{ distribute_error("errors_%s"|format(c[0]), 'x', 'y', '(GP_Coord)src->w', 'err_%s'|format(c[0])) }}
-
- {{ clamp_val("res_%s"|format(c[0]), c[2]) }}
-%% endfor
-
-%% if pt.is_gray()
+@ else:
+ float val_{{ c.name }} = GP_Pixel_GET_{{ c.name }}_RGB888(pix);
+@ end
+ val_{{ c.name }} += errors_{{ c.name }}[y%2][x];
+
+ float err_{{ c.name }} = val_{{ c.name }};
+@ if pt.is_gray():
+ GP_Pixel res_{{ c.name }} = {{ 2 ** c[2] - 1}} * val_{{ c.name }} / (3 * 255);
+ err_{{ c.name }} -= res_{{ c.name }} * (3 * 255) / {{ 2 ** c[2] - 1}};
+@ else:
+ GP_Pixel res_{{ c.name }} = {{ 2 ** c[2] - 1}} * val_{{ c.name }} / 255;
+ err_{{ c.name }} -= res_{{ c.name }} * 255 / {{ 2 ** c[2] - 1}};
+@ end
+
+ {@ distribute_error('errors_' + c.name, 'x', 'y', '(GP_Coord)src->w', 'err_' + c.name) @}
+
+ GP_CLAMP_DOWN({{ 'res_' + c.name }}, {{ c.max }});
+@ end
+
+@ if pt.is_gray():
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, res_V);
-%% else
- GP_Pixel res = GP_Pixel_CREATE_{{ pt.name }}(res_{{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, res_{{ c[0] }}{% endfor %});
+@ else:
+ GP_Pixel res = GP_Pixel_CREATE_{{ pt.name }}({{ arr_to_params(pt.chan_names, 'res_') }});
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, res);
-%% endif
+@ end
}
-%% for c in pt.chanslist
- memset(errors_{{ c[0] }}[y%2], 0, src->w * sizeof(float));
-%% endfor
+@ for c in pt.chanslist:
+ memset(errors_{{ c.name }}[y%2], 0, src->w * sizeof(float));
+@ end
if (GP_ProgressCallbackReport(callback, y, src->h, src->w))
return 1;
@@ -124,9 +103,8 @@ static int floyd_steinberg_to_{{ pt.name }}_Raw(const GP_Context *src,
return 0;
}
-%% endif
-%% endfor
-
+@ end
+@
static int floyd_steinberg(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
@@ -138,12 +116,11 @@ static int floyd_steinberg(const GP_Context *src, GP_Context *dst,
}
switch (dst->pixel_type) {
-%% for pt in pixeltypes
-%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha()
+@ for pt in pixeltypes:
+@ if pt.is_gray() or pt.is_rgb() and not pt.is_alpha():
case GP_PIXEL_{{ pt.name }}:
return floyd_steinberg_to_{{ pt.name }}_Raw(src, dst, callback);
-%% endif
-%% endfor
+@ end
default:
errno = EINVAL;
return 1;
@@ -178,5 +155,3 @@ GP_Context *GP_FilterFloydSteinbergAlloc(const GP_Context *src,
return ret;
}
-
-%% endblock body
diff --git a/libs/filters/GP_GaussianNoise.gen.c.t b/libs/filters/GP_GaussianNoise.gen.c.t
index 939533b4..a8c6ad85 100644
--- a/libs/filters/GP_GaussianNoise.gen.c.t
+++ b/libs/filters/GP_GaussianNoise.gen.c.t
@@ -1,30 +1,9 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "filter.c.t"
-
-{% block descr %}Gaussian Noise{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * Gaussian Noise
+ *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <errno.h>
@@ -38,8 +17,8 @@
#include "GP_Rand.h"
#include "GP_GaussianNoise.h"
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
GP_Size w_src, GP_Size h_src,
@@ -51,37 +30,37 @@ static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Context *src,
GP_DEBUG(1, "Additive Gaussian noise filter %ux%u sigma=%f mu=%f",
w_src, h_src, sigma, mu);
- %% for c in pt.chanslist
- int sigma_{{ c[0] }} = {{ 2 ** c[2] - 1 }} * sigma;
- int mu_{{ c[0] }} = {{ 2 ** c[2] - 1 }} * mu;
- %% endfor
+@ for c in pt.chanslist:
+ int sigma_{{ c.name }} = {{ c.max }} * sigma;
+ int mu_{{ c.name }} = {{ c.max }} * mu;
+@ end
unsigned int size = w_src + w_src%2;
/* Create temporary buffers */
GP_TempAllocCreate(temp, sizeof(int) * size * {{ len(pt.chanslist) }});
- %% for c in pt.chanslist
- int *{{ c[0] }} = GP_TempAllocGet(temp, size * sizeof(int));
- %% endfor
+@ for c in pt.chanslist:
+ int *{{ c.name }} = GP_TempAllocGet(temp, size * sizeof(int));
+@ end
/* Apply the additive noise filter */
unsigned int x, y;
for (y = 0; y < h_src; y++) {
- %% for c in pt.chanslist
- GP_NormInt({{ c[0] }}, size, sigma_{{ c[0] }}, mu_{{ c[0] }});
- %% endfor
+@ for c in pt.chanslist:
+ GP_NormInt({{ c.name }}, size, sigma_{{ c.name }}, mu_{{ c.name }});
+@ end
for (x = 0; x < w_src; x++) {
GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x + x_src, y + y_src);
- %% for c in pt.chanslist
- {{ c[0] }}[x] += GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix);
- {{ c[0] }}[x] = GP_CLAMP({{ c[0] }}[x], 0, {{ 2 ** c[2] - 1 }});
- %% endfor
+@ for c in pt.chanslist:
+ {{ c.name }}[x] += GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix);
+ {{ c.name }}[x] = GP_CLAMP({{ c.name }}[x], 0, {{ c.max }});
+@ end
- pix = GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "", "[x]") }});
+ pix = GP_Pixel_CREATE_{{ pt.name }}({{ arr_to_params(pt.chan_names, '', '[x]') }});
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x + x_dst, y + y_dst, pix);
}
@@ -98,9 +77,8 @@ static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Context *src,
return 0;
}
-%% endif
-%% endfor
-
+@ end
+@
int GP_FilterGaussianNoiseAdd_Raw(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
GP_Size w_src, GP_Size h_src,
@@ -110,15 +88,14 @@ int GP_FilterGaussianNoiseAdd_Raw(const GP_Context *src,
GP_ProgressCallback *callback)
{
switch (src->pixel_type) {
- %% for pt in pixeltypes
- %% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
case GP_PIXEL_{{ pt.name }}:
return GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(src, x_src,
y_src, w_src, h_src, dst, x_dst, y_dst,
sigma, mu, callback);
break;
- %% endif
- %% endfor
+@ end
default:
errno = EINVAL;
return -1;
@@ -173,5 +150,3 @@ GP_Context *GP_FilterGaussianNoiseAddExAlloc(const GP_Context *src,
return dst;
}
-
-%% endblock body
diff --git a/libs/filters/GP_HilbertPeano.gen.c.t b/libs/filters/GP_HilbertPeano.gen.c.t
index 1c11973c..e1a07f7b 100644
--- a/libs/filters/GP_HilbertPeano.gen.c.t
+++ b/libs/filters/GP_HilbertPeano.gen.c.t
@@ -1,30 +1,9 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.c.t"
-
-{% block descr %}Hilbert Peano dithering RGB888 -> any pixel{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * Hilbert Peano dithering RGB888 -> any pixel
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <errno.h>
@@ -51,8 +30,8 @@ static unsigned int count_bits(unsigned int n)
return (i + (s != (1U<<i)));
}
-%% for pt in pixeltypes
-%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha()
+@ for pt in pixeltypes:
+@ if pt.is_gray() or pt.is_rgb() and not pt.is_alpha():
/*
* Hilbert Peano to {{ pt.name }}
*/
@@ -73,9 +52,9 @@ static int hilbert_peano_to_{{ pt.name }}_Raw(const GP_Context *src,
unsigned int cnt = 0;
/* error counters */
-%% for c in pt.chanslist
+@ for c in pt.chanslist:
int err_{{ c[0] }} = 0;
-%% endfor
+@ end
while (GP_HilbertCurveContinues(&state)) {
if (state.x < src->w && state.y < src->h) {
@@ -84,33 +63,31 @@ static int hilbert_peano_to_{{ pt.name }}_Raw(const GP_Context *src,
pix = GP_GetPixel_Raw(src, state.x, state.y);
pix = GP_PixelToRGB888(pix, src->pixel_type);
-%% for c in pt.chanslist
-%% if pt.is_gray()
+@ for c in pt.chanslist:
+@ if pt.is_gray():
int pix_{{ c[0] }} = GP_Pixel_GET_R_RGB888(pix) +
GP_Pixel_GET_G_RGB888(pix) +
GP_Pixel_GET_B_RGB888(pix);
-%% else
+@ else:
int pix_{{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_RGB888(pix);
-%% endif
-
+@ end
pix_{{ c[0] }} += err_{{ c[0] }};
-%% if pt.is_gray()
+@ if pt.is_gray():
int res_{{ c[0] }} = ({{ 2 ** c[2] - 1}} * pix_{{ c[0] }} + 382) / {{ 3 * 255 }};
err_{{ c[0] }} = pix_{{ c[0] }} - {{ 3 * 255 }} * res_{{ c[0] }} / {{ 2 ** c[2] - 1 }};
-%% else
+@ else:
int res_{{ c[0] }} = ({{ 2 ** c[2] - 1}} * pix_{{ c[0] }} + 127) / 255;
err_{{ c[0] }} = pix_{{ c[0] }} - 255 * res_{{ c[0] }} / {{ 2 ** c[2] - 1 }};
-%% endif
-%% endfor
+@ end
-%% if pt.is_gray()
+@ if pt.is_gray():
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, state.x, state.y, res_V);
-%% else
- GP_Pixel res = GP_Pixel_CREATE_{{ pt.name }}(res_{{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, res_{{ c[0] }}{% endfor %});
+@ else:
+ GP_Pixel res = GP_Pixel_CREATE_{{ pt.name }}({{ arr_to_params(pt.chan_names, 'res_') }});
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, state.x, state.y, res);
-%% endif
+@ end
cnt++;
if (GP_ProgressCallbackReport(callback, cnt/src->h, src->w, src->h))
@@ -122,9 +99,9 @@ static int hilbert_peano_to_{{ pt.name }}_Raw(const GP_Context *src,
return 0;
}
} else {
-%% for c in pt.chanslist
+@ for c in pt.chanslist:
err_{{ c[0] }} = 0;
-%% endfor
+@ end
}
GP_HilbertCurveNext(&state);
@@ -134,9 +111,8 @@ static int hilbert_peano_to_{{ pt.name }}_Raw(const GP_Context *src,
return 0;
}
-%% endif
-%% endfor
-
+@ end
+@
static int hilbert_peano(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
@@ -148,12 +124,11 @@ static int hilbert_peano(const GP_Context *src, GP_Context *dst,
}
switch (dst->pixel_type) {
-%% for pt in pixeltypes
-%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha()
+@ for pt in pixeltypes:
+@ if pt.is_gray() or pt.is_rgb() and not pt.is_alpha():
case GP_PIXEL_{{ pt.name }}:
return hilbert_peano_to_{{ pt.name }}_Raw(src, dst, callback);
-%% endif
-%% endfor
+@ end
default:
errno = EINVAL;
return 1;
@@ -187,5 +162,3 @@ GP_Context *GP_FilterHilbertPeanoAlloc(const GP_Context *src,
return ret;
}
-
-%% endblock body
diff --git a/libs/filters/GP_LinearConvolution.gen.c.t b/libs/filters/GP_LinearConvolution.gen.c.t
index 70fe090f..4c320e18 100644
--- a/libs/filters/GP_LinearConvolution.gen.c.t
+++ b/libs/filters/GP_LinearConvolution.gen.c.t
@@ -1,30 +1,9 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "filter.c.t"
-
-{% block descr %}Linear Convolution{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * Linear Convolution
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <errno.h>
@@ -38,8 +17,8 @@
#define MUL 1024
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
static int h_lin_conv_{{ pt.name }}(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
@@ -62,9 +41,9 @@ static int h_lin_conv_{{ pt.name }}(const GP_Context *src,
/* Create temporary buffers */
GP_TempAllocCreate(temp, {{ len(pt.chanslist) }} * size * sizeof(int));
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
int *{{ c.name }} = GP_TempAllocGet(temp, size * sizeof(int));
- %% endfor
+@ end
/* Do horizontal linear convolution */
for (y = 0; y < (GP_Coord)h_src; y++) {
@@ -78,9 +57,9 @@ static int h_lin_conv_{{ pt.name }}(const GP_Context *src,
/* Copy border pixel until the source image starts */
while (xi <= 0 && i < size) {
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}[i] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix);
- %% endfor
+@ end
i++;
xi++;
}
@@ -89,9 +68,9 @@ static int h_lin_conv_{{ pt.name }}(const GP_Context *src,
while (xi < (int)src->w && i < size) {
pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, xi, yi);
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}[i] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix);
- %% endfor
+@ end
i++;
xi++;
@@ -99,39 +78,38 @@ static int h_lin_conv_{{ pt.name }}(const GP_Context *src,
/* Copy the rest the border pixel when we are out again */
while (i < size) {
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}[i] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix);
- %% endfor
+@ end
i++;
}
for (x = 0; x < (GP_Coord)w_src; x++) {
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
int32_t {{ c.name }}_sum = MUL/2;
int *p{{ c.name }} = {{ c.name }} + x;
- %% endfor
+@ end
/* count the pixel value from neighbours weighted by kernel */
for (i = 0; i < kw; i++) {
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}_sum += (*p{{ c.name }}++) * ikernel[i];
- %% endfor
+@ end
}
/* divide the result */
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}_sum /= ikern_div;
- %% endfor
+@ end
/* and clamp just to be extra sure */
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}_sum = GP_CLAMP({{ c.name }}_sum, 0, {{ c.max }});
- %% endfor
-
+@ end
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x_dst + x, y_dst + y,
GP_Pixel_CREATE_{{ pt.name }}(
- {{ expand_chanslist(pt, "", "_sum") }}
+ {{ arr_to_params(pt.chan_names, "", "_sum") }}
));
}
@@ -147,9 +125,7 @@ static int h_lin_conv_{{ pt.name }}(const GP_Context *src,
return 0;
}
-%% endif
-%% endfor
-
+@ end
int GP_FilterHLinearConvolution_Raw(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
@@ -164,23 +140,22 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src,
kw, x_src, y_src, w_src, h_src);
switch (src->pixel_type) {
- %% for pt in pixeltypes
- %% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
case GP_PIXEL_{{ pt.name }}:
return h_lin_conv_{{ pt.name }}(src, x_src, y_src, w_src, h_src,
dst, x_dst, y_dst,
kernel, kw, kern_div, callback);
break;
- %% endif
- %% endfor
+@ end
default:
errno = EINVAL;
return -1;
}
}
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
static int v_lin_conv_{{ pt.name }}(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
@@ -203,9 +178,9 @@ static int v_lin_conv_{{ pt.name }}(const GP_Context *src,
/* Create temporary buffers */
GP_TempAllocCreate(temp, {{ len(pt.chanslist) }} * size * sizeof(int));
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
int *{{ c.name }} = GP_TempAllocGet(temp, size * sizeof(int));
- %% endfor
+@ end
/* Do vertical linear convolution */
for (x = 0; x < (GP_Coord)w_src; x++) {
@@ -219,9 +194,9 @@ static int v_lin_conv_{{ pt.name }}(const GP_Context *src,
/* Copy border pixel until the source image starts */
while (yi <= 0 && i < size) {
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}[i] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix);
- %% endfor
+@ end
i++;
yi++;
@@ -231,9 +206,9 @@ static int v_lin_conv_{{ pt.name }}(const GP_Context *src,
while (yi < (int)src->h && i < size) {
pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, xi, yi);
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}[i] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix);
- %% endfor
+@ end
i++;
yi++;
@@ -241,39 +216,39 @@ static int v_lin_conv_{{ pt.name }}(const GP_Context *src,
/* Copy the rest the border pixel when we are out again */
while (i < size) {
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}[i] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix);
- %% endfor
+@ end
i++;
}
for (y = 0; y < (GP_Coord)h_src; y++) {
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
int32_t {{ c.name }}_sum = MUL/2;
int *p{{ c.name }} = {{ c.name }} + y;
- %% endfor
+@ end
/* count the pixel value from neighbours weighted by kernel */
for (i = 0; i < kh; i++) {
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}_sum += (*p{{ c.name }}++) * ikernel[i];
- %% endfor
+@ end
}
/* divide the result */
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}_sum /= ikern_div;
- %% endfor
+@ end
/* and clamp just to be extra sure */
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}_sum = GP_CLAMP({{ c.name }}_sum, 0, {{ c.max }});
- %% endfor
+@ end
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x_dst + x, y_dst + y,
GP_Pixel_CREATE_{{ pt.name }}(
- {{ expand_chanslist(pt, "", "_sum") }}
+ {{ arr_to_params(pt.chan_names, "", "_sum") }}
));
}
@@ -289,8 +264,7 @@ static int v_lin_conv_{{ pt.name }}(const GP_Context *src,
return 0;
}
-%% endif
-%% endfor
+@ end
int GP_FilterVLinearConvolution_Raw(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
@@ -305,23 +279,22 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src,
kh, x_src, y_src, w_src, h_src);
switch (src->pixel_type) {
- %% for pt in pixeltypes
- %% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
case GP_PIXEL_{{ pt.name }}:
return v_lin_conv_{{ pt.name }}(src, x_src, y_src, w_src, h_src,
dst, x_dst, y_dst,
kernel, kh, kern_div, callback);
break;
- %% endif
- %% endfor
+@ end
default:
errno = EINVAL;
return -1;
}
}
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
static int lin_conv_{{ pt.name }}(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
@@ -336,9 +309,9 @@ static int lin_conv_{{ pt.name }}(const GP_Context *src,
/* Do linear convolution */
for (y = 0; y < (GP_Coord)h_src; y++) {
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
uint32_t {{ c.name }}[kw][kh];
- %% endfor
+@ end
GP_Pixel pix;
/* Prefill the buffer on the start */
@@ -352,18 +325,18 @@ static int lin_conv_{{ pt.name }}(const GP_Context *src,
pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, xi, yi);
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}[i][j] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix);
- %% endfor
+@ end
}
}
int idx = kw - 1;
for (x = 0; x < (GP_Coord)w_src; x++) {
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
float {{ c.name }}_sum = 0;
- %% endfor
+@ end
for (j = 0; j < kh; j++) {
int xi = x_src + x + kw/2;
@@ -374,9 +347,9 @@ static int lin_conv_{{ pt.name }}(const GP_Context *src,
pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, xi, yi);
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}[idx][j] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix);
- %% endfor
+@ end
}
/* Count the pixel value from neighbours weighted by kernel */
@@ -389,23 +362,23 @@ static int lin_conv_{{ pt.name }}(const GP_Context *src,
k = i - idx - 1;
for (j = 0; j < kh; j++) {
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}_sum += {{ c.name }}[i][j] * kernel[k + j * kw];
- %% endfor
+@ end
}
}
/* divide the result */
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
{{ c.name }}_sum /= kern_div;
- %% endfor
+@ end
/* and clamp just to be extra sure */
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
int {{ c.name }}_res = GP_CLAMP((int){{ c.name }}_sum, 0, {{ c.max }});
- %% endfor
+@ end
- pix = GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "", "_res") }});
+ pix = GP_Pixel_CREATE_{{ pt.name }}({{ arr_to_params(pt.chan_names, "", "_res") }});
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x_dst + x, y_dst + y, pix);
@@ -423,8 +396,7 @@ static int lin_conv_{{ pt.name }}(const GP_Context *src,
return 0;
}
-%% endif
-%% endfor
+@ end
int GP_FilterLinearConvolution_Raw(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
@@ -438,19 +410,16 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src,
kw, kh, w_src, h_src);
switch (src->pixel_type) {
- %% for pt in pixeltypes
- %% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
case GP_PIXEL_{{ pt.name }}:
return lin_conv_{{ pt.name }}(src, x_src, y_src, w_src, h_src,
dst, x_dst, y_dst,
kernel, kw, kh, kern_div, callback);
break;
- %% endif
- %% endfor
+@ end
default:
errno = EINVAL;
return -1;
}
}
-
-%% endblock body
diff --git a/libs/filters/GP_MirrorH.gen.c.t b/libs/filters/GP_MirrorH.gen.c.t
index e190c37b..e926bba3 100644
--- a/libs/filters/GP_MirrorH.gen.c.t
+++ b/libs/filters/GP_MirrorH.gen.c.t
@@ -1,36 +1,15 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.c.t"
-
-{% block descr %}Horizontal Mirror alogorithm{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * Horizontal Mirror alogorithm
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include "core/GP_GetPutPixel.h"
#include "core/GP_Debug.h"
#include "GP_Rotate.h"
-%% for ps in pixelsizes
+@ for ps in pixelsizes:
static int GP_MirrorH_Raw_{{ ps.suffix }}(const GP_Context *src,
GP_Context *dst,
GP_ProgressCallback *callback)
@@ -63,8 +42,8 @@ static int GP_MirrorH_Raw_{{ ps.suffix }}(const GP_Context *src,
return 0;
}
-%% endfor
-
+@ end
+@
static int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
@@ -105,6 +84,3 @@ GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src,
return res;
}
-
-
-%% endblock body
diff --git a/libs/filters/GP_MultiTone.gen.c.t b/libs/filters/GP_MultiTone.gen.c.t
index 4329a3f1..2039a93c 100644
--- a/libs/filters/GP_MultiTone.gen.c.t
+++ b/libs/filters/GP_MultiTone.gen.c.t
@@ -1,32 +1,9 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "filter.c.t"
-
-%% block descr
-Generic Point filer
-%% endblock
-
-%% block body
+@ include source.t
+/*
+ * Generic Point filer
+ *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <errno.h>
@@ -38,8 +15,8 @@ Generic Point filer
#include "filters/GP_MultiTone.h"
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
static void init_table_{{ pt.name }}(GP_Pixel table[],
GP_Size table_size,
GP_Pixel pixels[],
@@ -67,22 +44,21 @@ static void init_table_{{ pt.name }}(GP_Pixel table[],
// GP_PixelPrint(table[i], GP_PIXEL_{{ pt.name }});
}
}
-%% endif
-%% endfor
+@ end
+@
static void init_table(GP_PixelType type,
GP_Pixel table[], GP_Size table_size,
GP_Pixel pixels[], GP_Size pixels_size)
{
switch (type) {
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
case GP_PIXEL_{{ pt.name }}:
init_table_{{ pt.name }}(table, table_size,
pixels, pixels_size);
break;
-%% endif
-%% endfor
+@ end
default:
GP_BUG("Should not be reached");
break;
@@ -91,8 +67,8 @@ static void init_table(GP_PixelType type,
#include <assert.h>
-%% for pt in pixeltypes
-%% if pt.is_gray()
+@ for pt in pixeltypes:
+@ if pt.is_gray():
static int multitone_{{ pt.name }}(const GP_Context *const src,
GP_Coord x_src, GP_Coord y_src,
GP_Size w_src, GP_Size h_src,
@@ -101,7 +77,7 @@ static int multitone_{{ pt.name }}(const GP_Context *const src,
GP_Pixel pixels[], GP_Size pixels_size,
GP_ProgressCallback *callback)
{
-%% set size = pt.chanslist[0].max + 1
+@ size = pt.chanslist[0].max + 1
GP_TempAllocCreate(tmp, {{ size }} * sizeof(GP_Pixel));
GP_Pixel *table = GP_TempAllocGet(tmp, {{ size }} * sizeof(GP_Pixel));
@@ -139,9 +115,8 @@ static int multitone_{{ pt.name }}(const GP_Context *const src,
return 0;
}
-%% endif
-%% endfor
-
+@ end
+@
int GP_FilterMultiToneEx(const GP_Context *const src,
GP_Coord x_src, GP_Coord y_src,
GP_Size w_src, GP_Size h_src,
@@ -153,8 +128,8 @@ int GP_FilterMultiToneEx(const GP_Context *const src,
//CHECK DST IS NOT PALETTE PixelHasFlags
switch (src->pixel_type) {
-%% for pt in pixeltypes
-%% if pt.is_gray()
+@ for pt in pixeltypes:
+@ if pt.is_gray():
case GP_PIXEL_{{ pt.name }}:
return multitone_{{ pt.name }}(src, x_src, y_src,
w_src, h_src, dst,
@@ -162,8 +137,7 @@ int GP_FilterMultiToneEx(const GP_Context *const src,
pixels, pixels_size,
callback);
break;
-%% endif
-%% endfor
+@ end
default:
errno = EINVAL;
return -1;
@@ -197,5 +171,3 @@ GP_Context *GP_FilterMultiToneExAlloc(const GP_Context *const src,
return res;
}
-
-%% endblock body
diff --git a/libs/filters/GP_ResizeCubic.gen.c.t b/libs/filters/GP_ResizeCubic.gen.c.t
index ae849013..39abb557 100644
--- a/libs/filters/GP_ResizeCubic.gen.c.t
+++ b/libs/filters/GP_ResizeCubic.gen.c.t
@@ -1,30 +1,9 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "filter.c.t"
-
-{% block descr %}Cubic resampling{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * Cubic resampling
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <errno.h>
#include <math.h>
@@ -51,15 +30,14 @@
#define SUM_I(a) ((a)[0] + (a)[1] + (a)[2] + (a)[3])
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_palette()
-
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
static int resize_cubic_{{ pt.name }}(const GP_Context *src,
GP_Context *dst, GP_ProgressCallback *callback)
{
- %% for c in pt.chanslist
- int32_t col_{{ c[0] }}[src->w];
- %% endfor
+@ for c in pt.chanslist:
+ int32_t col_{{ c.name }}[src->w];
+@ end
uint32_t i, j;
@@ -67,7 +45,7 @@ static int resize_cubic_{{ pt.name }}(const GP_Context *src,
src->w, src->h, dst->w, dst->h,
1.00 * dst->w / src->w, 1.00 * dst->h / src->h);
-{{ fetch_gamma_tables(pt, "src") }}
+ {@ fetch_gamma_tables(pt, "src") @}
/* pre-generate x mapping and constants */
int32_t xmap[dst->w][4];
@@ -113,9 +91,9 @@ static int resize_cubic_{{ pt.name }}(const GP_Context *src,
/* Generate interpolated row */
for (j = 0; j < src->w; j++) {
- %% for c in pt.chanslist
- int32_t {{ c[0] }}v[4];
- %% endfor
+@ for c in pt.chanslist:
+ int32_t {{ c.name }}v[4];
+@ end
GP_Pixel pix[4];
pix[0] = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, j, yi[0]);
@@ -123,67 +101,67 @@ static int resize_cubic_{{ pt.name }}(const GP_Context *src,
pix[2] = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, j, yi[2]);
pix[3] = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, j, yi[3]);
- %% for c in pt.chanslist
- {{ c[0] }}v[0] = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix[0]);
- {{ c[0] }}v[1] = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix[1]);
- {{ c[0] }}v[2] = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix[2]);
- {{ c[0] }}v[3] = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix[3]);
- %% endfor
+@ for c in pt.chanslist:
+ {{ c.name }}v[0] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix[0]);
+ {{ c.name }}v[1] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix[1]);
+ {{ c.name }}v[2] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix[2]);
+ {{ c.name }}v[3] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix[3]);
+@ end
if (src->gamma) {
- %% for c in pt.chanslist
- {{ c[0] }}v[0] = {{ c[0] }}_2_LIN[{{ c[0] }}v[0]];
- {{ c[0] }}v[1] = {{ c[0] }}_2_LIN[{{ c[0] }}v[1]];
- {{ c[0] }}v[2] = {{ c[0] }}_2_LIN[{{ c[0] }}v[2]];
- {{ c[0] }}v[3] = {{ c[0] }}_2_LIN[{{ c[0] }}v[3]];
- %% endfor
+@ for c in pt.chanslist:
+ {{ c.name }}v[0] = {{ c.name }}_2_LIN[{{ c.name }}v[0]];
+ {{ c.name }}v[1] = {{ c.name }}_2_LIN[{{ c.name }}v[1]];
+ {{ c.name }}v[2] = {{ c.name }}_2_LIN[{{ c.name }}v[2]];
+ {{ c.name }}v[3] = {{ c.name }}_2_LIN[{{ c.name }}v[3]];
+@ end
}
- %% for c in pt.chanslist
- MUL_I({{ c[0] }}v, cvy);
- %% endfor
+@ for c in pt.chanslist:
+ MUL_I({{ c.name }}v, cvy);
+@ end
- %% for c in pt.chanslist
- col_{{ c[0] }}[j] = SUM_I({{ c[0] }}v);
- %% endfor
+@ for c in pt.chanslist:
+ col_{{ c.name }}[j] = SUM_I({{ c.name }}v);
+@ end
}
/* now interpolate column for new image */
for (j = 0; j < dst->w; j++) {
- %% for c in pt.chanslist
- int32_t {{ c[0] }}v[4];
- int32_t {{ c[0] }};
- %% endfor
-
- %% for c in pt.chanslist
- {{ c[0] }}v[0] = col_{{ c[0] }}[xmap[j][0]];
- {{ c[0] }}v[1] = col_{{ c[0] }}[xmap[j][1]];
- {{ c[0] }}v[2] = col_{{ c[0] }}[xmap[j][2]];
- {{ c[0] }}v[3] = col_{{ c[0] }}[xmap[j][3]];
- %% endfor
-
- %% for c in pt.chanslist
- MUL_I({{ c[0] }}v, xmap_c[j]);
- %% endfor
-
- %% for c in pt.chanslist
- {{ c[0] }} = (SUM_I({{ c[0] }}v) + MUL*MUL/2) / MUL / MUL;
- %% endfor
+@ for c in pt.chanslist:
+ int32_t {{ c.name }}v[4];
+ int32_t {{ c.name }};
+@ end
+
+@ for c in pt.chanslist:
+ {{ c.name }}v[0] = col_{{ c.name }}[xmap[j][0]];
+ {{ c.name }}v[1] = col_{{ c.name }}[xmap[j][1]];
+ {{ c.name }}v[2] = col_{{ c.name }}[xmap[j][2]];
+ {{ c.name }}v[3] = col_{{ c.name }}[xmap[j][3]];
+@ end
+
+@ for c in pt.chanslist:
+ MUL_I({{ c.name }}v, xmap_c[j]);
+@ end
+
+@ for c in pt.chanslist:
+ {{ c.name }} = (SUM_I({{ c.name }}v) + MUL*MUL/2) / MUL / MUL;
+@ end
if (src->gamma) {
- %% for c in pt.chanslist
- {{ c[0] }} = GP_CLAMP_GENERIC({{ c[0] }}, 0, {{ 2 ** (c[2] + 2) - 1 }});
- %% endfor
- %% for c in pt.chanslist
- {{ c[0] }} = {{ c[0] }}_2_GAMMA[{{ c[0] }}];
- %% endfor
+@ for c in pt.chanslist:
+ {{ c.name }} = GP_CLAMP_GENERIC({{ c.name }}, 0, {{ 2 ** (c[2] + 2) - 1 }});
+@ end
+@ for c in pt.chanslist:
+ {{ c.name }} = {{ c.name }}_2_GAMMA[{{ c.name }}];
+@ end
} else {
- %% for c in pt.chanslist
- {{ c[0] }} = GP_CLAMP_GENERIC({{ c[0] }}, 0, {{ 2 ** c[2] - 1 }});
- %% endfor
+@ for c in pt.chanslist:
+ {{ c.name }} = GP_CLAMP_GENERIC({{ c.name }}, 0, {{ 2 ** c[2] - 1 }});
+@ end
}
- GP_Pixel pix = GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "(uint8_t)") }});
+ GP_Pixel pix = GP_Pixel_CREATE_{{ pt.name }}({{ arr_to_params(pt.chan_names, "(uint8_t)") }});
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, j, i, pix);
}
@@ -195,20 +173,18 @@ static int resize_cubic_{{ pt.name }}(const GP_Context *src,
return 0;
}
-%% endif
-%% endfor
-
+@ end
+@
static int resize_cubic(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
switch (src->pixel_type) {
- %% for pt in pixeltypes
- %% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
case GP_PIXEL_{{ pt.name }}:
return resize_cubic_{{ pt.name }}(src, dst, callback);
break;
- %% endif
- %% endfor
+@ end
default:
errno = EINVAL;
return -1;
@@ -226,5 +202,3 @@ int GP_FilterResizeCubicInt(const GP_Context *src, GP_Context *dst,
return resize_cubic(src, dst, callback);
}
-
-%% endblock body
diff --git a/libs/filters/GP_ResizeLinear.gen.c.t b/libs/filters/GP_ResizeLinear.gen.c.t
index 6a2b947d..cfa38928 100644
--- a/libs/filters/GP_ResizeLinear.gen.c.t
+++ b/libs/filters/GP_ResizeLinear.gen.c.t
@@ -1,30 +1,9 @@
-/*****************************************************************************
- * 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-2014 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "filter.c.t"
-
-{% block descr %}Linear resampling{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * Linear resampling
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <string.h>
#include <errno.h>
@@ -36,41 +15,40 @@
#include "core/GP_Debug.h"
#include "GP_Resize.h"
-
-%%- macro fetch_rows(pt, y)
- for (x = 0; x < src->w; x++) {
- GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x, {{ y }});
-%% for c in pt.chanslist
- {{ c.name }}[x] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix);
-%% endfor
- }
-%% endmacro
-
-%%- macro sum_rows(pt, mult)
- for (x = 0; x < dst->w; x++) {
- /* Get first left pixel */
-%% for c in pt.chanslist
- uint32_t {{ c.name }}_middle = 0;
- uint32_t {{ c.name }}_first = {{ c.name }}[xmap[x]] * (MULT - xoff[x]);
-%% endfor
- /* Sum middle pixels */
- for (j = xmap[x]+1; j < xmap[x+1]; j++) {
-%% for c in pt.chanslist
- {{ c.name }}_middle += {{ c.name }}[j];
-%% endfor
- }
- /* Add it all together with last pixel on the right */
-%% for c in pt.chanslist
- {{ c.name }}_res[x] += ({{ c.name }}_middle * (MULT / DIV) +
- ({{ c.name }}[xmap[x+1]] * xoff[x+1] +
- {{ c.name }}_first) / DIV) * {{ mult }} / DIV;
-%% endfor
+@
+@ def fetch_rows(pt, y):
+for (x = 0; x < src->w; x++) {
+ GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x, {{ y }});
+@ for c in pt.chanslist:
+ {{ c.name }}[x] = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix);
+@ end
+}
+@ end
+@
+@ def sum_rows(pt, mult):
+for (x = 0; x < dst->w; x++) {
+ /* Get first left pixel */
+@ for c in pt.chanslist:
+ uint32_t {{ c.name }}_middle = 0;
+ uint32_t {{ c.name }}_first = {{ c.name }}[xmap[x]] * (MULT - xoff[x]);
+@ end
+ /* Sum middle pixels */
+ for (j = xmap[x]+1; j < xmap[x+1]; j++) {
+@ for c in pt.chanslist:
+ {{ c.name }}_middle += {{ c.name }}[j];
+@ end
+ }
+ /* Add it all together with last pixel on the right */
+@ for c in pt.chanslist:
+ {{ c.name }}_res[x] += ({{ c.name }}_middle * (MULT / DIV) +
+ ({{ c.name }}[xmap[x+1]] * xoff[x+1] +
+ {{ c.name }}_first) / DIV) * {{ mult }} / DIV;
+@ end
}
-%% endmacro
-
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_palette()
+@ end
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
@@ -78,19 +56,19 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst,
uint32_t ymap[dst->h + 1];
uint32_t xoff[dst->w + 1];
uint32_t yoff[dst->h + 1];
-%% for c in pt.chanslist
+@ for c in pt.chanslist:
uint32_t {{ c.name }}[src->w];
-%% endfor
+@ end
uint32_t x, y;
uint32_t i, j;
-{# Reduce fixed point bits for > 8 bits per channel (fixed 16 bit Grayscale) #}
-%% if pt.chanslist[0].size > 8
+@ # Reduce fixed point bits for > 8 bits per channel (fixed 16 bit Grayscale)
+@ if pt.chanslist[0].size > 8:
const int MULT=1<<10;
const int DIV=1<<6;
-%% else
+@ else:
const int MULT=1<<14;
const int DIV=1<<9;
-%% endif
+@ end
/* Pre-compute mapping for interpolation */
for (i = 0; i <= dst->w; i++) {
@@ -107,38 +85,38 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst,
uint32_t div = (((uint64_t)(xmap[1] * MULT + xoff[1]) * ((uint64_t)ymap[1] * MULT + yoff[1]) + DIV/2) / DIV + DIV/2)/DIV;
/* Prefetch first row */
- {{ fetch_rows(pt, 0) }}
+ {@ fetch_rows(pt, 0) @}
for (y = 0; y < dst->h; y++) {
-%% for c in pt.chanslist
+@ for c in pt.chanslist:
uint32_t {{ c.name }}_res[dst->w];
-%% endfor
+@ end
-%% for c in pt.chanslist
+@ for c in pt.chanslist:
memset({{ c.name }}_res, 0, sizeof({{ c.name }}_res));
-%% endfor
+@ end
/* Sum first row */
- {{ sum_rows(pt, '(MULT-yoff[y])') }}
+ {@ sum_rows(pt, '(MULT-yoff[y])') @}
/* Sum middle */
for (i = ymap[y]+1; i < ymap[y+1]; i++) {
- {{ fetch_rows(pt, 'i') }}
- {{ sum_rows(pt, 'MULT') }}
+ {@ fetch_rows(pt, 'i') @}
+ {@ sum_rows(pt, 'MULT') @}
}
/* Sum last row */
if (yoff[y+1]) {
- {{ fetch_rows(pt, 'ymap[y+1]') }}
- {{ sum_rows(pt, 'yoff[y+1]') }}
+ {@ fetch_rows(pt, 'ymap[y+1]') @}
+ {@ sum_rows(pt, 'yoff[y+1]') @}
}
for (x = 0; x < dst->w; x++) {
-%% for c in pt.chanslist
+@ for c in pt.chanslist:
uint32_t {{ c.name }}_p = ({{ c.name }}_res[x] + div/2) / div;
-%% endfor
+@ end
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y,
- GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, '', '_p') }}));
+ GP_Pixel_CREATE_{{ pt.name }}({{ arr_to_params(pt.chan_names, '', '_p') }}));
}
if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w))
@@ -149,12 +127,10 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst,
return 0;
}
-%% endif
-%% endfor
-
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_palette()
-
+@ end
+@
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
static int resize_lin{{ pt.name }}(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
@@ -190,9 +166,9 @@ static int resize_lin{{ pt.name }}(const GP_Context *src, GP_Context *dst,
for (x = 0; x < dst->w; x++) {
GP_Pixel pix00, pix01, pix10, pix11;
GP_Coord x0, x1, y0, y1;
- %% for c in pt.chanslist
+@ for c in pt.chanslist:
uint32_t {{ c[0] }}, {{ c[0] }}0, {{ c[0] }}1;
- %% endfor
+@ end
x0 = xmap[x];
x1 = xmap[x] + 1;
@@ -211,28 +187,28 @@ static int resize_lin{{ pt.name }}(const GP_Context *src, GP_Context *dst,
pix01 = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x0, y1);
pix11 = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x1, y1);
- %% for c in pt.chanslist
- {{ c[0] }}0 = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix00) * (255 - xoff[x]);
- %% endfor
+@ for c in pt.chanslist:
+ {{ c.name }}0 = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix00) * (255 - xoff[x]);
+@ end
- %% for c in pt.chanslist
- {{ c[0] }}0 += GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix10) * xoff[x];
- %% endfor
+@ for c in pt.chanslist:
+ {{ c.name }}0 += GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix10) * xoff[x];
+@ end
- %% for c in pt.chanslist
- {{ c[0] }}1 = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix01) * (255 - xoff[x]);
- %% endfor
+@ for c in pt.chanslist:
+ {{ c.name }}1 = GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix01) * (255 - xoff[x]);
+@ end
- %% for c in pt.chanslist
- {{ c[0] }}1 += GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix11) * xoff[x];
- %% endfor
+@ for c in pt.chanslist:
+ {{ c.name }}1 += GP_Pixel_GET_{{ c.name }}_{{ pt.name }}(pix11) * xoff[x];
+@ end
- %% for c in pt.chanslist
- {{ c[0] }} = ({{ c[0] }}1 * yoff[y] + {{ c[0] }}0 * (255 - yoff[y]) + (1<<15)) >> 16;
- %% endfor
+@ for c in pt.chanslist:
+ {{ c.name }} = ({{ c.name }}1 * yoff[y] + {{ c.name }}0 * (255 - yoff[y]) + (1<<15)) >> 16;
+@ end
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y,
- GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "") }}));
+ GP_Pixel_CREATE_{{ pt.name }}({{ arr_to_params(pt.chan_names) }}));
}
if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w))
@@ -243,20 +219,18 @@ static int resize_lin{{ pt.name }}(const GP_Context *src, GP_Context *dst,
return 0;
}
-%% endif
-%% endfor
-
+@ end
+@
static int resize_lin(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
switch (src->pixel_type) {
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
case GP_PIXEL_{{ pt.name }}:
return resize_lin{{ pt.name }}(src, dst, callback);
break;
-%% endif
-%% endfor
+@ end
default:
GP_WARN("Invalid pixel type %s",
GP_PixelTypeName(src->pixel_type));
@@ -289,13 +263,12 @@ static int resize_lin_lf(const GP_Context *src, GP_Context *dst,
src->w, src->h, dst->w, dst->h, x_rat, y_rat);
switch (src->pixel_type) {
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_palette()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown() and not pt.is_palette():
case GP_PIXEL_{{ pt.name }}:
return resize_lin_lf_{{ pt.name }}(src, dst, callback);
break;
-%% endif
-%% endfor
+@ end
default:
GP_WARN("Invalid pixel type %s",
GP_PixelTypeName(src->pixel_type));
@@ -321,5 +294,3 @@ int GP_FilterResizeLinearLFInt(const GP_Context *src, GP_Context *dst,
return resize_lin_lf(src, dst, callback);
}
-
-%% endblock body
diff --git a/libs/filters/GP_ResizeNN.gen.c.t b/libs/filters/GP_ResizeNN.gen.c.t
index 48742883..82ef9cdf 100644
--- a/libs/filters/GP_ResizeNN.gen.c.t
+++ b/libs/filters/GP_ResizeNN.gen.c.t
@@ -1,30 +1,9 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "filter.c.t"
-
-{% block descr %}Nearest Neighbour resampling{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * Nearest Neighbour resampling
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <errno.h>
@@ -35,9 +14,8 @@
#include "GP_ResizeNN.h"
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
-
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
static int resize_nn{{ pt.name }}(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
@@ -75,20 +53,18 @@ static int resize_nn{{ pt.name }}(const GP_Context *src, GP_Context *dst,
return 0;
}
-%% endif
-%% endfor
-
+@ end
+@
static int resize_nn(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
switch (src->pixel_type) {
- %% for pt in pixeltypes
- %% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
case GP_PIXEL_{{ pt.name }}:
return resize_nn{{ pt.name }}(src, dst, callback);
break;
- %% endif
- %% endfor
+@ end
default:
return -1;
}
@@ -105,5 +81,3 @@ int GP_FilterResizeNN(const GP_Context *src, GP_Context *dst,
return resize_nn(src, dst, callback);
}
-
-%% endblock body
diff --git a/libs/filters/GP_Rotate.gen.c.t b/libs/filters/GP_Rotate.gen.c.t
index 05c404c1..6c5660b2 100644
--- a/libs/filters/GP_Rotate.gen.c.t
+++ b/libs/filters/GP_Rotate.gen.c.t
@@ -1,36 +1,15 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.c.t"
-
-{% block descr %}Vertical Mirror alogorithm{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * Vertical Mirror alogorithm
+ *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include "core/GP_Debug.h"
#include "core/GP_GetPutPixel.h"
#include "GP_Rotate.h"
-%% for ps in pixelsizes
+@ for ps in pixelsizes:
static int GP_FilterRotate90_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
@@ -52,8 +31,8 @@ static int GP_FilterRotate90_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Conte
return 0;
}
-%% endfor
-
+@ end
+@
static int GP_FilterRotate90_Raw(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
@@ -96,14 +75,14 @@ GP_Context *GP_FilterRotate90Alloc(const GP_Context *src,
return res;
}
-%% macro swap_pixels(ps, src, dst, x0, y0, x1, y1)
- GP_Pixel pix0 = GP_GetPixel_Raw_{{ ps.suffix }}({{ src }}, {{ x0 }}, {{ y0 }});
- GP_Pixel pix1 = GP_GetPixel_Raw_{{ ps.suffix }}({{ src }}, {{ x1 }}, {{ y1 }});
- GP_PutPixel_Raw_{{ ps.suffix }}({{ dst }}, {{ x0 }}, {{ y0 }}, pix1);
- GP_PutPixel_Raw_{{ ps.suffix }}({{ dst }}, {{ x1 }}, {{ y1 }}, pix0);
-%% endmacro
-
-%% for ps in pixelsizes
+@ def swap_pixels(ps, src, dst, x0, y0, x1, y1):
+GP_Pixel pix0 = GP_GetPixel_Raw_{{ ps.suffix }}({{ src }}, {{ x0 }}, {{ y0 }});
+GP_Pixel pix1 = GP_GetPixel_Raw_{{ ps.suffix }}({{ src }}, {{ x1 }}, {{ y1 }});
+GP_PutPixel_Raw_{{ ps.suffix }}({{ dst }}, {{ x0 }}, {{ y0 }}, pix1);
+GP_PutPixel_Raw_{{ ps.suffix }}({{ dst }}, {{ x1 }}, {{ y1 }}, pix0);
+@ end
+@
+@ for ps in pixelsizes:
static int GP_FilterRotate180_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
@@ -116,7 +95,7 @@ static int GP_FilterRotate180_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont
uint32_t xr = src->w - x - 1;
uint32_t yr = src->h - y - 1;
- {{ swap_pixels(ps, 'src', 'dst', 'x', 'y', 'xr', 'yr') }}
+ {@ swap_pixels(ps, 'src', 'dst', 'x', 'y', 'xr', 'yr') @}
}
if (GP_ProgressCallbackReport(callback, x, src->w, src->h))
@@ -127,8 +106,8 @@ static int GP_FilterRotate180_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont
return 0;
}
-%% endfor
-
+@ end
+@
static int GP_FilterRotate180_Raw(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
@@ -171,7 +150,7 @@ GP_Context *GP_FilterRotate180Alloc(const GP_Context *src,
return res;
}
-%% for ps in pixelsizes
+@ for ps in pixelsizes:
static int GP_FilterRotate270_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
@@ -193,8 +172,8 @@ static int GP_FilterRotate270_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont
return 0;
}
-%% endfor
-
+@ end
+@
static int GP_FilterRotate270_Raw(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
@@ -236,5 +215,3 @@ GP_Context *GP_FilterRotate270Alloc(const GP_Context *src,
return res;
}
-
-%% endblock body
diff --git a/libs/filters/Makefile b/libs/filters/Makefile
index 9c5f30f6..5eca5abb 100644
--- a/libs/filters/Makefile
+++ b/libs/filters/Makefile
@@ -1,14 +1,15 @@
TOPDIR=../..
include $(TOPDIR)/pre.mk
-STATS_FILTERS=GP_Histogram.gen.c
+#STATS_FILTERS=GP_Histogram.gen.c
-POINT_FILTERS=GP_GaussianNoise.gen.c GP_ApplyTables.gen.c GP_Invert.gen.c+#POINT_FILTERS=GP_Invert.gen.c GP_Brightness.gen.c GP_Contrast.gen.c GP_BrightnessContrast.gen.c GP_Posterize.gen.c- GP_MultiTone.gen.c
-ARITHMETIC_FILTERS=GP_Difference.gen.c GP_Addition.gen.c GP_Min.gen.c+POINT_FILTERS=GP_GaussianNoise.gen.c GP_ApplyTables.gen.c GP_MultiTone.gen.c
+
+#ARITHMETIC_FILTERS=GP_Difference.gen.c GP_Addition.gen.c GP_Min.gen.c GP_Max.gen.c GP_Multiply.gen.c
RESAMPLING_FILTERS=GP_ResizeNN.gen.c GP_Cubic.gen.c GP_ResizeCubic.gen.c@@ -22,11 +23,6 @@ CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
LIBNAME=filters
INCLUDE=core
-include $(TOPDIR)/gen.mk
+include $(TOPDIR)/genn.mk
include $(TOPDIR)/lib.mk
include $(TOPDIR)/post.mk
-
-$(POINT_FILTERS) $(ARITHMETIC_FILTERS) $(STATS_FILTERS): $(TEMPLATE_DIR)/filter.c.t
-$(STATS_FILTERS): $(TEMPLATE_DIR)/filter.stats.c.t
-$(POINT_FILTERS): $(TEMPLATE_DIR)/filter.point.c.t
-$(ARITHMETIC_FILTERS): $(TEMPLATE_DIR)/filter.arithmetic.c.t
diff --git a/libs/gfx/GP_FillCircle.gen.c.t b/libs/gfx/GP_FillCircle.gen.c.t
index ac4c6ceb..856b13bb 100644
--- a/libs/gfx/GP_FillCircle.gen.c.t
+++ b/libs/gfx/GP_FillCircle.gen.c.t
@@ -1,33 +1,11 @@
-/*****************************************************************************
- * 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 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.c.t"
-
-{% block descr %}A filled circle drawing algorithm.{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * A filled circle drawing algorithm.
+ *
+ * Copyright (C) 2009-2012 Jiri "BlueBear" Dluhos
+ * <jiri.bluebear.dluhos(a)gmail.com>
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include "core/GP_GetPutPixel.h"
#include "core/GP_Transform.h"
@@ -44,8 +22,7 @@
* until we accumulate enough Y changes to reach the next line,
* and then draw the full line. The top and bottom half are mirrored.
*/
-
-%% for ps in pixelsizes
+@ for ps in pixelsizes:
static void GP_FillCircle_Raw_{{ ps.suffix }}(GP_Context *context,
GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel)
@@ -68,7 +45,7 @@ static void GP_FillCircle_Raw_{{ ps.suffix }}(GP_Context *context,
}
}
-%% endfor
+@ end
void GP_FillCircle_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size r, GP_Pixel pixel)
@@ -88,5 +65,3 @@ void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_FillCircle_Raw(context, xcenter, ycenter, r, pixel);
}
-
-%% endblock body
diff --git a/libs/gfx/GP_FillEllipse.gen.c.t b/libs/gfx/GP_FillEllipse.gen.c.t
index 325106e0..9638d478 100644
--- a/libs/gfx/GP_FillEllipse.gen.c.t
+++ b/libs/gfx/GP_FillEllipse.gen.c.t
@@ -1,33 +1,9 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.c.t"
-
-{% block descr %}A filled ellipse drawing algorithm.{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos
+ * <jiri.bluebear.dluhos(a)gmail.com>
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include "core/GP_GetPutPixel.h"
#include "core/GP_FnPerBpp.h"
@@ -44,7 +20,7 @@
* we just iterate X until Y reaches next line, and then draw the full line.
*/
-%% for ps in pixelsizes
+@ for ps in pixelsizes:
static void GP_FillEllipse_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord xcenter,
GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel)
@@ -73,7 +49,7 @@ static void GP_FillEllipse_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord xce
}
}
-%% endfor
+@ end
void GP_FillEllipse_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size a, GP_Size b, GP_Pixel pixel)
@@ -94,5 +70,3 @@ void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_FillEllipse_Raw(context, xcenter, ycenter, a, b, pixel);
}
-
-%% endblock body
diff --git a/libs/gfx/GP_HLine.gen.c.t b/libs/gfx/GP_HLine.gen.c.t
index 4a9ea1e9..f5caae70 100644
--- a/libs/gfx/GP_HLine.gen.c.t
+++ b/libs/gfx/GP_HLine.gen.c.t
@@ -1,48 +1,25 @@
-/*****************************************************************************
- * 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> *
- * *
- *****************************************************************************/
-
-%% extends "base.c.t"
-
-{% block descr %}Horizontal line drawing{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * Horizontal line drawing
+ *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos
+ * <jiri.bluebear.dluhos(a)gmail.com>
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include "core/GP_GetPutPixel.gen.h"
#include "core/GP_WritePixel.h"
#include "gfx/GP_HLine.h"
-{# Explicit list of BPP that have optimized write pixel #}
-%% set have_writepixels = ['1BPP_LE', '1BPP_BE',
- '2BPP_LE', '2BPP_BE',
- '4BPP_LE', '4BPP_BE',
- '8BPP', '16BPP',
- '24BPP', '32BPP']
-
-%% for ps in pixelsizes
-
+@ # Explicit list of BPP that have optimized write pixel
+@ have_writepixels = ['1BPP_LE', '1BPP_BE',
+@ '2BPP_LE', '2BPP_BE',
+@ '4BPP_LE', '4BPP_BE',
+@ '8BPP', '16BPP',
+@ '24BPP', '32BPP']
+@
+@ for ps in pixelsizes:
void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int x1, int y,
GP_Pixel pixel)
{
@@ -58,23 +35,19 @@ void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int x1, int y,
x0 = GP_MAX(x0, 0);
x1 = GP_MIN(x1, (int) context->w - 1);
-%% if ps.suffix in have_writepixels
+@ if ps.suffix in have_writepixels:
size_t length = 1 + x1 - x0;
void *start = GP_PIXEL_ADDR(context, x0, y);
-%% if ps.needs_bit_endian()
+@ if ps.needs_bit_endian():
unsigned int offset = GP_PIXEL_ADDR_OFFSET_{{ ps.suffix }}(x0);
GP_WritePixels_{{ ps.suffix }}(start, offset, length, pixel);
-%% else
+@ else:
GP_WritePixels_{{ ps.suffix }}(start, length, pixel);
-%% endif
-
-%% else
+@ else:
for (;x0 <= x1; x0++)
GP_PutPixel_Raw_{{ ps.suffix }}(context, x0, y, pixel);
-%% endif
+@ end
}
-%% endfor
-%% endblock body
diff --git a/libs/gfx/GP_HLineAA.gen.c.t b/libs/gfx/GP_HLineAA.gen.c.t
index 63fc0d62..2a4910fb 100644
--- a/libs/gfx/GP_HLineAA.gen.c.t
+++ b/libs/gfx/GP_HLineAA.gen.c.t
@@ -20,11 +20,7 @@
* *
*****************************************************************************/
-%% extends "base.c.t"
-
-{% block descr %}Anti Aliased Horizontal Line{% endblock %}
-
-%% block body
+/* Anti Aliased Horizontal Line */
#include "core/GP_Context.h"
#include "core/GP_MixPixels.h"
@@ -92,5 +88,3 @@ void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1,
GP_MixPixel_Raw_Clipped(context, x, int_y+1, pixel, lp);
}
}
-
-%% endblock body
diff --git a/libs/gfx/GP_Line.gen.c.t b/libs/gfx/GP_Line.gen.c.t
index d91b45a0..093a6742 100644
--- a/libs/gfx/GP_Line.gen.c.t
+++ b/libs/gfx/GP_Line.gen.c.t
@@ -1,33 +1,11 @@
-/*****************************************************************************
- * 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 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.c.t"
-
-{% block descr %}Line drawing algorithm{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * Line drawing algorithm.
+ *
+ * Copyright (C) 2009-2012 Jiri "BlueBear" Dluhos
+ * <jiri.bluebear.dluhos(a)gmail.com>
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include "core/GP_Common.h"
#include "core/GP_GetPutPixel.h"
@@ -44,8 +22,7 @@
* for a nice and understandable description.
*/
-%% for ps in pixelsizes
-
+@ for ps in pixelsizes:
void GP_Line_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int y0,
int x1, int y1, GP_Pixel pixval)
{
@@ -116,7 +93,7 @@ void GP_Line_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int y0,
}
}
-%% endfor
+@ end
void GP_Line_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
@@ -137,5 +114,3 @@ void GP_Line(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Line_Raw(context, x0, y0, x1, y1, pixel);
}
-
-%% endblock body
diff --git a/libs/gfx/GP_LineAA.gen.c.t b/libs/gfx/GP_LineAA.gen.c.t
index 845819e0..3029dfb5 100644
--- a/libs/gfx/GP_LineAA.gen.c.t
+++ b/libs/gfx/GP_LineAA.gen.c.t
@@ -20,11 +20,7 @@
* *
*****************************************************************************/
-%% extends "base.c.t"
-
-{% block descr %}Anti Aliased Line{% endblock %}
-
-%% block body
+/* Anti Aliased Line */
#include "core/GP_Context.h"
#include "core/GP_MixPixels.h"
@@ -157,5 +153,3 @@ void GP_LineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
else
line_aa_x(context, x0, y0, x1, y1, pixel);
}
-
-%% endblock body
diff --git a/libs/gfx/GP_PutPixelAA.gen.c.t b/libs/gfx/GP_PutPixelAA.gen.c.t
index b061bf9d..92cfbdb1 100644
--- a/libs/gfx/GP_PutPixelAA.gen.c.t
+++ b/libs/gfx/GP_PutPixelAA.gen.c.t
@@ -20,11 +20,7 @@
* *
*****************************************************************************/
-%% extends "base.c.t"
-
-{% block descr %}Anti Aliased Put Pixel{% endblock %}
-
-%% block body
+/* Anti Aliased Put Pixel */
#include "core/GP_Context.h"
#include "core/GP_MixPixels.h"
@@ -70,6 +66,3 @@ void GP_PutPixelAA(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel pixel)
GP_PutPixelAA_Raw_Clipped(context, x, y, pixel);
}
-
-
-%% endblock body
diff --git a/libs/gfx/GP_VLine.gen.c.t b/libs/gfx/GP_VLine.gen.c.t
index d894f146..6870dea3 100644
--- a/libs/gfx/GP_VLine.gen.c.t
+++ b/libs/gfx/GP_VLine.gen.c.t
@@ -1,35 +1,14 @@
-/*****************************************************************************
- * 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 descr %}Vertical Line{% endblock %}
-
-{% block body %}
+@ include source.t
+/*
+ * Vertical Line drawing algorithm.
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include "core/GP_GetPutPixel.h"
#include "gfx/GP_VLine.gen.h"
-%% for ps in pixelsizes
+@ for ps in pixelsizes:
void GP_VLine_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord x,
GP_Coord y0, GP_Coord y1, GP_Pixel pixel)
{
@@ -39,6 +18,3 @@ void GP_VLine_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord x,
GP_PutPixel_Raw_{{ ps.suffix }}(context, x, y, pixel);
}
-%% endfor
-
-{% endblock body %}
diff --git a/libs/gfx/GP_VLineAA.gen.c.t b/libs/gfx/GP_VLineAA.gen.c.t
index 7c5f3fb4..7ddd7cef 100644
--- a/libs/gfx/GP_VLineAA.gen.c.t
+++ b/libs/gfx/GP_VLineAA.gen.c.t
@@ -20,11 +20,7 @@
* *
*****************************************************************************/
-%% extends "base.c.t"
-
-{% block descr %}Anti Aliased Vertical Line{% endblock %}
-
-%% block body
+/* Anti Aliased Vertical Line */
#include "core/GP_Context.h"
#include "core/GP_MixPixels.h"
@@ -79,5 +75,3 @@ void GP_VLineAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y0,
GP_MixPixel_Raw_Clipped(context, int_x+1, y, pixel, lp);
}
}
-
-%% endblock body
diff --git a/libs/gfx/Makefile b/libs/gfx/Makefile
index 8ffe38a0..b76fe13c 100644
--- a/libs/gfx/Makefile
+++ b/libs/gfx/Makefile
@@ -7,6 +7,6 @@ GENSOURCES=GP_Line.gen.c GP_HLine.gen.c GP_LineAA.gen.c GP_PutPixelAA.gen.c GP_FillEllipse.gen.c
LIBNAME=gfx
-include $(TOPDIR)/gen.mk
+include $(TOPDIR)/genn.mk
include $(TOPDIR)/lib.mk
include $(TOPDIR)/post.mk
diff --git a/libs/text/GP_Text.gen.c.t b/libs/text/GP_Text.gen.c.t
index b15d33ac..6a034864 100644
--- a/libs/text/GP_Text.gen.c.t
+++ b/libs/text/GP_Text.gen.c.t
@@ -1,33 +1,11 @@
-/*****************************************************************************
- * 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-2014 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.c.t"
-
-{% block descr %}Text rendering rutines{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * Text rendering rutines.
+ *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos
+ * <jiri.bluebear.dluhos(a)gmail.com>
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include "core/GP_GetPutPixel.h"
#include "core/GP_MixPixels.gen.h"
@@ -42,8 +20,8 @@ static int get_width(GP_TextStyle *style, int width)
return width * style->pixel_xmul + (width - 1) * style->pixel_xspace;
}
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
static void text_draw_1BPP_{{ pt.name }}(GP_Context *context, GP_TextStyle *style,
GP_Coord x, GP_Coord y,
@@ -95,26 +73,24 @@ static void text_draw_1BPP_{{ pt.name }}(GP_Context *context, GP_TextStyle *styl
}
}
-%% endif
-%% endfor
+@ end
static void text_draw_1BPP(GP_Context *context, GP_TextStyle *style, int x, int y,
GP_Pixel fg, const char *str)
{
switch (context->pixel_type) {
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
case GP_PIXEL_{{ pt.name }}:
text_draw_1BPP_{{ pt.name }}(context, style, x, y, fg, str);
break;
-%% endif
-%% endfor
+@ end
default:
GP_ABORT("Invalid context->pixel_type");
}
}
-%% macro text_8BPP(pt, use_bg)
+@ def text_8BPP(pt, use_bg):
const char *p;
GP_Coord y0 = y;
@@ -147,10 +123,10 @@ static void text_draw_1BPP(GP_Context *context, GP_TextStyle *style, int x, int
int cur_y = y - (glyph->bearing_y - style->font->ascend) * y_mul;
for (k = 0; k < style->pixel_ymul; k++) {
-%% if use_bg
+@ if use_bg:
GP_HLine(context, x_start, x_start + style->pixel_xmul - 1, cur_y + k,
GP_MIX_PIXELS_{{ pt.name }}(fg, bg, gray));
-%% else
+@ else:
unsigned int l;
for (l = x_start; l < x_start + style->pixel_xmul; l++) {
@@ -160,7 +136,7 @@ static void text_draw_1BPP(GP_Context *context, GP_TextStyle *style, int x, int
GP_TRANSFORM_POINT(context, px, py);
GP_MixPixel_Raw_Clipped_{{ pt.name }}(context, px, py, fg, gray);
}
-%% endif
+@ end
}
}
@@ -172,40 +148,38 @@ static void text_draw_1BPP(GP_Context *context, GP_TextStyle *style, int x, int
if (p == str)
x -= get_width(style, glyph->bearing_x);
}
-%% endmacro
-
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ end
+@
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
static void text_8BPP_bg_{{ pt.name }}(GP_Context *context, GP_TextStyle *style,
GP_Coord x, GP_Coord y,
GP_Pixel fg, GP_Pixel bg, const char *str)
{
-{{ text_8BPP(pt, True) }}
+@ text_8BPP(pt, True)
}
static void text_8BPP_{{ pt.name }}(GP_Context *context, GP_TextStyle *style,
GP_Coord x, GP_Coord y,
GP_Pixel fg, const char *str)
{
-{{ text_8BPP(pt, False) }}
+@ text_8BPP(pt, False)
}
-%% endif
-%% endfor
+@ end
static void text_8BPP_bg(GP_Context *context, GP_TextStyle *style,
GP_Coord x, GP_Coord y,
GP_Pixel fg, GP_Pixel bg, const char *str)
{
switch (context->pixel_type) {
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
case GP_PIXEL_{{ pt.name }}:
text_8BPP_bg_{{ pt.name }}(context, style, x, y, fg, bg, str);
break;
-%% endif
-%% endfor
+@ end
default:
GP_ABORT("Invalid context->pixel_type");
}
@@ -216,13 +190,12 @@ static void text_8BPP(GP_Context *context, GP_TextStyle *style,
GP_Pixel fg, const char *str)
{
switch (context->pixel_type) {
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
case GP_PIXEL_{{ pt.name }}:
text_8BPP_{{ pt.name }}(context, style, x, y, fg, str);
break;
-%% endif
-%% endfor
+@ end
default:
GP_ABORT("Invalid context->pixel_type");
}
@@ -246,5 +219,3 @@ void GP_Text_Raw(GP_Context *context, GP_TextStyle *style,
GP_ABORT("Invalid font glyph bitmap format");
}
}
-
-%% endblock body
diff --git a/libs/text/Makefile b/libs/text/Makefile
index ed33ab79..a02d86a8 100644
--- a/libs/text/Makefile
+++ b/libs/text/Makefile
@@ -6,7 +6,7 @@ GENSOURCES=GP_Text.gen.c
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
LIBNAME=text
-include $(TOPDIR)/gen.mk
+include $(TOPDIR)/genn.mk
include $(TOPDIR)/lib.mk
include $(TOPDIR)/post.mk
diff --git a/tests/core/BlitConv.gen.c.t b/tests/core/BlitConv.gen.c.t
index 05be76a3..97375a8f 100644
--- a/tests/core/BlitConv.gen.c.t
+++ b/tests/core/BlitConv.gen.c.t
@@ -1,30 +1,9 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.test.c.t"
-
-{% block descr %}Blit conversions tests.{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * Blit conversions tests.
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <stdio.h>
@@ -83,7 +62,7 @@ static GP_Pixel rgb_to_pixel(int r, int g, int b, GP_Context *c)
return GP_RGBToContextPixel(r, g, b, c);
}
-%% macro gen_blit(name, r, g, b, pt1, pt2)
+@ def gen_blit(name, r, g, b, pt1, pt2):
static int blit_{{ name }}_{{ pt1.name }}_to_{{ pt2.name }}(void)
{
GP_Context *src = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt1.name }});
@@ -112,87 +91,70 @@ static int blit_{{ name }}_{{ pt1.name }}_to_{{ pt2.name }}(void)
return TST_SUCCESS;
}
-%% endmacro
-
-%% macro blit_color(name, r, g, b)
-%% for pt1 in pixeltypes
-%% if not pt1.is_unknown() and not pt1.is_palette()
-%% for pt2 in pixeltypes
-%% if not pt2.is_unknown() and not pt2.is_palette()
-{{ gen_blit(name, r, g, b, pt1, pt2) }}
-%% endif
-%% endfor
-%% endif
-%% endfor
-%% endmacro
-
-{{ blit_color('black', '0x00', '0x00', '0x00') }}
-{{ blit_color('white', '0xff', '0xff', '0xff') }}
-
-%% macro blit_equal_pixel(name, r, g, b)
-%% for pt1 in pixeltypes
-%% if not pt1.is_unknown() and not pt1.is_palette()
-{{ gen_blit(name, r, g, b, pt1, pt1) }}
-%% endif
-%% endfor
-%% endmacro
-
-{{ blit_equal_pixel('equal_pixel', '0x0f', '0xff', '0x00') }}
-
-%% macro gen_blit2(name, r, g, b, pname1, pname2)
-{{ gen_blit(name, r, g, b, pixeltypes_dict[pname1], pixeltypes_dict[pname2]) }}
-%% endmacro
-
-{{ gen_blit2('red', '0xff', '0x00', '0x00', 'RGB888', 'CMYK8888') }}
-{{ gen_blit2('green', '0x00', '0xff', '0x00', 'RGB888', 'CMYK8888') }}
-{{ gen_blit2('blue', '0x00', '0x00', '0xff', 'RGB888', 'CMYK8888') }}
-{{ gen_blit2('gray', '0xef', '0xef', '0xef', 'RGB888', 'CMYK8888') }}
-
-{{ gen_blit2('red', '0xff', '0x00', '0x00', 'CMYK8888', 'RGB888') }}
-{{ gen_blit2('green', '0x00', '0xff', '0x00', 'CMYK8888', 'RGB888') }}
-{{ gen_blit2('blue', '0x00', '0x00', '0xff', 'CMYK8888', 'RGB888') }}
-{{ gen_blit2('gray', '0xef', '0xef', '0xef', 'CMYK8888', 'RGB888') }}
-
-
-%% macro gen_suite_entry(name, from, to)
- {.name = "Blit {{ from }} to {{ to }}",
- .tst_fn = blit_{{ name }}_{{ from }}_to_{{ to }}},
-%% endmacro
+
+@ def blit_color(name, r, g, b):
+@ for pt1 in pixeltypes:
+@ if not pt1.is_unknown() and not pt1.is_palette():
+@ for pt2 in pixeltypes:
+@ if not pt2.is_unknown() and not pt2.is_palette():
+{@ gen_blit(name, r, g, b, pt1, pt2) @}
+@ end
+@
+{@ blit_color('black', '0x00', '0x00', '0x00') @}
+{@ blit_color('white', '0xff', '0xff', '0xff') @}
+
+@ def blit_equal_pixel(name, r, g, b):
+@ for pt1 in pixeltypes:
+@ if not pt1.is_unknown() and not pt1.is_palette():
+{@ gen_blit(name, r, g, b, pt1, pt1) @}
+@ end
+@
+{@ blit_equal_pixel('equal_pixel', '0x0f', '0xff', '0x00') @}
+
+@ def gen_blit2(name, r, g, b, pname1, pname2):
+{@ gen_blit(name, r, g, b, pixeltypes_dict[pname1], pixeltypes_dict[pname2]) @}
+@ end
+
+{@ gen_blit2('red', '0xff', '0x00', '0x00', 'RGB888', 'CMYK8888') @}
+{@ gen_blit2('green', '0x00', '0xff', '0x00', 'RGB888', 'CMYK8888') @}
+{@ gen_blit2('blue', '0x00', '0x00', '0xff', 'RGB888', 'CMYK8888') @}
+{@ gen_blit2('gray', '0xef', '0xef', '0xef', 'RGB888', 'CMYK8888') @}
+{@ gen_blit2('red', '0xff', '0x00', '0x00', 'CMYK8888', 'RGB888') @}
+{@ gen_blit2('green', '0x00', '0xff', '0x00', 'CMYK8888', 'RGB888') @}
+{@ gen_blit2('blue', '0x00', '0x00', '0xff', 'CMYK8888', 'RGB888') @}
+{@ gen_blit2('gray', '0xef', '0xef', '0xef', 'CMYK8888', 'RGB888') @}
+
+@ def gen_suite_entry(name, p_from, p_to):
+ {.name = "Blit {{ p_from }} to {{ p_to }}",
+ .tst_fn = blit_{{ name }}_{{ p_from }}_to_{{ p_to }}},
+@ end
const struct tst_suite tst_suite = {
.suite_name = "Blit Conversions Testsuite",
.tests = {
-%% for pt1 in pixeltypes
-%% if not pt1.is_unknown() and not pt1.is_palette()
-%% for pt2 in pixeltypes
-%% if not pt2.is_unknown() and not pt2.is_palette()
- {.name = "Blit black {{ pt1.name }} to {{ pt2.name }}",
+@ for pt1 in pixeltypes:
+@ if not pt1.is_unknown() and not pt1.is_palette():
+@ for pt2 in pixeltypes:
+@ if not pt2.is_unknown() and not pt2.is_palette():
+ {.name = "Blit black {{ pt1.name }} to {{ pt2.name }}",
.tst_fn = blit_black_{{ pt1.name }}_to_{{ pt2.name }}},
- {.name = "Blit white {{ pt1.name }} to {{ pt2.name }}",
+ {.name = "Blit white {{ pt1.name }} to {{ pt2.name }}",
.tst_fn = blit_white_{{ pt1.name }}_to_{{ pt2.name }}},
-%% endif
-%% endfor
-%% endif
-%% endfor
-%% for pt1 in pixeltypes
-%% if not pt1.is_unknown() and not pt1.is_palette()
- {.name = "Blit {{ pt1.name }} to {{ pt1.name }}",
+@ for pt1 in pixeltypes:
+@ if not pt1.is_unknown() and not pt1.is_palette():
+ {.name = "Blit {{ pt1.name }} to {{ pt1.name }}",
.tst_fn = blit_equal_pixel_{{ pt1.name }}_to_{{ pt1.name }}},
-%% endif
-%% endfor
-
-{{ gen_suite_entry('red', 'RGB888', 'CMYK8888') }}
-{{ gen_suite_entry('green', 'RGB888', 'CMYK8888') }}
-{{ gen_suite_entry('blue', 'RGB888', 'CMYK8888') }}
-{{ gen_suite_entry('gray', 'RGB888', 'CMYK8888') }}
+@ end
-{{ gen_suite_entry('red', 'CMYK8888', 'RGB888') }}
-{{ gen_suite_entry('green', 'CMYK8888', 'RGB888') }}
-{{ gen_suite_entry('blue', 'CMYK8888', 'RGB888') }}
-{{ gen_suite_entry('gray', 'CMYK8888', 'RGB888') }}
+{@ gen_suite_entry('red', 'RGB888', 'CMYK8888') @}
+{@ gen_suite_entry('green', 'RGB888', 'CMYK8888') @}
+{@ gen_suite_entry('blue', 'RGB888', 'CMYK8888') @}
+{@ gen_suite_entry('gray', 'RGB888', 'CMYK8888') @}
+{@ gen_suite_entry('red', 'CMYK8888', 'RGB888') @}
+{@ gen_suite_entry('green', 'CMYK8888', 'RGB888') @}
+{@ gen_suite_entry('blue', 'CMYK8888', 'RGB888') @}
+{@ gen_suite_entry('gray', 'CMYK8888', 'RGB888') @}
{.name = NULL}
}
};
-
-%% endblock body
diff --git a/tests/core/Convert.gen.c.t b/tests/core/Convert.gen.c.t
index 945903ae..362d765a 100644
--- a/tests/core/Convert.gen.c.t
+++ b/tests/core/Convert.gen.c.t
@@ -1,33 +1,10 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.test.c.t"
-
-{% block descr %}Pixel conversions tests.{% endblock %}
-
-%% block body
-
+@ include source.t
+/*
+ * Pixel conversions tests.
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <stdio.h>
-
#include <core/GP_Convert.h>
#include "tst_test.h"
@@ -38,20 +15,19 @@
static GP_Pixel get_black(GP_PixelType pixel_type)
{
switch (pixel_type) {
-%% for pt in pixeltypes
+@ for pt in pixeltypes:
case {{ pt.C_type }}:
-%% if pt.is_cmyk()
-%% set K = pt.chans['K']
+@ if pt.is_cmyk():
+@ K = pt.chans['K']
/* Black in CMYK is full K rest zero */
return {{ K.C_mask }};
-%% elif pt.is_alpha()
-%% set A = pt.chans['A']
+@ elif pt.is_alpha():
+@ A = pt.chans['A']
/* Black with Alpha channel is full A rest zero */
return {{ A.C_mask }};
-%% else
+@ else:
return 0;
-%% endif
-%% endfor
+@ end
default:
tst_msg("Invalid pixel type %i", pixel_type);
exit(TST_INTERR);
@@ -64,39 +40,38 @@ static GP_Pixel get_black(GP_PixelType pixel_type)
static GP_Pixel get_white(GP_PixelType pixel_type)
{
switch (pixel_type) {
-%% for pt in pixeltypes
+@ for pt in pixeltypes:
case {{ pt.C_type }}:
-%% if pt.is_cmyk()
+@ if pt.is_cmyk():
/* White in CMYK is zero */
return 0x0;
-%% elif pt.is_rgb()
-%% set R = pt.chans['R']
-%% set G = pt.chans['G']
-%% set B = pt.chans['B']
-%% if pt.is_alpha()
-%% set A = pt.chans['A']
+@ elif pt.is_rgb():
+@ R = pt.chans['R']
+@ G = pt.chans['G']
+@ B = pt.chans['B']
+@ if pt.is_alpha():
+@ A = pt.chans['A']
/* White in RGBA */
return {{ A.C_mask }} | {{ R.C_mask }} | {{ G.C_mask }} | {{ B.C_mask }};
-%% else
+@ else:
/* Plain old RGB */
return {{ R.C_mask }} | {{ G.C_mask }} | {{ B.C_mask }};
-%% endif
-%% elif pt.is_gray()
-%% set V = pt.chans['V']
-%% if pt.is_alpha()
-%% set A = pt.chans['A']
+@ end
+@ elif pt.is_gray():
+@ V = pt.chans['V']
+@ if pt.is_alpha():
+@ A = pt.chans['A']
/* Grayscale with Alpha */
return {{ V.C_mask }} | {{ A.C_mask }};
-%% else
+@ else:
/* Grayscale */
return {{ V.C_mask }};
-%% endif
-%% else
+@ end
+@ else:
tst_msg("FIXME: Unsupported conversion to %s",
GP_PixelTypeName(pixel_type));
exit(TST_INTERR);
-%% endif
-%% endfor
+@ end
default:
tst_msg("Invalid pixel type %i", pixel_type);
exit(TST_INTERR);
@@ -109,46 +84,45 @@ static GP_Pixel get_white(GP_PixelType pixel_type)
static GP_Pixel get_red(GP_PixelType pixel_type)
{
switch (pixel_type) {
-%% for pt in pixeltypes
+@ for pt in pixeltypes:
case {{ pt.C_type }}:
-%% if pt.is_cmyk()
-%% set M = pt.chans['M']
-%% set Y = pt.chans['Y']
+@ if pt.is_cmyk():
+@ M = pt.chans['M']
+@ Y = pt.chans['Y']
/* Red in CMYK is full M and Y rest zero */
return {{ M.C_mask }} | {{ Y.C_mask }};
-%% elif pt.is_rgb()
-%% set R = pt.chans['R']
-%% if pt.is_alpha()
-%% set A = pt.chans['A']
+@ elif pt.is_rgb():
+@ R = pt.chans['R']
+@ if pt.is_alpha():
+@ A = pt.chans['A']
/* Red with Alpha channel is full Alpha and R rest zero */
return {{ A.C_mask }} | {{ R.C_mask }};
-%% else
+@ else:
/* Plain old RGB */
return {{ R.C_mask }};
-%% endif
-%% elif pt.is_gray()
-%% set V = pt.chans['V']
-%% if pt.is_alpha()
-%% set A = pt.chans['A']
+@ end
+@ elif pt.is_gray():
+@ V = pt.chans['V']
+@ if pt.is_alpha():
+@ A = pt.chans['A']
/* Grayscale with Alpha channel is full Alpha + 1/3 Gray */
return ({{ hex(V.max // 3)}}{{ V.C_shift }}) | {{ A.C_mask }};
-%% else
+@ else:
/* Grayscale is 1/3 Gray */
return {{ hex(V.max // 3) }}{{ V.C_shift }};
-%% endif
-%% else
+@ end
+@ else:
tst_msg("FIXME: Unsupported conversion to %s",
GP_PixelTypeName(pixel_type));
exit(TST_INTERR);
-%% endif
-%% endfor
+@ end
default:
tst_msg("Invalid pixel type %i", pixel_type);
exit(TST_INTERR);
}
}
-%% macro gen_convert_and_check(test_name, in_name, out_name)
+@ def gen_convert_and_check(test_name, in_name, out_name):
static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(void)
{
GP_Pixel out = 0;
@@ -167,69 +141,63 @@ static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(voi
return TST_SUCCESS;
}
-%% endmacro
-
-%% macro gen_converts()
-%% for pt1 in pixeltypes
-%% if not pt1.is_unknown() and not pt1.is_palette()
-%% if pt1.name not in ['RGB888', 'RGBA8888']
-{#- White -#}
-{{ gen_convert_and_check('white', pt1.name, 'RGB888') }}
-{{ gen_convert_and_check('white', pt1.name, 'RGBA8888') }}
-{{ gen_convert_and_check('white', 'RGB888', pt1.name) }}
-{{ gen_convert_and_check('white', 'RGBA8888', pt1.name) }}
-{#- Black -#}
-{{ gen_convert_and_check('black', pt1.name, 'RGB888') }}
-{{ gen_convert_and_check('black', pt1.name, 'RGBA8888') }}
-{{ gen_convert_and_check('black', 'RGB888', pt1.name) }}
-{{ gen_convert_and_check('black', 'RGBA8888', pt1.name) }}
-{#- Red -#}
-%% if not pt1.is_gray()
-{{ gen_convert_and_check('red', pt1.name, 'RGB888') }}
-{{ gen_convert_and_check('red', pt1.name, 'RGBA8888') }}
-%% endif
-{{ gen_convert_and_check('red', 'RGB888', pt1.name) }}
-{{ gen_convert_and_check('red', 'RGBA8888', pt1.name) }}
-%% endif
-%% endif
-%% endfor
-%% endmacro
-{{ gen_converts() }}
-
-%% macro gen_suite_entry(name, from, to)
- {.name = "Convert {{ name }} {{ from }} -> {{ to }}",
- .tst_fn = convert_and_check_{{ name }}_{{ from }}_to_{{ to }}},
-%% endmacro
+@ end
+@
+@ def gen_converts():
+@ for pt1 in pixeltypes:
+@ if not pt1.is_unknown() and not pt1.is_palette():
+@ if pt1.name not in ['RGB888', 'RGBA8888']:
+@ # White
+{@ gen_convert_and_check('white', pt1.name, 'RGB888') @}
+{@ gen_convert_and_check('white', pt1.name, 'RGBA8888') @}
+{@ gen_convert_and_check('white', 'RGB888', pt1.name) @}
+{@ gen_convert_and_check('white', 'RGBA8888', pt1.name) @}
+@ # Black
+{@ gen_convert_and_check('black', pt1.name, 'RGB888') @}
+{@ gen_convert_and_check('black', pt1.name, 'RGBA8888') @}
+{@ gen_convert_and_check('black', 'RGB888', pt1.name) @}
+{@ gen_convert_and_check('black', 'RGBA8888', pt1.name) @}
+@ # Red
+@ if not pt1.is_gray():
+{@ gen_convert_and_check('red', pt1.name, 'RGB888') @}
+{@ gen_convert_and_check('red', pt1.name, 'RGBA8888') @}
+@ end
+{@ gen_convert_and_check('red', 'RGB888', pt1.name) @}
+{@ gen_convert_and_check('red', 'RGBA8888', pt1.name) @}
+@ end
+@
+{@ gen_converts() @}
+
+@ def gen_suite_entry(name, p_from, p_to):
+ {.name = "Convert {{ name }} {{ p_from }} -> {{ p_to }}",
+ .tst_fn = convert_and_check_{{ name }}_{{ p_from }}_to_{{ p_to }}},
+@ end
const struct tst_suite tst_suite = {
.suite_name = "Pixel Conversions Testsuite",
.tests = {
-%% for pt1 in pixeltypes
-%% if not pt1.is_unknown() and not pt1.is_palette()
-%% if pt1.name not in ['RGB888', 'RGBA8888']
-{#- White -#}
-{{ gen_suite_entry('white', pt1.name, 'RGB888') }}
-{{ gen_suite_entry('white', pt1.name, 'RGBA8888') }}
-{{ gen_suite_entry('white', 'RGB888', pt1.name) }}
-{{ gen_suite_entry('white', 'RGBA8888', pt1.name) }}
-{#- Black -#}
-{{ gen_suite_entry('black', pt1.name, 'RGB888') }}
-{{ gen_suite_entry('black', pt1.name, 'RGBA8888') }}
-{{ gen_suite_entry('black', 'RGB888', pt1.name) }}
-{{ gen_suite_entry('black', 'RGBA8888', pt1.name) }}
-{#- Red -#}
-%% if not pt1.is_gray()
-{{ gen_suite_entry('red', pt1.name, 'RGB888') }}
-{{ gen_suite_entry('red', pt1.name, 'RGBA8888') }}
-%% endif
-{{ gen_suite_entry('red', 'RGB888', pt1.name) }}
-{{ gen_suite_entry('red', 'RGBA8888', pt1.name) }}
-%% endif
-%% endif
-%% endfor
+@ for pt1 in pixeltypes:
+@ if not pt1.is_unknown() and not pt1.is_palette():
+@ if pt1.name not in ['RGB888', 'RGBA8888']:
+@ # White
+{@ gen_suite_entry('white', pt1.name, 'RGB888') @}
+{@ gen_suite_entry('white', pt1.name, 'RGBA8888') @}
+{@ gen_suite_entry('white', 'RGB888', pt1.name) @}
+{@ gen_suite_entry('white', 'RGBA8888', pt1.name) @}
+@ # Black
+{@ gen_suite_entry('black', pt1.name, 'RGB888') @}
+{@ gen_suite_entry('black', pt1.name, 'RGBA8888') @}
+{@ gen_suite_entry('black', 'RGB888', pt1.name) @}
+{@ gen_suite_entry('black', 'RGBA8888', pt1.name) @}
+@ # Red
+@ if not pt1.is_gray():
+{@ gen_suite_entry('red', pt1.name, 'RGB888') @}
+{@ gen_suite_entry('red', pt1.name, 'RGBA8888') @}
+@ end
+{@ gen_suite_entry('red', 'RGB888', pt1.name) @}
+{@ gen_suite_entry('red', 'RGBA8888', pt1.name) @}
+@ end
{.name = NULL}
}
};
-
-%% endblock body
diff --git a/tests/core/Convert_Scale.gen.c.t b/tests/core/Convert_Scale.gen.c.t
index 2da4e03c..85f86b3a 100644
--- a/tests/core/Convert_Scale.gen.c.t
+++ b/tests/core/Convert_Scale.gen.c.t
@@ -1,30 +1,9 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.test.c.t"
-
-{% block descr %}ConvertScale tests.{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * ConvertScale tests.
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <stdio.h>
#include <math.h>
@@ -34,11 +13,11 @@
#include "tst_test.h"
-%% set max_in = 24
-%% set max_out = 16
-
-%% for i in range(1, max_in)
-%% for j in range(1, max_out)
+@ max_in = 24
+@ max_out = 16
+@
+@ for i in range(1, max_in):
+@ for j in range(1, max_out):
static int check_convert_{{ i }}_{{ j }}(void)
{
unsigned int v, fail = 0;
@@ -47,7 +26,7 @@ static int check_convert_{{ i }}_{{ j }}(void)
for (v = 0; v < {{ 2 ** i - 1 }}; v++) {
res = GP_SCALE_VAL_{{ i }}_{{ j }}(v);
-%% if j > i
+@ if j > i:
/*
* We have {{ 2**i }} values and we need to map them to
* subset of {{ 2**j }} values while making sure 0 -> 0
@@ -60,7 +39,7 @@ static int check_convert_{{ i }}_{{ j }}(void)
*/
fres = (v / {{ (2.00 ** i - 1) }}) * {{ (2.00 ** j - 1) }};
exp_res = round(fres);
-%% else
+@ else:
/*
* We have {{ 2**i }} values that must be mapped to {{ 2**j }}
* so we do simple division and floor() which maps the values
@@ -70,7 +49,7 @@ static int check_convert_{{ i }}_{{ j }}(void)
*/
fres = v * {{ (2.00 ** j) / (2.00 ** i) }};
exp_res = floor(fres);
-%% endif
+@ end
if (res != exp_res) {
if (fail < 5)
@@ -89,20 +68,16 @@ static int check_convert_{{ i }}_{{ j }}(void)
return TST_SUCCESS;
}
-%% endfor
-%% endfor
-
+@ endfor
+@
const struct tst_suite tst_suite = {
.suite_name = "Convert Scale Testsuite",
.tests = {
-%% for i in range(1, max_in)
-%% for j in range(1, max_out)
+@ for i in range(1, max_in):
+@ for j in range(1, max_out):
{.name = "SCALE_{{ i }}_{{ j }}()",
.tst_fn = check_convert_{{ i }}_{{ j }}},
-%% endfor
-%% endfor
+@ end
{.name = NULL}
}
};
-
-%% endblock body
diff --git a/tests/core/GetPutPixel.gen.c.t b/tests/core/GetPutPixel.gen.c.t
index 1e8bccde..4f2c2157 100644
--- a/tests/core/GetPutPixel.gen.c.t
+++ b/tests/core/GetPutPixel.gen.c.t
@@ -1,30 +1,9 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.test.c.t"
-
-{% block descr %}GetPutPixel tests.{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * GetPutPixel tests.
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <stdio.h>
@@ -71,8 +50,8 @@ static int try_pattern(GP_Context *c, GP_Pixel p)
return 0;
}
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
static int GetPutPixel_{{ pt.name }}(void)
{
GP_Context *c;
@@ -104,11 +83,10 @@ static int GetPutPixel_{{ pt.name }}(void)
return TST_SUCCESS;
}
-%% endif
-%% endfor
+@ end
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
static int GetPutPixel_Clipping_{{ pt.name }}(void)
{
GP_Context *c;
@@ -149,28 +127,23 @@ static int GetPutPixel_Clipping_{{ pt.name }}(void)
return TST_SUCCESS;
}
-%% endif
-%% endfor
+@ end
const struct tst_suite tst_suite = {
.suite_name = "GetPutPixel Testsuite",
.tests = {
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
{.name = "GetPutPixel {{ pt.name }}",
.tst_fn = GetPutPixel_{{ pt.name }}},
-%% endif
-%% endfor
+@ end
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
{.name = "GetPutPixel Clipping {{ pt.name }}",
.tst_fn = GetPutPixel_Clipping_{{ pt.name }}},
-%% endif
-%% endfor
+@ end
{.name = NULL}
}
};
-
-%% endblock body
diff --git a/tests/core/GetSetBits.gen.c.t b/tests/core/GetSetBits.gen.c.t
index 5c33f89b..475c83a9 100644
--- a/tests/core/GetSetBits.gen.c.t
+++ b/tests/core/GetSetBits.gen.c.t
@@ -1,30 +1,9 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.test.c.t"
-
-{% block descr %}GP_GET_BITS() and GP_SET_BITS() tests.{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * GP_GET_BITS() and GP_SET_BITS() tests.
+ *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <stdlib.h>
#include <stdint.h>
@@ -40,8 +19,8 @@ static const uint32_t patterns[] = {
0x43f8af32,
};
-%% for len in range(1, 33)
-%% for off in range(0, 33 - len)
+@ for len in range(1, 33):
+@ for off in range(0, 33 - len):
static int getbits_{{ off }}_{{ len }}(void)
{
uint32_t p_exp, p_get;
@@ -65,15 +44,11 @@ static int getbits_{{ off }}_{{ len }}(void)
return TST_SUCCESS;
}
-%% endfor
-%% endfor
-%% macro mask(off, len)
-~{{ hex((2 ** len - 1) * (2 ** off)) }}
-%%- endmacro
-
-%% for len in range(1, 33)
-%% for off in range(0, 33 - len)
+@ end
+@
+@ for len in range(1, 33):
+@ for off in range(0, 33 - len):
static int setbits_{{ off }}_{{ len }}(void)
{
uint32_t p_exp, canary1, p_get, canary2, val;
@@ -81,7 +56,7 @@ static int setbits_{{ off }}_{{ len }}(void)
for (i = 0; i < GP_ARRAY_SIZE(patterns); i++) {
for (j = 0; j < GP_ARRAY_SIZE(patterns); j++) {
- {# GP_SET_BITS() needs value clamped to the len #}
+@ # GP_SET_BITS() needs value clamped to the len
val = patterns[j] & {{ hex(2 ** len - 1) }};
canary1 = 0;
@@ -89,7 +64,7 @@ static int setbits_{{ off }}_{{ len }}(void)
p_get = patterns[i];
GP_SET_BITS({{ off }}, {{ len }}, p_get, val);
- p_exp = patterns[i] & {{ mask(off, len) }};
+ p_exp = patterns[i] & ~{{ hex((2 ** len - 1) * (2 ** off)) }};
p_exp |= val<<{{ off }};
if (p_get != p_exp || canary1 != 0 || canary2 != 0) {
@@ -105,26 +80,22 @@ static int setbits_{{ off }}_{{ len }}(void)
return TST_SUCCESS;
}
-%% endfor
-%% endfor
+@ end
+@
const struct tst_suite tst_suite = {
.suite_name = "GetSetBits testsuite",
.tests = {
-%% for len in range(1, 33)
-%% for off in range(0, 33 - len)
+@ for len in range(1, 33):
+@ for off in range(0, 33 - len):
{.name = "GP_GET_BITS off={{ off }} len={{ len }}",
.tst_fn = getbits_{{ off }}_{{ len }}},
-%% endfor
-%% endfor
-%% for len in range(1, 33)
-%% for off in range(0, 33 - len)
+@ end
+@ for len in range(1, 33):
+@ for off in range(0, 33 - len):
{.name = "GP_SET_BITS off={{ off }} len={{ len }}",
.tst_fn = setbits_{{ off }}_{{ len }}},
-%% endfor
-%% endfor
+@ end
{.name = NULL}
}
};
-
-%% endblock body
diff --git a/tests/core/Makefile b/tests/core/Makefile
index 737fc17f..cfb3a543 100644
--- a/tests/core/Makefile
+++ b/tests/core/Makefile
@@ -12,6 +12,6 @@ APPS=WritePixel.gen Pixel Context GetPutPixel.gen Convert.gen BlitConv.gen
include ../tests.mk
-include $(TOPDIR)/gen.mk
+include $(TOPDIR)/genn.mk
include $(TOPDIR)/app.mk
include $(TOPDIR)/post.mk
diff --git a/tests/core/WritePixel.gen.c.t b/tests/core/WritePixel.gen.c.t
index 9c433a0f..094c4438 100644
--- a/tests/core/WritePixel.gen.c.t
+++ b/tests/core/WritePixel.gen.c.t
@@ -1,30 +1,8 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "base.test.c.t"
-
-{% block descr %}WritePixel tests.{% endblock %}
-
-%% block body
+/*
+ * WritePixel tests.
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <stdio.h>
#include <string.h>
@@ -73,12 +51,12 @@ static void dump_buffer(const char *name, char *buf, unsigned int buf_len)
return TST_SUCCESS; } while (0)
-%% for pixelsize in [8, 16, 24, 32]
-%% for offset in range(0, 4)
-%% for len in range(0, 6)
-%% for aligment in [0, 4]
-%% if (pixelsize != 16 and pixelsize != 32) or aligment == 0
-static int WritePixel{{ "_%i_%i_%i_%i"|format(pixelsize, offset, len, aligment) }}(void)
+@ for pixelsize in [8, 16, 24, 32]:
+@ for offset in range(0, 4):
+@ for len in range(0, 6):
+@ for aligment in [0, 4]:
+@ if (pixelsize != 16 and pixelsize != 32) or aligment == 0:
+static int WritePixel{{ "_%i_%i_%i_%i" % (pixelsize, offset, len, aligment) }}(void)
{
char write_buf[{{ 25 * pixelsize//8 }}] = {};
char gen_buf[{{ 25 * pixelsize//8 }}] = {};
@@ -86,18 +64,17 @@ static int WritePixel{{ "_%i_%i_%i_%i"|format(pixelsize, offset, len, aligment)
/*
* Fill the compare buffer
*/
-%% for i in range(0, len)
-%% for j in range(0, pixelsize//8)
+@ for i in range(0, len):
+@ for j in range(0, pixelsize//8):
gen_buf[{{aligment + offset * pixelsize//8 + i * pixelsize//8 + j}}] = 0xff;
-%% endfor
-%% endfor
+@ end
GP_WritePixels_{{ pixelsize }}BPP(write_buf + {{aligment + offset * pixelsize//8}}, {{ len }}, 0xffffffff>>{{32 - pixelsize}});
- COMPARE_BUFFERS({{""p=%i o=%i l=%i a=%i""|format(pixelsize, offset, len, aligment)}}, write_buf, gen_buf);
+ COMPARE_BUFFERS({{'"p=%i o=%i l=%i a=%i"' % (pixelsize, offset, len, aligment)}}, write_buf, gen_buf);
}
-static int WritePixel{{ "_%i_%i_%i_%i_alloc"|format(pixelsize, offset, len, aligment) }}(void)
+static int WritePixel{{ "_%i_%i_%i_%i_alloc" % (pixelsize, offset, len, aligment) }}(void)
{
char gen_buf[{{ 25 * pixelsize//8 }}] = {};
char *write_buf = malloc({{ 25 * pixelsize//8 }});
@@ -105,11 +82,10 @@ static int WritePixel{{ "_%i_%i_%i_%i_alloc"|format(pixelsize, offset, len, alig
/*
* Fill the compare buffer
*/
-%% for i in range(0, len)
-%% for j in range(0, pixelsize//8)
+@ for i in range(0, len):
+@ for j in range(0, pixelsize//8):
gen_buf[{{aligment + offset * pixelsize//8 + i * pixelsize//8 + j}}] = 0xff;
-%% endfor
-%% endfor
+@ end
if (gen_buf == NULL) {
tst_msg("Malloc failed :(");
@@ -120,33 +96,23 @@ static int WritePixel{{ "_%i_%i_%i_%i_alloc"|format(pixelsize, offset, len, alig
GP_WritePixels_{{ pixelsize }}BPP(write_buf + {{aligment + offset * pixelsize//8}}, {{ len }}, 0xffffffff>>{{32 - pixelsize}});
- COMPARE_BUFFERS({{""p=%i o=%i l=%i a=%i""|format(pixelsize, offset, len, aligment)}}, write_buf, gen_buf);
+ COMPARE_BUFFERS({{'"p=%i o=%i l=%i a=%i"' % (pixelsize, offset, len, aligment)}}, write_buf, gen_buf);
}
-%% endif
-%% endfor
-%% endfor
-%% endfor
-%% endfor
+@ end
const struct tst_suite tst_suite = {
.suite_name = "WritePixel Testsuite",
.tests = {
-%% for pixelsize in [8, 16, 24, 32]
-%% for offset in range(0, 4)
-%% for len in range(0, 6)
-%% for aligment in [0, 4]
-%% if (pixelsize != 16 and pixelsize != 32) or aligment == 0
- {.name = "WritePixel {{ pixelsize }} {{ offset }} {{ len }} {{ aligment }} stack",
- .tst_fn = WritePixel{{ "_%i_%i_%i_%i"|format(pixelsize, offset, len, aligment) }}},
- {.name = "WritePixel {{ pixelsize }} {{ offset }} {{ len }} {{ aligment }} alloc",
- .tst_fn = WritePixel{{ "_%i_%i_%i_%i_alloc"|format(pixelsize, offset, len, aligment) }}},
-%% endif
-%% endfor
-%% endfor
-%% endfor
-%% endfor
+@ for pixelsize in [8, 16, 24, 32]:
+@ for offset in range(0, 4):
+@ for len in range(0, 6):
+@ for aligment in [0, 4]:
+@ if (pixelsize != 16 and pixelsize != 32) or aligment == 0:
+ {.name = "WritePixel {{ pixelsize }} {{ offset }} {{ len }} {{ aligment }} stack",
+ .tst_fn = WritePixel{{ "_%i_%i_%i_%i" % (pixelsize, offset, len, aligment) }}},
+ {.name = "WritePixel {{ pixelsize }} {{ offset }} {{ len }} {{ aligment }} alloc",
+ .tst_fn = WritePixel{{ "_%i_%i_%i_%i_alloc" % (pixelsize, offset, len, aligment) }}},
+@ end
{.name = NULL}
}
};
-
-%% endblock body
diff --git a/tests/gfx/APICoverage.gen.c.t b/tests/gfx/APICoverage.gen.c.t
index 1afea7e4..7cccfa00 100644
--- a/tests/gfx/APICoverage.gen.c.t
+++ b/tests/gfx/APICoverage.gen.c.t
@@ -1,37 +1,10 @@
-/*****************************************************************************
- * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
- /*
-
- The purpose of this test is to exercise as much codepaths as possible
- without checking for result corectness.
-
- */
-
-%% extends "base.test.c.t"
-
-{% block descr %}GFX API converage tests.{% endblock %}
-
-%% block body
+@ include source.t
+/*
+ * The purpose of this test is to exercise as much codepaths as possible
+ * without checking for result corectness.
+ *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz>
+ */
#include <stdio.h>
@@ -40,101 +13,95 @@
#include "tst_test.h"
-%% set API_List = [
- ['Fill', 'GP_Context:in', 'int:pixel'],
-
- ['HLine', 'GP_Context:in', 'int:x0', 'int:x1', 'int:y', 'int:pixel'],
- ['VLine', 'GP_Context:in', 'int:x', 'int:y0', 'int:y1', 'int:pixel'],
-
- ['Line', 'GP_Context:in', 'int:x0', 'int:y0',
- 'int:x1', 'int:y1', 'int:pixel'],
-
- ['Circle', 'GP_Context:in', 'int:xcenter', 'int:ycenter',
- 'int:r', 'int:pixel'],
- ['FillCircle', 'GP_Context:in', 'int:xcenter', 'int:ycenter',
- 'int:r', 'int:pixel'],
-
- ['Ellipse', 'GP_Context:in', 'int:xcenter', 'int:ycenter',
- 'int:a', 'int:b', 'int:pixel'],
- ['FillEllipse', 'GP_Context:in', 'int:xcenter', 'int:ycenter',
- 'int:a', 'int:b', 'int:pixel'],
-
- ['Ring', 'GP_Context:in', 'int:xc', 'int:yc',
- 'int:r1', 'int:r2', 'int:pixel'],
- ['FillRing', 'GP_Context:in', 'int:xc', 'int:yc',
- 'int:r1', 'int:r2', 'int:pixel'],
-
- ['Rect', 'GP_Context:in', 'int:x0', 'int:y0',
- 'int:x1', 'int:y1', 'int:pixel'],
- ['FillRect', 'GP_Context:in', 'int:x0', 'int:y0',
- 'int:x1', 'int:y1', 'int:pixel'],
-
- ['Triangle', 'GP_Context:in', 'int:x0', 'int:y0',
- 'int:x1', 'int:y1', 'int:x2', 'int:y2', 'int:pixel'],
- ['FillTriangle', 'GP_Context:in', 'int:x0', 'int:y0',
- 'int:x1', 'int:y1', 'int:x2', 'int:y2', 'int:pixel'],
-
- ['Tetragon', 'GP_Context:in', 'int:x0', 'int:y0', 'int:x1', 'int:y1',
- 'int:x2', 'int:y2', 'int:x3', 'int:y3', 'int:pixel'],
- ['FillTetragon', 'GP_Context:in', 'int:x0', 'int:y0', 'int:x1', 'int:y1',
- 'int:x2', 'int:y2', 'int:x3', 'int:y3', 'int:pixel'],
-
-]
-
-%% macro prep_context(id, pt)
- GP_Context *{{ id }} = GP_ContextAlloc(331, 331, GP_PIXEL_{{ pt.name }});
-%% endmacro
-
-%% macro prep_int(id)
- int {{ id }} = 2;
-%% endmacro
-
-%% macro prep_param(param, pt)
-%% if (param.split(':', 1)[0] == 'GP_Context')
-{{ prep_context(param.split(':', 1)[1], pt) }}
-%% endif
-%% if (param.split(':', 1)[0] == 'float')
-{{ prep_float(param.split(':', 1)[1]) }}
-%% endif
-%% if (param.split(':', 1)[0] == 'int')
-{{ prep_int(param.split(':', 1)[1]) }}
-%% endif
-%% endmacro
-
-{% macro get_param(param) %}{% if len(param.split(':', 1)) == 1 %}NULL{% else %}{{ param.split(':', 1)[1] }}{% endif %}{% endmacro %}
-
-%% for fn in API_List
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
-
+@ API_List = [
+@ ['Fill', 'GP_Context:in', 'int:pixel'],
+@
+@ ['HLine', 'GP_Context:in', 'int:x0', 'int:x1', 'int:y', 'int:pixel'],
+@ ['VLine', 'GP_Context:in', 'int:x', 'int:y0', 'int:y1', 'int:pixel'],
+@
+@ ['Line', 'GP_Context:in', 'int:x0', 'int:y0',
+@ 'int:x1', 'int:y1', 'int:pixel'],
+@
+@ ['Circle', 'GP_Context:in', 'int:xcenter', 'int:ycenter',
+@ 'int:r', 'int:pixel'],
+@ ['FillCircle', 'GP_Context:in', 'int:xcenter', 'int:ycenter',
+@ 'int:r', 'int:pixel'],
+@
+@ ['Ellipse', 'GP_Context:in', 'int:xcenter', 'int:ycenter',
+@ 'int:a', 'int:b', 'int:pixel'],
+@ ['FillEllipse', 'GP_Context:in', 'int:xcenter', 'int:ycenter',
+@ 'int:a', 'int:b', 'int:pixel'],
+@
+@ ['Ring', 'GP_Context:in', 'int:xc', 'int:yc',
+@ 'int:r1', 'int:r2', 'int:pixel'],
+@ ['FillRing', 'GP_Context:in', 'int:xc', 'int:yc',
+@ 'int:r1', 'int:r2', 'int:pixel'],
+@
+@ ['Rect', 'GP_Context:in', 'int:x0', 'int:y0',
+@ 'int:x1', 'int:y1', 'int:pixel'],
+@ ['FillRect', 'GP_Context:in', 'int:x0', 'int:y0',
+@ 'int:x1', 'int:y1', 'int:pixel'],
+@
+@ ['Triangle', 'GP_Context:in', 'int:x0', 'int:y0',
+@ 'int:x1', 'int:y1', 'int:x2', 'int:y2', 'int:pixel'],
+@ ['FillTriangle', 'GP_Context:in', 'int:x0', 'int:y0',
+@ 'int:x1', 'int:y1', 'int:x2', 'int:y2', 'int:pixel'],
+@
+@ ['Tetragon', 'GP_Context:in', 'int:x0', 'int:y0', 'int:x1', 'int:y1',
+@ 'int:x2', 'int:y2', 'int:x3', 'int:y3', 'int:pixel'],
+@ ['FillTetragon', 'GP_Context:in', 'int:x0', 'int:y0', 'int:x1', 'int:y1',
+@ 'int:x2', 'int:y2', 'int:x3', 'int:y3', 'int:pixel'],
+@ ]
+@
+@ def prep_context(id, pt):
+GP_Context *{{ id }} = GP_ContextAlloc(331, 331, GP_PIXEL_{{ pt.name }});
+@ end
+@
+@ def prep_int(id):
+int {{ id }} = 2;
+@ end
+@
+@ def prep_param(param, pt):
+@ if (param.split(':', 1)[0] == 'GP_Context'):
+{@ prep_context(param.split(':', 1)[1], pt) @}
+@ if (param.split(':', 1)[0] == 'float'):
+{@ prep_float(param.split(':', 1)[1]) @}
+@ if (param.split(':', 1)[0] == 'int'):
+{@ prep_int(param.split(':', 1)[1]) @}
+@ end
+@
+@ def get_param(param):
+@ if len(param.split(':', 1)) == 1:
+@ return 'NULL'
+@ else:
+@ return param.split(':', 1)[1]
+@ end
+@
+@ for fn in API_List:
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
static int Gfx_{{ fn[0]}}_{{ pt.name }}(void)
{
-%% for param in fn[1:]
-{{ prep_param(param, pt) }}
-%% endfor
+@ for param in fn[1:]:
+ {@ prep_param(param, pt) @}
+@ end
- GP_{{ fn[0] }}({{ get_param(fn[1]) }}{% for param in fn[2:] %}, {{ get_param(param) }}{% endfor %});
+ GP_{{ fn[0] }}({{ ', '.join(map(get_param, fn[1:])) }});
return TST_SUCCESS;
}
-%% endif
-%% endfor
-%% endfor
-
+@ end
+@
const struct tst_suite tst_suite = {
.suite_name = "Gfx API Coverage",
.tests = {
-%% for fn in API_List
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
- {.name = "{{ fn[0] }} {{ pt.name }}",
+@ for fn in API_List:
+@ for pt in pixeltypes:
+@ if not pt.is_unknown():
+ {.name = "{{ fn[0] }} {{ pt.name }}",
.tst_fn = Gfx_{{ fn[0] }}_{{ pt.name }}},
-%% endif
-%% endfor
-%% endfor
+@ end
{.name = NULL}
}
};
-
-%% endblock body
diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile
index c93bf99d..577b61e8 100644
--- a/tests/gfx/Makefile
+++ b/tests/gfx/Makefile
@@ -23,6 +23,6 @@ FillRect: common.o
include ../tests.mk
-include $(TOPDIR)/gen.mk
+include $(TOPDIR)/genn.mk
include $(TOPDIR)/app.mk
include $(TOPDIR)/post.mk
http://repo.or.cz/w/gfxprim.git/commit/1176d24e31d0d820628edf8b4d5ba74db4d5…
commit 1176d24e31d0d820628edf8b4d5ba74db4d51cb5
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Oct 23 10:45:05 2014 +0200
Update .gitignore files.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/bogoman/.gitignore b/demos/bogoman/.gitignore
new file mode 100644
index 00000000..8ba14a01
--- /dev/null
+++ b/demos/bogoman/.gitignore
@@ -0,0 +1 @@
+/bogoman
diff --git a/demos/c_simple/.gitignore b/demos/c_simple/.gitignore
index a9d725a0..62b24904 100644
--- a/demos/c_simple/.gitignore
+++ b/demos/c_simple/.gitignore
@@ -1,9 +1,35 @@
-backend_example
-filters_symmetry
-gfx_koch
-loaders
-loaders_example
-meta_data
-meta_data_dump
-tmp_file
-virtual_backend_example
+/SDL_glue
+/backend_example
+/backend_timers_example
+/blittest
+/convolution
+/data_storage
+/debug_handler
+/fileview
+/filters_symmetry
+/fonttest
+/gaussian_noise
+/gfx_koch
+/input_example
+/koch
+/linetest
+/loaders
+/loaders_example
+/loaders_register
+/memory_io
+/meta_data
+/pretty_print
+/randomshapetest
+/shapetest
+/showimage
+/sin_AA
+/textaligntest
+/timers
+/tmp_file
+/v4l2_grab
+/v4l2_show
+/version
+/virtual_backend_example
+/weighted_median
+/x11_windows
+/zip_container
diff --git a/tests/core/.gitignore b/tests/core/.gitignore
new file mode 100644
index 00000000..f52f0420
--- /dev/null
+++ b/tests/core/.gitignore
@@ -0,0 +1,10 @@
+/BlitClipped
+/BlitConv.gen
+/Context
+/Convert.gen
+/Convert_Scale.gen
+/Debug
+/GetPutPixel.gen
+/GetSetBits.gen
+/Pixel
+/WritePixel.gen
diff --git a/tests/filters/.gitignore b/tests/filters/.gitignore
new file mode 100644
index 00000000..608d042b
--- /dev/null
+++ b/tests/filters/.gitignore
@@ -0,0 +1,3 @@
+/APICoverage.gen
+/FilterMirrorH
+/FiltersCompare.gen
diff --git a/tests/framework/.gitignore b/tests/framework/.gitignore
new file mode 100644
index 00000000..ee4c9268
--- /dev/null
+++ b/tests/framework/.gitignore
@@ -0,0 +1 @@
+/test
diff --git a/tests/gfx/.gitignore b/tests/gfx/.gitignore
new file mode 100644
index 00000000..92632603
--- /dev/null
+++ b/tests/gfx/.gitignore
@@ -0,0 +1,15 @@
+/APICoverage.gen
+/Circle
+/CircleSeg
+/Ellipse
+/FillCircle
+/FillEllipse
+/FillRect
+/HLine
+/HLineAA
+/Line
+/LineAA
+/Polygon
+/PutPixelAA
+/VLine
+/gfx_benchmark
diff --git a/tests/input/.gitignore b/tests/input/.gitignore
new file mode 100644
index 00000000..c2490496
--- /dev/null
+++ b/tests/input/.gitignore
@@ -0,0 +1,2 @@
+/TimeStamp
+/Timer
diff --git a/tests/loaders/.gitignore b/tests/loaders/.gitignore
index 6b693da7..83ddae9d 100644
--- a/tests/loaders/.gitignore
+++ b/tests/loaders/.gitignore
@@ -1,15 +1,16 @@
-GIF
-IO
-PBM
-PGM
-PNG
-PNM
-PPM
-PCX
-JPG
-SaveAbort.gen
-SaveLoad.gen
-ZIP
-loaders_suite
-Loader
-DataStorage
+/DataStorage
+/Exif
+/GIF
+/IO
+/JPG
+/Loader
+/PBM
+/PCX
+/PGM
+/PNG
+/PNM
+/PPM
+/SaveAbort.gen
+/SaveLoad.gen
+/ZIP
+/loaders_suite
http://repo.or.cz/w/gfxprim.git/commit/c962710c01d67f93a2a39d49db5b5a678df8…
commit c962710c01d67f93a2a39d49db5b5a678df8070e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Oct 23 10:31:19 2014 +0200
JP2: Fix loader gettting stuck on no end marker.
In case that the file ended up prematurely the read callback will spin
in infinite loop because the read has returned zero. Change it to return
-1 in this case which causes the openjpeg loader abort instead of the
infinite loop.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_JP2.c b/libs/loaders/GP_JP2.c
index 39b080d2..e1694ff2 100644
--- a/libs/loaders/GP_JP2.c
+++ b/libs/loaders/GP_JP2.c
@@ -86,7 +86,13 @@ static const char *color_space_name(OPJ_COLOR_SPACE color_space)
static OPJ_SIZE_T jp2_io_read(void *buf, OPJ_SIZE_T size, void *io)
{
- return GP_IORead(io, buf, size);
+ ssize_t ret;
+ ret = GP_IORead(io, buf, size);
+
+ if (ret == 0)
+ return -1;
+
+ return ret;
}
static void fill_metadata(opj_image_t *img, GP_DataStorage *storage)
http://repo.or.cz/w/gfxprim.git/commit/c0cfb2f6ac22689db526b97aa65cb0ca89bb…
commit c0cfb2f6ac22689db526b97aa65cb0ca89bbb1cf
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Jul 21 22:09:24 2014 +0200
loaders: Rewrite Exif loader and meta data storage
Now all loader functions have Ex variant that has data storage parameter
to store image metadata to.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Loaders_symbols.txt b/build/syms/Loaders_symbols.txt
index 24d0e037..5ef70802 100644
--- a/build/syms/Loaders_symbols.txt
+++ b/build/syms/Loaders_symbols.txt
@@ -1,18 +1,18 @@
GP_MatchJPG
GP_ReadJPG
+GP_ReadJPGEx
GP_LoadJPG
+GP_LoadJPGEx
GP_WriteJPG
GP_SaveJPG
-GP_ReadJPGMetaData
-GP_LoadJPGMetaData
GP_JPG
GP_MatchPNG
GP_ReadPNG
+GP_ReadPNGEx
GP_LoadPNG
-GP_ReadPNGMetaData
-GP_LoadPNGMetaData
+GP_LoadPNGEx
GP_WritePNG
GP_SavePNG
GP_PNG
@@ -20,6 +20,7 @@ GP_PNG
GP_MatchBMP
GP_WriteBMP
GP_LoadBMP
+GP_ReadBMPEx
GP_ReadBMP
GP_SaveBMP
GP_BMP
@@ -27,21 +28,27 @@ GP_BMP
GP_MatchPSP
GP_ReadPSP
GP_LoadPSP
+GP_ReadPSPEx
GP_PSP
GP_MatchGIF
-GP_LoadGIF
GP_ReadGIF
+GP_ReadGIFEx
+GP_LoadGIF
+GP_LoadGIFEx
GP_GIF
-GP_MatchTIFF
GP_ReadTIFF
GP_LoadTIFF
+GP_ReadTIFFEx
+GP_LoadTIFFEx
+GP_MatchTIFF
GP_WriteTIFF
GP_SaveTIFF
GP_TIFF
GP_ReadPBM
+GP_ReadPBMEx
GP_LoadPBM
GP_WritePBM
GP_SavePBM
@@ -49,6 +56,7 @@ GP_MatchPBM
GP_PBM
GP_ReadPGM
+GP_ReadPGMEx
GP_LoadPGM
GP_WritePGM
GP_SavePGM
@@ -56,6 +64,7 @@ GP_MatchPGM
GP_PGM
GP_ReadPPM
+GP_ReadPPMEx
GP_LoadPPM
GP_WritePPM
GP_SavePPM
@@ -63,6 +72,7 @@ GP_MatchPPM
GP_PPM
GP_ReadPNM
+GP_ReadPNMEx
GP_LoadPNM
GP_WritePNM
GP_SavePNM
@@ -71,48 +81,44 @@ GP_PNM
GP_ReadJP2
GP_LoadJP2
+GP_ReadJP2Ex
+GP_LoadJP2Ex
GP_MatchJP2
GP_JP2
GP_ReadPCX
GP_LoadPCX
+GP_ReadPCXEx
+GP_LoadPCXEx
GP_MatchPCX
GP_PCX
GP_ReadPSD
+GP_ReadPSDEx
GP_LoadPSD
GP_MatchPSD
GP_PSD
+GP_ReadExif
+
GP_SaveTmpFile
GP_LoadTmpFile
GP_LoaderBySignature
GP_LoaderByFilename
GP_LoaderLoadImage
+GP_LoaderLoadImageEx
+GP_LoaderReadImage
+GP_LoaderReadImageEx
GP_LoaderSaveImage
GP_ReadImage
GP_LoadImage
-GP_SaveImage
GP_LoadMetaData
+GP_SaveImage
GP_ListLoaders
GP_LoaderRegister
GP_LoaderUnregister
-GP_MetaDataGetString
-GP_MetaDataCreateRat
-GP_MetaDataCreateInt
-GP_MetaDataCreateRecord
-GP_MetaDataGetInt
-GP_MetaDataDestroy
-GP_MetaDataClear
-GP_MetaDataCreateDouble
-GP_MetaDataCreateString
-GP_MetaDataCreate
-GP_MetaDataPrint
-GP_MetaDataGetDouble
-GP_MetaDataFromExif
-
GP_ContainerLoad
GP_ContainerSeek
@@ -138,3 +144,17 @@ GP_IOPrintF
GP_IOZlib
GP_IOZlibReset
+
+GP_DataStorageCreate
+GP_DataStorageDestroy
+GP_DataStorageClear
+GP_DataStorageRoot
+GP_DataStorageGet
+GP_DataStorageAdd
+GP_DataStorageAddInt
+GP_DataStorageAddDouble
+GP_DataStorageAddString
+GP_DataStorageAddRational
+GP_DataStorageAddDict
+GP_DataTypeName
+GP_DataPrint
diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile
index 0abe0214..654df984 100644
--- a/demos/c_simple/Makefile
+++ b/demos/c_simple/Makefile
@@ -13,12 +13,12 @@ INCLUDE=
LDLIBS+=-lrt
APPS=backend_example loaders_example loaders filters_symmetry gfx_koch- virtual_backend_example meta_data meta_data_dump tmp_file showimage+ virtual_backend_example meta_data tmp_file showimage v4l2_show v4l2_grab convolution weighted_median shapetest koch input_example fileview linetest randomshapetest fonttest loaders_register blittest textaligntest sin_AA x11_windows debug_handler gaussian_noise version pretty_print timers- zip_container backend_timers_example memory_io
+ zip_container backend_timers_example memory_io data_storage
ifeq ($(HAVE_LIBSDL),yes)
APPS+=SDL_glue
@@ -36,7 +36,6 @@ tmp_file: LDLIBS+=-lgfxprim-loaders
filters_symmetry: LDLIBS+=-lgfxprim-loaders
gfx_koch: LDLIBS+=-lgfxprim-loaders -lm
meta_data: LDLIBS+=-lgfxprim-loaders
-meta_data_dump: LDLIBS+=-lgfxprim-loaders
v4l2_show: LDLIBS+=-lgfxprim-grabbers -lgfxprim-backends
v4l2_grab: LDLIBS+=-lgfxprim-grabbers -lgfxprim-loaders
convolution: LDLIBS+=-lgfxprim-loaders
@@ -56,6 +55,7 @@ sin_AA: LDLIBS+=-lgfxprim-backends -lm
x11_windows: LDLIBS+=-lgfxprim-backends
zip_container: LDLIBS+=-lgfxprim-loaders -lgfxprim-backends
memory_io: LDLIBS+=-lgfxprim-backends -lgfxprim-loaders
+data_storage: LDLIBS+=-lgfxprim-loaders
include $(TOPDIR)/app.mk
include $(TOPDIR)/post.mk
diff --git a/demos/c_simple/meta_data_dump.c b/demos/c_simple/data_storage.c
similarity index 60%
copy from demos/c_simple/meta_data_dump.c
copy to demos/c_simple/data_storage.c
index 8fc25263..902bbdbb 100644
--- a/demos/c_simple/meta_data_dump.c
+++ b/demos/c_simple/data_storage.c
@@ -16,52 +16,60 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
/*
- Read image meta-data and print them into stdout.
+ Data storage operations example.
*/
#include <stdio.h>
-#include <string.h>
-#include <errno.h>
#include <GP.h>
-#define SEP -"-----------------------------------------------------------------------------"
-
-int main(int argc, char *argv[])
+int main(void)
{
- GP_MetaData *data = GP_MetaDataCreate(80);
- int i;
+ GP_DataStorage *storage = GP_DataStorageCreate();
+ GP_DataNode *flags;
- if (argc < 2) {
- fprintf(stderr, "Takes an image(s) as parameter(s)n");
+ if (storage == NULL)
return 1;
- }
- //GP_SetDebugLevel(10);
+ printf("Empty storage -----------------------n");
+ GP_DataPrint(GP_DataStorageRoot(storage));
+ printf("-------------------------------------nn");
+
+ GP_DataNode data = {
+ .type = GP_DATA_INT,
+ .value.i = 300,
+ .id = "dpi"
+ };
+
+ GP_DataStorageAdd(storage, NULL, &data);
+
+ GP_DataStorageAddString(storage, NULL, "orientation", "top-down");
+
+ printf("Flat storage ------------------------n");
+ GP_DataPrint(GP_DataStorageRoot(storage));
+ printf("-------------------------------------nn");
+
+ flags = GP_DataStorageAddDict(storage, NULL, "flags");
- for (i = 1; i < argc; i++) {
- puts(SEP);
- printf("Opening '%s'n", argv[i]);
+ data.type = GP_DATA_INT;
+ data.id = "compression_level";
+ data.value.i = 10;
- GP_MetaDataClear(data);
+ GP_DataStorageAdd(storage, flags, &data);
- if (GP_LoadMetaData(argv[i], data)) {
- fprintf(stderr, "Failed to read '%s' meta-data: %sn",
- argv[1], strerror(errno));
- } else {
- GP_MetaDataPrint(data);
- }
- }
+ printf("Recursive storage -------------------n");
+ GP_DataPrint(GP_DataStorageRoot(storage));
+ printf("-------------------------------------nn");
- puts(SEP);
+ GP_DataPrint(GP_DataStorageGet(storage, NULL, "dpi"));
+ GP_DataStorageDestroy(storage);
return 0;
}
diff --git a/demos/c_simple/meta_data.c b/demos/c_simple/meta_data.c
index a2c9a645..2e217818 100644
--- a/demos/c_simple/meta_data.c
+++ b/demos/c_simple/meta_data.c
@@ -16,69 +16,57 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
/*
- Meta-data storage operations example.
-
- Meta-data storage is used to store image meta-data (if present) such as
- physical size, creation date, etc...
-
- Meta-data storage is basically an typed dictionary.
-
- This example shows low-level interface to GP_MetaData structure.
+ Read image meta-data and print them into stdout.
*/
#include <stdio.h>
+#include <string.h>
+#include <errno.h>
#include <GP.h>
-int main(void)
-{
- GP_MetaData *data = GP_MetaDataCreate(10);
+#define SEP +"-----------------------------------------------------------------------------"
- //GP_SetDebugLevel(10);
+int main(int argc, char *argv[])
+{
+ GP_DataStorage *storage;
+ int i;
- if (data == NULL)
+ if (argc < 2) {
+ fprintf(stderr, "Takes an image(s) as parameter(s)n");
return 1;
+ }
- /*
- * Create integer
- *
- * May fail, if there is allready record with id 'dpi' or
- * if there is no space left.
- */
- GP_MetaDataCreateInt(data, "dpi", 300);
-
- /*
- * Create an string.
- *
- * The last parameter says, if the string should be duplicated
- * in the metadata storage.
- */
- GP_MetaDataCreateString(data, "author", "Foo Bar <foo(a)bar.net>", 0, 1);
- GP_MetaDataCreateString(data, "comment", "Created in hurry.", 0, 1);
- GP_MetaDataCreateDouble(data, "pi", 3.141592);
+ storage = GP_DataStorageCreate();
- const char *ret;
+ if (!storage) {
+ fprintf(stderr, "Failed to create data storagen");
+ return 1;
+ }
- ret = GP_MetaDataGetString(data, "comment");
+ for (i = 1; i < argc; i++) {
+ puts(SEP);
+ printf("Opening '%s'n", argv[i]);
- if (ret != NULL)
- printf("Found string 'comment' = '%s'n", ret);
- else
- printf("ERROR: cannot cound string 'comment'n");
+ GP_DataStorageClear(storage);
- printf("n");
+ if (GP_LoadMetaData(argv[i], storage)) {
+ fprintf(stderr, "Failed to read '%s' meta-data: %sn",
+ argv[i], strerror(errno));
+ } else {
+ GP_DataStoragePrint(storage);
+ }
+ }
- /*
- * Print all meta-data
- */
- GP_MetaDataPrint(data);
+ puts(SEP);
return 0;
}
diff --git a/include/loaders/GP_BMP.h b/include/loaders/GP_BMP.h
index 982de158..da388d0b 100644
--- a/include/loaders/GP_BMP.h
+++ b/include/loaders/GP_BMP.h
@@ -25,14 +25,18 @@
#include "loaders/GP_Loader.h"
...e-mail trimmed, has been too large.
1
0