Skip to content

Commit

Permalink
platform: Drop NativeBuffer detritus
Browse files Browse the repository at this point in the history
Turns out there's *still* a bunch of only-used-by-mirclient
detritus in the platform code. Remove this bit.
  • Loading branch information
RAOF committed Aug 29, 2023
1 parent e4bc180 commit 008210f
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 161 deletions.
35 changes: 0 additions & 35 deletions include/common/mir/graphics/native_buffer.h

This file was deleted.

5 changes: 2 additions & 3 deletions include/platform/mir/graphics/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
43 changes: 0 additions & 43 deletions src/platforms/gbm-kms/include/native_buffer.h

This file was deleted.

1 change: 0 additions & 1 deletion src/platforms/gbm-kms/server/kms/display_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 4 additions & 8 deletions tests/include/mir/test/doubles/mock_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<graphics::NativeBuffer>()));
}

MOCK_CONST_METHOD0(size, geometry::Size());
MOCK_CONST_METHOD0(pixel_format, MirPixelFormat());
MOCK_CONST_METHOD0(native_buffer_handle, std::shared_ptr<graphics::NativeBuffer>());
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));
};

}
Expand Down
26 changes: 5 additions & 21 deletions tests/include/mir/test/doubles/stub_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
#include <vector>
#include <string.h>

#include <boost/throw_exception.hpp>
#include <exception>
#include <stdexcept>

namespace mir
{
namespace test
Expand All @@ -44,7 +40,6 @@ class StubBuffer :
public:
StubBuffer()
: StubBuffer{
nullptr,
graphics::BufferProperties{
geometry::Size{},
mir_pixel_format_abgr_8888,
Expand All @@ -56,7 +51,6 @@ class StubBuffer :

StubBuffer(geometry::Size const& size)
: StubBuffer{
nullptr,
graphics::BufferProperties{
size,
mir_pixel_format_abgr_8888,
Expand All @@ -66,9 +60,8 @@ class StubBuffer :
{
}

StubBuffer(std::shared_ptr<graphics::NativeBuffer> 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,
Expand All @@ -78,13 +71,8 @@ class StubBuffer :
{
}

StubBuffer(std::shared_ptr<graphics::NativeBuffer> 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())
Expand All @@ -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<graphics::NativeBuffer> 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()}
Expand Down Expand Up @@ -190,7 +175,6 @@ class StubBuffer :
return this;
}

std::shared_ptr<graphics::NativeBuffer> const native_buffer;
geometry::Size const buf_size;
MirPixelFormat const buf_pixel_format;
geometry::Stride const buf_stride;
Expand Down
4 changes: 1 addition & 3 deletions tests/include/mir/test/doubles/stub_buffer_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include <mir/compositor/buffer_stream.h>
#include <mir/test/doubles/stub_buffer.h>
#include "mir_test_framework/stub_platform_native_buffer.h"

namespace mir
{
Expand All @@ -33,8 +32,7 @@ class StubBufferStream : public compositor::BufferStream
public:
StubBufferStream()
{
stub_compositor_buffer = std::make_shared<StubBuffer>(
std::make_shared<mir_test_framework::NativeBuffer>(graphics::BufferProperties{}));
stub_compositor_buffer = std::make_shared<StubBuffer>();
}


Expand Down
37 changes: 0 additions & 37 deletions tests/include/mir_test_framework/stub_platform_native_buffer.h

This file was deleted.

6 changes: 3 additions & 3 deletions tests/mir_test_doubles/stub_buffer_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -28,6 +26,8 @@
#include <vector>
#include <memory>

#include <boost/throw_exception.hpp>

namespace mtd = mir::test::doubles;
namespace mg = mir::graphics;

Expand Down Expand Up @@ -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<mg::Buffer>
{
graphics::BufferProperties properties{sz, pf, graphics::BufferUsage::software};
return std::make_shared<StubBuffer>(std::make_shared<mir_test_framework::NativeBuffer>(properties), properties, geometry::Stride{sz.width.as_uint32_t() * MIR_BYTES_PER_PIXEL(pf)});
return std::make_shared<StubBuffer>(properties, geometry::Stride{sz.width.as_uint32_t() * MIR_BYTES_PER_PIXEL(pf)});
}

auto mtd::StubBufferAllocator::supported_pixel_formats() -> std::vector<MirPixelFormat>
Expand Down
2 changes: 0 additions & 2 deletions tests/mir_test_framework/stub_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions tests/mir_test_framework/stubbed_graphics_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <boost/exception/errinfo_errno.hpp>
#include <boost/throw_exception.hpp>

#include <system_error>
#include <stdexcept>

namespace geom = mir::geometry;
namespace mg = mir::graphics;
Expand Down
1 change: 0 additions & 1 deletion tests/unit-tests/graphics/test_software_cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<mtd::StubBuffer>(
nullptr,
mg::BufferProperties{
sz,
pf,
Expand Down
1 change: 0 additions & 1 deletion tests/unit-tests/input/test_touchspot_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ TEST_F(TestTouchspotController, handles_stride_mismatch_in_buffer)
{
mg::BufferProperties properties{size, pf, mg::BufferUsage::software};
return std::make_shared<mtd::StubBuffer>(
nullptr,
properties,
geom::Stride{size.width.as_uint32_t() * MIR_BYTES_PER_PIXEL(pf) + 29}); // Return a stride != width
}));
Expand Down

0 comments on commit 008210f

Please sign in to comment.