diff options
author | Jonathan G Rennison <j.g.rennison@gmail.com> | 2018-05-23 09:55:04 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2018-05-23 09:55:04 +0100 |
commit | 17257b9620a78dc115fadbcfa9a891e5392f09ab (patch) | |
tree | 78ba69e935bebbdc3b4ad9996cdc0059e576bf8f /src/blitter/32bpp_base.hpp | |
parent | 306b999cf41307377bebe916048bdfb6fdf8e648 (diff) | |
download | openttd-17257b9620a78dc115fadbcfa9a891e5392f09ab.tar.xz |
Add: 32bpp SSE2 blitter palette animator (#6795)
Create a new blitter mode: 32bpp-sse2-anim, which is 32bpp-anim + this.
32bpp-sse2-anim is now used by default where 32bpp-anim would have been.
Also use this with the 32bpp-sse4-anim blitter.
See issue #6469.
Diffstat (limited to 'src/blitter/32bpp_base.hpp')
-rw-r--r-- | src/blitter/32bpp_base.hpp | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/src/blitter/32bpp_base.hpp b/src/blitter/32bpp_base.hpp index 26c3dee3f..9b7627170 100644 --- a/src/blitter/32bpp_base.hpp +++ b/src/blitter/32bpp_base.hpp @@ -146,30 +146,14 @@ public: static const int DEFAULT_BRIGHTNESS = 128; + static Colour ReallyAdjustBrightness(Colour colour, uint8 brightness); + static inline Colour AdjustBrightness(Colour colour, uint8 brightness) { /* Shortcut for normal brightness */ if (brightness == DEFAULT_BRIGHTNESS) return colour; - uint16 ob = 0; - uint16 r = colour.r * brightness / DEFAULT_BRIGHTNESS; - uint16 g = colour.g * brightness / DEFAULT_BRIGHTNESS; - uint16 b = colour.b * brightness / DEFAULT_BRIGHTNESS; - - /* Sum overbright */ - if (r > 255) ob += r - 255; - if (g > 255) ob += g - 255; - if (b > 255) ob += b - 255; - - if (ob == 0) return Colour(r, g, b, colour.a); - - /* Reduce overbright strength */ - ob /= 2; - return Colour( - r >= 255 ? 255 : min(r + ob * (255 - r) / 256, 255), - g >= 255 ? 255 : min(g + ob * (255 - g) / 256, 255), - b >= 255 ? 255 : min(b + ob * (255 - b) / 256, 255), - colour.a); + return ReallyAdjustBrightness(colour, brightness); } }; |