annotate window/render.cc @ 55:f1a27ee7e03c

* started the same changes on scn2k_text.cc * handle opcodes childObj*. In fact, it was handled (in a strange way, but it worked) before the previous changeset
author thib
date Wed, 22 Apr 2009 15:01:42 +0000
parents 15a18fbe6f21
children c7bcc0ec2267
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
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
28 #include "font/font.h"
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
29 #include "font/text.h"
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
30 #include "rect.h"
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
31 #include "SDL.h"
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
32 #include "surface.h"
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
33 #include <stdio.h>
0
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 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
61
0
223b71206888 Initial import
thib
parents:
diff changeset
62 inline Rect _Rect(const SDL_Rect& r) {
223b71206888 Initial import
thib
parents:
diff changeset
63 return Rect(r.x, r.y, r.x+r.w, r.y+r.h);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
64 }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
65
0
223b71206888 Initial import
thib
parents:
diff changeset
66 inline SDL_Rect SDLed(const Rect& rect) {
223b71206888 Initial import
thib
parents:
diff changeset
67 SDL_Rect r;
223b71206888 Initial import
thib
parents:
diff changeset
68 r.x = rect.lx;
223b71206888 Initial import
thib
parents:
diff changeset
69 r.y = rect.ty;
223b71206888 Initial import
thib
parents:
diff changeset
70 r.w = rect.rx-rect.lx;
223b71206888 Initial import
thib
parents:
diff changeset
71 r.h = rect.by-rect.ty;
223b71206888 Initial import
thib
parents:
diff changeset
72 return r;
223b71206888 Initial import
thib
parents:
diff changeset
73 }
223b71206888 Initial import
thib
parents:
diff changeset
74
223b71206888 Initial import
thib
parents:
diff changeset
75 Rect DSurfaceRenderText(TextGlyphStream::iterator start, TextGlyphStream::iterator end, const Rect& srcrect,
223b71206888 Initial import
thib
parents:
diff changeset
76 Surface* dst_o, const Rect& dstrect) {
223b71206888 Initial import
thib
parents:
diff changeset
77
223b71206888 Initial import
thib
parents:
diff changeset
78 SDL_Surface* dst = (SDL_Surface*)dst_o;
223b71206888 Initial import
thib
parents:
diff changeset
79 Rect confine_to(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
80 Rect dst_clip(_Rect(dst->clip_rect));
223b71206888 Initial import
thib
parents:
diff changeset
81 Rect drawn_rect(0,0,0,0);
223b71206888 Initial import
thib
parents:
diff changeset
82
223b71206888 Initial import
thib
parents:
diff changeset
83 int dif_x = dstrect.lx - srcrect.lx;
223b71206888 Initial import
thib
parents:
diff changeset
84 int dif_y = dstrect.ty - srcrect.ty;
223b71206888 Initial import
thib
parents:
diff changeset
85
223b71206888 Initial import
thib
parents:
diff changeset
86 dst_clip.rmove(-dif_x, -dif_y);
223b71206888 Initial import
thib
parents:
diff changeset
87 confine_to.intersect(dst_clip);
223b71206888 Initial import
thib
parents:
diff changeset
88
223b71206888 Initial import
thib
parents:
diff changeset
89 TextGlyphStream::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
90 SDL_PixelFormat& fmt = *dst->format;
223b71206888 Initial import
thib
parents:
diff changeset
91 int ashift = fmt.Ashift - fmt.Aloss; int amask = fmt.Amask;
223b71206888 Initial import
thib
parents:
diff changeset
92 int dbpl = dst->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
93 int dbpp = fmt.BytesPerPixel;
223b71206888 Initial import
thib
parents:
diff changeset
94
223b71206888 Initial import
thib
parents:
diff changeset
95 SDL_LockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
96 for (it=start; it!=end; it++) {
223b71206888 Initial import
thib
parents:
diff changeset
97 Rect letter_r(*it);
223b71206888 Initial import
thib
parents:
diff changeset
98 letter_r.intersect(confine_to);
223b71206888 Initial import
thib
parents:
diff changeset
99 if (letter_r.empty()) continue;
223b71206888 Initial import
thib
parents:
diff changeset
100 drawn_rect.join(letter_r);
223b71206888 Initial import
thib
parents:
diff changeset
101
223b71206888 Initial import
thib
parents:
diff changeset
102 int w = letter_r.width();
223b71206888 Initial import
thib
parents:
diff changeset
103 int h = letter_r.height();
223b71206888 Initial import
thib
parents:
diff changeset
104 int sbpl = it->glyph->bitmap.width;
223b71206888 Initial import
thib
parents:
diff changeset
105
223b71206888 Initial import
thib
parents:
diff changeset
106 unsigned char* smem = it->glyph->bitmap.buffer +
223b71206888 Initial import
thib
parents:
diff changeset
107 (letter_r.ty - (it->y-it->glyph->bitmap_top)) * sbpl +
223b71206888 Initial import
thib
parents:
diff changeset
108 (letter_r.lx - (it->x+it->glyph->bitmap_left));
223b71206888 Initial import
thib
parents:
diff changeset
109 char* dmem = (char*)dst->pixels +
223b71206888 Initial import
thib
parents:
diff changeset
110 (letter_r.ty + dif_y) * dbpl +
223b71206888 Initial import
thib
parents:
diff changeset
111 (letter_r.lx + dif_x) * dbpp;
223b71206888 Initial import
thib
parents:
diff changeset
112 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
113 int i,j;
223b71206888 Initial import
thib
parents:
diff changeset
114 if (!it->is_rev) {
223b71206888 Initial import
thib
parents:
diff changeset
115 if (dbpp == 4) {
223b71206888 Initial import
thib
parents:
diff changeset
116 for (i=0; i<h; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
117 for (j=0; j<w; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
118 int alpha = smem[j];
223b71206888 Initial import
thib
parents:
diff changeset
119 ((Uint32*)dmem)[j] = pixel | ((alpha << ashift)&amask);
223b71206888 Initial import
thib
parents:
diff changeset
120 }
223b71206888 Initial import
thib
parents:
diff changeset
121 smem += sbpl; dmem += dbpl;
223b71206888 Initial import
thib
parents:
diff changeset
122 }
223b71206888 Initial import
thib
parents:
diff changeset
123 } else if (dbpp == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
124 for (i=0; i<h; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
125 for (j=0; j<w; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
126 int alpha = smem[j];
223b71206888 Initial import
thib
parents:
diff changeset
127 ((Uint16*)dmem)[j] = pixel | ((alpha << ashift)&amask);
223b71206888 Initial import
thib
parents:
diff changeset
128 }
223b71206888 Initial import
thib
parents:
diff changeset
129 smem += sbpl; dmem += dbpl;
223b71206888 Initial import
thib
parents:
diff changeset
130 }
223b71206888 Initial import
thib
parents:
diff changeset
131 } else abort();
223b71206888 Initial import
thib
parents:
diff changeset
132 } else { /* reversed */
223b71206888 Initial import
thib
parents:
diff changeset
133 if (dbpp == 4) {
223b71206888 Initial import
thib
parents:
diff changeset
134 for (i=0; i<h; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
135 for (j=0; j<w; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
136 int alpha = 255 - smem[j];
223b71206888 Initial import
thib
parents:
diff changeset
137 ((Uint32*)dmem)[j] = pixel | ((alpha << ashift)&amask);
223b71206888 Initial import
thib
parents:
diff changeset
138 }
223b71206888 Initial import
thib
parents:
diff changeset
139 smem += sbpl; dmem += dbpl;
223b71206888 Initial import
thib
parents:
diff changeset
140 }
223b71206888 Initial import
thib
parents:
diff changeset
141 } else if (dbpp == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
142 for (i=0; i<h; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
143 for (j=0; j<w; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
144 int alpha = 255 - smem[j];
223b71206888 Initial import
thib
parents:
diff changeset
145 ((Uint16*)dmem)[j] = pixel | ((alpha << ashift)&amask);
223b71206888 Initial import
thib
parents:
diff changeset
146 }
223b71206888 Initial import
thib
parents:
diff changeset
147 smem += sbpl; dmem += dbpl;
223b71206888 Initial import
thib
parents:
diff changeset
148 }
223b71206888 Initial import
thib
parents:
diff changeset
149 } else abort();
223b71206888 Initial import
thib
parents:
diff changeset
150 }
223b71206888 Initial import
thib
parents:
diff changeset
151 }
223b71206888 Initial import
thib
parents:
diff changeset
152 SDL_UnlockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
153 drawn_rect.rmove(dif_x, dif_y);
223b71206888 Initial import
thib
parents:
diff changeset
154 return drawn_rect;
223b71206888 Initial import
thib
parents:
diff changeset
155 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
156
0
223b71206888 Initial import
thib
parents:
diff changeset
157 void DSurfaceFill(Surface* src_o, const Rect& rect, int r, int g, int b, int a) {
223b71206888 Initial import
thib
parents:
diff changeset
158 SDL_Rect sr = SDLed(rect);
223b71206888 Initial import
thib
parents:
diff changeset
159 SDL_Surface* src = (SDL_Surface*)src_o;
223b71206888 Initial import
thib
parents:
diff changeset
160 SDL_FillRect( src, &sr, SDL_MapRGBA(src->format, r, g, b, a));
223b71206888 Initial import
thib
parents:
diff changeset
161 }
223b71206888 Initial import
thib
parents:
diff changeset
162
223b71206888 Initial import
thib
parents:
diff changeset
163 static void clip_rect(Rect& srcrect, Rect& dstrect, SDL_Surface* dstsurf) {
223b71206888 Initial import
thib
parents:
diff changeset
164 Rect confine_to(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
165 Rect dst_clip(_Rect(dstsurf->clip_rect));
223b71206888 Initial import
thib
parents:
diff changeset
166
223b71206888 Initial import
thib
parents:
diff changeset
167 int dif_x = dstrect.lx - srcrect.lx;
223b71206888 Initial import
thib
parents:
diff changeset
168 int dif_y = dstrect.ty - srcrect.ty;
223b71206888 Initial import
thib
parents:
diff changeset
169
223b71206888 Initial import
thib
parents:
diff changeset
170 dst_clip.rmove(-dif_x, -dif_y);
223b71206888 Initial import
thib
parents:
diff changeset
171 confine_to.intersect(dst_clip);
223b71206888 Initial import
thib
parents:
diff changeset
172
223b71206888 Initial import
thib
parents:
diff changeset
173 srcrect = confine_to;
223b71206888 Initial import
thib
parents:
diff changeset
174 dstrect = confine_to;
223b71206888 Initial import
thib
parents:
diff changeset
175 dstrect.rmove(dif_x, dif_y);
223b71206888 Initial import
thib
parents:
diff changeset
176 }
223b71206888 Initial import
thib
parents:
diff changeset
177
223b71206888 Initial import
thib
parents:
diff changeset
178 void DSurfaceMove(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o) {
223b71206888 Initial import
thib
parents:
diff changeset
179
223b71206888 Initial import
thib
parents:
diff changeset
180 SDL_Surface* dst = (SDL_Surface*)dst_o;
223b71206888 Initial import
thib
parents:
diff changeset
181 SDL_Surface* src = (SDL_Surface*)src_o;
223b71206888 Initial import
thib
parents:
diff changeset
182
223b71206888 Initial import
thib
parents:
diff changeset
183 if (dst->format->BytesPerPixel != src->format->BytesPerPixel) return; // RGB変換はできない
223b71206888 Initial import
thib
parents:
diff changeset
184
223b71206888 Initial import
thib
parents:
diff changeset
185 Rect srcrect(srcrect_o), dstrect(dstrect_o);
223b71206888 Initial import
thib
parents:
diff changeset
186 clip_rect(srcrect, dstrect, dst);
223b71206888 Initial import
thib
parents:
diff changeset
187
223b71206888 Initial import
thib
parents:
diff changeset
188 SDL_LockSurface(dst); SDL_LockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
189 int sbpl = src->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
190 int dbpl = dst->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
191 int bpp = dst->format->BytesPerPixel;
223b71206888 Initial import
thib
parents:
diff changeset
192 int width = bpp * srcrect.width();
223b71206888 Initial import
thib
parents:
diff changeset
193 int height = srcrect.height();
223b71206888 Initial import
thib
parents:
diff changeset
194 char* smem = src_o->mem(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
195 char* dmem = dst_o->mem(dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
196 char* smem_end = src_o->mem_end(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
197 char* dmem_end = dst_o->mem_end(dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
198
223b71206888 Initial import
thib
parents:
diff changeset
199 // メモリに重なりがあり、src が上位側の場合、コピー方向を逆転する
223b71206888 Initial import
thib
parents:
diff changeset
200 if (smem < dmem && dmem < smem_end) {
223b71206888 Initial import
thib
parents:
diff changeset
201 int i,j;
223b71206888 Initial import
thib
parents:
diff changeset
202 for (i=0; i<height; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
203 char* s = smem_end; char* d = dmem_end;
223b71206888 Initial import
thib
parents:
diff changeset
204 for (j=0; j<width; j++)
223b71206888 Initial import
thib
parents:
diff changeset
205 *--d = *--s;
223b71206888 Initial import
thib
parents:
diff changeset
206 dmem_end -= dbpl; smem_end -= sbpl;
223b71206888 Initial import
thib
parents:
diff changeset
207 }
223b71206888 Initial import
thib
parents:
diff changeset
208 } else {
223b71206888 Initial import
thib
parents:
diff changeset
209 int i;
223b71206888 Initial import
thib
parents:
diff changeset
210 for (i=0; i<height; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
211 memcpy(dmem, smem, width);
223b71206888 Initial import
thib
parents:
diff changeset
212 dmem += dbpl; smem += sbpl;
223b71206888 Initial import
thib
parents:
diff changeset
213 }
223b71206888 Initial import
thib
parents:
diff changeset
214 }
223b71206888 Initial import
thib
parents:
diff changeset
215 SDL_UnlockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
216 SDL_UnlockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
217 }
223b71206888 Initial import
thib
parents:
diff changeset
218
223b71206888 Initial import
thib
parents:
diff changeset
219 void DSurfaceFillA(Surface* dsto, const Rect& rect, int r, int g, int b, int a) {
223b71206888 Initial import
thib
parents:
diff changeset
220 SDL_Surface* dst = (SDL_Surface*)dsto;
223b71206888 Initial import
thib
parents:
diff changeset
221 SDL_LockSurface( dst);
223b71206888 Initial import
thib
parents:
diff changeset
222 int dbpl = dst->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
223 int bpp = dst->format->BytesPerPixel;
223b71206888 Initial import
thib
parents:
diff changeset
224 int width = rect.width();
223b71206888 Initial import
thib
parents:
diff changeset
225 int height = rect.height();
223b71206888 Initial import
thib
parents:
diff changeset
226 int amask = dst->format->Amask;
223b71206888 Initial import
thib
parents:
diff changeset
227 int ashift = dst->format->Ashift - dst->format->Aloss;
223b71206888 Initial import
thib
parents:
diff changeset
228
223b71206888 Initial import
thib
parents:
diff changeset
229 char* dmem = (char*)(dst->pixels) + rect.ty*dbpl + rect.lx*bpp;
223b71206888 Initial import
thib
parents:
diff changeset
230 unsigned int pixel = SDL_MapRGBA(dst->format, r, g, b, 0);
223b71206888 Initial import
thib
parents:
diff changeset
231 unsigned int pixela = SDL_MapRGBA(dst->format, r, g, b, a);
223b71206888 Initial import
thib
parents:
diff changeset
232 a += a>>7; /* 0-256 にする */
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
233 int i, j;
0
223b71206888 Initial import
thib
parents:
diff changeset
234 for (i=0; i<height; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
235 char* d = dmem;
223b71206888 Initial import
thib
parents:
diff changeset
236 if (bpp == 4) {
223b71206888 Initial import
thib
parents:
diff changeset
237 for (j=0; j<width; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
238 int alpha = (*(Uint32*)d)>>ashift;
223b71206888 Initial import
thib
parents:
diff changeset
239 if (alpha == 0) (*(Uint32*)d) = pixel;
223b71206888 Initial import
thib
parents:
diff changeset
240 else if (alpha == 255) *((Uint32*)d) = pixela;
223b71206888 Initial import
thib
parents:
diff changeset
241 else { *((Uint32*)d) = pixel | ((((alpha*a)>>8)<<ashift)&amask); }
223b71206888 Initial import
thib
parents:
diff changeset
242 d += bpp;
223b71206888 Initial import
thib
parents:
diff changeset
243 }
223b71206888 Initial import
thib
parents:
diff changeset
244 } else if (bpp == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
245 for (j=0; j<width; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
246 int alpha = (*(Uint16*)d)>>ashift;
223b71206888 Initial import
thib
parents:
diff changeset
247 if (alpha == 0) *((Uint16*)d) = pixel;
223b71206888 Initial import
thib
parents:
diff changeset
248 else if (alpha == 255) *((Uint16*)d) = pixela;
223b71206888 Initial import
thib
parents:
diff changeset
249 else { *((Uint16*)d) = pixel | ((((alpha*a)>>8)<<ashift)&amask); }
223b71206888 Initial import
thib
parents:
diff changeset
250 d += bpp;
223b71206888 Initial import
thib
parents:
diff changeset
251 }
223b71206888 Initial import
thib
parents:
diff changeset
252 }
223b71206888 Initial import
thib
parents:
diff changeset
253 dmem += dbpl;
223b71206888 Initial import
thib
parents:
diff changeset
254 }
223b71206888 Initial import
thib
parents:
diff changeset
255 SDL_UnlockSurface( dst);
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 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
282
0
223b71206888 Initial import
thib
parents:
diff changeset
283 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
284 int j;
223b71206888 Initial import
thib
parents:
diff changeset
285 int ax = ax0;
223b71206888 Initial import
thib
parents:
diff changeset
286 const unsigned char* a = amem + ax0;
223b71206888 Initial import
thib
parents:
diff changeset
287 Uint32* d = dmem;
223b71206888 Initial import
thib
parents:
diff changeset
288 Uint32* s = smem;
223b71206888 Initial import
thib
parents:
diff changeset
289 if (awidth == 1) { // わりとよくあるので最適化
223b71206888 Initial import
thib
parents:
diff changeset
290 for (j=aj0; j < aj1; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
291 blit_pixel(d++, s++, amem, use_srcalpha);
223b71206888 Initial import
thib
parents:
diff changeset
292 }
223b71206888 Initial import
thib
parents:
diff changeset
293 } else {
223b71206888 Initial import
thib
parents:
diff changeset
294 for (j=aj0; j < aj1; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
295 for (; ax<awidth; ax++)
223b71206888 Initial import
thib
parents:
diff changeset
296 blit_pixel(d++, s++, a++, use_srcalpha);
223b71206888 Initial import
thib
parents:
diff changeset
297 ax = 0;
223b71206888 Initial import
thib
parents:
diff changeset
298 a = amem;
223b71206888 Initial import
thib
parents:
diff changeset
299 }
223b71206888 Initial import
thib
parents:
diff changeset
300 for (; ax < ax1; ax++) blit_pixel(d++, s++, a++, use_srcalpha);
223b71206888 Initial import
thib
parents:
diff changeset
301 }
223b71206888 Initial import
thib
parents:
diff changeset
302 }
223b71206888 Initial import
thib
parents:
diff changeset
303
223b71206888 Initial import
thib
parents:
diff changeset
304 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
305 SDL_Surface* dst = (SDL_Surface*)dst_o;
223b71206888 Initial import
thib
parents:
diff changeset
306 SDL_Surface* src = (SDL_Surface*)src_o;
223b71206888 Initial import
thib
parents:
diff changeset
307 SDL_PixelFormat& fmt = *dst->format;
223b71206888 Initial import
thib
parents:
diff changeset
308
223b71206888 Initial import
thib
parents:
diff changeset
309 Rect srcrect(srcrect_o), dstrect(dstrect_o);
223b71206888 Initial import
thib
parents:
diff changeset
310 clip_rect(srcrect, dstrect, dst);
223b71206888 Initial import
thib
parents:
diff changeset
311
223b71206888 Initial import
thib
parents:
diff changeset
312 int awidth = alpharect.width();
223b71206888 Initial import
thib
parents:
diff changeset
313 int aheight = alpharect.height();
223b71206888 Initial import
thib
parents:
diff changeset
314 if (awidth == 0 || aheight == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
315 int ax0 = srcrect.lx % awidth;
223b71206888 Initial import
thib
parents:
diff changeset
316 int ay0 = srcrect.ty % aheight;
223b71206888 Initial import
thib
parents:
diff changeset
317 int aj0 = srcrect.lx / awidth;
223b71206888 Initial import
thib
parents:
diff changeset
318 int ai0 = srcrect.ty / aheight;
223b71206888 Initial import
thib
parents:
diff changeset
319 int ax1 = srcrect.rx % awidth;
223b71206888 Initial import
thib
parents:
diff changeset
320 int ay1 = srcrect.by % aheight;
223b71206888 Initial import
thib
parents:
diff changeset
321 int aj1 = srcrect.rx / awidth;
223b71206888 Initial import
thib
parents:
diff changeset
322 int ai1 = srcrect.by / aheight;
223b71206888 Initial import
thib
parents:
diff changeset
323
223b71206888 Initial import
thib
parents:
diff changeset
324 SDL_LockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
325 SDL_LockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
326 int dbpl = dst->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
327 int sbpl = src->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
328 int bpp = dst->format->BytesPerPixel;
223b71206888 Initial import
thib
parents:
diff changeset
329
223b71206888 Initial import
thib
parents:
diff changeset
330 char* dmem = dst_o->mem(dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
331 char* smem = src_o->mem(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
332
223b71206888 Initial import
thib
parents:
diff changeset
333 const unsigned char* amem = alpha + ay0 * awidth;
223b71206888 Initial import
thib
parents:
diff changeset
334 int i;
223b71206888 Initial import
thib
parents:
diff changeset
335 int ay = ay0;
223b71206888 Initial import
thib
parents:
diff changeset
336 for (i = ai0; i < ai1; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
337 for (; ay < aheight; ay++) {
223b71206888 Initial import
thib
parents:
diff changeset
338 if (src->format->Amask == 0)
223b71206888 Initial import
thib
parents:
diff changeset
339 blit_line( (Uint32*)dmem, (Uint32*)smem, amem,ax0, ax1, awidth, aj0, aj1, false);
223b71206888 Initial import
thib
parents:
diff changeset
340 else
223b71206888 Initial import
thib
parents:
diff changeset
341 blit_line( (Uint32*)dmem, (Uint32*)smem, amem,ax0, ax1, awidth, aj0, aj1, true);
223b71206888 Initial import
thib
parents:
diff changeset
342 amem += awidth; dmem += dbpl; smem += sbpl;
223b71206888 Initial import
thib
parents:
diff changeset
343 }
223b71206888 Initial import
thib
parents:
diff changeset
344 ay = 0; amem = alpha;
223b71206888 Initial import
thib
parents:
diff changeset
345 }
223b71206888 Initial import
thib
parents:
diff changeset
346 for (; ay < ay1; ay++) {
223b71206888 Initial import
thib
parents:
diff changeset
347 if (src->format->Amask == 0)
223b71206888 Initial import
thib
parents:
diff changeset
348 blit_line( (Uint32*)dmem, (Uint32*)smem, amem,ax0, ax1, awidth, aj0, aj1, false);
223b71206888 Initial import
thib
parents:
diff changeset
349 else
223b71206888 Initial import
thib
parents:
diff changeset
350 blit_line( (Uint32*)dmem, (Uint32*)smem, amem,ax0, ax1, awidth, aj0, aj1, true);
223b71206888 Initial import
thib
parents:
diff changeset
351 amem += awidth; dmem += dbpl; smem += sbpl;
223b71206888 Initial import
thib
parents:
diff changeset
352 }
223b71206888 Initial import
thib
parents:
diff changeset
353 SDL_UnlockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
354 SDL_UnlockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
355 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
356
0
223b71206888 Initial import
thib
parents:
diff changeset
357 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
358 SDL_Surface* dst = (SDL_Surface*)dst_o;
223b71206888 Initial import
thib
parents:
diff changeset
359 SDL_Surface* src = (SDL_Surface*)src_o;
223b71206888 Initial import
thib
parents:
diff changeset
360
223b71206888 Initial import
thib
parents:
diff changeset
361 if (dst->format->BytesPerPixel != src->format->BytesPerPixel) return; // RGB変換はできない
223b71206888 Initial import
thib
parents:
diff changeset
362
223b71206888 Initial import
thib
parents:
diff changeset
363 Rect srcrect(srcrect_o), dstrect(dstrect_o);
223b71206888 Initial import
thib
parents:
diff changeset
364 clip_rect(srcrect, dstrect, dst);
223b71206888 Initial import
thib
parents:
diff changeset
365
223b71206888 Initial import
thib
parents:
diff changeset
366 SDL_LockSurface(dst); SDL_LockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
367 int sbpl = src->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
368 int dbpl = dst->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
369 int bpp = dst->format->BytesPerPixel;
223b71206888 Initial import
thib
parents:
diff changeset
370 int width = srcrect.width();
223b71206888 Initial import
thib
parents:
diff changeset
371 int height = srcrect.height();
223b71206888 Initial import
thib
parents:
diff changeset
372 char* smem = src_o->mem(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
373 char* dmem = dst_o->mem(dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
374 char* smem_end = src_o->mem_end(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
375 char* dmem_end = dst_o->mem_end(dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
376
223b71206888 Initial import
thib
parents:
diff changeset
377 SDL_PixelFormat& fmt = *dst->format;
223b71206888 Initial import
thib
parents:
diff changeset
378 int rshift = fmt.Rshift - fmt.Rloss; int rmask = fmt.Rmask;
223b71206888 Initial import
thib
parents:
diff changeset
379 int gshift = fmt.Gshift - fmt.Gloss; int gmask = fmt.Gmask;
223b71206888 Initial import
thib
parents:
diff changeset
380 int bshift = fmt.Bshift - fmt.Bloss; int bmask = fmt.Bmask;
223b71206888 Initial import
thib
parents:
diff changeset
381 int allmask = rmask | gmask | bmask;
223b71206888 Initial import
thib
parents:
diff changeset
382 int i;
223b71206888 Initial import
thib
parents:
diff changeset
383 for (i=0; i<height; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
384 char* d = dmem; char* s = smem;
223b71206888 Initial import
thib
parents:
diff changeset
385 int j; for (j=0; j<width; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
386 Uint32 sd = *(Uint32*)s;
223b71206888 Initial import
thib
parents:
diff changeset
387 Uint32 dd = *(Uint32*)d;
223b71206888 Initial import
thib
parents:
diff changeset
388 if (sd&allmask) {
223b71206888 Initial import
thib
parents:
diff changeset
389 Uint32 sr = (sd&rmask)>>rshift;
223b71206888 Initial import
thib
parents:
diff changeset
390 Uint32 sg = (sd&gmask)>>gshift;
223b71206888 Initial import
thib
parents:
diff changeset
391 Uint32 sb = (sd&bmask)>>bshift;
223b71206888 Initial import
thib
parents:
diff changeset
392 if (alpha != ALPHA_MAX) {
223b71206888 Initial import
thib
parents:
diff changeset
393 sr = (sr*alpha)>>8;
223b71206888 Initial import
thib
parents:
diff changeset
394 sg = (sg*alpha)>>8;
223b71206888 Initial import
thib
parents:
diff changeset
395 sb = (sb*alpha)>>8;
223b71206888 Initial import
thib
parents:
diff changeset
396 }
223b71206888 Initial import
thib
parents:
diff changeset
397 Uint32 dr = sr + ((dd&rmask)>>rshift);
223b71206888 Initial import
thib
parents:
diff changeset
398 Uint32 dg = sg + ((dd&gmask)>>gshift);
223b71206888 Initial import
thib
parents:
diff changeset
399 Uint32 db = sb + ((dd&bmask)>>bshift);
223b71206888 Initial import
thib
parents:
diff changeset
400 if (dr > 255) dr = 255;
223b71206888 Initial import
thib
parents:
diff changeset
401 if (dg > 255) dg = 255;
223b71206888 Initial import
thib
parents:
diff changeset
402 if (db > 255) db = 255;
223b71206888 Initial import
thib
parents:
diff changeset
403 *(Uint32*)d = ((dr<<rshift)&rmask)| ((dg<<gshift)&gmask)| ((db<<bshift)&bmask);
223b71206888 Initial import
thib
parents:
diff changeset
404 }
223b71206888 Initial import
thib
parents:
diff changeset
405 s += bpp; d += bpp;
223b71206888 Initial import
thib
parents:
diff changeset
406 }
223b71206888 Initial import
thib
parents:
diff changeset
407 dmem += dbpl; smem += sbpl;
223b71206888 Initial import
thib
parents:
diff changeset
408 }
223b71206888 Initial import
thib
parents:
diff changeset
409 SDL_UnlockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
410 SDL_UnlockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
411 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 0
diff changeset
412
0
223b71206888 Initial import
thib
parents:
diff changeset
413 void DSurfaceBlitMultiply(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o) {
223b71206888 Initial import
thib
parents:
diff changeset
414 SDL_Surface* dst = (SDL_Surface*)dst_o;
223b71206888 Initial import
thib
parents:
diff changeset
415 SDL_Surface* src = (SDL_Surface*)src_o;
223b71206888 Initial import
thib
parents:
diff changeset
416
223b71206888 Initial import
thib
parents:
diff changeset
417 Rect srcrect(srcrect_o), dstrect(dstrect_o);
223b71206888 Initial import
thib
parents:
diff changeset
418 clip_rect(srcrect, dstrect, dst);
223b71206888 Initial import
thib
parents:
diff changeset
419
223b71206888 Initial import
thib
parents:
diff changeset
420 SDL_LockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
421 SDL_LockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
422 int dbpl = dst->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
423 int sbpl = src->pitch;
223b71206888 Initial import
thib
parents:
diff changeset
424 int bpp = dst->format->BytesPerPixel;
223b71206888 Initial import
thib
parents:
diff changeset
425 int width = srcrect.width();
223b71206888 Initial import
thib
parents:
diff changeset
426 int height = srcrect.height();
223b71206888 Initial import
thib
parents:
diff changeset
427 char* dmem = dst_o->mem(dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
428 char* smem = src_o->mem(srcrect);
223b71206888 Initial import
thib
parents:
diff changeset
429
223b71206888 Initial import
thib
parents:
diff changeset
430 SDL_PixelFormat& fmt = *dst->format;
223b71206888 Initial import
thib
parents:
diff changeset
431 /* dst の 0-255 を 0-pixel に変換する(積算) */
223b71206888 Initial import
thib
parents:
diff changeset
432 int i;
223b71206888 Initial import
thib
parents:
diff changeset
433 int table1[256], table2[256], table3[256];
223b71206888 Initial import
thib
parents:
diff changeset
434 Uint32 src_pixel = *(Uint32*)smem;
223b71206888 Initial import
thib
parents:
diff changeset
435 src_pixel |= 0xff000000;
223b71206888 Initial import
thib
parents:
diff changeset
436 int c1=src_pixel&255, c2=(src_pixel>>8)&255, c3=(src_pixel>>16)&255;
223b71206888 Initial import
thib
parents:
diff changeset
437 for (i=0; i<256; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
438 int n = i + (i>>7);
223b71206888 Initial import
thib
parents:
diff changeset
439 table1[i] = (c1*n)>>8;
223b71206888 Initial import
thib
parents:
diff changeset
440 table2[i] = (c2*n)&0xff00;
223b71206888 Initial import
thib
parents:
diff changeset
441 table3[i] = ((c3*n)<<8) & 0xff0000;
223b71206888 Initial import
thib
parents:
diff changeset
442 }
223b71206888 Initial import
thib
parents:
diff changeset
443 int err_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
444 for (i=0; i<height; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
445 Uint32* d = (Uint32*)dmem;
223b71206888 Initial import
thib
parents:
diff changeset
446 Uint32* s = (Uint32*)smem;
223b71206888 Initial import
thib
parents:
diff changeset
447 int j; for (j=0; j<width; j++) {
223b71206888 Initial import
thib
parents:
diff changeset
448 Uint32 dd = *d;
223b71206888 Initial import
thib
parents:
diff changeset
449 Uint32 ss = *s;
223b71206888 Initial import
thib
parents:
diff changeset
450 if (ss == src_pixel) {
223b71206888 Initial import
thib
parents:
diff changeset
451 *(Uint32*)d = table1[ dd & 0xff] | table2[ (dd>>8) & 0xff] | table3[ (dd>>16) & 0xff];
223b71206888 Initial import
thib
parents:
diff changeset
452 } else if ( ((ss^src_pixel) & 0xffffff) == 0) { // r,g,b of ss == src_pixel
223b71206888 Initial import
thib
parents:
diff changeset
453 Uint32 as = ss>>ASHIFT;
223b71206888 Initial import
thib
parents:
diff changeset
454 as += as>>7;
223b71206888 Initial import
thib
parents:
diff changeset
455 ss = table1[ dd & 0xff] | table2[ (dd>>8) & 0xff] | table3[ (dd>>16) & 0xff];
223b71206888 Initial import
thib
parents:
diff changeset
456 Uint32 s1 = ss&CMASK1;
223b71206888 Initial import
thib
parents:
diff changeset
457 Uint32 d1 = dd&CMASK1;
223b71206888 Initial import
thib
parents:
diff changeset
458 d1 = (d1 + (((s1-d1) * as) >> 8)) & CMASK1;
223b71206888 Initial import
thib
parents:
diff changeset
459 ss &= CMASK2;
223b71206888 Initial import
thib
parents:
diff changeset
460 dd &= CMASK2;
223b71206888 Initial import
thib
parents:
diff changeset
461 dd = (dd + (((ss-dd) * as) >> 8)) & CMASK2;
223b71206888 Initial import
thib
parents:
diff changeset
462 *(Uint32*)d = d1 | dd | 0xff000000;
223b71206888 Initial import
thib
parents:
diff changeset
463 } else err_count++;
223b71206888 Initial import
thib
parents:
diff changeset
464 d++; s++;
223b71206888 Initial import
thib
parents:
diff changeset
465 }
223b71206888 Initial import
thib
parents:
diff changeset
466 dmem += dbpl; smem += sbpl;
223b71206888 Initial import
thib
parents:
diff changeset
467 }
223b71206888 Initial import
thib
parents:
diff changeset
468 if (err_count) {
223b71206888 Initial import
thib
parents:
diff changeset
469 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
470 src_pixel, err_count, width, height);
223b71206888 Initial import
thib
parents:
diff changeset
471 }
223b71206888 Initial import
thib
parents:
diff changeset
472 SDL_UnlockSurface(dst);
223b71206888 Initial import
thib
parents:
diff changeset
473 SDL_UnlockSurface(src);
223b71206888 Initial import
thib
parents:
diff changeset
474 }