32bpp_sse2.hpp

Go to the documentation of this file.
00001 /* $Id: 32bpp_sse2.hpp 26260 2014-01-13 18:20:23Z rubidium $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * 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.
00006  * 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.
00007  * 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/>.
00008  */
00009 
00012 #ifndef BLITTER_32BPP_SSE2_HPP
00013 #define BLITTER_32BPP_SSE2_HPP
00014 
00015 #ifdef WITH_SSE
00016 
00017 #ifndef SSE_VERSION
00018 #define SSE_VERSION 2
00019 #endif
00020 
00021 #ifndef FULL_ANIMATION
00022 #define FULL_ANIMATION 0
00023 #endif
00024 
00025 #include "32bpp_sse_type.h"
00026 
00028 class Blitter_32bppSSE_Base {
00029 public:
00030   virtual ~Blitter_32bppSSE_Base() {}
00031 
00032   struct MapValue {
00033     uint8 m;
00034     uint8 v;
00035   };
00036   assert_compile(sizeof(MapValue) == 2);
00037 
00039   enum ReadMode {
00040     RM_WITH_SKIP,   
00041     RM_WITH_MARGIN, 
00042     RM_NONE,        
00043   };
00044 
00046   enum BlockType {
00047     BT_EVEN, 
00048     BT_ODD,  
00049     BT_NONE, 
00050   };
00051 
00057   enum SpriteFlags {
00058     SF_NONE        = 0,
00059     SF_TRANSLUCENT = 1 << 1, 
00060     SF_NO_REMAP    = 1 << 2, 
00061     SF_NO_ANIM     = 1 << 3, 
00062   };
00063 
00065   struct SpriteInfo {
00066     uint32 sprite_offset;    
00067     uint32 mv_offset;        
00068     uint16 sprite_line_size; 
00069     uint16 sprite_width;     
00070   };
00071   struct SpriteData {
00072     SpriteFlags flags;
00073     SpriteInfo infos[ZOOM_LVL_COUNT];
00074     byte data[]; 
00075   };
00076 
00077   Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
00078 };
00079 
00080 DECLARE_ENUM_AS_BIT_SET(Blitter_32bppSSE_Base::SpriteFlags);
00081 
00083 class Blitter_32bppSSE2 : public Blitter_32bppSimple, public Blitter_32bppSSE_Base {
00084 public:
00085   /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
00086   template <BlitterMode mode, Blitter_32bppSSE_Base::ReadMode read_mode, Blitter_32bppSSE_Base::BlockType bt_last, bool translucent>
00087   void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
00088 
00089   /* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) {
00090     return Blitter_32bppSSE_Base::Encode(sprite, allocator);
00091   }
00092 
00093   /* virtual */ const char *GetName() { return "32bpp-sse2"; }
00094 };
00095 
00097 class FBlitter_32bppSSE2 : public BlitterFactory {
00098 public:
00099   FBlitter_32bppSSE2() : BlitterFactory("32bpp-sse2", "32bpp SSE2 Blitter (no palette animation)", HasCPUIDFlag(1, 3, 26)) {}
00100   /* virtual */ Blitter *CreateInstance() { return new Blitter_32bppSSE2(); }
00101 };
00102 
00103 #endif /* WITH_SSE */
00104 #endif /* BLITTER_32BPP_SSE2_HPP */