summaryrefslogtreecommitdiff
path: root/Widgets/GraphicsBitmap.h
blob: fad84f15d4c73f8bc0e95226bdf9c2cc44899742 (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
44
45
46
47
48
#pragma once

#include "Color.h"
#include "Size.h"
#include <AK/Retainable.h>
#include <AK/RetainPtr.h>

#ifdef KERNEL
#include "Process.h"
#endif

class GraphicsBitmap : public Retainable<GraphicsBitmap> {
public:
#ifdef KERNEL
    static RetainPtr<GraphicsBitmap> create(Process&, const Size&);
#endif
    static RetainPtr<GraphicsBitmap> create_wrapper(const Size&, RGBA32*);
    ~GraphicsBitmap();

    RGBA32* scanline(int y);
    const RGBA32* scanline(int y) const;

    Size size() const { return m_size; }
    int width() const { return m_size.width(); }
    int height() const { return m_size.height(); }
    size_t pitch() const { return m_pitch; }

#ifdef KERNEL
    Region* client_region() { return m_client_region; }
    Region* server_region() { return m_server_region; }
#endif

private:
#ifdef KERNEL
    GraphicsBitmap(Process&, const Size&);
#endif
    GraphicsBitmap(const Size&, RGBA32*);

    Size m_size;
    RGBA32* m_data { nullptr };
    size_t m_pitch { 0 };

#ifdef KERNEL
    Process* m_client_process { nullptr };
    Region* m_client_region { nullptr };
    Region* m_server_region { nullptr };
#endif
};