Mir

Merge lp:~kdub/mir/android-internal-client into lp:~mir-team/mir/trunk

Proposed by Kevin DuBois
Status: Merged
Approved by: Kevin DuBois
Approved revision: no longer in the source branch.
Merged at revision: 681
Proposed branch: lp:~kdub/mir/android-internal-client
Merge into: lp:~mir-team/mir/trunk
Diff against target: 2860 lines (+1466/-454)
55 files modified
examples/CMakeLists.txt (+1/-4)
examples/demo-inprocess-egl/demo_inprocess_egl.cpp (+1/-0)
examples/demo-inprocess-egl/inprocess_egl_client.cpp (+17/-6)
examples/demo-inprocess-egl/inprocess_egl_client.h (+5/-2)
include/server/mir/graphics/egl/mesa_native_display.h (+0/-42)
include/server/mir/graphics/internal_client.h (+43/-0)
include/server/mir/graphics/platform.h (+6/-5)
include/shared/mir_toolkit/mesa/native_display.h (+9/-0)
include/test/mir_test_doubles/mock_interpreter_resource_cache.h (+37/-0)
include/test/mir_test_doubles/mock_swapper.h (+1/-0)
include/test/mir_test_doubles/stub_platform.h (+60/-0)
src/server/graphics/CMakeLists.txt (+0/-4)
src/server/graphics/android/CMakeLists.txt (+3/-0)
src/server/graphics/android/android_platform.cpp (+5/-3)
src/server/graphics/android/android_platform.h (+2/-3)
src/server/graphics/android/default_framebuffer_factory.cpp (+3/-1)
src/server/graphics/android/internal_client.cpp (+42/-0)
src/server/graphics/android/internal_client.h (+52/-0)
src/server/graphics/android/internal_client_window.cpp (+79/-0)
src/server/graphics/android/internal_client_window.h (+58/-0)
src/server/graphics/android/interpreter_cache.cpp (+41/-0)
src/server/graphics/android/interpreter_cache.h (+45/-0)
src/server/graphics/android/interpreter_resource_cache.h (+50/-0)
src/server/graphics/android/server_render_window.cpp (+6/-12)
src/server/graphics/android/server_render_window.h (+4/-3)
src/server/graphics/egl/CMakeLists.txt (+0/-10)
src/server/graphics/gbm/CMakeLists.txt (+2/-0)
src/server/graphics/gbm/gbm_platform.cpp (+38/-12)
src/server/graphics/gbm/gbm_platform.h (+7/-6)
src/server/graphics/gbm/internal_client.cpp (+40/-0)
src/server/graphics/gbm/internal_client.h (+55/-0)
src/server/graphics/gbm/internal_native_display.cpp (+65/-112)
src/server/graphics/gbm/internal_native_display.h (+56/-0)
tests/integration-tests/graphics/android/CMakeLists.txt (+1/-0)
tests/integration-tests/graphics/android/test_internal_client.cpp (+132/-0)
tests/integration-tests/graphics/gbm/test_buffer_integration.cpp (+2/-2)
tests/integration-tests/test_display_info.cpp (+5/-3)
tests/integration-tests/test_drm_auth_magic.cpp (+2/-2)
tests/integration-tests/test_surfaceloop.cpp (+6/-5)
tests/mir_test_framework/testing_server_options.cpp (+2/-2)
tests/unit-tests/client/gbm/test_gbm_client_platform.cpp (+4/-0)
tests/unit-tests/frontend/test_session_mediator.cpp (+2/-26)
tests/unit-tests/frontend/test_session_mediator_android.cpp (+3/-27)
tests/unit-tests/frontend/test_session_mediator_gbm.cpp (+2/-2)
tests/unit-tests/graphics/CMakeLists.txt (+0/-1)
tests/unit-tests/graphics/android/CMakeLists.txt (+4/-1)
tests/unit-tests/graphics/android/test_internal_client.cpp (+87/-0)
tests/unit-tests/graphics/android/test_internal_client_interpreter.cpp (+149/-0)
tests/unit-tests/graphics/android/test_interpreter_buffer_cache.cpp (+86/-0)
tests/unit-tests/graphics/android/test_server_interpreter.cpp (+24/-74)
tests/unit-tests/graphics/egl/CMakeLists.txt (+0/-6)
tests/unit-tests/graphics/gbm/CMakeLists.txt (+2/-0)
tests/unit-tests/graphics/gbm/test_gbm_platform.cpp (+20/-0)
tests/unit-tests/graphics/gbm/test_internal_client.cpp (+43/-0)
tests/unit-tests/graphics/gbm/test_internal_native_display.cpp (+57/-78)
To merge this branch: bzr merge lp:~kdub/mir/android-internal-client
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Robert Ancell Approve
Review via email: mp+163211@code.launchpad.net

Commit message

enable internal clients (in-process-egl) for android. refactor platform abstraction for internal clients as well.

tested on my laptop (intel drivers), galaxy nexus, nexus4

fixes: lp:1173191

Description of the change

enable internal clients (in-process-egl) for android. refactor platform abstraction for internal clients as well.

tested on my laptop (intel drivers), galaxy nexus, nexus4

fixes: lp:1173191

To post a comment you must log in.
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)
Revision history for this message
Robert Ancell (robert-ancell) wrote :

I didn't review in depth, but at a high level looks good to me.

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

Here are some places to zone in:

l70: the in-process client registers sigint/sigterm handlers to stop the render loop. this is what fixes one of the bugs I noticed in this branch.

l86/87: mg::InternalClient is the current way that the platform constructs an internal (in-process-egl) client. It is constructed in mg::Platform via an mf::Surface. I'd expect mg::InternalClient to expand in the future (say, so the internal clients can get at size/pixelformat/etc info about the surface they were granted). A full example is in the integration test in line 1546.

I rolled src/graphics/egl into src/graphics/gbm like I was talking about at the sprint. This involved a bit of refactoring of ShellMesaEGLNativeDisplay, which is now called mgg::InternalNativeDisplay. what used to be in src/graphics/egl is really just gbm-specific code for a different sort of EGLNativeWindowType, (very analagous to mga::ServerRenderWindow and mga::InternalClientWindow) so it should be in the gbm directory.

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

