13template<std::
unsigned_
integral Pixel>
23 [[nodiscard]]
unsigned getWidth() const final;
24 [[nodiscard]]
unsigned getHeight() const final;
29 [[nodiscard]] std::span<Pixel>
acquireLine(
unsigned y)
final;
33 [[nodiscard]] std::span<Pixel>
releasePre(
unsigned y, std::span<Pixel> buf);
34 void releasePost(
unsigned y, std::span<Pixel> dstLine);
40 std::vector<Pixel*> pool;
43template<std::
unsigned_
integral Pixel>
50 void releaseLine(
unsigned y, std::span<Pixel> buf)
override;
56template<std::
unsigned_
integral Pixel,
unsigned IN_WIDTH,
typename SCALE>
65template<std::
unsigned_
integral Pixel>
74template<std::
unsigned_
integral Pixel>
83template<std::
unsigned_
integral Pixel>
92template<std::
unsigned_
integral Pixel>
104template<std::
unsigned_
integral Pixel>
108 : pixelOps(
std::move(pixelOps_))
113template<std::
unsigned_
integral Pixel>
116 for (
auto& p : pool) {
121template<std::
unsigned_
integral Pixel>
124 return output.getWidth();
127template<std::
unsigned_
integral Pixel>
130 return output.getHeight();
133template<std::
unsigned_
integral Pixel>
136 auto width = getWidth();
138 Pixel* buf = pool.back();
148template<std::
unsigned_
integral Pixel>
151 assert(buf.size() == getWidth());
152 pool.push_back(buf.data());
153 return output.acquireLine(y);
156template<std::
unsigned_
integral Pixel>
159 output.releaseLine(y, dstLine);
162template<std::
unsigned_
integral Pixel>
166 auto dstLine = output.acquireLine(y);
167 memset(dstLine, color);
168 output.releaseLine(y, dstLine);
174template<std::
unsigned_
integral Pixel>
184template<std::
unsigned_
integral Pixel>
187 auto dstLine = this->releasePre(y, buf);
188 auto dstWidth = dstLine.size();
190 auto srcWidth = (dstWidth / 320) * inWidth;
191 auto srcOffset = (dstWidth - srcWidth) / 2;
193 zoom(buf.subspan(srcOffset, srcWidth), dstLine);
195 this->releasePost(y, dstLine);
201template<std::
unsigned_
integral Pixel,
unsigned IN_WIDTH,
typename SCALE>
209template<std::
unsigned_
integral Pixel,
unsigned IN_WIDTH,
typename SCALE>
212 auto dstLine = this->releasePre(y, buf);
213 auto dstWidth = dstLine.size();
215 auto srcWidth = (dstWidth / 320) * IN_WIDTH;
216 auto srcOffset = (dstWidth - srcWidth) / 2;
217 SCALE
scale(this->pixelOps);
218 scale(buf.subspan(srcOffset, srcWidth), dstLine);
220 this->releasePost(y, dstLine);
226template<std::
unsigned_
integral Pixel>
231 out,
std::move(pixelOps_))
238template<std::
unsigned_
integral Pixel>
243 out,
std::move(pixelOps_))
250template<std::
unsigned_
integral Pixel>
255 out,
std::move(pixelOps_))
262template<std::
unsigned_
integral Pixel>
267 out,
std::move(pixelOps_))
274template<std::
unsigned_
integral Pixel>
282 return std::make_unique<DirectScalerOutput<Pixel>>(output);
284 return std::make_unique<StretchScalerOutput288<Pixel>>(
285 output, std::move(pixelOps));
287 return std::make_unique<StretchScalerOutput280<Pixel>>(
288 output, std::move(pixelOps));
290 return std::make_unique<StretchScalerOutput272<Pixel>>(
291 output, std::move(pixelOps));
293 return std::make_unique<StretchScalerOutput256<Pixel>>(
294 output, std::move(pixelOps));
296 return std::make_unique<StretchScalerOutput<Pixel>>(
297 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 final
StretchScalerOutputBase & operator=(const StretchScalerOutputBase &)=delete
void fillLine(unsigned y, Pixel color) override
unsigned getWidth() const final
StretchScalerOutputBase(SDLOutputSurface &out, PixelOperations< Pixel > pixelOps)
std::span< Pixel > acquireLine(unsigned y) final
~StretchScalerOutputBase() override
std::span< Pixel > releasePre(unsigned y, std::span< Pixel > buf)
void releasePost(unsigned y, std::span< Pixel > dstLine)
const PixelOperations< Pixel > pixelOps
StretchScalerOutputBase(const StretchScalerOutputBase &)=delete
StretchScalerOutputN(SDLOutputSurface &out, PixelOperations< Pixel > pixelOps)
void releaseLine(unsigned y, std::span< Pixel > buf) override
void releaseLine(unsigned y, std::span< 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)