comparison src/video/SDL_blit.c @ 2265:265bb136af92

More work in progress...
author Sam Lantinga <slouken@libsdl.org>
date Fri, 17 Aug 2007 06:58:20 +0000
parents 900c35d8e8fd
children e61ad15a205f
comparison
equal deleted inserted replaced
2264:f7f80b822c1f 2265:265bb136af92
119 #endif /* __MACOSX__ */ 119 #endif /* __MACOSX__ */
120 120
121 static SDL_BlitFunc 121 static SDL_BlitFunc
122 SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFuncEntry * entries) 122 SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFuncEntry * entries)
123 { 123 {
124 int i; 124 int i, flagcheck;
125 static Uint32 features = 0xffffffff; 125 static Uint32 features = 0xffffffff;
126 126
127 /* Get the available CPU features */ 127 /* Get the available CPU features */
128 if (features == 0xffffffff) { 128 if (features == 0xffffffff) {
129 const char *override = SDL_getenv("SDL_BLIT_CPU_FEATURES"); 129 const char *override = SDL_getenv("SDL_BLIT_CPU_FEATURES");
155 } 155 }
156 } 156 }
157 } 157 }
158 158
159 for (i = 0; entries[i].func; ++i) { 159 for (i = 0; entries[i].func; ++i) {
160 /* Check for matching pixel formats */
160 if (src_format != entries[i].src_format) { 161 if (src_format != entries[i].src_format) {
161 continue; 162 continue;
162 } 163 }
163 if (dst_format != entries[i].dst_format) { 164 if (dst_format != entries[i].dst_format) {
164 continue; 165 continue;
165 } 166 }
166 if ((flags & entries[i].flags) != flags) { 167
167 continue; 168 /* Check modulation flags */
168 } 169 flagcheck = (flags & (SDL_COPY_MODULATE_COLOR|SDL_COPY_MODULATE_COLOR));
169 if (!(features & entries[i].cpu)) { 170 if ((flagcheck & entries[i].flags) != flagcheck) {
170 continue; 171 continue;
171 } 172 }
173
174 /* Check blend flags */
175 flagcheck = (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD));
176 if ((flagcheck & entries[i].flags) != flagcheck) {
177 continue;
178 }
179
180 /* Check colorkey flag */
181 flagcheck = (flags & SDL_COPY_COLORKEY);
182 if ((flagcheck & entries[i].flags) != flagcheck) {
183 continue;
184 }
185
186 /* Check scaling flags */
187 flagcheck = (flags & SDL_COPY_NEAREST);
188 if ((flagcheck & entries[i].flags) != flagcheck) {
189 continue;
190 }
191
192 /* Check CPU features */
193 flagcheck = entries[i].cpu;
194 if ((flagcheck & features) != flagcheck) {
195 continue;
196 }
197
198 /* We found the best one! */
172 return entries[i].func; 199 return entries[i].func;
173 } 200 }
174 return NULL; 201 return NULL;
175 } 202 }
176 203
230 SDL_SetError("Blit combination not supported"); 257 SDL_SetError("Blit combination not supported");
231 return (-1); 258 return (-1);
232 } 259 }
233 260
234 /* Choose software blitting function */ 261 /* Choose software blitting function */
235 if (surface->flags & SDL_RLEACCELOK) { 262 if ((surface->flags & SDL_RLEACCELOK) && !(surface->map->flags & () {
236 if (surface->map->identity 263 if (surface->map->identity && (surface->map->flags & SDL_COPY_COLORKEY)
237 && (blit_index == 1 264 && (blit_index == 1
238 || (blit_index == 3 && !surface->format->Amask))) { 265 || (blit_index == 3 && !surface->format->Amask))) {
239 if (SDL_RLESurface(surface) == 0) 266 if (SDL_RLESurface(surface) == 0)
240 surface->map->blit = SDL_RLEBlit; 267 surface->map->blit = SDL_RLEBlit;
241 } else if (blit_index == 2 && surface->format->Amask) { 268 } else if (blit_index == 2 && surface->format->Amask) {