From 6c79efcae41cef4d2d0daaf2e3e0a995a1d04da2 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sat, 11 May 2024 19:53:38 -0400 Subject: [PATCH] LibGfx: Move AnimationWriter to its own file No behavior change. --- .../Userland/Libraries/LibGfx/BUILD.gn | 1 + Tests/LibGfx/TestImageWriter.cpp | 1 + Userland/Libraries/LibGfx/CMakeLists.txt | 1 + .../LibGfx/ImageFormats/AnimationWriter.cpp | 13 ++++++++++ .../LibGfx/ImageFormats/AnimationWriter.h | 26 +++++++++++++++++++ .../LibGfx/ImageFormats/WebPWriter.cpp | 1 + .../LibGfx/ImageFormats/WebPWriter.h | 13 ++-------- Userland/Utilities/animation.cpp | 1 + 8 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 Userland/Libraries/LibGfx/ImageFormats/AnimationWriter.cpp create mode 100644 Userland/Libraries/LibGfx/ImageFormats/AnimationWriter.h diff --git a/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn index fe8934d002f..c6f6a2596e3 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn @@ -63,6 +63,7 @@ shared_library("LibGfx") { "ICC/TagTypes.cpp", "ICC/Tags.cpp", "ICC/WellKnownProfiles.cpp", + "ImageFormats/AnimationWriter.cpp", "ImageFormats/BMPLoader.cpp", "ImageFormats/BMPWriter.cpp", "ImageFormats/BooleanDecoder.cpp", diff --git a/Tests/LibGfx/TestImageWriter.cpp b/Tests/LibGfx/TestImageWriter.cpp index 4a131200a5e..6fd60df0179 100644 --- a/Tests/LibGfx/TestImageWriter.cpp +++ b/Tests/LibGfx/TestImageWriter.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibGfx/CMakeLists.txt b/Userland/Libraries/LibGfx/CMakeLists.txt index 517954ea5fe..e8c97884106 100644 --- a/Userland/Libraries/LibGfx/CMakeLists.txt +++ b/Userland/Libraries/LibGfx/CMakeLists.txt @@ -36,6 +36,7 @@ set(SOURCES ICC/Tags.cpp ICC/TagTypes.cpp ICC/WellKnownProfiles.cpp + ImageFormats/AnimationWriter.cpp ImageFormats/BMPLoader.cpp ImageFormats/BMPWriter.cpp ImageFormats/BooleanDecoder.cpp diff --git a/Userland/Libraries/LibGfx/ImageFormats/AnimationWriter.cpp b/Userland/Libraries/LibGfx/ImageFormats/AnimationWriter.cpp new file mode 100644 index 00000000000..bfd7f8ccc61 --- /dev/null +++ b/Userland/Libraries/LibGfx/ImageFormats/AnimationWriter.cpp @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2024, Nico Weber + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +namespace Gfx { + +AnimationWriter::~AnimationWriter() = default; + +} diff --git a/Userland/Libraries/LibGfx/ImageFormats/AnimationWriter.h b/Userland/Libraries/LibGfx/ImageFormats/AnimationWriter.h new file mode 100644 index 00000000000..9b08134f291 --- /dev/null +++ b/Userland/Libraries/LibGfx/ImageFormats/AnimationWriter.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024, Nico Weber + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include +#include + +namespace Gfx { + +class AnimationWriter { +public: + virtual ~AnimationWriter(); + + // Flushes the frame to disk. + // IntRect { at, at + bitmap.size() } must fit in the dimensions + // passed to `start_writing_animation()`. + // FIXME: Consider passing in disposal method and blend mode. + virtual ErrorOr add_frame(Bitmap&, int duration_ms, IntPoint at = {}) = 0; +}; + +} diff --git a/Userland/Libraries/LibGfx/ImageFormats/WebPWriter.cpp b/Userland/Libraries/LibGfx/ImageFormats/WebPWriter.cpp index ce46f652ef7..28430792a31 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/WebPWriter.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/WebPWriter.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibGfx/ImageFormats/WebPWriter.h b/Userland/Libraries/LibGfx/ImageFormats/WebPWriter.h index 8c4488bc235..1ecaaa5994e 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/WebPWriter.h +++ b/Userland/Libraries/LibGfx/ImageFormats/WebPWriter.h @@ -13,21 +13,12 @@ namespace Gfx { +class AnimationWriter; + struct WebPEncoderOptions { Optional icc_data; }; -class AnimationWriter { -public: - virtual ~AnimationWriter() = default; - - // Flushes the frame to disk. - // IntRect { at, at + bitmap.size() } must fit in the dimensions - // passed to `start_writing_animation()`. - // FIXME: Consider passing in disposal method and blend mode. - virtual ErrorOr add_frame(Bitmap&, int duration_ms, IntPoint at = {}) = 0; -}; - class WebPWriter { public: using Options = WebPEncoderOptions; diff --git a/Userland/Utilities/animation.cpp b/Userland/Utilities/animation.cpp index 0cff245f25c..af675675a29 100644 --- a/Userland/Utilities/animation.cpp +++ b/Userland/Utilities/animation.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include