blob: ec36b53d0f1c7c9fdd2de4c9988d9b66e33264c0 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#pragma once
#include "Color.h"
#include "Rect.h"
#include "Size.h"
#include <AK/Retainable.h>
#include <AK/RetainPtr.h>
#include <AK/AKString.h>
class Region;
class GraphicsBitmap : public Retainable<GraphicsBitmap> {
public:
static RetainPtr<GraphicsBitmap> create(const Size&);
static RetainPtr<GraphicsBitmap> create_wrapper(const Size&, RGBA32*);
static RetainPtr<GraphicsBitmap> load_from_file(const String& path, const Size&);
static RetainPtr<GraphicsBitmap> create_with_shared_buffer(int shared_buffer_id, const Size&, RGBA32* buffer = nullptr);
~GraphicsBitmap();
RGBA32* scanline(int y);
const RGBA32* scanline(int y) const;
Rect rect() const { return { {}, m_size }; }
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* server_region() { return m_server_region; }
#endif
int shared_buffer_id() const { return m_shared_buffer_id; }
private:
#ifdef KERNEL
GraphicsBitmap(const Size&);
#endif
GraphicsBitmap(const Size&, RGBA32*);
GraphicsBitmap(int shared_buffer_id, const Size&, RGBA32*);
Size m_size;
RGBA32* m_data { nullptr };
size_t m_pitch { 0 };
bool m_mmaped { false };
int m_shared_buffer_id { -1 };
#ifdef KERNEL
Region* m_server_region { nullptr };
#endif
};
inline RGBA32* GraphicsBitmap::scanline(int y)
{
return reinterpret_cast<RGBA32*>((((byte*)m_data) + (y * m_pitch)));
}
inline const RGBA32* GraphicsBitmap::scanline(int y) const
{
return reinterpret_cast<const RGBA32*>((((const byte*)m_data) + (y * m_pitch)));
}
|