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:
parent
8c9fa50c61
commit
f28047de73
Notes:
sideshowbarker
2024-07-17 18:23:16 +09:00
Author: https://github.com/gmta
Commit: f28047de73
Pull-request: https://github.com/SerenityOS/serenity/pull/12695
Reviewed-by: https://github.com/Quaker762 ✅
Reviewed-by: https://github.com/linusg ✅
Reviewed-by: https://github.com/sunverwerth ✅
1 changed files with 6 additions and 2 deletions
|
@ -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(),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue