(svn r27953) -Cleanup: Adjust other languages for r27952
[openttd.git] / src / blitter / 32bpp_sse2.hpp
blobd6b17f679c46be698ad25c9d17f15e20f2be4960
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file 32bpp_sse2.hpp SSE2 32 bpp blitter. */
12 #ifndef BLITTER_32BPP_SSE2_HPP
13 #define BLITTER_32BPP_SSE2_HPP
15 #ifdef WITH_SSE
17 #ifndef SSE_VERSION
18 #define SSE_VERSION 2
19 #endif
21 #ifndef FULL_ANIMATION
22 #define FULL_ANIMATION 0
23 #endif
25 #include "32bpp_sse_type.h"
27 /** Base methods for 32bpp SSE blitters. */
28 class Blitter_32bppSSE_Base {
29 public:
30 virtual ~Blitter_32bppSSE_Base() {}
32 struct MapValue {
33 uint8 m;
34 uint8 v;
36 assert_compile(sizeof(MapValue) == 2);
38 /** Helper for creating specialised functions for specific optimisations. */
39 enum ReadMode {
40 RM_WITH_SKIP, ///< Use normal code for skipping empty pixels.
41 RM_WITH_MARGIN, ///< Use cached number of empty pixels at begin and end of line to reduce work.
42 RM_NONE, ///< No specialisation.
45 /** Helper for creating specialised functions for the case where the sprite width is odd or even. */
46 enum BlockType {
47 BT_EVEN, ///< An even number of pixels in the width; no need for a special case for the last pixel.
48 BT_ODD, ///< An odd number of pixels in the width; special case for the last pixel.
49 BT_NONE, ///< No specialisation for either case.
52 /** Helper for using specialised functions designed to prevent whenever it's possible things like:
53 * - IO (reading video buffer),
54 * - calculations (alpha blending),
55 * - heavy branching (remap lookups and animation buffer handling).
57 enum SpriteFlags {
58 SF_NONE = 0,
59 SF_TRANSLUCENT = 1 << 1, ///< The sprite has at least 1 translucent pixel.
60 SF_NO_REMAP = 1 << 2, ///< The sprite has no remappable colour pixel.
61 SF_NO_ANIM = 1 << 3, ///< The sprite has no palette animated pixel.
64 /** Data stored about a (single) sprite. */
65 struct SpriteInfo {
66 uint32 sprite_offset; ///< The offset to the sprite data.
67 uint32 mv_offset; ///< The offset to the map value data.
68 uint16 sprite_line_size; ///< The size of a single line (pitch).
69 uint16 sprite_width; ///< The width of the sprite.
71 struct SpriteData {
72 SpriteFlags flags;
73 SpriteInfo infos[ZOOM_LVL_COUNT];
74 byte data[]; ///< Data, all zoomlevels.
77 Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
80 DECLARE_ENUM_AS_BIT_SET(Blitter_32bppSSE_Base::SpriteFlags);
82 /** The SSE2 32 bpp blitter (without palette animation). */
83 class Blitter_32bppSSE2 : public Blitter_32bppSimple, public Blitter_32bppSSE_Base {
84 public:
85 /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
86 template <BlitterMode mode, Blitter_32bppSSE_Base::ReadMode read_mode, Blitter_32bppSSE_Base::BlockType bt_last, bool translucent>
87 void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
89 /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) {
90 return Blitter_32bppSSE_Base::Encode(sprite, allocator);
93 /* virtual */ const char *GetName() { return "32bpp-sse2"; }
96 /** Factory for the SSE2 32 bpp blitter (without palette animation). */
97 class FBlitter_32bppSSE2 : public BlitterFactory {
98 public:
99 FBlitter_32bppSSE2() : BlitterFactory("32bpp-sse2", "32bpp SSE2 Blitter (no palette animation)", HasCPUIDFlag(1, 3, 26)) {}
100 /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSE2(); }
103 #endif /* WITH_SSE */
104 #endif /* BLITTER_32BPP_SSE2_HPP */