mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 17:42:29 +01:00
Share blit methods between BMP and RLE
This commit is contained in:
@@ -9,78 +9,6 @@
|
|||||||
|
|
||||||
#include "Drawing.h"
|
#include "Drawing.h"
|
||||||
|
|
||||||
template<DrawBlendOp TBlendOp> 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<DrawBlendOp TBlendOp>
|
|
||||||
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<TBlendOp>(src, dst, paletteMap);
|
|
||||||
dst++;
|
|
||||||
}
|
|
||||||
dst += yDstSkip;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<DrawBlendOp TBlendOp> static void FASTCALL DrawBMPSpriteMagnify(DrawSpriteArgs& args)
|
template<DrawBlendOp TBlendOp> static void FASTCALL DrawBMPSpriteMagnify(DrawSpriteArgs& args)
|
||||||
{
|
{
|
||||||
auto& g1 = args.SourceImage;
|
auto& g1 = args.SourceImage;
|
||||||
|
|||||||
@@ -9,80 +9,9 @@
|
|||||||
|
|
||||||
#include "Drawing.h"
|
#include "Drawing.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
template<DrawBlendOp TBlendOp> 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<DrawBlendOp TBlendOp>
|
|
||||||
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<TBlendOp>(src, dst, paletteMap);
|
|
||||||
dst++;
|
|
||||||
}
|
|
||||||
dst += yDstSkip;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<DrawBlendOp TBlendOp, size_t TZoom> static void FASTCALL DrawRLESpriteMagnify(DrawSpriteArgs& args)
|
template<DrawBlendOp TBlendOp, size_t TZoom> static void FASTCALL DrawRLESpriteMagnify(DrawSpriteArgs& args)
|
||||||
{
|
{
|
||||||
auto dpi = args.DPI;
|
auto dpi = args.DPI;
|
||||||
|
|||||||
@@ -544,6 +544,78 @@ struct DrawSpriteArgs
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<DrawBlendOp TBlendOp> 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<DrawBlendOp TBlendOp>
|
||||||
|
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<TBlendOp>(src, dst, paletteMap);
|
||||||
|
dst++;
|
||||||
|
}
|
||||||
|
dst += yDstSkip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define SPRITE_ID_PALETTE_COLOUR_1(colourId) (IMAGE_TYPE_REMAP | ((colourId) << 19))
|
#define SPRITE_ID_PALETTE_COLOUR_1(colourId) (IMAGE_TYPE_REMAP | ((colourId) << 19))
|
||||||
#define SPRITE_ID_PALETTE_COLOUR_2(primaryId, secondaryId) \
|
#define SPRITE_ID_PALETTE_COLOUR_2(primaryId, secondaryId) \
|
||||||
(IMAGE_TYPE_REMAP_2_PLUS | IMAGE_TYPE_REMAP | (((primaryId) << 19) | ((secondaryId) << 24)))
|
(IMAGE_TYPE_REMAP_2_PLUS | IMAGE_TYPE_REMAP | (((primaryId) << 19) | ((secondaryId) << 24)))
|
||||||
|
|||||||
Reference in New Issue
Block a user