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/>.
10 /** @file 32bpp_sse2.hpp SSE2 32 bpp blitter. */
12 #ifndef BLITTER_32BPP_SSE2_HPP
13 #define BLITTER_32BPP_SSE2_HPP
21 #ifndef FULL_ANIMATION
22 #define FULL_ANIMATION 0
25 #include "32bpp_sse_type.h"
27 /** Base methods for 32bpp SSE blitters. */
28 class Blitter_32bppSSE_Base
{
30 virtual ~Blitter_32bppSSE_Base() {}
36 assert_compile(sizeof(MapValue
) == 2);
38 /** Helper for creating specialised functions for specific optimisations. */
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. */
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 /** Data stored about a (single) sprite. */
54 uint32 sprite_offset
; ///< The offset to the sprite data.
55 uint32 mv_offset
; ///< The offset to the map value data.
56 uint16 sprite_line_size
; ///< The size of a single line (pitch).
57 uint16 sprite_width
; ///< The width of the sprite.
60 BlitterSpriteFlags flags
;
61 SpriteInfo infos
[ZOOM_LVL_COUNT
];
62 byte data
[]; ///< Data, all zoomlevels.
65 Sprite
*Encode(const SpriteLoader::Sprite
*sprite
, AllocatorProc
*allocator
);
68 /** The SSE2 32 bpp blitter (without palette animation). */
69 class Blitter_32bppSSE2
: public Blitter_32bppSimple
, public Blitter_32bppSSE_Base
{
71 /* virtual */ void Draw(Blitter::BlitterParams
*bp
, BlitterMode mode
, ZoomLevel zoom
);
72 template <BlitterMode mode
, Blitter_32bppSSE_Base::ReadMode read_mode
, Blitter_32bppSSE_Base::BlockType bt_last
, bool translucent
>
73 void Draw(const Blitter::BlitterParams
*bp
, ZoomLevel zoom
);
75 /* virtual */ Sprite
*Encode(const SpriteLoader::Sprite
*sprite
, AllocatorProc
*allocator
) {
76 return Blitter_32bppSSE_Base::Encode(sprite
, allocator
);
79 /* virtual */ const char *GetName() { return "32bpp-sse2"; }
82 /** Factory for the SSE2 32 bpp blitter (without palette animation). */
83 class FBlitter_32bppSSE2
: public BlitterFactory
{
85 FBlitter_32bppSSE2() : BlitterFactory("32bpp-sse2", "32bpp SSE2 Blitter (no palette animation)", HasCPUIDFlag(1, 3, 26)) {}
86 /* virtual */ Blitter
*CreateInstance() { return new Blitter_32bppSSE2(); }
90 #endif /* BLITTER_32BPP_SSE2_HPP */