Browse Source

Fix an alignment issue in caca_get_canvas_chars() and caca_get_canvas_attrs().

Fixes #41.
tags/v0.99.beta17
Sam Hocevar sam 15 years ago
parent
commit
231c33acce
9 changed files with 28 additions and 34 deletions
  1. +2
    -2
      caca/caca.h
  2. +10
    -10
      caca/canvas.c
  3. +3
    -3
      caca/driver/conio.c
  4. +3
    -3
      caca/driver/gl.c
  5. +2
    -4
      caca/driver/ncurses.c
  6. +2
    -4
      caca/driver/slang.c
  7. +2
    -4
      caca/driver/vga.c
  8. +2
    -2
      caca/driver/win32.c
  9. +2
    -2
      caca/driver/x11.c

+ 2
- 2
caca/caca.h View File

@@ -218,8 +218,8 @@ __extern int caca_unmanage_canvas(caca_canvas_t *, int (*)(void *), void *);
__extern int caca_set_canvas_size(caca_canvas_t *, int, int); __extern int caca_set_canvas_size(caca_canvas_t *, int, int);
__extern int caca_get_canvas_width(caca_canvas_t const *); __extern int caca_get_canvas_width(caca_canvas_t const *);
__extern int caca_get_canvas_height(caca_canvas_t const *); __extern int caca_get_canvas_height(caca_canvas_t const *);
__extern uint8_t const * caca_get_canvas_chars(caca_canvas_t const *);
__extern uint8_t const * caca_get_canvas_attrs(caca_canvas_t const *);
__extern uint32_t const * caca_get_canvas_chars(caca_canvas_t const *);
__extern uint32_t const * caca_get_canvas_attrs(caca_canvas_t const *);
__extern int caca_free_canvas(caca_canvas_t *); __extern int caca_free_canvas(caca_canvas_t *);
__extern int caca_rand(int, int); __extern int caca_rand(int, int);
__extern char const * caca_get_version(void); __extern char const * caca_get_version(void);


+ 10
- 10
caca/canvas.c View File

@@ -263,17 +263,17 @@ int caca_get_canvas_height(caca_canvas_t const *cv)
* consist in native endian 32-bit Unicode values as returned by * consist in native endian 32-bit Unicode values as returned by
* caca_get_char(). * caca_get_char().
* *
* This function is only useful for display drivers such as the \e libcaca
* library.
* This function is probably only useful for \e libcaca 's internal display
* drivers.
* *
* This function never fails. * This function never fails.
* *
* \param cv A libcaca canvas. * \param cv A libcaca canvas.
* \return The canvas character array. * \return The canvas character array.
*/ */
uint8_t const * caca_get_canvas_chars(caca_canvas_t const *cv)
uint32_t const * caca_get_canvas_chars(caca_canvas_t const *cv)
{ {
return (uint8_t const *)cv->chars;
return (uint32_t const *)cv->chars;
} }


/** \brief Get the canvas attribute array. /** \brief Get the canvas attribute array.
@@ -282,17 +282,17 @@ uint8_t const * caca_get_canvas_chars(caca_canvas_t const *cv)
* consist in native endian 32-bit attribute values as returned by * consist in native endian 32-bit attribute values as returned by
* caca_get_attr(). * caca_get_attr().
* *
* This function is only useful for display drivers such as the \e libcaca
* library.
* This function is probably only useful for \e libcaca 's internal display
* drivers.
* *
* This function never fails. * This function never fails.
* *
* \param cv A libcaca canvas. * \param cv A libcaca canvas.
* \return The canvas attribute array. * \return The canvas attribute array.
*/ */
uint8_t const * caca_get_canvas_attrs(caca_canvas_t const *cv)
uint32_t const * caca_get_canvas_attrs(caca_canvas_t const *cv)
{ {
return (uint8_t const *)cv->attrs;
return (uint32_t const *)cv->attrs;
} }


/** \brief Free a \e libcaca canvas. /** \brief Free a \e libcaca canvas.
@@ -539,9 +539,9 @@ int cucul_get_canvas_width(cucul_canvas_t const *)
CACA_ALIAS(caca_get_canvas_width); CACA_ALIAS(caca_get_canvas_width);
int cucul_get_canvas_height(cucul_canvas_t const *) int cucul_get_canvas_height(cucul_canvas_t const *)
CACA_ALIAS(caca_get_canvas_height); CACA_ALIAS(caca_get_canvas_height);
uint8_t const * cucul_get_canvas_chars(cucul_canvas_t const *)
uint32_t const * cucul_get_canvas_chars(cucul_canvas_t const *)
CACA_ALIAS(caca_get_canvas_chars); CACA_ALIAS(caca_get_canvas_chars);
uint8_t const * cucul_get_canvas_attrs(cucul_canvas_t const *)
uint32_t const * cucul_get_canvas_attrs(cucul_canvas_t const *)
CACA_ALIAS(caca_get_canvas_attrs); CACA_ALIAS(caca_get_canvas_attrs);
int cucul_free_canvas(cucul_canvas_t *) CACA_ALIAS(caca_free_canvas); int cucul_free_canvas(cucul_canvas_t *) CACA_ALIAS(caca_free_canvas);
int cucul_rand(int, int) CACA_ALIAS(caca_rand); int cucul_rand(int, int) CACA_ALIAS(caca_rand);


+ 3
- 3
caca/driver/conio.c View File

@@ -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-2009 Sam Hocevar <sam@hocevar.net>
* All Rights Reserved * All Rights Reserved
* *
* $Id$ * $Id$
@@ -98,8 +98,8 @@ static int conio_get_display_height(caca_display_t const *dp)
static void conio_display(caca_display_t *dp) static void conio_display(caca_display_t *dp)
{ {
char *screen = dp->drv.p->screen; char *screen = dp->drv.p->screen;
uint32_t const *chars = (uint32_t const *)caca_get_canvas_chars(dp->cv);
uint32_t const *attrs = (uint32_t const *)caca_get_canvas_attrs(dp->cv);
uint32_t const *chars = caca_get_canvas_chars(dp->cv);
uint32_t const *attrs = caca_get_canvas_attrs(dp->cv);
int width = caca_get_canvas_width(dp->cv); int width = caca_get_canvas_width(dp->cv);
int height = caca_get_canvas_height(dp->cv); int height = caca_get_canvas_height(dp->cv);
int n; int n;


+ 3
- 3
caca/driver/gl.c View File

@@ -1,6 +1,6 @@
/* /*
* libcaca Colour ASCII-Art library * libcaca Colour ASCII-Art library
* Copyright (c) 2002-2006 Sam Hocevar <sam@hocevar.net>
* Copyright (c) 2002-2009 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
@@ -216,8 +216,8 @@ static int gl_get_display_height(caca_display_t const *dp)


static void gl_display(caca_display_t *dp) static void gl_display(caca_display_t *dp)
{ {
uint32_t const *cvchars = (uint32_t const *)caca_get_canvas_chars(dp->cv);
uint32_t const *cvattrs = (uint32_t const *)caca_get_canvas_attrs(dp->cv);
uint32_t const *cvchars = caca_get_canvas_chars(dp->cv);
uint32_t const *cvattrs = caca_get_canvas_attrs(dp->cv);
int width = caca_get_canvas_width(dp->cv); int width = caca_get_canvas_width(dp->cv);
int x, y, line; int x, y, line;




+ 2
- 4
caca/driver/ncurses.c View File

@@ -355,10 +355,8 @@ static void ncurses_display(caca_display_t *dp)


caca_get_dirty_rect(dp->cv, i, &dx, &dy, &dw, &dh); caca_get_dirty_rect(dp->cv, i, &dx, &dy, &dw, &dh);


cvchars = (uint32_t const *)caca_get_canvas_chars(dp->cv)
+ dx + dy * dp->cv->width;
cvattrs = (uint32_t const *)caca_get_canvas_attrs(dp->cv)
+ dx + dy * dp->cv->width;
cvchars = caca_get_canvas_chars(dp->cv) + dx + dy * dp->cv->width;
cvattrs = caca_get_canvas_attrs(dp->cv) + dx + dy * dp->cv->width;


for(y = dy; y < dy + dh; y++) for(y = dy; y < dy + dh; y++)
{ {


+ 2
- 4
caca/driver/slang.c View File

@@ -244,10 +244,8 @@ static void slang_display(caca_display_t *dp)


caca_get_dirty_rect(dp->cv, i, &dx, &dy, &dw, &dh); caca_get_dirty_rect(dp->cv, i, &dx, &dy, &dw, &dh);


cvchars = (uint32_t const *)caca_get_canvas_chars(dp->cv)
+ dx + dy * dp->cv->width;
cvattrs = (uint32_t const *)caca_get_canvas_attrs(dp->cv)
+ dx + dy * dp->cv->width;
cvchars = caca_get_canvas_chars(dp->cv) + dx + dy * dp->cv->width;
cvattrs = caca_get_canvas_attrs(dp->cv) + dx + dy * dp->cv->width;


for(y = dy; y < dy + dh; y++) for(y = dy; y < dy + dh; y++)
{ {


+ 2
- 4
caca/driver/vga.c View File

@@ -124,10 +124,8 @@ static void vga_display(caca_display_t *dp)


caca_get_dirty_rect(dp->cv, i, &dx, &dy, &dw, &dh); caca_get_dirty_rect(dp->cv, i, &dx, &dy, &dw, &dh);


cvchars = (uint32_t const *)caca_get_canvas_chars(dp->cv)
+ dx + dy * dp->cv->width;
cvattrs = (uint32_t const *)caca_get_canvas_attrs(dp->cv)
+ dx + dy * dp->cv->width;
cvchars = caca_get_canvas_chars(dp->cv) + dx + dy * dp->cv->width;
cvattrs = caca_get_canvas_attrs(dp->cv) + dx + dy * dp->cv->width;


screen += dy * dp->cv->width + dx; screen += dy * dp->cv->width + dx;




+ 2
- 2
caca/driver/win32.c View File

@@ -195,8 +195,8 @@ static void win32_display(caca_display_t *dp)
COORD size, pos; COORD size, pos;
SMALL_RECT rect; SMALL_RECT rect;
CHAR_INFO *buffer = dp->drv.p->buffer; CHAR_INFO *buffer = dp->drv.p->buffer;
uint32_t const *cvchars = (uint32_t const *)caca_get_canvas_chars(dp->cv);
uint32_t const *cvattrs = (uint32_t const *)caca_get_canvas_attrs(dp->cv);
uint32_t const *cvchars = caca_get_canvas_chars(dp->cv);
uint32_t const *cvattrs = caca_get_canvas_attrs(dp->cv);
int width = caca_get_canvas_width(dp->cv); int width = caca_get_canvas_width(dp->cv);
int height = caca_get_canvas_height(dp->cv); int height = caca_get_canvas_height(dp->cv);
int n; int n;


+ 2
- 2
caca/driver/x11.c View File

@@ -393,8 +393,8 @@ static int x11_get_display_height(caca_display_t const *dp)


static void x11_display(caca_display_t *dp) static void x11_display(caca_display_t *dp)
{ {
uint32_t const *cvchars = (uint32_t const *)caca_get_canvas_chars(dp->cv);
uint32_t const *cvattrs = (uint32_t const *)caca_get_canvas_attrs(dp->cv);
uint32_t const *cvchars = caca_get_canvas_chars(dp->cv);
uint32_t const *cvattrs = caca_get_canvas_attrs(dp->cv);
int width = caca_get_canvas_width(dp->cv); int width = caca_get_canvas_width(dp->cv);
int height = caca_get_canvas_height(dp->cv); int height = caca_get_canvas_height(dp->cv);
int x, y, i, len; int x, y, i, len;


Loading…
Cancel
Save