Donner 0.5.0
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::svg::ImageComparisonParams Struct Reference

Parameters for controlling image comparison tests. More...

#include "donner/svg/renderer/tests/ImageComparisonTestFixture.h"

Collaboration diagram for donner::svg::ImageComparisonParams:
[legend]

Public Member Functions

ImageComparisonParamsdisableDebugSkpOnFailure ()
 Disables saving of .skp files on test failure.
ImageComparisonParamsincludeAntiAliasingDifferences ()
 Counts anti-aliased pixel differences as mismatches.
ImageComparisonParamsenableGoldenUpdateFromEnv ()
 Enables updating golden images based on an environment variable.
ImageComparisonParamssetCanvasSize (int width, int height)
 Sets a custom canvas size for rendering.
ImageComparisonParamsdisableBackend (RendererBackend backend, std::string_view reason=std::string_view())
 Disables one backend for this test case.
ImageComparisonParamsrequireFeature (RendererBackendFeature feature, std::string_view reason=std::string_view())
 Requires a renderer feature for this test case.
ImageComparisonParamswithSimpleTextMaxPixels (int pixels)
 Sets a separate maxMismatchedPixels for simple text (without HarfBuzz shaping).
ImageComparisonParamswithMaxPixelsDifferent (int pixels)
 Sets the max mismatched pixels for this test case.
ImageComparisonParamsonlyTextFull ()
 Skip this test entirely when running without HarfBuzz (simple text).
int effectiveMaxMismatchedPixels () const
 Returns the effective maxMismatchedPixels for the active text config.
bool shouldSkip () const
 Returns true if this test should be skipped for the active text config.

Static Public Member Functions

static ImageComparisonParams Skip ()
 Creates parameters to skip a test.
static ImageComparisonParams RenderOnly ()
 Creates parameters that render the test but skip pixel comparison.
static ImageComparisonParams WithThreshold (float threshold, int maxMismatchedPixels=kDefaultMismatchedPixels)
 Creates parameters with a specific threshold and maximum mismatched pixels.
static ImageComparisonParams WithGoldenOverride (std::string_view filename, float threshold=kDefaultThreshold)
 Creates parameters with an overridden golden image filename.

Public Attributes

float threshold = kDefaultThreshold
 Maximum allowed difference per pixel (0.0 to 1.0).
int maxMismatchedPixels = kDefaultMismatchedPixels
 Maximum number of pixels that can exceed the threshold.
int simpleTextMaxMismatchedPixels = -1
 Override for maxMismatchedPixels when running without HarfBuzz text shaping (DONNER_TEXT_FULL not defined). -1 means use maxMismatchedPixels for all configs.
bool skipSimpleText = false
 If true, skip this test when running without HarfBuzz (simple text).
bool includeAntiAliasing = false
 If true, count anti-aliased pixels as mismatches instead of suppressing them.
bool skip = false
 If true, skip this test case.
bool saveDebugSkpOnFailure = true
 If true, save a .skp file for debugging when a test fails.
bool updateGoldenFromEnv = false
 If true, allow updating golden images via an environment variable.
bool showTerminalPreview = true
 If true, emit a terminal preview grid when comparisons fail.
std::optional< Vector2icanvasSize
 Optional canvas size override, which determines the size of the rendered image.
std::string_view overrideGoldenFilename
 Optional filename to use for the golden image, overriding the default.
bool allowSkia = true
 If false, skip the test when the active backend is Skia.
bool allowTinySkia = true
 If false, skip the test when the active backend is TinySkia.
bool allowGeode = true
 If false, skip the test when the active backend is Geode.
uint32_t requiredFeatures = 0
 Bitmask of required backend features, built from RendererBackendFeatureMask.
std::string_view backendRequirementReason
 Human-readable reason used when backend restrictions cause a skip.
bool renderOnly = false
 If true, render but skip the pixel comparison. Used for tests where the output is implementation-defined or UB, but we still want to verify rendering stability.

Detailed Description

Parameters for controlling image comparison tests.

This struct allows customization of various aspects of the image comparison process, such as error thresholds, skipping tests, and overriding golden image filenames.

Member Function Documentation

◆ disableBackend()

ImageComparisonParams & donner::svg::ImageComparisonParams::disableBackend ( RendererBackend backend,
std::string_view reason = std::string_view() )
inline

Disables one backend for this test case.

Parameters
backendThe backend to disable.
reasonOptional human-readable skip reason.
Returns
Reference to this ImageComparisonParams object.

◆ disableDebugSkpOnFailure()

ImageComparisonParams & donner::svg::ImageComparisonParams::disableDebugSkpOnFailure ( )
inline

Disables saving of .skp files on test failure.

Returns
Reference to this ImageComparisonParams object.

◆ enableGoldenUpdateFromEnv()

ImageComparisonParams & donner::svg::ImageComparisonParams::enableGoldenUpdateFromEnv ( )
inline

Enables updating golden images based on an environment variable.

Returns
Reference to this ImageComparisonParams object.

◆ includeAntiAliasingDifferences()

ImageComparisonParams & donner::svg::ImageComparisonParams::includeAntiAliasingDifferences ( )
inline

Counts anti-aliased pixel differences as mismatches.

Returns
Reference to this ImageComparisonParams object.

◆ onlyTextFull()

ImageComparisonParams & donner::svg::ImageComparisonParams::onlyTextFull ( )
inline

Skip this test entirely when running without HarfBuzz (simple text).

Use this for tests that require text-full features (e.g., color emoji fonts that can't be loaded by stb_truetype at all).

Returns
Reference to this ImageComparisonParams object.

◆ RenderOnly()

ImageComparisonParams donner::svg::ImageComparisonParams::RenderOnly ( )
inlinestatic

Creates parameters that render the test but skip pixel comparison.

Used for tests where the output is implementation-defined or has expected variance, but we want to verify that rendering completes without crashing.

Returns
ImageComparisonParams configured for render-only mode.

◆ requireFeature()

ImageComparisonParams & donner::svg::ImageComparisonParams::requireFeature ( RendererBackendFeature feature,
std::string_view reason = std::string_view() )
inline

Requires a renderer feature for this test case.

Parameters
featureThe feature to require.
reasonOptional human-readable skip reason.
Returns
Reference to this ImageComparisonParams object.

◆ setCanvasSize()

ImageComparisonParams & donner::svg::ImageComparisonParams::setCanvasSize ( int width,
int height )
inline

Sets a custom canvas size for rendering.

Parameters
widthThe width of the canvas.
heightThe height of the canvas.
Returns
Reference to this ImageComparisonParams object.

◆ Skip()

ImageComparisonParams donner::svg::ImageComparisonParams::Skip ( )
inlinestatic

Creates parameters to skip a test.

Returns
ImageComparisonParams configured to skip.

◆ WithGoldenOverride()

ImageComparisonParams donner::svg::ImageComparisonParams::WithGoldenOverride ( std::string_view filename,
float threshold = kDefaultThreshold )
inlinestatic

Creates parameters with an overridden golden image filename.

Parameters
filenameThe filename to use for the golden image.
thresholdOptional per-pixel difference threshold to use with the override.
Returns
ImageComparisonParams configured with the golden override.

◆ withMaxPixelsDifferent()

ImageComparisonParams & donner::svg::ImageComparisonParams::withMaxPixelsDifferent ( int pixels)
inline

Sets the max mismatched pixels for this test case.

Parameters
pixelsThe max mismatched pixels.
Returns
Reference to this ImageComparisonParams object.

◆ withSimpleTextMaxPixels()

ImageComparisonParams & donner::svg::ImageComparisonParams::withSimpleTextMaxPixels ( int pixels)
inline

Sets a separate maxMismatchedPixels for simple text (without HarfBuzz shaping).

When DONNER_TEXT_FULL is not defined, this value is used instead of maxMismatchedPixels. This allows tests that require text shaping (combining marks, ligatures, etc.) to have a looser threshold for simple text while keeping a strict threshold for HarfBuzz.

Parameters
pixelsThe max mismatched pixels for simple text.
Returns
Reference to this ImageComparisonParams object.

◆ WithThreshold()

ImageComparisonParams donner::svg::ImageComparisonParams::WithThreshold ( float threshold,
int maxMismatchedPixels = kDefaultMismatchedPixels )
inlinestatic

Creates parameters with a specific threshold and maximum mismatched pixels.

Parameters
thresholdThe per-pixel difference threshold.
maxMismatchedPixelsThe maximum number of pixels allowed to mismatch.
Returns
ImageComparisonParams configured with the specified thresholds.

The documentation for this struct was generated from the following file: