mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-23 04:55:15 +00:00
LibGfx+LibWeb: Replace usages of Bitmap::fill() with Gfx::Painter
Let's always mutate a bitmap using painter, because Skia likely could do it faster than our own implementation.
This commit is contained in:
parent
f2d3f8bc42
commit
a499ece16c
Notes:
github-actions[bot]
2024-09-19 04:22:36 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/a499ece16ca Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1432 Reviewed-by: https://github.com/circl-lastname
2 changed files with 6 additions and 3 deletions
|
@ -16,6 +16,7 @@
|
|||
#include <AK/Try.h>
|
||||
#include <LibCompress/Lzw.h>
|
||||
#include <LibGfx/ImageFormats/GIFLoader.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
@ -159,7 +160,8 @@ static ErrorOr<void> decode_frame(GIFLoadingContext& context, size_t frame_index
|
|||
auto const previous_image_disposal_method = i > 0 ? context.images.at(i - 1)->disposal_method : GIFImageDescriptor::DisposalMethod::None;
|
||||
|
||||
if (i == 0) {
|
||||
context.frame_buffer->fill(Color::Transparent);
|
||||
auto painter = Gfx::Painter::create(*context.frame_buffer);
|
||||
painter->clear_rect(context.frame_buffer->rect().to_type<float>(), Color::Transparent);
|
||||
} else if (i > 0 && image->disposal_method == GIFImageDescriptor::DisposalMethod::RestorePrevious
|
||||
&& previous_image_disposal_method != GIFImageDescriptor::DisposalMethod::RestorePrevious) {
|
||||
// This marks the start of a run of frames that once disposed should be restored to the
|
||||
|
|
|
@ -385,8 +385,9 @@ void CanvasRenderingContext2D::reset_to_default_state()
|
|||
auto* bitmap = canvas_element().bitmap();
|
||||
|
||||
// 1. Clear canvas's bitmap to transparent black.
|
||||
if (bitmap)
|
||||
bitmap->fill(Gfx::Color::Transparent);
|
||||
if (bitmap) {
|
||||
painter()->clear_rect(bitmap->rect().to_type<float>(), Color::Transparent);
|
||||
}
|
||||
|
||||
// 2. Empty the list of subpaths in context's current default path.
|
||||
path().clear();
|
||||
|
|
Loading…
Add table
Reference in a new issue