mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:07:46 +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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,33 +26,32 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "Color.h"
|
||||
#include "Rect.h"
|
||||
#include "Size.h"
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/MappedFile.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/SharedBuffer.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibGfx/Size.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
enum class BitmapFormat {
|
||||
Invalid,
|
||||
RGB32,
|
||||
RGBA32,
|
||||
Indexed8
|
||||
};
|
||||
|
||||
class Bitmap : public RefCounted<Bitmap> {
|
||||
public:
|
||||
enum class Format {
|
||||
Invalid,
|
||||
RGB32,
|
||||
RGBA32,
|
||||
Indexed8
|
||||
};
|
||||
|
||||
static NonnullRefPtr<Bitmap> create(Format, const Size&);
|
||||
static NonnullRefPtr<Bitmap> create_purgeable(Format, const Size&);
|
||||
static NonnullRefPtr<Bitmap> create_wrapper(Format, const Size&, size_t pitch, RGBA32*);
|
||||
static NonnullRefPtr<Bitmap> create(BitmapFormat, const Size&);
|
||||
static NonnullRefPtr<Bitmap> create_purgeable(BitmapFormat, const Size&);
|
||||
static NonnullRefPtr<Bitmap> create_wrapper(BitmapFormat, const Size&, size_t pitch, RGBA32*);
|
||||
static RefPtr<Bitmap> load_from_file(const StringView& path);
|
||||
static RefPtr<Bitmap> load_from_file(Format, const StringView& path, const Size&);
|
||||
static NonnullRefPtr<Bitmap> create_with_shared_buffer(Format, NonnullRefPtr<SharedBuffer>&&, const Size&);
|
||||
static RefPtr<Bitmap> load_from_file(BitmapFormat, const StringView& path, const Size&);
|
||||
static NonnullRefPtr<Bitmap> create_with_shared_buffer(BitmapFormat, NonnullRefPtr<SharedBuffer>&&, const Size&);
|
||||
|
||||
NonnullRefPtr<Bitmap> to_shareable_bitmap() const;
|
||||
|
||||
|
@ -69,7 +68,7 @@ public:
|
|||
int width() const { return m_size.width(); }
|
||||
int height() const { return m_size.height(); }
|
||||
size_t pitch() const { return m_pitch; }
|
||||
int shared_buffer_id() const { return m_shared_buffer ? m_shared_buffer->shared_buffer_id() : -1; }
|
||||
int shared_buffer_id() const;
|
||||
|
||||
SharedBuffer* shared_buffer() { return m_shared_buffer.ptr(); }
|
||||
const SharedBuffer* shared_buffer() const { return m_shared_buffer.ptr(); }
|
||||
|
@ -77,22 +76,22 @@ public:
|
|||
unsigned bpp() const
|
||||
{
|
||||
switch (m_format) {
|
||||
case Format::Indexed8:
|
||||
case BitmapFormat::Indexed8:
|
||||
return 8;
|
||||
case Format::RGB32:
|
||||
case Format::RGBA32:
|
||||
case BitmapFormat::RGB32:
|
||||
case BitmapFormat::RGBA32:
|
||||
return 32;
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
case Format::Invalid:
|
||||
case BitmapFormat::Invalid:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void fill(Color);
|
||||
|
||||
bool has_alpha_channel() const { return m_format == Format::RGBA32; }
|
||||
Format format() const { return m_format; }
|
||||
bool has_alpha_channel() const { return m_format == BitmapFormat::RGBA32; }
|
||||
BitmapFormat format() const { return m_format; }
|
||||
|
||||
void set_mmap_name(const StringView&);
|
||||
|
||||
|
@ -101,7 +100,7 @@ public:
|
|||
Color palette_color(u8 index) const { return Color::from_rgba(m_palette[index]); }
|
||||
void set_palette_color(u8 index, Color color) { m_palette[index] = color.value(); }
|
||||
|
||||
template<Format>
|
||||
template<BitmapFormat>
|
||||
Color get_pixel(int x, int y) const
|
||||
{
|
||||
(void)x;
|
||||
|
@ -116,7 +115,7 @@ public:
|
|||
return get_pixel(position.x(), position.y());
|
||||
}
|
||||
|
||||
template<Format>
|
||||
template<BitmapFormat>
|
||||
void set_pixel(int x, int y, Color)
|
||||
{
|
||||
(void)x;
|
||||
|
@ -139,16 +138,16 @@ public:
|
|||
private:
|
||||
enum class Purgeable { No,
|
||||
Yes };
|
||||
Bitmap(Format, const Size&, Purgeable);
|
||||
Bitmap(Format, const Size&, size_t pitch, RGBA32*);
|
||||
Bitmap(Format, const Size&, MappedFile&&);
|
||||
Bitmap(Format, NonnullRefPtr<SharedBuffer>&&, const Size&);
|
||||
Bitmap(BitmapFormat, const Size&, Purgeable);
|
||||
Bitmap(BitmapFormat, const Size&, size_t pitch, RGBA32*);
|
||||
Bitmap(BitmapFormat, const Size&, MappedFile&&);
|
||||
Bitmap(BitmapFormat, NonnullRefPtr<SharedBuffer>&&, const Size&);
|
||||
|
||||
Size m_size;
|
||||
RGBA32* m_data { nullptr };
|
||||
RGBA32* m_palette { nullptr };
|
||||
size_t m_pitch { 0 };
|
||||
Format m_format { Format::Invalid };
|
||||
BitmapFormat m_format { BitmapFormat::Invalid };
|
||||
bool m_needs_munmap { false };
|
||||
bool m_purgeable { false };
|
||||
bool m_volatile { false };
|
||||
|
@ -177,19 +176,19 @@ inline u8* Bitmap::bits(int y)
|
|||
}
|
||||
|
||||
template<>
|
||||
inline Color Bitmap::get_pixel<Bitmap::Format::RGB32>(int x, int y) const
|
||||
inline Color Bitmap::get_pixel<BitmapFormat::RGB32>(int x, int y) const
|
||||
{
|
||||
return Color::from_rgb(scanline(y)[x]);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Color Bitmap::get_pixel<Bitmap::Format::RGBA32>(int x, int y) const
|
||||
inline Color Bitmap::get_pixel<BitmapFormat::RGBA32>(int x, int y) const
|
||||
{
|
||||
return Color::from_rgba(scanline(y)[x]);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Color Bitmap::get_pixel<Bitmap::Format::Indexed8>(int x, int y) const
|
||||
inline Color Bitmap::get_pixel<BitmapFormat::Indexed8>(int x, int y) const
|
||||
{
|
||||
return Color::from_rgba(m_palette[bits(y)[x]]);
|
||||
}
|
||||
|
@ -197,12 +196,12 @@ inline Color Bitmap::get_pixel<Bitmap::Format::Indexed8>(int x, int y) const
|
|||
inline Color Bitmap::get_pixel(int x, int y) const
|
||||
{
|
||||
switch (m_format) {
|
||||
case Format::RGB32:
|
||||
return get_pixel<Format::RGB32>(x, y);
|
||||
case Format::RGBA32:
|
||||
return get_pixel<Format::RGBA32>(x, y);
|
||||
case Format::Indexed8:
|
||||
return get_pixel<Format::Indexed8>(x, y);
|
||||
case BitmapFormat::RGB32:
|
||||
return get_pixel<BitmapFormat::RGB32>(x, y);
|
||||
case BitmapFormat::RGBA32:
|
||||
return get_pixel<BitmapFormat::RGBA32>(x, y);
|
||||
case BitmapFormat::Indexed8:
|
||||
return get_pixel<BitmapFormat::Indexed8>(x, y);
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
return {};
|
||||
|
@ -210,13 +209,13 @@ inline Color Bitmap::get_pixel(int x, int y) const
|
|||
}
|
||||
|
||||
template<>
|
||||
inline void Bitmap::set_pixel<Bitmap::Format::RGB32>(int x, int y, Color color)
|
||||
inline void Bitmap::set_pixel<BitmapFormat::RGB32>(int x, int y, Color color)
|
||||
{
|
||||
scanline(y)[x] = color.value();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void Bitmap::set_pixel<Bitmap::Format::RGBA32>(int x, int y, Color color)
|
||||
inline void Bitmap::set_pixel<BitmapFormat::RGBA32>(int x, int y, Color color)
|
||||
{
|
||||
scanline(y)[x] = color.value();
|
||||
}
|
||||
|
@ -224,13 +223,13 @@ inline void Bitmap::set_pixel<Bitmap::Format::RGBA32>(int x, int y, Color color)
|
|||
inline void Bitmap::set_pixel(int x, int y, Color color)
|
||||
{
|
||||
switch (m_format) {
|
||||
case Format::RGB32:
|
||||
set_pixel<Format::RGB32>(x, y, color);
|
||||
case BitmapFormat::RGB32:
|
||||
set_pixel<BitmapFormat::RGB32>(x, y, color);
|
||||
break;
|
||||
case Format::RGBA32:
|
||||
set_pixel<Format::RGBA32>(x, y, color);
|
||||
case BitmapFormat::RGBA32:
|
||||
set_pixel<BitmapFormat::RGBA32>(x, y, color);
|
||||
break;
|
||||
case Format::Indexed8:
|
||||
case BitmapFormat::Indexed8:
|
||||
ASSERT_NOT_REACHED();
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
|
|
52
Libraries/LibGfx/Forward.h
Normal file
52
Libraries/LibGfx/Forward.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
class Bitmap;
|
||||
class CharacterBitmap;
|
||||
class Color;
|
||||
class DisjointRectSet;
|
||||
class FloatPoint;
|
||||
class FloatRect;
|
||||
class FloatSize;
|
||||
class Font;
|
||||
class Painter;
|
||||
class Palette;
|
||||
class Point;
|
||||
class Rect;
|
||||
class Size;
|
||||
class StylePainter;
|
||||
class SystemTheme;
|
||||
class Triangle;
|
||||
|
||||
enum class BitmapFormat;
|
||||
|
||||
}
|
||||
|
||||
using Gfx::Color;
|
|
@ -520,7 +520,7 @@ static bool decode_png_bitmap(PNGLoadingContext& context)
|
|||
}
|
||||
}
|
||||
|
||||
context.bitmap = Bitmap::create_purgeable(context.has_alpha() ? Bitmap::Format::RGBA32 : Bitmap::Format::RGB32, { context.width, context.height });
|
||||
context.bitmap = Bitmap::create_purgeable(context.has_alpha() ? BitmapFormat::RGBA32 : BitmapFormat::RGB32, { context.width, context.height });
|
||||
|
||||
unfilter(context);
|
||||
|
||||
|
|
|
@ -51,14 +51,14 @@
|
|||
|
||||
namespace Gfx {
|
||||
|
||||
template<Bitmap::Format format = Bitmap::Format::Invalid>
|
||||
template<BitmapFormat format = BitmapFormat::Invalid>
|
||||
static ALWAYS_INLINE Color get_pixel(const Gfx::Bitmap& bitmap, int x, int y)
|
||||
{
|
||||
if constexpr (format == Bitmap::Format::Indexed8)
|
||||
if constexpr (format == BitmapFormat::Indexed8)
|
||||
return bitmap.palette_color(bitmap.bits(y)[x]);
|
||||
if constexpr (format == Bitmap::Format::RGB32)
|
||||
if constexpr (format == BitmapFormat::RGB32)
|
||||
return Color::from_rgb(bitmap.scanline(y)[x]);
|
||||
if constexpr (format == Bitmap::Format::RGBA32)
|
||||
if constexpr (format == BitmapFormat::RGBA32)
|
||||
return Color::from_rgba(bitmap.scanline(y)[x]);
|
||||
return bitmap.get_pixel(x, y);
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ void Painter::draw_tiled_bitmap(const Rect& a_dst_rect, const Gfx::Bitmap& sourc
|
|||
RGBA32* dst = m_target->scanline(clipped_rect.y()) + clipped_rect.x();
|
||||
const size_t dst_skip = m_target->pitch() / sizeof(RGBA32);
|
||||
|
||||
if (source.format() == Bitmap::Format::RGB32 || source.format() == Bitmap::Format::RGBA32) {
|
||||
if (source.format() == BitmapFormat::RGB32 || source.format() == BitmapFormat::RGBA32) {
|
||||
int x_start = first_column + a_dst_rect.left();
|
||||
for (int row = first_row; row <= last_row; ++row) {
|
||||
const RGBA32* sl = source.scanline((row + a_dst_rect.top())
|
||||
|
@ -430,7 +430,7 @@ void Painter::blit_offset(const Point& position,
|
|||
RGBA32* dst = m_target->scanline(clipped_rect.y()) + clipped_rect.x();
|
||||
const size_t dst_skip = m_target->pitch() / sizeof(RGBA32);
|
||||
|
||||
if (source.format() == Bitmap::Format::RGB32 || source.format() == Bitmap::Format::RGBA32) {
|
||||
if (source.format() == BitmapFormat::RGB32 || source.format() == BitmapFormat::RGBA32) {
|
||||
int x_start = first_column + src_rect.left();
|
||||
for (int row = first_row; row <= last_row; ++row) {
|
||||
int sr = row - offset.y() + src_rect.top();
|
||||
|
@ -502,7 +502,7 @@ void Painter::blit(const Point& position, const Gfx::Bitmap& source, const Rect&
|
|||
RGBA32* dst = m_target->scanline(clipped_rect.y()) + clipped_rect.x();
|
||||
const size_t dst_skip = m_target->pitch() / sizeof(RGBA32);
|
||||
|
||||
if (source.format() == Bitmap::Format::RGB32 || source.format() == Bitmap::Format::RGBA32) {
|
||||
if (source.format() == BitmapFormat::RGB32 || source.format() == BitmapFormat::RGBA32) {
|
||||
const RGBA32* src = source.scanline(src_rect.top() + first_row) + src_rect.left() + first_column;
|
||||
const size_t src_skip = source.pitch() / sizeof(RGBA32);
|
||||
for (int row = first_row; row <= last_row; ++row) {
|
||||
|
@ -513,7 +513,7 @@ void Painter::blit(const Point& position, const Gfx::Bitmap& source, const Rect&
|
|||
return;
|
||||
}
|
||||
|
||||
if (source.format() == Bitmap::Format::Indexed8) {
|
||||
if (source.format() == BitmapFormat::Indexed8) {
|
||||
const u8* src = source.bits(src_rect.top() + first_row) + src_rect.left() + first_column;
|
||||
const size_t src_skip = source.pitch();
|
||||
for (int row = first_row; row <= last_row; ++row) {
|
||||
|
@ -597,32 +597,32 @@ void Painter::draw_scaled_bitmap(const Rect& a_dst_rect, const Gfx::Bitmap& sour
|
|||
|
||||
if (source.has_alpha_channel()) {
|
||||
switch (source.format()) {
|
||||
case Bitmap::Format::RGB32:
|
||||
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::RGB32>);
|
||||
case BitmapFormat::RGB32:
|
||||
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::RGB32>);
|
||||
break;
|
||||
case Bitmap::Format::RGBA32:
|
||||
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::RGBA32>);
|
||||
case BitmapFormat::RGBA32:
|
||||
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::RGBA32>);
|
||||
break;
|
||||
case Bitmap::Format::Indexed8:
|
||||
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::Indexed8>);
|
||||
case BitmapFormat::Indexed8:
|
||||
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::Indexed8>);
|
||||
break;
|
||||
default:
|
||||
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::Invalid>);
|
||||
do_draw_scaled_bitmap<true>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::Invalid>);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (source.format()) {
|
||||
case Bitmap::Format::RGB32:
|
||||
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::RGB32>);
|
||||
case BitmapFormat::RGB32:
|
||||
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::RGB32>);
|
||||
break;
|
||||
case Bitmap::Format::RGBA32:
|
||||
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::RGBA32>);
|
||||
case BitmapFormat::RGBA32:
|
||||
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::RGBA32>);
|
||||
break;
|
||||
case Bitmap::Format::Indexed8:
|
||||
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::Indexed8>);
|
||||
case BitmapFormat::Indexed8:
|
||||
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::Indexed8>);
|
||||
break;
|
||||
default:
|
||||
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<Bitmap::Format::Invalid>);
|
||||
do_draw_scaled_bitmap<false>(*m_target, dst_rect, clipped_rect, source, src_rect, hscale, vscale, get_pixel<BitmapFormat::Invalid>);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/SharedBuffer.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
@ -73,4 +75,13 @@ void Palette::set_color(ColorRole role, Color color)
|
|||
theme.color[(int)role] = color;
|
||||
}
|
||||
|
||||
PaletteImpl::~PaletteImpl()
|
||||
{
|
||||
}
|
||||
|
||||
void PaletteImpl::replace_internal_buffer(Badge<GUI::Application>, SharedBuffer& buffer)
|
||||
{
|
||||
m_theme_buffer = buffer;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Noncopyable.h>
|
||||
#include <LibGfx/SystemTheme.h>
|
||||
|
||||
|
@ -40,13 +40,14 @@ class PaletteImpl : public RefCounted<PaletteImpl> {
|
|||
AK_MAKE_NONCOPYABLE(PaletteImpl)
|
||||
AK_MAKE_NONMOVABLE(PaletteImpl)
|
||||
public:
|
||||
~PaletteImpl();
|
||||
static NonnullRefPtr<PaletteImpl> create_with_shared_buffer(SharedBuffer&);
|
||||
NonnullRefPtr<PaletteImpl> clone() const;
|
||||
|
||||
Color color(ColorRole) const;
|
||||
const SystemTheme& theme() const;
|
||||
|
||||
void replace_internal_buffer(Badge<GUI::Application>, SharedBuffer& buffer) { m_theme_buffer = buffer; }
|
||||
void replace_internal_buffer(Badge<GUI::Application>, SharedBuffer& buffer);
|
||||
|
||||
private:
|
||||
explicit PaletteImpl(SharedBuffer&);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/SharedBuffer.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibGfx/SystemTheme.h>
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/SharedBuffer.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibGfx/Color.h>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue