openMSX
SuperImposedFrame.cc
Go to the documentation of this file.
2
3#include "LineScalers.hh"
4
5#include "vla.hh"
6
7#include <algorithm>
8#include <cstdint>
9
10namespace openmsx {
11
12using Pixel = uint32_t;
13
15 const FrameSource* top_, const FrameSource* bottom_)
16{
17 top = top_;
18 bottom = bottom_;
19 setHeight(std::max(top->getHeight(), bottom->getHeight()));
20}
21
22unsigned 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
31std::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), // as wide as the widest source
39 helpBuf.size()); // but no wider than the output buffer
40
41 auto tBuf = std::span{helpBuf.data(), width};
42 VLA_SSE_ALIGNED(Pixel, bBuf, 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); // possibly tLine == tBuf
47 return tBuf;
48}
49
50} // 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.
void init(const FrameSource *top, const FrameSource *bottom)
unsigned getLineWidth(unsigned line) const override
Gets the number of display pixels on the given line.
std::span< const Pixel > getUnscaledLine(unsigned line, std::span< Pixel > helpBuf) const override
Get a specific line, with the 'native' line-width.
This file implemented 3 utility functions:
Definition Autofire.cc:11
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