mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Implement support for drawing with CanvasPattern
We already had the API, but drawing to the canvas was not affected by any created CanvasPattern. This moves CanvasPatternPaintStyle to LibGfx so we don't have to reach into LibWeb, and implements the plumbing to let Skia use images as a fill pattern.
This commit is contained in:
parent
9753b8e62c
commit
62ae4e878f
Notes:
github-actions[bot]
2025-10-23 12:21:23 +00:00
Author: https://github.com/gmta
Commit: 62ae4e878f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6548
Reviewed-by: https://github.com/tcl3 ✅
20 changed files with 237 additions and 167 deletions
|
|
@ -14,11 +14,30 @@ void ImageProvider::did_update_alt_text(ImageBox& layout_node)
|
|||
layout_node.dom_node_did_update_alt_text({});
|
||||
}
|
||||
|
||||
Optional<CSSPixelSize> ImageProvider::intrinsic_size() const
|
||||
{
|
||||
auto width = intrinsic_width();
|
||||
auto height = intrinsic_height();
|
||||
if (!width.has_value() || !height.has_value())
|
||||
return {};
|
||||
|
||||
return CSSPixelSize { *width, *height };
|
||||
}
|
||||
|
||||
RefPtr<Gfx::ImmutableBitmap> ImageProvider::current_image_bitmap() const
|
||||
{
|
||||
int w = intrinsic_width().value_or({}).to_int();
|
||||
int h = intrinsic_height().value_or({}).to_int();
|
||||
return current_image_bitmap_sized({ w, h });
|
||||
return current_image_bitmap_sized(intrinsic_size().value_or({}).to_type<int>());
|
||||
}
|
||||
|
||||
RefPtr<Gfx::ImmutableBitmap> ImageProvider::default_image_bitmap() const
|
||||
{
|
||||
return default_image_bitmap_sized(intrinsic_size().value_or({}).to_type<int>());
|
||||
}
|
||||
|
||||
RefPtr<Gfx::ImmutableBitmap> ImageProvider::default_image_bitmap_sized(Gfx::IntSize size) const
|
||||
{
|
||||
// Defer to the current image by default.
|
||||
return current_image_bitmap_sized(size);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue