mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-10 19:46:03 +00:00
LibGfx: Use NonnullRefPtr<Bitmap> for frame descriptors
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This makes it a bit easier to reason about where bitmaps should be available.
This commit is contained in:
parent
ff78746be1
commit
2687246808
Notes:
github-actions[bot]
2025-06-25 10:55:58 +00:00
Author: https://github.com/gmta
Commit: 2687246808
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5208
12 changed files with 35 additions and 42 deletions
|
@ -1547,7 +1547,7 @@ ErrorOr<ImageFrameDescriptor> BMPImageDecoderPlugin::frame(size_t index, Optiona
|
|||
TRY(decode_bmp_pixel_data(*m_context));
|
||||
|
||||
VERIFY(m_context->bitmap);
|
||||
return ImageFrameDescriptor { m_context->bitmap, 0 };
|
||||
return ImageFrameDescriptor { *m_context->bitmap, 0 };
|
||||
}
|
||||
|
||||
ErrorOr<Optional<ReadonlyBytes>> BMPImageDecoderPlugin::icc_data()
|
||||
|
|
|
@ -488,20 +488,20 @@ ErrorOr<ImageFrameDescriptor> GIFImageDecoderPlugin::frame(size_t index, Optiona
|
|||
m_context->error_state = GIFLoadingContext::ErrorState::FailedToDecodeAnyFrame;
|
||||
return result.release_error();
|
||||
}
|
||||
if (auto result = decode_frame(*m_context, 0); result.is_error()) {
|
||||
if (result = decode_frame(*m_context, 0); result.is_error()) {
|
||||
m_context->error_state = GIFLoadingContext::ErrorState::FailedToDecodeAnyFrame;
|
||||
return result.release_error();
|
||||
}
|
||||
m_context->error_state = GIFLoadingContext::ErrorState::FailedToDecodeAllFrames;
|
||||
}
|
||||
|
||||
ImageFrameDescriptor frame {};
|
||||
frame.image = TRY(m_context->frame_buffer->clone());
|
||||
frame.duration = m_context->images[index]->duration * 10;
|
||||
ImageFrameDescriptor frame {
|
||||
.image = TRY(m_context->frame_buffer->clone()),
|
||||
.duration = m_context->images[index]->duration * 10,
|
||||
};
|
||||
|
||||
if (frame.duration <= 10) {
|
||||
if (frame.duration <= 10)
|
||||
frame.duration = 100;
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
|
|
@ -171,10 +171,6 @@ ErrorOr<void> ICOImageDecoderPlugin::load_ico_bitmap(ICOLoadingContext& context)
|
|||
if (PNGImageDecoderPlugin::sniff({ context.data + desc.offset, desc.size })) {
|
||||
auto png_decoder = TRY(PNGImageDecoderPlugin::create({ context.data + desc.offset, desc.size }));
|
||||
auto decoded_png_frame = TRY(png_decoder->frame(0));
|
||||
if (!decoded_png_frame.image) {
|
||||
dbgln_if(ICO_DEBUG, "load_ico_bitmap: failed to load PNG encoded image index: {}", real_index);
|
||||
return Error::from_string_literal("Encoded image not null");
|
||||
}
|
||||
desc.bitmap = decoded_png_frame.image;
|
||||
return {};
|
||||
} else {
|
||||
|
@ -184,10 +180,6 @@ ErrorOr<void> ICOImageDecoderPlugin::load_ico_bitmap(ICOLoadingContext& context)
|
|||
// inside an ICO image.
|
||||
if (bmp_decoder->sniff_dib()) {
|
||||
auto decoded_bmp_frame = TRY(bmp_decoder->frame(0));
|
||||
if (!decoded_bmp_frame.image) {
|
||||
dbgln_if(ICO_DEBUG, "load_ico_bitmap: failed to load BMP encoded image index: {}", real_index);
|
||||
return Error::from_string_literal("Encoded image not null");
|
||||
}
|
||||
desc.bitmap = decoded_bmp_frame.image;
|
||||
} else {
|
||||
dbgln_if(ICO_DEBUG, "load_ico_bitmap: encoded image not supported at index: {}", real_index);
|
||||
|
@ -244,7 +236,7 @@ ErrorOr<ImageFrameDescriptor> ICOImageDecoderPlugin::frame(size_t index, Optiona
|
|||
}
|
||||
|
||||
VERIFY(m_context->images[m_context->largest_index].bitmap);
|
||||
return ImageFrameDescriptor { m_context->images[m_context->largest_index].bitmap, 0 };
|
||||
return ImageFrameDescriptor { *m_context->images[m_context->largest_index].bitmap, 0 };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ namespace Gfx {
|
|||
class Bitmap;
|
||||
|
||||
struct ImageFrameDescriptor {
|
||||
RefPtr<Bitmap> image;
|
||||
NonnullRefPtr<Bitmap> image;
|
||||
int duration { 0 };
|
||||
};
|
||||
|
||||
struct VectorImageFrameDescriptor {
|
||||
RefPtr<VectorGraphic> image;
|
||||
NonnullRefPtr<VectorGraphic> image;
|
||||
int duration { 0 };
|
||||
};
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ ErrorOr<ImageFrameDescriptor> JPEGImageDecoderPlugin::frame(size_t index, Option
|
|||
m_context->state = JPEGLoadingContext::State::Decoded;
|
||||
}
|
||||
|
||||
return ImageFrameDescriptor { m_context->rgb_bitmap, 0 };
|
||||
return ImageFrameDescriptor { *m_context->rgb_bitmap, 0 };
|
||||
}
|
||||
|
||||
Optional<Metadata const&> JPEGImageDecoderPlugin::metadata()
|
||||
|
|
|
@ -786,7 +786,7 @@ ErrorOr<ImageFrameDescriptor> TIFFImageDecoderPlugin::frame(size_t index, Option
|
|||
if (m_context->cmyk_bitmap())
|
||||
return ImageFrameDescriptor { TRY(m_context->cmyk_bitmap()->to_low_quality_rgb()), 0 };
|
||||
|
||||
return ImageFrameDescriptor { m_context->bitmap(), 0 };
|
||||
return ImageFrameDescriptor { *m_context->bitmap(), 0 };
|
||||
}
|
||||
|
||||
Optional<Metadata const&> TIFFImageDecoderPlugin::metadata()
|
||||
|
|
|
@ -571,13 +571,13 @@ ErrorOr<ImageFrameDescriptor> TinyVGImageDecoderPlugin::frame(size_t, Optional<I
|
|||
auto target_size = ideal_size.value_or(m_context->decoded_image->size());
|
||||
if (!m_context->bitmap || m_context->bitmap->size() != target_size)
|
||||
m_context->bitmap = TRY(m_context->decoded_image->bitmap(target_size));
|
||||
return ImageFrameDescriptor { m_context->bitmap };
|
||||
return ImageFrameDescriptor { *m_context->bitmap };
|
||||
}
|
||||
|
||||
ErrorOr<VectorImageFrameDescriptor> TinyVGImageDecoderPlugin::vector_frame(size_t)
|
||||
{
|
||||
TRY(ensure_fully_decoded(*m_context));
|
||||
return VectorImageFrameDescriptor { m_context->decoded_image, 0 };
|
||||
return VectorImageFrameDescriptor { *m_context->decoded_image, 0 };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue