Gfxprim
Threads by month
- ----- 2026 -----
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- 929 discussions
[repo.or.cz] gfxprim.git branch generate updated: 6c56dcd01573c443d0cd512a43a5966aa6edfde8
by gavento 26 May '11
by gavento 26 May '11
26 May '11
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, generate has been updated
via 6c56dcd01573c443d0cd512a43a5966aa6edfde8 (commit)
from 27ea5ba0493ced3a9af7c3d6ee912fe87e78f0e3 (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/6c56dcd01573c443d0cd512a43a5966aa6ed…
commit 6c56dcd01573c443d0cd512a43a5966aa6edfde8
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Thu May 26 22:44:05 2011 +0200
Mid-way restructuring the generating system
Make rules now work for few targets (GP_Pixel.gen.[ch])
diff --git a/gen.mk b/gen.mk
index 28b1bc6..f15aae6 100644
--- a/gen.mk
+++ b/gen.mk
@@ -35,3 +35,10 @@ GENERATORS=$(PYTHON_FILES)
# Generated files depend on python generators and libs
#
%.gen.c %.gen.h: $(GENERATORS)
+ifdef VERBOSE
+ ${PYTHON} ${TOPDIR}/pylib/bin/generate_file.py "$@"
+else
+ @echo "GEN $@"
+ @${PYTHON} ${TOPDIR}/pylib/bin/generate_file.py "$@"
+endif
+
diff --git a/libs/core/Makefile b/libs/core/Makefile
index 989d786..8126e00 100644
--- a/libs/core/Makefile
+++ b/libs/core/Makefile
@@ -8,15 +8,3 @@ include $(TOPDIR)/gen.mk
include $(TOPDIR)/include.mk
include $(TOPDIR)/lib.mk
-$(INCLUDE_PREFIX)GP_Pixel.gen.h GP_Pixel.gen.c: ${GENERATORS}
- ${PYTHON} "${PYLIBSDIR}/gfxprim/core/make_GP_Pixel.py" - "$(INCLUDE_PREFIX)GP_Pixel.gen.h" "GP_Pixel.gen.c"
-
-$(INCLUDE_PREFIX)GP_Blit.gen.h GP_Blit.gen.c: ${GENERATORS}
- ${PYTHON} "${PYLIBSDIR}/gfxprim/core/make_GP_Blit.py" - "$(INCLUDE_PREFIX)GP_Blit.gen.h" "GP_Blit.gen.c"
-
-$(INCLUDE_PREFIX)GP_Pixel_Scale.gen.h: ${GENERATORS}
- ${PYTHON} "${PYLIBSDIR}/gfxprim/core/make_GP_Pixel_Scale.py" - "$(INCLUDE_PREFIX)GP_Pixel_Scale.gen.h"
-
diff --git a/pylib/bin/generate_file.py b/pylib/bin/generate_file.py
index ee56e8f..086f801 100644
--- a/pylib/bin/generate_file.py
+++ b/pylib/bin/generate_file.py
@@ -7,16 +7,19 @@
#
import sys
-from gfxprim import generators.utils, die
+from gfxprim.generators import utils
+from gfxprim import die
usage = """Usage: %s [files_to_generate...]
The files are matched only based on path suffixes, but written to given paths.
"""
-def __main__():
- generators.utils.load_generators()
+def main():
+ utils.load_generators()
if len(sys.argv) <= 1:
die(usage)
for f in sys.argv[1:]:
- generators.utils.generate_file(f)
+ utils.generate_file(f)
+if __name__ == '__main__':
+ main()
diff --git a/pylib/gfxprim/__init__.py b/pylib/gfxprim/__init__.py
index cacbf91..7b3b919 100644
--- a/pylib/gfxprim/__init__.py
+++ b/pylib/gfxprim/__init__.py
@@ -4,8 +4,12 @@
# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
#
+import sys
+
def die(msg):
"Exit(1) with a message."
+ if not msg.endswith('n'):
+ msg += 'n'
sys.stderr.write(msg)
sys.exit(1)
diff --git a/pylib/gfxprim/generators/core/make_GP_Pixel_Scale.py b/pylib/gfxprim/generators/core/make_GP_Pixel_Scale.py
index f864489..77619fa 100644
--- a/pylib/gfxprim/generators/core/make_GP_Pixel_Scale.py
+++ b/pylib/gfxprim/generators/core/make_GP_Pixel_Scale.py
@@ -5,38 +5,38 @@
# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
#
-from gfxprim.genutils import *
-from gfxprim.pixeltype import *
-from gfxprim.genutils import j2render as r
-from gfxprim.core.gen_pixeltype import *
-
-h = []
-c = []
-
-## Headers
-
-gen_headers(h, c,
- descr = "fast value scaling macros",
- authors = ["2011 - Tomas Gavenciak <gavento(a)ucw.cz>"],
- generator = __file__,
- hdef = "GP_PIXEL_SCALEVAL")
-
-h.append(r(
- "/* helper macros to transfer s1-bit value to s2-bit valuen"
- " * NOTE: efficient and accurate for both up- and downscaling,n"
- " * WARNING: GP_SCALE_VAL requires constants numebrs as first two parametersn"
- " */n"
- "#define GP_SCALE_VAL(s1, s2, val) ( GP_SCALE_VAL_##s1##_##s2(val) )nn"
-
- "{% for s1 in [1, 2, 4, 8] %}{% for s2 in [1, 2, 4, 8] %}"
- "{% if s2>s1 %}"
- "#define GP_SCALE_VAL_{{s1}}_{{s2}}(val) ((val) * {{ multcoef(s1, s2) }})n"
- "{% else %}"
- "#define GP_SCALE_VAL_{{s1}}_{{s2}}(val) ((val) >> {{ s1 - s2 }})n"
- "{% endif %}"
- "{% endfor %}{% endfor %}", multcoef = lambda s1,s2: hex(sum([1<<i*s1 for i in range(s2/s1)]))
- ))
-
-if __name__ == '__main__':
- main_write(h, None)
+from gfxprim.generators.generator import *
+#from gfxprim.generators.core.gen_pixeltype import *
+
+@generator(CHeaderGenerator(name = 'GP_Pixel_Scale.gen.h'),
+ descr = 'fast value scaling macros',
+ authors = ["2011 - Tomas Gavenciak <gavento(a)ucw.cz>"])
+def core_GP_Pixel_Scale_gen(h):
+ h.rhead(
+ "/* helper macros to transfer s1-bit value to s2-bit valuen"
+ " * NOTE: efficient and accurate for both up- and downscaling,n"
+ " * WARNING: GP_SCALE_VAL requires constants numebrs as first two parametersn"
+ " */n"
+ "#define GP_SCALE_VAL(s1, s2, val) ( GP_SCALE_VAL_##s1##_##s2(val) )nn"
+
+ "{% for s1 in [1, 2, 4, 8] %}{% for s2 in [1, 2, 4, 8] %}"
+ "{% if s2>s1 %}"
+ "#define GP_SCALE_VAL_{{s1}}_{{s2}}(val) ((val) * {{ multcoef(s1, s2) }})n"
+ "{% else %}"
+ "#define GP_SCALE_VAL_{{s1}}_{{s2}}(val) ((val) >> {{ s1 - s2 }})n"
+ "{% endif %}"
+ "{% endfor %}{% endfor %}", multcoef = lambda s1,s2: hex(sum([1<<i*s1 for i in range(s2/s1)]))
+ )
+
+@generator(CSourceGenerator(name='GP_Pixel.gen.c'),
+ CHeaderGenerator(name='GP_Pixel.gen.h'),
+ descr = 'pixel type definitions and functions',
+ authors = ["2011 - Tomas Gavenciak <gavento(a)ucw.cz>"])
+def core_GP_Pixel_gen(c, h):
+ c.rhead("CCCCCC")
+ h.rhead("HHHHHH")
+
+
+
+
diff --git a/pylib/gfxprim/generators/generator.py b/pylib/gfxprim/generators/generator.py
index e0b4192..df2e8c9 100644
--- a/pylib/gfxprim/generators/generator.py
+++ b/pylib/gfxprim/generators/generator.py
@@ -1,3 +1,4 @@
+#
# Module with templates and tools for writing generated code,
# especially C source and headers
#
@@ -5,9 +6,10 @@
#
import sys, os, time
-import jinja2
+from gfxprim import die
+from gfxprim.generators.utils import j2render
-# List of known CodeGenerator classes
+# List of known CodeGenerator instances
known_generators = []
class CodeGenerator(object):
@@ -16,19 +18,23 @@ class CodeGenerator(object):
"fdir ('') - directory prefix to matchn"
"generating_f (None) - user function called in generate(), should generate contentn"
"register (False) - if true, register in global generator listn"
+ generator_attributes__ = ['generating_f', 'register']
def __init__(self, **kwargs):
- self.fname = kwargs.pop('fname')
- self.fdir = kwargs.pop('fdir', "")
- self.generating_f = kwargs.pop('generating_f', None)
- self.register = kwargs.pop('register', False)
- self.fname_suffix = os.path.join(self.fdir, self.fname)
+ self.name = kwargs.pop('name')
+ self.fdir, self.fname = os.path.split(self.name)
+ self.generating_f = None
+ self.register = False
self.head = []
self.body = []
self.foot = []
- if self.register:
- known_generators.append(self)
+ self.setargs(**kwargs)
+ if kwargs:
+ die('Unknown arguments to CodeGenerator: %s' & str(kwargs.keys()))
+ def setargs(self, **kwargs):
+ for i in self.generator_attributes__:
+ if i in kwargs: self.__setattr__(i, kwargs.pop(i))
def matches_path(self, path):
- return path.endswith(self.fname_suffix)
+ return path.endswith(self.name)
def r(self, s, *args, **kwargs):
return j2render(s, g=self, *args, **kwargs)
def rhead(self, *args, **kwargs):
@@ -43,29 +49,41 @@ class CodeGenerator(object):
self.foot = []
if run_gen_base:
self.gen_base()
- # Run user-specified generation
+ # Run user-specified generation f
if self.generating_f:
- self.generating_f(self)
+ f, pos, params = self.generating_f
+ args = [self if i == pos else global_null_generator for i in range(params)]
+ f(*args)
return ''.join(self.head + self.body + self.foot)
def gen_base(self):
"Fill basic subclass-dependent content into head/body/foot"
pass
+class NullGenerator(CodeGenerator):
+ def rhead(self, *args, **kwargs): pass
+ def rbody(self, *args, **kwargs): pass
+ def rfoot(self, *args, **kwargs): pass
+ def generate(self, *args, **kwargs): return ''
+ def r(self, *args, **kwargs): return ''
+
+global_null_generator = NullGenerator(name='null_generator')
+
class CCodeGenerator(CodeGenerator):
"Args:n"
"authors ([]) - list of author creditsn"
"descr ("") - (multiline) file descriptionn"
+ generator_attributes__ = ['authors', 'descr'] + CodeGenerator.generator_attributes__
def __init__(self, **kwargs):
+ self.authors = []
+ self.descr = ""
super(CCodeGenerator, self).__init__(**kwargs)
- self.authors = kwargs.pop('authors', [])
- self.descr = kwargs.pop('descr', "")
def gen_base(self):
super(CCodeGenerator, self).gen_base()
self.head.append(self.r(
"/*n"
" * {{ g.fname }}n"
" *n"
- " * GENERATED on {{ date }} for suffix "{{ g.fname_suffix }}"n"
+ " * GENERATED on {{ date }} by generator "{{ g.name }}"n"
" * DO NOT MODIFY THIS FILE DIRECTLY!n"
" *n"
"{% if g.descr %}"
@@ -78,22 +96,12 @@ class CCodeGenerator(CodeGenerator):
class CSourceGenerator(CCodeGenerator):
def __init__(self, **kwargs):
- print kwargs
super(CSourceGenerator, self).__init__(**kwargs)
-def c_source_generator(*args, **kwargs):
- "Decorator to create C source generators."
- def decorate(f):
- kwargs['generating_f'] = f
- kwargs['register'] = True
- g = CSourceGenerator(*args, **kwargs)
- return f
- return decorate
-
class CHeaderGenerator(CCodeGenerator):
def __init__(self, **kwargs):
super(CHeaderGenerator, self).__init__(**kwargs)
- self.hdef = 'GP_HEADER_' + self.fname_suffix.replace('.', '_').replace('/', '_').upper()
+ self.hdef = 'GP_HEADER_' + self.name.replace('.', '_').replace('/', '_').upper()
def gen_base(self):
super(CHeaderGenerator, self).gen_base()
self.head.append(self.r(
@@ -102,11 +110,15 @@ class CHeaderGenerator(CCodeGenerator):
self.foot.append(self.r(
"#endif /* {{ g.hdef }} */n"))
-def c_header_generator(*args, **kwargs):
- "Decorator to create C header generators."
+def generator(*args, **kwargs):
+ "Decorate functions to be content-creator for given generators.n"
+ "By default also registers the generator to pool of known generators."
+ register = kwargs.pop('register', True)
def decorate(f):
- kwargs['generating_f'] = f
- kwargs['register'] = True
- g = CHeaderGenerator(*args, **kwargs)
+ for i in range(len(args)):
+ kwargs['generating_f'] = (f, i, len(args))
+ args[i].setargs(**kwargs)
+ if register:
+ known_generators.append(args[i])
return f
return decorate
diff --git a/pylib/gfxprim/generators/utils.py b/pylib/gfxprim/generators/utils.py
index ee388f9..cd12e5e 100644
--- a/pylib/gfxprim/generators/utils.py
+++ b/pylib/gfxprim/generators/utils.py
@@ -6,14 +6,21 @@
import sys, os, time
import jinja2
-from gfxprim.generators.generator import known_generators
+from gfxprim import die
+
+def j2render(tmpl, **kw):
+ "Internal helper to render jinja2 templates (with StrictUndefined)"
+ t2 = tmpl.rstrip('n') # Jinja strips the last 'n', so add these later
+ return jinja2.Template(t2, undefined=jinja2.StrictUndefined).render(**kw) + tmpl[len(t2):]
def load_generators():
"Load all modules containig generators to allow them to register"
- # TODO: write
+ # TODO: write proper discovery
+ import gfxprim.generators.core.make_GP_Pixel_Scale
pass
def generate_file(fname):
+ from gfxprim.generators.generator import known_generators
"Function trying to generate file `fname` using matching known generator."
matches = []
for k in known_generators:
@@ -27,8 +34,4 @@ def generate_file(fname):
with open(fname, "wt") as f:
f.write(s)
-def j2render(tmpl, **kw):
- "Internal helper to render jinja2 templates (with StrictUndefined)"
- t2 = tmpl.rstrip('n') # Jinja strips the last 'n', so add these later
- return jinja2.Template(t2, undefined=jinja2.StrictUndefined).render(**kw) + tmpl[len(t2):]
-----------------------------------------------------------------------
Summary of changes:
gen.mk | 7 ++
libs/core/Makefile | 12 ---
pylib/bin/generate_file.py | 11 ++-
pylib/gfxprim/__init__.py | 4 +
.../gfxprim/generators/core/make_GP_Pixel_Scale.py | 68 +++++++++---------
pylib/gfxprim/generators/generator.py | 74 +++++++++++--------
pylib/gfxprim/generators/utils.py | 15 +++--
7 files changed, 104 insertions(+), 87 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: 27ea5ba0493ced3a9af7c3d6ee912fe87e78f0e3
by gavento 26 May '11
by gavento 26 May '11
26 May '11
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, generate has been updated
via 27ea5ba0493ced3a9af7c3d6ee912fe87e78f0e3 (commit)
via cce65abc35040e3a3473f476b7d8ca0902f8fbf2 (commit)
via 01dcdb50122a43d5a26690c470c9fce2dc80046a (commit)
via bc3e7e202aaedf55738f151b598ffc10161881c5 (commit)
via af6444d674affcc352f05e1616ad2b6fa4a5dfe8 (commit)
via 7f6bea085c6d5bdcef77c514eb41a96aac13e6d1 (commit)
via db5988548d394fcf94da3d66ff85c40afd719fc1 (commit)
via 665128da4ce856b78beece7af486c561a0a84f58 (commit)
from 5e1cf45920d28673d7e1245b9709b65c1724084d (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/27ea5ba0493ced3a9af7c3d6ee912fe87e78…
commit 27ea5ba0493ced3a9af7c3d6ee912fe87e78f0e3
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Thu May 26 01:44:23 2011 +0200
New generating arch, cont. (incl makefiles)
diff --git a/gen.mk b/gen.mk
index 926fd57..28b1bc6 100644
--- a/gen.mk
+++ b/gen.mk
@@ -6,12 +6,6 @@ $(error LIBNAME not defined, fix your library Makefile)
endif
#
-# All potential dependencies for generated files
-#
-GENERATORS=$(shell find ${PYLIBSDIR} -name *.py)
-CLEAN+=$(patsubst, %.py, %.pyc, ${GENERATORS})
-
-#
# Headers goes into include/core/
#
INCLUDE_PREFIX=$(TOPDIR)/include/$(LIBNAME)/
@@ -23,7 +17,7 @@ RGENHEADERS=$(addprefix $(INCLUDE_PREFIX),$(GENHEADERS))
CSOURCES+=$(GENSOURCES)
#
-# Make the targets build actually
+# Make the genrated headers actually build
#
all: $(RGENHEADERS)
@@ -31,3 +25,13 @@ all: $(RGENHEADERS)
# And clean them
#
CLEAN+=$(GENSOURCES) $(RGENHEADERS)
+
+#
+# Currently, just depend on all python files
+#
+GENERATORS=$(PYTHON_FILES)
+
+#
+# Generated files depend on python generators and libs
+#
+%.gen.c %.gen.h: $(GENERATORS)
diff --git a/include.mk b/include.mk
index 68fab64..ada1072 100644
--- a/include.mk
+++ b/include.mk
@@ -32,6 +32,13 @@ COMPILE=yes
endif
#
+# Potential python dependencies for generated files and scripts
+# Add .pyc files to CLEAN list
+#
+PYTHON_FILES=$(shell find "${PYLIBSDIR}" -name *.py)
+CLEAN+=$(patsubst, %.py, %.pyc, ${})
+
+#
# 1. Generate and include dependencies for all C sources
# 2. Generate OBJECTS list from CSOURCES list
# 3. Adds OBJECTS to CLEAN list
diff --git a/pylib/bin/generate_file.py b/pylib/bin/generate_file.py
new file mode 100644
index 0000000..ee56e8f
--- /dev/null
+++ b/pylib/bin/generate_file.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+#
+# Main source file generating script
+# Collects all known file generators from the generators/ directory
+#
+# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
+#
+
+import sys
+from gfxprim import generators.utils, die
+
+usage = """Usage: %s [files_to_generate...]
+The files are matched only based on path suffixes, but written to given paths.
+"""
+
+def __main__():
+ generators.utils.load_generators()
+ if len(sys.argv) <= 1:
+ die(usage)
+ for f in sys.argv[1:]:
+ generators.utils.generate_file(f)
+
diff --git a/pylib/gfxprim/generators/__init__.py b/pylib/gfxprim/generators/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pylib/gfxprim/generators/utils.py b/pylib/gfxprim/generators/generator.py
similarity index 73%
copy from pylib/gfxprim/generators/utils.py
copy to pylib/gfxprim/generators/generator.py
index 6cc2ddd..e0b4192 100644
--- a/pylib/gfxprim/generators/utils.py
+++ b/pylib/gfxprim/generators/generator.py
@@ -4,54 +4,12 @@
# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
#
-import sys, os
+import sys, os, time
import jinja2
# List of known CodeGenerator classes
known_generators = []
-def generate_file(fname):
- "Function trying to generate file `fname` using matching known generator."
- matches = []
- for k in known_generators:
- if k.matches(fname):
- matches.append(k)
- if len(matches) == 0:
- die("No known generators match '%s'" % (fname,))
- if len(matches) > 1:
- die("Multiple generators match '%s': %s" % (fname, str(matches)))
- s = matches[0].generate()
- with open(fname, "wt") as f:
- f.write(s)
-
-def j2render(tmpl, **kw):
- "Internal helper to render jinja2 templates (with StrictUndefined)"
- t2 = tmpl.rstrip('n') # Jinja strips the last 'n', so add these later
- return jinja2.Template(t2, undefined=jinja2.StrictUndefined).render(**kw) + tmpl[len(t2):]
-
-#def hmask(bits):
-# "Helper returning hex mask for that many bits"
-# "WARN: may contain 'L'"
-# return hex((1<<bits)-1)
-
-def c_source_generator(*args, **kwargs):
- "Decorator to create C source generators."
- def decorate(f):
- kwargs['generating_f'] = f
- kwargs['register'] = True
- g = CSourceGenerator(*args, **kwargs)
- return f
- return decorate
-
-def c_header_generator(*args, **kwargs):
- "Decorator to create C header generators."
- def decorate(f):
- kwargs['generating_f'] = f
- kwargs['register'] = True
- g = CHeaderGenerator(*args, **kwargs)
- return f
-return decorate
-
class CodeGenerator(object):
"Args:n"
"fname (required) - name of the generated file (without path)n"
@@ -101,29 +59,37 @@ class CCodeGenerator(CodeGenerator):
super(CCodeGenerator, self).__init__(**kwargs)
self.authors = kwargs.pop('authors', [])
self.descr = kwargs.pop('descr', "")
- self.descr_star_lines = ''.join([(' * ' + i + 'n')
- for i in self.descr.split('n')])
def gen_base(self):
super(CCodeGenerator, self).gen_base()
self.head.append(self.r(
"/*n"
- " * GENERATED SOURCE {{ g.fname }}n"
- " * DO NOT MODIFY THIS FILE DIRECTLY! *n"
+ " * {{ g.fname }}n"
" *n"
- " * generated for filename suffix '{{ g.fname_suffix }}'n"
- " *n"
- "{{ g.descr_star_lines }}"
+ " * GENERATED on {{ date }} for suffix "{{ g.fname_suffix }}"n"
+ " * DO NOT MODIFY THIS FILE DIRECTLY!n"
" *n"
+ "{% if g.descr %}"
+ " * {{ g.descr }}n *n"
+ "{% endif %}"
"{% for a in g.authors %}"
- " * {{ a }}n"
+ " * {{ a }}n"
"{% endfor %}"
- " */nn"))
+ " */nn", date = time.ctime()))
class CSourceGenerator(CCodeGenerator):
def __init__(self, **kwargs):
print kwargs
super(CSourceGenerator, self).__init__(**kwargs)
+def c_source_generator(*args, **kwargs):
+ "Decorator to create C source generators."
+ def decorate(f):
+ kwargs['generating_f'] = f
+ kwargs['register'] = True
+ g = CSourceGenerator(*args, **kwargs)
+ return f
+ return decorate
+
class CHeaderGenerator(CCodeGenerator):
def __init__(self, **kwargs):
super(CHeaderGenerator, self).__init__(**kwargs)
@@ -136,4 +102,11 @@ class CHeaderGenerator(CCodeGenerator):
self.foot.append(self.r(
"#endif /* {{ g.hdef }} */n"))
-
+def c_header_generator(*args, **kwargs):
+ "Decorator to create C header generators."
+ def decorate(f):
+ kwargs['generating_f'] = f
+ kwargs['register'] = True
+ g = CHeaderGenerator(*args, **kwargs)
+ return f
+ return decorate
diff --git a/pylib/gfxprim/generators/utils.py b/pylib/gfxprim/generators/utils.py
index 6cc2ddd..ee388f9 100644
--- a/pylib/gfxprim/generators/utils.py
+++ b/pylib/gfxprim/generators/utils.py
@@ -4,17 +4,20 @@
# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
#
-import sys, os
+import sys, os, time
import jinja2
+from gfxprim.generators.generator import known_generators
-# List of known CodeGenerator classes
-known_generators = []
+def load_generators():
+ "Load all modules containig generators to allow them to register"
+ # TODO: write
+ pass
def generate_file(fname):
"Function trying to generate file `fname` using matching known generator."
matches = []
for k in known_generators:
- if k.matches(fname):
+ if k.matches_path(fname):
matches.append(k)
if len(matches) == 0:
die("No known generators match '%s'" % (fname,))
@@ -29,111 +32,3 @@ def j2render(tmpl, **kw):
t2 = tmpl.rstrip('n') # Jinja strips the last 'n', so add these later
return jinja2.Template(t2, undefined=jinja2.StrictUndefined).render(**kw) + tmpl[len(t2):]
-#def hmask(bits):
-# "Helper returning hex mask for that many bits"
-# "WARN: may contain 'L'"
-# return hex((1<<bits)-1)
-
-def c_source_generator(*args, **kwargs):
- "Decorator to create C source generators."
- def decorate(f):
- kwargs['generating_f'] = f
- kwargs['register'] = True
- g = CSourceGenerator(*args, **kwargs)
- return f
- return decorate
-
-def c_header_generator(*args, **kwargs):
- "Decorator to create C header generators."
- def decorate(f):
- kwargs['generating_f'] = f
- kwargs['register'] = True
- g = CHeaderGenerator(*args, **kwargs)
- return f
-return decorate
-
-class CodeGenerator(object):
- "Args:n"
- "fname (required) - name of the generated file (without path)n"
- "fdir ('') - directory prefix to matchn"
- "generating_f (None) - user function called in generate(), should generate contentn"
- "register (False) - if true, register in global generator listn"
- def __init__(self, **kwargs):
- self.fname = kwargs.pop('fname')
- self.fdir = kwargs.pop('fdir', "")
- self.generating_f = kwargs.pop('generating_f', None)
- self.register = kwargs.pop('register', False)
- self.fname_suffix = os.path.join(self.fdir, self.fname)
- self.head = []
- self.body = []
- self.foot = []
- if self.register:
- known_generators.append(self)
- def matches_path(self, path):
- return path.endswith(self.fname_suffix)
- def r(self, s, *args, **kwargs):
- return j2render(s, g=self, *args, **kwargs)
- def rhead(self, *args, **kwargs):
- self.head.append(self.r(*args, **kwargs))
- def rbody(self, *args, **kwargs):
- self.body.append(self.r(*args, **kwargs))
- def rfoot(self, *args, **kwargs):
- self.foot.append(self.r(*args, **kwargs))
- def generate(self, run_gen_base=True):
- self.head = []
- self.body = []
- self.foot = []
- if run_gen_base:
- self.gen_base()
- # Run user-specified generation
- if self.generating_f:
- self.generating_f(self)
- return ''.join(self.head + self.body + self.foot)
- def gen_base(self):
- "Fill basic subclass-dependent content into head/body/foot"
- pass
-
-class CCodeGenerator(CodeGenerator):
- "Args:n"
- "authors ([]) - list of author creditsn"
- "descr ("") - (multiline) file descriptionn"
- def __init__(self, **kwargs):
- super(CCodeGenerator, self).__init__(**kwargs)
- self.authors = kwargs.pop('authors', [])
- self.descr = kwargs.pop('descr', "")
- self.descr_star_lines = ''.join([(' * ' + i + 'n')
- for i in self.descr.split('n')])
- def gen_base(self):
- super(CCodeGenerator, self).gen_base()
- self.head.append(self.r(
- "/*n"
- " * GENERATED SOURCE {{ g.fname }}n"
- " * DO NOT MODIFY THIS FILE DIRECTLY! *n"
- " *n"
- " * generated for filename suffix '{{ g.fname_suffix }}'n"
- " *n"
- "{{ g.descr_star_lines }}"
- " *n"
- "{% for a in g.authors %}"
- " * {{ a }}n"
- "{% endfor %}"
- " */nn"))
-
-class CSourceGenerator(CCodeGenerator):
- def __init__(self, **kwargs):
- print kwargs
- super(CSourceGenerator, self).__init__(**kwargs)
-
-class CHeaderGenerator(CCodeGenerator):
- def __init__(self, **kwargs):
- super(CHeaderGenerator, self).__init__(**kwargs)
- self.hdef = 'GP_HEADER_' + self.fname_suffix.replace('.', '_').replace('/', '_').upper()
- def gen_base(self):
- super(CHeaderGenerator, self).gen_base()
- self.head.append(self.r(
- "#ifndef {{ g.hdef }}n"
- "#define {{ g.hdef }}nn"))
- self.foot.append(self.r(
- "#endif /* {{ g.hdef }} */n"))
-
-
http://repo.or.cz/w/gfxprim.git/commit/cce65abc35040e3a3473f476b7d8ca0902f8…
commit cce65abc35040e3a3473f476b7d8ca0902f8fbf2
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Thu May 26 01:24:14 2011 +0200
Mid-transposition to cleaner generating infratructure
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/generators/core/__init__.py
similarity index 100%
rename from pylib/gfxprim/core/__init__.py
rename to pylib/gfxprim/generators/core/__init__.py
diff --git a/pylib/gfxprim/core/gen_blit.py b/pylib/gfxprim/generators/core/gen_blit.py
similarity index 100%
rename from pylib/gfxprim/core/gen_blit.py
rename to pylib/gfxprim/generators/core/gen_blit.py
diff --git a/pylib/gfxprim/core/gen_pixeltype.py b/pylib/gfxprim/generators/core/gen_pixeltype.py
similarity index 100%
rename from pylib/gfxprim/core/gen_pixeltype.py
rename to pylib/gfxprim/generators/core/gen_pixeltype.py
diff --git a/pylib/gfxprim/core/make_GP_Blit.py b/pylib/gfxprim/generators/core/make_GP_Blit.py
similarity index 100%
rename from pylib/gfxprim/core/make_GP_Blit.py
rename to pylib/gfxprim/generators/core/make_GP_Blit.py
diff --git a/pylib/gfxprim/core/make_GP_Pixel.py b/pylib/gfxprim/generators/core/make_GP_Pixel.py
similarity index 100%
rename from pylib/gfxprim/core/make_GP_Pixel.py
rename to pylib/gfxprim/generators/core/make_GP_Pixel.py
diff --git a/pylib/gfxprim/core/make_GP_Pixel_Scale.py b/pylib/gfxprim/generators/core/make_GP_Pixel_Scale.py
similarity index 100%
rename from pylib/gfxprim/core/make_GP_Pixel_Scale.py
rename to pylib/gfxprim/generators/core/make_GP_Pixel_Scale.py
diff --git a/pylib/gfxprim/pixeltype.py b/pylib/gfxprim/generators/pixeltype.py
similarity index 100%
rename from pylib/gfxprim/pixeltype.py
rename to pylib/gfxprim/generators/pixeltype.py
diff --git a/pylib/gfxprim/generators/utils.py b/pylib/gfxprim/generators/utils.py
new file mode 100644
index 0000000..6cc2ddd
--- /dev/null
+++ b/pylib/gfxprim/generators/utils.py
@@ -0,0 +1,139 @@
+# Module with templates and tools for writing generated code,
+# especially C source and headers
+#
+# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
+#
+
+import sys, os
+import jinja2
+
+# List of known CodeGenerator classes
+known_generators = []
+
+def generate_file(fname):
+ "Function trying to generate file `fname` using matching known generator."
+ matches = []
+ for k in known_generators:
+ if k.matches(fname):
+ matches.append(k)
+ if len(matches) == 0:
+ die("No known generators match '%s'" % (fname,))
+ if len(matches) > 1:
+ die("Multiple generators match '%s': %s" % (fname, str(matches)))
+ s = matches[0].generate()
+ with open(fname, "wt") as f:
+ f.write(s)
+
+def j2render(tmpl, **kw):
+ "Internal helper to render jinja2 templates (with StrictUndefined)"
+ t2 = tmpl.rstrip('n') # Jinja strips the last 'n', so add these later
+ return jinja2.Template(t2, undefined=jinja2.StrictUndefined).render(**kw) + tmpl[len(t2):]
+
+#def hmask(bits):
+# "Helper returning hex mask for that many bits"
+# "WARN: may contain 'L'"
+# return hex((1<<bits)-1)
+
+def c_source_generator(*args, **kwargs):
+ "Decorator to create C source generators."
+ def decorate(f):
+ kwargs['generating_f'] = f
+ kwargs['register'] = True
+ g = CSourceGenerator(*args, **kwargs)
+ return f
+ return decorate
+
+def c_header_generator(*args, **kwargs):
+ "Decorator to create C header generators."
+ def decorate(f):
+ kwargs['generating_f'] = f
+ kwargs['register'] = True
+ g = CHeaderGenerator(*args, **kwargs)
+ return f
+return decorate
+
+class CodeGenerator(object):
+ "Args:n"
+ "fname (required) - name of the generated file (without path)n"
+ "fdir ('') - directory prefix to matchn"
+ "generating_f (None) - user function called in generate(), should generate contentn"
+ "register (False) - if true, register in global generator listn"
+ def __init__(self, **kwargs):
+ self.fname = kwargs.pop('fname')
+ self.fdir = kwargs.pop('fdir', "")
+ self.generating_f = kwargs.pop('generating_f', None)
+ self.register = kwargs.pop('register', False)
+ self.fname_suffix = os.path.join(self.fdir, self.fname)
+ self.head = []
+ self.body = []
+ self.foot = []
+ if self.register:
+ known_generators.append(self)
+ def matches_path(self, path):
+ return path.endswith(self.fname_suffix)
+ def r(self, s, *args, **kwargs):
+ return j2render(s, g=self, *args, **kwargs)
+ def rhead(self, *args, **kwargs):
+ self.head.append(self.r(*args, **kwargs))
+ def rbody(self, *args, **kwargs):
+ self.body.append(self.r(*args, **kwargs))
+ def rfoot(self, *args, **kwargs):
+ self.foot.append(self.r(*args, **kwargs))
+ def generate(self, run_gen_base=True):
+ self.head = []
+ self.body = []
+ self.foot = []
+ if run_gen_base:
+ self.gen_base()
+ # Run user-specified generation
+ if self.generating_f:
+ self.generating_f(self)
+ return ''.join(self.head + self.body + self.foot)
+ def gen_base(self):
+ "Fill basic subclass-dependent content into head/body/foot"
+ pass
+
+class CCodeGenerator(CodeGenerator):
+ "Args:n"
+ "authors ([]) - list of author creditsn"
+ "descr ("") - (multiline) file descriptionn"
+ def __init__(self, **kwargs):
+ super(CCodeGenerator, self).__init__(**kwargs)
+ self.authors = kwargs.pop('authors', [])
+ self.descr = kwargs.pop('descr', "")
+ self.descr_star_lines = ''.join([(' * ' + i + 'n')
+ for i in self.descr.split('n')])
+ def gen_base(self):
+ super(CCodeGenerator, self).gen_base()
+ self.head.append(self.r(
+ "/*n"
+ " * GENERATED SOURCE {{ g.fname }}n"
+ " * DO NOT MODIFY THIS FILE DIRECTLY! *n"
+ " *n"
+ " * generated for filename suffix '{{ g.fname_suffix }}'n"
+ " *n"
+ "{{ g.descr_star_lines }}"
+ " *n"
+ "{% for a in g.authors %}"
+ " * {{ a }}n"
+ "{% endfor %}"
+ " */nn"))
+
+class CSourceGenerator(CCodeGenerator):
+ def __init__(self, **kwargs):
+ print kwargs
+ super(CSourceGenerator, self).__init__(**kwargs)
+
+class CHeaderGenerator(CCodeGenerator):
+ def __init__(self, **kwargs):
+ super(CHeaderGenerator, self).__init__(**kwargs)
+ self.hdef = 'GP_HEADER_' + self.fname_suffix.replace('.', '_').replace('/', '_').upper()
+ def gen_base(self):
+ super(CHeaderGenerator, self).gen_base()
+ self.head.append(self.r(
+ "#ifndef {{ g.hdef }}n"
+ "#define {{ g.hdef }}nn"))
+ self.foot.append(self.r(
+ "#endif /* {{ g.hdef }} */n"))
+
+
diff --git a/pylib/gfxprim/genutils.py b/pylib/gfxprim/genutils.py
deleted file mode 100644
index 281518b..0000000
--- a/pylib/gfxprim/genutils.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# Module with utils for writing C source and headers
-# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
-
-import sys
-import jinja2
-import gfxprim
-from gfxprim import die
-
-def hmask(bits):
- "Helper returning hex mask for that many bits"
- "WARN: may contain 'L'"
- return hex((1<<bits)-1)
-
-
-def j2render(tmpl, **kw):
- "Internal helper to render jinja2 templates (with StrictUndefined)"
- t2 = tmpl.rstrip('n') # Jinja strips the last 'n', so add these later
- return jinja2.Template(t2, undefined=jinja2.StrictUndefined).render(**kw) + tmpl[len(t2):]
-
-
-def gen_headers(header, code, descr, authors, generator, hdef):
- "Generate header- and source-file headers"
- "TODO - add license"
- header.append(j2render(
- "/* GENERATED header -- {{ descr }}n"
- " * DO NOT MODIFY THIS FILE DIRECTLY! *n"
- " *n"
- " * generator: {{ generator }}n"
- "{% for a in authors %}"
- " * {{ a }}n"
- "{% endfor %}"
- " */nn"
- "#ifndef {{ hdef }}n"
- "#define {{ hdef }}nn", descr=descr, authors=authors,
- generator=generator, hdef=hdef))
- code.append(j2render(
- "/* GENERATED header -- {{ descr }}n"
- " * DO NOT MODIFY THIS FILE DIRECTLY! *n"
- " *n"
- " * generator: {{ generator }}n"
- "{% for a in authors %}"
- " * {{ a }}n"
- "{% endfor %}"
- " */nn", descr=descr, authors=authors,
- generator=generator))
-
-
-def gen_footers(header, code):
- "Generate header-file footer"
- header.append("#endif /* Header file #include guard */n")
-
-
-def main_write(*files):
- "Helper writing files to argv[1:], "
- "usually header to argv[1] and code to argv[2].n"
- "Skips writing header resp. code if set to None"
- "Expects as many argv params as not-None arguments"
- if len(sys.argv) != len(files) + 1:
- die("Generator expects %d parameters (output file names).n" % len(files))
- for i in range(len(files)):
- p = files[i]
- fname = sys.argv[i+1]
- sys.stderr.write("Writing generated source to " + fname + "n")
- f = open(fname, "wt")
- f.write('n'.join(p))
- f.close()
-
http://repo.or.cz/w/gfxprim.git/commit/01dcdb50122a43d5a26690c470c9fce2dc80…
commit 01dcdb50122a43d5a26690c470c9fce2dc80046a
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Wed May 25 23:15:06 2011 +0200
Restructure generating system for new build system
diff --git a/config.mk b/config.mk
index 6653c55..d9a784d 100644
--- a/config.mk
+++ b/config.mk
@@ -1,3 +1,9 @@
CFLAGS+=-W -Wall -Wextra -fPIC -ggdb -O2 -std=gnu99
CFLAGS+=-I$(TOPDIR)/include/
LDLIBS+=-ldl
+
+# path to local module directory
+PYLIBSDIR=$(TOPDIR)/pylib
+
+# Command to run Python with pylib/ modules
+PYTHON=PYTHONPATH=$$PYTHONPATH:${PYLIBSDIR} python
diff --git a/gen.mk b/gen.mk
index 56803bc..926fd57 100644
--- a/gen.mk
+++ b/gen.mk
@@ -6,6 +6,12 @@ $(error LIBNAME not defined, fix your library Makefile)
endif
#
+# All potential dependencies for generated files
+#
+GENERATORS=$(shell find ${PYLIBSDIR} -name *.py)
+CLEAN+=$(patsubst, %.py, %.pyc, ${GENERATORS})
+
+#
# Headers goes into include/core/
#
INCLUDE_PREFIX=$(TOPDIR)/include/$(LIBNAME)/
diff --git a/libs/core/Makefile b/libs/core/Makefile
index 0ef2e5b..989d786 100644
--- a/libs/core/Makefile
+++ b/libs/core/Makefile
@@ -1,6 +1,6 @@
TOPDIR=../..
-GENSOURCES=GP_Pixel.gen.c
-GENHEADERS=GP_Pixel.gen.h
+GENSOURCES=GP_Pixel.gen.c GP_Blit.gen.c
+GENHEADERS=GP_Pixel_Scale.gen.h GP_Blit.gen.h GP_Pixel.gen.h
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
LIBNAME=core
@@ -8,5 +8,15 @@ include $(TOPDIR)/gen.mk
include $(TOPDIR)/include.mk
include $(TOPDIR)/lib.mk
-GP_Pixel.gen.c $(INCLUDE_PREFIX)GP_Pixel.gen.h: gen/make_GP_Pixel.py
- python gen/make_GP_Pixel.py $(INCLUDE_PREFIX)GP_Pixel.gen.h GP_Pixel.gen.c
+$(INCLUDE_PREFIX)GP_Pixel.gen.h GP_Pixel.gen.c: ${GENERATORS}
+ ${PYTHON} "${PYLIBSDIR}/gfxprim/core/make_GP_Pixel.py" + "$(INCLUDE_PREFIX)GP_Pixel.gen.h" "GP_Pixel.gen.c"
+
+$(INCLUDE_PREFIX)GP_Blit.gen.h GP_Blit.gen.c: ${GENERATORS}
+ ${PYTHON} "${PYLIBSDIR}/gfxprim/core/make_GP_Blit.py" + "$(INCLUDE_PREFIX)GP_Blit.gen.h" "GP_Blit.gen.c"
+
+$(INCLUDE_PREFIX)GP_Pixel_Scale.gen.h: ${GENERATORS}
+ ${PYTHON} "${PYLIBSDIR}/gfxprim/core/make_GP_Pixel_Scale.py" + "$(INCLUDE_PREFIX)GP_Pixel_Scale.gen.h"
+
diff --git a/libs/core/gen/README b/pylib/gfxprim/README
similarity index 100%
rename from libs/core/gen/README
rename to pylib/gfxprim/README
diff --git a/pylib/gfxprim/__init__.py b/pylib/gfxprim/__init__.py
new file mode 100644
index 0000000..cacbf91
--- /dev/null
+++ b/pylib/gfxprim/__init__.py
@@ -0,0 +1,12 @@
+# GfxPrim auxiliary libraries
+# Contains C code-generation
+#
+# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
+#
+
+def die(msg):
+ "Exit(1) with a message."
+ sys.stderr.write(msg)
+ sys.exit(1)
+
+
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/libs/core/gen/gen_blit.py b/pylib/gfxprim/core/gen_blit.py
similarity index 99%
rename from libs/core/gen/gen_blit.py
rename to pylib/gfxprim/core/gen_blit.py
index 519bfb2..26fd3f7 100644
--- a/libs/core/gen/gen_blit.py
+++ b/pylib/gfxprim/core/gen_blit.py
@@ -2,7 +2,7 @@
# - submodule for blit and friends
# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
-from gen_utils import *
+from gfxprim.gen_utils import *
## all generated direct blits, for generating GP_Blit() and others
generated_blits = []
diff --git a/libs/core/gen/gen_pixeltype.py b/pylib/gfxprim/core/gen_pixeltype.py
similarity index 98%
rename from libs/core/gen/gen_pixeltype.py
rename to pylib/gfxprim/core/gen_pixeltype.py
index 683fe87..bfde4f2 100644
--- a/libs/core/gen/gen_pixeltype.py
+++ b/pylib/gfxprim/core/gen_pixeltype.py
@@ -7,8 +7,9 @@ Such functions accept (and then extend) two list of strins.
These should be later joined with "" or "
".
"""
-from pixeltype import pixeltypes, channels
-from gen_utils import *
+from gfxprim.pixeltype import pixeltypes, channels
+from gfxprim.genutils import *
+from gfxprim.genutils import j2render as r
def str_start(ptype):
diff --git a/libs/core/gen/make_GP_Blit.py b/pylib/gfxprim/core/make_GP_Blit.py
similarity index 84%
rename from libs/core/gen/make_GP_Blit.py
rename to pylib/gfxprim/core/make_GP_Blit.py
index 9d103ac..cda0e33 100644
--- a/libs/core/gen/make_GP_Blit.py
+++ b/pylib/gfxprim/core/make_GP_Blit.py
@@ -1,11 +1,14 @@
#!/usr/bin/python
+#
# Script generating GP_Pixel_Blit.gen.c and GP_Pixel_Blit.gen.h
+#
# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
+#
-from pixeltype import *
-from gen_blit import *
-from gen_utils import *
-import defs
+from gfxprim.genutils import *
+from gfxprim.pixeltype import *
+from gfxprim.genutils import j2render as r
+from gfxprim.core.gen_pixeltype import *
h = []
c = []
diff --git a/libs/core/gen/make_GP_Pixel.py b/pylib/gfxprim/core/make_GP_Pixel.py
similarity index 89%
rename from libs/core/gen/make_GP_Pixel.py
rename to pylib/gfxprim/core/make_GP_Pixel.py
index a0be576..e8f9f9a 100644
--- a/libs/core/gen/make_GP_Pixel.py
+++ b/pylib/gfxprim/core/make_GP_Pixel.py
@@ -1,11 +1,14 @@
#!/usr/bin/python
+#
# Script generating GP_Pixel.gen.c and GP_Pixel.gen.h
+#
# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
+#
-from pixeltype import *
-from gen_utils import *
-from gen_pixeltype import *
-import defs
+from gfxprim.genutils import *
+from gfxprim.pixeltype import *
+from gfxprim.genutils import j2render as r
+from gfxprim.core.gen_pixeltype import *
h = []
c = []
diff --git a/libs/core/gen/make_GP_Pixel_Scale.py b/pylib/gfxprim/core/make_GP_Pixel_Scale.py
similarity index 87%
rename from libs/core/gen/make_GP_Pixel_Scale.py
rename to pylib/gfxprim/core/make_GP_Pixel_Scale.py
index 13a63a2..f864489 100644
--- a/libs/core/gen/make_GP_Pixel_Scale.py
+++ b/pylib/gfxprim/core/make_GP_Pixel_Scale.py
@@ -1,11 +1,14 @@
-
#!/usr/bin/python
+#
# Script generating GP_Pixel.gen.c and GP_Pixel.gen.h
+#
# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
+#
-from pixeltype import *
-from gen_utils import *
-import defs
+from gfxprim.genutils import *
+from gfxprim.pixeltype import *
+from gfxprim.genutils import j2render as r
+from gfxprim.core.gen_pixeltype import *
h = []
c = []
diff --git a/libs/core/gen/gen_utils.py b/pylib/gfxprim/genutils.py
similarity index 75%
rename from libs/core/gen/gen_utils.py
rename to pylib/gfxprim/genutils.py
index 547b06d..281518b 100644
--- a/libs/core/gen/gen_utils.py
+++ b/pylib/gfxprim/genutils.py
@@ -3,11 +3,8 @@
import sys
import jinja2
-
-def die(msg):
- sys.stderr.write(msg)
- sys.exit(1)
-
+import gfxprim
+from gfxprim import die
def hmask(bits):
"Helper returning hex mask for that many bits"
@@ -15,7 +12,7 @@ def hmask(bits):
return hex((1<<bits)-1)
-def r(tmpl, **kw):
+def j2render(tmpl, **kw):
"Internal helper to render jinja2 templates (with StrictUndefined)"
t2 = tmpl.rstrip('n') # Jinja strips the last 'n', so add these later
return jinja2.Template(t2, undefined=jinja2.StrictUndefined).render(**kw) + tmpl[len(t2):]
@@ -24,7 +21,7 @@ def r(tmpl, **kw):
def gen_headers(header, code, descr, authors, generator, hdef):
"Generate header- and source-file headers"
"TODO - add license"
- header.append(r(
+ header.append(j2render(
"/* GENERATED header -- {{ descr }}n"
" * DO NOT MODIFY THIS FILE DIRECTLY! *n"
" *n"
@@ -36,7 +33,7 @@ def gen_headers(header, code, descr, authors, generator, hdef):
"#ifndef {{ hdef }}n"
"#define {{ hdef }}nn", descr=descr, authors=authors,
generator=generator, hdef=hdef))
- code.append(r(
+ code.append(j2render(
"/* GENERATED header -- {{ descr }}n"
" * DO NOT MODIFY THIS FILE DIRECTLY! *n"
" *n"
@@ -53,21 +50,17 @@ def gen_footers(header, code):
header.append("#endif /* Header file #include guard */n")
-#import pprint
-def main_write(header, code):
- "Helper writing header to argv[1] and code to argv[2]"
+def main_write(*files):
+ "Helper writing files to argv[1:], "
+ "usually header to argv[1] and code to argv[2].n"
"Skips writing header resp. code if set to None"
"Expects as many argv params as not-None arguments"
-
- # Some after-midnight functional crazines:
- proc = [a for a in [header, code] if a is not None]
- if len(sys.argv) != len(proc) + 1:
- die("Generator expects %d parameters (output file names).n" % len(proc))
- for i in range(len(proc)):
- p = proc[i]
+ if len(sys.argv) != len(files) + 1:
+ die("Generator expects %d parameters (output file names).n" % len(files))
+ for i in range(len(files)):
+ p = files[i]
fname = sys.argv[i+1]
- sys.stderr.write("Writing GP_Pixel generated " + ("header" if p==header else "source") +
- " to " + fname + "n")
+ sys.stderr.write("Writing generated source to " + fname + "n")
f = open(fname, "wt")
f.write('n'.join(p))
f.close()
diff --git a/libs/core/gen/pixeltype.py b/pylib/gfxprim/pixeltype.py
similarity index 72%
rename from libs/core/gen/pixeltype.py
rename to pylib/gfxprim/pixeltype.py
index 3e85dfe..7c4248d 100644
--- a/libs/core/gen/pixeltype.py
+++ b/pylib/gfxprim/pixeltype.py
@@ -10,8 +10,9 @@
# bitwidth
# name
-import re
-
+import re, os, sys
+import gfxprim
+from gfxprim import die
## *Global* dictionary of all pixeltypes { name : PixelType }
pixeltypes = {}
@@ -90,5 +91,28 @@ class PixelType(object):
def __str__(self):
return "<PixelType " + self.name + ">"
-if 0 not in pixeltypes:
- PixelType("UNKNOWN", 0, [], bit_endian=bit_endians[0], number=0)
+def load_pixeltypes(defs_file = None):
+ "Initialize pixeltypes by loading the defs file.n"
+ "Looks for the file by parameter, env['PIXELTYPE_DEFS'] and "
+ "in dir(__file__)/../../pixeltypes.py, in that order.n"
+ "PixelType UNKNOWN is not defined here."
+ if not defs_file:
+ defs_file = os.environ.get('PIXELTYPE_DEFS', None)
+ if not defs_file:
+ path = os.path.dirname(os.path.abspath(__file__))
+ defs_file = os.path.join(path, '..', 'pixeltypes.py')
+ sys.stderr.write("Opening PixelType defs file '" + defs_file + "'n")
+ l1 = len(pixeltypes)
+ execfile(defs_file)
+ l2 = len(pixeltypes)
+ sys.stderr.write("Read %d PixelTypes, now %d totaln" % (l2 - l1, l2))
+
+def __init__():
+ "Initialize PixelType UNKNOWN.n"
+ "Currently also reads PIXELTYPE_DEFS, but that may change!"
+ if 0 not in pixeltypes:
+ PixelType("UNKNOWN", 0, [], bit_endian=bit_endians[0], number=0)
+ load_pixeltypes()
+
+__init__()
+
diff --git a/libs/core/gen/defs.py b/pylib/pixeltypes.py
similarity index 57%
rename from libs/core/gen/defs.py
rename to pylib/pixeltypes.py
index 8e9bd5c..7f77336 100644
--- a/libs/core/gen/defs.py
+++ b/pylib/pixeltypes.py
@@ -1,9 +1,18 @@
-# Module defining known PixelTypes
-# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
-
-# NOTE: order defines numbering
+#
+# pixeltypes.py - module defining known PixelTypes
+#
-from pixeltype import PixelType
+#
+# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
+#
+# Every call to PixelType defines one new GP_PixelType, order defines
+# the numbering. Undefined type is defined automatically.
+# No other functionality than PixelType() should be defined here.
+#
+# This file is sourced by all the generating scripts.
+# Moreover, the generated files are sourced by almost all Gfxprim sources,
+# a complete recompilation is required after any change.
+#
PixelType(name='RGBx8888', size=32, chanslist=[
http://repo.or.cz/w/gfxprim.git/commit/bc3e7e202aaedf55738f151b598ffc101618…
commit bc3e7e202aaedf55738f151b598ffc10161881c5
Merge: 5e1cf45 af6444d
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Wed May 25 21:40:39 2011 +0200
Merge branch 'master' into generate
http://repo.or.cz/w/gfxprim.git/commit/af6444d674affcc352f05e1616ad2b6fa4a5…
commit af6444d674affcc352f05e1616ad2b6fa4a5dfe8
Merge: 45b543a 7f6bea0
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Wed May 25 21:40:18 2011 +0200
Merge branch 'master' of git://repo.or.cz/gfxprim
-----------------------------------------------------------------------
Summary of changes:
Makefile | 17 +++-
build/Makefile | 40 ++++----
build/get_objs.sh | 12 ++
build/link.sh | 27 -----
config.mk | 6 +
gen.mk | 37 +++++++
include.mk | 7 ++
include/GP.h | 3 +
include/backends/GP_Backend.h | 2 +-
{tests => include}/sdl/GP_SDL.h | 0
{tests => include}/sdl/GP_SDL_Context.h | 3 +-
{tests => include}/sdl/GP_SDL_VideoInit.h | 0
include/sdl/README | 2 +
libs/Makefile | 2 +-
libs/core/Makefile | 19 +++-
libs/core/gen/gen_utils.py | 74 -------------
libs/gfx/GP_Circle.c | 10 ++
{tests => libs}/sdl/GP_SDL_Context.c | 3 +-
{tests => libs}/sdl/GP_SDL_VideoInit.c | 0
libs/{gfx => sdl}/Makefile | 2 +-
pylib/bin/generate_file.py | 22 ++++
{libs/core/gen => pylib/gfxprim}/README | 0
pylib/gfxprim/__init__.py | 12 ++
.../gfxprim/generators/core}/gen_blit.py | 2 +-
.../gfxprim/generators/core}/gen_pixeltype.py | 5 +-
.../gfxprim/generators/core}/make_GP_Blit.py | 11 ++-
.../gfxprim/generators/core}/make_GP_Pixel.py | 11 ++-
.../generators/core}/make_GP_Pixel_Scale.py | 11 ++-
pylib/gfxprim/generators/generator.py | 112 ++++++++++++++++++++
.../gen => pylib/gfxprim/generators}/pixeltype.py | 32 +++++-
pylib/gfxprim/generators/utils.py | 34 ++++++
libs/core/gen/defs.py => pylib/pixeltypes.py | 19 +++-
tests/Makefile | 2 +-
tests/sdl/Makefile | 18 +++-
tests/sdl/{tests => }/fileview.c | 0
tests/sdl/{tests => }/fonttest.c | 0
tests/sdl/{tests => }/linetest.c | 0
tests/sdl/{tests/Makefile => old.dddd} | 0
tests/sdl/{tests => }/pixeltest.c | 0
tests/sdl/{tests => }/randomshapetest.c | 0
tests/sdl/runtest.sh | 10 ++
tests/sdl/{tests => }/shapetest.c | 0
tests/sdl/{tests => }/sierpinsky.c | 0
tests/sdl/{tests => }/symbolstest.c | 0
tests/sdl/tests/runtest.sh | 10 --
tests/sdl/{tests => }/textaligntest.c | 0
tests/sdl/{tests => }/trianglefps.c | 0
47 files changed, 407 insertions(+), 170 deletions(-)
create mode 100755 build/get_objs.sh
delete mode 100755 build/link.sh
create mode 100644 gen.mk
rename {tests => include}/sdl/GP_SDL.h (100%)
rename {tests => include}/sdl/GP_SDL_Context.h (95%)
rename {tests => include}/sdl/GP_SDL_VideoInit.h (100%)
create mode 100644 include/sdl/README
delete mode 100644 libs/core/gen/gen_utils.py
rename {tests => libs}/sdl/GP_SDL_Context.c (98%)
rename {tests => libs}/sdl/GP_SDL_VideoInit.c (100%)
copy libs/{gfx => sdl}/Makefile (88%)
create mode 100644 pylib/bin/generate_file.py
rename {libs/core/gen => pylib/gfxprim}/README (100%)
create mode 100644 pylib/gfxprim/__init__.py
create mode 100644 pylib/gfxprim/generators/__init__.py
create mode 100644 pylib/gfxprim/generators/core/__init__.py
rename {libs/core/gen => pylib/gfxprim/generators/core}/gen_blit.py (99%)
rename {libs/core/gen => pylib/gfxprim/generators/core}/gen_pixeltype.py (98%)
rename {libs/core/gen => pylib/gfxprim/generators/core}/make_GP_Blit.py (84%)
rename {libs/core/gen => pylib/gfxprim/generators/core}/make_GP_Pixel.py (89%)
rename {libs/core/gen => pylib/gfxprim/generators/core}/make_GP_Pixel_Scale.py (87%)
create mode 100644 pylib/gfxprim/generators/generator.py
rename {libs/core/gen => pylib/gfxprim/generators}/pixeltype.py (72%)
create mode 100644 pylib/gfxprim/generators/utils.py
rename libs/core/gen/defs.py => pylib/pixeltypes.py (57%)
rename tests/sdl/{tests => }/fileview.c (100%)
rename tests/sdl/{tests => }/fonttest.c (100%)
rename tests/sdl/{tests => }/linetest.c (100%)
rename tests/sdl/{tests/Makefile => old.dddd} (100%)
rename tests/sdl/{tests => }/pixeltest.c (100%)
rename tests/sdl/{tests => }/randomshapetest.c (100%)
create mode 100755 tests/sdl/runtest.sh
rename tests/sdl/{tests => }/shapetest.c (100%)
rename tests/sdl/{tests => }/sierpinsky.c (100%)
rename tests/sdl/{tests => }/symbolstest.c (100%)
delete mode 100755 tests/sdl/tests/runtest.sh
rename tests/sdl/{tests => }/textaligntest.c (100%)
rename tests/sdl/{tests => }/trianglefps.c (100%)
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
Hi,
I would find it preferable to receive only commit-messages as repo
updates. Some of the patches are quite lengthy and it is hard to find
the messages of subsequent patches if more commits are pushed at once.
Does anyone use the (current - patchy) mail format? Would it be hard
to change? Am I bragging about minor trifles?
Tomas
P.S.: Thanks to metan for the great work on refactoring the file
structure and for the new build system!
2
1
[repo.or.cz] gfxprim.git branch master updated: 7f6bea085c6d5bdcef77c514eb41a96aac13e6d1
by metan 23 May '11
by metan 23 May '11
23 May '11
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 7f6bea085c6d5bdcef77c514eb41a96aac13e6d1 (commit)
from db5988548d394fcf94da3d66ff85c40afd719fc1 (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/7f6bea085c6d5bdcef77c514eb41a96aac13…
commit 7f6bea085c6d5bdcef77c514eb41a96aac13e6d1
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue May 24 01:31:08 2011 +0200
build: Added infrastructure for using python generators.
diff --git a/gen.mk b/gen.mk
new file mode 100644
index 0000000..56803bc
--- /dev/null
+++ b/gen.mk
@@ -0,0 +1,27 @@
+#
+# This is makefile rule for generating C sources from python generators
+#
+ifndef LIBNAME
+$(error LIBNAME not defined, fix your library Makefile)
+endif
+
+#
+# Headers goes into include/core/
+#
+INCLUDE_PREFIX=$(TOPDIR)/include/$(LIBNAME)/
+RGENHEADERS=$(addprefix $(INCLUDE_PREFIX),$(GENHEADERS))
+
+#
+# Generate genfiles for generated sources
+#
+CSOURCES+=$(GENSOURCES)
+
+#
+# Make the targets build actually
+#
+all: $(RGENHEADERS)
+
+#
+# And clean them
+#
+CLEAN+=$(GENSOURCES) $(RGENHEADERS)
diff --git a/libs/core/Makefile b/libs/core/Makefile
index e740c3b..0ef2e5b 100644
--- a/libs/core/Makefile
+++ b/libs/core/Makefile
@@ -1,5 +1,12 @@
TOPDIR=../..
-CSOURCES=$(shell ls *.c)
+GENSOURCES=GP_Pixel.gen.c
+GENHEADERS=GP_Pixel.gen.h
+CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
LIBNAME=core
+
+include $(TOPDIR)/gen.mk
include $(TOPDIR)/include.mk
include $(TOPDIR)/lib.mk
+
+GP_Pixel.gen.c $(INCLUDE_PREFIX)GP_Pixel.gen.h: gen/make_GP_Pixel.py
+ python gen/make_GP_Pixel.py $(INCLUDE_PREFIX)GP_Pixel.gen.h GP_Pixel.gen.c
-----------------------------------------------------------------------
Summary of changes:
gen.mk | 27 +++++++++++++++++++++++++++
libs/core/Makefile | 9 ++++++++-
2 files changed, 35 insertions(+), 1 deletions(-)
create mode 100644 gen.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
[repo.or.cz] gfxprim.git branch master updated: db5988548d394fcf94da3d66ff85c40afd719fc1
by metan 23 May '11
by metan 23 May '11
23 May '11
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 db5988548d394fcf94da3d66ff85c40afd719fc1 (commit)
from 665128da4ce856b78beece7af486c561a0a84f58 (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/db5988548d394fcf94da3d66ff85c40afd71…
commit db5988548d394fcf94da3d66ff85c40afd719fc1
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 23 22:45:07 2011 +0200
build: Hacked together the deprecated SDL backend and it's tests.
diff --git a/build/Makefile b/build/Makefile
index 642e852..6f01215 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -1,13 +1,13 @@
LIB_OBJECTS=$(shell ./get_objs.sh)
-all: libGP.a libGP.so
+all: libGP.a libGP.so libGP.so.0
clean:
ifdef VERBOSE
- rm -f libGP.a libGP.so
+ rm -f libGP.a libGP.so libGP.so.0
else
- @echo "RM libGP.a libGP.so"
- @rm -f libGP.a libGP.so
+ @echo "RM libGP.a libGP.so libGP.so.0"
+ @rm -f libGP.a libGP.so libGP.so.0
endif
libGP.a: $(LIB_OBJECTS)
@@ -29,3 +29,11 @@ else
@$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,libGP.so.0 $(LIB_OBJECTS) -o libGP.so
endif
@. ./liblock.sh; spinunlock .
+
+libGP.so.0: libGP.so
+ifdef VERBOSE
+ ln -s libGP.so libGP.so.0
+else
+ @echo "LN libGP.so.0"
+ @ln -s libGP.so libGP.so.0
+endif
diff --git a/include/GP.h b/include/GP.h
index e68b747..90777f3 100644
--- a/include/GP.h
+++ b/include/GP.h
@@ -35,4 +35,7 @@
/* fonts and text drawing */
#include "text/GP_Text.h"
+/* backends */
+#include "backends/GP_Backend.h"
+
#endif /* GP_H */
diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h
index 3f81ed7..db771cd 100644
--- a/include/backends/GP_Backend.h
+++ b/include/backends/GP_Backend.h
@@ -89,4 +89,4 @@ void GP_UpdateBackendVideo(void);
*/
int GP_GetBackendEvent(struct GP_BackendEvent *event);
-#endif
+#endif /* GP_BACKEND_H */
diff --git a/tests/sdl/GP_SDL.h b/include/sdl/GP_SDL.h
similarity index 100%
rename from tests/sdl/GP_SDL.h
rename to include/sdl/GP_SDL.h
diff --git a/tests/sdl/GP_SDL_Context.h b/include/sdl/GP_SDL_Context.h
similarity index 95%
rename from tests/sdl/GP_SDL_Context.h
rename to include/sdl/GP_SDL_Context.h
index c908b51..3963824 100644
--- a/tests/sdl/GP_SDL_Context.h
+++ b/include/sdl/GP_SDL_Context.h
@@ -28,7 +28,6 @@
#include "GP.h"
-inline GP_RetCode GP_SDL_ContextFromSurface(GP_Context *context,
- SDL_Surface *surf);
+GP_RetCode GP_SDL_ContextFromSurface(GP_Context *context, SDL_Surface *surf);
#endif /* GP_SDL_CONTEXT_H */
diff --git a/tests/sdl/GP_SDL_VideoInit.h b/include/sdl/GP_SDL_VideoInit.h
similarity index 100%
rename from tests/sdl/GP_SDL_VideoInit.h
rename to include/sdl/GP_SDL_VideoInit.h
diff --git a/include/sdl/README b/include/sdl/README
new file mode 100644
index 0000000..37680b8
--- /dev/null
+++ b/include/sdl/README
@@ -0,0 +1,2 @@
+This code/interface is deprecated and will be removed after backends are
+written.
diff --git a/libs/Makefile b/libs/Makefile
index 1c3d990..9907fb1 100644
--- a/libs/Makefile
+++ b/libs/Makefile
@@ -1,3 +1,3 @@
TOPDIR=..
-SUBDIRS=core gfx text loaders filters input backends
+SUBDIRS=core gfx text loaders filters input backends sdl
include $(TOPDIR)/include.mk
diff --git a/libs/gfx/GP_Circle.c b/libs/gfx/GP_Circle.c
index 9522c1b..4e92243 100644
--- a/libs/gfx/GP_Circle.c
+++ b/libs/gfx/GP_Circle.c
@@ -45,6 +45,16 @@ void GP_Circle(GP_Context *context, int xcenter, int ycenter,
xcenter, ycenter, r, pixel);
}
+void GP_TCircle(GP_Context *context, int xcenter, int ycenter,
+ unsigned int r, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_TRANSFORM_POINT(context, xcenter, ycenter);
+
+ GP_Circle(context, xcenter, ycenter, r, pixel);
+}
+
#include "algo/FillCircle.algo.h"
/* Generate drawing functions for various bit depths. */
diff --git a/tests/sdl/GP_SDL_Context.c b/libs/sdl/GP_SDL_Context.c
similarity index 98%
rename from tests/sdl/GP_SDL_Context.c
rename to libs/sdl/GP_SDL_Context.c
index 3689e44..487476b 100644
--- a/tests/sdl/GP_SDL_Context.c
+++ b/libs/sdl/GP_SDL_Context.c
@@ -97,8 +97,7 @@ static enum GP_PixelType find_surface_pixel_type(SDL_Surface *surf)
}
-inline GP_RetCode GP_SDL_ContextFromSurface(
- GP_Context *context, SDL_Surface *surf)
+GP_RetCode GP_SDL_ContextFromSurface(GP_Context *context, SDL_Surface *surf)
{
if (surf == NULL || surf->pixels == NULL || context == NULL) {
return GP_ENULLPTR;
diff --git a/tests/sdl/GP_SDL_VideoInit.c b/libs/sdl/GP_SDL_VideoInit.c
similarity index 100%
rename from tests/sdl/GP_SDL_VideoInit.c
rename to libs/sdl/GP_SDL_VideoInit.c
diff --git a/libs/sdl/Makefile b/libs/sdl/Makefile
new file mode 100644
index 0000000..ede8ef8
--- /dev/null
+++ b/libs/sdl/Makefile
@@ -0,0 +1,5 @@
+TOPDIR=../..
+CSOURCES=$(shell ls *.c)
+LIBNAME=sdl
+include $(TOPDIR)/include.mk
+include $(TOPDIR)/lib.mk
diff --git a/tests/Makefile b/tests/Makefile
index 1008e61..4181c5c 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,3 +1,3 @@
TOPDIR=..
-SUBDIRS=loaders filters core
+SUBDIRS=loaders filters core sdl
include $(TOPDIR)/include.mk
diff --git a/tests/sdl/Makefile b/tests/sdl/Makefile
index e7c006f..41b109f 100644
--- a/tests/sdl/Makefile
+++ b/tests/sdl/Makefile
@@ -1,2 +1,16 @@
-all:
-clean:
+TOPDIR=../..
+
+CSOURCES=$(shell echo *.c)
+
+INCLUDE=core gfx sdl backends
+LDLIBS+=-lGP -L$(TOPDIR)/build/ -lSDL
+
+APPS=pixeltest fileview fonttest linetest randomshapetest shapetest sierpinsky+ symboltest textaligntest trianglefps
+
+include $(TOPDIR)/include.mk
+include $(TOPDIR)/app.mk
+
+
+$(APPS): $(TOPDIR)/libs/sdl/*.o
+
diff --git a/tests/sdl/tests/fileview.c b/tests/sdl/fileview.c
similarity index 100%
rename from tests/sdl/tests/fileview.c
rename to tests/sdl/fileview.c
diff --git a/tests/sdl/tests/fonttest.c b/tests/sdl/fonttest.c
similarity index 100%
rename from tests/sdl/tests/fonttest.c
rename to tests/sdl/fonttest.c
diff --git a/tests/sdl/tests/linetest.c b/tests/sdl/linetest.c
similarity index 100%
rename from tests/sdl/tests/linetest.c
rename to tests/sdl/linetest.c
diff --git a/tests/sdl/tests/Makefile b/tests/sdl/old.dddd
similarity index 100%
rename from tests/sdl/tests/Makefile
rename to tests/sdl/old.dddd
diff --git a/tests/sdl/tests/pixeltest.c b/tests/sdl/pixeltest.c
similarity index 100%
rename from tests/sdl/tests/pixeltest.c
rename to tests/sdl/pixeltest.c
diff --git a/tests/sdl/tests/randomshapetest.c b/tests/sdl/randomshapetest.c
similarity index 100%
rename from tests/sdl/tests/randomshapetest.c
rename to tests/sdl/randomshapetest.c
diff --git a/tests/sdl/runtest.sh b/tests/sdl/runtest.sh
new file mode 100755
index 0000000..73c9f61
--- /dev/null
+++ b/tests/sdl/runtest.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+#
+# Run dynamically linked test.
+#
+
+PROG="$1"
+shift
+
+echo "LD_LIBRARY_PATH=../../build/ ./$PROG $@"
+LD_LIBRARY_PATH=../../build/ ./$PROG $@
diff --git a/tests/sdl/tests/shapetest.c b/tests/sdl/shapetest.c
similarity index 100%
rename from tests/sdl/tests/shapetest.c
rename to tests/sdl/shapetest.c
diff --git a/tests/sdl/tests/sierpinsky.c b/tests/sdl/sierpinsky.c
similarity index 100%
rename from tests/sdl/tests/sierpinsky.c
rename to tests/sdl/sierpinsky.c
diff --git a/tests/sdl/tests/symbolstest.c b/tests/sdl/symbolstest.c
similarity index 100%
rename from tests/sdl/tests/symbolstest.c
rename to tests/sdl/symbolstest.c
diff --git a/tests/sdl/tests/runtest.sh b/tests/sdl/tests/runtest.sh
deleted file mode 100755
index 4678f55..0000000
--- a/tests/sdl/tests/runtest.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-#
-# Run dynamically linked test.
-#
-
-PROG="$1"
-shift
-
-echo "LD_LIBRARY_PATH=..:../../.. ./$PROG $@"
-LD_LIBRARY_PATH=..:../../../core ./$PROG $@
diff --git a/tests/sdl/tests/textaligntest.c b/tests/sdl/textaligntest.c
similarity index 100%
rename from tests/sdl/tests/textaligntest.c
rename to tests/sdl/textaligntest.c
diff --git a/tests/sdl/tests/trianglefps.c b/tests/sdl/trianglefps.c
similarity index 100%
rename from tests/sdl/tests/trianglefps.c
rename to tests/sdl/trianglefps.c
-----------------------------------------------------------------------
Summary of changes:
build/Makefile | 16 ++++++++++++----
include/GP.h | 3 +++
include/backends/GP_Backend.h | 2 +-
{tests => include}/sdl/GP_SDL.h | 0
{tests => include}/sdl/GP_SDL_Context.h | 3 +--
{tests => include}/sdl/GP_SDL_VideoInit.h | 0
include/sdl/README | 2 ++
libs/Makefile | 2 +-
libs/gfx/GP_Circle.c | 10 ++++++++++
{tests => libs}/sdl/GP_SDL_Context.c | 3 +--
{tests => libs}/sdl/GP_SDL_VideoInit.c | 0
libs/{gfx => sdl}/Makefile | 2 +-
tests/Makefile | 2 +-
tests/sdl/Makefile | 18 ++++++++++++++++--
tests/sdl/{tests => }/fileview.c | 0
tests/sdl/{tests => }/fonttest.c | 0
tests/sdl/{tests => }/linetest.c | 0
tests/sdl/{tests/Makefile => old.dddd} | 0
tests/sdl/{tests => }/pixeltest.c | 0
tests/sdl/{tests => }/randomshapetest.c | 0
tests/sdl/runtest.sh | 10 ++++++++++
tests/sdl/{tests => }/shapetest.c | 0
tests/sdl/{tests => }/sierpinsky.c | 0
tests/sdl/{tests => }/symbolstest.c | 0
tests/sdl/tests/runtest.sh | 10 ----------
tests/sdl/{tests => }/textaligntest.c | 0
tests/sdl/{tests => }/trianglefps.c | 0
27 files changed, 59 insertions(+), 24 deletions(-)
rename {tests => include}/sdl/GP_SDL.h (100%)
rename {tests => include}/sdl/GP_SDL_Context.h (95%)
rename {tests => include}/sdl/GP_SDL_VideoInit.h (100%)
create mode 100644 include/sdl/README
rename {tests => libs}/sdl/GP_SDL_Context.c (98%)
rename {tests => libs}/sdl/GP_SDL_VideoInit.c (100%)
copy libs/{gfx => sdl}/Makefile (88%)
rename tests/sdl/{tests => }/fileview.c (100%)
rename tests/sdl/{tests => }/fonttest.c (100%)
rename tests/sdl/{tests => }/linetest.c (100%)
rename tests/sdl/{tests/Makefile => old.dddd} (100%)
rename tests/sdl/{tests => }/pixeltest.c (100%)
rename tests/sdl/{tests => }/randomshapetest.c (100%)
create mode 100755 tests/sdl/runtest.sh
rename tests/sdl/{tests => }/shapetest.c (100%)
rename tests/sdl/{tests => }/sierpinsky.c (100%)
rename tests/sdl/{tests => }/symbolstest.c (100%)
delete mode 100755 tests/sdl/tests/runtest.sh
rename tests/sdl/{tests => }/textaligntest.c (100%)
rename tests/sdl/{tests => }/trianglefps.c (100%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: 5e1cf45920d28673d7e1245b9709b65c1724084d
by gavento 23 May '11
by gavento 23 May '11
23 May '11
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, generate has been updated
via 5e1cf45920d28673d7e1245b9709b65c1724084d (commit)
via a4788df1092827ba940a1ffe30d56a13b7511bdc (commit)
via a1fcf54f181d9449202b06a78d15ed2e46adc48e (commit)
via 21bff8ae3a18cadfc1b4da2dfe70f686083a40d6 (commit)
via 9d70f761d257857c896cff683236def3bf1133b3 (commit)
via ed742c11ffda92c31b8fd354d96ff2b07e9a61bf (commit)
via c06d997dec540789eee858038b0e0f64c40328b3 (commit)
via 45b543a87a205f931395839e32415a0ca76b0978 (commit)
via da0b966559ef04b7d53d080fefe9b99ddd7097a0 (commit)
via ca86f291356ade62df38c8059f7f0eecebfe0991 (commit)
via cc61bfdb1d208cdc21b01d7335604049a94db9ca (commit)
via 3cefa3907f68f96ec6e2e7ecc4ecf1fb26b96cdb (commit)
via 6dee12b408a53004c3f5a74d265696d8ce3edd47 (commit)
via d984c76e6650ed7d005745e36ccb6e029eb634d3 (commit)
via cbe54b1ef522cf97d90f0d4e7c909884e96ffde6 (commit)
via 3814872780477efda3b924604c52c6583f77ecce (commit)
via 0cfb5e91e793cb577881a8bfc1c5c61e5353422b (commit)
via 44de9a46432c45949764964d3c49e65e2bb9701b (commit)
via f553db48b5df795253902ce74770f57217b642ab (commit)
via ff4fe6a3deedee19d4472c17568f13c3a029475b (commit)
via dfefe1528e754ca7f9908dafb4544c08a78f6e6c (commit)
via cf69cb4b75d228a01a4d7b803e6dfd2d32efbef3 (commit)
via 3e29dc184eff61f987adb9bbab4c223a9b07ff5f (commit)
via e3dfb3d477878b7ae70682ef12aefb91d9a17dba (commit)
via 852d0d3925acf658dd96979bfbaef0dabb45e81b (commit)
via 266c6d21983c196e2071c65d6b5d14d201d9392c (commit)
via 983969d8fad548991c47cf81e7e013308fcf6a70 (commit)
via ab15bc2a2e7b7636d7e0481251615c360de17c3f (commit)
via 94a7d269628a94cf585ed33951bac25b370f20cc (commit)
via 48a02d9f6947b24c9b1ea70effaeee5191bf454a (commit)
via 3e089f991eb2a1946964b6d42357db197d3be099 (commit)
via c3b33c14d2263d443554d1b3ac5f43430e148698 (commit)
via 6722436c25bf3899cc2c3c2b44ed0382e04a7fff (commit)
via d5cdf89dd42290ce846e29309879a9263aa9e023 (commit)
via 037f2ffabeabd1a2522169b7b766333a64680762 (commit)
via 21f013df6c1f9ff561304ef0543589baefd79a9b (commit)
via 8cfcfcb548e810bf75dd41fa38391a96b18b8907 (commit)
via b0f09bfef85c7a22ed6feba890e085634a6517e2 (commit)
via e72092bb7d6f87d5d739cc1697da79cd69c6a2a7 (commit)
via 50ac1f21f85e66b3d2a8a0a6047971c474c250a4 (commit)
via 2274cefa956331bb30fc65f72522f7a4d4ec0e28 (commit)
via 582174a303ed68281404b7f09beeba72d8d80a17 (commit)
via 16a50bf6b0c956641c452653bd38621d668aef66 (commit)
via 1ee71956ba9e5ca2cd298fa3702e4036bbf59225 (commit)
via 4fd5560abf4f40f8436fd4af18d604ceff3d64b8 (commit)
via 4d97054a669a9060142863a6004144d993270c13 (commit)
via 4df5151ae9400f76567697fd5c88917d9ee79229 (commit)
via 31bfb14e08456f70a7823efa3832ad4e3ffbb9d3 (commit)
via 5815d26c3a7e2a3be30f5d075c4ca064092734a3 (commit)
via d45e568685703f9a6b74bff7d25392f3a2f9b417 (commit)
via 83881d075d4d203f6949641c09d45d7f4ab6b6c0 (commit)
via e57fbf5bbbc9b4618c8ac015ac9986bd928f797c (commit)
via e1b16f55b51c64ae4e2c5755e4e1633e579164f0 (commit)
via a15037c925ea8b6b995b3fd765e86978e6430dcd (commit)
via c4107c1c47c062cb836f0dc0269b7479acc03de6 (commit)
via 231bb15ee44ff8cb70008eb11e25241e07c8e693 (commit)
via da9aaa9bac5aa0db09a184b718b60ff089316b42 (commit)
via 7d1b48ec4f4c4f73b46ede4785131cb431f2ac30 (commit)
via 571600efa81d0dddf7ecb637119291f8632635d0 (commit)
via 1f275d3bbb03491c03943f5661a3b4d627213121 (commit)
via 6597f082e58619947cdc34a05d008a786910bb11 (commit)
via 09df1ce6c6cb1b860555326cbadc581ba885c839 (commit)
via 32dd244ed5673a96c86c34430fbfbd4574900f5d (commit)
via 689eed1ceaa4407932ae557b389ff0fbf01715d4 (commit)
via faee6e47752b868e830f56b14af54798b559afe7 (commit)
via 8edfb8c8c31d5a39be06c4f82760b7af2fbf696b (commit)
via 47786e2ac0576f3807142e29c1b0c5d930b8b3b1 (commit)
via dff0057435e267886b3ab76d62e37dfa0bfbd481 (commit)
via dff8cea876a4c7b585c88beb18423631def57946 (commit)
via ef185c24c13d6b6b65ad276a1f894af3d8288f4a (commit)
via 4e59064f36aafdc2e7cd90ab765e94c649b48e13 (commit)
via fce92553224cc36cb387d6581e68160c559a5e69 (commit)
via 1fd107c16aaafd19b603a3adb5a92e20aaf9fed9 (commit)
via 07637417375c72f3016b80e1191b5e43e66bbe94 (commit)
via 70a10c5b2f60f9580c0ad734ad2902e2c61802e8 (commit)
via d2b5a02db8e3a4f27c108e0b60f947d560d99de9 (commit)
via f364349752582a08c589f7c6788634505ae2334e (commit)
via 248ca0b50c775fd21a6bbc7a84267d24e4603238 (commit)
via 288182835aeafe92a9ee3e965985709a0784d2ca (commit)
via ba5d7661e9707e44c1db947feabdcefbeda5c89c (commit)
via 089cf8c4f64083f121955cb21cc724ffb7073e5a (commit)
via d7cceddf8e7c963cd6db8dc11cae641c4c0e3f2e (commit)
via ea3b5b87735179113af713d1d12002629a559379 (commit)
via d8973e04d58e1e2d70073624ff4e8d11fe1d8473 (commit)
via dac445e4561fcea0c8e73da90218c8c436d1af16 (commit)
via dc9cbe7bf75dfa499c3f9bddaa3c1d0576e11c3f (commit)
via 57721fc6a318d3fa9183e0e1a621a8cf642b5b43 (commit)
via 916c9af7680ff98ff79a5bfca5d4ead8c9c56336 (commit)
via b77a4182193f1c0f6223dd997aa17fb85a0d7834 (commit)
via 9771ff1a54b004327cf9c82cc7e44b2071cc415f (commit)
via 0a67965e5e61bf57c22a975d910ac2fb7a4f6e44 (commit)
via 5b4e605c17c3734690054cc7459388e3e2a693c8 (commit)
via 2445c17c5ef46920b04e732e2792844ca26567fc (commit)
via 116d00c687a9b06a22c1de0e21e219315ad82796 (commit)
via ee08b37cc676a5f1b57a1b0292384cf317ef7492 (commit)
via 84c2e00d1de47903ee2c3d8724de108ef5e6f0ee (commit)
via f99d4bbefef6c942e9f3588314981cb3b90a52d3 (commit)
from 62b806d63d5e37b8001e7de7cf5a128467e75eef (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/5e1cf45920d28673d7e1245b9709b65c1724…
commit 5e1cf45920d28673d7e1245b9709b65c1724084d
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Mon May 23 21:56:56 2011 +0200
Post-merge moves
diff --git a/core/GP_Counter.h b/include/core/GP_Counter.h
similarity index 100%
rename from core/GP_Counter.h
rename to include/core/GP_Counter.h
diff --git a/core/GP_Counter.c b/libs/core/GP_Counter.c
similarity index 100%
rename from core/GP_Counter.c
rename to libs/core/GP_Counter.c
diff --git a/core/gen/README b/libs/core/gen/README
similarity index 100%
rename from core/gen/README
rename to libs/core/gen/README
diff --git a/core/gen/defs.py b/libs/core/gen/defs.py
similarity index 100%
rename from core/gen/defs.py
rename to libs/core/gen/defs.py
diff --git a/core/gen/gen_blit.py b/libs/core/gen/gen_blit.py
similarity index 100%
rename from core/gen/gen_blit.py
rename to libs/core/gen/gen_blit.py
diff --git a/core/gen/gen_pixeltype.py b/libs/core/gen/gen_pixeltype.py
similarity index 100%
rename from core/gen/gen_pixeltype.py
rename to libs/core/gen/gen_pixeltype.py
diff --git a/core/gen/gen_utils.py b/libs/core/gen/gen_utils.py
similarity index 100%
rename from core/gen/gen_utils.py
rename to libs/core/gen/gen_utils.py
diff --git a/core/gen/make_GP_Blit.py b/libs/core/gen/make_GP_Blit.py
similarity index 100%
rename from core/gen/make_GP_Blit.py
rename to libs/core/gen/make_GP_Blit.py
diff --git a/core/gen/make_GP_Pixel.py b/libs/core/gen/make_GP_Pixel.py
similarity index 100%
rename from core/gen/make_GP_Pixel.py
rename to libs/core/gen/make_GP_Pixel.py
diff --git a/core/gen/make_GP_Pixel_Scale.py b/libs/core/gen/make_GP_Pixel_Scale.py
similarity index 100%
rename from core/gen/make_GP_Pixel_Scale.py
rename to libs/core/gen/make_GP_Pixel_Scale.py
diff --git a/core/gen/pixeltype.py b/libs/core/gen/pixeltype.py
similarity index 100%
rename from core/gen/pixeltype.py
rename to libs/core/gen/pixeltype.py
diff --git a/core/tests/GP_Counter.test.c b/tests/core/GP_Counter.test.c
similarity index 100%
rename from core/tests/GP_Counter.test.c
rename to tests/core/GP_Counter.test.c
http://repo.or.cz/w/gfxprim.git/commit/a4788df1092827ba940a1ffe30d56a13b751…
commit a4788df1092827ba940a1ffe30d56a13b7511bdc
Merge: a1fcf54 45b543a
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Mon May 23 21:48:41 2011 +0200
Merge branch 'master' into generate
Conflicts:
core/Makefile
include/core/GP_Context.h
include/gfx/GP_Gfx.h
diff --cc include/gfx/GP_Gfx.h
index cd9f74d,19bad4e..149f26e
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_Gfx.h
@@@ -58,16 -54,4 +54,14 @@@
#include "GP_Polygon.h"
#include "GP_Symbol.h"
- /* fonts */
- #include "GP_Font.h"
- #include "GP_TextStyle.h"
- #include "GP_TextMetric.h"
- #include "GP_Text.h"
+ #endif /* GP_GFX_H */
+
+/* backends */
+#include "GP_Backend.h"
+
+#define typeof __typeof__
+
+#endif /* GP_H */
++=======
++#endif /* GP_GFX_H */
++>>>>>>> master:include/gfx/GP_Gfx.h
diff --cc libs/core/GP_Pixel.c
index e7f4b80,0ed154e..eedd94a
--- a/libs/core/GP_Pixel.c
+++ b/libs/core/GP_Pixel.c
@@@ -23,213 -23,228 +23,213 @@@
* *
*****************************************************************************/
- #include "GP.h"
+ #include "GP_Core.h"
-struct PixelTypeInfo {
- const char *type_name; /* human-readable name */
- GP_ColorType color_type; /* color type used for this pixel type */
- unsigned int bits; /* how many bits the pixel occupies */
-};
-
-/* This table shows relations of pixel types to color types, their names
- * and bits per pixel.
- */
-static struct PixelTypeInfo pixel_type_infos[] = {
- { "Unknown pixel type", GP_NOCOLOR, 0 },
- { "Palette 4bit", GP_PAL4, 4 },
- { "Palette 8bit", GP_PAL8, 8 },
- { "Grayscale 1bit", GP_G1, 1 },
- { "Grayscale 2bits", GP_G2, 2 },
- { "Grayscale 4bits", GP_G4, 4 },
- { "Grayscale 8bits", GP_G8, 8 },
- { "RGB 555", GP_RGB555, 16 },
- { "BGR 555", GP_RGB555, 16 },
- { "RGB 565", GP_RGB565, 16 },
- { "BGR 565", GP_RGB565, 16 },
- { "RGB 888", GP_RGB888, 24 },
- { "BGR 888", GP_RGB888, 24 },
- { "XRGB 8888", GP_RGB888, 32 },
- { "RGBX 8888", GP_RGB888, 32 },
- { "XBGR 8888", GP_RGB888, 32 },
- { "BGRX 8888", GP_RGB888, 32 },
- { "ARGB 8888", GP_RGBA8888, 32 },
- { "RGBA 8888", GP_RGBA8888, 32 },
- { "ABGR 8888", GP_RGBA8888, 32 },
- { "BGRA 8888", GP_RGBA8888, 32 }
-};
-
-const char *GP_PixelTypeName(GP_PixelType type)
-{
- if (type >= GP_PIXEL_MAX)
- return "INVALID TYPE";
-
- return pixel_type_infos[type].type_name;
-}
-
-uint32_t GP_PixelSize(GP_PixelType type)
-{
- if (type >= GP_PIXEL_MAX)
- return 0;
-
- return pixel_type_infos[type].bits;
-}
-
-GP_ColorType GP_PixelTypeToColorType(GP_PixelType type)
-{
- if (type >= GP_PIXEL_MAX)
- return GP_COLMAX;
-
- return pixel_type_infos[type].color_type;
-}
-
-#define CHECK_RET(ret) if (ret != GP_ESUCCESS && ret != GP_EUNPRECISE) return ret;
-
-GP_RetCode GP_ColorToPixelType(GP_PixelType pixel_type, GP_Color color, GP_Pixel *pixel)
-{
- if (pixel == NULL)
- return GP_ENULLPTR;
-
- GP_RetCode ret;
-
- switch (pixel_type) {
- case GP_PIXEL_PAL4:
- ret = GP_ColorConvert(&color, GP_PAL4);
- CHECK_RET(ret);
- *pixel = color.pal4.index;
- return ret;
- break;
- case GP_PIXEL_PAL8:
- ret = GP_ColorConvert(&color, GP_PAL8);
- CHECK_RET(ret);
- *pixel = color.pal8.index;
- return ret;
- break;
- case GP_PIXEL_G1:
- ret = GP_ColorConvert(&color, GP_G1);
- CHECK_RET(ret);
- *pixel = color.g1.gray;
- return ret;
- break;
- case GP_PIXEL_G2:
- ret = GP_ColorConvert(&color, GP_G2);
- CHECK_RET(ret);
- *pixel = color.g2.gray;
- return ret;
- break;
- case GP_PIXEL_G4:
- ret = GP_ColorConvert(&color, GP_G4);
- CHECK_RET(ret);
- *pixel = color.g4.gray;
- return ret;
- break;
- case GP_PIXEL_G8:
- ret = GP_ColorConvert(&color, GP_G8);
- CHECK_RET(ret);
- *pixel = color.g8.gray;
- return ret;
- break;
- case GP_PIXEL_RGB565:
- ret = GP_ColorConvert(&color, GP_RGB565);
- CHECK_RET(ret);
- *pixel = color.rgb565.red << 0x0b |
- color.rgb565.green << 0x05 |
- color.rgb565.blue;
- case GP_PIXEL_RGB888:
- case GP_PIXEL_XRGB8888:
- ret = GP_ColorConvert(&color, GP_RGB888);
- CHECK_RET(ret);
- *pixel = color.rgb888.red << 0x10 |
- color.rgb888.green << 0x08 |
- color.rgb888.blue;
- return ret;
- break;
- case GP_PIXEL_BGR888:
- case GP_PIXEL_XBGR8888:
- ret = GP_ColorConvert(&color, GP_RGB888);
- CHECK_RET(ret);
- *pixel = color.rgb888.red |
- color.rgb888.green << 0x08 |
- color.rgb888.blue << 0x10;
- return ret;
- break;
- case GP_PIXEL_RGBX8888:
- ret = GP_ColorConvert(&color, GP_RGB888);
- CHECK_RET(ret);
- *pixel = color.rgb888.red << 0x18 |
- color.rgb888.green << 0x10 |
- color.rgb888.blue << 0x8;
- return ret;
- break;
- case GP_PIXEL_BGRX8888:
- ret = GP_ColorConvert(&color, GP_RGB888);
- CHECK_RET(ret);
- *pixel = color.rgb888.red << 0x08 |
- color.rgb888.green << 0x10 |
- color.rgb888.blue << 0x18;
- return ret;
- break;
- case GP_PIXEL_ARGB8888:
- ret = GP_ColorConvert(&color, GP_RGBA8888);
- CHECK_RET(ret);
- *pixel = color.rgba8888.red << 0x10 |
- color.rgba8888.green << 0x08 |
- color.rgba8888.blue |
- color.rgba8888.alpha << 0x18;
- return ret;
- break;
- case GP_PIXEL_RGBA8888:
- ret = GP_ColorConvert(&color, GP_RGBA8888);
- CHECK_RET(ret);
- *pixel = color.rgba8888.red << 0x18 |
- color.rgba8888.green << 0x10 |
- color.rgba8888.blue << 0x08 |
- color.rgba8888.alpha;
- return ret;
- break;
- case GP_PIXEL_ABGR8888:
- ret = GP_ColorConvert(&color, GP_RGBA8888);
- CHECK_RET(ret);
- *pixel = color.rgba8888.red |
- color.rgba8888.green << 0x08 |
- color.rgba8888.blue << 0x10 |
- color.rgba8888.alpha << 0x18;
- return ret;
- break;
- case GP_PIXEL_BGRA8888:
- ret = GP_ColorConvert(&color, GP_RGBA8888);
- CHECK_RET(ret);
- *pixel = color.rgba8888.red << 0x08 |
- color.rgba8888.green << 0x10 |
- color.rgba8888.blue << 0x18 |
- color.rgba8888.alpha;
- return ret;
- break;
- case GP_PIXEL_MAX:
- break;
- }
-
- if (pixel_type >= GP_PIXEL_MAX)
- return GP_EINVAL;
- else
- return GP_ENOIMPL;
-}
-
-GP_RetCode GP_ColorToPixel(GP_Context *context, GP_Color color, GP_Pixel *pixel)
-{
- if (context == NULL || pixel == NULL)
- return GP_ENULLPTR;
-
- return GP_ColorToPixelType(context->pixel_type, color, pixel);
-}
-
-GP_RetCode GP_ColorNameToPixel(GP_Context *context, GP_ColorName name, GP_Pixel *pixel)
-{
- if (context == NULL || pixel == NULL)
- return GP_ENULLPTR;
-
- GP_Color color = GP_COLNAME_PACK(name);
- return GP_ColorToPixelType(context->pixel_type, color, pixel);
-}
-
-GP_RetCode GP_ColorNameToPixelType(GP_PixelType pixel_type, GP_ColorName name, GP_Pixel *pixel)
-{
- if (pixel == NULL)
- return GP_ENULLPTR;
-
- GP_Color color = GP_COLNAME_PACK(name);
- return GP_ColorToPixelType(pixel_type, color, pixel);
-}
-
-GP_RetCode GP_RGBToPixel(GP_Context *context, uint8_t r, uint8_t g, uint8_t b, GP_Pixel *pixel)
-{
- if (pixel == NULL)
- return GP_ENULLPTR;
-
- GP_Color color = GP_RGB888_PACK(r, g, b);
- return GP_ColorToPixelType(context->pixel_type, color, pixel);
-}
+/////// removed by gavento
+// struct PixelTypeInfo {
+// const char *type_name; /* human-readable name */
+// GP_ColorType color_type; /* color type used for this pixel type */
+// unsigned int bits; /* how many bits the pixel occupies */
+// };
+//
+// /* This table shows relations of pixel types to color types, their names
+// * and bits per pixel.
+// */
+// static struct PixelTypeInfo pixel_type_infos[] = {
+// { "Unknown pixel type", GP_NOCOLOR, 0 },
+// { "Palette 4bit", GP_PAL4, 4 },
+// { "Palette 8bit", GP_PAL8, 8 },
+// { "Grayscale 1bit", GP_G1, 1 },
+// { "Grayscale 2bits", GP_G2, 2 },
+// { "Grayscale 4bits", GP_G4, 4 },
+// { "Grayscale 8bits", GP_G8, 8 },
+// { "RGB 555", GP_RGB555, 16 },
+// { "BGR 555", GP_RGB555, 16 },
+// { "RGB 565", GP_RGB565, 16 },
+// { "BGR 565", GP_RGB565, 16 },
+// { "RGB 888", GP_RGB888, 24 },
+// { "BGR 888", GP_RGB888, 24 },
+// { "XRGB 8888", GP_RGB888, 32 },
+// { "RGBX 8888", GP_RGB888, 32 },
+// { "XBGR 8888", GP_RGB888, 32 },
+// { "BGRX 8888", GP_RGB888, 32 },
+// { "ARGB 8888", GP_RGBA8888, 32 },
+// { "RGBA 8888", GP_RGBA8888, 32 },
+// { "ABGR 8888", GP_RGBA8888, 32 },
+// { "BGRA 8888", GP_RGBA8888, 32 }
+// };
+//
+// GP_ColorType GP_PixelTypeToColorType(GP_PixelType type)
+// {
+// if (type >= GP_PIXEL_MAX)
+// return GP_COLMAX;
+//
+// return pixel_type_infos[type].color_type;
+// }
+//
+// #define CHECK_RET(ret) if (ret != GP_ESUCCESS && ret != GP_EUNPRECISE) return ret;
+//
+// GP_RetCode GP_ColorToPixelType(GP_PixelType pixel_type, GP_Color color, GP_Pixel *pixel)
+// {
+// if (pixel == NULL)
+// return GP_ENULLPTR;
+//
+// GP_RetCode ret;
+//
+// switch (pixel_type) {
+// case GP_PIXEL_PAL4:
+// ret = GP_ColorConvert(&color, GP_PAL4);
+// CHECK_RET(ret);
+// *pixel = color.pal4.index;
+// return ret;
+// break;
+// case GP_PIXEL_PAL8:
+// ret = GP_ColorConvert(&color, GP_PAL8);
+// CHECK_RET(ret);
+// *pixel = color.pal8.index;
+// return ret;
+// break;
+// case GP_PIXEL_G1:
+// ret = GP_ColorConvert(&color, GP_G1);
+// CHECK_RET(ret);
+// *pixel = color.g1.gray;
+// return ret;
+// break;
+// case GP_PIXEL_G2:
+// ret = GP_ColorConvert(&color, GP_G2);
+// CHECK_RET(ret);
+// *pixel = color.g2.gray;
+// return ret;
+// break;
+// case GP_PIXEL_G4:
+// ret = GP_ColorConvert(&color, GP_G4);
+// CHECK_RET(ret);
+// *pixel = color.g4.gray;
+// return ret;
+// break;
+// case GP_PIXEL_G8:
+// ret = GP_ColorConvert(&color, GP_G8);
+// CHECK_RET(ret);
+// *pixel = color.g8.gray;
+// return ret;
+// break;
+// case GP_PIXEL_RGB565:
+// ret = GP_ColorConvert(&color, GP_RGB565);
+// CHECK_RET(ret);
+// *pixel = color.rgb565.red << 0x0b |
+// color.rgb565.green << 0x05 |
+// color.rgb565.blue;
+// case GP_PIXEL_RGB888:
+// case GP_PIXEL_XRGB8888:
+// ret = GP_ColorConvert(&color, GP_RGB888);
+// CHECK_RET(ret);
+// *pixel = color.rgb888.red << 0x10 |
+// color.rgb888.green << 0x08 |
+// color.rgb888.blue;
+// return ret;
+// break;
+// case GP_PIXEL_BGR888:
+// case GP_PIXEL_XBGR8888:
+// ret = GP_ColorConvert(&color, GP_RGB888);
+// CHECK_RET(ret);
+// *pixel = color.rgb888.red |
+// color.rgb888.green << 0x08 |
+// color.rgb888.blue << 0x10;
+// return ret;
+// break;
+// case GP_PIXEL_RGBX8888:
+// ret = GP_ColorConvert(&color, GP_RGB888);
+// CHECK_RET(ret);
+// *pixel = color.rgb888.red << 0x18 |
+// color.rgb888.green << 0x10 |
+// color.rgb888.blue << 0x8;
+// return ret;
+// break;
+// case GP_PIXEL_BGRX8888:
+// ret = GP_ColorConvert(&color, GP_RGB888);
+// CHECK_RET(ret);
+// *pixel = color.rgb888.red << 0x08 |
+// color.rgb888.green << 0x10 |
+// color.rgb888.blue << 0x18;
+// return ret;
+// break;
+// case GP_PIXEL_ARGB8888:
+// ret = GP_ColorConvert(&color, GP_RGBA8888);
+// CHECK_RET(ret);
+// *pixel = color.rgba8888.red << 0x10 |
+// color.rgba8888.green << 0x08 |
+// color.rgba8888.blue |
+// color.rgba8888.alpha << 0x18;
+// return ret;
+// break;
+// case GP_PIXEL_RGBA8888:
+// ret = GP_ColorConvert(&color, GP_RGBA8888);
+// CHECK_RET(ret);
+// *pixel = color.rgba8888.red << 0x18 |
+// color.rgba8888.green << 0x10 |
+// color.rgba8888.blue << 0x08 |
+// color.rgba8888.alpha;
+// return ret;
+// break;
+// case GP_PIXEL_ABGR8888:
+// ret = GP_ColorConvert(&color, GP_RGBA8888);
+// CHECK_RET(ret);
+// *pixel = color.rgba8888.red |
+// color.rgba8888.green << 0x08 |
+// color.rgba8888.blue << 0x10 |
+// color.rgba8888.alpha << 0x18;
+// return ret;
+// break;
+// case GP_PIXEL_BGRA8888:
+// ret = GP_ColorConvert(&color, GP_RGBA8888);
+// CHECK_RET(ret);
+// *pixel = color.rgba8888.red << 0x08 |
+// color.rgba8888.green << 0x10 |
+// color.rgba8888.blue << 0x18 |
+// color.rgba8888.alpha;
+// return ret;
+// break;
+// case GP_PIXEL_MAX:
+// break;
+// }
+//
+// if (pixel_type >= GP_PIXEL_MAX)
+// return GP_EINVAL;
+// else
+// return GP_ENOIMPL;
+// }
+//
+// GP_RetCode GP_ColorToPixel(GP_Context *context, GP_Color color, GP_Pixel *pixel)
+// {
+// if (context == NULL || pixel == NULL)
+// return GP_ENULLPTR;
+//
+// return GP_ColorToPixelType(context->pixel_type, color, pixel);
+// }
+//
+// GP_RetCode GP_ColorNameToPixel(GP_Context *context, GP_ColorName name, GP_Pixel *pixel)
+// {
+// if (context == NULL || pixel == NULL)
+// return GP_ENULLPTR;
+//
+// GP_Color color = GP_COLNAME_PACK(name);
+// return GP_ColorToPixelType(context->pixel_type, color, pixel);
+// }
+//
+// GP_RetCode GP_ColorNameToPixelType(GP_PixelType pixel_type, GP_ColorName name, GP_Pixel *pixel)
+// {
+// if (pixel == NULL)
+// return GP_ENULLPTR;
+//
+// GP_Color color = GP_COLNAME_PACK(name);
+// return GP_ColorToPixelType(pixel_type, color, pixel);
+// }
+//
+// GP_RetCode GP_RGBToPixel(GP_Context *context, uint8_t r, uint8_t g, uint8_t b, GP_Pixel *pixel)
+// {
+// if (pixel == NULL)
+// return GP_ENULLPTR;
+//
+// GP_Color color = GP_RGB888_PACK(r, g, b);
+// return GP_ColorToPixelType(context->pixel_type, color, pixel);
+// }
diff --cc libs/gfx/GP_Line.c
index f85eb0b,42a6cbc..21066b1
--- a/libs/gfx/GP_Line.c
+++ b/libs/gfx/GP_Line.c
@@@ -23,17 -23,14 +23,17 @@@
* *
*****************************************************************************/
- #include "GP.h"
+ #include "GP_Gfx.h"
#include "algo/Line.algo.h"
- #include "GP_FnPerBpp.h"
+ #include "core/GP_FnPerBpp.h"
/* Generate drawing functions for various bit depths. */
-DEF_LINE_FN(GP_Line1bpp, GP_Context *, GP_Pixel, GP_PutPixel1bpp)
-DEF_LINE_FN(GP_Line2bpp, GP_Context *, GP_Pixel, GP_PutPixel2bpp)
-DEF_LINE_FN(GP_Line4bpp, GP_Context *, GP_Pixel, GP_PutPixel4bpp)
+DEF_LINE_FN(GP_Line1bpp_LE, GP_Context *, GP_Pixel, GP_PutPixel1bpp_LE)
+DEF_LINE_FN(GP_Line2bpp_LE, GP_Context *, GP_Pixel, GP_PutPixel2bpp_LE)
+DEF_LINE_FN(GP_Line4bpp_LE, GP_Context *, GP_Pixel, GP_PutPixel4bpp_LE)
+DEF_LINE_FN(GP_Line1bpp_BE, GP_Context *, GP_Pixel, GP_PutPixel1bpp_BE)
+DEF_LINE_FN(GP_Line2bpp_BE, GP_Context *, GP_Pixel, GP_PutPixel2bpp_BE)
+DEF_LINE_FN(GP_Line4bpp_BE, GP_Context *, GP_Pixel, GP_PutPixel4bpp_BE)
DEF_LINE_FN(GP_Line8bpp, GP_Context *, GP_Pixel, GP_PutPixel8bpp)
DEF_LINE_FN(GP_Line16bpp, GP_Context *, GP_Pixel, GP_PutPixel16bpp)
DEF_LINE_FN(GP_Line24bpp, GP_Context *, GP_Pixel, GP_PutPixel24bpp)
http://repo.or.cz/w/gfxprim.git/commit/a1fcf54f181d9449202b06a78d15ed2e46ad…
commit a1fcf54f181d9449202b06a78d15ed2e46adc48e
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Mon May 23 21:42:32 2011 +0200
Add typeof definition (C99)
diff --git a/core/GP.h b/core/GP.h
index 77ba1b0..cd9f74d 100644
--- a/core/GP.h
+++ b/core/GP.h
@@ -68,4 +68,6 @@
/* backends */
#include "GP_Backend.h"
+#define typeof __typeof__
+
#endif /* GP_H */
http://repo.or.cz/w/gfxprim.git/commit/21bff8ae3a18cadfc1b4da2dfe70f686083a…
commit 21bff8ae3a18cadfc1b4da2dfe70f686083a40d6
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Mon May 23 21:38:51 2011 +0200
Fix GP_Blit generation
diff --git a/core/gen/gen_blit.py b/core/gen/gen_blit.py
index df9c4b4..519bfb2 100644
--- a/core/gen/gen_blit.py
+++ b/core/gen/gen_blit.py
@@ -61,7 +61,7 @@ def gen_blit_same_t(size, size_suffix, header, code):
" if (al1 != 0)n"
" GP_SET_BITS(al1, 8-al1, *p2, GP_GET_BITS(al1, 8-al1, *p1));n"
" memcpy(p2+(al1!=0), p1+(al1!=0), copy_size);n"
- " if (end_al != 0) {n"
+ " if (end_al != 0)n"
" GP_SET_BITS(0, end_al, *end_p2, GP_GET_BITS(0, end_al, *end_p1));n"
" p1 += c1->bytes_per_row;n"
" end_p1 += c1->bytes_per_row;n"
diff --git a/core/gen/make_GP_Blit.py b/core/gen/make_GP_Blit.py
index 22f3f82..9d103ac 100644
--- a/core/gen/make_GP_Blit.py
+++ b/core/gen/make_GP_Blit.py
@@ -21,6 +21,7 @@ gen_headers(h, c,
c.append('#include <stdio.h>n')
c.append('#include <string.h>n')
c.append('#include "GP_Pixel.h"n')
+c.append('#include "GP.h"n')
c.append('#include "GP_Context.h"n')
c.append('#include "GP_Blit.gen.h"n')
http://repo.or.cz/w/gfxprim.git/commit/9d70f761d257857c896cff683236def3bf11…
commit 9d70f761d257857c896cff683236def3bf1133b3
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Mon May 23 21:36:38 2011 +0200
Tweak PixelType definitons
diff --git a/core/GP_Pixel.h b/core/GP_Pixel.h
index 5171d47..feb7eac 100644
--- a/core/GP_Pixel.h
+++ b/core/GP_Pixel.h
@@ -56,6 +56,18 @@ typedef uint32_t GP_Pixel;
#include "GP_Pixel.gen.h"
/*
+ * Information about ordering of pixels in byte for 1, 2 and 4 bpp
+ * used in a one bit variable in GP_Context
+ */
+
+typedef enum {
+ /* less significant bits contain pixels with lower indices */
+ GP_BIT_ENDIAN_LE = 0,
+ /* more significant bits contain pixels with lower indices */
+ GP_BIT_ENDIAN_BE,
+} GP_BIT_ENDIAN;
+
+/*
* Description of one channel
* Assumes all the channel names to be at most 7 chars long
*
@@ -68,45 +80,41 @@ typedef uint32_t GP_Pixel;
typedef struct {
char name[8]; /* Channel name */
- int offset; /* Offset in bits */
- int size; /* Bit-size */
+ uint8_t offset; /* Offset in bits */
+ uint8_t size; /* Bit-size */
} GP_PixelTypeChannel;
/*
+ * Maximum number of channels in a PixelType
+ */
+
+#define GP_PIXELTYPE_MAX_CHANNELS 8
+
+/*
* Description of one PixelType
* Assumes name with at most 15 chars
* Assumes at most 8 channels
*/
typedef struct {
- GP_PixelType type; /* Number of the type */
- const char name[16]; /* Name */
- int size; /* Size in bits */
- int bit_endian; /* Order of pixels in a byte */ /**TODO : add proper type !! */
- int numchannels; /* Number of channels */
- const char bitmap[36]; /* String describing the bit-representaton (as in "RRRRRGGGGGGBBBBB")*/
- const GP_PixelTypeChannel channels[8]; /* Individual channels */
+ GP_PixelType type; /* Number of the type */
+ const char name[16]; /* Name */
+ uint8_t size; /* Size in bits */
+ GP_BIT_ENDIAN bit_endian; /* Order of pixels in a byte */
+ uint8_t numchannels; /* Number of channels */
+ /* String describing the bit-representaton (as in "RRRRRGGGGGGBBBBB")*/
+ const char bitmap[sizeof(GP_Pixel) * 8 + 1];
+ /* Individual channels */
+ const GP_PixelTypeChannel channels[GP_PIXELTYPE_MAX_CHANNELS];
} GP_PixelTypeDescription;
/*
- * Array of GP_PIXEL_MAX entries
+ * Array of size GP_PIXEL_MAX describing known pixel types
*/
extern const GP_PixelTypeDescription const GP_PixelTypes[];
/*
- * Information about ordering of pixels in byte for 1, 2 and 4 bpp
- * used in a one bit variable in GP_Context
- */
-
-typedef enum {
- /* less significant bits contain pixels with lower indices */
- GP_BIT_ENDIAN_LE = 0,
- /* more significant bits contain pixels with lower indices */
- GP_BIT_ENDIAN_BE,
-} GP_BIT_ENDIAN;
-
-/*
* Convert pixel type to name.
*/
http://repo.or.cz/w/gfxprim.git/commit/ed742c11ffda92c31b8fd354d96ff2b07e9a…
commit ed742c11ffda92c31b8fd354d96ff2b07e9a61bf
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Mon May 23 21:35:13 2011 +0200
Fix transform bugs, add docs to GP_Transform.h
diff --git a/core/GP_Transform.h b/core/GP_Transform.h
index 935b771..152253d 100644
--- a/core/GP_Transform.h
+++ b/core/GP_Transform.h
@@ -21,32 +21,49 @@
* *
* Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
* *
+ * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
+ * *
*****************************************************************************/
#ifndef GP_TRANSFORM_H
#define GP_TRANSFORM_H
+/*
+ * Flip a coordinate within context according to context transformation.
+ */
#define GP_TRANSFORM_X(context, x) do { if ((context)->x_swap) - x = (context)->w - x; + x = (context)->w - x - 1; } while (0)
#define GP_TRANSFORM_Y(context, y) do { if ((context)->y_swap) - y = (context)->h - y; + y = (context)->h - y - 1; } while (0)
+/*
+ * Swap coordinates (axes) according to context transformation.
+ */
#define GP_TRANSFORM_SWAP(context, x, y) do { if ((context)->axes_swap) GP_SWAP(x, y); } while (0)
+/*
+ * Transform "user"-coordinates to "real"-coordinates according to context
+ * transformation.
+ */
#define GP_TRANSFORM_POINT(context, x, y) do { GP_TRANSFORM_SWAP(context, x, y); GP_TRANSFORM_X(context, x); GP_TRANSFORM_Y(context, y); } while (0)
+/*
+ * Transform "user"-coordinates to "real"-coordinates of a rectangle corner
+ * according to context transformation. Corner with min-coordinates is
+ * transformed to (different) corner with min-coordinates etc.
+ */
#define GP_TRANSFORM_RECT(context, x, y, rw, rh) do { GP_TRANSFORM_SWAP(context, x, y); GP_TRANSFORM_SWAP(context, w, h); @@ -59,8 +76,8 @@
} while (0)
/*
- * Inverse transformation. Use for translating mouse pointer coordinates to
- * coordinates on context.
+ * Inverse transformation to GP_TRANSFORM_POINT.
+ * Use for translating mouse pointer coordinates to coordinates on context.
*/
#define GP_RETRANSFORM_POINT(context, x, y) do { GP_TRANSFORM_X(context, x);
http://repo.or.cz/w/gfxprim.git/commit/c06d997dec540789eee858038b0e0f64c403…
commit c06d997dec540789eee858038b0e0f64c40328b3
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Mon May 23 21:34:34 2011 +0200
Cleanup and minor edits of core code
diff --git a/core/GP_Common.h b/core/GP_Common.h
index d077f33..cbfaf9b 100644
--- a/core/GP_Common.h
+++ b/core/GP_Common.h
@@ -146,8 +146,10 @@
#define GP_SET_BITS_OR(offset, dest, val) ( (dest) |= ((val)<<(offset)) )
-#define GP_SET_BITS(offset, count, dest, val) (GP_CLEAR_BITS(offset, count, dest), - GP_SET_BITS_OR(offset, dest, val) )
+#define GP_SET_BITS(offset, count, dest, val) do { + GP_CLEAR_BITS(offset, count, dest); + GP_SET_BITS_OR(offset, dest, val); + } while (0)
/* Determines the sign of the integer value; it is +1 if value is positive,
diff --git a/core/GP_Context.c b/core/GP_Context.c
index faaa64c..efe9ed3 100644
--- a/core/GP_Context.c
+++ b/core/GP_Context.c
@@ -27,11 +27,6 @@
#include <string.h>
-inline GP_PixelType GP_GetContextPixelType(const GP_Context *context)
-{
- return context->pixel_type;
-}
-
GP_Context *GP_ContextCopy(GP_Context *context, int flag)
{
GP_Context *new;
diff --git a/core/GP_Context.h b/core/GP_Context.h
index e5b5220..b356c59 100644
--- a/core/GP_Context.h
+++ b/core/GP_Context.h
@@ -32,6 +32,10 @@
#include "GP_Common.h"
#include "GP_Pixel.h"
+/* Integer type for coordinates: x, y, width, height, ...
+ * Should be signed to hold negative values as well. */
+typedef int GP_Coord;
+
/* This structure holds all information needed for drawing into an image. */
typedef struct GP_Context {
uint8_t *pixels; /* pointer to image pixels */
@@ -58,7 +62,10 @@ typedef struct GP_Context {
} GP_Context;
/* Returns the pixel type used by the context. */
-inline GP_PixelType GP_GetContextPixelType(const GP_Context *context);
+static inline GP_PixelType GP_GetContextPixelType(const GP_Context *context)
+{
+ return context->pixel_type;
+}
/* Determines the address of a pixel within the context's image.
* Rows and columns are specified in the image's orientation
@@ -136,23 +143,13 @@ void GP_ContextFlagsRotateCCW(GP_Context *context);
*/
static inline uint32_t GP_ContextW(GP_Context *context)
{
- return context->w;
-}
-
-static inline uint32_t GP_ContextH(GP_Context *context)
-{
- return context->h;
-}
-
-static inline uint32_t GP_TContextW(GP_Context *context)
-{
if (context->axes_swap)
return context->h;
else
return context->w;
}
-static inline uint32_t GP_TContextH(GP_Context *context)
+static inline uint32_t GP_ContextH(GP_Context *context)
{
if (context->axes_swap)
return context->w;
diff --git a/core/GP_Pixel.h b/core/GP_Pixel.h
index 31c6400..5171d47 100644
--- a/core/GP_Pixel.h
+++ b/core/GP_Pixel.h
@@ -30,6 +30,7 @@
#include <stdint.h>
#include "GP_Color.h"
+#include "GP_Common.h"
#include "GP_RetCode.h"
struct GP_Context;
http://repo.or.cz/w/gfxprim.git/commit/45b543a87a205f931395839e32415a0ca76b…
commit 45b543a87a205f931395839e32415a0ca76b0978
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Mon May 23 00:15:36 2011 +0200
Fix up tests (issue with aliasing remains)
diff --git a/tests/core/GP_Comon.test.c b/tests/core/GP_Comon.test.c
index e99cf3d..0fe2b1f 100644
--- a/tests/core/GP_Comon.test.c
+++ b/tests/core/GP_Comon.test.c
@@ -23,6 +23,7 @@
#include "GP_Tests.h"
#include <GP_Common.h>
+#include <unistd.h>
/*
* Demo ("testing" ;-) tests for GP_Common.h
@@ -52,7 +53,7 @@ GP_ENDTEST
GP_TEST(set_bits)
{
uint32_t x = 0x89ABC;
- uint16_t *y = (uint16_t*) &x;
+ uint16_t *y = (uint16_t*) &x;
GP_CLEAR_BITS(3, 4, x);
fail_unless(x == 0x89A84);
GP_SET_BITS_OR(10, x, 0x0000000);
@@ -61,12 +62,21 @@ GP_TEST(set_bits)
fail_unless(x == 0xF1089A84);
/* Check that only uint16_t is affected */
GP_SET_BITS(0, 24, *y, 0x100F000LL);
+# if __BYTE_ORDER == __BIG_ENDIAN
fail_unless(x == 0xF108F000);
+# else
+ fail_unless(x == 0x100F9A84);
+# endif
}
GP_ENDTEST
-GP_TEST(abort_check_assert, "loop_start=0, loop_end=9, expect_exit=1")
+GP_TEST(abort_check_assert, "loop_start=0, loop_end=9, expect_signal=6")
{
+ /* Prevent output during testing */
+# ifdef stderr
+# undef stderr
+# endif
+# define stderr stdin
if (_i==0) GP_ABORT();
if (_i==1) GP_ABORT("MSG");
if (_i==2) GP_ABORT("FORMAT %d", _i);
diff --git a/tests/core/Makefile b/tests/core/Makefile
index b1da0ed..2911629 100644
--- a/tests/core/Makefile
+++ b/tests/core/Makefile
@@ -14,11 +14,11 @@ include $(TOPDIR)/app.mk
TEST_SRCS=$(wildcard *.test.c)
TEST_OBJS=$(patsubst %.c,%.o,$(TEST_SRCS))
-
+TESTS=core_tests
CLEAN+=core_tests.gen.c
run: $(TESTS)
- for test in $(TESTS); do LD_LIBRARY_PATH=../ ./"$$test" -v ; done
+ for test in $(TESTS); do LD_LIBRARY_PATH=../../build ./"$$test" -v ; done
core_tests.gen.c: $(TEST_SRCS) find_tests.py
ifdef VERBOSE
http://repo.or.cz/w/gfxprim.git/commit/da0b966559ef04b7d53d080fefe9b99ddd70…
commit da0b966559ef04b7d53d080fefe9b99ddd7097a0
Merge: cc61bfd ca86f29
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sun May 22 23:32:51 2011 +0200
Merge branch 'master' of git://repo.or.cz/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/cc61bfdb1d208cdc21b01d7335604049a94d…
commit cc61bfdb1d208cdc21b01d7335604049a94db9ca
Merge: 6dee12b 3cefa39
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sun May 22 22:35:05 2011 +0200
Merge branch 'master' of git://repo.or.cz/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/6dee12b408a53004c3f5a74d265696d8ce3e…
commit 6dee12b408a53004c3f5a74d265696d8ce3edd47
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sun May 22 20:37:45 2011 +0200
Stop %'s in GP_ASSERT() from breaking printf format
A bit ugly (extra internal macro + extra parameter)
Also added spaces to avoid "empty printf format" warning
diff --git a/core/GP_Common.h b/core/GP_Common.h
index d077f33..8560a7f 100644
--- a/core/GP_Common.h
+++ b/core/GP_Common.h
@@ -63,33 +63,42 @@
#endif
/*
- * Aborts and prints the message along with the location in code
- * to stderr. Used for fatal errors.
+ * Internal macros with common code for GP_ABORT, GP_ASSERT and GP_CHECK.
+ * GP_INTERNAL_ABORT takes a message that may contain % (e.g. assert condition)
+ * and prints:
+ * "*** gfxprim: __FILE__:__LINE__: in __FUNCTION__: str_abort_msg_" format(__VA_ARGS__) "n"
*
- * Use as either GP_ABORT(), GP_ABORT(msg) or GP_ABORT(format, params...) where
- * msg and format must be string constants.
+ * GP_GENERAL_CHECK is a check with specified message prefix (for assert and check)
*/
-#define GP_ABORT(...) do { - fprintf(stderr, "*** gfxprim: %s:%d: in %s: ", - __FILE__, __LINE__, __FUNCTION__); - fprintf(stderr, "" __VA_ARGS__); +
+#define GP_INTERNAL_ABORT(str_abort_msg_, ...) do { + fprintf(stderr, "*** gfxprim: %s:%d: in %s: %s", + __FILE__, __LINE__, __FUNCTION__, str_abort_msg_); if (! (#__VA_ARGS__ [0])) fprintf(stderr, "abort()"); + else + fprintf(stderr, " " __VA_ARGS__); fprintf(stderr, "n"); abort(); } while (0)
+#define GP_GENERAL_CHECK(check_cond_, check_message_, ...) do { + if (unlikely(!(check_cond_))) { + if (#__VA_ARGS__ [0]) + GP_INTERNAL_ABORT(check_message_ #check_cond_, "n" __VA_ARGS__); + else + GP_INTERNAL_ABORT(check_message_ #check_cond_, " "); + } + } while (0)
+
/*
- * Internal macro with common code for GP_ASSERT and GP_CHECK.
+ * Aborts and prints the message along with the location in code
+ * to stderr. Used for fatal errors.
+ *
+ * Use as either GP_ABORT(), GP_ABORT(msg) or GP_ABORT(format, params...) where
+ * msg and format must be string constants.
*/
-#define GP_GENERAL_CHECK(check_cond_, check_message_, ...) do { - if (unlikely(!(check_cond_))) { - if (#__VA_ARGS__ [0]) - GP_ABORT(check_message_ #check_cond_ "n" __VA_ARGS__); - else - GP_ABORT(check_message_ #check_cond_); - } -} while (0)
+#define GP_ABORT(...) GP_INTERNAL_ABORT("", ##__VA_ARGS__)
/*
* Checks the condition and aborts immediately if it is not satisfied,
diff --git a/core/tests/GP_Comon.test.c b/core/tests/GP_Comon.test.c
index 7cdc22e..e99cf3d 100644
--- a/core/tests/GP_Comon.test.c
+++ b/core/tests/GP_Comon.test.c
@@ -77,13 +77,14 @@ GP_TEST(abort_check_assert, "loop_start=0, loop_end=9, expect_exit=1")
if (_i==7) GP_CHECK(1==0, "MSG");
if (_i==8) GP_CHECK(1==0, "FORMAT %d", _i);
}
-END_TEST
+GP_ENDTEST
GP_TEST(assert_check_nop)
{
- GP_ASSERT(1);
- GP_ASSERT(1, "MSG");
- GP_CHECK(1);
- GP_CHECK(1, "MSG");
+ /* Also tests % in conditon */
+ GP_ASSERT(7 % 3 == 1);
+ GP_ASSERT(7 % 3 == 1, "MSG");
+ GP_CHECK(7 % 3 == 1);
+ GP_CHECK(7 % 3 == 1, "MSG");
}
GP_ENDTEST
http://repo.or.cz/w/gfxprim.git/commit/d984c76e6650ed7d005745e36ccb6e029eb6…
commit d984c76e6650ed7d005745e36ccb6e029eb634d3
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sun May 22 20:01:49 2011 +0200
Minor extension to testing
doc comment, example and special END_TEST macro
diff --git a/core/tests/GP_Comon.test.c b/core/tests/GP_Comon.test.c
index 9faa290..7cdc22e 100644
--- a/core/tests/GP_Comon.test.c
+++ b/core/tests/GP_Comon.test.c
@@ -38,7 +38,7 @@ GP_TEST(min_max)
fail_unless(GP_MAX(x++, ++y) == 1);
fail_unless(x == 1 && y == 1);
}
-END_TEST
+GP_ENDTEST
GP_TEST(get_bits)
{
@@ -47,7 +47,7 @@ GP_TEST(get_bits)
fail_unless(GP_GET_BITS(16, 16, 0x1234) == 0);
fail_unless(GP_GET_BITS(1, 32, 0x12345678ULL) == 0x091A2B3CULL);
}
-END_TEST
+GP_ENDTEST
GP_TEST(set_bits)
{
@@ -63,7 +63,7 @@ GP_TEST(set_bits)
GP_SET_BITS(0, 24, *y, 0x100F000LL);
fail_unless(x == 0xF108F000);
}
-END_TEST
+GP_ENDTEST
GP_TEST(abort_check_assert, "loop_start=0, loop_end=9, expect_exit=1")
{
@@ -86,4 +86,4 @@ GP_TEST(assert_check_nop)
GP_CHECK(1);
GP_CHECK(1, "MSG");
}
-END_TEST
+GP_ENDTEST
diff --git a/core/tests/GP_Tests.h b/core/tests/GP_Tests.h
index 1735f60..d24b5f6 100644
--- a/core/tests/GP_Tests.h
+++ b/core/tests/GP_Tests.h
@@ -20,6 +20,26 @@
* *
*****************************************************************************/
+/*
+ * Wrappers around check.h unit-test library
+ *
+ * Create a .test.c file with (example):
+ *
+ * GP_SUITE(suite_name)
+ *
+ * GP_TEST(test1)
+ * {
+ * fail_unless(1 == 1);
+ * fail_if(1 < 0, "Impossible!");
+ * int i = 3;
+ * if (1 + 1 == i) fail("Arrgh, 1 + 1 is %d", i);
+ * }
+ * GP_ENDTEST
+ *
+ * The tests are collected automatically by find_tests.py.
+ * See below for more options.
+ */
+
#include <check.h>
/*
@@ -46,6 +66,8 @@
void GP_TEST_##name(int i) {name(i);} START_TEST(name)
+#define GP_ENDTEST END_TEST
+
/*
* Helper macro to allow auto-generation of suites.
* Defines suite from this point until EOF or redefinition.
diff --git a/core/tests/font.test.c b/core/tests/font.test.c
index b368454..7775ab8 100644
--- a/core/tests/font.test.c
+++ b/core/tests/font.test.c
@@ -54,5 +54,5 @@ GP_TEST(load_save)
/* cleanup */
fail_unless(unlink(FONT_FILE) == 0);
}
-END_TEST
+GP_ENDTEST
http://repo.or.cz/w/gfxprim.git/commit/cbe54b1ef522cf97d90f0d4e7c909884e96f…
commit cbe54b1ef522cf97d90f0d4e7c909884e96ffde6
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sun May 22 19:58:09 2011 +0200
Adapt gen/ for bit-endianness
diff --git a/core/gen/gen_blit.py b/core/gen/gen_blit.py
index 78de911..df9c4b4 100644
--- a/core/gen/gen_blit.py
+++ b/core/gen/gen_blit.py
@@ -7,29 +7,30 @@ from gen_utils import *
## all generated direct blits, for generating GP_Blit() and others
generated_blits = []
-# TODO: adapt for both bit-endianness
+# TODO: adapt for both bit-endianness (in-byte prefix and suffix)
# WARN: assuming little-endian in sub-byte pixels order (probably)
-def gen_blit_same_t(size, header, code):
- "Generate a function blitting the same type of pixel"
- "Only depends on bpp (bit size)"
+def gen_blit_same_t(size, size_suffix, header, code):
+ "Generate a function blitting the same type of pixel."
+ "Only depends on bpp (bit size), size_suffix must be"
+ "of form 8BPP, 2BPP_LE and the like."
header.append(r(
- "n/*** Blit preserving type, variant for {{ size }}bpp ***n"
+ "n/*** Blit preserving type, variant for {{ size_suffix }} ***n"
" * Assumes the contexts to be of the right types and sizesn"
" * Ignores transformations and clipping */nn"
- "void GP_Blit_{{ size }}bpp(const GP_Context *c1, int x1, int y1, int w, int h,n"
+ "void GP_Blit_{{ size_suffix }}(const GP_Context *c1, int x1, int y1, int w, int h,n"
" GP_Context *c2, int x2, int y2);n",
- size=size))
+ size=size, size_suffix=size_suffix))
code.append(r(
- "n/*** Blit preservimg type, variant for {{ size }} bpp ***/n"
- "void GP_Blit_{{ size }}bpp(const GP_Context *c1, int x1, int y1, int w, int h,n"
+ "n/*** Blit preservimg type, variant for {{ size_suffix }} ***/n"
+ "void GP_Blit_{{ size_suffix }}(const GP_Context *c1, int x1, int y1, int w, int h,n"
" GP_Context *c2, int x2, int y2)n"
"{n"
" if (unlikely(w == 0 || h == 0)) return;nn"
" /* Special case - copy whole line-block with one memcpy() */n"
- " if (x1 == 0 && x2 == 0 && w == c1->w && c1->w == c2->w &&n"
- " c1->bytes_per_row == c2->bytes_per_row) {n"
+ " if ((x1 == 0) && (x2 == 0) && (w == c1->w) && (c1->w == c2->w) &&n"
+ " (c1->bytes_per_row == c2->bytes_per_row)) {n"
" memcpy(c2->pixels + c2->bytes_per_row * y2,n"
" c1->pixels + c1->bytes_per_row * y1,n"
" c1->bytes_per_row * h);n"
@@ -38,24 +39,25 @@ def gen_blit_same_t(size, header, code):
"{% if size>=8 %}"
" /* General case - memcpy() each horizontal line */n"
" for (int i=0; i<h; i++)n"
- " memcpy(GP_PIXEL_ADDR_{{ size }}bpp(c2, x2, y2 + i), n"
- " GP_PIXEL_ADDR_{{ size }}bpp(c1, x2, y2 + i),n"
+ " memcpy(GP_PIXEL_ADDR_{{ size_suffix }}(c2, x2, y2 + i), n"
+ " GP_PIXEL_ADDR_{{ size_suffix }}(c1, x2, y2 + i),n"
" {{ size/8 }} * w);n"
"{% else %}" # subtle - rectangles may not be byte aligned in the same way
- " /* Number of bits in the first byte */n"
- " int al1 = GP_PIXEL_ADDR_OFFSET(x1);n"
- " int al2 = GP_PIXEL_ADDR_OFFSET(x2);n"
- " if (al1 == al2) {n"
- " /* Number of bits in the last byte */n"
- " int end_al = GP_PIXEL_ADDR_OFFSET(x1 + w);n"
- " assert((w - al1 - end_al) % {{ ppb }} == 0);n"
- " int copy_size = (w - al1 - end_al) / {{ ppb }};n"
+ " /* Alignment (index) of first bits in the first byte */n"
+ " int al1 = GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x1);n"
+ " int al2 = GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x2);n"
+ " /* Special case of the same alignment and width >=2 bytes */n"
+ " if ((al1 == al2) && (w * {{ size }} >= 16)) {n"
+ " /* Number of bits in the last partial byte */n"
+ " int end_al = GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x1 + w);n"
+ " GP_ASSERT(({{ size }} * w - al1 - end_al) % 8 == 0);n"
+ " int copy_size = ({{ size }} * w - al1 - end_al) / 8;n"
" /* First and last byte incident to the line */n"
- " uint8_t *p1 = GP_PIXEL_ADDR_{{ size }}bpp(c1, x1, y1);n"
- " uint8_t *p2 = GP_PIXEL_ADDR_{{ size }}bpp(c2, x2, y2);n"
- " uint8_t *end_p1 = GP_PIXEL_ADDR_{{ size }}bpp(c1, x1 + w - 1, y1);n"
- " uint8_t *end_p2 = GP_PIXEL_ADDR_{{ size }}bpp(c2, x2 + w - 1, y2);n"
- " for (int i=0; i<h; i++) {n"
+ " uint8_t *p1 = GP_PIXEL_ADDR_{{ size_suffix }}(c1, x1, y1);n"
+ " uint8_t *p2 = GP_PIXEL_ADDR_{{ size_suffix }}(c2, x2, y2);n"
+ " uint8_t *end_p1 = GP_PIXEL_ADDR_{{ size_suffix }}(c1, x1 + w - 1, y1);n"
+ " uint8_t *end_p2 = GP_PIXEL_ADDR_{{ size_suffix }}(c2, x2 + w - 1, y2);n"
+ " for (int i = 0; i < h; i++) {n"
" if (al1 != 0)n"
" GP_SET_BITS(al1, 8-al1, *p2, GP_GET_BITS(al1, 8-al1, *p1));n"
" memcpy(p2+(al1!=0), p1+(al1!=0), copy_size);n"
@@ -66,20 +68,10 @@ def gen_blit_same_t(size, header, code):
" p2 += c2->bytes_per_row;n"
" end_p2 += c2->bytes_per_row;n"
" }n"
-# " /* Check for source strip inside just one byte */n"
-# " if (x1 / {{ ppb }} == (x1 + w - 1) / {{ ppb }}) {n"
-# " int bwidth = w * {{ size }};n"
-# " uint8_t v1 = ((* GP_PIXEL_ADDR_{{ size }}bpp(c1, x1, y1)) <<n"
-# " GP_PIXEL_ADDR_OFFSET_{{ size }}bpp(x1)) >>n"
-# " GP_PIXEL_ADDR_OFFSET_{{ size }}bpp(x2);n"
-# " uint8_t *p2 = GP_PIXEL_ADDR_{{ size }}bpp(c2, x2, y2);n"
-# " "
-# " GP_SET_BITS(
-# " /// TODO: CHECK for narrow lines, these are special-case
" } else /* Different bit-alignment, can't use memcpy() */n"
- " GP_Blit_V{{ size }}(c1, x1, y1, w, h, c2, x2, y2);n"
+ " GP_Blit_Naive(c1, x1, y1, w, h, c2, x2, y2);n"
"{% endif %}"
- "}n", size=size, ppb=8/size))
+ "}n", size=size, size_suffix=size_suffix))
def gen_blit_t(f1, f2, header, code):
diff --git a/core/gen/gen_pixeltype.py b/core/gen/gen_pixeltype.py
index b677d45..683fe87 100644
--- a/core/gen/gen_pixeltype.py
+++ b/core/gen/gen_pixeltype.py
@@ -21,7 +21,7 @@ def str_description(ptype):
return r(
"/* Automatically generated code for pixel type {{ f.name }}n"
" *n"
- " * Size (bpp): {{ f.size }}n"
+ " * Size (bpp): {{ f.size }} ({{ f.size_suffix }})n"
"{% if f.size<8 %} * Bit endian: {{ f.bit_endian }}n{% endif %}"
" * Pixel structure: {{ ''.join(f.bits) }}n"
" * Channels: n"
@@ -148,35 +148,31 @@ def gen_get_pixel_addr(ptype, header, code):
"Generate GP_PIXEL_ADDR_<TYPE> and _OFFSET_<TYPE> macros"
header.append(r(
"/* macro to get address of pixel {{ f.name }} in a context */n"
- "#define GP_PIXEL_ADDR_{{ f.name }}(context, x, y) GP_PIXEL_ADDR_{{ f.size }}bpp(context, x, y)n"
+ "#define GP_PIXEL_ADDR_{{ f.name }}(context, x, y) GP_PIXEL_ADDR_{{ f.size_suffix }}(context, x, y)n"
"/* macro to get bit-offset of pixel {{ f.name }} */n"
- "{% if f.size<8 %}"
- "#define GP_PIXEL_ADDR_OFFSET_{{ f.name }}(x)
"
- " GP_PIXEL_ADDR_OFFSET_{{ f.size }}bpp(x)n"
- "{% else %}" # bit_endian matters
- "#define GP_PIXEL_ADDR_OFFSET_{{ f.name }}(x)
"
- " GP_PIXEL_ADDR_OFFSET_{{ f.size }}bpp_{{ f.bit_endian }}(x)n"
- "{% endif %}",
+ "#define GP_PIXEL_ADDR_OFFSET_{{ f.name }}(x)
"
+ " GP_PIXEL_ADDR_OFFSET_{{ f.size_suffix }}(x)n",
f=ptype))
-def gen_get_pixel_addr_bpp(size, bit_endian, header, code):
- "Generate GP_PIXEL_ADDR_<SIZE>bpp and _OFFSET_<SIZE>bpp macros"
- assert bit_endian in ['BE','LE']
+def gen_get_pixel_addr_bpp(size, size_suffix, header, code):
+ "Generate GP_PIXEL_ADDR_<size_suffix> and _OFFSET_<size_suffix> macros"
+ bit_endian = size_suffix[-2:]
+ if size < 8:
+ assert bit_endian in ['LE', 'BE']
header.append(r(
- "/* macro to get address of pixel in a {{ size }}bpp context */n"
- "#define GP_PIXEL_ADDR_{{ size }}bpp(context, x, y)
"
+ "/* macro to get address of pixel in a {{ size_suffix }} context */n"
+ "#define GP_PIXEL_ADDR_{{ size_suffix }}(context, x, y)
"
" ((context)->pixels + (context)->bytes_per_row * (y) + {{ size//8 }} * (x))n"
- "/* macro to get bit-offset of pixel in {{ size }}bpp context */n"
- "{% if size>=8 %}"
- "#define GP_PIXEL_ADDR_OFFSET_{{ size }}bpp(x) (0)n"
+ "/* macro to get bit-offset of pixel in {{ size_suffix }} context */n"
+ "{% if size >= 8 %}"
+ "#define GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x) (0)n"
"{% else %}" # bit_endian matters
"{% if bit_endian=='LE' %}"
- "#define GP_PIXEL_ADDR_OFFSET_{{ size }}bpp(x)
"
+ "#define GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x)
"
" (((x) % {{ 8//size }}) * {{ size }})n"
"{% else %}"
- "#define GP_PIXEL_ADDR_OFFSET_{{ size }}bpp(x)
"
+ "#define GP_PIXEL_ADDR_OFFSET_{{ size_suffix }}(x)
"
" ({{ 8-size }} - ((x) % {{ 8//size }}) * {{ size }})n"
"{% endif %}"
"{% endif %}",
- size=size, bit_endian=bit_endian))
-
+ size=size, size_suffix=size_suffix, bit_endian=bit_endian))
diff --git a/core/gen/make_GP_Blit.py b/core/gen/make_GP_Blit.py
index a439898..22f3f82 100644
--- a/core/gen/make_GP_Blit.py
+++ b/core/gen/make_GP_Blit.py
@@ -19,12 +19,15 @@ gen_headers(h, c,
hdef = "GP_PIXEL_BLIT_GEN_H")
c.append('#include <stdio.h>n')
+c.append('#include <string.h>n')
c.append('#include "GP_Pixel.h"n')
c.append('#include "GP_Context.h"n')
c.append('#include "GP_Blit.gen.h"n')
for bpp in bitsizes:
- gen_blit_same_t(bpp, h, c)
+ for bit_endian in bit_endians:
+ if (bpp < 8) or (bit_endian == bit_endians[0]):
+ gen_blit_same_t(bpp, get_size_suffix(bpp, bit_endian), h, c)
## Close the files
diff --git a/core/gen/make_GP_Pixel.py b/core/gen/make_GP_Pixel.py
index e09ba13..a0be576 100644
--- a/core/gen/make_GP_Pixel.py
+++ b/core/gen/make_GP_Pixel.py
@@ -19,6 +19,7 @@ gen_headers(h, c,
hdef = "GP_PIXEL_GEN_H")
c.append('#include <stdio.h>n')
+c.append('#include <GP.h>n')
c.append('#include "GP_Pixel.h"n')
## Enum of types
@@ -44,11 +45,9 @@ for t in pixeltypes.values():
# Per-bpp macros
for bpp in bitsizes:
- if bpp>=8:
- gen_get_pixel_addr_bpp(bpp, 'LE', h, c)
- else: # bit_endian matters
- for be in bit_endians:
- gen_get_pixel_addr_bpp(bpp, be, h, c)
+ for bit_endian in bit_endians:
+ if (bpp < 8) or (bit_endian == bit_endians[0]):
+ gen_get_pixel_addr_bpp(bpp, get_size_suffix(bpp, bit_endian), h, c)
## Conversion macros
diff --git a/core/gen/pixeltype.py b/core/gen/pixeltype.py
index 677ca52..3e85dfe 100644
--- a/core/gen/pixeltype.py
+++ b/core/gen/pixeltype.py
@@ -25,13 +25,22 @@ bitsizes = [1,2,4,8,16,24,32]
## bit_endian values
bit_endians = ['LE', 'BE']
+## Create pixel-size suffix (16BPP or 4BPP_LE)
+def get_size_suffix(bpp, bit_endian):
+ assert bpp in bitsizes
+ assert bit_endian in bit_endians
+ size_suffix = '%dBPP' % (bpp)
+ if bpp < 8:
+ size_suffix += '_' + bit_endian
+ return size_suffix
+
class PixelType(object):
"""Representation of one GP_PixelType"""
def __init__(self, name, size, chanslist, number=None, bit_endian=None):
"""`name` must be a valid C identifier
`size` is in bits, allowed are 1, 2, 4, 8, 16, 24, 32
- `bit_endian` is order of 1,2,4bpp pixels in a byte, either 'BE' or 'LE'
+ `bit_endian` is order of 1,2,4BPP pixels in a byte, either 'BE' or 'LE'
`chanslist` is a list of triplets describing individual channels as
[ (`chan_name`, `bit_offset`, `bit_size`) ]
`chan_name` is usually one of: R, G, B, V (value, used for grayscale), A (opacity)
@@ -52,6 +61,11 @@ class PixelType(object):
assert bit_endian in bit_endians
self.bit_endian = bit_endian
+ if self.size == 0:
+ self.size_suffix = "INVALID"
+ else:
+ self.size_suffix = get_size_suffix(self.size, self.bit_endian)
+
# Numbering from 1
if number is not None:
self.number = number
http://repo.or.cz/w/gfxprim.git/commit/3814872780477efda3b924604c52c6583f77…
commit 3814872780477efda3b924604c52c6583f77ecce
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sun May 22 16:36:27 2011 +0200
Fix type warning
diff --git a/core/GP_Counter.c b/core/GP_Counter.c
index 0f0d26b..a7809d3 100644
--- a/core/GP_Counter.c
+++ b/core/GP_Counter.c
@@ -54,12 +54,12 @@ void GP_PrintCounters(struct FILE *f)
int i;
GP_CHECK(f != NULL);
if (GP_used_counters == 0)
- fprintf(f, "[ no counters defined ]n");
+ fprintf((FILE *) f, "[ no counters defined ]n");
for (i = 0; i < GP_used_counters; i++)
- fprintf(f, "%*s : %lldn", -GP_COUNTER_NAME_LEN, GP_counter_list[i].name,
- *(GP_counter_list[i].counter));
+ fprintf((FILE *) f, "%*s : %lldn", -GP_COUNTER_NAME_LEN,
+ GP_counter_list[i].name, *(GP_counter_list[i].counter));
if (GP_counter_list_overflow > 0)
- fprintf(f, "[ unable to allocate new counter %lld times ]n",
+ fprintf((FILE *) f, "[ unable to allocate new counter %lld times ]n",
GP_counter_list_overflow);
#endif /* GP_IMPLEMENT_COUNTERS */
}
http://repo.or.cz/w/gfxprim.git/commit/0cfb5e91e793cb577881a8bfc1c5c61e5353…
commit 0cfb5e91e793cb577881a8bfc1c5c61e5353422b
Merge: 83881d0 44de9a4
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sun May 22 15:17:27 2011 +0200
Merge branch 'master' into generate
Conflicts:
core/GP_Common.h
diff --cc core/GP_FnPerBpp.h
index e97d54b,2a745e7..cad977c
--- a/core/GP_FnPerBpp.h
+++ b/core/GP_FnPerBpp.h
@@@ -30,38 -30,18 +30,33 @@@
* of the specified function depending on the bit depth of the context.
* Extra arguments are arguments to be passed to the function.
* Returns GP_ENOIMPL if the bit depth is unknown.
- *
- * Note: Relying on existing context variable is ugly and broken, I know...
- * But I hate doing just another GP_FN_PER_BPP macro for functions
- * that takes context as it's only argument. Or passing the context
- * twice or whatever else.
*/
- #define GP_FN_PER_BPP(FN_NAME, ...) + #define GP_FN_PER_BPP(FN_NAME, bpp, ...) - switch (context->bpp) { + switch (bpp) { case 1: - FN_NAME##1bpp(__VA_ARGS__); + { + if (context->bit_endian==GP_BIT_ENDIAN_LE) + FN_NAME##1bpp_LE(__VA_ARGS__); + else + FN_NAME##1bpp_BE(__VA_ARGS__); + } break; case 2: - FN_NAME##2bpp(__VA_ARGS__); + { + if (context->bit_endian==GP_BIT_ENDIAN_LE) + FN_NAME##2bpp_LE(__VA_ARGS__); + else + FN_NAME##2bpp_BE(__VA_ARGS__); + } break; case 4: - FN_NAME##4bpp(__VA_ARGS__); + { + if (context->bit_endian==GP_BIT_ENDIAN_LE) + FN_NAME##4bpp_LE(__VA_ARGS__); + else + FN_NAME##4bpp_BE(__VA_ARGS__); + } break; case 8: FN_NAME##8bpp(__VA_ARGS__); @@@ -76,35 -56,18 +71,33 @@@
FN_NAME##32bpp(__VA_ARGS__); break; default: - return GP_ENOIMPL; + break; } - - return GP_ESUCCESS;
- #define GP_FN_RET_PER_BPP(FN_NAME, ...) + #define GP_FN_RET_PER_BPP(FN_NAME, bpp, ...) - switch (context->bpp) { + switch (bpp) { case 1: - return FN_NAME##1bpp(__VA_ARGS__); + { + if (context->bit_endian==GP_BIT_ENDIAN_LE) + return FN_NAME##1bpp_LE(__VA_ARGS__); + else + return FN_NAME##1bpp_BE(__VA_ARGS__); + } case 2: - return FN_NAME##2bpp(__VA_ARGS__); + { + if (context->bit_endian==GP_BIT_ENDIAN_LE) + return FN_NAME##2bpp_LE(__VA_ARGS__); + else + return FN_NAME##2bpp_BE(__VA_ARGS__); + } case 4: - return FN_NAME##4bpp(__VA_ARGS__); + { + if (context->bit_endian==GP_BIT_ENDIAN_LE) + return FN_NAME##4bpp_LE(__VA_ARGS__); + else + return FN_NAME##4bpp_BE(__VA_ARGS__); + } case 8: return FN_NAME##8bpp(__VA_ARGS__); case 16: diff --cc core/Makefile
index 59d9a7e,b23dad4..cb2a01c
--- a/core/Makefile
+++ b/core/Makefile
@@@ -32,23 -33,6 +33,24 @@@ $(LIBRARY).so: $(OBJECTS
clean:
rm -f $(LIBRARY).a $(LIBRARY).so $(LIBRARY).so.0
rm -f *.o
+ rm -f ../backends/*.o
cd tests && $(MAKE) clean
+ rm -f $(GENERATED)
+
+
+GENERATORS=$(wildcard gen/*.py)
+GENERATED=GP_Pixel_Scale.gen.h + GP_Pixel.gen.c GP_Pixel.gen.h + GP_Blit.gen.h GP_Blit.gen.c
+
+GP_Pixel_Scale.gen.h: $(GENERATORS)
+ python gen/make_GP_Pixel_Scale.py GP_Pixel_Scale.gen.h
+
+GP_Pixel.gen.c GP_Pixel.gen.h: $(GENERATORS)
+ python gen/make_GP_Pixel.py GP_Pixel.gen.h GP_Pixel.gen.c
+
+GP_Blit.gen.c GP_Blit.gen.h: $(GENERATORS)
+ python gen/make_GP_Blit.py GP_Blit.gen.h GP_Blit.gen.c
+
+generated: $(GENERATED)
http://repo.or.cz/w/gfxprim.git/commit/83881d075d4d203f6949641c09d45d7f4ab6…
commit 83881d075d4d203f6949641c09d45d7f4ab6b6c0
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Apr 5 02:45:22 2011 +0200
Fixed, extended and tested GP_Counter
Fixed bug in GetCounter
Finished writing tests
Added GP_SetCounter
diff --git a/core/GP_Counter.c b/core/GP_Counter.c
index e5922d0..0f0d26b 100644
--- a/core/GP_Counter.c
+++ b/core/GP_Counter.c
@@ -21,6 +21,7 @@
*****************************************************************************/
#include <string.h>
+#include <stdio.h>
#include "GP_Common.h"
#include "GP_Counter.h"
@@ -47,10 +48,11 @@ static GP_Counter_t GP_counter_list_overflow = 0;
#endif /* GP_IMPLEMENT_COUNTERS */
-void GP_PrintCounters(FILE *f)
+void GP_PrintCounters(struct FILE *f)
{
#ifdef GP_IMPLEMENT_COUNTERS
int i;
+ GP_CHECK(f != NULL);
if (GP_used_counters == 0)
fprintf(f, "[ no counters defined ]n");
for (i = 0; i < GP_used_counters; i++)
@@ -73,7 +75,7 @@ GP_Counter GP_GetCounter(const char *name)
/* Bisect GP_counter_list to find either the counter or a place for it
* interval [l, r) (not incl. r) */
- while(r > l + 1) {
+ while(r > l) {
int med = (r + l) / 2; /* Here never equal to r, might be l */
int cmp = strcmp(GP_counter_list[med].name, name);
if (cmp == 0)
@@ -94,7 +96,7 @@ GP_Counter GP_GetCounter(const char *name)
}
/* Move the counter records up and initialize a new one */
- memmove(GP_counter_list + l, GP_counter_list + l + 1,
+ memmove(GP_counter_list + l + 1, GP_counter_list + l,
sizeof(struct GP_CounterRecord) * GP_used_counters - l);
strcpy(GP_counter_list[l].name, name);
GP_counter_list[l].counter = GP_counters + GP_used_counters;
diff --git a/core/GP_Counter.h b/core/GP_Counter.h
index 3c0358b..f9e501e 100644
--- a/core/GP_Counter.h
+++ b/core/GP_Counter.h
@@ -20,6 +20,9 @@
* *
*****************************************************************************/
+#ifndef GP_COUNTER_H
+#define GP_COUNTER_H
+
/*
* Simple global named 64-bit counters.
*
@@ -52,7 +55,7 @@ typedef GP_Counter_t *GP_Counter;
* Increase a counter by 1.
*/
-inline void GP_IncCounter(GP_Counter counter)
+static inline void GP_IncCounter(GP_Counter counter)
{
#ifdef GP_IMPLEMENT_COUNTERS
if (!counter) return;
@@ -65,7 +68,7 @@ inline void GP_IncCounter(GP_Counter counter)
* No checks for underflow.
*/
-inline void GP_AddCounter(GP_Counter counter, GP_Counter_t delta)
+static inline void GP_AddCounter(GP_Counter counter, GP_Counter_t delta)
{
#ifdef GP_IMPLEMENT_COUNTERS
if (!counter) return;
@@ -74,6 +77,18 @@ inline void GP_AddCounter(GP_Counter counter, GP_Counter_t delta)
}
/*
+ * Set counter to given value.
+ */
+
+static inline void GP_SetCounter(GP_Counter counter, GP_Counter_t value)
+{
+#ifdef GP_IMPLEMENT_COUNTERS
+ if (!counter) return;
+ (*counter) = value;
+#endif /* GP_IMPLEMENT_COUNTERS */
+}
+
+/*
* Return counter value
*/
@@ -92,7 +107,8 @@ inline GP_Counter_t GP_CounterVal(GP_Counter counter)
* Includes info about counter-list overflow
*/
-void GP_PrintCounters(FILE *f);
+struct FILE;
+void GP_PrintCounters(struct FILE *f);
/*
* Lookup a counter by name, possibly creating a new one.
@@ -106,3 +122,4 @@ void GP_PrintCounters(FILE *f);
GP_Counter GP_GetCounter(const char *name);
+#endif /* GP_COUNTER_H */
diff --git a/core/tests/GP_Counter.test.c b/core/tests/GP_Counter.test.c
index a334106..8f8ddd3 100644
--- a/core/tests/GP_Counter.test.c
+++ b/core/tests/GP_Counter.test.c
@@ -21,49 +21,60 @@
*****************************************************************************/
#include <string.h>
+#include <stdio.h>
-#include "GP_Test.h"
+#include "GP_Tests.h"
#include "GP_Counter.h"
GP_SUITE(GP_Counter)
GP_TEST(Smoke)
{
- fail_unless(GP_CounterVal(NULL) == 0);
- GP_IncCounter(NULL);
- GP_AddCounter(NULL, -10);
- fail_unless(GP_GetCounter("") != NULL);
+ fail_unless(GP_CounterVal(NULL) == 0);
+ GP_IncCounter(NULL);
+ GP_AddCounter(NULL, -10);
+ fail_unless(GP_GetCounter("") != NULL);
- GP_IncCounter(GP_GetCounter("a"));
- fail_unless(GP_CounterVal(GP_GetCounter("a")) == 1);
+ GP_IncCounter(GP_GetCounter("a"));
+ fail_unless(GP_CounterVal(GP_GetCounter("a")) == 1);
+
+ GP_PrintCounters(fopen("/dev/null","wt"));
}
+END_TEST
GP_TEST(Allocation)
{
- GP_IncCounter(GP_GetCounter("a"));
- GP_AddCounter(GP_GetCounter("e"), -42);
- GP_AddCounter(GP_GetCounter("b"), -8);
- GP_IncCounter(GP_GetCounter("a"));
- GP_IncCounter(GP_GetCounter("d"));
- GP_Counter b = GP_GetCounter("b");
- GP_AddCounter(GP_GetCounter("c"), 21);
- GP_IncCounter(GP_GetCounter("b"));
- GP_IncCounter(b);
-
- fail_unless(GP_CounterVal(GP_GetCounter("a")) == 2);
- fail_unless(GP_CounterVal(GP_GetCounter("b")) == -6);
- fail_unless(GP_CounterVal(GP_GetCounter("c")) == 21);
- fail_unless(GP_CounterVal(GP_GetCounter("d")) == 1);
- fail_unless(GP_CounterVal(GP_GetCounter("e")) == -42);
+ /* random-like operations with counters,
+ * should test reasonably many combinations */
+ GP_SetCounter(GP_GetCounter("a"), 11);
+ GP_AddCounter(GP_GetCounter("e"), -42);
+ GP_Counter b = GP_GetCounter("b");
+ GP_IncCounter(GP_GetCounter("a"));
+ GP_GetCounter("d");
+ GP_AddCounter(GP_GetCounter("c"), 21);
+ GP_IncCounter(GP_GetCounter("b"));
+ GP_AddCounter(GP_GetCounter("b"), -8);
+ GP_IncCounter(b);
+ GP_SetCounter(GP_GetCounter("f"), 91);
+ GP_SetCounter(GP_GetCounter("f"), -1);
+
+ fail_unless(GP_CounterVal(GP_GetCounter("a")) == 12);
+ fail_unless(GP_CounterVal(GP_GetCounter("b")) == -6);
+ fail_unless(GP_CounterVal(GP_GetCounter("c")) == 21);
+ fail_unless(GP_CounterVal(GP_GetCounter("d")) == 0);
+ fail_unless(GP_CounterVal(GP_GetCounter("e")) == -42);
+ fail_unless(GP_CounterVal(GP_GetCounter("f")) == -1);
}
+END_TEST
GP_TEST(Overflow)
{
- char buf[8];
- for (int i = 0; i < GP_COUNTER_MAX + 10; i++) {
- sprintf(buf, "%d", i);
- GP_GetCounter(buf);
- }
- fail_unless(GP_GetCounter("") == NULL);
+ char buf[8];
+ for (int i = 0; i < GP_COUNTER_MAX; i++) {
+ sprintf(buf, "%d", i);
+ fail_if(GP_GetCounter(buf) == NULL);
+ }
+ fail_unless(GP_GetCounter("next") == NULL);
}
+END_TEST
http://repo.or.cz/w/gfxprim.git/commit/e57fbf5bbbc9b4618c8ac015ac9986bd928f…
commit e57fbf5bbbc9b4618c8ac015ac9986bd928f797c
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Apr 5 02:42:53 2011 +0200
Remove code to be replaced
minor updates after bitendian merge
tests still compile only with lots of hacks
diff --git a/core/GP_Pixel.c b/core/GP_Pixel.c
index 79386c1..e7f4b80 100644
--- a/core/GP_Pixel.c
+++ b/core/GP_Pixel.c
@@ -25,230 +25,211 @@
#include "GP.h"
-struct PixelTypeInfo {
- const char *type_name; /* human-readable name */
- GP_ColorType color_type; /* color type used for this pixel type */
- unsigned int bits; /* how many bits the pixel occupies */
-};
-
-/* This table shows relations of pixel types to color types, their names
- * and bits per pixel.
- */
-static struct PixelTypeInfo pixel_type_infos[] = {
- { "Unknown pixel type", GP_NOCOLOR, 0 },
- { "Palette 4bit", GP_PAL4, 4 },
- { "Palette 8bit", GP_PAL8, 8 },
- { "Grayscale 1bit", GP_G1, 1 },
- { "Grayscale 2bits", GP_G2, 2 },
- { "Grayscale 4bits", GP_G4, 4 },
- { "Grayscale 8bits", GP_G8, 8 },
- { "RGB 555", GP_RGB555, 16 },
- { "BGR 555", GP_RGB555, 16 },
- { "RGB 565", GP_RGB565, 16 },
- { "BGR 565", GP_RGB565, 16 },
- { "RGB 888", GP_RGB888, 24 },
- { "BGR 888", GP_RGB888, 24 },
- { "XRGB 8888", GP_RGB888, 32 },
- { "RGBX 8888", GP_RGB888, 32 },
- { "XBGR 8888", GP_RGB888, 32 },
- { "BGRX 8888", GP_RGB888, 32 },
- { "ARGB 8888", GP_RGBA8888, 32 },
- { "RGBA 8888", GP_RGBA8888, 32 },
- { "ABGR 8888", GP_RGBA8888, 32 },
- { "BGRA 8888", GP_RGBA8888, 32 }
-};
-
-const char *GP_PixelTypeName(GP_PixelType type)
-{
- if (type >= GP_PIXEL_MAX)
- return "INVALID TYPE";
-
- return pixel_type_infos[type].type_name;
-}
-
-uint32_t GP_PixelSize(GP_PixelType type)
-{
- if (type >= GP_PIXEL_MAX)
- return 0;
-
- return pixel_type_infos[type].bits;
-}
-
-GP_ColorType GP_PixelTypeToColorType(GP_PixelType type)
-{
- if (type >= GP_PIXEL_MAX)
- return GP_COLMAX;
-
- return pixel_type_infos[type].color_type;
-}
-
-#define CHECK_RET(ret) if (ret != GP_ESUCCESS && ret != GP_EUNPRECISE) return ret;
-
-GP_RetCode GP_ColorToPixelType(GP_PixelType pixel_type, GP_Color color, GP_Pixel *pixel)
-{
- if (pixel == NULL)
- return GP_ENULLPTR;
-
- GP_RetCode ret;
-
- switch (pixel_type) {
- case GP_PIXEL_PAL4_LE:
- case GP_PIXEL_PAL4_BE:
- ret = GP_ColorConvert(&color, GP_PAL4);
- CHECK_RET(ret);
- *pixel = color.pal4.index;
- return ret;
- break;
- case GP_PIXEL_PAL8:
- ret = GP_ColorConvert(&color, GP_PAL8);
- CHECK_RET(ret);
- *pixel = color.pal8.index;
- return ret;
- break;
- case GP_PIXEL_G1_LE:
- case GP_PIXEL_G1_BE:
- ret = GP_ColorConvert(&color, GP_G1);
- CHECK_RET(ret);
- *pixel = color.g1.gray;
- return ret;
- break;
- case GP_PIXEL_G2_LE:
- case GP_PIXEL_G2_BE:
- ret = GP_ColorConvert(&color, GP_G2);
- CHECK_RET(ret);
- *pixel = color.g2.gray;
- return ret;
- break;
- case GP_PIXEL_G4_LE:
- case GP_PIXEL_G4_BE:
- ret = GP_ColorConvert(&color, GP_G4);
- CHECK_RET(ret);
- *pixel = color.g4.gray;
- return ret;
- break;
- case GP_PIXEL_G8:
- ret = GP_ColorConvert(&color, GP_G8);
- CHECK_RET(ret);
- *pixel = color.g8.gray;
- return ret;
- break;
- case GP_PIXEL_RGB565:
- ret = GP_ColorConvert(&color, GP_RGB565);
- CHECK_RET(ret);
- *pixel = color.rgb565.red << 0x0b |
- color.rgb565.green << 0x05 |
- color.rgb565.blue;
- case GP_PIXEL_RGB888:
- case GP_PIXEL_XRGB8888:
- ret = GP_ColorConvert(&color, GP_RGB888);
- CHECK_RET(ret);
- *pixel = color.rgb888.red << 0x10 |
- color.rgb888.green << 0x08 |
- color.rgb888.blue;
- return ret;
- break;
- case GP_PIXEL_BGR888:
- case GP_PIXEL_XBGR8888:
- ret = GP_ColorConvert(&color, GP_RGB888);
- CHECK_RET(ret);
- *pixel = color.rgb888.red |
- color.rgb888.green << 0x08 |
- color.rgb888.blue << 0x10;
- return ret;
- break;
- case GP_PIXEL_RGBX8888:
- ret = GP_ColorConvert(&color, GP_RGB888);
- CHECK_RET(ret);
- *pixel = color.rgb888.red << 0x18 |
- color.rgb888.green << 0x10 |
- color.rgb888.blue << 0x8;
- return ret;
- break;
- case GP_PIXEL_BGRX8888:
- ret = GP_ColorConvert(&color, GP_RGB888);
- CHECK_RET(ret);
- *pixel = color.rgb888.red << 0x08 |
- color.rgb888.green << 0x10 |
- color.rgb888.blue << 0x18;
- return ret;
- break;
- case GP_PIXEL_ARGB8888:
- ret = GP_ColorConvert(&color, GP_RGBA8888);
- CHECK_RET(ret);
- *pixel = color.rgba8888.red << 0x10 |
- color.rgba8888.green << 0x08 |
- color.rgba8888.blue |
- color.rgba8888.alpha << 0x18;
- return ret;
- break;
- case GP_PIXEL_RGBA8888:
- ret = GP_ColorConvert(&color, GP_RGBA8888);
- CHECK_RET(ret);
- *pixel = color.rgba8888.red << 0x18 |
- color.rgba8888.green << 0x10 |
- color.rgba8888.blue << 0x08 |
- color.rgba8888.alpha;
- return ret;
- break;
- case GP_PIXEL_ABGR8888:
- ret = GP_ColorConvert(&color, GP_RGBA8888);
- CHECK_RET(ret);
- *pixel = color.rgba8888.red |
- color.rgba8888.green << 0x08 |
- color.rgba8888.blue << 0x10 |
- color.rgba8888.alpha << 0x18;
- return ret;
- break;
- case GP_PIXEL_BGRA8888:
- ret = GP_ColorConvert(&color, GP_RGBA8888);
- CHECK_RET(ret);
- *pixel = color.rgba8888.red << 0x08 |
- color.rgba8888.green << 0x10 |
- color.rgba8888.blue << 0x18 |
- color.rgba8888.alpha;
- return ret;
- break;
- case GP_PIXEL_MAX:
- break;
- }
-
- if (pixel_type >= GP_PIXEL_MAX)
- return GP_EINVAL;
- else
- return GP_ENOIMPL;
-}
-
-GP_RetCode GP_ColorToPixel(GP_Context *context, GP_Color color, GP_Pixel *pixel)
-{
- if (context == NULL || pixel == NULL)
- return GP_ENULLPTR;
-
- return GP_ColorToPixelType(context->pixel_type, color, pixel);
-}
-
-GP_RetCode GP_ColorNameToPixel(GP_Context *context, GP_ColorName name, GP_Pixel *pixel)
-{
- if (context == NULL || pixel == NULL)
- return GP_ENULLPTR;
-
- GP_Color color = GP_COLNAME_PACK(name);
- return GP_ColorToPixelType(context->pixel_type, color, pixel);
-}
-
-GP_RetCode GP_ColorNameToPixelType(GP_PixelType pixel_type, GP_ColorName name, GP_Pixel *pixel)
-{
- if (pixel == NULL)
- return GP_ENULLPTR;
-
- GP_Color color = GP_COLNAME_PACK(name);
- return GP_ColorToPixelType(pixel_type, color, pixel);
-}
-
-GP_RetCode GP_RGBToPixel(GP_Context *context, uint8_t r, uint8_t g, uint8_t b, GP_Pixel *pixel)
-{
- if (pixel == NULL)
- return GP_ENULLPTR;
-
- GP_Color color = GP_RGB888_PACK(r, g, b);
- return GP_ColorToPixelType(context->pixel_type, color, pixel);
-}
+/////// removed by gavento
+// struct PixelTypeInfo {
+// const char *type_name; /* human-readable name */
+// GP_ColorType color_type; /* color type used for this pixel type */
+// unsigned int bits; /* how many bits the pixel occupies */
+// };
+//
+// /* This table shows relations of pixel types to color types, their names
+// * and bits per pixel.
+// */
+// static struct PixelTypeInfo pixel_type_infos[] = {
+// { "Unknown pixel type", GP_NOCOLOR, 0 },
+// { "Palette 4bit", GP_PAL4, 4 },
+// { "Palette 8bit", GP_PAL8, 8 },
+// { "Grayscale 1bit", GP_G1, 1 },
+// { "Grayscale 2bits", GP_G2, 2 },
+// { "Grayscale 4bits", GP_G4, 4 },
+// { "Grayscale 8bits", GP_G8, 8 },
+// { "RGB 555", GP_RGB555, 16 },
+// { "BGR 555", GP_RGB555, 16 },
+// { "RGB 565", GP_RGB565, 16 },
+// { "BGR 565", GP_RGB565, 16 },
+// { "RGB 888", GP_RGB888, 24 },
+// { "BGR 888", GP_RGB888, 24 },
+// { "XRGB 8888", GP_RGB888, 32 },
+// { "RGBX 8888", GP_RGB888, 32 },
+// { "XBGR 8888", GP_RGB888, 32 },
+// { "BGRX 8888", GP_RGB888, 32 },
+// { "ARGB 8888", GP_RGBA8888, 32 },
+// { "RGBA 8888", GP_RGBA8888, 32 },
+// { "ABGR 8888", GP_RGBA8888, 32 },
+// { "BGRA 8888", GP_RGBA8888, 32 }
+// };
+//
+// GP_ColorType GP_PixelTypeToColorType(GP_PixelType type)
+// {
+// if (type >= GP_PIXEL_MAX)
+// return GP_COLMAX;
+//
+// return pixel_type_infos[type].color_type;
+// }
+//
+// #define CHECK_RET(ret) if (ret != GP_ESUCCESS && ret != GP_EUNPRECISE) return ret;
+//
+// GP_RetCode GP_ColorToPixelType(GP_PixelType pixel_type, GP_Color color, GP_Pixel *pixel)
+// {
+// if (pixel == NULL)
+// return GP_ENULLPTR;
+//
+// GP_RetCode ret;
+//
+// switch (pixel_type) {
+// case GP_PIXEL_PAL4:
+// ret = GP_ColorConvert(&color, GP_PAL4);
+// CHECK_RET(ret);
+// *pixel = color.pal4.index;
+// return ret;
+// break;
+// case GP_PIXEL_PAL8:
+// ret = GP_ColorConvert(&color, GP_PAL8);
+// CHECK_RET(ret);
+// *pixel = color.pal8.index;
+// return ret;
+// break;
+// case GP_PIXEL_G1:
+// ret = GP_ColorConvert(&color, GP_G1);
+// CHECK_RET(ret);
+// *pixel = color.g1.gray;
+// return ret;
+// break;
+// case GP_PIXEL_G2:
+// ret = GP_ColorConvert(&color, GP_G2);
+// CHECK_RET(ret);
+// *pixel = color.g2.gray;
+// return ret;
+// break;
+// case GP_PIXEL_G4:
+// ret = GP_ColorConvert(&color, GP_G4);
+// CHECK_RET(ret);
+// *pixel = color.g4.gray;
+// return ret;
+// break;
+// case GP_PIXEL_G8:
+// ret = GP_ColorConvert(&color, GP_G8);
+// CHECK_RET(ret);
+// *pixel = color.g8.gray;
+// return ret;
+// break;
+// case GP_PIXEL_RGB565:
+// ret = GP_ColorConvert(&color, GP_RGB565);
+// CHECK_RET(ret);
+// *pixel = color.rgb565.red << 0x0b |
+// color.rgb565.green << 0x05 |
+// color.rgb565.blue;
+// case GP_PIXEL_RGB888:
+// case GP_PIXEL_XRGB8888:
+// ret = GP_ColorConvert(&color, GP_RGB888);
+// CHECK_RET(ret);
+// *pixel = color.rgb888.red << 0x10 |
+// color.rgb888.green << 0x08 |
+// color.rgb888.blue;
+// return ret;
+// break;
+// case GP_PIXEL_BGR888:
+// case GP_PIXEL_XBGR8888:
+// ret = GP_ColorConvert(&color, GP_RGB888);
+// CHECK_RET(ret);
+// *pixel = color.rgb888.red |
+// color.rgb888.green << 0x08 |
+// color.rgb888.blue << 0x10;
+// return ret;
+// break;
+// case GP_PIXEL_RGBX8888:
+// ret = GP_ColorConvert(&color, GP_RGB888);
+// CHECK_RET(ret);
+// *pixel = color.rgb888.red << 0x18 |
+// color.rgb888.green << 0x10 |
+// color.rgb888.blue << 0x8;
+// return ret;
+// break;
+// case GP_PIXEL_BGRX8888:
+// ret = GP_ColorConvert(&color, GP_RGB888);
+// CHECK_RET(ret);
+// *pixel = color.rgb888.red << 0x08 |
+// color.rgb888.green << 0x10 |
+// color.rgb888.blue << 0x18;
+// return ret;
+// break;
+// case GP_PIXEL_ARGB8888:
+// ret = GP_ColorConvert(&color, GP_RGBA8888);
+// CHECK_RET(ret);
+// *pixel = color.rgba8888.red << 0x10 |
+// color.rgba8888.green << 0x08 |
+// color.rgba8888.blue |
+// color.rgba8888.alpha << 0x18;
+// return ret;
+// break;
+// case GP_PIXEL_RGBA8888:
+// ret = GP_ColorConvert(&color, GP_RGBA8888);
+// CHECK_RET(ret);
+// *pixel = color.rgba8888.red << 0x18 |
+// color.rgba8888.green << 0x10 |
+// color.rgba8888.blue << 0x08 |
+// color.rgba8888.alpha;
+// return ret;
+// break;
+// case GP_PIXEL_ABGR8888:
+// ret = GP_ColorConvert(&color, GP_RGBA8888);
+// CHECK_RET(ret);
+// *pixel = color.rgba8888.red |
+// color.rgba8888.green << 0x08 |
+// color.rgba8888.blue << 0x10 |
+// color.rgba8888.alpha << 0x18;
+// return ret;
+// break;
+// case GP_PIXEL_BGRA8888:
+// ret = GP_ColorConvert(&color, GP_RGBA8888);
+// CHECK_RET(ret);
+// *pixel = color.rgba8888.red << 0x08 |
+// color.rgba8888.green << 0x10 |
+// color.rgba8888.blue << 0x18 |
+// color.rgba8888.alpha;
+// return ret;
+// break;
+// case GP_PIXEL_MAX:
+// break;
+// }
+//
+// if (pixel_type >= GP_PIXEL_MAX)
+// return GP_EINVAL;
+// else
+// return GP_ENOIMPL;
+// }
+//
+// GP_RetCode GP_ColorToPixel(GP_Context *context, GP_Color color, GP_Pixel *pixel)
+// {
+// if (context == NULL || pixel == NULL)
+// return GP_ENULLPTR;
+//
+// return GP_ColorToPixelType(context->pixel_type, color, pixel);
+// }
+//
+// GP_RetCode GP_ColorNameToPixel(GP_Context *context, GP_ColorName name, GP_Pixel *pixel)
+// {
+// if (context == NULL || pixel == NULL)
+// return GP_ENULLPTR;
+//
+// GP_Color color = GP_COLNAME_PACK(name);
+// return GP_ColorToPixelType(context->pixel_type, color, pixel);
+// }
+//
+// GP_RetCode GP_ColorNameToPixelType(GP_PixelType pixel_type, GP_ColorName name, GP_Pixel *pixel)
+// {
+// if (pixel == NULL)
+// return GP_ENULLPTR;
+//
+// GP_Color color = GP_COLNAME_PACK(name);
+// return GP_ColorToPixelType(pixel_type, color, pixel);
+// }
+//
+// GP_RetCode GP_RGBToPixel(GP_Context *context, uint8_t r, uint8_t g, uint8_t b, GP_Pixel *pixel)
+// {
+// if (pixel == NULL)
+// return GP_ENULLPTR;
+//
+// GP_Color color = GP_RGB888_PACK(r, g, b);
+// return GP_ColorToPixelType(context->pixel_type, color, pixel);
+// }
diff --git a/core/GP_Pixel.h b/core/GP_Pixel.h
index beaa22c..31c6400 100644
--- a/core/GP_Pixel.h
+++ b/core/GP_Pixel.h
@@ -81,6 +81,7 @@ typedef struct {
GP_PixelType type; /* Number of the type */
const char name[16]; /* Name */
int size; /* Size in bits */
+ int bit_endian; /* Order of pixels in a byte */ /**TODO : add proper type !! */
int numchannels; /* Number of channels */
const char bitmap[36]; /* String describing the bit-representaton (as in "RRRRRGGGGGGBBBBB")*/
const GP_PixelTypeChannel channels[8]; /* Individual channels */
@@ -110,6 +111,7 @@ typedef enum {
static inline const char *GP_PixelTypeName(GP_PixelType type)
{
+ GP_CHECK(type < GP_PIXEL_MAX);
return GP_PixelTypes[type].name;
}
@@ -119,6 +121,7 @@ static inline const char *GP_PixelTypeName(GP_PixelType type)
static inline uint32_t GP_PixelSize(GP_PixelType type)
{
+ GP_CHECK(type < GP_PIXEL_MAX);
return GP_PixelTypes[type].size;
}
http://repo.or.cz/w/gfxprim.git/commit/e1b16f55b51c64ae4e2c5755e4e1633e5791…
commit e1b16f55b51c64ae4e2c5755e4e1633e579164f0
Merge: a15037c d2b5a02
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Apr 5 02:01:39 2011 +0200
Merge branch 'bitendian' of git://repo.or.cz/gfxprim into generate
Conflicts:
core/GP_Pixel.h
diff --cc core/GP_Pixel.h
index a47424a,02ffa14..beaa22c
--- a/core/GP_Pixel.h
+++ b/core/GP_Pixel.h
@@@ -51,67 -81,24 +51,79 @@@ struct GP_Context
typedef uint32_t GP_Pixel;
-/* information about ordering of pixels in byte for 1, 2 and 4 bpp */
-/* used in a one bit variable in GP_Context */
+/* Generated header */
+#include "GP_Pixel.gen.h"
+
+/*
+ * Description of one channel
+ * Assumes all the channel names to be at most 7 chars long
+ *
+ * The common channel names are:
+ * R, G, B - as usual
+ * V - value, for grayscale
+ * A - opacity (0=transparent)
+ * P - palette (index)
+ */
+
+typedef struct {
+ char name[8]; /* Channel name */
+ int offset; /* Offset in bits */
+ int size; /* Bit-size */
+} GP_PixelTypeChannel;
+
+/*
+ * Description of one PixelType
+ * Assumes name with at most 15 chars
+ * Assumes at most 8 channels
+ */
+
+typedef struct {
+ GP_PixelType type; /* Number of the type */
+ const char name[16]; /* Name */
+ int size; /* Size in bits */
+ int numchannels; /* Number of channels */
+ const char bitmap[36]; /* String describing the bit-representaton (as in "RRRRRGGGGGGBBBBB")*/
+ const GP_PixelTypeChannel channels[8]; /* Individual channels */
+} GP_PixelTypeDescription;
+
+/*
+ * Array of GP_PIXEL_MAX entries
+ */
+
+extern const GP_PixelTypeDescription const GP_PixelTypes[];
+
+/*
++ * Information about ordering of pixels in byte for 1, 2 and 4 bpp
++ * used in a one bit variable in GP_Context
++ */
++
+ typedef enum {
+ /* less significant bits contain pixels with lower indices */
+ GP_BIT_ENDIAN_LE = 0,
+ /* more significant bits contain pixels with lower indices */
+ GP_BIT_ENDIAN_BE,
+ } GP_BIT_ENDIAN;
+
+ /*
* Convert pixel type to name.
*/
-const char *GP_PixelTypeName(GP_PixelType type);
+
- inline const char *GP_PixelTypeName(GP_PixelType type)
++static inline const char *GP_PixelTypeName(GP_PixelType type)
+{
+ return GP_PixelTypes[type].name;
+}
/*
* Returns number of bits per pixel.
*/
-uint32_t GP_PixelSize(GP_PixelType type);
+
- inline uint32_t GP_PixelSize(GP_PixelType type)
++static inline uint32_t GP_PixelSize(GP_PixelType type)
+{
+ return GP_PixelTypes[type].size;
+}
+
+
+/* Below -- TODO sync with new pixel type */
/*
* Returns GP_PixelType to GP_ColorType mapping.
http://repo.or.cz/w/gfxprim.git/commit/a15037c925ea8b6b995b3fd765e86978e643…
commit a15037c925ea8b6b995b3fd765e86978e6430dcd
Merge: c4107c1 da9aaa9
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Apr 5 01:15:09 2011 +0200
Merge branch 'master' into generate
Conflicts:
core/GP_Common.h
diff --cc core/GP_Common.h
index 5e2a2c9,6f06121..f863dc3
--- a/core/GP_Common.h
+++ b/core/GP_Common.h
@@@ -34,6 -34,6 +34,7 @@@
/*
* Returns a minimum of the two numbers.
*/
++
#define GP_MIN(a, b) ({ typeof(a) _a = (a); typeof(b) _b = (b); @@@ -43,6 -43,6 +44,7 @@@
/*
* Returns a maximum of the two numbers.
*/
++
#define GP_MAX(a, b) ({ typeof(a) _a = (a); typeof(b) _b = (b); @@@ -52,18 -52,19 +54,21 @@@
/*
* Abort and print abort location to stderr
*/
++
#define GP_ABORT(msg) do { - fprintf(stderr, "*** gfxprim: aborted: %s: %sn", __FUNCTION__, #msg); + fprintf(stderr, "*** gfxprim: aborted: %s:%d: in %s: %sn", + __FILE__, __LINE__, __FUNCTION__, #msg); abort(); } while (0)
/*
* Perform a runtime check, on failure abort and print a message
*/
++
#define GP_CHECK(cond) do { if (!(cond)) { - fprintf(stderr, "*** gfxprim: runtime check failed: %s: %sn", - __FUNCTION__, #cond); + fprintf(stderr, "*** gfxprim: check failed: %s:%d: in %s: %sn", + __FILE__, __LINE__, __FUNCTION__, #cond); abort(); } } while (0)
@@@ -72,6 -73,6 +77,7 @@@
* The standard likely() and unlikely() used in Kernel
* TODO: Define as no-op for non-GCC compilers
*/
++
#ifndef likely
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
@@@ -80,6 -81,6 +86,7 @@@
/*
* Swap a and b using an intermediate variable
*/
++
#define GP_SWAP(a, b) do { typeof(a) tmp = b; b = a; @@@ -92,7 -93,7 +99,8 @@@
* Return (shifted) count bits at offset of value
* Note: operates with value types same as val
*/
- #define GP_GET_BITS(offset, count, val) ( ( (val)>>(offset) ) & ( (((typeof(val)1)<<(count)) - 1) ) )
++
+ #define GP_GET_BITS(offset, count, val) ( ( (val)>>(offset) ) & ( ((((typeof(val))1)<<(count)) - 1) ) )
/*
* Set count bits of dest at ofset to val (shifted by offset)
@@@ -105,12 -106,20 +113,23 @@@
* GP_CLEAR_BITS sets the target bits to zero
* GP_SET_BITS does both
*/
++
#define GP_CLEAR_BITS(offset, count, dest) ( (dest) &= ~(((((typeof(dest))1) << (count)) - 1) << (offset)) )
#define GP_SET_BITS_OR(offset, dest, val) ( (dest) |= ((val)<<(offset)) )
#define GP_SET_BITS(offset, count, dest, val) (GP_CLEAR_BITS(offset, count, dest), - SET_BITS_OR(offset, dest, val) )
+ GP_SET_BITS_OR(offset, dest, val) )
+
-/* Determines the sign of the integer value; it is +1 if value is positive,
++/*
++ * Determines the sign of the integer value; it is +1 if value is positive,
+ * -1 if negative, and 0 if it is zero.
+ */
++
+ #define GP_SIGN(a) ({ + typeof(a) _a = a; + (_a > 0) ? 1 : ((_a < 0) ? -1 : 0); + })
#endif /* GP_COMMON_H */
http://repo.or.cz/w/gfxprim.git/commit/c4107c1c47c062cb836f0dc0269b7479acc0…
commit c4107c1c47c062cb836f0dc0269b7479acc03de6
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Tue Apr 5 01:09:23 2011 +0200
Added simple counters (+tests)
For accounting arvitrary operations
As "quantitative warnings"
diff --git a/core/GP_Counter.c b/core/GP_Counter.c
new file mode 100644
index 0000000..e5922d0
--- /dev/null
+++ b/core/GP_Counter.c
@@ -0,0 +1,107 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+#include <string.h>
+#include "GP_Common.h"
+#include "GP_Counter.h"
+
+/*
+ * Internal struct used in counter list
+ */
+
+struct GP_CounterRecord {
+ char name[GP_COUNTER_NAME_LEN];
+ GP_Counter counter;
+};
+
+
+/*
+ * variables local to module (static)
+ */
+
+#ifdef GP_IMPLEMENT_COUNTERS
+
+static GP_Counter_t GP_counters[GP_COUNTER_MAX];
+static int GP_used_counters = 0;
+static struct GP_CounterRecord GP_counter_list[GP_COUNTER_MAX];
+static GP_Counter_t GP_counter_list_overflow = 0;
+
+#endif /* GP_IMPLEMENT_COUNTERS */
+
+void GP_PrintCounters(FILE *f)
+{
+#ifdef GP_IMPLEMENT_COUNTERS
+ int i;
+ if (GP_used_counters == 0)
+ fprintf(f, "[ no counters defined ]n");
+ for (i = 0; i < GP_used_counters; i++)
+ fprintf(f, "%*s : %lldn", -GP_COUNTER_NAME_LEN, GP_counter_list[i].name,
+ *(GP_counter_list[i].counter));
+ if (GP_counter_list_overflow > 0)
+ fprintf(f, "[ unable to allocate new counter %lld times ]n",
+ GP_counter_list_overflow);
+#endif /* GP_IMPLEMENT_COUNTERS */
+}
+
+GP_Counter GP_GetCounter(const char *name)
+{
+#ifdef GP_IMPLEMENT_COUNTERS
+ int l = 0;
+ int r = GP_used_counters;
+
+ GP_CHECK(name != NULL);
+ GP_CHECK(strlen(name) + 1 <= GP_COUNTER_NAME_LEN);
+
+ /* Bisect GP_counter_list to find either the counter or a place for it
+ * interval [l, r) (not incl. r) */
+ while(r > l + 1) {
+ int med = (r + l) / 2; /* Here never equal to r, might be l */
+ int cmp = strcmp(GP_counter_list[med].name, name);
+ if (cmp == 0)
+ return GP_counter_list[med].counter;
+ if (cmp < 0)
+ l = med + 1;
+ else
+ r = med;
+ }
+ GP_CHECK(l == r);
+ if ((l < GP_used_counters) && (strcmp(GP_counter_list[l].name, name) == 0))
+ return GP_counter_list[l].counter;
+
+ /* Add a new counter */
+ if (GP_used_counters >= GP_COUNTER_MAX) {
+ GP_counter_list_overflow ++;
+ return NULL;
+ }
+
+ /* Move the counter records up and initialize a new one */
+ memmove(GP_counter_list + l, GP_counter_list + l + 1,
+ sizeof(struct GP_CounterRecord) * GP_used_counters - l);
+ strcpy(GP_counter_list[l].name, name);
+ GP_counter_list[l].counter = GP_counters + GP_used_counters;
+
+ GP_used_counters ++;
+ return GP_counter_list[l].counter;
+#else /* GP_IMPLEMENT_COUNTERS */
+ return NULL;
+#endif /* GP_IMPLEMENT_COUNTERS */
+}
diff --git a/core/GP_Counter.h b/core/GP_Counter.h
new file mode 100644
index 0000000..3c0358b
--- /dev/null
+++ b/core/GP_Counter.h
@@ -0,0 +1,108 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+/*
+ * Simple global named 64-bit counters.
+ *
+ * Intended for accounting of expensive operations ("quantitative warnings").
+ * All operations accept NULL as GP_Counter.
+ *
+ * If GP_IMPLEMENT_COUNTERS is undefined, all operations are NOP and
+ * no memory is allocated.
+ */
+
+#define GP_IMPLEMENT_COUNTERS
+
+/*
+ * Maximum length of counter name,
+ * maximum number of counters (~40 bytes each)
+ */
+
+#define GP_COUNTER_NAME_LEN 24
+#define GP_COUNTER_MAX 256
+
+/*
+ * Basic types.
+ * Only use GP_Counter in your programs.
+ */
+
+typedef int64_t GP_Counter_t;
+typedef GP_Counter_t *GP_Counter;
+
+/*
+ * Increase a counter by 1.
+ */
+
+inline void GP_IncCounter(GP_Counter counter)
+{
+#ifdef GP_IMPLEMENT_COUNTERS
+ if (!counter) return;
+ (*counter) ++;
+#endif /* GP_IMPLEMENT_COUNTERS */
+}
+
+/*
+ * Increase a counter by delta (may be negative).
+ * No checks for underflow.
+ */
+
+inline void GP_AddCounter(GP_Counter counter, GP_Counter_t delta)
+{
+#ifdef GP_IMPLEMENT_COUNTERS
+ if (!counter) return;
+ (*counter) += delta;
+#endif /* GP_IMPLEMENT_COUNTERS */
+}
+
+/*
+ * Return counter value
+ */
+
+inline GP_Counter_t GP_CounterVal(GP_Counter counter)
+{
+#ifdef GP_IMPLEMENT_COUNTERS
+ if (!counter) return 0;
+ return *counter;
+#else /* GP_IMPLEMENT_COUNTERS */
+ return 0;
+#endif /* GP_IMPLEMENT_COUNTERS */
+}
+
+/*
+ * Pretty-printing of all counters and their values to f
+ * Includes info about counter-list overflow
+ */
+
+void GP_PrintCounters(FILE *f);
+
+/*
+ * Lookup a counter by name, possibly creating a new one.
+ *
+ * May return NULL if no space is left in the counter list.
+ * The returned value is not unallocated in any way.
+ *
+ * NOTE: Current implementation has very slow adds (O(current_counters)),
+ * but the lookup is reasonably fast (bisection)
+ */
+
+GP_Counter GP_GetCounter(const char *name);
+
diff --git a/core/tests/GP_Counter.test.c b/core/tests/GP_Counter.test.c
new file mode 100644
index 0000000..a334106
--- /dev/null
+++ b/core/tests/GP_Counter.test.c
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+#include <string.h>
+
+#include "GP_Test.h"
+#include "GP_Counter.h"
+
+GP_SUITE(GP_Counter)
+
+GP_TEST(Smoke)
+{
+ fail_unless(GP_CounterVal(NULL) == 0);
+ GP_IncCounter(NULL);
+ GP_AddCounter(NULL, -10);
+ fail_unless(GP_GetCounter("") != NULL);
+
+ GP_IncCounter(GP_GetCounter("a"));
+ fail_unless(GP_CounterVal(GP_GetCounter("a")) == 1);
+}
+
+GP_TEST(Allocation)
+{
+ GP_IncCounter(GP_GetCounter("a"));
+ GP_AddCounter(GP_GetCounter("e"), -42);
+ GP_AddCounter(GP_GetCounter("b"), -8);
+ GP_IncCounter(GP_GetCounter("a"));
+ GP_IncCounter(GP_GetCounter("d"));
+ GP_Counter b = GP_GetCounter("b");
+ GP_AddCounter(GP_GetCounter("c"), 21);
+ GP_IncCounter(GP_GetCounter("b"));
+ GP_IncCounter(b);
+
+ fail_unless(GP_CounterVal(GP_GetCounter("a")) == 2);
+ fail_unless(GP_CounterVal(GP_GetCounter("b")) == -6);
+ fail_unless(GP_CounterVal(GP_GetCounter("c")) == 21);
+ fail_unless(GP_CounterVal(GP_GetCounter("d")) == 1);
+ fail_unless(GP_CounterVal(GP_GetCounter("e")) == -42);
+}
+
+GP_TEST(Overflow)
+{
+ char buf[8];
+ for (int i = 0; i < GP_COUNTER_MAX + 10; i++) {
+ sprintf(buf, "%d", i);
+ GP_GetCounter(buf);
+ }
+ fail_unless(GP_GetCounter("") == NULL);
+}
+
-----------------------------------------------------------------------
Summary of changes:
Makefile | 64 ++--
algo/README | 7 -
app.mk | 15 +
build/Makefile | 41 ++
build/liblock.sh | 25 ++
build/link.sh | 27 ++
config.mk | 3 +
core/GP_Circle.c | 61 ---
core/GP_FillCircle.h | 37 --
core/GP_FillEllipse.c | 61 ---
core/GP_FillRect.c | 77 ----
core/GP_FillRect.h | 46 ---
core/GP_FillTetragon.c | 57 ---
core/GP_FillTetragon.h | 38 --
core/GP_FillTriangle.c | 64 ---
core/GP_FillTriangle.h | 37 --
core/GP_LineTrack.h | 72 ----
core/GP_Pixel.c | 244 ------------
core/GP_ReadPixel.h | 36 --
core/Makefile | 52 ---
core/tests/GP_color_type_test.c | 61 ---
core/tests/GP_palette_test.c | 74 ----
core/tests/Makefile | 19 -
core/tests/runtest.sh | 10 -
doc/context.txt | 24 ++
doc/drawing_api.txt | 82 ++--
drivers/Makefile | 29 --
filters/Makefile | 29 --
filters/tests/Makefile | 17 -
include.mk | 101 +++++
targets/sdl/GP_SDL_Context.h => include/GP.h | 16 +-
.../backends/GP_Backend.h | 96 +++---
include/config.h | 1 +
{core => include/core}/GP_Clip.h | 0
{core => include/core}/GP_Color.h | 0
{core => include/core}/GP_Common.h | 96 ++++-
{core => include/core}/GP_Context.h | 72 +++-
core/GP_Circle.h => include/core/GP_Core.h | 27 +-
include/core/GP_Counter.h | 125 ++++++
{core => include/core}/GP_FnPerBpp.h | 61 ++-
{core => include/core}/GP_GetPixel.h | 0
{core => include/core}/GP_Palette.h | 0
{core => include/core}/GP_Pixel.h | 46 ++-
{core => include/core}/GP_PutPixel.h | 18 +-
{core => include/core}/GP_RetCode.h | 3 +-
{core => include/core}/GP_Transform.h | 25 +-
{core => include/core}/GP_WritePixel.h | 37 --
{filters => include/filters}/GP_Filters.h | 0
{filters => include/filters}/GP_Rotate.h | 3 +-
core/GP_FillEllipse.h => include/gfx/GP_Circle.h | 22 +-
{core => include/gfx}/GP_Ellipse.h | 17 +-
{core => include/gfx}/GP_Fill.h | 4 +-
core/GP.h => include/gfx/GP_Gfx.h | 49 ++--
{core => include/gfx}/GP_HLine.h | 18 +-
{core => include/gfx}/GP_Line.h | 12 +-
core/GP_Fill.h => include/gfx/GP_Polygon.h | 11 +-
{core => include/gfx}/GP_Rect.h | 33 ++-
{core => include/gfx}/GP_Symbol.h | 24 +-
{core => include/gfx}/GP_Tetragon.h | 16 +-
{core => include/gfx}/GP_Triangle.h | 16 +-
{core => include/gfx}/GP_VLine.h | 16 +-
{input => include/input}/GP_Event.h | 0
{loaders => include/loaders}/GP_Loaders.h | 6 +
{loaders => include/loaders}/GP_PBM.h | 2 +-
{loaders => include/loaders}/GP_PGM.h | 2 +-
{core => include/text}/GP_Font.h | 9 +-
{core => include/text}/GP_Text.h | 41 ++-
{core => include/text}/GP_TextMetric.h | 8 +-
{core => include/text}/GP_TextStyle.h | 10 +-
input/Makefile | 27 --
lib.mk | 11 +
libs/Makefile | 3 +
.../GP_font_save.c => libs/backends/GP_Backend.c | 81 +++--
.../backends/GP_Backend_SDL.c | 149 ++++++--
libs/backends/Makefile | 5 +
{core => libs/core}/GP_Color.c | 0
{core => libs/core}/GP_Context.c | 77 ++++-
libs/core/GP_Counter.c | 109 ++++++
{core => libs/core}/GP_GetPixel.c | 4 +-
{core => libs/core}/GP_Palette.c | 0
libs/core/GP_Pixel.c | 235 ++++++++++++
{core => libs/core}/GP_PutPixel.c | 27 +-
{core => libs/core}/GP_RetCode.c | 1 +
{core => libs/core}/GP_WritePixel.c | 27 +-
libs/core/Makefile | 5 +
{core => libs/core}/gen/README | 0
{core => libs/core}/gen/defs.py | 0
{core => libs/core}/gen/gen_blit.py | 70 ++--
{core => libs/core}/gen/gen_pixeltype.py | 38 +-
{core => libs/core}/gen/gen_utils.py | 0
{core => libs/core}/gen/make_GP_Blit.py | 6 +-
{core => libs/core}/gen/make_GP_Pixel.py | 9 +-
{core => libs/core}/gen/make_GP_Pixel_Scale.py | 0
{core => libs/core}/gen/pixeltype.py | 16 +-
{filters => libs/filters}/GP_Rotate.c | 19 +-
libs/filters/Makefile | 5 +
{filters => libs/filters/algo}/GP_MirrorV.algo.h | 2 +-
{filters => libs/filters/algo}/GP_Rotate.algo.h | 6 +-
core/GP_FillCircle.c => libs/gfx/GP_Circle.c | 50 ++-
{core => libs/gfx}/GP_Ellipse.c | 61 +++-
{core => libs/gfx}/GP_Fill.c | 8 +-
{core => libs/gfx}/GP_HLine.c | 54 ++--
{core => libs/gfx}/GP_Line.c | 38 +-
libs/gfx/GP_Polygon.c | 196 ++++++++++
{core => libs/gfx}/GP_Rect.c | 84 +++--
{core => libs/gfx}/GP_Symbol.c | 67 ++--
{core => libs/gfx}/GP_Tetragon.c | 45 ++-
{core => libs/gfx}/GP_Triangle.c | 46 ++-
{core => libs/gfx}/GP_VLine.c | 52 ++--
libs/gfx/Makefile | 5 +
{algo => libs/gfx/algo}/Circle.algo.h | 0
{algo => libs/gfx/algo}/Ellipse.algo.h | 0
{algo => libs/gfx/algo}/FillCircle.algo.h | 0
{algo => libs/gfx/algo}/FillEllipse.algo.h | 0
{algo => libs/gfx/algo}/FillTriangle.algo.h | 94 ++++-
{algo => libs/gfx/algo}/HLine.algo.h | 0
{algo => libs/gfx/algo}/Line.algo.h | 0
{algo => libs/gfx/algo}/VLine.algo.h | 0
{input => libs/input}/GP_Event.c | 0
libs/input/Makefile | 5 +
{loaders => libs/loaders}/GP_PBM.c | 0
{loaders => libs/loaders}/GP_PGM.c | 0
{loaders => libs/loaders}/GP_PXMCommon.c | 0
{loaders => libs/loaders}/GP_PXMCommon.h | 2 +-
libs/loaders/Makefile | 5 +
{core => libs/text}/GP_DefaultFont.c | 224 ++++++------
{core => libs/text}/GP_Font.c | 25 +-
{core => libs/text}/GP_Text.c | 74 +++-
{core => libs/text}/GP_TextMetric.c | 78 +++-
{core => libs/text}/GP_TextStyle.c | 8 +-
libs/text/Makefile | 5 +
{algo => libs/text/algo}/Text.algo.h | 0
loaders/Makefile | 29 --
loaders/tests/Makefile | 17 -
old_tests/Makefile | 26 --
old_tests/circlefps.c | 148 -------
old_tests/circlestest.c | 220 -----------
old_tests/ellipsetest.c | 240 ------------
old_tests/linefps.c | 149 --------
old_tests/linetest.c | 158 --------
old_tests/pixeltest.c | 138 -------
old_tests/runtest.sh | 10 -
old_tests/shapetest.c | 402 --------------------
old_tests/widelinetest.c | 138 -------
targets/sdl/Makefile | 61 ---
tests/Makefile | 3 +
tests/core/GP_Comon.test.c | 100 +++++
.../GP_LineTrack.c => tests/core/GP_Counter.test.c | 94 +++---
core/GP_Palette.h => tests/core/GP_Tests.h | 88 +++--
tests/core/Makefile | 31 ++
core/GP_ReadPixel.c => tests/core/core_tests.c | 78 +++--
tests/core/find_tests.py | 154 ++++++++
drivers/GP_Framebuffer.h => tests/core/font.test.c | 54 ++-
{drivers => tests/drivers}/GP_Framebuffer.c | 115 +++++-
{drivers => tests/drivers}/GP_Framebuffer.h | 5 +-
{drivers => tests/drivers}/tests/Makefile | 0
.../drivers}/tests/framebuffer_test.c | 54 ++-
{drivers => tests/drivers}/tests/runtest.sh | 0
{drivers => tests/drivers}/tests/sierpinsky.c | 4 +-
tests/filters/Makefile | 11 +
{filters/tests => tests/filters}/PGM_rotate.c | 0
{filters/tests => tests/filters}/rotate_test.c | 0
{filters/tests => tests/filters}/runtest.sh | 0
{filters/tests => tests/filters}/test-big.pgm | 0
tests/loaders/Makefile | 11 +
{loaders/tests => tests/loaders}/PBM_invert.c | 0
{loaders/tests => tests/loaders}/PBM_test.c | 0
{loaders/tests => tests/loaders}/PGM_invert.c | 0
{loaders/tests => tests/loaders}/PGM_test.c | 0
{loaders/tests => tests/loaders}/autotest.sh | 0
{loaders/tests => tests/loaders}/runtest.sh | 0
{targets => tests}/sdl/GP_SDL.h | 0
{targets => tests}/sdl/GP_SDL_Context.c | 0
{targets => tests}/sdl/GP_SDL_Context.h | 0
{targets => tests}/sdl/GP_SDL_VideoInit.c | 0
{targets => tests}/sdl/GP_SDL_VideoInit.h | 0
tests/sdl/Makefile | 2 +
{targets => tests}/sdl/tests/Makefile | 2 +-
{targets => tests}/sdl/tests/fileview.c | 11 +-
{targets => tests}/sdl/tests/fonttest.c | 24 ++
{targets => tests}/sdl/tests/linetest.c | 0
{targets => tests}/sdl/tests/pixeltest.c | 0
{targets => tests}/sdl/tests/randomshapetest.c | 24 ++-
{targets => tests}/sdl/tests/runtest.sh | 0
{targets => tests}/sdl/tests/shapetest.c | 24 +-
{targets => tests}/sdl/tests/sierpinsky.c | 96 ++++--
{targets => tests}/sdl/tests/symbolstest.c | 0
{targets => tests}/sdl/tests/textaligntest.c | 2 +-
{targets => tests}/sdl/tests/trianglefps.c | 0
189 files changed, 3282 insertions(+), 4051 deletions(-)
delete mode 100644 algo/README
create mode 100644 app.mk
create mode 100644 build/Makefile
create mode 100644 build/liblock.sh
create mode 100755 build/link.sh
create mode 100644 config.mk
delete mode 100644 core/GP_Circle.c
delete mode 100644 core/GP_FillCircle.h
delete mode 100644 core/GP_FillEllipse.c
delete mode 100644 core/GP_FillRect.c
delete mode 100644 core/GP_FillRect.h
delete mode 100644 core/GP_FillTetragon.c
delete mode 100644 core/GP_FillTetragon.h
delete mode 100644 core/GP_FillTriangle.c
delete mode 100644 core/GP_FillTriangle.h
delete mode 100644 core/GP_LineTrack.h
delete mode 100644 core/GP_Pixel.c
delete mode 100644 core/GP_ReadPixel.h
delete mode 100644 core/Makefile
delete mode 100644 core/tests/GP_color_type_test.c
delete mode 100644 core/tests/GP_palette_test.c
delete mode 100644 core/tests/Makefile
delete mode 100755 core/tests/runtest.sh
delete mode 100644 drivers/Makefile
delete mode 100644 filters/Makefile
delete mode 100644 filters/tests/Makefile
create mode 100644 include.mk
copy targets/sdl/GP_SDL_Context.h => include/GP.h (90%)
copy core/GP_WritePixel.h => include/backends/GP_Backend.h (53%)
create mode 100644 include/config.h
rename {core => include/core}/GP_Clip.h (100%)
rename {core => include/core}/GP_Color.h (100%)
rename {core => include/core}/GP_Common.h (57%)
rename {core => include/core}/GP_Context.h (71%)
rename core/GP_Circle.h => include/core/GP_Core.h (84%)
create mode 100644 include/core/GP_Counter.h
rename {core => include/core}/GP_FnPerBpp.h (73%)
rename {core => include/core}/GP_GetPixel.h (100%)
copy {core => include/core}/GP_Palette.h (100%)
rename {core => include/core}/GP_Pixel.h (77%)
rename {core => include/core}/GP_PutPixel.h (83%)
rename {core => include/core}/GP_RetCode.h (95%)
rename {core => include/core}/GP_Transform.h (79%)
rename {core => include/core}/GP_WritePixel.h (74%)
rename {filters => include/filters}/GP_Filters.h (100%)
rename {filters => include/filters}/GP_Rotate.h (98%)
rename core/GP_FillEllipse.h => include/gfx/GP_Circle.h (77%)
rename {core => include/gfx}/GP_Ellipse.h (77%)
copy {core => include/gfx}/GP_Fill.h (96%)
rename core/GP.h => include/gfx/GP_Gfx.h (78%)
rename {core => include/gfx}/GP_HLine.h (86%)
rename {core => include/gfx}/GP_Line.h (89%)
rename core/GP_Fill.h => include/gfx/GP_Polygon.h (90%)
rename {core => include/gfx}/GP_Rect.h (67%)
rename {core => include/gfx}/GP_Symbol.h (76%)
rename {core => include/gfx}/GP_Tetragon.h (76%)
rename {core => include/gfx}/GP_Triangle.h (78%)
rename {core => include/gfx}/GP_VLine.h (83%)
rename {input => include/input}/GP_Event.h (100%)
rename {loaders => include/loaders}/GP_Loaders.h (97%)
rename {loaders => include/loaders}/GP_PBM.h (98%)
rename {loaders => include/loaders}/GP_PGM.h (98%)
rename {core => include/text}/GP_Font.h (93%)
rename {core => include/text}/GP_Text.h (65%)
rename {core => include/text}/GP_TextMetric.h (92%)
rename {core => include/text}/GP_TextStyle.h (91%)
delete mode 100644 input/Makefile
create mode 100644 lib.mk
create mode 100644 libs/Makefile
rename core/tests/GP_font_save.c => libs/backends/GP_Backend.c (62%)
copy targets/sdl/GP_SDL_Context.c => libs/backends/GP_Backend_SDL.c (50%)
create mode 100644 libs/backends/Makefile
rename {core => libs/core}/GP_Color.c (100%)
rename {core => libs/core}/GP_Context.c (75%)
create mode 100644 libs/core/GP_Counter.c
rename {core => libs/core}/GP_GetPixel.c (96%)
rename {core => libs/core}/GP_Palette.c (100%)
create mode 100644 libs/core/GP_Pixel.c
rename {core => libs/core}/GP_PutPixel.c (79%)
rename {core => libs/core}/GP_RetCode.c (98%)
rename {core => libs/core}/GP_WritePixel.c (94%)
create mode 100644 libs/core/Makefile
rename {core => libs/core}/gen/README (100%)
rename {core => libs/core}/gen/defs.py (100%)
rename {core => libs/core}/gen/gen_blit.py (52%)
rename {core => libs/core}/gen/gen_pixeltype.py (86%)
rename {core => libs/core}/gen/gen_utils.py (100%)
rename {core => libs/core}/gen/make_GP_Blit.py (76%)
rename {core => libs/core}/gen/make_GP_Pixel.py (86%)
rename {core => libs/core}/gen/make_GP_Pixel_Scale.py (100%)
rename {core => libs/core}/gen/pixeltype.py (83%)
rename {filters => libs/filters}/GP_Rotate.c (93%)
create mode 100644 libs/filters/Makefile
rename {filters => libs/filters/algo}/GP_MirrorV.algo.h (98%)
rename {filters => libs/filters/algo}/GP_Rotate.algo.h (97%)
rename core/GP_FillCircle.c => libs/gfx/GP_Circle.c (66%)
rename {core => libs/gfx}/GP_Ellipse.c (60%)
rename {core => libs/gfx}/GP_Fill.c (92%)
rename {core => libs/gfx}/GP_HLine.c (72%)
rename {core => libs/gfx}/GP_Line.c (73%)
create mode 100644 libs/gfx/GP_Polygon.c
rename {core => libs/gfx}/GP_Rect.c (57%)
rename {core => libs/gfx}/GP_Symbol.c (80%)
rename {core => libs/gfx}/GP_Tetragon.c (66%)
rename {core => libs/gfx}/GP_Triangle.c (68%)
rename {core => libs/gfx}/GP_VLine.c (71%)
create mode 100644 libs/gfx/Makefile
rename {algo => libs/gfx/algo}/Circle.algo.h (100%)
rename {algo => libs/gfx/algo}/Ellipse.algo.h (100%)
rename {algo => libs/gfx/algo}/FillCircle.algo.h (100%)
rename {algo => libs/gfx/algo}/FillEllipse.algo.h (100%)
rename {algo => libs/gfx/algo}/FillTriangle.algo.h (69%)
rename {algo => libs/gfx/algo}/HLine.algo.h (100%)
rename {algo => libs/gfx/algo}/Line.algo.h (100%)
rename {algo => libs/gfx/algo}/VLine.algo.h (100%)
rename {input => libs/input}/GP_Event.c (100%)
create mode 100644 libs/input/Makefile
rename {loaders => libs/loaders}/GP_PBM.c (100%)
rename {loaders => libs/loaders}/GP_PGM.c (100%)
rename {loaders => libs/loaders}/GP_PXMCommon.c (100%)
rename {loaders => libs/loaders}/GP_PXMCommon.h (99%)
create mode 100644 libs/loaders/Makefile
rename {core => libs/text}/GP_DefaultFont.c (56%)
rename {core => libs/text}/GP_Font.c (91%)
rename {core => libs/text}/GP_Text.c (76%)
rename {core => libs/text}/GP_TextMetric.c (68%)
rename {core => libs/text}/GP_TextStyle.c (94%)
create mode 100644 libs/text/Makefile
rename {algo => libs/text/algo}/Text.algo.h (100%)
delete mode 100644 loaders/Makefile
delete mode 100644 loaders/tests/Makefile
delete mode 100644 old_tests/Makefile
delete mode 100644 old_tests/circlefps.c
delete mode 100644 old_tests/circlestest.c
delete mode 100644 old_tests/ellipsetest.c
delete mode 100644 old_tests/linefps.c
delete mode 100644 old_tests/linetest.c
delete mode 100644 old_tests/pixeltest.c
delete mode 100755 old_tests/runtest.sh
delete mode 100644 old_tests/shapetest.c
delete mode 100644 old_tests/widelinetest.c
delete mode 100644 targets/sdl/Makefile
create mode 100644 tests/Makefile
create mode 100644 tests/core/GP_Comon.test.c
rename core/GP_LineTrack.c => tests/core/GP_Counter.test.c (51%)
rename core/GP_Palette.h => tests/core/GP_Tests.h (50%)
create mode 100644 tests/core/Makefile
rename core/GP_ReadPixel.c => tests/core/core_tests.c (60%)
create mode 100644 tests/core/find_tests.py
copy drivers/GP_Framebuffer.h => tests/core/font.test.c (69%)
rename {drivers => tests/drivers}/GP_Framebuffer.c (67%)
rename {drivers => tests/drivers}/GP_Framebuffer.h (97%)
rename {drivers => tests/drivers}/tests/Makefile (100%)
rename {drivers => tests/drivers}/tests/framebuffer_test.c (68%)
rename {drivers => tests/drivers}/tests/runtest.sh (100%)
rename {drivers => tests/drivers}/tests/sierpinsky.c (98%)
create mode 100644 tests/filters/Makefile
rename {filters/tests => tests/filters}/PGM_rotate.c (100%)
rename {filters/tests => tests/filters}/rotate_test.c (100%)
rename {filters/tests => tests/filters}/runtest.sh (100%)
rename {filters/tests => tests/filters}/test-big.pgm (100%)
create mode 100644 tests/loaders/Makefile
rename {loaders/tests => tests/loaders}/PBM_invert.c (100%)
rename {loaders/tests => tests/loaders}/PBM_test.c (100%)
rename {loaders/tests => tests/loaders}/PGM_invert.c (100%)
rename {loaders/tests => tests/loaders}/PGM_test.c (100%)
rename {loaders/tests => tests/loaders}/autotest.sh (100%)
rename {loaders/tests => tests/loaders}/runtest.sh (100%)
rename {targets => tests}/sdl/GP_SDL.h (100%)
rename {targets => tests}/sdl/GP_SDL_Context.c (100%)
rename {targets => tests}/sdl/GP_SDL_Context.h (100%)
rename {targets => tests}/sdl/GP_SDL_VideoInit.c (100%)
rename {targets => tests}/sdl/GP_SDL_VideoInit.h (100%)
create mode 100644 tests/sdl/Makefile
rename {targets => tests}/sdl/tests/Makefile (89%)
rename {targets => tests}/sdl/tests/fileview.c (97%)
rename {targets => tests}/sdl/tests/fonttest.c (88%)
rename {targets => tests}/sdl/tests/linetest.c (100%)
rename {targets => tests}/sdl/tests/pixeltest.c (100%)
rename {targets => tests}/sdl/tests/randomshapetest.c (93%)
rename {targets => tests}/sdl/tests/runtest.sh (100%)
rename {targets => tests}/sdl/tests/shapetest.c (97%)
rename {targets => tests}/sdl/tests/sierpinsky.c (65%)
rename {targets => tests}/sdl/tests/symbolstest.c (100%)
rename {targets => tests}/sdl/tests/textaligntest.c (98%)
rename {targets => tests}/sdl/tests/trianglefps.c (100%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 665128da4ce856b78beece7af486c561a0a84f58
by metan 22 May '11
by metan 22 May '11
22 May '11
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 665128da4ce856b78beece7af486c561a0a84f58 (commit)
from ca86f291356ade62df38c8059f7f0eecebfe0991 (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/665128da4ce856b78beece7af486c561a0a8…
commit 665128da4ce856b78beece7af486c561a0a84f58
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 23 01:41:27 2011 +0200
build: slightly better library linker scripts.
diff --git a/Makefile b/Makefile
index 6b16da8..35b28d4 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,18 @@ TOPDIR=.
SUBDIRS=libs tests
include include.mk
-tests: libs
+#
+# Make sure tests are build after library and
+# rebuild library before entering test just
+# to be extra safe.
+#
+.PHONY: build
+
+tests: build libs
+
+build:
+ @$(MAKE) --no-print-directory -C build clean
+ @$(MAKE) --no-print-directory -C build
clean:
ifdef VERBOSE
@@ -15,7 +26,7 @@ endif
HEADER_LOC=/usr/include/
LIB_LOC=/usr/lib/
-#install:
+install:
# core library
# install -m 775 -d $(HEADER_LOC)GP/
# install -m 664 core/*.h $(HEADER_LOC)GP/
@@ -33,5 +44,5 @@ LIB_LOC=/usr/lib/
# install -m 664 targets/sdl/*.h $(HEADER_LOC)GP/SDL/
# install -m 664 targets/sdl/*.so targets/sdl/*.so.0 targets/sdl/*.a $(LIB_LOC)
-tar: clean
+tar:
cd .. && tar cjf gfxprim-`date +%Y-%b-%d-%HH%MM`.tar.bz2 gfxprim
diff --git a/build/Makefile b/build/Makefile
index a0fe717..642e852 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -1,16 +1,6 @@
-all: print libs
+LIB_OBJECTS=$(shell ./get_objs.sh)
-print:
-ifndef VERBOSE
- @echo "GEN (linker) libGP.a libGP.so"
-endif
-
-libs: print libGP.a libGP.so
-
-#
-# Do NOT remove this
-#
-.PHONY: libGP.a libGP.so
+all: libGP.a libGP.so
clean:
ifdef VERBOSE
@@ -20,22 +10,22 @@ else
@rm -f libGP.a libGP.so
endif
-libGP.a:
+libGP.a: $(LIB_OBJECTS)
@. ./liblock.sh; spinlock .
ifdef VERBOSE
- ./link.sh libGP.a
+ $(AR) rcs libGP.a $(LIB_OBJECTS)
else
@echo "AR libGP.a"
- @./link.sh libGP.a
+ @$(AR) rcs libGP.a $(LIB_OBJECTS)
endif
@. ./liblock.sh; spinunlock .
-libGP.so:
+libGP.so: $(LIB_OBJECTS)
@. ./liblock.sh; spinlock .
ifdef VERBOSE
- ./link.sh libGP.so
+ $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,libGP.so.0 $(LIB_OBJECTS) -o libGP.so
else
@echo "LD libGP.so"
- @./link.sh libGP.so
+ @$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,libGP.so.0 $(LIB_OBJECTS) -o libGP.so
endif
@. ./liblock.sh; spinunlock .
diff --git a/build/get_objs.sh b/build/get_objs.sh
new file mode 100755
index 0000000..834fd77
--- /dev/null
+++ b/build/get_objs.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+TOPDIR=..
+LIBDIRS="core gfx text loaders filters backends input"
+
+for i in $LIBDIRS; do
+ OBJECTS=`echo $TOPDIR/libs/$i/*.o`;
+
+ if [ "$OBJECTS" != "$TOPDIR/libs/$i/*.o" ]; then
+ echo "$OBJECTS"
+ fi
+done
diff --git a/build/link.sh b/build/link.sh
deleted file mode 100755
index f13ee9e..0000000
--- a/build/link.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-
-TOPDIR=..
-LIBDIRS="core gfx text loaders filters backends input"
-
-get_objects()
-{
- for i in $LIBDIRS; do
- OBJECTS=`echo $TOPDIR/libs/$i/*.o`;
-
- if [ "$OBJECTS" != "$TOPDIR/libs/$i/*.o" ]; then
- echo "$OBJECTS"
- fi
- done
-}
-
-if [ "$1" = "libGP.a" ]; then
- OBJECTS=`get_objects`
-
- ar rcs libGP.a $OBJECTS
-fi
-
-if [ "$1" = "libGP.so" ]; then
- OBJECTS=`get_objects`
-
- gcc -fPIC -dPIC --shared -Wl,-soname -Wl,libGP.so.0 $OBJECTS -o libGP.so
-fi
diff --git a/tests/Makefile b/tests/Makefile
index 676ca51..1008e61 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,3 +1,3 @@
TOPDIR=..
-SUBDIRS=loaders filters #core
+SUBDIRS=loaders filters core
include $(TOPDIR)/include.mk
-----------------------------------------------------------------------
Summary of changes:
Makefile | 17 ++++++++++++++---
build/Makefile | 26 ++++++++------------------
build/get_objs.sh | 12 ++++++++++++
build/link.sh | 27 ---------------------------
tests/Makefile | 2 +-
5 files changed, 35 insertions(+), 49 deletions(-)
create mode 100755 build/get_objs.sh
delete mode 100755 build/link.sh
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: ca86f291356ade62df38c8059f7f0eecebfe0991
by metan 22 May '11
by metan 22 May '11
22 May '11
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 ca86f291356ade62df38c8059f7f0eecebfe0991 (commit)
from 3cefa3907f68f96ec6e2e7ecc4ecf1fb26b96cdb (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/ca86f291356ade62df38c8059f7f0eecebfe…
commit ca86f291356ade62df38c8059f7f0eecebfe0991
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 22 17:07:24 2011 -0400
build: Fix bashism (to work on debian with their dash).
diff --git a/build/liblock.sh b/build/liblock.sh
index 159d23b..2af11e4 100644
--- a/build/liblock.sh
+++ b/build/liblock.sh
@@ -5,9 +5,10 @@ spinlock()
{
I=0
#echo -n "Trying to acquire lock in '$1' ."
- while ! mkdir "$1/.lock" &> /dev/null; do
+ while ! `mkdir "$1/.lock" &> /dev/null`; do
sleep 1;
((I=I+1))
+ echo $I
if [ $I -gt 10 ]; then
echo "Failed to acquire lock '`pwd`/.lock'"
exit 1
diff --git a/build/link.sh b/build/link.sh
index 580ff19..f13ee9e 100755
--- a/build/link.sh
+++ b/build/link.sh
@@ -14,14 +14,14 @@ get_objects()
done
}
-if [ "$1" == "libGP.a" ]; then
- OBJECTS=$(get_objects)
+if [ "$1" = "libGP.a" ]; then
+ OBJECTS=`get_objects`
ar rcs libGP.a $OBJECTS
fi
-if [ "$1" == "libGP.so" ]; then
- OBJECTS=$(get_objects)
+if [ "$1" = "libGP.so" ]; then
+ OBJECTS=`get_objects`
gcc -fPIC -dPIC --shared -Wl,-soname -Wl,libGP.so.0 $OBJECTS -o libGP.so
fi
-----------------------------------------------------------------------
Summary of changes:
build/liblock.sh | 3 ++-
build/link.sh | 8 ++++----
2 files changed, 6 insertions(+), 5 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 3cefa3907f68f96ec6e2e7ecc4ecf1fb26b96cdb
by metan 22 May '11
by metan 22 May '11
22 May '11
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 3cefa3907f68f96ec6e2e7ecc4ecf1fb26b96cdb (commit)
from 44de9a46432c45949764964d3c49e65e2bb9701b (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/3cefa3907f68f96ec6e2e7ecc4ecf1fb26b9…
commit 3cefa3907f68f96ec6e2e7ecc4ecf1fb26b96cdb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 22 22:16:28 2011 +0200
Fix the directory layout and build system.
And so the man divided the darkness from
the light, the wild from the home, the work
from the relief and so the chaos was ordered
and calculated and finally disappeared.
diff --git a/Makefile b/Makefile
index c0c29af..6b16da8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,49 +1,37 @@
-HEADER_LOC=/usr/include/
-LIB_LOC=/usr/lib/
-
-.PHONY: all core sdl drivers loaders install filters clean tar
-
-all: core sdl drivers loaders filters
-
-drivers:
- cd drivers && $(MAKE) all
-
-core:
- cd core && $(MAKE) all
+TOPDIR=.
+SUBDIRS=libs tests
+include include.mk
-sdl: core
- cd targets/sdl && $(MAKE) all
+tests: libs
-loaders:
- cd loaders && $(MAKE) all
+clean:
+ifdef VERBOSE
+ $(MAKE) -C build clean
+else
+ @echo "/build"
+ @$(MAKE) --no-print-directory -C build clean
+endif
-filters:
- cd filters && $(MAKE) all
+HEADER_LOC=/usr/include/
+LIB_LOC=/usr/lib/
-install:
+#install:
# core library
- install -m 775 -d $(HEADER_LOC)GP/
- install -m 664 core/*.h $(HEADER_LOC)GP/
- install -m 664 core/*.so core/*.so.0 core/*.a $(LIB_LOC)
+# install -m 775 -d $(HEADER_LOC)GP/
+# install -m 664 core/*.h $(HEADER_LOC)GP/
+# install -m 664 core/*.so core/*.so.0 core/*.a $(LIB_LOC)
# bitmap loaders
- install -m 775 -d $(HEADER_LOC)GP/loaders/
- install -m 664 loaders/*.h $(HEADER_LOC)GP/loaders/
- install -m 664 loaders/*.so loaders/*.so.0 loaders/*.a $(LIB_LOC)
+# install -m 775 -d $(HEADER_LOC)GP/loaders/
+# install -m 664 loaders/*.h $(HEADER_LOC)GP/loaders/
+# install -m 664 loaders/*.so loaders/*.so.0 loaders/*.a $(LIB_LOC)
# context filters
- install -m 775 -d $(HEADER_LOC)GP/filters/
- install -m 664 filters/*.h $(HEADER_LOC)GP/filters/
- install -m 664 filters/*.so filters/*.so.0 filters/*.a $(LIB_LOC)
+# install -m 775 -d $(HEADER_LOC)GP/filters/
+# install -m 664 filters/*.h $(HEADER_LOC)GP/filters/
+# install -m 664 filters/*.so filters/*.so.0 filters/*.a $(LIB_LOC)
# sdl target
- install -m 775 -d $(HEADER_LOC)GP/SDL/
- install -m 664 targets/sdl/*.h $(HEADER_LOC)GP/SDL/
- install -m 664 targets/sdl/*.so targets/sdl/*.so.0 targets/sdl/*.a $(LIB_LOC)
-
-clean:
- cd core && $(MAKE) clean
- cd targets/sdl && $(MAKE) clean
- cd drivers && $(MAKE) clean
- cd loaders && $(MAKE) clean
- cd filters && $(MAKE) clean
+# install -m 775 -d $(HEADER_LOC)GP/SDL/
+# install -m 664 targets/sdl/*.h $(HEADER_LOC)GP/SDL/
+# install -m 664 targets/sdl/*.so targets/sdl/*.so.0 targets/sdl/*.a $(LIB_LOC)
tar: clean
cd .. && tar cjf gfxprim-`date +%Y-%b-%d-%HH%MM`.tar.bz2 gfxprim
diff --git a/algo/README b/algo/README
deleted file mode 100644
index 7ec8962..0000000
--- a/algo/README
+++ /dev/null
@@ -1,7 +0,0 @@
-This directory contains implementations of various drawing algorithms
-in form of macros. Each macro generates a function that draws a shape
-using lower-level primitives that are specified by the user.
-
-This allows for having multiple drawing functions customized for various
-conditions, typically various bit depths.
-
diff --git a/app.mk b/app.mk
new file mode 100644
index 0000000..4c90884
--- /dev/null
+++ b/app.mk
@@ -0,0 +1,15 @@
+ifndef APPS
+$(error APPS not defined, fix your library Makefile)
+endif
+
+all: $(APPS)
+
+CLEAN+=$(APPS)
+
+%: %.o
+ifdef VERBOSE
+ $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $(LDLIBS) $^ -Wl,--end-group -o $@
+else
+ @echo "LD $@"
+ @$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $(LDLIBS) $^ -Wl,--end-group -o $@
+endif
diff --git a/build/Makefile b/build/Makefile
new file mode 100644
index 0000000..a0fe717
--- /dev/null
+++ b/build/Makefile
@@ -0,0 +1,41 @@
+all: print libs
+
+print:
+ifndef VERBOSE
+ @echo "GEN (linker) libGP.a libGP.so"
+endif
+
+libs: print libGP.a libGP.so
+
+#
+# Do NOT remove this
+#
+.PHONY: libGP.a libGP.so
+
+clean:
+ifdef VERBOSE
+ rm -f libGP.a libGP.so
+else
+ @echo "RM libGP.a libGP.so"
+ @rm -f libGP.a libGP.so
+endif
+
+libGP.a:
+ @. ./liblock.sh; spinlock .
+ifdef VERBOSE
+ ./link.sh libGP.a
+else
+ @echo "AR libGP.a"
+ @./link.sh libGP.a
+endif
+ @. ./liblock.sh; spinunlock .
+
+libGP.so:
+ @. ./liblock.sh; spinlock .
+ifdef VERBOSE
+ ./link.sh libGP.so
+else
+ @echo "LD libGP.so"
+ @./link.sh libGP.so
+endif
+ @. ./liblock.sh; spinunlock .
diff --git a/build/liblock.sh b/build/liblock.sh
new file mode 100644
index 0000000..159d23b
--- /dev/null
+++ b/build/liblock.sh
@@ -0,0 +1,24 @@
+#
+# Takes directory as parameter
+#
+spinlock()
+{
+ I=0
+ #echo -n "Trying to acquire lock in '$1' ."
+ while ! mkdir "$1/.lock" &> /dev/null; do
+ sleep 1;
+ ((I=I+1))
+ if [ $I -gt 10 ]; then
+ echo "Failed to acquire lock '`pwd`/.lock'"
+ exit 1
+ fi
+ # echo -n .
+ done
+ #echo " done"
+}
+
+spinunlock()
+{
+ #echo "Removing lock in '$1'"
+ rmdir "$1/.lock" &> /dev/null
+}
diff --git a/build/link.sh b/build/link.sh
new file mode 100755
index 0000000..580ff19
--- /dev/null
+++ b/build/link.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+TOPDIR=..
+LIBDIRS="core gfx text loaders filters backends input"
+
+get_objects()
+{
+ for i in $LIBDIRS; do
+ OBJECTS=`echo $TOPDIR/libs/$i/*.o`;
+
+ if [ "$OBJECTS" != "$TOPDIR/libs/$i/*.o" ]; then
+ echo "$OBJECTS"
+ fi
+ done
+}
+
+if [ "$1" == "libGP.a" ]; then
+ OBJECTS=$(get_objects)
+
+ ar rcs libGP.a $OBJECTS
+fi
+
+if [ "$1" == "libGP.so" ]; then
+ OBJECTS=$(get_objects)
+
+ gcc -fPIC -dPIC --shared -Wl,-soname -Wl,libGP.so.0 $OBJECTS -o libGP.so
+fi
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..6653c55
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,3 @@
+CFLAGS+=-W -Wall -Wextra -fPIC -ggdb -O2 -std=gnu99
+CFLAGS+=-I$(TOPDIR)/include/
+LDLIBS+=-ldl
diff --git a/core/GP_Circle.c b/core/GP_Circle.c
deleted file mode 100644
index 8be5f55..0000000
--- a/core/GP_Circle.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include "GP.h"
-#include "algo/Circle.algo.h"
-#include "GP_FnPerBpp.h"
-
-/* Generate drawing functions for various bit depths. */
-DEF_CIRCLE_FN(GP_Circle1bpp, GP_Context *, GP_Pixel, GP_PutPixel1bpp)
-DEF_CIRCLE_FN(GP_Circle2bpp, GP_Context *, GP_Pixel, GP_PutPixel2bpp)
-DEF_CIRCLE_FN(GP_Circle4bpp, GP_Context *, GP_Pixel, GP_PutPixel4bpp)
-DEF_CIRCLE_FN(GP_Circle8bpp, GP_Context *, GP_Pixel, GP_PutPixel8bpp)
-DEF_CIRCLE_FN(GP_Circle16bpp, GP_Context *, GP_Pixel, GP_PutPixel16bpp)
-DEF_CIRCLE_FN(GP_Circle24bpp, GP_Context *, GP_Pixel, GP_PutPixel24bpp)
-DEF_CIRCLE_FN(GP_Circle32bpp, GP_Context *, GP_Pixel, GP_PutPixel32bpp)
-
-void GP_Circle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel)
-{
- GP_CHECK_CONTEXT(context);
-
- GP_FN_PER_BPP(GP_Circle, context->bpp, context,
- xcenter, ycenter, r, pixel);
-}
-
-void GP_TCircle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel)
-{
- GP_CHECK_CONTEXT(context);
-
- /* Just recalculate center point */
- GP_TRANSFORM_POINT(context, xcenter, ycenter);
-
- GP_Circle(context, xcenter, ycenter, r, pixel);
-}
diff --git a/core/GP_FillEllipse.c b/core/GP_FillEllipse.c
deleted file mode 100644
index 5625012..0000000
--- a/core/GP_FillEllipse.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include "GP.h"
-#include "GP_FnPerBpp.h"
-#include "algo/FillEllipse.algo.h"
-
-/* Generate drawing functions for various bit depths. */
-DEF_FILLELLIPSE_FN(GP_FillEllipse1bpp, GP_Context *, GP_Pixel, GP_HLine1bpp)
-DEF_FILLELLIPSE_FN(GP_FillEllipse2bpp, GP_Context *, GP_Pixel, GP_HLine2bpp)
-DEF_FILLELLIPSE_FN(GP_FillEllipse4bpp, GP_Context *, GP_Pixel, GP_HLine4bpp)
-DEF_FILLELLIPSE_FN(GP_FillEllipse8bpp, GP_Context *, GP_Pixel, GP_HLine8bpp)
-DEF_FILLELLIPSE_FN(GP_FillEllipse16bpp, GP_Context *, GP_Pixel, GP_HLine16bpp)
-DEF_FILLELLIPSE_FN(GP_FillEllipse24bpp, GP_Context *, GP_Pixel, GP_HLine24bpp)
-DEF_FILLELLIPSE_FN(GP_FillEllipse32bpp, GP_Context *, GP_Pixel, GP_HLine32bpp)
-
-void GP_FillEllipse(GP_Context *context, int xcenter, int ycenter,
- unsigned int a, unsigned int b, GP_Pixel pixel)
-{
- GP_CHECK_CONTEXT(context);
-
- GP_FN_PER_BPP(GP_FillEllipse, context->bpp, context,
- xcenter, ycenter, a, b, pixel);
-}
-
-void GP_TFillEllipse(GP_Context *context, int xcenter, int ycenter,
- unsigned int a, unsigned int b, GP_Pixel pixel)
-{
- GP_CHECK_CONTEXT(context);
-
- GP_TRANSFORM_POINT(context, xcenter, ycenter);
- GP_TRANSFORM_SWAP(context, a, b);
-
- GP_FillEllipse(context, xcenter, ycenter, a, b, pixel);
-}
diff --git a/core/GP_FillEllipse.h b/core/GP_FillEllipse.h
deleted file mode 100644
index cf0c7c5..0000000
--- a/core/GP_FillEllipse.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#ifndef GP_FILLELLIPSE_H
-#define GP_FILLELLIPSE_H
-
-#include "GP_Context.h"
-
-#include <stdint.h>
-
-void GP_FillEllipse(GP_Context *context, int xcenter, int ycenter,
- unsigned int a, unsigned int b, GP_Pixel pixel);
-
-void GP_TFillEllipse(GP_Context *context, int xcenter, int ycenter,
- unsigned int a, unsigned int b, GP_Pixel pixel);
-
-#endif /* GP_FILLELLIPSE_H */
diff --git a/core/GP_FillRect.h b/core/GP_FillRect.h
deleted file mode 100644
index c12f57e..0000000
--- a/core/GP_FillRect.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#ifndef GP_FILLRECT_H
-#define GP_FILLRECT_H
-
-#include "GP_Context.h"
-
-void GP_FillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1,
- GP_Pixel pixel);
-
-void GP_FillRectXYWH(GP_Context *context, int x, int y,
- unsigned int w, unsigned int h, GP_Pixel pixel);
-
-void GP_TFillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1,
- GP_Pixel pixel);
-
-void GP_TFillRectXYWH(GP_Context *context, int x, int y,
- unsigned int w, unsigned int h, GP_Pixel pixel);
-
-#define GP_FillRect GP_FillRectXYXY
-#define GP_TFillRect GP_TFillRectXYXY
-
-#endif /* GP_FILLRECT_H */
diff --git a/core/GP_LineTrack.c b/core/GP_LineTrack.c
deleted file mode 100644
index fbf21b4..0000000
--- a/core/GP_LineTrack.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include "GP.h"
-
-inline void GP_LineTrackInit(struct GP_LineTrack *track, int x0, int y0,
- int x1, int y1)
-{
- track->x0 = x0;
- track->y0 = y0;
- track->x1 = x1;
- track->y1 = y1;
-
- track->dx = abs(x1 - x0);
- track->dy = abs(y1 - y0);
- track->xstep = (x0 < x1) ? 1 : -1;
- track->ystep = (y0 < y1) ? 1 : -1;
-
- track->x = x0;
- track->y = y0;
- track->err = track->dx - track->dy;
- track->xmin = x0;
- track->xmax = x0;
-}
-
-inline void GP_LineTrackNext(struct GP_LineTrack *track)
-{
- int x = track->x;
- int xmin = track->x;
- int xmax = track->x;
-
- for (;;) {
- xmin = GP_MIN(x, xmin);
- xmax = GP_MAX(x, xmax);
-
- if (x == track->x1 && track->y == track->y1)
- break;
-
- int err2 = 2*track->err;
- if (err2 > -track->dy) {
- track->err -= track->dy;
- x += track->xstep;
- }
- if (err2 < track->dx) {
- track->err += track->dx;
- track->y += track->ystep;
- break;
- }
- }
-
- track->x = x;
- track->xmin = xmin;
- track->xmax = xmax;
-}
diff --git a/core/GP_LineTrack.h b/core/GP_LineTrack.h
deleted file mode 100644
index 4a505b8..0000000
--- a/core/GP_LineTrack.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#ifndef GP_LINE_TRACK_H
-#define GP_LINE_TRACK_H
-
-#define GP_KEEP_FIRST 1
-#define GP_KEEP_XMIN 2
-#define GP_KEEP_XMAX 4
-
-/* This structure is used to track the starting and ending points of a line
- * drawn by Bresenham algorithm, scanline by scanline (in a top-down manner).
- * Use GP_LineTrackInit() to initialize the structure.
- * Use GP_LineTrackNext() to calculate the next scanline.
- */
-struct GP_LineTrack {
-
- /* these values are constant during the tracking */
-
- int x0, y0; /* starting point (inclusive) */
- int x1, y1; /* ending point (inclusive) */
- int dx; /* absolute difference between x0 and x1 */
- int dy; /* ditto for Y */
- int xstep; /* +1 if X increases, -1 if it decreases */
- int ystep; /* ditto for Y */
-
- /* only the values below are changing during the tracking */
-
- int x, y; /* current X and Y position */
- int err; /* error term (difference in Y from ideal line) */
-
- /* output values, written by GP_LineTrackNext(), never reused */
-
- int xmin; /* minimum X value for the PREVIOUS scanline */
- int xmax; /* maximum X value for the PREVIOUS scanline */
-};
-
-/* Initializes the GP_LineTrack structure and prepares for tracking the line
- * from (x0, y0) to (x1, y1), inclusive.
- * IMPORTANT: At this point, the 'xmin', 'xmax' fields are not yet computed!
- * You must call GP_LineTrackNext() to obtain values for the first scanline.
- */
-inline void GP_LineTrackInit(struct GP_LineTrack *track, int x0, int y0, int x1, int y1);
-
-/* Calculates the next scanline of the Bresenham line algorithm,
- * updating the 'x', 'y', 'err' fields and writing 'xmin', 'xmax'.
- */
-inline void GP_LineTrackNext(struct GP_LineTrack *track);
-
-#endif /* GP_LINE_TRACK_H */
diff --git a/core/GP_Rect.c b/core/GP_Rect.c
deleted file mode 100644
index 08cecc1..0000000
--- a/core/GP_Rect.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include "GP.h"
-
-void GP_RectXYXY(GP_Context *context, int x0, int y0, int x1, int y1,
- GP_Pixel pixel)
-{
- GP_CHECK_CONTEXT(context);
-
- GP_HLine(context, x0, x1, y0, pixel);
- GP_HLine(context, x0, x1, y1, pixel);
- GP_VLine(context, x0, y0, y1, pixel);
- GP_VLine(context, x1, y0, y1, pixel);
-}
-
-void GP_RectXYWH(GP_Context *context, int x, int y,
- unsigned int w, unsigned int h, GP_Pixel pixel)
-{
- GP_CHECK_CONTEXT(context);
-
- GP_HLine(context, x, x + w, y, pixel);
- GP_HLine(context, x, x + w, y + h, pixel);
- GP_VLine(context, x, y, y + h, pixel);
- GP_VLine(context, x + w, y, y + h, pixel);
-}
-
-void GP_TRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1,
- GP_Pixel pixel)
-{
- GP_CHECK_CONTEXT(context);
-
- GP_TRANSFORM_POINT(context, x0, y0);
- GP_TRANSFORM_POINT(context, x1, y1);
-
- GP_RectXYXY(context, x0, y0, x1, y1, pixel);
-}
-
-void GP_TRectXYWH(GP_Context *context, int x, int y,
- unsigned int w, unsigned int h, GP_Pixel pixel)
-{
- GP_TRectXYXY(context, x, y, x + w, y + h, pixel);
-}
diff --git a/core/Makefile b/core/Makefile
deleted file mode 100644
index b23dad4..0000000
--- a/core/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-COREDIR=`pwd`
-LIBRARY=libGP_core
-SOURCES=$(wildcard *.c) $(wildcard ../backends/*.c)
-OBJECTS=$(SOURCES:.c=.o)
-HEADERS=$(wildcard *.h) $(wildcard ../backends/*.h)
-ALGORITHMS=$(wildcard ../algo/*.algo.h)
-CFLAGS=-W -Wall -O2 -fPIC -I$(COREDIR) -I$(COREDIR)/../
-
-HEADER_LOC=/usr/include/
-LIB_LOC=/usr/lib/
-
-.PHONY: all clean tests
-
-all: $(LIBRARY)
-
-tests: $(LIBRARY)
- cd tests && $(MAKE) all
-
-$(LIBRARY): $(LIBRARY).a $(LIBRARY).so
-
-$(OBJECTS): $(HEADERS) $(ALGORITHMS)
-
-$(LIBRARY).a: $(OBJECTS)
- ar crus $@ $^
-
-$(LIBRARY).so: $(OBJECTS)
- $(CC) -fPIC -dPIC -lm -ldl --shared -Wl,-soname -Wl,$@.0 $(CFLAGS) $^ -o $@
- ln -sf $@ $@.0
-
-%.o: %.c $(ALGORITHMS)
- $(CC) $(CFLAGS) $< -c -o $@
-
-clean:
- rm -f $(LIBRARY).a $(LIBRARY).so $(LIBRARY).so.0
- rm -f *.o
- rm -f ../backends/*.o
- cd tests && $(MAKE) clean
-
diff --git a/core/tests/Makefile b/core/tests/Makefile
deleted file mode 100644
index b56bcc6..0000000
--- a/core/tests/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-LIBRARY=../libGP_core.a
-LDFLAGS=-L../ -lGP_core
-
-INCLUDE=-I../
-
-CFLAGS=$(INCLUDE) -ggdb -W -Wall -O -std=gnu99
-
-TESTS=core_tests
-
-# General stuff
-
-.PHONY: all clean run
-
-all: $(TESTS)
-
-clean:
- rm -f *.o *.tmp
- rm -f $(TESTS)
- rm -f core_tests.gen.c
-
-run: $(TESTS)
- for test in $(TESTS); do LD_LIBRARY_PATH=../ ./"$$test" -v ; done
-
-# Check tests
-
-TEST_SRCS=$(wildcard *.test.c)
-TEST_OBJS=$(patsubst %.c,%.o,$(TEST_SRCS))
-
-core_tests.gen.c: $(TEST_SRCS) find_tests.py
- python find_tests.py -c $@ $(TEST_SRCS)
-
-core_tests: $(TEST_OBJS) core_tests.o core_tests.gen.o
- $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBRARY) -lcheck -o $@
diff --git a/drivers/Makefile b/drivers/Makefile
deleted file mode 100644
index ffd891b..0000000
--- a/drivers/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-LIBRARY=libGP_drivers
-SOURCES=$(wildcard *.c)
-OBJECTS=$(SOURCES:.c=.o)
-HEADERS=$(wildcard *.h)
-CFLAGS=-I../core/ -W -Wall -O2 -fPIC
-
-.PHONY: all clean
-
-all: $(LIBRARY)
- cd tests && $(MAKE) all
-
-$(LIBRARY): $(LIBRARY).a $(LIBRARY).so
-
-$(OBJECTS): $(HEADERS)
-
-$(LIBRARY).a: $(OBJECTS)
- ar crus $@ $^
-
-$(LIBRARY).so: $(OBJECTS)
- $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$@.0 $(CFLAGS) $^ -o $@
- ln -sf $@ $@.0
-
-%.o: %.c
- $(CC) $(CFLAGS) $< -c -o $@
-
-clean:
- rm -f $(LIBRARY).a $(LIBRARY).so $(LIBRARY).so.0
- rm -f *.o
- cd tests && $(MAKE) clean
diff --git a/filters/Makefile b/filters/Makefile
deleted file mode 100644
index 58b807b..0000000
--- a/filters/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-LIBRARY=libGP_filters
-SOURCES=$(wildcard *.c)
-OBJECTS=$(SOURCES:.c=.o)
-HEADERS=$(wildcard *.h)
-CFLAGS=-I../core/ -W -Wall -O2 -fPIC
-
-.PHONY: all clean
-
-all: $(LIBRARY)
- cd tests && $(MAKE) all
-
-$(LIBRARY): $(LIBRARY).a $(LIBRARY).so
-
-$(OBJECTS): $(HEADERS)
-
-$(LIBRARY).a: $(OBJECTS)
- ar crus $@ $^
-
-$(LIBRARY).so: $(OBJECTS)
- $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$@.0 $(CFLAGS) $^ -o $@
- ln -sf $@ $@.0
-
-%.o: %.c
- $(CC) $(CFLAGS) $< -c -o $@
-
-clean:
- rm -f $(LIBRARY).a $(LIBRARY).so $(LIBRARY).so.0
- rm -f *.o
- cd tests && $(MAKE) clean
diff --git a/filters/tests/Makefile b/filters/tests/Makefile
deleted file mode 100644
index 4fe81db..0000000
--- a/filters/tests/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-LDFLAGS=-L../ -L../../core/ -L../../loaders/ -lGP_core -lGP_loaders -lGP_filters
-
-INCLUDE=-I../ -I../../core/ -I../../loaders/
-# Some warnings are triggered only with -O2
-# thuss added here
-CFLAGS=$(INCLUDE) -ggdb -W -Wall -O2 -lm
-SOURCES=$(wildcard *.c)
-TESTS=$(SOURCES:.c=)
-
-all: $(TESTS)
-
-%: %.c
- $(CC) $(CFLAGS) $(LDFLAGS) $(LIBRARY) $^ -o $@
-
-clean:
- rm -f *.o $(TESTS)
- rm -f test-mv.pgm test-mh.pgm test-cw.pgm test-ccw.pgm
diff --git a/include.mk b/include.mk
new file mode 100644
index 0000000..68fab64
--- /dev/null
+++ b/include.mk
@@ -0,0 +1,101 @@
+.PHONY: $(SUBDIRS) all clean help
+
+all: $(SUBDIRS)
+clean: $(SUBDIRS)
+
+help:
+ @echo "*** Available targets ***"
+ @echo ""
+ @echo "help: prints this help"
+ @echo ""
+ @echo "clean: cleans current directory and all subdirectories"
+ @echo ""
+ @echo "all: make current directory and all subdirectories"
+ @echo ""
+ @echo "The default silent output could be turned off by defining"
+ @echo "'VERBOSE' shell variable as 'VERBOSE=1 make'"
+ @echo ""
+
+include $(TOPDIR)/config.mk
+
+#
+# Determine mode (eg do not generate anything if not in compile mode
+#
+COMPILE=no
+
+ifeq ($(MAKECMDGOALS),all)
+COMPILE=yes
+endif
+
+ifeq ($(MAKECMDGOALS),)
+COMPILE=yes
+endif
+
+#
+# 1. Generate and include dependencies for all C sources
+# 2. Generate OBJECTS list from CSOURCES list
+# 3. Adds OBJECTS to CLEAN list
+#
+ifdef CSOURCES
+DEPFILES=$(subst .c,.dep,$(CSOURCES))
+ifeq ($(COMPILE),yes)
+-include $(DEPFILES)
+endif
+CLEAN+=$(subst .c,.dep,$(CSOURCES))
+OBJECTS=$(CSOURCES:.c=.o)
+CLEAN+=$(OBJECTS)
+endif
+
+#
+# Automatically include library headers
+#
+ifdef LIBNAME
+INCLUDE+=$(LIBNAME)
+endif
+
+#
+# If there was anything in INCLUDE list, create CFLAGS for each entry
+#
+ifdef INCLUDE
+CFLAGS+=$(addprefix -I$(TOPDIR)/include/, $(INCLUDE))
+endif
+
+#
+# Walk trought SUBDIRS, this code works even for -jX
+#
+$(SUBDIRS):
+ifdef VERBOSE
+ $(MAKE) -C $@ $(MAKECMDGOALS)
+else
+ @export CURSUBDIR="$$CURSUBDIR/$@" && echo "DIR $$CURSUBDIR" &&+ $(MAKE) --no-print-directory -C $@ $(MAKECMDGOALS)
+endif
+
+#
+# Actual make rules
+#
+$(DEPFILES): %.dep: %.c
+ifdef VERBOSE
+ $(CC) -MM $(CFLAGS) $< -o $@
+else
+ @echo "DEP -I(include $(INCLUDE)) $@"
+ @$(CC) -MM $(CFLAGS) $< -o $@
+endif
+
+$(OBJECTS): %.o: %.c
+ifdef VERBOSE
+ $(CC) $(CFLAGS) -c $< -o $@
+else
+ @echo "CC -I(include $(INCLUDE)) $@"
+ @$(CC) $(CFLAGS) -c $< -o $@
+endif
+
+ifdef CLEAN
+clean:
+ifdef VERBOSE
+ rm -f $(CLEAN)
+else
+ @echo "RM $(CLEAN)"
+ @rm -f $(CLEAN)
+endif
+endif
diff --git a/filters/GP_Filters.h b/include/GP.h
similarity index 90%
copy from filters/GP_Filters.h
copy to include/GP.h
index eb63d43..e68b747 100644
--- a/filters/GP_Filters.h
+++ b/include/GP.h
@@ -23,15 +23,16 @@
* *
*****************************************************************************/
-/*
+#ifndef GP_H
+#define GP_H
- GP_Context filters.
+/* library core */
+#include "core/GP_Core.h"
- */
+/* public drawing API */
+#include "gfx/GP_Gfx.h"
-#ifndef GP_FILTERS_H
-#define GP_FILTERS_H
+/* fonts and text drawing */
+#include "text/GP_Text.h"
-#include "GP_Rotate.h"
-
-#endif /* GP_FILTERS_H */
+#endif /* GP_H */
diff --git a/core/GP_Backend.h b/include/backends/GP_Backend.h
similarity index 99%
rename from core/GP_Backend.h
rename to include/backends/GP_Backend.h
index d1dff51..3f81ed7 100644
--- a/core/GP_Backend.h
+++ b/include/backends/GP_Backend.h
@@ -26,7 +26,7 @@
#ifndef GP_BACKEND_H
#define GP_BACKEND_H
-#include "GP_Context.h"
+#include "core/GP_Context.h"
/*
* Types of events provided by the backend.
diff --git a/core/config.h b/include/config.h
similarity index 91%
rename from core/config.h
rename to include/config.h
index baac35b..cd640ca 100644
--- a/core/config.h
+++ b/include/config.h
@@ -1,3 +1 @@
-
#define GP_HAVE_SDL 1
-
diff --git a/core/GP_Clip.h b/include/core/GP_Clip.h
similarity index 100%
rename from core/GP_Clip.h
rename to include/core/GP_Clip.h
diff --git a/core/GP_Color.h b/include/core/GP_Color.h
similarity index 100%
rename from core/GP_Color.h
rename to include/core/GP_Color.h
diff --git a/core/GP_Common.h b/include/core/GP_Common.h
similarity index 100%
rename from core/GP_Common.h
rename to include/core/GP_Common.h
diff --git a/core/GP_Context.h b/include/core/GP_Context.h
similarity index 98%
rename from core/GP_Context.h
rename to include/core/GP_Context.h
index 67851b5..acb04f9 100644
--- a/core/GP_Context.h
+++ b/include/core/GP_Context.h
@@ -57,7 +57,10 @@ typedef struct GP_Context {
} GP_Context;
/* Returns the pixel type used by the context. */
-inline GP_PixelType GP_GetContextPixelType(const GP_Context *context);
+static inline GP_PixelType GP_GetContextPixelType(const GP_Context *context)
+{
+ return context->pixel_type;
+}
/* Determines the address of a pixel within the context's image.
* Rows and columns are specified in the image's orientation
diff --git a/core/GP_FillCircle.h b/include/core/GP_Core.h
similarity index 84%
rename from core/GP_FillCircle.h
rename to include/core/GP_Core.h
index 208a6b8..dd70700 100644
--- a/core/GP_FillCircle.h
+++ b/include/core/GP_Core.h
@@ -23,15 +23,26 @@
* *
*****************************************************************************/
-#ifndef GP_FILLCIRCLE_H
-#define GP_FILLCIRCLE_H
+/*
-#include "GP_Context.h"
+ This is header file for public core API.
-void GP_FillCircle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel);
+ */
-void GP_TFillCircle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel);
+#ifndef GP_CORE_H
+#define GP_CORE_H
-#endif /* GP_FILLCIRCLE_H */
+/* Common building blocks */
+#include "core/GP_Common.h"
+
+/* Context ... */
+#include "core/GP_Context.h"
+
+/* ... and it's trasformations */
+#include "core/GP_Transform.h"
+
+/* Pixels */
+#include "GP_GetPixel.h"
+#include "GP_PutPixel.h"
+
+#endif /* GP_CORE_H */
diff --git a/core/GP_FnPerBpp.h b/include/core/GP_FnPerBpp.h
similarity index 99%
rename from core/GP_FnPerBpp.h
rename to include/core/GP_FnPerBpp.h
index 2a745e7..22f15c4 100644
--- a/core/GP_FnPerBpp.h
+++ b/include/core/GP_FnPerBpp.h
@@ -23,8 +23,6 @@
* *
*****************************************************************************/
-#include "GP.h"
-
/*
* Macro that generates a switch-case block that calls various variants
* of the specified function depending on the bit depth of the context.
diff --git a/core/GP_GetPixel.h b/include/core/GP_GetPixel.h
similarity index 100%
rename from core/GP_GetPixel.h
rename to include/core/GP_GetPixel.h
diff --git a/core/GP_Palette.h b/include/core/GP_Palette.h
similarity index 100%
rename from core/GP_Palette.h
rename to include/core/GP_Palette.h
diff --git a/core/GP_Pixel.h b/include/core/GP_Pixel.h
similarity index 100%
rename from core/GP_Pixel.h
rename to include/core/GP_Pixel.h
diff --git a/core/GP_PutPixel.h b/include/core/GP_PutPixel.h
similarity index 100%
rename from core/GP_PutPixel.h
rename to include/core/GP_PutPixel.h
diff --git a/core/GP_RetCode.h b/include/core/GP_RetCode.h
similarity index 100%
rename from core/GP_RetCode.h
rename to include/core/GP_RetCode.h
diff --git a/core/GP_Transform.h b/include/core/GP_Transform.h
similarity index 100%
rename from core/GP_Transform.h
rename to include/core/GP_Transform.h
diff --git a/core/GP_WritePixel.h b/include/core/GP_WritePixel.h
similarity index 100%
rename from core/GP_WritePixel.h
rename to include/core/GP_WritePixel.h
diff --git a/filters/GP_Filters.h b/include/filters/GP_Filters.h
similarity index 100%
rename from filters/GP_Filters.h
rename to include/filters/GP_Filters.h
diff --git a/filters/GP_Rotate.h b/include/filters/GP_Rotate.h
similarity index 98%
rename from filters/GP_Rotate.h
rename to include/filters/GP_Rotate.h
index f1ec0c8..e73b0fe 100644
--- a/filters/GP_Rotate.h
+++ b/include/filters/GP_Rotate.h
@@ -32,7 +32,7 @@
#ifndef GP_ROTATE_H
#define GP_ROTATE_H
-#include "GP_Context.h"
+#include "core/GP_Context.h"
/*
* Mirror horizontally.
@@ -54,5 +54,4 @@ GP_RetCode GP_RotateCW(GP_Context *context);
*/
GP_RetCode GP_RotateCCW(GP_Context *context);
-
#endif /* GP_ROTATE_H */
diff --git a/core/GP_Circle.h b/include/gfx/GP_Circle.h
similarity index 89%
rename from core/GP_Circle.h
rename to include/gfx/GP_Circle.h
index 9c2d4ea..6360e72 100644
--- a/core/GP_Circle.h
+++ b/include/gfx/GP_Circle.h
@@ -26,7 +26,7 @@
#ifndef GP_CIRCLE_H
#define GP_CIRCLE_H
-#include "GP_Context.h"
+#include "core/GP_Context.h"
void GP_Circle(GP_Context *context, int xcenter, int ycenter,
unsigned int r, GP_Pixel pixel);
@@ -34,4 +34,10 @@ void GP_Circle(GP_Context *context, int xcenter, int ycenter,
void GP_TCircle(GP_Context *context, int xcenter, int ycenter,
unsigned int r, GP_Pixel pixel);
+void GP_FillCircle(GP_Context *context, int xcenter, int ycenter,
+ unsigned int r, GP_Pixel pixel);
+
+void GP_TFillCircle(GP_Context *context, int xcenter, int ycenter,
+ unsigned int r, GP_Pixel pixel);
+
#endif /* GP_CIRCLE_H */
diff --git a/core/GP_Ellipse.h b/include/gfx/GP_Ellipse.h
similarity index 87%
rename from core/GP_Ellipse.h
rename to include/gfx/GP_Ellipse.h
index 5f29458..eeb6d5a 100644
--- a/core/GP_Ellipse.h
+++ b/include/gfx/GP_Ellipse.h
@@ -26,7 +26,7 @@
#ifndef GP_ELLIPSE_H
#define GP_ELLIPSE_H
-#include "GP_Context.h"
+#include "core/GP_Context.h"
void GP_Ellipse(GP_Context *context, int xcenter, int ycenter,
unsigned int a, unsigned int b, GP_Pixel pixel);
@@ -34,4 +34,11 @@ void GP_Ellipse(GP_Context *context, int xcenter, int ycenter,
void GP_TEllipse(GP_Context *context, int xcenter, int ycenter,
unsigned int a, unsigned int b, GP_Pixel pixel);
+void GP_FillEllipse(GP_Context *context, int xcenter, int ycenter,
+ unsigned int a, unsigned int b, GP_Pixel pixel);
+
+void GP_TFillEllipse(GP_Context *context, int xcenter, int ycenter,
+ unsigned int a, unsigned int b, GP_Pixel pixel);
+
+
#endif /* GP_ELLIPSE_H */
diff --git a/core/GP_Fill.h b/include/gfx/GP_Fill.h
similarity index 98%
rename from core/GP_Fill.h
rename to include/gfx/GP_Fill.h
index 87af0d4..6b6139d 100644
--- a/core/GP_Fill.h
+++ b/include/gfx/GP_Fill.h
@@ -26,7 +26,7 @@
#ifndef GP_FILL_H
#define GP_FILL_H
-#include "GP_Context.h"
+#include "core/GP_Context.h"
void GP_Fill(GP_Context *context, GP_Pixel pixel);
diff --git a/core/GP.h b/include/gfx/GP_Gfx.h
similarity index 79%
rename from core/GP.h
rename to include/gfx/GP_Gfx.h
index 77ba1b0..19bad4e 100644
--- a/core/GP.h
+++ b/include/gfx/GP_Gfx.h
@@ -23,49 +23,35 @@
* *
*****************************************************************************/
-#ifndef GP_H
-#define GP_H
+/*
-#include <stdint.h>
+ This is a main header for gfx part.
-/* basic definitions and structures */
-#include "GP_Common.h"
-#include "GP_Transform.h"
-#include "GP_Context.h"
+ */
-/* semi-public, low-level drawing API */
-#include "GP_WritePixel.h"
+#ifndef GP_GFX_H
+#define GP_GFX_H
-/* colors */
-#include "GP_Color.h"
-#include "GP_Palette.h"
+/* basic definitions and structures */
+#include "core/GP_Common.h"
+#include "core/GP_Transform.h"
+#include "core/GP_Context.h"
+#include "core/GP_WritePixel.h"
+#include "core/GP_GetPixel.h"
+#include "core/GP_PutPixel.h"
+#include "core/GP_Color.h"
/* public drawing API */
#include "GP_Fill.h"
-#include "GP_GetPixel.h"
-#include "GP_PutPixel.h"
#include "GP_HLine.h"
#include "GP_VLine.h"
#include "GP_Line.h"
-#include "GP_LineTrack.h"
#include "GP_Rect.h"
-#include "GP_FillRect.h"
#include "GP_Triangle.h"
#include "GP_Tetragon.h"
#include "GP_Circle.h"
-#include "GP_FillCircle.h"
#include "GP_Ellipse.h"
-#include "GP_FillEllipse.h"
#include "GP_Polygon.h"
#include "GP_Symbol.h"
-/* fonts */
-#include "GP_Font.h"
-#include "GP_TextStyle.h"
-#include "GP_TextMetric.h"
-#include "GP_Text.h"
-
-/* backends */
-#include "GP_Backend.h"
-
-#endif /* GP_H */
+#endif /* GP_GFX_H */
diff --git a/core/GP_HLine.h b/include/gfx/GP_HLine.h
similarity index 98%
rename from core/GP_HLine.h
rename to include/gfx/GP_HLine.h
index 7cdd11c..ee3c674 100644
--- a/core/GP_HLine.h
+++ b/include/gfx/GP_HLine.h
@@ -26,9 +26,7 @@
#ifndef GP_HLINE_H
#define GP_HLINE_H
-#include "GP_Context.h"
-
-#include <stdint.h>
+#include "core/GP_Context.h"
void GP_HLine1bpp(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel);
void GP_HLine2bpp(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel);
diff --git a/core/GP_Line.h b/include/gfx/GP_Line.h
similarity index 98%
rename from core/GP_Line.h
rename to include/gfx/GP_Line.h
index 38c0290..b5587bd 100644
--- a/core/GP_Line.h
+++ b/include/gfx/GP_Line.h
@@ -26,9 +26,7 @@
#ifndef GP_LINE_H
#define GP_LINE_H
-#include "GP_Context.h"
-
-#include <stdint.h>
+#include "core/GP_Context.h"
void GP_Line8bpp(GP_Context *context, int x0, int y0, int x1, int y1,
GP_Pixel pixel);
diff --git a/core/GP_Polygon.h b/include/gfx/GP_Polygon.h
similarity index 97%
rename from core/GP_Polygon.h
rename to include/gfx/GP_Polygon.h
index bbbdf9b..dc4a6e1 100644
--- a/core/GP_Polygon.h
+++ b/include/gfx/GP_Polygon.h
@@ -26,9 +26,9 @@
#ifndef GP_FILL_POLYGON_H
#define GP_FILL_POLYGON_H
-#include "GP_Context.h"
+#include "core/GP_Context.h"
void GP_FillPolygon(GP_Context *context, int vertex_count, const int *xy,
GP_Pixel pixel);
-#endif /* GP_RECT_H */
+#endif /* GP_FILL_POLYGON_H */
diff --git a/core/GP_Rect.h b/include/gfx/GP_Rect.h
similarity index 81%
rename from core/GP_Rect.h
rename to include/gfx/GP_Rect.h
index 63ef486..a0085e8 100644
--- a/core/GP_Rect.h
+++ b/include/gfx/GP_Rect.h
@@ -26,7 +26,7 @@
#ifndef GP_RECT_H
#define GP_RECT_H
-#include "GP_Context.h"
+#include "core/GP_Context.h"
void GP_RectXYXY(GP_Context *context, int x0, int y0, int x1, int y1,
GP_Pixel pixel);
@@ -44,4 +44,19 @@ void GP_TRectXYWH(GP_Context *context, int x, int y,
#define GP_Rect GP_RectXYXY
#define GP_TRect GP_TRectXYXY
+void GP_FillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1,
+ GP_Pixel pixel);
+
+void GP_FillRectXYWH(GP_Context *context, int x, int y,
+ unsigned int w, unsigned int h, GP_Pixel pixel);
+
+void GP_TFillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1,
+ GP_Pixel pixel);
+
+void GP_TFillRectXYWH(GP_Context *context, int x, int y,
+ unsigned int w, unsigned int h, GP_Pixel pixel);
+
+#define GP_FillRect GP_FillRectXYXY
+#define GP_TFillRect GP_TFillRectXYXY
+
#endif /* GP_RECT_H */
diff --git a/core/GP_Symbol.h b/include/gfx/GP_Symbol.h
similarity index 98%
rename from core/GP_Symbol.h
rename to include/gfx/GP_Symbol.h
index 259bddb..5aa3f2c 100644
--- a/core/GP_Symbol.h
+++ b/include/gfx/GP_Symbol.h
@@ -30,9 +30,7 @@
#ifndef GP_SYMBOL_H
#define GP_SYMBOL_H
-#include "GP_Context.h"
-
-#include <stdint.h>
+#include "core/GP_Context.h"
typedef enum GP_SymbolType {
GP_SYM_TRIANGLE_UP,
diff --git a/core/GP_Tetragon.h b/include/gfx/GP_Tetragon.h
similarity index 98%
rename from core/GP_Tetragon.h
rename to include/gfx/GP_Tetragon.h
index f69aee8..3f9d027 100644
--- a/core/GP_Tetragon.h
+++ b/include/gfx/GP_Tetragon.h
@@ -26,7 +26,7 @@
#ifndef GP_TETRAGON_H
#define GP_TETRAGON_H
-#include "GP_Context.h"
+#include "core/GP_Context.h"
void GP_Tetragon(GP_Context *context, int x0, int y0, int x1, int y1,
int x2, int y2, int x3, int y3, GP_Pixel pixel);
diff --git a/core/GP_Triangle.h b/include/gfx/GP_Triangle.h
similarity index 98%
rename from core/GP_Triangle.h
rename to include/gfx/GP_Triangle.h
index 4bc5523..128a721 100644
--- a/core/GP_Triangle.h
+++ b/include/gfx/GP_Triangle.h
@@ -26,7 +26,7 @@
#ifndef GP_TRIANGLE_H
#define GP_TRIANGLE_H
-#include "GP_Context.h"
+#include "core/GP_Context.h"
void GP_Triangle(GP_Context *context, int x0, int y0, int x1, int y1,
int x2, int y2, GP_Pixel pixel);
diff --git a/core/GP_VLine.h b/include/gfx/GP_VLine.h
similarity index 98%
rename from core/GP_VLine.h
rename to include/gfx/GP_VLine.h
index 3f943ec..9e857b4 100644
--- a/core/GP_VLine.h
+++ b/include/gfx/GP_VLine.h
@@ -26,7 +26,7 @@
#ifndef GP_VLINE_H
#define GP_VLINE_H
-#include "GP_Context.h"
+#include "core/GP_Context.h"
void GP_VLineXYY(GP_Context *context, int x, int y0, int y1, GP_Pixel pixel);
diff --git a/input/GP_Event.h b/include/input/GP_Event.h
similarity index 100%
rename from input/GP_Event.h
rename to include/input/GP_Event.h
diff --git a/loaders/GP_Loaders.h b/include/loaders/GP_Loaders.h
similarity index 97%
rename from loaders/GP_Loaders.h
rename to include/loaders/GP_Loaders.h
index ea4f9f9..44d1405 100644
--- a/loaders/GP_Loaders.h
+++ b/include/loaders/GP_Loaders.h
@@ -23,6 +23,12 @@
* *
*****************************************************************************/
+ /*
+
+ Core include file for loaders API.
+
+ */
+
#ifndef GP_LOADERS_H
#define GP_LOADERS_H
diff --git a/loaders/GP_PBM.h b/include/loaders/GP_PBM.h
similarity index 98%
rename from loaders/GP_PBM.h
rename to include/loaders/GP_PBM.h
index c858160..19c52a4 100644
--- a/loaders/GP_PBM.h
+++ b/include/loaders/GP_PBM.h
@@ -26,7 +26,7 @@
#ifndef GP_PBM_H
#define GP_PBM_H
-#include "GP_Context.h"
+#include "core/GP_Context.h"
GP_RetCode GP_LoadPBM(const char *src, GP_Context **res);
diff --git a/loaders/GP_PGM.h b/include/loaders/GP_PGM.h
similarity index 98%
rename from loaders/GP_PGM.h
rename to include/loaders/GP_PGM.h
index 998a6f2..272c50c 100644
--- a/loaders/GP_PGM.h
+++ b/include/loaders/GP_PGM.h
@@ -26,7 +26,7 @@
#ifndef GP_PGM_H
#define GP_PGM_H
-#include "GP_Context.h"
+#include "core/GP_Context.h"
GP_RetCode GP_LoadPGM(const char *src, GP_Context **res);
diff --git a/core/GP_Font.h b/include/text/GP_Font.h
similarity index 99%
rename from core/GP_Font.h
rename to include/text/GP_Font.h
index 0354948..e84d459 100644
--- a/core/GP_Font.h
+++ b/include/text/GP_Font.h
@@ -154,7 +154,7 @@ const GP_CharData *GP_GetCharData(const GP_Font *font, int c);
*/
unsigned int GP_GetFontDataSize(const GP_Font *font);
-#include "GP_RetCode.h"
+#include "core/GP_RetCode.h"
GP_RetCode GP_FontLoad(GP_Font **font, const char *filename);
GP_RetCode GP_FontSave(const GP_Font *font, const char *filename);
diff --git a/core/GP_Text.h b/include/text/GP_Text.h
similarity index 97%
rename from core/GP_Text.h
rename to include/text/GP_Text.h
index 35fc68e..e1144fa 100644
--- a/core/GP_Text.h
+++ b/include/text/GP_Text.h
@@ -26,7 +26,10 @@
#ifndef GP_TEXT_H
#define GP_TEXT_H
-#include "GP_Context.h"
+#include "core/GP_Context.h"
+
+#include "GP_TextStyle.h"
+#include "GP_TextMetric.h"
/* How the rendered text should be aligned.
* For GP_Text(), the alignment is relative to the specified point:
diff --git a/core/GP_TextMetric.h b/include/text/GP_TextMetric.h
similarity index 100%
rename from core/GP_TextMetric.h
rename to include/text/GP_TextMetric.h
diff --git a/core/GP_TextStyle.h b/include/text/GP_TextStyle.h
similarity index 99%
rename from core/GP_TextStyle.h
rename to include/text/GP_TextStyle.h
index d79a326..d57e678 100644
--- a/core/GP_TextStyle.h
+++ b/include/text/GP_TextStyle.h
@@ -27,7 +27,7 @@
#define GP_TEXTSTYLE_H
#include "GP_Font.h"
-#include "GP_RetCode.h"
+#include "core/GP_RetCode.h"
/*
* This structure describes how a text should be rendered.
diff --git a/input/Makefile b/input/Makefile
deleted file mode 100644
index 2254ef5..0000000
--- a/input/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-LIBRARY=libGP_input
-SOURCES=$(wildcard *.c)
-OBJECTS=$(SOURCES:.c=.o)
-HEADERS=$(wildcard *.h)
-CFLAGS=-I../core/ -W -Wall -O2 -fPIC
-
-.PHONY: all clean
-
-all: $(LIBRARY)
-
-$(LIBRARY): $(LIBRARY).a $(LIBRARY).so
-
-$(OBJECTS): $(HEADERS)
-
-$(LIBRARY).a: $(OBJECTS)
- ar crus $@ $^
-
-$(LIBRARY).so: $(OBJECTS)
- $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$@.0 $(CFLAGS) $^ -o $@
- ln -sf $@ $@.0
-
-%.o: %.c
- $(CC) $(CFLAGS) $< -c -o $@
-
-clean:
- rm -f $(LIBRARY).a $(LIBRARY).so $(LIBRARY).so.0
- rm -f *.o
diff --git a/lib.mk b/lib.mk
new file mode 100644
index 0000000..a8bccff
--- /dev/null
+++ b/lib.mk
@@ -0,0 +1,11 @@
+ifndef LIBNAME
+$(error LIBNAME not defined, fix your library Makefile)
+endif
+
+#
+# Trigger library rebuild
+#
+all: $(OBJECTS)
+ @$(MAKE) --no-print-directory -C $(TOPDIR)/build/
+
+CLEAN+=$(OBJECTS)
diff --git a/libs/Makefile b/libs/Makefile
new file mode 100644
index 0000000..1c3d990
--- /dev/null
+++ b/libs/Makefile
@@ -0,0 +1,3 @@
+TOPDIR=..
+SUBDIRS=core gfx text loaders filters input backends
+include $(TOPDIR)/include.mk
diff --git a/core/GP_Backend.c b/libs/backends/GP_Backend.c
similarity index 98%
rename from core/GP_Backend.c
rename to libs/backends/GP_Backend.c
index 12d2e5d..40f3d21 100644
--- a/core/GP_Backend.c
+++ b/libs/backends/GP_Backend.c
@@ -23,7 +23,8 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "core/GP_Core.h"
+#include "GP_Backend.h"
#include "config.h"
#include <string.h>
diff --git a/backends/GP_Backend_SDL.c b/libs/backends/GP_Backend_SDL.c
similarity index 99%
rename from backends/GP_Backend_SDL.c
rename to libs/backends/GP_Backend_SDL.c
index af746c1..2cf4fe4 100644
--- a/backends/GP_Backend_SDL.c
+++ b/libs/backends/GP_Backend_SDL.c
@@ -23,7 +23,7 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Backend.h"
#include "config.h"
#ifdef GP_HAVE_SDL
diff --git a/libs/backends/Makefile b/libs/backends/Makefile
new file mode 100644
index 0000000..da08bb7
--- /dev/null
+++ b/libs/backends/Makefile
@@ -0,0 +1,5 @@
+TOPDIR=../..
+CSOURCES=$(shell ls *.c)
+LIBNAME=backends
+include $(TOPDIR)/include.mk
+include $(TOPDIR)/lib.mk
diff --git a/core/GP_Color.c b/libs/core/GP_Color.c
similarity index 100%
rename from core/GP_Color.c
rename to libs/core/GP_Color.c
diff --git a/core/GP_Context.c b/libs/core/GP_Context.c
similarity index 97%
rename from core/GP_Context.c
rename to libs/core/GP_Context.c
index faaa64c..1660d25 100644
--- a/core/GP_Context.c
+++ b/libs/core/GP_Context.c
@@ -23,15 +23,10 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Core.h"
#include <string.h>
-inline GP_PixelType GP_GetContextPixelType(const GP_Context *context)
-{
- return context->pixel_type;
-}
-
GP_Context *GP_ContextCopy(GP_Context *context, int flag)
{
GP_Context *new;
diff --git a/core/GP_GetPixel.c b/libs/core/GP_GetPixel.c
similarity index 99%
rename from core/GP_GetPixel.c
rename to libs/core/GP_GetPixel.c
index 3bbd201..76013b4 100644
--- a/core/GP_GetPixel.c
+++ b/libs/core/GP_GetPixel.c
@@ -23,7 +23,7 @@
* *
*****************************************************************************/
-#include "GP_GetPixel.h"
+#include "GP_Core.h"
#include "GP_FnPerBpp.h"
#define DO_GETPIXEL(bits) diff --git a/core/GP_Palette.c b/libs/core/GP_Palette.c
similarity index 100%
rename from core/GP_Palette.c
rename to libs/core/GP_Palette.c
diff --git a/core/GP_Pixel.c b/libs/core/GP_Pixel.c
similarity index 99%
rename from core/GP_Pixel.c
rename to libs/core/GP_Pixel.c
index 1ae9bbd..0ed154e 100644
--- a/core/GP_Pixel.c
+++ b/libs/core/GP_Pixel.c
@@ -23,7 +23,7 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Core.h"
struct PixelTypeInfo {
const char *type_name; /* human-readable name */
diff --git a/core/GP_PutPixel.c b/libs/core/GP_PutPixel.c
similarity index 99%
rename from core/GP_PutPixel.c
rename to libs/core/GP_PutPixel.c
index 70bd85d..40a8363 100644
--- a/core/GP_PutPixel.c
+++ b/libs/core/GP_PutPixel.c
@@ -23,7 +23,7 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Core.h"
#include "GP_FnPerBpp.h"
diff --git a/core/GP_RetCode.c b/libs/core/GP_RetCode.c
similarity index 100%
rename from core/GP_RetCode.c
rename to libs/core/GP_RetCode.c
diff --git a/core/GP_WritePixel.c b/libs/core/GP_WritePixel.c
similarity index 99%
rename from core/GP_WritePixel.c
rename to libs/core/GP_WritePixel.c
index 40a8683..01fbedd 100644
--- a/core/GP_WritePixel.c
+++ b/libs/core/GP_WritePixel.c
@@ -23,7 +23,8 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Core.h"
+#include "GP_WritePixel.h"
static const uint8_t chunks_1bpp[8] = {
0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe,
diff --git a/libs/core/Makefile b/libs/core/Makefile
new file mode 100644
index 0000000..e740c3b
--- /dev/null
+++ b/libs/core/Makefile
@@ -0,0 +1,5 @@
+TOPDIR=../..
+CSOURCES=$(shell ls *.c)
+LIBNAME=core
+include $(TOPDIR)/include.mk
+include $(TOPDIR)/lib.mk
diff --git a/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c
similarity index 97%
rename from filters/GP_Rotate.c
rename to libs/filters/GP_Rotate.c
index 6f595fc..e73c106 100644
--- a/filters/GP_Rotate.c
+++ b/libs/filters/GP_Rotate.c
@@ -23,14 +23,13 @@
* *
*****************************************************************************/
-#include "GP_Rotate.h"
+#include "core/GP_Core.h"
+#include "core/GP_FnPerBpp.h"
-#include "GP_GetPixel.h"
-#include "GP_PutPixel.h"
-#include "GP_FnPerBpp.h"
+#include "GP_Rotate.h"
-#include "GP_MirrorV.algo.h"
-#include "GP_Rotate.algo.h"
+#include "algo/GP_MirrorV.algo.h"
+#include "algo/GP_Rotate.algo.h"
#include <string.h>
diff --git a/libs/filters/Makefile b/libs/filters/Makefile
new file mode 100644
index 0000000..7fc92d3
--- /dev/null
+++ b/libs/filters/Makefile
@@ -0,0 +1,5 @@
+TOPDIR=../..
+CSOURCES=$(shell ls *.c)
+LIBNAME=filters
+include $(TOPDIR)/include.mk
+include $(TOPDIR)/lib.mk
diff --git a/filters/GP_MirrorV.algo.h b/libs/filters/algo/GP_MirrorV.algo.h
similarity index 98%
rename from filters/GP_MirrorV.algo.h
rename to libs/filters/algo/GP_MirrorV.algo.h
index 0518b41..3ea1438 100644
--- a/filters/GP_MirrorV.algo.h
+++ b/libs/filters/algo/GP_MirrorV.algo.h
@@ -24,7 +24,7 @@
*****************************************************************************/
-#include "GP_Clip.h"
+#include "core/GP_Clip.h"
#define DEF_MIRRORV_FN(FN_NAME, CONTEXT_T, PIXEL_T, PUTPIXEL, GETPIXEL) void FN_NAME(CONTEXT_T context) diff --git a/filters/GP_Rotate.algo.h b/libs/filters/algo/GP_Rotate.algo.h
similarity index 97%
rename from filters/GP_Rotate.algo.h
rename to libs/filters/algo/GP_Rotate.algo.h
index cdcfa35..2d5cf28 100644
--- a/filters/GP_Rotate.algo.h
+++ b/libs/filters/algo/GP_Rotate.algo.h
@@ -23,9 +23,9 @@
* *
*****************************************************************************/
-#include "GP_Clip.h"
-#include "GP_Common.h"
-#include "GP_Context.h"
+#include "core/GP_Clip.h"
+#include "core/GP_Common.h"
+#include "core/GP_Context.h"
#define DEF_ROTATECW_FN(FN_NAME, CONTEXT_T, PUTPIXEL, GETPIXEL) GP_RetCode FN_NAME(CONTEXT_T context) diff --git a/core/GP_FillCircle.c b/libs/gfx/GP_Circle.c
similarity index 77%
rename from core/GP_FillCircle.c
rename to libs/gfx/GP_Circle.c
index a7cacb1..9522c1b 100644
--- a/core/GP_FillCircle.c
+++ b/libs/gfx/GP_Circle.c
@@ -23,8 +23,28 @@
* *
*****************************************************************************/
-#include "GP.h"
-#include "GP_FnPerBpp.h"
+#include "GP_Gfx.h"
+#include "algo/Circle.algo.h"
+#include "core/GP_FnPerBpp.h"
+
+/* Generate drawing functions for various bit depths. */
+DEF_CIRCLE_FN(GP_Circle1bpp, GP_Context *, GP_Pixel, GP_PutPixel1bpp)
+DEF_CIRCLE_FN(GP_Circle2bpp, GP_Context *, GP_Pixel, GP_PutPixel2bpp)
+DEF_CIRCLE_FN(GP_Circle4bpp, GP_Context *, GP_Pixel, GP_PutPixel4bpp)
+DEF_CIRCLE_FN(GP_Circle8bpp, GP_Context *, GP_Pixel, GP_PutPixel8bpp)
+DEF_CIRCLE_FN(GP_Circle16bpp, GP_Context *, GP_Pixel, GP_PutPixel16bpp)
+DEF_CIRCLE_FN(GP_Circle24bpp, GP_Context *, GP_Pixel, GP_PutPixel24bpp)
+DEF_CIRCLE_FN(GP_Circle32bpp, GP_Context *, GP_Pixel, GP_PutPixel32bpp)
+
+void GP_Circle(GP_Context *context, int xcenter, int ycenter,
+ unsigned int r, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_FN_PER_BPP(GP_Circle, context->bpp, context,
+ xcenter, ycenter, r, pixel);
+}
+
#include "algo/FillCircle.algo.h"
/* Generate drawing functions for various bit depths. */
diff --git a/core/GP_Ellipse.c b/libs/gfx/GP_Ellipse.c
similarity index 71%
rename from core/GP_Ellipse.c
rename to libs/gfx/GP_Ellipse.c
index c3fefbb..701f9bb 100644
--- a/core/GP_Ellipse.c
+++ b/libs/gfx/GP_Ellipse.c
@@ -23,9 +23,9 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Gfx.h"
#include "algo/Ellipse.algo.h"
-#include "GP_FnPerBpp.h"
+#include "core/GP_FnPerBpp.h"
/* Generate drawing functions for various bit depths. */
DEF_ELLIPSE_FN(GP_Ellipse1bpp, GP_Context *, GP_Pixel, GP_PutPixel1bpp);
@@ -56,3 +56,34 @@ void GP_TEllipse(GP_Context *context, int xcenter, int ycenter,
GP_Ellipse(context, xcenter, ycenter, a, b, pixel);
}
+
+#include "algo/FillEllipse.algo.h"
+
+/* Generate drawing functions for various bit depths. */
+DEF_FILLELLIPSE_FN(GP_FillEllipse1bpp, GP_Context *, GP_Pixel, GP_HLine1bpp)
+DEF_FILLELLIPSE_FN(GP_FillEllipse2bpp, GP_Context *, GP_Pixel, GP_HLine2bpp)
+DEF_FILLELLIPSE_FN(GP_FillEllipse4bpp, GP_Context *, GP_Pixel, GP_HLine4bpp)
+DEF_FILLELLIPSE_FN(GP_FillEllipse8bpp, GP_Context *, GP_Pixel, GP_HLine8bpp)
+DEF_FILLELLIPSE_FN(GP_FillEllipse16bpp, GP_Context *, GP_Pixel, GP_HLine16bpp)
+DEF_FILLELLIPSE_FN(GP_FillEllipse24bpp, GP_Context *, GP_Pixel, GP_HLine24bpp)
+DEF_FILLELLIPSE_FN(GP_FillEllipse32bpp, GP_Context *, GP_Pixel, GP_HLine32bpp)
+
+void GP_FillEllipse(GP_Context *context, int xcenter, int ycenter,
+ unsigned int a, unsigned int b, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_FN_PER_BPP(GP_FillEllipse, context->bpp, context,
+ xcenter, ycenter, a, b, pixel);
+}
+
+void GP_TFillEllipse(GP_Context *context, int xcenter, int ycenter,
+ unsigned int a, unsigned int b, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_TRANSFORM_POINT(context, xcenter, ycenter);
+ GP_TRANSFORM_SWAP(context, a, b);
+
+ GP_FillEllipse(context, xcenter, ycenter, a, b, pixel);
+}
diff --git a/core/GP_Fill.c b/libs/gfx/GP_Fill.c
similarity index 99%
rename from core/GP_Fill.c
rename to libs/gfx/GP_Fill.c
index 65065cc..c99df23 100644
--- a/core/GP_Fill.c
+++ b/libs/gfx/GP_Fill.c
@@ -26,7 +26,7 @@
#ifndef GP_FILL_H
#define GP_FILL_H
-#include "GP.h"
+#include "GP_Gfx.h"
void GP_Fill(GP_Context *context, GP_Pixel pixel)
{
diff --git a/core/GP_HLine.c b/libs/gfx/GP_HLine.c
similarity index 98%
rename from core/GP_HLine.c
rename to libs/gfx/GP_HLine.c
index 71c4671..ede37ef 100644
--- a/core/GP_HLine.c
+++ b/libs/gfx/GP_HLine.c
@@ -23,9 +23,9 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Gfx.h"
#include "algo/HLine.algo.h"
-#include "GP_FnPerBpp.h"
+#include "core/GP_FnPerBpp.h"
/* Generate drawing functions for various bit depths. */
DEF_HLINE_BU_FN(GP_HLine1bpp, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp)
diff --git a/core/GP_Line.c b/libs/gfx/GP_Line.c
similarity index 98%
rename from core/GP_Line.c
rename to libs/gfx/GP_Line.c
index 23ea98d..42a6cbc 100644
--- a/core/GP_Line.c
+++ b/libs/gfx/GP_Line.c
@@ -23,9 +23,9 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Gfx.h"
#include "algo/Line.algo.h"
-#include "GP_FnPerBpp.h"
+#include "core/GP_FnPerBpp.h"
/* Generate drawing functions for various bit depths. */
DEF_LINE_FN(GP_Line1bpp, GP_Context *, GP_Pixel, GP_PutPixel1bpp)
diff --git a/core/GP_Polygon.c b/libs/gfx/GP_Polygon.c
similarity index 99%
rename from core/GP_Polygon.c
rename to libs/gfx/GP_Polygon.c
index a72b114..bf47baf 100644
--- a/core/GP_Polygon.c
+++ b/libs/gfx/GP_Polygon.c
@@ -23,7 +23,7 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Gfx.h"
#include <limits.h>
#include <stdlib.h>
diff --git a/core/GP_FillRect.c b/libs/gfx/GP_Rect.c
similarity index 73%
rename from core/GP_FillRect.c
rename to libs/gfx/GP_Rect.c
index 05f7c65..52e3a36 100644
--- a/core/GP_FillRect.c
+++ b/libs/gfx/GP_Rect.c
@@ -23,7 +23,46 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Gfx.h"
+
+void GP_RectXYXY(GP_Context *context, int x0, int y0, int x1, int y1,
+ GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_HLine(context, x0, x1, y0, pixel);
+ GP_HLine(context, x0, x1, y1, pixel);
+ GP_VLine(context, x0, y0, y1, pixel);
+ GP_VLine(context, x1, y0, y1, pixel);
+}
+
+void GP_RectXYWH(GP_Context *context, int x, int y,
+ unsigned int w, unsigned int h, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_HLine(context, x, x + w, y, pixel);
+ GP_HLine(context, x, x + w, y + h, pixel);
+ GP_VLine(context, x, y, y + h, pixel);
+ GP_VLine(context, x + w, y, y + h, pixel);
+}
+
+void GP_TRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1,
+ GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_TRANSFORM_POINT(context, x0, y0);
+ GP_TRANSFORM_POINT(context, x1, y1);
+
+ GP_RectXYXY(context, x0, y0, x1, y1, pixel);
+}
+
+void GP_TRectXYWH(GP_Context *context, int x, int y,
+ unsigned int w, unsigned int h, GP_Pixel pixel)
+{
+ GP_TRectXYXY(context, x, y, x + w, y + h, pixel);
+}
void GP_FillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1,
GP_Pixel pixel)
diff --git a/core/GP_Symbol.c b/libs/gfx/GP_Symbol.c
similarity index 99%
rename from core/GP_Symbol.c
rename to libs/gfx/GP_Symbol.c
index 95bd3b8..1103673 100644
--- a/core/GP_Symbol.c
+++ b/libs/gfx/GP_Symbol.c
@@ -23,7 +23,7 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Gfx.h"
#define DO_TRIANGLE_UP(x, y, w, h) x, y + h, x + w, y + h, x + w/2, y
diff --git a/core/GP_Tetragon.c b/libs/gfx/GP_Tetragon.c
similarity index 99%
rename from core/GP_Tetragon.c
rename to libs/gfx/GP_Tetragon.c
index 2f0b777..ff9100e 100644
--- a/core/GP_Tetragon.c
+++ b/libs/gfx/GP_Tetragon.c
@@ -23,7 +23,7 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Gfx.h"
void GP_Tetragon(GP_Context *context, int x0, int y0, int x1, int y1,
int x2, int y2, int x3, int y3, GP_Pixel pixel)
diff --git a/core/GP_Triangle.c b/libs/gfx/GP_Triangle.c
similarity index 99%
rename from core/GP_Triangle.c
rename to libs/gfx/GP_Triangle.c
index 9a8d87b..46f6939 100644
--- a/core/GP_Triangle.c
+++ b/libs/gfx/GP_Triangle.c
@@ -23,7 +23,7 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Gfx.h"
void GP_Triangle(GP_Context *context, int x0, int y0, int x1, int y1,
int x2, int y2, GP_Pixel pixel)
diff --git a/core/GP_VLine.c b/libs/gfx/GP_VLine.c
similarity index 98%
rename from core/GP_VLine.c
rename to libs/gfx/GP_VLine.c
index 3985329..7a27768 100644
--- a/core/GP_VLine.c
+++ b/libs/gfx/GP_VLine.c
@@ -23,9 +23,9 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Gfx.h"
#include "algo/VLine.algo.h"
-#include "GP_FnPerBpp.h"
+#include "core/GP_FnPerBpp.h"
/* Generate drawing functions for various bit depths. */
DEF_VLINE_FN(GP_VLine1bpp, GP_Context *, GP_Pixel, GP_PutPixel1bpp)
diff --git a/libs/gfx/Makefile b/libs/gfx/Makefile
new file mode 100644
index 0000000..a3e7da2
--- /dev/null
+++ b/libs/gfx/Makefile
@@ -0,0 +1,5 @@
+TOPDIR=../..
+CSOURCES=$(shell ls *.c)
+LIBNAME=gfx
+include $(TOPDIR)/include.mk
+include $(TOPDIR)/lib.mk
diff --git a/algo/Circle.algo.h b/libs/gfx/algo/Circle.algo.h
similarity index 100%
rename from algo/Circle.algo.h
rename to libs/gfx/algo/Circle.algo.h
diff --git a/algo/Ellipse.algo.h b/libs/gfx/algo/Ellipse.algo.h
similarity index 100%
rename from algo/Ellipse.algo.h
rename to libs/gfx/algo/Ellipse.algo.h
diff --git a/algo/FillCircle.algo.h b/libs/gfx/algo/FillCircle.algo.h
similarity index 100%
rename from algo/FillCircle.algo.h
rename to libs/gfx/algo/FillCircle.algo.h
diff --git a/algo/FillEllipse.algo.h b/libs/gfx/algo/FillEllipse.algo.h
similarity index 100%
rename from algo/FillEllipse.algo.h
rename to libs/gfx/algo/FillEllipse.algo.h
diff --git a/algo/FillTriangle.algo.h b/libs/gfx/algo/FillTriangle.algo.h
similarity index 100%
rename from algo/FillTriangle.algo.h
rename to libs/gfx/algo/FillTriangle.algo.h
diff --git a/algo/HLine.algo.h b/libs/gfx/algo/HLine.algo.h
similarity index 100%
rename from algo/HLine.algo.h
rename to libs/gfx/algo/HLine.algo.h
diff --git a/algo/Line.algo.h b/libs/gfx/algo/Line.algo.h
similarity index 100%
rename from algo/Line.algo.h
rename to libs/gfx/algo/Line.algo.h
diff --git a/algo/VLine.algo.h b/libs/gfx/algo/VLine.algo.h
similarity index 100%
rename from algo/VLine.algo.h
rename to libs/gfx/algo/VLine.algo.h
diff --git a/input/GP_Event.c b/libs/input/GP_Event.c
similarity index 100%
rename from input/GP_Event.c
rename to libs/input/GP_Event.c
diff --git a/libs/input/Makefile b/libs/input/Makefile
new file mode 100644
index 0000000..0dcb208
--- /dev/null
+++ b/libs/input/Makefile
@@ -0,0 +1,5 @@
+TOPDIR=../..
+CSOURCES=$(shell ls *.c)
+LIBNAME=input
+include $(TOPDIR)/include.mk
+include $(TOPDIR)/lib.mk
diff --git a/loaders/GP_PBM.c b/libs/loaders/GP_PBM.c
similarity index 100%
rename from loaders/GP_PBM.c
rename to libs/loaders/GP_PBM.c
diff --git a/loaders/GP_PGM.c b/libs/loaders/GP_PGM.c
similarity index 100%
rename from loaders/GP_PGM.c
rename to libs/loaders/GP_PGM.c
diff --git a/loaders/GP_PXMCommon.c b/libs/loaders/GP_PXMCommon.c
similarity index 100%
rename from loaders/GP_PXMCommon.c
rename to libs/loaders/GP_PXMCommon.c
diff --git a/loaders/GP_PXMCommon.h b/libs/loaders/GP_PXMCommon.h
similarity index 99%
rename from loaders/GP_PXMCommon.h
rename to libs/loaders/GP_PXMCommon.h
index 586cf65..0c52e71 100644
--- a/loaders/GP_PXMCommon.h
+++ b/libs/loaders/GP_PXMCommon.h
@@ -33,7 +33,7 @@
#define GP_PXM_COMMON_H
#include <stdio.h>
-#include "GP.h"
+#include "core/GP_Core.h"
/*
* Save context to ascii file.
diff --git a/libs/loaders/Makefile b/libs/loaders/Makefile
new file mode 100644
index 0000000..1e88e78
--- /dev/null
+++ b/libs/loaders/Makefile
@@ -0,0 +1,5 @@
+TOPDIR=../..
+CSOURCES=$(shell ls *.c)
+LIBNAME=loaders
+include $(TOPDIR)/include.mk
+include $(TOPDIR)/lib.mk
diff --git a/core/GP_DefaultFont.c b/libs/text/GP_DefaultFont.c
similarity index 100%
rename from core/GP_DefaultFont.c
rename to libs/text/GP_DefaultFont.c
diff --git a/core/GP_Font.c b/libs/text/GP_Font.c
similarity index 99%
rename from core/GP_Font.c
rename to libs/text/GP_Font.c
index 1c7d0a0..8778ce3 100644
--- a/core/GP_Font.c
+++ b/libs/text/GP_Font.c
@@ -23,7 +23,8 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_Font.h"
+#include "core/GP_Common.h"
#include <stdio.h>
diff --git a/core/GP_Text.c b/libs/text/GP_Text.c
similarity index 98%
rename from core/GP_Text.c
rename to libs/text/GP_Text.c
index 4e331b0..af11a48 100644
--- a/core/GP_Text.c
+++ b/libs/text/GP_Text.c
@@ -23,9 +23,10 @@
* *
*****************************************************************************/
-#include "GP.h"
#include "algo/Text.algo.h"
-#include "GP_FnPerBpp.h"
+#include "gfx/GP_Gfx.h"
+#include "core/GP_FnPerBpp.h"
+#include "GP_Text.h"
static GP_TextStyle DefaultStyle = GP_DEFAULT_TEXT_STYLE;
diff --git a/core/GP_TextMetric.c b/libs/text/GP_TextMetric.c
similarity index 98%
rename from core/GP_TextMetric.c
rename to libs/text/GP_TextMetric.c
index 247f191..cac94cf 100644
--- a/core/GP_TextMetric.c
+++ b/libs/text/GP_TextMetric.c
@@ -23,7 +23,8 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "core/GP_Common.h"
+#include "GP_TextMetric.h"
static unsigned int SpaceWidth(const GP_TextStyle *style)
{
diff --git a/core/GP_TextStyle.c b/libs/text/GP_TextStyle.c
similarity index 98%
rename from core/GP_TextStyle.c
rename to libs/text/GP_TextStyle.c
index 3c7fc00..4d4d4bd 100644
--- a/core/GP_TextStyle.c
+++ b/libs/text/GP_TextStyle.c
@@ -23,7 +23,7 @@
* *
*****************************************************************************/
-#include "GP.h"
+#include "GP_TextStyle.h"
void GP_DefaultTextStyle(GP_TextStyle *style)
{
diff --git a/libs/text/Makefile b/libs/text/Makefile
new file mode 100644
index 0000000..300ad6e
--- /dev/null
+++ b/libs/text/Makefile
@@ -0,0 +1,5 @@
+TOPDIR=../..
+CSOURCES=$(shell ls *.c)
+LIBNAME=text
+include $(TOPDIR)/include.mk
+include $(TOPDIR)/lib.mk
diff --git a/algo/Text.algo.h b/libs/text/algo/Text.algo.h
similarity index 100%
rename from algo/Text.algo.h
rename to libs/text/algo/Text.algo.h
diff --git a/loaders/Makefile b/loaders/Makefile
deleted file mode 100644
index e69679a..0000000
--- a/loaders/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-LIBRARY=libGP_loaders
-SOURCES=$(wildcard *.c)
-OBJECTS=$(SOURCES:.c=.o)
-HEADERS=$(wildcard *.h)
-CFLAGS=-I../core/ -W -Wall -O2 -fPIC
-
-.PHONY: all clean
-
-all: $(LIBRARY)
- cd tests && $(MAKE) all
-
-$(LIBRARY): $(LIBRARY).a $(LIBRARY).so
-
-$(OBJECTS): $(HEADERS)
-
-$(LIBRARY).a: $(OBJECTS)
- ar crus $@ $^
-
-$(LIBRARY).so: $(OBJECTS)
- $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$@.0 $(CFLAGS) $^ -o $@
- ln -sf $@ $@.0
-
-%.o: %.c
- $(CC) $(CFLAGS) $< -c -o $@
-
-clean:
- rm -f $(LIBRARY).a $(LIBRARY).so $(LIBRARY).so.0
- rm -f *.o
- cd tests && $(MAKE) clean
diff --git a/loaders/tests/Makefile b/loaders/tests/Makefile
deleted file mode 100644
index e272a2a..0000000
--- a/loaders/tests/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-LDFLAGS=-L../ -L../../core/ -lGP_core -lGP_loaders
-
-INCLUDE=-I../ -I../../core/
-# Some warnings are triggered only with -O2
-# thuss added here
-CFLAGS=$(INCLUDE) -ggdb -W -Wall -O2 -lm
-SOURCES=$(wildcard *.c)
-TESTS=$(SOURCES:.c=)
-
-all: $(TESTS)
-
-%: %.c
- $(CC) $(CFLAGS) $(LDFLAGS) $(LIBRARY) $^ -o $@
-
-clean:
- rm -f *.o
- rm -f $(TESTS) test.pbm test.pgm
diff --git a/old_tests/Makefile b/old_tests/Makefile
deleted file mode 100644
index f21f263..0000000
--- a/old_tests/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Comment one of these lines.
-#
-# First one triggers static linking.
-#
-# Second one triggers dynamic.
-#
-LIBRARY=../libGP.a
-#LDFLAGS=-lGP -lSDL -L..
-
-INCLUDE=-I..
-# Some warnings are triggered only with -O2
-# thuss added here
-CFLAGS=$(INCLUDE) -ggdb -W -Wall -O2
-SOURCES=$(shell ls *.c)
-TESTS=$(SOURCES:.c=)
-
-all: $(TESTS)
-
-%: %.c $(LIBRARY)
- $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBRARY) -o $@ -lSDL
-
-clean:
- rm -f *.o
- rm -f $(TESTS)
-
diff --git a/old_tests/circlefps.c b/old_tests/circlefps.c
deleted file mode 100644
index 63d7560..0000000
--- a/old_tests/circlefps.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <SDL/SDL.h>
-
-#include "GP.h"
-
-/* The surface used as a display (in fact it is a software surface). */
-SDL_Surface *display = NULL;
-
-/* Frames per second. */
-int fps = 0, fps_min = 1000000, fps_max = 0;
-
-/*
- * Timer used for FPS measurement and key reactions.
- * SDL_USEREVENT is triggered each second.
- */
-
-SDL_TimerID timer;
-
-SDL_UserEvent timer_event;
-
-Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
- __attribute__((unused)) void * param)
-{
- timer_event.type = SDL_USEREVENT;
- SDL_PushEvent((SDL_Event *) &timer_event);
- return 1000;
-}
-
-/* Values for color pixels in display format. */
-static long colors[GP_BASIC_COLOR_COUNT];
-
-void draw_frame(void)
-{
- int x = display->w/2 + 120 - random() % 240;
- int y = display->h/2 + 120 - random() % 240;
-
- long color = SDL_MapRGB(display->format, random() % 255, random() % 255, random() % 255);
-
- GP_Circle(display, color, x, y, display->h/2);
-}
-
-void event_loop(void)
-{
- SDL_Event event;
-
- for (;;) {
- while (SDL_PollEvent(&event) > 0) {
- switch (event.type) {
- case SDL_USEREVENT:
- SDL_Flip(display);
- fprintf(stdout, "%d FPS, min = %d, max = %dr", fps, fps_min, fps_max);
- fflush(stdout);
-
- /* Update frames per second */
- if (fps < fps_min)
- fps_min = fps;
- if (fps > fps_max)
- fps_max = fps;
- fps = 0;
- break;
- case SDL_KEYDOWN:
- case SDL_QUIT:
- return;
- }
- }
- draw_frame();
- fps++;
- }
-}
-
-int main(void)
-{
- /* Initialize SDL */
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
- fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError());
- return 1;
- }
-
- /* Create a window with a software back surface */
- display = SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE);
- if (display == NULL) {
- fprintf(stderr, "Could not open display: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Print basic information about the surface */
- printf("Display surface properties:n");
- printf(" width: %4d, height: %4d, pitch: %4dn",
- display->w, display->h, display->pitch);
- printf(" bits per pixel: %2d, bytes per pixel: %2dn",
- display->format->BitsPerPixel, display->format->BytesPerPixel);
-
- /* Get colors */
- GP_LoadBasicColors(display, colors);
-
- /* Set up a clipping rectangle to test proper clipping of pixels */
- SDL_Rect clip_rect = { 10, 10, 620, 460 };
- SDL_SetClipRect(display, &clip_rect);
-
- /* Set up the timer */
- timer = SDL_AddTimer(1000, timer_callback, NULL);
- if (timer == 0) {
- fprintf(stderr, "Could not set up timer: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Enter the event loop */
- event_loop();
-
- /* Preserve the last result by a newline */
- fprintf(stdout, "n");
-
- /* We're done */
- SDL_Quit();
- return 0;
-
-fail:
- SDL_Quit();
- return 1;
-}
-
diff --git a/old_tests/circlestest.c b/old_tests/circlestest.c
deleted file mode 100644
index 1935c69..0000000
--- a/old_tests/circlestest.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <SDL/SDL.h>
-
-#include "GP.h"
-
-SDL_Surface *display = NULL;
-
-static int state;
-
-void draw1(void)
-{
- long pixel;
- int x = 160;
- int y = 120;
- int r;
-
- SDL_LockSurface(display);
-
- for (r = 202; r > 0; r -= 3) {
- pixel = SDL_MapRGB(display->format, 150*(r%2) + r/2, 0, 0);
- GP_FillCircle(display, pixel, x, y, r);
- }
-
-
- SDL_UnlockSurface(display);
-}
-
-void draw2(void)
-{
- long pixel;
- int x = 160;
- int y = 120;
- int r;
-
- SDL_LockSurface(display);
-
- for (r = 203; r > 0; r -= 3) {
- pixel = SDL_MapRGB(display->format, 0, 150*(r%2) + r/2, 0);
- GP_FillCircle(display, pixel, x, y, r);
- }
-
-
- SDL_UnlockSurface(display);
-}
-
-void draw3(void)
-{
- long pixel;
- int x = 160;
- int y = 120;
- int r;
-
- SDL_LockSurface(display);
-
- for (r = 201; r > 0; r -= 3) {
- pixel = SDL_MapRGB(display->format, 0, 0, 150*(r%2) + r/2);
- GP_FillCircle(display, pixel, x, y, r);
- }
-
-
- SDL_UnlockSurface(display);
-}
-
-void draw4(void)
-{
- long pixel;
- int x = 160;
- int y = 120;
- int r;
-
- SDL_LockSurface(display);
-
- SDL_FillRect(display, NULL, 0xff000000);
-
- for (r = 202; r > 0; r -= 3) {
- pixel = SDL_MapRGB(display->format, 150 + r/2, 0, 0);
- GP_Circle(display, pixel, x, y, r);
- }
-
-
- SDL_UnlockSurface(display);
-}
-
-void draw5(void)
-{
- long pixel;
- int x = 160;
- int y = 120;
- int r;
-
- SDL_LockSurface(display);
-
- SDL_FillRect(display, NULL, 0xff000000);
-
- for (r = 203; r > 0; r -= 3) {
- pixel = SDL_MapRGB(display->format, 0, 150 + r/2, 0);
- GP_Circle(display, pixel, x, y, r);
- }
-
-
- SDL_UnlockSurface(display);
-}
-
-void draw6(void)
-{
- long pixel;
- int x = 160;
- int y = 120;
- int r;
-
- SDL_LockSurface(display);
-
- SDL_FillRect(display, NULL, 0xff000000);
-
- for (r = 201; r > 0; r -= 3) {
- pixel = SDL_MapRGB(display->format, 0, 0, 150 + r/2);
- GP_Circle(display, pixel, x, y, r);
- }
-
-
- SDL_UnlockSurface(display);
-}
-
-void event_loop(void)
-{
- SDL_Event event;
-
- while (SDL_WaitEvent(&event) > 0) {
-
- switch (event.type) {
- case SDL_KEYDOWN:
- switch (state++) {
- case 0:
- draw2();
- SDL_Flip(display);
- break;
- case 1:
- draw3();
- SDL_Flip(display);
- break;
- case 2:
- draw4();
- SDL_Flip(display);
- break;
- case 3:
- draw5();
- SDL_Flip(display);
- break;
- case 4:
- draw6();
- SDL_Flip(display);
- break;
- default:
- return;
- }
- break;
- case SDL_QUIT:
- return;
- }
- }
-}
-
-int main(void)
-{
- /* Initialize SDL */
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
- fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError());
- return 1;
- }
-
- /* Create a window with a software back surface */
- display = SDL_SetVideoMode(320, 240, 0, SDL_SWSURFACE);
- if (display == NULL) {
- fprintf(stderr, "Could not open display: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Set up a clipping rectangle to test proper clipping of pixels */
- SDL_Rect clip_rect = { 10, 10, 300, 220 };
- SDL_SetClipRect(display, &clip_rect);
-
- draw1();
- SDL_Flip(display);
-
- event_loop();
-
- SDL_Quit();
- return 0;
-
-fail:
- SDL_Quit();
- return 1;
-}
-
diff --git a/old_tests/ellipsetest.c b/old_tests/ellipsetest.c
deleted file mode 100644
index 21abd07..0000000
--- a/old_tests/ellipsetest.c
+++ /dev/null
@@ -1,240 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <SDL/SDL.h>
-
-#include "GP.h"
-
-/* The surface used as a display (in fact it is a software surface). */
-SDL_Surface *display = NULL;
-
-/* Timer used for refreshing the display */
-SDL_TimerID timer;
-
-/* An event used for signaling that the timer was triggered. */
-SDL_UserEvent timer_event;
-
-Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
- __attribute__((unused)) void * param)
-{
- timer_event.type = SDL_USEREVENT;
- SDL_PushEvent((SDL_Event *) &timer_event);
- return 60;
-}
-
-/* Orientation flag (horizontal or vertical). */
-int orientation_flag = 0;
-
-/* Fill flag. */
-int fill_flag = 0;
-
-/* Radius ratio. */
-int rratio = 2;
-
-/* True if filling is drawn first, false if shapes are drawn first. */
-int fill_first = 0;
-
-/* True to draw axes. */
-int draw_axes = 0;
-
-/* Minimum radius. */
-int min_radius = 3;
-
-/* Basic colors in display format. */
-static long colors[GP_BASIC_COLOR_COUNT];
-
-void draw_pixels(void)
-{
- int rx, ry, active_rx, active_ry;
- int intensity;
- long fill_color;
-
- /* Set up a clipping rectangle to test proper clipping of pixels */
- SDL_Rect clip_rect = { 20, 20, 600, 440 };
- SDL_SetClipRect(display, &clip_rect);
-
- SDL_LockSurface(display);
-
- /* Clear screen */
- GP_Clear(display, colors[GP_BLACK]);
-
- for (rx = 210 + min_radius; rx >= min_radius; rx -= 7) {
- ry = rratio*rx;
- intensity = (rx % 4) * 50;
- fill_color = SDL_MapRGB(display->format, intensity, intensity, intensity);
-
- if (orientation_flag) {
- active_rx = ry;
- active_ry = rx;
- }
- else {
- active_rx = rx;
- active_ry = ry;
- }
-
- if (fill_flag) {
- if (fill_first) {
- GP_FillEllipse(display, fill_color, 320, 240, active_rx, active_ry);
- GP_Ellipse(display, colors[GP_WHITE], 320, 240, active_rx, active_ry);
- }
- else {
- GP_Ellipse(display, colors[GP_WHITE], 320, 240, active_rx, active_ry);
- GP_FillEllipse(display, fill_color, 320, 240, active_rx, active_ry);
- }
- }
- else {
- GP_Ellipse(display, colors[GP_WHITE], 320, 240, active_rx, active_ry);
- }
- }
-
- if (draw_axes) {
-
- if (orientation_flag) {
- active_rx = rratio * min_radius;
- active_ry = min_radius;
- } else {
- active_rx = min_radius;
- active_ry = rratio*min_radius;
- }
-
- GP_Line(display, colors[GP_RED], 0, 240, 640, 240);
- GP_Line(display, colors[GP_RED], 320, 0, 320, 640);
- GP_Line(display, colors[GP_GREEN], 0, 240+active_ry, 640, 240+active_ry);
- GP_Line(display, colors[GP_GREEN], 0, 240-active_ry, 640, 240-active_ry);
- GP_Line(display, colors[GP_GREEN], 320+active_rx, 0, 320+active_rx, 640);
- GP_Line(display, colors[GP_GREEN], 320-active_rx, 0, 320-active_rx, 640);
- }
-
- SDL_UnlockSurface(display);
-}
-
-void event_loop(void)
-{
- SDL_Event event;
-
- /* Initial redraw */
- draw_pixels();
- SDL_Flip(display);
-
- while (SDL_WaitEvent(&event) > 0) {
-
- switch (event.type) {
-
-#if 0
- case SDL_USEREVENT:
- draw_pixels();
- SDL_Flip(display);
- break;
-#endif
-
- case SDL_VIDEOEXPOSE:
- draw_pixels();
- SDL_Flip(display);
- break;
-
- case SDL_KEYDOWN:
- if (event.key.keysym.sym == SDLK_ESCAPE) {
- return;
- }
- else if (event.key.keysym.sym == SDLK_o) {
- orientation_flag = !orientation_flag;
- }
- else if (event.key.keysym.sym == SDLK_f) {
- fill_flag = !fill_flag;
- }
- else if (event.key.keysym.sym == SDLK_1) {
- rratio = 1;
- }
- else if (event.key.keysym.sym == SDLK_2) {
- rratio = 2;
- }
- else if (event.key.keysym.sym == SDLK_3) {
- rratio = 3;
- }
- else if (event.key.keysym.sym == SDLK_4) {
- rratio = 4;
- }
- else if (event.key.keysym.sym == SDLK_m) {
- fill_first = !fill_first;
- }
- else if (event.key.keysym.sym == SDLK_r) {
- min_radius++;
- if (min_radius > 10)
- min_radius = 3;
- }
- else if (event.key.keysym.sym == SDLK_x) {
- draw_axes = !draw_axes;
- }
-
- draw_pixels();
- SDL_Flip(display);
- break;
-
- case SDL_QUIT:
- return;
- }
- }
-}
-
-int main(void)
-{
- /* Initialize SDL */
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
- fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError());
- return 1;
- }
-
- /* Create a window with a software back surface */
- display = SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE);
- if (display == NULL) {
- fprintf(stderr, "Could not open display: %sn", SDL_GetError());
- goto fail;
- }
-
-#if 0
- /* Set up the refresh timer */
- timer = SDL_AddTimer(60, timer_callback, NULL);
- if (timer == 0) {
- fprintf(stderr, "Could not set up timer: %sn", SDL_GetError());
- goto fail;
- }
-#endif
-
- GP_LoadBasicColors(display, colors);
-
- /* Enter the event loop */
- event_loop();
-
- /* We're done */
- SDL_Quit();
- return 0;
-
-fail:
- SDL_Quit();
- return 1;
-}
-
diff --git a/old_tests/linefps.c b/old_tests/linefps.c
deleted file mode 100644
index d88d427..0000000
--- a/old_tests/linefps.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <SDL/SDL.h>
-
-#include "GP.h"
-
-/* The surface used as a display (in fact it is a software surface). */
-SDL_Surface *display = NULL;
-
-/* Frames per second. */
-int fps = 0, fps_min = 1000000, fps_max = 0;
-
-/*
- * Timer used for FPS measurement and key reactions.
- * SDL_USEREVENT is triggered each second.
- */
-
-SDL_TimerID timer;
-
-SDL_UserEvent timer_event;
-
-Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
- __attribute__((unused)) void * param)
-{
- timer_event.type = SDL_USEREVENT;
- SDL_PushEvent((SDL_Event *) &timer_event);
- return 1000;
-}
-
-/* Values for color pixels in display format. */
-static long colors[GP_BASIC_COLOR_COUNT];
-
-void draw_frame(void)
-{
- int x0 = 0;
- int y0 = random() % display->h;
- int x1 = display->w;
- int y1 = random() % display->h;
- long color = SDL_MapRGB(display->format, random() % 255, random() % 255, random() % 255);
-
- GP_Line(display, color, x0, y0, x1, y1);
-}
-
-void event_loop(void)
-{
- SDL_Event event;
-
- for (;;) {
- while (SDL_PollEvent(&event) > 0) {
- switch (event.type) {
- case SDL_USEREVENT:
- SDL_Flip(display);
- fprintf(stdout, "%d FPS, min = %d, max = %dr", fps, fps_min, fps_max);
- fflush(stdout);
-
- /* Update frames per second */
- if (fps < fps_min)
- fps_min = fps;
- if (fps > fps_max)
- fps_max = fps;
- fps = 0;
- break;
- case SDL_KEYDOWN:
- case SDL_QUIT:
- return;
- }
- }
- draw_frame();
- fps++;
- }
-}
-
-int main(void)
-{
- /* Initialize SDL */
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
- fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError());
- return 1;
- }
-
- /* Create a window with a software back surface */
- display = SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE);
- if (display == NULL) {
- fprintf(stderr, "Could not open display: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Print basic information about the surface */
- printf("Display surface properties:n");
- printf(" width: %4d, height: %4d, pitch: %4dn",
- display->w, display->h, display->pitch);
- printf(" bits per pixel: %2d, bytes per pixel: %2dn",
- display->format->BitsPerPixel, display->format->BytesPerPixel);
-
- /* Get colors */
- GP_LoadBasicColors(display, colors);
-
- /* Set up a clipping rectangle to test proper clipping of pixels */
- SDL_Rect clip_rect = { 10, 10, 620, 460 };
- SDL_SetClipRect(display, &clip_rect);
-
- /* Set up the timer */
- timer = SDL_AddTimer(1000, timer_callback, NULL);
- if (timer == 0) {
- fprintf(stderr, "Could not set up timer: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Enter the event loop */
- event_loop();
-
- /* Preserve the last result by a newline */
- fprintf(stdout, "n");
-
- /* We're done */
- SDL_Quit();
- return 0;
-
-fail:
- SDL_Quit();
- return 1;
-}
-
diff --git a/old_tests/linetest.c b/old_tests/linetest.c
deleted file mode 100644
index 962f577..0000000
--- a/old_tests/linetest.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <SDL/SDL.h>
-
-#include "GP.h"
-
-/* The surface used as a display (in fact it is a software surface). */
-SDL_Surface *display = NULL;
-
-/* Timer used for refreshing the display */
-SDL_TimerID timer;
-
-/* An event used for signaling that the timer was triggered. */
-SDL_UserEvent timer_event;
-
-/* Values for color pixels in display format. */
-static long colors[GP_BASIC_COLOR_COUNT];
-
-Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
- __attribute__((unused)) void * param)
-{
- timer_event.type = SDL_USEREVENT;
- SDL_PushEvent((SDL_Event *) &timer_event);
- return 30;
-}
-
-double start_angle = 0.0;
-
-void redraw_screen(void)
-{
- double angle;
- int x, y;
- int xcenter = display->w/2;
- int ycenter = display->h/2;
-
- SDL_LockSurface(display);
-
- GP_Clear(display, colors[GP_BLACK]);
-
- for (angle = 0.0; angle < 2*M_PI; angle += 0.1) {
- x = (int) (display->w/2 * cos(start_angle + angle));
- y = (int) (display->h/2 * sin(start_angle + angle));
-
- Uint8 r = 127.0 + 127.0 * cos(start_angle + angle);
- Uint8 g = 127.0 + 127.0 * sin(start_angle + angle);
-
- Uint32 color = SDL_MapRGB(display->format, r, 0, g);
-
- /*
- * Draw the line forth and back to detect any pixel change
- * between one direction and the other.
- */
- GP_Line(display, color, xcenter, ycenter, xcenter + x, ycenter + y);
- GP_Line(display, color, xcenter + x, ycenter + y, xcenter, ycenter);
- }
-
- /* axes */
- GP_HLine(display, colors[GP_WHITE], 0, display->w, ycenter);
- GP_VLine(display, colors[GP_WHITE], xcenter, 0, display->h);
-
- SDL_UnlockSurface(display);
-}
-
-void event_loop(void)
-{
- SDL_Event event;
-
- while (SDL_WaitEvent(&event) > 0) {
- switch (event.type) {
- case SDL_USEREVENT:
- redraw_screen();
- SDL_Flip(display);
- start_angle += 0.01;
- if (start_angle > 2*M_PI) {
- start_angle = 0.0;
- }
- break;
- case SDL_KEYDOWN:
- case SDL_QUIT:
- return;
- }
- }
-}
-
-int main(void)
-{
- /* Initialize SDL */
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
- fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError());
- return 1;
- }
-
- /* Create a window with a software back surface */
- display = SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE);
- if (display == NULL) {
- fprintf(stderr, "Could not open display: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Print basic information about the surface */
- printf("Display surface properties:n");
- printf(" width: %4d, height: %4d, pitch: %4dn",
- display->w, display->h, display->pitch);
- printf(" bits per pixel: %2d, bytes per pixel: %2dn",
- display->format->BitsPerPixel, display->format->BytesPerPixel);
-
- /* Get colors */
- GP_LoadBasicColors(display, colors);
-
- /* Set up a clipping rectangle to test proper clipping of pixels */
- SDL_Rect clip_rect = { 10, 10, 620, 460 };
- SDL_SetClipRect(display, &clip_rect);
-
- /* Set up the refresh timer */
- timer = SDL_AddTimer(30, timer_callback, NULL);
- if (timer == 0) {
- fprintf(stderr, "Could not set up timer: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Enter the event loop */
- event_loop();
-
- /* We're done */
- SDL_Quit();
- return 0;
-
-fail:
- SDL_Quit();
- return 1;
-}
-
diff --git a/old_tests/pixeltest.c b/old_tests/pixeltest.c
deleted file mode 100644
index b4bea6e..0000000
--- a/old_tests/pixeltest.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <SDL/SDL.h>
-
-#include "GP.h"
-
-/* The surface used as a display (in fact it is a software surface). */
-SDL_Surface *display = NULL;
-
-/* Timer used for refreshing the display */
-SDL_TimerID timer;
-
-/* An event used for signaling that the timer was triggered. */
-SDL_UserEvent timer_event;
-
-/* Values for color pixels in display format. */
-long red;
-long green;
-long blue;
-
-Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
- __attribute__((unused)) void *param)
-{
- timer_event.type = SDL_USEREVENT;
- SDL_PushEvent((SDL_Event *) &timer_event);
- return 30;
-}
-
-void draw_pixels(void)
-{
- long pixel;
- int x = random() % 320;
- int y = random() % 240;
-
- SDL_LockSurface(display);
- pixel = GP_GetPixel(display, x, y);
-
- if (pixel == green)
- GP_SetPixel(display, blue, x, y);
- else
- GP_SetPixel(display, green, x, y);
-
- SDL_UnlockSurface(display);
-}
-
-void event_loop(void)
-{
- SDL_Event event;
-
- while (SDL_WaitEvent(&event) > 0) {
-
- switch (event.type) {
- case SDL_USEREVENT:
- draw_pixels();
- SDL_Flip(display);
- break;
- case SDL_KEYDOWN:
- case SDL_QUIT:
- return;
- }
- }
-}
-
-int main(void)
-{
- /* Initialize SDL */
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
- fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError());
- return 1;
- }
-
- /* Create a window with a software back surface */
- display = SDL_SetVideoMode(320, 240, 0, SDL_SWSURFACE);
- if (display == NULL) {
- fprintf(stderr, "Could not open display: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Print basic information about the surface */
- printf("Display surface properties:n");
- printf(" width: %4d, height: %4d, pitch: %4dn",
- display->w, display->h, display->pitch);
- printf(" bits per pixel: %2d, bytes per pixel: %2dn",
- display->format->BitsPerPixel, display->format->BytesPerPixel);
-
- /* Get colors */
- red = SDL_MapRGB(display->format, 255, 0, 0);
- green = SDL_MapRGB(display->format, 0, 255, 0);
- blue = SDL_MapRGB(display->format, 0, 0, 255);
-
- /* Set up a clipping rectangle to test proper clipping of pixels */
- SDL_Rect clip_rect = {10, 10, 300, 220};
- SDL_SetClipRect(display, &clip_rect);
-
- /* Set up the refresh timer */
- timer = SDL_AddTimer(30, timer_callback, NULL);
- if (timer == 0) {
- fprintf(stderr, "Could not set up timer: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Enter the event loop */
- event_loop();
-
- /* We're done */
- SDL_Quit();
- return 0;
-
-fail:
- SDL_Quit();
- return 1;
-}
-
diff --git a/old_tests/runtest.sh b/old_tests/runtest.sh
deleted file mode 100755
index 372498f..0000000
--- a/old_tests/runtest.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-#
-# Run dynamically linked test.
-#
-
-PROG="$1"
-shift
-
-echo "LD_LIBRARY_PATH=../ ./$PROG $@"
-LD_LIBRARY_PATH=../ ./$PROG $@
diff --git a/old_tests/shapetest.c b/old_tests/shapetest.c
deleted file mode 100644
index c451202..0000000
--- a/old_tests/shapetest.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <SDL/SDL.h>
-
-#include "GP.h"
-
-/* The surface used as a display (in fact it is a software surface). */
-SDL_Surface *display = NULL;
-
-/* Timer used for refreshing the display */
-SDL_TimerID timer;
-
-/* An event used for signaling that the timer was triggered. */
-SDL_UserEvent timer_event;
-
-Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
- __attribute__((unused)) void * param)
-{
- timer_event.type = SDL_USEREVENT;
- SDL_PushEvent((SDL_Event *) &timer_event);
- return 60;
-}
-
-/* Basic colors in display-specific format. */
-long colors[GP_BASIC_COLOR_COUNT];
-
-/* Radius of the shape being drawn */
-static int xradius = 5;
-static int yradius = 5;
-
-/* Draw outline? */
-static int outline = 0;
-
-/* Fill the shape? */
-static int fill = 1;
-
-/* Show axes? */
-static int show_axes = 1;
-
-/* Shape to be drawn */
-#define SHAPE_FIRST 1
-#define SHAPE_TRIANGLE 1
-#define SHAPE_CIRCLE 2
-#define SHAPE_ELLIPSE 3
-#define SHAPE_RECTANGLE 4
-#define SHAPE_LAST 4
-static int shape = SHAPE_FIRST;
-
-/* Variants in coordinates, if applicable */
-static int variant = 1;
-
-/* Increments added to radii in every timeframe (0 = no change). */
-static int xradius_add = 0;
-static int yradius_add = 0;
-
-void draw_testing_triangle(int x, int y, int xradius, int yradius)
-{
- int x0, y0, x1, y1, x2, y2;
- switch (variant) {
- case 1:
- x0 = x;
- y0 = y - yradius;
- x1 = x - xradius;
- y1 = y;
- x2 = x + xradius;
- y2 = y + yradius;
- break;
- case 2:
- x0 = x - xradius;
- y0 = y - yradius;
- x1 = x + xradius;
- y1 = y;
- x2 = x + xradius;
- y2 = y + yradius;
- break;
-
- case 3:
- default:
- x0 = x;
- y0 = y - yradius;
- x1 = x + xradius;
- y1 = y + yradius;
- x2 = x - xradius;
- y2 = y + yradius;
- break;
- }
-
- if (fill) {
- GP_FillTriangle(display, colors[GP_RED], x0, y0, x1, y1, x2, y2);
- }
-
- if (outline) {
- GP_Triangle(display, colors[GP_WHITE], x0, y0, x1, y1, x2, y2);
- }
-}
-
-void draw_testing_circle(int x, int y, int xradius,
- __attribute__((unused)) int yradius)
-{
- if (fill) {
- GP_FillCircle(display, colors[GP_RED], x, y, xradius);
- }
- if (outline) {
- GP_Circle(display, colors[GP_WHITE], x, y, xradius);
- }
-}
-
-void draw_testing_ellipse(int x, int y, int xradius, int yradius)
-{
- if (fill) {
- GP_FillEllipse(display, colors[GP_RED], x, y, xradius, yradius);
- }
- if (outline) {
- GP_Ellipse(display, colors[GP_WHITE], x, y, xradius, yradius);
- }
-}
-
-void draw_testing_rectangle(int x, int y, int xradius, int yradius)
-{
- if (fill) {
- GP_FillRect(display, colors[GP_RED], x - xradius, y - yradius, x + xradius, y + yradius);
- }
- if (outline) {
- GP_Rect(display, colors[GP_WHITE], x - xradius, y - yradius, x + xradius, y + yradius);
- }
-}
-
-void redraw_screen(void)
-{
- int x = 320;
- int y = 240;
-
- /* text style for the label */
- GP_TextStyle style = {
- .font = &GP_default_console_font,
-// .foreground = colors[GP_WHITE],
- .pixel_xmul = 2,
- .pixel_ymul = 1,
- .pixel_xspace = 0,
- .pixel_yspace = 1,
- };
-
- SDL_LockSurface(display);
- GP_Clear(display, colors[GP_BLACK]);
-
- /* axes */
- if (show_axes) {
- GP_HLine(display, colors[GP_GRAY], 0, 640, y);
- GP_HLine(display, colors[GP_DARK_GRAY], 0, 640, y-yradius);
- GP_HLine(display, colors[GP_DARK_GRAY], 0, 640, y+yradius);
- GP_VLine(display, colors[GP_GRAY], x, 0, 480);
- GP_VLine(display, colors[GP_DARK_GRAY], x-xradius, 0, 480);
- GP_VLine(display, colors[GP_DARK_GRAY], x+xradius, 0, 480);
- }
-
- /* the shape */
- const char *title = NULL;
- switch (shape) {
- case SHAPE_TRIANGLE:
- draw_testing_triangle(x, y, xradius, yradius);
- title = "TRIANGLE";
- break;
- case SHAPE_CIRCLE:
- draw_testing_circle(x, y, xradius, yradius);
- title = "CIRCLE";
- break;
- case SHAPE_ELLIPSE:
- draw_testing_ellipse(x, y, xradius, yradius);
- title = "ELLIPSE";
- break;
- case SHAPE_RECTANGLE:
- draw_testing_rectangle(x, y, xradius, yradius);
- title = "RECTANGLE";
- break;
- }
- GP_Text(display, colors[GP_WHITE], &style, 16, 16, title);
-
- SDL_UnlockSurface(display);
-}
-
-void event_loop(void)
-{
- SDL_Event event;
-
- while (SDL_WaitEvent(&event) > 0) {
-
- switch (event.type) {
- case SDL_USEREVENT:
-
- if (xradius + xradius_add > 1 && xradius + xradius_add < 400)
- xradius += xradius_add;
- if (yradius + yradius_add > 1 && yradius + yradius_add < 400)
- yradius += yradius_add;
-
- redraw_screen();
- SDL_Flip(display);
- break;
-
- case SDL_KEYDOWN:
- switch (event.key.keysym.sym) {
-
- case SDLK_f:
- fill = !fill;
- if (!fill && !outline) {
- outline = 1;
- }
- break;
-
- case SDLK_o:
- outline = !outline;
- if (!fill && !outline) {
- fill = 1;
- }
- break;
-
- case SDLK_x:
- show_axes = !show_axes;
- break;
-
- case SDLK_ESCAPE:
- return;
-
- case SDLK_LEFT:
- xradius_add = -1;
- break;
-
- case SDLK_RIGHT:
- xradius_add = 1;
- break;
-
- case SDLK_UP:
- yradius_add = 1;
- break;
-
- case SDLK_DOWN:
- yradius_add = -1;
- break;
-
- case SDLK_PAGEUP:
- xradius_add = 1;
- yradius_add = 1;
- break;
-
- case SDLK_PAGEDOWN:
- xradius_add = -1;
- yradius_add = -1;
- break;
-
- case SDLK_1:
- variant = 1;
- break;
-
- case SDLK_2:
- variant = 2;
- break;
-
- case SDLK_3:
- variant = 3;
- break;
-
- case SDLK_SPACE:
- shape++;
- if (shape > SHAPE_LAST)
- shape = SHAPE_FIRST;
- break;
-
- case SDLK_EQUALS:
- if (xradius > yradius)
- yradius = xradius;
- else
- xradius = yradius;
- break;
-
- default:
- break;
- }
- break;
- case SDL_KEYUP:
- switch (event.key.keysym.sym) {
-
- /* Stop incrementing as soon as the key is released. */
- case SDLK_LEFT:
- case SDLK_RIGHT:
- xradius_add = 0;
- break;
- case SDLK_UP:
- case SDLK_DOWN:
- yradius_add = 0;
- break;
-
- case SDLK_PAGEUP:
- case SDLK_PAGEDOWN:
- xradius_add = 0;
- yradius_add = 0;
- break;
-
- default:
- break;
- }
- break;
- case SDL_QUIT:
- return;
- }
- }
-}
-
-void print_instructions(void)
-{
- printf("Use the following keys to control the test:n");
- printf(" Esc ......... exitn");
- printf(" Space ....... change shapesn");
- printf(" O ........... toggle outline drawingn");
- printf(" F ........... toggle fillingn");
- printf(" X ........... show/hide axesn");
- printf(" left/right .. increase/decrease horizontal radiusn");
- printf(" up/down ..... increase/decrease vertical radiusn");
- printf(" PgUp/PgDn ... increase/decrease both radiin");
- printf(" = ........... reset radii to the same valuen");
- printf(" 1/2/3 ....... choose shape variant (if applicable)n");
-}
-
-int main(int argc, char ** argv)
-{
- int display_bpp = 0;
-
- int i;
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-16") == 0) {
- display_bpp = 16;
- }
- else if (strcmp(argv[i], "-24") == 0) {
- display_bpp = 24;
- }
- }
-
- /* Initialize SDL */
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
- fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError());
- return 1;
- }
-
- /* Create a window with a software back surface */
- display = SDL_SetVideoMode(640, 480, display_bpp, SDL_SWSURFACE);
- if (display == NULL) {
- fprintf(stderr, "Could not open display: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Find pixel representations of needed colors */
- GP_LoadBasicColors(display, colors);
-
- /* Set up a clipping rectangle to exercise clipping */
- SDL_Rect clip_rect = {10, 10, 620, 460};
- SDL_SetClipRect(display, &clip_rect);
-
- /* Set up the refresh timer */
- timer = SDL_AddTimer(60, timer_callback, NULL);
- if (timer == 0) {
- fprintf(stderr, "Could not set up timer: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Print a short info how to use this test. */
- print_instructions();
-
- /* Enter the event loop */
- event_loop();
-
- /* We're done */
- SDL_Quit();
- return 0;
-
-fail:
- SDL_Quit();
- return 1;
-}
-
diff --git a/old_tests/widelinetest.c b/old_tests/widelinetest.c
deleted file mode 100644
index 395885d..0000000
--- a/old_tests/widelinetest.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <SDL/SDL.h>
-
-#include "GP.h"
-
-/* The surface used as a display (in fact it is a software surface). */
-SDL_Surface *display = NULL;
-
-/* Timer used for refreshing the display */
-SDL_TimerID timer;
-
-/* An event used for signaling that the timer was triggered. */
-SDL_UserEvent timer_event;
-
-/* Values for color pixels in display format. */
-static long colors[GP_BASIC_COLOR_COUNT];
-
-Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
- __attribute__((unused)) void *param)
-{
- timer_event.type = SDL_USEREVENT;
- SDL_PushEvent((SDL_Event *) &timer_event);
- return 30;
-}
-
-double start_angle = 0.0;
-
-void redraw_screen(void)
-{
- int i;
-
- for (i = 1; i < 10; i++) {
- GP_HLineWide(display, colors[GP_WHITE], GP_LINE_CENTER, i, 10, 100, 20*i);
- GP_HLine(display, colors[GP_RED], 10, 100, 20*i);
- }
-
- for (i = 1; i < 10; i++) {
- GP_VLineWide(display, colors[GP_WHITE], GP_LINE_CENTER, i, 100 + 20*i, 100, 190);
- GP_VLine(display, colors[GP_RED], 100 + 20*i, 100, 190);
- }
-}
-
-void event_loop(void)
-{
- SDL_Event event;
-
- while (SDL_WaitEvent(&event) > 0) {
- switch (event.type) {
- case SDL_USEREVENT:
- redraw_screen();
- SDL_Flip(display);
- start_angle += 0.01;
- if (start_angle > 2*M_PI) {
- start_angle = 0.0;
- }
- break;
- case SDL_KEYDOWN:
- case SDL_QUIT:
- return;
- }
- }
-}
-
-int main(void)
-{
- /* Initialize SDL */
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
- fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError());
- return 1;
- }
-
- /* Create a window with a software back surface */
- display = SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE);
- if (display == NULL) {
- fprintf(stderr, "Could not open display: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Print basic information about the surface */
- printf("Display surface properties:n");
- printf(" width: %4d, height: %4d, pitch: %4dn",
- display->w, display->h, display->pitch);
- printf(" bits per pixel: %2d, bytes per pixel: %2dn",
- display->format->BitsPerPixel, display->format->BytesPerPixel);
-
- /* Get colors */
- GP_LoadBasicColors(display, colors);
-
- /* Set up a clipping rectangle to test proper clipping of pixels */
- SDL_Rect clip_rect = { 10, 10, 620, 460 };
- SDL_SetClipRect(display, &clip_rect);
-
- /* Set up the refresh timer */
- timer = SDL_AddTimer(30, timer_callback, NULL);
- if (timer == 0) {
- fprintf(stderr, "Could not set up timer: %sn", SDL_GetError());
- goto fail;
- }
-
- /* Enter the event loop */
- event_loop();
-
- /* We're done */
- SDL_Quit();
- return 0;
-
-fail:
- SDL_Quit();
- return 1;
-}
-
diff --git a/targets/sdl/Makefile b/targets/sdl/Makefile
deleted file mode 100644
index 6c088f8..0000000
--- a/targets/sdl/Makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-LIBRARY=libGP_SDL
-
-HEADERS=GP_SDL.h - GP_SDL_Context.h - GP_SDL_VideoInit.h
-
-EXTRA_DEPS=
-
-OBJECTS=GP_SDL_Context.o - GP_SDL_VideoInit.o
-
-.PHONY: library tests clean tar install
-
-all: library tests
-
-library: $(LIBRARY)
-
-tests:
- cd tests && $(MAKE) all
-
-$(LIBRARY): $(LIBRARY).a $(LIBRARY).so
-
-$(OBJECTS): GP_SDL.h
-
-#############################################################################
-# Building rules.
-#############################################################################
-
-CFLAGS=-W -Wall -O2 -fPIC -I../.. -I../../core
-
-%.o: %.c $(HEADERS)
- $(CC) $(CFLAGS) $< -c -o $@
-
-$(LIBRARY).a: $(OBJECTS) $(EXTRA_DEPS)
- ar crus $@ $^
-
-$(LIBRARY).so: $(OBJECTS) $(EXTRA_DEPS)
- $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$@.0 $(CFLAGS) $^ -o $@
- ln -sf $@ $@.0
-
-#############################################################################
-# Installation, cleanup, and packing.
-#############################################################################
-
-HEADER_LOC=/usr/include/
-LIB_LOC=/usr/lib/
-
-install:
- install -m 775 -d $(HEADER_LOC)GP/
- install -m 664 *.h $(HEADER_LOC)GP/
- install -m 775 -d $(HEADER_LOC)GP/backends/
- install -m 664 backends/*.h $(HEADER_LOC)GP/backends/
- install -m 664 *.so *.so.0 *.a $(LIB_LOC)
-
-clean:
- rm -f $(OBJECTS)
- rm -f $(LIBRARY).a $(LIBRARY).so $(LIBRARY).so.0
- cd tests && $(MAKE) clean
-
-tar: clean
- cd .. && tar cjf gfxprim-`date +%Y-%b-%d`.tar.bz2 gfxprim
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..676ca51
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,3 @@
+TOPDIR=..
+SUBDIRS=loaders filters #core
+include $(TOPDIR)/include.mk
diff --git a/core/tests/GP_Comon.test.c b/tests/core/GP_Comon.test.c
similarity index 100%
rename from core/tests/GP_Comon.test.c
rename to tests/core/GP_Comon.test.c
diff --git a/core/tests/GP_Tests.h b/tests/core/GP_Tests.h
similarity index 100%
rename from core/tests/GP_Tests.h
rename to tests/core/GP_Tests.h
diff --git a/tests/core/Makefile b/tests/core/Makefile
new file mode 100644
index 0000000..b1da0ed
--- /dev/null
+++ b/tests/core/Makefile
@@ -0,0 +1,31 @@
+TOPDIR=../..
+
+CSOURCES=$(shell echo *.test.c) core_tests.gen.c
+
+INCLUDE=core
+LDLIBS+=-lGP -L$(TOPDIR)/build/ -lcheck
+
+APPS=core_tests
+
+include $(TOPDIR)/include.mk
+include $(TOPDIR)/app.mk
+
+.PHONY: run
+
+TEST_SRCS=$(wildcard *.test.c)
+TEST_OBJS=$(patsubst %.c,%.o,$(TEST_SRCS))
+
+CLEAN+=core_tests.gen.c
+
+run: $(TESTS)
+ for test in $(TESTS); do LD_LIBRARY_PATH=../ ./"$$test" -v ; done
+
+core_tests.gen.c: $(TEST_SRCS) find_tests.py
+ifdef VERBOSE
+ python find_tests.py -c $@ $(TEST_SRCS)
+else
+ @echo "GEN (python) $@"
+ @python find_tests.py -c $@ $(TEST_SRCS)
+endif
+
+core_tests: $(TEST_OBJS) core_tests.gen.o
diff --git a/core/tests/core_tests.c b/tests/core/core_tests.c
similarity index 100%
rename from core/tests/core_tests.c
rename to tests/core/core_tests.c
diff --git a/core/tests/find_tests.py b/tests/core/find_tests.py
similarity index 100%
rename from core/tests/find_tests.py
rename to tests/core/find_tests.py
diff --git a/core/tests/font.test.c b/tests/core/font.test.c
similarity index 100%
rename from core/tests/font.test.c
rename to tests/core/font.test.c
diff --git a/drivers/GP_Framebuffer.c b/tests/drivers/GP_Framebuffer.c
similarity index 100%
rename from drivers/GP_Framebuffer.c
rename to tests/drivers/GP_Framebuffer.c
diff --git a/drivers/GP_Framebuffer.h b/tests/drivers/GP_Framebuffer.h
similarity index 100%
rename from drivers/GP_Framebuffer.h
rename to tests/drivers/GP_Framebuffer.h
diff --git a/drivers/tests/Makefile b/tests/drivers/tests/Makefile
similarity index 100%
rename from drivers/tests/Makefile
rename to tests/drivers/tests/Makefile
diff --git a/drivers/tests/framebuffer_test.c b/tests/drivers/tests/framebuffer_test.c
similarity index 100%
rename from drivers/tests/framebuffer_test.c
rename to tests/drivers/tests/framebuffer_test.c
diff --git a/drivers/tests/runtest.sh b/tests/drivers/tests/runtest.sh
similarity index 100%
rename from drivers/tests/runtest.sh
rename to tests/drivers/tests/runtest.sh
diff --git a/drivers/tests/sierpinsky.c b/tests/drivers/tests/sierpinsky.c
similarity index 100%
rename from drivers/tests/sierpinsky.c
rename to tests/drivers/tests/sierpinsky.c
diff --git a/tests/filters/Makefile b/tests/filters/Makefile
new file mode 100644
index 0000000..7e43d98
--- /dev/null
+++ b/tests/filters/Makefile
@@ -0,0 +1,11 @@
+TOPDIR=../..
+
+CSOURCES=$(shell echo *.c)
+
+INCLUDE=filters loaders
+LDLIBS+=-lGP -L$(TOPDIR)/build/
+
+APPS=PGM_rotate rotate_test
+
+include $(TOPDIR)/include.mk
+include $(TOPDIR)/app.mk
diff --git a/filters/tests/PGM_rotate.c b/tests/filters/PGM_rotate.c
similarity index 100%
rename from filters/tests/PGM_rotate.c
rename to tests/filters/PGM_rotate.c
diff --git a/filters/tests/rotate_test.c b/tests/filters/rotate_test.c
similarity index 100%
rename from filters/tests/rotate_test.c
rename to tests/filters/rotate_test.c
diff --git a/filters/tests/runtest.sh b/tests/filters/runtest.sh
similarity index 100%
rename from filters/tests/runtest.sh
rename to tests/filters/runtest.sh
diff --git a/filters/tests/test-big.pgm b/tests/filters/test-big.pgm
similarity index 100%
rename from filters/tests/test-big.pgm
rename to tests/filters/test-big.pgm
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile
new file mode 100644
index 0000000..e079177
--- /dev/null
+++ b/tests/loaders/Makefile
@@ -0,0 +1,11 @@
+TOPDIR=../..
+
+CSOURCES=$(shell echo *.c)
+
+INCLUDE=loaders
+LDLIBS+=-lGP -L$(TOPDIR)/build/
+
+APPS=PBM_invert PBM_test PGM_invert PGM_test
+
+include $(TOPDIR)/include.mk
+include $(TOPDIR)/app.mk
diff --git a/loaders/tests/PBM_invert.c b/tests/loaders/PBM_invert.c
similarity index 100%
rename from loaders/tests/PBM_invert.c
rename to tests/loaders/PBM_invert.c
diff --git a/loaders/tests/PBM_test.c b/tests/loaders/PBM_test.c
similarity index 100%
rename from loaders/tests/PBM_test.c
rename to tests/loaders/PBM_test.c
diff --git a/loaders/tests/PGM_invert.c b/tests/loaders/PGM_invert.c
similarity index 100%
rename from loaders/tests/PGM_invert.c
rename to tests/loaders/PGM_invert.c
diff --git a/loaders/tests/PGM_test.c b/tests/loaders/PGM_test.c
similarity index 100%
rename from loaders/tests/PGM_test.c
rename to tests/loaders/PGM_test.c
diff --git a/loaders/tests/autotest.sh b/tests/loaders/autotest.sh
similarity index 100%
rename from loaders/tests/autotest.sh
rename to tests/loaders/autotest.sh
diff --git a/loaders/tests/runtest.sh b/tests/loaders/runtest.sh
similarity index 100%
rename from loaders/tests/runtest.sh
rename to tests/loaders/runtest.sh
diff --git a/targets/sdl/GP_SDL.h b/tests/sdl/GP_SDL.h
similarity index 100%
rename from targets/sdl/GP_SDL.h
rename to tests/sdl/GP_SDL.h
diff --git a/targets/sdl/GP_SDL_Context.c b/tests/sdl/GP_SDL_Context.c
similarity index 100%
rename from targets/sdl/GP_SDL_Context.c
rename to tests/sdl/GP_SDL_Context.c
diff --git a/targets/sdl/GP_SDL_Context.h b/tests/sdl/GP_SDL_Context.h
similarity index 100%
rename from targets/sdl/GP_SDL_Context.h
rename to tests/sdl/GP_SDL_Context.h
diff --git a/targets/sdl/GP_SDL_VideoInit.c b/tests/sdl/GP_SDL_VideoInit.c
similarity index 100%
rename from targets/sdl/GP_SDL_VideoInit.c
rename to tests/sdl/GP_SDL_VideoInit.c
diff --git a/targets/sdl/GP_SDL_VideoInit.h b/tests/sdl/GP_SDL_VideoInit.h
similarity index 100%
rename from targets/sdl/GP_SDL_VideoInit.h
rename to tests/sdl/GP_SDL_VideoInit.h
diff --git a/tests/sdl/Makefile b/tests/sdl/Makefile
new file mode 100644
index 0000000..e7c006f
--- /dev/null
+++ b/tests/sdl/Makefile
@@ -0,0 +1,2 @@
+all:
+clean:
diff --git a/targets/sdl/tests/Makefile b/tests/sdl/tests/Makefile
similarity index 100%
rename from targets/sdl/tests/Makefile
rename to tests/sdl/tests/Makefile
diff --git a/targets/sdl/tests/fileview.c b/tests/sdl/tests/fileview.c
similarity index 100%
rename from targets/sdl/tests/fileview.c
rename to tests/sdl/tests/fileview.c
diff --git a/targets/sdl/tests/fonttest.c b/tests/sdl/tests/fonttest.c
similarity index 100%
rename from targets/sdl/tests/fonttest.c
rename to tests/sdl/tests/fonttest.c
diff --git a/targets/sdl/tests/linetest.c b/tests/sdl/tests/linetest.c
similarity index 100%
rename from targets/sdl/tests/linetest.c
rename to tests/sdl/tests/linetest.c
diff --git a/targets/sdl/tests/pixeltest.c b/tests/sdl/tests/pixeltest.c
similarity index 100%
rename from targets/sdl/tests/pixeltest.c
rename to tests/sdl/tests/pixeltest.c
diff --git a/targets/sdl/tests/randomshapetest.c b/tests/sdl/tests/randomshapetest.c
similarity index 100%
rename from targets/sdl/tests/randomshapetest.c
rename to tests/sdl/tests/randomshapetest.c
diff --git a/targets/sdl/tests/runtest.sh b/tests/sdl/tests/runtest.sh
similarity index 100%
rename from targets/sdl/tests/runtest.sh
rename to tests/sdl/tests/runtest.sh
diff --git a/targets/sdl/tests/shapetest.c b/tests/sdl/tests/shapetest.c
similarity index 100%
rename from targets/sdl/tests/shapetest.c
rename to tests/sdl/tests/shapetest.c
diff --git a/targets/sdl/tests/sierpinsky.c b/tests/sdl/tests/sierpinsky.c
similarity index 100%
rename from targets/sdl/tests/sierpinsky.c
rename to tests/sdl/tests/sierpinsky.c
diff --git a/targets/sdl/tests/symbolstest.c b/tests/sdl/tests/symbolstest.c
similarity index 100%
rename from targets/sdl/tests/symbolstest.c
rename to tests/sdl/tests/symbolstest.c
diff --git a/targets/sdl/tests/textaligntest.c b/tests/sdl/tests/textaligntest.c
similarity index 100%
rename from targets/sdl/tests/textaligntest.c
rename to tests/sdl/tests/textaligntest.c
diff --git a/targets/sdl/tests/trianglefps.c b/tests/sdl/tests/trianglefps.c
similarity index 100%
rename from targets/sdl/tests/trianglefps.c
rename to tests/sdl/tests/trianglefps.c
-----------------------------------------------------------------------
Summary of changes:
Makefile | 64 ++--
algo/README | 7 -
app.mk | 15 +
build/Makefile | 41 ++
build/liblock.sh | 24 ++
build/link.sh | 27 ++
config.mk | 3 +
core/GP_Circle.c | 57 ---
core/GP_FillEllipse.c | 57 ---
core/GP_FillEllipse.h | 39 --
core/GP_FillRect.h | 46 ---
core/GP_LineTrack.c | 76 ----
core/GP_LineTrack.h | 72 ----
core/GP_Rect.c | 65 ----
core/Makefile | 38 --
core/tests/Makefile | 33 --
drivers/Makefile | 29 --
filters/Makefile | 29 --
filters/tests/Makefile | 17 -
include.mk | 101 +++++
filters/GP_Filters.h => include/GP.h | 17 +-
{core => include/backends}/GP_Backend.h | 2 +-
{core => include}/config.h | 2 -
{core => include/core}/GP_Clip.h | 0
{core => include/core}/GP_Color.h | 0
{core => include/core}/GP_Common.h | 0
{core => include/core}/GP_Context.h | 5 +-
core/GP_FillCircle.h => include/core/GP_Core.h | 27 +-
{core => include/core}/GP_FnPerBpp.h | 2 -
{core => include/core}/GP_GetPixel.h | 0
{core => include/core}/GP_Palette.h | 0
{core => include/core}/GP_Pixel.h | 0
{core => include/core}/GP_PutPixel.h | 0
{core => include/core}/GP_RetCode.h | 0
{core => include/core}/GP_Transform.h | 0
{core => include/core}/GP_WritePixel.h | 0
{filters => include/filters}/GP_Filters.h | 0
{filters => include/filters}/GP_Rotate.h | 3 +-
{core => include/gfx}/GP_Circle.h | 8 +-
{core => include/gfx}/GP_Ellipse.h | 9 +-
{core => include/gfx}/GP_Fill.h | 2 +-
core/GP.h => include/gfx/GP_Gfx.h | 42 +--
{core => include/gfx}/GP_HLine.h | 4 +-
{core => include/gfx}/GP_Line.h | 4 +-
{core => include/gfx}/GP_Polygon.h | 4 +-
{core => include/gfx}/GP_Rect.h | 17 +-
{core => include/gfx}/GP_Symbol.h | 4 +-
{core => include/gfx}/GP_Tetragon.h | 2 +-
{core => include/gfx}/GP_Triangle.h | 2 +-
{core => include/gfx}/GP_VLine.h | 2 +-
{input => include/input}/GP_Event.h | 0
{loaders => include/loaders}/GP_Loaders.h | 6 +
{loaders => include/loaders}/GP_PBM.h | 2 +-
{loaders => include/loaders}/GP_PGM.h | 2 +-
{core => include/text}/GP_Font.h | 2 +-
{core => include/text}/GP_Text.h | 5 +-
{core => include/text}/GP_TextMetric.h | 0
{core => include/text}/GP_TextStyle.h | 2 +-
input/Makefile | 27 --
lib.mk | 11 +
libs/Makefile | 3 +
{core => libs/backends}/GP_Backend.c | 3 +-
{backends => libs/backends}/GP_Backend_SDL.c | 2 +-
libs/backends/Makefile | 5 +
{core => libs/core}/GP_Color.c | 0
{core => libs/core}/GP_Context.c | 7 +-
{core => libs/core}/GP_GetPixel.c | 2 +-
{core => libs/core}/GP_Palette.c | 0
{core => libs/core}/GP_Pixel.c | 2 +-
{core => libs/core}/GP_PutPixel.c | 2 +-
{core => libs/core}/GP_RetCode.c | 0
{core => libs/core}/GP_WritePixel.c | 3 +-
libs/core/Makefile | 5 +
{filters => libs/filters}/GP_Rotate.c | 11 +-
libs/filters/Makefile | 5 +
{filters => libs/filters/algo}/GP_MirrorV.algo.h | 2 +-
{filters => libs/filters/algo}/GP_Rotate.algo.h | 6 +-
core/GP_FillCircle.c => libs/gfx/GP_Circle.c | 24 +-
{core => libs/gfx}/GP_Ellipse.c | 35 ++-
{core => libs/gfx}/GP_Fill.c | 2 +-
{core => libs/gfx}/GP_HLine.c | 4 +-
{core => libs/gfx}/GP_Line.c | 4 +-
{core => libs/gfx}/GP_Polygon.c | 2 +-
core/GP_FillRect.c => libs/gfx/GP_Rect.c | 41 ++-
{core => libs/gfx}/GP_Symbol.c | 2 +-
{core => libs/gfx}/GP_Tetragon.c | 2 +-
{core => libs/gfx}/GP_Triangle.c | 2 +-
{core => libs/gfx}/GP_VLine.c | 4 +-
libs/gfx/Makefile | 5 +
{algo => libs/gfx/algo}/Circle.algo.h | 0
{algo => libs/gfx/algo}/Ellipse.algo.h | 0
{algo => libs/gfx/algo}/FillCircle.algo.h | 0
{algo => libs/gfx/algo}/FillEllipse.algo.h | 0
{algo => libs/gfx/algo}/FillTriangle.algo.h | 0
{algo => libs/gfx/algo}/HLine.algo.h | 0
{algo => libs/gfx/algo}/Line.algo.h | 0
{algo => libs/gfx/algo}/VLine.algo.h | 0
{input => libs/input}/GP_Event.c | 0
libs/input/Makefile | 5 +
{loaders => libs/loaders}/GP_PBM.c | 0
{loaders => libs/loaders}/GP_PGM.c | 0
{loaders => libs/loaders}/GP_PXMCommon.c | 0
{loaders => libs/loaders}/GP_PXMCommon.h | 2 +-
libs/loaders/Makefile | 5 +
{core => libs/text}/GP_DefaultFont.c | 0
{core => libs/text}/GP_Font.c | 3 +-
{core => libs/text}/GP_Text.c | 5 +-
{core => libs/text}/GP_TextMetric.c | 3 +-
{core => libs/text}/GP_TextStyle.c | 2 +-
libs/text/Makefile | 5 +
{algo => libs/text/algo}/Text.algo.h | 0
loaders/Makefile | 29 --
loaders/tests/Makefile | 17 -
old_tests/Makefile | 26 --
old_tests/circlefps.c | 148 -------
old_tests/circlestest.c | 220 -----------
old_tests/ellipsetest.c | 240 ------------
old_tests/linefps.c | 149 --------
old_tests/linetest.c | 158 --------
old_tests/pixeltest.c | 138 -------
old_tests/runtest.sh | 10 -
old_tests/shapetest.c | 402 --------------------
old_tests/widelinetest.c | 138 -------
targets/sdl/Makefile | 61 ---
tests/Makefile | 3 +
{core/tests => tests/core}/GP_Comon.test.c | 0
{core/tests => tests/core}/GP_Tests.h | 0
tests/core/Makefile | 31 ++
{core/tests => tests/core}/core_tests.c | 0
{core/tests => tests/core}/find_tests.py | 0
{core/tests => tests/core}/font.test.c | 0
{drivers => tests/drivers}/GP_Framebuffer.c | 0
{drivers => tests/drivers}/GP_Framebuffer.h | 0
{drivers => tests/drivers}/tests/Makefile | 0
.../drivers}/tests/framebuffer_test.c | 0
{drivers => tests/drivers}/tests/runtest.sh | 0
{drivers => tests/drivers}/tests/sierpinsky.c | 0
tests/filters/Makefile | 11 +
{filters/tests => tests/filters}/PGM_rotate.c | 0
{filters/tests => tests/filters}/rotate_test.c | 0
{filters/tests => tests/filters}/runtest.sh | 0
{filters/tests => tests/filters}/test-big.pgm | 0
tests/loaders/Makefile | 11 +
{loaders/tests => tests/loaders}/PBM_invert.c | 0
{loaders/tests => tests/loaders}/PBM_test.c | 0
{loaders/tests => tests/loaders}/PGM_invert.c | 0
{loaders/tests => tests/loaders}/PGM_test.c | 0
{loaders/tests => tests/loaders}/autotest.sh | 0
{loaders/tests => tests/loaders}/runtest.sh | 0
{targets => tests}/sdl/GP_SDL.h | 0
{targets => tests}/sdl/GP_SDL_Context.c | 0
{targets => tests}/sdl/GP_SDL_Context.h | 0
{targets => tests}/sdl/GP_SDL_VideoInit.c | 0
{targets => tests}/sdl/GP_SDL_VideoInit.h | 0
tests/sdl/Makefile | 2 +
{targets => tests}/sdl/tests/Makefile | 0
{targets => tests}/sdl/tests/fileview.c | 0
{targets => tests}/sdl/tests/fonttest.c | 0
{targets => tests}/sdl/tests/linetest.c | 0
{targets => tests}/sdl/tests/pixeltest.c | 0
{targets => tests}/sdl/tests/randomshapetest.c | 0
{targets => tests}/sdl/tests/runtest.sh | 0
{targets => tests}/sdl/tests/shapetest.c | 0
{targets => tests}/sdl/tests/sierpinsky.c | 0
{targets => tests}/sdl/tests/symbolstest.c | 0
{targets => tests}/sdl/tests/textaligntest.c | 0
{targets => tests}/sdl/tests/trianglefps.c | 0
167 files changed, 579 insertions(+), 2485 deletions(-)
delete mode 100644 algo/README
create mode 100644 app.mk
create mode 100644 build/Makefile
create mode 100644 build/liblock.sh
create mode 100755 build/link.sh
create mode 100644 config.mk
delete mode 100644 core/GP_Circle.c
delete mode 100644 core/GP_FillEllipse.c
delete mode 100644 core/GP_FillEllipse.h
delete mode 100644 core/GP_FillRect.h
delete mode 100644 core/GP_LineTrack.c
delete mode 100644 core/GP_LineTrack.h
delete mode 100644 core/GP_Rect.c
delete mode 100644 core/Makefile
delete mode 100644 core/tests/Makefile
delete mode 100644 drivers/Makefile
delete mode 100644 filters/Makefile
delete mode 100644 filters/tests/Makefile
create mode 100644 include.mk
copy filters/GP_Filters.h => include/GP.h (90%)
rename {core => include/backends}/GP_Backend.h (99%)
rename {core => include}/config.h (91%)
rename {core => include/core}/GP_Clip.h (100%)
rename {core => include/core}/GP_Color.h (100%)
rename {core => include/core}/GP_Common.h (100%)
rename {core => include/core}/GP_Context.h (98%)
rename core/GP_FillCircle.h => include/core/GP_Core.h (84%)
rename {core => include/core}/GP_FnPerBpp.h (99%)
rename {core => include/core}/GP_GetPixel.h (100%)
rename {core => include/core}/GP_Palette.h (100%)
rename {core => include/core}/GP_Pixel.h (100%)
rename {core => include/core}/GP_PutPixel.h (100%)
rename {core => include/core}/GP_RetCode.h (100%)
rename {core => include/core}/GP_Transform.h (100%)
rename {core => include/core}/GP_WritePixel.h (100%)
rename {filters => include/filters}/GP_Filters.h (100%)
rename {filters => include/filters}/GP_Rotate.h (98%)
rename {core => include/gfx}/GP_Circle.h (89%)
rename {core => include/gfx}/GP_Ellipse.h (87%)
rename {core => include/gfx}/GP_Fill.h (98%)
rename core/GP.h => include/gfx/GP_Gfx.h (79%)
rename {core => include/gfx}/GP_HLine.h (98%)
rename {core => include/gfx}/GP_Line.h (98%)
rename {core => include/gfx}/GP_Polygon.h (97%)
rename {core => include/gfx}/GP_Rect.h (81%)
rename {core => include/gfx}/GP_Symbol.h (98%)
rename {core => include/gfx}/GP_Tetragon.h (98%)
rename {core => include/gfx}/GP_Triangle.h (98%)
rename {core => include/gfx}/GP_VLine.h (98%)
rename {input => include/input}/GP_Event.h (100%)
rename {loaders => include/loaders}/GP_Loaders.h (97%)
rename {loaders => include/loaders}/GP_PBM.h (98%)
rename {loaders => include/loaders}/GP_PGM.h (98%)
rename {core => include/text}/GP_Font.h (99%)
rename {core => include/text}/GP_Text.h (97%)
rename {core => include/text}/GP_TextMetric.h (100%)
rename {core => include/text}/GP_TextStyle.h (99%)
delete mode 100644 input/Makefile
create mode 100644 lib.mk
create mode 100644 libs/Makefile
rename {core => libs/backends}/GP_Backend.c (98%)
rename {backends => libs/backends}/GP_Backend_SDL.c (99%)
create mode 100644 libs/backends/Makefile
rename {core => libs/core}/GP_Color.c (100%)
rename {core => libs/core}/GP_Context.c (97%)
rename {core => libs/core}/GP_GetPixel.c (99%)
rename {core => libs/core}/GP_Palette.c (100%)
rename {core => libs/core}/GP_Pixel.c (99%)
rename {core => libs/core}/GP_PutPixel.c (99%)
rename {core => libs/core}/GP_RetCode.c (100%)
rename {core => libs/core}/GP_WritePixel.c (99%)
create mode 100644 libs/core/Makefile
rename {filters => libs/filters}/GP_Rotate.c (97%)
create mode 100644 libs/filters/Makefile
rename {filters => libs/filters/algo}/GP_MirrorV.algo.h (98%)
rename {filters => libs/filters/algo}/GP_Rotate.algo.h (97%)
rename core/GP_FillCircle.c => libs/gfx/GP_Circle.c (77%)
rename {core => libs/gfx}/GP_Ellipse.c (71%)
rename {core => libs/gfx}/GP_Fill.c (99%)
rename {core => libs/gfx}/GP_HLine.c (98%)
rename {core => libs/gfx}/GP_Line.c (98%)
rename {core => libs/gfx}/GP_Polygon.c (99%)
rename core/GP_FillRect.c => libs/gfx/GP_Rect.c (73%)
rename {core => libs/gfx}/GP_Symbol.c (99%)
rename {core => libs/gfx}/GP_Tetragon.c (99%)
rename {core => libs/gfx}/GP_Triangle.c (99%)
rename {core => libs/gfx}/GP_VLine.c (98%)
create mode 100644 libs/gfx/Makefile
rename {algo => libs/gfx/algo}/Circle.algo.h (100%)
rename {algo => libs/gfx/algo}/Ellipse.algo.h (100%)
rename {algo => libs/gfx/algo}/FillCircle.algo.h (100%)
rename {algo => libs/gfx/algo}/FillEllipse.algo.h (100%)
rename {algo => libs/gfx/algo}/FillTriangle.algo.h (100%)
rename {algo => libs/gfx/algo}/HLine.algo.h (100%)
rename {algo => libs/gfx/algo}/Line.algo.h (100%)
rename {algo => libs/gfx/algo}/VLine.algo.h (100%)
rename {input => libs/input}/GP_Event.c (100%)
create mode 100644 libs/input/Makefile
rename {loaders => libs/loaders}/GP_PBM.c (100%)
rename {loaders => libs/loaders}/GP_PGM.c (100%)
rename {loaders => libs/loaders}/GP_PXMCommon.c (100%)
rename {loaders => libs/loaders}/GP_PXMCommon.h (99%)
create mode 100644 libs/loaders/Makefile
rename {core => libs/text}/GP_DefaultFont.c (100%)
rename {core => libs/text}/GP_Font.c (99%)
rename {core => libs/text}/GP_Text.c (98%)
rename {core => libs/text}/GP_TextMetric.c (98%)
rename {core => libs/text}/GP_TextStyle.c (98%)
create mode 100644 libs/text/Makefile
rename {algo => libs/text/algo}/Text.algo.h (100%)
delete mode 100644 loaders/Makefile
delete mode 100644 loaders/tests/Makefile
delete mode 100644 old_tests/Makefile
delete mode 100644 old_tests/circlefps.c
delete mode 100644 old_tests/circlestest.c
delete mode 100644 old_tests/ellipsetest.c
delete mode 100644 old_tests/linefps.c
delete mode 100644 old_tests/linetest.c
delete mode 100644 old_tests/pixeltest.c
delete mode 100755 old_tests/runtest.sh
delete mode 100644 old_tests/shapetest.c
delete mode 100644 old_tests/widelinetest.c
delete mode 100644 targets/sdl/Makefile
create mode 100644 tests/Makefile
rename {core/tests => tests/core}/GP_Comon.test.c (100%)
rename {core/tests => tests/core}/GP_Tests.h (100%)
create mode 100644 tests/core/Makefile
rename {core/tests => tests/core}/core_tests.c (100%)
rename {core/tests => tests/core}/find_tests.py (100%)
rename {core/tests => tests/core}/font.test.c (100%)
rename {drivers => tests/drivers}/GP_Framebuffer.c (100%)
rename {drivers => tests/drivers}/GP_Framebuffer.h (100%)
rename {drivers => tests/drivers}/tests/Makefile (100%)
rename {drivers => tests/drivers}/tests/framebuffer_test.c (100%)
rename {drivers => tests/drivers}/tests/runtest.sh (100%)
rename {drivers => tests/drivers}/tests/sierpinsky.c (100%)
create mode 100644 tests/filters/Makefile
rename {filters/tests => tests/filters}/PGM_rotate.c (100%)
rename {filters/tests => tests/filters}/rotate_test.c (100%)
rename {filters/tests => tests/filters}/runtest.sh (100%)
rename {filters/tests => tests/filters}/test-big.pgm (100%)
create mode 100644 tests/loaders/Makefile
rename {loaders/tests => tests/loaders}/PBM_invert.c (100%)
rename {loaders/tests => tests/loaders}/PBM_test.c (100%)
rename {loaders/tests => tests/loaders}/PGM_invert.c (100%)
rename {loaders/tests => tests/loaders}/PGM_test.c (100%)
rename {loaders/tests => tests/loaders}/autotest.sh (100%)
rename {loaders/tests => tests/loaders}/runtest.sh (100%)
rename {targets => tests}/sdl/GP_SDL.h (100%)
rename {targets => tests}/sdl/GP_SDL_Context.c (100%)
rename {targets => tests}/sdl/GP_SDL_Context.h (100%)
rename {targets => tests}/sdl/GP_SDL_VideoInit.c (100%)
rename {targets => tests}/sdl/GP_SDL_VideoInit.h (100%)
create mode 100644 tests/sdl/Makefile
rename {targets => tests}/sdl/tests/Makefile (100%)
rename {targets => tests}/sdl/tests/fileview.c (100%)
rename {targets => tests}/sdl/tests/fonttest.c (100%)
rename {targets => tests}/sdl/tests/linetest.c (100%)
rename {targets => tests}/sdl/tests/pixeltest.c (100%)
rename {targets => tests}/sdl/tests/randomshapetest.c (100%)
rename {targets => tests}/sdl/tests/runtest.sh (100%)
rename {targets => tests}/sdl/tests/shapetest.c (100%)
rename {targets => tests}/sdl/tests/sierpinsky.c (100%)
rename {targets => tests}/sdl/tests/symbolstest.c (100%)
rename {targets => tests}/sdl/tests/textaligntest.c (100%)
rename {targets => tests}/sdl/tests/trianglefps.c (100%)
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
Jolly Sunday, good men,
what about some refactoring? I know metan is already taking look at
it. Some thoughts:
* Separate backends including GP_Backend.h (rationale: both Gfxprim
core, fonts and drawing are backend independent and should work even
without one, i.e. drawing to a file)
* The same for Events. Does it make sense to put it together with
backends (is it backend dependent)?
* Take all the drawing stuff from core/. Perhaps combine it with algo/
to drawing/ or something similar
* Take fonts from core/, perhaps separately from draw/
While there should be a single library as a result, I would propose
completely separate Makefiles and output libraries for the "modules"
-- this should speed up development (currently, I spend most of the
time patching the broken/irrelevant code out of my branch while
maintaining the ability to pull from master, "compilability" and
reasonable prospect of merging back to master in the future. Loser me.
How do you manage that?)
Tomas
2
1