Libraries: Use default constructors/destructors in LibGfx

https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
This commit is contained in:
Lenny Maiorani 2022-03-14 13:26:37 -06:00 committed by Linus Groh
parent c37820b898
commit 9c56a83b76
Notes: sideshowbarker 2024-07-17 17:15:18 +09:00
31 changed files with 41 additions and 73 deletions

View File

@ -1307,9 +1307,7 @@ BMPImageDecoderPlugin::BMPImageDecoderPlugin(const u8* data, size_t data_size)
m_context->file_size = data_size;
}
BMPImageDecoderPlugin::~BMPImageDecoderPlugin()
{
}
BMPImageDecoderPlugin::~BMPImageDecoderPlugin() = default;
IntSize BMPImageDecoderPlugin::size()
{

View File

@ -16,14 +16,6 @@ namespace Gfx {
static constexpr int menubar_height = 20;
ClassicWindowTheme::ClassicWindowTheme()
{
}
ClassicWindowTheme::~ClassicWindowTheme()
{
}
Gfx::IntRect ClassicWindowTheme::titlebar_icon_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const
{
if (window_type == WindowType::ToolWindow)

View File

@ -13,8 +13,8 @@ namespace Gfx {
class ClassicWindowTheme final : public WindowTheme {
public:
ClassicWindowTheme();
virtual ~ClassicWindowTheme() override;
ClassicWindowTheme() = default;
virtual ~ClassicWindowTheme() override = default;
virtual void paint_normal_frame(Painter& painter, WindowState window_state, const IntRect& window_rect, StringView window_title, const Bitmap& icon, const Palette& palette, const IntRect& leftmost_button_rect, int menu_row_count, bool window_modified) const override;
virtual void paint_tool_window_frame(Painter&, WindowState, const IntRect& window_rect, StringView title, const Palette&, const IntRect& leftmost_button_rect) const override;

View File

@ -944,9 +944,7 @@ DDSImageDecoderPlugin::DDSImageDecoderPlugin(const u8* data, size_t size)
m_context->data_size = size;
}
DDSImageDecoderPlugin::~DDSImageDecoderPlugin()
{
}
DDSImageDecoderPlugin::~DDSImageDecoderPlugin() = default;
IntSize DDSImageDecoderPlugin::size()
{

View File

@ -17,8 +17,8 @@ public:
DisjointRectSet(const DisjointRectSet&) = delete;
DisjointRectSet& operator=(const DisjointRectSet&) = delete;
DisjointRectSet() { }
~DisjointRectSet() { }
DisjointRectSet() = default;
~DisjointRectSet() = default;
DisjointRectSet(const IntRect& rect)
{

View File

@ -13,8 +13,8 @@ namespace Gfx {
template<size_t N>
class BoxBlurFilter : public GenericConvolutionFilter<N> {
public:
BoxBlurFilter() { }
virtual ~BoxBlurFilter() { }
BoxBlurFilter() = default;
virtual ~BoxBlurFilter() = default;
virtual const char* class_name() const override { return "BoxBlurFilter"; }
};

View File

@ -17,9 +17,9 @@ public:
public:
virtual bool is_generic_convolution_filter() const { return false; }
virtual ~Parameters() { }
virtual ~Parameters() = default;
};
virtual ~Filter() { }
virtual ~Filter() = default;
virtual const char* class_name() const = 0;
@ -27,7 +27,7 @@ public:
virtual void apply(Bitmap&, IntRect const&, Bitmap const&, IntRect const&) {};
protected:
Filter() { }
Filter() = default;
};
}

View File

@ -58,8 +58,8 @@ public:
RefPtr<Gfx::Bitmap> m_target;
};
GenericConvolutionFilter() { }
virtual ~GenericConvolutionFilter() { }
GenericConvolutionFilter() = default;
virtual ~GenericConvolutionFilter() = default;
virtual const char* class_name() const override { return "GenericConvolutionFilter"; }

View File

@ -12,8 +12,8 @@ namespace Gfx {
class GrayscaleFilter : public ColorFilter {
public:
GrayscaleFilter() { }
virtual ~GrayscaleFilter() { }
GrayscaleFilter() = default;
virtual ~GrayscaleFilter() = default;
virtual char const* class_name() const override { return "GrayscaleFilter"; }

View File

@ -12,8 +12,8 @@ namespace Gfx {
class InvertFilter : public ColorFilter {
public:
InvertFilter() { }
virtual ~InvertFilter() { }
InvertFilter() = default;
virtual ~InvertFilter() = default;
virtual char const* class_name() const override { return "InvertFilter"; }

View File

@ -12,8 +12,8 @@ namespace Gfx {
class LaplacianFilter : public GenericConvolutionFilter<3> {
public:
LaplacianFilter() { }
virtual ~LaplacianFilter() { }
LaplacianFilter() = default;
virtual ~LaplacianFilter() = default;
virtual const char* class_name() const override { return "LaplacianFilter"; }
};

View File

@ -18,7 +18,7 @@ public:
: m_amount(amount)
{
}
virtual ~SepiaFilter() { }
virtual ~SepiaFilter() = default;
virtual char const* class_name() const override { return "SepiaFilter"; }

View File

@ -12,8 +12,8 @@ namespace Gfx {
class SharpenFilter : public GenericConvolutionFilter<3> {
public:
SharpenFilter() { }
virtual ~SharpenFilter() { }
SharpenFilter() = default;
virtual ~SharpenFilter() = default;
virtual const char* class_name() const override { return "SharpenFilter"; }
};

View File

@ -14,8 +14,8 @@ namespace Gfx {
template<size_t N, typename = typename EnableIf<N % 2 == 1>::Type>
class SpatialGaussianBlurFilter : public GenericConvolutionFilter<N> {
public:
SpatialGaussianBlurFilter() { }
virtual ~SpatialGaussianBlurFilter() { }
SpatialGaussianBlurFilter() = default;
virtual ~SpatialGaussianBlurFilter() = default;
virtual const char* class_name() const override { return "SpatialGaussianBlurFilter"; }
};

View File

@ -119,10 +119,6 @@ FontDatabase::FontDatabase()
}
}
FontDatabase::~FontDatabase()
{
}
void FontDatabase::for_each_font(Function<void(const Gfx::Font&)> callback)
{
Vector<RefPtr<Gfx::Font>> fonts;

View File

@ -54,7 +54,7 @@ public:
private:
FontDatabase();
~FontDatabase();
~FontDatabase() = default;
RefPtr<Typeface> get_or_create_typeface(const String& family, const String& variant);

View File

@ -605,7 +605,7 @@ GIFImageDecoderPlugin::GIFImageDecoderPlugin(const u8* data, size_t size)
m_context->data_size = size;
}
GIFImageDecoderPlugin::~GIFImageDecoderPlugin() { }
GIFImageDecoderPlugin::~GIFImageDecoderPlugin() = default;
IntSize GIFImageDecoderPlugin::size()
{

View File

@ -286,7 +286,7 @@ ICOImageDecoderPlugin::ICOImageDecoderPlugin(const u8* data, size_t size)
m_context->data_size = size;
}
ICOImageDecoderPlugin::~ICOImageDecoderPlugin() { }
ICOImageDecoderPlugin::~ICOImageDecoderPlugin() = default;
IntSize ICOImageDecoderPlugin::size()
{

View File

@ -79,8 +79,4 @@ ImageDecoder::ImageDecoder(NonnullOwnPtr<ImageDecoderPlugin> plugin)
{
}
ImageDecoder::~ImageDecoder()
{
}
}

View File

@ -27,7 +27,7 @@ struct ImageFrameDescriptor {
class ImageDecoderPlugin {
public:
virtual ~ImageDecoderPlugin() { }
virtual ~ImageDecoderPlugin() = default;
virtual IntSize size() = 0;
@ -42,13 +42,13 @@ public:
virtual ErrorOr<ImageFrameDescriptor> frame(size_t index) = 0;
protected:
ImageDecoderPlugin() { }
ImageDecoderPlugin() = default;
};
class ImageDecoder : public RefCounted<ImageDecoder> {
public:
static RefPtr<ImageDecoder> try_create(ReadonlyBytes);
~ImageDecoder();
~ImageDecoder() = default;
IntSize size() const { return m_plugin->size(); }
int width() const { return size().width(); }

View File

@ -1232,9 +1232,7 @@ JPGImageDecoderPlugin::JPGImageDecoderPlugin(const u8* data, size_t size)
m_context->huffman_stream.stream.ensure_capacity(50 * KiB);
}
JPGImageDecoderPlugin::~JPGImageDecoderPlugin()
{
}
JPGImageDecoderPlugin::~JPGImageDecoderPlugin() = default;
IntSize JPGImageDecoderPlugin::size()
{

View File

@ -19,7 +19,7 @@ namespace Gfx {
template<typename T>
class Line {
public:
Line() { }
Line() = default;
Line(Point<T> a, Point<T> b)
: m_a(a)

View File

@ -918,9 +918,7 @@ PNGImageDecoderPlugin::PNGImageDecoderPlugin(const u8* data, size_t size)
m_context->data_size = size;
}
PNGImageDecoderPlugin::~PNGImageDecoderPlugin()
{
}
PNGImageDecoderPlugin::~PNGImageDecoderPlugin() = default;
IntSize PNGImageDecoderPlugin::size()
{

View File

@ -19,7 +19,7 @@ public:
static ByteBuffer encode(Gfx::Bitmap const&);
private:
PNGWriter() { }
PNGWriter() = default;
Vector<u8> m_data;
void add_chunk(PNGChunk&);

View File

@ -72,10 +72,6 @@ Painter::Painter(Gfx::Bitmap& bitmap)
m_clip_origin = state().clip_rect;
}
Painter::~Painter()
{
}
void Painter::fill_rect_with_draw_op(IntRect const& a_rect, Color color)
{
VERIFY(scale() == 1); // FIXME: Add scaling support.

View File

@ -26,7 +26,7 @@ namespace Gfx {
class Painter {
public:
explicit Painter(Gfx::Bitmap&);
~Painter();
~Painter() = default;
enum class LineStyle {
Solid,

View File

@ -143,7 +143,7 @@ private:
class Path {
public:
Path() { }
Path() = default;
void move_to(const FloatPoint& point)
{

View File

@ -14,7 +14,7 @@ namespace Gfx {
class ShareableBitmap {
public:
ShareableBitmap() { }
ShareableBitmap() = default;
enum Tag { ConstructWithKnownGoodBitmap };
ShareableBitmap(NonnullRefPtr<Gfx::Bitmap>, Tag);

View File

@ -34,7 +34,7 @@ enum class FrameShape {
// FIXME: should this be in its own header?
class BaseStylePainter {
public:
virtual ~BaseStylePainter() { }
virtual ~BaseStylePainter() = default;
virtual void paint_button(Painter&, IntRect const&, Palette const&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true, bool focused = false, bool default_button = false) = 0;
virtual void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, bool top, bool in_active_window) = 0;
@ -47,7 +47,7 @@ public:
virtual void paint_simple_rect_shadow(Painter&, IntRect const&, Bitmap const& shadow_bitmap, bool shadow_includes_frame = false, bool fill_content = false) = 0;
protected:
BaseStylePainter() { }
BaseStylePainter() = default;
};
class StylePainter {

View File

@ -15,8 +15,4 @@ WindowTheme& WindowTheme::current()
return theme;
}
WindowTheme::~WindowTheme()
{
}
}

View File

@ -27,7 +27,7 @@ public:
Moving,
};
virtual ~WindowTheme();
virtual ~WindowTheme() = default;
static WindowTheme& current();
@ -50,7 +50,7 @@ public:
virtual float frame_alpha_hit_threshold(WindowState) const = 0;
protected:
WindowTheme() { }
WindowTheme() = default;
};
}