summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h
blob: e022a67c3fdf9260fea81c550808de06eb042fdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/ByteBuffer.h>
#include <LibGfx/Forward.h>
#include <LibWeb/HTML/HTMLElement.h>

namespace Web::HTML {

class HTMLCanvasElement final : public HTMLElement {
public:
    using WrapperType = Bindings::HTMLCanvasElementWrapper;

    HTMLCanvasElement(DOM::Document&, QualifiedName);
    virtual ~HTMLCanvasElement() override;

    const Gfx::Bitmap* bitmap() const { return m_bitmap; }
    Gfx::Bitmap* bitmap() { return m_bitmap; }
    bool create_bitmap();

    CanvasRenderingContext2D* get_context(String type);

    unsigned width() const;
    unsigned height() const;

    void set_width(unsigned);
    void set_height(unsigned);

    String to_data_url(const String& type, Optional<double> quality) const;

private:
    virtual RefPtr<Layout::Node> create_layout_node() override;

    RefPtr<Gfx::Bitmap> m_bitmap;
    RefPtr<CanvasRenderingContext2D> m_context;
};

}