mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
LibGfx+LibWebView+UI: Store Gfx::Bitmap in RefPtr to const
This commit is contained in:
parent
d8b738a08d
commit
dac4110af4
8 changed files with 15 additions and 15 deletions
|
@ -333,7 +333,7 @@ static ARGB32 sub_argb32(ARGB32 a, ARGB32 b)
|
|||
.value();
|
||||
}
|
||||
|
||||
static ErrorOr<NonnullRefPtr<Bitmap>> maybe_write_color_indexing_transform(LittleEndianOutputBitStream& bit_stream, NonnullRefPtr<Bitmap> bitmap, IsOpaque& is_fully_opaque)
|
||||
static ErrorOr<NonnullRefPtr<Bitmap const>> maybe_write_color_indexing_transform(LittleEndianOutputBitStream& bit_stream, NonnullRefPtr<Bitmap const> bitmap, IsOpaque& is_fully_opaque)
|
||||
{
|
||||
// https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification#44_color_indexing_transform
|
||||
unsigned color_table_size = 0;
|
||||
|
@ -427,7 +427,7 @@ static ErrorOr<NonnullRefPtr<Bitmap>> maybe_write_color_indexing_transform(Littl
|
|||
return new_bitmap;
|
||||
}
|
||||
|
||||
static ErrorOr<void> write_VP8L_image_data(Stream& stream, NonnullRefPtr<Bitmap> bitmap, VP8LEncoderOptions const& options, IsOpaque& is_fully_opaque)
|
||||
static ErrorOr<void> write_VP8L_image_data(Stream& stream, NonnullRefPtr<Bitmap const> bitmap, VP8LEncoderOptions const& options, IsOpaque& is_fully_opaque)
|
||||
{
|
||||
LittleEndianOutputBitStream bit_stream { MaybeOwned<Stream>(stream) };
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ protected:
|
|||
struct SharedBitmap {
|
||||
i32 id { -1 };
|
||||
Web::DevicePixelSize last_painted_size;
|
||||
RefPtr<Gfx::Bitmap> bitmap;
|
||||
RefPtr<Gfx::Bitmap const> bitmap;
|
||||
};
|
||||
|
||||
struct ClientState {
|
||||
|
@ -289,7 +289,7 @@ protected:
|
|||
|
||||
RefPtr<Core::Timer> m_backing_store_shrink_timer;
|
||||
|
||||
RefPtr<Gfx::Bitmap> m_backup_bitmap;
|
||||
RefPtr<Gfx::Bitmap const> m_backup_bitmap;
|
||||
Web::DevicePixelSize m_backup_bitmap_size;
|
||||
|
||||
size_t m_crash_count = 0;
|
||||
|
|
|
@ -95,7 +95,7 @@ void WebViewBridge::enqueue_input_event(Web::KeyEvent event)
|
|||
|
||||
Optional<WebViewBridge::Paintable> WebViewBridge::paintable()
|
||||
{
|
||||
Gfx::Bitmap* bitmap = nullptr;
|
||||
Gfx::Bitmap const* bitmap = nullptr;
|
||||
Gfx::IntSize bitmap_size;
|
||||
|
||||
if (m_client_state.has_usable_bitmap) {
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
void enqueue_input_event(Web::KeyEvent);
|
||||
|
||||
struct Paintable {
|
||||
Gfx::Bitmap& bitmap;
|
||||
Gfx::Bitmap const& bitmap;
|
||||
Gfx::IntSize bitmap_size;
|
||||
};
|
||||
Optional<Paintable> paintable();
|
||||
|
|
|
@ -164,11 +164,11 @@ void HeadlessWebView::clear_content_filters()
|
|||
client().async_set_content_filters(m_client_state.page_index, {});
|
||||
}
|
||||
|
||||
NonnullRefPtr<Core::Promise<RefPtr<Gfx::Bitmap>>> HeadlessWebView::take_screenshot()
|
||||
NonnullRefPtr<Core::Promise<RefPtr<Gfx::Bitmap const>>> HeadlessWebView::take_screenshot()
|
||||
{
|
||||
VERIFY(!m_pending_screenshot);
|
||||
|
||||
m_pending_screenshot = Core::Promise<RefPtr<Gfx::Bitmap>>::construct();
|
||||
m_pending_screenshot = Core::Promise<RefPtr<Gfx::Bitmap const>>::construct();
|
||||
client().async_take_document_screenshot(0);
|
||||
|
||||
return *m_pending_screenshot;
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
|
||||
void clear_content_filters();
|
||||
|
||||
NonnullRefPtr<Core::Promise<RefPtr<Gfx::Bitmap>>> take_screenshot();
|
||||
NonnullRefPtr<Core::Promise<RefPtr<Gfx::Bitmap const>>> take_screenshot();
|
||||
|
||||
TestPromise& test_promise() { return *m_test_promise; }
|
||||
void on_test_complete(TestCompletion);
|
||||
|
@ -45,7 +45,7 @@ private:
|
|||
Core::AnonymousBuffer m_theme;
|
||||
Web::DevicePixelSize m_viewport_size;
|
||||
|
||||
RefPtr<Core::Promise<RefPtr<Gfx::Bitmap>>> m_pending_screenshot;
|
||||
RefPtr<Core::Promise<RefPtr<Gfx::Bitmap const>>> m_pending_screenshot;
|
||||
|
||||
NonnullRefPtr<TestPromise> m_test_promise;
|
||||
|
||||
|
|
|
@ -328,7 +328,7 @@ static void run_ref_test(HeadlessWebView& view, Test& test, URL::URL const& url,
|
|||
if (Application::the().dump_failed_ref_tests) {
|
||||
warnln("\033[33;1mRef test {} failed; dumping screenshots\033[0m", test.relative_path);
|
||||
|
||||
auto dump_screenshot = [&](Gfx::Bitmap& bitmap, StringView path) -> ErrorOr<void> {
|
||||
auto dump_screenshot = [&](Gfx::Bitmap const& bitmap, StringView path) -> ErrorOr<void> {
|
||||
auto screenshot_file = TRY(Core::File::open(path, Core::File::OpenMode::Write));
|
||||
auto encoded_data = TRY(Gfx::PNGWriter::encode(bitmap));
|
||||
TRY(screenshot_file->write_until_depleted(encoded_data));
|
||||
|
@ -375,13 +375,13 @@ static void run_ref_test(HeadlessWebView& view, Test& test, URL::URL const& url,
|
|||
} else {
|
||||
test.ref_test_expectation_type = RefTestExpectationType::Match;
|
||||
}
|
||||
view.take_screenshot()->when_resolved([&view, &test, on_test_complete = move(on_test_complete)](RefPtr<Gfx::Bitmap> screenshot) {
|
||||
view.take_screenshot()->when_resolved([&view, &test, on_test_complete = move(on_test_complete)](RefPtr<Gfx::Bitmap const> screenshot) {
|
||||
test.expectation_screenshot = move(screenshot);
|
||||
view.reset_zoom();
|
||||
on_test_complete();
|
||||
});
|
||||
} else {
|
||||
view.take_screenshot()->when_resolved([&view, &test](RefPtr<Gfx::Bitmap> screenshot) {
|
||||
view.take_screenshot()->when_resolved([&view, &test](RefPtr<Gfx::Bitmap const> screenshot) {
|
||||
test.actual_screenshot = move(screenshot);
|
||||
view.reset_zoom();
|
||||
view.debug_request("load-reference-page");
|
||||
|
|
|
@ -77,8 +77,8 @@ struct Test {
|
|||
|
||||
Optional<RefTestExpectationType> ref_test_expectation_type {};
|
||||
|
||||
RefPtr<Gfx::Bitmap> actual_screenshot {};
|
||||
RefPtr<Gfx::Bitmap> expectation_screenshot {};
|
||||
RefPtr<Gfx::Bitmap const> actual_screenshot {};
|
||||
RefPtr<Gfx::Bitmap const> expectation_screenshot {};
|
||||
};
|
||||
|
||||
struct TestCompletion {
|
||||
|
|
Loading…
Add table
Reference in a new issue