diff --git a/Userland/Libraries/LibCore/CMakeLists.txt b/Userland/Libraries/LibCore/CMakeLists.txt index a754d6be3c5..9caa1484946 100644 --- a/Userland/Libraries/LibCore/CMakeLists.txt +++ b/Userland/Libraries/LibCore/CMakeLists.txt @@ -91,7 +91,6 @@ endif() if (APPLE) list(APPEND SOURCES IOSurface.cpp) - list(APPEND SOURCES MetalContext.mm) endif() serenity_lib(LibCore core) @@ -103,7 +102,6 @@ if (APPLE) target_link_libraries(LibCore PUBLIC "-framework CoreServices") target_link_libraries(LibCore PUBLIC "-framework Foundation") target_link_libraries(LibCore PUBLIC "-framework IOSurface") - target_link_libraries(LibCore PUBLIC "-framework Metal") endif() if (ANDROID) diff --git a/Userland/Libraries/LibGfx/CMakeLists.txt b/Userland/Libraries/LibGfx/CMakeLists.txt index 3d5eb3e14fb..5816b52878b 100644 --- a/Userland/Libraries/LibGfx/CMakeLists.txt +++ b/Userland/Libraries/LibGfx/CMakeLists.txt @@ -70,6 +70,10 @@ set(SOURCES SkiaBackendContext.cpp ) +if (APPLE) + list(APPEND SOURCES MetalContext.mm) +endif() + serenity_lib(LibGfx gfx) target_link_libraries(LibGfx PRIVATE LibCompress LibCore LibCrypto LibFileSystem LibRIFF LibTextCodec LibIPC LibUnicode LibURL) @@ -129,3 +133,7 @@ if (ENABLE_SWIFT) target_link_libraries(LibGfx PRIVATE AK) add_swift_target_properties(LibGfx LAGOM_LIBRARIES AK) endif() + +if (APPLE) + target_link_libraries(LibCore PUBLIC "-framework Metal") +endif() diff --git a/Userland/Libraries/LibCore/MetalContext.h b/Userland/Libraries/LibGfx/MetalContext.h similarity index 85% rename from Userland/Libraries/LibCore/MetalContext.h rename to Userland/Libraries/LibGfx/MetalContext.h index 244643a7893..efe338b0c97 100644 --- a/Userland/Libraries/LibCore/MetalContext.h +++ b/Userland/Libraries/LibGfx/MetalContext.h @@ -13,7 +13,7 @@ static_assert(false, "This file must only be used for macOS"); #include #include -namespace Core { +namespace Gfx { class MetalTexture { public: @@ -29,7 +29,7 @@ public: virtual void const* device() const = 0; virtual void const* queue() const = 0; - virtual OwnPtr create_texture_from_iosurface(IOSurfaceHandle const&) = 0; + virtual OwnPtr create_texture_from_iosurface(Core::IOSurfaceHandle const&) = 0; virtual ~MetalContext() {}; }; diff --git a/Userland/Libraries/LibCore/MetalContext.mm b/Userland/Libraries/LibGfx/MetalContext.mm similarity index 93% rename from Userland/Libraries/LibCore/MetalContext.mm rename to Userland/Libraries/LibGfx/MetalContext.mm index 76e2f89176d..225685b7109 100644 --- a/Userland/Libraries/LibCore/MetalContext.mm +++ b/Userland/Libraries/LibGfx/MetalContext.mm @@ -5,11 +5,11 @@ */ #include -#include +#include #import -namespace Core { +namespace Gfx { class MetalTextureImpl final : public MetalTexture { public: @@ -42,7 +42,7 @@ public: void const* device() const override { return m_device; } void const* queue() const override { return m_queue; } - OwnPtr create_texture_from_iosurface(IOSurfaceHandle const& iosurface) override + OwnPtr create_texture_from_iosurface(Core::IOSurfaceHandle const& iosurface) override { auto* const descriptor = [[MTLTextureDescriptor alloc] init]; descriptor.pixelFormat = MTLPixelFormatBGRA8Unorm; diff --git a/Userland/Libraries/LibGfx/PaintingSurface.cpp b/Userland/Libraries/LibGfx/PaintingSurface.cpp index 3d31a1cd02c..13dc73a42b1 100644 --- a/Userland/Libraries/LibGfx/PaintingSurface.cpp +++ b/Userland/Libraries/LibGfx/PaintingSurface.cpp @@ -72,7 +72,7 @@ NonnullRefPtr PaintingSurface::wrap_bitmap(Bitmap& bitmap) } #ifdef AK_OS_MACOS -NonnullRefPtr PaintingSurface::wrap_metal_surface(Core::MetalTexture& metal_texture, RefPtr context) +NonnullRefPtr PaintingSurface::wrap_metal_surface(Gfx::MetalTexture& metal_texture, RefPtr context) { IntSize const size { metal_texture.width(), metal_texture.height() }; auto image_info = SkImageInfo::Make(size.width(), size.height(), kBGRA_8888_SkColorType, kPremul_SkAlphaType); diff --git a/Userland/Libraries/LibGfx/PaintingSurface.h b/Userland/Libraries/LibGfx/PaintingSurface.h index 00449996132..336070e1d27 100644 --- a/Userland/Libraries/LibGfx/PaintingSurface.h +++ b/Userland/Libraries/LibGfx/PaintingSurface.h @@ -14,7 +14,7 @@ #include #ifdef AK_OS_MACOS -# include +# include #endif class SkCanvas; @@ -28,7 +28,7 @@ public: static NonnullRefPtr wrap_bitmap(Bitmap&); #ifdef AK_OS_MACOS - static NonnullRefPtr wrap_metal_surface(Core::MetalTexture&, RefPtr); + static NonnullRefPtr wrap_metal_surface(Gfx::MetalTexture&, RefPtr); #endif RefPtr create_snapshot() const; diff --git a/Userland/Libraries/LibGfx/SkiaBackendContext.cpp b/Userland/Libraries/LibGfx/SkiaBackendContext.cpp index 389e460d81c..0a9a28ae225 100644 --- a/Userland/Libraries/LibGfx/SkiaBackendContext.cpp +++ b/Userland/Libraries/LibGfx/SkiaBackendContext.cpp @@ -109,7 +109,7 @@ private: sk_sp m_context; }; -RefPtr SkiaBackendContext::create_metal_context(Core::MetalContext const& metal_context) +RefPtr SkiaBackendContext::create_metal_context(Gfx::MetalContext const& metal_context) { GrMtlBackendContext backend_context; backend_context.fDevice.retain((GrMTLHandle)metal_context.device()); diff --git a/Userland/Libraries/LibGfx/SkiaBackendContext.h b/Userland/Libraries/LibGfx/SkiaBackendContext.h index e6dea00fc7d..409dfafb8f1 100644 --- a/Userland/Libraries/LibGfx/SkiaBackendContext.h +++ b/Userland/Libraries/LibGfx/SkiaBackendContext.h @@ -10,7 +10,7 @@ #include #ifdef AK_OS_MACOS -# include +# include #endif #ifdef USE_VULKAN @@ -32,7 +32,7 @@ public: #endif #ifdef AK_OS_MACOS - static RefPtr create_metal_context(Core::MetalContext const&); + static RefPtr create_metal_context(Gfx::MetalContext const&); #endif SkiaBackendContext() {}; diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp index bcff3db18f0..747e50919da 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp @@ -31,7 +31,7 @@ TraversableNavigable::TraversableNavigable(JS::NonnullGCPtr page) #ifdef AK_OS_MACOS auto display_list_player_type = page->client().display_list_player_type(); if (display_list_player_type == DisplayListPlayerType::SkiaGPUIfAvailable) { - m_metal_context = Core::get_metal_context(); + m_metal_context = Gfx::get_metal_context(); m_skia_backend_context = Gfx::SkiaBackendContext::create_metal_context(*m_metal_context); } #endif diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.h b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.h index 1d0087dfac0..dccf9cb8cb9 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.h +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.h @@ -16,7 +16,7 @@ #include #ifdef AK_OS_MACOS -# include +# include #endif #ifdef USE_VULKAN @@ -147,7 +147,7 @@ private: RefPtr m_skia_backend_context; #ifdef AK_OS_MACOS - OwnPtr m_metal_context; + OwnPtr m_metal_context; #endif };