CanvasDrawImage.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/Forward.h>
  8. #include <LibWeb/HTML/HTMLCanvasElement.h>
  9. #include <LibWeb/HTML/HTMLImageElement.h>
  10. #include <LibWeb/HTML/HTMLVideoElement.h>
  11. #include <LibWeb/WebIDL/ExceptionOr.h>
  12. namespace Web::HTML {
  13. // https://html.spec.whatwg.org/multipage/canvas.html#canvasimagesource
  14. // NOTE: This is the Variant created by the IDL wrapper generator, and needs to be updated accordingly.
  15. using CanvasImageSource = Variant<GC::Root<HTMLImageElement>, GC::Root<SVG::SVGImageElement>, GC::Root<HTMLCanvasElement>, GC::Root<ImageBitmap>, GC::Root<HTMLVideoElement>>;
  16. // https://html.spec.whatwg.org/multipage/canvas.html#canvasdrawimage
  17. class CanvasDrawImage {
  18. public:
  19. virtual ~CanvasDrawImage() = default;
  20. WebIDL::ExceptionOr<void> draw_image(CanvasImageSource const&, float destination_x, float destination_y);
  21. WebIDL::ExceptionOr<void> draw_image(CanvasImageSource const&, float destination_x, float destination_y, float destination_width, float destination_height);
  22. 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);
  23. 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;
  24. protected:
  25. CanvasDrawImage() = default;
  26. };
  27. }