mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-24 02:08:58 +00:00
LibWeb+LibGfx: Support alpha
in CanvasRenderingContext2D
This is implemented by these related changes: * The Skia alpha type 'Opaque' is selected for surfaces that were created with the intention of not having an alpha channel. Previously we were simply creating one with alpha. * Clearing now happens through Skia's `clear()` which always uses the source color's value for the result, instead of setting all values to 0. * CanvasRenderingContext2D selects a different clearing color based on the `alpha` context attribute's value.
This commit is contained in:
parent
fac0f82031
commit
35efd4d14b
Notes:
github-actions[bot]
2025-04-29 11:52:28 +00:00
Author: https://github.com/gmta
Commit: 35efd4d14b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4506
Reviewed-by: https://github.com/shannonbooth
7 changed files with 68 additions and 12 deletions
|
@ -40,6 +40,20 @@ constexpr SkColorType to_skia_color_type(Gfx::BitmapFormat format)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
constexpr SkAlphaType to_skia_alpha_type(Gfx::BitmapFormat format, Gfx::AlphaType alpha_type)
|
||||
{
|
||||
if (format == BitmapFormat::BGRx8888 || format == BitmapFormat::RGBx8888)
|
||||
return kOpaque_SkAlphaType;
|
||||
|
||||
switch (alpha_type) {
|
||||
case AlphaType::Premultiplied:
|
||||
return kPremul_SkAlphaType;
|
||||
case AlphaType::Unpremultiplied:
|
||||
return kUnpremul_SkAlphaType;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
constexpr SkRect to_skia_rect(auto const& rect)
|
||||
{
|
||||
return SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue