diff --git a/src/openrct2/drawing/Drawing.Sprite.BMP.cpp b/src/openrct2/drawing/Drawing.Sprite.BMP.cpp index 5f39d2d92c..8c4f1d6e75 100644 --- a/src/openrct2/drawing/Drawing.Sprite.BMP.cpp +++ b/src/openrct2/drawing/Drawing.Sprite.BMP.cpp @@ -9,78 +9,6 @@ #include "Drawing.h" -template static bool FASTCALL BlitPixel(const uint8_t* src, uint8_t* dst, const PaletteMap& paletteMap) -{ - if constexpr (TBlendOp & BLEND_TRANSPARENT) - { - // Ignore transparent pixels - if (*src == 0) - { - return false; - } - } - - if constexpr (((TBlendOp & BLEND_SRC) != 0) && ((TBlendOp & BLEND_DST) != 0)) - { - auto pixel = paletteMap.Blend(*src, *dst); - if constexpr (TBlendOp & BLEND_TRANSPARENT) - { - if (pixel == 0) - { - return false; - } - } - *dst = pixel; - return true; - } - else if constexpr ((TBlendOp & BLEND_SRC) != 0) - { - auto pixel = paletteMap[*src]; - if constexpr (TBlendOp & BLEND_TRANSPARENT) - { - if (pixel == 0) - { - return false; - } - } - *dst = pixel; - return true; - } - else if constexpr ((TBlendOp & BLEND_DST) != 0) - { - auto pixel = paletteMap[*dst]; - if constexpr (TBlendOp & BLEND_TRANSPARENT) - { - if (pixel == 0) - { - return false; - } - } - *dst = pixel; - return true; - } - else - { - *dst = *src; - return true; - } -} - -template -static void FASTCALL BlitPixels(const uint8_t* src, uint8_t* dst, const PaletteMap& paletteMap, uint8_t zoom, size_t dstPitch) -{ - auto yDstSkip = dstPitch - zoom; - for (uint8_t yy = 0; yy < zoom; yy++) - { - for (uint8_t xx = 0; xx < zoom; xx++) - { - BlitPixel(src, dst, paletteMap); - dst++; - } - dst += yDstSkip; - } -} - template static void FASTCALL DrawBMPSpriteMagnify(DrawSpriteArgs& args) { auto& g1 = args.SourceImage; diff --git a/src/openrct2/drawing/Drawing.Sprite.RLE.cpp b/src/openrct2/drawing/Drawing.Sprite.RLE.cpp index 713de42ee6..db718df048 100644 --- a/src/openrct2/drawing/Drawing.Sprite.RLE.cpp +++ b/src/openrct2/drawing/Drawing.Sprite.RLE.cpp @@ -9,80 +9,9 @@ #include "Drawing.h" +#include #include -template static bool FASTCALL BlitPixel(const uint8_t* src, uint8_t* dst, const PaletteMap& paletteMap) -{ - if constexpr (TBlendOp & BLEND_TRANSPARENT) - { - // Ignore transparent pixels - if (*src == 0) - { - return false; - } - } - - if constexpr (((TBlendOp & BLEND_SRC) != 0) && ((TBlendOp & BLEND_DST) != 0)) - { - auto pixel = paletteMap.Blend(*src, *dst); - if constexpr (TBlendOp & BLEND_TRANSPARENT) - { - if (pixel == 0) - { - return false; - } - } - *dst = pixel; - return true; - } - else if constexpr ((TBlendOp & BLEND_SRC) != 0) - { - auto pixel = paletteMap[*src]; - if constexpr (TBlendOp & BLEND_TRANSPARENT) - { - if (pixel == 0) - { - return false; - } - } - *dst = pixel; - return true; - } - else if constexpr ((TBlendOp & BLEND_DST) != 0) - { - auto pixel = paletteMap[*dst]; - if constexpr (TBlendOp & BLEND_TRANSPARENT) - { - if (pixel == 0) - { - return false; - } - } - *dst = pixel; - return true; - } - else - { - *dst = *src; - return true; - } -} - -template -static void FASTCALL BlitPixels(const uint8_t* src, uint8_t* dst, const PaletteMap& paletteMap, uint8_t zoom, size_t dstPitch) -{ - auto yDstSkip = dstPitch - zoom; - for (uint8_t yy = 0; yy < zoom; yy++) - { - for (uint8_t xx = 0; xx < zoom; xx++) - { - BlitPixel(src, dst, paletteMap); - dst++; - } - dst += yDstSkip; - } -} - template static void FASTCALL DrawRLESpriteMagnify(DrawSpriteArgs& args) { auto dpi = args.DPI; diff --git a/src/openrct2/drawing/Drawing.h b/src/openrct2/drawing/Drawing.h index c3c1465048..48079e118b 100644 --- a/src/openrct2/drawing/Drawing.h +++ b/src/openrct2/drawing/Drawing.h @@ -544,6 +544,78 @@ struct DrawSpriteArgs } }; +template bool FASTCALL BlitPixel(const uint8_t* src, uint8_t* dst, const PaletteMap& paletteMap) +{ + if constexpr (TBlendOp & BLEND_TRANSPARENT) + { + // Ignore transparent pixels + if (*src == 0) + { + return false; + } + } + + if constexpr (((TBlendOp & BLEND_SRC) != 0) && ((TBlendOp & BLEND_DST) != 0)) + { + auto pixel = paletteMap.Blend(*src, *dst); + if constexpr (TBlendOp & BLEND_TRANSPARENT) + { + if (pixel == 0) + { + return false; + } + } + *dst = pixel; + return true; + } + else if constexpr ((TBlendOp & BLEND_SRC) != 0) + { + auto pixel = paletteMap[*src]; + if constexpr (TBlendOp & BLEND_TRANSPARENT) + { + if (pixel == 0) + { + return false; + } + } + *dst = pixel; + return true; + } + else if constexpr ((TBlendOp & BLEND_DST) != 0) + { + auto pixel = paletteMap[*dst]; + if constexpr (TBlendOp & BLEND_TRANSPARENT) + { + if (pixel == 0) + { + return false; + } + } + *dst = pixel; + return true; + } + else + { + *dst = *src; + return true; + } +} + +template +void FASTCALL BlitPixels(const uint8_t* src, uint8_t* dst, const PaletteMap& paletteMap, uint8_t zoom, size_t dstPitch) +{ + auto yDstSkip = dstPitch - zoom; + for (uint8_t yy = 0; yy < zoom; yy++) + { + for (uint8_t xx = 0; xx < zoom; xx++) + { + BlitPixel(src, dst, paletteMap); + dst++; + } + dst += yDstSkip; + } +} + #define SPRITE_ID_PALETTE_COLOUR_1(colourId) (IMAGE_TYPE_REMAP | ((colourId) << 19)) #define SPRITE_ID_PALETTE_COLOUR_2(primaryId, secondaryId) \ (IMAGE_TYPE_REMAP_2_PLUS | IMAGE_TYPE_REMAP | (((primaryId) << 19) | ((secondaryId) << 24)))