refactor: Use default member initializers for JpegContext and PngContext (#1435)

**What is the goal of this PR?**

Replace verbose constructor initializer lists with in-class default
member initializers in JpegContext and PngContext

---

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**NO**_
This commit is contained in:
Zach Nelson
2026-04-08 10:44:10 +02:00
committed by jpirnay
parent 27e246cb22
commit 93f285d296
2 changed files with 33 additions and 80 deletions
@@ -20,60 +20,37 @@ namespace {
// The draw callback receives this via pDraw->pUser (set by setUserPointer()).
// The file I/O callbacks receive the FsFile* via pFile->fHandle (set by jpegOpen()).
struct JpegContext {
GfxRenderer* renderer;
const RenderConfig* config;
int screenWidth;
int screenHeight;
GfxRenderer* renderer{nullptr};
const RenderConfig* config{nullptr};
int screenWidth{0};
int screenHeight{0};
// Source dimensions after JPEGDEC's built-in scaling
int scaledSrcWidth;
int scaledSrcHeight;
int scaledSrcWidth{0};
int scaledSrcHeight{0};
// Final output dimensions
int dstWidth;
int dstHeight;
int dstWidth{0};
int dstHeight{0};
// Fine scale in 16.16 fixed-point (ESP32-C3 has no FPU)
int32_t fineScaleFP; // src -> dst mapping
int32_t invScaleFP; // dst -> src mapping
int32_t fineScaleFP{1 << 16}; // src -> dst mapping
int32_t invScaleFP{1 << 16}; // dst -> src mapping
PixelCache cache;
bool caching;
bool caching{false};
// See PngContext for the rationale: monochromeOutput requests a 1-bit Atkinson dither
// emitting only 0/3 so the BW DirectPixelWriter (`pixelValue < 3` rule) maps cleanly.
int oneBitDitherRow;
Atkinson1BitDitherer* atkinson1BitDitherer;
int oneBitDitherRow{-1};
Atkinson1BitDitherer* atkinson1BitDitherer{nullptr};
#ifdef ENABLE_IMAGE_DITHERING_EXTENSION
int currentDitherRow;
AtkinsonDitherer* atkinsonDitherer;
DiffusedBayerDitherer* diffusedBayerDitherer;
int currentDitherRow{-1};
AtkinsonDitherer* atkinsonDitherer{nullptr};
DiffusedBayerDitherer* diffusedBayerDitherer{nullptr};
#endif
JpegContext()
: renderer(nullptr),
config(nullptr),
screenWidth(0),
screenHeight(0),
scaledSrcWidth(0),
scaledSrcHeight(0),
dstWidth(0),
dstHeight(0),
fineScaleFP(1 << 16),
invScaleFP(1 << 16),
caching(false),
oneBitDitherRow(-1),
atkinson1BitDitherer(nullptr)
#ifdef ENABLE_IMAGE_DITHERING_EXTENSION
,
currentDitherRow(-1),
atkinsonDitherer(nullptr),
diffusedBayerDitherer(nullptr)
#endif
{
}
~JpegContext() {
delete atkinson1BitDitherer;
#ifdef ENABLE_IMAGE_DITHERING_EXTENSION