OSDN Git Service

[WIP][Agar] Build fit to CSP.
[csp-qt/common_source_project-fm7.git] / source / src / agar / common / scaler / sse2 / scaler_x125_sse2.c
1 /*
2  * Zoom x1.25x2 i.e. 800x480.
3  * (C) 2014 K.Ohta
4  * 
5  * History:
6  *  2013-04-02 Move from scaler_x2.c
7  */
8 #include <agar/core.h>
9 #include <agar/gui.h>
10 #include "simd_types.h"
11 #include "sdl_cpuid.h"
12 #include "cache_wrapper.h"
13
14 extern struct XM7_CPUID *pCpuID;
15 extern BOOL bFullScan;
16
17 extern void pVram2RGB_x125(Uint32 *src, Uint32 *dst, int x, int y, int yrep);
18
19 #if defined(__SSE2__)
20
21 static void Scaler_DrawLine(Uint32 *dst, Uint32 *src, int ww, int repeat, int pitch)
22 {
23    int xx;
24    int yy;
25    int yrep2;
26    int yrep3;
27    int blank;
28    Uint32 *b2p;
29    v4hi r1, r2;
30    v4hi *d0;
31    v4hi *b;
32    int pitch2;
33 #if AG_BIG_ENDIAN != 1
34    const Uint32 bb = 0xff000000;
35 #else
36    const Uint32 bb = 0x000000ff;
37 #endif
38      
39    if(repeat <= 0) return;
40    b = (v4hi *)src;
41    b2p = (Uint32 *)dst;
42    pitch2 = pitch / sizeof(Uint32);
43    if((bFullScan) || (repeat < 2)) {
44       for(xx = 0; xx < ww; xx += 8) {
45          b2p = (Uint32 *)dst;
46          r1 = *b++;
47          r2 = *b++;
48          // 76543210 -> 7654432100
49          for(yy = 0; yy < repeat; yy++) {
50                b2p[0] = b2p[1] = r1.i[0];
51                b2p[2] = r1.i[1];
52                b2p[3] = r1.i[2];
53                b2p[4] = r1.i[3];
54                b2p[5] = b2p[6] = r2.i[0];
55                b2p[7] = r2.i[1];
56                b2p[8] = r2.i[2];
57                b2p[9] = r2.i[3];
58                b2p = b2p + pitch2;
59          }
60          dst = dst + 10;
61 //       b += 2;
62       }
63    } else {
64       for(xx = 0; xx < ww; xx += 8) {
65          b2p = (Uint32 *)dst;
66          r1 = *b++;
67          r2 = *b++;
68          // 76543210 -> 776655444332211000
69          // 76543210 -> 7654432100
70          for(yy = 0; yy < repeat - 1; yy++) {
71                b2p[0] = b2p[1] = r1.i[0];
72                b2p[2] = r1.i[1];
73                b2p[3] = r1.i[2];
74                b2p[4] = r1.i[3];
75                b2p[5] = b2p[6] = r2.i[0];
76                b2p[7] = r2.i[1];
77                b2p[8] = r2.i[2];
78                b2p[9] = r2.i[3];
79                b2p = b2p + pitch2;
80          }
81          b2p[0] = b2p[1] = b2p[2] = b2p[3] =
82          b2p[4] = b2p[5] = b2p[6] = b2p[7] =
83          b2p[8] = b2p[9] =
84            bb;
85          dst = dst + 10;
86 //       b += 2;
87       }
88    }
89    
90 }
91
92
93
94 void pVram2RGB_x125_Line_SSE2(Uint32 *src, Uint8 *dst, int xbegin, int xend, int y, int yrep)
95 {
96    register v4hi *b;
97    AG_Surface *Surface = GetDrawSurface();
98    Uint32 *d1;
99    Uint32 *d2;
100    Uint32 *p;
101    int w;
102    int h;
103    int yy;
104    int xx;
105    int hh;
106    int ww;
107    int i;
108    int x = xbegin;
109    int yrep2;
110    unsigned  pitch;
111    Uint32 black;
112    if(Surface == NULL) return;
113    w = Surface->w;
114    h = Surface->h;
115
116
117    ww = xend - xbegin;
118 //   if(ww > (w / 2)) ww = w / 2;
119    ww = (ww / 8) * 8;
120    if(ww <= 0) return;
121
122
123 #if AG_BIG_ENDIAN != 1
124    black = 0xff000000;
125 #else
126    black = 0x000000ff;
127 #endif
128 //   yrep = yrep * 16.0f;
129
130    yrep2 = yrep;
131
132    d1 = (Uint32 *)((Uint8 *)dst + ((x * 10) / 8) * Surface->format->BytesPerPixel);
133    d2 = &src[x + y * 640];
134    Scaler_DrawLine(d1, (Uint32 *)d2, ww, yrep2, Surface->pitch);
135 //   AG_SurfaceUnlock(Surface);
136    return;
137 }
138
139
140 #else 
141
142 void pVram2RGB_x125_Line_SSE2(Uint32 *src, int xbegin,  int xend, int y, int yrep)
143 {
144    pVram2RGB_x125_Line(src, dst, x, y, yrep);
145 }
146
147 #endif // __SSE2__