1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

LibAccelGfx: Premultiply linear gradient colors by alpha

With this change color blending for gradients matches CPU painter.
This commit is contained in:
Aliaksandr Kalenik 2023-11-29 12:53:49 +01:00 committed by Andreas Kling
parent be8952b89d
commit 707added91
3 changed files with 37 additions and 16 deletions

View file

@ -23,10 +23,23 @@ void set_viewport(Gfx::IntRect rect)
verify_no_error();
}
void enable_blending()
static GLenum to_gl_enum(BlendFactor factor)
{
switch (factor) {
case BlendFactor::SrcAlpha:
return GL_SRC_ALPHA;
case BlendFactor::One:
return GL_ONE;
case BlendFactor::OneMinusSrcAlpha:
return GL_ONE_MINUS_SRC_ALPHA;
}
VERIFY_NOT_REACHED();
}
void enable_blending(BlendFactor source, BlendFactor destination)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc(to_gl_enum(source), to_gl_enum(destination));
verify_no_error();
}