openMSX
ScalerFactory.cc
Go to the documentation of this file.
1 #include "ScalerFactory.hh"
2 #include "RenderSettings.hh"
3 #include "EnumSetting.hh"
4 #include "IntegerSetting.hh"
5 #include "Simple2xScaler.hh"
6 #include "Simple3xScaler.hh"
7 #include "SaI2xScaler.hh" // note: included even if MAX_SCALE_FACTOR == 1
8 #include "SaI3xScaler.hh"
9 #include "Scale2xScaler.hh"
10 #include "Scale3xScaler.hh"
11 #include "HQ2xScaler.hh"
12 #include "HQ3xScaler.hh"
13 #include "HQ2xLiteScaler.hh"
14 #include "HQ3xLiteScaler.hh"
15 #include "RGBTriplet3xScaler.hh"
16 #include "MLAAScaler.hh"
17 #include "Scaler1.hh"
18 #include "memory.hh"
19 #include "unreachable.hh"
20 #include "build-info.hh"
21 
22 using std::unique_ptr;
23 
24 namespace openmsx {
25 
26 template <class Pixel>
27 unique_ptr<Scaler<Pixel>> ScalerFactory<Pixel>::createScaler(
28  const PixelOperations<Pixel>& pixelOps, RenderSettings& renderSettings)
29 {
30  switch (renderSettings.getScaleFactor().getValue()) {
31 #if (MIN_SCALE_FACTOR <= 1) && (MAX_SCALE_FACTOR >= 1)
32  case 1:
33  return make_unique<Scaler1<Pixel>>(pixelOps);
34 #endif
35 #if (MIN_SCALE_FACTOR <= 2) && (MAX_SCALE_FACTOR >= 2)
36  case 2:
37  switch (renderSettings.getScaleAlgorithm().getValue()) {
39  return make_unique<Simple2xScaler<Pixel>>(
40  pixelOps, renderSettings);
42  return make_unique<SaI2xScaler<Pixel>>(pixelOps);
44  return make_unique<Scale2xScaler<Pixel>>(pixelOps);
46  return make_unique<HQ2xScaler<Pixel>>(pixelOps);
48  return make_unique<HQ2xLiteScaler<Pixel>>(pixelOps);
50  case RenderSettings::SCALER_TV: // fallback
51  return make_unique<Simple2xScaler<Pixel>>(
52  pixelOps, renderSettings);
54  return make_unique<MLAAScaler<Pixel>>(640, pixelOps);
55  default:
57  }
58 #endif
59 #if (MIN_SCALE_FACTOR <= 4) && (MAX_SCALE_FACTOR >= 3)
60  case 3:
61  case 4: // fallback
62  switch (renderSettings.getScaleAlgorithm().getValue()) {
64  return make_unique<Simple3xScaler<Pixel>>(
65  pixelOps, renderSettings);
67  return make_unique<SaI3xScaler<Pixel>>(pixelOps);
69  return make_unique<Scale3xScaler<Pixel>>(pixelOps);
71  return make_unique<HQ3xScaler<Pixel>>(pixelOps);
73  return make_unique<HQ3xLiteScaler<Pixel>>(pixelOps);
75  case RenderSettings::SCALER_TV: // fallback
76  return make_unique<RGBTriplet3xScaler<Pixel>>(
77  pixelOps, renderSettings);
79  return make_unique<MLAAScaler<Pixel>>(960, pixelOps);
80  default:
82  }
83 #endif
84  default:
86  }
87  return nullptr; // avoid warning
88 }
89 
90 // Force template instantiation.
91 #if HAVE_16BPP
92 template class ScalerFactory<word>;
93 #endif
94 #if HAVE_32BPP
95 template class ScalerFactory<unsigned>;
96 #endif
97 
98 } // namespace openmsx