This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 4128a845f099a7902414cfe3314a61bcff9b60c8 (commit) via feddd1c185068f220e394cc7ec34ff3f0e6b5801 (commit) via cd4e4016c7c2bd7293eec6d9cc99e3355cc8dd38 (commit) from 7064952e38373799deaae59b2ea67093d75b3709 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/4128a845f099a7902414cfe3314a61bcff9b6...
commit 4128a845f099a7902414cfe3314a61bcff9b60c8 Author: Cyril Hrubis metan@ucw.cz Date: Sun Nov 25 22:33:29 2012 +0100
tests: Finally get rid of obsolete SDL tests.
diff --git a/tests/Makefile b/tests/Makefile index 7a0ad0d..71b1004 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,7 +1,7 @@ TOPDIR=.. include $(TOPDIR)/pre.mk
-SUBDIRS=core SDL drivers framework loaders gfx filters +SUBDIRS=core drivers framework loaders gfx filters
loaders: framework gfx: framework diff --git a/tests/SDL/Makefile b/tests/SDL/Makefile deleted file mode 100644 index ce12dcb..0000000 --- a/tests/SDL/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -TOPDIR=../.. -include $(TOPDIR)/pre.mk - -INCLUDE=core gfx SDL backends -LDLIBS+=-lGP -L$(TOPDIR)/build/ -lGP_SDL -lSDL - -ifeq ($(HAVE_LIBSDL),yes) -CSOURCES=$(shell echo *.c) - -APPS=textaligntest subcontext- mixpixeltest -endif - -include $(TOPDIR)/app.mk -include $(TOPDIR)/post.mk diff --git a/tests/SDL/mixpixeltest.c b/tests/SDL/mixpixeltest.c deleted file mode 100644 index 0f0d179..0000000 --- a/tests/SDL/mixpixeltest.c +++ /dev/null @@ -1,228 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> -#include <SDL/SDL.h> - -#include "GP.h" -#include "GP_SDL.h" - -/* The surface used as a display (in fact it is a software surface). */ -SDL_Surface *display = NULL; -GP_Context context; - -/* Timer used for refreshing the display */ -SDL_TimerID timer; - -/* An event used for signaling that the timer was triggered. */ -SDL_UserEvent timer_event; - -/* Values for color pixels in display format. */ -GP_Pixel red_pixel, green_pixel, blue_pixel, white_pixel; - -Uint32 timer_callback(__attribute__((unused)) Uint32 interval, - __attribute__((unused)) void *param) -{ - timer_event.type = SDL_USEREVENT; - SDL_PushEvent((SDL_Event *) &timer_event); - return 0; -} - -void draw_pixels(void) -{ - unsigned int i, j, k; - - GP_FillRect(&context, 0, 0, context.w, 120, white_pixel); - - unsigned int y = 20; - - for (i = 0; i <= 256; i++) { - GP_MixPixel_Raw(&context, i + 20, y + 0, 0, i); - GP_MixPixel_Raw(&context, i + 20, y + 1, 0, i); - GP_MixPixel_Raw(&context, i + 20, y + 2, 0, i); - GP_MixPixel_Raw(&context, i + 20, y + 3, 0, i); - GP_MixPixel_Raw(&context, i + 20, y + 4, 0, i); - - GP_MixPixel_Raw(&context, i + 20, y + 5, red_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 6, red_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 7, red_pixel, i); - - GP_MixPixel_Raw(&context, i + 20, y + 8, green_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 9, green_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 10, green_pixel, i); - - GP_MixPixel_Raw(&context, i + 20, y + 11, blue_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 12, blue_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 13, blue_pixel, i); - - - if (i % 16 == 0) - GP_PutPixel(&context, i + 20, y + 14, 0); - - if (i % 32 == 0) - GP_PutPixel(&context, i + 20, y + 15, 0); - - if (i % 64 == 0) { - GP_PutPixel(&context, i + 20, y + 16, 0); - GP_Print(&context, NULL, i + 20, y + 20, - GP_ALIGN_CENTER | GP_VALIGN_BELOW, - 0, 0, "%u", i); - } - - if (i % 128 == 0) - GP_PutPixel(&context, i + 20, y + 17, 0); - } - - for (i = 0; i < 7; i++) - for (j = 0; j < 32; j++) - for (k = 0; k < 32; k++) - GP_MixPixel_Raw(&context, (225 * i) / 6 + j + 20, - y + k + 40, 0, (255 * i) / 6); - - y = 140; - - for (i = 0; i <= 256; i++) { - GP_MixPixel_Raw(&context, i + 20, y + 0, white_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 1, white_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 2, white_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 3, white_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 4, white_pixel, i); - - GP_MixPixel_Raw(&context, i + 20, y + 5, red_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 6, red_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 7, red_pixel, i); - - GP_MixPixel_Raw(&context, i + 20, y + 8, green_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 9, green_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 10, green_pixel, i); - - GP_MixPixel_Raw(&context, i + 20, y + 11, blue_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 12, blue_pixel, i); - GP_MixPixel_Raw(&context, i + 20, y + 13, blue_pixel, i); - - if (i % 16 == 0) - GP_PutPixel(&context, i + 20, y + 14, white_pixel); - - if (i % 32 == 0) - GP_PutPixel(&context, i + 20, y + 15, white_pixel); - - if (i % 64 == 0) { - GP_PutPixel(&context, i + 20, y + 16, white_pixel); - GP_Print(&context, NULL, i + 20, y + 20, - GP_ALIGN_CENTER | GP_VALIGN_BELOW, - white_pixel, 0, "%u", i); - } - - if (i % 128 == 0) - GP_PutPixel(&context, i + 20, y + 17, white_pixel); - } - - for (i = 0; i < 7; i++) - for (j = 0; j < 32; j++) - for (k = 0; k < 32; k++) - GP_MixPixel_Raw(&context, (225 * i) / 6 + j + 20, - y + k + 40, white_pixel, (255 * i) / 6); - -} - -void event_loop(void) -{ - SDL_Event event; - - while (SDL_WaitEvent(&event) > 0) { - switch (event.type) { - case SDL_USEREVENT: - draw_pixels(); - SDL_Flip(display); - break; - case SDL_KEYDOWN: - case SDL_QUIT: - return; - } - } -} - -int main(int argc, char **argv) -{ - int display_bpp = 0; - - int i; - for (i = 1; i < argc; i++) { - if (strcmp(argv[i], "-16") == 0) { - display_bpp = 16; - } else if (strcmp(argv[i], "-24") == 0) { - display_bpp = 24; - } - } - - /* Initialize SDL */ - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) { - fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError()); - return 1; - } - - /* Create a window with a software back surface */ - display = SDL_SetVideoMode(320, 240, display_bpp, SDL_SWSURFACE); - if (display == NULL) { - fprintf(stderr, "Could not open display: %sn", SDL_GetError()); - goto fail; - } - - - /* Print basic information about the surface */ - printf("Display surface properties:n"); - printf(" width: %4d, height: %4d, pitch: %4dn", - display->w, display->h, display->pitch); - printf(" bits per pixel: %2d, bytes per pixel: %2dn", - display->format->BitsPerPixel, display->format->BytesPerPixel); - - /* Set up a clipping rectangle to test proper clipping of pixels */ - SDL_Rect clip_rect = {10, 10, 300, 220}; - SDL_SetClipRect(display, &clip_rect); - - GP_SDL_ContextFromSurface(&context, display); - - /* Load pixel values compatible with the display. */ - red_pixel = GP_ColorToContextPixel(GP_COL_RED, &context); - green_pixel = GP_ColorToContextPixel(GP_COL_GREEN, &context); - blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, &context); - white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, &context); - - /* Set up the refresh timer */ - timer = SDL_AddTimer(30, timer_callback, NULL); - if (timer == 0) { - fprintf(stderr, "Could not set up timer: %sn", SDL_GetError()); - goto fail; - } - - /* Enter the event loop */ - event_loop(); - - /* We're done */ - SDL_Quit(); - return 0; - -fail: - SDL_Quit(); - return 1; -} diff --git a/tests/SDL/runtest.sh b/tests/SDL/runtest.sh deleted file mode 100755 index 163c76c..0000000 --- a/tests/SDL/runtest.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# -# Run dynamically linked test. -# - -PROG="$1" -shift - -echo "LD_LIBRARY_PATH=../../build/ ./$PROG $@" -LD_LIBRARY_PATH=../../build/ ./$PROG "$@" diff --git a/tests/SDL/subcontext.c b/tests/SDL/subcontext.c deleted file mode 100644 index a9348e6..0000000 --- a/tests/SDL/subcontext.c +++ /dev/null @@ -1,281 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <SDL/SDL.h> - -#include "GP.h" -#include "GP_SDL.h" - -static GP_Pixel black, white, gray; - -SDL_Surface *display = NULL; -GP_Context context, *sub_context; - -SDL_TimerID timer; - -SDL_UserEvent timer_event; - -static int pause_flag = 0; -static int draw_flag = 0; - -Uint32 timer_callback(__attribute__((unused)) Uint32 interval, - __attribute__((unused)) void *param) -{ - timer_event.type = SDL_USEREVENT; - SDL_PushEvent((SDL_Event *) &timer_event); - return 30; -} - -static void draw_line(GP_Context *dest, GP_Coord x, GP_Coord y, - GP_Size w, GP_Size h, GP_Color col) -{ - GP_Coord x1, x2, y1, y2; - - x1 = random() % w + x; - y1 = random() % h + y; - x2 = random() % w + x; - y2 = random() % h + y; - - GP_Line(dest, x1, y1, x2, y2, col); -} - -static void draw_triangle(GP_Context *dest, GP_Coord x, GP_Coord y, - GP_Size w, GP_Size h, GP_Color col, int flag) -{ - GP_Coord x1, x2, x3, y1, y2, y3; - - x1 = random() % w + x; - y1 = random() % h + y; - x2 = random() % w + x; - y2 = random() % h + y; - x3 = random() % w + x; - y3 = random() % h + y; - - if (flag) - GP_FillTriangle(dest, x1, y1, x2, y2, x3, y3, col); - else - GP_Triangle(dest, x1, y1, x2, y2, x3, y3, col); -} - -static void draw_rect(GP_Context *dest, GP_Coord x, GP_Coord y, - GP_Size w, GP_Size h, GP_Color col, int flag) -{ - GP_Coord x1, x2, y1, y2; - - x1 = random() % w + x; - y1 = random() % h + y; - x2 = random() % w + x; - y2 = random() % h + y; - - if (flag) - GP_FillRect(dest, x1, y1, x2, y2, col); - else - GP_Rect(dest, x1, y1, x2, y2, col); -} - -static void draw_circle(GP_Context *dest, GP_Coord x, GP_Coord y, - GP_Size w, GP_Size h, GP_Color col, int flag) -{ - GP_Coord x1, y1, r; - - r = random() % 150; - - x1 = random() % (w - 2*r) + x + r; - y1 = random() % (h - 2*r) + y + r; - - if (flag) - GP_FillCircle(dest, x1, y1, r, col); - else - GP_Circle(dest, x1, y1, r, col); -} - -#define TEXT "Lorem Ipsum Dolor Sit Amet" - -static void draw_text(GP_Context *dest, GP_Coord x, GP_Coord y, - GP_Size w, GP_Size h, GP_Color col) -{ - GP_Coord x1, y1; - GP_Size tw, th; - - tw = GP_TextWidth(NULL, TEXT); - th = GP_TextHeight(NULL); - - x1 = random() % (w - tw) + x; - y1 = random() % (h - th) + y; - - GP_Text(dest, NULL, x1, y1, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, col, black, TEXT); -} - -void redraw_screen(void) -{ - if (pause_flag) - return; - - SDL_LockSurface(display); - - uint8_t v = random() % 128 + 50; - GP_Color col; - if (sub_context->pixel_type == GP_PIXEL_P8) - col = random() % 256; - else - col = GP_RGBToContextPixel(v, v, 255, sub_context); - - /* frame around subcontext */ - GP_Rect(&context, 99, 99, context.w - 100, context.h - 100, white); - - switch (draw_flag) { - case 0: - draw_line(sub_context, -100, -100, sub_context->w + 200, sub_context->h + 200, col); - break; - case 1: - draw_triangle(sub_context, -100, -100, sub_context->w + 200, sub_context->h + 200, col, 0); - break; - case 2: - draw_triangle(sub_context, -100, -100, sub_context->w + 200, sub_context->h + 200, col, 1); - break; - case 3: - draw_rect(sub_context, -100, -100, sub_context->w + 200, sub_context->h + 200, col, 0); - break; - case 4: - draw_rect(sub_context, -100, -100, sub_context->w + 200, sub_context->h + 200, col, 1); - break; - case 5: - draw_circle(sub_context, -100, -100, sub_context->w + 200, sub_context->h + 200, col, 0); - break; - case 6: - draw_circle(sub_context, -100, -100, sub_context->w + 200, sub_context->h + 200, col, 1); - break; - case 7: - draw_text(sub_context, -100, -100, sub_context->w + 200, sub_context->h + 200, col); - break; - } - - SDL_Flip(display); - - SDL_UnlockSurface(display); -} - -void clear_screen(void) -{ - GP_Fill(&context, black); - GP_Fill(sub_context, gray); -} - -void event_loop(void) -{ - SDL_Event event; - - while (SDL_WaitEvent(&event) > 0) { - - switch (event.type) { - - case SDL_USEREVENT: - redraw_screen(); - break; - case SDL_KEYDOWN: - switch (event.key.keysym.sym) { - case SDLK_p: - pause_flag = !pause_flag; - break; - case SDLK_SPACE: - draw_flag = (draw_flag + 1) % 8; - clear_screen(); - break; - case SDLK_ESCAPE: - return; - - default: - break; - } - break; - case SDL_QUIT: - return; - default: - break; - } - } -} - -int main(int argc, char *argv[]) -{ - /* Bits per pixel to be set for the display surface. */ - int display_bpp = 0; - - int i; - for (i = 1; i < argc; i++) { - if (strcmp(argv[i], "-8") == 0) { - display_bpp = 8; - } else if (strcmp(argv[i], "-16") == 0) { - display_bpp = 16; - } - else if (strcmp(argv[i], "-24") == 0) { - display_bpp = 24; - } - else if (strcmp(argv[i], "-32") == 0) { - display_bpp = 32; - } - } - - GP_SetDebugLevel(10); - - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) { - fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError()); - return 1; - } - - display = SDL_SetVideoMode(640, 480, display_bpp, SDL_SWSURFACE); - if (display == NULL) { - fprintf(stderr, "Could not open display: %sn", SDL_GetError()); - goto fail; - } - - GP_SDL_ContextFromSurface(&context, display); - - black = GP_ColorToContextPixel(GP_COL_BLACK, &context); - white = GP_ColorToContextPixel(GP_COL_WHITE, &context); - gray = GP_ColorToContextPixel(GP_COL_GRAY_DARK, &context); - - sub_context = GP_SubContextAlloc(&context, 100, 100, 440, 280); - GP_Fill(sub_context, gray); - - timer = SDL_AddTimer(60, timer_callback, NULL); - if (timer == 0) { - fprintf(stderr, "Could not set up timer: %sn", SDL_GetError()); - goto fail; - } - - event_loop(); - - SDL_Quit(); - return 0; - -fail: - SDL_Quit(); - return 1; -} - diff --git a/tests/SDL/textaligntest.c b/tests/SDL/textaligntest.c deleted file mode 100644 index a58e670..0000000 --- a/tests/SDL/textaligntest.c +++ /dev/null @@ -1,185 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> -#include <SDL/SDL.h> - -#include "GP.h" -#include "GP_SDL.h" - -SDL_Surface *display = NULL; -GP_Context context; - -static GP_Pixel black_pixel, red_pixel, yellow_pixel, green_pixel, blue_pixel, - darkgray_pixel; - -static int font_flag = 0; - -static int X = 640; -static int Y = 480; - -GP_FontFace *font = NULL; - -void redraw_screen(void) -{ - SDL_LockSurface(display); - - GP_Fill(&context, black_pixel); - - /* draw axes intersecting in the middle, where text should be shown */ - GP_HLine(&context, 0, X, Y/2, darkgray_pixel); - GP_VLine(&context, X/2, 0, Y, darkgray_pixel); - - GP_TextStyle style = GP_DEFAULT_TEXT_STYLE; - - switch (font_flag) { - case 0: - style.font = &GP_DefaultProportionalFont; - break; - case 1: - style.font = &GP_DefaultConsoleFont; - break; - case 2: - style.font = font; - break; - } - - GP_Text(&context, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_BELOW, - yellow_pixel, black_pixel, "bottom left"); - GP_Text(&context, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_BELOW, - red_pixel, black_pixel, "bottom right"); - GP_Text(&context, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_ABOVE, - blue_pixel, black_pixel, "top right"); - GP_Text(&context, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_ABOVE, - green_pixel, black_pixel, "top left"); - - SDL_UnlockSurface(display); -} - -void event_loop(void) -{ - SDL_Event event; - - while (SDL_WaitEvent(&event) > 0) { - switch (event.type) { - - case SDL_VIDEOEXPOSE: - redraw_screen(); - SDL_Flip(display); - break; - - case SDL_KEYDOWN: - switch (event.key.keysym.sym) { - case SDLK_SPACE: - font_flag += 1; - - if (font) { - if (font_flag >= 3) - font_flag = 0; - } else { - if (font_flag >= 2) - font_flag = 0; - } - break; - case SDLK_x: - context.x_swap = !context.x_swap; - break; - case SDLK_y: - context.y_swap = !context.y_swap; - break; - case SDLK_r: - context.axes_swap = !context.axes_swap; - GP_SWAP(X, Y); - break; - default: - break; - case SDLK_ESCAPE: - return; - } - redraw_screen(); - SDL_Flip(display); - break; - - case SDL_QUIT: - return; - } - } -} - -void print_instructions(void) -{ - printf("Use the following keys to control the test:n"); - printf(" Space ............... toggle proportional/nonproportional fontn"); - printf(" X ................... mirror Xn"); - printf(" Y ................... mirror Yn"); - printf(" R ................... reverse X and Yn"); -} - -int main(int argc, char *argv[]) -{ - GP_SetDebugLevel(10); - - if (argc > 1) - font = GP_FontFaceLoad(argv[1], 0, 16); - - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) { - fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError()); - return 1; - } - - display = SDL_SetVideoMode(X, Y, 0, SDL_SWSURFACE); - if (display == NULL) { - fprintf(stderr, "Could not open display: %sn", SDL_GetError()); - goto fail; - } - - print_instructions(); - - SDL_Rect clip_rect = {10, 10, X-10, Y-10}; - SDL_SetClipRect(display, &clip_rect); - - GP_SDL_ContextFromSurface(&context, display); - - black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, &context); - red_pixel = GP_ColorToContextPixel(GP_COL_RED, &context); - blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, &context); - green_pixel = GP_ColorToContextPixel(GP_COL_GREEN, &context); - yellow_pixel = GP_ColorToContextPixel(GP_COL_YELLOW, &context); - darkgray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_DARK, &context); - - redraw_screen(); - SDL_Flip(display); - - event_loop(); - - SDL_Quit(); - return 0; - -fail: - SDL_Quit(); - return 1; -} -
http://repo.or.cz/w/gfxprim.git/commit/feddd1c185068f220e394cc7ec34ff3f0e6b5...
commit feddd1c185068f220e394cc7ec34ff3f0e6b5801 Author: Cyril Hrubis metan@ucw.cz Date: Sun Nov 25 22:33:11 2012 +0100
tests: Port textaligntest to backends.
diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile index 708a3ca..b30fc23 100644 --- a/demos/c_simple/Makefile +++ b/demos/c_simple/Makefile @@ -9,7 +9,8 @@ LDLIBS+=-lrt `$(TOPDIR)/gfxprim-config --libs --libs-backends` APPS=backend_example loaders_example loaders filters_symmetry gfx_koch virtual_backend_example meta_data meta_data_dump tmp_file showimage v4l2_show v4l2_grab convolution weighted_median shapetest koch input- fileview linetest randomshapetest fonttest loaders_register blittest + fileview linetest randomshapetest fonttest loaders_register blittest+ textaligntest
v4l2_show: LDLIBS+=-lGP_grabbers v4l2_grab: LDLIBS+=-lGP_grabbers diff --git a/demos/c_simple/textaligntest.c b/demos/c_simple/textaligntest.c new file mode 100644 index 0000000..0f1b4a3 --- /dev/null +++ b/demos/c_simple/textaligntest.c @@ -0,0 +1,167 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * + * jiri.bluebear.dluhos@gmail.com * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <GP.h> + +static GP_Pixel black_pixel, red_pixel, yellow_pixel, green_pixel, blue_pixel, + darkgray_pixel; + +static int font_flag = 0; + +static int X = 640; +static int Y = 480; + +static GP_FontFace *font = NULL; + +static GP_Backend *win; + +void redraw_screen(void) +{ + GP_Fill(win->context, 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_TextStyle style = GP_DEFAULT_TEXT_STYLE; + + switch (font_flag) { + case 0: + style.font = &GP_DefaultProportionalFont; + break; + case 1: + style.font = &GP_DefaultConsoleFont; + break; + case 2: + style.font = font; + break; + } + + GP_Text(win->context, &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, + red_pixel, black_pixel, "bottom right"); + GP_Text(win->context, &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, + green_pixel, black_pixel, "top left"); +} + +static void event_loop(void) +{ + GP_Event ev; + + while (GP_EventGet(&ev)) { + switch (ev.type) { + case GP_EV_KEY: + if (ev.code != GP_EV_KEY_DOWN) + continue; + + switch (ev.val.key.key) { + case GP_KEY_X: + win->context->x_swap = !win->context->x_swap; + break; + case GP_KEY_Y: + win->context->y_swap = !win->context->y_swap; + break; + case GP_KEY_R: + win->context->axes_swap = !win->context->axes_swap; + GP_SWAP(X, Y); + break; + case GP_KEY_SPACE: + font_flag++; + + if (font) { + if (font_flag >= 3) + font_flag = 0; + } else { + if (font_flag >= 2) + font_flag = 0; + } + break; + case GP_KEY_ESC: + GP_BackendExit(win); + exit(0); + break; + } + break; + case GP_EV_SYS: + switch(ev.code) { + case GP_EV_SYS_QUIT: + GP_BackendExit(win); + exit(0); + break; + } + break; + } + + redraw_screen(); + GP_BackendFlip(win); + } +} + +void print_instructions(void) +{ + printf("Use the following keys to control the test:n"); + printf(" Space ........ toggle proportional/nonproportional fontn"); + printf(" X ............ mirror Xn"); + printf(" Y ............ mirror Yn"); + printf(" R ............ reverse X and Yn"); +} + +int main(int argc, char *argv[]) +{ + const char *backend_opts = "X11"; + + if (argc > 1) + font = GP_FontFaceLoad(argv[1], 0, 16); + + print_instructions(); + + win = GP_BackendInit(backend_opts, "Font Align Test", stderr); + + if (win == NULL) { + fprintf(stderr, "Failed to initalize backend '%s'n", + backend_opts); + return 1; + } + + black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, win->context); + red_pixel = GP_ColorToContextPixel(GP_COL_RED, win->context); + blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, win->context); + green_pixel = GP_ColorToContextPixel(GP_COL_GREEN, win->context); + yellow_pixel = GP_ColorToContextPixel(GP_COL_YELLOW, win->context); + darkgray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_DARK, win->context); + + redraw_screen(); + + GP_BackendFlip(win); + + for (;;) { + GP_BackendWait(win); + event_loop(); + } +} +
http://repo.or.cz/w/gfxprim.git/commit/cd4e4016c7c2bd7293eec6d9cc99e3355cc8d...
commit cd4e4016c7c2bd7293eec6d9cc99e3355cc8dd38 Author: Cyril Hrubis metan@ucw.cz Date: Sun Nov 25 21:50:16 2012 +0100
tests: core: Add SubContext assertions.
diff --git a/tests/core/Context.c b/tests/core/Context.c index 4e05306..af26656 100644 --- a/tests/core/Context.c +++ b/tests/core/Context.c @@ -96,11 +96,125 @@ static int Context_Alloc_Free(void) return TST_SUCCESS; }
+/* + * Asserts that subcontext structure is initialized correctly + */ +static int subcontext_assert(const GP_Context *c, const GP_Context *sc, + GP_Size w, GP_Size h) +{ + if (c->bpp != sc->bpp) { + tst_msg("Context->bpp != SubContext->bpp"); + return TST_FAILED; + } + + if (c->bytes_per_row != sc->bytes_per_row) { + tst_msg("Context->bytes_per_row != SubContext->bytes_per_row"); + return TST_FAILED; + } + + if (sc->w != w) { + tst_msg("SubContext->w != %u (== %i)", w, sc->w); + return TST_FAILED; + } + + if (sc->h != h) { + tst_msg("SubContext->h != %u (== %i)", h, sc->h); + return TST_FAILED; + } + + if (sc->offset != 0) { + tst_msg("SubContext->offset != 0"); + return TST_FAILED; + } + + if (sc->pixel_type != GP_PIXEL_RGB888) { + tst_msg("SubContext->pixel_type != GP_PIXEL_RGB888"); + return TST_FAILED; + } + + if (sc->gamma != NULL) { + tst_msg("SubContext->gamma != NULL"); + return TST_FAILED; + } + + if (sc->axes_swap != 0 || sc->x_swap != 0 || sc->y_swap != 0) { + tst_msg("Wrong default orientation %i %i %i", + sc->axes_swap, sc->x_swap, sc->y_swap); + return TST_FAILED; + } + + /* access the start and end of the pixel buffer */ + *(char*)GP_PIXEL_ADDR(sc, 0, 0) = 0; + *(char*)GP_PIXEL_ADDR(sc, sc->w - 1, sc->h - 1) = 0; + + return 0; +} + +static int SubContext_Alloc_Free(void) +{ + GP_Context *c, *sc; + int ret; + + c = GP_ContextAlloc(300, 300, GP_PIXEL_RGB888); + + if (c == NULL) { + tst_msg("GP_ContextAlloc() failed"); + return TST_UNTESTED; + } + + sc = GP_SubContextAlloc(c, 100, 100, 100, 100); + + if (sc == NULL) { + GP_ContextFree(c); + return TST_FAILED; + } + + ret = subcontext_assert(c, sc, 100, 100); + + if (ret) + return ret; + + GP_ContextFree(c); + GP_ContextFree(sc); + + return TST_SUCCESS; +} + +static int SubContext_Create(void) +{ + GP_Context *c, sc; + int ret; + + c = GP_ContextAlloc(300, 300, GP_PIXEL_RGB888); + + if (c == NULL) { + tst_msg("GP_ContextAlloc() failed"); + return TST_UNTESTED; + } + + GP_SubContext(c, &sc, 100, 100, 100, 100); + + ret = subcontext_assert(c, &sc, 100, 100); + + if (ret) + return ret; + + GP_ContextFree(c); + + return TST_SUCCESS; +} + + const struct tst_suite tst_suite = { .suite_name = "Context Testsuite", .tests = { {.name = "Context Alloc Free", .tst_fn = Context_Alloc_Free, .flags = TST_CHECK_MALLOC}, + {.name = "SubContext Alloc Free", + .tst_fn = SubContext_Alloc_Free, + .flags = TST_CHECK_MALLOC}, + {.name = "SubContext Create", + .tst_fn = SubContext_Create}, {.name = NULL}, } };
-----------------------------------------------------------------------
Summary of changes: demos/c_simple/Makefile | 3 +- {tests/SDL => demos/c_simple}/textaligntest.c | 156 ++++++-------- tests/Makefile | 2 +- tests/SDL/Makefile | 15 -- tests/SDL/mixpixeltest.c | 228 -------------------- tests/SDL/runtest.sh | 10 - tests/SDL/subcontext.c | 281 ------------------------- tests/core/Context.c | 114 ++++++++++ 8 files changed, 186 insertions(+), 623 deletions(-) rename {tests/SDL => demos/c_simple}/textaligntest.c (57%) delete mode 100644 tests/SDL/Makefile delete mode 100644 tests/SDL/mixpixeltest.c delete mode 100755 tests/SDL/runtest.sh delete mode 100644 tests/SDL/subcontext.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.