diff --git a/modules/juce_graphics/geometry/juce_Rectangle.h b/modules/juce_graphics/geometry/juce_Rectangle.h index 4ac28f9784..5903d9f024 100644 --- a/modules/juce_graphics/geometry/juce_Rectangle.h +++ b/modules/juce_graphics/geometry/juce_Rectangle.h @@ -688,22 +688,12 @@ public: */ Rectangle getSmallestIntegerContainer() const noexcept { - return getSmallestIntegerContainerWithType(); - } + const int x1 = floorAsInt (pos.x); + const int y1 = floorAsInt (pos.y); + const int x2 = ceilAsInt (pos.x + w); + const int y2 = ceilAsInt (pos.y + h); - /** Returns the smallest integer-aligned rectangle that completely contains this one. - This is only relevent for floating-point rectangles, of course. - @see toFloat() - */ - template - Rectangle getSmallestIntegerContainerWithType() const noexcept - { - const IntType x1 = static_cast (std::floor (pos.x)); - const IntType y1 = static_cast (std::floor (pos.y)); - const IntType x2 = static_cast (std::ceil (pos.x + w)); - const IntType y2 = static_cast (std::ceil (pos.y + h)); - - return Rectangle (x1, y1, x2 - x1, y2 - y1); + return Rectangle (x1, y1, x2 - x1, y2 - y1); } /** Casts this rectangle to a Rectangle. @@ -828,6 +818,13 @@ private: void copyWithRounding (Rectangle& result) const noexcept { result = getSmallestIntegerContainer(); } void copyWithRounding (Rectangle& result) const noexcept { result = toFloat(); } void copyWithRounding (Rectangle& result) const noexcept { result = toDouble(); } + + static int floorAsInt (int n) noexcept { return n; } + static int floorAsInt (float n) noexcept { return (int) std::floor (n); } + static int floorAsInt (double n) noexcept { return (int) std::floor (n); } + static int ceilAsInt (int n) noexcept { return n; } + static int ceilAsInt (float n) noexcept { return (int) std::ceil (n); } + static int ceilAsInt (double n) noexcept { return (int) std::ceil (n); } };