Skip to content

Commit

Permalink
Libraries: Use default constructors/destructors in LibGfx
Browse files Browse the repository at this point in the history
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."
  • Loading branch information
ldm5180 authored and linusg committed Mar 17, 2022
1 parent c37820b commit 9c56a83
Show file tree
Hide file tree
Showing 31 changed files with 41 additions and 73 deletions.
4 changes: 1 addition & 3 deletions Userland/Libraries/LibGfx/BMPLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
8 changes: 0 additions & 8 deletions Userland/Libraries/LibGfx/ClassicWindowTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGfx/ClassicWindowTheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions Userland/Libraries/LibGfx/DDSLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGfx/DisjointRectSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class DisjointRectSet {
DisjointRectSet(const DisjointRectSet&) = delete;
DisjointRectSet& operator=(const DisjointRectSet&) = delete;

DisjointRectSet() { }
~DisjointRectSet() { }
DisjointRectSet() = default;
~DisjointRectSet() = default;

DisjointRectSet(const IntRect& rect)
{
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGfx/Filters/BoxBlurFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"; }
};
Expand Down
6 changes: 3 additions & 3 deletions Userland/Libraries/LibGfx/Filters/Filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ class Filter {
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;

virtual void apply(Bitmap&, IntRect const&, Bitmap const&, IntRect const&, Parameters const&) {};
virtual void apply(Bitmap&, IntRect const&, Bitmap const&, IntRect const&) {};

protected:
Filter() { }
Filter() = default;
};

}
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGfx/Filters/GenericConvolutionFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class GenericConvolutionFilter : public Filter {
RefPtr<Gfx::Bitmap> m_target;
};

GenericConvolutionFilter() { }
virtual ~GenericConvolutionFilter() { }
GenericConvolutionFilter() = default;
virtual ~GenericConvolutionFilter() = default;

virtual const char* class_name() const override { return "GenericConvolutionFilter"; }

Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGfx/Filters/GrayscaleFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"; }

Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGfx/Filters/InvertFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"; }

Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGfx/Filters/LaplacianFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"; }
};
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGfx/Filters/SepiaFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SepiaFilter : public ColorFilter {
: m_amount(amount)
{
}
virtual ~SepiaFilter() { }
virtual ~SepiaFilter() = default;

virtual char const* class_name() const override { return "SepiaFilter"; }

Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGfx/Filters/SharpenFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"; }
};
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGfx/Filters/SpatialGaussianBlurFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"; }
};
Expand Down
4 changes: 0 additions & 4 deletions Userland/Libraries/LibGfx/FontDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ FontDatabase::FontDatabase()
}
}

FontDatabase::~FontDatabase()
{
}

void FontDatabase::for_each_font(Function<void(const Gfx::Font&)> callback)
{
Vector<RefPtr<Gfx::Font>> fonts;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGfx/FontDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class FontDatabase {

private:
FontDatabase();
~FontDatabase();
~FontDatabase() = default;

RefPtr<Typeface> get_or_create_typeface(const String& family, const String& variant);

Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGfx/GIFLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGfx/ICOLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
4 changes: 0 additions & 4 deletions Userland/Libraries/LibGfx/ImageDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,4 @@ ImageDecoder::ImageDecoder(NonnullOwnPtr<ImageDecoderPlugin> plugin)
{
}

ImageDecoder::~ImageDecoder()
{
}

}
6 changes: 3 additions & 3 deletions Userland/Libraries/LibGfx/ImageDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct ImageFrameDescriptor {

class ImageDecoderPlugin {
public:
virtual ~ImageDecoderPlugin() { }
virtual ~ImageDecoderPlugin() = default;

virtual IntSize size() = 0;

Expand All @@ -42,13 +42,13 @@ class ImageDecoderPlugin {
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(); }
Expand Down
4 changes: 1 addition & 3 deletions Userland/Libraries/LibGfx/JPGLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGfx/Line.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions Userland/Libraries/LibGfx/PNGLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGfx/PNGWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PNGWriter {
static ByteBuffer encode(Gfx::Bitmap const&);

private:
PNGWriter() { }
PNGWriter() = default;

Vector<u8> m_data;
void add_chunk(PNGChunk&);
Expand Down
4 changes: 0 additions & 4 deletions Userland/Libraries/LibGfx/Painter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGfx/Painter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Gfx {
class Painter {
public:
explicit Painter(Gfx::Bitmap&);
~Painter();
~Painter() = default;

enum class LineStyle {
Solid,
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGfx/Path.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class EllipticalArcSegment final : public Segment {

class Path {
public:
Path() { }
Path() = default;

void move_to(const FloatPoint& point)
{
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGfx/ShareableBitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Gfx {

class ShareableBitmap {
public:
ShareableBitmap() { }
ShareableBitmap() = default;

enum Tag { ConstructWithKnownGoodBitmap };
ShareableBitmap(NonnullRefPtr<Gfx::Bitmap>, Tag);
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGfx/StylePainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -47,7 +47,7 @@ class BaseStylePainter {
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 {
Expand Down
4 changes: 0 additions & 4 deletions Userland/Libraries/LibGfx/WindowTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,4 @@ WindowTheme& WindowTheme::current()
return theme;
}

WindowTheme::~WindowTheme()
{
}

}
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGfx/WindowTheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class WindowTheme {
Moving,
};

virtual ~WindowTheme();
virtual ~WindowTheme() = default;

static WindowTheme& current();

Expand All @@ -50,7 +50,7 @@ class WindowTheme {
virtual float frame_alpha_hit_threshold(WindowState) const = 0;

protected:
WindowTheme() { }
WindowTheme() = default;
};

}

0 comments on commit 9c56a83

Please sign in to comment.