mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 08:50:37 +00:00
VirGLDemo: Make a factory function for Demo and propagate errors
This removes a measly 1 FIXME :))
This commit is contained in:
parent
d4f74d6c48
commit
c4f68bde57
Notes:
sideshowbarker
2024-07-17 10:08:28 +09:00
Author: https://github.com/Baitinq Commit: https://github.com/SerenityOS/serenity/commit/c4f68bde57 Pull-request: https://github.com/SerenityOS/serenity/pull/16505 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/linusg
3 changed files with 13 additions and 4 deletions
|
@ -316,7 +316,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_has_alpha_channel(false);
|
||||
window->set_alpha_hit_threshold(1);
|
||||
|
||||
auto demo = TRY(window->try_set_main_widget<Demo>());
|
||||
auto demo = TRY(Demo::create());
|
||||
window->set_main_widget(demo);
|
||||
|
||||
auto app_icon = GUI::Icon::default_icon("app-cube"sv);
|
||||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
|
|
|
@ -9,11 +9,18 @@
|
|||
|
||||
#include "Widget.h"
|
||||
|
||||
ErrorOr<NonnullRefPtr<Demo>> Demo::create()
|
||||
{
|
||||
auto demo = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Demo));
|
||||
|
||||
demo->m_bitmap = TRY(Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { DRAWTARGET_WIDTH, DRAWTARGET_HEIGHT }));
|
||||
demo->m_bitmap->fill(Gfx::Color::Black);
|
||||
|
||||
return demo;
|
||||
}
|
||||
|
||||
Demo::Demo()
|
||||
{
|
||||
m_bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { DRAWTARGET_WIDTH, DRAWTARGET_HEIGHT }).release_value_but_fixme_should_propagate_errors();
|
||||
m_bitmap->fill(Gfx::Color::Black);
|
||||
|
||||
m_cycles = 0;
|
||||
|
||||
stop_timer();
|
||||
|
|
|
@ -16,6 +16,7 @@ constexpr size_t DRAWTARGET_HEIGHT = 500;
|
|||
class Demo final : public GUI::Widget {
|
||||
C_OBJECT(Demo)
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<Demo>> create();
|
||||
virtual ~Demo() override;
|
||||
bool show_window_frame() const { return m_show_window_frame; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue