openMSX
SuperImposedFrame.cc
Go to the documentation of this file.
2#include "LineScalers.hh"
3#include "vla.hh"
4#include <algorithm>
5#include <cstdint>
6
7namespace openmsx {
8
9using Pixel = uint32_t;
10
12 const FrameSource* top_, const FrameSource* bottom_)
13{
14 top = top_;
15 bottom = bottom_;
16 setHeight(std::max(top->getHeight(), bottom->getHeight()));
17}
18
19unsigned SuperImposedFrame::getLineWidth(unsigned line) const
20{
21 unsigned tNum = (getHeight() == top ->getHeight()) ? line : line / 2;
22 unsigned bNum = (getHeight() == bottom->getHeight()) ? line : line / 2;
23 unsigned tWidth = top ->getLineWidth(tNum);
24 unsigned bWidth = bottom->getLineWidth(bNum);
25 return std::max(tWidth, bWidth);
26}
27
29 unsigned line, unsigned& width, void* buf, unsigned bufWidth) const
30{
31 unsigned tNum = (getHeight() == top ->getHeight()) ? line : line / 2;
32 unsigned bNum = (getHeight() == bottom->getHeight()) ? line : line / 2;
33 unsigned tWidth = top ->getLineWidth(tNum);
34 unsigned bWidth = bottom->getLineWidth(bNum);
35 width = std::max(tWidth, bWidth); // as wide as the widest source
36 width = std::min(width, bufWidth); // but no wider than the output buffer
37
38 auto tBuf = std::span{static_cast<Pixel*>(buf), width};
39 VLA_SSE_ALIGNED(Pixel, bBuf, width);
40 auto tLine = top ->getLine(tNum, tBuf);
41 auto bLine = bottom->getLine(bNum, bBuf);
42
43 alphaBlendLines(tLine, bLine, tBuf); // possibly tLine == tBuf
44 return tBuf.data();
45}
46
47} // namespace openmsx
Interface for getting lines from a video frame.
std::span< const Pixel > getLine(int line, std::span< Pixel > buf) const
Gets a pointer to the pixels of the given line number.
virtual unsigned getLineWidth(unsigned line) const =0
Gets the number of display pixels on the given line.
void setHeight(unsigned height_)
unsigned getHeight() const
Gets the number of lines in this frame.
const void * getLineInfo(unsigned line, unsigned &width, void *buf, unsigned bufWidth) const override
Abstract implementation of getLinePtr().
void init(const FrameSource *top, const FrameSource *bottom)
unsigned getLineWidth(unsigned line) const override
Gets the number of display pixels on the given line.
This file implemented 3 utility functions:
Definition Autofire.cc:9
void alphaBlendLines(std::span< const Pixel > in1, std::span< const Pixel > in2, std::span< Pixel > out)
AlphaBlendLines functor Generate an output line that is a per-pixel-alpha-blend of the two input line...
CharacterConverter::Pixel Pixel
#define VLA_SSE_ALIGNED(TYPE, NAME, LENGTH)
Definition vla.hh:50