1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00

LibSoftGPU: Round rasterization position to nearest integer

This fixes the issue where e.g. `299.97` would be cast to an integer
value of `299`, whereas the pixel's center would lie at `299.5` and
would then erroneously be excluded.
This commit is contained in:
Jelle Raaijmakers 2022-02-03 16:45:08 +01:00 committed by Linus Groh
parent 8c9fa50c61
commit f28047de73
Notes: sideshowbarker 2024-07-17 18:23:16 +09:00

View file

@ -18,6 +18,7 @@
#include <LibSoftGPU/Device.h>
#include <LibSoftGPU/PixelQuad.h>
#include <LibSoftGPU/SIMD.h>
#include <math.h>
namespace SoftGPU {
@ -1335,9 +1336,12 @@ void Device::set_raster_position(FloatVector4 const& position, FloatMatrix4x4 co
Gfx::IntRect Device::get_rasterization_rect_of_size(Gfx::IntSize size)
{
// Round the X and Y floating point coordinates to the nearest integer; OpenGL 1.5 spec:
// "Any fragments whose centers lie inside of this rectangle (or on its bottom or left
// boundaries) are produced in correspondence with this particular group of elements."
return {
static_cast<int>(m_raster_position.window_coordinates.x()),
static_cast<int>(m_raster_position.window_coordinates.y()),
static_cast<int>(roundf(m_raster_position.window_coordinates.x())),
static_cast<int>(roundf(m_raster_position.window_coordinates.y())),
size.width(),
size.height(),
};