/src/serenity/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <LibWeb/Forward.h> |
10 | | #include <LibWeb/HTML/HTMLCanvasElement.h> |
11 | | #include <LibWeb/HTML/HTMLImageElement.h> |
12 | | #include <LibWeb/HTML/HTMLVideoElement.h> |
13 | | #include <LibWeb/WebIDL/ExceptionOr.h> |
14 | | |
15 | | namespace Web::HTML { |
16 | | |
17 | | // https://html.spec.whatwg.org/multipage/canvas.html#canvasimagesource |
18 | | // NOTE: This is the Variant created by the IDL wrapper generator, and needs to be updated accordingly. |
19 | | using CanvasImageSource = Variant<JS::Handle<HTMLImageElement>, JS::Handle<SVG::SVGImageElement>, JS::Handle<HTMLCanvasElement>, JS::Handle<ImageBitmap>, JS::Handle<HTMLVideoElement>>; |
20 | | |
21 | | // https://html.spec.whatwg.org/multipage/canvas.html#canvasdrawimage |
22 | | class CanvasDrawImage { |
23 | | public: |
24 | 0 | virtual ~CanvasDrawImage() = default; |
25 | | |
26 | | WebIDL::ExceptionOr<void> draw_image(CanvasImageSource const&, float destination_x, float destination_y); |
27 | | WebIDL::ExceptionOr<void> draw_image(CanvasImageSource const&, float destination_x, float destination_y, float destination_width, float destination_height); |
28 | | WebIDL::ExceptionOr<void> draw_image(CanvasImageSource const&, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height); |
29 | | |
30 | | virtual WebIDL::ExceptionOr<void> draw_image_internal(CanvasImageSource const&, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height) = 0; |
31 | | |
32 | | protected: |
33 | 0 | CanvasDrawImage() = default; |
34 | | }; |
35 | | |
36 | | } |