Lumiera  0.pre.03
»edit your freedom«
zoom-window-test.cpp File Reference

Go to the source code of this file.

Description

unit test ZoomWindow_test The timeline uses the abstraction of an »Zoom Window« to define the scrolling and temporal scaling behaviour uniformly.

This unit test verifies this abstracted behaviour against the spec.

Fractional Seconds

A defining trait of the ZoomWindow implementation — as it stands 12/2022 — is the use of integer fractions for most scale and time interval calculations. The typical media handling operations often rely on denomination into a divisor defined scale — be it seconds divided by frame count (25fps), or be it audio samples like 1/96000 sec. And for presentation in the UI, these uneven fractions need to be broken down into a fixed pixel count, while the zoom factor can vary over several orders of magnitude. Integer fractions are a technically brilliant solution to cope with this challenge, without rounding discrepancies and accumulation of errors.

However, there is a catch: The way fractional arithmetics are handled leads to lots of multiplications, with the tendency to build up very large irreducible numbers, both in numerator and denominator. In worst case, numeric wrap-around can happen even at seemingly innocuous places. In an attempt to maintain the benefits of integer fraction arithmetics, for ZoomWindow a set of »coping strategies« was developed, to detect and control the cases when numbers „go south“. This approach is based on the observation that almost all everyday time calculations happen within a rather limited domain, while the extended time domain of years and centuries rather serves as a theoretical headroom. Thus it seems reasonable to benefit from integer fractions within this everyday range, under the condition that computations can be kept from derailing totally, when entering the extended domain.

To this end, we use the trick of introducing a minute numeric error, by re-quantising huge numbers into a scale with a smaller denominator. We introduce the notion of »toxic« numbers, which are defined by figures above 2^40 — irrespective if in numerator or in denominator. This rather arbitrary choice is based on the observation that most computation paths require to multiply with Time::SCALE (the µ-tick scale of 10^6), which together with 2^40 just fits into the value range of int64_t. Thus, into all crucial computation paths, a function detox() is wired, which remains inactive for regular values, but automatically sanitises extreme values. Together with the safety headroom built into the limits of the Lumiera lib::time::Time domain, this allows to handle all valid time points and represent even the largest possible lib::time::Duration::MAX.

A major part of this test is dedicated to covering those hypothetical corner cases and to ensure the defined behaviour can be maintained even under extreme conditions.

Definition in file zoom-window-test.cpp.

Classes

class  ZoomWindow_test
 

Functions

Time _t (int secs)
 
Time _t (int s, int div)
 
 LAUNCHER (ZoomWindow_test, "unit gui")
 Register this test class... More...
 

Namespaces

 stage
 Lumiera GTK UI implementation root.
 
 stage::model
 The Lumiera GTK-GUI uses a thin proxy layer data model on top of the actual "high-level-model", which lives in the Steam-Layer below.
 

Function Documentation

◆ LAUNCHER()

stage::model::test::LAUNCHER ( ZoomWindow_test  ,
"unit gui"   
)

Register this test class...