mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibGfx+LibSoftGPU: Add and use Vector.xy()
Also use `.xyz()` where appropriate.
This commit is contained in:
parent
439617cf6f
commit
d75135663b
Notes:
sideshowbarker
2024-07-17 17:50:18 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/d75135663b Pull-request: https://github.com/SerenityOS/serenity/pull/12911 Reviewed-by: https://github.com/ldm5180
2 changed files with 12 additions and 7 deletions
|
@ -201,7 +201,12 @@ public:
|
|||
return AK::sqrt(m_data[0] * m_data[0] + m_data[1] * m_data[1] + m_data[2] * m_data[2] + m_data[3] * m_data[3]);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr VectorN<3, T> xyz() const requires(N == 4)
|
||||
[[nodiscard]] constexpr VectorN<2, T> xy() const requires(N >= 3)
|
||||
{
|
||||
return VectorN<2, T>(x(), y());
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr VectorN<3, T> xyz() const requires(N >= 4)
|
||||
{
|
||||
return VectorN<3, T>(x(), y(), z());
|
||||
}
|
||||
|
|
|
@ -192,9 +192,9 @@ void Device::rasterize_triangle(const Triangle& triangle)
|
|||
Vertex const vertex2 = triangle.vertices[2];
|
||||
|
||||
// Calculate area of the triangle for later tests
|
||||
FloatVector2 const v0 { vertex0.window_coordinates.x(), vertex0.window_coordinates.y() };
|
||||
FloatVector2 const v1 { vertex1.window_coordinates.x(), vertex1.window_coordinates.y() };
|
||||
FloatVector2 const v2 { vertex2.window_coordinates.x(), vertex2.window_coordinates.y() };
|
||||
FloatVector2 const v0 = vertex0.window_coordinates.xy();
|
||||
FloatVector2 const v1 = vertex1.window_coordinates.xy();
|
||||
FloatVector2 const v2 = vertex2.window_coordinates.xy();
|
||||
|
||||
auto const area = edge_function(v0, v1, v2);
|
||||
auto const one_over_area = 1.0f / area;
|
||||
|
@ -608,7 +608,7 @@ static void generate_texture_coordinates(Vertex& vertex, RasterizerOptions const
|
|||
}
|
||||
case TexCoordGenerationMode::SphereMap: {
|
||||
auto const eye_unit = vertex.eye_coordinates.normalized();
|
||||
FloatVector3 const eye_unit_xyz = { eye_unit.x(), eye_unit.y(), eye_unit.z() };
|
||||
FloatVector3 const eye_unit_xyz = eye_unit.xyz();
|
||||
auto const normal = vertex.normal;
|
||||
auto reflection = eye_unit_xyz - normal * 2 * normal.dot(eye_unit_xyz);
|
||||
reflection.set_z(reflection.z() + 1);
|
||||
|
@ -617,7 +617,7 @@ static void generate_texture_coordinates(Vertex& vertex, RasterizerOptions const
|
|||
}
|
||||
case TexCoordGenerationMode::ReflectionMap: {
|
||||
auto const eye_unit = vertex.eye_coordinates.normalized();
|
||||
FloatVector3 const eye_unit_xyz = { eye_unit.x(), eye_unit.y(), eye_unit.z() };
|
||||
FloatVector3 const eye_unit_xyz = eye_unit.xyz();
|
||||
auto const normal = vertex.normal;
|
||||
auto reflection = eye_unit_xyz - normal * 2 * normal.dot(eye_unit_xyz);
|
||||
switch (config_index) {
|
||||
|
@ -995,7 +995,7 @@ ALWAYS_INLINE void Device::shade_fragments(PixelQuad& quad)
|
|||
// FIXME: implement GL_TEXTURE_1D, GL_TEXTURE_3D and GL_TEXTURE_CUBE_MAP
|
||||
auto const& sampler = m_samplers[i];
|
||||
|
||||
auto texel = sampler.sample_2d({ quad.texture_coordinates[i].x(), quad.texture_coordinates[i].y() });
|
||||
auto texel = sampler.sample_2d(quad.texture_coordinates[i].xy());
|
||||
INCREASE_STATISTICS_COUNTER(g_num_sampler_calls, 1);
|
||||
|
||||
// FIXME: Implement more blend modes
|
||||
|
|
Loading…
Reference in a new issue