From 008210f9f87c9e0efc9c147fce529046e5fef808 Mon Sep 17 00:00:00 2001 From: Christopher James Halse Rogers Date: Tue, 29 Aug 2023 14:14:51 +1000 Subject: [PATCH] platform: Drop `NativeBuffer` detritus Turns out there's *still* a bunch of only-used-by-mirclient detritus in the platform code. Remove this bit. --- include/common/mir/graphics/native_buffer.h | 35 --------------- include/platform/mir/graphics/buffer.h | 5 +-- src/platforms/gbm-kms/include/native_buffer.h | 43 ------------------- .../gbm-kms/server/kms/display_buffer.cpp | 1 - tests/include/mir/test/doubles/mock_buffer.h | 12 ++---- tests/include/mir/test/doubles/stub_buffer.h | 26 +++-------- .../mir/test/doubles/stub_buffer_stream.h | 4 +- .../stub_platform_native_buffer.h | 37 ---------------- .../stub_buffer_allocator.cpp | 6 +-- tests/mir_test_framework/stub_session.cpp | 2 - .../stubbed_graphics_platform.cpp | 4 +- .../graphics/test_software_cursor.cpp | 1 - .../input/test_touchspot_controller.cpp | 1 - 13 files changed, 16 insertions(+), 161 deletions(-) delete mode 100644 include/common/mir/graphics/native_buffer.h delete mode 100644 src/platforms/gbm-kms/include/native_buffer.h delete mode 100644 tests/include/mir_test_framework/stub_platform_native_buffer.h diff --git a/include/common/mir/graphics/native_buffer.h b/include/common/mir/graphics/native_buffer.h deleted file mode 100644 index 91807c2ea38..00000000000 --- a/include/common/mir/graphics/native_buffer.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright © Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License version 2 or 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -#ifndef MIR_GRAPHICS_NATIVE_BUFFER_H_ -#define MIR_GRAPHICS_NATIVE_BUFFER_H_ - -namespace mir -{ -namespace graphics -{ -class NativeBuffer -{ -protected: - NativeBuffer() = default; - virtual ~NativeBuffer() = default; - NativeBuffer(NativeBuffer const&) = delete; - NativeBuffer operator=(NativeBuffer const&) = delete; -}; -} -} - -#endif /* MIR_GRAPHICS_NATIVE_BUFFER_H_ */ diff --git a/include/platform/mir/graphics/buffer.h b/include/platform/mir/graphics/buffer.h index 0d6b0f79b1b..0aed4e83074 100644 --- a/include/platform/mir/graphics/buffer.h +++ b/include/platform/mir/graphics/buffer.h @@ -17,7 +17,6 @@ #ifndef MIR_GRAPHICS_BUFFER_H_ #define MIR_GRAPHICS_BUFFER_H_ -#include "mir/graphics/native_buffer.h" #include "mir/graphics/buffer_id.h" #include "mir/geometry/size.h" #include "mir_toolkit/common.h" @@ -35,8 +34,8 @@ class NativeBufferBase protected: NativeBufferBase() = default; virtual ~NativeBufferBase() = default; - NativeBufferBase(NativeBuffer const&) = delete; - NativeBufferBase operator=(NativeBuffer const&) = delete; + NativeBufferBase(NativeBufferBase const&) = delete; + NativeBufferBase operator=(NativeBufferBase const&) = delete; }; class Buffer diff --git a/src/platforms/gbm-kms/include/native_buffer.h b/src/platforms/gbm-kms/include/native_buffer.h deleted file mode 100644 index 00a3b3abcfc..00000000000 --- a/src/platforms/gbm-kms/include/native_buffer.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright © Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License version 2 or 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -#ifndef MIR_GRAPHICS_GBM_NATIVE_BUFFER_H_ -#define MIR_GRAPHICS_GBM_NATIVE_BUFFER_H_ - -#include -#include "mir/graphics/native_buffer.h" - -#include -#include - -namespace mir -{ -namespace graphics -{ -namespace gbm -{ -struct NativeBuffer : graphics::NativeBuffer, MirBufferPackage -{ - struct gbm_bo *bo; - bool is_gbm_buffer; - uint32_t native_format; - uint32_t native_flags; -}; -} -} -} - -#endif /* MIR_GRAPHICS_GBM_NATIVE_BUFFER_H_ */ diff --git a/src/platforms/gbm-kms/server/kms/display_buffer.cpp b/src/platforms/gbm-kms/server/kms/display_buffer.cpp index 20d6e21a134..296dfb52c7a 100644 --- a/src/platforms/gbm-kms/server/kms/display_buffer.cpp +++ b/src/platforms/gbm-kms/server/kms/display_buffer.cpp @@ -21,7 +21,6 @@ #include "bypass.h" #include "mir/fatal.h" #include "mir/log.h" -#include "native_buffer.h" #include "display_helpers.h" #include "egl_helper.h" #include "mir/graphics/egl_error.h" diff --git a/tests/include/mir/test/doubles/mock_buffer.h b/tests/include/mir/test/doubles/mock_buffer.h index df23d016d4c..3115be20f70 100644 --- a/tests/include/mir/test/doubles/mock_buffer.h +++ b/tests/include/mir/test/doubles/mock_buffer.h @@ -55,18 +55,14 @@ struct MockBuffer : public graphics::Buffer, public graphics::NativeBufferBase ON_CALL(*this, id()) .WillByDefault(Return(graphics::BufferID{4})); - ON_CALL(*this, native_buffer_handle()) - .WillByDefault(Return(std::shared_ptr())); } - MOCK_CONST_METHOD0(size, geometry::Size()); - MOCK_CONST_METHOD0(pixel_format, MirPixelFormat()); - MOCK_CONST_METHOD0(native_buffer_handle, std::shared_ptr()); + MOCK_METHOD(geometry::Size, size, (), (const override)); + MOCK_METHOD(MirPixelFormat, pixel_format, (), (const override)); - MOCK_CONST_METHOD0(id, graphics::BufferID()); + MOCK_METHOD(graphics::BufferID, id, (), (const override)); - MOCK_METHOD0(native_buffer_base, graphics::NativeBufferBase*()); - MOCK_METHOD0(used_as_texture, void()); + MOCK_METHOD(graphics::NativeBufferBase*, native_buffer_base, (), (override)); }; } diff --git a/tests/include/mir/test/doubles/stub_buffer.h b/tests/include/mir/test/doubles/stub_buffer.h index c5511c4abd8..e45325547b9 100644 --- a/tests/include/mir/test/doubles/stub_buffer.h +++ b/tests/include/mir/test/doubles/stub_buffer.h @@ -25,10 +25,6 @@ #include #include -#include -#include -#include - namespace mir { namespace test @@ -44,7 +40,6 @@ class StubBuffer : public: StubBuffer() : StubBuffer{ - nullptr, graphics::BufferProperties{ geometry::Size{}, mir_pixel_format_abgr_8888, @@ -56,7 +51,6 @@ class StubBuffer : StubBuffer(geometry::Size const& size) : StubBuffer{ - nullptr, graphics::BufferProperties{ size, mir_pixel_format_abgr_8888, @@ -66,9 +60,8 @@ class StubBuffer : { } - StubBuffer(std::shared_ptr const& native_buffer, geometry::Size const& size, MirPixelFormat const pixel_format) + StubBuffer(geometry::Size const& size, MirPixelFormat const pixel_format) : StubBuffer{ - native_buffer, graphics::BufferProperties{ size, pixel_format, @@ -78,13 +71,8 @@ class StubBuffer : { } - StubBuffer(std::shared_ptr const& native_buffer) - : StubBuffer{native_buffer, {}, mir_pixel_format_abgr_8888} - { - } - StubBuffer(graphics::BufferProperties const& properties) - : StubBuffer{nullptr, properties, geometry::Stride{properties.size.width.as_int() * MIR_BYTES_PER_PIXEL(properties.format)}} + : StubBuffer{properties, geometry::Stride{properties.size.width.as_int() * MIR_BYTES_PER_PIXEL(properties.format)}} { written_pixels.resize(buf_size.height.as_uint32_t() * buf_stride.as_uint32_t()); if (written_pixels.size()) @@ -95,19 +83,16 @@ class StubBuffer : } StubBuffer(graphics::BufferID id) - : native_buffer(nullptr), - buf_size{}, + : buf_size{}, buf_pixel_format{mir_pixel_format_abgr_8888}, buf_stride{}, buf_id{id} { } - StubBuffer(std::shared_ptr const& native_buffer, - graphics::BufferProperties const& properties, + StubBuffer(graphics::BufferProperties const& properties, geometry::Stride stride) - : native_buffer(native_buffer), - buf_size{properties.size}, + : buf_size{properties.size}, buf_pixel_format{properties.format}, buf_stride{stride}, buf_id{graphics::BufferBasic::id()} @@ -190,7 +175,6 @@ class StubBuffer : return this; } - std::shared_ptr const native_buffer; geometry::Size const buf_size; MirPixelFormat const buf_pixel_format; geometry::Stride const buf_stride; diff --git a/tests/include/mir/test/doubles/stub_buffer_stream.h b/tests/include/mir/test/doubles/stub_buffer_stream.h index 5a79d27b76f..2f90b265e9a 100644 --- a/tests/include/mir/test/doubles/stub_buffer_stream.h +++ b/tests/include/mir/test/doubles/stub_buffer_stream.h @@ -19,7 +19,6 @@ #include #include -#include "mir_test_framework/stub_platform_native_buffer.h" namespace mir { @@ -33,8 +32,7 @@ class StubBufferStream : public compositor::BufferStream public: StubBufferStream() { - stub_compositor_buffer = std::make_shared( - std::make_shared(graphics::BufferProperties{})); + stub_compositor_buffer = std::make_shared(); } diff --git a/tests/include/mir_test_framework/stub_platform_native_buffer.h b/tests/include/mir_test_framework/stub_platform_native_buffer.h deleted file mode 100644 index 2f2c338faf4..00000000000 --- a/tests/include/mir_test_framework/stub_platform_native_buffer.h +++ /dev/null @@ -1,37 +0,0 @@ - -#ifndef MIR_TEST_FRAMEWORK_STUB_PLATFORM_NATIVE_BUFFER_H_ -#define MIR_TEST_FRAMEWORK_STUB_PLATFORM_NATIVE_BUFFER_H_ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace mir_test_framework -{ -//just a simple FD and int, helps to check for leaks/memory issues. -struct NativeBuffer : mir::graphics::NativeBuffer -{ - NativeBuffer(mir::graphics::BufferProperties const& properties) : - properties(properties) - { - if (fd < 0) - { - BOOST_THROW_EXCEPTION( - boost::enable_error_info( - std::system_error(errno, std::system_category(), "Failed to open dummy fd"))); - } - } - int const data {0x328}; - mir::Fd const fd{open("/dev/zero", O_RDONLY)}; - mir::graphics::BufferProperties const properties; -}; -} -#endif /* MIR_TEST_FRAMEWORK_STUB_PLATFORM_NATIVE_BUFFER_H_ */ diff --git a/tests/mir_test_doubles/stub_buffer_allocator.cpp b/tests/mir_test_doubles/stub_buffer_allocator.cpp index 5a4c0177816..fd3a30d2e2e 100644 --- a/tests/mir_test_doubles/stub_buffer_allocator.cpp +++ b/tests/mir_test_doubles/stub_buffer_allocator.cpp @@ -17,8 +17,6 @@ #include "mir/test/doubles/stub_buffer_allocator.h" #include "mir/test/doubles/stub_buffer.h" -#include "mir_test_framework/stub_platform_native_buffer.h" -#include "mir_toolkit/client_types.h" #include "src/platforms/common/server/shm_buffer.h" #include "mir/graphics/egl_context_executor.h" #include "mir/test/doubles/null_gl_context.h" @@ -28,6 +26,8 @@ #include #include +#include + namespace mtd = mir::test::doubles; namespace mg = mir::graphics; @@ -64,7 +64,7 @@ inline void memcpy_from_mapping(mir::renderer::software::ReadMappableBuffer& buf auto mtd::StubBufferAllocator::alloc_software_buffer(geometry::Size sz, MirPixelFormat pf) -> std::shared_ptr { graphics::BufferProperties properties{sz, pf, graphics::BufferUsage::software}; - return std::make_shared(std::make_shared(properties), properties, geometry::Stride{sz.width.as_uint32_t() * MIR_BYTES_PER_PIXEL(pf)}); + return std::make_shared(properties, geometry::Stride{sz.width.as_uint32_t() * MIR_BYTES_PER_PIXEL(pf)}); } auto mtd::StubBufferAllocator::supported_pixel_formats() -> std::vector diff --git a/tests/mir_test_framework/stub_session.cpp b/tests/mir_test_framework/stub_session.cpp index 81bc8756c1b..9b45e5ad415 100644 --- a/tests/mir_test_framework/stub_session.cpp +++ b/tests/mir_test_framework/stub_session.cpp @@ -15,8 +15,6 @@ */ #include "mir/test/doubles/stub_session.h" -#include "mir/test/doubles/stub_buffer.h" -#include "mir_test_framework/stub_platform_native_buffer.h" namespace mtd = mir::test::doubles; namespace ms = mir::scene; diff --git a/tests/mir_test_framework/stubbed_graphics_platform.cpp b/tests/mir_test_framework/stubbed_graphics_platform.cpp index 26ce2c68a64..30f23f28eca 100644 --- a/tests/mir_test_framework/stubbed_graphics_platform.cpp +++ b/tests/mir_test_framework/stubbed_graphics_platform.cpp @@ -17,18 +17,16 @@ #include "stubbed_graphics_platform.h" #include "mir/graphics/platform.h" -#include "mir_test_framework/stub_platform_native_buffer.h" #include "mir_toolkit/common.h" #include "mir/test/doubles/stub_buffer_allocator.h" #include "mir/test/doubles/fake_display.h" -#include "mir/fd.h" #include "mir/assert_module_entry_point.h" #include #include -#include +#include namespace geom = mir::geometry; namespace mg = mir::graphics; diff --git a/tests/unit-tests/graphics/test_software_cursor.cpp b/tests/unit-tests/graphics/test_software_cursor.cpp index ec56d03d932..b2fa263bfef 100644 --- a/tests/unit-tests/graphics/test_software_cursor.cpp +++ b/tests/unit-tests/graphics/test_software_cursor.cpp @@ -498,7 +498,6 @@ TEST_F(SoftwareCursor, handles_argb_8888_buffer_with_stride) sz.width.as_uint32_t() * MIR_BYTES_PER_PIXEL(pf) + 41 }; auto buffer = std::make_shared( - nullptr, mg::BufferProperties{ sz, pf, diff --git a/tests/unit-tests/input/test_touchspot_controller.cpp b/tests/unit-tests/input/test_touchspot_controller.cpp index 194a59942d2..23539cc1659 100644 --- a/tests/unit-tests/input/test_touchspot_controller.cpp +++ b/tests/unit-tests/input/test_touchspot_controller.cpp @@ -129,7 +129,6 @@ TEST_F(TestTouchspotController, handles_stride_mismatch_in_buffer) { mg::BufferProperties properties{size, pf, mg::BufferUsage::software}; return std::make_shared( - nullptr, properties, geom::Stride{size.width.as_uint32_t() * MIR_BYTES_PER_PIXEL(pf) + 29}); // Return a stride != width }));