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
01 Dec '13
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 5b9a67f154c6251afb1203702830b837297a1030 (commit)
via 282b616826f4ad7cfd9c3b804c649e61e56a9b32 (commit)
via f63f5aa939d96a4abb0b345470dd7d92ab65a360 (commit)
from 2600399e7b0b62f90f89278758e619402535d74d (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/5b9a67f154c6251afb1203702830b837297a…
commit 5b9a67f154c6251afb1203702830b837297a1030
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Dec 1 20:28:53 2013 +0100
doc: Add C core documentation page + cleanup.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/Makefile b/doc/Makefile
index 197e81d..28cc670 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -4,7 +4,7 @@ SOURCES=index.html about.txt context.txt loaders.txt filters.txt gen.txt pixels.txt coordinate_system.txt coding_style.txt get_put_pixel.txt blits.txt progress_callback.txt text.txt event_queue.txt compilation.txt filters_resize.txt - filters_dithering.txt filters_python.txt spiv.txt
+ filters_dithering.txt filters_python.txt spiv.txt core_common.txt
SOURCES+=core_python.txt gfx_python.txt loaders_python.txt backends_python.txt
diff --git a/doc/asciidoc.conf b/doc/asciidoc.conf
index 240991d..be8e2dd 100644
--- a/doc/asciidoc.conf
+++ b/doc/asciidoc.conf
@@ -49,6 +49,7 @@ ifdef::toc2[<link rel="stylesheet" href="{stylesdir=.}/toc2.css" type="text/css"
</ul>
C API Pages
<ul>
+ <li><a href="core.html">Core</a></li>
<li><a href="gfx.html">Gfx</a></li>
<li><a href="text.html">Text</a></li>
<li><a href="filters.html">Filters</a></li>
diff --git a/doc/context.txt b/doc/context.txt
index ea7d5ba..0d42abd 100644
--- a/doc/context.txt
+++ b/doc/context.txt
@@ -1,8 +1,8 @@
Drawing Context
---------------
-The 'GP_Context' structure describes an 'in memory' pixmap. It contains all
-metadata needed for drawing and filters.
+The 'GP_Context' structure describes an 'in memory' pixmap. The structure
+contains all metadata needed for drawing, loaders and filters.
Data Structure
~~~~~~~~~~~~~~
@@ -40,14 +40,26 @@ typedef struct GP_Context {
The 'pixels' field points to the image data.
The 'pixels' are stored as a one-dimensional array consisting of byte-aligned
-lines (i.e. each image line starts at whole byte and ends at whole byte). The
-'pixels' array starts exactly at the start of the first line. Each line is
-'bytes_per_row' bytes long. The first pixel may actually start at 'offset' bit
-in the first byte in each line (but only for some sub contexts for pixel types
-that are not byte aligned). The first pixel is followed by the rest of the
-pixels in the image line (there is 'w' pixels in each line) and ends somewhere
-before the end of the line (i.e. there may be padding before the start of the
-next line or in case of subcontexts image data of the parent context).
+lines (i.e. each image line starts at whole byte and ends at whole byte).
+
+The 'pixels' array starts exactly at upper left corner of the image and is
+stored in horizontal lines (each line contains 'w' pixels and there is 'h'
+lines). Each line is 'bytes_per_row' bytes long (which equals to 'w' * 'bpp' /
+8 rouned up to the whole bytes). The first pixel may actually start at
+'offset' bit in the first byte in each line (but only for some
+<<Sub_Context,subcontexts>> for pixel types that are not byte aligned).
+
+The link:pixels.html[pixel_type enumeration] defines in which format and how
+are pixel data stored in the 'pixels' buffer, i.e. organization and function
+of the pixel channels.
+
+The optional pointer to link:gamma.html[gamma tables] describes per-channel
+gamma correction. Unfortunatelly very few parts of the library use it at the
+moment (this will be fixed in subsequent releases).
+
+The bitfield at the the end of the structure describes image orientation (see
+bellow) and a flag that tell if 'pixels' data should be freed, which is
+usefull for example for <<Sub_Context, subcontexts>>.
Rotation
^^^^^^^^
@@ -213,6 +225,7 @@ If 'free_pixels' flag is set, the pixels buffer is freed too.
If gamma pointer is not 'NULL' the 'GP_GammaRelease()' is called.
+[[Sub_Context]]
Subcontext
~~~~~~~~~~
diff --git a/doc/core.txt b/doc/core.txt
index c7148fa..1ae253a 100644
--- a/doc/core.txt
+++ b/doc/core.txt
@@ -1,146 +1,49 @@
-Common code in Core
--------------------
+Library Core
+------------
-NOTE: Some of the interfaces described here (most notably the allocator) are
- semi-internal interfaces and as such API is not considered stable.
+Library core contains all basic data structures and functions that forms the
+glue which holds the GFXprim libraries together.
-Common Macros and Inline Functions
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The most important data structure is a link:context.html[Context] which
+describes in-memory pixmap which is used extensively in all parts of the
+library.
-[source,c]
--------------------------------------------------------------------------------
-#include <core/GP_Common.h>
-/* or */
-#include <GP.h>
+Core also contains link:gen.html[generated] code for basic pixel manipulations
+such as link:get_put_pixel.html[GetPixel and PutPixel] as well as
+link:blits.html[Blits] implementation.
-GP_MIN(a, b);
+Library Core is a place to implement common functinonality that is used from
+the rest of the GFXprim modules, for example the link:debug.html[Debug layer]
+or link:progress_callback.html[Progress callback].
-GP_MAX(a, b);
+.Main Core library parts
+[grid="rows"]
+[options="autowidth"]
+|=============================================================================
+| link:context.html[Context] | Describes in-memory pixmap
-GP_MAX3(a, b, c);
+| link:basic_types.html[Basic types] | Types for size, lenght, pixel and
+ color
-GP_ABS(a);
+| link:pixels.html[Pixel types] | Pixel types handling and interface
-GP_SWAP(a, b);
+| link:get_put_pixel.html[GetPixel and PutPixel] | Macros and functions to
+ get and put pixels
-GP_SIGN(a);
+| link:blits.html[Blits] | Blits (copies) a rectangular area from one context to
+ another as well as simple pixel format conversions
-GP_ARRAY_SIZE(arr);
+| link:progress_callback.html[Progress Callback] | Progress callback passed
+ to all
+ link:filters.html[filters]
+ and
+ link:loaders.html[loaders]
-GP_CONTAINER_OF(ptr, structure, member);
+| link:debug.html[Debug layer] | Library debug layer
--------------------------------------------------------------------------------
+| link:core_common.html[Common macros] | Common macros and semi-internal
+ interface
-These common macros implements basic functions such as minimum, maximum,
-absolute value, swap and sign.
-
-All macros use 'typeof()' in order to evaluate their arguments exactly once.
-
-The 'GP_ARRAY_SIZE()' macro computes size of statically defined array (i.e.
-returns +sizeof(array) / sizeof(elem)+).
-
-The 'GP_CONTAINER_OF()' macro computes pointer to a structure given pointer to
-its member.
-
-[source,c]
--------------------------------------------------------------------------------
-#include <core/GP_Clamp.h>
-
-/*
- * Clamps integer value to 8 bit unsigned value.
- */
-GP_CLAMP_INT_0_255(val);
-
-/*
- * Clamps integer value.
- */
-GP_CLAMP(val, min, max);
-
--------------------------------------------------------------------------------
-
-Value clamping macros.
-
-NOTE: this header is not included by including the 'GP.h' header.
-
-Temporary Buffer Allocator
-~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Temporary buffer allocator is used to allocate temporary buffer needed for
-certain operations (mostly used in image filters).
-
-The intended usage of temporary buffers is:
-
-* Count sum of the size needed for all buffers
-* Allocate temporary buffer of this size
-* Partition the buffer into smaller blocks
-* Use the blocks as needed
-* Once operation is done, free the buffer
-
-The allocator code greatly simplifies these steps. Moreover it avoids memory
-fragmentation by creating small buffers on the process stack (current theshold
-is set to 2kB) and by grouping the temporary buffers into one continuous
-region.
-
-NOTE: The allocator itself does not align the resulting blocks. It's your
- responsibility to allocate the buffers in a way that the result is
- adequately aligned (hint: the start of the block is aligned, so
- get blocks that needs to be aligned first).
-
-[source,c]
--------------------------------------------------------------------------------
-#include <core/GP_TempAlloc.h>
-
-/*
- * A macro that creates block allocator.
- *
- * The name must be unique among variable and functions names.
- *
- * The bsize is actual size of the block allocated.
- */
-GP_TempAllocCreate(name, bsize);
-
-/*
- * A macro that returns pointer to the start of a block of a bsize
- * partioned from the block allocator passed as self argument.
- */
-GP_TempAllocGet(self, bsize);
-
-/*
- * Free the allocator memory.
- */
-GP_TempAllocFree(self);
--------------------------------------------------------------------------------
-
-Example usage of the allocator:
-
-[source,c]
--------------------------------------------------------------------------------
-#include <core/GP_TempAlloc.h>
-
-int foo(...)
-{
- GP_TempAllocCreate(tmp, 3 * img->width);
-
- uint8_t *R = GP_TempAllocGet(tmp, img->width);
- uint8_t *G = GP_TempAllocGet(tmp, img->width);
- uint8_t *B = GP_TempAllocGet(tmp, img->width);
-
- /* start of the code that uses the buffers */
-
- ...
-
- if (error) {
- GP_TempAllocFree(self);
- return -1;
- }
-
- ...
-
- /* end of the code that uses the buffers */
-
- GP_TempAllocFree(self);
-
- return 0;
-}
--------------------------------------------------------------------------------
+| link:environment_variables.html[Environment variables] | Environment variables
+|=============================================================================
diff --git a/doc/core.txt b/doc/core_common.txt
similarity index 100%
copy from doc/core.txt
copy to doc/core_common.txt
diff --git a/doc/get_put_pixel.txt b/doc/get_put_pixel.txt
index 3c5e716..86d90c7 100644
--- a/doc/get_put_pixel.txt
+++ b/doc/get_put_pixel.txt
@@ -43,7 +43,7 @@ void GP_PutPixel_Raw_{{ bpp }}(GP_Context *c, GP_Coord x, GP_Coord y,
--------------------------------------------------------------------------------
These functions are generally fast, but does not honour context rotation flags
-and do not check coordinates.
+and do not check that coordinates are inside of the context.
They are intended as basic building blocks for other GFX primitives, filters,
etc.
diff --git a/doc/pixels.txt b/doc/pixels.txt
index d6c18e8..37553c4 100644
--- a/doc/pixels.txt
+++ b/doc/pixels.txt
@@ -10,7 +10,7 @@ Pixel Type
-------------------------------------------------------------------------------
#include <GP.h>
/* or */
-#include <core/GP_Pixel.h>
+#include <core/GP_Pixel.gen.h>
typedef enum GP_PixelType {
GP_PIXEL_UNKNOWN,
@@ -28,14 +28,15 @@ typedef enum GP_PixelType {
/*
* The same values are also defined as macros so it's possible to
- * use them with ifdef as follows.
+ * use them with ifdef as:
+ * #ifdef GP_PIXEL_RGB555
+ * ...
+ * #endif /* GP_PIXEL_RGB555 */
*/
-#ifdef GP_PIXEL_RGB555
-
+#define GP_PIXEL_UNKNOWN GP_PIXEL_UNKNOWN
+#define GP_PIXEL_xRGB8888 GP_PIXEL_xRGB8888
...
-#endif /* GP_PIXEL_RGB555 */
-
-------------------------------------------------------------------------------
Pixels are described by a pixel type, which is enumeration type. The enum is
diff --git a/doc/progress_callback.txt b/doc/progress_callback.txt
index 38719e7..e12dccf 100644
--- a/doc/progress_callback.txt
+++ b/doc/progress_callback.txt
@@ -1,9 +1,6 @@
Progress Callback
-----------------
-Progress Callback
-~~~~~~~~~~~~~~~~~
-
The 'GP_ProgressCallback' is a structure that stores user-defined callback
function and user-defined pointer and percentage.
@@ -11,7 +8,8 @@ It is passed as last parameter to functions that would take some time to
complete and adds capability to track the operation progress as well as to
abort the operation.
-Currently it's used for filters and loaders.
+Currently it's used in link:filters.html[filters] and
+link:loaders.html[loaders].
[source,c]
-------------------------------------------------------------------------------
@@ -22,12 +20,21 @@ typdedef struct GP_ProgressCallback {
} GP_ProgressCallback;
-------------------------------------------------------------------------------
-If non 'NULL' progress callback structure is passed to a function, the
-callback function is periodically called and the percentage is updated.
+The 'callback' pointer is a pointer to user defined callback function.
+
+The 'priv' pointer can be used to pass a pointer to the callback function and
+can accessed inside of the callback by defererencin the 'self' argument.
+
+The 'percentage' field is updated by the function the callback was passed to
+and is increased monotonically till it reaches 100.
+
+If 'non-NULL' progress callback structure is passed to a function, it's called
+periodically and the percentage field is updated.
-The return value from callback could abort the function execution. If non zero
-value is returned operation is aborted, all memory freed etc. and in case of
-bitmap loaders 'errno' is set to 'ECANCELED'.
+The return value from callback could abort the execution. If a non-zero value
+is returned operation is aborted, all memory freed etc., in case of pixmap
+loaders 'errno' is set to 'ECANCELED' and in case of pixmap savers the newly
+created file is removed too.
The callback, if supported, is the last parameter of a function.
http://repo.or.cz/w/gfxprim.git/commit/282b616826f4ad7cfd9c3b804c649e61e56a…
commit 282b616826f4ad7cfd9c3b804c649e61e56a9b32
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Dec 1 19:56:28 2013 +0100
doc: Remove unused pixel_types.txt.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/pixel_types.txt b/doc/pixel_types.txt
deleted file mode 100644
index ee0111c..0000000
--- a/doc/pixel_types.txt
+++ /dev/null
@@ -1,56 +0,0 @@
-Supported pixel sizes
----------------------
-
-The default maximum size of a single pixel is 32 bits. The limitations would
-be analogous for other settings (8, 16 and 64).
-
-Pixel sizes 8, 16 and 32 are supported on all systems and generally very efficient
-(assignment is used for all operations). 24 bpp is supported, but the operations may be
-slightly slower.
-
-Pixel sizes 1, 2 and 4 depend on bit-endian setting and are supported on all systems.
-Subcontext operations and blits may be slower in case of a different subpixel alignment.
-
-Pixel sizes not divisible by 8 and between 9 and 23 depend on the bit endian -
-the endianity of the system must match the bit-endianity. The other combination
-is not supported at all - it would be too complicated and probably very inefficient
-to decode/encode.
-
-Pixel sizes between 25 and 31 are not supported at all, as these pixels might not fit
-into a 32-bit byte-aligned window.
-
-The pixel sizes to be supported must be explicitly listed in the configuration file,
-each including the bit-endian if required (see below).
-
-Supported pixel types
----------------------
-
-The supported files are declared in the configuration file and must use only the declared
-pixel sizes with bit-endians. RGB, monochrome and palette formats are supported,
-all with optional alpha channel (the alpha support level for palette types is not decided yet).
-
-The pixel type
-
-System endianity
-----------------
-
-The library should work on both little-endian and big-endian systems.
-Other variants than the standard (0123 and 3210) are not supported.
-
-In case of pixel sizes between 9 and 23 (except for 16), the system endianity must match the
-selected bit endianity. It is safe to build the library with the disallowed combination
-format, as long as it is not used (compile-time warning is generated).
-
-Bit-endianity
--------------
-
-With 1, 2 and 4 bpp formats, there are two possible orders of pixels within a byte,
-both seen in the wild. The two are enumerated in `GP_BIT_ENDIAN`:
-
-`GP_BIT_ENDIAN_LE`::
- Less significant bits contain pixels with lower indices.
- Also used for irrelevant bit-endian (8, 15, 24, 32bpp).
-`GP_BIT_ENDIAN_BE`::
- More significant bits contain pixels with lower indices.
-
-
http://repo.or.cz/w/gfxprim.git/commit/f63f5aa939d96a4abb0b345470dd7d92ab65…
commit f63f5aa939d96a4abb0b345470dd7d92ab65a360
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Dec 1 19:05:30 2013 +0100
doc: Autogenerate table of all examples + cleanup.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/.gitignore b/doc/.gitignore
index 670b96a..4731cc5 100644
--- a/doc/.gitignore
+++ b/doc/.gitignore
@@ -13,3 +13,5 @@ bit-endian-be-1bit.png
bit-endian-be-2bits.png
bit-endian-le-1bit.png
bit-endian-le-2bits.png
+
+examples.txt
diff --git a/doc/Makefile b/doc/Makefile
index a9121f7..197e81d 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -21,6 +21,7 @@ GENIMAGES=discrete_linear_1D_convolution_alg1 discrete_linear_1D_convolution_alg
PAGES=$(subst .txt,.html,$(SOURCES))
PAGES+=$(subst .txt,.html,$(EXAMPLE_SOURCES))
+PAGES+=examples.html
.PHONY: toolcheck clean
@@ -58,14 +59,18 @@ toolcheck:
$(PAGES): %.html: %.txt
asciidoc $(ASCIIDOC_PARAMS) $<
-examples.html: examples.txt ../demos/c_simple/*.c ../demos/py_simple/*.py asciidoc.conf
- asciidoc $(ASCIIDOC_PARAMS) -a toc examples.txt
+#
+# Autogenerate examples page
+#
+examples.txt: $(EXAMPLE_SOURCES) gen_examples_page.sh
+ ./gen_examples_page.sh examples.txt
#
# Clean up generated images
#
CLEAN+=$(patsubst %,%.md5,$(GENIMAGES))
CLEAN+=$(patsubst %,%.png,$(GENIMAGES))
+CLEAN+=examples.txt
#
# Clean up generated pages
diff --git a/doc/asciidoc.conf b/doc/asciidoc.conf
index 4cc241a..240991d 100644
--- a/doc/asciidoc.conf
+++ b/doc/asciidoc.conf
@@ -45,6 +45,7 @@ ifdef::toc2[<link rel="stylesheet" href="{stylesdir=.}/toc2.css" type="text/css"
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="compilation.html">Compilation</a></li>
+ <li><a href="examples.html">Examples</a></li>
</ul>
C API Pages
<ul>
diff --git a/doc/backends.txt b/doc/backends.txt
index e124cca..46a631a 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -195,7 +195,8 @@ Currently the 'AA-lib' backend uses default initialization parameters.
Way how to pass 'AA-lib' specific parameters will be added. This interface
will likely change.
-Overall init function
+[[Backend_Init]]
+Backend init function
~~~~~~~~~~~~~~~~~~~~~
Although there is no unified backend initialization, there is something close to
@@ -436,6 +437,7 @@ queue and the call returns.
}
-------------------------------------------------------------------------------
+[[Timers]]
GP_BackendAddTimer
^^^^^^^^^^^^^^^^^^
@@ -594,6 +596,7 @@ NOTE: The backend->context pointer may change upon calling this function and
at least backend->context->pixels pointer will change.
+[[ResizeAck]]
GP_BackendResizeAck
^^^^^^^^^^^^^^^^^^^
diff --git a/doc/backends_python.txt b/doc/backends_python.txt
index 65ff893..a5c2206 100644
--- a/doc/backends_python.txt
+++ b/doc/backends_python.txt
@@ -44,7 +44,7 @@ the other hand, has its own input queue.
TIP: See multiple windows link:example_py_x11_windows.html[example].
-
+[[Backend_Init]]
BackendInit
^^^^^^^^^^^
diff --git a/doc/debug.txt b/doc/debug.txt
index aedef2a..83cf91d 100644
--- a/doc/debug.txt
+++ b/doc/debug.txt
@@ -67,7 +67,7 @@ void GP_DebugPrint(int level, const char *file, const char *function, int line,
-------------------------------------------------------------------------------
Printf-like macros used to print debug messages. All of them calls the
-'GP_DebugPrint()' function with slightly parameters.
+'GP_DebugPrint()' function with slightly different parameters.
[source,c]
-------------------------------------------------------------------------------
diff --git a/doc/example_SDL_glue.txt b/doc/example_SDL_glue.txt
index aab453f..804898f 100644
--- a/doc/example_SDL_glue.txt
+++ b/doc/example_SDL_glue.txt
@@ -1,5 +1,5 @@
-SDL Glue Example
-----------------
+SDL Glue
+--------
You can easily mix SDL and GFXprim code using 'GP_ContextFromSDLSurface()'
function.
diff --git a/doc/example_backend.txt b/doc/example_backend.txt
index ed13dea..55e7f16 100644
--- a/doc/example_backend.txt
+++ b/doc/example_backend.txt
@@ -1,5 +1,11 @@
-Graphics Backend Example
-------------------------
+Graphics Backend
+----------------
+This is a very simple backend example that shows how to use
+link:backends.html#Backend_Init[backend init function] and
+link:input.html[input event layer].
+
+It also shows how to handle
+link:backends.html#ResizeAck[window resize events].
[source,c]
------------------------------------------------------------------
diff --git a/doc/example_backend_timers.txt b/doc/example_backend_timers.txt
index e9d479f..ce57a85 100644
--- a/doc/example_backend_timers.txt
+++ b/doc/example_backend_timers.txt
@@ -1,5 +1,6 @@
-Backend Timers Example
-----------------------
+Backend Timers
+--------------
+This example shows how to use link:backends.html#Timers[backend timers].
[source,c]
------------------------------------------------------------------
diff --git a/doc/example_debug_handler.txt b/doc/example_debug_handler.txt
index a859f68..67f28ee 100644
--- a/doc/example_debug_handler.txt
+++ b/doc/example_debug_handler.txt
@@ -1,5 +1,7 @@
-Debug Message Handler Example
------------------------------
+Custom Debug Message Handler
+----------------------------
+This example shows how to redirect link:debug.html[library debug messages]
+into a custom debug message handler.
[source,c]
------------------------------------------------------------------
diff --git a/doc/example_fonts.txt b/doc/example_fonts.txt
index 85a6618..4c4b79b 100644
--- a/doc/example_fonts.txt
+++ b/doc/example_fonts.txt
@@ -1,6 +1,9 @@
-Font Test Example
------------------
-.A simple program to show all font characters with different styles.
+Font and Text rendering
+-----------------------
+
+Fonttest
+~~~~~~~~
+A simple program to show all font characters with different styles.
[source,c]
------------------------------------------------------------------
@@ -8,8 +11,8 @@ include::../demos/c_simple/fonttest.c[]
------------------------------------------------------------------
Fileview
---------
-.A simple program to show contents of a file.
+~~~~~~~~
+A simple program to show contents of a file.
[source,c]
------------------------------------------------------------------
diff --git a/doc/example_gaussian_noise.txt b/doc/example_gaussian_noise.txt
index 1f023d8..95b8a81 100644
--- a/doc/example_gaussian_noise.txt
+++ b/doc/example_gaussian_noise.txt
@@ -1,5 +1,6 @@
-Gaussian Additive Noise Filter Example
---------------------------------------
+Gaussian Additive Noise Filter
+------------------------------
+Simple program that adds a gaussian distributed noise to the image.
[source,c]
------------------------------------------------------------------
diff --git a/doc/example_input.txt b/doc/example_input.txt
index 15b7233..8132a26 100644
--- a/doc/example_input.txt
+++ b/doc/example_input.txt
@@ -1,5 +1,6 @@
-Input Events Example
---------------------
+Input Events Handling
+---------------------
+This example shows how to handle most of the link:input.html[input events].
[source,c]
------------------------------------------------------------------
diff --git a/doc/example_loader_registration.txt b/doc/example_loader_registration.txt
index b287560..fd4f348 100644
--- a/doc/example_loader_registration.txt
+++ b/doc/example_loader_registration.txt
@@ -1,5 +1,10 @@
-Image Loader Registration Example
----------------------------------
+Image Loader Registration
+-------------------------
+This example shows how to
+link:loaders.html#Register_Loader[register custom image loader]
+so that library functions such as
+link:loaders.html#Load_Image[GP_LoadImage()] and
+link:loaders.html#Save_Image[GP_SaveImage()] can use it.
[source,c]
------------------------------------------------------------------
diff --git a/doc/example_loaders_progress_callback.txt b/doc/example_loaders_progress_callback.txt
index 7da5160..6024c74 100644
--- a/doc/example_loaders_progress_callback.txt
+++ b/doc/example_loaders_progress_callback.txt
@@ -1,5 +1,7 @@
-Graphics Backend Example
-------------------------
+Loaders with Progress Callback
+------------------------------
+This example shows how to use link:progress_callback.html[progress callback]
+together with link:loaders.html[image loaders functions].
[source,c]
------------------------------------------------------------------
diff --git a/doc/example_py_backends.txt b/doc/example_py_backends.txt
index 625084c..5ff7213 100644
--- a/doc/example_py_backends.txt
+++ b/doc/example_py_backends.txt
@@ -1,6 +1,7 @@
Backend Init
------------
-.A simple program to demonstrate backend init function.
+A simple program to demonstrate
+link:backends_python.html#Backend_Init[backend init function].
[source,python]
------------------------------------------------------------------
diff --git a/doc/example_py_blur.txt b/doc/example_py_blur.txt
index cfe5577..c8ab4d1 100644
--- a/doc/example_py_blur.txt
+++ b/doc/example_py_blur.txt
@@ -1,6 +1,6 @@
-Gaussian Blur Example
----------------------
-.A simple program that loads image, blurs it and saves result
+Gaussian Blur Filter
+--------------------
+A simple program that loads image, blurs it and saves result.
[source,python]
------------------------------------------------------------------
diff --git a/doc/example_py_convolution.txt b/doc/example_py_convolution.txt
index 0cdfe06..58ee950 100644
--- a/doc/example_py_convolution.txt
+++ b/doc/example_py_convolution.txt
@@ -1,6 +1,6 @@
-Block Blur Convolution Example
-------------------------------
-.A simple program that loads image, blurs it and saves result
+Box Blur Convolution
+--------------------
+A simple program that loads image, blurs it and saves result.
[source,python]
------------------------------------------------------------------
diff --git a/doc/example_py_dithering.txt b/doc/example_py_dithering.txt
index d187c7d..6b3fd9e 100644
--- a/doc/example_py_dithering.txt
+++ b/doc/example_py_dithering.txt
@@ -1,6 +1,6 @@
-Dithering Example
------------------
-.A simple program that loads image, dithers it and saves result
+Floyd-Steinberg Dithering
+-------------------------
+A simple program that loads image, dithers it and saves result.
[source,python]
------------------------------------------------------------------
diff --git a/doc/example_py_gfx.txt b/doc/example_py_gfx.txt
index 2c8854d..4102f96 100644
--- a/doc/example_py_gfx.txt
+++ b/doc/example_py_gfx.txt
@@ -1,6 +1,6 @@
-Gfx
----
-.A simple program to show how to use gfx
+GFX Primitives
+--------------
+A simple program to show how to use most of the graphics primitives.
[source,python]
------------------------------------------------------------------
diff --git a/doc/example_py_showimage.txt b/doc/example_py_showimage.txt
index 10e6e51..608d500 100644
--- a/doc/example_py_showimage.txt
+++ b/doc/example_py_showimage.txt
@@ -1,6 +1,6 @@
Showimage
---------
-.A simple program to load and show image
+A very simple program that loads an image and shows it in a window.
[source,python]
------------------------------------------------------------------
diff --git a/doc/example_py_x11_windows.txt b/doc/example_py_x11_windows.txt
index 7d454a9..d077760 100644
--- a/doc/example_py_x11_windows.txt
+++ b/doc/example_py_x11_windows.txt
@@ -1,6 +1,6 @@
-X11 Windows
------------
-.A simple program to demonstrate multiple windows with X11
+X11 backend with multiple windows
+---------------------------------
+A simple program to demonstrate multiple windows on X11 backend.
[source,python]
------------------------------------------------------------------
diff --git a/doc/example_v4l2.txt b/doc/example_v4l2.txt
index 2f1e389..cfa6de9 100644
--- a/doc/example_v4l2.txt
+++ b/doc/example_v4l2.txt
@@ -1,7 +1,8 @@
-Graphics Backend Example
+Grabbers (v4l2) Examples
------------------------
-Simple grabber that saves images taken from v4l2 device.
+Simple link:grabbers.html[grabber example] that saves images taken from v4l2
+device.
[source,c]
------------------------------------------------------------------
diff --git a/doc/example_x11_windows.txt b/doc/example_x11_windows.txt
index 4e4bb31..a5f0406 100644
--- a/doc/example_x11_windows.txt
+++ b/doc/example_x11_windows.txt
@@ -1,6 +1,6 @@
-Graphics Backend Example
-------------------------
-.An example how to create and manage two windows using the X11 backend
+X11 Backend with multiple windows
+---------------------------------
+This example shows how to create multiple X11 windows.
[source,c]
------------------------------------------------------------------
diff --git a/doc/examples.txt b/doc/examples.txt
index 0f6566b..d96b7f8 100644
--- a/doc/examples.txt
+++ b/doc/examples.txt
@@ -1,122 +1,38 @@
-Image loaders examples
-----------------------
-
-Loads an image and saves it into 'out.png' png image.
-
-Example in C
-~~~~~~~~~~~~
-
-[source,c]
-------------------------------------------------------------------
-include::../demos/c_simple/loaders_example.c[]
-------------------------------------------------------------------
-
-Example in C utilizing progress callback
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-[source,c]
-------------------------------------------------------------------
-include::../demos/c_simple/loaders.c[]
-------------------------------------------------------------------
-
-Example in C using image meta-data interface
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-[source,c]
-------------------------------------------------------------------
-include::../demos/c_simple/meta_data.c[]
-------------------------------------------------------------------
-
-[source,c]
-------------------------------------------------------------------
-include::../demos/c_simple/meta_data_dump.c[]
-------------------------------------------------------------------
-
-Example in Python
-~~~~~~~~~~~~~~~~~
-
-[source,python]
-------------------------------------------------------------------
-include::../demos/py_simple/loaders_example.py[]
-------------------------------------------------------------------
-
-GFX Examples
-------------
-
-Drawing Lines
-~~~~~~~~~~~~~
-
-Example in C
-^^^^^^^^^^^^
-
-[source,c]
-------------------------------------------------------------------
-include::../demos/c_simple/gfx_koch.c[]
-------------------------------------------------------------------
-
-Filters
--------
-
-Symmetry filters (Rotation, Mirroring)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Example in C
-^^^^^^^^^^^^
-
-[source,c]
-------------------------------------------------------------------
-include::../demos/c_simple/filters_symmetry.c[]
-------------------------------------------------------------------
-
-Example in Python
-^^^^^^^^^^^^^^^^^
-
-[source,python]
-------------------------------------------------------------------
-include::../demos/py_simple/rotate90.py[]
-------------------------------------------------------------------
-
-Simple backend example
-----------------------
-
-Basic backend code example. Initalizes backends, draws a cross and dumps
-events.
-
-Example in C
-~~~~~~~~~~~~
-
-[source,c]
-------------------------------------------------------------------
-include::../demos/c_simple/backend_example.c[]
-------------------------------------------------------------------
-
-[source,c]
-------------------------------------------------------------------
-include::../demos/c_simple/showimage.c[]
-------------------------------------------------------------------
-
-Grabbers
---------
-
-Simple C source that saves JPEG images from V4L2 device (web camera).
-
-[source,c]
-------------------------------------------------------------------
-include::../demos/c_simple/v4l2_grab.c[]
-------------------------------------------------------------------
-
-Simple C source that shows filters interactively on image stream from a
-camera.
-
-[source,c]
-------------------------------------------------------------------
-include::../demos/c_simple/v4l2_show.c[]
-------------------------------------------------------------------
-
-GFXprim + PyGTK
----------------
-
-[source,python]
-------------------------------------------------------------------
-include::../demos/py_simple/pygtk_example.py[]
-------------------------------------------------------------------
+List of examples
+----------------
+Following pages contains a list of all code examples, the source
+files could be found and are compiled in the +demos/c_simple/+ and
++demos/py_simple+ directories in the source tree.
+
+.List C examples
+[grid="rows"]
+[options="autowidth,header",cols="<,<m"]
+|===========================
+| Example | Source filename(s)
+| link:example_SDL_glue.html[SDL Glue] | SDL_glue.c
+| link:example_backend.html[Graphics Backend] | backend_example.c
+| link:example_backend_timers.html[Backend Timers] | backend_timers_example.c
+| link:example_debug_handler.html[Custom Debug Message Handler] | debug_handler.c
+| link:example_fonts.html[Font and Text rendering] | fonttest.c
+fileview.c
+| link:example_gaussian_noise.html[Gaussian Additive Noise Filter] | gaussian_noise.c
+| link:example_input.html[Input Events Handling] | input_example.c
+| link:example_loader_registration.html[Image Loader Registration] | loaders_register.c
+| link:example_loaders_progress_callback.html[Loaders with Progress Callback] | loaders.c
+| link:example_v4l2.html[Grabbers (v4l2) Examples] | v4l2_grab.c
+v4l2_show.c
+| link:example_x11_windows.html[X11 Backend with multiple windows] | x11_windows.c
+|===========================
+.List Python examples
+[grid="rows"]
+[options="autowidth,header",cols="<,<m"]
+|===========================
+| Example | Source filename(s)
+| link:example_py_backends.html[Backend Init] | backends.py
+| link:example_py_blur.html[Gaussian Blur Filter] | blur.py
+| link:example_py_convolution.html[Box Blur Convolution] | convolution.py
+| link:example_py_dithering.html[Floyd-Steinberg Dithering] | dither.py
+| link:example_py_gfx.html[GFX Primitives] | gfx.py
+| link:example_py_showimage.html[Showimage] | showimage.py
+| link:example_py_x11_windows.html[X11 backend with multiple windows] | x11_windows.py
+|===========================
diff --git a/doc/gen_examples_page.sh b/doc/gen_examples_page.sh
new file mode 100755
index 0000000..eb94a4d
--- /dev/null
+++ b/doc/gen_examples_page.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# Autogenerate examples page
+#
+OUT="$1"
+
+get_names()
+{
+ LINKS=$(grep 'include:.*' $1)
+ NAMES=$(echo $LINKS | sed 's/include:://g' | sed 's/[]//g')
+ for i in $NAMES; do
+ echo $(basename $i)
+ done
+}
+
+table_header()
+{
+ echo ".List $1 examples" >> $OUT
+ echo "[grid="rows"]" >> $OUT
+ echo '[options="autowidth,header",cols="<,<m"]' >> $OUT
+ echo "|===========================" >> $OUT
+ echo "| Example | Source filename(s)" >> $OUT
+}
+
+table_footer()
+{
+ echo "|===========================" >> $OUT
+}
+
+echo "List of examples" > $OUT
+echo "----------------" >> $OUT
+echo "Following pages contains a list of all code examples, the source " >> $OUT
+echo "files could be found and are compiled in the +demos/c_simple/+ and" >> $OUT
+echo "+demos/py_simple+ directories in the source tree." >> $OUT
+echo >> $OUT
+
+table_header "C"
+for i in example_*.txt; do
+ LINK=$(echo $i | sed s/.txt/.html/)
+ DESC=$(head -n 1 $i)
+ FNAMES=$(get_names "$i")
+ if $(echo $i | grep -q '_py_'); then
+ continue
+ fi
+ echo "| link:$LINK[$DESC] | $FNAMES" >> $OUT
+done
+table_footer
+
+table_header "Python"
+for i in example_py_*.txt; do
+ LINK=$(echo $i | sed s/.txt/.html/)
+ DESC=$(head -n 1 $i)
+ FNAMES=$(get_names "$i")
+ echo "| link:$LINK[$DESC] | $FNAMES" >> $OUT
+done
+table_footer
diff --git a/doc/loaders.txt b/doc/loaders.txt
index 3b8e283..b42c47e 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -8,8 +8,8 @@ saving and GIF, JPEG2000 and PSP for loading.
Have a look at the link:about.html#Loaders[supported formats].
-Loaders API
-~~~~~~~~~~~
+Image Loaders and Savers
+~~~~~~~~~~~~~~~~~~~~~~~~
All loading functions returns a pointer to allocated and loaded image or upon
a failure 'NULL'.
@@ -18,12 +18,10 @@ All saving functions returns zero on success and non-zero on failure. If
image saving is aborted by a callback, the opened file is closed and removed
from a filesystem before the call returns.
-In case of a failure 'errno' is set.
-
The signature matching functions takes a 32 bytes long buffer and looks for a
-valid image signature. If signature is found 1 is returned.
+valid image signature. If signature is found non-zero is returned.
-The possible 'errno' values are:
+In case of a failure 'errno' is set, possible 'errno' values are:
* anything returned by +open()+, +close()+, +lseek()+, +read()+, +write()+, ...
- 'ENOENT' if file doesn't exist
@@ -38,9 +36,8 @@ The possible 'errno' values are:
You can get more information about the error condition by turning on GFXprim
link:environment_variables.html#GP_DEBUG[debug messages].
-Image Loader
-~~~~~~~~~~~~
+[[Load_Image]]
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_Loader.h>
@@ -66,6 +63,7 @@ is returned.
If file extension disagrees with file signature on the file format a warning
is printed into the 'stderr'.
+[[Save_Image]]
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_Loader.h>
@@ -89,8 +87,9 @@ wasn't compiled with support for this image type).
If context pixel type is not supported by the format 'errno' is set to
'EINVAL'.
-Advanced usage
-^^^^^^^^^^^^^^
+[[Register_Loader]]
+Advanced Loaders usage
+^^^^^^^^^^^^^^^^^^^^^^
[source,c]
-------------------------------------------------------------------------------
@@ -161,10 +160,10 @@ extensions that are commonly used for this image format.
All internal loaders are all described in list of this structures which is
used to implement functions such as 'GP_LoadImage()'.
-You can print currently active loaders via the 'GP_ListLoaders()' register and
+You can print currently active loaders via the 'GP_ListLoaders()'. Register and
unregister your own loaders by 'GP_LoaderRegister()' and
'GP_LoaderUnregister()'. Once image loader is registered the generic loading
-functions could use it to load and save images.
+functions can use it to load and save images.
TIP: For example usage see image loader registration
link:example_loader_registration.html[example].
-----------------------------------------------------------------------
Summary of changes:
doc/.gitignore | 2 +
doc/Makefile | 11 ++-
doc/asciidoc.conf | 2 +
doc/backends.txt | 5 +-
doc/backends_python.txt | 2 +-
doc/context.txt | 33 ++++--
doc/core.txt | 167 ++++++-----------------------
doc/{core.txt => core_common.txt} | 0
doc/debug.txt | 2 +-
doc/example_SDL_glue.txt | 4 +-
doc/example_backend.txt | 10 ++-
doc/example_backend_timers.txt | 5 +-
doc/example_debug_handler.txt | 6 +-
doc/example_fonts.txt | 13 ++-
doc/example_gaussian_noise.txt | 5 +-
doc/example_input.txt | 5 +-
doc/example_loader_registration.txt | 9 ++-
doc/example_loaders_progress_callback.txt | 6 +-
doc/example_py_backends.txt | 3 +-
doc/example_py_blur.txt | 6 +-
doc/example_py_convolution.txt | 6 +-
doc/example_py_dithering.txt | 6 +-
doc/example_py_gfx.txt | 6 +-
doc/example_py_showimage.txt | 2 +-
doc/example_py_x11_windows.txt | 6 +-
doc/example_v4l2.txt | 5 +-
doc/example_x11_windows.txt | 6 +-
doc/examples.txt | 160 +++++++---------------------
doc/gen_examples_page.sh | 56 ++++++++++
doc/get_put_pixel.txt | 2 +-
doc/loaders.txt | 23 ++--
doc/pixel_types.txt | 56 ----------
doc/pixels.txt | 13 ++-
doc/progress_callback.txt | 25 +++--
34 files changed, 271 insertions(+), 397 deletions(-)
copy doc/{core.txt => core_common.txt} (100%)
create mode 100755 doc/gen_examples_page.sh
delete mode 100644 doc/pixel_types.txt
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
28 Nov '13
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 2600399e7b0b62f90f89278758e619402535d74d (commit)
via 240ca18152614d80a0709a7e41d64eed47c65379 (commit)
via 8af66ccd14cac2c8a95560762f40508fc2a7ccf7 (commit)
via 68e27f7a81d3c0e89c04b8857edcb6189027f0d1 (commit)
via bd1b371f5447999c61281bc1bdf654ae42bfe05e (commit)
from 757febd5664bc013d3568d5faec50e4f8de74de8 (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/2600399e7b0b62f90f89278758e619402535…
commit 2600399e7b0b62f90f89278758e619402535d74d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Nov 28 23:13:50 2013 +0100
build: Fix configure && install.
Make correct use of --prefix and DESTDIR.
Reported-by: Milan Vancura <milan(a)ucw.cz>
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/configure b/configure
index 2e8164b..ac35338 100755
--- a/configure
+++ b/configure
@@ -116,7 +116,7 @@ class libraries:
sys.stderr.write("----------------------n")
for i in cfg:
- sys.stderr.write("%14s : %sn" % (i, cfg[i][0]))
+ sys.stderr.write("%14s : '%s'n" % (i, cfg[i][0]))
sys.stderr.write(" - %snn" % cfg[i][1])
sys.stderr.write("Libraries to link againstn")
@@ -227,10 +227,10 @@ def basic_checks(cfg):
if cfg['libdir'][0] == '':
sys.stderr.write("Checking for lib directory ... ")
- if os.path.isdir(cfg['prefix'][0] + '/usr/lib64'):
- cfg['libdir'][0] = '/usr/lib64'
+ if os.path.isdir('/usr/lib64'):
+ cfg['libdir'][0] = 'lib64'
else:
- cfg['libdir'][0] = '/usr/lib'
+ cfg['libdir'][0] = 'lib'
sys.stderr.write(cfg['libdir'][0] + 'n');
@@ -308,12 +308,12 @@ if __name__ == '__main__':
'SWIG' : ['swig', 'Simplified Wrapper and Interface Generator'],
'PYTHON_CONFIG' : ['python-config', 'Python config helper'],
'PYTHON_VER' : ['', 'Python version (derived from python config)'],
- 'include_path' : ['/usr/include', 'Path to the system headers'],
- 'prefix' : ['', 'Installation prefix'],
- 'bindir' : ['/usr/bin', 'Where to install binaries'],
- 'libdir' : ['', 'Where to install libraries'],
- 'includedir' : ['/usr/include', 'Where to install headers'],
- 'mandir' : ['/usr/share/man', 'Where to install man pages']}
+ 'include_path' : ['/usr/include', 'Path to the system headers'],
+ 'prefix' : ['/usr/local/', 'Installation prefix'],
+ 'bindir' : ['bin', 'Where to install binaries'],
+ 'libdir' : ['', 'Where to install libraries'],
+ 'includedir' : ['include', 'Where to install headers'],
+ 'mandir' : ['share/man', 'Where to install man pages']}
#
# Library detection/enable disable
@@ -333,36 +333,36 @@ if __name__ == '__main__':
"An open-source JPEG 2000 library",
[header_exists, "openjpeg-2.0/openjpeg.h"], "", "-lopenjp2", ["loaders"]],
["giflib",
- "Library to handle, display and manipulate GIF images",
- [header_exists, "gif_lib.h"], "", "-lgif", ["loaders"]],
+ "Library to handle, display and manipulate GIF images",
+ [header_exists, "gif_lib.h"], "", "-lgif", ["loaders"]],
["tiff",
- "Tag Image File Format (TIFF) library",
- [header_exists, "tiffio.h"], "", "-ltiff", ["loaders"]],
+ "Tag Image File Format (TIFF) library",
+ [header_exists, "tiffio.h"], "", "-ltiff", ["loaders"]],
["zlib",
- "Standard (de)compression library",
- [header_exists, "zlib.h"], "", "-lz", ["loaders"]],
- ["libX11",
- "X11 library",
- [header_exists, "X11/Xlib.h"], "", "-lX11", ["backends"]],
+ "Standard (de)compression library",
+ [header_exists, "zlib.h"], "", "-lz", ["loaders"]],
+ ["libX11",
+ "X11 library",
+ [header_exists, "X11/Xlib.h"], "", "-lX11", ["backends"]],
["X_SHM",
- "MIT-SHM X Extension",
- [header_exists, "X11/extensions/XShm.h"], "", "-lXext", ["backends"]],
- ["aalib",
- "Portable ascii art GFX library",
- [header_exists, "aalib.h"], "", "-laa", ["backends"]],
- ["freetype",
+ "MIT-SHM X Extension",
+ [header_exists, "X11/extensions/XShm.h"], "", "-lXext", ["backends"]],
+ ["aalib",
+ "Portable ascii art GFX library",
+ [header_exists, "aalib.h"], "", "-laa", ["backends"]],
+ ["freetype",
"A high-quality and portable font engine",
[header_exists, "ft2build.h"], "", "`freetype-config --libs`", ["core"]],
- ["dl",
+ ["dl",
"Dynamic linker",
[header_exists, "dlfcn.h"], "", "-ldl", ["core"]],
- ["V4L2",
+ ["V4L2",
"Video for linux 2",
[header_exists, "linux/videodev2.h"], "", "", ["grabbers"]],
- ["pthread",
+ ["pthread",
"Posix Threads",
[header_exists, "pthread.h"], "-pthread", "-pthread", ["core"]],
- ["backtrace",
+ ["backtrace",
"C stack trace writeout",
[c_try_compile, "#include <execinfo.h>nint main(void) { backtrace(0, 0); }",
"Checking for backtrace() ... "], "", "", ["core"]]], cfg)
@@ -398,7 +398,7 @@ if __name__ == '__main__':
l.set(i, False);
for i in cfg:
- if getattr(options, i):
+ if getattr(options, i) is not None:
cfg[i][0] = getattr(options, i)
basic_checks(cfg);
diff --git a/install.mk b/install.mk
index 689acda..991247a 100644
--- a/install.mk
+++ b/install.mk
@@ -1,13 +1,13 @@
ifdef DESTDIR
-BIN_DIR=$(DESTDIR)$(bindir)
+BIN_DIR=$(DESTDIR)$(prefix)/$(bindir)
else
-BIN_DIR=$(bindir)
+BIN_DIR=$(prefix)/$(bindir)
endif
ifdef DESTDIR
-MAN_DIR=$(DESTDIR)$(mandir)/man1
+MAN_DIR=$(DESTDIR)$(prefix)/$(mandir)/man1
else
-MAN_DIR=$(mandir)/man1
+MAN_DIR=$(prefix)/$(mandir)/man1
endif
install:
@@ -18,7 +18,7 @@ ifdef VERBOSE
else
@install -d "$(BIN_DIR)"
@echo "MKDIR $(BIN_DIR)"
- @for i in $(INSTALL_BIN); do echo "CP $$i $(MAN_DIR)"; install "$$i" "$(BIN_DIR)"; done
+ @for i in $(INSTALL_BIN); do echo "CP $$i $(BIN_DIR)"; install "$$i" "$(BIN_DIR)"; done
endif
endif
diff --git a/install.sh b/install.sh
index 14c9835..a0f8d83 100755
--- a/install.sh
+++ b/install.sh
@@ -5,9 +5,9 @@ LIBDIR="$2"
BINDIR="$3"
INCLUDEDIR="$4"
-HEADER_LOC="$PREFIX/$INCLUDEDIR"
-LIB_LOC="$PREFIX/$LIBDIR"
-BIN_LOC="$PREFIX/$BINDIR"
+HEADER_LOC="${DESTDIR}$PREFIX/$INCLUDEDIR"
+LIB_LOC="${DESTDIR}$PREFIX/$LIBDIR"
+BIN_LOC="${DESTDIR}$PREFIX/$BINDIR"
# Headers
echo "INSTALL headers ($HEADER_LOC)"
@@ -18,13 +18,15 @@ for i in `ls include/`; do
install -m 775 -d "${HEADER_LOC}/GP/$i"
install -m 664 "include/$i/"*.h "${HEADER_LOC}/GP/$i"
else
- install -m 664 "include/$i" "${HEADER_LOC}/GP/$i"
+ if [ "$i" != "Makefile" ]; then
+ install -m 664 "include/$i" "${HEADER_LOC}/GP/$i"
+ fi
fi
done
# Library
echo "INSTALL libraries ($LIB_LOC)"
-install -m 775 -d "$LIB_LOC"
+install -m 775 -d "$LIB_LOC"
for i in build/*.so build/*.so.* build/*.a; do
if [ -L "$i" ]; then
http://repo.or.cz/w/gfxprim.git/commit/240ca18152614d80a0709a7e41d64eed47c6…
commit 240ca18152614d80a0709a7e41d64eed47c65379
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Nov 28 22:44:39 2013 +0100
loaders: ZIP: Fix loading from mixed content zips
* Fix loading from ZIP files with mixed content
(the loader wrongy aborted on unknown stored
file due to wrong error propagation)
* Prepare for end-of-archive detection
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c
index d8e20b5..c64214e 100644
--- a/libs/loaders/GP_ZIP.c
+++ b/libs/loaders/GP_ZIP.c
@@ -275,16 +275,37 @@ err0:
static int zip_load_header(FILE *f, struct zip_local_header *header)
{
- int ret;
+ int ret, ch;
+
+ ret = GP_FRead(f, "0x50 0x4b");
- //TODO: check for central directory signature -> end of data
+ if (ret != 2) {
+ GP_DEBUG(1, "Failed to read header");
+ return EIO;
+ }
+
+ ch = fgetc(f);
+
+ switch (ch) {
+ /* Central directory -> end of archive */
+ case 0x01:
+ GP_DEBUG(1, "Reached end of the archive");
+ return EINVAL;
+ break;
+ /* File header */
+ case 0x03:
+ break;
+ default:
+ GP_DEBUG(1, "Unexpected header PK%x", ch);
+ return EIO;
+ }
- ret = GP_FRead(f, "0x50 0x4b 0x03 0x04 L2 L2 L2 I4 L4 L4 L4 L2 L2",
+ ret = GP_FRead(f, "0x04 L2 L2 L2 I4 L4 L4 L4 L2 L2",
&header->ver, &header->bit_flags, &header->comp_type,
&header->crc, &header->comp_size, &header->uncomp_size,
&header->fname_len, &header->extf_len);
- if (ret != 13) {
+ if (ret != 10) {
GP_DEBUG(1, "Failed to read header");
return EIO;
}
@@ -355,12 +376,15 @@ static GP_Context *zip_next_file(FILE *f, GP_ProgressCallback *callback)
ret = GP_ReadPNG(f, callback);
}
+ fseek(f, cur_off + header.comp_size, SEEK_SET);
+
goto out;
break;
case COMPRESS_DEFLATE:
- if (read_deflate(f, &header, &fres))
+ if (read_deflate(f, &header, &fres)) {
+ err = errno;
goto out;
-
+ }
ret = GP_ReadJPG(fres, callback);
@@ -369,9 +393,6 @@ static GP_Context *zip_next_file(FILE *f, GP_ProgressCallback *callback)
ret = GP_ReadPNG(fres, callback);
}
- if (!ret)
- err = errno;
-
fclose(fres);
goto out;
break;
@@ -512,7 +533,6 @@ static int load_next_offset(struct zip_priv *priv)
int ret;
long offset = ftell(priv->f);
- //TODO: End of file!
if ((ret = zip_load_header(priv->f, &header)))
return ret;
http://repo.or.cz/w/gfxprim.git/commit/8af66ccd14cac2c8a95560762f40508fc2a7…
commit 8af66ccd14cac2c8a95560762f40508fc2a7ccf7
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Nov 28 22:10:47 2013 +0100
tests: loaders: ZIP: Two more testcases.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/loaders/ZIP.c b/tests/loaders/ZIP.c
index c7f9e05..35dded8 100644
--- a/tests/loaders/ZIP.c
+++ b/tests/loaders/ZIP.c
@@ -76,6 +76,43 @@ struct test jpeg_stored = {
.path = "jpeg_stored.zip"
};
+struct test mixed_content = {
+ .w = 100,
+ .h = 100,
+ .path = "mixed_content.zip"
+};
+
+/*
+ * Test ZIP with no images, we expect to get NULL with errno set to zero
+ */
+static int no_images(const char *path)
+{
+ GP_Container *zip = GP_OpenZip(path);
+ GP_Context *img;
+ int ret = TST_SUCCESS;
+
+ if (!zip) {
+ tst_msg("Failed to open zip");
+ return TST_FAILED;
+ }
+
+ img = GP_ContainerLoad(zip, NULL);
+
+ if (img) {
+ tst_msg("Loaded image from zip without images");
+ ret = TST_FAILED;
+ }
+
+ if (errno) {
+ tst_msg("Get errno %d (%s)", errno, strerror(errno));
+ ret = TST_FAILED;
+ }
+
+ GP_ContainerClose(zip);
+
+ return ret;
+}
+
const struct tst_suite tst_suite = {
.suite_name = "ZIP",
.tests = {
@@ -91,6 +128,18 @@ const struct tst_suite tst_suite = {
.data = &jpeg_stored,
.flags = TST_TMPDIR | TST_MALLOC_CANARIES},
+ {.name = "Load JPEG is second file in ZIP",
+ .tst_fn = test_load,
+ .res_path = "data/zip/valid/mixed_content.zip",
+ .data = &mixed_content,
+ .flags = TST_TMPDIR | TST_MALLOC_CANARIES},
+
+ {.name = "Load ZIP with no images",
+ .tst_fn = no_images,
+ .res_path = "data/zip/valid/no_images.zip",
+ .data = "no_images.zip",
+ .flags = TST_TMPDIR | TST_MALLOC_CANARIES},
+
{.name = NULL},
}
};
diff --git a/tests/loaders/data/zip/valid/mixed_content.zip b/tests/loaders/data/zip/valid/mixed_content.zip
new file mode 100644
index 0000000..946db63
Binary files /dev/null and b/tests/loaders/data/zip/valid/mixed_content.zip differ
diff --git a/tests/loaders/data/zip/valid/no_images.zip b/tests/loaders/data/zip/valid/no_images.zip
new file mode 100644
index 0000000..ac5fcfc
Binary files /dev/null and b/tests/loaders/data/zip/valid/no_images.zip differ
http://repo.or.cz/w/gfxprim.git/commit/68e27f7a81d3c0e89c04b8857edcb6189027…
commit 68e27f7a81d3c0e89c04b8857edcb6189027f0d1
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Nov 28 20:04:26 2013 +0100
loaders: ZIP: Fix memory leak in deflate decompression
Add forgotten deinitializaiton for the deflate decompression.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c
index 794d794..d8e20b5 100644
--- a/libs/loaders/GP_ZIP.c
+++ b/libs/loaders/GP_ZIP.c
@@ -258,6 +258,9 @@ static int read_deflate(FILE *f, struct zip_local_header *header, FILE **res_f)
goto err2;
}
+ inflateBackEnd(&strm);
+ free(window);
+
rewind(tf);
*res_f = tf;
return 0;
http://repo.or.cz/w/gfxprim.git/commit/bd1b371f5447999c61281bc1bdf654ae42bf…
commit bd1b371f5447999c61281bc1bdf654ae42bfe05e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Nov 28 20:03:11 2013 +0100
tests: loaders: Add basic test for ZIP container.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile
index 66edb90..a592ff9 100644
--- a/tests/loaders/Makefile
+++ b/tests/loaders/Makefile
@@ -1,10 +1,10 @@
TOPDIR=../..
include $(TOPDIR)/pre.mk
-CSOURCES=loaders_suite.c PNG.c PBM.c PGM.c PPM.c
+CSOURCES=loaders_suite.c PNG.c PBM.c PGM.c PPM.c ZIP.c
GENSOURCES=SaveLoad.gen.c SaveAbort.gen.c
-APPS=loaders_suite PNG PBM PGM PPM SaveLoad.gen SaveAbort.gen
+APPS=loaders_suite PNG PBM PGM PPM SaveLoad.gen SaveAbort.gen ZIP
include ../tests.mk
diff --git a/tests/loaders/ZIP.c b/tests/loaders/ZIP.c
new file mode 100644
index 0000000..c7f9e05
--- /dev/null
+++ b/tests/loaders/ZIP.c
@@ -0,0 +1,96 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include <core/GP_Context.h>
+#include <loaders/GP_Loaders.h>
+
+#include "tst_test.h"
+
+struct test {
+ GP_Size w, h;
+ const char *path;
+};
+
+static int test_load(struct test *test)
+{
+ GP_Container *zip = GP_OpenZip(test->path);
+ GP_Context *img;
+ int ret = TST_SUCCESS;
+
+ if (!zip) {
+ tst_msg("Failed to open zip");
+ return TST_FAILED;
+ }
+
+ img = GP_ContainerLoad(zip, NULL);
+
+ if (!img) {
+ tst_msg("Failed to load image");
+ return TST_FAILED;
+ }
+
+ if (img->w != test->w || img->h != test->h) {
+ tst_msg("Image has wrong size, expected %ux%u have %ux%u",
+ test->w, test->h, img->w, img->h);
+ ret = TST_FAILED;
+ }
+
+ GP_ContextFree(img);
+ GP_ContainerClose(zip);
+
+ return ret;
+}
+
+struct test jpeg_deflated = {
+ .w = 100,
+ .h = 100,
+ .path = "jpeg_deflated.zip"
+};
+
+struct test jpeg_stored = {
+ .w = 100,
+ .h = 100,
+ .path = "jpeg_stored.zip"
+};
+
+const struct tst_suite tst_suite = {
+ .suite_name = "ZIP",
+ .tests = {
+ {.name = "Load JPEG deflated in ZIP",
+ .tst_fn = test_load,
+ .res_path = "data/zip/valid/jpeg_deflated.zip",
+ .data = &jpeg_deflated,
+ .flags = TST_TMPDIR | TST_MALLOC_CANARIES},
+
+ {.name = "Load JPEG stored in ZIP",
+ .tst_fn = test_load,
+ .res_path = "data/zip/valid/jpeg_stored.zip",
+ .data = &jpeg_stored,
+ .flags = TST_TMPDIR | TST_MALLOC_CANARIES},
+
+ {.name = NULL},
+ }
+};
diff --git a/tests/loaders/data/zip/valid/jpeg_deflated.zip b/tests/loaders/data/zip/valid/jpeg_deflated.zip
new file mode 100644
index 0000000..7a84e36
Binary files /dev/null and b/tests/loaders/data/zip/valid/jpeg_deflated.zip differ
diff --git a/tests/loaders/data/zip/valid/jpeg_stored.zip b/tests/loaders/data/zip/valid/jpeg_stored.zip
new file mode 100644
index 0000000..eceb6c0
Binary files /dev/null and b/tests/loaders/data/zip/valid/jpeg_stored.zip differ
diff --git a/tests/loaders/test_list.txt b/tests/loaders/test_list.txt
index 162943e..9f52d34 100644
--- a/tests/loaders/test_list.txt
+++ b/tests/loaders/test_list.txt
@@ -4,5 +4,6 @@ PNG
PBM
PGM
PPM
+ZIP
SaveLoad.gen
SaveAbort.gen
-----------------------------------------------------------------------
Summary of changes:
configure | 60 +++++-----
install.mk | 10 +-
install.sh | 12 +-
libs/loaders/GP_ZIP.c | 43 +++++--
tests/loaders/Makefile | 4 +-
tests/loaders/{SaveLoad.gen.c.t => ZIP.c} | 161 +++++++++++++-----------
tests/loaders/data/zip/valid/jpeg_deflated.zip | Bin 0 -> 384 bytes
tests/loaders/data/zip/valid/jpeg_stored.zip | Bin 0 -> 564 bytes
tests/loaders/data/zip/valid/mixed_content.zip | Bin 0 -> 549 bytes
tests/loaders/data/zip/valid/no_images.zip | Bin 0 -> 363 bytes
tests/loaders/test_list.txt | 1 +
11 files changed, 163 insertions(+), 128 deletions(-)
copy tests/loaders/{SaveLoad.gen.c.t => ZIP.c} (50%)
create mode 100644 tests/loaders/data/zip/valid/jpeg_deflated.zip
create mode 100644 tests/loaders/data/zip/valid/jpeg_stored.zip
create mode 100644 tests/loaders/data/zip/valid/mixed_content.zip
create mode 100644 tests/loaders/data/zip/valid/no_images.zip
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
23 Nov '13
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 757febd5664bc013d3568d5faec50e4f8de74de8 (commit)
via 55a42a3b2e7dedc7c26c2db9a5333904a601f13c (commit)
from f4a9af195d3e128c3752825a1b568d32f9c1bfc8 (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/757febd5664bc013d3568d5faec50e4f8de7…
commit 757febd5664bc013d3568d5faec50e4f8de74de8
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 23 11:06:01 2013 +0100
spiv: Fix help for arrow keys.
It's 10px by default and 1px with shift not the other way around.
Reported-by: Milan Vancura <milan(a)ucw.cz>
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c
index b3d25da..72be0bc 100644
--- a/demos/spiv/spiv_help.c
+++ b/demos/spiv/spiv_help.c
@@ -64,10 +64,10 @@ static struct key_help help_keys[] = {
{"Shift 2", "Resize twice of the image size"},
{"Shift 3", "Resize three times of the image size"},
{"...", ""},
- {"Up", "Move image by 1px up (by 10 with Shift)"},
- {"Down", "Move image by 1px down (by 10 with Shift)"},
- {"Left", "Move image by 1px left (by 10 with Shift)"},
- {"Right", "Move image by 1px right (by 10 with Shift)"},
+ {"Up", "Move image by 10px up (by 1 with Shift)"},
+ {"Down", "Move image by 10px down (by 1 with Shift)"},
+ {"Left", "Move image by 10px left (by 1 with Shift)"},
+ {"Right", "Move image by 10px right (by 1 with Shift)"},
{"", ""},
{"]", "Change to next resampling method"},
{"[", "Change to prev resampling method"},
http://repo.or.cz/w/gfxprim.git/commit/55a42a3b2e7dedc7c26c2db9a5333904a601…
commit 55a42a3b2e7dedc7c26c2db9a5333904a601f13c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Nov 18 20:19:47 2013 +0100
spiv: Fix action index in image_action_run().
Action parameters are indexed from one not zero.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 428e5ea..74a45a4 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -1016,7 +1016,7 @@ int main(int argc, char *argv[])
zoom_mul(¶ms, 1/1.5);
break;
case GP_KEY_F1 ... GP_KEY_F10:
- image_action_run(ev.val.key.key - GP_KEY_F1,
+ image_action_run(ev.val.key.key - GP_KEY_F1 + 1,
image_loader_img_path());
break;
}
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 2 +-
demos/spiv/spiv_help.c | 8 ++++----
2 files changed, 5 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
17 Nov '13
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 f4a9af195d3e128c3752825a1b568d32f9c1bfc8 (commit)
via 671e87281d1facd1b67e02eb4ec22ec918be719e (commit)
via 02e619a972aa0b3c53fab8c2ae0863f8335c5d9f (commit)
via f75a8c4a88ce2805d3a6879e956945248dd5b075 (commit)
via 04c28a7494aa96256e17537a97cc7fb78254a6f2 (commit)
via d85d6ad1a7f73a6b37e5bc322daa26bf15453f71 (commit)
via 54c4a75afdc2cae3b7e3dea64cff7ee29696d321 (commit)
via 309a7bbfdc215e46a9e5a4782d13e6be20b374d5 (commit)
via d6f5b7524dee82c9886c2605247d72991ee71840 (commit)
from a38bd31917407a2fd2b4054c51f6421c2d79654f (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/f4a9af195d3e128c3752825a1b568d32f9c1…
commit f4a9af195d3e128c3752825a1b568d32f9c1bfc8
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 16 16:42:04 2013 +0100
loaders: PNM: Fix save_ascii_rgb888
The pointers should be incremented after we safe first pixel, not
before.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c
index 7e28f1b..de81c4b 100644
--- a/libs/loaders/GP_PNM.c
+++ b/libs/loaders/GP_PNM.c
@@ -990,14 +990,14 @@ static int save_ascii_rgb888(FILE *f, const GP_Context *ctx,
}
for (x = 0; x < ctx->w; x++) {
- addr+=3;
-
ret |= write_ascii_byte(f, addr[2]);
ret |= write_ascii_byte(f, addr[1]);
ret |= write_ascii_byte(f, addr[0]);
if (ret)
return errno;
+
+ addr+=3;
}
if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) {
http://repo.or.cz/w/gfxprim.git/commit/671e87281d1facd1b67e02eb4ec22ec918be…
commit 671e87281d1facd1b67e02eb4ec22ec918be719e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 16 16:43:26 2013 +0100
tests: loaders: Enable malloc canaries for SaveLoad
The PNG and TIFF loaders segfaults for currently unknown reasons.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/loaders/SaveLoad.gen.c.t b/tests/loaders/SaveLoad.gen.c.t
index 81478c0..6daac8b 100644
--- a/tests/loaders/SaveLoad.gen.c.t
+++ b/tests/loaders/SaveLoad.gen.c.t
@@ -125,7 +125,7 @@ const struct tst_suite tst_suite = {
%% if not pt.is_unknown()
{.name = "{{ fmt }} {{ pt.name }}",
.tst_fn = test_{{ fmt }}_{{ pt.name }},
- .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+ .flags = TST_TMPDIR | TST_MALLOC_CANARIES},
%% endif
%% endfor
%% endfor
http://repo.or.cz/w/gfxprim.git/commit/02e619a972aa0b3c53fab8c2ae0863f8335c…
commit 02e619a972aa0b3c53fab8c2ae0863f8335c5d9f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 16 16:26:43 2013 +0100
tests: framework: Add TST_MALLOC_CANARIES flag.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c
index 04b6714..f0607a8 100644
--- a/tests/framework/tst_job.c
+++ b/tests/framework/tst_job.c
@@ -413,10 +413,23 @@ void tst_job_run(struct tst_job *job)
tst_malloc_check_start();
/* Run test */
- if (job->test->bench_iter)
+ if (job->test->bench_iter) {
ret = tst_job_benchmark(job);
- else
- ret = job_run(job);
+ } else {
+ if (job->test->flags & TST_MALLOC_CANARIES) {
+ tst_malloc_canaries_set(MALLOC_CANARY_BEGIN);
+ ret = job_run(job);
+
+ if (!ret) {
+ tst_malloc_canaries_set(MALLOC_CANARY_END);
+ ret = job_run(job);
+ }
+
+ tst_malloc_canaries_set(MALLOC_CANARY_OFF);
+ } else {
+ ret = job_run(job);
+ }
+ }
if (job->test->flags & TST_CHECK_MALLOC) {
tst_malloc_check_stop();
diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h
index 52db399..4d65b1b 100644
--- a/tests/framework/tst_test.h
+++ b/tests/framework/tst_test.h
@@ -48,6 +48,14 @@ enum tst_flags {
* Check malloc for memory leaks.
*/
TST_CHECK_MALLOC = 0x02,
+
+ /*
+ * Enable malloc canaries. Executes test twice, allocating PROT_NONE
+ * page first before, then after the allocated buffer.
+ *
+ * Implies TST_CHECK_MALLOC.
+ */
+ TST_MALLOC_CANARIES = 0x06,
};
struct tst_test {
http://repo.or.cz/w/gfxprim.git/commit/f75a8c4a88ce2805d3a6879e956945248dd5…
commit f75a8c4a88ce2805d3a6879e956945248dd5b075
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 16 16:12:04 2013 +0100
tests: Fix whitespaces.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/BlitConv.gen.c.t b/tests/core/BlitConv.gen.c.t
index b6d02af..05be76a 100644
--- a/tests/core/BlitConv.gen.c.t
+++ b/tests/core/BlitConv.gen.c.t
@@ -71,7 +71,7 @@ static int check_filled(GP_Context *c, GP_Pixel p)
}
}
}
-
+
return 0;
}
diff --git a/tests/core/Context.c b/tests/core/Context.c
index 5715717..cf8374d 100644
--- a/tests/core/Context.c
+++ b/tests/core/Context.c
@@ -61,12 +61,12 @@ static int Context_Alloc_Free(void)
tst_msg("Context->w != 100 (== %i)", c->w);
return TST_FAILED;
}
-
+
if (c->h != 200) {
tst_msg("Context->h != 200 (== %i)", c->h);
return TST_FAILED;
}
-
+
if (c->offset != 0) {
tst_msg("Context->offset != 0");
return TST_FAILED;
@@ -112,17 +112,17 @@ static int subcontext_assert(const GP_Context *c, const GP_Context *sc,
tst_msg("Context->bytes_per_row != SubContext->bytes_per_row");
return TST_FAILED;
}
-
+
if (sc->w != w) {
tst_msg("SubContext->w != %u (== %i)", w, sc->w);
return TST_FAILED;
}
-
+
if (sc->h != h) {
tst_msg("SubContext->h != %u (== %i)", h, sc->h);
return TST_FAILED;
}
-
+
if (sc->offset != 0) {
tst_msg("SubContext->offset != 0");
return TST_FAILED;
@@ -143,7 +143,7 @@ static int subcontext_assert(const GP_Context *c, const GP_Context *sc,
sc->axes_swap, sc->x_swap, sc->y_swap);
return TST_FAILED;
}
-
+
/* access the start and end of the pixel buffer */
*(char*)GP_PIXEL_ADDR(sc, 0, 0) = 0;
*(char*)GP_PIXEL_ADDR(sc, sc->w - 1, sc->h - 1) = 0;
@@ -194,7 +194,7 @@ static int SubContext_Create(void)
}
GP_SubContext(c, &sc, 100, 100, 100, 100);
-
+
ret = subcontext_assert(c, &sc, 100, 100);
if (ret)
diff --git a/tests/core/GetSetBits.gen.c.t b/tests/core/GetSetBits.gen.c.t
index 1f28cfd..5c33f89 100644
--- a/tests/core/GetSetBits.gen.c.t
+++ b/tests/core/GetSetBits.gen.c.t
@@ -88,7 +88,7 @@ static int setbits_{{ off }}_{{ len }}(void)
canary2 = 0;
p_get = patterns[i];
GP_SET_BITS({{ off }}, {{ len }}, p_get, val);
-
+
p_exp = patterns[i] & {{ mask(off, len) }};
p_exp |= val<<{{ off }};
diff --git a/tests/core/Pixel.c b/tests/core/Pixel.c
index e334a16..f2ea3c8 100644
--- a/tests/core/Pixel.c
+++ b/tests/core/Pixel.c
@@ -39,17 +39,17 @@ static int pixel_flags(void)
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");
diff --git a/tests/core/WritePixel.gen.c.t b/tests/core/WritePixel.gen.c.t
index 9ec20c6..9c433a0 100644
--- a/tests/core/WritePixel.gen.c.t
+++ b/tests/core/WritePixel.gen.c.t
@@ -42,12 +42,12 @@ static void dump_buffer(const char *name, char *buf, unsigned int buf_len)
for (i = 0; i < buf_len; i++) {
printf("%i", !!buf[i]);
-
+
if (i != buf_len - 1)
printf(", ");
-
+
if (i % 26 == 25)
- printf("n ");
+ printf("n ");
}
printf("}n");
@@ -84,8 +84,8 @@ static int WritePixel{{ "_%i_%i_%i_%i"|format(pixelsize, offset, len, aligment)
char gen_buf[{{ 25 * pixelsize//8 }}] = {};
/*
- * Fill the compare buffer
- */
+ * Fill the compare buffer
+ */
%% for i in range(0, len)
%% for j in range(0, pixelsize//8)
gen_buf[{{aligment + offset * pixelsize//8 + i * pixelsize//8 + j}}] = 0xff;
@@ -103,8 +103,8 @@ static int WritePixel{{ "_%i_%i_%i_%i_alloc"|format(pixelsize, offset, len, alig
char *write_buf = malloc({{ 25 * pixelsize//8 }});
/*
- * Fill the compare buffer
- */
+ * Fill the compare buffer
+ */
%% for i in range(0, len)
%% for j in range(0, pixelsize//8)
gen_buf[{{aligment + offset * pixelsize//8 + i * pixelsize//8 + j}}] = 0xff;
@@ -115,7 +115,7 @@ static int WritePixel{{ "_%i_%i_%i_%i_alloc"|format(pixelsize, offset, len, alig
tst_msg("Malloc failed :(");
return TST_UNTESTED;
}
-
+
memset(write_buf, 0, {{ 25 * pixelsize//8 }});
GP_WritePixels_{{ pixelsize }}BPP(write_buf + {{aligment + offset * pixelsize//8}}, {{ len }}, 0xffffffff>>{{32 - pixelsize}});
diff --git a/tests/filters/FilterMirrorH.c b/tests/filters/FilterMirrorH.c
index 8aa50ac..509da34 100644
--- a/tests/filters/FilterMirrorH.c
+++ b/tests/filters/FilterMirrorH.c
@@ -104,7 +104,7 @@ struct testcase testcase_2x2 = {
2, 3,
0, 1,
},
-
+
.src = {
0, 1,
2, 3,
@@ -121,7 +121,7 @@ struct testcase testcase_10x2 = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
},
-
+
.src = {
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
@@ -139,7 +139,7 @@ struct testcase testcase_2x3 = {
2, 3,
0, 1,
},
-
+
.src = {
0, 1,
2, 3,
@@ -159,7 +159,7 @@ struct testcase testcase_3x3 = {
3, 4, 5,
0, 1, 2,
},
-
+
.src = {
0, 1, 2,
3, 4, 5,
@@ -179,7 +179,7 @@ struct testcase testcase_4x4 = {
4, 5, 6, 7,
0, 1, 2, 3,
},
-
+
.src = {
0, 1, 2, 3,
4, 5, 6, 7,
@@ -202,7 +202,7 @@ struct testcase testcase_G1_16x2 = {
0x0f, 0xaa, 0xf0,
0xff, 0xff, 0xff,
},
-
+
.src = {
0x0f, 0xff, 0xf0,
0xff, 0xaa, 0xff,
@@ -222,7 +222,7 @@ static int test_abort(void)
{
int ret;
GP_Context *c;
-
+
c = GP_ContextAlloc(10, 10, GP_PIXEL_G8);
if (c == NULL) {
@@ -275,11 +275,11 @@ const struct tst_suite tst_suite = {
{.name = "MirrorH 1x1",
.tst_fn = test_mirror_h,
.data = &testcase_1x1},
-
+
{.name = "MirrorH 2x2",
.tst_fn = test_mirror_h,
.data = &testcase_2x2},
-
+
{.name = "MirrorH 10x2",
.tst_fn = test_mirror_h,
.data = &testcase_10x2},
@@ -291,7 +291,7 @@ const struct tst_suite tst_suite = {
{.name = "MirrorH 3x3",
.tst_fn = test_mirror_h,
.data = &testcase_3x3},
-
+
{.name = "MirrorH 4x4",
.tst_fn = test_mirror_h,
.data = &testcase_3x3},
diff --git a/tests/filters/LinearConvolution.c b/tests/filters/LinearConvolution.c
index 42ac872..9d685c9 100644
--- a/tests/filters/LinearConvolution.c
+++ b/tests/filters/LinearConvolution.c
@@ -97,7 +97,7 @@ static int test_h_lin_conv_box_3_raw(void)
if (errno == ENOSYS)
return TST_SKIPPED;
}
-
+
/* Check result */
//TODO
@@ -113,7 +113,7 @@ static int test_v_lin_conv_box_3_raw(void)
if (ret != TST_SUCCESS)
return ret;
-
+
// GP_SetDebugLevel(10);
/* Apply the convolution */
@@ -124,7 +124,7 @@ static int test_v_lin_conv_box_3_raw(void)
if (errno == ENOSYS)
return TST_SKIPPED;
}
-
+
/* Check result */
//TODO
diff --git a/tests/filters/common.c b/tests/filters/common.c
index 35a6d13..86d129f 100644
--- a/tests/filters/common.c
+++ b/tests/filters/common.c
@@ -50,8 +50,8 @@ void dump_buffers(const char *pattern, const GP_Context *c)
unsigned int idx = x + y * c->w;
char p = ((char*)c->pixels)[idx];
- if (pattern[idx] != p) {
- /* TODO: we expect background to be 0 */
+ if (pattern[idx] != p) {
+ /* TODO: we expect background to be 0 */
if (p == 0)
printf(" x ");
else
@@ -74,14 +74,14 @@ int compare_buffers(const char *pattern, const GP_Context *c)
for (x = 0; x < c->w; x++) {
for (y = 0; y < c->h; y++) {
unsigned int idx = x + y * c->w;
-
+
if (pattern[idx] != ((char*)c->pixels)[idx])
err++;
}
}
if (err)
- dump_buffers(pattern, c);
+ dump_buffers(pattern, c);
return err;
}
diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c
index 1d0d754..04b6714 100644
--- a/tests/framework/tst_job.c
+++ b/tests/framework/tst_job.c
@@ -386,11 +386,11 @@ void tst_job_run(struct tst_job *job)
}
/* Redirect stderr/stdout TODO: catch its output */
- if (freopen("/dev/null", "w", stderr) == NULL)
- tst_warn("freopen(stderr) failed: %s", strerror(errno));
+// if (freopen("/dev/null", "w", stderr) == NULL)
+// tst_warn("freopen(stderr) failed: %s", strerror(errno));
- if (freopen("/dev/null", "w", stdout) == NULL)
- tst_warn("freopen(stdout) failed: %s", strerror(errno));
+// if (freopen("/dev/null", "w", stdout) == NULL)
+// tst_warn("freopen(stdout) failed: %s", strerror(errno));
/* Create directory in /tmp/ and chdir into it. */
if (job->test->flags & TST_TMPDIR)
diff --git a/tests/framework/tst_job.h b/tests/framework/tst_job.h
index 171c0f0..140a9f8 100644
--- a/tests/framework/tst_job.h
+++ b/tests/framework/tst_job.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Test job is an instance of running test.
*/
@@ -37,8 +37,8 @@
struct tst_job {
const struct tst_test *test;
-
- /*
+
+ /*
* Pipe fd.
*
* In parent this points to the read side of the pipe so the parent
@@ -48,19 +48,19 @@ struct tst_job {
* send data to parent.
*/
int pipefd;
-
+
int running:1;
-
+
/* test execution time */
struct timespec start_time;
struct timespec stop_time;
-
+
/* test cpu time */
struct timespec cpu_time;
/* test pid */
int pid;
-
+
/* test result */
enum tst_ret result;
diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c
index 658419e..b30dcb9 100644
--- a/tests/framework/tst_log.c
+++ b/tests/framework/tst_log.c
@@ -130,7 +130,7 @@ int tst_log_append(struct tst_job *job, FILE *f)
/* Append any test reports */
append_msg_json(job, f);
-
+
/* If calculated include malloc report */
if (job->test->flags & TST_CHECK_MALLOC)
append_malloc_stats_json(job, f);
diff --git a/tests/framework/tst_log.h b/tests/framework/tst_log.h
index 400d9e8..b7586ff 100644
--- a/tests/framework/tst_log.h
+++ b/tests/framework/tst_log.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Logs finished job result into the file.
*/
diff --git a/tests/framework/tst_msg.h b/tests/framework/tst_msg.h
index f144851..781573d 100644
--- a/tests/framework/tst_msg.h
+++ b/tests/framework/tst_msg.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Code to store test messages into a data structure.
*/
diff --git a/tests/framework/tst_preload_FILE.h b/tests/framework/tst_preload_FILE.h
index 0c1da0a..0691c7b 100644
--- a/tests/framework/tst_preload_FILE.h
+++ b/tests/framework/tst_preload_FILE.h
@@ -32,7 +32,7 @@ enum tst_file_call {
* Describes which call on which file and how should fail.
*/
struct tst_fail_FILE {
- /*
+ /*
* File path to be failed, this is matched exactly against the path
* passed to fopen().
*
@@ -45,8 +45,8 @@ struct tst_fail_FILE {
/* if not zero, errno is set to this */
int err;
-
- /*
+
+ /*
* Which call should be failed.
*/
enum tst_file_call call;
diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h
index b19e40d..52db399 100644
--- a/tests/framework/tst_test.h
+++ b/tests/framework/tst_test.h
@@ -38,7 +38,7 @@ enum tst_ret {
};
enum tst_flags {
- /*
+ /*
* Create teporary directory and set it as CWD and
* clean it after the test is finised.
*/
@@ -53,7 +53,7 @@ enum tst_flags {
struct tst_test {
/* test name */
const char *name;
- /*
+ /*
* Resurce path, file or directory which is copied to
* test directory before test is executed.
*/
@@ -111,7 +111,7 @@ int tst_report(int level, const char *fmt, ...)
int tst_msg(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
-/*
+/*
* Warning and Error are used in test framework to distinguish the type of test
* internal problem. You shouldn't use this one unless the test exited with
* TST_UNTESTED.
diff --git a/tests/framework/tst_timespec.h b/tests/framework/tst_timespec.h
index 27ab5cb..3ec03ee 100644
--- a/tests/framework/tst_timespec.h
+++ b/tests/framework/tst_timespec.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Timespec manipulation utils.
*/
diff --git a/tests/gfx/Circle.c b/tests/gfx/Circle.c
index 0015ebe..bb6f4e1 100644
--- a/tests/gfx/Circle.c
+++ b/tests/gfx/Circle.c
@@ -212,31 +212,31 @@ const struct tst_suite tst_suite = {
.tests = {
{.name = "Circle r=0",
.tst_fn = test_circle,
- .data = &testcase_circle_r_0},
+ .data = &testcase_circle_r_0},
{.name = "Circle r=1",
.tst_fn = test_circle,
- .data = &testcase_circle_r_1},
+ .data = &testcase_circle_r_1},
{.name = "Circle r=2",
.tst_fn = test_circle,
- .data = &testcase_circle_r_2},
+ .data = &testcase_circle_r_2},
{.name = "Circle r=3",
.tst_fn = test_circle,
- .data = &testcase_circle_r_3},
+ .data = &testcase_circle_r_3},
{.name = "Circle r=4",
.tst_fn = test_circle,
- .data = &testcase_circle_r_4},
-
+ .data = &testcase_circle_r_4},
+
{.name = "Circle r=5 + clipping",
.tst_fn = test_circle,
- .data = &testcase_circle_r_5_clip},
+ .data = &testcase_circle_r_5_clip},
{.name = "Circle r=6 + clipping",
.tst_fn = test_circle,
- .data = &testcase_circle_r_6_clip},
+ .data = &testcase_circle_r_6_clip},
{.name = NULL}
}
diff --git a/tests/gfx/FillCircle.c b/tests/gfx/FillCircle.c
index 3ab67b9..e885d4a 100644
--- a/tests/gfx/FillCircle.c
+++ b/tests/gfx/FillCircle.c
@@ -212,31 +212,31 @@ const struct tst_suite tst_suite = {
.tests = {
{.name = "FillCircle r=0",
.tst_fn = test_circle,
- .data = &testcase_circle_r_0},
+ .data = &testcase_circle_r_0},
{.name = "FillCircle r=1",
.tst_fn = test_circle,
- .data = &testcase_circle_r_1},
+ .data = &testcase_circle_r_1},
{.name = "FillCircle r=2",
.tst_fn = test_circle,
- .data = &testcase_circle_r_2},
+ .data = &testcase_circle_r_2},
{.name = "FillCircle r=3",
.tst_fn = test_circle,
- .data = &testcase_circle_r_3},
+ .data = &testcase_circle_r_3},
{.name = "FillCircle r=4",
.tst_fn = test_circle,
- .data = &testcase_circle_r_4},
-
+ .data = &testcase_circle_r_4},
+
{.name = "FillCircle r=5 + clipping",
.tst_fn = test_circle,
- .data = &testcase_circle_r_5_clip},
+ .data = &testcase_circle_r_5_clip},
{.name = "FillCircle r=6 + clipping",
.tst_fn = test_circle,
- .data = &testcase_circle_r_6_clip},
+ .data = &testcase_circle_r_6_clip},
{.name = NULL}
}
diff --git a/tests/gfx/HLine.c b/tests/gfx/HLine.c
index 14dfd51..db0ecb2 100644
--- a/tests/gfx/HLine.c
+++ b/tests/gfx/HLine.c
@@ -161,7 +161,7 @@ static struct testcase testcase_clipping_3 = {
};
static struct testcase testcase_xyw_1 = {
- .x = 1,
+ .x = 1,
.y = 1,
.lw = 0,
@@ -177,7 +177,7 @@ static struct testcase testcase_xyw_1 = {
};
static struct testcase testcase_xyw_2 = {
- .x = 1,
+ .x = 1,
.y = 1,
.lw = 2,
@@ -193,7 +193,7 @@ static struct testcase testcase_xyw_2 = {
};
static struct testcase testcase_xyw_clipp_1 = {
- .x = -10000,
+ .x = -10000,
.y = 1,
.lw = 20000,
@@ -246,15 +246,15 @@ const struct tst_suite tst_suite = {
{.name = "HLine 1px",
.tst_fn = test_hline,
.data = &testcase_1_px},
-
+
{.name = "HLine 3px 1",
.tst_fn = test_hline,
.data = &testcase_3_px_1},
-
+
{.name = "HLine 3px 2",
.tst_fn = test_hline,
.data = &testcase_3_px_2},
-
+
{.name = "HLine clipping 1",
.tst_fn = test_hline,
.data = &testcase_clipping_1},
@@ -274,7 +274,7 @@ const struct tst_suite tst_suite = {
{.name = "HLineXYW 2",
.tst_fn = test_hline,
.data = &testcase_xyw_2},
-
+
{.name = "HLineXYW clipping 1",
.tst_fn = test_hline,
.data = &testcase_xyw_clipp_1},
diff --git a/tests/gfx/HLineAA.c b/tests/gfx/HLineAA.c
index d0f8656..3f67996 100644
--- a/tests/gfx/HLineAA.c
+++ b/tests/gfx/HLineAA.c
@@ -76,7 +76,7 @@ static struct testcase testcase_line_len_0_1 = {
.pixmap = {
0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
}
};
@@ -91,7 +91,7 @@ static struct testcase testcase_line_len_0_2 = {
.pixmap = {
0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
}
};
@@ -106,7 +106,7 @@ static struct testcase testcase_line_len_0_3 = {
.pixmap = {
0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
}
};
@@ -121,7 +121,7 @@ static struct testcase testcase_line_len_0_4 = {
.pixmap = {
0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
}
};
@@ -136,7 +136,7 @@ static struct testcase testcase_line_len_0_5 = {
.pixmap = {
0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
}
};
@@ -151,7 +151,7 @@ static struct testcase testcase_line_len_05_1 = {
.pixmap = {
0x00, 0x00, 0x00,
- 0x00, 0x80, 0x00,
+ 0x00, 0x80, 0x00,
0x00, 0x00, 0x00,
}
};
@@ -166,7 +166,7 @@ static struct testcase testcase_line_len_05_2 = {
.pixmap = {
0x00, 0x00, 0x00,
- 0x00, 0x40, 0x00,
+ 0x00, 0x40, 0x00,
0x00, 0x40, 0x00,
0x00, 0x00, 0x00,
}
@@ -283,15 +283,15 @@ const struct tst_suite tst_suite = {
{.name = "HLineAA len=0 4",
.tst_fn = test_line,
.data = &testcase_line_len_0_4},
-
+
{.name = "HLineAA len=0 5",
.tst_fn = test_line,
.data = &testcase_line_len_0_5},
-
+
{.name = "HLineAA len=0.5 1",
.tst_fn = test_line,
.data = &testcase_line_len_05_1},
-
+
{.name = "HLineAA len=0.5 2",
.tst_fn = test_line,
.data = &testcase_line_len_05_2},
@@ -311,11 +311,11 @@ const struct tst_suite tst_suite = {
{.name = "LineAA len=1 4",
.tst_fn = test_line,
.data = &testcase_line_len_1_4},
-
+
{.name = "LineAA len=4 1",
.tst_fn = test_line,
.data = &testcase_line_len_4_1},
-
+
{.name = "LineAA len=4 2",
.tst_fn = test_line,
.data = &testcase_line_len_4_2},
diff --git a/tests/gfx/Line.c b/tests/gfx/Line.c
index 5fcc4a3..fc806d7 100644
--- a/tests/gfx/Line.c
+++ b/tests/gfx/Line.c
@@ -79,7 +79,7 @@ static struct testcase testcase_line_1px = {
.pixmap = {
0, 0, 0,
- 0, 1, 0,
+ 0, 1, 0,
0, 0, 0,
}
};
@@ -215,19 +215,19 @@ const struct tst_suite tst_suite = {
{.name = "Line Horizontal",
.tst_fn = test_line,
.data = &testcase_line_horiz},
-
+
{.name = "Line Vertical",
.tst_fn = test_line,
.data = &testcase_line_vert},
-
+
{.name = "Line 45 degrees",
.tst_fn = test_line,
.data = &testcase_line_45},
-
+
{.name = "Line 15 degrees",
.tst_fn = test_line,
.data = &testcase_line_15},
-
+
{.name = "Line clipping",
.tst_fn = test_line,
.data = &testcase_line_clip},
@@ -236,7 +236,7 @@ const struct tst_suite tst_suite = {
.tst_fn = test_line,
.data = &testcase_line_large_xy,
.timeout = 1},
-
+
{.name = NULL}
}
};
diff --git a/tests/gfx/LineAA.c b/tests/gfx/LineAA.c
index f4a5d45..5373c24 100644
--- a/tests/gfx/LineAA.c
+++ b/tests/gfx/LineAA.c
@@ -79,7 +79,7 @@ static struct testcase testcase_line_1px = {
.pixmap = {
0x00, 0x00, 0x00,
- 0x00, 0xff, 0x00,
+ 0x00, 0xff, 0x00,
0x00, 0x00, 0x00,
}
};
@@ -142,15 +142,15 @@ const struct tst_suite tst_suite = {
{.name = "LineAA 1px",
.tst_fn = test_line,
.data = &testcase_line_1px},
-
+
{.name = "LineAA 2px",
.tst_fn = test_line,
.data = &testcase_line_2px},
-
+
{.name = "LineAA 2px horizontal",
.tst_fn = test_line,
.data = &testcase_line_2px_h},
-
+
{.name = "LineAA 2px vertical",
.tst_fn = test_line,
.data = &testcase_line_2px_v},
diff --git a/tests/gfx/Polygon.c b/tests/gfx/Polygon.c
index d846328..e0ff15c 100644
--- a/tests/gfx/Polygon.c
+++ b/tests/gfx/Polygon.c
@@ -35,7 +35,7 @@ struct testcase {
/* polygon description */
unsigned int edge_count;
GP_Coord edges[20];
-
+
/* expected result */
GP_Size w, h;
const char pixmap[];
@@ -349,11 +349,11 @@ const struct tst_suite tst_suite = {
{.name = "Triangle 6px Polygon",
.tst_fn = test_polygon,
.data = &testcase_6px_triangle},
-
+
{.name = "Triangle 1. Polygon",
.tst_fn = test_polygon,
.data = &testcase_triangle_1},
-
+
{.name = "Bow 4edges 7px",
.tst_fn = test_polygon,
.data = &testcase_bow_4edges_7px},
diff --git a/tests/gfx/PutPixelAA.c b/tests/gfx/PutPixelAA.c
index 55f46de..22faee7 100644
--- a/tests/gfx/PutPixelAA.c
+++ b/tests/gfx/PutPixelAA.c
@@ -75,7 +75,7 @@ static struct testcase testcase_pixel_center = {
.pixmap = {
0x00, 0x00, 0x00,
- 0x00, 0xff, 0x00,
+ 0x00, 0xff, 0x00,
0x00, 0x00, 0x00,
}
};
@@ -89,7 +89,7 @@ static struct testcase testcase_pixel_hcenter = {
.pixmap = {
0x00, 0x00, 0x00,
- 0x00, 0x80, 0x00,
+ 0x00, 0x80, 0x00,
0x00, 0x80, 0x00,
0x00, 0x00, 0x00,
}
@@ -130,15 +130,15 @@ const struct tst_suite tst_suite = {
{.name = "PutPixelAA center",
.tst_fn = test_pixel,
.data = &testcase_pixel_center},
-
+
{.name = "PutPixelAA hcenter",
.tst_fn = test_pixel,
.data = &testcase_pixel_hcenter},
-
+
{.name = "PutPixelAA vcenter",
.tst_fn = test_pixel,
.data = &testcase_pixel_vcenter},
-
+
{.name = "PutPixelAA",
.tst_fn = test_pixel,
.data = &testcase_pixel},
diff --git a/tests/gfx/VLine.c b/tests/gfx/VLine.c
index 03b2d62..61640c3 100644
--- a/tests/gfx/VLine.c
+++ b/tests/gfx/VLine.c
@@ -171,7 +171,7 @@ static struct testcase testcase_clipping_3 = {
};
static struct testcase testcase_xyh_1 = {
- .x = 1,
+ .x = 1,
.y = 1,
.lh = 0,
@@ -187,7 +187,7 @@ static struct testcase testcase_xyh_1 = {
};
static struct testcase testcase_xyh_2 = {
- .x = 1,
+ .x = 1,
.y = 1,
.lh = 2,
@@ -204,7 +204,7 @@ static struct testcase testcase_xyh_2 = {
};
static struct testcase testcase_xyh_clipp_1 = {
- .x = 1,
+ .x = 1,
.y = -10000,
.lh = 20000,
@@ -257,15 +257,15 @@ const struct tst_suite tst_suite = {
{.name = "VLine 1px",
.tst_fn = test_vline,
.data = &testcase_1_px},
-
+
{.name = "VLine 3px 1",
.tst_fn = test_vline,
.data = &testcase_3_px_1},
-
+
{.name = "VLine 3px 2",
.tst_fn = test_vline,
.data = &testcase_3_px_2},
-
+
{.name = "VLine clipping 1",
.tst_fn = test_vline,
.data = &testcase_clipping_1},
@@ -277,7 +277,7 @@ const struct tst_suite tst_suite = {
{.name = "VLine clipping 3",
.tst_fn = test_vline,
.data = &testcase_clipping_3},
-
+
{.name = "VLineXYH 1",
.tst_fn = test_vline,
.data = &testcase_xyh_1},
@@ -297,7 +297,7 @@ const struct tst_suite tst_suite = {
{.name = "VLineXYH clipping 3",
.tst_fn = test_vline,
.data = &testcase_xyh_clipp_3},
-
+
{.name = NULL}
}
};
diff --git a/tests/gfx/common.c b/tests/gfx/common.c
index 35a6d13..86d129f 100644
--- a/tests/gfx/common.c
+++ b/tests/gfx/common.c
@@ -50,8 +50,8 @@ void dump_buffers(const char *pattern, const GP_Context *c)
unsigned int idx = x + y * c->w;
char p = ((char*)c->pixels)[idx];
- if (pattern[idx] != p) {
- /* TODO: we expect background to be 0 */
+ if (pattern[idx] != p) {
+ /* TODO: we expect background to be 0 */
if (p == 0)
printf(" x ");
else
@@ -74,14 +74,14 @@ int compare_buffers(const char *pattern, const GP_Context *c)
for (x = 0; x < c->w; x++) {
for (y = 0; y < c->h; y++) {
unsigned int idx = x + y * c->w;
-
+
if (pattern[idx] != ((char*)c->pixels)[idx])
err++;
}
}
if (err)
- dump_buffers(pattern, c);
+ dump_buffers(pattern, c);
return err;
}
diff --git a/tests/gfx/gfx_benchmark.c b/tests/gfx/gfx_benchmark.c
index c4cff7a..4d5674c 100644
--- a/tests/gfx/gfx_benchmark.c
+++ b/tests/gfx/gfx_benchmark.c
@@ -125,7 +125,7 @@ const struct tst_suite tst_suite = {
.bench_iter = 10},
{.name = "Line 32BPP", .tst_fn = bench_line_32bpp,
.bench_iter = 10},
-
+
{.name = "Circle 1BPP", .tst_fn = bench_circle_1bpp,
.bench_iter = 10},
{.name = "Circle 2BPP", .tst_fn = bench_circle_2bpp,
@@ -136,7 +136,7 @@ const struct tst_suite tst_suite = {
.bench_iter = 10},
{.name = "Circle 32BPP", .tst_fn = bench_circle_32bpp,
.bench_iter = 10},
-
+
{.name = NULL},
}
};
http://repo.or.cz/w/gfxprim.git/commit/04c28a7494aa96256e17537a97cc7fb78254…
commit 04c28a7494aa96256e17537a97cc7fb78254a6f2
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 16 16:10:07 2013 +0100
tests: FillRect: A few more testcases.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/gfx/FillRect.c b/tests/gfx/FillRect.c
index bd30ad5..87b720b 100644
--- a/tests/gfx/FillRect.c
+++ b/tests/gfx/FillRect.c
@@ -266,6 +266,60 @@ struct testcase testcase_rect_9d = {
}
};
+struct testcase testcase_rect_0a = {
+ .x1 = 2147483647,
+ .y1 = -2147483648,
+ .x2 = 2147483647,
+ .y2 = -2147483648,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+struct testcase testcase_rect_0b = {
+ .x1 = -2147483648,
+ .y1 = 2147483647,
+ .x2 = -2147483648,
+ .y2 = 2147483647,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+struct testcase testcase_rect_25 = {
+ .x1 = -2147483648,
+ .y1 = 2147483647,
+ .x2 = 2147483647,
+ .y2 = -2147483648,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1,
+ }
+};
+
const struct tst_suite tst_suite = {
.suite_name = "FillRect Testsuite",
.tests = {
@@ -321,6 +375,21 @@ const struct tst_suite tst_suite = {
.data = &testcase_rect_9d,
.timeout = 2},
+ {.name = "FillRect rect out of context 1",
+ .tst_fn = test_rect,
+ .data = &testcase_rect_0a,
+ .timeout = 2},
+
+ {.name = "FillRect rect out of context 2",
+ .tst_fn = test_rect,
+ .data = &testcase_rect_0b,
+ .timeout = 2},
+
+ {.name = "FillRect full rect",
+ .tst_fn = test_rect,
+ .data = &testcase_rect_25,
+ .timeout = 2},
+
{.name = NULL}
}
};
http://repo.or.cz/w/gfxprim.git/commit/d85d6ad1a7f73a6b37e5bc322daa26bf1545…
commit d85d6ad1a7f73a6b37e5bc322daa26bf15453f71
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 16 15:52:15 2013 +0100
pywrap: filters: Add weighted median (disabled for now)
Note that the functions are disabled because the filter seems to be
broken. I will enable them once the filter is working again.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gfxprim/filters/__init__.py b/pylib/gfxprim/filters/__init__.py
index 1ac3acb..9fd278c 100644
--- a/pylib/gfxprim/filters/__init__.py
+++ b/pylib/gfxprim/filters/__init__.py
@@ -150,5 +150,64 @@ def _init(module):
module['ConvolutionEx'] = ConvolutionEx
module['ConvolutionExAlloc'] = ConvolutionExAlloc
+
+ #
+ # Special handling for weighted median parameters
+ #
+ def array_to_weights(weights):
+ h = len(weights)
+ w = len(weights[0])
+
+ # Assert that array is matrix of numbers
+ for i in range(0, h):
+ assert(len(weights[i]) == w)
+
+ for j in weights[i]:
+ assert(isinstance(j, int) and j >= 0)
+
+ # flatten the python array into C array
+ warr = c_filters.new_uint_array(w * h)
+
+ for i in range(0, h):
+ for j in range(0, w):
+ c_filters.uint_array_setitem(warr, i * w + j, weights[i][j])
+
+ ret = c_filters.GP_MedianWeights(w, h, warr)
+
+ return ret
+
+ def uint_arr_del(w):
+ c_filters.delete_uint_array(w.weights)
+
+ def WeightedMedian(src, dst, weights, callback=None):
+ """
+ WeightedMedian(src, dst, weights, callback=None)
+
+ Weighted variant of median filter. Weights is a two dimensional
+ array of positive integers that describe weights for neighbour pixels.
+ """
+ w = array_to_weights(weights)
+ ret = c_filters.GP_FilterWeightedMedian(src, dst, w, callback)
+ uint_arr_del(w)
+ return ret
+
+# extend_submodule(FiltersSubmodule, 'WeightedMedian', WeightedMedian)
+# module['WeightedMedian'] = WeightedMedian
+
+ def WeightedMedianAlloc(src, weights, callback=None):
+ """
+ WeightedMedianAlloc(src, weights, callback=None)
+
+ Weighted variant of median filter. Weights is a two dimensional
+ array of positive integers that describe weights for neighbour pixels.
+ """
+ w = array_to_weights(weights)
+ ret = c_filters.GP_FilterWeightedMedianAlloc(src, w, callback)
+ uint_arr_del(w)
+ return ret
+
+# extend_submodule(FiltersSubmodule, 'WeightedMedianAlloc', WeightedMedianAlloc)
+# module['WeightedMedianAlloc'] = WeightedMedianAlloc
+
_init(locals())
del _init
diff --git a/pylib/gfxprim/filters/filters.i b/pylib/gfxprim/filters/filters.i
index 8bec204..b0f7f1a 100644
--- a/pylib/gfxprim/filters/filters.i
+++ b/pylib/gfxprim/filters/filters.i
@@ -110,6 +110,31 @@ FILTER_FUNC(Median);
/* Weighted Median */
FILTER_FUNC(WeightedMedianEx);
FILTER_FUNC(WeightedMedian);
+
+%array_functions(unsigned int, uint_array);
+
+%extend GP_MedianWeights {
+ ~GP_MedianWeights() {
+ free($self);
+ }
+ GP_MedianWeights(unsigned int w, unsigned int h,
+ unsigned int *weights) {
+
+ GP_MedianWeights *ret = malloc(sizeof(GP_MedianWeights));
+
+ if (!ret) {
+ GP_DEBUG(1, "Malloc failed :(");
+ return NULL;
+ }
+
+ ret->w = w;
+ ret->h = h;
+ ret->weights = weights;
+
+ return ret;
+ }
+};
+
%include "GP_WeightedMedian.h"
/* Sigma filter */
http://repo.or.cz/w/gfxprim.git/commit/54c4a75afdc2cae3b7e3dea64cff7ee29696…
commit 54c4a75afdc2cae3b7e3dea64cff7ee29696d321
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 16 15:10:47 2013 +0100
examples: py_simple: Remove pygtk_example
It never worked anyway.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/py_simple/pygtk_example.py b/demos/py_simple/pygtk_example.py
deleted file mode 100755
index 0c220b3..0000000
--- a/demos/py_simple/pygtk_example.py
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-
-import pygtk
-pygtk.require('2.0')
-import gtk
-
-import gfxprim.core as core
-import gfxprim.loaders as loaders
-import gfxprim.filters as filters
-
-class HelloWorld:
- def delete_event(self, widget, event, data=None):
- return False
-
- def destroy(self, widget, data=None):
- gtk.main_quit()
-
- def __init__(self):
- self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
- self.window.set_title("PyGTK Example")
- self.window.connect("delete_event", self.delete_event)
- self.window.connect("destroy", self.destroy)
- self.window.set_border_width(1)
-
- self.image = gtk.Image();
- self.window.add(self.image)
-
- self.window.show()
- self.image.show()
-
- img = loaders.LoadImage(sys.argv[2])
- self.pixmap = gtk.gdk.Pixmap(None, img.w, img.h, 24)
- self.gc = gtk.gdk.Drawable.new_gc(self.pixmap)
-
- img2 = img.Convert(core.core_c.GP_PIXEL_BGR888);
-
- self.pixmap.draw_rgb_image(self.gc, 0, 0, img2.w, img2.h,
- gtk.gdk.RGB_DITHER_NONE,
- img2._hacky_hacky_pixels_buffer())
-
- self.image.set_from_pixmap(self.pixmap, None)
-
-
- def main(self):
- gtk.main()
-
-if __name__ == "__main__":
- hello = HelloWorld()
- hello.main()
http://repo.or.cz/w/gfxprim.git/commit/309a7bbfdc215e46a9e5a4782d13e6be20b3…
commit 309a7bbfdc215e46a9e5a4782d13e6be20b374d5
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 16 14:59:10 2013 +0100
loaders: PNG: Add support for 16 bit Grayscale.
Since we have PIXEL_G16 in config, we can make use of it.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 9e7ce53..937bb34 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -33,6 +33,7 @@
#include <string.h>
#include "../../config.h"
+#include "core/GP_ByteOrder.h"
#include "core/GP_Debug.h"
#include "GP_PNG.h"
@@ -168,6 +169,11 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback)
case 8:
pixel_type = GP_PIXEL_G8;
break;
+#ifdef GP_PIXEL_G16
+ case 16:
+ pixel_type = GP_PIXEL_G16;
+ break;
+#endif
}
break;
case PNG_COLOR_TYPE_RGB:
@@ -234,9 +240,20 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback)
goto err2;
}
- if (color_type == PNG_COLOR_TYPE_GRAY)
+ if (color_type == PNG_COLOR_TYPE_GRAY && depth < 8)
png_set_packswap(png);
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ /*
+ * PNG stores 16 bit values in big endian, turn
+ * on conversion to little endian if needed.
+ */
+ if (depth > 8) {
+ GP_DEBUG(1, "Enabling byte swap for bpp = %u", depth);
+ png_set_swap(png);
+ }
+#endif
+
uint32_t y;
int p;
@@ -436,6 +453,12 @@ static int prepare_png_header(const GP_Context *src, png_structp png,
bit_depth = 8;
color_type = PNG_COLOR_TYPE_GRAY;
break;
+#ifdef GP_PIXEL_G16
+ case GP_PIXEL_G16:
+ bit_depth = 16;
+ color_type = PNG_COLOR_TYPE_GRAY;
+ break;
+#endif
default:
return 1;
break;
@@ -454,7 +477,7 @@ static int prepare_png_header(const GP_Context *src, png_structp png,
//png_set_packing(png);
- /* prepare for format conversion */
+ /* prepare for format conversions */
switch (src->pixel_type) {
case GP_PIXEL_RGB888:
png_set_bgr(png);
@@ -468,6 +491,17 @@ static int prepare_png_header(const GP_Context *src, png_structp png,
break;
}
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ /*
+ * PNG stores 16 bit values in big endian, turn
+ * on conversion to little endian if needed.
+ */
+ if (bit_depth > 8) {
+ GP_DEBUG(1, "Enabling byte swap for bpp = %u", bit_depth);
+ png_set_swap(png);
+ }
+#endif
+
return 0;
}
http://repo.or.cz/w/gfxprim.git/commit/d6f5b7524dee82c9886c2605247d72991ee7…
commit d6f5b7524dee82c9886c2605247d72991ee71840
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 16 14:48:16 2013 +0100
core, loaders: Move endian include to core.
This just moves the #ifdefs around including
endian header to common place to core.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_ByteOrder.h b/include/core/GP_ByteOrder.h
new file mode 100644
index 0000000..f756d45
--- /dev/null
+++ b/include/core/GP_ByteOrder.h
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#ifndef CORE_GP_BYTE_ORDER_H
+#define CORE_GP_BYTE_ORDER_H
+
+/*
+ * To get macros as __BYTE_ORDER __BIG_ENDIAN and __LITTLE_ENDIAN
+ */
+#ifdef __linux__
+# include <endian.h>
+#else /* BSD Family */
+# include <machine/endian.h>
+#endif
+
+#endif /* CORE_GP_BYTE_ORDER_H */
diff --git a/libs/loaders/GP_ByteUtils.c b/libs/loaders/GP_ByteUtils.c
index 134c74e..b56c20d 100644
--- a/libs/loaders/GP_ByteUtils.c
+++ b/libs/loaders/GP_ByteUtils.c
@@ -22,12 +22,7 @@
#include <stdarg.h>
-#ifdef __linux__
-#include <endian.h>
-#else /* BSD Family */
-#include <machine/endian.h>
-#endif
-
+#include "core/GP_ByteOrder.h"
#include "core/GP_Debug.h"
#include "core/GP_Common.h"
-----------------------------------------------------------------------
Summary of changes:
demos/py_simple/pygtk_example.py | 51 --------------
.../{backends/GP_AALib.h => core/GP_ByteOrder.h} | 18 +++---
libs/loaders/GP_ByteUtils.c | 7 +--
libs/loaders/GP_PNG.c | 38 ++++++++++-
libs/loaders/GP_PNM.c | 4 +-
pylib/gfxprim/filters/__init__.py | 59 +++++++++++++++++
pylib/gfxprim/filters/filters.i | 25 +++++++
tests/core/BlitConv.gen.c.t | 2 +-
tests/core/Context.c | 14 ++--
tests/core/GetSetBits.gen.c.t | 2 +-
tests/core/Pixel.c | 6 +-
tests/core/WritePixel.gen.c.t | 16 ++--
tests/filters/FilterMirrorH.c | 20 +++---
tests/filters/LinearConvolution.c | 6 +-
tests/filters/common.c | 8 +-
tests/framework/tst_job.c | 27 ++++++--
tests/framework/tst_job.h | 14 ++--
tests/framework/tst_log.c | 2 +-
tests/framework/tst_log.h | 2 +-
tests/framework/tst_msg.h | 2 +-
tests/framework/tst_preload_FILE.h | 6 +-
tests/framework/tst_test.h | 14 +++-
tests/framework/tst_timespec.h | 2 +-
tests/gfx/Circle.c | 16 ++--
tests/gfx/FillCircle.c | 16 ++--
tests/gfx/FillRect.c | 69 ++++++++++++++++++++
tests/gfx/HLine.c | 14 ++--
tests/gfx/HLineAA.c | 24 ++++----
tests/gfx/Line.c | 12 ++--
tests/gfx/LineAA.c | 8 +-
tests/gfx/Polygon.c | 6 +-
tests/gfx/PutPixelAA.c | 10 ++--
tests/gfx/VLine.c | 16 ++--
tests/gfx/common.c | 8 +-
tests/gfx/gfx_benchmark.c | 4 +-
tests/loaders/SaveLoad.gen.c.t | 2 +-
36 files changed, 351 insertions(+), 199 deletions(-)
delete mode 100755 demos/py_simple/pygtk_example.py
copy include/{backends/GP_AALib.h => core/GP_ByteOrder.h} (86%)
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
15 Nov '13
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
discards d5a0602976ef29ab84cac9df07eebf0818eb894e (commit)
via a38bd31917407a2fd2b4054c51f6421c2d79654f (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (d5a0602976ef29ab84cac9df07eebf0818eb894e)
N -- N -- N (a38bd31917407a2fd2b4054c51f6421c2d79654f)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
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/a38bd31917407a2fd2b4054c51f6421c2d79…
commit a38bd31917407a2fd2b4054c51f6421c2d79654f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 15 19:41:54 2013 +0100
tests: framework: Makefile: Fix LDLIBS.
The -ldl must be after the object files.
(fixes tests on Ubuntu)
Fix the output to match the rest of nonverbose build.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/framework/Makefile b/tests/framework/Makefile
index 15cd84a..5b13c0f 100644
--- a/tests/framework/Makefile
+++ b/tests/framework/Makefile
@@ -5,8 +5,7 @@ CSOURCES=$(shell echo *.c)
INCLUDE=
LDFLAGS+=-L.
-LDLIBS+=-ltst_preload -lm -ldl -ltst -lrt
-CFLAGS+=
+LDLIBS=-ltst_preload -lm -ldl -ltst -lrt
test: libtst.a
@@ -15,10 +14,20 @@ APPS=test
ALL+=libtst_preload.so libtst.a
libtst_preload.so: tst_preload.o tst_malloc_canaries.o tst_preload_FILE.o
- $(CC) -Wl,-soname -Wl,tst_preload.so --shared -ldl -fPIC $^ -o $@
+ifndef VERBOSE
+ @echo "LD libtst_preload.so"
+ @$(CC) -Wl,-soname -Wl,tst_preload.so --shared -fPIC $^ -ldl -o $@
+else
+ $(CC) -Wl,-soname -Wl,tst_preload.so --shared -fPIC $^ -ldl -o $@
+endif
libtst.a: tst_suite.o tst_job.o tst_msg.o tst_log.o tst_main.o tst_timespec.o
+ifndef VERBOSE
+ @echo "AR libtst.a"
+ @$(AR) rcs $@ $^
+else
$(AR) rcs $@ $^
+endif
CLEAN+=libtst_preload.so libtst.a log.json
-----------------------------------------------------------------------
Summary of changes:
tests/framework/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 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
15 Nov '13
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 d5a0602976ef29ab84cac9df07eebf0818eb894e (commit)
from d54f2201630102b15e262536d2b99330962102a8 (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/d5a0602976ef29ab84cac9df07eebf0818eb…
commit d5a0602976ef29ab84cac9df07eebf0818eb894e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 15 19:41:54 2013 +0100
tests: framework: Makefile: Fix LDLIBS.
The -ldl must be after the object files.
(fixes tests on Ubuntu)
Fix the output to match the rest of nonverbose build.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/framework/Makefile b/tests/framework/Makefile
index 15cd84a..a5da130 100644
--- a/tests/framework/Makefile
+++ b/tests/framework/Makefile
@@ -4,9 +4,8 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
INCLUDE=
-LDFLAGS+=-L.
-LDLIBS+=-ltst_preload -lm -ldl -ltst -lrt
-CFLAGS+=
+LDFLAGS=-L.
+LDLIBS=-ltst_preload -lm -ldl -ltst -lrt
test: libtst.a
@@ -15,10 +14,20 @@ APPS=test
ALL+=libtst_preload.so libtst.a
libtst_preload.so: tst_preload.o tst_malloc_canaries.o tst_preload_FILE.o
- $(CC) -Wl,-soname -Wl,tst_preload.so --shared -ldl -fPIC $^ -o $@
+ifndef VERBOSE
+ @echo "LD libtst_preload.so"
+ @$(CC) -Wl,-soname -Wl,tst_preload.so --shared -fPIC $^ -ldl -o $@
+else
+ $(CC) -Wl,-soname -Wl,tst_preload.so --shared -fPIC $^ -ldl -o $@
+endif
libtst.a: tst_suite.o tst_job.o tst_msg.o tst_log.o tst_main.o tst_timespec.o
+ifndef VERBOSE
+ @echo "AR libtst.a"
+ @$(AR) rcs $@ $^
+else
$(AR) rcs $@ $^
+endif
CLEAN+=libtst_preload.so libtst.a log.json
-----------------------------------------------------------------------
Summary of changes:
tests/framework/Makefile | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 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
15 Nov '13
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 d54f2201630102b15e262536d2b99330962102a8 (commit)
via c2c66545b615cbaf86e22d1ab7fc1dc9c0099d4e (commit)
via aa1a11a33f69d31af0e13a5d16c46dc0edda6f53 (commit)
from 62ad65536ccbc9b75e09fd80591572ebdbe509a4 (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/d54f2201630102b15e262536d2b993309621…
commit d54f2201630102b15e262536d2b99330962102a8
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 15 18:02:16 2013 +0100
loaders: TIFF: Fix warnings.
Fix unused warnings when compiling without the TIFF library.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c
index 4443127..f9d32c8 100644
--- a/libs/loaders/GP_TIFF.c
+++ b/libs/loaders/GP_TIFF.c
@@ -702,8 +702,9 @@ GP_Context *GP_LoadTIFF(const char GP_UNUSED(*src_path),
return NULL;
}
-int GP_SaveTIFF(const GP_Context *src, const char *dst_path,
- GP_ProgressCallback *callback)
+int GP_SaveTIFF(const GP_Context GP_UNUSED(*src),
+ const char GP_UNUSED(*dst_path),
+ GP_ProgressCallback GP_UNUSED(*callback))
{
errno = ENOSYS;
return 1;
http://repo.or.cz/w/gfxprim.git/commit/c2c66545b615cbaf86e22d1ab7fc1dc9c009…
commit c2c66545b615cbaf86e22d1ab7fc1dc9c0099d4e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 15 17:57:53 2013 +0100
core: BlitClipped: Fix two special cases.
* When dest coordinates (x2, y2) are negative
we need to clip source rectangle and not move it
* Fix off by one bugs when checking that source rectangle
fits into destination context
Fixes segfaults in spiv when moving image to the
bottom right corner.
Reported-by: Milan Vancura <milan(a)ucw.cz>
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/core/GP_Blit.c b/libs/core/GP_Blit.c
index cb8223e..8becf61 100644
--- a/libs/core/GP_Blit.c
+++ b/libs/core/GP_Blit.c
@@ -72,21 +72,29 @@ void GP_BlitXYXY_Clipped(const GP_Context *src,
if (y1 < y0)
GP_SWAP(y0, y1);
- /* Noting to blit return now */
+ /*
+ * Handle all cases where at least one of dest coordinates are out of
+ * the dest in positive direction -> src is out of dst completly.
+ */
if (x2 >= (GP_Coord)GP_ContextW(dst) ||
y2 >= (GP_Coord)GP_ContextH(dst))
return;
- /* We need to shift source rectangle */
+ /*
+ * The coordinates in dest are negative.
+ *
+ * We need to clip the source upper left corner accordingly.
+ *
+ * Notice that x2 and y2 are inside the dst rectangle now.
+ * (>= 0 and < w, < h)
+ */
if (x2 < 0) {
x0 -= x2;
- x1 -= x2;
x2 = 0;
}
if (y2 < 0) {
y0 -= y2;
- y1 -= y2;
y2 = 0;
}
@@ -97,8 +105,8 @@ void GP_BlitXYXY_Clipped(const GP_Context *src,
y1 = GP_MIN(y1, (GP_Coord)GP_ContextH(src) - 1);
/* And source rectangle fits inside of the destination */
- GP_Coord src_w = x1 - x0;
- GP_Coord src_h = y1 - y0;
+ GP_Coord src_w = x1 - x0 + 1;
+ GP_Coord src_h = y1 - y0 + 1;
GP_Coord dst_w = GP_ContextW(dst) - x2;
GP_Coord dst_h = GP_ContextH(dst) - y2;
@@ -107,10 +115,10 @@ void GP_BlitXYXY_Clipped(const GP_Context *src,
src_w, src_h, dst_w, dst_h);
if (src_w > dst_w)
- x1 -= src_w - dst_w + 1;
+ x1 -= src_w - dst_w;
if (src_h > dst_h)
- y1 -= src_h - dst_h + 1;
+ y1 -= src_h - dst_h;
GP_DEBUG(2, "Blitting %ix%i->%ix%i in %ux%u to %ix%i in %ux%u",
x0, y0, x1, y1, GP_ContextW(src), GP_ContextH(src),
http://repo.or.cz/w/gfxprim.git/commit/aa1a11a33f69d31af0e13a5d16c46dc0edda…
commit aa1a11a33f69d31af0e13a5d16c46dc0edda6f53
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 15 16:53:34 2013 +0100
tests: core: A few more Blit Clipped tests.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/BlitClipped.c b/tests/core/BlitClipped.c
index 3f0ba65..1fd7bdd 100644
--- a/tests/core/BlitClipped.c
+++ b/tests/core/BlitClipped.c
@@ -29,10 +29,13 @@
#include <core/GP_Context.h>
#include <core/GP_Blit.h>
+#include <core/GP_Fill.h>
#include "tst_test.h"
#include "tst_preload.h"
+#include "../filters/common.c"
+
struct clipped_test {
/* size of the contexes */
GP_Size src_w, src_h;
@@ -44,14 +47,21 @@ struct clipped_test {
/* Destination offset */
GP_Coord x1, y1;
+
+ /* If set, is used to check assert correct result */
+ const char *dst;
};
static int clipped_test(struct clipped_test *test)
{
+ int ret = TST_SUCCESS;
GP_Context *src, *dst;
- src = GP_ContextAlloc(test->src_w, test->src_h, GP_PIXEL_RGB888);
- dst = GP_ContextAlloc(test->dst_w, test->dst_h, GP_PIXEL_RGB888);
+ src = GP_ContextAlloc(test->src_w, test->src_h, GP_PIXEL_G8);
+ dst = GP_ContextAlloc(test->dst_w, test->dst_h, GP_PIXEL_G8);
+
+ GP_Fill(src, 1);
+ GP_Fill(dst, 0);
if (!src || !dst) {
tst_msg("GP_ContextAlloc() failed");
@@ -61,10 +71,15 @@ static int clipped_test(struct clipped_test *test)
GP_BlitXYWH_Clipped(src, test->x0, test->y0, test->w0, test->h0,
dst, test->x1, test->y1);
+ if (test->dst) {
+ if (compare_buffers(test->dst, dst))
+ ret = TST_FAILED;
+ }
+
GP_ContextFree(src);
GP_ContextFree(dst);
- return TST_SUCCESS;
+ return ret;
}
static int clipped_test_canaries(struct clipped_test *test)
@@ -130,12 +145,14 @@ static struct clipped_test off_by_one_3 = {
.y1 = 1,
};
+static const char empty[400] = {0};
+
static struct clipped_test empty_src = {
- .src_w = 100,
- .src_h = 100,
+ .src_w = 10,
+ .src_h = 10,
- .dst_w = 200,
- .dst_h = 200,
+ .dst_w = 20,
+ .dst_h = 20,
.x0 = 0,
.y0 = 0,
@@ -144,54 +161,178 @@ static struct clipped_test empty_src = {
.x1 = 0,
.y1 = 0,
+
+ .dst = empty,
};
static struct clipped_test out_of_dst_1 = {
- .src_w = 100,
- .src_h = 100,
+ .src_w = 10,
+ .src_h = 10,
- .dst_w = 200,
- .dst_h = 200,
+ .dst_w = 20,
+ .dst_h = 20,
.x0 = 0,
.y0 = 0,
- .w0 = 100,
- .h0 = 100,
+ .w0 = 10,
+ .h0 = 10,
- .x1 = 200,
+ .x1 = 20,
.y1 = 0,
+
+ .dst = empty,
};
static struct clipped_test out_of_dst_2 = {
- .src_w = 100,
- .src_h = 100,
+ .src_w = 10,
+ .src_h = 10,
- .dst_w = 200,
- .dst_h = 200,
+ .dst_w = 20,
+ .dst_h = 20,
.x0 = 0,
.y0 = 0,
- .w0 = 100,
- .h0 = 100,
+ .w0 = 10,
+ .h0 = 10,
.x1 = 0,
- .y1 = 200,
+ .y1 = 20,
+
+ .dst = empty,
};
static struct clipped_test src_rect_out_of_src = {
- .src_w = 100,
- .src_h = 100,
+ .src_w = 10,
+ .src_h = 10,
- .dst_w = 200,
- .dst_h = 200,
+ .dst_w = 20,
+ .dst_h = 20,
- .x0 = -100,
- .y0 = -100,
- .w0 = 200,
- .h0 = 200,
+ .x0 = -10,
+ .y0 = -10,
+ .w0 = 10,
+ .h0 = 10,
.x1 = 0,
.y1 = 0,
+
+ .dst = empty,
+};
+
+static struct clipped_test dst_neg_coords1 = {
+ .src_w = 5,
+ .src_h = 5,
+
+ .dst_w = 5,
+ .dst_h = 5,
+
+ .x0 = 2,
+ .y0 = 2,
+ .w0 = 5,
+ .h0 = 5,
+
+ .x1 = -2,
+ .y1 = -2,
+
+ .dst = (const char []) {
+ 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+static struct clipped_test dst_big_coords = {
+ .src_w = 5,
+ .src_h = 5,
+
+ .dst_w = 5,
+ .dst_h = 5,
+
+ .x0 = 2,
+ .y0 = 2,
+ .w0 = 5,
+ .h0 = 5,
+
+ .x1 = 4,
+ .y1 = 4,
+
+ .dst = (const char []) {
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1,
+ }
+};
+
+static struct clipped_test dst_neg_coords2 = {
+ .src_w = 10,
+ .src_h = 10,
+
+ .dst_w = 3,
+ .dst_h = 3,
+
+ .x0 = 0,
+ .y0 = 0,
+ .w0 = 8,
+ .h0 = 8,
+
+ .x1 = -5,
+ .y1 = -5,
+
+ .dst = (const char []) {
+ 1, 1, 1,
+ 1, 1, 1,
+ 1, 1, 1,
+ }
+};
+
+static struct clipped_test dst_neg_coords3 = {
+ .src_w = 12,
+ .src_h = 12,
+
+ .dst_w = 3,
+ .dst_h = 3,
+
+ .x0 = 0,
+ .y0 = 0,
+ .w0 = 10,
+ .h0 = 10,
+
+ .x1 = -8,
+ .y1 = -8,
+
+ .dst = (const char []) {
+ 1, 1, 0,
+ 1, 1, 0,
+ 0, 0, 0,
+ }
+};
+
+static struct clipped_test src_inside = {
+ .src_w = 3,
+ .src_h = 3,
+
+ .dst_w = 5,
+ .dst_h = 5,
+
+ .x0 = 0,
+ .y0 = 0,
+ .w0 = 3,
+ .h0 = 3,
+
+ .x1 = 1,
+ .y1 = 1,
+
+ .dst = (const char []) {
+ 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 1, 1, 1, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0,
+ }
};
const struct tst_suite tst_suite = {
@@ -217,6 +358,31 @@ const struct tst_suite tst_suite = {
.data = &src_rect_out_of_src,
.flags = TST_CHECK_MALLOC},
+ {.name = "Dst negative coords 1",
+ .tst_fn = clipped_test_canaries,
+ .data = &dst_neg_coords1,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = "Dst negative coords 2",
+ .tst_fn = clipped_test_canaries,
+ .data = &dst_neg_coords2,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = "Dst negative coords 3",
+ .tst_fn = clipped_test_canaries,
+ .data = &dst_neg_coords3,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = "Dst big coords",
+ .tst_fn = clipped_test_canaries,
+ .data = &dst_big_coords,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = "Src inside dst",
+ .tst_fn = clipped_test_canaries,
+ .data = &src_inside,
+ .flags = TST_CHECK_MALLOC},
+
{.name = "Regression off by one 1",
.tst_fn = clipped_test_canaries,
.data = &off_by_one_1,
-----------------------------------------------------------------------
Summary of changes:
libs/core/GP_Blit.c | 24 ++++--
libs/loaders/GP_TIFF.c | 5 +-
tests/core/BlitClipped.c | 224 ++++++++++++++++++++++++++++++++++++++++------
3 files changed, 214 insertions(+), 39 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
15 Nov '13
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 62ad65536ccbc9b75e09fd80591572ebdbe509a4 (commit)
via d0202e863397c4427f5bb8163de13764e98dcb31 (commit)
via 24824d445743e205a9afb6a218c93a5bc4a883c0 (commit)
from 98c0bddd4c211b197d0186f2fcb7db48d3a46ace (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/62ad65536ccbc9b75e09fd80591572ebdbe5…
commit 62ad65536ccbc9b75e09fd80591572ebdbe509a4
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 15 00:30:43 2013 +0100
tests: core: Add BlitClipped() tests.
Add a few basic BlitClipped tests
+ regression test for a off by one bug I've found today.
(fix is on the way)
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/BlitClipped.c b/tests/core/BlitClipped.c
new file mode 100644
index 0000000..3f0ba65
--- /dev/null
+++ b/tests/core/BlitClipped.c
@@ -0,0 +1,237 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+/*
+
+ Clipped Blit tests.
+
+ */
+#include <errno.h>
+
+#include <core/GP_Context.h>
+#include <core/GP_Blit.h>
+
+#include "tst_test.h"
+#include "tst_preload.h"
+
+struct clipped_test {
+ /* size of the contexes */
+ GP_Size src_w, src_h;
+ GP_Size dst_w, dst_h;
+
+ /* Source rectangle */
+ GP_Coord x0, y0;
+ GP_Size w0, h0;
+
+ /* Destination offset */
+ GP_Coord x1, y1;
+};
+
+static int clipped_test(struct clipped_test *test)
+{
+ GP_Context *src, *dst;
+
+ src = GP_ContextAlloc(test->src_w, test->src_h, GP_PIXEL_RGB888);
+ dst = GP_ContextAlloc(test->dst_w, test->dst_h, GP_PIXEL_RGB888);
+
+ if (!src || !dst) {
+ tst_msg("GP_ContextAlloc() failed");
+ return TST_UNTESTED;
+ }
+
+ GP_BlitXYWH_Clipped(src, test->x0, test->y0, test->w0, test->h0,
+ dst, test->x1, test->y1);
+
+ GP_ContextFree(src);
+ GP_ContextFree(dst);
+
+ return TST_SUCCESS;
+}
+
+static int clipped_test_canaries(struct clipped_test *test)
+{
+ int ret;
+
+ tst_malloc_canaries_set(MALLOC_CANARY_BEGIN);
+ ret = clipped_test(test);
+
+ tst_malloc_canaries_set(MALLOC_CANARY_END);
+ ret |= clipped_test(test);
+
+ tst_malloc_canaries_set(MALLOC_CANARY_OFF);
+
+ return ret;
+}
+
+static struct clipped_test off_by_one_1 = {
+ .src_w = 100,
+ .src_h = 100,
+
+ .dst_w = 100,
+ .dst_h = 100,
+
+ .x0 = 0,
+ .y0 = 0,
+ .w0 = 100,
+ .h0 = 100,
+
+ .x1 = 1,
+ .y1 = 1,
+};
+
+static struct clipped_test off_by_one_2 = {
+ .src_w = 100,
+ .src_h = 100,
+
+ .dst_w = 100,
+ .dst_h = 100,
+
+ .x0 = 0,
+ .y0 = 0,
+ .w0 = 100,
+ .h0 = 100,
+
+ .x1 = 1,
+ .y1 = 0,
+};
+
+static struct clipped_test off_by_one_3 = {
+ .src_w = 100,
+ .src_h = 100,
+
+ .dst_w = 100,
+ .dst_h = 100,
+
+ .x0 = 0,
+ .y0 = 0,
+ .w0 = 100,
+ .h0 = 100,
+
+ .x1 = 0,
+ .y1 = 1,
+};
+
+static struct clipped_test empty_src = {
+ .src_w = 100,
+ .src_h = 100,
+
+ .dst_w = 200,
+ .dst_h = 200,
+
+ .x0 = 0,
+ .y0 = 0,
+ .w0 = 0,
+ .h0 = 0,
+
+ .x1 = 0,
+ .y1 = 0,
+};
+
+static struct clipped_test out_of_dst_1 = {
+ .src_w = 100,
+ .src_h = 100,
+
+ .dst_w = 200,
+ .dst_h = 200,
+
+ .x0 = 0,
+ .y0 = 0,
+ .w0 = 100,
+ .h0 = 100,
+
+ .x1 = 200,
+ .y1 = 0,
+};
+
+static struct clipped_test out_of_dst_2 = {
+ .src_w = 100,
+ .src_h = 100,
+
+ .dst_w = 200,
+ .dst_h = 200,
+
+ .x0 = 0,
+ .y0 = 0,
+ .w0 = 100,
+ .h0 = 100,
+
+ .x1 = 0,
+ .y1 = 200,
+};
+
+static struct clipped_test src_rect_out_of_src = {
+ .src_w = 100,
+ .src_h = 100,
+
+ .dst_w = 200,
+ .dst_h = 200,
+
+ .x0 = -100,
+ .y0 = -100,
+ .w0 = 200,
+ .h0 = 200,
+
+ .x1 = 0,
+ .y1 = 0,
+};
+
+const struct tst_suite tst_suite = {
+ .suite_name = "Blit Clipped Testsuite",
+ .tests = {
+ {.name = "Empty src",
+ .tst_fn = clipped_test_canaries,
+ .data = &empty_src,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = "Out of dst 1",
+ .tst_fn = clipped_test_canaries,
+ .data = &out_of_dst_1,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = "Out of dst 2",
+ .tst_fn = clipped_test_canaries,
+ .data = &out_of_dst_2,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = "Src rect out of src",
+ .tst_fn = clipped_test_canaries,
+ .data = &src_rect_out_of_src,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = "Regression off by one 1",
+ .tst_fn = clipped_test_canaries,
+ .data = &off_by_one_1,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = "Regression off by one 2",
+ .tst_fn = clipped_test_canaries,
+ .data = &off_by_one_2,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = "Regression off by one 3",
+ .tst_fn = clipped_test_canaries,
+ .data = &off_by_one_3,
+ .flags = TST_CHECK_MALLOC},
+
+ {.name = NULL},
+ }
+};
diff --git a/tests/core/Makefile b/tests/core/Makefile
index 3568fd0..9ede6dc 100644
--- a/tests/core/Makefile
+++ b/tests/core/Makefile
@@ -2,13 +2,13 @@ TOPDIR=../..
include $(TOPDIR)/pre.mk
-CSOURCES=Context.c Pixel.c
+CSOURCES=Context.c Pixel.c BlitClipped.c
GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c Convert.gen.c BlitConv.gen.c Convert_Scale.gen.c GetSetBits.gen.c
APPS=WritePixel.gen Pixel Context GetPutPixel.gen Convert.gen BlitConv.gen - Convert_Scale.gen GetSetBits.gen
+ Convert_Scale.gen GetSetBits.gen BlitClipped
include ../tests.mk
diff --git a/tests/core/test_list.txt b/tests/core/test_list.txt
index 5fbaeba..c728b8b 100644
--- a/tests/core/test_list.txt
+++ b/tests/core/test_list.txt
@@ -7,3 +7,4 @@ GetPutPixel.gen
Convert.gen
Convert_Scale.gen
BlitConv.gen
+BlitClipped
http://repo.or.cz/w/gfxprim.git/commit/d0202e863397c4427f5bb8163de13764e98d…
commit d0202e863397c4427f5bb8163de13764e98dcb31
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Nov 14 23:32:15 2013 +0100
tests: framework: Finish and rename malloc barriers
Rename malloc barriers to malloc canaries and plug them
into the malloc tracking code, so that they could be enabled
for all malloc() calls.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/framework/Makefile b/tests/framework/Makefile
index f7ceb2e..15cd84a 100644
--- a/tests/framework/Makefile
+++ b/tests/framework/Makefile
@@ -14,7 +14,7 @@ APPS=test
ALL+=libtst_preload.so libtst.a
-libtst_preload.so: tst_preload.o tst_alloc_barriers.o tst_preload_FILE.o
+libtst_preload.so: tst_preload.o tst_malloc_canaries.o tst_preload_FILE.o
$(CC) -Wl,-soname -Wl,tst_preload.so --shared -ldl -fPIC $^ -o $@
libtst.a: tst_suite.o tst_job.o tst_msg.o tst_log.o tst_main.o tst_timespec.o
diff --git a/tests/framework/test.c b/tests/framework/test.c
index db42323..3fbbc8d 100644
--- a/tests/framework/test.c
+++ b/tests/framework/test.c
@@ -27,7 +27,7 @@
#include <string.h>
#include "tst_test.h"
-#include "tst_alloc_barriers.h"
+#include "tst_malloc_canaries.h"
#include "tst_preload_FILE.h"
int success_fn(void)
@@ -120,9 +120,9 @@ int double_free(void)
return TST_SUCCESS;
}
-int barrier_allocation(void)
+int canary_allocation(void)
{
- char *buf = tst_alloc_barrier_right(31);
+ char *buf = tst_malloc_canary_right(31);
int i;
@@ -262,7 +262,7 @@ const struct tst_suite tst_suite = {
{.name = "Mem Leak test", .tst_fn = malloc_leak_fn, .flags = TST_CHECK_MALLOC},
{.name = "Mem Ok test", .tst_fn = malloc_ok_fn, .flags = TST_CHECK_MALLOC},
{.name = "Double free()", .tst_fn = double_free},
- {.name = "Barrier allocation", .tst_fn = barrier_allocation},
+ {.name = "Canary allocation", .tst_fn = canary_allocation},
{.name = "Failed FILE", .tst_fn = fail_FILE, .flags = TST_TMPDIR},
{.name = "Resource", .tst_fn = res_fn, .flags = TST_TMPDIR,
.res_path = "test.c"},
diff --git a/tests/framework/tst_alloc_barriers.c b/tests/framework/tst_malloc_canaries.c
similarity index 91%
rename from tests/framework/tst_alloc_barriers.c
rename to tests/framework/tst_malloc_canaries.c
index 567e462..40f16c9 100644
--- a/tests/framework/tst_alloc_barriers.c
+++ b/tests/framework/tst_malloc_canaries.c
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -25,9 +25,9 @@
#include <stdlib.h>
#include <unistd.h>
-#include "tst_alloc_barriers.h"
+#include "tst_malloc_canaries.h"
-void *tst_alloc_barrier_right(size_t size)
+void *tst_malloc_canary_right(size_t size)
{
size_t pagesize = sysconf(_SC_PAGESIZE);
size_t pages = size/pagesize + !!(size%pagesize) + 1;
@@ -50,7 +50,7 @@ void *tst_alloc_barrier_right(size_t size)
return buf + (pagesize - size%pagesize);
}
-void tst_free_barrier_right(void *ptr, size_t size)
+void tst_free_canary_right(void *ptr, size_t size)
{
size_t pagesize = sysconf(_SC_PAGESIZE);
size_t pages = size/pagesize + !!(size%pagesize);
@@ -64,7 +64,7 @@ void tst_free_barrier_right(void *ptr, size_t size)
free(start);
}
-void *tst_alloc_barrier_left(size_t size)
+void *tst_malloc_canary_left(size_t size)
{
size_t pagesize = sysconf(_SC_PAGESIZE);
size_t pages = size/pagesize + !!(size%pagesize) + 1;
@@ -87,7 +87,7 @@ void *tst_alloc_barrier_left(size_t size)
return buf + pagesize;
}
-void tst_free_barrier_left(void *ptr, size_t size __attribute__((unused)))
+void tst_free_canary_left(void *ptr, size_t size __attribute__((unused)))
{
size_t pagesize = sysconf(_SC_PAGESIZE);
void *start = ptr - pagesize;
diff --git a/tests/framework/tst_alloc_barriers.h b/tests/framework/tst_malloc_canaries.h
similarity index 78%
rename from tests/framework/tst_alloc_barriers.h
rename to tests/framework/tst_malloc_canaries.h
index dc6b12d..ca07190 100644
--- a/tests/framework/tst_alloc_barriers.h
+++ b/tests/framework/tst_malloc_canaries.h
@@ -16,45 +16,45 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
/*
- This code could create a buffer with either left or right barrier. Barrier is
+ This code could create a buffer with either left or right canary. Canary is
a page that exists right before respectively right after the buffer and is
set to PROT_NONE (reading or writing at adresses in such page causes
Segmentation Fault).
*/
-#ifndef TST_ALLOC_BARRIERS_H
-#define TST_ALLOC_BARRIERS_H
+#ifndef TST_ALLOC_CANARY_H
+#define TST_ALLOC_CANARY_H
/*
- * Allocate memory with a barrier page at the right side of the buffer
+ * Allocate memory with a canary page at the right side of the buffer
* (right == higher addresses).
*
* Returns NULL in case allocation or mprotect has failed.
*/
-void *tst_alloc_barrier_right(size_t size);
+void *tst_malloc_canary_right(size_t size);
/*
* Free allocated buffer.
*/
-void tst_free_barrier_right(void *ptr, size_t size);
+void tst_free_canary_right(void *ptr, size_t size);
/*
- * Allocate memory with barrier page at the left side of the buffer.
+ * Allocate memory with canary page at the left side of the buffer.
*
* Returns NULL in case allocation or mprotect has failed.
*/
-void *tst_alloc_barrier_left(size_t size);
+void *tst_malloc_canary_left(size_t size);
/*
* Free allocated buffer.
*/
-void tst_free_barrier_left(void *ptr, size_t size);
+void tst_free_canary_left(void *ptr, size_t size);
-#endif /* TST_ALLOC_BARRIERS_H */
+#endif /* TST_ALLOC_CANARY_H */
diff --git a/tests/framework/tst_preload.c b/tests/framework/tst_preload.c
index 9205a66..9436c2c 100644
--- a/tests/framework/tst_preload.c
+++ b/tests/framework/tst_preload.c
@@ -16,19 +16,30 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdint.h>
+#include <string.h>
#include <dlfcn.h>
#include "tst_test.h"
#include "tst_preload.h"
+#include "tst_malloc_canaries.h"
static int check_malloc = 0;
+static int malloc_canary = MALLOC_CANARY_OFF;
+
+static size_t cur_size = 0;
+static unsigned int cur_chunks = 0;
+static size_t total_size = 0;
+static unsigned int total_chunks = 0;
+/* Maximal allocated size at a time */
+static size_t max_size = 0;
+static unsigned int max_chunks = 0;
void tst_malloc_check_start(void)
{
@@ -37,16 +48,35 @@ void tst_malloc_check_start(void)
void tst_malloc_check_stop(void)
{
+ /*
+ * We cannot stop the tracing when canaries are on
+ * because we need the chunk table to keep track
+ * which allocations are with canary and their
+ * sizes for free and realloc.
+ */
+ if (malloc_canary != MALLOC_CANARY_OFF) {
+ tst_warn("Cannot turn malloc checks off when canaries are on");
+ return;
+ }
+
check_malloc = 0;
}
-static size_t cur_size = 0;
-static unsigned int cur_chunks = 0;
-static size_t total_size = 0;
-static unsigned int total_chunks = 0;
-/* Maximal allocated size at a time */
-static size_t max_size = 0;
-static unsigned int max_chunks = 0;
+void tst_malloc_canaries_set(enum tst_malloc_canary canary)
+{
+ if (!check_malloc) {
+ tst_warn("Cannot turn canaries on when checking is off");
+ return;
+ }
+
+ if (canary > MALLOC_CANARY_END) {
+ tst_warn("Invalid canary type");
+ return;
+ }
+
+ malloc_canary = canary;
+}
+
void tst_malloc_check_report(struct malloc_stats *stats)
{
@@ -65,6 +95,7 @@ void tst_malloc_check_report(struct malloc_stats *stats)
struct chunk {
void *ptr;
size_t size;
+ enum tst_malloc_canary canary;
int cont;
};
@@ -82,6 +113,7 @@ static void add_chunk(size_t size, void *ptr)
/* Store chunk */
chunks[chunks_top].size = size;
chunks[chunks_top].ptr = ptr;
+ chunks[chunks_top].canary = malloc_canary;
chunks_top++;
/* Update global stats */
@@ -117,14 +149,40 @@ static void rem_chunk(void *ptr)
tst_warn("Chunk passed to free not found (%p)", ptr);
}
+static struct chunk *get_chunk(void *ptr)
+{
+ unsigned int i;
+
+ for (i = 0; i < chunks_top; i++) {
+ if (chunks[i].ptr == ptr)
+ return &chunks[i];
+ }
+
+ return NULL;
+}
+
void *malloc(size_t size)
{
static void *(*real_malloc)(size_t) = NULL;
+ void *ptr;
if (!real_malloc)
real_malloc = dlsym(RTLD_NEXT, "malloc");
- void *ptr = real_malloc(size);
+ switch (malloc_canary) {
+ case MALLOC_CANARY_OFF:
+ ptr = real_malloc(size);
+ break;
+ case MALLOC_CANARY_BEGIN:
+ ptr = tst_malloc_canary_left(size);
+ break;
+ case MALLOC_CANARY_END:
+ ptr = tst_malloc_canary_right(size);
+ break;
+ /* Shut up gcc */
+ default:
+ return NULL;
+ }
if (check_malloc && ptr)
add_chunk(size, ptr);
@@ -132,15 +190,81 @@ void *malloc(size_t size)
return ptr;
}
+void free(void *ptr)
+{
+ static void (*real_free)(void *) = NULL;
+ struct chunk *chunk;
+
+ if (!real_free)
+ real_free = dlsym(RTLD_NEXT, "free");
+
+ if (!ptr)
+ return;
+
+ chunk = get_chunk(ptr);
+
+ /* Was allocated before malloc checking was turned on */
+ if (!chunk) {
+ real_free(ptr);
+ return;
+ }
+
+ switch (chunk->canary) {
+ case MALLOC_CANARY_OFF:
+ real_free(ptr);
+ break;
+ case MALLOC_CANARY_BEGIN:
+ tst_free_canary_left(ptr, chunk->size);
+ break;
+ case MALLOC_CANARY_END:
+ tst_free_canary_right(ptr, chunk->size);
+ break;
+ }
+
+ rem_chunk(ptr);
+}
+
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+
void *realloc(void *optr, size_t size)
{
static void *(*real_realloc)(void*, size_t) = NULL;
+ struct chunk *chunk;
+ void *ptr;
if (!real_realloc)
real_realloc = dlsym(RTLD_NEXT, "realloc");
- void *ptr = real_realloc(optr, size);
+ switch (malloc_canary) {
+ case MALLOC_CANARY_OFF:
+ ptr = real_realloc(optr, size);
+ break;
+ case MALLOC_CANARY_BEGIN:
+ case MALLOC_CANARY_END:
+ chunk = get_chunk(optr);
+ if (!chunk) {
+ tst_warn("%p allocated before checking was turned on, "
+ "using using real_realloc()", optr);
+
+ ptr = real_realloc(optr, size);
+
+ goto out;
+ }
+
+ ptr = malloc(size);
+
+ if (ptr) {
+ memcpy(ptr, optr, min(chunk->size, size));
+ free(optr);
+ }
+ break;
+ /* Shut up gcc */
+ default:
+ return NULL;
+ }
+
+out:
if (!ptr)
return NULL;
@@ -153,19 +277,6 @@ void *realloc(void *optr, size_t size)
return ptr;
}
-void free(void *ptr)
-{
- static void (*real_free)(void *) = NULL;
-
- if (!real_free)
- real_free = dlsym(RTLD_NEXT, "free");
-
- if (check_malloc && ptr != NULL)
- rem_chunk(ptr);
-
- real_free(ptr);
-}
-
void tst_malloc_print(const struct malloc_stats *stats)
{
fprintf(stderr, "Total size %zu chunks %u, lost size %zu chunks %un",
diff --git a/tests/framework/tst_preload.h b/tests/framework/tst_preload.h
index 0c44d3d..b4922c4 100644
--- a/tests/framework/tst_preload.h
+++ b/tests/framework/tst_preload.h
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -33,6 +33,25 @@ void tst_malloc_check_start(void);
*/
void tst_malloc_check_stop(void);
+enum tst_malloc_canary {
+ MALLOC_CANARY_OFF,
+ /* canary before the chunk */
+ MALLOC_CANARY_BEGIN,
+ /* canary after the chunk */
+ MALLOC_CANARY_END,
+};
+
+/*
+ * Turns on malloc canaries.
+ *
+ * If turned on each malloc gets a canary (a page with both read and write
+ * turned off) allocated at the end or at the start of the allocated chunk.
+ *
+ * Canaries cannot be turned on when malloc checking is off, and malloc checking
+ * cannot be turned off when canaries are turned on.
+ */
+void tst_malloc_canaries_set(enum tst_malloc_canary canary);
+
struct malloc_stats {
/*
* Sum of all alocated chunks.
http://repo.or.cz/w/gfxprim.git/commit/24824d445743e205a9afb6a218c93a5bc4a8…
commit 24824d445743e205a9afb6a218c93a5bc4a883c0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Nov 14 19:39:27 2013 +0100
backends: X11: Fix memleak.
Free the array of supported _NET_WM Atoms.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/backends/GP_X11_Conn.h b/libs/backends/GP_X11_Conn.h
index 3bbd683..4c5d732 100644
--- a/libs/backends/GP_X11_Conn.h
+++ b/libs/backends/GP_X11_Conn.h
@@ -89,6 +89,8 @@ static void x11_detect_wm_features(void)
for (i = 0; i < count; i++)
x11_check_atoms(args[i]);
+
+ XFree(args);
}
}
-----------------------------------------------------------------------
Summary of changes:
libs/backends/GP_X11_Conn.h | 2 +
tests/core/BlitClipped.c | 237 ++++++++++++++++++++
tests/core/Makefile | 4 +-
tests/core/test_list.txt | 1 +
tests/framework/Makefile | 2 +-
tests/framework/test.c | 8 +-
...{tst_alloc_barriers.c => tst_malloc_canaries.c} | 12 +-
...{tst_alloc_barriers.h => tst_malloc_canaries.h} | 22 +-
tests/framework/tst_preload.c | 157 +++++++++++--
tests/framework/tst_preload.h | 21 ++-
10 files changed, 418 insertions(+), 48 deletions(-)
create mode 100644 tests/core/BlitClipped.c
rename tests/framework/{tst_alloc_barriers.c => tst_malloc_canaries.c} (91%)
rename tests/framework/{tst_alloc_barriers.h => tst_malloc_canaries.h} (78%)
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
13 Nov '13
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 98c0bddd4c211b197d0186f2fcb7db48d3a46ace (commit)
from e9b780c9bbc1f2717fec705a0b2b5dff22d7845b (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/98c0bddd4c211b197d0186f2fcb7db48d3a4…
commit 98c0bddd4c211b197d0186f2fcb7db48d3a46ace
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Nov 13 23:20:49 2013 +0100
backends: X11: Ignore Win Resize request in FullScreen
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index ffa0b9c..b938db4 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -229,14 +229,18 @@ static int x11_set_attributes(struct GP_Backend *self,
}
if (w != 0 && h != 0) {
+ if (win->fullscreen_flag) {
+ GP_DEBUG(1, "Ignoring resize request in fullscreen");
+ goto out;
+ }
GP_DEBUG(3, "Setting window size to %ux%u", w, h);
XResizeWindow(win->dpy, win->win, w, h);
}
XFlush(win->dpy);
+out:
XUnlockDisplay(win->dpy);
-
return 0;
}
diff --git a/libs/backends/GP_X11_Win.h b/libs/backends/GP_X11_Win.h
index 1a81fc5..2fc3098 100644
--- a/libs/backends/GP_X11_Win.h
+++ b/libs/backends/GP_X11_Win.h
@@ -51,6 +51,7 @@ struct x11_win {
/* Flags */
int resized_flag:1;
int shm_flag:1;
+ int fullscreen_flag:1;
/* used to store width and height from ConfigureNotify event */
unsigned int new_w;
@@ -95,22 +96,48 @@ static int win_list_empty(void)
return win_list == NULL;
}
+#ifndef _NET_WM_STATE_REMOVE
+# define _NET_WM_STATE_REMOVE 0
+#endif
+
+#ifndef _NET_WM_STATE_ADD
+# define _NET_WM_STATE_ADD 1
+#endif
+
+#ifndef _NET_WM_STATE_TOGGLE
+# define _NET_WM_STATE_TOGGLE 2
+#endif
+
/* Send NETWM message, most modern Window Managers should understand */
static void x11_win_fullscreen(struct x11_win *win, int mode)
{
+ int fs;
XEvent ev;
- if (mode < 0 || mode > 2) {
+ switch (mode) {
+ case _NET_WM_STATE_REMOVE:
+ fs = 0;
+ break;
+ case _NET_WM_STATE_ADD:
+ fs = 1;
+ break;
+ case _NET_WM_STATE_TOGGLE:
+ fs = !win->fullscreen_flag;
+ break;
+ default:
GP_WARN("Invalid fullscreen mode = %u", mode);
return;
}
+ if (fs == win->fullscreen_flag)
+ return;
+
if (!x11_conn.S__NET_WM_STATE || !x11_conn.S__NET_WM_STATE_FULLSCREEN) {
GP_WARN("NetWM Fullscreen not supported");
return;
}
- GP_DEBUG(2, "Requesting fullscreen mode = %u", mode);
+ GP_DEBUG(2, "Requesting fullscreen mode = %u, fs = %i", mode, fs);
memset(&ev, 0, sizeof(ev));
@@ -129,6 +156,8 @@ static void x11_win_fullscreen(struct x11_win *win, int mode)
return;
}
+ win->fullscreen_flag = fs;
+
XFlush(win->dpy);
}
@@ -169,6 +198,8 @@ static int x11_win_open(struct x11_wreq *wreq)
win = wreq->win;
+ win->fullscreen_flag = 0;
+
/* Copy display */
win->dpy = x11_conn.dpy;
-----------------------------------------------------------------------
Summary of changes:
libs/backends/GP_X11.c | 6 +++++-
libs/backends/GP_X11_Win.h | 35 +++++++++++++++++++++++++++++++++--
2 files changed, 38 insertions(+), 3 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
13 Nov '13
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 e9b780c9bbc1f2717fec705a0b2b5dff22d7845b (commit)
via 4bd28f1260ee4a4e42fd57cac23a64de3892076e (commit)
from 88eea356e8494dea8645470506f2087b104d4326 (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/e9b780c9bbc1f2717fec705a0b2b5dff22d7…
commit e9b780c9bbc1f2717fec705a0b2b5dff22d7845b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Nov 13 22:48:33 2013 +0100
pywrap: core: Remove/ignore a few functions.
This removes/makes swig ignore a few functions that are not usable from
python and generate warnings.
* Remove GP_Common.h, there is noting that can be used pyton there.
* Ignore GP_DebugPrint(), again not usable.
* Ignore Callback operations.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i
index 74dbb04..8f578d2 100644
--- a/pylib/gfxprim/core/core.i
+++ b/pylib/gfxprim/core/core.i
@@ -9,7 +9,6 @@
* Basic types and common methods
*/
-%include "GP_Common.h"
%include "GP_Core.h"
%include "GP_Types.h"
%include "GP_Transform.h"
@@ -24,6 +23,7 @@
%immutable GP_DebugMsg::fn;
%immutable GP_DebugMsg::line;
%immutable GP_DebugMsg::msg;
+%ignore GP_DebugPrint;
%include "GP_Debug.h"
@@ -62,6 +62,8 @@ static int GP_ProgressCallbackProxy(GP_ProgressCallback *self)
}
%}
+%ignore GP_ProgressCallbackReport;
+%ignore GP_ProgressCallbackDone;
%include "GP_ProgressCallback.h"
/*
http://repo.or.cz/w/gfxprim.git/commit/4bd28f1260ee4a4e42fd57cac23a64de3892…
commit 4bd28f1260ee4a4e42fd57cac23a64de3892076e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Nov 13 22:37:34 2013 +0100
filters: point: Remove the FilterArea.
It was wrong idea to begin with.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/filters/GP_ApplyTables.h b/include/filters/GP_ApplyTables.h
index d2a6948..93d1eac 100644
--- a/include/filters/GP_ApplyTables.h
+++ b/include/filters/GP_ApplyTables.h
@@ -43,9 +43,13 @@ typedef struct GP_FilterTables {
/*
* Generic point filter, applies corresponding table on bitmap.
*/
-int GP_FilterTablesApply(const GP_FilterArea *const area,
- const GP_FilterTables *const tables,
- GP_ProgressCallback *callback);
+int GP_FilterTablesApply(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
+ GP_Context *dst,
+ GP_Coord x_dst, GP_Coord y_dst,
+ const GP_FilterTables *const tables,
+ GP_ProgressCallback *callback);
/*
* Aloocates and initializes tables.
diff --git a/include/filters/GP_Filter.h b/include/filters/GP_Filter.h
index 69254a0..690a64b 100644
--- a/include/filters/GP_Filter.h
+++ b/include/filters/GP_Filter.h
@@ -34,29 +34,4 @@
#include "GP_FilterParam.h"
-/*
- * Describes filter source, destination and coordinates.
- *
- * For Alloc filter variants dst, dst_x and dst_y is ignored.
- */
-typedef struct GP_FilterArea {
- const GP_Context *src;
- GP_Coord src_x, src_y;
- GP_Size src_w, src_h;
-
- GP_Context *dst;
- GP_Coord dst_x, dst_y;
-
- void *priv;
-} GP_FilterArea;
-
-#define GP_FILTER_AREA_DEFAULT(srcc, dstc) - GP_FilterArea area = { - .src = srcc, - .src_x = 0, .src_y = 0, - .src_w = srcc->w, .src_h = srcc->h, - .dst = dstc, - .dst_x = 0, .dst_y = 0, - };
-
#endif /* FILTERS_GP_FILTER_H */
diff --git a/include/filters/GP_Point.h b/include/filters/GP_Point.h
index 6ebf48c..3c8e6ac 100644
--- a/include/filters/GP_Point.h
+++ b/include/filters/GP_Point.h
@@ -36,27 +36,33 @@
*
* Increments each pixel channel by a p * channel_max value.
*/
-int GP_FilterBrightnessEx(const GP_FilterArea *area, float p,
+int GP_FilterBrightnessEx(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
+ GP_Context *dst,
+ GP_Coord x_dst, GP_Coord y_dst,
+ float p,
GP_ProgressCallback *callback);
-GP_Context *GP_FilterBrightnessExAlloc(const GP_FilterArea *area, float p,
+GP_Context *GP_FilterBrightnessExAlloc(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
+ float p,
GP_ProgressCallback *callback);
static inline int GP_FilterBrightness(const GP_Context *src, GP_Context *dst,
float p, GP_ProgressCallback *callback)
{
- GP_FILTER_AREA_DEFAULT(src, dst);
-
- return GP_FilterBrightnessEx(&area, p, callback);
+ return GP_FilterBrightnessEx(src, 0, 0, src->w, src->h,
+ dst, 0, 0, p, callback);
}
static inline GP_Context *
GP_FilterBrightnessAlloc(const GP_Context *src, float p,
GP_ProgressCallback *callback)
{
- GP_FILTER_AREA_DEFAULT(src, NULL);
-
- return GP_FilterBrightnessExAlloc(&area, p, callback);
+ return GP_FilterBrightnessExAlloc(src, 0, 0, src->w, src->h,
+ p, callback);
}
/*
@@ -67,46 +73,57 @@ GP_FilterBrightnessAlloc(const GP_Context *src, float p,
* The parameters should have the same pixel channels as
* source pixel type and are expected to be float numbers.
*/
-int GP_FilterContrastEx(const GP_FilterArea *area, float p,
+int GP_FilterContrastEx(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
+ GP_Context *dst,
+ GP_Coord x_dst, GP_Coord y_dst,
+ float p,
GP_ProgressCallback *callback);
-GP_Context *GP_FilterContrastExAlloc(const GP_FilterArea *area, float p,
+GP_Context *GP_FilterContrastExAlloc(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
+ float p,
GP_ProgressCallback *callback);
static inline int GP_FilterContrast(const GP_Context *src, GP_Context *dst,
float p, GP_ProgressCallback *callback)
{
- GP_FILTER_AREA_DEFAULT(src, dst);
-
- return GP_FilterContrastEx(&area, p, callback);
+ return GP_FilterContrastEx(src, 0, 0, src->w, src->h,
+ dst, 0, 0, p, callback);
}
static inline GP_Context *GP_FilterContrastAlloc(const GP_Context *src,
float p,
GP_ProgressCallback *callback)
{
- GP_FILTER_AREA_DEFAULT(src, NULL);
-
- return GP_FilterContrastExAlloc(&area, p, callback);
+ return GP_FilterContrastExAlloc(src, 0, 0, src->w, src->h,
+ p, callback);
}
/*
* Brightness and Contrast combined.
*/
-int GP_FilterBrightnessContrastEx(const GP_FilterArea *area, float b, float c,
+int GP_FilterBrightnessContrastEx(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
+ GP_Context *dst,
+ GP_Coord x_dst, GP_Coord y_dst,
+ float b, float c,
GP_ProgressCallback *callback);
-GP_Context *GP_FilterBrightnessContrastExAlloc(const GP_FilterArea *area,
+GP_Context *GP_FilterBrightnessContrastExAlloc(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
float b, float c,
GP_ProgressCallback *callback);
-
static inline int
GP_FilterBrightnessContrast(const GP_Context *src, GP_Context *dst,
float b, float c, GP_ProgressCallback *callback)
{
- GP_FILTER_AREA_DEFAULT(src, dst);
-
- return GP_FilterBrightnessContrastEx(&area, b, c, callback);
+ return GP_FilterBrightnessContrastEx(src, 0, 0, src->w, src->h,
+ dst, 0, 0, b, c, callback);
}
static inline GP_Context *
@@ -114,9 +131,8 @@ GP_FilterBrightnessContrastAlloc(const GP_Context *src,
float b, float c,
GP_ProgressCallback *callback)
{
- GP_FILTER_AREA_DEFAULT(src, NULL);
-
- return GP_FilterBrightnessContrastExAlloc(&area, b, c, callback);
+ return GP_FilterBrightnessContrastExAlloc(src, 0, 0, src->w, src->h,
+ b, c, callback);
}
/*
@@ -124,10 +140,17 @@ GP_FilterBrightnessContrastAlloc(const GP_Context *src,
*
* Does quantization into steps regions.
*/
-int GP_FilterPosterizeEx(const GP_FilterArea *area, unsigned int steps,
+int GP_FilterPosterizeEx(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
+ GP_Context *dst,
+ GP_Coord x_dst, GP_Coord y_dst,
+ unsigned int steps,
GP_ProgressCallback *callback);
-GP_Context *GP_FilterPosterizeExAlloc(const GP_FilterArea *area,
+GP_Context *GP_FilterPosterizeExAlloc(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
unsigned int steps,
GP_ProgressCallback *callback);
@@ -135,43 +158,44 @@ static inline int GP_FilterPosterize(const GP_Context *src, GP_Context *dst,
unsigned int steps,
GP_ProgressCallback *callback)
{
- GP_FILTER_AREA_DEFAULT(src, dst);
-
- return GP_FilterPosterizeEx(&area, steps, callback);
+ return GP_FilterPosterizeEx(src, 0, 0, src->w, src->h,
+ dst, 0, 0, steps, callback);
}
static inline GP_Context *
GP_FilterPosterizeAlloc(const GP_Context *src, unsigned int steps,
GP_ProgressCallback *callback)
{
- GP_FILTER_AREA_DEFAULT(src, NULL);
-
- return GP_FilterPosterizeExAlloc(&area, steps, callback);
+ return GP_FilterPosterizeExAlloc(src, 0, 0, src->w, src->h,
+ steps, callback);
}
/*
* Inverts the pixel value, i.e. sets it to max - val.
*/
-int GP_FilterInvertEx(const GP_FilterArea *area,
+int GP_FilterInvertEx(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
+ GP_Context *dst,
+ GP_Coord x_dst, GP_Coord y_dst,
GP_ProgressCallback *callback);
-GP_Context *GP_FilterInvertExAlloc(const GP_FilterArea *area,
+GP_Context *GP_FilterInvertExAlloc(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
GP_ProgressCallback *callback);
static inline int GP_FilterInvert(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
- GP_FILTER_AREA_DEFAULT(src, dst);
-
- return GP_FilterInvertEx(&area, callback);
+ return GP_FilterInvertEx(src, 0, 0, src->w, src->h,
+ dst, 0, 0, callback);
}
static inline GP_Context *GP_FilterInvertAlloc(const GP_Context *src,
GP_ProgressCallback *callback)
{
- GP_FILTER_AREA_DEFAULT(src, NULL);
-
- return GP_FilterInvertExAlloc(&area, callback);
+ return GP_FilterInvertExAlloc(src, 0, 0, src->w, src->h, callback);
}
#endif /* FILTERS_GP_POINT_H */
diff --git a/libs/filters/GP_ApplyTables.gen.c.t b/libs/filters/GP_ApplyTables.gen.c.t
index 566d957..f166af3 100644
--- a/libs/filters/GP_ApplyTables.gen.c.t
+++ b/libs/filters/GP_ApplyTables.gen.c.t
@@ -38,26 +38,28 @@ Generic Point filer
%% for pt in pixeltypes
%% if not pt.is_unknown() and not pt.is_palette()
-static int apply_tables_{{ pt.name }}(const GP_FilterArea *const area,
+static int apply_tables_{{ pt.name }}(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
+ GP_Context *dst,
+ GP_Coord x_dst, GP_Coord y_dst,
const GP_FilterTables *const tables,
GP_ProgressCallback *callback)
{
- GP_DEBUG(1, "Point filter %ux%u", area->src_w, area->src_h);
+ GP_DEBUG(1, "Point filter %ux%u", w_src, h_src);
unsigned int x, y;
- const GP_Context *src = area->src;
- GP_Context *dst = area->dst;
%% for c in pt.chanslist
GP_Pixel {{ c.name }};
%% endfor
- for (y = 0; y < area->src_h; y++) {
- for (x = 0; x < area->src_w; x++) {
- unsigned int src_x = area->src_x + x;
- unsigned int src_y = area->src_y + y;
- unsigned int dst_x = area->dst_x + x;
- unsigned int dst_y = area->dst_y + y;
+ for (y = 0; y < h_src; y++) {
+ for (x = 0; x < w_src; x++) {
+ unsigned int src_x = x_src + x;
+ unsigned int src_y = y_src + y;
+ unsigned int dst_x = x_dst + x;
+ unsigned int dst_y = y_dst + y;
GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, src_x, src_y);
@@ -70,7 +72,7 @@ static int apply_tables_{{ pt.name }}(const GP_FilterArea *const area,
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, dst_x, dst_y, pix);
}
- if (GP_ProgressCallbackReport(callback, y, area->src_h, area->src_w)) {
+ if (GP_ProgressCallbackReport(callback, y, h_src, w_src)) {
errno = ECANCELED;
return 1;
}
@@ -84,18 +86,25 @@ static int apply_tables_{{ pt.name }}(const GP_FilterArea *const area,
%% endif
%% endfor
-int GP_FilterTablesApply(const GP_FilterArea *const area,
+int GP_FilterTablesApply(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
+ GP_Context *dst,
+ GP_Coord x_dst, GP_Coord y_dst,
const GP_FilterTables *const tables,
GP_ProgressCallback *callback)
{
- GP_ASSERT(area->src->pixel_type == area->dst->pixel_type);
+ GP_ASSERT(src->pixel_type == dst->pixel_type);
//TODO: Assert size
- switch (area->src->pixel_type) {
+ switch (src->pixel_type) {
%% for pt in pixeltypes
%% if not pt.is_unknown() and not pt.is_palette()
case GP_PIXEL_{{ pt.name }}:
- return apply_tables_{{ pt.name }}(area, tables, callback);
+ return apply_tables_{{ pt.name }}(src, x_src, y_src,
+ w_src, h_src, dst,
+ x_dst, y_dst,
+ tables, callback);
break;
%% endif
%% endfor
diff --git a/pylib/templates/filter.point.c.t b/pylib/templates/filter.point.c.t
index bdd0679..155870e 100644
--- a/pylib/templates/filter.point.c.t
+++ b/pylib/templates/filter.point.c.t
@@ -10,8 +10,13 @@
%% endmacro
%% macro filter_point_ex(op_name, filter_op, fopts)
-int GP_Filter{{ op_name }}Ex(const GP_FilterArea *const area{{ maybe_opts_l(fopts) }},
- GP_ProgressCallback *callback)
+int GP_Filter{{ op_name }}Ex(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
+ GP_Context *dst,
+ GP_Coord x_dst, GP_Coord y_dst,
+ {{ maybe_opts_r(fopts) }}
+ GP_ProgressCallback *callback)
{
const GP_PixelTypeDescription *desc;
GP_FilterTables tables;
@@ -19,10 +24,10 @@ int GP_Filter{{ op_name }}Ex(const GP_FilterArea *const area{{ maybe_opts_l(fopt
GP_Pixel j;
int ret, err;
- if (GP_FilterTablesInit(&tables, area->src))
+ if (GP_FilterTablesInit(&tables, src))
return 1;
- desc = GP_PixelTypeDesc(area->src->pixel_type);
+ desc = GP_PixelTypeDesc(src->pixel_type);
for (i = 0; i < desc->numchannels; i++) {
GP_Pixel chan_max = (1 << desc->channels[i].size);
@@ -32,7 +37,8 @@ int GP_Filter{{ op_name }}Ex(const GP_FilterArea *const area{{ maybe_opts_l(fopt
table[j] = {{ filter_op('((signed)j)', '((signed)chan_max - 1)') }};
}
- ret = GP_FilterTablesApply(area, &tables, callback);
+ ret = GP_FilterTablesApply(src, x_src, y_src, w_src, h_src,
+ dst, x_dst, y_dst, &tables, callback);
err = errno;
GP_FilterTablesFree(&tables);
@@ -43,19 +49,17 @@ int GP_Filter{{ op_name }}Ex(const GP_FilterArea *const area{{ maybe_opts_l(fopt
%% endmacro
%% macro filter_point_ex_alloc(op_name, fopts, opts)
-GP_Context *GP_Filter{{ op_name }}ExAlloc(const GP_FilterArea *const area{{ maybe_opts_l(fopts) }},
- GP_ProgressCallback *callback)
+GP_Context *GP_Filter{{ op_name }}ExAlloc(const GP_Context *const src,
+ GP_Coord x_src, GP_Coord y_src,
+ GP_Size w_src, GP_Size h_src,
+ {{ maybe_opts_r(fopts) }}
+ GP_ProgressCallback *callback)
{
- GP_FilterArea carea = *area;
- GP_Context *new = GP_ContextAlloc(area->src_w, area->src_h,
- area->src->pixel_type);
+ GP_Context *new = GP_ContextAlloc(w_src, h_src,
+ src->pixel_type);
- /* Clear these just to be sure */
- carea.dst_x = 0;
- carea.dst_y = 0;
- carea.dst = new;
-
- if (GP_Filter{{ op_name }}Ex(&carea, {{ maybe_opts_r(opts) }}callback)) {
+ if (GP_Filter{{ op_name }}Ex(src, x_src, y_src, w_src, h_src, new, 0, 0,
+ {{ maybe_opts_r(opts) }}callback)) {
int err = errno;
GP_ContextFree(new);
errno = err;
-----------------------------------------------------------------------
Summary of changes:
include/filters/GP_ApplyTables.h | 10 ++-
include/filters/GP_Filter.h | 25 --------
include/filters/GP_Point.h | 106 +++++++++++++++++++++-------------
libs/filters/GP_ApplyTables.gen.c.t | 39 ++++++++-----
pylib/gfxprim/core/core.i | 4 +-
pylib/templates/filter.point.c.t | 36 +++++++-----
6 files changed, 119 insertions(+), 101 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