From 779618e45d4571bb6a4866aa2e398780f4b4da5d Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Wed, 6 Feb 2013 01:45:38 +0100 Subject: Fix integer overflow for bigger textures --- src/FbTk/TextureRender.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc index 8c7087f..4623417 100644 --- a/src/FbTk/TextureRender.cc +++ b/src/FbTk/TextureRender.cc @@ -111,6 +111,10 @@ struct Vec2 { } }; +template int sign(T val) { + return (T(0) < val) - (val < T(0)); +} + std::vector& getGradientBuffer(size_t size) { static std::vector buffer; if (buffer.size() < size) @@ -469,10 +473,10 @@ void renderRectangleGradient(bool interlaced, // check, if the point (x, y) is left or right of the vectors // 'a' and 'b'. if the point is on the same side for both 'a' and - // 'b' (a.cross() is equal to b.cross()) then use the y_gradient, + // 'b' (a.cross() is equal to b.cross()) then use the x_gradient, // otherwise use y_gradient - if ((a.cross(x, y) * b.cross(x, b.y + y)) < 0) { + if (sign(a.cross(x, y)) * sign(b.cross(x, b.y + y)) < 0) { rgba[i] = x_gradient[x]; } else { rgba[i] = y_gradient[y]; -- cgit v0.11.2