From 98cd4f682a77e56eea48dbcd85336c5073deb00c Mon Sep 17 00:00:00 2001 From: Cyril Hrubis Date: Sat, 23 Sep 2017 10:54:22 +0200 Subject: [PATCH] Rename GP_Context -> GP_Pixmap This should have been done long long time ago. Signed-off-by: Cyril Hrubis --- build/syms/Backend_symbols.txt | 2 +- build/syms/Core_symbols.txt | 26 +-- demos/bogoman/bogoman.c | 14 +- demos/bogoman/bogoman_render.c | 98 ++++----- demos/bogoman/bogoman_render.h | 6 +- demos/c_simple/SDL_glue.c | 18 +- demos/c_simple/backend_example.c | 12 +- demos/c_simple/backend_timers_example.c | 6 +- demos/c_simple/blittest.c | 32 +-- demos/c_simple/convolution.c | 2 +- demos/c_simple/debug_handler.c | 6 +- demos/c_simple/fileview.c | 16 +- demos/c_simple/filters_symmetry.c | 6 +- demos/c_simple/fonttest.c | 26 +-- demos/c_simple/gaussian_noise.c | 4 +- demos/c_simple/gfx_koch.c | 12 +- demos/c_simple/input_example.c | 12 +- demos/c_simple/koch.c | 36 ++-- demos/c_simple/linetest.c | 22 +-- demos/c_simple/loaders.c | 2 +- demos/c_simple/loaders_example.c | 2 +- demos/c_simple/loaders_register.c | 4 +- demos/c_simple/memory_io.c | 6 +- demos/c_simple/pretty_print.c | 8 +- demos/c_simple/randomshapetest.c | 58 +++--- demos/c_simple/shapetest.c | 40 ++-- demos/c_simple/showimage.c | 12 +- demos/c_simple/sin_AA.c | 24 +-- demos/c_simple/textaligntest.c | 42 ++-- demos/c_simple/v4l2_show.c | 12 +- demos/c_simple/virtual_backend_example.c | 42 ++-- demos/c_simple/weighted_median.c | 4 +- demos/c_simple/x11_windows.c | 18 +- demos/c_simple/zip_container.c | 14 +- demos/grinder/grinder.c | 78 ++++---- demos/grinder/histogram.c | 6 +- demos/grinder/histogram.h | 2 +- demos/particle/particle_demo.c | 18 +- demos/particle/space.c | 42 ++-- demos/particle/space.h | 2 +- demos/py_simple/backends.py | 2 +- demos/py_simple/blit.py | 8 +- demos/py_simple/cam_view.py | 2 +- demos/py_simple/font_style.py | 2 +- demos/py_simple/gfx.py | 78 ++++---- demos/py_simple/gravplots_AA.py | 16 +- demos/py_simple/showimage.py | 2 +- demos/py_simple/sinplots_AA.py | 10 +- demos/py_simple/x11_windows.py | 2 +- demos/spiv/image_cache.c | 32 +-- demos/spiv/image_cache.h | 8 +- demos/spiv/image_loader.c | 10 +- demos/spiv/image_loader.h | 4 +- demos/spiv/spiv.c | 134 ++++++------- demos/spiv/spiv_help.c | 6 +- demos/ttf2img/ttf2img.c | 14 +- doc/Makefile | 2 +- doc/about.txt | 2 +- doc/backends.txt | 20 +- doc/backends_python.txt | 4 +- doc/blits.txt | 24 +-- doc/coding_style.txt | 8 +- doc/convert.txt | 8 +- doc/core.txt | 6 +- doc/core_python.txt | 34 ++-- doc/debug.txt | 2 +- doc/environment_variables.txt | 6 +- doc/example_SDL_glue.txt | 2 +- doc/filters.txt | 218 ++++++++++---------- doc/filters_dithering.txt | 16 +- doc/filters_resize.txt | 28 +-- doc/gamma.txt | 2 +- doc/get_put_pixel.txt | 22 +-- doc/gfx.txt | 56 +++--- doc/gfx_python.txt | 48 ++--- doc/grabbers.txt | 4 +- doc/images/regen.py | 8 +- doc/loaders.txt | 200 +++++++++---------- doc/loaders_python.txt | 2 +- doc/{context.txt => pixmap.txt} | 146 +++++++------- doc/text.txt | 6 +- include/backends/GP_Backend.h | 14 +- .../backends/{GP_SDL_Context.h => GP_SDL_Pixmap.h} | 18 +- include/core/GP_Blit.h | 36 ++-- include/core/GP_Convert.gen.h.t | 2 +- include/core/GP_Convert.h | 26 +-- include/core/GP_Core.h | 4 +- include/core/GP_Debug.h | 2 +- include/core/GP_Fill.h | 4 +- include/core/GP_FnPerBpp.h | 20 +- include/core/GP_Gamma.h | 4 +- include/core/GP_GammaCorrection.h | 2 +- include/core/GP_GammaPixel.gen.h.t | 2 +- include/core/GP_GetPutPixel.gen.h.t | 16 +- include/core/GP_GetPutPixel.h | 36 ++-- include/core/GP_MixPixels.gen.h.t | 26 +-- include/core/GP_Pixel.gen.h.t | 4 +- include/core/GP_Pixel.h | 4 +- include/core/{GP_Context.h => GP_Pixmap.h} | 136 ++++++------- include/core/GP_Transform.h | 90 ++++----- include/filters/GP_ApplyTables.h | 10 +- include/filters/GP_Arithmetic.h | 50 ++--- include/filters/GP_Blur.h | 10 +- include/filters/GP_Convolution.h | 12 +- include/filters/GP_Dither.h | 12 +- include/filters/GP_EdgeDetection.h | 8 +- include/filters/GP_Filter.h | 2 +- include/filters/GP_Filters.h | 2 +- include/filters/GP_GaussianNoise.h | 14 +- include/filters/GP_Laplace.h | 8 +- include/filters/GP_Linear.h | 22 +-- include/filters/GP_Median.h | 12 +- include/filters/GP_MultiTone.h | 12 +- include/filters/GP_Point.h | 56 +++--- include/filters/GP_Resize.h | 8 +- include/filters/GP_ResizeCubic.h | 8 +- include/filters/GP_ResizeLinear.h | 8 +- include/filters/GP_ResizeNN.h | 4 +- include/filters/GP_Rotate.h | 38 ++-- include/filters/GP_Sepia.h | 12 +- include/filters/GP_Sigma.h | 12 +- include/filters/GP_Stats.h | 2 +- include/filters/GP_WeightedMedian.h | 12 +- include/gfx/GP_Arc.h | 6 +- include/gfx/GP_Circle.h | 18 +- include/gfx/GP_CircleSeg.h | 10 +- include/gfx/GP_Ellipse.h | 10 +- include/gfx/GP_Gfx.h | 2 +- include/gfx/GP_HLine.gen.h.t | 2 +- include/gfx/GP_HLine.h | 18 +- include/gfx/GP_HLineAA.h | 10 +- include/gfx/GP_Line.h | 6 +- include/gfx/GP_LineAA.h | 10 +- include/gfx/GP_Polygon.h | 10 +- include/gfx/GP_PutPixelAA.h | 14 +- include/gfx/GP_Rect.h | 34 ++-- include/gfx/GP_Tetragon.h | 10 +- include/gfx/GP_Triangle.h | 10 +- include/gfx/GP_VLine.gen.h.t | 2 +- include/gfx/GP_VLine.h | 18 +- include/gfx/GP_VLineAA.h | 10 +- include/grabbers/GP_Grabber.h | 6 +- include/loaders/GP_BMP.h | 12 +- include/loaders/GP_Container.h | 14 +- include/loaders/GP_GIF.h | 6 +- include/loaders/GP_JP2.h | 8 +- include/loaders/GP_JPG.h | 12 +- include/loaders/GP_Loader.h | 30 +-- include/loaders/GP_Loaders.h | 2 +- include/loaders/GP_PCX.h | 8 +- include/loaders/GP_PNG.h | 14 +- include/loaders/GP_PNM.h | 32 +-- include/loaders/GP_PSD.h | 8 +- include/loaders/GP_PSP.h | 10 +- include/loaders/GP_TIFF.h | 12 +- include/loaders/GP_ZIP.h | 2 +- include/text/GP_Text.h | 20 +- libs/backends/GP_AALib.c | 14 +- libs/backends/GP_Backend.c | 14 +- libs/backends/GP_BackendVirtual.c | 30 +-- libs/backends/GP_LinuxFB.c | 40 ++-- libs/backends/GP_SDL.c | 38 ++-- libs/backends/GP_X11.c | 46 ++--- libs/backends/GP_X11_Win.h | 2 +- libs/core/GP_Blit.c | 66 +++---- libs/core/GP_Blit.gen.c.t | 38 ++-- libs/core/GP_Context.c | 220 ++++++++++----------- libs/core/GP_Fill.gen.c.t | 8 +- libs/core/GP_GetPutPixel.c | 16 +- libs/filters/GP_ApplyTables.c | 10 +- libs/filters/GP_ApplyTables.gen.c.t | 10 +- libs/filters/GP_Blur.c | 16 +- libs/filters/GP_Convolution.c | 10 +- libs/filters/GP_Edge.c | 30 +-- libs/filters/GP_FloydSteinberg.gen.c.t | 16 +- libs/filters/GP_GaussianNoise.gen.c.t | 20 +- libs/filters/GP_HilbertPeano.gen.c.t | 16 +- libs/filters/GP_Histogram.gen.c.t | 8 +- libs/filters/GP_Laplace.c | 16 +- libs/filters/GP_LinearConvolution.c | 6 +- libs/filters/GP_LinearConvolution.gen.c.t | 26 +-- libs/filters/GP_Median.c | 16 +- libs/filters/GP_MirrorH.gen.c.t | 18 +- libs/filters/GP_MultiTone.gen.c.t | 18 +- libs/filters/GP_Resize.c | 12 +- libs/filters/GP_ResizeCubic.gen.c.t | 10 +- libs/filters/GP_ResizeCubicFloat.c | 4 +- libs/filters/GP_ResizeLinear.gen.c.t | 14 +- libs/filters/GP_ResizeNN.gen.c.t | 8 +- libs/filters/GP_Rotate.c | 16 +- libs/filters/GP_Rotate.gen.c.t | 48 ++--- libs/filters/GP_Sepia.c | 6 +- libs/filters/GP_Sigma.c | 16 +- libs/filters/GP_WeightedMedian.c | 16 +- libs/filters/arithmetic_filter.t | 22 +-- libs/filters/point_filter.t | 10 +- libs/gfx/GP_Arc.c | 16 +- libs/gfx/GP_Circle.c | 42 ++-- libs/gfx/GP_CircleSeg.c | 38 ++-- libs/gfx/GP_Ellipse.c | 16 +- libs/gfx/GP_FillCircle.gen.c.t | 22 +-- libs/gfx/GP_FillEllipse.gen.c.t | 24 +-- libs/gfx/GP_HLine.c | 36 ++-- libs/gfx/GP_HLine.gen.c.t | 10 +- libs/gfx/GP_HLineAA.c | 28 +-- libs/gfx/GP_HLineAA.gen.c.t | 16 +- libs/gfx/GP_Line.gen.c.t | 38 ++-- libs/gfx/GP_LineAA.c | 16 +- libs/gfx/GP_LineAA.gen.c.t | 40 ++-- libs/gfx/GP_PartialEllipse.c | 16 +- libs/gfx/GP_Polygon.c | 24 +-- libs/gfx/GP_PutPixelAA.gen.c.t | 22 +-- libs/gfx/GP_Rect.c | 54 ++--- libs/gfx/GP_Tetragon.c | 44 ++--- libs/gfx/GP_Triangle.c | 36 ++-- libs/gfx/GP_VLine.c | 42 ++-- libs/gfx/GP_VLine.gen.c.t | 4 +- libs/gfx/GP_VLineAA.c | 28 +-- libs/gfx/GP_VLineAA.gen.c.t | 16 +- libs/gfx/algo/Arc.algo.h | 24 +-- libs/gfx/algo/Circle.algo.h | 26 +-- libs/gfx/algo/CircleSeg.algo.h | 26 +-- libs/gfx/algo/Ellipse.algo.h | 28 +-- libs/gfx/algo/FillRing.algo.h | 20 +- libs/gfx/algo/FillTriangle.algo.h | 10 +- libs/gfx/algo/PartialEllipse.algo.h | 16 +- libs/grabbers/GP_V4L2.c | 8 +- libs/loaders/GP_BMP.c | 48 ++--- libs/loaders/GP_BMP_RLE.h | 12 +- libs/loaders/GP_Container.c | 2 +- libs/loaders/GP_GIF.c | 16 +- libs/loaders/GP_JP2.c | 14 +- libs/loaders/GP_JPG.c | 30 +-- libs/loaders/GP_Loader.c | 28 +-- libs/loaders/GP_PCX.c | 24 +-- libs/loaders/GP_PNG.c | 26 +-- libs/loaders/GP_PNM.c | 188 +++++++++--------- libs/loaders/GP_PSD.c | 32 +-- libs/loaders/GP_PSP.c | 10 +- libs/loaders/GP_TIFF.c | 30 +-- libs/loaders/GP_ZIP.c | 12 +- libs/text/GP_Text.c | 22 +-- libs/text/GP_Text.gen.c.t | 46 ++--- pylib/gfxprim/__init__.py | 6 +- pylib/gfxprim/backends/__init__.py | 2 +- pylib/gfxprim/backends/_extend_backend.py | 2 +- pylib/gfxprim/core/__init__.py | 124 ++++++------ pylib/gfxprim/core/core.i | 86 ++++---- pylib/gfxprim/filters/__init__.py | 12 +- pylib/gfxprim/gfx/__init__.py | 16 +- pylib/gfxprim/gfx/gfx.i | 8 +- pylib/gfxprim/loaders/__init__.py | 6 +- pylib/gfxprim/text/__init__.py | 12 +- tests/afl/loaders.c | 4 +- tests/core/.gitignore | 2 +- tests/core/BlitClipped.c | 14 +- tests/core/BlitConv.gen.c.t | 26 +-- tests/core/GetPutPixel.gen.c.t | 28 +-- tests/core/Makefile | 4 +- tests/core/{Context.c => Pixmap.c} | 142 ++++++------- tests/core/runtest.sh | 2 +- tests/core/test_list.txt | 2 +- tests/drivers/framebuffer_test.c | 34 ++-- tests/filters/APICoverage.gen.c.t | 100 +++++----- tests/filters/FilterMirrorH.c | 30 +-- tests/filters/FiltersCompare.gen.c.t | 22 +-- tests/filters/LinearConvolution.c | 10 +- tests/filters/common.c | 4 +- tests/filters/common.h | 6 +- tests/gfx/APICoverage.gen.c.t | 42 ++-- tests/gfx/Circle.c | 8 +- tests/gfx/CircleSeg.c | 8 +- tests/gfx/Ellipse.c | 8 +- tests/gfx/FillCircle.c | 8 +- tests/gfx/FillEllipse.c | 8 +- tests/gfx/FillRect.c | 28 +-- tests/gfx/HLine.c | 8 +- tests/gfx/HLineAA.c | 8 +- tests/gfx/Line.c | 8 +- tests/gfx/LineAA.c | 8 +- tests/gfx/Polygon.c | 8 +- tests/gfx/PutPixelAA.c | 8 +- tests/gfx/VLine.c | 8 +- tests/gfx/common.c | 4 +- tests/gfx/common.h | 6 +- tests/gfx/gfx_benchmark.c | 6 +- tests/loaders/GIF.c | 6 +- tests/loaders/JPG.c | 22 +-- tests/loaders/Loader.h | 44 ++--- tests/loaders/PBM.c | 2 +- tests/loaders/PCX.c | 12 +- tests/loaders/PGM.c | 2 +- tests/loaders/PNG.c | 28 +-- tests/loaders/PNM.c | 2 +- tests/loaders/PPM.c | 2 +- tests/loaders/SaveAbort.gen.c.t | 12 +- tests/loaders/SaveLoad.gen.c.t | 18 +- tests/loaders/ZIP.c | 8 +- tests/loaders/loaders_suite.c | 44 ++--- tests/pylib/test_core.py | 76 +++---- tests/pylib/test_gfx.py | 26 +-- tests/pylib/testutils.py | 16 +- 302 files changed, 3327 insertions(+), 3327 deletions(-) rename doc/{context.txt => pixmap.txt} (65%) rename include/backends/{GP_SDL_Context.h => GP_SDL_Pixmap.h} (82%) rename include/core/{GP_Context.h => GP_Pixmap.h} (59%) rename tests/core/{Context.c => Pixmap.c} (60%) diff --git a/build/syms/Backend_symbols.txt b/build/syms/Backend_symbols.txt index 4c830bf3..24bbc8b6 100644 --- a/build/syms/Backend_symbols.txt +++ b/build/syms/Backend_symbols.txt @@ -9,7 +9,7 @@ GP_BackendIsX11 GP_BackendX11RequestFullscreen GP_BackendSDLInit -GP_ContextFromSDLSurface +GP_PixmapFromSDLSurface GP_BackendAALibInit diff --git a/build/syms/Core_symbols.txt b/build/syms/Core_symbols.txt index 47acec59..7ee4ff21 100644 --- a/build/syms/Core_symbols.txt +++ b/build/syms/Core_symbols.txt @@ -1,19 +1,19 @@ GP_PixelTypes GP_PixelHasFlags -GP_ContextAlloc -GP_ContextResize -GP_ContextConvertAlloc -GP_ContextPrintInfo -GP_ContextRotateCCW -GP_SubContextAlloc -GP_ContextConvert -GP_ContextRotateCW -GP_ContextFree -GP_ContextInit -GP_SubContext -GP_ContextCopy -GP_ContextEqual +GP_PixmapAlloc +GP_PixmapResize +GP_PixmapConvertAlloc +GP_PixmapPrintInfo +GP_PixmapRotateCCW +GP_SubPixmapAlloc +GP_PixmapConvert +GP_PixmapRotateCW +GP_PixmapFree +GP_PixmapInit +GP_SubPixmap +GP_PixmapCopy +GP_PixmapEqual GP_PixelAddrOffset GP_GammaRelease diff --git a/demos/bogoman/bogoman.c b/demos/bogoman/bogoman.c index 36402c84..cd0def6c 100644 --- a/demos/bogoman/bogoman.c +++ b/demos/bogoman/bogoman.c @@ -32,29 +32,29 @@ static void save_png(struct bogoman_map *map, unsigned int elem_size, const char *filename) { - GP_Context *ctx; + GP_Pixmap *pixmap; unsigned int rx, ry; rx = elem_size * map->w; ry = elem_size * map->h; - ctx = GP_ContextAlloc(rx, ry, GP_PIXEL_RGB888); + pixmap = GP_PixmapAlloc(rx, ry, GP_PIXEL_RGB888); - if (ctx == NULL) + if (pixmap == NULL) return; struct bogoman_render render = { .map = map, .map_x_offset = 0, .map_y_offset = 0, - .ctx = ctx, + .pixmap = pixmap, .map_elem_size = elem_size, }; bogoman_render(&render, BOGOMAN_RENDER_ALL); - GP_SavePNG(ctx, filename, NULL); - GP_ContextFree(ctx); + GP_SavePNG(pixmap, filename, NULL); + GP_PixmapFree(pixmap); } static struct GP_Backend *backend; @@ -151,7 +151,7 @@ int main(int argc, char *argv[]) .map = map, .map_x_offset = 0, .map_y_offset = 0, - .ctx = backend->context, + .pixmap = backend->pixmap, .backend = backend, .map_elem_size = ELEM_SIZE, }; diff --git a/demos/bogoman/bogoman_render.c b/demos/bogoman/bogoman_render.c index bc47f7d2..c045b541 100644 --- a/demos/bogoman/bogoman_render.c +++ b/demos/bogoman/bogoman_render.c @@ -56,17 +56,17 @@ struct render_colors { static struct render_colors colors; -static void init_colors(GP_Context *ctx, struct render_colors *colors) +static void init_colors(GP_Pixmap *pixmap, struct render_colors *colors) { - colors->bg = GP_RGBToContextPixel(0xee, 0xee, 0xee, ctx); - colors->player = GP_RGBToContextPixel(0x00, 0xee, 0x00, ctx); - colors->frames = GP_RGBToContextPixel(0x00, 0x00, 0x00, ctx); - colors->diamond = GP_RGBToContextPixel(0x00, 0x00, 0xee, ctx); - colors->wall = GP_RGBToContextPixel(0x66, 0x66, 0x66, ctx); - colors->moveable = GP_RGBToContextPixel(0xff, 0xff, 0x60, ctx); - colors->edible = GP_RGBToContextPixel(0xff, 0x7f, 0x50, ctx); - colors->particle = GP_RGBToContextPixel(0xff, 0xff, 0x00, ctx); - colors->particle_dir = GP_RGBToContextPixel(0xff, 0x44, 0x00, ctx); + colors->bg = GP_RGBToPixmapPixel(0xee, 0xee, 0xee, pixmap); + colors->player = GP_RGBToPixmapPixel(0x00, 0xee, 0x00, pixmap); + colors->frames = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); + colors->diamond = GP_RGBToPixmapPixel(0x00, 0x00, 0xee, pixmap); + colors->wall = GP_RGBToPixmapPixel(0x66, 0x66, 0x66, pixmap); + colors->moveable = GP_RGBToPixmapPixel(0xff, 0xff, 0x60, pixmap); + colors->edible = GP_RGBToPixmapPixel(0xff, 0x7f, 0x50, pixmap); + colors->particle = GP_RGBToPixmapPixel(0xff, 0xff, 0x00, pixmap); + colors->particle_dir = GP_RGBToPixmapPixel(0xff, 0x44, 0x00, pixmap); } static void render_none(struct bogoman_render *render, @@ -77,7 +77,7 @@ static void render_none(struct bogoman_render *render, (void) elem; - GP_FillRectXYWH(render->ctx, x, y, w, w, colors.bg); + GP_FillRectXYWH(render->pixmap, x, y, w, w, colors.bg); } static void render_player(struct bogoman_render *render, @@ -88,10 +88,10 @@ static void render_player(struct bogoman_render *render, (void) elem; - GP_FillRectXYWH(render->ctx, x, y, w, w, colors.bg); + GP_FillRectXYWH(render->pixmap, x, y, w, w, colors.bg); - GP_FillCircle(render->ctx, x + w/2, y + w/2, w/2 - 1, colors.player); - GP_FillRing(render->ctx, x + w/2, y + w/2, w/2 - 1, w/2 - 2, colors.frames); + GP_FillCircle(render->pixmap, x + w/2, y + w/2, w/2 - 1, colors.player); + GP_FillRing(render->pixmap, x + w/2, y + w/2, w/2 - 1, w/2 - 2, colors.frames); } static void render_wall(struct bogoman_render *render, @@ -100,26 +100,26 @@ static void render_wall(struct bogoman_render *render, { unsigned int w = render->map_elem_size; - GP_FillRectXYWH(render->ctx, x, y, w, w, colors.wall); + GP_FillRectXYWH(render->pixmap, x, y, w, w, colors.wall); if (!(elem->flags & BOGOMAN_LEFT)) { - GP_VLineXYH(render->ctx, x, y, w, colors.frames); - GP_VLineXYH(render->ctx, x+1, y, w, colors.frames); + GP_VLineXYH(render->pixmap, x, y, w, colors.frames); + GP_VLineXYH(render->pixmap, x+1, y, w, colors.frames); } if (!(elem->flags & BOGOMAN_RIGHT)) { - GP_VLineXYH(render->ctx, x + w - 1, y, w, colors.frames); - GP_VLineXYH(render->ctx, x + w - 2, y, w, colors.frames); + GP_VLineXYH(render->pixmap, x + w - 1, y, w, colors.frames); + GP_VLineXYH(render->pixmap, x + w - 2, y, w, colors.frames); } if (!(elem->flags & BOGOMAN_UP)) { - GP_HLineXYW(render->ctx, x, y, w, colors.frames); - GP_HLineXYW(render->ctx, x, y+1, w, colors.frames); + GP_HLineXYW(render->pixmap, x, y, w, colors.frames); + GP_HLineXYW(render->pixmap, x, y+1, w, colors.frames); } if (!(elem->flags & BOGOMAN_DOWN)) { - GP_HLineXYW(render->ctx, x, y + w - 1, w, colors.frames); - GP_HLineXYW(render->ctx, x, y + w - 2, w, colors.frames); + GP_HLineXYW(render->pixmap, x, y + w - 1, w, colors.frames); + GP_HLineXYW(render->pixmap, x, y + w - 2, w, colors.frames); } } @@ -129,16 +129,16 @@ static void render_diamond(struct bogoman_render *render, { unsigned int w = render->map_elem_size; - GP_FillRectXYWH(render->ctx, x, y, w, w, colors.bg); + GP_FillRectXYWH(render->pixmap, x, y, w, w, colors.bg); (void) elem; - GP_FillTetragon(render->ctx, x + w/2, y, x + w - 1, y + w/2, + GP_FillTetragon(render->pixmap, x + w/2, y, x + w - 1, y + w/2, x + w/2, y + w - 1, x, y + w/2, colors.diamond); - GP_Tetragon(render->ctx, x + w/2, y, x + w - 1, y + w/2, + GP_Tetragon(render->pixmap, x + w/2, y, x + w - 1, y + w/2, x + w/2, y + w - 1, x, y + w/2, colors.frames); - GP_Tetragon(render->ctx, x + w/2, y+1, x + w - 2, y + w/2, + GP_Tetragon(render->pixmap, x + w/2, y+1, x + w - 2, y + w/2, x + w/2, y + w - 2, x+1, y + w/2, colors.frames); } @@ -150,11 +150,11 @@ static void render_moveable(struct bogoman_render *render, (void) elem; - GP_FillRectXYWH(render->ctx, x, y, w, w, colors.bg); + GP_FillRectXYWH(render->pixmap, x, y, w, w, colors.bg); - GP_FillRectXYWH(render->ctx, x + 1, y + 1, w - 2, w - 2, colors.moveable); - GP_RectXYWH(render->ctx, x + 1, y + 1, w - 2, w - 2, colors.frames); - GP_RectXYWH(render->ctx, x + 2, y + 2, w - 4, w - 4, colors.frames); + GP_FillRectXYWH(render->pixmap, x + 1, y + 1, w - 2, w - 2, colors.moveable); + GP_RectXYWH(render->pixmap, x + 1, y + 1, w - 2, w - 2, colors.frames); + GP_RectXYWH(render->pixmap, x + 2, y + 2, w - 4, w - 4, colors.frames); } static void render_edible(struct bogoman_render *render, @@ -165,9 +165,9 @@ static void render_edible(struct bogoman_render *render, (void) elem; - GP_FillRectXYWH(render->ctx, x, y, w, w, colors.bg); + GP_FillRectXYWH(render->pixmap, x, y, w, w, colors.bg); - GP_FillRectXYWH(render->ctx, x + 1, y + 1, w - 2, w - 2, colors.edible); + GP_FillRectXYWH(render->pixmap, x + 1, y + 1, w - 2, w - 2, colors.edible); } static void render_particle(struct bogoman_render *render, @@ -177,43 +177,43 @@ static void render_particle(struct bogoman_render *render, unsigned int w = render->map_elem_size; int dir = elem->flags & BOGOMAN_DIRECTION_MASK; - GP_FillRectXYWH(render->ctx, x, y, w, w, colors.bg); + GP_FillRectXYWH(render->pixmap, x, y, w, w, colors.bg); switch (elem->flags & ~BOGOMAN_DIRECTION_MASK) { case BOGOMAN_PARTICLE_ROUND: - GP_FillCircle(render->ctx, x + w/2, y + w/2, w/2-1, colors.particle); - GP_FillRing(render->ctx, x + w/2, y + w/2, w/2 - 1, w/2 - 2, colors.frames); + GP_FillCircle(render->pixmap, x + w/2, y + w/2, w/2-1, colors.particle); + GP_FillRing(render->pixmap, x + w/2, y + w/2, w/2 - 1, w/2 - 2, colors.frames); break; case BOGOMAN_PARTICLE_SQUARE: - GP_FillRectXYWH(render->ctx, x+1, y+1, w-2, w-2, colors.particle); - GP_RectXYWH(render->ctx, x+1, y+1, w-2, w-2, colors.frames); - GP_RectXYWH(render->ctx, x+2, y+2, w-4, w-4, colors.frames); + GP_FillRectXYWH(render->pixmap, x+1, y+1, w-2, w-2, colors.particle); + GP_RectXYWH(render->pixmap, x+1, y+1, w-2, w-2, colors.frames); + GP_RectXYWH(render->pixmap, x+2, y+2, w-4, w-4, colors.frames); break; } switch (dir) { case BOGOMAN_LEFT: - GP_FillTriangle(render->ctx, x + w/4, y + w/2, + GP_FillTriangle(render->pixmap, x + w/4, y + w/2, x + 5*w/8, y + w/4, x + 5*w/8, y + 3*w/4, colors.particle_dir); - GP_Triangle(render->ctx, x + w/4, y + w/2, + GP_Triangle(render->pixmap, x + w/4, y + w/2, x + 5*w/8, y + w/4, x + 5*w/8, y + 3*w/4, colors.frames); break; case BOGOMAN_RIGHT: - GP_FillTriangle(render->ctx, x + 3*w/4, y + w/2, + GP_FillTriangle(render->pixmap, x + 3*w/4, y + w/2, x + 3*w/8, y + w/4, x + 3*w/8, y + 3*w/4, colors.particle_dir); - GP_Triangle(render->ctx, x + 3*w/4, y + w/2, + GP_Triangle(render->pixmap, x + 3*w/4, y + w/2, x + 3*w/8, y + w/4, x + 3*w/8, y + 3*w/4, colors.frames); break; case BOGOMAN_UP: - GP_FillTriangle(render->ctx, x + w/2, y + w/4, + GP_FillTriangle(render->pixmap, x + w/2, y + w/4, x + w/4, y + 5*w/8, x + 3*w/4, y + 5*w/8, colors.particle_dir); - GP_Triangle(render->ctx, x + w/2, y + w/4, + GP_Triangle(render->pixmap, x + w/2, y + w/4, x + w/4, y + 5*w/8, x + 3*w/4, y + 5*w/8, colors.frames); break; case BOGOMAN_DOWN: - GP_FillTriangle(render->ctx, x + w/2, y + 3*w/4, + GP_FillTriangle(render->pixmap, x + w/2, y + 3*w/4, x + w/4, y + 3*w/8, x + 3*w/4, y + 3*w/8, colors.particle_dir); - GP_Triangle(render->ctx, x + w/2, y + 3*w/4, + GP_Triangle(render->pixmap, x + w/2, y + 3*w/4, x + w/4, y + 3*w/8, x + 3*w/4, y + 3*w/8, colors.frames); break; } @@ -268,10 +268,10 @@ void bogoman_render(struct bogoman_render *render, int flags) unsigned int x, y; //TODO: Hack - init_colors(render->ctx, &colors); + init_colors(render->pixmap, &colors); if (flags & BOGOMAN_RENDER_ALL) - GP_Fill(render->ctx, colors.bg); + GP_Fill(render->pixmap, colors.bg); for (y = render->map_x_offset; y < render->map->h; y++) { for (x = render->map_x_offset; x < render->map->w; x++) diff --git a/demos/bogoman/bogoman_render.h b/demos/bogoman/bogoman_render.h index e27744e2..38b7f0d5 100644 --- a/demos/bogoman/bogoman_render.h +++ b/demos/bogoman/bogoman_render.h @@ -24,7 +24,7 @@ #define __BOGOMAN_RENDER_H__ struct bogoman_map; -struct GP_Context; +struct GP_Pixmap; struct bogoman_render { /* both in map elements */ @@ -34,8 +34,8 @@ struct bogoman_render { /* current map */ struct bogoman_map *map; - /* context to be used for rendering */ - struct GP_Context *ctx; + /* pixmap to be used for rendering */ + struct GP_Pixmap *pixmap; /* if not NULL is used to update screen */ struct GP_Backend *backend; diff --git a/demos/c_simple/SDL_glue.c b/demos/c_simple/SDL_glue.c index 8e9e2162..ef360e0b 100644 --- a/demos/c_simple/SDL_glue.c +++ b/demos/c_simple/SDL_glue.c @@ -33,13 +33,13 @@ #include #include #include -#include +#include #define W 320 #define H 240 static SDL_Surface *display = NULL; -static GP_Context context; +static GP_Pixmap pixmap; static GP_Pixel black_pixel, darkgray_pixel; @@ -47,13 +47,13 @@ void redraw_screen(void) { SDL_LockSurface(display); - GP_Fill(&context, black_pixel); + GP_Fill(&pixmap, black_pixel); - GP_Text(&context, NULL, W/2, 20, GP_ALIGN_CENTER | GP_VALIGN_BELOW, + GP_Text(&pixmap, NULL, W/2, 20, GP_ALIGN_CENTER | GP_VALIGN_BELOW, darkgray_pixel, black_pixel, "GFXprim SDL Demo"); - GP_Line(&context, 0, 0, W-1, H-1, darkgray_pixel); - GP_Line(&context, 0, H-1, W-1, 0, darkgray_pixel); + GP_Line(&pixmap, 0, 0, W-1, H-1, darkgray_pixel); + GP_Line(&pixmap, 0, H-1, W-1, 0, darkgray_pixel); SDL_UnlockSurface(display); } @@ -100,10 +100,10 @@ int main(void) return 1; } - GP_ContextFromSDLSurface(&context, display); + GP_PixmapFromSDLSurface(&pixmap, display); - black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, &context); - darkgray_pixel = GP_RGBToContextPixel(0x7f, 0x7f, 0x7f, &context); + black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, &pixmap); + darkgray_pixel = GP_RGBToPixmapPixel(0x7f, 0x7f, 0x7f, &pixmap); redraw_screen(); SDL_Flip(display); diff --git a/demos/c_simple/backend_example.c b/demos/c_simple/backend_example.c index 5e87ff18..6c828834 100644 --- a/demos/c_simple/backend_example.c +++ b/demos/c_simple/backend_example.c @@ -31,15 +31,15 @@ static void redraw(GP_Backend *self) { - GP_Context *context = self->context; + GP_Pixmap *pixmap = self->pixmap; GP_Pixel white_pixel, black_pixel; - black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); - white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, context); + black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); + white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, pixmap); - GP_Fill(context, black_pixel); - GP_Line(context, 0, 0, context->w - 1, context->h - 1, white_pixel); - GP_Line(context, 0, context->h - 1, context->w - 1, 0, white_pixel); + GP_Fill(pixmap, black_pixel); + GP_Line(pixmap, 0, 0, pixmap->w - 1, pixmap->h - 1, white_pixel); + GP_Line(pixmap, 0, pixmap->h - 1, pixmap->w - 1, 0, white_pixel); /* Update the backend screen */ GP_BackendFlip(self); diff --git a/demos/c_simple/backend_timers_example.c b/demos/c_simple/backend_timers_example.c index 7b7aae2a..16912fb5 100644 --- a/demos/c_simple/backend_timers_example.c +++ b/demos/c_simple/backend_timers_example.c @@ -31,10 +31,10 @@ static void redraw(GP_Backend *self) { - GP_Context *context = self->context; - GP_Pixel black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); + GP_Pixmap *pixmap = self->pixmap; + GP_Pixel black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); - GP_Fill(context, black_pixel); + GP_Fill(pixmap, black_pixel); /* Update the backend screen */ GP_BackendFlip(self); diff --git a/demos/c_simple/blittest.c b/demos/c_simple/blittest.c index 362ef8b0..c12c8fe7 100644 --- a/demos/c_simple/blittest.c +++ b/demos/c_simple/blittest.c @@ -31,7 +31,7 @@ static GP_Pixel white; static GP_Backend *win; -static GP_Context *bitmap, *bitmap_raw, *bitmap_conv; +static GP_Pixmap *bitmap, *bitmap_raw, *bitmap_conv; static int bitmap_x, bitmap_y, bitmap_vx = -3, bitmap_vy = -3; static int pause_flag = 0; @@ -42,7 +42,7 @@ void redraw_screen(void) bitmap_x += bitmap_vx; bitmap_y += bitmap_vy; - if (bitmap_x + GP_ContextW(bitmap) > win->context->w) { + if (bitmap_x + GP_PixmapW(bitmap) > win->pixmap->w) { bitmap_vx = -bitmap_vx; bitmap_x += bitmap_vx; } @@ -52,7 +52,7 @@ void redraw_screen(void) bitmap_x += bitmap_vx; } - if (bitmap_y + GP_ContextH(bitmap) > win->context->h) { + if (bitmap_y + GP_PixmapH(bitmap) > win->pixmap->h) { bitmap_vy = -bitmap_vy; bitmap_y += bitmap_vy; } @@ -62,20 +62,20 @@ void redraw_screen(void) bitmap_y += bitmap_vy; } - GP_FillRectXYWH(win->context, 20, 20, 300, 50, black); + GP_FillRectXYWH(win->pixmap, 20, 20, 300, 50, black); - GP_Text(win->context, NULL, 20, 20, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + GP_Text(win->pixmap, NULL, 20, 20, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, white, black, text_buf); - GP_Print(win->context, NULL, 250, 20, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + GP_Print(win->pixmap, NULL, 250, 20, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, white, black, "%c|%c|%c", bitmap->x_swap ? 'x' : ' ', bitmap->y_swap ? 'y' : ' ', bitmap->axes_swap ? 'a' : ' '); - GP_Blit(bitmap, 0, 0, GP_ContextW(bitmap), GP_ContextH(bitmap), - win->context, bitmap_x, bitmap_y); + GP_Blit(bitmap, 0, 0, GP_PixmapW(bitmap), GP_PixmapH(bitmap), + win->pixmap, bitmap_x, bitmap_y); GP_BackendUpdateRectXYWH(win, bitmap_x, bitmap_y, - GP_ContextW(bitmap), GP_ContextH(bitmap)); + GP_PixmapW(bitmap), GP_PixmapH(bitmap)); GP_BackendUpdateRectXYWH(win, 20, 20, 400, 50); } @@ -88,7 +88,7 @@ static void change_bitmap(void) snprintf(text_buf, sizeof(text_buf), "'%s' -> '%s'", GP_PixelTypeName(bitmap->pixel_type), - GP_PixelTypeName(win->context->pixel_type)); + GP_PixelTypeName(win->pixmap->pixel_type)); } void event_loop(void) @@ -133,7 +133,7 @@ void event_loop(void) break; case GP_EV_SYS_RESIZE: GP_BackendResizeAck(win); - GP_Fill(win->context, black); + GP_Fill(win->pixmap, black); GP_BackendFlip(win); break; } @@ -175,14 +175,14 @@ int main(void) return 1; } - bitmap_conv = GP_ContextConvertAlloc(bitmap_raw, - win->context->pixel_type); + bitmap_conv = GP_PixmapConvertAlloc(bitmap_raw, + win->pixmap->pixel_type); change_bitmap(); - black = GP_RGBToContextPixel(0x00, 0x00, 0x00, win->context); - white = GP_RGBToContextPixel(0xff, 0xff, 0xff, win->context); + black = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win->pixmap); + white = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win->pixmap); - GP_Fill(win->context, black); + GP_Fill(win->pixmap, black); GP_BackendFlip(win); for (;;) { diff --git a/demos/c_simple/convolution.c b/demos/c_simple/convolution.c index 213baf8e..7d26f175 100644 --- a/demos/c_simple/convolution.c +++ b/demos/c_simple/convolution.c @@ -53,7 +53,7 @@ static int progress_callback(GP_ProgressCallback *self) int main(int argc, char *argv[]) { - GP_Context *img; + GP_Pixmap *img; struct callback_priv priv; GP_ProgressCallback callback = {.callback = progress_callback, .priv = &priv}; diff --git a/demos/c_simple/debug_handler.c b/demos/c_simple/debug_handler.c index 1744b049..5c472fd6 100644 --- a/demos/c_simple/debug_handler.c +++ b/demos/c_simple/debug_handler.c @@ -65,11 +65,11 @@ int main(void) /* Turn on verbose debug and call some library functions */ GP_SetDebugLevel(10); - GP_Context *ctx = GP_ContextAlloc(1000, 1000, 1); + GP_Pixmap *pixmap = GP_PixmapAlloc(1000, 1000, 1); - GP_FilterGaussianBlur(ctx, ctx, 10, 10, NULL); + GP_FilterGaussianBlur(pixmap, pixmap, 10, 10, NULL); - GP_ContextFree(ctx); + GP_PixmapFree(pixmap); return 0; } diff --git a/demos/c_simple/fileview.c b/demos/c_simple/fileview.c index e33a74a3..d5c870b6 100644 --- a/demos/c_simple/fileview.c +++ b/demos/c_simple/fileview.c @@ -29,7 +29,7 @@ #include -static GP_Context *win; +static GP_Pixmap *win; static GP_Backend *backend; static GP_Pixel white_pixel, gray_pixel, dark_gray_pixel, black_pixel, @@ -266,14 +266,14 @@ int main(int argc, char *argv[]) return 1; } - win = backend->context; + win = backend->pixmap; - white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, win); - gray_pixel = GP_RGBToContextPixel(0xbe, 0xbe, 0xbe, win); - dark_gray_pixel = GP_RGBToContextPixel(0x7f, 0x7f, 0x7f, win); - black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, win); - red_pixel = GP_RGBToContextPixel(0xff, 0x00, 0x00, win); - blue_pixel = GP_RGBToContextPixel(0x00, 0x00, 0xff, win); + white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win); + gray_pixel = GP_RGBToPixmapPixel(0xbe, 0xbe, 0xbe, win); + dark_gray_pixel = GP_RGBToPixmapPixel(0x7f, 0x7f, 0x7f, win); + black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win); + red_pixel = GP_RGBToPixmapPixel(0xff, 0x00, 0x00, win); + blue_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0xff, win); redraw_screen(); GP_BackendFlip(backend); diff --git a/demos/c_simple/filters_symmetry.c b/demos/c_simple/filters_symmetry.c index 735be566..92644535 100644 --- a/demos/c_simple/filters_symmetry.c +++ b/demos/c_simple/filters_symmetry.c @@ -48,7 +48,7 @@ static void usage_and_exit(int ret) int main(int argc, char *argv[]) { - GP_Context *src, *res; + GP_Pixmap *src, *res; const char *symmetry = NULL; int opt, sym, debug = 0; @@ -109,8 +109,8 @@ int main(int argc, char *argv[]) } /* Cleanup */ - GP_ContextFree(src); - GP_ContextFree(res); + GP_PixmapFree(src); + GP_PixmapFree(res); return 0; } diff --git a/demos/c_simple/fonttest.c b/demos/c_simple/fonttest.c index 7d6a7ca0..e2e5dd6c 100644 --- a/demos/c_simple/fonttest.c +++ b/demos/c_simple/fonttest.c @@ -101,7 +101,7 @@ static void print_font_properties(const GP_FontFace *font) void redraw_screen(void) { - GP_Fill(win->context, black_pixel); + GP_Fill(win->pixmap, black_pixel); GP_TextStyle style = GP_DEFAULT_TEXT_STYLE; @@ -144,29 +144,29 @@ void redraw_screen(void) style.pixel_yspace = 0; style.char_xspace = tracking; - GP_FillRectXYWH(win->context, + GP_FillRectXYWH(win->pixmap, 16, SPACING*i + 16, GP_TextWidth(&style, test_string), GP_FontHeight(style.font), dark_gray_pixel); - GP_RectXYWH(win->context, + GP_RectXYWH(win->pixmap, 15, SPACING*i + 15, GP_TextMaxWidth(&style, strlen(test_string)) + 1, GP_FontHeight(style.font) + 1, blue_pixel); - GP_Text(win->context, &style, 16, SPACING*i + 16, align, + GP_Text(win->pixmap, &style, 16, SPACING*i + 16, align, white_pixel, dark_gray_pixel, test_string); style.pixel_xmul = 2; style.pixel_ymul = 2; style.pixel_yspace = 1; - GP_Text(win->context, &style, 34, SPACING * i + 44, align, + GP_Text(win->pixmap, &style, 34, SPACING * i + 44, align, white_pixel, black_pixel, test_string); - GP_RectXYWH(win->context, 33, SPACING * i + 43, + GP_RectXYWH(win->pixmap, 33, SPACING * i + 43, GP_TextWidth(&style, test_string) + 1, GP_TextHeight(&style) + 1, dark_gray_pixel); @@ -184,7 +184,7 @@ void redraw_screen(void) style.pixel_yspace = 2; } - GP_Text(win->context, &style, 64, SPACING*i + 88, align, + GP_Text(win->pixmap, &style, 64, SPACING*i + 88, align, dark_gray_pixel, black_pixel, test_string); } } @@ -287,12 +287,12 @@ int main(int argc, char *argv[]) return 1; } - white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, win->context); - gray_pixel = GP_RGBToContextPixel(0xbe, 0xbe, 0xbe, win->context); - dark_gray_pixel = GP_RGBToContextPixel(0x7f, 0x7f, 0x7f, win->context); - black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, win->context); - red_pixel = GP_RGBToContextPixel(0xff, 0x00, 0x00, win->context); - blue_pixel = GP_RGBToContextPixel(0x00, 0x00, 0xff, win->context); + white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win->pixmap); + gray_pixel = GP_RGBToPixmapPixel(0xbe, 0xbe, 0xbe, win->pixmap); + dark_gray_pixel = GP_RGBToPixmapPixel(0x7f, 0x7f, 0x7f, win->pixmap); + black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win->pixmap); + red_pixel = GP_RGBToPixmapPixel(0xff, 0x00, 0x00, win->pixmap); + blue_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0xff, win->pixmap); redraw_screen(); GP_BackendFlip(win); diff --git a/demos/c_simple/gaussian_noise.c b/demos/c_simple/gaussian_noise.c index 21425ce0..8c0cb152 100644 --- a/demos/c_simple/gaussian_noise.c +++ b/demos/c_simple/gaussian_noise.c @@ -42,7 +42,7 @@ static void help(const char *app) int main(int argc, char *argv[]) { - GP_Context *img; + GP_Pixmap *img; float sigma = 0.1, mu = 0.1; int opt; @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) return 1; } - GP_Context *res = GP_FilterGaussianNoiseAddAlloc(img, sigma, mu, NULL); + GP_Pixmap *res = GP_FilterGaussianNoiseAddAlloc(img, sigma, mu, NULL); if (GP_SaveImage(res, argv[optind + 1], NULL)) { fprintf(stderr, "Failed to save image '%s': %s", diff --git a/demos/c_simple/gfx_koch.c b/demos/c_simple/gfx_koch.c index c188f3ad..615f2345 100644 --- a/demos/c_simple/gfx_koch.c +++ b/demos/c_simple/gfx_koch.c @@ -38,7 +38,7 @@ static int aa_flag = 0; /* * Generate color depending on distance from center * - * We could do this only and only because the context + * We could do this only and only because the pixmap * pixel type is fixed to GP_PIXEL_RGB888. */ static GP_Pixel do_color(int xc, int yc, float x, float y) @@ -66,7 +66,7 @@ static GP_Pixel do_color(int xc, int yc, float x, float y) return bmask | (gmask<<8) | (rmask << 16); } -static void draw(GP_Context *img, int level, float x0, float y0, float x1, float y1) +static void draw(GP_Pixmap *img, int level, float x0, float y0, float x1, float y1) { if (level == 0) { GP_Pixel pixel; @@ -106,13 +106,13 @@ static void draw(GP_Context *img, int level, float x0, float y0, float x1, float int main(void) { - GP_Context *img; + GP_Pixmap *img; /* Create RGB 24 bit image */ - img = GP_ContextAlloc(600, 600, GP_PIXEL_RGB888); + img = GP_PixmapAlloc(600, 600, GP_PIXEL_RGB888); if (img == NULL) { - fprintf(stderr, "Failed to allocate context"); + fprintf(stderr, "Failed to allocate pixmap"); return 1; } @@ -129,7 +129,7 @@ int main(void) } /* Cleanup */ - GP_ContextFree(img); + GP_PixmapFree(img); return 0; } diff --git a/demos/c_simple/input_example.c b/demos/c_simple/input_example.c index 3a294d23..5ac76d30 100644 --- a/demos/c_simple/input_example.c +++ b/demos/c_simple/input_example.c @@ -29,7 +29,7 @@ #include "GP.h" -static GP_Context *win; +static GP_Pixmap *win; static GP_Backend *backend; static GP_Pixel red, green, white, black; @@ -148,12 +148,12 @@ int main(int argc, char *argv[]) return 1; } - win = backend->context; + win = backend->pixmap; - red = GP_RGBToContextPixel(0xff, 0x00, 0x00, win); - green = GP_RGBToContextPixel(0x00, 0xff, 0x00, win); - white = GP_RGBToContextPixel(0xff, 0xff, 0xff, win); - black = GP_RGBToContextPixel(0x00, 0x00, 0x00, win); + red = GP_RGBToPixmapPixel(0xff, 0x00, 0x00, win); + green = GP_RGBToPixmapPixel(0x00, 0xff, 0x00, win); + white = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win); + black = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win); GP_Fill(win, black); GP_BackendFlip(backend); diff --git a/demos/c_simple/koch.c b/demos/c_simple/koch.c index 27ce6744..b5558c06 100644 --- a/demos/c_simple/koch.c +++ b/demos/c_simple/koch.c @@ -40,7 +40,7 @@ #define sgn(x) ((x)>0 ? 1 : -1) static GP_Backend *backend; -static GP_Context *context; +static GP_Pixmap *pixmap; static int iter, l, way = 1, draw_edge = 1; static GP_Pixel black, blue, gray, red; @@ -49,11 +49,11 @@ static void sierpinsky(double x1, double y1, double x4, double y4, int iter) { double x2, y2, x3, y3, x5, y5; GP_Pixel pixel; - pixel = GP_RGBToPixel(0, 0, 255-16*iter, context->pixel_type); + pixel = GP_RGBToPixel(0, 0, 255-16*iter, pixmap->pixel_type); if (iter <= 0) { if (draw_edge) - GP_Line(context, x1, y1, x4, y4, black); + GP_Line(pixmap, x1, y1, x4, y4, black); return; } @@ -66,11 +66,11 @@ static void sierpinsky(double x1, double y1, double x4, double y4, int iter) x5 = (x1+x4)/2 + (y2 - y3)*sqrt(3.00/4); y5 = (y1+y4)/2 + (x3 - x2)*sqrt(3.00/4); - GP_FillTriangle(context, x2, y2, x3, y3, x5, y5, pixel); + GP_FillTriangle(pixmap, x2, y2, x3, y3, x5, y5, pixel); - GP_PutPixel(context, x2, y2, red); - GP_PutPixel(context, x3, y3, red); - GP_PutPixel(context, x5, y5, red); + GP_PutPixel(pixmap, x2, y2, red); + GP_PutPixel(pixmap, x3, y3, red); + GP_PutPixel(pixmap, x5, y5, red); sierpinsky(x1, y1, x2, y2, iter - 1); sierpinsky(x2, y2, x5, y5, iter - 1); @@ -81,8 +81,8 @@ static void sierpinsky(double x1, double y1, double x4, double y4, int iter) static void draw(int x, int y, int l, int iter) { double x1, y1, x2, y2, x3, y3; - int w = context->w; - int h = context->h; + int w = pixmap->w; + int h = pixmap->h; l = ((w < h ? w : h) - 20)/(5 - 1.00*iter/120); @@ -95,9 +95,9 @@ static void draw(int x, int y, int l, int iter) x3 = sin(1.00 * (iter+240)/57) * l + x; y3 = cos(1.00 * (iter+240)/57) * l + y; - GP_Fill(context, gray); + GP_Fill(pixmap, gray); - GP_FillTriangle(context, x1, y1, x2, y2, x3, y3, blue); + GP_FillTriangle(pixmap, x1, y1, x2, y2, x3, y3, blue); sierpinsky(x1, y1, x2, y2, iter/60%6); sierpinsky(x2, y2, x3, y3, iter/60%6); @@ -121,7 +121,7 @@ void redraw(void) if (iter < 0) way *= -1; - draw(context->w/2, context->h/2, l, iter); + draw(pixmap->w/2, pixmap->h/2, l, iter); } int main(void) @@ -136,15 +136,15 @@ int main(void) return 1; } - context = backend->context; + pixmap = backend->pixmap; - black = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); - blue = GP_RGBToContextPixel(0x00, 0x00, 0xff, context); - gray = GP_RGBToContextPixel(0xbe, 0xbe, 0xbe, context); - red = GP_RGBToContextPixel(0xff, 0x00, 0x00, context); + black = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); + blue = GP_RGBToPixmapPixel(0x00, 0x00, 0xff, pixmap); + gray = GP_RGBToPixmapPixel(0xbe, 0xbe, 0xbe, pixmap); + red = GP_RGBToPixmapPixel(0xff, 0x00, 0x00, pixmap); iter = 0; - draw(context->w/2, context->h/2, l, iter); + draw(pixmap->w/2, pixmap->h/2, l, iter); for (;;) { GP_Event ev; diff --git a/demos/c_simple/linetest.c b/demos/c_simple/linetest.c index 19a0244d..7e535df9 100644 --- a/demos/c_simple/linetest.c +++ b/demos/c_simple/linetest.c @@ -41,12 +41,12 @@ void redraw_screen(void) { double angle; int x, y; - int w = win->context->w; - int h = win->context->h; + int w = win->pixmap->w; + int h = win->pixmap->h; int xcenter = w/2; int ycenter = h/2; - GP_Fill(win->context, black); + GP_Fill(win->pixmap, black); for (angle = 0.0; angle < 2*M_PI; angle += 0.1) { x = (int) (w/2 * cos(start_angle + angle)); @@ -56,22 +56,22 @@ void redraw_screen(void) int b = 127.0 + 127.0 * sin(start_angle + angle); GP_Pixel pixel; - pixel = GP_RGBToPixel(r, 0, b, win->context->pixel_type); + pixel = GP_RGBToPixel(r, 0, b, win->pixmap->pixel_type); if (aa_flag) { - GP_LineAA_Raw(win->context, GP_FP_FROM_INT(xcenter), GP_FP_FROM_INT(ycenter), + GP_LineAA_Raw(win->pixmap, GP_FP_FROM_INT(xcenter), GP_FP_FROM_INT(ycenter), GP_FP_FROM_INT(xcenter + x), GP_FP_FROM_INT(ycenter + y), pixel); } else { - GP_Line(win->context, xcenter + x, ycenter + y, xcenter, ycenter, pixel); - GP_Line(win->context, xcenter, ycenter, xcenter + x, ycenter + y, pixel); + GP_Line(win->pixmap, xcenter + x, ycenter + y, xcenter, ycenter, pixel); + GP_Line(win->pixmap, xcenter, ycenter, xcenter + x, ycenter + y, pixel); } } GP_BackendFlip(win); /* axes */ -// GP_HLineXYW(&context, 0, ycenter, display->w, white); -// GP_VLineXYH(&context, xcenter, 0, display->h, white); +// GP_HLineXYW(&pixmap, 0, ycenter, display->w, white); +// GP_VLineXYH(&pixmap, xcenter, 0, display->h, white); } void event_loop(void) @@ -135,8 +135,8 @@ int main(int argc, char *argv[]) return 1; } - white = GP_RGBToContextPixel(0xff, 0xff, 0xff, win->context); - black = GP_RGBToContextPixel(0x00, 0x00, 0x00, win->context); + white = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win->pixmap); + black = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win->pixmap); redraw_screen(); diff --git a/demos/c_simple/loaders.c b/demos/c_simple/loaders.c index 369ec488..e9a3a306 100644 --- a/demos/c_simple/loaders.c +++ b/demos/c_simple/loaders.c @@ -53,7 +53,7 @@ static int progress_callback(GP_ProgressCallback *self) int main(int argc, char *argv[]) { - GP_Context *img; + GP_Pixmap *img; struct callback_priv priv; GP_ProgressCallback callback = {.callback = progress_callback, .priv = &priv}; diff --git a/demos/c_simple/loaders_example.c b/demos/c_simple/loaders_example.c index 9c0a65ad..b240aea9 100644 --- a/demos/c_simple/loaders_example.c +++ b/demos/c_simple/loaders_example.c @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) { - GP_Context *img; + GP_Pixmap *img; /* Turn on debug messages */ GP_SetDebugLevel(10); diff --git a/demos/c_simple/loaders_register.c b/demos/c_simple/loaders_register.c index 5152d6b5..4279c51f 100644 --- a/demos/c_simple/loaders_register.c +++ b/demos/c_simple/loaders_register.c @@ -37,7 +37,7 @@ /* * Saves 2 bpp grayscale image as ASCII Art */ -static int write_data(const GP_Context *img, GP_IO *io, +static int write_data(const GP_Pixmap *img, GP_IO *io, GP_ProgressCallback *callback) { GP_IO *bio; @@ -106,7 +106,7 @@ GP_Loader loader = { int main(int argc, char *argv[]) { - GP_Context *c, *gc; + GP_Pixmap *c, *gc; GP_LoaderRegister(&loader); diff --git a/demos/c_simple/memory_io.c b/demos/c_simple/memory_io.c index 873b27c7..57d09174 100644 --- a/demos/c_simple/memory_io.c +++ b/demos/c_simple/memory_io.c @@ -56,7 +56,7 @@ static char pgm[] = { int main(void) { GP_Backend *b; - GP_Context *img; + GP_Pixmap *img; GP_IO *io; io = GP_IOMem(pgm, sizeof(pgm), NULL); @@ -81,8 +81,8 @@ int main(void) return 1; } - GP_Fill(b->context, 0); - GP_Blit_Clipped(img, 0, 0, img->w, img->h, b->context, + GP_Fill(b->pixmap, 0); + GP_Blit_Clipped(img, 0, 0, img->w, img->h, b->pixmap, (WIN_W - img->w)/2, (WIN_H - img->h)/2); GP_BackendFlip(b); diff --git a/demos/c_simple/pretty_print.c b/demos/c_simple/pretty_print.c index 82e9d084..ddd79bba 100644 --- a/demos/c_simple/pretty_print.c +++ b/demos/c_simple/pretty_print.c @@ -22,7 +22,7 @@ /* - Pretty print function for pixel and context. + Pretty print function for pixel and pixmap. */ @@ -30,14 +30,14 @@ int main(void) { - GP_Context *ctx = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888); + GP_Pixmap *pixmap = GP_PixmapAlloc(100, 100, GP_PIXEL_RGB888); GP_Pixel pix = ~(GP_Pixel)0; /* Pretty prints pixel values */ GP_PixelPrint(pix, GP_PIXEL_RGB888); - /* Pretty prints context info */ - GP_ContextPrintInfo(ctx); + /* Pretty prints pixmap info */ + GP_PixmapPrintInfo(pixmap); return 0; } diff --git a/demos/c_simple/randomshapetest.c b/demos/c_simple/randomshapetest.c index 6b970f0b..766b48e5 100644 --- a/demos/c_simple/randomshapetest.c +++ b/demos/c_simple/randomshapetest.c @@ -56,7 +56,7 @@ static int fill_flag = 1; /* Do a clipping test? */ static int cliptest_flag = 0; -void random_point(const GP_Context *c, int *x, int *y) +void random_point(const GP_Pixmap *c, int *x, int *y) { if (cliptest_flag) { *x = random() % (3*c->w) - c->w; @@ -67,7 +67,7 @@ void random_point(const GP_Context *c, int *x, int *y) } } -void random_point_AA(const GP_Context *c, int *x, int *y) +void random_point_AA(const GP_Pixmap *c, int *x, int *y) { *x = random() % (c->w<<8); *y = random() % (c->h<<8); @@ -76,70 +76,70 @@ void random_point_AA(const GP_Context *c, int *x, int *y) void draw_random_circle(GP_Pixel pixel) { int x, y; - random_point(win->context, &x, &y); + random_point(win->pixmap, &x, &y); int r = random() % 50; if (fill_flag) - GP_FillCircle(win->context, x, y, r, pixel); + GP_FillCircle(win->pixmap, x, y, r, pixel); if (outline_flag) - GP_Circle(win->context, x, y, r, white); + GP_Circle(win->pixmap, x, y, r, white); } void draw_random_ellipse(GP_Pixel pixel) { int x, y; - random_point(win->context, &x, &y); + random_point(win->pixmap, &x, &y); int rx = random() % 50; int ry = random() % 50; if (fill_flag) - GP_FillEllipse(win->context, x, y, rx, ry, pixel); + GP_FillEllipse(win->pixmap, x, y, rx, ry, pixel); if (outline_flag) - GP_Ellipse(win->context, x, y, rx, ry, white); + GP_Ellipse(win->pixmap, x, y, rx, ry, white); } void draw_random_triangle(GP_Pixel pixel) { int x0, y0, x1, y1, x2, y2; - random_point(win->context, &x0, &y0); - random_point(win->context, &x1, &y1); - random_point(win->context, &x2, &y2); + random_point(win->pixmap, &x0, &y0); + random_point(win->pixmap, &x1, &y1); + random_point(win->pixmap, &x2, &y2); if (fill_flag) - GP_FillTriangle(win->context, x0, y0, x1, y1, x2, y2, pixel); + GP_FillTriangle(win->pixmap, x0, y0, x1, y1, x2, y2, pixel); if (outline_flag) - GP_Triangle(win->context, x0, y0, x1, y1, x2, y2, white); + GP_Triangle(win->pixmap, x0, y0, x1, y1, x2, y2, white); } void draw_random_rectangle(GP_Pixel pixel) { int x0, y0, x1, y1; - random_point(win->context, &x0, &y0); - random_point(win->context, &x1, &y1); + random_point(win->pixmap, &x0, &y0); + random_point(win->pixmap, &x1, &y1); if (fill_flag) - GP_FillRect(win->context, x0, y0, x1, y1, pixel); + GP_FillRect(win->pixmap, x0, y0, x1, y1, pixel); if (outline_flag) - GP_Rect(win->context, x0, y0, x1, y1, white); + GP_Rect(win->pixmap, x0, y0, x1, y1, white); } void draw_random_tetragon(GP_Pixel pixel) { int x0, y0, x1, y1, x2, y2, x3, y3; - random_point(win->context, &x0, &y0); - random_point(win->context, &x1, &y1); - random_point(win->context, &x2, &y2); - random_point(win->context, &x3, &y3); + random_point(win->pixmap, &x0, &y0); + random_point(win->pixmap, &x1, &y1); + random_point(win->pixmap, &x2, &y2); + random_point(win->pixmap, &x3, &y3); if (fill_flag) - GP_FillTetragon(win->context, x0, y0, x1, y1, x2, y2, x3, y3, pixel); + GP_FillTetragon(win->pixmap, x0, y0, x1, y1, x2, y2, x3, y3, pixel); if (outline_flag) - GP_Tetragon(win->context, x0, y0, x1, y1, x2, y2, x3, y3, pixel); + GP_Tetragon(win->pixmap, x0, y0, x1, y1, x2, y2, x3, y3, pixel); } void draw_random_polygon(GP_Pixel pixel) @@ -148,15 +148,15 @@ void draw_random_polygon(GP_Pixel pixel) int i; for (i = 0; i < 5; i++) { - random_point(win->context, xy + 2*i, xy + 2*i + 1); + random_point(win->pixmap, xy + 2*i, xy + 2*i + 1); } - GP_FillPolygon_Raw(win->context, 5, xy, pixel); + GP_FillPolygon_Raw(win->pixmap, 5, xy, pixel); } void clear_screen(void) { - GP_Fill(win->context, black); + GP_Fill(win->pixmap, black); GP_BackendFlip(win); } @@ -168,7 +168,7 @@ void redraw_screen(void) /* Pick a random color for drawing. */ GP_Pixel pixel; pixel = GP_RGBToPixel(random() % 256, random() % 256, - random() % 256, win->context->pixel_type); + random() % 256, win->pixmap->pixel_type); switch (shape) { case SHAPE_CIRCLE: @@ -258,8 +258,8 @@ int main(void) return 1; } - white = GP_RGBToContextPixel(0xff, 0xff, 0xff, win->context); - black = GP_RGBToContextPixel(0x00, 0x00, 0x00, win->context); + white = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win->pixmap); + black = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win->pixmap); for (;;) { GP_BackendPoll(win); diff --git a/demos/c_simple/shapetest.c b/demos/c_simple/shapetest.c index 14e832ce..71d82c85 100644 --- a/demos/c_simple/shapetest.c +++ b/demos/c_simple/shapetest.c @@ -28,7 +28,7 @@ #include -static GP_Context *win; +static GP_Pixmap *win; static GP_Backend *backend; /* Basic colors in display-specific format. */ @@ -253,8 +253,8 @@ void redraw_screen(void) if (show_axes) { int w, h; - w = GP_ContextW(win); - h = GP_ContextH(win); + w = GP_PixmapW(win); + h = GP_PixmapH(win); GP_HLine(win, 0, w, center_y, gray); GP_HLine(win, 0, w, center_y-yradius, darkgray); @@ -310,7 +310,7 @@ void redraw_screen(void) static void xradius_add(int xradius_add) { if (xradius + xradius_add > 1 && - xradius + xradius_add < (int)GP_ContextW(win)) + xradius + xradius_add < (int)GP_PixmapW(win)) xradius += xradius_add; } @@ -318,21 +318,21 @@ static void xradius_add(int xradius_add) static void yradius_add(int yradius_add) { if (yradius + yradius_add > 1 && - yradius + yradius_add < (int)GP_ContextH(win)) + yradius + yradius_add < (int)GP_PixmapH(win)) yradius += yradius_add; } static void xcenter_add(int xcenter_add) { if (center_x + xcenter_add > 1 && - center_x + xcenter_add < (int)GP_ContextW(win)/2) + center_x + xcenter_add < (int)GP_PixmapW(win)/2) center_x += xcenter_add; } static void ycenter_add(int ycenter_add) { if (center_y + ycenter_add > 1 && - center_y + ycenter_add < (int)GP_ContextH(win)/2) + center_y + ycenter_add < (int)GP_PixmapH(win)/2) center_y += ycenter_add; } @@ -364,8 +364,8 @@ void event_loop(void) break; case GP_KEY_R: win->axes_swap = !win->axes_swap; - center_x = GP_ContextW(win) / 2; - center_y = GP_ContextH(win) / 2; + center_x = GP_PixmapW(win) / 2; + center_y = GP_PixmapH(win) / 2; break; case GP_KEY_F: fill = !fill; @@ -451,9 +451,9 @@ void event_loop(void) break; case GP_EV_SYS_RESIZE: GP_BackendResizeAck(backend); - win = backend->context; - center_x = GP_ContextW(win) / 2; - center_y = GP_ContextH(win) / 2; + win = backend->pixmap; + center_x = GP_PixmapW(win) / 2; + center_y = GP_PixmapH(win) / 2; break; } break; @@ -506,19 +506,19 @@ int main(int argc, char *argv[]) return 1; } - win = backend->context; + win = backend->pixmap; center_x = win->w / 2; center_y = win->h / 2; /* Load colors compatible with the display */ - black = GP_RGBToContextPixel(0x00, 0x00, 0x00, win); - white = GP_RGBToContextPixel(0xff, 0xff, 0xff, win); - yellow = GP_RGBToContextPixel(0xff, 0xff, 0x00, win); - green = GP_RGBToContextPixel(0x00, 0xff, 0x00, win); - red = GP_RGBToContextPixel(0xff, 0x00, 0x00, win); - gray = GP_RGBToContextPixel(0xbe, 0xbe, 0xbe, win); - darkgray = GP_RGBToContextPixel(0x7f, 0x7f, 0x7f, win); + black = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win); + white = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win); + yellow = GP_RGBToPixmapPixel(0xff, 0xff, 0x00, win); + green = GP_RGBToPixmapPixel(0x00, 0xff, 0x00, win); + red = GP_RGBToPixmapPixel(0xff, 0x00, 0x00, win); + gray = GP_RGBToPixmapPixel(0xbe, 0xbe, 0xbe, win); + darkgray = GP_RGBToPixmapPixel(0x7f, 0x7f, 0x7f, win); print_instructions(); redraw_screen(); diff --git a/demos/c_simple/showimage.c b/demos/c_simple/showimage.c index 4934d4cf..4208b201 100644 --- a/demos/c_simple/showimage.c +++ b/demos/c_simple/showimage.c @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) { GP_Backend *backend; - GP_Context *image; + GP_Pixmap *image; if (argc != 2) { fprintf(stderr, "Takes image as an argument\n"); @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) } /* Blit image into the window and show it */ - GP_Blit(image, 0, 0, image->w, image->h, backend->context, 0, 0); + GP_Blit(image, 0, 0, image->w, image->h, backend->pixmap, 0, 0); GP_BackendFlip(backend); /* Wait for events */ @@ -78,11 +78,11 @@ int main(int argc, char *argv[]) GP_BackendResizeAck(backend); - cx = ((int)backend->context->w - (int)image->w) / 2; - cy = ((int)backend->context->h - (int)image->h) / 2; + cx = ((int)backend->pixmap->w - (int)image->w) / 2; + cy = ((int)backend->pixmap->h - (int)image->h) / 2; - GP_Fill(backend->context, 0); - GP_Blit_Clipped(image, 0, 0, image->w, image->h, backend->context, cx, cy); + GP_Fill(backend->pixmap, 0); + GP_Blit_Clipped(image, 0, 0, image->w, image->h, backend->pixmap, cx, cy); GP_BackendFlip(backend); } } diff --git a/demos/c_simple/sin_AA.c b/demos/c_simple/sin_AA.c index 20e32027..0191918a 100644 --- a/demos/c_simple/sin_AA.c +++ b/demos/c_simple/sin_AA.c @@ -32,35 +32,35 @@ #include -static void redraw(GP_Context *context) +static void redraw(GP_Pixmap *pixmap) { static float param = 1; static float param2 = 0.01; static int flag = 1; - GP_Pixel b = GP_RGBToContextPixel(0xbe, 0xbe, 0x9e, context); + GP_Pixel b = GP_RGBToPixmapPixel(0xbe, 0xbe, 0x9e, pixmap); unsigned int y; - GP_Fill(context, b); + GP_Fill(pixmap, b); - for (y = 0; y < context->w; y++) { + for (y = 0; y < pixmap->w; y++) { GP_Coord x0, x1, l1, l2; - x0 = (context->w)<<7; - x1 = (context->w)<<7; + x0 = (pixmap->w)<<7; + x1 = (pixmap->w)<<7; - l1 = (context->w)<<5; - l2 = (context->w)<<3; + l1 = (pixmap->w)<<5; + l2 = (pixmap->w)<<3; - GP_Pixel p = GP_RGBToContextPixel(120 - 3 * param, abs(40 * param), 0, context); + GP_Pixel p = GP_RGBToPixmapPixel(120 - 3 * param, abs(40 * param), 0, pixmap); - l2 *= 4.00 * y / context->h; + l2 *= 4.00 * y / pixmap->h; l1 *= param; x0 += l1 * sin(param2 * y) + l2; x1 -= l1 * cos(param2 * y) + l2; - GP_HLineAA(context, x0, x1, y<<8, p); + GP_HLineAA(pixmap, x0, x1, y<<8, p); } if (flag) { @@ -97,7 +97,7 @@ int main(void) /* Wait for events */ for (;;) { if (!pause_flag) { - redraw(backend->context); + redraw(backend->pixmap); GP_BackendFlip(backend); } diff --git a/demos/c_simple/textaligntest.c b/demos/c_simple/textaligntest.c index 0c08140b..9827ee6b 100644 --- a/demos/c_simple/textaligntest.c +++ b/demos/c_simple/textaligntest.c @@ -41,11 +41,11 @@ static GP_Backend *win; void redraw_screen(void) { - GP_Fill(win->context, black_pixel); + GP_Fill(win->pixmap, black_pixel); /* draw axes intersecting in the middle, where text should be shown */ - GP_HLine(win->context, 0, X, Y/2, darkgray_pixel); - GP_VLine(win->context, X/2, 0, Y, darkgray_pixel); + GP_HLine(win->pixmap, 0, X, Y/2, darkgray_pixel); + GP_VLine(win->pixmap, X/2, 0, Y, darkgray_pixel); switch (font_flag) { case 0: @@ -68,17 +68,17 @@ void redraw_screen(void) break; } - GP_Text(win->context, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_BELOW, + GP_Text(win->pixmap, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_BELOW, yellow_pixel, black_pixel, "bottom left"); - GP_Text(win->context, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_BELOW, + GP_Text(win->pixmap, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_BELOW, red_pixel, black_pixel, "bottom right"); - GP_Text(win->context, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_ABOVE, + GP_Text(win->pixmap, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_ABOVE, blue_pixel, black_pixel, "top right"); - GP_Text(win->context, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_ABOVE, + GP_Text(win->pixmap, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_ABOVE, green_pixel, black_pixel, "top left"); - GP_HLine(win->context, 0, X, Y/3, darkgray_pixel); - GP_Text(win->context, &style, X/2, Y/3, GP_ALIGN_CENTER|GP_VALIGN_BASELINE, + GP_HLine(win->pixmap, 0, X, Y/3, darkgray_pixel); + GP_Text(win->pixmap, &style, X/2, Y/3, GP_ALIGN_CENTER|GP_VALIGN_BASELINE, white_pixel, black_pixel, "x center y baseline"); } @@ -96,13 +96,13 @@ static void event_loop(void) switch (ev.val.key.key) { case GP_KEY_X: - win->context->x_swap = !win->context->x_swap; + win->pixmap->x_swap = !win->pixmap->x_swap; break; case GP_KEY_Y: - win->context->y_swap = !win->context->y_swap; + win->pixmap->y_swap = !win->pixmap->y_swap; break; case GP_KEY_R: - win->context->axes_swap = !win->context->axes_swap; + win->pixmap->axes_swap = !win->pixmap->axes_swap; GP_SWAP(X, Y); break; case GP_KEY_SPACE: @@ -146,8 +146,8 @@ static void event_loop(void) break; case GP_EV_SYS_RESIZE: GP_BackendResizeAck(win); - X = win->context->w; - Y = win->context->h; + X = win->pixmap->w; + Y = win->pixmap->h; break; } break; @@ -186,13 +186,13 @@ int main(int argc, char *argv[]) return 1; } - black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, win->context); - red_pixel = GP_RGBToContextPixel(0xff, 0x00, 0x00, win->context); - blue_pixel = GP_RGBToContextPixel(0x00, 0x00, 0xff, win->context); - green_pixel = GP_RGBToContextPixel(0x00, 0xff, 0x00, win->context); - yellow_pixel = GP_RGBToContextPixel(0xff, 0xff, 0x00, win->context); - white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, win->context); - darkgray_pixel = GP_RGBToContextPixel(0x7f, 0x7f, 0x7f, win->context); + black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, win->pixmap); + red_pixel = GP_RGBToPixmapPixel(0xff, 0x00, 0x00, win->pixmap); + blue_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0xff, win->pixmap); + green_pixel = GP_RGBToPixmapPixel(0x00, 0xff, 0x00, win->pixmap); + yellow_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0x00, win->pixmap); + white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, win->pixmap); + darkgray_pixel = GP_RGBToPixmapPixel(0x7f, 0x7f, 0x7f, win->pixmap); redraw_screen(); GP_BackendFlip(win); diff --git a/demos/c_simple/v4l2_show.c b/demos/c_simple/v4l2_show.c index 443d6d49..5f5dacf8 100644 --- a/demos/c_simple/v4l2_show.c +++ b/demos/c_simple/v4l2_show.c @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) for (;;) { if (GP_GrabberPoll(grabber) > 0) { - GP_Context *res, *img = grabber->frame; + GP_Pixmap *res, *img = grabber->frame; switch (mode) { case 0: @@ -113,14 +113,14 @@ int main(int argc, char *argv[]) break; } - unsigned int c_x = (backend->context->w - res->w) / 2; - unsigned int c_y = (backend->context->h - res->h) / 2; + unsigned int c_x = (backend->pixmap->w - res->w) / 2; + unsigned int c_y = (backend->pixmap->h - res->h) / 2; - GP_Blit_Clipped(res, 0, 0, res->w, res->h, backend->context, c_x, c_y); + GP_Blit_Clipped(res, 0, 0, res->w, res->h, backend->pixmap, c_x, c_y); GP_BackendFlip(backend); if (mode) - GP_ContextFree(res); + GP_PixmapFree(res); } usleep(1000); @@ -157,7 +157,7 @@ int main(int argc, char *argv[]) case GP_EV_SYS: if (ev.code == GP_EV_SYS_RESIZE) { GP_BackendResizeAck(backend); - GP_Fill(backend->context, 0); + GP_Fill(backend->pixmap, 0); } break; } diff --git a/demos/c_simple/virtual_backend_example.c b/demos/c_simple/virtual_backend_example.c index f59f4ec3..b1d8199f 100644 --- a/demos/c_simple/virtual_backend_example.c +++ b/demos/c_simple/virtual_backend_example.c @@ -35,48 +35,48 @@ static GP_Pixel white_pixel, black_pixel, red_pixel, blue_pixel, green_pixel; static void redraw(GP_Backend *backend) { - GP_Context *context = backend->context; + GP_Pixmap *pixmap = backend->pixmap; /* Now draw some testing patters */ - black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); - white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, context); - red_pixel = GP_RGBToContextPixel(0xff, 0x00, 0x00, context); - blue_pixel = GP_RGBToContextPixel(0x00, 0x00, 0xff, context); - green_pixel = GP_RGBToContextPixel(0x00, 0xff, 0x00, context); + black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); + white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, pixmap); + red_pixel = GP_RGBToPixmapPixel(0xff, 0x00, 0x00, pixmap); + blue_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0xff, pixmap); + green_pixel = GP_RGBToPixmapPixel(0x00, 0xff, 0x00, pixmap); - GP_Fill(context, white_pixel); + GP_Fill(pixmap, white_pixel); unsigned int i, j; for (i = 0; i < 40; i++) { - GP_HLineXYW(context, 0, i, i, black_pixel); - GP_HLineXYW(context, 1, i + 40, i, black_pixel); - GP_HLineXYW(context, 2, i + 80, i, black_pixel); - GP_HLineXYW(context, 3, i + 120, i, black_pixel); - GP_HLineXYW(context, 4, i + 160, i, black_pixel); - GP_HLineXYW(context, 5, i + 200, i, black_pixel); - GP_HLineXYW(context, 6, i + 240, i, black_pixel); - GP_HLineXYW(context, 7, i + 280, i, black_pixel); + GP_HLineXYW(pixmap, 0, i, i, black_pixel); + GP_HLineXYW(pixmap, 1, i + 40, i, black_pixel); + GP_HLineXYW(pixmap, 2, i + 80, i, black_pixel); + GP_HLineXYW(pixmap, 3, i + 120, i, black_pixel); + GP_HLineXYW(pixmap, 4, i + 160, i, black_pixel); + GP_HLineXYW(pixmap, 5, i + 200, i, black_pixel); + GP_HLineXYW(pixmap, 6, i + 240, i, black_pixel); + GP_HLineXYW(pixmap, 7, i + 280, i, black_pixel); } for (i = 0; i < 256; i++) { for (j = 0; j < 256; j++) { uint8_t val = 1.00 * sqrt(i*i + j*j)/sqrt(2) + 0.5; - GP_Pixel pix = GP_RGBToContextPixel(i, j, val, context); - GP_PutPixel(context, i + 60, j + 10, pix); + GP_Pixel pix = GP_RGBToPixmapPixel(i, j, val, pixmap); + GP_PutPixel(pixmap, i + 60, j + 10, pix); } } - GP_Text(context, NULL, 60, 270, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, + GP_Text(pixmap, NULL, 60, 270, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, black_pixel, white_pixel, "Lorem Ipsum dolor sit..."); - GP_Text(context, NULL, 60, 290, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, + GP_Text(pixmap, NULL, 60, 290, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, red_pixel, white_pixel, "Lorem Ipsum dolor sit..."); - GP_Text(context, NULL, 60, 310, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, + GP_Text(pixmap, NULL, 60, 310, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, green_pixel, white_pixel, "Lorem Ipsum dolor sit..."); - GP_Text(context, NULL, 60, 330, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, + GP_Text(pixmap, NULL, 60, 330, GP_VALIGN_BELOW|GP_ALIGN_RIGHT, blue_pixel, white_pixel, "Lorem Ipsum dolor sit..."); /* Update the backend screen */ diff --git a/demos/c_simple/weighted_median.c b/demos/c_simple/weighted_median.c index a0b09fd4..dc481603 100644 --- a/demos/c_simple/weighted_median.c +++ b/demos/c_simple/weighted_median.c @@ -53,7 +53,7 @@ static int progress_callback(GP_ProgressCallback *self) int main(int argc, char *argv[]) { - GP_Context *img; + GP_Pixmap *img; struct callback_priv priv; GP_ProgressCallback callback = {.callback = progress_callback, .priv = &priv}; @@ -141,7 +141,7 @@ int main(int argc, char *argv[]) priv.op = "Weighted Median"; - GP_Context *res = GP_FilterWeightedMedianAlloc(img, &weights, &callback); + GP_Pixmap *res = GP_FilterWeightedMedianAlloc(img, &weights, &callback); printf("\n"); diff --git a/demos/c_simple/x11_windows.c b/demos/c_simple/x11_windows.c index aa37c7b2..da9d8d8b 100644 --- a/demos/c_simple/x11_windows.c +++ b/demos/c_simple/x11_windows.c @@ -29,16 +29,16 @@ #include #include -static void redraw(struct GP_Context *context) +static void redraw(struct GP_Pixmap *pixmap) { GP_Pixel white_pixel, black_pixel; - black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); - white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, context); + black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); + white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, pixmap); - GP_Fill(context, black_pixel); - GP_Line(context, 0, 0, context->w - 1, context->h - 1, white_pixel); - GP_Line(context, 0, context->h - 1, context->w - 1, 0, white_pixel); + GP_Fill(pixmap, black_pixel); + GP_Line(pixmap, 0, 0, pixmap->w - 1, pixmap->h - 1, white_pixel); + GP_Line(pixmap, 0, pixmap->h - 1, pixmap->w - 1, 0, white_pixel); } static int ev_loop(struct GP_Backend *backend, const char *name) @@ -68,7 +68,7 @@ static int ev_loop(struct GP_Backend *backend, const char *name) switch (ev.code) { case GP_EV_SYS_RESIZE: GP_BackendResizeAck(backend); - redraw(backend->context); + redraw(backend->pixmap); GP_BackendFlip(backend); break; case GP_EV_SYS_QUIT: @@ -99,8 +99,8 @@ int main(void) } /* Update the backend screen */ - redraw(win_1->context); - redraw(win_2->context); + redraw(win_1->pixmap); + redraw(win_2->pixmap); GP_BackendFlip(win_1); GP_BackendFlip(win_2); diff --git a/demos/c_simple/zip_container.c b/demos/c_simple/zip_container.c index 1fe5e36f..4cf77fd9 100644 --- a/demos/c_simple/zip_container.c +++ b/demos/c_simple/zip_container.c @@ -33,7 +33,7 @@ #include static GP_Backend *backend; -static GP_Context *image; +static GP_Pixmap *image; static GP_Container *container; /* @@ -45,20 +45,20 @@ static GP_Container *container; */ static void load_next(void) { - GP_ContextFree(image); + GP_PixmapFree(image); image = GP_ContainerLoadNext(container, NULL); if (image == NULL) return; - if (image->w != backend->context->w || - image->h != backend->context->h) { + if (image->w != backend->pixmap->w || + image->h != backend->pixmap->h) { GP_BackendResize(backend, image->w, image->h); return; } - GP_Blit_Clipped(image, 0, 0, image->w, image->h, backend->context, 0, 0); + GP_Blit_Clipped(image, 0, 0, image->w, image->h, backend->pixmap, 0, 0); GP_BackendFlip(backend); } @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) } /* Blit image into the window and show it */ - GP_Blit_Clipped(image, 0, 0, image->w, image->h, backend->context, 0, 0); + GP_Blit_Clipped(image, 0, 0, image->w, image->h, backend->pixmap, 0, 0); GP_BackendFlip(backend); /* Wait for events */ @@ -123,7 +123,7 @@ int main(int argc, char *argv[]) if (ev.code == GP_EV_SYS_RESIZE) { GP_BackendResizeAck(backend); GP_Blit_Clipped(image, 0, 0, image->w, image->h, - backend->context, 0, 0); + backend->pixmap, 0, 0); GP_BackendFlip(backend); } break; diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index 8c798d4c..fe40e252 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -106,7 +106,7 @@ static struct param resize_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int resize(GP_Context **c, const char *params) +static int resize(GP_Pixmap **c, const char *params) { int alg = 1; float ratio = -1; @@ -122,14 +122,14 @@ static int resize(GP_Context **c, const char *params) GP_Size w = ratio * (*c)->w; GP_Size h = ratio * (*c)->h; - GP_Context *res = NULL; + GP_Pixmap *res = NULL; res = GP_FilterResizeAlloc(*c, w, h, alg, progress_callback); if (res == NULL) return EINVAL; - GP_ContextFree(*c); + GP_PixmapFree(*c); *c = res; return 0; @@ -164,7 +164,7 @@ static struct param scale_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int scale(GP_Context **c, const char *params) +static int scale(GP_Pixmap **c, const char *params) { int alg = 1; int w = -1; @@ -185,14 +185,14 @@ static int scale(GP_Context **c, const char *params) if (h == -1) h = (*c)->h * (1.00 * w/(*c)->w) + 0.5; - GP_Context *res = NULL; + GP_Pixmap *res = NULL; res = GP_FilterResizeAlloc(*c, w, h, alg, progress_callback); if (res == NULL) return EINVAL; - GP_ContextFree(*c); + GP_PixmapFree(*c); *c = res; return 0; @@ -211,7 +211,7 @@ static struct param rotate_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int rotate(GP_Context **c, const char *params) +static int rotate(GP_Pixmap **c, const char *params) { int rot = -1; @@ -223,7 +223,7 @@ static int rotate(GP_Context **c, const char *params) return EINVAL; } - GP_Context *res = NULL; + GP_Pixmap *res = NULL; switch (rot) { case 0: @@ -240,7 +240,7 @@ static int rotate(GP_Context **c, const char *params) if (res == NULL) return ENOMEM; - GP_ContextFree(*c); + GP_PixmapFree(*c); *c = res; return 0; @@ -254,7 +254,7 @@ static struct param mirror_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int mirror(GP_Context **c, const char *params) +static int mirror(GP_Pixmap **c, const char *params) { int vert = 0, horiz = 0; @@ -277,7 +277,7 @@ static struct param bright_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int bright(GP_Context **c, const char *params) +static int bright(GP_Pixmap **c, const char *params) { float bright = 0; @@ -296,7 +296,7 @@ static struct param contrast_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int contrast(GP_Context **c, const char *params) +static int contrast(GP_Pixmap **c, const char *params) { float mul = 0; @@ -319,7 +319,7 @@ static struct param invert_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int invert(GP_Context **c, const char *params) +static int invert(GP_Pixmap **c, const char *params) { if (param_parse(params, invert_params, "invert", param_err)) return EINVAL; @@ -338,7 +338,7 @@ static struct param blur_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int blur(GP_Context **c, const char *params) +static int blur(GP_Pixmap **c, const char *params) { float sigma = 0; float sigma_x = 0; @@ -389,7 +389,7 @@ static struct param dither_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int dither(GP_Context **c, const char *params) +static int dither(GP_Pixmap **c, const char *params) { int fmt = -1; @@ -401,15 +401,15 @@ static int dither(GP_Context **c, const char *params) return EINVAL; } - GP_Context *bw; + GP_Pixmap *bw; bw = GP_FilterFloydSteinbergAlloc(*c, dither_pixel_types[fmt], progress_callback); - //TODO: so far we convert the context back to RGB888 + //TODO: so far we convert the pixmap back to RGB888 //(so we can do further work with it) - GP_Blit(bw, 0, 0, GP_ContextW(bw), GP_ContextH(bw), *c, 0, 0); + GP_Blit(bw, 0, 0, GP_PixmapW(bw), GP_PixmapH(bw), *c, 0, 0); - GP_ContextFree(bw); + GP_PixmapFree(bw); return 0; } @@ -421,7 +421,7 @@ static struct param save_jpg_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int save_jpg(GP_Context **c, const char *params) +static int save_jpg(GP_Pixmap **c, const char *params) { char *file = NULL; @@ -445,7 +445,7 @@ static struct param save_png_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int save_png(GP_Context **c, const char *params) +static int save_png(GP_Pixmap **c, const char *params) { char *file = NULL; @@ -471,7 +471,7 @@ static struct param median_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int median(GP_Context **c, const char *params) +static int median(GP_Pixmap **c, const char *params) { int rad = -1, rad_x, rad_y; @@ -486,12 +486,12 @@ static int median(GP_Context **c, const char *params) if (rad_x < 0 || rad_y < 0) return EINVAL; - GP_Context *ret = GP_FilterMedianAlloc(*c, rad_x, rad_y, progress_callback); + GP_Pixmap *ret = GP_FilterMedianAlloc(*c, rad_x, rad_y, progress_callback); if (ret == NULL) return ENOMEM; - GP_ContextFree(*c); + GP_PixmapFree(*c); *c = ret; return 0; @@ -508,7 +508,7 @@ static struct param sigma_mean_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int sigma_mean(GP_Context **c, const char *params) +static int sigma_mean(GP_Pixmap **c, const char *params) { int rad = -1, rad_x, rad_y, min = 0; float sigma = 0.1; @@ -527,12 +527,12 @@ static int sigma_mean(GP_Context **c, const char *params) (*c)->gamma = GP_GammaAcquire((*c)->pixel_type, 1.2); - GP_Context *ret = GP_FilterSigmaAlloc(*c, rad_x, rad_y, min, sigma, progress_callback); + GP_Pixmap *ret = GP_FilterSigmaAlloc(*c, rad_x, rad_y, min, sigma, progress_callback); if (ret == NULL) return ENOMEM; - GP_ContextFree(*c); + GP_PixmapFree(*c); *c = ret; return 0; @@ -545,19 +545,19 @@ static struct param sharpen_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int sharpen(GP_Context **c, const char *params) +static int sharpen(GP_Pixmap **c, const char *params) { float weight = 0.1; if (param_parse(params, sharpen_params, "sigma", param_err, &weight)) return EINVAL; - GP_Context *ret = GP_FilterEdgeSharpeningAlloc(*c, weight, progress_callback); + GP_Pixmap *ret = GP_FilterEdgeSharpeningAlloc(*c, weight, progress_callback); if (ret == NULL) return ENOMEM; - GP_ContextFree(*c); + GP_PixmapFree(*c); *c = ret; return 0; @@ -571,7 +571,7 @@ static struct param gauss_noise_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int gauss_noise(GP_Context **c, const char *params) +static int gauss_noise(GP_Pixmap **c, const char *params) { float sigma = 0.1; float mu = 0; @@ -601,7 +601,7 @@ static struct param arithmetic_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int arithmetic(GP_Context **c, const char *params) +static int arithmetic(GP_Pixmap **c, const char *params) { char *file = NULL; int op = -1; @@ -614,7 +614,7 @@ static int arithmetic(GP_Context **c, const char *params) return EINVAL; } - GP_Context *img, *res = NULL; + GP_Pixmap *img, *res = NULL; if ((img = GP_LoadImage(file, progress_callback)) == NULL) { print_error("arithmetic: Invalid image."); @@ -642,7 +642,7 @@ static int arithmetic(GP_Context **c, const char *params) if (res == NULL) return ENOMEM; - GP_ContextFree(*c); + GP_PixmapFree(*c); *c = res; @@ -656,7 +656,7 @@ static struct param histogram_params[] = { {NULL, 0, NULL, NULL, NULL} }; -static int histogram(GP_Context **c, const char *params) +static int histogram(GP_Pixmap **c, const char *params) { char *file = "histogram.png"; @@ -678,7 +678,7 @@ struct filter { const char *name; const char *desc; struct param *param_desc; - int (*apply)(GP_Context **c, const char *params); + int (*apply)(GP_Pixmap **c, const char *params); }; static struct filter filter_table[] = { @@ -763,7 +763,7 @@ static void add_filter(char *params) filter_params[filter_cnt++] = params; } -static void apply_filters(GP_Context **src) +static void apply_filters(GP_Pixmap **src) { unsigned int i; int ret; @@ -845,7 +845,7 @@ static void check_fmt(const char *fmt) exit(1); } -static void save_by_fmt(struct GP_Context *bitmap, const char *name, const char *fmt) +static void save_by_fmt(struct GP_Pixmap *bitmap, const char *name, const char *fmt) { int ret; @@ -874,7 +874,7 @@ static void save_by_fmt(struct GP_Context *bitmap, const char *name, const char int main(int argc, char *argv[]) { - GP_Context *bitmap; + GP_Pixmap *bitmap; int opt, i; const char *out_fmt = "ppm"; diff --git a/demos/grinder/histogram.c b/demos/grinder/histogram.c index 9706315b..d02f1751 100644 --- a/demos/grinder/histogram.c +++ b/demos/grinder/histogram.c @@ -22,7 +22,7 @@ #include "histogram.h" -void histogram_to_png(const GP_Context *src, const char *filename) +void histogram_to_png(const GP_Pixmap *src, const char *filename) { GP_Histogram *hist; @@ -36,7 +36,7 @@ void histogram_to_png(const GP_Context *src, const char *filename) unsigned int i, j; - GP_Context *res = GP_ContextAlloc(257*4, 256, GP_PIXEL_RGB888); + GP_Pixmap *res = GP_PixmapAlloc(257*4, 256, GP_PIXEL_RGB888); GP_Fill(res, 0xffffff); @@ -76,6 +76,6 @@ void histogram_to_png(const GP_Context *src, const char *filename) GP_SavePNG(res, filename, NULL); - GP_ContextFree(res); + GP_PixmapFree(res); GP_HistogramFree(hist); } diff --git a/demos/grinder/histogram.h b/demos/grinder/histogram.h index d6fdb4e5..e58dfd4c 100644 --- a/demos/grinder/histogram.h +++ b/demos/grinder/histogram.h @@ -25,6 +25,6 @@ #include -void histogram_to_png(const GP_Context *src, const char *filename); +void histogram_to_png(const GP_Pixmap *src, const char *filename); #endif /* HISTOGRAM_H */ diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c index 46fafe29..e4226c27 100644 --- a/demos/particle/particle_demo.c +++ b/demos/particle/particle_demo.c @@ -37,7 +37,7 @@ static GP_Pixel black_pixel; static GP_Pixel white_pixel; static GP_Backend *backend = NULL; -static GP_Context *context = NULL; +static GP_Pixmap *pixmap = NULL; static void sighandler(int signo) { @@ -88,16 +88,16 @@ int main(int argc, char *argv[]) init_backend(backend_opts); - context = backend->context; + pixmap = backend->pixmap; - black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); - white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, context); + black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); + white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, pixmap); - GP_Fill(context, black_pixel); + GP_Fill(pixmap, black_pixel); GP_BackendFlip(backend); struct space *space; - space = space_create(particles, 10<<8, 10<<8, (context->w - 10)<<8, (context->h - 10)<<8); + space = space_create(particles, 10<<8, 10<<8, (pixmap->w - 10)<<8, (pixmap->h - 10)<<8); for (;;) { if (backend->Poll) @@ -146,8 +146,8 @@ int main(int argc, char *argv[]) space_destroy(space); space = space_create(particles, 10<<8, 10<<8, - (context->w - 10)<<8, - (context->h - 10)<<8); + (pixmap->w - 10)<<8, + (pixmap->h - 10)<<8); break; } break; @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) if (!pause_flag) { space_time_tick(space, 1); - space_draw_particles(context, space); + space_draw_particles(pixmap, space); GP_BackendFlip(backend); } } diff --git a/demos/particle/space.c b/demos/particle/space.c index c53b9e31..8dfc956d 100644 --- a/demos/particle/space.c +++ b/demos/particle/space.c @@ -67,11 +67,11 @@ void space_destroy(struct space *space) #define SQUARE(x) ((x) * (x)) -void space_draw_particles(GP_Context *context, struct space *space) +void space_draw_particles(GP_Pixmap *pixmap, struct space *space) { unsigned int i; - GP_Fill(context, 0x000000); + GP_Fill(pixmap, 0x000000); for (i = 0; i < space->particle_count; i++) { GP_Pixel color; @@ -88,9 +88,9 @@ void space_draw_particles(GP_Context *context, struct space *space) } */ - color = GP_RGBToContextPixel(0xee, 0xee, 0xee, context); + color = GP_RGBToPixmapPixel(0xee, 0xee, 0xee, pixmap); - GP_PutPixelAA(context, x, y, color); + GP_PutPixelAA(pixmap, x, y, color); int val = SQUARE(space->particles[i].vx) + SQUARE(space->particles[i].vy); @@ -99,29 +99,29 @@ void space_draw_particles(GP_Context *context, struct space *space) if (val > 255) val = 255; - color = GP_RGBToContextPixel(val, val, 0x40, context); + color = GP_RGBToPixmapPixel(val, val, 0x40, pixmap); /* Hexagons */ - GP_LineAA(context, x - a2, y - a1, x + a2, y - a1, color); - // GP_LineAA(context, x + a2, y - a1, x + a1, y - a2, color); - GP_LineAA(context, x + a1, y - a2, x + a1, y + a2, color); - // GP_LineAA(context, x + a1, y + a2, x + a2, y + a1, color); - GP_LineAA(context, x + a2, y + a1, x - a2, y + a1, color); - // GP_LineAA(context, x - a2, y + a1, x - a1, y + a2, color); - GP_LineAA(context, x - a1, y + a2, x - a1, y - a2, color); - // GP_LineAA(context, x - a1, y - a2, x - a2, y - a1, color); + GP_LineAA(pixmap, x - a2, y - a1, x + a2, y - a1, color); + // GP_LineAA(pixmap, x + a2, y - a1, x + a1, y - a2, color); + GP_LineAA(pixmap, x + a1, y - a2, x + a1, y + a2, color); + // GP_LineAA(pixmap, x + a1, y + a2, x + a2, y + a1, color); + GP_LineAA(pixmap, x + a2, y + a1, x - a2, y + a1, color); + // GP_LineAA(pixmap, x - a2, y + a1, x - a1, y + a2, color); + GP_LineAA(pixmap, x - a1, y + a2, x - a1, y - a2, color); + // GP_LineAA(pixmap, x - a1, y - a2, x - a2, y - a1, color); /* - GP_PutPixelAA(context, x + a2, y - a1, 0xffffff); - GP_PutPixelAA(context, x + a1, y - a2, 0xffffff); + GP_PutPixelAA(pixmap, x + a2, y - a1, 0xffffff); + GP_PutPixelAA(pixmap, x + a1, y - a2, 0xffffff); - GP_PutPixelAA(context, x + a1, y + a2, 0xffffff); - GP_PutPixelAA(context, x + a2, y + a1, 0xffffff); + GP_PutPixelAA(pixmap, x + a1, y + a2, 0xffffff); + GP_PutPixelAA(pixmap, x + a2, y + a1, 0xffffff); - GP_PutPixelAA(context, x - a2, y + a1, 0xffffff); - GP_PutPixelAA(context, x - a1, y + a2, 0xffffff); + GP_PutPixelAA(pixmap, x - a2, y + a1, 0xffffff); + GP_PutPixelAA(pixmap, x - a1, y + a2, 0xffffff); - GP_PutPixelAA(context, x - a1, y - a2, 0xffffff); - GP_PutPixelAA(context, x - a2, y - a1, 0xffffff); + GP_PutPixelAA(pixmap, x - a1, y - a2, 0xffffff); + GP_PutPixelAA(pixmap, x - a2, y - a1, 0xffffff); */ } } diff --git a/demos/particle/space.h b/demos/particle/space.h index 7878b11c..021d615b 100644 --- a/demos/particle/space.h +++ b/demos/particle/space.h @@ -69,7 +69,7 @@ struct space *space_create(unsigned int particle_count, int min_w, int min_h, void space_destroy(struct space *space); -void space_draw_particles(GP_Context *context, struct space *space); +void space_draw_particles(GP_Pixmap *pixmap, struct space *space); void space_time_tick(struct space *space, int time); diff --git a/demos/py_simple/backends.py b/demos/py_simple/backends.py index 31fb59d1..84715526 100755 --- a/demos/py_simple/backends.py +++ b/demos/py_simple/backends.py @@ -9,7 +9,7 @@ import gfxprim.text as text import gfxprim.input as input def redraw(bk): - c = bk.context + c = bk.pixmap black = c.RGBToPixel(0, 0, 0) white = c.RGBToPixel(0xff, 0xff, 0xff) diff --git a/demos/py_simple/blit.py b/demos/py_simple/blit.py index 2b3a6943..e76b8c08 100755 --- a/demos/py_simple/blit.py +++ b/demos/py_simple/blit.py @@ -21,13 +21,13 @@ class Ball: self.bg_img = bg_img def draw(self, bk): - self.ball.Blit(0, 0, bk.context, self.x, self.y, self.ball.w, self.ball.h) + self.ball.Blit(0, 0, bk.pixmap, self.x, self.y, self.ball.w, self.ball.h) def move(self, bk): old_x = self.x; old_y = self.y; - self.bg_img.Blit(old_x, old_y, bk.context, old_x, old_y, self.ball.w, self.ball.h) + self.bg_img.Blit(old_x, old_y, bk.pixmap, old_x, old_y, self.ball.w, self.ball.h) self.x += self.dx self.y += self.dy @@ -38,7 +38,7 @@ class Ball: if (self.y <= 0 or self.y >= self.bg_img.h - self.ball.h): self.dy = -self.dy - self.ball.Blit(0, 0, bk.context, self.x, self.y, self.ball.w, self.ball.h) + self.ball.Blit(0, 0, bk.pixmap, self.x, self.y, self.ball.w, self.ball.h) bk.UpdateRect(min(old_x, self.x), min(self.y, old_y), max(old_x, self.x) + self.ball.w - 1, max(old_y, self.y) + self.ball.h - 1) @@ -59,7 +59,7 @@ def main(): # Create X11 window bk = backends.BackendX11Init(None, 0, 0, bg.w, bg.h, sys.argv[1], 0) assert(bk) - bg.Blit(0, 0, bk.context, 0, 0, bg.w, bg.h) + bg.Blit(0, 0, bk.pixmap, 0, 0, bg.w, bg.h) bk.Flip() diff --git a/demos/py_simple/cam_view.py b/demos/py_simple/cam_view.py index 6692abb9..dd7bcc88 100755 --- a/demos/py_simple/cam_view.py +++ b/demos/py_simple/cam_view.py @@ -25,7 +25,7 @@ def main(): sleep(0.01) if (grabber.Poll()): - grabber.frame.Blit(0, 0, bk.context, 0, 0, grabber.frame.w, grabber.frame.h) + grabber.frame.Blit(0, 0, bk.pixmap, 0, 0, grabber.frame.w, grabber.frame.h) bk.Flip() ev = bk.PollEvent() diff --git a/demos/py_simple/font_style.py b/demos/py_simple/font_style.py index 47d8e2cb..1799253d 100755 --- a/demos/py_simple/font_style.py +++ b/demos/py_simple/font_style.py @@ -9,7 +9,7 @@ import gfxprim.input as input import gfxprim.text as text def redraw(win): - c = win.context + c = win.pixmap black = c.RGBToPixel(0, 0, 0) white = c.RGBToPixel(0xff, 0xff, 0xff) diff --git a/demos/py_simple/gfx.py b/demos/py_simple/gfx.py index c79d879e..0ee8dbe6 100755 --- a/demos/py_simple/gfx.py +++ b/demos/py_simple/gfx.py @@ -8,88 +8,88 @@ import gfxprim.backends as backends import gfxprim.input as input def fill(bk): - color = bk.context.RGBToPixel(0xee, 0xee, 0xee) - bk.context.gfx.Fill(color) + color = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) + bk.pixmap.gfx.Fill(color) bk.Flip() def hline(bk): - fg = bk.context.RGBToPixel(0xee, 0xee, 0xee) - bg = bk.context.RGBToPixel(0, 0, 0); + fg = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) + bg = bk.pixmap.RGBToPixel(0, 0, 0); - bk.context.gfx.Fill(bg) - for i in range(0, bk.context.h, 10): - bk.context.gfx.HLine(0, bk.context.w, i, fg) + bk.pixmap.gfx.Fill(bg) + for i in range(0, bk.pixmap.h, 10): + bk.pixmap.gfx.HLine(0, bk.pixmap.w, i, fg) bk.Flip() def vline(bk): - fg = bk.context.RGBToPixel(0xee, 0xee, 0xee) - bg = bk.context.RGBToPixel(0, 0, 0); + fg = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) + bg = bk.pixmap.RGBToPixel(0, 0, 0); - bk.context.gfx.Fill(bg) + bk.pixmap.gfx.Fill(bg) - for i in range(0, bk.context.w, 10): - bk.context.gfx.VLine(i, 0, bk.context.h, fg) + for i in range(0, bk.pixmap.w, 10): + bk.pixmap.gfx.VLine(i, 0, bk.pixmap.h, fg) bk.Flip() def line(bk): - fg = bk.context.RGBToPixel(0xee, 0xee, 0xee) - bg = bk.context.RGBToPixel(0, 0, 0); + fg = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) + bg = bk.pixmap.RGBToPixel(0, 0, 0); - bk.context.gfx.Fill(bg) + bk.pixmap.gfx.Fill(bg) - for i in range(0, 2 * max(bk.context.w, bk.context.h), 13): - bk.context.gfx.Line(0, i, i, 0, fg) + for i in range(0, 2 * max(bk.pixmap.w, bk.pixmap.h), 13): + bk.pixmap.gfx.Line(0, i, i, 0, fg) bk.Flip() def rect(bk): - fg = bk.context.RGBToPixel(0xee, 0xee, 0xee) - bg = bk.context.RGBToPixel(0, 0, 0); + fg = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) + bg = bk.pixmap.RGBToPixel(0, 0, 0); - bk.context.gfx.Fill(bg) + bk.pixmap.gfx.Fill(bg) for i in range(10, 130, 10): - bk.context.gfx.Rect(i, i, bk.context.w - i, bk.context.h - i, fg) + bk.pixmap.gfx.Rect(i, i, bk.pixmap.w - i, bk.pixmap.h - i, fg) bk.Flip() def triangle(bk): - fg = bk.context.RGBToPixel(0xee, 0xee, 0xee) - bg = bk.context.RGBToPixel(0, 0, 0); + fg = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) + bg = bk.pixmap.RGBToPixel(0, 0, 0); - bk.context.gfx.Fill(bg) + bk.pixmap.gfx.Fill(bg) - w = bk.context.w - h = bk.context.h + w = bk.pixmap.w + h = bk.pixmap.h for i in range(10, 90, 10): - bk.context.gfx.Triangle(2*i, i, w - 2*i, i, w//2, h - 2*i, fg) + bk.pixmap.gfx.Triangle(2*i, i, w - 2*i, i, w//2, h - 2*i, fg) bk.Flip() def tetragon(bk): - fg = bk.context.RGBToPixel(0xee, 0xee, 0xee) - bg = bk.context.RGBToPixel(0, 0, 0); + fg = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) + bg = bk.pixmap.RGBToPixel(0, 0, 0); - bk.context.gfx.Fill(bg) + bk.pixmap.gfx.Fill(bg) - w = bk.context.w - h = bk.context.h + w = bk.pixmap.w + h = bk.pixmap.h for i in range(10, 70, 10): - bk.context.gfx.Tetragon(i, i, w-2*i, i, w-i, h-i, 2*i, h-i, fg) + bk.pixmap.gfx.Tetragon(i, i, w-2*i, i, w-i, h-i, 2*i, h-i, fg) bk.Flip() def polygon(bk): - fg = bk.context.RGBToPixel(0xee, 0xee, 0xee) - bg = bk.context.RGBToPixel(0, 0, 0); + fg = bk.pixmap.RGBToPixel(0xee, 0xee, 0xee) + bg = bk.pixmap.RGBToPixel(0, 0, 0); - bk.context.gfx.Fill(bg) + bk.pixmap.gfx.Fill(bg) - w = bk.context.w - h = bk.context.h + w = bk.pixmap.w + h = bk.pixmap.h polygon = [(10, 10), (10, (h-10)//3), ((w-10)//3, (h-10)//2), (10, 2*(h-10)//3), (10, h-10), ((w-10)//3, h-10), @@ -98,7 +98,7 @@ def polygon(bk): (w-10, (h-10)//3), (w-10, 10), (2*(w-10)//3, 10), ((w-10)//2, (h-10)//3), ((w-10)//3, 10)] - bk.context.gfx.Polygon(polygon, fg) + bk.pixmap.gfx.Polygon(polygon, fg) bk.Flip() diff --git a/demos/py_simple/gravplots_AA.py b/demos/py_simple/gravplots_AA.py index 74777440..5de7bcc6 100755 --- a/demos/py_simple/gravplots_AA.py +++ b/demos/py_simple/gravplots_AA.py @@ -72,7 +72,7 @@ def main(): print(bk) print("Modify source for parameters,") print("Kill to terminate ;-)") - black = bk.context.RGBToPixel(0, 0, 0) + black = bk.pixmap.RGBToPixel(0, 0, 0) es = [elem() for i in range(N)] while True: @@ -86,18 +86,18 @@ def main(): x = int((e.x % W) * 0x100) y = int(e.y * 0x100) if e.vx > 0.2: - bk.context.gfx.VLineAA(x + 0x100, y - 0x300, y + 0x300, black) + bk.pixmap.gfx.VLineAA(x + 0x100, y - 0x300, y + 0x300, black) if e.vx < -0.2: - bk.context.gfx.VLineAA(x - 0x100, y - 0x300, y + 0x300, black) - bk.context.gfx.PutPixelAA(x, y, bk.context.RGBToPixel(e.r, e.g, e.b)) + bk.pixmap.gfx.VLineAA(x - 0x100, y - 0x300, y + 0x300, black) + bk.pixmap.gfx.PutPixelAA(x, y, bk.pixmap.RGBToPixel(e.r, e.g, e.b)) else: x = int(e.x % W) y = int(e.y) if e.vx > 0.2: - bk.context.gfx.VLine(x + 1, y - 2, y + 2, black) + bk.pixmap.gfx.VLine(x + 1, y - 2, y + 2, black) if e.vx < -0.2: - bk.context.gfx.VLine(x - 1, y - 2, y + 2, black) - bk.context.core.PutPixel(x, y, bk.context.RGBToPixel(e.r, e.g, e.b)) + bk.pixmap.gfx.VLine(x - 1, y - 2, y + 2, black) + bk.pixmap.core.PutPixel(x, y, bk.pixmap.RGBToPixel(e.r, e.g, e.b)) bk.Poll() bk.Flip() global TIMEOUT @@ -106,7 +106,7 @@ def main(): if TIMEOUT == 0: break if SAVETO: - bk.context.Save(SAVETO) + bk.pixmap.Save(SAVETO) if __name__ == '__main__': main() diff --git a/demos/py_simple/showimage.py b/demos/py_simple/showimage.py index 6c5e97c5..07c54b41 100755 --- a/demos/py_simple/showimage.py +++ b/demos/py_simple/showimage.py @@ -18,7 +18,7 @@ def main(): # Create X11 window bk = backends.BackendX11Init(None, 0, 0, img.w, img.h, sys.argv[1], 0) assert(bk) - img.Blit(0, 0, bk.context, 0, 0, img.w, img.h) + img.Blit(0, 0, bk.pixmap, 0, 0, img.w, img.h) bk.Flip() # Event loop diff --git a/demos/py_simple/sinplots_AA.py b/demos/py_simple/sinplots_AA.py index e0933b56..44afd21e 100755 --- a/demos/py_simple/sinplots_AA.py +++ b/demos/py_simple/sinplots_AA.py @@ -34,7 +34,7 @@ def main(): print(bk) print("Modify source for parameters,") print("Kill to terminate ;-)") - black = bk.context.RGBToPixel(0, 0, 0) + black = bk.pixmap.RGBToPixel(0, 0, 0) ps = [plotter() for i in range(N)] t = random.uniform(0.0, 10.0 * W) @@ -46,13 +46,13 @@ def main(): if AA: x = int(x * 0x100) y = int(y * 0x100) - bk.context.gfx.VLineAA(x + 0x100, y - 0x200, y + 0x200, black) - bk.context.gfx.PutPixelAA(x, y, bk.context.RGBToPixel(int(r), int(g), int(b))) + bk.pixmap.gfx.VLineAA(x + 0x100, y - 0x200, y + 0x200, black) + bk.pixmap.gfx.PutPixelAA(x, y, bk.pixmap.RGBToPixel(int(r), int(g), int(b))) else: x = int(x) y = int(y) - bk.context.gfx.VLine(x + 1, y - 2, y + 2, black) - bk.context.core.PutPixel(x, y, bk.context.RGBToPixel(int(r), int(g), int(b))) + bk.pixmap.gfx.VLine(x + 1, y - 2, y + 2, black) + bk.pixmap.core.PutPixel(x, y, bk.pixmap.RGBToPixel(int(r), int(g), int(b))) bk.Flip() if __name__ == '__main__': diff --git a/demos/py_simple/x11_windows.py b/demos/py_simple/x11_windows.py index 133be6e5..3c34ff7a 100755 --- a/demos/py_simple/x11_windows.py +++ b/demos/py_simple/x11_windows.py @@ -9,7 +9,7 @@ import gfxprim.input as input import gfxprim.text as text def redraw(bk, id): - c = bk.context + c = bk.pixmap black = c.RGBToPixel(0, 0, 0) white = c.RGBToPixel(0xff, 0xff, 0xff) diff --git a/demos/spiv/image_cache.c b/demos/spiv/image_cache.c index 5f270a8a..28ea5bbb 100644 --- a/demos/spiv/image_cache.c +++ b/demos/spiv/image_cache.c @@ -26,7 +26,7 @@ #include "image_cache.h" struct image { - GP_Context *ctx; + GP_Pixmap *pixmap; GP_DataStorage *meta_data; struct image *prev; @@ -73,23 +73,23 @@ size_t image_cache_get_ram_size(void) /* * Reports correct image record size. */ -static size_t image_size2(GP_Context *ctx, GP_DataStorage *meta_data, +static size_t image_size2(GP_Pixmap *pixmap, GP_DataStorage *meta_data, const char *path) { size_t meta_data_size = 0; - size_t context_size = ctx->bytes_per_row * ctx->h + sizeof(GP_Context); + size_t pixmap_size = pixmap->bytes_per_row * pixmap->h + sizeof(GP_Pixmap); //TODO! 4096 is a size of single block, data storage may have more blocks if (meta_data) meta_data_size = 4096; - return meta_data_size + context_size + + return meta_data_size + pixmap_size + sizeof(struct image) + strlen(path) + 1; } static size_t image_size(struct image *img) { - return image_size2(img->ctx, NULL, img->path); + return image_size2(img->pixmap, NULL, img->path); } struct image_cache *image_cache_create(unsigned int max_size_kbytes) @@ -135,7 +135,7 @@ static void remove_img_free(struct image_cache *self, GP_DEBUG(2, "Freeing image '%s' size %zu", img->path, size); remove_img(self, img, size); - GP_ContextFree(img->ctx); + GP_PixmapFree(img->pixmap); GP_DataStorageDestroy(img->meta_data); free(img); } @@ -159,7 +159,7 @@ static void add_img(struct image_cache *self, struct image *img, size_t size) self->end = img; } -int image_cache_get(struct image_cache *self, GP_Context **img, +int image_cache_get(struct image_cache *self, GP_Pixmap **img, GP_DataStorage **meta_data, int elevate, const char *key) { struct image *i; @@ -189,7 +189,7 @@ int image_cache_get(struct image_cache *self, GP_Context **img, } if (img) - *img = i->ctx; + *img = i->pixmap; if (meta_data) *meta_data = i->meta_data; @@ -197,7 +197,7 @@ int image_cache_get(struct image_cache *self, GP_Context **img, return 0; } -GP_Context *image_cache_get2(struct image_cache *self, int elevate, +GP_Pixmap *image_cache_get2(struct image_cache *self, int elevate, const char *fmt, ...) { va_list va; @@ -246,7 +246,7 @@ GP_Context *image_cache_get2(struct image_cache *self, int elevate, if (len >= sizeof(buf)) free(key); - return i ? i->ctx : NULL; + return i ? i->pixmap : NULL; } void image_cache_print(struct image_cache *self) @@ -283,7 +283,7 @@ static int assert_size(struct image_cache *self, size_t size) return 0; } -int image_cache_put(struct image_cache *self, GP_Context *ctx, +int image_cache_put(struct image_cache *self, GP_Pixmap *pixmap, GP_DataStorage *meta_data, const char *key) { size_t size; @@ -291,7 +291,7 @@ int image_cache_put(struct image_cache *self, GP_Context *ctx, if (self == NULL) return 1; - size = image_size2(ctx, meta_data, key); + size = image_size2(pixmap, meta_data, key); /* * We try to create room for the image. If this fails we add the image @@ -307,7 +307,7 @@ int image_cache_put(struct image_cache *self, GP_Context *ctx, return 1; } - img->ctx = ctx; + img->pixmap = pixmap; img->meta_data = meta_data; img->elevated = 0; strcpy(img->path, key); @@ -319,7 +319,7 @@ int image_cache_put(struct image_cache *self, GP_Context *ctx, return 0; } -int image_cache_put2(struct image_cache *self, GP_Context *ctx, +int image_cache_put2(struct image_cache *self, GP_Pixmap *pixmap, GP_DataStorage *meta_data, const char *fmt, ...) { size_t size, len; @@ -333,7 +333,7 @@ int image_cache_put2(struct image_cache *self, GP_Context *ctx, va_end(va); //TODO: FIX THIS - size = image_size2(ctx, meta_data, "") + len + 1; + size = image_size2(pixmap, meta_data, "") + len + 1; /* * We try to create room for the image. If this fails we add the image @@ -349,7 +349,7 @@ int image_cache_put2(struct image_cache *self, GP_Context *ctx, return 1; } - img->ctx = ctx; + img->pixmap = pixmap; img->meta_data = meta_data; img->elevated = 0; diff --git a/demos/spiv/image_cache.h b/demos/spiv/image_cache.h index f2ea1fa1..5aa40021 100644 --- a/demos/spiv/image_cache.h +++ b/demos/spiv/image_cache.h @@ -47,20 +47,20 @@ struct image_cache *image_cache_create(unsigned int max_size_kbytes); * If elevate set and image is found, the image is elevated to the top so * it has lesser chance of being freed. */ -int image_cache_get(struct image_cache *self, GP_Context **img, +int image_cache_get(struct image_cache *self, GP_Pixmap **img, GP_DataStorage **meta_data, int elevate, const char *key); -GP_Context *image_cache_get2(struct image_cache *self, int elevate, +GP_Pixmap *image_cache_get2(struct image_cache *self, int elevate, const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); /* * Puts an image into a cache. */ -int image_cache_put(struct image_cache *self, GP_Context *img, +int image_cache_put(struct image_cache *self, GP_Pixmap *img, GP_DataStorage *meta_data, const char *key); -int image_cache_put2(struct image_cache *self, GP_Context *img, +int image_cache_put2(struct image_cache *self, GP_Pixmap *img, GP_DataStorage *meta_data, const char *fmt, ...) __attribute__ ((format (printf, 4, 5))); diff --git a/demos/spiv/image_loader.c b/demos/spiv/image_loader.c index c7e0f9ba..8f86f92f 100644 --- a/demos/spiv/image_loader.c +++ b/demos/spiv/image_loader.c @@ -22,7 +22,7 @@ #include -#include +#include #include #include @@ -34,7 +34,7 @@ static struct image_cache *img_cache; static struct image_list *img_list; -static GP_Context *cur_img; +static GP_Pixmap *cur_img; static GP_DataStorage *cur_meta_data; static GP_Container *cur_cont; @@ -57,11 +57,11 @@ int image_loader_init(const char *args[], unsigned int cache_max_bytes) return 0; } -GP_Context *image_loader_get_image(GP_ProgressCallback *callback, int elevate) +GP_Pixmap *image_loader_get_image(GP_ProgressCallback *callback, int elevate) { struct cpu_timer timer; const char *path; - GP_Context *img; + GP_Pixmap *img; int err, ret; if (cur_img) @@ -154,7 +154,7 @@ static void drop_cur_img(void) * Currently loaded image is too big to be cached -> free it. */ if (image_cache_get(img_cache, NULL, NULL, 0, path)) { - GP_ContextFree(cur_img); + GP_PixmapFree(cur_img); GP_DataStorageDestroy(cur_meta_data); } diff --git a/demos/spiv/image_loader.h b/demos/spiv/image_loader.h index 9992bca7..5d2223ee 100644 --- a/demos/spiv/image_loader.h +++ b/demos/spiv/image_loader.h @@ -31,7 +31,7 @@ #ifndef __IMAGE_LOADER_H__ #define __IMAGE_LOADER_H__ -#include +#include #include /* @@ -46,7 +46,7 @@ int image_loader_init(const char *args[], unsigned int cache_max_bytes); * * Note that the callback may not be called when the image is cached. */ -GP_Context *image_loader_get_image(GP_ProgressCallback *callback, int elevate); +GP_Pixmap *image_loader_get_image(GP_ProgressCallback *callback, int elevate); /* * Retruns current image meta data or NULL there are none. diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index 91b1a2a3..947390c9 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -81,7 +81,7 @@ struct loader_params { static int image_loader_callback(GP_ProgressCallback *self) { static GP_Size size = 0; - GP_Context *c = backend->context; + GP_Pixmap *c = backend->pixmap; if (abort_flag) return 1; @@ -114,7 +114,7 @@ static int image_loader_callback(GP_ProgressCallback *self) return 0; } -static GP_Context *load_image(int elevate); +static GP_Pixmap *load_image(int elevate); static const char *img_name(const char *img_path) { @@ -140,9 +140,9 @@ static void set_caption(const char *path, float rat) /* * Loads image */ -static GP_Context *load_image(int elevate) +static GP_Pixmap *load_image(int elevate) { - GP_Context *img; + GP_Pixmap *img; GP_ProgressCallback callback = {.callback = image_loader_callback, .priv = "Loading image"}; @@ -151,13 +151,13 @@ static GP_Context *load_image(int elevate) if (img) return img; - GP_Context *ctx = backend->context; + GP_Pixmap *pixmap = backend->pixmap; - GP_Fill(ctx, black_pixel); - GP_Print(ctx, config.style, ctx->w/2, ctx->h/2 - 10, + GP_Fill(pixmap, black_pixel); + GP_Print(pixmap, config.style, pixmap->w/2, pixmap->h/2 - 10, GP_ALIGN_CENTER|GP_VALIGN_CENTER, white_pixel, black_pixel, "'%s'", image_loader_img_path()); - GP_Print(ctx, config.style, ctx->w/2, ctx->h/2 + 10, + GP_Print(pixmap, config.style, pixmap->w/2, pixmap->h/2 + 10, GP_ALIGN_CENTER|GP_VALIGN_CENTER, white_pixel, black_pixel, "Failed to load image :( (%s)", strerror(errno)); GP_BackendFlip(backend); @@ -166,16 +166,16 @@ static GP_Context *load_image(int elevate) } /* - * Fill context with chessboard-like pattern. + * Fill pixmap with chessboard-like pattern. */ -static void pattern_fill(GP_Context *ctx, unsigned int x0, unsigned int y0, +static void pattern_fill(GP_Pixmap *pixmap, unsigned int x0, unsigned int y0, unsigned int w, unsigned int h) { unsigned int x, y, i, j = 0; GP_Pixel col[2]; - col[0] = GP_RGBToContextPixel(0x64, 0x64, 0x64, ctx); - col[1] = GP_RGBToContextPixel(0x80, 0x80, 0x80, ctx); + col[0] = GP_RGBToPixmapPixel(0x64, 0x64, 0x64, pixmap); + col[1] = GP_RGBToPixmapPixel(0x80, 0x80, 0x80, pixmap); unsigned int wm = w/20 < 5 ? 5 : w/20; unsigned int hm = h/20 < 5 ? 5 : h/20; @@ -184,18 +184,18 @@ static void pattern_fill(GP_Context *ctx, unsigned int x0, unsigned int y0, i = j; j = !j; for (x = 0; x < w; x += wm) { - GP_FillRectXYWH(ctx, x0 + x, y0 + y, wm, hm, col[i]); + GP_FillRectXYWH(pixmap, x0 + x, y0 + y, wm, hm, col[i]); i = !i; } } } -static void info_printf(GP_Context *ctx, GP_Coord x, GP_Coord y, +static void info_printf(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, const char *fmt, ...) __attribute__ ((format (printf, 4, 5))); -static void info_printf(GP_Context *ctx, GP_Coord x, GP_Coord y, +static void info_printf(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, const char *fmt, ...) { va_list va, vac; @@ -203,17 +203,17 @@ static void info_printf(GP_Context *ctx, GP_Coord x, GP_Coord y, va_start(va, fmt); va_copy(vac, va); - GP_VPrint(ctx, config.style, x-1, y-1, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM|GP_TEXT_NOBG, + GP_VPrint(pixmap, config.style, x-1, y-1, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM|GP_TEXT_NOBG, black_pixel, white_pixel, fmt, vac); va_end(vac); - GP_VPrint(ctx, config.style, x, y, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM|GP_TEXT_NOBG, + GP_VPrint(pixmap, config.style, x, y, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM|GP_TEXT_NOBG, white_pixel, black_pixel, fmt, va); va_end(va); } -static unsigned int print_meta_data(GP_DataNode *node, GP_Context *context, +static unsigned int print_meta_data(GP_DataNode *node, GP_Pixmap *pixmap, unsigned int th, unsigned int y, int level) { GP_DataNode *i; @@ -224,21 +224,21 @@ static unsigned int print_meta_data(GP_DataNode *node, GP_Context *context, x = th * level + 10; switch (i->type) { case GP_DATA_INT: - info_printf(context, x, y, "%s : %li", i->id, i->value.i); + info_printf(pixmap, x, y, "%s : %li", i->id, i->value.i); break; case GP_DATA_DOUBLE: - info_printf(context, x, y, "%s : %lf", i->id, i->value.d); + info_printf(pixmap, x, y, "%s : %lf", i->id, i->value.d); break; case GP_DATA_STRING: - info_printf(context, x, y, "%s : %s", i->id, i->value.str); + info_printf(pixmap, x, y, "%s : %s", i->id, i->value.str); break; case GP_DATA_RATIONAL: - info_printf(context, x, y, "%s : %li/%li", + info_printf(pixmap, x, y, "%s : %li/%li", i->id, i->value.rat.num, i->value.rat.den); break; case GP_DATA_DICT: - info_printf(context, x, y, "%s", i->id); - y = print_meta_data(i, context, th, y, level+1); + info_printf(pixmap, x, y, "%s", i->id); + y = print_meta_data(i, pixmap, th, y, level+1); break; } } @@ -246,10 +246,10 @@ static unsigned int print_meta_data(GP_DataNode *node, GP_Context *context, return y; } -static void show_info(struct loader_params *params, GP_Context *img, - GP_Context *orig_img) +static void show_info(struct loader_params *params, GP_Pixmap *img, + GP_Pixmap *orig_img) { - GP_Context *context = backend->context; + GP_Pixmap *pixmap = backend->pixmap; const char *img_path = image_loader_img_path(); set_caption(img_path, params->zoom_rat); @@ -259,17 +259,17 @@ static void show_info(struct loader_params *params, GP_Context *img, GP_Size th = GP_TextHeight(config.style), y = 10; - info_printf(context, 10, y, "%ux%u (%ux%u) 1:%3.3f %3.1f%% %s", + info_printf(pixmap, 10, y, "%ux%u (%ux%u) 1:%3.3f %3.1f%% %s", img->w, img->h, orig_img->w, orig_img->h, params->zoom_rat, params->zoom_rat * 100, GP_PixelTypeName(img->pixel_type)); y += th + 2; - info_printf(context, 10, y, "%s", img_name(img_path)); + info_printf(pixmap, 10, y, "%s", img_name(img_path)); y += th + 2; if (params->zoom_rat != 1.00) { - info_printf(context, 10, y, "%s%s", + info_printf(pixmap, 10, y, "%s%s", params->use_low_pass && params->zoom_rat < 1 ? "Gaussian LP + " : "", GP_InterpolationTypeName(params->resampling_method)); y += th + 2; @@ -278,14 +278,14 @@ static void show_info(struct loader_params *params, GP_Context *img, unsigned int count = image_loader_count(); unsigned int pos = image_loader_pos() + 1; - info_printf(context, 10, y, "%u of %u", pos, count); + info_printf(pixmap, 10, y, "%u of %u", pos, count); y += th + 2; if (image_loader_is_in_dir()) { unsigned int dir_count = image_loader_dir_count(); unsigned int dir_pos = image_loader_dir_pos() + 1; - info_printf(context, 10, y, + info_printf(pixmap, 10, y, "%u of %u in directory", dir_pos, dir_count); } @@ -299,13 +299,13 @@ static void show_info(struct loader_params *params, GP_Context *img, if (node->type != GP_DATA_DICT) return; - print_meta_data(node, context, th + 2, y + th, 0); + print_meta_data(node, pixmap, th + 2, y + th, 0); } -static void update_display(struct loader_params *params, GP_Context *img, - GP_Context *orig_img) +static void update_display(struct loader_params *params, GP_Pixmap *img, + GP_Pixmap *orig_img) { - GP_Context *context = backend->context; + GP_Pixmap *pixmap = backend->pixmap; struct cpu_timer timer; GP_ProgressCallback callback = {.callback = image_loader_callback}; @@ -340,11 +340,11 @@ static void update_display(struct loader_params *params, GP_Context *img, */ if (config.win_strategy == ZOOM_WIN_FIXED) { - if (img->w < context->w) - cx = (context->w - img->w)/2; + if (img->w < pixmap->w) + cx = (pixmap->w - img->w)/2; - if (img->h < context->h) - cy = (context->h - img->h)/2; + if (img->h < pixmap->h) + cy = (pixmap->h - img->h)/2; } if (params->zoom_manual) { @@ -352,49 +352,49 @@ static void update_display(struct loader_params *params, GP_Context *img, cy = params->zoom_y_offset; } - GP_Context sub_display; + GP_Pixmap sub_display; cpu_timer_start(&timer, "Blitting"); if (config.floyd_steinberg) { callback.priv = "Dithering"; - GP_SubContext(context, &sub_display, cx, cy, img->w, img->h); + GP_SubPixmap(pixmap, &sub_display, cx, cy, img->w, img->h); GP_FilterFloydSteinberg(img, &sub_display, NULL); // GP_FilterHilbertPeano(img, &sub_display, NULL); } else { if (GP_PixelHasFlags(img->pixel_type, GP_PIXEL_HAS_ALPHA)) - pattern_fill(context, cx, cy, img->w, img->h); - GP_Blit_Clipped(img, 0, 0, img->w, img->h, context, cx, cy); + pattern_fill(pixmap, cx, cy, img->w, img->h); + GP_Blit_Clipped(img, 0, 0, img->w, img->h, pixmap, cx, cy); } cpu_timer_stop(&timer); /* clean up the rest of the display */ - GP_FillRectXYWH(context, 0, 0, cx, context->h, black_pixel); - GP_FillRectXYWH(context, 0, 0, context->w, cy, black_pixel); + GP_FillRectXYWH(pixmap, 0, 0, cx, pixmap->h, black_pixel); + GP_FillRectXYWH(pixmap, 0, 0, pixmap->w, cy, black_pixel); - int w = context->w - img->w - cx; + int w = pixmap->w - img->w - cx; if (w > 0) - GP_FillRectXYWH(context, img->w + cx, 0, w, context->h, black_pixel); + GP_FillRectXYWH(pixmap, img->w + cx, 0, w, pixmap->h, black_pixel); - int h = context->h - img->h - cy; + int h = pixmap->h - img->h - cy; if (h > 0) - GP_FillRectXYWH(context, 0, img->h + cy, context->w, h, black_pixel); + GP_FillRectXYWH(pixmap, 0, img->h + cy, pixmap->w, h, black_pixel); show_info(params, img, orig_img); if (config.combined_orientation) - GP_ContextFree(img); + GP_PixmapFree(img); GP_BackendFlip(backend); } -GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size h) +GP_Pixmap *load_resized_image(struct loader_params *params, GP_Size w, GP_Size h) { - GP_Context *img, *res = NULL; + GP_Pixmap *img, *res = NULL; struct cpu_timer timer; GP_ProgressCallback callback = {.callback = image_loader_callback}; @@ -414,10 +414,10 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size if (params->show_nn_first) { /* Do simple interpolation and blit the result */ - GP_Context *nn = GP_FilterResizeNNAlloc(img, w, h, NULL); + GP_Pixmap *nn = GP_FilterResizeNNAlloc(img, w, h, NULL); if (nn != NULL) { update_display(params, nn, img); - GP_ContextFree(nn); + GP_PixmapFree(nn); } } @@ -441,7 +441,7 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size cpu_timer_start(&timer, "Resampling"); callback.priv = "Resampling Image"; - GP_Context *i1 = GP_FilterResizeAlloc(img, w, h, params->resampling_method, &callback); + GP_Pixmap *i1 = GP_FilterResizeAlloc(img, w, h, params->resampling_method, &callback); img = i1; cpu_timer_stop(&timer); @@ -454,8 +454,8 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size } */ - /* Free low passed context if needed */ - GP_ContextFree(res); + /* Free low passed pixmap if needed */ + GP_PixmapFree(res); if (img == NULL) return NULL; @@ -593,7 +593,7 @@ static void *image_loader(void *ptr) { struct loader_params *params = ptr; struct cpu_timer sum_timer; - GP_Context *img, *orig_img, *context = backend->context; + GP_Pixmap *img, *orig_img, *pixmap = backend->pixmap; cpu_timer_start(&sum_timer, "sum"); @@ -609,7 +609,7 @@ static void *image_loader(void *ptr) GP_Size w, h; params->zoom_rat = calc_img_size(params, orig_img->w, orig_img->h, - context->w, context->h); + pixmap->w, pixmap->h); w = orig_img->w * params->zoom_rat + 0.5; h = orig_img->h * params->zoom_rat + 0.5; @@ -788,7 +788,7 @@ static uint32_t timer_callback(GP_Timer *self) int main(int argc, char *argv[]) { - GP_Context *context = NULL; + GP_Pixmap *pixmap = NULL; int shift_flag; int opts; @@ -853,13 +853,13 @@ int main(int argc, char *argv[]) GP_BACKEND_CALL_EXIT); } - context = backend->context; + pixmap = backend->pixmap; - black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); - white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, context); - gray_pixel = GP_RGBToContextPixel(0x33, 0x33, 0x33, context); + black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); + white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, pixmap); + gray_pixel = GP_RGBToPixmapPixel(0x33, 0x33, 0x33, pixmap); - GP_Fill(context, black_pixel); + GP_Fill(pixmap, black_pixel); GP_BackendFlip(backend); params.show_progress_once = 1; @@ -1115,7 +1115,7 @@ int main(int argc, char *argv[]) /* stop loader thread before resizing backend buffer */ stop_loader(); GP_BackendResizeAck(backend); - GP_Fill(backend->context, 0); + GP_Fill(backend->pixmap, 0); params.show_progress_once = 1; show_image(¶ms); break; diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c index 2d7eac94..aad40105 100644 --- a/demos/spiv/spiv_help.c +++ b/demos/spiv/spiv_help.c @@ -234,9 +234,9 @@ static int last_line; static int redraw_help(GP_Backend *backend, unsigned int loff, GP_Coord xoff) { - GP_Context *c = backend->context; - GP_Pixel black = GP_RGBToContextPixel(0x00, 0x00, 0x00, c); - GP_Pixel white = GP_RGBToContextPixel(0xff, 0xff, 0xff, c); + GP_Pixmap *c = backend->pixmap; + GP_Pixel black = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, c); + GP_Pixel white = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, c); int i; int spacing = GP_TextHeight(config.style)/10 + 2; diff --git a/demos/ttf2img/ttf2img.c b/demos/ttf2img/ttf2img.c index deaa37a4..0e75546a 100644 --- a/demos/ttf2img/ttf2img.c +++ b/demos/ttf2img/ttf2img.c @@ -74,23 +74,23 @@ int main(int argc, char *argv[]) GP_SetDebugLevel(debug_level); - GP_Context *context = GP_ContextAlloc(img_w, img_h, GP_PIXEL_RGB888); + GP_Pixmap *pixmap = GP_PixmapAlloc(img_w, img_h, GP_PIXEL_RGB888); - GP_Pixel black_pixel = GP_RGBToContextPixel(0x00, 0x00, 0x00, context); - GP_Pixel white_pixel = GP_RGBToContextPixel(0xff, 0xff, 0xff, context); + GP_Pixel black_pixel = GP_RGBToPixmapPixel(0x00, 0x00, 0x00, pixmap); + GP_Pixel white_pixel = GP_RGBToPixmapPixel(0xff, 0xff, 0xff, pixmap); - GP_Fill(context, white_pixel); + GP_Fill(pixmap, white_pixel); GP_TextStyle style = GP_DEFAULT_TEXT_STYLE; style.font = GP_FontFaceLoad(font_path, 27, 0); - GP_Text(context, &style, img_w/2, img_h/2, GP_ALIGN_CENTER|GP_VALIGN_CENTER, + GP_Text(pixmap, &style, img_w/2, img_h/2, GP_ALIGN_CENTER|GP_VALIGN_CENTER, black_pixel, white_pixel, string); - GP_SavePNG(context, img_path, NULL); + GP_SavePNG(pixmap, img_path, NULL); - GP_ContextFree(context); + GP_PixmapFree(pixmap); return 0; } diff --git a/doc/Makefile b/doc/Makefile index 9c1bcfb7..5da5636a 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,7 +1,7 @@ TOPDIR=.. include $(TOPDIR)/config.mk -SOURCES=index.html about.txt context.txt loaders.txt filters.txt \ +SOURCES=index.html about.txt pixmap.txt loaders.txt filters.txt \ basic_types.txt gfx.txt backends.txt gamma.txt grabbers.txt \ environment_variables.txt debug.txt core.txt input.txt \ gen.txt pixels.txt coordinate_system.txt coding_style.txt \ diff --git a/doc/about.txt b/doc/about.txt index 167425ab..96f3652b 100644 --- a/doc/about.txt +++ b/doc/about.txt @@ -17,7 +17,7 @@ Core Core of the library contains minimal amount of code to define interface that is shared between all parts of the library. -The most important part of the core is link:context.html[CP_Context] structure +The most important part of the core is link:pixmap.html[GP_Pixmap] structure that represents in-memory pixmap. The Core also contains generated code for basic operations such as diff --git a/doc/backends.txt b/doc/backends.txt index 944c13f3..a4834660 100644 --- a/doc/backends.txt +++ b/doc/backends.txt @@ -80,15 +80,15 @@ window resizable. [source,c] ------------------------------------------------------------------------------- -#include +#include -int GP_ContextFromSDLSurface(GP_Context *c, const SDL_Surface *surf); +int GP_PixmapFromSDLSurface(GP_Pixmap *c, const SDL_Surface *surf); ------------------------------------------------------------------------------- This function allows you to mix 'SDL' and 'GFXprim' code. -It initializes a 'GFXprim' context from the 'SDL' surface using the pixel -buffer from surface as pixel buffer for the context. +It initializes a 'GFXprim' pixmap from the 'SDL' surface using the pixel +buffer from surface as pixel buffer for the pixmap. Function returns zero on success and non-zero on failure (i.e. there is no 'GFXprim' pixel type to match given surface). @@ -243,9 +243,9 @@ typdef struct GP_Backend { const char *name; /* - * Pointer to context APP should draw to. + * Pointer to pixmap APP should draw to. */ - GP_Context *context; + GP_Pixmap *pixmap; ... @@ -595,8 +595,8 @@ was successful (i.e. X server allowed us to resize the window) the resize event will be send and should be handled in your event loop. You must respond to it by the 'GP_BackendResizeAck()' described below. -NOTE: The backend->context pointer may change upon calling this function and - at least backend->context->pixels pointer will change. +NOTE: The backend->pixmap pointer may change upon calling this function and + at least backend->pixmap->pixels pointer will change. [[ResizeAck]] @@ -613,10 +613,10 @@ int GP_BackendResizeAck(GP_Backend *self); ------------------------------------------------------------------------------- If backend is resizable by user interaction (for example X Window) you will -get resize event for each change of window size, however the backend context +get resize event for each change of window size, however the backend pixmap will not be resized until you call this function. This is useful in multi-threaded application where one threads waits for events and others draws -into the buffer so you can stop the drawing threads before the backend context +into the buffer so you can stop the drawing threads before the backend pixmap size change. diff --git a/doc/backends_python.txt b/doc/backends_python.txt index 183b4c18..b53b6bd7 100644 --- a/doc/backends_python.txt +++ b/doc/backends_python.txt @@ -87,8 +87,8 @@ import gfxprim.backends as backends # Assert that inicialization was successful assert(bk) - # Now you can draw into the backend via bk.context - bk.context.gfx.Fill(bk.context.RGBToPixel(0, 0, 0)); + # Now you can draw into the backend via bk.pixmap + bk.pixmap.gfx.Fill(bk.pixmap.RGBToPixel(0, 0, 0)); # If backend is buffered, changes are not propagated unless the screen is # updated via Flip() diff --git a/doc/blits.txt b/doc/blits.txt index d2e4e372..5a537376 100644 --- a/doc/blits.txt +++ b/doc/blits.txt @@ -24,17 +24,17 @@ into destination pixel type to speed up the blitting. /* or */ #include -void GP_Blit(const GP_Context *src, +void GP_Blit(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, - GP_Context *dst, GP_Coord x1, GP_Coord y1); + GP_Pixmap *dst, GP_Coord x1, GP_Coord y1); -void GP_BlitXYWH(const GP_Context *src, +void GP_BlitXYWH(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, - GP_Context *dst, GP_Coord x1, GP_Coord y1); + GP_Pixmap *dst, GP_Coord x1, GP_Coord y1); -void GP_BlitXYXY(const GP_Context *src, +void GP_BlitXYXY(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2); + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2); -------------------------------------------------------------------------------- Blit functions to copy rectangular area from source to destination. @@ -54,18 +54,18 @@ WARNING: For these functions the behavior is undefined when you pass /* or */ #include -void GP_BlitXYXY_Clipped(const GP_Context *src, +void GP_BlitXYXY_Clipped(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2); + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2); -void GP_BlitXYWH_Clipped(const GP_Context *src, +void GP_BlitXYWH_Clipped(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, - GP_Context *dst, GP_Coord x1, GP_Coord y1); + GP_Pixmap *dst, GP_Coord x1, GP_Coord y1); -void GP_Blit_Clipped(const GP_Context *src, +void GP_Blit_Clipped(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, - GP_Context *dst, GP_Coord x1, GP_Coord y1); + GP_Pixmap *dst, GP_Coord x1, GP_Coord y1); -------------------------------------------------------------------------------- Blit functions to copy rectangular area from source to destination. Both diff --git a/doc/coding_style.txt b/doc/coding_style.txt index ebd0f3f1..c23ad06b 100644 --- a/doc/coding_style.txt +++ b/doc/coding_style.txt @@ -108,14 +108,14 @@ GFXprim Specific Rules * Library external API uses CamelCase ** Together with mandatory 'GP_' prefix. -** For example 'GP_PixelType', 'GP_Context', etc. +** For example 'GP_PixelType', 'GP_Pixmap', etc. ** We will not change that, get over it. (It could have been worse, trust me.) * Basic library types are typedefed ** We have 'GP_Size' and 'GP_Coord' integer types to better distinguish roles of function parameters. -** The basic structures are also typedefed so you can wite 'GP_Context' - instead of 'struct GP_Context'. +** The basic structures are also typedefed so you can wite 'GP_Pixmap' + instead of 'struct GP_Pixmap'. ** Other uses of typedef are frowned upon. * When you add an externally visible symbol, i.e. new API function @@ -143,5 +143,5 @@ All constants are available in 'foo.C' submodules (i.e. 'core.C') to avoid clutter. Where this makes sense, functions should be available as methods of -an object (i.e. 'Context.Copy()' rather than 'Copy(context)'). Be Pythonic. +an object (i.e. 'Pixmap.Copy()' rather than 'Copy(pixmap)'). Be Pythonic. diff --git a/doc/convert.txt b/doc/convert.txt index f11f932a..a534ecb5 100644 --- a/doc/convert.txt +++ b/doc/convert.txt @@ -14,11 +14,11 @@ GP_Pixel GP_RGBToPixel(uint8_t r, uint8_t g, uint8_t b, GP_PixelType type); GP_Pixel GP_RGBAToPixel(uint8_t r, uint8_t g, uint8_t b, uint8_t a, GP_PixelType type); -GP_Pixel GP_RGBToContextPixel(uint8_t r, uint8_t g, uint8_t b, - const GP_Context *context); +GP_Pixel GP_RGBToPixmapPixel(uint8_t r, uint8_t g, uint8_t b, + const GP_Pixmap *pixmap); -GP_Pixel GP_RGBAToContextPixel(uint8_t r, uint8_t g, uint8_t b, uint8_t a, - const GP_Context *context); +GP_Pixel GP_RGBAToPixmapPixel(uint8_t r, uint8_t g, uint8_t b, uint8_t a, + const GP_Pixmap *pixmap); ------------------------------------------------------------------------------- Simple functions to convert RGB or RGBA 8 bit values into the specific diff --git a/doc/core.txt b/doc/core.txt index 1ae253a6..439494a6 100644 --- a/doc/core.txt +++ b/doc/core.txt @@ -4,7 +4,7 @@ Library Core Library core contains all basic data structures and functions that forms the glue which holds the GFXprim libraries together. -The most important data structure is a link:context.html[Context] which +The most important data structure is a link:pixmap.html[Pixmap] which describes in-memory pixmap which is used extensively in all parts of the library. @@ -20,7 +20,7 @@ or link:progress_callback.html[Progress callback]. [grid="rows"] [options="autowidth"] |============================================================================= -| link:context.html[Context] | Describes in-memory pixmap +| link:pixmap.html[Pixmap] | Describes in-memory pixmap | link:basic_types.html[Basic types] | Types for size, lenght, pixel and color @@ -30,7 +30,7 @@ or link:progress_callback.html[Progress callback]. | link:get_put_pixel.html[GetPixel and PutPixel] | Macros and functions to get and put pixels -| link:blits.html[Blits] | Blits (copies) a rectangular area from one context to +| link:blits.html[Blits] | Blits (copies) a rectangular area from one pixmap to another as well as simple pixel format conversions | link:progress_callback.html[Progress Callback] | Progress callback passed diff --git a/doc/core_python.txt b/doc/core_python.txt index 108c8594..0b960007 100644 --- a/doc/core_python.txt +++ b/doc/core_python.txt @@ -3,28 +3,28 @@ Python Core module The python binding maps mostly to the C API with the 'GP_' prefix stripped. -However structures as 'GP_Context' are not created by the 'GP_ContextAlloc()' +However structures as 'GP_Pixmap' are not created by the 'GP_PixmapAlloc()' function but have proper constructor and destructor to keep the Python reference counting happy. Then there are a bit more tricky solutions, such as 'GP_ProgressCallback' which needs a proxy function to call the python callback from the C code. -Context +Pixmap ~~~~~~~ [source,python] ------------------------------------------------------------------------------- import gfxprim.core as core - # Create 100x100 RGB888 context - c = core.Context(100, 100, core.C.PIXEL_RGB888) + # Create 100x100 RGB888 pixmap + c = core.Pixmap(100, 100, core.C.PIXEL_RGB888) print("w={} h={} bpp={}".format(c.w, c.h, c.bpp)) ------------------------------------------------------------------------------- -Creates a context of a particular size and pixel type. +Creates a pixmap of a particular size and pixel type. First two parameters are 'width' and 'height' third is pixel type which is an enumeration @@ -41,7 +41,7 @@ enumeration ------------------------------------------------------------------------------- import gfxprim.core as core - pixel = context.GetPixel(x, y) + pixel = pixmap.GetPixel(x, y) ------------------------------------------------------------------------------- @@ -52,7 +52,7 @@ returned. ------------------------------------------------------------------------------- import gfxprim.core as core - context.PutPixel(x, y, pixel) + pixmap.PutPixel(x, y, pixel) ------------------------------------------------------------------------------- @@ -66,11 +66,11 @@ NOTE: You may want to see link:coordinate_system.html[coordinate system] ------------------------------------------------------------------------------- import gfxprim.core as core - grayscale = context.Convert(core.C.PIXEL_G8) + grayscale = pixmap.Convert(core.C.PIXEL_G8) ------------------------------------------------------------------------------- -Returns context converted into the desired pixel format. +Returns pixmap converted into the desired pixel format. The conversion is naive i.e. the values are just divided/multiplied. @@ -80,15 +80,15 @@ The conversion is naive i.e. the values are just divided/multiplied. ------------------------------------------------------------------------------- import gfxprim.core as core - # Blits context to target starting at - # sx and sy in the source context + # Blits pixmap to target starting at + # sx and sy in the source pixmap # tx and ty in in the target - context.Blit(sx, sy, target, tx, ty, w, h) + pixmap.Blit(sx, sy, target, tx, ty, w, h) # Alternatively the size can be described by # coordinates in the source or target - context.Blit(sx, sy, target, tx, ty, sx2=, sy2=) - context.Blit(sx, sy, target, tx, ty, tx2=, ty2=) + pixmap.Blit(sx, sy, target, tx, ty, sx2=, sy2=) + pixmap.Blit(sx, sy, target, tx, ty, tx2=, ty2=) ------------------------------------------------------------------------------- @@ -118,8 +118,8 @@ import gfxprim.core as core # You can create a pixel from RGB and pixel type black = core.RGBToPixel(0, 0, 0, core.C.PIXEL_G1) - # Or using shortcut from context - black = context.RGBToPixel(0, 0, 0) + # Or using shortcut from pixmap + black = pixmap.RGBToPixel(0, 0, 0) ------------------------------------------------------------------------------- @@ -170,5 +170,5 @@ import gfxprim.core as core Sets and gets the GFXprim debug level. See link:debug.html[debug messages] description for more details. -These are basic 'Context' methods from core module. Importing other modules +These are basic 'Pixmap' methods from core module. Importing other modules will add some other (for example gfx module adds all drawing functions). diff --git a/doc/debug.txt b/doc/debug.txt index 09c80aa0..b209b53a 100644 --- a/doc/debug.txt +++ b/doc/debug.txt @@ -5,7 +5,7 @@ The GFXprim library includes a debug message infrastructure in order to ease the debugging. Many places of the library uses debug messages to report warnings, bugs, or -generally important events (i.e. context has been allocated, filter function +generally important events (i.e. pixmap has been allocated, filter function has been called). Debug messages are printed into the stderr and could be redirected to custom diff --git a/doc/environment_variables.txt b/doc/environment_variables.txt index 5ce7488a..216f19f1 100644 --- a/doc/environment_variables.txt +++ b/doc/environment_variables.txt @@ -48,13 +48,13 @@ The output is, by default, written to stderr and will look like: 1: GP_Loader.c:loader_by_filename():222: Loading file by filename extension 'pgm' 1: GP_Loader.c:loader_by_extension():198: Found loader 'Netpbm portable Graymap' 1: GP_PNM.c:load_header():244: Have header P2 (ASCII encoded PGM) 24x7 depth=15 -1: GP_Context.c:GP_ContextAlloc():62: Allocating context 24 x 7 - G4 +1: GP_Pixmap.c:GP_PixmapAlloc():62: Allocating pixmap 24 x 7 - G4 4: GP_X11.c:x11_update_rect():71: Updating rect 222x458-418x479 4: GP_X11.c:x11_update_rect():71: Updating rect 214x458-426x479 2: GP_Blit.c:GP_BlitXYXY_Clipped():129: Blitting 23x6, available 332x244 2: GP_Blit.c:GP_BlitXYXY_Clipped():139: Blitting 0x0->23x6 in 24x7 to 308x236 in 640x480 3: GP_X11.c:x11_set_attributes():225: Setting window caption to 'Spiv ~ test.pgm 1:1.000' - 4: GP_X11.c:x11_flip():91: Flipping context -1: GP_Context.c:GP_ContextFree():102: Freeing context (0x7f5008000b60) + 4: GP_X11.c:x11_flip():91: Flipping pixmap +1: GP_Pixmap.c:GP_PixmapFree():102: Freeing pixmap (0x7f5008000b60) 1: GP_X11_Conn.h:x11_close():72: Closing X11 display ------------------------------------------------------------------------------ diff --git a/doc/example_SDL_glue.txt b/doc/example_SDL_glue.txt index 804898f4..5e12aac6 100644 --- a/doc/example_SDL_glue.txt +++ b/doc/example_SDL_glue.txt @@ -1,7 +1,7 @@ SDL Glue -------- -You can easily mix SDL and GFXprim code using 'GP_ContextFromSDLSurface()' +You can easily mix SDL and GFXprim code using 'GP_PixmapFromSDLSurface()' function. [source,c] diff --git a/doc/filters.txt b/doc/filters.txt index c0cc5466..da1cf5aa 100644 --- a/doc/filters.txt +++ b/doc/filters.txt @@ -1,12 +1,12 @@ -Context filters +Pixmap filters --------------- -Pixel filters for 'GP_Context'. +Pixel filters for 'GP_Pixmap'. -The context filter is basically a function that operates on context pixels. +The pixmap filter is basically a function that operates on pixmap pixels. The result may be stored into a new bitmap or placed to bitmap passed as argument or, in some cases, the filter could be used 'in place' so the result -is stored into the same context as the one passed as filter source. +is stored into the same pixmap as the one passed as filter source. Common filter API ~~~~~~~~~~~~~~~~~ @@ -22,21 +22,21 @@ For convenience, the filters API is unified: * And the last argument is link:progress_callback.html[progress callback] When using allocating version of the filter, pointer to the newly allocated -context is returned, or in case of failure NULL is returned. +pixmap is returned, or in case of failure NULL is returned. If 'malloc()' has failed NULL is returned. If filter has been interrupted by a callback, all allocated memory is freed, and NULL is returned. -When using non-allocating variant of the filter, the destination context must +When using non-allocating variant of the filter, the destination pixmap must have correct pixel type and the size must be big enough to store the result. The return value from such filter is either zero, in case of success, or non-zero when filter was interrupted by a callback. For filters that work 'in-place' (which is explicitly said for each filter) -the source and the destination could be the same context. Note that this is -not expected to work if you do several overlapping sub-contexts and pass these +the source and the destination could be the same pixmap. Note that this is +not expected to work if you do several overlapping sub-pixmaps and pass these as arguments. [source,c] @@ -44,11 +44,11 @@ as arguments. /* * Filter common API. */ -int GP_FilterFoo(const GP_Context *src, GP_Context *dst, +int GP_FilterFoo(const GP_Pixmap *src, GP_Pixmap *dst, foo params ..., GP_ProgressCallback *callback); -GP_Context *GP_FilterFooAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterFooAlloc(const GP_Pixmap *src, foo params ..., GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -71,10 +71,10 @@ Invert /* or */ #include -int GP_FilterInvert(const GP_Context *src, GP_Context *dst, +int GP_FilterInvert(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterInvertAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterInvertAlloc(const GP_Pixmap *src, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -91,10 +91,10 @@ Brightness /* or */ #include -int GP_FilterBrightness(const GP_Context *src, GP_Context *dst, +int GP_FilterBrightness(const GP_Pixmap *src, GP_Pixmap *dst, float p, GP_ProgressCallback *callback); -GP_Context *GP_FilterBrightnessAlloc(const GP_Context *src, float p, +GP_Pixmap *GP_FilterBrightnessAlloc(const GP_Pixmap *src, float p, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -111,10 +111,10 @@ Contrast /* or */ #include -int GP_FilterContrast(const GP_Context *src, GP_Context *dst, +int GP_FilterContrast(const GP_Pixmap *src, GP_Pixmap *dst, float p, GP_ProgressCallback *callback); -GP_Context *GP_FilterContrastAlloc(const GP_Context *src, float p, +GP_Pixmap *GP_FilterContrastAlloc(const GP_Pixmap *src, float p, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -131,11 +131,11 @@ BrightnessContrast /* or */ #include -int GP_FilterBrightnessContrast(const GP_Context *src, GP_Context *dst, +int GP_FilterBrightnessContrast(const GP_Pixmap *src, GP_Pixmap *dst, float b, float c, GP_ProgressCallback *callback); -GP_Context *GP_FilterBrightnessContrastAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterBrightnessContrastAlloc(const GP_Pixmap *src, float b, float c, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -153,10 +153,10 @@ Posterize /* or */ #include -int GP_FilterPosterize(const GP_Context *src, GP_Context *dst, +int GP_FilterPosterize(const GP_Pixmap *src, GP_Pixmap *dst, unsigned int levels, GP_ProgressCallback *callback); -GP_Context *GP_FilterPosterizeAlloc(const GP_Context *src, unsigned int levels, +GP_Pixmap *GP_FilterPosterizeAlloc(const GP_Pixmap *src, unsigned int levels, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -174,27 +174,27 @@ Gaussian additive noise filter /* or */ #include -int GP_FilterGaussianNoiseAddEx(const GP_Context *src, +int GP_FilterGaussianNoiseAddEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float sigma, float mu, GP_ProgressCallback *callback); -GP_Context *GP_FilterGaussianNoiseAddExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterGaussianNoiseAddExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, float sigma, float mu, GP_ProgressCallback *callback); -static inline int GP_FilterGaussianNoiseAdd(const GP_Context *src, - GP_Context *dst, +static inline int GP_FilterGaussianNoiseAdd(const GP_Pixmap *src, + GP_Pixmap *dst, float sigma, float mu, GP_ProgressCallback *callback); -static inline GP_Context * -GP_FilterGaussianNoiseAddAlloc(const GP_Context *src, +static inline GP_Pixmap * +GP_FilterGaussianNoiseAddAlloc(const GP_Pixmap *src, float sigma, float mu, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -210,12 +210,12 @@ include::images/gaussian_noise/images.txt[] Arithmetic filters ~~~~~~~~~~~~~~~~~~ -Arithmetic filters do take two contexts as an input and combines them into one -output context. +Arithmetic filters do take two pixmaps as an input and combines them into one +output pixmap. -The pixel type of both input contexts must match. +The pixel type of both input pixmaps must match. -If size of the input contexts differs, minimum is used. +If size of the input pixmaps differs, minimum is used. [source,c] ------------------------------------------------------------------------------- @@ -223,17 +223,17 @@ If size of the input contexts differs, minimum is used. /* or */ #include -int GP_FilterAddition(const GP_Context *src_a, - const GP_Context *src_b, - GP_Context *dst, +int GP_FilterAddition(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, + GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterAdditionAlloc(const GP_Context *src_a, - const GP_Context *src_b, +GP_Pixmap *GP_FilterAdditionAlloc(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Produces saturated (clamped) addition of two contexts. +Produces saturated (clamped) addition of two pixmaps. [source,c] ------------------------------------------------------------------------------- @@ -241,17 +241,17 @@ Produces saturated (clamped) addition of two contexts. /* or */ #include -int GP_FilterMultiply(const GP_Context *src_a, - const GP_Context *src_b, - GP_Context *dst, +int GP_FilterMultiply(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, + GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterMultiplyAlloc(const GP_Context *src_a, - const GP_Context *src_b, +GP_Pixmap *GP_FilterMultiplyAlloc(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Produces saturated (clamped) multiplication of two contexts. +Produces saturated (clamped) multiplication of two pixmaps. [source,c] ------------------------------------------------------------------------------- @@ -259,13 +259,13 @@ Produces saturated (clamped) multiplication of two contexts. /* or */ #include -int GP_FilterDifference(const GP_Context *src_a, - const GP_Context *src_b, - GP_Context *dst, +int GP_FilterDifference(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, + GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterDifferenceAlloc(const GP_Context *src_a, - const GP_Context *src_b, +GP_Pixmap *GP_FilterDifferenceAlloc(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -278,22 +278,22 @@ Produces symmetric difference (i.e. abs(a - b)). /* or */ #include -int GP_FilterMax(const GP_Context *src_a, - const GP_Context *src_b, - GP_Context *dst, +int GP_FilterMax(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, + GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterMaxAlloc(const GP_Context *src_a, - const GP_Context *src_b, +GP_Pixmap *GP_FilterMaxAlloc(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, GP_ProgressCallback *callback); -int GP_FilterMin(const GP_Context *src_a, - const GP_Context *src_b, - GP_Context *dst, +int GP_FilterMin(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, + GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterMinAlloc(const GP_Context *src_a, - const GP_Context *src_b, +GP_Pixmap *GP_FilterMinAlloc(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -308,14 +308,14 @@ Rotation and Symmetry filters /* or */ #include -int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst, +int GP_FilterMirrorH(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterMirrorHAlloc(const GP_Pixmap *src, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Mirrors context horizontally. +Mirrors pixmap horizontally. Works 'in-place'. @@ -330,14 +330,14 @@ include::images/mirror_h/images.txt[] /* or */ #include -int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst, +int GP_FilterMirrorV(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterMirrorVAlloc(const GP_Pixmap *src, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Mirrors context vertically. +Mirrors pixmap vertically. Works 'in-place'. @@ -352,19 +352,19 @@ include::images/mirror_v/images.txt[] /* or */ #include -int GP_FilterRotate90(const GP_Context *src, GP_Context *dst, +int GP_FilterRotate90(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterRotate90Alloc(const GP_Context *src, +GP_Pixmap *GP_FilterRotate90Alloc(const GP_Pixmap *src, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Rotate context by 90 degrees. +Rotate pixmap by 90 degrees. Doesn't work 'in-place' (yet). The destination has to have the same pixel type and size must be large enough to -fit rotated context (i.e. W and H are swapped). +fit rotated pixmap (i.e. W and H are swapped). include::images/rotate_90/images.txt[] @@ -374,14 +374,14 @@ include::images/rotate_90/images.txt[] /* or */ #include -int GP_FilterRotate180(const GP_Context *src, GP_Context *dst, +int GP_FilterRotate180(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterRotate180Alloc(const GP_Context *src, +GP_Pixmap *GP_FilterRotate180Alloc(const GP_Pixmap *src, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Rotate context by 180 degrees. +Rotate pixmap by 180 degrees. Doesn't work 'in-place' (yet). @@ -396,19 +396,19 @@ include::images/rotate_180/images.txt[] /* or */ #include -int GP_FilterRotate270(const GP_Context *src, GP_Context *dst, +int GP_FilterRotate270(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterRotate270Alloc(const GP_Context *src, +GP_Pixmap *GP_FilterRotate270Alloc(const GP_Pixmap *src, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Rotate context by 270 degrees. +Rotate pixmap by 270 degrees. Doesn't work 'in-place' (yet). The destination has to have the same pixel type and destination size must be -large enough to fit rotated context (i.e. W and H are swapped). +large enough to fit rotated pixmap (i.e. W and H are swapped). include::images/rotate_270/images.txt[] @@ -428,11 +428,11 @@ typedef enum GP_FilterSymmetries { GP_MIRROR_V, } GP_FilterSymmetries; -GP_Context *GP_FilterSymmetry(const GP_Context *src, +GP_Pixmap *GP_FilterSymmetry(const GP_Pixmap *src, GP_FilterSymmetries symmetry, GP_ProgressCallback *callback); -int GP_FilterSymmetry(const GP_Context *src, GP_Context *dst, +int GP_FilterSymmetry(const GP_Pixmap *src, GP_Pixmap *dst, GP_FilterSymmetries symmetry, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -481,10 +481,10 @@ ready-to-use filters. /* or */ #include -int GP_FilterLinearConvolution_Raw(const GP_Context *src, +int GP_FilterLinearConvolution_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float kernel[], uint32_t kw, uint32_t kh, float kern_div, GP_ProgressCallback *callback); @@ -493,10 +493,10 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src, Internal generic convolution filter, this is a base for all linear convolution filters with non-separable kernel. -The src coordinate and sizes denotes rectangle in the source context that the +The src coordinate and sizes denotes rectangle in the source pixmap that the filter operates on. -The dst coordinates defines offset into the dst context. +The dst coordinates defines offset into the dst pixmap. The kernel is two-dimensional array of a size kw * kh indexed as kernel[x + y*kw]. @@ -539,26 +539,26 @@ include::images/convolution/images.txt[] /* or */ #include -int GP_FilterHLinearConvolution_Raw(const GP_Context *src, +int GP_FilterHLinearConvolution_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float kernel[], uint32_t kw, float kern_div, GP_ProgressCallback *callback); -int GP_FilterVLinearConvolution_Raw(const GP_Context *src, +int GP_FilterVLinearConvolution_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float kernel[], uint32_t kh, float kern_div, GP_ProgressCallback *callback); -int GP_FilterVHLinearConvolution_Raw(const GP_Context *src, +int GP_FilterVHLinearConvolution_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float hkernel[], uint32_t kw, float hkern_div, float vkernel[], uint32_t kh, float vkern_div, @@ -570,7 +570,7 @@ void GP_FilterKernelPrint_Raw(float kernel[], int kw, int kh, float kern_div); Internal special functions for one dimensional vertical and horizontal convolution these two functions are base for all separable convolution filters. -The src coordinate and sizes denotes rectangle in the source context that the +The src coordinate and sizes denotes rectangle in the source pixmap that the filter operates on. The dst coordinates are offset into the dst. @@ -640,25 +640,25 @@ typedef struct GP_FilterKernel2D { float *kernel; } GP_FilterKernel2D; -int GP_FilterConvolutionEx(const GP_Context *src, +int GP_FilterConvolutionEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Coord h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, const GP_FilterKernel2D *kernel, GP_ProgressCallback *callback); -GP_Context *GP_FilterConvolutionExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterConvolutionExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, const GP_FilterKernel2D *kernel, GP_ProgressCallback *callback); -int GP_FilterConvolution(const GP_Context *src, GP_Context *dst, +int GP_FilterConvolution(const GP_Pixmap *src, GP_Pixmap *dst, const GP_FilterKernel2D *kernel, GP_ProgressCallback *callback); -GP_Context *GP_FilterConvolutionAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterConvolutionAlloc(const GP_Pixmap *src, const GP_FilterKernel2D *kernel, GP_ProgressCallback *callback); @@ -690,7 +690,7 @@ WARNING: If filter is executed in-place the work cannot be distributed between /* * Example box smoothing filter. */ -static void box_smoothing(GP_Context *img) +static void box_smoothing(GP_Pixmap *img) { float box_filter[] = { 1, 1, 1, @@ -720,10 +720,10 @@ Laplace Filter /* or */ #include -int GP_FilterLaplace(const GP_Context *src, GP_Context *dst, +int GP_FilterLaplace(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterLaplaceAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterLaplaceAlloc(const GP_Pixmap *src, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -767,10 +767,10 @@ Laplacian Edge Sharpening /* or */ #include -int GP_FilterEdgeSharpening(const GP_Context *src, GP_Context *dst, +int GP_FilterEdgeSharpening(const GP_Pixmap *src, GP_Pixmap *dst, float w, GP_ProgressCallback *callback); -GP_Context *GP_FilterEdgeSharpeningAlloc(const GP_Context *src, float w, +GP_Pixmap *GP_FilterEdgeSharpeningAlloc(const GP_Pixmap *src, float w, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -798,25 +798,25 @@ Gaussian Blur /* or */ #include -int GP_FilterGaussianBlurEx(const GP_Context *src, +int GP_FilterGaussianBlurEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float x_sigma, float y_sigma, GP_ProgressCallback *callback); -GP_Context *GP_FilterGaussianBlurExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterGaussianBlurExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, float x_sigma, float y_sigma, GP_ProgressCallback *callback); -int GP_FilterGaussianBlur(const GP_Context *src, GP_Context *dst, +int GP_FilterGaussianBlur(const GP_Pixmap *src, GP_Pixmap *dst, float x_sigma, float y_sigma, GP_ProgressCallback *callback) -GP_Context *GP_FilterGaussianBlurAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterGaussianBlurAlloc(const GP_Pixmap *src, float x_sigma, float y_sigma, GP_ProgressCallback *callback) ------------------------------------------------------------------------------- @@ -879,26 +879,26 @@ Median /* or */ #include -int GP_FilterMedianEx(const GP_Context *src, +int GP_FilterMedianEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, int xmed, int ymed, GP_ProgressCallback *callback); -GP_Context *GP_FilterMedianExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterMedianExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, int xmed, int ymed, GP_ProgressCallback *callback); -int GP_FilterMedian(const GP_Context *src, - GP_Context *dst, +int GP_FilterMedian(const GP_Pixmap *src, + GP_Pixmap *dst, int xmed, int ymed, GP_ProgressCallback *callback); -GP_Context *GP_FilterMedianAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterMedianAlloc(const GP_Pixmap *src, int xmed, int ymed, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- diff --git a/doc/filters_dithering.txt b/doc/filters_dithering.txt index 94c82033..c7cf060b 100644 --- a/doc/filters_dithering.txt +++ b/doc/filters_dithering.txt @@ -27,11 +27,11 @@ And is throwed away at the image borders. /* or */ #include -int GP_FilterFloydSteinberg(const GP_Context *src, GP_Context *dst, +int GP_FilterFloydSteinberg(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Renders Floyd Steinberg dithering directly into passed context. The +Renders Floyd Steinberg dithering directly into passed pixmap. The destination must be at least as large as source. If operation was aborted by a callback, non-zero is returned. @@ -45,12 +45,12 @@ the function returns non-zero and sets errno to 'ENOSYS'. /* or */ #include -GP_Context *GP_FilterFloydSteinbergAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterFloydSteinbergAlloc(const GP_Pixmap *src, GP_PixelType pixel_type, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Returns pointer to allocated context of given pixel_type. +Returns pointer to allocated pixmap of given pixel_type. If 'malloc(2)' has failed, or operation was aborted by a callback NULL is returned. @@ -75,11 +75,11 @@ edges tend to be less sharp. /* or */ #include -int GP_FilterHilbertPeano(const GP_Context *src, GP_Context *dst, +int GP_FilterHilbertPeano(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Renders Hilbert Peano dithering directly into passed context. The +Renders Hilbert Peano dithering directly into passed pixmap. The destination must be at least as large as source. If operation was aborted by a callback, non-zero is returned. @@ -93,12 +93,12 @@ the function returns NULL and sets errno to 'ENOSYS'. /* or */ #include -GP_Context *GP_FilterHilbertPeanoAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterHilbertPeanoAlloc(const GP_Pixmap *src, GP_PixelType pixel_type, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Returns pointer to allocated context of given pixel_type. +Returns pointer to allocated pixmap of given pixel_type. If 'malloc(2)' has failed, or operation was aborted by a callback NULL is returned. diff --git a/doc/filters_resize.txt b/doc/filters_resize.txt index 6cf65644..349ad2a7 100644 --- a/doc/filters_resize.txt +++ b/doc/filters_resize.txt @@ -21,17 +21,17 @@ typedef enum GP_InterpolationType { const char *GP_InterpolationTypeName(enum GP_InterpolationType interp_type); -int GP_FilterResize(const GP_Context *src, GP_Context *dst, +int GP_FilterResize(const GP_Pixmap *src, GP_Pixmap *dst, GP_InterpolationType type, GP_ProgressCallback *callback); -GP_Context *GP_FilterResizeAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterResizeAlloc(const GP_Pixmap *src, GP_Size w, GP_Size h, GP_InterpolationType type, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Interpolate (resize) the context. +Interpolate (resize) the pixmap. Resize image given size and interpolation type. @@ -49,7 +49,7 @@ GP_FilterResizeAlloc The +GP_FilterResizeAlloc()+ allocates the destination give it's size. -Returns pointer to newly allocated context or NULL in case of failure and +Returns pointer to newly allocated pixmap or NULL in case of failure and errno is set. Nearest Neighbour Interpolation @@ -61,10 +61,10 @@ Nearest Neighbour Interpolation /* or */ #include -int GP_FilterResizeNN(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeNN(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -static inline GP_Context *GP_FilterResizeNNAlloc(const GP_Context *src, +static inline GP_Pixmap *GP_FilterResizeNNAlloc(const GP_Pixmap *src, GP_Size w, GP_Size h, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -87,17 +87,17 @@ Bilinear Interpolation /* or */ #include -int GP_FilterResizeLinearInt(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeLinearInt(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -int GP_FilterResizeLinearLFInt(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeLinearLFInt(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterResizeLinearIntAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterResizeLinearIntAlloc(const GP_Pixmap *src, GP_Size w, GP_Size h, GP_ProgressCallback *callback); -GP_Context *GP_FilterResizeLinearLFIntAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterResizeLinearLFIntAlloc(const GP_Pixmap *src, GP_Size w, GP_Size h, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -115,17 +115,17 @@ Bicubic Interpolation /* or */ #include -int GP_FilterResizeCubicInt(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeCubicInt(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -int GP_FilterResizeCubic(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeCubic(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterResizeCubicIntAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterResizeCubicIntAlloc(const GP_Pixmap *src, GP_Size w, GP_Size h, GP_ProgressCallback *callback); -GP_Context *GP_FilterResizeCubicAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterResizeCubicAlloc(const GP_Pixmap *src, GP_Size w, GP_Size h, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- diff --git a/doc/gamma.txt b/doc/gamma.txt index a38518bd..521306a7 100644 --- a/doc/gamma.txt +++ b/doc/gamma.txt @@ -38,7 +38,7 @@ and text still use legacy gamma support.) Implementation ~~~~~~~~~~~~~~ -The 'GP_Gamma' structure defines per context, per channel, gamma tables. +The 'GP_Gamma' structure defines per pixmap, per channel, gamma tables. The tables for particular gamma are reference counted. There is only one table for particular gamma value and bit depth in memory at a time. diff --git a/doc/get_put_pixel.txt b/doc/get_put_pixel.txt index 86d90c7f..db9893f0 100644 --- a/doc/get_put_pixel.txt +++ b/doc/get_put_pixel.txt @@ -7,17 +7,17 @@ GetPixel and PutPixel /* or */ #include -GP_Pixel GP_GetPixel(const GP_Context *context, GP_Coord x, GP_Coord y); +GP_Pixel GP_GetPixel(const GP_Pixmap *pixmap, GP_Coord x, GP_Coord y); -void GP_PutPixel(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel p); +void GP_PutPixel(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel p); -------------------------------------------------------------------------------- Gets, puts a pixel value. GP_Pixel is a number which holds a pixel value. -This functions are clipped, GetPixel outside of the context returns zero, -PutPixel outside the context is no-op. +This functions are clipped, GetPixel outside of the pixmap returns zero, +PutPixel outside the pixmap is no-op. -This functions honour link:context.html[context rotation flags]. +This functions honour link:pixmap.html[pixmap rotation flags]. Generally these function are safe to use but rather slow in innner cycles. @@ -27,23 +27,23 @@ Generally these function are safe to use but rather slow in innner cycles. /* or */ #include -GP_Pixel GP_GetPixel_Raw(const GP_Context *context, GP_Coord x, GP_Coord y); +GP_Pixel GP_GetPixel_Raw(const GP_Pixmap *pixmap, GP_Coord x, GP_Coord y); -void GP_PutPixel_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel p); +void GP_PutPixel_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel p); /* * Substitute {{ bpp }} for specific bits per pixel (1BPP_LE, 24BPP, ...) * * These macros are generated to core/GP_GetPutPixel.gen.h */ -GP_Pixel GP_GetPixel_Raw_{{ bpp }}(const GP_Context *c, int x, int y); +GP_Pixel GP_GetPixel_Raw_{{ bpp }}(const GP_Pixmap *c, int x, int y); -void GP_PutPixel_Raw_{{ bpp }}(GP_Context *c, GP_Coord x, GP_Coord y, +void GP_PutPixel_Raw_{{ bpp }}(GP_Pixmap *c, GP_Coord x, GP_Coord y, GP_Pixel p); -------------------------------------------------------------------------------- -These functions are generally fast, but does not honour context rotation flags -and do not check that coordinates are inside of the context. +These functions are generally fast, but does not honour pixmap rotation flags +and do not check that coordinates are inside of the pixmap. They are intended as basic building blocks for other GFX primitives, filters, etc. diff --git a/doc/gfx.txt b/doc/gfx.txt index 14cb7d8b..35f75d23 100644 --- a/doc/gfx.txt +++ b/doc/gfx.txt @@ -11,7 +11,7 @@ See also RGB tripplet to pixel link:convert.html[conversions]. Rotation Flags ~~~~~~~~~~~~~~ -Drawing orientation is affected by the link:context.html[context rotation +Drawing orientation is affected by the link:pixmap.html[pixmap rotation flags]. The parameters passed to the functions are transformed accordingly to the flags before the drawing, which allows for fast and transparent rotated or mirrored rendering. @@ -28,10 +28,10 @@ Fill [source,c] -------------------------------------------------------------------------------- -void GP_Fill(GP_Context *context, GP_Pixel pixel); +void GP_Fill(GP_Pixmap *pixmap, GP_Pixel pixel); -------------------------------------------------------------------------------- -Fills the whole context bitmap with the specified pixel value. +Fills the whole pixmap bitmap with the specified pixel value. NOTE: GP_Fill is implemented in the library Core rather than in GFX so that it's available to all library parts. @@ -41,10 +41,10 @@ Lines [source,c] -------------------------------------------------------------------------------- -void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, +void GP_HLineXXY(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel); -void GP_HLine(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, +void GP_HLine(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -55,7 +55,7 @@ x0, x1 can be specified in any order. [source,c] -------------------------------------------------------------------------------- -void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, +void GP_HLineXYW(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -64,10 +64,10 @@ Draws a horizontal line from (x, y) to (x+w-1, y), inclusive. [source,c] -------------------------------------------------------------------------------- -void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1, +void GP_VLineXYY(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel); -void GP_VLine(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1, +void GP_VLine(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -78,7 +78,7 @@ y0, y1 can be specified in any order. [source,c] -------------------------------------------------------------------------------- -void GP_VLineXYH(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size h, +void GP_VLineXYH(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size h, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -87,7 +87,7 @@ Draws a vertical line from (x, y) to (x, y+h-1), inclusive. [source,c] -------------------------------------------------------------------------------- -void GP_Line(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Line(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -100,7 +100,7 @@ Circles [source,c] -------------------------------------------------------------------------------- -void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Circle(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -111,7 +111,7 @@ specified by points (xcenter-r, ycenter-r, xcenter+r, ycenter+r), inclusive. [source,c] -------------------------------------------------------------------------------- -void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillCircle(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -125,7 +125,7 @@ Rings ~~~~~ [source,c] -------------------------------------------------------------------------------- -void GP_Ring(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Ring(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r1, GP_Size r2, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -136,7 +136,7 @@ and appropriate radii. [source,c] -------------------------------------------------------------------------------- -void GP_FillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillRing(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r1, GP_Size r2, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -150,7 +150,7 @@ Ellipses [source,c] -------------------------------------------------------------------------------- -void GP_Ellipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Ellipse(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -161,7 +161,7 @@ specified by points (xcenter-a, ycenter-b, xcenter+a, ycenter+b), inclusive. [source,c] -------------------------------------------------------------------------------- -void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillEllipse(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -172,7 +172,7 @@ Triangles [source,c] -------------------------------------------------------------------------------- -void GP_Triangle(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Triangle(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -181,7 +181,7 @@ Draws a triangle. [source,c] -------------------------------------------------------------------------------- -void GP_FillTriangle(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_FillTriangle(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -193,13 +193,13 @@ Rects [source,c] -------------------------------------------------------------------------------- -void GP_RectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_RectXYXY(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel); -void GP_RectXYWH(GP_Context *context, GP_Coord x, GP_Coord y, +void GP_RectXYWH(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel); -void GP_Rect(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Rect(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -211,13 +211,13 @@ The 'GP_Rect()' function is an alias for 'GP_RectXYXY()'. [source,c] -------------------------------------------------------------------------------- -void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_FillRectXYXY(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel); -void GP_FillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y, +void GP_FillRectXYWH(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel); -void GP_FillRect(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_FillRect(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -234,7 +234,7 @@ Tetragons [source,c] -------------------------------------------------------------------------------- -void GP_Tetragon(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Tetragon(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Coord x3, GP_Coord y3, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -243,7 +243,7 @@ Draws a tetragon. [source,c] -------------------------------------------------------------------------------- -void GP_FillTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_FillTetragon(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Coord x3, GP_Coord y3, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -255,7 +255,7 @@ Polygons [source,c] -------------------------------------------------------------------------------- -void GP_Polygon(GP_Context *context, unsigned int vertex_count, +void GP_Polygon(GP_Pixmap *pixmap, unsigned int vertex_count, const GP_Coord *xy, GP_Pixel pixel); -------------------------------------------------------------------------------- @@ -263,7 +263,7 @@ Draws a polygon. [source,c] -------------------------------------------------------------------------------- -void GP_FillPolygon(GP_Context *context, unsigned int vertex_count, +void GP_FillPolygon(GP_Pixmap *pixmap, unsigned int vertex_count, const GP_Coord *xy, GP_Pixel pixel); -------------------------------------------------------------------------------- diff --git a/doc/gfx_python.txt b/doc/gfx_python.txt index 941b1f85..eda0951d 100644 --- a/doc/gfx_python.txt +++ b/doc/gfx_python.txt @@ -3,7 +3,7 @@ Python GFX module The python binding maps mostly to the C API with the 'GP_' prefix stripped. -The gfx module adds methods to the gfx context submodule. +The gfx module adds methods to the gfx pixmap submodule. NOTE: You may want to see the link:coordinate_system.html[coordinate system] first. @@ -13,9 +13,9 @@ Drawing functions All drawing functions takes a 'pixel' value (to describe color) which link:core_python.html#Colors_and_Pixels[can be obtained], for a particular -pixel type (context), from a RGB triplet. +pixel type (pixmap), from a RGB triplet. -All drawing functions are clipped. Drawing outside of a context is no-op. +All drawing functions are clipped. Drawing outside of a pixmap is no-op. WARNING: Drawing functions takes strictly integer coordinates, make sure that all divisions are integer divisions (i.e. use // instead of /) to @@ -28,7 +28,7 @@ Line Based Primitives ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.HLine(x0, x1, y, pixel) + pixmap.gfx.HLine(x0, x1, y, pixel) ------------------------------------------------------------------------------- @@ -38,7 +38,7 @@ Draws a horizontal line from 'x0' to 'x1' at 'y'. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.VLine(x, y0, y1, pixel) + pixmap.gfx.VLine(x, y0, y1, pixel) ------------------------------------------------------------------------------- @@ -49,7 +49,7 @@ Draws a vertical line from 'y0' to 'y1' at 'x'. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.Line(x0, y0, x1, y1, pixel) + pixmap.gfx.Line(x0, y0, x1, y1, pixel) ------------------------------------------------------------------------------- @@ -59,7 +59,7 @@ Draws a line from x0, y0 to x1, y1. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.Rect(x0, y0, x1, y1, pixel) + pixmap.gfx.Rect(x0, y0, x1, y1, pixel) ------------------------------------------------------------------------------- @@ -69,7 +69,7 @@ Draws a rectangle defined by two points. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.Triangle(x0, y0, x1, y1, x1, y2, pixel) + pixmap.gfx.Triangle(x0, y0, x1, y1, x1, y2, pixel) ------------------------------------------------------------------------------- @@ -79,7 +79,7 @@ Draws a triangle defined by three points. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.Tetragon(x0, y0, x1, y1, x1, y2, x3, y3, pixel) + pixmap.gfx.Tetragon(x0, y0, x1, y1, x1, y2, x3, y3, pixel) ------------------------------------------------------------------------------- @@ -89,9 +89,9 @@ Draws a tetragon defined by four points. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.Polygon([x0, y0, x1, y1, ...], pixel) + pixmap.gfx.Polygon([x0, y0, x1, y1, ...], pixel) - context.gfx.Polygon([(x0, y0), (x1, y1), ...], pixel) + pixmap.gfx.Polygon([(x0, y0), (x1, y1), ...], pixel) ------------------------------------------------------------------------------- @@ -102,7 +102,7 @@ integers or list of N tuples. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.Circle(x, y, r, pixel) + pixmap.gfx.Circle(x, y, r, pixel) ------------------------------------------------------------------------------- @@ -112,7 +112,7 @@ Draws a circle. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.Ellipse(x, y, a, b, pixel) + pixmap.gfx.Ellipse(x, y, a, b, pixel) ------------------------------------------------------------------------------- @@ -122,7 +122,7 @@ Draws an ellipse. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.Ring(x, y, r1, r2, pixel) + pixmap.gfx.Ring(x, y, r1, r2, pixel) ------------------------------------------------------------------------------- @@ -135,17 +135,17 @@ Filled Primitives ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.Fill(pixel) + pixmap.gfx.Fill(pixel) ------------------------------------------------------------------------------- -Fills context with particular 'pixel' value. +Fills pixmap with particular 'pixel' value. [source,python] ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.FillRect(x0, y0, x1, y1, pixel) + pixmap.gfx.FillRect(x0, y0, x1, y1, pixel) ------------------------------------------------------------------------------- @@ -155,7 +155,7 @@ Fills a rectangle defined by two points. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.FillTriangle(x0, y0, x1, y1, x1, y2, pixel) + pixmap.gfx.FillTriangle(x0, y0, x1, y1, x1, y2, pixel) ------------------------------------------------------------------------------- @@ -165,7 +165,7 @@ Draws a filled triangle defined by three points. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.FillTetragon(x0, y0, x1, y1, x1, y2, x3, y3, pixel) + pixmap.gfx.FillTetragon(x0, y0, x1, y1, x1, y2, x3, y3, pixel) ------------------------------------------------------------------------------- @@ -175,9 +175,9 @@ Draws a filled tetragon defined by four points. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.FillPolygon([x0, y0, x1, y1, ...], pixel) + pixmap.gfx.FillPolygon([x0, y0, x1, y1, ...], pixel) - context.gfx.FillPolygon([(x0, y0), (x1, y1), ...], pixel) + pixmap.gfx.FillPolygon([(x0, y0), (x1, y1), ...], pixel) ------------------------------------------------------------------------------- @@ -188,7 +188,7 @@ integers or list of N tuples. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.FillCircle(x, y, r, pixel) + pixmap.gfx.FillCircle(x, y, r, pixel) ------------------------------------------------------------------------------- @@ -198,7 +198,7 @@ Fills a circle. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.FillEllipse(x, y, a, b, pixel) + pixmap.gfx.FillEllipse(x, y, a, b, pixel) ------------------------------------------------------------------------------- @@ -208,7 +208,7 @@ Fills an ellipse. ------------------------------------------------------------------------------- import gfxprim.gfx as gfx - context.gfx.FillRing(x, y, r1, r2, pixel) + pixmap.gfx.FillRing(x, y, r1, r2, pixel) ------------------------------------------------------------------------------- diff --git a/doc/grabbers.txt b/doc/grabbers.txt index 21285921..871cfdca 100644 --- a/doc/grabbers.txt +++ b/doc/grabbers.txt @@ -25,7 +25,7 @@ typdef struct GP_Grabber { /* * Currently loaded frame. */ - GP_Context *frame; + GP_Pixmap *frame; /* * Connection fd usable for select() or poll(). @@ -100,7 +100,7 @@ grabber 'fd' is not -1 it's preferable to call it when select() or poll() returns that data are available on the 'fd'. This function returns non-zero if new frame was received and stored into the -'frame' context. Otherwise zero is returned. +'frame' pixmap. Otherwise zero is returned. Grabber Initializations ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/images/regen.py b/doc/images/regen.py index ba540aa7..0dabd6c6 100755 --- a/doc/images/regen.py +++ b/doc/images/regen.py @@ -33,10 +33,10 @@ def to_str(x, to_str): return res -def convert(ctx): - if (ctx.pixel_type == core.C.PIXEL_RGB332): - return ctx.Convert(core.C.PIXEL_RGB888) - return ctx +def convert(pixmap): + if (pixmap.pixel_type == core.C.PIXEL_RGB332): + return pixmap.Convert(core.C.PIXEL_RGB888) + return pixmap class ImgGen: def __init__(self, orig_path): diff --git a/doc/loaders.txt b/doc/loaders.txt index 0b83df55..a01d4a32 100644 --- a/doc/loaders.txt +++ b/doc/loaders.txt @@ -1,4 +1,4 @@ -Context loaders +Pixmap loaders --------------- This part of GFXprim library implements API to load and save images for common image file formats. @@ -19,8 +19,8 @@ to a file and one that reads data from an link:loaders_io.html[IO stream]. All loading functions returns a pointer to newly allocated and loaded image or upon a failure NULL and errno is set. -The link:context.html[Context] returned by the loaders should be later freed -with link:context.html#ContextFree[GP_ContextFree()]. +The link:pixmap.html[Pixmap] returned by the loaders should be later freed +with link:pixmap.html#PixmapFree[GP_PixmapFree()]. All saving functions returns zero on success and non-zero on failure. If image saving is aborted by a callback, the opened file is closed and removed from a @@ -57,7 +57,7 @@ General interface /* or */ #include -GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Loads an image from a file. @@ -75,8 +75,8 @@ signature is recognized, image loader it is called and the result is returned. If file extension disagrees with file signature (which is quite common on the internet) a warning is printed into the stderr. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [[Save_Image]] [source,c] @@ -85,11 +85,11 @@ link:context.html#ContextFree[GP_ContextFree()]. /* or */ #include -int GP_SaveImage(GP_Context *src, const char *dst_path, +int GP_SaveImage(GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Saves a link:context.html[Context] into a file. +Saves a link:pixmap.html[Pixmap] into a file. The file format is matched accordingly to the file extension. @@ -99,7 +99,7 @@ If extension was found but support for saving the image format is not implemented errno is set to 'ENOSYS' (this may happen in case that GFXprim wasn't compiled with support for this image type). -If context pixel type is not supported by the format errno is set to +If pixmap pixel type is not supported by the format errno is set to 'EINVAL'. [[Register_Loader]] @@ -112,17 +112,17 @@ typedef struct GP_Loader { /* * Reads an image from an IO stream. * - * Returns newly allocated context cotaining the loaded image or in + * Returns newly allocated pixmap cotaining the loaded image or in * case of failure NULL and errno is set. */ - GP_Context *(*Read)(GP_IO *io, GP_ProgressCallback *callback); + GP_Pixmap *(*Read)(GP_IO *io, GP_ProgressCallback *callback); /* * Save an image. * * Returns zero on success, non-zero on failure and errno must be set. */ - int (*Save)(const GP_Context *src, const char *dst_path, + int (*Save)(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); /* @@ -224,7 +224,7 @@ against extensions defined by loaders. /* or */ #include -GP_Context *GP_LoaderLoadImage(const GP_Loader *self, const char *src_path, +GP_Pixmap *GP_LoaderLoadImage(const GP_Loader *self, const char *src_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -247,17 +247,17 @@ link:http://www.libpng.org/[libpng library]. /* or */ #include -GP_Context *GP_ReadPNG(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPNG(GP_IO *io, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Reads a 'PNG' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'PNG' file signature. -Returns newly allocated context (containing decompressed image) or in case of +Returns newly allocated pixmap (containing decompressed image) or in case of failure NULL and errno is set. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -265,7 +265,7 @@ link:context.html#ContextFree[GP_ContextFree()]. /* or */ #include -GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Loads a 'PNG' image from a file. @@ -273,8 +273,8 @@ Loads a 'PNG' image from a file. Returns a pointer to newly allocated loaded image, or in case of failure NULL and errno is set. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -282,11 +282,11 @@ link:context.html#ContextFree[GP_ContextFree()]. /* or */ #include -int GP_SavePNG(const GP_Context *src, const char *dst_path, +int GP_SavePNG(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Saves a link:context.html[Context] as a 'PNG' image, in case particular pixel +Saves a link:pixmap.html[Pixmap] as a 'PNG' image, in case particular pixel type is not supported non-zero is returned and errno is set to 'ENOSYS'. Supports 'G1', 'G2', 'G4', 'G8', 'G16', and 8-bit 'RGB' and 'RGBA' pixel @@ -314,17 +314,17 @@ The 'JPEG' image support is implemented by the jpeg library. /* or */ #include -GP_Context *GP_ReadJPG(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadJPG(GP_IO *io, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Reads a 'JPEG' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'JPEG' file signature. -Returns newly allocated context (containing decompressed image) or in case of +Returns newly allocated pixmap (containing decompressed image) or in case of failure NULL and errno is set. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -332,7 +332,7 @@ link:context.html#ContextFree[GP_ContextFree()]. /* or */ #include -GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Loads a 'JPEG' image from a file. @@ -340,8 +340,8 @@ Loads a 'JPEG' image from a file. Returns a pointer to newly allocated loaded image, or in case of failure NULL and errno is set. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -349,11 +349,11 @@ link:context.html#ContextFree[GP_ContextFree()]. /* or */ #include -int GP_SaveJPG(const GP_Context *src, const char *dst_path, +int GP_SaveJPG(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Saves a link:context.html[Context] as a 'JPEG' image. +Saves a link:pixmap.html[Pixmap] as a 'JPEG' image. The 'JPEG' format could store either 'G8' or 8-bit 'RGB' pixel-types. @@ -380,17 +380,17 @@ The 'JPEG 2000' image support is implemented using the openjpeg library. /* or */ #include -GP_Context *GP_ReadJP2(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadJP2(GP_IO *io, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Reads a 'JPEG2000' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'JPEG2000' file signature. -Returns newly allocated context (containing decompressed image) or in case of +Returns newly allocated pixmap (containing decompressed image) or in case of failure NULL and errno is set. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. NOTE: Due to limitations of the openjpeg library progress callback does not work. @@ -400,13 +400,13 @@ NOTE: Due to limitations of the openjpeg library progress callback does not work /* or */ #include -GP_Context *GP_LoadJP2(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadJP2(const char *src_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Loads a 'JPEG2000' image from a file. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. NOTE: Due to limitations of the openjpeg library progress callback does not work. @@ -435,17 +435,17 @@ link:http://sourceforge.net/projects/giflib/[giflib library]. /* or */ #include -GP_Context *GP_ReadGIF(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadGIF(GP_IO *io, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Reads a 'GIF' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'GIF' file signature. -Returns newly allocated context (containing decompressed image) or in case of +Returns newly allocated pixmap (containing decompressed image) or in case of failure NULL and errno is set. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. NOTE: Currently this function loads only first image from the 'GIF' container. @@ -455,13 +455,13 @@ NOTE: Currently this function loads only first image from the 'GIF' container. /* or */ #include -GP_Context *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Loads a 'GIF' image from a file. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -488,17 +488,17 @@ be exotic RGB compressions (RGB101010 for example) and RLE4 support. /* or */ #include -GP_Context *GP_ReadBMP(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadBMP(GP_IO *io, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Reads a 'BMP' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'BMP' file signature. -Returns newly allocated context (containing decompressed image) or in case of +Returns newly allocated pixmap (containing decompressed image) or in case of failure NULL and errno is set. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -506,13 +506,13 @@ link:context.html#ContextFree[GP_ContextFree()]. /* or */ #include -GP_Context *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Loads a 'BMP' image from a file. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -520,11 +520,11 @@ link:context.html#ContextFree[GP_ContextFree()]. /* or */ #include -int GP_SaveBMP(const GP_Context *src, const char *dst_path, +int GP_SaveBMP(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Saves a link:context.html[Context] as a 'BMP' image. +Saves a link:pixmap.html[Pixmap] as a 'BMP' image. Currently only 8-bit 'RGB' pixel types are supported. @@ -556,17 +556,17 @@ yet. /* or */ #include -GP_Context *GP_ReadTIFF(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadTIFF(GP_IO *io, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Reads a 'TIFF' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'TIFF' file signature. -Returns newly allocated context (containing decompressed image) or in case of +Returns newly allocated pixmap (containing decompressed image) or in case of failure NULL and errno is set. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -574,13 +574,13 @@ link:context.html#ContextFree[GP_ContextFree()]. /* or */ #include -GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Loads a 'TIFF' image from a file. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -588,11 +588,11 @@ link:context.html#ContextFree[GP_ContextFree()]. /* or */ #include -int GP_SaveTIFF(const GP_Context *src, const char *dst_path, +int GP_SaveTIFF(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Saves a link:context.html[Context] as a 'TIFF' image. +Saves a link:pixmap.html[Pixmap] as a 'TIFF' image. Supports 'G1', 'G2', 'G4' and 'G8' grayscale and 8-bit 'RGB' pixel types. @@ -622,18 +622,18 @@ The 'PSP' loader can load a composite image from a Paint Shop Pro Image Files. /* or */ #include -GP_Context *GP_ReadPSP(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPSP(GP_IO *io, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Reads a 'PSP' composite image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'PSP' file signature. -Returns newly allocated context (containing decompressed image) or in case of +Returns newly allocated pixmap (containing decompressed image) or in case of failure NULL and errno is set. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -641,13 +641,13 @@ link:context.html#ContextFree[GP_ContextFree()]. /* or */ #include -GP_Context *GP_LoadPSP(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPSP(const char *src_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Loads a composite image from a 'PSP' file. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -676,17 +676,17 @@ RGB). /* or */ #include -GP_Context *GP_ReadPSD(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPSD(GP_IO *io, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Reads a 'PSD' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'PSD' file signature. -Returns newly allocated context (containing decompressed image) or in case of +Returns newly allocated pixmap (containing decompressed image) or in case of failure NULL and errno is set. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -694,7 +694,7 @@ link:context.html#ContextFree[GP_ContextFree()]. /* or */ #include -GP_Context *GP_LoadPSD(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPSD(const char *src_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Loads a merged image (if present) from a 'PSD' file. @@ -705,8 +705,8 @@ type. Returns NULL (TODO ERRNO) if merged image is not present/supported and thumbnail is not present either. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -730,21 +730,21 @@ PNM Loaders /* or */ #include -GP_Context *GP_ReadPBM(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPBM(GP_IO *io, GP_ProgressCallback *callback); -GP_Context *GP_ReadPGM(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPGM(GP_IO *io, GP_ProgressCallback *callback); -GP_Context *GP_ReadPPM(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPPM(GP_IO *io, GP_ProgressCallback *callback); -GP_Context *GP_ReadPNM(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPNM(GP_IO *io, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Reads a ASCII or Rawbits (binary) 'PBM', 'PGM' and 'PPM' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the file signature. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -752,21 +752,21 @@ link:context.html#ContextFree[GP_ContextFree()]. /* or */ #include -GP_Context *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback); -GP_Context *GP_LoadPGM(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPGM(const char *src_path, GP_ProgressCallback *callback); -GP_Context *GP_LoadPPM(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPPM(const char *src_path, GP_ProgressCallback *callback); -GP_Context *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Loads either ASCII or Rawbits (binary) 'PBM', 'PGM' and 'PPM'. The 'PNM' loader can load all of them i.e. 'PBM', 'PGM' and 'PPM'. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -774,7 +774,7 @@ link:context.html#ContextFree[GP_ContextFree()]. /* or */ #include -GP_Context *GP_SavePBM(const GP_Context *src, const char *dst_path, +GP_Pixmap *GP_SavePBM(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -786,7 +786,7 @@ Saves 'G1' (1 bit grayscale) image as ASCII 'PBM'. /* or */ #include -GP_Context *GP_SavePGM(const GP_Context *src, const char *dst_path, +GP_Pixmap *GP_SavePGM(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -799,7 +799,7 @@ Saves 'G1', 'G2', 'G4' and 'G8' (1, 2, 4 and 8 bit grayscale) image as ASCII /* or */ #include -GP_Context *GP_SavePPM(const GP_Context *src, const char *dst_path, +GP_Pixmap *GP_SavePPM(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -811,7 +811,7 @@ Saves 'RGB888' (24 bit RGB) image as ASCII 'PPM'. /* or */ #include -GP_Context *GP_SavePNM(const GP_Context *src, const char *dst_path, +GP_Pixmap *GP_SavePNM(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- @@ -852,17 +852,17 @@ The 'PCX' loader can load ZSoft PCX images. /* or */ #include -GP_Context *GP_ReadPCX(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPCX(GP_IO *io, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Reads a 'PCX' image from readable 'GP_IO'. The link:loaders_io.html[IO stream] is expected to start exactly at the 'PCX' file signature. -Returns newly allocated context (containing decompressed image) or in case of +Returns newly allocated pixmap (containing decompressed image) or in case of failure NULL and errno is set. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- @@ -870,13 +870,13 @@ link:context.html#ContextFree[GP_ContextFree()]. /* or */ #include -GP_Context *GP_LoadPCX(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPCX(const char *src_path, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- Loads a 'PCX' image from a file. -The resulting link:context.html[Context] should be later freed with -link:context.html#ContextFree[GP_ContextFree()]. +The resulting link:pixmap.html[Pixmap] should be later freed with +link:pixmap.html#PixmapFree[GP_PixmapFree()]. [source,c] ------------------------------------------------------------------------------- diff --git a/doc/loaders_python.txt b/doc/loaders_python.txt index 5f230841..1b92bb67 100644 --- a/doc/loaders_python.txt +++ b/doc/loaders_python.txt @@ -3,7 +3,7 @@ Python Loaders module The python binding maps mostly to the C API with the 'GP_' prefix stripped. -Loaders adds support for loading and storing contexts into/from various image +Loaders adds support for loading and storing pixmaps into/from various image fomats. [source,python] diff --git a/doc/context.txt b/doc/pixmap.txt similarity index 65% rename from doc/context.txt rename to doc/pixmap.txt index 37287f7e..562ca4db 100644 --- a/doc/context.txt +++ b/doc/pixmap.txt @@ -1,7 +1,7 @@ -Drawing Context +Drawing Pixmap --------------- -The 'GP_Context' structure describes an 'in memory' pixmap. The structure +The 'GP_Pixmap' structure describes an 'in memory' pixmap. The structure contains all metadata needed for drawing, loaders and filters. Data Structure @@ -9,7 +9,7 @@ Data Structure [source,c] ------------------------------------------------------------------------------- -typedef struct GP_Context { +typedef struct GP_Pixmap { uint8_t *pixels; /* pointer to image pixels */ uint8_t bpp; /* pixel length in bits */ uint32_t bytes_per_row; @@ -18,7 +18,7 @@ typedef struct GP_Context { /* * Row bit offset. The offset is ignored for byte aligned pixels. * Basically it's used for non aligned pixels with combination - * with subcontextes. + * with subpixmapes. */ uint8_t offset; @@ -33,8 +33,8 @@ typedef struct GP_Context { uint8_t x_swap:1; /* mirror x */ uint8_t y_swap:1; /* mirror y */ uint8_t bit_endian:1; /* GP_BIT_ENDIAN */ - uint8_t free_pixels:1; /* if set GP_ContextFree() calls free on context->pixels */ -} GP_Context; + uint8_t free_pixels:1; /* if set GP_PixmapFree() calls free on pixmap->pixels */ +} GP_Pixmap; ------------------------------------------------------------------------------- The 'pixels' field points to the image data. @@ -47,7 +47,7 @@ stored in horizontal lines (each line contains 'w' pixels and there is 'h' lines). Each line is 'bytes_per_row' bytes long (which equals to 'w * bpp / 8' rouned up to the whole bytes). The first pixel may actually start at 'offset' bit in the first byte in each line (but only for some -<> for pixel types that are not byte aligned). +<> for pixel types that are not byte aligned). The link:pixels.html[pixel_type enumeration] defines in which format and how are pixel data stored in the 'pixels' buffer, i.e. organization and function @@ -59,7 +59,7 @@ moment (this will be fixed in subsequent releases). The bitfield at the the end of the structure describes image orientation (see below) and a flag that tell if 'pixels' data should be freed, which is -usefull for example for <>. +usefull for example for <>. Rotation ^^^^^^^^ @@ -76,8 +76,8 @@ If you really need drawing primitives that do not use the orientation flags, you could use variants with _Raw suffix (although this is not recommended). There are various helper macros for transforming coordinates and sizes in -'core/GP_Transform.h'. And context helper functions to "rotate" the flags -clock wise and counter clock wise as well as functions to get the context size +'core/GP_Transform.h'. And pixmap helper functions to "rotate" the flags +clock wise and counter clock wise as well as functions to get the pixmap size when taking into the account the width and height. [source,c] @@ -87,68 +87,68 @@ when taking into the account the width and height. #include /* Transforms point user coordinates to bitmap coordinates */ -GP_TRANSFORM_POINT(context, x, y) +GP_TRANSFORM_POINT(pixmap, x, y) /* Transforms rectangular area coordinates and size */ -GP_TRANSFORM_RECT(context, x, y, w, h) +GP_TRANSFORM_RECT(pixmap, x, y, w, h) /* Inverse transformation, bitmap coordinates to user coordinates */ -GP_RETRANSFORM_POINT(context, x, y) +GP_RETRANSFORM_POINT(pixmap, x, y) ------------------------------------------------------------------------------- [source,c] ------------------------------------------------------------------------------ -#include +#include /* or */ #include /* - * Rotate context flags clock wise. + * Rotate pixmap flags clock wise. */ -void GP_ContextRotateCW(GP_Context *context); +void GP_PixmapRotateCW(GP_Pixmap *pixmap); /* - * Rotate context flags counter clock wise. + * Rotate pixmap flags counter clock wise. */ -void GP_ContextRotateCCW(GP_Context *context); +void GP_PixmapRotateCCW(GP_Pixmap *pixmap); /* * Retruns 1 if rotation flags are equal. */ -int GP_ContextRotationEqual(const GP_Context *c1, const GP_Context *c2); +int GP_PixmapRotationEqual(const GP_Pixmap *c1, const GP_Pixmap *c2); /* - * Sets context rotation flags. + * Sets pixmap rotation flags. */ -void GP_ContextSetRotation(GP_Context *dst, int axes_swap, +void GP_PixmapSetRotation(GP_Pixmap *dst, int axes_swap, int x_swap, int y_swap); /* * Copies rotation flags. */ -void GP_ContextCopyRotation(const GP_Context *src, GP_Context *dst); +void GP_PixmapCopyRotation(const GP_Pixmap *src, GP_Pixmap *dst); /* - * Returns context width and height taking the rotation flags into the account. + * Returns pixmap width and height taking the rotation flags into the account. */ -GP_Size GP_ContextW(const GP_Context *context); -GP_Size GP_ContextH(const GP_Context *context); +GP_Size GP_PixmapW(const GP_Pixmap *pixmap); +GP_Size GP_PixmapH(const GP_Pixmap *pixmap); ------------------------------------------------------------------------------- -Basic context functions +Basic pixmap functions ~~~~~~~~~~~~~~~~~~~~~~~ [source,c] ------------------------------------------------------------------------------- -#include +#include /* or */ #include -GP_Context *GP_ContextInit(GP_Context *context, GP_Size w, GP_Size h, +GP_Pixmap *GP_PixmapInit(GP_Pixmap *pixmap, GP_Size w, GP_Size h, GP_PixelType type, void *pixels); ------------------------------------------------------------------------------- -Initialize given context accordingly to parameters, the rest of context +Initialize given pixmap accordingly to parameters, the rest of pixmap parameters are set to the default values (i.e. rotation flags are all set to zero, 'free_pixels' flag is not set). Number of bits per pixel and bytes per row are computed from the given pixel type and size. @@ -156,19 +156,19 @@ bytes per row are computed from the given pixel type and size. The 'pixels' pointer can be NULL and can be changed later manually (the call will *not* try to allocate the pixel memory automatically). -The function returns a pointer to the initialized context (i.e. the same +The function returns a pointer to the initialized pixmap (i.e. the same pointer you passed as second argument). [source,c] ------------------------------------------------------------------------------- -#include +#include /* or */ #include -GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type); +GP_Pixmap *GP_PixmapAlloc(GP_Size w, GP_Size h, GP_PixelType type); ------------------------------------------------------------------------------- -The 'GP_ContextAlloc()' allocates and initializes a context. +The 'GP_PixmapAlloc()' allocates and initializes a pixmap. The orientation flags are all set to zero, the 'free_pixels' flag is set and the rest of the metadata are calculated accordingly to width, height and @@ -177,11 +177,11 @@ appropriate size; the initial contents of the bitmap are undefined. [source,c] ------------------------------------------------------------------------------- -#include +#include /* or */ #include -enum GP_ContextCopyFlags { +enum GP_PixmapCopyFlags { /* * Copy bitmap pixels too. If not set pixels are uninitialized. */ @@ -192,13 +192,13 @@ enum GP_ContextCopyFlags { GP_COPY_WITH_ROTATION = 0x02, }; -GP_Context *GP_ContextCopy(const GP_Context *src, int flags); +GP_Pixmap *GP_PixmapCopy(const GP_Pixmap *src, int flags); ------------------------------------------------------------------------------- -The 'GP_ContextCopy()' allocates and initializes a copy of the context passed +The 'GP_PixmapCopy()' allocates and initializes a copy of the pixmap passed as arguments. -The call returns pointer to newly allocated context or in case of 'malloc()' +The call returns pointer to newly allocated pixmap or in case of 'malloc()' failure NULL. If 'GP_COPY_WITH_PIXELS' is set, the bitmap contents ('src->pixels') are also @@ -208,85 +208,85 @@ contents. If 'GP_COPY_WITH_ROTATION' is set rotation flags are copied; otherwise rotation flags are set to zero. -The 'free_pixels' flag for the resulting context is set. +The 'free_pixels' flag for the resulting pixmap is set. -[[ContextFree]] +[[PixmapFree]] [source,c] ------------------------------------------------------------------------------- -#include +#include /* or */ #include -void GP_ContextFree(GP_Context *context); +void GP_PixmapFree(GP_Pixmap *pixmap); ------------------------------------------------------------------------------- -Frees the context memory. +Frees the pixmap memory. If 'free_pixels' flag is set, the pixels buffer is freed too. If gamma pointer is not NULL the 'GP_GammaRelease()' is called. -[[Sub_Context]] -Subcontext +[[Sub_Pixmap]] +Subpixmap ~~~~~~~~~~ -A subcontext is a context that refers to a rectangular area within another -context. Subcontexts can be used as any other contexts (including subcontext +A subpixmap is a pixmap that refers to a rectangular area within another +pixmap. Subpixmaps can be used as any other pixmaps (including subpixmap creation). -WARNING: If you create overlaping subcontexts the result is undefined. +WARNING: If you create overlaping subpixmaps the result is undefined. -Calling 'GP_ContextFree()' on a allocated subcontext is safe; the bitmap is -not freed as it belongs to another context; it will be freed when the parent -context is freed (i.e. the 'free_pixels' flag is not set when creating -subcontext). +Calling 'GP_PixmapFree()' on a allocated subpixmap is safe; the bitmap is +not freed as it belongs to another pixmap; it will be freed when the parent +pixmap is freed (i.e. the 'free_pixels' flag is not set when creating +subpixmap). -CAUTION: The subcontext doesn't hold a reference to the original context, so - once the parent context is freed the subcontext pixels pointer is not +CAUTION: The subpixmap doesn't hold a reference to the original pixmap, so + once the parent pixmap is freed the subpixmap pixels pointer is not valid anymore. [source,c] ------------------------------------------------------------------------------- -#include +#include /* or */ #include -GP_Context *GP_SubContext(const GP_Context *context, GP_Context *subcontext, +GP_Pixmap *GP_SubPixmap(const GP_Pixmap *pixmap, GP_Pixmap *subpixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h); -GP_Context *GP_SubContextAlloc(const GP_Context *context, +GP_Pixmap *GP_SubPixmapAlloc(const GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h); ------------------------------------------------------------------------------- -Creates subcontext of a context. The rectangular area must fit into the parent -context. +Creates subpixmap of a pixmap. The rectangular area must fit into the parent +pixmap. -The 'GP_SubContext()' function initializes the passed pointer as a subcontext -of a context and returns pointer to the initialized subcontext (i.e. the same -pointer you passed as the subcontext parameter). +The 'GP_SubPixmap()' function initializes the passed pointer as a subpixmap +of a pixmap and returns pointer to the initialized subpixmap (i.e. the same +pointer you passed as the subpixmap parameter). -The 'GP_SubContextAlloc()' function allocates 'GP_Context' structure and -initializes it as a subcontext. This function may return NULL in case of -'malloc()' failure and the newly created context should be later freed with -'GP_ContextFree()'. +The 'GP_SubPixmapAlloc()' function allocates 'GP_Pixmap' structure and +initializes it as a subpixmap. This function may return NULL in case of +'malloc()' failure and the newly created pixmap should be later freed with +'GP_PixmapFree()'. Conversions ~~~~~~~~~~~ [source,c] ------------------------------------------------------------------------------- -#include +#include /* or */ #include -GP_Context *GP_ContextConvertAlloc(const GP_Context *src, +GP_Pixmap *GP_PixmapConvertAlloc(const GP_Pixmap *src, GP_PixelType dst_pixel_type); -GP_Context *GP_ContextConvert(const GP_Context *src, GP_Context *dst); +GP_Pixmap *GP_PixmapConvert(const GP_Pixmap *src, GP_Pixmap *dst); ------------------------------------------------------------------------------- -Converts a context to different pixel type. +Converts a pixmap to different pixel type. This is naive implementation that only multiplies/divides the pixel values. @@ -297,13 +297,13 @@ Misc [source,c] ------------------------------------------------------------------------------- -#include +#include /* or */ #include -void GP_ContextPrintInfo(const GP_Context *self); +void GP_PixmapPrintInfo(const GP_Pixmap *self); ------------------------------------------------------------------------------- -This function prints the content of a 'GP_Context' structure, in a readable +This function prints the content of a 'GP_Pixmap' structure, in a readable format, into the stdout. diff --git a/doc/text.txt b/doc/text.txt index e0264ff6..acaf8373 100644 --- a/doc/text.txt +++ b/doc/text.txt @@ -24,16 +24,16 @@ typedef enum GP_TextAlign { GP_VALIGN_BELOW = 0x40 /* below the point */ } GP_TextAlign; -void GP_Text(GP_Context *context, const GP_TextStyle *style, +void GP_Text(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel fg, GP_Pixel bg, const char *str); -GP_Size GP_Print(GP_Context *context, const GP_TextStyle *style, +GP_Size GP_Print(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel fg, GP_Pixel bg, const char *fmt, ...); -GP_Size GP_VPrint(GP_Context *context, const GP_TextStyle *style, +GP_Size GP_VPrint(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel fg, GP_Pixel bg, const char *fmt, va_list va); diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h index e54f3c69..f71b0f0a 100644 --- a/include/backends/GP_Backend.h +++ b/include/backends/GP_Backend.h @@ -42,7 +42,7 @@ #ifndef BACKENDS_GP_BACKEND_H #define BACKENDS_GP_BACKEND_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "input/GP_EventQueue.h" #include "input/GP_Timer.h" @@ -54,15 +54,15 @@ typedef struct GP_Backend { const char *name; /* - * Pointer to context app should draw to. + * Pointer to pixmap app should draw to. * * This MAY change upon a flip operation. */ - GP_Context *context; + GP_Pixmap *pixmap; /* * If display is buffered, this copies content - * of context onto display. + * of pixmap onto display. * * If display is not buffered, this is no-op (set to NULL). */ @@ -71,7 +71,7 @@ typedef struct GP_Backend { /* * Updates display rectangle. * - * In contrast to flip operation, the context + * In contrast to flip operation, the pixmap * must not change (this is intended for updating very small areas). * * If display is not buffered, this is no-op (set to NULL). @@ -246,7 +246,7 @@ static inline int GP_BackendSetCaption(GP_Backend *backend, * When the backend size matches the passed width and height, * no action is done. * - * Note that after calling this, the backend->context pointer may change. + * Note that after calling this, the backend->pixmap pointer may change. */ int GP_BackendResize(GP_Backend *backend, uint32_t w, uint32_t h); @@ -256,7 +256,7 @@ int GP_BackendResize(GP_Backend *backend, uint32_t w, uint32_t h); * received resize event. * * This will resize backend buffers. After this call returns the backend width - * height and context pointer are most likely different. + * height and pixmap pointer are most likely different. * * This function returns zero on succes. Non zero on failure. If it fails the * best action to take is to save application data and exit (as the backend diff --git a/include/backends/GP_SDL_Context.h b/include/backends/GP_SDL_Pixmap.h similarity index 82% rename from include/backends/GP_SDL_Context.h rename to include/backends/GP_SDL_Pixmap.h index 011273f0..c56b5976 100644 --- a/include/backends/GP_SDL_Context.h +++ b/include/backends/GP_SDL_Pixmap.h @@ -20,30 +20,30 @@ * * *****************************************************************************/ -#ifndef BACKENDS_GP_SDL_CONTEXT_H -#define BACKENDS_GP_SDL_CONTEXT_H +#ifndef BACKENDS_GP_SDL_PIXMAP_H +#define BACKENDS_GP_SDL_PIXMAP_H #include -#include +#include /* * This function lets you use GFXprim together with SDL. All you need to do - * is to initialize context from surface. The usage is as follows: + * is to initialize pixmap from surface. The usage is as follows: * * ... * - * GP_Context c; + * GP_Pixmap c; * - * if (GP_ContextFromSDLSurface(&c, surface)) { + * if (GP_PixmapFromSDLSurface(&c, surface)) { * error("Failed to match PIXEL_TYPE for given surface"); * exit(1); * } * * ... * - * Now you have initialized context that shares the pixel buffer with + * Now you have initialized pixmap that shares the pixel buffer with * the SDL surface. */ -int GP_ContextFromSDLSurface(GP_Context *c, const SDL_Surface *surf); +int GP_PixmapFromSDLSurface(GP_Pixmap *c, const SDL_Surface *surf); -#endif /* BACKENDS_GP_SDL_CONTEXT_H */ +#endif /* BACKENDS_GP_SDL_PIXMAP_H */ diff --git a/include/core/GP_Blit.h b/include/core/GP_Blit.h index caa41122..10687e84 100644 --- a/include/core/GP_Blit.h +++ b/include/core/GP_Blit.h @@ -43,49 +43,49 @@ * Blits rectangle from src defined by x0, y0, x1, y1 (x1, y1 included) to dst * starting on x2, y2. */ -void GP_BlitXYXY(const GP_Context *src, +void GP_BlitXYXY(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2); + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2); /* * Clipped variant. Could handle destination coordinates outside of the * destination rectangle (both possitive and negative). Source larger than * destination and so. */ -void GP_BlitXYXY_Clipped(const GP_Context *src, +void GP_BlitXYXY_Clipped(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2); + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2); /* * Blits rectangle from src defined by x0, y0, w0, h0 (uses w0 x h0 pixels) to * dst starting on x2, y2. */ -void GP_BlitXYWH(const GP_Context *src, +void GP_BlitXYWH(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, - GP_Context *dst, GP_Coord x1, GP_Coord y1); + GP_Pixmap *dst, GP_Coord x1, GP_Coord y1); /* * Clipped variant. Could handle destination coordinates outside of the * destination rectangle (both possitive and negative). Source larger than * destination and so. */ -void GP_BlitXYWH_Clipped(const GP_Context *src, +void GP_BlitXYWH_Clipped(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, - GP_Context *dst, GP_Coord x1, GP_Coord y1); + GP_Pixmap *dst, GP_Coord x1, GP_Coord y1); /* The default is XYWH */ -static inline void GP_Blit(const GP_Context *src, +static inline void GP_Blit(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, - GP_Context *dst, GP_Coord x1, GP_Coord y1) + GP_Pixmap *dst, GP_Coord x1, GP_Coord y1) { GP_BlitXYWH(src, x0, y0, w0, h0, dst, x1, y1); } -static inline void GP_Blit_Clipped(const GP_Context *src, +static inline void GP_Blit_Clipped(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, - GP_Context *dst, GP_Coord x1, GP_Coord y1) + GP_Pixmap *dst, GP_Coord x1, GP_Coord y1) { GP_BlitXYWH_Clipped(src, x0, y0, w0, h0, dst, x1, y1); } @@ -93,24 +93,24 @@ static inline void GP_Blit_Clipped(const GP_Context *src, /* * Same as GP_BlitXYXY but doesn't respect rotations. Faster (for now). */ -void GP_BlitXYXY_Raw(const GP_Context *src, +void GP_BlitXYXY_Raw(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2); + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2); /* * Same as GP_BlitXYWH but doesn't respect rotations. Faster (for now). */ -void GP_BlitXYWH_Raw(const GP_Context *src, +void GP_BlitXYWH_Raw(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, - GP_Context *dst, GP_Coord x2, GP_Coord y2); + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2); /* * Same as GP_Blit but doesn't respect rotations. Faster (for now). */ -static inline void GP_Blit_Raw(const GP_Context *src, +static inline void GP_Blit_Raw(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, - GP_Context *dst, GP_Coord x1, GP_Coord y1) + GP_Pixmap *dst, GP_Coord x1, GP_Coord y1) { GP_BlitXYWH_Raw(src, x0, y0, w0, h0, dst, x1, y1); } diff --git a/include/core/GP_Convert.gen.h.t b/include/core/GP_Convert.gen.h.t index ee266eaf..02fe86f0 100644 --- a/include/core/GP_Convert.gen.h.t +++ b/include/core/GP_Convert.gen.h.t @@ -84,7 +84,7 @@ @ end #include "GP_GetSetBits.h" -#include "GP_Context.h" +#include "GP_Pixmap.h" #include "GP_Pixel.h" @ diff --git a/include/core/GP_Convert.h b/include/core/GP_Convert.h index abf2df2a..29a1517a 100644 --- a/include/core/GP_Convert.h +++ b/include/core/GP_Convert.h @@ -24,7 +24,7 @@ #define CORE_GP_CONVERT_H #include "GP_Common.h" -#include "GP_Context.h" +#include "GP_Pixmap.h" #include "GP_Pixel.h" /* Generated headers */ @@ -77,23 +77,23 @@ 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. + * compatible with the specified pixmap. */ -static inline GP_Pixel GP_RGBToContextPixel(uint8_t r, uint8_t g, uint8_t b, - const GP_Context *context) +static inline GP_Pixel GP_RGBToPixmapPixel(uint8_t r, uint8_t g, uint8_t b, + const GP_Pixmap *pixmap) { - return GP_RGBToPixel(r, g, b, context->pixel_type); + return GP_RGBToPixel(r, g, b, pixmap->pixel_type); } /* * Converts a color specified by its R, G, B, A components to a pixel value - * compatible with the specified context. + * compatible with the specified pixmap. */ -static inline GP_Pixel GP_RGBAToContextPixel(uint8_t r, uint8_t g, +static inline GP_Pixel GP_RGBAToPixmapPixel(uint8_t r, uint8_t g, uint8_t b, uint8_t a, - const GP_Context *context) + const GP_Pixmap *pixmap) { - return GP_RGBAToPixel(r, g, b, a, context->pixel_type); + return GP_RGBAToPixel(r, g, b, a, pixmap->pixel_type); } /* @@ -106,12 +106,12 @@ static inline GP_Pixel GP_ConvertPixel(GP_Pixel pixel, GP_PixelType from, } /* - * Convert between pixel types of given contexts (excl. palette types) via + * Convert between pixel types of given pixmaps (excl. palette types) via * RGBA8888. */ -static inline GP_Pixel GP_ConvertContextPixel(GP_Pixel pixel, - const GP_Context *from, - const GP_Context *to) +static inline GP_Pixel GP_ConvertPixmapPixel(GP_Pixel pixel, + const GP_Pixmap *from, + const GP_Pixmap *to) { return GP_RGBA8888ToPixel(GP_PixelToRGBA8888(pixel, from->pixel_type), to->pixel_type); diff --git a/include/core/GP_Core.h b/include/core/GP_Core.h index bef68345..187e2006 100644 --- a/include/core/GP_Core.h +++ b/include/core/GP_Core.h @@ -38,8 +38,8 @@ /* Common building blocks */ #include "core/GP_Common.h" -/* Context ... */ -#include "core/GP_Context.h" +/* Pixmap ... */ +#include "core/GP_Pixmap.h" /* ... and it's trasformations */ #include "core/GP_Transform.h" diff --git a/include/core/GP_Debug.h b/include/core/GP_Debug.h index 0c6af6fd..42ab72e3 100644 --- a/include/core/GP_Debug.h +++ b/include/core/GP_Debug.h @@ -25,7 +25,7 @@ Debug message layer. Many places of the library uses debug messages to report warnings, bugs, or - generally important events (i.e. context has been allocated, filter function + generally important events (i.e. pixmap has been allocated, filter function has been called). Debug messages are printed into the stderr and could be redirected to custom diff --git a/include/core/GP_Fill.h b/include/core/GP_Fill.h index 4ef179bc..f318fe9a 100644 --- a/include/core/GP_Fill.h +++ b/include/core/GP_Fill.h @@ -24,8 +24,8 @@ #define CORE_GP_FILL_H /* - * Fills context with givel pixel value + * Fills pixmap with givel pixel value */ -void GP_Fill(GP_Context *context, GP_Pixel val); +void GP_Fill(GP_Pixmap *pixmap, GP_Pixel val); #endif /* CORE_GP_FILL_H */ diff --git a/include/core/GP_FnPerBpp.h b/include/core/GP_FnPerBpp.h index 8586468c..08e161ba 100644 --- a/include/core/GP_FnPerBpp.h +++ b/include/core/GP_FnPerBpp.h @@ -31,10 +31,10 @@ * y_xBPP, resp y_xBPP_LE (or _BE; the bit-endian) for x<8. * * The functions branch either on bpp and bit_endian, type of given - * GP_Context or given GP_PixelType. + * GP_Pixmap 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 pixmap/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,10 +47,10 @@ #include "GP_FnPerBpp.gen.h" /* - * Branch on GP_Context argument. + * Branch on GP_Pixmap argument. */ -#define GP_FN_PER_BPP_CONTEXT(FN_NAME, context, ...) \ - GP_FN_PER_BPP(FN_NAME, (context)->bpp, (context)->bit_endian, __VA_ARGS__) +#define GP_FN_PER_BPP_PIXMAP(FN_NAME, pixmap, ...) \ + GP_FN_PER_BPP(FN_NAME, (pixmap)->bpp, (pixmap)->bit_endian, __VA_ARGS__) /* * Branch on GP_PixelType argument. @@ -58,10 +58,10 @@ #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_Pixmap 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__) +#define GP_FN_RET_PER_BPP_PIXMAP(FN_NAME, pixmap, ...) \ + GP_FN_RET_PER_BPP(FN_NAME, (pixmap)->bpp, (pixmap)->bit_endian, __VA_ARGS__) /* * Branch on GP_PixelType argument. @@ -73,7 +73,7 @@ * Macros that gets MACRO template for drawing function and generates drawing * functions for each BPP. * - * This functions are later used by GP_FN_PER_BPP_CONTEXT() to generate one + * This functions are later used by GP_FN_PER_BPP_PIXMAP() to generate one * drawing function for all BPP Yay! */ #define GP_DEF_DRAW_FN_PER_BPP(fname, MACRO_NAME) \ @@ -83,6 +83,6 @@ GP_DEF_FN_PER_BPP(fname, MACRO_NAME, GP_HLine_Raw_) #define GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, bpp) \ - MACRO_NAME(fname##_##bpp, GP_Context *, GP_Pixel, fdraw##bpp) + MACRO_NAME(fname##_##bpp, GP_Pixmap *, GP_Pixel, fdraw##bpp) #endif /* GP_FN_PER_BPP_H */ diff --git a/include/core/GP_Gamma.h b/include/core/GP_Gamma.h index 6fffaacf..1d4918dc 100644 --- a/include/core/GP_Gamma.h +++ b/include/core/GP_Gamma.h @@ -58,7 +58,7 @@ /* - This code implements management functions for easy, per context, per + This code implements management functions for easy, per pixmap, per channel, gamma tables. The tables for particular gamma are reference counted. There is only one @@ -113,7 +113,7 @@ #include -#include "GP_Context.h" +#include "GP_Pixmap.h" typedef enum GP_CorrectionType { /* diff --git a/include/core/GP_GammaCorrection.h b/include/core/GP_GammaCorrection.h index 6c476871..37f9f3a7 100644 --- a/include/core/GP_GammaCorrection.h +++ b/include/core/GP_GammaCorrection.h @@ -61,7 +61,7 @@ #include -#include "GP_Context.h" +#include "GP_Pixmap.h" #include "GP_GammaCorrection.gen.h" diff --git a/include/core/GP_GammaPixel.gen.h.t b/include/core/GP_GammaPixel.gen.h.t index 14ace8a4..35a596fd 100644 --- a/include/core/GP_GammaPixel.gen.h.t +++ b/include/core/GP_GammaPixel.gen.h.t @@ -5,7 +5,7 @@ * Copyright (C) 2012-2014 Cyril Hrubis */ -#include "GP_Context.h" +#include "GP_Pixmap.h" #include "GP_GammaCorrection.h" @ for pt in pixeltypes: diff --git a/include/core/GP_GetPutPixel.gen.h.t b/include/core/GP_GetPutPixel.gen.h.t index 39c4d06c..24e5ca6e 100644 --- a/include/core/GP_GetPutPixel.gen.h.t +++ b/include/core/GP_GetPutPixel.gen.h.t @@ -49,17 +49,17 @@ */ #include "GP_GetSetBits.h" -#include "GP_Context.h" +#include "GP_Pixmap.h" @ for ps in pixelsizes: /* - * macro to get address of pixel in a {{ ps.suffix }} context + * macro to get address of pixel in a {{ ps.suffix }} pixmap */ -#define GP_PIXEL_ADDR_{{ ps.suffix }}(context, x, y) \ - ((GP_Pixel*)(((void*)((context)->pixels)) + (context)->bytes_per_row * (y) + ({{ ps.size }} * (x)) / 8)) +#define GP_PIXEL_ADDR_{{ ps.suffix }}(pixmap, x, y) \ + ((GP_Pixel*)(((void*)((pixmap)->pixels)) + (pixmap)->bytes_per_row * (y) + ({{ ps.size }} * (x)) / 8)) /* - * macro to get bit-offset of pixel in {{ ps.suffix }} context + * macro to get bit-offset of pixel in {{ ps.suffix }} pixmap */ #define GP_PIXEL_ADDR_OFFSET_{{ ps.suffix }}(x) \ @ if not ps.needs_bit_endian(): @@ -80,7 +80,7 @@ /* * GP_GetPixel for {{ ps.suffix }} */ -static inline GP_Pixel GP_GetPixel_Raw_{{ ps.suffix }}(const GP_Context *c, int x, int y) +static inline GP_Pixel GP_GetPixel_Raw_{{ ps.suffix }}(const GP_Pixmap *c, int x, int y) { @ if ps.size == 32: /* @@ -155,7 +155,7 @@ static inline GP_Pixel GP_GetPixel_Raw_{{ ps.suffix }}(const GP_Context *c, int /* * GP_PutPixel for {{ ps.suffix }} */ -static inline void GP_PutPixel_Raw_{{ ps.suffix }}(GP_Context *c, int x, int y, GP_Pixel p) +static inline void GP_PutPixel_Raw_{{ ps.suffix }}(GP_Pixmap *c, int x, int y, GP_Pixel p) { @ if ps.size == 32: /* @@ -227,7 +227,7 @@ static inline void GP_PutPixel_Raw_{{ ps.suffix }}(GP_Context *c, int x, int y, @ end } -static inline void GP_PutPixel_Raw_Clipped_{{ ps.suffix }}(GP_Context *c, GP_Coord x, GP_Coord y, GP_Pixel p) +static inline void GP_PutPixel_Raw_Clipped_{{ ps.suffix }}(GP_Pixmap *c, GP_Coord x, GP_Coord y, GP_Pixel p) { if (GP_PIXEL_IS_CLIPPED(c, x, y)) return; diff --git a/include/core/GP_GetPutPixel.h b/include/core/GP_GetPutPixel.h index 6faf7b2d..9e16d6fe 100644 --- a/include/core/GP_GetPutPixel.h +++ b/include/core/GP_GetPutPixel.h @@ -24,7 +24,7 @@ #ifndef CORE_GP_GETPUTPIXEL_H #define CORE_GP_GETPUTPIXEL_H -#include "GP_Context.h" +#include "GP_Pixmap.h" #include "GP_Transform.h" #include "GP_FnPerBpp.h" #include "GP_Pixel.h" @@ -35,59 +35,59 @@ #include "GP_GetPutPixel.gen.h" /* - * GetPixel with context transformations and clipping. + * GetPixel with pixmap transformations and clipping. * Returns 0 for clipped pixels or pixels outside bitmap. */ -GP_Pixel GP_GetPixel(const GP_Context *context, GP_Coord x, GP_Coord y); +GP_Pixel GP_GetPixel(const GP_Pixmap *pixmap, GP_Coord x, GP_Coord y); /* * Version of GetPixel without transformations nor border checking. */ -static inline GP_Pixel GP_GetPixel_Raw(const GP_Context *context, +static inline GP_Pixel GP_GetPixel_Raw(const GP_Pixmap *pixmap, GP_Coord x, GP_Coord y) { - GP_FN_RET_PER_BPP(GP_GetPixel_Raw, context->bpp, context->bit_endian, - context, x, y); + GP_FN_RET_PER_BPP(GP_GetPixel_Raw, pixmap->bpp, pixmap->bit_endian, + pixmap, x, y); - GP_ABORT("Invalid context pixel type"); + GP_ABORT("Invalid pixmap pixel type"); } /* * Version of GetPixel without transformations and with border checking. */ -static inline GP_Pixel GP_GetPixel_Raw_Clipped(const GP_Context *context, +static inline GP_Pixel GP_GetPixel_Raw_Clipped(const GP_Pixmap *pixmap, GP_Coord x, GP_Coord y) { - if (GP_PIXEL_IS_CLIPPED(context, x, y)) + if (GP_PIXEL_IS_CLIPPED(pixmap, x, y)) return 0; - return GP_GetPixel_Raw(context, x, y); + return GP_GetPixel_Raw(pixmap, x, y); } /* - * PutPixel with context transformations and clipping. + * PutPixel with pixmap transformations and clipping. * NOP for clipped pixels or pixels outside bitmap. */ -void GP_PutPixel(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel p); +void GP_PutPixel(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel p); /* * Version of PutPixel without transformations nor border checking. */ -static inline void GP_PutPixel_Raw(GP_Context *context, +static inline void GP_PutPixel_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel p) { - GP_FN_PER_BPP(GP_PutPixel_Raw, context->bpp, context->bit_endian, - context, x, y, p); + GP_FN_PER_BPP(GP_PutPixel_Raw, pixmap->bpp, pixmap->bit_endian, + pixmap, x, y, p); } /* * Version of PutPixel without transformation and with border checking. */ -static inline void GP_PutPixel_Raw_Clipped(GP_Context *context, +static inline void GP_PutPixel_Raw_Clipped(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel p) { - GP_FN_PER_BPP(GP_PutPixel_Raw_Clipped, context->bpp, context->bit_endian, - context, x, y, p); + GP_FN_PER_BPP(GP_PutPixel_Raw_Clipped, pixmap->bpp, pixmap->bit_endian, + pixmap, x, y, p); } /* diff --git a/include/core/GP_MixPixels.gen.h.t b/include/core/GP_MixPixels.gen.h.t index 518ed9bc..5d06e43a 100644 --- a/include/core/GP_MixPixels.gen.h.t +++ b/include/core/GP_MixPixels.gen.h.t @@ -5,7 +5,7 @@ * Copyright (C) 2011-2014 Cyril Hrubis */ -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_Pixel.h" #include "core/GP_GetPutPixel.h" #include "core/GP_GammaCorrection.h" @@ -74,37 +74,37 @@ static inline GP_Pixel GP_MixPixels(GP_Pixel pix1, GP_Pixel pix2, @ for pt in pixeltypes: @ if not pt.is_unknown(): -static inline void GP_MixPixel_Raw_{{ pt.name }}(GP_Context *context, +static inline void GP_MixPixel_Raw_{{ pt.name }}(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel pixel, uint8_t perc) { - GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(context, x, y); + GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(pixmap, x, y); pix = GP_MIX_PIXELS_{{ pt.name }}(pixel, pix, perc); - GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(context, x, y, pix); + GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(pixmap, x, y, pix); } @ end @ for pt in pixeltypes: @ if not pt.is_unknown(): -static inline void GP_MixPixel_Raw_Clipped_{{ pt.name }}(GP_Context *context, +static inline void GP_MixPixel_Raw_Clipped_{{ pt.name }}(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel pixel, uint8_t perc) { - if (GP_PIXEL_IS_CLIPPED(context, x, y)) + if (GP_PIXEL_IS_CLIPPED(pixmap, x, y)) return; - GP_MixPixel_Raw_{{ pt.name }}(context, x, y, pixel, perc); + GP_MixPixel_Raw_{{ pt.name }}(pixmap, x, y, pixel, perc); } @ end -static inline void GP_MixPixel_Raw(GP_Context *context, GP_Coord x, GP_Coord y, +static inline void GP_MixPixel_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel pixel, uint8_t perc) { - switch (context->pixel_type) { + switch (pixmap->pixel_type) { @ for pt in pixeltypes: @ if not pt.is_unknown(): case GP_PIXEL_{{ pt.name }}: - GP_MixPixel_Raw_{{ pt.name }}(context, x, y, pixel, perc); + GP_MixPixel_Raw_{{ pt.name }}(pixmap, x, y, pixel, perc); break; @ end default: @@ -112,15 +112,15 @@ static inline void GP_MixPixel_Raw(GP_Context *context, GP_Coord x, GP_Coord y, } } -static inline void GP_MixPixel_Raw_Clipped(GP_Context *context, +static inline void GP_MixPixel_Raw_Clipped(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel pixel, uint8_t perc) { - switch (context->pixel_type) { + switch (pixmap->pixel_type) { @ for pt in pixeltypes: @ if not pt.is_unknown(): case GP_PIXEL_{{ pt.name }}: - GP_MixPixel_Raw_Clipped_{{ pt.name }}(context, x, y, pixel, perc); + GP_MixPixel_Raw_Clipped_{{ pt.name }}(pixmap, x, y, pixel, perc); break; @ end default: diff --git a/include/core/GP_Pixel.gen.h.t b/include/core/GP_Pixel.gen.h.t index 23aa3ab9..50b2c8d7 100644 --- a/include/core/GP_Pixel.gen.h.t +++ b/include/core/GP_Pixel.gen.h.t @@ -42,9 +42,9 @@ typedef enum GP_PixelType { @ end /* - * macros to get address and bit-offset of a pixel {{ pt.name }} in a context + * macros to get address and bit-offset of a pixel {{ pt.name }} in a pixmap */ -#define GP_PIXEL_ADDR_{{ pt.name }}(context, x, y) GP_PIXEL_ADDR_{{ pt.pixelsize.suffix }}(context, x, y) +#define GP_PIXEL_ADDR_{{ pt.name }}(pixmap, x, y) GP_PIXEL_ADDR_{{ pt.pixelsize.suffix }}(pixmap, x, y) #define GP_PIXEL_ADDR_OFFSET_{{ pt.name }}(x) GP_PIXEL_ADDR_OFFSET_{{ pt.pixelsize.suffix }}(x) /* diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h index 1f11a590..3270a78c 100644 --- a/include/core/GP_Pixel.h +++ b/include/core/GP_Pixel.h @@ -34,7 +34,7 @@ #include "GP_Common.h" #include "GP_FnPerBpp.h" -struct GP_Context; +struct GP_Pixmap; /* * GP_PixelType is typedef enum of PixelTypes, @@ -59,7 +59,7 @@ typedef uint32_t GP_Pixel; /* * Information about ordering of pixels in byte for 1, 2 and 4 bpp - * used in a one bit variable in GP_Context + * used in a one bit variable in GP_Pixmap */ typedef enum { /* less significant bits contain pixels with lower indices */ diff --git a/include/core/GP_Context.h b/include/core/GP_Pixmap.h similarity index 59% rename from include/core/GP_Context.h rename to include/core/GP_Pixmap.h index a5755223..f67e6ec2 100644 --- a/include/core/GP_Context.h +++ b/include/core/GP_Pixmap.h @@ -23,8 +23,8 @@ * * *****************************************************************************/ -#ifndef CORE_GP_CONTEXT_H -#define CORE_GP_CONTEXT_H +#ifndef CORE_GP_PIXMAP_H +#define CORE_GP_PIXMAP_H #include #include @@ -36,7 +36,7 @@ struct GP_Gamma; /* This structure holds all information needed for drawing into an image. */ -typedef struct GP_Context { +typedef struct GP_Pixmap { uint8_t *pixels; /* pointer to image pixels */ uint8_t bpp; /* pixel size in bits */ uint32_t bytes_per_row; @@ -45,7 +45,7 @@ typedef struct GP_Context { /* * Row bit offset. The offset is ignored for byte aligned pixels. * Basically it's used for non aligned pixels with combination - * with subcontextes. + * with subpixmapes. */ uint8_t offset; @@ -71,72 +71,72 @@ typedef struct GP_Context { uint8_t x_swap:1; /* swap direction on x */ uint8_t y_swap:1; /* swap direction on y */ uint8_t bit_endian:1; /* GP_BIT_ENDIAN */ - uint8_t free_pixels:1; /* If set pixels are freed on GP_ContextFree */ -} GP_Context; + uint8_t free_pixels:1; /* If set pixels are freed on GP_PixmapFree */ +} GP_Pixmap; -/* Determines the address of a pixel within the context's image. +/* Determines the address of a pixel within the pixmap's image. * Rows and columns are specified in the image's orientation * (i.e. they might not be XY if the image is rotated). */ -#define GP_PIXEL_ADDR(context, x, y) ((context)->pixels \ - + (y) * (context)->bytes_per_row \ - + ((x) * (context)->bpp) / 8) +#define GP_PIXEL_ADDR(pixmap, x, y) ((pixmap)->pixels \ + + (y) * (pixmap)->bytes_per_row \ + + ((x) * (pixmap)->bpp) / 8) #define GP_CALC_ROW_SIZE(pixel_type, width) \ ((GP_PixelSize(pixel_type) * width) / 8 + \ !!((GP_PixelSize(pixel_type) * width) % 8)) -/* Performs a series of sanity checks on context, aborting if any fails. */ -#define GP_CHECK_CONTEXT(context) do { \ - GP_CHECK(context, "NULL passed as context"); \ - GP_CHECK(context->pixels, "invalid context: NULL image pointer"); \ - GP_CHECK(context->bpp <= 32, "invalid context: unsupported bits-per-pixel count"); \ - GP_CHECK(context->w > 0 && context->h > 0, "invalid context: invalid image size"); \ +/* Performs a series of sanity checks on pixmap, aborting if any fails. */ +#define GP_CHECK_PIXMAP(pixmap) do { \ + GP_CHECK(pixmap, "NULL passed as pixmap"); \ + GP_CHECK(pixmap->pixels, "invalid pixmap: NULL image pointer"); \ + GP_CHECK(pixmap->bpp <= 32, "invalid pixmap: unsupported bits-per-pixel count"); \ + GP_CHECK(pixmap->w > 0 && pixmap->h > 0, "invalid pixmap: invalid image size"); \ } while (0) /* - * Is true, when pixel is clipped out of context. + * Is true, when pixel is clipped out of pixmap. */ -#define GP_PIXEL_IS_CLIPPED(context, x, y) \ - ((x) < 0 || x >= (typeof(x)) context->w \ - || (y) < 0 || y >= (typeof(y)) context->h) \ +#define GP_PIXEL_IS_CLIPPED(pixmap, x, y) \ + ((x) < 0 || x >= (typeof(x)) pixmap->w \ + || (y) < 0 || y >= (typeof(y)) pixmap->h) \ /* - * Allocate context. + * Allocate pixmap. * - * The context consists of two parts, the GP_Context structure and pixels array. + * The pixmap consists of two parts, the GP_Pixmap structure and pixels array. * * The rotation flags are set to (0, 0, 0). */ -GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type); +GP_Pixmap *GP_PixmapAlloc(GP_Size w, GP_Size h, GP_PixelType type); /* - * Free context. + * Free pixmap. * - * If context->free_pixels, also free pixel data. + * If pixmap->free_pixels, also free pixel data. */ -void GP_ContextFree(GP_Context *context); +void GP_PixmapFree(GP_Pixmap *pixmap); /* - * Initalize context, pixels pointer is not dereferenced so it's safe to pass - * NULL there and allocate it later with size context->bpr * context->h. + * Initalize pixmap, pixels pointer is not dereferenced so it's safe to pass + * NULL there and allocate it later with size pixmap->bpr * pixmap->h. * * The returned pointer is the pointer you passed as first argument. */ -GP_Context *GP_ContextInit(GP_Context *context, GP_Size w, GP_Size h, +GP_Pixmap *GP_PixmapInit(GP_Pixmap *pixmap, GP_Size w, GP_Size h, GP_PixelType type, void *pixels); /* - * Resizes context->pixels array and changes metadata to match the new size. + * Resizes pixmap->pixels array and changes metadata to match the new size. * * Returns non-zero on failure (malloc() has failed). * * This call only resizes the pixel array. The pixel values, after resizing, * are __UNINITALIZED__ use resampling filters to resize image data. */ -int GP_ContextResize(GP_Context *context, GP_Size w, GP_Size h); +int GP_PixmapResize(GP_Pixmap *pixmap, GP_Size w, GP_Size h); -enum GP_ContextCopyFlags { +enum GP_PixmapCopyFlags { /* * Copy bitmap pixels too. If not set pixels are uninitalized. */ @@ -148,63 +148,63 @@ enum GP_ContextCopyFlags { }; /* - * Allocates a contex with exactly same values as source context. + * Allocates a contex with exactly same values as source pixmap. */ -GP_Context *GP_ContextCopy(const GP_Context *src, int flags); +GP_Pixmap *GP_PixmapCopy(const GP_Pixmap *src, int flags); /* - * Initalize subcontext. The returned pointer points to passed subcontext. + * Initalize subpixmap. The returned pointer points to passed subpixmap. */ -GP_Context *GP_SubContext(const GP_Context *context, GP_Context *subcontext, +GP_Pixmap *GP_SubPixmap(const GP_Pixmap *pixmap, GP_Pixmap *subpixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h); /* - * Allocate and initalize subcontext. + * Allocate and initalize subpixmap. * - * The free_pixels flag is set to 0 upon subcontext initalization so the - * GP_ContextFree() would not call free() upon the subcontext->pixels pointer. + * The free_pixels flag is set to 0 upon subpixmap initalization so the + * GP_PixmapFree() would not call free() upon the subpixmap->pixels pointer. */ -GP_Context *GP_SubContextAlloc(const GP_Context *context, +GP_Pixmap *GP_SubPixmapAlloc(const GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h); /* - * Converts context to a different pixel type. - * Returns a newly allocated context. + * Converts pixmap to a different pixel type. + * Returns a newly allocated pixmap. * * This is naive implementation that doesn't do any ditherings or error * diffusions. */ -GP_Context *GP_ContextConvertAlloc(const GP_Context *src, +GP_Pixmap *GP_PixmapConvertAlloc(const GP_Pixmap *src, GP_PixelType dst_pixel_type); /* - * Converts context to a different pixel type. + * Converts pixmap to a different pixel type. * * This is naive implementation that doesn't do any ditherings or error * diffusions. */ -GP_Context *GP_ContextConvert(const GP_Context *src, GP_Context *dst); +GP_Pixmap *GP_PixmapConvert(const GP_Pixmap *src, GP_Pixmap *dst); /* - * Prints context information into stdout. + * Prints pixmap information into stdout. */ -void GP_ContextPrintInfo(const GP_Context *self); +void GP_PixmapPrintInfo(const GP_Pixmap *self); /* - * Rotates context flags clock wise. + * Rotates pixmap flags clock wise. */ -void GP_ContextRotateCW(GP_Context *context); +void GP_PixmapRotateCW(GP_Pixmap *pixmap); /* - * Rotates context flags counter clock wise. + * Rotates pixmap flags counter clock wise. */ -void GP_ContextRotateCCW(GP_Context *context); +void GP_PixmapRotateCCW(GP_Pixmap *pixmap); /* * Retruns 1 if rotation flags are equal. */ -static inline int GP_ContextRotationEqual(const GP_Context *c1, - const GP_Context *c2) +static inline int GP_PixmapRotationEqual(const GP_Pixmap *c1, + const GP_Pixmap *c2) { return c1->axes_swap == c2->axes_swap && c1->x_swap == c2->x_swap && @@ -214,7 +214,7 @@ static inline int GP_ContextRotationEqual(const GP_Context *c1, /* * Sets rotation flags. */ -static inline void GP_ContextSetRotation(GP_Context *dst, int axes_swap, +static inline void GP_PixmapSetRotation(GP_Pixmap *dst, int axes_swap, int x_swap, int y_swap) { dst->axes_swap = axes_swap; @@ -225,8 +225,8 @@ static inline void GP_ContextSetRotation(GP_Context *dst, int axes_swap, /* * Copies rotation flags. */ -static inline void GP_ContextCopyRotation(const GP_Context *src, - GP_Context *dst) +static inline void GP_PixmapCopyRotation(const GP_Pixmap *src, + GP_Pixmap *dst) { dst->axes_swap = src->axes_swap; dst->x_swap = src->x_swap; @@ -234,26 +234,26 @@ static inline void GP_ContextCopyRotation(const GP_Context *src, } /* - * Returns context width and height taking the rotation flags into a account. + * Returns pixmap width and height taking the rotation flags into a account. */ -static inline GP_Size GP_ContextW(const GP_Context *context) +static inline GP_Size GP_PixmapW(const GP_Pixmap *pixmap) { - if (context->axes_swap) - return context->h; + if (pixmap->axes_swap) + return pixmap->h; else - return context->w; + return pixmap->w; } -static inline GP_Size GP_ContextH(const GP_Context *context) +static inline GP_Size GP_PixmapH(const GP_Pixmap *pixmap) { - if (context->axes_swap) - return context->w; + if (pixmap->axes_swap) + return pixmap->w; else - return context->h; + return pixmap->h; } /* - * Compare two contexts. Returns true only if all of types, sizes and + * Compare two pixmaps. Returns true only if all of types, sizes and * bitmap data match. Takes transformations into account. * * For now ignores gamma tables. @@ -262,7 +262,7 @@ static inline GP_Size GP_ContextH(const GP_Context *context) * TODO: speed up for same rotation and same bit-offset data (per-row memcpy). */ -int GP_ContextEqual(const GP_Context *ctx1, const GP_Context *ctx2); +int GP_PixmapEqual(const GP_Pixmap *pixmap1, const GP_Pixmap *pixmap2); -#endif /* CORE_GP_CONTEXT_H */ +#endif /* CORE_GP_PIXMAP_H */ diff --git a/include/core/GP_Transform.h b/include/core/GP_Transform.h index 5915c892..5e21ab9c 100644 --- a/include/core/GP_Transform.h +++ b/include/core/GP_Transform.h @@ -32,81 +32,81 @@ #include "GP_FixedPoint.h" /* - * Flip a coordinate within context according to context transformation. + * Flip a coordinate within pixmap according to pixmap transformation. */ -#define GP_TRANSFORM_X(context, x) do { \ - if ((context)->x_swap) \ - x = (context)->w - x - 1; \ +#define GP_TRANSFORM_X(pixmap, x) do { \ + if ((pixmap)->x_swap) \ + x = (pixmap)->w - x - 1; \ } while (0) -#define GP_TRANSFORM_Y(context, y) do { \ - if ((context)->y_swap) \ - y = (context)->h - y - 1; \ +#define GP_TRANSFORM_Y(pixmap, y) do { \ + if ((pixmap)->y_swap) \ + y = (pixmap)->h - y - 1; \ } while (0) /* * Fixed point variants. */ -#define GP_TRANSFORM_X_FP(context, x) do { \ - if ((context)->x_swap) \ - x = GP_FP_FROM_INT((context)->w - 1) - x; \ +#define GP_TRANSFORM_X_FP(pixmap, x) do { \ + if ((pixmap)->x_swap) \ + x = GP_FP_FROM_INT((pixmap)->w - 1) - x; \ } while (0) -#define GP_TRANSFORM_Y_FP(context, y) do { \ - if ((context)->y_swap) \ - y = GP_FP_FROM_INT((context)->h - 1) - y; \ +#define GP_TRANSFORM_Y_FP(pixmap, y) do { \ + if ((pixmap)->y_swap) \ + y = GP_FP_FROM_INT((pixmap)->h - 1) - y; \ } while (0) /* - * Swap coordinates (axes) according to context transformation. + * Swap coordinates (axes) according to pixmap transformation. */ -#define GP_TRANSFORM_SWAP(context, x, y) do { \ - if ((context)->axes_swap) \ +#define GP_TRANSFORM_SWAP(pixmap, x, y) do { \ + if ((pixmap)->axes_swap) \ GP_SWAP(x, y); \ } while (0) /* - * Transform "user"-coordinates to "real"-coordinates according to context + * Transform "user"-coordinates to "real"-coordinates according to pixmap * transformation. */ -#define GP_TRANSFORM_POINT(context, x, y) do { \ - GP_TRANSFORM_SWAP(context, x, y); \ - GP_TRANSFORM_X(context, x); \ - GP_TRANSFORM_Y(context, y); \ +#define GP_TRANSFORM_POINT(pixmap, x, y) do { \ + GP_TRANSFORM_SWAP(pixmap, x, y); \ + GP_TRANSFORM_X(pixmap, x); \ + GP_TRANSFORM_Y(pixmap, y); \ } while (0) -#define GP_TRANSFORM_POINT_FP(context, x, y) do { \ - GP_TRANSFORM_SWAP(context, x, y); \ - GP_TRANSFORM_X_FP(context, x); \ - GP_TRANSFORM_Y_FP(context, y); \ +#define GP_TRANSFORM_POINT_FP(pixmap, x, y) do { \ + GP_TRANSFORM_SWAP(pixmap, x, y); \ + GP_TRANSFORM_X_FP(pixmap, x); \ + GP_TRANSFORM_Y_FP(pixmap, y); \ } while (0) /* * Transform "user"-coordinates to "real"-coordinates of a rectangle corner - * according to context transformation. Corner with min-coordinates is + * according to pixmap 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 { \ - GP_TRANSFORM_SWAP(context, x, y); \ - GP_TRANSFORM_SWAP(context, w, h); \ +#define GP_TRANSFORM_RECT(pixmap, x, y, w, h) do { \ + GP_TRANSFORM_SWAP(pixmap, x, y); \ + GP_TRANSFORM_SWAP(pixmap, w, h); \ \ - if ((context)->x_swap) \ - x = (context)->w - x - w; \ + if ((pixmap)->x_swap) \ + x = (pixmap)->w - x - w; \ \ - if ((context)->y_swap) \ - y = (context)->h - y - h; \ + if ((pixmap)->y_swap) \ + y = (pixmap)->h - y - h; \ } while (0) -#define GP_TRANSFORM_RECT_FP(context, x, y, w, h) do { \ - GP_TRANSFORM_SWAP(context, x, y); \ - GP_TRANSFORM_SWAP(context, w, h); \ +#define GP_TRANSFORM_RECT_FP(pixmap, x, y, w, h) do { \ + GP_TRANSFORM_SWAP(pixmap, x, y); \ + GP_TRANSFORM_SWAP(pixmap, w, h); \ \ - if ((context)->x_swap) \ - x = GP_FP_FROM_INT((context)->w) - x - w; \ + if ((pixmap)->x_swap) \ + x = GP_FP_FROM_INT((pixmap)->w) - x - w; \ \ - if ((context)->y_swap) \ - y = GP_FP_FROM_INT((context)->h) - y - h; \ + if ((pixmap)->y_swap) \ + y = GP_FP_FROM_INT((pixmap)->h) - y - h; \ } while (0) /* @@ -123,12 +123,12 @@ /* * Inverse transformation to GP_TRANSFORM_POINT. - * Use for translating mouse pointer coordinates to coordinates on context. + * Use for translating mouse pointer coordinates to coordinates on pixmap. */ -#define GP_RETRANSFORM_POINT(context, x, y) do { \ - GP_TRANSFORM_X(context, x); \ - GP_TRANSFORM_Y(context, y); \ - GP_TRANSFORM_SWAP(context, x, y); \ +#define GP_RETRANSFORM_POINT(pixmap, x, y) do { \ + GP_TRANSFORM_X(pixmap, x); \ + GP_TRANSFORM_Y(pixmap, y); \ + GP_TRANSFORM_SWAP(pixmap, x, y); \ } while (0) #endif /* CORE_GP_TRANSFORM_H */ diff --git a/include/filters/GP_ApplyTables.h b/include/filters/GP_ApplyTables.h index 93d1eac7..7941b35b 100644 --- a/include/filters/GP_ApplyTables.h +++ b/include/filters/GP_ApplyTables.h @@ -22,7 +22,7 @@ /* - Applies per-channel tables on a context pixels. Used for fast point filters + Applies per-channel tables on a pixmap pixels. Used for fast point filters implementation. */ @@ -43,10 +43,10 @@ typedef struct GP_FilterTables { /* * Generic point filter, applies corresponding table on bitmap. */ -int GP_FilterTablesApply(const GP_Context *const src, +int GP_FilterTablesApply(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, const GP_FilterTables *const tables, GP_ProgressCallback *callback); @@ -54,12 +54,12 @@ int GP_FilterTablesApply(const GP_Context *const src, /* * Aloocates and initializes tables. */ -int GP_FilterTablesInit(GP_FilterTables *self, const GP_Context *ctx); +int GP_FilterTablesInit(GP_FilterTables *self, const GP_Pixmap *pixmap); /* * Allocates and initializes table structure and tables. */ -GP_FilterTables *GP_FilterTablesAlloc(const GP_Context *ctx); +GP_FilterTables *GP_FilterTablesAlloc(const GP_Pixmap *pixmap); /* * Frees point filter tables. diff --git a/include/filters/GP_Arithmetic.h b/include/filters/GP_Arithmetic.h index 47fca477..e2966296 100644 --- a/include/filters/GP_Arithmetic.h +++ b/include/filters/GP_Arithmetic.h @@ -36,13 +36,13 @@ * * Produces saturated (clamped) addtion. */ -int GP_FilterAddition(const GP_Context *src_a, - const GP_Context *src_b, - GP_Context *dst, +int GP_FilterAddition(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, + GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterAdditionAlloc(const GP_Context *src_a, - const GP_Context *src_b, +GP_Pixmap *GP_FilterAdditionAlloc(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, GP_ProgressCallback *callback); /* @@ -50,13 +50,13 @@ GP_Context *GP_FilterAdditionAlloc(const GP_Context *src_a, * * Produces saturated (clamped) multiplication. */ -int GP_FilterMultiply(const GP_Context *src_a, - const GP_Context *src_b, - GP_Context *dst, +int GP_FilterMultiply(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, + GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterMultiplyAlloc(const GP_Context *src_a, - const GP_Context *src_b, +GP_Pixmap *GP_FilterMultiplyAlloc(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, GP_ProgressCallback *callback); /* @@ -65,37 +65,37 @@ GP_Context *GP_FilterMultiplyAlloc(const GP_Context *src_a, * Produces symetric difference. * eg. dst = abs(src_a - src_b) */ -int GP_FilterDifference(const GP_Context *src_a, - const GP_Context *src_b, - GP_Context *dst, +int GP_FilterDifference(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, + GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterDifferenceAlloc(const GP_Context *src_a, - const GP_Context *src_b, +GP_Pixmap *GP_FilterDifferenceAlloc(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, GP_ProgressCallback *callback); /* * Maximum filter. */ -int GP_FilterMax(const GP_Context *src_a, - const GP_Context *src_b, - GP_Context *dst, +int GP_FilterMax(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, + GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterMaxAlloc(const GP_Context *src_a, - const GP_Context *src_b, +GP_Pixmap *GP_FilterMaxAlloc(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, GP_ProgressCallback *callback); /* * Minimum filter. */ -int GP_FilterMin(const GP_Context *src_a, - const GP_Context *src_b, - GP_Context *dst, +int GP_FilterMin(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, + GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterMinAlloc(const GP_Context *src_a, - const GP_Context *src_b, +GP_Pixmap *GP_FilterMinAlloc(const GP_Pixmap *src_a, + const GP_Pixmap *src_b, GP_ProgressCallback *callback); #endif /* FILTERS_GP_ARITHMETIC_H */ diff --git a/include/filters/GP_Blur.h b/include/filters/GP_Blur.h index 691955e7..d4448e5b 100644 --- a/include/filters/GP_Blur.h +++ b/include/filters/GP_Blur.h @@ -38,21 +38,21 @@ * defines blur on vertical direction. */ -int GP_FilterGaussianBlurEx(const GP_Context *src, +int GP_FilterGaussianBlurEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float x_sigma, float y_sigma, GP_ProgressCallback *callback); -GP_Context *GP_FilterGaussianBlurExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterGaussianBlurExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, float x_sigma, float y_sigma, GP_ProgressCallback *callback); -static inline int GP_FilterGaussianBlur(const GP_Context *src, GP_Context *dst, +static inline int GP_FilterGaussianBlur(const GP_Pixmap *src, GP_Pixmap *dst, float x_sigma, float y_sigma, GP_ProgressCallback *callback) { @@ -60,7 +60,7 @@ static inline int GP_FilterGaussianBlur(const GP_Context *src, GP_Context *dst, x_sigma, y_sigma, callback); } -static inline GP_Context *GP_FilterGaussianBlurAlloc(const GP_Context *src, +static inline GP_Pixmap *GP_FilterGaussianBlurAlloc(const GP_Pixmap *src, float x_sigma, float y_sigma, GP_ProgressCallback *callback) { diff --git a/include/filters/GP_Convolution.h b/include/filters/GP_Convolution.h index e8d30d01..79551da0 100644 --- a/include/filters/GP_Convolution.h +++ b/include/filters/GP_Convolution.h @@ -70,10 +70,10 @@ typedef struct GP_FilterKernel2D { * The result is stored into dst strating from x_dst and y_dst. * */ -int GP_FilterConvolutionEx(const GP_Context *src, +int GP_FilterConvolutionEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Coord h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, const GP_FilterKernel2D *kernel, GP_ProgressCallback *callback); @@ -83,16 +83,16 @@ int GP_FilterConvolutionEx(const GP_Context *src, * * Works on rectangle in src defined by x_src, y_src, w_src and h_src. * - * Allocates context of a w_src x h_src. + * Allocates pixmap of a w_src x h_src. */ -GP_Context *GP_FilterConvolutionExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterConvolutionExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, const GP_FilterKernel2D *kernel, GP_ProgressCallback *callback); -static inline int GP_FilterConvolution(const GP_Context *src, GP_Context *dst, +static inline int GP_FilterConvolution(const GP_Pixmap *src, GP_Pixmap *dst, const GP_FilterKernel2D *kernel, GP_ProgressCallback *callback) { @@ -100,7 +100,7 @@ static inline int GP_FilterConvolution(const GP_Context *src, GP_Context *dst, kernel, callback); } -static inline GP_Context *GP_FilterConvolutionAlloc(const GP_Context *src, +static inline GP_Pixmap *GP_FilterConvolutionAlloc(const GP_Pixmap *src, const GP_FilterKernel2D *kernel, GP_ProgressCallback *callback) { diff --git a/include/filters/GP_Dither.h b/include/filters/GP_Dither.h index 848ea836..024544d3 100644 --- a/include/filters/GP_Dither.h +++ b/include/filters/GP_Dither.h @@ -58,15 +58,15 @@ * * If operation was aborted from within a callback, non-zero is returned. */ -int GP_FilterFloydSteinberg(const GP_Context *src, - GP_Context *dst, +int GP_FilterFloydSteinberg(const GP_Pixmap *src, + GP_Pixmap *dst, GP_ProgressCallback *callback); /* * If malloc() has failed, or operation was aborted by a callback, NULL is * returned. */ -GP_Context *GP_FilterFloydSteinbergAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterFloydSteinbergAlloc(const GP_Pixmap *src, GP_PixelType pixel_type, GP_ProgressCallback *callback); @@ -89,15 +89,15 @@ GP_Context *GP_FilterFloydSteinbergAlloc(const GP_Context *src, * * If the operation was aborted from within a callback, non-zero is returned. */ -int GP_FilterHilbertPeano(const GP_Context *src, - GP_Context *dst, +int GP_FilterHilbertPeano(const GP_Pixmap *src, + GP_Pixmap *dst, GP_ProgressCallback *callback); /* * If malloc() has failed, or operation was aborted by a callback, NULL is * returned. */ -GP_Context *GP_FilterHilbertPeanoAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterHilbertPeanoAlloc(const GP_Pixmap *src, GP_PixelType pixel_type, GP_ProgressCallback *callback); diff --git a/include/filters/GP_EdgeDetection.h b/include/filters/GP_EdgeDetection.h index 94adc6e1..aca8fc93 100644 --- a/include/filters/GP_EdgeDetection.h +++ b/include/filters/GP_EdgeDetection.h @@ -25,12 +25,12 @@ #include "GP_Filter.h" -int GP_FilterEdgeSobel(const GP_Context *src, - GP_Context **E, GP_Context **Phi, +int GP_FilterEdgeSobel(const GP_Pixmap *src, + GP_Pixmap **E, GP_Pixmap **Phi, GP_ProgressCallback *callback); -int GP_FilterEdgePrewitt(const GP_Context *src, - GP_Context **E, GP_Context **Phi, +int GP_FilterEdgePrewitt(const GP_Pixmap *src, + GP_Pixmap **E, GP_Pixmap **Phi, GP_ProgressCallback *callback); diff --git a/include/filters/GP_Filter.h b/include/filters/GP_Filter.h index bc36e2ed..0752e403 100644 --- a/include/filters/GP_Filter.h +++ b/include/filters/GP_Filter.h @@ -29,7 +29,7 @@ #ifndef FILTERS_GP_FILTER_H #define FILTERS_GP_FILTER_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_ProgressCallback.h" #endif /* FILTERS_GP_FILTER_H */ diff --git a/include/filters/GP_Filters.h b/include/filters/GP_Filters.h index 1b68c71f..0e2ac76e 100644 --- a/include/filters/GP_Filters.h +++ b/include/filters/GP_Filters.h @@ -25,7 +25,7 @@ /* - GP_Context filters. + GP_Pixmap filters. */ diff --git a/include/filters/GP_GaussianNoise.h b/include/filters/GP_GaussianNoise.h index e67fc2f9..27966a66 100644 --- a/include/filters/GP_GaussianNoise.h +++ b/include/filters/GP_GaussianNoise.h @@ -35,22 +35,22 @@ #include "GP_Filter.h" -int GP_FilterGaussianNoiseAddEx(const GP_Context *src, +int GP_FilterGaussianNoiseAddEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float sigma, float mu, GP_ProgressCallback *callback); -GP_Context *GP_FilterGaussianNoiseAddExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterGaussianNoiseAddExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, float sigma, float mu, GP_ProgressCallback *callback); -static inline int GP_FilterGaussianNoiseAdd(const GP_Context *src, - GP_Context *dst, +static inline int GP_FilterGaussianNoiseAdd(const GP_Pixmap *src, + GP_Pixmap *dst, float sigma, float mu, GP_ProgressCallback *callback) { @@ -58,8 +58,8 @@ static inline int GP_FilterGaussianNoiseAdd(const GP_Context *src, dst, 0, 0, sigma, mu, callback); } -static inline GP_Context * -GP_FilterGaussianNoiseAddAlloc(const GP_Context *src, +static inline GP_Pixmap * +GP_FilterGaussianNoiseAddAlloc(const GP_Pixmap *src, float sigma, float mu, GP_ProgressCallback *callback) { diff --git a/include/filters/GP_Laplace.h b/include/filters/GP_Laplace.h index ead7e6e9..a89deac3 100644 --- a/include/filters/GP_Laplace.h +++ b/include/filters/GP_Laplace.h @@ -40,10 +40,10 @@ * [-2 ] * [ 1 ] */ -int GP_FilterLaplace(const GP_Context *src, GP_Context *dst, +int GP_FilterLaplace(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterLaplaceAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterLaplaceAlloc(const GP_Pixmap *src, GP_ProgressCallback *callback); /* @@ -52,10 +52,10 @@ GP_Context *GP_FilterLaplaceAlloc(const GP_Context *src, * This filter substract result of Laplace filter weigted by w from the * original image which amplifies edges. */ -int GP_FilterEdgeSharpening(const GP_Context *src, GP_Context *dst, +int GP_FilterEdgeSharpening(const GP_Pixmap *src, GP_Pixmap *dst, float w, GP_ProgressCallback *callback); -GP_Context *GP_FilterEdgeSharpeningAlloc(const GP_Context *src, float w, +GP_Pixmap *GP_FilterEdgeSharpeningAlloc(const GP_Pixmap *src, float w, GP_ProgressCallback *callback); #endif /* FILTERS_GP_LAPLACE_H */ diff --git a/include/filters/GP_Linear.h b/include/filters/GP_Linear.h index 62ff12d8..77206072 100644 --- a/include/filters/GP_Linear.h +++ b/include/filters/GP_Linear.h @@ -40,7 +40,7 @@ * The src coordinates and size defines rectangle in the source on which the * filter operates. * - * The dst coodinates defines start pixel of in the destination context. + * The dst coodinates defines start pixel of in the destination pixmap. * * To define 3x3 average filter * @@ -54,10 +54,10 @@ * * kern_div = 9 */ -int GP_FilterLinearConvolution_Raw(const GP_Context *src, +int GP_FilterLinearConvolution_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float kernel[], uint32_t kw, uint32_t kh, float kern_div, GP_ProgressCallback *callback); @@ -72,18 +72,18 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src, * * Both works also in-place. */ -int GP_FilterHLinearConvolution_Raw(const GP_Context *src, +int GP_FilterHLinearConvolution_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float kernel[], uint32_t kw, float kern_div, GP_ProgressCallback *callback); -int GP_FilterVLinearConvolution_Raw(const GP_Context *src, +int GP_FilterVLinearConvolution_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float kernel[], uint32_t kh, float kern_div, GP_ProgressCallback *callback); @@ -93,10 +93,10 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, * correct progress callback (both horizontal and vertical kernels are expected * to be similar in size). */ -int GP_FilterVHLinearConvolution_Raw(const GP_Context *src, +int GP_FilterVHLinearConvolution_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float hkernel[], uint32_t kw, float hkern_div, float vkernel[], uint32_t kh, float vkern_div, @@ -110,13 +110,13 @@ void GP_FilterKernelPrint_Raw(float kernel[], int kw, int kh, float kern_div); typedef struct GP_ConvolutionParams { - const GP_Context *src; + const GP_Pixmap *src; GP_Coord x_src; GP_Coord y_src; GP_Size w_src; GP_Size h_src; - GP_Context *dst; + GP_Pixmap *dst; GP_Coord x_dst; GP_Coord y_dst; diff --git a/include/filters/GP_Median.h b/include/filters/GP_Median.h index 0274b290..eab0fa51 100644 --- a/include/filters/GP_Median.h +++ b/include/filters/GP_Median.h @@ -36,22 +36,22 @@ #include "GP_Filter.h" -int GP_FilterMedianEx(const GP_Context *src, +int GP_FilterMedianEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, int xmed, int ymed, GP_ProgressCallback *callback); -GP_Context *GP_FilterMedianExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterMedianExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, int xmed, int ymed, GP_ProgressCallback *callback); -static inline int GP_FilterMedian(const GP_Context *src, - GP_Context *dst, +static inline int GP_FilterMedian(const GP_Pixmap *src, + GP_Pixmap *dst, int xmed, int ymed, GP_ProgressCallback *callback) { @@ -59,7 +59,7 @@ static inline int GP_FilterMedian(const GP_Context *src, dst, 0, 0, xmed, ymed, callback); } -static inline GP_Context *GP_FilterMedianAlloc(const GP_Context *src, +static inline GP_Pixmap *GP_FilterMedianAlloc(const GP_Pixmap *src, int xmed, int ymed, GP_ProgressCallback *callback) { diff --git a/include/filters/GP_MultiTone.h b/include/filters/GP_MultiTone.h index 9a33d46e..f1af3fe3 100644 --- a/include/filters/GP_MultiTone.h +++ b/include/filters/GP_MultiTone.h @@ -25,16 +25,16 @@ #include "GP_Filter.h" -int GP_FilterMultiToneEx(const GP_Context *const src, +int GP_FilterMultiToneEx(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, GP_Pixel pixels[], GP_Size pixels_size, GP_ProgressCallback *callback); -static inline int GP_FilterMultiTone(const GP_Context *const src, - GP_Context *dst, +static inline int GP_FilterMultiTone(const GP_Pixmap *const src, + GP_Pixmap *dst, GP_Pixel pixels[], GP_Size pixels_size, GP_ProgressCallback *callback) { @@ -42,14 +42,14 @@ static inline int GP_FilterMultiTone(const GP_Context *const src, pixels, pixels_size, callback); } -GP_Context *GP_FilterMultiToneExAlloc(const GP_Context *const src, +GP_Pixmap *GP_FilterMultiToneExAlloc(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, GP_PixelType dst_pixel_type, GP_Pixel pixels[], GP_Size pixels_size, GP_ProgressCallback *callback); -static inline GP_Context *GP_FilterMultiToneAlloc(const GP_Context *const src, +static inline GP_Pixmap *GP_FilterMultiToneAlloc(const GP_Pixmap *const src, GP_PixelType dst_pixel_type, GP_Pixel pixels[], GP_Size pixels_size, diff --git a/include/filters/GP_Point.h b/include/filters/GP_Point.h index 3c8e6ac3..084bb3a6 100644 --- a/include/filters/GP_Point.h +++ b/include/filters/GP_Point.h @@ -36,29 +36,29 @@ * * Increments each pixel channel by a p * channel_max value. */ -int GP_FilterBrightnessEx(const GP_Context *const src, +int GP_FilterBrightnessEx(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float p, GP_ProgressCallback *callback); -GP_Context *GP_FilterBrightnessExAlloc(const GP_Context *const src, +GP_Pixmap *GP_FilterBrightnessExAlloc(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, float p, GP_ProgressCallback *callback); -static inline int GP_FilterBrightness(const GP_Context *src, GP_Context *dst, +static inline int GP_FilterBrightness(const GP_Pixmap *src, GP_Pixmap *dst, float p, GP_ProgressCallback *callback) { return GP_FilterBrightnessEx(src, 0, 0, src->w, src->h, dst, 0, 0, p, callback); } -static inline GP_Context * -GP_FilterBrightnessAlloc(const GP_Context *src, float p, +static inline GP_Pixmap * +GP_FilterBrightnessAlloc(const GP_Pixmap *src, float p, GP_ProgressCallback *callback) { return GP_FilterBrightnessExAlloc(src, 0, 0, src->w, src->h, @@ -73,28 +73,28 @@ GP_FilterBrightnessAlloc(const GP_Context *src, float p, * The parameters should have the same pixel channels as * source pixel type and are expected to be float numbers. */ -int GP_FilterContrastEx(const GP_Context *const src, +int GP_FilterContrastEx(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float p, GP_ProgressCallback *callback); -GP_Context *GP_FilterContrastExAlloc(const GP_Context *const src, +GP_Pixmap *GP_FilterContrastExAlloc(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, float p, GP_ProgressCallback *callback); -static inline int GP_FilterContrast(const GP_Context *src, GP_Context *dst, +static inline int GP_FilterContrast(const GP_Pixmap *src, GP_Pixmap *dst, float p, GP_ProgressCallback *callback) { return GP_FilterContrastEx(src, 0, 0, src->w, src->h, dst, 0, 0, p, callback); } -static inline GP_Context *GP_FilterContrastAlloc(const GP_Context *src, +static inline GP_Pixmap *GP_FilterContrastAlloc(const GP_Pixmap *src, float p, GP_ProgressCallback *callback) { @@ -105,29 +105,29 @@ static inline GP_Context *GP_FilterContrastAlloc(const GP_Context *src, /* * Brightness and Contrast combined. */ -int GP_FilterBrightnessContrastEx(const GP_Context *const src, +int GP_FilterBrightnessContrastEx(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float b, float c, GP_ProgressCallback *callback); -GP_Context *GP_FilterBrightnessContrastExAlloc(const GP_Context *const src, +GP_Pixmap *GP_FilterBrightnessContrastExAlloc(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, float b, float c, GP_ProgressCallback *callback); static inline int -GP_FilterBrightnessContrast(const GP_Context *src, GP_Context *dst, +GP_FilterBrightnessContrast(const GP_Pixmap *src, GP_Pixmap *dst, float b, float c, GP_ProgressCallback *callback) { return GP_FilterBrightnessContrastEx(src, 0, 0, src->w, src->h, dst, 0, 0, b, c, callback); } -static inline GP_Context * -GP_FilterBrightnessContrastAlloc(const GP_Context *src, +static inline GP_Pixmap * +GP_FilterBrightnessContrastAlloc(const GP_Pixmap *src, float b, float c, GP_ProgressCallback *callback) { @@ -140,21 +140,21 @@ GP_FilterBrightnessContrastAlloc(const GP_Context *src, * * Does quantization into steps regions. */ -int GP_FilterPosterizeEx(const GP_Context *const src, +int GP_FilterPosterizeEx(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, unsigned int steps, GP_ProgressCallback *callback); -GP_Context *GP_FilterPosterizeExAlloc(const GP_Context *const src, +GP_Pixmap *GP_FilterPosterizeExAlloc(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, unsigned int steps, GP_ProgressCallback *callback); -static inline int GP_FilterPosterize(const GP_Context *src, GP_Context *dst, +static inline int GP_FilterPosterize(const GP_Pixmap *src, GP_Pixmap *dst, unsigned int steps, GP_ProgressCallback *callback) { @@ -162,8 +162,8 @@ static inline int GP_FilterPosterize(const GP_Context *src, GP_Context *dst, dst, 0, 0, steps, callback); } -static inline GP_Context * -GP_FilterPosterizeAlloc(const GP_Context *src, unsigned int steps, +static inline GP_Pixmap * +GP_FilterPosterizeAlloc(const GP_Pixmap *src, unsigned int steps, GP_ProgressCallback *callback) { return GP_FilterPosterizeExAlloc(src, 0, 0, src->w, src->h, @@ -173,26 +173,26 @@ GP_FilterPosterizeAlloc(const GP_Context *src, unsigned int steps, /* * Inverts the pixel value, i.e. sets it to max - val. */ -int GP_FilterInvertEx(const GP_Context *const src, +int GP_FilterInvertEx(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterInvertExAlloc(const GP_Context *const src, +GP_Pixmap *GP_FilterInvertExAlloc(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, GP_ProgressCallback *callback); -static inline int GP_FilterInvert(const GP_Context *src, GP_Context *dst, +static inline int GP_FilterInvert(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { return GP_FilterInvertEx(src, 0, 0, src->w, src->h, dst, 0, 0, callback); } -static inline GP_Context *GP_FilterInvertAlloc(const GP_Context *src, +static inline GP_Pixmap *GP_FilterInvertAlloc(const GP_Pixmap *src, GP_ProgressCallback *callback) { return GP_FilterInvertExAlloc(src, 0, 0, src->w, src->h, callback); diff --git a/include/filters/GP_Resize.h b/include/filters/GP_Resize.h index 18f49583..975eddb9 100644 --- a/include/filters/GP_Resize.h +++ b/include/filters/GP_Resize.h @@ -22,7 +22,7 @@ /* - GP_Context interpolations. + GP_Pixmap interpolations. Nearest Neighbour ~~~~~~~~~~~~~~~~~ @@ -72,18 +72,18 @@ const char *GP_InterpolationTypeName(enum GP_InterpolationType interp_type); * * Returns non-zero on error (interrupted from callback), zero on success. */ -int GP_FilterResize(const GP_Context *src, GP_Context *dst, +int GP_FilterResize(const GP_Pixmap *src, GP_Pixmap *dst, GP_InterpolationType type, GP_ProgressCallback *callback); /* * Resize src to wxh, the result is allocated. * - * Returns pointer to newly created context. + * Returns pointer to newly created pixmap. * * Returns NULL in case of failure and errno is set correspondinlgy. */ -GP_Context *GP_FilterResizeAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterResizeAlloc(const GP_Pixmap *src, GP_Size w, GP_Size h, GP_InterpolationType type, GP_ProgressCallback *callback); diff --git a/include/filters/GP_ResizeCubic.h b/include/filters/GP_ResizeCubic.h index ebbab41c..26ca30ca 100644 --- a/include/filters/GP_ResizeCubic.h +++ b/include/filters/GP_ResizeCubic.h @@ -32,20 +32,20 @@ #include "GP_Filter.h" #include "GP_Resize.h" -int GP_FilterResizeCubicInt(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeCubicInt(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -int GP_FilterResizeCubic(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeCubic(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -static inline GP_Context *GP_FilterResizeCubicIntAlloc(const GP_Context *src, +static inline GP_Pixmap *GP_FilterResizeCubicIntAlloc(const GP_Pixmap *src, GP_Size w, GP_Size h, GP_ProgressCallback *callback) { return GP_FilterResizeAlloc(src, w, h, GP_INTERP_CUBIC_INT, callback); } -static inline GP_Context *GP_FilterResizeCubicAlloc(const GP_Context *src, +static inline GP_Pixmap *GP_FilterResizeCubicAlloc(const GP_Pixmap *src, GP_Size w, GP_Size h, GP_ProgressCallback *callback) { diff --git a/include/filters/GP_ResizeLinear.h b/include/filters/GP_ResizeLinear.h index 55067511..3aea311a 100644 --- a/include/filters/GP_ResizeLinear.h +++ b/include/filters/GP_ResizeLinear.h @@ -32,20 +32,20 @@ #include "GP_Filter.h" #include "GP_Resize.h" -int GP_FilterResizeLinearInt(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeLinearInt(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -int GP_FilterResizeLinearLFInt(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeLinearLFInt(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -static inline GP_Context *GP_FilterResizeLinearIntAlloc(const GP_Context *src, +static inline GP_Pixmap *GP_FilterResizeLinearIntAlloc(const GP_Pixmap *src, GP_Size w, GP_Size h, GP_ProgressCallback *callback) { return GP_FilterResizeAlloc(src, w, h, GP_INTERP_LINEAR_INT, callback); } -static inline GP_Context *GP_FilterResizeLinearLFIntAlloc(const GP_Context *src, +static inline GP_Pixmap *GP_FilterResizeLinearLFIntAlloc(const GP_Pixmap *src, GP_Size w, GP_Size h, GP_ProgressCallback *callback) { diff --git a/include/filters/GP_ResizeNN.h b/include/filters/GP_ResizeNN.h index d511702f..e83d9b1e 100644 --- a/include/filters/GP_ResizeNN.h +++ b/include/filters/GP_ResizeNN.h @@ -32,10 +32,10 @@ #include "GP_Filter.h" #include "GP_Resize.h" -int GP_FilterResizeNN(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeNN(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -static inline GP_Context *GP_FilterResizeNNAlloc(const GP_Context *src, +static inline GP_Pixmap *GP_FilterResizeNNAlloc(const GP_Pixmap *src, GP_Size w, GP_Size h, GP_ProgressCallback *callback) { diff --git a/include/filters/GP_Rotate.h b/include/filters/GP_Rotate.h index f1560687..8d315e9b 100644 --- a/include/filters/GP_Rotate.h +++ b/include/filters/GP_Rotate.h @@ -22,14 +22,14 @@ /* - GP_Context rotations and mirroring. + GP_Pixmap rotations and mirroring. */ #ifndef FILTERS_GP_ROTATE_H #define FILTERS_GP_ROTATE_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "GP_Filter.h" /* @@ -38,21 +38,21 @@ * The dst must be at least as big as source. * * The filter works 'in-place' which means that src and dst - * may be very same context. Note that when aborting in-place operation + * may be very same pixmap. Note that when aborting in-place operation * the image buffer gets into an inconsistent state. * * Returns zero on success, non-zero if operation was aborted. */ -int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst, +int GP_FilterMirrorH(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); /* * Mirrors bitmap horizontally. * - * Returns pointer to newly allocated context, or NULL if malloc() has failed + * Returns pointer to newly allocated pixmap, or NULL if malloc() has failed * or operation was aborted from withing a callback. */ -GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterMirrorHAlloc(const GP_Pixmap *src, GP_ProgressCallback *callback); /* @@ -61,44 +61,44 @@ GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src, * The dst must be at least as big as source. * * The filter works 'in-place' which means that src and dst - * may be very same context. Note that when aborting in-place operation + * may be very same pixmap. Note that when aborting in-place operation * the image buffer gets into an inconsistent state. * * Returns zero on success, non-zero if operation was aborted. */ -int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst, +int GP_FilterMirrorV(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); /* * Mirrors bitmap vertically. * - * Returns pointer to newly allocated context, or NULL if malloc() has failed + * Returns pointer to newly allocated pixmap, or NULL if malloc() has failed * or operation was aborted from withing a callback. */ -GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterMirrorVAlloc(const GP_Pixmap *src, GP_ProgressCallback *callback); /* - * Rotate the context by 90, 180, 270. + * Rotate the pixmap by 90, 180, 270. * * Returns pointer to destination bitmap or NULL if allocation failed. */ -int GP_FilterRotate90(const GP_Context *src, GP_Context *dst, +int GP_FilterRotate90(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterRotate90Alloc(const GP_Context *src, +GP_Pixmap *GP_FilterRotate90Alloc(const GP_Pixmap *src, GP_ProgressCallback *callback); -int GP_FilterRotate180(const GP_Context *src, GP_Context *dst, +int GP_FilterRotate180(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterRotate180Alloc(const GP_Context *src, +GP_Pixmap *GP_FilterRotate180Alloc(const GP_Pixmap *src, GP_ProgressCallback *callback); -int GP_FilterRotate270(const GP_Context *src, GP_Context *dst, +int GP_FilterRotate270(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback); -GP_Context *GP_FilterRotate270Alloc(const GP_Context *src, +GP_Pixmap *GP_FilterRotate270Alloc(const GP_Pixmap *src, GP_ProgressCallback *callback); /* @@ -131,11 +131,11 @@ extern const char **GP_FilterSymmetryNames; */ int GP_FilterSymmetryByName(const char *symmetry); -int GP_FilterSymmetry(const GP_Context *src, GP_Context *dst, +int GP_FilterSymmetry(const GP_Pixmap *src, GP_Pixmap *dst, GP_FilterSymmetries symmetry, GP_ProgressCallback *callback); -GP_Context *GP_FilterSymmetryAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterSymmetryAlloc(const GP_Pixmap *src, GP_FilterSymmetries symmetry, GP_ProgressCallback *callback); diff --git a/include/filters/GP_Sepia.h b/include/filters/GP_Sepia.h index 2d41dd9b..53c137e4 100644 --- a/include/filters/GP_Sepia.h +++ b/include/filters/GP_Sepia.h @@ -25,28 +25,28 @@ #include "GP_Filter.h" -int GP_FilterSepiaEx(const GP_Context *const src, +int GP_FilterSepiaEx(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, GP_ProgressCallback *callback); -static inline int GP_FilterSepia(const GP_Context *const src, - GP_Context *dst, +static inline int GP_FilterSepia(const GP_Pixmap *const src, + GP_Pixmap *dst, GP_ProgressCallback *callback) { return GP_FilterSepiaEx(src, 0, 0, src->w, src->h, dst, 0, 0, callback); } -GP_Context *GP_FilterSepiaExAlloc(const GP_Context *const src, +GP_Pixmap *GP_FilterSepiaExAlloc(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, GP_PixelType dst_pixel_type, GP_ProgressCallback *callback); -static inline GP_Context *GP_FilterSepiaAlloc(const GP_Context *const src, +static inline GP_Pixmap *GP_FilterSepiaAlloc(const GP_Pixmap *const src, GP_PixelType dst_pixel_type, GP_ProgressCallback *callback) { diff --git a/include/filters/GP_Sigma.h b/include/filters/GP_Sigma.h index 01f1cf4c..1def4981 100644 --- a/include/filters/GP_Sigma.h +++ b/include/filters/GP_Sigma.h @@ -42,24 +42,24 @@ #include "GP_Filter.h" -int GP_FilterSigmaEx(const GP_Context *src, +int GP_FilterSigmaEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, int xrad, int yrad, unsigned int min, float sigma, GP_ProgressCallback *callback); -GP_Context *GP_FilterSigmaExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterSigmaExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, int xrad, int yrad, unsigned int min, float sigma, GP_ProgressCallback *callback); -static inline int GP_FilterSigma(const GP_Context *src, - GP_Context *dst, +static inline int GP_FilterSigma(const GP_Pixmap *src, + GP_Pixmap *dst, int xrad, int yrad, unsigned int min, float sigma, GP_ProgressCallback *callback) @@ -68,7 +68,7 @@ static inline int GP_FilterSigma(const GP_Context *src, dst, 0, 0, xrad, yrad, min, sigma, callback); } -static inline GP_Context *GP_FilterSigmaAlloc(const GP_Context *src, +static inline GP_Pixmap *GP_FilterSigmaAlloc(const GP_Pixmap *src, int xrad, int yrad, unsigned int min, float sigma, GP_ProgressCallback *callback) diff --git a/include/filters/GP_Stats.h b/include/filters/GP_Stats.h index 8d780fe2..6dadc6eb 100644 --- a/include/filters/GP_Stats.h +++ b/include/filters/GP_Stats.h @@ -63,7 +63,7 @@ GP_HistogramChannel *GP_HistogramChannelByName(GP_Histogram *self, /* * Computes histogram. Returns non-zero on failure (i.e. canceled by callback). */ -int GP_FilterHistogram(GP_Histogram *self, const GP_Context *src, +int GP_FilterHistogram(GP_Histogram *self, const GP_Pixmap *src, GP_ProgressCallback *callback); #endif /* FILTERS_GP_STATS_H */ diff --git a/include/filters/GP_WeightedMedian.h b/include/filters/GP_WeightedMedian.h index 167b454a..9ae61b84 100644 --- a/include/filters/GP_WeightedMedian.h +++ b/include/filters/GP_WeightedMedian.h @@ -36,22 +36,22 @@ typedef struct GP_MedianWeights { unsigned int *weights; } GP_MedianWeights; -int GP_FilterWeightedMedianEx(const GP_Context *src, +int GP_FilterWeightedMedianEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, GP_MedianWeights *weights, GP_ProgressCallback *callback); -GP_Context *GP_FilterWeightedMedianExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterWeightedMedianExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, GP_MedianWeights *weights, GP_ProgressCallback *callback); -static inline int GP_FilterWeightedMedian(const GP_Context *src, - GP_Context *dst, +static inline int GP_FilterWeightedMedian(const GP_Pixmap *src, + GP_Pixmap *dst, GP_MedianWeights *weights, GP_ProgressCallback *callback) { @@ -59,7 +59,7 @@ static inline int GP_FilterWeightedMedian(const GP_Context *src, dst, 0, 0, weights, callback); } -static inline GP_Context *GP_FilterWeightedMedianAlloc(const GP_Context *src, +static inline GP_Pixmap *GP_FilterWeightedMedianAlloc(const GP_Pixmap *src, GP_MedianWeights *weights, GP_ProgressCallback *callback) { diff --git a/include/gfx/GP_Arc.h b/include/gfx/GP_Arc.h index 29894892..c20bcde0 100644 --- a/include/gfx/GP_Arc.h +++ b/include/gfx/GP_Arc.h @@ -26,16 +26,16 @@ #ifndef GP_ARC_H #define GP_ARC_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include -void GP_ArcSegment(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_ArcSegment(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, int direction, double start, double end, GP_Pixel pixel); -void GP_ArcSegment_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_ArcSegment_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, int direction, double start, double end, GP_Pixel pixel); diff --git a/include/gfx/GP_Circle.h b/include/gfx/GP_Circle.h index 8f9f4dee..9bf893b5 100644 --- a/include/gfx/GP_Circle.h +++ b/include/gfx/GP_Circle.h @@ -26,38 +26,38 @@ #ifndef GP_CIRCLE_H #define GP_CIRCLE_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" /* Circle */ -void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Circle(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel); -void GP_Circle_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Circle_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel); /* Filled Circle */ -void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillCircle(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel); -void GP_FillCircle_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillCircle_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel); /* Ring */ -void GP_Ring(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Ring(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r1, GP_Size r2, GP_Pixel pixel); -void GP_Ring_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Ring_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r1, GP_Size r2, GP_Pixel pixel); /* Filled Ring */ -void GP_FillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillRing(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r1, GP_Size r2, GP_Pixel pixel); -void GP_FillRing_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillRing_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r1, GP_Size r2, GP_Pixel pixel); #endif /* GP_CIRCLE_H */ diff --git a/include/gfx/GP_CircleSeg.h b/include/gfx/GP_CircleSeg.h index 3bd41e2c..af2def0b 100644 --- a/include/gfx/GP_CircleSeg.h +++ b/include/gfx/GP_CircleSeg.h @@ -26,7 +26,7 @@ #ifndef GFX_GP_CIRCLE_H #define GFX_GP_CIRCLE_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" /* * Quadrants in cartesian space the center is set in the middle of the circle. @@ -50,18 +50,18 @@ enum GP_CircleSegments { /* Circle Segment */ -void GP_CircleSeg(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_CircleSeg(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, uint8_t seg_flag, GP_Pixel pixel); -void GP_CircleSeg_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_CircleSeg_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, uint8_t seg_flag, GP_Pixel pixel); /* Filled Circle Segment */ -void GP_FillCircleSeg(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillCircleSeg(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, uint8_t seg_flag, GP_Pixel pixel); -void GP_FillCircleSeg_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillCircleSeg_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, uint8_t seg_flag, GP_Pixel pixel); #endif /* GFX_GP_CIRCLE_H */ diff --git a/include/gfx/GP_Ellipse.h b/include/gfx/GP_Ellipse.h index 6a86a478..848ae596 100644 --- a/include/gfx/GP_Ellipse.h +++ b/include/gfx/GP_Ellipse.h @@ -26,22 +26,22 @@ #ifndef GP_ELLIPSE_H #define GP_ELLIPSE_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" /* Ellipse */ -void GP_Ellipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Ellipse(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel); -void GP_Ellipse_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Ellipse_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel); /* Filled Ellipse */ -void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillEllipse(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel); -void GP_FillEllipse_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillEllipse_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel); #endif /* GP_ELLIPSE_H */ diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_Gfx.h index 5b7e2866..12a06d26 100644 --- a/include/gfx/GP_Gfx.h +++ b/include/gfx/GP_Gfx.h @@ -33,7 +33,7 @@ #define GP_GFX_H /* basic definitions and structures */ -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_GetPutPixel.h" #include "core/GP_WritePixel.h" #include "core/GP_Fill.h" diff --git a/include/gfx/GP_HLine.gen.h.t b/include/gfx/GP_HLine.gen.h.t index 1ed91346..6dcb587b 100644 --- a/include/gfx/GP_HLine.gen.h.t +++ b/include/gfx/GP_HLine.gen.h.t @@ -6,6 +6,6 @@ */ @ for ps in pixelsizes: -void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord x0, +void GP_HLine_Raw_{{ ps.suffix }}(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel); diff --git a/include/gfx/GP_HLine.h b/include/gfx/GP_HLine.h index 50f9a126..1ceebef9 100644 --- a/include/gfx/GP_HLine.h +++ b/include/gfx/GP_HLine.h @@ -26,35 +26,35 @@ #ifndef GFX_GP_HLINE_H #define GFX_GP_HLINE_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" /* Raw per BPP HLines */ #include "gfx/GP_HLine.gen.h" /* Generic HLines */ -void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, +void GP_HLineXXY(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel); -void GP_HLineXXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, +void GP_HLineXXY_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel); -void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, +void GP_HLineXYW(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Pixel pixel); -void GP_HLineXYW_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, +void GP_HLineXYW_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Pixel pixel); /* default argument set is XXY */ -static inline void GP_HLine_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, +static inline void GP_HLine_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel p) { - GP_HLineXXY_Raw(context, x0, x1, y, p); + GP_HLineXXY_Raw(pixmap, x0, x1, y, p); } -static inline void GP_HLine(GP_Context *context, GP_Coord x0, GP_Coord x1, +static inline void GP_HLine(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel p) { - GP_HLineXXY(context, x0, x1, y, p); + GP_HLineXXY(pixmap, x0, x1, y, p); } #endif /* GFX_GP_HLINE_H */ diff --git a/include/gfx/GP_HLineAA.h b/include/gfx/GP_HLineAA.h index cbb34e7d..44ebe44c 100644 --- a/include/gfx/GP_HLineAA.h +++ b/include/gfx/GP_HLineAA.h @@ -27,7 +27,7 @@ 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 + For RGB pixmaps gamma correction tables are used to generate correct intensity for pixels. */ @@ -35,19 +35,19 @@ #ifndef GFX_GP_HLINE_AA_H #define GFX_GP_HLINE_AA_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" /* - * Anti Aliased Horizontal Line respecting context rotation flags and with + * Anti Aliased Horizontal Line respecting pixmap rotation flags and with * clipping. */ -void GP_HLineAA(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, +void GP_HLineAA(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel); /* * Horizontal Line without contect rotation flags. */ -void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, +void GP_HLineAA_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel); #endif /* GFX_GP_HLINE_AA_H */ diff --git a/include/gfx/GP_Line.h b/include/gfx/GP_Line.h index c131c7a6..f9e73c8c 100644 --- a/include/gfx/GP_Line.h +++ b/include/gfx/GP_Line.h @@ -26,12 +26,12 @@ #ifndef GP_LINE_H #define GP_LINE_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" -void GP_Line(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Line(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel); -void GP_Line_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Line_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel); #endif /* GP_LINE_H */ diff --git a/include/gfx/GP_LineAA.h b/include/gfx/GP_LineAA.h index c8a0ac66..10afe1ee 100644 --- a/include/gfx/GP_LineAA.h +++ b/include/gfx/GP_LineAA.h @@ -27,7 +27,7 @@ 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 + For RGB pixmaps gamma correction tables are used to generate correct intensity for pixels. */ @@ -35,18 +35,18 @@ #ifndef GFX_GP_LINE_AA_H #define GFX_GP_LINE_AA_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" /* - * Anti Aliased Line respecting context rotation flags and with clipping. + * Anti Aliased Line respecting pixmap rotation flags and with clipping. */ -void GP_LineAA(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_LineAA(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel); /* * Line without contect rotation flags. */ -void GP_LineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_LineAA_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel); #endif /* GFX_GP_LINE_AA_H */ diff --git a/include/gfx/GP_Polygon.h b/include/gfx/GP_Polygon.h index 1ed256e5..d459a135 100644 --- a/include/gfx/GP_Polygon.h +++ b/include/gfx/GP_Polygon.h @@ -26,18 +26,18 @@ #ifndef GFX_GP_POLYGON_H #define GFX_GP_POLYGON_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" -void GP_Polygon(GP_Context *context, unsigned int vertex_count, +void GP_Polygon(GP_Pixmap *pixmap, unsigned int vertex_count, const GP_Coord *xy, GP_Pixel pixel); -void GP_Polygon_Raw(GP_Context *context, unsigned int vertex_count, +void GP_Polygon_Raw(GP_Pixmap *pixmap, unsigned int vertex_count, const GP_Coord *xy, GP_Pixel pixel); -void GP_FillPolygon(GP_Context *context, unsigned int vertex_count, +void GP_FillPolygon(GP_Pixmap *pixmap, unsigned int vertex_count, const GP_Coord *xy, GP_Pixel pixel); -void GP_FillPolygon_Raw(GP_Context *context, unsigned int vertex_count, +void GP_FillPolygon_Raw(GP_Pixmap *pixmap, unsigned int vertex_count, const GP_Coord *xy, GP_Pixel pixel); #endif /* GFX_GP_POLYGON_H */ diff --git a/include/gfx/GP_PutPixelAA.h b/include/gfx/GP_PutPixelAA.h index 2852cc4c..aa02ef21 100644 --- a/include/gfx/GP_PutPixelAA.h +++ b/include/gfx/GP_PutPixelAA.h @@ -22,12 +22,12 @@ /* - Puts an anti aliased pixel to context. + Puts an anti aliased pixel to pixmap. 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 + For RGB pixmaps gamma correction tables are used to generate correct intensity for pixels. */ @@ -35,23 +35,23 @@ #ifndef GFX_GP_PUT_PIXEL_AA_H #define GFX_GP_PUT_PIXEL_AA_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" /* - * Anti Aliased Put Pixel respecting context rotation flags and with clipping. + * Anti Aliased Put Pixel respecting pixmap rotation flags and with clipping. */ -void GP_PutPixelAA(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel pixel); +void GP_PutPixelAA(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel pixel); /* * Anti Aliased Put Pixel with clipping. */ -void GP_PutPixelAA_Raw_Clipped(GP_Context *context, GP_Coord x, GP_Coord y, +void GP_PutPixelAA_Raw_Clipped(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel pixel); /* * Raw Put Pixel. */ -void GP_PutPixelAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y, +void GP_PutPixelAA_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel pixel); #endif /* GFX_GP_PUT_PIXEL_AA_H */ diff --git a/include/gfx/GP_Rect.h b/include/gfx/GP_Rect.h index 5a3d57fe..70eadf50 100644 --- a/include/gfx/GP_Rect.h +++ b/include/gfx/GP_Rect.h @@ -26,61 +26,61 @@ #ifndef GP_RECT_H #define GP_RECT_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" /* Rectangle */ -void GP_RectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_RectXYXY(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel); -void GP_RectXYXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_RectXYXY_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel); -void GP_RectXYWH(GP_Context *context, GP_Coord x, GP_Coord y, +void GP_RectXYWH(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel); -void GP_RectXYWH_Raw(GP_Context *context, GP_Coord x, GP_Coord y, +void GP_RectXYWH_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel); /* The XYXY argument set is the default */ -static inline void GP_Rect(GP_Context *context, GP_Coord x0, GP_Coord y0, +static inline void GP_Rect(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { - GP_RectXYXY(context, x0, y0, x1, y1, pixel); + GP_RectXYXY(pixmap, x0, y0, x1, y1, pixel); } -static inline void GP_Rect_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +static inline void GP_Rect_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { - GP_RectXYXY_Raw(context, x0, y0, x1, y1, pixel); + GP_RectXYXY_Raw(pixmap, x0, y0, x1, y1, pixel); } /* Filled Rectangle */ -void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_FillRectXYXY(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel); -void GP_FillRectXYXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_FillRectXYXY_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel); -void GP_FillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y, +void GP_FillRectXYWH(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel); -void GP_FillRectXYWH_Raw(GP_Context *context, GP_Coord x, GP_Coord y, +void GP_FillRectXYWH_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel); /* The XYXY argument set is the default */ -static inline void GP_FillRect(GP_Context *context, GP_Coord x0, GP_Coord y0, +static inline void GP_FillRect(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { - GP_FillRectXYXY(context, x0, y0, x1, y1, pixel); + GP_FillRectXYXY(pixmap, x0, y0, x1, y1, pixel); } -static inline void GP_FillRect_Raw(GP_Context *context, +static inline void GP_FillRect_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { - GP_FillRectXYXY_Raw(context, x0, y0, x1, y1, pixel); + GP_FillRectXYXY_Raw(pixmap, x0, y0, x1, y1, pixel); } #endif /* GP_RECT_H */ diff --git a/include/gfx/GP_Tetragon.h b/include/gfx/GP_Tetragon.h index c6307c38..bcc1a1b6 100644 --- a/include/gfx/GP_Tetragon.h +++ b/include/gfx/GP_Tetragon.h @@ -26,25 +26,25 @@ #ifndef GP_TETRAGON_H #define GP_TETRAGON_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" /* Tetragon */ -void GP_Tetragon(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Tetragon(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Coord x3, GP_Coord y3, GP_Pixel pixel); -void GP_Tetragon_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Tetragon_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Coord x3, GP_Coord y3, GP_Pixel pixel); /* Filled Tetragon */ -void GP_FillTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_FillTetragon(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Coord x3, GP_Coord y3, GP_Pixel pixel); -void GP_FillTetragon_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_FillTetragon_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Coord x3, GP_Coord y3, GP_Pixel pixel); diff --git a/include/gfx/GP_Triangle.h b/include/gfx/GP_Triangle.h index 2496d89e..0c2faedf 100644 --- a/include/gfx/GP_Triangle.h +++ b/include/gfx/GP_Triangle.h @@ -26,25 +26,25 @@ #ifndef GP_TRIANGLE_H #define GP_TRIANGLE_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" /* Triangle */ -void GP_Triangle(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Triangle(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Pixel pixel); -void GP_Triangle_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Triangle_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Pixel pixel); /* Filled Triangle */ -void GP_FillTriangle(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_FillTriangle(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Pixel pixel); -void GP_FillTriangle_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_FillTriangle_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Pixel pixel); diff --git a/include/gfx/GP_VLine.gen.h.t b/include/gfx/GP_VLine.gen.h.t index 0261557d..4a1acb08 100644 --- a/include/gfx/GP_VLine.gen.h.t +++ b/include/gfx/GP_VLine.gen.h.t @@ -6,6 +6,6 @@ */ @ for ps in pixelsizes: -void GP_VLine_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord x, +void GP_VLine_Raw_{{ ps.suffix }}(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel); diff --git a/include/gfx/GP_VLine.h b/include/gfx/GP_VLine.h index 269d57ad..6c3f3810 100644 --- a/include/gfx/GP_VLine.h +++ b/include/gfx/GP_VLine.h @@ -26,34 +26,34 @@ #ifndef GFX_GP_VLINE_H #define GFX_GP_VLINE_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" /* Raw per BPP HLines */ #include "gfx/GP_VLine.gen.h" -void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0, +void GP_VLineXYY(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel); -void GP_VLineXYY_Raw(GP_Context *context, GP_Coord x, GP_Coord y0, +void GP_VLineXYY_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel); -void GP_VLineXYH(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size h, +void GP_VLineXYH(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size h, GP_Pixel pixel); -void GP_VLineXYH_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size h, +void GP_VLineXYH_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size h, GP_Pixel pixel); /* default argument set is XYY */ -static inline void GP_VLine(GP_Context *context, GP_Coord x, +static inline void GP_VLine(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel) { - GP_VLineXYY(context, x, y0, y1, pixel); + GP_VLineXYY(pixmap, x, y0, y1, pixel); } -static inline void GP_VLine_Raw(GP_Context *context, GP_Coord x, +static inline void GP_VLine_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel) { - GP_VLineXYY_Raw(context, x, y0, y1, pixel); + GP_VLineXYY_Raw(pixmap, x, y0, y1, pixel); } #endif /* GFX_GP_VLINE_H */ diff --git a/include/gfx/GP_VLineAA.h b/include/gfx/GP_VLineAA.h index 87bf5865..12ad90ee 100644 --- a/include/gfx/GP_VLineAA.h +++ b/include/gfx/GP_VLineAA.h @@ -27,7 +27,7 @@ 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 + For RGB pixmaps gamma correction tables are used to generate correct intensity for pixels. */ @@ -35,18 +35,18 @@ #ifndef GFX_GP_VLINE_AA_H #define GFX_GP_VLINE_AA_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" /* - * Anti Aliased Horizontal Line respecting context rotation flags and with clipping. + * Anti Aliased Horizontal Line respecting pixmap rotation flags and with clipping. */ -void GP_VLineAA(GP_Context *context, GP_Coord x, GP_Coord y0, GP_Coord y1, +void GP_VLineAA(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel); /* * Horizontal Line without contect rotation flags. */ -void GP_VLineAA_Raw(GP_Context *context, GP_Coord x, +void GP_VLineAA_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel); #endif /* GFX_GP_VLINE_AA_H */ diff --git a/include/grabbers/GP_Grabber.h b/include/grabbers/GP_Grabber.h index f47fd863..37c7c25c 100644 --- a/include/grabbers/GP_Grabber.h +++ b/include/grabbers/GP_Grabber.h @@ -23,13 +23,13 @@ #ifndef GP_GRABBERS_GRABBER_H #define GP_GRABBERS_GRABBER_H -struct GP_Context; +struct GP_Pixmap; typedef struct GP_Grabber { /* - * Context with current frame. + * Pixmap with current frame. */ - struct GP_Context *frame; + struct GP_Pixmap *frame; /* * Returns 0 if there are no images in queue and 1 otherwise. diff --git a/include/loaders/GP_BMP.h b/include/loaders/GP_BMP.h index da388d0b..cf140d73 100644 --- a/include/loaders/GP_BMP.h +++ b/include/loaders/GP_BMP.h @@ -25,36 +25,36 @@ #include "loaders/GP_Loader.h" -int GP_ReadBMPEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, +int GP_ReadBMPEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); -int GP_LoadBMPEx(const char *src_path, GP_Context **img, +int GP_LoadBMPEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); /* * Reads a BMP from an IO stream. */ -GP_Context *GP_ReadBMP(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadBMP(GP_IO *io, GP_ProgressCallback *callback); /* * Loads a BMP image from a file. */ -GP_Context *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback); /* * Writes a BMP to an IO Stream. * * Returns zero on success, non-zero on failure and errno is set. */ -int GP_WriteBMP(const GP_Context *src, GP_IO *io, +int GP_WriteBMP(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback); /* * Saves BMP to a file. Zero is returned on succes. Upon failure non-zero is * returned and errno is filled accordingly. */ -int GP_SaveBMP(const GP_Context *src, const char *dst_path, +int GP_SaveBMP(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); /* diff --git a/include/loaders/GP_Container.h b/include/loaders/GP_Container.h index c1df3946..b7feb7a2 100644 --- a/include/loaders/GP_Container.h +++ b/include/loaders/GP_Container.h @@ -30,7 +30,7 @@ #ifndef LOADERS_GP_CONTAINER_H #define LOADERS_GP_CONTAINER_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_ProgressCallback.h" #include "loaders/GP_DataStorage.h" @@ -48,13 +48,13 @@ struct GP_ContainerOps { * Loads next image from container, use the inline function defined * below. */ - GP_Context *(*LoadNext)(struct GP_Container *self, + GP_Pixmap *(*LoadNext)(struct GP_Container *self, GP_ProgressCallback *callback); /* * Just loads current image, does not advance to the next image. */ - int (*LoadEx)(struct GP_Container *self, GP_Context **img, + int (*LoadEx)(struct GP_Container *self, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); /* @@ -102,7 +102,7 @@ typedef struct GP_Container { /* * Behaves just like GP_LoadImage, but takes pointer to opened container instead. */ -static inline GP_Context *GP_ContainerLoadNext(GP_Container *self, +static inline GP_Pixmap *GP_ContainerLoadNext(GP_Container *self, GP_ProgressCallback *callback) { return self->ops->LoadNext(self, callback); @@ -111,13 +111,13 @@ static inline GP_Context *GP_ContainerLoadNext(GP_Container *self, /* * Just loads current image, does not advance to the next one. */ -int GP_ContainerLoadEx(GP_Container *self, GP_Context **img, +int GP_ContainerLoadEx(GP_Container *self, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); -static inline GP_Context *GP_ContainerLoad(GP_Container *self, +static inline GP_Pixmap *GP_ContainerLoad(GP_Container *self, GP_ProgressCallback *callback) { - GP_Context *ret = NULL; + GP_Pixmap *ret = NULL; GP_ContainerLoadEx(self, &ret, NULL, callback); diff --git a/include/loaders/GP_GIF.h b/include/loaders/GP_GIF.h index 989259f4..dcc7ea97 100644 --- a/include/loaders/GP_GIF.h +++ b/include/loaders/GP_GIF.h @@ -34,15 +34,15 @@ /* * Reads first image found in GIF container from an IO stream. * - * Returns newly allocated context cotaining the loaded image or in case of + * Returns newly allocated pixmap cotaining the loaded image or in case of * failure NULL and errno is set. */ -GP_Context *GP_ReadGIF(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadGIF(GP_IO *io, GP_ProgressCallback *callback); /* * Loads first image found in GIF container from a file. */ -GP_Context *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback); /* * Looks for GIF file signature. Returns non-zero if found. diff --git a/include/loaders/GP_JP2.h b/include/loaders/GP_JP2.h index 8dd4477f..746f26a4 100644 --- a/include/loaders/GP_JP2.h +++ b/include/loaders/GP_JP2.h @@ -31,21 +31,21 @@ #include "loaders/GP_Loader.h" -int GP_ReadJP2Ex(GP_IO *io, GP_Context **rimg, GP_DataStorage *storage, +int GP_ReadJP2Ex(GP_IO *io, GP_Pixmap **rimg, GP_DataStorage *storage, GP_ProgressCallback *callback); -int GP_LoadJP2Ex(const char *src_path, GP_Context **img, +int GP_LoadJP2Ex(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); /* * Reads a JPEG2000 from an IO stream. */ -GP_Context *GP_ReadJP2(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadJP2(GP_IO *io, GP_ProgressCallback *callback); /* * Loads a JPEG2000 image from a file. */ -GP_Context *GP_LoadJP2(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadJP2(const char *src_path, GP_ProgressCallback *callback); /* * Looks for JPEG2000 file signature. Returns non-zero if found. diff --git a/include/loaders/GP_JPG.h b/include/loaders/GP_JPG.h index e19eb431..77b38b88 100644 --- a/include/loaders/GP_JPG.h +++ b/include/loaders/GP_JPG.h @@ -34,32 +34,32 @@ /* * Extended loading function. */ -int GP_ReadJPGEx(GP_IO *io, GP_Context **img, +int GP_ReadJPGEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); -int GP_LoadJPGEx(const char *src_path, GP_Context **img, +int GP_LoadJPGEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); /* * Loads a JPEG image from a file. */ -GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback); /* * Reads a JPEG image from an I/O stream. */ -GP_Context *GP_ReadJPG(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadJPG(GP_IO *io, GP_ProgressCallback *callback); /* * Writes JPEG into an I/O stream. */ -int GP_WriteJPG(const GP_Context *src, GP_IO *io, +int GP_WriteJPG(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback); /* * Saves JPEG to a file. */ -int GP_SaveJPG(const GP_Context *src, const char *dst_path, +int GP_SaveJPG(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); /* diff --git a/include/loaders/GP_Loader.h b/include/loaders/GP_Loader.h index f65c1094..798b34e2 100644 --- a/include/loaders/GP_Loader.h +++ b/include/loaders/GP_Loader.h @@ -29,7 +29,7 @@ #ifndef LOADERS_GP_LOADER_H #define LOADERS_GP_LOADER_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_ProgressCallback.h" #include "loaders/GP_IO.h" @@ -41,9 +41,9 @@ * The image format is matched from the file signature (first few bytes of the * I/O stream). */ -GP_Context *GP_ReadImage(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadImage(GP_IO *io, GP_ProgressCallback *callback); -int GP_ReadImageEx(GP_IO *io, GP_Context **img, GP_DataStorage *meta_data, +int GP_ReadImageEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *meta_data, GP_ProgressCallback *callback); /* @@ -51,10 +51,10 @@ int GP_ReadImageEx(GP_IO *io, GP_Context **img, GP_DataStorage *meta_data, * * If operation fails NULL is returned and errno is filled. */ -GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback); int GP_LoadImageEx(const char *src_path, - GP_Context **img, GP_DataStorage *meta_data, + GP_Pixmap **img, GP_DataStorage *meta_data, GP_ProgressCallback *callback); /* @@ -76,7 +76,7 @@ int GP_LoadMetaData(const char *src_path, GP_DataStorage *storage); * The resulting errno may also be set to any possible error from fopen(3), open(3), * write(3), fwrite(3), seek(3), etc.. */ -int GP_SaveImage(const GP_Context *src, const char *dst_path, +int GP_SaveImage(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); /* @@ -86,7 +86,7 @@ typedef struct GP_Loader { /* * Reads image and/or metadata from an I/O stream. */ - int (*Read)(GP_IO *io, GP_Context **img, GP_DataStorage *storage, + int (*Read)(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); /* @@ -94,7 +94,7 @@ typedef struct GP_Loader { * * Returns zero on success, non-zero on failure and errno must be set. */ - int (*Write)(const GP_Context *src, GP_IO *io, + int (*Write)(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback); /* @@ -154,9 +154,9 @@ void GP_LoaderUnregister(const GP_Loader *self); * Generic LoadImage for a given loader. * * The function prepares the I/O from file, calls the loader Read() method, - * closes the I/O and returns the context. + * closes the I/O and returns the pixmap. */ -GP_Context *GP_LoaderLoadImage(const GP_Loader *self, const char *src_path, +GP_Pixmap *GP_LoaderLoadImage(const GP_Loader *self, const char *src_path, GP_ProgressCallback *callback); /* @@ -164,7 +164,7 @@ GP_Context *GP_LoaderLoadImage(const GP_Loader *self, const char *src_path, * * The function calls the loader Read() method for a given I/O. */ -GP_Context *GP_LoaderReadImage(const GP_Loader *self, GP_IO *io, +GP_Pixmap *GP_LoaderReadImage(const GP_Loader *self, GP_IO *io, GP_ProgressCallback *callback); /* @@ -173,17 +173,17 @@ GP_Context *GP_LoaderReadImage(const GP_Loader *self, GP_IO *io, * The function calls the loader Read() method for a given I/O. */ int GP_LoaderReadImageEx(const GP_Loader *self, GP_IO *io, - GP_Context **img, GP_DataStorage *data, + GP_Pixmap **img, GP_DataStorage *data, GP_ProgressCallback *callback); /* * Generic LoadImageEx for a given loader. * * The function prepares the I/O from file, calls the loader ReadEx() method, - * closes the I/O and returns the context. + * closes the I/O and returns the pixmap. */ int GP_LoaderLoadImageEx(const GP_Loader *self, const char *src_path, - GP_Context **img, GP_DataStorage *data, + GP_Pixmap **img, GP_DataStorage *data, GP_ProgressCallback *callback); /* @@ -192,7 +192,7 @@ int GP_LoaderLoadImageEx(const GP_Loader *self, const char *src_path, * The function/ prepares the I/O from file, calls the loader Write() method * and closes the I/O. */ -int GP_LoaderSaveImage(const GP_Loader *self, const GP_Context *src, +int GP_LoaderSaveImage(const GP_Loader *self, const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); /* diff --git a/include/loaders/GP_Loaders.h b/include/loaders/GP_Loaders.h index bb2f6998..1999beb6 100644 --- a/include/loaders/GP_Loaders.h +++ b/include/loaders/GP_Loaders.h @@ -32,7 +32,7 @@ #ifndef LOADERS_GP_LOADERS_H #define LOADERS_GP_LOADERS_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_ProgressCallback.h" #include "loaders/GP_PNM.h" diff --git a/include/loaders/GP_PCX.h b/include/loaders/GP_PCX.h index b7eba193..2388b479 100644 --- a/include/loaders/GP_PCX.h +++ b/include/loaders/GP_PCX.h @@ -34,21 +34,21 @@ /* * Extended loading function. */ -int GP_ReadPCXEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, +int GP_ReadPCXEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); -int GP_LoadPCXEx(const char *src_path, GP_Context **img, +int GP_LoadPCXEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); /* * Reads a PCX from an IO stream. */ -GP_Context *GP_ReadPCX(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPCX(GP_IO *io, GP_ProgressCallback *callback); /* * Loads a PCX image from a file. */ -GP_Context *GP_LoadPCX(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPCX(const char *src_path, GP_ProgressCallback *callback); /* * Match PCX signature. diff --git a/include/loaders/GP_PNG.h b/include/loaders/GP_PNG.h index f78431c0..171f42f2 100644 --- a/include/loaders/GP_PNG.h +++ b/include/loaders/GP_PNG.h @@ -34,34 +34,34 @@ /* * Loads a PNG image from a file. */ -GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback); /* * Extended load function. */ -int GP_ReadPNGEx(GP_IO *io, GP_Context **img, +int GP_ReadPNGEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); -int GP_LoadPNGEx(const char *src_path, GP_Context **img, +int GP_LoadPNGEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); /* * Reads a PNG from an IO stream. * - * Returns newly allocated context cotaining the loaded image or in case of + * Returns newly allocated pixmap cotaining the loaded image or in case of * failure NULL and errno is set. */ -GP_Context *GP_ReadPNG(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPNG(GP_IO *io, GP_ProgressCallback *callback); /* * Writes PNG into an I/O stream. */ -int GP_SavePNG(const GP_Context *src, const char *dst_path, +int GP_SavePNG(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); /* * Saves PNG to a file. */ -int GP_SavePNG(const GP_Context *src, const char *dst_path, +int GP_SavePNG(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); /* diff --git a/include/loaders/GP_PNM.h b/include/loaders/GP_PNM.h index 4397c636..7135f702 100644 --- a/include/loaders/GP_PNM.h +++ b/include/loaders/GP_PNM.h @@ -28,54 +28,54 @@ /* * PBM Bitmap */ -GP_Context *GP_ReadPBM(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPBM(GP_IO *io, GP_ProgressCallback *callback); -GP_Context *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback); -int GP_WritePBM(const GP_Context *src, GP_IO *io, +int GP_WritePBM(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback); -int GP_SavePBM(const GP_Context *src, const char *dst_path, +int GP_SavePBM(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); /* * PGM Graymap */ -GP_Context *GP_ReadPGM(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPGM(GP_IO *io, GP_ProgressCallback *callback); -GP_Context *GP_LoadPGM(const char *src_path, +GP_Pixmap *GP_LoadPGM(const char *src_path, GP_ProgressCallback *callback); -int GP_WritePGM(const GP_Context *src, GP_IO *io, +int GP_WritePGM(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback); -int GP_SavePGM(const GP_Context *src, const char *dst_path, +int GP_SavePGM(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); /* * PPM Pixmap */ -GP_Context *GP_ReadPPM(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPPM(GP_IO *io, GP_ProgressCallback *callback); -GP_Context *GP_LoadPPM(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPPM(const char *src_path, GP_ProgressCallback *callback); -int GP_WritePPM(const GP_Context *src, GP_IO *io, +int GP_WritePPM(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback); -int GP_SavePPM(const GP_Context *src, const char *dst_path, +int GP_SavePPM(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); /* * PNM Anymap (All of above) */ -GP_Context *GP_ReadPNM(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPNM(GP_IO *io, GP_ProgressCallback *callback); -GP_Context *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback); -int GP_WritePNM(const GP_Context *src, GP_IO *io, +int GP_WritePNM(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback); -int GP_SavePNM(const GP_Context *src, const char *dst_path, +int GP_SavePNM(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); /* diff --git a/include/loaders/GP_PSD.h b/include/loaders/GP_PSD.h index 8855cc3c..29c1bb55 100644 --- a/include/loaders/GP_PSD.h +++ b/include/loaders/GP_PSD.h @@ -35,15 +35,15 @@ #include "loaders/GP_Loader.h" -int GP_ReadPSDEx(GP_IO *io, GP_Context **img, +int GP_ReadPSDEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); -int GP_LoadPSDEx(const char *src_path, GP_Context **img, +int GP_LoadPSDEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); -GP_Context *GP_ReadPSD(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPSD(GP_IO *io, GP_ProgressCallback *callback); -GP_Context *GP_LoadPSD(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPSD(const char *src_path, GP_ProgressCallback *callback); int GP_MatchPSD(const void *buf); diff --git a/include/loaders/GP_PSP.h b/include/loaders/GP_PSP.h index 0132d2f8..bc6ebeac 100644 --- a/include/loaders/GP_PSP.h +++ b/include/loaders/GP_PSP.h @@ -36,20 +36,20 @@ /* * Reads a BMP from an IO stream. * - * Returns newly allocated context cotaining the loaded image or in case of + * Returns newly allocated pixmap cotaining the loaded image or in case of * failure NULL and errno is set. */ -GP_Context *GP_ReadPSP(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadPSP(GP_IO *io, GP_ProgressCallback *callback); /* * Loads a PSP image from a file. */ -GP_Context *GP_LoadPSP(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadPSP(const char *src_path, GP_ProgressCallback *callback); -int GP_ReadPSPEx(GP_IO *io, GP_Context **img, +int GP_ReadPSPEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); -int GP_LoadPSPEx(const char *src_path, GP_Context **img, +int GP_LoadPSPEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); /* diff --git a/include/loaders/GP_TIFF.h b/include/loaders/GP_TIFF.h index 83145ed7..b239a01c 100644 --- a/include/loaders/GP_TIFF.h +++ b/include/loaders/GP_TIFF.h @@ -28,31 +28,31 @@ /* * Extended loading function. */ -int GP_ReadTIFFEx(GP_IO *io, GP_Context **img, +int GP_ReadTIFFEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); -int GP_LoadTIFFEx(const char *src_path, GP_Context **img, +int GP_LoadTIFFEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback); /* * Reads first image in TIFF from an IO stream. */ -GP_Context *GP_ReadTIFF(GP_IO *io, GP_ProgressCallback *callback); +GP_Pixmap *GP_ReadTIFF(GP_IO *io, GP_ProgressCallback *callback); /* * Loads fist image in TIFF from a file. */ -GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback); +GP_Pixmap *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback); /* * Writes TIFF into an I/O stream. */ -int GP_WriteTIFF(const GP_Context *src, GP_IO *io, +int GP_WriteTIFF(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback); /* * Saves TIFF. */ -int GP_SaveTIFF(const GP_Context *src, const char *dst_path, +int GP_SaveTIFF(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback); /* diff --git a/include/loaders/GP_ZIP.h b/include/loaders/GP_ZIP.h index cb97efd2..540c7efb 100644 --- a/include/loaders/GP_ZIP.h +++ b/include/loaders/GP_ZIP.h @@ -29,7 +29,7 @@ #ifndef LOADERS_GP_ZIP_H #define LOADERS_GP_ZIP_H -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_ProgressCallback.h" #include "loaders/GP_Container.h" diff --git a/include/text/GP_Text.h b/include/text/GP_Text.h index 30176d05..5299db10 100644 --- a/include/text/GP_Text.h +++ b/include/text/GP_Text.h @@ -28,7 +28,7 @@ #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "text/GP_TextStyle.h" #include "text/GP_TextMetric.h" @@ -45,7 +45,7 @@ * - GP_VALIGN_CENTER centers the text vertically at the point * - GP_VALIGN_BASELINE places the text baseline at the point * - GP_VALIGN_BELOW (or BOTTOM) draws the text below the point - * - GP_TEXT_NOBG mix the alpha pixels with data read from the context + * - GP_TEXT_NOBG mix the alpha pixels with data read from the pixmap * rather than mixing them with bg_color * (which is slightly slower) */ @@ -66,9 +66,9 @@ typedef enum GP_TextAttr { * Raw version, doesn't use Text aligment. * * If flags are set to GP_TEXT_NOBG the the bg_color is ignored and - * the context pixels are used for alpha mixing. + * the pixmap pixels are used for alpha mixing. */ -void GP_Text_Raw(GP_Context *context, const GP_TextStyle *style, +void GP_Text_Raw(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, uint8_t flags, GP_Pixel fg_color, GP_Pixel bg_color, const char *str); @@ -76,38 +76,38 @@ 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 string is rendered to pixmap (horizontally) with defined text style. * The x and y coordinates determines point defined by aligment flags. * * The background color is ignored for 1bpp font formats. */ -void GP_Text(GP_Context *context, const GP_TextStyle *style, +void GP_Text(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel fg_color, GP_Pixel bg_color, const char *str); /* * Same as above, but printf like and returns text width in pixels. */ -GP_Size GP_Print(GP_Context *context, const GP_TextStyle *style, +GP_Size GP_Print(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel fg_color, GP_Pixel bg_color, const char *fmt, ...) __attribute__ ((format (printf, 8, 9))); -GP_Size GP_VPrint(GP_Context *context, const GP_TextStyle *style, +GP_Size GP_VPrint(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel fg_color, GP_Pixel bg_color, const char *fmt, va_list va); /* * Clears rectangle that would be used to draw text of size pixels. */ -void GP_TextClear(GP_Context *context, const GP_TextStyle *style, +void GP_TextClear(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel bg_color, GP_Size size); /* * Dtto, but with string. */ -void GP_TextClearStr(GP_Context *context, const GP_TextStyle *style, +void GP_TextClearStr(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel bg_color, const char *str); diff --git a/libs/backends/GP_AALib.c b/libs/backends/GP_AALib.c index bfcd9468..22880987 100644 --- a/libs/backends/GP_AALib.c +++ b/libs/backends/GP_AALib.c @@ -23,7 +23,7 @@ #include #include "core/GP_Debug.h" -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "backends/GP_AALib.h" #include "input/GP_Input.h" @@ -44,7 +44,7 @@ static pthread_mutex_t aalib_mutex = PTHREAD_MUTEX_INITIALIZER; struct aalib_priv { aa_context *c; - GP_Context ctx; + GP_Pixmap pixmap; }; /* ascii mapped keys */ @@ -145,9 +145,9 @@ static int aalib_resize_ack(GP_Backend *self) int w = aa_imgwidth(aa->c); int h = aa_imgheight(aa->c); - GP_DEBUG(1, "Reinitializing Context %ix%i", w, h); + GP_DEBUG(1, "Reinitializing Pixmap %ix%i", w, h); - GP_ContextInit(&aa->ctx, w, h, GP_PIXEL_G8, aa_image(aa->c)); + GP_PixmapInit(&aa->pixmap, w, h, GP_PIXEL_G8, aa_image(aa->c)); return 0; } @@ -241,13 +241,13 @@ GP_Backend *GP_BackendAALibInit(void) w = aa_imgwidth(aa->c); h = aa_imgheight(aa->c); - GP_DEBUG(1, "Initializing Context %ix%i", w, h); + GP_DEBUG(1, "Initializing Pixmap %ix%i", w, h); - GP_ContextInit(&aa->ctx, w, h, GP_PIXEL_G8, aa_image(aa->c)); + GP_PixmapInit(&aa->pixmap, w, h, GP_PIXEL_G8, aa_image(aa->c)); /* update API */ backend->name = "AALib"; - backend->context = &aa->ctx; + backend->pixmap = &aa->pixmap; backend->Flip = aalib_flip; backend->UpdateRect = aalib_update_rect; backend->Exit = aalib_exit; diff --git a/libs/backends/GP_Backend.c b/libs/backends/GP_Backend.c index e209a2cb..b4d2d964 100644 --- a/libs/backends/GP_Backend.c +++ b/libs/backends/GP_Backend.c @@ -45,8 +45,8 @@ void GP_BackendUpdateRectXYXY(GP_Backend *backend, if (backend->UpdateRect == NULL) return; - GP_TRANSFORM_POINT(backend->context, x0, y0); - GP_TRANSFORM_POINT(backend->context, x1, y1); + GP_TRANSFORM_POINT(backend->pixmap, x0, y0); + GP_TRANSFORM_POINT(backend->pixmap, x1, y1); if (x1 < x0) GP_SWAP(x0, x1); @@ -64,14 +64,14 @@ void GP_BackendUpdateRectXYXY(GP_Backend *backend, y0 = 0; } - GP_Coord w = backend->context->w; + GP_Coord w = backend->pixmap->w; if (x1 >= w) { GP_WARN("Too large x coordinate %i, clipping to %u", x1, w - 1); x1 = w - 1; } - GP_Coord h = backend->context->h; + GP_Coord h = backend->pixmap->h; if (y1 >= h) { GP_WARN("Too large y coordinate %i, clipping to %u", y1, h - 1); @@ -88,12 +88,12 @@ int GP_BackendResize(GP_Backend *backend, uint32_t w, uint32_t h) return 1; if (w == 0) - w = backend->context->w; + w = backend->pixmap->w; if (h == 0) - h = backend->context->h; + h = backend->pixmap->h; - if (backend->context->w == w && backend->context->h == h) + if (backend->pixmap->w == w && backend->pixmap->h == h) return 0; return backend->SetAttributes(backend, w, h, NULL); diff --git a/libs/backends/GP_BackendVirtual.c b/libs/backends/GP_BackendVirtual.c index fd1c2d27..c65c7c75 100644 --- a/libs/backends/GP_BackendVirtual.c +++ b/libs/backends/GP_BackendVirtual.c @@ -22,7 +22,7 @@ #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_Blit.h" #include "core/GP_Debug.h" @@ -40,8 +40,8 @@ static void virt_flip(GP_Backend *self) struct virt_priv *virt = GP_BACKEND_PRIV(self); /* Convert and copy the buffer */ - GP_Blit(self->context, 0, 0, self->context->w, self->context->h, - virt->backend->context, 0, 0); + GP_Blit(self->pixmap, 0, 0, self->pixmap->w, self->pixmap->h, + virt->backend->pixmap, 0, 0); /* Call blit on original backend */ virt->backend->Flip(virt->backend); @@ -53,8 +53,8 @@ static void virt_update_rect(GP_Backend *self, GP_Coord x0, GP_Coord y0, 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); + GP_BlitXYXY(self->pixmap, x0, y0, x1, y1, + virt->backend->pixmap, x0, y0); /* Call blit on original backend */ virt->backend->UpdateRect(virt->backend, x0, y0, x1, y1); @@ -74,7 +74,7 @@ static int virt_set_attrs(struct GP_Backend *self, /* If backend was resized, update our buffer as well */ if (h != 0 && w != 0) - GP_ContextResize(self->context, w, h); + GP_PixmapResize(self->pixmap, w, h); return 0; } @@ -107,7 +107,7 @@ static void virt_exit(GP_Backend *self) { struct virt_priv *virt = GP_BACKEND_PRIV(self); - GP_ContextFree(self->context); + GP_PixmapFree(self->pixmap); if (virt->flags & GP_BACKEND_CALL_EXIT) virt->backend->Exit(virt->backend); @@ -125,9 +125,9 @@ static int virt_resize_ack(GP_Backend *self) if (ret) return ret; - return GP_ContextResize(self->context, - virt->backend->context->w, - virt->backend->context->h); + return GP_PixmapResize(self->pixmap, + virt->backend->pixmap->w, + virt->backend->pixmap->h); } GP_Backend *GP_BackendVirtualInit(GP_Backend *backend, @@ -146,11 +146,11 @@ GP_Backend *GP_BackendVirtualInit(GP_Backend *backend, memset(self, 0, sizeof(GP_Backend)); - /* Create new buffer with different context type */ - self->context = GP_ContextAlloc(backend->context->w, backend->context->h, + /* Create new buffer with different pixmap type */ + self->pixmap = GP_PixmapAlloc(backend->pixmap->w, backend->pixmap->h, pixel_type); - if (self->context == NULL) + if (self->pixmap == NULL) goto err0; virt = GP_BACKEND_PRIV(self); @@ -168,8 +168,8 @@ GP_Backend *GP_BackendVirtualInit(GP_Backend *backend, self->SetAttributes = backend->SetAttributes ? virt_set_attrs : NULL; self->timers = NULL; - GP_EventQueueInit(&self->event_queue, backend->context->w, - backend->context->h, 0); + GP_EventQueueInit(&self->event_queue, backend->pixmap->w, + backend->pixmap->h, 0); return self; diff --git a/libs/backends/GP_LinuxFB.c b/libs/backends/GP_LinuxFB.c index c14195f1..e358dae3 100644 --- a/libs/backends/GP_LinuxFB.c +++ b/libs/backends/GP_LinuxFB.c @@ -40,7 +40,7 @@ #include "backends/GP_LinuxFB.h" struct fb_priv { - GP_Context context; + GP_Pixmap pixmap; uint32_t bsize; void *fb_mem; @@ -246,7 +246,7 @@ static void fb_exit(GP_Backend *self) struct fb_priv *fb = GP_BACKEND_PRIV(self); if (fb->flags & GP_FB_SHADOW) - free(fb->context.pixels); + free(fb->pixmap.pixels); /* unmap framebuffer */ munmap(fb->fb_mem, fb->bsize); @@ -266,7 +266,7 @@ static void fb_flip_shadow(GP_Backend *self) GP_DEBUG(2, "Flipping buffer"); - memcpy(fb->fb_mem, fb->context.pixels, fb->bsize); + memcpy(fb->fb_mem, fb->pixmap.pixels, fb->bsize); } static void fb_update_rect_shadow(GP_Backend *self, GP_Coord x0, GP_Coord y0, @@ -276,13 +276,13 @@ static void fb_update_rect_shadow(GP_Backend *self, GP_Coord x0, GP_Coord y0, GP_DEBUG(2, "Flipping buffer"); - size_t size = ((x1 - x0) * fb->context.bpp) / 8; + size_t size = ((x1 - x0) * fb->pixmap.bpp) / 8; for (;y0 <= y1; y0++) { - void *src = GP_PIXEL_ADDR(&fb->context, x0, y0); + void *src = GP_PIXEL_ADDR(&fb->pixmap, x0, y0); void *dst = (char*)fb->fb_mem + - y0 * fb->context.bytes_per_row + - (x0 * fb->context.bpp)/8; + y0 * fb->pixmap.bytes_per_row + + (x0 * fb->pixmap.bpp)/8; memcpy(dst, src, size); } } @@ -357,9 +357,9 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flags) } if (flags & GP_FB_SHADOW) { - fb->context.pixels = malloc(fscri.smem_len); + fb->pixmap.pixels = malloc(fscri.smem_len); - if (!fb->context.pixels) { + if (!fb->pixmap.pixels) { GP_DEBUG(1, "Malloc failed :("); goto err3; } @@ -379,25 +379,25 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flags) fb->flags = flags; if (!(flags & GP_FB_SHADOW)) - fb->context.pixels = fb->fb_mem; + fb->pixmap.pixels = fb->fb_mem; - fb->context.w = vscri.xres; - fb->context.h = vscri.yres; + fb->pixmap.w = vscri.xres; + fb->pixmap.h = vscri.yres; - fb->context.axes_swap = 0; - fb->context.x_swap = 0; - fb->context.y_swap = 0; + fb->pixmap.axes_swap = 0; + fb->pixmap.x_swap = 0; + fb->pixmap.y_swap = 0; - fb->context.bpp = vscri.bits_per_pixel; - fb->context.bytes_per_row = fscri.line_length; - fb->context.pixel_type = pixel_type; + fb->pixmap.bpp = vscri.bits_per_pixel; + fb->pixmap.bytes_per_row = fscri.line_length; + fb->pixmap.pixel_type = pixel_type; int shadow = flags & GP_FB_SHADOW; int kbd = flags & GP_FB_INPUT_KBD; /* update API */ backend->name = "Linux FB"; - backend->context = &fb->context; + backend->pixmap = &fb->pixmap; backend->Flip = shadow ? fb_flip_shadow : NULL; backend->UpdateRect = shadow ? fb_update_rect_shadow : NULL; backend->Exit = fb_exit; @@ -413,7 +413,7 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flags) return backend; err4: if (flags & GP_FB_SHADOW) - free(fb->context.pixels); + free(fb->pixmap.pixels); err3: close(fd); err2: diff --git a/libs/backends/GP_SDL.c b/libs/backends/GP_SDL.c index 47a7f941..c97a6e23 100644 --- a/libs/backends/GP_SDL.c +++ b/libs/backends/GP_SDL.c @@ -34,14 +34,14 @@ #include "GP_Backend.h" #include "GP_SDL.h" -#include "GP_SDL_Context.h" +#include "GP_SDL_Pixmap.h" #include #include static SDL_Surface *sdl_surface; static SDL_mutex *mutex; -static GP_Context context; +static GP_Pixmap pixmap; static uint32_t sdl_flags = SDL_SWSURFACE; @@ -56,7 +56,7 @@ static void sdl_flip(struct GP_Backend *self __attribute__((unused))) SDL_mutexP(mutex); SDL_Flip(sdl_surface); - context.pixels = sdl_surface->pixels; + pixmap.pixels = sdl_surface->pixels; SDL_mutexV(mutex); } @@ -121,7 +121,7 @@ static void sdl_wait(struct GP_Backend *self __attribute__((unused))) } } -static int context_from_surface(GP_Context *context, const SDL_Surface *surf) +static int pixmap_from_surface(GP_Pixmap *pixmap, const SDL_Surface *surf) { /* sanity checks on the SDL surface */ if (surf->format->BytesPerPixel == 0) { @@ -144,19 +144,19 @@ static int context_from_surface(GP_Context *context, const SDL_Surface *surf) return 1; /* basic structure and size */ - context->pixels = surf->pixels; - context->bpp = 8 * surf->format->BytesPerPixel; - context->pixel_type = pixeltype; - context->bytes_per_row = surf->pitch; - context->w = surf->w; - context->h = surf->h; + pixmap->pixels = surf->pixels; + pixmap->bpp = 8 * surf->format->BytesPerPixel; + pixmap->pixel_type = pixeltype; + pixmap->bytes_per_row = surf->pitch; + pixmap->w = surf->w; + pixmap->h = surf->h; return 0; } -int GP_ContextFromSDLSurface(GP_Context *c, const SDL_Surface *surf) +int GP_PixmapFromSDLSurface(GP_Pixmap *c, const SDL_Surface *surf) { - return context_from_surface(c, surf); + return pixmap_from_surface(c, surf); } static int sdl_set_attributes(struct GP_Backend *self, @@ -184,10 +184,10 @@ static int sdl_resize_ack(struct GP_Backend *self __attribute__((unused))) SDL_mutexP(mutex); sdl_surface = SDL_SetVideoMode(new_w, new_h, 0, sdl_flags); - context_from_surface(backend.context, sdl_surface); + pixmap_from_surface(backend.pixmap, sdl_surface); GP_EventQueueSetScreenSize(&backend.event_queue, - backend.context->w, backend.context->h); + backend.pixmap->w, backend.pixmap->h); SDL_mutexV(mutex); @@ -198,7 +198,7 @@ static void sdl_exit(struct GP_Backend *self __attribute__((unused))); static struct GP_Backend backend = { .name = "SDL", - .context = NULL, + .pixmap = NULL, .Flip = sdl_flip, .UpdateRect = sdl_update_rect, .SetAttributes = sdl_set_attributes, @@ -218,14 +218,14 @@ static void sdl_exit(struct GP_Backend *self __attribute__((unused))) SDL_DestroyMutex(mutex); - backend.context = NULL; + backend.pixmap = NULL; } GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp, uint8_t flags, const char *caption) { /* SDL was already initalized */ - if (backend.context != NULL) + if (backend.pixmap != NULL) return &backend; if (SDL_Init(SDL_INIT_VIDEO)) { @@ -252,7 +252,7 @@ GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp, uint8_t flags, mutex = SDL_CreateMutex(); - if (context_from_surface(&context, sdl_surface)) { + if (pixmap_from_surface(&pixmap, sdl_surface)) { GP_WARN("Failed to match pixel_type"); SDL_Quit(); return NULL; @@ -263,7 +263,7 @@ GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp, uint8_t flags, GP_EventQueueInit(&backend.event_queue, w, h, 0); - backend.context = &context; + backend.pixmap = &pixmap; return &backend; } diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c index 14f6ec2f..c6e812b9 100644 --- a/libs/backends/GP_X11.c +++ b/libs/backends/GP_X11.c @@ -86,10 +86,10 @@ static void x11_update_rect(GP_Backend *self, GP_Coord x0, GP_Coord y0, static void x11_flip(GP_Backend *self) { struct x11_win *win = GP_BACKEND_PRIV(self); - unsigned int w = self->context->w; - unsigned int h = self->context->h; + unsigned int w = self->pixmap->w; + unsigned int h = self->pixmap->h; - GP_DEBUG(4, "Flipping context"); + GP_DEBUG(4, "Flipping pixmap"); if (win->resized_flag) { GP_DEBUG(4, "Ignoring flip, waiting for resize ack"); @@ -136,13 +136,13 @@ static void x11_ev(XEvent *ev) break; /* Safety measure */ - if (ev->xexpose.x + ev->xexpose.width > (int)self->context->w) { - GP_WARN("Expose x + w > context->w"); + if (ev->xexpose.x + ev->xexpose.width > (int)self->pixmap->w) { + GP_WARN("Expose x + w > pixmap->w"); break; } - if (ev->xexpose.y + ev->xexpose.height > (int)self->context->h) { - GP_WARN("Expose y + h > context->h"); + if (ev->xexpose.y + ev->xexpose.height > (int)self->pixmap->h) { + GP_WARN("Expose y + h > pixmap->h"); break; } @@ -152,8 +152,8 @@ static void x11_ev(XEvent *ev) ev->xexpose.y + ev->xexpose.height - 1); break; case ConfigureNotify: - if (ev->xconfigure.width == (int)self->context->w && - ev->xconfigure.height == (int)self->context->h) + if (ev->xconfigure.width == (int)self->pixmap->w && + ev->xconfigure.height == (int)self->pixmap->h) break; if (ev->xconfigure.width == (int)win->new_w && @@ -170,7 +170,7 @@ static void x11_ev(XEvent *ev) default: //TODO: More accurate window w and h? x11_input_event_put(&self->event_queue, ev, - self->context->w, self->context->h); + self->pixmap->w, self->pixmap->h); break; } } @@ -318,7 +318,7 @@ static int create_shm_ximage(GP_Backend *self, GP_Size w, GP_Size h) return 1; } - if (self->context == NULL) + if (self->pixmap == NULL) GP_DEBUG(1, "Using MIT SHM Extension"); win->img = XShmCreateImage(win->dpy, win->vis, win->scr_depth, @@ -366,10 +366,10 @@ static int create_shm_ximage(GP_Backend *self, GP_Size w, GP_Size h) goto err2; } - GP_ContextInit(&win->context, w, h, pixel_type, win->shminfo.shmaddr); - win->context.bytes_per_row = win->img->bytes_per_line; + GP_PixmapInit(&win->pixmap, w, h, pixel_type, win->shminfo.shmaddr); + win->pixmap.bytes_per_row = win->img->bytes_per_line; - self->context = &win->context; + self->pixmap = &win->pixmap; win->shm_flag = 1; @@ -407,7 +407,7 @@ static int resize_shm_ximage(GP_Backend *self, int w, int h) int ret; GP_DEBUG(4, "Resizing XShmImage %ux%u -> %ux%u", - self->context->w, self->context->h, w, h); + self->pixmap->w, self->pixmap->h, w, h); XLockDisplay(win->dpy); @@ -479,15 +479,15 @@ static int create_ximage(GP_Backend *self, GP_Size w, GP_Size h) goto err1; } - self->context = GP_ContextAlloc(w, h, pixel_type); + self->pixmap = GP_PixmapAlloc(w, h, pixel_type); - if (self->context == NULL) { + if (self->pixmap == NULL) { GP_DEBUG(1, "Malloc failed :("); goto err1; } win->shm_flag = 0; - win->img->data = (char*)self->context->pixels; + win->img->data = (char*)self->pixmap->pixels; return 0; err1: @@ -500,7 +500,7 @@ static void destroy_ximage(GP_Backend *self) { struct x11_win *win = GP_BACKEND_PRIV(self); - GP_ContextFree(self->context); + GP_PixmapFree(self->pixmap); win->img->data = NULL; XDestroyImage(win->img); } @@ -519,8 +519,8 @@ static int resize_ximage(GP_Backend *self, int w, int h) return 1; } - /* Resize context */ - if (GP_ContextResize(self->context, w, h)) { + /* Resize pixmap */ + if (GP_PixmapResize(self->pixmap, w, h)) { XDestroyImage(img); return 1; } @@ -530,7 +530,7 @@ static int resize_ximage(GP_Backend *self, int w, int h) XDestroyImage(win->img); /* Swap the pointers */ - img->data = (char*)self->context->pixels; + img->data = (char*)self->pixmap->pixels; win->img = img; return 0; @@ -610,7 +610,7 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y, /* Init the event queue, once we know the window size */ GP_EventQueueInit(&backend->event_queue, wreq.w, wreq.h, 0); - backend->context = NULL; + backend->pixmap = NULL; if ((flags & GP_X11_DISABLE_SHM || !x11_conn.local) || create_shm_ximage(backend, wreq.w, wreq.h)) { diff --git a/libs/backends/GP_X11_Win.h b/libs/backends/GP_X11_Win.h index 2fc3098f..58873d1b 100644 --- a/libs/backends/GP_X11_Win.h +++ b/libs/backends/GP_X11_Win.h @@ -42,7 +42,7 @@ struct x11_win { XShmSegmentInfo shminfo; #endif /* HAVE_X_SHM */ - GP_Context context; + GP_Pixmap pixmap; /* Window list pointers */ struct x11_win *prev; diff --git a/libs/core/GP_Blit.c b/libs/core/GP_Blit.c index 8becf611..039f20ea 100644 --- a/libs/core/GP_Blit.c +++ b/libs/core/GP_Blit.c @@ -23,23 +23,23 @@ #include "core/GP_Pixel.h" #include "core/GP_GetPutPixel.h" -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_Convert.h" #include "core/GP_Debug.h" #include "core/GP_Blit.h" /* Generated functions */ -void GP_BlitXYXY_Raw_Fast(const GP_Context *src, +void GP_BlitXYXY_Raw_Fast(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2); + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2); -void GP_BlitXYXY_Fast(const GP_Context *src, +void GP_BlitXYXY_Fast(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2); + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2); -void GP_BlitXYXY(const GP_Context *src, +void GP_BlitXYXY(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2) + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2) { /* Normalize source rectangle */ if (x1 < x0) @@ -48,22 +48,22 @@ void GP_BlitXYXY(const GP_Context *src, if (y1 < y0) GP_SWAP(y0, y1); - /* All coordinates are inside of src the context */ - GP_CHECK(x0 < (GP_Coord)GP_ContextW(src)); - GP_CHECK(y0 < (GP_Coord)GP_ContextH(src)); - GP_CHECK(x1 < (GP_Coord)GP_ContextW(src)); - GP_CHECK(y1 < (GP_Coord)GP_ContextH(src)); + /* All coordinates are inside of src the pixmap */ + GP_CHECK(x0 < (GP_Coord)GP_PixmapW(src)); + GP_CHECK(y0 < (GP_Coord)GP_PixmapH(src)); + GP_CHECK(x1 < (GP_Coord)GP_PixmapW(src)); + GP_CHECK(y1 < (GP_Coord)GP_PixmapH(src)); /* Destination is big enough */ - GP_CHECK(x2 + (x1 - x0) < (GP_Coord)GP_ContextW(dst)); - GP_CHECK(y2 + (y1 - y0) < (GP_Coord)GP_ContextH(dst)); + GP_CHECK(x2 + (x1 - x0) < (GP_Coord)GP_PixmapW(dst)); + GP_CHECK(y2 + (y1 - y0) < (GP_Coord)GP_PixmapH(dst)); GP_BlitXYXY_Fast(src, x0, y0, x1, y1, dst, x2, y2); } -void GP_BlitXYXY_Clipped(const GP_Context *src, +void GP_BlitXYXY_Clipped(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2) + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2) { /* Normalize source rectangle */ if (x1 < x0) @@ -76,8 +76,8 @@ void GP_BlitXYXY_Clipped(const GP_Context *src, * Handle all cases where at least one of dest coordinates are out of * the dest in positive direction -> src is out of dst completly. */ - if (x2 >= (GP_Coord)GP_ContextW(dst) || - y2 >= (GP_Coord)GP_ContextH(dst)) + if (x2 >= (GP_Coord)GP_PixmapW(dst) || + y2 >= (GP_Coord)GP_PixmapH(dst)) return; /* @@ -101,15 +101,15 @@ void GP_BlitXYXY_Clipped(const GP_Context *src, /* Make sure souce coordinates are inside of the src */ x0 = GP_MAX(x0, 0); y0 = GP_MAX(y0, 0); - x1 = GP_MIN(x1, (GP_Coord)GP_ContextW(src) - 1); - y1 = GP_MIN(y1, (GP_Coord)GP_ContextH(src) - 1); + x1 = GP_MIN(x1, (GP_Coord)GP_PixmapW(src) - 1); + y1 = GP_MIN(y1, (GP_Coord)GP_PixmapH(src) - 1); /* And source rectangle fits inside of the destination */ GP_Coord src_w = x1 - x0 + 1; GP_Coord src_h = y1 - y0 + 1; - GP_Coord dst_w = GP_ContextW(dst) - x2; - GP_Coord dst_h = GP_ContextH(dst) - y2; + GP_Coord dst_w = GP_PixmapW(dst) - x2; + GP_Coord dst_h = GP_PixmapH(dst) - y2; GP_DEBUG(2, "Blitting %ix%i, available %ix%i", src_w, src_h, dst_w, dst_h); @@ -121,15 +121,15 @@ void GP_BlitXYXY_Clipped(const GP_Context *src, y1 -= src_h - dst_h; GP_DEBUG(2, "Blitting %ix%i->%ix%i in %ux%u to %ix%i in %ux%u", - x0, y0, x1, y1, GP_ContextW(src), GP_ContextH(src), - x2, y2, GP_ContextW(dst), GP_ContextH(dst)); + x0, y0, x1, y1, GP_PixmapW(src), GP_PixmapH(src), + x2, y2, GP_PixmapW(dst), GP_PixmapH(dst)); GP_BlitXYXY_Fast(src, x0, y0, x1, y1, dst, x2, y2); } -void GP_BlitXYWH(const GP_Context *src, +void GP_BlitXYWH(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, - GP_Context *dst, GP_Coord x1, GP_Coord y1) + GP_Pixmap *dst, GP_Coord x1, GP_Coord y1) { if (w0 == 0 || h0 == 0) return; @@ -137,9 +137,9 @@ void GP_BlitXYWH(const GP_Context *src, GP_BlitXYXY(src, x0, y0, x0 + w0 - 1, y0 + h0 - 1, dst, x1, y1); } -void GP_BlitXYWH_Clipped(const GP_Context *src, +void GP_BlitXYWH_Clipped(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, - GP_Context *dst, GP_Coord x1, GP_Coord y1) + GP_Pixmap *dst, GP_Coord x1, GP_Coord y1) { if (w0 == 0 || h0 == 0) return; @@ -147,9 +147,9 @@ void GP_BlitXYWH_Clipped(const GP_Context *src, GP_BlitXYXY_Clipped(src, x0, y0, x0 + w0 - 1, y0 + h0 - 1, dst, x1, y1); } -void GP_BlitXYXY_Raw(const GP_Context *src, +void GP_BlitXYXY_Raw(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2) + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2) { /* Normalize source rectangle */ if (x1 < x0) @@ -158,7 +158,7 @@ void GP_BlitXYXY_Raw(const GP_Context *src, if (y1 < y0) GP_SWAP(y0, y1); - /* All coordinates are inside of src the context */ + /* All coordinates are inside of src the pixmap */ GP_CHECK(x0 < (GP_Coord)src->w); GP_CHECK(y0 < (GP_Coord)src->h); GP_CHECK(x1 < (GP_Coord)src->w); @@ -171,9 +171,9 @@ void GP_BlitXYXY_Raw(const GP_Context *src, GP_BlitXYXY_Raw_Fast(src, x0, y0, x1, y1, dst, x2, y2); } -void GP_BlitXYWH_Raw(const GP_Context *src, +void GP_BlitXYWH_Raw(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0, - GP_Context *dst, GP_Coord x2, GP_Coord y2) + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2) { if (w0 == 0 || h0 == 0) return; diff --git a/libs/core/GP_Blit.gen.c.t b/libs/core/GP_Blit.gen.c.t index c7f17388..c53a7c07 100644 --- a/libs/core/GP_Blit.gen.c.t +++ b/libs/core/GP_Blit.gen.c.t @@ -10,7 +10,7 @@ #include "core/GP_Pixel.h" #include "core/GP_GetPutPixel.h" -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_Blit.h" #include "core/GP_Debug.h" #include "core/GP_Convert.h" @@ -21,9 +21,9 @@ /* * TODO: this is used for same pixel but different offset, could still be optimized */ -static void blitXYXY_Naive_Raw(const GP_Context *src, +static void blitXYXY_Naive_Raw(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2) + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2) { GP_Coord x, y; @@ -32,7 +32,7 @@ static void blitXYXY_Naive_Raw(const GP_Context *src, GP_Pixel p = GP_GetPixel_Raw(src, x, y); if (src->pixel_type != dst->pixel_type) - p = GP_ConvertContextPixel(p, src, dst); + p = GP_ConvertPixmapPixel(p, src, dst); GP_PutPixel_Raw(dst, x2 + (x - x0), y2 + (y - y0), p); } @@ -44,9 +44,9 @@ static void blitXYXY_Naive_Raw(const GP_Context *src, /* * Blit for equal pixel types {{ ps.suffix }} */ -static void blitXYXY_Raw_{{ ps.suffix }}(const GP_Context *src, +static void blitXYXY_Raw_{{ ps.suffix }}(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2) + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2) { @ if not ps.needs_bit_endian(): /* memcpy() each horizontal line */ @@ -60,8 +60,8 @@ static void blitXYXY_Raw_{{ ps.suffix }}(const GP_Context *src, # if 0 /* Rectangles may not be bit-aligned in the same way! */ /* Alignment (index) of first bits in the first byte */ - //TODO: This is wrong for subcontexts where the offset - // needs to be summed with context->offset and moduled + //TODO: This is wrong for subpixmaps where the offset + // needs to be summed with pixmap->offset and moduled int al1 = GP_PIXEL_ADDR_OFFSET_{{ ps.suffix }}(x0); int al2 = GP_PIXEL_ADDR_OFFSET_{{ ps.suffix }}(x2); /* Special case of the same alignment and width >=2 bytes */ @@ -108,9 +108,9 @@ static void blitXYXY_Raw_{{ ps.suffix }}(const GP_Context *src, /* * Blits {{ src.name }} to {{ dst.name }} */ -static void blitXYXY_Raw_{{ src.name }}_{{ dst.name }}(const GP_Context *src, +static void blitXYXY_Raw_{{ src.name }}_{{ dst.name }}(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2) + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2) { GP_Coord x, y, dx, dy; @@ -136,9 +136,9 @@ static void blitXYXY_Raw_{{ src.name }}_{{ dst.name }}(const GP_Context *src, @ end -void GP_BlitXYXY_Raw_Fast(const GP_Context *src, +void GP_BlitXYXY_Raw_Fast(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2) + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2) { /* Same pixel type, could be (mostly) optimized to memcpy() */ if (src->pixel_type == dst->pixel_type) { @@ -183,9 +183,9 @@ void GP_BlitXYXY_Raw_Fast(const GP_Context *src, /* * Blits {{ src.name }} to {{ dst.name }} */ -static void blitXYXY_{{ src.name }}_{{ dst.name }}(const GP_Context *src, +static void blitXYXY_{{ src.name }}_{{ dst.name }}(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2) + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2) { GP_Coord x, y, xt, yt; @@ -213,9 +213,9 @@ static void blitXYXY_{{ src.name }}_{{ dst.name }}(const GP_Context *src, /* * Blits for same pixel type and bpp {{ ps.suffix }} */ -static void blitXYXY_{{ ps.suffix }}(const GP_Context *src, +static void blitXYXY_{{ ps.suffix }}(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2) + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2) { GP_Coord x, y, xt, yt; @@ -233,9 +233,9 @@ static void blitXYXY_{{ ps.suffix }}(const GP_Context *src, } @ end -void GP_BlitXYXY_Fast(const GP_Context *src, +void GP_BlitXYXY_Fast(const GP_Pixmap *src, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, - GP_Context *dst, GP_Coord x2, GP_Coord y2) + GP_Pixmap *dst, GP_Coord x2, GP_Coord y2) { GP_DEBUG(2, "Blitting %s -> %s", GP_PixelTypeName(src->pixel_type), @@ -248,7 +248,7 @@ void GP_BlitXYXY_Fast(const GP_Context *src, return; } - if (GP_ContextRotationEqual(src, dst)) { + if (GP_PixmapRotationEqual(src, dst)) { GP_BlitXYXY_Raw_Fast(src, x0, y0, x1, y1, dst, x2, y2); return; } diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c index 050c4dd8..53c289e1 100644 --- a/libs/core/GP_Context.c +++ b/libs/core/GP_Context.c @@ -31,7 +31,7 @@ #include "GP_Pixel.h" #include "GP_GetPutPixel.h" #include "GP_Gamma.h" -#include "GP_Context.h" +#include "GP_Pixmap.h" #include "GP_Blit.h" static uint32_t get_bpr(uint32_t bpp, uint32_t w) @@ -40,16 +40,16 @@ static uint32_t get_bpr(uint32_t bpp, uint32_t w) uint8_t padd = !!(bits_per_row % 8); if (bits_per_row / 8 + padd > UINT32_MAX) { - GP_WARN("Context too wide %u (overflow detected)", w); + GP_WARN("Pixmap too wide %u (overflow detected)", w); return 0; } return bits_per_row / 8 + padd; } -GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type) +GP_Pixmap *GP_PixmapAlloc(GP_Size w, GP_Size h, GP_PixelType type) { - GP_Context *context; + GP_Pixmap *pixmap; uint32_t bpp; size_t bpr; void *pixels; @@ -61,12 +61,12 @@ GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type) } if (w <= 0 || h <= 0) { - GP_WARN("Trying to allocate context with zero width and/or height"); + GP_WARN("Trying to allocate pixmap with zero width and/or height"); errno = EINVAL; return NULL; } - GP_DEBUG(1, "Allocating context %u x %u - %s", + GP_DEBUG(1, "Allocating pixmap %u x %u - %s", w, h, GP_PixelTypeName(type)); bpp = GP_PixelSize(type); @@ -77,113 +77,113 @@ GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type) size_t size = bpr * h; if (size / h != bpr) { - GP_WARN("Context too big %u x %u (owerflow detected)", w, h); + GP_WARN("Pixmap too big %u x %u (owerflow detected)", w, h); return NULL; } pixels = malloc(size); - context = malloc(sizeof(GP_Context)); + pixmap = malloc(sizeof(GP_Pixmap)); - if (pixels == NULL || context == NULL) { + if (pixels == NULL || pixmap == NULL) { free(pixels); - free(context); + free(pixmap); GP_WARN("Malloc failed :("); errno = ENOMEM; return NULL; } - context->pixels = pixels; - context->bpp = bpp; - context->bytes_per_row = bpr; - context->offset = 0; + pixmap->pixels = pixels; + pixmap->bpp = bpp; + pixmap->bytes_per_row = bpr; + pixmap->offset = 0; - context->w = w; - context->h = h; + pixmap->w = w; + pixmap->h = h; - context->gamma = NULL; + pixmap->gamma = NULL; - context->pixel_type = type; + pixmap->pixel_type = type; #warning Hmm, bit endianity... Why is not this settled by different pixel types? - context->bit_endian = GP_PixelTypes[type].bit_endian; + pixmap->bit_endian = GP_PixelTypes[type].bit_endian; /* rotation and mirroring */ - GP_ContextSetRotation(context, 0, 0, 0); + GP_PixmapSetRotation(pixmap, 0, 0, 0); - context->free_pixels = 1; + pixmap->free_pixels = 1; - return context; + return pixmap; } -void GP_ContextFree(GP_Context *context) +void GP_PixmapFree(GP_Pixmap *pixmap) { - GP_DEBUG(1, "Freeing context (%p)", context); + GP_DEBUG(1, "Freeing pixmap (%p)", pixmap); - if (context == NULL) + if (pixmap == NULL) return; - if (context->free_pixels) - free(context->pixels); + if (pixmap->free_pixels) + free(pixmap->pixels); - if (context->gamma) - GP_GammaRelease(context->gamma); + if (pixmap->gamma) + GP_GammaRelease(pixmap->gamma); - free(context); + free(pixmap); } -GP_Context *GP_ContextInit(GP_Context *context, GP_Size w, GP_Size h, +GP_Pixmap *GP_PixmapInit(GP_Pixmap *pixmap, GP_Size w, GP_Size h, GP_PixelType type, void *pixels) { uint32_t bpp = GP_PixelSize(type); uint32_t bpr = get_bpr(bpp, w); - context->pixels = pixels; - context->bpp = bpp; - context->bytes_per_row = bpr; - context->offset = 0; + pixmap->pixels = pixels; + pixmap->bpp = bpp; + pixmap->bytes_per_row = bpr; + pixmap->offset = 0; - context->w = w; - context->h = h; + pixmap->w = w; + pixmap->h = h; - context->pixel_type = type; - context->bit_endian = 0; + pixmap->pixel_type = type; + pixmap->bit_endian = 0; - context->gamma = NULL; + pixmap->gamma = NULL; /* rotation and mirroring */ - GP_ContextSetRotation(context, 0, 0, 0); + GP_PixmapSetRotation(pixmap, 0, 0, 0); - context->free_pixels = 0; + pixmap->free_pixels = 0; - return context; + return pixmap; } -int GP_ContextResize(GP_Context *context, GP_Size w, GP_Size h) +int GP_PixmapResize(GP_Pixmap *pixmap, GP_Size w, GP_Size h) { - uint32_t bpr = get_bpr(context->bpp, w); + uint32_t bpr = get_bpr(pixmap->bpp, w); void *pixels; - pixels = realloc(context->pixels, bpr * h); + pixels = realloc(pixmap->pixels, bpr * h); if (pixels == NULL) return 1; - context->w = w; - context->h = h; - context->bytes_per_row = bpr; - context->pixels = pixels; + pixmap->w = w; + pixmap->h = h; + pixmap->bytes_per_row = bpr; + pixmap->pixels = pixels; return 0; } -GP_Context *GP_ContextCopy(const GP_Context *src, int flags) +GP_Pixmap *GP_PixmapCopy(const GP_Pixmap *src, int flags) { - GP_Context *new; + GP_Pixmap *new; uint8_t *pixels; if (src == NULL) return NULL; - new = malloc(sizeof(GP_Context)); + new = malloc(sizeof(GP_Pixmap)); pixels = malloc(src->bytes_per_row * src->h); if (pixels == NULL || new == NULL) { @@ -210,9 +210,9 @@ GP_Context *GP_ContextCopy(const GP_Context *src, int flags) new->bit_endian = src->bit_endian; if (flags & GP_COPY_WITH_ROTATION) - GP_ContextCopyRotation(src, new); + GP_PixmapCopyRotation(src, new); else - GP_ContextSetRotation(new, 0, 0, 0); + GP_PixmapSetRotation(new, 0, 0, 0); //TODO: Copy the gamma too new->gamma = NULL; @@ -223,13 +223,13 @@ GP_Context *GP_ContextCopy(const GP_Context *src, int flags) } -GP_Context *GP_ContextConvertAlloc(const GP_Context *src, +GP_Pixmap *GP_PixmapConvertAlloc(const GP_Pixmap *src, GP_PixelType dst_pixel_type) { - int w = GP_ContextW(src); - int h = GP_ContextH(src); + int w = GP_PixmapW(src); + int h = GP_PixmapH(src); - GP_Context *ret = GP_ContextAlloc(w, h, dst_pixel_type); + GP_Pixmap *ret = GP_PixmapAlloc(w, h, dst_pixel_type); if (ret == NULL) return NULL; @@ -246,11 +246,11 @@ GP_Context *GP_ContextConvertAlloc(const GP_Context *src, return ret; } -GP_Context *GP_ContextConvert(const GP_Context *src, GP_Context *dst) +GP_Pixmap *GP_PixmapConvert(const GP_Pixmap *src, GP_Pixmap *dst) { //TODO: Asserts - int w = GP_ContextW(src); - int h = GP_ContextH(src); + int w = GP_PixmapW(src); + int h = GP_PixmapH(src); /* * Fill the buffer with zeroes, otherwise it will @@ -264,10 +264,10 @@ GP_Context *GP_ContextConvert(const GP_Context *src, GP_Context *dst) return dst; } -GP_Context *GP_SubContextAlloc(const GP_Context *context, +GP_Pixmap *GP_SubPixmapAlloc(const GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h) { - GP_Context *res = malloc(sizeof(GP_Context)); + GP_Pixmap *res = malloc(sizeof(GP_Pixmap)); if (res == NULL) { GP_WARN("Malloc failed :("); @@ -275,46 +275,46 @@ GP_Context *GP_SubContextAlloc(const GP_Context *context, return NULL; } - return GP_SubContext(context, res, x, y, w, h); + return GP_SubPixmap(pixmap, res, x, y, w, h); } -GP_Context *GP_SubContext(const GP_Context *context, GP_Context *subcontext, +GP_Pixmap *GP_SubPixmap(const GP_Pixmap *pixmap, GP_Pixmap *subpixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h) { - GP_CHECK(context, "NULL context"); + GP_CHECK(pixmap, "NULL pixmap"); - GP_TRANSFORM_RECT(context, x, y, w, h); + GP_TRANSFORM_RECT(pixmap, x, y, w, h); - GP_CHECK(context->w >= x + w, "Subcontext w out of original context."); - GP_CHECK(context->h >= y + h, "Subcontext h out of original context."); + GP_CHECK(pixmap->w >= x + w, "Subpixmap w out of original pixmap."); + GP_CHECK(pixmap->h >= y + h, "Subpixmap h out of original pixmap."); - subcontext->bpp = context->bpp; - subcontext->bytes_per_row = context->bytes_per_row; - subcontext->offset = (context->offset + - GP_PixelAddrOffset(x, context->pixel_type)) % 8; + subpixmap->bpp = pixmap->bpp; + subpixmap->bytes_per_row = pixmap->bytes_per_row; + subpixmap->offset = (pixmap->offset + + GP_PixelAddrOffset(x, pixmap->pixel_type)) % 8; - subcontext->w = w; - subcontext->h = h; + subpixmap->w = w; + subpixmap->h = h; - subcontext->pixel_type = context->pixel_type; - subcontext->bit_endian = context->bit_endian; + subpixmap->pixel_type = pixmap->pixel_type; + subpixmap->bit_endian = pixmap->bit_endian; /* gamma */ - subcontext->gamma = context->gamma; + subpixmap->gamma = pixmap->gamma; /* rotation and mirroring */ - GP_ContextCopyRotation(context, subcontext); + GP_PixmapCopyRotation(pixmap, subpixmap); - subcontext->pixels = GP_PIXEL_ADDR(context, x, y); + subpixmap->pixels = GP_PIXEL_ADDR(pixmap, x, y); - subcontext->free_pixels = 0; + subpixmap->free_pixels = 0; - return subcontext; + return subpixmap; } -void GP_ContextPrintInfo(const GP_Context *self) +void GP_PixmapPrintInfo(const GP_Pixmap *self) { - printf("Context info\n"); + printf("Pixmap info\n"); printf("------------\n"); printf("Size\t%ux%u\n", self->w, self->h); printf("BPP\t%u\n", self->bpp); @@ -330,7 +330,7 @@ void GP_ContextPrintInfo(const GP_Context *self) } /* - * The context rotations consists of two cyclic permutation groups that are + * The pixmap rotations consists of two cyclic permutation groups that are * mirrored. * * The flags change as follows: @@ -352,66 +352,66 @@ void GP_ContextPrintInfo(const GP_Context *self) * 0 1 0 * */ -void GP_ContextRotateCW(GP_Context *context) +void GP_PixmapRotateCW(GP_Pixmap *pixmap) { - context->axes_swap = !context->axes_swap; + pixmap->axes_swap = !pixmap->axes_swap; - if (!context->x_swap && !context->y_swap) { - context->x_swap = 1; + if (!pixmap->x_swap && !pixmap->y_swap) { + pixmap->x_swap = 1; return; } - if (context->x_swap && !context->y_swap) { - context->y_swap = 1; + if (pixmap->x_swap && !pixmap->y_swap) { + pixmap->y_swap = 1; return; } - if (context->x_swap && context->y_swap) { - context->x_swap = 0; + if (pixmap->x_swap && pixmap->y_swap) { + pixmap->x_swap = 0; return; } - context->y_swap = 0; + pixmap->y_swap = 0; } -void GP_ContextRotateCCW(GP_Context *context) +void GP_PixmapRotateCCW(GP_Pixmap *pixmap) { - context->axes_swap = !context->axes_swap; + pixmap->axes_swap = !pixmap->axes_swap; - if (!context->x_swap && !context->y_swap) { - context->y_swap = 1; + if (!pixmap->x_swap && !pixmap->y_swap) { + pixmap->y_swap = 1; return; } - if (context->x_swap && !context->y_swap) { - context->x_swap = 0; + if (pixmap->x_swap && !pixmap->y_swap) { + pixmap->x_swap = 0; return; } - if (context->x_swap && context->y_swap) { - context->y_swap = 0; + if (pixmap->x_swap && pixmap->y_swap) { + pixmap->y_swap = 0; return; } - context->x_swap = 1; + pixmap->x_swap = 1; } -int GP_ContextEqual(const GP_Context *ctx1, const GP_Context *ctx2) +int GP_PixmapEqual(const GP_Pixmap *pixmap1, const GP_Pixmap *pixmap2) { - if (ctx1->pixel_type != ctx2->pixel_type) + if (pixmap1->pixel_type != pixmap2->pixel_type) return 0; - if (GP_ContextW(ctx1) != GP_ContextW(ctx2)) + if (GP_PixmapW(pixmap1) != GP_PixmapW(pixmap2)) return 0; - if (GP_ContextH(ctx1) != GP_ContextH(ctx2)) + if (GP_PixmapH(pixmap1) != GP_PixmapH(pixmap2)) return 0; - GP_Coord x, y, w = GP_ContextW(ctx1), h = GP_ContextH(ctx1); + GP_Coord x, y, w = GP_PixmapW(pixmap1), h = GP_PixmapH(pixmap1); for (x = 0; x < w; x++) for (y = 0; y < h; y++) - if (GP_GetPixel(ctx1, x, y) != GP_GetPixel(ctx2, x, y)) + if (GP_GetPixel(pixmap1, x, y) != GP_GetPixel(pixmap2, x, y)) return 0; return 1; diff --git a/libs/core/GP_Fill.gen.c.t b/libs/core/GP_Fill.gen.c.t index e9bb6514..7f5caa7f 100644 --- a/libs/core/GP_Fill.gen.c.t +++ b/libs/core/GP_Fill.gen.c.t @@ -6,14 +6,14 @@ * Copyright (C) 2009-2014 Cyril Hrubis */ -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_WritePixel.h" #include "core/GP_GetPutPixel.h" #include "core/GP_FnPerBpp.h" #include "core/GP_Fill.h" @ for ps in pixelsizes: -static void fill_{{ ps.suffix }}(GP_Context *ctx, GP_Pixel val) +static void fill_{{ ps.suffix }}(GP_Pixmap *ctx, GP_Pixel val) { unsigned int y; @@ -35,7 +35,7 @@ static void fill_{{ ps.suffix }}(GP_Context *ctx, GP_Pixel val) @ end -void GP_Fill(GP_Context *ctx, GP_Pixel val) +void GP_Fill(GP_Pixmap *ctx, GP_Pixel val) { - GP_FN_PER_BPP_CONTEXT(fill, ctx, ctx, val); + GP_FN_PER_BPP_PIXMAP(fill, ctx, ctx, val); } diff --git a/libs/core/GP_GetPutPixel.c b/libs/core/GP_GetPutPixel.c index 4a083ac7..fb718b29 100644 --- a/libs/core/GP_GetPutPixel.c +++ b/libs/core/GP_GetPutPixel.c @@ -24,19 +24,19 @@ #include "GP_GetPutPixel.h" #include "GP_Transform.h" -GP_Pixel GP_GetPixel(const GP_Context *context, GP_Coord x, GP_Coord y) +GP_Pixel GP_GetPixel(const GP_Pixmap *pixmap, GP_Coord x, GP_Coord y) { - GP_TRANSFORM_POINT(context, x, y); - if (GP_PIXEL_IS_CLIPPED(context, x, y)) + GP_TRANSFORM_POINT(pixmap, x, y); + if (GP_PIXEL_IS_CLIPPED(pixmap, x, y)) return 0; - return GP_GetPixel_Raw(context, x, y); + return GP_GetPixel_Raw(pixmap, x, y); } -void GP_PutPixel(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel p) +void GP_PutPixel(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel p) { - GP_TRANSFORM_POINT(context, x, y); - if (!GP_PIXEL_IS_CLIPPED(context, x, y)) - GP_PutPixel_Raw(context, x, y, p); + GP_TRANSFORM_POINT(pixmap, x, y); + if (!GP_PIXEL_IS_CLIPPED(pixmap, x, y)) + GP_PutPixel_Raw(pixmap, x, y, p); } uint8_t GP_PixelAddrOffset(GP_Coord x, GP_PixelType pixel_type) diff --git a/libs/filters/GP_ApplyTables.c b/libs/filters/GP_ApplyTables.c index bc03dda4..c61a9b99 100644 --- a/libs/filters/GP_ApplyTables.c +++ b/libs/filters/GP_ApplyTables.c @@ -58,18 +58,18 @@ static void free_tables(GP_FilterTables *self) } } -int GP_FilterTablesInit(GP_FilterTables *self, const GP_Context *ctx) +int GP_FilterTablesInit(GP_FilterTables *self, const GP_Pixmap *pixmap) { unsigned int i; const GP_PixelTypeDescription *desc; GP_DEBUG(2, "Allocating tables for pixel %s", - GP_PixelTypeName(ctx->pixel_type)); + GP_PixelTypeName(pixmap->pixel_type)); for (i = 0; i < GP_PIXELTYPE_MAX_CHANNELS; i++) self->table[i] = NULL; - desc = GP_PixelTypeDesc(ctx->pixel_type); + desc = GP_PixelTypeDesc(pixmap->pixel_type); for (i = 0; i < desc->numchannels; i++) { self->table[i] = create_table(&desc->channels[i]); @@ -84,7 +84,7 @@ int GP_FilterTablesInit(GP_FilterTables *self, const GP_Context *ctx) return 0; } -GP_FilterTables *GP_FilterTablesAlloc(const GP_Context *ctx) +GP_FilterTables *GP_FilterTablesAlloc(const GP_Pixmap *pixmap) { GP_FilterTables *tables = malloc(sizeof(GP_FilterTables)); @@ -95,7 +95,7 @@ GP_FilterTables *GP_FilterTablesAlloc(const GP_Context *ctx) return NULL; } - if (GP_FilterTablesInit(tables, ctx)) { + if (GP_FilterTablesInit(tables, pixmap)) { free(tables); return NULL; } diff --git a/libs/filters/GP_ApplyTables.gen.c.t b/libs/filters/GP_ApplyTables.gen.c.t index dd3581cf..931d7606 100644 --- a/libs/filters/GP_ApplyTables.gen.c.t +++ b/libs/filters/GP_ApplyTables.gen.c.t @@ -7,7 +7,7 @@ #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_GetPutPixel.h" #include "core/GP_Debug.h" @@ -15,10 +15,10 @@ @ for pt in pixeltypes: @ if not pt.is_unknown() and not pt.is_palette(): -static int apply_tables_{{ pt.name }}(const GP_Context *const src, +static int apply_tables_{{ pt.name }}(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, const GP_FilterTables *const tables, GP_ProgressCallback *callback) @@ -62,10 +62,10 @@ static int apply_tables_{{ pt.name }}(const GP_Context *const src, @ end @ -int GP_FilterTablesApply(const GP_Context *const src, +int GP_FilterTablesApply(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, const GP_FilterTables *const tables, GP_ProgressCallback *callback) diff --git a/libs/filters/GP_Blur.c b/libs/filters/GP_Blur.c index 147d675a..d3a016e8 100644 --- a/libs/filters/GP_Blur.c +++ b/libs/filters/GP_Blur.c @@ -69,17 +69,17 @@ static int gaussian_callback_vert(GP_ProgressCallback *self) return callback->callback(callback); } -int GP_FilterGaussianBlur_Raw(const GP_Context *src, +int GP_FilterGaussianBlur_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float x_sigma, float y_sigma, GP_ProgressCallback *callback) { unsigned int size_x = gaussian_kernel_size(x_sigma); unsigned int size_y = gaussian_kernel_size(y_sigma); - const GP_Context *tmp = dst; + const GP_Pixmap *tmp = dst; GP_DEBUG(1, "Gaussian blur x_sigma=%2.3f y_sigma=%2.3f kernel %ix%i image %ux%u", x_sigma, y_sigma, size_x, size_y, w_src, h_src); @@ -159,10 +159,10 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src, return 0; } -int GP_FilterGaussianBlurEx(const GP_Context *src, +int GP_FilterGaussianBlurEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float x_sigma, float y_sigma, GP_ProgressCallback *callback) @@ -178,20 +178,20 @@ int GP_FilterGaussianBlurEx(const GP_Context *src, x_sigma, y_sigma, callback); } -GP_Context *GP_FilterGaussianBlurExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterGaussianBlurExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, float x_sigma, float y_sigma, GP_ProgressCallback *callback) { - GP_Context *dst = GP_ContextAlloc(w_src, h_src, src->pixel_type); + GP_Pixmap *dst = GP_PixmapAlloc(w_src, h_src, src->pixel_type); if (dst == NULL) return NULL; if (GP_FilterGaussianBlur_Raw(src, x_src, y_src, w_src, h_src, dst, 0, 0, x_sigma, y_sigma, callback)) { - GP_ContextFree(dst); + GP_PixmapFree(dst); return NULL; } diff --git a/libs/filters/GP_Convolution.c b/libs/filters/GP_Convolution.c index b01f768b..63634629 100644 --- a/libs/filters/GP_Convolution.c +++ b/libs/filters/GP_Convolution.c @@ -24,10 +24,10 @@ #include "GP_Linear.h" #include "GP_Convolution.h" -int GP_FilterConvolutionEx(const GP_Context *src, +int GP_FilterConvolutionEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Coord h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, const GP_FilterKernel2D *kernel, GP_ProgressCallback *callback) @@ -49,13 +49,13 @@ int GP_FilterConvolutionEx(const GP_Context *src, callback); } -GP_Context *GP_FilterConvolutionExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterConvolutionExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, const GP_FilterKernel2D *kernel, GP_ProgressCallback *callback) { - GP_Context *ret = GP_ContextAlloc(w_src, h_src, src->pixel_type); + GP_Pixmap *ret = GP_PixmapAlloc(w_src, h_src, src->pixel_type); GP_DEBUG(1, "Linear convolution kernel size %ux%u", kernel->w, kernel->h); @@ -66,7 +66,7 @@ GP_Context *GP_FilterConvolutionExAlloc(const GP_Context *src, if (GP_FilterLinearConvolution_Raw(src, x_src, y_src, w_src, h_src, ret, 0, 0, kernel->kernel, kernel->w, kernel->h, kernel->div, callback)) { - GP_ContextFree(ret); + GP_PixmapFree(ret); return NULL; } diff --git a/libs/filters/GP_Edge.c b/libs/filters/GP_Edge.c index 01cc811f..ded2cde9 100644 --- a/libs/filters/GP_Edge.c +++ b/libs/filters/GP_Edge.c @@ -31,7 +31,7 @@ /* * Apply prewitt operator. */ -static int prewitt(const GP_Context *src, GP_Context *dx, GP_Context *dy, +static int prewitt(const GP_Pixmap *src, GP_Pixmap *dx, GP_Pixmap *dy, GP_ProgressCallback *callback) { float smooth_kern[3] = {1, 1, 1,}; @@ -55,7 +55,7 @@ static int prewitt(const GP_Context *src, GP_Context *dx, GP_Context *dy, /* * Apply sobel operator. */ -static int sobel(const GP_Context *src, GP_Context *dx, GP_Context *dy, +static int sobel(const GP_Pixmap *src, GP_Pixmap *dx, GP_Pixmap *dy, GP_ProgressCallback *callback) { float dx_kern[] = { @@ -111,17 +111,17 @@ static int sobel(const GP_Context *src, GP_Context *dx, GP_Context *dy, return 0; } -static int edge_detect(const GP_Context *src, - GP_Context **E, GP_Context **Phi, int type, +static int edge_detect(const GP_Pixmap *src, + GP_Pixmap **E, GP_Pixmap **Phi, int type, GP_ProgressCallback *callback) { //TODO GP_ASSERT(src->pixel_type == GP_PIXEL_RGB888); - GP_Context *dx, *dy; + GP_Pixmap *dx, *dy; - dx = GP_ContextCopy(src, 0); - dy = GP_ContextCopy(src, 0); + dx = GP_PixmapCopy(src, 0); + dy = GP_PixmapCopy(src, 0); if (dx == NULL || dy == NULL) goto err0; @@ -188,22 +188,22 @@ static int edge_detect(const GP_Context *src, if (Phi != NULL) *Phi = dy; else - GP_ContextFree(dy); + GP_PixmapFree(dy); if (E != NULL) *E = dx; else - GP_ContextFree(dx); + GP_PixmapFree(dx); return 0; err0: - GP_ContextFree(dx); - GP_ContextFree(dy); + GP_PixmapFree(dx); + GP_PixmapFree(dy); return 1; } -int GP_FilterEdgeSobel(const GP_Context *src, - GP_Context **E, GP_Context **Phi, +int GP_FilterEdgeSobel(const GP_Pixmap *src, + GP_Pixmap **E, GP_Pixmap **Phi, GP_ProgressCallback *callback) { GP_DEBUG(1, "Sobel edge detection image %ux%u", src->w, src->h); @@ -211,8 +211,8 @@ int GP_FilterEdgeSobel(const GP_Context *src, return edge_detect(src, E, Phi, 0, callback); } -int GP_FilterEdgePrewitt(const GP_Context *src, - GP_Context **E, GP_Context **Phi, +int GP_FilterEdgePrewitt(const GP_Pixmap *src, + GP_Pixmap **E, GP_Pixmap **Phi, GP_ProgressCallback *callback) { GP_DEBUG(1, "Prewitt edge detection image %ux%u", src->w, src->h); diff --git a/libs/filters/GP_FloydSteinberg.gen.c.t b/libs/filters/GP_FloydSteinberg.gen.c.t index 2486fc86..13b6999d 100644 --- a/libs/filters/GP_FloydSteinberg.gen.c.t +++ b/libs/filters/GP_FloydSteinberg.gen.c.t @@ -31,8 +31,8 @@ if ({{ x }} + 1 < {{ w }}) /* * Floyd Steinberg to {{ pt.name }} */ -static int floyd_steinberg_to_{{ pt.name }}_Raw(const GP_Context *src, - GP_Context *dst, +static int floyd_steinberg_to_{{ pt.name }}_Raw(const GP_Pixmap *src, + GP_Pixmap *dst, GP_ProgressCallback *callback) { @ for c in pt.chanslist: @@ -105,7 +105,7 @@ static int floyd_steinberg_to_{{ pt.name }}_Raw(const GP_Context *src, @ end @ -static int floyd_steinberg(const GP_Context *src, GP_Context *dst, +static int floyd_steinberg(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { if (GP_PixelHasFlags(src->pixel_type, GP_PIXEL_IS_PALETTE)) { @@ -127,7 +127,7 @@ static int floyd_steinberg(const GP_Context *src, GP_Context *dst, } } -int GP_FilterFloydSteinberg(const GP_Context *src, GP_Context *dst, +int GP_FilterFloydSteinberg(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { GP_CHECK(src->w <= dst->w); @@ -137,19 +137,19 @@ int GP_FilterFloydSteinberg(const GP_Context *src, GP_Context *dst, } -GP_Context *GP_FilterFloydSteinbergAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterFloydSteinbergAlloc(const GP_Pixmap *src, GP_PixelType pixel_type, GP_ProgressCallback *callback) { - GP_Context *ret; + GP_Pixmap *ret; - ret = GP_ContextAlloc(src->w, src->h, pixel_type); + ret = GP_PixmapAlloc(src->w, src->h, pixel_type); if (ret == NULL) return NULL; if (floyd_steinberg(src, ret, callback)) { - GP_ContextFree(ret); + GP_PixmapFree(ret); return NULL; } diff --git a/libs/filters/GP_GaussianNoise.gen.c.t b/libs/filters/GP_GaussianNoise.gen.c.t index d3cfaacf..770610fb 100644 --- a/libs/filters/GP_GaussianNoise.gen.c.t +++ b/libs/filters/GP_GaussianNoise.gen.c.t @@ -7,7 +7,7 @@ #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_GetPutPixel.h" #include "core/GP_TempAlloc.h" //#include "core/GP_Gamma.h" @@ -19,10 +19,10 @@ @ for pt in pixeltypes: @ if not pt.is_unknown() and not pt.is_palette(): -static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Context *src, +static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float sigma, float mu, GP_ProgressCallback *callback) @@ -79,10 +79,10 @@ static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Context *src, @ end @ -int GP_FilterGaussianNoiseAdd_Raw(const GP_Context *src, +int GP_FilterGaussianNoiseAdd_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float sigma, float mu, GP_ProgressCallback *callback) @@ -102,10 +102,10 @@ int GP_FilterGaussianNoiseAdd_Raw(const GP_Context *src, } } -int GP_FilterGaussianNoiseAddEx(const GP_Context *src, +int GP_FilterGaussianNoiseAddEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float sigma, float mu, GP_ProgressCallback *callback) @@ -125,7 +125,7 @@ int GP_FilterGaussianNoiseAddEx(const GP_Context *src, sigma, mu, callback); } -GP_Context *GP_FilterGaussianNoiseAddExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterGaussianNoiseAddExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, float sigma, float mu, @@ -133,7 +133,7 @@ GP_Context *GP_FilterGaussianNoiseAddExAlloc(const GP_Context *src, { int ret, err; - GP_Context *dst = GP_ContextAlloc(w_src, h_src, src->pixel_type); + GP_Pixmap *dst = GP_PixmapAlloc(w_src, h_src, src->pixel_type); if (dst == NULL) return NULL; @@ -143,7 +143,7 @@ GP_Context *GP_FilterGaussianNoiseAddExAlloc(const GP_Context *src, if (ret) { err = errno; - GP_ContextFree(dst); + GP_PixmapFree(dst); errno = err; return NULL; } diff --git a/libs/filters/GP_HilbertPeano.gen.c.t b/libs/filters/GP_HilbertPeano.gen.c.t index e1a07f7b..d2a33677 100644 --- a/libs/filters/GP_HilbertPeano.gen.c.t +++ b/libs/filters/GP_HilbertPeano.gen.c.t @@ -35,8 +35,8 @@ static unsigned int count_bits(unsigned int n) /* * Hilbert Peano to {{ pt.name }} */ -static int hilbert_peano_to_{{ pt.name }}_Raw(const GP_Context *src, - GP_Context *dst, +static int hilbert_peano_to_{{ pt.name }}_Raw(const GP_Pixmap *src, + GP_Pixmap *dst, GP_ProgressCallback *callback) { struct GP_CurveState state; @@ -113,7 +113,7 @@ static int hilbert_peano_to_{{ pt.name }}_Raw(const GP_Context *src, @ end @ -static int hilbert_peano(const GP_Context *src, GP_Context *dst, +static int hilbert_peano(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { if (GP_PixelHasFlags(src->pixel_type, GP_PIXEL_IS_PALETTE)) { @@ -135,7 +135,7 @@ static int hilbert_peano(const GP_Context *src, GP_Context *dst, } } -int GP_FilterHilbertPeano(const GP_Context *src, GP_Context *dst, +int GP_FilterHilbertPeano(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { GP_CHECK(src->w <= dst->w); @@ -144,19 +144,19 @@ int GP_FilterHilbertPeano(const GP_Context *src, GP_Context *dst, return hilbert_peano(src, dst, callback); } -GP_Context *GP_FilterHilbertPeanoAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterHilbertPeanoAlloc(const GP_Pixmap *src, GP_PixelType pixel_type, GP_ProgressCallback *callback) { - GP_Context *ret; + GP_Pixmap *ret; - ret = GP_ContextAlloc(src->w, src->h, pixel_type); + ret = GP_PixmapAlloc(src->w, src->h, pixel_type); if (ret == NULL) return NULL; if (hilbert_peano(src, ret, callback)) { - GP_ContextFree(ret); + GP_PixmapFree(ret); return NULL; } diff --git a/libs/filters/GP_Histogram.gen.c.t b/libs/filters/GP_Histogram.gen.c.t index 52bfc5c1..ffdd56ca 100644 --- a/libs/filters/GP_Histogram.gen.c.t +++ b/libs/filters/GP_Histogram.gen.c.t @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include @@ -18,10 +18,10 @@ @ for pt in pixeltypes: @ if not pt.is_unknown() and not pt.is_palette(): static int GP_FilterHistogram_{{ pt.name }}(GP_Histogram *self, - const GP_Context *src, GP_ProgressCallback *callback) + const GP_Pixmap *src, GP_ProgressCallback *callback) { if (self->pixel_type != src->pixel_type) { - GP_WARN("Histogram (%s) and context (%s) pixel type must match", + GP_WARN("Histogram (%s) and pixmap (%s) pixel type must match", GP_PixelTypeName(self->pixel_type), GP_PixelTypeName(src->pixel_type)); errno = EINVAL; @@ -56,7 +56,7 @@ static int GP_FilterHistogram_{{ pt.name }}(GP_Histogram *self, @ end @ -int GP_FilterHistogram(GP_Histogram *self, const GP_Context *src, +int GP_FilterHistogram(GP_Histogram *self, const GP_Pixmap *src, GP_ProgressCallback *callback) { unsigned int i, j; diff --git a/libs/filters/GP_Laplace.c b/libs/filters/GP_Laplace.c index 3081ace7..e0510eb7 100644 --- a/libs/filters/GP_Laplace.c +++ b/libs/filters/GP_Laplace.c @@ -27,7 +27,7 @@ #include "GP_Laplace.h" -int GP_FilterLaplace(const GP_Context *src, GP_Context *dst, +int GP_FilterLaplace(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { GP_DEBUG(1, "Laplace filter %ux%u", src->w, src->h); @@ -43,16 +43,16 @@ int GP_FilterLaplace(const GP_Context *src, GP_Context *dst, return 0; } -GP_Context *GP_FilterLaplaceAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterLaplaceAlloc(const GP_Pixmap *src, GP_ProgressCallback *callback) { - GP_Context *ret = GP_ContextCopy(src, 0); + GP_Pixmap *ret = GP_PixmapCopy(src, 0); if (ret == NULL) return NULL; if (GP_FilterLaplace(src, ret, callback)) { - GP_ContextFree(ret); + GP_PixmapFree(ret); return NULL; } @@ -60,7 +60,7 @@ GP_Context *GP_FilterLaplaceAlloc(const GP_Context *src, } -int GP_FilterEdgeSharpening(const GP_Context *src, GP_Context *dst, +int GP_FilterEdgeSharpening(const GP_Pixmap *src, GP_Pixmap *dst, float w, GP_ProgressCallback *callback) { /* Identity kernel */ @@ -85,16 +85,16 @@ int GP_FilterEdgeSharpening(const GP_Context *src, GP_Context *dst, return 0; } -GP_Context *GP_FilterEdgeSharpeningAlloc(const GP_Context *src, float w, +GP_Pixmap *GP_FilterEdgeSharpeningAlloc(const GP_Pixmap *src, float w, GP_ProgressCallback *callback) { - GP_Context *ret = GP_ContextCopy(src, 0); + GP_Pixmap *ret = GP_PixmapCopy(src, 0); if (ret == NULL) return NULL; if (GP_FilterEdgeSharpening(src, ret, w, callback)) { - GP_ContextFree(ret); + GP_PixmapFree(ret); return NULL; } diff --git a/libs/filters/GP_LinearConvolution.c b/libs/filters/GP_LinearConvolution.c index 87094078..6012edc3 100644 --- a/libs/filters/GP_LinearConvolution.c +++ b/libs/filters/GP_LinearConvolution.c @@ -20,7 +20,7 @@ * * *****************************************************************************/ -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_Debug.h" #include "GP_Linear.h" @@ -41,10 +41,10 @@ static int v_callback(GP_ProgressCallback *self) return callback->callback(callback); } -int GP_FilterVHLinearConvolution_Raw(const GP_Context *src, +int GP_FilterVHLinearConvolution_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float hkernel[], uint32_t kw, float hkern_div, float vkernel[], uint32_t kh, float vkern_div, diff --git a/libs/filters/GP_LinearConvolution.gen.c.t b/libs/filters/GP_LinearConvolution.gen.c.t index 4c320e18..3e0de14f 100644 --- a/libs/filters/GP_LinearConvolution.gen.c.t +++ b/libs/filters/GP_LinearConvolution.gen.c.t @@ -7,7 +7,7 @@ #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_GetPutPixel.h" #include "core/GP_TempAlloc.h" #include "core/GP_Clamp.h" @@ -20,10 +20,10 @@ @ for pt in pixeltypes: @ if not pt.is_unknown() and not pt.is_palette(): -static int h_lin_conv_{{ pt.name }}(const GP_Context *src, +static int h_lin_conv_{{ pt.name }}(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float kernel[], uint32_t kw, float kern_div, GP_ProgressCallback *callback) @@ -127,10 +127,10 @@ static int h_lin_conv_{{ pt.name }}(const GP_Context *src, @ end -int GP_FilterHLinearConvolution_Raw(const GP_Context *src, +int GP_FilterHLinearConvolution_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float kernel[], uint32_t kw, float kern_div, GP_ProgressCallback *callback) @@ -157,10 +157,10 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src, @ for pt in pixeltypes: @ if not pt.is_unknown() and not pt.is_palette(): -static int v_lin_conv_{{ pt.name }}(const GP_Context *src, +static int v_lin_conv_{{ pt.name }}(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float kernel[], uint32_t kh, float kern_div, GP_ProgressCallback *callback) @@ -266,10 +266,10 @@ static int v_lin_conv_{{ pt.name }}(const GP_Context *src, @ end -int GP_FilterVLinearConvolution_Raw(const GP_Context *src, +int GP_FilterVLinearConvolution_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float kernel[], uint32_t kh, float kern_div, GP_ProgressCallback *callback) @@ -296,10 +296,10 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, @ for pt in pixeltypes: @ if not pt.is_unknown() and not pt.is_palette(): -static int lin_conv_{{ pt.name }}(const GP_Context *src, +static int lin_conv_{{ pt.name }}(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float kernel[], uint32_t kw, uint32_t kh, float kern_div, GP_ProgressCallback *callback) @@ -398,10 +398,10 @@ static int lin_conv_{{ pt.name }}(const GP_Context *src, @ end -int GP_FilterLinearConvolution_Raw(const GP_Context *src, +int GP_FilterLinearConvolution_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, float kernel[], uint32_t kw, uint32_t kh, float kern_div, GP_ProgressCallback *callback) diff --git a/libs/filters/GP_Median.c b/libs/filters/GP_Median.c index 170ce24b..a0327dc8 100644 --- a/libs/filters/GP_Median.c +++ b/libs/filters/GP_Median.c @@ -22,7 +22,7 @@ #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_GetPutPixel.h" #include "core/GP_TempAlloc.h" #include "core/GP_Clamp.h" @@ -167,10 +167,10 @@ static inline unsigned int hist8_median(struct hist8u *h, struct hist8 *row, return 0; } -static int GP_FilterMedian_Raw(const GP_Context *src, +static int GP_FilterMedian_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, int xmed, int ymed, GP_ProgressCallback *callback) @@ -283,10 +283,10 @@ static int GP_FilterMedian_Raw(const GP_Context *src, return 0; } -int GP_FilterMedianEx(const GP_Context *src, +int GP_FilterMedianEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, int xmed, int ymed, GP_ProgressCallback *callback) @@ -303,7 +303,7 @@ int GP_FilterMedianEx(const GP_Context *src, dst, x_dst, y_dst, xmed, ymed, callback); } -GP_Context *GP_FilterMedianExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterMedianExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, int xmed, int ymed, @@ -313,7 +313,7 @@ GP_Context *GP_FilterMedianExAlloc(const GP_Context *src, GP_CHECK(xmed >= 0 && ymed >= 0); - GP_Context *dst = GP_ContextAlloc(w_src, h_src, src->pixel_type); + GP_Pixmap *dst = GP_PixmapAlloc(w_src, h_src, src->pixel_type); if (dst == NULL) return NULL; @@ -322,7 +322,7 @@ GP_Context *GP_FilterMedianExAlloc(const GP_Context *src, dst, 0, 0, xmed, ymed, callback); if (ret) { - GP_ContextFree(dst); + GP_PixmapFree(dst); return NULL; } diff --git a/libs/filters/GP_MirrorH.gen.c.t b/libs/filters/GP_MirrorH.gen.c.t index e926bba3..6c5be385 100644 --- a/libs/filters/GP_MirrorH.gen.c.t +++ b/libs/filters/GP_MirrorH.gen.c.t @@ -10,8 +10,8 @@ #include "GP_Rotate.h" @ for ps in pixelsizes: -static int GP_MirrorH_Raw_{{ ps.suffix }}(const GP_Context *src, - GP_Context *dst, +static int GP_MirrorH_Raw_{{ ps.suffix }}(const GP_Pixmap *src, + GP_Pixmap *dst, GP_ProgressCallback *callback) { uint32_t x, y; @@ -44,14 +44,14 @@ static int GP_MirrorH_Raw_{{ ps.suffix }}(const GP_Context *src, @ end @ -static int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst, +static int GP_FilterMirrorH_Raw(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { - GP_FN_RET_PER_BPP_CONTEXT(GP_MirrorH_Raw, src, src, dst, callback); + GP_FN_RET_PER_BPP_PIXMAP(GP_MirrorH_Raw, src, src, dst, callback); return 1; } -int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst, +int GP_FilterMirrorH(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { GP_ASSERT(src->pixel_type == dst->pixel_type, @@ -67,18 +67,18 @@ int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst, return 0; } -GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterMirrorHAlloc(const GP_Pixmap *src, GP_ProgressCallback *callback) { - GP_Context *res; + GP_Pixmap *res; - res = GP_ContextCopy(src, 0); + res = GP_PixmapCopy(src, 0); if (res == NULL) return NULL; if (GP_FilterMirrorH_Raw(src, res, callback)) { - GP_ContextFree(res); + GP_PixmapFree(res); return NULL; } diff --git a/libs/filters/GP_MultiTone.gen.c.t b/libs/filters/GP_MultiTone.gen.c.t index 3dbd28ed..c20b4bc7 100644 --- a/libs/filters/GP_MultiTone.gen.c.t +++ b/libs/filters/GP_MultiTone.gen.c.t @@ -7,7 +7,7 @@ #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_GetPutPixel.h" #include "core/GP_TempAlloc.h" #include "core/GP_MixPixels.h" @@ -69,10 +69,10 @@ static void init_table(GP_PixelType type, @ for pt in pixeltypes: @ if pt.is_gray(): -static int multitone_{{ pt.name }}(const GP_Context *const src, +static int multitone_{{ pt.name }}(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, GP_Pixel pixels[], GP_Size pixels_size, GP_ProgressCallback *callback) @@ -117,10 +117,10 @@ static int multitone_{{ pt.name }}(const GP_Context *const src, @ end @ -int GP_FilterMultiToneEx(const GP_Context *const src, +int GP_FilterMultiToneEx(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, GP_Pixel pixels[], GP_Size pixels_size, GP_ProgressCallback *callback) @@ -144,17 +144,17 @@ int GP_FilterMultiToneEx(const GP_Context *const src, } } -GP_Context *GP_FilterMultiToneExAlloc(const GP_Context *const src, +GP_Pixmap *GP_FilterMultiToneExAlloc(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, GP_PixelType dst_pixel_type, GP_Pixel pixels[], GP_Size pixels_size, GP_ProgressCallback *callback) { - GP_Context *res; + GP_Pixmap *res; int err; - res = GP_ContextAlloc(w_src, h_src, dst_pixel_type); + res = GP_PixmapAlloc(w_src, h_src, dst_pixel_type); if (!res) { GP_DEBUG(1, "Malloc failed :("); @@ -164,7 +164,7 @@ GP_Context *GP_FilterMultiToneExAlloc(const GP_Context *const src, if (GP_FilterMultiToneEx(src, x_src, y_src, w_src, h_src, res, 0, 0, pixels, pixels_size, callback)) { err = errno; - GP_ContextFree(res); + GP_PixmapFree(res); errno = err; return NULL; } diff --git a/libs/filters/GP_Resize.c b/libs/filters/GP_Resize.c index fa0da01a..5e8b0bab 100644 --- a/libs/filters/GP_Resize.c +++ b/libs/filters/GP_Resize.c @@ -22,7 +22,7 @@ #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_Debug.h" #include "GP_ResizeNN.h" @@ -46,7 +46,7 @@ const char *GP_InterpolationTypeName(enum GP_InterpolationType interp_type) return interp_types[interp_type]; } -static int resize(const GP_Context *src, GP_Context *dst, +static int resize(const GP_Pixmap *src, GP_Pixmap *dst, GP_InterpolationType type, GP_ProgressCallback *callback) { @@ -69,7 +69,7 @@ static int resize(const GP_Context *src, GP_Context *dst, return 1; } -int GP_FilterResize(const GP_Context *src, GP_Context *dst, +int GP_FilterResize(const GP_Pixmap *src, GP_Pixmap *dst, GP_InterpolationType type, GP_ProgressCallback *callback) { @@ -82,18 +82,18 @@ int GP_FilterResize(const GP_Context *src, GP_Context *dst, return resize(src, dst, type, callback); } -GP_Context *GP_FilterResizeAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterResizeAlloc(const GP_Pixmap *src, GP_Size w, GP_Size h, GP_InterpolationType type, GP_ProgressCallback *callback) { - GP_Context *res = GP_ContextAlloc(w, h, src->pixel_type); + GP_Pixmap *res = GP_PixmapAlloc(w, h, src->pixel_type); if (!res) return NULL; if (resize(src, res, type, callback)) { - GP_ContextFree(res); + GP_PixmapFree(res); return NULL; } diff --git a/libs/filters/GP_ResizeCubic.gen.c.t b/libs/filters/GP_ResizeCubic.gen.c.t index 39abb557..3f358d4f 100644 --- a/libs/filters/GP_ResizeCubic.gen.c.t +++ b/libs/filters/GP_ResizeCubic.gen.c.t @@ -8,7 +8,7 @@ #include #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_GetPutPixel.h" #include "core/GP_Gamma.h" #include "core/GP_Clamp.h" @@ -32,8 +32,8 @@ @ for pt in pixeltypes: @ if not pt.is_unknown() and not pt.is_palette(): -static int resize_cubic_{{ pt.name }}(const GP_Context *src, - GP_Context *dst, GP_ProgressCallback *callback) +static int resize_cubic_{{ pt.name }}(const GP_Pixmap *src, + GP_Pixmap *dst, GP_ProgressCallback *callback) { @ for c in pt.chanslist: int32_t col_{{ c.name }}[src->w]; @@ -175,7 +175,7 @@ static int resize_cubic_{{ pt.name }}(const GP_Context *src, @ end @ -static int resize_cubic(const GP_Context *src, GP_Context *dst, +static int resize_cubic(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { switch (src->pixel_type) { @@ -191,7 +191,7 @@ static int resize_cubic(const GP_Context *src, GP_Context *dst, } } -int GP_FilterResizeCubicInt(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeCubicInt(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { if (src->pixel_type != dst->pixel_type) { diff --git a/libs/filters/GP_ResizeCubicFloat.c b/libs/filters/GP_ResizeCubicFloat.c index 908e328b..10820438 100644 --- a/libs/filters/GP_ResizeCubicFloat.c +++ b/libs/filters/GP_ResizeCubicFloat.c @@ -23,7 +23,7 @@ #include #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_GetPutPixel.h" #include "core/GP_Gamma.h" @@ -76,7 +76,7 @@ typedef union v4f { val = 255; \ } while (0) -int GP_FilterResizeCubic(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeCubic(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { float col_r[src->h], col_g[src->h], col_b[src->h]; diff --git a/libs/filters/GP_ResizeLinear.gen.c.t b/libs/filters/GP_ResizeLinear.gen.c.t index cfa38928..1b2bd950 100644 --- a/libs/filters/GP_ResizeLinear.gen.c.t +++ b/libs/filters/GP_ResizeLinear.gen.c.t @@ -8,7 +8,7 @@ #include #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_GetPutPixel.h" #include "core/GP_Gamma.h" @@ -49,7 +49,7 @@ for (x = 0; x < dst->w; x++) { @ for pt in pixeltypes: @ if not pt.is_unknown() and not pt.is_palette(): -static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst, +static int resize_lin_lf_{{ pt.name }}(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { uint32_t xmap[dst->w + 1]; @@ -131,7 +131,7 @@ static int resize_lin_lf_{{ pt.name }}(const GP_Context *src, GP_Context *dst, @ @ for pt in pixeltypes: @ if not pt.is_unknown() and not pt.is_palette(): -static int resize_lin{{ pt.name }}(const GP_Context *src, GP_Context *dst, +static int resize_lin{{ pt.name }}(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { uint32_t xmap[dst->w + 1]; @@ -221,7 +221,7 @@ static int resize_lin{{ pt.name }}(const GP_Context *src, GP_Context *dst, @ end @ -static int resize_lin(const GP_Context *src, GP_Context *dst, +static int resize_lin(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { switch (src->pixel_type) { @@ -239,7 +239,7 @@ static int resize_lin(const GP_Context *src, GP_Context *dst, } } -int GP_FilterResizeLinearInt(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeLinearInt(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { if (src->pixel_type != dst->pixel_type) { @@ -251,7 +251,7 @@ int GP_FilterResizeLinearInt(const GP_Context *src, GP_Context *dst, return resize_lin(src, dst, callback); } -static int resize_lin_lf(const GP_Context *src, GP_Context *dst, +static int resize_lin_lf(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { float x_rat = 1.00 * dst->w / src->w; @@ -283,7 +283,7 @@ static int resize_lin_lf(const GP_Context *src, GP_Context *dst, return resize_lin(src, dst, callback); } -int GP_FilterResizeLinearLFInt(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeLinearLFInt(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { if (src->pixel_type != dst->pixel_type) { diff --git a/libs/filters/GP_ResizeNN.gen.c.t b/libs/filters/GP_ResizeNN.gen.c.t index 82ef9cdf..385c7577 100644 --- a/libs/filters/GP_ResizeNN.gen.c.t +++ b/libs/filters/GP_ResizeNN.gen.c.t @@ -7,7 +7,7 @@ #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_GetPutPixel.h" #include "core/GP_Debug.h" @@ -16,7 +16,7 @@ @ for pt in pixeltypes: @ if not pt.is_unknown(): -static int resize_nn{{ pt.name }}(const GP_Context *src, GP_Context *dst, +static int resize_nn{{ pt.name }}(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { uint32_t xmap[dst->w]; @@ -55,7 +55,7 @@ static int resize_nn{{ pt.name }}(const GP_Context *src, GP_Context *dst, @ end @ -static int resize_nn(const GP_Context *src, GP_Context *dst, +static int resize_nn(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { switch (src->pixel_type) { @@ -70,7 +70,7 @@ static int resize_nn(const GP_Context *src, GP_Context *dst, } } -int GP_FilterResizeNN(const GP_Context *src, GP_Context *dst, +int GP_FilterResizeNN(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { if (src->pixel_type != dst->pixel_type) { diff --git a/libs/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c index 1b3f7412..11abe211 100644 --- a/libs/filters/GP_Rotate.c +++ b/libs/filters/GP_Rotate.c @@ -29,7 +29,7 @@ #include -int GP_FilterMirrorV_Raw(const GP_Context *src, GP_Context *dst, +int GP_FilterMirrorV_Raw(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { uint32_t bpr = src->bytes_per_row; @@ -72,7 +72,7 @@ int GP_FilterMirrorV_Raw(const GP_Context *src, GP_Context *dst, return 0; } -int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst, +int GP_FilterMirrorV(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { GP_ASSERT(src->pixel_type == dst->pixel_type, @@ -87,18 +87,18 @@ int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst, return 0; } -GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterMirrorVAlloc(const GP_Pixmap *src, GP_ProgressCallback *callback) { - GP_Context *res; + GP_Pixmap *res; - res = GP_ContextCopy(src, 0); + res = GP_PixmapCopy(src, 0); if (res == NULL) return NULL; if (GP_FilterMirrorV_Raw(src, res, callback)) { - GP_ContextFree(res); + GP_PixmapFree(res); return NULL; } @@ -127,7 +127,7 @@ int GP_FilterSymmetryByName(const char *symmetry) return -1; } -GP_Context *GP_FilterSymmetryAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterSymmetryAlloc(const GP_Pixmap *src, GP_FilterSymmetries symmetry, GP_ProgressCallback *callback) { @@ -148,7 +148,7 @@ GP_Context *GP_FilterSymmetryAlloc(const GP_Context *src, } } -int GP_FilterSymmetry(const GP_Context *src, GP_Context *dst, +int GP_FilterSymmetry(const GP_Pixmap *src, GP_Pixmap *dst, GP_FilterSymmetries symmetry, GP_ProgressCallback *callback) { diff --git a/libs/filters/GP_Rotate.gen.c.t b/libs/filters/GP_Rotate.gen.c.t index 60ba39a1..3e8608e4 100644 --- a/libs/filters/GP_Rotate.gen.c.t +++ b/libs/filters/GP_Rotate.gen.c.t @@ -10,7 +10,7 @@ #include "GP_Rotate.h" @ for ps in pixelsizes: -static int GP_FilterRotate90_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst, +static int GP_FilterRotate90_Raw_{{ ps.suffix }}(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { uint32_t x, y; @@ -33,14 +33,14 @@ static int GP_FilterRotate90_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Conte @ end @ -static int GP_FilterRotate90_Raw(const GP_Context *src, GP_Context *dst, +static int GP_FilterRotate90_Raw(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { - GP_FN_RET_PER_BPP_CONTEXT(GP_FilterRotate90_Raw, src, src, dst, callback); + GP_FN_RET_PER_BPP_PIXMAP(GP_FilterRotate90_Raw, src, src, dst, callback); return 1; } -int GP_FilterRotate90(const GP_Context *src, GP_Context *dst, +int GP_FilterRotate90(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { GP_ASSERT(src->pixel_type == dst->pixel_type, @@ -56,19 +56,19 @@ int GP_FilterRotate90(const GP_Context *src, GP_Context *dst, return 0; } -GP_Context *GP_FilterRotate90Alloc(const GP_Context *src, +GP_Pixmap *GP_FilterRotate90Alloc(const GP_Pixmap *src, GP_ProgressCallback *callback) { - GP_Context *res; + GP_Pixmap *res; - res = GP_ContextAlloc(src->h, src->w, src->pixel_type); + res = GP_PixmapAlloc(src->h, src->w, src->pixel_type); if (res == NULL) return NULL; if (GP_FilterRotate90_Raw(src, res, callback)) { GP_DEBUG(1, "Operation aborted"); - GP_ContextFree(res); + GP_PixmapFree(res); return NULL; } @@ -83,7 +83,7 @@ GP_PutPixel_Raw_{{ ps.suffix }}({{ dst }}, {{ x1 }}, {{ y1 }}, pix0); @ end @ @ for ps in pixelsizes: -static int GP_FilterRotate180_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst, +static int GP_FilterRotate180_Raw_{{ ps.suffix }}(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { uint32_t x, y; @@ -108,14 +108,14 @@ static int GP_FilterRotate180_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont @ end @ -static int GP_FilterRotate180_Raw(const GP_Context *src, GP_Context *dst, +static int GP_FilterRotate180_Raw(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { - GP_FN_RET_PER_BPP_CONTEXT(GP_FilterRotate180_Raw, src, src, dst, callback); + GP_FN_RET_PER_BPP_PIXMAP(GP_FilterRotate180_Raw, src, src, dst, callback); return 1; } -int GP_FilterRotate180(const GP_Context *src, GP_Context *dst, +int GP_FilterRotate180(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { GP_ASSERT(src->pixel_type == dst->pixel_type, @@ -131,19 +131,19 @@ int GP_FilterRotate180(const GP_Context *src, GP_Context *dst, return 0; } -GP_Context *GP_FilterRotate180Alloc(const GP_Context *src, +GP_Pixmap *GP_FilterRotate180Alloc(const GP_Pixmap *src, GP_ProgressCallback *callback) { - GP_Context *res; + GP_Pixmap *res; - res = GP_ContextCopy(src, 0); + res = GP_PixmapCopy(src, 0); if (res == NULL) return NULL; if (GP_FilterRotate180_Raw(src, res, callback)) { GP_DEBUG(1, "Operation aborted"); - GP_ContextFree(res); + GP_PixmapFree(res); return NULL; } @@ -151,7 +151,7 @@ GP_Context *GP_FilterRotate180Alloc(const GP_Context *src, } @ for ps in pixelsizes: -static int GP_FilterRotate270_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst, +static int GP_FilterRotate270_Raw_{{ ps.suffix }}(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { uint32_t x, y; @@ -174,14 +174,14 @@ static int GP_FilterRotate270_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont @ end @ -static int GP_FilterRotate270_Raw(const GP_Context *src, GP_Context *dst, +static int GP_FilterRotate270_Raw(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { - GP_FN_RET_PER_BPP_CONTEXT(GP_FilterRotate270_Raw, src, src, dst, callback); + GP_FN_RET_PER_BPP_PIXMAP(GP_FilterRotate270_Raw, src, src, dst, callback); return 1; } -int GP_FilterRotate270(const GP_Context *src, GP_Context *dst, +int GP_FilterRotate270(const GP_Pixmap *src, GP_Pixmap *dst, GP_ProgressCallback *callback) { GP_ASSERT(src->pixel_type == dst->pixel_type, @@ -197,19 +197,19 @@ int GP_FilterRotate270(const GP_Context *src, GP_Context *dst, return 0; } -GP_Context *GP_FilterRotate270Alloc(const GP_Context *src, +GP_Pixmap *GP_FilterRotate270Alloc(const GP_Pixmap *src, GP_ProgressCallback *callback) { - GP_Context *res; + GP_Pixmap *res; - res = GP_ContextAlloc(src->h, src->w, src->pixel_type); + res = GP_PixmapAlloc(src->h, src->w, src->pixel_type); if (res == NULL) return NULL; if (GP_FilterRotate270_Raw(src, res, callback)) { GP_DEBUG(1, "Operation aborted"); - GP_ContextFree(res); + GP_PixmapFree(res); return NULL; } diff --git a/libs/filters/GP_Sepia.c b/libs/filters/GP_Sepia.c index bfc2379f..2522abc3 100644 --- a/libs/filters/GP_Sepia.c +++ b/libs/filters/GP_Sepia.c @@ -36,10 +36,10 @@ static void init_sepia_tones(GP_Pixel pixels[PIX], GP_PixelType pixel_type) pixels[2] = GP_RGBToPixel(230, 230, 230, pixel_type); } -int GP_FilterSepiaEx(const GP_Context *const src, +int GP_FilterSepiaEx(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, GP_ProgressCallback *callback) { @@ -51,7 +51,7 @@ int GP_FilterSepiaEx(const GP_Context *const src, dst, x_dst, y_dst, pixels, PIX, callback); } -GP_Context *GP_FilterSepiaExAlloc(const GP_Context *const src, +GP_Pixmap *GP_FilterSepiaExAlloc(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, GP_PixelType dst_pixel_type, diff --git a/libs/filters/GP_Sigma.c b/libs/filters/GP_Sigma.c index 63e016aa..7a48b47b 100644 --- a/libs/filters/GP_Sigma.c +++ b/libs/filters/GP_Sigma.c @@ -22,7 +22,7 @@ #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_GetPutPixel.h" #include "core/GP_TempAlloc.h" #include "core/GP_Clamp.h" @@ -34,10 +34,10 @@ #include -static int GP_FilterSigma_Raw(const GP_Context *src, +static int GP_FilterSigma_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, int xrad, int yrad, unsigned int min, float sigma, @@ -206,10 +206,10 @@ static int GP_FilterSigma_Raw(const GP_Context *src, return 0; } -int GP_FilterSigmaEx(const GP_Context *src, +int GP_FilterSigmaEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, int xrad, int yrad, unsigned int min, float sigma, @@ -228,7 +228,7 @@ int GP_FilterSigmaEx(const GP_Context *src, callback); } -GP_Context *GP_FilterSigmaExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterSigmaExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, int xrad, int yrad, @@ -239,7 +239,7 @@ GP_Context *GP_FilterSigmaExAlloc(const GP_Context *src, GP_CHECK(xrad >= 0 && yrad >= 0); - GP_Context *dst = GP_ContextAlloc(w_src, h_src, src->pixel_type); + GP_Pixmap *dst = GP_PixmapAlloc(w_src, h_src, src->pixel_type); if (dst == NULL) return NULL; @@ -248,7 +248,7 @@ GP_Context *GP_FilterSigmaExAlloc(const GP_Context *src, dst, 0, 0, xrad, yrad, min, sigma, callback); if (ret) { - GP_ContextFree(dst); + GP_PixmapFree(dst); return NULL; } diff --git a/libs/filters/GP_WeightedMedian.c b/libs/filters/GP_WeightedMedian.c index 62732ee9..1a147ee3 100644 --- a/libs/filters/GP_WeightedMedian.c +++ b/libs/filters/GP_WeightedMedian.c @@ -22,7 +22,7 @@ #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_GetPutPixel.h" #include "core/GP_TempAlloc.h" #include "core/GP_Clamp.h" @@ -77,10 +77,10 @@ static inline unsigned int get_weight(GP_MedianWeights *weights, return weights->weights[y * weights->w + x]; } -static int GP_FilterWeightedMedian_Raw(const GP_Context *src, +static int GP_FilterWeightedMedian_Raw(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, GP_MedianWeights *weights, GP_ProgressCallback *callback) @@ -179,10 +179,10 @@ static int GP_FilterWeightedMedian_Raw(const GP_Context *src, return 0; } -int GP_FilterWeightedMedianEx(const GP_Context *src, +int GP_FilterWeightedMedianEx(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, GP_MedianWeights *weights, GP_ProgressCallback *callback) @@ -199,7 +199,7 @@ int GP_FilterWeightedMedianEx(const GP_Context *src, dst, x_dst, y_dst, weights, callback); } -GP_Context *GP_FilterWeightedMedianExAlloc(const GP_Context *src, +GP_Pixmap *GP_FilterWeightedMedianExAlloc(const GP_Pixmap *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, GP_MedianWeights *weights, @@ -209,7 +209,7 @@ GP_Context *GP_FilterWeightedMedianExAlloc(const GP_Context *src, //GP_CHECK(xmed >= 0 && ymed >= 0); - GP_Context *dst = GP_ContextAlloc(w_src, h_src, src->pixel_type); + GP_Pixmap *dst = GP_PixmapAlloc(w_src, h_src, src->pixel_type); if (dst == NULL) return NULL; @@ -218,7 +218,7 @@ GP_Context *GP_FilterWeightedMedianExAlloc(const GP_Context *src, dst, 0, 0, weights, callback); if (ret) { - GP_ContextFree(dst); + GP_PixmapFree(dst); return NULL; } diff --git a/libs/filters/arithmetic_filter.t b/libs/filters/arithmetic_filter.t index 556e05d1..4580e690 100644 --- a/libs/filters/arithmetic_filter.t +++ b/libs/filters/arithmetic_filter.t @@ -1,5 +1,5 @@ @ def filter_arithmetic(name, filter_op, opts='', params=''): -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_Pixel.h" #include "core/GP_GetPutPixel.h" #include "core/GP_Debug.h" @@ -8,8 +8,8 @@ @ for pt in pixeltypes: @ if not pt.is_unknown(): -static int GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src_a, const GP_Context *src_b, - GP_Context *dst, {{ maybe_opts_r(opts) }}GP_ProgressCallback *callback) +static int GP_Filter{{ name }}_{{ pt.name }}(const GP_Pixmap *src_a, const GP_Pixmap *src_b, + GP_Pixmap *dst, {{ maybe_opts_r(opts) }}GP_ProgressCallback *callback) { uint32_t x, y, w, h; @@ -47,8 +47,8 @@ static int GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src_a, const GP_C @ end @ -int GP_Filter{{ name }}_Raw(const GP_Context *src_a, const GP_Context *src_b, - GP_Context *dst{{ maybe_opts_l(opts) }}, GP_ProgressCallback *callback) +int GP_Filter{{ name }}_Raw(const GP_Pixmap *src_a, const GP_Pixmap *src_b, + GP_Pixmap *dst{{ maybe_opts_l(opts) }}, GP_ProgressCallback *callback) { GP_DEBUG(1, "Running filter {{ name }}"); @@ -65,8 +65,8 @@ int GP_Filter{{ name }}_Raw(const GP_Context *src_a, const GP_Context *src_b, return 1; } -int GP_Filter{{ name }}(const GP_Context *src_a, const GP_Context *src_b, - GP_Context *dst{{ maybe_opts_l(opts) }}, +int GP_Filter{{ name }}(const GP_Pixmap *src_a, const GP_Pixmap *src_b, + GP_Pixmap *dst{{ maybe_opts_l(opts) }}, GP_ProgressCallback *callback) { GP_Size w = GP_MIN(src_a->w, src_b->w); @@ -86,10 +86,10 @@ int GP_Filter{{ name }}(const GP_Context *src_a, const GP_Context *src_b, } -GP_Context *GP_Filter{{ name }}Alloc(const GP_Context *src_a, const GP_Context *src_b, +GP_Pixmap *GP_Filter{{ name }}Alloc(const GP_Pixmap *src_a, const GP_Pixmap *src_b, {{ maybe_opts_r(opts) }}GP_ProgressCallback *callback) { - GP_Context *res; + GP_Pixmap *res; GP_ASSERT(src_a->pixel_type == src_b->pixel_type, "Pixel types for sources must match."); @@ -97,7 +97,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); + res = GP_PixmapAlloc(w, h, src_a->pixel_type); if (res == NULL) return NULL; @@ -105,7 +105,7 @@ GP_Context *GP_Filter{{ name }}Alloc(const GP_Context *src_a, const GP_Context * if (GP_Filter{{ name }}_Raw(src_a, src_b, res{{ maybe_opts_l(params) }}, callback)) { GP_DEBUG(1, "Operation aborted"); - GP_ContextFree(res); + GP_PixmapFree(res); return NULL; } diff --git a/libs/filters/point_filter.t b/libs/filters/point_filter.t index 4c1347a6..fba04afe 100644 --- a/libs/filters/point_filter.t +++ b/libs/filters/point_filter.t @@ -1,8 +1,8 @@ @ def filter_point_ex(op_name, filter_op, fopts): -int GP_Filter{{ op_name }}Ex(const GP_Context *const src, +int GP_Filter{{ op_name }}Ex(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - GP_Context *dst, + GP_Pixmap *dst, GP_Coord x_dst, GP_Coord y_dst, {{ maybe_opts_r(fopts) }} GP_ProgressCallback *callback) @@ -37,19 +37,19 @@ int GP_Filter{{ op_name }}Ex(const GP_Context *const src, } @ @ def filter_point_ex_alloc(op_name, fopts, opts): -GP_Context *GP_Filter{{ op_name }}ExAlloc(const GP_Context *const src, +GP_Pixmap *GP_Filter{{ op_name }}ExAlloc(const GP_Pixmap *const src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, {{ maybe_opts_r(fopts) }} GP_ProgressCallback *callback) { - GP_Context *new = GP_ContextAlloc(w_src, h_src, + GP_Pixmap *new = GP_PixmapAlloc(w_src, h_src, src->pixel_type); if (GP_Filter{{ op_name }}Ex(src, x_src, y_src, w_src, h_src, new, 0, 0, {{ maybe_opts_r(opts) }}callback)) { int err = errno; - GP_ContextFree(new); + GP_PixmapFree(new); errno = err; return NULL; } diff --git a/libs/gfx/GP_Arc.c b/libs/gfx/GP_Arc.c index 0b9a66c1..a4b26b63 100644 --- a/libs/gfx/GP_Arc.c +++ b/libs/gfx/GP_Arc.c @@ -33,29 +33,29 @@ /* Generate drawing functions for various bit depths. */ GP_DEF_DRAW_FN_PER_BPP(GP_ArcSegment_Raw, DEF_ARCSEGMENT_FN) -void GP_ArcSegment_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_ArcSegment_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, int direction, double start, double end, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_FN_PER_BPP_CONTEXT(GP_ArcSegment_Raw, context, context, + GP_FN_PER_BPP_PIXMAP(GP_ArcSegment_Raw, pixmap, pixmap, xcenter, ycenter, a, b, direction, start, end, pixel); } -void GP_ArcSegment(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_ArcSegment(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, int direction, double start, double end, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); /* 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_TRANSFORM_POINT(pixmap, xcenter, ycenter); + GP_TRANSFORM_SWAP(pixmap, a, b); - GP_ArcSegment_Raw(context, xcenter, ycenter, a, b, direction, + GP_ArcSegment_Raw(pixmap, xcenter, ycenter, a, b, direction, start, end, pixel); } diff --git a/libs/gfx/GP_Circle.c b/libs/gfx/GP_Circle.c index 2b399283..0ccee1fc 100644 --- a/libs/gfx/GP_Circle.c +++ b/libs/gfx/GP_Circle.c @@ -34,40 +34,40 @@ /* Generate drawing functions for various bit depths. */ GP_DEF_DRAW_FN_PER_BPP(GP_Circle_Raw, DEF_CIRCLE_FN) -void GP_Circle_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Circle_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_FN_PER_BPP_CONTEXT(GP_Circle_Raw, context, context, + GP_FN_PER_BPP_PIXMAP(GP_Circle_Raw, pixmap, pixmap, xcenter, ycenter, r, pixel); } -void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Circle(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT(context, xcenter, ycenter); + GP_TRANSFORM_POINT(pixmap, xcenter, ycenter); - GP_Circle_Raw(context, xcenter, ycenter, r, pixel); + GP_Circle_Raw(pixmap, xcenter, ycenter, r, pixel); } -void GP_Ring_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Ring_Raw(GP_Pixmap *pixmap, 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(pixmap, xcenter, ycenter, r1, pixel); + GP_Circle_Raw(pixmap, xcenter, ycenter, r2, pixel); } -void GP_Ring(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Ring(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r1, GP_Size r2, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT(context, xcenter, ycenter); + GP_TRANSFORM_POINT(pixmap, xcenter, ycenter); - GP_Ring_Raw(context, xcenter, ycenter, r1, r2, pixel); + GP_Ring_Raw(pixmap, xcenter, ycenter, r1, r2, pixel); } #include "algo/FillRing.algo.h" @@ -75,21 +75,21 @@ void GP_Ring(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, /* Generate drawing functions for various bit depths. */ GP_DEF_FILL_FN_PER_BPP(GP_FillRing_Raw, DEF_FILLRING_FN) -void GP_FillRing_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillRing_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r1, GP_Size r2, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_FN_PER_BPP_CONTEXT(GP_FillRing_Raw, context, context, + GP_FN_PER_BPP_PIXMAP(GP_FillRing_Raw, pixmap, pixmap, xcenter, ycenter, r1, r2, pixel); } -void GP_FillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillRing(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r1, GP_Size r2, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT(context, xcenter, ycenter); + GP_TRANSFORM_POINT(pixmap, xcenter, ycenter); - GP_FillRing_Raw(context, xcenter, ycenter, r1, r2, pixel); + GP_FillRing_Raw(pixmap, xcenter, ycenter, r1, r2, pixel); } diff --git a/libs/gfx/GP_CircleSeg.c b/libs/gfx/GP_CircleSeg.c index feeaf9ea..8b517976 100644 --- a/libs/gfx/GP_CircleSeg.c +++ b/libs/gfx/GP_CircleSeg.c @@ -31,22 +31,22 @@ #include "algo/CircleSeg.algo.h" -static uint8_t transform_segments(GP_Context *context, uint8_t seg_flags) +static uint8_t transform_segments(GP_Pixmap *pixmap, uint8_t seg_flags) { uint8_t seg1 = seg_flags & GP_CIRCLE_SEG1; uint8_t seg2 = seg_flags & GP_CIRCLE_SEG2; uint8_t seg3 = seg_flags & GP_CIRCLE_SEG3; uint8_t seg4 = seg_flags & GP_CIRCLE_SEG4; - if (context->axes_swap) + if (pixmap->axes_swap) GP_SWAP(seg1, seg3); - if (context->x_swap) { + if (pixmap->x_swap) { GP_SWAP(seg1, seg2); GP_SWAP(seg3, seg4); } - if (context->y_swap) { + if (pixmap->y_swap) { GP_SWAP(seg1, seg4); GP_SWAP(seg2, seg3); } @@ -62,24 +62,24 @@ static uint8_t transform_segments(GP_Context *context, uint8_t seg_flags) /* Generate drawing functions for various bit depths. */ GP_DEF_DRAW_FN_PER_BPP(GP_CircleSeg_Raw, DEF_CIRCLE_SEG_FN) -void GP_CircleSeg_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_CircleSeg_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, uint8_t seg_flag, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_FN_PER_BPP_CONTEXT(GP_CircleSeg_Raw, context, context, + GP_FN_PER_BPP_PIXMAP(GP_CircleSeg_Raw, pixmap, pixmap, xcenter, ycenter, r, seg_flag, pixel); } -void GP_CircleSeg(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_CircleSeg(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, uint8_t seg_flag, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT(context, xcenter, ycenter); + GP_TRANSFORM_POINT(pixmap, xcenter, ycenter); - GP_CircleSeg_Raw(context, xcenter, ycenter, r, - transform_segments(context, seg_flag), pixel); + GP_CircleSeg_Raw(pixmap, xcenter, ycenter, r, + transform_segments(pixmap, seg_flag), pixel); } /* @@ -87,22 +87,22 @@ void GP_CircleSeg(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, GP_DEF_FILL_FN_PER_BPP(GP_FillCircle_Raw, DEF_FILLCIRCLE_FN) -void GP_FillCircle_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillCircle_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_FN_PER_BPP_CONTEXT(GP_FillCircle_Raw, context, context, + GP_FN_PER_BPP_PIXMAP(GP_FillCircle_Raw, pixmap, pixmap, xcenter, ycenter, r, pixel); } -void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillCircle(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT(context, xcenter, ycenter); + GP_TRANSFORM_POINT(pixmap, xcenter, ycenter); - GP_FillCircle_Raw(context, xcenter, ycenter, r, pixel); + GP_FillCircle_Raw(pixmap, xcenter, ycenter, r, pixel); } */ diff --git a/libs/gfx/GP_Ellipse.c b/libs/gfx/GP_Ellipse.c index 1d2085ea..ce5869a6 100644 --- a/libs/gfx/GP_Ellipse.c +++ b/libs/gfx/GP_Ellipse.c @@ -34,23 +34,23 @@ /* Generate drawing functions for various bit depths. */ GP_DEF_DRAW_FN_PER_BPP(GP_Ellipse_Raw, DEF_ELLIPSE_FN) -void GP_Ellipse_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Ellipse_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_FN_PER_BPP_CONTEXT(GP_Ellipse_Raw, context, context, + GP_FN_PER_BPP_PIXMAP(GP_Ellipse_Raw, pixmap, pixmap, xcenter, ycenter, a, b, pixel); } -void GP_Ellipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_Ellipse(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); /* 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_TRANSFORM_POINT(pixmap, xcenter, ycenter); + GP_TRANSFORM_SWAP(pixmap, a, b); - GP_Ellipse_Raw(context, xcenter, ycenter, a, b, pixel); + GP_Ellipse_Raw(pixmap, xcenter, ycenter, a, b, pixel); } diff --git a/libs/gfx/GP_FillCircle.gen.c.t b/libs/gfx/GP_FillCircle.gen.c.t index 856b13bb..48ac9501 100644 --- a/libs/gfx/GP_FillCircle.gen.c.t +++ b/libs/gfx/GP_FillCircle.gen.c.t @@ -24,12 +24,12 @@ */ @ for ps in pixelsizes: -static void GP_FillCircle_Raw_{{ ps.suffix }}(GP_Context *context, +static void GP_FillCircle_Raw_{{ ps.suffix }}(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel) { /* for r == 0, circle degenerates to a point */ if (r == 0) { - GP_PutPixel_Raw_{{ ps.suffix }}(context, xcenter, ycenter, pixel); + GP_PutPixel_Raw_{{ ps.suffix }}(pixmap, xcenter, ycenter, pixel); return; } @@ -40,28 +40,28 @@ static void GP_FillCircle_Raw_{{ ps.suffix }}(GP_Context *context, x++; } error += -2*y + 1; - 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); + GP_HLine_Raw_{{ ps.suffix }}(pixmap, xcenter-x+1, xcenter+x-1, ycenter-y, pixel); + GP_HLine_Raw_{{ ps.suffix }}(pixmap, xcenter-x+1, xcenter+x-1, ycenter+y, pixel); } } @ end -void GP_FillCircle_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillCircle_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_FN_PER_BPP_CONTEXT(GP_FillCircle_Raw, context, context, + GP_FN_PER_BPP_PIXMAP(GP_FillCircle_Raw, pixmap, pixmap, xcenter, ycenter, r, pixel); } -void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillCircle(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size r, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT(context, xcenter, ycenter); + GP_TRANSFORM_POINT(pixmap, xcenter, ycenter); - GP_FillCircle_Raw(context, xcenter, ycenter, r, pixel); + GP_FillCircle_Raw(pixmap, xcenter, ycenter, r, pixel); } diff --git a/libs/gfx/GP_FillEllipse.gen.c.t b/libs/gfx/GP_FillEllipse.gen.c.t index 9638d478..3a86fcfa 100644 --- a/libs/gfx/GP_FillEllipse.gen.c.t +++ b/libs/gfx/GP_FillEllipse.gen.c.t @@ -22,7 +22,7 @@ @ for ps in pixelsizes: -static void GP_FillEllipse_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord xcenter, +static void GP_FillEllipse_Raw_{{ ps.suffix }}(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel) { /* Precompute quadratic terms. */ @@ -31,7 +31,7 @@ static void GP_FillEllipse_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord xce /* Handle special case */ if (a == 0) { - GP_VLine_Raw_{{ ps.suffix }}(context, xcenter, ycenter - b, ycenter + b, pixel); + GP_VLine_Raw_{{ ps.suffix }}(pixmap, xcenter, ycenter - b, ycenter + b, pixel); return; } @@ -44,29 +44,29 @@ static void GP_FillEllipse_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord xce 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); + GP_HLine_Raw_{{ ps.suffix }}(pixmap, xcenter-x+1, xcenter+x-1, ycenter-y, pixel); + GP_HLine_Raw_{{ ps.suffix }}(pixmap, xcenter-x+1, xcenter+x-1, ycenter+y, pixel); } } @ end -void GP_FillEllipse_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillEllipse_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_FN_PER_BPP_CONTEXT(GP_FillEllipse_Raw, context, context, + GP_FN_PER_BPP_PIXMAP(GP_FillEllipse_Raw, pixmap, pixmap, xcenter, ycenter, a, b, pixel); } -void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_FillEllipse(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT(context, xcenter, ycenter); - GP_TRANSFORM_SWAP(context, a, b); + GP_TRANSFORM_POINT(pixmap, xcenter, ycenter); + GP_TRANSFORM_SWAP(pixmap, a, b); - GP_FillEllipse_Raw(context, xcenter, ycenter, a, b, pixel); + GP_FillEllipse_Raw(pixmap, xcenter, ycenter, a, b, pixel); } diff --git a/libs/gfx/GP_HLine.c b/libs/gfx/GP_HLine.c index 22556606..fa32807e 100644 --- a/libs/gfx/GP_HLine.c +++ b/libs/gfx/GP_HLine.c @@ -28,47 +28,47 @@ #include "gfx/GP_HLine.h" #include "gfx/GP_VLine.h" -void GP_HLineXXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, +void GP_HLineXXY_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_FN_PER_BPP_CONTEXT(GP_HLine_Raw, context, context, x0, x1, y, + GP_FN_PER_BPP_PIXMAP(GP_HLine_Raw, pixmap, pixmap, x0, x1, y, pixel); } -void GP_HLineXYW_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, +void GP_HLineXYW_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Pixel pixel) { if (w == 0) return; - GP_HLineXXY_Raw(context, x, x + w - 1, y, pixel); + GP_HLineXXY_Raw(pixmap, x, x + w - 1, y, pixel); } -void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y, +void GP_HLineXXY(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - if (context->axes_swap) { - GP_TRANSFORM_Y(context, x0); - GP_TRANSFORM_Y(context, x1); - GP_TRANSFORM_X(context, y); - GP_VLine_Raw(context, y, x0, x1, pixel); + if (pixmap->axes_swap) { + GP_TRANSFORM_Y(pixmap, x0); + GP_TRANSFORM_Y(pixmap, x1); + GP_TRANSFORM_X(pixmap, y); + GP_VLine_Raw(pixmap, y, x0, x1, pixel); } else { - GP_TRANSFORM_X(context, x0); - GP_TRANSFORM_X(context, x1); - GP_TRANSFORM_Y(context, y); - GP_HLine_Raw(context, x0, x1, y, pixel); + GP_TRANSFORM_X(pixmap, x0); + GP_TRANSFORM_X(pixmap, x1); + GP_TRANSFORM_Y(pixmap, y); + GP_HLine_Raw(pixmap, x0, x1, y, pixel); } } -void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w, +void GP_HLineXYW(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Pixel pixel) { if (w == 0) return; - GP_HLineXXY(context, x, x + w - 1, y, pixel); + GP_HLineXXY(pixmap, x, x + w - 1, y, pixel); } diff --git a/libs/gfx/GP_HLine.gen.c.t b/libs/gfx/GP_HLine.gen.c.t index f5caae70..d2e21237 100644 --- a/libs/gfx/GP_HLine.gen.c.t +++ b/libs/gfx/GP_HLine.gen.c.t @@ -20,7 +20,7 @@ @ '24BPP', '32BPP'] @ @ for ps in pixelsizes: -void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int x1, int y, +void GP_HLine_Raw_{{ ps.suffix }}(GP_Pixmap *pixmap, int x0, int x1, int y, GP_Pixel pixel) { /* draw always from left to right, swap coords if necessary */ @@ -28,16 +28,16 @@ void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int x1, int y, GP_SWAP(x0, x1); /* return immediately if the line is completely out of surface */ - if (y < 0 || y >= (int) context->h || x1 < 0 || x0 >= (int) context->w) + if (y < 0 || y >= (int) pixmap->h || x1 < 0 || x0 >= (int) pixmap->w) return; /* clip the line against surface boundaries */ x0 = GP_MAX(x0, 0); - x1 = GP_MIN(x1, (int) context->w - 1); + x1 = GP_MIN(x1, (int) pixmap->w - 1); @ if ps.suffix in have_writepixels: size_t length = 1 + x1 - x0; - void *start = GP_PIXEL_ADDR(context, x0, y); + void *start = GP_PIXEL_ADDR(pixmap, x0, y); @ if ps.needs_bit_endian(): unsigned int offset = GP_PIXEL_ADDR_OFFSET_{{ ps.suffix }}(x0); @@ -47,7 +47,7 @@ void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int x1, int y, GP_WritePixels_{{ ps.suffix }}(start, length, pixel); @ else: for (;x0 <= x1; x0++) - GP_PutPixel_Raw_{{ ps.suffix }}(context, x0, y, pixel); + GP_PutPixel_Raw_{{ ps.suffix }}(pixmap, x0, y, pixel); @ end } diff --git a/libs/gfx/GP_HLineAA.c b/libs/gfx/GP_HLineAA.c index 93b5e04e..28818247 100644 --- a/libs/gfx/GP_HLineAA.c +++ b/libs/gfx/GP_HLineAA.c @@ -27,30 +27,30 @@ #include "gfx/GP_VLineAA.h" /* -void GP_HLineXXYAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, +void GP_HLineXXYAA_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_FN_PER_BPP_CONTEXT(GP_HLine_Raw, context, context, x0, x1, y, + GP_FN_PER_BPP_PIXMAP(GP_HLine_Raw, pixmap, pixmap, x0, x1, y, pixel); } */ -void GP_HLineAA(GP_Context *context, GP_Coord x0, GP_Coord x1, +void GP_HLineAA(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - if (context->axes_swap) { - GP_TRANSFORM_Y_FP(context, x0); - GP_TRANSFORM_Y_FP(context, x1); - GP_TRANSFORM_X_FP(context, y); - GP_VLineAA_Raw(context, y, x0, x1, pixel); + if (pixmap->axes_swap) { + GP_TRANSFORM_Y_FP(pixmap, x0); + GP_TRANSFORM_Y_FP(pixmap, x1); + GP_TRANSFORM_X_FP(pixmap, y); + GP_VLineAA_Raw(pixmap, y, x0, x1, pixel); } else { - GP_TRANSFORM_X_FP(context, x0); - GP_TRANSFORM_X_FP(context, x1); - GP_TRANSFORM_Y_FP(context, y); - GP_HLineAA_Raw(context, x0, x1, y, pixel); + GP_TRANSFORM_X_FP(pixmap, x0); + GP_TRANSFORM_X_FP(pixmap, x1); + GP_TRANSFORM_Y_FP(pixmap, y); + GP_HLineAA_Raw(pixmap, x0, x1, y, pixel); } } diff --git a/libs/gfx/GP_HLineAA.gen.c.t b/libs/gfx/GP_HLineAA.gen.c.t index 2a4910fb..49c40ef7 100644 --- a/libs/gfx/GP_HLineAA.gen.c.t +++ b/libs/gfx/GP_HLineAA.gen.c.t @@ -22,7 +22,7 @@ /* Anti Aliased Horizontal Line */ -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_MixPixels.h" #include "core/GP_FixedPoint.h" #include "core/GP_GammaCorrection.h" @@ -39,7 +39,7 @@ #define TO_X_S(x) GP_FP_FLOOR_TO_INT((x) + GP_FP_1_2) #define TO_X_E(x) GP_FP_CEIL_TO_INT((x) - GP_FP_1_2) -void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, +void GP_HLineAA_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord x1, GP_Coord y, GP_Pixel pixel) { /* Nothing to draw */ @@ -62,19 +62,19 @@ void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, 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); + GP_MixPixel_Raw_Clipped(pixmap, 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(pixmap, 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); + GP_MixPixel_Raw_Clipped(pixmap, 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(pixmap, int_x1, int_y+1, pixel, perc); } GP_Coord x; @@ -84,7 +84,7 @@ void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1, 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); + GP_MixPixel_Raw_Clipped(pixmap, x, int_y, pixel, up); + GP_MixPixel_Raw_Clipped(pixmap, 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 093a6742..b45bfacd 100644 --- a/libs/gfx/GP_Line.gen.c.t +++ b/libs/gfx/GP_Line.gen.c.t @@ -23,29 +23,29 @@ */ @ for ps in pixelsizes: -void GP_Line_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int y0, +void GP_Line_Raw_{{ ps.suffix }}(GP_Pixmap *pixmap, int x0, int y0, int x1, int y1, GP_Pixel pixval) { - if (!GP_LineClip(&x0, &y0, &x1, &y1, context->w - 1, context->h - 1)) + if (!GP_LineClip(&x0, &y0, &x1, &y1, pixmap->w - 1, pixmap->h - 1)) return; - GP_ASSERT(x0 >= 0 && x0 <= (int) context->w-1); - 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); + GP_ASSERT(x0 >= 0 && x0 <= (int) pixmap->w-1); + GP_ASSERT(x1 >= 0 && x1 <= (int) pixmap->w-1); + GP_ASSERT(y0 >= 0 && y0 <= (int) pixmap->h-1); + GP_ASSERT(y1 >= 0 && y1 <= (int) pixmap->h-1); /* special cases: vertical line, horizontal line, single point */ if (x0 == x1) { if (y0 == y1) { - GP_PutPixel_Raw_Clipped_{{ ps.suffix }}(context, + GP_PutPixel_Raw_Clipped_{{ ps.suffix }}(pixmap, x0, y0, pixval); return; } - GP_VLine_Raw(context, x0, y0, y1, pixval); + GP_VLine_Raw(pixmap, x0, y0, y1, pixval); return; } if (y0 == y1) { - GP_HLine_Raw(context, x0, x1, y0, pixval); + GP_HLine_Raw(pixmap, x0, x1, y0, pixval); return; } @@ -79,10 +79,10 @@ void GP_Line_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int y0, for (x = x0; x <= x1; x++) { if (steep) - GP_PutPixel_Raw_{{ ps.suffix }}(context, y, x, + GP_PutPixel_Raw_{{ ps.suffix }}(pixmap, y, x, pixval); else - GP_PutPixel_Raw_{{ ps.suffix }}(context, x, y, + GP_PutPixel_Raw_{{ ps.suffix }}(pixmap, x, y, pixval); error -= deltay; @@ -95,22 +95,22 @@ void GP_Line_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int y0, @ end -void GP_Line_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Line_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_FN_PER_BPP_CONTEXT(GP_Line_Raw, context, context, x0, y0, x1, y1, + GP_FN_PER_BPP_PIXMAP(GP_Line_Raw, pixmap, pixmap, x0, y0, x1, y1, pixel); } -void GP_Line(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Line(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT(context, x0, y0); - GP_TRANSFORM_POINT(context, x1, y1); + GP_TRANSFORM_POINT(pixmap, x0, y0); + GP_TRANSFORM_POINT(pixmap, x1, y1); - GP_Line_Raw(context, x0, y0, x1, y1, pixel); + GP_Line_Raw(pixmap, x0, y0, x1, y1, pixel); } diff --git a/libs/gfx/GP_LineAA.c b/libs/gfx/GP_LineAA.c index 5c2ad8e9..1e20ddc9 100644 --- a/libs/gfx/GP_LineAA.c +++ b/libs/gfx/GP_LineAA.c @@ -29,23 +29,23 @@ #include "gfx/GP_LineAA.h" /* -void GP_Line_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Line_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_FN_PER_BPP_CONTEXT(GP_Line_Raw, context, context, x0, y0, x1, y1, + GP_FN_PER_BPP_PIXMAP(GP_Line_Raw, pixmap, pixmap, x0, y0, x1, y1, pixel); } */ -void GP_LineAA(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_LineAA(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT_FP(context, x0, y0); - GP_TRANSFORM_POINT_FP(context, x1, y1); + GP_TRANSFORM_POINT_FP(pixmap, x0, y0); + GP_TRANSFORM_POINT_FP(pixmap, x1, y1); - GP_LineAA_Raw(context, x0, y0, x1, y1, pixel); + GP_LineAA_Raw(pixmap, x0, y0, x1, y1, pixel); } diff --git a/libs/gfx/GP_LineAA.gen.c.t b/libs/gfx/GP_LineAA.gen.c.t index 3029dfb5..3eed710d 100644 --- a/libs/gfx/GP_LineAA.gen.c.t +++ b/libs/gfx/GP_LineAA.gen.c.t @@ -22,7 +22,7 @@ /* Anti Aliased Line */ -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_MixPixels.h" #include "core/GP_FixedPoint.h" #include "core/GP_GammaCorrection.h" @@ -32,7 +32,7 @@ #define FP_TO_PERC(a) (GP_FP_ROUND_TO_INT((a) * 255)) -static inline void line_aa_x(GP_Context *context, +static inline void line_aa_x(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { @@ -54,9 +54,9 @@ static inline void line_aa_x(GP_Context *context, ypx1 = GP_FP_TO_INT(yend); perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(yend), xgap)); - GP_MixPixel_Raw_Clipped(context, xpx1, ypx1, pixel, perc); + GP_MixPixel_Raw_Clipped(pixmap, xpx1, ypx1, pixel, perc); perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(yend), xgap)); - GP_MixPixel_Raw_Clipped(context, xpx1, ypx1+1, pixel, perc); + GP_MixPixel_Raw_Clipped(pixmap, xpx1, ypx1+1, pixel, perc); xend = GP_FP_ROUND(x0); yend = y0 + GP_FP_DIV(GP_FP_MUL(dy, xend - x0), dx); @@ -65,9 +65,9 @@ static inline void line_aa_x(GP_Context *context, ypx0 = GP_FP_TO_INT(yend); perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(yend), xgap)); - GP_MixPixel_Raw_Clipped(context, xpx0, ypx0, pixel, perc); + GP_MixPixel_Raw_Clipped(pixmap, xpx0, ypx0, pixel, perc); perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(yend), xgap)); - GP_MixPixel_Raw_Clipped(context, xpx0, ypx0+1, pixel, perc); + GP_MixPixel_Raw_Clipped(pixmap, xpx0, ypx0+1, pixel, perc); GP_Coord x; GP_Coord intery; @@ -76,13 +76,13 @@ static inline void line_aa_x(GP_Context *context, 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); + GP_MixPixel_Raw_Clipped(pixmap, x, GP_FP_TO_INT(intery), pixel, perc); perc = FP_TO_PERC(GP_FP_FRAC(intery)); - GP_MixPixel_Raw_Clipped(context, x, GP_FP_TO_INT(intery)+1, pixel, perc); + GP_MixPixel_Raw_Clipped(pixmap, x, GP_FP_TO_INT(intery)+1, pixel, perc); } } -static inline void line_aa_y(GP_Context *context, +static inline void line_aa_y(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { @@ -104,9 +104,9 @@ static inline void line_aa_y(GP_Context *context, xpx1 = GP_FP_TO_INT(xend); perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(xend), ygap)); - GP_MixPixel_Raw_Clipped(context, xpx1, ypx1, pixel, perc); + GP_MixPixel_Raw_Clipped(pixmap, xpx1, ypx1, pixel, perc); perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(xend), ygap)); - GP_MixPixel_Raw_Clipped(context, xpx1, ypx1+1, pixel, perc); + GP_MixPixel_Raw_Clipped(pixmap, xpx1, ypx1+1, pixel, perc); yend = GP_FP_ROUND(y0); xend = x0 + GP_FP_DIV(GP_FP_MUL(dx, yend - y0), dy); @@ -115,9 +115,9 @@ static inline void line_aa_y(GP_Context *context, xpx0 = GP_FP_TO_INT(xend); perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(xend), ygap)); - GP_MixPixel_Raw_Clipped(context, xpx0, ypx0, pixel, perc); + GP_MixPixel_Raw_Clipped(pixmap, xpx0, ypx0, pixel, perc); perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(xend), ygap)); - GP_MixPixel_Raw_Clipped(context, xpx0, ypx0+1, pixel, perc); + GP_MixPixel_Raw_Clipped(pixmap, xpx0, ypx0+1, pixel, perc); GP_Coord y; GP_Coord intery; @@ -126,30 +126,30 @@ static inline void line_aa_y(GP_Context *context, 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); + GP_MixPixel_Raw_Clipped(pixmap, GP_FP_TO_INT(intery), y, pixel, perc); perc = FP_TO_PERC(GP_FP_FRAC(intery)); - GP_MixPixel_Raw_Clipped(context, GP_FP_TO_INT(intery)+1, y, pixel, perc); + GP_MixPixel_Raw_Clipped(pixmap, GP_FP_TO_INT(intery)+1, y, pixel, perc); } } -void GP_LineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_LineAA_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { int64_t dx = x1 - x0; int64_t dy = y1 - y0; if (dy == 0) { - GP_HLineAA_Raw(context, x0, x1, y0, pixel); + GP_HLineAA_Raw(pixmap, x0, x1, y0, pixel); return; } if (dx == 0) { - GP_VLineAA_Raw(context, x0, y0, y1, pixel); + GP_VLineAA_Raw(pixmap, x0, y0, y1, pixel); return; } if (GP_ABS(dx) < GP_ABS(dy)) - line_aa_y(context, x0, y0, x1, y1, pixel); + line_aa_y(pixmap, x0, y0, x1, y1, pixel); else - line_aa_x(context, x0, y0, x1, y1, pixel); + line_aa_x(pixmap, x0, y0, x1, y1, pixel); } diff --git a/libs/gfx/GP_PartialEllipse.c b/libs/gfx/GP_PartialEllipse.c index 964bf933..0cfd1c9d 100644 --- a/libs/gfx/GP_PartialEllipse.c +++ b/libs/gfx/GP_PartialEllipse.c @@ -33,23 +33,23 @@ /* Generate drawing functions for various bit depths. */ GP_DEF_DRAW_FN_PER_BPP(GP_PartialEllipse_Raw, DEF_PARTIAL_ELLIPSE_FN) -void GP_PartialEllipse_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_PartialEllipse_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, int start, int end, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_FN_PER_BPP_CONTEXT(GP_PartialEllipse_Raw, context, context, + GP_FN_PER_BPP_PIXMAP(GP_PartialEllipse_Raw, pixmap, pixmap, xcenter, ycenter, a, b, start, end, pixel); } -void GP_PartialEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter, +void GP_PartialEllipse(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, GP_Size a, GP_Size b, int start, int end, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); /* 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_TRANSFORM_POINT(pixmap, xcenter, ycenter); + GP_TRANSFORM_SWAP(pixmap, a, b); - GP_PartialEllipse_Raw(context, xcenter, ycenter, a, b, start, end, pixel); + GP_PartialEllipse_Raw(pixmap, xcenter, ycenter, a, b, start, end, pixel); } diff --git a/libs/gfx/GP_Polygon.c b/libs/gfx/GP_Polygon.c index dd397b54..8b62e9aa 100644 --- a/libs/gfx/GP_Polygon.c +++ b/libs/gfx/GP_Polygon.c @@ -139,7 +139,7 @@ static int GP_CompareEdgesRuntime(struct GP_Edge *e1, struct GP_Edge *e2) return 0; } -void GP_FillPolygon_Raw(GP_Context *context, unsigned int nvert, +void GP_FillPolygon_Raw(GP_Pixmap *pixmap, unsigned int nvert, const GP_Coord *xy, GP_Pixel pixel) { unsigned int i; @@ -217,7 +217,7 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int nvert, break; float end = inter[i+1]; - GP_HLine_Raw(context, start, end, y, pixel); + GP_HLine_Raw(pixmap, start, end, y, pixel); } /* update active edges for next step */ @@ -240,13 +240,13 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int nvert, for (i = 0; i < nedges; i++) { e = edges + i; if (e->state == EDGE_HORIZONTAL) { - GP_HLine_Raw(context, e->x, e->x + e->dxy, e->y, + GP_HLine_Raw(pixmap, e->x, e->x + e->dxy, e->y, pixel); } } } -void GP_FillPolygon(GP_Context *context, unsigned int vertex_count, +void GP_FillPolygon(GP_Pixmap *pixmap, unsigned int vertex_count, const GP_Coord *xy, GP_Pixel pixel) { unsigned int i; @@ -258,13 +258,13 @@ void GP_FillPolygon(GP_Context *context, unsigned int vertex_count, xy_copy[x] = xy[x]; xy_copy[y] = xy[y]; - GP_TRANSFORM_POINT(context, xy_copy[x], xy_copy[y]); + GP_TRANSFORM_POINT(pixmap, xy_copy[x], xy_copy[y]); } - GP_FillPolygon_Raw(context, vertex_count, xy_copy, pixel); + GP_FillPolygon_Raw(pixmap, vertex_count, xy_copy, pixel); } -void GP_Polygon_Raw(GP_Context *context, unsigned int vertex_count, +void GP_Polygon_Raw(GP_Pixmap *pixmap, unsigned int vertex_count, const GP_Coord *xy, GP_Pixel pixel) { unsigned int i; @@ -276,7 +276,7 @@ void GP_Polygon_Raw(GP_Context *context, unsigned int vertex_count, GP_Coord x = xy[2 * i]; GP_Coord y = xy[2 * i + 1]; - GP_Line_Raw(context, prev_x, prev_y, x, y, pixel); + GP_Line_Raw(pixmap, prev_x, prev_y, x, y, pixel); prev_x = x; prev_y = y; @@ -284,7 +284,7 @@ void GP_Polygon_Raw(GP_Context *context, unsigned int vertex_count, } -void GP_Polygon(GP_Context *context, unsigned int vertex_count, +void GP_Polygon(GP_Pixmap *pixmap, unsigned int vertex_count, const GP_Coord *xy, GP_Pixel pixel) { unsigned int i; @@ -292,15 +292,15 @@ void GP_Polygon(GP_Context *context, unsigned int vertex_count, GP_Coord prev_x = xy[2 * vertex_count - 2]; GP_Coord prev_y = xy[2 * vertex_count - 1]; - GP_TRANSFORM_POINT(context, prev_x, prev_y); + GP_TRANSFORM_POINT(pixmap, prev_x, prev_y); for (i = 0; i < vertex_count; i++) { GP_Coord x = xy[2 * i]; GP_Coord y = xy[2 * i + 1]; - GP_TRANSFORM_POINT(context, x, y); + GP_TRANSFORM_POINT(pixmap, x, y); - GP_Line_Raw(context, prev_x, prev_y, x, y, pixel); + GP_Line_Raw(pixmap, prev_x, prev_y, x, y, pixel); prev_x = x; prev_y = y; diff --git a/libs/gfx/GP_PutPixelAA.gen.c.t b/libs/gfx/GP_PutPixelAA.gen.c.t index 92cfbdb1..0d2a0713 100644 --- a/libs/gfx/GP_PutPixelAA.gen.c.t +++ b/libs/gfx/GP_PutPixelAA.gen.c.t @@ -22,7 +22,7 @@ /* Anti Aliased Put Pixel */ -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_MixPixels.h" #include "core/GP_FixedPoint.h" #include "core/GP_GammaCorrection.h" @@ -32,7 +32,7 @@ #define FP_TO_PERC(a) (GP_FP_ROUND_TO_INT((a) * 255)) -void GP_PutPixelAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y, +void GP_PutPixelAA_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel pixel) { GP_Coord int_x = GP_FP_TO_INT(x); @@ -42,27 +42,27 @@ void GP_PutPixelAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y, uint8_t perc; 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); + GP_MixPixel_Raw_Clipped(pixmap, 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); + GP_MixPixel_Raw_Clipped(pixmap, 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); + GP_MixPixel_Raw_Clipped(pixmap, 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); + GP_MixPixel_Raw_Clipped(pixmap, int_x + 1, int_y + 1, pixel, perc); } -void GP_PutPixelAA_Raw_Clipped(GP_Context *context, GP_Coord x, GP_Coord y, +void GP_PutPixelAA_Raw_Clipped(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel pixel) { - GP_PutPixelAA_Raw(context, x, y, pixel); + GP_PutPixelAA_Raw(pixmap, x, y, pixel); } -void GP_PutPixelAA(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel pixel) +void GP_PutPixelAA(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Pixel pixel) { - GP_TRANSFORM_POINT_FP(context, x, y); + GP_TRANSFORM_POINT_FP(pixmap, x, y); - GP_PutPixelAA_Raw_Clipped(context, x, y, pixel); + GP_PutPixelAA_Raw_Clipped(pixmap, x, y, pixel); } diff --git a/libs/gfx/GP_Rect.c b/libs/gfx/GP_Rect.c index 618c7885..cbaf5f2b 100644 --- a/libs/gfx/GP_Rect.c +++ b/libs/gfx/GP_Rect.c @@ -29,85 +29,85 @@ #include "gfx/GP_VLine.h" #include "gfx/GP_Rect.h" -void GP_RectXYXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_RectXYXY_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { - GP_HLine_Raw(context, x0, x1, y0, pixel); - GP_HLine_Raw(context, x0, x1, y1, pixel); - GP_VLine_Raw(context, x0, y0, y1, pixel); - GP_VLine_Raw(context, x1, y0, y1, pixel); + GP_HLine_Raw(pixmap, x0, x1, y0, pixel); + GP_HLine_Raw(pixmap, x0, x1, y1, pixel); + GP_VLine_Raw(pixmap, x0, y0, y1, pixel); + GP_VLine_Raw(pixmap, x1, y0, y1, pixel); } -void GP_RectXYWH_Raw(GP_Context *context, GP_Coord x, GP_Coord y, +void GP_RectXYWH_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel) { if (w == 0 || h == 0) return; - GP_RectXYXY_Raw(context, x, y, x + w - 1, y + h - 1, pixel); + GP_RectXYXY_Raw(pixmap, x, y, x + w - 1, y + h - 1, pixel); } -void GP_RectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_RectXYXY(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT(context, x0, y0); - GP_TRANSFORM_POINT(context, x1, y1); + GP_TRANSFORM_POINT(pixmap, x0, y0); + GP_TRANSFORM_POINT(pixmap, x1, y1); - GP_RectXYXY_Raw(context, x0, y0, x1, y1, pixel); + GP_RectXYXY_Raw(pixmap, x0, y0, x1, y1, pixel); } -void GP_RectXYWH(GP_Context *context, GP_Coord x, GP_Coord y, +void GP_RectXYWH(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel) { if (w == 0 || h == 0) return; - GP_RectXYXY(context, x, y, x + w - 1, y + h - 1, pixel); + GP_RectXYXY(pixmap, x, y, x + w - 1, y + h - 1, pixel); } -void GP_FillRectXYXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_FillRectXYXY_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); if (y0 > y1) GP_SWAP(y0, y1); y0 = GP_MAX(0, y0); - y1 = GP_MIN(y1, (GP_Coord)context->h - 1); + y1 = GP_MIN(y1, (GP_Coord)pixmap->h - 1); GP_Coord y; for (y = y0; y <= y1; y++) - GP_HLine_Raw(context, x0, x1, y, pixel); + GP_HLine_Raw(pixmap, x0, x1, y, pixel); } -void GP_FillRectXYWH_Raw(GP_Context *context, GP_Coord x, GP_Coord y, +void GP_FillRectXYWH_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel) { if (w == 0 || h == 0) return; - GP_FillRectXYXY_Raw(context, x, y, x + w - 1, y + h - 1, pixel); + GP_FillRectXYXY_Raw(pixmap, x, y, x + w - 1, y + h - 1, pixel); } -void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_FillRectXYXY(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT(context, x0, y0); - GP_TRANSFORM_POINT(context, x1, y1); + GP_TRANSFORM_POINT(pixmap, x0, y0); + GP_TRANSFORM_POINT(pixmap, x1, y1); - GP_FillRectXYXY_Raw(context, x0, y0, x1, y1, pixel); + GP_FillRectXYXY_Raw(pixmap, x0, y0, x1, y1, pixel); } -void GP_FillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y, +void GP_FillRectXYWH(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel) { if (w == 0 || h == 0) return; - GP_FillRectXYXY(context, x, y, x + w - 1, y + h - 1, pixel); + GP_FillRectXYXY(pixmap, x, y, x + w - 1, y + h - 1, pixel); } diff --git a/libs/gfx/GP_Tetragon.c b/libs/gfx/GP_Tetragon.c index 66ed426e..5bf45da8 100644 --- a/libs/gfx/GP_Tetragon.c +++ b/libs/gfx/GP_Tetragon.c @@ -29,53 +29,53 @@ #include "gfx/GP_Polygon.h" #include "gfx/GP_Tetragon.h" -void GP_Tetragon_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Tetragon_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Coord x3, GP_Coord y3, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_Line_Raw(context, x0, y0, x1, y1, pixel); - GP_Line_Raw(context, x1, y1, x2, y2, pixel); - GP_Line_Raw(context, x2, y2, x3, y3, pixel); - GP_Line_Raw(context, x3, y3, x0, y0, pixel); + GP_Line_Raw(pixmap, x0, y0, x1, y1, pixel); + GP_Line_Raw(pixmap, x1, y1, x2, y2, pixel); + GP_Line_Raw(pixmap, x2, y2, x3, y3, pixel); + GP_Line_Raw(pixmap, x3, y3, x0, y0, pixel); } -void GP_Tetragon(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Tetragon(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Coord x3, GP_Coord y3, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT(context, x0, y0); - GP_TRANSFORM_POINT(context, x1, y1); - GP_TRANSFORM_POINT(context, x2, y2); - GP_TRANSFORM_POINT(context, x3, y3); + GP_TRANSFORM_POINT(pixmap, x0, y0); + GP_TRANSFORM_POINT(pixmap, x1, y1); + GP_TRANSFORM_POINT(pixmap, x2, y2); + GP_TRANSFORM_POINT(pixmap, x3, y3); - GP_Tetragon_Raw(context, x0, y0, x1, y1, x2, y2, x3, y3, pixel); + GP_Tetragon_Raw(pixmap, x0, y0, x1, y1, x2, y2, x3, y3, pixel); } -void GP_FillTetragon_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_FillTetragon_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, 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); + GP_FillPolygon_Raw(pixmap, 4, xy, pixel); } -void GP_FillTetragon(GP_Context* context, GP_Coord x0, GP_Coord y0, +void GP_FillTetragon(GP_Pixmap* pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Coord x3, GP_Coord y3, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT(context, x0, y0); - GP_TRANSFORM_POINT(context, x1, y1); - GP_TRANSFORM_POINT(context, x2, y2); - GP_TRANSFORM_POINT(context, x3, y3); + GP_TRANSFORM_POINT(pixmap, x0, y0); + GP_TRANSFORM_POINT(pixmap, x1, y1); + GP_TRANSFORM_POINT(pixmap, x2, y2); + GP_TRANSFORM_POINT(pixmap, x3, y3); const GP_Coord xy[8] = {x0, y0, x1, y1, x2, y2, x3, y3}; - GP_FillPolygon_Raw(context, 4, xy, pixel); + GP_FillPolygon_Raw(pixmap, 4, xy, pixel); } diff --git a/libs/gfx/GP_Triangle.c b/libs/gfx/GP_Triangle.c index 5f1e4e79..c4d9d10f 100644 --- a/libs/gfx/GP_Triangle.c +++ b/libs/gfx/GP_Triangle.c @@ -29,46 +29,46 @@ #include "gfx/GP_Polygon.h" #include "gfx/GP_Triangle.h" -void GP_Triangle_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Triangle_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Pixel pixel) { - GP_Line_Raw(context, x0, y0, x1, y1, pixel); - GP_Line_Raw(context, x0, y0, x2, y2, pixel); - GP_Line_Raw(context, x1, y1, x2, y2, pixel); + GP_Line_Raw(pixmap, x0, y0, x1, y1, pixel); + GP_Line_Raw(pixmap, x0, y0, x2, y2, pixel); + GP_Line_Raw(pixmap, x1, y1, x2, y2, pixel); } -void GP_Triangle(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_Triangle(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT(context, x0, y0); - GP_TRANSFORM_POINT(context, x1, y1); - GP_TRANSFORM_POINT(context, x2, y2); + GP_TRANSFORM_POINT(pixmap, x0, y0); + GP_TRANSFORM_POINT(pixmap, x1, y1); + GP_TRANSFORM_POINT(pixmap, x2, y2); - GP_Triangle_Raw(context, x0, y0, x1, y1, x2, y2, pixel); + GP_Triangle_Raw(pixmap, x0, y0, x1, y1, x2, y2, pixel); } -void GP_FillTriangle_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0, +void GP_FillTriangle_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Pixel pixel) { const GP_Coord coords[6] = {x0, y0, x1, y1, x2, y2}; - GP_FillPolygon_Raw(context, 3, coords, pixel); + GP_FillPolygon_Raw(pixmap, 3, coords, pixel); } -void GP_FillTriangle(GP_Context* context, GP_Coord x0, GP_Coord y0, +void GP_FillTriangle(GP_Pixmap* pixmap, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_TRANSFORM_POINT(context, x0, y0); - GP_TRANSFORM_POINT(context, x1, y1); - GP_TRANSFORM_POINT(context, x2, y2); + GP_TRANSFORM_POINT(pixmap, x0, y0); + GP_TRANSFORM_POINT(pixmap, x1, y1); + GP_TRANSFORM_POINT(pixmap, x2, y2); - GP_FillTriangle_Raw(context, x0, y0, x1, y1, x2, y2, pixel); + GP_FillTriangle_Raw(pixmap, x0, y0, x1, y1, x2, y2, pixel); } diff --git a/libs/gfx/GP_VLine.c b/libs/gfx/GP_VLine.c index 166aa032..e3ee1a77 100644 --- a/libs/gfx/GP_VLine.c +++ b/libs/gfx/GP_VLine.c @@ -37,55 +37,55 @@ #define ORDER_AND_CLIP_COORDS do { \ if (y0 > y1) \ GP_SWAP(y0, y1); \ - if (x < 0 || x >= (int) context->w || \ - y1 < 0 || y0 >= (int) context->h) \ + if (x < 0 || x >= (int) pixmap->w || \ + y1 < 0 || y0 >= (int) pixmap->h) \ return; \ y0 = GP_MAX(y0, 0); \ - y1 = GP_MIN(y1, (int) context->h - 1); \ + y1 = GP_MIN(y1, (int) pixmap->h - 1); \ } while (0) -void GP_VLineXYY_Raw(GP_Context *context, GP_Coord x, GP_Coord y0, +void GP_VLineXYY_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); ORDER_AND_CLIP_COORDS; - GP_FN_PER_BPP_CONTEXT(GP_VLine_Raw, context, context, x, y0, y1, pixel); + GP_FN_PER_BPP_PIXMAP(GP_VLine_Raw, pixmap, pixmap, x, y0, y1, pixel); } -void GP_VLineXYH_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size h, +void GP_VLineXYH_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size h, GP_Pixel pixel) { if (h == 0) return; - GP_VLineXYY(context, x, y, y + h - 1, pixel); + GP_VLineXYY(pixmap, x, y, y + h - 1, pixel); } -void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0, +void GP_VLineXYY(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - if (context->axes_swap) { - GP_TRANSFORM_Y(context, x); - GP_TRANSFORM_X(context, y0); - GP_TRANSFORM_X(context, y1); - GP_HLine_Raw(context, y0, y1, x, pixel); + if (pixmap->axes_swap) { + GP_TRANSFORM_Y(pixmap, x); + GP_TRANSFORM_X(pixmap, y0); + GP_TRANSFORM_X(pixmap, y1); + GP_HLine_Raw(pixmap, y0, y1, x, pixel); } else { - GP_TRANSFORM_X(context, x); - GP_TRANSFORM_Y(context, y0); - GP_TRANSFORM_Y(context, y1); - GP_VLine_Raw(context, x, y0, y1, pixel); + GP_TRANSFORM_X(pixmap, x); + GP_TRANSFORM_Y(pixmap, y0); + GP_TRANSFORM_Y(pixmap, y1); + GP_VLine_Raw(pixmap, x, y0, y1, pixel); } } -void GP_VLineXYH(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size h, +void GP_VLineXYH(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y, GP_Size h, GP_Pixel pixel) { if (h == 0) return; - GP_VLineXYY(context, x, y, y + h - 1, pixel); + GP_VLineXYY(pixmap, x, y, y + h - 1, pixel); } diff --git a/libs/gfx/GP_VLine.gen.c.t b/libs/gfx/GP_VLine.gen.c.t index 6870dea3..afd34ca2 100644 --- a/libs/gfx/GP_VLine.gen.c.t +++ b/libs/gfx/GP_VLine.gen.c.t @@ -9,12 +9,12 @@ #include "gfx/GP_VLine.gen.h" @ for ps in pixelsizes: -void GP_VLine_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord x, +void GP_VLine_Raw_{{ ps.suffix }}(GP_Pixmap *pixmap, 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); + GP_PutPixel_Raw_{{ ps.suffix }}(pixmap, x, y, pixel); } diff --git a/libs/gfx/GP_VLineAA.c b/libs/gfx/GP_VLineAA.c index 4af9f69b..37117a02 100644 --- a/libs/gfx/GP_VLineAA.c +++ b/libs/gfx/GP_VLineAA.c @@ -27,29 +27,29 @@ #include "gfx/GP_HLineAA.h" /* -void GP_VLineXYY_Raw(GP_Context *context, GP_Coord x, GP_Coord y0, +void GP_VLineXYY_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - GP_FN_PER_BPP_CONTEXT(GP_VLine, context, context, x, y0, y1, pixel); + GP_FN_PER_BPP_PIXMAP(GP_VLine, pixmap, pixmap, x, y0, y1, pixel); } */ -void GP_VLineAA(GP_Context *context, GP_Coord x, GP_Coord y0, +void GP_VLineAA(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); - if (context->axes_swap) { - GP_TRANSFORM_Y_FP(context, x); - GP_TRANSFORM_X_FP(context, y0); - GP_TRANSFORM_X_FP(context, y1); - GP_HLineAA_Raw(context, y0, y1, x, pixel); + if (pixmap->axes_swap) { + GP_TRANSFORM_Y_FP(pixmap, x); + GP_TRANSFORM_X_FP(pixmap, y0); + GP_TRANSFORM_X_FP(pixmap, y1); + GP_HLineAA_Raw(pixmap, y0, y1, x, pixel); } else { - GP_TRANSFORM_X_FP(context, x); - GP_TRANSFORM_Y_FP(context, y0); - GP_TRANSFORM_Y_FP(context, y1); - GP_VLineAA_Raw(context, x, y0, y1, pixel); + GP_TRANSFORM_X_FP(pixmap, x); + GP_TRANSFORM_Y_FP(pixmap, y0); + GP_TRANSFORM_Y_FP(pixmap, y1); + GP_VLineAA_Raw(pixmap, x, y0, y1, pixel); } } diff --git a/libs/gfx/GP_VLineAA.gen.c.t b/libs/gfx/GP_VLineAA.gen.c.t index 7ddd7cef..22c220d6 100644 --- a/libs/gfx/GP_VLineAA.gen.c.t +++ b/libs/gfx/GP_VLineAA.gen.c.t @@ -22,14 +22,14 @@ /* Anti Aliased Vertical Line */ -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_MixPixels.h" #include "core/GP_FixedPoint.h" #include "core/GP_GammaCorrection.h" #define FP_TO_PERC(a) (GP_FP_ROUND_TO_INT((a) * 255)) -void GP_VLineAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y0, +void GP_VLineAA_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y0, GP_Coord y1, GP_Pixel pixel) { if (y1 < y0) @@ -53,16 +53,16 @@ void GP_VLineAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y0, 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); + GP_MixPixel_Raw_Clipped(pixmap, 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(pixmap, 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); + GP_MixPixel_Raw_Clipped(pixmap, 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(pixmap, int_x+1, int_y1, pixel, perc); /* Draw the middle pixels */ uint8_t up = FP_TO_PERC(GP_FP_RFRAC(x)); @@ -71,7 +71,7 @@ void GP_VLineAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y0, 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); + GP_MixPixel_Raw_Clipped(pixmap, int_x, y, pixel, up); + GP_MixPixel_Raw_Clipped(pixmap, int_x+1, y, pixel, lp); } } diff --git a/libs/gfx/algo/Arc.algo.h b/libs/gfx/algo/Arc.algo.h index baff6771..eb2141e4 100644 --- a/libs/gfx/algo/Arc.algo.h +++ b/libs/gfx/algo/Arc.algo.h @@ -38,13 +38,13 @@ * (y > 0) are used. * * Arguments: - * CONTEXT_T - user-defined type of drawing context (passed to PUTPIXEL) + * PIXMAP_T - user-defined type of drawing pixmap (passed to PUTPIXEL) * PIXVAL_T - user-defined pixel value type (passed to PUTPIXEL) - * PUTPIXEL - a pixel drawing function f(context, x, y, pixval) + * PUTPIXEL - a pixel drawing function f(pixmap, x, y, pixval) * FN_NAME - name of the function to be defined */ -#define DEF_ARCSEGMENT_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) \ -static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, \ +#define DEF_ARCSEGMENT_FN(FN_NAME, PIXMAP_T, PIXVAL_T, PUTPIXEL) \ +static void FN_NAME(PIXMAP_T pixmap, int xcenter, int ycenter, \ unsigned int a, unsigned int b, int direction, \ double start, double end, PIXVAL_T pixval) \ { \ @@ -68,18 +68,18 @@ static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, \ \ if (direction < 0) { \ if ((-x+1) >= xmin && (-x+1) <= xmax) { \ - PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter-y, pixval); \ } \ if ((x-1) >= xmin && (x-1) <= xmax) { \ - PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter-y, pixval); \ } \ } \ if (direction > 0) { \ if ((-x+1) >= xmin && (-x+1) <= xmax) { \ - PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter+y, pixval); \ } \ if ((x-1) >= xmin && (x-1) <= xmax) { \ - PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter+y, pixval); \ } \ } \ } \ @@ -89,18 +89,18 @@ static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, \ \ if (direction < 0) { \ if ((-x+1) >= xmin && (-x+1) <= xmax) { \ - PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter-y, pixval); \ } \ if ((x-1) >= xmin && (x-1) <= xmax) { \ - PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter-y, pixval); \ } \ } \ if (direction > 0) { \ if ((-x+1) >= xmin && (-x+1) <= xmax) { \ - PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter+y, pixval); \ } \ if ((x-1) >= xmin && (x-1) <= xmax) { \ - PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter+y, pixval); \ } \ } \ } \ diff --git a/libs/gfx/algo/Circle.algo.h b/libs/gfx/algo/Circle.algo.h index 55c33edd..c1357984 100644 --- a/libs/gfx/algo/Circle.algo.h +++ b/libs/gfx/algo/Circle.algo.h @@ -68,20 +68,20 @@ /* * This macro defines a circle drawing function. * Arguments: - * CONTEXT_T - user-defined type of drawing context (passed to PUTPIXEL) + * PIXMAP_T - user-defined type of drawing pixmap (passed to PUTPIXEL) * PIXVAL_T - user-defined pixel value type (passed to PUTPIXEL) - * PUTPIXEL - a pixel drawing function f(context, x, y, pixval) + * PUTPIXEL - a pixel drawing function f(pixmap, x, y, pixval) * FN_NAME - name of the function to be defined */ -#define DEF_CIRCLE_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) \ -static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, int r, \ +#define DEF_CIRCLE_FN(FN_NAME, PIXMAP_T, PIXVAL_T, PUTPIXEL) \ +static void FN_NAME(PIXMAP_T pixmap, int xcenter, int ycenter, int r, \ PIXVAL_T pixval) \ { \ int x, y, error; \ \ /* Special case for r == 0 */ \ if (r == 0) { \ - PUTPIXEL(context, xcenter, ycenter, pixval); \ + PUTPIXEL(pixmap, xcenter, ycenter, pixval); \ return; \ } \ \ @@ -94,17 +94,17 @@ static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, int r, \ while (error < 0) { \ error += 2*x + 1; \ x++; \ - PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); \ - PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); \ - PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); \ - PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter+y, pixval); \ } \ \ /* Enough changes accumulated, go to next line. */ \ error += -2*y + 1; \ - PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); \ - PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); \ - PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); \ - PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter+y, pixval); \ } \ } diff --git a/libs/gfx/algo/CircleSeg.algo.h b/libs/gfx/algo/CircleSeg.algo.h index de3de088..a0ffa7a6 100644 --- a/libs/gfx/algo/CircleSeg.algo.h +++ b/libs/gfx/algo/CircleSeg.algo.h @@ -68,13 +68,13 @@ /* * This macro defines a circle drawing function. * Arguments: - * CONTEXT_T - user-defined type of drawing context (passed to PUTPIXEL) + * PIXMAP_T - user-defined type of drawing pixmap (passed to PUTPIXEL) * PIXVAL_T - user-defined pixel value type (passed to PUTPIXEL) - * PUTPIXEL - a pixel drawing function f(context, x, y, pixval) + * PUTPIXEL - a pixel drawing function f(pixmap, x, y, pixval) * FN_NAME - name of the function to be defined */ -#define DEF_CIRCLE_SEG_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) \ -static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, int r, \ +#define DEF_CIRCLE_SEG_FN(FN_NAME, PIXMAP_T, PIXVAL_T, PUTPIXEL) \ +static void FN_NAME(PIXMAP_T pixmap, int xcenter, int ycenter, int r, \ uint8_t seg_flags, PIXVAL_T pixval) \ { \ int x, y, error; \ @@ -82,7 +82,7 @@ static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, int r, \ /* Special case for r == 0 */ \ if (r == 0) { \ if (seg_flags) \ - PUTPIXEL(context, xcenter, ycenter, pixval); \ + PUTPIXEL(pixmap, xcenter, ycenter, pixval); \ return; \ } \ \ @@ -96,24 +96,24 @@ static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, int r, \ error += 2*x + 1; \ x++; \ if (seg_flags & GP_CIRCLE_SEG2) \ - PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter-y, pixval); \ if (seg_flags & GP_CIRCLE_SEG1) \ - PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter-y, pixval); \ if (seg_flags & GP_CIRCLE_SEG3) \ - PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter+y, pixval); \ if (seg_flags & GP_CIRCLE_SEG4) \ - PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter+y, pixval); \ } \ \ /* Enough changes accumulated, go to next line. */ \ error += -2*y + 1; \ if (seg_flags & GP_CIRCLE_SEG2) \ - PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter-y, pixval); \ if (seg_flags & GP_CIRCLE_SEG1) \ - PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter-y, pixval); \ if (seg_flags & GP_CIRCLE_SEG3) \ - PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter+y, pixval); \ if (seg_flags & GP_CIRCLE_SEG4) \ - PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter+y, pixval); \ } \ } diff --git a/libs/gfx/algo/Ellipse.algo.h b/libs/gfx/algo/Ellipse.algo.h index a964e863..f09a14ec 100644 --- a/libs/gfx/algo/Ellipse.algo.h +++ b/libs/gfx/algo/Ellipse.algo.h @@ -66,13 +66,13 @@ /* * This macro defines an ellipse drawing function. * Arguments: - * CONTEXT_T - user-defined type of drawing context (passed to PUTPIXEL) + * PIXMAP_T - user-defined type of drawing pixmap (passed to PUTPIXEL) * PIXVAL_T - user-defined pixel value type (passed to PUTPIXEL) - * PUTPIXEL - a pixel drawing function f(context, x, y, pixval) + * PUTPIXEL - a pixel drawing function f(pixmap, x, y, pixval) * FN_NAME - name of the function to be defined */ -#define DEF_ELLIPSE_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) \ -static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, \ +#define DEF_ELLIPSE_FN(FN_NAME, PIXMAP_T, PIXVAL_T, PUTPIXEL) \ +static void FN_NAME(PIXMAP_T pixmap, int xcenter, int ycenter, \ unsigned int a, unsigned int b, PIXVAL_T pixval) \ { \ /* Precompute quadratic terms. */ \ @@ -83,13 +83,13 @@ static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, \ \ if (a == 0) { \ for (y = -b; y <= (int)b; y++) \ - PUTPIXEL(context, xcenter, ycenter + y, pixval); \ + PUTPIXEL(pixmap, xcenter, ycenter + y, pixval); \ return; \ } \ \ if (b == 0) { \ for (x = -a; x <= (int)a; x++) \ - PUTPIXEL(context, xcenter + x, ycenter, pixval); \ + PUTPIXEL(pixmap, xcenter + x, ycenter, pixval); \ return; \ } \ \ @@ -100,18 +100,18 @@ static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, \ error += 2*x*b2 + b2; \ x++; \ \ - PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); \ - PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); \ - PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); \ - PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter+y, pixval); \ } \ \ /* Calculate error(y-1) from error(y). */ \ error += -2*y*a2 + a2; \ \ - PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); \ - PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); \ - PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); \ - PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter-x+1, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter+x-1, ycenter+y, pixval); \ } \ } diff --git a/libs/gfx/algo/FillRing.algo.h b/libs/gfx/algo/FillRing.algo.h index 0238a633..0673cfd8 100644 --- a/libs/gfx/algo/FillRing.algo.h +++ b/libs/gfx/algo/FillRing.algo.h @@ -30,13 +30,13 @@ /* * This macro defines a filled circle drawing function. * Arguments: - * CONTEXT_T - user-defined type of drawing context (passed to HLINE) + * PIXMAP_T - user-defined type of drawing pixmap (passed to HLINE) * PIXVAL_T - user-defined pixel value type (passed to HLINE) - * HLINE - horizontal line drawing function f(context, x0, x1, y, pixval) + * HLINE - horizontal line drawing function f(pixmap, x0, x1, y, pixval) * FN_NAME - name of the function to be defined */ -#define DEF_FILLRING_FN(FN_NAME, CONTEXT_T, PIXVAL_T, HLINE) \ -static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, \ +#define DEF_FILLRING_FN(FN_NAME, PIXMAP_T, PIXVAL_T, HLINE) \ +static void FN_NAME(PIXMAP_T pixmap, int xcenter, int ycenter, \ unsigned int r1, unsigned int r2, PIXVAL_T pixval) \ { \ int outer_r = (int) GP_MAX(r1, r2); \ @@ -61,13 +61,13 @@ static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, \ } \ inner_error += -2*y + 1; \ \ - HLINE(context, xcenter - outer_x + 1, xcenter - inner_x, ycenter - y, pixval); \ - HLINE(context, xcenter + inner_x, xcenter + outer_x - 1, ycenter - y, pixval); \ - HLINE(context, xcenter - outer_x + 1, xcenter - inner_x, ycenter + y, pixval); \ - HLINE(context, xcenter + inner_x, xcenter + outer_x - 1, ycenter + y, pixval); \ + HLINE(pixmap, xcenter - outer_x + 1, xcenter - inner_x, ycenter - y, pixval); \ + HLINE(pixmap, xcenter + inner_x, xcenter + outer_x - 1, ycenter - y, pixval); \ + HLINE(pixmap, xcenter - outer_x + 1, xcenter - inner_x, ycenter + y, pixval); \ + HLINE(pixmap, xcenter + inner_x, xcenter + outer_x - 1, ycenter + y, pixval); \ } else { \ - HLINE(context, xcenter - outer_x + 1, xcenter + outer_x - 1, ycenter-y, pixval); \ - HLINE(context, xcenter - outer_x + 1, xcenter + outer_x - 1, ycenter+y, pixval); \ + HLINE(pixmap, xcenter - outer_x + 1, xcenter + outer_x - 1, ycenter-y, pixval); \ + HLINE(pixmap, xcenter - outer_x + 1, xcenter + outer_x - 1, ycenter+y, pixval); \ } \ } \ } diff --git a/libs/gfx/algo/FillTriangle.algo.h b/libs/gfx/algo/FillTriangle.algo.h index eef06206..1f7b2ce6 100644 --- a/libs/gfx/algo/FillTriangle.algo.h +++ b/libs/gfx/algo/FillTriangle.algo.h @@ -46,8 +46,8 @@ * determined by comparing Bx against Ax. */ -#define DEF_FILLTRIANGLE_FN(FN_NAME, CONTEXT_T, PIXVAL_T, HLINE, PUTPIXEL) \ -void FN_NAME(CONTEXT_T context, int x0, int y0, int x1, int y1, \ +#define DEF_FILLTRIANGLE_FN(FN_NAME, PIXMAP_T, PIXVAL_T, HLINE, PUTPIXEL) \ +void FN_NAME(PIXMAP_T pixmap, int x0, int y0, int x1, int y1, \ int x2, int y2, PIXVAL_T pixval) \ { \ \ @@ -89,7 +89,7 @@ void FN_NAME(CONTEXT_T context, int x0, int y0, int x1, int y1, \ \ /* Special case: Ay = By = Cy, triangle degenerates to a line. */ \ if (Ay == Cy) { \ - return HLINE(context, \ + return HLINE(pixmap, \ GP_MIN(Ax, GP_MIN(Bx, Cx)), \ GP_MAX(Ax, GP_MAX(Bx, Cx)), \ Ay, pixval); \ @@ -140,7 +140,7 @@ void FN_NAME(CONTEXT_T context, int x0, int y0, int x1, int y1, \ } \ xstart = GP_MIN(ACx, xstart); \ xend = GP_MAX(ACx, xend); \ - HLINE(context, xstart, xend, y, pixval); \ + HLINE(pixmap, xstart, xend, y, pixval); \ } \ \ bottom_part: \ @@ -171,7 +171,7 @@ bottom_part: \ } \ xstart = GP_MIN(xstart, ACx); \ xend = GP_MAX(xend, ACx); \ - HLINE(context, xstart, xend, y, pixval); \ + HLINE(pixmap, xstart, xend, y, pixval); \ } \ \ end: \ diff --git a/libs/gfx/algo/PartialEllipse.algo.h b/libs/gfx/algo/PartialEllipse.algo.h index 58aea309..6bf4385e 100644 --- a/libs/gfx/algo/PartialEllipse.algo.h +++ b/libs/gfx/algo/PartialEllipse.algo.h @@ -30,13 +30,13 @@ /* * This macro defines a partial ellipse drawing function. * Arguments: - * CONTEXT_T - user-defined type of drawing context (passed to PUTPIXEL) + * PIXMAP_T - user-defined type of drawing pixmap (passed to PUTPIXEL) * PIXVAL_T - user-defined pixel value type (passed to PUTPIXEL) - * PUTPIXEL - a pixel drawing function f(context, x, y, pixval) + * PUTPIXEL - a pixel drawing function f(pixmap, x, y, pixval) * FN_NAME - name of the function to be defined */ -#define DEF_PARTIAL_ELLIPSE_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) \ -static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, int a, int b, \ +#define DEF_PARTIAL_ELLIPSE_FN(FN_NAME, PIXMAP_T, PIXVAL_T, PUTPIXEL) \ +static void FN_NAME(PIXMAP_T pixmap, int xcenter, int ycenter, int a, int b, \ int start, int end, PIXVAL_T pixval) \ { \ double startAngle = GP_NormalizeAngle(2*M_PI*(start / 360000.0)); \ @@ -47,10 +47,10 @@ static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, int a, int b, \ double angle = acos(((double) x) / a); \ double y = floor(b*sin(angle)); \ if (GP_AngleInRange(angle, startAngle, endAngle)) { \ - PUTPIXEL(context, xcenter+x, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter+x, ycenter-y, pixval); \ } \ if (GP_AngleInRange(2*M_PI - angle, startAngle, endAngle)) { \ - PUTPIXEL(context, xcenter+x, ycenter+y, pixval); \ + PUTPIXEL(pixmap, xcenter+x, ycenter+y, pixval); \ } \ } \ \ @@ -59,10 +59,10 @@ static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, int a, int b, \ double angle = asin(((double) y) / b); \ double x = floor(a*cos(angle)); \ if (GP_AngleInRange(angle, startAngle, endAngle)) { \ - PUTPIXEL(context, xcenter+x, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter+x, ycenter-y, pixval); \ } \ if (GP_AngleInRange(M_PI - angle, startAngle, endAngle)) { \ - PUTPIXEL(context, xcenter-x, ycenter-y, pixval); \ + PUTPIXEL(pixmap, xcenter-x, ycenter-y, pixval); \ } \ } \ } diff --git a/libs/grabbers/GP_V4L2.c b/libs/grabbers/GP_V4L2.c index baef2639..a81f6885 100644 --- a/libs/grabbers/GP_V4L2.c +++ b/libs/grabbers/GP_V4L2.c @@ -36,7 +36,7 @@ #include -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_Debug.h" @@ -76,7 +76,7 @@ static void v4l2_exit(struct GP_Grabber *self) } close(self->fd); - GP_ContextFree(self->frame); + GP_PixmapFree(self->frame); free(self); } @@ -329,7 +329,7 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device, goto err0; } - new->frame = GP_ContextAlloc(fmt.fmt.pix.width, fmt.fmt.pix.height, GP_PIXEL_RGB888); + new->frame = GP_PixmapAlloc(fmt.fmt.pix.width, fmt.fmt.pix.height, GP_PIXEL_RGB888); if (new->frame == NULL) { err = ENOMEM; @@ -411,7 +411,7 @@ err3: if (priv->bufptr[i] != NULL) munmap(priv->bufptr[i], priv->buf_len[i]); err2: - GP_ContextFree(new->frame); + GP_PixmapFree(new->frame); err1: free(new); err0: diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c index 2112f048..b92a467e 100644 --- a/libs/loaders/GP_BMP.c +++ b/libs/loaders/GP_BMP.c @@ -505,7 +505,7 @@ static uint8_t get_idx(struct bitmap_info_header *header, #include "GP_BMP_RLE.h" static int read_palette(GP_IO *io, struct bitmap_info_header *header, - GP_Context *context, GP_ProgressCallback *callback) + GP_Pixmap *pixmap, GP_ProgressCallback *callback) { uint32_t palette_size = get_palette_size(header); uint32_t row_size = bitmap_row_size(header); @@ -552,11 +552,11 @@ static int read_palette(GP_IO *io, struct bitmap_info_header *header, else ry = GP_ABS(header->h) - 1 - y; - GP_PutPixel_Raw_24BPP(context, x, ry, p); + GP_PutPixel_Raw_24BPP(pixmap, x, ry, p); } if (GP_ProgressCallbackReport(callback, y, - context->h, context->w)) { + pixmap->h, pixmap->w)) { GP_DEBUG(1, "Operation aborted"); err = ECANCELED; goto err; @@ -570,7 +570,7 @@ err: } static int read_bitfields_or_rgb(GP_IO *io, struct bitmap_info_header *header, - GP_Context *context, + GP_Pixmap *pixmap, GP_ProgressCallback *callback) { uint32_t row_size = header->w * (header->bpp / 8); @@ -601,7 +601,7 @@ static int read_bitfields_or_rgb(GP_IO *io, struct bitmap_info_header *header, else ry = GP_ABS(header->h) - 1 - y; - uint8_t *row = GP_PIXEL_ADDR(context, 0, ry); + uint8_t *row = GP_PIXEL_ADDR(pixmap, 0, ry); if (GP_IOFill(io, row, row_size)) { err = errno; @@ -620,7 +620,7 @@ static int read_bitfields_or_rgb(GP_IO *io, struct bitmap_info_header *header, } if (GP_ProgressCallbackReport(callback, y, - context->h, context->w)) { + pixmap->h, pixmap->w)) { GP_DEBUG(1, "Operation aborted"); return ECANCELED; } @@ -641,11 +641,11 @@ static void check_palette_size(struct bitmap_info_header *header) } static int read_bitmap_pixels(GP_IO *io, struct bitmap_info_header *header, - GP_Context *context, GP_ProgressCallback *callback) + GP_Pixmap *pixmap, GP_ProgressCallback *callback) { if (header->compress_type == COMPRESS_RLE8) { check_palette_size(header); - return read_RLE8(io, header, context, callback); + return read_RLE8(io, header, pixmap, callback); } switch (header->bpp) { @@ -655,11 +655,11 @@ static int read_bitmap_pixels(GP_IO *io, struct bitmap_info_header *header, case 4: case 8: check_palette_size(header); - return read_palette(io, header, context, callback); + return read_palette(io, header, pixmap, callback); case 16: case 24: case 32: - return read_bitfields_or_rgb(io, header, context, callback); + return read_bitfields_or_rgb(io, header, pixmap, callback); } return ENOSYS; @@ -684,12 +684,12 @@ int GP_MatchBMP(const void *buf) return !memcmp(buf, "BM", 2); } -int GP_ReadBMPEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, +int GP_ReadBMPEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { struct bitmap_info_header header; GP_PixelType pixel_type; - GP_Context *context; + GP_Pixmap *pixmap; int err; if ((err = read_bitmap_header(io, &header))) @@ -725,37 +725,37 @@ int GP_ReadBMPEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, if (!img) return 0; - context = GP_ContextAlloc(header.w, GP_ABS(header.h), pixel_type); + pixmap = GP_PixmapAlloc(header.w, GP_ABS(header.h), pixel_type); - if (context == NULL) { + if (pixmap == NULL) { err = ENOMEM; goto err1; } - if ((err = read_bitmap_pixels(io, &header, context, callback))) + if ((err = read_bitmap_pixels(io, &header, pixmap, callback))) goto err2; - *img = context; + *img = pixmap; return 0; err2: - GP_ContextFree(context); + GP_PixmapFree(pixmap); err1: errno = err; return 1; } -GP_Context *GP_ReadBMP(GP_IO *io, GP_ProgressCallback *callback) +GP_Pixmap *GP_ReadBMP(GP_IO *io, GP_ProgressCallback *callback) { return GP_LoaderReadImage(&GP_BMP, io, callback); } -GP_Context *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback) +GP_Pixmap *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback) { return GP_LoaderLoadImage(&GP_BMP, src_path, callback); } -int GP_LoadBMPEx(const char *src_path, GP_Context **img, +int GP_LoadBMPEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { return GP_LoaderLoadImageEx(&GP_BMP, src_path, img, storage, callback); @@ -828,7 +828,7 @@ static GP_PixelType out_pixel_types[] = { GP_PIXEL_UNKNOWN, }; -static int bmp_fill_header(const GP_Context *src, struct bitmap_info_header *header) +static int bmp_fill_header(const GP_Pixmap *src, struct bitmap_info_header *header) { GP_PixelType out_pix; @@ -857,7 +857,7 @@ static int bmp_fill_header(const GP_Context *src, struct bitmap_info_header *hea return 0; } -static int bmp_write_data(GP_IO *io, const GP_Context *src, +static int bmp_write_data(GP_IO *io, const GP_Pixmap *src, GP_ProgressCallback *callback) { int y; @@ -899,7 +899,7 @@ static int bmp_write_data(GP_IO *io, const GP_Context *src, return 0; } -int GP_WriteBMP(const GP_Context *src, GP_IO *io, +int GP_WriteBMP(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback) { struct bitmap_info_header header; @@ -922,7 +922,7 @@ err: return 1; } -int GP_SaveBMP(const GP_Context *src, const char *dst_path, +int GP_SaveBMP(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback) { return GP_LoaderSaveImage(&GP_BMP, src, dst_path, callback); diff --git a/libs/loaders/GP_BMP_RLE.h b/libs/loaders/GP_BMP_RLE.h index 6d5625b9..950f3ee2 100644 --- a/libs/loaders/GP_BMP_RLE.h +++ b/libs/loaders/GP_BMP_RLE.h @@ -264,16 +264,16 @@ static int RLE8_next(struct RLE *rle) } static int read_RLE8(GP_IO *io, struct bitmap_info_header *header, - GP_Context *context, GP_ProgressCallback *callback) + GP_Pixmap *pixmap, GP_ProgressCallback *callback) { uint32_t palette_size = get_palette_size(header); DECLARE_RLE(rle, header->w, GP_ABS(header->h), io); int err; - if (context->pixel_type != GP_PIXEL_RGB888) { + if (pixmap->pixel_type != GP_PIXEL_RGB888) { GP_WARN("Corrupted BMP header! " "RLE8 is 24bit (RGB888) palette but header says %s", - GP_PixelTypeName(context->pixel_type)); + GP_PixelTypeName(pixmap->pixel_type)); return EINVAL; } @@ -293,7 +293,7 @@ static int read_RLE8(GP_IO *io, struct bitmap_info_header *header, * TODO: Untouched pixels should be treated as * 1 bit transpanrency (in header3+) */ - GP_Fill(context, palette[0]); + GP_Fill(pixmap, palette[0]); for (;;) { if ((err = RLE8_next(&rle))) @@ -320,12 +320,12 @@ static int read_RLE8(GP_IO *io, struct bitmap_info_header *header, else ry = GP_ABS(header->h) - 1 - rle.y; - GP_PutPixel_Raw_24BPP(context, rle.x, ry, p); + GP_PutPixel_Raw_24BPP(pixmap, rle.x, ry, p); if (cnt++ > header->w) { cnt = 0; if (GP_ProgressCallbackReport(callback, rle.y, - context->h, context->w)) { + pixmap->h, pixmap->w)) { GP_DEBUG(1, "Operation aborted"); err = ECANCELED; goto err; diff --git a/libs/loaders/GP_Container.c b/libs/loaders/GP_Container.c index f2dfcc9b..c1af7ec7 100644 --- a/libs/loaders/GP_Container.c +++ b/libs/loaders/GP_Container.c @@ -38,7 +38,7 @@ int GP_ContainerSeek(GP_Container *self, int offset, return self->ops->Seek(self, offset, whence); } -int GP_ContainerLoadEx(GP_Container *self, GP_Context **img, +int GP_ContainerLoadEx(GP_Container *self, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { if (!self->ops->LoadEx) { diff --git a/libs/loaders/GP_GIF.c b/libs/loaders/GP_GIF.c index 594fc7bc..ca2e7f1d 100644 --- a/libs/loaders/GP_GIF.c +++ b/libs/loaders/GP_GIF.c @@ -235,12 +235,12 @@ static void fill_metadata(GifFileType *gf, GP_DataStorage *storage) GP_DataStorageAddInt(storage, NULL, "Interlace", gf->Image.Interlace); } -int GP_ReadGIFEx(GP_IO *io, GP_Context **img, +int GP_ReadGIFEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { GifFileType *gf; GifRecordType rec_type; - GP_Context *res = NULL; + GP_Pixmap *res = NULL; GP_Pixel bg; int32_t x, y; int err; @@ -312,7 +312,7 @@ int GP_ReadGIFEx(GP_IO *io, GP_Context **img, if (!img) break; - res = GP_ContextAlloc(gf->SWidth, gf->SHeight, GP_PIXEL_RGB888); + res = GP_PixmapAlloc(gf->SWidth, gf->SHeight, GP_PIXEL_RGB888); if (res == NULL) { err = ENOMEM; @@ -373,7 +373,7 @@ int GP_ReadGIFEx(GP_IO *io, GP_Context **img, return 0; err2: - GP_ContextFree(res); + GP_PixmapFree(res); err1: #if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 DGifCloseFile(gf, NULL); @@ -392,7 +392,7 @@ int GP_MatchGIF(const void GP_UNUSED(*buf)) return -1; } -GP_Context *GP_ReadGIFEx(GP_IO GP_UNUSED(*io), +GP_Pixmap *GP_ReadGIFEx(GP_IO GP_UNUSED(*io), GP_ProgressCallback GP_UNUSED(*callback)) { errno = ENOSYS; @@ -401,17 +401,17 @@ GP_Context *GP_ReadGIFEx(GP_IO GP_UNUSED(*io), #endif /* HAVE_GIFLIB */ -GP_Context *GP_ReadGIF(GP_IO *io, GP_ProgressCallback *callback) +GP_Pixmap *GP_ReadGIF(GP_IO *io, GP_ProgressCallback *callback) { return GP_LoaderReadImage(&GP_GIF, io, callback); } -GP_Context *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback) +GP_Pixmap *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback) { return GP_LoaderLoadImage(&GP_GIF, src_path, callback); } -int GP_LoadGIFEx(const char *src_path, GP_Context **img, +int GP_LoadGIFEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { return GP_LoaderLoadImageEx(&GP_GIF, src_path, img, storage, callback); diff --git a/libs/loaders/GP_JP2.c b/libs/loaders/GP_JP2.c index e1694ff2..9f97d96b 100644 --- a/libs/loaders/GP_JP2.c +++ b/libs/loaders/GP_JP2.c @@ -119,7 +119,7 @@ static void fill_metadata(opj_image_t *img, GP_DataStorage *storage) } } -int GP_ReadJP2Ex(GP_IO *io, GP_Context **rimg, GP_DataStorage *storage, +int GP_ReadJP2Ex(GP_IO *io, GP_Pixmap **rimg, GP_DataStorage *storage, GP_ProgressCallback *callback) { opj_dparameters_t params; @@ -128,7 +128,7 @@ int GP_ReadJP2Ex(GP_IO *io, GP_Context **rimg, GP_DataStorage *storage, opj_image_t *img; GP_PixelType pixel_type; - GP_Context *res = NULL; + GP_Pixmap *res = NULL; unsigned int i, x, y; int err = 0, ret = 1; @@ -229,7 +229,7 @@ int GP_ReadJP2Ex(GP_IO *io, GP_Context **rimg, GP_DataStorage *storage, goto err3; } - res = GP_ContextAlloc(img->comps[0].w, img->comps[0].h, pixel_type); + res = GP_PixmapAlloc(img->comps[0].w, img->comps[0].h, pixel_type); if (!res) { GP_DEBUG(1, "Malloc failed :("); @@ -266,7 +266,7 @@ err0: #else -int GP_ReadJP2Ex(GP_IO GP_UNUSED(*io), GP_Context GP_UNUSED(**img), +int GP_ReadJP2Ex(GP_IO GP_UNUSED(*io), GP_Pixmap GP_UNUSED(**img), GP_DataStorage GP_UNUSED(*storage), GP_ProgressCallback GP_UNUSED(*callback)) { @@ -276,17 +276,17 @@ int GP_ReadJP2Ex(GP_IO GP_UNUSED(*io), GP_Context GP_UNUSED(**img), #endif /* HAVE_OPENJPEG */ -GP_Context *GP_LoadJP2(const char *src_path, GP_ProgressCallback *callback) +GP_Pixmap *GP_LoadJP2(const char *src_path, GP_ProgressCallback *callback) { return GP_LoaderLoadImage(&GP_JP2, src_path, callback); } -GP_Context *GP_ReadJP2(GP_IO *io, GP_ProgressCallback *callback) +GP_Pixmap *GP_ReadJP2(GP_IO *io, GP_ProgressCallback *callback) { return GP_LoaderReadImage(&GP_JP2, io, callback); } -int GP_LoadJP2Ex(const char *src_path, GP_Context **img, +int GP_LoadJP2Ex(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { return GP_LoaderLoadImageEx(&GP_JP2, src_path, img, storage, callback); diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c index 9ac46300..9cd7178c 100644 --- a/libs/loaders/GP_JPG.c +++ b/libs/loaders/GP_JPG.c @@ -89,7 +89,7 @@ static const char *get_colorspace(J_COLOR_SPACE color_space) }; } -static int load(struct jpeg_decompress_struct *cinfo, GP_Context *ret, +static int load(struct jpeg_decompress_struct *cinfo, GP_Pixmap *ret, GP_ProgressCallback *callback) { while (cinfo->output_scanline < cinfo->output_height) { @@ -107,7 +107,7 @@ static int load(struct jpeg_decompress_struct *cinfo, GP_Context *ret, return 0; } -static int load_cmyk(struct jpeg_decompress_struct *cinfo, GP_Context *ret, +static int load_cmyk(struct jpeg_decompress_struct *cinfo, GP_Pixmap *ret, GP_ProgressCallback *callback) { while (cinfo->output_scanline < cinfo->output_height) { @@ -256,13 +256,13 @@ static void save_jpg_markers(struct jpeg_decompress_struct *cinfo) jpeg_save_markers(cinfo, JPEG_APP0 + 1, 0xffff); } -int GP_ReadJPGEx(GP_IO *io, GP_Context **img, +int GP_ReadJPGEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { struct jpeg_decompress_struct cinfo; struct my_source_mgr src; struct my_jpg_err my_err; - GP_Context *ret = NULL; + GP_Pixmap *ret = NULL; uint8_t buf[1024]; int err; @@ -318,7 +318,7 @@ int GP_ReadJPGEx(GP_IO *io, GP_Context **img, goto err1; } - ret = GP_ContextAlloc(cinfo.image_width, cinfo.image_height, + ret = GP_PixmapAlloc(cinfo.image_width, cinfo.image_height, pixel_type); if (ret == NULL) { @@ -355,7 +355,7 @@ exit: return 0; err2: - GP_ContextFree(ret); + GP_PixmapFree(ret); err1: jpeg_destroy_decompress(&cinfo); errno = err; @@ -363,7 +363,7 @@ err1: } static int save_convert(struct jpeg_compress_struct *cinfo, - const GP_Context *src, + const GP_Pixmap *src, GP_PixelType out_pix, GP_ProgressCallback *callback) { @@ -391,7 +391,7 @@ static int save_convert(struct jpeg_compress_struct *cinfo, } static int save(struct jpeg_compress_struct *cinfo, - const GP_Context *src, + const GP_Pixmap *src, GP_ProgressCallback *callback) { while (cinfo->next_scanline < cinfo->image_height) { @@ -469,7 +469,7 @@ static GP_PixelType out_pixel_types[] = { GP_PIXEL_UNKNOWN }; -int GP_WriteJPG(const GP_Context *src, GP_IO *io, +int GP_WriteJPG(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback) { struct jpeg_compress_struct cinfo; @@ -544,7 +544,7 @@ int GP_WriteJPG(const GP_Context *src, GP_IO *io, #else -int GP_ReadJPGEx(GP_IO GP_UNUSED(*io), GP_Context GP_UNUSED(**img), +int GP_ReadJPGEx(GP_IO GP_UNUSED(*io), GP_Pixmap GP_UNUSED(**img), GP_DataStorage GP_UNUSED(*storage), GP_ProgressCallback GP_UNUSED(*callback)) { @@ -552,7 +552,7 @@ int GP_ReadJPGEx(GP_IO GP_UNUSED(*io), GP_Context GP_UNUSED(**img), return 1; } -int GP_WriteJPG(const GP_Context GP_UNUSED(*src), GP_IO GP_UNUSED(*io), +int GP_WriteJPG(const GP_Pixmap GP_UNUSED(*src), GP_IO GP_UNUSED(*io), GP_ProgressCallback GP_UNUSED(*callback)) { errno = ENOSYS; @@ -561,23 +561,23 @@ int GP_WriteJPG(const GP_Context GP_UNUSED(*src), GP_IO GP_UNUSED(*io), #endif /* HAVE_JPEG */ -GP_Context *GP_ReadJPG(GP_IO *io, GP_ProgressCallback *callback) +GP_Pixmap *GP_ReadJPG(GP_IO *io, GP_ProgressCallback *callback) { return GP_LoaderReadImage(&GP_JPG, io, callback); } -GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback) +GP_Pixmap *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback) { return GP_LoaderLoadImage(&GP_JPG, src_path, callback); } -int GP_LoadJPGEx(const char *src_path, GP_Context **img, +int GP_LoadJPGEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { return GP_LoaderLoadImageEx(&GP_JPG, src_path, img, storage, callback); } -int GP_SaveJPG(const GP_Context *src, const char *dst_path, +int GP_SaveJPG(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback) { return GP_LoaderSaveImage(&GP_JPG, src, dst_path, callback); diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c index 84461f99..0d6c449b 100644 --- a/libs/loaders/GP_Loader.c +++ b/libs/loaders/GP_Loader.c @@ -229,16 +229,16 @@ err0: return NULL; } -GP_Context *GP_ReadImage(GP_IO *io, GP_ProgressCallback *callback) +GP_Pixmap *GP_ReadImage(GP_IO *io, GP_ProgressCallback *callback) { - GP_Context *ret = NULL; + GP_Pixmap *ret = NULL; GP_ReadImageEx(io, &ret, NULL, callback); return ret; } -int GP_ReadImageEx(GP_IO *io, GP_Context **img, GP_DataStorage *meta_data, +int GP_ReadImageEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *meta_data, GP_ProgressCallback *callback) { char buf[32]; @@ -286,7 +286,7 @@ int GP_ReadImageEx(GP_IO *io, GP_Context **img, GP_DataStorage *meta_data, } int GP_LoaderLoadImageEx(const GP_Loader *self, const char *src_path, - GP_Context **img, GP_DataStorage *storage, + GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { GP_IO *io; @@ -313,20 +313,20 @@ int GP_LoaderLoadImageEx(const GP_Loader *self, const char *src_path, } -GP_Context *GP_LoaderLoadImage(const GP_Loader *self, const char *src_path, +GP_Pixmap *GP_LoaderLoadImage(const GP_Loader *self, const char *src_path, GP_ProgressCallback *callback) { - GP_Context *ret = NULL; + GP_Pixmap *ret = NULL; GP_LoaderLoadImageEx(self, src_path, &ret, NULL, callback); return ret; } -GP_Context *GP_LoaderReadImage(const GP_Loader *self, GP_IO *io, +GP_Pixmap *GP_LoaderReadImage(const GP_Loader *self, GP_IO *io, GP_ProgressCallback *callback) { - GP_Context *ret = NULL; + GP_Pixmap *ret = NULL; GP_LoaderReadImageEx(self, io, &ret, NULL, callback); @@ -334,7 +334,7 @@ GP_Context *GP_LoaderReadImage(const GP_Loader *self, GP_IO *io, } int GP_LoaderReadImageEx(const GP_Loader *self, GP_IO *io, - GP_Context **img, GP_DataStorage *data, + GP_Pixmap **img, GP_DataStorage *data, GP_ProgressCallback *callback) { GP_DEBUG(1, "Reading image (I/O %p)", io); @@ -347,9 +347,9 @@ int GP_LoaderReadImageEx(const GP_Loader *self, GP_IO *io, return self->Read(io, img, data, callback); } -GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback) +GP_Pixmap *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback) { - GP_Context *ret = NULL; + GP_Pixmap *ret = NULL; GP_LoadImageEx(src_path, &ret, NULL, callback); @@ -357,7 +357,7 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback) } int GP_LoadImageEx(const char *src_path, - GP_Context **img, GP_DataStorage *meta_data, + GP_Pixmap **img, GP_DataStorage *meta_data, GP_ProgressCallback *callback) { int err; @@ -460,7 +460,7 @@ out: return 1; } -int GP_LoaderSaveImage(const GP_Loader *self, const GP_Context *src, +int GP_LoaderSaveImage(const GP_Loader *self, const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback) { GP_IO *io; @@ -491,7 +491,7 @@ int GP_LoaderSaveImage(const GP_Loader *self, const GP_Context *src, return 0; } -int GP_SaveImage(const GP_Context *src, const char *dst_path, +int GP_SaveImage(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback) { const GP_Loader *l = GP_LoaderByFilename(dst_path); diff --git a/libs/loaders/GP_PCX.c b/libs/loaders/GP_PCX.c index 2304bbd0..f68be5a6 100644 --- a/libs/loaders/GP_PCX.c +++ b/libs/loaders/GP_PCX.c @@ -218,7 +218,7 @@ struct pcx_header { #include "core/GP_BitSwap.h" static int read_g1(GP_IO *io, struct pcx_header *header, - GP_Context *res, GP_ProgressCallback *callback) + GP_Pixmap *res, GP_ProgressCallback *callback) { uint32_t y; int padd = (int)header->bytes_per_line - (int)res->bytes_per_row; @@ -252,7 +252,7 @@ static int read_g1(GP_IO *io, struct pcx_header *header, } static int read_rgb888(GP_IO *io, struct pcx_header *header, - GP_Context *res, GP_ProgressCallback *callback) + GP_Pixmap *res, GP_ProgressCallback *callback) { uint32_t x, y; unsigned int bpr = header->bytes_per_line; @@ -286,7 +286,7 @@ static int read_rgb888(GP_IO *io, struct pcx_header *header, } static int read_16_palette(GP_IO *io, struct pcx_header *header, - GP_Context *res, GP_ProgressCallback *callback) + GP_Pixmap *res, GP_ProgressCallback *callback) { uint32_t x, y; unsigned int i; @@ -346,7 +346,7 @@ static int read_16_palette(GP_IO *io, struct pcx_header *header, #define PALETTE_SIZE (3 * 256 + 1) static int read_256_palette(GP_IO *io, struct pcx_header *header, - GP_Context *res, GP_ProgressCallback *callback) + GP_Pixmap *res, GP_ProgressCallback *callback) { uint32_t x, y; unsigned int i; @@ -425,7 +425,7 @@ static GP_PixelType match_pixel_type(struct pcx_header *header) } static int read_image(GP_IO *io, struct pcx_header *header, - GP_Context *res, GP_ProgressCallback *callback) + GP_Pixmap *res, GP_ProgressCallback *callback) { switch (header->nplanes) { case 1: @@ -461,10 +461,10 @@ static void fill_metadata(struct pcx_header *header, GP_DataStorage *storage) GP_DataStorageAddInt(storage, NULL, "Samples per Pixel", header->nplanes); } -int GP_ReadPCXEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, +int GP_ReadPCXEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { - GP_Context *res = NULL; + GP_Pixmap *res = NULL; GP_PixelType pixel_type; struct pcx_header header; unsigned int w, h; @@ -551,7 +551,7 @@ int GP_ReadPCXEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, w = max_w; } - res = GP_ContextAlloc(w, h, pixel_type); + res = GP_PixmapAlloc(w, h, pixel_type); if (!res) { GP_DEBUG(1, "Malloc failed :("); @@ -567,23 +567,23 @@ int GP_ReadPCXEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, *img = res; return 0; err1: - GP_ContextFree(res); + GP_PixmapFree(res); err0: errno = err; return 1; } -GP_Context *GP_LoadPCX(const char *src_path, GP_ProgressCallback *callback) +GP_Pixmap *GP_LoadPCX(const char *src_path, GP_ProgressCallback *callback) { return GP_LoaderLoadImage(&GP_PCX, src_path, callback); } -GP_Context *GP_ReadPCX(GP_IO *io, GP_ProgressCallback *callback) +GP_Pixmap *GP_ReadPCX(GP_IO *io, GP_ProgressCallback *callback) { return GP_LoaderReadImage(&GP_PCX, io, callback); } -int GP_LoadPCXEx(const char *src_path, GP_Context **img, +int GP_LoadPCXEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { return GP_LoaderLoadImageEx(&GP_PCX, src_path, img, storage, callback); diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c index ebf81932..ce8f6500 100644 --- a/libs/loaders/GP_PNG.c +++ b/libs/loaders/GP_PNG.c @@ -153,7 +153,7 @@ static void load_meta_data(png_structp png, png_infop png_info, } } -int GP_ReadPNGEx(GP_IO *io, GP_Context **img, +int GP_ReadPNGEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { png_structp png; @@ -161,7 +161,7 @@ int GP_ReadPNGEx(GP_IO *io, GP_Context **img, png_uint_32 w, h; int depth, color_type, interlace_type; GP_PixelType pixel_type = GP_PIXEL_UNKNOWN; - GP_Context *res = NULL; + GP_Pixmap *res = NULL; int err, passes = 1; double gamma; @@ -299,7 +299,7 @@ int GP_ReadPNGEx(GP_IO *io, GP_Context **img, goto err2; } - res = GP_ContextAlloc(w, h, pixel_type); + res = GP_PixmapAlloc(w, h, pixel_type); if (res == NULL) { err = ENOMEM; @@ -351,7 +351,7 @@ exit: return 0; err3: - GP_ContextFree(res); + GP_PixmapFree(res); err2: png_destroy_read_struct(&png, png_info ? &png_info : NULL, NULL); err1: @@ -376,7 +376,7 @@ static GP_PixelType save_ptypes[] = { /* * Maps gfxprim Pixel Type to the PNG format */ -static int prepare_png_header(const GP_Context *src, png_structp png, +static int prepare_png_header(const GP_Pixmap *src, png_structp png, png_infop png_info, int *bit_endian_flag) { int bit_depth, color_type; @@ -463,7 +463,7 @@ static int prepare_png_header(const GP_Context *src, png_structp png, return 0; } -static int write_png_data(const GP_Context *src, png_structp png, +static int write_png_data(const GP_Pixmap *src, png_structp png, GP_ProgressCallback *callback, int bit_endian_flag) { /* Look if we need to swap data when writing */ @@ -508,7 +508,7 @@ static void flush_data(png_structp png_ptr) (void)png_ptr; } -int GP_WritePNG(const GP_Context *src, GP_IO *io, +int GP_WritePNG(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback) { png_structp png; @@ -576,7 +576,7 @@ int GP_MatchPNG(const void GP_UNUSED(*buf)) return 1; } -int GP_ReadPNGEx(GP_IO GP_UNUSED(*io), GP_Context GP_UNUSED(**img), +int GP_ReadPNGEx(GP_IO GP_UNUSED(*io), GP_Pixmap GP_UNUSED(**img), GP_DataStorage GP_UNUSED(*storage), GP_ProgressCallback GP_UNUSED(*callback)) { @@ -584,7 +584,7 @@ int GP_ReadPNGEx(GP_IO GP_UNUSED(*io), GP_Context GP_UNUSED(**img), return 1; } -int GP_WritePNG(const GP_Context *src, GP_IO GP_UNUSED(*io), +int GP_WritePNG(const GP_Pixmap *src, GP_IO GP_UNUSED(*io), GP_ProgressCallback *callback) { errno = ENOSYS; @@ -593,23 +593,23 @@ int GP_WritePNG(const GP_Context *src, GP_IO GP_UNUSED(*io), #endif /* HAVE_LIBPNG */ -GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback) +GP_Pixmap *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback) { return GP_LoaderLoadImage(&GP_PNG, src_path, callback); } -int GP_SavePNG(const GP_Context *src, const char *dst_path, +int GP_SavePNG(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback) { return GP_LoaderSaveImage(&GP_PNG, src, dst_path, callback); } -GP_Context *GP_ReadPNG(GP_IO *io, GP_ProgressCallback *callback) +GP_Pixmap *GP_ReadPNG(GP_IO *io, GP_ProgressCallback *callback) { return GP_LoaderReadImage(&GP_PNG, io, callback); } -int GP_LoadPNGEx(const char *src_path, GP_Context **img, +int GP_LoadPNGEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { return GP_LoaderLoadImageEx(&GP_PNG, src_path, img, storage, callback); diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c index a9003da1..49fe18d5 100644 --- a/libs/loaders/GP_PNM.c +++ b/libs/loaders/GP_PNM.c @@ -55,7 +55,7 @@ #include #include "core/GP_Debug.h" -#include "core/GP_Context.h" +#include "core/GP_Pixmap.h" #include "core/GP_GetPutPixel.h" #include "loaders/GP_LineConvert.h" @@ -364,22 +364,22 @@ static inline int write_ascii_byte(GP_IO *io, uint8_t byte) /* * The PBM ASCII has the values inverted */ -static int load_ascii_g1_inv(struct buf *buf, GP_Context *ctx, +static int load_ascii_g1_inv(struct buf *buf, GP_Pixmap *pixmap, GP_ProgressCallback *cb) { uint32_t x, y; int val, err; - for (y = 0; y < ctx->h; y++) { - for (x = 0; x < ctx->w; x++) { + for (y = 0; y < pixmap->h; y++) { + for (x = 0; x < pixmap->w; x++) { if ((err = get_ascii_int(buf, &val))) return err; - GP_PutPixel_Raw_1BPP_LE(ctx, x, y, !val); + GP_PutPixel_Raw_1BPP_LE(pixmap, x, y, !val); } - if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) { + if (GP_ProgressCallbackReport(cb, y, pixmap->h, pixmap->w)) { GP_DEBUG(1, "Operation aborted"); return ECANCELED; } @@ -392,24 +392,24 @@ static int load_ascii_g1_inv(struct buf *buf, GP_Context *ctx, //TODO: This is temporary till blit works with bitendian #include "core/GP_BitSwap.h" -static int load_raw_g1_inv(struct buf *buf, GP_Context *ctx, +static int load_raw_g1_inv(struct buf *buf, GP_Pixmap *pixmap, GP_ProgressCallback *cb) { uint32_t x, y; uint8_t *addr; int val; - for (y = 0; y < ctx->h; y++) { - for (x = 0; x < ctx->w; x+=8) { + for (y = 0; y < pixmap->h; y++) { + for (x = 0; x < pixmap->w; x+=8) { if ((val = getb(buf)) == EOF) return EIO; - addr = GP_PIXEL_ADDR(ctx, x, y); + addr = GP_PIXEL_ADDR(pixmap, x, y); *addr = ~GP_BIT_SWAP_B1(val); } - if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) { + if (GP_ProgressCallbackReport(cb, y, pixmap->h, pixmap->w)) { GP_DEBUG(1, "Operation aborted"); return ECANCELED; } @@ -419,14 +419,14 @@ static int load_raw_g1_inv(struct buf *buf, GP_Context *ctx, return 0; } -static int load_ascii_g1(struct buf *buf, GP_Context *ctx, +static int load_ascii_g1(struct buf *buf, GP_Pixmap *pixmap, GP_ProgressCallback *cb) { uint32_t x, y; int val, err; - for (y = 0; y < ctx->h; y++) { - for (x = 0; x < ctx->w; x++) { + for (y = 0; y < pixmap->h; y++) { + for (x = 0; x < pixmap->w; x++) { if ((err = get_ascii_int(buf, &val))) return err; @@ -436,10 +436,10 @@ static int load_ascii_g1(struct buf *buf, GP_Context *ctx, val = 1; } - GP_PutPixel_Raw_1BPP_LE(ctx, x, y, val); + GP_PutPixel_Raw_1BPP_LE(pixmap, x, y, val); } - if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) { + if (GP_ProgressCallbackReport(cb, y, pixmap->h, pixmap->w)) { GP_DEBUG(1, "Operation aborted"); return ECANCELED; } @@ -449,14 +449,14 @@ static int load_ascii_g1(struct buf *buf, GP_Context *ctx, return 0; } -static int load_ascii_g2(struct buf *buf, GP_Context *ctx, +static int load_ascii_g2(struct buf *buf, GP_Pixmap *pixmap, GP_ProgressCallback *cb) { uint32_t x, y; int val, err; - for (y = 0; y < ctx->h; y++) { - for (x = 0; x < ctx->w; x++) { + for (y = 0; y < pixmap->h; y++) { + for (x = 0; x < pixmap->w; x++) { if ((err = get_ascii_int(buf, &val))) return err; @@ -466,10 +466,10 @@ static int load_ascii_g2(struct buf *buf, GP_Context *ctx, val = 3; } - GP_PutPixel_Raw_2BPP_LE(ctx, x, y, val); + GP_PutPixel_Raw_2BPP_LE(pixmap, x, y, val); } - if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) { + if (GP_ProgressCallbackReport(cb, y, pixmap->h, pixmap->w)) { GP_DEBUG(1, "Operation aborted"); return ECANCELED; } @@ -479,14 +479,14 @@ static int load_ascii_g2(struct buf *buf, GP_Context *ctx, return 0; } -static int load_ascii_g4(struct buf *buf, GP_Context *ctx, +static int load_ascii_g4(struct buf *buf, GP_Pixmap *pixmap, GP_ProgressCallback *cb) { uint32_t x, y; int val, err; - for (y = 0; y < ctx->h; y++) { - for (x = 0; x < ctx->w; x++) { + for (y = 0; y < pixmap->h; y++) { + for (x = 0; x < pixmap->w; x++) { if ((err = get_ascii_int(buf, &val))) return err; @@ -496,10 +496,10 @@ static int load_ascii_g4(struct buf *buf, GP_Context *ctx, val = 15; } - GP_PutPixel_Raw_4BPP_LE(ctx, x, y, val); + GP_PutPixel_Raw_4BPP_LE(pixmap, x, y, val); } - if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) { + if (GP_ProgressCallbackReport(cb, y, pixmap->h, pixmap->w)) { GP_DEBUG(1, "Operation aborted"); return ECANCELED; } @@ -509,14 +509,14 @@ static int load_ascii_g4(struct buf *buf, GP_Context *ctx, return 0; } -static int load_ascii_g8(struct buf *buf, GP_Context *ctx, +static int load_ascii_g8(struct buf *buf, GP_Pixmap *pixmap, GP_ProgressCallback *cb) { uint32_t x, y; int val, err; - for (y = 0; y < ctx->h; y++) { - for (x = 0; x < ctx->w; x++) { + for (y = 0; y < pixmap->h; y++) { + for (x = 0; x < pixmap->w; x++) { if ((err = get_ascii_int(buf, &val))) return err; @@ -526,10 +526,10 @@ static int load_ascii_g8(struct buf *buf, GP_Context *ctx, val = 255; } - GP_PutPixel_Raw_8BPP(ctx, x, y, val); + GP_PutPixel_Raw_8BPP(pixmap, x, y, val); } - if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) { + if (GP_ProgressCallbackReport(cb, y, pixmap->h, pixmap->w)) { GP_DEBUG(1, "Operation aborted"); return ECANCELED; } @@ -539,18 +539,18 @@ static int load_ascii_g8(struct buf *buf, GP_Context *ctx, return 0; } -static int load_bin_g8(struct buf *buf, GP_Context *ctx, +static int load_bin_g8(struct buf *buf, GP_Pixmap *pixmap, GP_ProgressCallback *cb) { uint32_t y; - for (y = 0; y < ctx->h; y++) { - uint8_t *addr = GP_PIXEL_ADDR(ctx, 0, y); + for (y = 0; y < pixmap->h; y++) { + uint8_t *addr = GP_PIXEL_ADDR(pixmap, 0, y); - if (fillb(buf, addr, ctx->w)) + if (fillb(buf, addr, pixmap->w)) return errno; - if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) { + if (GP_ProgressCallbackReport(cb, y, pixmap->h, pixmap->w)) { GP_DEBUG(1, "Operation aborted"); return ECANCELED; } @@ -560,14 +560,14 @@ static int load_bin_g8(struct buf *buf, GP_Context *ctx, return 0; } -static int load_ascii_rgb888(struct buf *buf, GP_Context *ctx, +static int load_ascii_rgb888(struct buf *buf, GP_Pixmap *pixmap, GP_ProgressCallback *cb) { uint32_t x, y; int r, g, b, err; - for (y = 0; y < ctx->h; y++) { - for (x = 0; x < ctx->w; x++) { + for (y = 0; y < pixmap->h; y++) { + for (x = 0; x < pixmap->w; x++) { if ((err = get_ascii_int(buf, &r))) return err; @@ -593,11 +593,11 @@ static int load_ascii_rgb888(struct buf *buf, GP_Context *ctx, b = 255; } - GP_PutPixel_Raw_24BPP(ctx, x, y, + GP_PutPixel_Raw_24BPP(pixmap, x, y, GP_Pixel_CREATE_RGB888(r, g, b)); } - if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) { + if (GP_ProgressCallbackReport(cb, y, pixmap->h, pixmap->w)) { GP_DEBUG(1, "Operation aborted"); return ECANCELED; } @@ -607,21 +607,21 @@ static int load_ascii_rgb888(struct buf *buf, GP_Context *ctx, return 0; } -static int load_bin_rgb888(struct buf *buf, GP_Context *ctx, +static int load_bin_rgb888(struct buf *buf, GP_Pixmap *pixmap, GP_ProgressCallback *cb) { uint32_t y, x; - for (y = 0; y < ctx->h; y++) { - uint8_t *addr = GP_PIXEL_ADDR(ctx, 0, y); + for (y = 0; y < pixmap->h; y++) { + uint8_t *addr = GP_PIXEL_ADDR(pixmap, 0, y); - if (fillb(buf, addr, ctx->w * 3)) + if (fillb(buf, addr, pixmap->w * 3)) return errno; - for (x = 0; x < ctx->w; x++) + for (x = 0; x < pixmap->w; x++) GP_SWAP(addr[3*x], addr[3*x + 2]); - if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) { + if (GP_ProgressCallbackReport(cb, y, pixmap->h, pixmap->w)) { GP_DEBUG(1, "Operation aborted"); return ECANCELED; } @@ -631,15 +631,15 @@ static int load_bin_rgb888(struct buf *buf, GP_Context *ctx, return 0; } -static int save_ascii(GP_IO *io, const GP_Context *ctx, +static int save_ascii(GP_IO *io, const GP_Pixmap *pixmap, GP_ProgressCallback *cb, int inv) { uint32_t x, y; int err; - for (y = 0; y < ctx->h; y++) { - for (x = 0; x < ctx->w; x++) { - int val = GP_GetPixel_Raw(ctx, x, y); + for (y = 0; y < pixmap->h; y++) { + for (x = 0; x < pixmap->w; x++) { + int val = GP_GetPixel_Raw(pixmap, x, y); if (inv) val = !val; @@ -651,7 +651,7 @@ static int save_ascii(GP_IO *io, const GP_Context *ctx, } } - if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) { + if (GP_ProgressCallbackReport(cb, y, pixmap->h, pixmap->w)) { GP_DEBUG(1, "Operation aborted"); return ECANCELED; } @@ -665,9 +665,9 @@ static int save_ascii(GP_IO *io, const GP_Context *ctx, } static int read_bitmap(struct buf *buf, struct pnm_header *header, - GP_Context **img, GP_ProgressCallback *callback) + GP_Pixmap **img, GP_ProgressCallback *callback) { - GP_Context *ret; + GP_Pixmap *ret; int err; if (!is_bitmap(header->magic)) { @@ -676,7 +676,7 @@ static int read_bitmap(struct buf *buf, struct pnm_header *header, goto err0; } - ret = GP_ContextAlloc(header->w, header->h, GP_PIXEL_G1); + ret = GP_PixmapAlloc(header->w, header->h, GP_PIXEL_G1); if (ret == NULL) { err = ENOMEM; @@ -694,7 +694,7 @@ static int read_bitmap(struct buf *buf, struct pnm_header *header, *img = ret; return 0; err1: - GP_ContextFree(ret); + GP_PixmapFree(ret); err0: errno = err; return 1; @@ -711,7 +711,7 @@ static void fill_meta_data(struct pnm_header *header, GP_DataStorage *storage) GP_DataStorageAddString(storage, NULL, "Format", pnm_magic_name(header->magic)); } -int GP_ReadPBMEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, +int GP_ReadPBMEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { struct pnm_header header; @@ -737,7 +737,7 @@ static GP_PixelType pbm_save_pixels[] = { GP_PIXEL_UNKNOWN, }; -int GP_WritePBM(const GP_Context *src, GP_IO *io, +int GP_WritePBM(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback) { GP_IO *bio; @@ -789,7 +789,7 @@ static GP_Pixel depth_to_pixel(int depth) } static int load_ascii_graymap(struct buf *buf, struct pnm_header *header, - GP_Context *ret, GP_ProgressCallback *callback) + GP_Pixmap *ret, GP_ProgressCallback *callback) { int err = ENOSYS; @@ -812,7 +812,7 @@ static int load_ascii_graymap(struct buf *buf, struct pnm_header *header, } static int load_bin_graymap(struct buf *buf, struct pnm_header *header, - GP_Context *ret, GP_ProgressCallback *callback) + GP_Pixmap *ret, GP_ProgressCallback *callback) { int err = ENOSYS; @@ -826,9 +826,9 @@ static int load_bin_graymap(struct buf *buf, struct pnm_header *header, } static int read_graymap(struct buf *buf, struct pnm_header *header, - GP_Context **img, GP_ProgressCallback *callback) + GP_Pixmap **img, GP_ProgressCallback *callback) { - GP_Context *ret; + GP_Pixmap *ret; GP_PixelType pixel_type; int err; @@ -844,7 +844,7 @@ static int read_graymap(struct buf *buf, struct pnm_header *header, goto err0; } - ret = GP_ContextAlloc(header->w, header->h, pixel_type); + ret = GP_PixmapAlloc(header->w, header->h, pixel_type); if (ret == NULL) { err = ENOMEM; @@ -862,13 +862,13 @@ static int read_graymap(struct buf *buf, struct pnm_header *header, *img = ret; return 0; err1: - GP_ContextFree(ret); + GP_PixmapFree(ret); err0: errno = err; return 1; } -int GP_ReadPGMEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, +int GP_ReadPGMEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { struct pnm_header header; @@ -913,7 +913,7 @@ static GP_PixelType pgm_save_pixels[] = { GP_PIXEL_UNKNOWN, }; -int GP_WritePGM(const GP_Context *src, GP_IO *io, +int GP_WritePGM(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback) { int err, depth; @@ -949,9 +949,9 @@ err: } static int read_pixmap(struct buf *buf, struct pnm_header *header, - GP_Context **img, GP_ProgressCallback *callback) + GP_Pixmap **img, GP_ProgressCallback *callback) { - GP_Context *ret; + GP_Pixmap *ret; int err = 0; if (!is_pixmap(header->magic)) { @@ -966,7 +966,7 @@ static int read_pixmap(struct buf *buf, struct pnm_header *header, goto err0; } - ret = GP_ContextAlloc(header->w, header->h, GP_PIXEL_RGB888); + ret = GP_PixmapAlloc(header->w, header->h, GP_PIXEL_RGB888); if (ret == NULL) { err = ENOMEM; @@ -988,13 +988,13 @@ static int read_pixmap(struct buf *buf, struct pnm_header *header, *img = ret; return 0; err1: - GP_ContextFree(ret); + GP_PixmapFree(ret); err0: errno = err; return 1; } -int GP_ReadPPMEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, +int GP_ReadPPMEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { struct pnm_header header; @@ -1015,7 +1015,7 @@ int GP_ReadPPMEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, return read_pixmap(&buf, &header, img, callback); } -static int write_binary_ppm(FILE *f, GP_Context *src) +static int write_binary_ppm(FILE *f, GP_Pixmap *src) { uint32_t x, y; @@ -1034,23 +1034,23 @@ static int write_binary_ppm(FILE *f, GP_Context *src) return 0; } -static int save_ascii_rgb888(GP_IO *io, const GP_Context *ctx, +static int save_ascii_rgb888(GP_IO *io, const GP_Pixmap *pixmap, GP_LineConvert Convert, GP_ProgressCallback *cb) { uint32_t x, y; int ret = 0; - uint8_t buf[3 * ctx->w], *addr; + uint8_t buf[3 * pixmap->w], *addr; - for (y = 0; y < ctx->h; y++) { + for (y = 0; y < pixmap->h; y++) { - addr = GP_PIXEL_ADDR(ctx, 0, y); + addr = GP_PIXEL_ADDR(pixmap, 0, y); if (Convert) { - Convert(addr, buf, ctx->w); + Convert(addr, buf, pixmap->w); addr = buf; } - for (x = 0; x < ctx->w; x++) { + for (x = 0; x < pixmap->w; x++) { ret |= write_ascii_byte(io, addr[2]); ret |= write_ascii_byte(io, addr[1]); ret |= write_ascii_byte(io, addr[0]); @@ -1061,7 +1061,7 @@ static int save_ascii_rgb888(GP_IO *io, const GP_Context *ctx, addr+=3; } - if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) { + if (GP_ProgressCallbackReport(cb, y, pixmap->h, pixmap->w)) { GP_DEBUG(1, "Operation aborted"); return ECANCELED; } @@ -1079,7 +1079,7 @@ static GP_PixelType ppm_save_pixels[] = { GP_PIXEL_UNKNOWN, }; -int GP_WritePPM(const GP_Context *src, GP_IO *io, +int GP_WritePPM(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback) { GP_Pixel out_pix; @@ -1120,7 +1120,7 @@ err: return 1; } -int GP_ReadPNMEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, +int GP_ReadPNMEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { struct pnm_header header; @@ -1159,7 +1159,7 @@ static GP_PixelType pnm_save_pixels[] = { GP_PIXEL_UNKNOWN, }; -int GP_WritePNM(const GP_Context *src, GP_IO *io, +int GP_WritePNM(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback) { switch (src->pixel_type) { @@ -1179,65 +1179,65 @@ int GP_WritePNM(const GP_Context *src, GP_IO *io, } } -GP_Context *GP_ReadPBM(GP_IO *io, GP_ProgressCallback *callback) +GP_Pixmap *GP_ReadPBM(GP_IO *io, GP_ProgressCallback *callback) { return GP_LoaderReadImage(&GP_PBM, io, callback); } -GP_Context *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback) +GP_Pixmap *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback) { return GP_LoaderLoadImage(&GP_PBM, src_path, callback); } -int GP_SavePBM(const GP_Context *src, const char *dst_path, +int GP_SavePBM(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback) { return GP_LoaderSaveImage(&GP_PBM, src, dst_path, callback); } -GP_Context *GP_ReadPGM(GP_IO *io, GP_ProgressCallback *callback) +GP_Pixmap *GP_ReadPGM(GP_IO *io, GP_ProgressCallback *callback) { return GP_LoaderReadImage(&GP_PGM, io, callback); } -GP_Context *GP_LoadPGM(const char *src_path, GP_ProgressCallback *callback) +GP_Pixmap *GP_LoadPGM(const char *src_path, GP_ProgressCallback *callback) { return GP_LoaderLoadImage(&GP_PGM, src_path, callback); } -int GP_SavePGM(const GP_Context *src, const char *dst_path, +int GP_SavePGM(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback) { return GP_LoaderSaveImage(&GP_PGM, src, dst_path, callback); } -GP_Context *GP_ReadPPM(GP_IO *io, GP_ProgressCallback *callback) +GP_Pixmap *GP_ReadPPM(GP_IO *io, GP_ProgressCallback *callback) { return GP_LoaderReadImage(&GP_PPM, io, callback); } -GP_Context *GP_LoadPPM(const char *src_path, GP_ProgressCallback *callback) +GP_Pixmap *GP_LoadPPM(const char *src_path, GP_ProgressCallback *callback) { return GP_LoaderLoadImage(&GP_PPM, src_path, callback); } -int GP_SavePPM(const GP_Context *src, const char *dst_path, +int GP_SavePPM(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback) { return GP_LoaderSaveImage(&GP_PPM, src, dst_path, callback); } -GP_Context *GP_ReadPNM(GP_IO *io, GP_ProgressCallback *callback) +GP_Pixmap *GP_ReadPNM(GP_IO *io, GP_ProgressCallback *callback) { return GP_LoaderReadImage(&GP_PNM, io, callback); } -GP_Context *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback) +GP_Pixmap *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback) { return GP_LoaderLoadImage(&GP_PNM, src_path, callback); } -int GP_SavePNM(const GP_Context *src, const char *dst_path, +int GP_SavePNM(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback) { return GP_LoaderSaveImage(&GP_PNM, src, dst_path, callback); diff --git a/libs/loaders/GP_PSD.c b/libs/loaders/GP_PSD.c index c6308113..b1bf45e3 100644 --- a/libs/loaders/GP_PSD.c +++ b/libs/loaders/GP_PSD.c @@ -202,12 +202,12 @@ static const char *thumbnail_fmt_name(uint16_t fmt) #define THUMBNAIL50_HSIZE 28 -static GP_Context *psd_thumbnail50(GP_IO *io, size_t size, +static GP_Pixmap *psd_thumbnail50(GP_IO *io, size_t size, GP_ProgressCallback *callback) { uint32_t fmt, w, h; uint16_t bpp, nr_planes; - GP_Context *res; + GP_Pixmap *res; int err; uint16_t res_thumbnail_header[] = { @@ -318,7 +318,7 @@ static void psd_read_version_info(GP_IO *io) version, str, reader); } -static unsigned int psd_next_img_res_block(GP_IO *io, GP_Context **res, +static unsigned int psd_next_img_res_block(GP_IO *io, GP_Pixmap **res, GP_ProgressCallback *callback) { uint16_t res_id; @@ -559,7 +559,7 @@ static GP_IO *rle(GP_IO *io) /* * Data are in planar mode RRRRR... GGGGG... BBBBB... etc. */ -static int psd_load_rle_rgb(GP_IO *rle_io, GP_Context *res, +static int psd_load_rle_rgb(GP_IO *rle_io, GP_Pixmap *res, GP_ProgressCallback *callback) { unsigned int x, y, c, p; @@ -598,7 +598,7 @@ static int psd_load_rle_rgb(GP_IO *rle_io, GP_Context *res, return 0; } -static int psd_load_rle_cmyk(GP_IO *rle_io, GP_Context *res, +static int psd_load_rle_cmyk(GP_IO *rle_io, GP_Pixmap *res, GP_ProgressCallback *callback) { unsigned int x, y, c; @@ -626,7 +626,7 @@ static int psd_load_rle_cmyk(GP_IO *rle_io, GP_Context *res, } static int psd_combined_image(GP_IO *io, struct psd_header *header, - GP_Context **res, GP_ProgressCallback *callback) + GP_Pixmap **res, GP_ProgressCallback *callback) { uint16_t compress; GP_PixelType pixel_type = GP_PIXEL_UNKNOWN; @@ -687,7 +687,7 @@ static int psd_combined_image(GP_IO *io, struct psd_header *header, return errno; } - *res = GP_ContextAlloc(header->w, header->h, pixel_type); + *res = GP_PixmapAlloc(header->w, header->h, pixel_type); if (!*res) return ENOMEM; @@ -702,7 +702,7 @@ static int psd_combined_image(GP_IO *io, struct psd_header *header, ret = psd_load_rle_rgb(rle_io, *res, callback); if (ret) - GP_ContextFree(*res); + GP_PixmapFree(*res); GP_IOClose(rle_io); return ret; @@ -718,13 +718,13 @@ static void fill_metadata(struct psd_header *header, GP_DataStorage *storage) psd_color_mode_name(header->color_mode)); } -int GP_ReadPSDEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, +int GP_ReadPSDEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { int err; uint32_t len, size, read_size = 0; struct psd_header header; - GP_Context *thumbnail = NULL; + GP_Pixmap *thumbnail = NULL; uint16_t psd_header[] = { '8', 'B', 'P', 'S', @@ -808,11 +808,11 @@ int GP_ReadPSDEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, goto err; } - GP_Context *combined = NULL; + GP_Pixmap *combined = NULL; err = psd_combined_image(io, &header, &combined, callback); if (!err) { - GP_ContextFree(thumbnail); + GP_PixmapFree(thumbnail); *img = combined; return 0; } @@ -828,22 +828,22 @@ int GP_ReadPSDEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, errno = ENOSYS; return 1; err: - GP_ContextFree(thumbnail); + GP_PixmapFree(thumbnail); errno = err; return 1; } -GP_Context *GP_LoadPSD(const char *src_path, GP_ProgressCallback *callback) +GP_Pixmap *GP_LoadPSD(const char *src_path, GP_ProgressCallback *callback) { return GP_LoaderLoadImage(&GP_PSD, src_path, callback); } -GP_Context *GP_ReadPSD(GP_IO *io, GP_ProgressCallback *callback) +GP_Pixmap *GP_ReadPSD(GP_IO *io, GP_ProgressCallback *callback) { return GP_LoaderReadImage(&GP_PSD, io, callback); } -int GP_LoadPSDEx(const char *src_path, GP_Context **img, +int GP_LoadPSDEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { return GP_LoaderLoadImageEx(&GP_PSD, src_path, img, storage, callback); diff --git a/libs/loaders/GP_PSP.c b/libs/loaders/GP_PSP.c index 02041632..0c34e4d9 100644 --- a/libs/loaders/GP_PSP.c +++ b/libs/loaders/GP_PSP.c @@ -172,7 +172,7 @@ struct psp_img_attrs { int is_loaded:1; uint8_t subblock; void *priv; - GP_Context *img; + GP_Pixmap *img; GP_DataStorage *storage; }; @@ -458,7 +458,7 @@ static int psp_next_block(GP_IO *io, struct psp_img_attrs *attrs, return 0; } -int GP_ReadPSPEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, +int GP_ReadPSPEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { int err = 0; @@ -514,17 +514,17 @@ err0: return 1; } -GP_Context *GP_LoadPSP(const char *src_path, GP_ProgressCallback *callback) +GP_Pixmap *GP_LoadPSP(const char *src_path, GP_ProgressCallback *callback) { return GP_LoaderLoadImage(&GP_PSP, src_path, callback); } -GP_Context *GP_ReadPSP(GP_IO *io, GP_ProgressCallback *callback) +GP_Pixmap *GP_ReadPSP(GP_IO *io, GP_ProgressCallback *callback) { return GP_LoaderReadImage(&GP_PSP, io, callback); } -int GP_LoadPSPEx(const char *src_path, GP_Context **img, +int GP_LoadPSPEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { return GP_LoaderLoadImageEx(&GP_PSP, src_path, img, storage, callback); diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c index 806923e9..fad41caf 100644 --- a/libs/loaders/GP_TIFF.c +++ b/libs/loaders/GP_TIFF.c @@ -358,7 +358,7 @@ static uint16_t get_idx(uint8_t *row, uint32_t x, uint16_t bps) return 0; } -static int tiff_read_palette(TIFF *tiff, GP_Context *res, +static int tiff_read_palette(TIFF *tiff, GP_Pixmap *res, struct tiff_header *header, GP_ProgressCallback *callback) { @@ -430,7 +430,7 @@ static int tiff_read_palette(TIFF *tiff, GP_Context *res, /* * Direct read -> data in image are in right format. */ -static int tiff_read(TIFF *tiff, GP_Context *res, struct tiff_header *header, +static int tiff_read(TIFF *tiff, GP_Pixmap *res, struct tiff_header *header, GP_ProgressCallback *callback) { uint32_t i, y; @@ -549,12 +549,12 @@ static void tiff_io_unmap(thandle_t io, void *base, toff_t size) } */ -int GP_ReadTIFFEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, +int GP_ReadTIFFEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { TIFF *tiff; struct tiff_header header; - GP_Context *res; + GP_Pixmap *res; GP_PixelType pixel_type; int err; @@ -584,7 +584,7 @@ int GP_ReadTIFFEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, goto err1; } - res = GP_ContextAlloc(header.w, header.h, pixel_type); + res = GP_PixmapAlloc(header.w, header.h, pixel_type); if (res == NULL) { err = errno; @@ -608,7 +608,7 @@ int GP_ReadTIFFEx(GP_IO *io, GP_Context **img, GP_DataStorage *storage, *img = res; return 0; err2: - GP_ContextFree(res); + GP_PixmapFree(res); err1: TIFFClose(tiff); err0: @@ -616,7 +616,7 @@ err0: return 1; } -static int save_grayscale(TIFF *tiff, const GP_Context *src, +static int save_grayscale(TIFF *tiff, const GP_Pixmap *src, GP_ProgressCallback *callback) { uint32_t x, y; @@ -667,7 +667,7 @@ static int save_grayscale(TIFF *tiff, const GP_Context *src, return 0; } -static int save_rgb(TIFF *tiff, const GP_Context *src, +static int save_rgb(TIFF *tiff, const GP_Pixmap *src, GP_ProgressCallback *callback) { uint8_t buf[src->w * 3]; @@ -723,7 +723,7 @@ static GP_PixelType save_ptypes[] = { GP_PIXEL_UNKNOWN, }; -int GP_WriteTIFF(const GP_Context *src, GP_IO *io, +int GP_WriteTIFF(const GP_Pixmap *src, GP_IO *io, GP_ProgressCallback *callback) { TIFF *tiff; @@ -801,7 +801,7 @@ int GP_WriteTIFF(const GP_Context *src, GP_IO *io, #else -int GP_ReadTIFFEx(GP_IO GP_UNUSED(*io), GP_Context GP_UNUSED(**img), +int GP_ReadTIFFEx(GP_IO GP_UNUSED(*io), GP_Pixmap GP_UNUSED(**img), GP_DataStorage GP_UNUSED(*storage), GP_ProgressCallback GP_UNUSED(*callback)) { @@ -809,7 +809,7 @@ int GP_ReadTIFFEx(GP_IO GP_UNUSED(*io), GP_Context GP_UNUSED(**img), return 1; } -int GP_WriteTIFF(const GP_Context GP_UNUSED(*src), GP_IO GP_UNUSED(*io), +int GP_WriteTIFF(const GP_Pixmap GP_UNUSED(*src), GP_IO GP_UNUSED(*io), GP_ProgressCallback GP_UNUSED(*callback)) { errno = ENOSYS; @@ -818,23 +818,23 @@ int GP_WriteTIFF(const GP_Context GP_UNUSED(*src), GP_IO GP_UNUSED(*io), #endif /* HAVE_TIFF */ -GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback) +GP_Pixmap *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback) { return GP_LoaderLoadImage(&GP_TIFF, src_path, callback); } -GP_Context *GP_ReadTIFF(GP_IO *io, GP_ProgressCallback *callback) +GP_Pixmap *GP_ReadTIFF(GP_IO *io, GP_ProgressCallback *callback) { return GP_LoaderReadImage(&GP_TIFF, io, callback); } -int GP_LoadTIFFEx(const char *src_path, GP_Context **img, +int GP_LoadTIFFEx(const char *src_path, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { return GP_LoaderLoadImageEx(&GP_TIFF, src_path, img, storage, callback); } -int GP_SaveTIFF(const GP_Context *src, const char *dst_path, +int GP_SaveTIFF(const GP_Pixmap *src, const char *dst_path, GP_ProgressCallback *callback) { return GP_LoaderSaveImage(&GP_TIFF, src, dst_path, callback); diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c index f9ae413c..fd1d7ab7 100644 --- a/libs/loaders/GP_ZIP.c +++ b/libs/loaders/GP_ZIP.c @@ -241,13 +241,13 @@ static int zip_read_data_desc(GP_IO *io, struct zip_local_header *header) return 0; } -static int zip_next_file(struct zip_priv *priv, GP_Context **img, +static int zip_next_file(struct zip_priv *priv, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { struct zip_local_header header = {.file_name = NULL}; int err = 0, res; - GP_Context *ret = NULL; + GP_Pixmap *ret = NULL; GP_IO *io; if ((err = zip_load_header(priv->io, &header))) @@ -412,7 +412,7 @@ static void record_offset(struct zip_priv *priv, long offset) */ } -static int zip_load_next(GP_Container *self, GP_Context **img, +static int zip_load_next(GP_Container *self, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { @@ -438,9 +438,9 @@ static int zip_load_next(GP_Container *self, GP_Context **img, return 0; } -static GP_Context *load_next(GP_Container *self, GP_ProgressCallback *callback) +static GP_Pixmap *load_next(GP_Container *self, GP_ProgressCallback *callback) { - GP_Context *img = NULL; + GP_Pixmap *img = NULL; zip_load_next(self, &img, NULL, callback); @@ -570,7 +570,7 @@ static int zip_seek(GP_Container *self, int offset, return ret; } -static int zip_load(GP_Container *self, GP_Context **img, +static int zip_load(GP_Container *self, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { if (zip_load_next(self, img, storage, callback)) diff --git a/libs/text/GP_Text.c b/libs/text/GP_Text.c index 14a28e7b..d3764d0f 100644 --- a/libs/text/GP_Text.c +++ b/libs/text/GP_Text.c @@ -73,12 +73,12 @@ static int do_align(GP_Coord *topleft_x, GP_Coord *topleft_y, int align, return 0; } -void GP_Text(GP_Context *context, const GP_TextStyle *style, +void GP_Text(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel fg_color, GP_Pixel bg_color, const char *str) { - GP_CHECK_CONTEXT(context); + GP_CHECK_PIXMAP(pixmap); if (str == NULL) return; @@ -93,11 +93,11 @@ void GP_Text(GP_Context *context, const GP_TextStyle *style, GP_ASSERT(do_align(&topleft_x, &topleft_y, align, x, y, style, w) == 0, "Invalid aligment flags"); - GP_Text_Raw(context, style, topleft_x, topleft_y, + GP_Text_Raw(pixmap, style, topleft_x, topleft_y, align & GP_TEXT_NOBG, fg_color, bg_color, str); } -GP_Size GP_VPrint(GP_Context *context, const GP_TextStyle *style, +GP_Size GP_VPrint(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel fg_color, GP_Pixel bg_color, const char *fmt, va_list va) @@ -111,12 +111,12 @@ GP_Size GP_VPrint(GP_Context *context, const GP_TextStyle *style, vsnprintf(buf, sizeof(buf), fmt, vac); va_end(vac); - GP_Text(context, style, x, y, align, fg_color, bg_color, buf); + GP_Text(pixmap, style, x, y, align, fg_color, bg_color, buf); return GP_TextWidth(style, buf); } -GP_Size GP_Print(GP_Context *context, const GP_TextStyle *style, +GP_Size GP_Print(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel fg_color, GP_Pixel bg_color, const char *fmt, ...) { @@ -124,14 +124,14 @@ GP_Size GP_Print(GP_Context *context, const GP_TextStyle *style, GP_Size ret; va_start(va, fmt); - ret = GP_VPrint(context, style, x, y, align, + ret = GP_VPrint(pixmap, style, x, y, align, fg_color, bg_color, fmt, va); va_end(va); return ret; } -void GP_TextClear(GP_Context *context, const GP_TextStyle *style, +void GP_TextClear(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel bg_color, GP_Size size) { @@ -140,14 +140,14 @@ void GP_TextClear(GP_Context *context, const GP_TextStyle *style, GP_ASSERT(do_align(&topleft_x, &topleft_y, align, x, y, style, size) == 0, "Invalid aligment flags"); - GP_FillRectXYWH(context, topleft_x, topleft_y, + GP_FillRectXYWH(pixmap, topleft_x, topleft_y, size, GP_TextHeight(style), bg_color); } -void GP_TextClearStr(GP_Context *context, const GP_TextStyle *style, +void GP_TextClearStr(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel bg_color, const char *str) { - GP_TextClear(context, style, x, y, align, + GP_TextClear(pixmap, style, x, y, align, bg_color, GP_TextWidth(style, str)); } diff --git a/libs/text/GP_Text.gen.c.t b/libs/text/GP_Text.gen.c.t index e8f2dbd7..209d00de 100644 --- a/libs/text/GP_Text.gen.c.t +++ b/libs/text/GP_Text.gen.c.t @@ -24,7 +24,7 @@ static int get_width(const GP_TextStyle *style, int width) @ for pt in pixeltypes: @ if not pt.is_unknown(): -static void text_draw_1BPP_{{ pt.name }}(GP_Context *context, const GP_TextStyle *style, +static void text_draw_1BPP_{{ pt.name }}(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, GP_Pixel fg, const char *str) { @@ -60,7 +60,7 @@ static void text_draw_1BPP_{{ pt.name }}(GP_Context *context, const GP_TextStyle continue; for (k = 0; k < style->pixel_ymul; k++) - GP_HLine(context, x_start, x_start + style->pixel_xmul - 1, + GP_HLine(pixmap, x_start, x_start + style->pixel_xmul - 1, y - (glyph->bearing_y - style->font->ascend) * y_mul + k, fg); } @@ -76,18 +76,18 @@ static void text_draw_1BPP_{{ pt.name }}(GP_Context *context, const GP_TextStyle @ end -static void text_draw_1BPP(GP_Context *context, const GP_TextStyle *style, int x, int y, +static void text_draw_1BPP(GP_Pixmap *pixmap, const GP_TextStyle *style, int x, int y, GP_Pixel fg, const char *str) { - switch (context->pixel_type) { + switch (pixmap->pixel_type) { @ for pt in pixeltypes: @ if not pt.is_unknown(): case GP_PIXEL_{{ pt.name }}: - text_draw_1BPP_{{ pt.name }}(context, style, x, y, fg, str); + text_draw_1BPP_{{ pt.name }}(pixmap, style, x, y, fg, str); break; @ end default: - GP_ABORT("Invalid context->pixel_type"); + GP_ABORT("Invalid pixmap->pixel_type"); } } @@ -125,7 +125,7 @@ static void text_draw_1BPP(GP_Context *context, const GP_TextStyle *style, int x for (k = 0; k < style->pixel_ymul; k++) { @ if use_bg: - GP_HLine(context, x_start, x_start + style->pixel_xmul - 1, cur_y + k, + GP_HLine(pixmap, x_start, x_start + style->pixel_xmul - 1, cur_y + k, GP_MIX_PIXELS_{{ pt.name }}(fg, bg, gray)); @ else: unsigned int l; @@ -134,8 +134,8 @@ static void text_draw_1BPP(GP_Context *context, const GP_TextStyle *style, int x unsigned int px = l; unsigned int py = cur_y + k; //TODO: optimize this - GP_TRANSFORM_POINT(context, px, py); - GP_MixPixel_Raw_Clipped_{{ pt.name }}(context, px, py, fg, gray); + GP_TRANSFORM_POINT(pixmap, px, py); + GP_MixPixel_Raw_Clipped_{{ pt.name }}(pixmap, px, py, fg, gray); } @ end } @@ -154,14 +154,14 @@ static void text_draw_1BPP(GP_Context *context, const GP_TextStyle *style, int x @ for pt in pixeltypes: @ if not pt.is_unknown(): -static void text_8BPP_bg_{{ pt.name }}(GP_Context *context, const GP_TextStyle *style, +static void text_8BPP_bg_{{ pt.name }}(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, GP_Pixel fg, GP_Pixel bg, const char *str) { @ text_8BPP(pt, True) } -static void text_8BPP_{{ pt.name }}(GP_Context *context, const GP_TextStyle *style, +static void text_8BPP_{{ pt.name }}(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, GP_Pixel fg, const char *str) { @@ -170,51 +170,51 @@ static void text_8BPP_{{ pt.name }}(GP_Context *context, const GP_TextStyle *sty @ end -static void text_8BPP_bg(GP_Context *context, const GP_TextStyle *style, +static void text_8BPP_bg(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, GP_Pixel fg, GP_Pixel bg, const char *str) { - switch (context->pixel_type) { + switch (pixmap->pixel_type) { @ for pt in pixeltypes: @ if not pt.is_unknown(): case GP_PIXEL_{{ pt.name }}: - text_8BPP_bg_{{ pt.name }}(context, style, x, y, fg, bg, str); + text_8BPP_bg_{{ pt.name }}(pixmap, style, x, y, fg, bg, str); break; @ end default: - GP_ABORT("Invalid context->pixel_type"); + GP_ABORT("Invalid pixmap->pixel_type"); } } -static void text_8BPP(GP_Context *context, const GP_TextStyle *style, +static void text_8BPP(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, GP_Pixel fg, const char *str) { - switch (context->pixel_type) { + switch (pixmap->pixel_type) { @ for pt in pixeltypes: @ if not pt.is_unknown(): case GP_PIXEL_{{ pt.name }}: - text_8BPP_{{ pt.name }}(context, style, x, y, fg, str); + text_8BPP_{{ pt.name }}(pixmap, style, x, y, fg, str); break; @ end default: - GP_ABORT("Invalid context->pixel_type"); + GP_ABORT("Invalid pixmap->pixel_type"); } } -void GP_Text_Raw(GP_Context *context, const GP_TextStyle *style, +void GP_Text_Raw(GP_Pixmap *pixmap, const GP_TextStyle *style, GP_Coord x, GP_Coord y, uint8_t flags, GP_Pixel fg, GP_Pixel bg, const char *str) { switch (style->font->glyph_bitmap_format) { case GP_FONT_BITMAP_1BPP: - text_draw_1BPP(context, style, x, y, fg, str); + text_draw_1BPP(pixmap, style, x, y, fg, str); break; case GP_FONT_BITMAP_8BPP: if (flags) - text_8BPP(context, style, x, y, fg, str); + text_8BPP(pixmap, style, x, y, fg, str); else - text_8BPP_bg(context, style, x, y, fg, bg, str); + text_8BPP_bg(pixmap, style, x, y, fg, bg, str); break; default: GP_ABORT("Invalid font glyph bitmap format"); diff --git a/pylib/gfxprim/__init__.py b/pylib/gfxprim/__init__.py index 47101360..a0c5fb21 100644 --- a/pylib/gfxprim/__init__.py +++ b/pylib/gfxprim/__init__.py @@ -4,9 +4,9 @@ GFXPrim Python bindings. Mostly generated using SWIG. Structure: gfxprim: core: - context: module defining Context - Context - wrapper class, with many proxy methods - [Context from context] + pixmap: module defining Pixmap + Pixmap - wrapper class, with many proxy methods + [Pixmap from pixmap] gfxprim_core_c: - SWIG module [almost * from gfxprim_core_c] loaders: diff --git a/pylib/gfxprim/backends/__init__.py b/pylib/gfxprim/backends/__init__.py index 9e94604b..eccaf05e 100644 --- a/pylib/gfxprim/backends/__init__.py +++ b/pylib/gfxprim/backends/__init__.py @@ -3,7 +3,7 @@ Module wrapping GfxPrim backends. BIG FAT WARNING --------------- -Accessing a context after its backend has ben freed will probably +Accessing a pixmap after its backend has ben freed will probably end your (program's) world """ diff --git a/pylib/gfxprim/backends/_extend_backend.py b/pylib/gfxprim/backends/_extend_backend.py index 0a03acb5..45421923 100644 --- a/pylib/gfxprim/backends/_extend_backend.py +++ b/pylib/gfxprim/backends/_extend_backend.py @@ -16,7 +16,7 @@ def extend_backend(_backend): @extend(_backend) def Flip(self): - "If display is buffered, this copies content of context onto display." + "If display is buffered, this copies content of pixmap onto display." return c_backends.GP_BackendFlip(self) @extend(_backend) diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py index 82b27f9e..88135425 100644 --- a/pylib/gfxprim/core/__init__.py +++ b/pylib/gfxprim/core/__init__.py @@ -9,14 +9,14 @@ from . import c_core from . import C -# Main Context proxy (extended below) +# Main Pixmap proxy (extended below) -Context = c_core.GP_Context +Pixmap = c_core.GP_Pixmap def _init(module): """ - Extends _context class with core module methods and properties + Extends _pixmap class with core module methods and properties for object-oriented usage. Called once on module initialization. """ @@ -29,35 +29,35 @@ def _init(module): _ptdescr = c_core.GP_PixelTypeDescription - # String representation of a Context + # String representation of a Pixmap @extend(_ptdescr, name='__str__') @extend(_ptdescr, name='__repr__') def ptdescr_str(self): return "" % (self.name, ) - ### Context + ### Pixmap - _context = module['Context'] + _pixmap = module['Pixmap'] # String representation - @extend(_context, name='__str__') - @extend(_context, name='__repr__') - def context_str(self): - return "" % ( + @extend(_pixmap, name='__str__') + @extend(_pixmap, name='__repr__') + def pixmap_str(self): + return "" % ( self.w, self.h, module['PixelTypes'][self.pixel_type].name, self.bpp, "" if self.thisown else "not ", "with" if self.parent else "no") # Equality - @extend(_context, name='__eq__') - def ContextEqual(self, other): - "Compare Contexts - pixel types, sizes and data must match (gamma ignored)." - if not isinstance(other, _context): - raise TypeError("Can only compare two Contexts.") - return bool(c_core.GP_ContextEqual(self, other)) + @extend(_pixmap, name='__eq__') + def PixmapEqual(self, other): + "Compare Pixmaps - pixel types, sizes and data must match (gamma ignored)." + if not isinstance(other, _pixmap): + raise TypeError("Can only compare two Pixmaps.") + return bool(c_core.GP_PixmapEqual(self, other)) # Constructor @@ -69,62 +69,62 @@ def _init(module): return pixeltype.type raise TypeError("Not a PixelType instance or number: %r", pixeltype) - extend(_context, name='__swig_init__')(_context.__init__) + extend(_pixmap, name='__swig_init__')(_pixmap.__init__) - @extend(_context, name='__init__') - def ContextCreate(self, w, h, pixeltype): + @extend(_pixmap, name='__init__') + def PixmapCreate(self, w, h, pixeltype): "Allocate a new w*h bitmap of given type." # Add "parent" attribute, pointing to a wrapper of the actual parent or None - _context.__swig_init__(self, w, h, pixeltype_no(pixeltype)) + _pixmap.__swig_init__(self, w, h, pixeltype_no(pixeltype)) self.parent = None # New instance methods - @extend(_context) - def SubContext(self, x, y, w, h): - "Create a subcontext (a rectangular view)." - c = c_core.GP_SubContextAlloc(self, x, y, w, h) + @extend(_pixmap) + def SubPixmap(self, x, y, w, h): + "Create a subpixmap (a rectangular view)." + c = c_core.GP_SubPixmapAlloc(self, x, y, w, h) c.parent = self return c - @extend(_context) + @extend(_pixmap) def Copy(self, withdata): - "Copy the context to a new context. Pixel data are copie optionally." + "Copy the pixmap to a new pixmap. Pixel data are copie optionally." flags = c_core.GP_COPY_WITH_PIXELS if withdata else 0 - return c_core.GP_ContextCopy(self, flags) + return c_core.GP_PixmapCopy(self, flags) - @extend(_context) + @extend(_pixmap) def Convert(self, target_type): - """Converts context to a different pixel type, allocates new context. - See GP_ContextConvertAlloc() for details.""" - return c_core.GP_ContextConvertAlloc(self, pixeltype_no(target_type)) + """Converts pixmap to a different pixel type, allocates new pixmap. + See GP_PixmapConvertAlloc() for details.""" + return c_core.GP_PixmapConvertAlloc(self, pixeltype_no(target_type)) - @extend(_context) + @extend(_pixmap) def ToByteArray(self): - """Returns new Python ByteArray created from context pixels. The - array size is exactly context.bytes_per_row * context.h""" - return c_core.GP_ContextToByteArray(self) + """Returns new Python ByteArray created from pixmap pixels. The + array size is exactly pixmap.bytes_per_row * pixmap.h""" + return c_core.GP_PixmapToByteArray(self) # Manipulation - extend_direct(_context, "PutPixel", c_core.GP_PutPixel, - "Set a pixel value encoded according to context PixelType. Clipped.") + extend_direct(_pixmap, "PutPixel", c_core.GP_PutPixel, + "Set a pixel value encoded according to pixmap PixelType. Clipped.") - extend_direct(_context, "GetPixel", c_core.GP_GetPixel, - "Get a pixel value (encoded according to context PixelType). Clipped.") + extend_direct(_pixmap, "GetPixel", c_core.GP_GetPixel, + "Get a pixel value (encoded according to pixmap PixelType). Clipped.") - extend_direct(_context, "RotateCW", c_core.GP_ContextRotateCW, - "Rotate Context clockwise by changing the context orientation.") + extend_direct(_pixmap, "RotateCW", c_core.GP_PixmapRotateCW, + "Rotate Pixmap clockwise by changing the pixmap orientation.") - extend_direct(_context, "RotateCCW", c_core.GP_ContextRotateCCW, - "Rotate Context counter-clockwise by changing the context orientation.") + extend_direct(_pixmap, "RotateCCW", c_core.GP_PixmapRotateCCW, + "Rotate Pixmap counter-clockwise by changing the pixmap orientation.") - extend_direct(_context, "Resize", c_core.GP_ContextResize, - "Resize the context bitmap (reallocate). Fails on subcontexts.") + extend_direct(_pixmap, "Resize", c_core.GP_PixmapResize, + "Resize the pixmap bitmap (reallocate). Fails on subpixmaps.") # Blit - @extend(_context) + @extend(_pixmap) def Blit(self, sx, sy, target, tx, ty, w=None, h=None, sx2=None, sy2=None, tx2=None, ty2=None): """Copy a rectangle from self to target. (sx,sy) and (tx,ty) define @@ -146,35 +146,35 @@ def _init(module): # Color conversions - @extend(_context) + @extend(_pixmap) def RGBToPixel(self, r, g, b): - "Convert RGB888 (values 0-255) to context pixel type." + "Convert RGB888 (values 0-255) to pixmap pixel type." return c_core.GP_RGBToPixel(int(r), int(g), int(b), self.pixel_type) - @extend(_context) + @extend(_pixmap) def RGBAToPixel(self, r, g, b, a): - "Convert RGBA8888 (values 0-255) to context pixel type." + "Convert RGBA8888 (values 0-255) to pixmap pixel type." return c_core.GP_RGBAToPixel(int(r), int(g), int(b), int(a), self.pixel_type) - @extend(_context) + @extend(_pixmap) def Fill(self, pixel): - "Fills context with given pixel value." + "Fills pixmap with given pixel value." return c_core.GP_Fill(self, pixel) - # Handle submodule methods such as context.gfx.Line(...) + # Handle submodule methods such as pixmap.gfx.Line(...) _available_submodules = frozenset(['gfx', 'loaders', 'text', 'filters']) - extend(_context, name='_submodules')({}) + extend(_pixmap, name='_submodules')({}) - old__getattr__ = _context.__getattr__ - def Context__getattr__(self, name): - if name in _context._submodules: + old__getattr__ = _pixmap.__getattr__ + def Pixmap__getattr__(self, name): + if name in _pixmap._submodules: assert name in _available_submodules - return _context._submodules[name](self) + return _pixmap._submodules[name](self) if name in _available_submodules: raise RuntimeError("GfxPrim submodule '%s' not loaded" % name) return old__getattr__(self, name) - _context.__getattr__ = Context__getattr__ + _pixmap.__getattr__ = Pixmap__getattr__ # Import constants into a separate module @@ -184,8 +184,8 @@ def _init(module): def strip_GP(s): return re.sub('^GP_', '', s) import_members(c_core, C, include=const_regexes, sub=strip_GP) - # every Context also points to C for convenience - extend(_context, name='C')(C) + # every Pixmap also points to C for convenience + extend(_pixmap, name='C')(C) # Arrays with pixel type info module['PixelTypes'] = [c_core.GP_PixelTypes_access(i) @@ -209,7 +209,7 @@ def _init(module): '^GP_Fill', ]) - module['Convert'] = c_core.GP_ContextConvertAlloc + module['Convert'] = c_core.GP_PixmapConvertAlloc _init(locals()) del _init diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i index b0aff173..bc7eea73 100644 --- a/pylib/gfxprim/core/core.i +++ b/pylib/gfxprim/core/core.i @@ -48,77 +48,77 @@ const GP_PixelTypeDescription *GP_PixelTypes_access(GP_PixelType no) %} /* - * GP_Context wrapping + * GP_Pixmap wrapping */ /* Make some members RO */ -%immutable GP_Context::w; -%immutable GP_Context::h; -%immutable GP_Context::pixel_type; -%immutable GP_Context::bpp; -%immutable GP_Context::bytes_per_row; -/* Rename "internal" GP_Context */ -%rename("_%s") "GP_Context::pixels"; -%rename("_%s") "GP_Context::offset"; -%rename("_%s") "GP_Context::axes_swap"; -%rename("_%s") "GP_Context::x_swap"; -%rename("_%s") "GP_Context::y_swap"; -%rename("_%s") "GP_Context::bit_endian"; -%rename("_%s") "GP_Context::free_pixels"; +%immutable GP_Pixmap::w; +%immutable GP_Pixmap::h; +%immutable GP_Pixmap::pixel_type; +%immutable GP_Pixmap::bpp; +%immutable GP_Pixmap::bytes_per_row; +/* Rename "internal" GP_Pixmap */ +%rename("_%s") "GP_Pixmap::pixels"; +%rename("_%s") "GP_Pixmap::offset"; +%rename("_%s") "GP_Pixmap::axes_swap"; +%rename("_%s") "GP_Pixmap::x_swap"; +%rename("_%s") "GP_Pixmap::y_swap"; +%rename("_%s") "GP_Pixmap::bit_endian"; +%rename("_%s") "GP_Pixmap::free_pixels"; %inline %{ -PyObject *GP_ContextToByteArray(GP_Context *self) +PyObject *GP_PixmapToByteArray(GP_Pixmap *self) { return PyByteArray_FromStringAndSize((char*)self->pixels, self->bytes_per_row * self->h); } %} -%feature("autodoc", "Proxy of C GP_Context struct +%feature("autodoc", "Proxy of C GP_Pixmap struct -You can pass this class to wrapped GP_DrawSomething(...) as GP_Context. -All attributes of GP_Context are accessible directly as _attribute +You can pass this class to wrapped GP_DrawSomething(...) as GP_Pixmap. +All attributes of GP_Pixmap are accessible directly as _attribute (self._w etc.), but it is reccomended to use redefined properties: -self.w: Context width (transformed) -self.h: Context height (transformed) -self.pixel_type: Context pixel type (number) +self.w: Pixmap width (transformed) +self.h: Pixmap height (transformed) +self.pixel_type: Pixmap pixel type (number) -Some context-related methods are provided as class members for convenience. +Some pixmap-related methods are provided as class members for convenience. -GP_Context memory allocation is handled by gfxprim, deallocation by GP_ContextFree(). -The wrapper can be used without owning the GP_Context struct by setting self.this -and self.thisown.") GP_Context; +GP_Pixmap memory allocation is handled by gfxprim, deallocation by GP_PixmapFree(). +The wrapper can be used without owning the GP_Pixmap struct by setting self.this +and self.thisown.") GP_Pixmap; -%extend GP_Context { - ~GP_Context() { - GP_DEBUG(2, "[wrapper] GP_ContextFree (%dx%d raw, %dbpp, free_pixels:%d)", +%extend GP_Pixmap { + ~GP_Pixmap() { + GP_DEBUG(2, "[wrapper] GP_PixmapFree (%dx%d raw, %dbpp, free_pixels:%d)", $self->w, $self->h, $self->bpp, $self->free_pixels); - GP_ContextFree($self); + GP_PixmapFree($self); } - GP_Context(GP_Coord w, GP_Coord h, GP_PixelType typeno) { - return GP_ContextAlloc(w, h, typeno); + GP_Pixmap(GP_Coord w, GP_Coord h, GP_PixelType typeno) { + return GP_PixmapAlloc(w, h, typeno); } }; /* Error handling */ -ERROR_ON_NONZERO(GP_ContextResize); -ERROR_ON_NULL(GP_ContextAlloc); -ERROR_ON_NULL(GP_ContextCopy); -ERROR_ON_NULL(GP_ContextConvertAlloc); -ERROR_ON_NULL(GP_SubContextAlloc); +ERROR_ON_NONZERO(GP_PixmapResize); +ERROR_ON_NULL(GP_PixmapAlloc); +ERROR_ON_NULL(GP_PixmapCopy); +ERROR_ON_NULL(GP_PixmapConvertAlloc); +ERROR_ON_NULL(GP_SubPixmapAlloc); -/* Indicate new wrapper-owned GP_Context */ -%newobject GP_ContextAlloc; -%newobject GP_ContextCopy; -%newobject GP_ContextConvertAlloc; -%newobject GP_SubContextAlloc; +/* Indicate new wrapper-owned GP_Pixmap */ +%newobject GP_PixmapAlloc; +%newobject GP_PixmapCopy; +%newobject GP_PixmapConvertAlloc; +%newobject GP_SubPixmapAlloc; -%include "GP_Context.h" +%include "GP_Pixmap.h" /* - * Context manipulation + * Pixmap manipulation */ %include "GP_GetPutPixel.h" %import "GP_GetPutPixel.gen.h" diff --git a/pylib/gfxprim/filters/__init__.py b/pylib/gfxprim/filters/__init__.py index fe82d016..dae818d0 100644 --- a/pylib/gfxprim/filters/__init__.py +++ b/pylib/gfxprim/filters/__init__.py @@ -1,24 +1,24 @@ """ -Module extending the Context class with .filter submodule. +Module extending the Pixmap class with .filter submodule. -Use as in "import gfxprim.filters; context_foo.filter.Resize(...)" +Use as in "import gfxprim.filters; pixmap_foo.filter.Resize(...)" """ # Import the SWIG wrapper from . import c_filters def _init(module): - "Extend Context with filters submodule" + "Extend Pixmap with filters submodule" from ..utils import extend, extend_submodule - from ..core import Context as _context + from ..core import Pixmap as _pixmap - # New Context submodule + # New Pixmap submodule class FiltersSubmodule(object): def __init__(self, ctx): self.ctx = ctx - _context._submodules['filters'] = FiltersSubmodule + _pixmap._submodules['filters'] = FiltersSubmodule for name in ['Invert', 'InvertAlloc', 'Brightness', 'BrightnessAlloc', diff --git a/pylib/gfxprim/gfx/__init__.py b/pylib/gfxprim/gfx/__init__.py index 5c92d663..a6bd238d 100644 --- a/pylib/gfxprim/gfx/__init__.py +++ b/pylib/gfxprim/gfx/__init__.py @@ -1,7 +1,7 @@ """ -Module extending the Context class with .gfx submodule and its drawing functions. +Module extending the Pixmap class with .gfx submodule and its drawing functions. -Use as in "import gfxprim.gfx; context_foo.gfx.Line(...)" +Use as in "import gfxprim.gfx; pixmap_foo.gfx.Line(...)" """ # Import the SWIG wrapper @@ -11,18 +11,18 @@ from . import c_gfx from . import C def _init(module): - "Extend Context with gfx submodule" + "Extend Pixmap with gfx submodule" from ..utils import extend, add_swig_getmethod, add_swig_setmethod - from ..core import Context as _context + from ..core import Pixmap as _pixmap - # New Context submodule + # New Pixmap submodule class GfxSubmodule(object): def __init__(self, ctx): self.ctx = ctx self.C = C - _context._submodules['gfx'] = GfxSubmodule + _pixmap._submodules['gfx'] = GfxSubmodule # Imports from the SWIG module from ..utils import import_members, extend_submodule @@ -62,7 +62,7 @@ def _init(module): @extend(GfxSubmodule) def Polygon(self, points, pixel): """ - Polygon(context, coordinates, pixel) + Polygon(pixmap, coordinates, pixel) Draw a polygon with color `pixel`. `coordinates` is either an iterable of `int` coordinates `(x0, y0, x1, y1, ...)` @@ -73,7 +73,7 @@ def _init(module): @extend(GfxSubmodule) def FillPolygon(self, points, pixel): """ - FillPolygon(context, coordinates, pixel) + FillPolygon(pixmap, coordinates, pixel) Draw a filled polygon with color `pixel`. `coordinates` is either an iterable of `int` coordinates `(x0, y0, x1, y1, ...)` diff --git a/pylib/gfxprim/gfx/gfx.i b/pylib/gfxprim/gfx/gfx.i index 5e4f447a..ee92a814 100644 --- a/pylib/gfxprim/gfx/gfx.i +++ b/pylib/gfxprim/gfx/gfx.i @@ -47,17 +47,17 @@ static GP_Coord *GP_Polygon_unpack_coordinates(PyObject *coords) return cs; } -void GP_Polygon_wrap(GP_Context *context, PyObject *coords, GP_Pixel pixel) +void GP_Polygon_wrap(GP_Pixmap *pixmap, PyObject *coords, GP_Pixel pixel) { GP_Coord *cs = GP_Polygon_unpack_coordinates(coords); - GP_Polygon(context, PyTuple_Size(coords) / 2, cs, pixel); + GP_Polygon(pixmap, PyTuple_Size(coords) / 2, cs, pixel); free(cs); } -void GP_FillPolygon_wrap(GP_Context *context, PyObject *coords, GP_Pixel pixel) +void GP_FillPolygon_wrap(GP_Pixmap *pixmap, PyObject *coords, GP_Pixel pixel) { GP_Coord *cs = GP_Polygon_unpack_coordinates(coords); - GP_FillPolygon(context, PyTuple_Size(coords) / 2, cs, pixel); + GP_FillPolygon(pixmap, PyTuple_Size(coords) / 2, cs, pixel); free(cs); } %} diff --git a/pylib/gfxprim/loaders/__init__.py b/pylib/gfxprim/loaders/__init__.py index 7a1bd833..c4d23acc 100644 --- a/pylib/gfxprim/loaders/__init__.py +++ b/pylib/gfxprim/loaders/__init__.py @@ -6,16 +6,16 @@ def Load(filename, callback=None): return c def _init(module): - "Extend Context with loaders submodule" + "Extend Pixmap with loaders submodule" from ..utils import extend, add_swig_getmethod, add_swig_setmethod - from ..core import Context as _context + from ..core import Pixmap as _pixmap class LoadersSubmodule(object): def __init__(self, ctx): self.ctx = ctx - _context._submodules['loaders'] = LoadersSubmodule + _pixmap._submodules['loaders'] = LoadersSubmodule @extend(LoadersSubmodule) def Save(self, filename, callback=None): diff --git a/pylib/gfxprim/text/__init__.py b/pylib/gfxprim/text/__init__.py index 2561900c..333f8ded 100644 --- a/pylib/gfxprim/text/__init__.py +++ b/pylib/gfxprim/text/__init__.py @@ -1,7 +1,7 @@ """ -Module extending the Context class with .text submodule and its text drawing functions. +Module extending the Pixmap class with .text submodule and its text drawing functions. -Use as in "import gfxprim.text; context_foo.text.Text(...)" +Use as in "import gfxprim.text; pixmap_foo.text.Text(...)" """ # Import the SWIG wrapper @@ -11,18 +11,18 @@ from . import c_text from . import C def _init(module): - "Extend context with text submodule" + "Extend pixmap with text submodule" from ..utils import extend, add_swig_getmethod, add_swig_setmethod - from ..core import Context as _context + from ..core import Pixmap as _pixmap - # New Context submodule + # New Pixmap submodule class TextSubmodule(object): def __init__(self, ctx): self.ctx = ctx self.C = C - _context._submodules['text'] = TextSubmodule + _pixmap._submodules['text'] = TextSubmodule # Imports from the SWIG module from ..utils import import_members, extend_submodule diff --git a/tests/afl/loaders.c b/tests/afl/loaders.c index 7f3b482b..ead91d76 100644 --- a/tests/afl/loaders.c +++ b/tests/afl/loaders.c @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) { - GP_Context *img; + GP_Pixmap *img; if (argc != 2) { fprintf(stderr, "Takes an image as an parameter\n"); @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) img = GP_LoadImage(argv[1], NULL); - GP_ContextFree(img); + GP_PixmapFree(img); return 0; } diff --git a/tests/core/.gitignore b/tests/core/.gitignore index f52f0420..9baa8570 100644 --- a/tests/core/.gitignore +++ b/tests/core/.gitignore @@ -1,6 +1,6 @@ /BlitClipped /BlitConv.gen -/Context +/Pixmap /Convert.gen /Convert_Scale.gen /Debug diff --git a/tests/core/BlitClipped.c b/tests/core/BlitClipped.c index 1fd7bdd5..8362f180 100644 --- a/tests/core/BlitClipped.c +++ b/tests/core/BlitClipped.c @@ -27,7 +27,7 @@ */ #include -#include +#include #include #include @@ -55,16 +55,16 @@ struct clipped_test { static int clipped_test(struct clipped_test *test) { int ret = TST_SUCCESS; - GP_Context *src, *dst; + GP_Pixmap *src, *dst; - src = GP_ContextAlloc(test->src_w, test->src_h, GP_PIXEL_G8); - dst = GP_ContextAlloc(test->dst_w, test->dst_h, GP_PIXEL_G8); + src = GP_PixmapAlloc(test->src_w, test->src_h, GP_PIXEL_G8); + dst = GP_PixmapAlloc(test->dst_w, test->dst_h, GP_PIXEL_G8); GP_Fill(src, 1); GP_Fill(dst, 0); if (!src || !dst) { - tst_msg("GP_ContextAlloc() failed"); + tst_msg("GP_PixmapAlloc() failed"); return TST_UNTESTED; } @@ -76,8 +76,8 @@ static int clipped_test(struct clipped_test *test) ret = TST_FAILED; } - GP_ContextFree(src); - GP_ContextFree(dst); + GP_PixmapFree(src); + GP_PixmapFree(dst); return ret; } diff --git a/tests/core/BlitConv.gen.c.t b/tests/core/BlitConv.gen.c.t index 97375a8f..fed03000 100644 --- a/tests/core/BlitConv.gen.c.t +++ b/tests/core/BlitConv.gen.c.t @@ -7,14 +7,14 @@ #include -#include +#include #include #include #include #include "tst_test.h" -static void fill_context(GP_Context *c, GP_Pixel p) +static void fill_pixmap(GP_Pixmap *c, GP_Pixel p) { GP_Coord x, y; @@ -23,7 +23,7 @@ static void fill_context(GP_Context *c, GP_Pixel p) GP_PutPixel(c, x, y, p); } -static void mess_context(GP_Context *c) +static void mess_pixmap(GP_Pixmap *c) { GP_Coord y; unsigned int i; @@ -36,7 +36,7 @@ static void mess_context(GP_Context *c) } } -static int check_filled(GP_Context *c, GP_Pixel p) +static int check_filled(GP_Pixmap *c, GP_Pixel p) { GP_Coord x, y; GP_Pixel pc; @@ -54,23 +54,23 @@ static int check_filled(GP_Context *c, GP_Pixel p) return 0; } -static GP_Pixel rgb_to_pixel(int r, int g, int b, GP_Context *c) +static GP_Pixel rgb_to_pixel(int r, int g, int b, GP_Pixmap *c) { if (GP_PixelHasFlags(c->pixel_type, GP_PIXEL_HAS_ALPHA)) - return GP_RGBAToContextPixel(r, g, b, 0xff, c); + return GP_RGBAToPixmapPixel(r, g, b, 0xff, c); - return GP_RGBToContextPixel(r, g, b, c); + return GP_RGBToPixmapPixel(r, g, b, c); } @ def gen_blit(name, r, g, b, pt1, pt2): static int blit_{{ name }}_{{ pt1.name }}_to_{{ pt2.name }}(void) { - GP_Context *src = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt1.name }}); - GP_Context *dst = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt2.name }}); + GP_Pixmap *src = GP_PixmapAlloc(100, 100, GP_PIXEL_{{ pt1.name }}); + GP_Pixmap *dst = GP_PixmapAlloc(100, 100, GP_PIXEL_{{ pt2.name }}); if (src == NULL || dst == NULL) { - GP_ContextFree(src); - GP_ContextFree(dst); + GP_PixmapFree(src); + GP_PixmapFree(dst); tst_msg("Malloc failed :("); return TST_UNTESTED; } @@ -81,8 +81,8 @@ static int blit_{{ name }}_{{ pt1.name }}_to_{{ pt2.name }}(void) tst_msg("pixel_src=%08x pixel_dst=%08x", pix_src, pix_dst); - fill_context(src, pix_src); - mess_context(dst); + fill_pixmap(src, pix_src); + mess_pixmap(dst); GP_Blit(src, 0, 0, src->w, src->h, dst, 0, 0); diff --git a/tests/core/GetPutPixel.gen.c.t b/tests/core/GetPutPixel.gen.c.t index 4f2c2157..a34ba95d 100644 --- a/tests/core/GetPutPixel.gen.c.t +++ b/tests/core/GetPutPixel.gen.c.t @@ -7,12 +7,12 @@ #include -#include +#include #include #include "tst_test.h" -static void fill_context(GP_Context *c, GP_Pixel p) +static void fill_pixmap(GP_Pixmap *c, GP_Pixel p) { GP_Coord x, y; @@ -21,7 +21,7 @@ static void fill_context(GP_Context *c, GP_Pixel p) GP_PutPixel(c, x, y, p); } -static int check_filled(GP_Context *c) +static int check_filled(GP_Pixmap *c) { GP_Coord x, y; GP_Pixel p; @@ -38,9 +38,9 @@ static int check_filled(GP_Context *c) return 0; } -static int try_pattern(GP_Context *c, GP_Pixel p) +static int try_pattern(GP_Pixmap *c, GP_Pixel p) { - fill_context(c, p); + fill_pixmap(c, p); tst_msg("Filling pattern 0x%x", p); @@ -54,13 +54,13 @@ static int try_pattern(GP_Context *c, GP_Pixel p) @ if not pt.is_unknown(): static int GetPutPixel_{{ pt.name }}(void) { - GP_Context *c; + GP_Pixmap *c; int err = 0; - c = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt.name }}); + c = GP_PixmapAlloc(100, 100, GP_PIXEL_{{ pt.name }}); if (c == NULL) { - tst_msg("GP_ContextAlloc() failed"); + tst_msg("GP_PixmapAlloc() failed"); return TST_UNTESTED; } @@ -76,7 +76,7 @@ static int GetPutPixel_{{ pt.name }}(void) if (try_pattern(c, 0xf0f0f0f0 & {{ 2 ** pt.pixelsize.size - 1}}U)) err++; - GP_ContextFree(c); + GP_PixmapFree(c); if (err) return TST_FAILED; @@ -89,16 +89,16 @@ static int GetPutPixel_{{ pt.name }}(void) @ if not pt.is_unknown(): static int GetPutPixel_Clipping_{{ pt.name }}(void) { - GP_Context *c; + GP_Pixmap *c; - c = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt.name }}); + c = GP_PixmapAlloc(100, 100, GP_PIXEL_{{ pt.name }}); if (c == NULL) { - tst_msg("GP_ContextAlloc() failed"); + tst_msg("GP_PixmapAlloc() failed"); return TST_UNTESTED; } - fill_context(c, 0xffffffff); + fill_pixmap(c, 0xffffffff); GP_Coord x, y; int err = 0; @@ -120,7 +120,7 @@ static int GetPutPixel_Clipping_{{ pt.name }}(void) } } - GP_ContextFree(c); + GP_PixmapFree(c); if (err) return TST_FAILED; diff --git a/tests/core/Makefile b/tests/core/Makefile index 737fc17f..0f4181e3 100644 --- a/tests/core/Makefile +++ b/tests/core/Makefile @@ -2,12 +2,12 @@ TOPDIR=../.. include $(TOPDIR)/pre.mk -CSOURCES=Context.c Pixel.c BlitClipped.c Debug.c +CSOURCES=Pixmap.c Pixel.c BlitClipped.c Debug.c GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c Convert.gen.c BlitConv.gen.c \ Convert_Scale.gen.c GetSetBits.gen.c -APPS=WritePixel.gen Pixel Context GetPutPixel.gen Convert.gen BlitConv.gen \ +APPS=WritePixel.gen Pixel Pixmap GetPutPixel.gen Convert.gen BlitConv.gen \ Convert_Scale.gen GetSetBits.gen BlitClipped Debug include ../tests.mk diff --git a/tests/core/Context.c b/tests/core/Pixmap.c similarity index 60% rename from tests/core/Context.c rename to tests/core/Pixmap.c index cf8374d8..417b0f33 100644 --- a/tests/core/Context.c +++ b/tests/core/Pixmap.c @@ -22,63 +22,63 @@ /* - Very basic GP_Context tests. + Very basic GP_Pixmap tests. */ #include -#include +#include #include "tst_test.h" /* - * Check that Context is correctly allocated and freed + * Check that Pixmap is correctly allocated and freed */ -static int Context_Alloc_Free(void) +static int Pixmap_Alloc_Free(void) { - GP_Context *c; + GP_Pixmap *c; - c = GP_ContextAlloc(100, 200, GP_PIXEL_RGB888); + c = GP_PixmapAlloc(100, 200, GP_PIXEL_RGB888); if (c == NULL) { - tst_msg("GP_ContextAlloc() failed"); + tst_msg("GP_PixmapAlloc() failed"); return TST_FAILED; } - /* Assert context properties */ + /* Assert pixmap properties */ if (c->bpp != 24) { - tst_msg("Context->bpp != 24 (== %i)", c->bpp); + tst_msg("Pixmap->bpp != 24 (== %i)", c->bpp); return TST_FAILED; } if (c->bytes_per_row != 3 * c->w) { - tst_msg("Context->bytes_per_row != %i (== %i)", + tst_msg("Pixmap->bytes_per_row != %i (== %i)", 3 * c->w, c->bytes_per_row); return TST_FAILED; } if (c->w != 100) { - tst_msg("Context->w != 100 (== %i)", c->w); + tst_msg("Pixmap->w != 100 (== %i)", c->w); return TST_FAILED; } if (c->h != 200) { - tst_msg("Context->h != 200 (== %i)", c->h); + tst_msg("Pixmap->h != 200 (== %i)", c->h); return TST_FAILED; } if (c->offset != 0) { - tst_msg("Context->offset != 0"); + tst_msg("Pixmap->offset != 0"); return TST_FAILED; } if (c->pixel_type != GP_PIXEL_RGB888) { - tst_msg("Context->pixel_type != GP_PIXEL_RGB888"); + tst_msg("Pixmap->pixel_type != GP_PIXEL_RGB888"); return TST_FAILED; } if (c->gamma != NULL) { - tst_msg("Context->gamma != NULL"); + tst_msg("Pixmap->gamma != NULL"); return TST_FAILED; } @@ -92,49 +92,49 @@ static int Context_Alloc_Free(void) *(char*)GP_PIXEL_ADDR(c, 0, 0) = 0; *(char*)GP_PIXEL_ADDR(c, 100, 100) = 0; - GP_ContextFree(c); + GP_PixmapFree(c); return TST_SUCCESS; } /* - * Asserts that subcontext structure is initialized correctly + * Asserts that subpixmap structure is initialized correctly */ -static int subcontext_assert(const GP_Context *c, const GP_Context *sc, +static int subpixmap_assert(const GP_Pixmap *c, const GP_Pixmap *sc, GP_Size w, GP_Size h) { if (c->bpp != sc->bpp) { - tst_msg("Context->bpp != SubContext->bpp"); + tst_msg("Pixmap->bpp != SubPixmap->bpp"); return TST_FAILED; } if (c->bytes_per_row != sc->bytes_per_row) { - tst_msg("Context->bytes_per_row != SubContext->bytes_per_row"); + tst_msg("Pixmap->bytes_per_row != SubPixmap->bytes_per_row"); return TST_FAILED; } if (sc->w != w) { - tst_msg("SubContext->w != %u (== %i)", w, sc->w); + tst_msg("SubPixmap->w != %u (== %i)", w, sc->w); return TST_FAILED; } if (sc->h != h) { - tst_msg("SubContext->h != %u (== %i)", h, sc->h); + tst_msg("SubPixmap->h != %u (== %i)", h, sc->h); return TST_FAILED; } if (sc->offset != 0) { - tst_msg("SubContext->offset != 0"); + tst_msg("SubPixmap->offset != 0"); return TST_FAILED; } if (sc->pixel_type != GP_PIXEL_RGB888) { - tst_msg("SubContext->pixel_type != GP_PIXEL_RGB888"); + tst_msg("SubPixmap->pixel_type != GP_PIXEL_RGB888"); return TST_FAILED; } if (sc->gamma != NULL) { - tst_msg("SubContext->gamma != NULL"); + tst_msg("SubPixmap->gamma != NULL"); return TST_FAILED; } @@ -151,68 +151,68 @@ static int subcontext_assert(const GP_Context *c, const GP_Context *sc, return 0; } -static int SubContext_Alloc_Free(void) +static int SubPixmap_Alloc_Free(void) { - GP_Context *c, *sc; + GP_Pixmap *c, *sc; int ret; - c = GP_ContextAlloc(300, 300, GP_PIXEL_RGB888); + c = GP_PixmapAlloc(300, 300, GP_PIXEL_RGB888); if (c == NULL) { - tst_msg("GP_ContextAlloc() failed"); + tst_msg("GP_PixmapAlloc() failed"); return TST_UNTESTED; } - sc = GP_SubContextAlloc(c, 100, 100, 100, 100); + sc = GP_SubPixmapAlloc(c, 100, 100, 100, 100); if (sc == NULL) { - GP_ContextFree(c); + GP_PixmapFree(c); return TST_FAILED; } - ret = subcontext_assert(c, sc, 100, 100); + ret = subpixmap_assert(c, sc, 100, 100); if (ret) return ret; - GP_ContextFree(c); - GP_ContextFree(sc); + GP_PixmapFree(c); + GP_PixmapFree(sc); return TST_SUCCESS; } -static int SubContext_Create(void) +static int SubPixmap_Create(void) { - GP_Context *c, sc; + GP_Pixmap *c, sc; int ret; - c = GP_ContextAlloc(300, 300, GP_PIXEL_RGB888); + c = GP_PixmapAlloc(300, 300, GP_PIXEL_RGB888); if (c == NULL) { - tst_msg("GP_ContextAlloc() failed"); + tst_msg("GP_PixmapAlloc() failed"); return TST_UNTESTED; } - GP_SubContext(c, &sc, 100, 100, 100, 100); + GP_SubPixmap(c, &sc, 100, 100, 100, 100); - ret = subcontext_assert(c, &sc, 100, 100); + ret = subpixmap_assert(c, &sc, 100, 100); if (ret) return ret; - GP_ContextFree(c); + GP_PixmapFree(c); return TST_SUCCESS; } -static int context_zero_w(void) +static int pixmap_zero_w(void) { - GP_Context *c; + GP_Pixmap *c; - c = GP_ContextAlloc(0, 200, GP_PIXEL_G8); + c = GP_PixmapAlloc(0, 200, GP_PIXEL_G8); if (c != NULL) { - tst_msg("Context with zero width successfuly allocated"); + tst_msg("Pixmap with zero width successfuly allocated"); return TST_FAILED; } @@ -224,14 +224,14 @@ static int context_zero_w(void) return TST_SUCCESS; } -static int context_zero_h(void) +static int pixmap_zero_h(void) { - GP_Context *c; + GP_Pixmap *c; - c = GP_ContextAlloc(200, 0, GP_PIXEL_G8); + c = GP_PixmapAlloc(200, 0, GP_PIXEL_G8); if (c != NULL) { - tst_msg("Context with zero height successfuly allocated"); + tst_msg("Pixmap with zero height successfuly allocated"); return TST_FAILED; } @@ -243,14 +243,14 @@ static int context_zero_h(void) return TST_SUCCESS; } -static int context_invalid_pixeltype1(void) +static int pixmap_invalid_pixeltype1(void) { - GP_Context *c; + GP_Pixmap *c; - c = GP_ContextAlloc(100, 100, -1); + c = GP_PixmapAlloc(100, 100, -1); if (c != NULL) { - tst_msg("Context with invalid pixel type (-1) succesfully allocated"); + tst_msg("Pixmap with invalid pixel type (-1) succesfully allocated"); return TST_FAILED; } @@ -262,14 +262,14 @@ static int context_invalid_pixeltype1(void) return TST_SUCCESS; } -static int context_invalid_pixeltype2(void) +static int pixmap_invalid_pixeltype2(void) { - GP_Context *c; + GP_Pixmap *c; - c = GP_ContextAlloc(100, 100, GP_PIXEL_MAX + 1000); + c = GP_PixmapAlloc(100, 100, GP_PIXEL_MAX + 1000); if (c != NULL) { - tst_msg("Context with invalid pixel type (-1) succesfully allocated"); + tst_msg("Pixmap with invalid pixel type (-1) succesfully allocated"); return TST_FAILED; } @@ -282,23 +282,23 @@ static int context_invalid_pixeltype2(void) } const struct tst_suite tst_suite = { - .suite_name = "Context Testsuite", + .suite_name = "Pixmap Testsuite", .tests = { - {.name = "Context Alloc Free", .tst_fn = Context_Alloc_Free, + {.name = "Pixmap Alloc Free", .tst_fn = Pixmap_Alloc_Free, .flags = TST_CHECK_MALLOC}, - {.name = "SubContext Alloc Free", - .tst_fn = SubContext_Alloc_Free, + {.name = "SubPixmap Alloc Free", + .tst_fn = SubPixmap_Alloc_Free, .flags = TST_CHECK_MALLOC}, - {.name = "SubContext Create", - .tst_fn = SubContext_Create}, - {.name = "Context Create w = 0", - .tst_fn = context_zero_w}, - {.name = "Context Create h = 0", - .tst_fn = context_zero_h}, - {.name = "Context Create pixel_type = -1", - .tst_fn = context_invalid_pixeltype1}, - {.name = "Context Create invalid pixel_type", - .tst_fn = context_invalid_pixeltype2}, + {.name = "SubPixmap Create", + .tst_fn = SubPixmap_Create}, + {.name = "Pixmap Create w = 0", + .tst_fn = pixmap_zero_w}, + {.name = "Pixmap Create h = 0", + .tst_fn = pixmap_zero_h}, + {.name = "Pixmap Create pixel_type = -1", + .tst_fn = pixmap_invalid_pixeltype1}, + {.name = "Pixmap Create invalid pixel_type", + .tst_fn = pixmap_invalid_pixeltype2}, {.name = NULL}, } }; diff --git a/tests/core/runtest.sh b/tests/core/runtest.sh index b3039a36..e2486822 100755 --- a/tests/core/runtest.sh +++ b/tests/core/runtest.sh @@ -12,4 +12,4 @@ export LIBC_FATAL_STDERR_=1 TEST="$1" shift -LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ "./$TEST" "$@" +LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ gdb "./$TEST" "$@" diff --git a/tests/core/test_list.txt b/tests/core/test_list.txt index 1ff15be3..7ca755cb 100644 --- a/tests/core/test_list.txt +++ b/tests/core/test_list.txt @@ -1,6 +1,6 @@ # Core testsuite WritePixel.gen -Context +Pixmap Pixel GetSetBits.gen GetPutPixel.gen diff --git a/tests/drivers/framebuffer_test.c b/tests/drivers/framebuffer_test.c index 518d3b4a..ee788993 100644 --- a/tests/drivers/framebuffer_test.c +++ b/tests/drivers/framebuffer_test.c @@ -35,30 +35,30 @@ #include #include -static void draw(GP_Context *context, int x, int y, int l) +static void draw(GP_Pixmap *pixmap, int x, int y, int l) { int x2, y2, x3, y3; GP_Pixel red, blue, green; - red = GP_RGBToContextPixel(255, 0, 0, context); - blue = GP_RGBToContextPixel(0, 0, 255, context); - green = GP_RGBToContextPixel(0, 255, 0, context); + red = GP_RGBToPixmapPixel(255, 0, 0, pixmap); + blue = GP_RGBToPixmapPixel(0, 0, 255, pixmap); + green = GP_RGBToPixmapPixel(0, 255, 0, pixmap); x2 = x + l/2; y2 = y + sqrt(2)/2 * l; x3 = x - l/2; y3 = y2; - GP_FillTriangle(context, x, y, x2, y2, x + l, y, red); - GP_FillTriangle(context, x, y, x3, y3, x - l, y, green); - GP_FillTriangle(context, x2, y2, x3, y3, x, y + sqrt(2) * l, blue); + GP_FillTriangle(pixmap, x, y, x2, y2, x + l, y, red); + GP_FillTriangle(pixmap, x, y, x3, y3, x - l, y, green); + GP_FillTriangle(pixmap, x2, y2, x3, y3, x, y + sqrt(2) * l, blue); } int main(void) { GP_Backend *backend; - GP_Context *context; + GP_Pixmap *pixmap; GP_TextStyle style; GP_SetDebugLevel(10); @@ -70,7 +70,7 @@ int main(void) return 1; } - context = backend->context; + pixmap = backend->pixmap; GP_DefaultTextStyle(&style); @@ -79,20 +79,20 @@ int main(void) GP_Pixel gray, black; - gray = GP_RGBToContextPixel(200, 200, 200, context); - black = GP_RGBToContextPixel(0, 0, 0, context); + gray = GP_RGBToPixmapPixel(200, 200, 200, pixmap); + black = GP_RGBToPixmapPixel(0, 0, 0, pixmap); const char *text = "Framebuffer test"; - GP_Fill(context, gray); - GP_Line(context, 0, 0, context->w, context->h, black); - GP_Line(context, 0, context->h, context->w, 0, black); - GP_Text(context, &style, - (context->w - GP_TextWidth(&style, text))/2, + GP_Fill(pixmap, gray); + GP_Line(pixmap, 0, 0, pixmap->w, pixmap->h, black); + GP_Line(pixmap, 0, pixmap->h, pixmap->w, 0, black); + GP_Text(pixmap, &style, + (pixmap->w - GP_TextWidth(&style, text))/2, 16, GP_ALIGN_RIGHT|GP_VALIGN_BELOW, black, gray, text); - draw(context, context->w / 2, 2.00 * context->h / 3, 60); + draw(pixmap, pixmap->w / 2, 2.00 * pixmap->h / 3, 60); GP_BackendFlip(backend); diff --git a/tests/filters/APICoverage.gen.c.t b/tests/filters/APICoverage.gen.c.t index f7c97e0c..e5f29a6e 100644 --- a/tests/filters/APICoverage.gen.c.t +++ b/tests/filters/APICoverage.gen.c.t @@ -14,122 +14,122 @@ #include #include -#include +#include #include #include "tst_test.h" @ API_List = [ -@ ['Brightness', '', 'GP_Context:in', 'GP_Context:out', +@ ['Brightness', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'float:p', 'GP_ProgressCallback'], -@ ['BrightnessAlloc', '', 'GP_Context:in', +@ ['BrightnessAlloc', '', 'GP_Pixmap:in', @ 'float:p', 'GP_ProgressCallback'], @ -@ ['Contrast', '', 'GP_Context:in', 'GP_Context:out', +@ ['Contrast', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'float:p', 'GP_ProgressCallback'], -@ ['ContrastAlloc', '', 'GP_Context:in', +@ ['ContrastAlloc', '', 'GP_Pixmap:in', @ 'float:p', 'GP_ProgressCallback'], @ -@ ['Invert', '', 'GP_Context:in', 'GP_Context:out', +@ ['Invert', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_ProgressCallback'], -@ ['InvertAlloc', '', 'GP_Context:in', +@ ['InvertAlloc', '', 'GP_Pixmap:in', @ 'GP_ProgressCallback'], @ -@ ['MirrorH', '', 'GP_Context:in', 'GP_Context:out', +@ ['MirrorH', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_ProgressCallback'], -@ ['MirrorHAlloc', '', 'GP_Context:in', 'GP_ProgressCallback'], +@ ['MirrorHAlloc', '', 'GP_Pixmap:in', 'GP_ProgressCallback'], @ -@ ['MirrorV', '', 'GP_Context:in', 'GP_Context:out', +@ ['MirrorV', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_ProgressCallback'], -@ ['MirrorVAlloc', '', 'GP_Context:in', 'GP_ProgressCallback'], +@ ['MirrorVAlloc', '', 'GP_Pixmap:in', 'GP_ProgressCallback'], @ -@ ['Rotate90', '', 'GP_Context:in', 'GP_Context:out', +@ ['Rotate90', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_ProgressCallback'], -@ ['Rotate90Alloc', '', 'GP_Context:in', 'GP_ProgressCallback'], +@ ['Rotate90Alloc', '', 'GP_Pixmap:in', 'GP_ProgressCallback'], @ -@ ['Rotate180', '', 'GP_Context:in', 'GP_Context:out', +@ ['Rotate180', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_ProgressCallback'], -@ ['Rotate180Alloc', '', 'GP_Context:in', 'GP_ProgressCallback'], +@ ['Rotate180Alloc', '', 'GP_Pixmap:in', 'GP_ProgressCallback'], @ -@ ['Rotate270', '', 'GP_Context:in', 'GP_Context:out', +@ ['Rotate270', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_ProgressCallback'], -@ ['Rotate270Alloc', '', 'GP_Context:in', 'GP_ProgressCallback'], +@ ['Rotate270Alloc', '', 'GP_Pixmap:in', 'GP_ProgressCallback'], @ -@ ['Symmetry', 'H', 'GP_Context:in', 'GP_Context:out', +@ ['Symmetry', 'H', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_MIRROR_H', 'GP_ProgressCallback'], -@ ['SymmetryAlloc', 'H', 'GP_Context:in', 'GP_MIRROR_H', +@ ['SymmetryAlloc', 'H', 'GP_Pixmap:in', 'GP_MIRROR_H', @ 'GP_ProgressCallback'], @ -@ ['Symmetry', 'V', 'GP_Context:in', 'GP_Context:out', +@ ['Symmetry', 'V', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_MIRROR_V', 'GP_ProgressCallback'], -@ ['SymmetryAlloc', 'V', 'GP_Context:in', 'GP_MIRROR_V', +@ ['SymmetryAlloc', 'V', 'GP_Pixmap:in', 'GP_MIRROR_V', @ 'GP_ProgressCallback'], @ -@ ['Symmetry', '90', 'GP_Context:in', 'GP_Context:out', +@ ['Symmetry', '90', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_ROTATE_90', 'GP_ProgressCallback'], -@ ['SymmetryAlloc', '90', 'GP_Context:in', 'GP_ROTATE_90', +@ ['SymmetryAlloc', '90', 'GP_Pixmap:in', 'GP_ROTATE_90', @ 'GP_ProgressCallback'], @ -@ ['Symmetry', '180', 'GP_Context:in', 'GP_Context:out', +@ ['Symmetry', '180', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_ROTATE_180', 'GP_ProgressCallback'], -@ ['SymmetryAlloc', '180', 'GP_Context:in', 'GP_ROTATE_180', +@ ['SymmetryAlloc', '180', 'GP_Pixmap:in', 'GP_ROTATE_180', @ 'GP_ProgressCallback'], @ -@ ['Symmetry', '270', 'GP_Context:in', 'GP_Context:out', +@ ['Symmetry', '270', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_ROTATE_270', 'GP_ProgressCallback'], -@ ['SymmetryAlloc', '270', 'GP_Context:in', 'GP_ROTATE_270', +@ ['SymmetryAlloc', '270', 'GP_Pixmap:in', 'GP_ROTATE_270', @ 'GP_ProgressCallback'], @ -@ ['Convolution', '', 'GP_Context:in', 'GP_Context:out', +@ ['Convolution', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_FilterKernel2D:kernel', 'GP_ProgressCallback'], -@ ['ConvolutionAlloc', '', 'GP_Context:in', +@ ['ConvolutionAlloc', '', 'GP_Pixmap:in', @ 'GP_FilterKernel2D:kernel', 'GP_ProgressCallback'], @ -@ ['GaussianBlur', '', 'GP_Context:in', 'GP_Context:out', +@ ['GaussianBlur', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'float:sigma_x', 'float:sigma_y', 'GP_ProgressCallback'], -@ ['GaussianBlurAlloc', '', 'GP_Context:in', 'float:sigma_x', +@ ['GaussianBlurAlloc', '', 'GP_Pixmap:in', 'float:sigma_x', @ 'float:sigma_y', 'GP_ProgressCallback'], @ -@ ['GaussianNoiseAdd', '', 'GP_Context:in', 'GP_Context:out', +@ ['GaussianNoiseAdd', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'float:sigma', 'float:mu', 'GP_ProgressCallback'], -@ ['GaussianNoiseAddAlloc', '', 'GP_Context:in', +@ ['GaussianNoiseAddAlloc', '', 'GP_Pixmap:in', @ 'float:sigma', 'float:mu', 'GP_ProgressCallback'], @ -@ ['Median', '', 'GP_Context:in', 'GP_Context:out', +@ ['Median', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'int:xmed', 'int:ymed', 'GP_ProgressCallback'], -@ ['MedianAlloc', '', 'GP_Context:in', +@ ['MedianAlloc', '', 'GP_Pixmap:in', @ 'int:xmed', 'int:ymed', 'GP_ProgressCallback'], @ -@ ['WeightedMedian', '', 'GP_Context:in', 'GP_Context:out', +@ ['WeightedMedian', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_MedianWeights:weights', 'GP_ProgressCallback'], -@ ['WeightedMedianAlloc', '', 'GP_Context:in', +@ ['WeightedMedianAlloc', '', 'GP_Pixmap:in', @ 'GP_MedianWeights:weights', 'GP_ProgressCallback'], @ -@ ['Sigma', '', 'GP_Context:in', 'GP_Context:out', +@ ['Sigma', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'int:xrad', 'int:yrad', 'int:min', 'float:sigma', @ 'GP_ProgressCallback'], -@ ['SigmaAlloc', '', 'GP_Context:in', +@ ['SigmaAlloc', '', 'GP_Pixmap:in', @ 'int:xrad', 'int:yrad', 'int:min', 'float:sigma', @ 'GP_ProgressCallback'], @ -@ ['ResizeNN', '', 'GP_Context:in', 'GP_Context:out', +@ ['ResizeNN', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_ProgressCallback'], -@ ['ResizeNNAlloc', '', 'GP_Context:in', 'int:w', 'int:h', +@ ['ResizeNNAlloc', '', 'GP_Pixmap:in', 'int:w', 'int:h', @ 'GP_ProgressCallback'], @ -@ ['FloydSteinberg', '', 'GP_Context:in', 'GP_Context:out', +@ ['FloydSteinberg', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_ProgressCallback'], -@ ['FloydSteinbergAlloc', '', 'GP_Context:in', 'GP_PixelType:G8', +@ ['FloydSteinbergAlloc', '', 'GP_Pixmap:in', 'GP_PixelType:G8', @ 'GP_ProgressCallback'], @ -@ ['HilbertPeano', '', 'GP_Context:in', 'GP_Context:out', +@ ['HilbertPeano', '', 'GP_Pixmap:in', 'GP_Pixmap:out', @ 'GP_ProgressCallback'], -@ ['HilbertPeanoAlloc', '', 'GP_Context:in', 'GP_PixelType:G8', +@ ['HilbertPeanoAlloc', '', 'GP_Pixmap:in', 'GP_PixelType:G8', @ 'GP_ProgressCallback'], @ ] @ -@ def prep_context(id): - GP_Context *{{ id }} = GP_ContextAlloc(331, 331, pt); +@ def prep_pixmap(id): + GP_Pixmap *{{ id }} = GP_PixmapAlloc(331, 331, pt); @ @ def prep_float(id): float {{ id }} = 1; @@ -174,8 +174,8 @@ @ @ @ def prep_param(param): -@ if (param.split(':', 1)[0] == 'GP_Context'): -{@ prep_context(param.split(':', 1)[1]) @} +@ if (param.split(':', 1)[0] == 'GP_Pixmap'): +{@ prep_pixmap(param.split(':', 1)[1]) @} @ if (param.split(':', 1)[0] == 'float'): {@ prep_float(param.split(':', 1)[1]) @} @ if (param.split(':', 1)[0] == 'int'): @@ -209,7 +209,7 @@ static int filter_{{ fn[0] }}_{{ fn[1] }}(GP_PixelType pt) @ for param in fn[1:]: {@ prep_param(param) @} @ if 'Alloc' in fn[0]: - GP_Context *res; + GP_Pixmap *res; @ else: int res; @ end diff --git a/tests/filters/FilterMirrorH.c b/tests/filters/FilterMirrorH.c index 509da345..665bc4c3 100644 --- a/tests/filters/FilterMirrorH.c +++ b/tests/filters/FilterMirrorH.c @@ -22,7 +22,7 @@ #include -#include +#include #include #include "tst_test.h" @@ -45,20 +45,20 @@ struct testcase { static int test_mirror_h(struct testcase *t) { - GP_Context src, *c; + GP_Pixmap src, *c; int err; - /* Initialize source context */ - GP_ContextInit(&src, t->w, t->h, t->pixel_type, t->src); + /* Initialize source pixmap */ + GP_PixmapInit(&src, t->w, t->h, t->pixel_type, t->src); - /* Set offset to emulate non-byte aligned subcontexts */ + /* Set offset to emulate non-byte aligned subpixmaps */ src.offset = t->offset; /* Test with allocated destination */ - c = GP_ContextAlloc(t->w, t->h, t->pixel_type); + c = GP_PixmapAlloc(t->w, t->h, t->pixel_type); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } @@ -66,7 +66,7 @@ static int test_mirror_h(struct testcase *t) err = compare_buffers(t->res, c); - GP_ContextFree(c); + GP_PixmapFree(c); /* And with in-place variant */ // GP_FilterMirrorH(&src, &src, NULL); @@ -221,12 +221,12 @@ static GP_ProgressCallback abort_callback = { static int test_abort(void) { int ret; - GP_Context *c; + GP_Pixmap *c; - c = GP_ContextAlloc(10, 10, GP_PIXEL_G8); + c = GP_PixmapAlloc(10, 10, GP_PIXEL_G8); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } @@ -250,20 +250,20 @@ static int all_pixels(void) GP_Pixel pixel_type; for (pixel_type = 1; pixel_type < GP_PIXEL_MAX; pixel_type++) { - GP_Context *c; + GP_Pixmap *c; tst_msg("Trying pixel %s", GP_PixelTypeName(pixel_type)); - c = GP_ContextAlloc(10, 10, pixel_type); + c = GP_PixmapAlloc(10, 10, pixel_type); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } GP_FilterMirrorH(c, c, NULL); - GP_ContextFree(c); + GP_PixmapFree(c); } return TST_SUCCESS; diff --git a/tests/filters/FiltersCompare.gen.c.t b/tests/filters/FiltersCompare.gen.c.t index 61457c4e..0cfa6a42 100644 --- a/tests/filters/FiltersCompare.gen.c.t +++ b/tests/filters/FiltersCompare.gen.c.t @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -109,10 +109,10 @@ @ @ def apply_filter(filter): @ if 'dst' in filter[1]: - dst = GP_ContextCopy(src, GP_COPY_WITH_PIXELS); + dst = GP_PixmapCopy(src, GP_COPY_WITH_PIXELS); if (GP_Filter{{ filter[0] }}({{ arr_to_params(filter[1]) }})) { int err = errno; - GP_ContextFree(dst); + GP_PixmapFree(dst); dst = NULL; errno = err; } @@ -125,8 +125,8 @@ @ for fs in compare_list: static int compare_{{ fs[0] }}(GP_PixelType pt) { - GP_Context *src = GP_ContextAlloc(134, 1072, pt); - GP_Context *dst, *ref; + GP_Pixmap *src = GP_PixmapAlloc(134, 1072, pt); + GP_Pixmap *dst, *ref; int fail = 0; errno = 0; @@ -136,7 +136,7 @@ static int compare_{{ fs[0] }}(GP_PixelType pt) return TST_UNTESTED; } - /* randomize context content */ + /* randomize pixmap content */ GP_FilterGaussianNoiseAdd(src, src, 10, 0, NULL); /* Create reference result */ @@ -144,7 +144,7 @@ static int compare_{{ fs[0] }}(GP_PixelType pt) ref = dst; if (ref == NULL) { - GP_ContextFree(src); + GP_PixmapFree(src); switch (errno) { case ENOSYS: tst_msg("Not implemented"); @@ -161,16 +161,16 @@ static int compare_{{ fs[0] }}(GP_PixelType pt) @ for i in fs[2:]: {@ apply_filter(i) @} - if (!GP_ContextEqual(ref, dst)) { + if (!GP_PixmapEqual(ref, dst)) { fail++; tst_msg("Results for {{ fs[1][0] }} and {{ i[0] }} differs"); } - GP_ContextFree(dst); + GP_PixmapFree(dst); @ end - GP_ContextFree(src); - GP_ContextFree(ref); + GP_PixmapFree(src); + GP_PixmapFree(ref); if (fail) { tst_msg("%i failure(s)", fail); diff --git a/tests/filters/LinearConvolution.c b/tests/filters/LinearConvolution.c index 9d685c9e..c786772a 100644 --- a/tests/filters/LinearConvolution.c +++ b/tests/filters/LinearConvolution.c @@ -24,14 +24,14 @@ #include #include -#include +#include #include #include #include "tst_test.h" static int load_resources(const char *path1, const char *path2, - GP_Context **c1, GP_Context **c2) + GP_Pixmap **c1, GP_Pixmap **c2) { *c1 = GP_LoadImage(path1, NULL); *c2 = GP_LoadImage(path2, NULL); @@ -46,7 +46,7 @@ static int load_resources(const char *path1, const char *path2, static int test_lin_conv_box_3x3(void) { - GP_Context *in, *out; + GP_Pixmap *in, *out; int ret; ret = load_resources("in.pgm", "out.pgm", &in, &out); @@ -81,7 +81,7 @@ static int test_lin_conv_box_3x3(void) static int test_h_lin_conv_box_3_raw(void) { - GP_Context *in, *out; + GP_Pixmap *in, *out; int ret; ret = load_resources("in.pgm", "out.pgm", &in, &out); @@ -106,7 +106,7 @@ static int test_h_lin_conv_box_3_raw(void) static int test_v_lin_conv_box_3_raw(void) { - GP_Context *in, *out; + GP_Pixmap *in, *out; int ret; ret = load_resources("in.pgm", "out.pgm", &in, &out); diff --git a/tests/filters/common.c b/tests/filters/common.c index 86d129f4..e14fca36 100644 --- a/tests/filters/common.c +++ b/tests/filters/common.c @@ -35,7 +35,7 @@ static void dump_buffer(const char *pattern, int w, int h) } } -void dump_buffers(const char *pattern, const GP_Context *c) +void dump_buffers(const char *pattern, const GP_Pixmap *c) { printf("Expected pattern:\n"); dump_buffer(pattern, c->w, c->h); @@ -66,7 +66,7 @@ void dump_buffers(const char *pattern, const GP_Context *c) } } -int compare_buffers(const char *pattern, const GP_Context *c) +int compare_buffers(const char *pattern, const GP_Pixmap *c) { GP_Size x, y; int err = 0; diff --git a/tests/filters/common.h b/tests/filters/common.h index 65b9d196..b55b81a0 100644 --- a/tests/filters/common.h +++ b/tests/filters/common.h @@ -23,10 +23,10 @@ #ifndef __COMMON_H__ #define __COMMON_H__ -#include +#include -void dump_buffers(const char *pattern, const GP_Context *c); +void dump_buffers(const char *pattern, const GP_Pixmap *c); -int compare_buffers(const char *pattern, const GP_Context *c); +int compare_buffers(const char *pattern, const GP_Pixmap *c); #endif /* __COMMON_H__ */ diff --git a/tests/gfx/APICoverage.gen.c.t b/tests/gfx/APICoverage.gen.c.t index 86252389..09a8ccf4 100644 --- a/tests/gfx/APICoverage.gen.c.t +++ b/tests/gfx/APICoverage.gen.c.t @@ -8,53 +8,53 @@ #include -#include +#include #include #include "tst_test.h" @ API_List = [ -@ ['Fill', 'GP_Context:in', 'int:pixel'], +@ ['Fill', 'GP_Pixmap:in', 'int:pixel'], @ -@ ['HLine', 'GP_Context:in', 'int:x0', 'int:x1', 'int:y', 'int:pixel'], -@ ['VLine', 'GP_Context:in', 'int:x', 'int:y0', 'int:y1', 'int:pixel'], +@ ['HLine', 'GP_Pixmap:in', 'int:x0', 'int:x1', 'int:y', 'int:pixel'], +@ ['VLine', 'GP_Pixmap:in', 'int:x', 'int:y0', 'int:y1', 'int:pixel'], @ -@ ['Line', 'GP_Context:in', 'int:x0', 'int:y0', +@ ['Line', 'GP_Pixmap:in', 'int:x0', 'int:y0', @ 'int:x1', 'int:y1', 'int:pixel'], @ -@ ['Circle', 'GP_Context:in', 'int:xcenter', 'int:ycenter', +@ ['Circle', 'GP_Pixmap:in', 'int:xcenter', 'int:ycenter', @ 'int:r', 'int:pixel'], -@ ['FillCircle', 'GP_Context:in', 'int:xcenter', 'int:ycenter', +@ ['FillCircle', 'GP_Pixmap:in', 'int:xcenter', 'int:ycenter', @ 'int:r', 'int:pixel'], @ -@ ['Ellipse', 'GP_Context:in', 'int:xcenter', 'int:ycenter', +@ ['Ellipse', 'GP_Pixmap:in', 'int:xcenter', 'int:ycenter', @ 'int:a', 'int:b', 'int:pixel'], -@ ['FillEllipse', 'GP_Context:in', 'int:xcenter', 'int:ycenter', +@ ['FillEllipse', 'GP_Pixmap:in', 'int:xcenter', 'int:ycenter', @ 'int:a', 'int:b', 'int:pixel'], @ -@ ['Ring', 'GP_Context:in', 'int:xc', 'int:yc', +@ ['Ring', 'GP_Pixmap:in', 'int:xc', 'int:yc', @ 'int:r1', 'int:r2', 'int:pixel'], -@ ['FillRing', 'GP_Context:in', 'int:xc', 'int:yc', +@ ['FillRing', 'GP_Pixmap:in', 'int:xc', 'int:yc', @ 'int:r1', 'int:r2', 'int:pixel'], @ -@ ['Rect', 'GP_Context:in', 'int:x0', 'int:y0', +@ ['Rect', 'GP_Pixmap:in', 'int:x0', 'int:y0', @ 'int:x1', 'int:y1', 'int:pixel'], -@ ['FillRect', 'GP_Context:in', 'int:x0', 'int:y0', +@ ['FillRect', 'GP_Pixmap:in', 'int:x0', 'int:y0', @ 'int:x1', 'int:y1', 'int:pixel'], @ -@ ['Triangle', 'GP_Context:in', 'int:x0', 'int:y0', +@ ['Triangle', 'GP_Pixmap:in', 'int:x0', 'int:y0', @ 'int:x1', 'int:y1', 'int:x2', 'int:y2', 'int:pixel'], -@ ['FillTriangle', 'GP_Context:in', 'int:x0', 'int:y0', +@ ['FillTriangle', 'GP_Pixmap:in', 'int:x0', 'int:y0', @ 'int:x1', 'int:y1', 'int:x2', 'int:y2', 'int:pixel'], @ -@ ['Tetragon', 'GP_Context:in', 'int:x0', 'int:y0', 'int:x1', 'int:y1', +@ ['Tetragon', 'GP_Pixmap:in', 'int:x0', 'int:y0', 'int:x1', 'int:y1', @ 'int:x2', 'int:y2', 'int:x3', 'int:y3', 'int:pixel'], -@ ['FillTetragon', 'GP_Context:in', 'int:x0', 'int:y0', 'int:x1', 'int:y1', +@ ['FillTetragon', 'GP_Pixmap:in', 'int:x0', 'int:y0', 'int:x1', 'int:y1', @ 'int:x2', 'int:y2', 'int:x3', 'int:y3', 'int:pixel'], @ ] @ -@ def prep_context(id, pt): -GP_Context *{{ id }} = GP_ContextAlloc(331, 331, GP_PIXEL_{{ pt.name }}); +@ def prep_pixmap(id, pt): +GP_Pixmap *{{ id }} = GP_PixmapAlloc(331, 331, GP_PIXEL_{{ pt.name }}); @ end @ @ def prep_int(id): @@ -62,8 +62,8 @@ int {{ id }} = 2; @ end @ @ def prep_param(param, pt): -@ if (param.split(':', 1)[0] == 'GP_Context'): -{@ prep_context(param.split(':', 1)[1], pt) @} +@ if (param.split(':', 1)[0] == 'GP_Pixmap'): +{@ prep_pixmap(param.split(':', 1)[1], pt) @} @ if (param.split(':', 1)[0] == 'float'): {@ prep_float(param.split(':', 1)[1]) @} @ if (param.split(':', 1)[0] == 'int'): diff --git a/tests/gfx/Circle.c b/tests/gfx/Circle.c index bb6f4e1c..b3f0a96c 100644 --- a/tests/gfx/Circle.c +++ b/tests/gfx/Circle.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -44,13 +44,13 @@ struct testcase { static int test_circle(const struct testcase *t) { - GP_Context *c; + GP_Pixmap *c; int err; - c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + c = GP_PixmapAlloc(t->w, t->h, GP_PIXEL_G8); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } diff --git a/tests/gfx/CircleSeg.c b/tests/gfx/CircleSeg.c index dfb099bb..b398c9af 100644 --- a/tests/gfx/CircleSeg.c +++ b/tests/gfx/CircleSeg.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -160,13 +160,13 @@ static const char circle_r_2_s_1_4_11x11[] = { static int test_circle(const char *pattern, GP_Size w, GP_Size h, GP_Coord x, GP_Coord y, const int r, uint8_t seg_flag) { - GP_Context *c; + GP_Pixmap *c; int err; - c = GP_ContextAlloc(w, h, GP_PIXEL_G8); + c = GP_PixmapAlloc(w, h, GP_PIXEL_G8); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } diff --git a/tests/gfx/Ellipse.c b/tests/gfx/Ellipse.c index 5b0add6b..084609c8 100644 --- a/tests/gfx/Ellipse.c +++ b/tests/gfx/Ellipse.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -45,13 +45,13 @@ struct testcase { static int test_ellipse(const struct testcase *t) { - GP_Context *c; + GP_Pixmap *c; int err; - c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + c = GP_PixmapAlloc(t->w, t->h, GP_PIXEL_G8); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } diff --git a/tests/gfx/FillCircle.c b/tests/gfx/FillCircle.c index e885d4a2..49e0b9fd 100644 --- a/tests/gfx/FillCircle.c +++ b/tests/gfx/FillCircle.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -44,13 +44,13 @@ struct testcase { static int test_circle(const struct testcase *t) { - GP_Context *c; + GP_Pixmap *c; int err; - c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + c = GP_PixmapAlloc(t->w, t->h, GP_PIXEL_G8); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } diff --git a/tests/gfx/FillEllipse.c b/tests/gfx/FillEllipse.c index 84bb7d7f..5d5f59d5 100644 --- a/tests/gfx/FillEllipse.c +++ b/tests/gfx/FillEllipse.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -45,13 +45,13 @@ struct testcase { static int test_ellipse(const struct testcase *t) { - GP_Context *c; + GP_Pixmap *c; int err; - c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + c = GP_PixmapAlloc(t->w, t->h, GP_PIXEL_G8); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } diff --git a/tests/gfx/FillRect.c b/tests/gfx/FillRect.c index 87b720b4..520a8653 100644 --- a/tests/gfx/FillRect.c +++ b/tests/gfx/FillRect.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -45,13 +45,13 @@ struct testcase { static int test_rect(const struct testcase *t) { - GP_Context *c; + GP_Pixmap *c; int err; - c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + c = GP_PixmapAlloc(t->w, t->h, GP_PIXEL_G8); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } @@ -335,52 +335,52 @@ const struct tst_suite tst_suite = { .tst_fn = test_rect, .data = &testcase_rect_9b}, - {.name = "FillRect x1,y1 out of context", + {.name = "FillRect x1,y1 out of pixmap", .tst_fn = test_rect, .data = &testcase_rect_9lu, .timeout = 2}, - {.name = "FillRect x1,y2 out of context", + {.name = "FillRect x1,y2 out of pixmap", .tst_fn = test_rect, .data = &testcase_rect_9ld, .timeout = 2}, - {.name = "FillRect x2,y1 out of context", + {.name = "FillRect x2,y1 out of pixmap", .tst_fn = test_rect, .data = &testcase_rect_9ru, .timeout = 2}, - {.name = "FillRect x2,y2 out of context", + {.name = "FillRect x2,y2 out of pixmap", .tst_fn = test_rect, .data = &testcase_rect_9rd, .timeout = 2}, - {.name = "FillRect x1 out of context", + {.name = "FillRect x1 out of pixmap", .tst_fn = test_rect, .data = &testcase_rect_9r, .timeout = 2}, - {.name = "FillRect x2 out of context", + {.name = "FillRect x2 out of pixmap", .tst_fn = test_rect, .data = &testcase_rect_9l, .timeout = 2}, - {.name = "FillRect y1 out of context", + {.name = "FillRect y1 out of pixmap", .tst_fn = test_rect, .data = &testcase_rect_9u, .timeout = 2}, - {.name = "FillRect y2 out of context", + {.name = "FillRect y2 out of pixmap", .tst_fn = test_rect, .data = &testcase_rect_9d, .timeout = 2}, - {.name = "FillRect rect out of context 1", + {.name = "FillRect rect out of pixmap 1", .tst_fn = test_rect, .data = &testcase_rect_0a, .timeout = 2}, - {.name = "FillRect rect out of context 2", + {.name = "FillRect rect out of pixmap 2", .tst_fn = test_rect, .data = &testcase_rect_0b, .timeout = 2}, diff --git a/tests/gfx/HLine.c b/tests/gfx/HLine.c index db0ecb2e..986d9c42 100644 --- a/tests/gfx/HLine.c +++ b/tests/gfx/HLine.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -48,13 +48,13 @@ struct testcase { static int test_hline(struct testcase *t) { - GP_Context *c; + GP_Pixmap *c; int err; - c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + c = GP_PixmapAlloc(t->w, t->h, GP_PIXEL_G8); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } diff --git a/tests/gfx/HLineAA.c b/tests/gfx/HLineAA.c index 3f679967..c1d3bc9f 100644 --- a/tests/gfx/HLineAA.c +++ b/tests/gfx/HLineAA.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -44,13 +44,13 @@ struct testcase { static int test_line(const struct testcase *t) { - GP_Context *c; + GP_Pixmap *c; int err; - c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + c = GP_PixmapAlloc(t->w, t->h, GP_PIXEL_G8); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } diff --git a/tests/gfx/Line.c b/tests/gfx/Line.c index fc806d7c..25524acb 100644 --- a/tests/gfx/Line.c +++ b/tests/gfx/Line.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -45,13 +45,13 @@ struct testcase { static int test_line(const struct testcase *t) { - GP_Context *c; + GP_Pixmap *c; int err; - c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + c = GP_PixmapAlloc(t->w, t->h, GP_PIXEL_G8); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } diff --git a/tests/gfx/LineAA.c b/tests/gfx/LineAA.c index 5373c24f..c559cf87 100644 --- a/tests/gfx/LineAA.c +++ b/tests/gfx/LineAA.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -45,13 +45,13 @@ struct testcase { static int test_line(const struct testcase *t) { - GP_Context *c; + GP_Pixmap *c; int err; - c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + c = GP_PixmapAlloc(t->w, t->h, GP_PIXEL_G8); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } diff --git a/tests/gfx/Polygon.c b/tests/gfx/Polygon.c index e0ff15c9..bfc8ae1a 100644 --- a/tests/gfx/Polygon.c +++ b/tests/gfx/Polygon.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -43,13 +43,13 @@ struct testcase { static int test_polygon(struct testcase *t) { - GP_Context *c; + GP_Pixmap *c; int err; - c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + c = GP_PixmapAlloc(t->w, t->h, GP_PIXEL_G8); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } diff --git a/tests/gfx/PutPixelAA.c b/tests/gfx/PutPixelAA.c index 22faee79..c771746a 100644 --- a/tests/gfx/PutPixelAA.c +++ b/tests/gfx/PutPixelAA.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -43,13 +43,13 @@ struct testcase { static int test_pixel(const struct testcase *t) { - GP_Context *c; + GP_Pixmap *c; int err; - c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + c = GP_PixmapAlloc(t->w, t->h, GP_PIXEL_G8); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } diff --git a/tests/gfx/VLine.c b/tests/gfx/VLine.c index 61640c34..ddbd0691 100644 --- a/tests/gfx/VLine.c +++ b/tests/gfx/VLine.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -48,13 +48,13 @@ struct testcase { static int test_vline(struct testcase *t) { - GP_Context *c; + GP_Pixmap *c; int err; - c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + c = GP_PixmapAlloc(t->w, t->h, GP_PIXEL_G8); if (c == NULL) { - tst_err("Failed to allocate context"); + tst_err("Failed to allocate pixmap"); return TST_UNTESTED; } diff --git a/tests/gfx/common.c b/tests/gfx/common.c index 86d129f4..e14fca36 100644 --- a/tests/gfx/common.c +++ b/tests/gfx/common.c @@ -35,7 +35,7 @@ static void dump_buffer(const char *pattern, int w, int h) } } -void dump_buffers(const char *pattern, const GP_Context *c) +void dump_buffers(const char *pattern, const GP_Pixmap *c) { printf("Expected pattern:\n"); dump_buffer(pattern, c->w, c->h); @@ -66,7 +66,7 @@ void dump_buffers(const char *pattern, const GP_Context *c) } } -int compare_buffers(const char *pattern, const GP_Context *c) +int compare_buffers(const char *pattern, const GP_Pixmap *c) { GP_Size x, y; int err = 0; diff --git a/tests/gfx/common.h b/tests/gfx/common.h index 65b9d196..b55b81a0 100644 --- a/tests/gfx/common.h +++ b/tests/gfx/common.h @@ -23,10 +23,10 @@ #ifndef __COMMON_H__ #define __COMMON_H__ -#include +#include -void dump_buffers(const char *pattern, const GP_Context *c); +void dump_buffers(const char *pattern, const GP_Pixmap *c); -int compare_buffers(const char *pattern, const GP_Context *c); +int compare_buffers(const char *pattern, const GP_Pixmap *c); #endif /* __COMMON_H__ */ diff --git a/tests/gfx/gfx_benchmark.c b/tests/gfx/gfx_benchmark.c index 4d5674ce..5b0256c2 100644 --- a/tests/gfx/gfx_benchmark.c +++ b/tests/gfx/gfx_benchmark.c @@ -20,14 +20,14 @@ * * *****************************************************************************/ -#include +#include #include #include "tst_test.h" static int bench_line(GP_PixelType type) { - GP_Context *img = GP_ContextAlloc(800, 600, type); + GP_Pixmap *img = GP_PixmapAlloc(800, 600, type); if (img == NULL) { tst_err("Malloc failed"); @@ -71,7 +71,7 @@ static int bench_line_32bpp(void) static int bench_circle(GP_PixelType type) { - GP_Context *img = GP_ContextAlloc(800, 600, type); + GP_Pixmap *img = GP_PixmapAlloc(800, 600, type); if (img == NULL) { tst_err("Malloc failed"); diff --git a/tests/loaders/GIF.c b/tests/loaders/GIF.c index e33847e3..dc803e29 100644 --- a/tests/loaders/GIF.c +++ b/tests/loaders/GIF.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include @@ -32,7 +32,7 @@ static int test_load_GIF(const char *path) { - GP_Context *img; + GP_Pixmap *img; errno = 0; @@ -49,7 +49,7 @@ static int test_load_GIF(const char *path) } } - GP_ContextFree(img); + GP_PixmapFree(img); return TST_SUCCESS; } diff --git a/tests/loaders/JPG.c b/tests/loaders/JPG.c index 67c34dd4..077eb1bb 100644 --- a/tests/loaders/JPG.c +++ b/tests/loaders/JPG.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include @@ -32,7 +32,7 @@ static int test_load_JPG(const char *path) { - GP_Context *img; + GP_Pixmap *img; errno = 0; @@ -53,41 +53,41 @@ static int test_load_JPG(const char *path) * TODO: check correct data. */ - GP_ContextFree(img); + GP_PixmapFree(img); return TST_SUCCESS; } static int test_save_JPG(GP_PixelType pixel_type) { - GP_Context *ctx; + GP_Pixmap *pixmap; int ret; - ctx = GP_ContextAlloc(100, 100, pixel_type); + pixmap = GP_PixmapAlloc(100, 100, pixel_type); - if (ctx == NULL) { - tst_msg("Failed to allocate context"); + if (pixmap == NULL) { + tst_msg("Failed to allocate pixmap"); return TST_UNTESTED; } errno = 0; - ret = GP_SaveJPG(ctx, "/dev/null", NULL); + ret = GP_SaveJPG(pixmap, "/dev/null", NULL); if (ret == 0) { tst_msg("Saved successfully"); - GP_ContextFree(ctx); + GP_PixmapFree(pixmap); return TST_SUCCESS; } switch (errno) { case ENOSYS: tst_msg("Not Implemented"); - GP_ContextFree(ctx); + GP_PixmapFree(pixmap); return TST_SKIPPED; default: tst_msg("Failed and errno is not ENOSYS (%i)", errno); - GP_ContextFree(ctx); + GP_PixmapFree(pixmap); return TST_FAILED; } } diff --git a/tests/loaders/Loader.h b/tests/loaders/Loader.h index ec1fe62b..475af5ec 100644 --- a/tests/loaders/Loader.h +++ b/tests/loaders/Loader.h @@ -32,14 +32,14 @@ struct testcase { char *path; }; -static int test_check(struct testcase *test, GP_Context *img) +static int test_check(struct testcase *test, GP_Pixmap *img) { unsigned int x, y, err = 0; if (img->w != test->w || img->h != test->h) { tst_msg("Invalid image size have %ux%u expected %ux%u", img->w, img->h, test->w, test->h); - GP_ContextFree(img); + GP_PixmapFree(img); return TST_FAILED; } @@ -68,7 +68,7 @@ static int test_check(struct testcase *test, GP_Context *img) static int test_read(struct testcase *test) { - GP_Context *img; + GP_Pixmap *img; GP_IO *io; int err; @@ -96,7 +96,7 @@ static int test_read(struct testcase *test) err = test_check(test, img); - GP_ContextFree(img); + GP_PixmapFree(img); out: GP_IOClose(io); return err; @@ -106,7 +106,7 @@ out: static int test_load(struct testcase *test) { - GP_Context *img; + GP_Pixmap *img; int err; errno = 0; @@ -126,7 +126,7 @@ static int test_load(struct testcase *test) err = test_check(test, img); - GP_ContextFree(img); + GP_PixmapFree(img); return err; } @@ -134,7 +134,7 @@ static int test_load(struct testcase *test) static int test_load_fail(const char *path) { - GP_Context *img; + GP_Pixmap *img; errno = 0; @@ -142,7 +142,7 @@ static int test_load_fail(const char *path) if (img != NULL) { tst_msg("Succeeded unexpectedly"); - GP_ContextFree(img); + GP_PixmapFree(img); return TST_FAILED; } @@ -175,13 +175,13 @@ struct testcase_save_load { static int test_save_load(struct testcase_save_load *test) { - GP_Context *img, *img2; + GP_Pixmap *img, *img2; unsigned int x, y; - img = GP_ContextAlloc(test->w, test->h, test->pixel_type); + img = GP_PixmapAlloc(test->w, test->h, test->pixel_type); if (img == NULL) { - tst_msg("Failed to allocate context %ux%u %s", + tst_msg("Failed to allocate pixmap %ux%u %s", test->w, test->h, GP_PixelTypeName(test->pixel_type)); return TST_FAILED; } @@ -198,7 +198,7 @@ static int test_save_load(struct testcase_save_load *test) return TST_SKIPPED; } - tst_msg("Failed to save context %ux%u %s: %s", + tst_msg("Failed to save pixmap %ux%u %s: %s", test->w, test->h, GP_PixelTypeName(test->pixel_type), strerror(errno)); return TST_FAILED; @@ -211,11 +211,11 @@ static int test_save_load(struct testcase_save_load *test) switch (errno) { case ENOSYS: tst_msg("Not Implemented"); - GP_ContextFree(img); + GP_PixmapFree(img); return TST_SKIPPED; default: tst_msg("Got %s", strerror(errno)); - GP_ContextFree(img); + GP_PixmapFree(img); return TST_FAILED; } } @@ -223,14 +223,14 @@ static int test_save_load(struct testcase_save_load *test) if (img->w != img2->w || img->h != img2->h) { tst_msg("Source size %ux%u and loaded size %ux%u differs", img->w, img->h, img2->w, img2->h); - GP_ContextFree(img); - GP_ContextFree(img2); + GP_PixmapFree(img); + GP_PixmapFree(img2); return TST_FAILED; } if (img->pixel_type != img2->pixel_type) { - GP_ContextFree(img); - GP_ContextFree(img2); + GP_PixmapFree(img); + GP_PixmapFree(img2); tst_msg("Source pixel type %s and loaded type %s differs", GP_PixelTypeName(img->pixel_type), GP_PixelTypeName(img2->pixel_type)); @@ -239,13 +239,13 @@ static int test_save_load(struct testcase_save_load *test) if (GP_GetPixel(img2, 0, 0) != 0) { tst_msg("Pixel value is wrong %x", GP_GetPixel(img2, 0, 0)); - GP_ContextFree(img); - GP_ContextFree(img2); + GP_PixmapFree(img); + GP_PixmapFree(img2); return TST_FAILED; } - GP_ContextFree(img); - GP_ContextFree(img2); + GP_PixmapFree(img); + GP_PixmapFree(img2); return TST_SUCCESS; } diff --git a/tests/loaders/PBM.c b/tests/loaders/PBM.c index 9b71f04b..7840c115 100644 --- a/tests/loaders/PBM.c +++ b/tests/loaders/PBM.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include diff --git a/tests/loaders/PCX.c b/tests/loaders/PCX.c index 53d11e49..cf6ad0d8 100644 --- a/tests/loaders/PCX.c +++ b/tests/loaders/PCX.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include @@ -39,7 +39,7 @@ struct testcase { static int test_load_PCX(struct testcase *test) { - GP_Context *img; + GP_Pixmap *img; errno = 0; @@ -59,7 +59,7 @@ static int test_load_PCX(struct testcase *test) if (img->w != test->w || img->h != test->h) { tst_msg("Wrong size have %ux%u expected %ux%u", img->w, img->h, test->w, test->h); - GP_ContextFree(img); + GP_PixmapFree(img); return TST_FAILED; } @@ -67,7 +67,7 @@ static int test_load_PCX(struct testcase *test) tst_msg("Wrong pixel type have %s expected %s", GP_PixelTypeName(img->pixel_type), GP_PixelTypeName(test->pixel_type)); - GP_ContextFree(img); + GP_PixmapFree(img); return TST_FAILED; } @@ -87,9 +87,9 @@ static int test_load_PCX(struct testcase *test) } if (!fail) - tst_msg("Context pixels are correct"); + tst_msg("Pixmap pixels are correct"); - GP_ContextFree(img); + GP_PixmapFree(img); if (fail) return TST_FAILED; diff --git a/tests/loaders/PGM.c b/tests/loaders/PGM.c index 1fae8679..197badb4 100644 --- a/tests/loaders/PGM.c +++ b/tests/loaders/PGM.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include diff --git a/tests/loaders/PNG.c b/tests/loaders/PNG.c index 5cee605c..65328839 100644 --- a/tests/loaders/PNG.c +++ b/tests/loaders/PNG.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include @@ -32,7 +32,7 @@ static int test_load_PNG(const char *path) { - GP_Context *img; + GP_Pixmap *img; errno = 0; @@ -53,7 +53,7 @@ static int test_load_PNG(const char *path) * TODO: check correct data. */ - GP_ContextFree(img); + GP_PixmapFree(img); return TST_SUCCESS; } @@ -65,7 +65,7 @@ struct check_color_test { static int test_load_PNG_check_color(struct check_color_test *test) { - GP_Context *img; + GP_Pixmap *img; errno = 0; @@ -98,9 +98,9 @@ static int test_load_PNG_check_color(struct check_color_test *test) } if (!fail) - tst_msg("Context pixels are correct"); + tst_msg("Pixmap pixels are correct"); - GP_ContextFree(img); + GP_PixmapFree(img); if (fail) return TST_FAILED; @@ -125,34 +125,34 @@ static struct check_color_test red = { static int test_save_PNG(GP_PixelType pixel_type) { - GP_Context *ctx; + GP_Pixmap *pixmap; int ret; - ctx = GP_ContextAlloc(100, 100, pixel_type); + pixmap = GP_PixmapAlloc(100, 100, pixel_type); - if (ctx == NULL) { - tst_msg("Failed to allocate context"); + if (pixmap == NULL) { + tst_msg("Failed to allocate pixmap"); return TST_UNTESTED; } errno = 0; - ret = GP_SavePNG(ctx, "/dev/null", NULL); + ret = GP_SavePNG(pixmap, "/dev/null", NULL); if (ret == 0) { tst_msg("Saved successfully"); - GP_ContextFree(ctx); + GP_PixmapFree(pixmap); return TST_SUCCESS; } switch (errno) { case ENOSYS: tst_msg("Not Implemented"); - GP_ContextFree(ctx); + GP_PixmapFree(pixmap); return TST_SKIPPED; default: tst_msg("Failed and errno is not ENOSYS (%i)", errno); - GP_ContextFree(ctx); + GP_PixmapFree(pixmap); return TST_FAILED; } } diff --git a/tests/loaders/PNM.c b/tests/loaders/PNM.c index c1f75b77..30957099 100644 --- a/tests/loaders/PNM.c +++ b/tests/loaders/PNM.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include diff --git a/tests/loaders/PPM.c b/tests/loaders/PPM.c index a3c7b84f..1ceecc3a 100644 --- a/tests/loaders/PPM.c +++ b/tests/loaders/PPM.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include diff --git a/tests/loaders/SaveAbort.gen.c.t b/tests/loaders/SaveAbort.gen.c.t index feebd7e5..ac2aa2a1 100644 --- a/tests/loaders/SaveAbort.gen.c.t +++ b/tests/loaders/SaveAbort.gen.c.t @@ -1,7 +1,7 @@ @ include source.t @ include savers.t /* - * Iterate over all pixel types, try to save context but abort it from callback. + * Iterate over all pixel types, try to save pixmap but abort it from callback. * * Copyright (C) 2009-2014 Cyril Hrubis */ @@ -10,12 +10,12 @@ #include #include -#include +#include #include #include "tst_test.h" -typedef int (*Save)(const GP_Context *src, const char *path, GP_ProgressCallback *callback); +typedef int (*Save)(const GP_Pixmap *src, const char *path, GP_ProgressCallback *callback); static int progress_callback(GP_ProgressCallback *self) { @@ -25,11 +25,11 @@ static int progress_callback(GP_ProgressCallback *self) static int test(Save Saver, GP_PixelType pixel_type) { - GP_Context *src; + GP_Pixmap *src; GP_ProgressCallback callback ={.callback = progress_callback}; int ret = TST_SUCCESS; - src = GP_ContextAlloc(100, 100, pixel_type); + src = GP_PixmapAlloc(100, 100, pixel_type); if (!src) { tst_msg("Malloc failed"); @@ -68,7 +68,7 @@ static int test(Save Saver, GP_PixelType pixel_type) } err: - GP_ContextFree(src); + GP_PixmapFree(src); return ret; } diff --git a/tests/loaders/SaveLoad.gen.c.t b/tests/loaders/SaveLoad.gen.c.t index 6797ba06..12d24780 100644 --- a/tests/loaders/SaveLoad.gen.c.t +++ b/tests/loaders/SaveLoad.gen.c.t @@ -1,7 +1,7 @@ @ include source.t @ include savers.t /* - * Iterate over all pixel types, try to save and load back context. + * Iterate over all pixel types, try to save and load back pixmap. * * Copyright (C) 2009-2014 Cyril Hrubis */ @@ -10,23 +10,23 @@ #include #include -#include +#include #include #include #include "tst_test.h" -typedef int (*Save)(const GP_Context *src, const char *path, GP_ProgressCallback *callback); -typedef GP_Context *(*Load)(const char *path, GP_ProgressCallback *callback); +typedef int (*Save)(const GP_Pixmap *src, const char *path, GP_ProgressCallback *callback); +typedef GP_Pixmap *(*Load)(const char *path, GP_ProgressCallback *callback); static int test(Save Saver, Load Loader, GP_PixelType pixel_type) { - GP_Context *src; - GP_Context *res; + GP_Pixmap *src; + GP_Pixmap *res; unsigned int x, y; int ret = TST_SUCCESS; - src = GP_ContextAlloc(100, 100, pixel_type); + src = GP_PixmapAlloc(100, 100, pixel_type); if (!src) { tst_msg("Malloc failed"); @@ -75,9 +75,9 @@ static int test(Save Saver, Load Loader, GP_PixelType pixel_type) ret = TST_FAILED; } - GP_ContextFree(res); + GP_PixmapFree(res); err: - GP_ContextFree(src); + GP_PixmapFree(src); return ret; } diff --git a/tests/loaders/ZIP.c b/tests/loaders/ZIP.c index 35dded8a..16327412 100644 --- a/tests/loaders/ZIP.c +++ b/tests/loaders/ZIP.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -37,7 +37,7 @@ struct test { static int test_load(struct test *test) { GP_Container *zip = GP_OpenZip(test->path); - GP_Context *img; + GP_Pixmap *img; int ret = TST_SUCCESS; if (!zip) { @@ -58,7 +58,7 @@ static int test_load(struct test *test) ret = TST_FAILED; } - GP_ContextFree(img); + GP_PixmapFree(img); GP_ContainerClose(zip); return ret; @@ -88,7 +88,7 @@ struct test mixed_content = { static int no_images(const char *path) { GP_Container *zip = GP_OpenZip(path); - GP_Context *img; + GP_Pixmap *img; int ret = TST_SUCCESS; if (!zip) { diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c index 333eccdf..bbe372a0 100644 --- a/tests/loaders/loaders_suite.c +++ b/tests/loaders/loaders_suite.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include "tst_test.h" @@ -52,7 +52,7 @@ static const char *strfmt(enum fmt fmt) return "INVALID"; } -static int save_img(enum fmt fmt, const GP_Context *img, const char *name) +static int save_img(enum fmt fmt, const GP_Pixmap *img, const char *name) { char buf[256]; @@ -71,7 +71,7 @@ static int save_img(enum fmt fmt, const GP_Context *img, const char *name) } } -static GP_Context *load(enum fmt fmt, const char *name) +static GP_Pixmap *load(enum fmt fmt, const char *name) { char buf[256]; @@ -94,12 +94,12 @@ static GP_Context *load(enum fmt fmt, const char *name) static int save_load(enum fmt fmt, GP_Size w, GP_Size h) { - GP_Context *img, *res; + GP_Pixmap *img, *res; - img = GP_ContextAlloc(w, h, GP_PIXEL_RGB888); + img = GP_PixmapAlloc(w, h, GP_PIXEL_RGB888); if (img == NULL) { - tst_warn("GP_ContextAlloc failed"); + tst_warn("GP_PixmapAlloc failed"); return TST_UNTESTED; } @@ -124,8 +124,8 @@ static int save_load(enum fmt fmt, GP_Size w, GP_Size h) return TST_FAILED; } - GP_ContextFree(img); - GP_ContextFree(res); + GP_PixmapFree(img); + GP_PixmapFree(res); return TST_SUCCESS; } @@ -162,7 +162,7 @@ static int test_BMP_stress(void) static int load_enoent(enum fmt fmt) { - GP_Context *img; + GP_Pixmap *img; img = load(fmt, "nonexistent"); @@ -207,7 +207,7 @@ static int test_BMP_Load_ENOENT(void) static int load_eacces(enum fmt fmt) { char buf[256]; - GP_Context *img; + GP_Pixmap *img; snprintf(buf, sizeof(buf), "test.%s", strfmt(fmt)); @@ -269,7 +269,7 @@ static int test_BMP_Load_EACCES(void) static int load_eio(enum fmt fmt) { char buf[256]; - GP_Context *img; + GP_Pixmap *img; snprintf(buf, sizeof(buf), "test.%s", strfmt(fmt)); @@ -334,9 +334,9 @@ static int abort_callback(GP_ProgressCallback *self __attribute__((unused))) static int test_PNG_Save_abort(void) { - GP_Context *img; + GP_Pixmap *img; - img = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888); + img = GP_PixmapAlloc(100, 100, GP_PIXEL_RGB888); GP_ProgressCallback callback = {.callback = abort_callback}; @@ -356,16 +356,16 @@ static int test_PNG_Save_abort(void) return TST_FAILED; } - GP_ContextFree(img); + GP_PixmapFree(img); return TST_SUCCESS; } static int test_PNG_Load_abort(void) { - GP_Context *img; + GP_Pixmap *img; - img = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888); + img = GP_PixmapAlloc(100, 100, GP_PIXEL_RGB888); if (GP_SavePNG(img, "test.png", NULL)) { @@ -378,7 +378,7 @@ static int test_PNG_Load_abort(void) return TST_FAILED; } - GP_ContextFree(img); + GP_PixmapFree(img); GP_ProgressCallback callback = {.callback = abort_callback}; @@ -512,7 +512,7 @@ static int test_Load(void) } for (i = 0; file_testcases[i].filename != NULL; i++) { - GP_Context *ret; + GP_Pixmap *ret; errno = 0; ret = GP_LoadImage(file_testcases[i].filename, NULL); @@ -557,7 +557,7 @@ static int test_Load(void) static int test_load_BMP(const char *path) { - GP_Context *img; + GP_Pixmap *img; img = GP_LoadBMP(path, NULL); @@ -576,7 +576,7 @@ static int test_load_BMP(const char *path) * TODO: check correct data. */ - GP_ContextFree(img); + GP_PixmapFree(img); return TST_SUCCESS; } @@ -625,7 +625,7 @@ static int test_load_BMP_8bpp_1x64000(void) static int test_load_JPEG(const char *path) { - GP_Context *img; + GP_Pixmap *img; img = GP_LoadJPG(path, NULL); @@ -643,7 +643,7 @@ static int test_load_JPEG(const char *path) /* * TODO: check correct data. */ - GP_ContextFree(img); + GP_PixmapFree(img); return TST_SUCCESS; } diff --git a/tests/pylib/test_core.py b/tests/pylib/test_core.py index 894695aa..976dcda4 100644 --- a/tests/pylib/test_core.py +++ b/tests/pylib/test_core.py @@ -1,10 +1,10 @@ -"core.Context tests" +"core.Pixmap tests" from unittest import SkipTest from testutils import * from gfxprim import core -from gfxprim.core import Context +from gfxprim.core import Pixmap def test_basic_types_exist(): "There are the basic pixel types" @@ -14,18 +14,18 @@ def test_basic_types_exist(): @alltypes() def test_create_by_pixeltype(t): - "Allocate Context by pixeltype" - c = Context(13, 15, t.type) + "Allocate Pixmap by pixeltype" + c = Pixmap(13, 15, t.type) @alltypes() def test_create_by_number(t): "Allocation by pixeltype number" - c = Context(3, 5, t) + c = Pixmap(3, 5, t) @alltypes() def test_check_attributes(t): - "Context attributes" - c = Context(13, 15, t.type) + "Pixmap attributes" + c = Pixmap(13, 15, t.type) assert c.w == 13 assert c.h == 15 assert c._bit_endian == t.bit_endian @@ -37,7 +37,7 @@ def test_convert_from_RGB888(t): "Conversion from RGB888" if 'P' in t.name: raise SkipTest("Palette conversion are TODO") - c = ContextRand(17, 19, core.C.PIXEL_RGB888) + c = PixmapRand(17, 19, core.C.PIXEL_RGB888) # both by number and the pixeltype c2 = c.Convert(t) assert c2.pixel_type == t.type @@ -49,18 +49,18 @@ def test_convert_to_RGB888(t): "Conversion to RGB888" if 'P' in t.name: raise SkipTest("Palette conversion are TODO") - c = ContextRand(11, 12, t) + c = PixmapRand(11, 12, t) c2 = c.Convert(core.C.PIXEL_RGB888) assert c2.pixel_type == core.C.PIXEL_RGB888 @alltypes() def test_equality(t): "Equality" - c1a = ContextRand(2, 11, t, seed=123) - c1b = ContextRand(2, 11, t, seed=123) + c1a = PixmapRand(2, 11, t, seed=123) + c1b = PixmapRand(2, 11, t, seed=123) assert c1a == c1a assert c1a == c1b - c2 = ContextRand(2, 11, t, seed=456) + c2 = PixmapRand(2, 11, t, seed=456) assert c2 == c2 assert c1a != c2 assert c2 != c1a @@ -70,7 +70,7 @@ def test_get_put_pixel(t): "Get/Put pixel consistent" def f(x,y): return (x + 3 ** y) % (1 << t.size) - c = ContextRand(45, 37, t) + c = PixmapRand(45, 37, t) for x in range(c.w): for y in range(c.h): c.PutPixel(x, y, f(x, y)) @@ -80,8 +80,8 @@ def test_get_put_pixel(t): @alltypes() def test_str_repr(t): - "Context __str__ and __repr__ work" - c = Context(42, 43, t) + "Pixmap __str__ and __repr__ work" + c = Pixmap(42, 43, t) assert "42x43" in str(c) assert "42x43" in repr(c) assert t.name in str(c) @@ -90,10 +90,10 @@ def test_str_repr(t): @alltypes() def test_blit_with_offset_and_rotation(t): "Blit with various shifts and rotation" - c1 = ContextRand(19, 17, t) + c1 = PixmapRand(19, 17, t) for r in range(4): for i in [0,1,2]: - c2 = Context(51-i, 25+i, t) + c2 = Pixmap(51-i, 25+i, t) c1.Blit(2+i, 3+i, c2, 1+i, 4-i, w=2+3*i, h=13-i) c1.RotateCW() @@ -102,8 +102,8 @@ def test_blit_vs_convert_to_RGB888(t): "Compare Blit vs Convert" if 'P' in t.name: raise SkipTest("Palette conversions are TODO") - c = ContextRand(42, 43, t, seed=0) - c2a = ContextRand(c.w, c.h, core.C.PIXEL_RGB888, seed=42) + c = PixmapRand(42, 43, t, seed=0) + c2a = PixmapRand(c.w, c.h, core.C.PIXEL_RGB888, seed=42) if 'A' in t.name: try: import gfxprim.gfx @@ -117,14 +117,14 @@ def test_blit_vs_convert_to_RGB888(t): @alltypes() def test_copy(t): "Copying works" - c = ContextRand(19, 43, t) + c = PixmapRand(19, 43, t) c2 = c.Copy(True) assert c == c2 @alltypes() def test_rotate(t): "Rotations work (and LLL=R)" - c = ContextRand(42, 47, t) + c = PixmapRand(42, 47, t) c2 = c.Copy(True) assert c == c2 c2.RotateCCW() @@ -141,33 +141,33 @@ def test_rotate(t): assert c == c2 @alltypes() -def test_subcontext(t): - "Subcontext is sensible" - c1a = ContextRand(43, 51, t) - c1b = ContextRand(43, 51, t) +def test_subpixmap(t): + "Subpixmap is sensible" + c1a = PixmapRand(43, 51, t) + c1b = PixmapRand(43, 51, t) assert c1a == c1b - c2a = c1a.SubContext(5, 7, 10, 9) - c2b = c1b.SubContext(5, 7, 10, 9) + c2a = c1a.SubPixmap(5, 7, 10, 9) + c2b = c1b.SubPixmap(5, 7, 10, 9) assert c2a == c2b @alltypes() -def test_subcontext_vs_blit(t): - "Compare Subcontext and Blit of a rectangle" - c = ContextRand(31, 21, t) - c2a = c.SubContext(5, 7, 15, 9) - c2b = Context(15, 9, t) +def test_subpixmap_vs_blit(t): + "Compare Subpixmap and Blit of a rectangle" + c = PixmapRand(31, 21, t) + c2a = c.SubPixmap(5, 7, 15, 9) + c2b = Pixmap(15, 9, t) c.Blit(5, 7, c2b, 0, 0, w=15, h=9) assert c2a == c2b @alltypes() def test_blits_by_rect(t): "Blit defined by XYXY, XYX2Y2 and XYWH" - c = ContextRand(17, 13, t, seed=765) - c2a = ContextRand(16, 15, t, seed=4) - c2b = ContextRand(16, 15, t, seed=4) - c2c = ContextRand(16, 15, t, seed=4) - c2d = ContextRand(16, 15, t, seed=4) - c2e = ContextRand(16, 15, t, seed=4) + c = PixmapRand(17, 13, t, seed=765) + c2a = PixmapRand(16, 15, t, seed=4) + c2b = PixmapRand(16, 15, t, seed=4) + c2c = PixmapRand(16, 15, t, seed=4) + c2d = PixmapRand(16, 15, t, seed=4) + c2e = PixmapRand(16, 15, t, seed=4) assert c2a == c2b assert c2a == c2c assert c2a == c2d diff --git a/tests/pylib/test_gfx.py b/tests/pylib/test_gfx.py index b9314b2e..08918d51 100644 --- a/tests/pylib/test_gfx.py +++ b/tests/pylib/test_gfx.py @@ -1,21 +1,21 @@ -"core.Context tests" +"core.Pixmap tests" from unittest import SkipTest from testutils import * -from gfxprim.core import Context +from gfxprim.core import Pixmap from gfxprim import gfx, core def test_gfx_submodule_loads(): - "gfx is present in a Context" - c = Context(1, 1, core.C.PIXEL_RGB888) + "gfx is present in a Pixmap" + c = Pixmap(1, 1, core.C.PIXEL_RGB888) assert c.gfx def test_gfx_submodule_has_C(): "gfx contains C" - c = Context(1, 1, core.C.PIXEL_RGB888) + c = Pixmap(1, 1, core.C.PIXEL_RGB888) assert c.gfx.C assert gfx.C @@ -50,7 +50,7 @@ gfx_params = { def test_all_methods_are_known(): "All methods of gfx submodule have known param types in this test" - c = Context(1, 1, core.C.PIXEL_RGB888) + c = Pixmap(1, 1, core.C.PIXEL_RGB888) for name in dir(c.gfx): if name[0] != '_' and name not in ['C', 'ctx']: assert name in gfx_params @@ -84,7 +84,7 @@ def gen_dummy_args(params): @for_each_case(gfx_params) def test_method_call(n, params): "Calling with dummy parameters:" - c = ContextRand(10, 10, core.C.PIXEL_RGB888) + c = PixmapRand(10, 10, core.C.PIXEL_RGB888) if isinstance(params, str): c.gfx.__getattribute__(n)(*gen_dummy_args(params)) else: @@ -93,9 +93,9 @@ def test_method_call(n, params): def test_Polygon(): "Polygon() works" - c0 = ContextRand(13, 12, core.C.PIXEL_RGB888, seed=42) - c1 = ContextRand(13, 12, core.C.PIXEL_RGB888, seed=42) - c2 = ContextRand(13, 12, core.C.PIXEL_RGB888, seed=42) + c0 = PixmapRand(13, 12, core.C.PIXEL_RGB888, seed=42) + c1 = PixmapRand(13, 12, core.C.PIXEL_RGB888, seed=42) + c2 = PixmapRand(13, 12, core.C.PIXEL_RGB888, seed=42) assert c1 == c0 c1.gfx.Polygon([1,2,0,4,7,9,5,4,3,2], 43) c2.gfx.Polygon([(1,2),(0,4),(7,9),(5,4),(3,2)], 43) @@ -104,9 +104,9 @@ def test_Polygon(): def test_FillPolygon(): "FillPolygon() works" - c0 = ContextRand(13, 9, core.C.PIXEL_RGB888, seed=41) - c1 = ContextRand(13, 9, core.C.PIXEL_RGB888, seed=41) - c2 = ContextRand(13, 9, core.C.PIXEL_RGB888, seed=41) + c0 = PixmapRand(13, 9, core.C.PIXEL_RGB888, seed=41) + c1 = PixmapRand(13, 9, core.C.PIXEL_RGB888, seed=41) + c2 = PixmapRand(13, 9, core.C.PIXEL_RGB888, seed=41) assert c1 == c0 c1.gfx.FillPolygon([1,2,0,4,7,9,5,4,3,2], 0) c2.gfx.FillPolygon([(1,2),(0,4),(7,9),(5,4),(3,2)], 0) diff --git a/tests/pylib/testutils.py b/tests/pylib/testutils.py index 8c1badcb..7c7f740b 100644 --- a/tests/pylib/testutils.py +++ b/tests/pylib/testutils.py @@ -5,7 +5,7 @@ from random import Random from gfxprim import core __all__ = ["alltypes", "for_each_case", - "RandomizeContext", "ContextRand"] + "RandomizePixmap", "PixmapRand"] def alltypes(_filter=None): @@ -48,17 +48,17 @@ def for_each_case(cases, givename=True): return decorate -### core.Context helpers +### core.Pixmap helpers -def ContextRand(w, h, t, seed=None): - "Return new Context(w, h, t) filled with RandomizeContext(c, seed)" - c = core.Context(w, h, t) - RandomizeContext(c, seed) +def PixmapRand(w, h, t, seed=None): + "Return new Pixmap(w, h, t) filled with RandomizePixmap(c, seed)" + c = core.Pixmap(w, h, t) + RandomizePixmap(c, seed) return c -def RandomizeContext(c, seed=None): - """Fill Context with pseudorandom data. +def RandomizePixmap(c, seed=None): + """Fill Pixmap with pseudorandom data. The default seed is computed from size and type number. """ -- 2.11.4.GIT