Mir

Merge lp:~alan-griffiths/mir/move-miral-to-mir-cleanup-playground into lp:mir

Proposed by Alan Griffiths on 2017-08-30
Status: Merged
Approved by: Alan Griffiths on 2017-09-05
Approved revision: 4242
Merged at revision: 4239
Proposed branch: lp:~alan-griffiths/mir/move-miral-to-mir-cleanup-playground
Merge into: lp:mir
Prerequisite: lp:~alan-griffiths/mir/move-miral-to-mir-cleanup
Diff against target: 3018 lines (+2/-2681)
38 files modified
debian/mir-demos.install (+0/-1)
include/server/mir/compositor/scene_element.h (+0/-4)
include/server/mir/scene/surface.h (+0/-1)
include/test/mir/test/doubles/stub_surface.h (+0/-1)
playground/CMakeLists.txt (+1/-22)
playground/demo-shell/CMakeLists.txt (+0/-19)
playground/demo-shell/demo_compositor.cpp (+0/-204)
playground/demo-shell/demo_compositor.h (+0/-79)
playground/demo-shell/demo_renderer.cpp (+0/-402)
playground/demo-shell/demo_renderer.h (+0/-90)
playground/demo-shell/demo_shell.cpp (+0/-120)
playground/demo-shell/typo/CMakeLists.txt (+0/-23)
playground/demo-shell/typo/typo_freetype_renderer.cpp (+0/-125)
playground/demo-shell/typo/typo_freetype_renderer.h (+0/-44)
playground/demo-shell/typo/typo_glcache.cpp (+0/-99)
playground/demo-shell/typo/typo_glcache.h (+0/-56)
playground/demo-shell/typo/typo_renderer.cpp (+0/-59)
playground/demo-shell/typo/typo_renderer.h (+0/-61)
playground/demo-shell/typo/typo_stub_renderer.cpp (+0/-47)
playground/demo-shell/typo/typo_stub_renderer.h (+0/-34)
playground/demo-shell/window_manager.cpp (+0/-611)
playground/demo-shell/window_manager.h (+0/-97)
playground/server_configuration.cpp (+0/-86)
playground/server_configuration.h (+0/-49)
playground/server_example_display_configuration_policy.cpp (+0/-115)
playground/server_example_display_configuration_policy.h (+0/-62)
src/include/server/mir/compositor/decoration.h (+0/-38)
src/server/scene/basic_surface.cpp (+0/-6)
src/server/scene/basic_surface.h (+1/-1)
src/server/scene/surface_stack.cpp (+0/-11)
tests/include/mir/test/doubles/stub_scene_element.h (+0/-6)
tests/include/mir/test/doubles/stub_scene_surface.h (+0/-1)
tests/mir_test_framework/stub_surface.cpp (+0/-5)
tests/unit-tests/CMakeLists.txt (+0/-2)
tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp (+0/-7)
tests/unit-tests/scene/test_basic_surface.cpp (+0/-14)
tests/unit-tests/scene/test_surface.cpp (+0/-21)
tests/unit-tests/scene/test_surface_stack.cpp (+0/-58)
To merge this branch: bzr merge lp:~alan-griffiths/mir/move-miral-to-mir-cleanup-playground
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve on 2017-09-05
Gerry Boland Approve on 2017-09-05
Chris Halse Rogers 2017-08-30 Approve on 2017-08-31
Review via email: mp+329944@code.launchpad.net

Commit message

Incorporate miral project into mir source tree

This is a third pass at removing code obsoleted by MirAL

To post a comment you must log in.
Alan Griffiths (alan-griffiths) wrote :

I can't figure why launchpad is showing conflict markers. It is wrong.

Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:4239
https://mir-jenkins.ubuntu.com/job/mir-ci/3609/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/4935/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/5160
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=artful/5150
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/5150
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/5150
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=artful/4974/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4974/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=artful/4974/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/4974/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4974/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=artful/4974/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4974/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/4974/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3609/rebuild

review: Needs Fixing (continuous-integration)
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:4240
https://mir-jenkins.ubuntu.com/job/mir-ci/3614/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/4941/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-0-fetch/5166/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=artful/5156/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/5156/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/5156/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=artful/4980/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4980/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=artful/4980/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/4980/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4980/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=artful/4980/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4980/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/4980/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3614/rebuild

review: Needs Fixing (continuous-integration)
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:4241
https://mir-jenkins.ubuntu.com/job/mir-ci/3619/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/4946/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/5171
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=artful/5161
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/5161
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/5161
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=artful/4985/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4985/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=artful/4985/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/4985/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4985/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=artful/4985/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4985/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/4985/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3619/rebuild

review: Needs Fixing (continuous-integration)
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:4242
https://mir-jenkins.ubuntu.com/job/mir-ci/3625/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/4953
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/5178
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=artful/5168
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/5168
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/5168
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=artful/4992
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=artful/4992/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4992
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4992/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=artful/4992
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=artful/4992/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/4992
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/4992/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4992
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4992/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=artful/4992
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=artful/4992/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4992
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4992/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/4992
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/4992/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3625/rebuild

review: Approve (continuous-integration)
Chris Halse Rogers (raof) wrote :

LGTM

review: Approve
Gerry Boland (gerboland) wrote :

lots of red, nice to see. I'm not going to miss anything removed here

review: Approve
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://mir-jenkins.ubuntu.com/job/mir-autolanding/1403/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/4960/console
    None: https://mir-jenkins.ubuntu.com/job/generic-land-mp/1533/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/5188
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=artful/5176
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/5176
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/5176
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=artful/4999/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4999
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4999/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=artful/4999/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/4999
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/4999/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4999
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4999/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=artful/4999/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4999
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4999/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/4999
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/4999/artifact/output/*zip*/output.zip

review: Needs Fixing (continuous-integration)
Alan Griffiths (alan-griffiths) wrote :

12:29:10 E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-7/libobjc4_7.2.0-1ubuntu2_amd64.deb 404 Not Found [IP: 91.189.92.201 80]

12:29:08 E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-7/libobjc4_7.2.0-1ubuntu2_amd64.deb 404 Not Found [IP: 91.189.92.201 80]

Bad timing? Re-approving.

