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
96 template class SuperImposeScalerOutput<uint16_t>;
97 #endif
98 #if HAVE_32BPP
99 template class SuperImposeScalerOutput<uint32_t>;
100 #endif
101 
102 } // namespace openmsx
openmsx::SuperImposeScalerOutput::getHeight
unsigned getHeight() const override
Definition: SuperImposeScalerOutput.cc:30
MemoryOps.hh
openmsx::PixelOperations
Definition: PixelOperations.hh:144
openmsx::SuperImposeScalerOutput::acquireLine
Pixel * acquireLine(unsigned y) override
Definition: SuperImposeScalerOutput.cc:36
RawFrame.hh
openmsx::ScalerOutput
Definition: ScalerOutput.hh:7
openmsx::AlphaBlendLines
AlphaBlendLines functor Generate an output line that is a per-pixel-alpha-blend of the two input line...
Definition: LineScalers.hh:258
vla.hh
openmsx::Pixel
uint32_t Pixel
Definition: GLHQLiteScaler.cc:98
UNREACHABLE
#define UNREACHABLE
Definition: unreachable.hh:38
openmsx::SuperImposeScalerOutput
Definition: SuperImposeScalerOutput.hh:13
openmsx::MemoryOps::MemSet
Definition: MemoryOps.hh:8
openmsx::SuperImposeScalerOutput::getWidth
unsigned getWidth() const override
Definition: SuperImposeScalerOutput.cc:24
build-info.hh
ranges::copy
auto copy(InputRange &&range, OutputIter out)
Definition: ranges.hh:149
openmsx::RawFrame
A video frame as output by the VDP scanline conversion unit, before any postprocessing filters are ap...
Definition: RawFrame.hh:26
openmsx::Scale_1on1
Definition: LineScalers.hh:59
LineScalers.hh
openmsx::SuperImposeScalerOutput::releaseLine
void releaseLine(unsigned y, Pixel *buf) override
Definition: SuperImposeScalerOutput.cc:42
unreachable.hh
VLA_SSE_ALIGNED
#define VLA_SSE_ALIGNED(TYPE, NAME, LENGTH)
Definition: vla.hh:44
openmsx::SuperImposeScalerOutput::fillLine
void fillLine(unsigned y, Pixel color) override
Definition: SuperImposeScalerOutput.cc:53
SuperImposeScalerOutput.hh
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::SuperImposeScalerOutput::SuperImposeScalerOutput
SuperImposeScalerOutput(ScalerOutput< Pixel > &output, const RawFrame &superImpose_, const PixelOperations< Pixel > &pixelOps_)
Definition: SuperImposeScalerOutput.cc:13