Mir

Merge lp:~kdub/mir/reduce-mediator-dependencies into lp:~mir-team/mir/trunk

Proposed by Kevin DuBois
Status: Rejected
Rejected by: Kevin DuBois
Proposed branch: lp:~kdub/mir/reduce-mediator-dependencies
Merge into: lp:~mir-team/mir/trunk
Diff against target: 856 lines (+158/-185)
28 files modified
examples/render_surfaces.cpp (+2/-2)
include/server/mir/compositor/graphic_buffer_allocator.h (+0/-3)
include/server/mir/frontend/session_mediator.h (+0/-1)
include/server/mir/graphics/platform.h (+4/-0)
include/test/mir_test_doubles/stub_platform.h (+5/-0)
src/server/default_server_configuration.cpp (+0/-1)
src/server/frontend/session_mediator.cpp (+1/-4)
src/server/graphics/android/android_buffer_allocator.cpp (+0/-11)
src/server/graphics/android/android_graphic_buffer_allocator.h (+0/-2)
src/server/graphics/android/android_platform.cpp (+12/-0)
src/server/graphics/android/android_platform.h (+1/-0)
src/server/graphics/gbm/gbm_buffer_allocator.cpp (+0/-10)
src/server/graphics/gbm/gbm_buffer_allocator.h (+0/-3)
src/server/graphics/gbm/gbm_platform.cpp (+12/-0)
src/server/graphics/gbm/gbm_platform.h (+1/-0)
tests/integration-tests/graphics/gbm/test_buffer_integration.cpp (+5/-5)
tests/integration-tests/test_display_info.cpp (+16/-15)
tests/integration-tests/test_drm_auth_magic.cpp (+5/-0)
tests/integration-tests/test_surfaceloop.cpp (+11/-5)
tests/mir_test_framework/testing_server_options.cpp (+5/-5)
tests/unit-tests/frontend/test_session_mediator.cpp (+5/-23)
tests/unit-tests/frontend/test_session_mediator_android.cpp (+1/-19)
tests/unit-tests/frontend/test_session_mediator_gbm.cpp (+7/-18)
tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp (+0/-31)
tests/unit-tests/graphics/android/test_android_platform.cpp (+36/-2)
tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp (+0/-24)
tests/unit-tests/graphics/gbm/test_gbm_platform.cpp (+27/-0)
tests/unit-tests/graphics/test_graphics_platform.cpp (+2/-1)
To merge this branch: bzr merge lp:~kdub/mir/reduce-mediator-dependencies
Reviewer Review Type Date Requested Status
Alan Griffiths Needs Fixing
Alexandros Frantzis (community) Needs Information
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+166622@code.launchpad.net

Commit message

mf::SessionMediator had both mc::GraphicBufferAllocator and mg::Platform as a dependency. This is because it needed to query the /platform's/ supported pixel types. Tease out this dependency by moving the function to get the platform's pixel formats from the buffer factory to the platform, and eliminate the graphic buffer factory interface from the SessionMediator

Description of the change

mf::SessionMediator had both mc::GraphicBufferAllocator and mg::Platform as a dependency. This is because it needed to query the /platform's/ supported pixel types. Tease out this dependency by moving the function to get the platform's pixel formats from the buffer factory to the platform, and eliminate the graphic buffer factory interface from the SessionMediator

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

I think that mg::Platform is probably also an unneeded dependency for SessionMediator, but we can tease that out in a subsequent mp

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

I am not sure about this. We are talking about the pixel format of created buffers, so the buffer allocator, which receives requests for buffer creation, seems to me to be the one who should know/provide that information, not the Platform in general.

Is there another reason we want to eliminate the allocator dependency from session mediator, besides reducing the number of dependencies?

I think we are attacking the problem from the wrong angle, though. The session mediator doesn't need to know about either the mg::Platform or the mc::BufferAllocator. It just needs leaner mf::IPCPackaging and mf::SupportedPixelFormats interfaces, that could be implemented by whichever object we want (even an adapter object if needed).

Needs Information == Needs Discussion

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

I agree with all the motivations discussed by Kevin and Alexandros - it is wrong that SessionMediator has a dependency on GraphicBufferAllocator simply so that it can provide the information needed to form a request to Shell::create_surface_for().

But I don't see that moving this dependency to mg::Platform is the right approach.

Surely, the method ought to go to Shell (or Session?) - as that is the interface that (eventually, after a round trip to the client) consumes the information. (Admittedly Shell doesn't have direct access to the supported pixels either, so there's a domino effect.)

Needs Discussion

PS why the sudden urge to fix this? Is there some new motivation that's come to light but hasn't been mentioned?

review: Needs Fixing
Revision history for this message
Kevin DuBois (kdub) wrote :

It seems the best approach for correcting the dependency would be to get the BufferAllocator and the Platform to be owned somewhere else and the SessionMediator to access this through the appropriate interface... I'm not too attached to this branch, so I think I'll reject it in favor of refactoring a different way.

as to the 'why the sudden urge to fix this', in another branch, I was working on getting the swapinterval0 messages to come over the wire, and finding things in this part of the code difficult to mock/test.

Unmerged revisions

714. By Kevin DuBois

get android tests to pass

713. By Kevin DuBois

get all gbm to compile/pass

712. By Kevin DuBois

change session mediator test so we dont depend on the buffer allocator in the frontend

711. By Robert Ancell

Revert removal of mir_connection_drm_auth_magic() - it is required for XMir.

Approved by PS Jenkins bot, Robert Carr, Alexandros Frantzis, Chris Halse Rogers.

710. By Alan Griffiths

graphics::android: add some customization points to DefaultFramebufferFactory.

