OpenTTD
32bpp_sse2.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * 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.
4  * 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.
5  * 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/>.
6  */
7 
10 #ifndef BLITTER_32BPP_SSE2_HPP
11 #define BLITTER_32BPP_SSE2_HPP
12 
13 #ifdef WITH_SSE
14 
15 #ifndef SSE_VERSION
16 #define SSE_VERSION 2
17 #endif
18 
19 #ifndef FULL_ANIMATION
20 #define FULL_ANIMATION 0
21 #endif
22 
23 #include "32bpp_sse_type.h"
24 
26 class Blitter_32bppSSE_Base {
27 public:
28  virtual ~Blitter_32bppSSE_Base() {}
29 
30  struct MapValue {
31  uint8 m;
32  uint8 v;
33  };
34  assert_compile(sizeof(MapValue) == 2);
35 
37  enum ReadMode {
38  RM_WITH_SKIP,
39  RM_WITH_MARGIN,
40  RM_NONE,
41  };
42 
44  enum BlockType {
45  BT_EVEN,
46  BT_ODD,
47  BT_NONE,
48  };
49 
55  enum SpriteFlags {
56  SF_NONE = 0,
57  SF_TRANSLUCENT = 1 << 1,
58  SF_NO_REMAP = 1 << 2,
59  SF_NO_ANIM = 1 << 3,
60  };
61 
63  struct SpriteInfo {
64  uint32 sprite_offset;
65  uint32 mv_offset;
66  uint16 sprite_line_size;
67  uint16 sprite_width;
68  };
69  struct SpriteData {
70  SpriteFlags flags;
71  SpriteInfo infos[ZOOM_LVL_COUNT];
72  byte data[];
73  };
74 
75  Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
76 };
77 
78 DECLARE_ENUM_AS_BIT_SET(Blitter_32bppSSE_Base::SpriteFlags);
79 
81 class Blitter_32bppSSE2 : public Blitter_32bppSimple, public Blitter_32bppSSE_Base {
82 public:
83  void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
84  template <BlitterMode mode, Blitter_32bppSSE_Base::ReadMode read_mode, Blitter_32bppSSE_Base::BlockType bt_last, bool translucent>
85  void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
86 
87  Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override {
88  return Blitter_32bppSSE_Base::Encode(sprite, allocator);
89  }
90 
91  const char *GetName() override { return "32bpp-sse2"; }
92 };
93 
95 class FBlitter_32bppSSE2 : public BlitterFactory {
96 public:
97  FBlitter_32bppSSE2() : BlitterFactory("32bpp-sse2", "32bpp SSE2 Blitter (no palette animation)", HasCPUIDFlag(1, 3, 26)) {}
98  Blitter *CreateInstance() override { return new Blitter_32bppSSE2(); }
99 };
100 
101 #endif /* WITH_SSE */
102 #endif /* BLITTER_32BPP_SSE2_HPP */
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Data structure describing a sprite.
Definition: spritecache.h:16
Number of zoom levels.
Definition: zoom_type.h:30
How all blitters should look like.
Definition: base.hpp:28
Parameters related to blitting.
Definition: base.hpp:31
Types related to SSE 32 bpp blitter.
Structure for passing information from the sprite loader to the blitter.
The most trivial 32 bpp blitter (without palette animation).
bool HasCPUIDFlag(uint type, uint index, uint bit)
Check whether the current CPU has the given flag.
Definition: cpu.cpp:128
BlitterMode
The modes of blitting we can do.
Definition: base.hpp:17
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:19
The base factory, keeping track of all blitters.
Definition: factory.hpp:26