FreeBASIC  0.91.0
gfx_put_or.c
Go to the documentation of this file.
1 /* OR drawing method for PUT statement */
2 
3 #include "fb_gfx.h"
4 
5 
6 #ifdef HOST_X86
7 
8 #include "x86/fb_gfx_mmx.h"
9 
10 extern void fb_hPutOrMMX(unsigned char *src, unsigned char *dest, int w, int h, int src_pitch, int dest_pitch, int alpha, BLENDER *blender, void *param);
11 
12 #endif
13 
14 
15 /*:::::*/
16 void fb_hPutOrC(unsigned char *src, unsigned char *dest, int w, int h, int src_pitch, int dest_pitch, int alpha, BLENDER *blender, void *param)
17 {
18  int x;
20 
21  w <<= (context->target_bpp >> 1);
22  src_pitch -= w;
23  dest_pitch -= w;
24  for (; h; h--) {
25  if (w & 1)
26  *dest++ |= *src++;
27  if (w & 2) {
28  *(unsigned short *)dest |= *(unsigned short *)src;
29  dest += 2;
30  src += 2;
31  }
32  for (x = w >> 2; x; x--) {
33  *(unsigned int *)dest |= *(unsigned int *)src;
34  dest += 4;
35  src += 4;
36  }
37  src += src_pitch;
38  dest += dest_pitch;
39  }
40 }
41 
42 
43 /*:::::*/
44 void fb_hPutOr(unsigned char *src, unsigned char *dest, int w, int h, int src_pitch, int dest_pitch, int alpha, BLENDER *blender, void *param)
45 {
46  static PUTTER *all_putters[] = {
48 #ifdef HOST_X86
49  fb_hPutOrMMX, fb_hPutOrMMX, NULL, fb_hPutOrMMX,
50 #endif
51  };
52  PUTTER *putter;
54 
55  if (!context->putter[PUT_MODE_OR]) {
56 #ifdef HOST_X86
57  if (__fb_gfx->flags & HAS_MMX)
58  context->putter[PUT_MODE_OR] = &all_putters[4];
59  else
60 #endif
61  context->putter[PUT_MODE_OR] = &all_putters[0];
62  }
63  putter = context->putter[PUT_MODE_OR][context->target_bpp - 1];
64 
65  putter(src, dest, w, h, src_pitch, dest_pitch, alpha, blender, param);
66 }