FreeBASIC  0.91.0
gfx_put_trans.c
Go to the documentation of this file.
1 /* TRANS 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_hPutTrans1MMX(unsigned char *src, unsigned char *dest, int w, int h, int src_pitch, int dest_pitch, int alpha, BLENDER *blender, void *param);
11 extern void fb_hPutTrans2MMX(unsigned char *src, unsigned char *dest, int w, int h, int src_pitch, int dest_pitch, int alpha, BLENDER *blender, void *param);
12 extern void fb_hPutTrans4MMX(unsigned char *src, unsigned char *dest, int w, int h, int src_pitch, int dest_pitch, int alpha, BLENDER *blender, void *param);
13 
14 #endif
15 
16 
17 /*:::::*/
18 void fb_hPutTrans1C(unsigned char *src, unsigned char *dest, int w, int h, int src_pitch, int dest_pitch, int alpha, BLENDER *blender, void *param)
19 {
20  unsigned char *s = (unsigned char *)src;
21  unsigned char *d;
22  int x;
23 
24  src_pitch -= w;
25  for (; h; h--) {
26  d = (unsigned char *)dest;
27  for (x = w; x; x--) {
28  if (*s)
29  *d = (unsigned int)*s;
30  s++;
31  d++;
32  }
33  s += src_pitch;
34  dest += dest_pitch;
35  }
36 }
37 
38 
39 /*:::::*/
40 static void fb_hPutTrans2C(unsigned char *src, unsigned char *dest, int w, int h, int src_pitch, int dest_pitch, int alpha, BLENDER *blender, void *param)
41 {
42  unsigned short *s = (unsigned short *)src;
43  unsigned short *d;
44  int x;
45 
46  src_pitch = (src_pitch >> 1) - w;
47  for (; h; h--) {
48  d = (unsigned short *)dest;
49  for (x = w; x; x--) {
50  if (*s != MASK_COLOR_16)
51  *d = (unsigned short)*s;
52  s++;
53  d++;
54  }
55  s += src_pitch;
56  dest += dest_pitch;
57  }
58 }
59 
60 
61 /*:::::*/
62 static void fb_hPutTrans4C(unsigned char *src, unsigned char *dest, int w, int h, int src_pitch, int dest_pitch, int alpha, BLENDER *blender, void *param)
63 {
64  unsigned int *s = (unsigned int *)src;
65  unsigned int *d, c;
66  int x;
67 
68  src_pitch = (src_pitch >> 2) - w;
69  for (; h; h--) {
70  d = (unsigned int *)dest;
71  for (x = w; x; x--) {
72  c = *s & 0x00FFFFFF;
73  if (c != MASK_COLOR_32)
74  *d = c;
75  s++;
76  d++;
77  }
78  s += src_pitch;
79  dest += dest_pitch;
80  }
81 }
82 
83 
84 /*:::::*/
85 void fb_hPutTrans(unsigned char *src, unsigned char *dest, int w, int h, int src_pitch, int dest_pitch, int alpha, BLENDER *blender, void *param)
86 {
87  static PUTTER *all_putters[] = {
89 #ifdef HOST_X86
90  fb_hPutTrans1MMX, fb_hPutTrans2MMX, NULL, fb_hPutTrans4MMX,
91 #endif
92  };
93  PUTTER *putter;
95 
96  if (!context->putter[PUT_MODE_TRANS]) {
97 #ifdef HOST_X86
98  if (__fb_gfx->flags & HAS_MMX)
99  context->putter[PUT_MODE_TRANS] = &all_putters[4];
100  else
101 #endif
102  context->putter[PUT_MODE_TRANS] = &all_putters[0];
103  }
104  putter = context->putter[PUT_MODE_TRANS][context->target_bpp - 1];
105 
106  putter(src, dest, w, h, src_pitch, dest_pitch, alpha, blender, param);
107 }