openMSX
RawFrame.cc
Go to the documentation of this file.
1#include "RawFrame.hh"
2#include "narrow.hh"
3#include <cstdint>
4
5namespace openmsx {
6
7RawFrame::RawFrame(unsigned maxWidth_, unsigned height_)
8 : lineWidths(height_)
9 , maxWidth(maxWidth_)
10 , pitch(narrow<unsigned>(((sizeof(Pixel) * maxWidth) + 63) & ~63))
11{
12 setHeight(height_);
13
14 // Allocate memory, make sure each line starts at a 64 byte boundary:
15 // - SSE instructions need 16 byte aligned data
16 // - cache line size on many CPUs is 64 bytes
17 data.resize(size_t(pitch) * height_);
18
19 maxWidth = pitch / sizeof(Pixel); // adjust maxWidth
20
21 // Start with a black frame.
23 for (auto line : xrange(height_)) {
24 setBlank(line, static_cast<uint32_t>(0));
25 }
26}
27
28unsigned RawFrame::getLineWidth(unsigned line) const
29{
30 assert(line < getHeight());
31 return lineWidths[line];
32}
33
35 unsigned line, unsigned& width,
36 void* /*buf*/, unsigned /*bufWidth*/) const
37{
38 assert(line < getHeight());
39 width = lineWidths[line];
40 return data.data() + line * size_t(pitch);
41}
42
44{
45 return true;
46}
47
48} // namespace openmsx
void setHeight(unsigned height_)
void init(FieldType fieldType_)
(Re)initialize an existing FrameSource.
unsigned getHeight() const
Gets the number of lines in this frame.
@ FIELD_NONINTERLACED
Interlacing is off for this frame.
void resize(size_t size)
Grow or shrink the memory block.
Definition MemBuffer.hh:111
const T * data() const
Returns pointer to the start of the memory buffer.
Definition MemBuffer.hh:81
unsigned getLineWidth(unsigned line) const override
Gets the number of display pixels on the given line.
Definition RawFrame.cc:28
RawFrame(unsigned maxWidth, unsigned height)
Definition RawFrame.cc:7
void setBlank(unsigned line, Pixel color)
Definition RawFrame.hh:39
bool hasContiguousStorage() const override
Returns true when two consecutive rows are also consecutive in memory.
Definition RawFrame.cc:43
const void * getLineInfo(unsigned line, unsigned &width, void *buf, unsigned bufWidth) const override
Abstract implementation of getLinePtr().
Definition RawFrame.cc:34
This file implemented 3 utility functions:
Definition Autofire.cc:9
constexpr To narrow(From from) noexcept
Definition narrow.hh:37
constexpr auto xrange(T e)
Definition xrange.hh:132