TRX/lib/ddraw/Blitter.hpp

60 lines
1.1 KiB
C++
Raw Normal View History

2021-11-12 20:03:04 +01:00
#pragma once
2021-11-14 23:59:19 +01:00
#include <algorithm>
2021-11-12 20:03:04 +01:00
#include <cstdint>
#include <vector>
namespace glrage {
namespace ddraw {
class Blitter
{
public:
struct Rect
{
int32_t left, top, right, bottom;
int32_t width()
{
return std::abs(right - left);
}
int32_t height()
{
return std::abs(bottom - top);
}
bool operator==(const Rect& r)
{
return left == r.left && top == r.top && right == r.right &&
bottom == r.bottom;
}
};
struct Image
{
int32_t width;
int32_t height;
int32_t depth;
std::vector<uint8_t>& buffer;
uint8_t& operator()(int32_t x, int32_t y, int32_t z)
{
return buffer[(y * width + x) * depth + z];
}
bool operator==(const Image& i)
{
return width == i.width && height == i.height && depth == i.depth;
}
};
static void blit(Image& srcImg, Rect& srcRect, Image dstImg, Rect& dstRect);
private:
static const int32_t m_ratioBias = 16;
};
} // namespace ddraw
} // namespace glrage