summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-04-11 02:29:37 +0200
committerAndreas Kling <kling@serenityos.org>2022-04-11 02:29:37 +0200
commit88ef1bff389ef483222a92587cc610900ac6e1de (patch)
tree77254ed9305709feb8b04d1e9a553e426b9f7cf2 /Userland
parent57feb0f3ec55990cbe942f082e045fa45ee6c189 (diff)
downloadserenity-88ef1bff389ef483222a92587cc610900ac6e1de.zip
LibWeb: Add fast path for CRC2D.drawImage() with simple transform
If the transform is a simple translation, we don't need to run the big and slow transform rasterizer.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp
index 5ce9555a7f..80972ee7cf 100644
--- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp
+++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp
@@ -182,9 +182,10 @@ DOM::ExceptionOr<void> CanvasRenderingContext2D::draw_image(CanvasImageSource co
if (!painter)
return {};
- if (m_drawing_state.transform.is_identity()) {
- // There's no affine transformation to worry about, we can just call Gfx::Painter.
+ if (m_drawing_state.transform.is_identity_or_translation()) {
+ painter->translate(m_drawing_state.transform.e(), m_drawing_state.transform.f());
painter->draw_scaled_bitmap(destination_rect.to_rounded<int>(), *bitmap, source_rect, 1.0f, Gfx::Painter::ScalingMode::BilinearBlend);
+ painter->translate(-m_drawing_state.transform.e(), -m_drawing_state.transform.f());
} else {
// The context has an affine transform, we have to draw through it!