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