Approved by PS Jenkins bot, Alexandros Frantzis, Robert Ancell, Robert Carr.

709. By Robert Carr

Demote old input logs to a legacy report. Replace with a new InputReport interface and both logging and LTTNG based implementations.

Approved by Alan Griffiths, Alexandros Frantzis, PS Jenkins bot.

708. By Alexandros Frantzis

client: Move rpc components to their own subdirectory and namespace.

Approved by Alan Griffiths, Robert Carr, PS Jenkins bot.

707. By Alan Griffiths

compositor: another destructor marked non-throwing.

Approved by PS Jenkins bot, Robert Carr.

706. By Alexandros Frantzis

client: Introduce RpcReport class and logging implementation for it.

Approved by Alan Griffiths, Kevin DuBois, Robert Ancell, PS Jenkins bot.

705. By Robert Ancell

Close dmabuf file descriptor when the GBMBuffer is destroyed. Fixes: https://bugs.launchpad.net/bugs/1185183.

Approved by Alan Griffiths, Alexandros Frantzis, PS Jenkins bot.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/render_surfaces.cpp'
2--- examples/render_surfaces.cpp 2013-05-21 17:16:43 +0000
3+++ examples/render_surfaces.cpp 2013-05-31 00:41:23 +0000
4@@ -17,7 +17,7 @@
5 */
6
7 #include "mir/compositor/default_compositing_strategy.h"
8-#include "mir/compositor/graphic_buffer_allocator.h"
9+#include "mir/graphics/platform.h"
10 #include "mir/frontend/communicator.h"
11 #include "mir/shell/surface_creation_parameters.h"
12 #include "mir/geometry/size.h"
13@@ -376,7 +376,7 @@
14 float const angular_step = 2.0 * M_PI / moveables.size();
15 float const w = display_size.width.as_uint32_t();
16 float const h = display_size.height.as_uint32_t();
17- auto const surface_pf = the_buffer_allocator()->supported_pixel_formats()[0];
18+ auto const surface_pf = the_graphics_platform()->supported_pixel_formats()[0];
19
20 int i = 0;
21 for (auto& m : moveables)
22
23=== modified file 'include/server/mir/compositor/graphic_buffer_allocator.h'
24--- include/server/mir/compositor/graphic_buffer_allocator.h 2013-05-24 15:44:11 +0000
25+++ include/server/mir/compositor/graphic_buffer_allocator.h 2013-05-31 00:41:23 +0000
26@@ -21,7 +21,6 @@
27
28 #include "mir/compositor/buffer.h"
29
30-#include <vector>
31 #include <memory>
32
33 namespace mir
34@@ -39,8 +38,6 @@
35 virtual std::shared_ptr<Buffer> alloc_buffer(
36 BufferProperties const& buffer_properties) = 0;
37
38- virtual std::vector<geometry::PixelFormat> supported_pixel_formats() = 0;
39-
40 protected:
41 GraphicBufferAllocator() = default;
42 GraphicBufferAllocator(const GraphicBufferAllocator&) = delete;
43
44=== modified file 'include/server/mir/frontend/session_mediator.h'
45--- include/server/mir/frontend/session_mediator.h 2013-05-30 03:50:54 +0000
46+++ include/server/mir/frontend/session_mediator.h 2013-05-31 00:41:23 +0000
47@@ -62,7 +62,6 @@
48 std::shared_ptr<Shell> const& shell,
49 std::shared_ptr<graphics::Platform> const& graphics_platform,
50 std::shared_ptr<graphics::ViewableArea> const& viewable_area,
51- std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator,
52 std::shared_ptr<SessionMediatorReport> const& report,
53 std::shared_ptr<events::EventSink> const& event_sink,
54 std::shared_ptr<ResourceCache> const& resource_cache);
55
56=== modified file 'include/server/mir/graphics/platform.h'
57--- include/server/mir/graphics/platform.h 2013-05-17 18:18:20 +0000
58+++ include/server/mir/graphics/platform.h 2013-05-31 00:41:23 +0000
59@@ -20,7 +20,10 @@
60 #ifndef MIR_GRAPHICS_PLATFORM_H_
61 #define MIR_GRAPHICS_PLATFORM_H_
62
63+#include "mir/geometry/pixel_format.h"
64+
65 #include <memory>
66+#include <vector>
67
68 namespace mir
69 {
70@@ -62,6 +65,7 @@
71 std::shared_ptr<compositor::Buffer> const& buffer) const = 0;
72
73 virtual std::shared_ptr<InternalClient> create_internal_client() = 0;
74+ virtual std::vector<geometry::PixelFormat> supported_pixel_formats() = 0;
75 };
76
77 // Create and return a new graphics platform.
78
79=== modified file 'include/test/mir_test_doubles/stub_platform.h'
80--- include/test/mir_test_doubles/stub_platform.h 2013-05-17 18:18:20 +0000
81+++ include/test/mir_test_doubles/stub_platform.h 2013-05-31 00:41:23 +0000
82@@ -57,6 +57,11 @@
83 std::shared_ptr<compositor::Buffer> const&) const
84 {
85 }
86+
87+ virtual std::vector<geometry::PixelFormat> supported_pixel_formats()
88+ {
89+ return std::vector<geometry::PixelFormat>();
90+ }
91 };
92 }
93 }
94
95=== modified file 'src/server/default_server_configuration.cpp'
96--- src/server/default_server_configuration.cpp 2013-05-28 18:24:07 +0000
97+++ src/server/default_server_configuration.cpp 2013-05-31 00:41:23 +0000
98@@ -123,7 +123,6 @@
99 shell,
100 graphics_platform,
101 graphics_display,
102- buffer_allocator,
103 sm_report,
104 sink,
105 resource_cache());
106
107=== modified file 'src/server/frontend/session_mediator.cpp'
108--- src/server/frontend/session_mediator.cpp 2013-05-22 00:44:25 +0000
109+++ src/server/frontend/session_mediator.cpp 2013-05-31 00:41:23 +0000
110@@ -27,7 +27,6 @@
111 #include "mir/compositor/buffer_id.h"
112 #include "mir/compositor/buffer.h"
113 #include "mir/surfaces/buffer_bundle.h"
114-#include "mir/compositor/graphic_buffer_allocator.h"
115 #include "mir/geometry/dimensions.h"
116 #include "mir/graphics/platform.h"
117 #include "mir/graphics/viewable_area.h"
118@@ -46,14 +45,12 @@
119 std::shared_ptr<frontend::Shell> const& shell,
120 std::shared_ptr<graphics::Platform> const & graphics_platform,
121 std::shared_ptr<graphics::ViewableArea> const& viewable_area,
122- std::shared_ptr<compositor::GraphicBufferAllocator> const& buffer_allocator,
123 std::shared_ptr<SessionMediatorReport> const& report,
124 std::shared_ptr<events::EventSink> const& event_sink,
125 std::shared_ptr<ResourceCache> const& resource_cache) :
126 shell(shell),
127 graphics_platform(graphics_platform),
128 viewable_area(viewable_area),
129- buffer_allocator(buffer_allocator),
130 report(report),
131 event_sink(event_sink),
132 resource_cache(resource_cache),
133@@ -85,7 +82,7 @@
134 display_info->set_width(view_area.size.width.as_uint32_t());
135 display_info->set_height(view_area.size.height.as_uint32_t());
136
137- auto supported_pixel_formats = buffer_allocator->supported_pixel_formats();
138+ auto supported_pixel_formats = graphics_platform->supported_pixel_formats();
139 for (auto pf : supported_pixel_formats)
140 display_info->add_supported_pixel_format(static_cast<uint32_t>(pf));
141
142
143=== modified file 'src/server/graphics/android/android_buffer_allocator.cpp'
144--- src/server/graphics/android/android_buffer_allocator.cpp 2013-05-01 22:05:55 +0000
145+++ src/server/graphics/android/android_buffer_allocator.cpp 2013-05-31 00:41:23 +0000
146@@ -83,17 +83,6 @@
147 return buffer;
148 }
149
150-std::vector<geom::PixelFormat> mga::AndroidGraphicBufferAllocator::supported_pixel_formats()
151-{
152- static std::vector<geom::PixelFormat> const pixel_formats{
153- geom::PixelFormat::abgr_8888,
154- geom::PixelFormat::xbgr_8888,
155- geom::PixelFormat::bgr_888
156- };
157-
158- return pixel_formats;
159-}
160-
161 mga::BufferUsage mga::AndroidGraphicBufferAllocator::convert_from_compositor_usage(mc::BufferUsage usage)
162 {
163 switch (usage)
164
165=== modified file 'src/server/graphics/android/android_graphic_buffer_allocator.h'
166--- src/server/graphics/android/android_graphic_buffer_allocator.h 2013-05-24 15:51:37 +0000
167+++ src/server/graphics/android/android_graphic_buffer_allocator.h 2013-05-31 00:41:23 +0000
168@@ -50,8 +50,6 @@
169 std::shared_ptr<Buffer> alloc_buffer_platform(
170 geometry::Size sz, geometry::PixelFormat pf, BufferUsage use);
171
172- std::vector<geometry::PixelFormat> supported_pixel_formats();
173-
174 static BufferUsage convert_from_compositor_usage(compositor::BufferUsage usage);
175
176 private:
177
178=== modified file 'src/server/graphics/android/android_platform.cpp'
179--- src/server/graphics/android/android_platform.cpp 2013-05-24 15:44:11 +0000
180+++ src/server/graphics/android/android_platform.cpp 2013-05-31 00:41:23 +0000
181@@ -33,6 +33,7 @@
182 namespace mga=mir::graphics::android;
183 namespace mc=mir::compositor;
184 namespace mf=mir::frontend;
185+namespace geom = mir::geometry;
186
187 mga::AndroidPlatform::AndroidPlatform(std::shared_ptr<mg::DisplayReport> const& display_report)
188 : display_report(display_report)
189@@ -98,6 +99,17 @@
190 return std::make_shared<mga::InternalClient>();
191 }
192
193+std::vector<geom::PixelFormat> mga::AndroidPlatform::supported_pixel_formats()
194+{
195+ static std::vector<geom::PixelFormat> const pixel_formats{
196+ geom::PixelFormat::abgr_8888,
197+ geom::PixelFormat::xbgr_8888,
198+ geom::PixelFormat::bgr_888
199+ };
200+
201+ return pixel_formats;
202+}
203+
204 std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<DisplayReport> const& display_report)
205 {
206 return std::make_shared<mga::AndroidPlatform>(display_report);
207
208=== modified file 'src/server/graphics/android/android_platform.h'
209--- src/server/graphics/android/android_platform.h 2013-05-24 14:11:14 +0000
210+++ src/server/graphics/android/android_platform.h 2013-05-31 00:41:23 +0000
211@@ -44,6 +44,7 @@
212 std::shared_ptr<InternalClient> create_internal_client();
213 void fill_ipc_package(std::shared_ptr<compositor::BufferIPCPacker> const& packer,
214 std::shared_ptr<compositor::Buffer> const& buffer) const;
215+ std::vector<geometry::PixelFormat> supported_pixel_formats();
216
217 private:
218 // TODO a design that has this and create_buffer_allocator is missing simplicity
219
220=== modified file 'src/server/graphics/gbm/gbm_buffer_allocator.cpp'
221--- src/server/graphics/gbm/gbm_buffer_allocator.cpp 2013-04-29 23:59:18 +0000
222+++ src/server/graphics/gbm/gbm_buffer_allocator.cpp 2013-05-31 00:41:23 +0000
223@@ -182,13 +182,3 @@
224
225 return buffer;
226 }
227-
228-std::vector<geom::PixelFormat> mgg::GBMBufferAllocator::supported_pixel_formats()
229-{
230- static std::vector<geom::PixelFormat> const pixel_formats{
231- geom::PixelFormat::argb_8888,
232- geom::PixelFormat::xrgb_8888
233- };
234-
235- return pixel_formats;
236-}
237
238=== modified file 'src/server/graphics/gbm/gbm_buffer_allocator.h'
239--- src/server/graphics/gbm/gbm_buffer_allocator.h 2013-04-24 05:22:20 +0000
240+++ src/server/graphics/gbm/gbm_buffer_allocator.h 2013-05-31 00:41:23 +0000
241@@ -20,7 +20,6 @@
242 #define MIR_PLATFORM_GBM_GBM_BUFFER_ALLOCATOR_H_
243
244 #include "mir/compositor/graphic_buffer_allocator.h"
245-#include "mir/compositor/buffer_id.h"
246
247 #include <memory>
248
249@@ -45,8 +44,6 @@
250 virtual std::shared_ptr<compositor::Buffer> alloc_buffer(
251 compositor::BufferProperties const& buffer_properties);
252
253- std::vector<geometry::PixelFormat> supported_pixel_formats();
254-
255 private:
256 std::shared_ptr<GBMPlatform> platform;
257 std::shared_ptr<graphics::BufferInitializer> buffer_initializer;
258
259=== modified file 'src/server/graphics/gbm/gbm_platform.cpp'
260--- src/server/graphics/gbm/gbm_platform.cpp 2013-05-30 03:50:54 +0000
261+++ src/server/graphics/gbm/gbm_platform.cpp 2013-05-31 00:41:23 +0000
262@@ -34,6 +34,8 @@
263 namespace mg = mir::graphics;
264 namespace mgg = mg::gbm;
265 namespace mc = mir::compositor;
266+namespace geom = mir::geometry;
267+
268 namespace
269 {
270
271@@ -143,6 +145,16 @@
272 return std::make_shared<mgg::InternalClient>(internal_native_display);
273 }
274
275+std::vector<geom::PixelFormat> mgg::GBMPlatform::supported_pixel_formats()
276+{
277+ static std::vector<geom::PixelFormat> const pixel_formats{
278+ geom::PixelFormat::argb_8888,
279+ geom::PixelFormat::xrgb_8888
280+ };
281+
282+ return pixel_formats;
283+}
284+
285 std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<DisplayReport> const& report)
286 {
287 auto real_fops = std::make_shared<RealVTFileOperations>();
288
289=== modified file 'src/server/graphics/gbm/gbm_platform.h'
290--- src/server/graphics/gbm/gbm_platform.h 2013-05-30 03:50:54 +0000
291+++ src/server/graphics/gbm/gbm_platform.h 2013-05-31 00:41:23 +0000
292@@ -52,6 +52,7 @@
293
294 void fill_ipc_package(std::shared_ptr<compositor::BufferIPCPacker> const& packer,
295 std::shared_ptr<compositor::Buffer> const& buffer) const;
296+ std::vector<geometry::PixelFormat> supported_pixel_formats();
297
298 /* From DRMAuthenticator */
299 void drm_auth_magic(drm_magic_t magic);
300
301=== modified file 'tests/integration-tests/graphics/gbm/test_buffer_integration.cpp'
302--- tests/integration-tests/graphics/gbm/test_buffer_integration.cpp 2013-05-17 18:48:07 +0000
303+++ tests/integration-tests/graphics/gbm/test_buffer_integration.cpp 2013-05-31 00:41:23 +0000
304@@ -74,11 +74,6 @@
305 {
306 return std::shared_ptr<mc::Buffer>(new StubBufferThread());
307 }
308-
309- std::vector<geom::PixelFormat> supported_pixel_formats()
310- {
311- return std::vector<geom::PixelFormat>();
312- }
313 };
314
315 class StubGraphicPlatform : public mg::Platform
316@@ -108,6 +103,11 @@
317 void fill_ipc_package(std::shared_ptr<mc::BufferIPCPacker> const&, std::shared_ptr<mc::Buffer> const&) const
318 {
319 }
320+
321+ std::vector<geom::PixelFormat> supported_pixel_formats()
322+ {
323+ return std::vector<geom::PixelFormat>();
324+ }
325 };
326
327 class GBMBufferIntegration : public ::testing::Test
328
329=== modified file 'tests/integration-tests/test_display_info.cpp'
330--- tests/integration-tests/test_display_info.cpp 2013-05-17 18:18:20 +0000
331+++ tests/integration-tests/test_display_info.cpp 2013-05-31 00:41:23 +0000
332@@ -71,18 +71,6 @@
333 return std::shared_ptr<mc::Buffer>(new mtd::StubBuffer());
334 }
335
336- std::vector<geom::PixelFormat> supported_pixel_formats()
337- {
338- return pixel_formats;
339- }
340-
341- static std::vector<geom::PixelFormat> const pixel_formats;
342-};
343-
344-std::vector<geom::PixelFormat> const StubGraphicBufferAllocator::pixel_formats{
345- geom::PixelFormat::bgr_888,
346- geom::PixelFormat::abgr_8888,
347- geom::PixelFormat::xbgr_8888
348 };
349
350 class StubPlatform : public mg::Platform
351@@ -113,7 +101,20 @@
352 std::shared_ptr<mc::Buffer> const&) const
353 {
354 }
355-};
356+
357+ std::vector<geom::PixelFormat> supported_pixel_formats()
358+ {
359+ return pixel_formats;
360+ }
361+ static std::vector<geom::PixelFormat> const pixel_formats;
362+};
363+
364+std::vector<geom::PixelFormat> const StubPlatform::pixel_formats{
365+ geom::PixelFormat::bgr_888,
366+ geom::PixelFormat::abgr_8888,
367+ geom::PixelFormat::xbgr_8888
368+};
369+
370
371 void connection_callback(MirConnection* connection, void* context)
372 {
373@@ -159,12 +160,12 @@
374 EXPECT_EQ(StubDisplay::rectangle.size.height.as_uint32_t(),
375 static_cast<uint32_t>(info.height));
376
377- ASSERT_EQ(StubGraphicBufferAllocator::pixel_formats.size(),
378+ ASSERT_EQ(StubPlatform::pixel_formats.size(),
379 static_cast<uint32_t>(info.supported_pixel_format_items));
380
381 for (int i = 0; i < info.supported_pixel_format_items; ++i)
382 {
383- EXPECT_EQ(StubGraphicBufferAllocator::pixel_formats[i],
384+ EXPECT_EQ(StubPlatform::pixel_formats[i],
385 static_cast<geom::PixelFormat>(info.supported_pixel_format[i]));
386 }
387
388
389=== modified file 'tests/integration-tests/test_drm_auth_magic.cpp'
390--- tests/integration-tests/test_drm_auth_magic.cpp 2013-05-30 03:50:54 +0000
391+++ tests/integration-tests/test_drm_auth_magic.cpp 2013-05-31 00:41:23 +0000
392@@ -89,6 +89,11 @@
393 {
394 }
395
396+ std::vector<geom::PixelFormat> supported_pixel_formats()
397+ {
398+ return std::vector<geom::PixelFormat>();
399+ }
400+
401 MOCK_METHOD1(drm_auth_magic, void(unsigned int));
402 };
403
404
405=== modified file 'tests/integration-tests/test_surfaceloop.cpp'
406--- tests/integration-tests/test_surfaceloop.cpp 2013-05-24 15:44:11 +0000
407+++ tests/integration-tests/test_surfaceloop.cpp 2013-05-31 00:41:23 +0000
408@@ -98,11 +98,6 @@
409 std::shared_ptr<mc::Buffer> (mc::BufferProperties const&));
410
411
412- std::vector<geom::PixelFormat> supported_pixel_formats()
413- {
414- return std::vector<geom::PixelFormat>();
415- }
416-
417 std::unique_ptr<mc::Buffer> on_create_swapper(mc::BufferProperties const&)
418 {
419 return std::unique_ptr<mc::Buffer>(new mtd::StubBuffer(::buffer_properties));
420@@ -366,6 +361,12 @@
421 std::shared_ptr<mc::Buffer> const&) const
422 {
423 }
424+
425+ std::vector<geom::PixelFormat> supported_pixel_formats()
426+ {
427+ return std::vector<geom::PixelFormat>();
428+ }
429+
430 };
431
432 std::shared_ptr<mg::Platform> the_graphics_platform()
433@@ -503,6 +504,11 @@
434 std::shared_ptr<mc::Buffer> const&) const
435 {
436 }
437+
438+ std::vector<geom::PixelFormat> supported_pixel_formats()
439+ {
440+ return std::vector<geom::PixelFormat>();
441+ }
442 };
443
444 std::shared_ptr<mg::Platform> the_graphics_platform()
445
446=== modified file 'tests/mir_test_framework/testing_server_options.cpp'
447--- tests/mir_test_framework/testing_server_options.cpp 2013-05-21 15:11:41 +0000
448+++ tests/mir_test_framework/testing_server_options.cpp 2013-05-31 00:41:23 +0000
449@@ -66,11 +66,6 @@
450 {
451 return std::unique_ptr<mc::Buffer>(new mtd::StubBuffer(properties));
452 }
453-
454- std::vector<geom::PixelFormat> supported_pixel_formats()
455- {
456- return std::vector<geom::PixelFormat>();
457- }
458 };
459
460 class StubDisplay : public mg::Display
461@@ -127,6 +122,11 @@
462 std::shared_ptr<mc::Buffer> const&) const
463 {
464 }
465+
466+ std::vector<geom::PixelFormat> supported_pixel_formats()
467+ {
468+ return std::vector<geom::PixelFormat>();
469+ }
470 };
471
472 class StubRenderer : public mg::Renderer
473
474=== modified file 'tests/unit-tests/frontend/test_session_mediator.cpp'
475--- tests/unit-tests/frontend/test_session_mediator.cpp 2013-05-30 03:50:54 +0000
476+++ tests/unit-tests/frontend/test_session_mediator.cpp 2013-05-31 00:41:23 +0000
477@@ -87,24 +87,6 @@
478
479 int const StubbedSession::testing_client_input_fd{11};
480
481-class MockGraphicBufferAllocator : public mc::GraphicBufferAllocator
482-{
483-public:
484- MockGraphicBufferAllocator()
485- {
486- ON_CALL(*this, supported_pixel_formats())
487- .WillByDefault(testing::Return(std::vector<geom::PixelFormat>()));
488- }
489-
490- std::shared_ptr<mc::Buffer> alloc_buffer(mc::BufferProperties const&)
491- {
492- return std::shared_ptr<mc::Buffer>();
493- }
494-
495- MOCK_METHOD0(supported_pixel_formats, std::vector<geom::PixelFormat>());
496- ~MockGraphicBufferAllocator() noexcept {}
497-};
498-
499 class MockPlatform : public mg::Platform
500 {
501 public:
502@@ -117,6 +99,8 @@
503 .WillByDefault(Return(std::make_shared<mtd::NullDisplay>()));
504 ON_CALL(*this, get_ipc_package())
505 .WillByDefault(Return(std::make_shared<mg::PlatformIPCPackage>()));
506+ ON_CALL(*this, supported_pixel_formats())
507+ .WillByDefault(Return(std::vector<geom::PixelFormat>({})));
508 }
509
510 MOCK_METHOD1(create_buffer_allocator, std::shared_ptr<mc::GraphicBufferAllocator>(std::shared_ptr<mg::BufferInitializer> const&));
511@@ -125,6 +109,7 @@
512 MOCK_METHOD0(create_internal_client, std::shared_ptr<mg::InternalClient>());
513 MOCK_CONST_METHOD2(fill_ipc_package, void(std::shared_ptr<mc::BufferIPCPacker> const&,
514 std::shared_ptr<mc::Buffer> const&));
515+ MOCK_METHOD0(supported_pixel_formats, std::vector<geom::PixelFormat>());
516 };
517
518 class NullEventSink : public mir::events::EventSink
519@@ -139,11 +124,9 @@
520 : shell{std::make_shared<testing::NiceMock<mtd::MockShell>>()},
521 graphics_platform{std::make_shared<MockPlatform>()},
522 graphics_display{std::make_shared<mtd::NullDisplay>()},
523- buffer_allocator{std::make_shared<testing::NiceMock<MockGraphicBufferAllocator>>()},
524 report{std::make_shared<mf::NullSessionMediatorReport>()},
525 resource_cache{std::make_shared<mf::ResourceCache>()},
526- mediator{shell, graphics_platform, graphics_display,
527- buffer_allocator, report,
528+ mediator{shell, graphics_platform, graphics_display, report,
529 std::make_shared<NullEventSink>(),
530 resource_cache},
531 stubbed_session{std::make_shared<StubbedSession>()},
532@@ -158,7 +141,6 @@
533 std::shared_ptr<testing::NiceMock<mtd::MockShell>> const shell;
534 std::shared_ptr<MockPlatform> const graphics_platform;
535 std::shared_ptr<mg::Display> const graphics_display;
536- std::shared_ptr<testing::NiceMock<MockGraphicBufferAllocator>> const buffer_allocator;
537 std::shared_ptr<mf::SessionMediatorReport> const report;
538 std::shared_ptr<mf::ResourceCache> const resource_cache;
539 mf::SessionMediator mediator;
540@@ -309,7 +291,7 @@
541 geom::PixelFormat::xbgr_8888
542 };
543
544- EXPECT_CALL(*buffer_allocator, supported_pixel_formats())
545+ EXPECT_CALL(*graphics_platform, supported_pixel_formats())
546 .WillOnce(Return(pixel_formats));
547
548 mediator.connect(nullptr, &connect_parameters, &connection, null_callback.get());
549
550=== modified file 'tests/unit-tests/frontend/test_session_mediator_android.cpp'
551--- tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-05-30 03:50:54 +0000
552+++ tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-05-31 00:41:23 +0000
553@@ -16,7 +16,6 @@
554 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
555 */
556
557-#include "mir/compositor/graphic_buffer_allocator.h"
558 #include "mir/frontend/session_mediator_report.h"
559 #include "mir/frontend/session_mediator.h"
560 #include "mir/frontend/resource_cache.h"
561@@ -49,20 +48,6 @@
562 namespace
563 {
564
565-class StubGraphicBufferAllocator : public mc::GraphicBufferAllocator
566-{
567-public:
568- std::shared_ptr<mc::Buffer> alloc_buffer(mc::BufferProperties const&)
569- {
570- return std::shared_ptr<mc::Buffer>();
571- }
572-
573- virtual std::vector<geom::PixelFormat> supported_pixel_formats()
574- {
575- return std::vector<geom::PixelFormat>();
576- }
577-};
578-
579 class NullEventSink : public mir::events::EventSink
580 {
581 public:
582@@ -75,11 +60,9 @@
583 : shell{std::make_shared<mtd::StubShell>()},
584 graphics_platform{std::make_shared<mtd::StubPlatform>()},
585 graphics_display{std::make_shared<mtd::NullDisplay>()},
586- buffer_allocator{std::make_shared<StubGraphicBufferAllocator>()},
587 report{std::make_shared<mf::NullSessionMediatorReport>()},
588 resource_cache{std::make_shared<mf::ResourceCache>()},
589- mediator{shell, graphics_platform, graphics_display,
590- buffer_allocator, report,
591+ mediator{shell, graphics_platform, graphics_display, report,
592 std::make_shared<NullEventSink>(),
593 resource_cache},
594 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}
595@@ -89,7 +72,6 @@
596 std::shared_ptr<mtd::StubShell> const shell;
597 std::shared_ptr<mtd::StubPlatform> const graphics_platform;
598 std::shared_ptr<mg::Display> const graphics_display;
599- std::shared_ptr<mc::GraphicBufferAllocator> const buffer_allocator;
600 std::shared_ptr<mf::SessionMediatorReport> const report;
601 std::shared_ptr<mf::ResourceCache> const resource_cache;
602 mf::SessionMediator mediator;
603
604=== modified file 'tests/unit-tests/frontend/test_session_mediator_gbm.cpp'
605--- tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-05-30 03:50:54 +0000
606+++ tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-05-31 00:41:23 +0000
607@@ -49,27 +49,13 @@
608 namespace
609 {
610
611-class StubGraphicBufferAllocator : public mc::GraphicBufferAllocator
612-{
613-public:
614- std::shared_ptr<mc::Buffer> alloc_buffer(mc::BufferProperties const&)
615- {
616- return std::shared_ptr<mc::Buffer>();
617- }
618-
619- virtual std::vector<geom::PixelFormat> supported_pixel_formats()
620- {
621- return std::vector<geom::PixelFormat>();
622- }
623-};
624-
625 class MockAuthenticatingPlatform : public mg::Platform, public mg::DRMAuthenticator
626 {
627 public:
628 std::shared_ptr<mc::GraphicBufferAllocator> create_buffer_allocator(
629 const std::shared_ptr<mg::BufferInitializer>& /*buffer_initializer*/)
630 {
631- return std::shared_ptr<StubGraphicBufferAllocator>();
632+ return std::shared_ptr<mc::GraphicBufferAllocator>();
633 }
634
635 std::shared_ptr<mg::Display> create_display()
636@@ -92,6 +78,11 @@
637 {
638 }
639
640+ virtual std::vector<geom::PixelFormat> supported_pixel_formats()
641+ {
642+ return std::vector<geom::PixelFormat>();
643+ }
644+
645 MOCK_METHOD1(drm_auth_magic, void(drm_magic_t));
646 };
647
648@@ -107,11 +98,9 @@
649 : shell{std::make_shared<mtd::StubShell>()},
650 mock_platform{std::make_shared<MockAuthenticatingPlatform>()},
651 graphics_display{std::make_shared<mtd::NullDisplay>()},
652- buffer_allocator{std::make_shared<StubGraphicBufferAllocator>()},
653 report{std::make_shared<mf::NullSessionMediatorReport>()},
654 resource_cache{std::make_shared<mf::ResourceCache>()},
655- mediator{shell, mock_platform, graphics_display,
656- buffer_allocator, report,
657+ mediator{shell, mock_platform, graphics_display, report,
658 std::make_shared<NullEventSink>(),
659 resource_cache},
660 null_callback{google::protobuf::NewPermanentCallback(google::protobuf::DoNothing)}
661
662=== modified file 'tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp'
663--- tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp 2013-05-24 15:51:37 +0000
664+++ tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp 2013-05-31 00:41:23 +0000
665@@ -54,37 +54,6 @@
666 mga::AndroidGraphicBufferAllocator allocator(null_buffer_initializer);
667 }
668
669-TEST_F(AndroidGraphicBufferAllocatorTest, supported_pixel_formats_contain_common_formats)
670-{
671- mga::AndroidGraphicBufferAllocator allocator{null_buffer_initializer};
672- auto supported_pixel_formats = allocator.supported_pixel_formats();
673-
674- auto abgr_8888_count = std::count(supported_pixel_formats.begin(),
675- supported_pixel_formats.end(),
676- geom::PixelFormat::abgr_8888);
677-
678- auto xbgr_8888_count = std::count(supported_pixel_formats.begin(),
679- supported_pixel_formats.end(),
680- geom::PixelFormat::xbgr_8888);
681-
682- auto bgr_888_count = std::count(supported_pixel_formats.begin(),
683- supported_pixel_formats.end(),
684- geom::PixelFormat::bgr_888);
685-
686- EXPECT_EQ(1, abgr_8888_count);
687- EXPECT_EQ(1, xbgr_8888_count);
688- EXPECT_EQ(1, bgr_888_count);
689-}
690-
691-TEST_F(AndroidGraphicBufferAllocatorTest, supported_pixel_formats_have_sane_default_in_first_position)
692-{
693- mga::AndroidGraphicBufferAllocator allocator{null_buffer_initializer};
694- auto supported_pixel_formats = allocator.supported_pixel_formats();
695-
696- ASSERT_FALSE(supported_pixel_formats.empty());
697- EXPECT_EQ(geom::PixelFormat::abgr_8888, supported_pixel_formats[0]);
698-}
699-
700 TEST_F(AndroidGraphicBufferAllocatorTest, alloc_buffer_calls_initializer)
701 {
702 using namespace testing;
703
704=== modified file 'tests/unit-tests/graphics/android/test_android_platform.cpp'
705--- tests/unit-tests/graphics/android/test_android_platform.cpp 2013-05-17 18:48:07 +0000
706+++ tests/unit-tests/graphics/android/test_android_platform.cpp 2013-05-31 00:41:23 +0000
707@@ -29,7 +29,7 @@
708 namespace mtd=mir::test::doubles;
709 namespace geom=mir::geometry;
710
711-class PlatformBufferIPCPackaging : public ::testing::Test
712+class AndroidPlatform : public ::testing::Test
713 {
714 protected:
715 virtual void SetUp()
716@@ -71,7 +71,7 @@
717 };
718
719 /* ipc packaging tests */
720-TEST_F(PlatformBufferIPCPackaging, test_ipc_data_packed_correctly)
721+TEST_F(AndroidPlatform, test_ipc_data_packed_correctly)
722 {
723 auto mock_buffer = std::make_shared<mtd::MockBuffer>();
724 geom::Stride dummy_stride(4390);
725@@ -101,3 +101,37 @@
726 platform->fill_ipc_package(mock_packer, mock_buffer);
727
728 }
729+
730+TEST(AndroidPlatformFormats, supported_pixel_formats_contain_common_formats)
731+{
732+ auto stub_display_report = std::make_shared<mg::NullDisplayReport>();
733+ auto platform = mg::create_platform(stub_display_report);
734+ auto supported_pixel_formats = platform->supported_pixel_formats();
735+
736+ auto abgr_8888_count = std::count(supported_pixel_formats.begin(),
737+ supported_pixel_formats.end(),
738+ geom::PixelFormat::abgr_8888);
739+
740+ auto xbgr_8888_count = std::count(supported_pixel_formats.begin(),
741+ supported_pixel_formats.end(),
742+ geom::PixelFormat::xbgr_8888);
743+
744+ auto bgr_888_count = std::count(supported_pixel_formats.begin(),
745+ supported_pixel_formats.end(),
746+ geom::PixelFormat::bgr_888);
747+
748+ EXPECT_EQ(1, abgr_8888_count);
749+ EXPECT_EQ(1, xbgr_8888_count);
750+ EXPECT_EQ(1, bgr_888_count);
751+}
752+
753+TEST(AndroidPlatformFormats, supported_pixel_formats_have_sane_default_in_first_position)
754+{
755+ auto stub_display_report = std::make_shared<mg::NullDisplayReport>();
756+ auto platform = mg::create_platform(stub_display_report);
757+ auto supported_pixel_formats = platform->supported_pixel_formats();
758+
759+ ASSERT_FALSE(supported_pixel_formats.empty());
760+ EXPECT_EQ(geom::PixelFormat::abgr_8888, supported_pixel_formats[0]);
761+}
762+
763
764=== modified file 'tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp'
765--- tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp 2013-05-20 15:55:48 +0000
766+++ tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp 2013-05-31 00:41:23 +0000
767@@ -254,27 +254,3 @@
768 mgg::GBMBufferAllocator allocator(platform, mock_buffer_initializer);
769 }, std::runtime_error);
770 }
771-
772-TEST_F(GBMBufferAllocatorTest, supported_pixel_formats_contain_common_formats)
773-{
774- auto supported_pixel_formats = allocator->supported_pixel_formats();
775-
776- auto argb_8888_count = std::count(supported_pixel_formats.begin(),
777- supported_pixel_formats.end(),
778- geom::PixelFormat::argb_8888);
779-
780- auto xrgb_8888_count = std::count(supported_pixel_formats.begin(),
781- supported_pixel_formats.end(),
782- geom::PixelFormat::xrgb_8888);
783-
784- EXPECT_EQ(1, argb_8888_count);
785- EXPECT_EQ(1, xrgb_8888_count);
786-}
787-
788-TEST_F(GBMBufferAllocatorTest, supported_pixel_formats_have_sane_default_in_first_position)
789-{
790- auto supported_pixel_formats = allocator->supported_pixel_formats();
791-
792- ASSERT_FALSE(supported_pixel_formats.empty());
793- EXPECT_EQ(geom::PixelFormat::argb_8888, supported_pixel_formats[0]);
794-}
795
796=== modified file 'tests/unit-tests/graphics/gbm/test_gbm_platform.cpp'
797--- tests/unit-tests/graphics/gbm/test_gbm_platform.cpp 2013-05-30 03:50:54 +0000
798+++ tests/unit-tests/graphics/gbm/test_gbm_platform.cpp 2013-05-31 00:41:23 +0000
799@@ -42,6 +42,7 @@
800 namespace mg = mir::graphics;
801 namespace mgg = mir::graphics::gbm;
802 namespace mtd = mir::test::doubles;
803+namespace geom = mir::geometry;
804
805 namespace
806 {
807@@ -276,3 +277,29 @@
808
809 EXPECT_FALSE(detector.detected_concurrent_calls());
810 }
811+
812+TEST_F(GBMGraphicsPlatform, supported_pixel_formats_contain_common_formats)
813+{
814+ auto platform = create_platform();
815+ auto supported_pixel_formats = platform->supported_pixel_formats();
816+
817+ auto argb_8888_count = std::count(supported_pixel_formats.begin(),
818+ supported_pixel_formats.end(),
819+ geom::PixelFormat::argb_8888);
820+
821+ auto xrgb_8888_count = std::count(supported_pixel_formats.begin(),
822+ supported_pixel_formats.end(),
823+ geom::PixelFormat::xrgb_8888);
824+
825+ EXPECT_EQ(1, argb_8888_count);
826+ EXPECT_EQ(1, xrgb_8888_count);
827+}
828+
829+TEST_F(GBMGraphicsPlatform, supported_pixel_formats_have_sane_default_in_first_position)
830+{
831+ auto platform = create_platform();
832+ auto supported_pixel_formats = platform->supported_pixel_formats();
833+
834+ ASSERT_FALSE(supported_pixel_formats.empty());
835+ EXPECT_EQ(geom::PixelFormat::argb_8888, supported_pixel_formats[0]);
836+}
837
838=== modified file 'tests/unit-tests/graphics/test_graphics_platform.cpp'
839--- tests/unit-tests/graphics/test_graphics_platform.cpp 2013-05-20 15:55:48 +0000
840+++ tests/unit-tests/graphics/test_graphics_platform.cpp 2013-05-31 00:41:23 +0000
841@@ -41,6 +41,7 @@
842 namespace mg = mir::graphics;
843 namespace ml = mir::logging;
844 namespace geom = mir::geometry;
845+namespace geom = mir::geometry;
846 namespace mtd = mir::test::doubles;
847
848 class GraphicsPlatform : public ::testing::Test
849@@ -113,7 +114,7 @@
850 {
851 auto platform = create_platform();
852 auto allocator = platform->create_buffer_allocator(buffer_initializer);
853- auto supported_pixel_formats = allocator->supported_pixel_formats();
854+ auto supported_pixel_formats = platform->supported_pixel_formats();
855
856 ASSERT_NE(0u, supported_pixel_formats.size());
857

Subscribers

People subscribed via source and target branches