Mir CI Bot (mir-ci-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://mir-jenkins.ubuntu.com/job/mir-autolanding/1405/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/4962/console
    None: https://mir-jenkins.ubuntu.com/job/generic-land-mp/1535/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/5190
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=artful/5178
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/5178
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/5178
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=artful/5001/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/5001
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/5001/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=artful/5001/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/5001
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/5001/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/5001
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/5001/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=artful/5001/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/5001
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/5001/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/5001
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/5001/artifact/output/*zip*/output.zip

review: Needs Fixing (continuous-integration)
Alan Griffiths (alan-griffiths) wrote :

>
> 12:29:10 E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-7
> /libobjc4_7.2.0-1ubuntu2_amd64.deb 404 Not Found [IP: 91.189.92.201 80]
>
> 12:29:08 E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-7
> /libobjc4_7.2.0-1ubuntu2_amd64.deb 404 Not Found [IP: 91.189.92.201 80]
>
> Bad timing? Re-approving.

Nope. Looks like the archive is in a weird state:

$ apt show libobjc4
Package: libobjc4
Version: 7.2.0-3ubuntu1
...

Alan Griffiths (alan-griffiths) wrote :

OK, fixed the maintain jobs that update the chroots.

Trying again

Mir CI Bot (mir-ci-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/mir-demos.install'
2--- debian/mir-demos.install 2015-06-17 05:20:42 +0000
3+++ debian/mir-demos.install 2017-08-31 11:31:49 +0000
4@@ -1,3 +1,2 @@
5 usr/bin/mir_demo_*
6-usr/bin/mir_proving_*
7 usr/lib/*/libmir_demo_*
8
9=== modified file 'include/server/mir/compositor/scene_element.h'
10--- include/server/mir/compositor/scene_element.h 2017-07-28 17:00:43 +0000
11+++ include/server/mir/compositor/scene_element.h 2017-08-31 11:31:49 +0000
12@@ -39,10 +39,6 @@
13 virtual void rendered() = 0;
14 virtual void occluded() = 0;
15
16- //TODO: Decoration is opaque on purpose. It is only used by an internal example,
17- // and this function should be removed from the public API.
18- virtual std::unique_ptr<Decoration> decoration() const = 0;
19-
20 protected:
21 SceneElement() = default;
22 SceneElement(SceneElement const&) = delete;
23
24=== modified file 'include/server/mir/scene/surface.h'
25--- include/server/mir/scene/surface.h 2017-07-28 17:00:43 +0000
26+++ include/server/mir/scene/surface.h 2017-08-31 11:31:49 +0000
27@@ -66,7 +66,6 @@
28 virtual graphics::RenderableList generate_renderables(compositor::CompositorID id) const = 0;
29 virtual int buffers_ready_for_compositor(void const* compositor_id) const = 0;
30
31- virtual float alpha() const = 0; //only used in examples/
32 virtual MirWindowType type() const = 0;
33 virtual MirWindowState state() const = 0;
34 virtual void hide() = 0;
35
36=== modified file 'include/test/mir/test/doubles/stub_surface.h'
37--- include/test/mir/test/doubles/stub_surface.h 2017-07-28 17:00:43 +0000
38+++ include/test/mir/test/doubles/stub_surface.h 2017-08-31 11:31:49 +0000
39@@ -32,7 +32,6 @@
40 {
41 std::string name() const override;
42 void move_to(geometry::Point const& top_left) override;
43- float alpha() const override;
44 geometry::Size size() const override;
45 geometry::Size client_size() const override;
46 std::shared_ptr<frontend::BufferStream> primary_buffer_stream() const override;
47
48=== modified file 'playground/CMakeLists.txt'
49--- playground/CMakeLists.txt 2017-08-31 11:31:48 +0000
50+++ playground/CMakeLists.txt 2017-08-31 11:31:49 +0000
51@@ -1,27 +1,6 @@
52-
53 include_directories(
54- ${PROJECT_SOURCE_DIR}/src/include/server
55- ${PROJECT_SOURCE_DIR}/src/include/platform
56- ${PROJECT_SOURCE_DIR}/src/include/common
57- ${PROJECT_SOURCE_DIR}/src/include/gl
58- ${PROJECT_SOURCE_DIR}/src/include/client
59- ${PROJECT_SOURCE_DIR}/src/renderers
60 ${PROJECT_SOURCE_DIR}/include/client
61- ${PROJECT_SOURCE_DIR}/include/server
62- ${PROJECT_SOURCE_DIR}/include/platform
63- ${PROJECT_SOURCE_DIR}/include/renderer
64- ${PROJECT_SOURCE_DIR}/include/renderers/gl
65- ${PROJECT_SOURCE_DIR}/examples/
66-)
67-
68-add_library(playgroundserverconfig STATIC
69- server_configuration.cpp
70- server_example_display_configuration_policy.cpp
71-)
72-
73-add_subdirectory(demo-shell/)
74-
75-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
76+)
77
78 mir_add_wrapped_executable(mir_demo_client_egldiamond_render_surface
79 egldiamond_render_surface.c
80
81=== removed directory 'playground/demo-shell'
82=== removed file 'playground/demo-shell/CMakeLists.txt'
83--- playground/demo-shell/CMakeLists.txt 2017-05-08 03:04:26 +0000
84+++ playground/demo-shell/CMakeLists.txt 1970-01-01 00:00:00 +0000
85@@ -1,19 +0,0 @@
86-add_library(demo-shell STATIC
87- demo_compositor.cpp
88- demo_renderer.cpp
89- window_manager.cpp
90-)
91-
92-add_subdirectory(typo)
93-target_link_libraries(demo-shell typo)
94-
95-mir_add_wrapped_executable(mir_proving_server
96- demo_shell.cpp
97-)
98-
99-target_link_libraries(mir_proving_server
100- demo-shell
101- mirserver
102- playgroundserverconfig
103- exampleserverconfig
104-)
105
106=== removed file 'playground/demo-shell/demo_compositor.cpp'
107--- playground/demo-shell/demo_compositor.cpp 2017-07-28 17:00:43 +0000
108+++ playground/demo-shell/demo_compositor.cpp 1970-01-01 00:00:00 +0000
109@@ -1,204 +0,0 @@
110-/*
111- * Copyright © 2014 Canonical Ltd.
112- *
113- * This program is free software: you can redistribute it and/or modify
114- * it under the terms of the GNU General Public License version 2 or 3 as
115- * published by the Free Software Foundation.
116- *
117- * This program is distributed in the hope that it will be useful,
118- * but WITHOUT ANY WARRANTY; without even the implied warranty of
119- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
120- * GNU General Public License for more details.
121- *
122- * You should have received a copy of the GNU General Public License
123- * along with this program. If not, see <http://www.gnu.org/licenses/>.
124- *
125- * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
126- */
127-
128-#include "mir/graphics/display_buffer.h"
129-#include "mir/compositor/compositor_report.h"
130-#include "mir/compositor/scene_element.h"
131-#include "demo_compositor.h"
132-
133-namespace me = mir::examples;
134-namespace mg = mir::graphics;
135-namespace mc = mir::compositor;
136-namespace geom = mir::geometry;
137-
138-std::mutex me::DemoCompositor::instances_mutex;
139-std::unordered_set<me::DemoCompositor*> me::DemoCompositor::instances;
140-
141-me::DemoCompositor::DemoCompositor(
142- mg::DisplayBuffer& display_buffer,
143- std::shared_ptr<mc::CompositorReport> const& report) :
144- display_buffer(display_buffer),
145- report(report),
146- viewport(display_buffer.view_area()),
147- zoom_mag{1.0f},
148- renderer(
149- display_buffer,
150- 30.0f, //titlebar_height
151- 80.0f) //shadow_radius
152-{
153- std::lock_guard<std::mutex> lock(instances_mutex);
154- instances.insert(this);
155-}
156-
157-me::DemoCompositor::~DemoCompositor()
158-{
159- std::lock_guard<std::mutex> lock(instances_mutex);
160- instances.erase(this);
161-}
162-
163-void me::DemoCompositor::for_each(std::function<void(DemoCompositor&)> f)
164-{
165- std::lock_guard<std::mutex> lock(instances_mutex);
166- for (auto& i : instances)
167- f(*i);
168-}
169-
170-void me::DemoCompositor::composite(mc::SceneElementSequence&& elements)
171-{
172- report->began_frame(this);
173- //a simple filtering out of renderables that shouldn't be drawn
174- //the elements should be notified if they are rendered or not
175- bool nonrenderlist_elements{false};
176- mg::RenderableList renderable_list;
177- DecorMap decorated;
178-
179- for(auto const& it : elements)
180- {
181- auto const& renderable = it->renderable();
182-
183- bool embellished = false;
184- if (auto decor = it->decoration())
185- {
186- embellished = decor->type != mc::Decoration::Type::none;
187- decorated[renderable->id()] = std::move(decor);
188- }
189-
190- if (embellished || viewport.overlaps(renderable->screen_position()))
191- {
192- renderable_list.push_back(renderable);
193-
194- /*
195- * TODO: This logic could be replaced more cleanly in future by
196- * the surface stack logic setting decoration status more
197- * accurately for fullscreen surfaces.
198- */
199- // Fullscreen and opaque? Definitely no embellishment
200- if (renderable->screen_position() == viewport &&
201- renderable->alpha() == 1.0f &&
202- !renderable->shaped() &&
203- renderable->transformation() == glm::mat4())
204- {
205- embellished = false;
206- nonrenderlist_elements = false; // Don't care what's underneath
207- }
208-
209- it->rendered();
210- }
211- else
212- {
213- it->occluded();
214- }
215- nonrenderlist_elements |= embellished;
216- }
217-
218- /*
219- * Note: Buffer lifetimes are ensured by the two objects holding
220- * references to them; elements and renderable_list.
221- * So no buffer is going to be released back to the client till
222- * both of those containers get destroyed (end of the function).
223- * Actually, there's a third reference held by the texture cache
224- * in GLRenderer, but that gets released earlier in render().
225- */
226- elements.clear(); // Release those that didn't make it to renderable_list
227-
228- if (!nonrenderlist_elements &&
229- viewport == display_buffer.view_area() && // no bypass while zoomed
230- display_buffer.overlay(renderable_list))
231- {
232- report->renderables_in_frame(this, renderable_list);
233- renderer.suspend();
234- }
235- else
236- {
237- renderer.set_output_transform(display_buffer.transformation());
238- update_viewport();
239- renderer.set_viewport(viewport);
240- renderer.begin(std::move(decorated));
241- renderer.render(renderable_list);
242-
243- report->renderables_in_frame(this, renderable_list);
244- report->rendered_frame(this);
245-
246- // Release buffers back to the clients now that the swap has returned.
247- // It's important to do this before starting on the potentially slow
248- // flip() ...
249- // FIXME: This clear() call is blocking a little (LP: #1395421)
250- renderable_list.clear();
251- }
252-
253- report->finished_frame(this);
254-}
255-
256-void me::DemoCompositor::on_cursor_movement(
257- geometry::Point const& p)
258-{
259- cursor_pos = p;
260- if (zoom_mag != 1.0f)
261- update_viewport();
262-}
263-
264-void me::DemoCompositor::zoom(float mag)
265-{
266- zoom_mag = mag;
267- update_viewport();
268-}
269-
270-void me::DemoCompositor::set_colour_effect(me::ColourEffect e)
271-{
272- renderer.set_colour_effect(e);
273-}
274-
275-void me::DemoCompositor::update_viewport()
276-{
277- auto const& view_area = display_buffer.view_area();
278-
279- if (zoom_mag == 1.0f)
280- {
281- // The below calculations should yield the same result as this, but
282- // just in case there are any floating point precision errors,
283- // set it precisely:
284- viewport = view_area;
285- }
286- else
287- {
288- int db_width = view_area.size.width.as_int();
289- int db_height = view_area.size.height.as_int();
290- int db_x = view_area.top_left.x.as_int();
291- int db_y = view_area.top_left.y.as_int();
292-
293- float zoom_width = db_width / zoom_mag;
294- float zoom_height = db_height / zoom_mag;
295-
296- // Note the 0.5f. This is because cursors (and all input in general)
297- // measures coordinates at the centre of a pixel. But GL measures to
298- // the top-left corner of a pixel.
299- float screen_x = cursor_pos.x.as_int() + 0.5f - db_x;
300- float screen_y = cursor_pos.y.as_int() + 0.5f - db_y;
301-
302- float normal_x = screen_x / db_width;
303- float normal_y = screen_y / db_height;
304-
305- // Position the viewport so the cursor location matches up.
306- // This assumes the hardware cursor still traverses the physical
307- // screen and isn't being warped.
308- int zoom_x = db_x + (db_width - zoom_width) * normal_x;
309- int zoom_y = db_y + (db_height - zoom_height) * normal_y;
310-
311- viewport = {{zoom_x, zoom_y}, {zoom_width, zoom_height}};
312- }
313-}
314
315=== removed file 'playground/demo-shell/demo_compositor.h'
316--- playground/demo-shell/demo_compositor.h 2017-07-28 17:00:43 +0000
317+++ playground/demo-shell/demo_compositor.h 1970-01-01 00:00:00 +0000
318@@ -1,79 +0,0 @@
319-/*
320- * Copyright © 2014 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 2 or 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: Kevin DuBois <kevin.dubois@canonical.com>
335- */
336-
337-#ifndef MIR_EXAMPLES_DEMO_COMPOSITOR_H_
338-#define MIR_EXAMPLES_DEMO_COMPOSITOR_H_
339-
340-#include "mir/compositor/display_buffer_compositor.h"
341-#include "mir/compositor/scene.h"
342-#include "mir/geometry/rectangle.h"
343-#include "mir/graphics/renderable.h"
344-#include "demo_renderer.h"
345-
346-#include <mutex>
347-#include <set>
348-
349-namespace mir
350-{
351-namespace compositor
352-{
353-class Scene;
354-class CompositorReport;
355-}
356-namespace graphics
357-{
358-class DisplayBuffer;
359-}
360-namespace examples
361-{
362-
363-class DemoCompositor : public compositor::DisplayBufferCompositor
364-{
365-public:
366- DemoCompositor(
367- graphics::DisplayBuffer& display_buffer,
368- std::shared_ptr<compositor::CompositorReport> const& report);
369- ~DemoCompositor();
370-
371- void composite(compositor::SceneElementSequence&& elements) override;
372-
373- void zoom(float mag);
374- void on_cursor_movement(geometry::Point const& p);
375-
376- void set_colour_effect(ColourEffect);
377-
378- static void for_each(std::function<void(DemoCompositor&)> f);
379-
380-private:
381- void update_viewport();
382-
383- graphics::DisplayBuffer& display_buffer;
384- std::shared_ptr<compositor::CompositorReport> const report;
385- geometry::Rectangle viewport;
386- geometry::Point cursor_pos;
387- float zoom_mag;
388- DemoRenderer renderer;
389-
390- static std::mutex instances_mutex;
391- static std::unordered_set<DemoCompositor*> instances;
392-};
393-
394-} // namespace examples
395-} // namespace mir
396-
397-#endif // MIR_EXAMPLES_DEMO_COMPOSITOR_H_
398
399=== removed file 'playground/demo-shell/demo_renderer.cpp'
400--- playground/demo-shell/demo_renderer.cpp 2017-07-28 17:00:43 +0000
401+++ playground/demo-shell/demo_renderer.cpp 1970-01-01 00:00:00 +0000
402@@ -1,402 +0,0 @@
403-/*
404- * Copyright © 2014 Canonical Ltd.
405- *
406- * This program is free software: you can redistribute it and/or modify
407- * it under the terms of the GNU General Public License version 2 or 3 as
408- * published by the Free Software Foundation.
409- *
410- * This program is distributed in the hope that it will be useful,
411- * but WITHOUT ANY WARRANTY; without even the implied warranty of
412- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
413- * GNU General Public License for more details.
414- *
415- * You should have received a copy of the GNU General Public License
416- * along with this program. If not, see <http://www.gnu.org/licenses/>.
417- *
418- * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
419- */
420-
421-#define MIR_LOG_COMPONENT "DemoRenderer"
422-
423-#include "typo_stub_renderer.h"
424-#ifdef TYPO_SUPPORTS_FREETYPE
425-#include "typo_freetype_renderer.h"
426-#endif
427-#include "demo_renderer.h"
428-#include <mir/graphics/renderable.h>
429-#include <mir/log.h>
430-#include <cmath>
431-
432-using namespace mir;
433-using namespace mir::examples;
434-using namespace mir::geometry;
435-using namespace mir::compositor;
436-using namespace mir::renderer;
437-
438-namespace
439-{
440-
441-struct Color
442-{
443- GLubyte r, g, b, a;
444-};
445-
446-float penumbra_curve(float x)
447-{
448- return 1.0f - std::sin(x * M_PI / 2.0f);
449-}
450-
451-GLuint generate_shadow_corner_texture(float opacity)
452-{
453- struct Texel
454- {
455- GLubyte luminance;
456- GLubyte alpha;
457- };
458-
459- int const width = 256;
460- Texel image[width][width];
461-
462- int const max = width - 1;
463- for (int y = 0; y < width; ++y)
464- {
465- float curve_y = opacity * 255.0f *
466- penumbra_curve(static_cast<float>(y) / max);
467- for (int x = 0; x < width; ++x)
468- {
469- Texel *t = &image[y][x];
470- t->luminance = 0;
471- t->alpha = curve_y * penumbra_curve(static_cast<float>(x) / max);
472- }
473- }
474-
475- GLuint corner;
476- glGenTextures(1, &corner);
477- glBindTexture(GL_TEXTURE_2D, corner);
478- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
479- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
480- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
481- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
482- glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA,
483- width, width, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,
484- image);
485-
486- return corner;
487-}
488-
489-GLuint generate_frame_corner_texture(float corner_radius,
490- Color const& color,
491- GLubyte highlight)
492-{
493- int const height = 256;
494-/*
495- * GCC 4.9 with optimizations enabled will generate armhf NEON/VFP instructions
496- * here that are not understood/implemented by Valgrind (but are by hardware),
497- * causing Valgrind to crash:
498- * eebe 0acc vcvt.s32.f32 s0, s0, #8
499- * So this clumsy expression below tricks the compiler into not using those
500- * optimized ARM instructions that Valgrind doesn't support yet:
501- */
502- int const width = height / (1.0f / corner_radius);
503- Color image[height * height]; // Worst case still much faster than the heap
504-
505- int const cx = width;
506- int const cy = cx;
507- int const radius_sqr = cx * cy;
508-
509- for (int y = 0; y < height; ++y)
510- {
511- for (int x = 0; x < width; ++x)
512- {
513- Color col = color;
514-
515- // Set gradient
516- if (y < cy)
517- {
518- float brighten = (1.0f - (static_cast<float>(y) / cy)) *
519- std::sin(x * M_PI / (2 * (width - 1)));
520-
521- col.r += (highlight - col.r) * brighten;
522- col.g += (highlight - col.g) * brighten;
523- col.b += (highlight - col.b) * brighten;
524- }
525-
526- // Cut out the corner in a circular shape.
527- if (x < cx && y < cy)
528- {
529- int dx = cx - x;
530- int dy = cy - y;
531- if (dx * dx + dy * dy >= radius_sqr)
532- col = {0, 0, 0, 0};
533- }
534-
535- image[y * width + x] = col;
536- }
537- }
538-
539- GLuint corner;
540- glGenTextures(1, &corner);
541- glBindTexture(GL_TEXTURE_2D, corner);
542- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
543- GL_LINEAR_MIPMAP_LINEAR);
544- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
545- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
546- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
547- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
548- width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
549- image);
550- glGenerateMipmap(GL_TEXTURE_2D); // Antialiasing please
551-
552- return corner;
553-}
554-
555-static const GLchar inverse_fshader[] =
556-{
557- "#ifdef GL_ES\n"
558- "precision mediump float;\n"
559- "#endif\n"
560- "uniform sampler2D tex;\n"
561- "uniform float alpha;\n"
562- "varying vec2 v_texcoord;\n"
563- "void main() {\n"
564- " vec4 f = texture2D(tex, v_texcoord);\n"
565- " vec3 inverted = (vec3(1.0) - (f.rgb / f.a)) * f.a;\n"
566- " gl_FragColor = alpha*vec4(inverted, f.a);\n"
567- "}\n"
568-};
569-static const GLchar contrast_fshader[] =
570-{
571- "#ifdef GL_ES\n"
572- "precision mediump float;\n"
573- "#endif\n"
574- "uniform sampler2D tex;\n"
575- "uniform float alpha;\n"
576- "varying vec2 v_texcoord;\n"
577- "void main() {\n"
578- " vec4 raw = texture2D(tex, v_texcoord);\n"
579- " vec3 bent = (1.0 - cos(raw.rgb * 3.141592654)) / 2.0;\n"
580- " gl_FragColor = alpha * vec4(bent, raw.a);\n"
581- "}\n"
582-};
583-
584-} // namespace
585-
586-DemoRenderer::DemoRenderer(
587- graphics::DisplayBuffer& display_buffer,
588- float const titlebar_height,
589- float const shadow_radius) :
590- renderer::gl::Renderer(display_buffer),
591- titlebar_height{titlebar_height},
592- shadow_radius{shadow_radius},
593- corner_radius{0.5f},
594- colour_effect{none},
595- inverse_program(family.add_program(vshader, inverse_fshader)),
596- contrast_program(family.add_program(vshader, contrast_fshader)),
597- title_cache(std::make_shared<typo::StubRenderer>())
598-{
599- shadow_corner_tex = generate_shadow_corner_texture(0.4f);
600- titlebar_corner_tex = generate_frame_corner_texture(corner_radius,
601- {128,128,128,255},
602- 255);
603-
604- clear_color[0] = clear_color[1] = clear_color[2] = 0.2f;
605- clear_color[3] = 1.0f;
606-
607-#ifdef TYPO_SUPPORTS_FREETYPE
608- const char title_font_path[] = "/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf";
609- auto ftrenderer = std::make_shared<typo::FreetypeRenderer>();
610- if (ftrenderer->load(title_font_path, 128))
611- title_cache.change_renderer(ftrenderer);
612- else
613- mir::log_error("Failed to load titlebar font: %s", title_font_path);
614-#endif
615-}
616-
617-DemoRenderer::~DemoRenderer()
618-{
619- glDeleteTextures(1, &shadow_corner_tex);
620- glDeleteTextures(1, &titlebar_corner_tex);
621-}
622-
623-void DemoRenderer::begin(DecorMap&& d) const
624-{
625- decor_map = std::move(d);
626- title_cache.drop_unused();
627- title_cache.mark_all_unused();
628-}
629-
630-void DemoRenderer::tessellate(std::vector<gl::Primitive>& primitives,
631- graphics::Renderable const& renderable) const
632-{
633- renderer::gl::Renderer::tessellate(primitives, renderable);
634- auto d = decor_map.find(renderable.id());
635- if (d != decor_map.end())
636- {
637- auto& decor = d->second;
638- if (decor->type != Decoration::Type::none)
639- {
640- tessellate_shadow(primitives, renderable, shadow_radius);
641- tessellate_frame(primitives, renderable, titlebar_height,
642- decor->name.c_str());
643- }
644- }
645-}
646-
647-void DemoRenderer::tessellate_shadow(std::vector<gl::Primitive>& primitives,
648- graphics::Renderable const& renderable,
649- float radius) const
650-{
651- auto const& rect = renderable.screen_position();
652- GLfloat left = rect.top_left.x.as_int();
653- GLfloat right = left + rect.size.width.as_int();
654- GLfloat top = rect.top_left.y.as_int();
655- GLfloat bottom = top + rect.size.height.as_int();
656-
657- auto n = primitives.size();
658- primitives.resize(n + 8);
659-
660- GLfloat rightr = right + radius;
661- GLfloat leftr = left - radius;
662- GLfloat topr = top - radius;
663- GLfloat bottomr = bottom + radius;
664-
665- auto& right_shadow = primitives[n++];
666- right_shadow.tex_id = shadow_corner_tex;
667- right_shadow.vertices[0] = {{right, top, 0.0f}, {0.0f, 0.0f}};
668- right_shadow.vertices[1] = {{rightr, top, 0.0f}, {1.0f, 0.0f}};
669- right_shadow.vertices[2] = {{rightr, bottom, 0.0f}, {1.0f, 0.0f}};
670- right_shadow.vertices[3] = {{right, bottom, 0.0f}, {0.0f, 0.0f}};
671-
672- auto& left_shadow = primitives[n++];
673- left_shadow.tex_id = shadow_corner_tex;
674- left_shadow.vertices[0] = {{leftr, top, 0.0f}, {1.0f, 0.0f}};
675- left_shadow.vertices[1] = {{left, top, 0.0f}, {0.0f, 0.0f}};
676- left_shadow.vertices[2] = {{left, bottom, 0.0f}, {0.0f, 0.0f}};
677- left_shadow.vertices[3] = {{leftr, bottom, 0.0f}, {1.0f, 0.0f}};
678-
679- auto& top_shadow = primitives[n++];
680- top_shadow.tex_id = shadow_corner_tex;
681- top_shadow.vertices[0] = {{left, topr, 0.0f}, {1.0f, 0.0f}};
682- top_shadow.vertices[1] = {{right, topr, 0.0f}, {1.0f, 0.0f}};
683- top_shadow.vertices[2] = {{right, top, 0.0f}, {0.0f, 0.0f}};
684- top_shadow.vertices[3] = {{left, top, 0.0f}, {0.0f, 0.0f}};
685-
686- auto& bottom_shadow = primitives[n++];
687- bottom_shadow.tex_id = shadow_corner_tex;
688- bottom_shadow.vertices[0] = {{left, bottom, 0.0f}, {0.0f, 0.0f}};
689- bottom_shadow.vertices[1] = {{right, bottom, 0.0f}, {0.0f, 0.0f}};
690- bottom_shadow.vertices[2] = {{right, bottomr, 0.0f}, {1.0f, 0.0f}};
691- bottom_shadow.vertices[3] = {{left, bottomr, 0.0f}, {1.0f, 0.0f}};
692-
693- auto& tr_shadow = primitives[n++];
694- tr_shadow.tex_id = shadow_corner_tex;
695- tr_shadow.vertices[0] = {{right, top, 0.0f}, {0.0f, 0.0f}};
696- tr_shadow.vertices[1] = {{right, topr, 0.0f}, {1.0f, 0.0f}};
697- tr_shadow.vertices[2] = {{rightr, topr, 0.0f}, {1.0f, 1.0f}};
698- tr_shadow.vertices[3] = {{rightr, top, 0.0f}, {0.0f, 1.0f}};
699-
700- auto& br_shadow = primitives[n++];
701- br_shadow.tex_id = shadow_corner_tex;
702- br_shadow.vertices[0] = {{right, bottom, 0.0f}, {0.0f, 0.0f}};
703- br_shadow.vertices[1] = {{rightr, bottom, 0.0f}, {1.0f, 0.0f}};
704- br_shadow.vertices[2] = {{rightr, bottomr, 0.0f}, {1.0f, 1.0f}};
705- br_shadow.vertices[3] = {{right, bottomr, 0.0f}, {0.0f, 1.0f}};
706-
707- auto& bl_shadow = primitives[n++];
708- bl_shadow.tex_id = shadow_corner_tex;
709- bl_shadow.vertices[0] = {{left, bottom, 0.0f}, {0.0f, 0.0f}};
710- bl_shadow.vertices[1] = {{left, bottomr, 0.0f}, {1.0f, 0.0f}};
711- bl_shadow.vertices[2] = {{leftr, bottomr, 0.0f}, {1.0f, 1.0f}};
712- bl_shadow.vertices[3] = {{leftr, bottom, 0.0f}, {0.0f, 1.0f}};
713-
714- auto& tl_shadow = primitives[n++];
715- tl_shadow.tex_id = shadow_corner_tex;
716- tl_shadow.vertices[0] = {{left, top, 0.0f}, {0.0f, 0.0f}};
717- tl_shadow.vertices[1] = {{leftr, top, 0.0f}, {1.0f, 0.0f}};
718- tl_shadow.vertices[2] = {{leftr, topr, 0.0f}, {1.0f, 1.0f}};
719- tl_shadow.vertices[3] = {{left, topr, 0.0f}, {0.0f, 1.0f}};
720-}
721-
722-void DemoRenderer::tessellate_frame(std::vector<gl::Primitive>& primitives,
723- graphics::Renderable const& renderable,
724- float titlebar_height,
725- char const* name) const
726-{
727- auto const& rect = renderable.screen_position();
728- GLfloat left = rect.top_left.x.as_int();
729- GLfloat right = left + rect.size.width.as_int();
730- GLfloat top = rect.top_left.y.as_int();
731-
732- auto n = primitives.size();
733- primitives.resize(n + 4);
734-
735- GLfloat htop = top - titlebar_height;
736- GLfloat in = titlebar_height * corner_radius;
737- GLfloat inleft = left + in;
738- GLfloat inright = right - in;
739-
740- GLfloat mid = (left + right) / 2.0f;
741- if (inleft > mid) inleft = mid;
742- if (inright < mid) inright = mid;
743-
744- auto& top_left_corner = primitives[n++];
745- top_left_corner.tex_id = titlebar_corner_tex;
746- top_left_corner.vertices[0] = {{left, htop, 0.0f}, {0.0f, 0.0f}};
747- top_left_corner.vertices[1] = {{inleft, htop, 0.0f}, {1.0f, 0.0f}};
748- top_left_corner.vertices[2] = {{inleft, top, 0.0f}, {1.0f, 1.0f}};
749- top_left_corner.vertices[3] = {{left, top, 0.0f}, {0.0f, 1.0f}};
750-
751- auto& top_right_corner = primitives[n++];
752- top_right_corner.tex_id = titlebar_corner_tex;
753- top_right_corner.vertices[0] = {{inright, htop, 0.0f}, {1.0f, 0.0f}};
754- top_right_corner.vertices[1] = {{right, htop, 0.0f}, {0.0f, 0.0f}};
755- top_right_corner.vertices[2] = {{right, top, 0.0f}, {0.0f, 1.0f}};
756- top_right_corner.vertices[3] = {{inright, top, 0.0f}, {1.0f, 1.0f}};
757-
758- auto& titlebar = primitives[n++];
759- titlebar.tex_id = titlebar_corner_tex;
760- titlebar.vertices[0] = {{inleft, htop, 0.0f}, {1.0f, 0.0f}};
761- titlebar.vertices[1] = {{inright, htop, 0.0f}, {1.0f, 0.0f}};
762- titlebar.vertices[2] = {{inright, top, 0.0f}, {1.0f, 1.0f}};
763- titlebar.vertices[3] = {{inleft, top, 0.0f}, {1.0f, 1.0f}};
764-
765- auto str = title_cache.get(name);
766- GLfloat text_vin = titlebar_height / 5;
767- GLfloat text_top = htop + text_vin;
768- GLfloat text_bot = top - text_vin;
769- GLfloat text_height = text_bot - text_top;
770- GLfloat text_scale = text_height / str.height;
771- GLfloat text_left = inleft;
772- GLfloat text_right = text_left + text_scale * str.width;
773- GLfloat text_u = 1.0f;
774- if (text_right > inright) // Title too long for window
775- {
776- text_u = (inright - text_left) / (text_right - text_left);
777- text_right = inright;
778- }
779-
780- auto& text_prim = primitives[n++];
781- text_prim.tex_id = str.tex;
782- text_prim.vertices[0] = {{text_left, text_top, 0.0f}, {0.0f, 0.0f}};
783- text_prim.vertices[1] = {{text_right, text_top, 0.0f}, {text_u, 0.0f}};
784- text_prim.vertices[2] = {{text_right, text_bot, 0.0f}, {text_u, 1.0f}};
785- text_prim.vertices[3] = {{text_left, text_bot, 0.0f}, {0.0f, 1.0f}};
786-}
787-
788-void DemoRenderer::set_colour_effect(ColourEffect e)
789-{
790- colour_effect = e;
791-}
792-
793-void DemoRenderer::draw(graphics::Renderable const& renderable,
794- renderer::gl::Renderer::Program const& current_program) const
795-{
796- const renderer::gl::Renderer::Program* const programs[ColourEffect::neffects] =
797- {
798- &current_program,
799- &inverse_program,
800- &contrast_program
801- };
802-
803- renderer::gl::Renderer::draw(renderable, *programs[colour_effect]);
804-}
805
806=== removed file 'playground/demo-shell/demo_renderer.h'
807--- playground/demo-shell/demo_renderer.h 2017-07-28 17:00:43 +0000
808+++ playground/demo-shell/demo_renderer.h 1970-01-01 00:00:00 +0000
809@@ -1,90 +0,0 @@
810-/*
811- * Copyright © 2014 Canonical Ltd.
812- *
813- * This program is free software: you can redistribute it and/or modify
814- * it under the terms of the GNU General Public License version 2 or 3 as
815- * published by the Free Software Foundation.
816- *
817- * This program is distributed in the hope that it will be useful,
818- * but WITHOUT ANY WARRANTY; without even the implied warranty of
819- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
820- * GNU General Public License for more details.
821- *
822- * You should have received a copy of the GNU General Public License
823- * along with this program. If not, see <http://www.gnu.org/licenses/>.
824- *
825- * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
826- */
827-
828-#ifndef MIR_EXAMPLES_DEMO_RENDERER_H_
829-#define MIR_EXAMPLES_DEMO_RENDERER_H_
830-
831-#include "gl/renderer.h"
832-#include "mir/compositor/decoration.h"
833-#include "typo_glcache.h"
834-
835-#include <unordered_map>
836-
837-namespace mir
838-{
839-namespace examples
840-{
841-
842-enum ColourEffect
843-{
844- none,
845- inverse,
846- contrast,
847- neffects
848-};
849-
850-typedef std::unordered_map<graphics::Renderable::ID,
851- std::unique_ptr<compositor::Decoration>> DecorMap;
852-
853-class DemoRenderer : public renderer::gl::Renderer
854-{
855-public:
856- DemoRenderer(
857- graphics::DisplayBuffer& display_buffer,
858- float const titlebar_height,
859- float const shadow_radius);
860- ~DemoRenderer();
861-
862- void begin(DecorMap&&) const;
863- void set_colour_effect(ColourEffect);
864-
865-protected:
866- void tessellate(std::vector<gl::Primitive>& primitives,
867- graphics::Renderable const& renderable) const override;
868-
869- void draw(graphics::Renderable const& renderable,
870- Renderer::Program const& prog) const override;
871-
872-private:
873- void tessellate_shadow(
874- std::vector<gl::Primitive>& primitives,
875- graphics::Renderable const& renderable,
876- float radius) const;
877- void tessellate_frame(
878- std::vector<gl::Primitive>& primitives,
879- graphics::Renderable const& renderable,
880- float titlebar_height,
881- char const* name) const;
882-
883- float const titlebar_height;
884- float const shadow_radius;
885- float const corner_radius;
886- GLuint shadow_corner_tex;
887- GLuint titlebar_corner_tex;
888-
889- ColourEffect colour_effect;
890- Program inverse_program, contrast_program;
891-
892- mutable DecorMap decor_map;
893- mutable typo::GLCache title_cache;
894-};
895-
896-} // namespace examples
897-} // namespace mir
898-
899-#endif // MIR_EXAMPLES_DEMO_RENDERER_H_
900
901=== removed file 'playground/demo-shell/demo_shell.cpp'
902--- playground/demo-shell/demo_shell.cpp 2017-07-28 17:00:43 +0000
903+++ playground/demo-shell/demo_shell.cpp 1970-01-01 00:00:00 +0000
904@@ -1,120 +0,0 @@
905-/*
906- * Copyright © 2013-2015 Canonical Ltd.
907- *
908- * This program is free software: you can redistribute it and/or modify
909- * it under the terms of the GNU General Public License version 2 or 3 as
910- * published by the Free Software Foundation.
911- *
912- * This program is distributed in the hope that it will be useful,
913- * but WITHOUT ANY WARRANTY; without even the implied warranty of
914- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
915- * GNU General Public License for more details.
916- *
917- * You should have received a copy of the GNU General Public License
918- * along with this program. If not, see <http://www.gnu.org/licenses/>.
919- *
920- * Authored by: Robert Carr <robert.carr@canonical.com>
921- */
922-
923-/// \example demo_shell.cpp A simple mir shell
924-
925-#include "demo_compositor.h"
926-#include "window_manager.h"
927-#include "../server_configuration.h"
928-
929-#include "mir/run_mir.h"
930-#include "mir/report_exception.h"
931-#include "mir/graphics/display.h"
932-#include "mir/input/composite_event_filter.h"
933-#include "mir/compositor/display_buffer_compositor_factory.h"
934-#include "mir/renderer/renderer_factory.h"
935-#include "mir/options/option.h"
936-#include "server_example_host_lifecycle_event_listener.h"
937-
938-#include <iostream>
939-
940-namespace me = mir::examples;
941-namespace ms = mir::scene;
942-namespace mg = mir::graphics;
943-namespace mf = mir::frontend;
944-namespace mi = mir::input;
945-namespace mc = mir::compositor;
946-namespace msh = mir::shell;
947-
948-namespace mir
949-{
950-namespace examples
951-{
952-class DisplayBufferCompositorFactory : public mc::DisplayBufferCompositorFactory
953-{
954-public:
955- DisplayBufferCompositorFactory(
956- std::shared_ptr<mc::CompositorReport> const& report) :
957- report(report)
958- {
959- }
960-
961- std::unique_ptr<mc::DisplayBufferCompositor> create_compositor_for(
962- mg::DisplayBuffer& display_buffer) override
963- {
964- return std::unique_ptr<mc::DisplayBufferCompositor>(
965- new me::DemoCompositor{display_buffer, report});
966- }
967-
968-private:
969- std::shared_ptr<mc::CompositorReport> const report;
970-};
971-
972-class DemoServerConfiguration : public mir::examples::ServerConfiguration
973-{
974-public:
975- using mir::examples::ServerConfiguration::ServerConfiguration;
976-
977- std::shared_ptr<compositor::DisplayBufferCompositorFactory> the_display_buffer_compositor_factory() override
978- {
979- return display_buffer_compositor_factory(
980- [this]()
981- {
982- return std::make_shared<me::DisplayBufferCompositorFactory>(
983- the_compositor_report());
984- });
985- }
986-
987- std::shared_ptr<msh::HostLifecycleEventListener> the_host_lifecycle_event_listener() override
988- {
989- return host_lifecycle_event_listener(
990- [this]()
991- {
992- return std::make_shared<HostLifecycleEventListener>(the_logger());
993- });
994- }
995-};
996-
997-}
998-}
999-
1000-int main(int argc, char const* argv[])
1001-try
1002-{
1003- me::DemoServerConfiguration config(argc, argv);
1004-
1005- auto wm = std::make_shared<me::WindowManager>();
1006-
1007- mir::run_mir(config, [&config, &wm](mir::DisplayServer&)
1008- {
1009- // We use this strange two stage initialization to avoid a circular dependency between the EventFilters
1010- // and the SessionStore
1011- wm->set_focus_controller(config.the_focus_controller());
1012- wm->set_display(config.the_display());
1013- wm->set_compositor(config.the_compositor());
1014- wm->set_input_scene(config.the_input_scene());
1015-
1016- config.the_composite_event_filter()->prepend(wm);
1017- });
1018- return 0;
1019-}
1020-catch (...)
1021-{
1022- mir::report_exception(std::cerr);
1023- return 1;
1024-}
1025
1026=== removed directory 'playground/demo-shell/typo'
1027=== removed file 'playground/demo-shell/typo/CMakeLists.txt'
1028--- playground/demo-shell/typo/CMakeLists.txt 2017-05-08 03:04:26 +0000
1029+++ playground/demo-shell/typo/CMakeLists.txt 1970-01-01 00:00:00 +0000
1030@@ -1,23 +0,0 @@
1031-find_package(PkgConfig)
1032-
1033-pkg_search_module(FREETYPE freetype2)
1034-if (FREETYPE_FOUND)
1035- set(OPTIONAL_SRCS typo_freetype_renderer.cpp)
1036-endif ()
1037-
1038-add_library(typo STATIC
1039- typo_renderer.cpp
1040- typo_stub_renderer.cpp
1041- typo_glcache.cpp
1042- ${OPTIONAL_SRCS}
1043-)
1044-
1045-target_link_libraries(typo ${GL_LIBRARIES})
1046-target_include_directories(typo PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
1047-
1048-if (FREETYPE_FOUND)
1049- target_compile_definitions(typo PUBLIC -DTYPO_SUPPORTS_FREETYPE)
1050- target_link_libraries(typo ${FREETYPE_LIBRARIES})
1051- target_include_directories(typo PUBLIC ${FREETYPE_INCLUDE_DIRS})
1052-endif ()
1053-
1054
1055=== removed file 'playground/demo-shell/typo/typo_freetype_renderer.cpp'
1056--- playground/demo-shell/typo/typo_freetype_renderer.cpp 2017-07-28 17:00:43 +0000
1057+++ playground/demo-shell/typo/typo_freetype_renderer.cpp 1970-01-01 00:00:00 +0000
1058@@ -1,125 +0,0 @@
1059-/*
1060- * Copyright © 2015 Canonical Ltd.
1061- *
1062- * This program is free software: you can redistribute it and/or modify
1063- * it under the terms of the GNU General Public License version 2 or 3 as
1064- * published by the Free Software Foundation.
1065- *
1066- * This program is distributed in the hope that it will be useful,
1067- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1068- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1069- * GNU General Public License for more details.
1070- *
1071- * You should have received a copy of the GNU General Public License
1072- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1073- *
1074- * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
1075- */
1076-
1077-#include "typo_freetype_renderer.h"
1078-#include <stdexcept>
1079-#include <cstring>
1080-
1081-using namespace mir::typo;
1082-
1083-FreetypeRenderer::FreetypeRenderer()
1084- : lib(nullptr), face(nullptr), preferred_height(16)
1085-{
1086- if (FT_Init_FreeType(&lib))
1087- throw std::runtime_error("FreeType init failed");
1088-}
1089-
1090-FreetypeRenderer::~FreetypeRenderer()
1091-{
1092- if (face) FT_Done_Face(face);
1093- if (lib) FT_Done_FreeType(lib);
1094-}
1095-
1096-bool FreetypeRenderer::load(char const* font_path, int pref_height)
1097-{
1098- preferred_height = pref_height;
1099-
1100- if (face)
1101- {
1102- FT_Done_Face(face);
1103- face = nullptr;
1104- }
1105- if (FT_New_Face(lib, font_path, 0, &face))
1106- return false;
1107-
1108- FT_Set_Pixel_Sizes(face, 0, preferred_height);
1109-
1110- return true;
1111-}
1112-
1113-void FreetypeRenderer::render(char const* str, Image& img)
1114-{
1115- int minx = 0, maxx = 0, miny = 0, maxy = 0;
1116- int penx = 0, peny = 0;
1117- FT_GlyphSlot slot = face->glyph;
1118-
1119- char const* s = str;
1120- while (unsigned long u = unicode_from_utf8(&s))
1121- {
1122- auto glyph = FT_Get_Char_Index(face, u);
1123- FT_Load_Glyph(face, glyph, FT_LOAD_DEFAULT);
1124- FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL);
1125-
1126- int left = penx + slot->bitmap_left;
1127- if (left < minx) minx = left;
1128-
1129- int right = left + slot->bitmap.width;
1130- if (right > maxx) maxx = right;
1131-
1132- int top = peny - slot->bitmap_top;
1133- if (top < miny) miny = top;
1134-
1135- int bottom = top + slot->bitmap.rows;
1136- if (bottom > maxy) maxy = bottom;
1137-
1138- penx += slot->advance.x >> 6;
1139- peny += slot->advance.y >> 6;
1140- }
1141-
1142- int const padding = preferred_height / 8; // Allow mipmapping to smear
1143- int width = maxx - minx + 1 + 2*padding;
1144- int height = maxy - miny + 1;
1145- if (height < preferred_height) // e.g. str has no descenders, but make
1146- height = preferred_height; // room so we get a consistent height
1147- height += 2*padding;
1148- penx = -minx + padding;
1149- peny = -miny + padding;
1150-
1151- img.reserve(width, height, Image::alpha8);
1152-
1153- s = str;
1154- while (unsigned long u = unicode_from_utf8(&s))
1155- {
1156- auto glyph = FT_Get_Char_Index(face, u);
1157- FT_Load_Glyph(face, glyph, FT_LOAD_DEFAULT);
1158- FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL);
1159-
1160- auto& bitmap = slot->bitmap;
1161- int x = penx + slot->bitmap_left;
1162- int y = peny - slot->bitmap_top;
1163- int right = x + bitmap.width;
1164- int bottom = y + bitmap.rows;
1165-
1166- if (x >= 0 && right <= width && y >= 0 && bottom <= height)
1167- {
1168- unsigned char* src = bitmap.buffer;
1169- unsigned char* dest = img.data() + y*img.stride() + x;
1170-
1171- int ylimit = y + bitmap.rows;
1172- for (; y < ylimit; ++y)
1173- {
1174- memcpy(dest, src, bitmap.width);
1175- src += bitmap.pitch;
1176- dest += img.stride();
1177- }
1178- }
1179-
1180- penx += slot->advance.x >> 6;
1181- peny += slot->advance.y >> 6;
1182- }
1183-}
1184
1185=== removed file 'playground/demo-shell/typo/typo_freetype_renderer.h'
1186--- playground/demo-shell/typo/typo_freetype_renderer.h 2017-07-28 17:00:43 +0000
1187+++ playground/demo-shell/typo/typo_freetype_renderer.h 1970-01-01 00:00:00 +0000
1188@@ -1,44 +0,0 @@
1189-/*
1190- * Copyright © 2015 Canonical Ltd.
1191- *
1192- * This program is free software: you can redistribute it and/or modify
1193- * it under the terms of the GNU General Public License version 2 or 3 as
1194- * published by the Free Software Foundation.
1195- *
1196- * This program is distributed in the hope that it will be useful,
1197- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1198- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1199- * GNU General Public License for more details.
1200- *
1201- * You should have received a copy of the GNU General Public License
1202- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1203- *
1204- * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
1205- */
1206-
1207-#ifndef MIR_TYPO_FREETYPE_RENDERER_H_
1208-#define MIR_TYPO_FREETYPE_RENDERER_H_
1209-
1210-#include "typo_renderer.h"
1211-#include <ft2build.h>
1212-#include FT_FREETYPE_H
1213-
1214-namespace mir { namespace typo {
1215-
1216-class FreetypeRenderer : public Renderer
1217-{
1218-public:
1219- FreetypeRenderer();
1220- ~FreetypeRenderer();
1221- bool load(char const* font_path, int pref_height);
1222- void render(char const* str, Image& img) override;
1223-
1224-private:
1225- FT_Library lib;
1226- FT_Face face;
1227- int preferred_height;
1228-};
1229-
1230-} } // namespace mir::typo
1231-
1232-#endif // MIR_TYPO_FREETYPE_RENDERER_H_
1233
1234=== removed file 'playground/demo-shell/typo/typo_glcache.cpp'
1235--- playground/demo-shell/typo/typo_glcache.cpp 2017-07-28 17:00:43 +0000
1236+++ playground/demo-shell/typo/typo_glcache.cpp 1970-01-01 00:00:00 +0000
1237@@ -1,99 +0,0 @@
1238-/*
1239- * Copyright © 2015 Canonical Ltd.
1240- *
1241- * This program is free software: you can redistribute it and/or modify
1242- * it under the terms of the GNU General Public License version 2 or 3 as
1243- * published by the Free Software Foundation.
1244- *
1245- * This program is distributed in the hope that it will be useful,
1246- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1247- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1248- * GNU General Public License for more details.
1249- *
1250- * You should have received a copy of the GNU General Public License
1251- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1252- *
1253- * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
1254- */
1255-
1256-#include "typo_glcache.h"
1257-#include MIR_SERVER_GL_H
1258-
1259-using namespace mir::typo;
1260-
1261-GLCache::GLCache(std::shared_ptr<Renderer> const& r)
1262- : renderer(r)
1263-{
1264-}
1265-
1266-GLCache::~GLCache()
1267-{
1268- clear();
1269-}
1270-
1271-void GLCache::change_renderer(std::shared_ptr<Renderer> const& r)
1272-{
1273- clear();
1274- renderer = r;
1275-}
1276-
1277-void GLCache::clear()
1278-{
1279- for (auto& e : map)
1280- glDeleteTextures(1, &e.second.tex);
1281- map.clear();
1282-}
1283-
1284-void GLCache::mark_all_unused()
1285-{
1286- for (auto& e : map)
1287- e.second.used = false;
1288-}
1289-
1290-void GLCache::drop_unused()
1291-{
1292- for (auto e = map.begin(); e != map.end();)
1293- {
1294- if (!e->second.used)
1295- {
1296- glDeleteTextures(1, &e->second.tex);
1297- e = map.erase(e);
1298- }
1299- else
1300- e++;
1301- }
1302-}
1303-
1304-bool GLCache::Entry::valid() const
1305-{
1306- return width > 0 && height > 0;
1307-}
1308-
1309-GLCache::Entry const& GLCache::get(char const* str)
1310-{
1311- Entry& entry = map[str];
1312- if (!entry.valid())
1313- {
1314- Renderer::Image img;
1315- renderer->render(str, img);
1316- if (img.data())
1317- {
1318- entry.width = img.width();
1319- entry.height = img.height();
1320- glGenTextures(1, &entry.tex);
1321- glBindTexture(GL_TEXTURE_2D, entry.tex);
1322- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
1323- GL_LINEAR_MIPMAP_NEAREST);
1324- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1325- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1326- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1327- glPixelStorei(GL_UNPACK_ALIGNMENT, img.alignment());
1328- glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA,
1329- img.width(), img.height(), 0, GL_ALPHA,
1330- GL_UNSIGNED_BYTE, img.data());
1331- glGenerateMipmap(GL_TEXTURE_2D); // Antialiasing shrinkage please
1332- }
1333- }
1334- entry.used = true;
1335- return entry;
1336-}
1337
1338=== removed file 'playground/demo-shell/typo/typo_glcache.h'
1339--- playground/demo-shell/typo/typo_glcache.h 2017-07-28 17:00:43 +0000
1340+++ playground/demo-shell/typo/typo_glcache.h 1970-01-01 00:00:00 +0000
1341@@ -1,56 +0,0 @@
1342-/*
1343- * Copyright © 2015 Canonical Ltd.
1344- *
1345- * This program is free software: you can redistribute it and/or modify
1346- * it under the terms of the GNU General Public License version 2 or 3 as
1347- * published by the Free Software Foundation.
1348- *
1349- * This program is distributed in the hope that it will be useful,
1350- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1351- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1352- * GNU General Public License for more details.
1353- *
1354- * You should have received a copy of the GNU General Public License
1355- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1356- *
1357- * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
1358- */
1359-
1360-#ifndef MIR_TYPO_GLCACHE_H_
1361-#define MIR_TYPO_GLCACHE_H_
1362-
1363-#include "typo_renderer.h"
1364-#include <string>
1365-#include <unordered_map>
1366-#include <memory>
1367-
1368-namespace mir { namespace typo {
1369-
1370-class GLCache
1371-{
1372-public:
1373- struct Entry
1374- {
1375- bool valid() const;
1376- unsigned int tex = 0;
1377- int width = 0, height = 0;
1378- bool used = false;
1379- };
1380-
1381- explicit GLCache(std::shared_ptr<Renderer> const&);
1382- ~GLCache();
1383- void change_renderer(std::shared_ptr<Renderer> const&);
1384- Entry const& get(char const* str);
1385- void clear();
1386- void mark_all_unused();
1387- void drop_unused();
1388-
1389-private:
1390- typedef std::unordered_map<std::string, Entry> Map;
1391- Map map;
1392- std::shared_ptr<Renderer> renderer;
1393-};
1394-
1395-} } // namespace mir::typo
1396-
1397-#endif // MIR_TYPO_GLCACHE_H_
1398
1399=== removed file 'playground/demo-shell/typo/typo_renderer.cpp'
1400--- playground/demo-shell/typo/typo_renderer.cpp 2017-07-28 17:00:43 +0000
1401+++ playground/demo-shell/typo/typo_renderer.cpp 1970-01-01 00:00:00 +0000
1402@@ -1,59 +0,0 @@
1403-/*
1404- * Copyright © 2015 Canonical Ltd.
1405- *
1406- * This program is free software: you can redistribute it and/or modify
1407- * it under the terms of the GNU General Public License version 2 or 3 as
1408- * published by the Free Software Foundation.
1409- *
1410- * This program is distributed in the hope that it will be useful,
1411- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1412- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1413- * GNU General Public License for more details.
1414- *
1415- * You should have received a copy of the GNU General Public License
1416- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1417- *
1418- * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
1419- */
1420-
1421-#include "typo_renderer.h"
1422-#include <cstring>
1423-
1424-using namespace mir::typo;
1425-
1426-Renderer::Image::Image()
1427- : buf(nullptr), width_(0), stride_(0), height_(0), align_(4),
1428- format_(alpha8)
1429-{
1430-}
1431-
1432-Renderer::Image::~Image()
1433-{
1434- delete[] buf;
1435-}
1436-
1437-void Renderer::Image::reserve(int w, int h, Format f)
1438-{
1439- width_ = w;
1440- height_ = h;
1441- format_ = f;
1442- int const bpp = 1; // format is always alpha8
1443- stride_ = (((width_ * bpp) + align_ - 1) / align_) * align_;
1444- delete[] buf;
1445- auto size = stride_ * height_;
1446- buf = new unsigned char[size];
1447- memset(buf, 0, size);
1448-}
1449-
1450-Renderer::~Renderer()
1451-{
1452-}
1453-
1454-unsigned long Renderer::unicode_from_utf8(char const** utf8)
1455-{
1456- int char_len = 1; // TODO: Add support for non-ASCII UTF-8
1457- unsigned long unicode = **utf8;
1458- if (unicode)
1459- *utf8 += char_len;
1460- return unicode;
1461-}
1462
1463=== removed file 'playground/demo-shell/typo/typo_renderer.h'
1464--- playground/demo-shell/typo/typo_renderer.h 2017-07-28 17:00:43 +0000
1465+++ playground/demo-shell/typo/typo_renderer.h 1970-01-01 00:00:00 +0000
1466@@ -1,61 +0,0 @@
1467-/*
1468- * Copyright © 2015 Canonical Ltd.
1469- *
1470- * This program is free software: you can redistribute it and/or modify
1471- * it under the terms of the GNU General Public License version 2 or 3 as
1472- * published by the Free Software Foundation.
1473- *
1474- * This program is distributed in the hope that it will be useful,
1475- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1476- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1477- * GNU General Public License for more details.
1478- *
1479- * You should have received a copy of the GNU General Public License
1480- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1481- *
1482- * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
1483- */
1484-
1485-#ifndef MIR_TYPO_RENDERER_H_
1486-#define MIR_TYPO_RENDERER_H_
1487-
1488-namespace mir { namespace typo {
1489-
1490-class Renderer
1491-{
1492-public:
1493- class Image
1494- {
1495- public:
1496- Image();
1497- Image(Image const&) = delete;
1498- Image(Image const&&) = delete;
1499- Image& operator=(Image const&) = delete;
1500- ~Image();
1501-
1502- typedef enum {alpha8} Format;
1503-
1504- void reserve(int w, int h, Format f);
1505- unsigned char* data() const { return buf; };
1506- int width() const { return width_; }
1507- int height() const { return height_; }
1508- int stride() const { return stride_; }
1509- int alignment() const { return align_; }
1510- Format format() const { return format_; }
1511-
1512- private:
1513- unsigned char* buf;
1514- int width_, stride_, height_, align_;
1515- Format format_;
1516- };
1517-
1518- virtual ~Renderer();
1519- virtual void render(char const* str, Image& img) = 0;
1520-
1521-protected:
1522- static unsigned long unicode_from_utf8(char const** utf8);
1523-};
1524-
1525-} } // namespace mir::typo
1526-
1527-#endif // MIR_TYPO_RENDERER_H_
1528
1529=== removed file 'playground/demo-shell/typo/typo_stub_renderer.cpp'
1530--- playground/demo-shell/typo/typo_stub_renderer.cpp 2017-07-28 17:00:43 +0000
1531+++ playground/demo-shell/typo/typo_stub_renderer.cpp 1970-01-01 00:00:00 +0000
1532@@ -1,47 +0,0 @@
1533-/*
1534- * Copyright © 2015 Canonical Ltd.
1535- *
1536- * This program is free software: you can redistribute it and/or modify
1537- * it under the terms of the GNU General Public License version 2 or 3 as
1538- * published by the Free Software Foundation.
1539- *
1540- * This program is distributed in the hope that it will be useful,
1541- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1542- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1543- * GNU General Public License for more details.
1544- *
1545- * You should have received a copy of the GNU General Public License
1546- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1547- *
1548- * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
1549- */
1550-
1551-#include "typo_stub_renderer.h"
1552-#include <cstring>
1553-
1554-using namespace mir::typo;
1555-
1556-void StubRenderer::render(char const* str, Image& img)
1557-{
1558- int const char_width = 8;
1559- int const char_height = 16;
1560- int const char_space = 2;
1561- int const tex_height = 20;
1562- int const len = strlen(str);
1563- int const top = (tex_height - char_height) / 2;
1564-
1565- img.reserve(len*(char_width+char_space) - char_space, tex_height,
1566- Image::alpha8);
1567-
1568- char const* s = str;
1569- for (int n = 0; unicode_from_utf8(&s); ++n)
1570- {
1571- unsigned char* row = img.data() + top*img.stride() +
1572- n*(char_width+char_space);
1573- for (int y = 0; y < char_height; ++y)
1574- {
1575- memset(row, 255, char_width);
1576- row += img.stride();
1577- }
1578- }
1579-}
1580
1581=== removed file 'playground/demo-shell/typo/typo_stub_renderer.h'
1582--- playground/demo-shell/typo/typo_stub_renderer.h 2017-07-28 17:00:43 +0000
1583+++ playground/demo-shell/typo/typo_stub_renderer.h 1970-01-01 00:00:00 +0000
1584@@ -1,34 +0,0 @@
1585-/*
1586- * Copyright © 2015 Canonical Ltd.
1587- *
1588- * This program is free software: you can redistribute it and/or modify
1589- * it under the terms of the GNU General Public License version 2 or 3 as
1590- * published by the Free Software Foundation.
1591- *
1592- * This program is distributed in the hope that it will be useful,
1593- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1594- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1595- * GNU General Public License for more details.
1596- *
1597- * You should have received a copy of the GNU General Public License
1598- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1599- *
1600- * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
1601- */
1602-
1603-#ifndef MIR_TYPO_STUB_RENDERER_H_
1604-#define MIR_TYPO_STUB_RENDERER_H_
1605-
1606-#include "typo_renderer.h"
1607-
1608-namespace mir { namespace typo {
1609-
1610-class StubRenderer : public Renderer
1611-{
1612-public:
1613- void render(char const* str, Image& img) override;
1614-};
1615-
1616-} } // namespace mir::typo
1617-
1618-#endif // MIR_TYPO_STUB_RENDERER_H_
1619
1620=== removed file 'playground/demo-shell/window_manager.cpp'
1621--- playground/demo-shell/window_manager.cpp 2017-07-28 17:00:43 +0000
1622+++ playground/demo-shell/window_manager.cpp 1970-01-01 00:00:00 +0000
1623@@ -1,611 +0,0 @@
1624-/*
1625- * Copyright © 2013 Canonical Ltd.
1626- *
1627- * This program is free software: you can redistribute it and/or modify it
1628- * under the terms of the GNU General Public License version 2 or 3,
1629- * as published by the Free Software Foundation.
1630- *
1631- * This program is distributed in the hope that it will be useful,
1632- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1633- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1634- * GNU General Public License for more details.
1635- *
1636- * You should have received a copy of the GNU General Public License
1637- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1638- *
1639- * Authored by: Robert Carr <robert.carr@canonical.com>
1640- * Daniel van Vugt <daniel.van.vugt@canonical.com>
1641- */
1642-
1643-#include "window_manager.h"
1644-#include "demo_compositor.h"
1645-
1646-#include "mir/shell/focus_controller.h"
1647-#include "mir/scene/session.h"
1648-#include "mir/scene/surface.h"
1649-#include "mir/graphics/display.h"
1650-#include "mir/graphics/display_configuration.h"
1651-#include "mir/compositor/compositor.h"
1652-
1653-#include <linux/input.h>
1654-
1655-#include <cassert>
1656-#include <cstdlib>
1657-#include <cmath>
1658-
1659-namespace me = mir::examples;
1660-namespace msh = mir::shell;
1661-namespace mg = mir::graphics;
1662-namespace mc = mir::compositor;
1663-namespace mi = mir::input;
1664-
1665-namespace
1666-{
1667-const int min_swipe_distance = 100; // How long must a swipe be to act on?
1668-}
1669-
1670-me::WindowManager::WindowManager()
1671- : old_pinch_diam(0.0f), max_fingers(0)
1672-{
1673-}
1674-
1675-void me::WindowManager::set_focus_controller(std::shared_ptr<msh::FocusController> const& controller)
1676-{
1677- focus_controller = controller;
1678-}
1679-
1680-void me::WindowManager::set_display(std::shared_ptr<mg::Display> const& dpy)
1681-{
1682- display = dpy;
1683-}
1684-
1685-void me::WindowManager::set_compositor(std::shared_ptr<mc::Compositor> const& cptor)
1686-{
1687- compositor = cptor;
1688-}
1689-
1690-void me::WindowManager::set_input_scene(std::shared_ptr<mi::Scene> const& s)
1691-{
1692- input_scene = s;
1693-}
1694-
1695-void me::WindowManager::force_redraw()
1696-{
1697- // This is clumsy, but the only option our architecture allows us for now
1698- // Same hack as used in TouchspotController...
1699- input_scene->emit_scene_changed();
1700-}
1701-
1702-namespace
1703-{
1704-
1705-mir::geometry::Point average_pointer(MirTouchEvent const* tev)
1706-{
1707- using namespace mir;
1708- using namespace geometry;
1709-
1710- int x = 0, y = 0;
1711- int count = mir_touch_event_point_count(tev);
1712-
1713- for (int i = 0; i < count; i++)
1714- {
1715- x += mir_touch_event_axis_value(tev, i, mir_touch_axis_x);
1716- y += mir_touch_event_axis_value(tev, i, mir_touch_axis_y);
1717- }
1718-
1719- x /= count;
1720- y /= count;
1721-
1722- return Point{x, y};
1723-}
1724-
1725-float measure_pinch(MirTouchEvent const* tev,
1726- mir::geometry::Displacement& dir)
1727-{
1728- int count = mir_touch_event_point_count(tev);
1729- int max = 0;
1730-
1731- for (int i = 0; i < count; i++)
1732- {
1733- for (int j = 0; j < i; j++)
1734- {
1735- int dx = mir_touch_event_axis_value(tev, i, mir_touch_axis_x) -
1736- mir_touch_event_axis_value(tev, j, mir_touch_axis_x);
1737- int dy = mir_touch_event_axis_value(tev, i, mir_touch_axis_y) -
1738- mir_touch_event_axis_value(tev, j, mir_touch_axis_y);
1739-
1740- int sqr = dx*dx + dy*dy;
1741-
1742- if (sqr > max)
1743- {
1744- max = sqr;
1745- dir = mir::geometry::Displacement{dx, dy};
1746- }
1747- }
1748- }
1749-
1750- return sqrtf(max); // return pinch diameter
1751-}
1752-
1753-} // namespace
1754-
1755-
1756-void me::WindowManager::toggle(ColourEffect which)
1757-{
1758- colour_effect = (colour_effect == which) ? none : which;
1759- me::DemoCompositor::for_each([this](me::DemoCompositor& c)
1760- {
1761- c.set_colour_effect(colour_effect);
1762- });
1763- force_redraw();
1764-}
1765-
1766-void me::WindowManager::save_edges(scene::Surface& surf,
1767- geometry::Point const& p)
1768-{
1769- int width = surf.size().width.as_int();
1770- int height = surf.size().height.as_int();
1771-
1772- int left = surf.top_left().x.as_int();
1773- int right = left + width;
1774- int top = surf.top_left().y.as_int();
1775- int bottom = top + height;
1776-
1777- int leftish = left + width/3;
1778- int rightish = right - width/3;
1779- int topish = top + height/3;
1780- int bottomish = bottom - height/3;
1781-
1782- int click_x = p.x.as_int();
1783- xedge = (click_x <= leftish) ? left_edge :
1784- (click_x >= rightish) ? right_edge :
1785- hmiddle;
1786-
1787- int click_y = p.y.as_int();
1788- yedge = (click_y <= topish) ? top_edge :
1789- (click_y >= bottomish) ? bottom_edge :
1790- vmiddle;
1791-}
1792-
1793-void me::WindowManager::resize(scene::Surface& surf,
1794- geometry::Point const& cursor) const
1795-{
1796- int width = surf.size().width.as_int();
1797- int height = surf.size().height.as_int();
1798-
1799- int left = surf.top_left().x.as_int();
1800- int right = left + width;
1801- int top = surf.top_left().y.as_int();
1802- int bottom = top + height;
1803-
1804- geometry::Displacement drag = cursor - old_cursor;
1805- int dx = drag.dx.as_int();
1806- int dy = drag.dy.as_int();
1807-
1808- if (xedge == left_edge && dx < width)
1809- left = old_pos.x.as_int() + dx;
1810- else if (xedge == right_edge)
1811- right = old_pos.x.as_int() + old_size.width.as_int() + dx;
1812-
1813- if (yedge == top_edge && dy < height)
1814- top = old_pos.y.as_int() + dy;
1815- else if (yedge == bottom_edge)
1816- bottom = old_pos.y.as_int() + old_size.height.as_int() + dy;
1817-
1818- surf.move_to({left, top});
1819- surf.resize({right-left, bottom-top});
1820-}
1821-
1822-bool me::WindowManager::handle_key_event(MirKeyboardEvent const* kev)
1823-{
1824- static bool display_off = false;
1825-
1826- if (mir_keyboard_event_action(kev) != mir_keyboard_action_down)
1827- return false;
1828-
1829- auto modifiers = mir_keyboard_event_modifiers(kev);
1830- auto scan_code = mir_keyboard_event_scan_code(kev);
1831-
1832- if (modifiers & mir_input_event_modifier_alt &&
1833- scan_code == KEY_TAB) // TODO: Use keycode once we support keymapping on the server side
1834- {
1835- focus_controller->focus_next_session();
1836- if (auto const surface = focus_controller->focused_surface())
1837- focus_controller->raise({surface});
1838- return true;
1839- }
1840- else if (modifiers & mir_input_event_modifier_alt &&
1841- scan_code == KEY_GRAVE)
1842- {
1843- if (auto const prev = focus_controller->focused_surface())
1844- {
1845- auto const app = focus_controller->focused_session();
1846- auto const next = app->surface_after(prev);
1847- focus_controller->set_focus_to(app, next);
1848- focus_controller->raise({next});
1849- }
1850- return true;
1851- }
1852- else if (modifiers & mir_input_event_modifier_alt &&
1853- scan_code == KEY_F4)
1854- {
1855- auto const surf = focus_controller->focused_surface();
1856- if (surf)
1857- surf->request_client_surface_close();
1858- return true;
1859- }
1860- else if ((modifiers & mir_input_event_modifier_alt &&
1861- scan_code == KEY_P) ||
1862- (scan_code == KEY_POWER))
1863- {
1864- compositor->stop();
1865- auto conf = display->configuration();
1866- MirPowerMode new_power_mode = display_off ?
1867- mir_power_mode_on : mir_power_mode_off;
1868- conf->for_each_output(
1869- [&](mg::UserDisplayConfigurationOutput& output) -> void
1870- {
1871- output.power_mode = new_power_mode;
1872- });
1873- display_off = !display_off;
1874-
1875- display->configure(*conf.get());
1876- if (!display_off)
1877- compositor->start();
1878- return true;
1879- }
1880- else if ((modifiers & mir_input_event_modifier_alt) &&
1881- (modifiers & mir_input_event_modifier_ctrl) &&
1882- (scan_code == KEY_ESC))
1883- {
1884- std::abort();
1885- return true;
1886- }
1887- else if ((modifiers & mir_input_event_modifier_alt) &&
1888- (modifiers & mir_input_event_modifier_ctrl) &&
1889- (scan_code == KEY_L) &&
1890- focus_controller)
1891- {
1892- auto const app = focus_controller->focused_session();
1893- if (app)
1894- {
1895- app->set_lifecycle_state(mir_lifecycle_state_will_suspend);
1896- }
1897- }
1898- else if ((modifiers & mir_input_event_modifier_alt) &&
1899- (modifiers & mir_input_event_modifier_ctrl))
1900- {
1901- MirOrientation orientation = mir_orientation_normal;
1902- bool rotating = true;
1903- int mode_change = 0;
1904- bool preferred_mode = false;
1905- switch (scan_code)
1906- {
1907- case KEY_UP: orientation = mir_orientation_normal; break;
1908- case KEY_DOWN: orientation = mir_orientation_inverted; break;
1909- case KEY_LEFT: orientation = mir_orientation_left; break;
1910- case KEY_RIGHT: orientation = mir_orientation_right; break;
1911- default: rotating = false; break;
1912- }
1913- switch (scan_code)
1914- {
1915- case KEY_MINUS: mode_change = -1; break;
1916- case KEY_EQUAL: mode_change = +1; break;
1917- case KEY_0: preferred_mode = true; break;
1918- default: break;
1919- }
1920-
1921- if (rotating || mode_change || preferred_mode)
1922- {
1923- auto conf = display->configuration();
1924- conf->for_each_output(
1925- [&](mg::UserDisplayConfigurationOutput& output) -> void
1926- {
1927- // Only apply changes to the monitor the cursor is on
1928- if (!output.extents().contains(old_cursor))
1929- return;
1930- if (rotating)
1931- output.orientation = orientation;
1932- if (preferred_mode)
1933- {
1934- output.current_mode_index =
1935- output.preferred_mode_index;
1936- }
1937- else if (mode_change)
1938- {
1939- size_t nmodes = output.modes.size();
1940- if (nmodes)
1941- output.current_mode_index =
1942- (output.current_mode_index + nmodes +
1943- mode_change) % nmodes;
1944- }
1945- });
1946-
1947- if (!rotating) compositor->stop();
1948- display->configure(*conf);
1949- if (!rotating) compositor->start();
1950- force_redraw();
1951- return true;
1952- }
1953- }
1954- else if ((scan_code == KEY_VOLUMEDOWN ||
1955- scan_code == KEY_VOLUMEUP) &&
1956- max_fingers == 1)
1957- {
1958- int delta = (scan_code == KEY_VOLUMEDOWN) ? -1 : +1;
1959- static const MirOrientation order[4] =
1960- {
1961- mir_orientation_normal,
1962- mir_orientation_right,
1963- mir_orientation_inverted,
1964- mir_orientation_left
1965- };
1966- compositor->stop();
1967- auto conf = display->configuration();
1968- conf->for_each_output(
1969- [&](mg::UserDisplayConfigurationOutput& output)
1970- {
1971- int i = 0;
1972- for (; i < 4; ++i)
1973- {
1974- if (output.orientation == order[i])
1975- break;
1976- }
1977- output.orientation = order[(i+4+delta) % 4];
1978- });
1979- display->configure(*conf.get());
1980- compositor->start();
1981- return true;
1982- }
1983- else if (modifiers & mir_input_event_modifier_meta &&
1984- scan_code == KEY_N)
1985- {
1986- toggle(inverse);
1987- return true;
1988- }
1989- else if (modifiers & mir_input_event_modifier_meta &&
1990- scan_code == KEY_C)
1991- {
1992- toggle(contrast);
1993- return true;
1994- }
1995- return false;
1996-}
1997-
1998-
1999-bool me::WindowManager::handle_pointer_event(MirPointerEvent const* pev)
2000-{
2001- bool handled = false;
2002-
2003- geometry::Point cursor{mir_pointer_event_axis_value(pev, mir_pointer_axis_x),
2004- mir_pointer_event_axis_value(pev, mir_pointer_axis_y)};
2005- auto action = mir_pointer_event_action(pev);
2006- auto modifiers = mir_pointer_event_modifiers(pev);
2007- auto vscroll = mir_pointer_event_axis_value(pev, mir_pointer_axis_vscroll);
2008- auto primary_button_pressed = mir_pointer_event_button_state(pev, mir_pointer_button_primary);
2009- auto tertiary_button_pressed = mir_pointer_event_button_state(pev, mir_pointer_button_tertiary);
2010-
2011- float new_zoom_mag = 0.0f; // zero means unchanged
2012-
2013- if (modifiers & mir_input_event_modifier_meta &&
2014- action == mir_pointer_action_motion &&
2015- vscroll != 0.0f)
2016- {
2017- zoom_exponent += vscroll;
2018-
2019- // Negative exponents do work too, but disable them until
2020- // there's a clear edge to the desktop.
2021- if (zoom_exponent < 0)
2022- zoom_exponent = 0;
2023-
2024- new_zoom_mag = powf(1.2f, zoom_exponent);
2025- handled = true;
2026- }
2027-
2028- me::DemoCompositor::for_each(
2029- [new_zoom_mag,&cursor](me::DemoCompositor& c)
2030- {
2031- if (new_zoom_mag > 0.0f)
2032- c.zoom(new_zoom_mag);
2033- c.on_cursor_movement(cursor);
2034- });
2035-
2036- if (zoom_exponent || new_zoom_mag)
2037- force_redraw();
2038-
2039- auto const surf = focus_controller->focused_surface();
2040- if (surf &&
2041- (modifiers & mir_input_event_modifier_alt) && (primary_button_pressed || tertiary_button_pressed))
2042- {
2043- // Start of a gesture: When the latest finger/button goes down
2044- if (action == mir_pointer_action_button_down)
2045- {
2046- click = cursor;
2047- save_edges(*surf, click);
2048- handled = true;
2049- }
2050- else if (action == mir_pointer_action_motion)
2051- {
2052- geometry::Displacement drag = cursor - old_cursor;
2053-
2054- if (tertiary_button_pressed)
2055- { // Resize by mouse middle button
2056- resize(*surf, cursor);
2057- }
2058- else
2059- {
2060- surf->move_to(old_pos + drag);
2061- }
2062-
2063- handled = true;
2064- }
2065-
2066- old_pos = surf->top_left();
2067- old_size = surf->size();
2068- }
2069-
2070- if (surf &&
2071- (modifiers & mir_input_event_modifier_alt) &&
2072- action == mir_pointer_action_motion &&
2073- vscroll)
2074- {
2075- float alpha = surf->alpha();
2076- alpha += vscroll > 0.0f ? 0.1f : -0.1f;
2077- if (alpha < 0.0f)
2078- alpha = 0.0f;
2079- else if (alpha > 1.0f)
2080- alpha = 1.0f;
2081- surf->set_alpha(alpha);
2082- handled = true;
2083- }
2084-
2085- old_cursor = cursor;
2086- return handled;
2087-}
2088-
2089-namespace
2090-{
2091-bool any_touches_went_down(MirTouchEvent const* tev)
2092-{
2093- auto count = mir_touch_event_point_count(tev);
2094- for (unsigned i = 0; i < count; i++)
2095- {
2096- if (mir_touch_event_action(tev, i) == mir_touch_action_down)
2097- return true;
2098- }
2099- return false;
2100-}
2101-bool last_touch_released(MirTouchEvent const* tev)
2102-{
2103- auto count = mir_touch_event_point_count(tev);
2104- if (count > 1)
2105- return false;
2106- return mir_touch_event_action(tev, 0) == mir_touch_action_up;
2107-}
2108-}
2109-
2110-bool me::WindowManager::handle_touch_event(MirTouchEvent const* tev)
2111-{
2112- bool handled = false;
2113- geometry::Point cursor = average_pointer(tev);
2114-
2115- auto const& modifiers = mir_touch_event_modifiers(tev);
2116-
2117- int fingers = mir_touch_event_point_count(tev);
2118-
2119- if (fingers > max_fingers)
2120- max_fingers = fingers;
2121-
2122- auto const surf = focus_controller->focused_surface();
2123- if (surf &&
2124- (modifiers & mir_input_event_modifier_alt ||
2125- fingers >= 3))
2126- {
2127- geometry::Displacement pinch_dir;
2128- auto pinch_diam =
2129- measure_pinch(tev, pinch_dir);
2130-
2131- // Start of a gesture: When the latest finger/button goes down
2132- if (any_touches_went_down(tev))
2133- {
2134- click = cursor;
2135- save_edges(*surf, click);
2136- handled = true;
2137- }
2138- else if(max_fingers <= 3) // Avoid accidental movement
2139- {
2140- geometry::Displacement drag = cursor - old_cursor;
2141-
2142- surf->move_to(old_pos + drag);
2143-
2144- if (fingers == 3)
2145- { // Resize by pinch/zoom
2146- float diam_delta = pinch_diam - old_pinch_diam;
2147- /*
2148- * Resize vector (dx,dy) has length=diam_delta and
2149- * direction=pinch_dir, so solve for (dx,dy)...
2150- */
2151- float lenlen = diam_delta * diam_delta;
2152- int x = pinch_dir.dx.as_int();
2153- int y = pinch_dir.dy.as_int();
2154- int xx = x * x;
2155- int yy = y * y;
2156- int xxyy = xx + yy;
2157- int dx = sqrtf(lenlen * xx / xxyy);
2158- int dy = sqrtf(lenlen * yy / xxyy);
2159- if (diam_delta < 0.0f)
2160- {
2161- dx = -dx;
2162- dy = -dy;
2163- }
2164-
2165- int width = old_size.width.as_int() + dx;
2166- int height = old_size.height.as_int() + dy;
2167- surf->resize({width, height});
2168- }
2169-
2170- handled = true;
2171- }
2172-
2173- old_pos = surf->top_left();
2174- old_size = surf->size();
2175- old_pinch_diam = pinch_diam;
2176- }
2177-
2178- auto gesture_ended = last_touch_released(tev);
2179-
2180- if (max_fingers == 4 && gesture_ended)
2181- { // Four fingers released
2182- geometry::Displacement dir = cursor - click;
2183- if (abs(dir.dx.as_int()) >= min_swipe_distance)
2184- {
2185- focus_controller->focus_next_session();
2186- if (auto const surface = focus_controller->focused_surface())
2187- focus_controller->raise({surface});
2188- handled = true;
2189- }
2190- }
2191-
2192- if (fingers == 1 && gesture_ended)
2193- max_fingers = 0;
2194-
2195- old_cursor = cursor;
2196-
2197- /*
2198- * For now we reserve all 3 or 4 finger gestures for window manipulation.
2199- * Make sure clients don't receive spurious events in the process...
2200- */
2201- handled |= (max_fingers == 3 || max_fingers == 4);
2202-
2203- return handled;
2204-}
2205-
2206-bool me::WindowManager::handle(MirEvent const& event)
2207-{
2208- assert(focus_controller);
2209- assert(display);
2210- assert(compositor);
2211-
2212- if (mir_event_get_type(&event) != mir_event_type_input)
2213- return false;
2214- auto iev = mir_event_get_input_event(&event);
2215- auto input_type = mir_input_event_get_type(iev);
2216-
2217- if (input_type == mir_input_event_type_key)
2218- {
2219- return handle_key_event(mir_input_event_get_keyboard_event(iev));
2220- }
2221- else if (input_type == mir_input_event_type_pointer &&
2222- focus_controller)
2223- {
2224- return handle_pointer_event(mir_input_event_get_pointer_event(iev));
2225- }
2226- else if (input_type == mir_input_event_type_touch &&
2227- focus_controller)
2228- {
2229- return handle_touch_event(mir_input_event_get_touch_event(iev));
2230- }
2231-
2232-
2233- return false;
2234-}
2235
2236=== removed file 'playground/demo-shell/window_manager.h'
2237--- playground/demo-shell/window_manager.h 2017-07-28 17:00:43 +0000
2238+++ playground/demo-shell/window_manager.h 1970-01-01 00:00:00 +0000
2239@@ -1,97 +0,0 @@
2240-/*
2241- * Copyright © 2013 Canonical Ltd.
2242- *
2243- * This program is free software: you can redistribute it and/or modify it
2244- * under the terms of the GNU General Public License version 2 or 3,
2245- * as published by the Free Software Foundation.
2246- *
2247- * This program is distributed in the hope that it will be useful,
2248- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2249- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2250- * GNU General Public License for more details.
2251- *
2252- * You should have received a copy of the GNU General Public License
2253- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2254- *
2255- * Authored by: Robert Carr <robert.carr@canonical.com>
2256- */
2257-
2258-#ifndef MIR_EXAMPLES_WINDOW_MANAGER_H_
2259-#define MIR_EXAMPLES_WINDOW_MANAGER_H_
2260-
2261-#include "mir/input/event_filter.h"
2262-#include "mir/input/scene.h"
2263-#include "mir/geometry/displacement.h"
2264-#include "mir/geometry/size.h"
2265-#include "demo_renderer.h"
2266-
2267-#include <memory>
2268-
2269-namespace mir
2270-{
2271-namespace shell
2272-{
2273-class FocusController;
2274-}
2275-namespace graphics
2276-{
2277-class Display;
2278-}
2279-namespace compositor
2280-{
2281-class Compositor;
2282-}
2283-
2284-namespace scene { class Surface; }
2285-
2286-namespace examples
2287-{
2288-
2289-class WindowManager : public input::EventFilter
2290-{
2291-public:
2292- WindowManager();
2293- ~WindowManager() = default;
2294-
2295- void set_focus_controller(std::shared_ptr<shell::FocusController> const& focus_controller);
2296- void set_display(std::shared_ptr<graphics::Display> const& display);
2297- void set_compositor(std::shared_ptr<compositor::Compositor> const& compositor);
2298- void set_input_scene(std::shared_ptr<input::Scene> const& scene);
2299- void force_redraw();
2300-
2301- bool handle(MirEvent const& event) override;
2302-
2303-protected:
2304- WindowManager(const WindowManager&) = delete;
2305- WindowManager& operator=(const WindowManager&) = delete;
2306-
2307-private:
2308- std::shared_ptr<shell::FocusController> focus_controller;
2309- std::shared_ptr<graphics::Display> display;
2310- std::shared_ptr<compositor::Compositor> compositor;
2311- std::shared_ptr<input::Scene> input_scene;
2312-
2313- geometry::Point click;
2314- geometry::Point old_pos;
2315- geometry::Point old_cursor;
2316- geometry::Size old_size;
2317- float old_pinch_diam;
2318- int max_fingers; // Maximum number of fingers touched during gesture
2319- float zoom_exponent = 0.0f;
2320- ColourEffect colour_effect = none;
2321-
2322- void toggle(ColourEffect);
2323-
2324- enum {left_edge, hmiddle, right_edge} xedge = hmiddle;
2325- enum {top_edge, vmiddle, bottom_edge} yedge = vmiddle;
2326- void save_edges(scene::Surface& surf, geometry::Point const& p);
2327- void resize(scene::Surface& surf, geometry::Point const& cursor) const;
2328- bool handle_key_event(MirKeyboardEvent const* event);
2329- bool handle_touch_event(MirTouchEvent const* event);
2330- bool handle_pointer_event(MirPointerEvent const* event);
2331-};
2332-
2333-}
2334-} // namespace mir
2335-
2336-#endif // MIR_EXAMPLES_WINDOW_MANAGER_H_
2337
2338=== removed file 'playground/server_configuration.cpp'
2339--- playground/server_configuration.cpp 2017-07-28 17:00:43 +0000
2340+++ playground/server_configuration.cpp 1970-01-01 00:00:00 +0000
2341@@ -1,86 +0,0 @@
2342-/*
2343- * Copyright © 2013-2014 Canonical Ltd.
2344- *
2345- * This program is free software: you can redistribute it and/or modify
2346- * it under the terms of the GNU General Public License version 2 or 3 as
2347- * published by the Free Software Foundation.
2348- *
2349- * This program is distributed in the hope that it will be useful,
2350- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2351- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2352- * GNU General Public License for more details.
2353- *
2354- * You should have received a copy of the GNU General Public License
2355- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2356- *
2357- * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
2358- */
2359-
2360-#include "server_configuration.h"
2361-#include "mir/options/default_configuration.h"
2362-#include "mir/input/composite_event_filter.h"
2363-#include "mir/graphics/default_display_configuration_policy.h"
2364-#include "mir/main_loop.h"
2365-
2366-#include "server_example_display_configuration_policy.h"
2367-#include "server_example_input_event_filter.h"
2368-
2369-namespace me = mir::examples;
2370-namespace mg = mir::graphics;
2371-
2372-namespace
2373-{
2374-std::shared_ptr<mir::options::DefaultConfiguration> const& customize(
2375- std::shared_ptr<mir::options::DefaultConfiguration> const& opt)
2376-{
2377- opt->add_options()(me::display_config_opt,
2378- boost::program_options::value<std::string>()->
2379- default_value(me::clone_opt_val),
2380- me::display_config_descr);
2381-
2382- return opt;
2383-}
2384-}
2385-
2386-me::ServerConfiguration::ServerConfiguration(std::shared_ptr<options::DefaultConfiguration> const& configuration_options) :
2387- DefaultServerConfiguration(customize(configuration_options))
2388-{
2389-}
2390-
2391-me::ServerConfiguration::ServerConfiguration(int argc, char const** argv) :
2392- ServerConfiguration(std::make_shared<options::DefaultConfiguration>(argc, argv))
2393-{
2394-}
2395-
2396-std::shared_ptr<mg::DisplayConfigurationPolicy>
2397-me::ServerConfiguration::the_display_configuration_policy()
2398-{
2399- return display_configuration_policy(
2400- [this]() -> std::shared_ptr<mg::DisplayConfigurationPolicy>
2401- {
2402- auto display_config = the_options()->get<std::string>(me::display_config_opt);
2403-
2404- if (display_config == me::sidebyside_opt_val)
2405- return std::make_shared<mg::SideBySideDisplayConfigurationPolicy>();
2406- else if (display_config == me::single_opt_val)
2407- return std::make_shared<mg::SingleDisplayConfigurationPolicy>();
2408- else
2409- return DefaultServerConfiguration::the_display_configuration_policy();
2410- });
2411-}
2412-
2413-std::shared_ptr<mir::input::CompositeEventFilter>
2414-me::ServerConfiguration::the_composite_event_filter()
2415-{
2416- return composite_event_filter(
2417- [this]() -> std::shared_ptr<mir::input::CompositeEventFilter>
2418- {
2419- if (!quit_filter)
2420- quit_filter = std::make_shared<me::QuitFilter>([this] { the_main_loop()->stop(); });
2421-
2422- auto composite_filter = DefaultServerConfiguration::the_composite_event_filter();
2423- composite_filter->append(quit_filter);
2424-
2425- return composite_filter;
2426- });
2427-}
2428
2429=== removed file 'playground/server_configuration.h'
2430--- playground/server_configuration.h 2017-07-28 17:00:43 +0000
2431+++ playground/server_configuration.h 1970-01-01 00:00:00 +0000
2432@@ -1,49 +0,0 @@
2433-/*
2434- * Copyright © 2013-2014 Canonical Ltd.
2435- *
2436- * This program is free software: you can redistribute it and/or modify
2437- * it under the terms of the GNU General Public License version 2 or 3 as
2438- * published by the Free Software Foundation.
2439- *
2440- * This program is distributed in the hope that it will be useful,
2441- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2442- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2443- * GNU General Public License for more details.
2444- *
2445- * You should have received a copy of the GNU General Public License
2446- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2447- *
2448- * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
2449- */
2450-
2451-#ifndef MIR_EXAMPLES_SERVER_CONFIGURATION_H_
2452-#define MIR_EXAMPLES_SERVER_CONFIGURATION_H_
2453-
2454-#include "mir/default_server_configuration.h"
2455-
2456-namespace mir
2457-{
2458-namespace options
2459-{
2460-class DefaultConfiguration;
2461-}
2462-
2463-namespace examples
2464-{
2465-
2466-class ServerConfiguration : public DefaultServerConfiguration
2467-{
2468-public:
2469- ServerConfiguration(int argc, char const** argv);
2470- explicit ServerConfiguration(std::shared_ptr<options::DefaultConfiguration> const& configuration_options);
2471-
2472- std::shared_ptr<graphics::DisplayConfigurationPolicy> the_display_configuration_policy() override;
2473- std::shared_ptr<input::CompositeEventFilter> the_composite_event_filter() override;
2474-
2475-private:
2476- std::shared_ptr<input::EventFilter> quit_filter;
2477-};
2478-}
2479-}
2480-
2481-#endif /* MIR_EXAMPLES_SERVER_CONFIGURATION_H_ */
2482
2483=== removed file 'playground/server_example_display_configuration_policy.cpp'
2484--- playground/server_example_display_configuration_policy.cpp 2017-07-28 17:00:43 +0000
2485+++ playground/server_example_display_configuration_policy.cpp 1970-01-01 00:00:00 +0000
2486@@ -1,115 +0,0 @@
2487-/*
2488- * Copyright © 2014 Canonical Ltd.
2489- *
2490- * This program is free software: you can redistribute it and/or modify it
2491- * under the terms of the GNU General Public License version 2 or 3,
2492- * as published by the Free Software Foundation.
2493- *
2494- * This program is distributed in the hope that it will be useful,
2495- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2496- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2497- * GNU General Public License for more details.
2498- *
2499- * You should have received a copy of the GNU General Public License
2500- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2501- *
2502- * Authored By: Alan Griffiths <alan@octopull.co.uk>
2503- */
2504-
2505-#include "server_example_display_configuration_policy.h"
2506-#include "mir/graphics/default_display_configuration_policy.h"
2507-
2508-#include "mir/graphics/display_configuration.h"
2509-#include "mir/server.h"
2510-#include "mir/options/option.h"
2511-
2512-#include <algorithm>
2513-#include <unordered_map>
2514-#include <stdexcept>
2515-
2516-namespace geom = mir::geometry;
2517-namespace me = mir::examples;
2518-namespace mg = mir::graphics;
2519-
2520-///\example server_example_display_configuration_policy.cpp
2521-/// Demonstrate custom display configuration policies for "sidebyside" and "single"
2522-
2523-char const* const me::display_config_opt = "display-config";
2524-char const* const me::display_config_descr = "Display configuration [{clone,sidebyside,single}]";
2525-
2526-char const* const me::clone_opt_val = "clone";
2527-char const* const me::sidebyside_opt_val = "sidebyside";
2528-char const* const me::single_opt_val = "single";
2529-
2530-char const* const me::display_alpha_opt = "translucent";
2531-char const* const me::display_alpha_descr = "Select a display mode with alpha[{on,off}]";
2532-
2533-char const* const me::display_alpha_off = "off";
2534-char const* const me::display_alpha_on = "on";
2535-
2536-namespace
2537-{
2538-bool contains_alpha(MirPixelFormat format)
2539-{
2540- return (format == mir_pixel_format_abgr_8888 ||
2541- format == mir_pixel_format_argb_8888);
2542-}
2543-}
2544-
2545-me::PixelFormatSelector::PixelFormatSelector(std::shared_ptr<DisplayConfigurationPolicy> const& base_policy,
2546- bool with_alpha)
2547- : base_policy{base_policy},
2548- with_alpha{with_alpha}
2549-{}
2550-
2551-void me::PixelFormatSelector::apply_to(graphics::DisplayConfiguration & conf)
2552-{
2553- base_policy->apply_to(conf);
2554- conf.for_each_output(
2555- [&](graphics::UserDisplayConfigurationOutput& conf_output)
2556- {
2557- if (!conf_output.connected || !conf_output.used) return;
2558-
2559- auto const& pos = find_if(conf_output.pixel_formats.begin(),
2560- conf_output.pixel_formats.end(),
2561- [&](MirPixelFormat format) -> bool
2562- {
2563- return contains_alpha(format) == with_alpha;
2564- }
2565- );
2566-
2567- // keep the default settings if nothing was found
2568- if (pos == conf_output.pixel_formats.end())
2569- return;
2570-
2571- conf_output.current_format = *pos;
2572- });
2573-}
2574-
2575-void me::add_display_configuration_options_to(mir::Server& server)
2576-{
2577- // Add choice of monitor configuration
2578- server.add_configuration_option(
2579- me::display_config_opt, me::display_config_descr, me::clone_opt_val);
2580- server.add_configuration_option(
2581- me::display_alpha_opt, me::display_alpha_descr, me::display_alpha_off);
2582-
2583- server.wrap_display_configuration_policy(
2584- [&](std::shared_ptr<mg::DisplayConfigurationPolicy> const& wrapped)
2585- -> std::shared_ptr<mg::DisplayConfigurationPolicy>
2586- {
2587- auto const options = server.get_options();
2588- auto display_layout = options->get<std::string>(me::display_config_opt);
2589- auto with_alpha = options->get<std::string>(me::display_alpha_opt) == me::display_alpha_on;
2590-
2591- auto layout_selector = wrapped;
2592-
2593- if (display_layout == me::sidebyside_opt_val)
2594- layout_selector = std::make_shared<mg::SideBySideDisplayConfigurationPolicy>();
2595- else if (display_layout == me::single_opt_val)
2596- layout_selector = std::make_shared<mg::SingleDisplayConfigurationPolicy>();
2597-
2598- // Whatever the layout select a pixel format with requested alpha
2599- return std::make_shared<me::PixelFormatSelector>(layout_selector, with_alpha);
2600- });
2601-}
2602
2603=== removed file 'playground/server_example_display_configuration_policy.h'
2604--- playground/server_example_display_configuration_policy.h 2017-07-28 17:00:43 +0000
2605+++ playground/server_example_display_configuration_policy.h 1970-01-01 00:00:00 +0000
2606@@ -1,62 +0,0 @@
2607-/*
2608- * Copyright © 2014 Canonical Ltd.
2609- *
2610- * This program is free software: you can redistribute it and/or modify it
2611- * under the terms of the GNU General Public License version 2 or 3,
2612- * as published by the Free Software Foundation.
2613- *
2614- * This program is distributed in the hope that it will be useful,
2615- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2616- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2617- * GNU General Public License for more details.
2618- *
2619- * You should have received a copy of the GNU General Public License
2620- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2621- *
2622- * Authored By: Alan Griffiths <alan@octopull.co.uk>
2623- */
2624-
2625-#ifndef MIR_EXAMPLE_DISPLAY_CONFIGURATION_POLICY_H_
2626-#define MIR_EXAMPLE_DISPLAY_CONFIGURATION_POLICY_H_
2627-
2628-#include "mir/graphics/display_configuration_policy.h"
2629-
2630-#include <memory>
2631-
2632-namespace mir
2633-{
2634-class Server;
2635-
2636-namespace examples
2637-{
2638-extern char const* const display_config_opt;
2639-extern char const* const display_config_descr;
2640-extern char const* const clone_opt_val;
2641-extern char const* const sidebyside_opt_val;
2642-extern char const* const single_opt_val;
2643-extern char const* const display_alpha_opt;
2644-extern char const* const display_alpha_descr;
2645-extern char const* const display_alpha_off;
2646-extern char const* const display_alpha_on;
2647-
2648-/**
2649- * \brief Example of a DisplayConfigurationPolicy that tries to find
2650- * an opaque or transparent pixel format, or falls back to the default
2651- * if not found.
2652- */
2653-class PixelFormatSelector : public graphics::DisplayConfigurationPolicy
2654-{
2655-public:
2656- PixelFormatSelector(std::shared_ptr<graphics::DisplayConfigurationPolicy> const& base_policy,
2657- bool with_alpha);
2658- virtual void apply_to(graphics::DisplayConfiguration& conf);
2659-private:
2660- std::shared_ptr<graphics::DisplayConfigurationPolicy> const base_policy;
2661- bool const with_alpha;
2662-};
2663-
2664-void add_display_configuration_options_to(Server& server);
2665-}
2666-}
2667-
2668-#endif /* MIR_EXAMPLE_DISPLAY_CONFIGURATION_POLICY_H_ */
2669
2670=== removed file 'src/include/server/mir/compositor/decoration.h'
2671--- src/include/server/mir/compositor/decoration.h 2017-07-28 17:00:43 +0000
2672+++ src/include/server/mir/compositor/decoration.h 1970-01-01 00:00:00 +0000
2673@@ -1,38 +0,0 @@
2674-/*
2675- * Copyright © 2015 Canonical Ltd.
2676- *
2677- * This program is free software: you can redistribute it and/or modify it
2678- * under the terms of the GNU General Public License version 2 or 3,
2679- * as published by the Free Software Foundation.
2680- *
2681- * This program is distributed in the hope that it will be useful,
2682- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2683- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2684- * GNU General Public License for more details.
2685- *
2686- * You should have received a copy of the GNU General Public License
2687- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2688- *
2689- * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
2690- */
2691-
2692-#ifndef MIR_COMPOSITOR_DECORATION_H_
2693-#define MIR_COMPOSITOR_DECORATION_H_
2694-
2695-#include <string>
2696-
2697-namespace mir { namespace compositor {
2698-
2699-struct Decoration
2700-{
2701- enum class Type {none, surface} type;
2702- std::string name;
2703-
2704- Decoration() : type{Type::none} {}
2705- Decoration(Type t, std::string const& n) : type{t}, name{n} {}
2706- operator bool() const { return type != Type::none; }
2707-};
2708-
2709-} } // namespace mir::compositor
2710-
2711-#endif // MIR_COMPOSITOR_DECORATION_H_
2712
2713=== modified file 'src/server/scene/basic_surface.cpp'
2714--- src/server/scene/basic_surface.cpp 2017-07-28 17:00:43 +0000
2715+++ src/server/scene/basic_surface.cpp 2017-08-31 11:31:49 +0000
2716@@ -289,12 +289,6 @@
2717 observers.moved_to(top_left);
2718 }
2719
2720-float ms::BasicSurface::alpha() const
2721-{
2722- std::unique_lock<std::mutex> lk(guard);
2723- return surface_alpha;
2724-}
2725-
2726 void ms::BasicSurface::set_hidden(bool hide)
2727 {
2728 {
2729
2730=== modified file 'src/server/scene/basic_surface.h'
2731--- src/server/scene/basic_surface.h 2017-07-28 17:00:43 +0000
2732+++ src/server/scene/basic_surface.h 2017-08-31 11:31:49 +0000
2733@@ -79,7 +79,7 @@
2734
2735 std::string name() const override;
2736 void move_to(geometry::Point const& top_left) override;
2737- float alpha() const override;
2738+
2739 void set_hidden(bool is_hidden);
2740
2741 geometry::Size size() const override;
2742
2743=== modified file 'src/server/scene/surface_stack.cpp'
2744--- src/server/scene/surface_stack.cpp 2017-07-28 17:00:43 +0000
2745+++ src/server/scene/surface_stack.cpp 2017-08-31 11:31:49 +0000
2746@@ -23,7 +23,6 @@
2747 #include "mir/scene/surface.h"
2748 #include "mir/scene/scene_report.h"
2749 #include "mir/compositor/scene_element.h"
2750-#include "mir/compositor/decoration.h"
2751 #include "mir/graphics/renderable.h"
2752
2753 #include <boost/throw_exception.hpp>
2754@@ -73,11 +72,6 @@
2755 tracker->occluded_in(cid);
2756 }
2757
2758- std::unique_ptr<mc::Decoration> decoration() const override
2759- {
2760- return std::make_unique<mc::Decoration>(mc::Decoration::Type::surface, surface_name);
2761- }
2762-
2763 private:
2764 std::shared_ptr<mg::Renderable> const renderable_;
2765 std::shared_ptr<ms::RenderingTracker> const tracker;
2766@@ -108,11 +102,6 @@
2767 {
2768 }
2769
2770- std::unique_ptr<mc::Decoration> decoration() const override
2771- {
2772- return std::make_unique<mc::Decoration>();
2773- }
2774-
2775 private:
2776 std::shared_ptr<mg::Renderable> const renderable_;
2777 };
2778
2779=== modified file 'tests/include/mir/test/doubles/stub_scene_element.h'
2780--- tests/include/mir/test/doubles/stub_scene_element.h 2017-07-28 17:00:43 +0000
2781+++ tests/include/mir/test/doubles/stub_scene_element.h 2017-08-31 11:31:49 +0000
2782@@ -20,7 +20,6 @@
2783 #define MIR_TEST_DOUBLES_STUB_SCENE_ELEMENT_H_
2784
2785 #include "mir/compositor/scene_element.h"
2786-#include "mir/compositor/decoration.h"
2787 #include "stub_renderable.h"
2788
2789 namespace mir
2790@@ -56,11 +55,6 @@
2791 {
2792 }
2793
2794- std::unique_ptr<compositor::Decoration> decoration() const override
2795- {
2796- return nullptr;
2797- }
2798-
2799 private:
2800 std::shared_ptr<graphics::Renderable> const renderable_;
2801 };
2802
2803=== modified file 'tests/include/mir/test/doubles/stub_scene_surface.h'
2804--- tests/include/mir/test/doubles/stub_scene_surface.h 2017-07-28 17:00:43 +0000
2805+++ tests/include/mir/test/doubles/stub_scene_surface.h 2017-08-31 11:31:49 +0000
2806@@ -53,7 +53,6 @@
2807 graphics::RenderableList generate_renderables(compositor::CompositorID) const override { return {}; }
2808 int buffers_ready_for_compositor(void const*) const override { return 0; }
2809
2810- float alpha() const override { return 0.0f;}
2811 MirWindowType type() const override { return mir_window_type_normal; }
2812 MirWindowState state() const override { return mir_window_state_unknown; }
2813
2814
2815=== modified file 'tests/mir_test_framework/stub_surface.cpp'
2816--- tests/mir_test_framework/stub_surface.cpp 2017-07-28 17:00:43 +0000
2817+++ tests/mir_test_framework/stub_surface.cpp 2017-08-31 11:31:49 +0000
2818@@ -29,11 +29,6 @@
2819 {
2820 }
2821
2822-float mtd::StubSurface::alpha() const
2823-{
2824- return 0;
2825-}
2826-
2827 mir::geometry::Size mtd::StubSurface::size() const
2828 {
2829 return {};
2830
2831=== modified file 'tests/unit-tests/CMakeLists.txt'
2832--- tests/unit-tests/CMakeLists.txt 2017-05-08 03:04:26 +0000
2833+++ tests/unit-tests/CMakeLists.txt 2017-08-31 11:31:49 +0000
2834@@ -122,7 +122,6 @@
2835
2836 exampleserverconfig
2837 mirdraw
2838- demo-shell
2839 mircommon
2840 client_platform_common
2841 server_platform_common
2842@@ -166,7 +165,6 @@
2843
2844 exampleserverconfig
2845 mirdraw
2846- demo-shell
2847 mircommon
2848 client_platform_common
2849
2850
2851=== modified file 'tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp'
2852--- tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp 2017-07-28 17:00:43 +0000
2853+++ tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp 2017-08-31 11:31:49 +0000
2854@@ -18,7 +18,6 @@
2855
2856 #include "src/server/compositor/default_display_buffer_compositor.h"
2857 #include "mir/compositor/display_buffer_compositor.h"
2858-#include "mir/compositor/decoration.h"
2859 #include "src/server/report/null_report_factory.h"
2860 #include "mir/compositor/scene.h"
2861 #include "mir/renderer/renderer.h"
2862@@ -74,11 +73,6 @@
2863 {
2864 }
2865
2866- std::unique_ptr<mc::Decoration> decoration() const override
2867- {
2868- return nullptr;
2869- }
2870-
2871 private:
2872 std::shared_ptr<mg::Renderable> const renderable_;
2873 };
2874@@ -346,7 +340,6 @@
2875 }
2876
2877 MOCK_CONST_METHOD0(renderable, std::shared_ptr<mir::graphics::Renderable>());
2878- MOCK_CONST_METHOD0(decoration, std::unique_ptr<mc::Decoration>());
2879 MOCK_METHOD0(rendered, void());
2880 MOCK_METHOD0(occluded, void());
2881 };
2882
2883=== modified file 'tests/unit-tests/scene/test_basic_surface.cpp'
2884--- tests/unit-tests/scene/test_basic_surface.cpp 2017-07-28 17:00:43 +0000
2885+++ tests/unit-tests/scene/test_basic_surface.cpp 2017-08-31 11:31:49 +0000
2886@@ -229,24 +229,10 @@
2887 EXPECT_EQ(trans, got);
2888 }
2889
2890-TEST_F(BasicSurfaceTest, test_surface_set_alpha_notifies_changes)
2891-{
2892- using namespace testing;
2893- EXPECT_CALL(mock_callback, call())
2894- .Times(1);
2895-
2896- surface.add_observer(observer);
2897-
2898- float alpha = 0.5f;
2899- surface.set_alpha(0.5f);
2900- EXPECT_THAT(alpha, FloatEq(surface.alpha()));
2901-}
2902-
2903 TEST_F(BasicSurfaceTest, test_surface_is_opaque_by_default)
2904 {
2905 using namespace testing;
2906
2907- EXPECT_THAT(1.0f, FloatEq(surface.alpha()));
2908 auto renderables = surface.generate_renderables(compositor_id);
2909 ASSERT_THAT(renderables.size(), testing::Eq(1));
2910 EXPECT_FALSE(renderables[0]->shaped());
2911
2912=== modified file 'tests/unit-tests/scene/test_surface.cpp'
2913--- tests/unit-tests/scene/test_surface.cpp 2017-07-28 17:00:43 +0000
2914+++ tests/unit-tests/scene/test_surface.cpp 2017-08-31 11:31:49 +0000
2915@@ -331,27 +331,6 @@
2916 }
2917 }
2918
2919-TEST_F(SurfaceCreation, test_surface_set_alpha)
2920-{
2921- using namespace testing;
2922-
2923- float alpha = 0.5f;
2924-
2925- surface.set_alpha(alpha);
2926- EXPECT_FLOAT_EQ(alpha, surface.alpha());
2927- auto renderables = surface.generate_renderables(nullptr);
2928- ASSERT_THAT(renderables.size(), Ge(1));
2929- EXPECT_FLOAT_EQ(alpha, renderables[0]->alpha());
2930-
2931- alpha = 0.1;
2932-
2933- surface.set_alpha(alpha);
2934- EXPECT_FLOAT_EQ(alpha, surface.alpha());
2935- renderables = surface.generate_renderables(nullptr);
2936- ASSERT_THAT(renderables.size(), Ge(1));
2937- EXPECT_FLOAT_EQ(alpha, renderables[0]->alpha());
2938-}
2939-
2940 TEST_F(SurfaceCreation, consume_calls_send_event)
2941 {
2942 using namespace testing;
2943
2944=== modified file 'tests/unit-tests/scene/test_surface_stack.cpp'
2945--- tests/unit-tests/scene/test_surface_stack.cpp 2017-07-28 17:00:43 +0000
2946+++ tests/unit-tests/scene/test_surface_stack.cpp 2017-08-31 11:31:49 +0000
2947@@ -22,7 +22,6 @@
2948 #include "mir/scene/observer.h"
2949 #include "mir/scene/surface_creation_parameters.h"
2950 #include "mir/compositor/scene_element.h"
2951-#include "mir/compositor/decoration.h"
2952 #include "src/server/report/null_report_factory.h"
2953 #include "src/server/scene/basic_surface.h"
2954 #include "src/server/compositor/stream.h"
2955@@ -226,63 +225,6 @@
2956 SceneElementForStream(stub_buffer_stream2)));
2957 }
2958
2959-TEST_F(SurfaceStack, decor_name_is_surface_name)
2960-{
2961- using namespace testing;
2962-
2963- ms::SurfaceStack stack{report};
2964- auto surface = std::make_shared<ms::BasicSurface>(
2965- std::string("Mary had a little lamb"),
2966- geom::Rectangle{{},{}},
2967- mir_pointer_unconfined,
2968- std::list<ms::StreamInfo> { { std::make_shared<mtd::StubBufferStream>(), {}, {} } },
2969- std::shared_ptr<mg::CursorImage>(),
2970- report);
2971- stack.add_surface(surface, default_params.input_mode);
2972- surface->configure(mir_window_attrib_visibility,
2973- mir_window_visibility_exposed);
2974-
2975- auto elements = stack.scene_elements_for(compositor_id);
2976- ASSERT_EQ(1, elements.size());
2977-
2978- auto& element = elements.front();
2979-
2980- auto decor = element->decoration();
2981- ASSERT_THAT(decor, Ne(nullptr));
2982- EXPECT_EQ(mc::Decoration::Type::surface, decor->type);
2983- EXPECT_EQ("Mary had a little lamb", decor->name);
2984-}
2985-
2986-TEST_F(SurfaceStack, gets_surface_renames)
2987-{
2988- using namespace testing;
2989-
2990- ms::SurfaceStack stack{report};
2991- auto surface = std::make_shared<ms::BasicSurface>(
2992- std::string("username@hostname: /"),
2993- geom::Rectangle{{},{}},
2994- mir_pointer_unconfined,
2995- std::list<ms::StreamInfo> { { std::make_shared<mtd::StubBufferStream>(), {}, {} } },
2996- std::shared_ptr<mg::CursorImage>(),
2997- report);
2998- stack.add_surface(surface, default_params.input_mode);
2999- surface->configure(mir_window_attrib_visibility,
3000- mir_window_visibility_exposed);
3001-
3002- // (change directory in shell app)
3003- surface->rename("username@hostname: ~/Documents");
3004-
3005- auto elements = stack.scene_elements_for(compositor_id);
3006- ASSERT_EQ(1, elements.size());
3007-
3008- auto& element = elements.front();
3009-
3010- auto decor = element->decoration();
3011- ASSERT_THAT(decor, Ne(nullptr));
3012- EXPECT_EQ(mc::Decoration::Type::surface, decor->type);
3013- EXPECT_EQ("username@hostname: ~/Documents", decor->name);
3014-}
3015-
3016 TEST_F(SurfaceStack, scene_counts_pending_accurately)
3017 {
3018 using namespace testing;

Subscribers

People subscribed via source and target branches