openMSX
Scanline.hh
Go to the documentation of this file.
1 #ifndef SCANLINE_HH
2 #define SCANLINE_HH
3 
4 #include "PixelOperations.hh"
5 #include <cstdint>
6 #include <cstddef>
7 
8 namespace openmsx {
9 
13 template<std::unsigned_integral Pixel> class Multiply;
14 
15 template<> class Multiply<uint16_t>
16 {
17 public:
18  explicit Multiply(const PixelOperations<uint16_t>& pixelOps);
19  void setFactor(unsigned f);
20  [[nodiscard]] inline uint16_t multiply(uint16_t p, unsigned factor) const;
21  [[nodiscard]] inline uint16_t multiply(uint16_t p) const;
22  [[nodiscard]] inline const uint16_t* getTable() const;
23 private:
24  const PixelOperations<uint16_t>& pixelOps;
25  unsigned factor;
26  uint16_t tab[0x10000];
27 };
28 
29 template<> class Multiply<uint32_t>
30 {
31 public:
32  explicit Multiply(const PixelOperations<uint32_t>& pixelOps);
33  void setFactor(unsigned f);
34  [[nodiscard]] inline uint32_t multiply(uint32_t p, unsigned factor) const;
35  [[nodiscard]] inline uint32_t multiply(uint32_t p) const;
36  [[nodiscard]] const uint32_t* getTable() const;
37 private:
38  unsigned factor;
39 };
40 
44 template<std::unsigned_integral Pixel> class Scanline
45 {
46 public:
47  explicit Scanline(const PixelOperations<Pixel>& pixelOps);
48 
58  void draw(const Pixel* src1, const Pixel* src2, Pixel* dst,
59  unsigned factor, size_t width);
60 
63  [[nodiscard]] Pixel darken(Pixel p, unsigned factor) const;
64 
67  [[nodiscard]] Pixel darken(Pixel p1, Pixel p2, unsigned factor) const;
68 
69 private:
70  Multiply<Pixel> darkener;
71  PixelOperations<Pixel> pixelOps;
72 };
73 
74 } // namespace openmsx
75 
76 #endif
Helper class to perform 'pixel x scalar' calculations.
Definition: Scanline.hh:13
Helper class to draw scanlines.
Definition: Scanline.hh:45
Pixel darken(Pixel p, unsigned factor) const
Darken one pixel.
Definition: Scanline.cc:218
void draw(const Pixel *src1, const Pixel *src2, Pixel *dst, unsigned factor, size_t width)
Draws a scanline.
Definition: Scanline.cc:201
Scanline(const PixelOperations< Pixel > &pixelOps)
Definition: Scanline.cc:194
This file implemented 3 utility functions:
Definition: Autofire.cc:9
uint32_t Pixel