mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 04:35:06 +00:00
LibGfx: Move a bunch of LogStream::operator<< to cpp files
This commit is contained in:
parent
3866e0d4d4
commit
34b5ff7c29
12 changed files with 162 additions and 28 deletions
|
@ -37,4 +37,10 @@ ImageDecoder::ImageDecoder(const u8* data, size_t size)
|
||||||
ImageDecoder::~ImageDecoder()
|
ImageDecoder::~ImageDecoder()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RefPtr<Gfx::Bitmap> ImageDecoder::bitmap() const
|
||||||
|
{
|
||||||
|
return m_plugin->bitmap();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
Size size() const { return m_plugin->size(); }
|
Size size() const { return m_plugin->size(); }
|
||||||
int width() const { return size().width(); }
|
int width() const { return size().width(); }
|
||||||
int height() const { return size().height(); }
|
int height() const { return size().height(); }
|
||||||
RefPtr<Gfx::Bitmap> bitmap() const { return m_plugin->bitmap(); }
|
RefPtr<Gfx::Bitmap> bitmap() const;
|
||||||
void set_volatile() { m_plugin->set_volatile(); }
|
void set_volatile() { m_plugin->set_volatile(); }
|
||||||
[[nodiscard]] bool set_nonvolatile() { return m_plugin->set_nonvolatile(); }
|
[[nodiscard]] bool set_nonvolatile() { return m_plugin->set_nonvolatile(); }
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,12 @@ OBJS = \
|
||||||
PNGLoader.o \
|
PNGLoader.o \
|
||||||
Painter.o \
|
Painter.o \
|
||||||
Palette.o \
|
Palette.o \
|
||||||
|
Point.o \
|
||||||
Rect.o \
|
Rect.o \
|
||||||
|
Size.o \
|
||||||
StylePainter.o \
|
StylePainter.o \
|
||||||
SystemTheme.o
|
SystemTheme.o \
|
||||||
|
Triangle.o
|
||||||
|
|
||||||
LIBRARY = libgfx.a
|
LIBRARY = libgfx.a
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/Forward.h>
|
#include <AK/Forward.h>
|
||||||
|
#include <AK/NonnullRefPtr.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibGfx/Color.h>
|
#include <LibGfx/Color.h>
|
||||||
#include <LibGfx/Forward.h>
|
#include <LibGfx/Forward.h>
|
||||||
|
|
42
Libraries/LibGfx/Point.cpp
Normal file
42
Libraries/LibGfx/Point.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <AK/String.h>
|
||||||
|
#include <LibGfx/Point.h>
|
||||||
|
|
||||||
|
namespace Gfx {
|
||||||
|
|
||||||
|
String Point::to_string() const
|
||||||
|
{
|
||||||
|
return String::format("[%d,%d]", x(), y());
|
||||||
|
}
|
||||||
|
|
||||||
|
const LogStream& operator<<(const LogStream& stream, const Point& value)
|
||||||
|
{
|
||||||
|
return stream << value.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -26,8 +26,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/LogStream.h>
|
#include <AK/Forward.h>
|
||||||
#include <AK/String.h>
|
#include <AK/StdLibExtras.h>
|
||||||
#include <LibGfx/Orientation.h>
|
#include <LibGfx/Orientation.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
@ -105,7 +105,7 @@ public:
|
||||||
}
|
}
|
||||||
Point operator+(const Point& other) const { return { m_x + other.m_x, m_y + other.m_y }; }
|
Point operator+(const Point& other) const { return { m_x + other.m_x, m_y + other.m_y }; }
|
||||||
|
|
||||||
String to_string() const { return String::format("[%d,%d]", x(), y()); }
|
String to_string() const;
|
||||||
|
|
||||||
bool is_null() const { return !m_x && !m_y; }
|
bool is_null() const { return !m_x && !m_y; }
|
||||||
|
|
||||||
|
@ -156,9 +156,6 @@ private:
|
||||||
int m_y { 0 };
|
int m_y { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const LogStream& operator<<(const LogStream& stream, const Point& value)
|
const LogStream& operator<<(const LogStream&, const Point&);
|
||||||
{
|
|
||||||
return stream << value.to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
|
#include <AK/String.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibGfx/Rect.h>
|
#include <LibGfx/Rect.h>
|
||||||
|
|
||||||
|
@ -130,4 +131,14 @@ void Rect::align_within(const Rect& other, TextAlignment alignment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String Rect::to_string() const
|
||||||
|
{
|
||||||
|
return String::format("[%d,%d %dx%d]", x(), y(), width(), height());
|
||||||
|
}
|
||||||
|
|
||||||
|
const LogStream& operator<<(const LogStream& stream, const Rect& value)
|
||||||
|
{
|
||||||
|
return stream << value.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/LogStream.h>
|
#include <AK/Forward.h>
|
||||||
#include <AK/String.h>
|
|
||||||
#include <LibGfx/Orientation.h>
|
#include <LibGfx/Orientation.h>
|
||||||
#include <LibGfx/Point.h>
|
#include <LibGfx/Point.h>
|
||||||
#include <LibGfx/Size.h>
|
#include <LibGfx/Size.h>
|
||||||
|
@ -313,7 +312,7 @@ public:
|
||||||
set_y(other.center().y() - height() / 2);
|
set_y(other.center().y() - height() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
String to_string() const { return String::format("[%d,%d %dx%d]", x(), y(), width(), height()); }
|
String to_string() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Point m_location;
|
Point m_location;
|
||||||
|
@ -332,9 +331,6 @@ inline void Point::constrain(const Rect& rect)
|
||||||
set_y(rect.bottom());
|
set_y(rect.bottom());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const LogStream& operator<<(const LogStream& stream, const Rect& value)
|
const LogStream& operator<<(const LogStream&, const Rect&);
|
||||||
{
|
|
||||||
return stream << value.to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
42
Libraries/LibGfx/Size.cpp
Normal file
42
Libraries/LibGfx/Size.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <AK/String.h>
|
||||||
|
#include <LibGfx/Size.h>
|
||||||
|
|
||||||
|
namespace Gfx {
|
||||||
|
|
||||||
|
String Size::to_string() const
|
||||||
|
{
|
||||||
|
return String::format("[%dx%d]", m_width, m_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
const LogStream& operator<<(const LogStream& stream, const Size& value)
|
||||||
|
{
|
||||||
|
return stream << value.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -26,8 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/LogStream.h>
|
#include <AK/Forward.h>
|
||||||
#include <AK/String.h>
|
|
||||||
#include <LibGfx/Orientation.h>
|
#include <LibGfx/Orientation.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
@ -102,16 +101,13 @@ public:
|
||||||
set_height(value);
|
set_height(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
String to_string() const { return String::format("[%dx%d]", m_width, m_height); }
|
String to_string() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_width { 0 };
|
int m_width { 0 };
|
||||||
int m_height { 0 };
|
int m_height { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const LogStream& operator<<(const LogStream& stream, const Size& value)
|
const LogStream& operator<<(const LogStream&, const Size&);
|
||||||
{
|
|
||||||
return stream << value.to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
42
Libraries/LibGfx/Triangle.cpp
Normal file
42
Libraries/LibGfx/Triangle.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020, Shannon Booth <shannon.ml.booth@gmail.com>
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <AK/String.h>
|
||||||
|
#include <LibGfx/Triangle.h>
|
||||||
|
|
||||||
|
namespace Gfx {
|
||||||
|
|
||||||
|
String Triangle::to_string() const
|
||||||
|
{
|
||||||
|
return String::format("(%s,%s,%s)", m_a.to_string().characters(), m_b.to_string().characters(), m_c.to_string().characters());
|
||||||
|
}
|
||||||
|
|
||||||
|
const LogStream& operator<<(const LogStream& stream, const Triangle& value)
|
||||||
|
{
|
||||||
|
return stream << value.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -24,6 +24,7 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/Forward.h>
|
||||||
#include <LibGfx/Point.h>
|
#include <LibGfx/Point.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
@ -64,7 +65,7 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String to_string() const { return String::format("(%s,%s,%s)", m_a.to_string().characters(), m_b.to_string().characters(), m_c.to_string().characters()); }
|
String to_string() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_det;
|
int m_det;
|
||||||
|
@ -73,9 +74,6 @@ private:
|
||||||
Point m_c;
|
Point m_c;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const LogStream& operator<<(const LogStream& stream, const Triangle& value)
|
const LogStream& operator<<(const LogStream&, const Triangle&);
|
||||||
{
|
|
||||||
return stream << value.to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue