Mir

Merge lp:~mir-team/mir/trunk-0.1.7 into lp:mir/0.1

Proposed by kevin gunn
Status: Merged
Merged at revision: 1179
Proposed branch: lp:~mir-team/mir/trunk-0.1.7
Merge into: lp:mir/0.1
Diff against target: 12893 lines (+4671/-2634)
200 files modified
3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.cpp (+8/-0)
CMakeLists.txt (+1/-1)
debian/changelog (+56/-0)
debian/control (+2/-2)
debian/libmirserver17.install (+1/-1)
debian/rules (+5/-3)
examples/CMakeLists.txt (+0/-1)
examples/demo-shell/CMakeLists.txt (+1/-0)
examples/demo-shell/demo_renderer.cpp (+33/-0)
examples/demo-shell/demo_renderer.h (+39/-0)
examples/demo-shell/demo_shell.cpp (+21/-2)
examples/demo-shell/window_manager.cpp (+10/-24)
examples/eglplasma.c (+9/-7)
examples/image_renderer.cpp (+1/-0)
examples/pixel_format_selector.cpp (+2/-7)
examples/render_overlays.cpp (+92/-21)
examples/render_surfaces.cpp (+32/-5)
examples/scroll.cpp (+62/-41)
examples/server_configuration.cpp (+15/-26)
include/platform/mir/graphics/display_configuration.h (+27/-7)
include/platform/mir/graphics/overlapping_output_grouping.h (+3/-7)
include/platform/mir/graphics/renderable.h (+39/-1)
include/platform/mir/options/configuration.h (+0/-1)
include/server/mir/compositor/buffer_stream.h (+2/-1)
include/server/mir/compositor/compositing_criteria.h (+0/-52)
include/server/mir/compositor/display_buffer_compositor.h (+4/-2)
include/server/mir/compositor/gl_renderer.h (+32/-6)
include/server/mir/compositor/renderer.h (+6/-2)
include/server/mir/compositor/scene.h (+3/-4)
include/server/mir/frontend/screencast.h (+3/-1)
include/server/mir/shell/session.h (+0/-1)
include/shared/mir_toolkit/client_types.h (+23/-3)
include/shared/testdraw/draw_pattern_checkered-inl.h (+3/-3)
include/shared/testdraw/graphics_region_factory.h (+4/-4)
include/shared/testdraw/patterns.h (+3/-3)
include/test/mir_test_doubles/fake_renderable.h (+39/-17)
include/test/mir_test_doubles/mock_android_native_buffer.h (+9/-0)
include/test/mir_test_doubles/mock_buffer_bundle.h (+1/-0)
include/test/mir_test_doubles/mock_buffer_stream.h (+1/-0)
include/test/mir_test_doubles/mock_compositing_criteria.h (+0/-45)
include/test/mir_test_doubles/mock_display_device.h (+6/-3)
include/test/mir_test_doubles/mock_gl.h (+3/-2)
include/test/mir_test_doubles/mock_render_function.h (+40/-0)
include/test/mir_test_doubles/mock_render_function.h.moved (+40/-0)
include/test/mir_test_doubles/mock_renderable.h (+14/-1)
include/test/mir_test_doubles/mock_renderer.h (+2/-2)
include/test/mir_test_doubles/mock_scene.h (+48/-0)
include/test/mir_test_doubles/mock_screencast.h (+4/-2)
include/test/mir_test_doubles/mock_swapping_gl_context.h (+39/-0)
include/test/mir_test_doubles/null_display_configuration.h (+1/-1)
include/test/mir_test_doubles/null_screencast.h (+3/-1)
include/test/mir_test_doubles/stub_buffer.h (+16/-4)
include/test/mir_test_doubles/stub_buffer_stream.h (+2/-0)
include/test/mir_test_doubles/stub_display_configuration.h (+6/-1)
include/test/mir_test_doubles/stub_display_device.h (+5/-2)
include/test/mir_test_doubles/stub_renderable.h (+27/-2)
include/test/mir_test_doubles/stub_renderer.h (+2/-2)
include/test/mir_test_doubles/stub_swapping_gl_context.h (+39/-0)
src/client/CMakeLists.txt (+1/-0)
src/client/android/CMakeLists.txt (+9/-2)
src/client/mesa/CMakeLists.txt (+9/-2)
src/client/mir_screencast.cpp (+20/-23)
src/client/mir_screencast.h (+4/-2)
src/client/mir_screencast_api.cpp (+9/-19)
src/client/mir_surface.h (+0/-2)
src/platform/graphics/CMakeLists.txt (+1/-0)
src/platform/graphics/android/CMakeLists.txt (+10/-2)
src/platform/graphics/android/android_display.cpp (+8/-0)
src/platform/graphics/android/android_display_configuration.cpp (+4/-5)
src/platform/graphics/android/android_display_configuration.h (+1/-4)
src/platform/graphics/android/display_buffer.cpp (+10/-16)
src/platform/graphics/android/display_buffer.h (+1/-1)
src/platform/graphics/android/display_device.h (+6/-3)
src/platform/graphics/android/fb_device.cpp (+15/-14)
src/platform/graphics/android/fb_device.h (+5/-3)
src/platform/graphics/android/gl_context.cpp (+12/-0)
src/platform/graphics/android/gl_context.h (+15/-12)
src/platform/graphics/android/hwc_device.cpp (+96/-57)
src/platform/graphics/android/hwc_device.h (+27/-5)
src/platform/graphics/android/hwc_fb_device.cpp (+50/-30)
src/platform/graphics/android/hwc_fb_device.h (+7/-3)
src/platform/graphics/android/hwc_layerlist.cpp (+84/-90)
src/platform/graphics/android/hwc_layerlist.h (+21/-30)
src/platform/graphics/android/hwc_layers.cpp (+41/-11)
src/platform/graphics/android/hwc_layers.h (+7/-4)
src/platform/graphics/android/real_hwc_wrapper.cpp (+53/-0)
src/platform/graphics/android/real_hwc_wrapper.h (+48/-0)
src/platform/graphics/android/resource_factory.cpp (+3/-1)
src/platform/graphics/display_configuration.cpp (+50/-0)
src/platform/graphics/mesa/CMakeLists.txt (+9/-3)
src/platform/graphics/mesa/cursor.cpp (+26/-15)
src/platform/graphics/mesa/cursor.h (+2/-1)
src/platform/graphics/mesa/display.cpp (+7/-1)
src/platform/graphics/mesa/linux_virtual_terminal.cpp (+6/-5)
src/platform/graphics/mesa/linux_virtual_terminal.h (+21/-0)
src/platform/graphics/mesa/native_platform.cpp (+48/-1)
src/platform/graphics/mesa/native_platform.h (+10/-0)
src/platform/graphics/mesa/platform.cpp (+39/-2)
src/platform/graphics/mesa/real_kms_display_configuration.cpp (+6/-34)
src/platform/graphics/mesa/real_kms_display_configuration.h (+1/-4)
src/platform/graphics/overlapping_output_grouping.cpp (+7/-8)
src/platform/options/default_configuration.cpp (+2/-5)
src/server/CMakeLists.txt (+1/-1)
src/server/compositor/buffer_bundle.h (+1/-0)
src/server/compositor/buffer_stream_surfaces.cpp (+5/-0)
src/server/compositor/buffer_stream_surfaces.h (+1/-0)
src/server/compositor/bypass.cpp (+13/-52)
src/server/compositor/bypass.h (+5/-9)
src/server/compositor/compositing_screencast.cpp (+14/-37)
src/server/compositor/compositing_screencast.h (+6/-4)
src/server/compositor/default_configuration.cpp (+7/-4)
src/server/compositor/default_display_buffer_compositor.cpp (+25/-8)
src/server/compositor/default_display_buffer_compositor.h (+2/-1)
src/server/compositor/default_display_buffer_compositor_factory.cpp (+2/-2)
src/server/compositor/gl_renderer.cpp (+45/-57)
src/server/compositor/gl_renderer_factory.cpp (+1/-1)
src/server/compositor/gl_renderer_factory.h (+1/-1)
src/server/compositor/multi_threaded_compositor.cpp (+42/-25)
src/server/compositor/multi_threaded_compositor.h (+5/-3)
src/server/compositor/occlusion.cpp (+12/-32)
src/server/compositor/occlusion.h (+4/-6)
src/server/compositor/rendering_operator.cpp (+9/-5)
src/server/compositor/rendering_operator.h (+5/-3)
src/server/compositor/screencast_display_buffer.cpp (+3/-2)
src/server/compositor/switching_bundle.cpp (+32/-19)
src/server/compositor/switching_bundle.h (+2/-0)
src/server/frontend/session_mediator.cpp (+31/-20)
src/server/graphics/default_configuration.cpp (+28/-31)
src/server/graphics/default_display_configuration_policy.cpp (+9/-10)
src/server/graphics/nested/nested_display.cpp (+43/-34)
src/server/graphics/nested/nested_display_configuration.cpp (+59/-39)
src/server/graphics/nested/nested_display_configuration.h (+1/-5)
src/server/graphics/offscreen/display.cpp (+6/-0)
src/server/graphics/offscreen/display_configuration.cpp (+5/-3)
src/server/graphics/offscreen/display_configuration.h (+1/-5)
src/server/input/default_configuration.cpp (+2/-2)
src/server/input/nested_input_relay.cpp (+34/-55)
src/server/scene/basic_surface.cpp (+26/-41)
src/server/scene/basic_surface.h (+9/-6)
src/server/scene/mediating_display_changer.cpp (+2/-7)
src/server/scene/surface_stack.cpp (+9/-11)
src/shared/CMakeLists.txt (+1/-0)
src/shared/protobuf/mir_protobuf.proto (+9/-1)
src/shared/testdraw/CMakeLists.txt (+2/-0)
src/shared/testdraw/android_graphics_region_factory.cpp (+6/-5)
src/shared/testdraw/mesa_graphics_region_factory.cpp (+5/-5)
src/shared/testdraw/patterns.cpp (+4/-4)
src/utils/screencast.cpp (+161/-76)
tests/CMakeLists.txt (+0/-1)
tests/acceptance-tests/test_client_input.cpp (+38/-0)
tests/acceptance-tests/test_client_screencast.cpp (+72/-39)
tests/acceptance-tests/test_server_shutdown.cpp (+2/-2)
tests/acceptance-tests/test_surfaces_with_output_id.cpp (+4/-10)
tests/integration-tests/client/test_client_render.cpp (+2/-2)
tests/integration-tests/client/test_screencast.cpp (+5/-1)
tests/integration-tests/graphics/android/test_buffer_integration.cpp (+2/-2)
tests/integration-tests/input/CMakeLists.txt (+1/-0)
tests/integration-tests/input/test_nested_input.cpp (+124/-0)
tests/integration-tests/test_session.cpp (+2/-2)
tests/integration-tests/test_surface_first_frame_sync.cpp (+3/-3)
tests/integration-tests/test_swapinterval.cpp (+2/-1)
tests/mir_test/display_config_matchers.cpp (+6/-3)
tests/mir_test_doubles/mock_gl.cpp (+6/-0)
tests/mir_test_framework/stubbed_server_configuration.cpp (+2/-2)
tests/unit-tests/client/test_mir_screencast.cpp (+91/-79)
tests/unit-tests/compositor/test_bypass.cpp (+55/-59)
tests/unit-tests/compositor/test_compositing_screencast.cpp (+31/-20)
tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp (+91/-81)
tests/unit-tests/compositor/test_gl_renderer.cpp (+31/-37)
tests/unit-tests/compositor/test_multi_threaded_compositor.cpp (+85/-33)
tests/unit-tests/compositor/test_occlusion.cpp (+24/-27)
tests/unit-tests/compositor/test_rendering_operator.cpp (+13/-13)
tests/unit-tests/compositor/test_screencast_display_buffer.cpp (+17/-0)
tests/unit-tests/draw/test_draw_patterns.cpp (+1/-1)
tests/unit-tests/frontend/test_session_mediator.cpp (+1/-9)
tests/unit-tests/graphics/android/CMakeLists.txt (+1/-0)
tests/unit-tests/graphics/android/hwc_struct_helpers.h (+16/-3)
tests/unit-tests/graphics/android/test_android_fb.cpp (+21/-29)
tests/unit-tests/graphics/android/test_fb_device.cpp (+25/-16)
tests/unit-tests/graphics/android/test_hwc_common_device.cpp (+18/-1)
tests/unit-tests/graphics/android/test_hwc_device.cpp (+528/-117)
tests/unit-tests/graphics/android/test_hwc_display.cpp (+5/-23)
tests/unit-tests/graphics/android/test_hwc_fb_device.cpp (+88/-51)
tests/unit-tests/graphics/android/test_hwc_layerlist.cpp (+36/-196)
tests/unit-tests/graphics/android/test_hwc_layers.cpp (+122/-85)
tests/unit-tests/graphics/android/test_hwc_wrapper.cpp (+119/-0)
tests/unit-tests/graphics/mesa/test_cursor.cpp (+93/-5)
tests/unit-tests/graphics/mesa/test_display_multi_monitor.cpp (+27/-37)
tests/unit-tests/graphics/mesa/test_linux_virtual_terminal.cpp (+175/-11)
tests/unit-tests/graphics/mesa/test_native_platform.cpp (+60/-0)
tests/unit-tests/graphics/mesa/test_overlapping_output_grouping.cpp (+4/-7)
tests/unit-tests/graphics/nested/test_nested_display_configuration.cpp (+20/-68)
tests/unit-tests/graphics/test_default_display_configuration_policy.cpp (+42/-38)
tests/unit-tests/graphics/test_display.cpp (+34/-0)
tests/unit-tests/graphics/test_display_configuration.cpp (+41/-0)
tests/unit-tests/scene/test_basic_surface.cpp (+2/-28)
tests/unit-tests/scene/test_surface.cpp (+0/-1)
tests/unit-tests/scene/test_surface_stack.cpp (+83/-113)
tests/unit-tests/test_udev_wrapper.cpp (+3/-1)
tools/install_on_android.sh (+1/-1)
To merge this branch: bzr merge lp:~mir-team/mir/trunk-0.1.7
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Mir development team Pending
Review via email: mp+211132@code.launchpad.net

Commit message

Merge latest upstream release 0.1.7 (development-branch r1473)

To post a comment you must log in.
Revision history for this message
kevin gunn (kgunn72) wrote :

Did you test your feature/code change/bug fix ? what device(s) ?
- code has been run through CI testing on lp:mir/devel, running on desktop, n10, n4 & n7

Did you break mir server API or ABI and have the relevant bumps to .so and debian docs been made ?
- ABI for server, so name bumped

Did you break mir client API or ABI and have you followed up with the known clients & announced on mir-devel mailing list ?
- ABI for server broke, relevant MP's are in place

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

Verified the diff to release 0.1.7 is now only debian/changelog. And the conflicts no longer reappear when merging between distro/development.

review: Approve
Revision history for this message
kevin gunn (kgunn72) wrote :

daniel - in the future, if you update the branch especially with updates from devel, make sure to disable the arm integration tests, as those tests will fail on the silo builders

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.cpp 2014-01-22 10:03:11 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.cpp 2014-03-17 15:02:33 +0000
@@ -432,6 +432,7 @@
432sp<InputWindowHandle> InputDispatcher::findTouchedWindowAtLocked(int32_t x, int32_t y) {432sp<InputWindowHandle> InputDispatcher::findTouchedWindowAtLocked(int32_t x, int32_t y) {
433 sp<InputWindowHandle> foundHandle = NULL;433 sp<InputWindowHandle> foundHandle = NULL;
434 mEnumerator->for_each([&](sp<InputWindowHandle> windowHandle) {434 mEnumerator->for_each([&](sp<InputWindowHandle> windowHandle) {
435 windowHandle->updateInfo();
435 const InputWindowInfo* windowInfo = windowHandle->getInfo();436 const InputWindowInfo* windowInfo = windowHandle->getInfo();
436 int32_t flags = windowInfo->layoutParamsFlags;437 int32_t flags = windowInfo->layoutParamsFlags;
437438
@@ -1151,6 +1152,7 @@
11511152
1152 // Traverse windows from front to back to find touched window and outside targets.1153 // Traverse windows from front to back to find touched window and outside targets.
1153 mEnumerator->for_each([&](sp<InputWindowHandle> const& windowHandle){1154 mEnumerator->for_each([&](sp<InputWindowHandle> const& windowHandle){
1155 windowHandle->updateInfo();
1154 const InputWindowInfo* windowInfo = windowHandle->getInfo();1156 const InputWindowInfo* windowInfo = windowHandle->getInfo();
1155 int32_t flags = windowInfo->layoutParamsFlags;1157 int32_t flags = windowInfo->layoutParamsFlags;
11561158
@@ -2742,6 +2744,12 @@
2742 c_str(newFocusedWindowHandle->getName()));2744 c_str(newFocusedWindowHandle->getName()));
2743#endif2745#endif
2744 }2746 }
2747
2748 if (mInputTargetWaitCause != INPUT_TARGET_WAIT_CAUSE_NONE) {
2749 releasePendingEventLocked();
2750 drainInboundQueueLocked();
2751 }
2752
2745 mFocusedWindowHandle = newFocusedWindowHandle;2753 mFocusedWindowHandle = newFocusedWindowHandle;
2746 }2754 }
2747}2755}
27482756
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-02-28 13:51:43 +0000
+++ CMakeLists.txt 2014-03-17 15:02:33 +0000
@@ -28,7 +28,7 @@
2828
29set(MIR_VERSION_MAJOR 0)29set(MIR_VERSION_MAJOR 0)
30set(MIR_VERSION_MINOR 1)30set(MIR_VERSION_MINOR 1)
31set(MIR_VERSION_PATCH 6)31set(MIR_VERSION_PATCH 7)
3232
33set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)33set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
34execute_process(34execute_process(
3535
=== modified file 'debian/changelog'
--- debian/changelog 2014-03-10 19:28:46 +0000
+++ debian/changelog 2014-03-17 15:02:33 +0000
@@ -1,3 +1,59 @@
1mir (0.1.7-0ubuntu1) UNRELEASED; urgency=medium
2
3 * New upstream release 0.1.7 (https://launchpad.net/mir/+milestone/0.1.7)
4 - mirserver ABI bumped to 17
5 - mirclient ABI unchanged, still at 7. Clients do not need rebuilding.
6 - Server API changes (AKA why doesn't my code build any more?):
7 . Class "CompositingCriteria" has been removed. It's replaced by the more
8 flexible "Renderable" interface. This also resulted in parameter
9 changes for the Renderer and scene filtering classes.
10 . The function "DisplayConfiguration::configure_output()" has been
11 removed. Instead, please use the new mutable version of
12 "DisplayConfiguration::for_each_output()" with which you can modify
13 the output structure passed in on each iteration.
14 . Exposed formerly private class "GLRenderer" and demonstrated how
15 to override its behaviour in demo-shell. This area is under
16 construction and may experience further major changes.
17 - Added initial support for hardware (HWC) overlays to accelerate
18 rendering and reduce power consumption. Not complete yet.
19 - Screen rotation: Added mouse cursor rotation support, so you can now
20 still control things on a rotated screen. Still missing rotation of
21 the cursor bitmap itself.
22 - Lots of fixes to support nested Mir servers (see below).
23 - Major simplification to how surface size/position/transformation
24 interact, making transformations much easier to manage and work with.
25 - Bugs fixed:
26 . ./cross-compile-chroot.sh: line 83: popd: build-android-arm: invalid
27 argument popd: usage: popd [-n] [+N | -N] (LP: #1287600)
28 . Key events sent to the wrong client (and delayed) (LP: #1213804)
29 . Nested servers never receive input events (in their filters)
30 (LP: #1260612)
31 . Software clients crash immediately on nested servers - what(): Failed
32 to mmap buffer (LP: #1261286)
33 . MirMotionEvent lacks local coordinates. Reports only screen
34 coordinates. (LP: #1268819)
35 . Nested Mir crashes with - what():
36 MesaNativePlatform::create_internal_client is not implemented yet!
37 (LP: #1279092)
38 . clients fail to find some libraries if mir installed via "make install"
39 (LP: #1285566)
40 . Nested server hangs with multimonitor and internal clients.
41 (LP: #1287282)
42 . [regression] Multi-monitor frame sync no longer works (not
43 synchronized), and frames skip/jump/stutter (LP: #1288570)
44 . Mir FTBFS: /usr/bin/ld: cannot find -lmirtestdraw (when cmake ..
45 -DMIR_ENABLE_TESTS=OFF) (LP: #1283951)
46 . nested Mir library calls next_buffer() during startup (LP: #1284739)
47 . Building Mir produces lots of warnings from GLM headers about
48 deprecated degrees values vs radians (LP: #1286010)
49 . [enhancement] screencast of a single window (LP: #1288478)
50 . Nexus4 + mir_demo_client_eglplasma starts to stutter after a while
51 (LP: #1189753)
52 . --host-socket documented default argument isn't used as default
53 (LP: #1262091)
54
55 -- Daniel van Vugt <daniel.van.vugt@canonical.com> Wed, 12 Mar 2014 11:05:20 +0800
56
1mir (0.1.6+14.04.20140310-0ubuntu1) trusty; urgency=medium57mir (0.1.6+14.04.20140310-0ubuntu1) trusty; urgency=medium
258
3 [ Kevin Gunn ]59 [ Kevin Gunn ]
460
=== modified file 'debian/control'
--- debian/control 2014-03-06 14:18:50 +0000
+++ debian/control 2014-03-17 15:02:33 +0000
@@ -70,7 +70,7 @@
70 .70 .
71 Contains the protocol's definition files.71 Contains the protocol's definition files.
7272
73Package: libmirserver1673Package: libmirserver17
74Section: libs74Section: libs
75Architecture: i386 amd64 armhf arm6475Architecture: i386 amd64 armhf arm64
76Multi-Arch: same76Multi-Arch: same
@@ -148,7 +148,7 @@
148Architecture: i386 amd64 armhf arm64148Architecture: i386 amd64 armhf arm64
149Multi-Arch: same149Multi-Arch: same
150Pre-Depends: ${misc:Pre-Depends}150Pre-Depends: ${misc:Pre-Depends}
151Depends: libmirserver16 (= ${binary:Version}),151Depends: libmirserver17 (= ${binary:Version}),
152 libmirprotobuf-dev (= ${binary:Version}),152 libmirprotobuf-dev (= ${binary:Version}),
153 mircommon-dev (= ${binary:Version}),153 mircommon-dev (= ${binary:Version}),
154 libglm-dev,154 libglm-dev,
155155
=== renamed file 'debian/libmirserver16.install' => 'debian/libmirserver17.install'
--- debian/libmirserver16.install 2014-02-21 03:57:16 +0000
+++ debian/libmirserver17.install 2014-03-17 15:02:33 +0000
@@ -1,1 +1,1 @@
1usr/lib/*/libmirserver.so.161usr/lib/*/libmirserver.so.17
22
=== modified file 'debian/rules'
--- debian/rules 2014-03-06 14:18:50 +0000
+++ debian/rules 2014-03-17 15:02:33 +0000
@@ -22,8 +22,8 @@
22 dh_auto_configure -- \22 dh_auto_configure -- \
23 $(COMMON_CONFIGURE_OPTIONS) \23 $(COMMON_CONFIGURE_OPTIONS) \
24 -DMIR_RUN_ACCEPTANCE_TESTS=OFF \24 -DMIR_RUN_ACCEPTANCE_TESTS=OFF \
25 -DMIR_RUN_INTEGRATION_TESTS=OFF \25 -DMIR_RUN_INTEGRATION_TESTS=OFF \
26 -DMIR_PLATFORM=android\;mesa26 -DMIR_PLATFORM=android\;mesa
27else27else
28ifeq ($(DEB_HOST_ARCH),arm64)28ifeq ($(DEB_HOST_ARCH),arm64)
29 dh_auto_configure -- \29 dh_auto_configure -- \
@@ -41,7 +41,9 @@
41 dh_makeshlibs -V41 dh_makeshlibs -V
4242
43override_dh_install:43override_dh_install:
44 dh_install --fail-missing44 dh_install --fail-missing \
45 -Xusr/lib/$(DEB_HOST_MULTIARCH)/libmirplatformgraphics.so \
46 -Xusr/lib/$(DEB_HOST_MULTIARCH)/libmirclientplatform.so
45 sh debian/install_ld_so_conf.sh $(DEB_HOST_MULTIARCH)47 sh debian/install_ld_so_conf.sh $(DEB_HOST_MULTIARCH)
4648
47override_dh_installdeb:49override_dh_installdeb:
4850
=== modified file 'examples/CMakeLists.txt'
--- examples/CMakeLists.txt 2014-03-04 04:19:26 +0000
+++ examples/CMakeLists.txt 2014-03-17 15:02:33 +0000
@@ -93,7 +93,6 @@
93 ${PROJECT_SOURCE_DIR}/include/server93 ${PROJECT_SOURCE_DIR}/include/server
94 ${PROJECT_SOURCE_DIR}/include/client94 ${PROJECT_SOURCE_DIR}/include/client
95 ${PROJECT_SOURCE_DIR}/include/platform95 ${PROJECT_SOURCE_DIR}/include/platform
96 ${PROJECT_SOURCE_DIR}/include/test/mir_test/draw
97 ${GLESv2_INCLUDE_DIRS}96 ${GLESv2_INCLUDE_DIRS}
98)97)
9998
10099
=== modified file 'examples/demo-shell/CMakeLists.txt'
--- examples/demo-shell/CMakeLists.txt 2013-08-28 03:41:48 +0000
+++ examples/demo-shell/CMakeLists.txt 2014-03-17 15:02:33 +0000
@@ -1,5 +1,6 @@
1add_executable(mir_demo_server_shell1add_executable(mir_demo_server_shell
2 demo_shell.cpp2 demo_shell.cpp
3 demo_renderer.cpp
3 fullscreen_placement_strategy.cpp4 fullscreen_placement_strategy.cpp
4 window_manager.cpp5 window_manager.cpp
5 ../server_configuration.cpp6 ../server_configuration.cpp
67
=== added file 'examples/demo-shell/demo_renderer.cpp'
--- examples/demo-shell/demo_renderer.cpp 1970-01-01 00:00:00 +0000
+++ examples/demo-shell/demo_renderer.cpp 2014-03-17 15:02:33 +0000
@@ -0,0 +1,33 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */
18
19#include "demo_renderer.h"
20
21using namespace mir;
22using namespace mir::examples;
23
24DemoRenderer::DemoRenderer(geometry::Rectangle const& display_area)
25 : GLRenderer(display_area)
26{
27}
28
29void DemoRenderer::begin() const
30{
31 glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
32 glClear(GL_COLOR_BUFFER_BIT);
33}
034
=== added file 'examples/demo-shell/demo_renderer.h'
--- examples/demo-shell/demo_renderer.h 1970-01-01 00:00:00 +0000
+++ examples/demo-shell/demo_renderer.h 2014-03-17 15:02:33 +0000
@@ -0,0 +1,39 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */
18
19#ifndef MIR_EXAMPLES_DEMO_RENDERER_H_
20#define MIR_EXAMPLES_DEMO_RENDERER_H_
21
22#include "mir/compositor/gl_renderer.h"
23
24namespace mir
25{
26namespace examples
27{
28
29class DemoRenderer : public compositor::GLRenderer
30{
31public:
32 DemoRenderer(geometry::Rectangle const& display_area);
33 void begin() const override;
34};
35
36} // namespace examples
37} // namespace mir
38
39#endif // MIR_EXAMPLES_DEMO_RENDERER_H_
040
=== modified file 'examples/demo-shell/demo_shell.cpp'
--- examples/demo-shell/demo_shell.cpp 2014-02-28 13:51:43 +0000
+++ examples/demo-shell/demo_shell.cpp 2014-03-17 15:02:33 +0000
@@ -18,6 +18,7 @@
1818
19/// \example demo_shell.cpp A simple mir shell19/// \example demo_shell.cpp A simple mir shell
2020
21#include "demo_renderer.h"
21#include "window_manager.h"22#include "window_manager.h"
22#include "fullscreen_placement_strategy.h"23#include "fullscreen_placement_strategy.h"
23#include "../server_configuration.h"24#include "../server_configuration.h"
@@ -27,6 +28,7 @@
27#include "mir/report_exception.h"28#include "mir/report_exception.h"
28#include "mir/graphics/display.h"29#include "mir/graphics/display.h"
29#include "mir/input/composite_event_filter.h"30#include "mir/input/composite_event_filter.h"
31#include "mir/compositor/renderer_factory.h"
3032
31#include <iostream>33#include <iostream>
3234
@@ -42,8 +44,19 @@
42namespace examples44namespace examples
43{45{
4446
45struct DemoServerConfiguration : mir::examples::ServerConfiguration47class DemoRendererFactory : public compositor::RendererFactory
46{48{
49public:
50 std::unique_ptr<compositor::Renderer> create_renderer_for(
51 geometry::Rectangle const& rect) override
52 {
53 return std::unique_ptr<compositor::Renderer>(new DemoRenderer(rect));
54 }
55};
56
57class DemoServerConfiguration : public mir::examples::ServerConfiguration
58{
59public:
47 DemoServerConfiguration(int argc, char const* argv[],60 DemoServerConfiguration(int argc, char const* argv[],
48 std::initializer_list<std::shared_ptr<mi::EventFilter>> const& filter_list)61 std::initializer_list<std::shared_ptr<mi::EventFilter>> const& filter_list)
49 : ServerConfiguration([argc, argv]62 : ServerConfiguration([argc, argv]
@@ -82,6 +95,12 @@
82 return composite_filter;95 return composite_filter;
83 }96 }
8497
98 std::shared_ptr<compositor::RendererFactory> the_renderer_factory() override
99 {
100 return std::make_shared<DemoRendererFactory>();
101 }
102
103private:
85 std::vector<std::shared_ptr<mi::EventFilter>> const filter_list;104 std::vector<std::shared_ptr<mi::EventFilter>> const filter_list;
86};105};
87106
88107
=== modified file 'examples/demo-shell/window_manager.cpp'
--- examples/demo-shell/window_manager.cpp 2014-03-05 02:30:30 +0000
+++ examples/demo-shell/window_manager.cpp 2014-03-17 15:02:33 +0000
@@ -140,23 +140,14 @@
140 {140 {
141 compositor->stop();141 compositor->stop();
142 auto conf = display->configuration();142 auto conf = display->configuration();
143 conf->for_each_output([&](mg::DisplayConfigurationOutput const& output) -> void143 MirPowerMode new_power_mode = display_off ?
144 {144 mir_power_mode_on : mir_power_mode_off;
145 MirPowerMode power_mode;145 conf->for_each_output(
146 if (!output.used) return;146 [&](mg::UserDisplayConfigurationOutput& output) -> void
147147 {
148 if (display_off == true)148 output.power_mode = new_power_mode;
149 power_mode = mir_power_mode_on;149 }
150 else150 );
151 power_mode = mir_power_mode_off;
152
153 conf->configure_output(output.id, output.used,
154 output.top_left,
155 output.current_mode_index,
156 output.current_format,
157 power_mode,
158 output.orientation);
159 });
160 display_off = !display_off;151 display_off = !display_off;
161152
162 display->configure(*conf.get());153 display->configure(*conf.get());
@@ -184,14 +175,9 @@
184 compositor->stop();175 compositor->stop();
185 auto conf = display->configuration();176 auto conf = display->configuration();
186 conf->for_each_output(177 conf->for_each_output(
187 [&](mg::DisplayConfigurationOutput const& output) -> void178 [&](mg::UserDisplayConfigurationOutput& output) -> void
188 {179 {
189 conf->configure_output(output.id, output.used,180 output.orientation = orientation;
190 output.top_left,
191 output.current_mode_index,
192 output.current_format,
193 output.power_mode,
194 orientation);
195 }181 }
196 );182 );
197 display->configure(*conf);183 display->configure(*conf);
198184
=== modified file 'examples/eglplasma.c'
--- examples/eglplasma.c 2013-09-19 13:24:22 +0000
+++ examples/eglplasma.c 2014-03-17 15:02:33 +0000
@@ -85,14 +85,13 @@
85 " const float pi2 = 6.283185308; \n"85 " const float pi2 = 6.283185308; \n"
86 " float u = texcoord.x * pi2; \n"86 " float u = texcoord.x * pi2; \n"
87 " float v = texcoord.y * pi2; \n"87 " float v = texcoord.y * pi2; \n"
88 " float t = mod(theta, pi2); \n"88 " float us = (cos(1.1 * u + 7.0 * theta) + \n"
89 " float us = (cos(1.1 * u + 7.0 * t) + \n"89 " cos(2.3 * v * cos(1.0 * theta)) + \n"
90 " cos(2.3 * v * cos(1.0 * t)) + \n"90 " cos(0.3 * u * cos(3.0 * theta)) \n"
91 " cos(0.3 * u * cos(3.0 * t)) \n"
92 " ) / 3.0; \n"91 " ) / 3.0; \n"
93 " float vs = (cos(2.3 * v + 8.0 * t) + \n"92 " float vs = (cos(2.3 * v + 8.0 * theta) + \n"
94 " cos(1.3 * u * cos(3.0 * t)) + \n"93 " cos(1.3 * u * cos(3.0 * theta)) + \n"
95 " cos(1.7 * v * cos(2.0 * t)) \n"94 " cos(1.7 * v * cos(2.0 * theta)) \n"
96 " ) / 3.0; \n"95 " ) / 3.0; \n"
97 " float x = (us * vs + 1.0) / 2.0; \n"96 " float x = (us * vs + 1.0) / 2.0; \n"
98 " gl_FragColor = vec4(gradient(x), 1.0); \n"97 " gl_FragColor = vec4(gradient(x), 1.0); \n"
@@ -105,6 +104,7 @@
105 1.0f,-1.0f,104 1.0f,-1.0f,
106 -1.0f,-1.0f,105 -1.0f,-1.0f,
107 };106 };
107 const float pi2 = 6.283185308f;
108 GLuint vshader, fshader, prog;108 GLuint vshader, fshader, prog;
109 GLint linked, low_color, high_color, vpos, theta;109 GLint linked, low_color, high_color, vpos, theta;
110 unsigned int width = 0, height = 0;110 unsigned int width = 0, height = 0;
@@ -151,6 +151,8 @@
151 {151 {
152 glUniform1f(theta, angle);152 glUniform1f(theta, angle);
153 angle += 0.005f;153 angle += 0.005f;
154 if (angle > pi2)
155 angle -= pi2;
154 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);156 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
155 mir_eglapp_swap_buffers();157 mir_eglapp_swap_buffers();
156 }158 }
157159
=== modified file 'examples/image_renderer.cpp'
--- examples/image_renderer.cpp 2014-01-22 10:03:11 +0000
+++ examples/image_renderer.cpp 2014-03-17 15:02:33 +0000
@@ -23,6 +23,7 @@
23#pragma GCC diagnostic warning "-Wall"23#pragma GCC diagnostic warning "-Wall"
24#include <glm/glm.hpp>24#include <glm/glm.hpp>
25#pragma GCC diagnostic pop25#pragma GCC diagnostic pop
26#define GLM_FORCE_RADIANS
26#include <glm/gtc/type_ptr.hpp>27#include <glm/gtc/type_ptr.hpp>
2728
28#include <memory>29#include <memory>
2930
=== modified file 'examples/pixel_format_selector.cpp'
--- examples/pixel_format_selector.cpp 2014-03-05 02:30:30 +0000
+++ examples/pixel_format_selector.cpp 2014-03-17 15:02:33 +0000
@@ -40,7 +40,7 @@
40{40{
41 base_policy->apply_to(conf);41 base_policy->apply_to(conf);
42 conf.for_each_output(42 conf.for_each_output(
43 [&](graphics::DisplayConfigurationOutput const& conf_output)43 [&](graphics::UserDisplayConfigurationOutput& conf_output)
44 {44 {
45 if (!conf_output.connected || !conf_output.used) return;45 if (!conf_output.connected || !conf_output.used) return;
4646
@@ -56,12 +56,7 @@
56 if (pos == conf_output.pixel_formats.end())56 if (pos == conf_output.pixel_formats.end())
57 return;57 return;
5858
59 conf.configure_output(conf_output.id, true, conf_output.top_left,59 conf_output.current_format = *pos;
60 conf_output.current_mode_index,
61 *pos,
62 conf_output.power_mode,
63 conf_output.orientation
64 );
65 });60 });
66}61}
6762
6863
=== modified file 'examples/render_overlays.cpp'
--- examples/render_overlays.cpp 2014-03-04 04:19:26 +0000
+++ examples/render_overlays.cpp 2014-03-17 15:02:33 +0000
@@ -25,9 +25,10 @@
25#include "mir/graphics/buffer_properties.h"25#include "mir/graphics/buffer_properties.h"
26#include "mir/report_exception.h"26#include "mir/report_exception.h"
2727
28#include "graphics_region_factory.h"28#include "testdraw/graphics_region_factory.h"
29#include "patterns.h"29#include "testdraw/patterns.h"
3030
31#include <chrono>
31#include <csignal>32#include <csignal>
32#include <iostream>33#include <iostream>
3334
@@ -44,20 +45,69 @@
44{45{
45 running = false;46 running = false;
46}47}
47}48
49class DemoOverlayClient
50{
51public:
52 DemoOverlayClient(
53 mg::GraphicBufferAllocator& buffer_allocator,
54 mg::BufferProperties const& buffer_properties, uint32_t color)
55 : front_buffer(buffer_allocator.alloc_buffer(buffer_properties)),
56 back_buffer(buffer_allocator.alloc_buffer(buffer_properties)),
57 region_factory(mir::test::draw::create_graphics_region_factory()),
58 color{color},
59 last_tick{std::chrono::high_resolution_clock::now()}
60 {
61 }
62
63 void update_green_channel()
64 {
65 char green_value = (color >> 8) & 0xFF;
66 green_value += compute_update_value();
67 color &= 0xFFFF00FF;
68 color |= (green_value << 8);
69
70 mir::test::draw::DrawPatternSolid fill{color};
71 fill.draw(*region_factory->graphic_region_from_handle(*back_buffer->native_buffer_handle()));
72 std::swap(front_buffer, back_buffer);
73 }
74
75 std::shared_ptr<mg::Buffer> last_rendered()
76 {
77 return front_buffer;
78 }
79
80private:
81 int compute_update_value()
82 {
83 float const update_ratio{3.90625}; //this will give an update of 256 in 1s
84 auto current_tick = std::chrono::high_resolution_clock::now();
85 auto elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(
86 current_tick - last_tick).count();
87 float update_value = elapsed_ms / update_ratio;
88 last_tick = current_tick;
89 return static_cast<int>(update_value);
90 }
91
92 std::shared_ptr<mg::Buffer> front_buffer;
93 std::shared_ptr<mg::Buffer> back_buffer;
94 std::shared_ptr<mir::test::draw::GraphicsRegionFactory> region_factory;
95 unsigned int color;
96 std::chrono::time_point<std::chrono::high_resolution_clock> last_tick;
97};
4898
49class DemoRenderable : public mg::Renderable99class DemoRenderable : public mg::Renderable
50{100{
51public:101public:
52 DemoRenderable(std::shared_ptr<mg::Buffer> const& buffer, geom::Rectangle rect)102 DemoRenderable(std::shared_ptr<DemoOverlayClient> const& client, geom::Rectangle rect)
53 : renderable_buffer(buffer),103 : client(client),
54 position(rect)104 position(rect)
55 {105 {
56 }106 }
57107
58 std::shared_ptr<mg::Buffer> buffer() const108 std::shared_ptr<mg::Buffer> buffer(unsigned long) const override
59 {109 {
60 return renderable_buffer;110 return client->last_rendered();
61 }111 }
62112
63 bool alpha_enabled() const113 bool alpha_enabled() const
@@ -70,16 +120,41 @@
70 return position;120 return position;
71 }121 }
72122
123 float alpha() const override
124 {
125 return 1.0f;
126 }
127
128 glm::mat4 transformation() const override
129 {
130 return trans;
131 }
132
133 bool shaped() const
134 {
135 return false;
136 }
137
138 bool should_be_rendered_in(geom::Rectangle const& rect) const override
139 {
140 return rect.overlaps(position);
141 }
142
143 int buffers_ready_for_compositor() const override
144 {
145 return 1;
146 }
147
73private:148private:
74 std::shared_ptr<mg::Buffer> const renderable_buffer;149 std::shared_ptr<DemoOverlayClient> const client;
75 geom::Rectangle const position;150 geom::Rectangle const position;
151 glm::mat4 const trans;
76};152};
153}
77154
78int main(int argc, char const** argv)155int main(int argc, char const** argv)
79try156try
80{157{
81 mir::test::draw::DrawPatternSolid fill_with_green(0x00FF00FF);
82 mir::test::draw::DrawPatternSolid fill_with_blue(0x0000FFFF);
83158
84 /* Set up graceful exit on SIGINT and SIGTERM */159 /* Set up graceful exit on SIGINT and SIGTERM */
85 struct sigaction sa;160 struct sigaction sa;
@@ -95,7 +170,6 @@
95 auto platform = conf.the_graphics_platform();170 auto platform = conf.the_graphics_platform();
96 auto display = platform->create_display(conf.the_display_configuration_policy());171 auto display = platform->create_display(conf.the_display_configuration_policy());
97 auto buffer_allocator = platform->create_buffer_allocator(conf.the_buffer_initializer());172 auto buffer_allocator = platform->create_buffer_allocator(conf.the_buffer_initializer());
98 auto region_factory = mir::test::draw::create_graphics_region_factory();
99173
100 mg::BufferProperties buffer_properties{174 mg::BufferProperties buffer_properties{
101 geom::Size{512, 512},175 geom::Size{512, 512},
@@ -103,18 +177,13 @@
103 mg::BufferUsage::hardware177 mg::BufferUsage::hardware
104 };178 };
105179
106 auto buffer1 = buffer_allocator->alloc_buffer(buffer_properties);180 auto client1 = std::make_shared<DemoOverlayClient>(*buffer_allocator, buffer_properties,0xFF0000FF);
107 auto buffer2 = buffer_allocator->alloc_buffer(buffer_properties);181 auto client2 = std::make_shared<DemoOverlayClient>(*buffer_allocator, buffer_properties,0xFFFFFF00);
108182
109 fill_with_green.draw(*region_factory->graphic_region_from_handle(*buffer1->native_buffer_handle()));
110 fill_with_blue.draw(*region_factory->graphic_region_from_handle(*buffer2->native_buffer_handle()));
111
112 geom::Rectangle screen_pos1{{0,0} , {512, 512}};
113 geom::Rectangle screen_pos2{{80,80} , {592,592}};
114 std::list<std::shared_ptr<mg::Renderable>> renderlist183 std::list<std::shared_ptr<mg::Renderable>> renderlist
115 {184 {
116 std::make_shared<DemoRenderable>(buffer2, screen_pos2),185 std::make_shared<DemoRenderable>(client1, geom::Rectangle{{0,0} , {512, 512}}),
117 std::make_shared<DemoRenderable>(buffer1, screen_pos1)186 std::make_shared<DemoRenderable>(client2, geom::Rectangle{{80,80} , {592,592}})
118 };187 };
119188
120 while (running)189 while (running)
@@ -122,6 +191,8 @@
122 display->for_each_display_buffer([&](mg::DisplayBuffer& buffer)191 display->for_each_display_buffer([&](mg::DisplayBuffer& buffer)
123 {192 {
124 buffer.make_current();193 buffer.make_current();
194 client1->update_green_channel();
195 client2->update_green_channel();
125 auto render_fn = [](mg::Renderable const&) {};196 auto render_fn = [](mg::Renderable const&) {};
126 buffer.render_and_post_update(renderlist, render_fn);197 buffer.render_and_post_update(renderlist, render_fn);
127 });198 });
128199
=== modified file 'examples/render_surfaces.cpp'
--- examples/render_surfaces.cpp 2014-02-28 13:51:43 +0000
+++ examples/render_surfaces.cpp 2014-03-17 15:02:33 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19#include "mir/compositor/display_buffer_compositor_factory.h"19#include "mir/compositor/display_buffer_compositor_factory.h"
20#include "mir/server_status_listener.h"
20#include "mir/compositor/display_buffer_compositor.h"21#include "mir/compositor/display_buffer_compositor.h"
21#include "mir/options/default_configuration.h"22#include "mir/options/default_configuration.h"
22#include "mir/graphics/graphic_buffer_allocator.h"23#include "mir/graphics/graphic_buffer_allocator.h"
@@ -48,8 +49,6 @@
48#include <sstream>49#include <sstream>
49#include <vector>50#include <vector>
5051
51#include <glm/gtc/matrix_transform.hpp>
52
53namespace mg = mir::graphics;52namespace mg = mir::graphics;
54namespace mc = mir::compositor;53namespace mc = mir::compositor;
55namespace ms = mir::scene;54namespace ms = mir::scene;
@@ -86,6 +85,7 @@
8685
87namespace86namespace
88{87{
88std::atomic<bool> created{false};
89bool input_is_on = false;89bool input_is_on = false;
90std::weak_ptr<mg::Cursor> cursor;90std::weak_ptr<mg::Cursor> cursor;
91static const uint32_t bg_color = 0x00000000;91static const uint32_t bg_color = 0x00000000;
@@ -326,6 +326,31 @@
326 }326 }
327 ///\internal [RenderResourcesBufferInitializer_tag]327 ///\internal [RenderResourcesBufferInitializer_tag]
328328
329 // Unless the compositor starts before we create the surfaces it won't respond to
330 // the change notification that causes.
331 std::shared_ptr<mir::ServerStatusListener> the_server_status_listener()
332 {
333 struct ServerStatusListener : mir::ServerStatusListener
334 {
335 ServerStatusListener(std::function<void()> create_surfaces, std::shared_ptr<mir::ServerStatusListener> wrapped) :
336 create_surfaces(create_surfaces), wrapped(wrapped) {}
337
338 virtual void paused() override { wrapped->paused(); }
339 virtual void resumed() override { wrapped->resumed(); }
340 virtual void started() override { wrapped->started(); create_surfaces(); create_surfaces = []{}; }
341
342 std::function<void()> create_surfaces;
343 std::shared_ptr<mir::ServerStatusListener> const wrapped;
344 };
345
346 return server_status_listener(
347 [this]()
348 {
349 auto wrapped = ServerConfiguration::the_server_status_listener();
350 return std::make_shared<ServerStatusListener>([this] { create_surfaces(); }, wrapped);
351 });
352 }
353
329 ///\internal [RenderSurfacesDisplayBufferCompositor_tag]354 ///\internal [RenderSurfacesDisplayBufferCompositor_tag]
330 // Decorate the DefaultDisplayBufferCompositor in order to move surfaces.355 // Decorate the DefaultDisplayBufferCompositor in order to move surfaces.
331 std::shared_ptr<mc::DisplayBufferCompositorFactory> the_display_buffer_compositor_factory() override356 std::shared_ptr<mc::DisplayBufferCompositorFactory> the_display_buffer_compositor_factory() override
@@ -342,8 +367,9 @@
342 {367 {
343 }368 }
344369
345 void composite()370 bool composite()
346 {371 {
372 while (!created) std::this_thread::yield();
347 animate_cursor();373 animate_cursor();
348 stop_watch.stop();374 stop_watch.stop();
349 if (stop_watch.elapsed_seconds_since_last_restart() >= 1)375 if (stop_watch.elapsed_seconds_since_last_restart() >= 1)
@@ -360,6 +386,7 @@
360 m.step();386 m.step();
361387
362 frames++;388 frames++;
389 return false;
363 }390 }
364391
365 private:392 private:
@@ -459,6 +486,8 @@
459 2.0f * M_PI * cos(i));486 2.0f * M_PI * cos(i));
460 ++i;487 ++i;
461 }488 }
489
490 created = true;
462 }491 }
463492
464 bool input_is_on()493 bool input_is_on()
@@ -492,8 +521,6 @@
492521
493 mir::run_mir(conf, [&](mir::DisplayServer&)522 mir::run_mir(conf, [&](mir::DisplayServer&)
494 {523 {
495 conf.create_surfaces();
496
497 cursor = conf.the_cursor();524 cursor = conf.the_cursor();
498525
499 input_is_on = conf.input_is_on();526 input_is_on = conf.input_is_on();
500527
=== modified file 'examples/scroll.cpp'
--- examples/scroll.cpp 2014-03-04 04:19:26 +0000
+++ examples/scroll.cpp 2014-03-17 15:02:33 +0000
@@ -23,46 +23,21 @@
23#include <signal.h>23#include <signal.h>
24#include <string.h>24#include <string.h>
25#include <stdio.h>25#include <stdio.h>
26#include <stdlib.h>
26#include <unistd.h>27#include <unistd.h>
27#include <getopt.h>28#include <getopt.h>
28#include <EGL/egl.h>29#include <EGL/egl.h>
29#include <GLES2/gl2.h>30#include <GLES2/gl2.h>
3031
32#include <thread>
33
31static char const *socket_file = NULL;34static char const *socket_file = NULL;
3235static EGLDisplay disp;
33int main(int argc, char* argv[])36
37
38void create_and_run_scroll_surface(MirConnection *connection)
34{39{
35 MirConnection *connection = 0;
36 MirSurface *surface = 0;40 MirSurface *surface = 0;
37 int arg;
38 opterr = 0;
39 while ((arg = getopt (argc, argv, "hm:")) != -1)
40 {
41 switch (arg)
42 {
43 case 'm':
44 socket_file = optarg;
45 break;
46
47 case '?':
48 case 'h':
49 default:
50 puts(argv[0]);
51 puts("Usage:");
52 puts(" -m <Mir server socket>");
53 puts(" -h: this help text");
54 return -1;
55 }
56 }
57
58 puts("Starting");
59
60 connection = mir_connect_sync(socket_file, __PRETTY_FUNCTION__);
61 assert(connection != NULL);
62 assert(mir_connection_is_valid(connection));
63 assert(strcmp(mir_connection_get_error_message(connection), "") == 0);
64 puts("Connected");
65
66 MirPixelFormat pixel_format;41 MirPixelFormat pixel_format;
67 unsigned int valid_formats;42 unsigned int valid_formats;
68 mir_connection_get_available_surface_formats(connection, &pixel_format, 1, &valid_formats);43 mir_connection_get_available_surface_formats(connection, &pixel_format, 1, &valid_formats);
@@ -79,7 +54,6 @@
7954
80 /* egl setup */55 /* egl setup */
81 int major, minor, n, rc;56 int major, minor, n, rc;
82 EGLDisplay disp;
83 EGLContext context;57 EGLContext context;
84 EGLSurface egl_surface;58 EGLSurface egl_surface;
85 EGLConfig egl_config;59 EGLConfig egl_config;
@@ -93,13 +67,9 @@
93 EGL_NONE };67 EGL_NONE };
94 EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };68 EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
9569
96 EGLNativeDisplayType native_display = (EGLNativeDisplayType) mir_connection_get_egl_native_display(connection);
97 EGLNativeWindowType native_window = (EGLNativeWindowType) mir_surface_get_egl_native_window(surface);70 EGLNativeWindowType native_window = (EGLNativeWindowType) mir_surface_get_egl_native_window(surface);
98 assert(native_window != (EGLNativeWindowType)NULL);71 assert(native_window != (EGLNativeWindowType)NULL);
9972
100 disp = eglGetDisplay(native_display);
101 assert(disp != EGL_NO_DISPLAY);
102
103 rc = eglInitialize(disp, &major, &minor);73 rc = eglInitialize(disp, &major, &minor);
104 assert(rc == EGL_TRUE);74 assert(rc == EGL_TRUE);
105 assert(major == 1);75 assert(major == 1);
@@ -131,16 +101,67 @@
131101
132 eglDestroySurface(disp, egl_surface);102 eglDestroySurface(disp, egl_surface);
133 eglDestroyContext(disp, context);103 eglDestroyContext(disp, context);
134 eglTerminate(disp);104
135
136 mir_surface_release_sync(surface);105 mir_surface_release_sync(surface);
137 puts("Surface released");106 puts("Surface released");
107}
108
109int main(int argc, char* argv[])
110{
111 MirConnection *connection = 0;
112 unsigned num_windows = 1;
113 int arg;
114 opterr = 0;
115 while ((arg = getopt (argc, argv, "hm:w:")) != -1)
116 {
117 switch (arg)
118 {
119 case 'm':
120 socket_file = optarg;
121 break;
122 case 'w':
123 num_windows = atoi(optarg);
124 break;
125 case '?':
126 case 'h':
127 default:
128 puts(argv[0]);
129 puts("Usage:");
130 puts(" -m <Mir server socket>");
131 puts(" -w <Number of windows to create>:");
132 puts(" -h: this help text");
133 return -1;
134 }
135 }
136
137 puts("Starting");
138
139 connection = mir_connect_sync(socket_file, __PRETTY_FUNCTION__);
140 assert(connection != NULL);
141 assert(mir_connection_is_valid(connection));
142 assert(strcmp(mir_connection_get_error_message(connection), "") == 0);
143 puts("Connected");
144
145 EGLNativeDisplayType native_display = (EGLNativeDisplayType) mir_connection_get_egl_native_display(connection);
146 disp = eglGetDisplay(native_display);
147 assert(disp != EGL_NO_DISPLAY);
148
149 if (num_windows == 1)
150 {
151 create_and_run_scroll_surface(connection);
152 }
153 else
154 {
155 for (unsigned i = 0; i < num_windows; i++) std::thread(create_and_run_scroll_surface, connection).detach();
156 for(;;) {}
157 }
158
159
160 eglTerminate(disp);
138161
139 mir_connection_release(connection);162 mir_connection_release(connection);
140 puts("Connection released");163 puts("Connection released");
141164
142 (void)rc;
143
144 return 0;165 return 0;
145}166}
146167
147168
=== modified file 'examples/server_configuration.cpp'
--- examples/server_configuration.cpp 2014-03-05 02:30:30 +0000
+++ examples/server_configuration.cpp 2014-03-17 15:02:33 +0000
@@ -56,28 +56,23 @@
56 });56 });
5757
58 conf.for_each_output(58 conf.for_each_output(
59 [&](mg::DisplayConfigurationOutput const& conf_output)59 [&](mg::UserDisplayConfigurationOutput& conf_output)
60 {60 {
61 if (conf_output.connected && conf_output.modes.size() > 0 &&61 if (conf_output.connected && conf_output.modes.size() > 0 &&
62 available_outputs_for_card[conf_output.card_id] > 0)62 available_outputs_for_card[conf_output.card_id] > 0)
63 {63 {
64 conf.configure_output(conf_output.id, true,64 conf_output.used = true;
65 geom::Point{max_x, 0},65 conf_output.top_left = geom::Point{max_x, 0};
66 preferred_mode_index,66 conf_output.current_mode_index = preferred_mode_index;
67 conf_output.current_format,67 conf_output.power_mode = mir_power_mode_on;
68 mir_power_mode_on,68 conf_output.orientation = mir_orientation_normal;
69 mir_orientation_normal);
70 max_x += conf_output.modes[preferred_mode_index].size.width.as_int();69 max_x += conf_output.modes[preferred_mode_index].size.width.as_int();
71 --available_outputs_for_card[conf_output.card_id];70 --available_outputs_for_card[conf_output.card_id];
72 }71 }
73 else72 else
74 {73 {
75 conf.configure_output(conf_output.id, false,74 conf_output.used = false;
76 conf_output.top_left,75 conf_output.power_mode = mir_power_mode_off;
77 conf_output.current_mode_index,
78 conf_output.current_format,
79 mir_power_mode_on,
80 mir_orientation_normal);
81 }76 }
82 });77 });
83 }78 }
@@ -92,26 +87,20 @@
92 bool done{false};87 bool done{false};
9388
94 conf.for_each_output(89 conf.for_each_output(
95 [&](mg::DisplayConfigurationOutput const& conf_output)90 [&](mg::UserDisplayConfigurationOutput& conf_output)
96 {91 {
97 if (!done && conf_output.connected && conf_output.modes.size() > 0)92 if (!done && conf_output.connected && conf_output.modes.size() > 0)
98 {93 {
99 conf.configure_output(conf_output.id, true,94 conf_output.used = true;
100 geom::Point{0, 0},95 conf_output.top_left = geom::Point{0, 0};
101 preferred_mode_index,96 conf_output.current_mode_index = preferred_mode_index;
102 conf_output.current_format,97 conf_output.power_mode = mir_power_mode_on;
103 mir_power_mode_on,
104 mir_orientation_normal);
105 done = true;98 done = true;
106 }99 }
107 else100 else
108 {101 {
109 conf.configure_output(conf_output.id, false,102 conf_output.used = false;
110 conf_output.top_left,103 conf_output.power_mode = mir_power_mode_off;
111 conf_output.current_mode_index,
112 conf_output.current_format,
113 mir_power_mode_on,
114 mir_orientation_normal);
115 }104 }
116 });105 });
117 }106 }
118107
=== modified file 'include/platform/mir/graphics/display_configuration.h'
--- include/platform/mir/graphics/display_configuration.h 2014-03-05 02:30:30 +0000
+++ include/platform/mir/graphics/display_configuration.h 2014-03-17 15:02:33 +0000
@@ -114,6 +114,31 @@
114 /** The logical rectangle occupied by the output, based on its position,114 /** The logical rectangle occupied by the output, based on its position,
115 current mode and orientation (rotation) */115 current mode and orientation (rotation) */
116 geometry::Rectangle extents() const;116 geometry::Rectangle extents() const;
117 bool valid() const;
118};
119
120/**
121 * Mirror of a DisplayConfigurationOutput, with some fields limited to
122 * being read-only, preventing users from changing things they shouldn't.
123 */
124struct UserDisplayConfigurationOutput
125{
126 DisplayConfigurationOutputId const& id;
127 DisplayConfigurationCardId const& card_id;
128 DisplayConfigurationOutputType const& type;
129 std::vector<MirPixelFormat> const& pixel_formats;
130 std::vector<DisplayConfigurationMode> const& modes;
131 size_t const& preferred_mode_index;
132 geometry::Size const& physical_size_mm;
133 bool const& connected;
134 bool& used;
135 geometry::Point& top_left;
136 size_t& current_mode_index;
137 MirPixelFormat& current_format;
138 MirPowerMode& power_mode;
139 MirOrientation& orientation;
140
141 UserDisplayConfigurationOutput(DisplayConfigurationOutput& master);
117};142};
118143
119std::ostream& operator<<(std::ostream& out, DisplayConfigurationCard const& val);144std::ostream& operator<<(std::ostream& out, DisplayConfigurationCard const& val);
@@ -140,13 +165,8 @@
140 virtual void for_each_card(std::function<void(DisplayConfigurationCard const&)> f) const = 0;165 virtual void for_each_card(std::function<void(DisplayConfigurationCard const&)> f) const = 0;
141 /** Executes a function object for each output in the configuration. */166 /** Executes a function object for each output in the configuration. */
142 virtual void for_each_output(std::function<void(DisplayConfigurationOutput const&)> f) const = 0;167 virtual void for_each_output(std::function<void(DisplayConfigurationOutput const&)> f) const = 0;
143168 virtual void for_each_output(std::function<void(UserDisplayConfigurationOutput&)> f) = 0;
144 /** Configures an output. */169 virtual bool valid() const;
145 virtual void configure_output(DisplayConfigurationOutputId id, bool used,
146 geometry::Point top_left, size_t mode_index,
147 MirPixelFormat format,
148 MirPowerMode power_mode,
149 MirOrientation orientation) = 0;
150170
151protected:171protected:
152 DisplayConfiguration() = default;172 DisplayConfiguration() = default;
153173
=== renamed file 'src/platform/graphics/mesa/overlapping_output_grouping.h' => 'include/platform/mir/graphics/overlapping_output_grouping.h'
--- src/platform/graphics/mesa/overlapping_output_grouping.h 2014-01-22 10:03:11 +0000
+++ include/platform/mir/graphics/overlapping_output_grouping.h 2014-03-17 15:02:33 +0000
@@ -16,8 +16,8 @@
16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */17 */
1818
19#ifndef MIR_GRAPHICS_MESA_OVERLAPPING_OUTPUT_GROUPING_H_19#ifndef MIR_GRAPHICS_OVERLAPPING_OUTPUT_GROUPING_H_
20#define MIR_GRAPHICS_MESA_OVERLAPPING_OUTPUT_GROUPING_H_20#define MIR_GRAPHICS_OVERLAPPING_OUTPUT_GROUPING_H_
2121
22#include <vector>22#include <vector>
23#include <functional>23#include <functional>
@@ -34,9 +34,6 @@
34class DisplayConfiguration;34class DisplayConfiguration;
35struct DisplayConfigurationOutput;35struct DisplayConfigurationOutput;
3636
37namespace mesa
38{
39
40class OverlappingOutputGroup37class OverlappingOutputGroup
41{38{
42public:39public:
@@ -67,6 +64,5 @@
6764
68}65}
69}66}
70}
7167
72#endif /* MIR_GRAPHICS_MESA_OVERLAPPING_OUTPUT_GROUPING_H_ */68#endif /* MIR_GRAPHICS_OVERLAPPING_OUTPUT_GROUPING_H_ */
7369
=== modified file 'include/platform/mir/graphics/renderable.h'
--- include/platform/mir/graphics/renderable.h 2014-03-04 04:19:26 +0000
+++ include/platform/mir/graphics/renderable.h 2014-03-17 15:02:33 +0000
@@ -20,6 +20,7 @@
20#define MIR_GRAPHICS_RENDERABLE_H_20#define MIR_GRAPHICS_RENDERABLE_H_
2121
22#include <mir/geometry/rectangle.h>22#include <mir/geometry/rectangle.h>
23#include <glm/glm.hpp>
23#include <memory>24#include <memory>
2425
25namespace mir26namespace mir
@@ -31,10 +32,47 @@
31class Renderable32class Renderable
32{33{
33public:34public:
34 virtual std::shared_ptr<Buffer> buffer() const = 0;35 /**
36 * Return the next buffer that should be composited/rendered.
37 *
38 * \param [in] frameno The frameno parameter is important for
39 * multi-monitor platforms. Calls with the same frameno
40 * will get the same buffer returned. This ensures that
41 * a surface visible on multiple outputs does not get
42 * its buffers consumed any faster than the refresh
43 * rate of a single monitor. Implementations may ignore
44 * the value of frameno on single-monitor platforms
45 * only. The caller should always ensure the frameno
46 * is different to the previous frame. The exact value
47 * of frameno is not important but a large range of
48 * values is recommended.
49 */
50 virtual std::shared_ptr<Buffer> buffer(unsigned long frameno) const = 0;
51
35 virtual bool alpha_enabled() const = 0;52 virtual bool alpha_enabled() const = 0;
36 virtual geometry::Rectangle screen_position() const = 0;53 virtual geometry::Rectangle screen_position() const = 0;
3754
55 // These are from the old CompositingCriteria. There is a little bit
56 // of function overlap with the above functions still.
57 virtual float alpha() const = 0;
58
59 /**
60 * Transformation returns the transformation matrix that should be applied
61 * to the surface. By default when there are no transformations this will
62 * be the identity matrix.
63 *
64 * \warning As this functionality is presently only used by
65 * mir_demo_standalone_render_surfaces for rotations it may be
66 * deprecated in future. It is expected that real transformations
67 * may become more transient things (e.g. applied by animation
68 * logic externally instead of being a semi-permanent attribute of
69 * the surface itself).
70 */
71 virtual glm::mat4 transformation() const = 0;
72 virtual bool should_be_rendered_in(geometry::Rectangle const& rect) const = 0;
73 virtual bool shaped() const = 0; // meaning the pixel format has alpha
74 virtual int buffers_ready_for_compositor() const = 0;
75
38protected:76protected:
39 Renderable() = default;77 Renderable() = default;
40 virtual ~Renderable() = default;78 virtual ~Renderable() = default;
4179
=== modified file 'include/platform/mir/options/configuration.h'
--- include/platform/mir/options/configuration.h 2014-02-20 17:59:00 +0000
+++ include/platform/mir/options/configuration.h 2014-03-17 15:02:33 +0000
@@ -39,7 +39,6 @@
39extern char const* const scene_report_opt;39extern char const* const scene_report_opt;
40extern char const* const input_report_opt;40extern char const* const input_report_opt;
41extern char const* const host_socket_opt;41extern char const* const host_socket_opt;
42extern char const* const standalone_opt;
43extern char const* const frontend_threads_opt;42extern char const* const frontend_threads_opt;
4443
45extern char const* const name_opt;44extern char const* const name_opt;
4645
=== modified file 'include/server/mir/compositor/buffer_stream.h'
--- include/server/mir/compositor/buffer_stream.h 2014-02-10 09:07:48 +0000
+++ include/server/mir/compositor/buffer_stream.h 2014-03-17 15:02:33 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,5 * under the terms of the GNU General Public License version 3,
@@ -50,6 +50,7 @@
50 virtual void resize(geometry::Size const& size) = 0;50 virtual void resize(geometry::Size const& size) = 0;
51 virtual void allow_framedropping(bool) = 0;51 virtual void allow_framedropping(bool) = 0;
52 virtual void force_requests_to_complete() = 0;52 virtual void force_requests_to_complete() = 0;
53 virtual int buffers_ready_for_compositor() const = 0;
53};54};
5455
55}56}
5657
=== removed file 'include/server/mir/compositor/compositing_criteria.h'
--- include/server/mir/compositor/compositing_criteria.h 2014-03-10 19:28:33 +0000
+++ include/server/mir/compositor/compositing_criteria.h 1970-01-01 00:00:00 +0000
@@ -1,52 +0,0 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_COMPOSITOR_COMPOSITING_CRITERIA_H_
20#define MIR_COMPOSITOR_COMPOSITING_CRITERIA_H_
21
22#include <glm/glm.hpp>
23
24namespace mir
25{
26namespace geometry
27{
28struct Rectangle;
29}
30namespace compositor
31{
32
33class CompositingCriteria
34{
35public:
36 virtual float alpha() const = 0;
37 virtual glm::mat4 const& transformation() const = 0;
38 virtual bool should_be_rendered_in(geometry::Rectangle const& rect) const = 0;
39 virtual bool shaped() const = 0; // meaning the pixel format has alpha
40
41 virtual ~CompositingCriteria() = default;
42
43protected:
44 CompositingCriteria() = default;
45 CompositingCriteria(CompositingCriteria const&) = delete;
46 CompositingCriteria& operator=(CompositingCriteria const&) = delete;
47};
48
49}
50}
51
52#endif /* MIR_COMPOSITOR_COMPOSITING_CRITERIA_H_ */
530
=== modified file 'include/server/mir/compositor/display_buffer_compositor.h'
--- include/server/mir/compositor/display_buffer_compositor.h 2013-08-28 03:41:48 +0000
+++ include/server/mir/compositor/display_buffer_compositor.h 2014-03-17 15:02:33 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2012-2013 Canonical Ltd.2 * Copyright © 2012-2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,5 * under the terms of the GNU General Public License version 3,
@@ -30,7 +30,9 @@
30public:30public:
31 virtual ~DisplayBufferCompositor() = default;31 virtual ~DisplayBufferCompositor() = default;
3232
33 virtual void composite() = 0;33 /// Returns true if there is additional work to do. E.g. a composited surface
34 /// has additional buffers ready to composite or during animation
35 virtual bool composite() = 0;
3436
35protected:37protected:
36 DisplayBufferCompositor() = default;38 DisplayBufferCompositor() = default;
3739
=== renamed file 'src/server/compositor/gl_renderer.h' => 'include/server/mir/compositor/gl_renderer.h'
--- src/server/compositor/gl_renderer.h 2014-03-04 04:19:26 +0000
+++ include/server/mir/compositor/gl_renderer.h 2014-03-17 15:02:33 +0000
@@ -19,11 +19,12 @@
19#ifndef MIR_COMPOSITOR_GL_RENDERER_H_19#ifndef MIR_COMPOSITOR_GL_RENDERER_H_
20#define MIR_COMPOSITOR_GL_RENDERER_H_20#define MIR_COMPOSITOR_GL_RENDERER_H_
2121
22#include "renderer.h"22#include <mir/compositor/renderer.h>
23#include "mir/geometry/rectangle.h"23#include <mir/geometry/rectangle.h>
24#include "mir/graphics/buffer_id.h"24#include <mir/graphics/buffer_id.h>
25#include <GLES2/gl2.h>25#include <GLES2/gl2.h>
26#include <unordered_map>26#include <unordered_map>
27#include <vector>
2728
28namespace mir29namespace mir
29{30{
@@ -40,27 +41,52 @@
40 void set_viewport(geometry::Rectangle const& rect) override;41 void set_viewport(geometry::Rectangle const& rect) override;
41 void set_rotation(float degrees) override;42 void set_rotation(float degrees) override;
42 void begin() const override;43 void begin() const override;
43 void render(CompositingCriteria const& info, graphics::Buffer& buffer) const override;44 void render(graphics::Renderable const& renderable,
45 graphics::Buffer& buffer) const override;
44 void end() const override;46 void end() const override;
4547
46 // This is called _without_ a GL context:48 // This is called _without_ a GL context:
47 void suspend() override;49 void suspend() override;
4850
51 struct Vertex
52 {
53 GLfloat position[3];
54 GLfloat texcoord[2];
55 };
56
57 /**
58 * tessellate defines the list of triangles that will be used to render
59 * the surface. By default it just returns 4 vertices for a rectangle.
60 * However you can override its behaviour to tessellate more finely and
61 * deform freely for effects like wobbly windows.
62 *
63 * \returns The mode to be passed to glDrawArrays, e.g. GL_TRIANGLE_STRIP,
64 * GL_TRIANGLE_FAN or GL_TRIANGLES.
65 *
66 * \note The cohesion of this function to GLRenderer is quite loose and it
67 * does not strictly need to reside here.
68 * However it seems a good choice under GLRenderer while this remains
69 * the only OpenGL-specific class in the display server, and
70 * tessellation is very much OpenGL-specific.
71 */
72 virtual GLenum tessellate(graphics::Renderable const& renderable,
73 std::vector<Vertex>& vertices) const;
74
49private:75private:
50 GLuint vertex_shader;76 GLuint vertex_shader;
51 GLuint fragment_shader;77 GLuint fragment_shader;
52 GLuint program;78 GLuint program;
53 GLuint position_attr_loc;79 GLuint position_attr_loc;
54 GLuint texcoord_attr_loc;80 GLuint texcoord_attr_loc;
81 GLuint centre_uniform_loc;
55 GLuint display_transform_uniform_loc;82 GLuint display_transform_uniform_loc;
56 GLuint transform_uniform_loc;83 GLuint transform_uniform_loc;
57 GLuint alpha_uniform_loc;84 GLuint alpha_uniform_loc;
58 GLuint vertex_attribs_vbo;
59 float rotation;85 float rotation;
6086
61 geometry::Rectangle viewport;87 geometry::Rectangle viewport;
6288
63 typedef CompositingCriteria const* SurfaceID;89 typedef graphics::Renderable const* SurfaceID;
64 struct Texture90 struct Texture
65 {91 {
66 GLuint id = 0;92 GLuint id = 0;
6793
=== renamed file 'src/server/compositor/renderer.h' => 'include/server/mir/compositor/renderer.h'
--- src/server/compositor/renderer.h 2014-03-04 04:19:26 +0000
+++ include/server/mir/compositor/renderer.h 2014-03-17 15:02:33 +0000
@@ -26,10 +26,10 @@
26namespace graphics26namespace graphics
27{27{
28class Buffer;28class Buffer;
29class Renderable;
29}30}
30namespace compositor31namespace compositor
31{32{
32class CompositingCriteria;
3333
34class Renderer34class Renderer
35{35{
@@ -39,7 +39,11 @@
39 virtual void set_viewport(geometry::Rectangle const& rect) = 0;39 virtual void set_viewport(geometry::Rectangle const& rect) = 0;
40 virtual void set_rotation(float degrees) = 0;40 virtual void set_rotation(float degrees) = 0;
41 virtual void begin() const = 0;41 virtual void begin() const = 0;
42 virtual void render(CompositingCriteria const& info, graphics::Buffer& buffer) const = 0;42
43 // XXX The buffer parameter here could now be replaced with a "frameno"
44 // instead, and use renderable.buffer(frameno). Is that better?
45 virtual void render(graphics::Renderable const& renderable,
46 graphics::Buffer& buffer) const = 0;
43 virtual void end() const = 0;47 virtual void end() const = 0;
4448
45 virtual void suspend() = 0; // called when begin/render/end skipped49 virtual void suspend() = 0; // called when begin/render/end skipped
4650
=== renamed file 'src/server/compositor/renderer_factory.h' => 'include/server/mir/compositor/renderer_factory.h'
=== modified file 'include/server/mir/compositor/scene.h'
--- include/server/mir/compositor/scene.h 2014-03-04 04:19:26 +0000
+++ include/server/mir/compositor/scene.h 2014-03-17 15:02:33 +0000
@@ -26,17 +26,16 @@
2626
27namespace mir27namespace mir
28{28{
29namespace graphics { class Renderable; }
29namespace compositor30namespace compositor
30{31{
31class BufferStream;
32class CompositingCriteria;
3332
34class FilterForScene33class FilterForScene
35{34{
36public:35public:
37 virtual ~FilterForScene() {}36 virtual ~FilterForScene() {}
3837
39 virtual bool operator()(CompositingCriteria const&) = 0;38 virtual bool operator()(graphics::Renderable const&) = 0;
4039
41protected:40protected:
42 FilterForScene() = default;41 FilterForScene() = default;
@@ -49,7 +48,7 @@
49public:48public:
50 virtual ~OperatorForScene() {}49 virtual ~OperatorForScene() {}
5150
52 virtual void operator()(CompositingCriteria const&, BufferStream&) = 0;51 virtual void operator()(graphics::Renderable const&) = 0;
5352
54protected:53protected:
55 OperatorForScene() = default;54 OperatorForScene() = default;
5655
=== modified file 'include/server/mir/frontend/screencast.h'
--- include/server/mir/frontend/screencast.h 2014-01-30 13:08:32 +0000
+++ include/server/mir/frontend/screencast.h 2014-03-17 15:02:33 +0000
@@ -39,7 +39,9 @@
39 virtual ~Screencast() = default;39 virtual ~Screencast() = default;
4040
41 virtual ScreencastSessionId create_session(41 virtual ScreencastSessionId create_session(
42 graphics::DisplayConfigurationOutputId output_id) = 0;42 mir::geometry::Rectangle const& region,
43 mir::geometry::Size const& size,
44 MirPixelFormat pixel_format) = 0;
43 virtual void destroy_session(ScreencastSessionId id) = 0;45 virtual void destroy_session(ScreencastSessionId id) = 0;
44 virtual std::shared_ptr<graphics::Buffer> capture(ScreencastSessionId id) = 0;46 virtual std::shared_ptr<graphics::Buffer> capture(ScreencastSessionId id) = 0;
4547
4648
=== modified file 'include/server/mir/shell/session.h'
--- include/server/mir/shell/session.h 2014-03-04 04:19:26 +0000
+++ include/server/mir/shell/session.h 2014-03-17 15:02:33 +0000
@@ -33,7 +33,6 @@
33class Session : public frontend::Session33class Session : public frontend::Session
34{34{
35public:35public:
36 virtual std::string name() const = 0;
37 virtual void force_requests_to_complete() = 0;36 virtual void force_requests_to_complete() = 0;
38 virtual pid_t process_id() const = 0;37 virtual pid_t process_id() const = 0;
3938
4039
=== modified file 'include/shared/mir_toolkit/client_types.h'
--- include/shared/mir_toolkit/client_types.h 2014-02-10 09:07:48 +0000
+++ include/shared/mir_toolkit/client_types.h 2014-03-17 15:02:33 +0000
@@ -267,15 +267,35 @@
267 void *context;267 void *context;
268} MirEventDelegate;268} MirEventDelegate;
269269
270typedef struct MirRectangle
271{
272 int left;
273 int top;
274 unsigned int width;
275 unsigned int height;
276} MirRectangle;
277
270/**278/**
271 * MirScreencastParameters is the structure of required information that279 * MirScreencastParameters is the structure of required information that
272 * you must provide to Mir in order to create a MirScreencast.280 * you must provide to Mir in order to create a MirScreencast.
281 * The width and height parameters can be used to down-scale the screencast
282 * For no scaling set them to the region width and height.
273 */283 */
274typedef struct MirScreencastParameters284typedef struct MirScreencastParameters
275{285{
276 uint32_t output_id;286 /**
277 uint32_t width;287 * The rectangular region of the screen to capture -
278 uint32_t height;288 * The region is specified in virtual screen space hence multiple screens can be captured simultaneously
289 */
290 MirRectangle region;
291 /** The width of the screencast which can be different than the screen region capture width */
292 unsigned int width;
293 /** The height of the screencast which can be different than the screen region capture height */
294 unsigned int height;
295 /**
296 * The pixel format of the screencast.
297 * It must be a supported format obtained from mir_connection_get_available_surface_formats.
298 */
279 MirPixelFormat pixel_format;299 MirPixelFormat pixel_format;
280} MirScreencastParameters;300} MirScreencastParameters;
281301
282302
=== renamed directory 'include/test/mir_test/draw' => 'include/shared/testdraw'
=== modified file 'include/shared/testdraw/draw_pattern_checkered-inl.h'
--- include/test/mir_test/draw/draw_pattern_checkered-inl.h 2014-03-04 04:19:26 +0000
+++ include/shared/testdraw/draw_pattern_checkered-inl.h 2014-03-17 15:02:33 +0000
@@ -2,15 +2,15 @@
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.6 * as published by the Free Software Foundation.
7 *7 *
8 * This program is distributed in the hope that it will be useful,8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.11 * GNU Lesser General Public License for more details.
12 *12 *
13 * You should have received a copy of the GNU General Public License13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
1717
=== modified file 'include/shared/testdraw/graphics_region_factory.h'
--- include/test/mir_test/draw/graphics_region_factory.h 2014-03-04 04:19:26 +0000
+++ include/shared/testdraw/graphics_region_factory.h 2014-03-17 15:02:33 +0000
@@ -2,15 +2,15 @@
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.6 * as published by the Free Software Foundation.
7 *7 *
8 * This program is distributed in the hope that it will be useful,8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.11 * GNU Lesser General Public License for more details.
12 *12 *
13 * You should have received a copy of the GNU General Public License13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
@@ -34,7 +34,7 @@
34public:34public:
35 virtual ~GraphicsRegionFactory() {}35 virtual ~GraphicsRegionFactory() {}
36 virtual std::shared_ptr<MirGraphicsRegion> graphic_region_from_handle(36 virtual std::shared_ptr<MirGraphicsRegion> graphic_region_from_handle(
37 graphics::NativeBuffer const& native_buffer) = 0;37 graphics::NativeBuffer& native_buffer) = 0;
3838
39protected:39protected:
40 GraphicsRegionFactory() = default;40 GraphicsRegionFactory() = default;
4141
=== modified file 'include/shared/testdraw/patterns.h'
--- include/test/mir_test/draw/patterns.h 2014-03-04 04:19:26 +0000
+++ include/shared/testdraw/patterns.h 2014-03-17 15:02:33 +0000
@@ -2,15 +2,15 @@
2 * Copyright © 2012 Canonical Ltd.2 * Copyright © 2012 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.6 * as published by the Free Software Foundation.
7 *7 *
8 * This program is distributed in the hope that it will be useful,8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.11 * GNU Lesser General Public License for more details.
12 *12 *
13 * You should have received a copy of the GNU General Public License13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
1717
=== renamed file 'include/test/mir_test_doubles/stub_compositing_criteria.h' => 'include/test/mir_test_doubles/fake_renderable.h'
--- include/test/mir_test_doubles/stub_compositing_criteria.h 2014-03-04 04:19:26 +0000
+++ include/test/mir_test_doubles/fake_renderable.h 2014-03-17 15:02:33 +0000
@@ -16,10 +16,11 @@
16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */17 */
1818
19#ifndef MIR_TEST_DOUBLES_STUB_COMPOSITING_CRITERIA_H_19#ifndef MIR_TEST_DOUBLES_FAKE_RENDERABLE_H_
20#define MIR_TEST_DOUBLES_STUB_COMPOSITING_CRITERIA_H_20#define MIR_TEST_DOUBLES_FAKE_RENDERABLE_H_
2121
22#include "mir/compositor/compositing_criteria.h"22#include "mir/graphics/renderable.h"
23#define GLM_FORCE_RADIANS
23#include <glm/gtc/matrix_transform.hpp>24#include <glm/gtc/matrix_transform.hpp>
24#include <gmock/gmock.h>25#include <gmock/gmock.h>
2526
@@ -30,24 +31,20 @@
30namespace doubles31namespace doubles
31{32{
3233
33class StubCompositingCriteria : public compositor::CompositingCriteria34class FakeRenderable : public graphics::Renderable
34{35{
35public:36public:
36 StubCompositingCriteria(int x, int y, int width, int height,37 FakeRenderable(int x, int y, int width, int height,
37 float opacity=1.0f,38 float opacity=1.0f,
38 bool rectangular=true,39 bool rectangular=true,
39 bool visible=true,40 bool visible=true,
40 bool posted=true)41 bool posted=true)
41 : rect{{x, y}, {width, height}},42 : rect{{x, y}, {width, height}},
42 opacity(opacity),43 opacity(opacity),
43 rectangular(rectangular),44 rectangular(rectangular),
44 visible(visible),45 visible(visible),
45 posted(posted)46 posted(posted)
46 {47 {
47 const glm::mat4 ident;
48 glm::vec3 size(width, height, 0.0f);
49 glm::vec3 pos(x + width / 2, y + height / 2, 0.0f);
50 trans = glm::scale( glm::translate(ident, pos), size);
51 }48 }
5249
53 float alpha() const override50 float alpha() const override
@@ -55,9 +52,9 @@
55 return opacity;52 return opacity;
56 }53 }
5754
58 glm::mat4 const& transformation() const override55 glm::mat4 transformation() const override
59 {56 {
60 return trans;57 return glm::mat4();
61 }58 }
6259
63 bool should_be_rendered_in(const mir::geometry::Rectangle &r) const override60 bool should_be_rendered_in(const mir::geometry::Rectangle &r) const override
@@ -70,9 +67,34 @@
70 return !rectangular;67 return !rectangular;
71 }68 }
7269
70 void set_buffer(std::shared_ptr<graphics::Buffer> b)
71 {
72 buf = b;
73 }
74
75 std::shared_ptr<graphics::Buffer> buffer(unsigned long) const override
76 {
77 return buf;
78 }
79
80 bool alpha_enabled() const override
81 {
82 return shaped() || alpha() < 1.0f;
83 }
84
85 geometry::Rectangle screen_position() const override
86 {
87 return rect;
88 }
89
90 int buffers_ready_for_compositor() const override
91 {
92 return 1;
93 }
94
73private:95private:
96 std::shared_ptr<graphics::Buffer> buf;
74 mir::geometry::Rectangle rect;97 mir::geometry::Rectangle rect;
75 glm::mat4 trans;
76 float opacity;98 float opacity;
77 bool rectangular;99 bool rectangular;
78 bool visible;100 bool visible;
@@ -82,4 +104,4 @@
82} // namespace doubles104} // namespace doubles
83} // namespace test105} // namespace test
84} // namespace mir106} // namespace mir
85#endif // MIR_TEST_DOUBLES_STUB_COMPOSITING_CRITERIA_H_107#endif // MIR_TEST_DOUBLES_FAKE_RENDERABLE_H_
86108
=== modified file 'include/test/mir_test_doubles/mock_android_native_buffer.h'
--- include/test/mir_test_doubles/mock_android_native_buffer.h 2014-02-10 09:07:48 +0000
+++ include/test/mir_test_doubles/mock_android_native_buffer.h 2014-03-17 15:02:33 +0000
@@ -20,6 +20,7 @@
20#define MIR_TEST_DOUBLES_MOCK_ANDROID_NATIVE_BUFFER_H_20#define MIR_TEST_DOUBLES_MOCK_ANDROID_NATIVE_BUFFER_H_
2121
22#include "mir/graphics/android/native_buffer.h"22#include "mir/graphics/android/native_buffer.h"
23#include "mir/geometry/size.h"
23#include <gmock/gmock.h>24#include <gmock/gmock.h>
2425
25namespace mir26namespace mir
@@ -41,6 +42,14 @@
41 ON_CALL(*this, copy_fence())42 ON_CALL(*this, copy_fence())
42 .WillByDefault(Return(-1));43 .WillByDefault(Return(-1));
43 }44 }
45
46 MockAndroidNativeBuffer(geometry::Size sz)
47 : MockAndroidNativeBuffer()
48 {
49 stub_anwb.width = sz.width.as_int();
50 stub_anwb.height = sz.height.as_int();
51 }
52
44 MOCK_CONST_METHOD0(anwb, ANativeWindowBuffer*());53 MOCK_CONST_METHOD0(anwb, ANativeWindowBuffer*());
45 MOCK_CONST_METHOD0(handle, buffer_handle_t());54 MOCK_CONST_METHOD0(handle, buffer_handle_t());
46 MOCK_CONST_METHOD0(copy_fence, graphics::android::NativeFence());55 MOCK_CONST_METHOD0(copy_fence, graphics::android::NativeFence());
4756
=== modified file 'include/test/mir_test_doubles/mock_buffer_bundle.h'
--- include/test/mir_test_doubles/mock_buffer_bundle.h 2014-02-10 09:07:48 +0000
+++ include/test/mir_test_doubles/mock_buffer_bundle.h 2014-03-17 15:02:33 +0000
@@ -48,6 +48,7 @@
48 MOCK_METHOD0(force_client_abort, void());48 MOCK_METHOD0(force_client_abort, void());
49 MOCK_METHOD0(force_requests_to_complete, void());49 MOCK_METHOD0(force_requests_to_complete, void());
50 MOCK_METHOD1(resize, void(const geometry::Size &));50 MOCK_METHOD1(resize, void(const geometry::Size &));
51 int buffers_ready_for_compositor() const override { return 1; }
51};52};
5253
53}54}
5455
=== modified file 'include/test/mir_test_doubles/mock_buffer_stream.h'
--- include/test/mir_test_doubles/mock_buffer_stream.h 2014-02-10 09:07:48 +0000
+++ include/test/mir_test_doubles/mock_buffer_stream.h 2014-03-17 15:02:33 +0000
@@ -42,6 +42,7 @@
42 MOCK_METHOD0(force_client_completion, void());42 MOCK_METHOD0(force_client_completion, void());
43 MOCK_METHOD1(allow_framedropping, void(bool));43 MOCK_METHOD1(allow_framedropping, void(bool));
44 MOCK_METHOD0(force_requests_to_complete, void());44 MOCK_METHOD0(force_requests_to_complete, void());
45 int buffers_ready_for_compositor() const override { return 1; }
45};46};
46}47}
47}48}
4849
=== removed file 'include/test/mir_test_doubles/mock_compositing_criteria.h'
--- include/test/mir_test_doubles/mock_compositing_criteria.h 2014-03-10 19:28:33 +0000
+++ include/test/mir_test_doubles/mock_compositing_criteria.h 1970-01-01 00:00:00 +0000
@@ -1,45 +0,0 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_MOCK_COMPOSITING_CRITERIA_H_
20#define MIR_TEST_DOUBLES_MOCK_COMPOSITING_CRITERIA_H_
21
22#include "mir/compositor/compositing_criteria.h"
23#include <gmock/gmock.h>
24
25namespace mir
26{
27namespace test
28{
29namespace doubles
30{
31
32class MockCompositingCriteria : public compositor::CompositingCriteria
33{
34public:
35 ~MockCompositingCriteria() noexcept {}
36 MOCK_CONST_METHOD0(alpha, float());
37 MOCK_CONST_METHOD0(transformation, glm::mat4 const&());
38 MOCK_CONST_METHOD1(should_be_rendered_in, bool(geometry::Rectangle const&));
39 MOCK_CONST_METHOD0(shaped, bool());
40};
41
42}
43}
44}
45#endif /* MIR_TEST_DOUBLES_MOCK_COMPOSITING_CRITERIA_H_ */
460
=== modified file 'include/test/mir_test_doubles/mock_display_device.h'
--- include/test/mir_test_doubles/mock_display_device.h 2014-02-28 13:51:43 +0000
+++ include/test/mir_test_doubles/mock_display_device.h 2014-03-17 15:02:33 +0000
@@ -21,6 +21,7 @@
2121
22#include "mir/graphics/buffer.h"22#include "mir/graphics/buffer.h"
23#include "src/platform/graphics/android/display_device.h"23#include "src/platform/graphics/android/display_device.h"
24#include "src/platform/graphics/android/gl_context.h"
24#include <gmock/gmock.h>25#include <gmock/gmock.h>
2526
26namespace mir27namespace mir
@@ -34,9 +35,11 @@
34public:35public:
35 ~MockDisplayDevice() noexcept {}36 ~MockDisplayDevice() noexcept {}
36 MOCK_METHOD1(mode, void(MirPowerMode));37 MOCK_METHOD1(mode, void(MirPowerMode));
37 MOCK_METHOD0(prepare_gl, void());38 MOCK_METHOD1(render_gl, void(graphics::android::SwappingGLContext const&));
38 MOCK_METHOD1(prepare_gl_and_overlays, void(std::list<std::shared_ptr<graphics::Renderable>> const&));39 MOCK_METHOD3(render_gl_and_overlays, void(
39 MOCK_METHOD2(gpu_render, void(EGLDisplay, EGLSurface));40 graphics::android::SwappingGLContext const&,
41 std::list<std::shared_ptr<graphics::Renderable>> const&,
42 std::function<void(graphics::Renderable const&)> const&));
40 MOCK_METHOD1(post, void(graphics::Buffer const&));43 MOCK_METHOD1(post, void(graphics::Buffer const&));
41 MOCK_CONST_METHOD1(apply_orientation, bool(MirOrientation));44 MOCK_CONST_METHOD1(apply_orientation, bool(MirOrientation));
42};45};
4346
=== modified file 'include/test/mir_test_doubles/mock_gl.h'
--- include/test/mir_test_doubles/mock_gl.h 2014-02-10 09:07:48 +0000
+++ include/test/mir_test_doubles/mock_gl.h 2014-03-17 15:02:33 +0000
@@ -61,6 +61,7 @@
61 MOCK_METHOD3(glDrawArrays, void(GLenum, GLint, GLsizei));61 MOCK_METHOD3(glDrawArrays, void(GLenum, GLint, GLsizei));
62 MOCK_METHOD1(glEnable, void(GLenum));62 MOCK_METHOD1(glEnable, void(GLenum));
63 MOCK_METHOD1(glEnableVertexAttribArray, void(GLuint));63 MOCK_METHOD1(glEnableVertexAttribArray, void(GLuint));
64 MOCK_METHOD0(glFinish, void());
64 MOCK_METHOD4(glFramebufferRenderbuffer,65 MOCK_METHOD4(glFramebufferRenderbuffer,
65 void(GLenum, GLenum, GLenum, GLuint));66 void(GLenum, GLenum, GLenum, GLuint));
66 MOCK_METHOD5(glFramebufferTexture2D,67 MOCK_METHOD5(glFramebufferTexture2D,
@@ -92,7 +93,8 @@
92 void(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum,93 void(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum,
93 GLenum,const GLvoid*));94 GLenum,const GLvoid*));
94 MOCK_METHOD3(glTexParameteri, void(GLenum, GLenum, GLenum));95 MOCK_METHOD3(glTexParameteri, void(GLenum, GLenum, GLenum));
95 MOCK_METHOD2(glUniform1f, void(GLuint, GLfloat));96 MOCK_METHOD2(glUniform1f, void(GLint, GLfloat));
97 MOCK_METHOD3(glUniform2f, void(GLint, GLfloat, GLfloat));
96 MOCK_METHOD2(glUniform1i, void(GLint, GLint));98 MOCK_METHOD2(glUniform1i, void(GLint, GLint));
97 MOCK_METHOD4(glUniformMatrix4fv,99 MOCK_METHOD4(glUniformMatrix4fv,
98 void(GLuint, GLsizei, GLboolean, const GLfloat *));100 void(GLuint, GLsizei, GLboolean, const GLfloat *));
@@ -101,7 +103,6 @@
101 void(GLuint, GLint, GLenum, GLboolean, GLsizei,103 void(GLuint, GLint, GLenum, GLboolean, GLsizei,
102 const GLvoid *));104 const GLvoid *));
103 MOCK_METHOD4(glViewport, void(GLint, GLint, GLsizei, GLsizei));105 MOCK_METHOD4(glViewport, void(GLint, GLint, GLsizei, GLsizei));
104 MOCK_METHOD0(glFinish, void());
105};106};
106107
107}108}
108109
=== added file 'include/test/mir_test_doubles/mock_render_function.h'
--- include/test/mir_test_doubles/mock_render_function.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/mock_render_function.h 2014-03-17 15:02:33 +0000
@@ -0,0 +1,40 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_MOCK_RENDER_FUNCTION_H_
20#define MIR_TEST_DOUBLES_MOCK_RENDER_FUNCTION_H_
21
22#include <mir/graphics/renderable.h>
23
24namespace mir
25{
26namespace test
27{
28namespace doubles
29{
30
31struct MockRenderFunction
32{
33 MOCK_METHOD1(called, void(graphics::Renderable const&));
34};
35
36}
37}
38}
39
40#endif /* MIR_TEST_DOUBLES_MOCK_RENDER_FUNCTION_H_ */
041
=== added file 'include/test/mir_test_doubles/mock_render_function.h.moved'
--- include/test/mir_test_doubles/mock_render_function.h.moved 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/mock_render_function.h.moved 2014-03-17 15:02:33 +0000
@@ -0,0 +1,40 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_MOCK_RENDER_FUNCTION_H_
20#define MIR_TEST_DOUBLES_MOCK_RENDER_FUNCTION_H_
21
22#include <mir/graphics/renderable.h>
23
24namespace mir
25{
26namespace test
27{
28namespace doubles
29{
30
31struct MockRenderFunction
32{
33 MOCK_METHOD1(called, void(graphics::Renderable const&));
34};
35
36}
37}
38}
39
40#endif /* MIR_TEST_DOUBLES_MOCK_RENDER_FUNCTION_H_ */
041
=== modified file 'include/test/mir_test_doubles/mock_renderable.h'
--- include/test/mir_test_doubles/mock_renderable.h 2014-03-04 04:19:26 +0000
+++ include/test/mir_test_doubles/mock_renderable.h 2014-03-17 15:02:33 +0000
@@ -19,6 +19,7 @@
19#ifndef MIR_TEST_DOUBLES_MOCK_RENDERABLE_H_19#ifndef MIR_TEST_DOUBLES_MOCK_RENDERABLE_H_
20#define MIR_TEST_DOUBLES_MOCK_RENDERABLE_H_20#define MIR_TEST_DOUBLES_MOCK_RENDERABLE_H_
2121
22#include "mir_test_doubles/stub_buffer.h"
22#include <mir/graphics/renderable.h>23#include <mir/graphics/renderable.h>
23#include <gmock/gmock.h>24#include <gmock/gmock.h>
2425
@@ -30,9 +31,21 @@
30{31{
31struct MockRenderable : public graphics::Renderable32struct MockRenderable : public graphics::Renderable
32{33{
33 MOCK_CONST_METHOD0(buffer, std::shared_ptr<graphics::Buffer>());34 MockRenderable()
35 {
36 ON_CALL(*this, screen_position())
37 .WillByDefault(testing::Return(geometry::Rectangle{{},{}}));
38 ON_CALL(*this, buffer(testing::_))
39 .WillByDefault(testing::Return(std::make_shared<StubBuffer>()));
40 }
41 MOCK_CONST_METHOD1(buffer, std::shared_ptr<graphics::Buffer>(unsigned long));
34 MOCK_CONST_METHOD0(alpha_enabled, bool());42 MOCK_CONST_METHOD0(alpha_enabled, bool());
35 MOCK_CONST_METHOD0(screen_position, geometry::Rectangle());43 MOCK_CONST_METHOD0(screen_position, geometry::Rectangle());
44 MOCK_CONST_METHOD0(alpha, float());
45 MOCK_CONST_METHOD0(transformation, glm::mat4());
46 MOCK_CONST_METHOD1(should_be_rendered_in, bool(geometry::Rectangle const& rect));
47 MOCK_CONST_METHOD0(shaped, bool());
48 int buffers_ready_for_compositor() const override { return 1; }
36};49};
37}50}
38}51}
3952
=== modified file 'include/test/mir_test_doubles/mock_renderer.h'
--- include/test/mir_test_doubles/mock_renderer.h 2014-03-04 04:19:26 +0000
+++ include/test/mir_test_doubles/mock_renderer.h 2014-03-17 15:02:33 +0000
@@ -18,7 +18,7 @@
18#ifndef MIR_TEST_DOUBLES_MOCK_RENDERER_H_18#ifndef MIR_TEST_DOUBLES_MOCK_RENDERER_H_
19#define MIR_TEST_DOUBLES_MOCK_RENDERER_H_19#define MIR_TEST_DOUBLES_MOCK_RENDERER_H_
2020
21#include "src/server/compositor/renderer.h"21#include "mir/compositor/renderer.h"
2222
23#include <gmock/gmock.h>23#include <gmock/gmock.h>
2424
@@ -34,7 +34,7 @@
34 MOCK_METHOD1(set_viewport, void(geometry::Rectangle const&));34 MOCK_METHOD1(set_viewport, void(geometry::Rectangle const&));
35 MOCK_METHOD1(set_rotation, void(float));35 MOCK_METHOD1(set_rotation, void(float));
36 MOCK_CONST_METHOD0(begin, void());36 MOCK_CONST_METHOD0(begin, void());
37 MOCK_CONST_METHOD2(render, void(compositor::CompositingCriteria const&, graphics::Buffer&));37 MOCK_CONST_METHOD2(render, void(graphics::Renderable const&, graphics::Buffer&));
38 MOCK_CONST_METHOD0(end, void());38 MOCK_CONST_METHOD0(end, void());
39 MOCK_METHOD0(suspend, void());39 MOCK_METHOD0(suspend, void());
4040
4141
=== added file 'include/test/mir_test_doubles/mock_scene.h'
--- include/test/mir_test_doubles/mock_scene.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/mock_scene.h 2014-03-17 15:02:33 +0000
@@ -0,0 +1,48 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_MOCK_SCENE_H_
20#define MIR_TEST_DOUBLES_MOCK_SCENE_H_
21
22#include "mir/compositor/scene.h"
23#include <gmock/gmock.h>
24
25namespace mir
26{
27namespace test
28{
29namespace doubles
30{
31
32class MockScene : public compositor::Scene
33{
34public:
35 MOCK_METHOD2(for_each_if, void(compositor::FilterForScene&,
36 compositor::OperatorForScene&));
37 MOCK_METHOD2(reverse_for_each_if, void(compositor::FilterForScene&,
38 compositor::OperatorForScene&));
39 MOCK_METHOD1(set_change_callback, void(std::function<void()> const&));
40 MOCK_METHOD0(lock, void());
41 MOCK_METHOD0(unlock, void());
42};
43
44} // namespace doubles
45} // namespace test
46} // namespace mir
47
48#endif /* MIR_TEST_DOUBLES_MOCK_SCENE_H_ */
049
=== modified file 'include/test/mir_test_doubles/mock_screencast.h'
--- include/test/mir_test_doubles/mock_screencast.h 2014-01-29 18:02:33 +0000
+++ include/test/mir_test_doubles/mock_screencast.h 2014-03-17 15:02:33 +0000
@@ -33,9 +33,11 @@
33class MockScreencast : public frontend::Screencast33class MockScreencast : public frontend::Screencast
34{34{
35public:35public:
36 MOCK_METHOD1(create_session,36 MOCK_METHOD3(create_session,
37 frontend::ScreencastSessionId(37 frontend::ScreencastSessionId(
38 graphics::DisplayConfigurationOutputId));38 geometry::Rectangle const&,
39 geometry::Size const&,
40 MirPixelFormat));
39 MOCK_METHOD1(destroy_session, void(frontend::ScreencastSessionId));41 MOCK_METHOD1(destroy_session, void(frontend::ScreencastSessionId));
40 MOCK_METHOD1(capture,42 MOCK_METHOD1(capture,
41 std::shared_ptr<graphics::Buffer>(43 std::shared_ptr<graphics::Buffer>(
4244
=== added file 'include/test/mir_test_doubles/mock_swapping_gl_context.h'
--- include/test/mir_test_doubles/mock_swapping_gl_context.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/mock_swapping_gl_context.h 2014-03-17 15:02:33 +0000
@@ -0,0 +1,39 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_MOCK_SWAPPING_GL_CONTEXT_H_
20#define MIR_TEST_DOUBLES_MOCK_SWAPPING_GL_CONTEXT_H_
21
22#include "src/platform/graphics/android/gl_context.h"
23
24namespace mir
25{
26namespace test
27{
28namespace doubles
29{
30
31struct MockSwappingGLContext : public graphics::android::SwappingGLContext
32{
33 MOCK_CONST_METHOD0(swap_buffers, void());
34};
35
36}
37}
38}
39#endif // MIR_TEST_DOUBLES_MOCK_COMPOSITING_CRITERIA_H_
040
=== modified file 'include/test/mir_test_doubles/null_display_configuration.h'
--- include/test/mir_test_doubles/null_display_configuration.h 2014-03-05 02:30:30 +0000
+++ include/test/mir_test_doubles/null_display_configuration.h 2014-03-17 15:02:33 +0000
@@ -35,7 +35,7 @@
35 void for_each_output(std::function<void(graphics::DisplayConfigurationOutput const&)>) const override35 void for_each_output(std::function<void(graphics::DisplayConfigurationOutput const&)>) const override
36 {36 {
37 }37 }
38 void configure_output(graphics::DisplayConfigurationOutputId, bool, geometry::Point, size_t, MirPixelFormat, MirPowerMode, MirOrientation) override38 void for_each_output(std::function<void(graphics::UserDisplayConfigurationOutput&)>) override
39 {39 {
40 }40 }
41};41};
4242
=== modified file 'include/test/mir_test_doubles/null_screencast.h'
--- include/test/mir_test_doubles/null_screencast.h 2014-01-29 18:02:33 +0000
+++ include/test/mir_test_doubles/null_screencast.h 2014-03-17 15:02:33 +0000
@@ -32,7 +32,9 @@
32{32{
33public:33public:
34 frontend::ScreencastSessionId create_session(34 frontend::ScreencastSessionId create_session(
35 graphics::DisplayConfigurationOutputId)35 geometry::Rectangle const&,
36 geometry::Size const&,
37 MirPixelFormat)
36 {38 {
37 return frontend::ScreencastSessionId{1};39 return frontend::ScreencastSessionId{1};
38 }40 }
3941
=== modified file 'include/test/mir_test_doubles/stub_buffer.h'
--- include/test/mir_test_doubles/stub_buffer.h 2014-03-04 04:19:26 +0000
+++ include/test/mir_test_doubles/stub_buffer.h 2014-03-17 15:02:33 +0000
@@ -39,20 +39,31 @@
39{39{
40public:40public:
41 StubBuffer()41 StubBuffer()
42 : buf_size{0, 0},42 : StubBuffer{
43 buf_pixel_format{mir_pixel_format_abgr_8888}43 graphics::BufferProperties{
44 geometry::Size{},
45 mir_pixel_format_abgr_8888,
46 graphics::BufferUsage::hardware}}
47
44 {48 {
45 }49 }
4650
47 StubBuffer(graphics::BufferProperties const& properties)51 StubBuffer(graphics::BufferProperties const& properties)
52 : StubBuffer{properties, geometry::Stride{}}
53 {
54 }
55
56 StubBuffer(graphics::BufferProperties const& properties,
57 geometry::Stride stride)
48 : buf_size{properties.size},58 : buf_size{properties.size},
49 buf_pixel_format{properties.format}59 buf_pixel_format{properties.format},
60 buf_stride{stride}
50 {61 {
51 }62 }
5263
53 virtual geometry::Size size() const { return buf_size; }64 virtual geometry::Size size() const { return buf_size; }
5465
55 virtual geometry::Stride stride() const { return geometry::Stride(); }66 virtual geometry::Stride stride() const { return buf_stride; }
5667
57 virtual MirPixelFormat pixel_format() const { return buf_pixel_format; }68 virtual MirPixelFormat pixel_format() const { return buf_pixel_format; }
5869
@@ -70,6 +81,7 @@
7081
71 geometry::Size const buf_size;82 geometry::Size const buf_size;
72 MirPixelFormat const buf_pixel_format;83 MirPixelFormat const buf_pixel_format;
84 geometry::Stride const buf_stride;
73};85};
74}86}
75}87}
7688
=== modified file 'include/test/mir_test_doubles/stub_buffer_stream.h'
--- include/test/mir_test_doubles/stub_buffer_stream.h 2014-02-10 09:07:48 +0000
+++ include/test/mir_test_doubles/stub_buffer_stream.h 2014-03-17 15:02:33 +0000
@@ -72,6 +72,8 @@
72 {72 {
73 }73 }
7474
75 int buffers_ready_for_compositor() const override { return 1; }
76
75 StubBuffer stub_client_buffer;77 StubBuffer stub_client_buffer;
76 std::shared_ptr<graphics::Buffer> stub_compositor_buffer;78 std::shared_ptr<graphics::Buffer> stub_compositor_buffer;
77};79};
7880
=== modified file 'include/test/mir_test_doubles/stub_display_configuration.h'
--- include/test/mir_test_doubles/stub_display_configuration.h 2014-03-05 02:30:30 +0000
+++ include/test/mir_test_doubles/stub_display_configuration.h 2014-03-17 15:02:33 +0000
@@ -156,8 +156,13 @@
156 }156 }
157 }157 }
158158
159 void configure_output(graphics::DisplayConfigurationOutputId, bool, geometry::Point, size_t, MirPixelFormat, MirPowerMode, MirOrientation) override159 void for_each_output(std::function<void(graphics::UserDisplayConfigurationOutput&)> f) override
160 {160 {
161 for (auto& disp : outputs)
162 {
163 graphics::UserDisplayConfigurationOutput user(disp);
164 f(user);
165 }
161 }166 }
162167
163 std::vector<graphics::DisplayConfigurationCard> cards;168 std::vector<graphics::DisplayConfigurationCard> cards;
164169
=== modified file 'include/test/mir_test_doubles/stub_display_device.h'
--- include/test/mir_test_doubles/stub_display_device.h 2014-02-11 03:04:50 +0000
+++ include/test/mir_test_doubles/stub_display_device.h 2014-03-17 15:02:33 +0000
@@ -38,10 +38,13 @@
38 void mode(MirPowerMode)38 void mode(MirPowerMode)
39 {39 {
40 }40 }
41 void prepare_gl_and_overlays(std::list<std::shared_ptr<graphics::Renderable>> const&)41 void render_gl_and_overlays(
42 graphics::android::SwappingGLContext const&,
43 std::list<std::shared_ptr<graphics::Renderable>> const&,
44 std::function<void(graphics::Renderable const&)> const&)
42 {45 {
43 }46 }
44 void prepare_gl()47 void render_gl(graphics::android::SwappingGLContext const&)
45 {48 {
46 }49 }
47 void gpu_render(EGLDisplay, EGLSurface)50 void gpu_render(EGLDisplay, EGLSurface)
4851
=== modified file 'include/test/mir_test_doubles/stub_renderable.h'
--- include/test/mir_test_doubles/stub_renderable.h 2014-03-04 04:19:26 +0000
+++ include/test/mir_test_doubles/stub_renderable.h 2014-03-17 15:02:33 +0000
@@ -19,6 +19,7 @@
19#ifndef MIR_TEST_DOUBLES_STUB_RENDERABLE_H_19#ifndef MIR_TEST_DOUBLES_STUB_RENDERABLE_H_
20#define MIR_TEST_DOUBLES_STUB_RENDERABLE_H_20#define MIR_TEST_DOUBLES_STUB_RENDERABLE_H_
2121
22#include "mir_test_doubles/stub_buffer.h"
22#include <mir/graphics/renderable.h>23#include <mir/graphics/renderable.h>
23#include <memory>24#include <memory>
2425
@@ -32,9 +33,9 @@
32class StubRenderable : public graphics::Renderable33class StubRenderable : public graphics::Renderable
33{34{
34public:35public:
35 std::shared_ptr<graphics::Buffer> buffer() const36 std::shared_ptr<graphics::Buffer> buffer(unsigned long) const override
36 {37 {
37 return {};38 return std::make_shared<StubBuffer>();
38 }39 }
39 bool alpha_enabled() const40 bool alpha_enabled() const
40 {41 {
@@ -44,6 +45,30 @@
44 {45 {
45 return {{},{}};46 return {{},{}};
46 }47 }
48 float alpha() const override
49 {
50 return 1.0f;
51 }
52 glm::mat4 transformation() const override
53 {
54 return trans;
55 }
56 bool should_be_rendered_in(geometry::Rectangle const&) const override
57 {
58 return true;
59 }
60 bool shaped() const override
61 {
62 return false;
63 }
64
65 int buffers_ready_for_compositor() const override
66 {
67 return 1;
68 }
69
70private:
71 glm::mat4 trans;
47};72};
4873
49}74}
5075
=== modified file 'include/test/mir_test_doubles/stub_renderer.h'
--- include/test/mir_test_doubles/stub_renderer.h 2014-03-04 04:19:26 +0000
+++ include/test/mir_test_doubles/stub_renderer.h 2014-03-17 15:02:33 +0000
@@ -19,7 +19,7 @@
19#ifndef MIR_TEST_DOUBLES_STUB_RENDERER_H_19#ifndef MIR_TEST_DOUBLES_STUB_RENDERER_H_
20#define MIR_TEST_DOUBLES_STUB_RENDERER_H_20#define MIR_TEST_DOUBLES_STUB_RENDERER_H_
2121
22#include "src/server/compositor/renderer.h"22#include "mir/compositor/renderer.h"
2323
24namespace mir24namespace mir
25{25{
@@ -43,7 +43,7 @@
43 {43 {
44 }44 }
4545
46 void render(compositor::CompositingCriteria const&,46 void render(graphics::Renderable const&,
47 graphics::Buffer&) const override47 graphics::Buffer&) const override
48 {48 {
49 }49 }
5050
=== added file 'include/test/mir_test_doubles/stub_swapping_gl_context.h'
--- include/test/mir_test_doubles/stub_swapping_gl_context.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_doubles/stub_swapping_gl_context.h 2014-03-17 15:02:33 +0000
@@ -0,0 +1,39 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_TEST_DOUBLES_STUB_SWAPPING_GL_CONTEXT_H_
20#define MIR_TEST_DOUBLES_STUB_SWAPPING_GL_CONTEXT_H_
21
22#include "src/platform/graphics/android/gl_context.h"
23
24namespace mir
25{
26namespace test
27{
28namespace doubles
29{
30
31struct StubSwappingGLContext : public graphics::android::SwappingGLContext
32{
33 void swap_buffers() const {}
34};
35
36}
37}
38}
39#endif // MIR_TEST_DOUBLES_STUB_COMPOSITING_CRITERIA_H_
040
=== modified file 'src/client/CMakeLists.txt'
--- src/client/CMakeLists.txt 2014-02-28 13:51:43 +0000
+++ src/client/CMakeLists.txt 2014-03-17 15:02:33 +0000
@@ -72,6 +72,7 @@
72 mirsharedinput72 mirsharedinput
73 mirsharedlogging73 mirsharedlogging
74 mirsharedenv74 mirsharedenv
75 mirsharedgeometry
75 mirsharedsharedlibrary76 mirsharedsharedlibrary
76 mirclientrpc77 mirclientrpc
77 mirclientlttngstatic78 mirclientlttngstatic
7879
=== modified file 'src/client/android/CMakeLists.txt'
--- src/client/android/CMakeLists.txt 2014-02-28 13:51:43 +0000
+++ src/client/android/CMakeLists.txt 2014-03-17 15:02:33 +0000
@@ -26,6 +26,8 @@
26 ${LIBHARDWARE_LIBRARIES}26 ${LIBHARDWARE_LIBRARIES}
27)27)
2828
29install(TARGETS mirclientplatformandroid LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mir/clientplatform/android)
30
29if (MIR_TEST_PLATFORM STREQUAL "android")31if (MIR_TEST_PLATFORM STREQUAL "android")
30 add_custom_command(TARGET mirclientplatformandroid32 add_custom_command(TARGET mirclientplatformandroid
31 POST_BUILD33 POST_BUILD
@@ -33,6 +35,11 @@
33 COMMAND ${CMAKE_COMMAND} -E create_symlink android/$<TARGET_FILE_NAME:mirclientplatformandroid> libmirclientplatform.so35 COMMAND ${CMAKE_COMMAND} -E create_symlink android/$<TARGET_FILE_NAME:mirclientplatformandroid> libmirclientplatform.so
34 WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}36 WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
35 )37 )
38
39 install(CODE
40 "execute_process(
41 COMMAND ln -sf mir/clientplatform/android/libmirclientplatform.so
42 WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
43 )"
44 )
36endif()45endif()
37
38install(TARGETS mirclientplatformandroid LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mir/clientplatform/android)
3946
=== modified file 'src/client/mesa/CMakeLists.txt'
--- src/client/mesa/CMakeLists.txt 2014-02-28 13:51:43 +0000
+++ src/client/mesa/CMakeLists.txt 2014-03-17 15:02:33 +0000
@@ -27,6 +27,8 @@
27 ${DRM_LDFLAGS} ${DRM_LIBRARIES}27 ${DRM_LDFLAGS} ${DRM_LIBRARIES}
28)28)
2929
30install(TARGETS mirclientplatformmesa LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mir/clientplatform/mesa)
31
30if (MIR_TEST_PLATFORM STREQUAL "mesa")32if (MIR_TEST_PLATFORM STREQUAL "mesa")
31 add_custom_command(TARGET mirclientplatformmesa33 add_custom_command(TARGET mirclientplatformmesa
32 POST_BUILD34 POST_BUILD
@@ -34,7 +36,12 @@
34 COMMAND ${CMAKE_COMMAND} -E create_symlink mesa/$<TARGET_FILE_NAME:mirclientplatformmesa> libmirclientplatform.so36 COMMAND ${CMAKE_COMMAND} -E create_symlink mesa/$<TARGET_FILE_NAME:mirclientplatformmesa> libmirclientplatform.so
35 WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}37 WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
36 )38 )
39
40 install(CODE
41 "execute_process(
42 COMMAND ln -sf mir/clientplatform/mesa/libmirclientplatform.so
43 WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
44 )"
45 )
37endif()46endif()
3847
39install(TARGETS mirclientplatformmesa LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mir/clientplatform/mesa)
40
4148
=== modified file 'src/client/mir_screencast.cpp'
--- src/client/mir_screencast.cpp 2014-02-10 09:07:48 +0000
+++ src/client/mir_screencast.cpp 2014-03-17 15:02:33 +0000
@@ -31,23 +31,6 @@
3131
32void null_callback(MirScreencast*, void*) {}32void null_callback(MirScreencast*, void*) {}
3333
34geom::Size mir_output_get_size(MirDisplayOutput const& output)
35{
36 if (output.connected && output.used &&
37 output.current_mode < output.num_modes)
38 {
39 auto& current_mode = output.modes[output.current_mode];
40 return geom::Size{current_mode.horizontal_resolution,
41 current_mode.vertical_resolution};
42 }
43 else
44 {
45 BOOST_THROW_EXCEPTION(
46 std::runtime_error("Couldn't get size from invalid output"));
47 }
48}
49
50
51void populate_buffer_package(34void populate_buffer_package(
52 MirBufferPackage& buffer_package,35 MirBufferPackage& buffer_package,
53 mir::protobuf::Buffer const& protobuf_buffer)36 mir::protobuf::Buffer const& protobuf_buffer)
@@ -86,24 +69,38 @@
86}69}
8770
88MirScreencast::MirScreencast(71MirScreencast::MirScreencast(
89 MirDisplayOutput const& output,72 geom::Rectangle const& region,
73 geom::Size const& size,
74 MirPixelFormat pixel_format,
90 mir::protobuf::DisplayServer& server,75 mir::protobuf::DisplayServer& server,
91 std::shared_ptr<mcl::EGLNativeWindowFactory> const& egl_native_window_factory,76 std::shared_ptr<mcl::EGLNativeWindowFactory> const& egl_native_window_factory,
92 std::shared_ptr<mcl::ClientBufferFactory> const& factory,77 std::shared_ptr<mcl::ClientBufferFactory> const& factory,
93 mir_screencast_callback callback, void* context)78 mir_screencast_callback callback, void* context)
94 : server(server),79 : server(server),
95 output_id{output.output_id},80 output_size{size},
96 output_size{mir_output_get_size(output)},81 output_format{pixel_format},
97 output_format{output.current_format},
98 egl_native_window_factory{egl_native_window_factory},82 egl_native_window_factory{egl_native_window_factory},
99 buffer_depository{factory, mir::frontend::client_buffer_cache_size}83 buffer_depository{factory, mir::frontend::client_buffer_cache_size}
100{84{
85 if (output_size.width.as_int() == 0 ||
86 output_size.height.as_int() == 0 ||
87 region.size.width.as_int() == 0 ||
88 region.size.height.as_int() == 0 ||
89 pixel_format == mir_pixel_format_invalid)
90 {
91 BOOST_THROW_EXCEPTION(std::runtime_error("Invalid parameters"));
92 }
101 protobuf_screencast.set_error("Not initialized");93 protobuf_screencast.set_error("Not initialized");
10294
103 mir::protobuf::ScreencastParameters parameters;95 mir::protobuf::ScreencastParameters parameters;
104 parameters.set_output_id(output_id);96
97 parameters.mutable_region()->set_left(region.top_left.x.as_int());
98 parameters.mutable_region()->set_top(region.top_left.y.as_int());
99 parameters.mutable_region()->set_width(region.size.width.as_uint32_t());
100 parameters.mutable_region()->set_height(region.size.height.as_uint32_t());
105 parameters.set_width(output_size.width.as_uint32_t());101 parameters.set_width(output_size.width.as_uint32_t());
106 parameters.set_height(output_size.height.as_uint32_t());102 parameters.set_height(output_size.height.as_uint32_t());
103 parameters.set_pixel_format(pixel_format);
107104
108 server.create_screencast(105 server.create_screencast(
109 nullptr,106 nullptr,
@@ -132,7 +129,7 @@
132 output_size.height.as_int(),129 output_size.height.as_int(),
133 output_format,130 output_format,
134 mir_buffer_usage_hardware,131 mir_buffer_usage_hardware,
135 output_id};132 mir_display_output_id_invalid};
136}133}
137134
138std::shared_ptr<mcl::ClientBuffer> MirScreencast::get_current_buffer()135std::shared_ptr<mcl::ClientBuffer> MirScreencast::get_current_buffer()
139136
=== modified file 'src/client/mir_screencast.h'
--- src/client/mir_screencast.h 2014-02-10 09:07:48 +0000
+++ src/client/mir_screencast.h 2014-03-17 15:02:33 +0000
@@ -25,6 +25,7 @@
25#include "mir_toolkit/client_types.h"25#include "mir_toolkit/client_types.h"
26#include "mir_protobuf.pb.h"26#include "mir_protobuf.pb.h"
27#include "mir/geometry/size.h"27#include "mir/geometry/size.h"
28#include "mir/geometry/rectangle.h"
2829
29#include <EGL/eglplatform.h>30#include <EGL/eglplatform.h>
3031
@@ -42,7 +43,9 @@
42{43{
43public:44public:
44 MirScreencast(45 MirScreencast(
45 MirDisplayOutput const& output,46 mir::geometry::Rectangle const& region,
47 mir::geometry::Size const& size,
48 MirPixelFormat pixel_format,
46 mir::protobuf::DisplayServer& server,49 mir::protobuf::DisplayServer& server,
47 std::shared_ptr<mir::client::EGLNativeWindowFactory> const& egl_native_window_factory,50 std::shared_ptr<mir::client::EGLNativeWindowFactory> const& egl_native_window_factory,
48 std::shared_ptr<mir::client::ClientBufferFactory> const& factory,51 std::shared_ptr<mir::client::ClientBufferFactory> const& factory,
@@ -75,7 +78,6 @@
75 mir_screencast_callback callback, void* context);78 mir_screencast_callback callback, void* context);
7679
77 mir::protobuf::DisplayServer& server;80 mir::protobuf::DisplayServer& server;
78 uint32_t const output_id;
79 mir::geometry::Size const output_size;81 mir::geometry::Size const output_size;
80 MirPixelFormat const output_format;82 MirPixelFormat const output_format;
81 std::shared_ptr<mir::client::EGLNativeWindowFactory> const egl_native_window_factory;83 std::shared_ptr<mir::client::EGLNativeWindowFactory> const egl_native_window_factory;
8284
=== modified file 'src/client/mir_screencast_api.cpp'
--- src/client/mir_screencast_api.cpp 2014-02-18 02:12:21 +0000
+++ src/client/mir_screencast_api.cpp 2014-03-17 15:02:33 +0000
@@ -26,25 +26,7 @@
2626
27namespace27namespace
28{28{
29
30void null_callback(MirScreencast*, void*) {}29void null_callback(MirScreencast*, void*) {}
31
32MirDisplayOutput& find_display_output(
33 MirDisplayConfiguration const& config,
34 uint32_t output_id)
35{
36 for (decltype(config.num_outputs) i = 0; i != config.num_outputs; ++i)
37 {
38 if (config.outputs[i].output_id == output_id)
39 {
40 return config.outputs[i];
41 }
42 }
43
44 BOOST_THROW_EXCEPTION(
45 std::runtime_error("Couldn't find output with supplied id"));
46}
47
48}30}
4931
50MirScreencast* mir_connection_create_screencast_sync(32MirScreencast* mir_connection_create_screencast_sync(
@@ -64,9 +46,17 @@
6446
65 auto const client_platform = connection->get_client_platform();47 auto const client_platform = connection->get_client_platform();
6648
49 mir::geometry::Rectangle const region{
50 {parameters->region.left, parameters->region.top},
51 {parameters->region.width, parameters->region.height}
52 };
53 mir::geometry::Size const size{parameters->width, parameters->height};
54
67 std::unique_ptr<MirScreencast> screencast_uptr{55 std::unique_ptr<MirScreencast> screencast_uptr{
68 new MirScreencast{56 new MirScreencast{
69 find_display_output(*config, parameters->output_id),57 region,
58 size,
59 parameters->pixel_format,
70 connection->display_server(),60 connection->display_server(),
71 client_platform,61 client_platform,
72 client_platform->create_buffer_factory(),62 client_platform->create_buffer_factory(),
7363
=== modified file 'src/client/mir_surface.h'
--- src/client/mir_surface.h 2014-02-10 09:07:48 +0000
+++ src/client/mir_surface.h 2014-03-17 15:02:33 +0000
@@ -106,8 +106,6 @@
106 MirPixelFormat convert_ipc_pf_to_geometry(google::protobuf::int32 pf);106 MirPixelFormat convert_ipc_pf_to_geometry(google::protobuf::int32 pf);
107 void release_cpu_region();107 void release_cpu_region();
108108
109 /* todo: race condition. protobuf does not guarantee that callbacks will be synchronized. potential
110 race in surface, last_buffer_id */
111 mir::protobuf::DisplayServer::Stub & server;109 mir::protobuf::DisplayServer::Stub & server;
112 mir::protobuf::Surface surface;110 mir::protobuf::Surface surface;
113 std::string error_message;111 std::string error_message;
114112
=== modified file 'src/platform/graphics/CMakeLists.txt'
--- src/platform/graphics/CMakeLists.txt 2014-02-28 13:51:43 +0000
+++ src/platform/graphics/CMakeLists.txt 2014-03-17 15:02:33 +0000
@@ -10,6 +10,7 @@
10 display_configuration.cpp10 display_configuration.cpp
11 buffer_basic.cpp11 buffer_basic.cpp
12 pixel_format_utils.cpp12 pixel_format_utils.cpp
13 overlapping_output_grouping.cpp
13)14)
1415
15add_library(16add_library(
1617
=== modified file 'src/platform/graphics/android/CMakeLists.txt'
--- src/platform/graphics/android/CMakeLists.txt 2014-02-28 13:51:43 +0000
+++ src/platform/graphics/android/CMakeLists.txt 2014-03-17 15:02:33 +0000
@@ -32,6 +32,7 @@
32 interpreter_cache.cpp32 interpreter_cache.cpp
33 internal_client.cpp33 internal_client.cpp
34 gl_context.cpp34 gl_context.cpp
35 real_hwc_wrapper.cpp
35)36)
3637
37set_target_properties(38set_target_properties(
@@ -51,6 +52,8 @@
51 ${GLESv2_LDFLAGS} ${GLESv2_LIBRARIES}52 ${GLESv2_LDFLAGS} ${GLESv2_LIBRARIES}
52)53)
5354
55install(TARGETS mirplatformgraphicsandroid LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mir/platformgraphics/android)
56
54if (MIR_TEST_PLATFORM STREQUAL "android")57if (MIR_TEST_PLATFORM STREQUAL "android")
55 add_custom_command(TARGET mirplatformgraphicsandroid58 add_custom_command(TARGET mirplatformgraphicsandroid
56 POST_BUILD59 POST_BUILD
@@ -58,6 +61,11 @@
58 COMMAND ${CMAKE_COMMAND} -E create_symlink android/$<TARGET_FILE_NAME:mirplatformgraphicsandroid> libmirplatformgraphics.so61 COMMAND ${CMAKE_COMMAND} -E create_symlink android/$<TARGET_FILE_NAME:mirplatformgraphicsandroid> libmirplatformgraphics.so
59 WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}62 WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
60 )63 )
64
65 install(CODE
66 "execute_process(
67 COMMAND ln -sf mir/platformgraphics/android/libmirplatformgraphics.so
68 WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
69 )"
70 )
61endif()71endif()
62
63install(TARGETS mirplatformgraphicsandroid LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mir/platformgraphics/android)
6472
=== modified file 'src/platform/graphics/android/android_display.cpp'
--- src/platform/graphics/android/android_display.cpp 2014-03-05 02:30:30 +0000
+++ src/platform/graphics/android/android_display.cpp 2014-03-17 15:02:33 +0000
@@ -26,6 +26,8 @@
26#include "display_builder.h"26#include "display_builder.h"
27#include "mir/geometry/rectangle.h"27#include "mir/geometry/rectangle.h"
2828
29#include <boost/throw_exception.hpp>
30
29namespace mga=mir::graphics::android;31namespace mga=mir::graphics::android;
30namespace mg=mir::graphics;32namespace mg=mir::graphics;
31namespace geom=mir::geometry;33namespace geom=mir::geometry;
@@ -57,6 +59,12 @@
5759
58void mga::AndroidDisplay::configure(mg::DisplayConfiguration const& configuration)60void mga::AndroidDisplay::configure(mg::DisplayConfiguration const& configuration)
59{61{
62 if (!configuration.valid())
63 {
64 BOOST_THROW_EXCEPTION(
65 std::logic_error("Invalid or inconsistent display configuration"));
66 }
67
60 configuration.for_each_output([&](mg::DisplayConfigurationOutput const& output)68 configuration.for_each_output([&](mg::DisplayConfigurationOutput const& output)
61 {69 {
62 display_buffer->configure(output);70 display_buffer->configure(output);
6371
=== modified file 'src/platform/graphics/android/android_display_configuration.cpp'
--- src/platform/graphics/android/android_display_configuration.cpp 2014-03-05 02:30:30 +0000
+++ src/platform/graphics/android/android_display_configuration.cpp 2014-03-17 15:02:33 +0000
@@ -52,10 +52,9 @@
52 f(configuration);52 f(configuration);
53}53}
5454
55void mga::AndroidDisplayConfiguration::configure_output(55void mga::AndroidDisplayConfiguration::for_each_output(std::function<void(mg::UserDisplayConfigurationOutput&)> f)
56 mg::DisplayConfigurationOutputId, bool, geom::Point, size_t,
57 MirPixelFormat, MirPowerMode power_mode, MirOrientation orientation)
58{56{
59 configuration.power_mode = power_mode;57 mg::UserDisplayConfigurationOutput user(configuration);
60 configuration.orientation = orientation;58 f(user);
61}59}
60
6261
=== modified file 'src/platform/graphics/android/android_display_configuration.h'
--- src/platform/graphics/android/android_display_configuration.h 2014-03-05 02:30:30 +0000
+++ src/platform/graphics/android/android_display_configuration.h 2014-03-17 15:02:33 +0000
@@ -37,10 +37,7 @@
3737
38 void for_each_card(std::function<void(DisplayConfigurationCard const&)> f) const override;38 void for_each_card(std::function<void(DisplayConfigurationCard const&)> f) const override;
39 void for_each_output(std::function<void(DisplayConfigurationOutput const&)> f) const override;39 void for_each_output(std::function<void(DisplayConfigurationOutput const&)> f) const override;
40 void configure_output(DisplayConfigurationOutputId id, bool used,40 void for_each_output(std::function<void(UserDisplayConfigurationOutput&)> f) override;
41 geometry::Point top_left, size_t mode_index,
42 MirPixelFormat format, MirPowerMode power_mode,
43 MirOrientation) override;
4441
45private:42private:
46 DisplayConfigurationOutput configuration;43 DisplayConfigurationOutput configuration;
4744
=== modified file 'src/platform/graphics/android/display_buffer.cpp'
--- src/platform/graphics/android/display_buffer.cpp 2014-02-28 13:51:43 +0000
+++ src/platform/graphics/android/display_buffer.cpp 2014-03-17 15:02:33 +0000
@@ -85,35 +85,29 @@
85}85}
8686
87void mga::DisplayBuffer::render_and_post_update(87void mga::DisplayBuffer::render_and_post_update(
88 std::list<std::shared_ptr<Renderable>> const& renderlist,88 std::list<std::shared_ptr<Renderable>> const& renderlist,
89 std::function<void(Renderable const&)> const& render_fn)89 std::function<void(Renderable const&)> const& render_fn)
90{90{
91 if (renderlist.empty())91 if (renderlist.empty())
92 {92 {
93 display_device->prepare_gl();93 display_device->render_gl(gl_context);
94 }94 }
95 else95 else
96 {96 {
97 display_device->prepare_gl_and_overlays(renderlist);97 display_device->render_gl_and_overlays(gl_context, renderlist, render_fn);
98 }98 }
9999
100 for(auto& renderable : renderlist)100 post();
101 {
102 render_fn(*renderable);
103 }
104
105 render_and_post();
106}101}
107102
108void mga::DisplayBuffer::post_update()103void mga::DisplayBuffer::post_update()
109{104{
110 display_device->prepare_gl();105 display_device->render_gl(gl_context);
111 render_and_post();106 post();
112}107}
113108
114void mga::DisplayBuffer::render_and_post()109void mga::DisplayBuffer::post()
115{110{
116 display_device->gpu_render(gl_context.display(), gl_context.surface());
117 auto last_rendered = fb_bundle->last_rendered_buffer();111 auto last_rendered = fb_bundle->last_rendered_buffer();
118 display_device->post(*last_rendered);112 display_device->post(*last_rendered);
119}113}
120114
=== modified file 'src/platform/graphics/android/display_buffer.h'
--- src/platform/graphics/android/display_buffer.h 2014-02-28 13:51:43 +0000
+++ src/platform/graphics/android/display_buffer.h 2014-03-17 15:02:33 +0000
@@ -58,7 +58,7 @@
58 void configure(DisplayConfigurationOutput const&);58 void configure(DisplayConfigurationOutput const&);
5959
60private:60private:
61 void render_and_post();61 void post();
6262
63 std::shared_ptr<FramebufferBundle> const fb_bundle;63 std::shared_ptr<FramebufferBundle> const fb_bundle;
64 std::shared_ptr<DisplayDevice> const display_device;64 std::shared_ptr<DisplayDevice> const display_device;
6565
=== modified file 'src/platform/graphics/android/display_device.h'
--- src/platform/graphics/android/display_device.h 2014-02-28 13:51:43 +0000
+++ src/platform/graphics/android/display_device.h 2014-03-17 15:02:33 +0000
@@ -33,6 +33,7 @@
3333
34namespace android34namespace android
35{35{
36class SwappingGLContext;
3637
37class DisplayDevice38class DisplayDevice
38{39{
@@ -40,9 +41,11 @@
40 virtual ~DisplayDevice() = default;41 virtual ~DisplayDevice() = default;
4142
42 virtual void mode(MirPowerMode mode) = 0;43 virtual void mode(MirPowerMode mode) = 0;
43 virtual void prepare_gl() = 0;44 virtual void render_gl(SwappingGLContext const& context) = 0;
44 virtual void prepare_gl_and_overlays(std::list<std::shared_ptr<Renderable>> const& list) = 0; 45 virtual void render_gl_and_overlays(
45 virtual void gpu_render(EGLDisplay dpy, EGLSurface sur) = 0;46 SwappingGLContext const& context,
47 std::list<std::shared_ptr<Renderable>> const& list,
48 std::function<void(Renderable const&)> const& render_fn) = 0;
46 virtual void post(Buffer const& buffer) = 0;49 virtual void post(Buffer const& buffer) = 0;
47 virtual bool apply_orientation(MirOrientation orientation) const = 0;50 virtual bool apply_orientation(MirOrientation orientation) const = 0;
4851
4952
=== modified file 'src/platform/graphics/android/fb_device.cpp'
--- src/platform/graphics/android/fb_device.cpp 2014-02-28 13:51:43 +0000
+++ src/platform/graphics/android/fb_device.cpp 2014-03-17 15:02:33 +0000
@@ -19,6 +19,7 @@
19#include "mir/graphics/buffer.h"19#include "mir/graphics/buffer.h"
20#include "mir/graphics/android/native_buffer.h"20#include "mir/graphics/android/native_buffer.h"
21#include "mir/graphics/android/sync_fence.h"21#include "mir/graphics/android/sync_fence.h"
22#include "gl_context.h"
22#include "android_format_conversion-inl.h"23#include "android_format_conversion-inl.h"
23#include "fb_device.h"24#include "fb_device.h"
24#include "framebuffer_bundle.h"25#include "framebuffer_bundle.h"
@@ -43,20 +44,20 @@
43 mode(mir_power_mode_on);44 mode(mir_power_mode_on);
44}45}
4546
46void mga::FBDevice::prepare_gl()47void mga::FBDevice::render_gl(SwappingGLContext const& context)
47{48{
48}49 context.swap_buffers();
4950}
50void mga::FBDevice::prepare_gl_and_overlays(std::list<std::shared_ptr<Renderable>> const&)51
51{52void mga::FBDevice::render_gl_and_overlays(
52}53 SwappingGLContext const& context,
5354 std::list<std::shared_ptr<Renderable>> const& renderables,
54void mga::FBDevice::gpu_render(EGLDisplay dpy, EGLSurface sur)55 std::function<void(Renderable const&)> const& render_fn)
55{56{
56 if (eglSwapBuffers(dpy, sur) == EGL_FALSE)57 for(auto const& renderable : renderables)
57 {58 render_fn(*renderable);
58 BOOST_THROW_EXCEPTION(std::runtime_error("eglSwapBuffers failure\n"));59
59 }60 context.swap_buffers();
60}61}
6162
62void mga::FBDevice::post(mg::Buffer const& buffer)63void mga::FBDevice::post(mg::Buffer const& buffer)
6364
=== modified file 'src/platform/graphics/android/fb_device.h'
--- src/platform/graphics/android/fb_device.h 2014-02-28 13:51:43 +0000
+++ src/platform/graphics/android/fb_device.h 2014-03-17 15:02:33 +0000
@@ -37,9 +37,11 @@
3737
38 bool apply_orientation(MirOrientation orientation) const;38 bool apply_orientation(MirOrientation orientation) const;
39 void mode(MirPowerMode mode);39 void mode(MirPowerMode mode);
40 void prepare_gl();40 virtual void render_gl(SwappingGLContext const& context);
41 void prepare_gl_and_overlays(std::list<std::shared_ptr<Renderable>> const& list); 41 virtual void render_gl_and_overlays(
42 void gpu_render(EGLDisplay dpy, EGLSurface sur);42 SwappingGLContext const& context,
43 std::list<std::shared_ptr<Renderable>> const& list,
44 std::function<void(Renderable const&)> const& render_fn);
43 void post(Buffer const& buffer);45 void post(Buffer const& buffer);
4446
45private:47private:
4648
=== modified file 'src/platform/graphics/android/gl_context.cpp'
--- src/platform/graphics/android/gl_context.cpp 2014-01-22 10:03:11 +0000
+++ src/platform/graphics/android/gl_context.cpp 2014-03-17 15:02:33 +0000
@@ -23,6 +23,7 @@
23#include <algorithm>23#include <algorithm>
24#include <boost/throw_exception.hpp>24#include <boost/throw_exception.hpp>
25#include <stdexcept>25#include <stdexcept>
26#include <sstream>
2627
27namespace mg=mir::graphics;28namespace mg=mir::graphics;
28namespace mga=mir::graphics::android;29namespace mga=mir::graphics::android;
@@ -145,6 +146,17 @@
145 eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);146 eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
146}147}
147148
149void mga::GLContext::swap_buffers() const
150{
151 eglGetError();
152 if (eglSwapBuffers(egl_display, egl_surface) == EGL_FALSE)
153 {
154 std::stringstream sstream;
155 sstream << "eglSwapBuffers failure: EGL error code " << std::hex << eglGetError();
156 BOOST_THROW_EXCEPTION(std::runtime_error(sstream.str()));
157 }
158}
159
148mga::GLContext::~GLContext()160mga::GLContext::~GLContext()
149{161{
150 if (eglGetCurrentContext() == egl_context)162 if (eglGetCurrentContext() == egl_context)
151163
=== modified file 'src/platform/graphics/android/gl_context.h'
--- src/platform/graphics/android/gl_context.h 2014-01-22 10:03:11 +0000
+++ src/platform/graphics/android/gl_context.h 2014-03-17 15:02:33 +0000
@@ -36,7 +36,20 @@
36EGLSurface create_dummy_pbuffer_surface(EGLDisplay, EGLConfig);36EGLSurface create_dummy_pbuffer_surface(EGLDisplay, EGLConfig);
37EGLSurface create_window_surface(EGLDisplay, EGLConfig, EGLNativeWindowType);37EGLSurface create_window_surface(EGLDisplay, EGLConfig, EGLNativeWindowType);
3838
39class GLContext : public graphics::GLContext39class SwappingGLContext
40{
41public:
42 virtual ~SwappingGLContext() = default;
43 virtual void swap_buffers() const = 0;
44
45protected:
46 SwappingGLContext() = default;
47 SwappingGLContext(SwappingGLContext const&) = delete;
48 SwappingGLContext& operator=(SwappingGLContext const&) = delete;
49};
50
51class GLContext : public SwappingGLContext,
52 public graphics::GLContext
40{53{
41public:54public:
42 //For creating a gl context55 //For creating a gl context
@@ -49,19 +62,9 @@
49 ~GLContext();62 ~GLContext();
5063
51 void make_current() const override;64 void make_current() const override;
52 void swap_buffers();65 void swap_buffers() const override;
53 void release_current() const override;66 void release_current() const override;
5467
55 /* TODO: (kdub) remove these two functions once HWC1.0 construction is sorted out. */
56 EGLDisplay display()
57 {
58 return egl_display;
59 }
60 EGLSurface surface()
61 {
62 return egl_surface;
63 }
64
65private:68private:
66 EGLDisplay const egl_display;69 EGLDisplay const egl_display;
67 bool const own_display;70 bool const own_display;
6871
=== modified file 'src/platform/graphics/android/hwc_device.cpp'
--- src/platform/graphics/android/hwc_device.cpp 2014-02-11 03:04:50 +0000
+++ src/platform/graphics/android/hwc_device.cpp 2014-03-17 15:02:33 +0000
@@ -17,83 +17,122 @@
17 * Kevin DuBois <kevin.dubois@canonical.com>17 * Kevin DuBois <kevin.dubois@canonical.com>
18 */18 */
1919
20#include "gl_context.h"
20#include "hwc_device.h"21#include "hwc_device.h"
21#include "hwc_layerlist.h"22#include "hwc_layerlist.h"
22#include "hwc_vsync_coordinator.h"23#include "hwc_vsync_coordinator.h"
23#include "framebuffer_bundle.h"24#include "framebuffer_bundle.h"
24#include "buffer.h"25#include "buffer.h"
25#include "mir/graphics/android/native_buffer.h"
26#include "mir/graphics/buffer.h"26#include "mir/graphics/buffer.h"
2727
28#include <EGL/eglext.h>
29#include <boost/throw_exception.hpp>
30#include <stdexcept>
31
32namespace mg = mir::graphics;28namespace mg = mir::graphics;
33namespace mga=mir::graphics::android;29namespace mga=mir::graphics::android;
34namespace geom = mir::geometry;30namespace geom = mir::geometry;
3531
32namespace
33{
34static const size_t fbtarget_plus_skip_size = 2;
35static const size_t fbtarget_size = 1;
36}
37
38void mga::HwcDevice::setup_layer_types()
39{
40 auto it = hwc_list.additional_layers_begin();
41 auto const num_additional_layers = std::distance(it, hwc_list.end());
42 switch (num_additional_layers)
43 {
44 case fbtarget_plus_skip_size:
45 it->set_layer_type(mga::LayerType::skip);
46 ++it;
47 case fbtarget_size:
48 it->set_layer_type(mga::LayerType::framebuffer_target);
49 default:
50 break;
51 }
52}
53
54void mga::HwcDevice::set_list_framebuffer(mg::Buffer const& buffer)
55{
56 geom::Rectangle const disp_frame{{0,0}, {buffer.size()}};
57 for(auto it = hwc_list.additional_layers_begin(); it != hwc_list.end(); it++)
58 {
59 //TODO: the functions on mga::Layer should be consolidated
60 it->set_render_parameters(disp_frame, false);
61 it->set_buffer(buffer);
62 it->prepare_for_draw();
63 }
64}
65
36mga::HwcDevice::HwcDevice(std::shared_ptr<hwc_composer_device_1> const& hwc_device,66mga::HwcDevice::HwcDevice(std::shared_ptr<hwc_composer_device_1> const& hwc_device,
67 std::shared_ptr<HwcWrapper> const& hwc_wrapper,
37 std::shared_ptr<HWCVsyncCoordinator> const& coordinator,68 std::shared_ptr<HWCVsyncCoordinator> const& coordinator,
38 std::shared_ptr<SyncFileOps> const& sync_ops)69 std::shared_ptr<SyncFileOps> const& sync_ops)
39 : HWCCommonDevice(hwc_device, coordinator),70 : HWCCommonDevice(hwc_device, coordinator),
71 hwc_list{{}, 2},
72 hwc_wrapper(hwc_wrapper),
40 sync_ops(sync_ops)73 sync_ops(sync_ops)
41{74{
42}75 setup_layer_types();
4376}
44void mga::HwcDevice::prepare_gl()77
45{78void mga::HwcDevice::render_gl(SwappingGLContext const& context)
46 auto rc = 0;79{
47 auto display_list = layer_list.native_list().lock();80 hwc_list.update_list_and_check_if_changed({}, fbtarget_plus_skip_size);
48 if (display_list)81 setup_layer_types();
49 {82
50 //note, although we only have a primary display right now,83 list_needs_commit = true;
51 // set the external and virtual displays to null as some drivers check for that84
52 hwc_display_contents_1_t* displays[num_displays] {display_list.get(), nullptr, nullptr};85 hwc_wrapper->prepare(*hwc_list.native_list().lock());
53 rc = hwc_device->prepare(hwc_device.get(), 1, displays);86
54 }87 context.swap_buffers();
5588}
56 if ((rc != 0) || (!display_list))89
57 {90void mga::HwcDevice::render_gl_and_overlays(
58 BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc prepare()"));91 SwappingGLContext const& context,
59 }92 std::list<std::shared_ptr<Renderable>> const& renderables,
60}93 std::function<void(Renderable const&)> const& render_fn)
6194{
62void mga::HwcDevice::prepare_gl_and_overlays(std::list<std::shared_ptr<Renderable>> const&)95 if (!(list_needs_commit = hwc_list.update_list_and_check_if_changed(renderables, fbtarget_size)))
63{96 return;
64 prepare_gl();97 setup_layer_types();
65}98
6699 hwc_wrapper->prepare(*hwc_list.native_list().lock());
67void mga::HwcDevice::gpu_render(EGLDisplay dpy, EGLSurface sur)100
68{101 //draw layers that the HWC did not accept for overlays here
69 if (eglSwapBuffers(dpy, sur) == EGL_FALSE)102 bool needs_swapbuffers = false;
70 {103 auto layers_it = hwc_list.begin();
71 BOOST_THROW_EXCEPTION(std::runtime_error("eglSwapBuffers failure\n"));104 for(auto const& renderable : renderables)
72 }105 {
106 //prepare all layers for draw.
107 layers_it->prepare_for_draw();
108
109 //trigger GL on the layers that are not overlays
110 if (layers_it->needs_gl_render())
111 {
112 render_fn(*renderable);
113 needs_swapbuffers = true;
114 }
115 layers_it++;
116 }
117
118 if (needs_swapbuffers)
119 context.swap_buffers();
73}120}
74121
75void mga::HwcDevice::post(mg::Buffer const& buffer)122void mga::HwcDevice::post(mg::Buffer const& buffer)
76{123{
124 if (!list_needs_commit)
125 return;
126
77 auto lg = lock_unblanked();127 auto lg = lock_unblanked();
78128 set_list_framebuffer(buffer);
79 layer_list.set_fb_target(buffer);129 hwc_wrapper->set(*hwc_list.native_list().lock());
80130
81 auto rc = 0;131 for(auto& layer : hwc_list)
82 auto display_list = layer_list.native_list().lock();132 {
83 if (display_list)133 layer.update_fence_and_release_buffer();
84 {134 }
85 hwc_display_contents_1_t* displays[num_displays] {display_list.get(), nullptr, nullptr};135
86 rc = hwc_device->set(hwc_device.get(), 1, displays);136 mga::SyncFence retire_fence(sync_ops, hwc_list.retirement_fence());
87137 list_needs_commit = false;
88 mga::SyncFence retire_fence(sync_ops, layer_list.retirement_fence());
89
90 int framebuffer_fence = layer_list.fb_target_fence();
91 auto native_buffer = buffer.native_buffer_handle();
92 native_buffer->update_fence(framebuffer_fence);
93 }
94
95 if ((rc != 0) || (!display_list))
96 {
97 BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc set()"));
98 }
99}138}
100139
=== modified file 'src/platform/graphics/android/hwc_device.h'
--- src/platform/graphics/android/hwc_device.h 2014-02-11 03:04:50 +0000
+++ src/platform/graphics/android/hwc_device.h 2014-03-17 15:02:33 +0000
@@ -36,23 +36,45 @@
36class HWCVsyncCoordinator;36class HWCVsyncCoordinator;
37class SyncFileOps;37class SyncFileOps;
3838
39class HwcWrapper
40{
41public:
42 virtual ~HwcWrapper() = default;
43
44 virtual void prepare(hwc_display_contents_1_t&) const = 0;
45 virtual void set(hwc_display_contents_1_t&) const = 0;
46
47protected:
48 HwcWrapper() = default;
49 HwcWrapper& operator=(HwcWrapper const&) = delete;
50 HwcWrapper(HwcWrapper const&) = delete;
51};
52
39class HwcDevice : public HWCCommonDevice53class HwcDevice : public HWCCommonDevice
40{54{
41public:55public:
56 //TODO: the first two constructor arguments are redundant. eliminate the 1st one when the 2nd
57 // one can be used by the HWCCommonDevice
42 HwcDevice(std::shared_ptr<hwc_composer_device_1> const& hwc_device,58 HwcDevice(std::shared_ptr<hwc_composer_device_1> const& hwc_device,
59 std::shared_ptr<HwcWrapper> const& hwc_wrapper,
43 std::shared_ptr<HWCVsyncCoordinator> const& coordinator,60 std::shared_ptr<HWCVsyncCoordinator> const& coordinator,
44 std::shared_ptr<SyncFileOps> const& sync_ops);61 std::shared_ptr<SyncFileOps> const& sync_ops);
4562
46 void prepare_gl();63 virtual void render_gl(SwappingGLContext const& context);
47 void prepare_gl_and_overlays(std::list<std::shared_ptr<Renderable>> const& list); 64 virtual void render_gl_and_overlays(
48 void gpu_render(EGLDisplay dpy, EGLSurface sur);65 SwappingGLContext const& context,
66 std::list<std::shared_ptr<Renderable>> const& list,
67 std::function<void(Renderable const&)> const& render_fn);
49 void post(Buffer const& buffer);68 void post(Buffer const& buffer);
5069
51private:70private:
52 FBTargetLayerList layer_list;71 LayerList hwc_list;
72 void set_list_framebuffer(Buffer const&);
73 void setup_layer_types();
5374
75 std::shared_ptr<HwcWrapper> const hwc_wrapper;
54 std::shared_ptr<SyncFileOps> const sync_ops;76 std::shared_ptr<SyncFileOps> const sync_ops;
55 static size_t const num_displays{3}; //primary, external, virtual77 bool list_needs_commit{false};
56};78};
5779
58}80}
5981
=== modified file 'src/platform/graphics/android/hwc_fb_device.cpp'
--- src/platform/graphics/android/hwc_fb_device.cpp 2014-02-11 03:04:50 +0000
+++ src/platform/graphics/android/hwc_fb_device.cpp 2014-03-17 15:02:33 +0000
@@ -25,6 +25,7 @@
25#include "mir/graphics/android/native_buffer.h"25#include "mir/graphics/android/native_buffer.h"
2626
27#include <boost/throw_exception.hpp>27#include <boost/throw_exception.hpp>
28#include <sstream>
28#include <stdexcept>29#include <stdexcept>
2930
30namespace mg = mir::graphics;31namespace mg = mir::graphics;
@@ -35,39 +36,20 @@
35 std::shared_ptr<framebuffer_device_t> const& fb_device,36 std::shared_ptr<framebuffer_device_t> const& fb_device,
36 std::shared_ptr<HWCVsyncCoordinator> const& coordinator)37 std::shared_ptr<HWCVsyncCoordinator> const& coordinator)
37 : HWCCommonDevice(hwc_device, coordinator),38 : HWCCommonDevice(hwc_device, coordinator),
38 fb_device(fb_device)39 fb_device(fb_device),
39{40 layer_list{{},1}
40}41{
4142 layer_list.additional_layers_begin()->set_layer_type(mga::LayerType::skip);
42void mga::HwcFbDevice::prepare_gl()43}
43{44
44 auto rc = 0;45void mga::HwcFbDevice::gpu_render()
45 auto display_list = layer_list.native_list().lock();
46 if (display_list)
47 {
48 hwc_display_contents_1_t* displays[num_displays] {display_list.get()};
49 rc = hwc_device->prepare(hwc_device.get(), num_displays, displays);
50 }
51
52 if ((rc != 0) || (!display_list))
53 {
54 BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc prepare()"));
55 }
56}
57
58void mga::HwcFbDevice::prepare_gl_and_overlays(std::list<std::shared_ptr<Renderable>> const&)
59{
60 prepare_gl();
61}
62
63void mga::HwcFbDevice::gpu_render(EGLDisplay dpy, EGLSurface sur)
64{46{
65 auto rc = 0; 47 auto rc = 0;
66 auto display_list = layer_list.native_list().lock();48 auto display_list = layer_list.native_list().lock();
67 if (display_list)49 if (display_list)
68 {50 {
69 display_list->dpy = dpy;51 display_list->dpy = eglGetCurrentDisplay();
70 display_list->sur = sur;52 display_list->sur = eglGetCurrentSurface(EGL_DRAW);
7153
72 //set() may affect EGL state by calling eglSwapBuffers.54 //set() may affect EGL state by calling eglSwapBuffers.
73 //HWC 1.0 is the only version of HWC that can do this.55 //HWC 1.0 is the only version of HWC that can do this.
@@ -77,8 +59,46 @@
7759
78 if ((rc != 0) || (!display_list))60 if ((rc != 0) || (!display_list))
79 {61 {
80 BOOST_THROW_EXCEPTION(std::runtime_error("error during hwc set()"));62 std::stringstream ss;
81 }63 ss << "error during hwc set(). rc = " << std::hex << rc;
64 BOOST_THROW_EXCEPTION(std::runtime_error(ss.str()));
65 }
66}
67
68void mga::HwcFbDevice::prepare()
69{
70 auto rc = 0;
71 auto display_list = layer_list.native_list().lock();
72 if (display_list)
73 {
74 hwc_display_contents_1_t* displays[num_displays] {display_list.get()};
75 rc = hwc_device->prepare(hwc_device.get(), num_displays, displays);
76 }
77
78 if ((rc != 0) || (!display_list))
79 {
80 std::stringstream ss;
81 ss << "error during hwc prepare(). rc = " << std::hex << rc;
82 BOOST_THROW_EXCEPTION(std::runtime_error(ss.str()));
83 }
84}
85
86void mga::HwcFbDevice::render_gl(SwappingGLContext const&)
87{
88 prepare();
89 gpu_render();
90}
91
92void mga::HwcFbDevice::render_gl_and_overlays(
93 SwappingGLContext const&,
94 std::list<std::shared_ptr<Renderable>> const& renderables,
95 std::function<void(Renderable const&)> const& render_fn)
96{
97 prepare();
98 //TODO: filter this list based on the results of the preparation
99 for(auto const& renderable : renderables)
100 render_fn(*renderable);
101 gpu_render();
82}102}
83103
84void mga::HwcFbDevice::post(mg::Buffer const& buffer)104void mga::HwcFbDevice::post(mg::Buffer const& buffer)
85105
=== modified file 'src/platform/graphics/android/hwc_fb_device.h'
--- src/platform/graphics/android/hwc_fb_device.h 2014-02-11 03:04:50 +0000
+++ src/platform/graphics/android/hwc_fb_device.h 2014-03-17 15:02:33 +0000
@@ -38,12 +38,16 @@
38 std::shared_ptr<framebuffer_device_t> const& fb_device,38 std::shared_ptr<framebuffer_device_t> const& fb_device,
39 std::shared_ptr<HWCVsyncCoordinator> const& coordinator);39 std::shared_ptr<HWCVsyncCoordinator> const& coordinator);
4040
41 void prepare_gl();41 virtual void render_gl(SwappingGLContext const& context);
42 void prepare_gl_and_overlays(std::list<std::shared_ptr<Renderable>> const& list); 42 virtual void render_gl_and_overlays(
43 void gpu_render(EGLDisplay dpy, EGLSurface sur);43 SwappingGLContext const& context,
44 std::list<std::shared_ptr<Renderable>> const& list,
45 std::function<void(Renderable const&)> const& render_fn);
44 void post(Buffer const& buffer);46 void post(Buffer const& buffer);
4547
46private:48private:
49 void prepare();
50 void gpu_render();
47 std::shared_ptr<framebuffer_device_t> const fb_device;51 std::shared_ptr<framebuffer_device_t> const fb_device;
48 static int const num_displays{1};52 static int const num_displays{1};
49 LayerList layer_list;53 LayerList layer_list;
5054
=== modified file 'src/platform/graphics/android/hwc_layerlist.cpp'
--- src/platform/graphics/android/hwc_layerlist.cpp 2014-03-04 04:19:26 +0000
+++ src/platform/graphics/android/hwc_layerlist.cpp 2014-03-17 15:02:33 +0000
@@ -51,101 +51,95 @@
51}51}
52}52}
5353
54void mga::LayerListBase::update_representation(size_t needed_size)54bool mga::LayerList::update_list_and_check_if_changed(
55{55 std::list<std::shared_ptr<mg::Renderable>> const& renderlist,
56 std::shared_ptr<hwc_display_contents_1_t> new_hwc_representation;56 size_t additional_layers)
57 std::list<HWCLayer> new_layers;57{
5858 size_t needed_size = renderlist.size() + additional_layers;
59 if (hwc_representation->numHwLayers != needed_size)59
60 {60 bool any_buffer_updated = false;
61 new_hwc_representation = generate_hwc_list(needed_size);61 if ((!hwc_representation) || hwc_representation->numHwLayers != needed_size)
62 }62 {
63 else63 hwc_representation = generate_hwc_list(needed_size);
64 {64 }
65 new_hwc_representation = hwc_representation;65
66 }66 if (layers.size() == needed_size)
6767 {
68 for (auto i = 0u; i < needed_size; i++)68 auto layers_it = layers.begin();
69 {69 for(auto renderable : renderlist)
70 new_layers.emplace_back(mga::HWCLayer(new_hwc_representation, i));70 {
71 }71 layers_it->set_render_parameters(
7272 renderable->screen_position(), renderable->alpha_enabled());
73 std::swap(new_layers, layers);73 layers_it->set_buffer(*renderable->buffer(1));// TODO: remove needing to know about frameno
74 hwc_representation = new_hwc_representation;74 any_buffer_updated |= layers_it->needs_hwc_commit();
75}75 layers_it++;
7676 }
77std::weak_ptr<hwc_display_contents_1_t> mga::LayerListBase::native_list()77 }
78 else
79 {
80 any_buffer_updated = true;
81 std::list<HWCLayer> new_layers;
82 auto i = 0u;
83 for(auto const& renderable : renderlist)
84 {
85 new_layers.emplace_back(
86 mga::HWCLayer(
87 mga::LayerType::gl_rendered,
88 renderable->screen_position(),
89 renderable->alpha_enabled(),
90 hwc_representation, i++));
91 new_layers.back().set_buffer(*renderable->buffer(1));// TODO: remove needing to know about frameno
92 }
93
94 for(; i < needed_size; i++)
95 {
96 new_layers.emplace_back(mga::HWCLayer(hwc_representation, i));
97 }
98 layers = std::move(new_layers);
99 }
100
101 if (additional_layers == 0)
102 {
103 first_additional_layer = layers.end();
104 }
105 else
106 {
107 first_additional_layer = layers.begin();
108 std::advance(first_additional_layer, renderlist.size());
109 }
110
111 return any_buffer_updated;
112}
113
114std::list<mga::HWCLayer>::iterator mga::LayerList::begin()
115{
116 return layers.begin();
117}
118
119std::list<mga::HWCLayer>::iterator mga::LayerList::additional_layers_begin()
120{
121 return first_additional_layer;
122}
123
124std::list<mga::HWCLayer>::iterator mga::LayerList::end()
125{
126 return layers.end();
127}
128
129std::weak_ptr<hwc_display_contents_1_t> mga::LayerList::native_list()
78{130{
79 return hwc_representation;131 return hwc_representation;
80}132}
81133
82mga::NativeFence mga::LayerListBase::retirement_fence()134mga::NativeFence mga::LayerList::retirement_fence()
83{135{
84 return hwc_representation->retireFenceFd;136 return hwc_representation->retireFenceFd;
85}137}
86138
87mga::LayerListBase::LayerListBase(size_t initial_list_size)139mga::LayerList::LayerList(
88 : hwc_representation{generate_hwc_list(initial_list_size)}140 std::list<std::shared_ptr<mg::Renderable>> const& renderlist,
89{141 size_t additional_layers)
90 update_representation(initial_list_size);142{
91}143 update_list_and_check_if_changed(renderlist, additional_layers);
92144}
93mga::LayerList::LayerList()145
94 : LayerListBase{1}
95{
96 layers.back().set_layer_type(mga::LayerType::skip);
97}
98
99mga::FBTargetLayerList::FBTargetLayerList()
100 : LayerListBase{2}
101{
102 layers.front().set_layer_type(mga::LayerType::skip);
103 layers.back().set_layer_type(mga::LayerType::framebuffer_target);
104}
105
106void mga::FBTargetLayerList::reset_composition_layers()
107{
108 update_representation(2);
109
110 layers.front().set_layer_type(mga::LayerType::skip);
111 layers.back().set_layer_type(mga::LayerType::framebuffer_target);
112
113 skip_layers_present = true;
114}
115
116void mga::FBTargetLayerList::set_composition_layers(std::list<std::shared_ptr<graphics::Renderable>> const& list)
117{
118 auto const needed_size = list.size() + 1;
119 update_representation(needed_size);
120
121 auto layers_it = layers.begin();
122 for(auto const& renderable : list)
123 {
124 layers_it->set_layer_type(mga::LayerType::gl_rendered);
125 layers_it->set_render_parameters(renderable->screen_position(), renderable->alpha_enabled());
126 layers_it->set_buffer(*renderable->buffer());
127 layers_it++;
128 }
129
130 layers_it->set_layer_type(mga::LayerType::framebuffer_target);
131 skip_layers_present = false;
132}
133
134
135void mga::FBTargetLayerList::set_fb_target(mg::Buffer const& buffer)
136{
137 geom::Rectangle const disp_frame{{0,0}, {buffer.size()}};
138 if (skip_layers_present)
139 {
140 layers.front().set_render_parameters(disp_frame, false);
141 layers.front().set_buffer(buffer);
142 }
143
144 layers.back().set_render_parameters(disp_frame, false);
145 layers.back().set_buffer(buffer);
146}
147
148mga::NativeFence mga::FBTargetLayerList::fb_target_fence()
149{
150 return layers.back().release_fence();
151}
152146
=== modified file 'src/platform/graphics/android/hwc_layerlist.h'
--- src/platform/graphics/android/hwc_layerlist.h 2014-02-11 03:04:50 +0000
+++ src/platform/graphics/android/hwc_layerlist.h 2014-03-17 15:02:33 +0000
@@ -39,42 +39,33 @@
39namespace android39namespace android
40{40{
4141
42class LayerListBase42/* this is a partitioned list. renderlist makes up the first renderlist.size() elements
43 of the list, and there are additional_layers added to the end.
44 std::distance(begin(), additional_layers_begin()) == renderlist.size()
45 std::distance(additional_layers_begin(), end()) == additional_layers
46 std::distance(begin(), end()) == renderlist.size() + additional_layers
47*/
48class LayerList
43{49{
44public:50public:
51 LayerList(std::list<std::shared_ptr<Renderable>> const& renderlist, size_t additional_layers);
52 bool update_list_and_check_if_changed(
53 std::list<std::shared_ptr<Renderable>> const& renderlist,
54 size_t additional_layers);
55
56 std::list<HWCLayer>::iterator begin();
57 std::list<HWCLayer>::iterator additional_layers_begin();
58 std::list<HWCLayer>::iterator end();
59
45 std::weak_ptr<hwc_display_contents_1_t> native_list();60 std::weak_ptr<hwc_display_contents_1_t> native_list();
46 NativeFence retirement_fence();61 NativeFence retirement_fence();
4762private:
48protected:63 LayerList& operator=(LayerList const&) = delete;
49 LayerListBase(size_t initial_list_size);64 LayerList(LayerList const&) = delete;
5065
51 void update_representation(size_t needed_size);
52 std::list<HWCLayer> layers;66 std::list<HWCLayer> layers;
53
54private:
55 LayerListBase& operator=(LayerListBase const&) = delete;
56 LayerListBase(LayerListBase const&) = delete;
57
58 std::shared_ptr<hwc_display_contents_1_t> hwc_representation;67 std::shared_ptr<hwc_display_contents_1_t> hwc_representation;
59};68 std::list<HWCLayer>::iterator first_additional_layer;
60
61class LayerList : public LayerListBase
62{
63public:
64 LayerList();
65};
66
67class FBTargetLayerList : public LayerListBase
68{
69public:
70 FBTargetLayerList();
71 void set_composition_layers(std::list<std::shared_ptr<graphics::Renderable>> const& list);
72 void reset_composition_layers();
73 NativeFence fb_target_fence();
74 void set_fb_target(Buffer const&);
75
76private:
77 bool skip_layers_present{true};
78};69};
7970
80}71}
8172
=== modified file 'src/platform/graphics/android/hwc_layers.cpp'
--- src/platform/graphics/android/hwc_layers.cpp 2014-02-12 03:14:55 +0000
+++ src/platform/graphics/android/hwc_layers.cpp 2014-03-17 15:02:33 +0000
@@ -47,7 +47,8 @@
4747
48mga::HWCLayer::HWCLayer(std::shared_ptr<hwc_display_contents_1_t> list, size_t layer_index)48mga::HWCLayer::HWCLayer(std::shared_ptr<hwc_display_contents_1_t> list, size_t layer_index)
49 : hwc_layer(&list->hwLayers[layer_index]),49 : hwc_layer(&list->hwLayers[layer_index]),
50 hwc_list(list)50 hwc_list(list),
51 associated_buffer(nullptr) //todo: take this as a constructor param
51{52{
52 memset(hwc_layer, 0, sizeof(hwc_layer_1_t));53 memset(hwc_layer, 0, sizeof(hwc_layer_1_t));
53 memset(&visible_rect, 0, sizeof(hwc_rect_t));54 memset(&visible_rect, 0, sizeof(hwc_rect_t));
@@ -79,9 +80,15 @@
79 return ((hwc_layer->compositionType == HWC_FRAMEBUFFER) || (hwc_layer->flags == HWC_SKIP_LAYER));80 return ((hwc_layer->compositionType == HWC_FRAMEBUFFER) || (hwc_layer->flags == HWC_SKIP_LAYER));
80}81}
8182
82mga::NativeFence mga::HWCLayer::release_fence() const83void mga::HWCLayer::update_fence_and_release_buffer()
83{84{
84 return hwc_layer->releaseFenceFd;85 if (hwc_layer->compositionType != HWC_FRAMEBUFFER)
86 {
87 associated_buffer->update_fence(hwc_layer->releaseFenceFd);
88 hwc_layer->releaseFenceFd = -1;
89 hwc_layer->acquireFenceFd = -1;
90 associated_buffer.reset();
91 }
85}92}
8693
87void mga::HWCLayer::set_layer_type(LayerType type)94void mga::HWCLayer::set_layer_type(LayerType type)
@@ -129,16 +136,39 @@
129136
130void mga::HWCLayer::set_buffer(Buffer const& buffer)137void mga::HWCLayer::set_buffer(Buffer const& buffer)
131{138{
132 auto size = buffer.size();139 associated_buffer.reset();
133 auto native_buffer = buffer.native_buffer_handle();140 associated_buffer = buffer.native_buffer_handle();
134 hwc_layer->handle = native_buffer->handle();141 updated = (hwc_layer->handle != associated_buffer->handle());
135 if (!needs_gl_render())142
136 hwc_layer->acquireFenceFd = native_buffer->copy_fence();143 hwc_layer->handle = associated_buffer->handle();
137 hwc_layer->releaseFenceFd = -1;
138 hwc_layer->sourceCrop = 144 hwc_layer->sourceCrop =
139 {145 {
140 0, 0,146 0, 0,
141 size.width.as_int(),147 associated_buffer->anwb()->width,
142 size.height.as_int()148 associated_buffer->anwb()->height
143 };149 };
144}150}
151
152void mga::HWCLayer::prepare_for_draw()
153{
154 //we shouldn't be copying the FD unless the HWC has marked this as a buffer its interested in.
155 //we disregard fences that haven't changed, as the hwc will still own the buffer
156 if (updated && (((hwc_layer->compositionType == HWC_OVERLAY) ||
157 (hwc_layer->compositionType == HWC_FRAMEBUFFER_TARGET))))
158 {
159 hwc_layer->acquireFenceFd = associated_buffer->copy_fence();
160 }
161 //the HWC is not interested in this buffer. we can release the buffer.
162 else if (hwc_layer->compositionType == HWC_FRAMEBUFFER)
163 {
164 hwc_layer->acquireFenceFd = -1;
165 associated_buffer.reset();
166 }
167
168 hwc_layer->releaseFenceFd = -1;
169}
170
171bool mga::HWCLayer::needs_hwc_commit() const
172{
173 return (updated || needs_gl_render());
174}
145175
=== modified file 'src/platform/graphics/android/hwc_layers.h'
--- src/platform/graphics/android/hwc_layers.h 2014-02-12 03:14:55 +0000
+++ src/platform/graphics/android/hwc_layers.h 2014-03-17 15:02:33 +0000
@@ -35,10 +35,10 @@
3535
36class Renderable;36class Renderable;
37class Buffer;37class Buffer;
38class NativeBuffer;
3839
39namespace android40namespace android
40{41{
41
42enum LayerType42enum LayerType
43{43{
44 gl_rendered,44 gl_rendered,
@@ -64,15 +64,18 @@
64 64
65 void set_layer_type(LayerType type);65 void set_layer_type(LayerType type);
66 void set_render_parameters(geometry::Rectangle screen_position, bool alpha_enabled);66 void set_render_parameters(geometry::Rectangle screen_position, bool alpha_enabled);
67 void set_buffer(Buffer const&);67 void set_buffer(Buffer const& buffer);
6868
69 NativeFence release_fence() const;69 void update_fence_and_release_buffer();
70 bool needs_gl_render() const;70 bool needs_gl_render() const;
7171 bool needs_hwc_commit() const;
72 void prepare_for_draw();
72private:73private:
73 hwc_layer_1_t* hwc_layer;74 hwc_layer_1_t* hwc_layer;
74 std::shared_ptr<hwc_display_contents_1_t> hwc_list;75 std::shared_ptr<hwc_display_contents_1_t> hwc_list;
75 hwc_rect_t visible_rect;76 hwc_rect_t visible_rect;
77 std::shared_ptr<NativeBuffer> associated_buffer;
78 bool updated{false};
76};79};
77}80}
78}81}
7982
=== added file 'src/platform/graphics/android/real_hwc_wrapper.cpp'
--- src/platform/graphics/android/real_hwc_wrapper.cpp 1970-01-01 00:00:00 +0000
+++ src/platform/graphics/android/real_hwc_wrapper.cpp 2014-03-17 15:02:33 +0000
@@ -0,0 +1,53 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#include "real_hwc_wrapper.h"
20#include <boost/throw_exception.hpp>
21#include <stdexcept>
22#include <sstream>
23
24namespace mga=mir::graphics::android;
25
26mga::RealHwcWrapper::RealHwcWrapper(std::shared_ptr<hwc_composer_device_1> const& hwc_device)
27 : hwc_device(hwc_device)
28{
29}
30
31void mga::RealHwcWrapper::prepare(hwc_display_contents_1_t& display_list) const
32{
33 //note, although we only have a primary display right now,
34 // set the external and virtual displays to null as some drivers check for that
35 hwc_display_contents_1_t* displays[num_displays] {&display_list, nullptr, nullptr};
36 if (auto rc = hwc_device->prepare(hwc_device.get(), 1, displays))
37 {
38 std::stringstream ss;
39 ss << "error during hwc prepare(). rc = " << std::hex << rc;
40 BOOST_THROW_EXCEPTION(std::runtime_error(ss.str()));
41 }
42}
43
44void mga::RealHwcWrapper::set(hwc_display_contents_1_t& display_list) const
45{
46 hwc_display_contents_1_t* displays[num_displays] {&display_list, nullptr, nullptr};
47 if (auto rc = hwc_device->set(hwc_device.get(), 1, displays))
48 {
49 std::stringstream ss;
50 ss << "error during hwc prepare(). rc = " << std::hex << rc;
51 BOOST_THROW_EXCEPTION(std::runtime_error(ss.str()));
52 }
53}
054
=== added file 'src/platform/graphics/android/real_hwc_wrapper.h'
--- src/platform/graphics/android/real_hwc_wrapper.h 1970-01-01 00:00:00 +0000
+++ src/platform/graphics/android/real_hwc_wrapper.h 2014-03-17 15:02:33 +0000
@@ -0,0 +1,48 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17 */
18
19#ifndef MIR_GRAPHICS_ANDROID_REAL_HWC_WRAPPER_H_
20#define MIR_GRAPHICS_ANDROID_REAL_HWC_WRAPPER_H_
21
22#include "hwc_device.h"
23#include <memory>
24#include <hardware/hwcomposer.h>
25
26namespace mir
27{
28namespace graphics
29{
30namespace android
31{
32
33class RealHwcWrapper : public HwcWrapper
34{
35public:
36 RealHwcWrapper(std::shared_ptr<hwc_composer_device_1> const& hwc_device);
37
38 void prepare(hwc_display_contents_1_t&) const override;
39 void set(hwc_display_contents_1_t&) const override;
40private:
41 static size_t const num_displays{3}; //primary, external, virtual
42 std::shared_ptr<hwc_composer_device_1> const hwc_device;
43};
44
45}
46}
47}
48#endif /* MIR_GRAPHICS_ANDROID_REAL_HWC_WRAPPER_H_ */
049
=== modified file 'src/platform/graphics/android/resource_factory.cpp'
--- src/platform/graphics/android/resource_factory.cpp 2014-02-10 09:07:48 +0000
+++ src/platform/graphics/android/resource_factory.cpp 2014-03-17 15:02:33 +0000
@@ -30,6 +30,7 @@
30#include "hwc_layerlist.h"30#include "hwc_layerlist.h"
31#include "hwc_vsync.h"31#include "hwc_vsync.h"
32#include "android_display.h"32#include "android_display.h"
33#include "real_hwc_wrapper.h"
3334
34#include <boost/throw_exception.hpp>35#include <boost/throw_exception.hpp>
35#include <stdexcept>36#include <stdexcept>
@@ -93,7 +94,8 @@
93{94{
94 auto syncer = std::make_shared<mga::HWCVsync>();95 auto syncer = std::make_shared<mga::HWCVsync>();
95 auto file_ops = std::make_shared<mga::RealSyncFileOps>();96 auto file_ops = std::make_shared<mga::RealSyncFileOps>();
96 return std::make_shared<mga::HwcDevice>(hwc_native_device, syncer, file_ops);97 auto wrapper = std::make_shared<mga::RealHwcWrapper>(hwc_native_device);
98 return std::make_shared<mga::HwcDevice>(hwc_native_device, wrapper, syncer, file_ops);
97}99}
98100
99std::shared_ptr<mga::DisplayDevice> mga::ResourceFactory::create_hwc_fb_device(101std::shared_ptr<mga::DisplayDevice> mga::ResourceFactory::create_hwc_fb_device(
100102
=== modified file 'src/platform/graphics/display_configuration.cpp'
--- src/platform/graphics/display_configuration.cpp 2014-03-05 02:30:30 +0000
+++ src/platform/graphics/display_configuration.cpp 2014-03-17 15:02:33 +0000
@@ -19,6 +19,7 @@
19#include "mir/graphics/display_configuration.h"19#include "mir/graphics/display_configuration.h"
2020
21#include <ostream>21#include <ostream>
22#include <algorithm>
2223
23namespace mg = mir::graphics;24namespace mg = mir::graphics;
2425
@@ -196,3 +197,52 @@
196 return {top_left, {size.height.as_int(), size.width.as_int()}};197 return {top_left, {size.height.as_int(), size.width.as_int()}};
197 }198 }
198}199}
200
201bool mg::DisplayConfigurationOutput::valid() const
202{
203 if (!connected)
204 return !used;
205
206 auto const& f = std::find(pixel_formats.begin(), pixel_formats.end(),
207 current_format);
208 if (f == pixel_formats.end())
209 return false;
210
211 auto nmodes = modes.size();
212 if (preferred_mode_index >= nmodes || current_mode_index >= nmodes)
213 return false;
214
215 return true;
216}
217
218bool mg::DisplayConfiguration::valid() const
219{
220 bool all_valid = true;
221
222 for_each_output([&all_valid](DisplayConfigurationOutput const& out)
223 {
224 if (!out.valid())
225 all_valid = false;
226 });
227
228 return all_valid;
229}
230
231mg::UserDisplayConfigurationOutput::UserDisplayConfigurationOutput(
232 DisplayConfigurationOutput& master) :
233 id(master.id),
234 card_id(master.card_id),
235 type(master.type),
236 pixel_formats(master.pixel_formats),
237 modes(master.modes),
238 preferred_mode_index(master.preferred_mode_index),
239 physical_size_mm(master.physical_size_mm),
240 connected(master.connected),
241 used(master.used),
242 top_left(master.top_left),
243 current_mode_index(master.current_mode_index),
244 current_format(master.current_format),
245 power_mode(master.power_mode),
246 orientation(master.orientation)
247{
248}
199249
=== modified file 'src/platform/graphics/mesa/CMakeLists.txt'
--- src/platform/graphics/mesa/CMakeLists.txt 2014-02-28 13:51:43 +0000
+++ src/platform/graphics/mesa/CMakeLists.txt 2014-03-17 15:02:33 +0000
@@ -32,7 +32,6 @@
32 internal_native_surface.cpp32 internal_native_surface.cpp
33 internal_client.cpp33 internal_client.cpp
34 drm_close_threadsafe.cpp34 drm_close_threadsafe.cpp
35 overlapping_output_grouping.cpp
36 native_platform.cpp35 native_platform.cpp
37 anonymous_shm_file.cpp36 anonymous_shm_file.cpp
38 shm_buffer.cpp37 shm_buffer.cpp
@@ -54,6 +53,8 @@
54 ${GLESv2_LDFLAGS} ${GLESv2_LIBRARIES}53 ${GLESv2_LDFLAGS} ${GLESv2_LIBRARIES}
55)54)
5655
56install(TARGETS mirplatformgraphicsmesa LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mir/platformgraphics/mesa)
57
57if (MIR_TEST_PLATFORM STREQUAL "mesa")58if (MIR_TEST_PLATFORM STREQUAL "mesa")
58 add_custom_command(TARGET mirplatformgraphicsmesa59 add_custom_command(TARGET mirplatformgraphicsmesa
59 POST_BUILD60 POST_BUILD
@@ -61,6 +62,11 @@
61 COMMAND ${CMAKE_COMMAND} -E create_symlink mesa/$<TARGET_FILE_NAME:mirplatformgraphicsmesa> libmirplatformgraphics.so62 COMMAND ${CMAKE_COMMAND} -E create_symlink mesa/$<TARGET_FILE_NAME:mirplatformgraphicsmesa> libmirplatformgraphics.so
62 WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}63 WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
63 )64 )
65
66 install(CODE
67 "execute_process(
68 COMMAND ln -sf mir/platformgraphics/mesa/libmirplatformgraphics.so
69 WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
70 )"
71 )
64endif()72endif()
65
66install(TARGETS mirplatformgraphicsmesa LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/mir/platformgraphics/mesa)
6773
=== modified file 'src/platform/graphics/mesa/cursor.cpp'
--- src/platform/graphics/mesa/cursor.cpp 2014-01-22 10:03:11 +0000
+++ src/platform/graphics/mesa/cursor.cpp 2014-03-17 15:02:33 +0000
@@ -28,15 +28,32 @@
28#include <stdexcept>28#include <stdexcept>
29#include <vector>29#include <vector>
3030
31namespace mgm = mir::graphics::mesa;
32namespace geom = mir::geometry;
33
31namespace34namespace
32{35{
33#include "black_arrow.c"36#include "black_arrow.c"
34int const width = black_arrow.width;37int const width = black_arrow.width;
35int const height = black_arrow.height;38int const height = black_arrow.height;
36}
3739
38namespace mgm = mir::graphics::mesa;40// Transforms a relative position within the display bounds described by \a rect which is rotated with \a orientation
39namespace geom = mir::geometry;41geom::Displacement transform(geom::Rectangle const& rect, geom::Displacement const& vector, MirOrientation orientation)
42{
43 switch(orientation)
44 {
45 case mir_orientation_left:
46 return {vector.dy.as_int(), rect.size.width.as_int() -vector.dx.as_int()};
47 case mir_orientation_inverted:
48 return {rect.size.width.as_int() -vector.dx.as_int(), rect.size.height.as_int() - vector.dy.as_int()};
49 case mir_orientation_right:
50 return {rect.size.height.as_int() -vector.dy.as_int(), vector.dx.as_int()};
51 default:
52 case mir_orientation_normal:
53 return vector;
54 }
55}
56}
4057
41mgm::Cursor::GBMBOWrapper::GBMBOWrapper(gbm_device* gbm) :58mgm::Cursor::GBMBOWrapper::GBMBOWrapper(gbm_device* gbm) :
42 buffer(gbm_bo_create(59 buffer(gbm_bo_create(
@@ -103,7 +120,7 @@
103}120}
104121
105void mgm::Cursor::for_each_used_output(122void mgm::Cursor::for_each_used_output(
106 std::function<void(KMSOutput&, geom::Rectangle const&)> const& f)123 std::function<void(KMSOutput&, geom::Rectangle const&, MirOrientation orientation)> const& f)
107{124{
108 current_configuration->with_current_configuration_do(125 current_configuration->with_current_configuration_do(
109 [this,&f](KMSDisplayConfiguration const& kms_conf)126 [this,&f](KMSDisplayConfiguration const& kms_conf)
@@ -115,13 +132,7 @@
115 uint32_t const connector_id = kms_conf.get_kms_connector_id(conf_output.id);132 uint32_t const connector_id = kms_conf.get_kms_connector_id(conf_output.id);
116 auto output = output_container.get_kms_output_for(connector_id);133 auto output = output_container.get_kms_output_for(connector_id);
117134
118 // TODO: Cursor rotation support (conf_output.extents())135 f(*output, conf_output.extents(), conf_output.orientation);
119 geom::Rectangle output_rect
120 {
121 conf_output.top_left,
122 conf_output.modes[conf_output.current_mode_index].size
123 };
124 f(*output, output_rect);
125 }136 }
126 });137 });
127 });138 });
@@ -131,15 +142,15 @@
131 geometry::Point position,142 geometry::Point position,
132 ForceCursorState force_state)143 ForceCursorState force_state)
133{144{
134 for_each_used_output([&](KMSOutput& output, geom::Rectangle const& output_rect)145 for_each_used_output([&](KMSOutput& output, geom::Rectangle const& output_rect, MirOrientation orientation)
135 {146 {
136 if (output_rect.contains(position))147 if (output_rect.contains(position))
137 {148 {
138 auto dp = position - output_rect.top_left;149 auto dp = transform(output_rect, position - output_rect.top_left, orientation);
139 output.move_cursor({dp.dx.as_int(), dp.dy.as_int()});150 output.move_cursor({dp.dx.as_int(), dp.dy.as_int()});
140 if (force_state || !output.has_cursor())151 if (force_state || !output.has_cursor()) // TODO - or if orientation had changed - then set buffer..
141 {152 {
142 output.set_cursor(buffer);153 output.set_cursor(buffer);// TODO - select rotated buffer image
143 }154 }
144 }155 }
145 else156 else
146157
=== modified file 'src/platform/graphics/mesa/cursor.h'
--- src/platform/graphics/mesa/cursor.h 2014-01-22 10:03:11 +0000
+++ src/platform/graphics/mesa/cursor.h 2014-03-17 15:02:33 +0000
@@ -21,6 +21,7 @@
21#define MIR_GRAPHICS_MESA_CURSOR_H_21#define MIR_GRAPHICS_MESA_CURSOR_H_
2222
23#include "mir/graphics/cursor.h"23#include "mir/graphics/cursor.h"
24#include "mir_toolkit/common.h"
2425
25#include <gbm.h>26#include <gbm.h>
26#include <memory>27#include <memory>
@@ -73,7 +74,7 @@
7374
74private:75private:
75 enum ForceCursorState { UpdateState, ForceState };76 enum ForceCursorState { UpdateState, ForceState };
76 void for_each_used_output(std::function<void(KMSOutput&, geometry::Rectangle const&)> const& f);77 void for_each_used_output(std::function<void(KMSOutput&, geometry::Rectangle const&, MirOrientation orientation)> const& f);
77 void place_cursor_at(geometry::Point position, ForceCursorState force_state);78 void place_cursor_at(geometry::Point position, ForceCursorState force_state);
7879
79 KMSOutputContainer& output_container;80 KMSOutputContainer& output_container;
8081
=== modified file 'src/platform/graphics/mesa/display.cpp'
--- src/platform/graphics/mesa/display.cpp 2014-03-05 02:30:30 +0000
+++ src/platform/graphics/mesa/display.cpp 2014-03-17 15:02:33 +0000
@@ -24,7 +24,7 @@
24#include "kms_output.h"24#include "kms_output.h"
25#include "kms_page_flipper.h"25#include "kms_page_flipper.h"
26#include "virtual_terminal.h"26#include "virtual_terminal.h"
27#include "overlapping_output_grouping.h"27#include "mir/graphics/overlapping_output_grouping.h"
2828
29#include "mir/graphics/display_report.h"29#include "mir/graphics/display_report.h"
30#include "mir/graphics/gl_context.h"30#include "mir/graphics/gl_context.h"
@@ -128,6 +128,12 @@
128128
129void mgm::Display::configure(mg::DisplayConfiguration const& conf)129void mgm::Display::configure(mg::DisplayConfiguration const& conf)
130{130{
131 if (!conf.valid())
132 {
133 BOOST_THROW_EXCEPTION(
134 std::logic_error("Invalid or inconsistent display configuration"));
135 }
136
131 {137 {
132 std::lock_guard<std::mutex> lg{configuration_mutex};138 std::lock_guard<std::mutex> lg{configuration_mutex};
133139
134140
=== modified file 'src/platform/graphics/mesa/linux_virtual_terminal.cpp'
--- src/platform/graphics/mesa/linux_virtual_terminal.cpp 2014-01-22 10:03:11 +0000
+++ src/platform/graphics/mesa/linux_virtual_terminal.cpp 2014-03-17 15:02:33 +0000
@@ -36,11 +36,12 @@
3636
37namespace mgm = mir::graphics::mesa;37namespace mgm = mir::graphics::mesa;
3838
39mgm::LinuxVirtualTerminal::LinuxVirtualTerminal(39mgm::LinuxVirtualTerminal::LinuxVirtualTerminal(std::shared_ptr<VTFileOperations> const& fops,
40 std::shared_ptr<VTFileOperations> const& fops,40 std::unique_ptr<PosixProcessOperations> pops,
41 int vt_number,41 int vt_number,
42 std::shared_ptr<DisplayReport> const& report)42 std::shared_ptr<DisplayReport> const& report)
43 : fops{fops},43 : fops{fops},
44 pops{std::move(pops)},
44 report{report},45 report{report},
45 vt_fd{fops, open_vt(vt_number)},46 vt_fd{fops, open_vt(vt_number)},
46 prev_kd_mode{0},47 prev_kd_mode{0},
@@ -233,9 +234,9 @@
233 {234 {
234 // we should only try to create a new session in order to become the session235 // we should only try to create a new session in order to become the session
235 // and group leader if we are not already the session leader236 // and group leader if we are not already the session leader
236 if (getpid() != getsid(0))237 if (pops->getpid() != pops->getsid(0))
237 {238 {
238 if (getpid() == getpgid(0) && setpgid(0, getpgid(getppid())) < 0)239 if (pops->getpid() == pops->getpgid(0) && pops->setpgid(0, pops->getpgid(pops->getppid())) < 0)
239 {240 {
240 BOOST_THROW_EXCEPTION(241 BOOST_THROW_EXCEPTION(
241 boost::enable_error_info(242 boost::enable_error_info(
@@ -244,7 +245,7 @@
244 }245 }
245246
246 /* become process group leader */247 /* become process group leader */
247 if (setsid() < 0)248 if (pops->setsid() < 0)
248 {249 {
249 BOOST_THROW_EXCEPTION(250 BOOST_THROW_EXCEPTION(
250 boost::enable_error_info(251 boost::enable_error_info(
251252
=== modified file 'src/platform/graphics/mesa/linux_virtual_terminal.h'
--- src/platform/graphics/mesa/linux_virtual_terminal.h 2014-01-22 10:03:11 +0000
+++ src/platform/graphics/mesa/linux_virtual_terminal.h 2014-03-17 15:02:33 +0000
@@ -55,10 +55,30 @@
55 VTFileOperations& operator=(VTFileOperations const&) = delete;55 VTFileOperations& operator=(VTFileOperations const&) = delete;
56};56};
5757
58class PosixProcessOperations
59{
60public:
61 virtual ~PosixProcessOperations() = default;
62
63 virtual pid_t getpid() const = 0;
64 virtual pid_t getppid() const = 0;
65 virtual pid_t getpgid(pid_t process) const = 0;
66 virtual pid_t getsid(pid_t process) const = 0;
67
68 virtual int setpgid(pid_t process, pid_t group) = 0;
69 virtual pid_t setsid() = 0;
70
71protected:
72 PosixProcessOperations() = default;
73 PosixProcessOperations(PosixProcessOperations const&) = delete;
74 PosixProcessOperations& operator=(PosixProcessOperations const&) = delete;
75};
76
58class LinuxVirtualTerminal : public VirtualTerminal77class LinuxVirtualTerminal : public VirtualTerminal
59{78{
60public:79public:
61 LinuxVirtualTerminal(std::shared_ptr<VTFileOperations> const& fops,80 LinuxVirtualTerminal(std::shared_ptr<VTFileOperations> const& fops,
81 std::unique_ptr<PosixProcessOperations> pops,
62 int vt_number,82 int vt_number,
63 std::shared_ptr<DisplayReport> const& report);83 std::shared_ptr<DisplayReport> const& report);
64 ~LinuxVirtualTerminal() noexcept(true);84 ~LinuxVirtualTerminal() noexcept(true);
@@ -89,6 +109,7 @@
89109
90110
91 std::shared_ptr<VTFileOperations> const fops;111 std::shared_ptr<VTFileOperations> const fops;
112 std::unique_ptr<PosixProcessOperations> const pops;
92 std::shared_ptr<DisplayReport> const report;113 std::shared_ptr<DisplayReport> const report;
93 FDWrapper const vt_fd;114 FDWrapper const vt_fd;
94 int prev_kd_mode;115 int prev_kd_mode;
95116
=== modified file 'src/platform/graphics/mesa/native_platform.cpp'
--- src/platform/graphics/mesa/native_platform.cpp 2014-03-04 04:19:26 +0000
+++ src/platform/graphics/mesa/native_platform.cpp 2014-03-17 15:02:33 +0000
@@ -25,8 +25,13 @@
25#include "mir/graphics/platform_ipc_package.h"25#include "mir/graphics/platform_ipc_package.h"
26#include "mir/graphics/nested_context.h"26#include "mir/graphics/nested_context.h"
2727
28#include "internal_client.h"
29#include "internal_native_display.h"
30
28#include <boost/exception/errinfo_errno.hpp>31#include <boost/exception/errinfo_errno.hpp>
29#include <boost/throw_exception.hpp>32#include <boost/throw_exception.hpp>
33
34#include <mutex>
30#include <stdexcept>35#include <stdexcept>
3136
32namespace mg = mir::graphics;37namespace mg = mir::graphics;
@@ -42,6 +47,11 @@
42 nested_context->drm_set_gbm_device(gbm.device);47 nested_context->drm_set_gbm_device(gbm.device);
43}48}
4449
50mgm::NativePlatform::~NativePlatform()
51{
52 finish_internal_native_display();
53}
54
45std::shared_ptr<mg::GraphicBufferAllocator> mgm::NativePlatform::create_buffer_allocator(55std::shared_ptr<mg::GraphicBufferAllocator> mgm::NativePlatform::create_buffer_allocator(
46 std::shared_ptr<mg::BufferInitializer> const& buffer_initializer)56 std::shared_ptr<mg::BufferInitializer> const& buffer_initializer)
47{57{
@@ -82,7 +92,8 @@
8292
83std::shared_ptr<mg::InternalClient> mgm::NativePlatform::create_internal_client()93std::shared_ptr<mg::InternalClient> mgm::NativePlatform::create_internal_client()
84{94{
85 BOOST_THROW_EXCEPTION(std::runtime_error("MesaNativePlatform::create_internal_client is not implemented yet!"));95 auto nd = ensure_internal_native_display(get_ipc_package());
96 return std::make_shared<mgm::InternalClient>(nd);
86}97}
8798
88void mgm::NativePlatform::fill_ipc_package(BufferIPCPacker* packer, Buffer const* buffer) const99void mgm::NativePlatform::fill_ipc_package(BufferIPCPacker* packer, Buffer const* buffer) const
@@ -98,9 +109,45 @@
98 }109 }
99110
100 packer->pack_stride(buffer->stride());111 packer->pack_stride(buffer->stride());
112 packer->pack_flags(native_handle->flags);
113 packer->pack_size(buffer->size());
101}114}
102115
103extern "C" std::shared_ptr<mg::NativePlatform> create_native_platform(std::shared_ptr<mg::DisplayReport> const& /*report*/)116extern "C" std::shared_ptr<mg::NativePlatform> create_native_platform(std::shared_ptr<mg::DisplayReport> const& /*report*/)
104{117{
105 return std::make_shared<mgm::NativePlatform>();118 return std::make_shared<mgm::NativePlatform>();
106}119}
120
121namespace
122{
123std::shared_ptr<mgm::InternalNativeDisplay> native_display = nullptr;
124std::mutex native_display_guard;
125}
126
127bool mgm::NativePlatform::internal_native_display_in_use()
128{
129 std::unique_lock<std::mutex> lg(native_display_guard);
130 return native_display != nullptr;
131}
132
133std::shared_ptr<mgm::InternalNativeDisplay> mgm::NativePlatform::internal_native_display()
134{
135 std::unique_lock<std::mutex> lg(native_display_guard);
136 return native_display;
137}
138
139std::shared_ptr<mgm::InternalNativeDisplay> mgm::NativePlatform::ensure_internal_native_display(
140 std::shared_ptr<mg::PlatformIPCPackage> const& package)
141{
142 std::unique_lock<std::mutex> lg(native_display_guard);
143 if (!native_display)
144 native_display = std::make_shared<mgm::InternalNativeDisplay>(package);
145 return native_display;
146}
147
148void mgm::NativePlatform::finish_internal_native_display()
149{
150 std::unique_lock<std::mutex> lg(native_display_guard);
151 native_display.reset();
152}
153
107154
=== modified file 'src/platform/graphics/mesa/native_platform.h'
--- src/platform/graphics/mesa/native_platform.h 2014-01-22 10:03:11 +0000
+++ src/platform/graphics/mesa/native_platform.h 2014-03-17 15:02:33 +0000
@@ -30,20 +30,30 @@
30{30{
31namespace mesa31namespace mesa
32{32{
33class InternalNativeDisplay;
34
33class NativePlatform : public graphics::NativePlatform35class NativePlatform : public graphics::NativePlatform
34{36{
35public:37public:
38 virtual ~NativePlatform();
39
36 void initialize(std::shared_ptr<NestedContext> const& nested_context);40 void initialize(std::shared_ptr<NestedContext> const& nested_context);
37 std::shared_ptr<GraphicBufferAllocator> create_buffer_allocator(41 std::shared_ptr<GraphicBufferAllocator> create_buffer_allocator(
38 std::shared_ptr<BufferInitializer> const& buffer_initializer) override;42 std::shared_ptr<BufferInitializer> const& buffer_initializer) override;
39 std::shared_ptr<PlatformIPCPackage> get_ipc_package() override;43 std::shared_ptr<PlatformIPCPackage> get_ipc_package() override;
40 std::shared_ptr<InternalClient> create_internal_client() override;44 std::shared_ptr<InternalClient> create_internal_client() override;
41 void fill_ipc_package(BufferIPCPacker* packer, Buffer const* buffer) const override;45 void fill_ipc_package(BufferIPCPacker* packer, Buffer const* buffer) const override;
46
47 static std::shared_ptr<InternalNativeDisplay> internal_native_display();
48 static bool internal_native_display_in_use();
4249
43private:50private:
44 int drm_fd;51 int drm_fd;
45 std::shared_ptr<NestedContext> nested_context;52 std::shared_ptr<NestedContext> nested_context;
46 helpers::GBMHelper gbm;53 helpers::GBMHelper gbm;
54
55 static std::shared_ptr<InternalNativeDisplay> ensure_internal_native_display(std::shared_ptr<PlatformIPCPackage> const& package);
56 static void finish_internal_native_display();
47};57};
48}58}
49}59}
5060
=== modified file 'src/platform/graphics/mesa/platform.cpp'
--- src/platform/graphics/mesa/platform.cpp 2014-02-12 03:14:55 +0000
+++ src/platform/graphics/mesa/platform.cpp 2014-03-17 15:02:33 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19#include "platform.h"19#include "platform.h"
20#include "native_platform.h"
20#include "buffer_allocator.h"21#include "buffer_allocator.h"
21#include "display.h"22#include "display.h"
22#include "internal_client.h"23#include "internal_client.h"
@@ -89,6 +90,34 @@
89 }90 }
90};91};
9192
93struct RealPosixProcessOperations : public mgm::PosixProcessOperations
94{
95 pid_t getpid() const override
96 {
97 return ::getpid();
98 }
99 pid_t getppid() const override
100 {
101 return ::getppid();
102 }
103 pid_t getpgid(pid_t process) const override
104 {
105 return ::getpgid(process);
106 }
107 pid_t getsid(pid_t process) const override
108 {
109 return ::getsid(process);
110 }
111 int setpgid(pid_t process, pid_t group) override
112 {
113 return ::setpgid(process, group);
114 }
115 pid_t setsid() override
116 {
117 return ::setsid();
118 }
119};
120
92}121}
93122
94std::shared_ptr<mgm::InternalNativeDisplay> mgm::Platform::internal_native_display;123std::shared_ptr<mgm::InternalNativeDisplay> mgm::Platform::internal_native_display;
@@ -169,8 +198,10 @@
169extern "C" std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<mo::Option> const& options, std::shared_ptr<DisplayReport> const& report)198extern "C" std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<mo::Option> const& options, std::shared_ptr<DisplayReport> const& report)
170{199{
171 auto real_fops = std::make_shared<RealVTFileOperations>();200 auto real_fops = std::make_shared<RealVTFileOperations>();
201 auto real_pops = std::unique_ptr<RealPosixProcessOperations>(new RealPosixProcessOperations{});
172 auto vt = std::make_shared<mgm::LinuxVirtualTerminal>(202 auto vt = std::make_shared<mgm::LinuxVirtualTerminal>(
173 real_fops,203 real_fops,
204 std::move(real_pops),
174 options->get<int>("vt"), // TODO This option is mesa specific205 options->get<int>("vt"), // TODO This option is mesa specific
175 report);206 report);
176207
@@ -179,6 +210,12 @@
179210
180extern "C" int mir_server_mesa_egl_native_display_is_valid(MirMesaEGLNativeDisplay* display)211extern "C" int mir_server_mesa_egl_native_display_is_valid(MirMesaEGLNativeDisplay* display)
181{212{
182 return ((mgm::Platform::internal_display_clients_present) &&213 bool nested_internal_display_in_use = mgm::NativePlatform::internal_native_display_in_use();
183 (display == mgm::Platform::internal_native_display.get()));214 bool host_internal_display_in_use = mgm::Platform::internal_display_clients_present;
215
216 if (host_internal_display_in_use)
217 return (display == mgm::Platform::internal_native_display.get());
218 else if (nested_internal_display_in_use)
219 return (display == mgm::NativePlatform::internal_native_display().get());
220 return 0;
184}221}
185222
=== modified file 'src/platform/graphics/mesa/real_kms_display_configuration.cpp'
--- src/platform/graphics/mesa/real_kms_display_configuration.cpp 2014-03-05 02:30:30 +0000
+++ src/platform/graphics/mesa/real_kms_display_configuration.cpp 2014-03-17 15:02:33 +0000
@@ -66,11 +66,6 @@
66 return static_cast<mg::DisplayConfigurationOutputType>(connector_type);66 return static_cast<mg::DisplayConfigurationOutputType>(connector_type);
67}67}
6868
69bool format_available_in_pixel_formats(MirPixelFormat format, mg::DisplayConfigurationOutput const& output)
70{
71 return output.pixel_formats.end() != find(output.pixel_formats.begin(), output.pixel_formats.end(), format);
72}
73
74}69}
7570
76mgm::RealKMSDisplayConfiguration::RealKMSDisplayConfiguration(int drm_fd)71mgm::RealKMSDisplayConfiguration::RealKMSDisplayConfiguration(int drm_fd)
@@ -112,36 +107,13 @@
112 f(output);107 f(output);
113}108}
114109
115void mgm::RealKMSDisplayConfiguration::configure_output(110void mgm::RealKMSDisplayConfiguration::for_each_output(
116 DisplayConfigurationOutputId id, bool used,111 std::function<void(UserDisplayConfigurationOutput&)> f)
117 geometry::Point top_left, size_t mode_index,
118 MirPixelFormat format, MirPowerMode power_mode, MirOrientation orientation)
119{112{
120 auto iter = find_output_with_id(id);113 for (auto& output : outputs)
121114 {
122 if (iter != outputs.end())115 UserDisplayConfigurationOutput user(output);
123 {116 f(user);
124 auto& output = *iter;
125
126 if (used && mode_index >= output.modes.size())
127 BOOST_THROW_EXCEPTION(std::runtime_error("Invalid mode_index for used output"));
128
129 if (used && !valid_pixel_format(format))
130 BOOST_THROW_EXCEPTION(std::runtime_error("Invalid format for used output"));
131
132 if (used && !format_available_in_pixel_formats(format, output))
133 BOOST_THROW_EXCEPTION(std::runtime_error("Format not available for used output"));
134
135 output.used = used;
136 output.top_left = top_left;
137 output.current_mode_index = mode_index;
138 output.current_format = format;
139 output.power_mode = power_mode;
140 output.orientation = orientation;
141 }
142 else
143 {
144 BOOST_THROW_EXCEPTION(std::runtime_error("Trying to configure invalid output"));
145 }117 }
146}118}
147119
148120
=== modified file 'src/platform/graphics/mesa/real_kms_display_configuration.h'
--- src/platform/graphics/mesa/real_kms_display_configuration.h 2014-03-05 02:30:30 +0000
+++ src/platform/graphics/mesa/real_kms_display_configuration.h 2014-03-17 15:02:33 +0000
@@ -39,10 +39,7 @@
3939
40 void for_each_card(std::function<void(DisplayConfigurationCard const&)> f) const override;40 void for_each_card(std::function<void(DisplayConfigurationCard const&)> f) const override;
41 void for_each_output(std::function<void(DisplayConfigurationOutput const&)> f) const override;41 void for_each_output(std::function<void(DisplayConfigurationOutput const&)> f) const override;
42 void configure_output(DisplayConfigurationOutputId id, bool used,42 void for_each_output(std::function<void(UserDisplayConfigurationOutput&)> f) override;
43 geometry::Point top_left, size_t mode_index,
44 MirPixelFormat format, MirPowerMode power_mode,
45 MirOrientation orientation) override;
4643
47 uint32_t get_kms_connector_id(DisplayConfigurationOutputId id) const;44 uint32_t get_kms_connector_id(DisplayConfigurationOutputId id) const;
48 size_t get_kms_mode_index(DisplayConfigurationOutputId id, size_t conf_mode_index) const;45 size_t get_kms_mode_index(DisplayConfigurationOutputId id, size_t conf_mode_index) const;
4946
=== renamed file 'src/platform/graphics/mesa/overlapping_output_grouping.cpp' => 'src/platform/graphics/overlapping_output_grouping.cpp'
--- src/platform/graphics/mesa/overlapping_output_grouping.cpp 2014-01-22 10:03:11 +0000
+++ src/platform/graphics/overlapping_output_grouping.cpp 2014-03-17 15:02:33 +0000
@@ -16,7 +16,7 @@
16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */17 */
1818
19#include "overlapping_output_grouping.h"19#include "mir/graphics/overlapping_output_grouping.h"
2020
21#include "mir/graphics/display_configuration.h"21#include "mir/graphics/display_configuration.h"
22#include "mir/geometry/rectangle.h"22#include "mir/geometry/rectangle.h"
@@ -25,7 +25,6 @@
25#include <unordered_set>25#include <unordered_set>
2626
27namespace mg = mir::graphics;27namespace mg = mir::graphics;
28namespace mgm = mir::graphics::mesa;
29namespace geom = mir::geometry;28namespace geom = mir::geometry;
3029
31namespace30namespace
@@ -33,7 +32,7 @@
3332
34struct DCOutputHash33struct DCOutputHash
35{34{
36 size_t operator()(mg::DisplayConfigurationOutput const& o) const { return o.id.as_value(); };35 size_t operator()(mg::DisplayConfigurationOutput const& o) const { return o.id.as_value(); }
37};36};
3837
39struct DCOutputEqual38struct DCOutputEqual
@@ -51,7 +50,7 @@
51 * OverlappingOutputGroup *50 * OverlappingOutputGroup *
52 **************************/51 **************************/
5352
54geom::Rectangle mgm::OverlappingOutputGroup::bounding_rectangle() const53geom::Rectangle mg::OverlappingOutputGroup::bounding_rectangle() const
55{54{
56 geom::Rectangles rectangles;55 geom::Rectangles rectangles;
5756
@@ -61,7 +60,7 @@
61 return rectangles.bounding_rectangle();60 return rectangles.bounding_rectangle();
62}61}
6362
64void mgm::OverlappingOutputGroup::for_each_output(63void mg::OverlappingOutputGroup::for_each_output(
65 std::function<void(DisplayConfigurationOutput const&)> const& f) const64 std::function<void(DisplayConfigurationOutput const&)> const& f) const
66{65{
67 for (auto const& output : outputs)66 for (auto const& output : outputs)
@@ -72,7 +71,7 @@
72 * OverlappingOutputGrouping *71 * OverlappingOutputGrouping *
73 *****************************/72 *****************************/
7473
75mgm::OverlappingOutputGrouping::OverlappingOutputGrouping(DisplayConfiguration const& conf)74mg::OverlappingOutputGrouping::OverlappingOutputGrouping(DisplayConfiguration const& conf)
76{75{
77 conf.for_each_output([&](DisplayConfigurationOutput const& conf_output)76 conf.for_each_output([&](DisplayConfigurationOutput const& conf_output)
78 {77 {
@@ -85,14 +84,14 @@
8584
86}85}
8786
88void mgm::OverlappingOutputGrouping::for_each_group(87void mg::OverlappingOutputGrouping::for_each_group(
89 std::function<void(OverlappingOutputGroup const& group)> const& f)88 std::function<void(OverlappingOutputGroup const& group)> const& f)
90{89{
91 for (auto const& g : groups)90 for (auto const& g : groups)
92 f(g);91 f(g);
93}92}
9493
95void mgm::OverlappingOutputGrouping::add_output(DisplayConfigurationOutput const& conf_output)94void mg::OverlappingOutputGrouping::add_output(DisplayConfigurationOutput const& conf_output)
96{95{
97 std::vector<size_t> overlapping_groups;96 std::vector<size_t> overlapping_groups;
9897
9998
=== modified file 'src/platform/options/default_configuration.cpp'
--- src/platform/options/default_configuration.cpp 2014-03-04 14:19:36 +0000
+++ src/platform/options/default_configuration.cpp 2014-03-17 15:02:33 +0000
@@ -34,7 +34,6 @@
34char const* const mo::scene_report_opt = "scene-report";34char const* const mo::scene_report_opt = "scene-report";
35char const* const mo::input_report_opt = "input-report";35char const* const mo::input_report_opt = "input-report";
36char const* const mo::host_socket_opt = "host-socket";36char const* const mo::host_socket_opt = "host-socket";
37char const* const mo::standalone_opt = "standalone";
38char const* const mo::frontend_threads_opt = "ipc-thread-pool";37char const* const mo::frontend_threads_opt = "ipc-thread-pool";
39char const* const mo::name_opt = "name";38char const* const mo::name_opt = "name";
40char const* const mo::offscreen_opt = "offscreen";39char const* const mo::offscreen_opt = "offscreen";
@@ -70,12 +69,10 @@
70 namespace po = boost::program_options;69 namespace po = boost::program_options;
7170
72 add_options()71 add_options()
73 (standalone_opt, po::value<bool>(),
74 "Run mir in standalone mode. [bool:default=false]")
75 (host_socket_opt, po::value<std::string>(),72 (host_socket_opt, po::value<std::string>(),
76 "Host socket filename. [string:default={$MIR_SOCKET,$XDG_RUNTIME_DIR/mir_socket}]")73 "Host socket filename")
77 (server_socket_opt, po::value<std::string>()->default_value(::mir::default_server_socket),74 (server_socket_opt, po::value<std::string>()->default_value(::mir::default_server_socket),
78 "Socket filename.")75 "Socket filename [string:default=$XDG_RUNTIME_DIR/mir_socket or /tmp/mir_socket]")
79 (no_server_socket_opt, "Do not provide a socket filename for client connections")76 (no_server_socket_opt, "Do not provide a socket filename for client connections")
80 (platform_graphics_lib, po::value<std::string>()->default_value(default_platform_graphics_lib),77 (platform_graphics_lib, po::value<std::string>()->default_value(default_platform_graphics_lib),
81 "Library to use for platform graphics support")78 "Library to use for platform graphics support")
8279
=== modified file 'src/server/CMakeLists.txt'
--- src/server/CMakeLists.txt 2014-02-28 13:51:43 +0000
+++ src/server/CMakeLists.txt 2014-03-17 15:02:33 +0000
@@ -94,7 +94,7 @@
94 )94 )
95endif()95endif()
9696
97set(MIRSERVER_ABI 16)97set(MIRSERVER_ABI 17)
9898
99set_target_properties(99set_target_properties(
100 mirserver100 mirserver
101101
=== modified file 'src/server/compositor/buffer_bundle.h'
--- src/server/compositor/buffer_bundle.h 2014-02-10 09:07:48 +0000
+++ src/server/compositor/buffer_bundle.h 2014-03-17 15:02:33 +0000
@@ -46,6 +46,7 @@
46 virtual void allow_framedropping(bool dropping_allowed) = 0;46 virtual void allow_framedropping(bool dropping_allowed) = 0;
47 virtual void force_requests_to_complete() = 0;47 virtual void force_requests_to_complete() = 0;
48 virtual void resize(const geometry::Size &newsize) = 0;48 virtual void resize(const geometry::Size &newsize) = 0;
49 virtual int buffers_ready_for_compositor() const = 0;
49protected:50protected:
50 BufferBundle() = default;51 BufferBundle() = default;
51 BufferBundle(BufferBundle const&) = delete;52 BufferBundle(BufferBundle const&) = delete;
5253
=== modified file 'src/server/compositor/buffer_stream_surfaces.cpp'
--- src/server/compositor/buffer_stream_surfaces.cpp 2014-02-10 09:07:48 +0000
+++ src/server/compositor/buffer_stream_surfaces.cpp 2014-03-17 15:02:33 +0000
@@ -83,3 +83,8 @@
83{83{
84 buffer_bundle->allow_framedropping(allow);84 buffer_bundle->allow_framedropping(allow);
85}85}
86
87int mc::BufferStreamSurfaces::buffers_ready_for_compositor() const
88{
89 return buffer_bundle->buffers_ready_for_compositor();
90}
8691
=== modified file 'src/server/compositor/buffer_stream_surfaces.h'
--- src/server/compositor/buffer_stream_surfaces.h 2014-02-10 09:07:48 +0000
+++ src/server/compositor/buffer_stream_surfaces.h 2014-03-17 15:02:33 +0000
@@ -50,6 +50,7 @@
50 void resize(geometry::Size const& size) override;50 void resize(geometry::Size const& size) override;
51 void allow_framedropping(bool) override;51 void allow_framedropping(bool) override;
52 void force_requests_to_complete() override;52 void force_requests_to_complete() override;
53 int buffers_ready_for_compositor() const override;
5354
54protected:55protected:
55 BufferStreamSurfaces(const BufferStreamSurfaces&) = delete;56 BufferStreamSurfaces(const BufferStreamSurfaces&) = delete;
5657
=== modified file 'src/server/compositor/bypass.cpp'
--- src/server/compositor/bypass.cpp 2014-03-04 04:19:26 +0000
+++ src/server/compositor/bypass.cpp 2014-03-17 15:02:33 +0000
@@ -16,84 +16,46 @@
16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */17 */
1818
19#include "mir/compositor/compositing_criteria.h"19#include "mir/graphics/renderable.h"
20#include "mir/graphics/display_buffer.h"20#include "mir/graphics/display_buffer.h"
21#include "bypass.h"21#include "bypass.h"
2222
23using namespace mir;23using namespace mir;
24using namespace mir::compositor;24using namespace mir::compositor;
25using namespace mir::graphics;
2526
26BypassFilter::BypassFilter(const graphics::DisplayBuffer &display_buffer)27BypassFilter::BypassFilter(const graphics::DisplayBuffer &display_buffer)
27 : display_buffer(display_buffer)28 : display_buffer(display_buffer)
28{29{
29 const geometry::Rectangle &rect = display_buffer.view_area();
30 int width = rect.size.width.as_int();
31 int height = rect.size.height.as_int();
32
33 /*
34 * For a surface to exactly fit the display_buffer, its transformation
35 * will look exactly like this:
36 */
37 fullscreen[0][0] = width;
38 fullscreen[0][1] = 0.0f;
39 fullscreen[0][2] = 0.0f;
40 fullscreen[0][3] = 0.0f;
41
42 fullscreen[1][0] = 0.0f;
43 fullscreen[1][1] = height;
44 fullscreen[1][2] = 0.0f;
45 fullscreen[1][3] = 0.0f;
46
47 fullscreen[2][0] = 0.0f;
48 fullscreen[2][1] = 0.0f;
49 fullscreen[2][2] = 0.0f;
50 fullscreen[2][3] = 0.0f;
51
52 fullscreen[3][0] = rect.top_left.x.as_int() + width / 2;
53 fullscreen[3][1] = rect.top_left.y.as_int() + height / 2;
54 fullscreen[3][2] = 0.0f;
55 fullscreen[3][3] = 1.0f;
56}30}
5731
58bool BypassFilter::operator()(const CompositingCriteria &criteria)32bool BypassFilter::operator()(const Renderable &renderable)
59{33{
60 if (!all_orthogonal)34 if (!all_orthogonal)
61 return false;35 return false;
6236
63 const glm::mat4 &trans = criteria.transformation();
64 bool orthogonal =
65 trans[0][1] == 0.0f &&
66 trans[0][2] == 0.0f &&
67 trans[0][3] == 0.0f &&
68 trans[1][0] == 0.0f &&
69 trans[1][2] == 0.0f &&
70 trans[1][3] == 0.0f &&
71 trans[2][0] == 0.0f &&
72 trans[2][1] == 0.0f &&
73 trans[2][2] == 0.0f &&
74 trans[2][3] == 0.0f &&
75 trans[3][2] == 0.0f &&
76 trans[3][3] == 1.0f;
77
78 // Any weird transformations? Then we can't risk any bypass37 // Any weird transformations? Then we can't risk any bypass
79 if (!orthogonal)38 static const glm::mat4 identity;
39 if (renderable.transformation() != identity)
80 {40 {
81 all_orthogonal = false;41 all_orthogonal = false;
82 return false;42 return false;
83 }43 }
8444
45 auto const& view_area = display_buffer.view_area();
46
85 // Not weirdly transformed but also not on this monitor? Don't care...47 // Not weirdly transformed but also not on this monitor? Don't care...
86 // This will also check the surface is not hidden and has been posted.48 // This will also check the surface is not hidden and has been posted.
87 if (!criteria.should_be_rendered_in(display_buffer.view_area()))49 if (!renderable.should_be_rendered_in(view_area))
88 return false;50 return false;
8951
90 topmost_fits = false;52 topmost_fits = false;
9153
92 if (criteria.alpha() != 1.0f || criteria.shaped())54 if (renderable.alpha() != 1.0f || renderable.shaped())
93 return false;55 return false;
9456
95 // Transformed perfectly to fit the monitor? Bypass!57 // Transformed perfectly to fit the monitor? Bypass!
96 topmost_fits = criteria.transformation() == fullscreen;58 topmost_fits = renderable.screen_position() == view_area;
97 return topmost_fits;59 return topmost_fits;
98}60}
9961
@@ -102,13 +64,12 @@
102 return all_orthogonal && topmost_fits;64 return all_orthogonal && topmost_fits;
103}65}
10466
105void BypassMatch::operator()(const CompositingCriteria &,67void BypassMatch::operator()(const Renderable &r)
106 compositor::BufferStream &stream)
107{68{
108 latest = &stream;69 latest = &r;
109}70}
11071
111compositor::BufferStream *BypassMatch::topmost_fullscreen() const72const Renderable *BypassMatch::topmost_fullscreen() const
112{73{
113 return latest;74 return latest;
114}75}
11576
=== modified file 'src/server/compositor/bypass.h'
--- src/server/compositor/bypass.h 2014-03-04 04:19:26 +0000
+++ src/server/compositor/bypass.h 2014-03-17 15:02:33 +0000
@@ -20,7 +20,6 @@
20#define MIR_COMPOSITOR_BYPASS_H_20#define MIR_COMPOSITOR_BYPASS_H_
2121
22#include "mir/compositor/scene.h"22#include "mir/compositor/scene.h"
23#include "glm/glm.hpp"
2423
25namespace mir24namespace mir
26{25{
@@ -30,32 +29,29 @@
30}29}
31namespace compositor30namespace compositor
32{31{
33class CompositingCriteria;
3432
35class BypassFilter : public FilterForScene33class BypassFilter : public FilterForScene
36{34{
37public:35public:
38 BypassFilter(const graphics::DisplayBuffer &display_buffer);36 BypassFilter(const graphics::DisplayBuffer &display_buffer);
39 bool operator()(const CompositingCriteria &criteria) override;37 bool operator()(const graphics::Renderable &) override;
40 bool fullscreen_on_top() const;38 bool fullscreen_on_top() const;
4139
42private:40private:
43 bool all_orthogonal = true;41 bool all_orthogonal = true;
44 bool topmost_fits = false;42 bool topmost_fits = false;
45 glm::mat4 fullscreen;
46 const graphics::DisplayBuffer &display_buffer;43 const graphics::DisplayBuffer &display_buffer;
47};44};
4845
49class BypassMatch : public OperatorForScene46class BypassMatch : public OperatorForScene
50{47{
51public:48public:
52 void operator()(const CompositingCriteria &,49 void operator()(const graphics::Renderable &) override;
53 compositor::BufferStream &stream) override;50 const graphics::Renderable *topmost_fullscreen() const;
54 compositor::BufferStream *topmost_fullscreen() const;
5551
56private:52private:
57 // This has to be a pointer. We have no control over BufferStream lifetime53 // This has to be a pointer. We have no control over Renderable lifetime
58 compositor::BufferStream *latest = nullptr;54 const graphics::Renderable *latest = nullptr;
59};55};
6056
61} // namespace compositor57} // namespace compositor
6258
=== modified file 'src/server/compositor/compositing_screencast.cpp'
--- src/server/compositor/compositing_screencast.cpp 2014-02-05 16:32:31 +0000
+++ src/server/compositor/compositing_screencast.cpp 2014-03-17 15:02:33 +0000
@@ -60,15 +60,21 @@
60}60}
6161
62mf::ScreencastSessionId mc::CompositingScreencast::create_session(62mf::ScreencastSessionId mc::CompositingScreencast::create_session(
63 graphics::DisplayConfigurationOutputId output_id)63 geom::Rectangle const& region,
64 geom::Size const& size,
65 MirPixelFormat const pixel_format)
64{66{
65 geom::Rectangle extents;67 if (size.width.as_int() == 0 ||
66 MirPixelFormat pixel_format;68 size.height.as_int() == 0 ||
67 std::tie(extents,pixel_format) = output_info_for(output_id);69 region.size.width.as_int() == 0 ||
6870 region.size.height.as_int() == 0 ||
71 pixel_format == mir_pixel_format_invalid)
72 {
73 BOOST_THROW_EXCEPTION(std::runtime_error("Invalid parameters"));
74 }
69 std::lock_guard<decltype(session_mutex)> lock{session_mutex};75 std::lock_guard<decltype(session_mutex)> lock{session_mutex};
70 auto const id = next_available_session_id();76 auto const id = next_available_session_id();
71 session_contexts[id] = create_session_context(extents, pixel_format);77 session_contexts[id] = create_session_context(region, size, pixel_format);
7278
73 return id;79 return id;
74}80}
@@ -115,43 +121,14 @@
115 BOOST_THROW_EXCEPTION(std::runtime_error("Too many screencast sessions!"));121 BOOST_THROW_EXCEPTION(std::runtime_error("Too many screencast sessions!"));
116}122}
117123
118std::pair<geom::Rectangle,MirPixelFormat>
119mc::CompositingScreencast::output_info_for(
120 graphics::DisplayConfigurationOutputId output_id)
121{
122 auto const conf = display->configuration();
123 geom::Rectangle extents;
124 MirPixelFormat pixel_format{mir_pixel_format_invalid};
125
126 conf->for_each_output(
127 [&](mg::DisplayConfigurationOutput const& output)
128 {
129 if (output.id == output_id &&
130 output.connected && output.used &&
131 output.current_mode_index < output.modes.size())
132 {
133 extents = output.extents();
134 pixel_format = output.current_format;
135 }
136 });
137
138 if (extents == geom::Rectangle() ||
139 pixel_format == mir_pixel_format_invalid)
140 {
141 BOOST_THROW_EXCEPTION(
142 std::runtime_error("Invalid output for screen capture"));
143 }
144
145 return {extents, pixel_format};
146}
147
148std::shared_ptr<mc::detail::ScreencastSessionContext>124std::shared_ptr<mc::detail::ScreencastSessionContext>
149mc::CompositingScreencast::create_session_context(125mc::CompositingScreencast::create_session_context(
150 geometry::Rectangle const& rect,126 geometry::Rectangle const& rect,
127 geometry::Size const& size,
151 MirPixelFormat pixel_format)128 MirPixelFormat pixel_format)
152{129{
153 mg::BufferProperties buffer_properties{130 mg::BufferProperties buffer_properties{
154 rect.size,131 size,
155 pixel_format,132 pixel_format,
156 mg::BufferUsage::hardware};133 mg::BufferUsage::hardware};
157134
158135
=== modified file 'src/server/compositor/compositing_screencast.h'
--- src/server/compositor/compositing_screencast.h 2014-02-05 16:32:31 +0000
+++ src/server/compositor/compositing_screencast.h 2014-03-17 15:02:33 +0000
@@ -48,16 +48,18 @@
48 std::shared_ptr<DisplayBufferCompositorFactory> const& db_compositor_factory);48 std::shared_ptr<DisplayBufferCompositorFactory> const& db_compositor_factory);
4949
50 frontend::ScreencastSessionId create_session(50 frontend::ScreencastSessionId create_session(
51 graphics::DisplayConfigurationOutputId output_id);51 geometry::Rectangle const& region,
52 geometry::Size const& size,
53 MirPixelFormat pixel_format);
52 void destroy_session(frontend::ScreencastSessionId id);54 void destroy_session(frontend::ScreencastSessionId id);
53 std::shared_ptr<graphics::Buffer> capture(frontend::ScreencastSessionId id);55 std::shared_ptr<graphics::Buffer> capture(frontend::ScreencastSessionId id);
5456
55private:57private:
56 frontend::ScreencastSessionId next_available_session_id();58 frontend::ScreencastSessionId next_available_session_id();
57 std::pair<geometry::Rectangle,MirPixelFormat> output_info_for(
58 graphics::DisplayConfigurationOutputId output_id);
59 std::shared_ptr<detail::ScreencastSessionContext>59 std::shared_ptr<detail::ScreencastSessionContext>
60 create_session_context(geometry::Rectangle const& rect, MirPixelFormat pixel_format);60 create_session_context(geometry::Rectangle const& rect,
61 geometry::Size const& size,
62 MirPixelFormat pixel_format);
6163
62 std::mutex session_mutex;64 std::mutex session_mutex;
63 std::shared_ptr<graphics::Display> const display;65 std::shared_ptr<graphics::Display> const display;
6466
=== modified file 'src/server/compositor/default_configuration.cpp'
--- src/server/compositor/default_configuration.cpp 2014-02-28 13:51:43 +0000
+++ src/server/compositor/default_configuration.cpp 2014-03-17 15:02:33 +0000
@@ -25,6 +25,7 @@
25#include "compositing_screencast.h"25#include "compositing_screencast.h"
2626
27#include "mir/frontend/screencast.h"27#include "mir/frontend/screencast.h"
28#include "mir/options/configuration.h"
2829
29#include <boost/throw_exception.hpp>30#include <boost/throw_exception.hpp>
3031
@@ -59,10 +60,12 @@
59 return compositor(60 return compositor(
60 [this]()61 [this]()
61 {62 {
62 return std::make_shared<mc::MultiThreadedCompositor>(the_display(),63 return std::make_shared<mc::MultiThreadedCompositor>(
63 the_scene(),64 the_display(),
64 the_display_buffer_compositor_factory(),65 the_scene(),
65 the_compositor_report());66 the_display_buffer_compositor_factory(),
67 the_compositor_report(),
68 !the_options()->is_set(options::host_socket_opt));
66 });69 });
67}70}
6871
6972
=== modified file 'src/server/compositor/default_display_buffer_compositor.cpp'
--- src/server/compositor/default_display_buffer_compositor.cpp 2014-03-04 04:19:26 +0000
+++ src/server/compositor/default_display_buffer_compositor.cpp 2014-03-17 15:02:33 +0000
@@ -21,7 +21,7 @@
2121
22#include "rendering_operator.h"22#include "rendering_operator.h"
23#include "mir/compositor/scene.h"23#include "mir/compositor/scene.h"
24#include "mir/compositor/compositing_criteria.h"24#include "mir/graphics/renderable.h"
25#include "mir/graphics/display_buffer.h"25#include "mir/graphics/display_buffer.h"
26#include "mir/graphics/buffer.h"26#include "mir/graphics/buffer.h"
27#include "mir/compositor/buffer_stream.h"27#include "mir/compositor/buffer_stream.h"
@@ -46,10 +46,10 @@
46 occlusions(occlusions)46 occlusions(occlusions)
47 {47 {
48 }48 }
49 bool operator()(mc::CompositingCriteria const& info)49 bool operator()(mg::Renderable const& r)
50 {50 {
51 return info.should_be_rendered_in(enclosing_region) &&51 return r.should_be_rendered_in(enclosing_region) &&
52 !occlusions.occluded(info);52 !occlusions.occluded(r);
53 }53 }
5454
55 mir::geometry::Rectangle const& enclosing_region;55 mir::geometry::Rectangle const& enclosing_region;
@@ -80,7 +80,7 @@
80}80}
8181
8282
83void mc::DefaultDisplayBufferCompositor::composite()83bool mc::DefaultDisplayBufferCompositor::composite()
84{84{
85 report->began_frame(this);85 report->began_frame(this);
8686
@@ -104,9 +104,15 @@
104 return !env || env[0] != '0';104 return !env || env[0] != '0';
105 }()};105 }()};
106 bool bypassed = false;106 bool bypassed = false;
107 bool uncomposited_buffers{false};
107108
108 if (bypass_env && display_buffer.can_bypass())109 if (bypass_env && display_buffer.can_bypass())
109 {110 {
111 // It would be *really* nice not to lock the scene for a composite pass.
112 // (C.f. lp:1234018)
113 // A compositor shouldn't know anything about navigating the scene,
114 // it should be passed a collection of objects to render. (And any
115 // locks managed by the scene - which can just lock what is needed.)
110 std::unique_lock<Scene> lock(*scene);116 std::unique_lock<Scene> lock(*scene);
111117
112 mc::BypassFilter filter(display_buffer);118 mc::BypassFilter filter(display_buffer);
@@ -118,11 +124,12 @@
118 if (filter.fullscreen_on_top())124 if (filter.fullscreen_on_top())
119 {125 {
120 auto bypass_buf =126 auto bypass_buf =
121 match.topmost_fullscreen()->lock_compositor_buffer(127 match.topmost_fullscreen()->buffer(local_frameno);
122 local_frameno);
123128
124 if (bypass_buf->can_bypass())129 if (bypass_buf->can_bypass())
125 {130 {
131 uncomposited_buffers = match.topmost_fullscreen()->buffers_ready_for_compositor() > 1;
132
126 lock.unlock();133 lock.unlock();
127 display_buffer.post_update(bypass_buf);134 display_buffer.post_update(bypass_buf);
128 bypassed = true;135 bypassed = true;
@@ -150,14 +157,24 @@
150157
151 renderer->set_rotation(display_buffer.orientation());158 renderer->set_rotation(display_buffer.orientation());
152 renderer->begin();159 renderer->begin();
153 mc::RenderingOperator applicator(*renderer, save_resource, local_frameno);160 mc::RenderingOperator applicator(*renderer, save_resource, local_frameno, uncomposited_buffers);
154 FilterForVisibleSceneInRegion selector(view_area, occlusion_match);161 FilterForVisibleSceneInRegion selector(view_area, occlusion_match);
155 scene->for_each_if(selector, applicator);162 scene->for_each_if(selector, applicator);
156 renderer->end();163 renderer->end();
157164
158 display_buffer.post_update();165 display_buffer.post_update();
166
167 // This is a frig to avoid lp:1286190
168 if (size_of_last_pass)
169 {
170 uncomposited_buffers |= saved_resources.empty();
171 }
172
173 size_of_last_pass = saved_resources.size();
174 // End of frig
159 }175 }
160176
161 report->finished_frame(bypassed, this);177 report->finished_frame(bypassed, this);
178 return uncomposited_buffers;
162}179}
163180
164181
=== modified file 'src/server/compositor/default_display_buffer_compositor.h'
--- src/server/compositor/default_display_buffer_compositor.h 2014-01-22 10:03:11 +0000
+++ src/server/compositor/default_display_buffer_compositor.h 2014-03-17 15:02:33 +0000
@@ -44,7 +44,7 @@
44 std::shared_ptr<Renderer> const& renderer,44 std::shared_ptr<Renderer> const& renderer,
45 std::shared_ptr<CompositorReport> const& report);45 std::shared_ptr<CompositorReport> const& report);
4646
47 void composite() override;47 bool composite() override;
4848
49private:49private:
50 graphics::DisplayBuffer& display_buffer;50 graphics::DisplayBuffer& display_buffer;
@@ -53,6 +53,7 @@
53 std::shared_ptr<Renderer> const renderer;53 std::shared_ptr<Renderer> const renderer;
54 std::shared_ptr<CompositorReport> const report;54 std::shared_ptr<CompositorReport> const report;
5555
56 int size_of_last_pass = 0;
56 unsigned long local_frameno;57 unsigned long local_frameno;
57};58};
5859
5960
=== modified file 'src/server/compositor/default_display_buffer_compositor_factory.cpp'
--- src/server/compositor/default_display_buffer_compositor_factory.cpp 2014-01-31 05:10:46 +0000
+++ src/server/compositor/default_display_buffer_compositor_factory.cpp 2014-03-17 15:02:33 +0000
@@ -17,8 +17,8 @@
17 */17 */
1818
19#include "default_display_buffer_compositor_factory.h"19#include "default_display_buffer_compositor_factory.h"
20#include "renderer_factory.h"20#include "mir/compositor/renderer_factory.h"
21#include "renderer.h"21#include "mir/compositor/renderer.h"
22#include "mir/graphics/display_buffer.h"22#include "mir/graphics/display_buffer.h"
2323
24#include "default_display_buffer_compositor.h"24#include "default_display_buffer_compositor.h"
2525
=== modified file 'src/server/compositor/gl_renderer.cpp'
--- src/server/compositor/gl_renderer.cpp 2014-03-04 04:19:26 +0000
+++ src/server/compositor/gl_renderer.cpp 2014-03-17 15:02:33 +0000
@@ -15,11 +15,12 @@
15 * Authored By: Alexandros Frantzis <alexandros.frantzis@canonical.com>15 * Authored By: Alexandros Frantzis <alexandros.frantzis@canonical.com>
16 */16 */
1717
18#include "gl_renderer.h"18#include "mir/compositor/gl_renderer.h"
19#include "mir/compositor/compositing_criteria.h"
20#include "mir/compositor/buffer_stream.h"19#include "mir/compositor/buffer_stream.h"
20#include "mir/graphics/renderable.h"
21#include "mir/graphics/buffer.h"21#include "mir/graphics/buffer.h"
2222
23#define GLM_FORCE_RADIANS
23#include <glm/gtc/matrix_transform.hpp>24#include <glm/gtc/matrix_transform.hpp>
24#include <glm/gtc/type_ptr.hpp>25#include <glm/gtc/type_ptr.hpp>
2526
@@ -42,9 +43,13 @@
42 "uniform mat4 screen_to_gl_coords;\n"43 "uniform mat4 screen_to_gl_coords;\n"
43 "uniform mat4 display_transform;\n"44 "uniform mat4 display_transform;\n"
44 "uniform mat4 transform;\n"45 "uniform mat4 transform;\n"
46 "uniform vec2 centre;\n"
45 "varying vec2 v_texcoord;\n"47 "varying vec2 v_texcoord;\n"
46 "void main() {\n"48 "void main() {\n"
47 " gl_Position = display_transform * screen_to_gl_coords * transform * vec4(position, 1.0);\n"49 " vec4 mid = vec4(centre, 0.0, 0.0);\n"
50 " vec4 transformed = (transform * (vec4(position, 1.0) - mid)) + mid;\n"
51 " transformed.z = 0.0;\n" // avoid clipping while we lack depth/perspective
52 " gl_Position = display_transform * screen_to_gl_coords * transformed;\n"
48 " v_texcoord = texcoord;\n"53 " v_texcoord = texcoord;\n"
49 "}\n"54 "}\n"
50};55};
@@ -61,39 +66,6 @@
61 "}\n"66 "}\n"
62};67};
6368
64struct VertexAttributes
65{
66 glm::vec3 position;
67 glm::vec2 texcoord;
68};
69
70/*
71 * The texture coordinates are y-inverted to account for the difference in the
72 * texture and renderable pixel data row order. In particular, GL textures
73 * expect pixel data in rows starting from the bottom and moving up the image,
74 * whereas our renderables provide data in rows starting from the top and
75 * moving down the image.
76 */
77VertexAttributes vertex_attribs[4] =
78{
79 {
80 glm::vec3{-0.5f, -0.5f, 0.0f},
81 glm::vec2{0.0f, 0.0f}
82 },
83 {
84 glm::vec3{-0.5f, 0.5f, 0.0f},
85 glm::vec2{0.0f, 1.0f},
86 },
87 {
88 glm::vec3{0.5f, -0.5f, 0.0f},
89 glm::vec2{1.0f, 0.0f},
90 },
91 {
92 glm::vec3{0.5f, 0.5f, 0.0f},
93 glm::vec2{1.0f, 1.0f}
94 }
95};
96
97typedef void(*MirGLGetObjectInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *);69typedef void(*MirGLGetObjectInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *);
98typedef void(*MirGLGetObjectiv)(GLuint, GLenum, GLint *);70typedef void(*MirGLGetObjectiv)(GLuint, GLenum, GLint *);
9971
@@ -126,9 +98,9 @@
126 program(0),98 program(0),
127 position_attr_loc(0),99 position_attr_loc(0),
128 texcoord_attr_loc(0),100 texcoord_attr_loc(0),
101 centre_uniform_loc(0),
129 transform_uniform_loc(0),102 transform_uniform_loc(0),
130 alpha_uniform_loc(0),103 alpha_uniform_loc(0),
131 vertex_attribs_vbo(0),
132 rotation(NAN) // ensure the first set_rotation succeeds104 rotation(NAN) // ensure the first set_rotation succeeds
133{105{
134 /*106 /*
@@ -189,16 +161,10 @@
189 alpha_uniform_loc = glGetUniformLocation(program, "alpha");161 alpha_uniform_loc = glGetUniformLocation(program, "alpha");
190 position_attr_loc = glGetAttribLocation(program, "position");162 position_attr_loc = glGetAttribLocation(program, "position");
191 texcoord_attr_loc = glGetAttribLocation(program, "texcoord");163 texcoord_attr_loc = glGetAttribLocation(program, "texcoord");
164 centre_uniform_loc = glGetUniformLocation(program, "centre");
192165
193 glUniform1i(tex_loc, 0);166 glUniform1i(tex_loc, 0);
194167
195 /* Create VBO */
196 glGenBuffers(1, &vertex_attribs_vbo);
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches