소스 검색

Coding style: remove tabs and trailing spaces.

tags/v0.99.beta17
Sam Hocevar sam 15 년 전
부모
커밋
644ee4a78a
14개의 변경된 파일1515개의 추가작업 그리고 1498개의 파일을 삭제
  1. +1365
    -1365
      caca-php/php_caca.c
  2. +1
    -1
      caca/codec/export.c
  3. +34
    -34
      caca/driver/cocoa.m
  4. +3
    -3
      caca/driver/gl.c
  5. +1
    -1
      caca/figfont.c
  6. +1
    -1
      examples/import.c
  7. +40
    -40
      python/pypycaca.c
  8. +5
    -5
      ruby/caca-canvas.c
  9. +3
    -3
      ruby/caca-display.c
  10. +9
    -9
      ruby/caca-dither.c
  11. +2
    -2
      ruby/caca-event.c
  12. +7
    -7
      ruby/caca-font.c
  13. +15
    -15
      src/aafire.c
  14. +29
    -12
      tests/bench.c

+ 1365
- 1365
caca-php/php_caca.c
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 1
- 1
caca/codec/export.c 파일 보기

@@ -413,7 +413,7 @@ static void *export_html3(caca_canvas_t const *cv, size_t *bytes)
cell_boundary_bitmap[x / 8] |= 1 << (x % 8); cell_boundary_bitmap[x / 8] |= 1 << (x % 8);
} }
} }
/* The HTML table markup: less than 1000 bytes /* The HTML table markup: less than 1000 bytes
* A line: 10 chars for "<tr></tr>\n" * A line: 10 chars for "<tr></tr>\n"
* A glyph: up to 48 chars for "<td bgcolor=\"#xxxxxx\"><tt><font color=\"#xxxxxx\">" * A glyph: up to 48 chars for "<td bgcolor=\"#xxxxxx\"><tt><font color=\"#xxxxxx\">"


+ 34
- 34
caca/driver/cocoa.m 파일 보기

@@ -164,9 +164,9 @@ static BOOL s_quitting = NO;
float fh = _font_rect.size.height; float fh = _font_rect.size.height;
_w = ceilf([self bounds].size.width / fw); _w = ceilf([self bounds].size.width / fw);
_h = ceilf([self bounds].size.height / fh); _h = ceilf([self bounds].size.height / fh);
debug_log(@"fw=%f selfw=%f %u %f", fw, [self bounds].size.width,
debug_log(@"fw=%f selfw=%f %u %f", fw, [self bounds].size.width,
_w, [self bounds].size.width-(_w*fw)); _w, [self bounds].size.width-(_w*fw));
debug_log(@"fh=%f selfh=%f %u %f", fh, [self bounds].size.height,
debug_log(@"fh=%f selfh=%f %u %f", fh, [self bounds].size.height,
_h, [self bounds].size.height-(_h*fh)); _h, [self bounds].size.height-(_h*fh));
} }


@@ -199,18 +199,18 @@ static BOOL s_quitting = NO;
|| !_attrs || !_bkg_rects || !_bkg_colors) || !_attrs || !_bkg_rects || !_bkg_colors)
{ {
debug_log(@"%s resize to %ux%u", _cmd, _w, _h); debug_log(@"%s resize to %ux%u", _cmd, _w, _h);
_w = caca_get_canvas_width(dp->cv); _w = caca_get_canvas_width(dp->cv);
_h = caca_get_canvas_height(dp->cv); _h = caca_get_canvas_height(dp->cv);


if(_attrs) if(_attrs)
free(_attrs); free(_attrs);
_attrs = malloc(_w * _h * sizeof(uint32_t) * 2); _attrs = malloc(_w * _h * sizeof(uint32_t) * 2);
if(_bkg_rects) if(_bkg_rects)
free(_bkg_rects); free(_bkg_rects);
_bkg_rects = malloc(_w * _h * sizeof(NSRect)); _bkg_rects = malloc(_w * _h * sizeof(NSRect));
if(_bkg_colors) if(_bkg_colors)
free(_bkg_colors); free(_bkg_colors);
_bkg_colors = malloc(_w * _h * sizeof(NSColor*)); _bkg_colors = malloc(_w * _h * sizeof(NSColor*));
@@ -346,7 +346,7 @@ static BOOL s_quitting = NO;
#else // USE_RGB12_FGBG #else // USE_RGB12_FGBG
uint8_t argb[8]; uint8_t argb[8];
caca_attr_to_argb64(*attrs, argb); caca_attr_to_argb64(*attrs, argb);
debug_log(@"x,y=[%d,%d] r,g,b back=[%u %u %u] front=[%u %u %u]",
debug_log(@"x,y=[%d,%d] r,g,b back=[%u %u %u] front=[%u %u %u]",
x, y, argb[1], argb[2], argb[3], argb[5], argb[6], argb[7]); x, y, argb[1], argb[2], argb[3], argb[5], argb[6], argb[7]);
color = [NSColor colorWithCalibratedRed:((float)argb[5]) / 15.0 color = [NSColor colorWithCalibratedRed:((float)argb[5]) / 15.0
green:((float)argb[6]) / 15.0 green:((float)argb[6]) / 15.0
@@ -356,7 +356,7 @@ static BOOL s_quitting = NO;


if(color) if(color)
{ {
NSMutableDictionary* attrDict = (*attrs & CACA_UNDERLINE) ?
NSMutableDictionary* attrDict = (*attrs & CACA_UNDERLINE) ?
_attrDictUnderline : _attrDict; _attrDictUnderline : _attrDict;
[attrDict setObject:color forKey:NSForegroundColorAttributeName]; [attrDict setObject:color forKey:NSForegroundColorAttributeName];


@@ -460,7 +460,7 @@ struct driver_private


static NSString* get_application_name() static NSString* get_application_name()
{ {
NSString* appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:
NSString* appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:
@"CFBundleName"]; @"CFBundleName"];
if(![appName length]) if(![appName length])
appName = [[NSProcessInfo processInfo] processName]; appName = [[NSProcessInfo processInfo] processName];
@@ -476,32 +476,32 @@ static void create_application_menus()
/* Create the application menu */ /* Create the application menu */
NSString* appName = get_application_name(); NSString* appName = get_application_name();
NSMenu* appleMenu = [[NSMenu alloc] initWithTitle:@""]; NSMenu* appleMenu = [[NSMenu alloc] initWithTitle:@""];
/* Add menu items */ /* Add menu items */
NSString* title = [@"About " stringByAppendingString:appName]; NSString* title = [@"About " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title
action:@selector(orderFrontStandardAboutPanel:)
[appleMenu addItemWithTitle:title
action:@selector(orderFrontStandardAboutPanel:)
keyEquivalent:@""]; keyEquivalent:@""];
[appleMenu addItem:[NSMenuItem separatorItem]]; [appleMenu addItem:[NSMenuItem separatorItem]];


title = [@"Hide " stringByAppendingString:appName]; title = [@"Hide " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(hide:)
[appleMenu addItemWithTitle:title action:@selector(hide:)
keyEquivalent:@"h"]; keyEquivalent:@"h"];


id<NSMenuItem> menuItem = [appleMenu addItemWithTitle:@"Hide Others"
id<NSMenuItem> menuItem = [appleMenu addItemWithTitle:@"Hide Others"
action:@selector(hideOtherApplications:) action:@selector(hideOtherApplications:)
keyEquivalent:@"h"]; keyEquivalent:@"h"];
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)]; [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];


[appleMenu addItemWithTitle:@"Show All"
[appleMenu addItemWithTitle:@"Show All"
action:@selector(unhideAllApplications:) action:@selector(unhideAllApplications:)
keyEquivalent:@""]; keyEquivalent:@""];
[appleMenu addItem:[NSMenuItem separatorItem]]; [appleMenu addItem:[NSMenuItem separatorItem]];


title = [@"Quit " stringByAppendingString:appName]; title = [@"Quit " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(terminate:)
[appleMenu addItemWithTitle:title action:@selector(terminate:)
keyEquivalent:@"q"]; keyEquivalent:@"q"];
/* Put menu into the menubar */ /* Put menu into the menubar */
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
[menuItem setSubmenu:appleMenu]; [menuItem setSubmenu:appleMenu];
@@ -514,20 +514,20 @@ static void create_application_menus()


/* Create the window menu */ /* Create the window menu */
NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
/* "Minimize" item */ /* "Minimize" item */
menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize"
action:@selector(performMiniaturize:)
menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize"
action:@selector(performMiniaturize:)
keyEquivalent:@"m"]; keyEquivalent:@"m"];
[windowMenu addItem:menuItem]; [windowMenu addItem:menuItem];
[menuItem release]; [menuItem release];
/* Put menu into the menubar */ /* Put menu into the menubar */
menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
[menuItem setSubmenu:windowMenu]; [menuItem setSubmenu:windowMenu];
[[NSApp mainMenu] addItem:menuItem]; [[NSApp mainMenu] addItem:menuItem];
[menuItem release]; [menuItem release];
/* Tell the application object that this is now the window menu */ /* Tell the application object that this is now the window menu */
[NSApp setWindowsMenu:windowMenu]; [NSApp setWindowsMenu:windowMenu];
[windowMenu release]; [windowMenu release];
@@ -561,11 +561,11 @@ static void register_cocoa_app(caca_display_t *dp)
static __inline__ void convert_NSRect(NSRect *r) static __inline__ void convert_NSRect(NSRect *r)
{ {
float mb_height = 38.0; // [[NSApp mainMenu] menuBarHeight] is 0 - wtf ? float mb_height = 38.0; // [[NSApp mainMenu] menuBarHeight] is 0 - wtf ?
/*debug_log(@"%@ %f %f %d %d %d", [NSApp mainMenu],
[[NSApp mainMenu] menuBarHeight], mb_height,
(int)CGDisplayPixelsHigh(kCGDirectMainDisplay),
/*debug_log(@"%@ %f %f %d %d %d", [NSApp mainMenu],
[[NSApp mainMenu] menuBarHeight], mb_height,
(int)CGDisplayPixelsHigh(kCGDirectMainDisplay),
(int)r->origin.y, (int)r->size.height);*/ (int)r->origin.y, (int)r->size.height);*/
r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - mb_height
r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - mb_height
- r->origin.y - r->size.height; - r->origin.y - r->size.height;
} }


@@ -617,7 +617,7 @@ static int get_caca_keycode(NSEvent* event)
if(ch >= 'a' && ch <= 'z') if(ch >= 'a' && ch <= 'z')
caca_keycode = CACA_KEY_CTRL_A + ch - 'a'; caca_keycode = CACA_KEY_CTRL_A + ch - 'a';
} }
if(!caca_keycode) if(!caca_keycode)
{ {
NSString *chars = [event characters]; NSString *chars = [event characters];
@@ -728,9 +728,9 @@ static BOOL handle_key_event(caca_privevent_t *ev, NSEvent* event)
{ {
if(!ev || !event) if(!ev || !event)
return NO; return NO;
BOOL eventHandled = NO; BOOL eventHandled = NO;
if([event modifierFlags] & NSCommandKeyMask) if([event modifierFlags] & NSCommandKeyMask)
{ {
// let the system handle the Apple-commands for now // let the system handle the Apple-commands for now
@@ -767,7 +767,7 @@ static BOOL handle_key_event(caca_privevent_t *ev, NSEvent* event)
ev->data.key.utf32 = (uint32_t)mac_keycode; ev->data.key.utf32 = (uint32_t)mac_keycode;
ev->data.key.utf8[0] = mac_keycode & 0x00ff; // FIXME: endianness ev->data.key.utf8[0] = mac_keycode & 0x00ff; // FIXME: endianness
ev->data.key.utf8[1] = mac_keycode & 0xff00; ev->data.key.utf8[1] = mac_keycode & 0xff00;
eventHandled = YES; eventHandled = YES;
} }
} }
@@ -859,7 +859,7 @@ static int cocoa_init_graphics(caca_display_t *dp)


static int cocoa_end_graphics(caca_display_t *dp) static int cocoa_end_graphics(caca_display_t *dp)
{ {
debug_log(@"%s dp->cv: %ux%u", __PRETTY_FUNCTION__,
debug_log(@"%s dp->cv: %ux%u", __PRETTY_FUNCTION__,
caca_get_canvas_width(dp->cv), caca_get_canvas_height(dp->cv)); caca_get_canvas_width(dp->cv), caca_get_canvas_height(dp->cv));


NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -908,9 +908,9 @@ static int cocoa_get_event(caca_display_t *dp, caca_privevent_t *ev)


if([NSApp isRunning]) if([NSApp isRunning])
{ {
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantPast]
inMode:NSDefaultRunLoopMode
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantPast]
inMode:NSDefaultRunLoopMode
dequeue:YES]; dequeue:YES];
if(event) if(event)
{ {
@@ -923,7 +923,7 @@ static int cocoa_get_event(caca_display_t *dp, caca_privevent_t *ev)


case NSFlagsChanged: case NSFlagsChanged:
break; break;
case NSLeftMouseDown: case NSLeftMouseDown:
case NSLeftMouseUp: case NSLeftMouseUp:
case NSRightMouseDown: case NSRightMouseDown:


+ 3
- 3
caca/driver/gl.c 파일 보기

@@ -1,6 +1,6 @@
/* /*
* libcaca Colour ASCII-Art library * libcaca Colour ASCII-Art library
* Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
* Copyright (c) 2002-2006 Sam Hocevar <sam@hocevar.net>
* 2006 Jean-Yves Lamoureux <jylam@lnxscene.org> * 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
* 2007 Ben Wiley Sittler <bsittler@gmail.com> * 2007 Ben Wiley Sittler <bsittler@gmail.com>
* All Rights Reserved * All Rights Reserved
@@ -562,7 +562,7 @@ static void gl_compute_font(caca_display_t *dp)
caca_utf32_is_fullwidth(dp->drv.p->blocks[i] + j); caca_utf32_is_fullwidth(dp->drv.p->blocks[i] + j);


memset(tmp, 0, 16 * 8 * 16); memset(tmp, 0, 16 * 8 * 16);
for(y = 0; y < h; y++) for(y = 0; y < h; y++)
{ {
for(x = 0; x < w * (fullwidth ? 2 : 1); x++) for(x = 0; x < w * (fullwidth ? 2 : 1); x++)
@@ -576,7 +576,7 @@ static void gl_compute_font(caca_display_t *dp)
tmp[offset * 4 + 3] = c; tmp[offset * 4 + 3] = c;
} }
} }
glGenTextures(1, (GLuint*)&dp->drv.p->txid[b + j]); glGenTextures(1, (GLuint*)&dp->drv.p->txid[b + j]);
glBindTexture(GL_TEXTURE_2D, dp->drv.p->txid[b + j]); glBindTexture(GL_TEXTURE_2D, dp->drv.p->txid[b + j]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);


+ 1
- 1
caca/figfont.c 파일 보기

@@ -132,7 +132,7 @@ int caca_put_figchar(caca_canvas_t *cv, uint32_t ch)
caca_figfont_t *ff = cv->ff; caca_figfont_t *ff = cv->ff;
int c, w, h, x, y, overlap, extra, xleft, xright; int c, w, h, x, y, overlap, extra, xleft, xright;


if (!ff)
if (!ff)
return -1; return -1;


switch(ch) switch(ch)


+ 1
- 1
examples/import.c 파일 보기

@@ -42,7 +42,7 @@ int main(int argc, char *argv[])


if(caca_import_canvas_from_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0) if(caca_import_canvas_from_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0)
{ {
fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
caca_free_canvas(cv); caca_free_canvas(cv);
return 1; return 1;
} }


+ 40
- 40
python/pypycaca.c 파일 보기

@@ -59,7 +59,7 @@ static PyMethodDef CacaMethods[] = {
{"putstr", pycaca_putstr, METH_VARARGS, ""}, {"putstr", pycaca_putstr, METH_VARARGS, ""},
{"printf", pycaca_printf, METH_VARARGS, ""}, {"printf", pycaca_printf, METH_VARARGS, ""},
{"clear", pycaca_clear, METH_VARARGS, ""}, {"clear", pycaca_clear, METH_VARARGS, ""},
{"load_sprite", pycaca_load_sprite, METH_VARARGS, ""}, {"load_sprite", pycaca_load_sprite, METH_VARARGS, ""},
{"draw_sprite", pycaca_draw_sprite, METH_VARARGS, ""}, {"draw_sprite", pycaca_draw_sprite, METH_VARARGS, ""},
{"get_sprite_frames", pycaca_get_sprite_frames, METH_VARARGS, ""}, {"get_sprite_frames", pycaca_get_sprite_frames, METH_VARARGS, ""},
@@ -79,7 +79,7 @@ static PyMethodDef CacaMethods[] = {
{"set_bitmap_gamma", pycaca_set_bitmap_gamma, METH_VARARGS, ""}, {"set_bitmap_gamma", pycaca_set_bitmap_gamma, METH_VARARGS, ""},
{"draw_bitmap", pycaca_draw_bitmap, METH_VARARGS, ""}, {"draw_bitmap", pycaca_draw_bitmap, METH_VARARGS, ""},
{"free_bitmap", pycaca_free_bitmap, METH_VARARGS, ""}, {"free_bitmap", pycaca_free_bitmap, METH_VARARGS, ""},






@@ -98,7 +98,7 @@ initcaca(void)


obj = Py_InitModule("caca", CacaMethods); obj = Py_InitModule("caca", CacaMethods);
dict = PyModule_GetDict(obj); dict = PyModule_GetDict(obj);
SET_INTCONSTANT(dict,CACA_EVENT_NONE ); SET_INTCONSTANT(dict,CACA_EVENT_NONE );
SET_INTCONSTANT(dict,CACA_EVENT_KEY_PRESS ); SET_INTCONSTANT(dict,CACA_EVENT_KEY_PRESS );
SET_INTCONSTANT(dict,CACA_EVENT_KEY_RELEASE ); SET_INTCONSTANT(dict,CACA_EVENT_KEY_RELEASE );
@@ -107,7 +107,7 @@ initcaca(void)
SET_INTCONSTANT(dict,CACA_EVENT_MOUSE_MOTION ); SET_INTCONSTANT(dict,CACA_EVENT_MOUSE_MOTION );
SET_INTCONSTANT(dict,CACA_EVENT_RESIZE ); SET_INTCONSTANT(dict,CACA_EVENT_RESIZE );
SET_INTCONSTANT(dict,CACA_EVENT_ANY ); SET_INTCONSTANT(dict,CACA_EVENT_ANY );
SET_INTCONSTANT(dict, CACA_COLOR_BLACK ); SET_INTCONSTANT(dict, CACA_COLOR_BLACK );
SET_INTCONSTANT(dict, CACA_COLOR_BLUE ); SET_INTCONSTANT(dict, CACA_COLOR_BLUE );
SET_INTCONSTANT(dict, CACA_COLOR_GREEN ); SET_INTCONSTANT(dict, CACA_COLOR_GREEN );
@@ -191,7 +191,7 @@ static PyObject *
pycaca_init(PyObject *self, PyObject *args) pycaca_init(PyObject *self, PyObject *args)
{ {
int ret; int ret;
ret = caca_init(); ret = caca_init();
return Py_BuildValue("i", ret); return Py_BuildValue("i", ret);
} }
@@ -300,7 +300,7 @@ pycaca_get_feature(PyObject *self, PyObject *args)
int value, ret; int value, ret;
if (!PyArg_ParseTuple(args, "i", &value)); if (!PyArg_ParseTuple(args, "i", &value));
ret = caca_get_feature(value); ret = caca_get_feature(value);
return Py_BuildValue("i", ret); return Py_BuildValue("i", ret);


} }
@@ -311,7 +311,7 @@ pycaca_set_feature(PyObject *self, PyObject *args)
int value; int value;
if (!PyArg_ParseTuple(args, "i", &value)); if (!PyArg_ParseTuple(args, "i", &value));
caca_set_feature(value); caca_set_feature(value);
return Py_BuildValue("i", 1); /* FIXME */ return Py_BuildValue("i", 1); /* FIXME */


} }
@@ -323,7 +323,7 @@ pycaca_get_feature_name(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "i", &value)); if (!PyArg_ParseTuple(args, "i", &value));


ret = (char* const)caca_get_feature_name(value); ret = (char* const)caca_get_feature_name(value);
return Py_BuildValue("s", ret); return Py_BuildValue("s", ret);
} }


@@ -337,7 +337,7 @@ pycaca_get_event(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "i", &value)); if (!PyArg_ParseTuple(args, "i", &value));


ret = caca_get_event(value); ret = caca_get_event(value);
return Py_BuildValue("i", ret); return Py_BuildValue("i", ret);
} }
static PyObject * static PyObject *
@@ -347,7 +347,7 @@ pycaca_wait_event(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "i", &value)); if (!PyArg_ParseTuple(args, "i", &value));


ret = caca_get_event(value); ret = caca_get_event(value);
return Py_BuildValue("i", ret); return Py_BuildValue("i", ret);
} }


@@ -373,7 +373,7 @@ pycaca_draw_line(PyObject *self, PyObject *args)
{ {
int x1, y1, x2, y2; int x1, y1, x2, y2;
char c; char c;
if (!PyArg_ParseTuple(args, "iiiic", &x1,&y1,&x2,&y2,&c)); if (!PyArg_ParseTuple(args, "iiiic", &x1,&y1,&x2,&y2,&c));
caca_draw_line(x1,y1,x2,y2,c); caca_draw_line(x1,y1,x2,y2,c);
return Py_BuildValue("i", 1); /* FIXME */ return Py_BuildValue("i", 1); /* FIXME */
@@ -384,12 +384,12 @@ pycaca_draw_polyline(PyObject *self, PyObject *args)
PyObject *list_x, *list_y, *item; PyObject *list_x, *list_y, *item;
int *x, *y, n, lenx, leny, i; int *x, *y, n, lenx, leny, i;
char c; char c;
if (!PyArg_ParseTuple(args, "OOic", &list_x, &list_y, &n, &c)); if (!PyArg_ParseTuple(args, "OOic", &list_x, &list_y, &n, &c));


lenx = PySequence_Length(list_x); lenx = PySequence_Length(list_x);
leny = PySequence_Length(list_y); leny = PySequence_Length(list_y);
x = (int*) malloc(lenx*sizeof(int)); x = (int*) malloc(lenx*sizeof(int));
y = (int*) malloc(leny*sizeof(int)); y = (int*) malloc(leny*sizeof(int));


@@ -418,7 +418,7 @@ static PyObject *
pycaca_draw_thin_line(PyObject *self, PyObject *args) pycaca_draw_thin_line(PyObject *self, PyObject *args)
{ {
int x1, y1, x2, y2; int x1, y1, x2, y2;
if (!PyArg_ParseTuple(args, "iiii", &x1,&y1,&x2,&y2)); if (!PyArg_ParseTuple(args, "iiii", &x1,&y1,&x2,&y2));
caca_draw_thin_line(x1,y1,x2,y2); caca_draw_thin_line(x1,y1,x2,y2);
return Py_BuildValue("i", 1); /* FIXME */ return Py_BuildValue("i", 1); /* FIXME */
@@ -429,12 +429,12 @@ pycaca_draw_thin_polyline(PyObject *self, PyObject *args)
{ {
PyObject *list_x, *list_y, *item; PyObject *list_x, *list_y, *item;
int *x, *y, n, lenx, leny, i; int *x, *y, n, lenx, leny, i;
if (!PyArg_ParseTuple(args, "OOi", &list_x, &list_y, &n)); if (!PyArg_ParseTuple(args, "OOi", &list_x, &list_y, &n));


lenx = PySequence_Length(list_x); lenx = PySequence_Length(list_x);
leny = PySequence_Length(list_y); leny = PySequence_Length(list_y);
x = (int*) malloc(lenx*sizeof(int)); x = (int*) malloc(lenx*sizeof(int));
y = (int*) malloc(leny*sizeof(int)); y = (int*) malloc(leny*sizeof(int));


@@ -564,14 +564,14 @@ static PyObject *
pycaca_get_fg_color(PyObject *self, PyObject *args) pycaca_get_fg_color(PyObject *self, PyObject *args)
{ {
int ret = caca_get_fg_color(); int ret = caca_get_fg_color();
return Py_BuildValue("i", ret);
return Py_BuildValue("i", ret);
} }


static PyObject * static PyObject *
pycaca_get_bg_color(PyObject *self, PyObject *args) pycaca_get_bg_color(PyObject *self, PyObject *args)
{ {
int ret = caca_get_bg_color(); int ret = caca_get_bg_color();
return Py_BuildValue("i", ret);
return Py_BuildValue("i", ret);
} }


static PyObject * static PyObject *
@@ -581,7 +581,7 @@ pycaca_get_color_name(PyObject *self, PyObject *args)
char *ret; char *ret;
if (!PyArg_ParseTuple(args, "i", &c)); if (!PyArg_ParseTuple(args, "i", &c));
ret = (char *)caca_get_color_name(c); ret = (char *)caca_get_color_name(c);
return Py_BuildValue("s", ret); /* FIXME */ return Py_BuildValue("s", ret); /* FIXME */
} }


@@ -648,7 +648,7 @@ pycaca_draw_sprite(PyObject *self, PyObject *args)


if (!PyArg_ParseTuple(args, "iiii", &x, &y, &sprite,&frame)); if (!PyArg_ParseTuple(args, "iiii", &x, &y, &sprite,&frame));
caca_draw_sprite(x,y, (struct caca_sprite const *)PyCObject_AsVoidPtr((void*)sprite), frame); caca_draw_sprite(x,y, (struct caca_sprite const *)PyCObject_AsVoidPtr((void*)sprite), frame);
return Py_BuildValue("i", 1); /* FIXME */ return Py_BuildValue("i", 1); /* FIXME */
} }


@@ -659,8 +659,8 @@ pycaca_get_sprite_frames(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "i", &sprite)); if (!PyArg_ParseTuple(args, "i", &sprite));
ret = caca_get_sprite_frames((struct caca_sprite const *)PyCObject_AsVoidPtr((void*)sprite)); ret = caca_get_sprite_frames((struct caca_sprite const *)PyCObject_AsVoidPtr((void*)sprite));


return Py_BuildValue("i", ret);
return Py_BuildValue("i", ret);
} }


static PyObject * static PyObject *
@@ -670,7 +670,7 @@ pycaca_get_sprite_width(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "ii", &sprite, &i)); if (!PyArg_ParseTuple(args, "ii", &sprite, &i));
ret = caca_get_sprite_width((struct caca_sprite const *)PyCObject_AsVoidPtr((void*)sprite),i); ret = caca_get_sprite_width((struct caca_sprite const *)PyCObject_AsVoidPtr((void*)sprite),i);


return Py_BuildValue("i", ret);
return Py_BuildValue("i", ret);


} }


@@ -680,8 +680,8 @@ pycaca_get_sprite_height(PyObject *self, PyObject *args)
int sprite, ret, i; int sprite, ret, i;
if (!PyArg_ParseTuple(args, "ii", &sprite, i)); if (!PyArg_ParseTuple(args, "ii", &sprite, i));
ret = caca_get_sprite_height((struct caca_sprite const *)PyCObject_AsVoidPtr((void*)sprite),i); ret = caca_get_sprite_height((struct caca_sprite const *)PyCObject_AsVoidPtr((void*)sprite),i);
return Py_BuildValue("i", ret);
return Py_BuildValue("i", ret);
} }


static PyObject * static PyObject *
@@ -690,8 +690,8 @@ pycaca_get_sprite_dx(PyObject *self, PyObject *args)
int sprite, ret, i; int sprite, ret, i;
if (!PyArg_ParseTuple(args, "ii", &sprite), &i); if (!PyArg_ParseTuple(args, "ii", &sprite), &i);
ret = caca_get_sprite_dx((struct caca_sprite const *)PyCObject_AsVoidPtr((void*)sprite),i); ret = caca_get_sprite_dx((struct caca_sprite const *)PyCObject_AsVoidPtr((void*)sprite),i);
return Py_BuildValue("i", ret);
return Py_BuildValue("i", ret);
} }


static PyObject * static PyObject *
@@ -700,8 +700,8 @@ pycaca_get_sprite_dy(PyObject *self, PyObject *args)
int sprite, ret, i; int sprite, ret, i;
if (!PyArg_ParseTuple(args, "ii", &sprite), &i); if (!PyArg_ParseTuple(args, "ii", &sprite), &i);
ret = caca_get_sprite_dy((struct caca_sprite const *)PyCObject_AsVoidPtr((void*)sprite),i); ret = caca_get_sprite_dy((struct caca_sprite const *)PyCObject_AsVoidPtr((void*)sprite),i);
return Py_BuildValue("i", ret);
return Py_BuildValue("i", ret);
} }


static PyObject * static PyObject *
@@ -710,7 +710,7 @@ pycaca_free_sprite(PyObject *self, PyObject *args)
int sprite; int sprite;
if (!PyArg_ParseTuple(args, "i", &sprite)); if (!PyArg_ParseTuple(args, "i", &sprite));
caca_free_sprite((struct caca_sprite *)PyCObject_AsVoidPtr((void*)sprite)); caca_free_sprite((struct caca_sprite *)PyCObject_AsVoidPtr((void*)sprite));
return Py_BuildValue("i", 1); /* FIXME */ return Py_BuildValue("i", 1); /* FIXME */
} }


@@ -722,7 +722,7 @@ pycaca_get_html(PyObject *self, PyObject *args)
{ {
if (!PyArg_ParseTuple(args, "")); if (!PyArg_ParseTuple(args, ""));


return Py_BuildValue("s",caca_get_html());
return Py_BuildValue("s",caca_get_html());
} }


static PyObject * static PyObject *
@@ -730,7 +730,7 @@ pycaca_get_html3(PyObject *self, PyObject *args)
{ {
if (!PyArg_ParseTuple(args, "")); if (!PyArg_ParseTuple(args, ""));


return Py_BuildValue("s",caca_get_html3());
return Py_BuildValue("s",caca_get_html3());
} }


static PyObject * static PyObject *
@@ -738,7 +738,7 @@ pycaca_get_irc(PyObject *self, PyObject *args)
{ {
if (!PyArg_ParseTuple(args, "")); if (!PyArg_ParseTuple(args, ""));


return Py_BuildValue("s",caca_get_irc());
return Py_BuildValue("s",caca_get_irc());
} }


static PyObject * static PyObject *
@@ -746,8 +746,8 @@ pycaca_get_ansi(PyObject *self, PyObject *args)
{ {
int trailing; int trailing;
if (!PyArg_ParseTuple(args, "i", &trailing)); if (!PyArg_ParseTuple(args, "i", &trailing));
return Py_BuildValue("s",caca_get_ansi(trailing));
return Py_BuildValue("s",caca_get_ansi(trailing));
} }


/**********/ /**********/
@@ -773,7 +773,7 @@ pycaca_set_bitmap_palette(PyObject *self, PyObject *args)
unsigned int *r,*g,*b,*a,i; unsigned int *r,*g,*b,*a,i;


if (!PyArg_ParseTuple(args, "iOOOO", &bitmap, &list_r, &list_g, &list_b, &list_a)); if (!PyArg_ParseTuple(args, "iOOOO", &bitmap, &list_r, &list_g, &list_b, &list_a));
if((PySequence_Length(list_r)!=256) || if((PySequence_Length(list_r)!=256) ||
(PySequence_Length(list_g)!=256) || (PySequence_Length(list_g)!=256) ||
(PySequence_Length(list_b)!=256) || (PySequence_Length(list_b)!=256) ||
@@ -781,7 +781,7 @@ pycaca_set_bitmap_palette(PyObject *self, PyObject *args)
{ {
PyErr_SetString(PyExc_TypeError, "Lengths of colors lists must be 256"); PyErr_SetString(PyExc_TypeError, "Lengths of colors lists must be 256");
} }
r = malloc(256*sizeof(unsigned int)); r = malloc(256*sizeof(unsigned int));
g = malloc(256*sizeof(unsigned int)); g = malloc(256*sizeof(unsigned int));
b = malloc(256*sizeof(unsigned int)); b = malloc(256*sizeof(unsigned int));
@@ -826,17 +826,17 @@ pycaca_draw_bitmap(PyObject *self, PyObject *args)
int i; int i;


if (!PyArg_ParseTuple(args, "iiiiiO", &x1,&y1,&x2,&y2,&bitmap,&pixels)); if (!PyArg_ParseTuple(args, "iiiiiO", &x1,&y1,&x2,&y2,&bitmap,&pixels));


buffer = malloc(PySequence_Length(pixels)*sizeof(unsigned char)); buffer = malloc(PySequence_Length(pixels)*sizeof(unsigned char));


for(i=0;i<PySequence_Length(pixels);i++) for(i=0;i<PySequence_Length(pixels);i++)
{ {
item = PySequence_GetItem(pixels, i); item = PySequence_GetItem(pixels, i);
buffer[i] = (unsigned char)PyInt_AsLong(item); buffer[i] = (unsigned char)PyInt_AsLong(item);
} }




caca_draw_bitmap(x1,y1,x2,y2, (struct caca_bitmap *)PyCObject_AsVoidPtr((void*)bitmap), (void*)buffer); caca_draw_bitmap(x1,y1,x2,y2, (struct caca_bitmap *)PyCObject_AsVoidPtr((void*)bitmap), (void*)buffer);


+ 5
- 5
ruby/caca-canvas.c 파일 보기

@@ -225,7 +225,7 @@ static VALUE blit(int argc, VALUE* argv, VALUE self) {
} }
else else
cmask = NULL; cmask = NULL;
if(caca_blit(_SELF, NUM2INT(x), NUM2INT(y), csrc, cmask)<0) if(caca_blit(_SELF, NUM2INT(x), NUM2INT(y), csrc, cmask)<0)
rb_raise(rb_eRuntimeError, strerror(errno)); rb_raise(rb_eRuntimeError, strerror(errno));


@@ -295,7 +295,7 @@ static VALUE draw_polyline(VALUE self, VALUE points, VALUE ch)
} else } else
error = 1; error = 1;
} }
else
else
error = 1; error = 1;
} }


@@ -357,7 +357,7 @@ static VALUE draw_thin_polyline(VALUE self, VALUE points)
} else } else
error = 1; error = 1;
} }
else
else
error = 1; error = 1;
} }


@@ -583,7 +583,7 @@ void Init_caca_canvas(VALUE mCaca)
rb_define_method(cCanvas, "height=", set_canvas_height, 1); rb_define_method(cCanvas, "height=", set_canvas_height, 1);
rb_define_method(cCanvas, "set_height", set_canvas_height2, 1); rb_define_method(cCanvas, "set_height", set_canvas_height2, 1);
rb_define_method(cCanvas, "set_size", set_canvas_size, 2); rb_define_method(cCanvas, "set_size", set_canvas_size, 2);
rb_define_method(cCanvas, "gotoxy", gotoxy, 2); rb_define_method(cCanvas, "gotoxy", gotoxy, 2);
rb_define_method(cCanvas, "cursor_x", get_cursor_x, 0); rb_define_method(cCanvas, "cursor_x", get_cursor_x, 0);
rb_define_method(cCanvas, "cursor_y", get_cursor_y, 0); rb_define_method(cCanvas, "cursor_y", get_cursor_y, 0);
@@ -594,7 +594,7 @@ void Init_caca_canvas(VALUE mCaca)
rb_define_method(cCanvas, "set_boundaries", set_canvas_boundaries, 4); rb_define_method(cCanvas, "set_boundaries", set_canvas_boundaries, 4);


rb_define_method(cCanvas, "clear", clear_canvas, 0); rb_define_method(cCanvas, "clear", clear_canvas, 0);
rb_define_method(cCanvas, "put_char", put_char, 3); rb_define_method(cCanvas, "put_char", put_char, 3);
rb_define_method(cCanvas, "get_char", get_char, 2); rb_define_method(cCanvas, "get_char", get_char, 2);
rb_define_method(cCanvas, "put_str", put_str, 3); rb_define_method(cCanvas, "put_str", put_str, 3);


+ 3
- 3
ruby/caca-display.c 파일 보기

@@ -72,10 +72,10 @@ static VALUE display_initialize(int argc, VALUE* argv, VALUE self)
if(driver == NULL) if(driver == NULL)
{ {
display = caca_create_display(canvas); display = caca_create_display(canvas);
if(display && NIL_P(cv))
{
if(display && NIL_P(cv))
{
cv = canvas_create(caca_get_canvas(display)); cv = canvas_create(caca_get_canvas(display));
}
}
} }
else else
{ {


+ 9
- 9
ruby/caca-dither.c 파일 보기

@@ -24,7 +24,7 @@ void dither_free(void *dither)
static VALUE dither_alloc(VALUE klass) static VALUE dither_alloc(VALUE klass)
{ {
VALUE obj; VALUE obj;
obj = Data_Wrap_Struct(klass, 0, dither_free, NULL);
obj = Data_Wrap_Struct(klass, 0, dither_free, NULL);
return obj; return obj;
} }


@@ -102,7 +102,7 @@ static VALUE set_dither_palette(VALUE self, VALUE palette)
} else } else
error = 1; error = 1;
} }
else
else
error = 1; error = 1;
} }


@@ -111,7 +111,7 @@ static VALUE set_dither_palette(VALUE self, VALUE palette)
free(red); free(red);
free(green); free(green);
free(blue); free(blue);
free(alpha);
free(alpha);
rb_raise(rb_eArgError, "Invalid palette"); rb_raise(rb_eArgError, "Invalid palette");
} }


@@ -120,7 +120,7 @@ static VALUE set_dither_palette(VALUE self, VALUE palette)
free(red); free(red);
free(green); free(green);
free(blue); free(blue);
free(alpha);
free(alpha);
rb_raise(rb_eRuntimeError, strerror(errno)); rb_raise(rb_eRuntimeError, strerror(errno));
} }


@@ -128,7 +128,7 @@ static VALUE set_dither_palette(VALUE self, VALUE palette)
free(green); free(green);
free(blue); free(blue);
free(alpha); free(alpha);
return palette; return palette;
} }


@@ -139,15 +139,15 @@ static VALUE set_dither_palette2(VALUE self, VALUE palette)
} }


#define set_float(x) \ #define set_float(x) \
static VALUE set_##x(VALUE self, VALUE x) \
static VALUE set_##x(VALUE self, VALUE x) \
{ \ { \
if(caca_set_dither_##x(_SELF, (float)NUM2DBL(x))<0)\
if(caca_set_dither_##x(_SELF, (float)NUM2DBL(x))<0) \
rb_raise(rb_eRuntimeError, strerror(errno)); \ rb_raise(rb_eRuntimeError, strerror(errno)); \
\ \
return x; \ return x; \
} \ } \
\ \
static VALUE set_##x##2(VALUE self, VALUE x) \
static VALUE set_##x##2(VALUE self, VALUE x) \
{ \ { \
set_##x(self, x); \ set_##x(self, x); \
return self; \ return self; \
@@ -161,7 +161,7 @@ set_float(contrast)
get_double_list(dither_##x) \ get_double_list(dither_##x) \
static VALUE set_dither_##x(VALUE self, VALUE x) \ static VALUE set_dither_##x(VALUE self, VALUE x) \
{ \ { \
if(caca_set_dither_##x(_SELF, StringValuePtr(x))<0) \
if(caca_set_dither_##x(_SELF, StringValuePtr(x))<0) \
{ \ { \
rb_raise(rb_eRuntimeError, strerror(errno)); \ rb_raise(rb_eRuntimeError, strerror(errno)); \
} \ } \


+ 2
- 2
ruby/caca-event.c 파일 보기

@@ -31,7 +31,7 @@ void Init_caca_event(VALUE mCaca)
rb_define_const(cEvent, "TYPE", INT2FIX(CACA_EVENT_ANY)); rb_define_const(cEvent, "TYPE", INT2FIX(CACA_EVENT_ANY));


cEventKey = rb_define_class_under(cEvent, "Key", cEvent); cEventKey = rb_define_class_under(cEvent, "Key", cEvent);
rb_define_const(cEventKey, "TYPE",
rb_define_const(cEventKey, "TYPE",
INT2FIX(CACA_EVENT_KEY_PRESS| INT2FIX(CACA_EVENT_KEY_PRESS|
CACA_EVENT_KEY_RELEASE)); CACA_EVENT_KEY_RELEASE));


@@ -42,7 +42,7 @@ void Init_caca_event(VALUE mCaca)
cEventKeyRelease = rb_define_class_under(cEventKey, "Release", cEventKey); cEventKeyRelease = rb_define_class_under(cEventKey, "Release", cEventKey);
rb_define_const(cEventKeyRelease, "TYPE", rb_define_const(cEventKeyRelease, "TYPE",
INT2FIX(CACA_EVENT_KEY_RELEASE)); INT2FIX(CACA_EVENT_KEY_RELEASE));
cEventMouse = rb_define_class_under(cEvent, "Mouse", cEvent); cEventMouse = rb_define_class_under(cEvent, "Mouse", cEvent);
rb_define_const(cEventMouse, "TYPE", rb_define_const(cEventMouse, "TYPE",
INT2FIX(CACA_EVENT_MOUSE_PRESS| INT2FIX(CACA_EVENT_MOUSE_PRESS|


+ 7
- 7
ruby/caca-font.c 파일 보기

@@ -24,7 +24,7 @@ void font_free(void *font)
static VALUE font_alloc(VALUE klass) static VALUE font_alloc(VALUE klass)
{ {
VALUE obj; VALUE obj;
obj = Data_Wrap_Struct(klass, 0, font_free, NULL);
obj = Data_Wrap_Struct(klass, 0, font_free, NULL);
return obj; return obj;
} }


@@ -45,10 +45,10 @@ static VALUE font_list(void)
{ {
VALUE ary; VALUE ary;
char const* const* list; char const* const* list;
list = caca_get_font_list(); list = caca_get_font_list();
ary = rb_ary_new();
ary = rb_ary_new();
while (*list != NULL) while (*list != NULL)
{ {
rb_ary_push(ary, rb_str_new2(*list)); rb_ary_push(ary, rb_str_new2(*list));
@@ -72,10 +72,10 @@ static VALUE get_font_blocks(VALUE self)
{ {
VALUE ary; VALUE ary;
uint32_t const *list; uint32_t const *list;
list = caca_get_font_blocks(_SELF); list = caca_get_font_blocks(_SELF);
ary = rb_ary_new();
ary = rb_ary_new();
while (*list != 0L) while (*list != 0L)
{ {
rb_ary_push(ary, ULONG2NUM(*list)); rb_ary_push(ary, ULONG2NUM(*list));


+ 15
- 15
src/aafire.c 파일 보기

@@ -1,6 +1,6 @@
/* /*
* cacafire fire demo for libcaca * cacafire fire demo for libcaca
* Copyright (c) 2003 Sam Hocevar <sam@zoy.org>
* Copyright (c) 2003 Sam Hocevar <sam@hocevar.net>
* 1998, 1999, 2001 Jan Hubicka <hubicka@freesoft.cz> * 1998, 1999, 2001 Jan Hubicka <hubicka@freesoft.cz>
* All Rights Reserved * All Rights Reserved
* *
@@ -136,7 +136,7 @@ initialize (void)
} }
#else #else
aa_setpalette (palette, i, pal[i * 3] * 4, aa_setpalette (palette, i, pal[i * 3] * 4,
pal[i * 3 + 1] * 4, pal[i * 3 + 2] * 4);
pal[i * 3 + 1] * 4, pal[i * 3 + 2] * 4);
#endif #endif


#ifdef LIBCACA #ifdef LIBCACA
@@ -171,12 +171,12 @@ gentable (void)
for (i = 0; i < MAXTABLE; i++) for (i = 0; i < MAXTABLE; i++)
{ {
if (i > minus) if (i > minus)
{
p2 = (i - minus) / 5;
table[i] = p2;
}
{
p2 = (i - minus) / 5;
table[i] = p2;
}
else else
table[i] = 0;
table[i] = 0;
} }
} }


@@ -191,12 +191,12 @@ firemain (void)
#endif #endif
i = 0; i = 0;
#define END (bitmap + XSIZ * YSIZ) #define END (bitmap + XSIZ * YSIZ)
for (p = (unsigned char*)bitmap;
(char*)p <= (( char *) (END));
for (p = (unsigned char*)bitmap;
(char*)p <= (( char *) (END));
p += 1) p += 1)
{ {
*p = table[(*(p + XSIZ - 1) + *(p + XSIZ + 1) + *(p + XSIZ)) + *p = table[(*(p + XSIZ - 1) + *(p + XSIZ + 1) + *(p + XSIZ)) +
(*(p + 2 * XSIZ - 1) + *(p + 2 * XSIZ + 1))];
(*(p + 2 * XSIZ - 1) + *(p + 2 * XSIZ + 1))];
} }
} }


@@ -228,9 +228,9 @@ drawfire (void)
last1 = rand () % min (i1, min (i2, height)); last1 = rand () % min (i1, min (i2, height));
i = rand () % 6; i = rand () % 6;
for (; p < (unsigned char *) bitmap + XSIZ * (YSIZ + 1) && i != 0; for (; p < (unsigned char *) bitmap + XSIZ * (YSIZ + 1) && i != 0;
p++, i--, i1 += 4, i2 -= 4)
*p = last1, last1 += rand () % 6 - 2, *(p + XSIZ) = last1, last1 +=
rand () % 6 - 2;
p++, i--, i1 += 4, i2 -= 4)
*p = last1, last1 += rand () % 6 - 2, *(p + XSIZ) = last1, last1 +=
rand () % 6 - 2;
*(p + 2 * XSIZ) = last1, last1 += rand () % 6 - 2; *(p + 2 * XSIZ) = last1, last1 += rand () % 6 - 2;
} }
i = 0; i = 0;
@@ -244,13 +244,13 @@ _paused:
caca_put_str(cv, caca_get_canvas_width(cv) - 30, caca_put_str(cv, caca_get_canvas_width(cv) - 30,
caca_get_canvas_height(cv) - 2, caca_get_canvas_height(cv) - 2,
" -=[ Powered by libcaca ]=- "); " -=[ Powered by libcaca ]=- ");
caca_refresh_display(dp); caca_refresh_display(dp);
/*XSIZ = caca_get_width() * 2; /*XSIZ = caca_get_width() * 2;
YSIZ = caca_get_height() * 2 - 4;*/ YSIZ = caca_get_height() * 2 - 4;*/
#else #else
aa_renderpalette (context, palette, params, 0, 0, aa_scrwidth (context), aa_renderpalette (context, palette, params, 0, 0, aa_scrwidth (context),
aa_scrheight (context));
aa_scrheight (context));
aa_flush (context); aa_flush (context);
#endif #endif
} }


+ 29
- 12
tests/bench.c 파일 보기

@@ -1,9 +1,24 @@
/*
* libcaca benchmark program
* Copyright (c) 2009 Pascal Terjan <pterjan@linuxfr.org>
* 2009 Sam Hocevar <sam@hocevar.net>
*
* This library is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

#include "config.h" #include "config.h"


#include <stdio.h> #include <stdio.h>


#include "caca.h" #include "caca.h"


#define BLIT_LOOPS 1000000
#define PUTCHAR_LOOPS 50000000

#define TIME(desc, code) \ #define TIME(desc, code) \
{ \ { \
caca_display_t *dummy = caca_create_display_with_driver(NULL, "null"); \ caca_display_t *dummy = caca_create_display_with_driver(NULL, "null"); \
@@ -22,10 +37,11 @@ static void blit(int mask, int clear)
cv = caca_create_canvas(40, 40); cv = caca_create_canvas(40, 40);
cv2 = caca_create_canvas(16, 16); cv2 = caca_create_canvas(16, 16);
caca_fill_box(cv2, 0, 0, 16, 16, 'x'); caca_fill_box(cv2, 0, 0, 16, 16, 'x');
for (i=0; i<1000000; i++) {
if(clear)
caca_clear_canvas(cv);
caca_blit(cv, 1, 1, cv2, mask?cv2:NULL);
for (i = 0; i < BLIT_LOOPS; i++)
{
if(clear)
caca_clear_canvas(cv);
caca_blit(cv, 1, 1, cv2, mask ? cv2 : NULL);
} }
caca_free_canvas(cv); caca_free_canvas(cv);
caca_free_canvas(cv2); caca_free_canvas(cv2);
@@ -36,20 +52,21 @@ static void putchars(void)
caca_canvas_t *cv; caca_canvas_t *cv;
int i; int i;
cv = caca_create_canvas(40, 40); cv = caca_create_canvas(40, 40);
for (i=0; i<50000000; i++) {
caca_put_char(cv, 1, 1, 'x');
caca_put_char(cv, 1, 1, 'o');
for (i = 0; i < PUTCHAR_LOOPS; i++)
{
caca_put_char(cv, 1, 1, 'x');
caca_put_char(cv, 1, 1, 'o');
} }
caca_free_canvas(cv); caca_free_canvas(cv);
} }


int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
TIME("blit no mask, no clear",blit(0, 0));
TIME("blit no mask, clear",blit(0, 1));
TIME("blit mask, no clear",blit(1, 0));
TIME("blit mask, clear",blit(1, 1));
TIME("putchars",putchars());
TIME("blit no mask, no clear", blit(0, 0));
TIME("blit no mask, clear", blit(0, 1));
TIME("blit mask, no clear", blit(1, 0));
TIME("blit mask, clear", blit(1, 1));
TIME("putchars", putchars());
return 0; return 0;
} }



불러오는 중...
취소
저장