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 c5577daf85d4668a1599d1131d5539b56108e188 (commit) via 40d5d39bf35b82553d101497238393b04f86f55e (commit) from f9ab072d9aeefcd9888506fe0a9f30757c9e9a76 (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/c5577daf85d4668a1599d1131d5539b56108e...
commit c5577daf85d4668a1599d1131d5539b56108e188 Author: Cyril Hrubis metan@ucw.cz Date: Thu Apr 11 16:38:50 2013 +0200
core: Add GP_PixelHasFlags() + tests.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h index a60707f..ff2d710 100644 --- a/include/core/GP_Pixel.h +++ b/include/core/GP_Pixel.h @@ -91,6 +91,16 @@ typedef struct GP_PixelTypeChannel { #define GP_PIXELTYPE_MAX_CHANNELS 8
/* + * Pixel type flags for various pixel properties. + */ +typedef enum GP_PixelFlags { + GP_PIXEL_HAS_ALPHA = 0x01, + GP_PIXEL_IS_RGB = 0x02, + GP_PIXEL_IS_PALETTE = 0x04, + GP_PIXEL_IS_GRAYSCALE = 0x10, +} GP_PixelFlags; + +/* * Description of one PixelType * Assumes name with at most 15 chars * Assumes at most 8 channels @@ -101,6 +111,7 @@ typedef struct GP_PixelTypeDescription { uint8_t size; /* Size in bits */ GP_BIT_ENDIAN bit_endian; /* Order of pixels in a byte */ uint8_t numchannels; /* Number of channels */ + GP_PixelFlags flags; /* String describing the bit-representaton (as in "RRRRRGGGGGGBBBBB")*/ const char bitmap[GP_PIXEL_BITS + 1]; /* Individual channels */ @@ -187,9 +198,13 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff, uint8_t bits_per_pixel);
/* - * Function to determine pixel attributes. + * Functions to determine pixel attributes. + * + * Call as: + * + * if (GP_PixelHasFlags(pixel_type, GP_PIXEL_IS_RGB | GP_PIXEL_HAS_ALPHA)) + * ... */ -int GP_PixelHasAlpha(GP_PixelType pixel_type); - +int GP_PixelHasFlags(GP_PixelType pixel_type, GP_PixelFlags flags);
#endif /* CORE_GP_PIXEL_H */ diff --git a/libs/core/GP_Pixel.c b/libs/core/GP_Pixel.c index b1ccad5..a210892 100644 --- a/libs/core/GP_Pixel.c +++ b/libs/core/GP_Pixel.c @@ -163,15 +163,9 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff, return GP_PIXEL_UNKNOWN; }
-int GP_PixelHasAlpha(GP_PixelType pixel_type) +int GP_PixelHasFlags(GP_PixelType pixel_type, GP_PixelFlags flags) { - unsigned int i; - - GP_CHECK_VALID_PIXELTYPE(pixel_type); - - for (i = 0; i < GP_PixelTypes[pixel_type].numchannels; i++) - if (!strcmp(GP_PixelTypes[pixel_type].channels[i].name, "A")) - return 1; + GP_PixelFlags my_flags = GP_PixelTypes[pixel_type].flags;
- return 0; + return flags == (my_flags & flags); } diff --git a/libs/core/GP_Pixel.gen.c.t b/libs/core/GP_Pixel.gen.c.t index 8374856..7fad071 100644 --- a/libs/core/GP_Pixel.gen.c.t +++ b/libs/core/GP_Pixel.gen.c.t @@ -1,3 +1,26 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2011-2012 Tomas Gavenciak gavento@ucw.cz * + * Copyright (C) 2011-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + %% extends "base.c.t"
%% block descr @@ -9,6 +32,13 @@ Pixel type definitions and functions #include "GP_Pixel.h" #include "GP_GetSetBits.h"
+%%- macro getflags(pt) +{% if pt.is_alpha() %} | GP_PIXEL_HAS_ALPHA{% endif -%} +{% if pt.is_rgb() %} | GP_PIXEL_IS_RGB{% endif -%} +{% if pt.is_palette() %} | GP_PIXEL_IS_PALETTE{% endif -%} +{% if pt.is_gray() %} | GP_PIXEL_IS_GRAYSCALE{% endif -%} +%%- endmacro + /* * Description of all known pixel types */ @@ -21,6 +51,7 @@ const GP_PixelTypeDescription const GP_PixelTypes [GP_PIXEL_MAX] = { .bit_endian = {{ pt.pixelsize.bit_endian_const }}, .numchannels = {{ len(pt.chanslist) }}, .bitmap = "{{ pt.bits|join("") }}", + .flags = 0{{ getflags(pt) }}, .channels = { %% for c in pt.chanslist { .name = "{{ c[0] }}", .offset = {{ c[1] }}, .size = {{ c[2] }} }, diff --git a/tests/core/Makefile b/tests/core/Makefile index 91185c2..757416b 100644 --- a/tests/core/Makefile +++ b/tests/core/Makefile @@ -2,11 +2,11 @@ TOPDIR=../..
include $(TOPDIR)/pre.mk
-CSOURCES=Context.c +CSOURCES=Context.c Pixel.c
GENSOURCES+=WritePixel_testsuite.gen.c GetPutPixel.gen.c
-APPS=WritePixel_testsuite.gen Context GetPutPixel.gen +APPS=WritePixel_testsuite.gen Pixel Context GetPutPixel.gen
include ../tests.mk
diff --git a/tests/core/Pixel.c b/tests/core/Pixel.c new file mode 100644 index 0000000..e334a16 --- /dev/null +++ b/tests/core/Pixel.c @@ -0,0 +1,72 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +/* + + Very basic GP_Pixel tests. + + */ +#include <errno.h> + +#include <core/GP_Pixel.h> + +#include "tst_test.h" + +static int pixel_flags(void) +{ + int fail = 0; + + if (!GP_PixelHasFlags(GP_PIXEL_RGB888, GP_PIXEL_IS_RGB)) { + tst_msg("RGB888 is RGB failed"); + fail++; + } + + if (GP_PixelHasFlags(GP_PIXEL_G1, GP_PIXEL_IS_RGB)) { + tst_msg("G1 is RGB succeeded"); + fail++; + } + + if (!GP_PixelHasFlags(GP_PIXEL_RGBA8888, GP_PIXEL_HAS_ALPHA)) { + tst_msg("RGBA8888 has Alpha failed"); + fail++; + } + + if (!GP_PixelHasFlags(GP_PIXEL_RGBA8888, + GP_PIXEL_HAS_ALPHA | GP_PIXEL_IS_RGB)) { + tst_msg("RGBA8888 has Alpha and is RGB failed"); + fail++; + } + + if (fail) + return TST_FAILED; + + return TST_SUCCESS; +} + +const struct tst_suite tst_suite = { + .suite_name = "Pixel Testsuite", + .tests = { + {.name = "Pixel Flags", + .tst_fn = pixel_flags}, + {.name = NULL}, + } +}; diff --git a/tests/core/test_list.txt b/tests/core/test_list.txt index 458f6e4..c4f6bb7 100644 --- a/tests/core/test_list.txt +++ b/tests/core/test_list.txt @@ -1,4 +1,5 @@ # Core testsuite WritePixel_testsuite.gen Context +Pixel GetPutPixel.gen
http://repo.or.cz/w/gfxprim.git/commit/40d5d39bf35b82553d101497238393b04f86f...
commit 40d5d39bf35b82553d101497238393b04f86f55e Author: Cyril Hrubis metan@ucw.cz Date: Thu Apr 11 14:24:26 2013 +0200
doc: compilation: Add instructions for debian.
Thanks Milan Vancura for the list.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/doc/compilation.txt b/doc/compilation.txt index 741b878..cb025e0 100644 --- a/doc/compilation.txt +++ b/doc/compilation.txt @@ -66,7 +66,7 @@ into your system. Python bindings are not installable at the moment. OpenSUSE ~~~~~~~~
-Here are commands to install required packages on +Instruction to install required packages on link:http://www.opensuse.org/%5BOpenSUSE].
.Install basic tools @@ -100,3 +100,39 @@ zypper in gcc make python-Jinja2 libjpeg-devel libpng-devel giflib-devel freetype-devel libX11-devel libXext-devel swig python-devel -------------------------------------------------------------------------------
+Debian +~~~~~~ + +Instruction to install required packages on link:http://www.debian.org%5BDebian] +and other debian based distributions. + +.Install basic tools +------------------------------------------------------------------------------- +apt-get install gcc make python-jinja2 +------------------------------------------------------------------------------- + +.Install jpeg and png devel libraries +------------------------------------------------------------------------------- +apt-get install libjpeg-dev libpng-dev libgif-dev +------------------------------------------------------------------------------- + +.Install FreeType devel library +------------------------------------------------------------------------------- +apt-get install libfreetype6-dev +------------------------------------------------------------------------------- + +.Install X11 devel library +------------------------------------------------------------------------------- +apt-get install libx11-dev libxext-dev +------------------------------------------------------------------------------- + +.Install swig +------------------------------------------------------------------------------- +apt-get install swig python-dev +------------------------------------------------------------------------------- + +.All in the one for the lazy +------------------------------------------------------------------------------- +apt-get install gcc make python-jinja2 libjpeg-dev libpng-dev libgif-dev + libfreetype6-dev libx11-dev libxext-dev swig python-dev +-------------------------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes: doc/compilation.txt | 38 ++++++++++++++- include/core/GP_Pixel.h | 21 +++++++- libs/core/GP_Pixel.c | 12 +--- libs/core/GP_Pixel.gen.c.t | 31 ++++++++++++ tests/core/Makefile | 4 +- tests/{drivers/linux_input.c => core/Pixel.c} | 66 ++++++++++++++----------- tests/core/test_list.txt | 1 + 7 files changed, 129 insertions(+), 44 deletions(-) copy tests/{drivers/linux_input.c => core/Pixel.c} (66%)
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.