mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:08:12 +00:00
LibGfx: Add forward declaration header
This patch adds <LibGfx/Forward.h> with forward declarations for Gfx.
This commit is contained in:
parent
184475d45a
commit
3fe2640c8c
37 changed files with 264 additions and 172 deletions
|
@ -24,7 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/MappedFile.h>
|
||||
#include <AK/SharedBuffer.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/PNGLoader.h>
|
||||
#include <errno.h>
|
||||
|
@ -35,24 +35,24 @@
|
|||
|
||||
namespace Gfx {
|
||||
|
||||
NonnullRefPtr<Bitmap> Bitmap::create(Format format, const Size& size)
|
||||
NonnullRefPtr<Bitmap> Bitmap::create(BitmapFormat format, const Size& size)
|
||||
{
|
||||
return adopt(*new Bitmap(format, size, Purgeable::No));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Bitmap> Bitmap::create_purgeable(Format format, const Size& size)
|
||||
NonnullRefPtr<Bitmap> Bitmap::create_purgeable(BitmapFormat format, const Size& size)
|
||||
{
|
||||
return adopt(*new Bitmap(format, size, Purgeable::Yes));
|
||||
}
|
||||
|
||||
Bitmap::Bitmap(Format format, const Size& size, Purgeable purgeable)
|
||||
Bitmap::Bitmap(BitmapFormat format, const Size& size, Purgeable purgeable)
|
||||
: m_size(size)
|
||||
, m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16))
|
||||
, m_format(format)
|
||||
, m_purgeable(purgeable == Purgeable::Yes)
|
||||
{
|
||||
ASSERT(!m_size.is_empty());
|
||||
if (format == Format::Indexed8)
|
||||
if (format == BitmapFormat::Indexed8)
|
||||
m_palette = new RGBA32[256];
|
||||
int map_flags = purgeable == Purgeable::Yes ? (MAP_PURGEABLE | MAP_PRIVATE) : (MAP_ANONYMOUS | MAP_PRIVATE);
|
||||
m_data = (RGBA32*)mmap_with_name(nullptr, size_in_bytes(), PROT_READ | PROT_WRITE, map_flags, 0, 0, String::format("GraphicsBitmap [%dx%d]", width(), height()).characters());
|
||||
|
@ -60,7 +60,7 @@ Bitmap::Bitmap(Format format, const Size& size, Purgeable purgeable)
|
|||
m_needs_munmap = true;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Bitmap> Bitmap::create_wrapper(Format format, const Size& size, size_t pitch, RGBA32* data)
|
||||
NonnullRefPtr<Bitmap> Bitmap::create_wrapper(BitmapFormat format, const Size& size, size_t pitch, RGBA32* data)
|
||||
{
|
||||
return adopt(*new Bitmap(format, size, pitch, data));
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ RefPtr<Bitmap> Bitmap::load_from_file(const StringView& path)
|
|||
return load_png(path);
|
||||
}
|
||||
|
||||
RefPtr<Bitmap> Bitmap::load_from_file(Format format, const StringView& path, const Size& size)
|
||||
RefPtr<Bitmap> Bitmap::load_from_file(BitmapFormat format, const StringView& path, const Size& size)
|
||||
{
|
||||
MappedFile mapped_file(path);
|
||||
if (!mapped_file.is_valid())
|
||||
|
@ -78,39 +78,39 @@ RefPtr<Bitmap> Bitmap::load_from_file(Format format, const StringView& path, con
|
|||
return adopt(*new Bitmap(format, size, move(mapped_file)));
|
||||
}
|
||||
|
||||
Bitmap::Bitmap(Format format, const Size& size, size_t pitch, RGBA32* data)
|
||||
Bitmap::Bitmap(BitmapFormat format, const Size& size, size_t pitch, RGBA32* data)
|
||||
: m_size(size)
|
||||
, m_data(data)
|
||||
, m_pitch(pitch)
|
||||
, m_format(format)
|
||||
{
|
||||
if (format == Format::Indexed8)
|
||||
if (format == BitmapFormat::Indexed8)
|
||||
m_palette = new RGBA32[256];
|
||||
}
|
||||
|
||||
Bitmap::Bitmap(Format format, const Size& size, MappedFile&& mapped_file)
|
||||
Bitmap::Bitmap(BitmapFormat format, const Size& size, MappedFile&& mapped_file)
|
||||
: m_size(size)
|
||||
, m_data((RGBA32*)mapped_file.data())
|
||||
, m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16))
|
||||
, m_format(format)
|
||||
, m_mapped_file(move(mapped_file))
|
||||
{
|
||||
ASSERT(format != Format::Indexed8);
|
||||
ASSERT(format != BitmapFormat::Indexed8);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Bitmap> Bitmap::create_with_shared_buffer(Format format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const Size& size)
|
||||
NonnullRefPtr<Bitmap> Bitmap::create_with_shared_buffer(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const Size& size)
|
||||
{
|
||||
return adopt(*new Bitmap(format, move(shared_buffer), size));
|
||||
}
|
||||
|
||||
Bitmap::Bitmap(Format format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const Size& size)
|
||||
Bitmap::Bitmap(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const Size& size)
|
||||
: m_size(size)
|
||||
, m_data((RGBA32*)shared_buffer->data())
|
||||
, m_pitch(round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16))
|
||||
, m_format(format)
|
||||
, m_shared_buffer(move(shared_buffer))
|
||||
{
|
||||
ASSERT(format != Format::Indexed8);
|
||||
ASSERT(format != BitmapFormat::Indexed8);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Bitmap> Bitmap::to_shareable_bitmap() const
|
||||
|
@ -141,7 +141,7 @@ void Bitmap::set_mmap_name(const StringView& name)
|
|||
|
||||
void Bitmap::fill(Color color)
|
||||
{
|
||||
ASSERT(m_format == Bitmap::Format::RGB32 || m_format == Bitmap::Format::RGBA32);
|
||||
ASSERT(m_format == BitmapFormat::RGB32 || m_format == BitmapFormat::RGBA32);
|
||||
for (int y = 0; y < height(); ++y) {
|
||||
auto* scanline = this->scanline(y);
|
||||
fast_u32_fill(scanline, color.value(), width());
|
||||
|
@ -175,4 +175,9 @@ void Bitmap::set_volatile()
|
|||
return rc == 0;
|
||||
}
|
||||
|
||||
int Bitmap::shared_buffer_id() const
|
||||
{
|
||||
return m_shared_buffer ? m_shared_buffer->shared_buffer_id() : -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue