openMSX
SuperImposeScalerOutput.cc
Go to the documentation of this file.
2 #include "RawFrame.hh"
3 #include "LineScalers.hh"
4 #include "MemoryOps.hh"
5 #include "unreachable.hh"
6 #include "vla.hh"
7 #include "build-info.hh"
8 #include <cstdint>
9 
10 namespace openmsx {
11 
12 template<typename Pixel>
14  ScalerOutput<Pixel>& output_,
15  const RawFrame& superImpose_,
16  const PixelOperations<Pixel>& pixelOps_)
17  : output(output_)
18  , superImpose(superImpose_)
19  , pixelOps(pixelOps_)
20 {
21 }
22 
23 template<typename Pixel>
25 {
26  return output.getWidth();
27 }
28 
29 template<typename Pixel>
31 {
32  return output.getHeight();
33 }
34 
35 template<typename Pixel>
37 {
38  return output.acquireLine(y);
39 }
40 
41 template<typename Pixel>
43 {
44  unsigned width = output.getWidth();
45  VLA_SSE_ALIGNED(Pixel, buf2, width);
46  auto* srcLine = getSrcLine(y, buf2);
47  AlphaBlendLines<Pixel> alphaBlend(pixelOps);
48  alphaBlend(buf, srcLine, buf, width);
49  output.releaseLine(y, buf);
50 }
51 
52 template<typename Pixel>
54 {
55  auto* dstLine = output.acquireLine(y);
56  unsigned width = output.getWidth();
57  if (pixelOps.isFullyOpaque(color)) {
59  memset(dstLine, width, color);
60  } else {
61  auto* srcLine = getSrcLine(y, dstLine);
62  if (pixelOps.isFullyTransparent(color)) {
63  // optimization: use destination as work buffer, in case
64  // that buffer got used, we don't need to make a copy
65  // anymore
66  if (srcLine != dstLine) {
68  copy(srcLine, dstLine, width);
69  }
70  } else {
71  AlphaBlendLines<Pixel> alphaBlend(pixelOps);
72  alphaBlend(color, srcLine, dstLine, width); // possibly srcLine == dstLine
73  }
74  }
75  output.releaseLine(y, dstLine);
76 }
77 
78 template<typename Pixel>
80 {
81  unsigned width = output.getWidth();
82  if (width == 320) {
83  return superImpose.getLinePtr320_240(y, buf);
84  } else if (width == 640) {
85  return superImpose.getLinePtr640_480(y, buf);
86  } else if (width == 960) {
87  return superImpose.getLinePtr960_720(y, buf);
88  } else {
89  UNREACHABLE; return nullptr;
90  }
91 }
92 
93 
94 // Force template instantiation.
95 #if HAVE_16BPP
97 #endif
98 #if HAVE_32BPP
100 #endif
101 
102 } // namespace openmsx
auto copy(InputRange &&range, OutputIter out)
Definition: ranges.hh:149
uint32_t Pixel
A video frame as output by the VDP scanline conversion unit, before any postprocessing filters are ap...
Definition: RawFrame.hh:25
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
SuperImposeScalerOutput(ScalerOutput< Pixel > &output, const RawFrame &superImpose_, const PixelOperations< Pixel > &pixelOps_)
const Pixel * getLinePtr640_480(unsigned line, Pixel *buf) const
Get a pointer to a given line in this frame, the frame is scaled to 640x480 pixels.
Definition: FrameSource.cc:38
void fillLine(unsigned y, Pixel color) override
const Pixel * getLinePtr320_240(unsigned line, Pixel *buf) const
Get a pointer to a given line in this frame, the frame is scaled to 320x240 pixels.
Definition: FrameSource.cc:21
AlphaBlendLines functor Generate an output line that is a per-pixel-alpha-blend of the two input line...
Definition: LineScalers.hh:256
const Pixel * getLinePtr960_720(unsigned line, Pixel *buf) const
Get a pointer to a given line in this frame, the frame is scaled to 960x720 pixels.
Definition: FrameSource.cc:49
void releaseLine(unsigned y, Pixel *buf) override
#define VLA_SSE_ALIGNED(TYPE, NAME, LENGTH)
Definition: vla.hh:44
Pixel * acquireLine(unsigned y) override
#define UNREACHABLE
Definition: unreachable.hh:38