comparison src/video/sdlgenblit.pl @ 5143:e743b9c3f6d6

Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 31 Jan 2011 23:23:57 -0800
parents 99210400e8b9
children be02be2ea897
comparison
equal deleted inserted replaced
5142:57851a238c8f 5143:e743b9c3f6d6
81 open(FILE, ">$name.new") || die "Cant' open $name.new: $!"; 81 open(FILE, ">$name.new") || die "Cant' open $name.new: $!";
82 print FILE <<__EOF__; 82 print FILE <<__EOF__;
83 /* DO NOT EDIT! This file is generated by sdlgenblit.pl */ 83 /* DO NOT EDIT! This file is generated by sdlgenblit.pl */
84 /* 84 /*
85 SDL - Simple DirectMedia Layer 85 SDL - Simple DirectMedia Layer
86 Copyright (C) 1997-2009 Sam Lantinga 86 Copyright (C) 1997-2011 Sam Lantinga
87 87
88 This library is free software; you can redistribute it and/or 88 This library is free software; you can redistribute it and/or
89 modify it under the terms of the GNU Lesser General Public 89 modify it under the terms of the GNU Lesser General Public
90 License as published by the Free Software Foundation; either 90 License as published by the Free Software Foundation; either
91 version 2.1 of the License, or (at your option) any later version. 91 version 2.1 of the License, or (at your option) any later version.
236 ${s}R = (${s}R * ${s}A) / 255; 236 ${s}R = (${s}R * ${s}A) / 255;
237 ${s}G = (${s}G * ${s}A) / 255; 237 ${s}G = (${s}G * ${s}A) / 255;
238 ${s}B = (${s}B * ${s}A) / 255; 238 ${s}B = (${s}B * ${s}A) / 255;
239 } 239 }
240 } 240 }
241 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { 241 switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
242 case SDL_COPY_MASK:
243 if (${s}A) {
244 ${d}R = ${s}R;
245 ${d}G = ${s}G;
246 ${d}B = ${s}B;
247 }
248 break;
249 case SDL_COPY_BLEND: 242 case SDL_COPY_BLEND:
250 ${d}R = ${s}R + ((255 - ${s}A) * ${d}R) / 255; 243 ${d}R = ${s}R + ((255 - ${s}A) * ${d}R) / 255;
251 ${d}G = ${s}G + ((255 - ${s}A) * ${d}G) / 255; 244 ${d}G = ${s}G + ((255 - ${s}A) * ${d}G) / 255;
252 ${d}B = ${s}B + ((255 - ${s}A) * ${d}B) / 255; 245 ${d}B = ${s}B + ((255 - ${s}A) * ${d}B) / 255;
253 break; 246 break;
254 case SDL_COPY_ADD: 247 case SDL_COPY_ADD:
255 ${d}R = ${s}R + ${d}R; if (${d}R > 255) ${d}R = 255; 248 ${d}R = ${s}R + ${d}R; if (${d}R > 255) ${d}R = 255;
256 ${d}G = ${s}G + ${d}G; if (${d}G > 255) ${d}G = 255; 249 ${d}G = ${s}G + ${d}G; if (${d}G > 255) ${d}G = 255;
257 ${d}B = ${s}B + ${d}B; if (${d}B > 255) ${d}B = 255; 250 ${d}B = ${s}B + ${d}B; if (${d}B > 255) ${d}B = 255;
258 break;
259 case SDL_COPY_MOD:
260 ${d}R = (${s}R * ${d}R) / 255;
261 ${d}G = (${s}G * ${d}G) / 255;
262 ${d}B = (${s}B * ${d}B) / 255;
263 break; 251 break;
264 } 252 }
265 __EOF__ 253 __EOF__
266 } 254 }
267 if ( $blend ) { 255 if ( $blend ) {
408 } else { 396 } else {
409 $flags = "$flags | $flag"; 397 $flags = "$flags | $flag";
410 } 398 }
411 } 399 }
412 if ( $blend ) { 400 if ( $blend ) {
413 $flag = "SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD"; 401 $flag = "SDL_COPY_BLEND | SDL_COPY_ADD";
414 if ( $flags eq "" ) { 402 if ( $flags eq "" ) {
415 $flags = $flag; 403 $flags = $flag;
416 } else { 404 } else {
417 $flags = "$flags | $flag"; 405 $flags = "$flags | $flag";
418 } 406 }