Merge lp:~robertcarr/mir/enable-inprocess-egl into lp:~mir-team/mir/trunk
- enable-inprocess-egl
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Chris Halse Rogers | ||||||||
Approved revision: | no longer in the source branch. | ||||||||
Merged at revision: | 581 | ||||||||
Proposed branch: | lp:~robertcarr/mir/enable-inprocess-egl | ||||||||
Merge into: | lp:~mir-team/mir/trunk | ||||||||
Diff against target: |
1506 lines (+879/-66) 48 files modified
examples/CMakeLists.txt (+4/-0) examples/demo-inprocess-egl/CMakeLists.txt (+11/-0) examples/demo-inprocess-egl/demo_inprocess_egl.cpp (+48/-0) examples/demo-inprocess-egl/example_egl_helper.cpp (+78/-0) examples/demo-inprocess-egl/example_egl_helper.h (+53/-0) examples/demo-inprocess-egl/inprocess_egl_client.cpp (+83/-0) examples/demo-inprocess-egl/inprocess_egl_client.h (+61/-0) include/client/mir_toolkit/mir_client_library.h (+0/-7) include/server/mir/display_server.h (+0/-18) include/server/mir/graphics/egl/mesa_native_display.h (+42/-0) include/server/mir/graphics/platform.h (+5/-2) include/server/mir/shell/focus_sequence.h (+2/-2) include/shared/mir_toolkit/mesa/native_display.h (+3/-1) include/test/mir_test_doubles/mock_surface.h (+1/-1) include/test/mir_test_framework/testing_server_configuration.h (+1/-1) src/client/gbm/mesa_native_display_container.cpp (+8/-1) src/client/mir_client_library.cpp (+0/-5) src/server/display_server.cpp (+1/-0) src/server/graphics/CMakeLists.txt (+12/-2) src/server/graphics/android/android_platform.cpp (+6/-0) src/server/graphics/android/android_platform.h (+2/-0) src/server/graphics/egl/CMakeLists.txt (+10/-0) src/server/graphics/egl/mesa_native_display.cpp (+148/-0) src/server/graphics/gbm/gbm_platform.cpp (+17/-5) src/server/graphics/gbm/gbm_platform.h (+6/-0) src/server/shell/application_session.cpp (+1/-1) src/server/shell/single_visibility_focus_mechanism.cpp (+1/-1) src/server/shell/surface.cpp (+1/-2) src/server/shell/surface_source.cpp (+1/-2) tests/acceptance-tests/test_client_input.cpp (+1/-1) tests/acceptance-tests/test_test_framework.cpp (+1/-1) tests/behavior-tests/session_management_context.cpp (+1/-1) tests/integration-tests/graphics/gbm/test_buffer_integration.cpp (+5/-0) tests/integration-tests/test_display_info.cpp (+4/-1) tests/integration-tests/test_drm_auth_magic.cpp (+5/-0) tests/integration-tests/test_surfaceloop.cpp (+10/-0) tests/mir_test_framework/testing_process_manager.cpp (+1/-1) tests/mir_test_framework/testing_server_options.cpp (+6/-1) tests/unit-tests/client/gbm/test_gbm_client_platform.cpp (+6/-4) tests/unit-tests/frontend/test_session_mediator.cpp (+6/-1) tests/unit-tests/frontend/test_session_mediator_android.cpp (+5/-0) tests/unit-tests/frontend/test_session_mediator_gbm.cpp (+5/-0) tests/unit-tests/graphics/CMakeLists.txt (+1/-1) tests/unit-tests/graphics/egl/CMakeLists.txt (+6/-0) tests/unit-tests/graphics/egl/test_mirserver_mesa_egl_native_display.cpp (+207/-0) tests/unit-tests/shell/test_application_session.cpp (+1/-1) tests/unit-tests/shell/test_session_manager.cpp (+1/-1) tests/unit-tests/shell/test_surface.cpp (+1/-1) |
||||||||
To merge this branch: | bzr merge lp:~robertcarr/mir/enable-inprocess-egl | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Halse Rogers | Approve | ||
Kevin DuBois (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Alexandros Frantzis (community) | Needs Fixing | ||
Alan Griffiths | Abstain | ||
Review via email: mp+155888@code.launchpad.net |
Commit message
Provide a server side implementation of MirMesaEGLNativ
Description of the change
Inprocess demo is working
Machinery is all through graphics/
Android support is not present yet.
Daniel van Vugt (vanvugt) wrote : | # |
Alan Griffiths (alan-griffiths) wrote : | # |
Why rename DisplayServer to ServerInstance? (I could understand it being renamed e.g. "Mir".)
Anyway, it is broken:
src/server/
Alan Griffiths (alan-griffiths) wrote : | # |
67 + auto client = new me::InprocessEG
68 + client->start();
Looks like a memory leak.
~~~~
363 + InprocessEGLCli
...
853 + MesaNativeDispl
854 + : graphics_
I don't think these should be taking a DisplayServer - they should take a interface onto the configuration that has the_surface_
Alan Griffiths (alan-griffiths) wrote : | # |
I *think* the the_ready_
Alan Griffiths (alan-griffiths) wrote : | # |
Actually, why isn't DefaultServerCo
Robert Carr (robertcarr) wrote : | # |
Used the run_mir changes and some simplification around interfaces (never need mir::DisplayServer, just the graphics platform or surface factory) to simplify a lot of the errant complexity around this branch.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Robert Carr (robertcarr) wrote : | # |
Assosciated mesa changes (https:/
diff --git a/src/egl/
index d587ee9..a65aa40 100644
--- a/src/egl/
+++ b/src/egl/
@@ -60,7 +60,7 @@
#include <sys/stat.h>
#endif
#ifdef HAVE_MIR_PLATFORM
-#include <mir/client/
+#include <mir/client/
#endif
/**
@@ -158,7 +158,7 @@ _eglNativePlatf
#endif
#ifdef HAVE_MIR_PLATFORM
- if (mir_egl_
+ if (mir_egl_
return _EGL_PLATFORM_MIR;
#endif
@@ -196,7 +196,7 @@ _eglNativePlatf
_EGLPlatformType
_eglGetNativeP
{
- _EGLPlatformType native_platform = _EGL_INVALID_
+ static _EGLPlatformType native_platform = _EGL_INVALID_
char *detection_method = NULL;
if (native_platform == _EGL_INVALID_
diff --git a/src/egl/
index 292adad..ffdd146 100644
--- a/src/egl/
+++ b/src/egl/
@@ -200,8 +200,8 @@ _eglLoadModule(
lib_handle lib;
_EGLDriver *drv;
+ if (mod->Driver)
+ return EGL_TRUE;
if (mod->BuiltIn) {
lib = (lib_handle) NULL;
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:564
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:565
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Kevin DuBois (kdub) wrote : | # |
needs fixings:
src/server/
we build these on android (which appears to just have mesa related things). We should disable it until its working
src/server/
trailing whitespace in file
could the start function in the example program go in the constructor? (two step initialization)
non-blocking things that make the diff bigger:
src/server/
moving things around
src/server/
whitespace
default_
whitespace
Kevin DuBois (kdub) wrote : | # |
needs infos:
We're going to need some sort of platform abstraction for this I'd imagine... something like a mgeglm:
This might be because i'm not steeped in mesa terminology, but "MesaNativeDisplay" doesn't give me a hint as to what this is doing. (I could argue that the framebuffer is a native display too!) Maybe RenderTargetWindow? MesaInternalWin
Kevin DuBois (kdub) wrote : | # |
> needs infos:
> We're going to need some sort of platform abstraction for this I'd imagine...
> something like a mgeglm:
> independent namespace) that the inprocess clients can use without having to
> worry about mesa/android differences. Should we make a work item for this?
related to this... src/server/
Alan Griffiths (alan-griffiths) wrote : | # |
76 + auto client = new me::InprocessEG
77 + client->start();
Looks like a leak - at the very least it needs a comment explaining why it doesn't leak.
80 + std::shared_
81 + std::shared_
should be const.
Actually, loose this class and rewrite main():
int main(int argc, char const* argv[])
try
{
mir:
std:
mir:
{
client = std::make_
});
}
catch (std::exception const& error)
...
~~~~
516 === modified file 'include/
657 === modified file 'src/server/
1020 === modified file 'tests/
Unnecessary changes to these files. (None are are needed.)
~~~~
375 + virtual ~InprocessEGLCl
Why written explicitly? Why not "default"? Why virtual?
~~~~
402 -
Unnecessary
414 -
415 +
Wrong
~~~~
427 -/// All things Mir
It is a feeble doc comment, but please don't just remove it - replace it with something better!
~~~~
637 - display->context = connection;
638 + display->context = static_
Unnecessary?
~~~~
650 + display_server.cpp
651 run_mir.cpp
652 - display_server.cpp
Unnecessary.
Robert Carr (robertcarr) wrote : | # |
Kevin:
>> src/server/
>> we build these on android (which appears to just have mesa related things). We should disable it until its working
Fixed
>> could the start function in the example program go in the constructor? (two step initialization)
Yes! using the initializer list now
>> non-blocking things that make the diff bigger:
>> src/server/
>> moving things around
>>
>> src/server/
>> whitespace
>>
>> default_
>> whitespace
>> src/server/
>> trailing whitespace in file
Fixed!
>> We're going to need some sort of platform abstraction for this I'd imagine... something like a mgeglm:
I think maybe just a bug is fine?
>> This might be because i'm not steeped in mesa terminology, but "MesaNativeDisplay" doesn't give me a hint as to what this is doing. (I >>could argue that the framebuffer is a native display too!) Maybe RenderTargetWindow? MesaInternalWin
Would it help if it were called MesaEGLNativeDi
>> related to this... src/server/
>> sense. maybe mesa_native_
My thought here was that Mesa isn't really part of the "GBM" platform so to speak, so perhaps after android in server support lands there is graphics/
Robert Carr (robertcarr) wrote : | # |
Alan:
>>
>> 76 + auto client = new me::InprocessEG
>> 77 + client->start();
>>
>> Looks like a leak - at the very least it needs a comment explaining why it doesn't leak.
>>
>> 80 + std::shared_
>> 81 + std::shared_
>>
>> should be const.
>>
>> Actually, loose this class and rewrite main():
>>
>> int main(int argc, char const* argv[])
>> try
>> {
>> mir::DefaultSer
>>
>> std::shared_
>>
>> mir::run_
>> {
>> client = std::make_
>> config.
>> config.
>> client->start();
>> });
>> }
>> catch (std::exception const& error)
>> ...
>>
>> ~~~~
Good call. Fixed.
>>
>> 516 === modified file 'include/
>> 657 === modified file 'src/server/
>> 1020 === modified file 'tests/
>>
>> Unnecessary changes to these files. (None are are needed.)
>>
>> ~~~~
Removed
>>
>> 375 + virtual ~InprocessEGLCl
>>
>> Why written explicitly? Why not "default"? Why virtual?
>>
Removed
>> ~~~~
>>
>> 402 -
>>
>> Unnecessary
>>
>> 414 -
>> 415 +
>>
>> Wrong
>>
>> ~~~~
>>
>> 427 -/// All things Mir
>>
>> It is a feeble doc comment, but please don't just remove it - replace it with something better!
>>
>> ~~~~
>>
>> 637 - display->context = connection;
>> 638 + display->context = static_
>>
>> Unnecessary?
>>
>> ~~~~
>>
>> 650 + display_server.cpp
>> 651 run_mir.cpp
>> 652 - display_server.cpp
>>
>> Unnecessary.
>>
>>
Restored to original versions.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:575
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:578
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Alexandros Frantzis (afrantzis) wrote : | # |
I can't get this to run. I get:
libEGL debug: EGL user error 0x3001 (EGL_NOT_
mir_demo_
I am using the latest mesa from RAOF's git repository (https:/
Alan Griffiths (alan-griffiths) wrote : | # |
> I can't get this to run. I get:
>
> libEGL debug: EGL user error 0x3001 (EGL_NOT_
>
> mir_demo_
> /demo-inprocess
> mir::examples:
> EGLNativeWindow
>
> I am using the latest mesa from RAOF's git repository
> (https:/
I get a similar error. (mesa from ppa)
Robert Carr (robertcarr) wrote : | # |
Corrected mesa patch:
diff --git a/src/egl/
index da8136c..d587ee9 100644
--- a/src/egl/
+++ b/src/egl/
@@ -60,7 +60,7 @@
#include <sys/stat.h>
#endif
#ifdef HAVE_MIR_PLATFORM
-#include <mir_client_
+#include <mir/client/
#endif
/**
@@ -158,7 +158,7 @@ _eglNativePlatf
#endif
#ifdef HAVE_MIR_PLATFORM
- if (mir_connection
+ if (mir_egl_
return _EGL_PLATFORM_MIR;
#endif
@@ -196,7 +196,7 @@ _eglNativePlatf
_EGLPlatformType
_eglGetNativeP
{
- static _EGLPlatformType native_platform = _EGL_INVALID_
+ _EGLPlatformType native_platform = _EGL_INVALID_
char *detection_method = NULL;
if (native_platform == _EGL_INVALID_
diff --git a/src/egl/
index ffdd146..292adad 100644
--- a/src/egl/
+++ b/src/egl/
@@ -200,8 +200,8 @@ _eglLoadModule(
lib_handle lib;
_EGLDriver *drv;
- if (mod->Driver)
- return EGL_TRUE;
if (mod->BuiltIn) {
lib = (lib_handle) NULL;
Kevin DuBois (kdub) wrote : | # |
> Kevin:
> >> We're going to need some sort of platform abstraction for this I'd
> imagine... something like a mgeglm:
> platform independent namespace) that the inprocess clients can use without
> having to worry about mesa/android differences. Should we />> make a work item
> for this?
>
> I think maybe just a bug is fine?
Well, seems like a good time to head off a bug :)
include/
We have a mir::graphics:
>
> >> This might be because i'm not steeped in mesa terminology, but
> "MesaNativeDisplay" doesn't give me a hint as to what this is doing. (I
> >>could argue that the framebuffer is a native display too!) Maybe
> RenderTargetWindow? MesaInternalWin
>
> Would it help if it were called MesaEGLNativeDi
> this because of redundancy with the namespace. But redundancy isn't always
> bad.
I'm not too stuck on this one, I suppose we can leave it as it is
>
> >> related to this... src/server/
> are both platforms... egl isn't really a platform in this
> >> sense. maybe mesa_native_
> and we can get at it for mesa inprocess clients via the include/>>
> server/
>
> My thought here was that Mesa isn't really part of the "GBM" platform so to
> speak, so perhaps after android in server support lands there is
> graphics/
> graphics/
Could we just model these as a different displays? I'm beginning to think that we do need one folder for displays that are not necessarily tied to a platform (eg, an SDL display that Elenimaria was looking at, or one for mir-as-mir-client, or one for this). I am still favoring this being in the gbm platform folder, as we can't really separate mesa from gbm so they're all one logical platform, even if mesa and gbm are distinct pieces when working on that platform
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:579
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:581
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:583
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Robert Carr (robertcarr) wrote : | # |
Pushed some changes to abstract creation of the native display (and ownership of! looks much nicer from client perspective...see inprocess_
Kevin DuBois (kdub) wrote : | # |
ok! the abstraction is looking much better. The android platform returning a null is ok. Overall this looks good to me, a few minor things:
platform.h
mir_native_
android_
test_display_
<others>
C-style cast (although if its tough to get around because these are EGL types, i suppose its ok)
display_server.cpp
addition of tab whitespace after member variable
native_display.h
I don't see what's driving the change to void*
mesa_native_
we can considate the extern "C" with the one already in the file pretty easily
mesa_native_
we use new/raw ptrs instead of std::shared_ptr
Alan Griffiths (alan-griffiths) wrote : | # |
kdub has already mentioned my main points.
I'm also wondering if the example be cleaner if it threw exceptions rather than terminating via assert? (That permits a clean shutdown.)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:584
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alexandros Frantzis (afrantzis) wrote : | # |
> kdub has already mentioned my main points.
>
> I'm also wondering if the example be cleaner if it threw exceptions rather
> than terminating via assert? (That permits a clean shutdown.)
Tried this branch with the mesa patche applied. The example seems to work well, apart from aborting on shutdown :)
Chris Halse Rogers (raof) wrote : | # |
I've got the mesa changes cleaned up and ready to go.
Question: wither mir_egl_
Either mir_egl_
Alan Griffiths (alan-griffiths) wrote : | # |
Changing the signature of TestingServerCo
However, it leads to confict with trunk:
tests/acceptanc
Alan Griffiths (alan-griffiths) wrote : | # |
Remove blocking vote
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:586
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alexandros Frantzis (afrantzis) wrote : | # |
We should ensure the example runs and shuts down properly before merging this.
Robert Carr (robertcarr) wrote : | # |
>> Either mir_egl_
The old version still works. The new version exists to be overriden by the server (And for usage only by mesa)...I didn't want to have libmirserver conflict with client library symbols.
Robert Carr (robertcarr) wrote : | # |
Fixed shutdown.
Robert Carr (robertcarr) wrote : | # |
Renamed mg::Platform:
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:588
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:589
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:590
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Kevin DuBois (kdub) wrote : | # |
just a few questions remaining...
> platform.h
> mir_native_
> "inprocess egl"
cool, much better name
> android_
> test_display_
> <others>
> C-style cast (although if its tough to get around because these are EGL types,
> i suppose its ok)
these still remain... are they too difficult to remove?
> native_display.h
> I don't see what's driving the change to void*
> mesa_native_
> we use new/raw ptrs instead of std::shared_ptr
still a few new/delete's
Alexandros Frantzis (afrantzis) wrote : | # |
> > mesa_native_
> > we use new/raw ptrs instead of std::shared_ptr
>
> still a few new/delete's
Perhaps we should drop the Impl class, and just inherit from MirMesaEGLNativ
struct ShellMesaEGLNat
{
ShellMesaEG
: graphics_
{
/* Fill in MirMesaEGLNativ
context = this;
...
}
static void native_
{
auto native_disp = static_
}
void display_
{
...
}
std:
...
}
auto native_display = std::shared_
Robert Carr (robertcarr) wrote : | # |
>> these still remain... are they too difficult to remove?
No! fixed
> native_display.h
> I don't see what's driving the change to void*
Before it was MirConnection but we need to store server context as well (mesa_native_
> mesa_native_
> we use new/raw ptrs instead of std::shared_ptr
Removed one via alf's refactoring.
>> Perhaps we should drop the Impl class, and just inherit from MirMesaEGLNativ
>>
Good call.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:595
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Kevin DuBois (kdub) wrote : | # |
well, i can't speak to whether this works or not, but the code looks good. i'll +1 conditional on someone assuring me that the code works on gbm :)
Chris Halse Rogers (raof) wrote : | # |
Looks good to me, and works with the Mesa currently in the PPA.
Chris Halse Rogers (raof) wrote : | # |
Also now closes cleanly, fixing Alexandros' last review comment, so marking as approved.
Preview Diff
1 | === modified file 'examples/CMakeLists.txt' |
2 | --- examples/CMakeLists.txt 2013-03-28 09:50:09 +0000 |
3 | +++ examples/CMakeLists.txt 2013-04-10 16:59:23 +0000 |
4 | @@ -120,5 +120,9 @@ |
5 | mir_eglplasma |
6 | ) |
7 | |
8 | +if (MIR_PLATFORM STREQUAL "gbm") |
9 | + add_subdirectory(demo-inprocess-egl) |
10 | +endif() |
11 | + |
12 | install(TARGETS ${DEMO_CLIENTS} RUNTIME DESTINATION bin) |
13 | |
14 | |
15 | === added directory 'examples/demo-inprocess-egl' |
16 | === added file 'examples/demo-inprocess-egl/CMakeLists.txt' |
17 | --- examples/demo-inprocess-egl/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
18 | +++ examples/demo-inprocess-egl/CMakeLists.txt 2013-04-10 16:59:23 +0000 |
19 | @@ -0,0 +1,11 @@ |
20 | +add_executable(mir_demo_inprocess_egl |
21 | + demo_inprocess_egl.cpp |
22 | + inprocess_egl_client.cpp |
23 | + example_egl_helper.cpp |
24 | +) |
25 | + |
26 | +target_link_libraries(mir_demo_inprocess_egl |
27 | + mirserver |
28 | + mirdraw |
29 | +) |
30 | +# TODO Install this demo? |
31 | \ No newline at end of file |
32 | |
33 | === added file 'examples/demo-inprocess-egl/demo_inprocess_egl.cpp' |
34 | --- examples/demo-inprocess-egl/demo_inprocess_egl.cpp 1970-01-01 00:00:00 +0000 |
35 | +++ examples/demo-inprocess-egl/demo_inprocess_egl.cpp 2013-04-10 16:59:23 +0000 |
36 | @@ -0,0 +1,48 @@ |
37 | +/* |
38 | + * Copyright © 2013 Canonical Ltd. |
39 | + * |
40 | + * This program is free software: you can redistribute it and/or modify |
41 | + * it under the terms of the GNU General Public License version 3 as |
42 | + * published by the Free Software Foundation. |
43 | + * |
44 | + * This program is distributed in the hope that it will be useful, |
45 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
46 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
47 | + * GNU General Public License for more details. |
48 | + * |
49 | + * You should have received a copy of the GNU General Public License |
50 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
51 | + * |
52 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
53 | + */ |
54 | + |
55 | +#include "inprocess_egl_client.h" |
56 | + |
57 | +#include "mir/run_mir.h" |
58 | +#include "mir/default_server_configuration.h" |
59 | + |
60 | +#include <boost/exception/diagnostic_information.hpp> |
61 | +#include <iostream> |
62 | + |
63 | +namespace me = mir::examples; |
64 | + |
65 | +int main(int argc, char const* argv[]) |
66 | +try |
67 | +{ |
68 | + mir::DefaultServerConfiguration config(argc, argv); |
69 | + |
70 | + std::shared_ptr<me::InprocessEGLClient> client; |
71 | + mir::run_mir(config, [&config, &client](mir::DisplayServer&) |
72 | + { |
73 | + client = std::make_shared<me::InprocessEGLClient>( |
74 | + config.the_graphics_platform(), |
75 | + config.the_surface_factory()); |
76 | + }); |
77 | + |
78 | + return 0; |
79 | +} |
80 | +catch (std::exception const& error) |
81 | +{ |
82 | + std::cerr << "ERROR: " << boost::diagnostic_information(error) << std::endl; |
83 | + return 1; |
84 | +} |
85 | |
86 | === added file 'examples/demo-inprocess-egl/example_egl_helper.cpp' |
87 | --- examples/demo-inprocess-egl/example_egl_helper.cpp 1970-01-01 00:00:00 +0000 |
88 | +++ examples/demo-inprocess-egl/example_egl_helper.cpp 2013-04-10 16:59:23 +0000 |
89 | @@ -0,0 +1,78 @@ |
90 | +/* |
91 | + * Copyright © 2013 Canonical Ltd. |
92 | + * |
93 | + * This program is free software: you can redistribute it and/or modify |
94 | + * it under the terms of the GNU General Public License version 3 as |
95 | + * published by the Free Software Foundation. |
96 | + * |
97 | + * This program is distributed in the hope that it will be useful, |
98 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
99 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
100 | + * GNU General Public License for more details. |
101 | + * |
102 | + * You should have received a copy of the GNU General Public License |
103 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
104 | + * |
105 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
106 | + */ |
107 | + |
108 | +#include "example_egl_helper.h" |
109 | + |
110 | +#include <assert.h> |
111 | + |
112 | +namespace me = mir::examples; |
113 | + |
114 | +me::EGLHelper::EGLHelper(EGLNativeDisplayType native_display, EGLNativeWindowType native_window) |
115 | +{ |
116 | + display = eglGetDisplay(native_display); |
117 | + assert(display != EGL_NO_DISPLAY); |
118 | + |
119 | + int major, minor, rc; |
120 | + rc = eglInitialize(display, &major, &minor); |
121 | + assert(rc == EGL_TRUE); |
122 | + assert(major == 1); |
123 | + assert(minor == 4); |
124 | + |
125 | + EGLint attribs[] = { |
126 | + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
127 | + EGL_RED_SIZE, 8, |
128 | + EGL_GREEN_SIZE, 8, |
129 | + EGL_BLUE_SIZE, 8, |
130 | + EGL_ALPHA_SIZE, 8, |
131 | + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, |
132 | + EGL_NONE }; |
133 | + EGLConfig egl_config; |
134 | + int n; |
135 | + rc = eglChooseConfig(display, attribs, &egl_config, 1, &n); |
136 | + assert(rc == EGL_TRUE); |
137 | + assert(n == 1); |
138 | + |
139 | + surface = eglCreateWindowSurface(display, egl_config, native_window, nullptr); |
140 | + assert(surface != EGL_NO_SURFACE); |
141 | + |
142 | + EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; |
143 | + context = eglCreateContext(display, egl_config, EGL_NO_CONTEXT, context_attribs); |
144 | + assert(surface != EGL_NO_CONTEXT); |
145 | +} |
146 | + |
147 | +me::EGLHelper::~EGLHelper() |
148 | +{ |
149 | + eglDestroySurface(display, surface); |
150 | + eglDestroyContext(display, context); |
151 | + eglTerminate(display); |
152 | +} |
153 | + |
154 | +EGLDisplay me::EGLHelper::the_display() const |
155 | +{ |
156 | + return display; |
157 | +} |
158 | + |
159 | +EGLContext me::EGLHelper::the_context() const |
160 | +{ |
161 | + return context; |
162 | +} |
163 | + |
164 | +EGLSurface me::EGLHelper::the_surface() const |
165 | +{ |
166 | + return surface; |
167 | +} |
168 | |
169 | === added file 'examples/demo-inprocess-egl/example_egl_helper.h' |
170 | --- examples/demo-inprocess-egl/example_egl_helper.h 1970-01-01 00:00:00 +0000 |
171 | +++ examples/demo-inprocess-egl/example_egl_helper.h 2013-04-10 16:59:23 +0000 |
172 | @@ -0,0 +1,53 @@ |
173 | +/* |
174 | + * Copyright © 2013 Canonical Ltd. |
175 | + * |
176 | + * This program is free software: you can redistribute it and/or modify |
177 | + * it under the terms of the GNU General Public License version 3 as |
178 | + * published by the Free Software Foundation. |
179 | + * |
180 | + * This program is distributed in the hope that it will be useful, |
181 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
182 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
183 | + * GNU General Public License for more details. |
184 | + * |
185 | + * You should have received a copy of the GNU General Public License |
186 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
187 | + * |
188 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
189 | + */ |
190 | + |
191 | +#ifndef MIR_EXAMPLES_EGL_HELPER_H_ |
192 | +#define MIR_EXAMPLES_EGL_HELPER_H_ |
193 | + |
194 | +#include <EGL/egl.h> |
195 | + |
196 | +namespace mir |
197 | +{ |
198 | +namespace examples |
199 | +{ |
200 | + |
201 | +/// Simple helper class for managing an EGL rendering with a sensible default configuration. |
202 | +class EGLHelper |
203 | +{ |
204 | +public: |
205 | + EGLHelper(EGLNativeDisplayType native_display, EGLNativeWindowType native_surface); |
206 | + virtual ~EGLHelper(); |
207 | + |
208 | + EGLDisplay the_display() const; |
209 | + EGLContext the_context() const; |
210 | + EGLSurface the_surface() const; |
211 | + |
212 | +protected: |
213 | + EGLHelper(EGLHelper const&) = delete; |
214 | + EGLHelper& operator=(EGLHelper const&) = delete; |
215 | + |
216 | +private: |
217 | + EGLDisplay display; |
218 | + EGLContext context; |
219 | + EGLSurface surface; |
220 | +}; |
221 | + |
222 | +} |
223 | +} // namespace mir |
224 | + |
225 | +#endif // MIR_EXAMPLES_EGL_HELPER_H_ |
226 | |
227 | === added file 'examples/demo-inprocess-egl/inprocess_egl_client.cpp' |
228 | --- examples/demo-inprocess-egl/inprocess_egl_client.cpp 1970-01-01 00:00:00 +0000 |
229 | +++ examples/demo-inprocess-egl/inprocess_egl_client.cpp 2013-04-10 16:59:23 +0000 |
230 | @@ -0,0 +1,83 @@ |
231 | +/* |
232 | + * Copyright © 2013 Canonical Ltd. |
233 | + * |
234 | + * This program is free software: you can redistribute it and/or modify |
235 | + * it under the terms of the GNU General Public License version 3 as |
236 | + * published by the Free Software Foundation. |
237 | + * |
238 | + * This program is distributed in the hope that it will be useful, |
239 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
240 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
241 | + * GNU General Public License for more details. |
242 | + * |
243 | + * You should have received a copy of the GNU General Public License |
244 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
245 | + * |
246 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
247 | + */ |
248 | + |
249 | +#include "inprocess_egl_client.h" |
250 | +#include "example_egl_helper.h" |
251 | + |
252 | +#include "mir/shell/surface_factory.h" |
253 | +#include "mir/shell/surface.h" |
254 | +#include "mir/frontend/surface_creation_parameters.h" |
255 | +#include "mir/geometry/size.h" |
256 | +#include "mir/compositor/buffer_properties.h" |
257 | +#include "mir/graphics/platform.h" |
258 | + |
259 | +#include "mir/draw/graphics.h" |
260 | + |
261 | +#include <EGL/egl.h> |
262 | + |
263 | +#include <functional> |
264 | + |
265 | +#include <assert.h> |
266 | + |
267 | +namespace mf = mir::frontend; |
268 | +namespace mc = mir::compositor; |
269 | +namespace msh = mir::shell; |
270 | +namespace mg = mir::graphics; |
271 | +namespace me = mir::examples; |
272 | +namespace geom = mir::geometry; |
273 | + |
274 | +me::InprocessEGLClient::InprocessEGLClient(std::shared_ptr<mg::Platform> const& graphics_platform, |
275 | + std::shared_ptr<msh::SurfaceFactory> const& surface_factory) |
276 | + : graphics_platform(graphics_platform), |
277 | + surface_factory(surface_factory), |
278 | + client_thread(std::mem_fn(&InprocessEGLClient::thread_loop), this) |
279 | +{ |
280 | + client_thread.detach(); |
281 | +} |
282 | + |
283 | +void me::InprocessEGLClient::thread_loop() |
284 | +{ |
285 | + geom::Size const surface_size = geom::Size{geom::Width{512}, |
286 | + geom::Height{512}}; |
287 | + |
288 | + auto params = mf::a_surface().of_name("Inprocess EGL Demo") |
289 | + .of_size(surface_size) |
290 | + .of_buffer_usage(mc::BufferUsage::hardware) |
291 | + .of_pixel_format(geom::PixelFormat::argb_8888); |
292 | + auto surface = surface_factory->create_surface(params); |
293 | + |
294 | + surface->advance_client_buffer(); // TODO: What a wart! |
295 | + |
296 | + auto native_display = graphics_platform->shell_egl_display(); |
297 | + me::EGLHelper helper(reinterpret_cast<EGLNativeDisplayType>(native_display), reinterpret_cast<EGLNativeWindowType>(surface.get())); |
298 | + |
299 | + auto rc = eglMakeCurrent(helper.the_display(), helper.the_surface(), helper.the_surface(), helper.the_context()); |
300 | + assert(rc == EGL_TRUE); |
301 | + |
302 | + mir::draw::glAnimationBasic gl_animation; |
303 | + gl_animation.init_gl(); |
304 | + |
305 | + for(;;) |
306 | + { |
307 | + gl_animation.render_gl(); |
308 | + rc = eglSwapBuffers(helper.the_display(), helper.the_surface()); |
309 | + assert(rc = EGL_TRUE); |
310 | + |
311 | + gl_animation.step(); |
312 | + } |
313 | +} |
314 | |
315 | === added file 'examples/demo-inprocess-egl/inprocess_egl_client.h' |
316 | --- examples/demo-inprocess-egl/inprocess_egl_client.h 1970-01-01 00:00:00 +0000 |
317 | +++ examples/demo-inprocess-egl/inprocess_egl_client.h 2013-04-10 16:59:23 +0000 |
318 | @@ -0,0 +1,61 @@ |
319 | +/* |
320 | + * Copyright © 2013 Canonical Ltd. |
321 | + * |
322 | + * This program is free software: you can redistribute it and/or modify |
323 | + * it under the terms of the GNU General Public License version 3 as |
324 | + * published by the Free Software Foundation. |
325 | + * |
326 | + * This program is distributed in the hope that it will be useful, |
327 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
328 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
329 | + * GNU General Public License for more details. |
330 | + * |
331 | + * You should have received a copy of the GNU General Public License |
332 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
333 | + * |
334 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
335 | + */ |
336 | + |
337 | +#ifndef MIR_EXAMPLES_INPROCESS_EGL_CLIENT_H_ |
338 | +#define MIR_EXAMPLES_INPROCESS_EGL_CLIENT_H_ |
339 | + |
340 | +#include <thread> |
341 | +#include <memory> |
342 | + |
343 | +namespace mir |
344 | +{ |
345 | +namespace graphics |
346 | +{ |
347 | +class Platform; |
348 | +} |
349 | +namespace shell |
350 | +{ |
351 | +class SurfaceFactory; |
352 | +} |
353 | + |
354 | +namespace examples |
355 | +{ |
356 | + |
357 | +/// Encapsulation of a simple threaded client demonstrating inprocess EGL rendering |
358 | +class InprocessEGLClient |
359 | +{ |
360 | +public: |
361 | + InprocessEGLClient(std::shared_ptr<graphics::Platform> const& graphics_platform, |
362 | + std::shared_ptr<shell::SurfaceFactory> const& surface_factory); |
363 | + |
364 | +protected: |
365 | + InprocessEGLClient(InprocessEGLClient const&) = delete; |
366 | + InprocessEGLClient& operator=(InprocessEGLClient const&) = delete; |
367 | + |
368 | +private: |
369 | + std::shared_ptr<graphics::Platform> const graphics_platform; |
370 | + std::shared_ptr<shell::SurfaceFactory> const surface_factory; |
371 | + |
372 | + std::thread client_thread; |
373 | + void thread_loop(); |
374 | +}; |
375 | + |
376 | +} |
377 | +} // namespace mir |
378 | + |
379 | +#endif // MIR_EXAMPLES_INPROCESS_EGL_CLIENT_H_ |
380 | |
381 | === modified file 'include/client/mir_toolkit/mir_client_library.h' |
382 | --- include/client/mir_toolkit/mir_client_library.h 2013-04-08 05:51:29 +0000 |
383 | +++ include/client/mir_toolkit/mir_client_library.h 2013-04-10 16:59:23 +0000 |
384 | @@ -103,13 +103,6 @@ |
385 | MirEGLNativeDisplayType mir_connection_get_egl_native_display(MirConnection *connection); |
386 | |
387 | /** |
388 | - * Validate an EGL native display |
389 | - * \param [in] display the display |
390 | - * \return whether the display is valid for use with EGL |
391 | - */ |
392 | -int mir_egl_native_display_is_valid(MirEGLNativeDisplayType display); |
393 | - |
394 | -/** |
395 | * Request a new Mir surface on the supplied connection with the supplied |
396 | * parameters. The returned handle remains valid until the surface has been |
397 | * released. |
398 | |
399 | === modified file 'include/server/mir/display_server.h' |
400 | --- include/server/mir/display_server.h 2013-03-19 09:51:24 +0000 |
401 | +++ include/server/mir/display_server.h 2013-04-10 16:59:23 +0000 |
402 | @@ -26,24 +26,6 @@ |
403 | /// All things Mir |
404 | namespace mir |
405 | { |
406 | -namespace compositor |
407 | -{ |
408 | - |
409 | -class BufferAllocationStrategy; |
410 | -class BufferBundleFactory; |
411 | - |
412 | -} |
413 | -namespace frontend |
414 | -{ |
415 | - |
416 | -class Communicator; |
417 | - |
418 | -} |
419 | -namespace graphics |
420 | -{ |
421 | -class Display; |
422 | -} |
423 | - |
424 | class ServerConfiguration; |
425 | |
426 | class DisplayServer |
427 | |
428 | === added directory 'include/server/mir/graphics/egl' |
429 | === added file 'include/server/mir/graphics/egl/mesa_native_display.h' |
430 | --- include/server/mir/graphics/egl/mesa_native_display.h 1970-01-01 00:00:00 +0000 |
431 | +++ include/server/mir/graphics/egl/mesa_native_display.h 2013-04-10 16:59:23 +0000 |
432 | @@ -0,0 +1,42 @@ |
433 | +/* |
434 | + * Copyright © 2013 Canonical Ltd. |
435 | + * |
436 | + * This program is free software: you can redistribute it and/or modify it |
437 | + * under the terms of the GNU Lesser General Public License version 3, |
438 | + * as published by the Free Software Foundation. |
439 | + * |
440 | + * This program is distributed in the hope that it will be useful, |
441 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
442 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
443 | + * GNU General Public License for more details. |
444 | + * |
445 | + * You should have received a copy of the GNU Lesser General Public License |
446 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
447 | + * |
448 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
449 | + */ |
450 | + |
451 | +#ifndef MIR_GRAPHICS_EGL_NATIVE_DISPLAY_H_ |
452 | +#define MIR_GRAPHICS_EGL_NATIVE_DISPLAY_H_ |
453 | + |
454 | +#include "mir_toolkit/mesa/native_display.h" |
455 | + |
456 | +#include <memory> |
457 | + |
458 | +namespace mir |
459 | +{ |
460 | +namespace graphics |
461 | +{ |
462 | +class Platform; |
463 | + |
464 | +namespace egl |
465 | +{ |
466 | +namespace mesa |
467 | +{ |
468 | +std::shared_ptr<MirMesaEGLNativeDisplay> create_native_display(std::shared_ptr<Platform> const& platform); |
469 | +} |
470 | +} |
471 | +} |
472 | +} // namespace mir |
473 | + |
474 | +#endif // MIR_GRAPHICS_EGL_NATIVE_DISPLAY_H_ |
475 | |
476 | === modified file 'include/server/mir/graphics/platform.h' |
477 | --- include/server/mir/graphics/platform.h 2013-03-21 03:32:59 +0000 |
478 | +++ include/server/mir/graphics/platform.h 2013-04-10 16:59:23 +0000 |
479 | @@ -20,9 +20,10 @@ |
480 | #ifndef MIR_GRAPHICS_PLATFORM_H_ |
481 | #define MIR_GRAPHICS_PLATFORM_H_ |
482 | |
483 | +#include <EGL/egl.h> |
484 | + |
485 | #include <memory> |
486 | |
487 | - |
488 | namespace mir |
489 | { |
490 | namespace compositor |
491 | @@ -50,9 +51,11 @@ |
492 | Platform& operator=(const Platform& p) = delete; |
493 | |
494 | virtual std::shared_ptr<compositor::GraphicBufferAllocator> create_buffer_allocator( |
495 | - const std::shared_ptr<BufferInitializer>& buffer_initializer) = 0; |
496 | + std::shared_ptr<BufferInitializer> const& buffer_initializer) = 0; |
497 | virtual std::shared_ptr<Display> create_display() = 0; |
498 | virtual std::shared_ptr<PlatformIPCPackage> get_ipc_package() = 0; |
499 | + |
500 | + virtual EGLNativeDisplayType shell_egl_display() = 0; |
501 | }; |
502 | |
503 | // Create and return a new graphics platform. |
504 | |
505 | === modified file 'include/server/mir/shell/focus_sequence.h' |
506 | --- include/server/mir/shell/focus_sequence.h 2013-03-21 03:32:59 +0000 |
507 | +++ include/server/mir/shell/focus_sequence.h 2013-04-10 16:59:23 +0000 |
508 | @@ -42,8 +42,8 @@ |
509 | |
510 | protected: |
511 | FocusSequence() = default; |
512 | - FocusSequence(const FocusSequence&) = delete; |
513 | - FocusSequence& operator=(const FocusSequence&) = delete; |
514 | + FocusSequence(FocusSequence const&) = delete; |
515 | + FocusSequence& operator=(FocusSequence const&) = delete; |
516 | }; |
517 | |
518 | } |
519 | |
520 | === renamed file 'src/server/shell/surface.h' => 'include/server/mir/shell/surface.h' |
521 | === modified file 'include/shared/mir_toolkit/mesa/native_display.h' |
522 | --- include/shared/mir_toolkit/mesa/native_display.h 2013-03-29 11:39:30 +0000 |
523 | +++ include/shared/mir_toolkit/mesa/native_display.h 2013-04-10 16:59:23 +0000 |
524 | @@ -44,9 +44,11 @@ |
525 | void (*surface_advance_buffer)(MirMesaEGLNativeDisplay* display, |
526 | MirEGLNativeWindowType surface); |
527 | |
528 | - MirConnection* context; |
529 | + void *context; |
530 | }; |
531 | |
532 | +int mir_egl_mesa_display_is_valid(MirMesaEGLNativeDisplay* display); |
533 | + |
534 | #ifdef __cplusplus |
535 | } // extern "C" |
536 | /**@}*/ |
537 | |
538 | === modified file 'include/test/mir_test_doubles/mock_surface.h' |
539 | --- include/test/mir_test_doubles/mock_surface.h 2013-03-29 16:51:35 +0000 |
540 | +++ include/test/mir_test_doubles/mock_surface.h 2013-04-10 16:59:23 +0000 |
541 | @@ -19,7 +19,7 @@ |
542 | #ifndef MIR_TEST_DOUBLES_MOCK_SURFACE_H_ |
543 | #define MIR_TEST_DOUBLES_MOCK_SURFACE_H_ |
544 | |
545 | -#include "src/server/shell/surface.h" |
546 | +#include "mir/shell/surface.h" |
547 | |
548 | #include "mir/frontend/surface_creation_parameters.h" |
549 | |
550 | |
551 | === modified file 'include/test/mir_test_framework/testing_server_configuration.h' |
552 | --- include/test/mir_test_framework/testing_server_configuration.h 2013-03-25 10:18:17 +0000 |
553 | +++ include/test/mir_test_framework/testing_server_configuration.h 2013-04-10 16:59:23 +0000 |
554 | @@ -37,7 +37,7 @@ |
555 | TestingServerConfiguration(); |
556 | |
557 | // Code to run in server process |
558 | - virtual void exec(DisplayServer* display_server); |
559 | + virtual void exec(); |
560 | |
561 | // Code to run in server process after server exits |
562 | virtual void on_exit(); |
563 | |
564 | === modified file 'src/client/gbm/mesa_native_display_container.cpp' |
565 | --- src/client/gbm/mesa_native_display_container.cpp 2013-04-02 09:23:02 +0000 |
566 | +++ src/client/gbm/mesa_native_display_container.cpp 2013-04-10 16:59:23 +0000 |
567 | @@ -35,7 +35,9 @@ |
568 | static void gbm_egl_display_get_platform(MirMesaEGLNativeDisplay* display, |
569 | MirPlatformPackage* package) |
570 | { |
571 | - mir_connection_get_platform(display->context, package); |
572 | + auto connection = static_cast<MirConnection*>(display->context); |
573 | + |
574 | + mir_connection_get_platform(connection, package); |
575 | } |
576 | |
577 | static void gbm_egl_surface_get_current_buffer(MirMesaEGLNativeDisplay* /* display */, |
578 | @@ -66,6 +68,11 @@ |
579 | mir_surface_get_parameters(ms, surface_parameters); |
580 | } |
581 | |
582 | +int mir_egl_mesa_display_is_valid(MirMesaEGLNativeDisplay* display) |
583 | +{ |
584 | + return mcl::EGLNativeDisplayContainer::instance().validate(display); |
585 | +} |
586 | + |
587 | } |
588 | } |
589 | |
590 | |
591 | === modified file 'src/client/mir_client_library.cpp' |
592 | --- src/client/mir_client_library.cpp 2013-04-08 05:31:01 +0000 |
593 | +++ src/client/mir_client_library.cpp 2013-04-10 16:59:23 +0000 |
594 | @@ -108,11 +108,6 @@ |
595 | return connection->egl_native_display(); |
596 | } |
597 | |
598 | -int mir_egl_native_display_is_valid(MirEGLNativeDisplayType egl_display) |
599 | -{ |
600 | - return mcl::EGLNativeDisplayContainer::instance().validate(egl_display); |
601 | -} |
602 | - |
603 | MirWaitHandle* mir_surface_create( |
604 | MirConnection* connection, |
605 | MirSurfaceParameters const* params, |
606 | |
607 | === modified file 'src/server/display_server.cpp' |
608 | --- src/server/display_server.cpp 2013-04-08 16:20:33 +0000 |
609 | +++ src/server/display_server.cpp 2013-04-10 16:59:23 +0000 |
610 | @@ -30,6 +30,7 @@ |
611 | |
612 | namespace mc = mir::compositor; |
613 | namespace mf = mir::frontend; |
614 | +namespace msh = mir::shell; |
615 | namespace mg = mir::graphics; |
616 | namespace mi = mir::input; |
617 | |
618 | |
619 | === modified file 'src/server/graphics/CMakeLists.txt' |
620 | --- src/server/graphics/CMakeLists.txt 2013-03-21 03:32:59 +0000 |
621 | +++ src/server/graphics/CMakeLists.txt 2013-04-10 16:59:23 +0000 |
622 | @@ -11,14 +11,24 @@ |
623 | add_subdirectory(gbm/) |
624 | endif() |
625 | |
626 | -add_library( |
627 | - mirgraphics STATIC |
628 | +set( |
629 | + GRAPHICS_SOURCES |
630 | |
631 | gl_renderer.cpp |
632 | display_configuration.cpp |
633 | null_display_report.cpp |
634 | ) |
635 | |
636 | +if (MIR_PLATFORM STREQUAL "gbm") |
637 | + add_subdirectory(egl/) |
638 | +endif() |
639 | + |
640 | +add_library( |
641 | + mirgraphics STATIC |
642 | + |
643 | + ${GRAPHICS_SOURCES} |
644 | +) |
645 | + |
646 | target_link_libraries( |
647 | mirgraphics |
648 | |
649 | |
650 | === modified file 'src/server/graphics/android/android_platform.cpp' |
651 | --- src/server/graphics/android/android_platform.cpp 2013-04-02 15:06:31 +0000 |
652 | +++ src/server/graphics/android/android_platform.cpp 2013-04-10 16:59:23 +0000 |
653 | @@ -48,6 +48,12 @@ |
654 | return std::make_shared<mg::PlatformIPCPackage>(); |
655 | } |
656 | |
657 | +EGLNativeDisplayType mga::AndroidPlatform::shell_egl_display() |
658 | +{ |
659 | + // TODO: Implement |
660 | + return static_cast<EGLNativeDisplayType>(0); |
661 | +} |
662 | + |
663 | std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<DisplayReport> const& /*TODO*/) |
664 | { |
665 | return std::make_shared<mga::AndroidPlatform>(); |
666 | |
667 | === modified file 'src/server/graphics/android/android_platform.h' |
668 | --- src/server/graphics/android/android_platform.h 2013-03-22 17:08:01 +0000 |
669 | +++ src/server/graphics/android/android_platform.h 2013-04-10 16:59:23 +0000 |
670 | @@ -36,6 +36,8 @@ |
671 | const std::shared_ptr<BufferInitializer>& buffer_initializer); |
672 | std::shared_ptr<Display> create_display(); |
673 | std::shared_ptr<PlatformIPCPackage> get_ipc_package(); |
674 | + |
675 | + EGLNativeDisplayType shell_egl_display(); |
676 | }; |
677 | |
678 | } |
679 | |
680 | === added directory 'src/server/graphics/egl' |
681 | === added file 'src/server/graphics/egl/CMakeLists.txt' |
682 | --- src/server/graphics/egl/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
683 | +++ src/server/graphics/egl/CMakeLists.txt 2013-04-10 16:59:23 +0000 |
684 | @@ -0,0 +1,10 @@ |
685 | +list( |
686 | + APPEND GRAPHICS_SOURCES |
687 | + ${CMAKE_CURRENT_SOURCE_DIR}/mesa_native_display.cpp |
688 | +) |
689 | + |
690 | +set( |
691 | + GRAPHICS_SOURCES |
692 | + ${GRAPHICS_SOURCES} |
693 | + PARENT_SCOPE |
694 | +) |
695 | \ No newline at end of file |
696 | |
697 | === added file 'src/server/graphics/egl/mesa_native_display.cpp' |
698 | --- src/server/graphics/egl/mesa_native_display.cpp 1970-01-01 00:00:00 +0000 |
699 | +++ src/server/graphics/egl/mesa_native_display.cpp 2013-04-10 16:59:23 +0000 |
700 | @@ -0,0 +1,148 @@ |
701 | +/* |
702 | + * Copyright © 2013 Canonical Ltd. |
703 | + * |
704 | + * This program is free software: you can redistribute it and/or modify it |
705 | + * under the terms of the GNU Lesser General Public License version 3, |
706 | + * as published by the Free Software Foundation. |
707 | + * |
708 | + * This program is distributed in the hope that it will be useful, |
709 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
710 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
711 | + * GNU General Public License for more details. |
712 | + * |
713 | + * You should have received a copy of the GNU Lesser General Public License |
714 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
715 | + * |
716 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
717 | + */ |
718 | + |
719 | +#include "mir/display_server.h" |
720 | +#include "mir/graphics/egl/mesa_native_display.h" |
721 | +#include "mir/graphics/platform_ipc_package.h" |
722 | +#include "mir/graphics/platform.h" |
723 | +#include "mir/frontend/surface.h" |
724 | +#include "mir/compositor/buffer.h" |
725 | +#include "mir/compositor/buffer_ipc_package.h" |
726 | + |
727 | +#include "mir_toolkit/mesa/native_display.h" |
728 | +#include "mir_toolkit/c_types.h" |
729 | + |
730 | +#include <mutex> |
731 | +#include <set> |
732 | + |
733 | +namespace mg = mir::graphics; |
734 | +namespace mgeglm = mg::egl::mesa; |
735 | +namespace mf = mir::frontend; |
736 | + |
737 | +std::mutex valid_displays_guard; |
738 | +std::set<MirMesaEGLNativeDisplay*> valid_displays; |
739 | + |
740 | +namespace |
741 | +{ |
742 | +struct ShellMesaEGLNativeDisplay : MirMesaEGLNativeDisplay |
743 | +{ |
744 | +public: |
745 | + ShellMesaEGLNativeDisplay(std::shared_ptr<mg::Platform> const& graphics_platform) |
746 | + : graphics_platform(graphics_platform) |
747 | + { |
748 | + context = this; |
749 | + this->display_get_platform = &ShellMesaEGLNativeDisplay::native_display_get_platform; |
750 | + this->surface_get_current_buffer = &ShellMesaEGLNativeDisplay::native_display_surface_get_current_buffer; |
751 | + this->surface_get_parameters = &ShellMesaEGLNativeDisplay::native_display_surface_get_parameters; |
752 | + this->surface_advance_buffer = &ShellMesaEGLNativeDisplay::native_display_surface_advance_buffer; |
753 | + } |
754 | + |
755 | + static void native_display_get_platform(MirMesaEGLNativeDisplay* display, MirPlatformPackage* package) |
756 | + { |
757 | + auto native_disp = static_cast<ShellMesaEGLNativeDisplay*>(display); |
758 | + if (!native_disp->platform_package) |
759 | + native_disp->platform_package = native_disp->graphics_platform->get_ipc_package(); |
760 | + package->data_items = native_disp->platform_package->ipc_data.size(); |
761 | + for (int i = 0; i < package->data_items; i++) |
762 | + { |
763 | + package->data[i] = native_disp->platform_package->ipc_data[i]; |
764 | + } |
765 | + package->fd_items = native_disp->platform_package->ipc_fds.size(); |
766 | + for (int i = 0; i < package->fd_items; i++) |
767 | + { |
768 | + package->fd[i] = native_disp->platform_package->ipc_fds[i]; |
769 | + } |
770 | + |
771 | + } |
772 | + |
773 | + static void native_display_surface_get_current_buffer(MirMesaEGLNativeDisplay* /* display */, |
774 | + MirEGLNativeWindowType surface, |
775 | + MirBufferPackage* package) |
776 | + { |
777 | + auto mir_surface = static_cast<mf::Surface*>(surface); |
778 | + |
779 | + auto buffer = mir_surface->client_buffer(); |
780 | + auto buffer_package = buffer->get_ipc_package(); |
781 | + package->data_items = buffer_package->ipc_data.size(); |
782 | + for (int i = 0; i < package->data_items; i++) |
783 | + { |
784 | + package->data[i] = buffer_package->ipc_data[i]; |
785 | + } |
786 | + package->fd_items = buffer_package->ipc_fds.size(); |
787 | + for (int i = 0; i < package->fd_items; i++) |
788 | + { |
789 | + package->fd[i] = buffer_package->ipc_fds[i]; |
790 | + } |
791 | + package->stride = buffer_package->stride; |
792 | + } |
793 | + |
794 | + static void native_display_surface_get_parameters(MirMesaEGLNativeDisplay* /* display */, |
795 | + MirEGLNativeWindowType surface, |
796 | + MirSurfaceParameters* parameters) |
797 | + { |
798 | + auto mir_surface = static_cast<mf::Surface*>(surface); |
799 | + |
800 | + parameters->width = mir_surface->size().width.as_uint32_t(); |
801 | + parameters->height = mir_surface->size().height.as_uint32_t(); |
802 | + parameters->pixel_format = static_cast<MirPixelFormat>(mir_surface->pixel_format()); |
803 | + parameters->buffer_usage = mir_buffer_usage_hardware; |
804 | + } |
805 | + |
806 | + static void native_display_surface_advance_buffer(MirMesaEGLNativeDisplay* /* display */, |
807 | + MirEGLNativeWindowType surface) |
808 | + { |
809 | + auto mir_surface = static_cast<mf::Surface*>(surface); |
810 | + mir_surface->advance_client_buffer(); |
811 | + } |
812 | + |
813 | +private: |
814 | + std::shared_ptr<mg::Platform> graphics_platform; |
815 | + std::shared_ptr<mg::PlatformIPCPackage> platform_package; |
816 | +}; |
817 | + |
818 | +struct NativeDisplayDeleter |
819 | +{ |
820 | + void operator()(MirMesaEGLNativeDisplay* display) |
821 | + { |
822 | + std::unique_lock<std::mutex> lg(valid_displays_guard); |
823 | + valid_displays.erase(display); |
824 | + auto disp = static_cast<ShellMesaEGLNativeDisplay*>(display->context); |
825 | + delete disp; |
826 | + } |
827 | +}; |
828 | + |
829 | +} |
830 | + |
831 | +extern "C" |
832 | +{ |
833 | +int mir_egl_mesa_display_is_valid(MirMesaEGLNativeDisplay* display) |
834 | +{ |
835 | + std::unique_lock<std::mutex> lg(valid_displays_guard); |
836 | + return valid_displays.find(display) != valid_displays.end(); |
837 | +} |
838 | +} |
839 | + |
840 | +std::shared_ptr<MirMesaEGLNativeDisplay> mgeglm::create_native_display(std::shared_ptr<mg::Platform> const& platform) |
841 | +{ |
842 | + auto native_display = std::shared_ptr<ShellMesaEGLNativeDisplay>(new ShellMesaEGLNativeDisplay(platform), |
843 | + NativeDisplayDeleter()); |
844 | + std::unique_lock<std::mutex> lg(valid_displays_guard); |
845 | + valid_displays.insert(native_display.get()); |
846 | + |
847 | + return native_display; |
848 | +} |
849 | |
850 | === modified file 'src/server/graphics/gbm/gbm_platform.cpp' |
851 | --- src/server/graphics/gbm/gbm_platform.cpp 2013-03-13 04:54:15 +0000 |
852 | +++ src/server/graphics/gbm/gbm_platform.cpp 2013-04-10 16:59:23 +0000 |
853 | @@ -22,6 +22,7 @@ |
854 | #include "gbm_buffer_allocator.h" |
855 | #include "gbm_display.h" |
856 | #include "mir/graphics/platform_ipc_package.h" |
857 | +#include "mir/graphics/egl/mesa_native_display.h" |
858 | #include "mir/logging/logger.h" |
859 | #include "mir/logging/dumb_console_logger.h" |
860 | |
861 | @@ -29,10 +30,11 @@ |
862 | |
863 | #include <stdexcept> |
864 | |
865 | -namespace mgg=mir::graphics::gbm; |
866 | -namespace mg=mir::graphics; |
867 | -namespace ml=mir::logging; |
868 | -namespace mc=mir::compositor; |
869 | +namespace mg = mir::graphics; |
870 | +namespace mgg = mg::gbm; |
871 | +namespace mgeglm = mg::egl::mesa; |
872 | +namespace ml = mir::logging; |
873 | +namespace mc = mir::compositor; |
874 | |
875 | namespace |
876 | { |
877 | @@ -53,7 +55,8 @@ |
878 | } |
879 | |
880 | mgg::GBMPlatform::GBMPlatform(std::shared_ptr<DisplayReport> const& listener) : |
881 | - listener(listener) |
882 | + listener(listener), |
883 | + native_display(0) |
884 | { |
885 | drm.setup(); |
886 | gbm.setup(drm); |
887 | @@ -83,6 +86,15 @@ |
888 | drm.auth_magic(magic); |
889 | } |
890 | |
891 | +EGLNativeDisplayType mgg::GBMPlatform::shell_egl_display() |
892 | +{ |
893 | + if (native_display) |
894 | + return reinterpret_cast<EGLNativeDisplayType>(native_display.get()); |
895 | + native_display = mgeglm::create_native_display(this->shared_from_this()); |
896 | + |
897 | + return reinterpret_cast<EGLNativeDisplayType>(native_display.get()); |
898 | +} |
899 | + |
900 | std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<DisplayReport> const& report) |
901 | { |
902 | return std::make_shared<mgg::GBMPlatform>(report); |
903 | |
904 | === modified file 'src/server/graphics/gbm/gbm_platform.h' |
905 | --- src/server/graphics/gbm/gbm_platform.h 2013-03-13 04:54:15 +0000 |
906 | +++ src/server/graphics/gbm/gbm_platform.h 2013-04-10 16:59:23 +0000 |
907 | @@ -23,6 +23,8 @@ |
908 | #include "mir/graphics/drm_authenticator.h" |
909 | #include "gbm_display_helpers.h" |
910 | |
911 | +#include "mir_toolkit/mesa/native_display.h" |
912 | + |
913 | namespace mir |
914 | { |
915 | namespace graphics |
916 | @@ -42,6 +44,8 @@ |
917 | const std::shared_ptr<BufferInitializer>& buffer_initializer); |
918 | std::shared_ptr<Display> create_display(); |
919 | std::shared_ptr<PlatformIPCPackage> get_ipc_package(); |
920 | + |
921 | + EGLNativeDisplayType shell_egl_display(); |
922 | |
923 | /* From DRMAuthenticator */ |
924 | void drm_auth_magic(drm_magic_t magic); |
925 | @@ -50,6 +54,8 @@ |
926 | helpers::GBMHelper gbm; |
927 | |
928 | std::shared_ptr<DisplayReport> listener; |
929 | +private: |
930 | + std::shared_ptr<MirMesaEGLNativeDisplay> native_display; |
931 | }; |
932 | |
933 | } |
934 | |
935 | === modified file 'src/server/shell/application_session.cpp' |
936 | --- src/server/shell/application_session.cpp 2013-03-22 16:41:59 +0000 |
937 | +++ src/server/shell/application_session.cpp 2013-04-10 16:59:23 +0000 |
938 | @@ -17,7 +17,7 @@ |
939 | */ |
940 | |
941 | #include "mir/shell/application_session.h" |
942 | -#include "surface.h" |
943 | +#include "mir/shell/surface.h" |
944 | |
945 | #include "mir/shell/surface_factory.h" |
946 | |
947 | |
948 | === modified file 'src/server/shell/single_visibility_focus_mechanism.cpp' |
949 | --- src/server/shell/single_visibility_focus_mechanism.cpp 2013-03-22 16:41:59 +0000 |
950 | +++ src/server/shell/single_visibility_focus_mechanism.cpp 2013-04-10 16:59:23 +0000 |
951 | @@ -22,7 +22,7 @@ |
952 | #include "mir/shell/input_focus_selector.h" |
953 | |
954 | #include "mir/shell/session.h" |
955 | -#include "surface.h" // TODO: Cleanup headers ~racarr |
956 | +#include "mir/shell/surface.h" |
957 | |
958 | namespace mf = mir::frontend; |
959 | namespace msh = mir::shell; |
960 | |
961 | === modified file 'src/server/shell/surface.cpp' |
962 | --- src/server/shell/surface.cpp 2013-03-22 16:41:59 +0000 |
963 | +++ src/server/shell/surface.cpp 2013-04-10 16:59:23 +0000 |
964 | @@ -16,8 +16,7 @@ |
965 | * Authored by: Alan Griffiths <alan@octopull.co.uk> |
966 | */ |
967 | |
968 | -#include "surface.h" |
969 | - |
970 | +#include "mir/shell/surface.h" |
971 | #include "mir/shell/surface_builder.h" |
972 | #include "mir/input/input_channel.h" |
973 | |
974 | |
975 | === modified file 'src/server/shell/surface_source.cpp' |
976 | --- src/server/shell/surface_source.cpp 2013-03-21 03:32:59 +0000 |
977 | +++ src/server/shell/surface_source.cpp 2013-04-10 16:59:23 +0000 |
978 | @@ -18,11 +18,10 @@ |
979 | |
980 | #include "mir/shell/surface_source.h" |
981 | #include "mir/shell/surface_builder.h" |
982 | +#include "mir/shell/surface.h" |
983 | #include "mir/frontend/surface.h" |
984 | #include "mir/input/input_channel_factory.h" |
985 | |
986 | -#include "surface.h" |
987 | - |
988 | #include <cassert> |
989 | |
990 | namespace ms = mir::surfaces; |
991 | |
992 | === modified file 'tests/acceptance-tests/test_client_input.cpp' |
993 | --- tests/acceptance-tests/test_client_input.cpp 2013-04-09 08:50:40 +0000 |
994 | +++ tests/acceptance-tests/test_client_input.cpp 2013-04-10 16:59:23 +0000 |
995 | @@ -85,7 +85,7 @@ |
996 | { |
997 | } |
998 | |
999 | - void exec(mir::DisplayServer* /* display_server */) override |
1000 | + void exec() override |
1001 | { |
1002 | input_injection_thread = std::thread([this]() -> void |
1003 | { |
1004 | |
1005 | === modified file 'tests/acceptance-tests/test_test_framework.cpp' |
1006 | --- tests/acceptance-tests/test_test_framework.cpp 2012-12-20 09:00:28 +0000 |
1007 | +++ tests/acceptance-tests/test_test_framework.cpp 2013-04-10 16:59:23 +0000 |
1008 | @@ -35,7 +35,7 @@ |
1009 | { |
1010 | struct Server : TestingServerConfiguration |
1011 | { |
1012 | - void exec(mir::DisplayServer* ) |
1013 | + void exec() |
1014 | { |
1015 | using namespace testing; |
1016 | FAIL() << "Proving a test can fail"; |
1017 | |
1018 | === modified file 'tests/behavior-tests/session_management_context.cpp' |
1019 | --- tests/behavior-tests/session_management_context.cpp 2013-03-29 16:51:35 +0000 |
1020 | +++ tests/behavior-tests/session_management_context.cpp 2013-04-10 16:59:23 +0000 |
1021 | @@ -30,7 +30,7 @@ |
1022 | #include "mir/graphics/display.h" |
1023 | #include "mir/default_server_configuration.h" |
1024 | |
1025 | -#include "src/server/shell/surface.h" |
1026 | +#include "mir/shell/surface.h" |
1027 | |
1028 | #include "mir_test_doubles/stub_surface_builder.h" |
1029 | #include "mir_test/fake_shared.h" |
1030 | |
1031 | === modified file 'tests/integration-tests/graphics/gbm/test_buffer_integration.cpp' |
1032 | --- tests/integration-tests/graphics/gbm/test_buffer_integration.cpp 2013-03-13 08:09:52 +0000 |
1033 | +++ tests/integration-tests/graphics/gbm/test_buffer_integration.cpp 2013-04-10 16:59:23 +0000 |
1034 | @@ -99,6 +99,11 @@ |
1035 | { |
1036 | return std::shared_ptr<mg::PlatformIPCPackage>(); |
1037 | } |
1038 | + |
1039 | + EGLNativeDisplayType shell_egl_display() |
1040 | + { |
1041 | + return static_cast<EGLNativeDisplayType>(0); |
1042 | + } |
1043 | }; |
1044 | |
1045 | class GBMBufferIntegration : public ::testing::Test |
1046 | |
1047 | === modified file 'tests/integration-tests/test_display_info.cpp' |
1048 | --- tests/integration-tests/test_display_info.cpp 2013-03-22 10:34:16 +0000 |
1049 | +++ tests/integration-tests/test_display_info.cpp 2013-04-10 16:59:23 +0000 |
1050 | @@ -103,7 +103,10 @@ |
1051 | { |
1052 | return std::make_shared<mg::PlatformIPCPackage>(); |
1053 | } |
1054 | - |
1055 | + EGLNativeDisplayType shell_egl_display() |
1056 | + { |
1057 | + return static_cast<EGLNativeDisplayType>(0); |
1058 | + } |
1059 | }; |
1060 | |
1061 | void connection_callback(MirConnection* connection, void* context) |
1062 | |
1063 | === modified file 'tests/integration-tests/test_drm_auth_magic.cpp' |
1064 | --- tests/integration-tests/test_drm_auth_magic.cpp 2013-03-22 10:34:16 +0000 |
1065 | +++ tests/integration-tests/test_drm_auth_magic.cpp 2013-04-10 16:59:23 +0000 |
1066 | @@ -80,6 +80,11 @@ |
1067 | return std::make_shared<mg::PlatformIPCPackage>(); |
1068 | } |
1069 | |
1070 | + EGLNativeDisplayType shell_egl_display() |
1071 | + { |
1072 | + return static_cast<EGLNativeDisplayType>(0); |
1073 | + } |
1074 | + |
1075 | MOCK_METHOD1(drm_auth_magic, void(unsigned int)); |
1076 | }; |
1077 | |
1078 | |
1079 | === modified file 'tests/integration-tests/test_surfaceloop.cpp' |
1080 | --- tests/integration-tests/test_surfaceloop.cpp 2013-04-08 04:03:40 +0000 |
1081 | +++ tests/integration-tests/test_surfaceloop.cpp 2013-04-10 16:59:23 +0000 |
1082 | @@ -346,6 +346,11 @@ |
1083 | { |
1084 | return std::make_shared<mg::PlatformIPCPackage>(); |
1085 | } |
1086 | + |
1087 | + EGLNativeDisplayType shell_egl_display() |
1088 | + { |
1089 | + return static_cast<EGLNativeDisplayType>(0); |
1090 | + } |
1091 | }; |
1092 | |
1093 | std::shared_ptr<mg::Platform> the_graphics_platform() |
1094 | @@ -473,6 +478,11 @@ |
1095 | { |
1096 | return std::make_shared<mg::PlatformIPCPackage>(); |
1097 | } |
1098 | + |
1099 | + EGLNativeDisplayType shell_egl_display() |
1100 | + { |
1101 | + return (EGLNativeDisplayType) 0; |
1102 | + } |
1103 | }; |
1104 | |
1105 | std::shared_ptr<mg::Platform> the_graphics_platform() |
1106 | |
1107 | === modified file 'tests/mir_test_framework/testing_process_manager.cpp' |
1108 | --- tests/mir_test_framework/testing_process_manager.cpp 2013-03-28 12:38:23 +0000 |
1109 | +++ tests/mir_test_framework/testing_process_manager.cpp 2013-04-10 16:59:23 +0000 |
1110 | @@ -64,7 +64,7 @@ |
1111 | // We're in the server process, so create a display server |
1112 | SCOPED_TRACE("Server"); |
1113 | |
1114 | - mir::run_mir(config, [&](mir::DisplayServer& server) { config.exec(&server); }); |
1115 | + mir::run_mir(config, [&](mir::DisplayServer&) { config.exec(); }); |
1116 | |
1117 | config.on_exit(); |
1118 | } |
1119 | |
1120 | === modified file 'tests/mir_test_framework/testing_server_options.cpp' |
1121 | --- tests/mir_test_framework/testing_server_options.cpp 2013-03-29 16:51:35 +0000 |
1122 | +++ tests/mir_test_framework/testing_server_options.cpp 2013-04-10 16:59:23 +0000 |
1123 | @@ -105,6 +105,11 @@ |
1124 | { |
1125 | return std::make_shared<mg::PlatformIPCPackage>(); |
1126 | } |
1127 | + |
1128 | + EGLNativeDisplayType shell_egl_display() |
1129 | + { |
1130 | + return (EGLNativeDisplayType) 0; |
1131 | + } |
1132 | }; |
1133 | |
1134 | class StubRenderer : public mg::Renderer |
1135 | @@ -186,7 +191,7 @@ |
1136 | }); |
1137 | } |
1138 | |
1139 | -void mtf::TestingServerConfiguration::exec(DisplayServer* ) |
1140 | +void mtf::TestingServerConfiguration::exec() |
1141 | { |
1142 | } |
1143 | |
1144 | |
1145 | === modified file 'tests/unit-tests/client/gbm/test_gbm_client_platform.cpp' |
1146 | --- tests/unit-tests/client/gbm/test_gbm_client_platform.cpp 2013-03-01 18:50:18 +0000 |
1147 | +++ tests/unit-tests/client/gbm/test_gbm_client_platform.cpp 2013-04-10 16:59:23 +0000 |
1148 | @@ -21,6 +21,8 @@ |
1149 | #include "mir_test_doubles/mock_client_context.h" |
1150 | #include "mir_test_doubles/mock_client_surface.h" |
1151 | |
1152 | +#include "mir_toolkit/mesa/native_display.h" |
1153 | + |
1154 | #include <gtest/gtest.h> |
1155 | |
1156 | namespace mcl = mir::client; |
1157 | @@ -44,12 +46,12 @@ |
1158 | mcl::NativeClientPlatformFactory factory; |
1159 | auto platform = factory.create_client_platform(&context); |
1160 | |
1161 | - EGLNativeDisplayType nd; |
1162 | + MirMesaEGLNativeDisplay* nd; |
1163 | { |
1164 | std::shared_ptr<EGLNativeDisplayType> native_display = platform->create_egl_native_display(); |
1165 | |
1166 | - nd = *native_display; |
1167 | - EXPECT_TRUE(mir_egl_native_display_is_valid(nd)); |
1168 | + nd = reinterpret_cast<MirMesaEGLNativeDisplay*>(*native_display); |
1169 | + EXPECT_TRUE(mir_egl_mesa_display_is_valid(nd)); |
1170 | } |
1171 | - EXPECT_FALSE(mir_egl_native_display_is_valid(nd)); |
1172 | + EXPECT_FALSE(mir_egl_mesa_display_is_valid(nd)); |
1173 | } |
1174 | |
1175 | === modified file 'tests/unit-tests/frontend/test_session_mediator.cpp' |
1176 | --- tests/unit-tests/frontend/test_session_mediator.cpp 2013-03-29 16:51:35 +0000 |
1177 | +++ tests/unit-tests/frontend/test_session_mediator.cpp 2013-04-10 16:59:23 +0000 |
1178 | @@ -35,7 +35,7 @@ |
1179 | #include "mir_test_doubles/stub_surface_builder.h" |
1180 | #include "mir_test/fake_shared.h" |
1181 | |
1182 | -#include "src/server/shell/surface.h" |
1183 | +#include "mir/shell/surface.h" |
1184 | |
1185 | #include <gtest/gtest.h> |
1186 | #include <gmock/gmock.h> |
1187 | @@ -121,6 +121,11 @@ |
1188 | { |
1189 | return std::make_shared<mg::PlatformIPCPackage>(); |
1190 | } |
1191 | + |
1192 | + EGLNativeDisplayType shell_egl_display() |
1193 | + { |
1194 | + return static_cast<EGLNativeDisplayType>(0); |
1195 | + } |
1196 | }; |
1197 | |
1198 | } |
1199 | |
1200 | === modified file 'tests/unit-tests/frontend/test_session_mediator_android.cpp' |
1201 | --- tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-03-21 03:32:59 +0000 |
1202 | +++ tests/unit-tests/frontend/test_session_mediator_android.cpp 2013-04-10 16:59:23 +0000 |
1203 | @@ -78,6 +78,11 @@ |
1204 | { |
1205 | return std::make_shared<mg::PlatformIPCPackage>(); |
1206 | } |
1207 | + |
1208 | + EGLNativeDisplayType shell_egl_display() |
1209 | + { |
1210 | + return static_cast<EGLNativeDisplayType>(0); |
1211 | + } |
1212 | }; |
1213 | |
1214 | } |
1215 | |
1216 | === modified file 'tests/unit-tests/frontend/test_session_mediator_gbm.cpp' |
1217 | --- tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-03-21 03:32:59 +0000 |
1218 | +++ tests/unit-tests/frontend/test_session_mediator_gbm.cpp 2013-04-10 16:59:23 +0000 |
1219 | @@ -82,6 +82,11 @@ |
1220 | return std::make_shared<mg::PlatformIPCPackage>(); |
1221 | } |
1222 | |
1223 | + EGLNativeDisplayType shell_egl_display() |
1224 | + { |
1225 | + return static_cast<EGLNativeDisplayType>(0); |
1226 | + } |
1227 | + |
1228 | MOCK_METHOD1(drm_auth_magic, void(drm_magic_t)); |
1229 | }; |
1230 | |
1231 | |
1232 | === modified file 'tests/unit-tests/graphics/CMakeLists.txt' |
1233 | --- tests/unit-tests/graphics/CMakeLists.txt 2013-03-13 04:54:15 +0000 |
1234 | +++ tests/unit-tests/graphics/CMakeLists.txt 2013-04-10 16:59:23 +0000 |
1235 | @@ -11,7 +11,7 @@ |
1236 | |
1237 | if (MIR_PLATFORM STREQUAL "gbm") |
1238 | add_subdirectory(gbm/) |
1239 | +add_subdirectory(egl) |
1240 | endif() |
1241 | |
1242 | set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE) |
1243 | - |
1244 | |
1245 | === added directory 'tests/unit-tests/graphics/egl' |
1246 | === added file 'tests/unit-tests/graphics/egl/CMakeLists.txt' |
1247 | --- tests/unit-tests/graphics/egl/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1248 | +++ tests/unit-tests/graphics/egl/CMakeLists.txt 2013-04-10 16:59:23 +0000 |
1249 | @@ -0,0 +1,6 @@ |
1250 | +list(APPEND UNIT_TEST_SOURCES |
1251 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_mirserver_mesa_egl_native_display.cpp |
1252 | +) |
1253 | + |
1254 | +set(UNIT_TEST_SOURCES ${UNIT_TEST_SOURCES} PARENT_SCOPE) |
1255 | + |
1256 | |
1257 | === added file 'tests/unit-tests/graphics/egl/test_mirserver_mesa_egl_native_display.cpp' |
1258 | --- tests/unit-tests/graphics/egl/test_mirserver_mesa_egl_native_display.cpp 1970-01-01 00:00:00 +0000 |
1259 | +++ tests/unit-tests/graphics/egl/test_mirserver_mesa_egl_native_display.cpp 2013-04-10 16:59:23 +0000 |
1260 | @@ -0,0 +1,207 @@ |
1261 | +/* |
1262 | + * Copyright © 2013 Canonical Ltd. |
1263 | + * |
1264 | + * This program is free software: you can redistribute it and/or modify |
1265 | + * it under the terms of the GNU General Public License version 3 as |
1266 | + * published by the Free Software Foundation. |
1267 | + * |
1268 | + * This program is distributed in the hope that it will be useful, |
1269 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1270 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1271 | + * GNU General Public License for more details. |
1272 | + * |
1273 | + * You should have received a copy of the GNU General Public License |
1274 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1275 | + * |
1276 | + * Authored by: Robert Carr <robert.carr@canonical.com> |
1277 | + */ |
1278 | +#include "mir/graphics/egl/mesa_native_display.h" |
1279 | +#include "mir/graphics/platform.h" |
1280 | +#include "mir/graphics/platform_ipc_package.h" |
1281 | +#include "mir/compositor/buffer_ipc_package.h" |
1282 | + |
1283 | +#include "mir_toolkit/c_types.h" |
1284 | +#include "mir_toolkit/mesa/native_display.h" |
1285 | + |
1286 | +#include "mir_test/fake_shared.h" |
1287 | +#include "mir_test_doubles/stub_surface_builder.h" |
1288 | +#include "mir_test_doubles/mock_surface.h" |
1289 | +#include "mir_test_doubles/mock_buffer.h" |
1290 | + |
1291 | +#include <gtest/gtest.h> |
1292 | +#include <gmock/gmock.h> |
1293 | + |
1294 | +namespace mg = mir::graphics; |
1295 | +namespace mgeglm = mg::egl::mesa; |
1296 | +namespace mc = mir::compositor; |
1297 | +namespace msh = mir::shell; |
1298 | +namespace geom = mir::geometry; |
1299 | +namespace mt = mir::test; |
1300 | +namespace mtd = mt::doubles; |
1301 | + |
1302 | +namespace |
1303 | +{ |
1304 | + |
1305 | +struct MockGraphicsPlatform : public mg::Platform |
1306 | +{ |
1307 | + MOCK_METHOD1(create_buffer_allocator, std::shared_ptr<mc::GraphicBufferAllocator>(std::shared_ptr<mg::BufferInitializer> const&)); |
1308 | + MOCK_METHOD0(create_display, std::shared_ptr<mg::Display>()); |
1309 | + MOCK_METHOD0(get_ipc_package, std::shared_ptr<mg::PlatformIPCPackage>()); |
1310 | + MOCK_METHOD0(shell_egl_display, EGLNativeDisplayType()); |
1311 | +}; |
1312 | + |
1313 | +struct MirServerMesaEGLNativeDisplaySetup : public testing::Test |
1314 | +{ |
1315 | + MirServerMesaEGLNativeDisplaySetup() |
1316 | + { |
1317 | + using namespace ::testing; |
1318 | + |
1319 | + test_platform_package.ipc_data = {1, 2}; |
1320 | + test_platform_package.ipc_fds = {2, 3}; |
1321 | + |
1322 | + ON_CALL(mock_graphics_platform, get_ipc_package()) |
1323 | + .WillByDefault(Return(mt::fake_shared(test_platform_package))); |
1324 | + } |
1325 | + |
1326 | + // Test dependencies |
1327 | + MockGraphicsPlatform mock_graphics_platform; |
1328 | + |
1329 | + // Useful stub data |
1330 | + mg::PlatformIPCPackage test_platform_package; |
1331 | +}; |
1332 | + |
1333 | +MATCHER_P(PackageMatches, package, "") |
1334 | +{ |
1335 | + if (arg.data_items != static_cast<int>(package.ipc_data.size())) |
1336 | + return false; |
1337 | + for (uint i = 0; i < package.ipc_data.size(); i++) |
1338 | + { |
1339 | + if (arg.data[i] != package.ipc_data[i]) return false; |
1340 | + } |
1341 | + if (arg.fd_items != static_cast<int>(package.ipc_fds.size())) |
1342 | + return false; |
1343 | + for (uint i = 0; i < package.ipc_fds.size(); i++) |
1344 | + { |
1345 | + if (arg.fd[i] != package.ipc_fds[i]) return false; |
1346 | + } |
1347 | + return true; |
1348 | +} |
1349 | + |
1350 | +MATCHER_P(StrideMatches, package, "") |
1351 | +{ |
1352 | + if (arg.stride != package.stride) |
1353 | + { |
1354 | + return false; |
1355 | + } |
1356 | + return true; |
1357 | +} |
1358 | + |
1359 | +MATCHER_P(ParametersHaveSize, size, "") |
1360 | +{ |
1361 | + if (static_cast<uint32_t>(arg.width) != size.width.as_uint32_t()) |
1362 | + return false; |
1363 | + if (static_cast<uint32_t>(arg.height) != size.height.as_uint32_t()) |
1364 | + return false; |
1365 | + return true; |
1366 | +} |
1367 | + |
1368 | +} |
1369 | + |
1370 | +TEST_F(MirServerMesaEGLNativeDisplaySetup, display_get_platform_is_cached_platform_package) |
1371 | +{ |
1372 | + using namespace ::testing; |
1373 | + |
1374 | + EXPECT_CALL(mock_graphics_platform, get_ipc_package()).Times(1); |
1375 | + |
1376 | + auto display = mgeglm::create_native_display(mt::fake_shared(mock_graphics_platform)); |
1377 | + |
1378 | + MirPlatformPackage package; |
1379 | + memset(&package, 0, sizeof(MirPlatformPackage)); |
1380 | + display->display_get_platform(display.get(), &package); |
1381 | + EXPECT_THAT(package, PackageMatches(test_platform_package)); |
1382 | + |
1383 | + MirPlatformPackage requeried_package; |
1384 | + // The package is cached to allow the package creator to control lifespan of fd members |
1385 | + // and so this should not trigger another call to get_ipc_package() |
1386 | + display->display_get_platform(display.get(), &requeried_package); |
1387 | + |
1388 | + EXPECT_FALSE(memcmp(&requeried_package.data, &package.data, sizeof(package.data[0])*package.data_items)); |
1389 | + EXPECT_FALSE(memcmp(&requeried_package.fd, &package.fd, sizeof(package.fd[0])*package.fd_items)); |
1390 | +} |
1391 | + |
1392 | +TEST_F(MirServerMesaEGLNativeDisplaySetup, surface_get_current_buffer) |
1393 | +{ |
1394 | + using namespace ::testing; |
1395 | + |
1396 | + mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>()); |
1397 | + auto buffer = std::make_shared<mtd::MockBuffer>(geom::Size(), geom::Stride(), geom::PixelFormat()); |
1398 | + |
1399 | + mc::BufferIPCPackage test_buffer_package; |
1400 | + |
1401 | + test_buffer_package.ipc_data = {1, 2}; |
1402 | + test_buffer_package.ipc_fds = {2, 3}; |
1403 | + test_buffer_package.stride = 77; |
1404 | + |
1405 | + auto display = mgeglm::create_native_display(mt::fake_shared(mock_graphics_platform)); |
1406 | + |
1407 | + EXPECT_CALL(surface, client_buffer()).Times(1) |
1408 | + .WillOnce(Return(buffer)); |
1409 | + EXPECT_CALL(*buffer, get_ipc_package()).Times(1) |
1410 | + .WillOnce(Return(mt::fake_shared(test_buffer_package))); |
1411 | + |
1412 | + MirBufferPackage buffer_package; |
1413 | + memset(&buffer_package, 0, sizeof(MirBufferPackage)); |
1414 | + display->surface_get_current_buffer( |
1415 | + display.get(), static_cast<MirEGLNativeWindowType>(&surface), &buffer_package); |
1416 | + EXPECT_THAT(buffer_package, AllOf(PackageMatches(test_buffer_package), StrideMatches(test_buffer_package))); |
1417 | +} |
1418 | + |
1419 | +TEST_F(MirServerMesaEGLNativeDisplaySetup, surface_advance_buffer) |
1420 | +{ |
1421 | + using namespace ::testing; |
1422 | + |
1423 | + mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>()); |
1424 | + |
1425 | + auto display = mgeglm::create_native_display(mt::fake_shared(mock_graphics_platform)); |
1426 | + |
1427 | + EXPECT_CALL(surface, advance_client_buffer()).Times(1); |
1428 | + |
1429 | + display->surface_advance_buffer( |
1430 | + display.get(), static_cast<MirEGLNativeWindowType>(&surface)); |
1431 | +} |
1432 | + |
1433 | +TEST(MirServerMesaEGLNativeDisplayInvariants, pixel_format_formats_are_castable) |
1434 | +{ |
1435 | + EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::invalid), mir_pixel_format_invalid); |
1436 | + EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::abgr_8888), mir_pixel_format_abgr_8888); |
1437 | + EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::xbgr_8888), mir_pixel_format_xbgr_8888); |
1438 | + EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::argb_8888), mir_pixel_format_argb_8888); |
1439 | + EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::xrgb_8888), mir_pixel_format_xrgb_8888); |
1440 | + EXPECT_EQ(static_cast<MirPixelFormat>(geom::PixelFormat::bgr_888), mir_pixel_format_bgr_888); |
1441 | +} |
1442 | + |
1443 | +TEST_F(MirServerMesaEGLNativeDisplaySetup, surface_get_parameters) |
1444 | +{ |
1445 | + using namespace ::testing; |
1446 | + |
1447 | + geom::Size const test_surface_size = geom::Size{geom::Width{17}, |
1448 | + geom::Height{29}}; |
1449 | + geom::PixelFormat const test_pixel_format = geom::PixelFormat::xrgb_8888; |
1450 | + |
1451 | + auto display = mgeglm::create_native_display(mt::fake_shared(mock_graphics_platform)); |
1452 | + |
1453 | + mtd::MockSurface surface(std::make_shared<mtd::StubSurfaceBuilder>()); |
1454 | + EXPECT_CALL(surface, size()).Times(AtLeast(1)).WillRepeatedly(Return(test_surface_size)); |
1455 | + EXPECT_CALL(surface, pixel_format()).Times(AtLeast(1)).WillRepeatedly(Return(test_pixel_format)); |
1456 | + |
1457 | + MirSurfaceParameters parameters; |
1458 | + memset(¶meters, 0, sizeof(MirSurfaceParameters)); |
1459 | + display->surface_get_parameters( |
1460 | + display.get(), static_cast<MirEGLNativeWindowType>(&surface), ¶meters); |
1461 | + |
1462 | + EXPECT_THAT(parameters, ParametersHaveSize(test_surface_size)); |
1463 | + EXPECT_EQ(parameters.pixel_format, static_cast<MirPixelFormat>(geom::PixelFormat::xrgb_8888)); |
1464 | + |
1465 | + // TODO: What to do about buffer usage besides hardware? ~racarr |
1466 | + EXPECT_EQ(parameters.buffer_usage, mir_buffer_usage_hardware); |
1467 | +} |
1468 | |
1469 | === modified file 'tests/unit-tests/shell/test_application_session.cpp' |
1470 | --- tests/unit-tests/shell/test_application_session.cpp 2013-03-29 16:51:35 +0000 |
1471 | +++ tests/unit-tests/shell/test_application_session.cpp 2013-04-10 16:59:23 +0000 |
1472 | @@ -25,7 +25,7 @@ |
1473 | #include "mir_test_doubles/stub_surface_builder.h" |
1474 | #include "mir_test_doubles/stub_surface.h" |
1475 | |
1476 | -#include "src/server/shell/surface.h" |
1477 | +#include "mir/shell/surface.h" |
1478 | |
1479 | #include <gmock/gmock.h> |
1480 | #include <gtest/gtest.h> |
1481 | |
1482 | === modified file 'tests/unit-tests/shell/test_session_manager.cpp' |
1483 | --- tests/unit-tests/shell/test_session_manager.cpp 2013-03-29 16:51:35 +0000 |
1484 | +++ tests/unit-tests/shell/test_session_manager.cpp 2013-04-10 16:59:23 +0000 |
1485 | @@ -32,7 +32,7 @@ |
1486 | #include "mir_test_doubles/null_buffer_bundle.h" |
1487 | #include "mir_test_doubles/stub_surface_builder.h" |
1488 | |
1489 | -#include "src/server/shell/surface.h" |
1490 | +#include "mir/shell/surface.h" |
1491 | |
1492 | #include <gmock/gmock.h> |
1493 | #include <gtest/gtest.h> |
1494 | |
1495 | === modified file 'tests/unit-tests/shell/test_surface.cpp' |
1496 | --- tests/unit-tests/shell/test_surface.cpp 2013-03-29 17:03:04 +0000 |
1497 | +++ tests/unit-tests/shell/test_surface.cpp 2013-04-10 16:59:23 +0000 |
1498 | @@ -16,7 +16,7 @@ |
1499 | * Authored by: Alan Griffiths <alan@octopull.co.uk> |
1500 | */ |
1501 | |
1502 | -#include "src/server/shell/surface.h" |
1503 | +#include "mir/shell/surface.h" |
1504 | #include "mir/surfaces/surface.h" |
1505 | #include "mir/frontend/surface_creation_parameters.h" |
1506 | #include "mir/surfaces/surface_stack_model.h" |
Minor point: "ServerInstance" vs the old name "DisplayServer". "Instance" is a redundant word, more so than "Display" was :)