furthermore, I added some comments in a bug that exists in current lp:mir (https://bugs.launchpad.net/mir/+bug/1177902) which is a namespace collision in our .so's for the symbol mir_egl_mesa_display_is_valid. The workaround in lines 1105-1114 can be removed with some coordination with changing the mir platform in mesa

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

I'm not clear on some of the semantics - e.g. what does this do and why does it need a surface:

266 + virtual std::shared_ptr<InternalClient> create_internal_client(std::shared_ptr<frontend::Surface> const&) = 0;

But it seems to work without anything that leaps out as ugly.

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

> I'm not clear on some of the semantics - e.g. what does this do and why does
> it need a surface:
>
> 266 + virtual std::shared_ptr<InternalClient>
> create_internal_client(std::shared_ptr<frontend::Surface> const&) = 0;
>
> But it seems to work without anything that leaps out as ugly.

the drivers need to understand our surfaces to use them internally. With mesa/gbm platform, we can just use the mf::Surface interface directly, because we control those drivers. With Android, we wrap the mf::Surface interface in an interface that driver can understand, and then give that out to our clients. essentially, what the user of this function gets back is a platform-friendly representation of the mf::Surface that they can plug into their egl driver

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) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/CMakeLists.txt'
--- examples/CMakeLists.txt 2013-05-01 00:58:45 +0000
+++ examples/CMakeLists.txt 2013-05-09 21:03:25 +0000
@@ -120,10 +120,7 @@
120 mir_eglplasma120 mir_eglplasma
121)121)
122122
123if (MIR_PLATFORM STREQUAL "gbm")123add_subdirectory(demo-inprocess-egl)
124 add_subdirectory(demo-inprocess-egl)
125endif()
126
127add_subdirectory(demo-shell)124add_subdirectory(demo-shell)
128125
129install(TARGETS ${DEMO_CLIENTS} RUNTIME DESTINATION bin)126install(TARGETS ${DEMO_CLIENTS} RUNTIME DESTINATION bin)
130127
=== modified file 'examples/demo-inprocess-egl/demo_inprocess_egl.cpp'
--- examples/demo-inprocess-egl/demo_inprocess_egl.cpp 2013-05-02 00:11:18 +0000
+++ examples/demo-inprocess-egl/demo_inprocess_egl.cpp 2013-05-09 21:03:25 +0000
@@ -46,6 +46,7 @@
46 mir::run_mir(config, [&config, &client](mir::DisplayServer&)46 mir::run_mir(config, [&config, &client](mir::DisplayServer&)
47 {47 {
48 client = std::make_shared<me::InprocessEGLClient>(48 client = std::make_shared<me::InprocessEGLClient>(
49 config.the_main_loop(),
49 config.the_graphics_platform(),50 config.the_graphics_platform(),
50 config.the_shell_surface_factory());51 config.the_shell_surface_factory());
51 });52 });
5253
=== modified file 'examples/demo-inprocess-egl/inprocess_egl_client.cpp'
--- examples/demo-inprocess-egl/inprocess_egl_client.cpp 2013-05-02 00:11:18 +0000
+++ examples/demo-inprocess-egl/inprocess_egl_client.cpp 2013-05-09 21:03:25 +0000
@@ -19,12 +19,14 @@
19#include "inprocess_egl_client.h"19#include "inprocess_egl_client.h"
20#include "example_egl_helper.h"20#include "example_egl_helper.h"
2121
22#include "mir/main_loop.h"
22#include "mir/shell/surface_factory.h"23#include "mir/shell/surface_factory.h"
23#include "mir/shell/surface.h"24#include "mir/shell/surface.h"
24#include "mir/frontend/surface_creation_parameters.h"25#include "mir/frontend/surface_creation_parameters.h"
25#include "mir/geometry/size.h"26#include "mir/geometry/size.h"
26#include "mir/compositor/buffer_properties.h"27#include "mir/compositor/buffer_properties.h"
27#include "mir/graphics/platform.h"28#include "mir/graphics/platform.h"
29#include "mir/graphics/internal_client.h"
2830
29#include "graphics.h"31#include "graphics.h"
3032
@@ -33,6 +35,8 @@
33#include <functional>35#include <functional>
3436
35#include <assert.h>37#include <assert.h>
38#include <signal.h>
39
3640
37namespace mf = mir::frontend;41namespace mf = mir::frontend;
38namespace mc = mir::compositor;42namespace mc = mir::compositor;
@@ -41,12 +45,20 @@
41namespace me = mir::examples;45namespace me = mir::examples;
42namespace geom = mir::geometry;46namespace geom = mir::geometry;
4347
44me::InprocessEGLClient::InprocessEGLClient(std::shared_ptr<mg::Platform> const& graphics_platform,48me::InprocessEGLClient::InprocessEGLClient(std::shared_ptr<mir::MainLoop> const& main_loop,
49 std::shared_ptr<mg::Platform> const& graphics_platform,
45 std::shared_ptr<msh::SurfaceFactory> const& surface_factory)50 std::shared_ptr<msh::SurfaceFactory> const& surface_factory)
46 : graphics_platform(graphics_platform),51 : graphics_platform(graphics_platform),
47 surface_factory(surface_factory),52 surface_factory(surface_factory),
48 client_thread(std::mem_fn(&InprocessEGLClient::thread_loop), this)53 client_thread(std::mem_fn(&InprocessEGLClient::thread_loop), this),
54 terminate(false)
49{55{
56 main_loop->register_signal_handler({SIGTERM, SIGINT},
57 [this](int)
58 {
59 terminate = true;
60 }
61 );
50 client_thread.detach();62 client_thread.detach();
51}63}
5264
@@ -61,9 +73,8 @@
61 .of_buffer_usage(mc::BufferUsage::hardware)73 .of_buffer_usage(mc::BufferUsage::hardware)
62 .of_pixel_format(geom::PixelFormat::argb_8888);74 .of_pixel_format(geom::PixelFormat::argb_8888);
63 auto surface = surface_factory->create_surface(params, mf::SurfaceId(), std::shared_ptr<events::EventSink>());75 auto surface = surface_factory->create_surface(params, mf::SurfaceId(), std::shared_ptr<events::EventSink>());
6476 auto internal_client = graphics_platform->create_internal_client(surface);
65 auto native_display = graphics_platform->shell_egl_display();77 me::EGLHelper helper(internal_client->egl_native_display(), internal_client->egl_native_window());
66 me::EGLHelper helper(reinterpret_cast<EGLNativeDisplayType>(native_display), reinterpret_cast<EGLNativeWindowType>(surface.get()));
6778
68 auto rc = eglMakeCurrent(helper.the_display(), helper.the_surface(), helper.the_surface(), helper.the_context());79 auto rc = eglMakeCurrent(helper.the_display(), helper.the_surface(), helper.the_surface(), helper.the_context());
69 assert(rc == EGL_TRUE);80 assert(rc == EGL_TRUE);
@@ -73,7 +84,7 @@
73 ///\internal [setup_tag]84 ///\internal [setup_tag]
7485
75 ///\internal [loop_tag]86 ///\internal [loop_tag]
76 for(;;)87 while(!terminate)
77 {88 {
78 gl_animation.render_gl();89 gl_animation.render_gl();
79 rc = eglSwapBuffers(helper.the_display(), helper.the_surface());90 rc = eglSwapBuffers(helper.the_display(), helper.the_surface());
8091
=== modified file 'examples/demo-inprocess-egl/inprocess_egl_client.h'
--- examples/demo-inprocess-egl/inprocess_egl_client.h 2013-04-01 16:45:07 +0000
+++ examples/demo-inprocess-egl/inprocess_egl_client.h 2013-05-09 21:03:25 +0000
@@ -24,6 +24,7 @@
2424
25namespace mir25namespace mir
26{26{
27class MainLoop;
27namespace graphics28namespace graphics
28{29{
29class Platform;30class Platform;
@@ -40,7 +41,8 @@
40class InprocessEGLClient41class InprocessEGLClient
41{42{
42public:43public:
43 InprocessEGLClient(std::shared_ptr<graphics::Platform> const& graphics_platform,44 InprocessEGLClient(std::shared_ptr<mir::MainLoop> const& main_loop,
45 std::shared_ptr<graphics::Platform> const& graphics_platform,
44 std::shared_ptr<shell::SurfaceFactory> const& surface_factory);46 std::shared_ptr<shell::SurfaceFactory> const& surface_factory);
4547
46protected:48protected:
@@ -50,9 +52,10 @@
50private:52private:
51 std::shared_ptr<graphics::Platform> const graphics_platform;53 std::shared_ptr<graphics::Platform> const graphics_platform;
52 std::shared_ptr<shell::SurfaceFactory> const surface_factory;54 std::shared_ptr<shell::SurfaceFactory> const surface_factory;
53 55
54 std::thread client_thread;56 std::thread client_thread;
55 void thread_loop();57 void thread_loop();
58 bool terminate;
56};59};
5760
58}61}
5962
=== removed directory 'include/server/mir/graphics/egl'
=== removed file 'include/server/mir/graphics/egl/mesa_native_display.h'
--- include/server/mir/graphics/egl/mesa_native_display.h 2013-04-24 05:22:20 +0000
+++ include/server/mir/graphics/egl/mesa_native_display.h 1970-01-01 00:00:00 +0000
@@ -1,42 +0,0 @@
1/*
2 * Copyright © 2013 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: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef MIR_GRAPHICS_EGL_NATIVE_DISPLAY_H_
20#define MIR_GRAPHICS_EGL_NATIVE_DISPLAY_H_
21
22#include "mir_toolkit/mesa/native_display.h"
23
24#include <memory>
25
26namespace mir
27{
28namespace graphics
29{
30class Platform;
31
32namespace egl
33{
34namespace mesa
35{
36std::shared_ptr<MirMesaEGLNativeDisplay> create_native_display(std::shared_ptr<Platform> const& platform);
37}
38}
39}
40} // namespace mir
41
42#endif // MIR_GRAPHICS_EGL_NATIVE_DISPLAY_H_
430
=== added file 'include/server/mir/graphics/internal_client.h'
--- include/server/mir/graphics/internal_client.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/graphics/internal_client.h 2013-05-09 21:03:25 +0000
@@ -0,0 +1,43 @@
1/*
2 * Copyright © 2013 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19
20#ifndef MIR_GRAPHICS_INTERNAL_CLIENT_H_
21#define MIR_GRAPHICS_INTERNAL_CLIENT_H_
22
23#include <EGL/egl.h>
24
25namespace mir
26{
27namespace graphics
28{
29class InternalClient
30{
31public:
32 virtual EGLNativeDisplayType egl_native_display() = 0;
33 virtual EGLNativeWindowType egl_native_window() = 0;
34protected:
35 InternalClient() = default;
36 virtual ~InternalClient() = default;
37 InternalClient(InternalClient const&) = delete;
38 InternalClient& operator=(InternalClient const&) = delete;
39};
40}
41}
42
43#endif /* MIR_GRAPHICS_INTERNAL_CLIENT_H_ */
044
=== modified file 'include/server/mir/graphics/platform.h'
--- include/server/mir/graphics/platform.h 2013-04-24 05:22:20 +0000
+++ include/server/mir/graphics/platform.h 2013-05-09 21:03:25 +0000
@@ -20,12 +20,14 @@
20#ifndef MIR_GRAPHICS_PLATFORM_H_20#ifndef MIR_GRAPHICS_PLATFORM_H_
21#define MIR_GRAPHICS_PLATFORM_H_21#define MIR_GRAPHICS_PLATFORM_H_
2222
23#include <EGL/egl.h>
24
25#include <memory>23#include <memory>
2624
27namespace mir25namespace mir
28{26{
27namespace frontend
28{
29class Surface;
30}
29namespace compositor31namespace compositor
30{32{
31class GraphicBufferAllocator;33class GraphicBufferAllocator;
@@ -39,7 +41,7 @@
39class Display;41class Display;
40struct PlatformIPCPackage;42struct PlatformIPCPackage;
41class BufferInitializer;43class BufferInitializer;
4244class InternalClient;
43class DisplayReport;45class DisplayReport;
4446
45/// Interface to platform specific support for graphics operations.47/// Interface to platform specific support for graphics operations.
@@ -54,8 +56,7 @@
54 std::shared_ptr<BufferInitializer> const& buffer_initializer) = 0;56 std::shared_ptr<BufferInitializer> const& buffer_initializer) = 0;
55 virtual std::shared_ptr<Display> create_display() = 0;57 virtual std::shared_ptr<Display> create_display() = 0;
56 virtual std::shared_ptr<PlatformIPCPackage> get_ipc_package() = 0;58 virtual std::shared_ptr<PlatformIPCPackage> get_ipc_package() = 0;
57 59 virtual std::shared_ptr<InternalClient> create_internal_client(std::shared_ptr<frontend::Surface> const&) = 0;
58 virtual EGLNativeDisplayType shell_egl_display() = 0;
59};60};
6061
61// Create and return a new graphics platform.62// Create and return a new graphics platform.
6263
=== modified file 'include/shared/mir_toolkit/mesa/native_display.h'
--- include/shared/mir_toolkit/mesa/native_display.h 2013-05-03 22:53:42 +0000
+++ include/shared/mir_toolkit/mesa/native_display.h 2013-05-09 21:03:25 +0000
@@ -48,7 +48,16 @@
48 void *context;48 void *context;
49};49};
5050
51typedef enum mir_display_type
52{
53 MIR_DISPLAY_TYPE_CLIENT,
54 MIR_DISPLAY_TYPE_SERVER_INTERNAL
55} mir_display_type;
56
57mir_display_type mir_get_display_type(MirMesaEGLNativeDisplay* display);
58
51int mir_egl_mesa_display_is_valid(MirMesaEGLNativeDisplay* display);59int mir_egl_mesa_display_is_valid(MirMesaEGLNativeDisplay* display);
60int mir_server_internal_display_is_valid(MirMesaEGLNativeDisplay* display);
5261
53#ifdef __cplusplus62#ifdef __cplusplus
54} // extern "C"63} // extern "C"
5564
=== added file 'include/test/mir_test_doubles/mock_interpreter_resource_cache.h'
--- include/test/mir_test_doubles/mock_interpreter_resource_cache.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/mock_interpreter_resource_cache.h 2013-05-09 21:03:25 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright © 2013 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18#ifndef MIR_TEST_DOUBLES_MOCK_INTERPRETER_RESOURCE_CACHE_H_
19#define MIR_TEST_DOUBLES_MOCK_INTERPRETER_RESOURCE_CACHE_H_
20
21#include "src/server/graphics/android/interpreter_resource_cache.h"
22
23namespace mir
24{
25namespace test
26{
27namespace doubles
28{
29struct MockInterpreterResourceCache : public graphics::android::InterpreterResourceCache
30{
31 MOCK_METHOD2(store_buffer, void(std::shared_ptr<compositor::Buffer>const&, ANativeWindowBuffer*));
32 MOCK_METHOD1(retrieve_buffer, std::shared_ptr<compositor::Buffer>(ANativeWindowBuffer*));
33};
34}
35}
36}
37#endif /* MIR_TEST_DOUBLES_MOCK_INTERPRETER_RESOURCE_CACHE_H_ */
038
=== modified file 'include/test/mir_test_doubles/mock_swapper.h'
--- include/test/mir_test_doubles/mock_swapper.h 2013-05-02 16:29:48 +0000
+++ include/test/mir_test_doubles/mock_swapper.h 2013-05-09 21:03:25 +0000
@@ -32,6 +32,7 @@
32struct MockSwapper : public compositor::BufferSwapper32struct MockSwapper : public compositor::BufferSwapper
33{33{
34public:34public:
35 MockSwapper() {}
35 MockSwapper(std::shared_ptr<compositor::Buffer> buffer)36 MockSwapper(std::shared_ptr<compositor::Buffer> buffer)
36 : default_buffer(buffer)37 : default_buffer(buffer)
37 {38 {
3839
=== added file 'include/test/mir_test_doubles/stub_platform.h'
--- include/test/mir_test_doubles/stub_platform.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/stub_platform.h 2013-05-09 21:03:25 +0000
@@ -0,0 +1,60 @@
1/*
2 * Copyright © 2013 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_STUB_PLATFORM_H_
20#define MIR_TEST_DOUBLES_STUB_PLATFORM_H_
21
22#include "mir/graphics/platform.h"
23#include "mir/graphics/platform_ipc_package.h"
24#include "null_display.h"
25
26namespace mir
27{
28namespace test
29{
30namespace doubles
31{
32class StubPlatform : public graphics::Platform
33{
34 public:
35 std::shared_ptr<compositor::GraphicBufferAllocator> create_buffer_allocator(
36 const std::shared_ptr<graphics::BufferInitializer>& /*buffer_initializer*/)
37 {
38 return std::shared_ptr<compositor::GraphicBufferAllocator>();
39 }
40
41 std::shared_ptr<graphics::Display> create_display()
42 {
43 return std::make_shared<NullDisplay>();
44 }
45
46 std::shared_ptr<graphics::PlatformIPCPackage> get_ipc_package()
47 {
48 return std::make_shared<graphics::PlatformIPCPackage>();
49 }
50
51 std::shared_ptr<graphics::InternalClient> create_internal_client(std::shared_ptr<frontend::Surface> const&)
52 {
53 return std::shared_ptr<graphics::InternalClient>();
54 }
55};
56}
57}
58} // namespace mir
59
60#endif // MIR_TEST_DOUBLES_STUB_INPUT_LISTENER_H_
061
=== modified file 'src/server/graphics/CMakeLists.txt'
--- src/server/graphics/CMakeLists.txt 2013-04-24 05:22:20 +0000
+++ src/server/graphics/CMakeLists.txt 2013-05-09 21:03:25 +0000
@@ -19,10 +19,6 @@
19 null_display_report.cpp19 null_display_report.cpp
20)20)
2121
22if (MIR_PLATFORM STREQUAL "gbm")
23 add_subdirectory(egl/)
24endif()
25
26add_library(22add_library(
27 mirgraphics STATIC23 mirgraphics STATIC
2824
2925
=== modified file 'src/server/graphics/android/CMakeLists.txt'
--- src/server/graphics/android/CMakeLists.txt 2013-05-02 16:29:48 +0000
+++ src/server/graphics/android/CMakeLists.txt 2013-05-09 21:03:25 +0000
@@ -26,6 +26,9 @@
26 default_framebuffer_factory.cpp26 default_framebuffer_factory.cpp
27 fb_simple_swapper.cpp27 fb_simple_swapper.cpp
28 fb_device.cpp28 fb_device.cpp
29 internal_client_window.cpp
30 interpreter_cache.cpp
31 internal_client.cpp
29)32)
3033
31target_link_libraries(34target_link_libraries(
3235
=== modified file 'src/server/graphics/android/android_platform.cpp'
--- src/server/graphics/android/android_platform.cpp 2013-04-26 00:00:27 +0000
+++ src/server/graphics/android/android_platform.cpp 2013-05-09 21:03:25 +0000
@@ -23,6 +23,7 @@
23#include "android_display_allocator.h"23#include "android_display_allocator.h"
24#include "android_display_factory.h"24#include "android_display_factory.h"
25#include "default_framebuffer_factory.h"25#include "default_framebuffer_factory.h"
26#include "internal_client.h"
26#include "mir/graphics/platform_ipc_package.h"27#include "mir/graphics/platform_ipc_package.h"
27#include "mir/graphics/buffer_initializer.h"28#include "mir/graphics/buffer_initializer.h"
28#include "mir/compositor/buffer_id.h"29#include "mir/compositor/buffer_id.h"
@@ -30,6 +31,7 @@
30namespace mg=mir::graphics;31namespace mg=mir::graphics;
31namespace mga=mir::graphics::android;32namespace mga=mir::graphics::android;
32namespace mc=mir::compositor;33namespace mc=mir::compositor;
34namespace mf=mir::frontend;
3335
34mga::AndroidPlatform::AndroidPlatform(std::shared_ptr<mg::DisplayReport> const& display_report)36mga::AndroidPlatform::AndroidPlatform(std::shared_ptr<mg::DisplayReport> const& display_report)
35 : display_report(display_report)37 : display_report(display_report)
@@ -59,10 +61,10 @@
59 return std::make_shared<mg::PlatformIPCPackage>();61 return std::make_shared<mg::PlatformIPCPackage>();
60}62}
6163
62EGLNativeDisplayType mga::AndroidPlatform::shell_egl_display()64std::shared_ptr<mg::InternalClient> mga::AndroidPlatform::create_internal_client(
65 std::shared_ptr<mf::Surface> const& surface)
63{66{
64 // TODO: Implement67 return std::make_shared<mga::InternalClient>(surface);
65 return static_cast<EGLNativeDisplayType>(0);
66}68}
6769
68std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<DisplayReport> const& display_report)70std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<DisplayReport> const& display_report)
6971
=== modified file 'src/server/graphics/android/android_platform.h'
--- src/server/graphics/android/android_platform.h 2013-04-26 00:00:27 +0000
+++ src/server/graphics/android/android_platform.h 2013-05-09 21:03:25 +0000
@@ -38,9 +38,8 @@
38 std::shared_ptr<compositor::GraphicBufferAllocator> create_buffer_allocator(38 std::shared_ptr<compositor::GraphicBufferAllocator> create_buffer_allocator(
39 const std::shared_ptr<BufferInitializer>& buffer_initializer);39 const std::shared_ptr<BufferInitializer>& buffer_initializer);
40 std::shared_ptr<Display> create_display();40 std::shared_ptr<Display> create_display();
41 std::shared_ptr<PlatformIPCPackage> get_ipc_package();41 std::shared_ptr<PlatformIPCPackage> get_ipc_package();
42 42 std::shared_ptr<InternalClient> create_internal_client(std::shared_ptr<frontend::Surface> const&);
43 EGLNativeDisplayType shell_egl_display();
4443
45private:44private:
46 std::shared_ptr<DisplayReport> const display_report;45 std::shared_ptr<DisplayReport> const display_report;
4746
=== modified file 'src/server/graphics/android/default_framebuffer_factory.cpp'
--- src/server/graphics/android/default_framebuffer_factory.cpp 2013-05-06 17:11:28 +0000
+++ src/server/graphics/android/default_framebuffer_factory.cpp 2013-05-09 21:03:25 +0000
@@ -24,6 +24,7 @@
24#include "fb_simple_swapper.h"24#include "fb_simple_swapper.h"
25#include "graphic_buffer_allocator.h"25#include "graphic_buffer_allocator.h"
26#include "server_render_window.h"26#include "server_render_window.h"
27#include "interpreter_cache.h"
2728
28#include <boost/throw_exception.hpp>29#include <boost/throw_exception.hpp>
29#include <stdexcept>30#include <stdexcept>
@@ -51,7 +52,8 @@
51 }52 }
5253
53 auto swapper = std::make_shared<mga::FBSimpleSwapper>(buffers);54 auto swapper = std::make_shared<mga::FBSimpleSwapper>(buffers);
54 auto interpreter = std::make_shared<mga::ServerRenderWindow>(swapper, info_provider);55 auto cache = std::make_shared<mga::InterpreterCache>();
56 auto interpreter = std::make_shared<mga::ServerRenderWindow>(swapper, info_provider, cache);
55 return std::make_shared<mga::MirNativeWindow>(interpreter); 57 return std::make_shared<mga::MirNativeWindow>(interpreter);
56}58}
5759
5860
=== added file 'src/server/graphics/android/internal_client.cpp'
--- src/server/graphics/android/internal_client.cpp 1970-01-01 00:00:00 +0000
+++ src/server/graphics/android/internal_client.cpp 2013-05-09 21:03:25 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright © 2013 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "internal_client.h"
20#include "interpreter_cache.h"
21#include "internal_client_window.h"
22#include "mir/graphics/android/mir_native_window.h"
23
24namespace mf=mir::frontend;
25namespace mga=mir::graphics::android;
26
27mga::InternalClient::InternalClient(std::shared_ptr<frontend::Surface> const& surface)
28{
29 auto cache = std::make_shared<mga::InterpreterCache>();
30 auto interpreter = std::make_shared<mga::InternalClientWindow>(surface, cache);
31 client_window = std::make_shared<mga::MirNativeWindow>(interpreter);
32}
33
34EGLNativeDisplayType mga::InternalClient::egl_native_display()
35{
36 return EGL_DEFAULT_DISPLAY;
37}
38
39EGLNativeWindowType mga::InternalClient::egl_native_window()
40{
41 return client_window.get();
42}
043
=== added file 'src/server/graphics/android/internal_client.h'
--- src/server/graphics/android/internal_client.h 1970-01-01 00:00:00 +0000
+++ src/server/graphics/android/internal_client.h 2013-05-09 21:03:25 +0000
@@ -0,0 +1,52 @@
1/*
2 * Copyright © 2013 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_GRAPHICS_ANDROID_INTERNAL_CLIENT_H_
20#define MIR_GRAPHICS_ANDROID_INTERNAL_CLIENT_H_
21
22#include "mir/graphics/internal_client.h"
23#include <memory>
24
25namespace mir
26{
27namespace frontend
28{
29class Surface;
30}
31namespace graphics
32{
33namespace android
34{
35
36class MirNativeWindow;
37class InternalClient : public mir::graphics::InternalClient
38{
39public:
40 InternalClient(std::shared_ptr<frontend::Surface> const&);
41 EGLNativeDisplayType egl_native_display();
42 EGLNativeWindowType egl_native_window();
43
44private:
45 std::shared_ptr<MirNativeWindow> client_window;
46};
47
48}
49}
50}
51
52#endif /* MIR_GRAPHICS_ANDROID_INTERNAL_CLIENT_H_ */
053
=== added file 'src/server/graphics/android/internal_client_window.cpp'
--- src/server/graphics/android/internal_client_window.cpp 1970-01-01 00:00:00 +0000
+++ src/server/graphics/android/internal_client_window.cpp 2013-05-09 21:03:25 +0000
@@ -0,0 +1,79 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "mir/frontend/surface.h"
20#include "mir/compositor/buffer.h"
21#include "internal_client_window.h"
22#include "interpreter_resource_cache.h"
23#include "android_format_conversion-inl.h"
24
25#include <boost/throw_exception.hpp>
26#include <stdexcept>
27namespace mga=mir::graphics::android;
28namespace geom=mir::geometry;
29
30mga::InternalClientWindow::InternalClientWindow(std::shared_ptr<frontend::Surface> const& surface,
31 std::shared_ptr<InterpreterResourceCache> const& cache)
32 : surface(surface),
33 resource_cache(cache)
34{
35 format = mga::to_android_format(surface->pixel_format());
36}
37
38ANativeWindowBuffer* mga::InternalClientWindow::driver_requests_buffer()
39{
40 surface->advance_client_buffer();
41 auto buffer = surface->client_buffer();
42 auto handle = buffer->native_buffer_handle().get();
43 resource_cache->store_buffer(buffer, handle);
44 return handle;
45}
46
47void mga::InternalClientWindow::driver_returns_buffer(ANativeWindowBuffer* handle,
48 std::shared_ptr<SyncObject> const&)
49{
50 resource_cache->retrieve_buffer(handle);
51 /* here, the mc::TemporaryBuffer will destruct, triggering buffer advance */
52}
53
54void mga::InternalClientWindow::dispatch_driver_request_format(int request_format)
55{
56 format = request_format;
57}
58
59int mga::InternalClientWindow::driver_requests_info(int key) const
60{
61 geom::Size size;
62 switch(key)
63 {
64 case NATIVE_WINDOW_DEFAULT_WIDTH:
65 case NATIVE_WINDOW_WIDTH:
66 size = surface->size();
67 return size.width.as_uint32_t();
68 case NATIVE_WINDOW_DEFAULT_HEIGHT:
69 case NATIVE_WINDOW_HEIGHT:
70 size = surface->size();
71 return size.height.as_uint32_t();
72 case NATIVE_WINDOW_FORMAT:
73 return format;
74 case NATIVE_WINDOW_TRANSFORM_HINT:
75 return 0;
76 default:
77 BOOST_THROW_EXCEPTION(std::runtime_error("driver requests info we dont provide. key: " + key));
78 }
79}
080
=== added file 'src/server/graphics/android/internal_client_window.h'
--- src/server/graphics/android/internal_client_window.h 1970-01-01 00:00:00 +0000
+++ src/server/graphics/android/internal_client_window.h 2013-05-09 21:03:25 +0000
@@ -0,0 +1,58 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_GRAPHICS_ANDROID_INTERNAL_CLIENT_WINDOW_H_
20#define MIR_GRAPHICS_ANDROID_INTERNAL_CLIENT_WINDOW_H_
21
22#include "mir/graphics/android/android_driver_interpreter.h"
23#include "mir/geometry/size.h"
24#include "mir/geometry/pixel_format.h"
25
26namespace mir
27{
28
29namespace frontend
30{
31class Surface;
32}
33
34namespace graphics
35{
36namespace android
37{
38
39class InterpreterResourceCache;
40class InternalClientWindow : public AndroidDriverInterpreter
41{
42public:
43 InternalClientWindow(std::shared_ptr<frontend::Surface> const&,
44 std::shared_ptr<InterpreterResourceCache> const&);
45 ANativeWindowBuffer* driver_requests_buffer();
46 void driver_returns_buffer(ANativeWindowBuffer*, std::shared_ptr<SyncObject> const&);
47 void dispatch_driver_request_format(int);
48 int driver_requests_info(int) const;
49
50private:
51 std::shared_ptr<frontend::Surface> const surface;
52 std::shared_ptr<InterpreterResourceCache> const resource_cache;
53 int format;
54};
55}
56}
57}
58#endif /* MIR_GRAPHICS_ANDROID_INTERNAL_CLIENT_WINDOW_H_ */
059
=== added file 'src/server/graphics/android/interpreter_cache.cpp'
--- src/server/graphics/android/interpreter_cache.cpp 1970-01-01 00:00:00 +0000
+++ src/server/graphics/android/interpreter_cache.cpp 2013-05-09 21:03:25 +0000
@@ -0,0 +1,41 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "interpreter_cache.h"
20#include <boost/throw_exception.hpp>
21#include <stdexcept>
22
23namespace mga=mir::graphics::android;
24namespace mc=mir::compositor;
25
26void mga::InterpreterCache::store_buffer(std::shared_ptr<compositor::Buffer>const& buffer, ANativeWindowBuffer* key)
27{
28 buffers_in_driver[key] = buffer;
29}
30
31std::shared_ptr<mc::Buffer> mga::InterpreterCache::retrieve_buffer(ANativeWindowBuffer* returned_handle)
32{
33 auto buffer_it = buffers_in_driver.find(returned_handle);
34 if (buffer_it == buffers_in_driver.end())
35 {
36 BOOST_THROW_EXCEPTION(std::runtime_error("driver is returning buffers it never was given!"));
37 }
38 auto buffer_out = buffer_it->second;
39 buffers_in_driver.erase(buffer_it);
40 return buffer_out;
41}
042
=== added file 'src/server/graphics/android/interpreter_cache.h'
--- src/server/graphics/android/interpreter_cache.h 1970-01-01 00:00:00 +0000
+++ src/server/graphics/android/interpreter_cache.h 2013-05-09 21:03:25 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_GRAPHICS_ANDROID_INTERPRETER_CACHE_H_
20#define MIR_GRAPHICS_ANDROID_INTERPRETER_CACHE_H_
21
22#include "interpreter_resource_cache.h"
23#include <unordered_map>
24
25namespace mir
26{
27namespace graphics
28{
29namespace android
30{
31class InterpreterCache : public InterpreterResourceCache
32{
33public:
34 InterpreterCache() {}
35
36 void store_buffer(std::shared_ptr<compositor::Buffer>const& buffer, ANativeWindowBuffer* key);
37 std::shared_ptr<compositor::Buffer> retrieve_buffer(ANativeWindowBuffer* key);
38
39private:
40 std::unordered_map<ANativeWindowBuffer*, std::shared_ptr<compositor::Buffer>> buffers_in_driver;
41};
42}
43}
44}
45#endif /* MIR_GRAPHICS_ANDROID_INTERPRETER_CACHE_H_ */
046
=== added file 'src/server/graphics/android/interpreter_resource_cache.h'
--- src/server/graphics/android/interpreter_resource_cache.h 1970-01-01 00:00:00 +0000
+++ src/server/graphics/android/interpreter_resource_cache.h 2013-05-09 21:03:25 +0000
@@ -0,0 +1,50 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_GRAPHICS_ANDROID_INTERPRETER_RESOURCE_CACHE_H_
20#define MIR_GRAPHICS_ANDROID_INTERPRETER_RESOURCE_CACHE_H_
21#include <system/window.h>
22#include <memory>
23
24namespace mir
25{
26namespace compositor
27{
28class Buffer;
29}
30namespace graphics
31{
32namespace android
33{
34class InterpreterResourceCache
35{
36public:
37 InterpreterResourceCache() {}
38
39 virtual void store_buffer(std::shared_ptr<compositor::Buffer>const& buffer, ANativeWindowBuffer* key) = 0;
40 virtual std::shared_ptr<compositor::Buffer> retrieve_buffer(ANativeWindowBuffer* key) = 0;
41
42protected:
43 virtual ~InterpreterResourceCache() {}
44 InterpreterResourceCache(const InterpreterResourceCache&) = delete;
45 InterpreterResourceCache& operator=(const InterpreterResourceCache&) = delete;
46};
47}
48}
49}
50#endif /* MIR_GRAPHICS_ANDROID_INTERPRETER_RESOURCE_CACHE_H_ */
051
=== modified file 'src/server/graphics/android/server_render_window.cpp'
--- src/server/graphics/android/server_render_window.cpp 2013-05-06 15:38:52 +0000
+++ src/server/graphics/android/server_render_window.cpp 2013-05-09 21:03:25 +0000
@@ -23,11 +23,11 @@
23#include "fb_swapper.h"23#include "fb_swapper.h"
24#include "buffer.h"24#include "buffer.h"
25#include "android_format_conversion-inl.h"25#include "android_format_conversion-inl.h"
26#include "interpreter_resource_cache.h"
2627
27#include <boost/throw_exception.hpp>28#include <boost/throw_exception.hpp>
28#include <stdexcept>29#include <stdexcept>
2930
30
31#include <thread>31#include <thread>
32#include <chrono>32#include <chrono>
33namespace mc=mir::compositor;33namespace mc=mir::compositor;
@@ -35,9 +35,11 @@
35namespace geom=mir::geometry;35namespace geom=mir::geometry;
3636
37mga::ServerRenderWindow::ServerRenderWindow(std::shared_ptr<mga::FBSwapper> const& swapper,37mga::ServerRenderWindow::ServerRenderWindow(std::shared_ptr<mga::FBSwapper> const& swapper,
38 std::shared_ptr<mga::DisplaySupportProvider> const& display_poster)38 std::shared_ptr<mga::DisplaySupportProvider> const& display_poster,
39 std::shared_ptr<InterpreterResourceCache> const& cache)
39 : swapper(swapper),40 : swapper(swapper),
40 poster(display_poster),41 poster(display_poster),
42 resource_cache(cache),
41 format(mga::to_android_format(poster->display_format()))43 format(mga::to_android_format(poster->display_format()))
42{44{
43}45}
@@ -46,22 +48,14 @@
46{48{
47 auto buffer = swapper->compositor_acquire();49 auto buffer = swapper->compositor_acquire();
48 auto handle = buffer->native_buffer_handle().get();50 auto handle = buffer->native_buffer_handle().get();
49 buffers_in_driver[handle] = buffer;51 resource_cache->store_buffer(buffer, handle);
50
51 return handle;52 return handle;
52}53}
5354
54//sync object could be passed to hwc. we don't need to that yet though55//sync object could be passed to hwc. we don't need to that yet though
55void mga::ServerRenderWindow::driver_returns_buffer(ANativeWindowBuffer* returned_handle, std::shared_ptr<SyncObject> const&)56void mga::ServerRenderWindow::driver_returns_buffer(ANativeWindowBuffer* returned_handle, std::shared_ptr<SyncObject> const&)
56{57{
57 auto buffer_it = buffers_in_driver.find(returned_handle); 58 auto buffer = resource_cache->retrieve_buffer(returned_handle);
58 if (buffer_it == buffers_in_driver.end())
59 {
60 BOOST_THROW_EXCEPTION(std::runtime_error("driver is returning buffers it never was given!"));
61 }
62
63 auto buffer = buffer_it->second;
64 buffers_in_driver.erase(buffer_it);
65 poster->set_next_frontbuffer(buffer);59 poster->set_next_frontbuffer(buffer);
66 swapper->compositor_release(buffer);60 swapper->compositor_release(buffer);
67}61}
6862
=== modified file 'src/server/graphics/android/server_render_window.h'
--- src/server/graphics/android/server_render_window.h 2013-05-06 15:38:52 +0000
+++ src/server/graphics/android/server_render_window.h 2013-05-09 21:03:25 +0000
@@ -42,11 +42,13 @@
4242
43class FBSwapper;43class FBSwapper;
44class DisplaySupportProvider;44class DisplaySupportProvider;
45class InterpreterResourceCache;
45class ServerRenderWindow : public AndroidDriverInterpreter 46class ServerRenderWindow : public AndroidDriverInterpreter
46{47{
47public:48public:
48 ServerRenderWindow(std::shared_ptr<FBSwapper> const& swapper,49 ServerRenderWindow(std::shared_ptr<FBSwapper> const& swapper,
49 std::shared_ptr<DisplaySupportProvider> const& display_poster);50 std::shared_ptr<DisplaySupportProvider> const& display_poster,
51 std::shared_ptr<InterpreterResourceCache> const&);
5052
51 ANativeWindowBuffer* driver_requests_buffer();53 ANativeWindowBuffer* driver_requests_buffer();
52 void driver_returns_buffer(ANativeWindowBuffer*, std::shared_ptr<SyncObject> const&);54 void driver_returns_buffer(ANativeWindowBuffer*, std::shared_ptr<SyncObject> const&);
@@ -56,8 +58,7 @@
56private:58private:
57 std::shared_ptr<FBSwapper> const swapper;59 std::shared_ptr<FBSwapper> const swapper;
58 std::shared_ptr<DisplaySupportProvider> const poster;60 std::shared_ptr<DisplaySupportProvider> const poster;
5961 std::shared_ptr<InterpreterResourceCache> const resource_cache;
60 std::unordered_map<ANativeWindowBuffer*, std::shared_ptr<compositor::Buffer>> buffers_in_driver;
6162
62 int format;63 int format;
63}; 64};
6465
=== removed directory 'src/server/graphics/egl'
=== removed file 'src/server/graphics/egl/CMakeLists.txt'
--- src/server/graphics/egl/CMakeLists.txt 2013-03-27 00:11:32 +0000
+++ src/server/graphics/egl/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1list(
2 APPEND GRAPHICS_SOURCES
3 ${CMAKE_CURRENT_SOURCE_DIR}/mesa_native_display.cpp
4)
5
6set(
7 GRAPHICS_SOURCES
8 ${GRAPHICS_SOURCES}
9 PARENT_SCOPE
10)
11\ No newline at end of file0\ No newline at end of file
121
=== modified file 'src/server/graphics/gbm/CMakeLists.txt'
--- src/server/graphics/gbm/CMakeLists.txt 2013-04-30 21:38:41 +0000
+++ src/server/graphics/gbm/CMakeLists.txt 2013-05-09 21:03:25 +0000
@@ -26,6 +26,8 @@
26 kms_output_container.cpp26 kms_output_container.cpp
27 kms_page_flipper.cpp27 kms_page_flipper.cpp
28 linux_virtual_terminal.cpp28 linux_virtual_terminal.cpp
29 internal_native_display.cpp
30 internal_client.cpp
29)31)
3032
31target_link_libraries(33target_link_libraries(
3234
=== modified file 'src/server/graphics/gbm/gbm_platform.cpp'
--- src/server/graphics/gbm/gbm_platform.cpp 2013-04-24 05:22:20 +0000
+++ src/server/graphics/gbm/gbm_platform.cpp 2013-05-09 21:03:25 +0000
@@ -20,9 +20,10 @@
2020
21#include "gbm_buffer_allocator.h"21#include "gbm_buffer_allocator.h"
22#include "gbm_display.h"22#include "gbm_display.h"
23#include "internal_client.h"
24#include "internal_native_display.h"
23#include "linux_virtual_terminal.h"25#include "linux_virtual_terminal.h"
24#include "mir/graphics/platform_ipc_package.h"26#include "mir/graphics/platform_ipc_package.h"
25#include "mir/graphics/egl/mesa_native_display.h"
2627
27#include <xf86drm.h>28#include <xf86drm.h>
2829
@@ -31,9 +32,7 @@
3132
32namespace mg = mir::graphics;33namespace mg = mir::graphics;
33namespace mgg = mg::gbm;34namespace mgg = mg::gbm;
34namespace mgeglm = mg::egl::mesa;
35namespace mc = mir::compositor;35namespace mc = mir::compositor;
36
37namespace36namespace
38{37{
3938
@@ -76,15 +75,24 @@
7675
77}76}
7877
78std::shared_ptr<mgg::InternalNativeDisplay> mgg::GBMPlatform::internal_native_display;
79bool mgg::GBMPlatform::internal_display_clients_present;
79mgg::GBMPlatform::GBMPlatform(std::shared_ptr<DisplayReport> const& listener,80mgg::GBMPlatform::GBMPlatform(std::shared_ptr<DisplayReport> const& listener,
80 std::shared_ptr<VirtualTerminal> const& vt)81 std::shared_ptr<VirtualTerminal> const& vt)
81 : listener{listener},82 : listener{listener},
82 vt{vt},83 vt{vt}
83 native_display{0}
84{84{
85 drm.setup();85 drm.setup();
86 gbm.setup(drm);86 gbm.setup(drm);
87}87 internal_display_clients_present = false;
88}
89
90mgg::GBMPlatform::~GBMPlatform()
91{
92 internal_native_display.reset();
93 internal_display_clients_present = false;
94}
95
8896
89std::shared_ptr<mc::GraphicBufferAllocator> mgg::GBMPlatform::create_buffer_allocator(97std::shared_ptr<mc::GraphicBufferAllocator> mgg::GBMPlatform::create_buffer_allocator(
90 const std::shared_ptr<mg::BufferInitializer>& buffer_initializer)98 const std::shared_ptr<mg::BufferInitializer>& buffer_initializer)
@@ -110,13 +118,13 @@
110 drm.auth_magic(magic);118 drm.auth_magic(magic);
111}119}
112120
113EGLNativeDisplayType mgg::GBMPlatform::shell_egl_display()121std::shared_ptr<mg::InternalClient> mgg::GBMPlatform::create_internal_client(
122 std::shared_ptr<frontend::Surface> const& surface)
114{123{
115 if (native_display)124 if (!internal_native_display)
116 return reinterpret_cast<EGLNativeDisplayType>(native_display.get());125 internal_native_display = std::make_shared<mgg::InternalNativeDisplay>(get_ipc_package());
117 native_display = mgeglm::create_native_display(this->shared_from_this());126 internal_display_clients_present = true;
118 127 return std::make_shared<mgg::InternalClient>(internal_native_display, surface);
119 return reinterpret_cast<EGLNativeDisplayType>(native_display.get());
120}128}
121129
122std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<DisplayReport> const& report)130std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<DisplayReport> const& report)
@@ -125,3 +133,21 @@
125 auto vt = std::make_shared<mgg::LinuxVirtualTerminal>(real_fops, report);133 auto vt = std::make_shared<mgg::LinuxVirtualTerminal>(real_fops, report);
126 return std::make_shared<mgg::GBMPlatform>(report, vt);134 return std::make_shared<mgg::GBMPlatform>(report, vt);
127}135}
136
137extern "C"
138{
139int mir_server_internal_display_is_valid(MirMesaEGLNativeDisplay* display)
140{
141 return ((mgg::GBMPlatform::internal_display_clients_present) &&
142 (display == mgg::GBMPlatform::internal_native_display.get()));
143}
144
145/* TODO: this function is a bit fragile because libmirserver and libmirclient both have very different
146 * implementations and both have symbols for it.
147 * bug filed: lp:1177902
148 */
149int mir_egl_mesa_display_is_valid(MirMesaEGLNativeDisplay* display)
150{
151 return mir_server_internal_display_is_valid(display);
152}
153}
128154
=== modified file 'src/server/graphics/gbm/gbm_platform.h'
--- src/server/graphics/gbm/gbm_platform.h 2013-04-24 05:22:20 +0000
+++ src/server/graphics/gbm/gbm_platform.h 2013-05-09 21:03:25 +0000
@@ -33,7 +33,7 @@
33{33{
3434
35class VirtualTerminal;35class VirtualTerminal;
3636class InternalNativeDisplay;
37class GBMPlatform : public Platform,37class GBMPlatform : public Platform,
38 public DRMAuthenticator,38 public DRMAuthenticator,
39 public std::enable_shared_from_this<GBMPlatform>39 public std::enable_shared_from_this<GBMPlatform>
@@ -41,14 +41,14 @@
41public:41public:
42 explicit GBMPlatform(std::shared_ptr<DisplayReport> const& reporter,42 explicit GBMPlatform(std::shared_ptr<DisplayReport> const& reporter,
43 std::shared_ptr<VirtualTerminal> const& vt);43 std::shared_ptr<VirtualTerminal> const& vt);
44 ~GBMPlatform();
4445
45 /* From Platform */46 /* From Platform */
46 std::shared_ptr<compositor::GraphicBufferAllocator> create_buffer_allocator(47 std::shared_ptr<compositor::GraphicBufferAllocator> create_buffer_allocator(
47 const std::shared_ptr<BufferInitializer>& buffer_initializer);48 const std::shared_ptr<BufferInitializer>& buffer_initializer);
48 std::shared_ptr<Display> create_display();49 std::shared_ptr<Display> create_display();
49 std::shared_ptr<PlatformIPCPackage> get_ipc_package();50 std::shared_ptr<PlatformIPCPackage> get_ipc_package();
50 51 std::shared_ptr<InternalClient> create_internal_client(std::shared_ptr<frontend::Surface> const&);
51 EGLNativeDisplayType shell_egl_display();
5252
53 /* From DRMAuthenticator */53 /* From DRMAuthenticator */
54 void drm_auth_magic(drm_magic_t magic);54 void drm_auth_magic(drm_magic_t magic);
@@ -59,8 +59,9 @@
59 std::shared_ptr<DisplayReport> const listener;59 std::shared_ptr<DisplayReport> const listener;
60 std::shared_ptr<VirtualTerminal> const vt;60 std::shared_ptr<VirtualTerminal> const vt;
6161
62private:62 //connection shared by all internal clients
63 std::shared_ptr<MirMesaEGLNativeDisplay> native_display;63 static bool internal_display_clients_present;
64 static std::shared_ptr<InternalNativeDisplay> internal_native_display;
64};65};
6566
66}67}
6768
=== added file 'src/server/graphics/gbm/internal_client.cpp'
--- src/server/graphics/gbm/internal_client.cpp 1970-01-01 00:00:00 +0000
+++ src/server/graphics/gbm/internal_client.cpp 2013-05-09 21:03:25 +0000
@@ -0,0 +1,40 @@
1/*
2 * Copyright © 2013 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "internal_client.h"
20
21namespace mg=mir::graphics;
22namespace mgg=mir::graphics::gbm;
23namespace mf=mir::frontend;
24
25mgg::InternalClient::InternalClient(std::shared_ptr<MirMesaEGLNativeDisplay> const& native_display,
26 std::shared_ptr<mf::Surface> const& surface)
27 : native_display(native_display),
28 surface(surface)
29{
30}
31
32EGLNativeDisplayType mgg::InternalClient::egl_native_display()
33{
34 return reinterpret_cast<EGLNativeDisplayType>(native_display.get());
35}
36
37EGLNativeWindowType mgg::InternalClient::egl_native_window()
38{
39 return reinterpret_cast<EGLNativeWindowType>(surface.get());
40}
041
=== added file 'src/server/graphics/gbm/internal_client.h'
--- src/server/graphics/gbm/internal_client.h 1970-01-01 00:00:00 +0000
+++ src/server/graphics/gbm/internal_client.h 2013-05-09 21:03:25 +0000
@@ -0,0 +1,55 @@
1/*
2 * Copyright © 2013 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_GRAPHICS_GBM_INTERNAL_CLIENT_H_
20#define MIR_GRAPHICS_GBM_INTERNAL_CLIENT_H_
21
22#include "mir/graphics/internal_client.h"
23#include "internal_native_display.h"
24#include <memory>
25
26namespace mir
27{
28namespace frontend
29{
30class Surface;
31}
32namespace graphics
33{
34class Platform;
35namespace gbm
36{
37
38class InternalClient : public mir::graphics::InternalClient
39{
40public:
41 InternalClient(std::shared_ptr<MirMesaEGLNativeDisplay> const&,
42 std::shared_ptr<frontend::Surface> const&);
43 EGLNativeDisplayType egl_native_display();
44 EGLNativeWindowType egl_native_window();
45
46private:
47 std::shared_ptr<MirMesaEGLNativeDisplay> const native_display;
48 std::shared_ptr<frontend::Surface> const surface;
49};
50
51}
52}
53}
54
55#endif /* MIR_GRAPHICS_GBM_INTERNAL_CLIENT_H_ */
056
=== renamed file 'src/server/graphics/egl/mesa_native_display.cpp' => 'src/server/graphics/gbm/internal_native_display.cpp'
--- src/server/graphics/egl/mesa_native_display.cpp 2013-05-02 00:11:18 +0000
+++ src/server/graphics/gbm/internal_native_display.cpp 2013-05-09 21:03:25 +0000
@@ -16,8 +16,8 @@
16 * Authored by: Robert Carr <robert.carr@canonical.com>16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */17 */
1818
19#include "internal_native_display.h"
19#include "mir/display_server.h"20#include "mir/display_server.h"
20#include "mir/graphics/egl/mesa_native_display.h"
21#include "mir/graphics/platform_ipc_package.h"21#include "mir/graphics/platform_ipc_package.h"
22#include "mir/graphics/platform.h"22#include "mir/graphics/platform.h"
23#include "mir/frontend/surface.h"23#include "mir/frontend/surface.h"
@@ -30,118 +30,71 @@
30#include <set>30#include <set>
3131
32namespace mg = mir::graphics;32namespace mg = mir::graphics;
33namespace mgeglm = mg::egl::mesa;33namespace mgg = mir::graphics::gbm;
34namespace mf = mir::frontend;34namespace mf = mir::frontend;
3535
36std::mutex valid_displays_guard;36mgg::InternalNativeDisplay::InternalNativeDisplay(std::shared_ptr<mg::PlatformIPCPackage> const& platform_package)
37std::set<MirMesaEGLNativeDisplay*> valid_displays;37 : platform_package(platform_package)
3838{
39namespace39 context = this;
40{40 this->display_get_platform = &InternalNativeDisplay::native_display_get_platform;
41struct ShellMesaEGLNativeDisplay : MirMesaEGLNativeDisplay41 this->surface_get_current_buffer = &InternalNativeDisplay::native_display_surface_get_current_buffer;
42{42 this->surface_get_parameters = &InternalNativeDisplay::native_display_surface_get_parameters;
43public:43 this->surface_advance_buffer = &InternalNativeDisplay::native_display_surface_advance_buffer;
44 ShellMesaEGLNativeDisplay(std::shared_ptr<mg::Platform> const& graphics_platform)44}
45 : graphics_platform(graphics_platform)45
46 {46void mgg::InternalNativeDisplay::native_display_get_platform(MirMesaEGLNativeDisplay* display, MirPlatformPackage* package)
47 context = this;47{
48 this->display_get_platform = &ShellMesaEGLNativeDisplay::native_display_get_platform;48 auto native_disp = static_cast<InternalNativeDisplay*>(display);
49 this->surface_get_current_buffer = &ShellMesaEGLNativeDisplay::native_display_surface_get_current_buffer;49 package->data_items = native_disp->platform_package->ipc_data.size();
50 this->surface_get_parameters = &ShellMesaEGLNativeDisplay::native_display_surface_get_parameters;50 for (int i = 0; i < package->data_items; i++)
51 this->surface_advance_buffer = &ShellMesaEGLNativeDisplay::native_display_surface_advance_buffer;51 {
52 }52 package->data[i] = native_disp->platform_package->ipc_data[i];
5353 }
54 static void native_display_get_platform(MirMesaEGLNativeDisplay* display, MirPlatformPackage* package)54 package->fd_items = native_disp->platform_package->ipc_fds.size();
55 {55 for (int i = 0; i < package->fd_items; i++)
56 auto native_disp = static_cast<ShellMesaEGLNativeDisplay*>(display);56 {
57 if (!native_disp->platform_package)57 package->fd[i] = native_disp->platform_package->ipc_fds[i];
58 native_disp->platform_package = native_disp->graphics_platform->get_ipc_package();58 }
59 package->data_items = native_disp->platform_package->ipc_data.size();59
60 for (int i = 0; i < package->data_items; i++)60}
61 {61
62 package->data[i] = native_disp->platform_package->ipc_data[i];62void mgg::InternalNativeDisplay::native_display_surface_get_current_buffer(MirMesaEGLNativeDisplay*,
63 }
64 package->fd_items = native_disp->platform_package->ipc_fds.size();
65 for (int i = 0; i < package->fd_items; i++)
66 {
67 package->fd[i] = native_disp->platform_package->ipc_fds[i];
68 }
69
70 }
71
72 static void native_display_surface_get_current_buffer(MirMesaEGLNativeDisplay* /* display */,
73 MirEGLNativeWindowType surface,
74 MirBufferPackage* package)
75 {
76 auto mir_surface = static_cast<mf::Surface*>(surface);
77
78 auto buffer = mir_surface->client_buffer();
79 auto buffer_package = buffer->get_ipc_package();
80 package->data_items = buffer_package->ipc_data.size();
81 for (int i = 0; i < package->data_items; i++)
82 {
83 package->data[i] = buffer_package->ipc_data[i];
84 }
85 package->fd_items = buffer_package->ipc_fds.size();
86 for (int i = 0; i < package->fd_items; i++)
87 {
88 package->fd[i] = buffer_package->ipc_fds[i];
89 }
90 package->stride = buffer_package->stride;
91 }
92
93 static void native_display_surface_get_parameters(MirMesaEGLNativeDisplay* /* display */,
94 MirEGLNativeWindowType surface,63 MirEGLNativeWindowType surface,
95 MirSurfaceParameters* parameters)64 MirBufferPackage* package)
96 {65{
97 auto mir_surface = static_cast<mf::Surface*>(surface);66 auto mir_surface = static_cast<mf::Surface*>(surface);
9867
99 parameters->width = mir_surface->size().width.as_uint32_t();68 auto buffer = mir_surface->client_buffer();
100 parameters->height = mir_surface->size().height.as_uint32_t();69 auto buffer_package = buffer->get_ipc_package();
101 parameters->pixel_format = static_cast<MirPixelFormat>(mir_surface->pixel_format());70 package->data_items = buffer_package->ipc_data.size();
102 parameters->buffer_usage = mir_buffer_usage_hardware;71 for (int i = 0; i < package->data_items; i++)
103 }72 {
10473 package->data[i] = buffer_package->ipc_data[i];
105 static void native_display_surface_advance_buffer(MirMesaEGLNativeDisplay* /* display */, 74 }
106 MirEGLNativeWindowType surface)75 package->fd_items = buffer_package->ipc_fds.size();
107 {76 for (int i = 0; i < package->fd_items; i++)
108 auto mir_surface = static_cast<mf::Surface*>(surface);77 {
109 mir_surface->advance_client_buffer();78 package->fd[i] = buffer_package->ipc_fds[i];
110 }79 }
11180 package->stride = buffer_package->stride;
112private:81}
113 std::shared_ptr<mg::Platform> graphics_platform;82
114 std::shared_ptr<mg::PlatformIPCPackage> platform_package;83void mgg::InternalNativeDisplay::native_display_surface_get_parameters(MirMesaEGLNativeDisplay*,
115};84 MirEGLNativeWindowType surface,
11685 MirSurfaceParameters* parameters)
117struct NativeDisplayDeleter86{
118{87 auto mir_surface = static_cast<mf::Surface*>(surface);
119 void operator()(MirMesaEGLNativeDisplay* display)88
120 {89 parameters->width = mir_surface->size().width.as_uint32_t();
121 std::unique_lock<std::mutex> lg(valid_displays_guard);90 parameters->height = mir_surface->size().height.as_uint32_t();
122 valid_displays.erase(display);91 parameters->pixel_format = static_cast<MirPixelFormat>(mir_surface->pixel_format());
123 auto disp = static_cast<ShellMesaEGLNativeDisplay*>(display->context);92 parameters->buffer_usage = mir_buffer_usage_hardware;
124 delete disp;93}
125 }94
126};95void mgg::InternalNativeDisplay::native_display_surface_advance_buffer(MirMesaEGLNativeDisplay*,
12796 MirEGLNativeWindowType surface)
128}97{
12998 auto mir_surface = static_cast<mf::Surface*>(surface);
130extern "C"99 mir_surface->advance_client_buffer();
131{
132int mir_egl_mesa_display_is_valid(MirMesaEGLNativeDisplay* display)
133{
134 std::unique_lock<std::mutex> lg(valid_displays_guard);
135 return valid_displays.find(display) != valid_displays.end();
136}
137}
138
139std::shared_ptr<MirMesaEGLNativeDisplay> mgeglm::create_native_display(std::shared_ptr<mg::Platform> const& platform)
140{
141 auto native_display = std::shared_ptr<ShellMesaEGLNativeDisplay>(new ShellMesaEGLNativeDisplay(platform),
142 NativeDisplayDeleter());
143 std::unique_lock<std::mutex> lg(valid_displays_guard);
144 valid_displays.insert(native_display.get());
145
146 return native_display;
147}100}
148101
=== added file 'src/server/graphics/gbm/internal_native_display.h'
--- src/server/graphics/gbm/internal_native_display.h 1970-01-01 00:00:00 +0000
+++ src/server/graphics/gbm/internal_native_display.h 2013-05-09 21:03:25 +0000
@@ -0,0 +1,56 @@
1
2/*
3 * Copyright © 2013 Canonical Ltd.
4 *
5 * This program is free software: you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 3,
7 * as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Robert Carr <robert.carr@canonical.com>
18 * Kevin DuBois <kevin.dubois@canonical.com>
19 */
20
21#ifndef MIR_GRAPHICS_GBM_INTERNAL_NATIVE_DISPLAY_H_
22#define MIR_GRAPHICS_GBM_INTERNAL_NATIVE_DISPLAY_H_
23
24#include "mir_toolkit/mesa/native_display.h"
25#include <memory>
26
27namespace mir
28{
29namespace graphics
30{
31struct PlatformIPCPackage;
32namespace gbm
33{
34
35class InternalNativeDisplay : public MirMesaEGLNativeDisplay
36{
37public:
38 InternalNativeDisplay(std::shared_ptr<PlatformIPCPackage> const& platform_package);
39
40 static void native_display_get_platform(MirMesaEGLNativeDisplay* display, MirPlatformPackage* package);
41 static void native_display_surface_get_current_buffer(MirMesaEGLNativeDisplay* /* display */,
42 MirEGLNativeWindowType surface,
43 MirBufferPackage* package);
44 static void native_display_surface_get_parameters(MirMesaEGLNativeDisplay* /* display */,
45 MirEGLNativeWindowType surface,
46 MirSurfaceParameters* parameters);
47 static void native_display_surface_advance_buffer(MirMesaEGLNativeDisplay* /* display */,
48 MirEGLNativeWindowType surface);
49private:
50 std::shared_ptr<PlatformIPCPackage> platform_package;
51};
52
53}
54}
55}
56#endif /* MIR_GRAPHICS_GBM_INTERNAL_NATIVE_DISPLAY_H_ */
057
=== modified file 'tests/integration-tests/graphics/android/CMakeLists.txt'
--- tests/integration-tests/graphics/android/CMakeLists.txt 2013-05-02 16:29:48 +0000
+++ tests/integration-tests/graphics/android/CMakeLists.txt 2013-05-09 21:03:25 +0000
@@ -2,6 +2,7 @@
2 APPEND INTEGRATION_TESTS_SRCS2 APPEND INTEGRATION_TESTS_SRCS
3 ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_integration.cpp3 ${CMAKE_CURRENT_SOURCE_DIR}/test_buffer_integration.cpp
4 ${CMAKE_CURRENT_SOURCE_DIR}/test_display_integration.cpp4 ${CMAKE_CURRENT_SOURCE_DIR}/test_display_integration.cpp
5 ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client.cpp
5)6)
67
7set(8set(
89
=== added file 'tests/integration-tests/graphics/android/test_internal_client.cpp'
--- tests/integration-tests/graphics/android/test_internal_client.cpp 1970-01-01 00:00:00 +0000
+++ tests/integration-tests/graphics/android/test_internal_client.cpp 2013-05-09 21:03:25 +0000
@@ -0,0 +1,132 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "src/server/graphics/android/android_graphic_buffer_allocator.h"
20#include "src/server/graphics/android/internal_client_window.h"
21#include "src/server/graphics/android/interpreter_cache.h"
22#include "mir/compositor/swapper_factory.h"
23#include "mir/compositor/buffer_swapper.h"
24#include "mir/compositor/buffer_bundle_manager.h"
25#include "mir/graphics/buffer_initializer.h"
26#include "mir/graphics/null_display_report.h"
27#include "mir/graphics/android/mir_native_window.h"
28#include "mir/graphics/platform.h"
29#include "mir/graphics/internal_client.h"
30#include "mir/surfaces/surface_stack.h"
31#include "mir/surfaces/surface_controller.h"
32#include "mir/shell/surface_source.h"
33#include "mir/shell/surface.h"
34#include "mir/frontend/surface_creation_parameters.h"
35#include "mir/frontend/surface_id.h"
36#include "mir/input/input_channel_factory.h"
37
38#include <EGL/egl.h>
39#include <gtest/gtest.h>
40
41#include <GLES2/gl2.h>
42
43
44namespace mg=mir::graphics;
45namespace mga=mir::graphics::android;
46namespace mc=mir::compositor;
47namespace geom=mir::geometry;
48namespace ms=mir::surfaces;
49namespace msh=mir::shell;
50namespace mf=mir::frontend;
51namespace mi=mir::input;
52
53namespace
54{
55class AndroidInternalClient : public ::testing::Test
56{
57protected:
58 virtual void SetUp()
59 {
60 }
61};
62
63struct StubInputFactory : public mi::InputChannelFactory
64{
65 std::shared_ptr<mi::InputChannel> make_input_channel()
66 {
67 return std::shared_ptr<mi::InputChannel>();
68 }
69};
70}
71
72TEST_F(AndroidInternalClient, internal_client_creation_and_use)
73{
74 auto size = geom::Size{geom::Width{334},
75 geom::Height{122}};
76 auto pf = geom::PixelFormat::abgr_8888;
77 mf::SurfaceCreationParameters params;
78 params.name = std::string("test");
79 params.size = size;
80 params.pixel_format = pf;
81 params.buffer_usage = mc::BufferUsage::hardware;
82 auto id = mf::SurfaceId{4458};
83
84 auto stub_input_factory = std::make_shared<StubInputFactory>();
85 auto null_buffer_initializer = std::make_shared<mg::NullBufferInitializer>();
86 auto allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(null_buffer_initializer);
87 auto strategy = std::make_shared<mc::SwapperFactory>(allocator);
88 auto buffer_bundle_factory = std::make_shared<mc::BufferBundleManager>(strategy);
89 auto ss = std::make_shared<ms::SurfaceStack>(buffer_bundle_factory);
90 auto surface_controller = std::make_shared<ms::SurfaceController>(ss);
91 auto surface_source = std::make_shared<msh::SurfaceSource>(surface_controller, stub_input_factory);
92 auto mir_surface = surface_source->create_surface(params, id, std::shared_ptr<mir::events::EventSink>());
93
94 auto report = std::shared_ptr<mg::NullDisplayReport>();
95 auto platform = mg::create_platform(report);
96 auto internal_client = platform->create_internal_client(mir_surface);
97
98 int major, minor, n;
99 EGLContext egl_context;
100 EGLSurface egl_surface;
101 EGLConfig egl_config;
102 EGLint attribs[] = {
103 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
104 EGL_RED_SIZE, 8,
105 EGL_GREEN_SIZE, 8,
106 EGL_BLUE_SIZE, 8,
107 EGL_ALPHA_SIZE, 8,
108 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
109 EGL_NONE };
110 EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
111
112 auto egl_display = eglGetDisplay(internal_client->egl_native_display());
113 int rc = eglInitialize(egl_display, &major, &minor);
114 EXPECT_EQ(EGL_TRUE, rc);
115
116 rc = eglChooseConfig(egl_display, attribs, &egl_config, 1, &n);
117 EXPECT_EQ(EGL_TRUE, rc);
118
119 egl_surface = eglCreateWindowSurface(egl_display, egl_config, internal_client->egl_native_window(), NULL);
120 EXPECT_NE(EGL_NO_SURFACE, egl_surface);
121
122 egl_context = eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, context_attribs);
123 EXPECT_NE(EGL_NO_CONTEXT, egl_context);
124
125 rc = eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context);
126 EXPECT_EQ(EGL_TRUE, rc);
127
128 glClearColor(1.0f, 0.0, 0.0, 1.0);
129 glClear(GL_COLOR_BUFFER_BIT);
130 rc = eglSwapBuffers(egl_display, egl_surface);
131 EXPECT_EQ(EGL_TRUE, rc);
132}
0133
=== modified file 'tests/integration-tests/graphics/gbm/test_buffer_integration.cpp'
--- tests/integration-tests/graphics/gbm/test_buffer_integration.cpp 2013-04-24 05:22:20 +0000
+++ tests/integration-tests/graphics/gbm/test_buffer_integration.cpp 2013-05-09 21:03:25 +0000
@@ -100,9 +100,9 @@
100 return std::shared_ptr<mg::PlatformIPCPackage>();100 return std::shared_ptr<mg::PlatformIPCPackage>();
101 }101 }
102102
103 EGLNativeDisplayType shell_egl_display()103 std::shared_ptr<mg::InternalClient> create_internal_client(std::shared_ptr<mir::frontend::Surface> const&)
104 {104 {
105 return static_cast<EGLNativeDisplayType>(0);105 return std::shared_ptr<mg::InternalClient>();
106 }106 }
107};107};
108108
109109
=== modified file 'tests/integration-tests/test_display_info.cpp'
--- tests/integration-tests/test_display_info.cpp 2013-04-24 05:22:20 +0000
+++ tests/integration-tests/test_display_info.cpp 2013-05-09 21:03:25 +0000
@@ -34,6 +34,7 @@
34namespace mg = mir::graphics;34namespace mg = mir::graphics;
35namespace mc = mir::compositor;35namespace mc = mir::compositor;
36namespace geom = mir::geometry;36namespace geom = mir::geometry;
37namespace mf = mir::frontend;
37namespace mtf = mir_test_framework;38namespace mtf = mir_test_framework;
38namespace mtd = mir::test::doubles;39namespace mtd = mir::test::doubles;
3940
@@ -103,10 +104,11 @@
103 {104 {
104 return std::make_shared<mg::PlatformIPCPackage>();105 return std::make_shared<mg::PlatformIPCPackage>();
105 }106 }
106 EGLNativeDisplayType shell_egl_display()107
108 std::shared_ptr<mg::InternalClient> create_internal_client(std::shared_ptr<mf::Surface> const&)
107 {109 {
108 return static_cast<EGLNativeDisplayType>(0);110 return std::shared_ptr<mg::InternalClient>();
109 }111 }
110};112};
111113
112void connection_callback(MirConnection* connection, void* context)114void connection_callback(MirConnection* connection, void* context)
113115
=== modified file 'tests/integration-tests/test_drm_auth_magic.cpp'
--- tests/integration-tests/test_drm_auth_magic.cpp 2013-04-24 05:22:20 +0000
+++ tests/integration-tests/test_drm_auth_magic.cpp 2013-05-09 21:03:25 +0000
@@ -80,9 +80,9 @@
80 return std::make_shared<mg::PlatformIPCPackage>();80 return std::make_shared<mg::PlatformIPCPackage>();
81 }81 }
8282
83 EGLNativeDisplayType shell_egl_display()83 std::shared_ptr<mg::InternalClient> create_internal_client(std::shared_ptr<mir::frontend::Surface> const&)
84 {84 {
85 return static_cast<EGLNativeDisplayType>(0);85 return std::shared_ptr<mg::InternalClient>();
86 }86 }
8787
88 MOCK_METHOD1(drm_auth_magic, void(unsigned int));88 MOCK_METHOD1(drm_auth_magic, void(unsigned int));
8989
=== modified file 'tests/integration-tests/test_surfaceloop.cpp'
--- tests/integration-tests/test_surfaceloop.cpp 2013-05-01 21:55:49 +0000
+++ tests/integration-tests/test_surfaceloop.cpp 2013-05-09 21:03:25 +0000
@@ -42,6 +42,7 @@
42namespace mc = mir::compositor;42namespace mc = mir::compositor;
43namespace mg = mir::graphics;43namespace mg = mir::graphics;
44namespace geom = mir::geometry;44namespace geom = mir::geometry;
45namespace mf = mir::frontend;
45namespace mtf = mir_test_framework;46namespace mtf = mir_test_framework;
46namespace mtd = mir::test::doubles;47namespace mtd = mir::test::doubles;
4748
@@ -355,10 +356,10 @@
355 return std::make_shared<mg::PlatformIPCPackage>();356 return std::make_shared<mg::PlatformIPCPackage>();
356 }357 }
357358
358 EGLNativeDisplayType shell_egl_display()359 std::shared_ptr<mg::InternalClient> create_internal_client(std::shared_ptr<mf::Surface> const&)
359 {360 {
360 return static_cast<EGLNativeDisplayType>(0);361 return std::shared_ptr<mg::InternalClient>();
361 }362 }
362 };363 };
363364
364 std::shared_ptr<mg::Platform> the_graphics_platform()365 std::shared_ptr<mg::Platform> the_graphics_platform()
@@ -487,9 +488,9 @@
487 return std::make_shared<mg::PlatformIPCPackage>();488 return std::make_shared<mg::PlatformIPCPackage>();
488 }489 }
489490
490 EGLNativeDisplayType shell_egl_display()491 std::shared_ptr<mg::InternalClient> create_internal_client(std::shared_ptr<mf::Surface> const&)
491 {492 {
492 return (EGLNativeDisplayType) 0;493 return std::shared_ptr<mg::InternalClient>();
493 }494 }
494 };495 };
495496
496497
=== modified file 'tests/mir_test_framework/testing_server_options.cpp'
--- tests/mir_test_framework/testing_server_options.cpp 2013-05-02 04:17:41 +0000
+++ tests/mir_test_framework/testing_server_options.cpp 2013-05-09 21:03:25 +0000
@@ -119,9 +119,9 @@
119 return std::make_shared<mg::PlatformIPCPackage>();119 return std::make_shared<mg::PlatformIPCPackage>();
120 }120 }
121121
122 EGLNativeDisplayType shell_egl_display()122 std::shared_ptr<mg::InternalClient> create_internal_client(std::shared_ptr<mf::Surface> const&)
123 {123 {
124 return (EGLNativeDisplayType) 0;124 return std::shared_ptr<mg::InternalClient>();
125 }125 }
126};126};
127127
128128
=== modified file 'tests/unit-tests/client/gbm/test_gbm_client_platform.cpp'
--- tests/unit-tests/client/gbm/test_gbm_client_platform.cpp 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/client/gbm/test_gbm_client_platform.cpp 2013-05-09 21:03:25 +0000
@@ -40,6 +40,10 @@
40 EXPECT_EQ(reinterpret_cast<EGLNativeWindowType>(&surface), *native_window);40 EXPECT_EQ(reinterpret_cast<EGLNativeWindowType>(&surface), *native_window);
41}41}
4242
43/* TODO: mir_egl_mesa_display_is_valid is a bit fragile because libmirserver and libmirclient both have very
44 * different implementations and both have symbols for it. If the linking order of the test changes,
45 * specifically, if mir_egl_mesa_display_is_valid resolves into libmirserver, then this test will break.
46 */
43TEST(GBMClientPlatformTest, egl_native_display_is_valid_until_released)47TEST(GBMClientPlatformTest, egl_native_display_is_valid_until_released)
44{48{
45 mtd::MockClientContext context;49 mtd::MockClientContext context;
4650
=== modified file 'tests/unit-tests/frontend/test_session_mediator.cpp'
--- tests/unit-tests/frontend/test_session_mediator.cpp 2013-04-25 09:48:54 +0000
+++ tests/unit-tests/frontend/test_session_mediator.cpp 2013-05-09 21:03:25 +0000
@@ -33,6 +33,7 @@
33#include "mir_test_doubles/mock_buffer.h"33#include "mir_test_doubles/mock_buffer.h"
34#include "mir_test_doubles/stub_session.h"34#include "mir_test_doubles/stub_session.h"
35#include "mir_test_doubles/stub_surface_builder.h"35#include "mir_test_doubles/stub_surface_builder.h"
36#include "mir_test_doubles/stub_platform.h"
36#include "mir_test/fake_shared.h"37#include "mir_test/fake_shared.h"
37#include "mir/events/event_sink.h"38#include "mir/events/event_sink.h"
38#include "mir/shell/surface.h"39#include "mir/shell/surface.h"
@@ -104,31 +105,6 @@
104 MOCK_METHOD0(supported_pixel_formats, std::vector<geom::PixelFormat>());105 MOCK_METHOD0(supported_pixel_formats, std::vector<geom::PixelFormat>());
105};106};
106107
107class StubPlatform : public mg::Platform
108{
109 public:
110 std::shared_ptr<mc::GraphicBufferAllocator> create_buffer_allocator(
111 const std::shared_ptr<mg::BufferInitializer>& /*buffer_initializer*/)
112 {
113 return std::shared_ptr<mc::GraphicBufferAllocator>();
114 }
115
116 std::shared_ptr<mg::Display> create_display()
117 {
118 return std::make_shared<mtd::NullDisplay>();
119 }
120
121 std::shared_ptr<mg::PlatformIPCPackage> get_ipc_package()
122 {
123 return std::make_shared<mg::PlatformIPCPackage>();
124 }
125
126 EGLNativeDisplayType shell_egl_display()
127 {
128 return static_cast<EGLNativeDisplayType>(0);
129 }
130};
131
132class NullEventSink : public mir::events::EventSink108class NullEventSink : public mir::events::EventSink
133{109{
134public:110public:
@@ -139,7 +115,7 @@
139{115{
140 SessionMediatorTest()116 SessionMediatorTest()
141 : shell{std::make_shared<testing::NiceMock<mtd::MockShell>>()},117 : shell{std::make_shared<testing::NiceMock<mtd::MockShell>>()},
142 graphics_platform{std::make_shared<StubPlatform>()},118 graphics_platform{std::make_shared<mtd::StubPlatform>()},
143 graphics_display{std::make_shared<mtd::NullDisplay>()},119 graphics_display{std::make_shared<mtd::NullDisplay>()},
144 buffer_allocator{std::make_shared<testing::NiceMock<MockGraphicBufferAllocator>>()},120 buffer_allocator{std::make_shared<testing::NiceMock<MockGraphicBufferAllocator>>()},
145 report{std::make_shared<mf::NullSessionMediatorReport>()},121 report{std::make_shared<mf::NullSessionMediatorReport>()},
146122
=== modified file 'tests/unit-tests/frontend/test_session_mediator_android.cpp'
--- tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-04-25 09:48:54 +0000
+++ tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-05-09 21:03:25 +0000
@@ -30,6 +30,7 @@
30#include "mir_test_doubles/null_display.h"30#include "mir_test_doubles/null_display.h"
31#include "mir_test_doubles/mock_session.h"31#include "mir_test_doubles/mock_session.h"
32#include "mir_test_doubles/stub_shell.h"32#include "mir_test_doubles/stub_shell.h"
33#include "mir_test_doubles/stub_platform.h"
3334
34#include "mir/events/event_sink.h"35#include "mir/events/event_sink.h"
3536
@@ -62,31 +63,6 @@
62 }63 }
63};64};
6465
65class StubPlatform : public mg::Platform
66{
67 public:
68 std::shared_ptr<mc::GraphicBufferAllocator> create_buffer_allocator(
69 const std::shared_ptr<mg::BufferInitializer>& /*buffer_initializer*/)
70 {
71 return std::shared_ptr<mc::GraphicBufferAllocator>();
72 }
73
74 std::shared_ptr<mg::Display> create_display()
75 {
76 return std::make_shared<mtd::NullDisplay>();
77 }
78
79 std::shared_ptr<mg::PlatformIPCPackage> get_ipc_package()
80 {
81 return std::make_shared<mg::PlatformIPCPackage>();
82 }
83
84 EGLNativeDisplayType shell_egl_display()
85 {
86 return static_cast<EGLNativeDisplayType>(0);
87 }
88};
89
90class NullEventSink : public mir::events::EventSink66class NullEventSink : public mir::events::EventSink
91{67{
92public:68public:
@@ -97,7 +73,7 @@
97{73{
98 SessionMediatorAndroidTest()74 SessionMediatorAndroidTest()
99 : shell{std::make_shared<mtd::StubShell>()},75 : shell{std::make_shared<mtd::StubShell>()},
100 graphics_platform{std::make_shared<StubPlatform>()},76 graphics_platform{std::make_shared<mtd::StubPlatform>()},
101 graphics_display{std::make_shared<mtd::NullDisplay>()},77 graphics_display{std::make_shared<mtd::NullDisplay>()},
102 buffer_allocator{std::make_shared<StubGraphicBufferAllocator>()},78 buffer_allocator{std::make_shared<StubGraphicBufferAllocator>()},
103 report{std::make_shared<mf::NullSessionMediatorReport>()},79 report{std::make_shared<mf::NullSessionMediatorReport>()},
@@ -111,7 +87,7 @@
111 }87 }
11288
113 std::shared_ptr<mtd::StubShell> const shell;89 std::shared_ptr<mtd::StubShell> const shell;
114 std::shared_ptr<StubPlatform> const graphics_platform;90 std::shared_ptr<mtd::StubPlatform> const graphics_platform;
115 std::shared_ptr<mg::Display> const graphics_display;91 std::shared_ptr<mg::Display> const graphics_display;
116 std::shared_ptr<mc::GraphicBufferAllocator> const buffer_allocator;92 std::shared_ptr<mc::GraphicBufferAllocator> const buffer_allocator;
117 std::shared_ptr<mf::SessionMediatorReport> const report;93 std::shared_ptr<mf::SessionMediatorReport> const report;
11894
=== modified file 'tests/unit-tests/frontend/test_session_mediator_gbm.cpp'
--- tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-04-25 09:48:54 +0000
+++ tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-05-09 21:03:25 +0000
@@ -83,9 +83,9 @@
83 return std::make_shared<mg::PlatformIPCPackage>();83 return std::make_shared<mg::PlatformIPCPackage>();
84 }84 }
8585
86 EGLNativeDisplayType shell_egl_display()86 std::shared_ptr<mg::InternalClient> create_internal_client(std::shared_ptr<mf::Surface> const&)
87 {87 {
88 return static_cast<EGLNativeDisplayType>(0);88 return std::shared_ptr<mg::InternalClient>();
89 }89 }
9090
91 MOCK_METHOD1(drm_auth_magic, void(drm_magic_t));91 MOCK_METHOD1(drm_auth_magic, void(drm_magic_t));
9292
=== modified file 'tests/unit-tests/graphics/CMakeLists.txt'
--- tests/unit-tests/graphics/CMakeLists.txt 2013-04-24 05:22:20 +0000
+++ tests/unit-tests/graphics/CMakeLists.txt 2013-05-09 21:03:25 +0000
@@ -11,7 +11,6 @@
1111
12if (MIR_PLATFORM STREQUAL "gbm")12if (MIR_PLATFORM STREQUAL "gbm")
13add_subdirectory(gbm/)13add_subdirectory(gbm/)
14add_subdirectory(egl)
15endif()14endif()
1615
17set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE)16set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE)
1817
=== modified file 'tests/unit-tests/graphics/android/CMakeLists.txt'
--- tests/unit-tests/graphics/android/CMakeLists.txt 2013-05-02 16:29:48 +0000
+++ tests/unit-tests/graphics/android/CMakeLists.txt 2013-05-09 21:03:25 +0000
@@ -8,17 +8,20 @@
8 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_alloc_adaptor.cpp8 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_alloc_adaptor.cpp
9 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_alloc_adaptor_native_win.cpp9 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_alloc_adaptor_native_win.cpp
10 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_buffer_allocator.cpp10 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_buffer_allocator.cpp
11 ${CMAKE_CURRENT_SOURCE_DIR}/test_gpu_display.cpp
11 ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc_device.cpp12 ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc_device.cpp
12 ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc10_device.cpp13 ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc10_device.cpp
13 ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc11_device.cpp14 ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc11_device.cpp
14 ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc_display.cpp15 ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc_display.cpp
15 ${CMAKE_CURRENT_SOURCE_DIR}/test_gpu_display.cpp16 ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client_interpreter.cpp
17 ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client.cpp
16 ${CMAKE_CURRENT_SOURCE_DIR}/test_framebuffer_factory.cpp18 ${CMAKE_CURRENT_SOURCE_DIR}/test_framebuffer_factory.cpp
17 ${CMAKE_CURRENT_SOURCE_DIR}/test_fb_simple_swapper.cpp19 ${CMAKE_CURRENT_SOURCE_DIR}/test_fb_simple_swapper.cpp
18 ${CMAKE_CURRENT_SOURCE_DIR}/test_fb_device.cpp20 ${CMAKE_CURRENT_SOURCE_DIR}/test_fb_device.cpp
19 ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc_layerlist.cpp21 ${CMAKE_CURRENT_SOURCE_DIR}/test_hwc_layerlist.cpp
20 ${CMAKE_CURRENT_SOURCE_DIR}/test_server_interpreter.cpp22 ${CMAKE_CURRENT_SOURCE_DIR}/test_server_interpreter.cpp
21 ${CMAKE_CURRENT_SOURCE_DIR}/test_pixel_format.cpp23 ${CMAKE_CURRENT_SOURCE_DIR}/test_pixel_format.cpp
24 ${CMAKE_CURRENT_SOURCE_DIR}/test_interpreter_buffer_cache.cpp
22)25)
2326
24set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE)27set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE)
2528
=== added file 'tests/unit-tests/graphics/android/test_internal_client.cpp'
--- tests/unit-tests/graphics/android/test_internal_client.cpp 1970-01-01 00:00:00 +0000
+++ tests/unit-tests/graphics/android/test_internal_client.cpp 2013-05-09 21:03:25 +0000
@@ -0,0 +1,87 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "mir/frontend/surface.h"
20#include "src/server/graphics/android/internal_client.h"
21#include <system/window.h>
22#include <gtest/gtest.h>
23
24namespace geom=mir::geometry;
25namespace mc=mir::compositor;
26namespace mga=mir::graphics::android;
27
28namespace
29{
30class StubSurface : public mir::frontend::Surface
31{
32 void destroy()
33 {
34 }
35 void force_requests_to_complete()
36 {
37 }
38 geom::Size size() const
39 {
40 return geom::Size{geom::Width{4},geom::Height{2}};
41 }
42 geom::PixelFormat pixel_format() const
43 {
44 return geom::PixelFormat::xbgr_8888;
45 }
46 void advance_client_buffer()
47 {
48 }
49 std::shared_ptr<mc::Buffer> client_buffer() const
50 {
51 return std::shared_ptr<mc::Buffer>();
52 }
53 bool supports_input() const
54 {
55 return false;
56 }
57 int client_input_fd() const
58 {
59 return 5;
60 }
61 int configure(MirSurfaceAttrib, int)
62 {
63 return 218181;
64 }
65};
66}
67
68TEST(InternalClient, native_display)
69{
70 auto surface = std::make_shared<StubSurface>();
71 mga::InternalClient client(surface);
72 EXPECT_EQ(EGL_DEFAULT_DISPLAY, client.egl_native_display());
73}
74
75TEST(InternalClient, native_window)
76{
77 auto surface = std::make_shared<StubSurface>();
78 mga::InternalClient client(surface);
79 ANativeWindow* native_window = static_cast<ANativeWindow*>(client.egl_native_window());
80
81 /* check for basic window sanity */
82 ASSERT_NE(nullptr, native_window);
83 EXPECT_NE(nullptr, native_window->queueBuffer);
84 EXPECT_NE(nullptr, native_window->dequeueBuffer);
85 EXPECT_NE(nullptr, native_window->query);
86 EXPECT_NE(nullptr, native_window->perform);
87}
088
=== added file 'tests/unit-tests/graphics/android/test_internal_client_interpreter.cpp'
--- tests/unit-tests/graphics/android/test_internal_client_interpreter.cpp 1970-01-01 00:00:00 +0000
+++ tests/unit-tests/graphics/android/test_internal_client_interpreter.cpp 2013-05-09 21:03:25 +0000
@@ -0,0 +1,149 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "src/server/graphics/android/internal_client_window.h"
20#include "mir_test_doubles/mock_buffer.h"
21#include "mir_test_doubles/mock_swapper.h"
22#include "mir_test_doubles/mock_interpreter_resource_cache.h"
23#include "mir/frontend/surface.h"
24
25#include <gtest/gtest.h>
26#include <stdexcept>
27
28namespace mc=mir::compositor;
29namespace mtd=mir::test::doubles;
30namespace mga=mir::graphics::android;
31namespace geom=mir::geometry;
32namespace mf=mir::frontend;
33
34namespace
35{
36struct MockSurface : public mf::Surface
37{
38 MOCK_METHOD0(destroy, void());
39 MOCK_METHOD0(force_requests_to_complete, void());
40 MOCK_CONST_METHOD0(size, geom::Size());
41 MOCK_CONST_METHOD0(pixel_format, geom::PixelFormat());
42
43 MOCK_METHOD0(advance_client_buffer, void());
44 MOCK_CONST_METHOD0(client_buffer, std::shared_ptr<mc::Buffer>());
45
46 MOCK_CONST_METHOD0(supports_input, bool());
47 MOCK_CONST_METHOD0(client_input_fd, int());
48 MOCK_METHOD2(configure, int(MirSurfaceAttrib, int));
49};
50
51struct InternalClientWindow : public ::testing::Test
52{
53 void SetUp()
54 {
55 using namespace testing;
56 sz = geom::Size{geom::Width{4}, geom::Height{23}};
57 pf = geom::PixelFormat::abgr_8888;
58 mock_cache = std::make_shared<mtd::MockInterpreterResourceCache>();
59 mock_surface = std::make_shared<MockSurface>();
60 mock_buffer = std::make_shared<mtd::MockBuffer>();
61 stub_anw = std::make_shared<ANativeWindowBuffer>();
62
63 ON_CALL(*mock_surface, client_buffer())
64 .WillByDefault(Return(mock_buffer));
65 ON_CALL(*mock_surface, pixel_format())
66 .WillByDefault(Return(geom::PixelFormat::abgr_8888));
67 ON_CALL(*mock_buffer, native_buffer_handle())
68 .WillByDefault(Return(stub_anw));
69 }
70
71 std::shared_ptr<ANativeWindowBuffer> stub_anw;
72 std::shared_ptr<mtd::MockInterpreterResourceCache> mock_cache;
73 std::shared_ptr<MockSurface> mock_surface;
74 std::shared_ptr<mtd::MockBuffer> mock_buffer;
75 geom::Size sz;
76 geom::PixelFormat pf;
77};
78}
79
80TEST_F(InternalClientWindow, driver_requests_buffer)
81{
82 using namespace testing;
83 EXPECT_CALL(*mock_surface, client_buffer())
84 .Times(1);
85 EXPECT_CALL(*mock_buffer, native_buffer_handle())
86 .Times(1);
87 std::shared_ptr<mc::Buffer> tmp = mock_buffer;
88 EXPECT_CALL(*mock_cache, store_buffer(tmp, stub_anw.get()))
89 .Times(1);
90
91 mga::InternalClientWindow interpreter(mock_surface, mock_cache);
92 auto test_buffer = interpreter.driver_requests_buffer();
93 EXPECT_EQ(stub_anw.get(), test_buffer);
94}
95
96TEST_F(InternalClientWindow, driver_returns_buffer)
97{
98 using namespace testing;
99 std::shared_ptr<mga::SyncObject> fake_sync;
100
101 EXPECT_CALL(*mock_cache, retrieve_buffer(stub_anw.get()))
102 .Times(1)
103 .WillOnce(Return(mock_buffer));
104
105 mga::InternalClientWindow interpreter(mock_surface, mock_cache);
106 auto test_bufferptr = interpreter.driver_requests_buffer();
107 interpreter.driver_returns_buffer(test_bufferptr, fake_sync);
108}
109
110TEST_F(InternalClientWindow, size_test)
111{
112 using namespace testing;
113 EXPECT_CALL(*mock_surface, size())
114 .Times(2)
115 .WillOnce(Return(sz))
116 .WillOnce(Return(sz));
117 mga::InternalClientWindow interpreter(mock_surface, mock_cache);
118
119 unsigned int rc_width = interpreter.driver_requests_info(NATIVE_WINDOW_WIDTH);
120 unsigned int rc_height = interpreter.driver_requests_info(NATIVE_WINDOW_HEIGHT);
121
122 EXPECT_EQ(sz.width.as_uint32_t(), rc_width);
123 EXPECT_EQ(sz.height.as_uint32_t(), rc_height);
124}
125
126TEST_F(InternalClientWindow, driver_default_format)
127{
128 using namespace testing;
129 EXPECT_CALL(*mock_surface, pixel_format())
130 .Times(1);
131
132 mga::InternalClientWindow interpreter(mock_surface, mock_cache);
133
134 auto rc_format = interpreter.driver_requests_info(NATIVE_WINDOW_FORMAT);
135 EXPECT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, rc_format);
136}
137
138TEST_F(InternalClientWindow, driver_sets_format)
139{
140 using namespace testing;
141 EXPECT_CALL(*mock_surface, pixel_format())
142 .Times(AtLeast(1))
143 .WillRepeatedly(Return(geom::PixelFormat::abgr_8888));
144 mga::InternalClientWindow interpreter(mock_surface, mock_cache);
145
146 interpreter.dispatch_driver_request_format(HAL_PIXEL_FORMAT_RGBA_8888);
147 auto rc_format = interpreter.driver_requests_info(NATIVE_WINDOW_FORMAT);
148 EXPECT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, rc_format);
149}
0150
=== added file 'tests/unit-tests/graphics/android/test_interpreter_buffer_cache.cpp'
--- tests/unit-tests/graphics/android/test_interpreter_buffer_cache.cpp 1970-01-01 00:00:00 +0000
+++ tests/unit-tests/graphics/android/test_interpreter_buffer_cache.cpp 2013-05-09 21:03:25 +0000
@@ -0,0 +1,86 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "src/server/graphics/android/interpreter_cache.h"
20#include "mir_test_doubles/stub_buffer.h"
21
22#include <gtest/gtest.h>
23#include <stdexcept>
24
25namespace mga=mir::graphics::android;
26namespace mtd=mir::test::doubles;
27
28struct InterpreterResourceTest : public ::testing::Test
29{
30 void SetUp()
31 {
32 stub_buffer1 = std::make_shared<mtd::StubBuffer>();
33 stub_buffer2 = std::make_shared<mtd::StubBuffer>();
34 stub_buffer3 = std::make_shared<mtd::StubBuffer>();
35 key1 = (ANativeWindowBuffer*)0x1;
36 key2 = (ANativeWindowBuffer*)0x2;
37 key3 = (ANativeWindowBuffer*)0x3;
38 }
39
40 std::shared_ptr<mtd::StubBuffer> stub_buffer1;
41 std::shared_ptr<mtd::StubBuffer> stub_buffer2;
42 std::shared_ptr<mtd::StubBuffer> stub_buffer3;
43 ANativeWindowBuffer *key1;
44 ANativeWindowBuffer *key2;
45 ANativeWindowBuffer *key3;
46};
47
48TEST_F(InterpreterResourceTest, deposit_buffer)
49{
50 mga::InterpreterCache cache;
51 cache.store_buffer(stub_buffer1, key1);
52
53 auto test_buffer = cache.retrieve_buffer(key1);
54 EXPECT_EQ(stub_buffer1, test_buffer);
55}
56
57TEST_F(InterpreterResourceTest, deposit_many_buffers)
58{
59 mga::InterpreterCache cache;
60 cache.store_buffer(stub_buffer1, key1);
61 cache.store_buffer(stub_buffer2, key2);
62 cache.store_buffer(stub_buffer3, key3);
63
64 EXPECT_EQ(stub_buffer3, cache.retrieve_buffer(key3));
65 EXPECT_EQ(stub_buffer1, cache.retrieve_buffer(key1));
66 EXPECT_EQ(stub_buffer2, cache.retrieve_buffer(key2));
67}
68
69TEST_F(InterpreterResourceTest, deposit_buffer_has_ownership)
70{
71 mga::InterpreterCache cache;
72
73 auto use_count_before = stub_buffer1.use_count();
74 cache.store_buffer(stub_buffer1, key1);
75 EXPECT_EQ(use_count_before+1, stub_buffer1.use_count());
76 cache.retrieve_buffer(key1);
77 EXPECT_EQ(use_count_before, stub_buffer1.use_count());
78}
79
80TEST_F(InterpreterResourceTest, retreive_buffer_with_bad_key_throws)
81{
82 mga::InterpreterCache cache;
83 EXPECT_THROW({
84 cache.retrieve_buffer(key1);
85 }, std::runtime_error);
86}
087
=== modified file 'tests/unit-tests/graphics/android/test_server_interpreter.cpp'
--- tests/unit-tests/graphics/android/test_server_interpreter.cpp 2013-05-02 15:50:37 +0000
+++ tests/unit-tests/graphics/android/test_server_interpreter.cpp 2013-05-09 21:03:25 +0000
@@ -21,6 +21,7 @@
2121
22#include "mir_test_doubles/mock_display_support_provider.h"22#include "mir_test_doubles/mock_display_support_provider.h"
23#include "mir_test_doubles/mock_buffer.h"23#include "mir_test_doubles/mock_buffer.h"
24#include "mir_test_doubles/mock_interpreter_resource_cache.h"
2425
25#include <gtest/gtest.h>26#include <gtest/gtest.h>
26#include <gmock/gmock.h>27#include <gmock/gmock.h>
@@ -45,7 +46,8 @@
45 ~MockFBSwapper() noexcept {}46 ~MockFBSwapper() noexcept {}
46 MOCK_METHOD0(compositor_acquire, std::shared_ptr<mc::Buffer>());47 MOCK_METHOD0(compositor_acquire, std::shared_ptr<mc::Buffer>());
47 MOCK_METHOD1(compositor_release, void(std::shared_ptr<mc::Buffer> const& released_buffer));48 MOCK_METHOD1(compositor_release, void(std::shared_ptr<mc::Buffer> const& released_buffer));
48}; 49};
50
49struct ServerRenderWindowTest : public ::testing::Test51struct ServerRenderWindowTest : public ::testing::Test
50{52{
51 virtual void SetUp()53 virtual void SetUp()
@@ -56,6 +58,7 @@
56 mock_buffer3 = std::make_shared<NiceMock<mtd::MockBuffer>>();58 mock_buffer3 = std::make_shared<NiceMock<mtd::MockBuffer>>();
57 mock_swapper = std::make_shared<NiceMock<MockFBSwapper>>();59 mock_swapper = std::make_shared<NiceMock<MockFBSwapper>>();
58 mock_display_poster = std::make_shared<NiceMock<mtd::MockDisplaySupportProvider>>();60 mock_display_poster = std::make_shared<NiceMock<mtd::MockDisplaySupportProvider>>();
61 mock_cache = std::make_shared<mtd::MockInterpreterResourceCache>();
59 ON_CALL(*mock_display_poster, display_format())62 ON_CALL(*mock_display_poster, display_format())
60 .WillByDefault(Return(geom::PixelFormat::abgr_8888));63 .WillByDefault(Return(geom::PixelFormat::abgr_8888));
61 stub_sync = std::make_shared<StubFence>();64 stub_sync = std::make_shared<StubFence>();
@@ -64,6 +67,7 @@
64 std::shared_ptr<mtd::MockBuffer> mock_buffer1;67 std::shared_ptr<mtd::MockBuffer> mock_buffer1;
65 std::shared_ptr<mtd::MockBuffer> mock_buffer2;68 std::shared_ptr<mtd::MockBuffer> mock_buffer2;
66 std::shared_ptr<mtd::MockBuffer> mock_buffer3;69 std::shared_ptr<mtd::MockBuffer> mock_buffer3;
70 std::shared_ptr<mtd::MockInterpreterResourceCache> mock_cache;
67 std::shared_ptr<MockFBSwapper> mock_swapper;71 std::shared_ptr<MockFBSwapper> mock_swapper;
68 std::shared_ptr<mtd::MockDisplaySupportProvider> mock_display_poster;72 std::shared_ptr<mtd::MockDisplaySupportProvider> mock_display_poster;
69 std::shared_ptr<StubFence> stub_sync;73 std::shared_ptr<StubFence> stub_sync;
@@ -73,7 +77,7 @@
73TEST_F(ServerRenderWindowTest, driver_wants_a_buffer)77TEST_F(ServerRenderWindowTest, driver_wants_a_buffer)
74{78{
75 using namespace testing;79 using namespace testing;
76 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster);80 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache);
7781
78 auto stub_anw = std::make_shared<ANativeWindowBuffer>();82 auto stub_anw = std::make_shared<ANativeWindowBuffer>();
7983
@@ -84,17 +88,22 @@
84 .Times(1)88 .Times(1)
85 .WillOnce(Return(stub_anw));89 .WillOnce(Return(stub_anw));
8690
91 std::shared_ptr<mc::Buffer> tmp = mock_buffer1;
92 EXPECT_CALL(*mock_cache, store_buffer(tmp, stub_anw.get()))
93 .Times(1);
94
87 auto rc_buffer = render_window.driver_requests_buffer();95 auto rc_buffer = render_window.driver_requests_buffer();
88
89 EXPECT_EQ(stub_anw.get(), rc_buffer);96 EXPECT_EQ(stub_anw.get(), rc_buffer);
90}97}
9198
92TEST_F(ServerRenderWindowTest, driver_is_done_with_a_buffer_properly)99TEST_F(ServerRenderWindowTest, driver_is_done_with_a_buffer_properly)
93{100{
94 using namespace testing;101 using namespace testing;
95 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster);
96
97 auto stub_anw = std::make_shared<ANativeWindowBuffer>();102 auto stub_anw = std::make_shared<ANativeWindowBuffer>();
103 EXPECT_CALL(*mock_cache, retrieve_buffer(stub_anw.get()))
104 .Times(1)
105 .WillOnce(Return(mock_buffer1));
106 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache);
98107
99 EXPECT_CALL(*mock_swapper, compositor_acquire())108 EXPECT_CALL(*mock_swapper, compositor_acquire())
100 .Times(1)109 .Times(1)
@@ -116,74 +125,15 @@
116 testing::Mock::VerifyAndClearExpectations(mock_swapper.get());125 testing::Mock::VerifyAndClearExpectations(mock_swapper.get());
117}126}
118127
119/* note: in real usage, sync is enforced by the swapper class. we make use of the mock's non-blocking
120 to do the tests. */
121TEST_F(ServerRenderWindowTest, driver_is_done_with_a_few_buffers_properly)
122{
123 using namespace testing;
124 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster);
125
126 auto stub_anw = std::make_shared<ANativeWindowBuffer>();
127 auto stub_anw2 = std::make_shared<ANativeWindowBuffer>();
128 auto stub_anw3 = std::make_shared<ANativeWindowBuffer>();
129
130 EXPECT_CALL(*mock_swapper, compositor_acquire())
131 .Times(3)
132 .WillOnce(Return(mock_buffer1))
133 .WillOnce(Return(mock_buffer2))
134 .WillOnce(Return(mock_buffer3));
135 EXPECT_CALL(*mock_buffer1, native_buffer_handle())
136 .Times(1)
137 .WillOnce(Return(stub_anw));
138 EXPECT_CALL(*mock_buffer2, native_buffer_handle())
139 .Times(1)
140 .WillOnce(Return(stub_anw2));
141 EXPECT_CALL(*mock_buffer3, native_buffer_handle())
142 .Times(1)
143 .WillOnce(Return(stub_anw3));
144
145 auto handle1 = render_window.driver_requests_buffer();
146 auto handle2 = render_window.driver_requests_buffer();
147 auto handle3 = render_window.driver_requests_buffer();
148 testing::Mock::VerifyAndClearExpectations(mock_swapper.get());
149
150 std::shared_ptr<mc::Buffer> buf1 = mock_buffer1;
151 std::shared_ptr<mc::Buffer> buf2 = mock_buffer2;
152 std::shared_ptr<mc::Buffer> buf3 = mock_buffer3;
153 EXPECT_CALL(*mock_swapper, compositor_release(buf1))
154 .Times(1);
155 EXPECT_CALL(*mock_swapper, compositor_release(buf2))
156 .Times(1);
157 EXPECT_CALL(*mock_swapper, compositor_release(buf3))
158 .Times(1);
159
160 render_window.driver_returns_buffer(handle1, stub_sync);
161 render_window.driver_returns_buffer(handle2, stub_sync);
162 render_window.driver_returns_buffer(handle3, stub_sync);
163 testing::Mock::VerifyAndClearExpectations(mock_swapper.get());
164}
165
166TEST_F(ServerRenderWindowTest, throw_if_driver_returns_weird_buffer)
167{
168 using namespace testing;
169 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster);
170
171 auto stub_anw = std::make_shared<ANativeWindowBuffer>();
172
173 EXPECT_CALL(*mock_swapper, compositor_release(_))
174 .Times(0);
175
176 EXPECT_THROW({
177 render_window.driver_returns_buffer(nullptr, stub_sync);
178 }, std::runtime_error);
179}
180
181TEST_F(ServerRenderWindowTest, driver_returns_buffer_posts_to_fb)128TEST_F(ServerRenderWindowTest, driver_returns_buffer_posts_to_fb)
182{129{
183 using namespace testing;130 using namespace testing;
184 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster);131 auto stub_anw = std::make_shared<ANativeWindowBuffer>();
132 EXPECT_CALL(*mock_cache, retrieve_buffer(_))
133 .Times(1)
134 .WillOnce(Return(mock_buffer1));
135 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache);
185136
186 auto stub_anw = std::make_shared<ANativeWindowBuffer>();
187 mc::BufferID id{442}, returned_id;137 mc::BufferID id{442}, returned_id;
188 EXPECT_CALL(*mock_swapper, compositor_acquire())138 EXPECT_CALL(*mock_swapper, compositor_acquire())
189 .Times(1)139 .Times(1)
@@ -209,7 +159,7 @@
209 .Times(1)159 .Times(1)
210 .WillOnce(Return(geom::PixelFormat::abgr_8888));160 .WillOnce(Return(geom::PixelFormat::abgr_8888));
211161
212 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster);162 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache);
213163
214 EXPECT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, render_window.driver_requests_info(NATIVE_WINDOW_FORMAT));164 EXPECT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, render_window.driver_requests_info(NATIVE_WINDOW_FORMAT));
215}165}
@@ -218,7 +168,7 @@
218{168{
219 using namespace testing;169 using namespace testing;
220170
221 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster);171 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache);
222 EXPECT_CALL(*mock_display_poster, display_format())172 EXPECT_CALL(*mock_display_poster, display_format())
223 .Times(0);173 .Times(0);
224174
@@ -235,7 +185,7 @@
235 .Times(4)185 .Times(4)
236 .WillRepeatedly(Return(test_size));186 .WillRepeatedly(Return(test_size));
237187
238 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster);188 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache);
239189
240 unsigned int rc_width = render_window.driver_requests_info(NATIVE_WINDOW_DEFAULT_WIDTH);190 unsigned int rc_width = render_window.driver_requests_info(NATIVE_WINDOW_DEFAULT_WIDTH);
241 unsigned int rc_height = render_window.driver_requests_info(NATIVE_WINDOW_DEFAULT_HEIGHT);191 unsigned int rc_height = render_window.driver_requests_info(NATIVE_WINDOW_DEFAULT_HEIGHT);
@@ -252,7 +202,7 @@
252{202{
253 using namespace testing;203 using namespace testing;
254204
255 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster);205 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache);
256206
257 EXPECT_EQ(0, render_window.driver_requests_info(NATIVE_WINDOW_TRANSFORM_HINT));207 EXPECT_EQ(0, render_window.driver_requests_info(NATIVE_WINDOW_TRANSFORM_HINT));
258}208}
@@ -260,7 +210,7 @@
260TEST_F(ServerRenderWindowTest, driver_unknown_inquiry)210TEST_F(ServerRenderWindowTest, driver_unknown_inquiry)
261{211{
262 using namespace testing;212 using namespace testing;
263 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster);213 mga::ServerRenderWindow render_window(mock_swapper, mock_display_poster, mock_cache);
264214
265 EXPECT_THROW({215 EXPECT_THROW({
266 render_window.driver_requests_info(NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND);216 render_window.driver_requests_info(NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND);
267217
=== removed directory 'tests/unit-tests/graphics/egl'
=== removed file 'tests/unit-tests/graphics/egl/CMakeLists.txt'
--- tests/unit-tests/graphics/egl/CMakeLists.txt 2013-03-27 00:11:32 +0000
+++ tests/unit-tests/graphics/egl/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
1list(APPEND UNIT_TEST_SOURCES
2 ${CMAKE_CURRENT_SOURCE_DIR}/test_mirserver_mesa_egl_native_display.cpp
3)
4
5set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE)
6
70
=== modified file 'tests/unit-tests/graphics/gbm/CMakeLists.txt'
--- tests/unit-tests/graphics/gbm/CMakeLists.txt 2013-05-02 22:10:08 +0000
+++ tests/unit-tests/graphics/gbm/CMakeLists.txt 2013-05-09 21:03:25 +0000
@@ -5,9 +5,11 @@
5 ${CMAKE_CURRENT_SOURCE_DIR}/test_gbm_display.cpp5 ${CMAKE_CURRENT_SOURCE_DIR}/test_gbm_display.cpp
6 ${CMAKE_CURRENT_SOURCE_DIR}/test_gbm_display_multi_monitor.cpp6 ${CMAKE_CURRENT_SOURCE_DIR}/test_gbm_display_multi_monitor.cpp
7 ${CMAKE_CURRENT_SOURCE_DIR}/test_gbm_display_configuration.cpp7 ${CMAKE_CURRENT_SOURCE_DIR}/test_gbm_display_configuration.cpp
8 ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_client.cpp
8 ${CMAKE_CURRENT_SOURCE_DIR}/test_kms_output.cpp9 ${CMAKE_CURRENT_SOURCE_DIR}/test_kms_output.cpp
9 ${CMAKE_CURRENT_SOURCE_DIR}/test_kms_page_flipper.cpp10 ${CMAKE_CURRENT_SOURCE_DIR}/test_kms_page_flipper.cpp
10 ${CMAKE_CURRENT_SOURCE_DIR}/test_linux_virtual_terminal.cpp11 ${CMAKE_CURRENT_SOURCE_DIR}/test_linux_virtual_terminal.cpp
12 ${CMAKE_CURRENT_SOURCE_DIR}/test_internal_native_display.cpp
11)13)
1214
13set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE)15set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE)
1416
=== added file 'tests/unit-tests/graphics/gbm/internal_client.h'
=== modified file 'tests/unit-tests/graphics/gbm/test_gbm_platform.cpp'
--- tests/unit-tests/graphics/gbm/test_gbm_platform.cpp 2013-05-02 22:10:08 +0000
+++ tests/unit-tests/graphics/gbm/test_gbm_platform.cpp 2013-05-09 21:03:25 +0000
@@ -19,7 +19,9 @@
19#include "mir/graphics/platform_ipc_package.h"19#include "mir/graphics/platform_ipc_package.h"
20#include "mir/graphics/drm_authenticator.h"20#include "mir/graphics/drm_authenticator.h"
21#include "src/server/graphics/gbm/gbm_platform.h"21#include "src/server/graphics/gbm/gbm_platform.h"
22#include "src/server/graphics/gbm/internal_client.h"
22#include "mir_test_doubles/null_virtual_terminal.h"23#include "mir_test_doubles/null_virtual_terminal.h"
24#include "mir_test_doubles/stub_surface.h"
2325
24#include "mir/graphics/null_display_report.h"26#include "mir/graphics/null_display_report.h"
2527
@@ -139,3 +141,21 @@
139 authenticator->drm_auth_magic(magic);141 authenticator->drm_auth_magic(magic);
140 }, std::runtime_error);142 }, std::runtime_error);
141}143}
144
145/* TODO: this function is a bit fragile because libmirserver and libmirclient both have very different
146 * implementations and both have symbols for it. If the linking order of the test changes,
147 * specifically, if mir_egl_mesa_display_is_valid resolves into libmirclient, then this test will break.
148 */
149TEST_F(GBMGraphicsPlatform, platform_provides_validation_of_display_for_internal_clients)
150{
151 auto stub_surface = std::make_shared<mtd::StubSurface>();
152 MirMesaEGLNativeDisplay* native_display = nullptr;
153 EXPECT_EQ(0, mir_server_internal_display_is_valid(native_display));
154 {
155 auto platform = create_platform();
156 auto client = platform->create_internal_client(stub_surface);
157 native_display = reinterpret_cast<MirMesaEGLNativeDisplay*>(client->egl_native_display());
158 EXPECT_EQ(1, mir_server_internal_display_is_valid(native_display));
159 }
160 EXPECT_EQ(0, mir_server_internal_display_is_valid(native_display));
161}
142162
=== added file 'tests/unit-tests/graphics/gbm/test_internal_client.cpp'
--- tests/unit-tests/graphics/gbm/test_internal_client.cpp 1970-01-01 00:00:00 +0000
+++ tests/unit-tests/graphics/gbm/test_internal_client.cpp 2013-05-09 21:03:25 +0000
@@ -0,0 +1,43 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * 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: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "mir/frontend/surface.h"
20#include "mir_toolkit/mesa/native_display.h"
21#include "src/server/graphics/gbm/internal_client.h"
22#include "mir_test_doubles/stub_platform.h"
23#include "mir_test_doubles/stub_surface.h"
24
25#include <gtest/gtest.h>
26
27namespace geom=mir::geometry;
28namespace mc=mir::compositor;
29namespace mgg=mir::graphics::gbm;
30namespace mtd=mir::test::doubles;
31
32TEST(InternalClient, native_display)
33{
34 auto stub_window = std::make_shared<mtd::StubSurface>();
35 auto stub_display = std::make_shared<MirMesaEGLNativeDisplay>();
36 mgg::InternalClient client(stub_display, stub_window);
37
38 auto native_display = client.egl_native_display();
39 auto native_window = client.egl_native_window();
40
41 EXPECT_EQ(reinterpret_cast<EGLNativeDisplayType>(stub_display.get()), native_display);
42 EXPECT_EQ(reinterpret_cast<EGLNativeWindowType>(stub_window.get()), native_window);
43}
044
=== renamed file 'tests/unit-tests/graphics/egl/test_mirserver_mesa_egl_native_display.cpp' => 'tests/unit-tests/graphics/gbm/test_internal_native_display.cpp'
--- tests/unit-tests/graphics/egl/test_mirserver_mesa_egl_native_display.cpp 2013-04-23 08:17:12 +0000
+++ tests/unit-tests/graphics/gbm/test_internal_native_display.cpp 2013-05-09 21:03:25 +0000
@@ -15,7 +15,8 @@
15 *15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */17 */
18#include "mir/graphics/egl/mesa_native_display.h"18
19#include "src/server/graphics/gbm/internal_native_display.h"
19#include "mir/graphics/platform.h"20#include "mir/graphics/platform.h"
20#include "mir/graphics/platform_ipc_package.h"21#include "mir/graphics/platform_ipc_package.h"
21#include "mir/compositor/buffer_ipc_package.h"22#include "mir/compositor/buffer_ipc_package.h"
@@ -31,7 +32,7 @@
31#include <gmock/gmock.h>32#include <gmock/gmock.h>
3233
33namespace mg = mir::graphics;34namespace mg = mir::graphics;
34namespace mgeglm = mg::egl::mesa;35namespace mgg = mir::graphics::gbm;
35namespace mc = mir::compositor;36namespace mc = mir::compositor;
36namespace msh = mir::shell;37namespace msh = mir::shell;
37namespace geom = mir::geometry;38namespace geom = mir::geometry;
@@ -40,55 +41,44 @@
4041
41namespace42namespace
42{43{
4344struct InternalNativeDisplay : public testing::Test
44struct MockGraphicsPlatform : public mg::Platform45{
45{46 InternalNativeDisplay()
46 MOCK_METHOD1(create_buffer_allocator, std::shared_ptr<mc::GraphicBufferAllocator>(std::shared_ptr<mg::BufferInitializer> const&));47 {
47 MOCK_METHOD0(create_display, std::shared_ptr<mg::Display>());48 }
48 MOCK_METHOD0(get_ipc_package, std::shared_ptr<mg::PlatformIPCPackage>());49
49 MOCK_METHOD0(shell_egl_display, EGLNativeDisplayType());50 void SetUp()
50};
51
52struct MirServerMesaEGLNativeDisplaySetup : public testing::Test
53{
54 MirServerMesaEGLNativeDisplaySetup()
55 {51 {
56 using namespace ::testing;52 using namespace ::testing;
5753
58 test_platform_package.ipc_data = {1, 2};54 platform_package = std::make_shared<mg::PlatformIPCPackage>();
59 test_platform_package.ipc_fds = {2, 3};55 platform_package->ipc_data = {1, 2};
60 56 platform_package->ipc_fds = {2, 3};
61 ON_CALL(mock_graphics_platform, get_ipc_package())
62 .WillByDefault(Return(mt::fake_shared(test_platform_package)));
63 }57 }
6458
65 // Test dependencies59 std::shared_ptr<mg::PlatformIPCPackage> platform_package;
66 MockGraphicsPlatform mock_graphics_platform;
67
68 // Useful stub data
69 mg::PlatformIPCPackage test_platform_package;
70};60};
7161
72MATCHER_P(PackageMatches, package, "")62MATCHER_P(PackageMatches, package, "")
73{63{
74 if (arg.data_items != static_cast<int>(package.ipc_data.size()))64 if (arg.data_items != static_cast<int>(package->ipc_data.size()))
75 return false;65 return false;
76 for (uint i = 0; i < package.ipc_data.size(); i++)66 for (uint i = 0; i < package->ipc_data.size(); i++)
77 {67 {
78 if (arg.data[i] != package.ipc_data[i]) return false;68 if (arg.data[i] != package->ipc_data[i]) return false;
79 }69 }
80 if (arg.fd_items != static_cast<int>(package.ipc_fds.size()))70 if (arg.fd_items != static_cast<int>(package->ipc_fds.size()))
81 return false;71 return false;
82 for (uint i = 0; i < package.ipc_fds.size(); i++)72 for (uint i = 0; i < package->ipc_fds.size(); i++)
83 {73 {
84 if (arg.fd[i] != package.ipc_fds[i]) return false;74 if (arg.fd[i] != package->ipc_fds[i]) return false;
85 }75 }
86 return true;76 return true;
87}77}
8878
89MATCHER_P(StrideMatches, package, "")79MATCHER_P(StrideMatches, package, "")
90{80{
91 if (arg.stride != package.stride)81 if (arg.stride != package->stride)
92 {82 {
93 return false;83 return false;
94 }84 }
@@ -103,83 +93,62 @@
103 return false;93 return false;
104 return true;94 return true;
105}95}
106
107}96}
10897
109TEST_F(MirServerMesaEGLNativeDisplaySetup, display_get_platform_is_cached_platform_package)98TEST_F(InternalNativeDisplay, display_get_platform_matches_construction_platform)
110{99{
111 using namespace ::testing;100 using namespace ::testing;
112 101
113 EXPECT_CALL(mock_graphics_platform, get_ipc_package()).Times(1);102 mgg::InternalNativeDisplay native_display(platform_package);
114103
115 auto display = mgeglm::create_native_display(mt::fake_shared(mock_graphics_platform));104 MirPlatformPackage test_package;
116 105 memset(&test_package, 0, sizeof(MirPlatformPackage));
117 MirPlatformPackage package;106 native_display.display_get_platform(&native_display, &test_package);
118 memset(&package, 0, sizeof(MirPlatformPackage));107 EXPECT_THAT(test_package, PackageMatches(platform_package));
119 display->display_get_platform(display.get(), &package);
120 EXPECT_THAT(package, PackageMatches(test_platform_package));
121
122 MirPlatformPackage requeried_package;
123 // The package is cached to allow the package creator to control lifespan of fd members
124 // and so this should not trigger another call to get_ipc_package()
125 display->display_get_platform(display.get(), &requeried_package);
126
127 EXPECT_FALSE(memcmp(&requeried_package.data, &package.data, sizeof(package.data[0])*package.data_items));
128 EXPECT_FALSE(memcmp(&requeried_package.fd, &package.fd, sizeof(package.fd[0])*package.fd_items));
129}108}
130109
131TEST_F(MirServerMesaEGLNativeDisplaySetup, surface_get_current_buffer)110TEST_F(InternalNativeDisplay, surface_get_current_buffer)
132{111{
133 using namespace ::testing;112 using namespace ::testing;
134 113
135 mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>());114 mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>());
136 auto buffer = std::make_shared<mtd::MockBuffer>(geom::Size(), geom::Stride(), geom::PixelFormat());115 auto buffer = std::make_shared<mtd::MockBuffer>(geom::Size(), geom::Stride(), geom::PixelFormat());
137 116
138 mc::BufferIPCPackage test_buffer_package;117 auto test_buffer_package = std::make_shared<mc::BufferIPCPackage>();
139 118
140 test_buffer_package.ipc_data = {1, 2};119 test_buffer_package->ipc_data = {1, 2};
141 test_buffer_package.ipc_fds = {2, 3};120 test_buffer_package->ipc_fds = {2, 3};
142 test_buffer_package.stride = 77;121 test_buffer_package->stride = 77;
143122
144 auto display = mgeglm::create_native_display(mt::fake_shared(mock_graphics_platform));123 mgg::InternalNativeDisplay native_display(platform_package);
145 124
146 EXPECT_CALL(surface, client_buffer()).Times(1)125 EXPECT_CALL(surface, client_buffer()).Times(1)
147 .WillOnce(Return(buffer));126 .WillOnce(Return(buffer));
148 EXPECT_CALL(*buffer, get_ipc_package()).Times(1)127 EXPECT_CALL(*buffer, get_ipc_package()).Times(1)
149 .WillOnce(Return(mt::fake_shared(test_buffer_package)));128 .WillOnce(Return(test_buffer_package));
150 129
151 MirBufferPackage buffer_package;130 MirBufferPackage buffer_package;
152 memset(&buffer_package, 0, sizeof(MirBufferPackage));131 memset(&buffer_package, 0, sizeof(MirBufferPackage));
153 display->surface_get_current_buffer(132 native_display.surface_get_current_buffer(
154 display.get(), static_cast<MirEGLNativeWindowType>(&surface), &buffer_package);133 &native_display, static_cast<MirEGLNativeWindowType>(&surface), &buffer_package);
155 EXPECT_THAT(buffer_package, AllOf(PackageMatches(test_buffer_package), StrideMatches(test_buffer_package)));134 EXPECT_THAT(buffer_package, AllOf(PackageMatches(test_buffer_package), StrideMatches(test_buffer_package)));
156}135}
157136
158TEST_F(MirServerMesaEGLNativeDisplaySetup, surface_advance_buffer)137TEST_F(InternalNativeDisplay, surface_advance_buffer)
159{138{
160 using namespace ::testing;139 using namespace ::testing;
161 140
162 mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>());141 mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>());
163 142
164 auto display = mgeglm::create_native_display(mt::fake_shared(mock_graphics_platform));143 mgg::InternalNativeDisplay native_display(platform_package);
165 144
166 EXPECT_CALL(surface, advance_client_buffer()).Times(1);145 EXPECT_CALL(surface, advance_client_buffer()).Times(1);
167 146
168 display->surface_advance_buffer(147 native_display.surface_advance_buffer(
169 display.get(), static_cast<MirEGLNativeWindowType>(&surface));148 &native_display, static_cast<MirEGLNativeWindowType>(&surface));
170}149}
171150
172TEST(MirServerMesaEGLNativeDisplayInvariants, pixel_format_formats_are_castable)151TEST_F(InternalNativeDisplay, surface_get_parameters)
173{
174 EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::invalid), mir_pixel_format_invalid);
175 EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::abgr_8888), mir_pixel_format_abgr_8888);
176 EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::xbgr_8888), mir_pixel_format_xbgr_8888);
177 EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::argb_8888), mir_pixel_format_argb_8888);
178 EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::xrgb_8888), mir_pixel_format_xrgb_8888);
179 EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::bgr_888), mir_pixel_format_bgr_888);
180}
181
182TEST_F(MirServerMesaEGLNativeDisplaySetup, surface_get_parameters)
183{152{
184 using namespace ::testing;153 using namespace ::testing;
185 154
@@ -187,7 +156,7 @@
187 geom::Height{29}};156 geom::Height{29}};
188 geom::PixelFormat const test_pixel_format = geom::PixelFormat::xrgb_8888;157 geom::PixelFormat const test_pixel_format = geom::PixelFormat::xrgb_8888;
189158
190 auto display = mgeglm::create_native_display(mt::fake_shared(mock_graphics_platform));159 mgg::InternalNativeDisplay native_display(platform_package);
191160
192 mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>());161 mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>());
193 EXPECT_CALL(surface, size()).Times(AtLeast(1)).WillRepeatedly(Return(test_surface_size));162 EXPECT_CALL(surface, size()).Times(AtLeast(1)).WillRepeatedly(Return(test_surface_size));
@@ -195,8 +164,8 @@
195 164
196 MirSurfaceParameters parameters;165 MirSurfaceParameters parameters;
197 memset(&parameters, 0, sizeof(MirSurfaceParameters));166 memset(&parameters, 0, sizeof(MirSurfaceParameters));
198 display->surface_get_parameters(167 native_display.surface_get_parameters(
199 display.get(), static_cast<MirEGLNativeWindowType>(&surface), &parameters);168 &native_display, static_cast<MirEGLNativeWindowType>(&surface), &parameters);
200169
201 EXPECT_THAT(parameters, ParametersHaveSize(test_surface_size));170 EXPECT_THAT(parameters, ParametersHaveSize(test_surface_size));
202 EXPECT_EQ(parameters.pixel_format, static_cast<MirPixelFormat>(geom::PixelFormat::xrgb_8888));171 EXPECT_EQ(parameters.pixel_format, static_cast<MirPixelFormat>(geom::PixelFormat::xrgb_8888));
@@ -204,3 +173,13 @@
204 // TODO: What to do about buffer usage besides hardware? ~racarr173 // TODO: What to do about buffer usage besides hardware? ~racarr
205 EXPECT_EQ(parameters.buffer_usage, mir_buffer_usage_hardware);174 EXPECT_EQ(parameters.buffer_usage, mir_buffer_usage_hardware);
206}175}
176
177TEST(MirServerMesaEGLNativeDisplayInvariants, pixel_format_formats_are_castable)
178{
179 EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::invalid), mir_pixel_format_invalid);
180 EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::abgr_8888), mir_pixel_format_abgr_8888);
181 EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::xbgr_8888), mir_pixel_format_xbgr_8888);
182 EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::argb_8888), mir_pixel_format_argb_8888);
183 EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::xrgb_8888), mir_pixel_format_xrgb_8888);
184 EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::bgr_888), mir_pixel_format_bgr_888);
185}

Subscribers

People subscribed via source and target branches