Author: mordante
Date: Sat Mar 31 16:45:23 2012
New Revision: 53720
URL: http://svn.gna.org/viewcvs/wesnoth?rev=53720&view=rev
Log:
Rewrite the blending algorithm.
The rewrite only has minor visual differences, ImageMagick's
`composite -compose difference'
shows no visual differences.
The change makes it possible to optimise the code on the ARM Cortex A8
using NEON instructions.
Modified:
trunk/data/test/test/image/blend/0F_000000FF.png
trunk/data/test/test/image/blend/0F_0000FF00.png
trunk/data/test/test/image/blend/0F_00FF0000.png
trunk/data/test/test/image/blend/1F_000000FF.png
trunk/data/test/test/image/blend/1F_0000FF00.png
trunk/data/test/test/image/blend/1F_00FF0000.png
trunk/data/test/test/image/blend/2F_000000FF.png
trunk/data/test/test/image/blend/2F_0000FF00.png
trunk/data/test/test/image/blend/2F_00FF0000.png
trunk/data/test/test/image/blend/3F_000000FF.png
trunk/data/test/test/image/blend/3F_0000FF00.png
trunk/data/test/test/image/blend/3F_00FF0000.png
trunk/data/test/test/image/blend/4F_000000FF.png
trunk/data/test/test/image/blend/4F_0000FF00.png
trunk/data/test/test/image/blend/4F_00FF0000.png
trunk/data/test/test/image/blend/5F_000000FF.png
trunk/data/test/test/image/blend/5F_0000FF00.png
trunk/data/test/test/image/blend/5F_00FF0000.png
trunk/data/test/test/image/blend/6F_000000FF.png
trunk/data/test/test/image/blend/6F_0000FF00.png
trunk/data/test/test/image/blend/6F_00FF0000.png
trunk/data/test/test/image/blend/7F_000000FF.png
trunk/data/test/test/image/blend/7F_0000FF00.png
trunk/data/test/test/image/blend/7F_00FF0000.png
trunk/data/test/test/image/blend/8F_000000FF.png
trunk/data/test/test/image/blend/8F_0000FF00.png
trunk/data/test/test/image/blend/8F_00FF0000.png
trunk/data/test/test/image/blend/9F_000000FF.png
trunk/data/test/test/image/blend/9F_0000FF00.png
trunk/data/test/test/image/blend/9F_00FF0000.png
trunk/data/test/test/image/blend/AF_000000FF.png
trunk/data/test/test/image/blend/AF_0000FF00.png
trunk/data/test/test/image/blend/AF_00FF0000.png
trunk/data/test/test/image/blend/BF_000000FF.png
trunk/data/test/test/image/blend/BF_0000FF00.png
trunk/data/test/test/image/blend/BF_00FF0000.png
trunk/data/test/test/image/blend/CF_000000FF.png
trunk/data/test/test/image/blend/CF_0000FF00.png
trunk/data/test/test/image/blend/CF_00FF0000.png
trunk/data/test/test/image/blend/DF_000000FF.png
trunk/data/test/test/image/blend/DF_0000FF00.png
trunk/data/test/test/image/blend/DF_00FF0000.png
trunk/data/test/test/image/blend/EF_000000FF.png
trunk/data/test/test/image/blend/EF_0000FF00.png
trunk/data/test/test/image/blend/EF_00FF0000.png
trunk/src/sdl_utils.cpp
trunk/src/sdl_utils.hpp
Modified: trunk/data/test/test/image/blend/0F_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/0F_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/0F_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/0F_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/0F_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/0F_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/1F_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/1F_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/1F_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/1F_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/1F_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/1F_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/2F_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/2F_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/2F_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/2F_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/2F_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/2F_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/3F_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/3F_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/3F_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/3F_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/3F_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/3F_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/4F_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/4F_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/4F_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/4F_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/4F_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/4F_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/5F_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/5F_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/5F_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/5F_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/5F_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/5F_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/6F_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/6F_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/6F_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/6F_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/6F_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/6F_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/7F_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/7F_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/7F_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/7F_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/7F_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/7F_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/8F_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/8F_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/8F_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/8F_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/8F_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/8F_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/9F_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/9F_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/9F_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/9F_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/9F_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/9F_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/AF_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/AF_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/AF_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/AF_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/AF_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/AF_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/BF_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/BF_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/BF_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/BF_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/BF_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/BF_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/CF_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/CF_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/CF_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/CF_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/CF_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/CF_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/DF_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/DF_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/DF_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/DF_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/DF_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/DF_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/EF_000000FF.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/EF_000000FF.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/EF_0000FF00.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/EF_0000FF00.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/data/test/test/image/blend/EF_00FF0000.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/test/test/image/blend/EF_00FF0000.png?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
Binary files - no diff available.
Modified: trunk/src/sdl_utils.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sdl_utils.cpp?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
--- trunk/src/sdl_utils.cpp (original)
+++ trunk/src/sdl_utils.cpp Sat Mar 31 16:45:23 2012
@@ -1460,8 +1460,11 @@
return res;
}
-
-surface blend_surface(const surface &surf, double amount, Uint32 color, bool
optimize)
+surface blend_surface(
+ const surface &surf
+ , const double amount
+ , const Uint32 color
+ , const bool optimize)
{
if(surf== NULL) {
return NULL;
@@ -1479,25 +1482,17 @@
Uint32* beg = lock.pixels();
Uint32* end = beg + nsurf->w*surf->h;
- Uint8 red, green, blue, alpha;
- SDL_GetRGBA(color,nsurf->format,&red,&green,&blue,&alpha);
-
- red = Uint8(red * amount);
- green = Uint8(green * amount);
- blue = Uint8(blue * amount);
-
- amount = 1.0 - amount;
+ Uint16 ratio = amount * 256;
+ const Uint16 red = ratio * static_cast<Uint8>(color >> 16);
+ const Uint16 green = ratio * static_cast<Uint8>(color >> 8);
+ const Uint16 blue = ratio * static_cast<Uint8>(color);
+ ratio = 256 - ratio;
while(beg != end) {
- Uint8 r, g, b, a;
- a = (*beg) >> 24;
- r = (*beg) >> 16;
- g = (*beg) >> 8;
- b = (*beg);
-
- r = Uint8(r * amount) + red;
- g = Uint8(g * amount) + green;
- b = Uint8(b * amount) + blue;
+ Uint8 a = static_cast<Uint8>(*beg >> 24);
+ Uint8 r = (ratio * static_cast<Uint8>(*beg >> 16) +
red) >> 8;
+ Uint8 g = (ratio * static_cast<Uint8>(*beg >> 8) +
green) >> 8;
+ Uint8 b = (ratio * static_cast<Uint8>(*beg) +
blue) >> 8;
*beg = (a << 24) | (r << 16) | (g << 8) | b;
Modified: trunk/src/sdl_utils.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sdl_utils.hpp?rev=53720&r1=53719&r2=53720&view=diff
==============================================================================
--- trunk/src/sdl_utils.hpp (original)
+++ trunk/src/sdl_utils.hpp Sat Mar 31 16:45:23 2012
@@ -306,9 +306,9 @@
*/
surface blend_surface(
const surface &surf
- , double amount
- , Uint32 color
- , bool optimize = true);
+ , const double amount
+ , const Uint32 color
+ , const bool optimize = true);
surface flip_surface(const surface &surf, bool optimize=true);
surface flop_surface(const surface &surf, bool optimize=true);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits