1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:58:11 +00:00

LibAccelGfx+LibWeb: Implement draw_scaled_bitmap()

Very basic implementation of command to paint bitmap. In the future we
should reuse loaded textures across repaints whenever it is possible.
This commit is contained in:
Aliaksandr Kalenik 2023-11-02 01:18:07 +01:00 committed by Andreas Kling
parent b7f8d7e357
commit aa6c008450
3 changed files with 110 additions and 2 deletions

View file

@ -36,9 +36,25 @@ CommandResult PaintingCommandExecutorGPU::fill_rect(Gfx::IntRect const& rect, Co
return CommandResult::Continue;
}
CommandResult PaintingCommandExecutorGPU::draw_scaled_bitmap(Gfx::IntRect const&, Gfx::Bitmap const&, Gfx::IntRect const&, float, Gfx::Painter::ScalingMode)
CommandResult PaintingCommandExecutorGPU::draw_scaled_bitmap(Gfx::IntRect const& dst_rect, Gfx::Bitmap const& bitmap, Gfx::IntRect const& src_rect, float, Gfx::Painter::ScalingMode scaling_mode)
{
// FIXME
// FIXME: We should avoid using Gfx::Painter specific enums in painting commands
AccelGfx::Painter::ScalingMode accel_scaling_mode;
switch (scaling_mode) {
case Gfx::Painter::ScalingMode::NearestNeighbor:
case Gfx::Painter::ScalingMode::BoxSampling:
case Gfx::Painter::ScalingMode::SmoothPixels:
case Gfx::Painter::ScalingMode::None:
accel_scaling_mode = AccelGfx::Painter::ScalingMode::NearestNeighbor;
break;
case Gfx::Painter::ScalingMode::BilinearBlend:
accel_scaling_mode = AccelGfx::Painter::ScalingMode::Bilinear;
break;
default:
VERIFY_NOT_REACHED();
}
painter().draw_scaled_bitmap(dst_rect, bitmap, src_rect, accel_scaling_mode);
return CommandResult::Continue;
}