summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2022-02-06 02:31:11 +0100
committerLinus Groh <mail@linusgroh.de>2022-02-22 23:48:59 +0000
commitc3273e94929d0dc42cf8165bdc0b8f853335ed21 (patch)
treee1ab5d63585410dc0ecd3299d2aa2203c127605c /Userland/Libraries
parentf28047de73957d2c381fcfda80ef6935542fc1e7 (diff)
downloadserenity-c3273e94929d0dc42cf8165bdc0b8f853335ed21.zip
LibSoftGPU: Clean up some conditionals in `Device`
No functional changes.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibSoftGPU/Device.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/Userland/Libraries/LibSoftGPU/Device.cpp b/Userland/Libraries/LibSoftGPU/Device.cpp
index 2f6835492b..1bdba4a651 100644
--- a/Userland/Libraries/LibSoftGPU/Device.cpp
+++ b/Userland/Libraries/LibSoftGPU/Device.cpp
@@ -511,11 +511,10 @@ void Device::rasterize_triangle(const Triangle& triangle)
quad.barycentrics = quad.barycentrics * w_coordinates * interpolated_w;
// FIXME: make this more generic. We want to interpolate more than just color and uv
- if (m_options.shade_smooth) {
+ if (m_options.shade_smooth)
quad.vertex_color = interpolate(expand4(vertex0.color), expand4(vertex1.color), expand4(vertex2.color), quad.barycentrics);
- } else {
+ else
quad.vertex_color = expand4(vertex0.color);
- }
for (size_t i = 0; i < NUM_SAMPLERS; ++i)
quad.texture_coordinates[i] = interpolate(expand4(vertex0.tex_coords[i]), expand4(vertex1.tex_coords[i]), expand4(vertex2.tex_coords[i]), quad.barycentrics);
@@ -531,16 +530,15 @@ void Device::rasterize_triangle(const Triangle& triangle)
shade_fragments(quad);
- if (m_options.enable_alpha_test && m_options.alpha_test_func != AlphaTestFunction::Always && !test_alpha(quad)) {
+ if (m_options.enable_alpha_test && m_options.alpha_test_func != AlphaTestFunction::Always && !test_alpha(quad))
continue;
- }
// Write to depth buffer
if (m_options.enable_depth_test && m_options.enable_depth_write)
store4_masked(quad.depth, depth_ptrs[0], depth_ptrs[1], depth_ptrs[2], depth_ptrs[3], quad.mask);
// We will not update the color buffer at all
- if (!m_options.color_mask || !m_options.enable_color_write)
+ if ((m_options.color_mask == 0) || !m_options.enable_color_write)
continue;
ColorType* color_ptrs[4] = {
@@ -1251,18 +1249,16 @@ void Device::set_light_model_params(const LightModelParameters& lighting_model)
ColorType Device::get_color_buffer_pixel(int x, int y)
{
// FIXME: Reading individual pixels is very slow, rewrite this to transfer whole blocks
- if (x < 0 || y < 0 || x >= m_frame_buffer->rect().width() || y >= m_frame_buffer->rect().height())
+ if (!m_frame_buffer->rect().contains(x, y))
return 0;
-
return m_frame_buffer->color_buffer()->scanline(y)[x];
}
DepthType Device::get_depthbuffer_value(int x, int y)
{
// FIXME: Reading individual pixels is very slow, rewrite this to transfer whole blocks
- if (x < 0 || y < 0 || x >= m_frame_buffer->rect().width() || y >= m_frame_buffer->rect().height())
+ if (!m_frame_buffer->rect().contains(x, y))
return 1.0f;
-
return m_frame_buffer->depth_buffer()->scanline(y)[x];
}