mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Deleted unused parts of blitter
This commit is contained in:
parent
158bfa6442
commit
e8e5ef0369
6 changed files with 0 additions and 541 deletions
|
@ -206,14 +206,6 @@ public:
|
|||
//! copies this surface into another
|
||||
virtual void copyTo(IImage *target, const core::position2d<s32> &pos, const core::rect<s32> &sourceRect, const core::rect<s32> *clipRect = 0) = 0;
|
||||
|
||||
//! copies this surface into another, using the alpha mask and cliprect and a color to add with
|
||||
/** \param combineAlpha - When true then combine alpha channels. When false replace target image alpha with source image alpha.
|
||||
*/
|
||||
virtual void copyToWithAlpha(IImage *target, const core::position2d<s32> &pos,
|
||||
const core::rect<s32> &sourceRect, const SColor &color,
|
||||
const core::rect<s32> *clipRect = 0,
|
||||
bool combineAlpha = false) = 0;
|
||||
|
||||
//! copies this surface into another, scaling it to fit, applying a box filter
|
||||
virtual void copyToScalingBoxFilter(IImage *target, s32 bias = 0, bool blend = false) = 0;
|
||||
|
||||
|
|
416
irr/src/CBlit.h
416
irr/src/CBlit.h
|
@ -52,43 +52,6 @@ struct SBlitJob
|
|||
f32 y_stretch;
|
||||
};
|
||||
|
||||
// Bitfields Cohen Sutherland
|
||||
enum eClipCode
|
||||
{
|
||||
CLIPCODE_EMPTY = 0,
|
||||
CLIPCODE_BOTTOM = 1,
|
||||
CLIPCODE_TOP = 2,
|
||||
CLIPCODE_LEFT = 4,
|
||||
CLIPCODE_RIGHT = 8
|
||||
};
|
||||
|
||||
inline u32 GetClipCode(const AbsRectangle &r, const core::position2d<s32> &p)
|
||||
{
|
||||
u32 code = CLIPCODE_EMPTY;
|
||||
|
||||
if (p.X < r.x0)
|
||||
code = CLIPCODE_LEFT;
|
||||
else if (p.X > r.x1)
|
||||
code = CLIPCODE_RIGHT;
|
||||
|
||||
if (p.Y < r.y0)
|
||||
code |= CLIPCODE_TOP;
|
||||
else if (p.Y > r.y1)
|
||||
code |= CLIPCODE_BOTTOM;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
inline void GetClip(AbsRectangle &clipping, video::IImage *t)
|
||||
{
|
||||
clipping.x0 = 0;
|
||||
clipping.y0 = 0;
|
||||
clipping.x1 = t->getDimension().Width - 1;
|
||||
clipping.y1 = t->getDimension().Height - 1;
|
||||
}
|
||||
|
||||
/*
|
||||
return alpha in [0;256] Granularity from 32-Bit ARGB
|
||||
add highbit alpha ( alpha > 127 ? + 1 )
|
||||
|
@ -98,15 +61,6 @@ static inline u32 extractAlpha(const u32 c)
|
|||
return (c >> 24) + (c >> 31);
|
||||
}
|
||||
|
||||
/*
|
||||
return alpha in [0;255] Granularity and 32-Bit ARGB
|
||||
add highbit alpha ( alpha > 127 ? + 1 )
|
||||
*/
|
||||
static inline u32 packAlpha(const u32 c)
|
||||
{
|
||||
return (c > 127 ? c - 1 : c) << 24;
|
||||
}
|
||||
|
||||
/*!
|
||||
Scale Color by (1/value)
|
||||
value 0 - 256 ( alpha )
|
||||
|
@ -408,365 +362,11 @@ static void executeBlit_TextureCopy_32_to_24(const SBlitJob *job)
|
|||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
static void executeBlit_TextureBlend_16_to_16(const SBlitJob *job)
|
||||
{
|
||||
const f18 wscale = f32_to_f18(job->x_stretch);
|
||||
const f18 hscale = f32_to_f18(job->y_stretch);
|
||||
|
||||
f18 src_y = f18_zero;
|
||||
u16 *dst = (u16 *)job->dst;
|
||||
|
||||
for (u32 dy = 0; dy < job->height; ++dy, src_y += hscale) {
|
||||
const u16 *src = (u16 *)((u8 *)(job->src) + job->srcPitch * f18_floor(src_y));
|
||||
f18 src_x = f18_zero;
|
||||
for (u32 dx = 0; dx < job->width; ++dx, src_x += wscale) {
|
||||
dst[dx] = PixelBlend16(dst[dx], src[f18_floor(src_x)]);
|
||||
}
|
||||
dst = (u16 *)((u8 *)(dst) + job->dstPitch);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
static void executeBlit_TextureBlend_32_to_32(const SBlitJob *job)
|
||||
{
|
||||
const f18 wscale = f32_to_f18(job->x_stretch);
|
||||
const f18 hscale = f32_to_f18(job->y_stretch);
|
||||
|
||||
f18 src_y = f18_zero;
|
||||
u32 *dst = (u32 *)job->dst;
|
||||
for (u32 dy = 0; dy < job->height; ++dy, src_y += hscale) {
|
||||
const u32 *src = (u32 *)((u8 *)(job->src) + job->srcPitch * f18_floor(src_y));
|
||||
|
||||
f18 src_x = f18_zero;
|
||||
for (u32 dx = 0; dx < job->width; ++dx, src_x += wscale) {
|
||||
dst[dx] = PixelBlend32(dst[dx], src[f18_floor(src_x)]);
|
||||
}
|
||||
dst = (u32 *)((u8 *)(dst) + job->dstPitch);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
static void executeBlit_TextureBlendColor_16_to_16(const SBlitJob *job)
|
||||
{
|
||||
const u16 blend = video::A8R8G8B8toA1R5G5B5(job->argb);
|
||||
|
||||
const f18 wscale = f32_to_f18(job->x_stretch);
|
||||
const f18 hscale = f32_to_f18(job->y_stretch);
|
||||
|
||||
f18 src_y = f18_zero;
|
||||
u16 *dst = (u16 *)job->dst;
|
||||
for (u32 dy = 0; dy < job->height; ++dy, src_y += hscale) {
|
||||
const u16 *src = (u16 *)((u8 *)(job->src) + job->srcPitch * f18_floor(src_y));
|
||||
f18 src_x = f18_zero;
|
||||
for (u32 dx = 0; dx < job->width; ++dx, src_x += wscale) {
|
||||
u16 c0 = src[f18_floor(src_x)];
|
||||
if (0 == (c0 & 0x8000))
|
||||
continue;
|
||||
|
||||
dst[dx] = PixelMul16_2(c0, blend);
|
||||
}
|
||||
dst = (u16 *)((u8 *)(dst) + job->dstPitch);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
static void executeBlit_TextureBlendColor_32_to_32(const SBlitJob *job)
|
||||
{
|
||||
const f18 wscale = f32_to_f18(job->x_stretch);
|
||||
const f18 hscale = f32_to_f18(job->y_stretch);
|
||||
|
||||
u32 *dst = (u32 *)job->dst;
|
||||
f18 src_y = f18_zero;
|
||||
for (u32 dy = 0; dy < job->height; ++dy, src_y += hscale) {
|
||||
const u32 *src = (u32 *)((u8 *)(job->src) + job->srcPitch * f18_floor(src_y));
|
||||
|
||||
f18 src_x = f18_zero;
|
||||
for (u32 dx = 0; dx < job->width; ++dx, src_x += wscale) {
|
||||
dst[dx] = PixelBlend32(dst[dx], PixelMul32_2(src[f18_floor(src_x)], job->argb));
|
||||
}
|
||||
dst = (u32 *)((u8 *)(dst) + job->dstPitch);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
static void executeBlit_Color_16_to_16(const SBlitJob *job)
|
||||
{
|
||||
const u16 c = video::A8R8G8B8toA1R5G5B5(job->argb);
|
||||
u16 *dst = (u16 *)job->dst;
|
||||
|
||||
for (u32 dy = 0; dy < job->height; ++dy) {
|
||||
memset16(dst, c, job->srcPitch);
|
||||
dst = (u16 *)((u8 *)(dst) + job->dstPitch);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
static void executeBlit_Color_32_to_32(const SBlitJob *job)
|
||||
{
|
||||
u32 *dst = (u32 *)job->dst;
|
||||
|
||||
for (u32 dy = 0; dy < job->height; ++dy) {
|
||||
memset32(dst, job->argb, job->srcPitch);
|
||||
dst = (u32 *)((u8 *)(dst) + job->dstPitch);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
static void executeBlit_ColorAlpha_16_to_16(const SBlitJob *job)
|
||||
{
|
||||
u16 *dst = (u16 *)job->dst;
|
||||
|
||||
const u16 alpha = extractAlpha(job->argb) >> 3;
|
||||
if (0 == alpha)
|
||||
return;
|
||||
const u32 src = video::A8R8G8B8toA1R5G5B5(job->argb);
|
||||
|
||||
for (u32 dy = 0; dy != job->height; ++dy) {
|
||||
for (u32 dx = 0; dx != job->width; ++dx) {
|
||||
dst[dx] = PixelBlend16(dst[dx], src, alpha);
|
||||
}
|
||||
dst = (u16 *)((u8 *)(dst) + job->dstPitch);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
static void executeBlit_ColorAlpha_32_to_32(const SBlitJob *job)
|
||||
{
|
||||
const u32 alpha = extractAlpha(job->argb);
|
||||
if (0 == alpha)
|
||||
return;
|
||||
|
||||
u32 *dst = (u32 *)job->dst;
|
||||
for (u32 dy = 0; dy < job->height; ++dy) {
|
||||
for (u32 dx = 0; dx < job->width; ++dx) {
|
||||
dst[dx] = PixelBlend32(dst[dx], job->argb, alpha);
|
||||
}
|
||||
dst = (u32 *)((u8 *)(dst) + job->dstPitch);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Pixel =>
|
||||
color = sourceAlpha > 0 ? source, else dest
|
||||
alpha = max(destAlpha, sourceAlpha)
|
||||
*/
|
||||
inline u16 PixelCombine16(const u16 c2, const u16 c1)
|
||||
{
|
||||
if (video::getAlpha(c1) > 0)
|
||||
return c1;
|
||||
else
|
||||
return c2;
|
||||
}
|
||||
|
||||
/*!
|
||||
Combine alpha channels (increases alpha / reduces transparency)
|
||||
*/
|
||||
static void executeBlit_TextureCombineColor_16_to_16(const SBlitJob *job)
|
||||
{
|
||||
const u32 w = job->width * 2;
|
||||
const u32 h = job->height * 2;
|
||||
u16 *src = (u16 *)job->src;
|
||||
u16 *dst = (u16 *)job->dst;
|
||||
|
||||
const u16 jobColor = video::A8R8G8B8toA1R5G5B5(job->argb);
|
||||
|
||||
/*
|
||||
Stretch not supported.
|
||||
*/
|
||||
for (u32 dy = 0; dy != h; dy++) {
|
||||
for (u32 dx = 0; dx != w; dx++) {
|
||||
const u16 src_x = src[dx];
|
||||
const u16 dst_x = dst[dx];
|
||||
dst[dx] = PixelCombine16(dst_x, PixelMul16_2(src_x, jobColor));
|
||||
}
|
||||
src = (u16 *)((u8 *)(src) + job->srcPitch);
|
||||
dst = (u16 *)((u8 *)(dst) + job->dstPitch);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Combine alpha channels (increases alpha / reduces transparency)
|
||||
*/
|
||||
static void executeBlit_TextureCombineColor_16_to_24(const SBlitJob *job)
|
||||
{
|
||||
const u32 w = job->width;
|
||||
const u32 h = job->height;
|
||||
const u16 *src = static_cast<const u16 *>(job->src);
|
||||
u8 *dst = static_cast<u8 *>(job->dst);
|
||||
|
||||
const u16 jobColor = video::A8R8G8B8toA1R5G5B5(job->argb);
|
||||
|
||||
if (job->stretch) {
|
||||
const float wscale = job->x_stretch;
|
||||
const float hscale = job->y_stretch;
|
||||
|
||||
for (u32 dy = 0; dy < h; ++dy) {
|
||||
const u32 src_y = (u32)(dy * hscale);
|
||||
src = (u16 *)((u8 *)(job->src) + job->srcPitch * src_y);
|
||||
|
||||
for (u32 dx = 0; dx < w; ++dx) {
|
||||
const u32 src_x = (u32)(dx * wscale);
|
||||
u32 color = PixelMul16_2(video::A1R5G5B5toA8R8G8B8(src[src_x]), jobColor);
|
||||
u8 *writeTo = &dst[dx * 3];
|
||||
if (video::getAlpha(src[src_x]) > 0) { // only overlay if source has visible alpha (alpha == 1)
|
||||
*writeTo++ = (color >> 16) & 0xFF;
|
||||
*writeTo++ = (color >> 8) & 0xFF;
|
||||
*writeTo++ = color & 0xFF;
|
||||
}
|
||||
}
|
||||
dst += job->dstPitch;
|
||||
}
|
||||
} else {
|
||||
for (u32 dy = 0; dy != h; ++dy) {
|
||||
for (u32 dx = 0; dx != w; ++dx) {
|
||||
u32 color = PixelMul16_2(video::A1R5G5B5toA8R8G8B8(src[dx]), jobColor);
|
||||
u8 *writeTo = &dst[dx * 3];
|
||||
if (video::getAlpha(src[dx]) > 0) { // only overlay if source has visible alpha (alpha == 1)
|
||||
*writeTo++ = (color >> 16) & 0xFF;
|
||||
*writeTo++ = (color >> 8) & 0xFF;
|
||||
*writeTo++ = color & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
src = (u16 *)((u8 *)(src) + job->srcPitch);
|
||||
dst += job->dstPitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Pixel =>
|
||||
color = dest * ( 1 - SourceAlpha ) + source * SourceAlpha,
|
||||
alpha = destAlpha * ( 1 - SourceAlpha ) + sourceAlpha
|
||||
|
||||
where "1" means "full scale" (255)
|
||||
*/
|
||||
inline u32 PixelCombine32(const u32 c2, const u32 c1)
|
||||
{
|
||||
// alpha test
|
||||
u32 alpha = c1 & 0xFF000000;
|
||||
|
||||
if (0 == alpha)
|
||||
return c2;
|
||||
if (0xFF000000 == alpha) {
|
||||
return c1;
|
||||
}
|
||||
|
||||
alpha >>= 24;
|
||||
|
||||
// add highbit alpha, if ( alpha > 127 ) alpha += 1;
|
||||
// stretches [0;255] to [0;256] to avoid division by 255. use division 256 == shr 8
|
||||
alpha += (alpha >> 7);
|
||||
|
||||
u32 srcRB = c1 & 0x00FF00FF;
|
||||
u32 srcXG = c1 & 0x0000FF00;
|
||||
|
||||
u32 dstRB = c2 & 0x00FF00FF;
|
||||
u32 dstXG = c2 & 0x0000FF00;
|
||||
|
||||
u32 rb = srcRB - dstRB;
|
||||
u32 xg = srcXG - dstXG;
|
||||
|
||||
rb *= alpha;
|
||||
xg *= alpha;
|
||||
rb >>= 8;
|
||||
xg >>= 8;
|
||||
|
||||
rb += dstRB;
|
||||
xg += dstXG;
|
||||
|
||||
rb &= 0x00FF00FF;
|
||||
xg &= 0x0000FF00;
|
||||
|
||||
u32 sa = c1 >> 24;
|
||||
u32 da = c2 >> 24;
|
||||
u32 blendAlpha_fix8 = (sa * 256 + da * (256 - alpha)) >> 8;
|
||||
return blendAlpha_fix8 << 24 | rb | xg;
|
||||
}
|
||||
|
||||
/*!
|
||||
Combine alpha channels (increases alpha / reduces transparency)
|
||||
Destination alpha is treated as full 255
|
||||
*/
|
||||
static void executeBlit_TextureCombineColor_32_to_24(const SBlitJob *job)
|
||||
{
|
||||
const u32 w = job->width;
|
||||
const u32 h = job->height;
|
||||
const u32 *src = static_cast<const u32 *>(job->src);
|
||||
u8 *dst = static_cast<u8 *>(job->dst);
|
||||
|
||||
if (job->stretch) {
|
||||
const float wscale = job->x_stretch;
|
||||
const float hscale = job->y_stretch;
|
||||
|
||||
for (u32 dy = 0; dy < h; ++dy) {
|
||||
const u32 src_y = (u32)(dy * hscale);
|
||||
src = (u32 *)((u8 *)(job->src) + job->srcPitch * src_y);
|
||||
|
||||
for (u32 dx = 0; dx < w; ++dx) {
|
||||
const u32 src_x = src[(u32)(dx * wscale)];
|
||||
u8 *writeTo = &dst[dx * 3];
|
||||
const u32 dst_x = 0xFF000000 | writeTo[0] << 16 | writeTo[1] << 8 | writeTo[2];
|
||||
const u32 combo = PixelCombine32(dst_x, PixelMul32_2(src_x, job->argb));
|
||||
*writeTo++ = (combo >> 16) & 0xFF;
|
||||
*writeTo++ = (combo >> 8) & 0xFF;
|
||||
*writeTo++ = combo & 0xFF;
|
||||
}
|
||||
dst += job->dstPitch;
|
||||
}
|
||||
} else {
|
||||
for (u32 dy = 0; dy != h; ++dy) {
|
||||
for (u32 dx = 0; dx != w; ++dx) {
|
||||
u8 *writeTo = &dst[dx * 3];
|
||||
const u32 dst_x = 0xFF000000 | writeTo[0] << 16 | writeTo[1] << 8 | writeTo[2];
|
||||
const u32 combo = PixelCombine32(dst_x, PixelMul32_2(src[dx], job->argb));
|
||||
*writeTo++ = (combo >> 16) & 0xFF;
|
||||
*writeTo++ = (combo >> 8) & 0xFF;
|
||||
*writeTo++ = combo & 0xFF;
|
||||
}
|
||||
|
||||
src = (u32 *)((u8 *)(src) + job->srcPitch);
|
||||
dst += job->dstPitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Combine alpha channels (increases alpha / reduces transparency)
|
||||
*/
|
||||
static void executeBlit_TextureCombineColor_32_to_32(const SBlitJob *job)
|
||||
{
|
||||
u32 *src = (u32 *)job->src;
|
||||
u32 *dst = (u32 *)job->dst;
|
||||
|
||||
for (u32 dy = 0; dy != job->height; ++dy) {
|
||||
for (u32 dx = 0; dx != job->width; ++dx) {
|
||||
dst[dx] = PixelCombine32(dst[dx], PixelMul32_2(src[dx], job->argb));
|
||||
}
|
||||
src = (u32 *)((u8 *)(src) + job->srcPitch);
|
||||
dst = (u32 *)((u8 *)(dst) + job->dstPitch);
|
||||
}
|
||||
}
|
||||
|
||||
// Blitter Operation
|
||||
enum eBlitter
|
||||
{
|
||||
BLITTER_INVALID = 0,
|
||||
BLITTER_COLOR,
|
||||
BLITTER_COLOR_ALPHA,
|
||||
BLITTER_TEXTURE,
|
||||
BLITTER_TEXTURE_ALPHA_BLEND,
|
||||
BLITTER_TEXTURE_ALPHA_COLOR_BLEND,
|
||||
BLITTER_TEXTURE_COMBINE_ALPHA,
|
||||
};
|
||||
|
||||
typedef void (*tExecuteBlit)(const SBlitJob *job);
|
||||
|
@ -789,22 +389,6 @@ static const blitterTable blitTable[] = {
|
|||
{BLITTER_TEXTURE, video::ECF_A8R8G8B8, video::ECF_R8G8B8, executeBlit_TextureCopy_24_to_32},
|
||||
{BLITTER_TEXTURE, video::ECF_R8G8B8, video::ECF_A1R5G5B5, executeBlit_TextureCopy_16_to_24},
|
||||
{BLITTER_TEXTURE, video::ECF_R8G8B8, video::ECF_A8R8G8B8, executeBlit_TextureCopy_32_to_24},
|
||||
{BLITTER_TEXTURE_ALPHA_BLEND, video::ECF_A1R5G5B5, video::ECF_A1R5G5B5, executeBlit_TextureBlend_16_to_16},
|
||||
{BLITTER_TEXTURE_ALPHA_BLEND, video::ECF_A8R8G8B8, video::ECF_A8R8G8B8, executeBlit_TextureBlend_32_to_32},
|
||||
{BLITTER_TEXTURE_ALPHA_COLOR_BLEND, video::ECF_A1R5G5B5, video::ECF_A1R5G5B5, executeBlit_TextureBlendColor_16_to_16},
|
||||
{BLITTER_TEXTURE_ALPHA_COLOR_BLEND, video::ECF_A8R8G8B8, video::ECF_A8R8G8B8, executeBlit_TextureBlendColor_32_to_32},
|
||||
{BLITTER_COLOR, video::ECF_A1R5G5B5, -1, executeBlit_Color_16_to_16},
|
||||
{BLITTER_COLOR, video::ECF_A8R8G8B8, -1, executeBlit_Color_32_to_32},
|
||||
{BLITTER_COLOR_ALPHA, video::ECF_A1R5G5B5, -1, executeBlit_ColorAlpha_16_to_16},
|
||||
{BLITTER_COLOR_ALPHA, video::ECF_A8R8G8B8, -1, executeBlit_ColorAlpha_32_to_32},
|
||||
{BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_A8R8G8B8, video::ECF_A8R8G8B8, executeBlit_TextureCombineColor_32_to_32},
|
||||
{BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_A8R8G8B8, video::ECF_R8G8B8, executeBlit_TextureCopy_24_to_32},
|
||||
{BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_R8G8B8, video::ECF_A8R8G8B8, executeBlit_TextureCombineColor_32_to_24},
|
||||
{BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_R8G8B8, video::ECF_R8G8B8, executeBlit_TextureCopy_x_to_x},
|
||||
{BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_A1R5G5B5, video::ECF_R8G8B8, executeBlit_TextureCopy_24_to_16},
|
||||
{BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_A1R5G5B5, video::ECF_A1R5G5B5, executeBlit_TextureCombineColor_16_to_16},
|
||||
{BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_A1R5G5B5, video::ECF_R8G8B8, executeBlit_TextureCopy_24_to_16},
|
||||
{BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_R8G8B8, video::ECF_A1R5G5B5, executeBlit_TextureCombineColor_16_to_24},
|
||||
{BLITTER_INVALID, -1, -1, 0},
|
||||
};
|
||||
|
||||
|
|
|
@ -142,19 +142,6 @@ void CImage::copyTo(IImage *target, const core::position2d<s32> &pos, const core
|
|||
Blit(BLITTER_TEXTURE, target, clipRect, &pos, this, &sourceRect, 0);
|
||||
}
|
||||
|
||||
//! copies this surface into another, using the alpha mask, a cliprect and a color to add with
|
||||
void CImage::copyToWithAlpha(IImage *target, const core::position2d<s32> &pos, const core::rect<s32> &sourceRect, const SColor &color, const core::rect<s32> *clipRect, bool combineAlpha)
|
||||
{
|
||||
if (IImage::isCompressedFormat(Format)) {
|
||||
os::Printer::log("IImage::copyToWithAlpha method doesn't work with compressed images.", ELL_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
eBlitter op = combineAlpha ? BLITTER_TEXTURE_COMBINE_ALPHA : color.color == 0xFFFFFFFF ? BLITTER_TEXTURE_ALPHA_BLEND
|
||||
: BLITTER_TEXTURE_ALPHA_COLOR_BLEND;
|
||||
Blit(op, target, clipRect, &pos, this, &sourceRect, color.color);
|
||||
}
|
||||
|
||||
//! copies this surface into another, if it has the exact same size and format.
|
||||
bool CImage::copyToNoScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch) const
|
||||
{
|
||||
|
|
|
@ -53,11 +53,6 @@ public:
|
|||
//! copies this surface into another
|
||||
void copyTo(IImage *target, const core::position2d<s32> &pos, const core::rect<s32> &sourceRect, const core::rect<s32> *clipRect = 0) override;
|
||||
|
||||
//! copies this surface into another, using the alpha mask, an cliprect and a color to add with
|
||||
virtual void copyToWithAlpha(IImage *target, const core::position2d<s32> &pos,
|
||||
const core::rect<s32> &sourceRect, const SColor &color,
|
||||
const core::rect<s32> *clipRect = 0, bool combineAlpha = false) override;
|
||||
|
||||
//! copies this surface into another, scaling it to fit, applying a box filter
|
||||
void copyToScalingBoxFilter(IImage *target, s32 bias = 0, bool blend = false) override;
|
||||
|
||||
|
|
|
@ -2,11 +2,6 @@
|
|||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
/*
|
||||
History:
|
||||
- changed behavior for log2 textures ( replaced multiplies by shift )
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "irrMath.h"
|
||||
|
@ -120,98 +115,6 @@ REALINLINE u32 PixelBlend32(const u32 c2, const u32 c1, const u32 alpha)
|
|||
return rb | xg;
|
||||
}
|
||||
|
||||
/*!
|
||||
Pixel = dest * ( 1 - alpha ) + source * alpha
|
||||
alpha [0;32]
|
||||
*/
|
||||
inline u16 PixelBlend16(const u16 c2, const u16 c1, const u16 alpha)
|
||||
{
|
||||
const u16 srcRB = c1 & 0x7C1F;
|
||||
const u16 srcXG = c1 & 0x03E0;
|
||||
|
||||
const u16 dstRB = c2 & 0x7C1F;
|
||||
const u16 dstXG = c2 & 0x03E0;
|
||||
|
||||
u32 rb = srcRB - dstRB;
|
||||
u32 xg = srcXG - dstXG;
|
||||
|
||||
rb *= alpha;
|
||||
xg *= alpha;
|
||||
rb >>= 5;
|
||||
xg >>= 5;
|
||||
|
||||
rb += dstRB;
|
||||
xg += dstXG;
|
||||
|
||||
rb &= 0x7C1F;
|
||||
xg &= 0x03E0;
|
||||
|
||||
return (u16)(rb | xg);
|
||||
}
|
||||
|
||||
/*
|
||||
Pixel = c0 * (c1/31). c0 Alpha retain
|
||||
*/
|
||||
inline u16 PixelMul16(const u16 c0, const u16 c1)
|
||||
{
|
||||
return (u16)(((((c0 & 0x7C00) * (c1 & 0x7C00)) & 0x3E000000) >> 15) |
|
||||
((((c0 & 0x03E0) * (c1 & 0x03E0)) & 0x000F8000) >> 10) |
|
||||
((((c0 & 0x001F) * (c1 & 0x001F)) & 0x000003E0) >> 5) |
|
||||
(c0 & 0x8000));
|
||||
}
|
||||
|
||||
/*
|
||||
Pixel = c0 * (c1/31).
|
||||
*/
|
||||
inline u16 PixelMul16_2(u16 c0, u16 c1)
|
||||
{
|
||||
return (u16)((((c0 & 0x7C00) * (c1 & 0x7C00)) & 0x3E000000) >> 15 |
|
||||
(((c0 & 0x03E0) * (c1 & 0x03E0)) & 0x000F8000) >> 10 |
|
||||
(((c0 & 0x001F) * (c1 & 0x001F)) & 0x000003E0) >> 5 |
|
||||
(c0 & c1 & 0x8000));
|
||||
}
|
||||
|
||||
/*
|
||||
Pixel = c0 * (c1/255). c0 Alpha Retain
|
||||
*/
|
||||
REALINLINE u32 PixelMul32(const u32 c0, const u32 c1)
|
||||
{
|
||||
return (c0 & 0xFF000000) |
|
||||
((((c0 & 0x00FF0000) >> 12) * ((c1 & 0x00FF0000) >> 12)) & 0x00FF0000) |
|
||||
((((c0 & 0x0000FF00) * (c1 & 0x0000FF00)) >> 16) & 0x0000FF00) |
|
||||
((((c0 & 0x000000FF) * (c1 & 0x000000FF)) >> 8) & 0x000000FF);
|
||||
}
|
||||
|
||||
/*
|
||||
Pixel = c0 * (c1/255).
|
||||
*/
|
||||
REALINLINE u32 PixelMul32_2(const u32 c0, const u32 c1)
|
||||
{
|
||||
return ((((c0 & 0xFF000000) >> 16) * ((c1 & 0xFF000000) >> 16)) & 0xFF000000) |
|
||||
((((c0 & 0x00FF0000) >> 12) * ((c1 & 0x00FF0000) >> 12)) & 0x00FF0000) |
|
||||
((((c0 & 0x0000FF00) * (c1 & 0x0000FF00)) >> 16) & 0x0000FF00) |
|
||||
((((c0 & 0x000000FF) * (c1 & 0x000000FF)) >> 8) & 0x000000FF);
|
||||
}
|
||||
|
||||
/*
|
||||
Pixel = clamp ( c0 + c1, 0, 255 )
|
||||
*/
|
||||
REALINLINE u32 PixelAdd32(const u32 c2, const u32 c1)
|
||||
{
|
||||
u32 sum = (c2 & 0x00FFFFFF) + (c1 & 0x00FFFFFF);
|
||||
u32 low_bits = (c2 ^ c1) & 0x00010101;
|
||||
s32 carries = (sum - low_bits) & 0x01010100;
|
||||
u32 modulo = sum - carries;
|
||||
u32 clamp = carries - (carries >> 8);
|
||||
return modulo | clamp;
|
||||
}
|
||||
|
||||
// 1 - Bit Alpha Blending
|
||||
inline u16 PixelBlend16(const u16 c2, const u16 c1)
|
||||
{
|
||||
u16 mask = ((c1 & 0x8000) >> 15) + 0x7fff;
|
||||
return (c2 & mask) | (c1 & ~mask);
|
||||
}
|
||||
/*!
|
||||
Pixel = dest * ( 1 - SourceAlpha ) + source * SourceAlpha (OpenGL blending)
|
||||
*/
|
||||
|
|
|
@ -101,8 +101,6 @@ video::IImage* SourceImageCache::getOrLoad(const std::string &name)
|
|||
|
||||
|
||||
/** Draw an image on top of another one with gamma-incorrect alpha compositing
|
||||
*
|
||||
* This exists because IImage::copyToWithAlpha() doesn't seem to always work.
|
||||
*
|
||||
* \tparam overlay If enabled, only modify pixels in dst which are fully opaque.
|
||||
* Defaults to false.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue