mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use EnumBitSet for SpriteFlags.
parent
5abe7c1386
commit
234c9fb3bd
|
@ -397,35 +397,35 @@ bm_normal:
|
|||
if (bp->skip_left != 0 || bp->width <= MARGIN_NORMAL_THRESHOLD) {
|
||||
const BlockType bt_last = (BlockType) (bp->width & 1);
|
||||
if (bt_last == BT_EVEN) {
|
||||
if (sprite_flags & SF_NO_ANIM) Draw<BlitterMode::Normal, RM_WITH_SKIP, BT_EVEN, true, false>(bp, zoom);
|
||||
if (sprite_flags.Test(SpriteFlag::NoAnim)) Draw<BlitterMode::Normal, RM_WITH_SKIP, BT_EVEN, true, false>(bp, zoom);
|
||||
else Draw<BlitterMode::Normal, RM_WITH_SKIP, BT_EVEN, true, true>(bp, zoom);
|
||||
} else {
|
||||
if (sprite_flags & SF_NO_ANIM) Draw<BlitterMode::Normal, RM_WITH_SKIP, BT_ODD, true, false>(bp, zoom);
|
||||
if (sprite_flags.Test(SpriteFlag::NoAnim)) Draw<BlitterMode::Normal, RM_WITH_SKIP, BT_ODD, true, false>(bp, zoom);
|
||||
else Draw<BlitterMode::Normal, RM_WITH_SKIP, BT_ODD, true, true>(bp, zoom);
|
||||
}
|
||||
} else {
|
||||
#ifdef POINTER_IS_64BIT
|
||||
if (sprite_flags & SF_TRANSLUCENT) {
|
||||
if (sprite_flags & SF_NO_ANIM) Draw<BlitterMode::Normal, RM_WITH_MARGIN, BT_NONE, true, false>(bp, zoom);
|
||||
if (sprite_flags.Test(SpriteFlag::Translucent)) {
|
||||
if (sprite_flags.Test(SpriteFlag::NoAnim)) Draw<BlitterMode::Normal, RM_WITH_MARGIN, BT_NONE, true, false>(bp, zoom);
|
||||
else Draw<BlitterMode::Normal, RM_WITH_MARGIN, BT_NONE, true, true>(bp, zoom);
|
||||
} else {
|
||||
if (sprite_flags & SF_NO_ANIM) Draw<BlitterMode::Normal, RM_WITH_MARGIN, BT_NONE, false, false>(bp, zoom);
|
||||
if (sprite_flags.Test(SpriteFlag::NoAnim)) Draw<BlitterMode::Normal, RM_WITH_MARGIN, BT_NONE, false, false>(bp, zoom);
|
||||
else Draw<BlitterMode::Normal, RM_WITH_MARGIN, BT_NONE, false, true>(bp, zoom);
|
||||
}
|
||||
#else
|
||||
if (sprite_flags & SF_NO_ANIM) Draw<BlitterMode::Normal, RM_WITH_MARGIN, BT_NONE, true, false>(bp, zoom);
|
||||
if (sprite_flags.Test(SpriteFlag::NoAnim)) Draw<BlitterMode::Normal, RM_WITH_MARGIN, BT_NONE, true, false>(bp, zoom);
|
||||
else Draw<BlitterMode::Normal, RM_WITH_MARGIN, BT_NONE, true, true>(bp, zoom);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BlitterMode::ColourRemap:
|
||||
if (sprite_flags & SF_NO_REMAP) goto bm_normal;
|
||||
if (sprite_flags.Test(SpriteFlag::NoRemap)) goto bm_normal;
|
||||
if (bp->skip_left != 0 || bp->width <= MARGIN_REMAP_THRESHOLD) {
|
||||
if (sprite_flags & SF_NO_ANIM) Draw<BlitterMode::ColourRemap, RM_WITH_SKIP, BT_NONE, true, false>(bp, zoom);
|
||||
if (sprite_flags.Test(SpriteFlag::NoAnim)) Draw<BlitterMode::ColourRemap, RM_WITH_SKIP, BT_NONE, true, false>(bp, zoom);
|
||||
else Draw<BlitterMode::ColourRemap, RM_WITH_SKIP, BT_NONE, true, true>(bp, zoom);
|
||||
} else {
|
||||
if (sprite_flags & SF_NO_ANIM) Draw<BlitterMode::ColourRemap, RM_WITH_MARGIN, BT_NONE, true, false>(bp, zoom);
|
||||
if (sprite_flags.Test(SpriteFlag::NoAnim)) Draw<BlitterMode::ColourRemap, RM_WITH_MARGIN, BT_NONE, true, false>(bp, zoom);
|
||||
else Draw<BlitterMode::ColourRemap, RM_WITH_MARGIN, BT_NONE, true, true>(bp, zoom);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -128,10 +128,10 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
|
|||
}
|
||||
|
||||
/* Store sprite flags. */
|
||||
sd.flags = SF_NONE;
|
||||
if (has_translucency) sd.flags |= SF_TRANSLUCENT;
|
||||
if (!has_remap) sd.flags |= SF_NO_REMAP;
|
||||
if (!has_anim) sd.flags |= SF_NO_ANIM;
|
||||
sd.flags = {};
|
||||
if (has_translucency) sd.flags.Set(SpriteFlag::Translucent);
|
||||
if (!has_remap) sd.flags.Set(SpriteFlag::NoRemap);
|
||||
if (!has_anim) sd.flags.Set(SpriteFlag::NoAnim);
|
||||
memcpy(dst_sprite->data, &sd, sizeof(SpriteData));
|
||||
|
||||
return dst_sprite;
|
||||
|
|
|
@ -56,13 +56,14 @@ public:
|
|||
* - calculations (alpha blending),
|
||||
* - heavy branching (remap lookups and animation buffer handling).
|
||||
*/
|
||||
enum SpriteFlags : uint8_t {
|
||||
SF_NONE = 0,
|
||||
SF_TRANSLUCENT = 1 << 1, ///< The sprite has at least 1 translucent pixel.
|
||||
SF_NO_REMAP = 1 << 2, ///< The sprite has no remappable colour pixel.
|
||||
SF_NO_ANIM = 1 << 3, ///< The sprite has no palette animated pixel.
|
||||
enum class SpriteFlag : uint8_t {
|
||||
Translucent, ///< The sprite has at least 1 translucent pixel.
|
||||
NoRemap, ///< The sprite has no remappable colour pixel.
|
||||
NoAnim, ///< The sprite has no palette animated pixel.
|
||||
};
|
||||
|
||||
using SpriteFlags = EnumBitSet<SpriteFlag, uint8_t>;
|
||||
|
||||
/** Data stored about a (single) sprite. */
|
||||
struct SpriteInfo {
|
||||
uint32_t sprite_offset = 0; ///< The offset to the sprite data.
|
||||
|
@ -79,8 +80,6 @@ public:
|
|||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator);
|
||||
};
|
||||
|
||||
DECLARE_ENUM_AS_BIT_SET(Blitter_32bppSSE_Base::SpriteFlags);
|
||||
|
||||
/** The SSE2 32 bpp blitter (without palette animation). */
|
||||
class Blitter_32bppSSE2 : public Blitter_32bppSimple, public Blitter_32bppSSE_Base {
|
||||
public:
|
||||
|
|
|
@ -473,7 +473,7 @@ bm_normal:
|
|||
case BT_ODD: Draw<BlitterMode::Normal, RM_WITH_SKIP, BT_ODD, true>(bp, zoom); return;
|
||||
}
|
||||
} else {
|
||||
if (((const Blitter_32bppSSE_Base::SpriteData *) bp->sprite)->flags & SF_TRANSLUCENT) {
|
||||
if (((const Blitter_32bppSSE_Base::SpriteData *) bp->sprite)->flags.Test(SpriteFlag::Translucent)) {
|
||||
Draw<BlitterMode::Normal, RM_WITH_MARGIN, BT_NONE, true>(bp, zoom);
|
||||
} else {
|
||||
Draw<BlitterMode::Normal, RM_WITH_MARGIN, BT_NONE, false>(bp, zoom);
|
||||
|
@ -483,7 +483,7 @@ bm_normal:
|
|||
break;
|
||||
}
|
||||
case BlitterMode::ColourRemap:
|
||||
if (((const Blitter_32bppSSE_Base::SpriteData *) bp->sprite)->flags & SF_NO_REMAP) goto bm_normal;
|
||||
if (((const Blitter_32bppSSE_Base::SpriteData *) bp->sprite)->flags.Test(SpriteFlag::NoRemap)) goto bm_normal;
|
||||
if (bp->skip_left != 0 || bp->width <= MARGIN_REMAP_THRESHOLD) {
|
||||
Draw<BlitterMode::ColourRemap, RM_WITH_SKIP, BT_NONE, true>(bp, zoom); return;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue