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 <array>
6#include <cstdint>
7#include <cstddef>
8#include <span>
9
10namespace openmsx {
11
15template<std::unsigned_integral Pixel> class Multiply;
16
17template<> class Multiply<uint16_t>
18{
19public:
20 explicit Multiply(const PixelOperations<uint16_t>& pixelOps);
21 void setFactor(unsigned f);
22 [[nodiscard]] inline uint16_t multiply(uint16_t p, unsigned factor) const;
23 [[nodiscard]] inline uint16_t multiply(uint16_t p) const;
24 [[nodiscard]] inline std::span<const uint16_t, 0x10000> getTable() const { return tab; }
25private:
26 const PixelOperations<uint16_t>& pixelOps;
27 unsigned factor = 0;
28 std::array<uint16_t, 0x10000> tab = {};
29};
30
31template<> class Multiply<uint32_t>
32{
33public:
34 explicit Multiply(const PixelOperations<uint32_t>& pixelOps);
35 void setFactor(unsigned f);
36 [[nodiscard]] inline uint32_t multiply(uint32_t p, unsigned factor) const;
37 [[nodiscard]] inline uint32_t multiply(uint32_t p) const;
38private:
39 unsigned factor;
40};
41
45template<std::unsigned_integral Pixel> class Scanline
46{
47public:
48 explicit Scanline(const PixelOperations<Pixel>& pixelOps);
49
58 void draw(std::span<const Pixel> src1, std::span<const Pixel> src2,
59 std::span<Pixel> dst, unsigned factor);
60
63 [[nodiscard]] Pixel darken(Pixel p, unsigned factor) const;
64
67 [[nodiscard]] Pixel darken(Pixel p1, Pixel p2, unsigned factor) const;
68
69private:
70 Multiply<Pixel> darkener;
72};
73
74} // namespace openmsx
75
76#endif
std::span< const uint16_t, 0x10000 > getTable() const
Definition: Scanline.hh:24
Helper class to perform 'pixel x scalar' calculations.
Definition: Scanline.hh:15
Helper class to draw scanlines.
Definition: Scanline.hh:46
void draw(std::span< const Pixel > src1, std::span< const Pixel > src2, std::span< Pixel > dst, unsigned factor)
Draws a scanline.
Definition: Scanline.cc:190
Pixel darken(Pixel p, unsigned factor) const
Darken one pixel.
Definition: Scanline.cc:211
Scanline(const PixelOperations< Pixel > &pixelOps)
Definition: Scanline.cc:183
This file implemented 3 utility functions:
Definition: Autofire.cc:9
uint32_t Pixel