mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:07:34 +00:00
Kernel: Make FrameBufferDevice::try_to_set_resolution() return KResult
This commit is contained in:
parent
21bfa02dd2
commit
4ffee78146
3 changed files with 6 additions and 10 deletions
|
@ -45,7 +45,7 @@ Console::Console(RefPtr<FrameBufferDevice> const& framebuffer_device)
|
|||
void Console::set_resolution(size_t width, size_t height, size_t)
|
||||
{
|
||||
auto did_set_resolution = m_framebuffer_device->try_to_set_resolution(width, height);
|
||||
VERIFY(did_set_resolution);
|
||||
VERIFY(!did_set_resolution.is_error());
|
||||
}
|
||||
|
||||
void Console::flush(size_t x, size_t y, size_t width, size_t height)
|
||||
|
|
|
@ -114,10 +114,10 @@ void FrameBufferDevice::flush_displayed_image(Protocol::Rect const& dirty_rect,
|
|||
m_gpu.flush_displayed_image(dirty_rect, buffer.resource_id);
|
||||
}
|
||||
|
||||
bool FrameBufferDevice::try_to_set_resolution(size_t width, size_t height)
|
||||
KResult FrameBufferDevice::try_to_set_resolution(size_t width, size_t height)
|
||||
{
|
||||
if (width > MAX_VIRTIOGPU_RESOLUTION_WIDTH || height > MAX_VIRTIOGPU_RESOLUTION_HEIGHT)
|
||||
return false;
|
||||
return EINVAL;
|
||||
|
||||
auto& info = display_info();
|
||||
|
||||
|
@ -130,10 +130,7 @@ bool FrameBufferDevice::try_to_set_resolution(size_t width, size_t height)
|
|||
.height = (u32)height,
|
||||
};
|
||||
|
||||
// FIXME: Would be nice to be able to return KResultOr here.
|
||||
if (auto result = create_framebuffer(); result.is_error())
|
||||
return false;
|
||||
return true;
|
||||
return create_framebuffer();
|
||||
}
|
||||
|
||||
void FrameBufferDevice::set_buffer(int buffer_index)
|
||||
|
@ -161,8 +158,7 @@ KResult FrameBufferDevice::ioctl(OpenFileDescription&, unsigned request, Userspa
|
|||
auto user_resolution = static_ptr_cast<FBResolution*>(arg);
|
||||
FBResolution resolution;
|
||||
TRY(copy_from_user(&resolution, user_resolution));
|
||||
if (!try_to_set_resolution(resolution.width, resolution.height))
|
||||
return EINVAL;
|
||||
TRY(try_to_set_resolution(resolution.width, resolution.height));
|
||||
resolution.pitch = pitch();
|
||||
return copy_to_user(user_resolution, &resolution);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
virtual void deactivate_writes();
|
||||
virtual void activate_writes();
|
||||
|
||||
bool try_to_set_resolution(size_t width, size_t height);
|
||||
KResult try_to_set_resolution(size_t width, size_t height);
|
||||
void clear_to_black(Buffer&);
|
||||
|
||||
size_t width() const { return display_info().rect.width; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue