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