Mir

Merge lp:~mterry/mir/missing-links into lp:mir/0.1

Proposed by Michael Terry
Status: Superseded
Proposed branch: lp:~mterry/mir/missing-links
Merge into: lp:mir/0.1
Diff against target: 16346 lines (+5940/-3362)
274 files modified
3rd_party/android-input/android/CMakeLists.txt (+2/-0)
3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp (+46/-92)
3rd_party/android-input/android/frameworks/base/services/input/EventHub.h (+6/-5)
CMakeLists.txt (+1/-1)
benchmarks/android-input/CMakeLists.txt (+3/-1)
cmake/MirCommon.cmake (+15/-4)
cmake/src/mir/CMakeLists.txt (+5/-0)
cmake/src/mir/fail_on_success.sh (+8/-0)
cmake/src/mir/mir_discover_gtest_tests.cpp (+15/-2)
debian/changelog (+22/-0)
debian/control (+3/-3)
debian/libmirserver18.install (+1/-1)
deploy-and-test.sh (+21/-0)
examples/demo-shell/demo_renderer.cpp (+271/-0)
examples/demo-shell/demo_renderer.h (+15/-0)
examples/render_overlays.cpp (+9/-7)
examples/render_surfaces.cpp (+19/-7)
include/platform/mir/graphics/display_buffer.h (+2/-3)
include/platform/mir/graphics/gl_config.h (+54/-0)
include/platform/mir/graphics/platform.h (+8/-1)
include/platform/mir/graphics/renderable.h (+20/-13)
include/platform/mir/options/default_configuration.h (+1/-0)
include/platform/mir/shared_library_loader.h (+28/-0)
include/server/mir/compositor/buffer_stream.h (+1/-1)
include/server/mir/compositor/gl_renderer.h (+27/-4)
include/server/mir/compositor/renderer.h (+2/-2)
include/server/mir/compositor/scene.h (+7/-4)
include/server/mir/default_server_configuration.h (+12/-8)
include/server/mir/frontend/display_changer.h (+0/-1)
include/server/mir/frontend/session_authorizer.h (+3/-1)
include/server/mir/input/surface.h (+1/-1)
include/server/mir/scene/surface.h (+59/-0)
include/server/mir/scene/surface_configurator.h (+4/-4)
include/server/mir/scene/surface_coordinator.h (+17/-12)
include/server/mir/scene/surface_event_source.h (+49/-0)
include/server/mir/scene/surface_factory.h (+14/-14)
include/server/mir/scene/surface_observer.h (+45/-0)
include/server/mir/scene/surface_ranker.h (+2/-2)
include/server/mir/shell/surface.h (+1/-3)
include/server/mir/shell/surface_factory.h (+6/-8)
include/shared/mir/geometry/length.h (+102/-0)
include/test/mir_test_doubles/fake_renderable.h (+5/-5)
include/test/mir_test_doubles/mock_buffer_bundle.h (+1/-1)
include/test/mir_test_doubles/mock_buffer_stream.h (+1/-1)
include/test/mir_test_doubles/mock_display_buffer.h (+1/-1)
include/test/mir_test_doubles/mock_display_changer.h (+0/-1)
include/test/mir_test_doubles/mock_display_device.h (+1/-1)
include/test/mir_test_doubles/mock_egl.h (+27/-0)
include/test/mir_test_doubles/mock_gl_config.h (+43/-0)
include/test/mir_test_doubles/mock_hwc_composer_device_1.h (+0/-105)
include/test/mir_test_doubles/mock_hwc_device_wrapper.h (+42/-0)
include/test/mir_test_doubles/mock_input_surface.h (+2/-2)
include/test/mir_test_doubles/mock_renderable.h (+12/-3)
include/test/mir_test_doubles/mock_scene.h (+6/-2)
include/test/mir_test_doubles/mock_surface.h (+14/-12)
include/test/mir_test_doubles/mock_surface_configurator.h (+4/-4)
include/test/mir_test_doubles/mock_surface_factory.h (+4/-3)
include/test/mir_test_doubles/mock_surface_ranker.h (+2/-2)
include/test/mir_test_doubles/null_display_buffer.h (+1/-1)
include/test/mir_test_doubles/null_display_changer.h (+0/-3)
include/test/mir_test_doubles/null_platform.h (+2/-1)
include/test/mir_test_doubles/null_surface_configurator.h (+4/-4)
include/test/mir_test_doubles/stub_buffer_stream.h (+1/-1)
include/test/mir_test_doubles/stub_display_builder.h (+1/-1)
include/test/mir_test_doubles/stub_display_device.h (+1/-1)
include/test/mir_test_doubles/stub_gl_config.h (+43/-0)
include/test/mir_test_doubles/stub_ipc_factory.h (+1/-1)
include/test/mir_test_doubles/stub_renderable.h (+2/-2)
include/test/mir_test_doubles/stub_session_authorizer.h (+4/-0)
include/test/mir_test_doubles/stub_surface_builder.h (+0/-69)
include/test/mir_test_doubles/stub_surface_ranker.h (+0/-44)
include/test/mir_test_framework/declarative_placement_strategy.h (+64/-0)
include/test/mir_test_framework/udev_environment.h (+1/-0)
src/client/default_connection_configuration.cpp (+1/-1)
src/client/lttng/input_receiver_report_tp.h (+1/-0)
src/client/lttng/rpc_report_tp.h (+1/-0)
src/client/mir_client_library.cpp (+11/-2)
src/client/rpc/mir_basic_rpc_channel.cpp (+3/-3)
src/client/rpc/mir_basic_rpc_channel.h (+4/-3)
src/client/rpc/mir_socket_rpc_channel.cpp (+41/-32)
src/client/rpc/mir_socket_rpc_channel.h (+3/-1)
src/platform/CMakeLists.txt (+2/-1)
src/platform/graphics/android/CMakeLists.txt (+4/-0)
src/platform/graphics/android/android_display.cpp (+2/-1)
src/platform/graphics/android/android_display.h (+2/-0)
src/platform/graphics/android/android_platform.cpp (+37/-4)
src/platform/graphics/android/android_platform.h (+2/-1)
src/platform/graphics/android/display_buffer.cpp (+1/-1)
src/platform/graphics/android/display_buffer.h (+1/-1)
src/platform/graphics/android/display_device.h (+1/-1)
src/platform/graphics/android/fb_device.cpp (+1/-1)
src/platform/graphics/android/fb_device.h (+1/-1)
src/platform/graphics/android/gl_context.cpp (+17/-10)
src/platform/graphics/android/gl_context.h (+4/-1)
src/platform/graphics/android/hwc_common_device.cpp (+2/-2)
src/platform/graphics/android/hwc_common_device.h (+2/-1)
src/platform/graphics/android/hwc_device.cpp (+2/-1)
src/platform/graphics/android/hwc_device.h (+2/-15)
src/platform/graphics/android/hwc_fb_device.cpp (+12/-17)
src/platform/graphics/android/hwc_fb_device.h (+5/-1)
src/platform/graphics/android/hwc_formatted_logger.cpp (+177/-0)
src/platform/graphics/android/hwc_formatted_logger.h (+41/-0)
src/platform/graphics/android/hwc_layerlist.cpp (+4/-4)
src/platform/graphics/android/hwc_layerlist.h (+2/-2)
src/platform/graphics/android/hwc_logger.h (+46/-0)
src/platform/graphics/android/hwc_wrapper.h (+47/-0)
src/platform/graphics/android/real_hwc_wrapper.cpp (+11/-2)
src/platform/graphics/android/real_hwc_wrapper.h (+6/-3)
src/platform/graphics/android/resource_factory.cpp (+35/-2)
src/platform/graphics/android/resource_factory.h (+4/-0)
src/platform/graphics/mesa/display.cpp (+13/-3)
src/platform/graphics/mesa/display.h (+5/-2)
src/platform/graphics/mesa/display_buffer.cpp (+3/-1)
src/platform/graphics/mesa/display_buffer.h (+3/-1)
src/platform/graphics/mesa/display_helpers.cpp (+15/-3)
src/platform/graphics/mesa/display_helpers.h (+5/-5)
src/platform/graphics/mesa/platform.cpp (+11/-1)
src/platform/graphics/mesa/platform.h (+2/-1)
src/platform/options/default_configuration.cpp (+32/-3)
src/platform/shared_library_loader.cpp (+38/-0)
src/server/CMakeLists.txt (+1/-1)
src/server/compositor/buffer_bundle.h (+13/-1)
src/server/compositor/buffer_stream_surfaces.cpp (+2/-2)
src/server/compositor/buffer_stream_surfaces.h (+1/-1)
src/server/compositor/bypass.cpp (+6/-1)
src/server/compositor/default_display_buffer_compositor.cpp (+32/-57)
src/server/compositor/default_display_buffer_compositor.h (+1/-2)
src/server/compositor/gl_renderer.cpp (+68/-22)
src/server/compositor/occlusion.cpp (+28/-16)
src/server/compositor/occlusion.h (+2/-24)
src/server/compositor/rendering_operator.cpp (+5/-11)
src/server/compositor/rendering_operator.h (+3/-7)
src/server/compositor/screencast_display_buffer.cpp (+1/-1)
src/server/compositor/screencast_display_buffer.h (+1/-1)
src/server/compositor/switching_bundle.cpp (+6/-3)
src/server/compositor/switching_bundle.h (+3/-4)
src/server/compositor/temporary_buffers.cpp (+2/-2)
src/server/compositor/temporary_buffers.h (+1/-1)
src/server/default_server_configuration.cpp (+11/-6)
src/server/frontend/CMakeLists.txt (+1/-0)
src/server/frontend/default_configuration.cpp (+23/-7)
src/server/frontend/event_sender.cpp (+1/-1)
src/server/frontend/message_receiver.h (+3/-1)
src/server/frontend/message_sender.h (+2/-2)
src/server/frontend/protobuf_ipc_factory.h (+1/-2)
src/server/frontend/protobuf_responder.cpp (+9/-8)
src/server/frontend/protobuf_responder.h (+1/-1)
src/server/frontend/protobuf_session_creator.cpp (+1/-2)
src/server/frontend/session_mediator.cpp (+0/-6)
src/server/frontend/socket_messenger.cpp (+29/-14)
src/server/frontend/socket_messenger.h (+4/-3)
src/server/frontend/socket_session.cpp (+16/-9)
src/server/frontend/socket_session.h (+3/-2)
src/server/frontend/unauthorized_display_changer.cpp (+0/-5)
src/server/frontend/unauthorized_display_changer.h (+0/-2)
src/server/frontend/unauthorized_screencast.cpp (+46/-0)
src/server/frontend/unauthorized_screencast.h (+44/-0)
src/server/graphics/default_configuration.cpp (+20/-21)
src/server/graphics/nested/nested_display.cpp (+11/-4)
src/server/graphics/nested/nested_display.h (+6/-2)
src/server/graphics/nested/nested_output.cpp (+1/-1)
src/server/graphics/nested/nested_output.h (+1/-1)
src/server/graphics/nested/nested_platform.cpp (+5/-2)
src/server/graphics/nested/nested_platform.h (+2/-1)
src/server/graphics/offscreen/display_buffer.cpp (+1/-1)
src/server/graphics/offscreen/display_buffer.h (+1/-1)
src/server/mirserver.pc.in (+1/-1)
src/server/scene/CMakeLists.txt (+1/-2)
src/server/scene/application_session.cpp (+10/-2)
src/server/scene/basic_surface.cpp (+193/-27)
src/server/scene/basic_surface.h (+73/-26)
src/server/scene/default_configuration.cpp (+18/-27)
src/server/scene/mediating_display_changer.cpp (+0/-23)
src/server/scene/mediating_display_changer.h (+0/-2)
src/server/scene/mutable_surface_state.h (+0/-52)
src/server/scene/surface_allocator.cpp (+8/-4)
src/server/scene/surface_allocator.h (+8/-4)
src/server/scene/surface_controller.cpp (+23/-13)
src/server/scene/surface_controller.h (+16/-15)
src/server/scene/surface_event_source.cpp (+62/-0)
src/server/scene/surface_impl.cpp (+0/-273)
src/server/scene/surface_impl.h (+0/-114)
src/server/scene/surface_source.cpp (+0/-47)
src/server/scene/surface_source.h (+0/-64)
src/server/scene/surface_stack.cpp (+23/-34)
src/server/scene/surface_stack.h (+19/-19)
src/server/scene/surface_stack_model.h (+13/-6)
src/server/shell/default_configuration.cpp (+1/-1)
src/server/shell/default_focus_mechanism.cpp (+3/-1)
src/server/shell/organising_surface_factory.cpp (+29/-10)
src/server/shell/organising_surface_factory.h (+9/-6)
src/shared/sharedlibrary/CMakeLists.txt (+5/-0)
tests/CMakeLists.txt (+3/-10)
tests/acceptance-tests/test_client_authorization.cpp (+3/-0)
tests/acceptance-tests/test_client_input.cpp (+33/-70)
tests/acceptance-tests/test_client_screencast.cpp (+50/-0)
tests/acceptance-tests/test_display_configuration.cpp (+5/-4)
tests/acceptance-tests/test_protobuf.cpp (+5/-0)
tests/acceptance-tests/test_server_disconnect.cpp (+2/-0)
tests/acceptance-tests/test_shell_control_of_surface_configuration.cpp (+6/-6)
tests/acceptance-tests/test_surfaces_with_output_id.cpp (+7/-1)
tests/integration-tests/compositor/test_buffer_stream.cpp (+21/-21)
tests/integration-tests/compositor/test_swapping_swappers.cpp (+2/-4)
tests/integration-tests/graphics/android/test_display_integration.cpp (+9/-6)
tests/integration-tests/graphics/android/test_internal_client.cpp (+7/-7)
tests/integration-tests/graphics/mesa/test_buffer_integration.cpp (+4/-1)
tests/integration-tests/test_display_info.cpp (+2/-1)
tests/integration-tests/test_session_manager.cpp (+1/-1)
tests/integration-tests/test_surfaceloop.cpp (+4/-2)
tests/integration-tests/test_swapinterval.cpp (+1/-1)
tests/mir_test_framework/CMakeLists.txt (+10/-11)
tests/mir_test_framework/declarative_placement_strategy.cpp (+58/-0)
tests/mir_test_framework/stubbed_server_configuration.cpp (+2/-1)
tests/mir_test_framework/udev_environment.cpp (+22/-2)
tests/mir_test_framework/udev_recordings/bluetooth-magic-trackpad.ioctl (+21/-0)
tests/mir_test_framework/udev_recordings/bluetooth-magic-trackpad.umockdev (+222/-0)
tests/mir_test_framework/udev_recordings/laptop-keyboard.ioctl (+12/-0)
tests/mir_test_framework/udev_recordings/laptop-keyboard.umockdev (+74/-0)
tests/mir_test_framework/udev_recordings/synaptics-touchpad.ioctl (+29/-0)
tests/mir_test_framework/udev_recordings/synaptics-touchpad.umockdev (+65/-0)
tests/mir_test_framework/udev_recordings/usb-keyboard.ioctl (+13/-0)
tests/mir_test_framework/udev_recordings/usb-keyboard.umockdev (+244/-0)
tests/mir_test_framework/udev_recordings/usb-mouse.ioctl (+14/-0)
tests/mir_test_framework/udev_recordings/usb-mouse.umockdev (+240/-0)
tests/mir_test_framework/using_stub_client_platform.cpp (+11/-2)
tests/unit-tests/CMakeLists.txt (+5/-14)
tests/unit-tests/android_input/CMakeLists.txt (+1/-0)
tests/unit-tests/android_input/test_eventhub.cpp (+125/-0)
tests/unit-tests/client/test_mir_connection.cpp (+6/-0)
tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp (+348/-444)
tests/unit-tests/compositor/test_gl_renderer.cpp (+21/-2)
tests/unit-tests/compositor/test_multi_threaded_compositor.cpp (+5/-2)
tests/unit-tests/compositor/test_occlusion.cpp (+123/-81)
tests/unit-tests/compositor/test_rendering_operator.cpp (+15/-15)
tests/unit-tests/compositor/test_switching_bundle.cpp (+69/-51)
tests/unit-tests/frontend/test_event_sender.cpp (+7/-7)
tests/unit-tests/frontend/test_session_mediator.cpp (+4/-5)
tests/unit-tests/frontend/test_socket_session.cpp (+43/-14)
tests/unit-tests/geometry/CMakeLists.txt (+1/-0)
tests/unit-tests/geometry/test-length.cpp (+124/-0)
tests/unit-tests/graphics/android/CMakeLists.txt (+1/-0)
tests/unit-tests/graphics/android/hwc_struct_helpers.h (+8/-0)
tests/unit-tests/graphics/android/test_android_fb.cpp (+64/-31)
tests/unit-tests/graphics/android/test_hwc_common_device.cpp (+3/-1)
tests/unit-tests/graphics/android/test_hwc_device.cpp (+5/-9)
tests/unit-tests/graphics/android/test_hwc_display.cpp (+6/-1)
tests/unit-tests/graphics/android/test_hwc_fb_device.cpp (+44/-74)
tests/unit-tests/graphics/android/test_hwc_logger.cpp (+132/-0)
tests/unit-tests/graphics/android/test_hwc_wrapper.cpp (+28/-7)
tests/unit-tests/graphics/android/test_output_builder.cpp (+4/-1)
tests/unit-tests/graphics/android/test_resource_factory.cpp (+5/-4)
tests/unit-tests/graphics/mesa/test_display.cpp (+41/-8)
tests/unit-tests/graphics/mesa/test_display_buffer.cpp (+12/-0)
tests/unit-tests/graphics/mesa/test_display_configuration.cpp (+4/-2)
tests/unit-tests/graphics/mesa/test_display_multi_monitor.cpp (+7/-4)
tests/unit-tests/graphics/mesa/test_internal_native_display.cpp (+0/-4)
tests/unit-tests/graphics/mesa/test_internal_native_surface.cpp (+0/-3)
tests/unit-tests/graphics/nested/CMakeLists.txt (+1/-0)
tests/unit-tests/graphics/nested/test_nested_display.cpp (+27/-0)
tests/unit-tests/graphics/test_display.cpp (+4/-2)
tests/unit-tests/input/android/test_android_input_application_handle.cpp (+1/-1)
tests/unit-tests/input/android/test_android_input_registrar.cpp (+2/-3)
tests/unit-tests/input/android/test_android_input_window_handle.cpp (+18/-11)
tests/unit-tests/scene/test_application_session.cpp (+12/-14)
tests/unit-tests/scene/test_basic_surface.cpp (+124/-106)
tests/unit-tests/scene/test_default_focus_mechanism.cpp (+23/-40)
tests/unit-tests/scene/test_session_manager.cpp (+19/-17)
tests/unit-tests/scene/test_surface.cpp (+73/-31)
tests/unit-tests/scene/test_surface_controller.cpp (+36/-14)
tests/unit-tests/scene/test_surface_impl.cpp (+117/-209)
tests/unit-tests/scene/test_surface_stack.cpp (+143/-317)
tests/unit-tests/shell/test_organising_surface_factory.cpp (+24/-16)
tools/valgrind_suppressions_armhf (+30/-0)
tools/valgrind_suppressions_generic (+7/-0)
To merge this branch: bzr merge lp:~mterry/mir/missing-links
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+213905@code.launchpad.net

Commit message

Add some missing library link lines to mirplatformgraphicsandroid.

Description of the change

Add some missing library link lines to mirplatformgraphicsandroid.

These were causing crashes in unity8 for me. You can see that dpkg-shlibs will actually warn about these missing libraries with something like: "symbol X used by Y found in none of the libraries."

But there is no way to make that an error, which would help avoid these problems in the future. See Debian bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=644791

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '3rd_party/android-input/android/CMakeLists.txt'
2--- 3rd_party/android-input/android/CMakeLists.txt 2014-03-06 06:05:17 +0000
3+++ 3rd_party/android-input/android/CMakeLists.txt 2014-04-02 18:58:27 +0000
4@@ -7,6 +7,7 @@
5 system/extras/ext4_utils
6
7 ${PROJECT_SOURCE_DIR}/include/server
8+ ${PROJECT_SOURCE_DIR}/include/platform
9 )
10
11 add_definitions(
12@@ -64,6 +65,7 @@
13 target_link_libraries(
14 android-input
15
16+ mirplatform
17 ${Boost_LIBRARIES}
18 )
19
20
21=== modified file '3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp'
22--- 3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp 2013-10-03 05:12:59 +0000
23+++ 3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp 2014-04-02 18:58:27 +0000
24@@ -205,34 +205,34 @@
25
26 // --- EventHub ---
27
28-const uint32_t EventHub::EPOLL_ID_INOTIFY;
29+const uint32_t EventHub::EPOLL_ID_UDEV;
30 const uint32_t EventHub::EPOLL_ID_WAKE;
31 const int EventHub::EPOLL_SIZE_HINT;
32 const int EventHub::EPOLL_MAX_EVENTS;
33
34 EventHub::EventHub(std::shared_ptr<mi::InputReport> const& input_report) :
35 input_report(input_report),
36+ device_listener{mir::udev::Context()},
37 mBuiltInKeyboardId(NO_BUILT_IN_KEYBOARD), mNextDeviceId(1),
38 mOpeningDevices(0), mClosingDevices(0),
39 mNeedToSendFinishedDeviceScan(false),
40 mNeedToReopenDevices(false), mNeedToScanDevices(true),
41- mPendingEventCount(0), mPendingEventIndex(0), mPendingINotify(false) {
42+ mPendingEventCount(0), mPendingEventIndex(0), mPendingUdevEvent(false) {
43 acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID);
44
45 mEpollFd = epoll_create(EPOLL_SIZE_HINT);
46 LOG_ALWAYS_FATAL_IF(mEpollFd < 0, "Could not create epoll instance. errno=%d", errno);
47
48- mINotifyFd = inotify_init();
49- int result = inotify_add_watch(mINotifyFd, DEVICE_PATH, IN_DELETE | IN_CREATE | IN_ATTRIB);
50- LOG_ALWAYS_FATAL_IF(result < 0, "Could not register INotify for %s. errno=%d",
51- DEVICE_PATH, errno);
52+ device_listener.filter_by_subsystem("input");
53+ device_listener.enable();
54+
55
56 struct epoll_event eventItem;
57 memset(&eventItem, 0, sizeof(eventItem));
58 eventItem.events = EPOLLIN;
59- eventItem.data.u32 = EPOLL_ID_INOTIFY;
60- result = epoll_ctl(mEpollFd, EPOLL_CTL_ADD, mINotifyFd, &eventItem);
61- LOG_ALWAYS_FATAL_IF(result != 0, "Could not add INotify to epoll instance. errno=%d", errno);
62+ eventItem.data.u32 = EPOLL_ID_UDEV;
63+ int result = epoll_ctl(mEpollFd, EPOLL_CTL_ADD, device_listener.fd(), &eventItem);
64+ LOG_ALWAYS_FATAL_IF(result != 0, "Could not add Udev monitor to epoll instance. errno=%d", errno);
65
66 int wakeFds[2];
67 result = pipe(wakeFds);
68@@ -265,7 +265,6 @@
69 }
70
71 ::close(mEpollFd);
72- ::close(mINotifyFd);
73 ::close(mWakeReadPipeFd);
74 ::close(mWakeWritePipeFd);
75
76@@ -730,9 +729,9 @@
77 bool deviceChanged = false;
78 while (mPendingEventIndex < mPendingEventCount) {
79 const struct epoll_event& eventItem = mPendingEventItems[mPendingEventIndex++];
80- if (eventItem.data.u32 == EPOLL_ID_INOTIFY) {
81+ if (eventItem.data.u32 == EPOLL_ID_UDEV) {
82 if (eventItem.events & EPOLLIN) {
83- mPendingINotify = true;
84+ mPendingUdevEvent = true;
85 } else {
86 ALOGW("Received unexpected epoll event 0x%08x for INotify.", eventItem.events);
87 }
88@@ -839,9 +838,9 @@
89 // readNotify() will modify the list of devices so this must be done after
90 // processing all other events to ensure that we read all remaining events
91 // before closing the devices.
92- if (mPendingINotify && mPendingEventIndex >= mPendingEventCount) {
93- mPendingINotify = false;
94- readNotifyLocked();
95+ if (mPendingUdevEvent && mPendingEventIndex >= mPendingEventCount) {
96+ mPendingUdevEvent = false;
97+ handleUdevEventsLocked();
98 deviceChanged = true;
99 }
100
101@@ -916,15 +915,44 @@
102 }
103
104 void EventHub::scanDevicesLocked() {
105- status_t res = scanDirLocked(DEVICE_PATH);
106- if(res < 0) {
107- ALOGE("scan dir failed for %s\n", DEVICE_PATH);
108+ mir::udev::Enumerator input_enumerator{std::make_shared<mir::udev::Context>()};
109+
110+ input_enumerator.match_subsystem("input");
111+ input_enumerator.scan_devices();
112+
113+ for (auto& device : input_enumerator)
114+ {
115+ if (device.devnode() != nullptr)
116+ {
117+ openDeviceLocked(device.devnode());
118+ }
119 }
120+
121 if (mDevices.indexOfKey(VIRTUAL_KEYBOARD_ID) < 0) {
122 createVirtualKeyboardLocked();
123 }
124 }
125
126+void EventHub::handleUdevEventsLocked()
127+{
128+ device_listener.process_events([this](mir::udev::Monitor::EventType type, mir::udev::Device const& dev){
129+ if (type == mir::udev::Monitor::ADDED)
130+ {
131+ if (dev.devnode() != nullptr)
132+ {
133+ openDeviceLocked(dev.devnode());
134+ }
135+ }
136+ else if (type == mir::udev::Monitor::REMOVED)
137+ {
138+ if (dev.devnode() != nullptr)
139+ {
140+ closeDeviceByPathLocked(dev.devnode());
141+ }
142+ }
143+ });
144+}
145+
146 // ----------------------------------------------------------------------------
147
148 static bool containsNonZeroByte(const uint8_t* array, uint32_t startIndex, uint32_t endIndex) {
149@@ -1391,80 +1419,6 @@
150 }
151 }
152
153-status_t EventHub::readNotifyLocked() {
154- int res;
155- char devname[PATH_MAX];
156- char *filename;
157- char event_buf[512];
158- int event_size;
159- int event_pos = 0;
160- struct inotify_event *event;
161-
162- ALOGV("EventHub::readNotify nfd: %d\n", mINotifyFd);
163- res = read(mINotifyFd, event_buf, sizeof(event_buf));
164- if(res < (int)sizeof(*event)) {
165- if(errno == EINTR)
166- return 0;
167- ALOGW("could not get event, %s\n", strerror(errno));
168- return -1;
169- }
170- //printf("got %d bytes of event information\n", res);
171-
172- strcpy(devname, DEVICE_PATH);
173- filename = devname + strlen(devname);
174- *filename++ = '/';
175-
176- while(res >= (int)sizeof(*event)) {
177- event = (struct inotify_event *)(event_buf + event_pos);
178- //printf("%d: %08x \"%s\"\n", event->wd, event->mask, event->len ? event->name : "");
179- if(event->len) {
180- strcpy(filename, event->name);
181- if(event->mask & IN_CREATE) {
182- openDeviceLocked(devname);
183- } else if (event->mask & IN_ATTRIB) {
184- Device* device = getDeviceByPathLocked(devname);
185- if (!device) {
186- ALOGI("Retry opening device file %s", devname);
187- // file permissions might have changed, making the device readable now
188- // let's retry opening it
189- openDeviceLocked(devname);
190- }
191- } else {
192- ALOGI("Removing device '%s' due to inotify event\n", devname);
193- closeDeviceByPathLocked(devname);
194- }
195- }
196- event_size = sizeof(*event) + event->len;
197- res -= event_size;
198- event_pos += event_size;
199- }
200- return 0;
201-}
202-
203-status_t EventHub::scanDirLocked(const char *dirname)
204-{
205- char devname[PATH_MAX];
206- char *filename;
207- DIR *dir;
208- struct dirent *de;
209- dir = opendir(dirname);
210- if(dir == NULL)
211- return -1;
212- strcpy(devname, dirname);
213- filename = devname + strlen(devname);
214- *filename++ = '/';
215- while((de = readdir(dir))) {
216- if(de->d_name[0] == '.' &&
217- (de->d_name[1] == '\0' ||
218- (de->d_name[1] == '.' && de->d_name[2] == '\0')))
219- continue;
220- strcpy(filename, de->d_name);
221- openDeviceLocked(devname);
222- }
223- closedir(dir);
224- return 0;
225-}
226-
227 void EventHub::requestReopenDevices() {
228 ALOGV("requestReopenDevices() called");
229
230
231=== modified file '3rd_party/android-input/android/frameworks/base/services/input/EventHub.h'
232--- 3rd_party/android-input/android/frameworks/base/services/input/EventHub.h 2013-10-03 05:12:59 +0000
233+++ 3rd_party/android-input/android/frameworks/base/services/input/EventHub.h 2014-04-02 18:58:27 +0000
234@@ -18,6 +18,8 @@
235 #ifndef _RUNTIME_EVENT_HUB_H
236 #define _RUNTIME_EVENT_HUB_H
237
238+#include "mir/udev/wrapper.h"
239+
240 #include <androidfw/Input.h>
241 #include <androidfw/InputDevice.h>
242 #include <androidfw/Keyboard.h>
243@@ -366,9 +368,8 @@
244 void closeDeviceLocked(Device* device);
245 void closeAllDevicesLocked();
246
247- status_t scanDirLocked(const char *dirname);
248 void scanDevicesLocked();
249- status_t readNotifyLocked();
250+ void handleUdevEventsLocked();
251
252 Device* getDeviceLocked(int32_t deviceId) const;
253 Device* getDeviceByPathLocked(const char* devicePath) const;
254@@ -407,12 +408,12 @@
255 Vector<String8> mExcludedDevices;
256
257 int mEpollFd;
258- int mINotifyFd;
259+ mir::udev::Monitor device_listener;
260 int mWakeReadPipeFd;
261 int mWakeWritePipeFd;
262
263 // Ids used for epoll notifications not associated with devices.
264- static const uint32_t EPOLL_ID_INOTIFY = 0x80000001;
265+ static const uint32_t EPOLL_ID_UDEV = 0x80000001;
266 static const uint32_t EPOLL_ID_WAKE = 0x80000002;
267
268 // Epoll FD list size hint.
269@@ -425,7 +426,7 @@
270 struct epoll_event mPendingEventItems[EPOLL_MAX_EVENTS];
271 size_t mPendingEventCount;
272 size_t mPendingEventIndex;
273- bool mPendingINotify;
274+ bool mPendingUdevEvent;
275 };
276
277 // Made available to test
278
279=== modified file 'CMakeLists.txt'
280--- CMakeLists.txt 2014-03-06 06:05:17 +0000
281+++ CMakeLists.txt 2014-04-02 18:58:27 +0000
282@@ -28,7 +28,7 @@
283
284 set(MIR_VERSION_MAJOR 0)
285 set(MIR_VERSION_MINOR 1)
286-set(MIR_VERSION_PATCH 7)
287+set(MIR_VERSION_PATCH 8)
288
289 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
290 execute_process(
291
292=== modified file 'benchmarks/android-input/CMakeLists.txt'
293--- benchmarks/android-input/CMakeLists.txt 2013-10-15 10:10:05 +0000
294+++ benchmarks/android-input/CMakeLists.txt 2014-04-02 18:58:27 +0000
295@@ -5,7 +5,9 @@
296 )
297
298 include_directories(
299- ${Mir_SOURCE_DIR}/include/test)
300+ ${Mir_SOURCE_DIR}/include/test
301+ ${Mir_SOURCE_DIR}/include/platform
302+)
303
304 add_executable(input-reader-perf ${SOURCES})
305
306
307=== modified file 'cmake/MirCommon.cmake'
308--- cmake/MirCommon.cmake 2014-03-06 06:05:17 +0000
309+++ cmake/MirCommon.cmake 2014-04-02 18:58:27 +0000
310@@ -22,8 +22,10 @@
311 valgrind)
312
313 if(VALGRIND_EXECUTABLE)
314- set(VALGRIND_ARGS "--error-exitcode=1" "--trace-children=yes")
315+ set(VALGRIND_ARGS "--error-exitcode=1" "--trace-children=yes" "--leak-check=full" "--show-leak-kinds=definite" "--errors-for-leak-kinds=definite")
316+ set(VALGRIND_ARGS ${VALGRIND_ARGS} "--suppressions=${CMAKE_SOURCE_DIR}/tools/valgrind_suppressions_generic")
317 set(DISCOVER_FLAGS "--enable-memcheck")
318+ set(DISCOVER_FLAGS ${DISCOVER_FLAGS} "--suppressions=${CMAKE_SOURCE_DIR}/tools/valgrind_suppressions_generic")
319 if (TARGET_ARCH STREQUAL "arm-linux-gnueabihf")
320 set(VALGRIND_ARGS ${VALGRIND_ARGS} "--suppressions=${CMAKE_SOURCE_DIR}/tools/valgrind_suppressions_armhf")
321 set(DISCOVER_FLAGS ${DISCOVER_FLAGS} "--suppressions=${CMAKE_SOURCE_DIR}/tools/valgrind_suppressions_armhf")
322@@ -35,10 +37,11 @@
323
324 function (mir_discover_tests EXECUTABLE)
325 if(DISABLE_GTEST_TEST_DISCOVERY)
326- add_test(${EXECUTABLE} ${VALGRIND_EXECUTABLE} ${VALGRIND_ARGS} "${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE}")
327-
328+ add_test(${EXECUTABLE} ${VALGRIND_EXECUTABLE} ${VALGRIND_ARGS} ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE} "--gtest_filter=-*DeathTest.*")
329+ add_test(${EXECUTABLE}_death_tests ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE} "--gtest_filter=*DeathTest.*")
330 if (${ARGC} GREATER 1)
331 set_property(TEST ${EXECUTABLE} PROPERTY ENVIRONMENT ${ARGN})
332+ set_property(TEST ${EXECUTABLE}_death_tests PROPERTY ENVIRONMENT ${ARGN})
333 endif()
334 else()
335 set(CHECK_TEST_DISCOVERY_TARGET_NAME "check_discover_tests_in_${EXECUTABLE}")
336@@ -82,7 +85,15 @@
337 function (mir_add_memcheck_test)
338 if (ENABLE_MEMCHECK_OPTION)
339 if(DISABLE_GTEST_TEST_DISCOVERY)
340- ADD_TEST("memcheck-test" "sh" "-c" "${VALGRIND_EXECUTABLE} ${VALGRIND_ARGS} ${CMAKE_BINARY_DIR}/mir_gtest/mir_test_memory_error; if [ $? != 0 ]; then exit 0; else exit 1; fi")
341+ add_custom_target(
342+ memcheck_test ALL
343+ )
344+ ADD_TEST("memcheck-test" ${CMAKE_BINARY_DIR}/mir_gtest/fail_on_success.sh ${VALGRIND_EXECUTABLE} ${VALGRIND_ARGS} ${CMAKE_BINARY_DIR}/mir_gtest/mir_test_memory_error)
345+ add_dependencies(
346+ memcheck_test
347+
348+ mir_test_memory_error
349+ )
350 else()
351 add_custom_target(
352 memcheck_test ALL
353
354=== modified file 'cmake/src/mir/CMakeLists.txt'
355--- cmake/src/mir/CMakeLists.txt 2013-03-13 04:54:15 +0000
356+++ cmake/src/mir/CMakeLists.txt 2014-04-02 18:58:27 +0000
357@@ -17,3 +17,8 @@
358 mir_test_memory_error PROPERTIES
359 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/mir_gtest
360 )
361+
362+file(INSTALL ${CMAKE_CURRENT_SOURCE_DIR}/fail_on_success.sh
363+ DESTINATION ${CMAKE_BINARY_DIR}/mir_gtest
364+ USE_SOURCE_PERMISSIONS
365+)
366
367=== added file 'cmake/src/mir/fail_on_success.sh'
368--- cmake/src/mir/fail_on_success.sh 1970-01-01 00:00:00 +0000
369+++ cmake/src/mir/fail_on_success.sh 2014-04-02 18:58:27 +0000
370@@ -0,0 +1,8 @@
371+#!/bin/sh
372+
373+$@
374+
375+if [ $? -eq 0 ] ; then
376+ exit 1;
377+fi
378+exit 0;
379
380=== modified file 'cmake/src/mir/mir_discover_gtest_tests.cpp'
381--- cmake/src/mir/mir_discover_gtest_tests.cpp 2014-03-06 06:05:17 +0000
382+++ cmake/src/mir/mir_discover_gtest_tests.cpp 2014-04-02 18:58:27 +0000
383@@ -234,6 +234,18 @@
384 }
385 }
386
387+bool is_death_test(string const& test)
388+{
389+ // precondition: test will match Foo.*
390+ // assumption: death tests will match FooDeathTest.*
391+ bool death_test = false;
392+ if (test.size() > strlen("DeathTest.*"))
393+ death_test = test.substr(test.size() - strlen("DeathTest.*"),
394+ strlen("DeathTest")) == "DeathTest";
395+
396+ return death_test;
397+}
398+
399 int main (int argc, char **argv)
400 {
401 int output_width = get_output_width();
402@@ -291,8 +303,9 @@
403 snprintf(
404 cmd_line,
405 sizeof(cmd_line),
406- config.enable_memcheck ? memcheck_cmd_line_pattern(config.suppressions).c_str() :
407- ordinary_cmd_line_pattern().c_str(),
408+ (config.enable_memcheck && !is_death_test(*test)) ?
409+ memcheck_cmd_line_pattern(config.suppressions).c_str() :
410+ ordinary_cmd_line_pattern().c_str(),
411 test_suite.c_str(),
412 elide_string_left(*test, output_width/2).c_str(),
413 config.executable,
414
415=== modified file 'debian/changelog'
416--- debian/changelog 2014-03-18 18:38:01 +0000
417+++ debian/changelog 2014-04-02 18:58:27 +0000
418@@ -1,3 +1,25 @@
419+mir (0.1.8-0ubuntu1) UNRELEASED; urgency=medium
420+
421+ * New upstream release 0.1.8 (https://launchpad.net/mir/+milestone/0.1.8)
422+ - mirserver ABI bumped to 18.
423+ - mirclient ABI unchanged, still at 7. Clients do not need rebuilding.
424+ - Server API changes affecting shells:
425+ . GLRenderer::tessellate() changed syntax.
426+ - Switch EventHub device enumeration and hotplug to Udev. NOTE! This means
427+ mir_test_* can't run natively on touch devices any more without some
428+ preparation first:
429+ sudo mount -o remount,rw /
430+ sudo apt-get update
431+ sudo apt-get install -y umockdev
432+ - Added logging for HWC events.
433+ - Continued consolidation of Surface classes toward a simpler architecture.
434+ - Added some decorations to demo-shell; shadows and basic title bars, all
435+ anti-aliased and high-DPI-scalable.
436+ - Bugs fixed:
437+ . TODO (during merge proposal to distro)
438+
439+ -- Daniel van Vugt <daniel.van.vugt@canonical.com> Thu, 20 Mar 2014 14:05:25 +0800
440+
441 mir (0.1.7+14.04.20140318-0ubuntu1) trusty; urgency=low
442
443 [ Alberto Aguirre ]
444
445=== modified file 'debian/control'
446--- debian/control 2014-03-17 07:35:22 +0000
447+++ debian/control 2014-04-02 18:58:27 +0000
448@@ -31,7 +31,7 @@
449 libgoogle-glog-dev,
450 liblttng-ust-dev,
451 libxkbcommon-dev,
452- libumockdev-dev,
453+ libumockdev-dev (>= 0.6),
454 umockdev,
455 libudev-dev,
456 google-mock (>= 1.6.0+svn437),
457@@ -70,7 +70,7 @@
458 .
459 Contains the protocol's definition files.
460
461-Package: libmirserver17
462+Package: libmirserver18
463 Section: libs
464 Architecture: i386 amd64 armhf arm64
465 Multi-Arch: same
466@@ -148,7 +148,7 @@
467 Architecture: i386 amd64 armhf arm64
468 Multi-Arch: same
469 Pre-Depends: ${misc:Pre-Depends}
470-Depends: libmirserver17 (= ${binary:Version}),
471+Depends: libmirserver18 (= ${binary:Version}),
472 libmirprotobuf-dev (= ${binary:Version}),
473 mircommon-dev (= ${binary:Version}),
474 libglm-dev,
475
476=== renamed file 'debian/libmirserver17.install' => 'debian/libmirserver18.install'
477--- debian/libmirserver17.install 2014-03-12 06:41:13 +0000
478+++ debian/libmirserver18.install 2014-04-02 18:58:27 +0000
479@@ -1,1 +1,1 @@
480-usr/lib/*/libmirserver.so.17
481+usr/lib/*/libmirserver.so.18
482
483=== added file 'deploy-and-test.sh'
484--- deploy-and-test.sh 1970-01-01 00:00:00 +0000
485+++ deploy-and-test.sh 2014-04-02 18:58:27 +0000
486@@ -0,0 +1,21 @@
487+#!/bin/sh
488+
489+if [ ! -d build-android-arm ] ; then
490+ echo "Built tree not found in $(pwd)/build-android-arm"
491+ exit 1
492+fi
493+
494+# Unpack umockdev requirements
495+( cd build-android-arm ;
496+ apt-get download umockdev:armhf libumockdev0:armhf ;
497+ dpkg -x umockdev_*armhf*.deb . ;
498+ dpkg -x libumockdev0_*armhf*.deb .
499+)
500+
501+adb push build-android-arm/bin /home/phablet/mir/bin
502+adb push build-android-arm/lib /home/phablet/mir/lib
503+adb push build-android-arm/usr /home/phablet/mir/usr
504+
505+adb shell "LD_LIBRARY_PATH=/home/phablet/mir/usr/lib/arm-linux-gnueabihf/:/home/phablet/mir/lib PATH=$PATH:/home/phablet/mir/usr/bin bash -c \"cd /home/phablet/mir/usr/bin ; umockdev-run /home/phablet/mir/bin/mir_unit_tests\""
506+adb shell "LD_LIBRARY_PATH=/home/phablet/mir/usr/lib/arm-linux-gnueabihf/:/home/phablet/mir/lib PATH=$PATH:/home/phablet/mir/usr/bin bash -c \"cd /home/phablet/mir/usr/bin ; umockdev-run /home/phablet/mir/bin/mir_integration_tests\""
507+adb shell "LD_LIBRARY_PATH=/home/phablet/mir/usr/lib/arm-linux-gnueabihf/:/home/phablet/mir/lib PATH=$PATH:/home/phablet/mir/usr/bin bash -c \"cd /home/phablet/mir/usr/bin ; umockdev-run /home/phablet/mir/bin/mir_acceptance_tests\""
508
509=== modified file 'examples/demo-shell/demo_renderer.cpp'
510--- examples/demo-shell/demo_renderer.cpp 2014-03-05 04:13:32 +0000
511+++ examples/demo-shell/demo_renderer.cpp 2014-04-02 18:58:27 +0000
512@@ -17,13 +17,131 @@
513 */
514
515 #include "demo_renderer.h"
516+#include <mir/graphics/renderable.h>
517+#include <cmath>
518
519 using namespace mir;
520 using namespace mir::examples;
521
522+namespace
523+{
524+
525+float penumbra_curve(float x)
526+{
527+ return 1.0f - std::sin(x * M_PI / 2.0f);
528+}
529+
530+GLuint generate_shadow_corner_texture(float opacity)
531+{
532+ struct Texel
533+ {
534+ GLubyte luminance;
535+ GLubyte alpha;
536+ };
537+
538+ int const width = 256;
539+ Texel image[width][width];
540+
541+ int const max = width - 1;
542+ for (int y = 0; y < width; ++y)
543+ {
544+ float curve_y = opacity * 255.0f *
545+ penumbra_curve(static_cast<float>(y) / max);
546+ for (int x = 0; x < width; ++x)
547+ {
548+ Texel *t = &image[y][x];
549+ t->luminance = 0;
550+ t->alpha = curve_y * penumbra_curve(static_cast<float>(x) / max);
551+ }
552+ }
553+
554+ GLuint corner;
555+ glGenTextures(1, &corner);
556+ glBindTexture(GL_TEXTURE_2D, corner);
557+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
558+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
559+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
560+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
561+ glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA,
562+ width, width, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,
563+ image);
564+
565+ return corner;
566+}
567+
568+GLuint generate_frame_corner_texture()
569+{
570+ struct Texel
571+ {
572+ GLubyte r, g, b, a;
573+ };
574+
575+ int const width = 256;
576+ Texel image[width][width];
577+
578+ int cx = width / 2;
579+ int cy = width / 2;
580+ int radius_sqr = cx * cx;
581+
582+ for (int y = 0; y < width; ++y)
583+ {
584+ for (int x = 0; x < width; ++x)
585+ {
586+ GLubyte lum = 128;
587+ GLubyte alpha = 255;
588+
589+ // Cut out the corner in a circular shape.
590+ if (x < cx && y < cy)
591+ {
592+ int dx = cx - x;
593+ int dy = cy - y;
594+ if (dx * dx + dy * dy >= radius_sqr)
595+ alpha = 0;
596+ }
597+
598+ // Set gradient
599+ if (y < cy)
600+ {
601+ float brighten = (1.0f - (static_cast<float>(y) / cy));
602+ if (x < cx)
603+ brighten *= std::sin(x * M_PI / width);
604+
605+ lum += (255 - lum) * brighten;
606+ }
607+
608+ image[y][x] = {lum, lum, lum, alpha};
609+ }
610+ }
611+
612+ GLuint corner;
613+ glGenTextures(1, &corner);
614+ glBindTexture(GL_TEXTURE_2D, corner);
615+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
616+ GL_LINEAR_MIPMAP_LINEAR);
617+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
618+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
619+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
620+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
621+ width, width, 0, GL_RGBA, GL_UNSIGNED_BYTE,
622+ image);
623+ glGenerateMipmap(GL_TEXTURE_2D); // Antialiasing please
624+
625+ return corner;
626+}
627+
628+} // namespace
629+
630 DemoRenderer::DemoRenderer(geometry::Rectangle const& display_area)
631 : GLRenderer(display_area)
632 {
633+ shadow_corner_tex = generate_shadow_corner_texture(0.4f);
634+ titlebar_corner_tex = generate_frame_corner_texture();
635+}
636+
637+DemoRenderer::~DemoRenderer()
638+{
639+ glDeleteTextures(1, &shadow_corner_tex);
640+ glDeleteTextures(1, &titlebar_corner_tex);
641 }
642
643 void DemoRenderer::begin() const
644@@ -31,3 +149,156 @@
645 glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
646 glClear(GL_COLOR_BUFFER_BIT);
647 }
648+
649+void DemoRenderer::tessellate(std::vector<Primitive>& primitives,
650+ graphics::Renderable const& renderable,
651+ geometry::Size const& buf_size) const
652+{
653+ GLRenderer::tessellate(primitives, renderable, buf_size);
654+ tessellate_shadow(primitives, renderable, 80.0f);
655+ tessellate_frame(primitives, renderable, 30.0f);
656+}
657+
658+void DemoRenderer::tessellate_shadow(std::vector<Primitive>& primitives,
659+ graphics::Renderable const& renderable,
660+ float radius) const
661+{
662+ auto const& rect = renderable.screen_position();
663+ GLfloat left = rect.top_left.x.as_int();
664+ GLfloat right = left + rect.size.width.as_int();
665+ GLfloat top = rect.top_left.y.as_int();
666+ GLfloat bottom = top + rect.size.height.as_int();
667+
668+ auto n = primitives.size();
669+ primitives.resize(n + 8);
670+
671+ GLfloat rightr = right + radius;
672+ GLfloat leftr = left - radius;
673+ GLfloat topr = top - radius;
674+ GLfloat bottomr = bottom + radius;
675+
676+ auto& right_shadow = primitives[n++];
677+ right_shadow.tex_id = shadow_corner_tex;
678+ right_shadow.type = GL_TRIANGLE_FAN;
679+ right_shadow.vertices.resize(4);
680+ right_shadow.vertices[0] = {{right, top, 0.0f}, {0.0f, 0.0f}};
681+ right_shadow.vertices[1] = {{rightr, top, 0.0f}, {1.0f, 0.0f}};
682+ right_shadow.vertices[2] = {{rightr, bottom, 0.0f}, {1.0f, 0.0f}};
683+ right_shadow.vertices[3] = {{right, bottom, 0.0f}, {0.0f, 0.0f}};
684+
685+ auto& left_shadow = primitives[n++];
686+ left_shadow.tex_id = shadow_corner_tex;
687+ left_shadow.type = GL_TRIANGLE_FAN;
688+ left_shadow.vertices.resize(4);
689+ left_shadow.vertices[0] = {{leftr, top, 0.0f}, {1.0f, 0.0f}};
690+ left_shadow.vertices[1] = {{left, top, 0.0f}, {0.0f, 0.0f}};
691+ left_shadow.vertices[2] = {{left, bottom, 0.0f}, {0.0f, 0.0f}};
692+ left_shadow.vertices[3] = {{leftr, bottom, 0.0f}, {1.0f, 0.0f}};
693+
694+ auto& top_shadow = primitives[n++];
695+ top_shadow.tex_id = shadow_corner_tex;
696+ top_shadow.type = GL_TRIANGLE_FAN;
697+ top_shadow.vertices.resize(4);
698+ top_shadow.vertices[0] = {{left, topr, 0.0f}, {1.0f, 0.0f}};
699+ top_shadow.vertices[1] = {{right, topr, 0.0f}, {1.0f, 0.0f}};
700+ top_shadow.vertices[2] = {{right, top, 0.0f}, {0.0f, 0.0f}};
701+ top_shadow.vertices[3] = {{left, top, 0.0f}, {0.0f, 0.0f}};
702+
703+ auto& bottom_shadow = primitives[n++];
704+ bottom_shadow.tex_id = shadow_corner_tex;
705+ bottom_shadow.type = GL_TRIANGLE_FAN;
706+ bottom_shadow.vertices.resize(4);
707+ bottom_shadow.vertices[0] = {{left, bottom, 0.0f}, {0.0f, 0.0f}};
708+ bottom_shadow.vertices[1] = {{right, bottom, 0.0f}, {0.0f, 0.0f}};
709+ bottom_shadow.vertices[2] = {{right, bottomr, 0.0f}, {1.0f, 0.0f}};
710+ bottom_shadow.vertices[3] = {{left, bottomr, 0.0f}, {1.0f, 0.0f}};
711+
712+ auto& tr_shadow = primitives[n++];
713+ tr_shadow.tex_id = shadow_corner_tex;
714+ tr_shadow.type = GL_TRIANGLE_FAN;
715+ tr_shadow.vertices.resize(4);
716+ tr_shadow.vertices[0] = {{right, top, 0.0f}, {0.0f, 0.0f}};
717+ tr_shadow.vertices[1] = {{right, topr, 0.0f}, {1.0f, 0.0f}};
718+ tr_shadow.vertices[2] = {{rightr, topr, 0.0f}, {1.0f, 1.0f}};
719+ tr_shadow.vertices[3] = {{rightr, top, 0.0f}, {0.0f, 1.0f}};
720+
721+ auto& br_shadow = primitives[n++];
722+ br_shadow.tex_id = shadow_corner_tex;
723+ br_shadow.type = GL_TRIANGLE_FAN;
724+ br_shadow.vertices.resize(4);
725+ br_shadow.vertices[0] = {{right, bottom, 0.0f}, {0.0f, 0.0f}};
726+ br_shadow.vertices[1] = {{rightr, bottom, 0.0f}, {1.0f, 0.0f}};
727+ br_shadow.vertices[2] = {{rightr, bottomr, 0.0f}, {1.0f, 1.0f}};
728+ br_shadow.vertices[3] = {{right, bottomr, 0.0f}, {0.0f, 1.0f}};
729+
730+ auto& bl_shadow = primitives[n++];
731+ bl_shadow.tex_id = shadow_corner_tex;
732+ bl_shadow.type = GL_TRIANGLE_FAN;
733+ bl_shadow.vertices.resize(4);
734+ bl_shadow.vertices[0] = {{left, bottom, 0.0f}, {0.0f, 0.0f}};
735+ bl_shadow.vertices[1] = {{left, bottomr, 0.0f}, {1.0f, 0.0f}};
736+ bl_shadow.vertices[2] = {{leftr, bottomr, 0.0f}, {1.0f, 1.0f}};
737+ bl_shadow.vertices[3] = {{leftr, bottom, 0.0f}, {0.0f, 1.0f}};
738+
739+ auto& tl_shadow = primitives[n++];
740+ tl_shadow.tex_id = shadow_corner_tex;
741+ tl_shadow.type = GL_TRIANGLE_FAN;
742+ tl_shadow.vertices.resize(4);
743+ tl_shadow.vertices[0] = {{left, top, 0.0f}, {0.0f, 0.0f}};
744+ tl_shadow.vertices[1] = {{leftr, top, 0.0f}, {1.0f, 0.0f}};
745+ tl_shadow.vertices[2] = {{leftr, topr, 0.0f}, {1.0f, 1.0f}};
746+ tl_shadow.vertices[3] = {{left, topr, 0.0f}, {0.0f, 1.0f}};
747+
748+ // Shadows always need blending...
749+ glEnable(GL_BLEND);
750+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
751+}
752+
753+void DemoRenderer::tessellate_frame(std::vector<Primitive>& primitives,
754+ graphics::Renderable const& renderable,
755+ float titlebar_height) const
756+{
757+ auto const& rect = renderable.screen_position();
758+ GLfloat left = rect.top_left.x.as_int();
759+ GLfloat right = left + rect.size.width.as_int();
760+ GLfloat top = rect.top_left.y.as_int();
761+
762+ auto n = primitives.size();
763+ primitives.resize(n + 3);
764+
765+ GLfloat htop = top - titlebar_height;
766+ GLfloat inleft = left + titlebar_height; // Square proportions for corners
767+ GLfloat inright = right - titlebar_height;
768+
769+ GLfloat mid = (left + right) / 2.0f;
770+ if (inleft > mid) inleft = mid;
771+ if (inright < mid) inright = mid;
772+
773+ auto& top_left_corner = primitives[n++];
774+ top_left_corner.tex_id = titlebar_corner_tex;
775+ top_left_corner.type = GL_TRIANGLE_FAN;
776+ top_left_corner.vertices.resize(4);
777+ top_left_corner.vertices[0] = {{left, htop, 0.0f}, {0.0f, 0.0f}};
778+ top_left_corner.vertices[1] = {{inleft, htop, 0.0f}, {1.0f, 0.0f}};
779+ top_left_corner.vertices[2] = {{inleft, top, 0.0f}, {1.0f, 1.0f}};
780+ top_left_corner.vertices[3] = {{left, top, 0.0f}, {0.0f, 1.0f}};
781+
782+ auto& top_right_corner = primitives[n++];
783+ top_right_corner.tex_id = titlebar_corner_tex;
784+ top_right_corner.type = GL_TRIANGLE_FAN;
785+ top_right_corner.vertices.resize(4);
786+ top_right_corner.vertices[0] = {{inright, htop, 0.0f}, {1.0f, 0.0f}};
787+ top_right_corner.vertices[1] = {{right, htop, 0.0f}, {0.0f, 0.0f}};
788+ top_right_corner.vertices[2] = {{right, top, 0.0f}, {0.0f, 1.0f}};
789+ top_right_corner.vertices[3] = {{inright, top, 0.0f}, {1.0f, 1.0f}};
790+
791+ auto& titlebar = primitives[n++];
792+ titlebar.tex_id = titlebar_corner_tex;
793+ titlebar.type = GL_TRIANGLE_FAN;
794+ titlebar.vertices.resize(4);
795+ titlebar.vertices[0] = {{inleft, htop, 0.0f}, {1.0f, 0.0f}};
796+ titlebar.vertices[1] = {{inright, htop, 0.0f}, {1.0f, 0.0f}};
797+ titlebar.vertices[2] = {{inright, top, 0.0f}, {1.0f, 1.0f}};
798+ titlebar.vertices[3] = {{inleft, top, 0.0f}, {1.0f, 1.0f}};
799+}
800+
801
802=== modified file 'examples/demo-shell/demo_renderer.h'
803--- examples/demo-shell/demo_renderer.h 2014-02-14 09:58:06 +0000
804+++ examples/demo-shell/demo_renderer.h 2014-04-02 18:58:27 +0000
805@@ -30,7 +30,22 @@
806 {
807 public:
808 DemoRenderer(geometry::Rectangle const& display_area);
809+ ~DemoRenderer();
810+
811 void begin() const override;
812+ void tessellate(std::vector<Primitive>& primitives,
813+ graphics::Renderable const& renderable,
814+ geometry::Size const& buf_size) const override;
815+ void tessellate_shadow(std::vector<Primitive>& primitives,
816+ graphics::Renderable const& renderable,
817+ float radius) const;
818+ void tessellate_frame(std::vector<Primitive>& primitives,
819+ graphics::Renderable const& renderable,
820+ float titlebar_height) const;
821+
822+private:
823+ GLuint shadow_corner_tex;
824+ GLuint titlebar_corner_tex;
825 };
826
827 } // namespace examples
828
829=== modified file 'examples/render_overlays.cpp'
830--- examples/render_overlays.cpp 2014-03-17 07:35:22 +0000
831+++ examples/render_overlays.cpp 2014-04-02 18:58:27 +0000
832@@ -105,17 +105,17 @@
833 {
834 }
835
836- std::shared_ptr<mg::Buffer> buffer(unsigned long) const override
837+ std::shared_ptr<mg::Buffer> buffer(void const*) const override
838 {
839 return client->last_rendered();
840 }
841
842- bool alpha_enabled() const
843+ bool alpha_enabled() const override
844 {
845 return false;
846 }
847
848- geom::Rectangle screen_position() const
849+ geom::Rectangle screen_position() const override
850 {
851 return position;
852 }
853@@ -130,14 +130,14 @@
854 return trans;
855 }
856
857- bool shaped() const
858+ bool shaped() const override
859 {
860 return false;
861 }
862
863- bool should_be_rendered_in(geom::Rectangle const& rect) const override
864+ bool visible() const override
865 {
866- return rect.overlaps(position);
867+ return true;
868 }
869
870 int buffers_ready_for_compositor() const override
871@@ -168,7 +168,9 @@
872 mir::DefaultServerConfiguration conf{argc, argv};
873
874 auto platform = conf.the_graphics_platform();
875- auto display = platform->create_display(conf.the_display_configuration_policy());
876+ auto display = platform->create_display(
877+ conf.the_display_configuration_policy(),
878+ conf.the_gl_config());
879 auto buffer_allocator = platform->create_buffer_allocator(conf.the_buffer_initializer());
880
881 mg::BufferProperties buffer_properties{
882
883=== modified file 'examples/render_surfaces.cpp'
884--- examples/render_surfaces.cpp 2014-03-11 04:03:54 +0000
885+++ examples/render_surfaces.cpp 2014-04-02 18:58:27 +0000
886@@ -31,7 +31,8 @@
887 #include "mir/graphics/display_buffer.h"
888 #include "mir/graphics/gl_context.h"
889 #include "mir/shell/surface_factory.h"
890-#include "mir/shell/surface.h"
891+#include "mir/scene/surface.h"
892+#include "mir/scene/surface_coordinator.h"
893 #include "mir/run_mir.h"
894 #include "mir/report_exception.h"
895 #include "mir/raii.h"
896@@ -41,6 +42,9 @@
897 #include "image_renderer.h"
898 #include "server_configuration.h"
899
900+#define GLM_FORCE_RADIANS
901+#include <glm/gtc/matrix_transform.hpp>
902+
903 #include <thread>
904 #include <atomic>
905 #include <chrono>
906@@ -90,6 +94,7 @@
907 std::weak_ptr<mg::Cursor> cursor;
908 static const uint32_t bg_color = 0x00000000;
909 static const uint32_t fg_color = 0xffdd4814;
910+static const float min_alpha = 0.3f;
911
912 void update_cursor(uint32_t bg_color, uint32_t fg_color)
913 {
914@@ -233,8 +238,16 @@
915 y = new_y;
916 }
917
918- surface->set_rotation(total_elapsed_sec * 120.0f, rotation_axis);
919- surface->set_alpha(0.5 + 0.5 * sin(alpha_offset + 2 * M_PI * total_elapsed_sec / 3.0));
920+ glm::mat4 trans = glm::rotate(glm::mat4(1.0f),
921+ glm::radians(total_elapsed_sec * 120.0f),
922+ rotation_axis);
923+ surface->set_transformation(trans);
924+
925+ float const alpha_amplitude = (1.0f - min_alpha) / 2.0f;
926+ surface->set_alpha(min_alpha + alpha_amplitude +
927+ alpha_amplitude *
928+ sin(alpha_offset + 2 * M_PI * total_elapsed_sec /
929+ 3.0));
930 }
931
932 private:
933@@ -433,7 +446,7 @@
934 std::cout << "Rendering " << moveables.size() << " surfaces" << std::endl;
935
936 auto const display = the_display();
937- auto const surface_factory = the_scene_surface_factory();
938+ auto const surface_coordinator = the_surface_coordinator();
939 /* TODO: Get proper configuration */
940 geom::Rectangles view_area;
941 display->for_each_display_buffer([&view_area](mg::DisplayBuffer const& db)
942@@ -452,12 +465,11 @@
943 int i = 0;
944 for (auto& m : moveables)
945 {
946- auto const s = surface_factory->create_surface(
947- nullptr,
948+ auto const s = surface_coordinator->add_surface(
949 msh::a_surface().of_size(surface_size)
950 .of_pixel_format(surface_pf)
951 .of_buffer_usage(mg::BufferUsage::hardware),
952- mf::SurfaceId(), {});
953+ {});
954
955 /*
956 * We call swap_buffers() twice so that the surface is
957
958=== modified file 'include/platform/mir/graphics/display_buffer.h'
959--- include/platform/mir/graphics/display_buffer.h 2014-03-06 06:05:17 +0000
960+++ include/platform/mir/graphics/display_buffer.h 2014-04-02 18:58:27 +0000
961@@ -20,11 +20,11 @@
962 #define MIR_GRAPHICS_DISPLAY_BUFFER_H_
963
964 #include <mir/geometry/rectangle.h>
965+#include <mir/graphics/renderable.h>
966 #include <mir_toolkit/common.h>
967
968 #include <memory>
969 #include <functional>
970-#include <list>
971
972 namespace mir
973 {
974@@ -32,7 +32,6 @@
975 {
976
977 class Buffer;
978-class Renderable;
979
980 /**
981 * Interface to an output framebuffer.
982@@ -57,7 +56,7 @@
983 that Renderable via OpenGL, or via another method. If the Renderable is to be rendered
984 via OpenGL, render_fn will be invoked on that Renderable. */
985 virtual void render_and_post_update(
986- std::list<std::shared_ptr<Renderable>> const& renderlist,
987+ RenderableList const& renderlist,
988 std::function<void(Renderable const&)> const& render_fn) = 0;
989
990 /** to be deprecated */
991
992=== added file 'include/platform/mir/graphics/gl_config.h'
993--- include/platform/mir/graphics/gl_config.h 1970-01-01 00:00:00 +0000
994+++ include/platform/mir/graphics/gl_config.h 2014-04-02 18:58:27 +0000
995@@ -0,0 +1,54 @@
996+/*
997+ * Copyright © 2014 Canonical Ltd.
998+ *
999+ * This program is free software: you can redistribute it and/or modify it
1000+ * under the terms of the GNU Lesser General Public License version 3,
1001+ * as published by the Free Software Foundation.
1002+ *
1003+ * This program is distributed in the hope that it will be useful,
1004+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1005+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1006+ * GNU Lesser General Public License for more details.
1007+ *
1008+ * You should have received a copy of the GNU Lesser General Public License
1009+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1010+ *
1011+ * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
1012+ */
1013+
1014+#ifndef MIR_GRAPHICS_GL_CONFIG_H_
1015+#define MIR_GRAPHICS_GL_CONFIG_H_
1016+
1017+namespace mir
1018+{
1019+namespace graphics
1020+{
1021+
1022+/**
1023+ * Interface for customizing aspects of the GL config used by the server.
1024+ */
1025+class GLConfig
1026+{
1027+public:
1028+ virtual ~GLConfig() = default;
1029+
1030+ /**
1031+ * Gets the bits to use for each pixel in the depth buffer.
1032+ */
1033+ virtual int depth_buffer_bits() const = 0;
1034+
1035+ /**
1036+ * Gets the bits to use for each pixel in the stencil buffer.
1037+ */
1038+ virtual int stencil_buffer_bits() const = 0;
1039+
1040+protected:
1041+ GLConfig() = default;
1042+ GLConfig(GLConfig const&) = delete;
1043+ GLConfig& operator=(GLConfig const&) = delete;
1044+};
1045+
1046+}
1047+}
1048+
1049+#endif /* MIR_GRAPHICS_GL_CONFIG_H_ */
1050
1051=== modified file 'include/platform/mir/graphics/platform.h'
1052--- include/platform/mir/graphics/platform.h 2014-03-06 06:05:17 +0000
1053+++ include/platform/mir/graphics/platform.h 2014-04-02 18:58:27 +0000
1054@@ -22,6 +22,7 @@
1055
1056 #include "basic_platform.h"
1057
1058+#include <boost/program_options/options_description.hpp>
1059 #include <memory>
1060
1061 namespace mir
1062@@ -48,6 +49,7 @@
1063 class DisplayReport;
1064 class DisplayConfigurationPolicy;
1065 class GraphicBufferAllocator;
1066+class GLConfig;
1067
1068 /**
1069 * \defgroup platform_enablement Mir platform enablement
1070@@ -81,7 +83,8 @@
1071 * Creates the display subsystem.
1072 */
1073 virtual std::shared_ptr<Display> create_display(
1074- std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy) = 0;
1075+ std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
1076+ std::shared_ptr<GLConfig> const& gl_config) = 0;
1077
1078 /**
1079 * Gets the IPC package for the platform.
1080@@ -119,6 +122,10 @@
1081 */
1082 extern "C" typedef std::shared_ptr<Platform>(*CreatePlatform)(std::shared_ptr<options::Option> const& options, std::shared_ptr<DisplayReport> const& report);
1083 extern "C" std::shared_ptr<Platform> create_platform (std::shared_ptr<options::Option> const& options, std::shared_ptr<DisplayReport> const& report);
1084+extern "C" typedef void(*AddPlatformOptions)(
1085+ boost::program_options::options_description& config);
1086+extern "C" void add_platform_options(
1087+ boost::program_options::options_description& config);
1088 }
1089 }
1090
1091
1092=== modified file 'include/platform/mir/graphics/renderable.h'
1093--- include/platform/mir/graphics/renderable.h 2014-03-17 07:35:22 +0000
1094+++ include/platform/mir/graphics/renderable.h 2014-04-02 18:58:27 +0000
1095@@ -22,6 +22,7 @@
1096 #include <mir/geometry/rectangle.h>
1097 #include <glm/glm.hpp>
1098 #include <memory>
1099+#include <list>
1100
1101 namespace mir
1102 {
1103@@ -35,19 +36,15 @@
1104 /**
1105 * Return the next buffer that should be composited/rendered.
1106 *
1107- * \param [in] frameno The frameno parameter is important for
1108- * multi-monitor platforms. Calls with the same frameno
1109- * will get the same buffer returned. This ensures that
1110- * a surface visible on multiple outputs does not get
1111- * its buffers consumed any faster than the refresh
1112- * rate of a single monitor. Implementations may ignore
1113- * the value of frameno on single-monitor platforms
1114- * only. The caller should always ensure the frameno
1115- * is different to the previous frame. The exact value
1116- * of frameno is not important but a large range of
1117- * values is recommended.
1118+ * \param [in] user_id An arbitrary unique identifier used to distinguish
1119+ * separate threads/monitors/components which need
1120+ * to concurrently receive the same buffer. Calling
1121+ * with the same user_id will return a new (different)
1122+ * buffer to that user each time. For consistency,
1123+ * all callers need to determine their user_id in the
1124+ * same way (e.g. always use "this" pointer).
1125 */
1126- virtual std::shared_ptr<Buffer> buffer(unsigned long frameno) const = 0;
1127+ virtual std::shared_ptr<Buffer> buffer(void const* user_id) const = 0;
1128
1129 virtual bool alpha_enabled() const = 0;
1130 virtual geometry::Rectangle screen_position() const = 0;
1131@@ -69,7 +66,14 @@
1132 * the surface itself).
1133 */
1134 virtual glm::mat4 transformation() const = 0;
1135- virtual bool should_be_rendered_in(geometry::Rectangle const& rect) const = 0;
1136+
1137+ /**
1138+ * TODO: Its a bit questionable that we have this member function, why not
1139+ * just trim the renderable from the RenderableList? Its convenient
1140+ * to have this function temporarily while refactoring --kdub
1141+ */
1142+ virtual bool visible() const = 0;
1143+
1144 virtual bool shaped() const = 0; // meaning the pixel format has alpha
1145 virtual int buffers_ready_for_compositor() const = 0;
1146
1147@@ -80,6 +84,9 @@
1148 Renderable& operator=(Renderable const&) = delete;
1149 };
1150
1151+// XXX Would performance be better with a vector?
1152+typedef std::list<std::shared_ptr<Renderable>> RenderableList;
1153+
1154 }
1155 }
1156
1157
1158=== modified file 'include/platform/mir/options/default_configuration.h'
1159--- include/platform/mir/options/default_configuration.h 2014-03-17 07:35:22 +0000
1160+++ include/platform/mir/options/default_configuration.h 2014-04-02 18:58:27 +0000
1161@@ -37,6 +37,7 @@
1162 boost::program_options::options_description_easy_init add_options();
1163
1164 private:
1165+ void add_platform_options();
1166 // accessed via the base interface, when access to add_options() has been "lost"
1167 std::shared_ptr<options::Option> the_options() const override;
1168
1169
1170=== added file 'include/platform/mir/shared_library_loader.h'
1171--- include/platform/mir/shared_library_loader.h 1970-01-01 00:00:00 +0000
1172+++ include/platform/mir/shared_library_loader.h 2014-04-02 18:58:27 +0000
1173@@ -0,0 +1,28 @@
1174+/*
1175+ * Copyright © 2013 Canonical Ltd.
1176+ *
1177+ * This program is free software: you can redistribute it and/or modify it
1178+ * under the terms of the GNU Lesser General Public License version 3,
1179+ * as published by the Free Software Foundation.
1180+ *
1181+ * This program is distributed in the hope that it will be useful,
1182+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1183+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1184+ * GNU Lesser General Public License for more details.
1185+ *
1186+ * You should have received a copy of the GNU Lesser General Public License
1187+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1188+ *
1189+ * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
1190+ */
1191+
1192+#ifndef MIR_SHARED_LIBRARY_LOADER_H_
1193+#define MIR_SHARED_LIBRARY_LOADER_H_
1194+
1195+#include <string>
1196+namespace mir
1197+{
1198+class SharedLibrary;
1199+SharedLibrary const* load_library(std::string const& libname);
1200+}
1201+#endif
1202
1203=== modified file 'include/server/mir/compositor/buffer_stream.h'
1204--- include/server/mir/compositor/buffer_stream.h 2014-03-07 03:15:55 +0000
1205+++ include/server/mir/compositor/buffer_stream.h 2014-04-02 18:58:27 +0000
1206@@ -43,7 +43,7 @@
1207
1208 virtual void swap_client_buffers(graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete) = 0;
1209 virtual std::shared_ptr<graphics::Buffer>
1210- lock_compositor_buffer(unsigned long frameno) = 0;
1211+ lock_compositor_buffer(void const* user_id) = 0;
1212 virtual std::shared_ptr<graphics::Buffer> lock_snapshot_buffer() = 0;
1213 virtual MirPixelFormat get_stream_pixel_format() = 0;
1214 virtual geometry::Size stream_size() = 0;
1215
1216=== modified file 'include/server/mir/compositor/gl_renderer.h'
1217--- include/server/mir/compositor/gl_renderer.h 2014-03-17 07:35:22 +0000
1218+++ include/server/mir/compositor/gl_renderer.h 2014-04-02 18:58:27 +0000
1219@@ -54,14 +54,27 @@
1220 GLfloat texcoord[2];
1221 };
1222
1223+ struct Primitive
1224+ {
1225+ GLenum type; // GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRIANGLES etc
1226+ GLuint tex_id; // GL texture ID (or 0 to represent the surface itself)
1227+ std::vector<Vertex> vertices;
1228+ };
1229+
1230 /**
1231 * tessellate defines the list of triangles that will be used to render
1232 * the surface. By default it just returns 4 vertices for a rectangle.
1233 * However you can override its behaviour to tessellate more finely and
1234 * deform freely for effects like wobbly windows.
1235 *
1236- * \returns The mode to be passed to glDrawArrays, e.g. GL_TRIANGLE_STRIP,
1237- * GL_TRIANGLE_FAN or GL_TRIANGLES.
1238+ * \param [in,out] primitives The list of rendering primitives to be
1239+ * grown and/or modified.
1240+ * \param [in] renderable The renderable surface being tessellated.
1241+ * \param [in] buf_size The dimensions of the buffer being rendered,
1242+ * which can be particularly useful in
1243+ * calculating texcoords for a surface being
1244+ * actively resized (as the buf_size doesn't
1245+ * yet match renderable.size()).
1246 *
1247 * \note The cohesion of this function to GLRenderer is quite loose and it
1248 * does not strictly need to reside here.
1249@@ -69,8 +82,18 @@
1250 * the only OpenGL-specific class in the display server, and
1251 * tessellation is very much OpenGL-specific.
1252 */
1253- virtual GLenum tessellate(graphics::Renderable const& renderable,
1254- std::vector<Vertex>& vertices) const;
1255+ virtual void tessellate(std::vector<Primitive>& primitives,
1256+ graphics::Renderable const& renderable,
1257+ geometry::Size const& buf_size) const;
1258+
1259+ /**
1260+ * Load the texture for a surface any which way you like. The default
1261+ * implementation does so with efficient GPU-side caching built in.
1262+ *
1263+ * \returns The OpenGL texture name for the surface.
1264+ */
1265+ virtual GLuint load_texture(graphics::Renderable const& renderable,
1266+ graphics::Buffer& buffer) const;
1267
1268 private:
1269 GLuint vertex_shader;
1270
1271=== modified file 'include/server/mir/compositor/renderer.h'
1272--- include/server/mir/compositor/renderer.h 2014-03-17 07:35:22 +0000
1273+++ include/server/mir/compositor/renderer.h 2014-04-02 18:58:27 +0000
1274@@ -40,8 +40,8 @@
1275 virtual void set_rotation(float degrees) = 0;
1276 virtual void begin() const = 0;
1277
1278- // XXX The buffer parameter here could now be replaced with a "frameno"
1279- // instead, and use renderable.buffer(frameno). Is that better?
1280+ // XXX The buffer parameter here could now be replaced with
1281+ // renderable::buffer().
1282 virtual void render(graphics::Renderable const& renderable,
1283 graphics::Buffer& buffer) const = 0;
1284 virtual void end() const = 0;
1285
1286=== modified file 'include/server/mir/compositor/scene.h'
1287--- include/server/mir/compositor/scene.h 2014-03-17 07:35:22 +0000
1288+++ include/server/mir/compositor/scene.h 2014-04-02 18:58:27 +0000
1289@@ -20,6 +20,7 @@
1290 #define MIR_COMPOSITOR_SCENE_H_
1291
1292 #include "mir/geometry/forward.h"
1293+#include "mir/graphics/renderable.h"
1294
1295 #include <memory>
1296 #include <functional>
1297@@ -62,13 +63,15 @@
1298 public:
1299 virtual ~Scene() {}
1300
1301+ /**
1302+ * Generate a valid list of renderables based on the current state of the Scene.
1303+ * \returns a list of mg::Renderables. The list is in stacking order from back to front.
1304+ */
1305+ virtual graphics::RenderableList generate_renderable_list() const = 0;
1306+
1307 // Back to front; normal rendering order
1308 virtual void for_each_if(FilterForScene& filter, OperatorForScene& op) = 0;
1309
1310- // Front to back; as used when scanning for occlusions
1311- virtual void reverse_for_each_if(FilterForScene& filter,
1312- OperatorForScene& op) = 0;
1313-
1314 /**
1315 * Sets a callback to be called whenever the state of the
1316 * Scene changes.
1317
1318=== modified file 'include/server/mir/default_server_configuration.h'
1319--- include/server/mir/default_server_configuration.h 2014-03-06 06:05:17 +0000
1320+++ include/server/mir/default_server_configuration.h 2014-04-02 18:58:27 +0000
1321@@ -61,7 +61,6 @@
1322 class SessionListener;
1323 class FocusController;
1324 class DisplayLayout;
1325-class SurfaceConfigurator;
1326 }
1327 namespace time
1328 {
1329@@ -69,6 +68,7 @@
1330 }
1331 namespace scene
1332 {
1333+class SurfaceFactory;
1334 class BroadcastingSessionEventSink;
1335 class BufferStreamFactory;
1336 class MediatingDisplayChanger;
1337@@ -78,7 +78,8 @@
1338 class SessionEventHandlerRegister;
1339 class SessionManager;
1340 class SnapshotStrategy;
1341-class SurfaceBuilder;
1342+class SurfaceCoordinator;
1343+class SurfaceConfigurator;
1344 class SurfaceStackModel;
1345 class SurfaceStack;
1346 class SurfaceRanker;
1347@@ -93,6 +94,7 @@
1348 class BufferInitializer;
1349 class DisplayReport;
1350 class GraphicBufferAllocator;
1351+class GLConfig;
1352 namespace nested { class HostConnection; }
1353 }
1354 namespace input
1355@@ -152,6 +154,7 @@
1356 virtual std::shared_ptr<graphics::DisplayConfigurationPolicy> the_display_configuration_policy();
1357 virtual std::shared_ptr<graphics::nested::HostConnection> the_host_connection();
1358 virtual std::shared_ptr<input::EventFilter> the_nested_event_filter();
1359+ virtual std::shared_ptr<graphics::GLConfig> the_gl_config();
1360 /** @} */
1361
1362 /** @name graphics configuration - dependencies
1363@@ -198,12 +201,10 @@
1364 * configurable interfaces for modifying shell
1365 * @{ */
1366 virtual std::shared_ptr<shell::SurfaceFactory> the_shell_surface_factory();
1367- virtual std::shared_ptr<shell::SurfaceFactory> the_scene_surface_factory();
1368 virtual std::shared_ptr<shell::FocusSetter> the_shell_focus_setter();
1369 virtual std::shared_ptr<shell::PlacementStrategy> the_shell_placement_strategy();
1370 virtual std::shared_ptr<shell::SessionListener> the_shell_session_listener();
1371 virtual std::shared_ptr<shell::DisplayLayout> the_shell_display_layout();
1372- virtual std::shared_ptr<shell::SurfaceConfigurator> the_shell_surface_configurator();
1373 /** @} */
1374
1375 /** @name internal scene configuration
1376@@ -216,7 +217,10 @@
1377 virtual std::shared_ptr<scene::SessionEventSink> the_session_event_sink();
1378 virtual std::shared_ptr<scene::SessionEventHandlerRegister> the_session_event_handler_register();
1379 virtual std::shared_ptr<scene::SurfaceStackModel> the_surface_stack_model();
1380- virtual std::shared_ptr<scene::SurfaceRanker> the_surface_ranker();
1381+ virtual std::shared_ptr<scene::SurfaceRanker> the_surface_ranker();
1382+ virtual std::shared_ptr<scene::SurfaceFactory> the_surface_factory();
1383+ virtual std::shared_ptr<scene::SurfaceCoordinator>the_surface_coordinator();
1384+ virtual std::shared_ptr<scene::SurfaceConfigurator> the_surface_configurator();
1385 /** @} */
1386
1387 /** @name scene configuration - dependencies
1388@@ -284,7 +288,7 @@
1389 CachedPtr<scene::SceneReport> scene_report;
1390
1391 CachedPtr<shell::SurfaceFactory> shell_surface_factory;
1392- CachedPtr<shell::SurfaceFactory> scene_surface_factory;
1393+ CachedPtr<scene::SurfaceFactory> surface_factory;
1394 CachedPtr<scene::SessionContainer> session_container;
1395 CachedPtr<shell::FocusSetter> shell_focus_setter;
1396 CachedPtr<shell::PlacementStrategy> shell_placement_strategy;
1397@@ -292,7 +296,7 @@
1398 CachedPtr<scene::PixelBuffer> pixel_buffer;
1399 CachedPtr<scene::SnapshotStrategy> snapshot_strategy;
1400 CachedPtr<shell::DisplayLayout> shell_display_layout;
1401- CachedPtr<shell::SurfaceConfigurator> shell_surface_configurator;
1402+ CachedPtr<scene::SurfaceConfigurator> surface_configurator;
1403 CachedPtr<compositor::DisplayBufferCompositorFactory> display_buffer_compositor_factory;
1404 CachedPtr<compositor::Compositor> compositor;
1405 CachedPtr<compositor::CompositorReport> compositor_report;
1406@@ -304,6 +308,7 @@
1407 CachedPtr<graphics::DisplayConfigurationPolicy> display_configuration_policy;
1408 CachedPtr<graphics::nested::HostConnection> host_connection;
1409 CachedPtr<scene::MediatingDisplayChanger> mediating_display_changer;
1410+ CachedPtr<graphics::GLConfig> gl_config;
1411
1412 private:
1413 std::shared_ptr<options::Configuration> const configuration_options;
1414@@ -321,7 +326,6 @@
1415 std::shared_ptr<scene::BroadcastingSessionEventSink> the_broadcasting_session_event_sink();
1416 std::shared_ptr<input::NestedInputRelay> the_nested_input_relay();
1417 std::shared_ptr<scene::SessionManager> the_session_manager();
1418- std::shared_ptr<scene::SurfaceBuilder> the_surface_builder();
1419 std::shared_ptr<scene::SurfaceController> the_surface_controller();
1420
1421 auto report_factory(char const* report_opt) -> std::unique_ptr<report::ReportFactory>;
1422
1423=== modified file 'include/server/mir/frontend/display_changer.h'
1424--- include/server/mir/frontend/display_changer.h 2013-09-17 20:03:16 +0000
1425+++ include/server/mir/frontend/display_changer.h 2014-04-02 18:58:27 +0000
1426@@ -38,7 +38,6 @@
1427
1428 virtual std::shared_ptr<graphics::DisplayConfiguration> active_configuration() = 0;
1429 virtual void configure(std::shared_ptr<Session> const&, std::shared_ptr<graphics::DisplayConfiguration> const&) = 0;
1430- virtual void ensure_display_powered(std::shared_ptr<Session> const& session) = 0;
1431
1432 protected:
1433 DisplayChanger() = default;
1434
1435=== modified file 'include/server/mir/frontend/session_authorizer.h'
1436--- include/server/mir/frontend/session_authorizer.h 2014-03-06 06:05:17 +0000
1437+++ include/server/mir/frontend/session_authorizer.h 2014-04-02 18:58:27 +0000
1438@@ -29,10 +29,12 @@
1439 class SessionAuthorizer
1440 {
1441 public:
1442- virtual ~SessionAuthorizer() {}
1443+ virtual ~SessionAuthorizer() = default;
1444
1445 virtual bool connection_is_allowed(pid_t pid) = 0;
1446 virtual bool configure_display_is_allowed(pid_t pid) = 0;
1447+ virtual bool screencast_is_allowed(pid_t pid) = 0;
1448+
1449 protected:
1450 SessionAuthorizer() = default;
1451 SessionAuthorizer(SessionAuthorizer const&) = delete;
1452
1453=== modified file 'include/server/mir/input/surface.h'
1454--- include/server/mir/input/surface.h 2014-03-06 06:05:17 +0000
1455+++ include/server/mir/input/surface.h 2014-04-02 18:58:27 +0000
1456@@ -30,7 +30,7 @@
1457 class Surface
1458 {
1459 public:
1460- virtual std::string const& name() const = 0;
1461+ virtual std::string name() const = 0;
1462 virtual geometry::Point top_left() const = 0;
1463 virtual geometry::Size size() const = 0;
1464 virtual bool contains(geometry::Point const& point) const = 0;
1465
1466=== added file 'include/server/mir/scene/surface.h'
1467--- include/server/mir/scene/surface.h 1970-01-01 00:00:00 +0000
1468+++ include/server/mir/scene/surface.h 2014-04-02 18:58:27 +0000
1469@@ -0,0 +1,59 @@
1470+/*
1471+ * Copyright © 2014 Canonical Ltd.
1472+ *
1473+ * This program is free software: you can redistribute it and/or modify it
1474+ * under the terms of the GNU General Public License version 3,
1475+ * as published by the Free Software Foundation.
1476+ *
1477+ * This program is distributed in the hope that it will be useful,
1478+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1479+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1480+ * GNU General Public License for more details.
1481+ *
1482+ * You should have received a copy of the GNU General Public License
1483+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1484+ *
1485+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
1486+ */
1487+
1488+#ifndef MIR_SCENE_SURFACE_H_
1489+#define MIR_SCENE_SURFACE_H_
1490+
1491+#include "mir/graphics/renderable.h"
1492+#include "mir/input/surface.h"
1493+#include "mir/shell/surface.h"
1494+
1495+namespace mir
1496+{
1497+namespace input { class InputChannel; }
1498+
1499+namespace scene
1500+{
1501+class SurfaceObserver;
1502+
1503+class Surface :
1504+ public graphics::Renderable,
1505+ public input::Surface,
1506+ public shell::Surface
1507+{
1508+public:
1509+ // resolve ambiguous member function names
1510+ std::string name() const = 0;
1511+ geometry::Size size() const = 0;
1512+ geometry::Point top_left() const = 0;
1513+ float alpha() const = 0;
1514+
1515+ // member functions that don't exist in base classes
1516+ // TODO input_channel() and on_change() relate to
1517+ // TODO adding and removing the surface from the scene and are probably not
1518+ // TODO cleanest interface for this.
1519+ virtual std::shared_ptr<input::InputChannel> input_channel() const = 0;
1520+ virtual void on_change(std::function<void()> change_notification) = 0;
1521+
1522+ virtual void add_observer(std::shared_ptr<SurfaceObserver> const& observer) = 0;
1523+ virtual void remove_observer(std::shared_ptr<SurfaceObserver> const& observer) = 0;
1524+};
1525+}
1526+}
1527+
1528+#endif // MIR_SCENE_SURFACE_H_
1529
1530=== renamed file 'include/server/mir/shell/surface_configurator.h' => 'include/server/mir/scene/surface_configurator.h'
1531--- include/server/mir/shell/surface_configurator.h 2014-03-06 06:05:17 +0000
1532+++ include/server/mir/scene/surface_configurator.h 2014-04-02 18:58:27 +0000
1533@@ -16,8 +16,8 @@
1534 * Authored by: Robert Carr <robert.carr@canonical.com>
1535 */
1536
1537-#ifndef MIR_SHELL_SURFACE_CONFIGURATOR_H_
1538-#define MIR_SHELL_SURFACE_CONFIGURATOR_H_
1539+#ifndef MIR_SCENE_SURFACE_CONFIGURATOR_H_
1540+#define MIR_SCENE_SURFACE_CONFIGURATOR_H_
1541
1542 #include "mir_toolkit/common.h"
1543
1544@@ -26,7 +26,7 @@
1545 namespace mir
1546 {
1547
1548-namespace shell
1549+namespace scene
1550 {
1551 class Surface;
1552
1553@@ -51,4 +51,4 @@
1554 }
1555 } // namespace mir
1556
1557-#endif // MIR_SHELL_SURFACE_CONFIGURATOR_H_
1558+#endif // MIR_SCENE_SURFACE_CONFIGURATOR_H_
1559
1560=== renamed file 'src/server/scene/surface_builder.h' => 'include/server/mir/scene/surface_coordinator.h'
1561--- src/server/scene/surface_builder.h 2014-03-06 06:05:17 +0000
1562+++ include/server/mir/scene/surface_coordinator.h 2014-04-02 18:58:27 +0000
1563@@ -1,5 +1,5 @@
1564 /*
1565- * Copyright © 2013 Canonical Ltd.
1566+ * Copyright © 2013-14 Canonical Ltd.
1567 *
1568 * This program is free software: you can redistribute it and/or modify it
1569 * under the terms of the GNU General Public License version 3,
1570@@ -17,8 +17,10 @@
1571 */
1572
1573
1574-#ifndef MIR_SCENE_SURFACE_BUILDER_H_
1575-#define MIR_SCENE_SURFACE_BUILDER_H_
1576+#ifndef MIR_SCENE_SURFACE_COORDINATOR_H_
1577+#define MIR_SCENE_SURFACE_COORDINATOR_H_
1578+
1579+#include "mir/scene/surface_ranker.h"
1580
1581 #include <memory>
1582
1583@@ -31,22 +33,25 @@
1584
1585 namespace scene
1586 {
1587-class BasicSurface;
1588+class Surface;
1589+class SurfaceObserver;
1590
1591-class SurfaceBuilder
1592+class SurfaceCoordinator : public SurfaceRanker
1593 {
1594 public:
1595- virtual std::weak_ptr<BasicSurface> create_surface(shell::SurfaceCreationParameters const& params) = 0;
1596+ virtual std::shared_ptr<Surface> add_surface(
1597+ shell::SurfaceCreationParameters const& params,
1598+ std::shared_ptr<SurfaceObserver> const& observer) = 0;
1599
1600- virtual void destroy_surface(std::weak_ptr<BasicSurface> const& surface) = 0;
1601+ virtual void remove_surface(std::weak_ptr<Surface> const& surface) = 0;
1602 protected:
1603- SurfaceBuilder() = default;
1604- virtual ~SurfaceBuilder() = default;
1605- SurfaceBuilder(SurfaceBuilder const&) = delete;
1606- SurfaceBuilder& operator=(SurfaceBuilder const&) = delete;
1607+ SurfaceCoordinator() = default;
1608+ virtual ~SurfaceCoordinator() = default;
1609+ SurfaceCoordinator(SurfaceCoordinator const&) = delete;
1610+ SurfaceCoordinator& operator=(SurfaceCoordinator const&) = delete;
1611 };
1612 }
1613 }
1614
1615
1616-#endif /* MIR_SCENE_SURFACE_BUILDER_H_ */
1617+#endif /* MIR_SCENE_SURFACE_COORDINATOR_H_ */
1618
1619=== added file 'include/server/mir/scene/surface_event_source.h'
1620--- include/server/mir/scene/surface_event_source.h 1970-01-01 00:00:00 +0000
1621+++ include/server/mir/scene/surface_event_source.h 2014-04-02 18:58:27 +0000
1622@@ -0,0 +1,49 @@
1623+/*
1624+ * Copyright © 2014 Canonical Ltd.
1625+ *
1626+ * This program is free software: you can redistribute it and/or modify it
1627+ * under the terms of the GNU General Public License version 3,
1628+ * as published by the Free Software Foundation.
1629+ *
1630+ * This program is distributed in the hope that it will be useful,
1631+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1632+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1633+ * GNU General Public License for more details.
1634+ *
1635+ * You should have received a copy of the GNU General Public License
1636+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1637+ *
1638+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
1639+ */
1640+
1641+#ifndef MIR_SCENE_SURFACE_EVENT_SOURCE_H_
1642+#define MIR_SCENE_SURFACE_EVENT_SOURCE_H_
1643+
1644+#include "mir/scene/surface_observer.h"
1645+#include "mir/frontend/surface_id.h"
1646+#include "mir/frontend/event_sink.h"
1647+
1648+#include <memory>
1649+
1650+namespace mir
1651+{
1652+namespace scene
1653+{
1654+class SurfaceEventSource : public SurfaceObserver
1655+{
1656+public:
1657+ SurfaceEventSource(
1658+ frontend::SurfaceId id,
1659+ std::shared_ptr<frontend::EventSink> const& event_sink);
1660+
1661+ void attrib_change(MirSurfaceAttrib attrib, int value);
1662+ void resize(geometry::Size const& size);
1663+
1664+private:
1665+ frontend::SurfaceId const id;
1666+ std::shared_ptr<frontend::EventSink> const event_sink;
1667+};
1668+}
1669+}
1670+
1671+#endif // MIR_SCENE_SURFACE_EVENT_SOURCE_H_
1672
1673=== renamed file 'src/server/scene/basic_surface_factory.h' => 'include/server/mir/scene/surface_factory.h'
1674--- src/server/scene/basic_surface_factory.h 2014-03-06 06:05:17 +0000
1675+++ include/server/mir/scene/surface_factory.h 2014-04-02 18:58:27 +0000
1676@@ -1,5 +1,5 @@
1677 /*
1678- * Copyright © 2013 Canonical Ltd.
1679+ * Copyright © 2013-2014 Canonical Ltd.
1680 *
1681 * This program is free software: you can redistribute it and/or modify it
1682 * under the terms of the GNU General Public License version 3,
1683@@ -16,33 +16,33 @@
1684 * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
1685 */
1686
1687-#ifndef MIR_SCENE_BASIC_SURFACE_FACTORY_H_
1688-#define MIR_SCENE_BASIC_SURFACE_FACTORY_H_
1689+#ifndef MIR_SCENE_SURFACE_FACTORY_H_
1690+#define MIR_SCENE_SURFACE_FACTORY_H_
1691
1692 #include "mir/shell/surface_creation_parameters.h"
1693 #include <memory>
1694-#include <functional>
1695
1696 namespace mir
1697 {
1698 namespace scene
1699 {
1700+class Surface;
1701
1702-class BasicSurface;
1703-class BasicSurfaceFactory
1704+class SurfaceFactory
1705 {
1706 public:
1707- BasicSurfaceFactory() = default;
1708- virtual ~BasicSurfaceFactory() = default;
1709-
1710- virtual std::shared_ptr<BasicSurface> create_surface(
1711- shell::SurfaceCreationParameters const&, std::function<void()> const&) = 0;
1712+ SurfaceFactory() = default;
1713+ virtual ~SurfaceFactory() = default;
1714+
1715+ virtual std::shared_ptr<Surface> create_surface(
1716+ shell::SurfaceCreationParameters const& params) = 0;
1717+
1718 private:
1719- BasicSurfaceFactory(const BasicSurfaceFactory&) = delete;
1720- BasicSurfaceFactory& operator=(const BasicSurfaceFactory&) = delete;
1721+ SurfaceFactory(const SurfaceFactory&) = delete;
1722+ SurfaceFactory& operator=(const SurfaceFactory&) = delete;
1723 };
1724
1725 }
1726 }
1727
1728-#endif /* MIR_SCENE_BASIC_SURFACE_FACTORY_H_ */
1729+#endif /* MIR_SCENE_SURFACE_FACTORY_H_ */
1730
1731=== added file 'include/server/mir/scene/surface_observer.h'
1732--- include/server/mir/scene/surface_observer.h 1970-01-01 00:00:00 +0000
1733+++ include/server/mir/scene/surface_observer.h 2014-04-02 18:58:27 +0000
1734@@ -0,0 +1,45 @@
1735+/*
1736+ * Copyright © 2014 Canonical Ltd.
1737+ *
1738+ * This program is free software: you can redistribute it and/or modify it
1739+ * under the terms of the GNU General Public License version 3,
1740+ * as published by the Free Software Foundation.
1741+ *
1742+ * This program is distributed in the hope that it will be useful,
1743+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1744+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1745+ * GNU General Public License for more details.
1746+ *
1747+ * You should have received a copy of the GNU General Public License
1748+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1749+ *
1750+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
1751+ */
1752+
1753+#ifndef MIR_SCENE_SURFACE_OBSERVER_H_
1754+#define MIR_SCENE_SURFACE_OBSERVER_H_
1755+
1756+#include "mir/geometry/size.h"
1757+#include "mir_toolkit/common.h"
1758+
1759+namespace mir
1760+{
1761+namespace scene
1762+{
1763+// Initial cut - supporting the frontend requirement, more will follow
1764+class SurfaceObserver
1765+{
1766+public:
1767+ virtual void attrib_change(MirSurfaceAttrib attrib, int value) = 0;
1768+ virtual void resize(geometry::Size const& size) = 0;
1769+
1770+protected:
1771+ SurfaceObserver() = default;
1772+ virtual ~SurfaceObserver() = default;
1773+ SurfaceObserver(SurfaceObserver const&) = delete;
1774+ SurfaceObserver& operator=(SurfaceObserver const&) = delete;
1775+};
1776+}
1777+}
1778+
1779+#endif // MIR_SCENE_SURFACE_OBSERVER_H_
1780
1781=== renamed file 'src/server/scene/surface_ranker.h' => 'include/server/mir/scene/surface_ranker.h'
1782--- src/server/scene/surface_ranker.h 2014-03-06 06:05:17 +0000
1783+++ include/server/mir/scene/surface_ranker.h 2014-04-02 18:58:27 +0000
1784@@ -26,12 +26,12 @@
1785 {
1786 namespace scene
1787 {
1788-class BasicSurface;
1789+class Surface;
1790
1791 class SurfaceRanker
1792 {
1793 public:
1794- virtual void raise(std::weak_ptr<BasicSurface> const& surface) = 0;
1795+ virtual void raise(std::weak_ptr<Surface> const& surface) = 0;
1796
1797 protected:
1798 SurfaceRanker() = default;
1799
1800=== modified file 'include/server/mir/shell/surface.h'
1801--- include/server/mir/shell/surface.h 2014-03-06 06:05:17 +0000
1802+++ include/server/mir/shell/surface.h 2014-04-02 18:58:27 +0000
1803@@ -50,10 +50,8 @@
1804
1805 virtual void allow_framedropping(bool) = 0;
1806
1807- virtual void raise(std::shared_ptr<scene::SurfaceRanker> const& controller) = 0;
1808-
1809 virtual void resize(geometry::Size const& size) = 0;
1810- virtual void set_rotation(float degrees, glm::vec3 const& axis) = 0;
1811+ virtual void set_transformation(glm::mat4 const& t) = 0;
1812
1813 virtual float alpha() const = 0;
1814 virtual void set_alpha(float alpha) = 0;
1815
1816=== modified file 'include/server/mir/shell/surface_factory.h'
1817--- include/server/mir/shell/surface_factory.h 2013-08-28 03:41:48 +0000
1818+++ include/server/mir/shell/surface_factory.h 2014-04-02 18:58:27 +0000
1819@@ -1,5 +1,5 @@
1820 /*
1821- * Copyright © 2012 Canonical Ltd.
1822+ * Copyright © 2012-2014 Canonical Ltd.
1823 *
1824 * This program is free software: you can redistribute it and/or modify it
1825 * under the terms of the GNU General Public License version 3,
1826@@ -19,15 +19,12 @@
1827 #ifndef MIR_SHELL_SURFACE_FACTORY_H_
1828 #define MIR_SHELL_SURFACE_FACTORY_H_
1829
1830-#include "mir/frontend/surface_id.h"
1831 #include <memory>
1832
1833 namespace mir
1834 {
1835-namespace frontend
1836-{
1837-class EventSink;
1838-}
1839+namespace scene { class SurfaceObserver; }
1840+
1841 namespace shell
1842 {
1843 class Session;
1844@@ -40,8 +37,9 @@
1845 virtual std::shared_ptr<Surface> create_surface(
1846 Session* session,
1847 SurfaceCreationParameters const& params,
1848- frontend::SurfaceId id,
1849- std::shared_ptr<frontend::EventSink> const& sink) = 0;
1850+ std::shared_ptr<scene::SurfaceObserver> const& observer) = 0;
1851+
1852+ virtual void destroy_surface(std::shared_ptr<Surface> const& surface) = 0;
1853
1854 protected:
1855 virtual ~SurfaceFactory() {}
1856
1857=== added file 'include/shared/mir/geometry/length.h'
1858--- include/shared/mir/geometry/length.h 1970-01-01 00:00:00 +0000
1859+++ include/shared/mir/geometry/length.h 2014-04-02 18:58:27 +0000
1860@@ -0,0 +1,102 @@
1861+/*
1862+ * Copyright © 2014 Canonical Ltd.
1863+ *
1864+ * This program is free software: you can redistribute it and/or modify it
1865+ * under the terms of the GNU Lesser General Public License version 3,
1866+ * as published by the Free Software Foundation.
1867+ *
1868+ * This program is distributed in the hope that it will be useful,
1869+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1870+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1871+ * GNU Lesser General Public License for more details.
1872+ *
1873+ * You should have received a copy of the GNU Lesser General Public License
1874+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1875+ *
1876+ * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
1877+ */
1878+
1879+#ifndef MIR_GEOMETRY_LENGTH_H_
1880+#define MIR_GEOMETRY_LENGTH_H_
1881+
1882+namespace mir
1883+{
1884+namespace geometry
1885+{
1886+
1887+/// Length represents a physical length in the real world. The number of pixels
1888+/// this equates to can then be calculated based on a given DPI.
1889+class Length
1890+{
1891+public:
1892+ enum Units
1893+ {
1894+ micrometres = 1,
1895+ millimetres = 1000,
1896+ centimetres = 10000,
1897+ inches = 25400
1898+ };
1899+
1900+ Length() : magnitude(0) {}
1901+ Length(Length const&) = default;
1902+ Length& operator=(Length const&) = default;
1903+ Length(float mag, Units units) : magnitude(mag * units) {}
1904+
1905+ float as(Units units) const
1906+ {
1907+ return static_cast<float>(magnitude) / units;
1908+ }
1909+
1910+ float as_pixels(float dpi) const
1911+ {
1912+ return as(inches) * dpi;
1913+ }
1914+
1915+ bool operator==(Length const& rhs) const
1916+ {
1917+ return magnitude == rhs.magnitude;
1918+ }
1919+
1920+ bool operator!=(Length const& rhs) const
1921+ {
1922+ return magnitude != rhs.magnitude;
1923+ }
1924+
1925+private:
1926+ float magnitude;
1927+};
1928+
1929+inline Length operator"" _mm(long double mag)
1930+{
1931+ return Length(mag, Length::millimetres);
1932+}
1933+
1934+inline Length operator"" _mm(unsigned long long mag)
1935+{
1936+ return Length(mag, Length::millimetres);
1937+}
1938+
1939+inline Length operator"" _cm(long double mag)
1940+{
1941+ return Length(mag, Length::centimetres);
1942+}
1943+
1944+inline Length operator"" _cm(unsigned long long mag)
1945+{
1946+ return Length(mag, Length::centimetres);
1947+}
1948+
1949+inline Length operator"" _in(long double mag)
1950+{
1951+ return Length(mag, Length::inches);
1952+}
1953+
1954+inline Length operator"" _in(unsigned long long mag)
1955+{
1956+ return Length(mag, Length::inches);
1957+}
1958+
1959+} // namespace geometry
1960+} // namespace mir
1961+
1962+#endif // MIR_GEOMETRY_LENGTH_H_
1963
1964=== modified file 'include/test/mir_test_doubles/fake_renderable.h'
1965--- include/test/mir_test_doubles/fake_renderable.h 2014-03-17 07:35:22 +0000
1966+++ include/test/mir_test_doubles/fake_renderable.h 2014-04-02 18:58:27 +0000
1967@@ -42,7 +42,7 @@
1968 : rect{{x, y}, {width, height}},
1969 opacity(opacity),
1970 rectangular(rectangular),
1971- visible(visible),
1972+ visible_(visible),
1973 posted(posted)
1974 {
1975 }
1976@@ -57,9 +57,9 @@
1977 return glm::mat4();
1978 }
1979
1980- bool should_be_rendered_in(const mir::geometry::Rectangle &r) const override
1981+ bool visible() const override
1982 {
1983- return visible && posted && rect.overlaps(r);
1984+ return visible_ && posted;
1985 }
1986
1987 bool shaped() const override
1988@@ -72,7 +72,7 @@
1989 buf = b;
1990 }
1991
1992- std::shared_ptr<graphics::Buffer> buffer(unsigned long) const override
1993+ std::shared_ptr<graphics::Buffer> buffer(void const*) const override
1994 {
1995 return buf;
1996 }
1997@@ -97,7 +97,7 @@
1998 mir::geometry::Rectangle rect;
1999 float opacity;
2000 bool rectangular;
2001- bool visible;
2002+ bool visible_;
2003 bool posted;
2004 };
2005
2006
2007=== modified file 'include/test/mir_test_doubles/mock_buffer_bundle.h'
2008--- include/test/mir_test_doubles/mock_buffer_bundle.h 2014-03-07 03:15:55 +0000
2009+++ include/test/mir_test_doubles/mock_buffer_bundle.h 2014-04-02 18:58:27 +0000
2010@@ -39,7 +39,7 @@
2011
2012 MOCK_METHOD1(client_acquire, void(std::function<void(graphics::Buffer*)>));
2013 MOCK_METHOD1(client_release, void(graphics::Buffer*));
2014- MOCK_METHOD1(compositor_acquire, std::shared_ptr<graphics::Buffer>(unsigned long));
2015+ MOCK_METHOD1(compositor_acquire, std::shared_ptr<graphics::Buffer>(void const*));
2016 MOCK_METHOD1(compositor_release, void(std::shared_ptr<graphics::Buffer> const&));
2017 MOCK_METHOD0(snapshot_acquire, std::shared_ptr<graphics::Buffer>());
2018 MOCK_METHOD1(snapshot_release, void(std::shared_ptr<graphics::Buffer> const&));
2019
2020=== modified file 'include/test/mir_test_doubles/mock_buffer_stream.h'
2021--- include/test/mir_test_doubles/mock_buffer_stream.h 2014-03-07 03:15:55 +0000
2022+++ include/test/mir_test_doubles/mock_buffer_stream.h 2014-04-02 18:58:27 +0000
2023@@ -33,7 +33,7 @@
2024 {
2025 MOCK_METHOD2(swap_client_buffers, void(graphics::Buffer*, std::function<void(graphics::Buffer*)> completee));
2026 MOCK_METHOD1(lock_compositor_buffer,
2027- std::shared_ptr<graphics::Buffer>(unsigned long));
2028+ std::shared_ptr<graphics::Buffer>(void const*));
2029 MOCK_METHOD0(lock_snapshot_buffer, std::shared_ptr<graphics::Buffer>());
2030
2031 MOCK_METHOD0(get_stream_pixel_format, MirPixelFormat());
2032
2033=== modified file 'include/test/mir_test_doubles/mock_display_buffer.h'
2034--- include/test/mir_test_doubles/mock_display_buffer.h 2014-03-06 06:05:17 +0000
2035+++ include/test/mir_test_doubles/mock_display_buffer.h 2014-04-02 18:58:27 +0000
2036@@ -46,7 +46,7 @@
2037 MOCK_METHOD0(release_current, void());
2038 MOCK_METHOD0(post_update, void());
2039 MOCK_CONST_METHOD0(can_bypass, bool());
2040- MOCK_METHOD2(render_and_post_update, void(std::list<std::shared_ptr<graphics::Renderable>> const&,
2041+ MOCK_METHOD2(render_and_post_update, void(graphics::RenderableList const&,
2042 std::function<void(graphics::Renderable const&)> const&));
2043 MOCK_CONST_METHOD0(orientation, MirOrientation());
2044 };
2045
2046=== modified file 'include/test/mir_test_doubles/mock_display_changer.h'
2047--- include/test/mir_test_doubles/mock_display_changer.h 2013-09-17 20:03:16 +0000
2048+++ include/test/mir_test_doubles/mock_display_changer.h 2014-04-02 18:58:27 +0000
2049@@ -35,7 +35,6 @@
2050 MOCK_METHOD0(active_configuration, std::shared_ptr<graphics::DisplayConfiguration>());
2051 MOCK_METHOD2(configure,
2052 void(std::shared_ptr<frontend::Session> const&, std::shared_ptr<graphics::DisplayConfiguration> const&));
2053- MOCK_METHOD1(ensure_display_powered, void(std::shared_ptr<frontend::Session> const&));
2054 };
2055
2056 }
2057
2058=== modified file 'include/test/mir_test_doubles/mock_display_device.h'
2059--- include/test/mir_test_doubles/mock_display_device.h 2014-03-11 13:44:57 +0000
2060+++ include/test/mir_test_doubles/mock_display_device.h 2014-04-02 18:58:27 +0000
2061@@ -38,7 +38,7 @@
2062 MOCK_METHOD1(render_gl, void(graphics::android::SwappingGLContext const&));
2063 MOCK_METHOD3(render_gl_and_overlays, void(
2064 graphics::android::SwappingGLContext const&,
2065- std::list<std::shared_ptr<graphics::Renderable>> const&,
2066+ graphics::RenderableList const&,
2067 std::function<void(graphics::Renderable const&)> const&));
2068 MOCK_METHOD1(post, void(graphics::Buffer const&));
2069 MOCK_CONST_METHOD1(apply_orientation, bool(MirOrientation));
2070
2071=== modified file 'include/test/mir_test_doubles/mock_egl.h'
2072--- include/test/mir_test_doubles/mock_egl.h 2014-03-06 06:05:17 +0000
2073+++ include/test/mir_test_doubles/mock_egl.h 2014-04-02 18:58:27 +0000
2074@@ -53,6 +53,33 @@
2075 return false;
2076 }
2077
2078+MATCHER_P2(EGLConfigContainsAttrib, attrib, value, "")
2079+{
2080+ bool attrib_position = true;
2081+ bool attrib_found = false;
2082+
2083+ while (!attrib_position || *arg != EGL_NONE)
2084+ {
2085+ if (attrib_position && *arg == attrib)
2086+ {
2087+ attrib_found = true;
2088+ }
2089+ else if (!attrib_position)
2090+ {
2091+ if (attrib_found && *arg == value)
2092+ {
2093+ return true;
2094+ }
2095+
2096+ attrib_found = false;
2097+ }
2098+ attrib_position = !attrib_position;
2099+ ++arg;
2100+ }
2101+
2102+ return false;
2103+}
2104+
2105 class MockEGL
2106 {
2107 public:
2108
2109=== added file 'include/test/mir_test_doubles/mock_gl_config.h'
2110--- include/test/mir_test_doubles/mock_gl_config.h 1970-01-01 00:00:00 +0000
2111+++ include/test/mir_test_doubles/mock_gl_config.h 2014-04-02 18:58:27 +0000
2112@@ -0,0 +1,43 @@
2113+/*
2114+ * Copyright © 2014 Canonical Ltd.
2115+ *
2116+ * This program is free software: you can redistribute it and/or modify it
2117+ * under the terms of the GNU General Public License version 3,
2118+ * as published by the Free Software Foundation.
2119+ *
2120+ * This program is distributed in the hope that it will be useful,
2121+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2122+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2123+ * GNU General Public License for more details.
2124+ *
2125+ * You should have received a copy of the GNU General Public License
2126+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2127+ *
2128+ * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
2129+ */
2130+
2131+#ifndef MIR_TEST_DOUBLES_MOCK_GL_CONFIG_H_
2132+#define MIR_TEST_DOUBLES_MOCK_GL_CONFIG_H_
2133+
2134+#include "mir/graphics/gl_config.h"
2135+
2136+#include <gmock/gmock.h>
2137+
2138+namespace mir
2139+{
2140+namespace test
2141+{
2142+namespace doubles
2143+{
2144+
2145+struct MockGLConfig : public graphics::GLConfig
2146+{
2147+ MOCK_CONST_METHOD0(depth_buffer_bits, int());
2148+ MOCK_CONST_METHOD0(stencil_buffer_bits, int());
2149+};
2150+
2151+}
2152+}
2153+}
2154+
2155+#endif /* MIR_TEST_DOUBLES_MOCK_GL_CONFIG_H_ */
2156
2157=== modified file 'include/test/mir_test_doubles/mock_hwc_composer_device_1.h'
2158--- include/test/mir_test_doubles/mock_hwc_composer_device_1.h 2014-03-06 06:05:17 +0000
2159+++ include/test/mir_test_doubles/mock_hwc_composer_device_1.h 2014-04-02 18:58:27 +0000
2160@@ -21,8 +21,6 @@
2161
2162 #include <hardware/hwcomposer.h>
2163 #include <gmock/gmock.h>
2164-#include <vector>
2165-#include <memory>
2166
2167 namespace mir
2168 {
2169@@ -37,16 +35,6 @@
2170 MockHWCComposerDevice1()
2171 {
2172 using namespace testing;
2173-
2174- primary_prepare = false;
2175- primary_set = false;
2176- external_prepare = false;
2177- external_set = false;
2178- virtual_prepare = false;
2179- virtual_set = false;
2180- fb_fence = -1;
2181- retire_fence = -1;
2182-
2183 common.version = HWC_DEVICE_API_VERSION_1_1;
2184
2185 registerProcs = hook_registerProcs;
2186@@ -56,91 +44,6 @@
2187 blank = hook_blank;
2188 getDisplayConfigs = hook_getDisplayConfigs;
2189 getDisplayAttributes = hook_getDisplayAttributes;
2190-
2191- ON_CALL(*this, set_interface(_,_,_))
2192- .WillByDefault(Invoke(this, &MockHWCComposerDevice1::save_last_set_arguments));
2193- ON_CALL(*this, prepare_interface(_,_,_))
2194- .WillByDefault(Invoke(this, &MockHWCComposerDevice1::save_last_prepare_arguments));
2195- }
2196-
2197- int save_args(hwc_display_contents_1_t* out, hwc_display_contents_1_t** in)
2198- {
2199- if ((nullptr == in) || (nullptr == *in))
2200- return -1;
2201-
2202- hwc_display_contents_1_t* primary_display = *in;
2203- memcpy(out, primary_display, sizeof(hwc_display_contents_1_t));
2204- return 0;
2205- }
2206-
2207- void hwc_set_return_fence(int fence)
2208- {
2209- fb_fence = fence;
2210- }
2211-
2212- void hwc_set_retire_fence(int fence)
2213- {
2214- retire_fence = fence;
2215- }
2216-
2217- int save_last_prepare_arguments(struct hwc_composer_device_1 *, size_t size, hwc_display_contents_1_t** displays)
2218- {
2219- if ((size == 0) || (!displays))
2220- return -1;
2221-
2222- switch (size)
2223- {
2224- case 3:
2225- virtual_prepare = (!!displays[2]);
2226- case 2:
2227- external_prepare = (!!displays[1]);
2228- case 1:
2229- primary_prepare = (!!displays[0]);
2230- for(auto i = 0u; i < displays[0]->numHwLayers; i++)
2231- {
2232- prepare_layerlist.push_back(displays[0]->hwLayers[i]);
2233- prepare_layerlist.back().visibleRegionScreen = {0, nullptr};
2234- }
2235- save_args(&display0_prepare_content, displays);
2236- default:
2237- break;
2238- }
2239- return 0;
2240- }
2241-
2242- int save_last_set_arguments(
2243- struct hwc_composer_device_1 *, size_t size, hwc_display_contents_1_t** displays)
2244- {
2245-
2246- if ((size == 0) || (!displays))
2247- return -1;
2248-
2249- switch (size)
2250- {
2251- case 3:
2252- virtual_set = (!!displays[2]);
2253- case 2:
2254- external_set = (!!displays[1]);
2255- case 1:
2256- primary_set = (!!displays[0]);
2257- for(auto i = 0u; i < displays[0]->numHwLayers; i++)
2258- {
2259- set_layerlist.push_back(displays[0]->hwLayers[i]);
2260- set_layerlist.back().visibleRegionScreen = {0, nullptr};
2261- }
2262-
2263- save_args(&display0_set_content, displays);
2264-
2265- if (displays[0]->numHwLayers >= 2)
2266- {
2267- displays[0]->hwLayers[1].releaseFenceFd = fb_fence;
2268- displays[0]->retireFenceFd = retire_fence;
2269- }
2270-
2271- default:
2272- break;
2273- }
2274- return 0;
2275 }
2276
2277 static void hook_registerProcs(struct hwc_composer_device_1* mock_hwc, hwc_procs_t const* procs)
2278@@ -188,14 +91,6 @@
2279 MOCK_METHOD3(blank_interface, int(struct hwc_composer_device_1 *, int, int));
2280 MOCK_METHOD4(getDisplayConfigs_interface, int(struct hwc_composer_device_1*, int, uint32_t*, size_t*));
2281 MOCK_METHOD5(getDisplayAttributes_interface, int(struct hwc_composer_device_1*, int, uint32_t, const uint32_t*, int32_t*));
2282-
2283- bool primary_prepare, primary_set, external_prepare, external_set, virtual_prepare, virtual_set;
2284- hwc_display_contents_1_t display0_set_content;
2285- std::vector<hwc_layer_1> set_layerlist;
2286- std::vector<hwc_layer_1> prepare_layerlist;
2287- hwc_display_contents_1_t display0_prepare_content;
2288- int fb_fence;
2289- int retire_fence;
2290 };
2291
2292 }
2293
2294=== added file 'include/test/mir_test_doubles/mock_hwc_device_wrapper.h'
2295--- include/test/mir_test_doubles/mock_hwc_device_wrapper.h 1970-01-01 00:00:00 +0000
2296+++ include/test/mir_test_doubles/mock_hwc_device_wrapper.h 2014-04-02 18:58:27 +0000
2297@@ -0,0 +1,42 @@
2298+/*
2299+ * Copyright © 2014 Canonical Ltd.
2300+ *
2301+ * This program is free software: you can redistribute it and/or modify it
2302+ * under the terms of the GNU General Public License version 3,
2303+ * as published by the Free Software Foundation.
2304+ *
2305+ * This program is distributed in the hope that it will be useful,
2306+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2307+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2308+ * GNU General Public License for more details.
2309+ *
2310+ * You should have received a copy of the GNU General Public License
2311+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2312+ *
2313+ * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
2314+ */
2315+
2316+#ifndef MIR_TEST_DOUBLES_MOCK_HWC_DEVICE_WRAPPER_H_
2317+#define MIR_TEST_DOUBLES_MOCK_HWC_DEVICE_WRAPPER_H_
2318+
2319+#include "src/platform/graphics/android/hwc_wrapper.h"
2320+
2321+#include <gmock/gmock.h>
2322+
2323+namespace mir
2324+{
2325+namespace test
2326+{
2327+namespace doubles
2328+{
2329+
2330+struct MockHWCDeviceWrapper : public graphics::android::HwcWrapper
2331+{
2332+ MOCK_CONST_METHOD1(prepare, void(hwc_display_contents_1_t&));
2333+ MOCK_CONST_METHOD1(set, void(hwc_display_contents_1_t&));
2334+};
2335+
2336+}
2337+}
2338+}
2339+#endif /* MIR_TEST_DOUBLES_MOCK_HWC_DEVICE_WRAPPER_H_ */
2340
2341=== modified file 'include/test/mir_test_doubles/mock_input_surface.h'
2342--- include/test/mir_test_doubles/mock_input_surface.h 2014-03-06 06:05:17 +0000
2343+++ include/test/mir_test_doubles/mock_input_surface.h 2014-04-02 18:58:27 +0000
2344@@ -43,12 +43,12 @@
2345 Return(geometry::Size{}));
2346 static std::string n;
2347 ON_CALL(*this, name())
2348- .WillByDefault(testing::ReturnRef(n));
2349+ .WillByDefault(testing::Return(n));
2350 }
2351 ~MockInputSurface() noexcept {}
2352 MOCK_CONST_METHOD0(top_left, geometry::Point());
2353 MOCK_CONST_METHOD0(size, geometry::Size());
2354- MOCK_CONST_METHOD0(name, std::string const&());
2355+ MOCK_CONST_METHOD0(name, std::string());
2356 MOCK_CONST_METHOD1(contains, bool(geometry::Point const&));
2357 };
2358
2359
2360=== modified file 'include/test/mir_test_doubles/mock_renderable.h'
2361--- include/test/mir_test_doubles/mock_renderable.h 2014-03-17 07:35:22 +0000
2362+++ include/test/mir_test_doubles/mock_renderable.h 2014-04-02 18:58:27 +0000
2363@@ -37,15 +37,24 @@
2364 .WillByDefault(testing::Return(geometry::Rectangle{{},{}}));
2365 ON_CALL(*this, buffer(testing::_))
2366 .WillByDefault(testing::Return(std::make_shared<StubBuffer>()));
2367+ ON_CALL(*this, buffers_ready_for_compositor())
2368+ .WillByDefault(testing::Return(1));
2369+ ON_CALL(*this, alpha())
2370+ .WillByDefault(testing::Return(1.0f));
2371+ ON_CALL(*this, transformation())
2372+ .WillByDefault(testing::Return(glm::mat4{}));
2373+ ON_CALL(*this, visible())
2374+ .WillByDefault(testing::Return(true));
2375 }
2376- MOCK_CONST_METHOD1(buffer, std::shared_ptr<graphics::Buffer>(unsigned long));
2377+
2378+ MOCK_CONST_METHOD1(buffer, std::shared_ptr<graphics::Buffer>(void const*));
2379 MOCK_CONST_METHOD0(alpha_enabled, bool());
2380 MOCK_CONST_METHOD0(screen_position, geometry::Rectangle());
2381 MOCK_CONST_METHOD0(alpha, float());
2382 MOCK_CONST_METHOD0(transformation, glm::mat4());
2383- MOCK_CONST_METHOD1(should_be_rendered_in, bool(geometry::Rectangle const& rect));
2384+ MOCK_CONST_METHOD0(visible, bool());
2385 MOCK_CONST_METHOD0(shaped, bool());
2386- int buffers_ready_for_compositor() const override { return 1; }
2387+ MOCK_CONST_METHOD0(buffers_ready_for_compositor, int());
2388 };
2389 }
2390 }
2391
2392=== modified file 'include/test/mir_test_doubles/mock_scene.h'
2393--- include/test/mir_test_doubles/mock_scene.h 2014-03-13 09:22:13 +0000
2394+++ include/test/mir_test_doubles/mock_scene.h 2014-04-02 18:58:27 +0000
2395@@ -32,10 +32,14 @@
2396 class MockScene : public compositor::Scene
2397 {
2398 public:
2399+ MockScene()
2400+ {
2401+ ON_CALL(*this, generate_renderable_list())
2402+ .WillByDefault(testing::Return(graphics::RenderableList{}));
2403+ }
2404+ MOCK_CONST_METHOD0(generate_renderable_list, graphics::RenderableList());
2405 MOCK_METHOD2(for_each_if, void(compositor::FilterForScene&,
2406 compositor::OperatorForScene&));
2407- MOCK_METHOD2(reverse_for_each_if, void(compositor::FilterForScene&,
2408- compositor::OperatorForScene&));
2409 MOCK_METHOD1(set_change_callback, void(std::function<void()> const&));
2410 MOCK_METHOD0(lock, void());
2411 MOCK_METHOD0(unlock, void());
2412
2413=== modified file 'include/test/mir_test_doubles/mock_surface.h'
2414--- include/test/mir_test_doubles/mock_surface.h 2014-03-06 06:05:17 +0000
2415+++ include/test/mir_test_doubles/mock_surface.h 2014-04-02 18:58:27 +0000
2416@@ -1,5 +1,5 @@
2417 /*
2418- * Copyright © 2013 Canonical Ltd.
2419+ * Copyright © 2013-2014 Canonical Ltd.
2420 *
2421 * This program is free software: you can redistribute it and/or modify it
2422 * under the terms of the GNU General Public License version 3,
2423@@ -19,16 +19,11 @@
2424 #ifndef MIR_TEST_DOUBLES_MOCK_SURFACE_H_
2425 #define MIR_TEST_DOUBLES_MOCK_SURFACE_H_
2426
2427-#include "src/server/scene/surface_impl.h"
2428-
2429-#include "mir/shell/surface_creation_parameters.h"
2430-#include "null_event_sink.h"
2431-#include "null_surface_configurator.h"
2432+#include "src/server/scene/basic_surface.h"
2433+#include "src/server/report/null_report_factory.h"
2434
2435 #include <gmock/gmock.h>
2436
2437-#include <memory>
2438-
2439 namespace mir
2440 {
2441 namespace test
2442@@ -36,10 +31,17 @@
2443 namespace doubles
2444 {
2445
2446-struct MockSurface : public scene::SurfaceImpl
2447+struct MockSurface : public scene::BasicSurface
2448 {
2449- MockSurface(std::shared_ptr<scene::SurfaceBuilder> const& builder) :
2450- scene::SurfaceImpl(builder, std::make_shared<NullSurfaceConfigurator>(), shell::a_surface(), frontend::SurfaceId{}, std::make_shared<NullEventSink>())
2451+ MockSurface() :
2452+ scene::BasicSurface(
2453+ {},
2454+ {{},{}},
2455+ true,
2456+ {},
2457+ {},
2458+ {},
2459+ mir::report::null_scene_report())
2460 {
2461 }
2462
2463@@ -53,7 +55,6 @@
2464 MOCK_METHOD0(force_requests_to_complete, void());
2465 MOCK_METHOD0(advance_client_buffer, std::shared_ptr<graphics::Buffer>());
2466
2467- MOCK_CONST_METHOD0(name, std::string());
2468 MOCK_CONST_METHOD0(size, geometry::Size());
2469 MOCK_CONST_METHOD0(pixel_format, MirPixelFormat());
2470
2471@@ -62,6 +63,7 @@
2472
2473 MOCK_METHOD2(configure, int(MirSurfaceAttrib, int));
2474 MOCK_METHOD1(take_input_focus, void(std::shared_ptr<shell::InputTargeter> const&));
2475+ MOCK_METHOD1(add_observer, void(std::shared_ptr<scene::SurfaceObserver> const&));
2476 };
2477
2478 }
2479
2480=== modified file 'include/test/mir_test_doubles/mock_surface_configurator.h'
2481--- include/test/mir_test_doubles/mock_surface_configurator.h 2013-07-31 23:09:53 +0000
2482+++ include/test/mir_test_doubles/mock_surface_configurator.h 2014-04-02 18:58:27 +0000
2483@@ -19,7 +19,7 @@
2484 #ifndef MIR_TEST_DOUBLES_MOCK_SURFACE_CONFIGURATOR_H_
2485 #define MIR_TEST_DOUBLES_MOCK_SURFACE_CONFIGURATOR_H_
2486
2487-#include "mir/shell/surface_configurator.h"
2488+#include "mir/scene/surface_configurator.h"
2489
2490 #include <gmock/gmock.h>
2491
2492@@ -30,10 +30,10 @@
2493 namespace doubles
2494 {
2495
2496-struct MockSurfaceConfigurator : public shell::SurfaceConfigurator
2497+struct MockSurfaceConfigurator : public scene::SurfaceConfigurator
2498 {
2499- MOCK_METHOD3(select_attribute_value, int(shell::Surface const&, MirSurfaceAttrib, int));
2500- MOCK_METHOD3(attribute_set, void(shell::Surface const&, MirSurfaceAttrib, int));
2501+ MOCK_METHOD3(select_attribute_value, int(scene::Surface const&, MirSurfaceAttrib, int));
2502+ MOCK_METHOD3(attribute_set, void(scene::Surface const&, MirSurfaceAttrib, int));
2503 };
2504
2505 }
2506
2507=== modified file 'include/test/mir_test_doubles/mock_surface_factory.h'
2508--- include/test/mir_test_doubles/mock_surface_factory.h 2013-08-28 03:41:48 +0000
2509+++ include/test/mir_test_doubles/mock_surface_factory.h 2014-04-02 18:58:27 +0000
2510@@ -33,11 +33,12 @@
2511
2512 struct MockSurfaceFactory : public shell::SurfaceFactory
2513 {
2514- MOCK_METHOD4(create_surface, std::shared_ptr<shell::Surface>(
2515+ MOCK_METHOD3(create_surface, std::shared_ptr<shell::Surface>(
2516 shell::Session*,
2517 const shell::SurfaceCreationParameters&,
2518- frontend::SurfaceId,
2519- std::shared_ptr<frontend::EventSink> const&));
2520+ std::shared_ptr<scene::SurfaceObserver> const&));
2521+
2522+ void destroy_surface(std::shared_ptr<shell::Surface> const& /*surface*/) override {}
2523 };
2524
2525 }
2526
2527=== modified file 'include/test/mir_test_doubles/mock_surface_ranker.h'
2528--- include/test/mir_test_doubles/mock_surface_ranker.h 2014-03-06 06:05:17 +0000
2529+++ include/test/mir_test_doubles/mock_surface_ranker.h 2014-04-02 18:58:27 +0000
2530@@ -20,7 +20,7 @@
2531 #ifndef MIR_TEST_DOUBLES_MOCK_SURFACE_RANKER_H_
2532 #define MIR_TEST_DOUBLES_MOCK_SURFACE_RANKER_H_
2533
2534-#include "src/server/scene/surface_ranker.h"
2535+#include "mir/scene/surface_ranker.h"
2536
2537 #include <gmock/gmock.h>
2538
2539@@ -33,7 +33,7 @@
2540
2541 struct MockSurfaceRanker : public scene::SurfaceRanker
2542 {
2543- MOCK_METHOD1(raise, void(std::weak_ptr<scene::BasicSurface> const&));
2544+ MOCK_METHOD1(raise, void(std::weak_ptr<scene::Surface> const&));
2545 };
2546
2547 }
2548
2549=== modified file 'include/test/mir_test_doubles/null_display_buffer.h'
2550--- include/test/mir_test_doubles/null_display_buffer.h 2014-03-06 06:05:17 +0000
2551+++ include/test/mir_test_doubles/null_display_buffer.h 2014-04-02 18:58:27 +0000
2552@@ -37,7 +37,7 @@
2553 void post_update() {}
2554 bool can_bypass() const override { return false; }
2555 void render_and_post_update(
2556- std::list<std::shared_ptr<graphics::Renderable>> const&,
2557+ graphics::RenderableList const&,
2558 std::function<void(graphics::Renderable const&)> const&) {}
2559 MirOrientation orientation() const override { return mir_orientation_normal; }
2560 };
2561
2562=== modified file 'include/test/mir_test_doubles/null_display_changer.h'
2563--- include/test/mir_test_doubles/null_display_changer.h 2013-09-17 20:03:16 +0000
2564+++ include/test/mir_test_doubles/null_display_changer.h 2014-04-02 18:58:27 +0000
2565@@ -39,9 +39,6 @@
2566 virtual void configure(std::shared_ptr<frontend::Session> const&, std::shared_ptr<graphics::DisplayConfiguration> const&)
2567 {
2568 }
2569- virtual void ensure_display_powered(std::shared_ptr<frontend::Session> const&)
2570- {
2571- }
2572 };
2573 }
2574 }
2575
2576=== modified file 'include/test/mir_test_doubles/null_platform.h'
2577--- include/test/mir_test_doubles/null_platform.h 2014-03-06 06:05:17 +0000
2578+++ include/test/mir_test_doubles/null_platform.h 2014-04-02 18:58:27 +0000
2579@@ -39,7 +39,8 @@
2580 }
2581
2582 std::shared_ptr<graphics::Display> create_display(
2583- std::shared_ptr<graphics::DisplayConfigurationPolicy> const&)
2584+ std::shared_ptr<graphics::DisplayConfigurationPolicy> const&,
2585+ std::shared_ptr<graphics::GLConfig> const&)
2586 {
2587 return std::make_shared<NullDisplay>();
2588 }
2589
2590=== modified file 'include/test/mir_test_doubles/null_surface_configurator.h'
2591--- include/test/mir_test_doubles/null_surface_configurator.h 2013-07-29 22:55:20 +0000
2592+++ include/test/mir_test_doubles/null_surface_configurator.h 2014-04-02 18:58:27 +0000
2593@@ -19,7 +19,7 @@
2594 #ifndef MIR_TEST_DOUBLES_NULL_SURFACE_CONFIGURATOR_H_
2595 #define MIR_TEST_DOUBLES_NULL_SURFACE_CONFIGURATOR_H_
2596
2597-#include "mir/shell/surface_configurator.h"
2598+#include "mir/scene/surface_configurator.h"
2599
2600 namespace mir
2601 {
2602@@ -28,14 +28,14 @@
2603 namespace doubles
2604 {
2605
2606-struct NullSurfaceConfigurator : public shell::SurfaceConfigurator
2607+struct NullSurfaceConfigurator : public scene::SurfaceConfigurator
2608 {
2609- int select_attribute_value(shell::Surface const&,
2610+ int select_attribute_value(scene::Surface const&,
2611 MirSurfaceAttrib, int requested_value)
2612 {
2613 return requested_value;
2614 }
2615- void attribute_set(shell::Surface const&,
2616+ void attribute_set(scene::Surface const&,
2617 MirSurfaceAttrib, int)
2618 {
2619 }
2620
2621=== modified file 'include/test/mir_test_doubles/stub_buffer_stream.h'
2622--- include/test/mir_test_doubles/stub_buffer_stream.h 2014-03-07 03:15:55 +0000
2623+++ include/test/mir_test_doubles/stub_buffer_stream.h 2014-04-02 18:58:27 +0000
2624@@ -40,7 +40,7 @@
2625 {
2626 complete(&stub_client_buffer);
2627 }
2628- std::shared_ptr<graphics::Buffer> lock_compositor_buffer(unsigned long) override
2629+ std::shared_ptr<graphics::Buffer> lock_compositor_buffer(void const*) override
2630 {
2631 return stub_compositor_buffer;
2632 }
2633
2634=== modified file 'include/test/mir_test_doubles/stub_display_builder.h'
2635--- include/test/mir_test_doubles/stub_display_builder.h 2014-03-06 06:05:17 +0000
2636+++ include/test/mir_test_doubles/stub_display_builder.h 2014-04-02 18:58:27 +0000
2637@@ -43,7 +43,7 @@
2638 void post_update() {}
2639 bool can_bypass() const override { return false; }
2640 void render_and_post_update(
2641- std::list<std::shared_ptr<graphics::Renderable>> const&,
2642+ graphics::RenderableList const&,
2643 std::function<void(graphics::Renderable const&)> const&) {}
2644 MirOrientation orientation() const override { return mir_orientation_normal; }
2645 void configure(graphics::DisplayConfigurationOutput const&) {}
2646
2647=== modified file 'include/test/mir_test_doubles/stub_display_device.h'
2648--- include/test/mir_test_doubles/stub_display_device.h 2014-03-11 13:44:57 +0000
2649+++ include/test/mir_test_doubles/stub_display_device.h 2014-04-02 18:58:27 +0000
2650@@ -40,7 +40,7 @@
2651 }
2652 void render_gl_and_overlays(
2653 graphics::android::SwappingGLContext const&,
2654- std::list<std::shared_ptr<graphics::Renderable>> const&,
2655+ graphics::RenderableList const&,
2656 std::function<void(graphics::Renderable const&)> const&)
2657 {
2658 }
2659
2660=== added file 'include/test/mir_test_doubles/stub_gl_config.h'
2661--- include/test/mir_test_doubles/stub_gl_config.h 1970-01-01 00:00:00 +0000
2662+++ include/test/mir_test_doubles/stub_gl_config.h 2014-04-02 18:58:27 +0000
2663@@ -0,0 +1,43 @@
2664+/*
2665+ * Copyright © 2014 Canonical Ltd.
2666+ *
2667+ * This program is free software: you can redistribute it and/or modify it
2668+ * under the terms of the GNU General Public License version 3,
2669+ * as published by the Free Software Foundation.
2670+ *
2671+ * This program is distributed in the hope that it will be useful,
2672+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2673+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2674+ * GNU General Public License for more details.
2675+ *
2676+ * You should have received a copy of the GNU General Public License
2677+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2678+ *
2679+ * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
2680+ */
2681+
2682+#ifndef MIR_TEST_DOUBLES_STUB_GL_CONFIG_H_
2683+#define MIR_TEST_DOUBLES_STUB_GL_CONFIG_H_
2684+
2685+#include "mir/graphics/gl_config.h"
2686+
2687+#include <gmock/gmock.h>
2688+
2689+namespace mir
2690+{
2691+namespace test
2692+{
2693+namespace doubles
2694+{
2695+
2696+struct StubGLConfig : public graphics::GLConfig
2697+{
2698+ int depth_buffer_bits() const override { return 0; }
2699+ int stencil_buffer_bits() const override { return 0; }
2700+};
2701+
2702+}
2703+}
2704+}
2705+
2706+#endif /* MIR_TEST_DOUBLES_STUB_GL_CONFIG_H_ */
2707
2708=== modified file 'include/test/mir_test_doubles/stub_ipc_factory.h'
2709--- include/test/mir_test_doubles/stub_ipc_factory.h 2014-03-06 06:05:17 +0000
2710+++ include/test/mir_test_doubles/stub_ipc_factory.h 2014-04-02 18:58:27 +0000
2711@@ -41,7 +41,7 @@
2712 }
2713
2714 std::shared_ptr<protobuf::DisplayServer> make_ipc_server(
2715- pid_t, std::shared_ptr<frontend::EventSink> const&, bool) override
2716+ pid_t, std::shared_ptr<frontend::EventSink> const&) override
2717 {
2718 return server;
2719 }
2720
2721=== modified file 'include/test/mir_test_doubles/stub_renderable.h'
2722--- include/test/mir_test_doubles/stub_renderable.h 2014-03-17 07:35:22 +0000
2723+++ include/test/mir_test_doubles/stub_renderable.h 2014-04-02 18:58:27 +0000
2724@@ -33,7 +33,7 @@
2725 class StubRenderable : public graphics::Renderable
2726 {
2727 public:
2728- std::shared_ptr<graphics::Buffer> buffer(unsigned long) const override
2729+ std::shared_ptr<graphics::Buffer> buffer(void const*) const override
2730 {
2731 return std::make_shared<StubBuffer>();
2732 }
2733@@ -53,7 +53,7 @@
2734 {
2735 return trans;
2736 }
2737- bool should_be_rendered_in(geometry::Rectangle const&) const override
2738+ bool visible() const
2739 {
2740 return true;
2741 }
2742
2743=== modified file 'include/test/mir_test_doubles/stub_session_authorizer.h'
2744--- include/test/mir_test_doubles/stub_session_authorizer.h 2013-08-28 03:41:48 +0000
2745+++ include/test/mir_test_doubles/stub_session_authorizer.h 2014-04-02 18:58:27 +0000
2746@@ -38,6 +38,10 @@
2747 {
2748 return true;
2749 }
2750+ bool screencast_is_allowed(pid_t)
2751+ {
2752+ return true;
2753+ }
2754 };
2755
2756 }
2757
2758=== removed file 'include/test/mir_test_doubles/stub_surface_builder.h'
2759--- include/test/mir_test_doubles/stub_surface_builder.h 2014-03-06 06:05:17 +0000
2760+++ include/test/mir_test_doubles/stub_surface_builder.h 1970-01-01 00:00:00 +0000
2761@@ -1,69 +0,0 @@
2762-/*
2763- * Copyright © 2013-2014 Canonical Ltd.
2764- *
2765- * This program is free software: you can redistribute it and/or modify it
2766- * under the terms of the GNU General Public License version 3,
2767- * as published by the Free Software Foundation.
2768- *
2769- * This program is distributed in the hope that it will be useful,
2770- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2771- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2772- * GNU General Public License for more details.
2773- *
2774- * You should have received a copy of the GNU General Public License
2775- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2776- *
2777- * Authored by: Alan Griffiths <alan@octopull.co.uk>
2778- */
2779-
2780-
2781-#ifndef MIR_TEST_DOUBLES_STUB_SURFACE_BUILDER_H_
2782-#define MIR_TEST_DOUBLES_STUB_SURFACE_BUILDER_H_
2783-
2784-#include "src/server/scene/surface_builder.h"
2785-#include "src/server/scene/basic_surface.h"
2786-#include "src/server/report/null_report_factory.h"
2787-#include "mir/shell/surface_creation_parameters.h"
2788-
2789-#include "mir_test_doubles/stub_buffer_stream.h"
2790-#include <memory>
2791-namespace mir
2792-{
2793-namespace test
2794-{
2795-namespace doubles
2796-{
2797-
2798-class StubSurfaceBuilder : public scene::SurfaceBuilder
2799-{
2800-public:
2801- StubSurfaceBuilder() :
2802- dummy_surface(std::make_shared<scene::BasicSurface>(
2803- std::string("stub"),
2804- geometry::Rectangle{{},{}},
2805- [](){},
2806- false,
2807- std::make_shared<StubBufferStream>(),
2808- std::shared_ptr<input::InputChannel>(),
2809- mir::report::null_scene_report()))
2810- {
2811- }
2812-
2813- std::weak_ptr<scene::BasicSurface> create_surface(shell::SurfaceCreationParameters const&)
2814- {
2815- return dummy_surface;
2816- }
2817-
2818- void destroy_surface(std::weak_ptr<scene::BasicSurface> const& )
2819- {
2820- }
2821-
2822-private:
2823- std::shared_ptr<scene::BasicSurface> dummy_surface;
2824-};
2825-}
2826-}
2827-}
2828-
2829-
2830-#endif /* MIR_TEST_DOUBLES_STUB_SURFACE_BUILDER_H_ */
2831
2832=== removed file 'include/test/mir_test_doubles/stub_surface_ranker.h'
2833--- include/test/mir_test_doubles/stub_surface_ranker.h 2014-03-06 06:05:17 +0000
2834+++ include/test/mir_test_doubles/stub_surface_ranker.h 1970-01-01 00:00:00 +0000
2835@@ -1,44 +0,0 @@
2836-/*
2837- * Copyright © 2013 Canonical Ltd.
2838- *
2839- * This program is free software: you can redistribute it and/or modify it
2840- * under the terms of the GNU General Public License version 3,
2841- * as published by the Free Software Foundation.
2842- *
2843- * This program is distributed in the hope that it will be useful,
2844- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2845- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2846- * GNU General Public License for more details.
2847- *
2848- * You should have received a copy of the GNU General Public License
2849- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2850- *
2851- * Authored by: Robert Carr <robert.carr@canonical.com>
2852- */
2853-
2854-
2855-#ifndef MIR_TEST_DOUBLES_STUB_SURFACE_RANKER_H_
2856-#define MIR_TEST_DOUBLES_STUB_SURFACE_RANKER_H_
2857-
2858-#include "src/server/scene/surface_ranker.h"
2859-
2860-namespace mir
2861-{
2862-namespace test
2863-{
2864-namespace doubles
2865-{
2866-
2867-struct StubSurfaceRanker : public scene::SurfaceRanker
2868-{
2869- void raise(std::weak_ptr<scene::BasicSurface> const&) override
2870- {
2871- }
2872-};
2873-
2874-}
2875-}
2876-}
2877-
2878-
2879-#endif /* MIR_TEST_DOUBLES_STUB_SURFACE_RANKER_H_ */
2880
2881=== added file 'include/test/mir_test_framework/declarative_placement_strategy.h'
2882--- include/test/mir_test_framework/declarative_placement_strategy.h 1970-01-01 00:00:00 +0000
2883+++ include/test/mir_test_framework/declarative_placement_strategy.h 2014-04-02 18:58:27 +0000
2884@@ -0,0 +1,64 @@
2885+/*
2886+ * Copyright © 2014 Canonical Ltd.
2887+ *
2888+ * This program is free software: you can redistribute it and/or modify it
2889+ * under the terms of the GNU General Public License version 3,
2890+ * as published by the Free Software Foundation.
2891+ *
2892+ * This program is distributed in the hope that it will be useful,
2893+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2894+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2895+ * GNU General Public License for more details.
2896+ *
2897+ * You should have received a copy of the GNU General Public License
2898+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2899+ *
2900+ * Authored by: Robert Carr <robert.carr@canonical.com>
2901+ */
2902+
2903+#ifndef MIR_TEST_FRAMEWORK_DECLARATIVE_PLACEMENT_STRATEGY_H_
2904+#define MIR_TEST_FRAMEWORK_DECLARATIVE_PLACEMENT_STRATEGY_H_
2905+
2906+#include "mir/shell/placement_strategy.h"
2907+#include "mir/geometry/rectangle.h"
2908+#include "mir/scene/depth_id.h"
2909+
2910+#include <memory>
2911+#include <map>
2912+#include <string>
2913+
2914+namespace mir_test_framework
2915+{
2916+typedef std::map<std::string, mir::geometry::Rectangle> SurfaceGeometries;
2917+typedef std::map<std::string, mir::scene::DepthId> SurfaceDepths;
2918+
2919+/// DeclarativePlacementStrategy is a test utility server component for specifying
2920+/// a static list of surface geometries and relative depths. Used, for example,
2921+/// in input tests where it is necessary to set up scenarios depending on
2922+/// multiple surfaces geometry and stacking.
2923+class DeclarativePlacementStrategy : public mir::shell::PlacementStrategy
2924+{
2925+ public:
2926+ // Placement requests will be passed through to default strategy, and then overriden if the surface appears
2927+ // in the geometry or depth map. This allows for the convenience of leaving some surfaces geometries unspecified
2928+ // and receiving the default behavior.
2929+ DeclarativePlacementStrategy(std::shared_ptr<mir::shell::PlacementStrategy> const& default_strategy,
2930+ SurfaceGeometries const& positions_by_name, SurfaceDepths const& depths_by_name);
2931+
2932+ virtual ~DeclarativePlacementStrategy() = default;
2933+
2934+ mir::shell::SurfaceCreationParameters place(mir::shell::Session const& session, mir::shell::SurfaceCreationParameters const& request_parameters) override;
2935+
2936+protected:
2937+ DeclarativePlacementStrategy(const DeclarativePlacementStrategy&) = delete;
2938+ DeclarativePlacementStrategy& operator=(const DeclarativePlacementStrategy&) = delete;
2939+
2940+private:
2941+ std::shared_ptr<mir::shell::PlacementStrategy> const default_strategy;
2942+
2943+ SurfaceGeometries surface_geometries_by_name;
2944+ SurfaceDepths surface_depths_by_name;
2945+};
2946+}
2947+
2948+#endif // MIR_TEST_FRAMEWORK_DECLARATIVE_PLACEMENT_STRATEGY_H_
2949
2950=== modified file 'include/test/mir_test_framework/udev_environment.h'
2951--- include/test/mir_test_framework/udev_environment.h 2014-03-06 06:05:17 +0000
2952+++ include/test/mir_test_framework/udev_environment.h 2014-04-02 18:58:27 +0000
2953@@ -56,6 +56,7 @@
2954 void add_standard_device(std::string const& name);
2955
2956 UMockdevTestbed *testbed;
2957+ std::string const recordings_path;
2958 };
2959
2960 }
2961
2962=== modified file 'src/client/default_connection_configuration.cpp'
2963--- src/client/default_connection_configuration.cpp 2014-03-06 06:05:17 +0000
2964+++ src/client/default_connection_configuration.cpp 2014-04-02 18:58:27 +0000
2965@@ -103,7 +103,7 @@
2966 {
2967 auto const val_raw = getenv("MIR_CLIENT_PLATFORM_LIB");
2968 std::string const val{val_raw ? val_raw : default_platform_lib};
2969- auto const platform_lib = load_library(val);
2970+ auto const platform_lib = ::load_library(val);
2971
2972 auto const create_client_platform_factory =
2973 platform_lib->load_function<mcl::CreateClientPlatformFactory>(
2974
2975=== modified file 'src/client/lttng/input_receiver_report_tp.h'
2976--- src/client/lttng/input_receiver_report_tp.h 2014-02-03 11:44:32 +0000
2977+++ src/client/lttng/input_receiver_report_tp.h 2014-04-02 18:58:27 +0000
2978@@ -26,6 +26,7 @@
2979 #define MIR_CLIENT_LTTNG_INPUT_RECEIVER_REPORT_TP_H_
2980
2981 #include <lttng/tracepoint.h>
2982+#include <stdint.h>
2983
2984 #ifdef __clang__
2985 /*
2986
2987=== modified file 'src/client/lttng/rpc_report_tp.h'
2988--- src/client/lttng/rpc_report_tp.h 2014-03-06 06:05:17 +0000
2989+++ src/client/lttng/rpc_report_tp.h 2014-04-02 18:58:27 +0000
2990@@ -26,6 +26,7 @@
2991 #define MIR_CLIENT_LTTNG_RPC_REPORT_TP_H_
2992
2993 #include <lttng/tracepoint.h>
2994+#include <stdint.h>
2995
2996 #ifdef __clang__
2997 /*
2998
2999=== modified file 'src/client/mir_client_library.cpp'
3000--- src/client/mir_client_library.cpp 2014-03-06 06:05:17 +0000
3001+++ src/client/mir_client_library.cpp 2014-04-02 18:58:27 +0000
3002@@ -120,8 +120,17 @@
3003 {
3004 if (!error_connections.contains(connection))
3005 {
3006- auto wait_handle = connection->disconnect();
3007- wait_handle->wait_for_all();
3008+ try
3009+ {
3010+ auto wait_handle = connection->disconnect();
3011+ wait_handle->wait_for_all();
3012+ }
3013+ catch (std::exception const&)
3014+ {
3015+ // We're implementing a C API so no exceptions are to be
3016+ // propagated. And that's OK because if disconnect() fails,
3017+ // we don't care why. We're finished with the connection anyway.
3018+ }
3019 }
3020 else
3021 {
3022
3023=== modified file 'src/client/rpc/mir_basic_rpc_channel.cpp'
3024--- src/client/rpc/mir_basic_rpc_channel.cpp 2014-03-06 06:05:17 +0000
3025+++ src/client/rpc/mir_basic_rpc_channel.cpp 2014-04-02 18:58:27 +0000
3026@@ -34,7 +34,7 @@
3027 }
3028
3029 void mclrd::PendingCallCache::save_completion_details(
3030- mir::protobuf::wire::Invocation& invoke,
3031+ mir::protobuf::wire::Invocation const& invoke,
3032 google::protobuf::Message* response,
3033 std::shared_ptr<google::protobuf::Closure> const& complete)
3034 {
3035@@ -102,8 +102,8 @@
3036
3037
3038 mir::protobuf::wire::Invocation mclr::MirBasicRpcChannel::invocation_for(
3039- const google::protobuf::MethodDescriptor* method,
3040- const google::protobuf::Message* request)
3041+ google::protobuf::MethodDescriptor const* method,
3042+ google::protobuf::Message const* request)
3043 {
3044 char buffer[mir::frontend::serialization_buffer_size];
3045
3046
3047=== modified file 'src/client/rpc/mir_basic_rpc_channel.h'
3048--- src/client/rpc/mir_basic_rpc_channel.h 2014-03-06 06:05:17 +0000
3049+++ src/client/rpc/mir_basic_rpc_channel.h 2014-04-02 18:58:27 +0000
3050@@ -55,7 +55,7 @@
3051 PendingCallCache(std::shared_ptr<RpcReport> const& rpc_report);
3052
3053 void save_completion_details(
3054- mir::protobuf::wire::Invocation& invoke,
3055+ mir::protobuf::wire::Invocation const& invoke,
3056 google::protobuf::Message* response,
3057 std::shared_ptr<google::protobuf::Closure> const& complete);
3058
3059@@ -95,8 +95,9 @@
3060 ~MirBasicRpcChannel();
3061
3062 protected:
3063- mir::protobuf::wire::Invocation invocation_for(const google::protobuf::MethodDescriptor* method,
3064- const google::protobuf::Message* request);
3065+ mir::protobuf::wire::Invocation invocation_for(
3066+ google::protobuf::MethodDescriptor const* method,
3067+ google::protobuf::Message const* request);
3068 int next_id();
3069
3070 private:
3071
3072=== modified file 'src/client/rpc/mir_socket_rpc_channel.cpp'
3073--- src/client/rpc/mir_socket_rpc_channel.cpp 2014-03-06 06:05:17 +0000
3074+++ src/client/rpc/mir_socket_rpc_channel.cpp 2014-04-02 18:58:27 +0000
3075@@ -142,8 +142,39 @@
3076 {
3077 if (!disconnected.load())
3078 {
3079- auto surface = dynamic_cast<mir::protobuf::Surface*>(response);
3080- mir::protobuf::Screencast* screencast{nullptr};
3081+ auto const message_type = response->GetTypeName();
3082+
3083+ mir::protobuf::Surface* surface = nullptr;
3084+ mir::protobuf::Buffer* buffer = nullptr;
3085+ mir::protobuf::Platform* platform = nullptr;
3086+
3087+ if (message_type == "mir.protobuf.Buffer")
3088+ {
3089+ buffer = static_cast<mir::protobuf::Buffer*>(response);
3090+ }
3091+ else if (message_type == "mir.protobuf.Surface")
3092+ {
3093+ surface = static_cast<mir::protobuf::Surface*>(response);
3094+ if (surface && surface->has_buffer())
3095+ buffer = surface->mutable_buffer();
3096+ }
3097+ else if (message_type == "mir.protobuf.Screencast")
3098+ {
3099+ auto screencast = static_cast<mir::protobuf::Screencast*>(response);
3100+ if (screencast && screencast->has_buffer())
3101+ buffer = screencast->mutable_buffer();
3102+ }
3103+ else if (message_type == "mir.protobuf.Platform")
3104+ {
3105+ platform = static_cast<mir::protobuf::Platform*>(response);
3106+ }
3107+ else if (message_type == "mir.protobuf.Connection")
3108+ {
3109+ auto connection = static_cast<mir::protobuf::Connection*>(response);
3110+ if (connection && connection->has_platform())
3111+ platform = connection->mutable_platform();
3112+ }
3113+
3114 if (surface)
3115 {
3116 surface->clear_fd();
3117@@ -158,19 +189,6 @@
3118 rpc_report->file_descriptors_received(*response, fds);
3119 }
3120 }
3121- else
3122- {
3123- screencast = dynamic_cast<mir::protobuf::Screencast*>(response);
3124- }
3125-
3126- auto buffer = dynamic_cast<mir::protobuf::Buffer*>(response);
3127- if (!buffer)
3128- {
3129- if (surface && surface->has_buffer())
3130- buffer = surface->mutable_buffer();
3131- else if (screencast && screencast->has_buffer())
3132- buffer = screencast->mutable_buffer();
3133- }
3134
3135 if (buffer)
3136 {
3137@@ -187,14 +205,6 @@
3138 }
3139 }
3140
3141- auto platform = dynamic_cast<mir::protobuf::Platform*>(response);
3142- if (!platform)
3143- {
3144- auto connection = dynamic_cast<mir::protobuf::Connection*>(response);
3145- if (connection && connection->has_platform())
3146- platform = connection->mutable_platform();
3147- }
3148-
3149 if (platform)
3150 {
3151 platform->clear_fd();
3152@@ -266,7 +276,7 @@
3153 google::protobuf::Message* response,
3154 google::protobuf::Closure* complete)
3155 {
3156- mir::protobuf::wire::Invocation invocation = invocation_for(method, parameters);
3157+ auto const& invocation = invocation_for(method, parameters);
3158
3159 rpc_report->invocation_requested(invocation);
3160
3161@@ -345,7 +355,7 @@
3162 {
3163 const size_t body_size = read_message_header();
3164
3165- result = read_message_body(body_size);
3166+ read_message_body(result, body_size);
3167
3168 rpc_report->result_receipt_succeeded(result);
3169 }
3170@@ -431,18 +441,17 @@
3171 return body_size;
3172 }
3173
3174-mir::protobuf::wire::Result mclr::MirSocketRpcChannel::read_message_body(const size_t body_size)
3175+void mclr::MirSocketRpcChannel::read_message_body(
3176+ mir::protobuf::wire::Result& result,
3177+ size_t const body_size)
3178 {
3179 boost::system::error_code error;
3180- boost::asio::streambuf message;
3181- boost::asio::read(socket, message, boost::asio::transfer_exactly(body_size), error);
3182+ body_bytes.resize(body_size);
3183+ boost::asio::read(socket, boost::asio::buffer(body_bytes), error);
3184 if (error)
3185 {
3186 BOOST_THROW_EXCEPTION(std::runtime_error("Failed to read message body: " + error.message()));
3187 }
3188
3189- std::istream in(&message);
3190- mir::protobuf::wire::Result result;
3191- result.ParseFromIstream(&in);
3192- return result;
3193+ result.ParseFromArray(body_bytes.data(), body_size);
3194 }
3195
3196=== modified file 'src/client/rpc/mir_socket_rpc_channel.h'
3197--- src/client/rpc/mir_socket_rpc_channel.h 2014-03-06 06:05:17 +0000
3198+++ src/client/rpc/mir_socket_rpc_channel.h 2014-04-02 18:58:27 +0000
3199@@ -80,6 +80,7 @@
3200
3201 static size_t const size_of_header = 2;
3202 unsigned char header_bytes[size_of_header];
3203+ std::vector<char> body_bytes;
3204
3205 void receive_file_descriptors(google::protobuf::Message* response, google::protobuf::Closure* complete);
3206 void receive_file_descriptors(std::vector<int> &fds);
3207@@ -92,7 +93,8 @@
3208
3209 size_t read_message_header();
3210
3211- mir::protobuf::wire::Result read_message_body(const size_t body_size);
3212+ void read_message_body(mir::protobuf::wire::Result& result,
3213+ size_t const body_size);
3214 void notify_disconnected();
3215
3216 std::shared_ptr<SurfaceMap> surface_map;
3217
3218=== modified file 'src/platform/CMakeLists.txt'
3219--- src/platform/CMakeLists.txt 2014-03-06 06:05:17 +0000
3220+++ src/platform/CMakeLists.txt 2014-04-02 18:58:27 +0000
3221@@ -3,13 +3,14 @@
3222
3223 add_library(
3224 mirplatform SHARED
3225-
3226+ shared_library_loader.cpp
3227 udev_wrapper.cpp
3228 )
3229
3230 target_link_libraries(
3231 mirplatform
3232 mirplatformgraphicscommon
3233+ mirsharedsharedlibrary
3234
3235 ${UDEV_LDFLAGS} ${UDEV_LIBRARIES}
3236 )
3237
3238=== modified file 'src/platform/graphics/android/CMakeLists.txt'
3239--- src/platform/graphics/android/CMakeLists.txt 2014-03-11 13:44:57 +0000
3240+++ src/platform/graphics/android/CMakeLists.txt 2014-04-02 18:58:27 +0000
3241@@ -20,6 +20,7 @@
3242 hwc_layerlist.cpp
3243 hwc_layers.cpp
3244 hwc_fb_device.cpp
3245+ hwc_formatted_logger.cpp
3246 hwc_device.cpp
3247 hwc_common_device.cpp
3248 hwc_vsync.cpp
3249@@ -44,9 +45,12 @@
3250 target_link_libraries(
3251 mirplatformgraphicsandroid
3252
3253+ miroptions
3254 mirplatform
3255 mirsharedandroid
3256+ mirsharedenv
3257
3258+ ${Boost_LIBRARIES}
3259 ${LIBHARDWARE_LIBRARIES}
3260 ${EGL_LDFLAGS} ${EGL_LIBRARIES}
3261 ${GLESv2_LDFLAGS} ${GLESv2_LIBRARIES}
3262
3263=== modified file 'src/platform/graphics/android/android_display.cpp'
3264--- src/platform/graphics/android/android_display.cpp 2014-03-17 07:35:22 +0000
3265+++ src/platform/graphics/android/android_display.cpp 2014-04-02 18:58:27 +0000
3266@@ -33,9 +33,10 @@
3267 namespace geom=mir::geometry;
3268
3269 mga::AndroidDisplay::AndroidDisplay(std::shared_ptr<mga::DisplayBuilder> const& display_builder,
3270+ std::shared_ptr<GLConfig> const& gl_config,
3271 std::shared_ptr<DisplayReport> const& display_report)
3272 : display_builder{display_builder},
3273- gl_context{display_builder->display_format(), *display_report},
3274+ gl_context{display_builder->display_format(), *gl_config, *display_report},
3275 display_buffer{display_builder->create_display_buffer(gl_context)}
3276 {
3277 display_report->report_successful_setup_of_native_resources();
3278
3279=== modified file 'src/platform/graphics/android/android_display.h'
3280--- src/platform/graphics/android/android_display.h 2014-03-06 06:05:17 +0000
3281+++ src/platform/graphics/android/android_display.h 2014-04-02 18:58:27 +0000
3282@@ -30,6 +30,7 @@
3283 {
3284
3285 class DisplayReport;
3286+class GLConfig;
3287
3288 namespace android
3289 {
3290@@ -41,6 +42,7 @@
3291 {
3292 public:
3293 explicit AndroidDisplay(std::shared_ptr<DisplayBuilder> const& display_builder,
3294+ std::shared_ptr<GLConfig> const& gl_config,
3295 std::shared_ptr<DisplayReport> const& display_report);
3296
3297 void for_each_display_buffer(std::function<void(graphics::DisplayBuffer&)> const& f);
3298
3299=== modified file 'src/platform/graphics/android/android_platform.cpp'
3300--- src/platform/graphics/android/android_platform.cpp 2014-03-06 06:05:17 +0000
3301+++ src/platform/graphics/android/android_platform.cpp 2014-04-02 18:58:27 +0000
3302@@ -31,6 +31,8 @@
3303 #include "mir/graphics/buffer_ipc_packer.h"
3304 #include "mir/graphics/display_report.h"
3305 #include "mir/options/option.h"
3306+#include "mir/options/configuration.h"
3307+#include "mir/abnormal_exit.h"
3308
3309 #include <boost/throw_exception.hpp>
3310 #include <stdexcept>
3311@@ -40,6 +42,26 @@
3312 namespace mf=mir::frontend;
3313 namespace mo = mir::options;
3314
3315+namespace
3316+{
3317+char const* const hwc_log_opt = "hwc-report";
3318+bool should_log_hwc(mo::Option const& options)
3319+{
3320+ if (!options.is_set(hwc_log_opt))
3321+ return false;
3322+
3323+ auto opt = options.get<std::string>(hwc_log_opt);
3324+ if (opt == mo::log_opt_value)
3325+ return true;
3326+ else if (opt == mo::off_opt_value)
3327+ return false;
3328+ else
3329+ throw mir::AbnormalExit(
3330+ std::string("Invalid hwc-report option: " + opt + " (valid options are: \"" +
3331+ mo::off_opt_value + "\" and \"" + mo::log_opt_value + "\")"));
3332+}
3333+}
3334+
3335 mga::AndroidPlatform::AndroidPlatform(
3336 std::shared_ptr<mga::DisplayBuilder> const& display_builder,
3337 std::shared_ptr<mg::DisplayReport> const& display_report)
3338@@ -61,9 +83,11 @@
3339 }
3340
3341 std::shared_ptr<mg::Display> mga::AndroidPlatform::create_display(
3342- std::shared_ptr<graphics::DisplayConfigurationPolicy> const&)
3343+ std::shared_ptr<graphics::DisplayConfigurationPolicy> const&,
3344+ std::shared_ptr<mg::GLConfig> const& gl_config)
3345 {
3346- return std::make_shared<mga::AndroidDisplay>(display_builder, display_report);
3347+ return std::make_shared<mga::AndroidDisplay>(
3348+ display_builder, gl_config, display_report);
3349 }
3350
3351 std::shared_ptr<mg::PlatformIPCPackage> mga::AndroidPlatform::get_ipc_package()
3352@@ -105,10 +129,10 @@
3353 return std::make_shared<mga::InternalClient>();
3354 }
3355
3356-extern "C" std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<mo::Option> const& /*options*/, std::shared_ptr<DisplayReport> const& display_report)
3357+extern "C" std::shared_ptr<mg::Platform> mg::create_platform(std::shared_ptr<mo::Option> const& options, std::shared_ptr<DisplayReport> const& display_report)
3358 {
3359 auto buffer_initializer = std::make_shared<mg::NullBufferInitializer>();
3360- auto display_resource_factory = std::make_shared<mga::ResourceFactory>();
3361+ auto display_resource_factory = std::make_shared<mga::ResourceFactory>(should_log_hwc(*options));
3362 auto fb_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(buffer_initializer);
3363 auto display_builder = std::make_shared<mga::OutputBuilder>(
3364 fb_allocator, display_resource_factory, display_report);
3365@@ -121,3 +145,12 @@
3366 // mg::NativePlatform cannot create a display anyways, so it doesnt need a display builder
3367 return std::make_shared<mga::AndroidPlatform>(nullptr, display_report);
3368 }
3369+
3370+extern "C" void add_platform_options(
3371+ boost::program_options::options_description& config)
3372+{
3373+ config.add_options()
3374+ (hwc_log_opt,
3375+ boost::program_options::value<std::string>()->default_value(std::string{mo::off_opt_value}),
3376+ "[platform-specific] How to handle the HWC logging report. [{log,off}]");
3377+}
3378
3379=== modified file 'src/platform/graphics/android/android_platform.h'
3380--- src/platform/graphics/android/android_platform.h 2014-03-06 06:05:17 +0000
3381+++ src/platform/graphics/android/android_platform.h 2014-04-02 18:58:27 +0000
3382@@ -44,7 +44,8 @@
3383 std::shared_ptr<graphics::GraphicBufferAllocator> create_buffer_allocator(
3384 std::shared_ptr<BufferInitializer> const& buffer_initializer);
3385 std::shared_ptr<Display> create_display(
3386- std::shared_ptr<graphics::DisplayConfigurationPolicy> const&);
3387+ std::shared_ptr<graphics::DisplayConfigurationPolicy> const&,
3388+ std::shared_ptr<graphics::GLConfig> const& /*gl_config*/);
3389 std::shared_ptr<PlatformIPCPackage> get_ipc_package();
3390 std::shared_ptr<InternalClient> create_internal_client();
3391 void fill_ipc_package(BufferIPCPacker* packer, graphics::Buffer const* buffer) const;
3392
3393=== modified file 'src/platform/graphics/android/display_buffer.cpp'
3394--- src/platform/graphics/android/display_buffer.cpp 2014-03-11 13:44:57 +0000
3395+++ src/platform/graphics/android/display_buffer.cpp 2014-04-02 18:58:27 +0000
3396@@ -85,7 +85,7 @@
3397 }
3398
3399 void mga::DisplayBuffer::render_and_post_update(
3400- std::list<std::shared_ptr<Renderable>> const& renderlist,
3401+ RenderableList const& renderlist,
3402 std::function<void(Renderable const&)> const& render_fn)
3403 {
3404 if (renderlist.empty())
3405
3406=== modified file 'src/platform/graphics/android/display_buffer.h'
3407--- src/platform/graphics/android/display_buffer.h 2014-03-11 13:44:57 +0000
3408+++ src/platform/graphics/android/display_buffer.h 2014-04-02 18:58:27 +0000
3409@@ -50,7 +50,7 @@
3410 bool can_bypass() const override;
3411
3412 void render_and_post_update(
3413- std::list<std::shared_ptr<Renderable>> const& renderlist,
3414+ RenderableList const& renderlist,
3415 std::function<void(Renderable const&)> const& render_fn);
3416 MirOrientation orientation() const override;
3417
3418
3419=== modified file 'src/platform/graphics/android/display_device.h'
3420--- src/platform/graphics/android/display_device.h 2014-03-11 13:44:57 +0000
3421+++ src/platform/graphics/android/display_device.h 2014-04-02 18:58:27 +0000
3422@@ -44,7 +44,7 @@
3423 virtual void render_gl(SwappingGLContext const& context) = 0;
3424 virtual void render_gl_and_overlays(
3425 SwappingGLContext const& context,
3426- std::list<std::shared_ptr<Renderable>> const& list,
3427+ RenderableList const& list,
3428 std::function<void(Renderable const&)> const& render_fn) = 0;
3429 virtual void post(Buffer const& buffer) = 0;
3430 virtual bool apply_orientation(MirOrientation orientation) const = 0;
3431
3432=== modified file 'src/platform/graphics/android/fb_device.cpp'
3433--- src/platform/graphics/android/fb_device.cpp 2014-03-11 13:44:57 +0000
3434+++ src/platform/graphics/android/fb_device.cpp 2014-04-02 18:58:27 +0000
3435@@ -51,7 +51,7 @@
3436
3437 void mga::FBDevice::render_gl_and_overlays(
3438 SwappingGLContext const& context,
3439- std::list<std::shared_ptr<Renderable>> const& renderables,
3440+ RenderableList const& renderables,
3441 std::function<void(Renderable const&)> const& render_fn)
3442 {
3443 for(auto const& renderable : renderables)
3444
3445=== modified file 'src/platform/graphics/android/fb_device.h'
3446--- src/platform/graphics/android/fb_device.h 2014-03-11 13:44:57 +0000
3447+++ src/platform/graphics/android/fb_device.h 2014-04-02 18:58:27 +0000
3448@@ -40,7 +40,7 @@
3449 virtual void render_gl(SwappingGLContext const& context);
3450 virtual void render_gl_and_overlays(
3451 SwappingGLContext const& context,
3452- std::list<std::shared_ptr<Renderable>> const& list,
3453+ RenderableList const& list,
3454 std::function<void(Renderable const&)> const& render_fn);
3455 void post(Buffer const& buffer);
3456
3457
3458=== modified file 'src/platform/graphics/android/gl_context.cpp'
3459--- src/platform/graphics/android/gl_context.cpp 2014-03-12 02:46:58 +0000
3460+++ src/platform/graphics/android/gl_context.cpp 2014-04-02 18:58:27 +0000
3461@@ -19,6 +19,7 @@
3462 #include "gl_context.h"
3463 #include "android_format_conversion-inl.h"
3464 #include "mir/graphics/display_report.h"
3465+#include "mir/graphics/gl_config.h"
3466
3467 #include <algorithm>
3468 #include <boost/throw_exception.hpp>
3469@@ -31,13 +32,6 @@
3470 namespace
3471 {
3472
3473-static EGLint const required_egl_config_attr [] =
3474-{
3475- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
3476- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
3477- EGL_NONE
3478-};
3479-
3480 static EGLint const default_egl_context_attr[] =
3481 {
3482 EGL_CONTEXT_CLIENT_VERSION, 2,
3483@@ -69,8 +63,19 @@
3484
3485 /* the minimum requirement is to have EGL_WINDOW_BIT and EGL_OPENGL_ES2_BIT, and to select a config
3486 whose pixel format matches that of the framebuffer. */
3487-static EGLConfig select_egl_config_with_format(EGLDisplay egl_display, MirPixelFormat display_format)
3488+EGLConfig select_egl_config_with_format(
3489+ EGLDisplay egl_display, MirPixelFormat display_format,
3490+ mg::GLConfig const& gl_config)
3491 {
3492+ EGLint const required_egl_config_attr [] =
3493+ {
3494+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
3495+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
3496+ EGL_DEPTH_SIZE, gl_config.depth_buffer_bits(),
3497+ EGL_STENCIL_SIZE, gl_config.stencil_buffer_bits(),
3498+ EGL_NONE
3499+ };
3500+
3501 int required_visual_id = mga::to_android_format(display_format);
3502 int num_potential_configs;
3503 EGLint num_match_configs;
3504@@ -107,10 +112,12 @@
3505 return eglCreateWindowSurface(disp, config, native, NULL);
3506 }
3507
3508-mga::GLContext::GLContext(MirPixelFormat display_format, mg::DisplayReport& report)
3509+mga::GLContext::GLContext(MirPixelFormat display_format,
3510+ mg::GLConfig const& gl_config,
3511+ mg::DisplayReport& report)
3512 : egl_display(create_and_initialize_display()),
3513 own_display(true),
3514- egl_config(select_egl_config_with_format(egl_display, display_format)),
3515+ egl_config(select_egl_config_with_format(egl_display, display_format, gl_config)),
3516 egl_context{egl_display,
3517 eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, default_egl_context_attr)},
3518 egl_surface{egl_display,
3519
3520=== modified file 'src/platform/graphics/android/gl_context.h'
3521--- src/platform/graphics/android/gl_context.h 2014-03-12 02:46:58 +0000
3522+++ src/platform/graphics/android/gl_context.h 2014-04-02 18:58:27 +0000
3523@@ -29,6 +29,7 @@
3524 namespace graphics
3525 {
3526 class DisplayReport;
3527+class GLConfig;
3528 namespace android
3529 {
3530
3531@@ -53,7 +54,9 @@
3532 {
3533 public:
3534 //For creating a gl context
3535- GLContext(MirPixelFormat display_format, DisplayReport& report);
3536+ GLContext(MirPixelFormat display_format,
3537+ GLConfig const& gl_config,
3538+ DisplayReport& report);
3539
3540 //For creating a gl context shared with another GLContext
3541 GLContext(GLContext const& shared_gl_context,
3542
3543=== modified file 'src/platform/graphics/android/hwc_common_device.cpp'
3544--- src/platform/graphics/android/hwc_common_device.cpp 2014-03-11 13:44:57 +0000
3545+++ src/platform/graphics/android/hwc_common_device.cpp 2014-04-02 18:58:27 +0000
3546@@ -44,8 +44,8 @@
3547
3548 mga::HWCCommonDevice::HWCCommonDevice(std::shared_ptr<hwc_composer_device_1> const& hwc_device,
3549 std::shared_ptr<mga::HWCVsyncCoordinator> const& coordinator)
3550- : hwc_device(hwc_device),
3551- coordinator(coordinator),
3552+ : coordinator(coordinator),
3553+ hwc_device(hwc_device),
3554 current_mode(mir_power_mode_on)
3555 {
3556 callbacks.hooks.invalidate = invalidate_hook;
3557
3558=== modified file 'src/platform/graphics/android/hwc_common_device.h'
3559--- src/platform/graphics/android/hwc_common_device.h 2014-03-06 06:05:17 +0000
3560+++ src/platform/graphics/android/hwc_common_device.h 2014-04-02 18:58:27 +0000
3561@@ -54,7 +54,6 @@
3562 HWCCommonDevice(std::shared_ptr<hwc_composer_device_1> const& hwc_device,
3563 std::shared_ptr<HWCVsyncCoordinator> const& coordinator);
3564
3565- std::shared_ptr<hwc_composer_device_1> const hwc_device;
3566 std::shared_ptr<HWCVsyncCoordinator> const coordinator;
3567 std::unique_lock<std::mutex> lock_unblanked();
3568
3569@@ -64,6 +63,8 @@
3570
3571 HWCCallbacks callbacks;
3572
3573+ std::shared_ptr<hwc_composer_device_1> const hwc_device;
3574+
3575 std::mutex blanked_mutex;
3576 std::condition_variable blanked_cond;
3577 MirPowerMode current_mode;
3578
3579=== modified file 'src/platform/graphics/android/hwc_device.cpp'
3580--- src/platform/graphics/android/hwc_device.cpp 2014-03-11 13:44:57 +0000
3581+++ src/platform/graphics/android/hwc_device.cpp 2014-04-02 18:58:27 +0000
3582@@ -21,6 +21,7 @@
3583 #include "hwc_device.h"
3584 #include "hwc_layerlist.h"
3585 #include "hwc_vsync_coordinator.h"
3586+#include "hwc_wrapper.h"
3587 #include "framebuffer_bundle.h"
3588 #include "buffer.h"
3589 #include "mir/graphics/buffer.h"
3590@@ -89,7 +90,7 @@
3591
3592 void mga::HwcDevice::render_gl_and_overlays(
3593 SwappingGLContext const& context,
3594- std::list<std::shared_ptr<Renderable>> const& renderables,
3595+ RenderableList const& renderables,
3596 std::function<void(Renderable const&)> const& render_fn)
3597 {
3598 if (!(list_needs_commit = hwc_list.update_list_and_check_if_changed(renderables, fbtarget_size)))
3599
3600=== modified file 'src/platform/graphics/android/hwc_device.h'
3601--- src/platform/graphics/android/hwc_device.h 2014-03-11 13:44:57 +0000
3602+++ src/platform/graphics/android/hwc_device.h 2014-04-02 18:58:27 +0000
3603@@ -35,20 +35,7 @@
3604 {
3605 class HWCVsyncCoordinator;
3606 class SyncFileOps;
3607-
3608-class HwcWrapper
3609-{
3610-public:
3611- virtual ~HwcWrapper() = default;
3612-
3613- virtual void prepare(hwc_display_contents_1_t&) const = 0;
3614- virtual void set(hwc_display_contents_1_t&) const = 0;
3615-
3616-protected:
3617- HwcWrapper() = default;
3618- HwcWrapper& operator=(HwcWrapper const&) = delete;
3619- HwcWrapper(HwcWrapper const&) = delete;
3620-};
3621+class HwcWrapper;
3622
3623 class HwcDevice : public HWCCommonDevice
3624 {
3625@@ -63,7 +50,7 @@
3626 virtual void render_gl(SwappingGLContext const& context);
3627 virtual void render_gl_and_overlays(
3628 SwappingGLContext const& context,
3629- std::list<std::shared_ptr<Renderable>> const& list,
3630+ RenderableList const& list,
3631 std::function<void(Renderable const&)> const& render_fn);
3632 void post(Buffer const& buffer);
3633
3634
3635=== modified file 'src/platform/graphics/android/hwc_fb_device.cpp'
3636--- src/platform/graphics/android/hwc_fb_device.cpp 2014-03-11 13:44:57 +0000
3637+++ src/platform/graphics/android/hwc_fb_device.cpp 2014-04-02 18:58:27 +0000
3638@@ -21,6 +21,7 @@
3639 #include "hwc_vsync_coordinator.h"
3640 #include "framebuffer_bundle.h"
3641 #include "android_format_conversion-inl.h"
3642+#include "hwc_wrapper.h"
3643 #include "mir/graphics/buffer.h"
3644 #include "mir/graphics/android/native_buffer.h"
3645
3646@@ -33,9 +34,11 @@
3647 namespace geom = mir::geometry;
3648
3649 mga::HwcFbDevice::HwcFbDevice(std::shared_ptr<hwc_composer_device_1> const& hwc_device,
3650+ std::shared_ptr<HwcWrapper> const& hwc_wrapper,
3651 std::shared_ptr<framebuffer_device_t> const& fb_device,
3652 std::shared_ptr<HWCVsyncCoordinator> const& coordinator)
3653 : HWCCommonDevice(hwc_device, coordinator),
3654+ hwc_wrapper(hwc_wrapper),
3655 fb_device(fb_device),
3656 layer_list{{},1}
3657 {
3658@@ -44,41 +47,33 @@
3659
3660 void mga::HwcFbDevice::gpu_render()
3661 {
3662- auto rc = 0;
3663- auto display_list = layer_list.native_list().lock();
3664- if (display_list)
3665+ if (auto display_list = layer_list.native_list().lock())
3666 {
3667 display_list->dpy = eglGetCurrentDisplay();
3668 display_list->sur = eglGetCurrentSurface(EGL_DRAW);
3669
3670 //set() may affect EGL state by calling eglSwapBuffers.
3671 //HWC 1.0 is the only version of HWC that can do this.
3672- hwc_display_contents_1_t* displays[num_displays] {display_list.get()};
3673- rc = hwc_device->set(hwc_device.get(), num_displays, displays);
3674+ hwc_wrapper->set(*display_list);
3675 }
3676-
3677- if ((rc != 0) || (!display_list))
3678+ else
3679 {
3680 std::stringstream ss;
3681- ss << "error during hwc set(). rc = " << std::hex << rc;
3682+ ss << "error locking list during hwc set()";
3683 BOOST_THROW_EXCEPTION(std::runtime_error(ss.str()));
3684 }
3685 }
3686
3687 void mga::HwcFbDevice::prepare()
3688 {
3689- auto rc = 0;
3690- auto display_list = layer_list.native_list().lock();
3691- if (display_list)
3692+ if (auto display_list = layer_list.native_list().lock())
3693 {
3694- hwc_display_contents_1_t* displays[num_displays] {display_list.get()};
3695- rc = hwc_device->prepare(hwc_device.get(), num_displays, displays);
3696+ hwc_wrapper->prepare(*display_list);
3697 }
3698-
3699- if ((rc != 0) || (!display_list))
3700+ else
3701 {
3702 std::stringstream ss;
3703- ss << "error during hwc prepare(). rc = " << std::hex << rc;
3704+ ss << "error accessing list during hwc prepare()";
3705 BOOST_THROW_EXCEPTION(std::runtime_error(ss.str()));
3706 }
3707 }
3708@@ -91,7 +86,7 @@
3709
3710 void mga::HwcFbDevice::render_gl_and_overlays(
3711 SwappingGLContext const&,
3712- std::list<std::shared_ptr<Renderable>> const& renderables,
3713+ RenderableList const& renderables,
3714 std::function<void(Renderable const&)> const& render_fn)
3715 {
3716 prepare();
3717
3718=== modified file 'src/platform/graphics/android/hwc_fb_device.h'
3719--- src/platform/graphics/android/hwc_fb_device.h 2014-03-11 13:44:57 +0000
3720+++ src/platform/graphics/android/hwc_fb_device.h 2014-04-02 18:58:27 +0000
3721@@ -30,24 +30,28 @@
3722 {
3723 namespace android
3724 {
3725+class HwcWrapper;
3726
3727 class HwcFbDevice : public HWCCommonDevice
3728 {
3729 public:
3730 HwcFbDevice(std::shared_ptr<hwc_composer_device_1> const& hwc_device,
3731+ std::shared_ptr<HwcWrapper> const& hwc_wrapper,
3732 std::shared_ptr<framebuffer_device_t> const& fb_device,
3733 std::shared_ptr<HWCVsyncCoordinator> const& coordinator);
3734
3735 virtual void render_gl(SwappingGLContext const& context);
3736 virtual void render_gl_and_overlays(
3737 SwappingGLContext const& context,
3738- std::list<std::shared_ptr<Renderable>> const& list,
3739+ RenderableList const& list,
3740 std::function<void(Renderable const&)> const& render_fn);
3741 void post(Buffer const& buffer);
3742
3743 private:
3744 void prepare();
3745 void gpu_render();
3746+
3747+ std::shared_ptr<HwcWrapper> const hwc_wrapper;
3748 std::shared_ptr<framebuffer_device_t> const fb_device;
3749 static int const num_displays{1};
3750 LayerList layer_list;
3751
3752=== added file 'src/platform/graphics/android/hwc_formatted_logger.cpp'
3753--- src/platform/graphics/android/hwc_formatted_logger.cpp 1970-01-01 00:00:00 +0000
3754+++ src/platform/graphics/android/hwc_formatted_logger.cpp 2014-04-02 18:58:27 +0000
3755@@ -0,0 +1,177 @@
3756+/*
3757+ * Copyright © 2014 Canonical Ltd.
3758+ *
3759+ * This program is free software: you can redistribute it and/or modify it
3760+ * under the terms of the GNU Lesser General Public License version 3,
3761+ * as published by the Free Software Foundation.
3762+ *
3763+ * This program is distributed in the hope that it will be useful,
3764+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3765+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3766+ * GNU Lesser General Public License for more details.
3767+ *
3768+ * You should have received a copy of the GNU Lesser General Public License
3769+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3770+ *
3771+ * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
3772+ */
3773+
3774+#include "hwc_formatted_logger.h"
3775+#include <iostream>
3776+#include <iomanip>
3777+
3778+namespace mga=mir::graphics::android;
3779+
3780+namespace
3781+{
3782+std::string const separator{" | "};
3783+int const layer_num_column_size{2};
3784+int const blending_column_size{8};
3785+int const rotation_column_size{9};
3786+int const rect_entry_column_size{4};
3787+int const type_column_size{9};
3788+
3789+class StreamFormatter
3790+{
3791+public:
3792+ StreamFormatter(std::ostream& str, unsigned int const width, std::ios_base::fmtflags flags)
3793+ : stream(str),
3794+ old_width(stream.width(width)),
3795+ old_flags(stream.setf(flags,std::ios::adjustfield))
3796+ {
3797+ }
3798+
3799+ ~StreamFormatter()
3800+ {
3801+ stream.setf(old_flags, std::ios::adjustfield);
3802+ stream.width(old_width);
3803+ }
3804+private:
3805+ std::ostream& stream;
3806+ unsigned int const old_width;
3807+ std::ios_base::fmtflags const old_flags;
3808+};
3809+
3810+struct LayerNumber{ unsigned int const num; };
3811+std::ostream& operator<<(std::ostream& str, LayerNumber l)
3812+{
3813+ StreamFormatter stream_format(str, layer_num_column_size, std::ios_base::right);
3814+ return str << l.num % 100;
3815+}
3816+
3817+struct HwcRotation{ unsigned int const key; };
3818+std::ostream& operator<<(std::ostream& str, HwcRotation rotation_key)
3819+{
3820+ StreamFormatter stream_format(str, rotation_column_size, std::ios_base::left);
3821+ switch(rotation_key.key)
3822+ {
3823+ case 0:
3824+ return str << std::string{"NONE"};
3825+ case HWC_TRANSFORM_ROT_90:
3826+ return str << std::string{"ROT_90"};
3827+ case HWC_TRANSFORM_ROT_180:
3828+ return str << std::string{"ROT_180"};
3829+ case HWC_TRANSFORM_ROT_270:
3830+ return str << std::string{"ROT_270"};
3831+ default:
3832+ return str << std::string{"UNKNOWN"};
3833+ }
3834+}
3835+
3836+struct HwcBlending{ int const key; };
3837+std::ostream& operator<<(std::ostream& str, HwcBlending blending_key)
3838+{
3839+ StreamFormatter stream_format(str, blending_column_size, std::ios_base::left);
3840+ switch(blending_key.key)
3841+ {
3842+ case HWC_BLENDING_NONE:
3843+ return str << std::string{"NONE"};
3844+ case HWC_BLENDING_PREMULT:
3845+ return str << std::string{"PREMULT"};
3846+ case HWC_BLENDING_COVERAGE:
3847+ return str << std::string{"COVERAGE"};
3848+ default:
3849+ return str << std::string{"UNKNOWN"};
3850+ }
3851+}
3852+
3853+struct HwcType{ int const type; unsigned int const flags; };
3854+std::ostream& operator<<(std::ostream& str, HwcType type)
3855+{
3856+ StreamFormatter stream_format(str, type_column_size, std::ios_base::left);
3857+ switch(type.type)
3858+ {
3859+ case HWC_OVERLAY:
3860+ return str << std::string{"OVERLAY"};
3861+ case HWC_FRAMEBUFFER:
3862+ if (type.flags == HWC_SKIP_LAYER)
3863+ return str << std::string{"FORCE_GL"};
3864+ else
3865+ return str << std::string{"GL_RENDER"};
3866+ case HWC_FRAMEBUFFER_TARGET:
3867+ return str << std::string{"FB_TARGET"};
3868+ default:
3869+ return str << std::string{"UNKNOWN"};
3870+ }
3871+}
3872+
3873+struct HwcRectMember { int member; };
3874+std::ostream& operator<<(std::ostream& str, HwcRectMember rect)
3875+{
3876+ StreamFormatter stream_format(str, rect_entry_column_size, std::ios_base::right);
3877+ return str << rect.member;
3878+}
3879+
3880+struct HwcRect { hwc_rect_t const& rect; };
3881+std::ostream& operator<<(std::ostream& str, HwcRect r)
3882+{
3883+ return str << "{"
3884+ << HwcRectMember{r.rect.left} << ","
3885+ << HwcRectMember{r.rect.top} << ","
3886+ << HwcRectMember{r.rect.right} << ","
3887+ << HwcRectMember{r.rect.bottom} << "}";
3888+}
3889+}
3890+
3891+void mga::HwcFormattedLogger::log_list_submitted_to_prepare(hwc_display_contents_1_t const& list) const
3892+{
3893+ std::cout << "before prepare():" << std::endl
3894+ << " # | pos {l,t,r,b} | crop {l,t,r,b} | transform | blending | "
3895+ << std::endl;
3896+ for(auto i = 0u; i < list.numHwLayers; i++)
3897+ std::cout << LayerNumber{i}
3898+ << separator
3899+ << HwcRect{list.hwLayers[i].displayFrame}
3900+ << separator
3901+ << HwcRect{list.hwLayers[i].sourceCrop}
3902+ << separator
3903+ << HwcRotation{list.hwLayers[i].transform}
3904+ << separator
3905+ << HwcBlending{list.hwLayers[i].blending}
3906+ << separator
3907+ << std::endl;
3908+}
3909+
3910+void mga::HwcFormattedLogger::log_prepare_done(hwc_display_contents_1_t const& list) const
3911+{
3912+ std::cout << "after prepare():" << std::endl
3913+ << " # | Type | " << std::endl;
3914+ for(auto i = 0u; i < list.numHwLayers; i++)
3915+ std::cout << LayerNumber{i}
3916+ << separator
3917+ << HwcType{list.hwLayers[i].compositionType,list.hwLayers[i].flags}
3918+ << separator
3919+ << std::endl;
3920+}
3921+
3922+void mga::HwcFormattedLogger::log_set_list(hwc_display_contents_1_t const& list) const
3923+{
3924+ std::cout << "set list():" << std::endl
3925+ << " # | handle" << std::endl;
3926+
3927+ for(auto i = 0u; i < list.numHwLayers; i++)
3928+ std::cout << LayerNumber{i}
3929+ << separator
3930+ << list.hwLayers[i].handle
3931+ << std::endl;
3932+}
3933
3934=== added file 'src/platform/graphics/android/hwc_formatted_logger.h'
3935--- src/platform/graphics/android/hwc_formatted_logger.h 1970-01-01 00:00:00 +0000
3936+++ src/platform/graphics/android/hwc_formatted_logger.h 2014-04-02 18:58:27 +0000
3937@@ -0,0 +1,41 @@
3938+/*
3939+ * Copyright © 2014 Canonical Ltd.
3940+ *
3941+ * This program is free software: you can redistribute it and/or modify it
3942+ * under the terms of the GNU Lesser General Public License version 3,
3943+ * as published by the Free Software Foundation.
3944+ *
3945+ * This program is distributed in the hope that it will be useful,
3946+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3947+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3948+ * GNU Lesser General Public License for more details.
3949+ *
3950+ * You should have received a copy of the GNU Lesser General Public License
3951+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3952+ *
3953+ * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
3954+ */
3955+
3956+#ifndef MIR_GRAPHICS_ANDROID_HWC_FORMATTED_LOGGER_H_
3957+#define MIR_GRAPHICS_ANDROID_HWC_FORMATTED_LOGGER_H_
3958+
3959+#include "hwc_logger.h"
3960+
3961+namespace mir
3962+{
3963+namespace graphics
3964+{
3965+namespace android
3966+{
3967+class HwcFormattedLogger : public HwcLogger
3968+{
3969+public:
3970+ HwcFormattedLogger() = default;
3971+ void log_list_submitted_to_prepare(hwc_display_contents_1_t const& list) const override;
3972+ void log_prepare_done(hwc_display_contents_1_t const& list) const override;
3973+ void log_set_list(hwc_display_contents_1_t const& list) const override;
3974+};
3975+}
3976+}
3977+}
3978+#endif /* MIR_GRAPHICS_ANDROID_HWC_FORMATTED_LOGGER_H_ */
3979
3980=== modified file 'src/platform/graphics/android/hwc_layerlist.cpp'
3981--- src/platform/graphics/android/hwc_layerlist.cpp 2014-03-17 07:35:22 +0000
3982+++ src/platform/graphics/android/hwc_layerlist.cpp 2014-04-02 18:58:27 +0000
3983@@ -52,7 +52,7 @@
3984 }
3985
3986 bool mga::LayerList::update_list_and_check_if_changed(
3987- std::list<std::shared_ptr<mg::Renderable>> const& renderlist,
3988+ RenderableList const& renderlist,
3989 size_t additional_layers)
3990 {
3991 size_t needed_size = renderlist.size() + additional_layers;
3992@@ -70,7 +70,7 @@
3993 {
3994 layers_it->set_render_parameters(
3995 renderable->screen_position(), renderable->alpha_enabled());
3996- layers_it->set_buffer(*renderable->buffer(1));// TODO: remove needing to know about frameno
3997+ layers_it->set_buffer(*renderable->buffer(this));
3998 any_buffer_updated |= layers_it->needs_hwc_commit();
3999 layers_it++;
4000 }
4001@@ -88,7 +88,7 @@
4002 renderable->screen_position(),
4003 renderable->alpha_enabled(),
4004 hwc_representation, i++));
4005- new_layers.back().set_buffer(*renderable->buffer(1));// TODO: remove needing to know about frameno
4006+ new_layers.back().set_buffer(*renderable->buffer(this));
4007 }
4008
4009 for(; i < needed_size; i++)
4010@@ -137,7 +137,7 @@
4011 }
4012
4013 mga::LayerList::LayerList(
4014- std::list<std::shared_ptr<mg::Renderable>> const& renderlist,
4015+ RenderableList const& renderlist,
4016 size_t additional_layers)
4017 {
4018 update_list_and_check_if_changed(renderlist, additional_layers);
4019
4020=== modified file 'src/platform/graphics/android/hwc_layerlist.h'
4021--- src/platform/graphics/android/hwc_layerlist.h 2014-03-11 13:44:57 +0000
4022+++ src/platform/graphics/android/hwc_layerlist.h 2014-04-02 18:58:27 +0000
4023@@ -48,9 +48,9 @@
4024 class LayerList
4025 {
4026 public:
4027- LayerList(std::list<std::shared_ptr<Renderable>> const& renderlist, size_t additional_layers);
4028+ LayerList(RenderableList const& renderlist, size_t additional_layers);
4029 bool update_list_and_check_if_changed(
4030- std::list<std::shared_ptr<Renderable>> const& renderlist,
4031+ RenderableList const& renderlist,
4032 size_t additional_layers);
4033
4034 std::list<HWCLayer>::iterator begin();
4035
4036=== added file 'src/platform/graphics/android/hwc_logger.h'
4037--- src/platform/graphics/android/hwc_logger.h 1970-01-01 00:00:00 +0000
4038+++ src/platform/graphics/android/hwc_logger.h 2014-04-02 18:58:27 +0000
4039@@ -0,0 +1,46 @@
4040+/*
4041+ * Copyright © 2014 Canonical Ltd.
4042+ *
4043+ * This program is free software: you can redistribute it and/or modify it
4044+ * under the terms of the GNU Lesser General Public License version 3,
4045+ * as published by the Free Software Foundation.
4046+ *
4047+ * This program is distributed in the hope that it will be useful,
4048+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4049+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4050+ * GNU Lesser General Public License for more details.
4051+ *
4052+ * You should have received a copy of the GNU Lesser General Public License
4053+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4054+ *
4055+ * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
4056+ */
4057+
4058+#ifndef MIR_GRAPHICS_ANDROID_HWC_LOGGER_H_
4059+#define MIR_GRAPHICS_ANDROID_HWC_LOGGER_H_
4060+
4061+#include <hardware/hwcomposer.h>
4062+
4063+namespace mir
4064+{
4065+namespace graphics
4066+{
4067+namespace android
4068+{
4069+class HwcLogger
4070+{
4071+public:
4072+ virtual ~HwcLogger() = default;
4073+
4074+ virtual void log_list_submitted_to_prepare(hwc_display_contents_1_t const& list) const = 0;
4075+ virtual void log_prepare_done(hwc_display_contents_1_t const& list) const = 0;
4076+ virtual void log_set_list(hwc_display_contents_1_t const& list) const = 0;
4077+protected:
4078+ HwcLogger() = default;
4079+ HwcLogger& operator=(HwcLogger const&) = delete;
4080+ HwcLogger(HwcLogger const&) = delete;
4081+};
4082+}
4083+}
4084+}
4085+#endif /* MIR_GRAPHICS_ANDROID_HWC_LOGGER_H_ */
4086
4087=== added file 'src/platform/graphics/android/hwc_wrapper.h'
4088--- src/platform/graphics/android/hwc_wrapper.h 1970-01-01 00:00:00 +0000
4089+++ src/platform/graphics/android/hwc_wrapper.h 2014-04-02 18:58:27 +0000
4090@@ -0,0 +1,47 @@
4091+/*
4092+ * Copyright © 2014 Canonical Ltd.
4093+ *
4094+ * This program is free software: you can redistribute it and/or modify it
4095+ * under the terms of the GNU Lesser General Public License version 3,
4096+ * as published by the Free Software Foundation.
4097+ *
4098+ * This program is distributed in the hope that it will be useful,
4099+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4100+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4101+ * GNU Lesser General Public License for more details.
4102+ *
4103+ * You should have received a copy of the GNU Lesser General Public License
4104+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4105+ *
4106+ * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
4107+ */
4108+
4109+#ifndef MIR_GRAPHICS_ANDROID_HWC_WRAPPER_H_
4110+#define MIR_GRAPHICS_ANDROID_HWC_WRAPPER_H_
4111+
4112+#include <hardware/hwcomposer.h>
4113+
4114+namespace mir
4115+{
4116+namespace graphics
4117+{
4118+namespace android
4119+{
4120+class HwcWrapper
4121+{
4122+public:
4123+ virtual ~HwcWrapper() = default;
4124+
4125+ virtual void prepare(hwc_display_contents_1_t&) const = 0;
4126+ virtual void set(hwc_display_contents_1_t&) const = 0;
4127+
4128+protected:
4129+ HwcWrapper() = default;
4130+ HwcWrapper& operator=(HwcWrapper const&) = delete;
4131+ HwcWrapper(HwcWrapper const&) = delete;
4132+};
4133+}
4134+}
4135+}
4136+
4137+#endif /* MIR_GRAPHICS_ANDROID_HWC_WRAPPER_H_ */
4138
4139=== modified file 'src/platform/graphics/android/real_hwc_wrapper.cpp'
4140--- src/platform/graphics/android/real_hwc_wrapper.cpp 2014-02-26 22:22:15 +0000
4141+++ src/platform/graphics/android/real_hwc_wrapper.cpp 2014-04-02 18:58:27 +0000
4142@@ -17,14 +17,18 @@
4143 */
4144
4145 #include "real_hwc_wrapper.h"
4146+#include "hwc_logger.h"
4147 #include <boost/throw_exception.hpp>
4148 #include <stdexcept>
4149 #include <sstream>
4150
4151 namespace mga=mir::graphics::android;
4152
4153-mga::RealHwcWrapper::RealHwcWrapper(std::shared_ptr<hwc_composer_device_1> const& hwc_device)
4154- : hwc_device(hwc_device)
4155+mga::RealHwcWrapper::RealHwcWrapper(
4156+ std::shared_ptr<hwc_composer_device_1> const& hwc_device,
4157+ std::shared_ptr<mga::HwcLogger> const& logger)
4158+ : hwc_device(hwc_device),
4159+ logger(logger)
4160 {
4161 }
4162
4163@@ -33,17 +37,22 @@
4164 //note, although we only have a primary display right now,
4165 // set the external and virtual displays to null as some drivers check for that
4166 hwc_display_contents_1_t* displays[num_displays] {&display_list, nullptr, nullptr};
4167+
4168+ logger->log_list_submitted_to_prepare(display_list);
4169 if (auto rc = hwc_device->prepare(hwc_device.get(), 1, displays))
4170 {
4171 std::stringstream ss;
4172 ss << "error during hwc prepare(). rc = " << std::hex << rc;
4173 BOOST_THROW_EXCEPTION(std::runtime_error(ss.str()));
4174 }
4175+ logger->log_prepare_done(display_list);
4176 }
4177
4178 void mga::RealHwcWrapper::set(hwc_display_contents_1_t& display_list) const
4179 {
4180 hwc_display_contents_1_t* displays[num_displays] {&display_list, nullptr, nullptr};
4181+
4182+ logger->log_set_list(display_list);
4183 if (auto rc = hwc_device->set(hwc_device.get(), 1, displays))
4184 {
4185 std::stringstream ss;
4186
4187=== modified file 'src/platform/graphics/android/real_hwc_wrapper.h'
4188--- src/platform/graphics/android/real_hwc_wrapper.h 2014-02-20 22:20:34 +0000
4189+++ src/platform/graphics/android/real_hwc_wrapper.h 2014-04-02 18:58:27 +0000
4190@@ -19,7 +19,7 @@
4191 #ifndef MIR_GRAPHICS_ANDROID_REAL_HWC_WRAPPER_H_
4192 #define MIR_GRAPHICS_ANDROID_REAL_HWC_WRAPPER_H_
4193
4194-#include "hwc_device.h"
4195+#include "hwc_wrapper.h"
4196 #include <memory>
4197 #include <hardware/hwcomposer.h>
4198
4199@@ -29,17 +29,20 @@
4200 {
4201 namespace android
4202 {
4203-
4204+class HwcLogger;
4205 class RealHwcWrapper : public HwcWrapper
4206 {
4207 public:
4208- RealHwcWrapper(std::shared_ptr<hwc_composer_device_1> const& hwc_device);
4209+ RealHwcWrapper(
4210+ std::shared_ptr<hwc_composer_device_1> const& hwc_device,
4211+ std::shared_ptr<HwcLogger> const& logger);
4212
4213 void prepare(hwc_display_contents_1_t&) const override;
4214 void set(hwc_display_contents_1_t&) const override;
4215 private:
4216 static size_t const num_displays{3}; //primary, external, virtual
4217 std::shared_ptr<hwc_composer_device_1> const hwc_device;
4218+ std::shared_ptr<HwcLogger> const logger;
4219 };
4220
4221 }
4222
4223=== modified file 'src/platform/graphics/android/resource_factory.cpp'
4224--- src/platform/graphics/android/resource_factory.cpp 2014-03-11 13:44:57 +0000
4225+++ src/platform/graphics/android/resource_factory.cpp 2014-04-02 18:58:27 +0000
4226@@ -31,6 +31,7 @@
4227 #include "hwc_vsync.h"
4228 #include "android_display.h"
4229 #include "real_hwc_wrapper.h"
4230+#include "hwc_formatted_logger.h"
4231
4232 #include <boost/throw_exception.hpp>
4233 #include <stdexcept>
4234@@ -39,6 +40,11 @@
4235 namespace mg = mir::graphics;
4236 namespace mga=mir::graphics::android;
4237
4238+mga::ResourceFactory::ResourceFactory(bool should_log_hwc)
4239+ : should_log_hwc{should_log_hwc}
4240+{
4241+}
4242+
4243 std::shared_ptr<framebuffer_device_t> mga::ResourceFactory::create_fb_native_device() const
4244 {
4245 hw_module_t const* module;
4246@@ -89,12 +95,37 @@
4247 return std::make_shared<mga::FBDevice>(fb_native_device);
4248 }
4249
4250+namespace
4251+{
4252+struct NullHwcLogger : public mga::HwcLogger
4253+{
4254+ void log_list_submitted_to_prepare(hwc_display_contents_1_t const&) const override
4255+ {
4256+ }
4257+ void log_prepare_done(hwc_display_contents_1_t const&) const override
4258+ {
4259+ }
4260+ void log_set_list(hwc_display_contents_1_t const&) const override
4261+ {
4262+ }
4263+};
4264+
4265+std::shared_ptr<mga::HwcLogger> make_logger(bool should_log)
4266+{
4267+ if (should_log)
4268+ return std::make_shared<mga::HwcFormattedLogger>();
4269+ else
4270+ return std::make_shared<NullHwcLogger>();
4271+}
4272+
4273+}
4274+
4275 std::shared_ptr<mga::DisplayDevice> mga::ResourceFactory::create_hwc_device(
4276 std::shared_ptr<hwc_composer_device_1> const& hwc_native_device) const
4277 {
4278 auto syncer = std::make_shared<mga::HWCVsync>();
4279 auto file_ops = std::make_shared<mga::RealSyncFileOps>();
4280- auto wrapper = std::make_shared<mga::RealHwcWrapper>(hwc_native_device);
4281+ auto wrapper = std::make_shared<mga::RealHwcWrapper>(hwc_native_device, make_logger(should_log_hwc));
4282 return std::make_shared<mga::HwcDevice>(hwc_native_device, wrapper, syncer, file_ops);
4283 }
4284
4285@@ -103,5 +134,7 @@
4286 std::shared_ptr<framebuffer_device_t> const& fb_native_device) const
4287 {
4288 auto syncer = std::make_shared<mga::HWCVsync>();
4289- return std::make_shared<mga::HwcFbDevice>(hwc_native_device, fb_native_device, syncer);
4290+ auto logger = std::make_shared<NullHwcLogger>();
4291+ auto wrapper = std::make_shared<mga::RealHwcWrapper>(hwc_native_device, make_logger(should_log_hwc));
4292+ return std::make_shared<mga::HwcFbDevice>(hwc_native_device, wrapper, fb_native_device, syncer);
4293 }
4294
4295=== modified file 'src/platform/graphics/android/resource_factory.h'
4296--- src/platform/graphics/android/resource_factory.h 2014-03-06 06:05:17 +0000
4297+++ src/platform/graphics/android/resource_factory.h 2014-04-02 18:58:27 +0000
4298@@ -31,6 +31,8 @@
4299 class ResourceFactory : public DisplayResourceFactory
4300 {
4301 public:
4302+ ResourceFactory(bool should_log_hwc);
4303+
4304 //native allocations
4305 std::shared_ptr<hwc_composer_device_1> create_hwc_native_device() const;
4306 std::shared_ptr<framebuffer_device_t> create_fb_native_device() const;
4307@@ -46,6 +48,8 @@
4308
4309 std::shared_ptr<ANativeWindow> create_native_window(
4310 std::shared_ptr<FramebufferBundle> const& fb_bundle) const;
4311+private:
4312+ bool const should_log_hwc;
4313 };
4314
4315 }
4316
4317=== modified file 'src/platform/graphics/mesa/display.cpp'
4318--- src/platform/graphics/mesa/display.cpp 2014-03-17 07:35:22 +0000
4319+++ src/platform/graphics/mesa/display.cpp 2014-04-02 18:58:27 +0000
4320@@ -54,7 +54,10 @@
4321 class GBMGLContext : public mg::GLContext
4322 {
4323 public:
4324- GBMGLContext(mgm::helpers::GBMHelper const& gbm, EGLContext shared_context)
4325+ GBMGLContext(mgm::helpers::GBMHelper const& gbm,
4326+ mg::GLConfig const& gl_config,
4327+ EGLContext shared_context)
4328+ : egl{gl_config}
4329 {
4330 egl.setup(gbm, shared_context);
4331 }
4332@@ -77,13 +80,16 @@
4333
4334 mgm::Display::Display(std::shared_ptr<Platform> const& platform,
4335 std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
4336+ std::shared_ptr<GLConfig> const& gl_config,
4337 std::shared_ptr<DisplayReport> const& listener)
4338 : platform(platform),
4339 listener(listener),
4340 monitor(mir::udev::Context()),
4341+ shared_egl{*gl_config},
4342 output_container{platform->drm.fd,
4343 std::make_shared<KMSPageFlipper>(platform->drm.fd)},
4344- current_display_configuration{platform->drm.fd}
4345+ current_display_configuration{platform->drm.fd},
4346+ gl_config{gl_config}
4347 {
4348 platform->vt->set_graphics_mode();
4349
4350@@ -203,6 +209,7 @@
4351 std::move(surface),
4352 bounding_rect,
4353 orientation,
4354+ *gl_config,
4355 shared_egl.context()}};
4356
4357 display_buffers_new.push_back(std::move(db));
4358@@ -320,7 +327,10 @@
4359 std::unique_ptr<mg::GLContext> mgm::Display::create_gl_context()
4360 {
4361 return std::unique_ptr<GBMGLContext>{
4362- new GBMGLContext{platform->gbm, shared_egl.context()}};
4363+ new GBMGLContext{
4364+ platform->gbm,
4365+ *gl_config,
4366+ shared_egl.context()}};
4367 }
4368
4369 void mgm::Display::clear_connected_unused_outputs()
4370
4371=== modified file 'src/platform/graphics/mesa/display.h'
4372--- src/platform/graphics/mesa/display.h 2014-03-06 06:05:17 +0000
4373+++ src/platform/graphics/mesa/display.h 2014-04-02 18:58:27 +0000
4374@@ -41,6 +41,7 @@
4375 class DisplayBuffer;
4376 class DisplayConfigurationPolicy;
4377 class EventHandlerRegister;
4378+class GLConfig;
4379
4380 namespace mesa
4381 {
4382@@ -54,8 +55,9 @@
4383 {
4384 public:
4385 Display(std::shared_ptr<Platform> const& platform,
4386- std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
4387- std::shared_ptr<DisplayReport> const& listener);
4388+ std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
4389+ std::shared_ptr<GLConfig> const& gl_config,
4390+ std::shared_ptr<DisplayReport> const& listener);
4391 ~Display();
4392
4393 geometry::Rectangle view_area() const;
4394@@ -92,6 +94,7 @@
4395 RealKMSOutputContainer output_container;
4396 mutable RealKMSDisplayConfiguration current_display_configuration;
4397 std::shared_ptr<Cursor> cursor;
4398+ std::shared_ptr<GLConfig> const gl_config;
4399 };
4400
4401 }
4402
4403=== modified file 'src/platform/graphics/mesa/display_buffer.cpp'
4404--- src/platform/graphics/mesa/display_buffer.cpp 2014-03-06 06:05:17 +0000
4405+++ src/platform/graphics/mesa/display_buffer.cpp 2014-04-02 18:58:27 +0000
4406@@ -101,6 +101,7 @@
4407 GBMSurfaceUPtr surface_gbm_param,
4408 geom::Rectangle const& area,
4409 MirOrientation rot,
4410+ GLConfig const& gl_config,
4411 EGLContext shared_context)
4412 : last_flipped_bufobj{nullptr},
4413 scheduled_bufobj{nullptr},
4414@@ -109,6 +110,7 @@
4415 drm(platform->drm),
4416 outputs(outputs),
4417 surface_gbm{std::move(surface_gbm_param)},
4418+ egl{gl_config},
4419 area(area),
4420 rotation(rot),
4421 needs_set_crtc{false},
4422@@ -196,7 +198,7 @@
4423 }
4424
4425 void mgm::DisplayBuffer::render_and_post_update(
4426- std::list<std::shared_ptr<Renderable>> const&,
4427+ RenderableList const&,
4428 std::function<void(Renderable const&)> const&)
4429 {
4430 post_update(nullptr);
4431
4432=== modified file 'src/platform/graphics/mesa/display_buffer.h'
4433--- src/platform/graphics/mesa/display_buffer.h 2014-03-06 06:05:17 +0000
4434+++ src/platform/graphics/mesa/display_buffer.h 2014-04-02 18:58:27 +0000
4435@@ -32,6 +32,7 @@
4436 {
4437
4438 class DisplayReport;
4439+class GLConfig;
4440
4441 namespace mesa
4442 {
4443@@ -49,6 +50,7 @@
4444 GBMSurfaceUPtr surface_gbm,
4445 geometry::Rectangle const& area,
4446 MirOrientation rot,
4447+ GLConfig const& gl_config,
4448 EGLContext shared_context);
4449 ~DisplayBuffer();
4450
4451@@ -59,7 +61,7 @@
4452
4453 bool can_bypass() const override;
4454 void post_update(std::shared_ptr<graphics::Buffer> bypass_buf) override;
4455- void render_and_post_update(std::list<std::shared_ptr<Renderable>> const& renderlist,
4456+ void render_and_post_update(RenderableList const& renderlist,
4457 std::function<void(Renderable const&)> const& render_fn);
4458 MirOrientation orientation() const override;
4459 void schedule_set_crtc();
4460
4461=== modified file 'src/platform/graphics/mesa/display_helpers.cpp'
4462--- src/platform/graphics/mesa/display_helpers.cpp 2014-03-12 02:46:58 +0000
4463+++ src/platform/graphics/mesa/display_helpers.cpp 2014-04-02 18:58:27 +0000
4464@@ -19,6 +19,7 @@
4465 #include "display_helpers.h"
4466 #include "drm_close_threadsafe.h"
4467
4468+#include "mir/graphics/gl_config.h"
4469 #include "mir/udev/wrapper.h"
4470
4471 #include <boost/exception/errinfo_errno.hpp>
4472@@ -219,7 +220,7 @@
4473 sv.drm_dd_major = -1; /* Don't care */
4474 sv.drm_dd_minor = -1; /* Don't care */
4475
4476- if ((error = drmSetInterfaceVersion(tmp_fd, &sv)))
4477+ if ((error = -drmSetInterfaceVersion(tmp_fd, &sv)))
4478 {
4479 close(tmp_fd);
4480 tmp_fd = -1;
4481@@ -238,7 +239,7 @@
4482 {
4483 BOOST_THROW_EXCEPTION(
4484 boost::enable_error_info(
4485- std::runtime_error("Error opening DRM device")) << boost::errinfo_errno(-error));
4486+ std::runtime_error("Error opening DRM device")) << boost::errinfo_errno(error));
4487 }
4488
4489 return tmp_fd;
4490@@ -295,6 +296,15 @@
4491 * EGLHelper *
4492 *************/
4493
4494+mgmh::EGLHelper::EGLHelper(GLConfig const& gl_config)
4495+ : depth_buffer_bits{gl_config.depth_buffer_bits()},
4496+ stencil_buffer_bits{gl_config.stencil_buffer_bits()},
4497+ egl_display{EGL_NO_DISPLAY}, egl_config{0},
4498+ egl_context{EGL_NO_CONTEXT}, egl_surface{EGL_NO_SURFACE},
4499+ should_terminate_egl{false}
4500+{
4501+}
4502+
4503 void mgmh::EGLHelper::setup(GBMHelper const& gbm)
4504 {
4505 static const EGLint context_attr[] = {
4506@@ -378,12 +388,14 @@
4507
4508 void mgmh::EGLHelper::setup_internal(GBMHelper const& gbm, bool initialize)
4509 {
4510- static const EGLint config_attr[] = {
4511+ EGLint const config_attr[] = {
4512 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
4513 EGL_RED_SIZE, 8,
4514 EGL_GREEN_SIZE, 8,
4515 EGL_BLUE_SIZE, 8,
4516 EGL_ALPHA_SIZE, 0,
4517+ EGL_DEPTH_SIZE, depth_buffer_bits,
4518+ EGL_STENCIL_SIZE, stencil_buffer_bits,
4519 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
4520 EGL_NONE
4521 };
4522
4523=== modified file 'src/platform/graphics/mesa/display_helpers.h'
4524--- src/platform/graphics/mesa/display_helpers.h 2014-03-12 02:46:58 +0000
4525+++ src/platform/graphics/mesa/display_helpers.h 2014-04-02 18:58:27 +0000
4526@@ -37,6 +37,8 @@
4527 {
4528 namespace graphics
4529 {
4530+class GLConfig;
4531+
4532 namespace mesa
4533 {
4534
4535@@ -92,11 +94,7 @@
4536 class EGLHelper
4537 {
4538 public:
4539- EGLHelper()
4540- : egl_display{EGL_NO_DISPLAY}, egl_config{0},
4541- egl_context{EGL_NO_CONTEXT}, egl_surface{EGL_NO_SURFACE},
4542- should_terminate_egl{false} {}
4543-
4544+ EGLHelper(GLConfig const& gl_config);
4545 ~EGLHelper() noexcept;
4546
4547 EGLHelper(const EGLHelper&) = delete;
4548@@ -117,6 +115,8 @@
4549 private:
4550 void setup_internal(GBMHelper const& gbm, bool initialize);
4551
4552+ EGLint const depth_buffer_bits;
4553+ EGLint const stencil_buffer_bits;
4554 EGLDisplay egl_display;
4555 EGLConfig egl_config;
4556 EGLContext egl_context;
4557
4558=== modified file 'src/platform/graphics/mesa/platform.cpp'
4559--- src/platform/graphics/mesa/platform.cpp 2014-03-13 07:47:55 +0000
4560+++ src/platform/graphics/mesa/platform.cpp 2014-04-02 18:58:27 +0000
4561@@ -147,11 +147,13 @@
4562 }
4563
4564 std::shared_ptr<mg::Display> mgm::Platform::create_display(
4565- std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy)
4566+ std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
4567+ std::shared_ptr<GLConfig> const& gl_config)
4568 {
4569 return std::make_shared<mgm::Display>(
4570 this->shared_from_this(),
4571 initial_conf_policy,
4572+ gl_config,
4573 listener);
4574 }
4575
4576@@ -219,3 +221,11 @@
4577 return (display == mgm::NativePlatform::internal_native_display().get());
4578 return 0;
4579 }
4580+
4581+extern "C" void add_platform_options(boost::program_options::options_description& config)
4582+{
4583+ config.add_options()
4584+ ("vt",
4585+ boost::program_options::value<int>()->default_value(0),
4586+ "[platform-specific] VT to run on or 0 to use current.");
4587+}
4588
4589=== modified file 'src/platform/graphics/mesa/platform.h'
4590--- src/platform/graphics/mesa/platform.h 2014-03-06 06:05:17 +0000
4591+++ src/platform/graphics/mesa/platform.h 2014-04-02 18:58:27 +0000
4592@@ -47,7 +47,8 @@
4593 std::shared_ptr<graphics::GraphicBufferAllocator> create_buffer_allocator(
4594 const std::shared_ptr<BufferInitializer>& buffer_initializer);
4595 std::shared_ptr<graphics::Display> create_display(
4596- std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy);
4597+ std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
4598+ std::shared_ptr<GLConfig> const& gl_config);
4599 std::shared_ptr<PlatformIPCPackage> get_ipc_package();
4600 std::shared_ptr<InternalClient> create_internal_client();
4601
4602
4603=== modified file 'src/platform/options/default_configuration.cpp'
4604--- src/platform/options/default_configuration.cpp 2014-03-17 07:35:22 +0000
4605+++ src/platform/options/default_configuration.cpp 2014-04-02 18:58:27 +0000
4606@@ -16,7 +16,10 @@
4607 * Authored by: Alan Griffiths <alan@octopull.co.uk>
4608 */
4609
4610+#include "mir/shared_library.h"
4611+#include "mir/shared_library_loader.h"
4612 #include "mir/options/default_configuration.h"
4613+#include "mir/graphics/platform.h"
4614 #include "mir/default_configuration.h"
4615 #include "mir/abnormal_exit.h"
4616
4617@@ -114,9 +117,35 @@
4618 (name_opt, po::value<std::string>(),
4619 "When nested, the name Mir uses when registering with the host.")
4620 (offscreen_opt,
4621- "Render to offscreen buffers instead of the real outputs.")
4622- ("vt", po::value<int>()->default_value(0), // TODO this not applicable on all graphics platforms
4623- "VT to run on or 0 to use current.");
4624+ "Render to offscreen buffers instead of the real outputs.");
4625+
4626+ add_platform_options();
4627+}
4628+
4629+void mo::DefaultConfiguration::add_platform_options()
4630+{
4631+ namespace po = boost::program_options;
4632+ po::options_description program_options;
4633+ program_options.add_options()
4634+ (platform_graphics_lib,
4635+ po::value<std::string>()->default_value(default_platform_graphics_lib), "");
4636+ mo::ProgramOption options;
4637+ options.parse_arguments(program_options, argc, argv);
4638+
4639+ std::string graphics_libname;
4640+ auto env_libname = ::getenv("MIR_SERVER_PLATFORM_GRAPHICS_LIB");
4641+ if (!options.is_set(platform_graphics_lib) && env_libname)
4642+ {
4643+ graphics_libname = std::string{env_libname};
4644+ }
4645+ else
4646+ {
4647+ graphics_libname = options.get<std::string>(platform_graphics_lib);
4648+ }
4649+
4650+ auto graphics_lib = load_library(graphics_libname);
4651+ auto add_platform_options = graphics_lib->load_function<mir::graphics::AddPlatformOptions>(std::string("add_platform_options"));
4652+ add_platform_options(*this->program_options);
4653 }
4654
4655 boost::program_options::options_description_easy_init mo::DefaultConfiguration::add_options()
4656
4657=== added file 'src/platform/shared_library_loader.cpp'
4658--- src/platform/shared_library_loader.cpp 1970-01-01 00:00:00 +0000
4659+++ src/platform/shared_library_loader.cpp 2014-04-02 18:58:27 +0000
4660@@ -0,0 +1,38 @@
4661+/*
4662+ * Copyright © 2013 Canonical Ltd.
4663+ *
4664+ * This program is free software: you can redistribute it and/or modify it
4665+ * under the terms of the GNU Lesser General Public License version 3,
4666+ * as published by the Free Software Foundation.
4667+ *
4668+ * This program is distributed in the hope that it will be useful,
4669+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4670+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4671+ * GNU Lesser General Public License for more details.
4672+ *
4673+ * You should have received a copy of the GNU Lesser General Public License
4674+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4675+ *
4676+ * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
4677+ */
4678+
4679+#include "mir/shared_library_loader.h"
4680+#include "mir/shared_library.h"
4681+#include <memory>
4682+#include <map>
4683+
4684+mir::SharedLibrary const* mir::load_library(std::string const& libname)
4685+{
4686+ // There's no point in loading twice, and it isn't safe to unload...
4687+ static std::map<std::string, std::shared_ptr<mir::SharedLibrary>> libraries_cache;
4688+
4689+ if (auto& ptr = libraries_cache[libname])
4690+ {
4691+ return ptr.get();
4692+ }
4693+ else
4694+ {
4695+ ptr = std::make_shared<mir::SharedLibrary>(libname);
4696+ return ptr.get();
4697+ }
4698+}
4699
4700=== modified file 'src/server/CMakeLists.txt'
4701--- src/server/CMakeLists.txt 2014-03-12 06:41:13 +0000
4702+++ src/server/CMakeLists.txt 2014-04-02 18:58:27 +0000
4703@@ -94,7 +94,7 @@
4704 )
4705 endif()
4706
4707-set(MIRSERVER_ABI 17)
4708+set(MIRSERVER_ABI 18)
4709
4710 set_target_properties(
4711 mirserver
4712
4713=== modified file 'src/server/compositor/buffer_bundle.h'
4714--- src/server/compositor/buffer_bundle.h 2014-03-07 03:15:55 +0000
4715+++ src/server/compositor/buffer_bundle.h 2014-04-02 18:58:27 +0000
4716@@ -36,8 +36,20 @@
4717 virtual ~BufferBundle() noexcept {}
4718 virtual void client_acquire(std::function<void(graphics::Buffer* buffer)> complete) = 0;
4719 virtual void client_release(graphics::Buffer*) = 0;
4720+
4721+ /**
4722+ * Acquire the next buffer that's ready to display/composite.
4723+ *
4724+ * \param [in] user_id A unique identifier of who is going to use the
4725+ * buffer, to ensure that separate users representing
4726+ * separate monitors who need the same frame will get
4727+ * the same buffer. However consecutive calls for the
4728+ * same user will get different buffers. To avoid
4729+ * collisions, all callers should determine user_id
4730+ * in the same way (e.g. always use "this" pointer).
4731+ */
4732 virtual std::shared_ptr<graphics::Buffer>
4733- compositor_acquire(unsigned long frameno) = 0;
4734+ compositor_acquire(void const* user_id) = 0;
4735 virtual void compositor_release(std::shared_ptr<graphics::Buffer> const&) = 0;
4736 virtual std::shared_ptr<graphics::Buffer> snapshot_acquire() = 0;
4737 virtual void snapshot_release(std::shared_ptr<graphics::Buffer> const&) = 0;
4738
4739=== modified file 'src/server/compositor/buffer_stream_surfaces.cpp'
4740--- src/server/compositor/buffer_stream_surfaces.cpp 2014-03-07 03:15:55 +0000
4741+++ src/server/compositor/buffer_stream_surfaces.cpp 2014-04-02 18:58:27 +0000
4742@@ -38,10 +38,10 @@
4743 }
4744
4745 std::shared_ptr<mg::Buffer> mc::BufferStreamSurfaces::lock_compositor_buffer(
4746- unsigned long frameno)
4747+ void const* user_id)
4748 {
4749 return std::make_shared<mc::TemporaryCompositorBuffer>(
4750- buffer_bundle, frameno);
4751+ buffer_bundle, user_id);
4752 }
4753
4754 std::shared_ptr<mg::Buffer> mc::BufferStreamSurfaces::lock_snapshot_buffer()
4755
4756=== modified file 'src/server/compositor/buffer_stream_surfaces.h'
4757--- src/server/compositor/buffer_stream_surfaces.h 2014-03-07 03:15:55 +0000
4758+++ src/server/compositor/buffer_stream_surfaces.h 2014-04-02 18:58:27 +0000
4759@@ -42,7 +42,7 @@
4760 void swap_client_buffers(graphics::Buffer* old_buffer, std::function<void(graphics::Buffer* new_buffer)> complete) override;
4761
4762 std::shared_ptr<graphics::Buffer>
4763- lock_compositor_buffer(unsigned long frameno) override;
4764+ lock_compositor_buffer(void const* user_id) override;
4765 std::shared_ptr<graphics::Buffer> lock_snapshot_buffer() override;
4766
4767 MirPixelFormat get_stream_pixel_format() override;
4768
4769=== modified file 'src/server/compositor/bypass.cpp'
4770--- src/server/compositor/bypass.cpp 2014-03-17 07:35:22 +0000
4771+++ src/server/compositor/bypass.cpp 2014-04-02 18:58:27 +0000
4772@@ -44,9 +44,14 @@
4773
4774 auto const& view_area = display_buffer.view_area();
4775
4776+ //TODO: remove this check, why are we getting a non visible renderable
4777+ // in the list of surfaces?
4778+ if (!renderable.visible())
4779+ return false;
4780+
4781 // Not weirdly transformed but also not on this monitor? Don't care...
4782 // This will also check the surface is not hidden and has been posted.
4783- if (!renderable.should_be_rendered_in(view_area))
4784+ if (!view_area.contains(renderable.screen_position()))
4785 return false;
4786
4787 topmost_fits = false;
4788
4789=== modified file 'src/server/compositor/default_display_buffer_compositor.cpp'
4790--- src/server/compositor/default_display_buffer_compositor.cpp 2014-03-17 07:35:22 +0000
4791+++ src/server/compositor/default_display_buffer_compositor.cpp 2014-04-02 18:58:27 +0000
4792@@ -29,41 +29,35 @@
4793 #include "occlusion.h"
4794 #include <mutex>
4795 #include <cstdlib>
4796-#include <vector>
4797+#include <algorithm>
4798
4799 namespace mc = mir::compositor;
4800 namespace mg = mir::graphics;
4801
4802+//TODO remove VisibilityFilter once we don't need filters/operators for rendering
4803 namespace
4804 {
4805-
4806-struct FilterForVisibleSceneInRegion : public mc::FilterForScene
4807+struct VisibilityFilter : public mc::FilterForScene
4808 {
4809- FilterForVisibleSceneInRegion(
4810- mir::geometry::Rectangle const& enclosing_region,
4811- mc::OcclusionMatch const& occlusions)
4812- : enclosing_region(enclosing_region),
4813- occlusions(occlusions)
4814+public:
4815+ VisibilityFilter(
4816+ mg::RenderableList const& renderable_list)
4817+ : list(renderable_list)
4818 {
4819 }
4820+
4821 bool operator()(mg::Renderable const& r)
4822 {
4823- return r.should_be_rendered_in(enclosing_region) &&
4824- !occlusions.occluded(r);
4825+ auto matcher = [&r](std::shared_ptr<mg::Renderable> const& renderable)
4826+ {
4827+ return (renderable.get() == &r);
4828+ };
4829+ return (std::find_if(list.begin(), list.end(), matcher) != list.end());
4830 }
4831
4832- mir::geometry::Rectangle const& enclosing_region;
4833- mc::OcclusionMatch const& occlusions;
4834+private:
4835+ mg::RenderableList const& list;
4836 };
4837-
4838-std::mutex global_frameno_lock;
4839-unsigned long global_frameno = 0;
4840-
4841-bool wrapped_greater_or_equal(unsigned long a, unsigned long b)
4842-{
4843- return (a - b) < (~0UL / 2UL);
4844-}
4845-
4846 }
4847
4848 mc::DefaultDisplayBufferCompositor::DefaultDisplayBufferCompositor(
4849@@ -75,29 +69,14 @@
4850 scene{scene},
4851 renderer{renderer},
4852 report{report},
4853- local_frameno{global_frameno}
4854+ last_pass_rendered_anything{false}
4855 {
4856 }
4857
4858-
4859 bool mc::DefaultDisplayBufferCompositor::composite()
4860 {
4861 report->began_frame(this);
4862
4863- /*
4864- * Increment frame counts for each tick of the fastest instance of
4865- * DefaultDisplayBufferCompositor. This means for the fastest refresh
4866- * rate of all attached outputs.
4867- */
4868- local_frameno++;
4869- {
4870- std::lock_guard<std::mutex> lock(global_frameno_lock);
4871- if (wrapped_greater_or_equal(local_frameno, global_frameno))
4872- global_frameno = local_frameno;
4873- else
4874- local_frameno = global_frameno;
4875- }
4876-
4877 static bool const bypass_env{[]
4878 {
4879 auto const env = getenv("MIR_BYPASS");
4880@@ -123,8 +102,13 @@
4881
4882 if (filter.fullscreen_on_top())
4883 {
4884- auto bypass_buf =
4885- match.topmost_fullscreen()->buffer(local_frameno);
4886+ /*
4887+ * Notice the user_id we pass to buffer() here has to be
4888+ * different to the one used in the Renderer. This is in case
4889+ * the below if() fails we want to complete the frame using the
4890+ * same buffer (different user_id required).
4891+ */
4892+ auto bypass_buf = match.topmost_fullscreen()->buffer(this);
4893
4894 if (bypass_buf->can_bypass())
4895 {
4896@@ -140,41 +124,32 @@
4897
4898 if (!bypassed)
4899 {
4900- // preserves buffers used in rendering until after post_update()
4901- std::vector<std::shared_ptr<void>> saved_resources;
4902- auto save_resource = [&](std::shared_ptr<void> const& r)
4903- {
4904- saved_resources.push_back(r);
4905- };
4906-
4907 display_buffer.make_current();
4908
4909 auto const& view_area = display_buffer.view_area();
4910+ auto renderable_list = scene->generate_renderable_list();
4911+ mc::filter_occlusions_from(renderable_list, view_area);
4912
4913- mc::OcclusionFilter occlusion_search(view_area);
4914- mc::OcclusionMatch occlusion_match;
4915- scene->reverse_for_each_if(occlusion_search, occlusion_match);
4916+ for(auto const& renderable : renderable_list)
4917+ uncomposited_buffers |= (renderable->buffers_ready_for_compositor() > 1);
4918
4919 renderer->set_rotation(display_buffer.orientation());
4920 renderer->begin();
4921- mc::RenderingOperator applicator(*renderer, save_resource, local_frameno, uncomposited_buffers);
4922- FilterForVisibleSceneInRegion selector(view_area, occlusion_match);
4923+ mc::RenderingOperator applicator(*renderer);
4924+ VisibilityFilter selector(renderable_list);
4925 scene->for_each_if(selector, applicator);
4926 renderer->end();
4927
4928 display_buffer.post_update();
4929
4930 // This is a frig to avoid lp:1286190
4931- if (size_of_last_pass)
4932- {
4933- uncomposited_buffers |= saved_resources.empty();
4934- }
4935+ if (last_pass_rendered_anything && renderable_list.empty())
4936+ uncomposited_buffers = true;
4937
4938- size_of_last_pass = saved_resources.size();
4939+ last_pass_rendered_anything = !renderable_list.empty();
4940 // End of frig
4941 }
4942
4943 report->finished_frame(bypassed, this);
4944 return uncomposited_buffers;
4945 }
4946-
4947
4948=== modified file 'src/server/compositor/default_display_buffer_compositor.h'
4949--- src/server/compositor/default_display_buffer_compositor.h 2014-03-07 03:15:55 +0000
4950+++ src/server/compositor/default_display_buffer_compositor.h 2014-04-02 18:58:27 +0000
4951@@ -53,8 +53,7 @@
4952 std::shared_ptr<Renderer> const renderer;
4953 std::shared_ptr<CompositorReport> const report;
4954
4955- int size_of_last_pass = 0;
4956- unsigned long local_frameno;
4957+ bool last_pass_rendered_anything;
4958 };
4959
4960 }
4961
4962=== modified file 'src/server/compositor/gl_renderer.cpp'
4963--- src/server/compositor/gl_renderer.cpp 2014-03-17 07:35:22 +0000
4964+++ src/server/compositor/gl_renderer.cpp 2014-04-02 18:58:27 +0000
4965@@ -48,7 +48,6 @@
4966 "void main() {\n"
4967 " vec4 mid = vec4(centre, 0.0, 0.0);\n"
4968 " vec4 transformed = (transform * (vec4(position, 1.0) - mid)) + mid;\n"
4969- " transformed.z = 0.0;\n" // avoid clipping while we lack depth/perspective
4970 " gl_Position = display_transform * screen_to_gl_coords * transformed;\n"
4971 " v_texcoord = texcoord;\n"
4972 "}\n"
4973@@ -184,8 +183,9 @@
4974 glDeleteTextures(1, &t.second.id);
4975 }
4976
4977-GLenum mc::GLRenderer::tessellate(graphics::Renderable const& renderable,
4978- std::vector<Vertex>& vertices) const
4979+void mc::GLRenderer::tessellate(std::vector<Primitive>& primitives,
4980+ graphics::Renderable const& renderable,
4981+ geometry::Size const& buf_size) const
4982 {
4983 auto const& rect = renderable.screen_position();
4984 GLfloat left = rect.top_left.x.as_int();
4985@@ -193,12 +193,22 @@
4986 GLfloat top = rect.top_left.y.as_int();
4987 GLfloat bottom = top + rect.size.height.as_int();
4988
4989+ primitives.resize(1);
4990+ auto& client = primitives[0];
4991+ client.tex_id = 0;
4992+ client.type = GL_TRIANGLE_STRIP;
4993+
4994+ GLfloat tex_right = static_cast<GLfloat>(rect.size.width.as_int()) /
4995+ buf_size.width.as_int();
4996+ GLfloat tex_bottom = static_cast<GLfloat>(rect.size.height.as_int()) /
4997+ buf_size.height.as_int();
4998+
4999+ auto& vertices = client.vertices;
5000 vertices.resize(4);
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches