bitblt.c

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