bitblt.c

changeset 48
3d0be1c1c1b2
parent 47
bfc6aaa089b0
child 53
bb180150e603
     1.1 diff -r bfc6aaa089b0 -r 3d0be1c1c1b2 bitblt.c
     1.2 --- a/bitblt.c	Mon Aug 26 05:43:49 2002 +0000
     1.3 +++ b/bitblt.c	Mon Aug 26 06:03:55 2002 +0000
     1.4 @@ -1,16 +1,17 @@
     1.5 +#include <stdbool.h>
     1.6 +#include <stdint.h>
     1.7  #include <assert.h>
     1.8  #include <stdio.h>
     1.9  #include <stdlib.h>
    1.10  #include <string.h>
    1.11  
    1.12 -#include "type.h"
    1.13  #include "bitblt.h"
    1.14  
    1.15  
    1.16  #define DIV_ROUND_UP(count,pow2) (((count) - 1) / (pow2) + 1)
    1.17  
    1.18  
    1.19 -static const u8 bit_reverse_byte [0x100] =
    1.20 +static const uint8_t bit_reverse_byte [0x100] =
    1.21  {
    1.22    0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
    1.23    0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
    1.24 @@ -47,7 +48,7 @@
    1.25  };
    1.26  
    1.27  
    1.28 -void reverse_bits (u8 *p, int byte_count)
    1.29 +void reverse_bits (uint8_t *p, int byte_count)
    1.30  {
    1.31    while (byte_count--)
    1.32      {
    1.33 @@ -69,7 +70,7 @@
    1.34  static word_type *temp_buffer;
    1.35  static word_type temp_buffer_size;
    1.36  
    1.37 -static void realloc_temp_buffer (u32 size)
    1.38 +static void realloc_temp_buffer (uint32_t size)
    1.39  {
    1.40    if (size <= temp_buffer_size)
    1.41      return;
    1.42 @@ -121,8 +122,8 @@
    1.43  Bitmap *create_bitmap (Rect *rect)
    1.44  {
    1.45    Bitmap *bitmap;
    1.46 -  u32 width = rect_width (rect);
    1.47 -  u32 height = rect_height (rect);
    1.48 +  uint32_t width = rect_width (rect);
    1.49 +  uint32_t height = rect_height (rect);
    1.50  
    1.51    if ((width <= 0) || (height <= 0))
    1.52      return (NULL);
    1.53 @@ -147,7 +148,7 @@
    1.54    free (bitmap);
    1.55  }
    1.56  
    1.57 -boolean get_pixel (Bitmap *bitmap, Point coord)
    1.58 +bool get_pixel (Bitmap *bitmap, Point coord)
    1.59  {
    1.60    word_type *p;
    1.61    int w,b;
    1.62 @@ -165,7 +166,7 @@
    1.63    return (((*p) & pixel_mask (b)) != 0);
    1.64  }
    1.65  
    1.66 -void set_pixel (Bitmap *bitmap, Point coord, boolean value)
    1.67 +void set_pixel (Bitmap *bitmap, Point coord, bool value)
    1.68  {
    1.69    word_type *p;
    1.70    int w,b;
    1.71 @@ -189,7 +190,7 @@
    1.72  
    1.73  /* modifies rect1 to be the intersection of rect1 and rect2;
    1.74     returns true if intersection is non-null */
    1.75 -static boolean clip_rect (Rect *rect1, Rect *rect2)
    1.76 +static bool clip_rect (Rect *rect1, Rect *rect2)
    1.77  {
    1.78    if (rect1->min.y > rect2->max.y)
    1.79      goto empty;
    1.80 @@ -223,12 +224,12 @@
    1.81  static void blt_background (Bitmap *dest_bitmap,
    1.82  			    Rect dest_rect)
    1.83  {
    1.84 -  u32 y;
    1.85 +  uint32_t y;
    1.86    word_type *rp;
    1.87 -  u32 left_bit, left_word;
    1.88 -  u32 right_bit, right_word;
    1.89 +  uint32_t left_bit, left_word;
    1.90 +  uint32_t right_bit, right_word;
    1.91    word_type left_mask, right_mask;
    1.92 -  s32 word_count;
    1.93 +  int32_t word_count;
    1.94  
    1.95    /* This function requires a non-null dest rect */
    1.96    assert (dest_rect.min.x < dest_rect.max.x);
    1.97 @@ -289,7 +290,7 @@
    1.98        /* use Duff's Device for the full words */
    1.99        if (word_count)
   1.100  	{
   1.101 -	  s32 i = word_count;
   1.102 +	  int32_t i = word_count;
   1.103  	  switch (i % 8)
   1.104  	    {
   1.105  	      while (i > 0)
   1.106 @@ -323,7 +324,7 @@
   1.107  		 Bitmap *dest_bitmap,
   1.108  		 Rect *dest_rect)
   1.109  {
   1.110 -  s32 y;
   1.111 +  int32_t y;
   1.112    word_type *rp;
   1.113  
   1.114    /* This function requires a non-null src rect */
   1.115 @@ -402,18 +403,18 @@
   1.116  {
   1.117    Rect sr, dr;     /* src and dest rects, clipped to visible portion of
   1.118  		      dest rect */
   1.119 -  u32 drw, drh;    /* dest rect width, height - gets adjusted */
   1.120 +  uint32_t drw, drh;    /* dest rect width, height - gets adjusted */
   1.121    Point src_point, dest_point;
   1.122  
   1.123    /* dest coordinates: */
   1.124 -  u32 x0, x1, x2, x3;
   1.125 -  u32 y0, y1, y2, y3;
   1.126 +  uint32_t x0, x1, x2, x3;
   1.127 +  uint32_t y0, y1, y2, y3;
   1.128  
   1.129    {
   1.130      sr = * src_rect;
   1.131  
   1.132 -    u32 srw = rect_width (& sr);
   1.133 -    u32 srh = rect_height (& sr);
   1.134 +    uint32_t srw = rect_width (& sr);
   1.135 +    uint32_t srh = rect_height (& sr);
   1.136  
   1.137      if ((srw < 0) || (srh < 0))
   1.138        goto done;  /* the source rect is empty! */
   1.139 @@ -595,7 +596,7 @@
   1.140  	       src_point.x < src_rect->max.x;
   1.141  	       src_point.x++)
   1.142  	    {
   1.143 -	      boolean a;
   1.144 +	      bool a;
   1.145  
   1.146  	      dest_point.x = dest_min->x + src_point.x - src_rect->min.x;
   1.147  
   1.148 @@ -616,7 +617,7 @@
   1.149  	       src_point.x < src_rect->max.x;
   1.150  	       src_point.x++)
   1.151  	    {
   1.152 -	      boolean a, b, c;
   1.153 +	      bool a, b, c;
   1.154  
   1.155  	      dest_point.x = dest_min->x + src_point.x - src_rect->min.x;
   1.156  
   1.157 @@ -639,7 +640,7 @@
   1.158    word_type *rp;  /* row pointer */
   1.159    word_type *p1;  /* work src ptr */
   1.160    word_type *p2;  /* work dest ptr */
   1.161 -  s32 y;
   1.162 +  int32_t y;
   1.163    int shift1, shift2;
   1.164  
   1.165    realloc_temp_buffer ((src->row_words + 1) * sizeof (word_type));
   1.166 @@ -713,7 +714,7 @@
   1.167  /* "in-place" transformations - will allocate new memory and free old */
   1.168  void transpose (Bitmap *src)
   1.169  {
   1.170 -  u32 new_row_words = DIV_ROUND_UP (rect_height (& src->rect), 32);
   1.171 +  uint32_t new_row_words = DIV_ROUND_UP (rect_height (& src->rect), 32);
   1.172    word_type *new_bits;
   1.173  
   1.174    new_bits = calloc (1, new_row_words * rect_width (& src->rect) * sizeof (word_type));