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 62c398e8f845bbe95f0af0e64ab2d9670c6b59af (commit) via 7bec5898aaebb798e08f348503b7df5df1d515ad (commit) from 88500942a4e2dda6951c5abaf6bc05e4bb5d6efc (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/62c398e8f845bbe95f0af0e64ab2d9670c6b5...
commit 62c398e8f845bbe95f0af0e64ab2d9670c6b59af Author: Cyril Hrubis metan@ucw.cz Date: Thu Jun 27 22:24:22 2013 +0200
tests: filters: Add common.o to CLEAN.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/filters/Makefile b/tests/filters/Makefile index bda08a5..986710f 100644 --- a/tests/filters/Makefile +++ b/tests/filters/Makefile @@ -11,6 +11,8 @@ include ../tests.mk
FilterMirrorH: common.o
+CLEAN+=common.o + include $(TOPDIR)/gen.mk include $(TOPDIR)/app.mk include $(TOPDIR)/post.mk
http://repo.or.cz/w/gfxprim.git/commit/7bec5898aaebb798e08f348503b7df5df1d51...
commit 7bec5898aaebb798e08f348503b7df5df1d515ad Author: Cyril Hrubis metan@ucw.cz Date: Thu Jun 27 22:22:22 2013 +0200
Remove traling whitespaces.
Remove all trailing whitespaces, spaces before tabs and add GPL headers to two sources in gfx.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/configure b/configure index 107db2d..971a960 100755 --- a/configure +++ b/configure @@ -9,9 +9,9 @@ import subprocess
def header_exists(cfg, filename): fpath = cfg['include_path'][0] + '/' + filename - + sys.stderr.write("Checking for '%s' ... " % fpath) - + try: st = os.stat(fpath) sys.stderr.write("Yesn") @@ -23,9 +23,9 @@ def header_exists(cfg, filename): def c_try_compile(cfg, code, msg): sys.stderr.write(msg)
- ret = os.system("echo '%s' | %s -x c -o /dev/null - > /dev/null 2>&1" % + ret = os.system("echo '%s' | %s -x c -o /dev/null - > /dev/null 2>&1" % (code, cfg["CC"][0])) - + if ret: sys.stderr.write("Non") return False @@ -111,7 +111,7 @@ class libraries:
sys.stderr.write("Libraries to link againstn") sys.stderr.write("-------------------------n") - + for i in self.libraries: sys.stderr.write("%10s" % i[0])
@@ -208,8 +208,8 @@ def basic_checks(cfg):
check_for_swig(cfg) check_for_python_config(cfg) - - cfg['PYTHON_VER'][0] = python_version(cfg) + + cfg['PYTHON_VER'][0] = python_version(cfg)
if cfg['libdir'][0] == '': sys.stderr.write("Checking for lib directory ... ") @@ -266,7 +266,7 @@ def write_gfxprim_config(cfg, libs): f.write('t--cflags) echo -n "-I/usr/include/GP/%s";;n' % libs.get_cflags('core')) f.write('t--libs) echo -n "-lGP -lrt -lm %s ";;n' % libs.get_linker_flags('core')) - + # ldflags for specific modules for i in modules: ldflags = '' @@ -348,8 +348,8 @@ if __name__ == '__main__':
# Get configuration parameters from environment variables for i in cfg: - if i in os.environ: - cfg[i][0] = os.environ[i] + if i in os.environ: + cfg[i][0] = os.environ[i]
# Enable disable libraries for linking parser.add_option("-e", "--enable", dest="enable", action="append", @@ -363,10 +363,10 @@ if __name__ == '__main__':
(options, args) = parser.parse_args();
- # + # # Enable/Disable libraries as user requested # These are not checked later - # + # if options.enable: for i in options.enable: l.set(i, True); @@ -379,7 +379,7 @@ if __name__ == '__main__': cfg[i][0] = getattr(options, i)
basic_checks(cfg); - + l.check() l.print_summary()
diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h index e623eda..f94252c 100644 --- a/include/backends/GP_Backend.h +++ b/include/backends/GP_Backend.h @@ -45,7 +45,7 @@ #include "core/GP_Context.h"
#include "input/GP_EventQueue.h" -#include "input/GP_Timer.h" +#include "input/GP_Timer.h"
typedef struct GP_Backend { /* @@ -53,7 +53,7 @@ typedef struct GP_Backend { */ const char *name;
- /* + /* * Pointer to context app should draw to. * * This MAY change upon a flip operation. @@ -107,8 +107,8 @@ typedef struct GP_Backend { */ void (*Exit)(struct GP_Backend *self);
- /* - * Connection fd. Set to -1 if not available + /* + * Connection fd. Set to -1 if not available */ int fd;
diff --git a/include/backends/GP_BackendInit.h b/include/backends/GP_BackendInit.h index 6fcc997..db9fdda 100644 --- a/include/backends/GP_BackendInit.h +++ b/include/backends/GP_BackendInit.h @@ -43,9 +43,9 @@ * The caption parameter may, or may not be used. For example in windowed * enviroment caption will become caption of a window. When running on * framebuffer it may be ignored completly. - * + * * Returns initalized backend or NULL in case of failure. - * + * * If initialization has failed or params is NULL and help is not NULL, help * text is printed to a given file. */ diff --git a/include/backends/GP_BackendVirtual.h b/include/backends/GP_BackendVirtual.h index a050dc3..720f8c6 100644 --- a/include/backends/GP_BackendVirtual.h +++ b/include/backends/GP_BackendVirtual.h @@ -33,7 +33,7 @@ #include "GP_Backend.h"
enum GP_BackendVirtFlags { - /* + /* * If set virtual backend exit calls 'parent' Exit as well. */ GP_BACKEND_CALL_EXIT = 0x01, diff --git a/include/backends/GP_SDL.h b/include/backends/GP_SDL.h index 514f65d..7a88f05 100644 --- a/include/backends/GP_SDL.h +++ b/include/backends/GP_SDL.h @@ -35,12 +35,12 @@ enum GP_BackendSDLFlags { * Initalize SDL as drawing backend. * * * SDL doesn't expose file descriptors. - * + * * * The backend is thread safe (the critical parts are guarded with a mutex) - * + * * * The backend is singleton, you can't have two SDL backends running at the * same time. - * + * * * When backend is allready initalized, this function ignores it's parameters * and returns pointer to allready initalized SDL backend. * @@ -51,7 +51,7 @@ enum GP_BackendSDLFlags { * The parameters w h and bpp are directly passed to SDL_SetVideoMode(). * * * If w, h and/or bpp are set to zero, SDL tries to do best fit. - * + * * * The GP_BackendSDLFlags are converted into SDL equivalents. * * Upon failure, or if SDL wasn't compiled in, NULL is returned. diff --git a/include/backends/GP_X11.h b/include/backends/GP_X11.h index a196a31..192afc6 100644 --- a/include/backends/GP_X11.h +++ b/include/backends/GP_X11.h @@ -28,7 +28,7 @@ enum GP_BackendX11Flags { /* When set, w and h is ignored and root window is used */ GP_X11_USE_ROOT_WIN = 0x01, - + /* Create new borderless window above the root window */ GP_X11_CREATE_ROOT_WIN = 0x02,
@@ -45,9 +45,9 @@ enum GP_BackendX11Flags { * * The display may be NULL for default display ($DISPLAY shell variable will * be used). - * + * * The coordinates are position and geometry for newly created window. - * + * * Upon failure NULL is returned. */ GP_Backend *GP_BackendX11Init(const char *display, int x, int y, @@ -62,7 +62,7 @@ int GP_BackendIsX11(GP_Backend *self);
/* * Changes full screen mode. - * + * * 0 = off * 1 = on * 2 = toggle diff --git a/include/core/GP_BitSwap.h b/include/core/GP_BitSwap.h index 5ad76ad..b0f694b 100644 --- a/include/core/GP_BitSwap.h +++ b/include/core/GP_BitSwap.h @@ -21,7 +21,7 @@ *****************************************************************************/
/* - + Inline functions for swapping bits inside of the byte
*/ diff --git a/include/core/GP_Blit.h b/include/core/GP_Blit.h index 693d73b..caa4112 100644 --- a/include/core/GP_Blit.h +++ b/include/core/GP_Blit.h @@ -22,14 +22,14 @@ *****************************************************************************/
/* - + These blits automatically converts pixel types, that's good (and fast), but there is a catch. This works rather well when the number of colors per pixel/color channel is increased (the gamma correction is still on TODO). However when the number of colors is decreased it's generally better to use dithering, which will yield into far better (you can use Floyd Steinberg filter for that). - + Also variants without the _Raw suffix do honor the rotation flags, that may get a little tricky as the flags for rotation are put together but don't worry althouth there is some algebra involved the result is quite intuitive. diff --git a/include/core/GP_Clamp.h b/include/core/GP_Clamp.h index 6b6443a..ac87cb7 100644 --- a/include/core/GP_Clamp.h +++ b/include/core/GP_Clamp.h @@ -21,7 +21,7 @@ *****************************************************************************/
/* - + Fast clamping.
*/ diff --git a/include/core/GP_Color.h b/include/core/GP_Color.h index 4c3233b..de87e6a 100644 --- a/include/core/GP_Color.h +++ b/include/core/GP_Color.h @@ -26,7 +26,7 @@ /*
Color is enumeration of color names which may be converted into pixel values - in desired pixel format. + in desired pixel format.
*/
@@ -63,7 +63,7 @@ typedef enum GP_Color { GP_Pixel GP_ColorToPixel(GP_Color color, GP_PixelType pixel_type);
/* - * Converts GP_Color to GP_Pixel. + * Converts GP_Color to GP_Pixel. */ static inline GP_Pixel GP_ColorToContextPixel(GP_Color color, GP_Context *context) @@ -93,7 +93,7 @@ bool GP_ColorNameToPixel(const char *color_name, GP_PixelType pixel_type,
/* * Converts Color name to Pixel. - * + * * Returns true if conversion was successful false otherwise. */ static inline bool GP_ColorNameToContextPixel(const char *color_name, diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h index 17d61b8..40b3c09 100644 --- a/include/core/GP_Common.h +++ b/include/core/GP_Common.h @@ -120,7 +120,7 @@ abort(); } while (0)
-/* +/* * Print as much trace info as possible. Currently, the (C) call stack and * the Python stack if a Python interpreter is set up. In case more wrappers * are written, it should print a trace for the currently active. diff --git a/include/core/GP_Context.h b/include/core/GP_Context.h index 83d3c10..a575522 100644 --- a/include/core/GP_Context.h +++ b/include/core/GP_Context.h @@ -41,15 +41,15 @@ typedef struct GP_Context { uint8_t bpp; /* pixel size in bits */ uint32_t bytes_per_row; uint32_t w; /* width in pixels */ - uint32_t h; /* height in pixels */ - /* + uint32_t h; /* height in pixels */ + /* * Row bit offset. The offset is ignored for byte aligned pixels. * Basically it's used for non aligned pixels with combination * with subcontextes. */ - uint8_t offset; + uint8_t offset;
- /* + /* * Pixel format. See GP_Pixel.gen.h and GP_Pixel.gen.c. */ enum GP_PixelType pixel_type; @@ -63,7 +63,7 @@ typedef struct GP_Context { */ struct GP_Gamma *gamma;
- /* + /* * Image orientation. Most common is landscape (0, 0, 0), * portrait with normal topleft corner is (1, 0, 0). */ @@ -137,11 +137,11 @@ GP_Context *GP_ContextInit(GP_Context *context, GP_Size w, GP_Size h, int GP_ContextResize(GP_Context *context, GP_Size w, GP_Size h);
enum GP_ContextCopyFlags { - /* + /* * Copy bitmap pixels too. If not set pixels are uninitalized. */ GP_COPY_WITH_PIXELS = 0x01, - /* + /* * Copy image rotation flags. If not set flags are set to (0, 0, 0). */ GP_COPY_WITH_ROTATION = 0x02, @@ -234,7 +234,7 @@ static inline void GP_ContextCopyRotation(const GP_Context *src, }
/* - * Returns context width and height taking the rotation flags into a account. + * Returns context width and height taking the rotation flags into a account. */ static inline GP_Size GP_ContextW(const GP_Context *context) { diff --git a/include/core/GP_Convert.h b/include/core/GP_Convert.h index 8b5fb6a..abf2df2 100644 --- a/include/core/GP_Convert.h +++ b/include/core/GP_Convert.h @@ -79,7 +79,7 @@ static inline GP_Pixel GP_RGBAToPixel(uint8_t r, uint8_t g, uint8_t b, * Converts a color specified by its R, G, B components to a pixel value * compatible with the specified context. */ -static inline GP_Pixel GP_RGBToContextPixel(uint8_t r, uint8_t g, uint8_t b, +static inline GP_Pixel GP_RGBToContextPixel(uint8_t r, uint8_t g, uint8_t b, const GP_Context *context) { return GP_RGBToPixel(r, g, b, context->pixel_type); @@ -89,7 +89,7 @@ static inline GP_Pixel GP_RGBToContextPixel(uint8_t r, uint8_t g, uint8_t b, * Converts a color specified by its R, G, B, A components to a pixel value * compatible with the specified context. */ -static inline GP_Pixel GP_RGBAToContextPixel(uint8_t r, uint8_t g, +static inline GP_Pixel GP_RGBAToContextPixel(uint8_t r, uint8_t g, uint8_t b, uint8_t a, const GP_Context *context) { @@ -104,7 +104,7 @@ static inline GP_Pixel GP_ConvertPixel(GP_Pixel pixel, GP_PixelType from, { return GP_RGBA8888ToPixel(GP_PixelToRGBA8888(pixel, from), to); } - + /* * Convert between pixel types of given contexts (excl. palette types) via * RGBA8888. diff --git a/include/core/GP_FnPerBpp.h b/include/core/GP_FnPerBpp.h index 11d12a3..8586468 100644 --- a/include/core/GP_FnPerBpp.h +++ b/include/core/GP_FnPerBpp.h @@ -34,7 +34,7 @@ * GP_Context or given GP_PixelType. * * Extra arguments are arguments to be passed to the function. - * Note that if the function takes the context/type/bpp as an argument, + * Note that if the function takes the context/type/bpp as an argument, * you still need to provide it in __VA_ARGS__ * * The GP_FN_PER_* variants ignore the return value of the called function. @@ -47,24 +47,24 @@ #include "GP_FnPerBpp.gen.h"
/* - * Branch on GP_Context argument. + * Branch on GP_Context argument. */ #define GP_FN_PER_BPP_CONTEXT(FN_NAME, context, ...) GP_FN_PER_BPP(FN_NAME, (context)->bpp, (context)->bit_endian, __VA_ARGS__)
/* - * Branch on GP_PixelType argument. + * Branch on GP_PixelType argument. */ #define GP_FN_PER_BPP_PIXELTYPE(FN_NAME, type, ...) GP_FN_PER_BPP(FN_NAME, GP_PixelTypes[type].size, GP_PixelTypes[type].bit_endian, __VA_ARGS__) /* - * Branch on GP_Context argument. + * Branch on GP_Context argument. */ #define GP_FN_RET_PER_BPP_CONTEXT(FN_NAME, context, ...) GP_FN_RET_PER_BPP(FN_NAME, (context)->bpp, (context)->bit_endian, __VA_ARGS__)
/* - * Branch on GP_PixelType argument. + * Branch on GP_PixelType argument. */ #define GP_FN_RET_PER_BPP_PIXELTYPE(FN_NAME, type, ...) GP_FN_RET_PER_BPP(FN_NAME, GP_PixelTypes[type].size, GP_PixelTypes[type].bit_endian, __VA_ARGS__) diff --git a/include/core/GP_Gamma.h b/include/core/GP_Gamma.h index 53e217e..6fffaac 100644 --- a/include/core/GP_Gamma.h +++ b/include/core/GP_Gamma.h @@ -57,7 +57,7 @@ */
/* - + This code implements management functions for easy, per context, per channel, gamma tables.
@@ -66,11 +66,11 @@
Also the table output, for linear values, has two more bits than original in order not to loose precision. - + The pointers to gamma tables are storied in GP_Gamma structure and are organized in the same order as channels. First N tables for each channel and - gamma value gamma, then N tables for inverse 1/gamma function. - + gamma value gamma, then N tables for inverse 1/gamma function. + So when we have RGB888 pixel and gamma 2.2 there are two tables in the memory, one for gamma 2.2 input 8bit output 10bit and it's inverse input 10bit output 8bit. The GP_Gamma contains six pointers. First three points to @@ -136,7 +136,7 @@ typedef struct GP_GammaTable { float gamma; uint8_t in_bits; uint8_t out_bits; - + /* Used for internal purpose */ unsigned int ref_count; struct GP_GammaTable *next; @@ -153,7 +153,7 @@ typedef struct GP_GammaTable { * * The GP_Gamma structure contains pointers to tables for each pixel * channel and for gamma and it's inverse transformation. - * + * * The interface is specially designed so that getting Gamma corrected value is * a matter of indexing two arrays. */ diff --git a/include/core/GP_GetPutPixel.h b/include/core/GP_GetPutPixel.h index 671a16e..6faf7b2 100644 --- a/include/core/GP_GetPutPixel.h +++ b/include/core/GP_GetPutPixel.h @@ -29,7 +29,7 @@ #include "GP_FnPerBpp.h" #include "GP_Pixel.h"
-/* +/* * Generated header */ #include "GP_GetPutPixel.gen.h" @@ -46,9 +46,9 @@ GP_Pixel GP_GetPixel(const GP_Context *context, GP_Coord x, GP_Coord y); static inline GP_Pixel GP_GetPixel_Raw(const GP_Context *context, GP_Coord x, GP_Coord y) { - GP_FN_RET_PER_BPP(GP_GetPixel_Raw, context->bpp, context->bit_endian, + GP_FN_RET_PER_BPP(GP_GetPixel_Raw, context->bpp, context->bit_endian, context, x, y); - + GP_ABORT("Invalid context pixel type"); }
@@ -76,7 +76,7 @@ void GP_PutPixel(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel p); static inline void GP_PutPixel_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel p) { - GP_FN_PER_BPP(GP_PutPixel_Raw, context->bpp, context->bit_endian, + GP_FN_PER_BPP(GP_PutPixel_Raw, context->bpp, context->bit_endian, context, x, y, p); }
diff --git a/include/core/GP_GetSetBits.h b/include/core/GP_GetSetBits.h index 40d6b81..1cd1e36 100644 --- a/include/core/GP_GetSetBits.h +++ b/include/core/GP_GetSetBits.h @@ -22,7 +22,7 @@ *****************************************************************************/
/* - + Helper macros to get/set bits given offset and lenght.
The GP_GET_BITS() and GP_SET_BITS() works __ONLY__ on aligned data types. @@ -42,10 +42,10 @@ #define CORE_GP_GET_SET_BITS_H
/* - * Helper macros to read/write parts of words + * Helper macros to read/write parts of words * * Return (shifted) count bits at offset of value - * Note: operates with value types same as val + * Note: operates with value types same as val */ #define GP_GET_BITS(offset, len, val) (sizeof(val) * 8 <= len ? @@ -91,9 +91,9 @@
/* * Set count bits of dest at ofset to val (shifted by offset) - * + * * Does not check val for overflow - * Operates on 8, 16, and 32 bit values, depending on the type of dest, + * Operates on 8, 16, and 32 bit values, depending on the type of dest, * this should be unsigned * * GP_SET_BITS_OR anly sets (|=) the bits, assuming these are clear beforehand diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h index 642f8b3..8c060f0 100644 --- a/include/core/GP_Pixel.h +++ b/include/core/GP_Pixel.h @@ -37,8 +37,8 @@ struct GP_Context;
/* - * GP_PixelType is typedef enum of PixelTypes, - * + * GP_PixelType is typedef enum of PixelTypes, + * * each named GP_PIXEL_<TYPENAME>, such as GP_PIXEL_RGB888 * see the beginning of GP_Pixel.gen.h for a complete list * @@ -58,8 +58,8 @@ typedef uint32_t GP_Pixel; #include "GP_GetSetBits.h"
/* - * Information about ordering of pixels in byte for 1, 2 and 4 bpp - * used in a one bit variable in GP_Context + * Information about ordering of pixels in byte for 1, 2 and 4 bpp + * used in a one bit variable in GP_Context */ typedef enum { /* less significant bits contain pixels with lower indices */ @@ -172,7 +172,7 @@ GP_PixelType GP_PixelTypeByName(const char *name); /* * Match pixel type to known pixel types. * - * Returns either valid PixelType or GP_PIXEL_UNKNOWN + * Returns either valid PixelType or GP_PIXEL_UNKNOWN */ GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask, GP_Pixel bmask, GP_Pixel amask, @@ -181,7 +181,7 @@ GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask, /* * Similar to GP_PixelRGBMatch but works with offsets and sizes * - * Returns either valid PixelType or GP_PIXEL_UNKNOWN + * Returns either valid PixelType or GP_PIXEL_UNKNOWN */ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff, uint32_t gsize, uint32_t goff, @@ -195,7 +195,7 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff, * Call as: * * if (GP_PixelHasFlags(pixel_type, GP_PIXEL_IS_RGB | GP_PIXEL_HAS_ALPHA)) - * ... + * ... */ int GP_PixelHasFlags(GP_PixelType pixel_type, GP_PixelFlags flags);
diff --git a/include/core/GP_ProgressCallback.h b/include/core/GP_ProgressCallback.h index e944154..850f480 100644 --- a/include/core/GP_ProgressCallback.h +++ b/include/core/GP_ProgressCallback.h @@ -43,15 +43,15 @@ */ typedef struct GP_ProgressCallback { float percentage; - + int (*callback)(struct GP_ProgressCallback *self); void *priv; - + /* * Number of threads to use (if supported). This setting could be used * to override the default number of threads as returned by * GP_NrThreads(). - * + * * 0 == use number returned from GP_NrThreads(). * * >= 1 use exactly n threads @@ -77,7 +77,7 @@ static inline void GP_ProgressCallbackDone(GP_ProgressCallback *callback) { if (callback == NULL) return; - + callback->percentage = 100; callback->callback(callback); } diff --git a/include/core/GP_Threads.h b/include/core/GP_Threads.h index 6cc4be6..69da584 100644 --- a/include/core/GP_Threads.h +++ b/include/core/GP_Threads.h @@ -81,7 +81,7 @@ struct GP_ProgressCallbackMPPriv { * ... * * for n threads: - * run_filter(..., callback ? &callback_mp : NULL); + * run_filter(..., callback ? &callback_mp : NULL); */ #define GP_PROGRESS_CALLBACK_MP(name, callback) struct GP_ProgressCallbackMPPriv name_priv = { diff --git a/include/core/GP_Transform.h b/include/core/GP_Transform.h index e903d69..5915c89 100644 --- a/include/core/GP_Transform.h +++ b/include/core/GP_Transform.h @@ -31,8 +31,8 @@ #include "GP_Common.h" #include "GP_FixedPoint.h"
-/* - * Flip a coordinate within context according to context transformation. +/* + * Flip a coordinate within context according to context transformation. */ #define GP_TRANSFORM_X(context, x) do { if ((context)->x_swap) @@ -57,17 +57,17 @@ y = GP_FP_FROM_INT((context)->h - 1) - y; } while (0)
-/* - * Swap coordinates (axes) according to context transformation. +/* + * Swap coordinates (axes) according to context transformation. */ #define GP_TRANSFORM_SWAP(context, x, y) do { if ((context)->axes_swap) GP_SWAP(x, y); } while (0)
-/* - * Transform "user"-coordinates to "real"-coordinates according to context - * transformation. +/* + * Transform "user"-coordinates to "real"-coordinates according to context + * transformation. */ #define GP_TRANSFORM_POINT(context, x, y) do { GP_TRANSFORM_SWAP(context, x, y); @@ -81,10 +81,10 @@ GP_TRANSFORM_Y_FP(context, y); } while (0)
-/* +/* * Transform "user"-coordinates to "real"-coordinates of a rectangle corner - * according to context transformation. Corner with min-coordinates is - * transformed to (different) corner with min-coordinates etc. + * according to context transformation. Corner with min-coordinates is + * transformed to (different) corner with min-coordinates etc. * Arguments x, y, w, h are modified. */ #define GP_TRANSFORM_RECT(context, x, y, w, h) do { @@ -109,7 +109,7 @@ y = GP_FP_FROM_INT((context)->h) - y - h; } while (0)
-/* +/* * Transform "user"-coordinates to "real"-coordinates for a blit * called as GP_Blit(c1, x1, y1, w, h, c2, x2, y2). * All x1, y1, x2, y2, w, h are adjusted. @@ -122,7 +122,7 @@ } while (0)
/* - * Inverse transformation to GP_TRANSFORM_POINT. + * Inverse transformation to GP_TRANSFORM_POINT. * Use for translating mouse pointer coordinates to coordinates on context. */ #define GP_RETRANSFORM_POINT(context, x, y) do { diff --git a/include/core/GP_Types.h b/include/core/GP_Types.h index e3d0f55..1b94743 100644 --- a/include/core/GP_Types.h +++ b/include/core/GP_Types.h @@ -25,8 +25,8 @@
#include <stdint.h>
-/* - * Integer type for coordinates: x, y, width, height, ... +/* + * Integer type for coordinates: x, y, width, height, ... * Should be signed to hold negative values as well. */ typedef int GP_Coord; diff --git a/include/filters/GP_Blur.h b/include/filters/GP_Blur.h index c008774..691955e 100644 --- a/include/filters/GP_Blur.h +++ b/include/filters/GP_Blur.h @@ -33,7 +33,7 @@
/* * Gaussian blur implemented using linear separable convolution. - * + * * The x_sigma defines the blur size in horizontal direction and y_sigma * defines blur on vertical direction. */ diff --git a/include/filters/GP_Convolution.h b/include/filters/GP_Convolution.h index 0cd9089..e8d30d0 100644 --- a/include/filters/GP_Convolution.h +++ b/include/filters/GP_Convolution.h @@ -36,23 +36,23 @@ * 2D convolution kernel. * * The kernel array size must be w * h. - * + * * The div is used to divide the resulting value which is commonly used for * normalization. * * Example box smoothing filter kernel initialization: * * float box_filter[] = { - * 1, 1, 1, - * 1, 1, 1, - * 1, 1, 1, + * 1, 1, 1, + * 1, 1, 1, + * 1, 1, 1, * }; * * GP_FilterKernel2D box_kernel = { - * .w = 3, - * .h = 3, - * .div = 9, - * .kernel = box_filter, + * .w = 3, + * .h = 3, + * .div = 9, + * .kernel = box_filter, * }; */ typedef struct GP_FilterKernel2D { diff --git a/include/filters/GP_FilterParam.h b/include/filters/GP_FilterParam.h index 6520354..31b7ab6 100644 --- a/include/filters/GP_FilterParam.h +++ b/include/filters/GP_FilterParam.h @@ -66,7 +66,7 @@ void GP_FilterParamDestroy(GP_FilterParam *self); /* * Takes array of filter parameters and returns filter parameter by a channel * name. - * + * * Returns NULL if channel wasn't found. */ GP_FilterParam *GP_FilterParamChannel(GP_FilterParam params[], diff --git a/include/filters/GP_GaussianNoise.h b/include/filters/GP_GaussianNoise.h index 135712b..e67fc2f 100644 --- a/include/filters/GP_GaussianNoise.h +++ b/include/filters/GP_GaussianNoise.h @@ -21,7 +21,7 @@ *****************************************************************************/
/* - + Additive Gaussian noise filters.
The sigma and mu parameters define the noise parameters. The sigma defines diff --git a/include/filters/GP_HilbertCurve.h b/include/filters/GP_HilbertCurve.h index f5283c8..d7ebd7c 100644 --- a/include/filters/GP_HilbertCurve.h +++ b/include/filters/GP_HilbertCurve.h @@ -55,7 +55,7 @@ static inline void GP_HilbertCurveInit(struct GP_CurveState *state, int n) static inline void GP_HilbertCurveGetXY(struct GP_CurveState *state) { int sa, sb; - /* + /* * Older gcc thinks that x and y are used uninitialized that is not * true so we silence the warning by initializing them. */ @@ -70,7 +70,7 @@ static inline void GP_HilbertCurveGetXY(struct GP_CurveState *state) x = y ^ (-sa); y = temp ^ (-sa); } - + x = (x >> 1) | (sa << 31); y = (y >> 1) | ((sa ^ sb) << 31); } diff --git a/include/filters/GP_Linear.h b/include/filters/GP_Linear.h index fe938f5..62ff12d 100644 --- a/include/filters/GP_Linear.h +++ b/include/filters/GP_Linear.h @@ -36,7 +36,7 @@ * * The kernel is array of kw * kh floats and is indexed as two directional * array. - * + * * The src coordinates and size defines rectangle in the source on which the * filter operates. * @@ -51,7 +51,7 @@ * }; * * kw = kh = 3 - * + * * kern_div = 9 */ int GP_FilterLinearConvolution_Raw(const GP_Context *src, diff --git a/include/filters/GP_Median.h b/include/filters/GP_Median.h index 4755961..0274b29 100644 --- a/include/filters/GP_Median.h +++ b/include/filters/GP_Median.h @@ -21,7 +21,7 @@ *****************************************************************************/
/* - + Constant time Median Filter (the computational complexity is independent of radius).
diff --git a/include/filters/GP_Point.h b/include/filters/GP_Point.h index 7032af3..42248a9 100644 --- a/include/filters/GP_Point.h +++ b/include/filters/GP_Point.h @@ -56,7 +56,7 @@ int GP_FilterContrast_Raw(const GP_Context *src, GP_Context *dst, GP_FilterParam params[], GP_ProgressCallback *callback);
-GP_Context *GP_FilterContrast(const GP_Context *src, GP_Context *dst, +GP_Context *GP_FilterContrast(const GP_Context *src, GP_Context *dst, GP_FilterParam params[], GP_ProgressCallback *callback);
diff --git a/include/filters/GP_Resize.h b/include/filters/GP_Resize.h index 7b1473c..31b96a0 100644 --- a/include/filters/GP_Resize.h +++ b/include/filters/GP_Resize.h @@ -44,7 +44,7 @@
Bicubic ~~~~~~~ - + Works well for upscaling as is. To get decent result on downscaling, low-pass filter (for example gaussian blur) must be used on original image before scaling is done. @@ -86,7 +86,7 @@ int GP_FilterResize_Raw(const GP_Context *src, GP_Context *dst, /* * If destination is non NULL, the w and h are used to create subcontext from * destination which is then used to interpolate the image to. - * + * * Otherwise if destination is NULL, the context of size w and h is allocated * and returned. * diff --git a/include/filters/GP_Rotate.h b/include/filters/GP_Rotate.h index 1da96c8..356ceb1 100644 --- a/include/filters/GP_Rotate.h +++ b/include/filters/GP_Rotate.h @@ -34,7 +34,7 @@
/* * Mirror horizontally. - * + * * Works 'in place'. The contexts must have equal pixel_type and size. * * This is semi-internal function without any assertions on destination. @@ -101,7 +101,7 @@ GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src, /* * Rotate context by 90, 180 and 270. * - * Doesn't work 'in place'. The contexts must have equal pixel_type size must + * Doesn't work 'in place'. The contexts must have equal pixel_type size must * match the rotated size (is equal for 180 and swapped for 90 and 270). * * These are semi-internal functions without any assertions on destination. @@ -139,7 +139,7 @@ GP_Context *GP_FilterRotate270Alloc(const GP_Context *src, GP_ProgressCallback *callback);
/* - * Calls a symmetry filter on bitmap. + * Calls a symmetry filter on bitmap. * * If dst is NULL, new bitmap is allocated. * @@ -162,7 +162,7 @@ extern const char **GP_FilterSymmetryNames;
/* * Symmetry by name (as defined in GP_FilerSymmetryNames). - * + * * Returns either one of the GP_FilterSymmetries enums or -1 in case of * failure. */ diff --git a/include/filters/GP_Sigma.h b/include/filters/GP_Sigma.h index e7db9d0..01f1cf4 100644 --- a/include/filters/GP_Sigma.h +++ b/include/filters/GP_Sigma.h @@ -21,14 +21,14 @@ *****************************************************************************/
/* - + Sigma Lee filter.
The xrad and yrad denotes radius the filter works on. The number of neighbor pixels is exactly 2 * rad + 1 for both directions. - + The sigma denotes maximal symetric difference of pixels scaled to [0,1] - interval. Greater sigma causes results to be closer to mean linear filter. + interval. Greater sigma causes results to be closer to mean linear filter.
The min parameter defines minimial number of pixels that must be in the two sigma iterval, if there is a less pixels in this interval the new pixel diff --git a/include/filters/GP_WeightedMedian.h b/include/filters/GP_WeightedMedian.h index 82dd8e4..167b454 100644 --- a/include/filters/GP_WeightedMedian.h +++ b/include/filters/GP_WeightedMedian.h @@ -21,7 +21,7 @@ *****************************************************************************/
/* - +
*/
diff --git a/include/gfx/GP_CircleSeg.h b/include/gfx/GP_CircleSeg.h index fddc5ef..3bd41e2 100644 --- a/include/gfx/GP_CircleSeg.h +++ b/include/gfx/GP_CircleSeg.h @@ -34,10 +34,10 @@ * First segment is where both x and y are possitive, second is where only y is * possitive, third is for both x and y negative and the last one for only y * negative. - * + * * Note that on computer screen (and in in-memory bitmaps) cordinates for y * grows in the opposite direction to the standard cartesian plane. - * + * * So first segment is actually down right, second is down left, third is up * left, and fourth is up right. */ diff --git a/include/gfx/GP_HLineAA.h b/include/gfx/GP_HLineAA.h index b253ae2..cbb34e7 100644 --- a/include/gfx/GP_HLineAA.h +++ b/include/gfx/GP_HLineAA.h @@ -21,12 +21,12 @@ *****************************************************************************/
/* - + Anti Aliased Horizontal line.
The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h for helper macros. - + For RGB contexts gamma correction tables are used to generate correct intensity for pixels.
diff --git a/include/gfx/GP_LineAA.h b/include/gfx/GP_LineAA.h index 34ec028..c8a0ac6 100644 --- a/include/gfx/GP_LineAA.h +++ b/include/gfx/GP_LineAA.h @@ -21,12 +21,12 @@ *****************************************************************************/
/* - + Anti Aliased line.
The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h for helper macros. - + For RGB contexts gamma correction tables are used to generate correct intensity for pixels.
@@ -40,7 +40,7 @@ /* * Anti Aliased Line respecting context rotation flags and with clipping. */ -void GP_LineAA(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_LineAA(GP_Context *context, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
/* diff --git a/include/gfx/GP_PutPixelAA.h b/include/gfx/GP_PutPixelAA.h index 7d697c7..2852cc4 100644 --- a/include/gfx/GP_PutPixelAA.h +++ b/include/gfx/GP_PutPixelAA.h @@ -21,12 +21,12 @@ *****************************************************************************/
/* - + Puts an anti aliased pixel to context.
The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h for helper macros. - + For RGB contexts gamma correction tables are used to generate correct intensity for pixels.
diff --git a/include/gfx/GP_VLineAA.h b/include/gfx/GP_VLineAA.h index 4bbce5a..87bf586 100644 --- a/include/gfx/GP_VLineAA.h +++ b/include/gfx/GP_VLineAA.h @@ -21,12 +21,12 @@ *****************************************************************************/
/* - + Anti Aliased Vertical line.
The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h for helper macros. - + For RGB contexts gamma correction tables are used to generate correct intensity for pixels.
diff --git a/include/grabbers/GP_Grabber.h b/include/grabbers/GP_Grabber.h index 5591297..f47fd86 100644 --- a/include/grabbers/GP_Grabber.h +++ b/include/grabbers/GP_Grabber.h @@ -75,7 +75,7 @@ static inline int GP_GrabberStart(struct GP_Grabber *self) { if (self->Start) return self->Start(self); - + return 0; }
@@ -83,7 +83,7 @@ static inline int GP_GrabberStop(struct GP_Grabber *self) { if (self->Stop) return self->Stop(self); - + return 0; }
diff --git a/include/input/GP_Event.h b/include/input/GP_Event.h index fa71742..eaef373 100644 --- a/include/input/GP_Event.h +++ b/include/input/GP_Event.h @@ -23,12 +23,12 @@ /*
Gfxprim event layer. - + Events are lowlevel interface to input devices (human interface).
- Events are notifications that something has changed, eg. button pressed - Each event carries some information about global state - + */
#ifndef INPUT_GP_EVENT_H @@ -145,7 +145,7 @@ enum GP_EventKeyValue { GP_KEY_KP_3 = 81, GP_KEY_KP_0 = 82, GP_KEY_KP_DOT = 83, - + GP_KEY_F11 = 87, GP_KEY_F12 = 88,
@@ -154,7 +154,7 @@ enum GP_EventKeyValue { GP_KEY_KP_SLASH = 98, GP_KEY_SYSRQ = 99, GP_KEY_RIGHT_ALT = 100, - + GP_KEY_HOME = 102, GP_KEY_UP = 103, GP_KEY_PAGE_UP = 104, @@ -279,18 +279,18 @@ typedef struct GP_Event {
/* input device id */ uint32_t dev_id; - + /* event timestamp */ struct timeval time;
- /* + /* * Cursor position, position on screen accumulated * from all pointer devices */ uint32_t cursor_x; uint32_t cursor_y;
- /* + /* * Bitmap of pressed keys including mouse buttons * accumulated for all input devices. */ diff --git a/include/input/GP_InputDriverLinux.h b/include/input/GP_InputDriverLinux.h index bb1b352..031769a 100644 --- a/include/input/GP_InputDriverLinux.h +++ b/include/input/GP_InputDriverLinux.h @@ -34,18 +34,18 @@ typedef struct GP_InputDriverLinux { /* fd */ int fd; - + /* to store rel coordinates */ int rel_x; int rel_y; - + uint8_t rel_flag;
/* to store abs coordinates */ int abs_x; int abs_y; int abs_press; - + int abs_x_max; int abs_y_max; int abs_press_max; diff --git a/include/input/GP_TimeStamp.h b/include/input/GP_TimeStamp.h index 32bd575..f232f8b 100644 --- a/include/input/GP_TimeStamp.h +++ b/include/input/GP_TimeStamp.h @@ -21,7 +21,7 @@ *****************************************************************************/
/* - + Returns monotonously incrementing timestamps in milliseconds.
*/ diff --git a/include/input/GP_Timer.h b/include/input/GP_Timer.h index 6026268..1debab2 100644 --- a/include/input/GP_Timer.h +++ b/include/input/GP_Timer.h @@ -21,7 +21,7 @@ *****************************************************************************/
/* - + Timers and priority queue implementation.
*/ @@ -48,8 +48,8 @@ typedef struct GP_Timer { /* Timer id, showed in debug messages */ char id[10];
- /* - * Timer Callback + /* + * Timer Callback * * If non-zero is returned, the timer is rescheduled to expire * return value from now. @@ -73,7 +73,7 @@ typedef struct GP_Timer { void GP_TimerQueueDump(GP_Timer *queue);
/* - * Inserts timer into the timer priority queue. + * Inserts timer into the timer priority queue. */ void GP_TimerQueueInsert(GP_Timer **queue, uint64_t now, GP_Timer *timer);
diff --git a/include/loaders/GP_BMP.h b/include/loaders/GP_BMP.h index e5ad3a7..4c5ca26 100644 --- a/include/loaders/GP_BMP.h +++ b/include/loaders/GP_BMP.h @@ -49,7 +49,7 @@ int GP_OpenBMP(const char *src_path, FILE **f,
/* * Reads a BMP from a opened file. - * + * * Upon successful return, context to store bitmap is allocated and image is * loaded. * diff --git a/include/loaders/GP_ByteUtils.h b/include/loaders/GP_ByteUtils.h index cfa4bea..8a26e9c 100644 --- a/include/loaders/GP_ByteUtils.h +++ b/include/loaders/GP_ByteUtils.h @@ -35,7 +35,7 @@ * The format string examples: * * Type Modifiers: - * + * * L - little endian (passed as value to write, passed as pointer to read) * B - big endian * A - byte array (passed as bointer for both read and write) @@ -51,10 +51,10 @@ * char sig[2]; * * if (GP_FWrite(f, "A2 0x00 0x00 L2 L2", "SG", w, h) != 5) - * //ERROR + * //ERROR * * if (GP_FRead(f, "A2 I2 L2 L2", sig, &w, &h) != 4) - * //ERROR + * //ERROR */
/* diff --git a/include/loaders/GP_GIF.h b/include/loaders/GP_GIF.h index 62284d0..b2ee363 100644 --- a/include/loaders/GP_GIF.h +++ b/include/loaders/GP_GIF.h @@ -21,7 +21,7 @@ *****************************************************************************/
/* - + GIF support using giflib library.
*/ diff --git a/include/loaders/GP_JPG.h b/include/loaders/GP_JPG.h index 5ee57ce..8f6a920 100644 --- a/include/loaders/GP_JPG.h +++ b/include/loaders/GP_JPG.h @@ -21,7 +21,7 @@ *****************************************************************************/
/* - + JPG support using jpeg library.
*/ diff --git a/include/loaders/GP_Loader.h b/include/loaders/GP_Loader.h index f80cf58..6522c0a 100644 --- a/include/loaders/GP_Loader.h +++ b/include/loaders/GP_Loader.h @@ -50,13 +50,13 @@ int GP_LoadMetaData(const char *src_path, GP_MetaData *data); * Simple saving function, the image format is matched by file extension. * * Retruns zero on succes. - * + * * On failure non-zero is returned. * * When file type wasn't recognized by extension or if support for requested * image format wasn't compiled in non-zero is returned and errno is set to * ENOSYS. - * + * * The resulting errno may also be set to any possible error from fopen(3), open(3), * write(3), fwrite(3), seek(3), etc.. */ @@ -67,7 +67,7 @@ int GP_SaveImage(const GP_Context *src, const char *dst_path, * You can register your own loader here. */ typedef struct GP_Loader { - /* + /* * Loads an image. * * Returns allocated and initialized bitmap on success, NULL on failure @@ -75,12 +75,12 @@ typedef struct GP_Loader { */ GP_Context *(*Load)(const char *src_path, GP_ProgressCallback *callback);
- /* + /* * Save an image. * * Returns zero on succes, non-zero on failure and errno must be set. */ - int (*Save)(const GP_Context *src, const char *dst_path, GP_ProgressCallback *callback); + int (*Save)(const GP_Context *src, const char *dst_path, GP_ProgressCallback *callback);
/* * The buffer is filled with 32 bytes from an image start, returns 1 if @@ -95,7 +95,7 @@ typedef struct GP_Loader {
/* don't touch */ struct GP_Loader *next; - + /* * NULL terminated array of file extensions. */ diff --git a/include/loaders/GP_MetaData.h b/include/loaders/GP_MetaData.h index 2c529d2..5416193 100644 --- a/include/loaders/GP_MetaData.h +++ b/include/loaders/GP_MetaData.h @@ -119,7 +119,7 @@ GP_MetaRecord *GP_MetaDataCreateDouble(GP_MetaData *self, const char *id, * * If len == 0, string is copied to the terminating '0', otherwise len * characters is copied. This has no effect if dup == 0. - * + * * If dup is set to 1, the string is duplicated inside of the MetaData * structure, otherwise only the pointer is saved. */ diff --git a/include/loaders/GP_PNG.h b/include/loaders/GP_PNG.h index cbb4b70..e9b72ce 100644 --- a/include/loaders/GP_PNG.h +++ b/include/loaders/GP_PNG.h @@ -21,7 +21,7 @@ *****************************************************************************/
/* - + PNG support using libpng library.
*/ @@ -55,7 +55,7 @@ int GP_OpenPNG(const char *src_path, FILE **f); /* * Reads PNG from an open FILE. Expects the file position set after the eight * bytes PNG signature. - * + * * Upon succesfull return pointer to newly allocated context is returned. * Otherwise NULL is returned and errno is filled. */ diff --git a/include/loaders/GP_PSP.h b/include/loaders/GP_PSP.h index a44ae9b..3ddf75c 100644 --- a/include/loaders/GP_PSP.h +++ b/include/loaders/GP_PSP.h @@ -21,7 +21,7 @@ *****************************************************************************/
/* - + Experimental Paint Shop Pro image loader.
*/ diff --git a/include/loaders/GP_TIFF.h b/include/loaders/GP_TIFF.h index f6cb428..cb34585 100644 --- a/include/loaders/GP_TIFF.h +++ b/include/loaders/GP_TIFF.h @@ -48,7 +48,7 @@ int GP_OpenTIFF(const char *src_path, void **t);
/* * Reads a TIFF from a opened file. - * + * * Upon successful return, context to store bitmap is allocated and image is * loaded. * diff --git a/include/loaders/GP_TmpFile.h b/include/loaders/GP_TmpFile.h index fe1f8d1..819962b 100644 --- a/include/loaders/GP_TmpFile.h +++ b/include/loaders/GP_TmpFile.h @@ -21,7 +21,7 @@ *****************************************************************************/
/* - + This is interface for saving GP_Context into non-portable uncompressed file, which is usefull for caching GP_Context to disk.
diff --git a/include/text/GP_Font.h b/include/text/GP_Font.h index 3612873..a6a584c 100644 --- a/include/text/GP_Font.h +++ b/include/text/GP_Font.h @@ -27,9 +27,9 @@
#define GP_FONT_NAME_MAX 64
-/* +/* * Data describing single Glyph. - * + * * Note that glyph do not necessarily correspond to one character (for example * ligature is a glyph but corresponds to at least two characters). * @@ -67,7 +67,7 @@ typedef struct GP_GlyphBitmap { */ uint8_t advance_x;
- /* + /* * Character bitmap, byte aligned bitmap. */ uint8_t bitmap[]; @@ -79,7 +79,7 @@ typedef enum GP_CharSet {
/* * Glyph bitmap data format. - * + * * The bitmap is byte aligned and for 1BPP the number of bytes per row is * rounted to bytes. * @@ -90,7 +90,7 @@ typedef enum GP_FontBitmapFormat { } GP_FontBitmapFormat;
/* - * Font face + * Font face */ typedef struct GP_FontFace { /* @@ -112,7 +112,7 @@ typedef struct GP_FontFace { * Maximal height of font glyph from baseline to the top. */ uint16_t ascend; - + /* * Maximal length of font glyph from baseline to the bottom. */ @@ -120,7 +120,7 @@ typedef struct GP_FontFace {
/* * Maximal width of font glyph. - * + * * (basically max from glyph->width + glyph->bearing_x) */ uint16_t max_glyph_width; @@ -136,7 +136,7 @@ typedef struct GP_FontFace { GP_FontBitmapFormat glyph_bitmap_format;
/* - * Pointer to glyph bitmap buffer. + * Pointer to glyph bitmap buffer. */ void *glyphs;
diff --git a/include/text/GP_Text.h b/include/text/GP_Text.h index 6ee567f..6834417 100644 --- a/include/text/GP_Text.h +++ b/include/text/GP_Text.h @@ -73,7 +73,7 @@ void GP_Text_Raw(GP_Context *context, const GP_TextStyle *style,
/* * Draws a string. - * + * * The string is rendered to context (horizontally) with defined text style. * The x and y coordinates determines point defined by aligment flags. * diff --git a/include/text/GP_TextMetric.h b/include/text/GP_TextMetric.h index 16d44bc..e12bdb0 100644 --- a/include/text/GP_TextMetric.h +++ b/include/text/GP_TextMetric.h @@ -50,13 +50,13 @@ GP_Size GP_TextMaxStrWidth(const GP_TextStyle *style, const char *str, */ GP_Size GP_TextHeight(const GP_TextStyle *style);
-/* +/* * Returns the ascent (height from the baseline to the top of characters), * for the given text style. (Result is in pixels.) */ GP_Size GP_TextAscent(const GP_TextStyle *style);
-/* +/* * Returns the descent (height from the baseline to the bottom of characters), * for the given text style. (Result is in pixels.) */ diff --git a/lib.mk b/lib.mk index 2aa9b00..b8e4a20 100644 --- a/lib.mk +++ b/lib.mk @@ -27,7 +27,7 @@ LIBS=$(BUILD_DIR)$(STATIC_LIB) $(BUILD_DIR)$(DYNAMIC_LIB) ALL+=$(LIBS) $(SYMLINKS) CLEAN+=$(LIBS) $(addprefix $(BUILD_DIR),$(SYMLINKS))
-# +# # OBJECTS are set in post.mk so we need to duplicate the values in # OBJS here too to have correct dependencies # diff --git a/libs/backends/GP_Backend.c b/libs/backends/GP_Backend.c index c216177..bcc7ac3 100644 --- a/libs/backends/GP_Backend.c +++ b/libs/backends/GP_Backend.c @@ -58,7 +58,7 @@ void GP_BackendUpdateRectXYXY(GP_Backend *backend, GP_WARN("Negative x coordinate %i, clipping to 0", x0); x0 = 0; } - + if (y0 < 0) { GP_WARN("Negative y coordinate %i, clipping to 0", y0); y0 = 0; @@ -70,14 +70,14 @@ void GP_BackendUpdateRectXYXY(GP_Backend *backend, GP_WARN("Too large x coordinate %i, clipping to %u", x1, w - 1); x1 = w - 1; } - + GP_Coord h = backend->context->h;
if (y1 >= h) { GP_WARN("Too large y coordinate %i, clipping to %u", y1, h - 1); y1 = h - 1; } - + backend->UpdateRect(backend, x0, y0, x1, y1); }
@@ -86,7 +86,7 @@ int GP_BackendResize(GP_Backend *backend, uint32_t w, uint32_t h) { if (backend->SetAttributes == NULL) return 1; - + if (w == 0) w = backend->context->w;
@@ -102,7 +102,7 @@ int GP_BackendResize(GP_Backend *backend, uint32_t w, uint32_t h) int GP_BackendResizeAck(GP_Backend *self) { GP_DEBUG(2, "Calling backend %s ResizeAck()", self->name); - + if (self->ResizeAck) return self->ResizeAck(self);
@@ -144,7 +144,7 @@ static void wait_timers_fd(GP_Backend *self, uint64_t now) int timeout;
timeout = self->timers->expires - now; - + struct pollfd fd = {.fd = self->fd, .events = POLLIN, fd.revents = 0};
if (poll(&fd, 1, timeout)) @@ -203,7 +203,7 @@ int GP_BackendWaitEvent(GP_Backend *self, GP_Event *ev) for (;;) { if ((ret = GP_BackendGetEvent(self, ev))) return ret; - + GP_BackendWait(self); } } @@ -211,12 +211,12 @@ int GP_BackendWaitEvent(GP_Backend *self, GP_Event *ev) int GP_BackendPollEvent(GP_Backend *self, GP_Event *ev) { int ret; - + if ((ret = GP_BackendGetEvent(self, ev))) return ret;
GP_BackendPoll(self); - + if ((ret = GP_BackendGetEvent(self, ev))) return ret;
diff --git a/libs/backends/GP_BackendInit.c b/libs/backends/GP_BackendInit.c index 1234a1c..f0a20f1 100644 --- a/libs/backends/GP_BackendInit.c +++ b/libs/backends/GP_BackendInit.c @@ -50,7 +50,7 @@ static int sdl_params_to_flags(const char *param, GP_Size *w, GP_Size *h, *flags |= GP_SDL_FULLSCREEN; return 0; } - + /* * Accepts only string with format "intxint" or "intXint" */ @@ -73,10 +73,10 @@ static GP_Backend *backend_sdl_init(char *params, const char *caption, { if (params == NULL) return GP_BackendSDLInit(0, 0, 0, 0, caption); - + GP_Size w = 0, h = 0; uint8_t flags = GP_SDL_RESIZABLE; - + char *s = params;
for (;;) { @@ -91,7 +91,7 @@ static GP_Backend *backend_sdl_init(char *params, const char *caption, case '0': if (sdl_params_to_flags(params, &w, &h, &flags, help)) return NULL; - + return GP_BackendSDLInit(w, h, 0, flags, caption); break; } @@ -116,7 +116,7 @@ static GP_Backend *backend_fb_init(char *params, const char *caption, FILE *help) { const char *fb = "/dev/fb0"; - + (void) help; (void) caption;
@@ -153,7 +153,7 @@ static int x11_params_to_flags(const char *param, GP_Size *w, GP_Size *h, *flags |= GP_X11_USE_ROOT_WIN; return 0; } - + if (!strcasecmp(param, "CREATE_ROOT")) { *flags |= GP_X11_CREATE_ROOT_WIN; return 0; @@ -163,7 +163,7 @@ static int x11_params_to_flags(const char *param, GP_Size *w, GP_Size *h, *flags |= GP_X11_DISABLE_SHM; return 0; } - + if (!strcasecmp(param, "FS")) { *flags |= GP_X11_FULLSCREEN; return 0; @@ -192,7 +192,7 @@ static GP_Backend *backend_x11_init(char *params, const char *caption, { GP_Size w = 640, h = 480; enum GP_BackendX11Flags flags = 0; - + if (params == NULL) return GP_BackendX11Init(NULL, 0, 0, w, h, caption, 0);
@@ -210,7 +210,7 @@ static GP_Backend *backend_x11_init(char *params, const char *caption, case '0': if (x11_params_to_flags(params, &w, &h, &flags, help)) return NULL; - + return GP_BackendX11Init(NULL, 0, 0, w, h, caption, flags); break; } @@ -267,7 +267,7 @@ static int get_backend(const char *name) for (i = 0; backend_names[i] != 0; i++) if (!strcasecmp(name, backend_names[i])) return i; - + return -1; }
@@ -295,11 +295,11 @@ GP_Backend *GP_BackendInit(const char *params, const char *caption, FILE *help) print_help(help, NULL); return NULL; } - + /* parse backend name */ int i, len = strlen(params); char buf[len+1], *backend_params = NULL; - + strcpy(buf, params);
for (i = 0; i < len; i++) { diff --git a/libs/backends/GP_BackendVirtual.c b/libs/backends/GP_BackendVirtual.c index 7ea1238..5ebf621 100644 --- a/libs/backends/GP_BackendVirtual.c +++ b/libs/backends/GP_BackendVirtual.c @@ -31,7 +31,7 @@ struct virt_priv { /* Original backend */ GP_Backend *backend; - + int flags; };
@@ -51,11 +51,11 @@ static void virt_update_rect(GP_Backend *self, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1) { struct virt_priv *virt = GP_BACKEND_PRIV(self); - + /* Convert and copy the buffer */ GP_BlitXYXY(self->context, x0, y0, x1, y1, virt->backend->context, x0, y0); - + /* Call blit on original backend */ virt->backend->UpdateRect(virt->backend, x0, y0, x1, y1); } @@ -96,7 +96,7 @@ static void virt_wait(GP_Backend *self) struct virt_priv *virt = GP_BACKEND_PRIV(self);
virt->backend->Wait(virt->backend); - + struct GP_Event ev;
while (GP_BackendGetEvent(virt->backend, &ev)) @@ -106,9 +106,9 @@ static void virt_wait(GP_Backend *self) static void virt_exit(GP_Backend *self) { struct virt_priv *virt = GP_BACKEND_PRIV(self); - + GP_ContextFree(self->context); - + if (virt->flags & GP_BACKEND_CALL_EXIT) virt->backend->Exit(virt->backend);
@@ -128,7 +128,7 @@ GP_Backend *GP_BackendVirtualInit(GP_Backend *backend, GP_DEBUG(1, "Malloc failed :("); return NULL; } - + memset(self, 0, sizeof(GP_Backend));
/* Create new buffer with different context type */ @@ -137,7 +137,7 @@ GP_Backend *GP_BackendVirtualInit(GP_Backend *backend,
if (self->context == NULL) goto err0; - + virt = GP_BACKEND_PRIV(self); virt->backend = backend; virt->flags = flags; diff --git a/libs/backends/GP_InputDriverSDL.c b/libs/backends/GP_InputDriverSDL.c index d94272d..6b478c8 100644 --- a/libs/backends/GP_InputDriverSDL.c +++ b/libs/backends/GP_InputDriverSDL.c @@ -143,7 +143,7 @@ void GP_InputDriverSDLEventPut(struct GP_EventQueue *event_queue, GP_WARN("Unmapped SDL keysym %u", keysym); return; } - + GP_EventQueuePushKey(event_queue, key, ev->key.state, NULL); break; case SDL_VIDEORESIZE: diff --git a/libs/backends/GP_InputDriverX11.c b/libs/backends/GP_InputDriverX11.c index 750dc17..fc6149f 100644 --- a/libs/backends/GP_InputDriverX11.c +++ b/libs/backends/GP_InputDriverX11.c @@ -183,7 +183,7 @@ static void init_table(Display *dpy) GP_WARN("Key '%s' keycode %u collides with key '%s'", GP_EventKeyName(sym_to_key[i].key), keycode, GP_EventKeyName(keycode_table[keycode - 9])); - continue; + continue; }
keycode_table[keycode - 9] = sym_to_key[i].key; @@ -239,7 +239,7 @@ void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue, GP_EV_REL_WHEEL, -1, NULL); return; } - + if (key == 0) { GP_WARN("Unmapped X11 button %02x", ev->xbutton.button); @@ -258,7 +258,7 @@ void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue, if (ev->xmotion.x < 0 || ev->xmotion.y < 0 || ev->xmotion.x > w || ev->xmotion.y > h) return; - + GP_EventQueuePushRelTo(event_queue, ev->xmotion.x, ev->xmotion.y, NULL); break; diff --git a/libs/backends/GP_LinuxFB.c b/libs/backends/GP_LinuxFB.c index 49566aa..9f5c83c 100644 --- a/libs/backends/GP_LinuxFB.c +++ b/libs/backends/GP_LinuxFB.c @@ -50,7 +50,7 @@ struct fb_priv { int con_nr; int last_con_nr; int saved_kb_mode; - + int fb_fd; char path[]; }; @@ -74,7 +74,7 @@ static int allocate_console(struct fb_priv *fb, int flag) strerror(errno)); return -1; } - + if (ioctl(fd, VT_OPENQRY, &nr) < 0) { GP_DEBUG(1, "Failed to ioctl VT_OPENQRY /dev/tty1: %s", strerror(errno)); @@ -94,7 +94,7 @@ static int allocate_console(struct fb_priv *fb, int flag) buf, strerror(errno)); return -1; } - + if (ioctl(fd, VT_GETSTATE, &vts) == 0) fb->last_con_nr = vts.v_active; else @@ -128,14 +128,14 @@ static int allocate_console(struct fb_priv *fb, int flag) if (flag) { struct termios t; cfmakeraw(&t); - + if (tcsetattr(fd, TCSANOW, &t) < 0) { GP_DEBUG(1, "Failed to tcsetattr(): %s", strerror(errno)); close(fd); return -1; } - + if (ioctl(fd, KDGKBMODE, &fb->saved_kb_mode)) { GP_DEBUG(1, "Failed to ioctl KDGKBMODE %s: %s", buf, strerror(errno)); @@ -164,7 +164,7 @@ static int allocate_console(struct fb_priv *fb, int flag)
static void fb_poll(GP_Backend *self) { - struct fb_priv *fb = GP_BACKEND_PRIV(self); + struct fb_priv *fb = GP_BACKEND_PRIV(self); unsigned char buf[16]; int i, res;
@@ -176,7 +176,7 @@ static void fb_poll(GP_Backend *self)
static void fb_wait(GP_Backend *self) { - struct fb_priv *fb = GP_BACKEND_PRIV(self); + struct fb_priv *fb = GP_BACKEND_PRIV(self);
struct pollfd fd = {.fd = fb->con_fd, .events = POLLIN, .revents = 0};
@@ -188,15 +188,15 @@ static void fb_wait(GP_Backend *self)
static void fb_exit(GP_Backend *self) { - struct fb_priv *fb = GP_BACKEND_PRIV(self); + struct fb_priv *fb = GP_BACKEND_PRIV(self);
/* unmap framebuffer */ munmap(fb->context.pixels, fb->bsize); close(fb->fb_fd); - + /* reset keyboard */ ioctl(fb->con_fd, KDSETMODE, KD_TEXT); - + /* restore keyboard mode */ if (fb->flag) { if (ioctl(fb->con_fd, KDSKBMODE, fb->saved_kb_mode) < 0) { @@ -204,11 +204,11 @@ static void fb_exit(GP_Backend *self) " /dev/tty%i: %s", fb->con_nr, strerror(errno)); } } - + /* switch back console */ if (fb->last_con_nr != -1) ioctl(fb->con_fd, VT_ACTIVATE, fb->last_con_nr); - + close(fb->con_fd); free(self); } @@ -220,7 +220,7 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flag) struct fb_fix_screeninfo fscri; struct fb_var_screeninfo vscri; int fd; - + backend = malloc(sizeof(GP_Backend) + sizeof(struct fb_priv) + strlen(path) + 1);
@@ -236,7 +236,7 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flag) GP_DEBUG(1, "Opening framebuffer '%s'", path);
fd = open(path, O_RDWR); - + if (fd < 0) { GP_DEBUG(1, "Opening framebuffer failed: %s", strerror(errno)); goto err2; @@ -247,7 +247,7 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flag) strerror(errno)); goto err3; } - + if (ioctl(fd, FBIOGET_VSCREENINFO, &vscri) < 0) { GP_DEBUG(1, "Failed to ioctl FBIOGET_VSCREENINFO: %s", strerror(errno)); @@ -293,7 +293,7 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flag)
fb->context.w = vscri.xres; fb->context.h = vscri.yres; - + fb->context.axes_swap = 0; fb->context.x_swap = 0; fb->context.y_swap = 0; @@ -322,10 +322,10 @@ err3: close(fd); err2: close(fb->con_fd); - + /* reset keyboard */ ioctl(fb->con_fd, KDSETMODE, KD_TEXT); - + /* switch back console */ if (fb->last_con_nr != -1) ioctl(fb->con_fd, VT_ACTIVATE, fb->last_con_nr); diff --git a/libs/backends/GP_SDL.c b/libs/backends/GP_SDL.c index 1e73ecf..ab87c82 100644 --- a/libs/backends/GP_SDL.c +++ b/libs/backends/GP_SDL.c @@ -73,7 +73,7 @@ static void sdl_update_rect(struct GP_Backend *self __attribute__((unused)), if (x1 != 0 && y1 != 0) SDL_UpdateRect(sdl_surface, x0, y0, GP_ABS(x1 - x0) + 1, GP_ABS(y1 - y0) + 1); - + SDL_mutexV(mutex); }
@@ -158,7 +158,7 @@ static int sdl_set_attributes(struct GP_Backend *self, { SDL_mutexP(mutex);
- if (caption != NULL) + if (caption != NULL) SDL_WM_SetCaption(caption, caption);
/* Send only resize event, the actual resize is done in resize_ack */ @@ -173,7 +173,7 @@ static int sdl_set_attributes(struct GP_Backend *self, static int sdl_resize_ack(struct GP_Backend *self __attribute__((unused))) { GP_DEBUG(2, "Resizing the buffer to %ux%u", new_w, new_h); - + SDL_mutexP(mutex);
sdl_surface = SDL_SetVideoMode(new_w, new_h, 0, sdl_flags); @@ -183,7 +183,7 @@ static int sdl_resize_ack(struct GP_Backend *self __attribute__((unused))) backend.context->w, backend.context->h);
SDL_mutexV(mutex); - + return 0; }
@@ -206,9 +206,9 @@ static struct GP_Backend backend = { static void sdl_exit(struct GP_Backend *self __attribute__((unused))) { SDL_mutexP(mutex); - + SDL_Quit(); - + SDL_DestroyMutex(mutex);
backend.context = NULL; @@ -253,11 +253,11 @@ GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp, uint8_t flags,
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); - + GP_EventQueueInit(&backend.event_queue, w, h, 0);
backend.context = &context; - + return &backend; }
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c index b0aff6d..7392202 100644 --- a/libs/backends/GP_X11.c +++ b/libs/backends/GP_X11.c @@ -149,12 +149,12 @@ static void x11_ev(XEvent *ev) case ConfigureNotify: if (ev->xconfigure.width == (int)self->context->w && ev->xconfigure.height == (int)self->context->h) - break; - + break; + if (ev->xconfigure.width == (int)win->new_w && ev->xconfigure.height == (int)win->new_h) - break; - + break; + win->new_w = ev->xconfigure.width; win->new_h = ev->xconfigure.height;
diff --git a/libs/backends/GP_X11_Conn.h b/libs/backends/GP_X11_Conn.h index f8bf3bf..87a188c 100644 --- a/libs/backends/GP_X11_Conn.h +++ b/libs/backends/GP_X11_Conn.h @@ -39,7 +39,7 @@ static unsigned int x11_open(const char *display) { if (x11_conn.ref_cnt != 0) return ++x11_conn.ref_cnt; - + GP_DEBUG(1, "Opening X11 display '%s'", display);
if (!XInitThreads()) { @@ -65,14 +65,14 @@ static void x11_close(void) /* Ignore close requests if connection is closed */ if (x11_conn.ref_cnt == 0) return; - + if (--x11_conn.ref_cnt != 0) return;
GP_DEBUG(1, "Closing X11 display");
XLockDisplay(x11_conn.dpy); - + /* I wonder if this is right sequence... */ //XUnlockDisplay(x11_conn.dpy); XCloseDisplay(x11_conn.dpy); diff --git a/libs/backends/GP_X11_Win.h b/libs/backends/GP_X11_Win.h index eb6905b..b2dfec3 100644 --- a/libs/backends/GP_X11_Win.h +++ b/libs/backends/GP_X11_Win.h @@ -109,7 +109,7 @@ static void x11_win_fullscreen(struct x11_win *win, int mode) GP_DEBUG(2, "Requesting fullscreen mode = %u", mode);
Atom wm_state, fullscreen; - + wm_state = XInternAtom(win->dpy, "_NET_WM_STATE", True); fullscreen = XInternAtom(win->dpy, "_NET_WM_STATE_FULLSCREEN", True);
@@ -193,7 +193,7 @@ static int x11_win_open(struct x11_wreq *wreq) KeyReleaseMask | PointerMotionMask; attr_mask |= CWEventMask;
- /* + /* * If root window was selected, resize w and h and set win->win to root * window. */ @@ -202,66 +202,66 @@ static int x11_win_open(struct x11_wreq *wreq) win->win = DefaultRootWindow(win->dpy);
x11_get_screen_size(wreq); - + GP_DEBUG(2, "Using root window, owerriding size to %ux%u", - wreq->w, wreq->h); + wreq->w, wreq->h);
win_list_add(win); - + XChangeWindowAttributes(win->dpy, win->win, attr_mask, &attrs); - + return 0; }
- /* + /* * For some reason reading mouse button clicks on root win are not * allowed... */ attrs.event_mask |= ButtonPressMask | ButtonReleaseMask; - + /* * Create undecoreated root window on background */ if (wreq->flags & GP_X11_CREATE_ROOT_WIN) { Atom xa; - + x11_get_screen_size(wreq); - + GP_DEBUG(2, "Creating a window above root, owerriding size to %ux%u", wreq->w, wreq->h);
win->win = XCreateWindow(win->dpy, DefaultRootWindow(win->dpy), 0, 0, wreq->w, wreq->h, 0, CopyFromParent, InputOutput, CopyFromParent, attr_mask, &attrs); - + /* Set empty WM_PROTOCOLS */ GP_DEBUG(2, "Setting empty MW_PROTOCOLS"); XSetWMProtocols(win->dpy, win->win, NULL, 0);
/* Set window type to desktop */ xa = XInternAtom(win->dpy, "_NET_WM_WINDOW_TYPE", False); - + if (xa != None) { GP_DEBUG(2, "Setting Atom _NET_WM_WINDOW_TYPE to _NET_WM_WINDOW_TYPE_DESKTOP"); - + Atom xa_prop = XInternAtom(win->dpy, "_NET_WM_WINDOW_TYPE_DESKTOP", False); - + XChangeProperty(win->dpy, win->win, xa, XA_ATOM, 32, PropModeReplace, (unsigned char *) &xa_prop, 1); } - + /* Turn off window decoration */ xa = XInternAtom(win->dpy, "_MOTIF_WM_HINTS", False); - + if (xa != None) { GP_DEBUG(2, "Setting Atom _MOTIF_WM_HINTS to 2, 0, 0, 0, 0"); - + long prop[5] = {2, 0, 0, 0, 0};
XChangeProperty(win->dpy, win->win, xa, xa, 32, PropModeReplace, (unsigned char *) prop, 5); } - + /* Set below other windows */ xa = XInternAtom(win->dpy, "_WIN_LAYER", False);
@@ -273,26 +273,26 @@ static int x11_win_open(struct x11_wreq *wreq) XChangeProperty(win->dpy, win->win, xa, XA_CARDINAL, 32, PropModeAppend, (unsigned char *) &prop, 1); } - + xa = XInternAtom(win->dpy, "_NET_WM_STATE", False);
if (xa != None) { GP_DEBUG(2, "Setting Atom _NET_WM_STATE to _NET_WM_STATE_BELOW"); - + Atom xa_prop = XInternAtom(win->dpy, "_NET_WM_STATE_BELOW", False);
XChangeProperty(win->dpy, win->win, xa, XA_ATOM, 32, PropModeAppend, (unsigned char *) &xa_prop, 1); } - + /* Set sticky */ xa = XInternAtom(win->dpy, "_NET_WM_DESKTOP", False); - + if (xa != None) { GP_DEBUG(2, "Setting Atom _NET_WM_DESKTOP to 0xffffffff");
CARD32 xa_prop = 0xffffffff; - + XChangeProperty(win->dpy, win->win, xa, XA_CARDINAL, 32, PropModeAppend, (unsigned char *) &xa_prop, 1); } @@ -307,10 +307,10 @@ static int x11_win_open(struct x11_wreq *wreq) XChangeProperty(win->dpy, win->win, xa, XA_ATOM, 32, PropModeAppend, (unsigned char *) &xa_prop, 1); } - + /* Skip taskbar */ xa = XInternAtom(win->dpy, "_NET_WM_STATE", False); - + if (xa != None) { GP_DEBUG(2, "Appending to Atom _NET_WM_STATE atom _NET_STATE_SKIP_TASKBAR");
@@ -319,10 +319,10 @@ static int x11_win_open(struct x11_wreq *wreq) XChangeProperty(win->dpy, win->win, xa, XA_ATOM, 32, PropModeAppend, (unsigned char *) &xa_prop, 1); } - + /* Skip pager */ xa = XInternAtom(win->dpy, "_NET_WM_STATE", False); - + if (xa != None) { GP_DEBUG(2, "Appending to Atom _NET_WM_STATE atom _NET_STATE_SKIP_PAGER");
@@ -331,7 +331,7 @@ static int x11_win_open(struct x11_wreq *wreq) XChangeProperty(win->dpy, win->win, xa, XA_ATOM, 32, PropModeAppend, (unsigned char *) &xa_prop, 1); } - + /* Set 100% opacity */ xa = XInternAtom(win->dpy, "_NET_WM_WINDOW_OPACITY", False);
@@ -343,7 +343,7 @@ static int x11_win_open(struct x11_wreq *wreq) XChangeProperty(win->dpy, win->win, xa, XA_CARDINAL, 32, PropModeAppend, (unsigned char *) &prop, 1); } - + win_list_add(win);
/* Show window */ @@ -358,7 +358,7 @@ static int x11_win_open(struct x11_wreq *wreq) wreq->x, wreq->y, wreq->w, wreq->h, 0, CopyFromParent, InputOutput, CopyFromParent, attr_mask, &attrs); - + /* Set window caption */ XmbSetWMProperties(win->dpy, win->win, wreq->caption, wreq->caption, NULL, 0, NULL, NULL, NULL); @@ -373,9 +373,9 @@ static int x11_win_open(struct x11_wreq *wreq) } else { GP_DEBUG(2, "Failed to set WM_DELETE_WINDOW Atom to True"); } - + win_list_add(win); - + /* Show window */ XMapWindow(win->dpy, win->win);
@@ -395,9 +395,9 @@ static void x11_win_close(struct x11_win *win) destroy_ximage(self); */ XUnmapWindow(win->dpy, win->win); - + XDestroyWindow(win->dpy, win->win); - + XUnlockDisplay(win->dpy);
/* Close connection/Decrease ref count */ diff --git a/libs/core/GP_Blit.c b/libs/core/GP_Blit.c index 58e818a..1651ca9 100644 --- a/libs/core/GP_Blit.c +++ b/libs/core/GP_Blit.c @@ -48,7 +48,7 @@ void GP_BlitXYXY_Naive(const GP_Context *src, for (x = x0; x <= x1; x++) { GP_Pixel p = GP_GetPixel(src, x, y);
- if (src->pixel_type != dst->pixel_type) + if (src->pixel_type != dst->pixel_type) p = GP_ConvertContextPixel(p, src, dst);
GP_PutPixel(dst, x2 + (x - x0), y2 + (y - y0), p); @@ -93,11 +93,11 @@ void GP_BlitXYXY_Clipped(const GP_Context *src,
if (y1 < y0) GP_SWAP(y0, y1); - + /* Noting to blit return now */ if (x2 >= (GP_Coord)GP_ContextW(dst) || y2 >= (GP_Coord)GP_ContextH(dst)) - return; + return;
/* We need to shift source rectangle */ if (x2 < 0) { @@ -140,7 +140,7 @@ void GP_BlitXYXY_Clipped(const GP_Context *src,
if (GP_ContextRotationEqual(src, dst)) GP_BlitXYXY_Raw_Fast(src, x0, y0, x1, y1, dst, x2, y2); - else + else GP_BlitXYXY_Fast(src, x0, y0, x1, y1, dst, x2, y2); }
diff --git a/libs/core/GP_Blit.gen.c.t b/libs/core/GP_Blit.gen.c.t index d743fc4..80c7f68 100644 --- a/libs/core/GP_Blit.gen.c.t +++ b/libs/core/GP_Blit.gen.c.t @@ -140,7 +140,7 @@ static void blitXYXY_Raw_{{ src.name }}_{{ dst.name }}(const GP_Context *src, dy = y2 + (y - y0);
GP_Pixel p1, p2 = 0, p3 = 0; - + p1 = GP_GetPixel_Raw_{{ src.pixelsize.suffix }}(src, x, y); %% if src.is_alpha() p2 = GP_GetPixel_Raw_{{ dst.pixelsize.suffix }}(dst, dx, dy); diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c index a7855c7..8e61ce0 100644 --- a/libs/core/GP_Context.c +++ b/libs/core/GP_Context.c @@ -129,7 +129,7 @@ GP_Context *GP_ContextInit(GP_Context *context, GP_Size w, GP_Size h,
context->pixel_type = type; context->bit_endian = 0; - + context->gamma = NULL;
/* rotation and mirroring */ @@ -196,10 +196,10 @@ GP_Context *GP_ContextCopy(const GP_Context *src, int flags) GP_ContextCopyRotation(src, new); else GP_ContextSetRotation(new, 0, 0, 0); - + //TODO: Copy the gamma too new->gamma = NULL; - + new->free_pixels = 1;
return new; @@ -216,8 +216,8 @@ GP_Context *GP_ContextConvertAlloc(const GP_Context *src,
if (ret == NULL) return NULL; - - /* + + /* * Fill the buffer with zeroes, otherwise it will * contain random data which will generate mess * when converting image with alpha channel. @@ -225,7 +225,7 @@ GP_Context *GP_ContextConvertAlloc(const GP_Context *src, memset(ret->pixels, 0, ret->bytes_per_row * ret->h);
GP_Blit(src, 0, 0, w, h, ret, 0, 0); - + return ret; }
@@ -234,14 +234,14 @@ GP_Context *GP_ContextConvert(const GP_Context *src, GP_Context *dst) //TODO: Asserts int w = GP_ContextW(src); int h = GP_ContextH(src); - - /* + + /* * Fill the buffer with zeroes, otherwise it will * contain random data which will generate mess * when converting image with alpha channel. */ memset(dst->pixels, 0, dst->bytes_per_row * dst->h); - + GP_Blit(src, 0, 0, w, h, dst, 0, 0);
return dst; @@ -270,7 +270,7 @@ GP_Context *GP_SubContext(const GP_Context *context, GP_Context *subcontext,
GP_CHECK(context->w >= x + w, "Subcontext w out of original context."); GP_CHECK(context->h >= y + h, "Subcontext h out of original context."); - + subcontext->bpp = context->bpp; subcontext->bytes_per_row = context->bytes_per_row; subcontext->offset = (context->offset + @@ -281,7 +281,7 @@ GP_Context *GP_SubContext(const GP_Context *context, GP_Context *subcontext,
subcontext->pixel_type = context->pixel_type; subcontext->bit_endian = context->bit_endian; - + /* gamma */ subcontext->gamma = context->gamma;
@@ -307,7 +307,7 @@ void GP_ContextPrintInfo(const GP_Context *self) printf("Offsett%u (only unaligned pixel types)n", self->offset); printf("Flagstaxes_swap=%u x_swap=%u y_swap=%u free_pixels=%un", self->axes_swap, self->x_swap, self->y_swap, self->free_pixels); - + if (self->gamma) GP_GammaPrint(self->gamma); } @@ -343,12 +343,12 @@ void GP_ContextRotateCW(GP_Context *context) context->x_swap = 1; return; } - + if (context->x_swap && !context->y_swap) { context->y_swap = 1; return; } - + if (context->x_swap && context->y_swap) { context->x_swap = 0; return; @@ -365,12 +365,12 @@ void GP_ContextRotateCCW(GP_Context *context) context->y_swap = 1; return; } - + if (context->x_swap && !context->y_swap) { context->x_swap = 0; return; } - + if (context->x_swap && context->y_swap) { context->y_swap = 0; return; @@ -389,7 +389,7 @@ int GP_ContextEqual(const GP_Context *ctx1, const GP_Context *ctx2)
if (GP_ContextH(ctx1) != GP_ContextH(ctx2)) return 0; - + GP_Coord x, y, w = GP_ContextW(ctx1), h = GP_ContextH(ctx1);
for (x = 0; x < w; x++) diff --git a/libs/core/GP_Debug.c b/libs/core/GP_Debug.c index 89d6047..9605507 100644 --- a/libs/core/GP_Debug.c +++ b/libs/core/GP_Debug.c @@ -50,15 +50,15 @@ void GP_DebugPrint(int level, const char *file, const char *function, int line, const char *fmt, ...) { int i; - + if (!env_used) { char *level = getenv("GP_DEBUG"); - + env_used = 1; - + if (level != NULL) { int new_level = atoi(level); - + if (new_level >= 0) { debug_level = new_level;
@@ -67,10 +67,10 @@ void GP_DebugPrint(int level, const char *file, const char *function, int line, debug_level); } } - + GP_DEBUG(1, "GFXprim library version " GP_VER_STR); } - + if (level > (int)debug_level) return;
@@ -78,7 +78,7 @@ void GP_DebugPrint(int level, const char *file, const char *function, int line, if (debug_handler) { char buf[256];
- va_list va; + va_list va; va_start(va, fmt); vsnprintf(buf, sizeof(buf), fmt, va); va_end(va); @@ -92,7 +92,7 @@ void GP_DebugPrint(int level, const char *file, const char *function, int line, };
debug_handler(&msg); - + return; }
@@ -122,6 +122,6 @@ void GP_DebugPrint(int level, const char *file, const char *function, int line, va_start(va, fmt); vfprintf(stderr, fmt, va); va_end(va); - + fputc('n', stderr); } diff --git a/libs/core/GP_Gamma.c b/libs/core/GP_Gamma.c index 6268b91..05500f9 100644 --- a/libs/core/GP_Gamma.c +++ b/libs/core/GP_Gamma.c @@ -48,7 +48,7 @@ static void fill_table16(GP_GammaTable *table, float gamma, unsigned int i; unsigned int in_max = (1<<in_bits) - 1; unsigned int out_max = (1<<out_bits) - 1; - + GP_DEBUG(3, "Initalizing gamma table %f", gamma);
for (i = 0; i < (1U<<in_bits); i++) @@ -86,13 +86,13 @@ static GP_GammaTable *get_table(float gamma, uint8_t in_bits, uint8_t out_bits) i->in_bits = in_bits; i->out_bits = out_bits; i->ref_count = 1; - i->type = GP_CORRECTION_GAMMA; - + i->type = GP_CORRECTION_GAMMA; + if (out_bits > 8) fill_table16(i, gamma, in_bits, out_bits); else fill_table8(i, gamma, in_bits, out_bits); - + /* Insert it into link list */ i->next = tables; tables = i; @@ -104,7 +104,7 @@ static void put_table(GP_GammaTable *table) { if (table == NULL) return; - + table->ref_count--;
GP_DEBUG(2, "Putting gamma table Gamma %f, in_bits %u, out_bits %u, " @@ -113,9 +113,9 @@ static void put_table(GP_GammaTable *table)
if (table->ref_count == 0) { GP_DEBUG(2, "Gamma table ref_count == 0, removing..."); - + GP_GammaTable *i, *prev = NULL; - + /* Remove from link list and free */ for (i = tables; i != NULL; i = i->next) { if (table == i) @@ -127,7 +127,7 @@ static void put_table(GP_GammaTable *table) tables = table->next; else prev->next = table->next; - + free(table); } } @@ -136,7 +136,7 @@ GP_Gamma *GP_GammaAcquire(GP_PixelType pixel_type, float gamma) { GP_CHECK_VALID_PIXELTYPE(pixel_type); int channels = GP_PixelTypes[pixel_type].numchannels, i; - + GP_DEBUG(1, "Acquiring Gamma table %s gamma %f", GP_PixelTypeName(pixel_type), gamma);
GP_Gamma *res = malloc(sizeof(struct GP_Gamma) + 2 * channels * sizeof(void*)); @@ -157,18 +157,18 @@ GP_Gamma *GP_GammaAcquire(GP_PixelType pixel_type, float gamma) for (i = 0; i < channels; i++) { unsigned int chan_size = GP_PixelTypes[pixel_type].channels[i].size; res->tables[i] = get_table(gamma, chan_size, chan_size + 2); - + if (res->tables[i] == NULL) { GP_GammaRelease(res); return NULL; } } - + /* And reverse tables, n + 2 bits -> n bits */ for (i = 0; i < channels; i++) { unsigned int chan_size = GP_PixelTypes[pixel_type].channels[i].size; res->tables[i + channels] = get_table(1/gamma, chan_size + 2, chan_size); - + if (res->tables[i] == NULL) { GP_GammaRelease(res); return NULL; @@ -222,13 +222,13 @@ void GP_GammaPrint(const GP_Gamma *self)
for (i = 0; i < desc->numchannels; i++) { enum GP_CorrectionType type = self->tables[i]->type; - + printf(" %s: %s", desc->channels[i].name, correction_type_name(type));
if (type == GP_CORRECTION_GAMMA) printf(" gamma = %.2f", self->tables[i]->gamma); - + printf("n"); } } diff --git a/libs/core/GP_GetPutPixel.c b/libs/core/GP_GetPutPixel.c index 83e4ff2..4a083ac 100644 --- a/libs/core/GP_GetPutPixel.c +++ b/libs/core/GP_GetPutPixel.c @@ -27,7 +27,7 @@ GP_Pixel GP_GetPixel(const GP_Context *context, GP_Coord x, GP_Coord y) { GP_TRANSFORM_POINT(context, x, y); - if (GP_PIXEL_IS_CLIPPED(context, x, y)) + if (GP_PIXEL_IS_CLIPPED(context, x, y)) return 0; return GP_GetPixel_Raw(context, x, y); } @@ -35,7 +35,7 @@ GP_Pixel GP_GetPixel(const GP_Context *context, GP_Coord x, GP_Coord y) void GP_PutPixel(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel p) { GP_TRANSFORM_POINT(context, x, y); - if (!GP_PIXEL_IS_CLIPPED(context, x, y)) + if (!GP_PIXEL_IS_CLIPPED(context, x, y)) GP_PutPixel_Raw(context, x, y, p); }
diff --git a/libs/core/GP_Pixel.c b/libs/core/GP_Pixel.c index a210892..4fb13fb 100644 --- a/libs/core/GP_Pixel.c +++ b/libs/core/GP_Pixel.c @@ -94,16 +94,16 @@ GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
if (r) GP_DEBUG(3, "Matching R %i %i", r->size, r->offset); - + if (g) GP_DEBUG(3, "Matching G %i %i", g->size, g->offset); - + if (b) GP_DEBUG(3, "Matching B %i %i", b->size, b->offset); - + if (a) GP_DEBUG(3, "Matching A %i %i", a->size, a->offset); - + res = match(r, rmask) && match(g, gmask) && match(b, bmask) && match(a, amask);
@@ -125,28 +125,28 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff, uint8_t bits_per_pixel) { unsigned int i; - + GP_DEBUG(1, "Looking up Pixel R %08x %08x G %08x %08x B %08x %08x " "size %u", rsize, roff, gsize, goff, bsize, boff, bits_per_pixel);
for (i = 0; i < GP_PIXEL_MAX; i++) { const GP_PixelTypeChannel *r, *g, *b, *a; - + if (GP_PixelTypes[i].size != bits_per_pixel) continue; - + GP_DEBUG(2, "Trying Pixel %s %u", GP_PixelTypes[i].name, bits_per_pixel); - + r = get_channel(&GP_PixelTypes[i], "R"); g = get_channel(&GP_PixelTypes[i], "G"); b = get_channel(&GP_PixelTypes[i], "B"); a = get_channel(&GP_PixelTypes[i], "A"); - + if (a == NULL && asize != 0) continue; - + if (a != NULL && (a->offset != aoff || a->size != asize)) continue;
@@ -155,7 +155,7 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff, b->offset == boff && b->size == bsize) { GP_DEBUG(1, "Pixel found type id %u name '%s'", GP_PixelTypes[i].type, GP_PixelTypes[i].name); - + return GP_PixelTypes[i].type; } } diff --git a/libs/core/GP_Pixel.gen.c.t b/libs/core/GP_Pixel.gen.c.t index 9dc56f8..96ba421 100644 --- a/libs/core/GP_Pixel.gen.c.t +++ b/libs/core/GP_Pixel.gen.c.t @@ -40,8 +40,8 @@ Pixel type definitions and functions {% if pt.is_cmyk() %} | GP_PIXEL_IS_CMYK{% endif -%} %%- endmacro
-/* - * Description of all known pixel types +/* + * Description of all known pixel types */ const GP_PixelTypeDescription const GP_PixelTypes [GP_PIXEL_MAX] = { %% for pt in pixeltypes @@ -64,7 +64,7 @@ const GP_PixelTypeDescription const GP_PixelTypes [GP_PIXEL_MAX] = { %% for pt in pixeltypes %% if not pt.is_unknown() /* - * snprintf a human readable value of pixel type {{pt.name}} + * snprintf a human readable value of pixel type {{pt.name}} */ static void GP_PixelSNPrint_{{ pt.name }}(char *buf, size_t len, GP_Pixel p) { diff --git a/libs/core/GP_Threads.c b/libs/core/GP_Threads.c index ff59d75..0f396d2 100644 --- a/libs/core/GP_Threads.c +++ b/libs/core/GP_Threads.c @@ -58,9 +58,9 @@ unsigned int GP_NrThreads(GP_Size w, GP_Size h, GP_ProgressCallback *callback) count = nr_threads; GP_DEBUG(1, "Using nr_threads=%i", count); } - + threads = GP_MIN(count, (int)(w * h / 1024) + 1); - + /* Call to the sysconf may return -1 if unsupported */ if (threads < -1) threads = 1; @@ -74,7 +74,7 @@ unsigned int GP_NrThreads(GP_Size w, GP_Size h, GP_ProgressCallback *callback) void GP_NrThreadsSet(unsigned int nr) { nr_threads = nr; - + GP_DEBUG(1, "Setting default number of threads to %u", nr); }
@@ -82,7 +82,7 @@ int GP_ProgressCallbackMP(GP_ProgressCallback *self) { struct GP_ProgressCallbackMPPriv *priv = self->priv;
- /* + /* * If any thread got non-zero return value from a callback abort all. */ if (priv->abort) @@ -99,7 +99,7 @@ int GP_ProgressCallbackMP(GP_ProgressCallback *self)
/* Call the original callback */ int ret = priv->orig_callback->callback(priv->orig_callback); - + /* Turn on abort flag if callback returned nonzero */ if (ret) priv->abort = 1; diff --git a/libs/filters/GP_Blur.c b/libs/filters/GP_Blur.c index 420073e..bd66c9c 100644 --- a/libs/filters/GP_Blur.c +++ b/libs/filters/GP_Blur.c @@ -43,7 +43,7 @@ static inline float gaussian_kernel_init(float sigma, float *kernel) float ret = 0;
double sigma2 = sigma * sigma; - + for (i = 0; i < N; i++) { double r = center - i; kernel[i] = exp(-0.5 * (r * r) / sigma2); @@ -79,10 +79,10 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src, { unsigned int size_x = gaussian_kernel_size(sigma_x); unsigned int size_y = gaussian_kernel_size(sigma_y); - + GP_DEBUG(1, "Gaussian blur sigma_x=%2.3f sigma_y=%2.3f kernel %ix%i image %ux%u", sigma_x, sigma_y, size_x, size_y, w_src, h_src); - + GP_ProgressCallback *new_callback = NULL;
GP_ProgressCallback gaussian_callback = { @@ -117,7 +117,7 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src, if (GP_FilterHConvolutionMP_Raw(¶ms)) return 1; } - + if (new_callback != NULL) new_callback->callback = gaussian_callback_vert;
@@ -125,7 +125,7 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src, if (sigma_y > 0) { float kernel_y[size_y]; float sum = gaussian_kernel_init(sigma_y, kernel_y); - + GP_ConvolutionParams params = { .src = src, .x_src = x_src, @@ -141,7 +141,7 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src, .kern_div = sum, .callback = new_callback, }; - + if (GP_FilterVConvolutionMP_Raw(¶ms)) return 1; } @@ -159,11 +159,11 @@ int GP_FilterGaussianBlurEx(const GP_Context *src, GP_ProgressCallback *callback) { GP_CHECK(src->pixel_type == dst->pixel_type); - + /* Check that destination is large enough */ GP_CHECK(x_dst + (GP_Coord)w_src <= (GP_Coord)dst->w); GP_CHECK(y_dst + (GP_Coord)h_src <= (GP_Coord)dst->h); - + return GP_FilterGaussianBlur_Raw(src, x_src, y_src, w_src, h_src, dst, x_dst, y_dst, sigma_x, sigma_y, callback); diff --git a/libs/filters/GP_Convolution.c b/libs/filters/GP_Convolution.c index 0b81e55..b01f768 100644 --- a/libs/filters/GP_Convolution.c +++ b/libs/filters/GP_Convolution.c @@ -33,7 +33,7 @@ int GP_FilterConvolutionEx(const GP_Context *src, GP_ProgressCallback *callback) { GP_CHECK(src->pixel_type == dst->pixel_type); - + /* Check that destination is large enough */ GP_CHECK(x_dst + (GP_Coord)w_src <= (GP_Coord)dst->w); GP_CHECK(y_dst + (GP_Coord)h_src <= (GP_Coord)dst->h); diff --git a/libs/filters/GP_Dither.c b/libs/filters/GP_Dither.c index ad87e9b..a050513 100644 --- a/libs/filters/GP_Dither.c +++ b/libs/filters/GP_Dither.c @@ -39,9 +39,9 @@ GP_Context *GP_FilterFloydSteinberg_RGB888_Alloc(const GP_Context *src, GP_ProgressCallback *callback) { GP_Context *ret; - + ret = GP_ContextAlloc(src->w, src->h, pixel_type); - + if (ret == NULL) return NULL;
diff --git a/libs/filters/GP_Edge.c b/libs/filters/GP_Edge.c index 349c36b..7d55077 100644 --- a/libs/filters/GP_Edge.c +++ b/libs/filters/GP_Edge.c @@ -47,7 +47,7 @@ static int prewitt(const GP_Context *src, GP_Context *dx, GP_Context *dy, grad_kern, 3, 1, smooth_kern, 3, 1, callback)) return 1; - + return 0; }
@@ -81,13 +81,13 @@ static int sobel(const GP_Context *src, GP_Context *dx, GP_Context *dy,
if (GP_FilterConvolution_Raw(&dx_conv)) return 1; - + float dy_kern[] = { -1, -2, -1, 0, 0, 0, 1, 2, 1, }; - + GP_ConvolutionParams dy_conv = { .src = src, .x_src = 0, @@ -137,9 +137,9 @@ static int edge_detect(const GP_Context *src, default: goto err0; } - + uint32_t i, j; - + for (i = 0; i < src->w; i++) { for (j = 0; j < src->h; j++) { GP_Pixel pix_x = GP_GetPixel_Raw_24BPP(dx, i, j); @@ -152,43 +152,43 @@ static int edge_detect(const GP_Context *src, Rx = GP_Pixel_GET_R_RGB888(pix_x); Gx = GP_Pixel_GET_G_RGB888(pix_x); Bx = GP_Pixel_GET_B_RGB888(pix_x); - + Ry = GP_Pixel_GET_R_RGB888(pix_y); Gy = GP_Pixel_GET_G_RGB888(pix_y); By = GP_Pixel_GET_B_RGB888(pix_y); - + RE = sqrt(Rx*Rx + Ry*Ry) + 0.5; GE = sqrt(Gx*Gx + Gy*Gy) + 0.5; BE = sqrt(Bx*Bx + By*By) + 0.5; - + GP_PutPixel_Raw_24BPP(dx, i, j, GP_Pixel_CREATE_RGB888(RE, GE, BE)); - + if (Rx != 0 && Ry != 0) RPhi = ((atan2(Rx, Ry) + M_PI) * 255)/(2*M_PI); else RPhi = 0; - + if (Gx != 0 && Gy != 0) GPhi = ((atan2(Gx, Gy) + M_PI) * 255)/(2*M_PI); else GPhi = 0; - + if (Bx != 0 && By != 0) BPhi = ((atan2(Bx, By) + M_PI) * 255)/(2*M_PI); else BPhi = 0; - + GP_PutPixel_Raw_24BPP(dy, i, j, GP_Pixel_CREATE_RGB888(RPhi, GPhi, BPhi)); } } - + if (Phi != NULL) *Phi = dy; else GP_ContextFree(dy); - + if (E != NULL) *E = dx; else diff --git a/libs/filters/GP_FilterParam.c b/libs/filters/GP_FilterParam.c index e6c0f6b..fe7537c 100644 --- a/libs/filters/GP_FilterParam.c +++ b/libs/filters/GP_FilterParam.c @@ -28,8 +28,8 @@
GP_FilterParam *GP_FilterParamCreate(GP_PixelType pixel_type) { - GP_FilterParam *ret; - + GP_FilterParam *ret; + ret = malloc((GP_PixelTypes[pixel_type].numchannels + 1) * sizeof(GP_FilterParam));
@@ -51,7 +51,7 @@ void GP_FilterParamDestroy(GP_FilterParam *self) static unsigned int count_channels(GP_FilterParam params[]) { unsigned int i = 0; - + while (params[i].channel_name[0] != '0') i++;
@@ -80,7 +80,7 @@ int GP_FilterParamCheckPixelType(GP_FilterParam params[], { unsigned int i, num_channels; const GP_PixelTypeChannel *channels; - + num_channels = GP_PixelTypes[pixel_type].numchannels; channels = GP_PixelTypes[pixel_type].channels;
@@ -92,7 +92,7 @@ int GP_FilterParamCheckPixelType(GP_FilterParam params[], for (i = 0; i < num_channels; i++) if (GP_FilterParamChannel(params, channels[i].name) == NULL) return 1; - + return 0; }
@@ -104,7 +104,7 @@ int GP_FilterParamCheckChannels(GP_FilterParam params[], for (i = 0; channel_names[i] != NULL; i++) if (GP_FilterParamChannel(params, channel_names[i]) == NULL) return 1; - + if (i != count_channels(params)) return 1;
@@ -116,15 +116,15 @@ void GP_FilterParamInitChannels(GP_FilterParam params[], { unsigned int i, num_channels; const GP_PixelTypeChannel *channels; - + num_channels = GP_PixelTypes[pixel_type].numchannels; channels = GP_PixelTypes[pixel_type].channels; - + for (i = 0; i < num_channels; i++) { strcpy(params[i].channel_name, channels[i].name); memset(¶ms[i].val, 0, sizeof(GP_FilterParamVal)); } - + params[i].channel_name[0] = '0'; }
@@ -219,7 +219,7 @@ int GP_FilterParamSetPtr(GP_FilterParam params[], const char *channel_name, void GP_FilterParamFreePtrAll(GP_FilterParam params[]) { unsigned int i; - + for (i = 0; params[i].channel_name[0] != '0'; i++) free(params[i].val.ptr); } @@ -227,7 +227,7 @@ void GP_FilterParamFreePtrAll(GP_FilterParam params[]) void GP_FilterParamPrintInt(GP_FilterParam params[]) { unsigned int i; - + for (i = 0; params[i].channel_name[0] != '0'; i++) printf("Chann '%s' = %in", params[i].channel_name, params[i].val.i); } @@ -235,7 +235,7 @@ void GP_FilterParamPrintInt(GP_FilterParam params[]) void GP_FilterParamPrintUInt(GP_FilterParam params[]) { unsigned int i; - + for (i = 0; params[i].channel_name[0] != '0'; i++) printf("Chann '%s' = %un", params[i].channel_name, params[i].val.ui); } @@ -243,7 +243,7 @@ void GP_FilterParamPrintUInt(GP_FilterParam params[]) void GP_FilterParamPrintFloat(GP_FilterParam params[]) { unsigned int i; - + for (i = 0; params[i].channel_name[0] != '0'; i++) printf("Chann '%s' = %fn", params[i].channel_name, params[i].val.f); } @@ -251,7 +251,7 @@ void GP_FilterParamPrintFloat(GP_FilterParam params[]) void GP_FilterParamPrintPtr(GP_FilterParam params[]) { unsigned int i; - + for (i = 0; params[i].channel_name[0] != '0'; i++) printf("Chann '%s' = %pn", params[i].channel_name, params[i].val.ptr); } diff --git a/libs/filters/GP_FloydSteinberg.gen.c.t b/libs/filters/GP_FloydSteinberg.gen.c.t index fde40d9..2d4d401 100644 --- a/libs/filters/GP_FloydSteinberg.gen.c.t +++ b/libs/filters/GP_FloydSteinberg.gen.c.t @@ -38,7 +38,7 @@
if ({{ x }} > 1) {{ errors }}[!({{ y }}%2)][{{ x }}-1] += 3 * {{ err }} / 16; - + {{ errors }}[!({{ y }}%2)][{{ x }}] += 5 * {{ err }} / 16;
if ({{ x }} + 1 < {{ w }}) @@ -70,9 +70,9 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G %% endfor
for (y = 0; y < (GP_Coord)src->h; y++) { - for (x = 0; x < (GP_Coord)src->w; x++) { + for (x = 0; x < (GP_Coord)src->w; x++) { GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, x, y); - + %% for c in pt.chanslist %% if pt.is_gray() float val_{{ c[0] }} = GP_Pixel_GET_R_RGB888(pix) + @@ -80,9 +80,9 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G GP_Pixel_GET_B_RGB888(pix); %% else float val_{{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_RGB888(pix); -%% endif +%% endif val_{{ c[0] }} += errors_{{ c[0] }}[y%2][x]; - + float err_{{ c[0] }} = val_{{ c[0] }}; %% if pt.is_gray() GP_Pixel res_{{ c[0] }} = {{ 2 ** c[2] - 1}} * val_{{ c[0] }} / (3 * 255); @@ -96,7 +96,7 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G
{{ clamp_val("res_%s"|format(c[0]), c[2]) }} %% endfor - + %% if pt.is_gray() GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, res_V); %% else @@ -109,7 +109,7 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G %% for c in pt.chanslist memset(errors_{{ c[0] }}[y%2], 0, src->w * sizeof(float)); %% endfor - + if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) return 1; } diff --git a/libs/filters/GP_GaussianNoise.gen.c.t b/libs/filters/GP_GaussianNoise.gen.c.t index bc37bdf..3e4764b 100644 --- a/libs/filters/GP_GaussianNoise.gen.c.t +++ b/libs/filters/GP_GaussianNoise.gen.c.t @@ -48,7 +48,7 @@ static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Context *src, { GP_DEBUG(1, "Additive Gaussian noise filter %ux%u sigma=%f mu=%f", w_src, h_src, sigma, mu); - + %% for c in pt.chanslist int sigma_{{ c[0] }} = {{ 2 ** c[2] - 1 }} * sigma; int mu_{{ c[0] }} = {{ 2 ** c[2] - 1 }} * mu; @@ -62,7 +62,7 @@ static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Context *src, %% for c in pt.chanslist int *{{ c[0] }} = GP_TempAllocGet(temp, size * sizeof(int)); %% endfor - + /* Apply the additive noise filter */ unsigned int x, y;
@@ -70,15 +70,15 @@ static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Context *src, %% for c in pt.chanslist GP_NormInt({{ c[0] }}, size, sigma_{{ c[0] }}, mu_{{ c[0] }}); %% endfor - + for (x = 0; x < w_src; x++) { GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x + x_src, y + y_src); - + %% for c in pt.chanslist {{ c[0] }}[x] += GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix); {{ c[0] }}[x] = GP_CLAMP({{ c[0] }}[x], 0, {{ 2 ** c[2] - 1 }}); %% endfor - + pix = GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "", "[x]") }}); GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x + x_dst, y + y_dst, pix); } @@ -88,7 +88,7 @@ static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Context *src, return 1; } } - + GP_TempAllocFree(temp); GP_ProgressCallbackDone(callback);
@@ -130,7 +130,7 @@ int GP_FilterGaussianNoiseAddEx(const GP_Context *src, GP_ProgressCallback *callback) { GP_CHECK(src->pixel_type == dst->pixel_type); - + /* Check that destination is large enough */ GP_CHECK(x_dst + (GP_Coord)w_src <= (GP_Coord)dst->w); GP_CHECK(y_dst + (GP_Coord)h_src <= (GP_Coord)dst->h); diff --git a/libs/filters/GP_HilbertPeano.gen.c.t b/libs/filters/GP_HilbertPeano.gen.c.t index 9c84bee..90ed943 100644 --- a/libs/filters/GP_HilbertPeano.gen.c.t +++ b/libs/filters/GP_HilbertPeano.gen.c.t @@ -65,7 +65,7 @@ int GP_FilterHilbertPeano_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, GP_DEBUG(1, "Hilbert Peano dithering %ux%u -> n = %u", src->w, src->h, n);
GP_HilbertCurveInit(&state, n); - + /* processed pixels counter */ unsigned int cnt = 0;
@@ -85,7 +85,7 @@ int GP_FilterHilbertPeano_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, GP_Pixel_GET_B_RGB888(pix); %% else int pix_{{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_RGB888(pix); -%% endif +%% endif
pix_{{ c[0] }} += err_{{ c[0] }};
diff --git a/libs/filters/GP_Laplace.c b/libs/filters/GP_Laplace.c index a21be78..3081ace 100644 --- a/libs/filters/GP_Laplace.c +++ b/libs/filters/GP_Laplace.c @@ -50,7 +50,7 @@ GP_Context *GP_FilterLaplaceAlloc(const GP_Context *src,
if (ret == NULL) return NULL; - + if (GP_FilterLaplace(src, ret, callback)) { GP_ContextFree(ret); return NULL; @@ -67,7 +67,7 @@ int GP_FilterEdgeSharpening(const GP_Context *src, GP_Context *dst, float kern[9] = {0, 0, 0, 0, 1, 0, 0, 0, 0}; - + GP_DEBUG(1, "Laplace Edge Sharpening filter %ux%u w=%f", src->w, src->h, w);
@@ -92,7 +92,7 @@ GP_Context *GP_FilterEdgeSharpeningAlloc(const GP_Context *src, float w,
if (ret == NULL) return NULL; - + if (GP_FilterEdgeSharpening(src, ret, w, callback)) { GP_ContextFree(ret); return NULL; diff --git a/libs/filters/GP_Linear.c b/libs/filters/GP_Linear.c index a87372f..5956b09 100644 --- a/libs/filters/GP_Linear.c +++ b/libs/filters/GP_Linear.c @@ -68,7 +68,7 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src, int *G = GP_TempAllocGet(temp, size * sizeof(int)); int *B = GP_TempAllocGet(temp, size * sizeof(int));
- /* Do horizontal linear convolution */ + /* Do horizontal linear convolution */ for (y = 0; y < (GP_Coord)h_src; y++) { int yi = GP_MIN(y_src + y, (int)src->h - 1);
@@ -83,7 +83,7 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src, R[i] = GP_Pixel_GET_R_RGB888(pix); G[i] = GP_Pixel_GET_G_RGB888(pix); B[i] = GP_Pixel_GET_B_RGB888(pix); - + i++; xi++; } @@ -95,7 +95,7 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src, R[i] = GP_Pixel_GET_R_RGB888(pix); G[i] = GP_Pixel_GET_G_RGB888(pix); B[i] = GP_Pixel_GET_B_RGB888(pix); - + i++; xi++; } @@ -105,7 +105,7 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src, R[i] = GP_Pixel_GET_R_RGB888(pix); G[i] = GP_Pixel_GET_G_RGB888(pix); B[i] = GP_Pixel_GET_B_RGB888(pix); - + i++; }
@@ -119,12 +119,12 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src, g += (*pG++) * ikernel[i]; b += (*pB++) * ikernel[i]; } - + /* divide the result */ r /= ikern_div; g /= ikern_div; b /= ikern_div; - + /* and clamp just to be extra sure */ r = GP_CLAMP(r, 0, 255); g = GP_CLAMP(g, 0, 255); @@ -139,7 +139,7 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src, return 1; } } - + GP_TempAllocFree(temp);
GP_ProgressCallbackDone(callback); @@ -165,7 +165,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, GP_DEBUG(1, "Vertical linear convolution kernel width %u " "offset %ix%i rectangle %ux%u", kh, x_src, y_src, w_src, h_src); - + /* Not yet implemented */ if (src->pixel_type != GP_PIXEL_RGB888) { errno = ENOSYS; @@ -173,7 +173,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, }
ikern_div = kern_div * MUL + 0.5; - + /* Create temporary buffers */ GP_TempAllocCreate(temp, 3 * size * sizeof(int));
@@ -181,10 +181,10 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, int *G = GP_TempAllocGet(temp, size * sizeof(int)); int *B = GP_TempAllocGet(temp, size * sizeof(int));
- /* Do vertical linear convolution */ + /* Do vertical linear convolution */ for (x = 0; x < (GP_Coord)w_src; x++) { int xi = GP_MIN(x_src + x, (int)src->w - 1); - + /* Fetch the whole row */ GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, xi, 0);
@@ -196,7 +196,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, R[i] = GP_Pixel_GET_R_RGB888(pix); G[i] = GP_Pixel_GET_G_RGB888(pix); B[i] = GP_Pixel_GET_B_RGB888(pix); - + i++; yi++; } @@ -208,7 +208,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, R[i] = GP_Pixel_GET_R_RGB888(pix); G[i] = GP_Pixel_GET_G_RGB888(pix); B[i] = GP_Pixel_GET_B_RGB888(pix); - + i++; yi++; } @@ -218,10 +218,10 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, R[i] = GP_Pixel_GET_R_RGB888(pix); G[i] = GP_Pixel_GET_G_RGB888(pix); B[i] = GP_Pixel_GET_B_RGB888(pix); - + i++; } - + for (y = 0; y < (GP_Coord)h_src; y++) { int32_t r = MUL/2, g = MUL/2, b = MUL/2; int *pR = R + y, *pG = G + y, *pB = B + y; @@ -237,7 +237,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, r /= ikern_div; g /= ikern_div; b /= ikern_div; - + /* and clamp just to be extra sure */ r = GP_CLAMP(r, 0, 255); g = GP_CLAMP(g, 0, 255); @@ -246,7 +246,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, GP_PutPixel_Raw_24BPP(dst, x_dst + x, y_dst + y, GP_Pixel_CREATE_RGB888(r, g, b)); } - + if (GP_ProgressCallbackReport(callback, x, w_src, h_src)) { GP_TempAllocFree(temp); return 1; @@ -254,7 +254,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, }
GP_TempAllocFree(temp); - + GP_ProgressCallbackDone(callback); return 0; } @@ -298,15 +298,15 @@ int GP_FilterVHLinearConvolution_Raw(const GP_Context *src, hkernel, kw, hkern_div, new_callback)) return 1; - + conv_callback.callback = v_callback; - + if (GP_FilterHLinearConvolution_Raw(dst, x_src, y_src, w_src, h_src, dst, x_dst, y_dst, vkernel, kh, vkern_div, new_callback)) return 1; - + GP_ProgressCallbackDone(callback); return 0; } @@ -324,14 +324,14 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src,
GP_DEBUG(1, "Linear convolution kernel %ix%i rectangle %ux%u", kw, kh, w_src, h_src); - + /* Not yet implemented */ if (src->pixel_type != GP_PIXEL_RGB888) { errno = ENOSYS; return 1; }
- /* Do linear convolution */ + /* Do linear convolution */ for (y = 0; y < (GP_Coord)h_src; y++) { uint32_t R[kw][kh], G[kw][kh], B[kw][kh]; GP_Pixel pix; @@ -343,8 +343,8 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src, int yi = y_src + y + j - kh/2;
xi = GP_CLAMP(xi, 0, (int)src->w - 1); - yi = GP_CLAMP(yi, 0, (int)src->h - 1); - + yi = GP_CLAMP(yi, 0, (int)src->h - 1); + pix = GP_GetPixel_Raw_24BPP(src, xi, yi);
R[i][j] = GP_Pixel_GET_R_RGB888(pix); @@ -361,9 +361,9 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src, for (j = 0; j < kh; j++) { int xi = x_src + x + kw/2; int yi = y_src + y + j - kh/2; - + xi = GP_CLAMP(xi, 0, (int)src->w - 1); - yi = GP_CLAMP(yi, 0, (int)src->h - 1); + yi = GP_CLAMP(yi, 0, (int)src->h - 1);
pix = GP_GetPixel_Raw_24BPP(src, xi, yi);
@@ -371,7 +371,7 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src, G[idx][j] = GP_Pixel_GET_G_RGB888(pix); B[idx][j] = GP_Pixel_GET_B_RGB888(pix); } - + /* Count the pixel value from neighbours weighted by kernel */ for (i = 0; i < kw; i++) { int k; @@ -401,13 +401,13 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src, pix = GP_Pixel_CREATE_RGB888((uint32_t)r, (uint32_t)g, (uint32_t)b);
GP_PutPixel_Raw_24BPP(dst, x_dst + x, y_dst + y, pix); - + idx++;
if (idx >= (int)kw) idx = 0; } - + if (GP_ProgressCallbackReport(callback, y, h_src, w_src)) return 1; } diff --git a/libs/filters/GP_LinearThreads.c b/libs/filters/GP_LinearThreads.c index 2ab625e..554d492 100644 --- a/libs/filters/GP_LinearThreads.c +++ b/libs/filters/GP_LinearThreads.c @@ -36,14 +36,14 @@ static void *h_linear_convolution(void *arg) struct GP_ConvolutionParams *params = arg;
long ret = GP_FilterHConvolution_Raw(params); - + return (void*)ret; }
static void *v_linear_convolution(void *arg) { struct GP_ConvolutionParams *params = arg; - + long ret = GP_FilterVConvolution_Raw(params);
return (void*)ret; @@ -52,7 +52,7 @@ static void *v_linear_convolution(void *arg) static void *linear_convolution(void *arg) { struct GP_ConvolutionParams *params = arg; - + long ret = GP_FilterConvolution_Raw(params);
return (void*)ret; @@ -79,7 +79,7 @@ int GP_FilterHConvolutionMP_Raw(const GP_ConvolutionParams *params) GP_Coord y_src_2 = params->y_src + i * h; GP_Coord y_dst_2 = params->y_dst + i * h; GP_Size h_src_2 = h; - + if (i == t - 1) h_src_2 = params->h_src - i * h;
@@ -101,7 +101,7 @@ int GP_FilterHConvolutionMP_Raw(const GP_ConvolutionParams *params)
ret |= (int)r; } - + return ret; }
@@ -112,12 +112,12 @@ int GP_FilterVConvolutionMP_Raw(const GP_ConvolutionParams *params)
if (t == 1) return GP_FilterVConvolution_Raw(params); - + GP_ASSERT(params->src != params->dst, "Multithreaded convolution can't work in-place"); - + GP_PROGRESS_CALLBACK_MP(callback_mp, params->callback); - + /* Run t threads */ pthread_t threads[t]; struct GP_ConvolutionParams convs[t]; @@ -127,7 +127,7 @@ int GP_FilterVConvolutionMP_Raw(const GP_ConvolutionParams *params) GP_Coord y_src_2 = params->y_src + i * h; GP_Coord y_dst_2 = params->y_dst + i * h; GP_Size h_src_2 = h; - + if (i == t - 1) h_src_2 = params->h_src - i * h;
@@ -136,7 +136,7 @@ int GP_FilterVConvolutionMP_Raw(const GP_ConvolutionParams *params) convs[i].h_src = h_src_2; convs[i].y_dst = y_dst_2; convs[i].callback = params->callback ? &callback_mp : NULL; - + pthread_create(&threads[i], NULL, v_linear_convolution, &convs[i]); }
@@ -148,7 +148,7 @@ int GP_FilterVConvolutionMP_Raw(const GP_ConvolutionParams *params)
ret |= (int)r; } - + return ret; }
@@ -159,12 +159,12 @@ int GP_FilterConvolutionMP_Raw(const GP_ConvolutionParams *params)
if (t == 1) return GP_FilterConvolution_Raw(params); - + GP_ASSERT(params->src != params->dst, "Multithreaded convolution can't work in-place");
GP_PROGRESS_CALLBACK_MP(callback_mp, params->callback); - + /* Run t threads */ pthread_t threads[t]; struct GP_ConvolutionParams convs[t]; @@ -174,7 +174,7 @@ int GP_FilterConvolutionMP_Raw(const GP_ConvolutionParams *params) GP_Coord y_src_2 = params->y_src + i * h; GP_Coord y_dst_2 = params->y_dst + i * h; GP_Size h_src_2 = h; - + if (i == t - 1) h_src_2 = params->h_src - i * h;
@@ -183,7 +183,7 @@ int GP_FilterConvolutionMP_Raw(const GP_ConvolutionParams *params) convs[i].h_src = h_src_2; convs[i].y_dst = y_dst_2; convs[i].callback = params->callback ? &callback_mp : NULL; - + pthread_create(&threads[i], NULL, linear_convolution, &convs[i]); }
@@ -195,6 +195,6 @@ int GP_FilterConvolutionMP_Raw(const GP_ConvolutionParams *params)
ret |= (int)r; } - + return ret; } diff --git a/libs/filters/GP_Median.c b/libs/filters/GP_Median.c index 130ad92..170ce24 100644 --- a/libs/filters/GP_Median.c +++ b/libs/filters/GP_Median.c @@ -77,7 +77,7 @@ static inline void hist8_add_fine(struct hist8u *out, struct hist8 *in, unsigned out->coarse[i + 1] += in[x].coarse[i + 1]; out->coarse[i + 2] += in[x].coarse[i + 2]; out->coarse[i + 3] += in[x].coarse[i + 3]; - + for (j = 0; j < 16; j++) { out->fine[i + 0][j] += in[x].fine[i + 0][j]; out->fine[i + 1][j] += in[x].fine[i + 1][j]; @@ -147,22 +147,22 @@ static inline unsigned int hist8_median(struct hist8u *h, struct hist8 *row,
for (i = 0; i < 16; i++) { acc += h->coarse[i]; - + if (acc >= trigger) { acc -= h->coarse[i]; - + /* update fine on position i */ hist8_update(h, i, row, x, xmed);
for (j = 0; j < 16; j++) { acc += h->fine[i][j]; - + if (acc >= trigger) return (i<<4) | j; } } } - + GP_BUG("Trigger not reached"); return 0; } @@ -185,7 +185,7 @@ static int GP_FilterMedian_Raw(const GP_Context *src,
GP_DEBUG(1, "Median filter size %ux%u xmed=%u ymed=%u", w_src, h_src, 2 * xmed + 1, 2 * ymed + 1); - + /* The buffer is w + 2*xmed + 1 size because we read the last value but we don't use it */ unsigned int size = (w_src + 2 * xmed + 1);
@@ -195,7 +195,7 @@ static int GP_FilterMedian_Raw(const GP_Context *src, struct hist8 *R = GP_TempAllocGet(temp, sizeof(struct hist8) * size); struct hist8 *G = GP_TempAllocGet(temp, sizeof(struct hist8) * size); struct hist8 *B = GP_TempAllocGet(temp, sizeof(struct hist8) * size); - + memset(R, 0, sizeof(*R) * size); memset(G, 0, sizeof(*G) * size); memset(B, 0, sizeof(*B) * size); @@ -207,15 +207,15 @@ static int GP_FilterMedian_Raw(const GP_Context *src, /* Prefill row of histograms */ for (x = 0; x < (int)w_src + 2*xmed; x++) { int xi = GP_CLAMP(x_src + x - xmed, 0, (int)src->w - 1); - + for (y = -ymed; y <= ymed; y++) { int yi = GP_CLAMP(y_src + y, 0, (int)src->h - 1); - + GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, xi, yi); - + hist8_inc(R, x, GP_Pixel_GET_R_RGB888(pix)); - hist8_inc(G, x, GP_Pixel_GET_G_RGB888(pix)); - hist8_inc(B, x, GP_Pixel_GET_B_RGB888(pix)); + hist8_inc(G, x, GP_Pixel_GET_G_RGB888(pix)); + hist8_inc(B, x, GP_Pixel_GET_B_RGB888(pix)); } }
@@ -224,7 +224,7 @@ static int GP_FilterMedian_Raw(const GP_Context *src, memset(XR, 0, sizeof(*XR)); memset(XG, 0, sizeof(*XG)); memset(XB, 0, sizeof(*XB)); - + /* Compute first histogram */ for (i = 0; i <= 2*xmed; i++) { hist8_add_fine(XR, R, i); @@ -240,7 +240,7 @@ static int GP_FilterMedian_Raw(const GP_Context *src,
GP_PutPixel_Raw_24BPP(dst, x_dst + x, y_dst + y, GP_Pixel_CREATE_RGB888(r, g, b)); - + /* Recompute histograms */ hist8_sub(XR, R, x); hist8_sub(XG, G, x); @@ -255,22 +255,22 @@ static int GP_FilterMedian_Raw(const GP_Context *src, for (x = 0; x < (int)w_src + 2*xmed; x++) { int xi = GP_CLAMP(x_src + x - xmed, 0, (int)src->w - 1); int yi = GP_CLAMP(y_src + y - ymed, 0, (int)src->h - 1); - + GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, xi, yi); - - hist8_dec(R, x, GP_Pixel_GET_R_RGB888(pix)); - hist8_dec(G, x, GP_Pixel_GET_G_RGB888(pix)); - hist8_dec(B, x, GP_Pixel_GET_B_RGB888(pix)); - + + hist8_dec(R, x, GP_Pixel_GET_R_RGB888(pix)); + hist8_dec(G, x, GP_Pixel_GET_G_RGB888(pix)); + hist8_dec(B, x, GP_Pixel_GET_B_RGB888(pix)); + yi = GP_MIN(y_src + y + ymed + 1, (int)src->h - 1); - + pix = GP_GetPixel_Raw_24BPP(src, xi, yi); - - hist8_inc(R, x, GP_Pixel_GET_R_RGB888(pix)); - hist8_inc(G, x, GP_Pixel_GET_G_RGB888(pix)); + + hist8_inc(R, x, GP_Pixel_GET_R_RGB888(pix)); + hist8_inc(G, x, GP_Pixel_GET_G_RGB888(pix)); hist8_inc(B, x, GP_Pixel_GET_B_RGB888(pix)); } - + if (GP_ProgressCallbackReport(callback, y, h_src, w_src)) { GP_TempAllocFree(temp); return 1; @@ -292,7 +292,7 @@ int GP_FilterMedianEx(const GP_Context *src, GP_ProgressCallback *callback) { GP_CHECK(src->pixel_type == dst->pixel_type); - + /* Check that destination is large enough */ GP_CHECK(x_dst + (GP_Coord)w_src <= (GP_Coord)dst->w); GP_CHECK(y_dst + (GP_Coord)h_src <= (GP_Coord)dst->h); diff --git a/libs/filters/GP_MirrorV.gen.c.t b/libs/filters/GP_MirrorV.gen.c.t index b2d4b86..99599af 100644 --- a/libs/filters/GP_MirrorV.gen.c.t +++ b/libs/filters/GP_MirrorV.gen.c.t @@ -39,7 +39,7 @@ static int GP_MirrorV_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Pixel tmp;
GP_DEBUG(1, "Mirroring image vertically %ux%u", src->w, src->h); - + for (x = 0; x < src->w/2; x++) { uint32_t xm = src->w - x - 1; for (y = 0; y < src->h; y++) { diff --git a/libs/filters/GP_Resize.c b/libs/filters/GP_Resize.c index 8641321..24d58a2 100644 --- a/libs/filters/GP_Resize.c +++ b/libs/filters/GP_Resize.c @@ -158,7 +158,7 @@ const char *GP_InterpolationTypeName(enum GP_InterpolationType interp_type) if (interp_type > GP_INTERP_MAX) return "Unknown";
- return interp_types[interp_type]; + return interp_types[interp_type]; }
#define A 0.5 @@ -223,26 +223,26 @@ int GP_FilterInterpolate_Cubic(const GP_Context *src, GP_Context *dst, float x = (1.00 * i / (dst->w - 1)) * (src->w - 1); v4f cvx; int xi[4]; - + xi[0] = floor(x - 1); xi[1] = x; xi[2] = x + 1; xi[3] = x + 2; - + cvx.f[0] = cubic(xi[0] - x); cvx.f[1] = cubic(xi[1] - x); cvx.f[2] = cubic(xi[2] - x); cvx.f[3] = cubic(xi[3] - x); - + if (xi[0] < 0) xi[0] = 0;
if (xi[2] >= (int)src->w) xi[2] = src->w - 1; - + if (xi[3] >= (int)src->w) xi[3] = src->w - 1; - + /* Generate interpolated column */ for (j = 0; j < src->h; j++) { v4f rv, gv, bv; @@ -252,17 +252,17 @@ int GP_FilterInterpolate_Cubic(const GP_Context *src, GP_Context *dst, pix[1] = GP_GetPixel_Raw_24BPP(src, xi[1], j); pix[2] = GP_GetPixel_Raw_24BPP(src, xi[2], j); pix[3] = GP_GetPixel_Raw_24BPP(src, xi[3], j); - + rv.f[0] = GP_Pixel_GET_R_RGB888(pix[0]); rv.f[1] = GP_Pixel_GET_R_RGB888(pix[1]); rv.f[2] = GP_Pixel_GET_R_RGB888(pix[2]); rv.f[3] = GP_Pixel_GET_R_RGB888(pix[3]); - + gv.f[0] = GP_Pixel_GET_G_RGB888(pix[0]); gv.f[1] = GP_Pixel_GET_G_RGB888(pix[1]); gv.f[2] = GP_Pixel_GET_G_RGB888(pix[2]); gv.f[3] = GP_Pixel_GET_G_RGB888(pix[3]); - + bv.f[0] = GP_Pixel_GET_B_RGB888(pix[0]); bv.f[1] = GP_Pixel_GET_B_RGB888(pix[1]); bv.f[2] = GP_Pixel_GET_B_RGB888(pix[2]); @@ -271,7 +271,7 @@ int GP_FilterInterpolate_Cubic(const GP_Context *src, GP_Context *dst, rv = MUL_V4SF(rv, cvx); gv = MUL_V4SF(gv, cvx); bv = MUL_V4SF(bv, cvx); - + col_r[j] = SUM_V4SF(rv); col_g[j] = SUM_V4SF(gv); col_b[j] = SUM_V4SF(bv); @@ -283,41 +283,41 @@ int GP_FilterInterpolate_Cubic(const GP_Context *src, GP_Context *dst, v4f cvy, rv, gv, bv; float r, g, b; int yi[4]; - + yi[0] = floor(y - 1); yi[1] = y; yi[2] = y + 1; yi[3] = y + 2; - + cvy.f[0] = cubic(yi[0] - y); cvy.f[1] = cubic(yi[1] - y); cvy.f[2] = cubic(yi[2] - y); cvy.f[3] = cubic(yi[3] - y); - + if (yi[0] < 0) yi[0] = 0; - + if (yi[2] >= (int)src->h) yi[2] = src->h - 1; - + if (yi[3] >= (int)src->h) yi[3] = src->h - 1; - + rv.f[0] = col_r[yi[0]]; rv.f[1] = col_r[yi[1]]; rv.f[2] = col_r[yi[2]]; rv.f[3] = col_r[yi[3]]; - + gv.f[0] = col_g[yi[0]]; gv.f[1] = col_g[yi[1]]; gv.f[2] = col_g[yi[2]]; gv.f[3] = col_g[yi[3]]; - + bv.f[0] = col_b[yi[0]]; bv.f[1] = col_b[yi[1]]; bv.f[2] = col_b[yi[2]]; bv.f[3] = col_b[yi[3]]; - + rv = MUL_V4SF(rv, cvy); gv = MUL_V4SF(gv, cvy); bv = MUL_V4SF(bv, cvy); @@ -333,7 +333,7 @@ int GP_FilterInterpolate_Cubic(const GP_Context *src, GP_Context *dst, GP_Pixel pix = GP_Pixel_CREATE_RGB888((uint8_t)r, (uint8_t)g, (uint8_t)b); GP_PutPixel_Raw_24BPP(dst, i, j, pix); } - + if (GP_ProgressCallbackReport(callback, i, dst->w, dst->h)) return 1; } @@ -379,18 +379,18 @@ GP_Context *GP_FilterResize(const GP_Context *src, GP_Context *dst, "The src and dst pixel types must match"); /* * The size of w and h is asserted in subcontext initalization - */ + */ res = GP_SubContext(dst, &sub, 0, 0, w, h); }
/* * Operation was aborted by progress callback. - * + * * Free any alloacted data and exit. */ if (GP_FilterResize_Raw(src, res, type, callback)) { GP_DEBUG(1, "Operation aborted"); - + if (dst == NULL) GP_ContextFree(dst);
diff --git a/libs/filters/GP_ResizeCubic.gen.c.t b/libs/filters/GP_ResizeCubic.gen.c.t index a515a2d..a273d14 100644 --- a/libs/filters/GP_ResizeCubic.gen.c.t +++ b/libs/filters/GP_ResizeCubic.gen.c.t @@ -67,24 +67,24 @@ static int GP_FilterResizeCubicInt_{{ pt.name }}_Raw(const GP_Context *src, 1.00 * dst->w / src->w, 1.00 * dst->h / src->h);
{{ fetch_gamma_tables(pt, "src") }} - + /* pre-generate x mapping and constants */ int32_t xmap[dst->w][4]; int32_t xmap_c[dst->w][4];
for (i = 0; i < dst->w; i++) { - float x = (1.00 * i / (dst->w - 1)) * (src->w - 1); - + float x = (1.00 * i / (dst->w - 1)) * (src->w - 1); + xmap[i][0] = floor(x - 1); xmap[i][1] = x; xmap[i][2] = x + 1; xmap[i][3] = x + 2; - + xmap_c[i][0] = cubic_int((xmap[i][0] - x) * MUL + 0.5); xmap_c[i][1] = cubic_int((xmap[i][1] - x) * MUL + 0.5); xmap_c[i][2] = cubic_int((xmap[i][2] - x) * MUL + 0.5); xmap_c[i][3] = cubic_int((xmap[i][3] - x) * MUL + 0.5); - + xmap[i][0] = GP_MAX(xmap[i][0], 0); xmap[i][2] = GP_MIN(xmap[i][2], (int)src->w - 1); xmap[i][3] = GP_MIN(xmap[i][3], (int)src->w - 1); @@ -95,17 +95,17 @@ static int GP_FilterResizeCubicInt_{{ pt.name }}_Raw(const GP_Context *src, float y = (1.00 * i / (dst->h - 1)) * (src->h - 1); int32_t cvy[4]; int yi[4]; - + yi[0] = floor(y - 1); yi[1] = y; yi[2] = y + 1; yi[3] = y + 2; - + cvy[0] = cubic_int((yi[0] - y) * MUL + 0.5); cvy[1] = cubic_int((yi[1] - y) * MUL + 0.5); cvy[2] = cubic_int((yi[2] - y) * MUL + 0.5); cvy[3] = cubic_int((yi[3] - y) * MUL + 0.5); - + yi[0] = GP_MAX(yi[0], 0); yi[2] = GP_MIN(yi[2], (int)src->h - 1); yi[3] = GP_MIN(yi[3], (int)src->h - 1); @@ -121,27 +121,27 @@ static int GP_FilterResizeCubicInt_{{ pt.name }}_Raw(const GP_Context *src, pix[1] = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, j, yi[1]); pix[2] = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, j, yi[2]); pix[3] = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, j, yi[3]); - + %% for c in pt.chanslist {{ c[0] }}v[0] = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix[0]); {{ c[0] }}v[1] = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix[1]); {{ c[0] }}v[2] = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix[2]); {{ c[0] }}v[3] = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix[3]); %% endfor - + if (src->gamma) { %% for c in pt.chanslist {{ c[0] }}v[0] = {{ c[0] }}_2_LIN[{{ c[0] }}v[0]]; {{ c[0] }}v[1] = {{ c[0] }}_2_LIN[{{ c[0] }}v[1]]; {{ c[0] }}v[2] = {{ c[0] }}_2_LIN[{{ c[0] }}v[2]]; {{ c[0] }}v[3] = {{ c[0] }}_2_LIN[{{ c[0] }}v[3]]; - %% endfor + %% endfor } - + %% for c in pt.chanslist MUL_I({{ c[0] }}v, cvy); %% endfor - + %% for c in pt.chanslist col_{{ c[0] }}[j] = SUM_I({{ c[0] }}v); %% endfor @@ -153,18 +153,18 @@ static int GP_FilterResizeCubicInt_{{ pt.name }}_Raw(const GP_Context *src, int32_t {{ c[0] }}v[4]; int32_t {{ c[0] }}; %% endfor - + %% for c in pt.chanslist {{ c[0] }}v[0] = col_{{ c[0] }}[xmap[j][0]]; {{ c[0] }}v[1] = col_{{ c[0] }}[xmap[j][1]]; {{ c[0] }}v[2] = col_{{ c[0] }}[xmap[j][2]]; {{ c[0] }}v[3] = col_{{ c[0] }}[xmap[j][3]]; %% endfor - + %% for c in pt.chanslist MUL_I({{ c[0] }}v, xmap_c[j]); %% endfor - + %% for c in pt.chanslist {{ c[0] }} = (SUM_I({{ c[0] }}v) + MUL*MUL/2) / MUL / MUL; %% endfor @@ -181,11 +181,11 @@ static int GP_FilterResizeCubicInt_{{ pt.name }}_Raw(const GP_Context *src, {{ c[0] }} = GP_CLAMP_GENERIC({{ c[0] }}, 0, {{ 2 ** c[2] - 1 }}); %% endfor } - + GP_Pixel pix = GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "(uint8_t)") }}); GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, j, i, pix); } - + if (GP_ProgressCallbackReport(callback, i, dst->h, dst->w)) return 1; } diff --git a/libs/filters/GP_ResizeLinear.gen.c.t b/libs/filters/GP_ResizeLinear.gen.c.t index 06f584a..e01b2c2 100644 --- a/libs/filters/GP_ResizeLinear.gen.c.t +++ b/libs/filters/GP_ResizeLinear.gen.c.t @@ -57,7 +57,7 @@ for (i = (1<<14) - xoff[x]; i > xpix_dist; i -= xpix_dist) { if (mx < src->w - 1) mx++; - + pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, mx, y0);
%% for c in pt.chanslist @@ -68,9 +68,9 @@ if (i > 0) { if (mx < src->w - 1) mx++; - + pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, mx, y0); - + %% for c in pt.chanslist {{ c[0] }}{{ suff }} += (GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix) * i) >> 9; %% endfor @@ -100,7 +100,7 @@ * * The pixels are weighted by how much they are 'hit' by the rectangle defined * by the sampled pixel. - * + * * The implementation is inspired by imlib2 downscaling algorithm. */ static int GP_FilterResizeLinearLFInt_{{ pt.name }}_Raw(const GP_Context *src, GP_Context *dst, @@ -152,12 +152,12 @@ static int GP_FilterResizeLinearLFInt_{{ pt.name }}_Raw(const GP_Context *src, G %% endfor
for (j = (1<<14) - yoff[y]; j > ypix_dist; j -= ypix_dist) { - + x0 = xmap[x]; - + if (y0 < src->h - 1) y0++; - + {{ sample_x(pt, '1') }}
%% for c in pt.chanslist @@ -167,10 +167,10 @@ static int GP_FilterResizeLinearLFInt_{{ pt.name }}_Raw(const GP_Context *src, G
if (j > 0) { x0 = xmap[x]; - + if (y0 < src->h - 1) y0++; - + {{ sample_x(pt, '1') }}
%% for c in pt.chanslist @@ -181,11 +181,11 @@ static int GP_FilterResizeLinearLFInt_{{ pt.name }}_Raw(const GP_Context *src, G %% for c in pt.chanslist {{ c[0] }} = ({{ c[0] }} + (1<<4))>>5; %% endfor - + GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "") }})); } - + if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w)) return 1; } @@ -207,7 +207,7 @@ static int GP_FilterResizeLinearInt_{{ pt.name }}_Raw(const GP_Context *src, GP_ uint8_t xoff[dst->w + 1]; uint8_t yoff[dst->h + 1]; uint32_t x, y, i; - + GP_DEBUG(1, "Scaling image %ux%u -> %ux%u %2.2f %2.2f", src->w, src->h, dst->w, dst->h, 1.00 * dst->w / src->w, 1.00 * dst->h / src->h); @@ -243,7 +243,7 @@ static int GP_FilterResizeLinearInt_{{ pt.name }}_Raw(const GP_Context *src, GP_
if (x1 >= (GP_Coord)src->w) x1 = src->w - 1; - + y0 = ymap[y]; y1 = ymap[y] + 1;
@@ -274,11 +274,11 @@ static int GP_FilterResizeLinearInt_{{ pt.name }}_Raw(const GP_Context *src, GP_ %% for c in pt.chanslist {{ c[0] }} = ({{ c[0] }}1 * yoff[y] + {{ c[0] }}0 * (255 - yoff[y]) + (1<<15)) >> 16; %% endfor - + GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "") }})); } - + if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w)) return 1; } @@ -318,7 +318,7 @@ int GP_FilterResizeLinearLFInt_Raw(const GP_Context *src, GP_Context *dst,
GP_DEBUG(1, "Downscaling image %ux%u -> %ux%u %2.2f %2.2f", src->w, src->h, dst->w, dst->h, x_rat, y_rat); - + switch (src->pixel_type) { %% for pt in pixeltypes %% if not pt.is_unknown() and not pt.is_palette() diff --git a/libs/filters/GP_ResizeNN.gen.c.t b/libs/filters/GP_ResizeNN.gen.c.t index 65d12bb..55eb34d 100644 --- a/libs/filters/GP_ResizeNN.gen.c.t +++ b/libs/filters/GP_ResizeNN.gen.c.t @@ -43,7 +43,7 @@ static int GP_FilterResizeNN_{{ pt.name }}_Raw(const GP_Context *src, uint32_t ymap[dst->h]; uint32_t i; GP_Coord x, y; - + GP_DEBUG(1, "Scaling image %ux%u -> %ux%u %2.2f %2.2f", src->w, src->h, dst->w, dst->h, 1.00 * dst->w / src->w, 1.00 * dst->h / src->h); @@ -62,7 +62,7 @@ static int GP_FilterResizeNN_{{ pt.name }}_Raw(const GP_Context *src,
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, pix); } - + if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w)) return 1; } diff --git a/libs/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c index 4adb911..6aff0ba 100644 --- a/libs/filters/GP_Rotate.c +++ b/libs/filters/GP_Rotate.c @@ -50,7 +50,7 @@ int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst, memcpy(buf, sl1, bpr); memcpy(dl1, sl2, bpr); memcpy(dl2, buf, bpr); - + if (GP_ProgressCallbackReport(callback, 2 * y, src->h, src->w)) { GP_DEBUG(1, "Operation aborted"); errno = ECANCELED; @@ -77,7 +77,7 @@ int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst, { GP_ASSERT(src->pixel_type == dst->pixel_type, "The src and dst pixel types must match"); - + GP_ASSERT(src->w <= dst->w && src->h <= dst->h, "Destination is not large enough");
@@ -91,9 +91,9 @@ GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src, GP_ProgressCallback *callback) { GP_Context *res; - + res = GP_ContextCopy(src, 0); - + if (res == NULL) return NULL;
@@ -101,7 +101,7 @@ GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src, GP_ContextFree(res); return NULL; } - + return res; }
diff --git a/libs/filters/GP_Rotate.gen.c.t b/libs/filters/GP_Rotate.gen.c.t index 391d04f..364dd77 100644 --- a/libs/filters/GP_Rotate.gen.c.t +++ b/libs/filters/GP_Rotate.gen.c.t @@ -35,7 +35,7 @@ static int GP_FilterRotate90_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Conte GP_ProgressCallback *callback) { uint32_t x, y; - + GP_DEBUG(1, "Rotating image by 90 %ux%u", src->w, src->h);
for (x = 0; x < src->w; x++) { @@ -43,11 +43,11 @@ static int GP_FilterRotate90_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Conte uint32_t yr = src->h - y - 1; GP_PutPixel_Raw_{{ ps.suffix }}(dst, yr, x, GP_GetPixel_Raw_{{ ps.suffix }}(src, x, y)); } - + if (GP_ProgressCallbackReport(callback, x, src->w, src->h)) return 1; } - + GP_ProgressCallbackDone(callback); return 0; } @@ -73,21 +73,21 @@ static int GP_FilterRotate180_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont GP_ProgressCallback *callback) { uint32_t x, y; - + GP_DEBUG(1, "Rotating image by 180 %ux%u", src->w, src->h);
for (x = 0; x < src->w; x++) { for (y = 0; y < src->h; y++) { uint32_t xr = src->w - x - 1; uint32_t yr = src->h - y - 1; - + {{ swap_pixels(ps, 'src', 'dst', 'x', 'y', 'xr', 'yr') }} } - + if (GP_ProgressCallbackReport(callback, x, src->w, src->h)) return 1; } - + GP_ProgressCallbackDone(callback); return 0; } @@ -106,7 +106,7 @@ static int GP_FilterRotate270_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont GP_ProgressCallback *callback) { uint32_t x, y; - + GP_DEBUG(1, "Rotating image by 270 %ux%u", src->w, src->h);
for (x = 0; x < src->w; x++) { @@ -118,7 +118,7 @@ static int GP_FilterRotate270_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont if (GP_ProgressCallbackReport(callback, x, src->w, src->h)) return 1; } - + GP_ProgressCallbackDone(callback); return 0; } diff --git a/libs/filters/GP_Sigma.c b/libs/filters/GP_Sigma.c index d6d78c8..63e016a 100644 --- a/libs/filters/GP_Sigma.c +++ b/libs/filters/GP_Sigma.c @@ -45,7 +45,7 @@ static int GP_FilterSigma_Raw(const GP_Context *src, { int x, y; unsigned int x1, y1; - + if (src->pixel_type != GP_PIXEL_RGB888) { errno = ENOSYS; return -1; @@ -69,11 +69,11 @@ static int GP_FilterSigma_Raw(const GP_Context *src, unsigned int *R = GP_TempAllocGet(temp, size * sizeof(unsigned int)); unsigned int *G = GP_TempAllocGet(temp, size * sizeof(unsigned int)); unsigned int *B = GP_TempAllocGet(temp, size * sizeof(unsigned int)); - + /* prefil the sampled array */ for (x = 0; x < (int)w; x++) { int xi = GP_CLAMP(x_src + x - xrad, 0, (int)src->w - 1); - + for (y = 0; y < (int)ydiam; y++) { int yi = GP_CLAMP(y_src + y - yrad, 0, (int)src->h - 1);
@@ -116,7 +116,7 @@ static int GP_FilterSigma_Raw(const GP_Context *src, R_sum = 0; G_sum = 0; B_sum = 0; - + R_ssum = 0; G_ssum = 0; B_ssum = 0; @@ -144,14 +144,14 @@ static int GP_FilterSigma_Raw(const GP_Context *src, G_ssum += G_cur; G_cnt++; } - + if (abs(B_cur - B_center) < B_sigma) { B_ssum += B_cur; B_cnt++; } } } - + R_sum -= R_center; G_sum -= G_center; B_sum -= B_center; @@ -159,12 +159,12 @@ static int GP_FilterSigma_Raw(const GP_Context *src, unsigned int r; unsigned int g; unsigned int b; - + if (R_cnt >= min) r = R_ssum / R_cnt; else r = R_sum / cnt; - + if (G_cnt >= min) g = G_ssum / G_cnt; else @@ -174,27 +174,26 @@ static int GP_FilterSigma_Raw(const GP_Context *src, b = B_ssum / B_cnt; else b = B_sum / cnt; - + GP_PutPixel_Raw_24BPP(dst, x_dst + x, y_dst + y, GP_Pixel_CREATE_RGB888(r, g, b)); } - + int yi = GP_CLAMP(y_src + y + yrad + 1, 0, (int)src->h - 1); - + for (x = 0; x < (int)w; x++) { int xi = GP_CLAMP(x_src + x - xrad, 0, (int)src->w - 1); - + GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, xi, yi); - + R[yl * w + x] = GP_Pixel_GET_R_RGB888(pix); G[yl * w + x] = GP_Pixel_GET_G_RGB888(pix); B[yl * w + x] = GP_Pixel_GET_B_RGB888(pix); - } - + yc = (yc+1) % ydiam; yl = (yl+1) % ydiam; - + if (GP_ProgressCallbackReport(callback, y, h_src, w_src)) { GP_TempAllocFree(temp); return 1; @@ -217,7 +216,7 @@ int GP_FilterSigmaEx(const GP_Context *src, GP_ProgressCallback *callback) { GP_CHECK(src->pixel_type == dst->pixel_type); - + /* Check that destination is large enough */ GP_CHECK(x_dst + (GP_Coord)w_src <= (GP_Coord)dst->w); GP_CHECK(y_dst + (GP_Coord)h_src <= (GP_Coord)dst->h); diff --git a/libs/filters/GP_Stats.c b/libs/filters/GP_Stats.c index df65794..3ed5b68 100644 --- a/libs/filters/GP_Stats.c +++ b/libs/filters/GP_Stats.c @@ -44,7 +44,7 @@ int GP_FilterHistogram(const GP_Context *src, GP_FilterParam histogram[], for (i = 0; histogram[i].channel_name[0] != '0'; i++) { unsigned int j; GP_Histogram *hist = histogram[i].val.ptr; - + hist->max = hist->hist[0]; hist->min = hist->hist[0];
@@ -65,7 +65,7 @@ void GP_FilterHistogramAlloc(GP_PixelType type, GP_FilterParam params[]) uint32_t i;
GP_FilterParamSetPtrAll(params, NULL); - + const GP_PixelTypeChannel *channels = GP_PixelTypes[type].channels;
for (i = 0; i < GP_PixelTypes[type].numchannels; i++) { @@ -73,12 +73,12 @@ void GP_FilterHistogramAlloc(GP_PixelType type, GP_FilterParam params[])
GP_Histogram *hist = malloc(sizeof(struct GP_Histogram) + sizeof(uint32_t) * chan_size); - + if (hist == NULL) { GP_FilterHistogramFree(params); return; } - + hist->len = chan_size; memset(hist->hist, 0, sizeof(uint32_t) * chan_size);
diff --git a/libs/filters/GP_WeightedMedian.c b/libs/filters/GP_WeightedMedian.c index aac0c75..62732ee 100644 --- a/libs/filters/GP_WeightedMedian.c +++ b/libs/filters/GP_WeightedMedian.c @@ -89,7 +89,7 @@ static int GP_FilterWeightedMedian_Raw(const GP_Context *src, unsigned int x1, y1;
if (src->pixel_type != GP_PIXEL_RGB888) { - errno = ENOSYS; + errno = ENOSYS; return -1; }
@@ -108,7 +108,7 @@ static int GP_FilterWeightedMedian_Raw(const GP_Context *src, /* prefil the sampled array */ for (x = 0; x < (int)w; x++) { int xi = GP_CLAMP(x_src + x - (int)weights->w/2, 0, (int)src->w - 1); - + for (y = 0; y < (int)weights->h; y++) { int yi = GP_CLAMP(y_src + y - (int)weights->h, 0, (int)src->h - 1);
@@ -144,7 +144,7 @@ static int GP_FilterWeightedMedian_Raw(const GP_Context *src, unsigned int r = hist_med(hist_R, 256, sum/2); unsigned int g = hist_med(hist_G, 256, sum/2); unsigned int b = hist_med(hist_B, 256, sum/2); - + GP_PutPixel_Raw_24BPP(dst, x_dst + x, y_dst + y, GP_Pixel_CREATE_RGB888(r, g, b));
@@ -152,10 +152,10 @@ static int GP_FilterWeightedMedian_Raw(const GP_Context *src, hist_clear(hist_G, 256); hist_clear(hist_B, 256); } - + for (x = 0; x < (int)w; x++) { int xi = GP_CLAMP(x_src + x - (int)weights->w/2, 0, (int)src->w - 1); - + for (y1 = 0; y1 < weights->h; y1++) { int yi = GP_CLAMP(y_src + y + (int)y1 - (int)weights->h/2, 0, (int)src->h - 1);
@@ -165,8 +165,8 @@ static int GP_FilterWeightedMedian_Raw(const GP_Context *src, G[y1 * w + x] = GP_Pixel_GET_G_RGB888(pix); B[y1 * w + x] = GP_Pixel_GET_B_RGB888(pix); } - } - + } + if (GP_ProgressCallbackReport(callback, y, h_src, w_src)) { GP_TempAllocFree(temp); return 1; @@ -188,7 +188,7 @@ int GP_FilterWeightedMedianEx(const GP_Context *src, GP_ProgressCallback *callback) { GP_CHECK(src->pixel_type == dst->pixel_type); - + /* Check that destination is large enough */ GP_CHECK(x_dst + (GP_Coord)w_src <= (GP_Coord)dst->w); GP_CHECK(y_dst + (GP_Coord)h_src <= (GP_Coord)dst->h); diff --git a/libs/gfx/GP_Arc.c b/libs/gfx/GP_Arc.c index ac0360a..0b9a66c 100644 --- a/libs/gfx/GP_Arc.c +++ b/libs/gfx/GP_Arc.c @@ -51,11 +51,11 @@ void GP_ArcSegment(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + /* recalculate center point and swap a and b when axes are swapped */ GP_TRANSFORM_POINT(context, xcenter, ycenter); GP_TRANSFORM_SWAP(context, a, b); - + GP_ArcSegment_Raw(context, xcenter, ycenter, a, b, direction, start, end, pixel); } diff --git a/libs/gfx/GP_Circle.c b/libs/gfx/GP_Circle.c index a19e98f..2b39928 100644 --- a/libs/gfx/GP_Circle.c +++ b/libs/gfx/GP_Circle.c @@ -49,25 +49,25 @@ void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, GP_CHECK_CONTEXT(context);
GP_TRANSFORM_POINT(context, xcenter, ycenter); - + GP_Circle_Raw(context, xcenter, ycenter, r, pixel); }
void GP_Ring_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, GP_Size r1, GP_Size r2, GP_Pixel pixel) { - GP_Circle_Raw(context, xcenter, ycenter, r1, pixel); - GP_Circle_Raw(context, xcenter, ycenter, r2, pixel); + GP_Circle_Raw(context, xcenter, ycenter, r1, pixel); + GP_Circle_Raw(context, xcenter, ycenter, r2, pixel); }
void GP_Ring(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, GP_Size r1, GP_Size r2, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + GP_TRANSFORM_POINT(context, xcenter, ycenter);
- GP_Ring_Raw(context, xcenter, ycenter, r1, r2, pixel); + GP_Ring_Raw(context, xcenter, ycenter, r1, r2, pixel); }
#include "algo/FillRing.algo.h" @@ -88,8 +88,8 @@ void GP_FillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, GP_Size r1, GP_Size r2, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + GP_TRANSFORM_POINT(context, xcenter, ycenter); - + GP_FillRing_Raw(context, xcenter, ycenter, r1, r2, pixel); } diff --git a/libs/gfx/GP_CircleSeg.c b/libs/gfx/GP_CircleSeg.c index 4d7dc19..feeaf9e 100644 --- a/libs/gfx/GP_CircleSeg.c +++ b/libs/gfx/GP_CircleSeg.c @@ -77,7 +77,7 @@ void GP_CircleSeg(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, GP_CHECK_CONTEXT(context);
GP_TRANSFORM_POINT(context, xcenter, ycenter); - + GP_CircleSeg_Raw(context, xcenter, ycenter, r, transform_segments(context, seg_flag), pixel); } @@ -100,9 +100,9 @@ void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + GP_TRANSFORM_POINT(context, xcenter, ycenter); - + GP_FillCircle_Raw(context, xcenter, ycenter, r, pixel); } */ diff --git a/libs/gfx/GP_Ellipse.c b/libs/gfx/GP_Ellipse.c index bd7d31b..1d2085e 100644 --- a/libs/gfx/GP_Ellipse.c +++ b/libs/gfx/GP_Ellipse.c @@ -47,10 +47,10 @@ void GP_Ellipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + /* recalculate center point and swap a and b when axes are swapped */ GP_TRANSFORM_POINT(context, xcenter, ycenter); GP_TRANSFORM_SWAP(context, a, b); - + GP_Ellipse_Raw(context, xcenter, ycenter, a, b, pixel); } diff --git a/libs/gfx/GP_FillEllipse.gen.c.t b/libs/gfx/GP_FillEllipse.gen.c.t index aed7d1f..325106e 100644 --- a/libs/gfx/GP_FillEllipse.gen.c.t +++ b/libs/gfx/GP_FillEllipse.gen.c.t @@ -58,7 +58,7 @@ static void GP_FillEllipse_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord xce GP_VLine_Raw_{{ ps.suffix }}(context, xcenter, ycenter - b, ycenter + b, pixel); return; } - + int x, y, error; for (x = 0, error = -b2*a, y = b; y >= 0; y--) { while (error < 0) { @@ -66,7 +66,7 @@ static void GP_FillEllipse_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord xce x++; } error += a2 * (-2*y + 1); - + /* Draw two horizontal lines reflected across Y. */ GP_HLine_Raw_{{ ps.suffix }}(context, xcenter-x+1, xcenter+x-1, ycenter-y, pixel); GP_HLine_Raw_{{ ps.suffix }}(context, xcenter-x+1, xcenter+x-1, ycenter+y, pixel); @@ -88,10 +88,10 @@ void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + GP_TRANSFORM_POINT(context, xcenter, ycenter); GP_TRANSFORM_SWAP(context, a, b); - + GP_FillEllipse_Raw(context, xcenter, ycenter, a, b, pixel); }
diff --git a/libs/gfx/GP_HLine.gen.c.t b/libs/gfx/GP_HLine.gen.c.t index 72f1555..4a9ea1e 100644 --- a/libs/gfx/GP_HLine.gen.c.t +++ b/libs/gfx/GP_HLine.gen.c.t @@ -58,7 +58,7 @@ void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int x1, int y, x0 = GP_MAX(x0, 0); x1 = GP_MIN(x1, (int) context->w - 1);
-%% if ps.suffix in have_writepixels +%% if ps.suffix in have_writepixels size_t length = 1 + x1 - x0; void *start = GP_PIXEL_ADDR(context, x0, y);
diff --git a/libs/gfx/GP_HLineAA.c b/libs/gfx/GP_HLineAA.c index 01770f4..93b5e04 100644 --- a/libs/gfx/GP_HLineAA.c +++ b/libs/gfx/GP_HLineAA.c @@ -31,7 +31,7 @@ void GP_HLineXXYAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + GP_FN_PER_BPP_CONTEXT(GP_HLine_Raw, context, context, x0, x1, y, pixel); } @@ -41,7 +41,7 @@ void GP_HLineAA(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + if (context->axes_swap) { GP_TRANSFORM_Y_FP(context, x0); GP_TRANSFORM_Y_FP(context, x1); diff --git a/libs/gfx/GP_HLineAA.gen.c.t b/libs/gfx/GP_HLineAA.gen.c.t index 8d3240d..63fc0d6 100644 --- a/libs/gfx/GP_HLineAA.gen.c.t +++ b/libs/gfx/GP_HLineAA.gen.c.t @@ -49,10 +49,10 @@ void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, /* Nothing to draw */ if (x0 == x1) return; - + if (x1 < x0) GP_SWAP(x1, x0); - + GP_Coord int_x0 = TO_X_S(x0); GP_Coord int_x1 = TO_X_E(x1); GP_Coord int_y = GP_FP_FLOOR_TO_INT(y); @@ -62,31 +62,31 @@ void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, /* Draw the four starting and ending pixels */ unsigned int perc; unsigned int w; - + w = GP_FP_RFRAC(x0 + GP_FP_1_2);
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(y), w)); GP_MixPixel_Raw_Clipped(context, int_x0, int_y, pixel, perc);
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(y), w)); - GP_MixPixel_Raw_Clipped(context, int_x0, int_y+1, pixel, perc); + GP_MixPixel_Raw_Clipped(context, int_x0, int_y+1, pixel, perc);
if (int_x0 != int_x1) { w = GP_FP_FRAC(x1 + GP_FP_1_2);
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(y), w)); GP_MixPixel_Raw_Clipped(context, int_x1, int_y, pixel, perc); - + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(y), w)); - GP_MixPixel_Raw_Clipped(context, int_x1, int_y+1, pixel, perc); + GP_MixPixel_Raw_Clipped(context, int_x1, int_y+1, pixel, perc); }
GP_Coord x; - + /* Now fill the inner part of the HLine */ uint8_t up = FP_TO_PERC(GP_FP_RFRAC(y)); uint8_t lp = FP_TO_PERC(GP_FP_FRAC(y)); - + for (x = int_x0 + 1; x < int_x1; x++) { GP_MixPixel_Raw_Clipped(context, x, int_y, pixel, up); GP_MixPixel_Raw_Clipped(context, x, int_y+1, pixel, lp); diff --git a/libs/gfx/GP_Line.gen.c.t b/libs/gfx/GP_Line.gen.c.t index a2dbd9d..d91b45a 100644 --- a/libs/gfx/GP_Line.gen.c.t +++ b/libs/gfx/GP_Line.gen.c.t @@ -56,7 +56,7 @@ void GP_Line_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int y0, GP_ASSERT(x1 >= 0 && x1 <= (int) context->w-1); GP_ASSERT(y0 >= 0 && y0 <= (int) context->h-1); GP_ASSERT(y1 >= 0 && y1 <= (int) context->h-1); - + /* special cases: vertical line, horizontal line, single point */ if (x0 == x1) { if (y0 == y1) { diff --git a/libs/gfx/GP_LineAA.c b/libs/gfx/GP_LineAA.c index 6d30df0..5c2ad8e 100644 --- a/libs/gfx/GP_LineAA.c +++ b/libs/gfx/GP_LineAA.c @@ -43,9 +43,9 @@ void GP_LineAA(GP_Context *context, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + GP_TRANSFORM_POINT_FP(context, x0, y0); GP_TRANSFORM_POINT_FP(context, x1, y1); - + GP_LineAA_Raw(context, x0, y0, x1, y1, pixel); } diff --git a/libs/gfx/GP_LineAA.gen.c.t b/libs/gfx/GP_LineAA.gen.c.t index c5796d5..845819e 100644 --- a/libs/gfx/GP_LineAA.gen.c.t +++ b/libs/gfx/GP_LineAA.gen.c.t @@ -1,3 +1,25 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + %% extends "base.c.t"
{% block descr %}Anti Aliased Line{% endblock %} @@ -20,10 +42,10 @@ static inline void line_aa_x(GP_Context *context, { GP_Coord xend, yend, xgap, xpx0, ypx0, xpx1, ypx1; uint8_t perc; - + int64_t dx = x1 - x0; int64_t dy = y1 - y0; - + if (x1 < x0) { GP_SWAP(x0, x1); GP_SWAP(y0, y1); @@ -56,7 +78,7 @@ static inline void line_aa_x(GP_Context *context,
for (x = xpx0 + 1; x < xpx1; x++) { intery = yend + GP_FP_DIV((x - xpx0) * dy, dx); - + perc = FP_TO_PERC(GP_FP_RFRAC(intery)); GP_MixPixel_Raw_Clipped(context, x, GP_FP_TO_INT(intery), pixel, perc); perc = FP_TO_PERC(GP_FP_FRAC(intery)); @@ -70,10 +92,10 @@ static inline void line_aa_y(GP_Context *context, { GP_Coord xend, yend, ygap, xpx0, ypx0, xpx1, ypx1; uint8_t perc; - + int64_t dx = x1 - x0; int64_t dy = y1 - y0; - + if (y1 < y0) { GP_SWAP(x0, x1); GP_SWAP(y0, y1); @@ -106,7 +128,7 @@ static inline void line_aa_y(GP_Context *context,
for (y = ypx0 + 1; y < ypx1; y++) { intery = xend + GP_FP_DIV((y - ypx0) * dx, dy); - + perc = FP_TO_PERC(GP_FP_RFRAC(intery)); GP_MixPixel_Raw_Clipped(context, GP_FP_TO_INT(intery), y, pixel, perc); perc = FP_TO_PERC(GP_FP_FRAC(intery)); diff --git a/libs/gfx/GP_LineClip.c b/libs/gfx/GP_LineClip.c index 6a1f76e..570a2e3 100644 --- a/libs/gfx/GP_LineClip.c +++ b/libs/gfx/GP_LineClip.c @@ -52,7 +52,7 @@ int GP_LineClip(int *px0, int *py0, int *px1, int *py1, int xmax, int ymax) goto give_result; } if (x0 == x1) { - + /* orient the line from top to down */ if (x1 < x0) { GP_SWAP(x0, x1); @@ -95,7 +95,7 @@ int GP_LineClip(int *px0, int *py0, int *px1, int *py1, int xmax, int ymax) x1 = xmax; y1 = y0 + (x1-x0)*dyx; } - + if (y0 < 0.0f) { x0 = x0 - y0*dxy; y0 = 0.0f; @@ -118,7 +118,7 @@ int GP_LineClip(int *px0, int *py0, int *px1, int *py1, int xmax, int ymax) /* the line misses the clip rectangle around the corner */ return 0; } - + give_result:
*px0 = (int) x0; diff --git a/libs/gfx/GP_PutPixelAA.gen.c.t b/libs/gfx/GP_PutPixelAA.gen.c.t index da47d7a..b061bf9 100644 --- a/libs/gfx/GP_PutPixelAA.gen.c.t +++ b/libs/gfx/GP_PutPixelAA.gen.c.t @@ -47,13 +47,13 @@ void GP_PutPixelAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_1 - frac_x, GP_FP_1 - frac_y)); GP_MixPixel_Raw_Clipped(context, int_x, int_y, pixel, perc); - + perc = FP_TO_PERC(GP_FP_MUL(frac_x, GP_FP_1 - frac_y)); GP_MixPixel_Raw_Clipped(context, int_x + 1, int_y, pixel, perc); - + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_1 - frac_x, frac_y)); GP_MixPixel_Raw_Clipped(context, int_x, int_y + 1, pixel, perc); - + perc = FP_TO_PERC(GP_FP_MUL(frac_x, frac_y)); GP_MixPixel_Raw_Clipped(context, int_x + 1, int_y + 1, pixel, perc); } diff --git a/libs/gfx/GP_Rect.c b/libs/gfx/GP_Rect.c index 9c30385..be07b8b 100644 --- a/libs/gfx/GP_Rect.c +++ b/libs/gfx/GP_Rect.c @@ -43,7 +43,7 @@ void GP_RectXYWH_Raw(GP_Context *context, GP_Coord x, GP_Coord y, { if (w == 0 || h == 0) return; - + GP_RectXYXY_Raw(context, x, y, x + w - 1, y + h - 1, pixel); }
@@ -51,7 +51,7 @@ void GP_RectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + GP_TRANSFORM_POINT(context, x0, y0); GP_TRANSFORM_POINT(context, x1, y1);
@@ -63,7 +63,7 @@ void GP_RectXYWH(GP_Context *context, GP_Coord x, GP_Coord y, { if (w == 0 || h == 0) return; - + GP_RectXYXY(context, x, y, x + w - 1, y + h - 1, pixel); }
@@ -93,7 +93,7 @@ void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + GP_TRANSFORM_POINT(context, x0, y0); GP_TRANSFORM_POINT(context, x1, y1);
diff --git a/libs/gfx/GP_RectAA.c b/libs/gfx/GP_RectAA.c index 812c6bd..6026cad 100644 --- a/libs/gfx/GP_RectAA.c +++ b/libs/gfx/GP_RectAA.c @@ -28,8 +28,6 @@ #include "GP_Rect.h" #include "GP_RectAA.h"
- - void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { @@ -46,7 +44,7 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, GP_Coord out_y0 = GP_FP_FLOOR_TO_INT(y0 + GP_FP_1_2); GP_Coord out_x1 = GP_FP_CEIL_TO_INT(x1 - GP_FP_1_2); GP_Coord out_y1 = GP_FP_CEIL_TO_INT(y1 - GP_FP_1_2); - + /* Size */ GP_Size w = x1 - x0; GP_Size h = y1 - y0; @@ -73,7 +71,7 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, if (out_y0 == out_y1) { uint8_t mix = w; GP_Coord i; - + /* Special case 1px 100% height line */ if (h == GP_FP_1) mix = 255; @@ -92,14 +90,14 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, GP_Coord in_y0 = GP_FP_CEIL_TO_INT(y0 + GP_FP_1_2); GP_Coord in_x1 = GP_FP_FLOOR_TO_INT(x1 - GP_FP_1_2); GP_Coord in_y1 = GP_FP_FLOOR_TO_INT(y1 - GP_FP_1_2); - - /* + + /* * Draw the inner rectanle in 100% intensity. * * Note that if out_x0 == in_x1 is 2px wide and both lines has less than * 100% intensity. The same goes for out_y0 == in_y1. */ - if (in_x1 >= in_x0 && (out_x0 != in_x1 || out_x1 != in_x0) + if (in_x1 >= in_x0 && (out_x0 != in_x1 || out_x1 != in_x0) && in_y1 >= in_y0 && (out_y0 != in_y1 || out_y1 != in_y0)) GP_FillRectXYXY_Raw(context, in_x0, in_y0, in_x1, in_y1, pixel);
@@ -107,18 +105,18 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, if (in_y0 != out_y0) { uint8_t mix = GP_FP_FROM_INT(in_y0) + GP_FP_1_2 - y0; GP_Coord i; - + for (i = out_x0; i <= out_x1; i++) { GP_Pixel p = GP_GetPixel_Raw_Clipped(context, i, out_y0); p = GP_MixPixels(pixel, p, mix, context->pixel_type); GP_PutPixel_Raw_Clipped(context, i, out_y0, p); } } - + if (in_y1 != out_y1) { uint8_t mix = y1 - GP_FP_FROM_INT(in_y0) - GP_FP_1_2; GP_Coord i; - + for (i = out_x0; i <= out_x1; i++) { GP_Pixel p = GP_GetPixel_Raw_Clipped(context, i, out_y1); p = GP_MixPixels(pixel, p, mix, context->pixel_type); @@ -129,7 +127,7 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, if (in_x0 != out_x0) { uint8_t mix = GP_FP_FROM_INT(in_x0) + GP_FP_1_2 - x0; GP_Coord i; - + for (i = out_y0; i <= out_y1; i++) { GP_Pixel p = GP_GetPixel_Raw_Clipped(context, out_x0, i); p = GP_MixPixels(pixel, p, mix, context->pixel_type); @@ -140,7 +138,7 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, if (in_x1 != out_x1) { uint8_t mix = x1 - GP_FP_FROM_INT(in_x1) - GP_FP_1_2; GP_Coord i; - + for (i = out_y0; i <= out_y1; i++) { GP_Pixel p = GP_GetPixel_Raw_Clipped(context, out_x1, i); p = GP_MixPixels(pixel, p, mix, context->pixel_type); @@ -165,7 +163,7 @@ void GP_FillRectXYXY_AA(GP_Context *context, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + GP_TRANSFORM_POINT_FP(context, x0, y0); GP_TRANSFORM_POINT_FP(context, x1, y1);
diff --git a/libs/gfx/GP_Tetragon.c b/libs/gfx/GP_Tetragon.c index e087d12..66ed426 100644 --- a/libs/gfx/GP_Tetragon.c +++ b/libs/gfx/GP_Tetragon.c @@ -46,7 +46,7 @@ void GP_Tetragon(GP_Context *context, GP_Coord x0, GP_Coord y0, GP_Coord x3, GP_Coord y3, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + GP_TRANSFORM_POINT(context, x0, y0); GP_TRANSFORM_POINT(context, x1, y1); GP_TRANSFORM_POINT(context, x2, y2); @@ -60,7 +60,7 @@ void GP_FillTetragon_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, GP_Coord x3, GP_Coord y3, GP_Pixel pixel) { const GP_Coord xy[8] = {x0, y0, x1, y1, x2, y2, x3, y3}; - + GP_FillPolygon_Raw(context, 4, xy, pixel); }
@@ -69,7 +69,7 @@ void GP_FillTetragon(GP_Context* context, GP_Coord x0, GP_Coord y0, GP_Coord x3, GP_Coord y3, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + GP_TRANSFORM_POINT(context, x0, y0); GP_TRANSFORM_POINT(context, x1, y1); GP_TRANSFORM_POINT(context, x2, y2); diff --git a/libs/gfx/GP_Triangle.c b/libs/gfx/GP_Triangle.c index 724e407..5f1e4e7 100644 --- a/libs/gfx/GP_Triangle.c +++ b/libs/gfx/GP_Triangle.c @@ -43,7 +43,7 @@ void GP_Triangle(GP_Context *context, GP_Coord x0, GP_Coord y0, GP_Coord x2, GP_Coord y2, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + GP_TRANSFORM_POINT(context, x0, y0); GP_TRANSFORM_POINT(context, x1, y1); GP_TRANSFORM_POINT(context, x2, y2); diff --git a/libs/gfx/GP_VLine.c b/libs/gfx/GP_VLine.c index 08d075c..166aa03 100644 --- a/libs/gfx/GP_VLine.c +++ b/libs/gfx/GP_VLine.c @@ -30,7 +30,7 @@ #include "gfx/GP_VLine.h" #include "gfx/GP_HLine.h"
-/* +/* * Ensures that coordinates are in correct order, and clips them. * Exits immediately if the line is completely clipped out. */ @@ -48,7 +48,7 @@ void GP_VLineXYY_Raw(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + ORDER_AND_CLIP_COORDS;
GP_FN_PER_BPP_CONTEXT(GP_VLine_Raw, context, context, x, y0, y1, pixel); @@ -67,7 +67,7 @@ void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + if (context->axes_swap) { GP_TRANSFORM_Y(context, x); GP_TRANSFORM_X(context, y0); diff --git a/libs/gfx/GP_VLine.gen.c.t b/libs/gfx/GP_VLine.gen.c.t index ad949e9..d894f14 100644 --- a/libs/gfx/GP_VLine.gen.c.t +++ b/libs/gfx/GP_VLine.gen.c.t @@ -27,14 +27,14 @@ {% block body %}
#include "core/GP_GetPutPixel.h" -#include "gfx/GP_VLine.gen.h" +#include "gfx/GP_VLine.gen.h"
%% for ps in pixelsizes void GP_VLine_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel) { int y; - + for (y = y0; y <= y1; y++) GP_PutPixel_Raw_{{ ps.suffix }}(context, x, y, pixel); } diff --git a/libs/gfx/GP_VLineAA.c b/libs/gfx/GP_VLineAA.c index 6b5b1d4..4af9f69 100644 --- a/libs/gfx/GP_VLineAA.c +++ b/libs/gfx/GP_VLineAA.c @@ -40,7 +40,7 @@ void GP_VLineAA(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); - + if (context->axes_swap) { GP_TRANSFORM_Y_FP(context, x); GP_TRANSFORM_X_FP(context, y0); diff --git a/libs/gfx/GP_VLineAA.gen.c.t b/libs/gfx/GP_VLineAA.gen.c.t index e754d3e..7c5f3fb 100644 --- a/libs/gfx/GP_VLineAA.gen.c.t +++ b/libs/gfx/GP_VLineAA.gen.c.t @@ -1,3 +1,25 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + %% extends "base.c.t"
{% block descr %}Anti Aliased Vertical Line{% endblock %} @@ -27,32 +49,31 @@ void GP_VLineAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y0,
/* Line is shorter than two pixels */ if (int_y0 == int_y1) { - //TODO + //TODO return; }
/* Draw the starting and ending pixel */ uint8_t perc; - + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(x), GP_FP_RFRAC(y0))); GP_MixPixel_Raw_Clipped(context, int_x, int_y0, pixel, perc);
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(x), GP_FP_RFRAC(y0))); - GP_MixPixel_Raw_Clipped(context, int_x+1, int_y0, pixel, perc); - - + GP_MixPixel_Raw_Clipped(context, int_x+1, int_y0, pixel, perc); + perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(x), GP_FP_FRAC(y1))); GP_MixPixel_Raw_Clipped(context, int_x, int_y1, pixel, perc);
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(x), GP_FP_FRAC(y1))); - GP_MixPixel_Raw_Clipped(context, int_x+1, int_y1, pixel, perc); + GP_MixPixel_Raw_Clipped(context, int_x+1, int_y1, pixel, perc);
/* Draw the middle pixels */ uint8_t up = FP_TO_PERC(GP_FP_RFRAC(x)); uint8_t lp = FP_TO_PERC(GP_FP_FRAC(x));
GP_Coord y; - + for (y = int_y0 + 1; y < int_y1; y++) { GP_MixPixel_Raw_Clipped(context, int_x, y, pixel, up); GP_MixPixel_Raw_Clipped(context, int_x+1, y, pixel, lp); diff --git a/libs/grabbers/GP_V4L2.c b/libs/grabbers/GP_V4L2.c index fc97e9b..baef263 100644 --- a/libs/grabbers/GP_V4L2.c +++ b/libs/grabbers/GP_V4L2.c @@ -21,7 +21,7 @@ *****************************************************************************/
/* - + Based on V4L2 example code.
*/ @@ -50,8 +50,8 @@ #include "GP_V4L2.h"
struct v4l2_priv { - int mode; - + int mode; + /* pointer to page aligned user buffer */ void *bufptr[4]; size_t buf_len[4]; @@ -67,9 +67,9 @@ static void v4l2_exit(struct GP_Grabber *self) int i;
GP_DEBUG(1, "Grabber '%s' exitting", priv->device); - + v4l2_stop(self); - + if (priv->mode == 2) { for (i = 0; i < 4; i++) munmap(priv->bufptr[i], priv->buf_len[i]); @@ -107,7 +107,7 @@ static void v4l2_yuv422_fillframe(struct GP_Grabber *self, void *buf) int32_t G = MUL * (*py) - ((int32_t)(MUL * 0.344)) * PU - ((int32_t)(MUL * 0.714)) * PV; int32_t B = MUL * (*py) + ((int32_t)(MUL * 1.402)) * PV; - + R = (R + MUL/2)/MUL; G = (G + MUL/2)/MUL; B = (B + MUL/2)/MUL; @@ -115,13 +115,13 @@ static void v4l2_yuv422_fillframe(struct GP_Grabber *self, void *buf) CLAMP(R, 255); CLAMP(G, 255); CLAMP(B, 255); - + *tmp++ = R; *tmp++ = G; - *tmp++ = B; + *tmp++ = B;
py += 2; - + if ((j & 1) == 1) { pu += 4; pv += 4; @@ -133,9 +133,9 @@ static void v4l2_yuv422_fillframe(struct GP_Grabber *self, void *buf) static int v4l2_poll(struct GP_Grabber *self) { struct v4l2_priv *priv = GP_GRABBER_PRIV(self); - + GP_DEBUG(3, "Grabber '%s' poll", priv->device); - + /* read/write interface */ if (priv->mode == 1) { GP_WARN("Read/write I/O not implemented."); @@ -154,7 +154,7 @@ static int v4l2_poll(struct GP_Grabber *self) switch (errno) { case EAGAIN: return 0; - default: + default: GP_WARN("Failed to ioctl VIDIOC_DQBUF on '%s' : %s", priv->device, strerror(errno)); return 0; @@ -188,12 +188,12 @@ static int v4l2_start(struct GP_Grabber *self) int i; struct v4l2_buffer buf; memset(&buf, 0, sizeof(buf)); - + for (i = 0; i < 4; i++) { buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; buf.index = i; - + if (ioctl(self->fd, VIDIOC_QBUF, &buf)) { GP_WARN("Failed to ioclt VIDIOC_QBUF on '%s': %s", priv->device, strerror(errno)); @@ -248,9 +248,9 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device, GP_WARN("Failed to open V4L2 grabber '%s'", device); goto err; } - + struct v4l2_capability cap; - + if (ioctl(fd, VIDIOC_QUERYCAP, &cap)) { err = errno; GP_WARN("ioctl VIDIOC_QUERYCAP failed, '%s' not V4L2 device?", @@ -294,7 +294,7 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device, crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; /* reset to default */ crop.c = cropcap.defrect; - + if (ioctl(fd, VIDIOC_S_CROP, &crop)) { /* error/cropping not supported */ } @@ -306,7 +306,7 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device, }
struct v4l2_format fmt; - + memset(&fmt, 0, sizeof(fmt));
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; @@ -330,7 +330,7 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device, }
new->frame = GP_ContextAlloc(fmt.fmt.pix.width, fmt.fmt.pix.height, GP_PIXEL_RGB888); - + if (new->frame == NULL) { err = ENOMEM; goto err1; @@ -340,7 +340,7 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device,
strcpy(priv->device, device); priv->mode = mode; - + switch (mode) { case 1: break; @@ -353,7 +353,7 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device, req.count = 4; req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; req.memory = V4L2_MEMORY_MMAP; - + if (ioctl(fd, VIDIOC_REQBUFS, &req)) { err = errno; GP_WARN("Failed to ioctl VIDIOC_REQBUFS on '%s' : %s", @@ -366,7 +366,7 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device, GP_WARN("Unexpected number of buffers on '%s'", device); goto err2; } - + struct v4l2_buffer buf; memset(&buf, 0, sizeof(buf));
diff --git a/libs/input/GP_Event.c b/libs/input/GP_Event.c index d7ec7cd..ce96a89 100644 --- a/libs/input/GP_Event.c +++ b/libs/input/GP_Event.c @@ -34,7 +34,7 @@ static char *key_names[] = { "Reserved", "Escape", "1", "2", "3", "4", "5", "6", "7", "8", - "9", "0", "Minus", "Equal", "BackSpace", + "9", "0", "Minus", "Equal", "BackSpace", "Tab", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "LeftBrace", "RightBrace", "Enter", "LeftCtrl", diff --git a/libs/input/GP_EventQueue.c b/libs/input/GP_EventQueue.c index a3732f1..f13a733 100644 --- a/libs/input/GP_EventQueue.c +++ b/libs/input/GP_EventQueue.c @@ -46,10 +46,10 @@ struct GP_EventQueue *GP_EventQueueAlloc(unsigned int screen_w, { size_t size; struct GP_EventQueue *new; - + size = sizeof(struct GP_EventQueue) + (queue_size - GP_EVENT_QUEUE_SIZE) * sizeof(struct GP_Event); - + new = malloc(size);
if (new == NULL) { @@ -78,7 +78,7 @@ void GP_EventQueueSetScreenSize(struct GP_EventQueue *self, /* clip cursor */ if (self->cur_state.cursor_x >= w) self->cur_state.cursor_x = w - 1; - + if (self->cur_state.cursor_y >= h) self->cur_state.cursor_y = h - 1; } @@ -91,7 +91,7 @@ void GP_EventQueueSetCursorPosition(struct GP_EventQueue *self, x, y, self->screen_w, self->screen_h); return; } - + self->cur_state.cursor_x = x; self->cur_state.cursor_y = y; } @@ -134,7 +134,7 @@ static void event_put(struct GP_EventQueue *self, struct GP_Event *ev) GP_WARN("Event queue full, dropping event."); return; } - + self->events[self->queue_last] = *ev; self->queue_last = next; } @@ -200,11 +200,13 @@ void GP_EventQueuePushRel(struct GP_EventQueue *self, self->cur_state.val.rel.rx = rx; self->cur_state.val.rel.ry = ry;
- set_time(self, time); + set_time(self, time);
/* move the global cursor */ - self->cur_state.cursor_x = clip_rel(self->cur_state.cursor_x, self->screen_w, rx); - self->cur_state.cursor_y = clip_rel(self->cur_state.cursor_y, self->screen_h, ry); + self->cur_state.cursor_x = clip_rel(self->cur_state.cursor_x, + self->screen_w, rx); + self->cur_state.cursor_y = clip_rel(self->cur_state.cursor_y, + self->screen_h, ry);
/* put it into queue */ event_put(self, &self->cur_state); @@ -217,7 +219,7 @@ void GP_EventQueuePushRelTo(struct GP_EventQueue *self, GP_WARN("x > screen_w or y > screen_h"); return; } - + int32_t rx = x - self->cur_state.cursor_x; int32_t ry = y - self->cur_state.cursor_y;
@@ -232,22 +234,22 @@ void GP_EventQueuePushAbs(struct GP_EventQueue *self, /* event header */ self->cur_state.type = GP_EV_ABS; self->cur_state.code = GP_EV_ABS_POS; - self->cur_state.val.abs.x = x; + self->cur_state.val.abs.x = x; self->cur_state.val.abs.y = y; self->cur_state.val.abs.pressure = pressure; - self->cur_state.val.abs.x_max = x_max; + self->cur_state.val.abs.x_max = x_max; self->cur_state.val.abs.y_max = y_max; self->cur_state.val.abs.pressure_max = pressure_max; - + set_time(self, time);
- /* + /* * Set global cursor, the packet could be partial, eg. update only x or * only y. In such case x_max or y_max is zero. */ - if (x_max != 0) + if (x_max != 0) self->cur_state.cursor_x = x * (self->screen_w - 1) / x_max; - + if (y_max != 0) self->cur_state.cursor_y = y * (self->screen_h - 1) / y_max;
@@ -287,7 +289,7 @@ static void key_to_ascii(struct GP_Event *ev) unsigned int key = ev->val.key.key;
ev->val.key.ascii = 0; - + if (GP_EventGetKey(ev, GP_KEY_LEFT_SHIFT) || GP_EventGetKey(ev, GP_KEY_RIGHT_SHIFT)) { if (ev->val.key.key < sizeof(keys_to_ascii_shift)) @@ -303,10 +305,10 @@ void GP_EventQueuePushKey(struct GP_EventQueue *self, { switch (code) { case GP_EV_KEY_UP: - GP_EventResetKey(&self->cur_state, key); + GP_EventResetKey(&self->cur_state, key); break; case GP_EV_KEY_DOWN: - GP_EventSetKey(&self->cur_state, key); + GP_EventSetKey(&self->cur_state, key); break; case GP_EV_KEY_REPEAT: break; @@ -321,7 +323,7 @@ void GP_EventQueuePushKey(struct GP_EventQueue *self, self->cur_state.val.key.key = key;
key_to_ascii(&self->cur_state); - + set_time(self, time);
/* put it into queue */ @@ -338,7 +340,7 @@ void GP_EventQueuePushResize(struct GP_EventQueue *self, self->cur_state.val.sys.w = w; self->cur_state.val.sys.h = h;
- set_time(self, time); + set_time(self, time);
/* put it into queue */ event_put(self, &self->cur_state); diff --git a/libs/input/GP_InputDriverKBD.c b/libs/input/GP_InputDriverKBD.c index ae575c3..020f45c 100644 --- a/libs/input/GP_InputDriverKBD.c +++ b/libs/input/GP_InputDriverKBD.c @@ -69,7 +69,7 @@ void GP_InputDriverKBDEventPut(struct GP_EventQueue *event_queue,
if (keycode > 0 && keycode <= GP_ARRAY_SIZE(keycode_table)) { key = keycode_table[keycode - 1]; - + if (key != 0) { GP_EventQueuePushKey(event_queue, key, press, NULL); return; diff --git a/libs/input/GP_InputDriverLinux.c b/libs/input/GP_InputDriverLinux.c index 09415c5..93bbdef 100644 --- a/libs/input/GP_InputDriverLinux.c +++ b/libs/input/GP_InputDriverLinux.c @@ -38,7 +38,7 @@ static int get_version(int fd)
if (ioctl(fd, EVIOCGVERSION, &ver)) return -1; - + GP_DEBUG(2, "Input version %u.%u.%u", ver>>16, (ver>>8)&0xff, ver&0xff);
@@ -57,7 +57,7 @@ static int get_name(int fd, char *buf, size_t buf_len)
return ret; } - + static void print_name(int fd) { char name[64]; @@ -86,13 +86,13 @@ static void try_load_callibration(struct GP_InputDriverLinux *self) abs[1], abs[2], abs[3], abs[4]); self->abs_x_max = abs[2]; } - + if (!ioctl(self->fd, EVIOCGABS(ABS_Y), abs)) { GP_DEBUG(3, "ABS Y = <%i,%i> Fuzz %i Flat %i", abs[1], abs[2], abs[3], abs[4]); self->abs_y_max = abs[2]; } - + if (!ioctl(self->fd, EVIOCGABS(ABS_PRESSURE), abs)) { GP_DEBUG(3, "ABS P = <%i,%i> Fuzz %i Flat %i", abs[1], abs[2], abs[3], abs[4]); @@ -130,7 +130,7 @@ struct GP_InputDriverLinux *GP_InputDriverLinuxOpen(const char *path) }
ret->fd = fd; - + ret->rel_x = 0; ret->rel_y = 0; ret->rel_flag = 0; @@ -177,7 +177,7 @@ static void input_rel(struct GP_InputDriverLinux *self, struct input_event *ev) static void input_abs(struct GP_InputDriverLinux *self, struct input_event *ev) { GP_DEBUG(4, "Absolute event"); - + switch (ev->code) { case ABS_X: self->abs_x = ev->value; @@ -235,12 +235,12 @@ static void do_sync(struct GP_InputDriverLinux *self, /* clipping */ if (self->abs_x > self->abs_x_max) self->abs_x = self->abs_x_max; - + if (self->abs_x < 0) self->abs_x = 0; - + x = self->abs_x; - x_max = self->abs_x_max; + x_max = self->abs_x_max;
self->abs_flag_x = 0; } @@ -249,19 +249,19 @@ static void do_sync(struct GP_InputDriverLinux *self, /* clipping */ if (self->abs_y > self->abs_y_max) self->abs_y = self->abs_y_max; - + if (self->abs_y < 0) self->abs_y = 0; - + y = self->abs_y; - y_max = self->abs_y_max; + y_max = self->abs_y_max;
self->abs_flag_y = 0; }
GP_EventQueuePushAbs(event_queue, x, y, self->abs_press, x_max, y_max, self->abs_press_max, NULL); - + self->abs_press = 0;
if (self->abs_pen_flag) { @@ -276,7 +276,7 @@ static void input_syn(struct GP_InputDriverLinux *self, struct input_event *ev) { GP_DEBUG(4, "Sync event"); - + switch (ev->code) { case 0: do_sync(self, event_queue); diff --git a/libs/input/GP_TimeStamp.c b/libs/input/GP_TimeStamp.c index 4185ee6..c22b478 100644 --- a/libs/input/GP_TimeStamp.c +++ b/libs/input/GP_TimeStamp.c @@ -40,7 +40,7 @@ static int choose_clock(clockid_t *clock)
#ifdef CLOCK_MONOTONIC_COARSE GP_DEBUG(1, "Trying CLOCK_MONOTONIC_COARSE"); - + if (clock_getres(CLOCK_MONOTONIC_COARSE, &ts)) { GP_DEBUG(1, "CLOCK_MONOTONIC_COARSE: %s", strerror(errno)); } else { diff --git a/libs/input/GP_Timer.c b/libs/input/GP_Timer.c index 39f63f5..519bfe6 100644 --- a/libs/input/GP_Timer.c +++ b/libs/input/GP_Timer.c @@ -101,7 +101,7 @@ static GP_Timer *swap_left(GP_Timer *heap)
static GP_Timer *swap_right(GP_Timer *heap) { - GP_Timer *right = heap->right; + GP_Timer *right = heap->right;
heap->right = right->right; right->right = heap; @@ -127,13 +127,13 @@ static GP_Timer *insert(GP_Timer *heap, GP_Timer *timer)
if (!heap->left || !well_balanced(heap->left->sons) || (heap->right && heap->left->sons == heap->right->sons)) { - + heap->left = insert(heap->left, timer); - + if (timer_cmp(heap, heap->left)) return swap_left(heap); } else { - + heap->right = insert(heap->right, timer);
if (timer_cmp(heap, heap->right)) @@ -239,7 +239,7 @@ static GP_Timer *process_top(GP_Timer *heap, uint64_t now) PRIu32" expires at %"PRIu64, period ? "periodic " : "", timer->id, now, ret, timer->expires); - heap = insert(heap, timer); + heap = insert(heap, timer); }
return heap; diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c index 44fb147..effb301 100644 --- a/libs/loaders/GP_BMP.c +++ b/libs/loaders/GP_BMP.c @@ -50,7 +50,7 @@
#define BUF_TO_2(buf, off) (buf[off] + (buf[off+1]<<8)) - +
struct bitmap_info_header { /* @@ -63,19 +63,19 @@ struct bitmap_info_header { */ uint32_t header_size;
- /* + /* * Image size in pixels. * If h is negative image is top-down (bottom-up is default) */ int32_t w; - int32_t h; - + int32_t h; + uint16_t bpp; uint32_t compress_type; - /* + /* * if 0 image uses whole range (2^bpp colors) */ - uint32_t palette_colors; + uint32_t palette_colors; /* * RGBA masks for bitfields compression */ @@ -158,7 +158,7 @@ static uint32_t get_palette_size(struct bitmap_info_header *header) static int read_bitfields(FILE *f, struct bitmap_info_header *header) { int ret; - + ret = GP_FRead(f, "L4 L4 L4", &header->R_mask, &header->G_mask, @@ -206,7 +206,7 @@ static int read_bitmap_info_header(FILE *f, struct bitmap_info_header *header) if (GP_FRead(f, "L4 L4 L2 L2 L4 I12 L4 I4", &header->w, &header->h, &nr_planes, &header->bpp, &header->compress_type, &header->palette_colors) != 8) { - + GP_DEBUG(1, "Failed to read bitmap info header"); return EIO; } @@ -251,7 +251,7 @@ static int read_bitmap_core_header(FILE *f, struct bitmap_info_header *header) GP_DEBUG(1, "Failed to read bitmap core header"); return EIO; } - + header->w = BUF_TO_2(buf, 0); header->h = BUF_TO_2(buf, 2); header->bpp = BUF_TO_2(buf, 6); @@ -356,13 +356,13 @@ static int read_bitmap_palette(FILE *f, struct bitmap_info_header *header, GP_DEBUG(1, "Failed to read palette %"PRIu32, i); return EIO; } - + palette[i] = GP_Pixel_CREATE_RGB888(buf[2], buf[1], buf[0]); - + GP_DEBUG(3, "Palette[%"PRIu32"] = [0x%02x, 0x%02x, 0x%02x]", i, - GP_Pixel_GET_R_RGB888(palette[i]), - GP_Pixel_GET_G_RGB888(palette[i]), - GP_Pixel_GET_B_RGB888(palette[i])); + GP_Pixel_GET_R_RGB888(palette[i]), + GP_Pixel_GET_G_RGB888(palette[i]), + GP_Pixel_GET_B_RGB888(palette[i])); }
return 0; @@ -427,7 +427,7 @@ static GP_PixelType match_pixel_type(struct bitmap_info_header *header) static uint32_t bitmap_row_size(struct bitmap_info_header *header) { uint32_t row_size = 0; - + /* align width to whole bytes */ switch (header->bpp) { case 1: @@ -458,7 +458,7 @@ static uint32_t bitmap_row_size(struct bitmap_info_header *header)
GP_DEBUG(2, "bpp = %"PRIu16", width = %"PRId32", row_size = %"PRIu32, header->bpp, header->w, row_size); - + return row_size; }
@@ -491,10 +491,10 @@ static int read_palette(FILE *f, struct bitmap_info_header *header,
if ((err = read_bitmap_palette(f, header, palette))) return err; - + if ((err = seek_pixels_offset(header, f))) return err; - + uint32_t row_size = bitmap_row_size(header); int32_t y;
@@ -517,7 +517,7 @@ static int read_palette(FILE *f, struct bitmap_info_header *header, } else { p = palette[idx]; } - + int32_t ry;
if (header->h < 0) @@ -527,14 +527,14 @@ static int read_palette(FILE *f, struct bitmap_info_header *header,
GP_PutPixel_Raw_24BPP(context, x, ry, p); } - + if (GP_ProgressCallbackReport(callback, y, context->h, context->w)) { GP_DEBUG(1, "Operation aborted"); return ECANCELED; } } - + GP_ProgressCallbackDone(callback); return 0; } @@ -557,7 +557,7 @@ static int read_bitfields_or_rgb(FILE *f, struct bitmap_info_header *header, ry = y; else ry = GP_ABS(header->h) - 1 - y; - + uint8_t *row = GP_PIXEL_ADDR(context, 0, ry);
if (fread(row, 1, row_size, f) != row_size) { @@ -639,19 +639,19 @@ int GP_OpenBMP(const char *src_path, FILE **f, err = EIO; goto err1; } - + if (w != NULL || h != NULL || pixel_type != NULL) { struct bitmap_info_header header; - + if ((err = read_bitmap_header(*f, &header))) goto err1;
if (w != NULL) *w = header.w; - + if (h != NULL) *h = header.h; - + if (pixel_type != NULL) *pixel_type = match_pixel_type(&header); } @@ -679,7 +679,7 @@ GP_Context *GP_ReadBMP(FILE *f, GP_ProgressCallback *callback) err = EIO; goto err1; } - + switch (header.compress_type) { case COMPRESS_RGB: case COMPRESS_BITFIELDS: @@ -760,7 +760,7 @@ static int bmp_write_header(struct bitmap_info_header *header, FILE *f) if (GP_FWrite(f, "A2 L4 0x00 0x00 0x00 0x00 L4", "BM", file_size, header->pixel_offset) != 7) return EIO; - + /* Bitmap Info Header */ if (GP_FWrite(f, "L4 L4 L4 L2 L2 L4 L4 L4 L4 L4 L4", header->header_size, header->w, header->h, 1, diff --git a/libs/loaders/GP_ByteUtils.c b/libs/loaders/GP_ByteUtils.c index 32abdd1..134c74e 100644 --- a/libs/loaders/GP_ByteUtils.c +++ b/libs/loaders/GP_ByteUtils.c @@ -112,8 +112,8 @@ static const char *get_int(const char *fmt, int *val) *val *= 10; *val += add; i++; - } - + } + return fmt + i; }
@@ -240,7 +240,7 @@ int GP_FRead(FILE *f, const char *fmt, ...)
if (fread(ptr, val, 1, f) != 1) goto end; - + swap_bytes(ptr, val, type); break; case IGNORE: @@ -251,7 +251,7 @@ int GP_FRead(FILE *f, const char *fmt, ...) GP_BUG("Wrong format type for reading (%i)", type); goto end; } - + ret++;
} @@ -296,17 +296,17 @@ int GP_FWrite(FILE *f, const char *fmt, ...) break; case 2: u16 = va_arg(va, int); - + swap_bytes(&u16, 2, type); - + if (fwrite(&u16, 2, 1, f) != 1) goto end; break; case 4: u32 = va_arg(va, int); - + swap_bytes(&u32, 4, type); - + if (fwrite(&u32, 4, 1, f) != 1) goto end; break; diff --git a/libs/loaders/GP_GIF.c b/libs/loaders/GP_GIF.c index b8554e8..59df688 100644 --- a/libs/loaders/GP_GIF.c +++ b/libs/loaders/GP_GIF.c @@ -23,7 +23,7 @@ /*
GIF image support using giflib. - + */
#include <stdint.h> @@ -54,7 +54,7 @@ int GP_MatchGIF(const void *buf) { if (!memcmp(buf, GIF_SIGNATURE1, GIF_SIGNATURE1_LEN)) return 1; - + if (!memcmp(buf, GIF_SIGNATURE2, GIF_SIGNATURE2_LEN)) return 1;
@@ -83,7 +83,7 @@ int GP_OpenGIF(const char *src_path, void **f) */ if (errno == 0) errno = EIO; - + return 1; }
@@ -206,14 +206,14 @@ static inline GP_Pixel get_color(GifFileType *gf, uint32_t idx) static int get_bg_color(GifFileType *gf, GP_Pixel *pixel) { GifColorType *color; - + if (gf->SColorMap == NULL) return 0;
color = get_color_from_map(gf->SColorMap, gf->SBackGroundColor);
*pixel = GP_Pixel_CREATE_RGB888(color->Red, color->Green, color->Blue); - + return 1; }
@@ -228,7 +228,7 @@ static inline unsigned int interlace_real_y(GifFileType *gf, unsigned int y)
/* Pass 1: Line 0 for each strip */ real_y = 8 * y; - + if (real_y < h) return real_y;
@@ -240,16 +240,16 @@ static inline unsigned int interlace_real_y(GifFileType *gf, unsigned int y)
/* Pass 3: Lines 2 and 6 */ real_y = 4 * (y - (h - 1)/4 - 1) + 2; - + if (real_y < h) return real_y; - + /* Pass 4: Lines 1, 3, 5, and 7 */ real_y = 2 * (y - h/2 - h%2) + 1; - + if (real_y < h) return real_y; - + GP_BUG("real_y > h");
return 0; @@ -272,7 +272,7 @@ GP_Context *GP_ReadGIF(void *f, GP_ProgressCallback *callback) err = EIO; goto err1; } - + GP_DEBUG(2, "Have GIF record type %s", rec_type_name(rec_type));
@@ -301,15 +301,15 @@ GP_Context *GP_ReadGIF(void *f, GP_ProgressCallback *callback) gf->Image.ColorMap ? gf->Image.ColorMap->BitsPerPixel : -1);
res = GP_ContextAlloc(gf->SWidth, gf->SHeight, GP_PIXEL_RGB888); - + if (res == NULL) { err = ENOMEM; goto err1; } - + /* If background color is defined, use it */ if (get_bg_color(gf, &bg)) { - GP_DEBUG(1, "Filling bg color %x", bg); + GP_DEBUG(1, "Filling bg color %x", bg); GP_Fill(res, bg); }
@@ -318,18 +318,18 @@ GP_Context *GP_ReadGIF(void *f, GP_ProgressCallback *callback) uint8_t line[gf->Image.Width];
DGifGetLine(gf, line, gf->Image.Width); - + unsigned int real_y = y;
if (gf->Image.Interlace == 64) { real_y = interlace_real_y(gf, y); GP_DEBUG(3, "Interlace y -> real_y %u %u", y, real_y); } - + //TODO: just now we have only 8BPP for (x = 0; x < gf->Image.Width; x++) GP_PutPixel_Raw_24BPP(res, x + gf->Image.Left, real_y, get_color(gf, line[x])); - + if (GP_ProgressCallbackReport(callback, y - gf->Image.Top, gf->Image.Height, gf->Image.Width)) { @@ -343,7 +343,6 @@ GP_Context *GP_ReadGIF(void *f, GP_ProgressCallback *callback) break;
} while (rec_type != TERMINATE_RECORD_TYPE); -
DGifCloseFile(gf);
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c index 11c34d1..0cf10f7 100644 --- a/libs/loaders/GP_JPG.c +++ b/libs/loaders/GP_JPG.c @@ -23,7 +23,7 @@ /*
JPG image support using jpeg library. - + */
#include <stdint.h> @@ -58,7 +58,7 @@ int GP_MatchJPG(const void *buf) int GP_OpenJPG(const char *src_path, FILE **f) { int err; - + *f = fopen(src_path, "rb");
if (*f == NULL) { @@ -70,7 +70,7 @@ int GP_OpenJPG(const char *src_path, FILE **f) }
//TODO: check signature and rewind the stream - + return 0; }
@@ -175,12 +175,12 @@ GP_Context *GP_ReadJPG(FILE *f, GP_ProgressCallback *callback) //TODO: fixme bigendian? /* fix the pixel, as we want in fact BGR */ unsigned int i; - + for (i = 0; i < ret->w; i++) { uint8_t *pix = GP_PIXEL_ADDR(ret, i, y); GP_SWAP(pix[0], pix[2]); } - + if (GP_ProgressCallbackReport(callback, y, ret->h, ret->w)) { GP_DEBUG(1, "Operation aborted"); err = ECANCELED; @@ -207,7 +207,7 @@ GP_Context *GP_ReadJPG(FILE *f, GP_ProgressCallback *callback) jpeg_destroy_decompress(&cinfo);
GP_ProgressCallbackDone(callback); - + return ret; err2: GP_ContextFree(ret); @@ -226,7 +226,7 @@ GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback) return NULL;
res = GP_ReadJPG(f, callback); - + fclose(f);
return res; @@ -259,10 +259,10 @@ static void save_jpg_markers(struct jpeg_decompress_struct *cinfo) { /* Comment marker */ jpeg_save_markers(cinfo, JPEG_COM, JPEG_COM_MAX); - + /* APP0 marker = JFIF data */ jpeg_save_markers(cinfo, JPEG_APP0 + 1, 0xffff); - + /* APP1 marker = Exif data */ jpeg_save_markers(cinfo, JPEG_APP0 + 1, 0xffff); } @@ -292,9 +292,9 @@ int GP_ReadJPGMetaData(FILE *f, GP_MetaData *data) get_colorspace(cinfo.jpeg_color_space), cinfo.image_width, cinfo.image_height, cinfo.num_components); - + read_jpg_metadata(&cinfo, data); - + // jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo);
@@ -346,7 +346,7 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path, dst_path, strerror(errno)); goto err0; } - + if (setjmp(my_err.setjmp_buf)) { err = EIO; //TODO: is cinfo allocated? @@ -355,7 +355,7 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
cinfo.err = jpeg_std_error(&my_err.error_mgr); my_err.error_mgr.error_exit = my_error_exit; - + jpeg_create_compress(&cinfo);
jpeg_stdio_dest(&cinfo, f); @@ -390,7 +390,7 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path, JSAMPROW row = (void*)GP_PIXEL_ADDR(src, 0, y); jpeg_write_scanlines(&cinfo, &row, 1); } - + if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) { GP_DEBUG(1, "Operation aborted"); err = ECANCELED; @@ -407,7 +407,7 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path, dst_path, strerror(errno)); goto err1; } - + GP_ProgressCallbackDone(callback); return 0; err3: diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c index e86c39a..cfb1d6d 100644 --- a/libs/loaders/GP_Loader.c +++ b/libs/loaders/GP_Loader.c @@ -23,7 +23,7 @@ /*
General functions for loading and saving bitmaps. - + */
#include <string.h> @@ -78,7 +78,7 @@ static GP_Loader ppm_loader = { static GP_Loader pnm_loader = { .Load = GP_LoadPNM, .Save = NULL, - /* + /* * Avoid double Match * This format is covered by PBM, PGM and PPM */ @@ -181,7 +181,7 @@ void GP_ListLoaders(void) for (j = 0; i->extensions[j] != NULL; j++) printf("%s ", i->extensions[j]); printf("n"); - + if (i->next != NULL) printf("n"); } @@ -274,12 +274,11 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback) { int err; struct stat st; - + if (access(src_path, R_OK)) { err = errno; GP_DEBUG(1, "Failed to access file '%s' : %s", src_path, strerror(errno)); - errno = err; return NULL; } @@ -300,14 +299,14 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
if (ext_load != NULL && ext_load->Load != NULL) { img = ext_load->Load(src_path, callback); - + if (img) return img; }
sig_load = loader_by_signature(src_path);
- /* + /* * Avoid further work if extension matches the signature but image * couldn't be loaded. Probably unimplemented format or damaged file. */ @@ -346,7 +345,7 @@ int GP_LoadMetaData(const char *src_path, GP_MetaData *data)
if (!strcasecmp(ext, "jpg") || !strcasecmp(ext, "jpeg")) return GP_LoadJPGMetaData(src_path, data); - + if (!strcasecmp(ext, "png")) return GP_LoadPNGMetaData(src_path, data);
@@ -364,7 +363,7 @@ int GP_SaveImage(const GP_Context *src, const char *dst_path, errno = EINVAL; return 1; } - + if (l->Save) return l->Save(src, dst_path, callback);
@@ -375,7 +374,7 @@ int GP_SaveImage(const GP_Context *src, const char *dst_path, const GP_Loader *GP_MatchSignature(const void *buf) { struct GP_Loader *i; - + for (i = loaders; i != NULL; i = i->next) { if (i->Match && i->Match(buf) == 1) { GP_DEBUG(1, "Found loader '%s'", i->fmt_name); diff --git a/libs/loaders/GP_MetaData.c b/libs/loaders/GP_MetaData.c index a81480f..e695953 100644 --- a/libs/loaders/GP_MetaData.c +++ b/libs/loaders/GP_MetaData.c @@ -76,7 +76,7 @@ void GP_MetaDataClear(GP_MetaData *self) { GP_DEBUG(1, "Clearing MetaData %p with %u records", self, self->rec_count); - + self->root = NULL; self->last = NULL; self->rec_count = 0; @@ -124,7 +124,7 @@ static GP_MetaRecord *record_lookup(GP_MetaData *self, const char *id, for (rec = self->root; rec != NULL; rec = rec->next) if (rec->hash == hash && !strcmp(rec->id, id)) return rec; - + return NULL; }
@@ -138,7 +138,7 @@ static void *do_alloc(struct GP_MetaData *self, size_t size) void *ret = ((char*)self) + sizeof(struct GP_MetaData) + (self->size - self->free);
self->free -= size; - + return ret; }
@@ -146,7 +146,7 @@ static GP_MetaRecord *record_create(GP_MetaData *self, const char *id, unsigned int hash) { GP_MetaRecord *rec; - + if (strlen(id) + 1 > GP_META_RECORD_ID_MAX) { GP_DEBUG(0, "Can't create id '%s' longer than %i chars", id, GP_META_RECORD_ID_MAX - 1); @@ -154,14 +154,14 @@ static GP_MetaRecord *record_create(GP_MetaData *self, const char *id, }
rec = do_alloc(self, sizeof(struct GP_MetaRecord)); - + if (rec == NULL) return NULL;
strcpy(rec->id, id); rec->hash = hash; rec->next = NULL; - + if (self->root == NULL) { self->root = rec; self->last = rec; @@ -169,7 +169,7 @@ static GP_MetaRecord *record_create(GP_MetaData *self, const char *id, self->last->next = rec; self->last = rec; } - + self->rec_count++;
return rec; @@ -184,15 +184,15 @@ GP_MetaRecord *GP_MetaDataCreateRecord(GP_MetaData *self, const char *id) return NULL; }
- return record_create(self, id, hash); + return record_create(self, id, hash); }
int GP_MetaDataGetInt(GP_MetaData *self, const char *id, int *res) { GP_MetaRecord *rec; - + GP_DEBUG(2, "Looking for GP_META_INT id '%s'", id); - + rec = record_lookup(self, id, do_hash(id));
if (rec == NULL) { @@ -215,9 +215,9 @@ int GP_MetaDataGetInt(GP_MetaData *self, const char *id, int *res) int GP_MetaDataGetDouble(GP_MetaData *self, const char *id, double *res) { GP_MetaRecord *rec; - + GP_DEBUG(2, "Looking for GP_META_DOUBLE id '%s'", id); - + rec = record_lookup(self, id, do_hash(id));
if (rec == NULL) { @@ -240,9 +240,9 @@ int GP_MetaDataGetDouble(GP_MetaData *self, const char *id, double *res) const char *GP_MetaDataGetString(GP_MetaData *self, const char *id) { GP_MetaRecord *rec; - + GP_DEBUG(2, "Looking for GP_META_STRING id '%s'", id); - + rec = record_lookup(self, id, do_hash(id));
if (rec == NULL) { @@ -265,12 +265,12 @@ GP_MetaRecord *GP_MetaDataCreateInt(GP_MetaData *self, const char *id, int val) GP_MetaRecord *rec;
GP_DEBUG(2, "Creating GP_META_INT id '%s' = %i", id, val); - + rec = GP_MetaDataCreateRecord(self, id);
if (rec == NULL) return NULL; - + rec->type = GP_META_INT; rec->val.i = val;
@@ -283,7 +283,7 @@ GP_MetaRecord *GP_MetaDataCreateRat(GP_MetaData *self, const char *id, GP_MetaRecord *rec;
GP_DEBUG(2, "Creating GP_META_RATIONAL id '%s' = %i/%i", id, num, den); - + if (den == 0) { GP_DEBUG(1, "Would not create '%s' with denominator == 0", id); return NULL; @@ -293,7 +293,7 @@ GP_MetaRecord *GP_MetaDataCreateRat(GP_MetaData *self, const char *id,
if (rec == NULL) return NULL; - + rec->type = GP_META_RATIONAL; rec->val.r.num = num; rec->val.r.den = den; @@ -307,12 +307,12 @@ GP_MetaRecord *GP_MetaDataCreateDouble(GP_MetaData *self, const char *id, GP_MetaRecord *rec;
GP_DEBUG(2, "Creating GP_META_DOUBLE id '%s' = %lf", id, val); - + rec = GP_MetaDataCreateRecord(self, id);
if (rec == NULL) return NULL; - + rec->type = GP_META_DOUBLE; rec->val.d = val;
@@ -334,10 +334,10 @@ GP_MetaRecord *GP_MetaDataCreateString(GP_MetaData *self, const char *id, if (dup) { size_t size; char *s; - + if (len == 0) len = strlen(str); - + size = len + 1;
/* Play safe with aligment */ diff --git a/libs/loaders/GP_MetaExif.c b/libs/loaders/GP_MetaExif.c index f188e00..0bd1c84 100644 --- a/libs/loaders/GP_MetaExif.c +++ b/libs/loaders/GP_MetaExif.c @@ -89,7 +89,7 @@ enum IFD_tags { IFD_RESOLUTION_UNIT = 0x0128, /* Software string. */ IFD_SOFTWARE = 0x0131, - /* YYYY:MM:DD HH:MM:SS in 24 hours format */ + /* YYYY:MM:DD HH:MM:SS in 24 hours format */ IFD_DATE_TIME = 0x0132, /* White Point */ IFD_WHITE_POINT = 0x013e, @@ -195,7 +195,7 @@ static const struct IFD_tag IFD_tags[] = { /* TAGs from Exif SubIFD */ {IFD_EXPOSURE_TIME, "Exposure Time", IFD_UNSIGNED_RATIONAL, 1}, {IFD_F_NUMBER, "F-Number", IFD_UNSIGNED_RATIONAL, 1}, - + /* TAG from IFD0 */ {IFD_EXIF_OFFSET, "Exif Offset", IFD_UNSIGNED_LONG, 1},
@@ -222,8 +222,8 @@ static const struct IFD_tag IFD_tags[] = { {IFD_FLASH_PIX_VERSION, "Flash Pix Version", IFD_UNDEFINED, 4}, {IFD_COLOR_SPACE, "Color Space", IFD_UNSIGNED_SHORT, 1}, /* these two may be short in some cases */ - {IFD_EXIF_IMAGE_WIDTH, "Exif Image Width", IFD_UNSIGNED_LONG, 1}, - {IFD_EXIF_IMAGE_HEIGHT, "Exif Image Height", IFD_UNSIGNED_LONG, 1}, + {IFD_EXIF_IMAGE_WIDTH, "Exif Image Width", IFD_UNSIGNED_LONG, 1}, + {IFD_EXIF_IMAGE_HEIGHT, "Exif Image Height", IFD_UNSIGNED_LONG, 1}, {IFD_RELATED_SOUND_FILE, "Related Soundfile", IFD_ASCII_STRING, 0}, };
@@ -258,7 +258,7 @@ static const struct IFD_tag *IFD_tag_get(uint16_t tag)
if (IFD_tags[right].tag == tag) return &IFD_tags[right]; - + return NULL; }
@@ -325,13 +325,13 @@ static const char *get_string(void *buf, size_t buf_len, { if (num_comp <= 4) return (const char*)val; - + if (*val + num_comp >= buf_len) { GP_DEBUG(1, "String out of buffer offset 0x%08x length %u", *val, num_comp); return NULL; } - + return ((const char*)buf) + *val; }
@@ -340,14 +340,14 @@ static int rat_num(void *buf, uint32_t offset, size_t buf_len, int swap) int ret;
GET_32(ret, buf, offset, buf_len, swap); - + return ret; }
static int rat_den(void *buf, uint32_t offset, size_t buf_len, int swap) { int ret; - + GET_32(ret, buf, offset + 4, buf_len, swap);
return ret; @@ -376,7 +376,7 @@ static void load_tag(GP_MetaData *self, void *buf, size_t buf_len, int swap, GP_WARN("Unexpected tag '%s' num_components %u expected %u", res->name, num_comp, res->num_components); } - + const char *addr;
switch (format) { @@ -408,7 +408,7 @@ static void load_tag(GP_MetaData *self, void *buf, size_t buf_len, int swap, case IFD_EXIF_VERSION: case IFD_FLASH_PIX_VERSION: addr = get_string(buf, buf_len, num_comp, &val); - + if (addr == NULL) return;
@@ -437,7 +437,7 @@ static int load_IFD(GP_MetaData *self, void *buf, size_t buf_len,
GP_DEBUG(2, "-- IFD Offset 0x%08x Entries 0x%04x --", IFD_offset, IFD_entries_count); - + int i;
for (i = 0; i < IFD_entries_count; i++) { @@ -448,19 +448,19 @@ static int load_IFD(GP_MetaData *self, void *buf, size_t buf_len, GET_16_INC(format, buf, IFD_offset, buf_len, swap); GET_32_INC(num_components, buf, IFD_offset, buf_len, swap); GET_32_INC(val, buf, IFD_offset, buf_len, swap); - + GP_DEBUG(3, "IFD Entry tag 0x%04x format (0x%04x) components 0x%08x val 0x%08x", tag, format, num_components, val); - + GP_DEBUG(3, "IFD Entry tag '%s' format '%s'", IFD_tag_name(tag), IFD_format_name(format)); - + if (tag == IFD_EXIF_OFFSET) load_IFD(self, buf, buf_len, val, swap); else load_tag(self, buf, buf_len, swap, tag, format, num_components, val); } -/* +/* GET_32(IFD_offset, buf, IFD_offset, buf_len, swap);
if (IFD_offset != 0x00000000) @@ -478,10 +478,10 @@ int GP_MetaDataFromExif(GP_MetaData *self, void *buf, size_t buf_len) int c1, c2;
if (buf_char(buf, 0, buf_len) != 'E' || - buf_char(buf, 1, buf_len) != 'x' || - buf_char(buf, 2, buf_len) != 'i' || - buf_char(buf, 3, buf_len) != 'f' || - buf_char(buf, 4, buf_len) != 0 || + buf_char(buf, 1, buf_len) != 'x' || + buf_char(buf, 2, buf_len) != 'i' || + buf_char(buf, 3, buf_len) != 'f' || + buf_char(buf, 4, buf_len) != 0 || buf_char(buf, 5, buf_len) != 0) { GP_WARN("Missing ASCII 'Exif "the start of the buffer"); @@ -496,7 +496,7 @@ int GP_MetaDataFromExif(GP_MetaData *self, void *buf, size_t buf_len) }
swap = (c1 == 'M'); - + GP_DEBUG(2, "TIFF aligment is '%c%c' swap = %i", c1, c1, swap);
uint16_t tag; @@ -517,6 +517,5 @@ int GP_MetaDataFromExif(GP_MetaData *self, void *buf, size_t buf_len) /* The offset starts from the II or MM */ load_IFD(self, (char*)buf + TIFF_OFFSET, buf_len - TIFF_OFFSET, IFD_offset, swap);
- return 0; } diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c index ce03c85..47a4d6a 100644 --- a/libs/loaders/GP_PNG.c +++ b/libs/loaders/GP_PNG.c @@ -23,7 +23,7 @@ /*
PNG image support using libpng. - + */
#include <stdint.h> @@ -73,7 +73,7 @@ int GP_OpenPNG(const char *src_path, FILE **f) GP_DEBUG(1, "Invalid file header, '%s' not a PNG image?", src_path); err = EINVAL; - goto err2; + goto err2; }
GP_DEBUG(1, "Found PNG signature in '%s'", src_path); @@ -199,7 +199,7 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback) break; } } - + /* Convert everything else to RGB888 */ //TODO: add palette matching to G2 G4 and G8 png_set_palette_to_rgb(png); @@ -208,7 +208,7 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback) png_read_update_info(png, png_info);
png_get_IHDR(png, png_info, &w, &h, &depth, - &color_type, NULL, NULL, NULL); + &color_type, NULL, NULL, NULL);
if (color_type & PNG_COLOR_MASK_ALPHA) { pixel_type = GP_PIXEL_RGBA8888; @@ -238,7 +238,7 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback) uint32_t y; int p;
- /* + /* * Do the actuall reading. * * The passes are needed for adam7 interlacing. @@ -259,7 +259,7 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback) png_destroy_read_struct(&png, &png_info, NULL);
GP_ProgressCallbackDone(callback); - + return res; err3: GP_ContextFree(res); @@ -279,7 +279,7 @@ GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback) return NULL;
res = GP_ReadPNG(f, callback); - + fclose(f);
return res; @@ -289,7 +289,7 @@ static void load_meta_data(png_structp png, png_infop png_info, GP_MetaData *dat { double gamma;
- if (png_get_gAMA(png, png_info, &gamma)) + if (png_get_gAMA(png, png_info, &gamma)) GP_MetaDataCreateInt(data, "gamma", gamma * 100000);
png_uint_32 res_x, res_y; @@ -298,14 +298,14 @@ static void load_meta_data(png_structp png, png_infop png_info, GP_MetaData *dat if (png_get_pHYs(png, png_info, &res_x, &res_y, &unit)) { GP_MetaDataCreateInt(data, "res_x", res_x); GP_MetaDataCreateInt(data, "res_y", res_y); - + const char *unit_name; - + if (unit == PNG_RESOLUTION_METER) unit_name = "meter"; else unit_name = "unknown"; - + GP_MetaDataCreateString(data, "res_unit", unit_name, 0, 0); }
@@ -333,12 +333,12 @@ static void load_meta_data(png_structp png, png_infop png_info, GP_MetaData *dat
if (png_get_text(png, png_info, &text_ptr, &text_cnt)) { int i; - + for (i = 0; i < text_cnt; i++) {
if (text_ptr[i].compression != PNG_TEXT_COMPRESSION_NONE) continue; - + char buf[GP_META_RECORD_ID_MAX]; snprintf(buf, GP_META_RECORD_ID_MAX, "text:%s", text_ptr[i].key); GP_MetaDataCreateString(data, buf, text_ptr[i].text, 0, 1); @@ -359,7 +359,7 @@ int GP_ReadPNGMetaData(FILE *f, GP_MetaData *data) err = ENOMEM; goto err1; } - + png_info = png_create_info_struct(png);
if (png_info == NULL) { @@ -446,10 +446,10 @@ static int prepare_png_header(const GP_Context *src, png_structp png, png_set_IHDR(png, png_info, src->w, src->h, bit_depth, color_type, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - + /* start the actuall writing */ png_write_info(png, png_info); - + //png_set_packing(png);
/* prepare for format conversion */ @@ -551,7 +551,7 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path, }
png_init_io(png, f); - + int bit_endian_flag = 0; /* Fill png header and prepare for data */ prepare_png_header(src, png, png_info, &bit_endian_flag); @@ -571,7 +571,7 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path, }
GP_ProgressCallbackDone(callback); - + return 0; err3: png_destroy_write_struct(&png, png_info == NULL ? NULL : &png_info); diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c index 374bad0..a0b5fab 100644 --- a/libs/loaders/GP_PNM.c +++ b/libs/loaders/GP_PNM.c @@ -24,9 +24,9 @@
PNM portable bitmap header -------------------------- - + Format: - + a magic number value of 'P' and one of '1' - PBM Bitmap ASCII '2' - PGM Gray ASCII @@ -40,10 +40,10 @@ ascii height whitespace maximal value (interval is 0 ... max) (not applicable for PBM) - width * height ascii or binary values - + width * height ascii or binary values + lines starting with '#' are comments to the end of line - + */
#include <stdio.h> @@ -648,9 +648,9 @@ int GP_SavePBM(const GP_Context *src, const char *dst_path, GP_DEBUG(1, "Invalid pixel type '%s'", GP_PixelTypeName(src->pixel_type)); errno = EINVAL; - return 1; + return 1; } - + f = fopen(dst_path, "w");
if (f == NULL) @@ -695,7 +695,7 @@ static GP_Context *read_graymap(FILE *f, struct pnm_header *header, int flag, GP_Context *ret; GP_PixelType pixel_type; int err; - + if (!is_graymap(header->magic)) { GP_DEBUG(1, "Invalid graymap magic P%c", header->magic); err = EINVAL; @@ -791,9 +791,9 @@ int GP_SavePGM(const GP_Context *src, const char *dst_path, GP_DEBUG(1, "Invalid pixel type '%s'", GP_PixelTypeName(src->pixel_type)); errno = EINVAL; - return 1; + return 1; } - + f = fopen(dst_path, "w");
if (f == NULL) { @@ -830,7 +830,7 @@ static GP_Context *read_pixmap(FILE *f, struct pnm_header *header, int flag, { GP_Context *ret; int err; - + if (!is_pixmap(header->magic)) { GP_DEBUG(1, "Invalid Pixmap magic P%c", header->magic); err = EINVAL; @@ -872,7 +872,7 @@ err1: fclose(f); err0: errno = err; - return NULL; + return NULL; }
GP_Context *GP_LoadPPM(const char *src_path, GP_ProgressCallback *callback) @@ -895,8 +895,8 @@ static int write_binary_ppm(FILE *f, GP_Context *src) for (y = 0; y < src->h; y++) for (x = 0; x < src->w; x++) { GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, x, y); - - uint8_t buf[3] = {GP_Pixel_GET_R_RGB888(pix), + + uint8_t buf[3] = {GP_Pixel_GET_R_RGB888(pix), GP_Pixel_GET_G_RGB888(pix), GP_Pixel_GET_B_RGB888(pix)};
@@ -916,9 +916,9 @@ static int save_ascii_rgb888(FILE *f, const GP_Context *ctx, for (y = 0; y < ctx->h; y++) { for (x = 0; x < ctx->w; x++) { GP_Pixel pix = GP_GetPixel_Raw_24BPP(ctx, x, y); - + ret = fprintf(f, "%u %u %u ", - GP_Pixel_GET_R_RGB888(pix), + GP_Pixel_GET_R_RGB888(pix), GP_Pixel_GET_G_RGB888(pix), GP_Pixel_GET_B_RGB888(pix));
@@ -952,9 +952,9 @@ int GP_SavePPM(const GP_Context *src, const char *dst_path, GP_DEBUG(1, "Invalid pixel type '%s'", GP_PixelTypeName(src->pixel_type)); errno = EINVAL; - return 1; + return 1; } - + f = fopen(dst_path, "w");
if (f == NULL) { @@ -990,7 +990,6 @@ err0:
GP_Context *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback) { - FILE *f; GP_Context *ret = NULL; struct pnm_header header; @@ -1022,7 +1021,7 @@ err1: fclose(f); err0: errno = err; - return NULL; + return NULL; }
int GP_SavePNM(const GP_Context *src, const char *dst_path, diff --git a/libs/loaders/GP_PSP.c b/libs/loaders/GP_PSP.c index 7585d91..f5c6c28 100644 --- a/libs/loaders/GP_PSP.c +++ b/libs/loaders/GP_PSP.c @@ -304,13 +304,13 @@ static int psp_read_composite_image_block(FILE *f, struct psp_img_attrs *attrs, { uint8_t buf[8]; uint32_t i, composite_image_count; - + /* we are allready in subblock -> error */ if (attrs->subblock) { GP_WARN("Composite Image Bank block inside of a Subblock"); return EINVAL; } - + if (fread(buf, sizeof(buf), 1, f) < 1) { GP_DEBUG(1, "Failed to read Composite Image Bank Info Chunk"); return EIO; @@ -398,9 +398,9 @@ static int psp_read_composite_attributes_block(FILE *f, struct psp_img_attrs *at static int psp_read_jpeg(FILE *f, struct psp_img_attrs *attrs, GP_ProgressCallback *callback) { - uint8_t buf[14]; + uint8_t buf[14]; int err; - + if (fread(buf, sizeof(buf), 1, f) < 1) { GP_DEBUG(1, "Failed to read JPEG Information Chunk"); return EIO; @@ -409,7 +409,7 @@ static int psp_read_jpeg(FILE *f, struct psp_img_attrs *attrs, //TODO: utilize chunk_size
GP_DEBUG(5, "JPEG Chunk"); - + attrs->img = GP_ReadJPG(f, callback);
if (attrs->img == NULL) { @@ -489,10 +489,10 @@ GP_Context *GP_ReadPSP(FILE *f, GP_ProgressCallback *callback)
while (!err) { err = psp_next_block(f, &attrs, callback); - + if (err) goto err1; - + if (attrs.img != NULL) { fclose(f); return attrs.img; diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c index f88d21e..3f4a4e9 100644 --- a/libs/loaders/GP_TIFF.c +++ b/libs/loaders/GP_TIFF.c @@ -23,7 +23,7 @@ /*
TIFF image support using libtiff. - + */
#include <stdint.h> @@ -61,7 +61,7 @@ int GP_OpenTIFF(const char *src_path, void **t)
if (tiff == NULL) return 1; - + *t = tiff; return 0; } @@ -115,7 +115,7 @@ GP_Context *GP_ReadTIFF(void *t, GP_ProgressCallback *callback)
GP_DEBUG(1, "TIFF image %ux%u compression: %s, bpp: %u", w, h, compression_name(compression), bpp); - + /* If set tiff is saved in tiles */ if (TIFFGetField(tiff, TIFFTAG_TILEWIDTH, &tile_w) && TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tile_h)) { @@ -184,9 +184,9 @@ GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback) return NULL;
res = GP_ReadTIFF(t, callback); - + TIFFClose(t); - + return res; }
diff --git a/libs/loaders/GP_TmpFile.c b/libs/loaders/GP_TmpFile.c index 2796652..3704946 100644 --- a/libs/loaders/GP_TmpFile.c +++ b/libs/loaders/GP_TmpFile.c @@ -139,13 +139,13 @@ int GP_SaveTmpFile(const GP_Context *src, const char *dst_path, i += fwrite(&src->pixel_type, sizeof(src->pixel_type), 1, f);
uint8_t flags = 0; - + if (src->axes_swap) flags |= 0x01;
if (src->x_swap) flags |= 0x02; - + if (src->y_swap) flags |= 0x04;
@@ -162,13 +162,13 @@ int GP_SaveTmpFile(const GP_Context *src, const char *dst_path, err = EIO; goto err1; } - + GP_ProgressCallbackReport(callback, y, src->h, src->w); }
if (fclose(f)) goto err0; - + GP_ProgressCallbackDone(callback);
return 0; diff --git a/libs/text/GP_Font.c b/libs/text/GP_Font.c index 633e45d..d723239 100644 --- a/libs/text/GP_Font.c +++ b/libs/text/GP_Font.c @@ -53,7 +53,7 @@ GP_GlyphBitmap *GP_GetGlyphBitmap(const GP_FontFace *font, int c)
uint32_t offset;
- if (font->glyph_offsets[0] == 0) + if (font->glyph_offsets[0] == 0) offset = font->glyph_offsets[i]; else offset = font->glyph_offsets[0] * i; diff --git a/libs/text/GP_FontTiny.c b/libs/text/GP_FontTiny.c index a210997..52d3c3b 100644 --- a/libs/text/GP_FontTiny.c +++ b/libs/text/GP_FontTiny.c @@ -97,7 +97,7 @@ static int8_t tiny_glyphs[] = { 0x70, 0x80, 0x80, 0x80, 0x70, 0x00, 0x00, /* 'D' */ 4, 5, 0, 5, 5, 0xe0, 0x90, 0x90, 0x90, 0xe0, 0x00, 0x00, - /* 'E' */ 4, 5, 0, 5, 5, + /* 'E' */ 4, 5, 0, 5, 5, 0xf0, 0x80, 0xe0, 0x80, 0xf0, 0x00, 0x00, /* 'F' */ 4, 5, 0, 5, 5, 0xf0, 0x80, 0xe0, 0x80, 0x80, 0x00, 0x00, diff --git a/libs/text/GP_FontTinyMono.c b/libs/text/GP_FontTinyMono.c index 2859472..5b1b86f 100644 --- a/libs/text/GP_FontTinyMono.c +++ b/libs/text/GP_FontTinyMono.c @@ -97,7 +97,7 @@ static int8_t tiny_mono_glyphs[] = { 0x70, 0x80, 0x80, 0x80, 0x70, 0x00, 0x00, /* 'D' */ 5, 5, 0, 5, 6, 0xe0, 0x90, 0x90, 0x90, 0xe0, 0x00, 0x00, - /* 'E' */ 5, 5, 0, 5, 6, + /* 'E' */ 5, 5, 0, 5, 6, 0xf0, 0x80, 0xe0, 0x80, 0xf0, 0x00, 0x00, /* 'F' */ 5, 5, 0, 5, 6, 0xf0, 0x80, 0xe0, 0x80, 0x80, 0x00, 0x00, diff --git a/libs/text/GP_FreeType.c b/libs/text/GP_FreeType.c index 29b3977..3b88667 100644 --- a/libs/text/GP_FreeType.c +++ b/libs/text/GP_FreeType.c @@ -70,14 +70,14 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height)
font_face_size = sizeof(GP_FontFace) + sizeof(uint32_t) * GP_GetGlyphCount(GP_CHARSET_7BIT); - + GP_FontFace *font = malloc(font_face_size); - + if (font == NULL) { GP_DEBUG(1, "Malloc failed :("); goto err1; } - + /* Copy font metadata */ strncpy(font->family_name, face->family_name, sizeof(font->family_name)); @@ -95,14 +95,14 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height)
for (i = 0x20; i < 0x7f; i++) { FT_UInt glyph_idx = FT_Get_Char_Index(face, i); - + err = FT_Load_Glyph(face, glyph_idx, FT_LOAD_DEFAULT);
if (err) { GP_DEBUG(1, "Failed to load glyph '%c'", i); goto err2; } - + err = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
if (err) { @@ -132,7 +132,7 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height) GP_DEBUG(1, "Malloc failed :("); goto err2; } - + font->max_glyph_width = 0; font->max_glyph_advance = 0; font->ascend = 0; @@ -140,16 +140,16 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height)
for (i = 0x20; i < 0x7f; i++) { FT_UInt glyph_idx = FT_Get_Char_Index(face, i); - + err = FT_Load_Glyph(face, glyph_idx, FT_LOAD_DEFAULT); - + GP_DEBUG(2, "Loading and rendering glyph '%c'", i);
if (err) { GP_DEBUG(1, "Failed to load glyph '%c'", i); goto err3; } - + err = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
if (err) { @@ -172,7 +172,7 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height)
if (font->ascend < ascend) font->ascend = ascend; - + if (font->descend < descend) font->descend = descend;
@@ -183,7 +183,7 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height) font->max_glyph_width = width;
int x, y; - + for (y = 0; y < glyph_bitmap->height; y++) { for (x = 0; x < glyph_bitmap->width; x++) { unsigned int addr = glyph_bitmap->width * y + x; diff --git a/libs/text/GP_Text.c b/libs/text/GP_Text.c index 2c83a3a..8a712ec 100644 --- a/libs/text/GP_Text.c +++ b/libs/text/GP_Text.c @@ -36,7 +36,7 @@ static int do_align(GP_Coord *topleft_x, GP_Coord *topleft_y, int align, GP_Size width) { int height = GP_TextHeight(style); - + switch (align & 0x0f) { case GP_ALIGN_LEFT: *topleft_x = x - width + 1; @@ -85,7 +85,7 @@ void GP_Text(GP_Context *context, const GP_TextStyle *style,
if (style == NULL) style = &GP_DefaultStyle; - + GP_Coord topleft_x, topleft_y; GP_Size w = GP_TextWidth(style, str);
@@ -121,7 +121,7 @@ GP_Size GP_Print(GP_Context *context, const GP_TextStyle *style, void GP_TextClear(GP_Context *context, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel bg_color, GP_Size size) -{ +{ GP_Coord topleft_x, topleft_y;
GP_ASSERT(do_align(&topleft_x, &topleft_y, align, x, y, style, size) == 0, diff --git a/libs/text/GP_TextMetric.c b/libs/text/GP_TextMetric.c index 26b26f8..9c98ad7 100644 --- a/libs/text/GP_TextMetric.c +++ b/libs/text/GP_TextMetric.c @@ -34,7 +34,7 @@ static const GP_GlyphBitmap *get_glyph(const GP_TextStyle *style, int c)
if (glyph == NULL) glyph = GP_GetGlyphBitmap(style->font, ' '); - + return glyph; }
@@ -74,9 +74,9 @@ static unsigned int max_glyph_advance_x(const GP_TextStyle *style, static unsigned int glyph_width(const GP_TextStyle *style, int c) { unsigned int size, advance; - + const GP_GlyphBitmap *glyph = get_glyph(style, c); - + advance = multiply_width(style, glyph->advance_x - glyph->bearing_x); size = multiply_width(style, glyph->width);
@@ -84,14 +84,14 @@ static unsigned int glyph_width(const GP_TextStyle *style, int c) }
/* - * Returns size occupied by the last glyph. Here we take advance_x into account. + * Returns size occupied by the last glyph. Here we take advance_x into account. */ static unsigned int last_glyph_width(const GP_TextStyle *style, int c) { unsigned int size, advance; - + const GP_GlyphBitmap *glyph = get_glyph(style, c); - + advance = multiply_width(style, glyph->advance_x); size = multiply_width(style, glyph->width + glyph->bearing_x);
@@ -151,7 +151,7 @@ unsigned int GP_TextWidth(const GP_TextStyle *style, const char *str)
/* first letter */ len = first_glyph_width(style, str[0]) + style->char_xspace; - + /* middle letters */ for (i = 1; str[i+1] != '0'; i++) len += glyph_advance_x(style, str[i]) + style->char_xspace; @@ -173,7 +173,7 @@ GP_Size GP_TextMaxWidth(const GP_TextStyle *style, unsigned int len) return 0;
return multiply_width(style, len * style->font->max_glyph_advance) + - (len - 1) * style->char_xspace; + (len - 1) * style->char_xspace; }
/* diff --git a/pylib/gfxprim/backends/_extend_backend.py b/pylib/gfxprim/backends/_extend_backend.py index efd010f..0a03acb 100644 --- a/pylib/gfxprim/backends/_extend_backend.py +++ b/pylib/gfxprim/backends/_extend_backend.py @@ -43,7 +43,7 @@ def extend_backend(_backend): def Wait(self): "Waits for backend." c_backends.GP_BackendWait(self) - + @extend(_backend) def WaitEvent(self): "Waits for backend event." @@ -92,7 +92,7 @@ def extend_backend(_backend): def Resize(self, w, h): "Resize backend window (if possible)" return c_backends.GP_BackendResize(self, w, h) - + @extend(_backend) def ResizeAck(self): "Acknowledge backend resize." diff --git a/pylib/gfxprim/backends/backends.i b/pylib/gfxprim/backends/backends.i index 6e5dc44..e893674 100644 --- a/pylib/gfxprim/backends/backends.i +++ b/pylib/gfxprim/backends/backends.i @@ -56,7 +56,7 @@ ERROR_ON_NULL(GP_BackendLinuxX11Init); * * This is a ugly hack because Python 3 uses its own I/O buffers for file * objects. - * + * */ %typemap(in) FILE* { if ($input != Py_None) { @@ -66,17 +66,17 @@ ERROR_ON_NULL(GP_BackendLinuxX11Init); PyErr_SetString(PyExc_TypeError, "$1_name must be a file type."); return NULL; } - + $1 = fdopen(dup(fd), "w"); } }
%exception GP_BackendInit { $action - + //HACK: fclose the FILE* fclose(arg3); - + if (result == NULL) return PyErr_SetFromErrno(PyExc_OSError); } diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i index afca013..74dbb04 100644 --- a/pylib/gfxprim/core/core.i +++ b/pylib/gfxprim/core/core.i @@ -17,7 +17,7 @@ %include "GP_Transform.h"
/* - * Make members of GP_DebugMsg structure immutable + * Make members of GP_DebugMsg structure immutable */ %immutable GP_DebugMsg::level; %immutable GP_DebugMsg::file; @@ -75,7 +75,7 @@ static int GP_ProgressCallbackProxy(GP_ProgressCallback *self) } GP_ProgressCallback(PyObject* obj) { GP_ProgressCallback *res; - + if (!PyCallable_Check(obj)) { GP_WARN("Callback must be callable python object"); return NULL; @@ -90,7 +90,7 @@ static int GP_ProgressCallbackProxy(GP_ProgressCallback *self)
res->priv = obj; res->callback = GP_ProgressCallbackProxy; - + GP_DEBUG(2, "[wrapper] creating Proxy Callback");
return res; diff --git a/pylib/gfxprim/filters/__init__.py b/pylib/gfxprim/filters/__init__.py index 32b2efd..f847331 100644 --- a/pylib/gfxprim/filters/__init__.py +++ b/pylib/gfxprim/filters/__init__.py @@ -2,7 +2,7 @@ from . import c_filters
def _init(module): "Extend Context with filters submodule" - + # Imports from the SWIG module import re def strip_GP(s): @@ -15,6 +15,6 @@ def _init(module): '^GP_Filter.*Alloc', '^GP_Filter[A-Za-z0-9]*$', ]) - + _init(locals()) del _init diff --git a/pylib/gp_codegen/gfxprimconfig.py b/pylib/gp_codegen/gfxprimconfig.py index 39ad70f..a0f1e8e 100644 --- a/pylib/gp_codegen/gfxprimconfig.py +++ b/pylib/gp_codegen/gfxprimconfig.py @@ -17,7 +17,7 @@ class GfxPrimConfig(object): pixel_type: name of C type for a pixel value pixel_size: number of bits of pixel_type pixelsizes: list of generated and allowed PixelSizes - pixelsizes_by_bpp: dictionary of bitendians by BPP + pixelsizes_by_bpp: dictionary of bitendians by BPP pixeltypes: list of generated PixelTypes, not incl. UNKNOWN """
diff --git a/pylib/gp_codegen/pixeltype.py b/pylib/gp_codegen/pixeltype.py index 9e89ddc..2e89931 100644 --- a/pylib/gp_codegen/pixeltype.py +++ b/pylib/gp_codegen/pixeltype.py @@ -88,7 +88,7 @@ class PixelType(object):
def is_gray(self): return ('V' in self.chans) - + def is_cmyk(self): for i in 'CMYK': if i not in self.chans: return False diff --git a/pylib/templates/filter.arithmetic.c.t b/pylib/templates/filter.arithmetic.c.t index 1bbeab1..e3bb60f 100644 --- a/pylib/templates/filter.arithmetic.c.t +++ b/pylib/templates/filter.arithmetic.c.t @@ -40,7 +40,7 @@ static int GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src_a, const GP_C
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, pix); } - + if (GP_ProgressCallbackReport(callback, y, h, w)) return 1; } @@ -63,7 +63,7 @@ static int GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src_a, const GP { {{ caller(ps) }} uint32_t x, y, w, h; - + w = GP_MIN(src_a->w, src_b->w); h = GP_MIN(src_a->h, src_b->h);
@@ -75,7 +75,7 @@ static int GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src_a, const GP {{ filter_op('pix', ps.size) }} GP_PutPixel_Raw_{{ ps.suffix }}(dst, x, y, pix); } - + if (GP_ProgressCallbackReport(callback, y, h, w)) return 1; } @@ -122,7 +122,7 @@ int GP_Filter{{ name }}(const GP_Context *src_a, const GP_Context *src_b, { GP_Size w = GP_MIN(src_a->w, src_b->w); GP_Size h = GP_MIN(src_a->h, src_b->h); - + GP_ASSERT(src_a->pixel_type == dst->pixel_type, "The src and dst pixel types must match"); GP_ASSERT(w <= dst->w && h <= dst->h, @@ -146,7 +146,7 @@ GP_Context *GP_Filter{{ name }}Alloc(const GP_Context *src_a, const GP_Context *
GP_Size w = GP_MIN(src_a->w, src_b->w); GP_Size h = GP_MIN(src_a->h, src_b->h); - + res = GP_ContextAlloc(w, h, src_a->pixel_type);
if (res == NULL) @@ -156,7 +156,7 @@ GP_Context *GP_Filter{{ name }}Alloc(const GP_Context *src_a, const GP_Context * GP_DEBUG(1, "Operation aborted");
GP_ContextFree(res); - + return NULL; }
diff --git a/pylib/templates/filter.c.t b/pylib/templates/filter.c.t index 335ffbc..da61c79 100644 --- a/pylib/templates/filter.c.t +++ b/pylib/templates/filter.c.t @@ -17,7 +17,7 @@
if ({{ var }} > {{ 2 ** size - 1}}) {{ var }} = {{ 2 ** size - 1}}; -%% endmacro +%% endmacro
/* * Load parameters from params structure into variables @@ -25,7 +25,7 @@ %% macro filter_params(pt, params, c_type, suffix, id) GP_ASSERT(GP_FilterParamCheckPixelType({{ params }}, GP_PIXEL_{{ pt.name }}) == 0, "Invalid params channels for context pixel type"); - + %% for chann in pt.chanslist {{ c_type }}{{ chann[0] }}{{ suffix }} = (GP_FilterParamChannel({{ params }}, "{{ chann[0] }}"))->val.{{ id }}; %% endfor @@ -34,7 +34,7 @@ %% macro filter_params_raw(pt, params, suffix) GP_ASSERT(GP_FilterParamCheckPixelType({{ params }}, GP_PIXEL_{{ pt.name }}) == 0, "Invalid params channels for context pixel type"); - + %% for chann in pt.chanslist GP_FilterParam *{{ chann[0] }}{{ suffix }} = GP_FilterParamChannel({{ params }}, "{{ chann[0] }}"); %% endfor diff --git a/pylib/templates/filter.point.c.t b/pylib/templates/filter.point.c.t index dde4ce4..7789bb1 100644 --- a/pylib/templates/filter.point.c.t +++ b/pylib/templates/filter.point.c.t @@ -32,7 +32,7 @@ static int GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src, GP_Context *
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, pix); } - + if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) return 1; } @@ -63,7 +63,7 @@ static int GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src, GP_Context {{ filter_op('pix', ps.size) }} GP_PutPixel_Raw_{{ ps.suffix }}(dst, x, y, pix); } - + if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) return 1; } @@ -126,7 +126,7 @@ GP_Context *GP_Filter{{ name }}(const GP_Context *src, GP_Context *dst{{ maybe_o
if (dst == NULL) GP_ContextFree(res); - + return NULL; }
diff --git a/pylib/templates/filter.stats.c.t b/pylib/templates/filter.stats.c.t index 5b65f3b..7c137db 100644 --- a/pylib/templates/filter.stats.c.t +++ b/pylib/templates/filter.stats.c.t @@ -28,7 +28,7 @@ static int GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src, {{ filter_op(c[0], c[2]) }} %% endfor } - + if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) return 1; } @@ -58,7 +58,7 @@ static int GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src, int32_t pix = GP_GetPixel_Raw_{{ ps.suffix }}(src, x, y); {{ filter_op('pix', ps.size) }} } - + if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) return 1; }
-----------------------------------------------------------------------
Summary of changes: configure | 26 ++++++------ include/backends/GP_Backend.h | 8 ++-- include/backends/GP_BackendInit.h | 4 +- include/backends/GP_BackendVirtual.h | 2 +- include/backends/GP_SDL.h | 8 ++-- include/backends/GP_X11.h | 8 ++-- include/core/GP_BitSwap.h | 2 +- include/core/GP_Blit.h | 4 +- include/core/GP_Clamp.h | 2 +- include/core/GP_Color.h | 6 +- include/core/GP_Common.h | 2 +- include/core/GP_Context.h | 16 +++--- include/core/GP_Convert.h | 6 +- include/core/GP_FnPerBpp.h | 10 ++-- include/core/GP_Gamma.h | 12 +++--- include/core/GP_GetPutPixel.h | 8 ++-- include/core/GP_GetSetBits.h | 10 ++-- include/core/GP_Pixel.h | 14 +++--- include/core/GP_ProgressCallback.h | 8 ++-- include/core/GP_Threads.h | 2 +- include/core/GP_Transform.h | 24 +++++----- include/core/GP_Types.h | 4 +- include/filters/GP_Blur.h | 2 +- include/filters/GP_Convolution.h | 16 +++--- include/filters/GP_FilterParam.h | 2 +- include/filters/GP_GaussianNoise.h | 2 +- include/filters/GP_HilbertCurve.h | 4 +- include/filters/GP_Linear.h | 4 +- include/filters/GP_Median.h | 2 +- include/filters/GP_Point.h | 2 +- include/filters/GP_Resize.h | 4 +- include/filters/GP_Rotate.h | 8 ++-- include/filters/GP_Sigma.h | 6 +- include/filters/GP_WeightedMedian.h | 2 +- include/gfx/GP_CircleSeg.h | 4 +- include/gfx/GP_HLineAA.h | 4 +- include/gfx/GP_LineAA.h | 6 +- include/gfx/GP_PutPixelAA.h | 4 +- include/gfx/GP_VLineAA.h | 4 +- include/grabbers/GP_Grabber.h | 4 +- include/input/GP_Event.h | 14 +++--- include/input/GP_InputDriverLinux.h | 6 +- include/input/GP_TimeStamp.h | 2 +- include/input/GP_Timer.h | 8 ++-- include/loaders/GP_BMP.h | 2 +- include/loaders/GP_ByteUtils.h | 6 +- include/loaders/GP_GIF.h | 2 +- include/loaders/GP_JPG.h | 2 +- include/loaders/GP_Loader.h | 12 +++--- include/loaders/GP_MetaData.h | 2 +- include/loaders/GP_PNG.h | 4 +- include/loaders/GP_PSP.h | 2 +- include/loaders/GP_TIFF.h | 2 +- include/loaders/GP_TmpFile.h | 2 +- include/text/GP_Font.h | 16 +++--- include/text/GP_Text.h | 2 +- include/text/GP_TextMetric.h | 4 +- lib.mk | 2 +- libs/backends/GP_Backend.c | 18 ++++---- libs/backends/GP_BackendInit.c | 24 +++++----- libs/backends/GP_BackendVirtual.c | 16 +++--- libs/backends/GP_InputDriverSDL.c | 2 +- libs/backends/GP_InputDriverX11.c | 6 +- libs/backends/GP_LinuxFB.c | 36 ++++++++-------- libs/backends/GP_SDL.c | 16 +++--- libs/backends/GP_X11.c | 8 ++-- libs/backends/GP_X11_Conn.h | 6 +- libs/backends/GP_X11_Win.h | 68 ++++++++++++++-------------- libs/core/GP_Blit.c | 8 ++-- libs/core/GP_Blit.gen.c.t | 2 +- libs/core/GP_Context.c | 34 +++++++------- libs/core/GP_Debug.c | 18 ++++---- libs/core/GP_Gamma.c | 28 ++++++------ libs/core/GP_GetPutPixel.c | 4 +- libs/core/GP_Pixel.c | 22 +++++----- libs/core/GP_Pixel.gen.c.t | 6 +- libs/core/GP_Threads.c | 10 ++-- libs/filters/GP_Blur.c | 16 +++--- libs/filters/GP_Convolution.c | 2 +- libs/filters/GP_Dither.c | 4 +- libs/filters/GP_Edge.c | 28 ++++++------ libs/filters/GP_FilterParam.c | 28 ++++++------ libs/filters/GP_FloydSteinberg.gen.c.t | 14 +++--- libs/filters/GP_GaussianNoise.gen.c.t | 14 +++--- libs/filters/GP_HilbertPeano.gen.c.t | 4 +- libs/filters/GP_Laplace.c | 6 +- libs/filters/GP_Linear.c | 60 +++++++++++++------------- libs/filters/GP_LinearThreads.c | 32 +++++++------- libs/filters/GP_Median.c | 52 +++++++++++----------- libs/filters/GP_MirrorV.gen.c.t | 2 +- libs/filters/GP_Resize.c | 46 ++++++++++---------- libs/filters/GP_ResizeCubic.gen.c.t | 36 ++++++++-------- libs/filters/GP_ResizeLinear.gen.c.t | 32 +++++++------- libs/filters/GP_ResizeNN.gen.c.t | 4 +- libs/filters/GP_Rotate.c | 10 ++-- libs/filters/GP_Rotate.gen.c.t | 18 ++++---- libs/filters/GP_Sigma.c | 33 +++++++------- libs/filters/GP_Stats.c | 8 ++-- libs/filters/GP_WeightedMedian.c | 16 +++--- libs/gfx/GP_Arc.c | 4 +- libs/gfx/GP_Circle.c | 14 +++--- libs/gfx/GP_CircleSeg.c | 6 +- libs/gfx/GP_Ellipse.c | 4 +- libs/gfx/GP_FillEllipse.gen.c.t | 8 ++-- libs/gfx/GP_HLine.gen.c.t | 2 +- libs/gfx/GP_HLineAA.c | 4 +- libs/gfx/GP_HLineAA.gen.c.t | 16 +++--- libs/gfx/GP_Line.gen.c.t | 2 +- libs/gfx/GP_LineAA.c | 4 +- libs/gfx/GP_LineAA.gen.c.t | 34 ++++++++++++--- libs/gfx/GP_LineClip.c | 6 +- libs/gfx/GP_PutPixelAA.gen.c.t | 6 +- libs/gfx/GP_Rect.c | 8 ++-- libs/gfx/GP_RectAA.c | 24 +++++------ libs/gfx/GP_Tetragon.c | 6 +- libs/gfx/GP_Triangle.c | 2 +- libs/gfx/GP_VLine.c | 6 +- libs/gfx/GP_VLine.gen.c.t | 4 +- libs/gfx/GP_VLineAA.c | 2 +- libs/gfx/GP_VLineAA.gen.c.t | 35 ++++++++++++--- libs/grabbers/GP_V4L2.c | 44 +++++++++--------- libs/input/GP_Event.c | 2 +- libs/input/GP_EventQueue.c | 42 +++++++++-------- libs/input/GP_InputDriverKBD.c | 2 +- libs/input/GP_InputDriverLinux.c | 28 ++++++------ libs/input/GP_TimeStamp.c | 2 +- libs/input/GP_Timer.c | 10 ++-- libs/loaders/GP_BMP.c | 56 ++++++++++++------------ libs/loaders/GP_ByteUtils.c | 16 +++--- libs/loaders/GP_GIF.c | 35 +++++++-------- libs/loaders/GP_JPG.c | 30 ++++++------ libs/loaders/GP_Loader.c | 19 ++++---- libs/loaders/GP_MetaData.c | 44 +++++++++--------- libs/loaders/GP_MetaExif.c | 43 +++++++++--------- libs/loaders/GP_PNG.c | 36 ++++++++-------- libs/loaders/GP_PNM.c | 39 ++++++++-------- libs/loaders/GP_PSP.c | 14 +++--- libs/loaders/GP_TIFF.c | 10 ++-- libs/loaders/GP_TmpFile.c | 8 ++-- libs/text/GP_Font.c | 2 +- libs/text/GP_FontTiny.c | 2 +- libs/text/GP_FontTinyMono.c | 2 +- libs/text/GP_FreeType.c | 22 +++++----- libs/text/GP_Text.c | 6 +- libs/text/GP_TextMetric.c | 16 +++--- pylib/gfxprim/backends/_extend_backend.py | 4 +- pylib/gfxprim/backends/backends.i | 8 ++-- pylib/gfxprim/core/core.i | 6 +- pylib/gfxprim/filters/__init__.py | 4 +- pylib/gp_codegen/gfxprimconfig.py | 2 +- pylib/gp_codegen/pixeltype.py | 2 +- pylib/templates/filter.arithmetic.c.t | 12 +++--- pylib/templates/filter.c.t | 6 +- pylib/templates/filter.point.c.t | 6 +- pylib/templates/filter.stats.c.t | 4 +- tests/filters/Makefile | 2 + 156 files changed, 988 insertions(+), 948 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.