mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
LibSoftGPU: Remove OpenGL type for alpha blend factors
Replaces the GLenum used for configuring alpha blend factors in the SoftGPU device with out own enum.
This commit is contained in:
parent
40bd73bdef
commit
c720cd00db
3 changed files with 60 additions and 16 deletions
|
@ -1130,9 +1130,39 @@ void SoftwareGLContext::gl_blend_func(GLenum src_factor, GLenum dst_factor)
|
||||||
m_blend_source_factor = src_factor;
|
m_blend_source_factor = src_factor;
|
||||||
m_blend_destination_factor = dst_factor;
|
m_blend_destination_factor = dst_factor;
|
||||||
|
|
||||||
|
auto map_gl_blend_factor_to_device = [](GLenum factor) constexpr
|
||||||
|
{
|
||||||
|
switch (factor) {
|
||||||
|
case GL_ZERO:
|
||||||
|
return SoftGPU::BlendFactor::Zero;
|
||||||
|
case GL_ONE:
|
||||||
|
return SoftGPU::BlendFactor::One;
|
||||||
|
case GL_SRC_ALPHA:
|
||||||
|
return SoftGPU::BlendFactor::SrcAlpha;
|
||||||
|
case GL_ONE_MINUS_SRC_ALPHA:
|
||||||
|
return SoftGPU::BlendFactor::OneMinusSrcAlpha;
|
||||||
|
case GL_SRC_COLOR:
|
||||||
|
return SoftGPU::BlendFactor::SrcColor;
|
||||||
|
case GL_ONE_MINUS_SRC_COLOR:
|
||||||
|
return SoftGPU::BlendFactor::OneMinusSrcColor;
|
||||||
|
case GL_DST_ALPHA:
|
||||||
|
return SoftGPU::BlendFactor::DstAlpha;
|
||||||
|
case GL_ONE_MINUS_DST_ALPHA:
|
||||||
|
return SoftGPU::BlendFactor::OneMinusDstAlpha;
|
||||||
|
case GL_DST_COLOR:
|
||||||
|
return SoftGPU::BlendFactor::DstColor;
|
||||||
|
case GL_ONE_MINUS_DST_COLOR:
|
||||||
|
return SoftGPU::BlendFactor::OneMinusDstColor;
|
||||||
|
case GL_SRC_ALPHA_SATURATE:
|
||||||
|
return SoftGPU::BlendFactor::SrcAlphaSaturate;
|
||||||
|
default:
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
auto options = m_rasterizer.options();
|
auto options = m_rasterizer.options();
|
||||||
options.blend_source_factor = m_blend_source_factor;
|
options.blend_source_factor = map_gl_blend_factor_to_device(m_blend_source_factor);
|
||||||
options.blend_destination_factor = m_blend_destination_factor;
|
options.blend_destination_factor = map_gl_blend_factor_to_device(m_blend_destination_factor);
|
||||||
m_rasterizer.set_options(options);
|
m_rasterizer.set_options(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ static Gfx::IntRect scissor_box_to_window_coordinates(Gfx::IntRect const& scisso
|
||||||
return scissor_box.translated(0, window_rect.height() - 2 * scissor_box.y() - scissor_box.height());
|
return scissor_box.translated(0, window_rect.height() - 2 * scissor_box.y() - scissor_box.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr void setup_blend_factors(GLenum mode, FloatVector4& constant, float& src_alpha, float& dst_alpha, float& src_color, float& dst_color)
|
static constexpr void setup_blend_factors(BlendFactor mode, FloatVector4& constant, float& src_alpha, float& dst_alpha, float& src_color, float& dst_color)
|
||||||
{
|
{
|
||||||
constant = { 0.0f, 0.0f, 0.0f, 0.0f };
|
constant = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
src_alpha = 0;
|
src_alpha = 0;
|
||||||
|
@ -69,40 +69,40 @@ static constexpr void setup_blend_factors(GLenum mode, FloatVector4& constant, f
|
||||||
dst_color = 0;
|
dst_color = 0;
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case GL_ZERO:
|
case BlendFactor::Zero:
|
||||||
break;
|
break;
|
||||||
case GL_ONE:
|
case BlendFactor::One:
|
||||||
constant = { 1.0f, 1.0f, 1.0f, 1.0f };
|
constant = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
break;
|
break;
|
||||||
case GL_SRC_COLOR:
|
case BlendFactor::SrcColor:
|
||||||
src_color = 1;
|
src_color = 1;
|
||||||
break;
|
break;
|
||||||
case GL_ONE_MINUS_SRC_COLOR:
|
case BlendFactor::OneMinusSrcColor:
|
||||||
constant = { 1.0f, 1.0f, 1.0f, 1.0f };
|
constant = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
src_color = -1;
|
src_color = -1;
|
||||||
break;
|
break;
|
||||||
case GL_SRC_ALPHA:
|
case BlendFactor::SrcAlpha:
|
||||||
src_alpha = 1;
|
src_alpha = 1;
|
||||||
break;
|
break;
|
||||||
case GL_ONE_MINUS_SRC_ALPHA:
|
case BlendFactor::OneMinusSrcAlpha:
|
||||||
constant = { 1.0f, 1.0f, 1.0f, 1.0f };
|
constant = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
src_alpha = -1;
|
src_alpha = -1;
|
||||||
break;
|
break;
|
||||||
case GL_DST_ALPHA:
|
case BlendFactor::DstAlpha:
|
||||||
dst_alpha = 1;
|
dst_alpha = 1;
|
||||||
break;
|
break;
|
||||||
case GL_ONE_MINUS_DST_ALPHA:
|
case BlendFactor::OneMinusDstAlpha:
|
||||||
constant = { 1.0f, 1.0f, 1.0f, 1.0f };
|
constant = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
dst_alpha = -1;
|
dst_alpha = -1;
|
||||||
break;
|
break;
|
||||||
case GL_DST_COLOR:
|
case BlendFactor::DstColor:
|
||||||
dst_color = 1;
|
dst_color = 1;
|
||||||
break;
|
break;
|
||||||
case GL_ONE_MINUS_DST_COLOR:
|
case BlendFactor::OneMinusDstColor:
|
||||||
constant = { 1.0f, 1.0f, 1.0f, 1.0f };
|
constant = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
dst_color = -1;
|
dst_color = -1;
|
||||||
break;
|
break;
|
||||||
case GL_SRC_ALPHA_SATURATE:
|
case BlendFactor::SrcAlphaSaturate:
|
||||||
// FIXME: How do we implement this?
|
// FIXME: How do we implement this?
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -37,6 +37,20 @@ enum class AlphaTestFunction {
|
||||||
Greater,
|
Greater,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class BlendFactor {
|
||||||
|
Zero,
|
||||||
|
One,
|
||||||
|
SrcAlpha,
|
||||||
|
OneMinusSrcAlpha,
|
||||||
|
SrcColor,
|
||||||
|
OneMinusSrcColor,
|
||||||
|
DstAlpha,
|
||||||
|
OneMinusDstAlpha,
|
||||||
|
DstColor,
|
||||||
|
OneMinusDstColor,
|
||||||
|
SrcAlphaSaturate,
|
||||||
|
};
|
||||||
|
|
||||||
struct RasterizerOptions {
|
struct RasterizerOptions {
|
||||||
bool shade_smooth { true };
|
bool shade_smooth { true };
|
||||||
bool enable_depth_test { false };
|
bool enable_depth_test { false };
|
||||||
|
@ -45,8 +59,8 @@ struct RasterizerOptions {
|
||||||
AlphaTestFunction alpha_test_func { AlphaTestFunction::Always };
|
AlphaTestFunction alpha_test_func { AlphaTestFunction::Always };
|
||||||
float alpha_test_ref_value { 0 };
|
float alpha_test_ref_value { 0 };
|
||||||
bool enable_blending { false };
|
bool enable_blending { false };
|
||||||
GLenum blend_source_factor { GL_ONE };
|
BlendFactor blend_source_factor { BlendFactor::One };
|
||||||
GLenum blend_destination_factor { GL_ONE };
|
BlendFactor blend_destination_factor { BlendFactor::One };
|
||||||
u32 color_mask { 0xffffffff };
|
u32 color_mask { 0xffffffff };
|
||||||
float depth_min { 0 };
|
float depth_min { 0 };
|
||||||
float depth_max { 1 };
|
float depth_max { 1 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue