Mir

Merge lp:~alan-griffiths/mir/remove-BufferInitializer into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1987
Proposed branch: lp:~alan-griffiths/mir/remove-BufferInitializer
Merge into: lp:mir
Diff against target: 1233 lines (+75/-348)
41 files modified
examples/render_overlays.cpp (+1/-1)
include/platform/mir/graphics/native_platform.h (+1/-3)
include/platform/mir/graphics/platform.h (+1/-6)
include/server/mir/default_server_configuration.h (+0/-3)
platform-ABI-sha1sums (+2/-2)
playground/render_surfaces.cpp (+17/-46)
server-ABI-sha1sums (+3/-3)
src/include/platform/mir/graphics/buffer_initializer.h (+0/-54)
src/platform/graphics/android/android_buffer_allocator.cpp (+3/-6)
src/platform/graphics/android/android_graphic_buffer_allocator.h (+1/-4)
src/platform/graphics/android/platform.cpp (+6/-10)
src/platform/graphics/android/platform.h (+2/-4)
src/platform/graphics/mesa/buffer_allocator.cpp (+0/-8)
src/platform/graphics/mesa/buffer_allocator.h (+1/-5)
src/platform/graphics/mesa/native_platform.cpp (+2/-4)
src/platform/graphics/mesa/native_platform.h (+1/-2)
src/platform/graphics/mesa/platform.cpp (+2/-3)
src/platform/graphics/mesa/platform.h (+1/-2)
src/server/graphics/default_configuration.cpp (+1/-12)
src/server/graphics/nested/nested_platform.cpp (+2/-3)
src/server/graphics/nested/nested_platform.h (+1/-2)
tests/acceptance-tests/test_display_configuration.cpp (+1/-2)
tests/acceptance-tests/test_nested_mir.cpp (+2/-3)
tests/include/mir_test_doubles/mock_buffer_initializer.h (+0/-48)
tests/include/mir_test_doubles/null_platform.h (+1/-2)
tests/integration-tests/client/test_client_render.cpp (+1/-3)
tests/integration-tests/graphics/android/test_buffer_integration.cpp (+3/-6)
tests/integration-tests/graphics/android/test_display_integration.cpp (+1/-3)
tests/integration-tests/graphics/android/test_internal_client.cpp (+1/-3)
tests/integration-tests/graphics/mesa/test_buffer_integration.cpp (+2/-5)
tests/integration-tests/test_display_info.cpp (+1/-2)
tests/integration-tests/test_drm_auth_magic.cpp (+1/-2)
tests/integration-tests/test_surfaceloop.cpp (+1/-2)
tests/mir_test_framework/stubbed_server_configuration.cpp (+1/-2)
tests/unit-tests/frontend/test_session_mediator.cpp (+2/-2)
tests/unit-tests/frontend/test_session_mediator_mesa.cpp (+1/-2)
tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp (+3/-39)
tests/unit-tests/graphics/mesa/test_buffer_allocator.cpp (+1/-28)
tests/unit-tests/graphics/mesa/test_gbm_buffer.cpp (+1/-4)
tests/unit-tests/graphics/nested/test_nested_platform.cpp (+1/-2)
tests/unit-tests/graphics/test_graphics_platform.cpp (+2/-5)
To merge this branch: bzr merge lp:~alan-griffiths/mir/remove-BufferInitializer
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alexandros Frantzis (community) Approve
Kevin DuBois (community) Approve
Review via email: mp+238549@code.launchpad.net

Commit message

graphics: remove BufferInitializer

Description of the change

graphics: remove BufferInitializer

This isn't a useful customization point - it was only ever used in render_surfaces and it wasn't needed there.

Although changing the signature of Platform::create_buffer_allocator() is an API change, that API isn't used in any downstream that I know of.

To post a comment you must log in.
Revision history for this message
Kevin DuBois (kdub) wrote :

Its one of the older classes in the code, and I agree that it hasn't gotten much useful customization and use, so I'm okay with its removal. This does break platform api, not sure what to do about that (sometimes we increment, sometimes we don't). I'd guess because this doesn't reach very far outside of the mir project we shouldn't increment. Apart from that issue though, approve.

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

Not related to this change: where did the green background for render_surfaces go?

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Its one of the older classes in the code, and I agree that it hasn't gotten
> much useful customization and use, so I'm okay with its removal. This does
> break platform api, not sure what to do about that (sometimes we increment,
> sometimes we don't). I'd guess because this doesn't reach very far outside of
> the mir project we shouldn't increment. Apart from that issue though, approve.

We do need to sort out the platform API (e.g. publish the headers needed to implement a driver platform). But I think that's for another MP.

1990. By Alan Griffiths

spike making render_surfaces an example once more

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/render_overlays.cpp'
--- examples/render_overlays.cpp 2014-10-06 03:02:44 +0000
+++ examples/render_overlays.cpp 2014-10-16 14:20:32 +0000
@@ -169,7 +169,7 @@
169169
170 auto platform = conf.the_graphics_platform();170 auto platform = conf.the_graphics_platform();
171 auto display = conf.the_display();171 auto display = conf.the_display();
172 auto buffer_allocator = platform->create_buffer_allocator(conf.the_buffer_initializer());172 auto buffer_allocator = platform->create_buffer_allocator();
173173
174 mg::BufferProperties buffer_properties{174 mg::BufferProperties buffer_properties{
175 geom::Size{512, 512},175 geom::Size{512, 512},
176176
=== modified file 'include/platform/mir/graphics/native_platform.h'
--- include/platform/mir/graphics/native_platform.h 2014-10-06 03:02:44 +0000
+++ include/platform/mir/graphics/native_platform.h 2014-10-16 14:20:32 +0000
@@ -32,7 +32,6 @@
32namespace graphics32namespace graphics
33{33{
34class GraphicBufferAllocator;34class GraphicBufferAllocator;
35class BufferInitializer;
36class PlatformIPCPackage;35class PlatformIPCPackage;
37class InternalClient;36class InternalClient;
38class BufferIpcMessage;37class BufferIpcMessage;
@@ -48,8 +47,7 @@
4847
49 virtual void initialize(std::shared_ptr<NestedContext> const& nested_context) = 0;48 virtual void initialize(std::shared_ptr<NestedContext> const& nested_context) = 0;
5049
51 virtual std::shared_ptr<GraphicBufferAllocator> create_buffer_allocator(50 virtual std::shared_ptr<GraphicBufferAllocator> create_buffer_allocator() = 0;
52 std::shared_ptr<BufferInitializer> const& buffer_initializer) = 0;
5351
54 virtual std::shared_ptr<PlatformIPCPackage> connection_ipc_package() = 0;52 virtual std::shared_ptr<PlatformIPCPackage> connection_ipc_package() = 0;
5553
5654
=== modified file 'include/platform/mir/graphics/platform.h'
--- include/platform/mir/graphics/platform.h 2014-09-24 17:01:33 +0000
+++ include/platform/mir/graphics/platform.h 2014-10-16 14:20:32 +0000
@@ -44,7 +44,6 @@
44{44{
45class Buffer;45class Buffer;
46class Display;46class Display;
47class BufferInitializer;
48class InternalClient;47class InternalClient;
49class DisplayReport;48class DisplayReport;
50class DisplayConfigurationPolicy;49class DisplayConfigurationPolicy;
@@ -75,12 +74,8 @@
7574
76 /**75 /**
77 * Creates the buffer allocator subsystem.76 * Creates the buffer allocator subsystem.
78 *
79 * \param [in] buffer_initializer the object responsible for initializing the buffers
80 */77 */
8178 virtual std::shared_ptr<GraphicBufferAllocator> create_buffer_allocator() = 0;
82 virtual std::shared_ptr<GraphicBufferAllocator> create_buffer_allocator(
83 std::shared_ptr<BufferInitializer> const& buffer_initializer) = 0;
84 79
85 virtual std::shared_ptr<BufferWriter> make_buffer_writer() = 0;80 virtual std::shared_ptr<BufferWriter> make_buffer_writer() = 0;
8681
8782
=== modified file 'include/server/mir/default_server_configuration.h'
--- include/server/mir/default_server_configuration.h 2014-10-14 11:48:16 +0000
+++ include/server/mir/default_server_configuration.h 2014-10-16 14:20:32 +0000
@@ -107,7 +107,6 @@
107class NativePlatform;107class NativePlatform;
108class Platform;108class Platform;
109class Display;109class Display;
110class BufferInitializer;
111class DisplayReport;110class DisplayReport;
112class GraphicBufferAllocator;111class GraphicBufferAllocator;
113class BufferWriter;112class BufferWriter;
@@ -189,7 +188,6 @@
189 /** @name graphics configuration - customization188 /** @name graphics configuration - customization
190 * configurable interfaces for modifying graphics189 * configurable interfaces for modifying graphics
191 * @{ */190 * @{ */
192 virtual std::shared_ptr<graphics::BufferInitializer> the_buffer_initializer();
193 virtual std::shared_ptr<compositor::RendererFactory> the_renderer_factory();191 virtual std::shared_ptr<compositor::RendererFactory> the_renderer_factory();
194 virtual std::shared_ptr<graphics::DisplayConfigurationPolicy> the_display_configuration_policy();192 virtual std::shared_ptr<graphics::DisplayConfigurationPolicy> the_display_configuration_policy();
195 virtual std::shared_ptr<graphics::nested::HostConnection> the_host_connection();193 virtual std::shared_ptr<graphics::nested::HostConnection> the_host_connection();
@@ -372,7 +370,6 @@
372 CachedPtr<input::TouchVisualizer> touch_visualizer;370 CachedPtr<input::TouchVisualizer> touch_visualizer;
373 CachedPtr<graphics::Platform> graphics_platform;371 CachedPtr<graphics::Platform> graphics_platform;
374 CachedPtr<graphics::NativePlatform> graphics_native_platform;372 CachedPtr<graphics::NativePlatform> graphics_native_platform;
375 CachedPtr<graphics::BufferInitializer> buffer_initializer;
376 CachedPtr<graphics::GraphicBufferAllocator> buffer_allocator;373 CachedPtr<graphics::GraphicBufferAllocator> buffer_allocator;
377 CachedPtr<graphics::BufferWriter> buffer_writer;374 CachedPtr<graphics::BufferWriter> buffer_writer;
378 CachedPtr<graphics::Display> display;375 CachedPtr<graphics::Display> display;
379376
=== modified file 'platform-ABI-sha1sums'
--- platform-ABI-sha1sums 2014-10-06 03:02:44 +0000
+++ platform-ABI-sha1sums 2014-10-16 14:20:32 +0000
@@ -35,8 +35,8 @@
35979d2c1ac723ccef538d9a378228a02b0f173bd7 include/platform/mir/graphics/graphic_buffer_allocator.h35979d2c1ac723ccef538d9a378228a02b0f173bd7 include/platform/mir/graphics/graphic_buffer_allocator.h
36f90a35371e236a6cfec8e9a8474dbb3305c7621e include/platform/mir/graphics/internal_client.h36f90a35371e236a6cfec8e9a8474dbb3305c7621e include/platform/mir/graphics/internal_client.h
37c9730cac4a3a101f9706ec6f444958abe047fd88 include/platform/mir/graphics/internal_surface.h37c9730cac4a3a101f9706ec6f444958abe047fd88 include/platform/mir/graphics/internal_surface.h
38b4aaa941df9c0a6f9342629b26542700876f3aaa include/platform/mir/graphics/native_platform.h38d4ab0ef9544345fcc85740f6ed6d8118728a5c59 include/platform/mir/graphics/native_platform.h
39f47dac961f060eb29a44ed3c8c18a49a3d353bb1 include/platform/mir/graphics/platform.h39109d2c82d245a512e7c1790a3b853c9c275ebd4d include/platform/mir/graphics/platform.h
401fbe488b4581486fd01e2f03e504f31b72c09040 include/platform/mir/graphics/platform_ipc_operations.h401fbe488b4581486fd01e2f03e504f31b72c09040 include/platform/mir/graphics/platform_ipc_operations.h
419c7712af84b6fde1970ff802ad2ea78f892c7b7e include/platform/mir/graphics/platform_ipc_package.h419c7712af84b6fde1970ff802ad2ea78f892c7b7e include/platform/mir/graphics/platform_ipc_package.h
4284c063346b3bd51b4624d9f940008d4c3f8be066 include/platform/mir/graphics/renderable.h4284c063346b3bd51b4624d9f940008d4c3f8be066 include/platform/mir/graphics/renderable.h
4343
=== modified file 'playground/render_surfaces.cpp'
--- playground/render_surfaces.cpp 2014-09-12 05:56:28 +0000
+++ playground/render_surfaces.cpp 2014-10-16 14:20:32 +0000
@@ -25,7 +25,6 @@
25#include "mir/scene/surface_creation_parameters.h"25#include "mir/scene/surface_creation_parameters.h"
26#include "mir/geometry/size.h"26#include "mir/geometry/size.h"
27#include "mir/geometry/rectangles.h"27#include "mir/geometry/rectangles.h"
28#include "mir/graphics/buffer_initializer.h"
29#include "mir/graphics/display.h"28#include "mir/graphics/display.h"
30#include "mir/graphics/display_buffer.h"29#include "mir/graphics/display_buffer.h"
31#include "mir/graphics/gl_context.h"30#include "mir/graphics/gl_context.h"
@@ -72,9 +71,7 @@
72///\section RenderSurfacesServerConfiguration RenderSurfacesServerConfiguration71///\section RenderSurfacesServerConfiguration RenderSurfacesServerConfiguration
73/// The configuration stubs out client connectivity and input.72/// The configuration stubs out client connectivity and input.
74/// \snippet render_surfaces.cpp RenderSurfacesServerConfiguration_stubs_tag73/// \snippet render_surfaces.cpp RenderSurfacesServerConfiguration_stubs_tag
75/// it also provides a bespoke buffer initializer74/// it also provides a bespoke display buffer compositor
76/// \snippet render_surfaces.cpp RenderResourcesBufferInitializer_tag
77/// and a bespoke display buffer compositor
78/// \snippet render_surfaces.cpp RenderSurfacesDisplayBufferCompositor_tag75/// \snippet render_surfaces.cpp RenderSurfacesDisplayBufferCompositor_tag
79///\section Utilities Utility classes76///\section Utilities Utility classes
80/// For smooth animation we need to track time and move surfaces accordingly77/// For smooth animation we need to track time and move surfaces accordingly
@@ -248,41 +245,6 @@
248 }245 }
249 ///\internal [RenderSurfacesServerConfiguration_stubs_tag]246 ///\internal [RenderSurfacesServerConfiguration_stubs_tag]
250247
251 ///\internal [RenderResourcesBufferInitializer_tag]
252 // Override for a bespoke buffer initializer
253 std::shared_ptr<mg::BufferInitializer> the_buffer_initializer() override
254 {
255 class RenderResourcesBufferInitializer : public mg::BufferInitializer
256 {
257 public:
258 RenderResourcesBufferInitializer(std::unique_ptr<mg::GLContext> gl_context)
259 : gl_context{std::move(gl_context)}
260 {
261 }
262
263 void operator()(mg::Buffer& buffer)
264 {
265 auto using_gl_context = mir::raii::paired_calls(
266 [this] { gl_context->make_current(); },
267 [this] { gl_context->release_current(); });
268
269 mt::ImageRenderer img_renderer{mir_image.pixel_data,
270 geom::Size{mir_image.width, mir_image.height},
271 mir_image.bytes_per_pixel};
272 mt::BufferRenderTarget brt{buffer};
273 brt.make_current();
274 img_renderer.render();
275 }
276
277 private:
278 std::unique_ptr<mg::GLContext> const gl_context;
279
280 };
281
282 return std::make_shared<RenderResourcesBufferInitializer>(the_display()->create_gl_context());
283 }
284 ///\internal [RenderResourcesBufferInitializer_tag]
285
286 // Unless the compositor starts before we create the surfaces it won't respond to248 // Unless the compositor starts before we create the surfaces it won't respond to
287 // the change notification that causes.249 // the change notification that causes.
288 std::shared_ptr<mir::ServerStatusListener> the_server_status_listener()250 std::shared_ptr<mir::ServerStatusListener> the_server_status_listener()
@@ -389,6 +351,8 @@
389351
390 auto const display = the_display();352 auto const display = the_display();
391 auto const surface_coordinator = the_surface_coordinator();353 auto const surface_coordinator = the_surface_coordinator();
354 auto const gl_context = the_display()->create_gl_context();
355
392 /* TODO: Get proper configuration */356 /* TODO: Get proper configuration */
393 geom::Rectangles view_area;357 geom::Rectangles view_area;
394 display->for_each_display_buffer([&view_area](mg::DisplayBuffer const& db)358 display->for_each_display_buffer([&view_area](mg::DisplayBuffer const& db)
@@ -413,16 +377,23 @@
413 .of_buffer_usage(mg::BufferUsage::hardware),377 .of_buffer_usage(mg::BufferUsage::hardware),
414 nullptr);378 nullptr);
415379
416 /*
417 * We call swap_buffers() twice so that the surface is
418 * considers the first buffer to be posted.
419 * (TODO There must be a better way!)
420 */
421 {380 {
422 mg::Buffer* buffer{nullptr};381 mg::Buffer* buffer{nullptr};
423 auto const complete = [&](mg::Buffer* new_buf){ buffer = new_buf; };382 auto const complete = [&](mg::Buffer* new_buf){ buffer = new_buf; };
424 s->swap_buffers(buffer, complete);383 s->swap_buffers(buffer, complete); // Fetch buffer for rendering
425 s->swap_buffers(buffer, complete);384 {
385 auto using_gl_context = mir::raii::paired_calls(
386 [&gl_context] { gl_context->make_current(); },
387 [&gl_context] { gl_context->release_current(); });
388
389 mt::ImageRenderer img_renderer{mir_image.pixel_data,
390 geom::Size{mir_image.width, mir_image.height},
391 mir_image.bytes_per_pixel};
392 mt::BufferRenderTarget brt{*buffer};
393 brt.make_current();
394 img_renderer.render();
395 }
396 s->swap_buffers(buffer, complete); // Post rendered buffer
426 }397 }
427398
428 /*399 /*
429400
=== modified file 'server-ABI-sha1sums'
--- server-ABI-sha1sums 2014-10-16 09:24:18 +0000
+++ server-ABI-sha1sums 2014-10-16 14:20:32 +0000
@@ -35,8 +35,8 @@
35979d2c1ac723ccef538d9a378228a02b0f173bd7 include/platform/mir/graphics/graphic_buffer_allocator.h35979d2c1ac723ccef538d9a378228a02b0f173bd7 include/platform/mir/graphics/graphic_buffer_allocator.h
36f90a35371e236a6cfec8e9a8474dbb3305c7621e include/platform/mir/graphics/internal_client.h36f90a35371e236a6cfec8e9a8474dbb3305c7621e include/platform/mir/graphics/internal_client.h
37c9730cac4a3a101f9706ec6f444958abe047fd88 include/platform/mir/graphics/internal_surface.h37c9730cac4a3a101f9706ec6f444958abe047fd88 include/platform/mir/graphics/internal_surface.h
38b4aaa941df9c0a6f9342629b26542700876f3aaa include/platform/mir/graphics/native_platform.h38d4ab0ef9544345fcc85740f6ed6d8118728a5c59 include/platform/mir/graphics/native_platform.h
39f47dac961f060eb29a44ed3c8c18a49a3d353bb1 include/platform/mir/graphics/platform.h39109d2c82d245a512e7c1790a3b853c9c275ebd4d include/platform/mir/graphics/platform.h
401fbe488b4581486fd01e2f03e504f31b72c09040 include/platform/mir/graphics/platform_ipc_operations.h401fbe488b4581486fd01e2f03e504f31b72c09040 include/platform/mir/graphics/platform_ipc_operations.h
419c7712af84b6fde1970ff802ad2ea78f892c7b7e include/platform/mir/graphics/platform_ipc_package.h419c7712af84b6fde1970ff802ad2ea78f892c7b7e include/platform/mir/graphics/platform_ipc_package.h
4284c063346b3bd51b4624d9f940008d4c3f8be066 include/platform/mir/graphics/renderable.h4284c063346b3bd51b4624d9f940008d4c3f8be066 include/platform/mir/graphics/renderable.h
@@ -48,7 +48,7 @@
48a9f284ba4b05d58fd3eeb628d1f56fe4ac188526 include/server/mir/compositor/compositor_id.h48a9f284ba4b05d58fd3eeb628d1f56fe4ac188526 include/server/mir/compositor/compositor_id.h
495205e30c5fdb5b5d8803064fc1abd102db59c4e7 include/server/mir/compositor/scene_element.h495205e30c5fdb5b5d8803064fc1abd102db59c4e7 include/server/mir/compositor/scene_element.h
504fcf34e424128b87ddc76733594e32e09ebbd486 include/server/mir/compositor/scene.h504fcf34e424128b87ddc76733594e32e09ebbd486 include/server/mir/compositor/scene.h
51afd4ec03c3aadc98b7dbee4e35d1d3bcb9a9334e include/server/mir/default_server_configuration.h51e1355c98730be9ba3d25480427f362d322631e88 include/server/mir/default_server_configuration.h
52af1ff0714be973ac76d56006a2e5991f68cd1dec include/server/mir/display_server.h52af1ff0714be973ac76d56006a2e5991f68cd1dec include/server/mir/display_server.h
53a35c5495d8fd28fc0e375b17495fc5caab51b329 include/server/mir/emergency_cleanup.h53a35c5495d8fd28fc0e375b17495fc5caab51b329 include/server/mir/emergency_cleanup.h
54938de641cb0e01e1098b007b39b151a7dfe4adc1 include/server/mir/frontend/display_changer.h54938de641cb0e01e1098b007b39b151a7dfe4adc1 include/server/mir/frontend/display_changer.h
5555
=== removed file 'src/include/platform/mir/graphics/buffer_initializer.h'
--- src/include/platform/mir/graphics/buffer_initializer.h 2014-09-11 05:51:44 +0000
+++ src/include/platform/mir/graphics/buffer_initializer.h 1970-01-01 00:00:00 +0000
@@ -1,54 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#ifndef MIR_GRAPHICS_BUFFER_INITIALIZER_H_
20#define MIR_GRAPHICS_BUFFER_INITIALIZER_H_
21
22namespace mir
23{
24namespace graphics
25{
26class Buffer;
27
28/**
29 * Interface to buffer initialization.
30 */
31class BufferInitializer
32{
33public:
34 virtual ~BufferInitializer() {}
35
36 /** Operator to call to initialize a buffer. */
37 virtual void operator()(Buffer& buffer) = 0;
38
39protected:
40 BufferInitializer() = default;
41 BufferInitializer(const BufferInitializer&) = delete;
42 BufferInitializer& operator=(const BufferInitializer&) = delete;
43};
44
45class NullBufferInitializer : public BufferInitializer
46{
47public:
48 void operator()(Buffer& /*buffer*/) {}
49};
50
51}
52}
53
54#endif /* MIR_GRAPHICS_BUFFER_INITIALIZER_H_ */
550
=== modified file 'src/platform/graphics/android/android_buffer_allocator.cpp'
--- src/platform/graphics/android/android_buffer_allocator.cpp 2014-09-19 03:08:20 +0000
+++ src/platform/graphics/android/android_buffer_allocator.cpp 2014-10-16 14:20:32 +0000
@@ -18,7 +18,6 @@
18 */18 */
1919
20#include "mir/graphics/platform.h"20#include "mir/graphics/platform.h"
21#include "mir/graphics/buffer_initializer.h"
22#include "mir/graphics/egl_extensions.h"21#include "mir/graphics/egl_extensions.h"
23#include "mir/graphics/buffer_properties.h"22#include "mir/graphics/buffer_properties.h"
24#include "mir/graphics/android/sync_fence.h"23#include "mir/graphics/android/sync_fence.h"
@@ -46,10 +45,8 @@
46};45};
47}46}
4847
49mga::AndroidGraphicBufferAllocator::AndroidGraphicBufferAllocator(48mga::AndroidGraphicBufferAllocator::AndroidGraphicBufferAllocator()
50 std::shared_ptr<BufferInitializer> const& buffer_initializer)49 : egl_extensions(std::make_shared<mg::EGLExtensions>())
51 : buffer_initializer(buffer_initializer),
52 egl_extensions(std::make_shared<mg::EGLExtensions>())
53{50{
54 int err;51 int err;
5552
@@ -82,7 +79,7 @@
82{79{
83 auto native_handle = alloc_device->alloc_buffer(sz, pf, use);80 auto native_handle = alloc_device->alloc_buffer(sz, pf, use);
84 auto buffer = std::make_shared<Buffer>(native_handle, egl_extensions);81 auto buffer = std::make_shared<Buffer>(native_handle, egl_extensions);
85 (*buffer_initializer)(*buffer);82
86 return buffer;83 return buffer;
87}84}
8885
8986
=== modified file 'src/platform/graphics/android/android_graphic_buffer_allocator.h'
--- src/platform/graphics/android/android_graphic_buffer_allocator.h 2014-03-06 06:05:17 +0000
+++ src/platform/graphics/android/android_graphic_buffer_allocator.h 2014-10-16 14:20:32 +0000
@@ -31,7 +31,6 @@
31namespace graphics31namespace graphics
32{32{
3333
34class BufferInitializer;
35class EGLExtensions;34class EGLExtensions;
3635
37namespace android36namespace android
@@ -42,8 +41,7 @@
42class AndroidGraphicBufferAllocator: public GraphicBufferAllocator, public graphics::GraphicBufferAllocator41class AndroidGraphicBufferAllocator: public GraphicBufferAllocator, public graphics::GraphicBufferAllocator
43{42{
44public:43public:
45 AndroidGraphicBufferAllocator(44 AndroidGraphicBufferAllocator();
46 std::shared_ptr<BufferInitializer> const& buffer_initializer);
4745
48 std::shared_ptr<graphics::Buffer> alloc_buffer(46 std::shared_ptr<graphics::Buffer> alloc_buffer(
49 graphics::BufferProperties const& buffer_properties);47 graphics::BufferProperties const& buffer_properties);
@@ -58,7 +56,6 @@
58private:56private:
59 const hw_module_t *hw_module;57 const hw_module_t *hw_module;
60 std::shared_ptr<GraphicAllocAdaptor> alloc_device;58 std::shared_ptr<GraphicAllocAdaptor> alloc_device;
61 std::shared_ptr<BufferInitializer> const buffer_initializer;
62 std::shared_ptr<EGLExtensions> const egl_extensions;59 std::shared_ptr<EGLExtensions> const egl_extensions;
63};60};
6461
6562
=== modified file 'src/platform/graphics/android/platform.cpp'
--- src/platform/graphics/android/platform.cpp 2014-09-30 06:11:33 +0000
+++ src/platform/graphics/android/platform.cpp 2014-10-16 14:20:32 +0000
@@ -30,7 +30,6 @@
30#include "mir/graphics/platform_ipc_package.h"30#include "mir/graphics/platform_ipc_package.h"
31#include "mir/graphics/buffer_ipc_message.h"31#include "mir/graphics/buffer_ipc_message.h"
32#include "mir/graphics/android/native_buffer.h"32#include "mir/graphics/android/native_buffer.h"
33#include "mir/graphics/buffer_initializer.h"
34#include "mir/graphics/buffer_id.h"33#include "mir/graphics/buffer_id.h"
35#include "mir/graphics/display_report.h"34#include "mir/graphics/display_report.h"
36#include "mir/options/option.h"35#include "mir/options/option.h"
@@ -90,12 +89,11 @@
90{89{
91}90}
9291
93std::shared_ptr<mg::GraphicBufferAllocator> mga::Platform::create_buffer_allocator(92std::shared_ptr<mg::GraphicBufferAllocator> mga::Platform::create_buffer_allocator()
94 std::shared_ptr<mg::BufferInitializer> const& buffer_initializer)
95{93{
96 if (quirks.gralloc_reopenable_after_close())94 if (quirks.gralloc_reopenable_after_close())
97 {95 {
98 return std::make_shared<mga::AndroidGraphicBufferAllocator>(buffer_initializer);96 return std::make_shared<mga::AndroidGraphicBufferAllocator>();
99 }97 }
100 else98 else
101 {99 {
@@ -104,15 +102,14 @@
104 std::unique_lock<std::mutex> lk(allocator_mutex);102 std::unique_lock<std::mutex> lk(allocator_mutex);
105 static std::shared_ptr<mg::GraphicBufferAllocator> preserved_allocator;103 static std::shared_ptr<mg::GraphicBufferAllocator> preserved_allocator;
106 if (!preserved_allocator)104 if (!preserved_allocator)
107 preserved_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(buffer_initializer);105 preserved_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>();
108 return preserved_allocator;106 return preserved_allocator;
109 }107 }
110}108}
111109
112std::shared_ptr<mga::GraphicBufferAllocator> mga::Platform::create_mga_buffer_allocator(110std::shared_ptr<mga::GraphicBufferAllocator> mga::Platform::create_mga_buffer_allocator()
113 std::shared_ptr<mg::BufferInitializer> const& buffer_initializer)
114{111{
115 return std::make_shared<mga::AndroidGraphicBufferAllocator>(buffer_initializer);112 return std::make_shared<mga::AndroidGraphicBufferAllocator>();
116}113}
117114
118std::shared_ptr<mg::PlatformIPCPackage> mga::Platform::connection_ipc_package()115std::shared_ptr<mg::PlatformIPCPackage> mga::Platform::connection_ipc_package()
@@ -167,9 +164,8 @@
167 auto logger = make_logger(*options);164 auto logger = make_logger(*options);
168 auto overlay_option = should_use_overlay_optimization(*options);165 auto overlay_option = should_use_overlay_optimization(*options);
169 logger->log_overlay_optimization(overlay_option);166 logger->log_overlay_optimization(overlay_option);
170 auto buffer_initializer = std::make_shared<mg::NullBufferInitializer>();
171 auto display_resource_factory = std::make_shared<mga::ResourceFactory>();167 auto display_resource_factory = std::make_shared<mga::ResourceFactory>();
172 auto fb_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(buffer_initializer);168 auto fb_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>();
173 auto display_builder = std::make_shared<mga::OutputBuilder>(169 auto display_builder = std::make_shared<mga::OutputBuilder>(
174 fb_allocator, display_resource_factory, display_report, overlay_option, logger);170 fb_allocator, display_resource_factory, display_report, overlay_option, logger);
175 return std::make_shared<mga::Platform>(display_builder, display_report);171 return std::make_shared<mga::Platform>(display_builder, display_report);
176172
=== modified file 'src/platform/graphics/android/platform.h'
--- src/platform/graphics/android/platform.h 2014-09-25 09:47:50 +0000
+++ src/platform/graphics/android/platform.h 2014-10-16 14:20:32 +0000
@@ -42,8 +42,7 @@
42 std::shared_ptr<DisplayReport> const& display_report);42 std::shared_ptr<DisplayReport> const& display_report);
4343
44 /* From Platform */44 /* From Platform */
45 std::shared_ptr<graphics::GraphicBufferAllocator> create_buffer_allocator(45 std::shared_ptr<graphics::GraphicBufferAllocator> create_buffer_allocator();
46 std::shared_ptr<BufferInitializer> const& buffer_initializer);
47 std::shared_ptr<Display> create_display(46 std::shared_ptr<Display> create_display(
48 std::shared_ptr<graphics::DisplayConfigurationPolicy> const&,47 std::shared_ptr<graphics::DisplayConfigurationPolicy> const&,
49 std::shared_ptr<graphics::GLProgramFactory> const&,48 std::shared_ptr<graphics::GLProgramFactory> const&,
@@ -62,8 +61,7 @@
6261
63 void initialize(std::shared_ptr<NestedContext> const& nested_context) override;62 void initialize(std::shared_ptr<NestedContext> const& nested_context) override;
6463
65 std::shared_ptr<GraphicBufferAllocator> create_mga_buffer_allocator(64 std::shared_ptr<GraphicBufferAllocator> create_mga_buffer_allocator();
66 std::shared_ptr<BufferInitializer> const& buffer_initializer);
6765
68 std::shared_ptr<DisplayBuilder> const display_builder;66 std::shared_ptr<DisplayBuilder> const display_builder;
69 std::shared_ptr<DisplayReport> const display_report;67 std::shared_ptr<DisplayReport> const display_report;
7068
=== modified file 'src/platform/graphics/mesa/buffer_allocator.cpp'
--- src/platform/graphics/mesa/buffer_allocator.cpp 2014-09-19 03:08:20 +0000
+++ src/platform/graphics/mesa/buffer_allocator.cpp 2014-10-16 14:20:32 +0000
@@ -23,7 +23,6 @@
23#include "buffer_texture_binder.h"23#include "buffer_texture_binder.h"
24#include "anonymous_shm_file.h"24#include "anonymous_shm_file.h"
25#include "shm_buffer.h"25#include "shm_buffer.h"
26#include "mir/graphics/buffer_initializer.h"
27#include "mir/graphics/egl_extensions.h"26#include "mir/graphics/egl_extensions.h"
28#include "mir/graphics/buffer_properties.h"27#include "mir/graphics/buffer_properties.h"
29#include <boost/throw_exception.hpp>28#include <boost/throw_exception.hpp>
@@ -110,15 +109,12 @@
110109
111mgm::BufferAllocator::BufferAllocator(110mgm::BufferAllocator::BufferAllocator(
112 gbm_device* device,111 gbm_device* device,
113 const std::shared_ptr<BufferInitializer>& buffer_initializer,
114 BypassOption bypass_option)112 BypassOption bypass_option)
115 : device(device),113 : device(device),
116 buffer_initializer(buffer_initializer),
117 egl_extensions(std::make_shared<mg::EGLExtensions>()),114 egl_extensions(std::make_shared<mg::EGLExtensions>()),
118 bypass_option(bypass_option)115 bypass_option(bypass_option)
119116
120{117{
121 assert(buffer_initializer.get() != 0);
122}118}
123119
124std::shared_ptr<mg::Buffer> mgm::BufferAllocator::alloc_buffer(120std::shared_ptr<mg::Buffer> mgm::BufferAllocator::alloc_buffer(
@@ -186,8 +182,6 @@
186 auto const buffer =182 auto const buffer =
187 std::make_shared<GBMBuffer>(bo, bo_flags, std::move(texture_binder));183 std::make_shared<GBMBuffer>(bo, bo_flags, std::move(texture_binder));
188184
189 (*buffer_initializer)(*buffer);
190
191 return buffer;185 return buffer;
192}186}
193187
@@ -213,8 +207,6 @@
213 std::make_shared<ShmBuffer>(shm_file, buffer_properties.size,207 std::make_shared<ShmBuffer>(shm_file, buffer_properties.size,
214 buffer_properties.format);208 buffer_properties.format);
215209
216 (*buffer_initializer)(*buffer);
217
218 return buffer;210 return buffer;
219}211}
220212
221213
=== modified file 'src/platform/graphics/mesa/buffer_allocator.h'
--- src/platform/graphics/mesa/buffer_allocator.h 2014-09-11 05:51:44 +0000
+++ src/platform/graphics/mesa/buffer_allocator.h 2014-10-16 14:20:32 +0000
@@ -34,7 +34,6 @@
34{34{
35namespace graphics35namespace graphics
36{36{
37class BufferInitializer;
38struct EGLExtensions;37struct EGLExtensions;
3938
40namespace mesa39namespace mesa
@@ -42,9 +41,7 @@
42class BufferAllocator: public graphics::GraphicBufferAllocator41class BufferAllocator: public graphics::GraphicBufferAllocator
43{42{
44public:43public:
45 BufferAllocator(gbm_device* device,44 BufferAllocator(gbm_device* device, BypassOption bypass_option);
46 std::shared_ptr<BufferInitializer> const& buffer_initializer,
47 BypassOption bypass_option);
4845
49 virtual std::shared_ptr<Buffer> alloc_buffer(46 virtual std::shared_ptr<Buffer> alloc_buffer(
50 graphics::BufferProperties const& buffer_properties);47 graphics::BufferProperties const& buffer_properties);
@@ -59,7 +56,6 @@
59 graphics::BufferProperties const& buffer_properties);56 graphics::BufferProperties const& buffer_properties);
6057
61 gbm_device* const device;58 gbm_device* const device;
62 std::shared_ptr<graphics::BufferInitializer> buffer_initializer;
63 std::shared_ptr<EGLExtensions> const egl_extensions;59 std::shared_ptr<EGLExtensions> const egl_extensions;
6460
65 BypassOption const bypass_option;61 BypassOption const bypass_option;
6662
=== modified file 'src/platform/graphics/mesa/native_platform.cpp'
--- src/platform/graphics/mesa/native_platform.cpp 2014-09-30 06:11:33 +0000
+++ src/platform/graphics/mesa/native_platform.cpp 2014-10-16 14:20:32 +0000
@@ -53,11 +53,9 @@
53 finish_internal_native_display();53 finish_internal_native_display();
54}54}
5555
56std::shared_ptr<mg::GraphicBufferAllocator> mgm::NativePlatform::create_buffer_allocator(56std::shared_ptr<mg::GraphicBufferAllocator> mgm::NativePlatform::create_buffer_allocator()
57 std::shared_ptr<mg::BufferInitializer> const& buffer_initializer)
58{57{
59 return std::make_shared<mgm::BufferAllocator>(58 return std::make_shared<mgm::BufferAllocator>(gbm.device, mgm::BypassOption::prohibited);
60 gbm.device, buffer_initializer, mgm::BypassOption::prohibited);
61}59}
6260
63std::shared_ptr<mg::PlatformIPCPackage> mgm::NativePlatform::connection_ipc_package()61std::shared_ptr<mg::PlatformIPCPackage> mgm::NativePlatform::connection_ipc_package()
6462
=== modified file 'src/platform/graphics/mesa/native_platform.h'
--- src/platform/graphics/mesa/native_platform.h 2014-09-24 17:01:33 +0000
+++ src/platform/graphics/mesa/native_platform.h 2014-10-16 14:20:32 +0000
@@ -38,8 +38,7 @@
38 virtual ~NativePlatform();38 virtual ~NativePlatform();
3939
40 void initialize(std::shared_ptr<NestedContext> const& nested_context);40 void initialize(std::shared_ptr<NestedContext> const& nested_context);
41 std::shared_ptr<GraphicBufferAllocator> create_buffer_allocator(41 std::shared_ptr<GraphicBufferAllocator> create_buffer_allocator() override;
42 std::shared_ptr<BufferInitializer> const& buffer_initializer) override;
43 std::shared_ptr<PlatformIPCPackage> connection_ipc_package() override;42 std::shared_ptr<PlatformIPCPackage> connection_ipc_package() override;
44 std::shared_ptr<InternalClient> create_internal_client() override;43 std::shared_ptr<InternalClient> create_internal_client() override;
45 void fill_buffer_package(44 void fill_buffer_package(
4645
=== modified file 'src/platform/graphics/mesa/platform.cpp'
--- src/platform/graphics/mesa/platform.cpp 2014-09-30 06:11:33 +0000
+++ src/platform/graphics/mesa/platform.cpp 2014-10-16 14:20:32 +0000
@@ -145,10 +145,9 @@
145}145}
146146
147147
148std::shared_ptr<mg::GraphicBufferAllocator> mgm::Platform::create_buffer_allocator(148std::shared_ptr<mg::GraphicBufferAllocator> mgm::Platform::create_buffer_allocator()
149 const std::shared_ptr<mg::BufferInitializer>& buffer_initializer)
150{149{
151 return std::make_shared<mgm::BufferAllocator>(gbm.device, buffer_initializer, bypass_option_);150 return std::make_shared<mgm::BufferAllocator>(gbm.device, bypass_option_);
152}151}
153152
154std::shared_ptr<mg::Display> mgm::Platform::create_display(153std::shared_ptr<mg::Display> mgm::Platform::create_display(
155154
=== modified file 'src/platform/graphics/mesa/platform.h'
--- src/platform/graphics/mesa/platform.h 2014-09-24 17:01:33 +0000
+++ src/platform/graphics/mesa/platform.h 2014-10-16 14:20:32 +0000
@@ -52,8 +52,7 @@
52 ~Platform();52 ~Platform();
5353
54 /* From Platform */54 /* From Platform */
55 std::shared_ptr<graphics::GraphicBufferAllocator> create_buffer_allocator(55 std::shared_ptr<graphics::GraphicBufferAllocator> create_buffer_allocator();
56 const std::shared_ptr<BufferInitializer>& buffer_initializer);
57 std::shared_ptr<graphics::BufferWriter> make_buffer_writer();56 std::shared_ptr<graphics::BufferWriter> make_buffer_writer();
58 std::shared_ptr<graphics::Display> create_display(57 std::shared_ptr<graphics::Display> create_display(
59 std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,58 std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
6059
=== modified file 'src/server/graphics/default_configuration.cpp'
--- src/server/graphics/default_configuration.cpp 2014-09-19 03:08:20 +0000
+++ src/server/graphics/default_configuration.cpp 2014-10-16 14:20:32 +0000
@@ -25,7 +25,6 @@
25#include "nested/nested_platform.h"25#include "nested/nested_platform.h"
26#include "offscreen/display.h"26#include "offscreen/display.h"
2727
28#include "mir/graphics/buffer_initializer.h"
29#include "mir/graphics/gl_config.h"28#include "mir/graphics/gl_config.h"
30#include "mir/graphics/cursor.h"29#include "mir/graphics/cursor.h"
31#include "program_factory.h"30#include "program_factory.h"
@@ -43,16 +42,6 @@
4342
44namespace mg = mir::graphics;43namespace mg = mir::graphics;
4544
46std::shared_ptr<mg::BufferInitializer>
47mir::DefaultServerConfiguration::the_buffer_initializer()
48{
49 return buffer_initializer(
50 []()
51 {
52 return std::make_shared<mg::NullBufferInitializer>();
53 });
54}
55
56std::shared_ptr<mg::DisplayConfigurationPolicy>45std::shared_ptr<mg::DisplayConfigurationPolicy>
57mir::DefaultServerConfiguration::the_display_configuration_policy()46mir::DefaultServerConfiguration::the_display_configuration_policy()
58{47{
@@ -102,7 +91,7 @@
102 return buffer_allocator(91 return buffer_allocator(
103 [&]()92 [&]()
104 {93 {
105 return the_graphics_platform()->create_buffer_allocator(the_buffer_initializer());94 return the_graphics_platform()->create_buffer_allocator();
106 });95 });
107}96}
10897
10998
=== modified file 'src/server/graphics/nested/nested_platform.cpp'
--- src/server/graphics/nested/nested_platform.cpp 2014-09-26 05:50:46 +0000
+++ src/server/graphics/nested/nested_platform.cpp 2014-10-16 14:20:32 +0000
@@ -74,10 +74,9 @@
74{74{
75}75}
7676
77std::shared_ptr<mg::GraphicBufferAllocator> mgn::NestedPlatform::create_buffer_allocator(77std::shared_ptr<mg::GraphicBufferAllocator> mgn::NestedPlatform::create_buffer_allocator()
78 std::shared_ptr<mg::BufferInitializer> const& buffer_initializer)
79{78{
80 return native_platform->create_buffer_allocator(buffer_initializer);79 return native_platform->create_buffer_allocator();
81}80}
8281
83std::shared_ptr<mg::BufferWriter> mgn::NestedPlatform::make_buffer_writer()82std::shared_ptr<mg::BufferWriter> mgn::NestedPlatform::make_buffer_writer()
8483
=== modified file 'src/server/graphics/nested/nested_platform.h'
--- src/server/graphics/nested/nested_platform.h 2014-09-26 05:50:46 +0000
+++ src/server/graphics/nested/nested_platform.h 2014-10-16 14:20:32 +0000
@@ -42,8 +42,7 @@
42 std::shared_ptr<NativePlatform> const& native_platform);42 std::shared_ptr<NativePlatform> const& native_platform);
4343
44 ~NestedPlatform() noexcept;44 ~NestedPlatform() noexcept;
45 std::shared_ptr<GraphicBufferAllocator> create_buffer_allocator(45 std::shared_ptr<GraphicBufferAllocator> create_buffer_allocator() override;
46 std::shared_ptr<BufferInitializer> const& buffer_initializer) override;
47 std::shared_ptr<Display> create_display(46 std::shared_ptr<Display> create_display(
48 std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,47 std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
49 std::shared_ptr<GLProgramFactory> const& gl_program_factory,48 std::shared_ptr<GLProgramFactory> const& gl_program_factory,
5049
=== modified file 'tests/acceptance-tests/test_display_configuration.cpp'
--- tests/acceptance-tests/test_display_configuration.cpp 2014-09-11 05:51:44 +0000
+++ tests/acceptance-tests/test_display_configuration.cpp 2014-10-16 14:20:32 +0000
@@ -140,8 +140,7 @@
140class StubPlatform : public mtd::NullPlatform140class StubPlatform : public mtd::NullPlatform
141{141{
142public:142public:
143 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator(143 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator() override
144 std::shared_ptr<mg::BufferInitializer> const& /*buffer_initializer*/) override
145 {144 {
146 return std::make_shared<mtd::StubBufferAllocator>();145 return std::make_shared<mtd::StubBufferAllocator>();
147 }146 }
148147
=== modified file 'tests/acceptance-tests/test_nested_mir.cpp'
--- tests/acceptance-tests/test_nested_mir.cpp 2014-09-30 06:11:33 +0000
+++ tests/acceptance-tests/test_nested_mir.cpp 2014-10-16 14:20:32 +0000
@@ -121,10 +121,9 @@
121121
122 void initialize(std::shared_ptr<mg::NestedContext> const& /*nested_context*/) override {}122 void initialize(std::shared_ptr<mg::NestedContext> const& /*nested_context*/) override {}
123123
124 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator(124 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator() override
125 std::shared_ptr<mg::BufferInitializer> const& buffer_initializer) override
126 {125 {
127 return adaptee->create_buffer_allocator(buffer_initializer);126 return adaptee->create_buffer_allocator();
128 }127 }
129128
130 std::shared_ptr<mg::PlatformIPCPackage> connection_ipc_package() override129 std::shared_ptr<mg::PlatformIPCPackage> connection_ipc_package() override
131130
=== removed file 'tests/include/mir_test_doubles/mock_buffer_initializer.h'
--- tests/include/mir_test_doubles/mock_buffer_initializer.h 2013-08-28 03:41:48 +0000
+++ tests/include/mir_test_doubles/mock_buffer_initializer.h 1970-01-01 00:00:00 +0000
@@ -1,48 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_MOCK_BUFFER_INITIALIZER_H_
20#define MIR_TEST_DOUBLES_MOCK_BUFFER_INITIALIZER_H_
21
22#include "mir/graphics/buffer_initializer.h"
23
24#include <gmock/gmock.h>
25
26namespace mir
27{
28namespace test
29{
30namespace doubles
31{
32
33class MockBufferInitializer : public graphics::BufferInitializer
34{
35public:
36 MOCK_METHOD1(operator_call, void(graphics::Buffer& buffer));
37
38 void operator()(graphics::Buffer& buffer)
39 {
40 operator_call(buffer);
41 }
42};
43
44}
45}
46} // namespace mir
47
48#endif /* MIR_TEST_DOUBLES_MOCK_BUFFER_INITIALIZER_H_ */
490
=== modified file 'tests/include/mir_test_doubles/null_platform.h'
--- tests/include/mir_test_doubles/null_platform.h 2014-09-24 17:01:33 +0000
+++ tests/include/mir_test_doubles/null_platform.h 2014-10-16 14:20:32 +0000
@@ -33,8 +33,7 @@
33class NullPlatform : public graphics::Platform33class NullPlatform : public graphics::Platform
34{34{
35 public:35 public:
36 std::shared_ptr<graphics::GraphicBufferAllocator> create_buffer_allocator(36 std::shared_ptr<graphics::GraphicBufferAllocator> create_buffer_allocator()
37 const std::shared_ptr<graphics::BufferInitializer>& /*buffer_initializer*/)
38 {37 {
39 return nullptr;38 return nullptr;
40 }39 }
4140
=== modified file 'tests/integration-tests/client/test_client_render.cpp'
--- tests/integration-tests/client/test_client_render.cpp 2014-10-14 17:16:30 +0000
+++ tests/integration-tests/client/test_client_render.cpp 2014-10-16 14:20:32 +0000
@@ -19,7 +19,6 @@
19#include "mir_test_framework/process.h"19#include "mir_test_framework/process.h"
2020
21#include "mir/graphics/buffer_properties.h"21#include "mir/graphics/buffer_properties.h"
22#include "mir/graphics/buffer_initializer.h"
23#include "src/platform/graphics/android/buffer.h"22#include "src/platform/graphics/android/buffer.h"
24#include "mir/graphics/android/native_buffer.h"23#include "mir/graphics/android/native_buffer.h"
25#include "src/platform/graphics/android/android_graphic_buffer_allocator.h"24#include "src/platform/graphics/android/android_graphic_buffer_allocator.h"
@@ -192,8 +191,7 @@
192{191{
193 StubServerGenerator()192 StubServerGenerator()
194 {193 {
195 auto initializer = std::make_shared<mg::NullBufferInitializer>();194 allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>();
196 allocator = std::make_shared<mga::AndroidGraphicBufferAllocator> (initializer);
197 auto size = geom::Size{test_width, test_height};195 auto size = geom::Size{test_width, test_height};
198 surface_pf = mir_pixel_format_abgr_8888;196 surface_pf = mir_pixel_format_abgr_8888;
199 last_posted = allocator->alloc_buffer_platform(size, surface_pf, mga::BufferUsage::use_hardware);197 last_posted = allocator->alloc_buffer_platform(size, surface_pf, mga::BufferUsage::use_hardware);
200198
=== modified file 'tests/integration-tests/graphics/android/test_buffer_integration.cpp'
--- tests/integration-tests/graphics/android/test_buffer_integration.cpp 2014-10-06 03:02:44 +0000
+++ tests/integration-tests/graphics/android/test_buffer_integration.cpp 2014-10-16 14:20:32 +0000
@@ -18,7 +18,6 @@
1818
19#include "src/platform/graphics/android/android_graphic_buffer_allocator.h"19#include "src/platform/graphics/android/android_graphic_buffer_allocator.h"
20#include "src/server/compositor/buffer_queue.h"20#include "src/server/compositor/buffer_queue.h"
21#include "mir/graphics/buffer_initializer.h"
22#include "src/server/report/null_report_factory.h"21#include "src/server/report/null_report_factory.h"
23#include "mir/graphics/android/native_buffer.h"22#include "mir/graphics/android/native_buffer.h"
24#include "mir/graphics/buffer_properties.h"23#include "mir/graphics/buffer_properties.h"
@@ -47,11 +46,9 @@
47 size = geom::Size{334, 122};46 size = geom::Size{334, 122};
48 pf = mir_pixel_format_abgr_8888;47 pf = mir_pixel_format_abgr_8888;
49 buffer_properties = mg::BufferProperties{size, pf, mg::BufferUsage::software};48 buffer_properties = mg::BufferProperties{size, pf, mg::BufferUsage::software};
50 null_buffer_initializer = std::make_shared<mg::NullBufferInitializer>();
51 graphics_region_factory = mtd::create_graphics_region_factory();49 graphics_region_factory = mtd::create_graphics_region_factory();
52 }50 }
5351
54 std::shared_ptr<mg::BufferInitializer> null_buffer_initializer;
55 geom::Size size;52 geom::Size size;
56 MirPixelFormat pf;53 MirPixelFormat pf;
57 mg::BufferProperties buffer_properties;54 mg::BufferProperties buffer_properties;
@@ -89,7 +86,7 @@
89{86{
90 using namespace testing;87 using namespace testing;
9188
92 auto allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(null_buffer_initializer);89 auto allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>();
9390
94 mg::BufferProperties sw_properties{size, pf, mg::BufferUsage::software};91 mg::BufferProperties sw_properties{size, pf, mg::BufferUsage::software};
95 auto test_buffer = allocator->alloc_buffer(sw_properties);92 auto test_buffer = allocator->alloc_buffer(sw_properties);
@@ -106,7 +103,7 @@
106 using namespace testing;103 using namespace testing;
107104
108 mg::BufferProperties hw_properties{size, pf, mg::BufferUsage::hardware};105 mg::BufferProperties hw_properties{size, pf, mg::BufferUsage::hardware};
109 auto allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(null_buffer_initializer);106 auto allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>();
110107
111 //TODO: kdub it is a bit trickier to test that a gpu can render... just check creation for now108 //TODO: kdub it is a bit trickier to test that a gpu can render... just check creation for now
112 auto test_buffer = allocator->alloc_buffer(hw_properties);109 auto test_buffer = allocator->alloc_buffer(hw_properties);
@@ -117,7 +114,7 @@
117{114{
118 using namespace testing;115 using namespace testing;
119116
120 auto allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(null_buffer_initializer);117 auto allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>();
121118
122 mc::BufferQueue swapper(2, allocator, buffer_properties, policy_factory);119 mc::BufferQueue swapper(2, allocator, buffer_properties, policy_factory);
123120
124121
=== modified file 'tests/integration-tests/graphics/android/test_display_integration.cpp'
--- tests/integration-tests/graphics/android/test_display_integration.cpp 2014-09-25 06:06:57 +0000
+++ tests/integration-tests/graphics/android/test_display_integration.cpp 2014-10-16 14:20:32 +0000
@@ -16,7 +16,6 @@
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */17 */
1818
19#include "mir/graphics/buffer_initializer.h"
20#include "mir/graphics/display_buffer.h"19#include "mir/graphics/display_buffer.h"
21#include "src/platform/graphics/android/display.h"20#include "src/platform/graphics/android/display.h"
22#include "src/platform/graphics/android/hwc_loggers.h"21#include "src/platform/graphics/android/hwc_loggers.h"
@@ -55,8 +54,7 @@
55 the server can handle this, but we need the test to as well */54 the server can handle this, but we need the test to as well */
56 original_sigterm_handler = signal(SIGTERM, [](int){});55 original_sigterm_handler = signal(SIGTERM, [](int){});
5756
58 auto buffer_initializer = std::make_shared<mg::NullBufferInitializer>();57 buffer_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>();
59 buffer_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(buffer_initializer);
6058
61 /* note about fb_device: OMAP4 drivers seem to only be able to open fb once59 /* note about fb_device: OMAP4 drivers seem to only be able to open fb once
62 per process (repeated framebuffer_{open,close}() doesn't seem to work). once we60 per process (repeated framebuffer_{open,close}() doesn't seem to work). once we
6361
=== modified file 'tests/integration-tests/graphics/android/test_internal_client.cpp'
--- tests/integration-tests/graphics/android/test_internal_client.cpp 2014-09-11 05:51:44 +0000
+++ tests/integration-tests/graphics/android/test_internal_client.cpp 2014-10-16 14:20:32 +0000
@@ -22,7 +22,6 @@
22#include "src/platform/graphics/android/internal_client.h"22#include "src/platform/graphics/android/internal_client.h"
23#include "src/server/compositor/buffer_stream_factory.h"23#include "src/server/compositor/buffer_stream_factory.h"
24#include "src/server/report/null_report_factory.h"24#include "src/server/report/null_report_factory.h"
25#include "mir/graphics/buffer_initializer.h"
26#include "src/server/report/null_report_factory.h"25#include "src/server/report/null_report_factory.h"
27#include "mir/graphics/android/mir_native_window.h"26#include "mir/graphics/android/mir_native_window.h"
28#include "mir/graphics/platform.h"27#include "mir/graphics/platform.h"
@@ -100,8 +99,7 @@
10099
101 auto stub_input_factory = std::make_shared<StubInputFactory>();100 auto stub_input_factory = std::make_shared<StubInputFactory>();
102 auto stub_input_sender = std::make_shared<mtd::StubInputSender>();101 auto stub_input_sender = std::make_shared<mtd::StubInputSender>();
103 auto null_buffer_initializer = std::make_shared<mg::NullBufferInitializer>();102 auto allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>();
104 auto allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(null_buffer_initializer);
105 auto buffer_stream_factory = std::make_shared<mc::BufferStreamFactory>(allocator, std::make_shared<mtd::StubFrameDroppingPolicyFactory>());103 auto buffer_stream_factory = std::make_shared<mc::BufferStreamFactory>(allocator, std::make_shared<mtd::StubFrameDroppingPolicyFactory>());
106 auto scene_report = mr::null_scene_report();104 auto scene_report = mr::null_scene_report();
107 auto const surface_configurator = std::make_shared<mtd::NullSurfaceConfigurator>();105 auto const surface_configurator = std::make_shared<mtd::NullSurfaceConfigurator>();
108106
=== modified file 'tests/integration-tests/graphics/mesa/test_buffer_integration.cpp'
--- tests/integration-tests/graphics/mesa/test_buffer_integration.cpp 2014-09-11 05:51:44 +0000
+++ tests/integration-tests/graphics/mesa/test_buffer_integration.cpp 2014-10-16 14:20:32 +0000
@@ -19,7 +19,6 @@
19#include "mir/graphics/buffer_basic.h"19#include "mir/graphics/buffer_basic.h"
20#include "mir/graphics/buffer_id.h"20#include "mir/graphics/buffer_id.h"
21#include "mir/graphics/buffer_properties.h"21#include "mir/graphics/buffer_properties.h"
22#include "mir/graphics/buffer_initializer.h"
23#include "mir/options/configuration.h"22#include "mir/options/configuration.h"
24#include "mir/options/option.h"23#include "mir/options/option.h"
25#include "mir_test_doubles/stub_buffer.h"24#include "mir_test_doubles/stub_buffer.h"
@@ -85,8 +84,7 @@
85class StubGraphicPlatform : public mtd::NullPlatform84class StubGraphicPlatform : public mtd::NullPlatform
86{85{
87public:86public:
88 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator(87 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator() override
89 const std::shared_ptr<mg::BufferInitializer>& /*buffer_initializer*/) override
90 {88 {
91 return std::make_shared<StubGraphicBufferAllocator>();89 return std::make_shared<StubGraphicBufferAllocator>();
92 }90 }
@@ -116,8 +114,7 @@
116 conf_policy,114 conf_policy,
117 std::make_shared<mtd::StubGLProgramFactory>(),115 std::make_shared<mtd::StubGLProgramFactory>(),
118 std::make_shared<mtd::StubGLConfig>());116 std::make_shared<mtd::StubGLConfig>());
119 auto buffer_initializer = std::make_shared<mg::NullBufferInitializer>();117 allocator = platform->create_buffer_allocator();
120 allocator = platform->create_buffer_allocator(buffer_initializer);
121 size = geom::Size{100, 100};118 size = geom::Size{100, 100};
122 pf = mir_pixel_format_abgr_8888;119 pf = mir_pixel_format_abgr_8888;
123 usage = mg::BufferUsage::hardware;120 usage = mg::BufferUsage::hardware;
124121
=== modified file 'tests/integration-tests/test_display_info.cpp'
--- tests/integration-tests/test_display_info.cpp 2014-09-11 05:51:44 +0000
+++ tests/integration-tests/test_display_info.cpp 2014-10-16 14:20:32 +0000
@@ -110,8 +110,7 @@
110class StubPlatform : public mtd::NullPlatform110class StubPlatform : public mtd::NullPlatform
111{111{
112public:112public:
113 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator(113 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator() override
114 std::shared_ptr<mg::BufferInitializer> const& /*buffer_initializer*/) override
115 {114 {
116 return std::make_shared<StubGraphicBufferAllocator>();115 return std::make_shared<StubGraphicBufferAllocator>();
117 }116 }
118117
=== modified file 'tests/integration-tests/test_drm_auth_magic.cpp'
--- tests/integration-tests/test_drm_auth_magic.cpp 2014-03-06 06:05:17 +0000
+++ tests/integration-tests/test_drm_auth_magic.cpp 2014-10-16 14:20:32 +0000
@@ -47,8 +47,7 @@
47class MockAuthenticatingPlatform : public mtd::NullPlatform, public mg::DRMAuthenticator47class MockAuthenticatingPlatform : public mtd::NullPlatform, public mg::DRMAuthenticator
48{48{
49public:49public:
50 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator(50 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator() override
51 std::shared_ptr<mg::BufferInitializer> const& /*buffer_initializer*/) override
52 {51 {
53 return std::make_shared<mtd::StubBufferAllocator>();52 return std::make_shared<mtd::StubBufferAllocator>();
54 }53 }
5554
=== modified file 'tests/integration-tests/test_surfaceloop.cpp'
--- tests/integration-tests/test_surfaceloop.cpp 2014-09-11 05:51:44 +0000
+++ tests/integration-tests/test_surfaceloop.cpp 2014-10-16 14:20:32 +0000
@@ -181,8 +181,7 @@
181 class StubPlatform : public mtd::NullPlatform181 class StubPlatform : public mtd::NullPlatform
182 {182 {
183 public:183 public:
184 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator(184 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator() override
185 const std::shared_ptr<mg::BufferInitializer>& /*buffer_initializer*/) override
186 {185 {
187 return std::make_shared<StubGraphicBufferAllocator>();186 return std::make_shared<StubGraphicBufferAllocator>();
188 }187 }
189188
=== modified file 'tests/mir_test_framework/stubbed_server_configuration.cpp'
--- tests/mir_test_framework/stubbed_server_configuration.cpp 2014-10-08 12:35:49 +0000
+++ tests/mir_test_framework/stubbed_server_configuration.cpp 2014-10-16 14:20:32 +0000
@@ -184,8 +184,7 @@
184 {184 {
185 }185 }
186186
187 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator(187 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator() override
188 const std::shared_ptr<mg::BufferInitializer>& /*buffer_initializer*/) override
189 {188 {
190 return std::make_shared<StubGraphicBufferAllocator>();189 return std::make_shared<StubGraphicBufferAllocator>();
191 }190 }
192191
=== modified file 'tests/unit-tests/frontend/test_session_mediator.cpp'
--- tests/unit-tests/frontend/test_session_mediator.cpp 2014-10-03 13:04:18 +0000
+++ tests/unit-tests/frontend/test_session_mediator.cpp 2014-10-16 14:20:32 +0000
@@ -209,7 +209,7 @@
209 MockPlatform(std::shared_ptr<mg::PlatformIpcOperations> const& ipc_ops)209 MockPlatform(std::shared_ptr<mg::PlatformIpcOperations> const& ipc_ops)
210 {210 {
211 using namespace testing;211 using namespace testing;
212 ON_CALL(*this, create_buffer_allocator(_))212 ON_CALL(*this, create_buffer_allocator())
213 .WillByDefault(Return(std::shared_ptr<mg::GraphicBufferAllocator>()));213 .WillByDefault(Return(std::shared_ptr<mg::GraphicBufferAllocator>()));
214 ON_CALL(*this, create_display(_,_,_))214 ON_CALL(*this, create_display(_,_,_))
215 .WillByDefault(Return(std::make_shared<mtd::NullDisplay>()));215 .WillByDefault(Return(std::make_shared<mtd::NullDisplay>()));
@@ -219,7 +219,7 @@
219 .WillByDefault(Return(ipc_ops));219 .WillByDefault(Return(ipc_ops));
220 }220 }
221221
222 MOCK_METHOD1(create_buffer_allocator, std::shared_ptr<mg::GraphicBufferAllocator>(std::shared_ptr<mg::BufferInitializer> const&));222 MOCK_METHOD0(create_buffer_allocator, std::shared_ptr<mg::GraphicBufferAllocator>());
223 MOCK_METHOD3(create_display,223 MOCK_METHOD3(create_display,
224 std::shared_ptr<mg::Display>(224 std::shared_ptr<mg::Display>(
225 std::shared_ptr<mg::DisplayConfigurationPolicy> const&,225 std::shared_ptr<mg::DisplayConfigurationPolicy> const&,
226226
=== modified file 'tests/unit-tests/frontend/test_session_mediator_mesa.cpp'
--- tests/unit-tests/frontend/test_session_mediator_mesa.cpp 2014-09-18 07:03:11 +0000
+++ tests/unit-tests/frontend/test_session_mediator_mesa.cpp 2014-10-16 14:20:32 +0000
@@ -54,8 +54,7 @@
54class MockAuthenticatingPlatform : public mtd::NullPlatform, public mg::DRMAuthenticator54class MockAuthenticatingPlatform : public mtd::NullPlatform, public mg::DRMAuthenticator
55{55{
56 public:56 public:
57 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator(57 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator() override
58 const std::shared_ptr<mg::BufferInitializer>& /*buffer_initializer*/) override
59 {58 {
60 return std::shared_ptr<mg::GraphicBufferAllocator>();59 return std::shared_ptr<mg::GraphicBufferAllocator>();
61 }60 }
6261
=== modified file 'tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp'
--- tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp 2014-03-06 06:05:17 +0000
+++ tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp 2014-10-16 14:20:32 +0000
@@ -18,10 +18,8 @@
1818
19#include "src/platform/graphics/android/android_graphic_buffer_allocator.h"19#include "src/platform/graphics/android/android_graphic_buffer_allocator.h"
20#include "mir_test_doubles/mock_android_hw.h"20#include "mir_test_doubles/mock_android_hw.h"
21#include "mir/graphics/buffer_initializer.h"
22#include "mir/graphics/buffer_properties.h"21#include "mir/graphics/buffer_properties.h"
2322
24#include "mir_test_doubles/mock_buffer_initializer.h"
25#include "mir_test_doubles/mock_egl.h"23#include "mir_test_doubles/mock_egl.h"
2624
27#include <hardware/gralloc.h>25#include <hardware/gralloc.h>
@@ -36,11 +34,9 @@
36struct AndroidGraphicBufferAllocatorTest : public ::testing::Test34struct AndroidGraphicBufferAllocatorTest : public ::testing::Test
37{35{
38 AndroidGraphicBufferAllocatorTest()36 AndroidGraphicBufferAllocatorTest()
39 : null_buffer_initializer{std::make_shared<mg::NullBufferInitializer>()}
40 {37 {
41 }38 }
4239
43 std::shared_ptr<mg::BufferInitializer> const null_buffer_initializer;
44 testing::NiceMock<mtd::HardwareAccessMock> hw_access_mock;40 testing::NiceMock<mtd::HardwareAccessMock> hw_access_mock;
45 testing::NiceMock<mtd::MockEGL> mock_egl;41 testing::NiceMock<mtd::MockEGL> mock_egl;
46};42};
@@ -52,12 +48,12 @@
52 EXPECT_CALL(hw_access_mock, hw_get_module(StrEq(GRALLOC_HARDWARE_MODULE_ID), _))48 EXPECT_CALL(hw_access_mock, hw_get_module(StrEq(GRALLOC_HARDWARE_MODULE_ID), _))
53 .Times(1);49 .Times(1);
5450
55 mga::AndroidGraphicBufferAllocator allocator(null_buffer_initializer);51 mga::AndroidGraphicBufferAllocator allocator{};
56}52}
5753
58TEST_F(AndroidGraphicBufferAllocatorTest, supported_pixel_formats_contain_common_formats)54TEST_F(AndroidGraphicBufferAllocatorTest, supported_pixel_formats_contain_common_formats)
59{55{
60 mga::AndroidGraphicBufferAllocator allocator{null_buffer_initializer};56 mga::AndroidGraphicBufferAllocator allocator{};
61 auto supported_pixel_formats = allocator.supported_pixel_formats();57 auto supported_pixel_formats = allocator.supported_pixel_formats();
6258
63 auto abgr_8888_count = std::count(supported_pixel_formats.begin(),59 auto abgr_8888_count = std::count(supported_pixel_formats.begin(),
@@ -79,45 +75,13 @@
7975
80TEST_F(AndroidGraphicBufferAllocatorTest, supported_pixel_formats_have_sane_default_in_first_position)76TEST_F(AndroidGraphicBufferAllocatorTest, supported_pixel_formats_have_sane_default_in_first_position)
81{77{
82 mga::AndroidGraphicBufferAllocator allocator{null_buffer_initializer};78 mga::AndroidGraphicBufferAllocator allocator{};
83 auto supported_pixel_formats = allocator.supported_pixel_formats();79 auto supported_pixel_formats = allocator.supported_pixel_formats();
8480
85 ASSERT_FALSE(supported_pixel_formats.empty());81 ASSERT_FALSE(supported_pixel_formats.empty());
86 EXPECT_EQ(mir_pixel_format_abgr_8888, supported_pixel_formats[0]);82 EXPECT_EQ(mir_pixel_format_abgr_8888, supported_pixel_formats[0]);
87}83}
8884
89TEST_F(AndroidGraphicBufferAllocatorTest, alloc_buffer_calls_initializer)
90{
91 using namespace testing;
92
93 auto buffer_initializer = std::make_shared<mtd::MockBufferInitializer>();
94
95 mg::BufferProperties properties{geom::Size{2, 2},
96 mir_pixel_format_abgr_8888,
97 mg::BufferUsage::hardware};
98 mga::AndroidGraphicBufferAllocator allocator{buffer_initializer};
99 EXPECT_CALL(*buffer_initializer, operator_call(_))
100 .Times(1);
101
102 allocator.alloc_buffer(properties);
103}
104
105TEST_F(AndroidGraphicBufferAllocatorTest, alloc_buffer_platform_calls_initializer)
106{
107 using namespace testing;
108
109 auto buffer_initializer = std::make_shared<mtd::MockBufferInitializer>();
110
111 mga::AndroidGraphicBufferAllocator allocator{buffer_initializer};
112 auto size = geom::Size{2, 2};
113 auto pf = mir_pixel_format_abgr_8888;
114
115 EXPECT_CALL(*buffer_initializer, operator_call(_))
116 .Times(1);
117
118 allocator.alloc_buffer_platform(size, pf, mga::BufferUsage::use_hardware);
119}
120
121TEST_F(AndroidGraphicBufferAllocatorTest, buffer_usage_converter)85TEST_F(AndroidGraphicBufferAllocatorTest, buffer_usage_converter)
122{86{
123 EXPECT_EQ(mga::BufferUsage::use_hardware,87 EXPECT_EQ(mga::BufferUsage::use_hardware,
12488
=== modified file 'tests/unit-tests/graphics/mesa/test_buffer_allocator.cpp'
--- tests/unit-tests/graphics/mesa/test_buffer_allocator.cpp 2014-09-11 05:51:44 +0000
+++ tests/unit-tests/graphics/mesa/test_buffer_allocator.cpp 2014-10-16 14:20:32 +0000
@@ -25,7 +25,6 @@
25#include "mir_test_doubles/mock_gbm.h"25#include "mir_test_doubles/mock_gbm.h"
26#include "mir_test_doubles/mock_egl.h"26#include "mir_test_doubles/mock_egl.h"
27#include "mir_test_doubles/mock_gl.h"27#include "mir_test_doubles/mock_gl.h"
28#include "mir_test_doubles/mock_buffer_initializer.h"
29#include "mir_test_doubles/platform_factory.h"28#include "mir_test_doubles/platform_factory.h"
30#include "mir_test_framework/udev_environment.h"29#include "mir_test_framework/udev_environment.h"
3130
@@ -62,9 +61,8 @@
62 .WillByDefault(Return(mock_gbm.fake_gbm.bo_handle));61 .WillByDefault(Return(mock_gbm.fake_gbm.bo_handle));
6362
64 platform = mtd::create_mesa_platform_with_null_dependencies();63 platform = mtd::create_mesa_platform_with_null_dependencies();
65 mock_buffer_initializer = std::make_shared<testing::NiceMock<mtd::MockBufferInitializer>>();
66 allocator.reset(new mgm::BufferAllocator(64 allocator.reset(new mgm::BufferAllocator(
67 platform->gbm.device, mock_buffer_initializer, mgm::BypassOption::allowed));65 platform->gbm.device, mgm::BypassOption::allowed));
68 }66 }
6967
70 // Defaults68 // Defaults
@@ -78,7 +76,6 @@
78 ::testing::NiceMock<mtd::MockEGL> mock_egl;76 ::testing::NiceMock<mtd::MockEGL> mock_egl;
79 ::testing::NiceMock<mtd::MockGL> mock_gl;77 ::testing::NiceMock<mtd::MockGL> mock_gl;
80 std::shared_ptr<mgm::Platform> platform;78 std::shared_ptr<mgm::Platform> platform;
81 std::shared_ptr<testing::NiceMock<mtd::MockBufferInitializer>> mock_buffer_initializer;
82 std::unique_ptr<mgm::BufferAllocator> allocator;79 std::unique_ptr<mgm::BufferAllocator> allocator;
83 mtf::UdevEnvironment fake_devices;80 mtf::UdevEnvironment fake_devices;
84};81};
@@ -147,7 +144,6 @@
147144
148 mgm::BufferAllocator alloc(145 mgm::BufferAllocator alloc(
149 platform->gbm.device,146 platform->gbm.device,
150 mock_buffer_initializer,
151 mgm::BypassOption::prohibited);147 mgm::BypassOption::prohibited);
152 auto buf = alloc.alloc_buffer(properties);148 auto buf = alloc.alloc_buffer(properties);
153 ASSERT_TRUE(buf.get() != NULL);149 ASSERT_TRUE(buf.get() != NULL);
@@ -236,29 +232,6 @@
236 allocator->alloc_buffer(buffer_properties);232 allocator->alloc_buffer(buffer_properties);
237}233}
238234
239TEST_F(MesaBufferAllocatorTest, buffer_initializer_is_called)
240{
241 using namespace testing;
242
243 EXPECT_CALL(*mock_buffer_initializer, operator_call(_))
244 .Times(1);
245
246 allocator->alloc_buffer(buffer_properties);
247}
248
249TEST_F(MesaBufferAllocatorTest, null_buffer_initializer_does_not_crash)
250{
251 using namespace testing;
252
253 auto null_buffer_initializer = std::make_shared<mg::NullBufferInitializer>();
254 allocator.reset(new mgm::BufferAllocator(
255 platform->gbm.device, null_buffer_initializer, mgm::BypassOption::allowed));
256
257 EXPECT_NO_THROW({
258 allocator->alloc_buffer(buffer_properties);
259 });
260}
261
262TEST_F(MesaBufferAllocatorTest, throws_on_buffer_creation_failure)235TEST_F(MesaBufferAllocatorTest, throws_on_buffer_creation_failure)
263{236{
264 using namespace testing;237 using namespace testing;
265238
=== modified file 'tests/unit-tests/graphics/mesa/test_gbm_buffer.cpp'
--- tests/unit-tests/graphics/mesa/test_gbm_buffer.cpp 2014-09-19 03:08:20 +0000
+++ tests/unit-tests/graphics/mesa/test_gbm_buffer.cpp 2014-10-16 14:20:32 +0000
@@ -25,7 +25,6 @@
2525
26#include "src/platform/graphics/mesa/gbm_buffer.h"26#include "src/platform/graphics/mesa/gbm_buffer.h"
27#include "src/platform/graphics/mesa/buffer_allocator.h"27#include "src/platform/graphics/mesa/buffer_allocator.h"
28#include "mir/graphics/buffer_initializer.h"
29#include "mir/graphics/buffer_properties.h"28#include "mir/graphics/buffer_properties.h"
30#include "mir_test_doubles/platform_factory.h"29#include "mir_test_doubles/platform_factory.h"
3130
@@ -71,9 +70,8 @@
71 .WillByDefault(Return(stride.as_uint32_t()));70 .WillByDefault(Return(stride.as_uint32_t()));
7271
73 platform = mtd::create_mesa_platform_with_null_dependencies();72 platform = mtd::create_mesa_platform_with_null_dependencies();
74 null_init = std::make_shared<mg::NullBufferInitializer>();
7573
76 allocator.reset(new mgm::BufferAllocator(platform->gbm.device, null_init, mgm::BypassOption::allowed));74 allocator.reset(new mgm::BufferAllocator(platform->gbm.device, mgm::BypassOption::allowed));
77 }75 }
7876
79 ::testing::NiceMock<mtd::MockDRM> mock_drm;77 ::testing::NiceMock<mtd::MockDRM> mock_drm;
@@ -81,7 +79,6 @@
81 ::testing::NiceMock<mtd::MockEGL> mock_egl;79 ::testing::NiceMock<mtd::MockEGL> mock_egl;
82 ::testing::NiceMock<mtd::MockGL> mock_gl;80 ::testing::NiceMock<mtd::MockGL> mock_gl;
83 std::shared_ptr<mgm::Platform> platform;81 std::shared_ptr<mgm::Platform> platform;
84 std::shared_ptr<mg::NullBufferInitializer> null_init;
85 std::unique_ptr<mgm::BufferAllocator> allocator;82 std::unique_ptr<mgm::BufferAllocator> allocator;
8683
87 // Defaults84 // Defaults
8885
=== modified file 'tests/unit-tests/graphics/nested/test_nested_platform.cpp'
--- tests/unit-tests/graphics/nested/test_nested_platform.cpp 2014-09-24 17:01:33 +0000
+++ tests/unit-tests/graphics/nested/test_nested_platform.cpp 2014-10-16 14:20:32 +0000
@@ -49,8 +49,7 @@
49public:49public:
50 void initialize(std::shared_ptr<mg::NestedContext> const&) override {}50 void initialize(std::shared_ptr<mg::NestedContext> const&) override {}
5151
52 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator(52 std::shared_ptr<mg::GraphicBufferAllocator> create_buffer_allocator() override
53 std::shared_ptr<mg::BufferInitializer> const&) override
54 {53 {
55 return {};54 return {};
56 }55 }
5756
=== modified file 'tests/unit-tests/graphics/test_graphics_platform.cpp'
--- tests/unit-tests/graphics/test_graphics_platform.cpp 2014-09-23 19:01:02 +0000
+++ tests/unit-tests/graphics/test_graphics_platform.cpp 2014-10-16 14:20:32 +0000
@@ -31,7 +31,6 @@
31#else31#else
32#include "mir_test_doubles/mock_android_hw.h"32#include "mir_test_doubles/mock_android_hw.h"
33#endif33#endif
34#include "mir/graphics/buffer_initializer.h"
35#include "mir/logging/dumb_console_logger.h"34#include "mir/logging/dumb_console_logger.h"
3635
3736
@@ -52,7 +51,6 @@
52 GraphicsPlatform() : logger(std::make_shared<ml::DumbConsoleLogger>())51 GraphicsPlatform() : logger(std::make_shared<ml::DumbConsoleLogger>())
53 {52 {
54 using namespace testing;53 using namespace testing;
55 buffer_initializer = std::make_shared<mg::NullBufferInitializer>();
5654
57#ifndef ANDROID55#ifndef ANDROID
58 ON_CALL(mock_gbm, gbm_bo_get_width(_))56 ON_CALL(mock_gbm, gbm_bo_get_width(_))
@@ -74,7 +72,6 @@
74 }72 }
7573
76 std::shared_ptr<ml::Logger> logger;74 std::shared_ptr<ml::Logger> logger;
77 std::shared_ptr<mg::BufferInitializer> buffer_initializer;
7875
79 ::testing::NiceMock<mtd::MockEGL> mock_egl;76 ::testing::NiceMock<mtd::MockEGL> mock_egl;
80 ::testing::NiceMock<mtd::MockGL> mock_gl;77 ::testing::NiceMock<mtd::MockGL> mock_gl;
@@ -93,7 +90,7 @@
9390
94 EXPECT_NO_THROW (91 EXPECT_NO_THROW (
95 auto platform = create_platform();92 auto platform = create_platform();
96 auto allocator = platform->create_buffer_allocator(buffer_initializer);93 auto allocator = platform->create_buffer_allocator();
9794
98 EXPECT_TRUE(allocator.get());95 EXPECT_TRUE(allocator.get());
99 );96 );
@@ -103,7 +100,7 @@
103TEST_F(GraphicsPlatform, buffer_creation)100TEST_F(GraphicsPlatform, buffer_creation)
104{101{
105 auto platform = create_platform();102 auto platform = create_platform();
106 auto allocator = platform->create_buffer_allocator(buffer_initializer);103 auto allocator = platform->create_buffer_allocator();
107 auto supported_pixel_formats = allocator->supported_pixel_formats();104 auto supported_pixel_formats = allocator->supported_pixel_formats();
108105
109 ASSERT_NE(0u, supported_pixel_formats.size());106 ASSERT_NE(0u, supported_pixel_formats.size());

Subscribers

People subscribed via source and target branches