annotate window/render.cc @ 50:35ce1a30f3f9

* Added va_end where there is a va_start * Used NULL instead of 0 (so it works on 64b)
author thib
date Fri, 17 Apr 2009 18:38:06 +0000
parents 223b71206888
children 15a18fbe6f21
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 /*
223b71206888 Initial import
thib
parents:
diff changeset
2 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno
223b71206888 Initial import
thib
parents:
diff changeset
3 * All rights reserved.
223b71206888 Initial import
thib
parents:
diff changeset
4 *
223b71206888 Initial import
thib
parents:
diff changeset
5 * Redistribution and use in source and binary forms, with or without
223b71206888 Initial import
thib
parents:
diff changeset
6 * modification, are permitted provided that the following conditions
223b71206888 Initial import
thib
parents:
diff changeset
7 * are met:
223b71206888 Initial import
thib
parents:
diff changeset
8 * 1. Redistributions of source code must retain the above copyright
223b71206888 Initial import
thib
parents:
diff changeset
9 * notice, this list of conditions and the following disclaimer.
223b71206888 Initial import
thib
parents:
diff changeset
10 * 2. Redistributions in binary form must reproduce the above copyright
223b71206888 Initial import
thib
parents:
diff changeset
11 * notice, this list of conditions and the following disclaimer in the
223b71206888 Initial import
thib
parents:
diff changeset
12 * documentation and/or other materials provided with the distribution.
223b71206888 Initial import
thib
parents:
diff changeset
13 * 3. The name of the author may not be used to endorse or promote products
223b71206888 Initial import
thib
parents:
diff changeset
14 * derived from this software without specific prior written permission.
223b71206888 Initial import
thib
parents:
diff changeset
15 *
223b71206888 Initial import
thib
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
223b71206888 Initial import
thib
parents:
diff changeset
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
223b71206888 Initial import
thib
parents:
diff changeset
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
223b71206888 Initial import
thib
parents:
diff changeset
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
223b71206888 Initial import
thib
parents:
diff changeset
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
223b71206888 Initial import
thib
parents:
diff changeset
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
223b71206888 Initial import
thib
parents:
diff changeset
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
223b71206888 Initial import
thib
parents:
diff changeset
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
223b71206888 Initial import
thib
parents:
diff changeset
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
223b71206888 Initial import
thib
parents:
diff changeset
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
223b71206888 Initial import
thib
parents:
diff changeset
26 */
223b71206888 Initial import
thib
parents:
diff changeset
27
223b71206888 Initial import
thib
parents:
diff changeset
28 #include"font/font.h"
223b71206888 Initial import
thib
parents:
diff changeset
29 #include"font/text.h"
223b71206888 Initial import
thib
parents:
diff changeset
30 #include"rect.h"
223b71206888 Initial import
thib
parents:
diff changeset
31 #include"SDL.h"
223b71206888 Initial import
thib
parents:
diff changeset
32 #include"surface.h"
223b71206888 Initial import
thib
parents:
diff changeset
33 #include<stdio.h>
223b71206888 Initial import
thib
parents:
diff changeset
34
223b71206888 Initial import
thib
parents:
diff changeset
35 Rect DSurfaceRenderText(TextGlyphStream::iterator start, TextGlyphStream::iterator end, const Rect& srcrect,
223b71206888 Initial import
thib
parents:
diff changeset
36 Surface* dst, const Rect& dstrect); // 文字描画
223b71206888 Initial import
thib
parents:
diff changeset
37 void DSurfaceFill(Surface* src, const Rect& rect, int r, int g, int b, int a); // クリア
223b71206888 Initial import
thib
parents:
diff changeset
38 void DSurfaceFillA(Surface* src, const Rect& rect, int r, int g, int b, int a); // テキストウィンドウ背景の設定
223b71206888 Initial import
thib
parents:
diff changeset
39 void DSurfaceMove(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect); // コピー
223b71206888 Initial import
thib
parents:
diff changeset
40 void DSurfaceBlitAlpha(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, const unsigned char* alpha, const Rect& alpharect);
223b71206888 Initial import
thib
parents:
diff changeset
41 void DSurfaceBlitSaturate(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect, unsigned char alpha);
223b71206888 Initial import
thib
parents:
diff changeset
42 void DSurfaceBlitMultiply(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o);
223b71206888 Initial import
thib
parents:
diff changeset
43
223b71206888 Initial import
thib
parents:
diff changeset
44 #ifndef ALPHA_MAX
223b71206888 Initial import
thib
parents:
diff changeset
45 #define ALPHA_MAX 255
223b71206888 Initial import
thib
parents:
diff changeset
46 #endif
223b71206888 Initial import
thib
parents:
diff changeset
47
223b71206888 Initial import
thib
parents:
diff changeset
48 Rect::Rect(const TextGlyph& letter) {
223b71206888 Initial import
thib
parents:
diff changeset
49 lx = letter.x + letter.glyph->bitmap_left;
223b71206888 Initial import
thib
parents:
diff changeset
50 rx = lx + letter.glyph->bitmap.width;
223b71206888 Initial import
thib
parents:
diff changeset
51
223b71206888 Initial import
thib
parents:
diff changeset
52 ty = letter.y - letter.glyph->bitmap_top;
223b71206888 Initial import
thib
parents:
diff changeset
53 by = ty + letter.glyph->bitmap.rows;
223b71206888 Initial import
thib
parents:
diff changeset
54 }
223b71206888 Initial import
thib
parents:
diff changeset
55
223b71206888 Initial import
thib
parents:
diff changeset
56 Rect::Rect(const class Surface& so) {
223b71206888 Initial import
thib
parents:
diff changeset
57 SDL_Surface* s = (SDL_Surface*)(&so);
223b71206888 Initial import
thib
parents:
diff changeset
58 lx = 0; ty = 0;
223b71206888 Initial import
thib
parents:
diff changeset
59 rx = s->w; by = s->h;
223b71206888 Initial import
thib
parents:
diff changeset
60 }
223b71206888 Initial import
thib
parents:
diff changeset
61 inline Rect _Rect(const SDL_Rect& r) {
223b71206888 Initial import
thib
parents:
diff changeset
62 return Rect(r.x, r.y, r.x+r.w, r.y+r.h);
223b71206888 Initial import
thib
parents:
diff changeset
63 };
223b71206888 Initial import
thib
parents:
diff changeset
64 inline SDL_Rect SDLed(const Rect& rect) {
223b71206888 Initial import
thib
parents:
diff changeset
65 SDL_Rect r;
223b71206888 Initial import
thib
parents:
diff changeset
66 r.x = rect.lx;
223b71206888 Initial import
thib
parents:
diff changeset
67 r.y = rect.ty;
223b71206888 Initial import
thib
parents:
diff changeset
68 r.w = rect.rx-rect.lx;
223b71206888 Initial import
thib
parents:
diff changeset
69 r.h = rect.by-rect.ty;
223b71206888 Initial import
thib
parents:
diff changeset
70 return r;
223b71206888 Initial import
thib
parents:
diff changeset
71 }
223b71206888 Initial import
thib
parents:
diff changeset
72
223b71206888 Initial import
thib
parents:
diff changeset
73 Rect DSurfaceRenderText(TextGlyphStream::iterator start, TextGlyphStream::iterator end, const Rect& srcrect,
223b71206888 Initial import
thib
parents:
diff changeset
74 Surface* dst_o, const Rect& dstrect) {
223b71206888 Initial import
thib
parents:
diff changeset
75
223b71206888 Initial import
thib
parents:
diff changeset
76 SDL_Surface* dst = (SDL_Surface*)dst_o;
223b71206888 Initial import
thib
parents:
diff changeset
77 Rect confine_to(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
78 Rect dst_clip(_Rect(dst->clip_rect));
223b71206888 Initial import
thib
parents:
diff changeset
79 Rect drawn_rect(0,0,0,0);
223b71206888 Initial import
thib
parents:
diff changeset
80
223b71206888 Initial import
thib
parents:
diff changeset
81 int dif_x = dstrect.lx - srcrect.lx;
223b71206888 Initial import
thib
parents:
diff changeset
82 int dif_y = dstrect.ty - srcrect.ty;
223b71206888 Initial import
thib
parents:
diff changeset
83
223b71206888 Initial import
thib
parents:
diff changeset
84 dst_clip.rmove(-dif_x, -dif_y);
223b71206888 Initial import
thib
parents:
diff changeset
85 confine_to.intersect(dst_clip);
223b71206888 Initial import
thib
parents:
diff changeset
86
223b71206888 Initial import
thib
parents:
diff changeset
87 TextGlyphStream::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
88 SDL_PixelFormat& fmt = *dst->format;
223b71206888 Initial import
thib
parents:
diff changeset
89 int ashift = fmt.Ashift - fmt.Aloss; int amask = fmt.Amask;
223b71206888 Initial import
thib
parents:
diff changeset
90 int dbpl = dst->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
91 int dbpp = fmt.BytesPerPixel;
223b71206888 Initial import
thib
parents:
diff changeset
92
223b71206888 Initial import
thib
parents:
diff changeset
93 SDL_LockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
94 for (it=start; it!=end; it++) {
223b71206888 Initial import
thib
parents:
diff changeset
95 Rect letter_r(*it);
223b71206888 Initial import
thib
parents:
diff changeset
96 letter_r.intersect(confine_to);
223b71206888 Initial import
thib
parents:
diff changeset
97 if (letter_r.empty()) continue;
223b71206888 Initial import
thib
parents:
diff changeset
98 drawn_rect.join(letter_r);
223b71206888 Initial import
thib
parents:
diff changeset
99
223b71206888 Initial import
thib
parents:
diff changeset
100 int w = letter_r.width();
223b71206888 Initial import
thib
parents:
diff changeset
101 int h = letter_r.height();
223b71206888 Initial import
thib
parents:
diff changeset
102 int sbpl = it->glyph->bitmap.width;
223b71206888 Initial import
thib
parents:
diff changeset
103
223b71206888 Initial import
thib
parents:
diff changeset
104 unsigned char* smem = it->glyph->bitmap.buffer +
223b71206888 Initial import
thib
parents:
diff changeset
105 (letter_r.ty - (it->y-it->glyph->bitmap_top)) * sbpl +
223b71206888 Initial import
thib
parents:
diff changeset
106 (letter_r.lx - (it->x+it->glyph->bitmap_left));
223b71206888 Initial import
thib
parents:
diff changeset
107 char* dmem = (char*)dst->pixels +
223b71206888 Initial import
thib
parents:
diff changeset
108 (letter_r.ty + dif_y) * dbpl +
223b71206888 Initial import
thib
parents:
diff changeset
109 (letter_r.lx + dif_x) * dbpp;
223b71206888 Initial import
thib
parents:
diff changeset
110 Uint32 pixel = ((int(it->r)<<fmt.Rshift)&fmt.Rmask) |((int(it->g)<<fmt.Gshift)&fmt.Gmask) |((int(it->b)<<fmt.Bshift)&fmt.Bmask);
223b71206888 Initial import
thib
parents:
diff changeset
111 int i,j;
223b71206888 Initial import
thib
parents:
diff changeset
112 if (!it->is_rev) {
223b71206888 Initial import
thib
parents:
diff changeset
113 if (dbpp == 4) {
223b71206888 Initial import
thib
parents:
diff changeset
114 for (i=0; i<h; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
115 for (j=0; j<w; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
116 int alpha = smem[j];
223b71206888 Initial import
thib
parents:
diff changeset
117 ((Uint32*)dmem)[j] = pixel | ((alpha << ashift)&amask);
223b71206888 Initial import
thib
parents:
diff changeset
118 }
223b71206888 Initial import
thib
parents:
diff changeset
119 smem += sbpl; dmem += dbpl;
223b71206888 Initial import
thib
parents:
diff changeset
120 }
223b71206888 Initial import
thib
parents:
diff changeset
121 } else if (dbpp == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
122 for (i=0; i<h; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
123 for (j=0; j<w; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
124 int alpha = smem[j];
223b71206888 Initial import
thib
parents:
diff changeset
125 ((Uint16*)dmem)[j] = pixel | ((alpha << ashift)&amask);
223b71206888 Initial import
thib
parents:
diff changeset
126 }
223b71206888 Initial import
thib
parents:
diff changeset
127 smem += sbpl; dmem += dbpl;
223b71206888 Initial import
thib
parents:
diff changeset
128 }
223b71206888 Initial import
thib
parents:
diff changeset
129 } else abort();
223b71206888 Initial import
thib
parents:
diff changeset
130 } else { /* reversed */
223b71206888 Initial import
thib
parents:
diff changeset
131 if (dbpp == 4) {
223b71206888 Initial import
thib
parents:
diff changeset
132 for (i=0; i<h; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
133 for (j=0; j<w; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
134 int alpha = 255 - smem[j];
223b71206888 Initial import
thib
parents:
diff changeset
135 ((Uint32*)dmem)[j] = pixel | ((alpha << ashift)&amask);
223b71206888 Initial import
thib
parents:
diff changeset
136 }
223b71206888 Initial import
thib
parents:
diff changeset
137 smem += sbpl; dmem += dbpl;
223b71206888 Initial import
thib
parents:
diff changeset
138 }
223b71206888 Initial import
thib
parents:
diff changeset
139 } else if (dbpp == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
140 for (i=0; i<h; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
141 for (j=0; j<w; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
142 int alpha = 255 - smem[j];
223b71206888 Initial import
thib
parents:
diff changeset
143 ((Uint16*)dmem)[j] = pixel | ((alpha << ashift)&amask);
223b71206888 Initial import
thib
parents:
diff changeset
144 }
223b71206888 Initial import
thib
parents:
diff changeset
145 smem += sbpl; dmem += dbpl;
223b71206888 Initial import
thib
parents:
diff changeset
146 }
223b71206888 Initial import
thib
parents:
diff changeset
147 } else abort();
223b71206888 Initial import
thib
parents:
diff changeset
148 }
223b71206888 Initial import
thib
parents:
diff changeset
149 }
223b71206888 Initial import
thib
parents:
diff changeset
150 SDL_UnlockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
151 drawn_rect.rmove(dif_x, dif_y);
223b71206888 Initial import
thib
parents:
diff changeset
152 return drawn_rect;
223b71206888 Initial import
thib
parents:
diff changeset
153 }
223b71206888 Initial import
thib
parents:
diff changeset
154 void DSurfaceFill(Surface* src_o, const Rect& rect, int r, int g, int b, int a) {
223b71206888 Initial import
thib
parents:
diff changeset
155 SDL_Rect sr = SDLed(rect);
223b71206888 Initial import
thib
parents:
diff changeset
156 SDL_Surface* src = (SDL_Surface*)src_o;
223b71206888 Initial import
thib
parents:
diff changeset
157 SDL_FillRect( src, &sr, SDL_MapRGBA(src->format, r, g, b, a));
223b71206888 Initial import
thib
parents:
diff changeset
158 return;
223b71206888 Initial import
thib
parents:
diff changeset
159 }
223b71206888 Initial import
thib
parents:
diff changeset
160
223b71206888 Initial import
thib
parents:
diff changeset
161 static void clip_rect(Rect& srcrect, Rect& dstrect, SDL_Surface* dstsurf) {
223b71206888 Initial import
thib
parents:
diff changeset
162 Rect confine_to(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
163 Rect dst_clip(_Rect(dstsurf->clip_rect));
223b71206888 Initial import
thib
parents:
diff changeset
164
223b71206888 Initial import
thib
parents:
diff changeset
165 int dif_x = dstrect.lx - srcrect.lx;
223b71206888 Initial import
thib
parents:
diff changeset
166 int dif_y = dstrect.ty - srcrect.ty;
223b71206888 Initial import
thib
parents:
diff changeset
167
223b71206888 Initial import
thib
parents:
diff changeset
168 dst_clip.rmove(-dif_x, -dif_y);
223b71206888 Initial import
thib
parents:
diff changeset
169 confine_to.intersect(dst_clip);
223b71206888 Initial import
thib
parents:
diff changeset
170
223b71206888 Initial import
thib
parents:
diff changeset
171 srcrect = confine_to;
223b71206888 Initial import
thib
parents:
diff changeset
172 dstrect = confine_to;
223b71206888 Initial import
thib
parents:
diff changeset
173 dstrect.rmove(dif_x, dif_y);
223b71206888 Initial import
thib
parents:
diff changeset
174 }
223b71206888 Initial import
thib
parents:
diff changeset
175
223b71206888 Initial import
thib
parents:
diff changeset
176 void DSurfaceMove(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o) {
223b71206888 Initial import
thib
parents:
diff changeset
177
223b71206888 Initial import
thib
parents:
diff changeset
178 SDL_Surface* dst = (SDL_Surface*)dst_o;
223b71206888 Initial import
thib
parents:
diff changeset
179 SDL_Surface* src = (SDL_Surface*)src_o;
223b71206888 Initial import
thib
parents:
diff changeset
180
223b71206888 Initial import
thib
parents:
diff changeset
181 if (dst->format->BytesPerPixel != src->format->BytesPerPixel) return; // RGB変換はできない
223b71206888 Initial import
thib
parents:
diff changeset
182
223b71206888 Initial import
thib
parents:
diff changeset
183 Rect srcrect(srcrect_o), dstrect(dstrect_o);
223b71206888 Initial import
thib
parents:
diff changeset
184 clip_rect(srcrect, dstrect, dst);
223b71206888 Initial import
thib
parents:
diff changeset
185
223b71206888 Initial import
thib
parents:
diff changeset
186 SDL_LockSurface(dst); SDL_LockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
187 int sbpl = src->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
188 int dbpl = dst->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
189 int bpp = dst->format->BytesPerPixel;
223b71206888 Initial import
thib
parents:
diff changeset
190 int width = bpp * srcrect.width();
223b71206888 Initial import
thib
parents:
diff changeset
191 int height = srcrect.height();
223b71206888 Initial import
thib
parents:
diff changeset
192 char* smem = src_o->mem(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
193 char* dmem = dst_o->mem(dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
194 char* smem_end = src_o->mem_end(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
195 char* dmem_end = dst_o->mem_end(dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
196
223b71206888 Initial import
thib
parents:
diff changeset
197 // メモリに重なりがあり、src が上位側の場合、コピー方向を逆転する
223b71206888 Initial import
thib
parents:
diff changeset
198 if (smem < dmem && dmem < smem_end) {
223b71206888 Initial import
thib
parents:
diff changeset
199 int i,j;
223b71206888 Initial import
thib
parents:
diff changeset
200 for (i=0; i<height; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
201 char* s = smem_end; char* d = dmem_end;
223b71206888 Initial import
thib
parents:
diff changeset
202 for (j=0; j<width; j++)
223b71206888 Initial import
thib
parents:
diff changeset
203 *--d = *--s;
223b71206888 Initial import
thib
parents:
diff changeset
204 dmem_end -= dbpl; smem_end -= sbpl;
223b71206888 Initial import
thib
parents:
diff changeset
205 }
223b71206888 Initial import
thib
parents:
diff changeset
206 } else {
223b71206888 Initial import
thib
parents:
diff changeset
207 int i;
223b71206888 Initial import
thib
parents:
diff changeset
208 for (i=0; i<height; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
209 memcpy(dmem, smem, width);
223b71206888 Initial import
thib
parents:
diff changeset
210 dmem += dbpl; smem += sbpl;
223b71206888 Initial import
thib
parents:
diff changeset
211 }
223b71206888 Initial import
thib
parents:
diff changeset
212 }
223b71206888 Initial import
thib
parents:
diff changeset
213 SDL_UnlockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
214 SDL_UnlockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
215 return;
223b71206888 Initial import
thib
parents:
diff changeset
216 }
223b71206888 Initial import
thib
parents:
diff changeset
217
223b71206888 Initial import
thib
parents:
diff changeset
218 void DSurfaceFillA(Surface* dsto, const Rect& rect, int r, int g, int b, int a) {
223b71206888 Initial import
thib
parents:
diff changeset
219 SDL_Surface* dst = (SDL_Surface*)dsto;
223b71206888 Initial import
thib
parents:
diff changeset
220 SDL_LockSurface( dst);
223b71206888 Initial import
thib
parents:
diff changeset
221 int dbpl = dst->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
222 int bpp = dst->format->BytesPerPixel;
223b71206888 Initial import
thib
parents:
diff changeset
223 int width = rect.width();
223b71206888 Initial import
thib
parents:
diff changeset
224 int height = rect.height();
223b71206888 Initial import
thib
parents:
diff changeset
225 int amask = dst->format->Amask;
223b71206888 Initial import
thib
parents:
diff changeset
226 int ashift = dst->format->Ashift - dst->format->Aloss;
223b71206888 Initial import
thib
parents:
diff changeset
227
223b71206888 Initial import
thib
parents:
diff changeset
228 char* dmem = (char*)(dst->pixels) + rect.ty*dbpl + rect.lx*bpp;
223b71206888 Initial import
thib
parents:
diff changeset
229 unsigned int pixel = SDL_MapRGBA(dst->format, r, g, b, 0);
223b71206888 Initial import
thib
parents:
diff changeset
230 unsigned int pixela = SDL_MapRGBA(dst->format, r, g, b, a);
223b71206888 Initial import
thib
parents:
diff changeset
231 a += a>>7; /* 0-256 にする */
223b71206888 Initial import
thib
parents:
diff changeset
232 int i,j;
223b71206888 Initial import
thib
parents:
diff changeset
233 for (i=0; i<height; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
234 char* d = dmem;
223b71206888 Initial import
thib
parents:
diff changeset
235 if (bpp == 4) {
223b71206888 Initial import
thib
parents:
diff changeset
236 for (j=0; j<width; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
237 int alpha = (*(Uint32*)d)>>ashift;
223b71206888 Initial import
thib
parents:
diff changeset
238 if (alpha == 0) (*(Uint32*)d) = pixel;
223b71206888 Initial import
thib
parents:
diff changeset
239 else if (alpha == 255) *((Uint32*)d) = pixela;
223b71206888 Initial import
thib
parents:
diff changeset
240 else { *((Uint32*)d) = pixel | ((((alpha*a)>>8)<<ashift)&amask); }
223b71206888 Initial import
thib
parents:
diff changeset
241 d += bpp;
223b71206888 Initial import
thib
parents:
diff changeset
242 }
223b71206888 Initial import
thib
parents:
diff changeset
243 } else if (bpp == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
244 for (j=0; j<width; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
245 int alpha = (*(Uint16*)d)>>ashift;
223b71206888 Initial import
thib
parents:
diff changeset
246 if (alpha == 0) *((Uint16*)d) = pixel;
223b71206888 Initial import
thib
parents:
diff changeset
247 else if (alpha == 255) *((Uint16*)d) = pixela;
223b71206888 Initial import
thib
parents:
diff changeset
248 else { *((Uint16*)d) = pixel | ((((alpha*a)>>8)<<ashift)&amask); }
223b71206888 Initial import
thib
parents:
diff changeset
249 d += bpp;
223b71206888 Initial import
thib
parents:
diff changeset
250 }
223b71206888 Initial import
thib
parents:
diff changeset
251 }
223b71206888 Initial import
thib
parents:
diff changeset
252 dmem += dbpl;
223b71206888 Initial import
thib
parents:
diff changeset
253 }
223b71206888 Initial import
thib
parents:
diff changeset
254 SDL_UnlockSurface( dst);
223b71206888 Initial import
thib
parents:
diff changeset
255 return;
223b71206888 Initial import
thib
parents:
diff changeset
256 }
223b71206888 Initial import
thib
parents:
diff changeset
257
223b71206888 Initial import
thib
parents:
diff changeset
258 #define ASHIFT 24
223b71206888 Initial import
thib
parents:
diff changeset
259 #define CMASK1 0xff00ff
223b71206888 Initial import
thib
parents:
diff changeset
260 #define CMASK2 0x00ff00
223b71206888 Initial import
thib
parents:
diff changeset
261
223b71206888 Initial import
thib
parents:
diff changeset
262 inline void blit_pixel(Uint32* dmem, Uint32* smem, const unsigned char* amem, bool use_srcalpha) {
223b71206888 Initial import
thib
parents:
diff changeset
263 Uint32 d = *dmem;
223b71206888 Initial import
thib
parents:
diff changeset
264 Uint32 s = *smem;
223b71206888 Initial import
thib
parents:
diff changeset
265 Uint32 as = s>>ASHIFT;
223b71206888 Initial import
thib
parents:
diff changeset
266 if (as == 255 || (!use_srcalpha) ) {
223b71206888 Initial import
thib
parents:
diff changeset
267 as = *amem;
223b71206888 Initial import
thib
parents:
diff changeset
268 } else {
223b71206888 Initial import
thib
parents:
diff changeset
269 as += as>>7; /* 0-0xff -> 0-0x100 */
223b71206888 Initial import
thib
parents:
diff changeset
270 as *= *amem;
223b71206888 Initial import
thib
parents:
diff changeset
271 as >>= 8;
223b71206888 Initial import
thib
parents:
diff changeset
272 }
223b71206888 Initial import
thib
parents:
diff changeset
273 as += as>>7;
223b71206888 Initial import
thib
parents:
diff changeset
274 Uint32 s1 = s & CMASK1;
223b71206888 Initial import
thib
parents:
diff changeset
275 Uint32 d1 = d & CMASK1;
223b71206888 Initial import
thib
parents:
diff changeset
276 d1 = (d1 + (((s1-d1) * as) >> 8)) & CMASK1;
223b71206888 Initial import
thib
parents:
diff changeset
277 s &= CMASK2;
223b71206888 Initial import
thib
parents:
diff changeset
278 d &= CMASK2;
223b71206888 Initial import
thib
parents:
diff changeset
279 d = (d + (((s-d) * as) >> 8)) & CMASK2;
223b71206888 Initial import
thib
parents:
diff changeset
280 *dmem = d1 | d | 0xff000000;
223b71206888 Initial import
thib
parents:
diff changeset
281 }
223b71206888 Initial import
thib
parents:
diff changeset
282 static void blit_line(Uint32* dmem, Uint32* smem, const unsigned char* amem,int ax0, int ax1, int awidth, int aj0, int aj1, bool use_srcalpha) {
223b71206888 Initial import
thib
parents:
diff changeset
283 int j;
223b71206888 Initial import
thib
parents:
diff changeset
284 int ax = ax0;
223b71206888 Initial import
thib
parents:
diff changeset
285 const unsigned char* a = amem + ax0;
223b71206888 Initial import
thib
parents:
diff changeset
286 Uint32* d = dmem;
223b71206888 Initial import
thib
parents:
diff changeset
287 Uint32* s = smem;
223b71206888 Initial import
thib
parents:
diff changeset
288 if (awidth == 1) { // わりとよくあるので最適化
223b71206888 Initial import
thib
parents:
diff changeset
289 for (j=aj0; j < aj1; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
290 blit_pixel(d++, s++, amem, use_srcalpha);
223b71206888 Initial import
thib
parents:
diff changeset
291 }
223b71206888 Initial import
thib
parents:
diff changeset
292 } else {
223b71206888 Initial import
thib
parents:
diff changeset
293 for (j=aj0; j < aj1; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
294 for (; ax<awidth; ax++)
223b71206888 Initial import
thib
parents:
diff changeset
295 blit_pixel(d++, s++, a++, use_srcalpha);
223b71206888 Initial import
thib
parents:
diff changeset
296 ax = 0;
223b71206888 Initial import
thib
parents:
diff changeset
297 a = amem;
223b71206888 Initial import
thib
parents:
diff changeset
298 }
223b71206888 Initial import
thib
parents:
diff changeset
299 for (; ax < ax1; ax++) blit_pixel(d++, s++, a++, use_srcalpha);
223b71206888 Initial import
thib
parents:
diff changeset
300 }
223b71206888 Initial import
thib
parents:
diff changeset
301 }
223b71206888 Initial import
thib
parents:
diff changeset
302
223b71206888 Initial import
thib
parents:
diff changeset
303 void DSurfaceBlitAlpha(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, const unsigned char* alpha, const Rect& alpharect) {
223b71206888 Initial import
thib
parents:
diff changeset
304 SDL_Surface* dst = (SDL_Surface*)dst_o;
223b71206888 Initial import
thib
parents:
diff changeset
305 SDL_Surface* src = (SDL_Surface*)src_o;
223b71206888 Initial import
thib
parents:
diff changeset
306 SDL_PixelFormat& fmt = *dst->format;
223b71206888 Initial import
thib
parents:
diff changeset
307
223b71206888 Initial import
thib
parents:
diff changeset
308 Rect srcrect(srcrect_o), dstrect(dstrect_o);
223b71206888 Initial import
thib
parents:
diff changeset
309 clip_rect(srcrect, dstrect, dst);
223b71206888 Initial import
thib
parents:
diff changeset
310
223b71206888 Initial import
thib
parents:
diff changeset
311 int awidth = alpharect.width();
223b71206888 Initial import
thib
parents:
diff changeset
312 int aheight = alpharect.height();
223b71206888 Initial import
thib
parents:
diff changeset
313 if (awidth == 0 || aheight == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
314 int ax0 = srcrect.lx % awidth;
223b71206888 Initial import
thib
parents:
diff changeset
315 int ay0 = srcrect.ty % aheight;
223b71206888 Initial import
thib
parents:
diff changeset
316 int aj0 = srcrect.lx / awidth;
223b71206888 Initial import
thib
parents:
diff changeset
317 int ai0 = srcrect.ty / aheight;
223b71206888 Initial import
thib
parents:
diff changeset
318 int ax1 = srcrect.rx % awidth;
223b71206888 Initial import
thib
parents:
diff changeset
319 int ay1 = srcrect.by % aheight;
223b71206888 Initial import
thib
parents:
diff changeset
320 int aj1 = srcrect.rx / awidth;
223b71206888 Initial import
thib
parents:
diff changeset
321 int ai1 = srcrect.by / aheight;
223b71206888 Initial import
thib
parents:
diff changeset
322
223b71206888 Initial import
thib
parents:
diff changeset
323 SDL_LockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
324 SDL_LockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
325 int dbpl = dst->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
326 int sbpl = src->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
327 int bpp = dst->format->BytesPerPixel;
223b71206888 Initial import
thib
parents:
diff changeset
328
223b71206888 Initial import
thib
parents:
diff changeset
329 char* dmem = dst_o->mem(dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
330 char* smem = src_o->mem(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
331
223b71206888 Initial import
thib
parents:
diff changeset
332 const unsigned char* amem = alpha + ay0 * awidth;
223b71206888 Initial import
thib
parents:
diff changeset
333 int i;
223b71206888 Initial import
thib
parents:
diff changeset
334 int ay = ay0;
223b71206888 Initial import
thib
parents:
diff changeset
335 for (i = ai0; i < ai1; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
336 for (; ay < aheight; ay++) {
223b71206888 Initial import
thib
parents:
diff changeset
337 if (src->format->Amask == 0)
223b71206888 Initial import
thib
parents:
diff changeset
338 blit_line( (Uint32*)dmem, (Uint32*)smem, amem,ax0, ax1, awidth, aj0, aj1, false);
223b71206888 Initial import
thib
parents:
diff changeset
339 else
223b71206888 Initial import
thib
parents:
diff changeset
340 blit_line( (Uint32*)dmem, (Uint32*)smem, amem,ax0, ax1, awidth, aj0, aj1, true);
223b71206888 Initial import
thib
parents:
diff changeset
341 amem += awidth; dmem += dbpl; smem += sbpl;
223b71206888 Initial import
thib
parents:
diff changeset
342 }
223b71206888 Initial import
thib
parents:
diff changeset
343 ay = 0; amem = alpha;
223b71206888 Initial import
thib
parents:
diff changeset
344 }
223b71206888 Initial import
thib
parents:
diff changeset
345 for (; ay < ay1; ay++) {
223b71206888 Initial import
thib
parents:
diff changeset
346 if (src->format->Amask == 0)
223b71206888 Initial import
thib
parents:
diff changeset
347 blit_line( (Uint32*)dmem, (Uint32*)smem, amem,ax0, ax1, awidth, aj0, aj1, false);
223b71206888 Initial import
thib
parents:
diff changeset
348 else
223b71206888 Initial import
thib
parents:
diff changeset
349 blit_line( (Uint32*)dmem, (Uint32*)smem, amem,ax0, ax1, awidth, aj0, aj1, true);
223b71206888 Initial import
thib
parents:
diff changeset
350 amem += awidth; dmem += dbpl; smem += sbpl;
223b71206888 Initial import
thib
parents:
diff changeset
351 }
223b71206888 Initial import
thib
parents:
diff changeset
352 SDL_UnlockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
353 SDL_UnlockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
354 return;
223b71206888 Initial import
thib
parents:
diff changeset
355 }
223b71206888 Initial import
thib
parents:
diff changeset
356 void DSurfaceBlitSaturate(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, unsigned char alpha) {
223b71206888 Initial import
thib
parents:
diff changeset
357 SDL_Surface* dst = (SDL_Surface*)dst_o;
223b71206888 Initial import
thib
parents:
diff changeset
358 SDL_Surface* src = (SDL_Surface*)src_o;
223b71206888 Initial import
thib
parents:
diff changeset
359
223b71206888 Initial import
thib
parents:
diff changeset
360 if (dst->format->BytesPerPixel != src->format->BytesPerPixel) return; // RGB変換はできない
223b71206888 Initial import
thib
parents:
diff changeset
361
223b71206888 Initial import
thib
parents:
diff changeset
362 Rect srcrect(srcrect_o), dstrect(dstrect_o);
223b71206888 Initial import
thib
parents:
diff changeset
363 clip_rect(srcrect, dstrect, dst);
223b71206888 Initial import
thib
parents:
diff changeset
364
223b71206888 Initial import
thib
parents:
diff changeset
365 SDL_LockSurface(dst); SDL_LockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
366 int sbpl = src->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
367 int dbpl = dst->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
368 int bpp = dst->format->BytesPerPixel;
223b71206888 Initial import
thib
parents:
diff changeset
369 int width = srcrect.width();
223b71206888 Initial import
thib
parents:
diff changeset
370 int height = srcrect.height();
223b71206888 Initial import
thib
parents:
diff changeset
371 char* smem = src_o->mem(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
372 char* dmem = dst_o->mem(dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
373 char* smem_end = src_o->mem_end(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
374 char* dmem_end = dst_o->mem_end(dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
375
223b71206888 Initial import
thib
parents:
diff changeset
376 SDL_PixelFormat& fmt = *dst->format;
223b71206888 Initial import
thib
parents:
diff changeset
377 int rshift = fmt.Rshift - fmt.Rloss; int rmask = fmt.Rmask;
223b71206888 Initial import
thib
parents:
diff changeset
378 int gshift = fmt.Gshift - fmt.Gloss; int gmask = fmt.Gmask;
223b71206888 Initial import
thib
parents:
diff changeset
379 int bshift = fmt.Bshift - fmt.Bloss; int bmask = fmt.Bmask;
223b71206888 Initial import
thib
parents:
diff changeset
380 int allmask = rmask | gmask | bmask;
223b71206888 Initial import
thib
parents:
diff changeset
381 int i;
223b71206888 Initial import
thib
parents:
diff changeset
382 for (i=0; i<height; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
383 char* d = dmem; char* s = smem;
223b71206888 Initial import
thib
parents:
diff changeset
384 int j; for (j=0; j<width; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
385 Uint32 sd = *(Uint32*)s;
223b71206888 Initial import
thib
parents:
diff changeset
386 Uint32 dd = *(Uint32*)d;
223b71206888 Initial import
thib
parents:
diff changeset
387 if (sd&allmask) {
223b71206888 Initial import
thib
parents:
diff changeset
388 Uint32 sr = (sd&rmask)>>rshift;
223b71206888 Initial import
thib
parents:
diff changeset
389 Uint32 sg = (sd&gmask)>>gshift;
223b71206888 Initial import
thib
parents:
diff changeset
390 Uint32 sb = (sd&bmask)>>bshift;
223b71206888 Initial import
thib
parents:
diff changeset
391 if (alpha != ALPHA_MAX) {
223b71206888 Initial import
thib
parents:
diff changeset
392 sr = (sr*alpha)>>8;
223b71206888 Initial import
thib
parents:
diff changeset
393 sg = (sg*alpha)>>8;
223b71206888 Initial import
thib
parents:
diff changeset
394 sb = (sb*alpha)>>8;
223b71206888 Initial import
thib
parents:
diff changeset
395 }
223b71206888 Initial import
thib
parents:
diff changeset
396 Uint32 dr = sr + ((dd&rmask)>>rshift);
223b71206888 Initial import
thib
parents:
diff changeset
397 Uint32 dg = sg + ((dd&gmask)>>gshift);
223b71206888 Initial import
thib
parents:
diff changeset
398 Uint32 db = sb + ((dd&bmask)>>bshift);
223b71206888 Initial import
thib
parents:
diff changeset
399 if (dr > 255) dr = 255;
223b71206888 Initial import
thib
parents:
diff changeset
400 if (dg > 255) dg = 255;
223b71206888 Initial import
thib
parents:
diff changeset
401 if (db > 255) db = 255;
223b71206888 Initial import
thib
parents:
diff changeset
402 *(Uint32*)d = ((dr<<rshift)&rmask)| ((dg<<gshift)&gmask)| ((db<<bshift)&bmask);
223b71206888 Initial import
thib
parents:
diff changeset
403 }
223b71206888 Initial import
thib
parents:
diff changeset
404 s += bpp; d += bpp;
223b71206888 Initial import
thib
parents:
diff changeset
405 }
223b71206888 Initial import
thib
parents:
diff changeset
406 dmem += dbpl; smem += sbpl;
223b71206888 Initial import
thib
parents:
diff changeset
407 }
223b71206888 Initial import
thib
parents:
diff changeset
408 SDL_UnlockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
409 SDL_UnlockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
410 return;
223b71206888 Initial import
thib
parents:
diff changeset
411 }
223b71206888 Initial import
thib
parents:
diff changeset
412 void DSurfaceBlitMultiply(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o) {
223b71206888 Initial import
thib
parents:
diff changeset
413 SDL_Surface* dst = (SDL_Surface*)dst_o;
223b71206888 Initial import
thib
parents:
diff changeset
414 SDL_Surface* src = (SDL_Surface*)src_o;
223b71206888 Initial import
thib
parents:
diff changeset
415
223b71206888 Initial import
thib
parents:
diff changeset
416 Rect srcrect(srcrect_o), dstrect(dstrect_o);
223b71206888 Initial import
thib
parents:
diff changeset
417 clip_rect(srcrect, dstrect, dst);
223b71206888 Initial import
thib
parents:
diff changeset
418
223b71206888 Initial import
thib
parents:
diff changeset
419 SDL_LockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
420 SDL_LockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
421 int dbpl = dst->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
422 int sbpl = src->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
423 int bpp = dst->format->BytesPerPixel;
223b71206888 Initial import
thib
parents:
diff changeset
424 int width = srcrect.width();
223b71206888 Initial import
thib
parents:
diff changeset
425 int height = srcrect.height();
223b71206888 Initial import
thib
parents:
diff changeset
426 char* dmem = dst_o->mem(dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
427 char* smem = src_o->mem(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
428
223b71206888 Initial import
thib
parents:
diff changeset
429 SDL_PixelFormat& fmt = *dst->format;
223b71206888 Initial import
thib
parents:
diff changeset
430 /* dst の 0-255 を 0-pixel に変換する(積算) */
223b71206888 Initial import
thib
parents:
diff changeset
431 int i;
223b71206888 Initial import
thib
parents:
diff changeset
432 int table1[256], table2[256], table3[256];
223b71206888 Initial import
thib
parents:
diff changeset
433 Uint32 src_pixel = *(Uint32*)smem;
223b71206888 Initial import
thib
parents:
diff changeset
434 src_pixel |= 0xff000000;
223b71206888 Initial import
thib
parents:
diff changeset
435 int c1=src_pixel&255, c2=(src_pixel>>8)&255, c3=(src_pixel>>16)&255;
223b71206888 Initial import
thib
parents:
diff changeset
436 for (i=0; i<256; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
437 int n = i + (i>>7);
223b71206888 Initial import
thib
parents:
diff changeset
438 table1[i] = (c1*n)>>8;
223b71206888 Initial import
thib
parents:
diff changeset
439 table2[i] = (c2*n)&0xff00;
223b71206888 Initial import
thib
parents:
diff changeset
440 table3[i] = ((c3*n)<<8) & 0xff0000;
223b71206888 Initial import
thib
parents:
diff changeset
441 }
223b71206888 Initial import
thib
parents:
diff changeset
442 int err_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
443 for (i=0; i<height; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
444 Uint32* d = (Uint32*)dmem;
223b71206888 Initial import
thib
parents:
diff changeset
445 Uint32* s = (Uint32*)smem;
223b71206888 Initial import
thib
parents:
diff changeset
446 int j; for (j=0; j<width; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
447 Uint32 dd = *d;
223b71206888 Initial import
thib
parents:
diff changeset
448 Uint32 ss = *s;
223b71206888 Initial import
thib
parents:
diff changeset
449 if (ss == src_pixel) {
223b71206888 Initial import
thib
parents:
diff changeset
450 *(Uint32*)d = table1[ dd & 0xff] | table2[ (dd>>8) & 0xff] | table3[ (dd>>16) & 0xff];
223b71206888 Initial import
thib
parents:
diff changeset
451 } else if ( ((ss^src_pixel) & 0xffffff) == 0) { // r,g,b of ss == src_pixel
223b71206888 Initial import
thib
parents:
diff changeset
452 Uint32 as = ss>>ASHIFT;
223b71206888 Initial import
thib
parents:
diff changeset
453 as += as>>7;
223b71206888 Initial import
thib
parents:
diff changeset
454 ss = table1[ dd & 0xff] | table2[ (dd>>8) & 0xff] | table3[ (dd>>16) & 0xff];
223b71206888 Initial import
thib
parents:
diff changeset
455 Uint32 s1 = ss&CMASK1;
223b71206888 Initial import
thib
parents:
diff changeset
456 Uint32 d1 = dd&CMASK1;
223b71206888 Initial import
thib
parents:
diff changeset
457 d1 = (d1 + (((s1-d1) * as) >> 8)) & CMASK1;
223b71206888 Initial import
thib
parents:
diff changeset
458 ss &= CMASK2;
223b71206888 Initial import
thib
parents:
diff changeset
459 dd &= CMASK2;
223b71206888 Initial import
thib
parents:
diff changeset
460 dd = (dd + (((ss-dd) * as) >> 8)) & CMASK2;
223b71206888 Initial import
thib
parents:
diff changeset
461 *(Uint32*)d = d1 | dd | 0xff000000;
223b71206888 Initial import
thib
parents:
diff changeset
462 } else err_count++;
223b71206888 Initial import
thib
parents:
diff changeset
463 d++; s++;
223b71206888 Initial import
thib
parents:
diff changeset
464 }
223b71206888 Initial import
thib
parents:
diff changeset
465 dmem += dbpl; smem += sbpl;
223b71206888 Initial import
thib
parents:
diff changeset
466 }
223b71206888 Initial import
thib
parents:
diff changeset
467 if (err_count) {
223b71206888 Initial import
thib
parents:
diff changeset
468 fprintf(stderr,"multipy_blit : surface does not have unique color(%08x); %d pixels in width %d, height %d\n",
223b71206888 Initial import
thib
parents:
diff changeset
469 src_pixel, err_count, width, height);
223b71206888 Initial import
thib
parents:
diff changeset
470 }
223b71206888 Initial import
thib
parents:
diff changeset
471 SDL_UnlockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
472 SDL_UnlockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
473 return;
223b71206888 Initial import
thib
parents:
diff changeset
474 }