|
@@ -626,40 +626,19 @@ void Painter::draw_tiled_bitmap(const IntRect& a_dst_rect, const Gfx::Bitmap& so
|
|
|
ASSERT_NOT_REACHED();
|
|
|
}
|
|
|
|
|
|
-void Painter::blit_offset(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& src_rect, const IntPoint& offset)
|
|
|
+void Painter::blit_offset(const IntPoint& a_position, const Gfx::Bitmap& source, const IntRect& a_src_rect, const IntPoint& offset)
|
|
|
{
|
|
|
- ASSERT(scale() == 1); // FIXME: Add scaling support.
|
|
|
-
|
|
|
- auto dst_rect = IntRect(position, src_rect.size()).translated(translation());
|
|
|
- auto clipped_rect = dst_rect.intersected(clip_rect());
|
|
|
- if (clipped_rect.is_empty())
|
|
|
- return;
|
|
|
- const int first_row = (clipped_rect.top() - dst_rect.top());
|
|
|
- const int last_row = (clipped_rect.bottom() - dst_rect.top());
|
|
|
- const int first_column = (clipped_rect.left() - dst_rect.left());
|
|
|
- RGBA32* dst = m_target->scanline(clipped_rect.y()) + clipped_rect.x();
|
|
|
- const size_t dst_skip = m_target->pitch() / sizeof(RGBA32);
|
|
|
-
|
|
|
- if (source.format() == BitmapFormat::RGB32 || source.format() == BitmapFormat::RGBA32) {
|
|
|
- int x_start = first_column + src_rect.left();
|
|
|
- for (int row = first_row; row <= last_row; ++row) {
|
|
|
- int sr = row - offset.y() + src_rect.top();
|
|
|
- if (sr >= source.size().height() || sr < 0) {
|
|
|
- dst += dst_skip;
|
|
|
- continue;
|
|
|
- }
|
|
|
- const RGBA32* sl = source.scanline(sr);
|
|
|
- for (int x = x_start; x < clipped_rect.width() + x_start; ++x) {
|
|
|
- int sx = x - offset.x();
|
|
|
- if (sx < source.size().width() && sx >= 0)
|
|
|
- dst[x - x_start] = sl[sx];
|
|
|
- }
|
|
|
- dst += dst_skip;
|
|
|
- }
|
|
|
- return;
|
|
|
+ auto src_rect = IntRect { a_src_rect.location() - offset, a_src_rect.size() };
|
|
|
+ auto position = a_position;
|
|
|
+ if (src_rect.x() < 0) {
|
|
|
+ position.set_x(position.x() - src_rect.x());
|
|
|
+ src_rect.set_x(0);
|
|
|
}
|
|
|
-
|
|
|
- ASSERT_NOT_REACHED();
|
|
|
+ if (src_rect.y() < 0) {
|
|
|
+ position.set_y(position.y() - src_rect.y());
|
|
|
+ src_rect.set_y(0);
|
|
|
+ }
|
|
|
+ blit(position, source, src_rect);
|
|
|
}
|
|
|
|
|
|
void Painter::blit_with_alpha(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& a_src_rect)
|