| 1 |
#include "SuperImposedFrame.hh" |
| 2 |
|
| 3 |
#include "LineScalers.hh" |
| 4 |
|
| 5 |
#include "inplace_buffer.hh" |
| 6 |
|
| 7 |
#include <algorithm> |
| 8 |
#include <cstdint> |
| 9 |
|
| 10 |
namespace openmsx { |
| 11 |
|
| 12 |
using Pixel = uint32_t; |
| 13 |
|
| 14 |
void SuperImposedFrame::init( |
| 15 |
const FrameSource* top_, const FrameSource* bottom_) |
| 16 |
{ |
| 17 |
top = top_; |
| 18 |
bottom = bottom_; |
| 19 |
setHeight(std::max(top->getHeight(), bottom->getHeight())); |
| 20 |
} |
| 21 |
|
| 22 |
unsigned SuperImposedFrame::getLineWidth(unsigned line) const |
| 23 |
{ |
| 24 |
unsigned tNum = (getHeight() == top ->getHeight()) ? line : line / 2; |
| 25 |
unsigned bNum = (getHeight() == bottom->getHeight()) ? line : line / 2; |
| 26 |
unsigned tWidth = top ->getLineWidth(tNum); |
| 27 |
unsigned bWidth = bottom->getLineWidth(bNum); |
| 28 |
return std::max(tWidth, bWidth); |
| 29 |
} |
| 30 |
|
| 31 |
std::span<const FrameSource::Pixel> SuperImposedFrame::getUnscaledLine( |
| 32 |
unsigned line, std::span<Pixel> helpBuf) const |
| 33 |
{ |
| 34 |
unsigned tNum = (getHeight() == top ->getHeight()) ? line : line / 2; |
| 35 |
unsigned bNum = (getHeight() == bottom->getHeight()) ? line : line / 2; |
| 36 |
unsigned tWidth = top ->getLineWidth(tNum); |
| 37 |
unsigned bWidth = bottom->getLineWidth(bNum); |
| 38 |
auto width = std::min(std::max<size_t>(tWidth, bWidth), |
| 39 |
helpBuf.size()); |
| 40 |
|
| 41 |
auto tBuf = helpBuf.subspan(0, width); |
| 42 |
inplace_buffer<Pixel, 1280> bBuf(uninitialized_tag{}, width); |
| 43 |
auto tLine = top ->getLine(narrow<int>(tNum), tBuf); |
| 44 |
auto bLine = bottom->getLine(narrow<int>(bNum), bBuf); |
| 45 |
|
| 46 |
alphaBlendLines(tLine, bLine, tBuf); |
| 47 |
return tBuf; |
| 48 |
} |
| 49 |
|
| 50 |
} |