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 47ceeb4450654c49fb304c7e79da62c50eb83304 (commit) via 5b542b7f5b3c026c6dc859bd55287f05f3586624 (commit) from 6c56dcd01573c443d0cd512a43a5966aa6edfde8 (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/47ceeb4450654c49fb304c7e79da62c50eb83...
commit 47ceeb4450654c49fb304c7e79da62c50eb83304 Author: Tomas Gavenciak gavento@ucw.cz Date: Thu May 26 23:29:07 2011 +0200
Fix .pyc cleanup rule
diff --git a/include.mk b/include.mk index ada1072..6505a3d 100644 --- a/include.mk +++ b/include.mk @@ -36,7 +36,7 @@ endif # Add .pyc files to CLEAN list # PYTHON_FILES=$(shell find "${PYLIBSDIR}" -name *.py) -CLEAN+=$(patsubst, %.py, %.pyc, ${}) +CLEAN+=$(patsubst %.py, %.pyc, ${PYTHON_FILES})
# # 1. Generate and include dependencies for all C sources
http://repo.or.cz/w/gfxprim.git/commit/5b542b7f5b3c026c6dc859bd55287f05f3586...
commit 5b542b7f5b3c026c6dc859bd55287f05f3586624 Author: Tomas Gavenciak gavento@ucw.cz Date: Thu May 26 23:26:15 2011 +0200
Old generators transformed to use new layout
Yay!
diff --git a/pylib/gfxprim/generators/core/gen_blit.py b/pylib/gfxprim/generators/core/gen_blit.py index 26fd3f7..819f29f 100644 --- a/pylib/gfxprim/generators/core/gen_blit.py +++ b/pylib/gfxprim/generators/core/gen_blit.py @@ -2,7 +2,7 @@ # - submodule for blit and friends # 2011 - Tomas Gavenciak gavento@ucw.cz
-from gfxprim.gen_utils import * +from gfxprim.generators.utils import *
## all generated direct blits, for generating GP_Blit() and others generated_blits = [] @@ -14,15 +14,15 @@ def gen_blit_same_t(size, size_suffix, header, code): "Only depends on bpp (bit size), size_suffix must be" "of form 8BPP, 2BPP_LE and the like."
- header.append(r( + header.rbody( "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_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_suffix=size_suffix)) + size=size, size_suffix=size_suffix)
- code.append(r( + code.rbody( "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" @@ -71,7 +71,7 @@ def gen_blit_same_t(size, size_suffix, header, code): " } else /* Different bit-alignment, can't use memcpy() */n" " GP_Blit_Naive(c1, x1, y1, w, h, c2, x2, y2);n" "{% endif %}" - "}n", size=size, size_suffix=size_suffix)) + "}n", size=size, size_suffix=size_suffix)
def gen_blit_t(f1, f2, header, code): @@ -82,10 +82,10 @@ def gen_blit_t(f1, f2, header, code): assert(set(f1.chans.keys()) in allowed_chansets) assert(set(f2.chans.keys()) in allowed_chansets)
- header.append(r( + header.rbody( "n/*** Blit line {{ f1.name }} -> {{ f2.name }} ***n" " * Assumes the contexts to be of the right types and sizes */nn" "void GP_Blit_{{ f1.name }}_{{ f2.name }}(const GP_Context *c1, int x1, int y2, int w, int h,n" " GP_Context *c2, int x2, int y2);n", - f1=f1, f2=f2)) + f1=f1, f2=f2)
diff --git a/pylib/gfxprim/generators/core/gen_pixeltype.py b/pylib/gfxprim/generators/core/gen_pixeltype.py index bfde4f2..b46d3dd 100644 --- a/pylib/gfxprim/generators/core/gen_pixeltype.py +++ b/pylib/gfxprim/generators/core/gen_pixeltype.py @@ -7,9 +7,8 @@ Such functions accept (and then extend) two list of strins. These should be later joined with "" or " ". """
-from gfxprim.pixeltype import pixeltypes, channels -from gfxprim.genutils import * -from gfxprim.genutils import j2render as r +from gfxprim.generators.pixeltype import pixeltypes, channels +from gfxprim.generators.utils import j2render as r, hmask
def str_start(ptype): @@ -36,20 +35,20 @@ def gen_GP_PixelType(header, code): pt_by_num = sorted([(t.number, t) for t in pixeltypes.values()]) sorted_pts = [t[1] for t in pt_by_num] pt_max = len(sorted_pts) - header.append(r( + header.rbody( "/* List of all known pixel types */n" "typedef enum GP_PixelType {n" "{% for t in sorted_pts %}" " GP_PIXEL_{{ t.name }} = {{ t.number }},n" "{% endfor %}" " GP_PIXEL_MAX = {{ pt_max }},n" - "} GP_PixelType;n", sorted_pts=sorted_pts, pt_max=pt_max)) + "} GP_PixelType;n", sorted_pts=sorted_pts, pt_max=pt_max)
def gen_GP_PixelTypes(header, code): "Generate the const structure GP_PixelTypes describing all the PixelTypes" pt_by_num = sorted([(t.number, t) for t in pixeltypes.values()]) sorted_pts = [t[1] for t in pt_by_num] - code.append(r( + code.rbody( "/* Description of all known pixel types */n" "const GP_PixelTypeDescription const GP_PixelTypes [] = {n" "{% for t in sorted_pts %}" @@ -67,14 +66,14 @@ def gen_GP_PixelTypes(header, code): '{% endfor %}' ' } },n' '{% endfor %}' - '};n', sorted_pts=sorted_pts, len=len)) + '};n', sorted_pts=sorted_pts, len=len)
def gen_print(ptype, header, code): "Generate a GP_Pixel_Print_<TYPE> function (source and header)" - header.append(r( + header.rbody( "/* print formatted value of pixel type {{ f.name }} */n" - "void GP_Pixel_Print_{{ f.name }}(GP_Pixel p);n", f=ptype)) - code.append(r( + "void GP_Pixel_Print_{{ f.name }}(GP_Pixel p);n", f=ptype) + code.rbody( "/* print formatted value of pixel type {{f.name}} */n" "void GP_Pixel_Print_{{ f.name }}(GP_Pixel p)n" "{n" @@ -83,15 +82,15 @@ def gen_print(ptype, header, code): "{% for c in f.chanslist %}" ",n GP_GET_BITS({{ c[1] }}, {{ c[2] }}, p)" "{% endfor %});n" - "}n", f=ptype)) + "}n", f=ptype)
def gen_get_chs(ptype, header, code): "Generate GP_Pixel_GET_<CHAN>_<TYPE> macros" - header.append(r( + header.rbody( "/* macros to get channels of pixel type {{ f.name }} */n" "{% for c in f.chanslist %}" "#define GP_Pixel_GET_{{ c[0] }}_{{ f.name }}(p) (GP_GET_BITS({{ c[1] }}, {{ c[2] }}, (p)))n" - "{% endfor %}", f=ptype)) + "{% endfor %}", f=ptype)
def gen_convert_to(f1, f2, header, code): "Generate a macro converting from f1 to f2" @@ -100,7 +99,7 @@ def gen_convert_to(f1, f2, header, code): assert(set(f1.chans.keys()) in allowed_chansets) assert(set(f2.chans.keys()) in allowed_chansets)
- header.append(r( + header.rbody( "n/*** {{ f1.name }} -> {{ f2.name }} ***n" " * macro storing p1 ({{ f1.name }} at bit-offset o1) in p2 ({{ f2.name }} at bit-offset o2),n" " * the relevant part of p2 is assumed to be clear (zero) */nn" @@ -143,24 +142,24 @@ def gen_convert_to(f1, f2, header, code): "/* a version without offsets */n" "#define GP_Pixel_{{ f1.name }}_TO_{{ f2.name }}(p1, p2) " "(GP_Pixel_{{ f1.name }}_TO_{{ f2.name }}_OFFSET(p1, 0, p2, 0))n", - f1=f1, f2=f2, hmask=hmask, set=set)) + f1=f1, f2=f2, hmask=hmask, set=set)
def gen_get_pixel_addr(ptype, header, code): "Generate GP_PIXEL_ADDR_<TYPE> and _OFFSET_<TYPE> macros" - header.append(r( + header.rbody( "/* 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_suffix }}(context, x, y)n" "/* macro to get bit-offset of pixel {{ f.name }} */n" "#define GP_PIXEL_ADDR_OFFSET_{{ f.name }}(x) " " GP_PIXEL_ADDR_OFFSET_{{ f.size_suffix }}(x)n", - f=ptype)) + f=ptype)
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( + header.rbody( "/* 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" @@ -176,4 +175,4 @@ def gen_get_pixel_addr_bpp(size, size_suffix, header, code): " ({{ 8-size }} - ((x) % {{ 8//size }}) * {{ size }})n" "{% endif %}" "{% endif %}", - size=size, size_suffix=size_suffix, bit_endian=bit_endian)) + size=size, size_suffix=size_suffix, bit_endian=bit_endian) diff --git a/pylib/gfxprim/generators/core/make_GP_Blit.py b/pylib/gfxprim/generators/core/make_GP_Blit.py index cda0e33..702d2ba 100644 --- a/pylib/gfxprim/generators/core/make_GP_Blit.py +++ b/pylib/gfxprim/generators/core/make_GP_Blit.py @@ -1,44 +1,31 @@ #!/usr/bin/python # -# Script generating GP_Pixel_Blit.gen.c and GP_Pixel_Blit.gen.h +# Generators for GP_Pixel_Blit.gen.c and GP_Pixel_Blit.gen.h # # 2011 - Tomas Gavenciak gavento@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 = "specialized blit functions and macros", - authors = ["2011 - Tomas Gavenciak gavento@ucw.cz"], - generator = __file__, - 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.h"n') -c.append('#include "GP_Context.h"n') -c.append('#include "GP_Blit.gen.h"n') - -for bpp in bitsizes: - 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 - -gen_footers(h, c) - -## Write out! - -if __name__ == '__main__': - main_write(h, c) +from gfxprim.generators.generator import * +from gfxprim.generators.pixeltype import * +from gfxprim.generators.core.gen_pixeltype import * +from gfxprim.generators.core.gen_blit import * + +@generator(CHeaderGenerator(name='GP_Blit.gen.h'), + CSourceGenerator(name='GP_Blit.gen.c'), + descr = 'specialized blit functions and macros', + authors = ["2011 - Tomas Gavenciak gavento@ucw.cz"]) +def core_GP_Blit_gen(h, c): + c.rhead( + '#include <stdio.h>n' + '#include <string.h>n' + '#include "GP_Pixel.h"n' + '#include "GP.h"n' + '#include "GP_Context.h"n' + '#include "GP_Blit.gen.h"n' + ) + + for bpp in bitsizes: + 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)
diff --git a/pylib/gfxprim/generators/core/make_GP_Pixel.py b/pylib/gfxprim/generators/core/make_GP_Pixel.py index e8f9f9a..f383f98 100644 --- a/pylib/gfxprim/generators/core/make_GP_Pixel.py +++ b/pylib/gfxprim/generators/core/make_GP_Pixel.py @@ -5,65 +5,66 @@ # 2011 - Tomas Gavenciak gavento@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 = "pixel type definitions and functions", - authors = ["2011 - Tomas Gavenciak gavento@ucw.cz"], - generator = __file__, - 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 - -gen_GP_PixelType(h, c) - -## PixelType parameters in C - -gen_GP_PixelTypes(h, c) - -## List of types - -for t in pixeltypes.values(): - if t.name != 'UNKNOWN': - h.append(str_start(t)) - h.append(str_description(t)) - c.append(str_start(t)) - c.append(str_description(t)) - - gen_print(t, h, c) - gen_get_chs(t, h, c) - gen_get_pixel_addr(t, h, c) - -# Per-bpp macros -for bpp in bitsizes: - 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 - -gen_convert_to(pixeltypes['RGB565'], pixeltypes['RGBA8888'], h, c) -gen_convert_to(pixeltypes['RGBA8888'], pixeltypes['V2'], h, c) -gen_convert_to(pixeltypes['VA12'], pixeltypes['RGBA8888'], h, c) - -## Close the files - -gen_footers(h, c) - -## Write out! - -if __name__ == '__main__': - main_write(h, c) +from gfxprim.generators.generator import * +from gfxprim.generators.pixeltype 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@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(CHeaderGenerator(name='GP_Pixel.gen.h'), + CSourceGenerator(name='GP_Pixel.gen.c'), + descr = 'pixel type definitions and functions', + authors = ["2011 - Tomas Gavenciak gavento@ucw.cz"]) +def core_GP_Pixel_gen(h, c): + c.rhead( + '#include <stdio.h>n' + '#include <GP.h>n' + '#include "GP_Pixel.h"n') + + ## Enum of types + gen_GP_PixelType(h, c) + + ## PixelType parameters in C + gen_GP_PixelTypes(h, c) + + ## List of types + for t in pixeltypes.values(): + if t.name != 'UNKNOWN': + h.rbody(str_start(t)) + h.rbody(str_description(t)) + c.rbody(str_start(t)) + c.rbody(str_description(t)) + + gen_print(t, h, c) + gen_get_chs(t, h, c) + gen_get_pixel_addr(t, h, c) + + # Per-bpp macros + for bpp in bitsizes: + 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 + gen_convert_to(pixeltypes['RGB565'], pixeltypes['RGBA8888'], h, c) + gen_convert_to(pixeltypes['RGBA8888'], pixeltypes['V2'], h, c) + gen_convert_to(pixeltypes['VA12'], pixeltypes['RGBA8888'], h, c)
diff --git a/pylib/gfxprim/generators/core/make_GP_Pixel_Scale.py b/pylib/gfxprim/generators/core/make_GP_Pixel_Scale.py deleted file mode 100644 index 77619fa..0000000 --- a/pylib/gfxprim/generators/core/make_GP_Pixel_Scale.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/python -# -# Script generating GP_Pixel.gen.c and GP_Pixel.gen.h -# -# 2011 - Tomas Gavenciak gavento@ucw.cz -# - -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@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@ucw.cz"]) -def core_GP_Pixel_gen(c, h): - c.rhead("CCCCCC") - h.rhead("HHHHHH") - - - - - diff --git a/pylib/gfxprim/generators/pixeltype.py b/pylib/gfxprim/generators/pixeltype.py index 7c4248d..384930d 100644 --- a/pylib/gfxprim/generators/pixeltype.py +++ b/pylib/gfxprim/generators/pixeltype.py @@ -100,7 +100,7 @@ def load_pixeltypes(defs_file = None): 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') + defs_file = os.path.join(path, '..', '..', 'pixeltypes.py') sys.stderr.write("Opening PixelType defs file '" + defs_file + "'n") l1 = len(pixeltypes) execfile(defs_file) diff --git a/pylib/gfxprim/generators/utils.py b/pylib/gfxprim/generators/utils.py index cd12e5e..28c1891 100644 --- a/pylib/gfxprim/generators/utils.py +++ b/pylib/gfxprim/generators/utils.py @@ -16,7 +16,8 @@ def j2render(tmpl, **kw): def load_generators(): "Load all modules containig generators to allow them to register" # TODO: write proper discovery - import gfxprim.generators.core.make_GP_Pixel_Scale + import gfxprim.generators.core.make_GP_Pixel + import gfxprim.generators.core.make_GP_Blit pass
def generate_file(fname): @@ -34,4 +35,6 @@ def generate_file(fname): with open(fname, "wt") as f: f.write(s)
- +def hmask(bits): + "Helper returning hex mask for that many bits" + return hex((1<<bits)-1).rstrip('L')
-----------------------------------------------------------------------
Summary of changes: include.mk | 2 +- pylib/gfxprim/generators/core/gen_blit.py | 14 +- pylib/gfxprim/generators/core/gen_pixeltype.py | 37 +++--- pylib/gfxprim/generators/core/make_GP_Blit.py | 61 ++++------ pylib/gfxprim/generators/core/make_GP_Pixel.py | 123 ++++++++++---------- .../gfxprim/generators/core/make_GP_Pixel_Scale.py | 42 ------- pylib/gfxprim/generators/pixeltype.py | 2 +- pylib/gfxprim/generators/utils.py | 7 +- 8 files changed, 118 insertions(+), 170 deletions(-) delete mode 100644 pylib/gfxprim/generators/core/make_GP_Pixel_Scale.py
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.