pike.git / src / modules / Image / blit.c

version» Context lines:

pike.git/src/modules/Image/blit.c:1: - /* $Id: blit.c,v 1.39 2000/06/03 21:00:43 per Exp $ */ + /* $Id: blit.c,v 1.40 2000/06/03 22:48:01 per Exp $ */   #include "global.h"      /*   **! module Image   **! note - **! $Id: blit.c,v 1.39 2000/06/03 21:00:43 per Exp $ + **! $Id: blit.c,v 1.40 2000/06/03 22:48:01 per Exp $   **! class Image   */      #include <math.h>   #include <ctype.h>      #include "stralloc.h"   #include "global.h"   #include "pike_macros.h"   #include "object.h"
pike.git/src/modules/Image/blit.c:119:   }         /*** end internals ***/         void img_clear(rgb_group *dest,rgb_group rgb,INT32 size)   {    if(!size) return;    THREADS_ALLOW(); +  if( ( rgb.r == rgb.g && rgb.r == rgb.b ) ) +  MEMSET(dest, rgb.r, size*sizeof(rgb_group) );   #ifdef ASSEMBLY_OK -  if( size > 512 ) +  else if( size > 512 && (image_cpuid & IMAGE_MMX) )    { -  if( image_cpuid & IMAGE_MMX ) -  { -  if( ( rgb.r == rgb.g && rgb.g == rgb.b ) ) -  image_clear_buffer_mmx_x86asm_eq( dest, size/8, rgb.g ); -  else -  { -  /* clear a few bytes the slow way. */ -  /* 8 pixels */ +  int *q = (int *)dest; +  /* 8 pixels, 24 bytes */    dest[0] = rgb; dest[1] = rgb; dest[2] = rgb; dest[3] = rgb; -  dest[4] = rgb; dest[5] = rgb; dest[6] = rgb; dest[7] = rgb; -  /* clear the rest the fast way */ +  q[4] = q[0]; q[5] = q[1]; q[6] = q[2]; +  /* clear the rest the fast way.. */    image_clear_buffer_mmx_x86asm_from( dest, size/8 ); -  } +     dest += size; size = size%8; dest -= size;    while(size--) *(dest++) = rgb; -  return; +     } -  } +    #endif -  if(!rgb.r && !rgb.b && !rgb.g) -  MEMSET(dest, 0, size*sizeof(rgb_group)); -  else if((sizeof(rgb.r) == 1) && (rgb.r == rgb.b && rgb.b == rgb.g)) -  MEMSET(dest, rgb.r, size*sizeof(rgb_group)); +     else if(size)    { -  { +     int increment = 1;    rgb_group *from = dest;    *(dest++)=rgb;    size -= 1;    while (size>increment)    {    MEMCPY(dest,from,increment*sizeof(rgb_group));    size-=increment,dest+=increment;    if (increment<1024) increment *= 2;    }    if(size>0) MEMCPY(dest,from,size*sizeof(rgb_group));    } -  } +     THREADS_DISALLOW();   }      void img_box_nocheck(INT32 x1,INT32 y1,INT32 x2,INT32 y2)   {    INT32 x,mod;    rgb_group *foo,*end,rgb;    struct image *this;       this=THIS;