OpenTTD: src/blitter/32bpp_sse2.hpp Source File

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

32bpp_sse2.hpp
Go to the documentation of this file.
1 /* $Id: 32bpp_sse2.hpp 26260 2014-01-13 18:20:23Z rubidium $ */
2
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 */
9
12 #ifndef BLITTER_32BPP_SSE2_HPP
13 #define BLITTER_32BPP_SSE2_HPP
14
15 #ifdef WITH_SSE
16
17 #ifndef SSE_VERSION
18 #define SSE_VERSION 2
19 #endif
20
21 #ifndef FULL_ANIMATION
22 #define FULL_ANIMATION 0
23 #endif
24
25 #include "32bpp_sse_type.h"
26
28 class Blitter_32bppSSE_Base {
29 public:
30 virtual ~Blitter_32bppSSE_Base() {}
31
32 struct MapValue {
33 uint8 m;
34 uint8 v;
35 };
36 assert_compile(sizeof(MapValue) == 2);
37
39 enum ReadMode {
40 RM_WITH_SKIP,
41 RM_WITH_MARGIN,
42 RM_NONE,
43 };
44
46 enum BlockType {
47 BT_EVEN,
48 BT_ODD,
49 BT_NONE,
50 };
51
57 enum SpriteFlags {
58 SF_NONE = 0,
59 SF_TRANSLUCENT = 1 << 1,
60 SF_NO_REMAP = 1 << 2,
61 SF_NO_ANIM = 1 << 3,
62 };
63
65 struct SpriteInfo {
66 uint32 sprite_offset;
67 uint32 mv_offset;
68 uint16 sprite_line_size;
69 uint16 sprite_width;
70 };
71 struct SpriteData {
72 SpriteFlags flags;
73 SpriteInfo infos[ZOOM_LVL_COUNT];
74 byte data[];
75 };
76
77 Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
78 };
79
80 DECLARE_ENUM_AS_BIT_SET(Blitter_32bppSSE_Base::SpriteFlags);
81
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);
88
89 /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) {
90 return Blitter_32bppSSE_Base::Encode(sprite, allocator);
91 }
92
93 /* virtual */ const char *GetName() { return "32bpp-sse2"; }
94 };
95
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(); }
101 };
102
103 #endif /* WITH_SSE */
104 #endif /* BLITTER_32BPP_SSE2_HPP */