openMSX
ScalerFactory.cc
Go to the documentation of this file.
1#include "ScalerFactory.hh"
2#include "RenderSettings.hh"
3#include "Simple2xScaler.hh"
4#include "Simple3xScaler.hh"
5#include "SaI2xScaler.hh" // note: included even if MAX_SCALE_FACTOR == 1
6#include "SaI3xScaler.hh"
7#include "Scale2xScaler.hh"
8#include "Scale3xScaler.hh"
9#include "HQ2xScaler.hh"
10#include "HQ3xScaler.hh"
11#include "HQ2xLiteScaler.hh"
12#include "HQ3xLiteScaler.hh"
13#include "RGBTriplet3xScaler.hh"
14#include "MLAAScaler.hh"
15#include "Scaler1.hh"
16#include "unreachable.hh"
17#include "build-info.hh"
18#include <cstdint>
19#include <memory>
20
21namespace openmsx {
22
23template<std::unsigned_integral Pixel>
24std::unique_ptr<Scaler<Pixel>> ScalerFactory<Pixel>::createScaler(
25 const PixelOperations<Pixel>& pixelOps, RenderSettings& renderSettings)
26{
27 switch (renderSettings.getScaleFactor()) {
28#if (MIN_SCALE_FACTOR <= 1) && (MAX_SCALE_FACTOR >= 1)
29 case 1:
30 return std::make_unique<Scaler1<Pixel>>(pixelOps);
31#endif
32#if (MIN_SCALE_FACTOR <= 2) && (MAX_SCALE_FACTOR >= 2)
33 case 2:
34 switch (renderSettings.getScaleAlgorithm()) {
36 return std::make_unique<Simple2xScaler<Pixel>>(
37 pixelOps, renderSettings);
39 return std::make_unique<SaI2xScaler<Pixel>>(pixelOps);
41 return std::make_unique<Scale2xScaler<Pixel>>(pixelOps);
43 return std::make_unique<HQ2xScaler<Pixel>>(pixelOps);
45 return std::make_unique<HQ2xLiteScaler<Pixel>>(pixelOps);
47 case RenderSettings::SCALER_TV: // fallback
48 return std::make_unique<Simple2xScaler<Pixel>>(
49 pixelOps, renderSettings);
51 return std::make_unique<MLAAScaler<Pixel>>(640, pixelOps);
52 default:
54 }
55#endif
56#if (MIN_SCALE_FACTOR <= 4) && (MAX_SCALE_FACTOR >= 3)
57 case 3:
58 case 4: // fallback
59 switch (renderSettings.getScaleAlgorithm()) {
61 return std::make_unique<Simple3xScaler<Pixel>>(
62 pixelOps, renderSettings);
64 return std::make_unique<SaI3xScaler<Pixel>>(pixelOps);
66 return std::make_unique<Scale3xScaler<Pixel>>(pixelOps);
68 return std::make_unique<HQ3xScaler<Pixel>>(pixelOps);
70 return std::make_unique<HQ3xLiteScaler<Pixel>>(pixelOps);
72 case RenderSettings::SCALER_TV: // fallback
73 return std::make_unique<RGBTriplet3xScaler<Pixel>>(
74 pixelOps, renderSettings);
76 return std::make_unique<MLAAScaler<Pixel>>(960, pixelOps);
77 default:
79 }
80#endif
81 default:
83 }
84 return nullptr; // avoid warning
85}
86
87// Force template instantiation.
88#if HAVE_16BPP
89template class ScalerFactory<uint16_t>;
90#endif
91#if HAVE_32BPP
92template class ScalerFactory<uint32_t>;
93#endif
94
95} // namespace openmsx
Class containing all settings for renderers.
ScaleAlgorithm getScaleAlgorithm() const
The current scaling algorithm.
Abstract base class for scalers.
static std::unique_ptr< Scaler< Pixel > > createScaler(const PixelOperations< Pixel > &pixelOps, RenderSettings &renderSettings)
Instantiates a Scaler.
This file implemented 3 utility functions:
Definition: Autofire.cc:9
#define UNREACHABLE
Definition: unreachable.hh:38