2019-01-09 02:06:04 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-01-10 05:36:32 +01:00
|
|
|
#include "Color.h"
|
2019-01-24 23:40:12 +01:00
|
|
|
#include "Rect.h"
|
2019-01-09 02:06:04 +01:00
|
|
|
#include "Size.h"
|
|
|
|
|
#include <AK/Retainable.h>
|
|
|
|
|
#include <AK/RetainPtr.h>
|
2019-02-07 23:13:47 +01:00
|
|
|
#include <AK/AKString.h>
|
2019-01-14 20:00:42 +01:00
|
|
|
|
|
|
|
|
#ifdef KERNEL
|
2019-01-14 15:25:34 +01:00
|
|
|
#include "Process.h"
|
2019-01-14 20:00:42 +01:00
|
|
|
#endif
|
2019-01-13 00:27:25 +01:00
|
|
|
|
2019-01-09 02:06:04 +01:00
|
|
|
class GraphicsBitmap : public Retainable<GraphicsBitmap> {
|
|
|
|
|
public:
|
2019-01-14 20:00:42 +01:00
|
|
|
#ifdef KERNEL
|
2019-01-14 15:25:34 +01:00
|
|
|
static RetainPtr<GraphicsBitmap> create(Process&, const Size&);
|
2019-02-11 09:47:10 +01:00
|
|
|
static RetainPtr<GraphicsBitmap> create_kernel_only(const Size&);
|
2019-01-14 20:00:42 +01:00
|
|
|
#endif
|
2019-01-10 05:36:32 +01:00
|
|
|
static RetainPtr<GraphicsBitmap> create_wrapper(const Size&, RGBA32*);
|
2019-02-07 23:13:47 +01:00
|
|
|
static RetainPtr<GraphicsBitmap> load_from_file(const String& path, const Size&);
|
2019-01-09 02:06:04 +01:00
|
|
|
~GraphicsBitmap();
|
|
|
|
|
|
2019-01-10 05:36:32 +01:00
|
|
|
RGBA32* scanline(int y);
|
2019-01-12 06:39:34 +01:00
|
|
|
const RGBA32* scanline(int y) const;
|
2019-01-09 02:06:04 +01:00
|
|
|
|
2019-01-24 23:40:12 +01:00
|
|
|
Rect rect() const { return { {}, m_size }; }
|
2019-01-09 02:06:04 +01:00
|
|
|
Size size() const { return m_size; }
|
|
|
|
|
int width() const { return m_size.width(); }
|
|
|
|
|
int height() const { return m_size.height(); }
|
2019-01-12 21:45:45 +01:00
|
|
|
size_t pitch() const { return m_pitch; }
|
2019-01-09 02:06:04 +01:00
|
|
|
|
2019-01-14 20:00:42 +01:00
|
|
|
#ifdef KERNEL
|
2019-01-14 15:25:34 +01:00
|
|
|
Region* client_region() { return m_client_region; }
|
|
|
|
|
Region* server_region() { return m_server_region; }
|
2019-01-14 20:00:42 +01:00
|
|
|
#endif
|
2019-01-14 15:25:34 +01:00
|
|
|
|
2019-01-09 02:06:04 +01:00
|
|
|
private:
|
2019-01-14 20:00:42 +01:00
|
|
|
#ifdef KERNEL
|
2019-01-14 15:25:34 +01:00
|
|
|
GraphicsBitmap(Process&, const Size&);
|
2019-02-11 09:47:10 +01:00
|
|
|
GraphicsBitmap(const Size&);
|
2019-01-14 20:00:42 +01:00
|
|
|
#endif
|
2019-01-10 05:36:32 +01:00
|
|
|
GraphicsBitmap(const Size&, RGBA32*);
|
2019-01-09 02:06:04 +01:00
|
|
|
|
|
|
|
|
Size m_size;
|
2019-01-10 05:36:32 +01:00
|
|
|
RGBA32* m_data { nullptr };
|
2019-01-12 21:29:05 +01:00
|
|
|
size_t m_pitch { 0 };
|
2019-01-14 20:00:42 +01:00
|
|
|
|
2019-02-07 23:13:47 +01:00
|
|
|
#ifdef USERLAND
|
|
|
|
|
bool m_mmaped { false };
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-01-14 20:00:42 +01:00
|
|
|
#ifdef KERNEL
|
2019-01-31 07:02:40 +01:00
|
|
|
WeakPtr<Process> m_client_process;
|
2019-01-14 15:25:34 +01:00
|
|
|
Region* m_client_region { nullptr };
|
|
|
|
|
Region* m_server_region { nullptr };
|
2019-01-14 20:00:42 +01:00
|
|
|
#endif
|
2019-01-09 02:06:04 +01:00
|
|
|
};
|
2019-01-16 19:43:01 +01:00
|
|
|
|
|
|
|
|
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)));
|
|
|
|
|
}
|