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