gems/animated_geometry.h: increase value range

The value range supported by the 'Animated_rect' utility is constrained
to 2^11 by the used 32-bit integer type. The interpolation is performed
on fixpoint numbers with a fractional precision of 10 bits. The
non-linear interpolation as performed by the 'Lazy_value' utility
involves squaring the values. Hence, the interpolated integral values
must not exceed 2^11 (2*11 bits for the square plus 10 bit for the
fractional part require 32 bits). This range is too small for
high-resolution displays. Hence this patch replaces the 32-bit integer
type by a 64-bit integer type.

Fixes #3627
This commit is contained in:
Norman Feske 2020-02-04 11:46:18 +01:00 committed by Christian Helmuth
parent 46c5a90ba1
commit 60f5d0e34a
1 changed files with 5 additions and 3 deletions

View File

@ -36,11 +36,13 @@ class Genode::Animated_rect : private Animator::Item, Noncopyable
Rect _rect { };
using Lazy_value = ::Lazy_value<int64_t>;
struct Animated_point
{
bool _initial = true;
Lazy_value<int> _x { }, _y { };
Lazy_value _x { }, _y { };
void animate() { _x.animate(); _y.animate(); }
@ -49,8 +51,8 @@ class Genode::Animated_rect : private Animator::Item, Noncopyable
void move_to(Point p, Steps steps)
{
if (_initial) {
_x = Lazy_value<int>(p.x() << 10);
_y = Lazy_value<int>(p.y() << 10);
_x = Lazy_value(p.x() << 10);
_y = Lazy_value(p.y() << 10);
_initial = false;
} else {
_x.dst(p.x() << 10, steps.value);