11 using std::unique_ptr;
15 template<
typename Pixel>
25 [[nodiscard]]
unsigned getWidth()
const override;
26 [[nodiscard]]
unsigned getHeight()
const override;
38 std::vector<Pixel*> pool;
41 template<
typename Pixel>
54 template<
typename Pixel,
unsigned IN_WIDTH,
typename SCALE>
63 template<
typename Pixel>
72 template<
typename Pixel>
81 template<
typename Pixel>
90 template<
typename Pixel>
102 template<
typename Pixel>
106 : pixelOps(std::move(pixelOps_))
111 template<
typename Pixel>
114 for (
auto& p : pool) {
119 template<
typename Pixel>
122 return output.getWidth();
125 template<
typename Pixel>
128 return output.getHeight();
131 template<
typename Pixel>
135 Pixel* buf = pool.back();
139 unsigned size =
sizeof(
Pixel) * output.getWidth();
144 template<
typename Pixel>
148 return output.acquireLine(y);
151 template<
typename Pixel>
154 output.releaseLine(y, dstLine);
157 template<
typename Pixel>
160 Pixel* dstLine = output.acquireLine(y);
162 memset(dstLine, output.getWidth(), color);
163 output.releaseLine(y, dstLine);
169 template<
typename Pixel>
179 template<
typename Pixel>
182 Pixel* dstLine = this->releasePre(y, buf);
185 unsigned srcWidth = (dstWidth / 320) * inWidth;
186 unsigned srcOffset = (dstWidth - srcWidth) / 2;
188 zoom(buf + srcOffset, srcWidth, dstLine, dstWidth);
190 this->releasePost(y, dstLine);
196 template<
typename Pixel,
unsigned IN_WIDTH,
typename SCALE>
204 template<
typename Pixel,
unsigned IN_WIDTH,
typename SCALE>
207 Pixel* dstLine = this->releasePre(y, buf);
210 unsigned srcWidth = (dstWidth / 320) * IN_WIDTH;
211 unsigned srcOffset = (dstWidth - srcWidth) / 2;
213 scale(buf + srcOffset, dstLine, dstWidth);
215 this->releasePost(y, dstLine);
221 template<
typename Pixel>
226 out, std::move(pixelOps_))
233 template<
typename Pixel>
238 out, std::move(pixelOps_))
245 template<
typename Pixel>
250 out, std::move(pixelOps_))
257 template<
typename Pixel>
262 out, std::move(pixelOps_))
269 template<
typename Pixel>
277 return std::make_unique<DirectScalerOutput<Pixel>>(output);
279 return std::make_unique<StretchScalerOutput288<Pixel>>(
280 output, std::move(pixelOps));
282 return std::make_unique<StretchScalerOutput280<Pixel>>(
283 output, std::move(pixelOps));
285 return std::make_unique<StretchScalerOutput272<Pixel>>(
286 output, std::move(pixelOps));
288 return std::make_unique<StretchScalerOutput256<Pixel>>(
289 output, std::move(pixelOps));
291 return std::make_unique<StretchScalerOutput<Pixel>>(
292 output, std::move(pixelOps), inWidth);
A frame buffer where pixels can be written to.
StretchScalerOutput256(SDLOutputSurface &out, PixelOperations< Pixel > pixelOps)
StretchScalerOutput272(SDLOutputSurface &out, PixelOperations< Pixel > pixelOps)
StretchScalerOutput280(SDLOutputSurface &out, PixelOperations< Pixel > pixelOps)
StretchScalerOutput288(SDLOutputSurface &out, PixelOperations< Pixel > pixelOps)
unsigned getHeight() const override
void fillLine(unsigned y, Pixel color) override
Pixel * acquireLine(unsigned y) override
Pixel * releasePre(unsigned y, Pixel *buf)
StretchScalerOutputBase(SDLOutputSurface &out, PixelOperations< Pixel > pixelOps)
void releasePost(unsigned y, Pixel *dstLine)
~StretchScalerOutputBase() override
unsigned getWidth() const override
const PixelOperations< Pixel > pixelOps
StretchScalerOutputBase(const StretchScalerOutputBase &)=delete
StretchScalerOutputBase & operator=(const StretchScalerOutputBase &)=delete
StretchScalerOutputN(SDLOutputSurface &out, PixelOperations< Pixel > pixelOps)
void releaseLine(unsigned y, Pixel *buf) override
void releaseLine(unsigned y, Pixel *buf) override
StretchScalerOutput(SDLOutputSurface &out, PixelOperations< Pixel > pixelOps, unsigned inWidth)
Stretch (or zoom) a given input line to a wider output line.
constexpr mat4 scale(const vec3 &xyz)
void * mallocAligned(size_t alignment, size_t size)
This file implemented 3 utility functions:
size_t size(std::string_view utf8)
static std::unique_ptr< ScalerOutput< Pixel > > create(SDLOutputSurface &output, PixelOperations< Pixel > pixelOps, unsigned inWidth)